Previous 15994 Revisions Next

r1294 Monday 19th November, 2007 at 14:34:26 UTC by Nathan Woods
Updated to MAME 0.121 core
[ROOT]whatsnew.txt
[docs]messnew.txt
[src/emu]attotime.c* attotime.h* cheat.c cpuexec.c cpuexec.h cpuintrf.c driver.c driver.h eigccx86.h eminline.h emu.mak emuopts.h info.c mame.c profiler.c sound.c streams.c streams.h timer.c timer.h ui.c uimenu.c validity.c video.c video.h
[src/emu/cpu]cpu.mak
[src/emu/cpu/ccpu]ccpu.c
[src/emu/cpu/dsp56k]dsp56k.c
[src/emu/cpu/f8]f3853.c
[src/emu/cpu/h83002]h8periph.c h8priv.h
[src/emu/cpu/m37710]m37710.c m37710cm.h
[src/emu/cpu/m6800]m6800.c
[src/emu/cpu/mips]mips3com.c mips3com.h
[src/emu/cpu/powerpc]ppc.c ppcdrc.c
[src/emu/cpu/sc61860]sc61860.c
[src/emu/cpu/sh2]sh2.c
[src/emu/cpu/sh4]sh4.c
[src/emu/cpu/tlcs90]tlcs90.c
[src/emu/cpu/tms32031]tms32031.c tms32031.h
[src/emu/cpu/tms34010]tms34010.c
[src/emu/cpu/tms9900]99xxcore.h
[src/emu/debug]debugcpu.c
[src/emu/machine]6522via.c 6526cia.c 6532riot.c 6840ptm.c 6850acia.c 74123.c 8042kbdc.c 8237dma.c am53cf96.c ds2401.c ds2404.c idectrl.c intelfsh.c laserdsc.c mb3773.c mc146818.c pc16552d.c pd4990a.c pic8259.c pit8253.c rtc65271.c scsihd.c timekpr.c tmp68301.c wd33c93.c z80ctc.c z80ctc.h z80sio.c
[src/emu/sound]2151intf.c 2203intf.c 2608intf.c 2610intf.c 2612intf.c 262intf.c 3812intf.c es5503.c fm.c fm.h fmopl.c fmopl.h ics2115.c k053260.c k054539.c msm5205.c nes_apu.c pokey.c scsp.c sp0250.c upd7759.c ym2151.c ym2413.c ymf262.c ymf262.h ymf271.c ymf278b.c ymz280b.c
[src/emu/video]cdp1869.c crtc6845.c rgbvmx.h tms34061.c vooddefs.h voodoo.c
[src/mame]mame.mak mamedriv.c
[src/mame/audio]8080bw.c amiga.c atarijsa.c cage.c cchasm.c cinemat.c dcs.c exidy.c exidy440.c galaxian.c geebee.c gottlieb.c irem.c jaguar.c leland.c mcr.c n8080.c namco54.c rockola.c segag80r.c segasnd.c senjyo.c snes.c starwars.c system16.c taito_en.c targ.c tiamc1.c turbo.c vicdual.c warpwarp.c williams.c
[src/mame/drivers]acefruit.c actfancr.c aerofgt.c afega.c aleck64.c alg.c ampoker.c arcadia.c artmagic.c asterix.c astrof.c asuka.c atarifb.c atarisy1.c atetris.c backfire.c bagman.c battlane.c beaminv.c beathead.c berzerk.c bestleag.c bfcobra.c bfm_sc2.c bionicc.c bishi.c blockade.c boxer.c brkthru.c btime.c btoads.c bublbobl.c bwing.c cabal.c canyon.c capbowl.c carrera.c cave.c cball.c cbuster.c ccastles.c centiped.c chinsan.c cidelsa.c circus.c cischeat.c clayshoo.c cliffhgr.c cloud9.c clshroad.c cninja.c cojag.c combatsc.c coolpool.c coolridr.c cps1.c cps2.c cps3.c crgolf.c crshrace.c crystal.c cshooter.c cubocd32.c cultures.c cvs.c darkhors.c darkmist.c darkseal.c dassault.c ddenlovr.c ddragon.c dec0.c dec8.c deco156.c deco32.c deco_mlc.c decocass.c destroyr.c discoboy.c dkong.c dlair.c dmndrby.c dragrace.c dreamwld.c drmicro.c dunhuang.c dwarfd.c dynax.c egghunt.c enigma2.c equites.c ertictac.c esd16.c esh.c exctsccr.c exterm.c fcrash.c fgoal.c finalizr.c firebeat.c firetrk.c flyball.c foodf.c funkyjet.c fuukifg2.c fuukifg3.c gaelco.c gaelco3d.c galaxia.c galpani2.c galpani3.c gameplan.c gcpinbal.c genesis.c ghosteo.c gijoe.c ginganin.c glass.c gottlieb.c gpworld.c gridlee.c groundfx.c gstriker.c gunbustr.c halleys.c hanaroku.c harddriv.c higemaru.c hitme.c hng64.c homedata.c hornet.c hyprduel.c igs_blit.c itech32.c itech8.c jack.c jackal.c jchan.c jedi.c jpmimpct.c kaneko16.c kinst.c kncljoe.c konamigq.c konamigv.c konamigx.c kopunch.c ksys573.c laserbas.c lemmings.c lethal.c lethalj.c lgp.c liberate.c littlerb.c looping.c ltcasino.c m107.c m62.c m92.c macrossp.c magmax.c malzak.c marineb.c mario.c mastboy.c maxaflex.c mcr68.c mediagx.c megadriv.c megaplay.c megatech.c metlclsh.c metro.c mgolf.c micro3d.c midvunit.c midzeus.c mirage.c missile.c mjkjidai.c mjsister.c mnight.c model1.c model2.c model3.c mogura.c moo.c mouser.c mpatrol.c mpu4.c mquake.c mrdo.c mrflea.c ms32.c mustache.c mw8080bw.c mystston.c mystwarr.c namcofl.c namcona1.c namconb1.c namcond1.c namcos11.c namcos12.c namcos21.c namcos22.c namcos23.c naomi.c naughtyb.c nemesis.c neodrvr.c neogeo.c ninjakd2.c nitedrvr.c onetwo.c orbit.c othunder.c pacman.c parodius.c pbaction.c peplus.c pgm.c pipeline.c pkscram.c plygonet.c pntnpuzl.c policetr.c polyplay.c ppmast93.c progolf.c psychic5.c pturn.c qdrmfgp.c rabbit.c redclash.c renegade.c rockola.c rohga.c rollerg.c runaway.c sandscrp.c sangho.c sauro.c sbrkout.c scramble.c scregg.c seattle.c segae.c segag80r.c segag80v.c segald.c segaorun.c segas16a.c segas16b.c segas18.c segas32.c segaxbd.c segaybd.c seibuspi.c senjyo.c seta.c shanghai.c shaolins.c simpl156.c simpsons.c skullxbo.c skyarmy.c skychut.c skylncr.c skyraid.c slapshot.c snk.c snowbros.c spacefb.c splash.c sprint4.c sprint8.c spy.c srmp6.c ssfindo.c sshangha.c sslam.c sspeedr.c ssv.c st0016.c stadhero.c starfire.c starwars.c statriv2.c stv.c stvinit.c suna16.c suna8.c supbtime.c superqix.c suprloco.c suprnova.c suprslam.c system1.c system24.c tagteam.c taito_b.c taito_f2.c taito_f3.c taito_z.c tank8.c tankbatt.c tatsumi.c tecmosys.c tehkanwc.c tempest.c tetrisp2.c thayers.c thunderj.c thunderx.c tiamc1.c tickee.c tmaster.c tmnt.c tnzs.c toaplan2.c topspeed.c toypop.c travrusa.c troangel.c truco.c trucocl.c trvquest.c tubep.c tugboat.c tumbleb.c tumblep.c turbo.c tx1.c ultratnk.c ultrsprt.c undrfire.c upscope.c vamphalf.c vaportra.c vegas.c vendetta.c vicdual.c videopin.c vmetal.c wecleman.c welltris.c wgp.c wheelfir.c wilytowr.c wiz.c wolfpack.c wwfsstar.c xain.c xexex.c xxmissio.c yard.c yiear.c zac2650.c zn.c zr107.c
[src/mame/includes]amiga.h mcr.h midzeus.h
[src/mame/machine]amiga.c arkanoid.c asic65.c atarigen.c balsente.c cubocd32.c dec0.c decocass.c decocass.h equites.c exctsccr.c gaelco2.c galaxian.c harddriv.c irobot.c kabuki.c kaneko16.c konamiic.c konppc.c leland.c mcr.c meters.c* meters.h* mhavoc.c midwayic.c model1.c mw8080bw.c n64.c namco50.c namcoio.c namcos1.c namcos2.c nb1413m3.c opwolf.c pcshare.c pgmcrypt.c pitnrun.c playch10.c psx.c qix.c rainbow.c s16fd.c s24fd.c scudsp.c segas32.c slapfght.c slapstic.c slikshot.c snes.c steppers.c steppers.h stfight.c stvcd.c tait8741.c taitosj.c ticket.c tx1.c vertigo.c volfied.c vsnes.c williams.c xevious.c
[src/mame/video]airbustr.c angelkds.c argus.c armedf.c artmagic.c asterix.c astrocde.c asuka.c atari.c atarimo.c atarirle.c atarisy1.c atarisy2.c avgdvg.c blstroid.c brkthru.c buggychl.c cave.c cchasm.c changela.c cps1.c crshrace.c csk.c dcheese.c dday.c deco32.c decocass.c dkong.c dynax.c esd16.c exctsccr.c exidy.c exidy440.c flstory.c freekick.c fromance.c gaiden.c galaxian.c gcpinbal.c genesis.c gstriker.c gsword.c gtia.c gticlub.c homerun.c hyhoo.c hyprduel.c iqblock.c itech32.c itech8.c jackal.c jaguar.c kan_pand.c kaneko16.c kickgoal.c konamiic.c ksayakyu.c ladyfrog.c leland.c lethalj.c lordgun.c m107.c m62.c m92.c mcatadv.c mcr3.c megasys1.c metro.c midtunit.c midvunit.c midyunit.c mjsister.c mnight.c model2.c momoko.c moo.c ms32.c n8080.c namcofl.c namcos2.c nbmj8688.c nbmj8891.c nbmj8991.c nbmj9195.c neogeo.c ninjakid.c niyanpai.c nycaptor.c omegaf.c pastelg.c pitnrun.c powerins.c ppu2c0x.c psikyosh.c psx.c psychic5.c qix.c renegade.c route16.c rpunch.c sbasketb.c segag80r.c segag80v.c segaic16.c segas32.c segasyse.c slapshot.c sprint8.c ssv.c stvvdp1.c stvvdp2.c suna16.c suna8.c system1.c system16.c taitoic.c taitosj.c tank8.c tatsumi.c tceptor.c thief.c tiamc1.c tickee.c toaplan1.c toaplan2.c triplhnt.c tsamurai.c tubep.c usgames.c victory.c vigilant.c wecleman.c wgp.c
[src/mess]image.c inputx.c inputx.h mess.mak
[src/mess/audio]dave.c lynx.c mea8000.c svision.c t6721.c
[src/mess/devices]bitbngr.c cassette.c flopdrv.c snapquik.c sonydriv.c thomflop.c
[src/mess/drivers]a2600.c a310.c abc80.c abc80x.c adam.c amiga.c amstrad.c apple1.c atari.c atarist.c avigo.c bbc.c coleco.c crvision.c dgn_beta.c einstein.c exelv.c exidy.c glasgow.c ip22.c mac.c mephisto.c mk1.c mk2.c mz700.c nc.c nes.c pcw.c pcw16.c psx.c ql.c saturn.c spectrum.c studio2.c super80.c svision.c tm990189.c tmc1800.c tmc2000e.c tutor.c vip.c x68k.c z88.c zx.c
[src/mess/formats]mz_cas.c thom_cas.c thom_dsk.c
[src/mess/includes]apple1.h cbm.h cbmdrive.h coco.h vectrex.h zx.h
[src/mess/machine]6551.c 68901mfp.c 99_dsk.c amigacd.c amigacrt.c amigafdc.c amigakbd.c apple1.c apple2.c apple2gs.c applefdc.c at29040.c atom.c ay3600.c bbc.c c65.c cbmb.c cbmdrive.c centroni.c coco.c compis.c corvushd.c dai.c electron.c europc.c gamecom.c gb.c geneve.c hd63450.c hd63450.h hp48.c i8271.c ibmpc.c intv.c kc.c kim1.c lisa.c lviv.c lynx.c mac.c matsucd.c mc6843.c mc6846.c mc6854.c mfm.c microtan.c mm58274c.c mz700.c nec765.c nes_mmc.c odyssey2.c oric.c osborne1.c pc1251.c pc1350.c pc1401.c pc1403.c pc8801.c pc_hdc.c pc_joy.c pc_mouse.c pc_turbo.c pce.c pcf8593.c pclpt.c pdp1.c pet.c pmd85.c pokemini.c rp5c15.c rriot.c serial.c sgi.c sms.c tc8521.c thomson.c ti85.c ti990.c ti99_4x.c tms5501.c tms9901.c tms9902.c trs80.c tx0.c uart8250.c upd7002.c vc1541.c vc20tape.c vectrex.c wd17xx.c wswan.c z80dart.c zx.c
[src/mess/tools/messtest]core.c core.h testmess.c tstutils.c
[src/mess/video]911_vdt.c abc80.c aim65.c apple1.c apple2.c atarist.c border.c cdp1861.c cdp1864.c coco3.c crtc6845.c gb.c kc.c m6845.c m6847.c m6847.h mz700.c odyssey2.c oric.c pc_cga.c pc_mda.c pc_vga.c saa5050.c smsvdp.c spectrum.c ted7360.c thomson.c vdc8563.c vectrex.c vic4567.c vic6560.c vic6567.c x68k.c zx.c zx8301.c
[src/osd/windows]drawd3d.c drawdd.c input.c osinline.h
[src/osd/winui]properties.c

src/mame/audio/cchasm.c
r1293r1294
182182   ctc_intf.baseclock = machine->drv->cpu[1].clock;
183183   z80ctc_init (0, &ctc_intf);
184184
185   mame_timer_pulse(make_mame_time(0, machine->screen[0].refresh), 0, cchasm_sh_update);
185   timer_pulse(attotime_make(0, machine->screen[0].refresh), 0, cchasm_sh_update);
186186}
187187
188188
src/mame/audio/warpwarp.c
r1293r1294
2323static int music2_latch = 0;
2424static int sound_signal = 0;
2525static int sound_volume = 0;
26static mame_timer *sound_volume_timer = NULL;
26static emu_timer *sound_volume_timer = NULL;
2727static int music_signal = 0;
2828static int music_volume = 0;
29static mame_timer *music_volume_timer = NULL;
29static emu_timer *music_volume_timer = NULL;
3030static int noise = 0;
3131
3232static TIMER_CALLBACK( sound_volume_decay )
r1293r1294
5454         * discharge C90(?) (1uF) through R13||R14 (22k||47k)
5555         * 0.639 * 15k * 1uF -> 0.9585s
5656         */
57        mame_time period = scale_down_mame_time(scale_up_mame_time(MAME_TIME_IN_HZ(32768), 95850), 100000);
58      mame_timer_adjust(sound_volume_timer, period, 0, period);
57        attotime period = attotime_div(attotime_mul(ATTOTIME_IN_HZ(32768), 95850), 100000);
58      timer_adjust(sound_volume_timer, period, 0, period);
5959   }
6060   else
6161   {
r1293r1294
6666         * ...but this is not very realistic for the game sound :(
6767         * maybe there _is_ a discharge through the diode D17?
6868         */
69//      mame_time period = scale_down_mame_time(scale_up_mame_time(MAME_TIME_IN_HZ(32768), 702900), 100000);
70        mame_time period = scale_down_mame_time(scale_up_mame_time(MAME_TIME_IN_HZ(32768), 191700), 100000);
71      mame_timer_adjust(sound_volume_timer, period, 0, period);
69//      attotime period = attotime_div(attotime_mul(ATTOTIME_IN_HZ(32768), 702900), 100000);
70        attotime period = attotime_div(attotime_mul(ATTOTIME_IN_HZ(32768), 191700), 100000);
71      timer_adjust(sound_volume_timer, period, 0, period);
7272    }
7373}
7474
r1293r1294
102102         * 0.639 * 15k * 10uF -> 9.585s
103103         * ...I'm sure this is off by one number of magnitude :/
104104         */
105        mame_time period = scale_down_mame_time(scale_up_mame_time(MAME_TIME_IN_HZ(32768), 95850), 100000);
106      mame_timer_adjust(music_volume_timer, period, 0, period);
105        attotime period = attotime_div(attotime_mul(ATTOTIME_IN_HZ(32768), 95850), 100000);
106      timer_adjust(music_volume_timer, period, 0, period);
107107   }
108108   else
109109   {
r1293r1294
112112         * discharge C95(?) (10uF) through R14 (47k)
113113         * 0.639 * 47k * 10uF -> 30.033s
114114         */
115//      mame_time period = scale_down_mame_time(scale_up_mame_time(MAME_TIME_IN_HZ(32768), 3003300), 100000);
116        mame_time period = scale_down_mame_time(scale_up_mame_time(MAME_TIME_IN_HZ(32768),  300330), 100000);
117      mame_timer_adjust(music_volume_timer, period, 0, period);
115//      attotime period = attotime_div(attotime_mul(ATTOTIME_IN_HZ(32768), 3003300), 100000);
116        attotime period = attotime_div(attotime_mul(ATTOTIME_IN_HZ(32768),  300330), 100000);
117      timer_adjust(music_volume_timer, period, 0, period);
118118   }
119119
120120}
r1293r1294
215215
216216   channel = stream_create(0, 1, CLOCK_16H, NULL, warpwarp_sound_update);
217217
218   sound_volume_timer = mame_timer_alloc(sound_volume_decay);
219   music_volume_timer = mame_timer_alloc(music_volume_decay);
218   sound_volume_timer = timer_alloc(sound_volume_decay);
219   music_volume_timer = timer_alloc(music_volume_decay);
220220    return auto_malloc(1);
221221}
src/mame/audio/snes.c
r1293r1294
3434{
3535   UINT8 enabled;
3636   UINT16 counter;
37   mame_timer *timer;
37   emu_timer *timer;
3838} timers[3];
3939static sound_stream *channel;
4040static UINT8 DSPregs[256];      /* DSP registers */
41UINT8 snes_ipl_region[64];   /* SPC top 64 bytes */
41static UINT8 snes_ipl_region[64];   /* SPC top 64 bytes */
4242
4343static const int gauss[]=
4444{
r1293r1294
11531153   channel = stream_create( 0, 2, 32000, NULL, snes_sh_update );
11541154
11551155   /* Initialize the timers */
1156   timers[0].timer = mame_timer_alloc( snes_spc_timer );
1157   mame_timer_adjust( timers[0].timer, MAME_TIME_IN_HZ(8000), 0, MAME_TIME_IN_HZ(8000) );
1158   mame_timer_enable( timers[0].timer, 0 );
1159   timers[1].timer = mame_timer_alloc( snes_spc_timer );
1160   mame_timer_adjust( timers[1].timer, MAME_TIME_IN_HZ(8000), 1, MAME_TIME_IN_HZ(8000) );
1161   mame_timer_enable( timers[1].timer, 0 );
1162   timers[2].timer = mame_timer_alloc( snes_spc_timer );
1163   mame_timer_adjust( timers[2].timer, MAME_TIME_IN_HZ(64000), 2, MAME_TIME_IN_HZ(64000) );
1164   mame_timer_enable( timers[2].timer, 0 );
1156   timers[0].timer = timer_alloc( snes_spc_timer );
1157   timer_adjust( timers[0].timer, ATTOTIME_IN_HZ(8000), 0, ATTOTIME_IN_HZ(8000) );
1158   timer_enable( timers[0].timer, 0 );
1159   timers[1].timer = timer_alloc( snes_spc_timer );
1160   timer_adjust( timers[1].timer, ATTOTIME_IN_HZ(8000), 1, ATTOTIME_IN_HZ(8000) );
1161   timer_enable( timers[1].timer, 0 );
1162   timers[2].timer = timer_alloc( snes_spc_timer );
1163   timer_adjust( timers[2].timer, ATTOTIME_IN_HZ(64000), 2, ATTOTIME_IN_HZ(64000) );
1164   timer_enable( timers[2].timer, 0 );
11651165
11661166   DSP_Reset();
11671167
r1293r1294
12701270            spc_ram[0xff] = 0;
12711271         }
12721272         timers[0].enabled = data & 0x1;
1273         mame_timer_enable( timers[0].timer, timers[0].enabled );
1273         timer_enable( timers[0].timer, timers[0].enabled );
12741274         timers[1].enabled = (data & 0x2) >> 1;
1275         mame_timer_enable( timers[1].timer, timers[1].enabled );
1275         timer_enable( timers[1].timer, timers[1].enabled );
12761276         timers[2].enabled = (data & 0x4) >> 2;
1277         mame_timer_enable( timers[2].timer, timers[2].enabled );
1277         timer_enable( timers[2].timer, timers[2].enabled );
12781278         if( data & 0x10 )
12791279         {
12801280            spc_port_in[0] = 0;
r1293r1294
13091309      case 0x7:      /* Port 3 */
13101310//          mame_printf_debug("SPC: %02x to APU @ %d (PC=%x)\n", data, offset&3, activecpu_get_pc());
13111311         spc_port_out[offset - 4] = data;
1312         cpu_boost_interleave(time_zero, MAME_TIME_IN_USEC(20));
1312         cpu_boost_interleave(attotime_zero, ATTOTIME_IN_USEC(20));
13131313         break;
13141314      case 0xA:      /* Timer 0 */
13151315      case 0xB:      /* Timer 1 */
src/mame/audio/jaguar.c
r1293r1294
166166static UINT16 dsp_regs[DSP_REGS];
167167
168168static UINT16 serial_frequency;
169static mame_timer *serial_timer;
169static emu_timer *serial_timer;
170170
171171static UINT8 gpu_irq_state;
172172
r1293r1294
285285void cojag_sound_reset(void)
286286{
287287#if ENABLE_SPEEDUP_HACKS
288   serial_timer = mame_timer_alloc(serial_chunky_callback);
288   serial_timer = timer_alloc(serial_chunky_callback);
289289#else
290   serial_timer = mame_timer_alloc(serial_callback);
290   serial_timer = timer_alloc(serial_callback);
291291#endif
292292}
293293
r1293r1294
461461            logerror("Unexpected write to SMODE = %X\n", data);
462462         if ((data & 0x3f) == 0x15)
463463         {
464            mame_time rate = scale_up_mame_time(MAME_TIME_IN_HZ(26000000), 32 * 2 * (serial_frequency + 1));
465            mame_timer_adjust(serial_timer, rate, 0, rate);
464            attotime rate = attotime_mul(ATTOTIME_IN_HZ(26000000), 32 * 2 * (serial_frequency + 1));
465            timer_adjust(serial_timer, rate, 0, rate);
466466         }
467467         break;
468468
src/mame/audio/n8080.c
r1293r1294
1313
1414static int n8080_hardware;
1515
16static mame_timer* sound_timer[3];
16static emu_timer* sound_timer[3];
1717
1818static int helifire_dac_phase;
1919
r1293r1294
149149}
150150
151151
152static void start_mono_flop(int n, mame_time expire)
152static void start_mono_flop(int n, attotime expire)
153153{
154154   mono_flop[n] = 1;
155155
156156   update_SN76477_status();
157157
158   mame_timer_adjust(sound_timer[n], expire, n, time_zero);
158   timer_adjust(sound_timer[n], expire, n, attotime_zero);
159159}
160160
161161
r1293r1294
165165
166166   update_SN76477_status();
167167
168   mame_timer_adjust(sound_timer[n], time_never, n, time_never);
168   timer_adjust(sound_timer[n], attotime_never, n, attotime_never);
169169}
170170
171171
r1293r1294
189189   }
190190   if (changes & (1 << 0x3))
191191   {
192      start_mono_flop(0, MAME_TIME_IN_USEC(550 * 36 * 100));
192      start_mono_flop(0, ATTOTIME_IN_USEC(550 * 36 * 100));
193193   }
194194   if (changes & (1 << 0x6))
195195   {
196      start_mono_flop(1, MAME_TIME_IN_USEC(550 * 22 * 33));
196      start_mono_flop(1, ATTOTIME_IN_USEC(550 * 22 * 33));
197197   }
198198   if (changes & (1 << 0x4))
199199   {
200      start_mono_flop(2, MAME_TIME_IN_USEC(550 * 22 * 33));
200      start_mono_flop(2, ATTOTIME_IN_USEC(550 * 22 * 33));
201201   }
202202   if (changes & ((1 << 0x2) | (1 << 0x3) | (1 << 0x5)))
203203   {
r1293r1294
216216   }
217217   if (changes & (1 << 0x6))
218218   {
219      start_mono_flop(0, MAME_TIME_IN_USEC(550 * 33 * 33));
219      start_mono_flop(0, ATTOTIME_IN_USEC(550 * 33 * 33));
220220   }
221221   if (changes & (1 << 0x4))
222222   {
223      start_mono_flop(1, MAME_TIME_IN_USEC(550 * 33 * 33));
223      start_mono_flop(1, ATTOTIME_IN_USEC(550 * 33 * 33));
224224   }
225225   if (changes & ((1 << 0x2) | (1 << 0x3) | (1 << 0x5)))
226226   {
r1293r1294
434434      helifire_dac_timing = DECAY_RATE * log(helifire_dac_volume);
435435   }
436436
437   helifire_dac_timing += mame_time_to_double(mame_timer_get_time());
437   helifire_dac_timing += attotime_to_double(timer_get_time());
438438}
439439
440440
r1293r1294
444444
445445   if (mono_flop[2])
446446   {
447      voltage = 5 * (1 - exp(- mame_time_to_double(mame_timer_timeelapsed(sound_timer[2])) / 0.22));
447      voltage = 5 * (1 - exp(- attotime_to_double(timer_timeelapsed(sound_timer[2])) / 0.22));
448448   }
449449
450450   SN76477_vco_voltage_w(0, voltage);
r1293r1294
453453
454454static TIMER_CALLBACK( helifire_dac_volume_timer )
455455{
456   double t = helifire_dac_timing - mame_time_to_double(mame_timer_get_time());
456   double t = helifire_dac_timing - attotime_to_double(timer_get_time());
457457
458458   if (helifire_dac_phase)
459459   {
r1293r1294
470470{
471471   n8080_hardware = 1;
472472
473   mame_timer_pulse(MAME_TIME_IN_HZ(1000), 0, spacefev_vco_voltage_timer);
473   timer_pulse(ATTOTIME_IN_HZ(1000), 0, spacefev_vco_voltage_timer);
474474
475   sound_timer[0] = mame_timer_alloc(stop_mono_flop_callback);
476   sound_timer[1] = mame_timer_alloc(stop_mono_flop_callback);
477   sound_timer[2] = mame_timer_alloc(stop_mono_flop_callback);
475   sound_timer[0] = timer_alloc(stop_mono_flop_callback);
476   sound_timer[1] = timer_alloc(stop_mono_flop_callback);
477   sound_timer[2] = timer_alloc(stop_mono_flop_callback);
478478
479479   mono_flop[0] = 0;
480480   mono_flop[1] = 0;
r1293r1294
489489{
490490   n8080_hardware = 2;
491491
492   sound_timer[0] = mame_timer_alloc(stop_mono_flop_callback);
493   sound_timer[1] = mame_timer_alloc(stop_mono_flop_callback);
492   sound_timer[0] = timer_alloc(stop_mono_flop_callback);
493   sound_timer[1] = timer_alloc(stop_mono_flop_callback);
494494
495495   mono_flop[0] = 0;
496496   mono_flop[1] = 0;
r1293r1294
504504{
505505   n8080_hardware = 3;
506506
507   mame_timer_pulse(MAME_TIME_IN_HZ(1000), 0, helifire_dac_volume_timer);
507   timer_pulse(ATTOTIME_IN_HZ(1000), 0, helifire_dac_volume_timer);
508508
509509   helifire_dac_volume = 1;
510510   helifire_dac_timing = 0;
src/mame/audio/amiga.c
r1293r1294
4444typedef struct _audio_channel audio_channel;
4545struct _audio_channel
4646{
47   mame_timer *   irq_timer;
47   emu_timer *   irq_timer;
4848   UINT32         curlocation;
4949   UINT16         curlength;
5050   UINT16         curticks;
r1293r1294
9090{
9191   chan->curlocation = CUSTOM_REG_LONG(REG_AUD0LCH + chan->index * 8);
9292   chan->curlength = CUSTOM_REG(REG_AUD0LEN + chan->index * 8);
93   mame_timer_adjust(chan->irq_timer, MAME_TIME_IN_HZ(15750), chan->index, time_zero);
93   timer_adjust(chan->irq_timer, ATTOTIME_IN_HZ(15750), chan->index, attotime_zero);
9494   LOG(("dma_reload(%d): offs=%05X len=%04X\n", chan->index, chan->curlocation, chan->curlength));
9595}
9696
r1293r1294
271271   for (i = 0; i < 4; i++)
272272   {
273273      audio_state->channel[i].index = i;
274      audio_state->channel[i].irq_timer = mame_timer_alloc(signal_irq);
274      audio_state->channel[i].irq_timer = timer_alloc(signal_irq);
275275   }
276276
277277   /* create the stream */
src/mame/audio/cinemat.c
r1293r1294
15201520}
15211521
15221522
1523ADDRESS_MAP_START( demon_sound_map, ADDRESS_SPACE_PROGRAM, 8 )
1523static ADDRESS_MAP_START( demon_sound_map, ADDRESS_SPACE_PROGRAM, 8 )
15241524   AM_RANGE(0x0000, 0x1fff) AM_ROM
15251525   AM_RANGE(0x3000, 0x33ff) AM_RAM
15261526   AM_RANGE(0x4001, 0x4001) AM_READ(AY8910_read_port_0_r)
r1293r1294
15361536ADDRESS_MAP_END
15371537
15381538
1539ADDRESS_MAP_START( demon_sound_ports, ADDRESS_SPACE_IO, 8 )
1539static ADDRESS_MAP_START( demon_sound_ports, ADDRESS_SPACE_IO, 8 )
15401540   ADDRESS_MAP_FLAGS( AMEF_ABITS(8) )
15411541   AM_RANGE(0x00, 0x03) AM_WRITE(z80ctc_0_w)
15421542   AM_RANGE(0x1c, 0x1f) AM_WRITE(z80ctc_0_w)
src/mame/audio/galaxian.c
r1293r1294
3737#define LOG(x)
3838#endif
3939
40static mame_timer *lfotimer = NULL;
40static emu_timer *lfotimer = NULL;
4141static INT32 freq = MAXFREQ;
4242
4343#define STEP 1
r1293r1294
6969#define CHANNEL_SHOOT   1
7070#define CHANNEL_LFO      2
7171static sound_stream * tone_stream;
72static mame_timer *noisetimer;
72static emu_timer *noisetimer;
7373
7474static TIMER_CALLBACK( lfo_timer_cb );
7575static TIMER_CALLBACK( galaxian_sh_update );
r1293r1294
363363   sample_set_volume(CHANNEL_LFO+2,0);
364364   sample_start_raw(CHANNEL_LFO+2,backgroundwave,sizeof(backgroundwave)/2,1000,1);
365365
366   noisetimer = mame_timer_alloc(noise_timer_cb);
367   mame_timer_adjust(noisetimer, MAME_TIME_IN_NSEC((155000+22000)/100*693*22), 0, MAME_TIME_IN_NSEC((155000+22000)/100*693*22));
366   noisetimer = timer_alloc(noise_timer_cb);
367   timer_adjust(noisetimer, ATTOTIME_IN_NSEC((155000+22000)/100*693*22), 0, ATTOTIME_IN_NSEC((155000+22000)/100*693*22));
368368
369   lfotimer = mame_timer_alloc(lfo_timer_cb);
369   lfotimer = timer_alloc(lfo_timer_cb);
370370
371   mame_timer_pulse(make_mame_time(0, Machine->screen[0].refresh), 0, galaxian_sh_update);
371   timer_pulse(attotime_make(0, Machine->screen[0].refresh), 0, galaxian_sh_update);
372372
373373   state_save_register_global(freq);
374374   state_save_register_global(noise_enable);
r1293r1294
446446#undef Vbe
447447#undef Vcc
448448   logerror("lfo timer bits:%d%d%d%d r1:%d, r2:%d, re: %d, td: %9.2fsec\n", lfobit[0], lfobit[1], lfobit[2], lfobit[3], (int)r1, (int)r2, (int)Re, td);
449   mame_timer_adjust(lfotimer, make_mame_time(0, MAX_SUBSECONDS / (MAXFREQ-MINFREQ) * td), 0, make_mame_time(0, MAX_SUBSECONDS / (MAXFREQ-MINFREQ) * td));
449   timer_adjust(lfotimer, attotime_make(0, ATTOSECONDS_PER_SECOND / (MAXFREQ-MINFREQ) * td), 0, attotime_make(0, ATTOSECONDS_PER_SECOND / (MAXFREQ-MINFREQ) * td));
450450#else
451451   double r0, r1, rx = 100000.0;
452452
r1293r1294
503503   rx = rx + 2000000.0 * r0 / (r0+r1);
504504
505505   LOG(("lfotimer bits:%d%d%d%d r0:%d, r1:%d, rx: %d, time: %9.2fus\n", lfobit[3], lfobit[2], lfobit[1], lfobit[0], (int)r0, (int)r1, (int)rx, 0.639 * rx));
506   mame_timer_adjust(lfotimer, make_mame_time(0, MAX_SUBSECONDS / 1000000000 / (MAXFREQ-MINFREQ) * 639 * rx), 0, make_mame_time(0, MAX_SUBSECONDS / 1000000000 / (MAXFREQ-MINFREQ) * 639 * rx));
506   timer_adjust(lfotimer, attotime_make(0, ATTOSECONDS_PER_SECOND / 1000000000 / (MAXFREQ-MINFREQ) * 639 * rx), 0, attotime_make(0, ATTOSECONDS_PER_SECOND / 1000000000 / (MAXFREQ-MINFREQ) * 639 * rx));
507507#endif
508508}
509509
src/mame/audio/turbo.c
r1293r1294
107107#else
108108
109109   if (((data ^ last_sound_a) & 0x1e) && (last_sound_a & 0x1e) != 0x1e)
110      mame_timer_set(MAME_TIME_IN_HZ(20000), data, update_sound_a);
110      timer_set(ATTOTIME_IN_HZ(20000), data, update_sound_a);
111111   else
112112      update_sound_a(data);
113113
src/mame/audio/atarijsa.c
r1293r1294
729729 *
730730 *************************************/
731731
732ADDRESS_MAP_START( atarijsa1_readmem, ADDRESS_SPACE_PROGRAM, 8 )
732static ADDRESS_MAP_START( atarijsa1_readmem, ADDRESS_SPACE_PROGRAM, 8 )
733733   AM_RANGE(0x0000, 0x1fff) AM_READ(MRA8_RAM)
734734   AM_RANGE(0x2000, 0x2001) AM_READ(YM2151_status_port_0_r)
735735   AM_RANGE(0x2800, 0x2bff) AM_READ(jsa1_io_r)
r1293r1294
737737ADDRESS_MAP_END
738738
739739
740ADDRESS_MAP_START( atarijsa1_writemem, ADDRESS_SPACE_PROGRAM, 8 )
740static ADDRESS_MAP_START( atarijsa1_writemem, ADDRESS_SPACE_PROGRAM, 8 )
741741   AM_RANGE(0x0000, 0x1fff) AM_WRITE(MWA8_RAM)
742742   AM_RANGE(0x2000, 0x2000) AM_WRITE(YM2151_register_port_0_w)
743743   AM_RANGE(0x2001, 0x2001) AM_WRITE(YM2151_data_port_0_w)
r1293r1294
746746ADDRESS_MAP_END
747747
748748
749ADDRESS_MAP_START( atarijsa2_readmem, ADDRESS_SPACE_PROGRAM, 8 )
749static ADDRESS_MAP_START( atarijsa2_readmem, ADDRESS_SPACE_PROGRAM, 8 )
750750   AM_RANGE(0x0000, 0x1fff) AM_READ(MRA8_RAM)
751751   AM_RANGE(0x2000, 0x2001) AM_READ(YM2151_status_port_0_r)
752752   AM_RANGE(0x2800, 0x2bff) AM_READ(jsa2_io_r)
r1293r1294
754754ADDRESS_MAP_END
755755
756756
757ADDRESS_MAP_START( atarijsa2_writemem, ADDRESS_SPACE_PROGRAM, 8 )
757static ADDRESS_MAP_START( atarijsa2_writemem, ADDRESS_SPACE_PROGRAM, 8 )
758758   AM_RANGE(0x0000, 0x1fff) AM_WRITE(MWA8_RAM)
759759   AM_RANGE(0x2000, 0x2000) AM_WRITE(YM2151_register_port_0_w)
760760   AM_RANGE(0x2001, 0x2001) AM_WRITE(YM2151_data_port_0_w)
r1293r1294
764764
765765
766766/* full map verified from schematics and Batman GALs */
767ADDRESS_MAP_START( atarijsa3_map, ADDRESS_SPACE_PROGRAM, 8 )
767static ADDRESS_MAP_START( atarijsa3_map, ADDRESS_SPACE_PROGRAM, 8 )
768768   AM_RANGE(0x0000, 0x1fff) AM_RAM
769769   AM_RANGE(0x2000, 0x2000) AM_MIRROR(0x07fe) AM_WRITE(YM2151_register_port_0_w)
770770   AM_RANGE(0x2001, 0x2001) AM_MIRROR(0x07fe) AM_WRITE(YM2151_data_port_0_w)
r1293r1294
774774ADDRESS_MAP_END
775775
776776
777ADDRESS_MAP_START( atarijsa3s_map, ADDRESS_SPACE_PROGRAM, 8 )
777static ADDRESS_MAP_START( atarijsa3s_map, ADDRESS_SPACE_PROGRAM, 8 )
778778   AM_RANGE(0x0000, 0x1fff) AM_RAM
779779   AM_RANGE(0x2000, 0x2000) AM_MIRROR(0x07fe) AM_WRITE(YM2151_register_port_0_w)
780780   AM_RANGE(0x2001, 0x2001) AM_MIRROR(0x07fe) AM_WRITE(YM2151_data_port_0_w)
src/mame/audio/cage.c
r1293r1294
3434 *************************************/
3535
3636static int cage_cpu;
37static mame_time cage_cpu_h1_clock_period;
37static attotime cage_cpu_h1_clock_period;
3838
3939static UINT8 cpu_to_cage_ready;
4040static UINT8 cage_to_cpu_ready;
4141
4242static void (*cage_irqhandler)(int);
4343
44static mame_time serial_period_per_word;
44static attotime serial_period_per_word;
4545
4646static UINT8 dma_enabled;
4747static UINT8 dma_timer_enabled;
48static mame_timer *dma_timer;
48static emu_timer *dma_timer;
4949
50static UINT8 timer_enabled[2];
51static mame_timer *timer[2];
50static UINT8 cage_timer_enabled[2];
51static emu_timer *timer[2];
5252
5353static UINT32 *tms32031_io_regs;
5454
r1293r1294
153153
154154void cage_init(int boot_region, offs_t speedup)
155155{
156   mame_time cage_cpu_clock_period;
156   attotime cage_cpu_clock_period;
157157
158158   cage_irqhandler = NULL;
159159
r1293r1294
161161   memory_set_bankptr(11, memory_region(boot_region + 1));
162162
163163   cage_cpu = mame_find_cpu_index(Machine, "cage");
164   cage_cpu_clock_period = MAME_TIME_IN_HZ(Machine->drv->cpu[cage_cpu].clock);
165   cage_cpu_h1_clock_period = scale_up_mame_time(cage_cpu_clock_period, 2);
164   cage_cpu_clock_period = ATTOTIME_IN_HZ(Machine->drv->cpu[cage_cpu].clock);
165   cage_cpu_h1_clock_period = attotime_mul(cage_cpu_clock_period, 2);
166166
167   dma_timer = mame_timer_alloc(dma_timer_callback);
168   timer[0] = mame_timer_alloc(timer_callback);
169   timer[1] = mame_timer_alloc(timer_callback);
167   dma_timer = timer_alloc(dma_timer_callback);
168   timer[0] = timer_alloc(timer_callback);
169   timer[1] = timer_alloc(timer_callback);
170170
171171   if (speedup)
172172      speedup_ram = memory_install_write32_handler(cage_cpu, ADDRESS_SPACE_PROGRAM, speedup, speedup, 0, 0, speedup_w);
r1293r1294
201201   {
202202      if (dma_timer_enabled)
203203      {
204         mame_timer_adjust(dma_timer, time_never, 0, time_never);
204         timer_adjust(dma_timer, attotime_never, 0, attotime_never);
205205         dma_timer_enabled = 0;
206206      }
207207      return;
r1293r1294
251251      /* compute the time of the interrupt and set the timer */
252252      if (!dma_timer_enabled)
253253      {
254         mame_time period = scale_up_mame_time(serial_period_per_word, tms32031_io_regs[DMA_TRANSFER_COUNT]);
255         mame_timer_adjust(dma_timer, period, addr, period);
254         attotime period = attotime_mul(serial_period_per_word, tms32031_io_regs[DMA_TRANSFER_COUNT]);
255         timer_adjust(dma_timer, period, addr, period);
256256         dma_timer_enabled = 1;
257257      }
258258   }
r1293r1294
260260   /* see if we turned off */
261261   else if (!enabled && dma_enabled)
262262   {
263      mame_timer_adjust(dma_timer, time_never, 0, time_never);
263      timer_adjust(dma_timer, attotime_never, 0, attotime_never);
264264      dma_timer_enabled = 0;
265265   }
266266
r1293r1294
282282
283283   /* set the interrupt */
284284   cpunum_set_input_line(cage_cpu, TMS32031_TINT0 + which, ASSERT_LINE);
285   timer_enabled[which] = 0;
285   cage_timer_enabled[which] = 0;
286286   update_timer(which);
287287}
288288
r1293r1294
294294   int enabled = ((tms32031_io_regs[base + TIMER0_GLOBAL_CTL] & 0xc0) == 0xc0);
295295
296296   /* see if we turned on */
297   if (enabled && !timer_enabled[which])
297   if (enabled && !cage_timer_enabled[which])
298298   {
299      mame_time period = scale_up_mame_time(cage_cpu_h1_clock_period, 2 * tms32031_io_regs[base + TIMER0_PERIOD]);
299      attotime period = attotime_mul(cage_cpu_h1_clock_period, 2 * tms32031_io_regs[base + TIMER0_PERIOD]);
300300
301301      /* make sure our assumptions are correct */
302302      if (tms32031_io_regs[base + TIMER0_GLOBAL_CTL] != 0x2c1)
303303         logerror("CAGE TIMER%d: unexpected timer config %08X!\n", which, tms32031_io_regs[base + TIMER0_GLOBAL_CTL]);
304304
305      mame_timer_adjust(timer[which], period, which, time_never);
305      timer_adjust(timer[which], period, which, attotime_never);
306306   }
307307
308308   /* see if we turned off */
309   else if (!enabled && timer_enabled[which])
309   else if (!enabled && cage_timer_enabled[which])
310310   {
311      mame_timer_adjust(timer[which], time_never, which, time_never);
311      timer_adjust(timer[which], attotime_never, which, attotime_never);
312312   }
313313
314314   /* set the new state */
315   timer_enabled[which] = enabled;
315   cage_timer_enabled[which] = enabled;
316316}
317317
318318
r1293r1294
325325
326326static void update_serial(void)
327327{
328   mame_time serial_clock_period, bit_clock_period;
328   attotime serial_clock_period, bit_clock_period;
329329   UINT32 freq;
330330
331331   /* we start out at half the H1 frequency (or 2x the H1 period) */
332   serial_clock_period = scale_up_mame_time(cage_cpu_h1_clock_period, 2);
332   serial_clock_period = attotime_mul(cage_cpu_h1_clock_period, 2);
333333
334334   /* if we're in clock mode, muliply by another factor of 2 */
335335   if (tms32031_io_regs[SPORT_GLOBAL_CTL] & 4)
336      serial_clock_period = scale_up_mame_time(serial_clock_period, 2);
336      serial_clock_period = attotime_mul(serial_clock_period, 2);
337337
338338   /* now multiply by the timer period */
339   bit_clock_period = scale_up_mame_time(serial_clock_period, (tms32031_io_regs[SPORT_TIMER_PERIOD] & 0xffff));
339   bit_clock_period = attotime_mul(serial_clock_period, (tms32031_io_regs[SPORT_TIMER_PERIOD] & 0xffff));
340340
341341   /* and times the number of bits per sample */
342   serial_period_per_word = scale_up_mame_time(bit_clock_period, 8 * (((tms32031_io_regs[SPORT_GLOBAL_CTL] >> 18) & 3) + 1));
342   serial_period_per_word = attotime_mul(bit_clock_period, 8 * (((tms32031_io_regs[SPORT_GLOBAL_CTL] >> 18) & 3) + 1));
343343
344344   /* compute the step value to stretch this to the sample_rate */
345   freq = SUBSECONDS_TO_HZ(serial_period_per_word.subseconds) / DAC_BUFFER_CHANNELS;
345   freq = ATTOSECONDS_TO_HZ(serial_period_per_word.attoseconds) / DAC_BUFFER_CHANNELS;
346346   if (freq > 0 && freq < 100000)
347347   {
348348      dmadac_set_frequency(0, DAC_BUFFER_CHANNELS, freq);
r1293r1294
411411
412412      case SPORT_DATA_TX:
413413#if (DAC_BUFFER_CHANNELS == 4)
414         if ((int)SUBSECONDS_TO_HZ(serial_period_per_word.subseconds) == 22050*4 && (tms32031_io_regs[SPORT_RX_CTL] & 0xff) == 0x62)
414         if ((int)ATTOSECONDS_TO_HZ(serial_period_per_word.attoseconds) == 22050*4 && (tms32031_io_regs[SPORT_RX_CTL] & 0xff) == 0x62)
415415            tms32031_io_regs[SPORT_RX_CTL] ^= 0x800;
416416#endif
417417         break;
r1293r1294
549549
550550      dma_enabled = 0;
551551      dma_timer_enabled = 0;
552      mame_timer_adjust(dma_timer, time_never, 0, time_never);
552      timer_adjust(dma_timer, attotime_never, 0, attotime_never);
553553
554      timer_enabled[0] = 0;
555      timer_enabled[1] = 0;
556      mame_timer_adjust(timer[0], time_never, 0, time_never);
557      mame_timer_adjust(timer[1], time_never, 0, time_never);
554      cage_timer_enabled[0] = 0;
555      cage_timer_enabled[1] = 0;
556      timer_adjust(timer[0], attotime_never, 0, attotime_never);
557      timer_adjust(timer[1], attotime_never, 0, attotime_never);
558558
559559      memset(tms32031_io_regs, 0, 0x60 * 4);
560560
src/mame/audio/namco54.c
r1293r1294
128128   // The input clock to the 06XX interface chip is 64H, that is
129129   // 18432000/6/64 = 48kHz, so it makes sense for the irq line to be
130130   // asserted for one clock cycle ~= 21us.
131   mame_timer_set(MAME_TIME_IN_USEC(21), cpunum, namco_54xx_irq_clear);
131   timer_set(ATTOTIME_IN_USEC(21), cpunum, namco_54xx_irq_clear);
132132}
src/mame/audio/senjyo.c
r1293r1294
5454static TIMER_CALLBACK( senjyo_sh_update )
5555{
5656   /* ctc2 timer single tone generator frequency */
57   mame_time period = z80ctc_getperiod (0, 2);
58   if (compare_mame_times(period, time_zero) != 0 )
59      single_rate = SUBSECONDS_TO_HZ(period.subseconds);
57   attotime period = z80ctc_getperiod (0, 2);
58   if (attotime_compare(period, attotime_zero) != 0 )
59      single_rate = ATTOSECONDS_TO_HZ(period.attoseconds);
6060   else
6161      single_rate = 0;
6262
r1293r1294
8484   sample_set_volume(0,0);
8585   sample_start_raw(0,_single,SINGLE_LENGTH,single_rate,1);
8686
87   mame_timer_pulse(make_mame_time(0, Machine->screen[0].refresh), 0, senjyo_sh_update);
87   timer_pulse(attotime_make(0, Machine->screen[0].refresh), 0, senjyo_sh_update);
8888}
src/mame/audio/exidy440.c
r1293r1294
404404 *
405405 *************************************/
406406
407void exidy440_m6844_update(void)
407static void exidy440_m6844_update(void)
408408{
409409   /* update the stream */
410410   stream_update(stream);
src/mame/audio/mcr.c
r1293r1294
3939 *
4040 *************************************/
4141
42UINT8 mcr_sound_config;
42static UINT8 mcr_sound_config;
4343
4444
4545
r1293r1294
463463/********* memory interfaces ***********/
464464
465465/* address map verified from schematics */
466ADDRESS_MAP_START( ssio_map, ADDRESS_SPACE_PROGRAM, 8 )
466static ADDRESS_MAP_START( ssio_map, ADDRESS_SPACE_PROGRAM, 8 )
467467   ADDRESS_MAP_FLAGS( AMEF_UNMAP(1) )
468468   AM_RANGE(0x0000, 0x3fff) AM_ROM
469469   AM_RANGE(0x8000, 0x83ff) AM_MIRROR(0x0c00) AM_RAM
r1293r1294
537537
538538   /* oftentimes games will write one nibble at a time; the sync on this is very */
539539   /* important, so we boost the interleave briefly while this happens */
540   cpu_boost_interleave(time_zero, MAME_TIME_IN_USEC(100));
540   cpu_boost_interleave(attotime_zero, ATTOTIME_IN_USEC(100));
541541}
542542
543543static READ16_HANDLER( csdeluxe_pia_r )
r1293r1294
581581/********* memory interfaces ***********/
582582
583583/* address map determined by PAL; not verified */
584ADDRESS_MAP_START( csdeluxe_map, ADDRESS_SPACE_PROGRAM, 16 )
584static ADDRESS_MAP_START( csdeluxe_map, ADDRESS_SPACE_PROGRAM, 16 )
585585   ADDRESS_MAP_FLAGS( AMEF_UNMAP(1) | AMEF_ABITS(17) )
586586   AM_RANGE(0x000000, 0x007fff) AM_ROM
587587   AM_RANGE(0x018000, 0x018007) AM_READWRITE(csdeluxe_pia_r, csdeluxe_pia_w)
r1293r1294
657657
658658   /* oftentimes games will write one nibble at a time; the sync on this is very */
659659   /* important, so we boost the interleave briefly while this happens */
660   cpu_boost_interleave(time_zero, MAME_TIME_IN_USEC(250));
660   cpu_boost_interleave(attotime_zero, ATTOTIME_IN_USEC(250));
661661}
662662
663663
r1293r1294
682682/********* memory interfaces ***********/
683683
684684/* address map determined by PAL; not verified */
685ADDRESS_MAP_START( soundsgood_map, ADDRESS_SPACE_PROGRAM, 16 )
685static ADDRESS_MAP_START( soundsgood_map, ADDRESS_SPACE_PROGRAM, 16 )
686686   ADDRESS_MAP_FLAGS( AMEF_UNMAP(1) | AMEF_ABITS(19) )
687687   AM_RANGE(0x000000, 0x03ffff) AM_ROM
688688   AM_RANGE(0x060000, 0x060007) AM_READWRITE(pia_1_msb_alt_r, pia_1_msb_alt_w)
r1293r1294
748748
749749   /* oftentimes games will write one nibble at a time; the sync on this is very */
750750   /* important, so we boost the interleave briefly while this happens */
751   cpu_boost_interleave(time_zero, MAME_TIME_IN_USEC(100));
751   cpu_boost_interleave(attotime_zero, ATTOTIME_IN_USEC(100));
752752}
753753
754754
r1293r1294
772772/********* memory interfaces ***********/
773773
774774/* address map verified from schematics */
775ADDRESS_MAP_START( turbocs_map, ADDRESS_SPACE_PROGRAM, 8 )
775static ADDRESS_MAP_START( turbocs_map, ADDRESS_SPACE_PROGRAM, 8 )
776776   ADDRESS_MAP_FLAGS( AMEF_UNMAP(1) )
777777   AM_RANGE(0x0000, 0x07ff) AM_MIRROR(0x3800) AM_RAM
778778   AM_RANGE(0x4000, 0x4003) AM_MIRROR(0x3ffc) AM_READWRITE(pia_0_alt_r, pia_0_alt_w)
r1293r1294
896896/* address map verified from schematics */
897897/* note that jumpers control the ROM sizes; if these are changed, use the alternate */
898898/* address map below */
899ADDRESS_MAP_START( squawkntalk_map, ADDRESS_SPACE_PROGRAM, 8 )
899static ADDRESS_MAP_START( squawkntalk_map, ADDRESS_SPACE_PROGRAM, 8 )
900900   ADDRESS_MAP_FLAGS( AMEF_UNMAP(1) )
901901   AM_RANGE(0x0000, 0x007f) AM_RAM      /* internal RAM */
902902   AM_RANGE(0x0080, 0x0083) AM_MIRROR(0x4f6c) AM_READWRITE(pia_0_r, pia_0_w)
r1293r1294
907907
908908/* alternate address map if the ROM jumpers are changed to support a smaller */
909909/* ROM size of 2k */
910#ifdef UNUSED_FUNCTION
910911ADDRESS_MAP_START( squawkntalk_alt_map, ADDRESS_SPACE_PROGRAM, 8 )
911912   ADDRESS_MAP_FLAGS( AMEF_UNMAP(1) )
912913   AM_RANGE(0x0000, 0x007f) AM_RAM      /* internal RAM */
r1293r1294
915916   AM_RANGE(0x0800, 0x0fff) AM_MIRROR(0x6000) AM_WRITE(squawkntalk_dac_w)
916917   AM_RANGE(0x8000, 0x9fff) AM_MIRROR(0x6000) AM_ROM
917918ADDRESS_MAP_END
919#endif
918920
919921
920922/********* PIA interfaces ***********/
src/mame/audio/segasnd.c
r1293r1294
317317   cpunum_set_input_line(usb.cpunum, INPUT_LINE_RESET, ASSERT_LINE);
318318
319319   /* start the clock timer */
320   mame_timer_pulse(scale_up_mame_time(MAME_TIME_IN_HZ(USB_2MHZ_CLOCK), 256), 0, increment_t1_clock);
320   timer_pulse(attotime_mul(ATTOTIME_IN_HZ(USB_2MHZ_CLOCK), 256), 0, increment_t1_clock);
321321   usb.t1_clock_mask = t1_clock_mask;
322322}
323323
r1293r1294
363363   timer_call_after_resynch(data, delayed_usb_data_w);
364364
365365   /* boost the interleave so that sequences can be sent */
366   cpu_boost_interleave(time_zero, MAME_TIME_IN_USEC(250));
366   cpu_boost_interleave(attotime_zero, ATTOTIME_IN_USEC(250));
367367}
368368
369369
src/mame/audio/vicdual.c
r1293r1294
1515 * Oct 2004, Derrick Renaud
1616 ************************************************************************/
1717
18static mame_timer *frogs_croak_timer;
18static emu_timer *frogs_croak_timer;
1919
2020
2121/* Discrete Sound Input Nodes */
r1293r1294
139139
140140MACHINE_START( frogs_audio )
141141{
142   frogs_croak_timer = mame_timer_alloc(frogs_croak_callback);
142   frogs_croak_timer = timer_alloc(frogs_croak_callback);
143143}
144144
145145
r1293r1294
168168      if (last_croak)
169169      {
170170         /* The croak will keep playing until .429s after being disabled */
171         mame_timer_adjust(frogs_croak_timer, double_to_mame_time(1.1 * RES_K(390) * CAP_U(1)), 0, time_zero);
171         timer_adjust(frogs_croak_timer, double_to_attotime(1.1 * RES_K(390) * CAP_U(1)), 0, attotime_zero);
172172      }
173173   }
174174   if (new_buzzz)
src/mame/audio/rockola.c
r1293r1294
745745#define HD38880_CMV   0x20
746746#define HD68880_SYBS   0x0f
747747
748int   hd38880_cmd;
749UINT32   hd38880_addr;
750int   hd38880_data_bytes;
751double   hd38880_speed;
748static int   hd38880_cmd;
749static UINT32   hd38880_addr;
750static int   hd38880_data_bytes;
751static double   hd38880_speed;
752752
753753
754754static void rockola_speech_w(UINT8 data, UINT16 *table, int start)
src/mame/audio/irem.c
r1293r1294
128128
129129
130130
131ADDRESS_MAP_START( irem_sound_readmem, ADDRESS_SPACE_PROGRAM, 8 )
131static ADDRESS_MAP_START( irem_sound_readmem, ADDRESS_SPACE_PROGRAM, 8 )
132132   AM_RANGE(0x4000, 0xffff) AM_READ(MRA8_ROM)
133133ADDRESS_MAP_END
134134
135ADDRESS_MAP_START( irem_sound_writemem, ADDRESS_SPACE_PROGRAM, 8 )
135static ADDRESS_MAP_START( irem_sound_writemem, ADDRESS_SPACE_PROGRAM, 8 )
136136   AM_RANGE(0x0800, 0x0800) AM_WRITE(MWA8_NOP)    /* IACK */
137137   AM_RANGE(0x0801, 0x0802) AM_WRITE(irem_adpcm_w)
138138   AM_RANGE(0x9000, 0x9000) AM_WRITE(MWA8_NOP)    /* IACK */
139139   AM_RANGE(0x4000, 0xffff) AM_WRITE(MWA8_ROM)
140140ADDRESS_MAP_END
141141
142ADDRESS_MAP_START( irem_sound_readport, ADDRESS_SPACE_IO, 8 )
142static ADDRESS_MAP_START( irem_sound_readport, ADDRESS_SPACE_IO, 8 )
143143   AM_RANGE(M6803_PORT1, M6803_PORT1) AM_READ(irem_port1_r)
144144   AM_RANGE(M6803_PORT2, M6803_PORT2) AM_READ(irem_port2_r)
145145ADDRESS_MAP_END
146146
147ADDRESS_MAP_START( irem_sound_writeport, ADDRESS_SPACE_IO, 8 )
147static ADDRESS_MAP_START( irem_sound_writeport, ADDRESS_SPACE_IO, 8 )
148148   AM_RANGE(M6803_PORT1, M6803_PORT1) AM_WRITE(irem_port1_w)
149149   AM_RANGE(M6803_PORT2, M6803_PORT2) AM_WRITE(irem_port2_w)
150150ADDRESS_MAP_END
src/mame/audio/leland.c
r1293r1294
227227   UINT16   maxA;
228228   UINT16   maxB;
229229   UINT16   count;
230   mame_timer *int_timer;
231   mame_timer *time_timer;
230   emu_timer *int_timer;
231   emu_timer *time_timer;
232232   UINT8   time_timer_active;
233   mame_time last_time;
233   attotime last_time;
234234};
235235
236236struct dma_state
r1293r1294
240240   UINT16   count;
241241   UINT16   control;
242242   UINT8   finished;
243   mame_timer *finish_timer;
243   emu_timer *finish_timer;
244244};
245245
246246struct intr_state
r1293r1294
284284
285285static struct counter_state
286286{
287   mame_timer *timer;
287   emu_timer *timer;
288288   INT32 count;
289289   UINT8 mode;
290290   UINT8 readbyte;
r1293r1294
526526   is_redline = 0;
527527
528528   /* create timers here so they stick around */
529   i80186.timer[0].int_timer = mame_timer_alloc(internal_timer_int);
530   i80186.timer[1].int_timer = mame_timer_alloc(internal_timer_int);
531   i80186.timer[2].int_timer = mame_timer_alloc(internal_timer_int);
532   i80186.timer[0].time_timer = mame_timer_alloc(NULL);
533   i80186.timer[1].time_timer = mame_timer_alloc(NULL);
534   i80186.timer[2].time_timer = mame_timer_alloc(NULL);
535   i80186.dma[0].finish_timer = mame_timer_alloc(dma_timer_callback);
536   i80186.dma[1].finish_timer = mame_timer_alloc(dma_timer_callback);
529   i80186.timer[0].int_timer = timer_alloc(internal_timer_int);
530   i80186.timer[1].int_timer = timer_alloc(internal_timer_int);
531   i80186.timer[2].int_timer = timer_alloc(internal_timer_int);
532   i80186.timer[0].time_timer = timer_alloc(NULL);
533   i80186.timer[1].time_timer = timer_alloc(NULL);
534   i80186.timer[2].time_timer = timer_alloc(NULL);
535   i80186.dma[0].finish_timer = timer_alloc(dma_timer_callback);
536   i80186.dma[1].finish_timer = timer_alloc(dma_timer_callback);
537537
538538   for (i = 0; i < 9; i++)
539      counter[i].timer = mame_timer_alloc(NULL);
539      counter[i].timer = timer_alloc(NULL);
540540
541541   return auto_malloc(1);
542542}
r1293r1294
553553static void leland_80186_reset(void)
554554{
555555   struct i80186_state oldstate = i80186;
556   mame_timer *counter_timer[9];
556   emu_timer *counter_timer[9];
557557   int i;
558558
559559   /* reset the i80186 state, but save the timers */
r1293r1294
612612
613613static int int_callback(int line)
614614{
615   if (LOG_INTERRUPTS) logerror("(%f) **** Acknowledged interrupt vector %02X\n", mame_time_to_double(mame_timer_get_time()), i80186.intr.poll_status & 0x1f);
615   if (LOG_INTERRUPTS) logerror("(%f) **** Acknowledged interrupt vector %02X\n", attotime_to_double(timer_get_time()), i80186.intr.poll_status & 0x1f);
616616
617617   /* clear the interrupt */
618618   activecpu_set_info_int(CPUINFO_INT_INPUT_STATE + 0, CLEAR_LINE);
r1293r1294
725725   if (!i80186.intr.pending)
726726      cpunum_set_input_line(2, 0, ASSERT_LINE);
727727   i80186.intr.pending = 1;
728   if (LOG_INTERRUPTS) logerror("(%f) **** Requesting interrupt vector %02X\n", mame_time_to_double(mame_timer_get_time()), new_vector);
728   if (LOG_INTERRUPTS) logerror("(%f) **** Requesting interrupt vector %02X\n", attotime_to_double(timer_get_time()), new_vector);
729729}
730730
731731
r1293r1294
750750         case 0x0f:   i80186.intr.in_service &= ~0x80;   break;
751751         default:   logerror("%05X:ERROR - 80186 EOI with unknown vector %02X\n", activecpu_get_pc(), data & 0x1f);
752752      }
753      if (LOG_INTERRUPTS) logerror("(%f) **** Got EOI for vector %02X\n", mame_time_to_double(mame_timer_get_time()), data & 0x1f);
753      if (LOG_INTERRUPTS) logerror("(%f) **** Got EOI for vector %02X\n", attotime_to_double(timer_get_time()), data & 0x1f);
754754   }
755755
756756   /* non-specific case */
r1293r1294
763763         if ((i80186.intr.timer & 7) == i && (i80186.intr.in_service & 0x01))
764764         {
765765            i80186.intr.in_service &= ~0x01;
766            if (LOG_INTERRUPTS) logerror("(%f) **** Got EOI for timer\n", mame_time_to_double(mame_timer_get_time()));
766            if (LOG_INTERRUPTS) logerror("(%f) **** Got EOI for timer\n", attotime_to_double(timer_get_time()));
767767            return;
768768         }
769769
r1293r1294
772772            if ((i80186.intr.dma[j] & 7) == i && (i80186.intr.in_service & (0x04 << j)))
773773            {
774774               i80186.intr.in_service &= ~(0x04 << j);
775               if (LOG_INTERRUPTS) logerror("(%f) **** Got EOI for DMA%d\n", mame_time_to_double(mame_timer_get_time()), j);
775               if (LOG_INTERRUPTS) logerror("(%f) **** Got EOI for DMA%d\n", attotime_to_double(timer_get_time()), j);
776776               return;
777777            }
778778
r1293r1294
781781            if ((i80186.intr.ext[j] & 7) == i && (i80186.intr.in_service & (0x10 << j)))
782782            {
783783               i80186.intr.in_service &= ~(0x10 << j);
784               if (LOG_INTERRUPTS) logerror("(%f) **** Got EOI for INT%d\n", mame_time_to_double(mame_timer_get_time()), j);
784               if (LOG_INTERRUPTS) logerror("(%f) **** Got EOI for INT%d\n", attotime_to_double(timer_get_time()), j);
785785               return;
786786            }
787787      }
r1293r1294
818818   if (t->control & 0x0001)
819819   {
820820      int count = t->maxA ? t->maxA : 0x10000;
821      mame_timer_adjust(t->int_timer, scale_up_mame_time(MAME_TIME_IN_HZ(2000000), count), which, time_zero);
821      timer_adjust(t->int_timer, attotime_mul(ATTOTIME_IN_HZ(2000000), count), which, attotime_zero);
822822      if (LOG_TIMER) logerror("  Repriming interrupt\n");
823823   }
824824   else
825      mame_timer_adjust(t->int_timer, time_never, which, time_never);
825      timer_adjust(t->int_timer, attotime_never, which, attotime_never);
826826}
827827
828828
r1293r1294
833833   /* if we have a timing timer running, adjust the count */
834834   if (t->time_timer_active)
835835   {
836      mame_time current_time = mame_timer_timeelapsed(t->time_timer);
837      int net_clocks = mame_time_to_double(scale_up_mame_time(sub_mame_times(current_time, t->last_time), 2000000));
836      attotime current_time = timer_timeelapsed(t->time_timer);
837      int net_clocks = attotime_to_double(attotime_mul(attotime_sub(current_time, t->last_time), 2000000));
838838      t->last_time = current_time;
839839
840840      /* set the max count bit if we passed the max */
r1293r1294
936936            internal_timer_sync(which);
937937
938938            /* nuke the timer and force the interrupt timer to be recomputed */
939            mame_timer_adjust(t->time_timer, time_never, which, time_never);
939            timer_adjust(t->time_timer, attotime_never, which, attotime_never);
940940            t->time_timer_active = 0;
941941            update_int_timer = 1;
942942         }
r1293r1294
945945         else if ((diff & 0x8000) && (new_control & 0x8000))
946946         {
947947            /* start the timing */
948            mame_timer_adjust(t->time_timer, time_never, which, time_never);
948            timer_adjust(t->time_timer, attotime_never, which, attotime_never);
949949            t->time_timer_active = 1;
950950            update_int_timer = 1;
951951         }
r1293r1294
974974         {
975975            int diff = t->maxA - t->count;
976976            if (diff <= 0) diff += 0x10000;
977            mame_timer_adjust(t->int_timer, scale_up_mame_time(MAME_TIME_IN_HZ(2000000), diff), which, time_zero);
977            timer_adjust(t->int_timer, attotime_mul(ATTOTIME_IN_HZ(2000000), diff), which, attotime_zero);
978978            if (LOG_TIMER) logerror("Set interrupt timer for %d\n", which);
979979         }
980980         else
981            mame_timer_adjust(t->int_timer, time_never, which, time_never);
981            timer_adjust(t->int_timer, attotime_never, which, attotime_never);
982982      }
983983}
984984
r1293r1294
10631063         if (LOG_DMA) logerror("Initiated DMA %d - count = %04X, source = %04X, dest = %04X\n", which, d->count, d->source, d->dest);
10641064
10651065         d->finished = 0;
1066         mame_timer_adjust(d->finish_timer, scale_up_mame_time(MAME_TIME_IN_HZ(dac[dacnum].frequency), count), which, time_zero);
1066         timer_adjust(d->finish_timer, attotime_mul(ATTOTIME_IN_HZ(dac[dacnum].frequency), count), which, attotime_zero);
10671067      }
10681068   }
10691069
r1293r1294
15241524   if (counter[which].timer)
15251525   {
15261526      /* determine how many 2MHz cycles are remaining */
1527      int count = mame_time_to_double(scale_up_mame_time(mame_timer_timeleft(counter[which].timer), 2000000));
1527      int count = attotime_to_double(attotime_mul(timer_timeleft(counter[which].timer), 2000000));
15281528      counter[which].count = (count < 0) ? 0 : count;
15291529   }
15301530}
r1293r1294
16061606            if (ctr->count == 0) ctr->count = 0x10000;
16071607
16081608            /* reset/start the timer */
1609            mame_timer_adjust(ctr->timer, time_never, 0, time_never);
1609            timer_adjust(ctr->timer, attotime_never, 0, attotime_never);
16101610
16111611            if (LOG_PIT) logerror("PIT counter %d set to %d (%d Hz)\n", which, ctr->count, 4000000 / ctr->count);
16121612
src/mame/audio/taito_en.c
r1293r1294
77static UINT16 es5510_dsp_ram[0x200];
88static UINT32   es5510_gpr[0xc0];
99static UINT32   es5510_gpr_latch;
10static mame_timer *timer_68681=NULL;
10static emu_timer *timer_68681=NULL;
1111static int timer_mode,m68681_imr;
1212
1313static int es_tmp=1;
r1293r1294
8080
8181void f3_68681_reset(void)
8282{
83   timer_68681 = mame_timer_alloc(timer_callback);
83   timer_68681 = timer_alloc(timer_callback);
8484}
8585
8686READ16_HANDLER(f3_68681_r)
r1293r1294
120120            case 3:
121121               logerror("Counter:  X1/Clk - divided by 16, counter is %04x, so interrupt every %d cycles\n",counter,(M68000_CLOCK/M68681_CLOCK)*counter*16);
122122               timer_mode=TIMER_SINGLESHOT;
123               mame_timer_adjust(timer_68681, MAME_TIME_IN_CYCLES((M68000_CLOCK/M68681_CLOCK)*counter*16,1), 0, time_zero);
123               timer_adjust(timer_68681, ATTOTIME_IN_CYCLES((M68000_CLOCK/M68681_CLOCK)*counter*16,1), 0, attotime_zero);
124124               break;
125125            case 4:
126126               logerror("Timer:  Unimplemented external IP2\n");
r1293r1294
131131            case 6:
132132               logerror("Timer:  X1/Clk, counter is %04x, so interrupt every %d cycles\n",counter,(M68000_CLOCK/M68681_CLOCK)*counter);
133133               timer_mode=TIMER_PULSE;
134               mame_timer_adjust(timer_68681, MAME_TIME_IN_CYCLES((M68000_CLOCK/M68681_CLOCK)*counter,1), 0, MAME_TIME_IN_CYCLES((M68000_CLOCK/M68681_CLOCK)*counter,1));
134               timer_adjust(timer_68681, ATTOTIME_IN_CYCLES((M68000_CLOCK/M68681_CLOCK)*counter,1), 0, ATTOTIME_IN_CYCLES((M68000_CLOCK/M68681_CLOCK)*counter,1));
135135               break;
136136            case 7:
137137               logerror("Timer:  Unimplemented X1/Clk - divided by 16\n");
src/mame/audio/geebee.c
r1293r1294
1313#include "sound/custom.h"
1414#include "includes/warpwarp.h"
1515
16static mame_timer *volume_timer = NULL;
16static emu_timer *volume_timer = NULL;
1717static UINT16 *decay = NULL;
1818static sound_stream *channel;
1919static int sound_latch = 0;
r1293r1294
4545         * Decay:
4646         * discharge C33 (1uF) through R50 (22k) -> 0.14058s
4747         */
48        mame_time period = scale_down_mame_time(scale_up_mame_time(MAME_TIME_IN_HZ(32768), 14058), 100000);
49      mame_timer_adjust(volume_timer, period, 0, period);
48        attotime period = attotime_div(attotime_mul(ATTOTIME_IN_HZ(32768), 14058), 100000);
49      timer_adjust(volume_timer, period, 0, period);
5050   }
5151   else
5252   {
r1293r1294
5757         * I can only guess here that the decay should be slower,
5858         * maybe half as fast?
5959         */
60        mame_time period = scale_down_mame_time(scale_up_mame_time(MAME_TIME_IN_HZ(32768), 29060), 100000);
61      mame_timer_adjust(volume_timer, period, 0, period);
60        attotime period = attotime_div(attotime_mul(ATTOTIME_IN_HZ(32768), 29060), 100000);
61      timer_adjust(volume_timer, period, 0, period);
6262    }
6363}
6464
r1293r1294
125125   channel = stream_create(0, 1, 18432000 / 3 / 2 / 384, NULL, geebee_sound_update);
126126   vcount = 0;
127127
128   volume_timer = mame_timer_alloc(volume_decay);
128   volume_timer = timer_alloc(volume_decay);
129129    return auto_malloc(1);
130130}
src/mame/audio/tiamc1.c
r1293r1294
6767#define T8253_CWORD      3
6868
6969
70void timer8253_reset(struct timer8253struct *t) {
70static void timer8253_reset(struct timer8253struct *t) {
7171   memset(t,0,sizeof(struct timer8253struct));
7272}
7373
7474
75void timer8253_tick(struct timer8253struct *t,int chn) {
75static void timer8253_tick(struct timer8253struct *t,int chn) {
7676   if (t->channel[chn].enable && t->channel[chn].gate) {
7777      switch (t->channel[chn].cntMode) {
7878      case 0:
r1293r1294
109109
110110
111111
112void timer8253_wr(struct timer8253struct *t, int reg, UINT8 val)
112static void timer8253_wr(struct timer8253struct *t, int reg, UINT8 val)
113113{
114114   int chn;
115115
r1293r1294
213213   }
214214}
215215
216void timer8253_set_gate(struct timer8253struct *t, int chn, UINT8 gate)
216static void timer8253_set_gate(struct timer8253struct *t, int chn, UINT8 gate)
217217{
218218   t->channel[chn].gate = gate;
219219}
220220
221221
222222
223char timer8253_get_output(struct timer8253struct *t, int chn)
223static char timer8253_get_output(struct timer8253struct *t, int chn)
224224{
225225   return t->channel[chn].output;
226226}
src/mame/audio/segag80r.c
r1293r1294
4444static UINT8 square_state;
4545static UINT8 square_count;
4646
47static mame_timer *sega005_sound_timer;
47static emu_timer *sega005_sound_timer;
4848static sound_stream *sega005_stream;
4949
5050static UINT8 n7751_command;
r1293r1294
519519   if ((diff & 0x20) && !(newval & 0x20))
520520   {
521521      //mame_printf_debug("Stopping timer\n");
522      mame_timer_adjust(sega005_sound_timer, time_never, 0, time_never);
522      timer_adjust(sega005_sound_timer, attotime_never, 0, attotime_never);
523523   }
524524
525525   /* if bit 5 goes low, we start the timer again */
526526   if ((diff & 0x20) && (newval & 0x20))
527527   {
528528      //mame_printf_debug("Starting timer\n");
529      mame_timer_adjust(sega005_sound_timer, MAME_TIME_IN_HZ(SEGA005_555_TIMER_FREQ), 0, MAME_TIME_IN_HZ(SEGA005_555_TIMER_FREQ));
529      timer_adjust(sega005_sound_timer, ATTOTIME_IN_HZ(SEGA005_555_TIMER_FREQ), 0, ATTOTIME_IN_HZ(SEGA005_555_TIMER_FREQ));
530530   }
531531}
532532
r1293r1294
579579   sega005_stream = stream_create(0, 1, SEGA005_COUNTER_FREQ, NULL, sega005_stream_update);
580580
581581   /* create a timer for the 555 */
582   sega005_sound_timer = mame_timer_alloc(sega005_auto_timer);
582   sega005_sound_timer = timer_alloc(sega005_auto_timer);
583583
584584   /* set the initial sound data */
585585   sound_data = 0x00;
r1293r1294
632632
633633static SOUND_START( spaceod );
634634
635const char *spaceod_sample_names[] =
635static const char *spaceod_sample_names[] =
636636{
637637   "*spaceod",
638638   "fire.wav",         /* 0 */
r1293r1294
796796 *
797797 *************************************/
798798
799ADDRESS_MAP_START( monsterb_7751_map, ADDRESS_SPACE_PROGRAM, 8 )
799static ADDRESS_MAP_START( monsterb_7751_map, ADDRESS_SPACE_PROGRAM, 8 )
800800   AM_RANGE(0x0000, 0x03ff) AM_ROM
801801ADDRESS_MAP_END
802802
803ADDRESS_MAP_START( monsterb_7751_portmap, ADDRESS_SPACE_IO, 8 )
803static ADDRESS_MAP_START( monsterb_7751_portmap, ADDRESS_SPACE_IO, 8 )
804804   AM_RANGE(I8039_t1, I8039_t1) AM_READ(n7751_t1_r)
805805   AM_RANGE(I8039_p2, I8039_p2) AM_READ(n7751_command_r)
806806   AM_RANGE(I8039_bus, I8039_bus) AM_READ(n7751_rom_r)
r1293r1294
934934    */
935935   n7751_command = data & 0x07;
936936   cpunum_set_input_line(1, 0, ((data & 0x08) == 0) ? ASSERT_LINE : CLEAR_LINE);
937   cpu_boost_interleave(time_zero, MAME_TIME_IN_USEC(100));
937   cpu_boost_interleave(attotime_zero, ATTOTIME_IN_USEC(100));
938938}
939939
940940
src/mame/audio/williams.c
r1293r1294
3636    STATIC GLOBALS
3737****************************************************************************/
3838
39UINT8 williams_sound_int_state;
39static UINT8 williams_sound_int_state;
4040
4141static UINT8 audio_talkback;
4242
r1293r1294
8484****************************************************************************/
8585
8686/* CVSD readmem/writemem structures */
87ADDRESS_MAP_START( williams_cvsd_map, ADDRESS_SPACE_PROGRAM, 8 )
87static ADDRESS_MAP_START( williams_cvsd_map, ADDRESS_SPACE_PROGRAM, 8 )
8888   AM_RANGE(0x0000, 0x07ff) AM_MIRROR(0x1800) AM_RAM
8989   AM_RANGE(0x2000, 0x2000) AM_MIRROR(0x1ffe) AM_WRITE(YM2151_register_port_0_w)
9090   AM_RANGE(0x2001, 0x2001) AM_MIRROR(0x1ffe) AM_READWRITE(YM2151_status_port_0_r, YM2151_data_port_0_w)
r1293r1294
9797
9898
9999/* NARC master readmem/writemem structures */
100ADDRESS_MAP_START( williams_narc_master_map, ADDRESS_SPACE_PROGRAM, 8 )
100static ADDRESS_MAP_START( williams_narc_master_map, ADDRESS_SPACE_PROGRAM, 8 )
101101   AM_RANGE(0x0000, 0x1fff) AM_RAM
102102   AM_RANGE(0x2000, 0x2000) AM_MIRROR(0x03fe) AM_WRITE(YM2151_register_port_0_w)
103103   AM_RANGE(0x2001, 0x2001) AM_MIRROR(0x03fe) AM_READWRITE(YM2151_status_port_0_r, YM2151_data_port_0_w)
r1293r1294
112112ADDRESS_MAP_END
113113
114114/* NARC slave readmem/writemem structures */
115ADDRESS_MAP_START( williams_narc_slave_map, ADDRESS_SPACE_PROGRAM, 8 )
115static ADDRESS_MAP_START( williams_narc_slave_map, ADDRESS_SPACE_PROGRAM, 8 )
116116   AM_RANGE(0x0000, 0x1fff) AM_RAM
117117   AM_RANGE(0x2000, 0x2000) AM_MIRROR(0x03ff) AM_WRITE(hc55516_0_clock_set_w)
118118   AM_RANGE(0x2400, 0x2400) AM_MIRROR(0x03ff) AM_WRITE(hc55516_0_digit_clock_clear_w)
r1293r1294
127127
128128
129129/* ADPCM readmem/writemem structures */
130ADDRESS_MAP_START( williams_adpcm_map, ADDRESS_SPACE_PROGRAM, 8 )
130static ADDRESS_MAP_START( williams_adpcm_map, ADDRESS_SPACE_PROGRAM, 8 )
131131   AM_RANGE(0x0000, 0x1fff) AM_RAM
132132   AM_RANGE(0x2000, 0x2000) AM_MIRROR(0x03ff) AM_WRITE(adpcm_bank_select_w)
133133   AM_RANGE(0x2400, 0x2400) AM_MIRROR(0x03fe) AM_WRITE(YM2151_register_port_0_w)
src/mame/audio/system16.c
r1293r1294
3939   if ((data & 0x0f) != 8)
4040   {
4141      cpunum_set_input_line(2, INPUT_LINE_RESET, PULSE_LINE);
42      mame_timer_set(MAME_TIME_IN_USEC(300), data, trigger_7751_sound);
42      timer_set(ATTOTIME_IN_USEC(300), data, trigger_7751_sound);
4343   }
4444}
4545
src/mame/audio/starwars.c
r1293r1294
158158         /* Should be decrementing every data*1024 6532 clock cycles */
159159         /* 6532 runs at 1.5 MHz */
160160
161         mame_timer_set(scale_up_mame_time(MAME_TIME_IN_HZ(1500000), data * 1024), 0, snd_interrupt);
161         timer_set(attotime_mul(ATTOTIME_IN_HZ(1500000), data * 1024), 0, snd_interrupt);
162162         return;
163163
164164      default:
r1293r1294
181181{
182182   port_A |= 0x40; /* result from sound cpu pending */
183183   main_data = param;
184   cpu_boost_interleave(time_zero, MAME_TIME_IN_USEC(100));
184   cpu_boost_interleave(attotime_zero, ATTOTIME_IN_USEC(100));
185185}
186186
187187READ8_HANDLER( starwars_sin_r )
r1293r1294
225225
226226   port_A |= 0x80;  /* command from main cpu pending */
227227   sound_data = param;
228   cpu_boost_interleave(time_zero, MAME_TIME_IN_USEC(100));
228   cpu_boost_interleave(attotime_zero, ATTOTIME_IN_USEC(100));
229229
230230   if (PA7_irq)
231231      cpunum_set_input_line(1, M6809_IRQ_LINE, ASSERT_LINE);
src/mame/audio/gottlieb.c
r1293r1294
8686}
8787
8888
89#ifdef UNUSED_FUNCTION
8990void gottlieb_knocker(void)
9091{
9192   if (!strcmp(Machine->gamedrv->name,"reactor"))   /* reactor */
r1293r1294
9495   else if (sndti_exists(SOUND_SAMPLES, 0))   /* qbert */
9596      sample_start(0,44,0);
9697}
98#endif
9799
98100/* callback for the timer */
99101static TIMER_CALLBACK( gottlieb_nmi_generate )
r1293r1294
148150   }
149151
150152   /* generate a NMI after a while to make the CPU continue to send data */
151   mame_timer_set(MAME_TIME_IN_USEC(50),0,gottlieb_nmi_generate);
153   timer_set(ATTOTIME_IN_USEC(50),0,gottlieb_nmi_generate);
152154}
153155
154156WRITE8_HANDLER( gottlieb_speech_clock_DAC_w )
r1293r1294
199201
200202
201203static UINT8 psg_latch;
202static mame_timer *nmi_timer;
204static emu_timer *nmi_timer;
203205static int nmi_rate;
204206static int sp0250_drq;
205207static UINT8 sp0250_latch;
r1293r1294
207209static TIMER_CALLBACK( nmi_callback );
208210void gottlieb_sound_init(void)
209211{
210   nmi_timer = mame_timer_alloc(nmi_callback);
212   nmi_timer = timer_alloc(nmi_callback);
211213}
212214
213215void stooges_sp0250_drq(int level)
r1293r1294
245247   if (data & 0x01)
246248   {
247249      /* base clock is 250kHz divided by 256 */
248      mame_time interval = scale_up_mame_time(MAME_TIME_IN_HZ(250000), 256 * (256-nmi_rate));
249      mame_timer_adjust(nmi_timer, interval, 0, interval);
250      attotime interval = attotime_mul(ATTOTIME_IN_HZ(250000), 256 * (256-nmi_rate));
251      timer_adjust(nmi_timer, interval, 0, interval);
250252   }
251253   else
252      mame_timer_adjust(nmi_timer, time_never, 0, time_never);
254      timer_adjust(nmi_timer, attotime_never, 0, attotime_never);
253255
254256   /* Bit 1 controls a LED on the sound board. I'm not emulating it */
255257}
src/mame/audio/dcs.c
r1293r1294
292292   UINT8      channels;
293293   UINT16      size;
294294   UINT16      incs;
295   mame_timer *reg_timer;
296   mame_timer *sport_timer;
297   mame_timer *internal_timer;
295   emu_timer *reg_timer;
296   emu_timer *sport_timer;
297   emu_timer *internal_timer;
298298   INT32      ireg;
299299   UINT16      ireg_base;
300300   UINT16      control_regs[32];
r1293r1294
343343   INT32      writes_left;
344344   UINT16      sum;
345345   INT32      fifo_entries;
346   mame_timer *watchdog;
346   emu_timer *watchdog;
347347};
348348
349349
r1293r1294
423423 *************************************/
424424
425425/* DCS 2k memory map */
426ADDRESS_MAP_START( dcs_2k_program_map, ADDRESS_SPACE_PROGRAM, 32 )
426static ADDRESS_MAP_START( dcs_2k_program_map, ADDRESS_SPACE_PROGRAM, 32 )
427427   AM_RANGE(0x0000, 0x03ff) AM_RAM AM_BASE(&dcs_internal_program_ram)
428428   AM_RANGE(0x0800, 0x0fff) AM_RAM AM_SHARE(1) AM_BASE(&dcs_external_program_ram)
429429   AM_RANGE(0x1000, 0x17ff) AM_RAM AM_SHARE(1)
430430   AM_RANGE(0x1800, 0x1fff) AM_RAM AM_SHARE(1)
431431ADDRESS_MAP_END
432432
433ADDRESS_MAP_START( dcs_2k_data_map, ADDRESS_SPACE_DATA, 16 )
433static ADDRESS_MAP_START( dcs_2k_data_map, ADDRESS_SPACE_DATA, 16 )
434434   AM_RANGE(0x0000, 0x07ff) AM_MIRROR(0x1800) AM_READWRITE(dcs_dataram_r, dcs_dataram_w)
435435   AM_RANGE(0x2000, 0x2fff) AM_ROMBANK(20)
436436   AM_RANGE(0x3000, 0x33ff) AM_WRITE(dcs_data_bank_select_w)
r1293r1294
441441
442442
443443/* DCS 2k with UART memory map */
444ADDRESS_MAP_START( dcs_2k_uart_data_map, ADDRESS_SPACE_DATA, 16 )
444static ADDRESS_MAP_START( dcs_2k_uart_data_map, ADDRESS_SPACE_DATA, 16 )
445445   AM_RANGE(0x0000, 0x07ff) AM_MIRROR(0x1800) AM_READWRITE(dcs_dataram_r, dcs_dataram_w)
446446   AM_RANGE(0x2000, 0x2fff) AM_ROMBANK(20)
447447   AM_RANGE(0x3000, 0x33ff) AM_WRITE(dcs_data_bank_select_w)
r1293r1294
454454
455455
456456/* DCS 8k memory map */
457ADDRESS_MAP_START( dcs_8k_program_map, ADDRESS_SPACE_PROGRAM, 32 )
457static ADDRESS_MAP_START( dcs_8k_program_map, ADDRESS_SPACE_PROGRAM, 32 )
458458   AM_RANGE(0x0000, 0x03ff) AM_RAM AM_BASE(&dcs_internal_program_ram)
459459   AM_RANGE(0x0800, 0x1fff) AM_RAM AM_BASE(&dcs_external_program_ram)
460460ADDRESS_MAP_END
461461
462ADDRESS_MAP_START( dcs_8k_data_map, ADDRESS_SPACE_DATA, 16 )
462static ADDRESS_MAP_START( dcs_8k_data_map, ADDRESS_SPACE_DATA, 16 )
463463   AM_RANGE(0x0000, 0x07ff) AM_RAM
464464   AM_RANGE(0x0800, 0x1fff) AM_READWRITE(dcs_dataram_r, dcs_dataram_w)
465465   AM_RANGE(0x2000, 0x2fff) AM_ROMBANK(20)
r1293r1294
477477 *
478478 *************************************/
479479
480ADDRESS_MAP_START( dcs2_program_map, ADDRESS_SPACE_PROGRAM, 32 )
480static ADDRESS_MAP_START( dcs2_program_map, ADDRESS_SPACE_PROGRAM, 32 )
481481   ADDRESS_MAP_FLAGS( AMEF_UNMAP(1) )
482482   AM_RANGE(0x0000, 0x03ff) AM_RAM   AM_BASE(&dcs_internal_program_ram)
483483ADDRESS_MAP_END
484484
485485
486ADDRESS_MAP_START( dcs2_data_map, ADDRESS_SPACE_DATA, 16 )
486static ADDRESS_MAP_START( dcs2_data_map, ADDRESS_SPACE_DATA, 16 )
487487   ADDRESS_MAP_FLAGS( AMEF_UNMAP(1) )
488488   AM_RANGE(0x0400, 0x0400) AM_READWRITE(input_latch_r, input_latch_ack_w)
489489   AM_RANGE(0x0401, 0x0401) AM_WRITE(output_latch_w)
r1293r1294
503503 *
504504 *************************************/
505505
506ADDRESS_MAP_START( dsio_program_map, ADDRESS_SPACE_PROGRAM, 32 )
506static ADDRESS_MAP_START( dsio_program_map, ADDRESS_SPACE_PROGRAM, 32 )
507507   ADDRESS_MAP_FLAGS( AMEF_UNMAP(1) )
508508   AM_RANGE(0x0000, 0x3fff) AM_RAM   AM_BASE(&dcs_internal_program_ram)
509509ADDRESS_MAP_END
510510
511511
512ADDRESS_MAP_START( dsio_data_map, ADDRESS_SPACE_DATA, 16 )
512static ADDRESS_MAP_START( dsio_data_map, ADDRESS_SPACE_DATA, 16 )
513513   ADDRESS_MAP_FLAGS( AMEF_UNMAP(1) )
514514   AM_RANGE(0x0000, 0x03ff) AM_RAMBANK(20)
515515   AM_RANGE(0x0400, 0x3fdf) AM_RAM
r1293r1294
517517ADDRESS_MAP_END
518518
519519
520ADDRESS_MAP_START( dsio_io_map, ADDRESS_SPACE_IO, 16 )
520static ADDRESS_MAP_START( dsio_io_map, ADDRESS_SPACE_IO, 16 )
521521   ADDRESS_MAP_FLAGS( AMEF_UNMAP(1) )
522522   AM_RANGE(0x0400, 0x0400) AM_READWRITE(input_latch_r, input_latch_ack_w)
523523   AM_RANGE(0x0401, 0x0401) AM_WRITE(output_latch_w)
r1293r1294
535535 *
536536 *************************************/
537537
538ADDRESS_MAP_START( denver_program_map, ADDRESS_SPACE_PROGRAM, 32 )
538static ADDRESS_MAP_START( denver_program_map, ADDRESS_SPACE_PROGRAM, 32 )
539539   ADDRESS_MAP_FLAGS( AMEF_UNMAP(1) )
540540   AM_RANGE(0x0000, 0x3fff) AM_RAM   AM_BASE(&dcs_internal_program_ram)
541541ADDRESS_MAP_END
542542
543543
544ADDRESS_MAP_START( denver_data_map, ADDRESS_SPACE_DATA, 16 )
544static ADDRESS_MAP_START( denver_data_map, ADDRESS_SPACE_DATA, 16 )
545545   ADDRESS_MAP_FLAGS( AMEF_UNMAP(1) )
546546   AM_RANGE(0x0000, 0x07ff) AM_RAMBANK(20)
547547   AM_RANGE(0x0800, 0x3fdf) AM_RAM
r1293r1294
549549ADDRESS_MAP_END
550550
551551
552ADDRESS_MAP_START( denver_io_map, ADDRESS_SPACE_IO, 16 )
552static ADDRESS_MAP_START( denver_io_map, ADDRESS_SPACE_IO, 16 )
553553   ADDRESS_MAP_FLAGS( AMEF_UNMAP(1) )
554554   AM_RANGE(0x0400, 0x0400) AM_READWRITE(input_latch_r, input_latch_ack_w)
555555   AM_RANGE(0x0401, 0x0401) AM_WRITE(output_latch_w)
r1293r1294
810810   /* reset timers */
811811   dcs.timer_enable = 0;
812812   dcs.timer_scale = 1;
813   mame_timer_adjust(dcs.internal_timer, time_never, 0, time_never);
813   timer_adjust(dcs.internal_timer, attotime_never, 0, attotime_never);
814814
815815   /* start the SPORT0 timer */
816816   if (dcs.sport_timer)
817      mame_timer_adjust(dcs.sport_timer, MAME_TIME_IN_HZ(1000), 0, MAME_TIME_IN_HZ(1000));
817      timer_adjust(dcs.sport_timer, ATTOTIME_IN_HZ(1000), 0, ATTOTIME_IN_HZ(1000));
818818
819819   /* reset the HLE transfer states */
820820   transfer.dcs_state = transfer.state = 0;
r1293r1294
891891   dcs.sounddata_words = dcs.bootrom_words;
892892
893893   /* create the timers */
894   dcs.internal_timer = mame_timer_alloc(internal_timer_callback);
895   dcs.reg_timer = mame_timer_alloc(dcs_irq);
894   dcs.internal_timer = timer_alloc(internal_timer_callback);
895   dcs.reg_timer = timer_alloc(dcs_irq);
896896
897897   /* non-RAM based automatically acks */
898898   dcs.auto_ack = TRUE;
r1293r1294
942942   dcs_sram = auto_malloc(0x8000*4);
943943
944944   /* create the timers */
945   dcs.internal_timer = mame_timer_alloc(internal_timer_callback);
946   dcs.reg_timer = mame_timer_alloc(dcs_irq);
947   dcs.sport_timer = mame_timer_alloc(sport0_irq);
945   dcs.internal_timer = timer_alloc(internal_timer_callback);
946   dcs.reg_timer = timer_alloc(dcs_irq);
947   dcs.sport_timer = timer_alloc(sport0_irq);
948948
949949   /* we don't do auto-ack by default */
950950   dcs.auto_ack = FALSE;
r1293r1294
955955
956956   /* allocate a watchdog timer for HLE transfers */
957957   if (HLE_TRANSFERS)
958      transfer.watchdog = mame_timer_alloc(transfer_watchdog_callback);
958      transfer.watchdog = timer_alloc(transfer_watchdog_callback);
959959
960960   /* reset the system */
961961   dcs_reset(Machine, 0);
962962}
963963
964964
965#ifdef UNUSED_FUNCTION
965966void dsio_init(int dram_in_mb, offs_t polling_offset)
966967{
967968   dcs2_init(dram_in_mb, polling_offset);
968969}
970#endif
969971
970972
971973void dcs_set_auto_ack(int state)
r1293r1294
14341436{
14351437   /* only boost for DCS2 boards */
14361438   if (!dcs.auto_ack && !HLE_TRANSFERS)
1437      cpu_boost_interleave(MAME_TIME_IN_NSEC(500), MAME_TIME_IN_USEC(5));
1439      cpu_boost_interleave(ATTOTIME_IN_NSEC(500), ATTOTIME_IN_USEC(5));
14381440   return dcs.latch_control;
14391441}
14401442
r1293r1294
14921494      logerror("%08X:dcs_data_w(%04X)\n", activecpu_get_pc(), data);
14931495
14941496   /* boost the interleave temporarily */
1495   cpu_boost_interleave(MAME_TIME_IN_NSEC(500), MAME_TIME_IN_USEC(5));
1497   cpu_boost_interleave(ATTOTIME_IN_NSEC(500), ATTOTIME_IN_USEC(5));
14961498
14971499   /* set the IRQ line on the ADSP */
14981500   cpunum_set_input_line(dcs.cpunum, ADSP2105_IRQ2, ASSERT_LINE);
r1293r1294
16831685
16841686   /* set the next timer, but only if it's for a reasonable number */
16851687   if (!dcs.timer_ignore && (dcs.timer_period > 10 || dcs.timer_scale > 1))
1686      mame_timer_adjust(dcs.internal_timer, MAME_TIME_IN_CYCLES(target_cycles, dcs.cpunum), 0, time_zero);
1688      timer_adjust(dcs.internal_timer, ATTOTIME_IN_CYCLES(target_cycles, dcs.cpunum), 0, attotime_zero);
16871689   cpunum_set_input_line(dcs.cpunum, ADSP2105_TIMER, PULSE_LINE);
16881690}
16891691
r1293r1294
17181720
17191721   /* adjust the timer if not optimized */
17201722   if (!dcs.timer_ignore)
1721      mame_timer_adjust(dcs.internal_timer, MAME_TIME_IN_CYCLES(dcs.timer_scale * (dcs.timer_start_count + 1), dcs.cpunum), 0, time_zero);
1723      timer_adjust(dcs.internal_timer, ATTOTIME_IN_CYCLES(dcs.timer_scale * (dcs.timer_start_count + 1), dcs.cpunum), 0, attotime_zero);
17221724}
17231725
17241726
r1293r1294
17281730   dcs.timer_ignore = 0;
17291731   if (enable)
17301732   {
1731//      mame_printf_debug("Timer enabled @ %d cycles/int, or %f Hz\n", dcs.timer_scale * (dcs.timer_period + 1), 1.0 / MAME_TIME_IN_CYCLES(dcs.timer_scale * (dcs.timer_period + 1), dcs.cpunum));
1733//      mame_printf_debug("Timer enabled @ %d cycles/int, or %f Hz\n", dcs.timer_scale * (dcs.timer_period + 1), 1.0 / ATTOTIME_IN_CYCLES(dcs.timer_scale * (dcs.timer_period + 1), dcs.cpunum));
17321734      reset_timer();
17331735   }
17341736   else
17351737   {
17361738//      mame_printf_debug("Timer disabled\n");
1737      mame_timer_adjust(dcs.internal_timer, time_never, 0, time_never);
1739      timer_adjust(dcs.internal_timer, attotime_never, 0, attotime_never);
17381740   }
17391741}
17401742
r1293r1294
18121814         if ((data & 0x0800) == 0)
18131815         {
18141816            dmadac_enable(0, dcs.channels, 0);
1815            mame_timer_adjust(dcs.reg_timer, time_never, 0, time_never);
1817            timer_adjust(dcs.reg_timer, attotime_never, 0, attotime_never);
18161818         }
18171819         break;
18181820
r1293r1294
18211823         if ((data & 0x0002) == 0)
18221824         {
18231825            dmadac_enable(0, dcs.channels, 0);
1824            mame_timer_adjust(dcs.reg_timer, time_never, 0, time_never);
1826            timer_adjust(dcs.reg_timer, attotime_never, 0, attotime_never);
18251827         }
18261828         break;
18271829
r1293r1294
19211923   /* calculate how long until we generate an interrupt */
19221924
19231925   /* frequency the time per each bit sent */
1924   mame_time sample_period = scale_up_mame_time(MAME_TIME_IN_HZ(Machine->drv->cpu[dcs.cpunum].clock), 2 * (dcs.control_regs[S1_SCLKDIV_REG] + 1));
1926   attotime sample_period = attotime_mul(ATTOTIME_IN_HZ(Machine->drv->cpu[dcs.cpunum].clock), 2 * (dcs.control_regs[S1_SCLKDIV_REG] + 1));
19251927
19261928   /* now put it down to samples, so we know what the channel frequency has to be */
1927   sample_period = scale_up_mame_time(sample_period, 16 * dcs.channels);
1928   dmadac_set_frequency(0, dcs.channels, SUBSECONDS_TO_HZ(sample_period.subseconds));
1929   sample_period = attotime_mul(sample_period, 16 * dcs.channels);
1930   dmadac_set_frequency(0, dcs.channels, ATTOSECONDS_TO_HZ(sample_period.attoseconds));
19291931   dmadac_enable(0, dcs.channels, 1);
19301932
19311933   /* fire off a timer wich will hit every half-buffer */
19321934   if (dcs.incs)
19331935   {
1934      mame_time period = scale_down_mame_time(scale_up_mame_time(sample_period, dcs.size), (2 * dcs.channels * dcs.incs));
1935      mame_timer_adjust(dcs.reg_timer, period, 0, period);
1936      attotime period = attotime_div(attotime_mul(sample_period, dcs.size), (2 * dcs.channels * dcs.incs));
1937      timer_adjust(dcs.reg_timer, period, 0, period);
19361938   }
19371939}
19381940
r1293r1294
19851987   dmadac_enable(0, dcs.channels, 0);
19861988
19871989   /* remove timer */
1988   mame_timer_adjust(dcs.reg_timer, time_never, 0, time_never);
1990   timer_adjust(dcs.reg_timer, attotime_never, 0, attotime_never);
19891991}
19901992
19911993
r1293r1294
20342036      for ( ; transfer.fifo_entries; transfer.fifo_entries--)
20352037         preprocess_write((*dcs.fifo_data_r)());
20362038   }
2037   mame_timer_adjust(transfer.watchdog, MAME_TIME_IN_MSEC(1), transfer.writes_left, time_zero);
2039   timer_adjust(transfer.watchdog, ATTOTIME_IN_MSEC(1), transfer.writes_left, attotime_zero);
20382040}
20392041
20402042
r1293r1294
20432045   /* if the output is full, stall for a usec */
20442046   if (IS_OUTPUT_FULL())
20452047   {
2046      mame_timer_set(MAME_TIME_IN_USEC(1), param, s1_ack_callback2);
2048      timer_set(ATTOTIME_IN_USEC(1), param, s1_ack_callback2);
20472049      return;
20482050   }
20492051   output_latch_w(0, 0x000a, 0);
r1293r1294
20552057   /* if the output is full, stall for a usec */
20562058   if (IS_OUTPUT_FULL())
20572059   {
2058      mame_timer_set(MAME_TIME_IN_USEC(1), param, s1_ack_callback1);
2060      timer_set(ATTOTIME_IN_USEC(1), param, s1_ack_callback1);
20592061      return;
20602062   }
20612063   output_latch_w(0, param, 0);
20622064
20632065   /* chain to the next word we need to write back */
2064   mame_timer_set(MAME_TIME_IN_USEC(1), 0, s1_ack_callback2);
2066   timer_set(ATTOTIME_IN_USEC(1), 0, s1_ack_callback2);
20652067}
20662068
20672069
r1293r1294
21712173
21722174            /* if we're done, start a timer to send the response words */
21732175            if (transfer.state == 0)
2174               mame_timer_set(MAME_TIME_IN_USEC(1), transfer.sum, s1_ack_callback1);
2176               timer_set(ATTOTIME_IN_USEC(1), transfer.sum, s1_ack_callback1);
21752177            return 1;
21762178         }
21772179         break;
r1293r1294
21852187   /* if the output is full, stall for a usec */
21862188   if (IS_OUTPUT_FULL())
21872189   {
2188      mame_timer_set(MAME_TIME_IN_USEC(1), param, s2_ack_callback);
2190      timer_set(ATTOTIME_IN_USEC(1), param, s2_ack_callback);
21892191      return;
21902192   }
21912193   output_latch_w(0, param, 0);
r1293r1294
22482250         transfer.sum = 0;
22492251         if (HLE_TRANSFERS)
22502252         {
2251            mame_timer_adjust(transfer.watchdog, MAME_TIME_IN_MSEC(1), transfer.writes_left, time_zero);
2253            timer_adjust(transfer.watchdog, ATTOTIME_IN_MSEC(1), transfer.writes_left, attotime_zero);
22522254            return 1;
22532255         }
22542256         break;
r1293r1294
22732275            /* if we're done, start a timer to send the response words */
22742276            if (transfer.state == 0)
22752277            {
2276               mame_timer_set(MAME_TIME_IN_USEC(1), transfer.sum, s2_ack_callback);
2277               mame_timer_adjust(transfer.watchdog, time_never, 0, time_never);
2278               timer_set(ATTOTIME_IN_USEC(1), transfer.sum, s2_ack_callback);
2279               timer_adjust(transfer.watchdog, attotime_never, 0, attotime_never);
22782280            }
22792281            return 1;
22802282         }
src/mame/audio/exidy.c
r1293r1294
4848static UINT8 riot_irq_state;
4949
5050/* 6532 variables */
51static mame_timer *riot_timer;
51static emu_timer *riot_timer;
5252static UINT8 riot_irq_flag;
5353static UINT8 riot_timer_irq_enable;
5454static UINT8 riot_PA7_irq_enable;
r1293r1294
420420   sh6840_LFSR_3 = 0xffffffff;
421421
422422   /* Init 6532 */
423    riot_timer = mame_timer_alloc(riot_interrupt);
423    riot_timer = timer_alloc(riot_interrupt);
424424    riot_irq_flag = 0;
425425    riot_timer_irq_enable = 0;
426426   riot_porta_data = 0xff;
r1293r1294
491491
492492      /* now start counting clock cycles down */
493493      riot_state = RIOT_POST_COUNT;
494      mame_timer_adjust(riot_timer, scale_up_mame_time(MAME_TIME_IN_HZ(SH6532_CLOCK), 0xff), 0, time_zero);
494      timer_adjust(riot_timer, attotime_mul(ATTOTIME_IN_HZ(SH6532_CLOCK), 0xff), 0, attotime_zero);
495495   }
496496
497497   /* if not, we are done counting down */
498498   else
499499   {
500500      riot_state = RIOT_IDLE;
501      mame_timer_adjust(riot_timer, time_never, 0, time_never);
501      timer_adjust(riot_timer, attotime_never, 0, attotime_never);
502502   }
503503}
504504
r1293r1294
536536               if (!(data & 0x01) && (riot_portb_data & 0x01))
537537               {
538538                  riot_porta_data = tms5220_status_r(0);
539                  logerror("(%f)%04X:TMS5220 status read = %02X\n", mame_time_to_double(mame_timer_get_time()), activecpu_get_previouspc(), riot_porta_data);
539                  logerror("(%f)%04X:TMS5220 status read = %02X\n", attotime_to_double(timer_get_time()), activecpu_get_previouspc(), riot_porta_data);
540540               }
541541               if (!(data & 0x02) && (riot_portb_data & 0x02))
542542               {
543                  logerror("(%f)%04X:TMS5220 data write = %02X\n", mame_time_to_double(mame_timer_get_time()), activecpu_get_previouspc(), riot_porta_data);
543                  logerror("(%f)%04X:TMS5220 data write = %02X\n", attotime_to_double(timer_get_time()), activecpu_get_previouspc(), riot_porta_data);
544544                  tms5220_data_w(0, riot_porta_data);
545545               }
546546            }
r1293r1294
575575
576576      /* set a new timer */
577577      riot_clock_divisor = divisors[offset & 0x03];
578      mame_timer_adjust(riot_timer, scale_up_mame_time(MAME_TIME_IN_HZ(SH6532_CLOCK), data * riot_clock_divisor), 0, time_zero);
578      timer_adjust(riot_timer, attotime_mul(ATTOTIME_IN_HZ(SH6532_CLOCK), data * riot_clock_divisor), 0, attotime_zero);
579579      riot_state = RIOT_COUNT;
580580   }
581581}
r1293r1294
641641            return 0x00;
642642
643643         case RIOT_COUNT:
644            return mame_time_to_double(mame_timer_timeleft(riot_timer)) * SH6532_CLOCK / riot_clock_divisor;
644            return attotime_to_double(timer_timeleft(riot_timer)) * SH6532_CLOCK / riot_clock_divisor;
645645
646646         case RIOT_POST_COUNT:
647            return mame_time_to_double(mame_timer_timeleft(riot_timer)) * SH6532_CLOCK;
647            return attotime_to_double(timer_timeleft(riot_timer)) * SH6532_CLOCK;
648648      }
649649   }
650650
r1293r1294
843843   }
844844    if (!(offset & 0x40))
845845    {
846       mame_time curtime = mame_timer_get_time();
847       int clock_pulse = curtime.subseconds / HZ_TO_SUBSECONDS(2 * CVSD_CLOCK_FREQ);
846       attotime curtime = timer_get_time();
847       int clock_pulse = curtime.attoseconds / HZ_TO_ATTOSECONDS(2 * CVSD_CLOCK_FREQ);
848848       return (clock_pulse & 1) << 7;
849849   }
850850   return 0;
src/mame/audio/8080bw.c
r1293r1294
99#include "sound/speaker.h"
1010
1111
12static mame_timer *schaser_effect_555_timer;
13static mame_time schaser_effect_555_time_remain;
12static emu_timer *schaser_effect_555_timer;
13static attotime schaser_effect_555_time_remain;
1414static int schaser_effect_555_is_low;
1515static int schaser_explosion;
1616static UINT8 port_1_last = 0;
r1293r1294
797797   {
798798      if (effect)
799799      {
800         if (compare_mame_times(schaser_effect_555_time_remain, time_zero) != 0)
800         if (attotime_compare(schaser_effect_555_time_remain, attotime_zero) != 0)
801801         {
802802            /* timer re-enabled, use up remaining 555 high time */
803            mame_timer_adjust(schaser_effect_555_timer, schaser_effect_555_time_remain, effect, time_zero);
803            timer_adjust(schaser_effect_555_timer, schaser_effect_555_time_remain, effect, attotime_zero);
804804         }
805805         else if (!schaser_effect_555_is_low)
806806         {
807807            /* set 555 high time */
808            mame_time new_time = make_mame_time(0, MAX_SUBSECONDS * .8873 * schaser_effect_rc[effect]);
809            mame_timer_adjust(schaser_effect_555_timer, new_time, effect, time_zero);
808            attotime new_time = attotime_make(0, ATTOSECONDS_PER_SECOND * .8873 * schaser_effect_rc[effect]);
809            timer_adjust(schaser_effect_555_timer, new_time, effect, attotime_zero);
810810         }
811811      }
812812      else
r1293r1294
814814         /* disable effect - stops at end of low cycle */
815815         if (!schaser_effect_555_is_low)
816816         {
817            schaser_effect_555_time_remain = mame_timer_timeleft(schaser_effect_555_timer);
818            mame_timer_adjust(schaser_effect_555_timer, time_never, 0, time_never);
817            schaser_effect_555_time_remain = timer_timeleft(schaser_effect_555_timer);
818            timer_adjust(schaser_effect_555_timer, attotime_never, 0, attotime_never);
819819         }
820820      }
821821      last_effect = effect;
r1293r1294
860860static TIMER_CALLBACK( schaser_effect_555_cb )
861861{
862862   int effect = param;
863   mame_time new_time;
863   attotime new_time;
864864   /* Toggle 555 output */
865865   schaser_effect_555_is_low = !schaser_effect_555_is_low;
866   schaser_effect_555_time_remain = time_zero;
866   schaser_effect_555_time_remain = attotime_zero;
867867
868868   if (schaser_effect_555_is_low)
869      new_time = scale_down_mame_time(PERIOD_OF_555_ASTABLE(0, RES_K(20), CAP_U(1)), 2);
869      new_time = attotime_div(PERIOD_OF_555_ASTABLE(0, RES_K(20), CAP_U(1)), 2);
870870   else
871871   {
872872      if (effect)
873         new_time = make_mame_time(0, MAX_SUBSECONDS * .8873 * schaser_effect_rc[effect]);
873         new_time = attotime_make(0, ATTOSECONDS_PER_SECOND * .8873 * schaser_effect_rc[effect]);
874874      else
875         new_time = time_never;
875         new_time = attotime_never;
876876   }
877   mame_timer_adjust(schaser_effect_555_timer, new_time, effect, time_zero);
877   timer_adjust(schaser_effect_555_timer, new_time, effect, attotime_zero);
878878   SN76477_enable_w(0, !(schaser_effect_555_is_low || schaser_explosion));
879879   SN76477_one_shot_cap_voltage_w(0, !(schaser_effect_555_is_low || schaser_explosion) ? 0 : SN76477_EXTERNAL_VOLTAGE_DISCONNECT);
880880}
r1293r1294
882882
883883MACHINE_START( schaser )
884884{
885   schaser_effect_555_timer = mame_timer_alloc(schaser_effect_555_cb);
885   schaser_effect_555_timer = timer_alloc(schaser_effect_555_cb);
886886
887887   machine_start_mw8080bw(machine);
888888}
r1293r1294
891891MACHINE_RESET( schaser )
892892{
893893   schaser_effect_555_is_low = 0;
894   mame_timer_adjust(schaser_effect_555_timer, time_never, 0, time_never);
894   timer_adjust(schaser_effect_555_timer, attotime_never, 0, attotime_never);
895895   schaser_sh_port_1_w(0, 0);
896896   schaser_sh_port_2_w(0, 0);
897   schaser_effect_555_time_remain = time_zero;
897   schaser_effect_555_time_remain = attotime_zero;
898898
899899   machine_reset_mw8080bw(machine);
900900}
src/mame/audio/targ.c
r1293r1294
4747#define FALLING_EDGE(bit) (!(data & bit) && (targ_sh_ctrl0 & bit))
4848
4949
50void targ_tone_generator(int data)
50static void targ_tone_generator(int data)
5151{
5252   int maxfreq;
5353
src/mame/machine/rainbow.c
r1293r1294
827827
828828   state_save_register_item("cchip", 0, current_bank);
829829
830   mame_timer_pulse(MAME_TIME_IN_HZ(60), 0, cchip_timer);
830   timer_pulse(ATTOTIME_IN_HZ(60), 0, cchip_timer);
831831}
src/mame/machine/scudsp.c
r1293r1294
118118#if DEBUG_DSP
119119static FILE *log_file = NULL;
120120#endif
121void dsp_dasm_opcode( UINT32 op, char *buffer );
121static void dsp_dasm_opcode( UINT32 op, char *buffer );
122122
123123
124124
r1293r1294
10081008};
10091009
10101010
1011void   dsp_dasm_prefix( const char* format, char* buffer, UINT32 *data )
1011static void   dsp_dasm_prefix( const char* format, char* buffer, UINT32 *data )
10121012{
10131013
10141014   for ( ; *format; format++ )
r1293r1294
11091109   }
11101110   *buffer = 0;
11111111}
1112void   dsp_dasm_operation( UINT32 op, char *buffer )
1112static void   dsp_dasm_operation( UINT32 op, char *buffer )
11131113{
11141114   char *my_buffer = buffer;
11151115   char temp_buffer[64];
r1293r1294
11751175   sprintf( my_buffer, "%-10s", temp_buffer );
11761176}
11771177
1178void dsp_dasm_move_immediate( UINT32 op, char *buffer )
1178static void dsp_dasm_move_immediate( UINT32 op, char *buffer )
11791179{
11801180   UINT32 data[3];
11811181   if ( (op & 0x2000000) )
r1293r1294
11931193   }
11941194}
11951195
1196void dsp_dasm_jump( UINT32 op, char *buffer )
1196static void dsp_dasm_jump( UINT32 op, char *buffer )
11971197{
11981198   UINT32 data[2];
11991199   if ( op & 0x3F80000 )
r1293r1294
12091209   }
12101210}
12111211
1212void dsp_dasm_loop( UINT32 op, char* buffer )
1212static void dsp_dasm_loop( UINT32 op, char* buffer )
12131213{
12141214   if ( op & 0x8000000 )
12151215   {
r1293r1294
12211221   }
12221222}
12231223
1224void dsp_dasm_end( UINT32 op, char* buffer )
1224static void dsp_dasm_end( UINT32 op, char* buffer )
12251225{
12261226   if ( op & 0x8000000 )
12271227   {
r1293r1294
12331233   }
12341234}
12351235
1236void dsp_dasm_dma( UINT32 op, char* buffer )
1236static void dsp_dasm_dma( UINT32 op, char* buffer )
12371237{
12381238   UINT32 data[4];
12391239   data[0] = (op &  0x4000) >> 14; /* H */
src/mame/machine/xevious.c
r1293r1294
1717
1818***************************************************************************/
1919
20static mame_timer *nmi_timer;
20static emu_timer *nmi_timer;
2121
2222static UINT8 customio[16];
2323static char battles_customio_command;
r1293r1294
3636   battles_customio_command_count = 0;
3737   battles_customio_data = 0;
3838   battles_sound_played = 0;
39   nmi_timer = mame_timer_alloc(battles_nmi_generate);
39   nmi_timer = timer_alloc(battles_nmi_generate);
4040}
4141
4242
r1293r1294
9696   switch (data)
9797   {
9898      case 0x10:
99         mame_timer_adjust(nmi_timer, time_never, 0, time_never);
99         timer_adjust(nmi_timer, attotime_never, 0, attotime_never);
100100         return; /* nop */
101101   }
102   mame_timer_adjust(nmi_timer, MAME_TIME_IN_USEC(166), 0, MAME_TIME_IN_USEC(166));
102   timer_adjust(nmi_timer, ATTOTIME_IN_USEC(166), 0, ATTOTIME_IN_USEC(166));
103103
104104}
105105
src/mame/machine/cubocd32.c
r1293r1294
5959   UINT8   cdrom_cmd_resp;
6060   cdrom_file *cdrom;
6161   UINT8 *   cdrom_toc;
62   mame_timer *dma_timer;
63   mame_timer *frame_timer;
62   emu_timer *dma_timer;
63   emu_timer *frame_timer;
6464} akiko;
6565
6666static TIMER_CALLBACK(akiko_dma_proc);
r1293r1294
9494   akiko.cdrom_cmd_resp = 0;
9595   akiko.cdrom = cdrom_open(get_disk_handle(0));
9696   akiko.cdrom_toc = NULL;
97   akiko.dma_timer = mame_timer_alloc(akiko_dma_proc);
98   akiko.frame_timer = mame_timer_alloc(akiko_frame_proc);
97   akiko.dma_timer = timer_alloc(akiko_dma_proc);
98   akiko.frame_timer = timer_alloc(akiko_frame_proc);
9999
100100   /* create the TOC table */
101101   if ( akiko.cdrom != NULL && cdrom_get_last_track(akiko.cdrom) )
r1293r1294
274274   if (cddanum != -1)
275275   {
276276      cdda_stop_audio(cddanum);
277      mame_timer_reset( akiko.frame_timer, time_never );
277      timer_reset( akiko.frame_timer, attotime_never );
278278   }
279279}
280280
r1293r1294
284284   if (cddanum != -1)
285285   {
286286      cdda_start_audio(cddanum, lba, num_blocks);
287      mame_timer_adjust( akiko.frame_timer, MAME_TIME_IN_HZ( 75 ), 0, time_zero );
287      timer_adjust( akiko.frame_timer, ATTOTIME_IN_HZ( 75 ), 0, attotime_zero );
288288   }
289289}
290290
r1293r1294
299299
300300         if ( pause )
301301         {
302            mame_timer_reset( akiko.frame_timer, time_never );
302            timer_reset( akiko.frame_timer, attotime_never );
303303         }
304304         else
305305         {
306            mame_timer_adjust( akiko.frame_timer, MAME_TIME_IN_HZ( 75 ), 0, time_zero );
306            timer_adjust( akiko.frame_timer, ATTOTIME_IN_HZ( 75 ), 0, attotime_zero );
307307         }
308308      }
309309   }
r1293r1294
367367         akiko_set_cd_status( 0x80000000 );   /* subcode ready */
368368      }
369369
370      mame_timer_adjust( akiko.frame_timer, MAME_TIME_IN_HZ( 75 ), 0, time_zero );
370      timer_adjust( akiko.frame_timer, ATTOTIME_IN_HZ( 75 ), 0, attotime_zero );
371371   }
372372}
373373
r1293r1294
472472   if ( akiko.cdrom_readreqmask == 0 )
473473      akiko_set_cd_status(0x04000000);
474474   else
475      mame_timer_adjust( akiko.dma_timer, MAME_TIME_IN_USEC( CD_SECTOR_TIME / akiko.cdrom_speed ), 0, time_zero );
475      timer_adjust( akiko.dma_timer, ATTOTIME_IN_USEC( CD_SECTOR_TIME / akiko.cdrom_speed ), 0, attotime_zero );
476476}
477477
478478static void akiko_start_dma( void )
r1293r1294
488488
489489   akiko.cdrom_lba_cur = akiko.cdrom_lba_start;
490490
491   mame_timer_adjust( akiko.dma_timer, MAME_TIME_IN_USEC( CD_SECTOR_TIME / akiko.cdrom_speed ), 0, time_zero );
491   timer_adjust( akiko.dma_timer, ATTOTIME_IN_USEC( CD_SECTOR_TIME / akiko.cdrom_speed ), 0, attotime_zero );
492492}
493493
494494static void akiko_setup_response( int len, UINT8 *r1 )
r1293r1294
679679      {
680680         akiko.cdrom_cmd_start = (akiko.cdrom_cmd_start+3) & 0xff;
681681
682         mame_timer_set( MAME_TIME_IN_MSEC(1), resp[0], akiko_cd_delayed_cmd );
682         timer_set( ATTOTIME_IN_MSEC(1), resp[0], akiko_cd_delayed_cmd );
683683
684684         break;
685685      }
src/mame/machine/playch10.c
r1293r1294
88int pc10_nmi_enable;   /* nmi enable */
99int pc10_dog_di;      /* watchdog disable */
1010int pc10_int_detect;   /* interrupt detect */
11int pc10_gun_controller;
11static int pc10_gun_controller;
1212int pc10_game_mode;      /* Used in Single monitor version to display Game or PPU */
1313int pc10_dispmask_old;
1414
src/mame/machine/s16fd.c
r1293r1294
4646   if it is then it copies the cached data to the user region where code is
4747   executed from, if its not cached then it gets decrypted to the current
4848   cache position using the functions in fd1094.c */
49void fd1094_setstate_and_decrypt(int state)
49static void fd1094_setstate_and_decrypt(int state)
5050{
5151   int i;
5252   UINT32 addr;
r1293r1294
9595}
9696
9797/* Callback for CMP.L instructions (state change) */
98void fd1094_cmp_callback(UINT32 val, int reg)
98static void fd1094_cmp_callback(UINT32 val, int reg)
9999{
100100   if (reg == 0 && (val & 0x0000ffff) == 0x0000ffff) // ?
101101   {
r1293r1294
104104}
105105
106106/* Callback when the FD1094 enters interrupt code */
107int fd1094_int_callback (int irq)
107static int fd1094_int_callback (int irq)
108108{
109109   fd1094_setstate_and_decrypt(FD1094_STATE_IRQ);
110110   return (0x60+irq*4)/4; // vector address
111111}
112112
113void fd1094_rte_callback (void)
113static void fd1094_rte_callback (void)
114114{
115115   fd1094_setstate_and_decrypt(FD1094_STATE_RTE);
116116}
117117
118118
119119/* KLUDGE, set the initial PC / SP based on table as we can't decrypt them yet */
120void fd1094_kludge_reset_values(void)
120static void fd1094_kludge_reset_values(void)
121121{
122122   int i;
123123
src/mame/machine/galaxian.c
r1293r1294
1212#include "includes/galaxian.h"
1313
1414static int irq_line;
15static mame_timer *int_timer;
15static emu_timer *int_timer;
1616
1717static UINT8 kingball_speech_dip;
1818static UINT8 kingball_sound;
r1293r1294
6363
6464   param = (param + 0x10) & 0xff;
6565
66   mame_timer_adjust(int_timer, video_screen_get_time_until_pos(0, param, 0), param, time_zero);
66   timer_adjust(int_timer, video_screen_get_time_until_pos(0, param, 0), param, attotime_zero);
6767
6868   TTL7474_update(0);
6969}
r1293r1294
8484   TTL7474_preset_w(1, 0);
8585
8686   /* start a timer to generate interrupts */
87   int_timer = mame_timer_alloc(interrupt_timer);
88   mame_timer_adjust(int_timer, video_screen_get_time_until_pos(0, 0, 0), 0, time_zero);
87   int_timer = timer_alloc(interrupt_timer);
88   timer_adjust(int_timer, video_screen_get_time_until_pos(0, 0, 0), 0, attotime_zero);
8989}
9090
9191MACHINE_RESET( galaxian )
src/mame/machine/asic65.c
r1293r1294
194194   if (asic65_type == ASIC65_ROMBASED)
195195   {
196196      timer_call_after_resynch(data | (offset << 16), m68k_asic65_deferred_w);
197      cpu_boost_interleave(time_zero, MAME_TIME_IN_USEC(20));
197      cpu_boost_interleave(attotime_zero, ATTOTIME_IN_USEC(20));
198198      return;
199199   }
200200
r1293r1294
232232   if (asic65_type == ASIC65_ROMBASED)
233233   {
234234      asic65_68full = 0;
235      cpu_boost_interleave(time_zero, MAME_TIME_IN_USEC(5));
235      cpu_boost_interleave(attotime_zero, ATTOTIME_IN_USEC(5));
236236      return asic65_68data;
237237   }
238238
r1293r1294
452452      /* bit 14 = 68FULL */
453453      /* bit 13 = XFLG */
454454      /* bit 12 = controlled by jumper */
455      cpu_boost_interleave(time_zero, MAME_TIME_IN_USEC(5));
455      cpu_boost_interleave(attotime_zero, ATTOTIME_IN_USEC(5));
456456      return (asic65_tfull << 15) | (asic65_68full << 14) | (asic65_xflg << 13) | 0x0000;
457457   }
458458   else
src/mame/machine/pgmcrypt.c
r1293r1294
319319}
320320
321321
322#ifdef UNUSED_FUNCTION
322323static UINT8 dfront_tab[256] = {
323324  0x51, 0xc4, 0xe3, 0x10, 0x1c, 0xad, 0x8a, 0x39, 0x8c, 0xe0, 0xa5, 0x04, 0x0f, 0xe4, 0x35, 0xc3,
324325  0x2d, 0x6b, 0x32, 0xe2, 0x60, 0x54, 0x63, 0x06, 0xa3, 0xf1, 0x0b, 0x5f, 0x6c, 0x5c, 0xb3, 0xec,
r1293r1294
431432      src[i] = x;
432433   }
433434}
435#endif
434436
435437
436438static UINT8 mm_tab[256] = {
src/mame/machine/segas32.c
r1293r1294
1212
1313#define xxxx 0x00
1414
15const UINT8 ga2_v25_opcode_table[256] = {
15static const UINT8 ga2_v25_opcode_table[256] = {
1616     xxxx,xxxx,0xEA,xxxx,xxxx,0x8B,xxxx,xxxx,xxxx,xxxx,xxxx,xxxx,xxxx,xxxx,xxxx,xxxx,
1717     xxxx,xxxx,xxxx,xxxx,xxxx,xxxx,xxxx,xxxx,xxxx,xxxx,xxxx,xxxx,xxxx,xxxx,xxxx,0xFA,
1818     xxxx,xxxx,xxxx,xxxx,xxxx,xxxx,xxxx,xxxx,xxxx,xxxx,xxxx,xxxx,0x49,xxxx,xxxx,xxxx,
r1293r1294
3333
3434#undef xxxx
3535
36void nec_v25_cpu_decrypt(void)
36static void nec_v25_cpu_decrypt(void)
3737{
3838   int i;
3939   UINT8 *rom = memory_region(REGION_CPU3);
src/mame/machine/slapfght.c
r1293r1294
1313UINT8 *slapfight_dpram;
1414size_t slapfight_dpram_size;
1515
16int slapfight_status;
17int getstar_sequence_index;
18int getstar_sh_intenabled;
16static int slapfight_status;
17static int getstar_sequence_index;
18static int getstar_sh_intenabled;
1919
2020static int slapfight_status_state;
2121extern UINT8 *getstar_e803;
src/mame/machine/mhavoc.c
r1293r1294
113113   gamma_irq_clock = 0;
114114
115115   /* set a timer going for the CPU interrupt generators */
116   mame_timer_pulse(MAME_TIME_IN_HZ(MHAVOC_CLOCK_5K), 0, cpu_irq_clock);
116   timer_pulse(ATTOTIME_IN_HZ(MHAVOC_CLOCK_5K), 0, cpu_irq_clock);
117117
118118   state_save_register_item("misc", 0, alpha_data);
119119   state_save_register_item("misc", 0, alpha_rcvd);
r1293r1294
146146   cpunum_set_input_line(1, INPUT_LINE_NMI, PULSE_LINE);
147147
148148   /* the sound CPU needs to reply in 250microseconds (according to Neil Bradley) */
149   mame_timer_set(MAME_TIME_IN_USEC(250), 0, 0);
149   timer_set(ATTOTIME_IN_USEC(250), 0, 0);
150150}
151151
152152
src/mame/machine/equites.c
r1293r1294
258258   mrulemap = (struct MRULELIST *)byte_ptr; // pointer table to rule lists
259259   mrulepool = (struct MRULE *)(byte_ptr + 0x4000); // rules pool
260260
261   mame_timer_pulse(MAME_TIME_IN_HZ(106), 0, equites_synth_callback); // hand tuned
261   timer_pulse(ATTOTIME_IN_HZ(106), 0, equites_synth_callback); // hand tuned
262262
263263   seedMT(mame_rand(Machine));
264264}
src/mame/machine/decocass.c
r1293r1294
1212/* tape direction, speed and timing (used also in video/decocass.c) */
1313INT32 tape_dir;
1414INT32 tape_speed;
15mame_time tape_time0;
16mame_timer *tape_timer;
15attotime tape_time0;
16emu_timer *tape_timer;
1717
1818static INT32 firsttime = 1;
1919static INT32 tape_present;
r1293r1294
9494
9595/* sound latches, ACK status bits and NMI timer */
9696static UINT8 decocass_sound_ack;
97static mame_timer *decocass_sound_timer;
97static emu_timer *decocass_sound_timer;
9898
9999WRITE8_HANDLER( decocass_coin_counter_w )
100100{
r1293r1294
148148WRITE8_HANDLER( decocass_sound_nmi_enable_w )
149149{
150150   LOG(2,("CPU #%d sound NMI enb -> $%02x\n", cpu_getactivecpu(), data));
151   mame_timer_adjust(decocass_sound_timer, MAME_TIME_IN_HZ(256 * 57 / 8 / 2), 0, MAME_TIME_IN_HZ(256 * 57 / 8 / 2));
151   timer_adjust(decocass_sound_timer, ATTOTIME_IN_HZ(256 * 57 / 8 / 2), 0, ATTOTIME_IN_HZ(256 * 57 / 8 / 2));
152152}
153153
154154READ8_HANDLER( decocass_sound_nmi_enable_r )
155155{
156156   UINT8 data = 0xff;
157157   LOG(2,("CPU #%d sound NMI enb <- $%02x\n", cpu_getactivecpu(), data));
158   mame_timer_adjust(decocass_sound_timer, MAME_TIME_IN_HZ(256 * 57 / 8 / 2), 0, MAME_TIME_IN_HZ(256 * 57 / 8 / 2));
158   timer_adjust(decocass_sound_timer, ATTOTIME_IN_HZ(256 * 57 / 8 / 2), 0, ATTOTIME_IN_HZ(256 * 57 / 8 / 2));
159159   return data;
160160}
161161
r1293r1294
277277
278278WRITE8_HANDLER( decocass_reset_w )
279279{
280   LOG(1,("%9.7f 6502-PC: %04x decocass_reset_w(%02x): $%02x\n", mame_time_to_double(mame_timer_get_time()), activecpu_get_previouspc(), offset, data));
280   LOG(1,("%9.7f 6502-PC: %04x decocass_reset_w(%02x): $%02x\n", attotime_to_double(timer_get_time()), activecpu_get_previouspc(), offset, data));
281281   decocass_reset = data;
282282
283283   /* CPU #1 active hight reset */
r1293r1294
285285
286286   /* on reset also remove the sound timer */
287287   if (data & 1)
288      mame_timer_adjust(decocass_sound_timer, time_never, 0, time_never);
288      timer_adjust(decocass_sound_timer, attotime_never, 0, attotime_never);
289289
290290   /* 8041 active low reset */
291291   cpunum_set_input_line(2, INPUT_LINE_RESET, (data & 0x08) ^ 0x08 );
r1293r1294
337337}
338338
339339
340mame_time decocass_adjust_tape_time(mame_time tape_time)
340attotime decocass_adjust_tape_time(attotime tape_time)
341341{
342   mame_time ret = tape_time;
342   attotime ret = tape_time;
343343
344344   if (tape_timer)
345345   {
346      mame_time elapsed = mame_timer_timeelapsed(tape_timer);
346      attotime elapsed = timer_timeelapsed(tape_timer);
347347
348348      if (tape_dir > 0)
349349      {
350         ret = add_mame_times(tape_time, elapsed);
350         ret = attotime_add(tape_time, elapsed);
351351
352         if (compare_mame_times(ret, MAME_TIME_IN_MSEC(999900)) > 0)
353            ret = MAME_TIME_IN_MSEC(999900);
352         if (attotime_compare(ret, ATTOTIME_IN_MSEC(999900)) > 0)
353            ret = ATTOTIME_IN_MSEC(999900);
354354      }
355355
356356      if (tape_dir < 0)
357357      {
358         if (compare_mame_times(tape_time, elapsed) > 0)
359            ret = sub_mame_times(tape_time, elapsed);
358         if (attotime_compare(tape_time, elapsed) > 0)
359            ret = attotime_sub(tape_time, elapsed);
360360         else
361            ret = time_zero;
361            ret = attotime_zero;
362362      }
363363   }
364364
r1293r1294
371371   static int last_byte;
372372   int offset, rclk, rdata, tape_bit, tape_byte, tape_block;
373373
374   mame_time tape_time = decocass_adjust_tape_time(tape_time0);
374   attotime tape_time = decocass_adjust_tape_time(tape_time0);
375375
376   offset = (int)(mame_time_to_double(scale_up_mame_time(tape_time, TAPE_CLOCKRATE)) + 0.499995);
376   offset = (int)(attotime_to_double(attotime_mul(tape_time, TAPE_CLOCKRATE)) + 0.499995);
377377
378378   /* reset RCLK and RDATA inputs */
379379   rclk = 0;
r1293r1294
388388      {
389389         tape_bot_eot = 1;
390390         set_led_status(1, 1);
391         LOG(5,("tape %5.4fs: %s found LEADER\n", mame_time_to_double(tape_time), dirnm(tape_dir)));
391         LOG(5,("tape %5.4fs: %s found LEADER\n", attotime_to_double(tape_time), dirnm(tape_dir)));
392392      }
393393   }
394394   else
r1293r1294
399399      {
400400         tape_bot_eot = 0;
401401         set_led_status(1, 0);
402         LOG(5,("tape %5.4fs: %s between BOT + LEADER\n", mame_time_to_double(tape_time), dirnm(tape_dir)));
402         LOG(5,("tape %5.4fs: %s between BOT + LEADER\n", attotime_to_double(tape_time), dirnm(tape_dir)));
403403      }
404404   }
405405   else
r1293r1294
410410      {
411411         tape_bot_eot = 1;
412412         set_led_status(1, 1);
413         LOG(5,("tape %5.4fs: %s found BOT\n", mame_time_to_double(tape_time), dirnm(tape_dir)));
413         LOG(5,("tape %5.4fs: %s found BOT\n", attotime_to_double(tape_time), dirnm(tape_dir)));
414414      }
415415   }
416416   else
r1293r1294
423423      {
424424         tape_bot_eot = 0;
425425         set_led_status(1, 0);
426         LOG(5,("tape %5.4fs: %s data area\n", mame_time_to_double(tape_time), dirnm(tape_dir)));
426         LOG(5,("tape %5.4fs: %s data area\n", attotime_to_double(tape_time), dirnm(tape_dir)));
427427      }
428428      rclk = (offset ^ 1) & 1;
429429      tape_bit = (offset / 2) % 8;
r1293r1294
441441         rdata = (0x00 >> tape_bit) & 1;
442442         if (tape_byte != last_byte)
443443         {
444            LOG(5,("tape %5.4fs: LEADIN $00\n", mame_time_to_double(tape_time)));
444            LOG(5,("tape %5.4fs: LEADIN $00\n", attotime_to_double(tape_time)));
445445            set_led_status(2, 1);
446446         }
447447      }
r1293r1294
450450      {
451451         rdata = (0xaa >> tape_bit) & 1;
452452         if (tape_byte != last_byte)
453            LOG(5,("tape %5.4fs: HEADER $aa\n", mame_time_to_double(tape_time)));
453            LOG(5,("tape %5.4fs: HEADER $aa\n", attotime_to_double(tape_time)));
454454      }
455455      else
456456      if (tape_byte < TAPE_BLOCK)
r1293r1294
458458         UINT8 *ptr = memory_region(REGION_USER2) + tape_block * 256 + tape_byte - TAPE_HEADER;
459459         rdata = (*ptr >> tape_bit) & 1;
460460         if (tape_byte != last_byte)
461            LOG(4,("tape %5.4fs: DATA(%02x) $%02x\n", mame_time_to_double(tape_time), tape_byte - TAPE_HEADER, *ptr));
461            LOG(4,("tape %5.4fs: DATA(%02x) $%02x\n", attotime_to_double(tape_time), tape_byte - TAPE_HEADER, *ptr));
462462      }
463463      else
464464      if (tape_byte < TAPE_CRC16_MSB)
465465      {
466466         rdata = (tape_crc16_msb[tape_block] >> tape_bit) & 1;
467467         if (tape_byte != last_byte)
468            LOG(4,("tape %5.4fs: CRC16 MSB $%02x\n", mame_time_to_double(tape_time), tape_crc16_msb[tape_block]));
468            LOG(4,("tape %5.4fs: CRC16 MSB $%02x\n", attotime_to_double(tape_time), tape_crc16_msb[tape_block]));
469469      }
470470      else
471471      if (tape_byte < TAPE_CRC16_LSB)
472472      {
473473         rdata = (tape_crc16_lsb[tape_block] >> tape_bit) & 1;
474474         if (tape_byte != last_byte)
475            LOG(4,("tape %5.4fs: CRC16 LSB $%02x\n", mame_time_to_double(tape_time), tape_crc16_lsb[tape_block]));
475            LOG(4,("tape %5.4fs: CRC16 LSB $%02x\n", attotime_to_double(tape_time), tape_crc16_lsb[tape_block]));
476476      }
477477      else
478478      if (tape_byte < TAPE_TRAILER)
479479      {
480480         rdata = (0xaa >> tape_bit) & 1;
481481         if (tape_byte != last_byte)
482            LOG(4,("tape %5.4fs: TRAILER $aa\n", mame_time_to_double(tape_time)));
482            LOG(4,("tape %5.4fs: TRAILER $aa\n", attotime_to_double(tape_time)));
483483      }
484484      else
485485      if (tape_byte < TAPE_LEADOUT)
486486      {
487487         rdata = (0x00 >> tape_bit) & 1;
488488         if (tape_byte != last_byte)
489            LOG(4,("tape %5.4fs: LEADOUT $00\n", mame_time_to_double(tape_time)));
489            LOG(4,("tape %5.4fs: LEADOUT $00\n", attotime_to_double(tape_time)));
490490      }
491491      else
492492      if (tape_byte < TAPE_LONGCLOCK)
493493      {
494494         if (tape_byte != last_byte)
495495         {
496            LOG(4,("tape %5.4fs: LONG CLOCK\n", mame_time_to_double(tape_time)));
496            LOG(4,("tape %5.4fs: LONG CLOCK\n", attotime_to_double(tape_time)));
497497            set_led_status(2, 0);
498498         }
499499         rclk = 1;
r1293r1294
509509      {
510510         tape_bot_eot = 1;
511511         set_led_status(1, 1);
512         LOG(5,("tape %5.4fs: %s found EOT\n", mame_time_to_double(tape_time), dirnm(tape_dir)));
512         LOG(5,("tape %5.4fs: %s found EOT\n", attotime_to_double(tape_time), dirnm(tape_dir)));
513513      }
514514   }
515515   else
r1293r1294
520520      {
521521         tape_bot_eot = 0;
522522         set_led_status(1, 0);
523         LOG(5,("tape %5.4fs: %s EOT and TRAILER\n", mame_time_to_double(tape_time), dirnm(tape_dir)));
523         LOG(5,("tape %5.4fs: %s EOT and TRAILER\n", attotime_to_double(tape_time), dirnm(tape_dir)));
524524      }
525525   }
526526   else
r1293r1294
530530      {
531531         tape_bot_eot = 1;
532532         set_led_status(1, 1);
533         LOG(5,("tape %5.4fs: %s found TRAILER\n", mame_time_to_double(tape_time), dirnm(tape_dir)));
533         LOG(5,("tape %5.4fs: %s found TRAILER\n", attotime_to_double(tape_time), dirnm(tape_dir)));
534534      }
535535      offset = tape_length - 1;
536536   }
r1293r1294
599599
600600      data = (BIT0(data) << 0) | (BIT1(data) << 1) | 0x7c;
601601      LOG(4,("%9.7f 6502-PC: %04x decocass_type1_latch_26_pass_3_inv_2_r(%02x): $%02x <- (%s %s)\n",
602         mame_time_to_double(mame_timer_get_time()), activecpu_get_previouspc(), offset, data,
602         attotime_to_double(timer_get_time()), activecpu_get_previouspc(), offset, data,
603603         (data & 1) ? "OBF" : "-",
604604         (data & 2) ? "IBF" : "-"));
605605   }
r1293r1294
647647         (((prom[promaddr] >> 4) & 1)            << MAP7(type1_outmap));
648648
649649      LOG(3,("%9.7f 6502-PC: %04x decocass_type1_latch_26_pass_3_inv_2_r(%02x): $%02x\n",
650         mame_time_to_double(mame_timer_get_time()), activecpu_get_previouspc(), offset, data));
650         attotime_to_double(timer_get_time()), activecpu_get_previouspc(), offset, data));
651651
652652      latch1 = save;      /* latch the data for the next A0 == 0 read */
653653   }
r1293r1294
679679
680680      data = (BIT0(data) << 0) | (BIT1(data) << 1) | 0x7c;
681681      LOG(4,("%9.7f 6502-PC: %04x decocass_type1_pass_136_r(%02x): $%02x <- (%s %s)\n",
682         mame_time_to_double(mame_timer_get_time()), activecpu_get_previouspc(), offset, data,
682         attotime_to_double(timer_get_time()), activecpu_get_previouspc(), offset, data,
683683         (data & 1) ? "OBF" : "-",
684684         (data & 2) ? "IBF" : "-"));
685685   }
r1293r1294
727727         (((prom[promaddr] >> 4) & 1)            << MAP7(type1_outmap));
728728
729729      LOG(3,("%9.7f 6502-PC: %04x decocass_type1_pass_136_r(%02x): $%02x\n",
730         mame_time_to_double(mame_timer_get_time()), activecpu_get_previouspc(), offset, data));
730         attotime_to_double(timer_get_time()), activecpu_get_previouspc(), offset, data));
731731
732732      latch1 = save;      /* latch the data for the next A0 == 0 read */
733733   }
r1293r1294
759759
760760      data = (BIT0(data) << 0) | (BIT1(data) << 1) | 0x7c;
761761      LOG(4,("%9.7f 6502-PC: %04x decocass_type1_latch_27_pass_3_inv_2_r(%02x): $%02x <- (%s %s)\n",
762         mame_time_to_double(mame_timer_get_time()), activecpu_get_previouspc(), offset, data,
762         attotime_to_double(timer_get_time()), activecpu_get_previouspc(), offset, data,
763763         (data & 1) ? "OBF" : "-",
764764         (data & 2) ? "IBF" : "-"));
765765   }
r1293r1294
807807         (((latch1 >> MAP7(type1_inmap)) & 1)      << MAP7(type1_outmap));
808808
809809      LOG(3,("%9.7f 6502-PC: %04x decocass_type1_latch_27_pass_3_inv_2_r(%02x): $%02x\n",
810         mame_time_to_double(mame_timer_get_time()), activecpu_get_previouspc(), offset, data));
810         attotime_to_double(timer_get_time()), activecpu_get_previouspc(), offset, data));
811811
812812      latch1 = save;      /* latch the data for the next A0 == 0 read */
813813   }
r1293r1294
839839
840840      data = (BIT0(data) << 0) | (BIT1(data) << 1) | 0x7c;
841841      LOG(4,("%9.7f 6502-PC: %04x decocass_type1_latch_26_pass_5_inv_2_r(%02x): $%02x <- (%s %s)\n",
842         mame_time_to_double(mame_timer_get_time()), activecpu_get_previouspc(), offset, data,
842         attotime_to_double(timer_get_time()), activecpu_get_previouspc(), offset, data,
843843         (data & 1) ? "OBF" : "-",
844844         (data & 2) ? "IBF" : "-"));
845845   }
r1293r1294
887887         (((prom[promaddr] >> 4) & 1)            << MAP7(type1_outmap));
888888
889889      LOG(3,("%9.7f 6502-PC: %04x decocass_type1_latch_26_pass_5_inv_2_r(%02x): $%02x\n",
890         mame_time_to_double(mame_timer_get_time()), activecpu_get_previouspc(), offset, data));
890         attotime_to_double(timer_get_time()), activecpu_get_previouspc(), offset, data));
891891
892892      latch1 = save;      /* latch the data for the next A0 == 0 read */
893893   }
r1293r1294
921921
922922      data = (BIT0(data) << 0) | (BIT1(data) << 1) | 0x7c;
923923      LOG(4,("%9.7f 6502-PC: %04x decocass_type1_latch_16_pass_3_inv_1_r(%02x): $%02x <- (%s %s)\n",
924         mame_time_to_double(mame_timer_get_time()), activecpu_get_previouspc(), offset, data,
924         attotime_to_double(timer_get_time()), activecpu_get_previouspc(), offset, data,
925925         (data & 1) ? "OBF" : "-",
926926         (data & 2) ? "IBF" : "-"));
927927   }
r1293r1294
969969         (((prom[promaddr] >> 4) & 1)            << MAP7(type1_outmap));
970970
971971      LOG(3,("%9.7f 6502-PC: %04x decocass_type1_latch_16_pass_3_inv_1_r(%02x): $%02x\n",
972         mame_time_to_double(mame_timer_get_time()), activecpu_get_previouspc(), offset, data));
972         attotime_to_double(timer_get_time()), activecpu_get_previouspc(), offset, data));
973973
974974      latch1 = save;      /* latch the data for the next A0 == 0 read */
975975   }
r1293r1294
998998      {
999999         UINT8 *prom = memory_region(REGION_USER1);
10001000         data = prom[256 * type2_d2_latch + type2_promaddr];
1001         LOG(3,("%9.7f 6502-PC: %04x decocass_type2_r(%02x): $%02x <- prom[%03x]\n", mame_time_to_double(mame_timer_get_time()), activecpu_get_previouspc(), offset, data, 256 * type2_d2_latch + type2_promaddr));
1001         LOG(3,("%9.7f 6502-PC: %04x decocass_type2_r(%02x): $%02x <- prom[%03x]\n", attotime_to_double(timer_get_time()), activecpu_get_previouspc(), offset, data, 256 * type2_d2_latch + type2_promaddr));
10021002      }
10031003      else
10041004      {
r1293r1294
10121012      else
10131013         data = offset & 0xff;
10141014
1015      LOG(3,("%9.7f 6502-PC: %04x decocass_type2_r(%02x): $%02x <- 8041-%s\n", mame_time_to_double(mame_timer_get_time()), activecpu_get_previouspc(), offset, data, offset & 1 ? "STATUS" : "DATA"));
1015      LOG(3,("%9.7f 6502-PC: %04x decocass_type2_r(%02x): $%02x <- 8041-%s\n", attotime_to_double(timer_get_time()), activecpu_get_previouspc(), offset, data, offset & 1 ? "STATUS" : "DATA"));
10161016   }
10171017   return data;
10181018}
r1293r1294
10231023   {
10241024      if (1 == (offset & 1))
10251025      {
1026         LOG(4,("%9.7f 6502-PC: %04x decocass_e5xx_w(%02x): $%02x -> set PROM+D2 latch", mame_time_to_double(mame_timer_get_time()), activecpu_get_previouspc(), offset, data));
1026         LOG(4,("%9.7f 6502-PC: %04x decocass_e5xx_w(%02x): $%02x -> set PROM+D2 latch", attotime_to_double(timer_get_time()), activecpu_get_previouspc(), offset, data));
10271027      }
10281028      else
10291029      {
10301030         type2_promaddr = data;
1031         LOG(3,("%9.7f 6502-PC: %04x decocass_e5xx_w(%02x): $%02x -> set PROM addr $%02x\n", mame_time_to_double(mame_timer_get_time()), activecpu_get_previouspc(), offset, data, type2_promaddr));
1031         LOG(3,("%9.7f 6502-PC: %04x decocass_e5xx_w(%02x): $%02x -> set PROM addr $%02x\n", attotime_to_double(timer_get_time()), activecpu_get_previouspc(), offset, data, type2_promaddr));
10321032         return;
10331033      }
10341034   }
10351035   else
10361036   {
1037      LOG(3,("%9.7f 6502-PC: %04x decocass_e5xx_w(%02x): $%02x -> %s ", mame_time_to_double(mame_timer_get_time()), activecpu_get_previouspc(), offset, data, offset & 1 ? "8041-CMND" : "8041 DATA"));
1037      LOG(3,("%9.7f 6502-PC: %04x decocass_e5xx_w(%02x): $%02x -> %s ", attotime_to_double(timer_get_time()), activecpu_get_previouspc(), offset, data, offset & 1 ? "8041-CMND" : "8041 DATA"));
10381038   }
10391039   if (1 == (offset & 1))
10401040   {
r1293r1294
10781078      {
10791079         UINT8 *prom = memory_region(REGION_USER1);
10801080         data = prom[type3_ctrs];
1081         LOG(3,("%9.7f 6502-PC: %04x decocass_type3_r(%02x): $%02x <- prom[$%03x]\n", mame_time_to_double(mame_timer_get_time()), activecpu_get_previouspc(), offset, data, type3_ctrs));
1081         LOG(3,("%9.7f 6502-PC: %04x decocass_type3_r(%02x): $%02x <- prom[$%03x]\n", attotime_to_double(timer_get_time()), activecpu_get_previouspc(), offset, data, type3_ctrs));
10821082         if (++type3_ctrs == 4096)
10831083            type3_ctrs = 0;
10841084      }
r1293r1294
10871087         if (0 == (offset & E5XX_MASK))
10881088         {
10891089            data = cpunum_get_reg(2, I8X41_STAT);
1090            LOG(4,("%9.7f 6502-PC: %04x decocass_type3_r(%02x): $%02x <- 8041 STATUS\n", mame_time_to_double(mame_timer_get_time()), activecpu_get_previouspc(), offset, data));
1090            LOG(4,("%9.7f 6502-PC: %04x decocass_type3_r(%02x): $%02x <- 8041 STATUS\n", attotime_to_double(timer_get_time()), activecpu_get_previouspc(), offset, data));
10911091         }
10921092         else
10931093         {
10941094            data = 0xff;   /* open data bus? */
1095            LOG(4,("%9.7f 6502-PC: %04x decocass_type3_r(%02x): $%02x <- open bus\n", mame_time_to_double(mame_timer_get_time()), activecpu_get_previouspc(), offset, data));
1095            LOG(4,("%9.7f 6502-PC: %04x decocass_type3_r(%02x): $%02x <- open bus\n", attotime_to_double(timer_get_time()), activecpu_get_previouspc(), offset, data));
10961096         }
10971097      }
10981098   }
r1293r1294
11011101      if (1 == type3_pal_19)
11021102      {
11031103         save = data = 0xff;    /* open data bus? */
1104         LOG(3,("%9.7f 6502-PC: %04x decocass_type3_r(%02x): $%02x <- open bus", mame_time_to_double(mame_timer_get_time()), activecpu_get_previouspc(), offset, data));
1104         LOG(3,("%9.7f 6502-PC: %04x decocass_type3_r(%02x): $%02x <- open bus", attotime_to_double(timer_get_time()), activecpu_get_previouspc(), offset, data));
11051105      }
11061106      else
11071107      {
r1293r1294
12321232                  (BIT7(save) << 7);
12331233            }
12341234            type3_d0_latch = save & 1;
1235            LOG(3,("%9.7f 6502-PC: %04x decocass_type3_r(%02x): $%02x '%c' <- 8041-DATA\n", mame_time_to_double(mame_timer_get_time()), activecpu_get_previouspc(), offset, data, (data >= 32) ? data : '.'));
1235            LOG(3,("%9.7f 6502-PC: %04x decocass_type3_r(%02x): $%02x '%c' <- 8041-DATA\n", attotime_to_double(timer_get_time()), activecpu_get_previouspc(), offset, data, (data >= 32) ? data : '.'));
12361236         }
12371237         else
12381238         {
r1293r1294
12461246               (BIT5(save) << 5) |
12471247               (BIT6(save) << 7) |
12481248               (BIT7(save) << 6);
1249            LOG(3,("%9.7f 6502-PC: %04x decocass_type3_r(%02x): $%02x '%c' <- open bus (D0 replaced with latch)\n", mame_time_to_double(mame_timer_get_time()), activecpu_get_previouspc(), offset, data, (data >= 32) ? data : '.'));
1249            LOG(3,("%9.7f 6502-PC: %04x decocass_type3_r(%02x): $%02x '%c' <- open bus (D0 replaced with latch)\n", attotime_to_double(timer_get_time()), activecpu_get_previouspc(), offset, data, (data >= 32) ? data : '.'));
12501250            type3_d0_latch = save & 1;
12511251         }
12521252      }
r1293r1294
12621262      if (1 == type3_pal_19)
12631263      {
12641264         type3_ctrs = data << 4;
1265         LOG(3,("%9.7f 6502-PC: %04x decocass_e5xx_w(%02x): $%02x -> %s\n", mame_time_to_double(mame_timer_get_time()), activecpu_get_previouspc(), offset, data, "LDCTRS"));
1265         LOG(3,("%9.7f 6502-PC: %04x decocass_e5xx_w(%02x): $%02x -> %s\n", attotime_to_double(timer_get_time()), activecpu_get_previouspc(), offset, data, "LDCTRS"));
12661266         return;
12671267      }
12681268      else
r1293r1294
12741274      if (1 == type3_pal_19)
12751275      {
12761276         /* write nowhere?? */
1277         LOG(3,("%9.7f 6502-PC: %04x decocass_e5xx_w(%02x): $%02x -> %s\n", mame_time_to_double(mame_timer_get_time()), activecpu_get_previouspc(), offset, data, "nowhere?"));
1277         LOG(3,("%9.7f 6502-PC: %04x decocass_e5xx_w(%02x): $%02x -> %s\n", attotime_to_double(timer_get_time()), activecpu_get_previouspc(), offset, data, "nowhere?"));
12781278         return;
12791279      }
12801280   }
1281   LOG(3,("%9.7f 6502-PC: %04x decocass_e5xx_w(%02x): $%02x -> %s\n", mame_time_to_double(mame_timer_get_time()), activecpu_get_previouspc(), offset, data, offset & 1 ? "8041-CMND" : "8041-DATA"));
1281   LOG(3,("%9.7f 6502-PC: %04x decocass_e5xx_w(%02x): $%02x -> %s\n", attotime_to_double(timer_get_time()), activecpu_get_previouspc(), offset, data, offset & 1 ? "8041-CMND" : "8041-DATA"));
12821282   cpunum_set_reg(2, offset & 1 ? I8X41_CMND : I8X41_DATA, data);
12831283}
12841284
r1293r1294
13031303      if (0 == (offset & E5XX_MASK))
13041304      {
13051305         data = cpunum_get_reg(2, I8X41_STAT);
1306         LOG(4,("%9.7f 6502-PC: %04x decocass_type4_r(%02x): $%02x <- 8041 STATUS\n", mame_time_to_double(mame_timer_get_time()), activecpu_get_previouspc(), offset, data));
1306         LOG(4,("%9.7f 6502-PC: %04x decocass_type4_r(%02x): $%02x <- 8041 STATUS\n", attotime_to_double(timer_get_time()), activecpu_get_previouspc(), offset, data));
13071307      }
13081308      else
13091309      {
13101310         data = 0xff;   /* open data bus? */
1311         LOG(4,("%9.7f 6502-PC: %04x decocass_type4_r(%02x): $%02x <- open bus\n", mame_time_to_double(mame_timer_get_time()), activecpu_get_previouspc(), offset, data));
1311         LOG(4,("%9.7f 6502-PC: %04x decocass_type4_r(%02x): $%02x <- open bus\n", attotime_to_double(timer_get_time()), activecpu_get_previouspc(), offset, data));
13121312      }
13131313   }
13141314   else
r1293r1294
13181318         UINT8 *prom = memory_region(REGION_USER1);
13191319
13201320         data = prom[type4_ctrs];
1321         LOG(3,("%9.7f 6502-PC: %04x decocass_type4_r(%02x): $%02x '%c' <- PROM[%04x]\n", mame_time_to_double(mame_timer_get_time()), activecpu_get_previouspc(), offset, data, (data >= 32) ? data : '.', type4_ctrs));
1321         LOG(3,("%9.7f 6502-PC: %04x decocass_type4_r(%02x): $%02x '%c' <- PROM[%04x]\n", attotime_to_double(timer_get_time()), activecpu_get_previouspc(), offset, data, (data >= 32) ? data : '.', type4_ctrs));
13221322         type4_ctrs = (type4_ctrs+1) & 0x7fff;
13231323      }
13241324      else
r1293r1294
13261326         if (0 == (offset & E5XX_MASK))
13271327         {
13281328            data = cpunum_get_reg(2, I8X41_DATA);
1329            LOG(3,("%9.7f 6502-PC: %04x decocass_type4_r(%02x): $%02x '%c' <- open bus (D0 replaced with latch)\n", mame_time_to_double(mame_timer_get_time()), activecpu_get_previouspc(), offset, data, (data >= 32) ? data : '.'));
1329            LOG(3,("%9.7f 6502-PC: %04x decocass_type4_r(%02x): $%02x '%c' <- open bus (D0 replaced with latch)\n", attotime_to_double(timer_get_time()), activecpu_get_previouspc(), offset, data, (data >= 32) ? data : '.'));
13301330         }
13311331         else
13321332         {
13331333            data = 0xff;   /* open data bus? */
1334            LOG(4,("%9.7f 6502-PC: %04x decocass_type4_r(%02x): $%02x <- open bus\n", mame_time_to_double(mame_timer_get_time()), activecpu_get_previouspc(), offset, data));
1334            LOG(4,("%9.7f 6502-PC: %04x decocass_type4_r(%02x): $%02x <- open bus\n", attotime_to_double(timer_get_time()), activecpu_get_previouspc(), offset, data));
13351335         }
13361336      }
13371337   }
r1293r1294
13461346      if (1 == type4_latch)
13471347      {
13481348         type4_ctrs = (type4_ctrs & 0x00ff) | ((data & 0x7f) << 8);
1349         LOG(3,("%9.7f 6502-PC: %04x decocass_e5xx_w(%02x): $%02x -> CTRS MSB (%04x)\n", mame_time_to_double(mame_timer_get_time()), activecpu_get_previouspc(), offset, data, type4_ctrs));
1349         LOG(3,("%9.7f 6502-PC: %04x decocass_e5xx_w(%02x): $%02x -> CTRS MSB (%04x)\n", attotime_to_double(timer_get_time()), activecpu_get_previouspc(), offset, data, type4_ctrs));
13501350         return;
13511351      }
13521352      else
r1293r1294
13601360      if (type4_latch)
13611361      {
13621362         type4_ctrs = (type4_ctrs & 0xff00) | data;
1363         LOG(3,("%9.7f 6502-PC: %04x decocass_e5xx_w(%02x): $%02x -> CTRS LSB (%04x)\n", mame_time_to_double(mame_timer_get_time()), activecpu_get_previouspc(), offset, data, type4_ctrs));
1363         LOG(3,("%9.7f 6502-PC: %04x decocass_e5xx_w(%02x): $%02x -> CTRS LSB (%04x)\n", attotime_to_double(timer_get_time()), activecpu_get_previouspc(), offset, data, type4_ctrs));
13641364         return;
13651365      }
13661366   }
1367   LOG(3,("%9.7f 6502-PC: %04x decocass_e5xx_w(%02x): $%02x -> %s\n", mame_time_to_double(mame_timer_get_time()), activecpu_get_previouspc(), offset, data, offset & 1 ? "8041-CMND" : "8041-DATA"));
1367   LOG(3,("%9.7f 6502-PC: %04x decocass_e5xx_w(%02x): $%02x -> %s\n", attotime_to_double(timer_get_time()), activecpu_get_previouspc(), offset, data, offset & 1 ? "8041-CMND" : "8041-DATA"));
13681368   cpunum_set_reg(2, offset & 1 ? I8X41_CMND : I8X41_DATA, data);
13691369}
13701370
r1293r1294
13861386      if (0 == (offset & E5XX_MASK))
13871387      {
13881388         data = cpunum_get_reg(2, I8X41_STAT);
1389         LOG(4,("%9.7f 6502-PC: %04x decocass_type5_r(%02x): $%02x <- 8041 STATUS\n", mame_time_to_double(mame_timer_get_time()), activecpu_get_previouspc(), offset, data));
1389         LOG(4,("%9.7f 6502-PC: %04x decocass_type5_r(%02x): $%02x <- 8041 STATUS\n", attotime_to_double(timer_get_time()), activecpu_get_previouspc(), offset, data));
13901390      }
13911391      else
13921392      {
13931393         data = 0xff;   /* open data bus? */
1394         LOG(4,("%9.7f 6502-PC: %04x decocass_type5_r(%02x): $%02x <- open bus\n", mame_time_to_double(mame_timer_get_time()), activecpu_get_previouspc(), offset, data));
1394         LOG(4,("%9.7f 6502-PC: %04x decocass_type5_r(%02x): $%02x <- open bus\n", attotime_to_double(timer_get_time()), activecpu_get_previouspc(), offset, data));
13951395      }
13961396   }
13971397   else
r1293r1294
13991399      if (type5_latch)
14001400      {
14011401         data = 0x55;   /* Only a fixed value? It looks like this is all we need to do */
1402         LOG(3,("%9.7f 6502-PC: %04x decocass_type5_r(%02x): $%02x '%c' <- fixed value???\n", mame_time_to_double(mame_timer_get_time()), activecpu_get_previouspc(), offset, data, (data >= 32) ? data : '.'));
1402         LOG(3,("%9.7f 6502-PC: %04x decocass_type5_r(%02x): $%02x '%c' <- fixed value???\n", attotime_to_double(timer_get_time()), activecpu_get_previouspc(), offset, data, (data >= 32) ? data : '.'));
14031403      }
14041404      else
14051405      {
14061406         if (0 == (offset & E5XX_MASK))
14071407         {
14081408            data = cpunum_get_reg(2, I8X41_DATA);
1409            LOG(3,("%9.7f 6502-PC: %04x decocass_type5_r(%02x): $%02x '%c' <- open bus (D0 replaced with latch)\n", mame_time_to_double(mame_timer_get_time()), activecpu_get_previouspc(), offset, data, (data >= 32) ? data : '.'));
1409            LOG(3,("%9.7f 6502-PC: %04x decocass_type5_r(%02x): $%02x '%c' <- open bus (D0 replaced with latch)\n", attotime_to_double(timer_get_time()), activecpu_get_previouspc(), offset, data, (data >= 32) ? data : '.'));
14101410         }
14111411         else
14121412         {
14131413            data = 0xff;   /* open data bus? */
1414            LOG(4,("%9.7f 6502-PC: %04x decocass_type5_r(%02x): $%02x <- open bus\n", mame_time_to_double(mame_timer_get_time()), activecpu_get_previouspc(), offset, data));
1414            LOG(4,("%9.7f 6502-PC: %04x decocass_type5_r(%02x): $%02x <- open bus\n", attotime_to_double(timer_get_time()), activecpu_get_previouspc(), offset, data));
14151415         }
14161416      }
14171417   }
r1293r1294
14251425   {
14261426      if (1 == type5_latch)
14271427      {
1428         LOG(3,("%9.7f 6502-PC: %04x decocass_e5xx_w(%02x): $%02x -> %s\n", mame_time_to_double(mame_timer_get_time()), activecpu_get_previouspc(), offset, data, "latch #2??"));
1428         LOG(3,("%9.7f 6502-PC: %04x decocass_e5xx_w(%02x): $%02x -> %s\n", attotime_to_double(timer_get_time()), activecpu_get_previouspc(), offset, data, "latch #2??"));
14291429         return;
14301430      }
14311431      else
r1293r1294
14371437      if (type5_latch)
14381438      {
14391439         /* write nowhere?? */
1440         LOG(3,("%9.7f 6502-PC: %04x decocass_e5xx_w(%02x): $%02x -> %s\n", mame_time_to_double(mame_timer_get_time()), activecpu_get_previouspc(), offset, data, "nowhere?"));
1440         LOG(3,("%9.7f 6502-PC: %04x decocass_e5xx_w(%02x): $%02x -> %s\n", attotime_to_double(timer_get_time()), activecpu_get_previouspc(), offset, data, "nowhere?"));
14411441         return;
14421442      }
14431443   }
1444   LOG(3,("%9.7f 6502-PC: %04x decocass_e5xx_w(%02x): $%02x -> %s\n", mame_time_to_double(mame_timer_get_time()), activecpu_get_previouspc(), offset, data, offset & 1 ? "8041-CMND" : "8041-DATA"));
1444   LOG(3,("%9.7f 6502-PC: %04x decocass_e5xx_w(%02x): $%02x -> %s\n", attotime_to_double(timer_get_time()), activecpu_get_previouspc(), offset, data, offset & 1 ? "8041-CMND" : "8041-DATA"));
14451445   cpunum_set_reg(2, offset & 1 ? I8X41_CMND : I8X41_DATA, data);
14461446}
14471447
r1293r1294
14621462      if (0 == (offset & E5XX_MASK))
14631463      {
14641464         data = cpunum_get_reg(2, I8X41_STAT);
1465         LOG(4,("%9.7f 6502-PC: %04x decocass_nodong_r(%02x): $%02x <- 8041 STATUS\n", mame_time_to_double(mame_timer_get_time()), activecpu_get_previouspc(), offset, data));
1465         LOG(4,("%9.7f 6502-PC: %04x decocass_nodong_r(%02x): $%02x <- 8041 STATUS\n", attotime_to_double(timer_get_time()), activecpu_get_previouspc(), offset, data));
14661466      }
14671467      else
14681468      {
14691469         data = 0xff;   /* open data bus? */
1470         LOG(4,("%9.7f 6502-PC: %04x decocass_nodong_r(%02x): $%02x <- open bus\n", mame_time_to_double(mame_timer_get_time()), activecpu_get_previouspc(), offset, data));
1470         LOG(4,("%9.7f 6502-PC: %04x decocass_nodong_r(%02x): $%02x <- open bus\n", attotime_to_double(timer_get_time()), activecpu_get_previouspc(), offset, data));
14711471      }
14721472   }
14731473   else
r1293r1294
14751475      if (0 == (offset & E5XX_MASK))
14761476      {
14771477         data = cpunum_get_reg(2, I8X41_DATA);
1478         LOG(3,("%9.7f 6502-PC: %04x decocass_nodong_r(%02x): $%02x '%c' <- open bus (D0 replaced with latch)\n", mame_time_to_double(mame_timer_get_time()), activecpu_get_previouspc(), offset, data, (data >= 32) ? data : '.'));
1478         LOG(3,("%9.7f 6502-PC: %04x decocass_nodong_r(%02x): $%02x '%c' <- open bus (D0 replaced with latch)\n", attotime_to_double(timer_get_time()), activecpu_get_previouspc(), offset, data, (data >= 32) ? data : '.'));
14791479      }
14801480      else
14811481      {
14821482         data = 0xff;   /* open data bus? */
1483         LOG(4,("%9.7f 6502-PC: %04x decocass_nodong_r(%02x): $%02x <- open bus\n", mame_time_to_double(mame_timer_get_time()), activecpu_get_previouspc(), offset, data));
1483         LOG(4,("%9.7f 6502-PC: %04x decocass_nodong_r(%02x): $%02x <- open bus\n", attotime_to_double(timer_get_time()), activecpu_get_previouspc(), offset, data));
14841484      }
14851485   }
14861486
r1293r1294
15111511         ((1 - tape_present)   << 7);   /* D7 = cassette present */
15121512
15131513      LOG(4,("%9.7f 6502-PC: %04x decocass_e5xx_r(%02x): $%02x <- STATUS (%s%s%s%s%s%s%s%s)\n",
1514         mame_time_to_double(mame_timer_get_time()),
1514         attotime_to_double(timer_get_time()),
15151515         activecpu_get_previouspc(),
15161516         offset, data,
15171517         data & 0x01 ? "" : "REQ/",
r1293r1294
15431543
15441544   if (0 == (offset & E5XX_MASK))
15451545   {
1546      LOG(3,("%9.7f 6502-PC: %04x decocass_e5xx_w(%02x): $%02x -> %s\n", mame_time_to_double(mame_timer_get_time()), activecpu_get_previouspc(), offset, data, offset & 1 ? "8041-CMND" : "8041-DATA"));
1546      LOG(3,("%9.7f 6502-PC: %04x decocass_e5xx_w(%02x): $%02x -> %s\n", attotime_to_double(timer_get_time()), activecpu_get_previouspc(), offset, data, offset & 1 ? "8041-CMND" : "8041-DATA"));
15471547      cpunum_set_reg(2, offset & 1 ? I8X41_CMND : I8X41_DATA, data);
15481548#ifdef MAME_DEBUG
15491549      decocass_fno(offset, data);
r1293r1294
15511551   }
15521552   else
15531553   {
1554      LOG(3,("%9.7f 6502-PC: %04x decocass_e5xx_w(%02x): $%02x -> dongle\n", mame_time_to_double(mame_timer_get_time()), activecpu_get_previouspc(), offset, data));
1554      LOG(3,("%9.7f 6502-PC: %04x decocass_e5xx_w(%02x): $%02x -> dongle\n", attotime_to_double(timer_get_time()), activecpu_get_previouspc(), offset, data));
15551555   }
15561556}
15571557
r1293r1294
16041604      decocass_w(A, mem[A]);
16051605   /* restart the timer if the tape was playing */
16061606   if (0 != tape_dir)
1607      mame_timer_adjust(tape_timer, time_never, 0, time_never);
1607      timer_adjust(tape_timer, attotime_never, 0, attotime_never);
16081608#endif
16091609}
16101610
r1293r1294
16151615   state_save_register_global(tape_dir);
16161616   state_save_register_global(tape_speed);
16171617   state_save_register_global(tape_time0.seconds);
1618   state_save_register_global(tape_time0.subseconds);
1618   state_save_register_global(tape_time0.attoseconds);
16191619   state_save_register_global(firsttime);
16201620   state_save_register_global(tape_present);
16211621   state_save_register_global(tape_blocks);
r1293r1294
16501650 *
16511651 ***************************************************************************/
16521652
1653void decocass_init_common(void)
1653static void decocass_init_common(void)
16541654{
16551655   UINT8 *image = memory_region(REGION_USER2);
16561656   int i, offs;
16571657
16581658   tape_dir = 0;
16591659   tape_speed = 0;
1660   tape_timer = mame_timer_alloc(NULL);
1660   tape_timer = timer_alloc(NULL);
16611661
16621662   firsttime = 1;
16631663   tape_present = 1;
r1293r1294
16861686   }
16871687
16881688   tape_length = tape_blocks * TAPE_CHUNK * 8 * 2 + 2 * (TAPE_LEADER + TAPE_GAP + TAPE_HOLE);
1689   tape_time0 = scale_up_mame_time(MAME_TIME_IN_HZ(TAPE_CLOCKRATE), TAPE_LEADER + TAPE_GAP - TAPE_HOLE);
1689   tape_time0 = attotime_mul(ATTOTIME_IN_HZ(TAPE_CLOCKRATE), TAPE_LEADER + TAPE_GAP - TAPE_HOLE);
16901690   LOG(0,("tape: %d blocks\n", tape_blocks));
16911691   tape_bot_eot = 0;
16921692
r1293r1294
17111711
17121712   memset(decocass_quadrature_decoder, 0, sizeof(decocass_quadrature_decoder));
17131713   decocass_sound_ack = 0;
1714   decocass_sound_timer = mame_timer_alloc(decocass_sound_nmi_pulse);
1714   decocass_sound_timer = timer_alloc(decocass_sound_nmi_pulse);
17151715}
17161716
17171717MACHINE_RESET( decocass )
r1293r1294
19861986   /* remember time */
19871987   tape_time0 = decocass_adjust_tape_time(tape_time0);
19881988
1989   mame_timer_adjust(tape_timer, time_never, 0, time_never);
1989   timer_adjust(tape_timer, attotime_never, 0, attotime_never);
19901990}
19911991
19921992
r1293r1294
19971997   if (data != i8041_p1_old)
19981998   {
19991999      LOG(4,("%9.7f 8041-PC: %03x i8041_p1_w: $%02x (%s%s%s%s%s%s%s%s)\n",
2000         mame_time_to_double(mame_timer_get_time()),
2000         attotime_to_double(timer_get_time()),
20012001         activecpu_get_previouspc(),
20022002         data,
20032003         data & 0x01 ? "" : "DATA-WRT",
r1293r1294
20172017      tape_stop();
20182018      if (0 == (data & 0x10))
20192019      {
2020         LOG(2,("tape %5.4fs: rewind\n", mame_time_to_double(tape_time0)));
2020         LOG(2,("tape %5.4fs: rewind\n", attotime_to_double(tape_time0)));
20212021         tape_dir = -1;
2022         mame_timer_adjust(tape_timer, time_never, 0, time_never);
2022         timer_adjust(tape_timer, attotime_never, 0, attotime_never);
20232023         set_led_status(0, 1);
20242024      }
20252025      else
20262026      {
20272027         tape_dir = 0;
20282028         tape_speed = 0;
2029         LOG(2,("tape %5.4fs: stopped\n", mame_time_to_double(tape_time0)));
2029         LOG(2,("tape %5.4fs: stopped\n", attotime_to_double(tape_time0)));
20302030#if TAPE_UI_DISPLAY
2031         popmessage("   [%05.1fs]   ", mame_time_to_double(tape_time0));
2031         popmessage("   [%05.1fs]   ", attotime_to_double(tape_time0));
20322032#endif
20332033         set_led_status(0, 0);
20342034      }
r1293r1294
20402040      tape_stop();
20412041      if (0 == (data & 0x20))
20422042      {
2043         LOG(2,("tape %5.4fs: forward\n", mame_time_to_double(tape_time0)));
2043         LOG(2,("tape %5.4fs: forward\n", attotime_to_double(tape_time0)));
20442044         tape_dir = +1;
2045         mame_timer_adjust(tape_timer, time_never, 0, time_never);
2045         timer_adjust(tape_timer, attotime_never, 0, attotime_never);
20462046         set_led_status(0, 1);
20472047      }
20482048      else
20492049      {
20502050         tape_dir = 0;
20512051         tape_speed = 0;
2052         LOG(2,("tape %5.4fs: stopped\n", mame_time_to_double(tape_time0)));
2052         LOG(2,("tape %5.4fs: stopped\n", attotime_to_double(tape_time0)));
20532053#if TAPE_UI_DISPLAY
2054         popmessage("   [%05.1fs]   ", mame_time_to_double(tape_time0));
2054         popmessage("   [%05.1fs]   ", attotime_to_double(tape_time0));
20552055#endif
20562056         set_led_status(0, 0);
20572057      }
r1293r1294
20672067      {
20682068         LOG(2,("tape: fast rewind %s\n", (0 == (data & 0x04)) ? "on" : "off"));
20692069         tape_dir = (tape_speed) ? -7 : -1;
2070         mame_timer_adjust(tape_timer, time_never, 0, time_never);
2070         timer_adjust(tape_timer, attotime_never, 0, attotime_never);
20712071      }
20722072      else
20732073      if (tape_dir > 0)
20742074      {
20752075         LOG(2,("tape: fast forward %s\n", (0 == (data & 0x04)) ? "on" : "off"));
20762076         tape_dir = (tape_speed) ? +7 : +1;
2077         mame_timer_adjust(tape_timer, time_never, 0, time_never);
2077         timer_adjust(tape_timer, attotime_never, 0, attotime_never);
20782078      }
20792079   }
20802080
r1293r1294
20892089   if (data != i8041_p1_old)
20902090   {
20912091      LOG(4,("%9.7f 8041-PC: %03x i8041_p1_r: $%02x (%s%s%s%s%s%s%s%s)\n",
2092         mame_time_to_double(mame_timer_get_time()),
2092         attotime_to_double(timer_get_time()),
20932093         activecpu_get_previouspc(),
20942094         data,
20952095         data & 0x01 ? "" : "DATA-WRT",
r1293r1294
21122112   if (data != i8041_p2_old)
21132113   {
21142114      LOG(4,("%9.7f 8041-PC: %03x i8041_p2_w: $%02x (%s%s%s%s%s%s%s%s)\n",
2115         mame_time_to_double(mame_timer_get_time()),
2115         attotime_to_double(timer_get_time()),
21162116         activecpu_get_previouspc(),
21172117         data,
21182118         data & 0x01 ? "" : "FNO/",
r1293r1294
21402140   if (data != i8041_p2_old)
21412141   {
21422142      LOG(4,("%9.7f 8041-PC: %03x i8041_p2_r: $%02x (%s%s%s%s%s%s%s%s)\n",
2143         mame_time_to_double(mame_timer_get_time()),
2143         attotime_to_double(timer_get_time()),
21442144         activecpu_get_previouspc(),
21452145         data,
21462146         data & 0x01 ? "" : "FNO/",
src/mame/machine/decocass.h
r1293r1294
2424extern READ8_HANDLER( decocass_input_r );
2525extern int tape_dir;
2626extern int tape_speed;
27extern mame_time tape_time0;
28extern mame_timer *tape_timer;
29mame_time decocass_adjust_tape_time(mame_time tape_time);
27extern attotime tape_time0;
28extern emu_timer *tape_timer;
29attotime decocass_adjust_tape_time(attotime tape_time);
3030
3131extern WRITE8_HANDLER( decocass_reset_w );
3232
src/mame/machine/konppc.c
r1293r1294
352352
353353/*****************************************************************************/
354354
355UINT32 nwk_fifo_r(int board)
355static UINT32 nwk_fifo_r(int board)
356356{
357357   int cpu = (board == 0) ? 2 : 3;
358358   UINT32 data;
r1293r1294
390390   return data;
391391}
392392
393void nwk_fifo_w(int board, UINT32 data)
393static void nwk_fifo_w(int board, UINT32 data)
394394{
395395   int cpu = (board == 0) ? 2 : 3;
396396
src/mame/machine/irobot.c
r1293r1294
3535static UINT8 irmb_running;
3636
3737#if IR_TIMING
38static mame_timer *irvg_timer;
39static mame_timer *irmb_timer;
38static emu_timer *irvg_timer;
39static emu_timer *irmb_timer;
4040#endif
4141
4242static UINT8 *comRAM[2], *mbRAM, *mbROM;
r1293r1294
112112      else
113113         logerror("vg start [busy!] ");
114114      IR_CPU_STATE;
115      mame_timer_adjust(irvg_timer, MAME_TIME_IN_MSEC(10), 0, time_zero);
115      timer_adjust(irvg_timer, ATTOTIME_IN_MSEC(10), 0, attotime_zero);
116116#endif
117117      irvg_running=1;
118118   }
r1293r1294
185185    /* set a callback for the next 32-scanline increment */
186186    scanline += 32;
187187    if (scanline >= 256) scanline = 0;
188    mame_timer_set(video_screen_get_time_until_pos(0, scanline, 0), scanline, scanline_callback);
188    timer_set(video_screen_get_time_until_pos(0, scanline, 0), scanline, scanline_callback);
189189}
190190
191191static TIMER_CALLBACK( irmb_done_callback );
r1293r1294
201201
202202   irvg_vblank=0;
203203   irvg_running = 0;
204   irvg_timer = mame_timer_alloc(irvg_done_callback);
204   irvg_timer = timer_alloc(irvg_done_callback);
205205   irmb_running = 0;
206   irmb_timer = mame_timer_alloc(irmb_done_callback);
206   irmb_timer = timer_alloc(irmb_done_callback);
207207
208208   /* set an initial timer to go off on scanline 0 */
209   mame_timer_set(video_screen_get_time_until_pos(0, 0, 0), 0, scanline_callback);
209   timer_set(video_screen_get_time_until_pos(0, 0, 0), 0, scanline_callback);
210210
211211   irobot_rom_banksel_w(0,0);
212212   irobot_out0_w(0,0);
r1293r1294
850850#if IR_TIMING
851851   if (irmb_running == 0)
852852   {
853      mame_timer_adjust(irmb_timer, scale_up_mame_time(MAME_TIME_IN_HZ(12000000), icount), 0, time_zero);
853      timer_adjust(irmb_timer, attotime_mul(ATTOTIME_IN_HZ(12000000), icount), 0, attotime_zero);
854854      logerror("mb start ");
855855      IR_CPU_STATE;
856856   }
r1293r1294
858858   {
859859      logerror("mb start [busy!] ");
860860      IR_CPU_STATE;
861      mame_timer_adjust(irmb_timer, scale_up_mame_time(MAME_TIME_IN_NSEC(200), icount), 0, time_zero);
861      timer_adjust(irmb_timer, attotime_mul(ATTOTIME_IN_NSEC(200), icount), 0, attotime_zero);
862862   }
863863#else
864864   cpunum_set_input_line(0, M6809_FIRQ_LINE, ASSERT_LINE);
src/mame/machine/leland.c
r1293r1294
4141
4242static UINT8 leland_gfx_control;
4343static UINT8 wcol_enable;
44static mame_timer *master_int_timer;
44static emu_timer *master_int_timer;
4545
4646static UINT8 *master_base;
4747static UINT8 *slave_base;
r1293r1294
361361   battery_ram = auto_malloc(LELAND_BATTERY_RAM_SIZE);
362362
363363   /* start scanline interrupts going */
364   master_int_timer = mame_timer_alloc(leland_interrupt_callback);
364   master_int_timer = timer_alloc(leland_interrupt_callback);
365365}
366366
367367
368368MACHINE_RESET( leland )
369369{
370   mame_timer_adjust(master_int_timer, video_screen_get_time_until_pos(0, 8, 0), 8, time_zero);
370   timer_adjust(master_int_timer, video_screen_get_time_until_pos(0, 8, 0), 8, attotime_zero);
371371
372372   /* reset globals */
373373   leland_gfx_control = 0x00;
r1293r1294
414414   extra_tram = auto_malloc(ATAXX_EXTRA_TRAM_SIZE);
415415
416416   /* start scanline interrupts going */
417   master_int_timer = mame_timer_alloc(ataxx_interrupt_callback);
417   master_int_timer = timer_alloc(ataxx_interrupt_callback);
418418}
419419
420420
421421MACHINE_RESET( ataxx )
422422{
423423   memset(extra_tram, 0, ATAXX_EXTRA_TRAM_SIZE);
424   mame_timer_adjust(master_int_timer, video_screen_get_time_until_pos(0, 8, 0), 8, time_zero);
424   timer_adjust(master_int_timer, video_screen_get_time_until_pos(0, 8, 0), 8, attotime_zero);
425425
426426   /* initialize the XROM */
427427   xrom_length = memory_region_length(REGION_USER1);
r1293r1294
475475   scanline += 16;
476476   if (scanline > 248)
477477      scanline = 8;
478   mame_timer_adjust(master_int_timer, video_screen_get_time_until_pos(0, scanline, 0), scanline, time_zero);
478   timer_adjust(master_int_timer, video_screen_get_time_until_pos(0, scanline, 0), scanline, attotime_zero);
479479}
480480
481481
r1293r1294
489489   cpunum_set_input_line(0, 0, HOLD_LINE);
490490
491491   /* set a timer for the next one */
492   mame_timer_adjust(master_int_timer, video_screen_get_time_until_pos(0, scanline, 0), scanline, time_zero);
492   timer_adjust(master_int_timer, video_screen_get_time_until_pos(0, scanline, 0), scanline, attotime_zero);
493493}
494494
495495
r1293r1294
12741274         break;
12751275
12761276      case 0x08:   /*  */
1277         mame_timer_adjust(master_int_timer, video_screen_get_time_until_pos(0, data + 1, 0), data + 1, time_zero);
1277         timer_adjust(master_int_timer, video_screen_get_time_until_pos(0, data + 1, 0), data + 1, attotime_zero);
12781278         break;
12791279
12801280      default:
src/mame/machine/midwayic.c
r1293r1294
4949struct pic_state
5050{
5151   UINT16   latch;
52   mame_time latch_expire_time;
52   attotime latch_expire_time;
5353   UINT8   state;
5454   UINT8   index;
5555   UINT8   total;
r1293r1294
6161   UINT8   time_index;
6262   UINT8   time_just_written;
6363   UINT16   yearoffs;
64   mame_timer *time_write_timer;
64   emu_timer *time_write_timer;
6565};
6666
6767struct ioasic_state
r1293r1294
265265{
266266   state_save_register_global(pic.latch);
267267   state_save_register_global(pic.latch_expire_time.seconds);
268   state_save_register_global(pic.latch_expire_time.subseconds);
268   state_save_register_global(pic.latch_expire_time.attoseconds);
269269   state_save_register_global(pic.state);
270270   state_save_register_global(pic.index);
271271   state_save_register_global(pic.total);
r1293r1294
287287
288288   pic.yearoffs = yearoffs;
289289   pic.time_just_written = 0;
290   pic.time_write_timer = mame_timer_alloc(reset_timer);
290   pic.time_write_timer = timer_alloc(reset_timer);
291291   memset(pic.default_nvram, 0xff, sizeof(pic.default_nvram));
292292   generate_serial_data(upper);
293293}
r1293r1294
306306   /* if we're still holding the data ready bit high, do it */
307307   if (pic.latch & 0xf00)
308308   {
309      if (compare_mame_times(mame_timer_get_time(), pic.latch_expire_time) > 0)
309      if (attotime_compare(timer_get_time(), pic.latch_expire_time) > 0)
310310         pic.latch &= 0xff;
311311      else
312312         pic.latch -= 0x100;
r1293r1294
352352
353353   /* store in the latch, along with a bit to indicate we have data */
354354   pic.latch = (data & 0x00f) | 0x480;
355   pic.latch_expire_time = add_mame_times(mame_timer_get_time(), MAME_TIME_IN_MSEC(1));
355   pic.latch_expire_time = attotime_add(timer_get_time(), ATTOTIME_IN_MSEC(1));
356356   if (data & 0x10)
357357   {
358358      int cmd = pic.state ? (pic.state & 0x0f) : (pic.latch & 0x0f);
r1293r1294
441441               /* otherwise, flag the time as having just been written for 1/2 second */
442442               else
443443               {
444                  mame_timer_adjust(pic.time_write_timer, MAME_TIME_IN_MSEC(500), 0, time_zero);
444                  timer_adjust(pic.time_write_timer, ATTOTIME_IN_MSEC(500), 0, attotime_zero);
445445                  pic.time_just_written = 1;
446446                  pic.state = 0;
447447               }
src/mame/machine/kabuki.c
r1293r1294
139139   return src;
140140}
141141
142void kabuki_decode(UINT8 *src,UINT8 *dest_op,UINT8 *dest_data,
142static void kabuki_decode(UINT8 *src,UINT8 *dest_op,UINT8 *dest_data,
143143      int base_addr,int length,int swap_key1,int swap_key2,int addr_key,int xor_key)
144144{
145145   int A;
src/mame/machine/stvcd.c
r1293r1294
105105} trans32T;
106106
107107// local variables
108static mame_timer *sector_timer;
108static emu_timer *sector_timer;
109109static partitionT partitions[MAX_FILTERS];
110110static partitionT *transpart;
111111
r1293r1294
198198   cr3 = (cd_curfad>>16)&0xff;
199199   cr4 = cd_curfad;
200200
201   mame_timer_adjust(sector_timer, MAME_TIME_IN_HZ(150), 0, time_zero);
201   timer_adjust(sector_timer, ATTOTIME_IN_HZ(150), 0, attotime_zero);
202202}
203203
204204// global functions
r1293r1294
273273      cd_stat = CD_STAT_OPEN;
274274   }
275275
276   sector_timer = mame_timer_alloc(sector_cb);
277   mame_timer_adjust(sector_timer, MAME_TIME_IN_HZ(150), 0, time_zero);   // 150 sectors / second = 300kBytes/second
276   sector_timer = timer_alloc(sector_cb);
277   timer_adjust(sector_timer, ATTOTIME_IN_HZ(150), 0, attotime_zero);   // 150 sectors / second = 300kBytes/second
278278}
279279
280280static blockT *cd_alloc_block(UINT8 *blknum)
r1293r1294
776776
777777         // and do the disc I/O
778778         // make sure it doesn't come in too early
779         mame_timer_adjust(sector_timer, time_never, 0, time_never);
780         mame_timer_adjust(sector_timer, MAME_TIME_IN_HZ(150), 0, time_zero);   // 150 sectors / second = 300kBytes/second
779         timer_adjust(sector_timer, attotime_never, 0, attotime_never);
780         timer_adjust(sector_timer, ATTOTIME_IN_HZ(150), 0, attotime_zero);   // 150 sectors / second = 300kBytes/second
781781         break;
782782
783783      case 0x1100: // disk seek
r1293r1294
12851285         playtype = 1;
12861286
12871287         // and do the disc I/O
1288//          mame_timer_adjust(sector_timer, MAME_TIME_IN_HZ(150), 0, time_zero);  // 150 sectors / second = 300kBytes/second
1288//          timer_adjust(sector_timer, ATTOTIME_IN_HZ(150), 0, attotime_zero);  // 150 sectors / second = 300kBytes/second
12891289         break;
12901290
12911291      case 0x7500:
src/mame/machine/ticket.c
r1293r1294
2121{
2222   UINT8 status;
2323   UINT8 power;
24   mame_timer *timer;
24   emu_timer *timer;
2525};
2626
2727static int active_bit = 0x80;
r1293r1294
5353   {
5454      dispenser[i].status   = ticketnotdispensed;
5555      dispenser[i].power    = 0x00;
56      dispenser[i].timer    = mame_timer_alloc_ptr(ticket_dispenser_toggle, &dispenser[i]);
56      dispenser[i].timer    = timer_alloc_ptr(ticket_dispenser_toggle, &dispenser[i]);
5757
5858      state_save_register_item("ticket", i, dispenser[i].status);
5959      state_save_register_item("ticket", i, dispenser[i].power);
r1293r1294
102102#ifdef DEBUG_TICKET
103103         logerror("PC: %04X  Ticket Power On\n", activecpu_get_pc());
104104#endif
105         mame_timer_adjust_ptr(dispenser[0].timer, MAME_TIME_IN_MSEC(time_msec), time_zero);
105         timer_adjust_ptr(dispenser[0].timer, ATTOTIME_IN_MSEC(time_msec), attotime_zero);
106106         dispenser[0].power = 1;
107107
108108         dispenser[0].status = ticketnotdispensed;
r1293r1294
115115#ifdef DEBUG_TICKET
116116         logerror("PC: %04X  Ticket Power Off\n", activecpu_get_pc());
117117#endif
118         mame_timer_adjust_ptr(dispenser[0].timer, time_never, time_never);
118         timer_adjust_ptr(dispenser[0].timer, attotime_never, attotime_never);
119119         set_led_status(2,0);
120120         dispenser[0].power = 0;
121121      }
r1293r1294
132132#ifdef DEBUG_TICKET
133133         logerror("PC: %04X  Ticket Power On\n", activecpu_get_pc());
134134#endif
135         mame_timer_adjust_ptr(dispenser[1].timer, MAME_TIME_IN_MSEC(time_msec), time_zero);
135         timer_adjust_ptr(dispenser[1].timer, ATTOTIME_IN_MSEC(time_msec), attotime_zero);
136136         dispenser[1].power = 1;
137137
138138         dispenser[1].status = ticketnotdispensed;
r1293r1294
145145#ifdef DEBUG_TICKET
146146         logerror("PC: %04X  Ticket Power Off\n", activecpu_get_pc());
147147#endif
148         mame_timer_adjust_ptr(dispenser[1].timer, time_never, time_never);
148         timer_adjust_ptr(dispenser[1].timer, attotime_never, attotime_never);
149149         set_led_status(2,0);
150150         dispenser[1].power = 0;
151151      }
r1293r1294
171171#ifdef DEBUG_TICKET
172172      logerror("Ticket Status Changed to %02X\n", status);
173173#endif
174      mame_timer_adjust_ptr(dispenser->timer, MAME_TIME_IN_MSEC(time_msec), time_zero);
174      timer_adjust_ptr(dispenser->timer, ATTOTIME_IN_MSEC(time_msec), attotime_zero);
175175   }
176176
177177   if (dispenser->status == ticketdispensed)
src/mame/machine/namcoio.c
r1293r1294
158158
159159static struct namcoio io[MAX_NAMCOIO];
160160static INT32 nmi_cpu[MAX_06XX];
161static mame_timer *nmi_timer[MAX_06XX];
161static emu_timer *nmi_timer[MAX_06XX];
162162
163163static READ8_HANDLER( nop_r ) { return 0x0f; }
164164static WRITE8_HANDLER( nop_w ) { }
r1293r1294
18218207: nop
183183*/
184184
185void namcoio_51XX_write(int chip,int data)
185static void namcoio_51XX_write(int chip,int data)
186186{
187187   data &= 0x07;
188188
r1293r1294
282282{    0xf, 0xe, 0xd, 0x5, 0xc, 0x9, 0x7, 0x6, 0xb, 0x3, 0xa, 0x4, 0x1, 0x2, 0x0, 0x8 };
283283
284284
285UINT8 namcoio_51XX_read(int chip)
285static UINT8 namcoio_51XX_read(int chip)
286286{
287287#if VERBOSE
288288   logerror("%04x: custom 51XX read\n",activecpu_get_pc());
r1293r1294
435435/***************************************************************************/
436436
437437
438UINT8 namcoio_ram[MAX_NAMCOIO * 16];
438static UINT8 namcoio_ram[MAX_NAMCOIO * 16];
439439
440440#define IORAM_READ(offset) (namcoio_ram[chip * 0x10 + (offset)] & 0x0f)
441441#define IORAM_WRITE(offset,data) {namcoio_ram[chip * 0x10 + (offset)] = (data) & 0x0f;}
r1293r1294
794794   if (chipnum < MAX_NAMCOIO && state != CLEAR_LINE && !io[chipnum].reset)
795795   {
796796      /* give the cpu a tiny bit of time to write the command before processing it */
797      mame_timer_set(MAME_TIME_IN_USEC(50), chipnum, namcoio_run);
797      timer_set(ATTOTIME_IN_USEC(50), chipnum, namcoio_run);
798798   }
799799}
800800
r1293r1294
876876      namcoio_init(4*chipnum + 2, type2, intf2);
877877      namcoio_init(4*chipnum + 3, type3, intf3);
878878      nmi_cpu[chipnum] = cpu;
879      nmi_timer[chipnum] = mame_timer_alloc(nmi_generate);
879      nmi_timer[chipnum] = timer_alloc(nmi_generate);
880880      namco_06xx_state_save(chipnum);
881881   }
882882}
r1293r1294
10411041#if VERBOSE
10421042      logerror("disabling nmi generate timer\n");
10431043#endif
1044      mame_timer_adjust(nmi_timer[chip], time_never, chip, time_never);
1044      timer_adjust(nmi_timer[chip], attotime_never, chip, attotime_never);
10451045   }
10461046   else
10471047   {
r1293r1294
10521052      // inputs if a transfer terminates at the wrong time.
10531053      // On the other hand, the time cannot be too short otherwise the 54XX will
10541054      // not have enough time to process the incoming commands.
1055      mame_timer_adjust(nmi_timer[chip], MAME_TIME_IN_USEC(200), chip, MAME_TIME_IN_USEC(200));
1055      timer_adjust(nmi_timer[chip], ATTOTIME_IN_USEC(200), chip, ATTOTIME_IN_USEC(200));
10561056
10571057      if (customio_command[chip] & 0x10)
10581058      {
src/mame/machine/pitnrun.c
r1293r1294
4747READ8_HANDLER( pitnrun_mcu_status_r )
4848{
4949   /* mcu synchronization */
50   cpu_yielduntil_time (MAME_TIME_IN_USEC(5));
50   cpu_yielduntil_time (ATTOTIME_IN_USEC(5));
5151   /* bit 0 = the 68705 has read data from the Z80 */
5252   /* bit 1 = the 68705 has written data for the Z80 */
5353   return ~((zready << 1) | (zaccept << 0));
src/mame/machine/namcos1.c
r1293r1294
700700   namcos1_active_bank[banknum] = *handler;
701701}
702702
703void namcos1_bankswitch(int cpu, offs_t offset, UINT8 data)
703static void namcos1_bankswitch(int cpu, offs_t offset, UINT8 data)
704704{
705705   static int chip[16];
706706   int bank = (cpu*8) + (( offset >> 9) & 0x07);
src/mame/machine/n64.c
r1293r1294
584584
585585
586586// Video Interface
587UINT32 vi_width;
587static UINT32 vi_width;
588588UINT32 vi_origin;
589589UINT32 vi_control;
590UINT32 vi_burst, vi_vsync, vi_hsync, vi_leap, vi_hstart, vi_vstart;
591UINT32 vi_intr, vi_vburst, vi_xscale, vi_yscale;
590static UINT32 vi_burst, vi_vsync, vi_hsync, vi_leap, vi_hstart, vi_vstart;
591static UINT32 vi_intr, vi_vburst, vi_xscale, vi_yscale;
592592
593593READ32_HANDLER( n64_vi_reg_r )
594594{
r1293r1294
737737static int ai_bitrate;
738738static UINT32 ai_status = 0;
739739
740static mame_timer *audio_timer;
740static emu_timer *audio_timer;
741741
742742#define SOUNDBUFFER_LENGTH   0x20000
743743#define AUDIO_DMA_DEPTH      2
r1293r1294
756756static void audio_fifo_push(UINT32 address, UINT32 length)
757757{
758758   AUDIO_DMA *current;
759   mame_time period;
759   attotime period;
760760
761761   if (audio_fifo_num == AUDIO_DMA_DEPTH)
762762   {
r1293r1294
783783   }
784784
785785   // adjust the timer
786   period = scale_up_mame_time(MAME_TIME_IN_HZ(DACRATE_NTSC), (ai_dacrate + 1) * (current->length / 4));
787   mame_timer_adjust(audio_timer, period, 0, time_zero);
786   period = attotime_mul(ATTOTIME_IN_HZ(DACRATE_NTSC), (ai_dacrate + 1) * (current->length / 4));
787   timer_adjust(audio_timer, period, 0, attotime_zero);
788788}
789789
790790static void audio_fifo_pop(void)
r1293r1294
10571057}
10581058
10591059// Serial Interface
1060UINT8 pif_ram[0x40];
1061UINT8 pif_cmd[0x40];
1060static UINT8 pif_ram[0x40];
1061static UINT8 pif_cmd[0x40];
10621062UINT32 si_dram_addr = 0;
10631063UINT32 si_pif_addr = 0;
10641064UINT32 si_status = 0;
r1293r1294
15761576   cpunum_set_info_ptr(0, CPUINFO_PTR_MIPS3_FASTRAM_BASE, rdram);
15771577   cpunum_set_info_int(0, CPUINFO_INT_MIPS3_FASTRAM_READONLY, 0);
15781578
1579   audio_timer = mame_timer_alloc(audio_timer_callback);
1580   mame_timer_adjust(audio_timer, time_never, 0, time_never);
1579   audio_timer = timer_alloc(audio_timer_callback);
1580   timer_adjust(audio_timer, attotime_never, 0, attotime_never);
15811581
15821582   cpunum_set_input_line(1, INPUT_LINE_HALT, ASSERT_LINE);
15831583
src/mame/machine/stfight.c
r1293r1294
108108{
109109    // Do a RST10
110110    cpunum_set_input_line_and_vector(0,0,HOLD_LINE,0xd7);
111      mame_timer_set(MAME_TIME_IN_HZ(120), 0, stfight_interrupt_1);
111      timer_set(ATTOTIME_IN_HZ(120), 0, stfight_interrupt_1);
112112}
113113
114114/*
src/mame/machine/tait8741.c
r1293r1294
7878
7979/* TAITO8741 I8741 emulation */
8080
81void taito8741_serial_rx(I8741 *st,UINT8 *data)
81static void taito8741_serial_rx(I8741 *st,UINT8 *data)
8282{
8383   memcpy(st->rxd,data,8);
8484}
r1293r1294
445445   if( (i8741[num].sts & 0x02) )
446446   {
447447      /* transmit data */
448      mame_timer_set (MAME_TIME_IN_USEC(1),num,josvolly_8741_tx);
448      timer_set (ATTOTIME_IN_USEC(1),num,josvolly_8741_tx);
449449   }
450450}
451451
src/mame/machine/volfied.c
r1293r1294
392392         // Palette request cmd - verified to take around 122242 68000 cycles to complete
393393         if (current_cmd >= 0x1 && current_cmd < 0x12)
394394         {
395            mame_timer_set(MAME_TIME_IN_CYCLES(122242,0), 0, timer_callback);
395            timer_set(ATTOTIME_IN_CYCLES(122242,0), 0, timer_callback);
396396         }
397397         // Unknown cmd - verified to take around 105500 68000 cycles to complete
398398         else if (current_cmd >= 0x81 && current_cmd < 0x92)
399399         {
400            mame_timer_set(MAME_TIME_IN_CYCLES(105500,0), 0, timer_callback);
400            timer_set(ATTOTIME_IN_CYCLES(105500,0), 0, timer_callback);
401401         }
402402         else
403403         {
src/mame/machine/balsente.c
r1293r1294
3535/* 8253 counter state */
3636struct counter_state
3737{
38   mame_timer *timer;
38   emu_timer *timer;
3939   UINT8 timer_active;
4040   INT32 initial;
4141   INT32 count;
r1293r1294
4848
4949static struct counter_state counter[3];
5050
51static mame_timer *scanline_timer;
51static emu_timer *scanline_timer;
5252
5353/* manually clocked counter 0 states */
5454static UINT8 counter_control;
5555static UINT8 counter_0_ff;
56static mame_timer *counter_0_timer;
56static emu_timer *counter_0_timer;
5757static UINT8 counter_0_timer_active;
5858
5959/* random number generator states */
r1293r1294
111111{
112112   /* next interrupt after scanline 256 is scanline 64 */
113113   if (param == 256)
114      mame_timer_adjust(scanline_timer, video_screen_get_time_until_pos(0, 64, 0), 64, time_zero);
114      timer_adjust(scanline_timer, video_screen_get_time_until_pos(0, 64, 0), 64, attotime_zero);
115115   else
116      mame_timer_adjust(scanline_timer, video_screen_get_time_until_pos(0, param + 64, 0), param + 64, time_zero);
116      timer_adjust(scanline_timer, video_screen_get_time_until_pos(0, param + 64, 0), param + 64, attotime_zero);
117117
118118   /* IRQ starts on scanline 0, 64, 128, etc. */
119119   cpunum_set_input_line(0, M6809_IRQ_LINE, ASSERT_LINE);
120120
121121   /* it will turn off on the next HBLANK */
122   mame_timer_set(video_screen_get_time_until_pos(0, param, BALSENTE_HBSTART), 0, irq_off);
122   timer_set(video_screen_get_time_until_pos(0, param, BALSENTE_HBSTART), 0, irq_off);
123123
124124   /* if this is Grudge Match, update the steering */
125125   if (grudge_steering_result & 0x80)
r1293r1294
155155
156156   /* reset counters; counter 2's gate is tied high */
157157   memset(counter, 0, sizeof(counter));
158   counter[1].timer = mame_timer_alloc(counter_callback);
159   counter[2].timer = mame_timer_alloc(counter_callback);
158   counter[1].timer = timer_alloc(counter_callback);
159   counter[2].timer = timer_alloc(counter_callback);
160160   counter[2].gate = 1;
161161
162162   /* reset the manual counter 0 clock */
163163   counter_control = 0x00;
164164   counter_0_ff = 0;
165   counter_0_timer = mame_timer_alloc(clock_counter_0_ff);
165   counter_0_timer = timer_alloc(clock_counter_0_ff);
166166   counter_0_timer_active = 0;
167167
168168   /* reset the ADC states */
r1293r1294
191191   memory_set_bank(2, 0);
192192
193193   /* start a timer to generate interrupts */
194   scanline_timer = mame_timer_alloc(interrupt_timer);
195   mame_timer_adjust(scanline_timer, video_screen_get_time_until_pos(0, 0, 0), 0, time_zero);
194   scanline_timer = timer_alloc(interrupt_timer);
195   timer_adjust(scanline_timer, video_screen_get_time_until_pos(0, 0, 0), 0, attotime_zero);
196196
197197   /* register for saving */
198198   for (i = 0; i < 3; i++)
r1293r1294
525525
526526   /* set a timer for 500usec later to actually transmit the data */
527527   /* (this is very important for several games, esp Snacks'n Jaxson) */
528   mame_timer_set(MAME_TIME_IN_USEC(500), param, m6850_data_ready_callback);
528   timer_set(ATTOTIME_IN_USEC(500), param, m6850_data_ready_callback);
529529}
530530
531531
r1293r1294
661661   /* set a timer to go off and read the value after 50us */
662662   /* it's important that we do this for Mini Golf */
663663logerror("adc_select %d\n", offset & 7);
664   mame_timer_set(MAME_TIME_IN_USEC(50), offset & 7, adc_finished);
664   timer_set(ATTOTIME_IN_USEC(50), offset & 7, adc_finished);
665665}
666666
667667
r1293r1294
683683      if (counter[which].gate && !counter[which].timer_active)
684684      {
685685         counter[which].timer_active = 1;
686         mame_timer_adjust(counter[which].timer, scale_up_mame_time(MAME_TIME_IN_HZ(2000000), counter[which].count), which, time_zero);
686         timer_adjust(counter[which].timer, attotime_mul(ATTOTIME_IN_HZ(2000000), counter[which].count), which, attotime_zero);
687687      }
688688   }
689689}
r1293r1294
693693{
694694   /* only stop the timer if it exists */
695695   if (counter[which].timer_active)
696      mame_timer_adjust(counter[which].timer, time_never, 0, time_zero);
696      timer_adjust(counter[which].timer, attotime_never, 0, attotime_zero);
697697   counter[which].timer_active = 0;
698698}
699699
r1293r1294
704704   if (counter[which].timer_active)
705705   {
706706      /* determine how many 2MHz cycles are remaining */
707      int count = mame_time_to_double(scale_up_mame_time(mame_timer_timeleft(counter[which].timer), 2000000));
707      int count = attotime_to_double(attotime_mul(timer_timeleft(counter[which].timer), 2000000));
708708      counter[which].count = (count < 0) ? 0 : count;
709709   }
710710}
r1293r1294
932932
933933   /* if there's already a timer, remove it */
934934   if (counter_0_timer_active)
935      mame_timer_adjust(counter_0_timer, time_never, 0, time_zero);
935      timer_adjust(counter_0_timer, attotime_never, 0, attotime_zero);
936936   counter_0_timer_active = 0;
937937
938938   /* find the counter with the maximum frequency */
r1293r1294
957957   if (maxfreq > 0.0)
958958   {
959959      counter_0_timer_active = 1;
960      mame_timer_adjust(counter_0_timer, MAME_TIME_IN_HZ(maxfreq), 0, MAME_TIME_IN_HZ(maxfreq));
960      timer_adjust(counter_0_timer, ATTOTIME_IN_HZ(maxfreq), 0, ATTOTIME_IN_HZ(maxfreq));
961961   }
962962}
963963
r1293r1294
10061006   /* if we gate off, remove the timer */
10071007   else if (counter[0].gate && !(data & 0x02) && counter_0_timer_active)
10081008   {
1009      mame_timer_adjust(counter_0_timer, time_never, 0, time_zero);
1009      timer_adjust(counter_0_timer, attotime_never, 0, attotime_zero);
10101010      counter_0_timer_active = 0;
10111011   }
10121012
src/mame/machine/vsnes.c
r1293r1294
1111#include "video/ppu2c0x.h"
1212
1313/* Globals */
14int vsnes_gun_controller;
15int vsnes_do_vrom_bank;
14static int vsnes_gun_controller;
15static int vsnes_do_vrom_bank;
1616
1717/* Locals */
1818static int input_latch[4];
src/mame/machine/meters.c
r0r1294
1///////////////////////////////////////////////////////////////////////////
2//                                                                       //
3// Electro mechanical meters                                             //
4//                                                                       //
5// 23-07-2004: Re-Animator                                               //
6//                                                                       //
7// TODO: - meter ticks if the signal changes from high to low AND the    //
8//         signal was high for at least 'reacttime' cycles               //
9//         It should tick if the signal goes from low to high AND stays  //
10//         high for at least xxx milliseconds                            //
11//                                                                       //
12///////////////////////////////////////////////////////////////////////////
13
14#include "driver.h"
15#include "meters.h"
16
17// local vars /////////////////////////////////////////////////////////////
18
19static struct
20{
21  long timestamp,   // time stamp in cycles after which timer will tick
22      reacttime,
23      count;      // mechmeter value
24  int  state;      // state 0/1
25} meter_info[MAXMECHMETERS];
26
27
28static int number_mtr;
29
30///////////////////////////////////////////////////////////////////////////
31
32void Mechmtr_init(int number)
33{
34  int i;
35
36  if ( number > MAXMECHMETERS ) number = MAXMECHMETERS;
37
38  for ( i = 0; i < number; i++ )
39  {
40   meter_info[i].reacttime = METERREACTTIME;
41   meter_info[i].state     = 0;
42   meter_info[i].count     = 0;
43   meter_info[i].timestamp = 0;
44  }
45  number_mtr = number;
46}
47
48///////////////////////////////////////////////////////////////////////////
49
50int  MechMtr_GetNumberMeters(void)
51{
52  return number_mtr;
53}
54
55///////////////////////////////////////////////////////////////////////////
56
57void MechMtr_Setcount(int id, long count)
58{
59  if ( id >= number_mtr ) return;
60
61  meter_info[id].count = count;
62}
63
64///////////////////////////////////////////////////////////////////////////
65
66long MechMtr_Getcount(int id)
67{
68  long result = 0;
69
70  if ( id < number_mtr ) result = meter_info[id].count;
71
72  return result;
73}
74
75///////////////////////////////////////////////////////////////////////////
76
77void MechMtr_ReactTime(int id, long cycles)
78{
79  if ( id >= number_mtr ) return;
80
81  meter_info[id].reacttime = cycles;
82}
83
84///////////////////////////////////////////////////////////////////////////
85
86int Mechmtr_update(int id, long cycles, int state)
87{
88  int res = 0;
89
90  if ( id >= number_mtr ) return res;
91
92  state = state?1:0;
93
94  if ( meter_info[id].state != state )
95  {   // meter state is changing
96   meter_info[id].state = state;
97
98   if ( state )
99   {
100     meter_info[id].timestamp = cycles + meter_info[id].reacttime;
101   }
102   else
103   {
104     if ( cycles > meter_info[id].timestamp )
105     { // meter has been active long enough
106      res = 1;
107      meter_info[id].count++;
108     }
109   }
110  }
111
112  return res;
113}
src/mame/machine/qix.c
r1293r1294
271271INTERRUPT_GEN( qix_vblank_start )
272272{
273273   pia_3_cb1_w(0, 1);
274   mame_timer_set(video_screen_get_time_until_pos(0, 0, 0), 0, vblank_stop);
274   timer_set(video_screen_get_time_until_pos(0, 0, 0), 0, vblank_stop);
275275}
276276
277277
r1293r1294
427427      cpunum_set_input_line(3, M68705_IRQ_LINE, ASSERT_LINE);
428428      /* temporarily boost the interleave to sync things up */
429429      /* note: I'm using 50 because 30 is not enough for space dungeon at game over */
430      cpu_boost_interleave(time_zero, MAME_TIME_IN_USEC(50));
430      cpu_boost_interleave(attotime_zero, ATTOTIME_IN_USEC(50));
431431   }
432432   else
433433      cpunum_set_input_line(3, M68705_IRQ_LINE, CLEAR_LINE);
src/mame/machine/meters.h
r0r1294
1///////////////////////////////////////////////////////////////////////////
2//                                                                       //
3// Electro mechanical meters                                             //
4//                                                                       //
5// 23-07-2004: Re-Animator                                               //
6//                                                                       //
7// TODO: - meter ticks if the signal changes from high to low AND the    //
8//         signal was high for at least 'reacttime' cycles               //
9//         It should tick if the signal goes from low to high AND stays  //
10//         high for at least xxx milliseconds                            //
11//                                                                       //
12///////////////////////////////////////////////////////////////////////////
13
14#ifndef INC_MMTR
15#define INC_MMTR
16
17#define MAXMECHMETERS 8
18
19#define METERREACTTIME 30000   // number of cycles meter has to be active to tick
20
21void Mechmtr_init(     int number);
22
23int  MechMtr_GetNumberMeters(void);
24
25void MechMtr_Setcount( int id, long count);
26
27long MechMtr_Getcount( int id);
28
29void MechMtr_ReactTime(int id, long cycles);
30
31int  Mechmtr_update(   int id, long cycles, int state); // returns 1 if meter ticked
32
33#endif
src/mame/machine/steppers.c
r1293r1294
1212//                                                                       //
1313// TODO:  add different types of stepper motors if needed                //
1414//                                                                       //
15// Any fixes for this driver should be forwarded to AGEMAME HQ           //
16// (http://www.mameworld.net/agemame/)                                   //
1715///////////////////////////////////////////////////////////////////////////
1816
1917#include "driver.h"
r1293r1294
607605      steppers[id].pattern     = 0;
608606      steppers[id].old_pattern = 0;
609607      steppers[id].step_pos    = 0;
610      steppers[id].max_steps   = 48*2;
608      steppers[id].max_steps   = (48*2)-1;
611609      steppers[id].type       = type;
612610
613611      switch ( steppers[id].type )
r1293r1294
620618         steppers[id].index_patt  = 0x09;
621619         break;
622620         case STEPPER_144STEPS_DICE :  // STARPOINT 1DCU DICE mechanism
623         steppers[id].max_steps = 144*2;
621         steppers[id].max_steps = (144*2)-1;
624622         break;
625623      }
626624      state_save_register_item("Stepper", id, steppers[id].index_pos);
src/mame/machine/snes.c
r1293r1294
3737static UINT8 snes_hdma_chnl;   /* channels enabled for HDMA */
3838static UINT8 joy1l, joy1h, joy2l, joy2h, joy3l, joy3h, joy4l, joy4h;
3939static UINT8 read_ophct = 0, read_opvct = 0;
40static mame_timer *snes_scanline_timer;
41static mame_timer *snes_hblank_timer;
42static mame_timer *snes_nmi_timer;
43static mame_timer *snes_hirq_timer;
40static emu_timer *snes_scanline_timer;
41static emu_timer *snes_hblank_timer;
42static emu_timer *snes_nmi_timer;
43static emu_timer *snes_hirq_timer;
4444static UINT16 hblank_offset;
4545static UINT16 snes_htmult;   /* in 512 wide, we run HTOTAL double and halve it on latching */
4646
r1293r1294
6161} joypad[4];
6262
6363// quick extern to fix missing header
64extern mame_time video_screen_get_time_until_pos(int scrnum, int vpos, int hpos);
64extern attotime video_screen_get_time_until_pos(int scrnum, int vpos, int hpos);
6565
6666// utility function - latches the H/V counters.  Used by IRQ, writes to WRIO, etc.
6767static void snes_latch_counters(void)
r1293r1294
8181   cpunum_set_input_line( 0, G65816_LINE_NMI, HOLD_LINE );
8282
8383   // don't happen again
84   mame_timer_adjust(snes_nmi_timer, time_never, 0, time_never);
84   timer_adjust(snes_nmi_timer, attotime_never, 0, attotime_never);
8585}
8686
8787static void snes_hirq_tick(void)
r1293r1294
9393   cpunum_set_input_line( 0, G65816_LINE_IRQ, HOLD_LINE );
9494
9595   // don't happen again
96   mame_timer_adjust(snes_hirq_timer, time_never, 0, time_never);
96   timer_adjust(snes_hirq_timer, attotime_never, 0, attotime_never);
9797}
9898
9999static TIMER_CALLBACK( snes_hirq_tick_callback )
r1293r1294
147147         }
148148         else
149149         {
150            mame_timer_adjust(snes_hirq_timer, video_screen_get_time_until_pos(0, snes_ppu.beam.current_vert, pixel*snes_htmult), 0, time_never);
150            timer_adjust(snes_hirq_timer, video_screen_get_time_until_pos(0, snes_ppu.beam.current_vert, pixel*snes_htmult), 0, attotime_never);
151151         }
152152      }
153153       }
r1293r1294
163163      if( snes_ram[NMITIMEN] & 0x80 )   /* NMI only signaled if this bit set */
164164      {
165165         // NMI goes off about 12 cycles after this (otherwise Chrono Trigger, NFL QB Club, etc. lock up)
166         mame_timer_adjust(snes_nmi_timer, MAME_TIME_IN_CYCLES(12, 0), 0, time_zero);
166         timer_adjust(snes_nmi_timer, ATTOTIME_IN_CYCLES(12, 0), 0, attotime_zero);
167167      }
168168   }
169169
r1293r1294
228228
229229   cpuintrf_pop_context();
230230
231   mame_timer_adjust(snes_scanline_timer, time_never, 0, time_never);
232   mame_timer_adjust(snes_hblank_timer, video_screen_get_time_until_pos(0, snes_ppu.beam.current_vert, hblank_offset*snes_htmult), 0, time_never);
231   timer_adjust(snes_scanline_timer, attotime_never, 0, attotime_never);
232   timer_adjust(snes_hblank_timer, video_screen_get_time_until_pos(0, snes_ppu.beam.current_vert, hblank_offset*snes_htmult), 0, attotime_never);
233233}
234234
235235/* This is called at the start of hblank *before* the scanline indicated in current_vert! */
r1293r1294
240240   snes_ppu.beam.current_vert = video_screen_get_vpos(0);
241241
242242   /* make sure we halt */
243   mame_timer_adjust(snes_hblank_timer, time_never, 0, time_never);
243   timer_adjust(snes_hblank_timer, attotime_never, 0, attotime_never);
244244
245245   // we must guarantee the 65816's context for HDMA to work
246246     cpuintrf_push_context(0);
r1293r1294
272272      nextscan = 0;
273273   }
274274
275   mame_timer_adjust(snes_scanline_timer, video_screen_get_time_until_pos(0, nextscan, 0), 0, time_never);
275   timer_adjust(snes_scanline_timer, video_screen_get_time_until_pos(0, nextscan, 0), 0, attotime_never);
276276}
277277
278278static void snes_init_ram(void)
r1293r1294
318318   snes_ram[VMAIN] = 0x80;
319319
320320   /* init timers and stop them */
321   snes_scanline_timer = mame_timer_alloc(snes_scanline_tick);
322   mame_timer_adjust(snes_scanline_timer, time_never, 0, time_never);
323   snes_hblank_timer = mame_timer_alloc(snes_hblank_tick);
324   mame_timer_adjust(snes_hblank_timer, time_never, 0, time_never);
325   snes_nmi_timer = mame_timer_alloc(snes_nmi_tick);
326   mame_timer_adjust(snes_nmi_timer, time_never, 0, time_never);
327   snes_hirq_timer = mame_timer_alloc(snes_hirq_tick_callback);
328   mame_timer_adjust(snes_hirq_timer, time_never, 0, time_never);
321   snes_scanline_timer = timer_alloc(snes_scanline_tick);
322   timer_adjust(snes_scanline_timer, attotime_never, 0, attotime_never);
323   snes_hblank_timer = timer_alloc(snes_hblank_tick);
324   timer_adjust(snes_hblank_timer, attotime_never, 0, attotime_never);
325   snes_nmi_timer = timer_alloc(snes_nmi_tick);
326   timer_adjust(snes_nmi_timer, attotime_never, 0, attotime_never);
327   snes_hirq_timer = timer_alloc(snes_hirq_tick_callback);
328   timer_adjust(snes_hirq_timer, attotime_never, 0, attotime_never);
329329
330330   // SNES hcounter has a 0-339 range.  hblank starts at counter 260.
331331   // clayfighter sets an HIRQ at 260, apparently it wants it to be before hdma kicks off, so we'll delay 2 pixels.
332332   hblank_offset = 268;
333   mame_timer_adjust(snes_hblank_timer, video_screen_get_time_until_pos(0, ((snes_ram[STAT78] & 0x10) == SNES_NTSC) ? SNES_VTOTAL_NTSC-1 : SNES_VTOTAL_PAL-1, hblank_offset), 0, time_never);
333   timer_adjust(snes_hblank_timer, video_screen_get_time_until_pos(0, ((snes_ram[STAT78] & 0x10) == SNES_NTSC) ? SNES_VTOTAL_NTSC-1 : SNES_VTOTAL_PAL-1, hblank_offset), 0, attotime_never);
334334
335335   // check if DSP1 is present (maybe not 100%?)
336336   has_dsp1 = ((snes_r_bank1(0xffd6) >= 3) && (snes_r_bank1(0xffd6) <= 5)) ? 1 : 0;
337337
338338   // init frame counter so first line is 0
339   if( SUBSECONDS_TO_HZ(Machine->screen[0].refresh) >= 59 )
339   if( ATTOSECONDS_TO_HZ(Machine->screen[0].refresh) >= 59 )
340340   {
341341      snes_ppu.beam.current_vert = SNES_VTOTAL_NTSC;
342342   }
r1293r1294
379379   snes_init_ram();
380380
381381   /* Set STAT78 to NTSC or PAL */
382   if( SUBSECONDS_TO_HZ(machine->screen[0].refresh) >= 59.0f )
382   if( ATTOSECONDS_TO_HZ(machine->screen[0].refresh) >= 59.0f )
383383      snes_ram[STAT78] = SNES_NTSC;
384384   else /* if( machine->screen[0].refresh == 50 ) */
385385      snes_ram[STAT78] = SNES_PAL;
r1293r1294
962962   {
963963//          printf("816: %02x to APU @ %d\n", data, offset&3);
964964           spc_port_in[offset & 0x3] = data;
965      cpu_boost_interleave(time_zero, MAME_TIME_IN_USEC(20));
965      cpu_boost_interleave(attotime_zero, ATTOTIME_IN_USEC(20));
966966      return;
967967   }
968968
src/mame/machine/steppers.h
r1293r1294
1//Any fixes for this driver should be forwarded to AGEMAME HQ (http://www.mameworld.net/agemame/)
1///////////////////////////////////////////////////////////////////////////
2//                                                                       //
3// Steppermotor emulation                                                //
4//                                                                       //
5// Emulates : 48 step motors driven with full step or half step          //
6//            also emulates the index optic                              //
7//                                                                       //
8// 26-01-2007: J. Wallace - Rewritten to make it more flexible           //
9//                          and to allow indices to be set in drivers    //
10// 29-12-2006: J. Wallace - Added state save support                     //
11// 05-03-2004: Re-Animator                                               //
12//                                                                       //
13// TODO:  add different types of stepper motors if needed                //
14//                                                                       //
15///////////////////////////////////////////////////////////////////////////
216
17
318#ifndef INC_STEPPERS
419#define INC_STEPPERS
520
r1293r1294
722
823#define STEPPER_48STEP_REEL    0         // STARPOINT RMXXX reel unit
924#define BARCREST_48STEP_REEL   1         // Barcrest bespoke reel unit
10#define STEPPER_144STEPS_DICE  2         // STARPOINT 1DCU DICE mechanism - tech sheet available from Re-A or EC on request
25#define STEPPER_144STEPS_DICE  2         // STARPOINT 1DCU DICE mechanism - tech sheet available on request
1126
1227void Stepper_init(  int id, int type);      // init a stepper motor
1328
src/mame/machine/taitosj.c
r1293r1294
134134#endif
135135   timer_call_after_resynch(data,taitosj_mcu_real_data_w);
136136   /* temporarily boost the interleave to sync things up */
137   cpu_boost_interleave(time_zero, MAME_TIME_IN_USEC(10));
137   cpu_boost_interleave(attotime_zero, ATTOTIME_IN_USEC(10));
138138}
139139
140140READ8_HANDLER( taitosj_mcu_status_r )
141141{
142142   /* temporarily boost the interleave to sync things up */
143   cpu_boost_interleave(time_zero, MAME_TIME_IN_USEC(10));
143   cpu_boost_interleave(attotime_zero, ATTOTIME_IN_USEC(10));
144144
145145   /* bit 0 = the 68705 has read data from the Z80 */
146146   /* bit 1 = the 68705 has written data for the Z80 */
src/mame/machine/amiga.c
r1293r1294
7676
7777static autoconfig_device *autoconfig_list;
7878static autoconfig_device *cur_autoconfig;
79static mame_timer * amiga_irq_timer;
80static mame_timer * amiga_blitter_timer;
79static emu_timer * amiga_irq_timer;
80static emu_timer * amiga_blitter_timer;
8181
8282const char *amiga_custom_names[0x100] =
8383{
r1293r1294
293293   cia_config(1, &cia_intf[1]);
294294
295295   /* setup the timers */
296   amiga_irq_timer = mame_timer_alloc(amiga_irq_proc);
297   amiga_blitter_timer = mame_timer_alloc(amiga_blitter_proc);
296   amiga_irq_timer = timer_alloc(amiga_irq_proc);
297   amiga_blitter_timer = timer_alloc(amiga_blitter_proc);
298298}
299299
300300
r1293r1294
434434static TIMER_CALLBACK( amiga_irq_proc )
435435{
436436   update_irqs();
437   mame_timer_reset( amiga_irq_timer, time_never);
437   timer_reset( amiga_irq_timer, attotime_never);
438438}
439439
440440/*************************************
r1293r1294
968968   amiga_custom_w(REG_INTREQ, 0x8000 | INTENA_BLIT, 0);
969969
970970   /* reset the blitter timer */
971   mame_timer_reset( amiga_blitter_timer, time_never);
971   timer_reset( amiga_blitter_timer, attotime_never);
972972}
973973
974974
r1293r1294
10321032    CUSTOM_REG(REG_DMACON) |= 0x4000;
10331033
10341034   /* set a timer */
1035   mame_timer_adjust( amiga_blitter_timer, MAME_TIME_IN_CYCLES( blittime, 0 ), 0, time_zero);
1035   timer_adjust( amiga_blitter_timer, ATTOTIME_IN_CYCLES( blittime, 0 ), 0, attotime_zero);
10361036}
10371037
10381038
r1293r1294
13081308         if (amiga_intf->serdat_w != NULL)
13091309            (*amiga_intf->serdat_w)(data);
13101310         CUSTOM_REG(REG_SERDATR) &= ~0x3000;
1311         mame_timer_set(amiga_get_serial_char_period(), 0, finish_serial_write);
1311         timer_set(amiga_get_serial_char_period(), 0, finish_serial_write);
13121312         break;
13131313
13141314      case REG_BLTSIZE:
r1293r1294
14021402
14031403         /* if 'blitter-nasty' has been turned on and we have a blit pending, reschedule it */
14041404         if ( ( data & 0x400 ) && ( CUSTOM_REG(REG_DMACON) & 0x4000 ) )
1405            mame_timer_adjust( amiga_blitter_timer, MAME_TIME_IN_CYCLES( BLITTER_NASTY_DELAY, 0 ), 0, time_zero);
1405            timer_adjust( amiga_blitter_timer, ATTOTIME_IN_CYCLES( BLITTER_NASTY_DELAY, 0 ), 0, attotime_zero);
14061406
14071407         break;
14081408
r1293r1294
14131413         CUSTOM_REG(offset) = data;
14141414
14151415         if ( temp & 0x8000  ) /* if we're enabling irq's, delay a bit */
1416            mame_timer_adjust( amiga_irq_timer, MAME_TIME_IN_CYCLES( AMIGA_IRQ_DELAY_CYCLES, 0 ), 0, time_zero);
1416            timer_adjust( amiga_irq_timer, ATTOTIME_IN_CYCLES( AMIGA_IRQ_DELAY_CYCLES, 0 ), 0, attotime_zero);
14171417         else /* if we're disabling irq's, process right away */
14181418            update_irqs();
14191419         break;
r1293r1294
14301430         CUSTOM_REG(offset) = data;
14311431
14321432         if ( temp & 0x8000  ) /* if we're generating irq's, delay a bit */
1433            mame_timer_adjust( amiga_irq_timer, MAME_TIME_IN_CYCLES( AMIGA_IRQ_DELAY_CYCLES, 0 ), 0, time_zero);
1433            timer_adjust( amiga_irq_timer, ATTOTIME_IN_CYCLES( AMIGA_IRQ_DELAY_CYCLES, 0 ), 0, attotime_zero);
14341434         else /* if we're clearing irq's, process right away */
14351435            update_irqs();
14361436         break;
r1293r1294
15131513}
15141514
15151515
1516mame_time amiga_get_serial_char_period(void)
1516attotime amiga_get_serial_char_period(void)
15171517{
15181518   UINT32 divisor = (CUSTOM_REG(REG_SERPER) & 0x7fff) + 1;
15191519   UINT32 baud = Machine->drv->cpu[0].clock / 2 / divisor;
15201520   UINT32 numbits = 2 + ((CUSTOM_REG(REG_SERPER) & 0x8000) ? 9 : 8);
1521   return scale_up_mame_time(MAME_TIME_IN_HZ(baud), numbits);
1521   return attotime_mul(ATTOTIME_IN_HZ(baud), numbits);
15221522}
15231523
15241524
src/mame/machine/vertigo.c
r1293r1294
3030/* Timestamp of last INTL4 change. The vector CPU runs for
3131   the delta between this and now.
3232*/
33static mame_time irq4_time;
33static attotime irq4_time;
3434
3535/* State of the priority encoder output */
3636static UINT8 irq_state;
r1293r1294
9393static void v_irq4_w(int level)
9494{
9595   update_irq_encoder(INPUT_LINE_IRQ4, level);
96   vertigo_vproc(MAME_TIME_TO_CYCLES(0, sub_mame_times(mame_timer_get_time(), irq4_time)), level);
97   irq4_time = mame_timer_get_time();
96   vertigo_vproc(ATTOTIME_TO_CYCLES(0, attotime_sub(timer_get_time(), irq4_time)), level);
97   irq4_time = timer_get_time();
9898}
9999
100100static void v_irq3_w(int level)
r1293r1294
168168       quickly. Otherwise the main CPU gives up with sound. Boosting
169169       the interleave for a while helps. */
170170
171   cpu_boost_interleave(time_zero, MAME_TIME_IN_USEC(100));
171   cpu_boost_interleave(attotime_zero, ATTOTIME_IN_USEC(100));
172172}
173173
174174WRITE16_HANDLER( vertigo_audio_w )
r1293r1294
205205   pit8253_init(1, &pit8254_config);
206206   vertigo_vproc_init();
207207
208   irq4_time = mame_timer_get_time();
208   irq4_time = timer_get_time();
209209   irq_state = 7;
210210
211211   state_save_register_global(irq_state);
212212   state_save_register_global(adc_result);
213213   state_save_register_global(irq4_time.seconds);
214   state_save_register_global(irq4_time.subseconds);
214   state_save_register_global(irq4_time.attoseconds);
215215}
216216
217217
src/mame/machine/pcshare.c
r1293r1294
5555#define VERBOSE_DBG 0       /* general debug messages */
5656#if VERBOSE_DBG
5757#define DBG_LOG(N,M,A) \
58   if(VERBOSE_DBG>=N){ if( M )logerror("%11.6f: %-24s",mame_time_to_double(mame_timer_get_time()),(char*)M ); logerror A; }
58   if(VERBOSE_DBG>=N){ if( M )logerror("%11.6f: %-24s",attotime_to_double(timer_get_time()),(char*)M ); logerror A; }
5959#else
6060#define DBG_LOG(n,m,a)
6161#endif
r1293r1294
6565#if VERBOSE_JOY
6666#define LOG(LEVEL,N,M,A)  \
6767#define JOY_LOG(N,M,A) \
68   if(VERBOSE_JOY>=N){ if( M )logerror("%11.6f: %-24s",mame_time_to_double(mame_timer_get_time()),(char*)M ); logerror A; }
68   if(VERBOSE_JOY>=N){ if( M )logerror("%11.6f: %-24s",attotime_to_double(timer_get_time()),(char*)M ); logerror A; }
6969#else
7070#define JOY_LOG(n,m,a)
7171#endif
r1293r1294
7373#define FDC_DMA 2
7474
7575
76static mame_timer *pc_keyboard_timer;
76static emu_timer *pc_keyboard_timer;
7777
7878static TIMER_CALLBACK( pc_keyb_timer );
7979
r1293r1294
503503      pc_page_offset_mask = 0x0F0000;
504504   }
505505
506   pc_keyboard_timer = mame_timer_alloc(pc_keyb_timer);
506   pc_keyboard_timer = timer_alloc(pc_keyb_timer);
507507}
508508
509509/*
r1293r1294
534534
535535void pc_keyb_set_clock(int on)
536536{
537   mame_time keyb_delay = { 0, MAX_SUBSECONDS/200 };   // 5ms
537   attotime keyb_delay = STATIC_ATTOTIME_IN_MSEC(5);
538538
539539   on = on ? 1 : 0;
540540
541541   if (pc_keyb.on != on)
542542   {
543543      if (on)
544         mame_timer_adjust(pc_keyboard_timer, keyb_delay, 0, time_zero);
544         timer_adjust(pc_keyboard_timer, keyb_delay, 0, attotime_zero);
545545      else
546         mame_timer_reset(pc_keyboard_timer, time_never);
546         timer_reset(pc_keyboard_timer, attotime_never);
547547
548548      pc_keyb.on = on;
549549   }
src/mame/machine/atarigen.c
r1293r1294
1818    CONSTANTS
1919##########################################################################*/
2020
21#define SOUND_TIMER_RATE         MAME_TIME_IN_USEC(5)
22#define SOUND_TIMER_BOOST         MAME_TIME_IN_USEC(100)
21#define SOUND_TIMER_RATE         ATTOTIME_IN_USEC(5)
22#define SOUND_TIMER_BOOST         ATTOTIME_IN_USEC(100)
2323
2424
2525
r1293r1294
6565##########################################################################*/
6666
6767static atarigen_int_callback update_int_callback;
68static mame_timer * scanline_interrupt_timer;
68static emu_timer * scanline_interrupt_timer;
6969
7070static UINT8          eeprom_unlocked;
7171
r1293r1294
9090static UINT32         playfield_latch;
9191static UINT32         playfield2_latch;
9292
93static mame_timer *      scanline_timer[ATARIMO_MAX];
94static mame_timer *      atarivc_eof_update_timer[ATARIMO_MAX];
93static emu_timer *      scanline_timer[ATARIMO_MAX];
94static emu_timer *      atarivc_eof_update_timer[ATARIMO_MAX];
9595
9696
9797
r1293r1294
143143
144144   /* create timers */
145145   for (i = 0; i < ATARIMO_MAX; i++)
146      scanline_timer[i] = mame_timer_alloc(scanline_timer_callback);
146      scanline_timer[i] = timer_alloc(scanline_timer_callback);
147147
148148   /* create a timer for scanlines */
149   scanline_interrupt_timer = mame_timer_alloc(scanline_interrupt_callback);
149   scanline_interrupt_timer = timer_alloc(scanline_interrupt_callback);
150150}
151151
152152
r1293r1294
170170
171171void atarigen_scanline_int_set(int scrnum, int scanline)
172172{
173   mame_timer_adjust(scanline_interrupt_timer, video_screen_get_time_until_pos(scrnum, scanline, 0), scrnum, time_zero);
173   timer_adjust(scanline_interrupt_timer, video_screen_get_time_until_pos(scrnum, scanline, 0), scrnum, attotime_zero);
174174}
175175
176176
r1293r1294
274274   atarigen_scanline_int_gen();
275275
276276   /* set a new timer to go off at the same scan line next frame */
277   mame_timer_adjust(scanline_interrupt_timer, video_screen_get_frame_period(param), param, time_zero);
277   timer_adjust(scanline_interrupt_timer, video_screen_get_frame_period(param), param, attotime_zero);
278278}
279279
280280
r1293r1294
839839
840840   /* set a timer to go off at scanline 0 */
841841   if (scanline_callback != NULL)
842      mame_timer_adjust(scanline_timer[scrnum], video_screen_get_time_until_pos(scrnum, 0, 0), (scrnum << 16) | 0, time_zero);
842      timer_adjust(scanline_timer[scrnum], video_screen_get_time_until_pos(scrnum, 0, 0), (scrnum << 16) | 0, attotime_zero);
843843}
844844
845845
r1293r1294
862862      scanline += scanlines_per_callback;
863863      if (scanline >= machine->screen[scrnum].height)
864864         scanline = 0;
865      mame_timer_adjust(scanline_timer[scrnum], video_screen_get_time_until_pos(scrnum, scanline, 0), (scrnum << 16) | scanline, time_zero);
865      timer_adjust(scanline_timer[scrnum], video_screen_get_time_until_pos(scrnum, scanline, 0), (scrnum << 16) | scanline, attotime_zero);
866866   }
867867}
868868
r1293r1294
899899      tilemap_set_scrollx(atarigen_playfield2_tilemap, 0, atarivc_state.pf1_xscroll);
900900      tilemap_set_scrolly(atarigen_playfield2_tilemap, 0, atarivc_state.pf1_yscroll);
901901   }
902   mame_timer_adjust(atarivc_eof_update_timer[scrnum], video_screen_get_time_until_pos(scrnum, 0, 0), scrnum, time_zero);
902   timer_adjust(atarivc_eof_update_timer[scrnum], video_screen_get_time_until_pos(scrnum, 0, 0), scrnum, attotime_zero);
903903
904904   /* use this for debugging the video controller values */
905905#if 0
r1293r1294
936936   atarivc_state.latch1 = atarivc_state.latch2 = -1;
937937   actual_vc_latch0 = actual_vc_latch1 = -1;
938938
939   atarivc_eof_update_timer[scrnum] = mame_timer_alloc(atarivc_eof_update);
939   atarivc_eof_update_timer[scrnum] = timer_alloc(atarivc_eof_update);
940940
941941   /* start a timer to go off a little before scanline 0 */
942942   if (atarivc_eof_data)
943      mame_timer_adjust(atarivc_eof_update_timer[scrnum], video_screen_get_time_until_pos(scrnum, 0, 0), scrnum, time_zero);
943      timer_adjust(atarivc_eof_update_timer[scrnum], video_screen_get_time_until_pos(scrnum, 0, 0), scrnum, attotime_zero);
944944}
945945
946946
r1293r1294
12971297
12981298   /* halt and set a timer to wake up */
12991299   fraction = (double)(hblank - hpos) / (double)Machine->screen[0].width;
1300   mame_timer_set(double_to_mame_time(mame_time_to_double(video_screen_get_scan_period(0)) * fraction), 0, unhalt_cpu);
1300   timer_set(double_to_attotime(attotime_to_double(video_screen_get_scan_period(0)) * fraction), 0, unhalt_cpu);
13011301   cpunum_set_input_line(0, INPUT_LINE_HALT, ASSERT_LINE);
13021302}
13031303
src/mame/machine/namcos2.c
r1293r1294
665665   if( IsSystem21()==0 && namcos2_68k_master_C148[NAMCOS2_C148_POSIRQ] )
666666   {
667667      int scanline = GetPosIRQScanline();
668      mame_timer_set(video_screen_get_time_until_pos(0, scanline, 0), scanline, namcos2_68k_master_posirq );
668      timer_set(video_screen_get_time_until_pos(0, scanline, 0), scanline, namcos2_68k_master_posirq );
669669   }
670670   cpunum_set_input_line( CPU_MASTER, namcos2_68k_master_C148[NAMCOS2_C148_VBLANKIRQ], HOLD_LINE);
671671}
r1293r1294
681681   if( IsSystem21()==0 && namcos2_68k_slave_C148[NAMCOS2_C148_POSIRQ] )
682682   {
683683      int scanline = GetPosIRQScanline();
684      mame_timer_set(video_screen_get_time_until_pos(0, scanline, 0), scanline, namcos2_68k_slave_posirq );
684      timer_set(video_screen_get_time_until_pos(0, scanline, 0), scanline, namcos2_68k_slave_posirq );
685685   }
686686   cpunum_set_input_line( CPU_SLAVE, namcos2_68k_slave_C148[NAMCOS2_C148_VBLANKIRQ], HOLD_LINE);
687687}
r1293r1294
699699   if( namcos2_68k_gpu_C148[NAMCOS2_C148_POSIRQ] )
700700   {
701701      int scanline = 0x50+0x89; /* HACK for Winning Run */
702      mame_timer_set(video_screen_get_time_until_pos(0, scanline, 0), scanline, namcos2_68k_gpu_posirq );
702      timer_set(video_screen_get_time_until_pos(0, scanline, 0), scanline, namcos2_68k_gpu_posirq );
703703   }
704704   cpunum_set_input_line( CPU_GPU, namcos2_68k_gpu_C148[NAMCOS2_C148_VBLANKIRQ], HOLD_LINE);
705705}
src/mame/machine/namco50.c
r1293r1294
266266   // The input clock to the 06XX interface chip is 64H, that is
267267   // 18432000/6/64 = 48kHz, so it makes sense for the irq line to be
268268   // asserted for one clock cycle ~= 21us.
269   mame_timer_set(MAME_TIME_IN_USEC(21), cpunum, namco_50xx_irq_clear);
269   timer_set(ATTOTIME_IN_USEC(21), cpunum, namco_50xx_irq_clear);
270270}
271271
272272void namco_50xx_write(UINT8 data)
src/mame/machine/gaelco2.c
r1293r1294
1616
1717***************************************************************************/
1818
19void gaelco2_ROM16_split(int src_reg, int dst_reg, int start, int length, int dest1, int dest2)
19static void gaelco2_ROM16_split(int src_reg, int dst_reg, int start, int length, int dest1, int dest2)
2020{
2121   int i;
2222
src/mame/machine/tx1.c
r1293r1294
3636/* Main portion of the arithmetic unit emulation. Accessed by AU_R and AU_W */
3737/* Only a few instructions implemented currently */
3838
39void MMI_74S516(int ins, UINT16 *data)
39static void MMI_74S516(int ins, UINT16 *data)
4040{
4141
4242   if ((ins!=7) && ((AU_Regs.ins_seq & 0xf)==7))   /* If last instruction was a reading operation, clear sequence. */
src/mame/machine/mcr.c
r1293r1294
2525 *
2626 *************************************/
2727
28mame_time mcr68_timing_factor;
28attotime mcr68_timing_factor;
2929
3030UINT8 mcr_cocktail_flip;
3131
r1293r1294
5050   UINT8         control;
5151   UINT16         latch;
5252   UINT16         count;
53   mame_timer *   timer;
53   emu_timer *   timer;
5454   UINT8         timer_active;
55   mame_time      period;
55   attotime      period;
5656} m6840_state[3];
5757
5858/* MCR/68k interrupt states */
r1293r1294
6565
6666static UINT8 zwackery_sound_data;
6767
68static mame_time m6840_counter_periods[3];
69static mame_time m6840_internal_counter_period;   /* 68000 CLK / 10 */
68static attotime m6840_counter_periods[3];
69static attotime m6840_internal_counter_period;   /* 68000 CLK / 10 */
7070
71static mame_timer *ipu_watchdog_timer;
71static emu_timer *ipu_watchdog_timer;
7272
7373
7474
r1293r1294
290290   z80sio_init(0, &nflfoot_sio_intf);
291291
292292   /* allocate a timer for the IPU watchdog */
293   ipu_watchdog_timer = mame_timer_alloc(ipu_watchdog_reset);
293   ipu_watchdog_timer = timer_alloc(ipu_watchdog_reset);
294294}
295295
296296
r1293r1294
319319   {
320320      struct counter_state *m6840 = &m6840_state[i];
321321
322      m6840->timer = mame_timer_alloc(counter_fired_callback);
322      m6840->timer = timer_alloc(counter_fired_callback);
323323
324324      state_save_register_item("m6840", i, m6840->control);
325325      state_save_register_item("m6840", i, m6840->latch);
r1293r1294
344344   int i;
345345
346346   /* reset the 6840's */
347   m6840_counter_periods[0] = MAME_TIME_IN_HZ(30);         /* clocked by /VBLANK */
348   m6840_counter_periods[1] = time_never;               /* grounded */
349   m6840_counter_periods[2] = MAME_TIME_IN_HZ(512 * 30);   /* clocked by /HSYNC */
347   m6840_counter_periods[0] = ATTOTIME_IN_HZ(30);         /* clocked by /VBLANK */
348   m6840_counter_periods[1] = attotime_never;               /* grounded */
349   m6840_counter_periods[2] = ATTOTIME_IN_HZ(512 * 30);   /* clocked by /HSYNC */
350350
351351   m6840_status = 0x00;
352352   m6840_status_read_since_int = 0x00;
r1293r1294
358358      m6840->control = 0x00;
359359      m6840->latch = 0xffff;
360360      m6840->count = 0xffff;
361      mame_timer_enable(m6840->timer, FALSE);
361      timer_enable(m6840->timer, FALSE);
362362      m6840->timer_active = 0;
363363      m6840->period = m6840_counter_periods[i];
364364   }
365365
366366   /* initialize the clock */
367   m6840_internal_counter_period = MAME_TIME_IN_HZ(Machine->drv->cpu[0].clock / 10);
367   m6840_internal_counter_period = ATTOTIME_IN_HZ(Machine->drv->cpu[0].clock / 10);
368368
369369   /* reset cocktail flip */
370370   mcr_cocktail_flip = 0;
r1293r1294
459459   /* also set a timer to generate the 493 signal at a specific time before the next VBLANK */
460460   /* the timing of this is crucial for Blasted and Tri-Sports, which check the timing of */
461461   /* VBLANK and 493 using counter 2 */
462   mame_timer_set(sub_mame_times(MAME_TIME_IN_HZ(30), mcr68_timing_factor), 0, v493_callback);
462   timer_set(attotime_sub(ATTOTIME_IN_HZ(30), mcr68_timing_factor), 0, v493_callback);
463463}
464464
465465
r1293r1294
499499{
500500   v493_irq_state = 1;
501501   update_mcr68_interrupts();
502   mame_timer_set(video_screen_get_scan_period(0), 0, mcr68_493_off_callback);
502   timer_set(video_screen_get_scan_period(0), 0, mcr68_493_off_callback);
503503   logerror("--- (INT1) ---\n");
504504}
505505
r1293r1294
620620static TIMER_CALLBACK( zwackery_493_callback )
621621{
622622   pia_2_ca1_w(0, 1);
623   mame_timer_set(video_screen_get_scan_period(0), 0, zwackery_493_off_callback);
623   timer_set(video_screen_get_scan_period(0), 0, zwackery_493_off_callback);
624624}
625625
626626
r1293r1294
719719
720720static void reload_count(int counter)
721721{
722   mame_time period;
723   mame_time total_period;
722   attotime period;
723   attotime total_period;
724724   int count;
725725
726726   /* copy the latched value in */
r1293r1294
729729   /* counter 0 is self-updating if clocked externally */
730730   if (counter == 0 && !(m6840_state[counter].control & 0x02))
731731   {
732      mame_timer_adjust(m6840_state[counter].timer, time_never, 0, time_zero);
732      timer_adjust(m6840_state[counter].timer, attotime_never, 0, attotime_zero);
733733      m6840_state[counter].timer_active = 0;
734734      return;
735735   }
r1293r1294
748748      count = count + 1;
749749
750750   /* set the timer */
751   total_period = make_mame_time(0, mame_time_to_subseconds(period) * count);
752LOG(("reload_count(%d): period = %f  count = %d\n", counter, mame_time_to_double(period), count));
753   mame_timer_adjust(m6840_state[counter].timer, total_period, (count << 2) + counter, time_zero);
751   total_period = attotime_make(0, attotime_to_attoseconds(period) * count);
752LOG(("reload_count(%d): period = %f  count = %d\n", counter, attotime_to_double(period), count));
753   timer_adjust(m6840_state[counter].timer, total_period, (count << 2) + counter, attotime_zero);
754754   m6840_state[counter].timer_active = 1;
755755}
756756
757757
758758static UINT16 compute_counter(int counter)
759759{
760   mame_time period;
760   attotime period;
761761   int remaining;
762762
763763   /* if there's no timer, return the count */
r1293r1294
771771      period = m6840_counter_periods[counter];
772772
773773   /* see how many are left */
774   remaining = mame_time_to_subseconds(mame_timer_timeleft(m6840_state[counter].timer)) / mame_time_to_subseconds(period);
774   remaining = attotime_to_attoseconds(timer_timeleft(m6840_state[counter].timer)) / attotime_to_attoseconds(period);
775775
776776   /* adjust the count for dual byte mode */
777777   if (m6840_state[counter].control & 0x04)
r1293r1294
813813         {
814814            for (i = 0; i < 3; i++)
815815            {
816               mame_timer_adjust(m6840_state[i].timer, time_never, 0, time_zero);
816               timer_adjust(m6840_state[i].timer, attotime_never, 0, attotime_zero);
817817               m6840_state[i].timer_active = 0;
818818            }
819819         }
r1293r1294
10151015{
10161016   /* watchdog counter is clocked by 7.3728MHz crystal / 16 */
10171017   /* watchdog is tripped when 14-bit counter overflows => / 32768 = 14.0625Hz*/
1018   mame_timer_adjust(ipu_watchdog_timer, MAME_TIME_IN_HZ(7372800 / 16 / 32768), 0, time_zero);
1018   timer_adjust(ipu_watchdog_timer, ATTOTIME_IN_HZ(7372800 / 16 / 32768), 0, attotime_zero);
10191019   return 0xff;
10201020}
10211021
src/mame/machine/s24fd.c
r1293r1294
2626   if it is then it copies the cached data to the user region where code is
2727   executed from, if its not cached then it gets decrypted to the current
2828   cache position using the functions in s24_fd1094.c */
29void s24_fd1094_setstate_and_decrypt(int state)
29static void s24_fd1094_setstate_and_decrypt(int state)
3030{
3131   int i;
3232   UINT32 addr;
r1293r1294
7777}
7878
7979/* Callback for CMP.L instructions (state change) */
80void s24_fd1094_cmp_callback(UINT32 val, int reg)
80static void s24_fd1094_cmp_callback(UINT32 val, int reg)
8181{
8282   if (reg == 0 && (val & 0x0000ffff) == 0x0000ffff) // ?
8383   {
r1293r1294
8686}
8787
8888/* Callback when the s24_fd1094 enters interrupt code */
89int s24_fd1094_int_callback (int irq)
89static int s24_fd1094_int_callback (int irq)
9090{
9191   s24_fd1094_setstate_and_decrypt(FD1094_STATE_IRQ);
9292   return (0x60+irq*4)/4; // vector address
9393}
9494
95void s24_fd1094_rte_callback (void)
95static void s24_fd1094_rte_callback (void)
9696{
9797   s24_fd1094_setstate_and_decrypt(FD1094_STATE_RTE);
9898}
9999
100100
101101/* KLUDGE, set the initial PC / SP based on table as we can't decrypt them yet */
102void s24_fd1094_kludge_reset_values(void)
102static void s24_fd1094_kludge_reset_values(void)
103103{
104104   int i;
105105
src/mame/machine/arkanoid.c
r1293r1294
1616
1717
1818UINT8 arkanoid_paddle_select;
19UINT8 arkanoid_paddle_value;
19static UINT8 arkanoid_paddle_value;
2020
2121static UINT8 z80write,fromz80,m68705write,toz80;
2222
r1293r1294
6262{
6363   timer_call_after_resynch(data, test);
6464   /* boost the interleave for a few usecs to make sure it is read successfully */
65   cpu_boost_interleave(time_zero, MAME_TIME_IN_USEC(10));
65   cpu_boost_interleave(attotime_zero, ATTOTIME_IN_USEC(10));
6666}
6767
6868READ8_HANDLER( arkanoid_68705_portA_r )
src/mame/machine/konamiic.c
r1293r1294
66static UINT8 K056800_host_reg[8];
77static UINT8 K056800_sound_reg[8];
88
9static mame_timer *K056800_sound_cpu_timer;
9static emu_timer *K056800_sound_cpu_timer;
1010static int K056800_sound_cpu_irq1_enable;
1111static void (*K056800_sound_irq_callback)(int);
1212
r1293r1294
5555
5656void K056800_init(void (* irq_callback)(int))
5757{
58   mame_time timer_period;
58   attotime timer_period;
5959   K056800_sound_irq_callback = irq_callback;
6060
6161   memset(K056800_host_reg, 0, sizeof(K056800_host_reg));
6262   memset(K056800_sound_reg, 0, sizeof(K056800_sound_reg));
6363
64   timer_period = scale_up_mame_time(MAME_TIME_IN_HZ(44100), 128);   // roughly 2.9us
64   timer_period = attotime_mul(ATTOTIME_IN_HZ(44100), 128);   // roughly 2.9us
6565
66   K056800_sound_cpu_timer = mame_timer_alloc(K056800_sound_cpu_timer_tick);
67   mame_timer_adjust(K056800_sound_cpu_timer, timer_period, 0, timer_period);
66   K056800_sound_cpu_timer = timer_alloc(K056800_sound_cpu_timer_tick);
67   timer_adjust(K056800_sound_cpu_timer, timer_period, 0, timer_period);
6868}
6969
7070READ32_HANDLER(K056800_host_r)
src/mame/machine/slikshot.c
r1293r1294
417417   inters_to_words(inter1, inter2, inter3, &beams, &word1, &word2, &word3);
418418   words_to_sensors(word1, word2, word3, beams, &sensor0, &sensor1, &sensor2, &sensor3);
419419
420   logerror("%15f: Sensor values: %04x %04x %04x %04x\n", mame_time_to_double(mame_timer_get_time()), sensor0, sensor1, sensor2, sensor3);
420   logerror("%15f: Sensor values: %04x %04x %04x %04x\n", attotime_to_double(timer_get_time()), sensor0, sensor1, sensor2, sensor3);
421421}
422422
423423
r1293r1294
518518   }
519519
520520   /* boost the interleave whenever this is written to */
521   cpu_boost_interleave(time_zero, MAME_TIME_IN_USEC(100));
521   cpu_boost_interleave(attotime_zero, ATTOTIME_IN_USEC(100));
522522
523523   /* stash the new value */
524524   z80_ctrl = data;
src/mame/machine/harddriv.c
r1293r1294
104104static UINT8 duart_read_data[16];
105105static UINT8 duart_write_data[16];
106106static UINT8 duart_output_port;
107static mame_timer *duart_timer;
107static emu_timer *duart_timer;
108108
109109static UINT8 last_gsp_shiftreg;
110110
r1293r1294
200200   memset(duart_read_data, 0, sizeof(duart_read_data));
201201   memset(duart_write_data, 0, sizeof(duart_write_data));
202202   duart_output_port = 0;
203   duart_timer = mame_timer_alloc(duart_callback);
203   duart_timer = timer_alloc(duart_callback);
204204
205205   /* reset the ADSP/DSIII/DSIV boards */
206206   adsp_halt = 1;
r1293r1294
612612}
613613
614614
615INLINE mame_time duart_clock_period(void)
615INLINE attotime duart_clock_period(void)
616616{
617   return MAME_TIME_IN_HZ(duart_clock());
617   return ATTOTIME_IN_HZ(duart_clock());
618618}
619619
620620
r1293r1294
628628      duart_irq_state = (duart_read_data[0x05] & duart_write_data[0x05]) != 0;
629629      atarigen_update_interrupts();
630630   }
631   mame_timer_adjust(duart_timer, scale_up_mame_time(duart_clock_period(), 65536), 0, time_zero);
631   timer_adjust(duart_timer, attotime_mul(duart_clock_period(), 65536), 0, attotime_zero);
632632}
633633
634634
r1293r1294
655655      case 0x0e:      /* Start-Counter Command 3 */
656656      {
657657         int reps = (duart_write_data[0x06] << 8) | duart_write_data[0x07];
658         mame_timer_adjust(duart_timer, scale_up_mame_time(duart_clock_period(), reps), 0, time_zero);
659         logerror("DUART timer started (period=%f)\n", mame_time_to_double(scale_up_mame_time(duart_clock_period(), reps)));
658         timer_adjust(duart_timer, attotime_mul(duart_clock_period(), reps), 0, attotime_zero);
659         logerror("DUART timer started (period=%f)\n", attotime_to_double(attotime_mul(duart_clock_period(), reps)));
660660         return 0x00ff;
661661      }
662662      case 0x0f:      /* Stop-Counter Command 3 */
663663         {
664            int reps = mame_time_to_double(scale_up_mame_time(mame_timer_timeleft(duart_timer), duart_clock()));
665            mame_timer_adjust(duart_timer, time_never, 0, time_zero);
664            int reps = attotime_to_double(attotime_mul(timer_timeleft(duart_timer), duart_clock()));
665            timer_adjust(duart_timer, attotime_never, 0, attotime_zero);
666666            duart_read_data[0x06] = reps >> 8;
667667            duart_read_data[0x07] = reps & 0xff;
668668            logerror("DUART timer stopped (final count=%04X)\n", reps);
r1293r1294
12511251   /* it is important that all the CPUs be in sync before we continue, so spin a little */
12521252   /* while to let everyone else catch up */
12531253   cpu_spinuntil_trigger(DS3_TRIGGER);
1254   cpu_triggertime(MAME_TIME_IN_USEC(5), DS3_TRIGGER);
1254   cpu_triggertime(ATTOTIME_IN_USEC(5), DS3_TRIGGER);
12551255
12561256   return ds3_gdata;
12571257}
src/mame/machine/psx.c
r1293r1294
132132static UINT32 m_p_n_dmabase[ 7 ];
133133static UINT32 m_p_n_dmablockcontrol[ 7 ];
134134static UINT32 m_p_n_dmachannelcontrol[ 7 ];
135static mame_timer *m_p_timer_dma[ 7 ];
135static emu_timer *m_p_timer_dma[ 7 ];
136136static psx_dma_read_handler m_p_fn_dma_read[ 7 ];
137137static psx_dma_write_handler m_p_fn_dma_write[ 7 ];
138138static UINT32 m_p_n_dma_ticks[ 7 ];
r1293r1294
142142
143143static void dma_start_timer( int n_channel, UINT32 n_ticks )
144144{
145   mame_timer_adjust( m_p_timer_dma[ n_channel ], scale_up_mame_time(MAME_TIME_IN_HZ(33868800), n_ticks), n_channel, time_zero);
145   timer_adjust( m_p_timer_dma[ n_channel ], attotime_mul(ATTOTIME_IN_HZ(33868800), n_ticks), n_channel, attotime_zero);
146146   m_p_n_dma_ticks[ n_channel ] = n_ticks;
147147   m_p_b_dma_running[ n_channel ] = 1;
148148}
149149
150150static void dma_stop_timer( int n_channel )
151151{
152   mame_timer_adjust( m_p_timer_dma[ n_channel ], time_never, 0, time_never);
152   timer_adjust( m_p_timer_dma[ n_channel ], attotime_never, 0, attotime_never);
153153   m_p_b_dma_running[ n_channel ] = 0;
154154}
155155
r1293r1294
467467
468468/* Root Counters */
469469
470static mame_timer *m_p_timer_root[ 3 ];
470static emu_timer *m_p_timer_root[ 3 ];
471471static UINT16 m_p_n_root_count[ 3 ];
472472static UINT16 m_p_n_root_mode[ 3 ];
473473static UINT16 m_p_n_root_target[ 3 ];
r1293r1294
542542{
543543   if( ( m_p_n_root_mode[ n_counter ] & RC_STOP ) != 0 )
544544   {
545      mame_timer_adjust( m_p_timer_root[ n_counter ], time_never, n_counter, time_never);
545      timer_adjust( m_p_timer_root[ n_counter ], attotime_never, n_counter, attotime_never);
546546   }
547547   else
548548   {
r1293r1294
556556
557557      n_duration *= root_divider( n_counter );
558558
559      mame_timer_adjust( m_p_timer_root[ n_counter ], scale_up_mame_time(MAME_TIME_IN_HZ(33868800), n_duration), n_counter, time_zero);
559      timer_adjust( m_p_timer_root[ n_counter ], attotime_mul(ATTOTIME_IN_HZ(33868800), n_duration), n_counter, attotime_zero);
560560   }
561561}
562562
r1293r1294
668668static UINT32 m_p_n_sio_tx_bits[ 2 ];
669669static UINT32 m_p_n_sio_rx_bits[ 2 ];
670670
671static mame_timer *m_p_timer_sio[ 2 ];
671static emu_timer *m_p_timer_sio[ 2 ];
672672static psx_sio_handler m_p_f_sio_handler[ 2 ];
673673
674674#define SIO_STATUS_TX_RDY ( 1 << 0 )
r1293r1294
702702
703703static void sio_timer_adjust( int n_port )
704704{
705   mame_time n_time;
705   attotime n_time;
706706   if( ( m_p_n_sio_status[ n_port ] & SIO_STATUS_TX_EMPTY ) == 0 || m_p_n_sio_tx_bits[ n_port ] != 0 )
707707   {
708708      int n_prescaler;
r1293r1294
725725
726726      if( m_p_n_sio_baud[ n_port ] != 0 && n_prescaler != 0 )
727727      {
728         n_time = scale_up_mame_time(MAME_TIME_IN_HZ(33868800), n_prescaler * m_p_n_sio_baud[n_port]);
728         n_time = attotime_mul(ATTOTIME_IN_HZ(33868800), n_prescaler * m_p_n_sio_baud[n_port]);
729729         verboselog( 2, "sio_timer_adjust( %d ) = %f ( %d x %d )\n", n_port, n_time, n_prescaler, m_p_n_sio_baud[ n_port ] );
730730      }
731731      else
732732      {
733         n_time = time_never;
733         n_time = attotime_never;
734734         verboselog( 0, "sio_timer_adjust( %d ) invalid baud rate ( %d x %d )\n", n_port, n_prescaler, m_p_n_sio_baud[ n_port ] );
735735      }
736736   }
737737   else
738738   {
739      n_time = time_never;
739      n_time = attotime_never;
740740      verboselog( 2, "sio_timer_adjust( %d ) finished\n", n_port );
741741   }
742   mame_timer_adjust( m_p_timer_sio[ n_port ], n_time, n_port, time_zero);
742   timer_adjust( m_p_timer_sio[ n_port ], n_time, n_port, attotime_zero);
743743}
744744
745745static TIMER_CALLBACK( sio_clock )
r1293r1294
15631563
15641564   for( n = 0; n < 7; n++ )
15651565   {
1566      m_p_timer_dma[ n ] = mame_timer_alloc( dma_finished_callback );
1566      m_p_timer_dma[ n ] = timer_alloc( dma_finished_callback );
15671567      m_p_fn_dma_read[ n ] = NULL;
15681568      m_p_fn_dma_write[ n ] = NULL;
15691569   }
15701570
15711571   for( n = 0; n < 3; n++ )
15721572   {
1573      m_p_timer_root[ n ] = mame_timer_alloc( root_finished );
1573      m_p_timer_root[ n ] = timer_alloc( root_finished );
15741574   }
15751575
15761576   for( n = 0; n < 2; n++ )
15771577   {
1578      m_p_timer_sio[ n ] = mame_timer_alloc( sio_clock );
1578      m_p_timer_sio[ n ] = timer_alloc( sio_clock );
15791579   }
15801580
15811581   for( n = 0; n < 256; n++ )
src/mame/machine/dec0.c
r1293r1294
458458}
459459
460460#if 0
461static mame_timer *i8751_timer;
461static emu_timer *i8751_timer;
462462
463463static TIMER_CALLBACK( i8751_callback )
464464{
src/mame/machine/kaneko16.c
r1293r1294
26926900207FE0 : may serves for relocating code (written as .l)
270270*/
271271
272void calc3_mcu_run(void);
272static void calc3_mcu_run(void);
273273
274274static int calc3_mcu_status, calc3_mcu_command_offset;
275275
src/mame/machine/williams.c
r1293r1294
1616
1717
1818/* timers */
19static mame_timer *scanline_timer;
20static mame_timer *scan240_timer;
21static mame_timer *scan254_timer;
19static emu_timer *scanline_timer;
20static emu_timer *scan240_timer;
21static emu_timer *scan254_timer;
2222
2323/* banking addresses set by the drivers */
2424UINT8 *mayday_protection;
r1293r1294
257257   /* set a timer for the next update */
258258   scanline++;
259259   if (scanline >= 256) scanline = 0;
260   mame_timer_adjust(scanline_timer, video_screen_get_time_until_pos(0, scanline, 0), scanline, time_zero);
260   timer_adjust(scanline_timer, video_screen_get_time_until_pos(0, scanline, 0), scanline, attotime_zero);
261261}
262262
263263
r1293r1294
274274   pia_1_ca1_w(0, 1);
275275
276276   /* set a timer to turn it off once the scanline counter resets */
277   mame_timer_set(video_screen_get_time_until_pos(0, 0, 0), 0, williams_count240_off_callback);
277   timer_set(video_screen_get_time_until_pos(0, 0, 0), 0, williams_count240_off_callback);
278278
279279   /* set a timer for next frame */
280   mame_timer_adjust(scan240_timer, video_screen_get_time_until_pos(0, 240, 0), 0, time_zero);
280   timer_adjust(scan240_timer, video_screen_get_time_until_pos(0, 240, 0), 0, attotime_zero);
281281}
282282
283283
r1293r1294
318318   ticket_dispenser_init(70, TICKET_MOTOR_ACTIVE_LOW, TICKET_STATUS_ACTIVE_HIGH);
319319
320320   /* set a timer to go off every 16 scanlines, to toggle the VA11 line and update the screen */
321   scanline_timer = mame_timer_alloc(williams_va11_callback);
322   mame_timer_adjust(scanline_timer, video_screen_get_time_until_pos(0, 0, 0), 0, time_zero);
321   scanline_timer = timer_alloc(williams_va11_callback);
322   timer_adjust(scanline_timer, video_screen_get_time_until_pos(0, 0, 0), 0, attotime_zero);
323323
324324   /* also set a timer to go off on scanline 240 */
325   scan240_timer = mame_timer_alloc(williams_count240_callback);
326   mame_timer_adjust(scan240_timer, video_screen_get_time_until_pos(0, 240, 0), 0, time_zero);
325   scan240_timer = timer_alloc(williams_count240_callback);
326   timer_adjust(scan240_timer, video_screen_get_time_until_pos(0, 240, 0), 0, attotime_zero);
327327
328328   state_save_register_global(vram_bank);
329329}
r1293r1294
360360   /* set a timer for the next update */
361361   scanline++;
362362   if (scanline >= 256) scanline = 0;
363   mame_timer_adjust(scanline_timer, video_screen_get_time_until_pos(0, scanline, 0), scanline, time_zero);
363   timer_adjust(scanline_timer, video_screen_get_time_until_pos(0, scanline, 0), scanline, attotime_zero);
364364}
365365
366366
r1293r1294
377377   pia_0_ca1_w(0, 0);
378378
379379   /* set a timer to turn it off once the scanline counter resets */
380   mame_timer_set(video_screen_get_time_until_pos(0, 8, 0), 0, williams2_endscreen_off_callback);
380   timer_set(video_screen_get_time_until_pos(0, 8, 0), 0, williams2_endscreen_off_callback);
381381
382382   /* set a timer for next frame */
383   mame_timer_adjust(scan254_timer, video_screen_get_time_until_pos(0, 254, 0), 0, time_zero);
383   timer_adjust(scan254_timer, video_screen_get_time_until_pos(0, 254, 0), 0, attotime_zero);
384384}
385385
386386
r1293r1294
410410   williams2_bank_select_w(0, 0);
411411
412412   /* set a timer to go off every 16 scanlines, to toggle the VA11 line and update the screen */
413   scanline_timer = mame_timer_alloc(williams2_va11_callback);
414   mame_timer_adjust(scanline_timer, video_screen_get_time_until_pos(0, 0, 0), 0, time_zero);
413   scanline_timer = timer_alloc(williams2_va11_callback);
414   timer_adjust(scanline_timer, video_screen_get_time_until_pos(0, 0, 0), 0, attotime_zero);
415415
416416   /* also set a timer to go off on scanline 254 */
417   scan254_timer = mame_timer_alloc(williams2_endscreen_callback);
418   mame_timer_adjust(scan254_timer, video_screen_get_time_until_pos(0, 254, 0), 0, time_zero);
417   scan254_timer = timer_alloc(williams2_endscreen_callback);
418   timer_adjust(scan254_timer, video_screen_get_time_until_pos(0, 254, 0), 0, attotime_zero);
419419
420420   state_save_register_global(vram_bank);
421421   state_save_register_func_postload(williams2_postload);
src/mame/machine/opwolf.c
r1293r1294
694694   {
695695      // Simulate time for command to execute (exact timing unknown, this is close)
696696      current_cmd=0xf5;
697      mame_timer_set(MAME_TIME_IN_CYCLES(80000,0), 0, timer_callback);
697      timer_set(ATTOTIME_IN_CYCLES(80000,0), 0, timer_callback);
698698   }
699699   cchip_last_7a=cchip_ram[0x7a];
700700
r1293r1294
747747   cchip_coins_for_credit[1]=1;
748748   cchip_credits_for_coin[1]=1;
749749
750   mame_timer_pulse(MAME_TIME_IN_HZ(60), 0, cchip_timer);
750   timer_pulse(ATTOTIME_IN_HZ(60), 0, cchip_timer);
751751}
src/mame/machine/nb1413m3.c
r1293r1294
4444#define NB1413M3_TIMER_BASE 20000000
4545static TIMER_CALLBACK( nb1413m3_timer_callback )
4646{
47   mame_timer_set(scale_up_mame_time(MAME_TIME_IN_HZ(NB1413M3_TIMER_BASE), 256), 0, nb1413m3_timer_callback);
47   timer_set(attotime_mul(ATTOTIME_IN_HZ(NB1413M3_TIMER_BASE), 256), 0, nb1413m3_timer_callback);
4848
4949   nb1413m3_74ls193_counter++;
5050   nb1413m3_74ls193_counter &= 0x0f;
src/mame/machine/exctsccr.c
r1293r1294
2121#include "driver.h"
2222
2323#define MCU_HACK 0
24#if MCU_HACK
2425
2526#define MCU_KEY_TABLE_SIZE 16
2627
2728/* These are global */
2829UINT8 *exctsccr_mcu_ram;
2930
30#if MCU_HACK
31
3231WRITE8_HANDLER( exctsccr_mcu_w );
3332WRITE8_HANDLER( exctsccr_mcu_control_w );
3433
src/mame/machine/model1.c
r1293r1294
20812081   if ( ram_adr == 0 && copro_fifoin_num != 0 )
20822082   {
20832083      /* spin the main cpu and let the TGP catch up */
2084      cpu_spinuntil_time(MAME_TIME_IN_USEC(100));
2084      cpu_spinuntil_time(ATTOTIME_IN_USEC(100));
20852085   }
20862086
20872087   return ram_adr;
r1293r1294
21072107      if ( ram_adr == 0 && r == 0xffff )
21082108      {
21092109         /* if the TGP is busy, spin some more */
2110         cpu_spinuntil_time(MAME_TIME_IN_USEC(100));
2110         cpu_spinuntil_time(ATTOTIME_IN_USEC(100));
21112111      }
21122112
21132113      if ( ram_adr & 0x8000 )
src/mame/machine/slapstic.c
r1293r1294
11191119#if LOG_SLAPSTIC
11201120static void slapstic_log(offs_t offset)
11211121{
1122   static mame_time last_time;
1122   static attotime last_time;
11231123
11241124   if (!slapsticlog)
11251125      slapsticlog = fopen("slapstic.log", "w");
11261126   if (slapsticlog)
11271127   {
1128      mame_time time = mame_timer_get_time();
1128      attotime time = timer_get_time();
11291129
1130      if (compare_mame_times(sub_mame_times(time, last_time), MAME_TIME_IN_SEC(1)) > 0)
1130      if (attotime_compare(attotime_sub(time, last_time), ATTOTIME_IN_SEC(1)) > 0)
11311131         fprintf(slapsticlog, "------------------------------------\n");
11321132      last_time = time;
11331133
src/mame/machine/mw8080bw.c
r1293r1294
1515 *
1616 *************************************/
1717
18static mame_timer *interrupt_timer;
18static emu_timer *interrupt_timer;
1919
2020
2121static UINT8 vpos_to_vysnc_chain_counter(int vpos)
r1293r1294
8181   }
8282
8383   next_vpos = vysnc_chain_counter_to_vpos(next_counter, next_vblank);
84   mame_timer_adjust(interrupt_timer, video_screen_get_time_until_pos(0, next_vpos, 0), 0, time_zero);
84   timer_adjust(interrupt_timer, video_screen_get_time_until_pos(0, next_vpos, 0), 0, attotime_zero);
8585}
8686
8787
8888static void mw8080bw_create_interrupt_timer(void)
8989{
90   interrupt_timer = mame_timer_alloc(mw8080bw_interrupt_callback);
90   interrupt_timer = timer_alloc(mw8080bw_interrupt_callback);
9191}
9292
9393
9494static void mw8080bw_start_interrupt_timer(void)
9595{
9696   int vpos = vysnc_chain_counter_to_vpos(MW8080BW_INT_TRIGGER_COUNT_1, MW8080BW_INT_TRIGGER_VBLANK_1);
97   mame_timer_adjust(interrupt_timer, video_screen_get_time_until_pos(0, vpos, 0), 0, time_zero);
97   timer_adjust(interrupt_timer, video_screen_get_time_until_pos(0, vpos, 0), 0, attotime_zero);
9898}
9999
100100
src/mame/mamedriv.c
r1293r1294
67816781   DRIVER( hardhea2 )   /* (c) 1991 SunA */
67826782   DRIVER( brickzn )   /* (c) 1992 SunA */
67836783   DRIVER( brickzn3 )   /* (c) 1992 SunA */
6784   DRIVER( bestbest )   /* (c) 1994 SunA */
67846785   DRIVER( sunaq )      /* (c) 1994 SunA */
67856786   DRIVER( bssoccer )   /* (c) 1996 SunA */
67866787   DRIVER( uballoon )   /* (c) 1996 SunA */
r1293r1294
74097410   /* JMP Impact Games */
74107411   DRIVER( cluedo )   /* (c) 1995 */
74117412   DRIVER( cluedo2c )   /* (c) 1995 */
7413   DRIVER( cluedo2 )   /* (c) 1995 */
74127414   DRIVER( trivialp )   /* (c) 1996 */
74137415   DRIVER( scrabble )   /* (c) 1997 */
74147416   DRIVER( hngmnjpm )   /* (c) 1998 */
src/mame/includes/amiga.h
r1293r1294
388388WRITE16_HANDLER( amiga_custom_w );
389389
390390void amiga_serial_in_w(UINT16 data);
391mame_time amiga_get_serial_char_period(void);
391attotime amiga_get_serial_char_period(void);
392392
393393void amiga_add_autoconfig(amiga_autoconfig_device *device);
394394READ16_HANDLER( amiga_autoconfig_r );
src/mame/includes/midzeus.h
r1293r1294
44
55**************************************************************************/
66
7#define MIDZEUS_VIDEO_CLOCK      66000000
78
9
810/*----------- defined in video/midzeus.c -----------*/
911
1012extern UINT32 *zeusbase;
src/mame/includes/mcr.h
r1293r1294
1818
1919/*----------- defined in machine/mcr.c -----------*/
2020
21extern mame_time mcr68_timing_factor;
21extern attotime mcr68_timing_factor;
2222
2323extern struct z80_irq_daisy_chain mcr_daisy_chain[];
2424extern struct z80_irq_daisy_chain mcr_ipu_daisy_chain[];
src/mame/mame.mak
r1293r1294
107107CPUS += TMS32025
108108CPUS += TMS32026
109109CPUS += TMS32031
110CPUS += TMS32032
110111CPUS += TMS32051
111112CPUS += CCPU
112113CPUS += ADSP2100
r1293r1294
531532   $(DRIVERS)/powerins.o $(VIDEO)/powerins.o \
532533
533534$(MAMEOBJ)/barcrest.a: \
534   $(MACHINE)/mmtr.o \
535   $(MACHINE)/meters.o \
535536   $(DRIVERS)/mpu4.o \
536537   $(MACHINE)/steppers.o \
537538
src/mame/video/nycaptor.c
r1293r1294
1616
1717UINT8 *nycaptor_scrlram;
1818
19UINT8 *nycaptor_spriteram;
19static UINT8 *nycaptor_spriteram;
2020extern UINT8 *nycaptor_sharedram;
2121extern int nyc_gametype;
2222
src/mame/video/omegaf.c
r1293r1294
7575**************************************************************************/
7676
7777UINT8 *omegaf_fg_videoram;
78UINT8 *omegaf_bg0_videoram;
79UINT8 *omegaf_bg1_videoram;
80UINT8 *omegaf_bg2_videoram;
81size_t omegaf_fgvideoram_size;
78static UINT8 *omegaf_bg0_videoram;
79static UINT8 *omegaf_bg1_videoram;
80static UINT8 *omegaf_bg2_videoram;
81//size_t omegaf_fgvideoram_size;
8282
8383static int omegaf_bg0_bank = 0;
8484static int omegaf_bg1_bank = 0;
src/mame/video/midyunit.c
r1293r1294
580580   }
581581
582582   /* signal we're done */
583   mame_timer_set(MAME_TIME_IN_NSEC(41 * dma_state.width * dma_state.height), 0, dma_callback);
583   timer_set(ATTOTIME_IN_NSEC(41 * dma_state.width * dma_state.height), 0, dma_callback);
584584
585585   profiler_mark(PROFILER_END);
586586}
r1293r1294
619619   /* if this is the last update of the screen, set a timer to clear out the final line */
620620   /* (since we update one behind) */
621621   if (scanline == machine->screen[0].visarea.max_y)
622      mame_timer_set(video_screen_get_time_until_pos(0, scanline + 1, 0), params->rowaddr, autoerase_line);
622      timer_set(video_screen_get_time_until_pos(0, scanline + 1, 0), params->rowaddr, autoerase_line);
623623}
src/mame/video/stvvdp1.c
r1293r1294
2121static int vdp1_sprite_log = 0;
2222
2323UINT32 *stv_vdp1_vram;
24UINT32 *stv_vdp1_regs;
24static UINT32 *stv_vdp1_regs;
2525UINT8* stv_vdp1_gfx_decode;
2626
2727extern UINT32 *stv_scu;
2828extern int stv_vblank;
2929
30UINT16    *stv_framebuffer[2];
31UINT16    **stv_framebuffer_draw_lines, **stv_framebuffer_display_lines;
32int       stv_framebuffer_width;
33int       stv_framebuffer_height;
30static UINT16    *stv_framebuffer[2];
31static UINT16    **stv_framebuffer_draw_lines;
32UINT16    **stv_framebuffer_display_lines;
33static int       stv_framebuffer_width;
34static int       stv_framebuffer_height;
3435int       stv_framebuffer_mode;
3536int       stv_framebuffer_double_interlace;
36int       stv_vdp1_fbcr_accessed;
37int       stv_vdp1_current_display_framebuffer;
38int       stv_vdp1_current_draw_framebuffer;
39int       stv_vdp1_clear_framebuffer_on_next_frame;
40rectangle stv_vdp1_system_cliprect;
41rectangle stv_vdp1_user_cliprect;
37static int       stv_vdp1_fbcr_accessed;
38static int       stv_vdp1_current_display_framebuffer;
39static int       stv_vdp1_current_draw_framebuffer;
40static int       stv_vdp1_clear_framebuffer_on_next_frame;
41static rectangle stv_vdp1_system_cliprect;
42static rectangle stv_vdp1_user_cliprect;
4243
43int stvvdp1_local_x;
44int stvvdp1_local_y;
44static int stvvdp1_local_x;
45static int stvvdp1_local_y;
4546
4647struct stv_vdp1_poly_scanline
4748{
r1293r1294
184185
185186
186187
187void stv_vdp1_process_list(void);
188static void stv_vdp1_process_list(void);
188189
189190READ32_HANDLER( stv_vdp1_regs_r )
190191{
r1293r1294
13901391   return (INT32)(INT16)v + stvvdp1_local_y;
13911392}
13921393
1393void stv_vdp1_draw_line( const rectangle *cliprect)
1394static void stv_vdp1_draw_line( const rectangle *cliprect)
13941395{
13951396   struct spoint q[4];
13961397
r1293r1294
14091410   vdp1_fill_quad(cliprect, 0, 1, q);
14101411}
14111412
1412void stv_vdp1_draw_poly_line( const rectangle *cliprect)
1413static void stv_vdp1_draw_poly_line( const rectangle *cliprect)
14131414{
14141415   struct spoint q[4];
14151416
r1293r1294
14721473
14731474}
14741475
1475void stv_vpd1_draw_distorted_sprite(const rectangle *cliprect)
1476static void stv_vpd1_draw_distorted_sprite(const rectangle *cliprect)
14761477{
14771478   struct spoint q[4];
14781479
r1293r1294
15301531   vdp1_fill_quad(cliprect, patterndata, xsize, q);
15311532}
15321533
1533void stv_vpd1_draw_scaled_sprite(const rectangle *cliprect)
1534static void stv_vpd1_draw_scaled_sprite(const rectangle *cliprect)
15341535{
15351536   struct spoint q[4];
15361537
r1293r1294
16781679}
16791680
16801681
1681void stv_vpd1_draw_normal_sprite(const rectangle *cliprect, int sprite_type)
1682static void stv_vpd1_draw_normal_sprite(const rectangle *cliprect, int sprite_type)
16821683{
16831684   UINT16 *destline;
16841685
src/mame/video/nbmj9195.c
r1293r1294
9898
9999
100100******************************************************************************/
101int nbmj9195_blitter_r(int vram, int offset)
101static int nbmj9195_blitter_r(int vram, int offset)
102102{
103103   int ret;
104104   UINT8 *GFXROM = memory_region(REGION_GFX1);
r1293r1294
113113   return ret;
114114}
115115
116void nbmj9195_blitter_w(int vram, int offset, int data)
116static void nbmj9195_blitter_w(int vram, int offset, int data)
117117{
118118   int new_line;
119119
r1293r1294
165165   nbmj9195_clutsel = data;
166166}
167167
168void nbmj9195_clut_w(int vram, int offset, int data)
168static void nbmj9195_clut_w(int vram, int offset, int data)
169169{
170170   nbmj9195_clut[vram][((nbmj9195_clutsel & 0xff) * 0x10) + (offset & 0x0f)] = data;
171171}
r1293r1294
382382   nb19010_busyflag = 0;
383383
384384   /* 1650ns per count */
385   mame_timer_set(make_mame_time(0, nb19010_busyctr * 1650 * (MAX_SUBSECONDS / 1000000000)), 0, blitter_timer_callback);
385   timer_set(attotime_make(0, nb19010_busyctr * 1650 * ATTOSECONDS_PER_NANOSECOND), 0, blitter_timer_callback);
386386}
387387
388388/******************************************************************************
src/mame/video/artmagic.c
r1293r1294
2626static UINT8 blitter_page;
2727
2828#if (!INSTANT_BLIT)
29static mame_time blitter_busy_until;
29static attotime blitter_busy_until;
3030#endif
3131
3232
r1293r1294
303303   profiler_mark(PROFILER_END);
304304
305305#if (!INSTANT_BLIT)
306   blitter_busy_until = add_mame_times(mame_timer_get_time(), MAME_TIME_IN_NSEC(w*h*20));
306   blitter_busy_until = attotime_add(timer_get_time(), ATTOTIME_IN_NSEC(w*h*20));
307307#endif
308308}
309309
r1293r1294
317317    */
318318   UINT16 result = 0xffef | (blitter_page << 4);
319319#if (!INSTANT_BLIT)
320   if (compare_mame_times(mame_timer_get_time(), blitter_busy_until) < 0)
320   if (attotime_compare(timer_get_time(), blitter_busy_until) < 0)
321321      result ^= 6;
322322#endif
323323   return result;
src/mame/video/thief.c
r1293r1294
44
55#include "driver.h"
66
7mame_bitmap *thief_page0;
8mame_bitmap *thief_page1;
7static mame_bitmap *thief_page0;
8static mame_bitmap *thief_page1;
99
1010static UINT8 thief_read_mask, thief_write_mask;
1111static UINT8 thief_video_control;
src/mame/video/midtunit.c
r1293r1294
804804
805805   /* signal we're done */
806806skipdma:
807   mame_timer_set(MAME_TIME_IN_NSEC(41 * pixels), 0, dma_callback);
807   timer_set(ATTOTIME_IN_NSEC(41 * pixels), 0, dma_callback);
808808
809809   profiler_mark(PROFILER_END);
810810}
src/mame/video/system1.c
r1293r1294
107107   palette_set_color(Machine,offset,MAKE_RGB(r,g,b));
108108}
109109
110void system1_postload(void)
110static void system1_postload(void)
111111{
112112   memset(sprite_onscreen_map, 255, 256*256);
113113   memset(bg_dirtybuffer, 1, 1024);
src/mame/video/powerins.c
r1293r1294
4242/* Variables that driver has access to: */
4343UINT16 *powerins_vram_0, *powerins_vctrl_0;
4444UINT16 *powerins_vram_1, *powerins_vctrl_1;
45UINT16 *powerins_vregs;
45//UINT16 *powerins_vregs;
4646
4747/* Variables only used here: */
4848static tilemap *tilemap_0, *tilemap_1;
src/mame/video/niyanpai.c
r1293r1294
8585
8686
8787******************************************************************************/
88int niyanpai_blitter_r(int vram, int offset)
88static int niyanpai_blitter_r(int vram, int offset)
8989{
9090   int ret;
9191   UINT8 *GFXROM = memory_region(REGION_GFX1);
r1293r1294
100100   return ret;
101101}
102102
103void niyanpai_blitter_w(int vram, int offset, int data)
103static void niyanpai_blitter_w(int vram, int offset, int data)
104104{
105105   switch (offset)
106106   {
r1293r1294
133133   }
134134}
135135
136void niyanpai_clutsel_w(int vram, int data)
136static void niyanpai_clutsel_w(int vram, int data)
137137{
138138   niyanpai_clutsel[vram] = data;
139139}
140140
141void niyanpai_clut_w(int vram, int offset, int data)
141static void niyanpai_clut_w(int vram, int offset, int data)
142142{
143143   niyanpai_clut[vram][((niyanpai_clutsel[vram] & 0xff) * 0x10) + (offset & 0x0f)] = data;
144144}
r1293r1294
342342   }
343343
344344   nb19010_busyflag = 0;
345   mame_timer_set(scale_up_mame_time(MAME_TIME_IN_NSEC(1650), nb19010_busyctr), 0, blitter_timer_callback);
345   timer_set(attotime_mul(ATTOTIME_IN_NSEC(1650), nb19010_busyctr), 0, blitter_timer_callback);
346346}
347347
348348/******************************************************************************
src/mame/video/stvvdp2.c
r1293r1294
8686UINT32* stv_vdp2_regs;
8787UINT32* stv_vdp2_vram;
8888/* this won't be used in the end .. */
89UINT8*  stv_vdp2_vram_dirty_8x8x4;
90UINT8*  stv_vdp2_vram_dirty_8x8x8;
89static UINT8*  stv_vdp2_vram_dirty_8x8x4;
90static UINT8*  stv_vdp2_vram_dirty_8x8x8;
9191
9292static UINT8* stv_vdp2_gfx_decode;
9393extern UINT8* stv_vdp1_gfx_decode;
src/mame/video/namcofl.c
r1293r1294
55#include "namcoic.h"
66#include "namcos2.h"
77
8UINT32 *namcofl_spritebank32;
8//UINT32 *namcofl_spritebank32;
99//UINT32 *namcofl_tilebank32;
1010UINT32 *namcofl_mcuram;
1111
src/mame/video/dynax.c
r1293r1294
909909
910910***************************************************************************/
911911
912void hanamai_copylayer(mame_bitmap *bitmap,const rectangle *cliprect,int i)
912static void hanamai_copylayer(mame_bitmap *bitmap,const rectangle *cliprect,int i)
913913{
914914   int color;
915915   int scrollx,scrolly;
r1293r1294
974974}
975975
976976
977void jantouki_copylayer(mame_bitmap *bitmap,const rectangle *cliprect,int i, int y)
977static void jantouki_copylayer(mame_bitmap *bitmap,const rectangle *cliprect,int i, int y)
978978{
979979   int color,scrollx,scrolly,palettes,palbank;
980980
r1293r1294
10431043}
10441044
10451045
1046void mjdialq2_copylayer(mame_bitmap *bitmap,const rectangle *cliprect,int i)
1046static void mjdialq2_copylayer(mame_bitmap *bitmap,const rectangle *cliprect,int i)
10471047{
10481048   int color;
10491049   int scrollx,scrolly;
src/mame/video/itech32.c
r1293r1294
137137static rectangle clip_rect, scaled_clip_rect;
138138static rectangle clip_save;
139139
140static mame_timer *scanline_timer;
140static emu_timer *scanline_timer;
141141
142142static UINT8 *grom_base;
143143static UINT32 grom_size;
r1293r1294
231231   /* reset statics */
232232   memset(itech32_video, 0, 0x80);
233233
234   scanline_timer = mame_timer_alloc(scanline_interrupt);
234   scanline_timer = timer_alloc(scanline_interrupt);
235235   enable_latch[0] = 1;
236236   enable_latch[1] = (itech32_planes > 1) ? 1 : 0;
237237
r1293r1294
478478static TIMER_CALLBACK( scanline_interrupt )
479479{
480480   /* set timer for next frame */
481   mame_timer_adjust(scanline_timer, video_screen_get_time_until_pos(0, VIDEO_INTSCANLINE, 0), 0, time_zero);
481   timer_adjust(scanline_timer, video_screen_get_time_until_pos(0, VIDEO_INTSCANLINE, 0), 0, attotime_zero);
482482
483483   /* set the interrupt bit in the status reg */
484484   logerror("-------------- (DISPLAY INT @ %d) ----------------\n", video_screen_get_vpos(0));
r1293r1294
13461346         break;
13471347
13481348      case 0x2c/2:   /* VIDEO_INTSCANLINE */
1349         mame_timer_adjust(scanline_timer, video_screen_get_time_until_pos(0, VIDEO_INTSCANLINE, 0), 0, time_zero);
1349         timer_adjust(scanline_timer, video_screen_get_time_until_pos(0, VIDEO_INTSCANLINE, 0), 0, attotime_zero);
13501350         break;
13511351
13521352      case 0x32/2:   /* VIDEO_VTOTAL */
src/mame/video/deco32.c
r1293r1294
343343    Bottom 8 bits per pixel is palettised sprite data, top 8 is
344344    colour/alpha/priority.
345345*/
346void deco32_draw_sprite(mame_bitmap *dest,const gfx_element *gfx,
346static void deco32_draw_sprite(mame_bitmap *dest,const gfx_element *gfx,
347347      UINT32 code,UINT32 priority,int flipx,int flipy,int sx,int sy,
348348      const rectangle *clip)
349349{
src/mame/video/argus.c
r1293r1294
154154static int lowbitscroll = 0;
155155static int prvscrollx = 0;
156156
157UINT8 bombsa_ram_page;
158UINT8* bomba_otherram;
157static UINT8 bombsa_ram_page;
158static UINT8* bomba_otherram;
159159
160160static int valtric_mosaic=0;
161161static mame_bitmap *mosaicbitmap;
r1293r1294
12181218   }
12191219}
12201220
1221void butasan_draw_sprites(running_machine *machine, mame_bitmap *bitmap, const rectangle *cliprect)
1221static void butasan_draw_sprites(running_machine *machine, mame_bitmap *bitmap, const rectangle *cliprect)
12221222{
12231223   int offs;
12241224
src/mame/video/ninjakid.c
r1293r1294
55static UINT8 flipscreen;
66static UINT8 ninjakun_xscroll,ninjakun_yscroll;
77
8UINT8 ninjakun_io_8000_ctrl[4];
8static UINT8 ninjakun_io_8000_ctrl[4];
99// static UINT8 old_scroll;
1010
1111/*******************************************************************************
src/mame/video/gaiden.c
r1293r1294
88
99UINT16 *gaiden_videoram,*gaiden_videoram2,*gaiden_videoram3;
1010int gaiden_sprite_sizey;
11int raiga_alpha;
11//int raiga_alpha;
1212
1313static tilemap *text_layer,*foreground,*background;
1414static mame_bitmap *sprite_bitmap, *tile_bitmap_bg, *tile_bitmap_fg;
src/mame/video/gticlub.c
r1293r1294
4040static UINT32 K001006_addr[MAX_K001006_CHIPS] = { 0, 0 };
4141static int K001006_device_sel[MAX_K001006_CHIPS] = { 0, 0 };
4242
43UINT32 K001006_palette[MAX_K001006_CHIPS][0x800];
43static UINT32 K001006_palette[MAX_K001006_CHIPS][0x800];
4444
4545static UINT32 K001006_r(int chip, int offset, UINT32 mem_mask)
4646{
r1293r1294
154154static const int decode_y_zr107[16] = {  0, 8, 32, 40, 4, 12, 36, 44, 64, 72, 96, 104, 68, 76, 100, 108 };
155155
156156UINT32 K001005_status = 0;
157mame_bitmap *K001005_bitmap[2];
158mame_bitmap *K001005_zbuffer;
159rectangle K001005_cliprect;
157static mame_bitmap *K001005_bitmap[2];
158static mame_bitmap *K001005_zbuffer;
159static rectangle K001005_cliprect;
160160
161161static void render_polygons(void);
162162
src/mame/video/armedf.c
r1293r1294
99UINT16 *legion_cmd;
1010static UINT16 armedf_fg_scrollx,armedf_fg_scrolly;
1111
12UINT16 terraf_scroll_msb;
12static UINT16 terraf_scroll_msb;
1313
1414static tilemap *bg_tilemap, *fg_tilemap;
1515tilemap *armedf_tx_tilemap;
src/mame/video/dkong.c
r1293r1294
2323
2424static mame_bitmap *bg_bits;
2525static const UINT8 *color_codes;
26static mame_timer *scanline_timer;
26static emu_timer *scanline_timer;
2727
2828static const double cd4049_vl = 1.5/5.0;
2929static const double cd4049_vh = 3.5/5.0;
r1293r1294
773773      counter++;
774774   scanline = (scanline+1) % VTOTAL;
775775   /* come back at the next appropriate scanline */
776   mame_timer_adjust(scanline_timer, video_screen_get_time_until_pos(0, scanline, 0), scanline, time_zero);
776   timer_adjust(scanline_timer, video_screen_get_time_until_pos(0, scanline, 0), scanline, attotime_zero);
777777}
778778
779779static VIDEO_START( dkong_base )
r1293r1294
820820
821821   bg_bits = auto_bitmap_alloc(machine->screen[0].width, machine->screen[0].height, machine->screen[0].format);
822822
823    scanline_timer = mame_timer_alloc(scanline_callback);
824    mame_timer_adjust(scanline_timer, video_screen_get_time_until_pos(0, 0, 0), 0, time_zero);
823    scanline_timer = timer_alloc(scanline_callback);
824    timer_adjust(scanline_timer, video_screen_get_time_until_pos(0, 0, 0), 0, attotime_zero);
825825
826826}
827827
r1293r1294
837837
838838   bg_bits = auto_bitmap_alloc(machine->screen[0].width, machine->screen[0].height, machine->screen[0].format);
839839
840    scanline_timer = mame_timer_alloc(scanline_callback);
841    mame_timer_adjust(scanline_timer, video_screen_get_time_until_pos(0, 0, 0), 0, time_zero);
840    scanline_timer = timer_alloc(scanline_callback);
841    timer_adjust(scanline_timer, video_screen_get_time_until_pos(0, 0, 0), 0, attotime_zero);
842842
843843}
844844
src/mame/video/psx.c
r1293r1294
624624   visarea.min_x = visarea.min_y = 0;
625625   visarea.max_x = m_n_screenwidth - 1;
626626   visarea.max_y = m_n_screenheight - 1;
627   video_screen_configure(0, m_n_screenwidth, m_n_screenheight, &visarea, HZ_TO_SUBSECONDS(refresh));
627   video_screen_configure(0, m_n_screenwidth, m_n_screenheight, &visarea, HZ_TO_ATTOSECONDS(refresh));
628628}
629629
630630static void psx_gpu_init( void )
src/mame/video/kaneko16.c
r1293r1294
3838UINT16 kaneko16_disp_enable = 1; // default enabled for games not using it
3939
4040
41tilemap *kaneko16_tmap_0, *kaneko16_tmap_1;
42tilemap *kaneko16_tmap_2, *kaneko16_tmap_3;
41static tilemap *kaneko16_tmap_0, *kaneko16_tmap_1;
42static tilemap *kaneko16_tmap_2, *kaneko16_tmap_3;
4343UINT16 *kaneko16_vram_0,    *kaneko16_vram_1,    *kaneko16_layers_0_regs;
4444UINT16 *kaneko16_vscroll_0, *kaneko16_vscroll_1;
4545UINT16 *kaneko16_vram_2,    *kaneko16_vram_3,    *kaneko16_layers_1_regs;
r1293r1294
801801
802802***************************************************************************/
803803
804void kaneko16_prepare_first_tilemap_chip(running_machine *machine, mame_bitmap *bitmap, const rectangle *cliprect)
804static void kaneko16_prepare_first_tilemap_chip(running_machine *machine, mame_bitmap *bitmap, const rectangle *cliprect)
805805{
806806   /* Set Up FIRST Tilemap chip */
807807   int layers_flip_0;
r1293r1294
841841
842842}
843843
844void kaneko16_prepare_second_tilemap_chip(running_machine *machine, mame_bitmap *bitmap, const rectangle *cliprect)
844static void kaneko16_prepare_second_tilemap_chip(running_machine *machine, mame_bitmap *bitmap, const rectangle *cliprect)
845845{
846846   /* Set Up SECOND Tilemap chip */
847847   int layers_flip_1 = 0;
r1293r1294
880880   }
881881}
882882
883void kaneko16_render_first_tilemap_chip(running_machine *machine, mame_bitmap *bitmap, const rectangle *cliprect, int pri)
883static void kaneko16_render_first_tilemap_chip(running_machine *machine, mame_bitmap *bitmap, const rectangle *cliprect, int pri)
884884{
885885   tilemap_draw_primask(bitmap,cliprect, kaneko16_tmap_0, pri, pri, 0);
886886   tilemap_draw_primask(bitmap,cliprect, kaneko16_tmap_1, pri, pri, 0);
887887}
888888
889void kaneko16_render_second_tilemap_chip(running_machine *machine, mame_bitmap *bitmap, const rectangle *cliprect, int pri)
889static void kaneko16_render_second_tilemap_chip(running_machine *machine, mame_bitmap *bitmap, const rectangle *cliprect, int pri)
890890{
891891   if (kaneko16_tmap_2)
892892   {
r1293r1294
895895   }
896896}
897897
898void kaneko16_render_sprites(running_machine *machine, mame_bitmap *bitmap, const rectangle *cliprect)
898static void kaneko16_render_sprites(running_machine *machine, mame_bitmap *bitmap, const rectangle *cliprect)
899899{
900900   /* Sprites last (rendered with pdrawgfx, so they can slip
901901       in between the layers) */
r1293r1294
913913   }
914914}
915915
916void kaneko16_render_15bpp_bitmap(running_machine *machine, mame_bitmap *bitmap, const rectangle *cliprect)
916static void kaneko16_render_15bpp_bitmap(running_machine *machine, mame_bitmap *bitmap, const rectangle *cliprect)
917917{
918918   if (kaneko16_bg15_bitmap)
919919   {
r1293r1294
937937   }
938938}
939939
940void kaneko16_fill_bitmap(running_machine *machine, mame_bitmap *bitmap, const rectangle *cliprect)
940static void kaneko16_fill_bitmap(running_machine *machine, mame_bitmap *bitmap, const rectangle *cliprect)
941941{
942942   if(kaneko16_sprite_type == 1)
943943      fillbitmap(bitmap,machine->pens[0x7f00],cliprect);
r1293r1294
948948      fillbitmap(bitmap,machine->pens[0],cliprect);
949949}
950950
951void kaneko16_video_update_common(running_machine *machine, mame_bitmap *bitmap, const rectangle *cliprect)
951static void kaneko16_video_update_common(running_machine *machine, mame_bitmap *bitmap, const rectangle *cliprect)
952952{
953953   int i;
954954
src/mame/video/ms32.c
r1293r1294
1414
1515#include "driver.h"
1616
17UINT32 *ms32_fce00000;
17//UINT32 *ms32_fce00000;
1818UINT32 *ms32_roz_ctrl;
1919UINT32 *ms32_tx_scroll;
2020UINT32 *ms32_bg_scroll;
r1293r1294
2828UINT32 *ms32_mainram;
2929
3030// kirarast, tp2m32, and 47pie2 require the sprites in a different order
31int ms32_reverse_sprite_order;
31static int ms32_reverse_sprite_order;
3232
3333/********** Tilemaps **********/
3434
src/mame/video/system16.c
r1293r1294
9797extern void start_system18_vdp(void);
9898extern READ16_HANDLER( segac2_vdp_r );
9999extern WRITE16_HANDLER( segac2_vdp_w );
100UINT16 sys18_ddcrew_bankregs[0x20];
100static UINT16 sys18_ddcrew_bankregs[0x20];
101101
102102
103103
r1293r1294
132132int sys16_fg_priority_mode;
133133int sys16_bg_priority_value;
134134int sys16_fg_priority_value;
135int sys16_18_mode;
135static int sys16_18_mode;
136136int sys16_tilebank_switch;
137137int sys16_rowscroll_scroll;
138138int shinobl_kludge;
src/mame/video/atarimo.c
r1293r1294
136136##########################################################################*/
137137
138138static struct atarimo_data atarimo[ATARIMO_MAX];
139static mame_timer *force_update_timer;
139static emu_timer *force_update_timer;
140140
141141
142142/*##########################################################################
r1293r1294
244244}
245245
246246static struct atarimo_data atarimo[ATARIMO_MAX];
247static mame_timer *force_update_timer;
247static emu_timer *force_update_timer;
248248
249249/*---------------------------------------------------------------
250250    init_savestate: Initialize save states
r1293r1294
323323   scanline += 64;
324324   if (scanline >= machine->screen[0].visarea.max_y)
325325      scanline = 0;
326   mame_timer_adjust(force_update_timer, video_screen_get_time_until_pos(0, scanline, 0), scanline, time_zero);
326   timer_adjust(force_update_timer, video_screen_get_time_until_pos(0, scanline, 0), scanline, attotime_zero);
327327}
328328
329329/*---------------------------------------------------------------
r1293r1294
444444   init_gfxelement(machine, mo, desc->gfxindex);
445445
446446   /* start a timer to update a few times during refresh */
447   force_update_timer = mame_timer_alloc(force_update);
448   mame_timer_adjust(force_update_timer,video_screen_get_time_until_pos(0, 0, 0), 0, time_zero);
447   force_update_timer = timer_alloc(force_update);
448   timer_adjust(force_update_timer,video_screen_get_time_until_pos(0, 0, 0), 0, attotime_zero);
449449
450450   init_savestate(map, mo);
451451
src/mame/video/mcr3.c
r1293r1294
2121INT16 spyhunt_scroll_offset;
2222
2323UINT8 *spyhunt_alpharam;
24size_t spyhunt_alpharam_size;
24//size_t spyhunt_alpharam_size;
2525
2626
2727
src/mame/video/jackal.c
r1293r1294
1010
1111#include "driver.h"
1212
13UINT8 *jackal_scrollram, *jackal_videoctrl;
13static UINT8 *jackal_scrollram;
14UINT8 *jackal_videoctrl;
1415
1516static tilemap *bg_tilemap;
1617
src/mame/video/tank8.c
r1293r1294
267267            }
268268         }
269269
270         mame_timer_set(video_screen_get_time_until_pos(0, y, x), index, tank8_collision_callback);
270         timer_set(video_screen_get_time_until_pos(0, y, x), index, tank8_collision_callback);
271271
272272         state = 1;
273273      }
src/mame/video/taitoic.c
r1293r1294
754754   common_get_PC080SN_fg_tile_info(machine,tileinfo,tile_index,PC080SN_bg_ram[1][1],PC080SN_bg_gfx[1]);
755755}
756756
757tile_get_info_callback PC080SN_get_tile_info[PC080SN_MAX_CHIPS][2] =
757static tile_get_info_callback PC080SN_get_tile_info[PC080SN_MAX_CHIPS][2] =
758758{
759759   { PC080SN_get_bg_tile_info_0, PC080SN_get_fg_tile_info_0 },
760760   { PC080SN_get_bg_tile_info_1, PC080SN_get_fg_tile_info_1 }
r1293r1294
10151015}
10161016
10171017
1018UINT16 topspeed_get_road_pixel_color(UINT16 pixel,UINT16 color)
1018static UINT16 topspeed_get_road_pixel_color(UINT16 pixel,UINT16 color)
10191019{
10201020   UINT16 road_body_color,off_road_color,pixel_type;
10211021
r1293r1294
14761476};
14771477
14781478
1479void TC0080VCO_set_layer_ptrs(void)
1479static void TC0080VCO_set_layer_ptrs(void)
14801480{
14811481   TC0080VCO_char_ram      = TC0080VCO_ram + 0x00000/2;   /* continues at +0x10000 */
14821482   TC0080VCO_tx_ram_0      = TC0080VCO_ram + 0x01000/2;
r1293r1294
14951495   TC0080VCO_scroll_ram    = TC0080VCO_ram + 0x20800/2;
14961496}
14971497
1498void TC0080VCO_dirty_chars(void)
1498static void TC0080VCO_dirty_chars(void)
14991499{
15001500   memset(TC0080VCO_char_dirty,1,TC0080VCO_TOTAL_CHARS);
15011501   TC0080VCO_chars_dirty = 1;
15021502}
15031503
1504void TC0080VCO_dirty_tilemaps(void)
1504static void TC0080VCO_dirty_tilemaps(void)
15051505{
15061506   tilemap_mark_all_tiles_dirty(TC0080VCO_tilemap[0]);
15071507   tilemap_mark_all_tiles_dirty(TC0080VCO_tilemap[1]);
15081508   tilemap_mark_all_tiles_dirty(TC0080VCO_tilemap[2]);
15091509}
15101510
1511void TC0080VCO_restore_scroll(void)
1511static void TC0080VCO_restore_scroll(void)
15121512{
15131513   TC0080VCO_flipscreen = TC0080VCO_scroll_ram[0] & 0x0c00;
15141514
r1293r1294
21632163
21642164/* This array changes with TC0100SCN_MAX_CHIPS */
21652165
2166tile_get_info_callback TC0100SCN_get_tile_info[TC0100SCN_MAX_CHIPS][3] =
2166static tile_get_info_callback TC0100SCN_get_tile_info[TC0100SCN_MAX_CHIPS][3] =
21672167{
21682168   { TC0100SCN_get_bg_tile_info_0, TC0100SCN_get_fg_tile_info_0, TC0100SCN_get_tx_tile_info_0 },
21692169   { TC0100SCN_get_bg_tile_info_1, TC0100SCN_get_fg_tile_info_1, TC0100SCN_get_tx_tile_info_1 },
r1293r1294
22112211    TC0100SCN_gfxbank = (data & 0x1);
22122212}
22132213
2214void TC0100SCN_set_layer_ptrs(int i)
2214static void TC0100SCN_set_layer_ptrs(int i)
22152215{
22162216   if (!TC0100SCN_dblwidth[i])
22172217   {
r1293r1294
22382238/* As we can't pass function calls with params in set...func_postload() calls
22392239   in the vh_start, this slightly obnoxious method is used */
22402240
2241void TC0100SCN_dirty_tilemaps(int chip)
2241static void TC0100SCN_dirty_tilemaps(int chip)
22422242{
22432243   tilemap_mark_all_tiles_dirty(TC0100SCN_tilemap[chip][0][TC0100SCN_dblwidth[chip]]);
22442244   tilemap_mark_all_tiles_dirty(TC0100SCN_tilemap[chip][1][TC0100SCN_dblwidth[chip]]);
22452245   tilemap_mark_all_tiles_dirty(TC0100SCN_tilemap[chip][2][TC0100SCN_dblwidth[chip]]);
22462246}
22472247
2248void TC0100SCN_dirty_chars(int chip)
2248static void TC0100SCN_dirty_chars(int chip)
22492249{
22502250   memset(TC0100SCN_char_dirty[chip],1,TC0100SCN_TOTAL_CHARS);
22512251   TC0100SCN_chars_dirty[chip] = 1;
r1293r1294
30113011   common_get_tc0480tx_tile_info(machine,tileinfo,tile_index,TC0480SCP_tx_ram,TC0480SCP_tx_gfx);
30123012}
30133013
3014tile_get_info_callback tc480_get_tile_info[5] =
3014static tile_get_info_callback tc480_get_tile_info[5] =
30153015{
30163016   TC0480SCP_get_bg0_tile_info, TC0480SCP_get_bg1_tile_info,
30173017   TC0480SCP_get_bg2_tile_info, TC0480SCP_get_bg3_tile_info,
r1293r1294
30343034   32*8   /* every sprite takes 32 consecutive bytes */
30353035};
30363036
3037void TC0480SCP_set_layer_ptrs(void)
3037static void TC0480SCP_set_layer_ptrs(void)
30383038{
30393039   if (!TC0480SCP_dblwidth)
30403040   {
r1293r1294
30723072   }
30733073}
30743074
3075void TC0480SCP_dirty_tilemaps(void)
3075static void TC0480SCP_dirty_tilemaps(void)
30763076{
30773077   tilemap_mark_all_tiles_dirty(TC0480SCP_tilemap[0][TC0480SCP_dblwidth]);
30783078   tilemap_mark_all_tiles_dirty(TC0480SCP_tilemap[1][TC0480SCP_dblwidth]);
r1293r1294
30813081   tilemap_mark_all_tiles_dirty(TC0480SCP_tilemap[4][TC0480SCP_dblwidth]);
30823082}
30833083
3084void TC0480SCP_dirty_chars(void)
3084static void TC0480SCP_dirty_chars(void)
30853085{
30863086   memset(TC0480SCP_char_dirty,1,TC0480SCP_TOTAL_CHARS);
30873087   TC0480SCP_chars_dirty = 1;
r1293r1294
46824682#define TC0110PCR_RAM_SIZE 0x2000
46834683
46844684
4685void TC0110PCR_restore_colors(int chip)
4685static void TC0110PCR_restore_colors(int chip)
46864686{
46874687   int i,color,r=0,g=0,b=0;
46884688
src/mame/video/suna8.c
r1293r1294
7373
7474#define TILEMAPS 0
7575
76int suna8_text_dim; /* specifies format of text layer */
76static int suna8_text_dim; /* specifies format of text layer */
7777
7878UINT8 suna8_rombank, suna8_spritebank, suna8_palettebank;
7979UINT8 suna8_unknown;
src/mame/video/cps1.c
r1293r1294
419419int cps1_scanline2;
420420int cps1_scancalls;
421421
422#ifdef UNUSED_FUNCTION
422423void cps_setversion(int v)
423424{
424425    cps_version=v;
425426}
427#endif
426428
427429
428430static MACHINE_RESET( cps )
src/mame/video/lethalj.c
r1293r1294
161161   if (offset == 7)
162162   {
163163      do_blit();
164      mame_timer_set(MAME_TIME_IN_USEC(10), 0, gen_ext1_int);
164      timer_set(ATTOTIME_IN_USEC(10), 0, gen_ext1_int);
165165   }
166166
167167   /* clear the IRQ on offset 0 */
src/mame/video/kickgoal.c
r1293r1294
33#include "driver.h"
44
55extern UINT16 *kickgoal_fgram, *kickgoal_bgram, *kickgoal_bg2ram, *kickgoal_scrram;
6tilemap *kickgoal_fgtm, *kickgoal_bgtm, *kickgoal_bg2tm;
6static tilemap *kickgoal_fgtm, *kickgoal_bgtm, *kickgoal_bg2tm;
77
88/* FG */
99static TILE_GET_INFO( get_kickgoal_fg_tile_info )
src/mame/video/itech8.c
r1293r1294
517517      blit_in_progress = 1;
518518
519519      /* set a timer to go off when we're done */
520      mame_timer_set(scale_up_mame_time(MAME_TIME_IN_HZ(12000000/4), BLITTER_WIDTH * BLITTER_HEIGHT + 12), 0, blitter_done);
520      timer_set(attotime_mul(ATTOTIME_IN_HZ(12000000/4), BLITTER_WIDTH * BLITTER_HEIGHT + 12), 0, blitter_done);
521521   }
522522
523523   /* debugging */
src/mame/video/galaxian.c
r1293r1294
102102       UINT8 galaxian_stars_on;
103103static INT32 stars_scrollpos;
104104static UINT8 stars_blink_state;
105static mame_timer *stars_blink_timer;
106static mame_timer *stars_scroll_timer;
105static emu_timer *stars_blink_timer;
106static emu_timer *stars_scroll_timer;
107107static UINT8 timer_adjusted;
108108       void galaxian_init_stars(running_machine *machine, int colors_offset);
109109static void (*draw_stars)(running_machine *, mame_bitmap *);      /* function to call to draw the star layer */
110110static void     noop_draw_stars(running_machine *machine, mame_bitmap *bitmap);
111111       void galaxian_draw_stars(running_machine *machine, mame_bitmap *bitmap);
112      void scramble_draw_stars(running_machine *machine, mame_bitmap *bitmap);
112static       void scramble_draw_stars(running_machine *machine, mame_bitmap *bitmap);
113113static void   rescue_draw_stars(running_machine *machine, mame_bitmap *bitmap);
114114static void  mariner_draw_stars(running_machine *machine, mame_bitmap *bitmap);
115115static void  jumpbug_draw_stars(running_machine *machine, mame_bitmap *bitmap);
r1293r1294
17311731
17321732   galaxian_stars_on = 0;
17331733   stars_blink_state = 0;
1734   stars_blink_timer = mame_timer_alloc(stars_blink_callback);
1735   stars_scroll_timer = mame_timer_alloc(stars_scroll_callback);
1734   stars_blink_timer = timer_alloc(stars_blink_callback);
1735   stars_scroll_timer = timer_alloc(stars_scroll_callback);
17361736   timer_adjusted = 0;
17371737   stars_colors_start = colors_offset;
17381738
r1293r1294
20322032
20332033   int period_in_ms = 693 * (ra + 2.0 * rb) * c;
20342034
2035   mame_timer_adjust(stars_blink_timer, MAME_TIME_IN_MSEC(period_in_ms), 0, MAME_TIME_IN_MSEC(period_in_ms));
2035   timer_adjust(stars_blink_timer, ATTOTIME_IN_MSEC(period_in_ms), 0, ATTOTIME_IN_MSEC(period_in_ms));
20362036}
20372037
20382038
r1293r1294
20462046
20472047static void start_stars_scroll_timer()
20482048{
2049   mame_timer_adjust(stars_scroll_timer, video_screen_get_frame_period(0), 0, video_screen_get_frame_period(0));
2049   timer_adjust(stars_scroll_timer, video_screen_get_frame_period(0), 0, video_screen_get_frame_period(0));
20502050}
20512051
20522052
src/mame/video/gstriker.c
r1293r1294
216216   return (row*64) + (col&63) + ((col&64)<<6);
217217}
218218
219void MB60553_init(int numchips)
219static void MB60553_init(int numchips)
220220{
221221   int i;
222222
r1293r1294
231231   }
232232}
233233
234void MB60553_set_pal_base(int numchip, int pal_base)
234static void MB60553_set_pal_base(int numchip, int pal_base)
235235{
236236   MB60553[numchip].pal_base = pal_base;
237237}
238238
239void MB60553_set_gfx_region(int numchip, int gfx_region)
239static void MB60553_set_gfx_region(int numchip, int gfx_region)
240240{
241241   MB60553[numchip].gfx_region = gfx_region;
242242}
243243
244244/* THIS IS STILL WRONG! */
245void MB60553_draw(running_machine *machine, int numchip, mame_bitmap* screen, const rectangle* cliprect, int priority)
245static void MB60553_draw(running_machine *machine, int numchip, mame_bitmap* screen, const rectangle* cliprect, int priority)
246246{
247247   int line;
248248   rectangle clip;
r1293r1294
288288
289289}
290290
291tilemap* MB60553_get_tilemap(int numchip)
291static tilemap* MB60553_get_tilemap(int numchip)
292292{
293293   return MB60553[numchip].tmap;
294294}
r1293r1294
495495   }
496496}
497497
498void CG10103_init(int numchips)
498static void CG10103_init(int numchips)
499499{
500500   int i;
501501
r1293r1294
509509   }
510510}
511511
512void CG10103_set_pal_base(int numchip, int pal_base)
512static void CG10103_set_pal_base(int numchip, int pal_base)
513513{
514514   CG10103[numchip].pal_base = pal_base;
515515}
516516
517void CG10103_set_gfx_region(int numchip, int gfx_region)
517static void CG10103_set_gfx_region(int numchip, int gfx_region)
518518{
519519   CG10103[numchip].gfx_region = gfx_region;
520520}
src/mame/video/hyprduel.c
r1293r1294
297297 the tile's sizes to be known at startup - which we don't!
298298*/
299299
300int hyprduel_sprite_xoffs, hyprduel_sprite_yoffs;
300static int hyprduel_sprite_xoffs, hyprduel_sprite_yoffs;
301301
302302
303303static void alloc_empty_tiles(void)
src/mame/video/flstory.c
r1293r1294
141141}
142142
143143
144void flstory_draw_sprites(running_machine *machine, mame_bitmap *bitmap, const rectangle *cliprect, int pri)
144static void flstory_draw_sprites(running_machine *machine, mame_bitmap *bitmap, const rectangle *cliprect, int pri)
145145{
146146   int i;
147147
r1293r1294
198198   return 0;
199199}
200200
201void victnine_draw_sprites(running_machine *machine, mame_bitmap *bitmap, const rectangle *cliprect)
201static void victnine_draw_sprites(running_machine *machine, mame_bitmap *bitmap, const rectangle *cliprect)
202202{
203203   int i;
204204
src/mame/video/model2.c
r1293r1294
11001100}
11011101
11021102/* 3D Rasterizer main data input port */
1103void model2_3d_push( UINT32 input )
1103static void model2_3d_push( UINT32 input )
11041104{
11051105   /* see if we have a command in progress */
11061106   if ( raster.cur_command != 0 )
src/mame/video/leland.c
r1293r1294
474474   update_for_scanline(VIDEO_HEIGHT * 8);
475475
476476   /* set a timer to go off at the top of the frame */
477   mame_timer_set(video_screen_get_time_until_pos(0, 0, 0), 0, scanline_reset);
477   timer_set(video_screen_get_time_until_pos(0, 0, 0), 0, scanline_reset);
478478}
479479
480480
src/mame/video/lordgun.c
r1293r1294
186186   0x1B3,0x1B4,0x1B5,0x1B6,0x1B7,0x1B8,0x1B9,0x1BA,0x1BB,0x1BC,0x1BD,0x1BE,0x1BF,0x1BF
187187};
188188
189void lorddgun_calc_gun_scr(int i)
189static void lorddgun_calc_gun_scr(int i)
190190{
191191   int x = readinputport(5+i) - 0x3c;
192192   if ( (x < 0) || (x > sizeof(lordgun_gun_x_table)/sizeof(lordgun_gun_x_table[0])) )
src/mame/video/tiamc1.c
r1293r1294
1616UINT8 *tiamc1_spriteram_y;
1717UINT8 *tiamc1_spriteram_a;
1818UINT8 *tiamc1_spriteram_n;
19UINT8 tiamc1_layers_ctrl;
20UINT8 tiamc1_bg_vshift;
21UINT8 tiamc1_bg_hshift;
19static UINT8 tiamc1_layers_ctrl;
20static UINT8 tiamc1_bg_vshift;
21static UINT8 tiamc1_bg_hshift;
2222
2323static tilemap *bg_tilemap1, *bg_tilemap2;
2424static rgb_t *palette;
src/mame/video/toaplan1.c
r1293r1294
304304   spriteram_size = TOAPLAN1_SPRITERAM_SIZE;
305305}
306306
307void toaplan1_set_scrolls(void)
307static void toaplan1_set_scrolls(void)
308308{
309309   tilemap_set_scrollx(pf1_tilemap,0,(pf1_scrollx >> 7) - (tiles_offsetx - scrollx_offs1));
310310   tilemap_set_scrollx(pf2_tilemap,0,(pf2_scrollx >> 7) - (tiles_offsetx - scrollx_offs2));
r1293r1294
316316   tilemap_set_scrolly(pf4_tilemap,0,(pf4_scrolly >> 7) - (tiles_offsety - scrolly_offs));
317317}
318318
319void rallybik_flipscreen(void)
319static void rallybik_flipscreen(void)
320320{
321321   rallybik_bcu_flipscreen_w(0, bcu_flipscreen, 0);
322322}
323323
324void toaplan1_flipscreen(void)
324static void toaplan1_flipscreen(void)
325325{
326326   toaplan1_bcu_flipscreen_w(0, bcu_flipscreen, 0);
327327}
src/mame/video/segag80r.c
r1293r1294
5353   /* set a timer to mimic the 555 timer that drives the EDGINT signal */
5454   /* the 555 is run in monostable mode with R=56000 and C=1000pF */
5555   vblank_latch = 1;
56   mame_timer_set(PERIOD_OF_555_MONOSTABLE(CAP_P(1000), RES_K(56)), 0, vblank_latch_clear);
56   timer_set(PERIOD_OF_555_MONOSTABLE(CAP_P(1000), RES_K(56)), 0, vblank_latch_clear);
5757
5858   /* latch the current flip state at the same time */
5959   video_flip = video_control & 1;
src/mame/video/pitnrun.c
r1293r1294
111111   tilemap_mark_all_tiles_dirty(ALL_TILEMAPS);
112112}
113113
114void pitnrun_spotlights(void)
114static void pitnrun_spotlights(void)
115115{
116116   int x,y,i,b,datapix;
117117   UINT8 *ROM = memory_region(REGION_USER1);
src/mame/video/segaic16.c
r1293r1294
11781178   }
11791179
11801180   /* set a timer to do this again next frame */
1181   mame_timer_set(video_screen_get_time_until_pos(0, 261, 0), param, segaic16_tilemap_16b_latch_values);
1181   timer_set(video_screen_get_time_until_pos(0, 261, 0), param, segaic16_tilemap_16b_latch_values);
11821182}
11831183
11841184
1185void segaic16_tilemap_16b_reset(struct tilemap_info *info)
1185static void segaic16_tilemap_16b_reset(struct tilemap_info *info)
11861186{
11871187   /* set a timer to latch values on scanline 261 */
1188   mame_timer_set(video_screen_get_time_until_pos(0, 261, 0), info->index, segaic16_tilemap_16b_latch_values);
1188   timer_set(video_screen_get_time_until_pos(0, 261, 0), info->index, segaic16_tilemap_16b_latch_values);
11891189}
11901190
11911191
src/mame/video/esd16.c
r1293r1294
6565
6666***************************************************************************/
6767
68tilemap *esdtilemap_0, *esdtilemap_1, *esdtilemap_1_16x16;
68static tilemap *esdtilemap_0;
69static tilemap *esdtilemap_1;
70tilemap *esdtilemap_1_16x16;
6971
7072static TILE_GET_INFO( get_tile_info_0 )
7173{
src/mame/video/iqblock.c
r1293r1294
33
44
55UINT8 *iqblock_bgvideoram;
6UINT8 *iqblock_fgscroll;
6//UINT8 *iqblock_fgscroll;
77UINT8 *iqblock_fgvideoram;
88int iqblock_videoenable;
99int iqblock_video_type;
src/mame/video/sbasketb.c
r1293r1294
88
99#include "driver.h"
1010
11UINT8 *sbasketb_scroll;
11//UINT8 *sbasketb_scroll;
1212UINT8 *sbasketb_palettebank;
1313UINT8 *sbasketb_spriteram_select;
1414
src/mame/video/cchasm.c
r1293r1294
100100      }
101101   }
102102    /* Refresh processor runs with 6 MHz */
103    mame_timer_set (scale_up_mame_time(MAME_TIME_IN_HZ(6000000), total_length), 0, cchasm_refresh_end);
103    timer_set (attotime_mul(ATTOTIME_IN_HZ(6000000), total_length), 0, cchasm_refresh_end);
104104}
105105
106106
src/mame/video/qix.c
r1293r1294
2424static UINT8 vram_mask;
2525static UINT8 qix_palettebank;
2626static UINT8 leds;
27static mame_timer *scanline_timer;
27static emu_timer *scanline_timer;
2828static UINT8 scanline_latch;
2929
3030
r1293r1294
8484   vram_mask = 0xff;
8585
8686   /* allocate a timer */
87   scanline_timer = mame_timer_alloc(scanline_callback);
88   mame_timer_adjust(scanline_timer, video_screen_get_time_until_pos(0, 1, 0), 1, time_zero);
87   scanline_timer = timer_alloc(scanline_callback);
88   timer_adjust(scanline_timer, video_screen_get_time_until_pos(0, 1, 0), 1, attotime_zero);
8989
9090   /* set up save states */
9191   state_save_register_global_pointer(videoram, 256 * 256);
r1293r1294
114114   scanline += SCANLINE_INCREMENT;
115115   if (scanline > machine->screen[0].visarea.max_y)
116116      scanline = SCANLINE_INCREMENT;
117   mame_timer_adjust(scanline_timer, video_screen_get_time_until_pos(0, scanline, 0), scanline, time_zero);
117   timer_adjust(scanline_timer, video_screen_get_time_until_pos(0, scanline, 0), scanline, attotime_zero);
118118}
119119
120120
src/mame/video/ksayakyu.c
r1293r1294
11#include "driver.h"
22
3tilemap *ksayakyu_tilemap;
4tilemap *ksayakyu_textmap;
3static tilemap *ksayakyu_tilemap;
4static tilemap *ksayakyu_textmap;
55
66static int video_ctrl;
77static int flipscreen;
src/mame/video/atarirle.c
r1293r1294
112112UINT16 *atarirle_0_spriteram;
113113UINT32 *atarirle_0_spriteram32;
114114
115UINT16 *atarirle_0_command;
116UINT32 *atarirle_0_command32;
115//UINT16 *atarirle_0_command;
116//UINT32 *atarirle_0_command32;
117117
118UINT16 *atarirle_0_table;
119UINT32 *atarirle_0_table32;
118//UINT16 *atarirle_0_table;
119//UINT32 *atarirle_0_table32;
120120
121121int atarirle_hilite_index = -1;
122122
src/mame/video/mcatadv.c
r1293r1294
156156   }
157157}
158158
159void mcatadv_draw_tilemap_part(UINT16* current_scroll, UINT16* current_videoram1, int i, tilemap* current_tilemap, mame_bitmap *bitmap, const rectangle *cliprect)
159static void mcatadv_draw_tilemap_part(UINT16* current_scroll, UINT16* current_videoram1, int i, tilemap* current_tilemap, mame_bitmap *bitmap, const rectangle *cliprect)
160160{
161161   int flip;
162162   UINT32 drawline;
src/mame/video/toaplan2.c
r1293r1294
180180UINT16 *toaplan2_txvideoram16_offs;   /* Text layer tile flip and positon ? */
181181UINT16 *toaplan2_txscrollram16;      /* Text layer scroll ? */
182182UINT16 *toaplan2_tx_gfxram16;         /* Text Layer RAM based tiles */
183UINT16 *raizing_tx_gfxram16;         /* Text Layer RAM based tiles (Batrider) */
183static UINT16 *raizing_tx_gfxram16;         /* Text Layer RAM based tiles (Batrider) */
184184static int toaplan2_overflow_vram;      /* Teki Paki VRAM test is bugged. It goes out of range */
185185
186186static int toaplan2_scroll_reg[2];
r1293r1294
559559
560560***************************************************************************/
561561
562void toaplan2_voffs_w(offs_t offset, UINT16 data, UINT32 mem_mask, int controller)
562static void toaplan2_voffs_w(offs_t offset, UINT16 data, UINT32 mem_mask, int controller)
563563{
564564   if (data >= 0x1c00)
565565      logerror("Hmmm, unknown video controller %01x layer being selected (%08x)\n",controller,data);
r1293r1294
718718
719719
720720
721int toaplan2_videoram16_r(offs_t offset, int controller)
721static int toaplan2_videoram16_r(offs_t offset, int controller)
722722{
723723   static UINT16 video_data = 0;
724724   static offs_t vram_offset;
r1293r1294
764764   return toaplan2_videoram16_r(offset, 1);
765765}
766766
767void toaplan2_videoram16_w(offs_t offset, UINT16 data, UINT32 mem_mask, int controller)
767static void toaplan2_videoram16_w(offs_t offset, UINT16 data, UINT32 mem_mask, int controller)
768768{
769769   offs_t vram_offset;
770770
r1293r1294
811811}
812812
813813
814void toaplan2_scroll_reg_select_w(offs_t offset, UINT16 data, UINT32 mem_mask, int controller)
814static void toaplan2_scroll_reg_select_w(offs_t offset, UINT16 data, UINT32 mem_mask, int controller)
815815{
816816   if (ACCESSING_LSB)
817817   {
r1293r1294
836836}
837837
838838
839void toaplan2_scroll_reg_data_w(offs_t offset, UINT16 data, UINT32 mem_mask, int controller)
839static void toaplan2_scroll_reg_data_w(offs_t offset, UINT16 data, UINT32 mem_mask, int controller)
840840{
841841   /************************************************************************/
842842   /***** layer X and Y flips can be set independantly, so emulate it ******/
src/mame/video/wecleman.c
r1293r1294
4242UINT16 *wecleman_videostatus;
4343UINT16 *wecleman_pageram, *wecleman_txtram, *wecleman_roadram;
4444size_t wecleman_roadram_size;
45int wecleman_bgpage[4], wecleman_fgpage[4], *wecleman_gfx_bank;
45static int wecleman_bgpage[4], wecleman_fgpage[4], *wecleman_gfx_bank;
4646
4747/* Variables only used here: */
4848static tilemap *bg_tilemap, *fg_tilemap, *txt_tilemap;
r1293r1294
416416                [ Frontmost (text) layer + video registers ]
417417------------------------------------------------------------------------*/
418418
419TILE_GET_INFO( wecleman_get_txt_tile_info )
419static TILE_GET_INFO( wecleman_get_txt_tile_info )
420420{
421421   int code = wecleman_txtram[tile_index];
422422   SET_TILE_INFO(PAGE_GFX, code&0xfff, (code>>5&0x78)+(code>>12), 0);
r1293r1294
462462                            [ Background ]
463463------------------------------------------------------------------------*/
464464
465TILE_GET_INFO( wecleman_get_bg_tile_info )
465static TILE_GET_INFO( wecleman_get_bg_tile_info )
466466{
467467   int page = wecleman_bgpage[((tile_index&0x7f)>>6) + ((tile_index>>12)<<1)];
468468   int code = wecleman_pageram[(tile_index&0x3f) + ((tile_index>>7&0x1f)<<6) + (page<<11)];
r1293r1294
474474                            [ Foreground ]
475475------------------------------------------------------------------------*/
476476
477TILE_GET_INFO( wecleman_get_fg_tile_info )
477static TILE_GET_INFO( wecleman_get_fg_tile_info )
478478{
479479   int page = wecleman_fgpage[((tile_index&0x7f)>>6) + ((tile_index>>12)<<1)];
480480   int code = wecleman_pageram[(tile_index&0x3f) + ((tile_index>>7&0x1f)<<6) + (page<<11)];
src/mame/video/pastelg.c
r1293r1294
2525static UINT8 *pastelg_clut;
2626
2727
28void pastelg_vramflip(void);
29void pastelg_gfxdraw(void);
28static void pastelg_vramflip(void);
29static void pastelg_gfxdraw(void);
3030
3131
3232/******************************************************************************
r1293r1294
253253   }
254254
255255   nb1413m3_busyflag = 0;
256   mame_timer_set(scale_up_mame_time(MAME_TIME_IN_HZ(400000), nb1413m3_busyctr), 0, blitter_timer_callback);
256   timer_set(attotime_mul(ATTOTIME_IN_HZ(400000), nb1413m3_busyctr), 0, blitter_timer_callback);
257257}
258258
259259/******************************************************************************
src/mame/video/freekick.c
r1293r1294
22
33#include "driver.h"
44
5tilemap *freek_tilemap;
5static tilemap *freek_tilemap;
66UINT8 *freek_videoram;
77
88
src/mame/video/atarisy1.c
r1293r1294
5353static UINT16 playfield_lookup[256];
5454static UINT8 playfield_tile_bank;
5555static UINT16 playfield_priority_pens;
56static mame_timer *yscroll_reset_timer;
56static emu_timer *yscroll_reset_timer;
5757
5858/* INT3 tracking */
5959static int next_timer_scanline;
60static mame_timer *scanline_timer;
61static mame_timer *int3off_timer;
60static emu_timer *scanline_timer;
61static emu_timer *int3off_timer;
6262
6363/* graphics bank tracking */
6464static UINT8 bank_gfx[3][8];
r1293r1294
201201   /* reset the statics */
202202   atarimo_set_yscroll(0, 256);
203203   next_timer_scanline = -1;
204   scanline_timer = mame_timer_alloc(int3_callback);
205   int3off_timer = mame_timer_alloc(int3off_callback);
206   yscroll_reset_timer = mame_timer_alloc(reset_yscroll_callback);
204   scanline_timer = timer_alloc(int3_callback);
205   int3off_timer = timer_alloc(int3off_callback);
206   yscroll_reset_timer = timer_alloc(reset_yscroll_callback);
207207}
208208
209209
r1293r1294
329329
330330   /* but since we've adjusted it, we must reset it to the normal value
331331       once we hit scanline 0 again */
332   mame_timer_adjust(yscroll_reset_timer, video_screen_get_time_until_pos(0, 0, 0), newscroll, time_zero);
332   timer_adjust(yscroll_reset_timer, video_screen_get_time_until_pos(0, 0, 0), newscroll, attotime_zero);
333333
334334   /* update the data */
335335   *atarigen_yscroll = newscroll;
r1293r1294
397397   atarigen_scanline_int_gen();
398398
399399   /* set a timer to turn it off */
400   mame_timer_adjust(int3off_timer, video_screen_get_scan_period(0), 0, time_zero);
400   timer_adjust(int3off_timer, video_screen_get_scan_period(0), 0, attotime_zero);
401401
402402   /* determine the time of the next one */
403403   next_timer_scanline = -1;
r1293r1294
476476
477477      /* set a new one */
478478      if (best != -1)
479         mame_timer_adjust(scanline_timer, video_screen_get_time_until_pos(0, best, 0), best, time_zero);
479         timer_adjust(scanline_timer, video_screen_get_time_until_pos(0, best, 0), best, attotime_zero);
480480      else
481         mame_timer_adjust(scanline_timer, time_never, 0, time_zero);
481         timer_adjust(scanline_timer, attotime_never, 0, attotime_zero);
482482   }
483483}
484484
src/mame/video/wgp.c
r1293r1294
1313static UINT16 wgp_piv_ctrl_reg;
1414static UINT16 wgp_piv_zoom[3],wgp_piv_scrollx[3],wgp_piv_scrolly[3];
1515UINT16 wgp_rotate_ctrl[8];
16int wgp_piv_xoffs,wgp_piv_yoffs;
16static int wgp_piv_xoffs,wgp_piv_yoffs;
1717
1818
1919
src/mame/video/sprint8.c
r1293r1294
150150      {
151151         if (p1[x] != 16 && p2[x] != 16)
152152         {
153            mame_timer_set(video_screen_get_time_until_pos(0, y + 24, x), p1[x], sprint8_collision_callback);
153            timer_set(video_screen_get_time_until_pos(0, y + 24, x), p1[x], sprint8_collision_callback);
154154         }
155155      }
156156   }
src/mame/video/ssv.c
r1293r1294
141141#include "ui.h"
142142#endif
143143
144int shadow_pen_mask, shadow_pen_shift;
144static int shadow_pen_mask, shadow_pen_shift;
145145
146void ssv_drawgfx(   mame_bitmap *bitmap, const gfx_element *gfx,
146static void ssv_drawgfx(   mame_bitmap *bitmap, const gfx_element *gfx,
147147               UINT32 code,UINT32 color,int flipx,int flipy,int x0,int y0,
148148               const rectangle *cliprect, int shadow   )
149149{
src/mame/video/tceptor.c
r1293r1294
276276   int len = 0x8000;
277277   int i;
278278
279   buffer = malloc(len);
279   buffer = malloc_or_die(len);
280280
281   assert_always(buffer, "Out of memory");
282
283281   /* expand rom tc2-19.10d */
284282   for (i = 0; i < len / 2; i++)
285283   {
r1293r1294
335333   UINT8 *dst;
336334   int i, y;
337335
338   dst = (UINT8 *)malloc(len);
339   assert_always(dst, "Out of memory");
336   dst = malloc_or_die(len);
340337
341338   for (i = 0; i < len / (4*4*16); i++)
342339      for (y = 0; y < 16; y++)
r1293r1294
391388   UINT8 *dst;
392389   int i;
393390
394   dst = (UINT8 *)malloc(len);
395   assert_always(dst, "Out of memory");
391   dst = malloc_or_die(len);
396392
397393   memset(dst, 0, len);
398394
src/mame/video/metro.c
r1293r1294
367367 the tile's sizes to be known at startup - which we don't!
368368*/
369369
370int metro_sprite_xoffs, metro_sprite_yoffs;
370static int metro_sprite_xoffs, metro_sprite_yoffs;
371371
372372
373373static void alloc_empty_tiles(void)
src/mame/video/angelkds.c
r1293r1294
124124   tilemap_set_scrollx(bgbot_tilemap, 0, data );
125125}
126126
127UINT8 angelkds_layer_ctrl;
127static UINT8 angelkds_layer_ctrl;
128128
129129WRITE8_HANDLER( angelkds_layer_ctrl_write )
130130{
src/mame/video/midvunit.c
r1293r1294
3434static UINT16 page_control;
3535static UINT8 video_changed;
3636
37static mame_timer *scanline_timer;
37static emu_timer *scanline_timer;
3838static poly_manager *poly;
3939
4040typedef struct _poly_extra_data poly_extra_data;
r1293r1294
5858   int scanline = param;
5959
6060   cpunum_set_input_line(0, 0, ASSERT_LINE);
61   mame_timer_adjust(scanline_timer, video_screen_get_time_until_pos(0, scanline + 1, 0), scanline, time_zero);
61   timer_adjust(scanline_timer, video_screen_get_time_until_pos(0, scanline + 1, 0), scanline, attotime_zero);
6262}
6363
6464
r1293r1294
7070
7171VIDEO_START( midvunit )
7272{
73   scanline_timer = mame_timer_alloc(scanline_timer_cb);
73   scanline_timer = timer_alloc(scanline_timer_cb);
7474   poly = poly_alloc(4000, sizeof(poly_extra_data), POLYFLAG_ALLOW_QUADS);
7575   add_exit_callback(machine, midvunit_exit);
7676}
r1293r1294
436436
437437   /* update the scanline timer */
438438   if (offset == 0)
439      mame_timer_adjust(scanline_timer, video_screen_get_time_until_pos(0, (data & 0x1ff) + 1, 0), data & 0x1ff, time_zero);
439      timer_adjust(scanline_timer, video_screen_get_time_until_pos(0, (data & 0x1ff) + 1, 0), data & 0x1ff, attotime_zero);
440440
441441   /* if something changed, update our parameters */
442442   if (old != video_regs[offset] && video_regs[6] != 0 && video_regs[11] != 0)
r1293r1294
448448      visarea.max_x = (video_regs[6] + video_regs[2] - video_regs[5]) % video_regs[6];
449449      visarea.min_y = 0;
450450      visarea.max_y = (video_regs[11] + video_regs[7] - video_regs[10]) % video_regs[11];
451      video_screen_configure(0, video_regs[6], video_regs[11], &visarea, HZ_TO_SUBSECONDS(MIDVUNIT_VIDEO_CLOCK / 2) * video_regs[6] * video_regs[11]);
451      video_screen_configure(0, video_regs[6], video_regs[11], &visarea, HZ_TO_ATTOSECONDS(MIDVUNIT_VIDEO_CLOCK / 2) * video_regs[6] * video_regs[11]);
452452   }
453453}
454454
src/mame/video/usgames.c
r1293r1294
33UINT8 *usg_videoram,*usg_charram;
44
55
6tilemap *usg_tilemap;
6static tilemap *usg_tilemap;
77
88
99
src/mame/video/suna16.c
r1293r1294
3939                ---- ---- --54 ----     ? (Bit 4 used by uballoon)
4040                ---- ---- ---- 3210     Source Row
4141
42    $10002.w                                -
42    $10002.w                            -
4343
4444
4545                            [ Sprite's Tiles Format ]
r1293r1294
6666   if (ACCESSING_LSB)
6767   {
6868      flip_screen_set( data & 1 );
69      color_bank = data & 4;
69      color_bank =   ( data & 4 ) >> 2;
7070   }
71   if (data & ~5)   logerror("CPU#0 PC %06X - Flip screen unknown bits: %04X\n", activecpu_get_pc(), data);
71   if (data & ~(1|4))   logerror("CPU#0 PC %06X - Flip screen unknown bits: %04X\n", activecpu_get_pc(), data);
7272}
7373
74WRITE16_HANDLER( bestbest_flipscreen_w )
75{
76   if (ACCESSING_LSB)
77   {
78      flip_screen_set( data & 0x10 );
79//      color_bank =   ( data & 0x07 );
80   }
81   if (data & ~(0x10))   logerror("CPU#0 PC %06X - Flip screen unknown bits: %04X\n", activecpu_get_pc(), data);
82}
7483
84
7585/***************************************************************************
7686
7787
r1293r1294
8292
8393VIDEO_START( suna16 )
8494{
85   paletteram16_2 = auto_malloc( 0x100 * sizeof(UINT16) );
95   paletteram16 = auto_malloc( machine->drv->total_colors * sizeof(UINT16) );
8696}
8797
8898READ16_HANDLER( suna16_paletteram16_r )
8999{
90   if (color_bank)   return paletteram16_2[offset];
91   else         return paletteram16[offset];
100   return paletteram16[offset + color_bank * 256];
92101}
93102
94103WRITE16_HANDLER( suna16_paletteram16_w )
95104{
96   if (color_bank)   data = COMBINE_DATA(&paletteram16_2[offset]);
97   else         data = COMBINE_DATA(&paletteram16[offset]);
98   palette_set_color_rgb( Machine, offset + (color_bank ? 0x100 : 0),pal5bit(data >> 0),pal5bit(data >> 5),pal5bit(data >> 10));
105   offset += color_bank * 256;
106   data = COMBINE_DATA(&paletteram16[offset]);
107   palette_set_color_rgb( Machine, offset, pal5bit(data >> 0),pal5bit(data >> 5),pal5bit(data >> 10));
99108}
100109
101110
r1293r1294
107116
108117***************************************************************************/
109118
110static void draw_sprites(running_machine *machine, mame_bitmap *bitmap, const rectangle *cliprect)
119static void draw_sprites(running_machine *machine, mame_bitmap *bitmap, const rectangle *cliprect, UINT16 *sprites, int gfx)
111120{
112121   int offs;
113122
114   int max_x   =   machine->screen[0].width   - 8;
123   int max_x   =   machine->screen[0].width  - 8;
115124   int max_y   =   machine->screen[0].height - 8;
116125
117126   for ( offs = 0xfc00/2; offs < 0x10000/2 ; offs += 4/2 )
r1293r1294
122131      int dx, dy;
123132      int flipx, y0;
124133
125      int y      =   spriteram16[ offs + 0 + 0x00000 / 2 ];
126      int x      =   spriteram16[ offs + 1 + 0x00000 / 2 ];
127      int dim    =   spriteram16[ offs + 0 + 0x10000 / 2 ];
134      int y      =   sprites[ offs + 0 + 0x00000 / 2 ];
135      int x      =   sprites[ offs + 1 + 0x00000 / 2 ];
136      int dim    =   sprites[ offs + 0 + 0x10000 / 2 ];
128137
129138      int bank   =   (x >> 12) & 0xf;
130139
r1293r1294
162171                        ((srcx + tile_x) & 0x1f) * 0x20 +
163172                        ((srcy + tile_y) & 0x1f);
164173
165            int tile   =   spriteram16[ addr + 0x00000 / 2 ];
166            int attr   =   spriteram16[ addr + 0x10000 / 2 ];
174            int tile   =   sprites[ addr + 0x00000 / 2 ];
175            int attr   =   sprites[ addr + 0x10000 / 2 ];
167176
168177            int sx      =   x + dx;
169178            int sy      =   (y + dy) & 0xff;
r1293r1294
181190               tile_flipy = !tile_flipy;
182191            }
183192
184            drawgfx(   bitmap, machine->gfx[0],
193            drawgfx(   bitmap, machine->gfx[gfx],
185194                     (tile & 0x3fff) + bank*0x4000,
186                     attr + (color_bank ? 0x10 : 0),
195                     attr + (color_bank << 4),
187196                     tile_flipx, tile_flipy,
188197                     sx, sy,
189198                     cliprect,TRANSPARENCY_PEN,15   );
r1293r1294
211220{
212221   /* Suna Quiz indicates the background is the last pen */
213222   fillbitmap(bitmap,machine->pens[0xff],cliprect);
214   draw_sprites(machine, bitmap, cliprect);
223   draw_sprites(machine, bitmap, cliprect, spriteram16, 0);
215224   return 0;
216225}
226
227VIDEO_UPDATE( bestbest )
228{
229   int layers_ctrl = -1;
230
231#ifdef MAME_DEBUG
232if (input_code_pressed(KEYCODE_Z))
233{   int msk = 0;
234   if (input_code_pressed(KEYCODE_Q))   msk |= 1;
235   if (input_code_pressed(KEYCODE_W))   msk |= 2;
236   if (msk != 0) layers_ctrl &= msk;
237}
238#endif
239
240   /* Suna Quiz indicates the background is the last pen */
241   fillbitmap(bitmap,machine->pens[0xff],cliprect);
242   if (layers_ctrl & 1)   draw_sprites(machine, bitmap, cliprect, spriteram16,   0);
243   if (layers_ctrl & 2)   draw_sprites(machine, bitmap, cliprect, spriteram16_2, 1);
244   return 0;
245}
src/mame/video/gtia.c
r1293r1294
146146
147147static int is_ntsc(void)
148148{
149   return SUBSECONDS_TO_HZ(Machine->screen[0].refresh) > 55;
149   return ATTOSECONDS_TO_HZ(Machine->screen[0].refresh) > 55;
150150}
151151
152152
src/mame/video/atarisy2.c
r1293r1294
2727 *
2828 *************************************/
2929
30static mame_timer *yscroll_reset_timer;
30static emu_timer *yscroll_reset_timer;
3131static UINT32 playfield_tile_bank[2];
3232static UINT32 videobank;
3333static UINT16 *vram;
r1293r1294
133133   tilemap_set_transparent_pen(atarigen_alpha_tilemap, 0);
134134
135135   /* reset the statics */
136   yscroll_reset_timer = mame_timer_alloc(reset_yscroll_callback);
136   yscroll_reset_timer = timer_alloc(reset_yscroll_callback);
137137   videobank = 0;
138138}
139139
r1293r1294
190190   if (!(newscroll & 0x10))
191191      tilemap_set_scrolly(atarigen_playfield_tilemap, 0, (newscroll >> 6) - video_screen_get_vpos(0));
192192   else
193      mame_timer_adjust(yscroll_reset_timer, video_screen_get_time_until_pos(0, 0, 0), newscroll >> 6, time_zero);
193      timer_adjust(yscroll_reset_timer, video_screen_get_time_until_pos(0, 0, 0), newscroll >> 6, attotime_zero);
194194
195195   /* update the playfield banking */
196196   if (playfield_tile_bank[1] != (newscroll & 0x0f) * 0x400)
src/mame/video/mjsister.c
r1293r1294
2929   mjsister_videoram1 = auto_malloc(0x8000);
3030}
3131
32void mjsister_plot0(int offset,UINT8 data)
32static void mjsister_plot0(int offset,UINT8 data)
3333{
3434   int x,y,c1,c2;
3535
r1293r1294
4343   *BITMAP_ADDR16(mjsister_tmpbitmap0, y, x*2+1) = Machine->pens[c2];
4444}
4545
46void mjsister_plot1(int offset,UINT8 data)
46static void mjsister_plot1(int offset,UINT8 data)
4747{
4848   int x,y,c1,c2;
4949
src/mame/video/jaguar.c
r1293r1294
190190static UINT32 blitter_regs[BLITTER_REGS];
191191static UINT16 gpu_regs[GPU_REGS];
192192
193static mame_timer *vi_timer;
193static emu_timer *vi_timer;
194194static UINT8 cpu_irq_state;
195195
196196static pen_t *pen_table;
r1293r1294
277277
278278   cpu_irq_state |= 1;
279279   update_cpu_irq();
280   mame_timer_adjust(vi_timer, video_screen_get_time_until_pos(0, scanline, 0), scanline, time_zero);
280   timer_adjust(vi_timer, video_screen_get_time_until_pos(0, scanline, 0), scanline, attotime_zero);
281281}
282282
283283
r1293r1294
302302 *
303303 *************************************/
304304
305void jaguar_set_palette(UINT16 vmode)
305static void jaguar_set_palette(UINT16 vmode)
306306{
307307   static const UINT8 red_lookup[256] =
308308   {
r1293r1294
648648      {
649649         case VI:
650650            scanline = (gpu_regs[VI] - gpu_regs[VBE]) / 2;
651            mame_timer_adjust(vi_timer, video_screen_get_time_until_pos(0, scanline, 0), scanline, time_zero);
651            timer_adjust(vi_timer, video_screen_get_time_until_pos(0, scanline, 0), scanline, attotime_zero);
652652            break;
653653
654654         case INT1:
r1293r1294
734734
735735   pen_table = auto_malloc(65536 * sizeof(pen_t));
736736
737   vi_timer = mame_timer_alloc(vi_callback);
737   vi_timer = timer_alloc(vi_callback);
738738
739739   state_save_register_global_pointer(pen_table, 65536);
740740   state_save_register_global_array(blitter_regs);
src/mame/video/n8080.c
r1293r1294
1313
1414int helifire_flash;
1515
16static mame_timer* cannon_timer;
16static emu_timer* cannon_timer;
1717
1818static int sheriff_color_mode;
1919static int sheriff_color_data;
r1293r1294
6565{
6666   spacefev_red_cannon = 1;
6767
68   mame_timer_adjust(cannon_timer, MAME_TIME_IN_USEC(550 * 68 * 10), 0, time_zero);
68   timer_adjust(cannon_timer, ATTOTIME_IN_USEC(550 * 68 * 10), 0, attotime_zero);
6969}
7070
7171
r1293r1294
7373{
7474   spacefev_red_cannon = 0;
7575
76   mame_timer_adjust(cannon_timer, time_never, 0, time_never);
76   timer_adjust(cannon_timer, attotime_never, 0, attotime_never);
7777}
7878
7979
80void helifire_next_line(void)
80static void helifire_next_line(void)
8181{
8282   helifire_mv++;
8383
r1293r1294
106106
107107VIDEO_START( spacefev )
108108{
109   cannon_timer = mame_timer_alloc(spacefev_stop_red_cannon);
109   cannon_timer = timer_alloc(spacefev_stop_red_cannon);
110110
111111   flip_screen = 0;
112112
src/mame/video/nbmj8891.c
r1293r1294
479479   }
480480
481481   nb1413m3_busyflag = 0;
482   mame_timer_set(scale_up_mame_time(MAME_TIME_IN_HZ(400000), nb1413m3_busyctr), 0, blitter_timer_callback);
482   timer_set(attotime_mul(ATTOTIME_IN_HZ(400000), nb1413m3_busyctr), 0, blitter_timer_callback);
483483}
484484
485485/******************************************************************************
src/mame/video/gcpinbal.c
r1293r1294
6464}
6565#endif
6666
67void gcpinbal_core_vh_start (void)
67static void gcpinbal_core_vh_start (void)
6868{
6969   int xoffs = 0;
7070   int yoffs = 0;
src/mame/video/segag80v.c
r1293r1294
110110}
111111
112112
113void sega_generate_vector_list(void)
113static void sega_generate_vector_list(void)
114114{
115115   UINT8 *sintable = memory_region(REGION_PROMS);
116116   double total_time = 1.0 / (double)IRQ_CLOCK;
src/mame/video/m62.c
r1293r1294
2727static INT32 m62_background_hscroll;
2828static INT32 m62_background_vscroll;
2929
30UINT8 *irem_textram;
31size_t irem_textram_size;
30static UINT8 *irem_textram;
31static size_t irem_textram_size;
3232
3333static UINT8 kidniki_background_bank;
3434static INT32 kidniki_text_vscroll;
r1293r1294
364364   }
365365}
366366
367void m62_start( tile_get_info_callback tile_get_info, int rows, int cols, int x1, int y1, int x2, int y2 )
367static void m62_start( tile_get_info_callback tile_get_info, int rows, int cols, int x1, int y1, int x2, int y2 )
368368{
369369   m62_background = tilemap_create( tile_get_info, tilemap_scan_rows, TILEMAP_TYPE_PEN, x1, y1, x2, y2 );
370370
r1293r1294
383383   }
384384}
385385
386void m62_textlayer( tile_get_info_callback tile_get_info, int rows, int cols, int x1, int y1, int x2, int y2 )
386static void m62_textlayer( tile_get_info_callback tile_get_info, int rows, int cols, int x1, int y1, int x2, int y2 )
387387{
388388   m62_foreground = tilemap_create( tile_get_info, tilemap_scan_rows, TILEMAP_TYPE_PEN, x1, y1, x2, y2 );
389389
src/mame/video/astrocde.c
r1293r1294
4747static UINT8 horizontal_feedback;
4848
4949/* Astrocade video parameters */
50static mame_timer *scanline_timer;
50static emu_timer *scanline_timer;
5151static UINT8 colors[8];
5252static UINT8 colorsplit;
5353static UINT8 bgdata;
r1293r1294
224224VIDEO_START( astrocde )
225225{
226226   /* allocate a per-scanline timer */
227   scanline_timer = mame_timer_alloc(scanline_callback);
228   mame_timer_adjust(scanline_timer, video_screen_get_time_until_pos(0, 1, 0), 1, time_zero);
227   scanline_timer = timer_alloc(scanline_callback);
228   timer_adjust(scanline_timer, video_screen_get_time_until_pos(0, 1, 0), 1, attotime_zero);
229229
230230   /* register for save states */
231231   init_savestate();
r1293r1294
239239VIDEO_START( profpac )
240240{
241241   /* allocate a per-scanline timer */
242   scanline_timer = mame_timer_alloc(scanline_callback);
243   mame_timer_adjust(scanline_timer, video_screen_get_time_until_pos(0, 1, 0), 1, time_zero);
242   scanline_timer = timer_alloc(scanline_callback);
243   timer_adjust(scanline_timer, video_screen_get_time_until_pos(0, 1, 0), 1, attotime_zero);
244244
245245   /* allocate videoram */
246246   profpac_videoram = auto_malloc(0x4000 * 4 * sizeof(*profpac_videoram));
r1293r1294
444444      else
445445      {
446446         cpunum_set_input_line_and_vector(0, 0, ASSERT_LINE, interrupt_vector & 0xf0);
447         mame_timer_set(MAME_TIME_IN_CYCLES(1, 0), 0, interrupt_off);
447         timer_set(ATTOTIME_IN_CYCLES(1, 0), 0, interrupt_off);
448448      }
449449
450450      /* latch the feedback registers */
r1293r1294
480480      else
481481      {
482482         cpunum_set_input_line_and_vector(0, 0, ASSERT_LINE, interrupt_vector);
483         mame_timer_set(MAME_TIME_IN_CYCLES(1, 0), 0, interrupt_off);
483         timer_set(ATTOTIME_IN_CYCLES(1, 0), 0, interrupt_off);
484484      }
485485   }
486486
r1293r1294
492492   scanline++;
493493   if (scanline >= machine->screen[0].height)
494494      scanline = 0;
495   mame_timer_adjust(scanline_timer, video_screen_get_time_until_pos(0, scanline, 0), scanline, time_zero);
495   timer_adjust(scanline_timer, video_screen_get_time_until_pos(0, scanline, 0), scanline, attotime_zero);
496496}
497497
498498
src/mame/video/renegade.c
r1293r1294
77#include "driver.h"
88
99UINT8 *renegade_videoram2;
10INT32 renegade_scrollx;
10static INT32 renegade_scrollx;
1111static tilemap *bg_tilemap;
1212static tilemap *fg_tilemap;
1313
src/mame/video/nbmj8688.c
r1293r1294
542542   nb1413m3_busyflag = 0;
543543
544544   if (gfxtype == GFXTYPE_8BIT)
545      mame_timer_set(scale_up_mame_time(MAME_TIME_IN_HZ(400000), nb1413m3_busyctr), 0, blitter_timer_callback);
545      timer_set(attotime_mul(ATTOTIME_IN_HZ(400000), nb1413m3_busyctr), 0, blitter_timer_callback);
546546   else
547      mame_timer_set(scale_up_mame_time(MAME_TIME_IN_HZ(400000), nb1413m3_busyctr), 0, blitter_timer_callback);
547      timer_set(attotime_mul(ATTOTIME_IN_HZ(400000), nb1413m3_busyctr), 0, blitter_timer_callback);
548548}
549549
550550
src/mame/video/psychic5.c
r1293r1294
5252   title_screen = data & 0x01;
5353}
5454
55void psychic5_paletteram_w(int color_offs, int offset, int data)
55static void psychic5_paletteram_w(int color_offs, int offset, int data)
5656{
5757   int r,g,b,a,val;
5858
src/mame/video/slapshot.c
r1293r1294
451451   }
452452}
453453
454void taito_update_sprites_active_area(void)
454static void taito_update_sprites_active_area(void)
455455{
456456   int off;
457457
src/mame/video/victory.c
r1293r1294
3434   UINT8      r,g,b;
3535   UINT8      x,xp,y,yp;
3636   UINT8      cmd,cmdlo;
37   mame_timer *   timer;
37   emu_timer *   timer;
3838   UINT8      timer_active;
39   mame_time   endtime;
39   attotime   endtime;
4040} micro;
4141
4242
r1293r1294
4444/* from what I can tell, this should be divided by 32, not 8  */
4545/* but the interrupt test does some precise timing, and fails */
4646/* if it's not 8 */
47#define MICRO_STATE_CLOCK_PERIOD   MAME_TIME_IN_HZ(11827000/8)
47#define MICRO_STATE_CLOCK_PERIOD   ATTOTIME_IN_HZ(11827000/8)
4848
4949
5050/* debugging constants */
r1293r1294
9797   update_complete = 0;
9898   video_control = 0;
9999   memset(&micro, 0, sizeof(micro));
100   micro.timer = mame_timer_alloc(NULL);
100   micro.timer = timer_alloc(NULL);
101101}
102102
103103
r1293r1294
108108 *
109109 *************************************/
110110
111void victory_update_irq(void)
111static void victory_update_irq(void)
112112{
113113   if (vblank_irq || fgcoll || (bgcoll && (video_control & 0x20)))
114114      cpunum_set_input_line(0, 0, ASSERT_LINE);
r1293r1294
221221         // D5 = 5VIRQ
222222         // D4 = 5BCIRQ (3B1)
223223         // D3 = SL256
224         if (micro.timer_active && compare_mame_times(mame_timer_timeelapsed(micro.timer), micro.endtime) < 0)
224         if (micro.timer_active && attotime_compare(timer_timeelapsed(micro.timer), micro.endtime) < 0)
225225            result |= 0x80;
226226         result |= (~fgcoll & 1) << 6;
227227         result |= (~vblank_irq & 1) << 5;
r1293r1294
555555
556556INLINE void count_states(int states)
557557{
558   mame_time state_time = make_mame_time(0, mame_time_to_subseconds(MICRO_STATE_CLOCK_PERIOD) * states);
558   attotime state_time = attotime_make(0, attotime_to_attoseconds(MICRO_STATE_CLOCK_PERIOD) * states);
559559
560560   if (!micro.timer)
561561   {
562      mame_timer_adjust(micro.timer, time_never, 0, time_zero);
562      timer_adjust(micro.timer, attotime_never, 0, attotime_zero);
563563      micro.timer_active = 1;
564564      micro.endtime = state_time;
565565   }
566   else if (compare_mame_times(mame_timer_timeelapsed(micro.timer), micro.endtime) > 0)
566   else if (attotime_compare(timer_timeelapsed(micro.timer), micro.endtime) > 0)
567567   {
568      mame_timer_adjust(micro.timer, time_never, 0, time_zero);
568      timer_adjust(micro.timer, attotime_never, 0, attotime_zero);
569569      micro.timer_active = 1;
570570      micro.endtime = state_time;
571571   }
572572   else
573      micro.endtime = add_mame_times(micro.endtime, state_time);
573      micro.endtime = attotime_add(micro.endtime, state_time);
574574}
575575
576576
r1293r1294
11801180         int fpix = *fg++;
11811181         int bpix = bg[(x + scrollx) & 255];
11821182         if (fpix && (bpix & bgcollmask) && count++ < 128)
1183            mame_timer_set(video_screen_get_time_until_pos(0, y, x), x | (y << 8), bgcoll_irq_callback);
1183            timer_set(video_screen_get_time_until_pos(0, y, x), x | (y << 8), bgcoll_irq_callback);
11841184      }
11851185   }
11861186}
r1293r1294
12181218         int bpix = bg[(x + scrollx) & 255];
12191219         scanline[x] = bpix | (fpix << 3);
12201220         if (fpix && (bpix & bgcollmask) && count++ < 128)
1221            mame_timer_set(video_screen_get_time_until_pos(0, y, x), x | (y << 8), bgcoll_irq_callback);
1221            timer_set(video_screen_get_time_until_pos(0, y, x), x | (y << 8), bgcoll_irq_callback);
12221222      }
12231223
12241224      /* draw the scanline */
src/mame/video/ladyfrog.c
r1293r1294
1414
1515UINT8 *ladyfrog_scrlram;
1616
17UINT8 *ladyfrog_spriteram;
17static UINT8 *ladyfrog_spriteram;
1818extern UINT8 *ladyfrog_sharedram;
1919
2020WRITE8_HANDLER(ladyfrog_spriteram_w)
src/mame/video/taitosj.c
r1293r1294
2020UINT8 *taitosj_gfxpointer;
2121UINT8 *taitosj_colorbank,*taitosj_video_priority;
2222UINT8 *kikstart_scrollram;
23UINT8 *taitosj_spritebank;
23static UINT8 *taitosj_spritebank;
2424static UINT8 taitosj_collision_reg[4];
2525static UINT8 *dirtybuffer2,*dirtybuffer3;
2626static mame_bitmap *taitosj_tmpbitmap[3];
src/mame/video/vigilant.c
r1293r1294
2323   6*8, 32*8-1
2424};
2525
26UINT8 *vigilant_paletteram;
27UINT8 *vigilant_sprite_paletteram;
26//UINT8 *vigilant_paletteram;
27//UINT8 *vigilant_sprite_paletteram;
2828
2929static int horiz_scroll_low=0;
3030static int horiz_scroll_high=0;
src/mame/video/avgdvg.c
r1293r1294
125125
126126static int xmin, xmax, ymin, ymax;
127127static int xcenter, ycenter;
128static mame_timer *vg_run_timer, *vg_halt_timer;
128static emu_timer *vg_run_timer, *vg_halt_timer;
129129
130130static int flip_x, flip_y;
131131
r1293r1294
12001200
12011201      /* If halt flag was set, let CPU catch up before we make halt visible */
12021202      if (vg->halt && !(vg->state_latch & 0x10))
1203         mame_timer_adjust(vg_halt_timer, scale_up_mame_time(MAME_TIME_IN_HZ(MASTER_CLOCK), cycles), 1, time_zero);
1203         timer_adjust(vg_halt_timer, attotime_mul(ATTOTIME_IN_HZ(MASTER_CLOCK), cycles), 1, attotime_zero);
12041204
12051205      vg->state_latch = (vg->halt << 4) | (vg->state_latch & 0xf);
12061206      cycles += 8;
12071207   }
12081208
1209   mame_timer_adjust(vg_run_timer, scale_up_mame_time(MAME_TIME_IN_HZ(MASTER_CLOCK), cycles), 0, time_zero);
1209   timer_adjust(vg_run_timer, attotime_mul(ATTOTIME_IN_HZ(MASTER_CLOCK), cycles), 0, attotime_zero);
12101210}
12111211
12121212
r1293r1294
12361236
12371237   vgc->vggo(vg);
12381238   vg_set_halt(0);
1239   mame_timer_adjust(vg_run_timer, time_zero, 0, time_zero);
1239   timer_adjust(vg_run_timer, attotime_zero, 0, attotime_zero);
12401240}
12411241
12421242WRITE16_HANDLER( avgdvg_go_word_w )
r1293r1294
12861286
12871287   flip_x = flip_y = 0;
12881288
1289   vg_halt_timer = mame_timer_alloc(vg_set_halt_callback);
1290   vg_run_timer = mame_timer_alloc(run_state_machine);
1289   vg_halt_timer = timer_alloc(vg_set_halt_callback);
1290   vg_run_timer = timer_alloc(run_state_machine);
12911291
12921292   /*
12931293     * The x and y DACs use 10 bit of the counter values which are in
src/mame/video/nbmj8991.c
r1293r1294
287287   }
288288
289289   nb1413m3_busyflag = 0;
290   mame_timer_set(scale_up_mame_time(MAME_TIME_IN_NSEC(1650), nb1413m3_busyctr), 0, blitter_timer_callback);
290   timer_set(attotime_mul(ATTOTIME_IN_NSEC(1650), nb1413m3_busyctr), 0, blitter_timer_callback);
291291}
292292
293293/******************************************************************************
src/mame/video/tsamurai.c
r1293r1294
229229
230230***************************************************************************/
231231
232int vsgongf_color;
232static int vsgongf_color;
233233
234234WRITE8_HANDLER( vsgongf_color_w )
235235{
src/mame/video/namcos2.c
r1293r1294
77UINT16 *namcos2_sprite_ram;
88UINT16 *namcos2_68k_palette_ram;
99size_t namcos2_68k_palette_size;
10size_t namcos2_68k_roz_ram_size;
10//size_t namcos2_68k_roz_ram_size;
1111UINT16 *namcos2_68k_roz_ram;
1212
1313static UINT16 namcos2_68k_roz_ctrl[0x8];
src/mame/video/route16.c
r1293r1294
1313UINT8 *route16_videoram1;
1414UINT8 *route16_videoram2;
1515size_t route16_videoram_size;
16int route16_hardware;
16//int route16_hardware;
1717
1818static UINT8 flipscreen;
1919static UINT8 palette_1;
src/mame/video/exidy440.c
r1293r1294
2929static UINT8 palettebank_vis;
3030
3131/* function prototypes */
32void exidy440_update_firq(void);
32static void exidy440_update_firq(void);
3333
3434
3535
r1293r1294
354354
355355                  /* check the collisions bit */
356356                  if ((palette[2 * pen] & 0x80) && count++ < 128)
357                     mame_timer_set(video_screen_get_time_until_pos(0, yoffs, currx), currx, collide_firq_callback);
357                     timer_set(video_screen_get_time_until_pos(0, yoffs, currx), currx, collide_firq_callback);
358358               }
359359               currx++;
360360
r1293r1294
367367
368368                  /* check the collisions bit */
369369                  if ((palette[2 * pen] & 0x80) && count++ < 128)
370                     mame_timer_set(video_screen_get_time_until_pos(0, yoffs, currx), currx, collide_firq_callback);
370                     timer_set(video_screen_get_time_until_pos(0, yoffs, currx), currx, collide_firq_callback);
371371               }
372372               currx++;
373373            }
r1293r1294
438438   /* generate an interrupt once/frame for the beam */
439439   if (!exidy440_topsecret)
440440   {
441      mame_time time;
442      subseconds_t increment;
441      attotime time;
442      attoseconds_t increment;
443443      int beamx, beamy;
444444      int i;
445445
r1293r1294
452452            From this, it appears that they are expecting to get beams over
453453            a 12 scanline period, and trying to pick roughly the middle one.
454454            This is how it is implemented. */
455      increment =  mame_time_to_subseconds(video_screen_get_scan_period(0));
456      time = sub_mame_times(video_screen_get_time_until_pos(0, beamy, beamx), make_mame_time(0, increment * 6));
455      increment = attotime_to_attoseconds(video_screen_get_scan_period(0));
456      time = attotime_sub(video_screen_get_time_until_pos(0, beamy, beamx), attotime_make(0, increment * 6));
457457      for (i = 0; i <= 12; i++)
458458      {
459         mame_timer_set(time, beamx, beam_firq_callback);
460         time = add_mame_times(time, make_mame_time(0, increment));
459         timer_set(time, beamx, beam_firq_callback);
460         time = attotime_add(time, attotime_make(0, increment));
461461      }
462462   }
463463}
src/mame/video/blstroid.c
r1293r1294
119119   if (offset < 0x1000)
120120      if (atarigen_playfield[offset] & 0x8000)
121121      {
122         mame_time period_on;
123         mame_time period_off;
122         attotime period_on;
123         attotime period_off;
124124
125125         /* fix me - the only thing this IRQ does it tweak the starting MO link */
126126         /* unfortunately, it does it too early for the given MOs! */
r1293r1294
132132         period_on  = video_screen_get_time_until_pos(scrnum, video_screen_get_vpos(scrnum) + 7, machine->screen[scrnum].width * 0.9);
133133         period_off = video_screen_get_time_until_pos(scrnum, video_screen_get_vpos(scrnum) + 8, machine->screen[scrnum].width * 0.9);
134134
135         mame_timer_set(period_on,  0, irq_on);
136         mame_timer_set(period_off, 0, irq_off);
135         timer_set(period_on,  0, irq_on);
136         timer_set(period_off, 0, irq_off);
137137      }
138138}
139139
src/mame/video/tatsumi.c
r1293r1294
88UINT16 *roundup_r_ram, *roundup_p_ram, *roundup_l_ram;
99UINT16 *cyclwarr_videoram, *cyclwarr_videoram2;
1010UINT16* tatsumi_sprite_control_ram;
11UINT16* roundup5_vram;
11static UINT16* roundup5_vram;
1212
1313/******************************************************************************/
1414
src/mame/video/konamiic.c
r1293r1294
29912991}
29922992
29932993
2994void K053245_chip_w(int chip,int offset,int data)
2994static void K053245_chip_w(int chip,int offset,int data)
29952995{
29962996   if(offset & 1)
29972997      K053245_ram[chip][offset>>1] = (K053245_ram[chip][offset>>1] & 0xff00) | data;
r1293r1294
30213021   memcpy(K053245_buffer[chip], K053245_ram[chip], K053245_ramsize[chip]);
30223022}
30233023
3024UINT8 K053244_chip_r (int chip, int offset)
3024static UINT8 K053244_chip_r (int chip, int offset)
30253025{
30263026   if ((K053244_regs[chip][5] & 0x10) && offset >= 0x0c && offset < 0x10)
30273027   {
r1293r1294
30533053   return K053244_chip_r(0,offset);
30543054}
30553055
3056void K053244_chip_w(int chip, int offset, int data)
3056static void K053244_chip_w(int chip, int offset, int data)
30573057{
30583058   K053244_regs[chip][offset] = data;
30593059
r1293r1294
45204520static TILE_GET_INFO( K051316_get_tile_info2 ) { K051316_get_tile_info(machine,tileinfo,tile_index,2); }
45214521
45224522
4523void K051316_vh_start(running_machine *machine,int chip, int gfx_memory_region,int bpp,
4523static void K051316_vh_start(running_machine *machine,int chip, int gfx_memory_region,int bpp,
45244524      int pen_is_mask,int transparent_pen,
45254525      void (*callback)(int *code,int *color,int *flags))
45264526{
r1293r1294
46374637}
46384638
46394639
4640int K051316_r(int chip, int offset)
4640static int K051316_r(int chip, int offset)
46414641{
46424642   return K051316_ram[chip][offset];
46434643}
r1293r1294
46584658}
46594659
46604660
4661void K051316_w(int chip,int offset,int data)
4661static void K051316_w(int chip,int offset,int data)
46624662{
46634663   K051316_ram[chip][offset] = data;
46644664   tilemap_mark_tile_dirty(K051316_tilemap[chip],offset & 0x3ff);
r1293r1294
46804680}
46814681
46824682
4683int K051316_rom_r(int chip, int offset)
4683static int K051316_rom_r(int chip, int offset)
46844684{
46854685   if ((K051316_ctrlram[chip][0x0e] & 0x01) == 0)
46864686   {
r1293r1294
47184718
47194719
47204720
4721void K051316_ctrl_w(int chip,int offset,int data)
4721static void K051316_ctrl_w(int chip,int offset,int data)
47224722{
47234723   K051316_ctrlram[chip][offset] = data;
47244724//if (offset >= 0x0c) logerror("%04x: write %02x to 051316 reg %x\n",activecpu_get_pc(),data,offset);
r1293r1294
47514751}
47524752
47534753
4754void K051316_zoom_draw(int chip, mame_bitmap *bitmap,const rectangle *cliprect,int flags,UINT32 priority)
4754static void K051316_zoom_draw(int chip, mame_bitmap *bitmap,const rectangle *cliprect,int flags,UINT32 priority)
47554755{
47564756   UINT32 startx,starty;
47574757   int incxx,incxy,incyx,incyy;
r1293r1294
52465246static UINT16 K056832_regsb[4];   // 157/832 regs group 2, board dependent
52475247
52485248static UINT8 *K056832_rombase;   // pointer to tile gfx data
5249UINT16 *K056832_videoram;
5249static UINT16 *K056832_videoram;
52505250static int K056832_NumGfxBanks;      // depends on size of graphics ROMs
52515251static int K056832_CurGfxBank;      // cached info for K056832_regs[0x1a]
52525252static int K056832_gfxnum;         // graphics element index for unpacked tiles
src/mame/video/gsword.c
r1293r1294
99
1010size_t gsword_spritexy_size;
1111
12UINT8 *gsword_scrolly_ram;
12//UINT8 *gsword_scrolly_ram;
1313UINT8 *gsword_spritexy_ram;
1414UINT8 *gsword_spritetile_ram;
1515UINT8 *gsword_spriteattrib_ram;
src/mame/video/csk.c
r1293r1294
1010
1111#define CPK_VIDEO_SIZE   0x800
1212
13UINT8 * cpk_colorram;
14UINT8 * cpk_videoram;
15UINT8 * cpk_palette;
16UINT8 * cpk_palette2;
17UINT8 * cpk_expram;
13static UINT8 * cpk_colorram;
14static UINT8 * cpk_videoram;
15static UINT8 * cpk_palette;
16static UINT8 * cpk_palette2;
17static UINT8 * cpk_expram;
1818
1919static UINT8 * dirtybuffer1;
2020static mame_bitmap *tmpbitmap2;
src/mame/video/momoko.c
r1293r1294
1212
1313UINT8 *momoko_bg_scrollx;
1414UINT8 *momoko_bg_scrolly;
15UINT8 momoko_fg_scrollx;
16UINT8 momoko_fg_scrolly;
17UINT8 momoko_fg_select;
18UINT8 momoko_text_scrolly;
19UINT8 momoko_text_mode;
20UINT8 momoko_bg_select;
21UINT8 momoko_bg_priority;
22UINT8 momoko_bg_mask;
23UINT8 momoko_fg_mask;
24UINT8 momoko_flipscreen;
15static UINT8 momoko_fg_scrollx;
16static UINT8 momoko_fg_scrolly;
17static UINT8 momoko_fg_select;
18static UINT8 momoko_text_scrolly;
19static UINT8 momoko_text_mode;
20static UINT8 momoko_bg_select;
21static UINT8 momoko_bg_priority;
22static UINT8 momoko_bg_mask;
23static UINT8 momoko_fg_mask;
24static UINT8 momoko_flipscreen;
2525
2626/****************************************************************************/
2727
src/mame/video/dday.c
r1293r1294
4848{
4949   timer_value = 0;
5050
51   mame_timer_pulse(MAME_TIME_IN_SEC(1), 0, countdown_timer_callback);
51   timer_pulse(ATTOTIME_IN_SEC(1), 0, countdown_timer_callback);
5252}
5353
5454
src/mame/video/atari.c
r1293r1294
10671067
10681068static void after(int cycles, void (*function)(running_machine *machine, int), const char *funcname)
10691069{
1070    mame_time duration = make_mame_time(0, mame_time_to_subseconds(video_screen_get_scan_period(0)) * cycles / CYCLES_PER_LINE);
1070    attotime duration = attotime_make(0, attotime_to_attoseconds(video_screen_get_scan_period(0)) * cycles / CYCLES_PER_LINE);
10711071    (void)funcname;
1072   LOG(("           after %3d (%5.1f us) %s\n", cycles, mame_time_to_double(duration) * 1.0e6, funcname));
1073   mame_timer_set(duration, 0, function);
1072   LOG(("           after %3d (%5.1f us) %s\n", cycles, attotime_to_double(duration) * 1.0e6, funcname));
1073   timer_set(duration, 0, function);
10741074}
10751075
10761076static TIMER_CALLBACK( antic_issue_dli )
src/mame/video/segas32.c
r1293r1294
378378{
379379   /* at the end of VBLANK is when automatic sprite rendering happens */
380380   if (!state)
381      mame_timer_set(MAME_TIME_IN_USEC(50), 1, update_sprites);
381      timer_set(ATTOTIME_IN_USEC(50), 1, update_sprites);
382382}
383383
384384
src/mame/video/psikyosh.c
r1293r1294
392392/* sx and sy is top-left of entire sprite regardless of flip */
393393/* Note that Level 5-4 of sbomberb boss is perfect! (Alpha blended zoomed) as well as S1945II logo */
394394/* pixel is only plotted if z is >= priority_buffer[y][x] */
395void psikyosh_drawgfxzoom( mame_bitmap *dest_bmp,const gfx_element *gfx,
395static void psikyosh_drawgfxzoom( mame_bitmap *dest_bmp,const gfx_element *gfx,
396396      UINT32 code,UINT32 color,int flipx,int flipy,int offsx,int offsy,
397397      const rectangle *clip,int transparency,int transparent_color,
398398      int zoomx, int zoomy, int wide, int high, UINT32 z)
src/mame/video/kan_pand.c
r1293r1294
7070}
7171
7272
73void pandora_draw(running_machine *machine, mame_bitmap *bitmap, const rectangle *cliprect)
73static void pandora_draw(running_machine *machine, mame_bitmap *bitmap, const rectangle *cliprect)
7474{
7575
7676   int sx=0, sy=0, x=0, y=0, offs;
src/mame/video/decocass.c
r1293r1294
618618#if TAPE_UI_DISPLAY
619619   if (tape_timer)
620620   {
621      mame_time tape_time = decocass_adjust_tape_time(tape_time0);
621      attotime tape_time = decocass_adjust_tape_time(tape_time0);
622622      popmessage("%c%c [%05.1fs] %c%c",
623623         (tape_dir < 0 && tape_speed) ? '<' : ' ',
624624         (tape_dir < 0) ? '<' : ' ',
625         mame_time_to_double(tape_time),
625         attotime_to_double(tape_time),
626626         (tape_dir > 0) ? '>' : ' ',
627627         (tape_dir > 0 && tape_speed) ? '>' : ' ');
628628   }
src/mame/video/fromance.c
r1293r1294
2525
2626static UINT8 crtc_register;
2727static UINT8 crtc_data[0x10];
28static mame_timer *crtc_timer;
28static emu_timer *crtc_timer;
2929
3030static UINT8 flipscreen_old = -1;
3131
r1293r1294
9090   tilemap_set_transparent_pen(fg_tilemap,15);
9191
9292   /* reset the timer */
93   crtc_timer = mame_timer_alloc(crtc_interrupt_gen);
93   crtc_timer = timer_alloc(crtc_interrupt_gen);
9494
9595   scrollx_ofs = 0x159;
9696   scrolly_ofs = 0x10;
r1293r1294
129129   tilemap_set_transparent_pen(fg_tilemap,15);
130130
131131   /* reset the timer */
132   crtc_timer = mame_timer_alloc(crtc_interrupt_gen);
132   crtc_timer = timer_alloc(crtc_interrupt_gen);
133133
134134   scrollx_ofs = 0x159;
135135   scrolly_ofs = 0x10;
r1293r1294
294294{
295295   cpunum_set_input_line(1, 0, HOLD_LINE);
296296   if (param != 0)
297      mame_timer_adjust(crtc_timer, make_mame_time(0, machine->screen[0].refresh / param), 0, make_mame_time(0, machine->screen[0].refresh / param));
297      timer_adjust(crtc_timer, attotime_make(0, machine->screen[0].refresh / param), 0, attotime_make(0, machine->screen[0].refresh / param));
298298}
299299
300300
r1293r1294
306306   {
307307      /* only register we know about.... */
308308      case 0x0b:
309         mame_timer_adjust(crtc_timer, video_screen_get_time_until_pos(0, Machine->screen[0].visarea.max_y + 1, 0), (data > 0x80) ? 2 : 1, time_zero);
309         timer_adjust(crtc_timer, video_screen_get_time_until_pos(0, Machine->screen[0].visarea.max_y + 1, 0), (data > 0x80) ? 2 : 1, attotime_zero);
310310         break;
311311
312312      default:
src/mame/video/neogeo.c
r1293r1294
3030static UINT8 auto_animation_disabled;
3131static UINT8 auto_animation_counter;
3232static UINT8 auto_animation_frame_counter;
33static mame_timer *auto_animation_timer;
33static emu_timer *auto_animation_timer;
3434
35static mame_timer *sprite_line_timer;
35static emu_timer *sprite_line_timer;
3636
3737
3838
r1293r1294
250250   else
251251      auto_animation_frame_counter = auto_animation_frame_counter - 1;
252252
253   mame_timer_adjust(auto_animation_timer, video_screen_get_time_until_pos(0, NEOGEO_VSSTART, 0), 0, time_zero);
253   timer_adjust(auto_animation_timer, video_screen_get_time_until_pos(0, NEOGEO_VSSTART, 0), 0, attotime_zero);
254254}
255255
256256
257257static void create_auto_animation_timer(void)
258258{
259   auto_animation_timer = mame_timer_alloc(auto_animation_timer_callback);
259   auto_animation_timer = timer_alloc(auto_animation_timer_callback);
260260}
261261
262262
263263static void start_auto_animation_timer(void)
264264{
265   mame_timer_adjust(auto_animation_timer, video_screen_get_time_until_pos(0, NEOGEO_VSSTART, 0), 0, time_zero);
265   timer_adjust(auto_animation_timer, video_screen_get_time_until_pos(0, NEOGEO_VSSTART, 0), 0, attotime_zero);
266266}
267267
268268
r1293r1294
672672   /* let's come back at the beginning of the next line */
673673   scanline = (scanline + 1) % NEOGEO_VTOTAL;
674674
675   mame_timer_adjust(sprite_line_timer, video_screen_get_time_until_pos(0, scanline, 0), scanline, time_zero);
675   timer_adjust(sprite_line_timer, video_screen_get_time_until_pos(0, scanline, 0), scanline, attotime_zero);
676676}
677677
678678
679679static void create_sprite_line_timer(void)
680680{
681   sprite_line_timer = mame_timer_alloc(sprite_line_timer_callback);
681   sprite_line_timer = timer_alloc(sprite_line_timer_callback);
682682}
683683
684684
685685static void start_sprite_line_timer(void)
686686{
687   mame_timer_adjust(sprite_line_timer, video_screen_get_time_until_pos(0, 0, 0), 0, time_zero);
687   timer_adjust(sprite_line_timer, video_screen_get_time_until_pos(0, 0, 0), 0, attotime_zero);
688688}
689689
690690
src/mame/video/ppu2c0x.c
r1293r1294
7373   pen_t               *colortable_mono;      /* monochromatic color table modified at run time */
7474   UINT8               *dirtychar;            /* an array flagging dirty characters */
7575   int                  chars_are_dirty;      /* master flag to check if theres any dirty character */
76   mame_timer            *scanline_timer;      /* scanline timer */
77   mame_timer            *hblank_timer;         /* hblank period at end of each scanline */
78   mame_timer            *nmi_timer;            /* NMI timer */
76   emu_timer            *scanline_timer;      /* scanline timer */
77   emu_timer            *hblank_timer;         /* hblank period at end of each scanline */
78   emu_timer            *nmi_timer;            /* NMI timer */
7979   int                  scanline;            /* scanline count */
8080   ppu2c0x_scanline_cb      scanline_callback_proc;   /* optional scanline callback */
8181   ppu2c0x_hblank_cb      hblank_callback_proc;   /* optional hblank callback */
r1293r1294
295295      }
296296
297297      /* initialize the scanline handling portion */
298      chips[i].scanline_timer = mame_timer_alloc(scanline_callback);
299      chips[i].hblank_timer = mame_timer_alloc(hblank_callback);
300      chips[i].nmi_timer = mame_timer_alloc(nmi_callback);
298      chips[i].scanline_timer = timer_alloc(scanline_callback);
299      chips[i].hblank_timer = timer_alloc(hblank_callback);
300      chips[i].nmi_timer = timer_alloc(nmi_callback);
301301      chips[i].scanline = 0;
302302      chips[i].scan_scale = 1;
303303
r1293r1294
363363   if (this_ppu->hblank_callback_proc)
364364      (*this_ppu->hblank_callback_proc) (num, this_ppu->scanline, vblank, blanked);
365365
366   mame_timer_adjust(chips[num].hblank_timer, time_never, num, time_never);
366   timer_adjust(chips[num].hblank_timer, attotime_never, num, attotime_never);
367367}
368368
369369static TIMER_CALLBACK( nmi_callback )
r1293r1294
375375   if (intf->nmi_handler[num])
376376      (*intf->nmi_handler[num]) (num, ppu_regs);
377377
378   mame_timer_adjust(chips[num].nmi_timer, time_never, num, time_never);
378   timer_adjust(chips[num].nmi_timer, attotime_never, num, attotime_never);
379379}
380380
381381static void draw_background(const int num, UINT8 *line_priority )
r1293r1294
871871         // a game can read the high bit of $2002 before the NMI is called (potentially resetting the bit
872872         // via a read from $2002 in the NMI handler).
873873         // B-Wings is an example game that needs this.
874         mame_timer_adjust(this_ppu->nmi_timer, MAME_TIME_IN_CYCLES(4, 0), num, time_never);
874         timer_adjust(this_ppu->nmi_timer, ATTOTIME_IN_CYCLES(4, 0), num, attotime_never);
875875      }
876876   }
877877
r1293r1294
922922      next_scanline = 0;
923923
924924   // Call us back when the hblank starts for this scanline
925   mame_timer_adjust(this_ppu->hblank_timer, MAME_TIME_IN_CYCLES(86.67, 0), num, time_never); // ??? FIXME - hardcoding NTSC, need better calculation
925   timer_adjust(this_ppu->hblank_timer, ATTOTIME_IN_CYCLES(86.67, 0), num, attotime_never); // ??? FIXME - hardcoding NTSC, need better calculation
926926
927927   // trigger again at the start of the next scanline
928   mame_timer_adjust(this_ppu->scanline_timer, video_screen_get_time_until_pos(0, next_scanline * this_ppu->scan_scale, 0), num, time_zero);
928   timer_adjust(this_ppu->scanline_timer, video_screen_get_time_until_pos(0, next_scanline * this_ppu->scan_scale, 0), num, attotime_zero);
929929}
930930
931931/*************************************
r1293r1294
950950   /* set the scan scale (this is for dual monitor vertical setups) */
951951   chips[num].scan_scale = scan_scale;
952952
953   mame_timer_adjust(chips[num].nmi_timer, time_never, num, time_never);
953   timer_adjust(chips[num].nmi_timer, attotime_never, num, attotime_never);
954954
955955   // Call us back when the hblank starts for this scanline
956   mame_timer_adjust(chips[num].hblank_timer, MAME_TIME_IN_CYCLES(86.67, 0), num, time_never); // ??? FIXME - hardcoding NTSC, need better calculation
956   timer_adjust(chips[num].hblank_timer, ATTOTIME_IN_CYCLES(86.67, 0), num, attotime_never); // ??? FIXME - hardcoding NTSC, need better calculation
957957
958958   // Call us back at the start of the next scanline
959   mame_timer_adjust(chips[num].scanline_timer, video_screen_get_time_until_pos(0, 1, 0), num, time_zero);
959   timer_adjust(chips[num].scanline_timer, video_screen_get_time_until_pos(0, 1, 0), num, attotime_zero);
960960
961961   /* reset the callbacks */
962962   chips[num].scanline_callback_proc = 0;
r1293r1294
14891489   this_ppu->mirror_state = mirroring;
14901490}
14911491
1492#ifdef UNUSED_FUNCTION
14921493void ppu2c0x_set_nmi_callback( int num, ppu2c0x_nmi_cb cb )
14931494{
14941495   /* check bounds */
r1293r1294
15001501
15011502   intf->nmi_handler[num] = cb;
15021503}
1504#endif
15031505
15041506void ppu2c0x_set_scanline_callback( int num, ppu2c0x_scanline_cb cb )
15051507{
src/mame/video/buggychl.c
r1293r1294
44
55
66UINT8 *buggychl_scrollv,*buggychl_scrollh;
7UINT8 buggychl_sprite_lookup[0x2000];
7static UINT8 buggychl_sprite_lookup[0x2000];
88UINT8 *buggychl_character_ram;
99
1010static int *dirtychar;
src/mame/video/asterix.c
r1293r1294
88static int tilebanks[4];
99static int spritebanks[4];
1010
11void reset_spritebank(void)
11static void reset_spritebank(void)
1212{
1313   K053244_bankselect(0, spritebank & 7);
1414   spritebanks[0] = (spritebank << 12) & 0x7000;
src/mame/video/tubep.c
r1293r1294
569569         cpunum_set_input_line(3,0,CLEAR_LINE);
570570
571571         /* 2.assert /SINT again after this time */
572         mame_timer_set( scale_up_mame_time(MAME_TIME_IN_HZ(19968000/8), (XSize+1)*(YSize+1)), 0, sprite_timer_callback);
572         timer_set( attotime_mul(ATTOTIME_IN_HZ(19968000/8), (XSize+1)*(YSize+1)), 0, sprite_timer_callback);
573573
574574         /* 3.clear of /SINT starts sprite drawing circuit */
575575         draw_sprite();
src/mame/video/exidy.c
r1293r1294
442442
443443            /* if we got one, trigger an interrupt */
444444            if ((collision_mask & exidy_collision_mask) && count++ < 128)
445               mame_timer_set(video_screen_get_time_until_pos(0, org_1_x + sx, org_1_y + sy), collision_mask, collision_irq_callback);
445               timer_set(video_screen_get_time_until_pos(0, org_1_x + sx, org_1_y + sy), collision_mask, collision_irq_callback);
446446            }
447447            if (*BITMAP_ADDR16(motion_object_2_vid, sy, sx) != pen0)
448448          {
449449                /* check for background collision (M2CHAR) */
450450            if (*BITMAP_ADDR16(tmpbitmap, org_2_y + sy, org_2_x + sx) != pen0)
451451               if ((exidy_collision_mask & 0x08) && count++ < 128)
452                  mame_timer_set(video_screen_get_time_until_pos(0, org_2_x + sx, org_2_y + sy), 0x08, collision_irq_callback);
452                  timer_set(video_screen_get_time_until_pos(0, org_2_x + sx, org_2_y + sy), 0x08, collision_irq_callback);
453453            }
454454      }
455455}
src/mame/video/hyhoo.c
r1293r1294
226226   }
227227
228228   nb1413m3_busyflag = 0;
229   mame_timer_set(scale_up_mame_time(MAME_TIME_IN_HZ(400000), nb1413m3_busyctr), 0, blitter_timer_callback);
229   timer_set(attotime_mul(ATTOTIME_IN_HZ(400000), nb1413m3_busyctr), 0, blitter_timer_callback);
230230}
231231
232232
src/mame/video/moo.c
r1293r1294
1515static int layer_colorbase[4], layerpri[3];
1616static int alpha_enabled;
1717
18#ifdef UNUSED_FUNCTION
1819void moo_set_alpha(int on)
1920{
2021   alpha_enabled = on;
2122}
23#endif
2224
2325static void moo_sprite_callback(int *code, int *color, int *priority_mask)
2426{
src/mame/video/tickee.c
r1293r1294
1313
1414
1515/* local variables */
16static mame_timer *setup_gun_timer;
16static emu_timer *setup_gun_timer;
1717
1818
1919
r1293r1294
5656   int beamx, beamy;
5757
5858   /* set a timer to do this again next frame */
59   mame_timer_adjust(setup_gun_timer, video_screen_get_time_until_pos(0, 0, 0), 0, time_zero);
59   timer_adjust(setup_gun_timer, video_screen_get_time_until_pos(0, 0, 0), 0, attotime_zero);
6060
6161   /* only do work if the palette is flashed */
6262   if (!tickee_control[2])
r1293r1294
6464
6565   /* generate interrupts for player 1's gun */
6666   get_crosshair_xy(0, &beamx, &beamy);
67   mame_timer_set(video_screen_get_time_until_pos(0, beamy,     beamx + 50), 0, trigger_gun_interrupt);
68   mame_timer_set(video_screen_get_time_until_pos(0, beamy + 1, beamx + 50), 0, clear_gun_interrupt);
67   timer_set(video_screen_get_time_until_pos(0, beamy,     beamx + 50), 0, trigger_gun_interrupt);
68   timer_set(video_screen_get_time_until_pos(0, beamy + 1, beamx + 50), 0, clear_gun_interrupt);
6969
7070   /* generate interrupts for player 2's gun */
7171   get_crosshair_xy(1, &beamx, &beamy);
72   mame_timer_set(video_screen_get_time_until_pos(0, beamy,     beamx + 50), 1, trigger_gun_interrupt);
73   mame_timer_set(video_screen_get_time_until_pos(0, beamy + 1, beamx + 50), 1, clear_gun_interrupt);
72   timer_set(video_screen_get_time_until_pos(0, beamy,     beamx + 50), 1, trigger_gun_interrupt);
73   timer_set(video_screen_get_time_until_pos(0, beamy + 1, beamx + 50), 1, clear_gun_interrupt);
7474}
7575
7676
r1293r1294
8484VIDEO_START( tickee )
8585{
8686   /* start a timer going on the first scanline of every frame */
87   setup_gun_timer = mame_timer_alloc(setup_gun_interrupts);
88   mame_timer_adjust(setup_gun_timer, video_screen_get_time_until_pos(0, 0, 0), 0, time_zero);
87   setup_gun_timer = timer_alloc(setup_gun_interrupts);
88   timer_adjust(setup_gun_timer, video_screen_get_time_until_pos(0, 0, 0), 0, attotime_zero);
8989}
9090
9191
src/mame/video/m92.c
r1293r1294
9999      /* Pixel clock is 26.6666 MHz, we have 0x800 bytes, or 0x400 words
100100           to copy from spriteram to the buffer.  It seems safe to assume 1
101101           word can be copied per clock.*/
102      mame_timer_set(scale_up_mame_time(MAME_TIME_IN_HZ(26666000), 0x400), 0, spritebuffer_callback);
102      timer_set(attotime_mul(ATTOTIME_IN_HZ(26666000), 0x400), 0, spritebuffer_callback);
103103   }
104104//  logerror("%04x: m92_spritecontrol_w %08x %08x\n",activecpu_get_pc(),offset,data);
105105}
src/mame/video/homerun.c
r1293r1294
44static int homerun_gc_up,homerun_gc_down;
55int homerun_xpa,homerun_xpb,homerun_xpc;
66
7tilemap *homerun_tilemap;
7static tilemap *homerun_tilemap;
88UINT8 *homerun_videoram;
99
1010#define half_screen 116
src/mame/video/segasyse.c
r1293r1294
2020static UINT16 vdp_accessaddr[CHIPS];   /* VDP Access Address */
2121static UINT8 vdp_readbuffer[CHIPS];      /* VDP Read Buffer */
2222
23UINT8 *segae_vdp_vram[CHIPS];         /* Pointer to VRAM */
23static UINT8 *segae_vdp_vram[CHIPS];         /* Pointer to VRAM */
2424static UINT8 *vdp_cram[CHIPS];         /* Pointer to the VDP's CRAM */
2525UINT8 *segae_vdp_regs[CHIPS];         /* Pointer to the VDP's Registers */
2626
27UINT8 segae_vdp_vrambank[CHIPS];      /* Current VRAM Bank number (from writes to Port 0xf7) */
27static UINT8 segae_vdp_vrambank[CHIPS];      /* Current VRAM Bank number (from writes to Port 0xf7) */
2828
2929static UINT8 *cache_bitmap;               /* 8bpp bitmap with raw pen values */
3030
r1293r1294
4242
4343static void draw_tiles_line(UINT8 *dest, int line, UINT8 chip, UINT8 pri);
4444static void draw_sprite_line(UINT8 *dest, UINT8 chip, UINT8 line);
45void segae_drawscanline(int line, int chips, int blank);
45static void segae_drawscanline(int line, int chips, int blank);
4646
4747static void draw_8pix_solid16(UINT8 *dest, UINT8 chip, UINT16 tile, UINT8 line, UINT8 flipx, UINT8 col);
4848static void draw_8pix(UINT8 *dest, UINT8 chip, UINT16 tile, UINT8 line, UINT8 flipx, UINT8 col);
src/mame/video/m107.c
r1293r1294
273273
274274/*****************************************************************************/
275275
276void m107_screenrefresh(running_machine *machine, mame_bitmap *bitmap, const rectangle *cliprect)
276static void m107_screenrefresh(running_machine *machine, mame_bitmap *bitmap, const rectangle *cliprect)
277277{
278278   if ((~m107_control[0x0b] >> 7) & 1)
279279   {
src/mame/video/megasys1.c
r1293r1294
679679   int priorities[16];
680680};
681681
682int megasys1_layers_order[16];
682static int megasys1_layers_order[16];
683683
684684/*
685685    Layers order encoded as an int like: 0x01234, where
src/mame/video/crshrace.c
r1293r1294
44
55
66UINT16 *crshrace_videoram1,*crshrace_videoram2;
7UINT16 *crshrace_roz_ctrl1,*crshrace_roz_ctrl2;
7//UINT16 *crshrace_roz_ctrl1,*crshrace_roz_ctrl2;
88
99static int roz_bank,gfxctrl,flipscreen;
1010
src/mame/video/airbustr.c
r1293r1294
3434#include "kan_pand.h"
3535
3636UINT8 *airbustr_videoram2, *airbustr_colorram2;
37int airbustr_clear_sprites;
37//int airbustr_clear_sprites;
3838static tilemap *bg_tilemap, *fg_tilemap;
3939static mame_bitmap *sprites_bitmap;
4040
src/mame/video/dcheese.c
r1293r1294
3232static UINT16 blitter_vidparam[32];
3333
3434static mame_bitmap *dstbitmap;
35static mame_timer *blitter_timer;
35static emu_timer *blitter_timer;
3636
3737
3838
r1293r1294
7070   if (blitter_vidparam[0x22/2] <= blitter_vidparam[0x1e/2])
7171   {
7272      int effscan;
73      mame_time time;
73      attotime time;
7474
7575      /* compute the effective scanline of the interrupt */
7676      effscan = blitter_vidparam[0x22/2] - blitter_vidparam[0x1a/2];
r1293r1294
7979
8080      /* determine the time; if it's in this scanline, bump to the next frame */
8181      time = video_screen_get_time_until_pos(0, effscan, 0);
82      if (compare_mame_times(time, video_screen_get_scan_period(0)) < 0)
83         time = add_mame_times(time, video_screen_get_frame_period(0));
84      mame_timer_adjust(blitter_timer, time, 0, time_zero);
82      if (attotime_compare(time, video_screen_get_scan_period(0)) < 0)
83         time = attotime_add(time, video_screen_get_frame_period(0));
84      timer_adjust(blitter_timer, time, 0, attotime_zero);
8585   }
8686}
8787
r1293r1294
111111   dstbitmap = auto_bitmap_alloc(DSTBITMAP_WIDTH, DSTBITMAP_HEIGHT, machine->screen[0].format);
112112
113113   /* create a timer */
114   blitter_timer = mame_timer_alloc(blitter_scanline_callback);
114   blitter_timer = timer_alloc(blitter_scanline_callback);
115115
116116   /* register for saving */
117117   state_save_register_global_array(blitter_color);
r1293r1294
162162      memset(BITMAP_ADDR16(dstbitmap, y % DSTBITMAP_HEIGHT, 0), 0, DSTBITMAP_WIDTH * 2);
163163
164164   /* signal an IRQ when done (timing is just a guess) */
165   mame_timer_set(video_screen_get_scan_period(0), 1, dcheese_signal_irq_callback);
165   timer_set(video_screen_get_scan_period(0), 1, dcheese_signal_irq_callback);
166166}
167167
168168
r1293r1294
216216   }
217217
218218   /* signal an IRQ when done (timing is just a guess) */
219   mame_timer_set(make_mame_time(0, mame_time_to_subseconds(video_screen_get_scan_period(0)) / 2), 2, dcheese_signal_irq_callback);
219   timer_set(attotime_make(0, attotime_to_attoseconds(video_screen_get_scan_period(0)) / 2), 2, dcheese_signal_irq_callback);
220220
221221   /* these extra parameters are written but they are always zero, so I don't know what they do */
222222   if (blitter_xparam[8] != 0 || blitter_xparam[9] != 0 || blitter_xparam[10] != 0 || blitter_xparam[11] != 0 ||
src/mame/video/cave.c
r1293r1294
285285   }
286286}
287287
288TILE_GET_INFO( sailormn_get_tile_info_2 )
288static TILE_GET_INFO( sailormn_get_tile_info_2 )
289289{
290290   UINT32 code, color, pri;
291291
r1293r1294
13911391   }
13921392}
13931393
1394void cave_tilemap_0_draw( mame_bitmap *bitmap, const rectangle *cliprect, UINT32 flags, UINT32 priority, UINT32 priority2 )
1394static void cave_tilemap_0_draw( mame_bitmap *bitmap, const rectangle *cliprect, UINT32 flags, UINT32 priority, UINT32 priority2 )
13951395{    cave_tilemap_draw( bitmap, cliprect, tilemap_0, cave_vram_0, cave_vctrl_0, flags, priority, priority2 );   }
1396void cave_tilemap_1_draw( mame_bitmap *bitmap, const rectangle *cliprect, UINT32 flags, UINT32 priority, UINT32 priority2 )
1396static void cave_tilemap_1_draw( mame_bitmap *bitmap, const rectangle *cliprect, UINT32 flags, UINT32 priority, UINT32 priority2 )
13971397{    cave_tilemap_draw( bitmap, cliprect, tilemap_1, cave_vram_1, cave_vctrl_1, flags, priority, priority2 );   }
1398void cave_tilemap_2_draw( mame_bitmap *bitmap, const rectangle *cliprect, UINT32 flags, UINT32 priority, UINT32 priority2 )
1398static void cave_tilemap_2_draw( mame_bitmap *bitmap, const rectangle *cliprect, UINT32 flags, UINT32 priority, UINT32 priority2 )
13991399{    cave_tilemap_draw( bitmap, cliprect, tilemap_2, cave_vram_2, cave_vctrl_2, flags, priority, priority2 );   }
1400void cave_tilemap_3_draw( mame_bitmap *bitmap, const rectangle *cliprect, UINT32 flags, UINT32 priority, UINT32 priority2 )
1400static void cave_tilemap_3_draw( mame_bitmap *bitmap, const rectangle *cliprect, UINT32 flags, UINT32 priority, UINT32 priority2 )
14011401{    cave_tilemap_draw( bitmap, cliprect, tilemap_3, cave_vram_3, cave_vctrl_3, flags, priority, priority2 );   }
14021402
14031403
src/mame/video/brkthru.c
r1293r1294
77#include "driver.h"
88
99
10UINT8 *brkthru_scroll;
10//UINT8 *brkthru_scroll;
1111UINT8 *brkthru_videoram;
1212size_t brkthru_videoram_size;
1313static int bgscroll;
src/mame/video/mnight.c
r1293r1294
1616static int       bg_enable = 1;
1717static int       sp_overdraw = 0;
1818
19void mnight_mark_background_dirty(void)
19static void mnight_mark_background_dirty(void)
2020{
2121   /* set 1024 bytes allocated in VIDEO_START( mnight ) to 'true' */
2222   memset(bg_dirtybuffer,1,1024);
src/mame/video/genesis.c
r1293r1294
1414void megaplay_start_video_normal(running_machine *machine);
1515void megaplay_update_video_normal(running_machine *machine, mame_bitmap *bitmap, const rectangle *cliprect );
1616
17int genesis_screen_number;
17static int genesis_screen_number;
1818
1919
2020/******************************************************************************
r1293r1294
125125******************************************************************************/
126126
127127
128void start_genesis_vdp(int screen_number)
128static void start_genesis_vdp(int screen_number)
129129{
130130   static const UINT8 vdp_init[24] =
131131   {
src/mame/video/rpunch.c
r1293r1294
2929
3030static UINT16 videoflags;
3131static UINT8 crtc_register;
32static mame_timer *crtc_timer;
32static emu_timer *crtc_timer;
3333static UINT8 bins, gins;
3434
3535
r1293r1294
7878{
7979   cpunum_set_input_line(0, 1, HOLD_LINE);
8080   if (param != 0)
81      mame_timer_adjust(crtc_timer, make_mame_time(0, machine->screen[0].refresh / param), 0, make_mame_time(0, machine->screen[0].refresh / param));
81      timer_adjust(crtc_timer, attotime_make(0, machine->screen[0].refresh / param), 0, attotime_make(0, machine->screen[0].refresh / param));
8282}
8383
8484
r1293r1294
9595      memset(rpunch_bitmapram, 0xff, rpunch_bitmapram_size);
9696
9797   /* reset the timer */
98   crtc_timer = mame_timer_alloc(crtc_interrupt_gen);
98   crtc_timer = timer_alloc(crtc_interrupt_gen);
9999}
100100
101101
r1293r1294
164164      {
165165         /* only register we know about.... */
166166         case 0x0b:
167            mame_timer_adjust(crtc_timer, video_screen_get_time_until_pos(0, Machine->screen[0].visarea.max_y + 1, 0), (data == 0xc0) ? 2 : 1, time_zero);
167            timer_adjust(crtc_timer, video_screen_get_time_until_pos(0, Machine->screen[0].visarea.max_y + 1, 0), (data == 0xc0) ? 2 : 1, attotime_zero);
168168            break;
169169
170170         default:
src/mame/video/changela.c
r1293r1294
3333
3434static mame_bitmap *obj0_bitmap, *river_bitmap, *tree0_bitmap, *tree1_bitmap;
3535
36static mame_timer* changela_scanline_timer;
36static emu_timer* changela_scanline_timer;
3737static TIMER_CALLBACK( changela_scanline_callback );
3838
3939VIDEO_START( changela )
r1293r1294
4646   tree0_bitmap = auto_bitmap_alloc(machine->screen[0].width, machine->screen[0].height, machine->screen[0].format);
4747   tree1_bitmap = auto_bitmap_alloc(machine->screen[0].width, machine->screen[0].height, machine->screen[0].format);
4848
49   changela_scanline_timer = mame_timer_alloc(changela_scanline_callback);
50   mame_timer_adjust(changela_scanline_timer, video_screen_get_time_until_pos(0, 30, 0), 30, time_zero);
49   changela_scanline_timer = timer_alloc(changela_scanline_callback);
50   timer_adjust(changela_scanline_timer, video_screen_get_time_until_pos(0, 30, 0), 30, attotime_zero);
5151
5252   state_save_register_global(slopeROM_bank);
5353   state_save_register_global(tree_en);
r1293r1294
737737
738738   sy++;
739739   if(sy > 256) sy = 30;
740   mame_timer_adjust(changela_scanline_timer, video_screen_get_time_until_pos(0, sy, 0), sy, time_zero);
740   timer_adjust(changela_scanline_timer, video_screen_get_time_until_pos(0, sy, 0), sy, attotime_zero);
741741}
742742
743743VIDEO_UPDATE( changela )
src/mame/video/asuka.c
r1293r1294
66
77/**********************************************************/
88
9void asuka_core_video_start(running_machine *machine, int x_offs,int buffering)
9static void asuka_core_video_start(running_machine *machine, int x_offs,int buffering)
1010{
1111   PC090OJ_vh_start(0,0,8,buffering);   /* gfxset, x offset, y offset, buffering */
1212   TC0100SCN_vh_start(machine,1,TC0100SCN_GFX_NUM,x_offs,0,0,0,0,0,0);
src/mame/video/triplhnt.c
r1293r1294
129129
130130   if (hit_line != 999 && hit_code != 999)
131131   {
132      mame_timer_set(video_screen_get_time_until_pos(0, hit_line, 0), hit_code, triplhnt_hit_callback);
132      timer_set(video_screen_get_time_until_pos(0, hit_line, 0), hit_code, triplhnt_hit_callback);
133133   }
134134}
135135
src/mame/video/exctsccr.c
r1293r1294
143143   bg_tilemap = tilemap_create(get_bg_tile_info, tilemap_scan_rows,
144144      TILEMAP_TYPE_PEN, 8, 8, 32, 32);
145145
146   mame_timer_pulse(MAME_TIME_IN_HZ(75), 0, exctsccr_fm_callback); /* updates fm */
146   timer_pulse(ATTOTIME_IN_HZ(75), 0, exctsccr_fm_callback); /* updates fm */
147147}
148148
149149static void draw_sprites(running_machine *machine, mame_bitmap *bitmap, const rectangle *cliprect)
src/mame/drivers/bfcobra.c
r1293r1294
8787/*
8888    Globals
8989*/
90UINT8 bank[4];
91UINT8 *work_ram;
92UINT8 *video_ram;
93UINT8 h_scroll;
94UINT8 v_scroll;
95UINT8 flip_8;
96UINT8 flip_22;
90static UINT8 bank[4];
91static UINT8 *work_ram;
92static UINT8 *video_ram;
93static UINT8 h_scroll;
94static UINT8 v_scroll;
95static UINT8 flip_8;
96static UINT8 flip_22;
9797
9898/* UART source/sinks */
99UINT8 z80_m6809_line;
100UINT8 m6809_z80_line;
101UINT8 data_r;
102UINT8 data_t;
99static UINT8 z80_m6809_line;
100static UINT8 m6809_z80_line;
101static UINT8 data_r;
102static UINT8 data_t;
103103
104int   irq_state;
105int acia_irq;
106int vblank_irq;
107int blitter_irq;
104static int   irq_state;
105static int acia_irq;
106static int vblank_irq;
107static int blitter_irq;
108108
109UINT8 z80_int;
110UINT8 z80_inten;
109static UINT8 z80_int;
110static UINT8 z80_inten;
111111
112112/* EM and lamps stuff */
113UINT32 meter_latch;
114UINT32 mux_input;
115UINT32 mux_outputlatch;
113static UINT32 meter_latch;
114static UINT32 mux_input;
115static UINT32 mux_outputlatch;
116116
117117/*
118118    Function prototypes
r1293r1294
190190/*
191191    Blitter state
192192*/
193struct
193static struct
194194{
195195   ADDR_REG   program;
196196
r1293r1294
212212/*
213213    MUSIC Semiconductor TR9C1710 RAMDAC or equivalent
214214*/
215struct
215static struct
216216{
217217   UINT8   addr_w;
218218   UINT8   addr_r;
r1293r1294
290290    The Flare One blitter is a simpler design with slightly different parameters
291291    and will require hardware tests to figure everything out correctly.
292292*/
293void RunBlit(void)
293static void RunBlit(void)
294294{
295295#define BLITPRG_READ(x)      blitter.x = *(blitter_get_addr(blitter.program.addr++))
296296
r1293r1294
788788
789789***************************************************************************/
790790
791void command_phase(UINT8 data);
792void exec_w_phase(UINT8 data);
793UINT8 exec_r_phase(void);
791static void command_phase(UINT8 data);
792static void exec_w_phase(UINT8 data);
793//UINT8 exec_r_phase(void);
794794
795795/*
796796    WD37C656C-PL (or equivalent) Floppy Disk Controller
r1293r1294
823823   SCAN_HIGH_OR_EQUAL = 29
824824};
825825
826struct
826static struct
827827{
828828   UINT8   MSR;
829829
r1293r1294
848848} fdc;
849849
850850
851void reset_fdc(void)
851static void reset_fdc(void)
852852{
853853   memset(&fdc, 0, sizeof(fdc));
854854
r1293r1294
958958   }
959959}
960960
961void command_phase(UINT8 data)
961static void command_phase(UINT8 data)
962962{
963963   if (fdc.cmd_cnt == 0)
964964   {
r1293r1294
10391039   }
10401040}
10411041
1042#ifdef UNUSED_FUNCTION
10421043UINT8 exec_r_phase(void)
10431044{
10441045   return 0;
10451046}
1047#endif
10461048
1047void exec_w_phase(UINT8 data)
1049static void exec_w_phase(UINT8 data)
10481050{
10491051}
10501052
1053#ifdef UNUSED_FUNCTION
10511054UINT8 results_phase(void)
10521055{
10531056   return 0;
10541057}
10551058
1056#ifdef UNUSED_FUNCTION
10571059WRITE8_HANDLER( fd_op_w )
10581060{
10591061}
r1293r1294
12241226   AM_RANGE(0xf000, 0xf000) AM_WRITE(MWA8_NOP)   /* Watchdog */
12251227ADDRESS_MAP_END
12261228
1227INPUT_PORTS_START( bfcobra )
1229static INPUT_PORTS_START( bfcobra )
12281230PORT_START_TAG("STROBE0")
12291231   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_COIN1 ) PORT_NAME("Coin: 10p")
12301232   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_COIN2 ) PORT_NAME("Coin: 20p")
r1293r1294
13311333/*
13321334    Allocate work RAM and video RAM shared by the Z80 and chipset.
13331335*/
1334static int init_ram(void)
1336static void init_ram(void)
13351337{
13361338   /* 768kB work RAM */
13371339   work_ram = auto_malloc(0xC0000);
13381340
1339   if (!work_ram)
1340      goto startfailed;
1341
13421341   /* 128kB video RAM */
13431342   video_ram = auto_malloc(0x20000);
13441343
1345   if (!video_ram)
1346      goto startfailed;
1347
13481344   memset(work_ram, 0, 0xc0000);
13491345   memset(video_ram, 0, 0x20000);
1350
1351   return 0;
1352
1353startfailed:
1354   return 1;
13551346}
13561347
13571348static void z80_acia_irq(int state)
r1293r1294
14191410   UINT8 *rom;
14201411   UINT8 *tmp;
14211412
1422   tmp = malloc(0x8000);
1413   tmp = malloc_or_die(0x8000);
14231414   rom = memory_region(REGION_CPU2) + 0x8000;
14241415   memcpy(tmp, rom, 0x8000);
14251416
src/mame/drivers/mgolf.c
r1293r1294
88
99static UINT8* mgolf_video_ram;
1010
11static mame_time time_pushed;
12static mame_time time_released;
11static attotime time_pushed;
12static attotime time_released;
1313
1414static UINT8 prev = 0;
1515static UINT8 mask = 0;
r1293r1294
7878   {
7979      if (val == 0)
8080      {
81         time_released = mame_timer_get_time();
81         time_released = timer_get_time();
8282
8383         if (!mask)
8484         {
r1293r1294
8787      }
8888      else
8989      {
90         time_pushed = mame_timer_get_time();
90         time_pushed = timer_get_time();
9191      }
9292
9393      prev = val;
r1293r1294
110110      scanline = 16;
111111   }
112112
113   mame_timer_set(video_screen_get_time_until_pos(0, scanline, 0), scanline, interrupt_callback);
113   timer_set(video_screen_get_time_until_pos(0, scanline, 0), scanline, interrupt_callback);
114114}
115115
116116
117117static double calc_plunger_pos(void)
118118{
119   return (mame_time_to_double(mame_timer_get_time()) - mame_time_to_double(time_released)) * (mame_time_to_double(time_released) - mame_time_to_double(time_pushed) + 0.2);
119   return (attotime_to_double(timer_get_time()) - attotime_to_double(time_released)) * (attotime_to_double(time_released) - attotime_to_double(time_pushed) + 0.2);
120120}
121121
122122
123123static MACHINE_RESET( mgolf )
124124{
125   mame_timer_set(video_screen_get_time_until_pos(0, 16, 0), 16, interrupt_callback);
125   timer_set(video_screen_get_time_until_pos(0, 16, 0), 16, interrupt_callback);
126126}
127127
128128
src/mame/drivers/deco_mlc.c
r1293r1294
109109
110110extern UINT32 *mlc_vram, *mlc_clip_ram;
111111static UINT32 *mlc_ram, *irq_ram;
112static mame_timer *raster_irq_timer;
112static emu_timer *raster_irq_timer;
113113static int mainCpuIsArm=1;
114int mlc_raster_table[9][256];
114static int mlc_raster_table[9][256];
115115
116116/***************************************************************************/
117117
r1293r1294
221221      return;
222222      break;
223223   case 0x14: /* Prepare scanline interrupt */
224      mame_timer_adjust(raster_irq_timer,video_screen_get_time_until_pos(0, irq_ram[0x14/4], 0),0,time_never);
224      timer_adjust(raster_irq_timer,video_screen_get_time_until_pos(0, irq_ram[0x14/4], 0),0,attotime_never);
225225      //logerror("prepare scanline to fire at %d (currently on %d)\n", irq_ram[0x14/4], video_screen_get_vpos(0));
226226      return;
227227      break;
r1293r1294
422422
423423static MACHINE_RESET( mlc )
424424{
425   raster_irq_timer = mame_timer_alloc(interrupt_gen);
425   raster_irq_timer = timer_alloc(interrupt_gen);
426426}
427427
428428static struct YMZ280Binterface ymz280b_intf =
src/mame/drivers/crystal.c
r1293r1294
249249   {
250250      int PD=(data>>8)&0xff;
251251      int TCV=program_read_dword_32le(0x01801404);
252      mame_time period = scale_up_mame_time(MAME_TIME_IN_HZ(43000000), (PD + 1) * (TCV + 1));
252      attotime period = attotime_mul(ATTOTIME_IN_HZ(43000000), (PD + 1) * (TCV + 1));
253253
254254      if(Timer0ctrl&2)
255         mame_timer_adjust(Timer0,period,0,period);
255         timer_adjust(Timer0,period,0,period);
256256      else
257         mame_timer_adjust(Timer0,period,0,time_zero);
257         timer_adjust(Timer0,period,0,attotime_zero);
258258   }
259259   COMBINE_DATA(&Timer0ctrl);
260260}
r1293r1294
277277   {
278278      int PD=(data>>8)&0xff;
279279      int TCV=program_read_dword_32le(0x0180140C);
280      mame_time period = scale_up_mame_time(MAME_TIME_IN_HZ(43000000), (PD + 1) * (TCV + 1));
280      attotime period = attotime_mul(ATTOTIME_IN_HZ(43000000), (PD + 1) * (TCV + 1));
281281
282282      if(Timer1ctrl&2)
283         mame_timer_adjust(Timer1,period,0,period);
283         timer_adjust(Timer1,period,0,period);
284284      else
285         mame_timer_adjust(Timer1,period,0,time_zero);
285         timer_adjust(Timer1,period,0,attotime_zero);
286286   }
287287   COMBINE_DATA(&Timer1ctrl);
288288}
r1293r1294
305305   {
306306      int PD=(data>>8)&0xff;
307307      int TCV=program_read_dword_32le(0x01801414);
308      mame_time period = scale_up_mame_time(MAME_TIME_IN_HZ(43000000), (PD + 1) * (TCV + 1));
308      attotime period = attotime_mul(ATTOTIME_IN_HZ(43000000), (PD + 1) * (TCV + 1));
309309
310310      if(Timer2ctrl&2)
311         mame_timer_adjust(Timer2,period,0,period);
311         timer_adjust(Timer2,period,0,period);
312312      else
313         mame_timer_adjust(Timer2,period,0,time_zero);
313         timer_adjust(Timer2,period,0,attotime_zero);
314314   }
315315   COMBINE_DATA(&Timer2ctrl);
316316}
r1293r1294
333333   {
334334      int PD=(data>>8)&0xff;
335335      int TCV=program_read_dword_32le(0x0180141C);
336      mame_time period = scale_up_mame_time(MAME_TIME_IN_HZ(43000000), (PD + 1) * (TCV + 1));
336      attotime period = attotime_mul(ATTOTIME_IN_HZ(43000000), (PD + 1) * (TCV + 1));
337337
338338      if(Timer3ctrl&2)
339         mame_timer_adjust(Timer3,period,0,period);
339         timer_adjust(Timer3,period,0,period);
340340      else
341         mame_timer_adjust(Timer3,period,0,time_zero);
341         timer_adjust(Timer3,period,0,attotime_zero);
342342   }
343343   COMBINE_DATA(&Timer3ctrl);
344344}
r1293r1294
593593   Timer2ctrl=0;
594594   Timer3ctrl=0;
595595
596   Timer0=mame_timer_alloc(Timer0cb);
597   mame_timer_adjust(Timer0,time_never,0,time_never);
596   Timer0=timer_alloc(Timer0cb);
597   timer_adjust(Timer0,attotime_never,0,attotime_never);
598598
599   Timer1=mame_timer_alloc(Timer1cb);
600   mame_timer_adjust(Timer1,time_never,0,time_never);
599   Timer1=timer_alloc(Timer1cb);
600   timer_adjust(Timer1,attotime_never,0,attotime_never);
601601
602   Timer2=mame_timer_alloc(Timer2cb);
603   mame_timer_adjust(Timer2,time_never,0,time_never);
602   Timer2=timer_alloc(Timer2cb);
603   timer_adjust(Timer2,attotime_never,0,attotime_never);
604604
605   Timer3=mame_timer_alloc(Timer3cb);
606   mame_timer_adjust(Timer3,time_never,0,time_never);
605   Timer3=timer_alloc(Timer3cb);
606   timer_adjust(Timer3,attotime_never,0,attotime_never);
607607
608608   VR0_Snd_Set_Areas(textureram,frameram);
609609#ifdef IDLE_LOOP_SPEEDUP
src/mame/drivers/tempest.c
r1293r1294
293293#define TEMPEST_BUTTONS_P2_TAG   ("BUTTONSP2")
294294
295295
296UINT8 tempest_player_select;
296static UINT8 tempest_player_select;
297297
298298/*************************************
299299 *
r1293r1294
584584   MDRV_CPU_ADD(M6502, MASTER_CLOCK / 8)
585585   MDRV_CPU_PROGRAM_MAP(main_map, 0)
586586   MDRV_CPU_PERIODIC_INT(irq0_line_assert, (double)MASTER_CLOCK / 4096 / 12)
587   MDRV_WATCHDOG_TIME_INIT(MAME_TIME_IN_HZ(CLOCK_3KHZ / 256))
587   MDRV_WATCHDOG_TIME_INIT(ATTOTIME_IN_HZ(CLOCK_3KHZ / 256))
588588   MDRV_SCREEN_REFRESH_RATE(60)
589589   MDRV_SCREEN_VBLANK_TIME(DEFAULT_60HZ_VBLANK_DURATION)
590590   MDRV_NVRAM_HANDLER(atari_vg)
src/mame/drivers/bublbobl.c
r1293r1294
462462   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_SPECIAL )   // output: select read or write shared RAM
463463
464464   PORT_START_TAG("DSW0")
465   PORT_DIPNAME( 0x05, 0x04, "Mode" )
465   PORT_DIPNAME( 0x05, 0x04, "Mode" )                  PORT_DIPLOCATION("DSW-A:1,3")
466466   PORT_DIPSETTING(    0x04, "Game, English" )
467467   PORT_DIPSETTING(    0x05, "Game, Japanese" )
468468   PORT_DIPSETTING(    0x01, "Test (Grid and Inputs)" )
469   PORT_DIPSETTING(    0x00, "Test (RAM and Sound)" )
470   PORT_DIPNAME( 0x02, 0x02, DEF_STR( Flip_Screen ) )
469   PORT_DIPSETTING(    0x00, "Test (RAM and Sound)/Pause" )
470   PORT_DIPNAME( 0x02, 0x02, DEF_STR( Flip_Screen ) )      PORT_DIPLOCATION("DSW-A:2")
471471   PORT_DIPSETTING(    0x02, DEF_STR( Off ) )
472472   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
473   PORT_DIPNAME( 0x08, 0x08, DEF_STR( Demo_Sounds ) )
473   PORT_DIPNAME( 0x08, 0x08, DEF_STR( Demo_Sounds ) )      PORT_DIPLOCATION("DSW-A:4")
474474   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
475475   PORT_DIPSETTING(    0x08, DEF_STR( On ) )
476   PORT_DIPNAME( 0x30, 0x30, DEF_STR( Coin_A ) )
476   PORT_DIPNAME( 0x30, 0x30, DEF_STR( Coin_A ) )         PORT_DIPLOCATION("DSW-A:5,6")
477477   PORT_DIPSETTING(    0x10, DEF_STR( 2C_1C ) )
478478   PORT_DIPSETTING(    0x30, DEF_STR( 1C_1C ) )
479479   PORT_DIPSETTING(    0x00, DEF_STR( 2C_3C ) )
480480   PORT_DIPSETTING(    0x20, DEF_STR( 1C_2C ) )
481   PORT_DIPNAME( 0xc0, 0xc0, DEF_STR( Coin_B ) )
481   PORT_DIPNAME( 0xc0, 0xc0, DEF_STR( Coin_B ) )         PORT_DIPLOCATION("DSW-A:7,8")
482482   PORT_DIPSETTING(    0x40, DEF_STR( 2C_1C ) )
483483   PORT_DIPSETTING(    0xc0, DEF_STR( 1C_1C ) )
484484   PORT_DIPSETTING(    0x00, DEF_STR( 2C_3C ) )
485485   PORT_DIPSETTING(    0x80, DEF_STR( 1C_2C ) )
486486
487487   PORT_START_TAG("DSW1")
488   PORT_DIPNAME( 0x03, 0x03, DEF_STR( Difficulty ) )
488   PORT_DIPNAME( 0x03, 0x03, DEF_STR( Difficulty ) )      PORT_DIPLOCATION("DSW-B:1,2")
489489   PORT_DIPSETTING(    0x02, DEF_STR( Easy ) )
490490   PORT_DIPSETTING(    0x03, DEF_STR( Normal ) )
491491   PORT_DIPSETTING(    0x01, DEF_STR( Hard ) )
492492   PORT_DIPSETTING(    0x00, DEF_STR( Very_Hard ) )
493   PORT_DIPNAME( 0x0c, 0x0c, DEF_STR( Bonus_Life ) )
493   PORT_DIPNAME( 0x0c, 0x0c, DEF_STR( Bonus_Life ) )      PORT_DIPLOCATION("DSW-B:3,4")
494494   PORT_DIPSETTING(    0x08, "20K 80K 300K" )
495495   PORT_DIPSETTING(    0x0c, "30K 100K 400K" )
496496   PORT_DIPSETTING(    0x04, "40K 200K 500K" )
497497   PORT_DIPSETTING(    0x00, "50K 250K 500K" )
498498   // then more bonus lives at 1M 2M 3M 4M 5M - for all dip switch settings
499   PORT_DIPNAME( 0x30, 0x30, DEF_STR( Lives ) )
499   PORT_DIPNAME( 0x30, 0x30, DEF_STR( Lives ) )         PORT_DIPLOCATION("DSW-B:5,6")
500500   PORT_DIPSETTING(    0x10, "1" )
501501   PORT_DIPSETTING(    0x00, "2" )
502502   PORT_DIPSETTING(    0x30, "3" )
503503   PORT_DIPSETTING(    0x20, "5" )
504   PORT_DIPNAME( 0x40, 0x40, DEF_STR( Unknown ) )   // must be off (see notes)
505   PORT_DIPSETTING(    0x40, DEF_STR( Off ) )
504   PORT_DIPNAME( 0x40, 0x40, DEF_STR( Unknown ) )         PORT_DIPLOCATION("DSW-B:7")
505   PORT_DIPSETTING(    0x40, DEF_STR( Off ) )            // must be off (see notes)
506506   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
507   PORT_DIPNAME( 0x80, 0x80, "ROM Type" )   // will hang on startup if set to wrong type
508   PORT_DIPSETTING(    0x80, "IC52=512kb, IC53=none" )
507   PORT_DIPNAME( 0x80, 0x80, "ROM Type" )               PORT_DIPLOCATION("DSW-B:8")
508   PORT_DIPSETTING(    0x80, "IC52=512kb, IC53=none" )      // will hang on startup if set to wrong type
509509   PORT_DIPSETTING(    0x00, "IC52=256kb, IC53=256kb" )
510510
511511   PORT_START_TAG("IN1")
r1293r1294
616616
617617static INPUT_PORTS_START( tokio )
618618   PORT_START_TAG("DSW0")
619   PORT_DIPNAME( 0x01, 0x00, DEF_STR( Cabinet ) )
619   PORT_DIPNAME( 0x01, 0x00, DEF_STR( Cabinet ) )      PORT_DIPLOCATION("SW A:1")
620620   PORT_DIPSETTING(    0x00, DEF_STR( Upright ) )
621621   PORT_DIPSETTING(    0x01, DEF_STR( Cocktail ) )
622   PORT_DIPNAME( 0x02, 0x02, DEF_STR( Flip_Screen ) )
622   PORT_DIPNAME( 0x02, 0x02, DEF_STR( Flip_Screen ) )   PORT_DIPLOCATION("SW A:2")
623623   PORT_DIPSETTING(    0x02, DEF_STR( Off ) )
624624   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
625   PORT_SERVICE( 0x04, IP_ACTIVE_LOW )
626   PORT_DIPNAME( 0x08, 0x08, DEF_STR( Demo_Sounds ) )
625   PORT_SERVICE_DIPLOC( 0x04, IP_ACTIVE_LOW, "SW A:3" )
626   PORT_DIPNAME( 0x08, 0x08, DEF_STR( Demo_Sounds ) )   PORT_DIPLOCATION("SW A:4")
627627   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
628628   PORT_DIPSETTING(    0x08, DEF_STR( On ) )
629   PORT_DIPNAME( 0x30, 0x30, DEF_STR( Coin_A ) )
629   PORT_DIPNAME( 0x30, 0x30, DEF_STR( Coin_A ) )      PORT_DIPLOCATION("SW A:5,6")
630630   PORT_DIPSETTING(    0x10, DEF_STR( 2C_1C ) )
631631   PORT_DIPSETTING(    0x30, DEF_STR( 1C_1C ) )
632632   PORT_DIPSETTING(    0x00, DEF_STR( 2C_3C ) )
633633   PORT_DIPSETTING(    0x20, DEF_STR( 1C_2C ) )
634   PORT_DIPNAME( 0xc0, 0xc0, DEF_STR( Coin_B ) )
634   PORT_DIPNAME( 0xc0, 0xc0, DEF_STR( Coin_B ) )      PORT_DIPLOCATION("SW A:7,8")
635635   PORT_DIPSETTING(    0x40, DEF_STR( 2C_1C ) )
636636   PORT_DIPSETTING(    0xc0, DEF_STR( 1C_1C ) )
637637   PORT_DIPSETTING(    0x00, DEF_STR( 2C_3C ) )
638638   PORT_DIPSETTING(    0x80, DEF_STR( 1C_2C ) )
639639
640640   PORT_START_TAG("DSW1")
641   PORT_DIPNAME( 0x01, 0x01, "Enemies" )
641   PORT_DIPNAME( 0x01, 0x00, "Enemies" )            PORT_DIPLOCATION("SW B:1")
642642   PORT_DIPSETTING(    0x01, "Few (Easy)" )
643643   PORT_DIPSETTING(    0x00, "Many (Hard)" )
644   PORT_DIPNAME( 0x02, 0x02, "Enemy Shots" )
644   PORT_DIPNAME( 0x02, 0x02, "Enemy Shots" )         PORT_DIPLOCATION("SW B:2")
645645   PORT_DIPSETTING(    0x02, "Few (Easy)" )
646646   PORT_DIPSETTING(    0x00, "Many (Hard)" )
647   PORT_DIPNAME( 0x0c, 0x0c, DEF_STR( Bonus_Life ) )
647   PORT_DIPNAME( 0x0c, 0x0c, DEF_STR( Bonus_Life ) )   PORT_DIPLOCATION("SW B:3,4")
648648   PORT_DIPSETTING(    0x0c, "100K 400K" )
649649   PORT_DIPSETTING(    0x08, "200K 400K" )
650650   PORT_DIPSETTING(    0x04, "300K 400K" )
651651   PORT_DIPSETTING(    0x00, "400K 400K" )
652   PORT_DIPNAME( 0x30, 0x30, DEF_STR( Lives ) )
652   PORT_DIPNAME( 0x30, 0x30, DEF_STR( Lives ) )      PORT_DIPLOCATION("SW B:5,6")
653653   PORT_DIPSETTING(    0x30, "3" )
654654   PORT_DIPSETTING(    0x20, "4" )
655655   PORT_DIPSETTING(    0x10, "5" )
656656   PORT_DIPSETTING(    0x00, "99 (Cheat)")   // 6 in original version
657   PORT_DIPUNUSED( 0x40, IP_ACTIVE_LOW )
658   PORT_DIPNAME( 0x80, 0x00, DEF_STR( Language ) )
657   PORT_DIPUNUSED_DIPLOC( 0x40, IP_ACTIVE_LOW, "SW B:7" )
658   PORT_DIPNAME( 0x80, 0x00, DEF_STR( Language ) )      PORT_DIPLOCATION("SW B:8")
659659   PORT_DIPSETTING(    0x00, DEF_STR( English ) )
660660   PORT_DIPSETTING(    0x80, DEF_STR( Japanese ) )
661661
r1293r1294
746746   MDRV_CPU_PROGRAM_MAP(tokio_sound_map, 0) // NMIs are triggered by the main CPU, IRQs are triggered by the YM2203
747747
748748   MDRV_SCREEN_REFRESH_RATE(VSYNC)   // 59.185606 Hz
749   MDRV_SCREEN_VBLANK_TIME(USEC_TO_SUBSECONDS(VBLANK))    // 2560 us
749   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(VBLANK))    // 2560 us
750750   MDRV_INTERLEAVE(100) // 100 CPU slices per frame - a high value to ensure proper synchronization of the CPUs
751751
752752   // video hardware
r1293r1294
789789   MDRV_CPU_VBLANK_INT(irq0_line_pulse, 1) // comes from the same clock that latches the INT pin on the second Z80
790790
791791   MDRV_SCREEN_REFRESH_RATE(VSYNC)   // 59.185606 Hz
792   MDRV_SCREEN_VBLANK_TIME(USEC_TO_SUBSECONDS(VBLANK))    // 2560 us
792   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(VBLANK))    // 2560 us
793793   MDRV_INTERLEAVE(100) // 100 CPU slices per frame - a high value to ensure proper synchronization of the CPUs
794794
795795   // video hardware
src/mame/drivers/chinsan.c
r1293r1294
4343#include "machine/mc8123.h"
4444#include "sound/2203intf.h"
4545
46UINT8* chinsan_video;
47UINT8 chinsan_port_select;
46static UINT8* chinsan_video;
47static UINT8 chinsan_port_select;
4848
4949static VIDEO_START(chinsan)
5050{
r1293r1294
462462   MDRV_CPU_IO_MAP(chinsan_io,0)
463463   MDRV_CPU_VBLANK_INT(irq0_line_hold,1)
464464
465   MDRV_MACHINE_RESET( chinsan );
465   MDRV_MACHINE_RESET( chinsan )
466466
467467   /* video hardware */
468468   MDRV_VIDEO_ATTRIBUTES(VIDEO_TYPE_RASTER )
src/mame/drivers/cshooter.c
r1293r1294
8686#include "driver.h"
8787#include "audio/seibu.h"
8888
89UINT8* cshooter_txram;
89static UINT8* cshooter_txram;
9090static tilemap *cshooter_txtilemap;
9191static int coin_stat=0;
9292
r1293r1294
195195
196196/* main cpu */
197197
198INTERRUPT_GEN( cshooter_interrupt )
198static INTERRUPT_GEN( cshooter_interrupt )
199199{
200200   if(cpu_getiloops())
201201   {
src/mame/drivers/aerofgt.c
r1293r1294
16521652   MDRV_CPU_IO_MAP(aerofgt_sound_readport,aerofgt_sound_writeport)
16531653                        /* IRQs are triggered by the YM2610 */
16541654   MDRV_SCREEN_REFRESH_RATE(60)
1655   MDRV_SCREEN_VBLANK_TIME(USEC_TO_SUBSECONDS(500))
1655   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(500))
16561656            /* wrong but improves sprite-background synchronization */
16571657
16581658   MDRV_MACHINE_RESET(aerofgt)
r1293r1294
16921692   MDRV_CPU_IO_MAP(aerofgt_sound_readport,aerofgt_sound_writeport)
16931693                        /* IRQs are triggered by the YM2610 */
16941694   MDRV_SCREEN_REFRESH_RATE(60)
1695   MDRV_SCREEN_VBLANK_TIME(USEC_TO_SUBSECONDS(400))
1695   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(400))
16961696            /* wrong but improves sprite-background synchronization */
16971697
16981698   MDRV_MACHINE_RESET(aerofgt)
r1293r1294
17301730   MDRV_CPU_PROGRAM_MAP(aerfboot_snd_map,0)
17311731
17321732   MDRV_SCREEN_REFRESH_RATE(60)
1733   MDRV_SCREEN_VBLANK_TIME(USEC_TO_SUBSECONDS(500))
1733   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(500))
17341734            /* wrong but improves sprite-background synchronization */
17351735
17361736   /* video hardware */
src/mame/drivers/fgoal.c
r1293r1294
122122      scanline = 0;
123123   }
124124
125   mame_timer_set(video_screen_get_time_until_pos(0, scanline, 0), 0, interrupt_callback);
125   timer_set(video_screen_get_time_until_pos(0, scanline, 0), 0, interrupt_callback);
126126}
127127
128128
129129static MACHINE_RESET( fgoal )
130130{
131   mame_timer_set(video_screen_get_time_until_pos(0, 0, 0), 0, interrupt_callback);
131   timer_set(video_screen_get_time_until_pos(0, 0, 0), 0, interrupt_callback);
132132}
133133
134134
src/mame/drivers/ultrsprt.c
r1293r1294
279279   MDRV_CPU_PERIODIC_INT(irq5_line_hold, 1)   // ???
280280
281281   MDRV_SCREEN_REFRESH_RATE(60)
282   MDRV_SCREEN_VBLANK_TIME(USEC_TO_SUBSECONDS(0))
282   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(0))
283283
284284   MDRV_INTERLEAVE(200)
285285
src/mame/drivers/mystston.c
r1293r1294
248248   MDRV_CPU_VBLANK_INT(mystston_interrupt, 272)
249249
250250   MDRV_SCREEN_REFRESH_RATE(((12000000.0 / 256.0) / 3.0) / 272.0)
251   MDRV_SCREEN_VBLANK_TIME(USEC_TO_SUBSECONDS(0))
251   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(0))
252252
253253   /* video hardware */
254254   MDRV_VIDEO_ATTRIBUTES(VIDEO_TYPE_RASTER)
src/mame/drivers/hitme.c
r1293r1294
1919#include "sound/discrete.h"
2020
2121static tilemap *hitme_tilemap;
22static mame_time timeout_time;
22static attotime timeout_time;
2323static UINT8 *hitme_vidram;
2424
2525
r1293r1294
129129static UINT8 read_port_and_t0(int port)
130130{
131131   UINT8 val = readinputport(port);
132   if (compare_mame_times(mame_timer_get_time(), timeout_time) > 0)
132   if (attotime_compare(timer_get_time(), timeout_time) > 0)
133133      val ^= 0x80;
134134   return val;
135135}
r1293r1294
185185    */
186186   UINT8 raw_game_speed = readinputport(6);
187187   double resistance = raw_game_speed * 25000 / 100;
188   mame_time duration = make_mame_time(0, MAX_SUBSECONDS * 0.45 * 6.8e-6 * resistance * (data+1));
189   timeout_time = add_mame_times(mame_timer_get_time(), duration);
188   attotime duration = attotime_make(0, ATTOSECONDS_PER_SECOND * 0.45 * 6.8e-6 * resistance * (data+1));
189   timeout_time = attotime_add(timer_get_time(), duration);
190190
191191   discrete_sound_w(HITME_DOWNCOUNT_VAL, data);
192192   discrete_sound_w(HITME_OUT0, 1);
src/mame/drivers/senjyo.c
r1293r1294
125125   int_delay_kludge = 10;
126126}
127127
128INTERRUPT_GEN( senjyo_interrupt )
128static INTERRUPT_GEN( senjyo_interrupt )
129129{
130130   if (int_delay_kludge == 0) cpunum_set_input_line(0, 0, HOLD_LINE);
131131   else int_delay_kludge--;
src/mame/drivers/yiear.c
r1293r1294
7979   VLM5030_RST( ( data >> 2 ) & 1 );
8080}
8181
82INTERRUPT_GEN( yiear_nmi_interrupt )
82static INTERRUPT_GEN( yiear_nmi_interrupt )
8383{
8484   /* can't use nmi_line_pulse() because interrupt_enable_w() effects it */
8585   if (yiear_nmi_enable) cpunum_set_input_line(0, INPUT_LINE_NMI, PULSE_LINE);
src/mame/drivers/snowbros.c
r1293r1294
100100
101101
102102static UINT16 *hyperpac_ram;
103int sb3_music_is_playing;
104int sb3_music;
103static int sb3_music_is_playing;
104static int sb3_music;
105105
106106static INTERRUPT_GEN( snowbros_interrupt )
107107{
r1293r1294
408408   return 0x0003;
409409}
410410
411void sb3_play_music(int data)
411static void sb3_play_music(int data)
412412{
413413   /* sample is actually played in interrupt function so it loops */
414414   sb3_music = data;
r1293r1294
452452   }
453453}
454454
455void sb3_play_sound (int data)
455static void sb3_play_sound (int data)
456456{
457457   int status = OKIM6295_status_0_r(0);
458458
src/mame/drivers/segaxbd.c
r1293r1294
111111   if (irq != 0)
112112   {
113113      cpunum_set_input_line(0, irq, ASSERT_LINE);
114      cpu_boost_interleave(time_zero, MAME_TIME_IN_USEC(100));
114      cpu_boost_interleave(attotime_zero, ATTOTIME_IN_USEC(100));
115115   }
116116   else
117117      cpunum_set_input_line(0, 7, CLEAR_LINE);
r1293r1294
150150      update_main_irqs();
151151
152152   /* come back in 2 scanlines */
153   mame_timer_set(video_screen_get_time_until_pos(0, next_scanline, 0), next_scanline, scanline_callback);
153   timer_set(video_screen_get_time_until_pos(0, next_scanline, 0), next_scanline, scanline_callback);
154154}
155155
156156
r1293r1294
205205static void xboard_reset(void)
206206{
207207   cpunum_set_input_line(1, INPUT_LINE_RESET, PULSE_LINE);
208   cpu_boost_interleave(time_zero, MAME_TIME_IN_USEC(100));
208   cpu_boost_interleave(attotime_zero, ATTOTIME_IN_USEC(100));
209209}
210210
211211
r1293r1294
222222   segaic16_compare_timer_init(1, NULL, NULL);
223223
224224   /* start timers to track interrupts */
225   mame_timer_set(video_screen_get_time_until_pos(0, 1, 0), 1, scanline_callback);
225   timer_set(video_screen_get_time_until_pos(0, 1, 0), 1, scanline_callback);
226226}
227227
228228
r1293r1294
461461static WRITE16_HANDLER( loffire_sync0_w )
462462{
463463   COMBINE_DATA(&loffire_sync[offset]);
464   cpu_boost_interleave(time_zero, MAME_TIME_IN_USEC(10));
464   cpu_boost_interleave(attotime_zero, ATTOTIME_IN_USEC(10));
465465}
466466
467467
r1293r1294
731731   PORT_DIPNAME( 0x04, 0x00, DEF_STR( Demo_Sounds ) ) PORT_DIPLOCATION("SWB:3")
732732   PORT_DIPSETTING(    0x04, DEF_STR( Off ) )
733733   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
734   // According to the manual, SWB:4 sets 3 or 4 lives, but it doesn't actually do that.
735   // However, it does on Afterburner II.  Maybe there's another version of Afterburner
736   // that behaves as the manual suggests.
734737   PORT_DIPNAME( 0x10, 0x00, DEF_STR( Lives ) ) PORT_DIPLOCATION("SWB:5")
735738   PORT_DIPSETTING(    0x10, "3" )
736739   PORT_DIPSETTING(    0x00, "3x Credits" )
r1293r1294
772775   PORT_DIPNAME( 0x04, 0x04, "Throttle Lever" ) PORT_DIPLOCATION("SWB:3")
773776   PORT_DIPSETTING(    0x00, DEF_STR( No ) )
774777   PORT_DIPSETTING(    0x04, DEF_STR( Yes ) )
775   PORT_DIPNAME( 0x08, 0x08, DEF_STR( Lives ) ) PORT_DIPLOCATION("SWB:4")
776   PORT_DIPSETTING(    0x08, "3" )
777   PORT_DIPSETTING(    0x00, "4" )
778   PORT_DIPNAME( 0x10, 0x00, "Ship Increase" ) PORT_DIPLOCATION("SWB:5")
779   PORT_DIPSETTING(    0x10, DEF_STR( No ) )
780   PORT_DIPSETTING(    0x00, DEF_STR( Yes ) )
778   PORT_DIPNAME( 0x18, 0x18, DEF_STR( Lives ) ) PORT_DIPLOCATION("SWB:4,5")
779   PORT_DIPSETTING(    0x18, "3" )
780   PORT_DIPSETTING(    0x10, "4" )
781   PORT_DIPSETTING(    0x08, "3x Credits" )
782   PORT_DIPSETTING(    0x00, "4x Credits" )
781783   PORT_DIPNAME( 0x20, 0x00, DEF_STR( Allow_Continue ) ) PORT_DIPLOCATION("SWB:6")
782784   PORT_DIPSETTING(    0x20, DEF_STR( No ) )
783785   PORT_DIPSETTING(    0x00, DEF_STR( Yes ) )
r1293r1294
11701172MACHINE_DRIVER_END
11711173
11721174
1173MACHINE_DRIVER_START( smgp )
1175static MACHINE_DRIVER_START( smgp )
11741176   MDRV_IMPORT_FROM(xboard)
11751177
11761178   MDRV_CPU_ADD_TAG("comm", Z80, 4000000)
src/mame/drivers/sslam.c
r1293r1294
8787
8888#define oki_time_base 0x08
8989
90static mame_timer *music_timer;
90static emu_timer *music_timer;
9191
9292static int sslam_sound;
9393static int sslam_melody;
r1293r1294
259259         sslam_track = 0;
260260         sslam_melody = 0;
261261         sslam_bar = 0;
262         mame_timer_enable(music_timer,0);
262         timer_enable(music_timer,0);
263263      }
264264      if (pattern) {
265265         logerror("Changing bar in music track to pattern %02x\n",pattern);
r1293r1294
287287               OKIM6295_data_0_w(0,0x40);
288288            OKIM6295_data_0_w(0,(0x80 | data));
289289            OKIM6295_data_0_w(0,0x81);
290            mame_timer_adjust(music_timer, MAME_TIME_IN_MSEC(4), 0, MAME_TIME_IN_HZ(250));   /* 250Hz for smooth sequencing */
290            timer_adjust(music_timer, ATTOTIME_IN_MSEC(4), 0, ATTOTIME_IN_HZ(250));   /* 250Hz for smooth sequencing */
291291         }
292292      }
293293      else {
r1293r1294
307307   }
308308   else {      /* use above 0x80 to turn off channels */
309309      if (track) {
310         mame_timer_enable(music_timer,0);
310         timer_enable(music_timer,0);
311311         sslam_track = 0;
312312         sslam_melody = 0;
313313         sslam_bar = 0;
r1293r1294
958958   state_save_register_global(sslam_bar);
959959   state_save_register_global(sslam_snd_bank);
960960
961   music_timer = mame_timer_alloc(music_playback);
961   music_timer = timer_alloc(music_playback);
962962}
963963
964964static DRIVER_INIT( powerbls )
src/mame/drivers/simpl156.c
r1293r1294
9999#include "deco16ic.h"
100100
101101static UINT32 *simpl156_systemram;
102UINT8 *simpl156_default_eeprom;
102static UINT8 *simpl156_default_eeprom;
103103
104104extern VIDEO_START( simpl156 );
105105extern VIDEO_UPDATE( simpl156 );
r1293r1294
486486   MDRV_CPU_VBLANK_INT(simpl156_vbl_interrupt,1)
487487
488488   MDRV_SCREEN_REFRESH_RATE(58)
489   MDRV_SCREEN_VBLANK_TIME(USEC_TO_SUBSECONDS(800))
489   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(800))
490490   MDRV_NVRAM_HANDLER(simpl156) // 93C45
491491
492492   /* video hardware */
r1293r1294
10401040
10411041/* some default eeproms */
10421042
1043UINT8 chainrec_eeprom[128] = {
1043static UINT8 chainrec_eeprom[128] = {
10441044   0x52, 0x54, 0x00, 0x50, 0x00, 0x00, 0x39, 0x11, 0x41, 0x54, 0x00, 0x43, 0x00, 0x50, 0xFF, 0xFF,
10451045   0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
10461046   0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
r1293r1294
11091109
11101110*/
11111111
1112UINT8 osman_eeprom[128] = {
1112static UINT8 osman_eeprom[128] = {
11131113   0xFF, 0xBE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
11141114   0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
11151115   0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
r1293r1294
11191119   0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
11201120   0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xBE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF
11211121};
1122UINT8 candance_eeprom[128] = {
1122static UINT8 candance_eeprom[128] = {
11231123   0xFF, 0xBF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
11241124   0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
11251125   0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
r1293r1294
11291129   0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
11301130   0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xBF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF
11311131};
1132UINT8 prtytime_eeprom[128] = {
1132static UINT8 prtytime_eeprom[128] = {
11331133   0xAF, 0x7F, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
11341134   0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
11351135   0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
r1293r1294
11401140   0xFF, 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xAF, 0x7F, 0xFF, 0xFF, 0x7F, 0xFE, 0xFF, 0xFF
11411141};
11421142
1143UINT8 gangonta_eeprom[128] = {
1143static UINT8 gangonta_eeprom[128] = {
11441144   0x2F, 0xFF, 0x2F, 0xFF, 0xFF, 0xFE, 0xFF, 0xFE, 0xFF, 0xFE, 0xED, 0xCB, 0xFF, 0xFF, 0xFF, 0xFF,
11451145   0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
11461146   0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
r1293r1294
11541154/* Everything seems more stable if we run the CPU speed x4 and use Idle skips.. maybe it has an internal multipler? */
11551155static READ32_HANDLER( joemacr_speedup_r )
11561156{
1157   if (activecpu_get_pc()==0x284)  cpu_spinuntil_time(MAME_TIME_IN_USEC(400));
1157   if (activecpu_get_pc()==0x284)  cpu_spinuntil_time(ATTOTIME_IN_USEC(400));
11581158   return simpl156_systemram[0x18/4];
11591159}
11601160
r1293r1294
11671167
11681168static READ32_HANDLER( chainrec_speedup_r )
11691169{
1170   if (activecpu_get_pc()==0x2d4)  cpu_spinuntil_time(MAME_TIME_IN_USEC(400));
1170   if (activecpu_get_pc()==0x2d4)  cpu_spinuntil_time(ATTOTIME_IN_USEC(400));
11711171   return simpl156_systemram[0x18/4];
11721172}
11731173
r1293r1294
11801180
11811181static READ32_HANDLER( prtytime_speedup_r )
11821182{
1183   if (activecpu_get_pc()==0x4f0)  cpu_spinuntil_time(MAME_TIME_IN_USEC(400));
1183   if (activecpu_get_pc()==0x4f0)  cpu_spinuntil_time(ATTOTIME_IN_USEC(400));
11841184   return simpl156_systemram[0xae0/4];
11851185}
11861186
r1293r1294
12011201
12021202static READ32_HANDLER( charlien_speedup_r )
12031203{
1204   if (activecpu_get_pc()==0xc8c8)  cpu_spinuntil_time(MAME_TIME_IN_USEC(400));
1204   if (activecpu_get_pc()==0xc8c8)  cpu_spinuntil_time(ATTOTIME_IN_USEC(400));
12051205   return simpl156_systemram[0x10/4];
12061206}
12071207
r1293r1294
12131213
12141214static READ32_HANDLER( osman_speedup_r )
12151215{
1216   if (activecpu_get_pc()==0x5974)  cpu_spinuntil_time(MAME_TIME_IN_USEC(400));
1216   if (activecpu_get_pc()==0x5974)  cpu_spinuntil_time(ATTOTIME_IN_USEC(400));
12171217   return simpl156_systemram[0x10/4];
12181218}
12191219
src/mame/drivers/lgp.c
r1293r1294
333333
334334   // IRQ
335335   cpunum_set_input_line(0, 0, ASSERT_LINE);
336   mame_timer_set(MAME_TIME_IN_USEC(50), 0, irq_stop);
336   timer_set(ATTOTIME_IN_USEC(50), 0, irq_stop);
337337
338338   laserdisc_vsync(discinfo);
339339}
src/mame/drivers/cliffhgr.c
r1293r1294
9191static render_texture *overlay_texture;
9292static mame_bitmap *last_video_bitmap;
9393
94static mame_timer *irq_timer;
94static emu_timer *irq_timer;
9595
9696/********************************************************/
9797
r1293r1294
251251   if ( phillips_code & 0x800000 )
252252      cpunum_set_input_line(0, 0, ASSERT_LINE);
253253
254   mame_timer_adjust(irq_timer, video_screen_get_time_until_pos(0, param, 0), param, time_zero);
254   timer_adjust(irq_timer, video_screen_get_time_until_pos(0, param, 0), param, attotime_zero);
255255}
256256
257257static void vdp_interrupt (int state)
r1293r1294
264264static MACHINE_START( cliffhgr )
265265{
266266   discinfo = laserdisc_init(LASERDISC_TYPE_PR8210, get_disk_handle(0), 0);
267   irq_timer = mame_timer_alloc(cliff_irq_callback);
267   irq_timer = timer_alloc(cliff_irq_callback);
268268}
269269
270270static MACHINE_RESET( cliffhgr )
271271{
272272   port_bank = 0;
273273   phillips_code = 0;
274   mame_timer_adjust(irq_timer, video_screen_get_time_until_pos(0, 17, 0), 17, time_zero);
274   timer_adjust(irq_timer, video_screen_get_time_until_pos(0, 17, 0), 17, attotime_zero);
275275}
276276
277277/********************************************************/
src/mame/drivers/artmagic.c
r1293r1294
717717 *
718718 *************************************/
719719
720MACHINE_DRIVER_START( artmagic )
720static MACHINE_DRIVER_START( artmagic )
721721
722722   /* basic machine hardware */
723723   MDRV_CPU_ADD_TAG("main", M68000, MASTER_CLOCK_25MHz/2)
r1293r1294
751751MACHINE_DRIVER_END
752752
753753
754MACHINE_DRIVER_START( stonebal )
754static MACHINE_DRIVER_START( stonebal )
755755   MDRV_IMPORT_FROM(artmagic)
756756
757757   MDRV_CPU_MODIFY("main")
src/mame/drivers/galpani2.c
r1293r1294
460460
461461/* CPU#1 Interrups */
462462#define GALPANI2_INTERRUPTS_NUM   4
463INTERRUPT_GEN( galpani2_interrupt )
463static INTERRUPT_GEN( galpani2_interrupt )
464464{
465465   switch ( cpu_getiloops() )
466466   {
r1293r1294
474474/* CPU#2 Interrups */
475475/* lev 3,4 & 5 are tested on power up. The rest is rte, but lev 7 */
476476#define GALPANI2_INTERRUPTS_NUM2   3
477INTERRUPT_GEN( galpani2_interrupt2 )
477static INTERRUPT_GEN( galpani2_interrupt2 )
478478{
479479   switch ( cpu_getiloops() )
480480   {
src/mame/drivers/hornet.c
r1293r1294
369369   }
370370}
371371
372void K037122_tile_draw(int chip, mame_bitmap *bitmap, const rectangle *cliprect)
372static void K037122_tile_draw(int chip, mame_bitmap *bitmap, const rectangle *cliprect)
373373{
374374   if (K037122_reg[chip][0xc] & 0x10000)
375375   {
r1293r1294
970970static int jvs_rdata_ptr = 0;
971971static int jvs_sdata_ptr = 0;
972972
973UINT8 jamma_jvs_r(void)
973static UINT8 jamma_jvs_r(void)
974974{
975975   UINT8 r;
976976   r = jvs_rdata[jvs_rdata_ptr];
r1293r1294
979979   return r;
980980}
981981
982void jamma_jvs_w(UINT8 data)
982static void jamma_jvs_w(UINT8 data)
983983{
984984   jvs_sdata[jvs_sdata_ptr] = data;
985985   jvs_sdata_ptr++;
r1293r1294
10341034   return outptr;
10351035}
10361036
1037void jamma_jvs_cmd_exec(void)
1037static void jamma_jvs_cmd_exec(void)
10381038{
10391039   UINT8 sync, node, byte_num;
10401040   UINT8 data[1024], rdata[1024];
src/mame/drivers/ccastles.c
r1293r1294
139139 *************************************/
140140
141141static const UINT8 *syncprom;
142static mame_timer *irq_timer;
142static emu_timer *irq_timer;
143143
144144static UINT8 irq_state;
145145static UINT8 *nvram_stage;
r1293r1294
164164         break;
165165
166166   /* next one at the start of this scanline */
167   mame_timer_adjust(irq_timer, video_screen_get_time_until_pos(0, curscanline, 0), curscanline, time_zero);
167   timer_adjust(irq_timer, video_screen_get_time_until_pos(0, curscanline, 0), curscanline, attotime_zero);
168168}
169169
170170
r1293r1294
226226   visarea.max_x = 255;
227227   visarea.min_y = ccastles_vblank_end;
228228   visarea.max_y = ccastles_vblank_start - 1;
229   video_screen_configure(0, 320, 256, &visarea, HZ_TO_SUBSECONDS(PIXEL_CLOCK) * VTOTAL * HTOTAL);
229   video_screen_configure(0, 320, 256, &visarea, HZ_TO_ATTOSECONDS(PIXEL_CLOCK) * VTOTAL * HTOTAL);
230230
231231   /* configure the ROM banking */
232232   memory_configure_bank(1, 0, 2, memory_region(REGION_CPU1) + 0xa000, 0x6000);
233233
234234   /* create a timer for IRQs and set up the first callback */
235   irq_timer = mame_timer_alloc(clock_irq);
235   irq_timer = timer_alloc(clock_irq);
236236   irq_state = 0;
237237   schedule_next_irq(0);
238238
src/mame/drivers/exterm.c
r1293r1294
7878static UINT8 aimpos[2];
7979static UINT8 trackball_old[2];
8080
81static mame_timer *sound_nmi_timer;
81static emu_timer *sound_nmi_timer;
8282static UINT8 master_sound_latch;
8383static UINT8 slave_sound_latch;
8484static UINT8 sound_control;
r1293r1294
104104
105105static MACHINE_RESET( exterm )
106106{
107   sound_nmi_timer = mame_timer_alloc(master_sound_nmi_callback);
107   sound_nmi_timer = timer_alloc(master_sound_nmi_callback);
108108}
109109
110110
r1293r1294
256256   /* rate is controlled by the value written here */
257257   /* this value is latched into up-counters, which are clocked at the */
258258   /* input clock / 256 */
259   mame_time nmi_rate = scale_up_mame_time(MAME_TIME_IN_HZ(4000000), 4096 * (256 - data));
260   mame_timer_adjust(sound_nmi_timer, nmi_rate, 0, nmi_rate);
259   attotime nmi_rate = attotime_mul(ATTOTIME_IN_HZ(4000000), 4096 * (256 - data));
260   timer_adjust(sound_nmi_timer, nmi_rate, 0, nmi_rate);
261261}
262262
263263
src/mame/drivers/dragrace.c
r1293r1294
3636
3737static MACHINE_RESET( dragrace )
3838{
39   mame_timer_pulse(video_screen_get_frame_period(0), 0, dragrace_frame_callback);
39   timer_pulse(video_screen_get_frame_period(0), 0, dragrace_frame_callback);
4040}
4141
4242static void dragrace_update_misc_flags(void)
src/mame/drivers/discoboy.c
r1293r1294
3939#include "sound/msm5205.h"
4040#include "sound/3812intf.h"
4141
42UINT8* discoboy_ram_part1;
43UINT8* discoboy_ram_part2;
44UINT8* discoboy_ram_part3;
45UINT8* discoboy_ram_part4;
46UINT8* discoboy_ram_att;
42static UINT8* discoboy_ram_part1;
43static UINT8* discoboy_ram_part2;
44static UINT8* discoboy_ram_part3;
45static UINT8* discoboy_ram_part4;
46static UINT8* discoboy_ram_att;
4747
48UINT8 discoboy_ram_bank;
48static UINT8 discoboy_ram_bank;
4949static UINT8 port_00;
50UINT8 discoboy_gfxbank;
50static UINT8 discoboy_gfxbank;
5151
5252static VIDEO_START( discoboy )
5353{
r1293r1294
163163   return 0;
164164}
165165
166#ifdef UNUSED_FUNCTION
166167void discoboy_setrombank(UINT8 data)
167168{
168169   UINT8 *ROM = memory_region(REGION_CPU1);
169170   data &=0x2f;
170171   memory_set_bankptr(1, &ROM[0x6000+(data*0x1000)] );
171172}
173#endif
172174
173175static WRITE8_HANDLER( rambank_select_w )
174176{
src/mame/drivers/mediagx.c
r1293r1294
112112static int dacl_ptr = 0;
113113static int dacr_ptr = 0;
114114
115static mame_timer *sound_timer;
115static emu_timer *sound_timer;
116116static UINT8 ad1847_regs[16];
117117static UINT32 ad1847_sample_counter = 0;
118118static UINT32 ad1847_sample_rate;
r1293r1294
642642static TIMER_CALLBACK( sound_timer_callback )
643643{
644644   ad1847_sample_counter = 0;
645   mame_timer_adjust(sound_timer, MAME_TIME_IN_MSEC(10), 0, time_zero);
645   timer_adjust(sound_timer, ATTOTIME_IN_MSEC(10), 0, attotime_zero);
646646
647647   dmadac_transfer(0, 1, 0, 1, dacl_ptr, dacl);
648648   dmadac_transfer(1, 1, 0, 1, dacr_ptr, dacr);
r1293r1294
860860   dacl = auto_malloc(65536 * sizeof(INT16));
861861   dacr = auto_malloc(65536 * sizeof(INT16));
862862
863   sound_timer = mame_timer_alloc(sound_timer_callback);
864   mame_timer_adjust(sound_timer, MAME_TIME_IN_MSEC(10), 0, time_zero);
863   sound_timer = timer_alloc(sound_timer_callback);
864   timer_adjust(sound_timer, ATTOTIME_IN_MSEC(10), 0, attotime_zero);
865865
866866   dmadac_enable(0, 2, 1);
867867   ide_controller_reset(0);
src/mame/drivers/orbit.c
r1293r1294
270270   MDRV_CPU_PERIODIC_INT(orbit_interrupt, 240)
271271
272272   MDRV_SCREEN_REFRESH_RATE(60) /* interlaced */
273   MDRV_SCREEN_VBLANK_TIME(USEC_TO_SUBSECONDS((int) ((22. * 1000000) / (262. * 60) + 0.5)))
273   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC((int) ((22. * 1000000) / (262. * 60) + 0.5)))
274274   MDRV_MACHINE_RESET(orbit)
275275
276276   /* video hardware */
src/mame/drivers/policetr.c
r1293r1294
128128static INTERRUPT_GEN( irq4_gen )
129129{
130130   cpunum_set_input_line(0, R3000_IRQ4, ASSERT_LINE);
131   mame_timer_set(video_screen_get_time_until_pos(0, 0, 0), 0, irq5_gen);
131   timer_set(video_screen_get_time_until_pos(0, 0, 0), 0, irq5_gen);
132132}
133133
134134
r1293r1294
472472};
473473
474474
475MACHINE_DRIVER_START( policetr )
475static MACHINE_DRIVER_START( policetr )
476476
477477   /* basic machine hardware */
478478   MDRV_CPU_ADD_TAG("main", R3000BE, MASTER_CLOCK/2)
r1293r1294
504504MACHINE_DRIVER_END
505505
506506
507MACHINE_DRIVER_START( sshooter )
507static MACHINE_DRIVER_START( sshooter )
508508   MDRV_IMPORT_FROM(policetr)
509509
510510   /* basic machine hardware */
src/mame/drivers/seibuspi.c
r1293r1294
17851785   MDRV_CPU_PROGRAM_MAP(spisound_map, 0)
17861786
17871787   MDRV_SCREEN_REFRESH_RATE(54)
1788   MDRV_SCREEN_VBLANK_TIME(USEC_TO_SUBSECONDS(0))
1788   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(0))
17891789   MDRV_INTERLEAVE(200)
17901790
17911791   MDRV_MACHINE_RESET(spi)
r1293r1294
20992099   MDRV_CPU_VBLANK_INT(spi_interrupt, 1)
21002100
21012101   MDRV_SCREEN_REFRESH_RATE(54)
2102   MDRV_SCREEN_VBLANK_TIME(USEC_TO_SUBSECONDS(0))
2102   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(0))
21032103
21042104   MDRV_NVRAM_HANDLER(sxx2f)
21052105   MDRV_MACHINE_RESET(seibu386)
src/mame/drivers/coolpool.c
r1293r1294
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 mame_timer *nvram_write_timer;
57static emu_timer *nvram_write_timer;
5858
5959
6060
r1293r1294
146146static MACHINE_RESET( amerdart )
147147{
148148   nvram_write_enable = 0;
149   nvram_write_timer = mame_timer_alloc(nvram_write_timeout);
149   nvram_write_timer = timer_alloc(nvram_write_timeout);
150150}
151151
152152
r1293r1294
154154{
155155   tlc34076_reset(6);
156156   nvram_write_enable = 0;
157   nvram_write_timer = mame_timer_alloc(nvram_write_timeout);
157   nvram_write_timer = timer_alloc(nvram_write_timeout);
158158}
159159
160160
r1293r1294
181181   if (!memcmp(nvram_unlock_seq, nvram_write_seq, sizeof(nvram_unlock_seq)))
182182   {
183183      nvram_write_enable = 1;
184      mame_timer_adjust(nvram_write_timer, MAME_TIME_IN_MSEC(1000), 0, time_zero);
184      timer_adjust(nvram_write_timer, ATTOTIME_IN_MSEC(1000), 0, attotime_zero);
185185   }
186186}
187187
r1293r1294
277277{
278278   logerror("%08x:IOP write %04x\n", activecpu_get_pc(), data);
279279   COMBINE_DATA(&iop_cmd);
280   mame_timer_set(MAME_TIME_IN_USEC(100), 0, amerdart_iop_response);
280   timer_set(ATTOTIME_IN_USEC(100), 0, amerdart_iop_response);
281281}
282282
283283
r1293r1294
314314   cpunum_set_input_line(1, 0, HOLD_LINE);   /* ???  I have no idea who should generate this! */
315315                              /* the DSP polls the status bit so it isn't strictly */
316316                              /* necessary to also have an IRQ */
317   cpu_boost_interleave(time_zero, MAME_TIME_IN_USEC(50));
317   cpu_boost_interleave(attotime_zero, ATTOTIME_IN_USEC(50));
318318}
319319
320320
r1293r1294
679679 *
680680 *************************************/
681681
682MACHINE_DRIVER_START( amerdart )
682static MACHINE_DRIVER_START( amerdart )
683683
684684   /* basic machine hardware */
685685   MDRV_CPU_ADD(TMS34010, 40000000/TMS34010_CLOCK_DIVIDER)
src/mame/drivers/sauro.c
r1293r1294
339339   MDRV_CPU_VBLANK_INT(irq0_line_hold, 1)
340340
341341   MDRV_SCREEN_REFRESH_RATE(60)
342   MDRV_SCREEN_VBLANK_TIME(USEC_TO_SUBSECONDS(5000))  // frames per second, vblank duration (otherwise sprites lag)
342   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(5000))  // frames per second, vblank duration (otherwise sprites lag)
343343
344344   /* video hardware */
345345   MDRV_VIDEO_ATTRIBUTES(VIDEO_TYPE_RASTER)
src/mame/drivers/drmicro.c
r1293r1294
3030
3131static int drmicro_nmi_enable;
3232
33INTERRUPT_GEN( drmicro_interrupt )
33static INTERRUPT_GEN( drmicro_interrupt )
3434{
3535   if (drmicro_nmi_enable)
3636       cpunum_set_input_line(0, INPUT_LINE_NMI, PULSE_LINE);
src/mame/drivers/system1.c
r1293r1294
113113   soundlatch_w(0,data);
114114   cpunum_set_input_line(1,INPUT_LINE_NMI,PULSE_LINE);
115115   /* spin for a while to let the Z80 read the command (fixes hanging sound in Regulus) */
116   cpu_spinuntil_time(MAME_TIME_IN_USEC(50));
116   cpu_spinuntil_time(ATTOTIME_IN_USEC(50));
117117}
118118
119119
src/mame/drivers/cultures.c
r1293r1294
312312   8*64,
313313};
314314
315GFXDECODE_START( culture )
315static GFXDECODE_START( culture )
316316   GFXDECODE_ENTRY(REGION_GFX1, 0, gfxlayout, 0, 1 )
317317   GFXDECODE_ENTRY(REGION_GFX2, 0, gfxlayout, 0, 1 )
318318   GFXDECODE_ENTRY(REGION_GFX3, 0, gfxlayout, 0, 1 )
src/mame/drivers/jedi.c
r1293r1294
129129static UINT8 speech_strobe_state;
130130static UINT8 nvram_enabled;
131131
132static mame_timer *jedi_timer;
132static emu_timer *jedi_timer;
133133
134134
135135/*************************************
r1293r1294
150150   scanline += 32;
151151   if (scanline > 256)
152152      scanline = 32;
153   mame_timer_adjust(jedi_timer,video_screen_get_time_until_pos(0, scanline, 0), scanline, time_zero);
153   timer_adjust(jedi_timer,video_screen_get_time_until_pos(0, scanline, 0), scanline, attotime_zero);
154154}
155155
156156
r1293r1294
169169static MACHINE_START( jedi )
170170{
171171   /* set a timer to run the interrupts */
172   jedi_timer = mame_timer_alloc(generate_interrupt);
173   mame_timer_adjust(jedi_timer,video_screen_get_time_until_pos(0, 32, 0), 32, time_zero);
172   jedi_timer = timer_alloc(generate_interrupt);
173   timer_adjust(jedi_timer,video_screen_get_time_until_pos(0, 32, 0), 32, attotime_zero);
174174
175175   /* configure the banks */
176176   memory_configure_bank(1, 0, 3, memory_region(REGION_CPU1) + 0x10000, 0x4000);
src/mame/drivers/bfm_sc2.c
r1293r1294
150150#include "machine/steppers.h" // stepper motor
151151
152152#include "machine/bfm_bd1.h"  // vfd
153#include "machine/mmtr.h"
153#include "machine/meters.h"
154154
155155#include "bfm_sc2.lh"
156156#include "gldncrwn.lh"
r1293r1294
202202static int data_to_uart1;
203203static int data_to_uart2;
204204static int locked;         // hardware lock/unlock status (0=unlocked)
205static int timer_enabled;
205static int is_timer_enabled;
206206static int reel_changed;
207207static int coin_inhibits;
208208static int irq_timer_stat;
r1293r1294
304304   mmtr_latch        = 0;
305305   triac_latch       = 0;
306306   irq_status        = 0;
307   timer_enabled     = 1;
307   is_timer_enabled  = 1;
308308   coin_inhibits     = 0;
309309   irq_timer_stat    = 0;
310310   expansion_latch   = 0;
r1293r1294
510510      }
511511   }
512512
513   if ( timer_enabled )
513   if ( is_timer_enabled )
514514   {
515515      irq_timer_stat = 0x01;
516516      irq_status     = 0x02;
r1293r1294
608608static WRITE8_HANDLER( mmtr_w )
609609{
610610   int  changed = mmtr_latch ^ data;
611   long cycles  = MAME_TIME_TO_CYCLES(0, mame_timer_get_time() );
611   long cycles  = ATTOTIME_TO_CYCLES(0, timer_get_time() );
612612
613613   mmtr_latch = data;
614614
r1293r1294
899899
900900static WRITE8_HANDLER( timerirq_w )
901901{
902   timer_enabled = data & 1;
902   is_timer_enabled = data & 1;
903903}
904904
905905///////////////////////////////////////////////////////////////////////////
r1293r1294
30693069
30703070   MDRV_CPU_ADD_TAG("adder2", M6809, 2000000 )         // adder2 board 6809 CPU at 2 Mhz
30713071   MDRV_CPU_PROGRAM_MAP(adder2_memmap,0)            // setup adder2 board memorymap
3072   MDRV_CPU_VBLANK_INT(adder2_vbl, 1);               // board has a VBL IRQ
3072   MDRV_CPU_VBLANK_INT(adder2_vbl, 1)               // board has a VBL IRQ
30733073
30743074   MDRV_SPEAKER_STANDARD_MONO("mono")
30753075   MDRV_SOUND_ADD(UPD7759, UPD7759_STANDARD_CLOCK)
src/mame/drivers/suprnova.c
r1293r1294
454454
455455static MACHINE_RESET(skns)
456456{
457   mame_timer_pulse(MAME_TIME_IN_MSEC(2), 15, interrupt_callback);
458   mame_timer_pulse(MAME_TIME_IN_MSEC(8), 11, interrupt_callback);
459   mame_timer_pulse(MAME_TIME_IN_CYCLES(1824, 0), 9, interrupt_callback);
457   timer_pulse(ATTOTIME_IN_MSEC(2), 15, interrupt_callback);
458   timer_pulse(ATTOTIME_IN_MSEC(8), 11, interrupt_callback);
459   timer_pulse(ATTOTIME_IN_CYCLES(1824, 0), 9, interrupt_callback);
460460
461461   memory_set_bankptr(1,memory_region(REGION_USER1));
462462}
src/mame/drivers/namcofl.c
r1293r1294
130130#include "audio/namcoc7x.h"
131131
132132
133static mame_timer *raster_interrupt_timer;
133static emu_timer *raster_interrupt_timer;
134134
135135VIDEO_START( namcofl );
136136VIDEO_UPDATE( namcofl );
r1293r1294
182182      UINT16 v = paletteram32[offset] >> 16;
183183      UINT16 triggerscanline=(((v>>8)&0xff)|((v&0xff)<<8))-(32+1);
184184
185      mame_timer_adjust(raster_interrupt_timer, video_screen_get_time_until_pos(0, triggerscanline, 0), 0, time_zero);
185      timer_adjust(raster_interrupt_timer, video_screen_get_time_until_pos(0, triggerscanline, 0), 0, attotime_zero);
186186   }
187187}
188188
r1293r1294
314314static TIMER_CALLBACK( network_interrupt_callback )
315315{
316316   cpunum_set_input_line(0, I960_IRQ0, ASSERT_LINE);
317   mame_timer_set(video_screen_get_frame_period(0), 0, network_interrupt_callback);
317   timer_set(video_screen_get_frame_period(0), 0, network_interrupt_callback);
318318}
319319
320320
321321static TIMER_CALLBACK( vblank_interrupt_callback )
322322{
323323   cpunum_set_input_line(0, I960_IRQ2, ASSERT_LINE);
324   mame_timer_set(video_screen_get_frame_period(0), 0, vblank_interrupt_callback);
324   timer_set(video_screen_get_frame_period(0), 0, vblank_interrupt_callback);
325325}
326326
327327
r1293r1294
329329{
330330   video_screen_update_partial(0, video_screen_get_vpos(0));
331331   cpunum_set_input_line(0, I960_IRQ1, ASSERT_LINE);
332   mame_timer_adjust(raster_interrupt_timer, video_screen_get_frame_period(0), 0, time_zero);
332   timer_adjust(raster_interrupt_timer, video_screen_get_frame_period(0), 0, attotime_zero);
333333}
334334
335335
336336static MACHINE_START( namcofl )
337337{
338   raster_interrupt_timer = mame_timer_alloc(raster_interrupt_callback);
338   raster_interrupt_timer = timer_alloc(raster_interrupt_callback);
339339}
340340
341341
342342static MACHINE_RESET( namcofl )
343343{
344   mame_timer_set(video_screen_get_time_until_pos(0, machine->screen[0].visarea.max_y + 3, 0), 0, network_interrupt_callback);
345   mame_timer_set(video_screen_get_time_until_pos(0, machine->screen[0].visarea.max_y + 1, 0), 0, vblank_interrupt_callback);
344   timer_set(video_screen_get_time_until_pos(0, machine->screen[0].visarea.max_y + 3, 0), 0, network_interrupt_callback);
345   timer_set(video_screen_get_time_until_pos(0, machine->screen[0].visarea.max_y + 1, 0), 0, vblank_interrupt_callback);
346346}
347347
348348
src/mame/drivers/dynax.c
r1293r1294
9494***************************************************************************/
9595
9696UINT8 dynax_blitter_irq;
97UINT8 dynax_sound_irq;
98UINT8 dynax_vblank_irq;
97static UINT8 dynax_sound_irq;
98static UINT8 dynax_vblank_irq;
9999
100100/* It runs in IM 0, thus needs an opcode on the data bus */
101101void sprtmtch_update_irq(void)
r1293r1294
118118   sprtmtch_update_irq();
119119}
120120
121INTERRUPT_GEN( sprtmtch_vblank_interrupt )
121static INTERRUPT_GEN( sprtmtch_vblank_interrupt )
122122{
123123   dynax_vblank_irq = 1;
124124   sprtmtch_update_irq();
125125}
126126
127void sprtmtch_sound_callback(int state)
127static void sprtmtch_sound_callback(int state)
128128{
129129   dynax_sound_irq = state;
130130   sprtmtch_update_irq();
r1293r1294
164164   jantouki_update_irq();
165165}
166166
167INTERRUPT_GEN( jantouki_vblank_interrupt )
167static INTERRUPT_GEN( jantouki_vblank_interrupt )
168168{
169169   dynax_vblank_irq = 1;
170170   jantouki_update_irq();
r1293r1294
175175                            Jantouki - Sound CPU
176176***************************************************************************/
177177
178UINT8 dynax_soundlatch_irq;
179UINT8 dynax_sound_vblank_irq;
178static UINT8 dynax_soundlatch_irq;
179static UINT8 dynax_sound_vblank_irq;
180180
181void jantouki_sound_update_irq(void)
181static void jantouki_sound_update_irq(void)
182182{
183183   int irq   =   ((dynax_sound_irq)         ? 0x08 : 0) |
184184            ((dynax_soundlatch_irq)      ? 0x10 : 0) |
r1293r1294
186186   cpunum_set_input_line_and_vector(1, 0, irq ? ASSERT_LINE : CLEAR_LINE, 0xc7 | irq); /* rst $xx */
187187}
188188
189INTERRUPT_GEN( jantouki_sound_vblank_interrupt )
189static INTERRUPT_GEN( jantouki_sound_vblank_interrupt )
190190{
191191   dynax_sound_vblank_irq = 1;
192192   jantouki_sound_update_irq();
r1293r1294
198198   jantouki_sound_update_irq();
199199}
200200
201void jantouki_sound_callback(int state)
201static void jantouki_sound_callback(int state)
202202{
203203   dynax_sound_irq = state;
204204   jantouki_sound_update_irq();
r1293r1294
845845                            Jantouki - Main CPU
846846***************************************************************************/
847847
848UINT8 dynax_soundlatch_ack;
849UINT8 dynax_soundlatch_full;
848static UINT8 dynax_soundlatch_ack;
849static UINT8 dynax_soundlatch_full;
850850static UINT8 latch;
851851
852852static READ8_HANDLER( jantouki_soundlatch_ack_r )
r1293r1294
11511151
11521152static int rombank;
11531153static UINT8 *romptr;
1154int tenkai_dswsel, tenkai_ipsel, tenkai_ip;
1154static int tenkai_dswsel, tenkai_ipsel, tenkai_ip;
11551155static UINT8 tenkai_p5_val;
11561156
11571157static WRITE8_HANDLER( tenkai_ipsel_w )
r1293r1294
37933793  what was it trying to do?
37943794  set an irq and clear it before its even taken? */
37953795
3796INTERRUPT_GEN( yarunara_clock_interrupt )
3796static INTERRUPT_GEN( yarunara_clock_interrupt )
37973797{
37983798   static int i=0;
37993799   i^=1;
r1293r1294
39483948   cpunum_set_input_line_and_vector(0, 0, HOLD_LINE, 0xfa);
39493949}
39503950
3951INTERRUPT_GEN( mjelctrn_vblank_interrupt )
3951static INTERRUPT_GEN( mjelctrn_vblank_interrupt )
39523952{
39533953   // This is a kludge to avoid losing blitter interrupts
39543954   // there should be a vblank ack mechanism
r1293r1294
39823982   cpunum_set_input_line_and_vector(0, 0, HOLD_LINE, 0x42);
39833983}
39843984
3985INTERRUPT_GEN( neruton_vblank_interrupt )
3985static INTERRUPT_GEN( neruton_vblank_interrupt )
39863986{
39873987   // This is a kludge to avoid losing blitter interrupts
39883988   // there should be a vblank ack mechanism
r1293r1294
40114011/*  It runs in IM 2, thus needs a vector on the data bus:
40124012    0x42 and 0x44 are very similar, they should be triggered by the blitter
40134013    0x40 is vblank  */
4014INTERRUPT_GEN( majxtal7_vblank_interrupt )
4014static INTERRUPT_GEN( majxtal7_vblank_interrupt )
40154015{
40164016   // This is a kludge to avoid losing blitter interrupts
40174017   // there should be a vblank ack mechanism
r1293r1294
40814081                               Mahjong Tenkaigen
40824082***************************************************************************/
40834083
4084INTERRUPT_GEN( tenkai_interrupt )
4084static INTERRUPT_GEN( tenkai_interrupt )
40854085{
40864086   switch(cpu_getiloops())
40874087   {
src/mame/drivers/zn.c
r1293r1294
11381138   memory_set_bankptr( 1, memory_region( REGION_USER2 ) + ( ( data & 3 ) * 0x800000 ) );
11391139}
11401140
1141INTERRUPT_GEN( coh1000t_vblank )
1141static INTERRUPT_GEN( coh1000t_vblank )
11421142{
11431143   /* kludge: stop dropping into test mode on bootup */
11441144   if( strcmp( Machine->gamedrv->name, "raystorm" ) == 0 )
r1293r1294
26432643   zn_machine_init();
26442644}
26452645
2646INTERRUPT_GEN( coh1002v_vblank )
2646static INTERRUPT_GEN( coh1002v_vblank )
26472647{
26482648   /* kludge: to stop dropping into test mode on bootup */
26492649   if(strcmp( Machine->gamedrv->name, "sncwgltd" ) == 0 )
r1293r1294
29102910   return ret;
29112911}
29122912
2913ADDRESS_MAP_START( cbaj_z80_map, ADDRESS_SPACE_PROGRAM, 8 )
2913static ADDRESS_MAP_START( cbaj_z80_map, ADDRESS_SPACE_PROGRAM, 8 )
29142914   AM_RANGE( 0x0000, 0x7fff ) AM_ROM
29152915   AM_RANGE( 0x8000, 0xffff ) AM_RAM
29162916ADDRESS_MAP_END
29172917
2918ADDRESS_MAP_START( cbaj_z80_port_map, ADDRESS_SPACE_IO, 8)
2918static ADDRESS_MAP_START( cbaj_z80_port_map, ADDRESS_SPACE_IO, 8)
29192919   ADDRESS_MAP_FLAGS( AMEF_ABITS(8) )
29202920   AM_RANGE( 0x84, 0x84 ) AM_READWRITE( YMZ280B_status_0_r, YMZ280B_register_0_w )
29212921   AM_RANGE( 0x85, 0x85 ) AM_READWRITE( YMZ280B_status_0_r, YMZ280B_data_0_w )
src/mame/drivers/megadriv.c
r1293r1294
7373static UINT8* sprite_renderline;
7474static UINT8* highpri_renderline;
7575static UINT16* video_renderline;
76UINT16* megadrive_vdp_palette_lookup;
77UINT16* megadrive_vdp_palette_lookup_shadow;
78UINT16* megadrive_vdp_palette_lookup_highlight;
76static UINT16* megadrive_vdp_palette_lookup;
77static UINT16* megadrive_vdp_palette_lookup_shadow;
78static UINT16* megadrive_vdp_palette_lookup_highlight;
7979static UINT8 oldscreenwidth = 3;
8080UINT16* megadrive_ram;
8181UINT8 megadrive_vram_fill_pending = 0;
8282UINT16 megadrive_vram_fill_length = 0;
8383int genesis_scanline_counter = 0;
8484int megadrive_sprite_collision = 0;
85int megadrive_region_export;
86int megadrive_region_pal;
87int megadrive_max_hposition;
85static int megadrive_region_export;
86static int megadrive_region_pal;
87static int megadrive_max_hposition;
8888
8989
90static mame_timer* frame_timer;
91static mame_timer* scanline_timer;
92static mame_timer* irq6_on_timer;
93static mame_timer* irq4_on_timer;
90static emu_timer* frame_timer;
91static emu_timer* scanline_timer;
92static emu_timer* irq6_on_timer;
93static emu_timer* irq4_on_timer;
9494static mame_bitmap* render_bitmap;
95//mame_timer* vblankirq_off_timer;
95//emu_timer* vblankirq_off_timer;
9696
9797
9898#ifdef UNUSED_FUNCTION
r1293r1294
136136   UINT8* z80_prgram;
137137} genz80;
138138
139void megadriv_z80_bank_w(UINT16 data)
139static void megadriv_z80_bank_w(UINT16 data)
140140{
141141   genz80.z80_bank_partial |= (data & 0x01)<<23; // add new bit to partial address
142142   genz80.z80_bank_pos++;
r1293r1294
199199
200200
201201
202int megadrive_vdp_command_pending; // 2nd half of command pending..
203UINT16 megadrive_vdp_command_part1;
204UINT16 megadrive_vdp_command_part2;
205UINT8  megadrive_vdp_code;
206UINT16 megadrive_vdp_address;
207UINT16 megadrive_vdp_register[0x20];
208UINT16* megadrive_vdp_vram;
209UINT16* megadrive_vdp_cram;
210UINT16* megadrive_vdp_vsram;
202static int megadrive_vdp_command_pending; // 2nd half of command pending..
203static UINT16 megadrive_vdp_command_part1;
204static UINT16 megadrive_vdp_command_part2;
205static UINT8  megadrive_vdp_code;
206static UINT16 megadrive_vdp_address;
207static UINT16 megadrive_vdp_register[0x20];
208static UINT16* megadrive_vdp_vram;
209static UINT16* megadrive_vdp_cram;
210static UINT16* megadrive_vdp_vsram;
211211/* The VDP keeps a 0x400 byte on-chip cache of the Sprite Attribute Table
212212   to speed up processing */
213UINT16* megadrive_vdp_internal_sprite_attribute_table;
213static UINT16* megadrive_vdp_internal_sprite_attribute_table;
214214
215215/*
216216
r1293r1294
401401}
402402
403403
404void megadriv_vdp_data_port_w(int data)
404static void megadriv_vdp_data_port_w(int data)
405405{
406406   megadrive_vdp_command_pending = 0;
407407
r1293r1294
497497
498498
499499
500void megadrive_vdp_set_register(int regnum, UINT8 value)
500static void megadrive_vdp_set_register(int regnum, UINT8 value)
501501{
502502   megadrive_vdp_register[regnum] = value;
503503
r1293r1294
555555//  mame_printf_debug("%06x Setting VDP Register #%02x to %02x\n",activecpu_get_pc(), regnum,value);
556556}
557557
558void update_megadrive_vdp_code_and_address(void)
558static void update_megadrive_vdp_code_and_address(void)
559559{
560560   megadrive_vdp_code = ((megadrive_vdp_command_part1 & 0xc000) >> 14) |
561561                        ((megadrive_vdp_command_part2 & 0x00f0) >> 2);
r1293r1294
608608
609609/* Note, In reality this transfer is NOT instant, the 68k isn't paused
610610   as the 68k address bus isn't accessed */
611void megadrive_do_insta_vram_copy(UINT32 source, UINT16 length);
611static void megadrive_do_insta_vram_copy(UINT32 source, UINT16 length);
612612
613613/* Wani Wani World, James Pond 3, Pirates Gold! */
614614void megadrive_do_insta_vram_copy(UINT32 source, UINT16 length)
r1293r1294
639639}
640640
641641/* Instant, but we pause the 68k a bit */
642void megadrive_do_insta_68k_to_vram_dma(UINT32 source,int length)
642static void megadrive_do_insta_68k_to_vram_dma(UINT32 source,int length)
643643{
644644   int count;
645645
646646   if (length==0x00) length = 0xffff;
647647
648648   /* This is a hack until real DMA timings are implemented */
649   cpu_spinuntil_time(MAME_TIME_IN_NSEC(length*1000/3500));
649   cpu_spinuntil_time(ATTOTIME_IN_NSEC(length*1000/3500));
650650
651651   for (count = 0;count<(length>>1);count++)
652652   {
r1293r1294
666666}
667667
668668
669void megadrive_do_insta_68k_to_cram_dma(UINT32 source,UINT16 length)
669static void megadrive_do_insta_68k_to_cram_dma(UINT32 source,UINT16 length)
670670{
671671   int count;
672672
r1293r1294
694694
695695}
696696
697void megadrive_do_insta_68k_to_vsram_dma(UINT32 source,UINT16 length)
697static void megadrive_do_insta_68k_to_vsram_dma(UINT32 source,UINT16 length)
698698{
699699   int count;
700700
r1293r1294
854854   }
855855}
856856
857void megadriv_vdp_ctrl_port_w(int data)
857static void megadriv_vdp_ctrl_port_w(int data)
858858{
859859//  logerror("write to vdp control port %04x\n",data);
860860   megadrive_vram_fill_pending = 0; // ??
r1293r1294
958958   return megadrive_vdp_cram[(megadrive_vdp_address&0x7e)>>1];
959959}
960960
961UINT16 megadriv_vdp_data_port_r(void)
961static UINT16 megadriv_vdp_data_port_r(void)
962962{
963963   UINT16 retdata=0;
964964
r1293r1294
10751075
10761076
10771077
1078UINT16 megadriv_vdp_ctrl_port_r(void)
1078static UINT16 megadriv_vdp_ctrl_port_r(void)
10791079{
10801080   /* Battletoads is very fussy about the vblank flag
10811081       it wants it to be 1. in scanline 224 */
r1293r1294
12411241
12421242
12431243
1244UINT16 megadriv_read_hv_counters(void)
1244static UINT16 megadriv_read_hv_counters(void)
12451245{
12461246   /* Bubble and Squeek wants vcount=0xe0 */
12471247   /* Dracula is very sensitive to this */
r1293r1294
14111411   }
14121412}
14131413
1414static mame_timer *io_timeout[2];
1414static emu_timer *io_timeout[2];
14151415static int io_stage[2];
14161416
14171417static TIMER_CALLBACK( io_timeout0_timer_callback )
r1293r1294
14251425}
14261426
14271427
1428void init_megadri6_io(void)
1428static void init_megadri6_io(void)
14291429{
1430   io_timeout[0] = mame_timer_alloc(io_timeout0_timer_callback);
1430   io_timeout[0] = timer_alloc(io_timeout0_timer_callback);
14311431   io_stage[0] = -1;
14321432
1433   io_timeout[1] = mame_timer_alloc(io_timeout1_timer_callback);
1433   io_timeout[1] = timer_alloc(io_timeout1_timer_callback);
14341434   io_stage[1] = -1;
14351435
14361436}
r1293r1294
17241724#define UP_BUTTON(player)    ( (readinputport(player) & 0x01) >> 0 )
17251725#define MD_RESET_BUTTON      ( (readinputportbytag_safe("RESET",0x00)      & 0x01) >> 0 )
17261726
1727UINT8 megadrive_io_data_regs[3];
1728UINT8 megadrive_io_ctrl_regs[3];
1729UINT8 megadrive_io_tx_regs[3];
1727static UINT8 megadrive_io_data_regs[3];
1728static UINT8 megadrive_io_ctrl_regs[3];
1729static UINT8 megadrive_io_tx_regs[3];
17301730
1731void megadrive_init_io(running_machine *machine)
1731static void megadrive_init_io(running_machine *machine)
17321732{
17331733   megadrive_io_data_regs[0] = 0x7f;
17341734   megadrive_io_data_regs[1] = 0x7f;
r1293r1294
17481748}
17491749
17501750/************* 6 button version **************************/
1751UINT8 megadrive_io_read_data_port_6button(int portnum)
1751static UINT8 megadrive_io_read_data_port_6button(int portnum)
17521752{
17531753   UINT8 retdata;
17541754
r1293r1294
18221822}
18231823/************* end 6 button version ********************************************/
18241824
1825UINT8 megadrive_io_read_data_port_3button(int portnum)
1825static UINT8 megadrive_io_read_data_port_3button(int portnum)
18261826{
18271827   UINT8 retdata;
18281828
r1293r1294
19241924         (LEFT_BUTTON(1)  << 0);
19251925}
19261926
1927UINT8 megadrive_io_read_ctrl_port(int portnum)
1927static UINT8 megadrive_io_read_ctrl_port(int portnum)
19281928{
19291929   UINT8 retdata;
19301930   retdata = megadrive_io_ctrl_regs[portnum];
r1293r1294
19331933   return retdata|(retdata<<8);
19341934}
19351935
1936UINT8 megadrive_io_read_tx_port(int portnum)
1936static UINT8 megadrive_io_read_tx_port(int portnum)
19371937{
19381938   UINT8 retdata;
19391939   retdata = megadrive_io_tx_regs[portnum];
19401940   return retdata|(retdata<<8);
19411941}
19421942
1943UINT8 megadrive_io_read_rx_port(int portnum)
1943static UINT8 megadrive_io_read_rx_port(int portnum)
19441944{
19451945   return 0x00;
19461946}
19471947
1948UINT8 megadrive_io_read_sctrl_port(int portnum)
1948static UINT8 megadrive_io_read_sctrl_port(int portnum)
19491949{
19501950   return 0x00;
19511951}
r1293r1294
20172017}
20182018
20192019
2020void megadrive_io_write_data_port_3button(int portnum, UINT16 data)
2020static void megadrive_io_write_data_port_3button(int portnum, UINT16 data)
20212021{
20222022   megadrive_io_data_regs[portnum] = data;
20232023   //mame_printf_debug("Writing IO Data Register #%d data %04x\n",portnum,data);
r1293r1294
20272027
20282028/******************************6 button version*****************************/
20292029
2030void megadrive_io_write_data_port_6button(int portnum, UINT16 data)
2030static void megadrive_io_write_data_port_6button(int portnum, UINT16 data)
20312031{
20322032   if (megadrive_io_ctrl_regs[portnum]&0x40)
20332033   {
20342034      if (((megadrive_io_data_regs[portnum]&0x40)==0x00) && ((data&0x40) == 0x40))
20352035      {
20362036         io_stage[portnum]++;
2037         mame_timer_adjust(io_timeout[portnum], MAME_TIME_IN_CYCLES(8192,0), 0, time_zero);
2037         timer_adjust(io_timeout[portnum], ATTOTIME_IN_CYCLES(8192,0), 0, attotime_zero);
20382038      }
20392039
20402040   }
r1293r1294
20462046
20472047/***************************end 6 button version ****************************/
20482048
2049void megadrive_io_write_ctrl_port(int portnum, UINT16 data)
2049static void megadrive_io_write_ctrl_port(int portnum, UINT16 data)
20502050{
20512051   megadrive_io_ctrl_regs[portnum] = data;
20522052//  mame_printf_debug("Setting IO Control Register #%d data %04x\n",portnum,data);
20532053}
20542054
2055void megadrive_io_write_tx_port(int portnum, UINT16 data)
2055static void megadrive_io_write_tx_port(int portnum, UINT16 data)
20562056{
20572057   megadrive_io_tx_regs[portnum] = data;
20582058}
20592059
2060void megadrive_io_write_rx_port(int portnum, UINT16 data)
2060static void megadrive_io_write_rx_port(int portnum, UINT16 data)
20612061{
20622062
20632063}
20642064
2065void megadrive_io_write_sctrl_port(int portnum, UINT16 data)
2065static void megadrive_io_write_sctrl_port(int portnum, UINT16 data)
20662066{
20672067
20682068}
r1293r1294
24772477   return mame_rand(Machine);
24782478}
24792479
2480UINT16 _32x_68k_comms[0x8];
2481UINT16 _32x_palette[0x400/2];
2480static UINT16 _32x_68k_comms[0x8];
2481static UINT16 _32x_palette[0x400/2];
24822482
24832483static READ16_HANDLER( _32x_68k_comms_r )
24842484{
r1293r1294
25722572/****************************************** END 32X related *************************************/
25732573
25742574
2575static mame_time time_elapsed_since_crap;
2575static attotime time_elapsed_since_crap;
25762576
25772577
25782578VIDEO_START(megadriv)
r1293r1294
26222622//  int xxx;
26232623   /* reference */
26242624
2625//  time_elapsed_since_crap = mame_timer_timeelapsed(frame_timer);
2626//  xxx = MAME_TIME_TO_CYCLES(0,time_elapsed_since_crap);
2627//  mame_printf_debug("update cycles %d, %08x %08x\n",xxx, (UINT32)(time_elapsed_since_crap.subseconds>>32),(UINT32)(time_elapsed_since_crap.subseconds&0xffffffff));
2625//  time_elapsed_since_crap = timer_timeelapsed(frame_timer);
2626//  xxx = ATTOTIME_TO_CYCLES(0,time_elapsed_since_crap);
2627//  mame_printf_debug("update cycles %d, %08x %08x\n",xxx, (UINT32)(time_elapsed_since_crap.attoseconds>>32),(UINT32)(time_elapsed_since_crap.attoseconds&0xffffffff));
26282628
26292629   return 0;
26302630}
r1293r1294
26752675
26762676*/
26772677
2678void genesis_render_spriteline_to_spritebuffer(int scanline)
2678static void genesis_render_spriteline_to_spritebuffer(int scanline)
26792679{
26802680   int screenwidth;
26812681   int maxsprites=0;
r1293r1294
28662866}
28672867
28682868/* Clean up this function (!) */
2869void genesis_render_videoline_to_videobuffer(int scanline)
2869static void genesis_render_videoline_to_videobuffer(int scanline)
28702870{
28712871   UINT16 base_a;
28722872   UINT16 base_w=0;
r1293r1294
38793879}
38803880
38813881/* This converts our render buffer to real screen colours */
3882void genesis_render_videobuffer_to_screenbuffer(running_machine *machine, int scanline)
3882static void genesis_render_videobuffer_to_screenbuffer(running_machine *machine, int scanline)
38833883{
38843884   UINT16*lineptr;
38853885   int x;
r1293r1294
39343934
39353935}
39363936
3937void genesis_render_scanline(running_machine *machine, int scanline)
3937static void genesis_render_scanline(running_machine *machine, int scanline)
39383938{
39393939   //if (MEGADRIVE_REG01_DMA_ENABLE==0) mame_printf_debug("off\n");
39403940   genesis_render_spriteline_to_spritebuffer(genesis_scanline_counter);
r1293r1294
39473947//  static int lowest = 99999;
39483948//  static int highest = -99999;
39493949
3950   mame_time time_elapsed_since_scanline_timer;
3950   attotime time_elapsed_since_scanline_timer;
39513951   UINT16 value4;
39523952
3953   time_elapsed_since_scanline_timer = mame_timer_timeelapsed(scanline_timer);
3953   time_elapsed_since_scanline_timer = timer_timeelapsed(scanline_timer);
39543954
3955   if (time_elapsed_since_scanline_timer.subseconds<(MAX_SUBSECONDS/megadriv_framerate /megadrive_total_scanlines))
3955   if (time_elapsed_since_scanline_timer.attoseconds<(ATTOSECONDS_PER_SECOND/megadriv_framerate /megadrive_total_scanlines))
39563956   {
3957      value4 = (UINT16)(megadrive_max_hposition*((double)(time_elapsed_since_scanline_timer.subseconds) / (double)(MAX_SUBSECONDS/megadriv_framerate /megadrive_total_scanlines)));
3957      value4 = (UINT16)(megadrive_max_hposition*((double)(time_elapsed_since_scanline_timer.attoseconds) / (double)(ATTOSECONDS_PER_SECOND/megadriv_framerate /megadrive_total_scanlines)));
39583958   }
39593959   else /* in some cases (probably due to rounding errors) we get some stupid results (the odd huge value where the time elapsed is much higher than the scanline time??!).. hopefully by clamping the result to the maximum we limit errors */
39603960   {
r1293r1294
42384238
42394239static int irq4counter = -1;
42404240
4241static mame_timer* render_timer;
4241static emu_timer* render_timer;
42424242
42434243static TIMER_CALLBACK( render_timer_callback )
42444244{
r1293r1294
42674267   {
42684268      genesis_scanline_counter++;
42694269//      mame_printf_debug("scanline %d\n",genesis_scanline_counter);
4270      mame_timer_adjust(scanline_timer, scale_down_mame_time(MAME_TIME_IN_HZ(megadriv_framerate), megadrive_total_scanlines), 0, time_zero);
4271      mame_timer_adjust(render_timer, MAME_TIME_IN_USEC(1), 0, time_zero);
4270      timer_adjust(scanline_timer, attotime_div(ATTOTIME_IN_HZ(megadriv_framerate), megadrive_total_scanlines), 0, attotime_zero);
4271      timer_adjust(render_timer, ATTOTIME_IN_USEC(1), 0, attotime_zero);
42724272
42734273      if (genesis_scanline_counter==megadrive_irq6_scanline )
42744274      {
42754275      //  mame_printf_debug("x %d",genesis_scanline_counter);
4276         mame_timer_adjust(irq6_on_timer,  MAME_TIME_IN_USEC(6), 0, time_zero);
4276         timer_adjust(irq6_on_timer,  ATTOTIME_IN_USEC(6), 0, attotime_zero);
42774277         megadrive_irq6_pending = 1;
42784278         megadrive_vblank_flag = 1;
42794279      }
r1293r1294
43004300
43014301            if (MEGADRIVE_REG0_IRQ4_ENABLE)
43024302            {
4303               mame_timer_adjust(irq4_on_timer,  MAME_TIME_IN_USEC(1), 0, time_zero);
4303               timer_adjust(irq4_on_timer,  ATTOTIME_IN_USEC(1), 0, attotime_zero);
43044304               //mame_printf_debug("irq4 on scanline %d reload %d\n",genesis_scanline_counter,MEGADRIVE_REG0A_HINT_VALUE);
43054305            }
43064306         }
r1293r1294
43114311         else irq4counter=MEGADRIVE_REG0A_HINT_VALUE;
43124312      }
43134313
4314      //if (genesis_scanline_counter==0) mame_timer_adjust(irq4_on_timer,  MAME_TIME_IN_USEC(2), 0, time_zero);
4314      //if (genesis_scanline_counter==0) timer_adjust(irq4_on_timer,  ATTOTIME_IN_USEC(2), 0, attotime_zero);
43154315
43164316
43174317
r1293r1294
43534353
43544354/*****************************************************************************************/
43554355
4356int hazemdchoice_megadrive_region_export;
4357int hazemdchoice_megadrive_region_pal;
4358int hazemdchoice_megadriv_framerate;
4356static int hazemdchoice_megadrive_region_export;
4357static int hazemdchoice_megadrive_region_pal;
4358static int hazemdchoice_megadriv_framerate;
43594359
43604360MACHINE_RESET( megadriv )
43614361{
r1293r1294
44074407
44084408   megadrive_init_io(machine);
44094409
4410   frame_timer = mame_timer_alloc(frame_timer_callback);
4411   scanline_timer = mame_timer_alloc(scanline_timer_callback);
4412   render_timer = mame_timer_alloc(render_timer_callback);
4410   frame_timer = timer_alloc(frame_timer_callback);
4411   scanline_timer = timer_alloc(scanline_timer_callback);
4412   render_timer = timer_alloc(render_timer_callback);
44134413
4414   irq6_on_timer = mame_timer_alloc(irq6_on_callback);
4415   irq4_on_timer = mame_timer_alloc(irq4_on_callback);
4414   irq6_on_timer = timer_alloc(irq6_on_callback);
4415   irq4_on_timer = timer_alloc(irq4_on_callback);
44164416
4417   mame_timer_adjust(frame_timer, time_zero, 0, time_zero);
4418   mame_timer_adjust(scanline_timer,  time_zero, 0, time_zero);
4417   timer_adjust(frame_timer, attotime_zero, 0, attotime_zero);
4418   timer_adjust(scanline_timer,  attotime_zero, 0, attotime_zero);
44194419
44204420//  set_refresh_rate(megadriv_framerate);
44214421   cpunum_set_clockscale(0, 0.9950f); /* Fatal Rewind is very fussy... */
r1293r1294
44284428
44294429void megadriv_stop_scanline_timer(void)
44304430{
4431   mame_timer_adjust(scanline_timer,  time_never, 0, time_never);
4431   timer_adjust(scanline_timer,  attotime_never, 0, attotime_never);
44324432}
44334433
44344434/*
r1293r1294
45294529   visarea.min_y = 0;
45304530   visarea.max_y = megadrive_visible_scanlines-1;
45314531
4532   video_screen_configure(0, scr_width, megadrive_visible_scanlines, &visarea, HZ_TO_SUBSECONDS(megadriv_framerate));
4532   video_screen_configure(0, scr_width, megadrive_visible_scanlines, &visarea, HZ_TO_ATTOSECONDS(megadriv_framerate));
45334533
45344534#if 0
45354535{
r1293r1294
45784578      UINT64 frametime;
45794579
45804580   //  /* reference */
4581      frametime = MAX_SUBSECONDS/megadriv_framerate;
4581      frametime = ATTOSECONDS_PER_SECOND/megadriv_framerate;
45824582
4583      time_elapsed_since_crap = mame_timer_timeelapsed(frame_timer);
4584      xxx = MAME_TIME_TO_CYCLES(0,time_elapsed_since_crap);
4585      //mame_printf_debug("---------- cycles %d, %08x %08x\n",xxx, (UINT32)(time_elapsed_since_crap.subseconds>>32),(UINT32)(time_elapsed_since_crap.subseconds&0xffffffff));
4583      time_elapsed_since_crap = timer_timeelapsed(frame_timer);
4584      xxx = ATTOTIME_TO_CYCLES(0,time_elapsed_since_crap);
4585      //mame_printf_debug("---------- cycles %d, %08x %08x\n",xxx, (UINT32)(time_elapsed_since_crap.attoseconds>>32),(UINT32)(time_elapsed_since_crap.attoseconds&0xffffffff));
45864586      //mame_printf_debug("---------- framet %d, %08x %08x\n",xxx, (UINT32)(frametime>>32),(UINT32)(frametime&0xffffffff));
45874587   }
45884588
4589   mame_timer_adjust(frame_timer,  time_zero, 0, time_zero);
4590   mame_timer_adjust(scanline_timer,  time_zero, 0, time_zero);
4589   timer_adjust(frame_timer,  attotime_zero, 0, attotime_zero);
4590   timer_adjust(scanline_timer,  attotime_zero, 0, attotime_zero);
45914591
45924592}
45934593
r1293r1294
46944694
46954695
46964696/* Callback when the genesis enters interrupt code */
4697int genesis_int_callback (int irq)
4697static int genesis_int_callback (int irq)
46984698{
46994699   if (irq==4)
47004700   {
r1293r1294
47154715   return 0; // writeback not allowed
47164716}
47174717
4718void megadriv_init_common(running_machine *machine)
4718static void megadriv_init_common(running_machine *machine)
47194719{
47204720   genz80.z80_cpunum = 1;
47214721   genz80.z80_prgram = auto_malloc(0x2000);
src/mame/drivers/galpani3.c
r1293r1294
7676
7777static UINT16 *galpani3_sprregs, *galpani3_spriteram;
7878
79INTERRUPT_GEN( galpani3_vblank ) // 2, 3, 5 ?
79static INTERRUPT_GEN( galpani3_vblank ) // 2, 3, 5 ?
8080{
8181   switch ( cpu_getiloops() )
8282   {
r1293r1294
197197***************************************************************************/
198198static UINT16 *mcu_ram, galpani3_mcu_com[4];
199199
200void galpani3_mcu_run(void)
200static void galpani3_mcu_run(void)
201201{
202202   UINT16 mcu_command = mcu_ram[0x0010/2];      /* command nb */
203203   UINT16 mcu_offset  = mcu_ram[0x0012/2] / 2;   /* offset in shared RAM where MCU will write */
src/mame/drivers/itech32.c
r1293r1294
390390{
391391   static int effx, effy;
392392   static int lastresult;
393   static mame_time lasttime;
394   mame_time curtime = mame_timer_get_time();
393   static attotime lasttime;
394   attotime curtime = timer_get_time();
395395
396   if (compare_mame_times(sub_mame_times(curtime, lasttime), video_screen_get_scan_period(0)) > 0)
396   if (attotime_compare(attotime_sub(curtime, lasttime), video_screen_get_scan_period(0)) > 0)
397397   {
398398      int upper, lower;
399399      int dx, dy;
r1293r1294
429429{
430430   static int effx, effy;
431431   static int lastresult;
432   static mame_time lasttime;
433   mame_time curtime = mame_timer_get_time();
432   static attotime lasttime;
433   attotime curtime = timer_get_time();
434434
435   if (compare_mame_times(sub_mame_times(curtime, lasttime), video_screen_get_scan_period(0)) > 0)
435   if (attotime_compare(attotime_sub(curtime, lasttime), video_screen_get_scan_period(0)) > 0)
436436   {
437437      int upper, lower;
438438      int dx, dy;
r1293r1294
709709   if (offset == 0) COMBINE_DATA(tms1_boot);
710710   if (offset == 0x382 && tms_spinning[0]) STOP_TMS_SPINNING(0);
711711   if (!tms_spinning[0])
712      cpu_boost_interleave(MAME_TIME_IN_HZ(CLOCK_25MHz/256), MAME_TIME_IN_USEC(20));
712      cpu_boost_interleave(ATTOTIME_IN_HZ(CLOCK_25MHz/256), ATTOTIME_IN_USEC(20));
713713}
714714
715715
r1293r1294
718718   COMBINE_DATA(&tms2_ram[offset]);
719719   if (offset == 0x382 && tms_spinning[1]) STOP_TMS_SPINNING(1);
720720   if (!tms_spinning[1])
721      cpu_boost_interleave(MAME_TIME_IN_HZ(CLOCK_25MHz/256), MAME_TIME_IN_USEC(20));
721      cpu_boost_interleave(ATTOTIME_IN_HZ(CLOCK_25MHz/256), ATTOTIME_IN_USEC(20));
722722}
723723
724724
725725static WRITE32_HANDLER( tms1_trigger_w )
726726{
727727   COMBINE_DATA(&tms1_ram[offset]);
728   cpu_boost_interleave(MAME_TIME_IN_HZ(CLOCK_25MHz/256), MAME_TIME_IN_USEC(20));
728   cpu_boost_interleave(ATTOTIME_IN_HZ(CLOCK_25MHz/256), ATTOTIME_IN_USEC(20));
729729}
730730
731731
732732static WRITE32_HANDLER( tms2_trigger_w )
733733{
734734   COMBINE_DATA(&tms2_ram[offset]);
735   cpu_boost_interleave(MAME_TIME_IN_HZ(CLOCK_25MHz/256), MAME_TIME_IN_USEC(20));
735   cpu_boost_interleave(ATTOTIME_IN_HZ(CLOCK_25MHz/256), ATTOTIME_IN_USEC(20));
736736}
737737
738738
src/mame/drivers/sspeedr.c
r1293r1294
225225   MDRV_CPU_VBLANK_INT(irq0_line_assert, 1)
226226
227227   MDRV_SCREEN_REFRESH_RATE(59.39)
228   MDRV_SCREEN_VBLANK_TIME(USEC_TO_SUBSECONDS(16 * 1000000 / 15680))
228   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(16 * 1000000 / 15680))
229229
230230   /* video hardware */
231231   MDRV_VIDEO_ATTRIBUTES(VIDEO_TYPE_RASTER)
src/mame/drivers/mouser.c
r1293r1294
1515#include "driver.h"
1616#include "sound/ay8910.h"
1717
18UINT8 mouser_sound_byte;
19UINT8 mouser_nmi_enable;
18static UINT8 mouser_sound_byte;
19static UINT8 mouser_nmi_enable;
2020
2121/* From "video/mouser.c" */
2222PALETTE_INIT( mouser );
r1293r1294
3434   mouser_nmi_enable = data;
3535}
3636
37INTERRUPT_GEN( mouser_nmi_interrupt )
37static INTERRUPT_GEN( mouser_nmi_interrupt )
3838{
3939   if ((mouser_nmi_enable & 1) == 1)
4040      nmi_line_pulse();
src/mame/drivers/undrfire.c
r1293r1294
134134extern UINT16 undrfire_rotate_ctrl[8];
135135static int frame_counter=0;
136136
137UINT32 *undrfire_ram;   /* will be read in video for gun target calcs */
137static UINT32 *undrfire_ram;   /* will be read in video for gun target calcs */
138138
139139
140140/***********************************************************
r1293r1294
295295static WRITE32_HANDLER( unknown_int_req_w )
296296{
297297   /* 10000 cycle delay is arbitrary */
298   mame_timer_set(MAME_TIME_IN_CYCLES(10000,0),0, undrfire_interrupt5);
298   timer_set(ATTOTIME_IN_CYCLES(10000,0),0, undrfire_interrupt5);
299299}
300300
301301
src/mame/drivers/malzak.c
r1293r1294
470470   MDRV_CPU_IO_MAP(readport,writeport)
471471
472472   MDRV_SCREEN_REFRESH_RATE(50)
473   //MDRV_SCREEN_VBLANK_TIME(USEC_TO_SUBSECONDS(SAA5050_VBLANK))
473   //MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(SAA5050_VBLANK))
474474
475475   /* video hardware */
476476   MDRV_VIDEO_ATTRIBUTES(VIDEO_TYPE_RASTER)
src/mame/drivers/deco32.c
r1293r1294
237237
238238static UINT32 *deco32_ram;
239239static int raster_enable;
240static mame_timer *raster_irq_timer;
240static emu_timer *raster_irq_timer;
241241static UINT8 nslasher_sound_irq;
242242
243243extern void decrypt156(void);
r1293r1294
304304   case 1: /* Raster IRQ scanline position, only valid for values between 1 & 239 (0 and 240-256 do NOT generate IRQ's) */
305305      scanline=(data&0xff);
306306      if (raster_enable && scanline>0 && scanline<240)
307         mame_timer_adjust(raster_irq_timer,video_screen_get_time_until_pos(0, scanline-1, 320),0,time_never);
307         timer_adjust(raster_irq_timer,video_screen_get_time_until_pos(0, scanline-1, 320),0,attotime_never);
308308      else
309         mame_timer_adjust(raster_irq_timer,time_never,0,time_zero);
309         timer_adjust(raster_irq_timer,attotime_never,0,attotime_zero);
310310      break;
311311   case 2: /* VBL irq ack */
312312      break;
r1293r1294
18591859
18601860static MACHINE_RESET( deco32 )
18611861{
1862   raster_irq_timer = mame_timer_alloc(interrupt_gen);
1862   raster_irq_timer = timer_alloc(interrupt_gen);
18631863}
18641864
18651865static INTERRUPT_GEN( deco32_vbl_interrupt )
src/mame/drivers/midzeus.c
r1293r1294
2323#include "audio/dcs.h"
2424
2525
26#define CPU_CLOCK      60000000
27
28
2629static UINT32 *ram_base;
2730static UINT8 cmos_protected;
2831
29static mame_timer *timer[2];
32static emu_timer *timer[2];
3033
3134static UINT32 *tms32031_control;
3235
r1293r1294
4447
4548   *(UINT32 *)ram_base *= 2;
4649
47   timer[0] = mame_timer_alloc(NULL);
48   timer[1] = mame_timer_alloc(NULL);
50   timer[0] = timer_alloc(NULL);
51   timer[1] = timer_alloc(NULL);
4952}
5053
5154
r1293r1294
8992   {
9093      /* timer is clocked at 100ns */
9194      int which = (offset >> 4) & 1;
92      INT32 result = mame_time_to_double(scale_up_mame_time(mame_timer_timeelapsed(timer[which]), 10000000));
95      INT32 result = attotime_to_double(attotime_mul(timer_timeelapsed(timer[which]), 10000000));
9396      return result;
9497   }
9598
r1293r1294
114117   {
115118      int which = (offset >> 4) & 1;
116119      if (data & 0x40)
117         mame_timer_adjust(timer[which], time_never, 0, time_never);
120         timer_adjust(timer[which], attotime_never, 0, attotime_never);
118121   }
119122   else
120123      logerror("%06X:tms32031_control_w(%02X) = %08X\n", activecpu_get_pc(), offset, data);
r1293r1294
149152   AM_RANGE(0x000000, 0x03ffff) AM_RAM AM_BASE(&ram_base)
150153   AM_RANGE(0x400000, 0x41ffff) AM_RAM
151154   AM_RANGE(0x808000, 0x80807f) AM_READWRITE(tms32031_control_r, tms32031_control_w) AM_BASE(&tms32031_control)
152   AM_RANGE(0x87fe00, 0x87ffff) AM_RAM
153155   AM_RANGE(0x880000, 0x8803ff) AM_READWRITE(zeus_r, zeus_w) AM_BASE(&zeusbase)
154156   AM_RANGE(0x8d0000, 0x8d0003) AM_READWRITE(unknown_8d0000_r, unknown_8d0000_w) AM_BASE(&unknown_8d0000)
155157   AM_RANGE(0x990000, 0x99000f) AM_READWRITE(midway_ioasic_r, midway_ioasic_w)
r1293r1294
166168   AM_RANGE(0x000000, 0x03ffff) AM_RAM AM_BASE(&ram_base)
167169   AM_RANGE(0x400000, 0x43ffff) AM_RAM
168170   AM_RANGE(0x808000, 0x80807f) AM_READWRITE(tms32031_control_r, tms32031_control_w) AM_BASE(&tms32031_control)
169   AM_RANGE(0x87fe00, 0x87ffff) AM_RAM
170171   AM_RANGE(0x880000, 0x8801ff) AM_READWRITE(zeus2_r, zeus2_w) AM_BASE(&zeusbase)
171172   AM_RANGE(0x8d0000, 0x8d0003) AM_READWRITE(unknown_8d0000_r, unknown_8d0000_w) AM_BASE(&unknown_8d0000)
172173   AM_RANGE(0x990000, 0x99000f) AM_READWRITE(midway_ioasic_r, midway_ioasic_w)
r1293r1294
617618 *
618619 *************************************/
619620
620MACHINE_DRIVER_START( midzeus )
621static MACHINE_DRIVER_START( midzeus )
621622
622623   /* basic machine hardware */
623   MDRV_CPU_ADD_TAG("main", TMS32031, 50000000)      // actually, TMS32032
624   MDRV_CPU_ADD_TAG("main", TMS32032, CPU_CLOCK)
624625   MDRV_CPU_PROGRAM_MAP(zeus_map,0)
625626   MDRV_CPU_VBLANK_INT(irq0_line_assert,1)
626627
r1293r1294
645646MACHINE_DRIVER_END
646647
647648
648MACHINE_DRIVER_START( midzeus2 )
649static MACHINE_DRIVER_START( midzeus2 )
649650   MDRV_IMPORT_FROM(midzeus)
650651
651652   /* basic machine hardware */
src/mame/drivers/bestleag.c
r1293r1294
2222
2323/* Video Handling */
2424
25UINT16 *bestleag_txram,*bestleag_bgram,*bestleag_fgram,*bestleag_vregs;
25static UINT16 *bestleag_txram,*bestleag_bgram,*bestleag_fgram,*bestleag_vregs;
2626static tilemap *tx_tilemap,*bg_tilemap,*fg_tilemap;
2727
2828static TILE_GET_INFO( get_tx_tile_info )
src/mame/drivers/aleck64.c
r1293r1294
426426   n64_machine_reset();
427427}
428428
429MACHINE_DRIVER_START( aleck64 )
429static MACHINE_DRIVER_START( aleck64 )
430430   /* basic machine hardware */
431431   MDRV_CPU_ADD(R4600BE, 93750000)
432432   MDRV_CPU_CONFIG(config)
src/mame/drivers/astrof.c
r1293r1294
6969static UINT8 *astrof_colorram;
7070static UINT8 *tomahawk_protection;
7171
72static mame_timer *irq_timer;
72static emu_timer *irq_timer;
7373
7474static UINT8 *astrof_color;
7575static UINT8 astrof_palette_bank;
r1293r1294
9999{
100100   cpunum_set_input_line(0, 0, ASSERT_LINE);
101101
102   mame_timer_adjust(irq_timer, video_screen_get_time_until_pos(0, VBSTART, 0), 0, time_zero);
102   timer_adjust(irq_timer, video_screen_get_time_until_pos(0, VBSTART, 0), 0, attotime_zero);
103103}
104104
105105
106106static void create_irq_timer(void)
107107{
108   irq_timer = mame_timer_alloc(irq_callback);
108   irq_timer = timer_alloc(irq_callback);
109109}
110110
111111
112112static void start_irq_timer(void)
113113{
114   mame_timer_adjust(irq_timer, video_screen_get_time_until_pos(0, VBSTART, 0), 0, time_zero);
114   timer_adjust(irq_timer, video_screen_get_time_until_pos(0, VBSTART, 0), 0, attotime_zero);
115115}
116116
117117
src/mame/drivers/maxaflex.c
r1293r1294
3131static UINT8 portB_in,portB_out,ddrB;
3232static UINT8 portC_in,portC_out,ddrC;
3333static UINT8 tdr,tcr;
34static mame_timer *mcu_timer;
34static emu_timer *mcu_timer;
3535
3636/* Port A:
3737    0   (in)  DSW
r1293r1294
182182   if ( (tcr & 0x40) == 0 )
183183   {
184184      int divider;
185      mame_time period;
185      attotime period;
186186
187187      if ( !(tcr & 0x20) )
188188      {
r1293r1294
201201         divider = divider * (1 << (tcr & 0x7));
202202      }
203203
204      period = scale_up_mame_time(MAME_TIME_IN_HZ(3579545), divider);
205      mame_timer_adjust( mcu_timer, period, 0, period);
204      period = attotime_mul(ATTOTIME_IN_HZ(3579545), divider);
205      timer_adjust( mcu_timer, period, 0, period);
206206   }
207207}
208208
r1293r1294
212212   portB_in = portB_out = ddrB   = 0;
213213   portC_in = portC_out = ddrC   = 0;
214214   tdr = tcr = 0;
215   mcu_timer = mame_timer_alloc( mcu_timer_proc );
215   mcu_timer = timer_alloc( mcu_timer_proc );
216216
217217   output_set_lamp_value(0, 0);
218218   output_set_lamp_value(1, 0);
r1293r1294
434434   MDRV_CPU_ADD_TAG("main", M6502, FREQ_17_EXACT)
435435   MDRV_CPU_PROGRAM_MAP(a600xl_mem, 0)
436436   MDRV_CPU_VBLANK_INT(a800xl_interrupt, TOTAL_LINES_60HZ)
437   MDRV_SCREEN_VBLANK_TIME(USEC_TO_SUBSECONDS(0))
437   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(0))
438438
439439   MDRV_CPU_ADD(M68705, 3579545/M68705_CLOCK_DIVIDER)
440440   MDRV_CPU_PROGRAM_MAP(mcu_mem,0)
src/mame/drivers/vegas.c
r1293r1294
306306 *************************************/
307307
308308#define SYSTEM_CLOCK      100000000
309#define TIMER_PERIOD      MAME_TIME_IN_HZ(SYSTEM_CLOCK)
309#define TIMER_PERIOD      ATTOTIME_IN_HZ(SYSTEM_CLOCK)
310310
311311#define MAX_DYNAMIC_ADDRESSES   32
312312
r1293r1294
458458static UINT32 pci_ide_regs[0x40];
459459static UINT32 pci_3dfx_regs[0x40];
460460
461static mame_timer *timer[4];
461static emu_timer *timer[4];
462462
463463static UINT8 vblank_state;
464464
r1293r1294
576576   cpunum_set_info_int(0, CPUINFO_INT_MIPS3_FASTRAM_READONLY, 1);
577577
578578   /* allocate timers for the NILE */
579   timer[0] = mame_timer_alloc(NULL);
580   timer[1] = mame_timer_alloc(NULL);
581   timer[2] = mame_timer_alloc(timer_callback);
582   timer[3] = mame_timer_alloc(timer_callback);
579   timer[0] = timer_alloc(NULL);
580   timer[1] = timer_alloc(NULL);
581   timer[2] = timer_alloc(timer_callback);
582   timer[3] = timer_alloc(timer_callback);
583583
584584   /* reset dynamic addressing */
585585   memset(nile_regs, 0, 0x1000);
r1293r1294
964964      if (regs[1] & 2)
965965         logerror("Unexpected value: timer %d is prescaled\n", which);
966966      if (scale != 0)
967         mame_timer_adjust(timer[which], scale_up_mame_time(TIMER_PERIOD, scale), which, time_never);
967         timer_adjust(timer[which], attotime_mul(TIMER_PERIOD, scale), which, attotime_never);
968968   }
969969
970970   /* trigger the interrupt */
r1293r1294
10471047         {
10481048            if (nile_regs[offset] & 2)
10491049               logerror("Unexpected value: timer %d is prescaled\n", which);
1050            result = nile_regs[offset + 1] = mame_time_to_double(mame_timer_timeleft(timer[which])) * (double)SYSTEM_CLOCK;
1050            result = nile_regs[offset + 1] = attotime_to_double(timer_timeleft(timer[which])) * (double)SYSTEM_CLOCK;
10511051         }
10521052
10531053         if (LOG_TIMERS) logerror("%08X:NILE READ: timer %d counter(%03X) = %08X\n", activecpu_get_pc(), which, offset*4, result);
r1293r1294
11771177            if (nile_regs[offset] & 2)
11781178               logerror("Unexpected value: timer %d is prescaled\n", which);
11791179            if (scale != 0)
1180               mame_timer_adjust(timer[which], scale_up_mame_time(TIMER_PERIOD, scale), which, time_never);
1181            if (LOG_TIMERS) logerror("Starting timer %d at a rate of %d Hz\n", which, (int)SUBSECONDS_TO_HZ(scale_up_mame_time(TIMER_PERIOD, nile_regs[offset + 1] + 1).subseconds));
1180               timer_adjust(timer[which], attotime_mul(TIMER_PERIOD, scale), which, attotime_never);
1181            if (LOG_TIMERS) logerror("Starting timer %d at a rate of %d Hz\n", which, (int)ATTOSECONDS_TO_HZ(attotime_mul(TIMER_PERIOD, nile_regs[offset + 1] + 1).attoseconds));
11821182         }
11831183
11841184         /* timer disabled? */
r1293r1294
11861186         {
11871187            if (nile_regs[offset] & 2)
11881188               logerror("Unexpected value: timer %d is prescaled\n", which);
1189            nile_regs[offset + 1] = mame_time_to_double(mame_timer_timeleft(timer[which])) * SYSTEM_CLOCK;
1190            mame_timer_adjust(timer[which], time_never, which, time_never);
1189            nile_regs[offset + 1] = attotime_to_double(timer_timeleft(timer[which])) * SYSTEM_CLOCK;
1190            timer_adjust(timer[which], attotime_never, which, attotime_never);
11911191         }
11921192         break;
11931193
r1293r1294
12031203         {
12041204            if (nile_regs[offset - 1] & 2)
12051205               logerror("Unexpected value: timer %d is prescaled\n", which);
1206            mame_timer_adjust(timer[which], scale_up_mame_time(TIMER_PERIOD, nile_regs[offset]), which, time_never);
1206            timer_adjust(timer[which], attotime_mul(TIMER_PERIOD, nile_regs[offset]), which, attotime_never);
12071207         }
12081208         break;
12091209
r1293r1294
22102210   SYSTEM_CLOCK   /* system clock rate */
22112211};
22122212
2213MACHINE_DRIVER_START( vegascore )
2213static MACHINE_DRIVER_START( vegascore )
22142214
22152215   /* basic machine hardware */
22162216   MDRV_CPU_ADD_TAG("main", R5000LE, SYSTEM_CLOCK*2)
r1293r1294
22332233MACHINE_DRIVER_END
22342234
22352235
2236MACHINE_DRIVER_START( vegas )
2236static MACHINE_DRIVER_START( vegas )
22372237   MDRV_IMPORT_FROM(vegascore)
22382238   MDRV_IMPORT_FROM(dcs2_audio_2104)
22392239MACHINE_DRIVER_END
22402240
22412241
2242MACHINE_DRIVER_START( vegas250 )
2242static MACHINE_DRIVER_START( vegas250 )
22432243   MDRV_IMPORT_FROM(vegascore)
22442244   MDRV_CPU_REPLACE("main", R5000LE, SYSTEM_CLOCK*2.5)
22452245   MDRV_IMPORT_FROM(dcs2_audio_2104)
22462246MACHINE_DRIVER_END
22472247
22482248
2249MACHINE_DRIVER_START( vegas32m )
2249static MACHINE_DRIVER_START( vegas32m )
22502250   MDRV_IMPORT_FROM(vegascore)
22512251   MDRV_CPU_MODIFY("main")
22522252   MDRV_CPU_PROGRAM_MAP(vegas_map_32mb,0)
r1293r1294
22542254MACHINE_DRIVER_END
22552255
22562256
2257MACHINE_DRIVER_START( vegasban )
2257static MACHINE_DRIVER_START( vegasban )
22582258   MDRV_IMPORT_FROM(vegascore)
22592259   MDRV_CPU_MODIFY("main")
22602260   MDRV_CPU_PROGRAM_MAP(vegas_map_32mb,0)
r1293r1294
22632263MACHINE_DRIVER_END
22642264
22652265
2266MACHINE_DRIVER_START( vegasv3 )
2266static MACHINE_DRIVER_START( vegasv3 )
22672267   MDRV_IMPORT_FROM(vegas32m)
22682268   MDRV_CPU_REPLACE("main", RM7000LE, SYSTEM_CLOCK*2.5)
22692269   MDRV_VIDEO_START(vegas_voodoo3)
22702270MACHINE_DRIVER_END
22712271
22722272
2273MACHINE_DRIVER_START( denver )
2273static MACHINE_DRIVER_START( denver )
22742274   MDRV_IMPORT_FROM(vegascore)
22752275   MDRV_CPU_REPLACE("main", RM7000LE, SYSTEM_CLOCK*2.5)
22762276   MDRV_CPU_PROGRAM_MAP(vegas_map_32mb,0)
src/mame/drivers/kopunch.c
r1293r1294
1313extern VIDEO_UPDATE( kopunch );
1414
1515
16INTERRUPT_GEN( kopunch_interrupt )
16static INTERRUPT_GEN( kopunch_interrupt )
1717{
1818   if (cpu_getiloops() == 0)
1919   {
src/mame/drivers/finalizr.c
r1293r1294
1919extern UINT8 *finalizr_videoram2,*finalizr_colorram2;
2020static UINT8 *finalizr_interrupt_enable;
2121
22int finalizr_T1_line;
22static int finalizr_T1_line;
2323
2424PALETTE_INIT( finalizr );
2525VIDEO_START( finalizr );
src/mame/drivers/segaybd.c
r1293r1294
3939
4040static UINT16 *backupram;
4141
42static mame_timer *interrupt_timer;
42static emu_timer *interrupt_timer;
4343
4444
4545
r1293r1294
8080      cpunum_set_input_line(0, irq, ASSERT_LINE);
8181      cpunum_set_input_line(1, irq, ASSERT_LINE);
8282      cpunum_set_input_line(2, irq, ASSERT_LINE);
83      cpu_boost_interleave(time_zero, MAME_TIME_IN_USEC(50));
83      cpu_boost_interleave(attotime_zero, ATTOTIME_IN_USEC(50));
8484   }
8585   else
8686   {
r1293r1294
163163   update_main_irqs();
164164
165165   /* come back at the next appropriate scanline */
166   mame_timer_adjust(interrupt_timer, video_screen_get_time_until_pos(0, scanline, 0), scanline, time_zero);
166   timer_adjust(interrupt_timer, video_screen_get_time_until_pos(0, scanline, 0), scanline, attotime_zero);
167167
168168#if TWEAK_IRQ2_SCANLINE
169169   if (scanline == 223)
r1293r1294
184184
185185static MACHINE_RESET( yboard )
186186{
187    interrupt_timer = mame_timer_alloc(scanline_callback);
188    mame_timer_adjust(interrupt_timer, video_screen_get_time_until_pos(0, 223, 0), 223, time_zero);
187    interrupt_timer = timer_alloc(scanline_callback);
188    timer_adjust(interrupt_timer, video_screen_get_time_until_pos(0, 223, 0), 223, attotime_zero);
189189
190190   state_save_register_global_array(misc_io_data);
191191   state_save_register_global_array(analog_data);
src/mame/drivers/enigma2.c
r1293r1294
6767 *
6868 *************************************/
6969
70static mame_timer *interrupt_clear_timer;
71static mame_timer *interrupt_assert_timer;
70static emu_timer *interrupt_clear_timer;
71static emu_timer *interrupt_assert_timer;
7272
7373
7474INLINE UINT16 vpos_to_vysnc_chain_counter(int vpos)
r1293r1294
107107      next_counter = INT_TRIGGER_COUNT_1;
108108
109109   next_vpos = vysnc_chain_counter_to_vpos(next_counter);
110   mame_timer_adjust(interrupt_assert_timer, video_screen_get_time_until_pos(0, next_vpos, 0), 0, time_zero);
111   mame_timer_adjust(interrupt_clear_timer, video_screen_get_time_until_pos(0, vpos + 1, 0), 0, time_zero);
110   timer_adjust(interrupt_assert_timer, video_screen_get_time_until_pos(0, next_vpos, 0), 0, attotime_zero);
111   timer_adjust(interrupt_clear_timer, video_screen_get_time_until_pos(0, vpos + 1, 0), 0, attotime_zero);
112112}
113113
114114
115115static void create_interrupt_timers(void)
116116{
117   interrupt_clear_timer = mame_timer_alloc(interrupt_clear_callback);
118   interrupt_assert_timer = mame_timer_alloc(interrupt_assert_callback);
117   interrupt_clear_timer = timer_alloc(interrupt_clear_callback);
118   interrupt_assert_timer = timer_alloc(interrupt_assert_callback);
119119}
120120
121121
122122static void start_interrupt_timers(void)
123123{
124124   int vpos = vysnc_chain_counter_to_vpos(INT_TRIGGER_COUNT_1);
125   mame_timer_adjust(interrupt_assert_timer, video_screen_get_time_until_pos(0, vpos, 0), 0, time_zero);
125   timer_adjust(interrupt_assert_timer, video_screen_get_time_until_pos(0, vpos, 0), 0, attotime_zero);
126126}
127127
128128
src/mame/drivers/segaorun.c
r1293r1294
186186   if (irq != 0)
187187   {
188188      cpunum_set_input_line(0, irq, ASSERT_LINE);
189      cpu_boost_interleave(time_zero, MAME_TIME_IN_USEC(100));
189      cpu_boost_interleave(attotime_zero, ATTOTIME_IN_USEC(100));
190190   }
191191   else
192192      cpunum_set_input_line(0, 7, CLEAR_LINE);
r1293r1294
213213      case 65:
214214      case 129:
215215      case 193:
216         mame_timer_set(video_screen_get_time_until_pos(0, scanline, machine->screen[0].visarea.max_x + 1), 0, irq2_gen);
216         timer_set(video_screen_get_time_until_pos(0, scanline, machine->screen[0].visarea.max_x + 1), 0, irq2_gen);
217217         next_scanline = scanline + 1;
218218         break;
219219
r1293r1294
244244   update_main_irqs();
245245
246246   /* come back at the next targeted scanline */
247   mame_timer_set(video_screen_get_time_until_pos(0, next_scanline, 0), next_scanline, scanline_callback);
247   timer_set(video_screen_get_time_until_pos(0, next_scanline, 0), next_scanline, scanline_callback);
248248}
249249
250250
r1293r1294
275275   cpunum_set_info_fct(0, CPUINFO_PTR_M68K_RESET_CALLBACK, (genf *)outrun_reset);
276276
277277   /* start timers to track interrupts */
278   mame_timer_set(video_screen_get_time_until_pos(0, 223, 0), 223, scanline_callback);
278   timer_set(video_screen_get_time_until_pos(0, 223, 0), 223, scanline_callback);
279279}
280280
281281
r1293r1294
854854MACHINE_DRIVER_END
855855
856856
857MACHINE_DRIVER_START( outrun )
857static MACHINE_DRIVER_START( outrun )
858858   MDRV_IMPORT_FROM(outrundx)
859859   MDRV_NVRAM_HANDLER(outrun)
860860MACHINE_DRIVER_END
861861
862862
863MACHINE_DRIVER_START( shangon )
863static MACHINE_DRIVER_START( shangon )
864864   MDRV_IMPORT_FROM(outrun)
865865
866866   MDRV_SCREEN_MODIFY("main")
src/mame/drivers/system24.c
r1293r1294
818818static UINT8  irq_timerb;
819819static UINT8  irq_allow0, irq_allow1;
820820static int    irq_timer_pend0, irq_timer_pend1, irq_yms;
821static mame_timer *irq_timer;
821static emu_timer *irq_timer;
822822
823823static TIMER_CALLBACK( irq_timer_cb )
824824{
r1293r1294
837837   irq_allow1 = 0;
838838   irq_timer_pend0 = 0;
839839   irq_timer_pend1 = 0;
840   irq_timer = mame_timer_alloc(irq_timer_cb);
840   irq_timer = timer_alloc(irq_timer_cb);
841841}
842842
843843static void irq_timer_reset(void)
r1293r1294
845845   int freq = (irq_timerb << 12) | irq_timera;
846846   freq &= 0x1fff;
847847
848   mame_timer_adjust(irq_timer, MAME_TIME_IN_HZ(freq), 0, MAME_TIME_IN_HZ(freq));
848   timer_adjust(irq_timer, ATTOTIME_IN_HZ(freq), 0, ATTOTIME_IN_HZ(freq));
849849   logerror("New timer frequency: %0d [%02x %04x]\n", freq, irq_timerb, irq_timera);
850850}
851851
r1293r1294
912912         /* set a timer to generate an irq at the needed point */
913913         if (ggground_kludge == 1)
914914         {
915            mame_timer_set(MAME_TIME_IN_USEC(180000), 0, gground_generate_kludge_irq);
915            timer_set(ATTOTIME_IN_USEC(180000), 0, gground_generate_kludge_irq);
916916            ggground_kludge = 0;
917917         }
918918         return 1;
r1293r1294
936936         /* set a timer to generate an irq at the needed point */
937937         if (ggground_kludge == 1)
938938         {
939            mame_timer_set(MAME_TIME_IN_USEC(180000), 0, gground_generate_kludge_irq);
939            timer_set(ATTOTIME_IN_USEC(180000), 0, gground_generate_kludge_irq);
940940            ggground_kludge = 0;
941941         }
942942         return 1;
r1293r1294
23752375   MDRV_CPU_PROGRAM_MAP(system24_cpu2_map, 0)
23762376
23772377   MDRV_SCREEN_REFRESH_RATE(58)
2378   MDRV_SCREEN_VBLANK_TIME(USEC_TO_SUBSECONDS(100))
2378   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(100))
23792379   MDRV_INTERLEAVE(4)
23802380
23812381   MDRV_MACHINE_RESET(system24)
src/mame/drivers/foodf.c
r1293r1294
8888 *
8989 *************************************/
9090
91static mame_timer *scanline_timer;
91static emu_timer *scanline_timer;
9292static UINT8 whichport = 0;
9393
9494
r1293r1294
146146      scanline = 0;
147147
148148   /* set a timer for it */
149   mame_timer_adjust(scanline_timer, video_screen_get_time_until_pos(0, scanline, 0), scanline, time_zero);
149   timer_adjust(scanline_timer, video_screen_get_time_until_pos(0, scanline, 0), scanline, attotime_zero);
150150}
151151
152152
153153static MACHINE_START( foodf )
154154{
155155   state_save_register_global(whichport);
156   scanline_timer = mame_timer_alloc(scanline_update);
156   scanline_timer = timer_alloc(scanline_update);
157157}
158158
159159
160160static MACHINE_RESET( foodf )
161161{
162162   atarigen_interrupt_reset(update_interrupts);
163   mame_timer_adjust(scanline_timer, video_screen_get_time_until_pos(0, 0, 0), 0, time_zero);
163   timer_adjust(scanline_timer, video_screen_get_time_until_pos(0, 0, 0), 0, attotime_zero);
164164}
165165
166166
src/mame/drivers/namcona1.c
r1293r1294
11691169   }
11701170}
11711171
1172ADDRESS_MAP_START( namcona1_mcu_map, ADDRESS_SPACE_PROGRAM, 16 )
1172static ADDRESS_MAP_START( namcona1_mcu_map, ADDRESS_SPACE_PROGRAM, 16 )
11731173   AM_RANGE(0x000800, 0x000fff) AM_READWRITE(mcu_mailbox_r, mcu_mailbox_w_mcu)   // "Mailslot" communications ports
11741174   AM_RANGE(0x001000, 0x001fff) AM_READWRITE(snd_r, snd_w)            // C140-alike sound chip
11751175   AM_RANGE(0x002000, 0x002fff) AM_READWRITE(na1mcu_shared_r, na1mcu_shared_w)   // mirror of first page of shared work RAM
r1293r1294
12951295   return (port & bitnum[offset>>1]) ? 0xff : 0x00;
12961296}
12971297
1298ADDRESS_MAP_START( namcona1_mcu_io_map, ADDRESS_SPACE_IO, 8 )
1298static ADDRESS_MAP_START( namcona1_mcu_io_map, ADDRESS_SPACE_IO, 8 )
12991299   AM_RANGE(M37710_PORT4, M37710_PORT4) AM_READWRITE( port4_r, port4_w )
13001300   AM_RANGE(M37710_PORT5, M37710_PORT5) AM_READWRITE( port5_r, port5_w )
13011301   AM_RANGE(M37710_PORT6, M37710_PORT6) AM_READWRITE( port6_r, port6_w )
r1293r1294
13041304   AM_RANGE(0x10, 0x1f) AM_READ( portana_r )
13051305ADDRESS_MAP_END
13061306
1307INTERRUPT_GEN( namcona1_interrupt )
1307static INTERRUPT_GEN( namcona1_interrupt )
13081308{
13091309   int level = cpu_getiloops(); /* 0,1,2,3,4 */
13101310   if( level==0 )
r1293r1294
13501350   MDRV_CPU_ADD(M37710, 50113000/4)
13511351   MDRV_CPU_PROGRAM_MAP(namcona1_mcu_map, 0)
13521352   MDRV_CPU_IO_MAP( namcona1_mcu_io_map, 0 )
1353   MDRV_CPU_VBLANK_INT(mcu_interrupt, 2);
1353   MDRV_CPU_VBLANK_INT(mcu_interrupt, 2)
13541354
13551355   MDRV_SCREEN_REFRESH_RATE(60)
13561356   MDRV_SCREEN_VBLANK_TIME(DEFAULT_REAL_60HZ_VBLANK_DURATION)
src/mame/drivers/acefruit.c
r1293r1294
3232   }
3333}
3434
35static mame_timer *acefruit_refresh_timer;
35static emu_timer *acefruit_refresh_timer;
3636
3737static TIMER_CALLBACK( acefruit_refresh )
3838{
r1293r1294
4343
4444   vpos = ( ( vpos / 8 ) + 1 ) * 8;
4545
46   mame_timer_adjust( acefruit_refresh_timer, video_screen_get_time_until_pos( 0, vpos, 0 ), 0, time_never );
46   timer_adjust( acefruit_refresh_timer, video_screen_get_time_until_pos( 0, vpos, 0 ), 0, attotime_never );
4747}
4848
4949static VIDEO_START( acefruit )
5050{
51   acefruit_refresh_timer = mame_timer_alloc( acefruit_refresh );
51   acefruit_refresh_timer = timer_alloc( acefruit_refresh );
5252}
5353
54INTERRUPT_GEN( acefruit_vblank )
54static INTERRUPT_GEN( acefruit_vblank )
5555{
5656   cpunum_set_input_line( 0, 0, HOLD_LINE );
57   mame_timer_adjust( acefruit_refresh_timer, time_zero, 0, time_never );
57   timer_adjust( acefruit_refresh_timer, attotime_zero, 0, attotime_never );
5858}
5959
6060static VIDEO_UPDATE( acefruit )
src/mame/drivers/dkong.c
r1293r1294
18961896   MDRV_CPU_MODIFY("main")
18971897   MDRV_CPU_IO_MAP(herbiedk_io_map, 0)
18981898
1899   //MDRV_SCREEN_VBLANK_TIME(USEC_TO_SUBSECONDS(1000))
1899   //MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(1000))
19001900MACHINE_DRIVER_END
19011901
19021902static MACHINE_DRIVER_START( spclforc )
src/mame/drivers/sprint4.c
r1293r1294
122122      cpunum_set_input_line(0, INPUT_LINE_NMI, PULSE_LINE);
123123   }
124124
125   mame_timer_set(video_screen_get_time_until_pos(0, scanline, 0), scanline, nmi_callback);
125   timer_set(video_screen_get_time_until_pos(0, scanline, 0), scanline, nmi_callback);
126126}
127127
128128
129129static MACHINE_RESET( sprint4 )
130130{
131   mame_timer_set(video_screen_get_time_until_pos(0, 32, 0), 32, nmi_callback);
131   timer_set(video_screen_get_time_until_pos(0, 32, 0), 32, nmi_callback);
132132
133133   memset(steer_FF1, 0, sizeof steer_FF1);
134134   memset(steer_FF2, 0, sizeof steer_FF2);
src/mame/drivers/skyraid.c
r1293r1294
266266   MDRV_CPU_VBLANK_INT(irq0_line_hold, 1)
267267
268268   MDRV_SCREEN_REFRESH_RATE(60)
269   MDRV_SCREEN_VBLANK_TIME(USEC_TO_SUBSECONDS(22 * 1000000 / 15750))
269   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(22 * 1000000 / 15750))
270270
271271   /* video hardware */
272272   MDRV_VIDEO_ATTRIBUTES(VIDEO_TYPE_RASTER)
src/mame/drivers/travrusa.c
r1293r1294
337337   MDRV_CPU_VBLANK_INT(irq0_line_hold,1)
338338
339339   MDRV_SCREEN_REFRESH_RATE(56.75)
340   MDRV_SCREEN_VBLANK_TIME(USEC_TO_SUBSECONDS(1790)   /* accurate frequency, measured on a Moon Patrol board, is 56.75Hz. */)
340   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(1790)   /* accurate frequency, measured on a Moon Patrol board, is 56.75Hz. */)
341341            /* the Lode Runner manual (similar but different hardware) */
342342            /* talks about 55Hz and 1790ms vblank duration. */
343343
src/mame/drivers/hanaroku.c
r1293r1294
1515
1616/* video */
1717
18UINT8 *hanaroku_spriteram1;
19UINT8 *hanaroku_spriteram2;
20UINT8 *hanaroku_spriteram3;
18static UINT8 *hanaroku_spriteram1;
19static UINT8 *hanaroku_spriteram2;
20static UINT8 *hanaroku_spriteram3;
2121
2222
2323static PALETTE_INIT( hanaroku )
src/mame/drivers/metlclsh.c
r1293r1294
296296   metlclsh_irqhandler
297297};
298298
299INTERRUPT_GEN( metlclsh_interrupt2 )
299static INTERRUPT_GEN( metlclsh_interrupt2 )
300300{
301301   if (cpu_getiloops() == 0)
302302      return;
src/mame/drivers/ddenlovr.c
r1293r1294
27492749                            Hanafuda Hana Ginga
27502750***************************************************************************/
27512751
2752UINT8 hginga_rombank;
2752static UINT8 hginga_rombank;
27532753static WRITE8_HANDLER( hginga_rombank_w )
27542754{
27552755   UINT8 *rom = memory_region(REGION_CPU1);
r1293r1294
29262926                             Hanafuda Hana Gokou
29272927***************************************************************************/
29282928
2929UINT8 hgokou_hopper;
2929static UINT8 hgokou_hopper;
29302930
29312931static UINT8 hgokou_player_r(int player)
29322932{
r1293r1294
33073307   return val;
33083308}
33093309
3310UINT8 mjflove_irq_cause;
3310static UINT8 mjflove_irq_cause;
33113311
33123312static READ8_HANDLER( mjflove_blitter_r )
33133313{
r1293r1294
70587058
70597059/*  It runs in IM 2, thus needs a vector on the data bus:
70607060    0xee is vblank  */
7061INTERRUPT_GEN( hparadis_irq )
7061static INTERRUPT_GEN( hparadis_irq )
70627062{
70637063   cpunum_set_input_line_and_vector(0, 0, HOLD_LINE, 0xee);
70647064}
src/mame/drivers/kaneko16.c
r1293r1294
17461746***************************************************************************/
17471747
17481748#define KANEKO16_INTERRUPTS_NUM   3
1749INTERRUPT_GEN( kaneko16_interrupt )
1749static INTERRUPT_GEN( kaneko16_interrupt )
17501750{
17511751   switch ( cpu_getiloops() )
17521752   {
r1293r1294
20822082    other: busy loop
20832083*/
20842084#define SHOGWARR_INTERRUPTS_NUM   3
2085INTERRUPT_GEN( shogwarr_interrupt )
2085static INTERRUPT_GEN( shogwarr_interrupt )
20862086{
20872087   switch ( cpu_getiloops() )
20882088   {
r1293r1294
21412141 have the even and odd pixels swapped. So we use this function to untangle
21422142 them and have one single gfxlayout for both tiles and sprites.
21432143*/
2144void kaneko16_unscramble_tiles(int region)
2144static void kaneko16_unscramble_tiles(int region)
21452145{
21462146   UINT8 *RAM   =   memory_region(region);
21472147   int size         =   memory_region_length(region);
r1293r1294
21552155   }
21562156}
21572157
2158void kaneko16_expand_sample_banks(int region)
2158static void kaneko16_expand_sample_banks(int region)
21592159{
21602160   /* The sample data for the first OKI has an address translator/
21612161       banking register in it that munges the addresses as follows:
src/mame/drivers/ms32.c
r1293r1294
275275   cpunum_set_input_line(1, INPUT_LINE_NMI, ASSERT_LINE);
276276
277277   // give the Z80 time to respond
278   cpu_spinuntil_time(MAME_TIME_IN_USEC(40));
278   cpu_spinuntil_time(ATTOTIME_IN_USEC(40));
279279}
280280
281281static READ32_HANDLER( ms32_sound_r )
src/mame/drivers/mpu4.c
r1293r1294
252252#include "sound/ay8910.h"
253253#include "machine/steppers.h"   // stepper motor
254254#include "machine/roc10937.h"   // vfd
255#include "machine/mmtr.h"
255#include "machine/meters.h"
256256
257257#ifdef MAME_DEBUG
258258#define LOG(x)logerror x
r1293r1294
296296static int ic23_active;
297297static int led_extend;
298298static int serial_card_connected;
299static mame_timer *ic24_timer;
299static emu_timer *ic24_timer;
300300static TIMER_CALLBACK( ic24_timeout );
301301
302302static int   input_strobe;     // IC23 74LS138 A = CA2 IC7, B = CA2 IC4, C = CA2 IC8
r1293r1294
304304static UINT8  lamp_data;
305305static UINT8  aydata;
306306
307const UINT8 MPU4_chr_lut[72];
308UINT8 MPU4_chr_data[72];
307extern const UINT8 MPU4_chr_lut[72];
308static UINT8 MPU4_chr_data[72];
309309static UINT8 led_segs[8];
310310static UINT8 Lamps[128];      // 128 multiplexed lamps
311311                        // 32  multiplexed inputs - but a further 8 possible per AUX.
r1293r1294
603603      {
604604         ic23_active=1;
605605         ic24_output(0);
606         mame_timer_adjust(ic24_timer, double_to_mame_time(duration), 0, time_zero);
606         timer_adjust(ic24_timer, double_to_attotime(duration), 0, attotime_zero);
607607      }
608608   }
609609}
r1293r1294
852852static WRITE8_HANDLER( pia_ic7_portb_w )
853853{
854854   int i;
855   long cycles  = MAME_TIME_TO_CYCLES(0, mame_timer_get_time() );
855   long cycles  = ATTOTIME_TO_CYCLES(0, timer_get_time() );
856856
857857// The meters are connected to a voltage drop sensor, where current
858858// flowing through them also passes through pin B7, meaning that when
r1293r1294
891891{
892892// The eighth meter is connected here, because the voltage sensor
893893// is on PB7.
894   long cycles  = MAME_TIME_TO_CYCLES(0, mame_timer_get_time() );
894   long cycles  = ATTOTIME_TO_CYCLES(0, timer_get_time() );
895895   if (data)
896896   {
897897      pia_set_input_b(4,mmtr_data|0x80);
r1293r1294
11971197   pia_config(4,&pia_ic7_intf);
11981198   pia_config(5,&pia_ic8_intf);
11991199
1200   ic24_timer = mame_timer_alloc(ic24_timeout);
1200   ic24_timer = timer_alloc(ic24_timeout);
12011201   // setup ptm ////////////////////////////////////////////////////////////
12021202   ptm6840_config(0, &ptm_ic2_intf );
12031203}
src/mame/drivers/skylncr.c
r1293r1294
417417
418418
419419// It runs in IM 0, thus needs an opcode on the data bus
420INTERRUPT_GEN( skylncr_vblank_interrupt )
420static INTERRUPT_GEN( skylncr_vblank_interrupt )
421421{
422422   if (skylncr_nmi_enable) cpunum_set_input_line(0, INPUT_LINE_NMI, PULSE_LINE);
423423}
src/mame/drivers/darkseal.c
r1293r1294
295295   MDRV_CPU_PROGRAM_MAP(sound_readmem,sound_writemem)
296296
297297   MDRV_SCREEN_REFRESH_RATE(58)
298   MDRV_SCREEN_VBLANK_TIME(USEC_TO_SUBSECONDS(529))
298   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(529))
299299
300300   /* video hardware */
301301   MDRV_VIDEO_ATTRIBUTES(VIDEO_TYPE_RASTER | VIDEO_BUFFERS_SPRITERAM)
src/mame/drivers/pipeline.c
r1293r1294
210210static WRITE8_HANDLER(protection_w)
211211{
212212   timer_call_after_resynch(data, protection_deferred_w);
213   cpu_boost_interleave(time_zero, MAME_TIME_IN_USEC(100));
213   cpu_boost_interleave(attotime_zero, ATTOTIME_IN_USEC(100));
214214}
215215
216216static ADDRESS_MAP_START( cpu0_mem, ADDRESS_SPACE_PROGRAM, 8 )
src/mame/drivers/stadhero.c
r1293r1294
288288   MDRV_CPU_PROGRAM_MAP(stadhero_s_readmem,stadhero_s_writemem)
289289
290290   MDRV_SCREEN_REFRESH_RATE(58)
291   MDRV_SCREEN_VBLANK_TIME(USEC_TO_SUBSECONDS(529))
291   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(529))
292292
293293   /* video hardware */
294294   MDRV_VIDEO_ATTRIBUTES(VIDEO_TYPE_RASTER)
src/mame/drivers/simpsons.c
r1293r1294
8585{
8686//  sound_nmi_enabled = 1;
8787   cpunum_set_input_line(1, INPUT_LINE_NMI, CLEAR_LINE);
88   mame_timer_set(MAME_TIME_IN_USEC(25),0,nmi_callback);   /* kludge until the K053260 is emulated correctly */
88   timer_set(ATTOTIME_IN_USEC(25),0,nmi_callback);   /* kludge until the K053260 is emulated correctly */
8989}
9090
9191static ADDRESS_MAP_START( z80_map, ADDRESS_SPACE_PROGRAM, 8 )
r1293r1294
266266      simpsons_objdma();
267267
268268      // 32+256us delay at 8MHz dotclock; artificially shortened since actual V-blank length is unknown
269      mame_timer_set(MAME_TIME_IN_USEC(30), 0, dmaend_callback);
269      timer_set(ATTOTIME_IN_USEC(30), 0, dmaend_callback);
270270   }
271271
272272   if (K052109_is_IRQ_enabled())
src/mame/drivers/wwfsstar.c
r1293r1294
367367   MDRV_CPU_PROGRAM_MAP(readmem_sound,writemem_sound)
368368
369369   MDRV_SCREEN_REFRESH_RATE(57.44)
370   MDRV_SCREEN_VBLANK_TIME(USEC_TO_SUBSECONDS(0))
370   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(0))
371371
372372   /* video hardware */
373373   MDRV_VIDEO_ATTRIBUTES(VIDEO_TYPE_RASTER)
src/mame/drivers/model1.c
r1293r1294
867867
868868   if ((sr & 0x0700) > 0x0100)
869869   {
870      cpu_spinuntil_time(MAME_TIME_IN_USEC(40));
870      cpu_spinuntil_time(ATTOTIME_IN_USEC(40));
871871      return 0;   // not ready yet, interrupts disabled
872872   }
873873
r1293r1294
883883   // signal the 68000 that there's data waiting
884884   cpunum_set_input_line(1, 2, HOLD_LINE);
885885   // give the 68k time to reply
886   cpu_spinuntil_time(MAME_TIME_IN_USEC(40));
886   cpu_spinuntil_time(ATTOTIME_IN_USEC(40));
887887}
888888
889889static ADDRESS_MAP_START( model1_mem, ADDRESS_SPACE_PROGRAM, 16 )
src/mame/drivers/actfancr.c
r1293r1294
399399   MDRV_CPU_PROGRAM_MAP(dec0_s_readmem,dec0_s_writemem)
400400
401401   MDRV_SCREEN_REFRESH_RATE(60)
402   MDRV_SCREEN_VBLANK_TIME(USEC_TO_SUBSECONDS(529))
402   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(529))
403403
404404   /* video hardware */
405405   MDRV_VIDEO_ATTRIBUTES(VIDEO_TYPE_RASTER | VIDEO_BUFFERS_SPRITERAM)
r1293r1294
442442   MDRV_CPU_PROGRAM_MAP(dec0_s_readmem,dec0_s_writemem)
443443
444444   MDRV_SCREEN_REFRESH_RATE(60)
445   MDRV_SCREEN_VBLANK_TIME(USEC_TO_SUBSECONDS(529))
445   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(529))
446446
447447   /* video hardware */
448448   MDRV_VIDEO_ATTRIBUTES(VIDEO_TYPE_RASTER | VIDEO_BUFFERS_SPRITERAM)
src/mame/drivers/taito_b.c
r1293r1294
216216
217217static INTERRUPT_GEN( rastansaga2_interrupt )
218218{
219   mame_timer_set(MAME_TIME_IN_CYCLES(5000,0),0,rsaga2_interrupt2);
219   timer_set(ATTOTIME_IN_CYCLES(5000,0),0,rsaga2_interrupt2);
220220   cpunum_set_input_line(0, 4, HOLD_LINE);
221221}
222222
r1293r1294
228228
229229static INTERRUPT_GEN( crimec_interrupt )
230230{
231   mame_timer_set(MAME_TIME_IN_CYCLES(5000,0),0,crimec_interrupt3);
231   timer_set(ATTOTIME_IN_CYCLES(5000,0),0,crimec_interrupt3);
232232   cpunum_set_input_line(0, 5, HOLD_LINE);
233233}
234234
r1293r1294
240240
241241static INTERRUPT_GEN( hitice_interrupt )
242242{
243   mame_timer_set(MAME_TIME_IN_CYCLES(5000,0),0,hitice_interrupt6);
243   timer_set(ATTOTIME_IN_CYCLES(5000,0),0,hitice_interrupt6);
244244   cpunum_set_input_line(0, 4, HOLD_LINE);
245245}
246246
r1293r1294
252252
253253static INTERRUPT_GEN( rambo3_interrupt )
254254{
255   mame_timer_set(MAME_TIME_IN_CYCLES(5000,0),0,rambo3_interrupt1);
255   timer_set(ATTOTIME_IN_CYCLES(5000,0),0,rambo3_interrupt1);
256256   cpunum_set_input_line(0, 6, HOLD_LINE);
257257}
258258
r1293r1294
264264
265265static INTERRUPT_GEN( pbobble_interrupt )
266266{
267   mame_timer_set(MAME_TIME_IN_CYCLES(5000,0),0,pbobble_interrupt5);
267   timer_set(ATTOTIME_IN_CYCLES(5000,0),0,pbobble_interrupt5);
268268   cpunum_set_input_line(0, 3, HOLD_LINE);
269269}
270270
r1293r1294
275275
276276static INTERRUPT_GEN( viofight_interrupt )
277277{
278   mame_timer_set(MAME_TIME_IN_CYCLES(5000,0),0,viofight_interrupt1);
278   timer_set(ATTOTIME_IN_CYCLES(5000,0),0,viofight_interrupt1);
279279   cpunum_set_input_line(0, 4, HOLD_LINE);
280280}
281281
r1293r1294
286286
287287static INTERRUPT_GEN( masterw_interrupt )
288288{
289   mame_timer_set(MAME_TIME_IN_CYCLES(5000,0),0,masterw_interrupt4);
289   timer_set(ATTOTIME_IN_CYCLES(5000,0),0,masterw_interrupt4);
290290   cpunum_set_input_line(0, 5, HOLD_LINE);
291291}
292292
r1293r1294
297297
298298static INTERRUPT_GEN( silentd_interrupt )
299299{
300   mame_timer_set(MAME_TIME_IN_CYCLES(5000,0),0,silentd_interrupt4);
300   timer_set(ATTOTIME_IN_CYCLES(5000,0),0,silentd_interrupt4);
301301   cpunum_set_input_line(0, 6, HOLD_LINE);
302302}
303303
r1293r1294
308308
309309static INTERRUPT_GEN( selfeena_interrupt )
310310{
311   mame_timer_set(MAME_TIME_IN_CYCLES(5000,0),0,selfeena_interrupt4);
311   timer_set(ATTOTIME_IN_CYCLES(5000,0),0,selfeena_interrupt4);
312312   cpunum_set_input_line(0, 6, HOLD_LINE);
313313}
314314
r1293r1294
319319
320320static INTERRUPT_GEN( sbm_interrupt )//5
321321{
322   mame_timer_set(MAME_TIME_IN_CYCLES(10000,0),0,sbm_interrupt5);
322   timer_set(ATTOTIME_IN_CYCLES(10000,0),0,sbm_interrupt5);
323323   cpunum_set_input_line(0, 4, HOLD_LINE);
324324}
325325
src/mame/drivers/jackal.c
r1293r1294
243243
244244/* Interrupt Generator */
245245
246INTERRUPT_GEN( jackal_interrupt )
246static INTERRUPT_GEN( jackal_interrupt )
247247{
248248   if (irq_enable)
249249      cpunum_set_input_line(0, 0, HOLD_LINE);
src/mame/drivers/tank8.c
r1293r1294
388388   MDRV_CPU_PROGRAM_MAP(tank8_cpu_map, 0)
389389
390390   MDRV_SCREEN_REFRESH_RATE(60)
391   MDRV_SCREEN_VBLANK_TIME(USEC_TO_SUBSECONDS(30 * 1000000 / 15681))
391   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(30 * 1000000 / 15681))
392392   MDRV_MACHINE_RESET(tank8)
393393
394394   /* video hardware */
src/mame/drivers/mw8080bw.c
r1293r1294
872872static MACHINE_START( maze )
873873{
874874   /* create astable timer for IC B1 */
875   mame_timer_pulse(MAZE_555_B1_PERIOD, 0, maze_tone_timing_timer_callback);
875   timer_pulse(MAZE_555_B1_PERIOD, 0, maze_tone_timing_timer_callback);
876876
877877   /* initialize state of Tone Timing FF, IC C1 */
878878   maze_tone_timing_state = 0;
r1293r1294
12751275   MDRV_CPU_MODIFY("main")
12761276   MDRV_CPU_IO_MAP(desertgu_io_map,0)
12771277   MDRV_MACHINE_START(desertgu)
1278   MDRV_WATCHDOG_TIME_INIT(MAME_TIME_IN_USEC(255000000 / (MW8080BW_PIXEL_CLOCK / MW8080BW_HTOTAL / MW8080BW_VTOTAL)))
1278   MDRV_WATCHDOG_TIME_INIT(ATTOTIME_IN_USEC(255000000 / (MW8080BW_PIXEL_CLOCK / MW8080BW_HTOTAL / MW8080BW_VTOTAL)))
12791279
12801280   /* audio hardware */
12811281   MDRV_IMPORT_FROM(desertgu_audio)
r1293r1294
14721472   MDRV_IMPORT_FROM(mw8080bw_root)
14731473   MDRV_CPU_MODIFY("main")
14741474   MDRV_CPU_IO_MAP(dplay_io_map,0)
1475   MDRV_WATCHDOG_TIME_INIT(MAME_TIME_IN_USEC(255000000 / (MW8080BW_PIXEL_CLOCK / MW8080BW_HTOTAL / MW8080BW_VTOTAL)))
1475   MDRV_WATCHDOG_TIME_INIT(ATTOTIME_IN_USEC(255000000 / (MW8080BW_PIXEL_CLOCK / MW8080BW_HTOTAL / MW8080BW_VTOTAL)))
14761476
14771477   /* audio hardware */
14781478   MDRV_IMPORT_FROM(dplay_audio)
r1293r1294
16541654   MDRV_CPU_MODIFY("main")
16551655   MDRV_CPU_IO_MAP(m4_io_map,0)
16561656   MDRV_MACHINE_START(m4)
1657   MDRV_WATCHDOG_TIME_INIT(MAME_TIME_IN_USEC(255000000 / (MW8080BW_PIXEL_CLOCK / MW8080BW_HTOTAL / MW8080BW_VTOTAL)))
1657   MDRV_WATCHDOG_TIME_INIT(ATTOTIME_IN_USEC(255000000 / (MW8080BW_PIXEL_CLOCK / MW8080BW_HTOTAL / MW8080BW_VTOTAL)))
16581658
16591659   /* audio hardware */
16601660   MDRV_IMPORT_FROM(m4_audio)
r1293r1294
18281828   MDRV_CPU_MODIFY("main")
18291829   MDRV_CPU_IO_MAP(clowns_io_map,0)
18301830   MDRV_MACHINE_START(clowns)
1831   MDRV_WATCHDOG_TIME_INIT(MAME_TIME_IN_USEC(255000000 / (MW8080BW_PIXEL_CLOCK / MW8080BW_HTOTAL / MW8080BW_VTOTAL)))
1831   MDRV_WATCHDOG_TIME_INIT(ATTOTIME_IN_USEC(255000000 / (MW8080BW_PIXEL_CLOCK / MW8080BW_HTOTAL / MW8080BW_VTOTAL)))
18321832
18331833   /* audio hardware */
18341834   MDRV_IMPORT_FROM(clowns_audio)
r1293r1294
19061906   MDRV_IMPORT_FROM(mw8080bw_root)
19071907   MDRV_CPU_MODIFY("main")
19081908   MDRV_CPU_IO_MAP(shuffle_io_map,0)
1909   MDRV_WATCHDOG_TIME_INIT(MAME_TIME_IN_USEC(255000000 / (MW8080BW_PIXEL_CLOCK / MW8080BW_HTOTAL / MW8080BW_VTOTAL)))
1909   MDRV_WATCHDOG_TIME_INIT(ATTOTIME_IN_USEC(255000000 / (MW8080BW_PIXEL_CLOCK / MW8080BW_HTOTAL / MW8080BW_VTOTAL)))
19101910
19111911   /* audio hardware */
19121912   /* MDRV_IMPORT_FROM(shuffle_audio) */
r1293r1294
19911991   MDRV_CPU_IO_MAP(dogpatch_io_map,0)
19921992   /* the watch dog time is unknown, but all other */
19931993   /* Midway boards of the era used the same circuit */
1994   MDRV_WATCHDOG_TIME_INIT(MAME_TIME_IN_USEC(255000000 / (MW8080BW_PIXEL_CLOCK / MW8080BW_HTOTAL / MW8080BW_VTOTAL)))
1994   MDRV_WATCHDOG_TIME_INIT(ATTOTIME_IN_USEC(255000000 / (MW8080BW_PIXEL_CLOCK / MW8080BW_HTOTAL / MW8080BW_VTOTAL)))
19951995
19961996   /* audio hardware */
19971997   MDRV_IMPORT_FROM(dogpatch_audio)
r1293r1294
20072007 *************************************/
20082008
20092009#define SPCENCTR_STROBE_FREQ      (9.00)  /* Hz - calculated from the 555 timer */
2010#define SPCENCTR_STROBE_PERIOD      MAME_TIME_IN_HZ(SPCENCTR_STROBE_FREQ)
2010#define SPCENCTR_STROBE_PERIOD      ATTOTIME_IN_HZ(SPCENCTR_STROBE_FREQ)
20112011#define SPCENCTR_DUTY_CYCLE         (95) /* % */
20122012
20132013
2014static mame_timer *spcenctr_strobe_on_timer;
2015static mame_timer *spcenctr_strobe_off_timer;
2014static emu_timer *spcenctr_strobe_on_timer;
2015static emu_timer *spcenctr_strobe_off_timer;
20162016static UINT8 spcenctr_strobe_state;
20172017static UINT8 spcenctr_trench_width;
20182018static UINT8 spcenctr_trench_center;
r1293r1294
20262026   if (spcenctr_strobe_state)
20272027   {
20282028      /* multiply by the precentage and divide by 100 to get the ON period */
2029      mame_time on_period = scale_down_mame_time(scale_up_mame_time(SPCENCTR_STROBE_PERIOD, SPCENCTR_DUTY_CYCLE), 100);
2029      attotime on_period = attotime_div(attotime_mul(SPCENCTR_STROBE_PERIOD, SPCENCTR_DUTY_CYCLE), 100);
20302030
2031      mame_timer_adjust(spcenctr_strobe_on_timer, time_zero, 1, SPCENCTR_STROBE_PERIOD);
2032      mame_timer_adjust(spcenctr_strobe_off_timer, on_period, 0, SPCENCTR_STROBE_PERIOD);
2031      timer_adjust(spcenctr_strobe_on_timer, attotime_zero, 1, SPCENCTR_STROBE_PERIOD);
2032      timer_adjust(spcenctr_strobe_off_timer, on_period, 0, SPCENCTR_STROBE_PERIOD);
20332033   }
20342034   else
20352035   {
2036      mame_timer_adjust(spcenctr_strobe_on_timer, time_never, 0, time_zero);
2037      mame_timer_adjust(spcenctr_strobe_off_timer, time_zero, 0, time_zero);
2036      timer_adjust(spcenctr_strobe_on_timer, attotime_never, 0, attotime_zero);
2037      timer_adjust(spcenctr_strobe_off_timer, attotime_zero, 0, attotime_zero);
20382038   }
20392039}
20402040
r1293r1294
20482048static MACHINE_START( spcenctr )
20492049{
20502050   /* create timers */
2051   spcenctr_strobe_on_timer = mame_timer_alloc(spcenctr_strobe_timer_callback);
2052   spcenctr_strobe_off_timer = mame_timer_alloc(spcenctr_strobe_timer_callback);
2051   spcenctr_strobe_on_timer = timer_alloc(spcenctr_strobe_timer_callback);
2052   spcenctr_strobe_off_timer = timer_alloc(spcenctr_strobe_timer_callback);
20532053
20542054   /* setup for save states */
20552055   state_save_register_global(spcenctr_strobe_state);
r1293r1294
21992199   MDRV_CPU_MODIFY("main")
22002200   MDRV_CPU_IO_MAP(spcenctr_io_map,0)
22012201   MDRV_MACHINE_START(spcenctr)
2202   MDRV_WATCHDOG_TIME_INIT(MAME_TIME_IN_USEC(255000000 / (MW8080BW_PIXEL_CLOCK / MW8080BW_HTOTAL / MW8080BW_VTOTAL)))
2202   MDRV_WATCHDOG_TIME_INIT(ATTOTIME_IN_USEC(255000000 / (MW8080BW_PIXEL_CLOCK / MW8080BW_HTOTAL / MW8080BW_VTOTAL)))
22032203
22042204   /* video hardware */
22052205   MDRV_VIDEO_UPDATE(spcenctr)
r1293r1294
22992299   MDRV_CPU_MODIFY("main")
23002300   MDRV_CPU_IO_MAP(phantom2_io_map,0)
23012301   MDRV_MACHINE_START(phantom2)
2302   MDRV_WATCHDOG_TIME_INIT(MAME_TIME_IN_USEC(255000000 / (MW8080BW_PIXEL_CLOCK / MW8080BW_HTOTAL / MW8080BW_VTOTAL)))
2302   MDRV_WATCHDOG_TIME_INIT(ATTOTIME_IN_USEC(255000000 / (MW8080BW_PIXEL_CLOCK / MW8080BW_HTOTAL / MW8080BW_VTOTAL)))
23032303
23042304   /* video hardware */
23052305   MDRV_VIDEO_UPDATE(phantom2)
r1293r1294
24352435   MDRV_IMPORT_FROM(mw8080bw_root)
24362436   MDRV_CPU_MODIFY("main")
24372437   MDRV_CPU_IO_MAP(bowler_io_map,0)
2438   MDRV_WATCHDOG_TIME_INIT(MAME_TIME_IN_USEC(255000000 / (MW8080BW_PIXEL_CLOCK / MW8080BW_HTOTAL / MW8080BW_VTOTAL)))
2438   MDRV_WATCHDOG_TIME_INIT(ATTOTIME_IN_USEC(255000000 / (MW8080BW_PIXEL_CLOCK / MW8080BW_HTOTAL / MW8080BW_VTOTAL)))
24392439
24402440   /* audio hardware */
24412441   MDRV_IMPORT_FROM(bowler_audio)
r1293r1294
26572657   MDRV_CPU_MODIFY("main")
26582658   MDRV_CPU_IO_MAP(invaders_io_map,0)
26592659   MDRV_MACHINE_START(invaders)
2660   MDRV_WATCHDOG_TIME_INIT(MAME_TIME_IN_USEC(255000000 / (MW8080BW_PIXEL_CLOCK / MW8080BW_HTOTAL / MW8080BW_VTOTAL)))
2660   MDRV_WATCHDOG_TIME_INIT(ATTOTIME_IN_USEC(255000000 / (MW8080BW_PIXEL_CLOCK / MW8080BW_HTOTAL / MW8080BW_VTOTAL)))
26612661
26622662   /* video hardware */
26632663   MDRV_VIDEO_UPDATE(invaders)
r1293r1294
27362736   MDRV_IMPORT_FROM(mw8080bw_root)
27372737   MDRV_CPU_MODIFY("main")
27382738   MDRV_CPU_IO_MAP(blueshrk_io_map,0)
2739   MDRV_WATCHDOG_TIME_INIT(MAME_TIME_IN_USEC(255000000 / (MW8080BW_PIXEL_CLOCK / MW8080BW_HTOTAL / MW8080BW_VTOTAL)))
2739   MDRV_WATCHDOG_TIME_INIT(ATTOTIME_IN_USEC(255000000 / (MW8080BW_PIXEL_CLOCK / MW8080BW_HTOTAL / MW8080BW_VTOTAL)))
27402740
27412741   /* audio hardware */
27422742   MDRV_IMPORT_FROM(blueshrk_audio)
r1293r1294
28342834   MDRV_IMPORT_FROM(mw8080bw_root)
28352835   MDRV_CPU_MODIFY("main")
28362836   MDRV_CPU_IO_MAP(invad2ct_io_map,0)
2837   MDRV_WATCHDOG_TIME_INIT(MAME_TIME_IN_USEC(255000000 / (MW8080BW_PIXEL_CLOCK / MW8080BW_HTOTAL / MW8080BW_VTOTAL)))
2837   MDRV_WATCHDOG_TIME_INIT(ATTOTIME_IN_USEC(255000000 / (MW8080BW_PIXEL_CLOCK / MW8080BW_HTOTAL / MW8080BW_VTOTAL)))
28382838
28392839   /* audio hardware */
28402840   MDRV_IMPORT_FROM(invad2ct_audio)
src/mame/drivers/suna8.c
r1293r1294
16531653   soundirq   /* IRQ Line */
16541654};
16551655
1656INTERRUPT_GEN( brickzn_interrupt )
1656static INTERRUPT_GEN( brickzn_interrupt )
16571657{
16581658   if (cpu_getiloops()) cpunum_set_input_line(0, INPUT_LINE_NMI, PULSE_LINE);
16591659   else             cpunum_set_input_line(0, 0, HOLD_LINE);
r1293r1294
17241724
17251725/* 1 x 24 MHz crystal */
17261726
1727INTERRUPT_GEN( hardhea2_interrupt )
1727static INTERRUPT_GEN( hardhea2_interrupt )
17281728{
17291729   if (cpu_getiloops())
17301730   {
src/mame/drivers/vaportra.c
r1293r1294
281281   MDRV_CPU_PROGRAM_MAP(sound_readmem,sound_writemem)
282282
283283   MDRV_SCREEN_REFRESH_RATE(58)
284   MDRV_SCREEN_VBLANK_TIME(USEC_TO_SUBSECONDS(529))
284   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(529))
285285
286286   /* video hardware */
287287   MDRV_VIDEO_ATTRIBUTES(VIDEO_TYPE_RASTER | VIDEO_BUFFERS_SPRITERAM)
src/mame/drivers/btime.c
r1293r1294
13031303   MDRV_CPU_VBLANK_INT(nmi_line_pulse,16)
13041304
13051305   MDRV_SCREEN_REFRESH_RATE(57)
1306   MDRV_SCREEN_VBLANK_TIME(USEC_TO_SUBSECONDS(3072))
1306   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(3072))
13071307
13081308   /* video hardware */
13091309   MDRV_VIDEO_ATTRIBUTES(VIDEO_TYPE_RASTER)
src/mame/drivers/qdrmfgp.c
r1293r1294
656656   sndram = memory_region(REGION_SOUND1) + 0x100000;
657657
658658   /* sound irq (CCU? 240Hz) */
659   mame_timer_pulse(MAME_TIME_IN_HZ(18432000/76800), 0, gp2_timer_callback);
659   timer_pulse(ATTOTIME_IN_HZ(18432000/76800), 0, gp2_timer_callback);
660660
661661   /* reset the IDE controller */
662662   gp2_irq_control = 0;
src/mame/drivers/cps1.c
r1293r1294
530530             INPUT PORTS, DIPs
531531***********************************************************/
532532
533#define CPS1_COINAGE_1 \
534   PORT_DIPNAME( 0x07, 0x07, DEF_STR( Coin_A ) ) \
533#define CPS1_COINAGE_1(diploc) \
534   PORT_DIPNAME( 0x07, 0x07, DEF_STR( Coin_A ) ) PORT_DIPLOCATION(diploc ":1,2,3") \
535535   PORT_DIPSETTING(    0x00, DEF_STR( 4C_1C ) ) \
536536   PORT_DIPSETTING(    0x01, DEF_STR( 3C_1C ) ) \
537537   PORT_DIPSETTING(    0x02, DEF_STR( 2C_1C ) ) \
r1293r1294
540540   PORT_DIPSETTING(    0x05, DEF_STR( 1C_3C ) ) \
541541   PORT_DIPSETTING(    0x04, DEF_STR( 1C_4C ) ) \
542542   PORT_DIPSETTING(    0x03, DEF_STR( 1C_6C ) ) \
543   PORT_DIPNAME( 0x38, 0x38, DEF_STR( Coin_B ) ) \
543   PORT_DIPNAME( 0x38, 0x38, DEF_STR( Coin_B ) ) PORT_DIPLOCATION(diploc ":4,5,6") \
544544   PORT_DIPSETTING(    0x00, DEF_STR( 4C_1C ) ) \
545545   PORT_DIPSETTING(    0x08, DEF_STR( 3C_1C ) ) \
546546   PORT_DIPSETTING(    0x10, DEF_STR( 2C_1C ) ) \
r1293r1294
550550   PORT_DIPSETTING(    0x20, DEF_STR( 1C_4C ) ) \
551551   PORT_DIPSETTING(    0x18, DEF_STR( 1C_6C ) )
552552
553#define CPS1_COINAGE_2 \
554   PORT_DIPNAME( 0x07, 0x07, DEF_STR( Coinage ) ) \
553#define CPS1_COINAGE_2(diploc) \
554   PORT_DIPNAME( 0x07, 0x07, DEF_STR( Coinage ) ) PORT_DIPLOCATION(diploc ":1,2,3") \
555555   PORT_DIPSETTING(    0x00, DEF_STR( 4C_1C ) ) \
556556   PORT_DIPSETTING(    0x01, DEF_STR( 3C_1C ) ) \
557557   PORT_DIPSETTING(    0x02, DEF_STR( 2C_1C ) ) \
r1293r1294
561561   PORT_DIPSETTING(    0x04, DEF_STR( 1C_4C ) ) \
562562   PORT_DIPSETTING(    0x03, DEF_STR( 1C_6C ) )
563563
564#define CPS1_COINAGE_3 \
565   PORT_DIPNAME( 0x07, 0x07, DEF_STR( Coin_A ) ) \
564#define CPS1_COINAGE_3(diploc) \
565   PORT_DIPNAME( 0x07, 0x07, DEF_STR( Coin_A ) ) PORT_DIPLOCATION(diploc ":1,2,3") \
566566   PORT_DIPSETTING(    0x01, DEF_STR( 4C_1C ) ) \
567567   PORT_DIPSETTING(    0x02, DEF_STR( 3C_1C ) ) \
568568   PORT_DIPSETTING(    0x03, DEF_STR( 2C_1C ) ) \
r1293r1294
571571   PORT_DIPSETTING(    0x06, DEF_STR( 1C_2C ) ) \
572572   PORT_DIPSETTING(    0x05, DEF_STR( 1C_3C ) ) \
573573   PORT_DIPSETTING(    0x04, DEF_STR( 1C_4C ) ) \
574   PORT_DIPNAME( 0x38, 0x38, DEF_STR( Coin_B ) ) \
574   PORT_DIPNAME( 0x38, 0x38, DEF_STR( Coin_B ) ) PORT_DIPLOCATION(diploc ":4,5,6") \
575575   PORT_DIPSETTING(    0x08, DEF_STR( 4C_1C ) ) \
576576   PORT_DIPSETTING(    0x10, DEF_STR( 3C_1C ) ) \
577577   PORT_DIPSETTING(    0x18, DEF_STR( 2C_1C ) ) \
r1293r1294
581581   PORT_DIPSETTING(    0x28, DEF_STR( 1C_3C ) ) \
582582   PORT_DIPSETTING(    0x20, DEF_STR( 1C_4C ) )
583583
584#define CPS1_DIFFICULTY_1 \
585   PORT_DIPNAME( 0x07, 0x04, DEF_STR( Difficulty ) ) \
584#define CPS1_DIFFICULTY_1(diploc) \
585   PORT_DIPNAME( 0x07, 0x04, DEF_STR( Difficulty ) ) PORT_DIPLOCATION(diploc ":1,2,3") \
586586   PORT_DIPSETTING(    0x07, "1 (Easiest)" ) \
587587   PORT_DIPSETTING(    0x06, "2" ) \
588588   PORT_DIPSETTING(    0x05, "3" ) \
r1293r1294
592592   PORT_DIPSETTING(    0x01, "7" ) \
593593   PORT_DIPSETTING(    0x00, "8 (Hardest)" )
594594
595#define CPS1_DIFFICULTY_2 \
596   PORT_DIPNAME( 0x07, 0x07, DEF_STR( Difficulty ) ) \
595#define CPS1_DIFFICULTY_2(diploc) \
596   PORT_DIPNAME( 0x07, 0x07, DEF_STR( Difficulty ) ) PORT_DIPLOCATION(diploc ":1,2,3") \
597597   PORT_DIPSETTING(    0x04, "1 (Easiest)" ) \
598598   PORT_DIPSETTING(    0x05, "2" ) \
599599   PORT_DIPSETTING(    0x06, "3" ) \
r1293r1294
615615   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )
616616   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
617617
618   PORT_START_TAG("DSWC")
619   PORT_DIPNAME( 0x80, 0x80, DEF_STR( Unused ) )
620   PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
621   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
622   PORT_DIPNAME( 0x40, 0x40, DEF_STR( Unknown ) )            // Check code at 0x013c78
623   PORT_DIPSETTING(    0x40, DEF_STR( Off ) )            // (0x013690 in 'lostwrld')
624   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
625   PORT_DIPNAME( 0x20, 0x20, DEF_STR( Unused ) )
626   PORT_DIPSETTING(    0x20, DEF_STR( Off ) )
627   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
628   PORT_DIPNAME( 0x10, 0x10, DEF_STR( Unused ) )
629   PORT_DIPSETTING(    0x10, DEF_STR( Off ) )
630   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
631   PORT_DIPNAME( 0x08, 0x08, DEF_STR( Unused ) )
632   PORT_DIPSETTING(    0x08, DEF_STR( Off ) )
633   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
634   PORT_DIPNAME( 0x04, 0x04, DEF_STR( Unused ) )
635   PORT_DIPSETTING(    0x04, DEF_STR( Off ) )
636   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
637   PORT_DIPNAME( 0x02, 0x02, DEF_STR( Unused ) )
638   PORT_DIPSETTING(    0x02, DEF_STR( Off ) )
639   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
640   PORT_DIPNAME( 0x01, 0x01, DEF_STR( Unused ) )
641   PORT_DIPSETTING(    0x01, DEF_STR( Off ) )
642   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
618   PORT_START_TAG("DSWC")                        // The manual only mentions two DIP switch banks.
619   PORT_DIPUNUSED( 0x80, 0x80 )                  // Is this port brought out to DIP switches or not?
620   PORT_DIPUNKNOWN( 0x40, 0x40 )                  // Check code at 0x013c78 (0x013690 in 'lostwrld')
621   PORT_DIPUNUSED( 0x20, 0x20 )
622   PORT_DIPUNUSED( 0x10, 0x10 )
623   PORT_DIPUNUSED( 0x08, 0x08 )
624   PORT_DIPUNUSED( 0x04, 0x04 )
625   PORT_DIPUNUSED( 0x02, 0x02 )
626   PORT_DIPUNUSED( 0x01, 0x01 )
643627
644628   PORT_START_TAG("DSWB")
645   PORT_DIPNAME( 0x80, 0x80, "Freeze" )
629   CPS1_DIFFICULTY_1( "DIP-B" )
630   PORT_DIPUNUSED_DIPLOC( 0x20, 0x20, "DIP-B:4" )
631   PORT_DIPUNUSED_DIPLOC( 0x10, 0x10, "DIP-B:5" )
632   PORT_DIPUNKNOWN_DIPLOC( 0x08, 0x08, "DIP-B:6" )         // Check code at 0x00111c (0x00112c in 'lostwrld')
633   PORT_SERVICE_DIPLOC( 0x40, IP_ACTIVE_LOW, "DIP-B:7" )
634   PORT_DIPNAME( 0x80, 0x80, "Freeze" )               PORT_DIPLOCATION("DIP-B:8")
646635   PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
647636   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
648   PORT_SERVICE( 0x40, IP_ACTIVE_LOW )
649   PORT_DIPNAME( 0x20, 0x20, DEF_STR( Unused ) )
650   PORT_DIPSETTING(    0x20, DEF_STR( Off ) )
651   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
652   PORT_DIPNAME( 0x10, 0x10, DEF_STR( Unused ) )
653   PORT_DIPSETTING(    0x10, DEF_STR( Off ) )
654   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
655   PORT_DIPNAME( 0x08, 0x08, DEF_STR( Unknown ) )            // Check code at 0x00111c
656   PORT_DIPSETTING(    0x08, DEF_STR( Off ) )            // (0x00112c in 'lostwrld')
657   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
658   CPS1_DIFFICULTY_1
659637
660638   PORT_START_TAG("DSWA")
661   PORT_DIPNAME( 0x80, 0x80, DEF_STR( Flip_Screen ) )
662   PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
663   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
664   PORT_DIPNAME( 0x40, 0x40, DEF_STR( Demo_Sounds ) )
639   CPS1_COINAGE_1( "DIP-A" )
640   PORT_DIPNAME( 0x40, 0x40, DEF_STR( Demo_Sounds ) )      PORT_DIPLOCATION("DIP-A:7")
665641   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
666642   PORT_DIPSETTING(    0x40, DEF_STR( On ) )
667   CPS1_COINAGE_1
643   PORT_DIPNAME( 0x80, 0x80, DEF_STR( Flip_Screen ) )      PORT_DIPLOCATION("DIP-A:8")
644   PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
645   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
668646
669647   PORT_START_TAG("IN1")
670648   PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_8WAY PORT_PLAYER(1)
r1293r1294
703681   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
704682
705683   PORT_START_TAG("DSWC")
706   PORT_DIPNAME( 0x80, 0x80, "Game Mode")
707   PORT_DIPSETTING(    0x80, "Game" )
708   PORT_DIPSETTING(    0x00, DEF_STR( Test ) )
709   PORT_DIPNAME( 0x40, 0x40, DEF_STR( Allow_Continue ) )
710   PORT_DIPSETTING(    0x00, DEF_STR( No ) )
711   PORT_DIPSETTING(    0x40, DEF_STR( Yes ) )
712   PORT_DIPNAME( 0x20, 0x20, DEF_STR( Unused ) )            // "Demo Sounds" in manual; doesn't work
713   PORT_DIPSETTING(    0x20, DEF_STR( Off ) )
714   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
715   PORT_DIPNAME( 0x10, 0x10, DEF_STR( Flip_Screen ) )
716   PORT_DIPSETTING(    0x10, DEF_STR( Off ) )
717   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
718   PORT_DIPNAME( 0x08, 0x08, DEF_STR( Unused ) )
719   PORT_DIPSETTING(    0x08, DEF_STR( Off ) )
720   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
721   PORT_DIPNAME( 0x04, 0x04, DEF_STR( Unused ) )
722   PORT_DIPSETTING(    0x04, DEF_STR( Off ) )
723   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
724   PORT_DIPNAME( 0x03, 0x03, DEF_STR( Lives ) )
684   PORT_DIPNAME( 0x03, 0x03, DEF_STR( Lives ) )         PORT_DIPLOCATION("SW(C):1,2")
725685   PORT_DIPSETTING(    0x03, "3" )
726686   PORT_DIPSETTING(    0x02, "4" )
727687   PORT_DIPSETTING(    0x01, "5" )
728688   PORT_DIPSETTING(    0x00, "6" )
729
730   PORT_START_TAG("DSWB")
731   PORT_DIPNAME( 0x80, 0x80, DEF_STR( Unused ) )
732   PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
689   PORT_DIPUNUSED_DIPLOC( 0x40, 0x40, "SW(C):3" )
690   PORT_DIPUNUSED_DIPLOC( 0x80, 0x80, "SW(C):4" )
691   PORT_DIPNAME( 0x10, 0x10, DEF_STR( Flip_Screen ) )      PORT_DIPLOCATION("SW(C):5")
692   PORT_DIPSETTING(    0x10, DEF_STR( Off ) )
733693   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
734   PORT_DIPNAME( 0x40, 0x40, DEF_STR( Unused ) )
735   PORT_DIPSETTING(    0x40, DEF_STR( Off ) )
694   PORT_DIPNAME( 0x20, 0x20, DEF_STR( Unused ) )         PORT_DIPLOCATION("SW(C):6")
695   PORT_DIPSETTING(    0x20, DEF_STR( Off ) )            // "Demo Sounds" in manual; doesn't work
736696   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
737   PORT_DIPNAME( 0x30, 0x30, DEF_STR( Bonus_Life ) )
697   PORT_DIPNAME( 0x40, 0x40, DEF_STR( Allow_Continue ) )   PORT_DIPLOCATION("SW(C):7")
698   PORT_DIPSETTING(    0x00, DEF_STR( No ) )
699   PORT_DIPSETTING(    0x40, DEF_STR( Yes ) )
700   PORT_DIPNAME( 0x80, 0x80, "Game Mode")               PORT_DIPLOCATION("SW(C):8")
701   PORT_DIPSETTING(    0x80, "Game" )
702   PORT_DIPSETTING(    0x00, DEF_STR( Test ) )
703
704   PORT_START_TAG("DSWB")
705   CPS1_DIFFICULTY_2( "SW(B)" )
706   PORT_DIPUNUSED_DIPLOC( 0x08, 0x08, "SW(B):4" )
707   PORT_DIPNAME( 0x30, 0x30, DEF_STR( Bonus_Life ) )      PORT_DIPLOCATION("SW(B):5,6")
738708   PORT_DIPSETTING(    0x20, "10K, 30K and every 30K" )
739709   PORT_DIPSETTING(    0x10, "20K, 50K and every 70K" )
740710   PORT_DIPSETTING(    0x30, "30K, 60K and every 70K" )
741711   PORT_DIPSETTING(    0x00, "40K, 70K and every 80K" )
742   PORT_DIPNAME( 0x08, 0x08, DEF_STR( Unused ) )
743   PORT_DIPSETTING(    0x08, DEF_STR( Off ) )
744   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
745   CPS1_DIFFICULTY_2
712   PORT_DIPUNUSED_DIPLOC( 0x40, 0x40, "SW(B):7" )
713   PORT_DIPUNUSED_DIPLOC( 0x80, 0x80, "SW(B):8" )
746714
747715   PORT_START_TAG("DSWA")
748   PORT_DIPNAME( 0xc0, 0xc0, DEF_STR( Cabinet ) )
716   CPS1_COINAGE_1( "SW(A)" )
717   PORT_DIPNAME( 0xc0, 0xc0, DEF_STR( Cabinet ) )         PORT_DIPLOCATION("SW(A):7,8")
749718   PORT_DIPSETTING(    0xc0, "Upright 1 Player" )
750719   PORT_DIPSETTING(    0x80, "Upright 2 Players" )
751//  PORT_DIPSETTING(    0x40, DEF_STR( Cocktail ) )
752   PORT_DIPSETTING(    0x00, DEF_STR( Cocktail ) )
753   CPS1_COINAGE_1
720//  PORT_DIPSETTING(    0x40, DEF_STR( Cocktail ) )         // Manual says these are both valid settings
721   PORT_DIPSETTING(    0x00, DEF_STR( Cocktail ) )         // for 2-player cocktail cabinet
754722
755723   PORT_START_TAG("IN1")
756724   PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_8WAY PORT_PLAYER(1)
r1293r1294
785753   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
786754
787755   PORT_START_TAG("DSWC")
788   PORT_DIPNAME( 0x80, 0x80, "Game Mode" )
789   PORT_DIPSETTING(    0x80, "Game" )
790   PORT_DIPSETTING(    0x00, DEF_STR( Test ) )
791   PORT_DIPNAME( 0x40, 0x40, DEF_STR( Allow_Continue ) )
792   PORT_DIPSETTING(    0x00, DEF_STR( No ) )
793   PORT_DIPSETTING(    0x40, DEF_STR( Yes ) )
794   PORT_DIPNAME( 0x20, 0x20, DEF_STR( Unused ) )            // "Demo Sounds" in manual; doesn't work
795   PORT_DIPSETTING(    0x20, DEF_STR( Off ) )
796   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
797   PORT_DIPNAME( 0x10, 0x10, DEF_STR( Flip_Screen ) )
798   PORT_DIPSETTING(    0x10, DEF_STR( Off ) )
799   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
800   PORT_DIPNAME( 0x08, 0x08, DEF_STR( Unused ) )
801   PORT_DIPSETTING(    0x08, DEF_STR( Off ) )
802   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
803   PORT_DIPNAME( 0x04, 0x04, DEF_STR( Unused ) )
804   PORT_DIPSETTING(    0x04, DEF_STR( Off ) )
805   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
806   PORT_DIPNAME( 0x03, 0x03, DEF_STR( Lives ) )
756   PORT_DIPNAME( 0x03, 0x03, DEF_STR( Lives ) )            PORT_DIPLOCATION("SW(C):1,2")
807757   PORT_DIPSETTING(    0x00, "2" )
808758   PORT_DIPSETTING(    0x03, "3" )
809759   PORT_DIPSETTING(    0x02, "4" )
810760   PORT_DIPSETTING(    0x01, "5" )
811
812   PORT_START_TAG("DSWB")
813   PORT_DIPNAME( 0x80, 0x80, "Freeze" )
814   PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
761   PORT_DIPUNUSED_DIPLOC( 0x40, 0x40, "SW(C):3" )
762   PORT_DIPUNUSED_DIPLOC( 0x80, 0x80, "SW(C):4" )
763   PORT_DIPNAME( 0x10, 0x10, DEF_STR( Flip_Screen ) )         PORT_DIPLOCATION("SW(C):5")
764   PORT_DIPSETTING(    0x10, DEF_STR( Off ) )
815765   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
816   PORT_DIPNAME( 0x40, 0x40, DEF_STR( Unused ) )
817   PORT_DIPSETTING(    0x40, DEF_STR( Off ) )
766   PORT_DIPNAME( 0x20, 0x20, DEF_STR( Unused ) )            PORT_DIPLOCATION("SW(C):6")
767   PORT_DIPSETTING(    0x20, DEF_STR( Off ) )               // "Demo Sounds" in manual; doesn't work
818768   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
769   PORT_DIPNAME( 0x40, 0x40, DEF_STR( Allow_Continue ) )      PORT_DIPLOCATION("SW(C):7")
770   PORT_DIPSETTING(    0x00, DEF_STR( No ) )
771   PORT_DIPSETTING(    0x40, DEF_STR( Yes ) )
772   PORT_DIPNAME( 0x80, 0x80, "Game Mode" )                  PORT_DIPLOCATION("SW(C):8")
773   PORT_DIPSETTING(    0x80, "Game" )
774   PORT_DIPSETTING(    0x00, DEF_STR( Test ) )
775
776   PORT_START_TAG("DSWB")
819777   /* Standard Dip Switches */
820   PORT_DIPNAME( 0x30, 0x30, DEF_STR( Bonus_Life ) )           PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x80)
821   PORT_DIPSETTING(    0x20, "10K, 30K and every 30K" )        PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x80)
822   PORT_DIPSETTING(    0x10, "20K, 50K and every 70K" )        PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x80)
823   PORT_DIPSETTING(    0x30, "30K, 60K and every 70K" )        PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x80)
824   PORT_DIPSETTING(    0x00, "40K, 70K and every 80K" )        PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x80)
825   PORT_DIPNAME( 0x08, 0x08, DEF_STR( Unused ) )               PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x80)
826   PORT_DIPSETTING(    0x08, DEF_STR( Off ) )                  PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x80)
827   PORT_DIPSETTING(    0x00, DEF_STR( On ) )                   PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x80)
828   PORT_DIPNAME( 0x07, 0x07, DEF_STR( Difficulty ) )           PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x80)
778   PORT_DIPNAME( 0x07, 0x07, DEF_STR( Difficulty ) )           PORT_DIPLOCATION("SW(B):1,2,3")
779                                                PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x80)
829780   PORT_DIPSETTING(    0x04, "1 (Easiest)" )                   PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x80)
830781   PORT_DIPSETTING(    0x05, "2" )                             PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x80)
831782   PORT_DIPSETTING(    0x06, "3" )                             PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x80)
r1293r1294
834785   PORT_DIPSETTING(    0x02, "6" )                             PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x80)
835786   PORT_DIPSETTING(    0x01, "7" )                             PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x80)
836787   PORT_DIPSETTING(    0x00, "8 (Hardest)" )                   PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x80)
788   PORT_DIPNAME( 0x08, 0x08, DEF_STR( Unused ) )            PORT_DIPLOCATION("SW(B):4")
789                                                PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x80)
790   PORT_DIPSETTING(    0x08, DEF_STR( Off ) )               PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x80)
791   PORT_DIPSETTING(    0x00, DEF_STR( On ) )               PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x80)
792   PORT_DIPNAME( 0x30, 0x30, DEF_STR( Bonus_Life ) )           PORT_DIPLOCATION("SW(B):5,6")
793                                                PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x80)
794   PORT_DIPSETTING(    0x20, "10K, 30K and every 30K" )        PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x80)
795   PORT_DIPSETTING(    0x10, "20K, 50K and every 70K" )        PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x80)
796   PORT_DIPSETTING(    0x30, "30K, 60K and every 70K" )        PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x80)
797   PORT_DIPSETTING(    0x00, "40K, 70K and every 80K" )        PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x80)
837798   /* Debug Dip Switches */
838   PORT_DIPNAME( 0x38, 0x30, "Armor on New Life" )             PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x00)
839//  PORT_DIPSETTING(    0x38, "Silver Armor" )                  PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x00)
840   PORT_DIPSETTING(    0x18, "Golden Armor" )                  PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x00)
841   PORT_DIPSETTING(    0x30, "Silver Armor" )                  PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x00)
842   PORT_DIPSETTING(    0x28, "None (young man)" )              PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x00)
843   PORT_DIPSETTING(    0x20, "None (old man)" )                PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x00)
844//  PORT_DIPSETTING(    0x10, "INVALID !" )                     PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x00)
845//  PORT_DIPSETTING(    0x08, "INVALID !" )                     PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x00)
846//  PORT_DIPSETTING(    0x00, "INVALID !" )                     PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x00)
847   PORT_DIPNAME( 0x07, 0x07, "Starting Weapon" )               PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x00)
799   PORT_DIPNAME( 0x07, 0x07, "Starting Weapon" )               PORT_DIPLOCATION("SW(B):1,2,3")
800                                                PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x00)
848801   PORT_DIPSETTING(    0x07, "Spear" )                         PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x00)
849802   PORT_DIPSETTING(    0x06, "Knife" )                         PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x00)
850803   PORT_DIPSETTING(    0x05, "Torch" )                         PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x00)
r1293r1294
853806   PORT_DIPSETTING(    0x02, "Shield" )                        PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x00)
854807   PORT_DIPSETTING(    0x01, "Super Weapon" )                  PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x00)
855808//  PORT_DIPSETTING(    0x00, "INVALID !" )                     PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x00)
809   PORT_DIPNAME( 0x38, 0x30, "Armor on New Life" )             PORT_DIPLOCATION("SW(B):4,5,6")
810                                                PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x00)
811//  PORT_DIPSETTING(    0x38, "Silver Armor" )                  PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x00)
812   PORT_DIPSETTING(    0x18, "Golden Armor" )                  PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x00)
813   PORT_DIPSETTING(    0x30, "Silver Armor" )                  PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x00)
814   PORT_DIPSETTING(    0x28, "None (young man)" )              PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x00)
815   PORT_DIPSETTING(    0x20, "None (old man)" )                PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x00)
816//  PORT_DIPSETTING(    0x10, "INVALID !" )                     PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x00)
817//  PORT_DIPSETTING(    0x08, "INVALID !" )                     PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x00)
818//  PORT_DIPSETTING(    0x00, "INVALID !" )                     PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x00)
856819
820   PORT_DIPUNUSED_DIPLOC( 0x40, 0x40, "SW(B):7" )
821   PORT_DIPNAME( 0x80, 0x80, "Freeze" )                  PORT_DIPLOCATION("SW(B):8")
822   PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
823   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
824
857825   PORT_START_TAG("DSWA")
858   PORT_DIPNAME( 0xc0, 0xc0, DEF_STR( Cabinet ) )
859   PORT_DIPSETTING(    0xc0, "Upright 1 Player" )
860   PORT_DIPSETTING(    0x80, "Upright 2 Players" )
861//  PORT_DIPSETTING(    0x40, DEF_STR( Cocktail ) )
862   PORT_DIPSETTING(    0x00, DEF_STR( Cocktail ) )
863826   /* Standard Dip Switches */
864   PORT_DIPNAME( 0x38, 0x38, DEF_STR( Coin_B ) )               PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x80)
827   PORT_DIPNAME( 0x07, 0x07, DEF_STR( Coin_A ) )            PORT_DIPLOCATION("SW(A):1,2,3")
828                                                PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x80)
865829   PORT_DIPSETTING(    0x00, DEF_STR( 4C_1C ) )                PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x80)
866   PORT_DIPSETTING(    0x08, DEF_STR( 3C_1C ) )                PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x80)
867   PORT_DIPSETTING(    0x10, DEF_STR( 2C_1C ) )                PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x80)
868   PORT_DIPSETTING(    0x38, DEF_STR( 1C_1C ) )                PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x80)
869   PORT_DIPSETTING(    0x30, DEF_STR( 1C_2C ) )                PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x80)
870   PORT_DIPSETTING(    0x28, DEF_STR( 1C_3C ) )                PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x80)
871   PORT_DIPSETTING(    0x20, DEF_STR( 1C_4C ) )                PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x80)
872   PORT_DIPSETTING(    0x18, DEF_STR( 1C_6C ) )                PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x80)
873   PORT_DIPNAME( 0x07, 0x07, DEF_STR( Coin_A ) )               PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x80)
874   PORT_DIPSETTING(    0x00, DEF_STR( 4C_1C ) )                PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x80)
875830   PORT_DIPSETTING(    0x01, DEF_STR( 3C_1C ) )                PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x80)
876831   PORT_DIPSETTING(    0x02, DEF_STR( 2C_1C ) )                PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x80)
877832   PORT_DIPSETTING(    0x07, DEF_STR( 1C_1C ) )                PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x80)
r1293r1294
879834   PORT_DIPSETTING(    0x05, DEF_STR( 1C_3C ) )                PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x80)
880835   PORT_DIPSETTING(    0x04, DEF_STR( 1C_4C ) )                PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x80)
881836   PORT_DIPSETTING(    0x03, DEF_STR( 1C_6C ) )                PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x80)
837   PORT_DIPNAME( 0x38, 0x38, DEF_STR( Coin_B ) )            PORT_DIPLOCATION("SW(A):4,5,6")
838                                                PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x80)
839   PORT_DIPSETTING(    0x00, DEF_STR( 4C_1C ) )                PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x80)
840   PORT_DIPSETTING(    0x08, DEF_STR( 3C_1C ) )                PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x80)
841   PORT_DIPSETTING(    0x10, DEF_STR( 2C_1C ) )                PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x80)
842   PORT_DIPSETTING(    0x38, DEF_STR( 1C_1C ) )                PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x80)
843   PORT_DIPSETTING(    0x30, DEF_STR( 1C_2C ) )                PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x80)
844   PORT_DIPSETTING(    0x28, DEF_STR( 1C_3C ) )                PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x80)
845   PORT_DIPSETTING(    0x20, DEF_STR( 1C_4C ) )                PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x80)
846   PORT_DIPSETTING(    0x18, DEF_STR( 1C_6C ) )                PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x80)
882847   /* Debug Dip Switches */
883   PORT_DIPNAME( 0x20, 0x20, "Slow Motion" )                   PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x00)
884   PORT_DIPSETTING(    0x20, DEF_STR( Off ) )                  PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x00)
885   PORT_DIPSETTING(    0x00, DEF_STR( On ) )                   PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x00)
886   PORT_DIPNAME( 0x10, 0x10, "Invulnerability" )               PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x00)
887   PORT_DIPSETTING(    0x10, DEF_STR( Off ) )                  PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x00)
888   PORT_DIPSETTING(    0x00, DEF_STR( On ) )                   PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x00)
889   PORT_DIPNAME( 0x0f, 0x0f, "Starting Level" )                PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x00)
848   PORT_DIPNAME( 0x0f, 0x0f, "Starting Level" )                PORT_DIPLOCATION("SW(A):1,2,3,4")
849                                                PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x00)
890850   PORT_DIPSETTING(    0x0f, "Level 1 (1st half)" )            PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x00)
891851   PORT_DIPSETTING(    0x0e, "Level 1 (2nd half)" )            PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x00)
892852   PORT_DIPSETTING(    0x0d, "Level 2 (1st half)" )            PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x00)
r1293r1294
903863//  PORT_DIPSETTING(    0x02, "INVALID !" )                     PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x00)
904864//  PORT_DIPSETTING(    0x01, "INVALID !" )                     PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x00)
905865//  PORT_DIPSETTING(    0x00, "INVALID !" )                     PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x00)
866   PORT_DIPNAME( 0x10, 0x10, "Invulnerability" )               PORT_DIPLOCATION("SW(A):5")
867                                                PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x00)
868   PORT_DIPSETTING(    0x10, DEF_STR( Off ) )                  PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x00)
869   PORT_DIPSETTING(    0x00, DEF_STR( On ) )                   PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x00)
870   PORT_DIPNAME( 0x20, 0x20, "Slow Motion" )                   PORT_DIPLOCATION("SW(A):6")
871                                                PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x00)
872   PORT_DIPSETTING(    0x20, DEF_STR( Off ) )                  PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x00)
873   PORT_DIPSETTING(    0x00, DEF_STR( On ) )                   PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x00)
906874
875   PORT_DIPNAME( 0xc0, 0xc0, DEF_STR( Cabinet ) )            PORT_DIPLOCATION("SW(A):7,8")
876   PORT_DIPSETTING(    0xc0, "Upright 1 Player" )
877   PORT_DIPSETTING(    0x80, "Upright 2 Players" )
878//  PORT_DIPSETTING(    0x40, DEF_STR( Cocktail ) )             // Manual says these are both valid settings
879   PORT_DIPSETTING(    0x00, DEF_STR( Cocktail ) )            // for 2-player cocktail cabinet
880
907881   PORT_START_TAG("IN1")
908882   PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_8WAY PORT_PLAYER(1)
909883   PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_8WAY PORT_PLAYER(1)
r1293r1294
928902   PORT_INCLUDE(ghouls)
929903
930904   PORT_MODIFY("DSWB")
931   PORT_DIPNAME( 0x80, 0x80, "Freeze" )
932   PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
905   PORT_DIPNAME( 0x80, 0x80, "Freeze" )      PORT_DIPLOCATION("SW(B):8")
906   PORT_DIPSETTING(    0x80, DEF_STR( Off ) )   // This switch isn't documented in the manual
933907   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
934908INPUT_PORTS_END
935909
r1293r1294
946920   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
947921
948922   PORT_START_TAG("DSWA")
949   CPS1_COINAGE_1
950   PORT_DIPNAME( 0xc0, 0xc0, DEF_STR( Cabinet ) )
951   PORT_DIPSETTING(    0xc0, "Upright 1 Player" )
923   CPS1_COINAGE_1( "SW(A)" )
924   PORT_DIPNAME( 0xc0, 0xc0, DEF_STR( Cabinet ) )            PORT_DIPLOCATION("SW(A):7,8")
925   PORT_DIPSETTING(    0xc0, "Upright 1 Player" )            // These switches are not documented in the manual
952926   PORT_DIPSETTING(    0x80, "Upright 2 Players" )
953927//  PORT_DIPSETTING(    0x40, DEF_STR( Cocktail ) )
954928   PORT_DIPSETTING(    0x00, DEF_STR( Cocktail ) )
955929
956930   PORT_START_TAG("DSWB")
957   CPS1_DIFFICULTY_2
931   CPS1_DIFFICULTY_2( "SW(B)" )
958932   /* In 'striderj', bit 3 is stored at 0xff8e77 ($e77,A5) via code at 0x000a2a,
959933       but this address is never checked again.
960934       In 'strider' and 'stridrja', this code even doesn't exist ! */
961   PORT_DIPNAME( 0x08, 0x08, DEF_STR( Unused ) )
962   PORT_DIPSETTING(    0x08, DEF_STR( Off ) )
963   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
964   PORT_DIPNAME( 0x30, 0x30, DEF_STR( Bonus_Life ) )
935   PORT_DIPNAME( 0x08, 0x08, DEF_STR( Unused ) )            PORT_DIPLOCATION("SW(B):4")
936   PORT_DIPSETTING(    0x08, DEF_STR( Off ) )               // Manual says this is 2c start/1c continue but it
937   PORT_DIPSETTING(    0x00, DEF_STR( On ) )               // doesn't work (see comment above)
938   PORT_DIPNAME( 0x30, 0x30, DEF_STR( Bonus_Life ) )         PORT_DIPLOCATION("SW(B):5,6")
965939   PORT_DIPSETTING(    0x30, "20K, 40K then every 60K" )
966940   PORT_DIPSETTING(    0x20, "30K, 50K then every 70K" )
967941   PORT_DIPSETTING(    0x10, "20K & 60K only" )
968942   PORT_DIPSETTING(    0x00, "30K & 60K only" )
969   PORT_DIPNAME( 0xc0, 0x80, "Internal Diff. on Life Loss" )      // Check code at 0x00d15a
970   PORT_DIPSETTING(    0xc0, "-3" )
971//  PORT_DIPSETTING(    0x40, "-1" )
943   PORT_DIPNAME( 0xc0, 0x80, "Internal Diff. on Life Loss" )   PORT_DIPLOCATION("SW(B):7,8")
944   PORT_DIPSETTING(    0xc0, "-3" )                     // Check code at 0x00d15a
945//  PORT_DIPSETTING(    0x40, "-1" )                            // These switches are not documented in the manual
972946   PORT_DIPSETTING(    0x00, "-1" )
973947   PORT_DIPSETTING(    0x80, "Default" )
974948
975949   PORT_START_TAG("DSWC")
976   PORT_DIPNAME( 0x03, 0x03, DEF_STR( Lives ) )
977   PORT_DIPSETTING(    0x00, "2" )                  // "6" in the "test mode"
950   PORT_DIPNAME( 0x03, 0x03, DEF_STR( Lives ) )            PORT_DIPLOCATION("SW(C):1,2")
951   PORT_DIPSETTING(    0x00, "2" )                        // "6" in the "test mode" and manual
978952   PORT_DIPSETTING(    0x03, "3" )
979953   PORT_DIPSETTING(    0x02, "4" )
980954   PORT_DIPSETTING(    0x01, "5" )
981   PORT_DIPNAME( 0x04, 0x04, "Freeze" )
955   PORT_DIPNAME( 0x04, 0x04, "Freeze" )                  PORT_DIPLOCATION("SW(C):3")
982956   PORT_DIPSETTING(    0x04, DEF_STR( Off ) )
983957   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
984   PORT_DIPNAME( 0x08, 0x08, DEF_STR( Free_Play ) )
958   PORT_DIPNAME( 0x08, 0x08, DEF_STR( Free_Play ) )         PORT_DIPLOCATION("SW(C):4")
985959   PORT_DIPSETTING(    0x08, DEF_STR( Off ) )
986960   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
987   PORT_DIPNAME( 0x10, 0x10, DEF_STR( Flip_Screen ) )
961   PORT_DIPNAME( 0x10, 0x10, DEF_STR( Flip_Screen ) )         PORT_DIPLOCATION("SW(C):5")
988962   PORT_DIPSETTING(    0x10, DEF_STR( Off ) )
989963   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
990   PORT_DIPNAME( 0x20, 0x20, DEF_STR( Demo_Sounds ) )
964   PORT_DIPNAME( 0x20, 0x20, DEF_STR( Demo_Sounds ) )         PORT_DIPLOCATION("SW(C):6")
991965   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
992966   PORT_DIPSETTING(    0x20, DEF_STR( On ) )
993   PORT_DIPNAME( 0x40, 0x40, DEF_STR( Allow_Continue ) )
967   PORT_DIPNAME( 0x40, 0x40, DEF_STR( Allow_Continue ) )      PORT_DIPLOCATION("SW(C):7")
994968   PORT_DIPSETTING(    0x00, DEF_STR( No ) )
995969   PORT_DIPSETTING(    0x40, DEF_STR( Yes ) )
996   PORT_DIPNAME( 0x80, 0x80, "Game Mode")
970   PORT_DIPNAME( 0x80, 0x80, "Game Mode")                  PORT_DIPLOCATION("SW(C):8")
997971   PORT_DIPSETTING(    0x80, "Game" )
998   PORT_DIPSETTING(    0x00, DEF_STR( Test ) )            // To enable the "debug" features
972   PORT_DIPSETTING(    0x00, DEF_STR( Test ) )               // To enable the "debug" features
999973
1000974   PORT_START_TAG("IN1")
1001975   PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_8WAY PORT_PLAYER(1)
r1293r1294
10301004   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
10311005
10321006   PORT_START_TAG("DSWA")
1033   CPS1_COINAGE_1
1034   PORT_DIPNAME( 0xc0, 0xc0, DEF_STR( Cabinet ) )
1035   PORT_DIPSETTING(    0xc0, "Upright 1 Player" )
1036   PORT_DIPSETTING(    0x80, "Upright 2 Players" )
1007   CPS1_COINAGE_1( "SW(A)" )
1008   PORT_DIPNAME( 0xc0, 0xc0, DEF_STR( Cabinet ) )               PORT_DIPLOCATION("SW(A):7,8")
1009   PORT_DIPSETTING(    0xc0, "Upright 1 Player" )               // These switches are not documented in the
1010   PORT_DIPSETTING(    0x80, "Upright 2 Players" )               // manual
10371011//  PORT_DIPSETTING(    0x40, DEF_STR( Cocktail ) )
10381012   PORT_DIPSETTING(    0x00, DEF_STR( Cocktail ) )
10391013
10401014   PORT_START_TAG("DSWB")
1041   CPS1_DIFFICULTY_2
1015   CPS1_DIFFICULTY_2( "SW(B)" )
10421016   /* In 'striderj', bit 3 is stored at 0xff8e77 ($e77,A5) via code at 0x000a2a,
10431017       but this address is never checked again.
10441018       In 'strider' and 'stridrja', this code even doesn't exist ! */
1045   PORT_DIPNAME( 0x08, 0x08, "2 Coins to Start, 1 to Continue" )
1046   PORT_DIPSETTING(    0x08, DEF_STR( Off ) )
1019   PORT_DIPNAME( 0x08, 0x08, "2 Coins to Start, 1 to Continue" )   PORT_DIPLOCATION("SW(B):4")
1020   PORT_DIPSETTING(    0x08, DEF_STR( Off ) )                  // This works in this revision
10471021   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
1048   PORT_DIPNAME( 0x30, 0x30, DEF_STR( Bonus_Life ) )
1022   PORT_DIPNAME( 0x30, 0x30, DEF_STR( Bonus_Life ) )            PORT_DIPLOCATION("SW(B):5,6")
10491023   PORT_DIPSETTING(    0x30, "20K, 40K then every 60K" )
10501024   PORT_DIPSETTING(    0x20, "30K, 50K then every 70K" )
10511025   PORT_DIPSETTING(    0x10, "20K & 60K only" )
10521026   PORT_DIPSETTING(    0x00, "30K & 60K only" )
1053   PORT_DIPNAME( 0xc0, 0x80, "Internal Diff. on Life Loss" )      // Check code at 0x00d15a
1054   PORT_DIPSETTING(    0xc0, "-3" )
1055//  PORT_DIPSETTING(    0x40, "-1" )
1056   PORT_DIPSETTING(    0x00, "-1" )
1027   PORT_DIPNAME( 0xc0, 0x80, "Internal Diff. on Life Loss" )      PORT_DIPLOCATION("SW(B):7,8")
1028   PORT_DIPSETTING(    0xc0, "-3" )                        // Check code at 0x00d15a
1029//  PORT_DIPSETTING(    0x40, "-1" )                                // These switches are not documented in the
1030   PORT_DIPSETTING(    0x00, "-1" )                        // manual
10571031   PORT_DIPSETTING(    0x80, "Default" )
10581032
10591033   PORT_START_TAG("DSWC")
1060   PORT_DIPNAME( 0x03, 0x03, DEF_STR( Lives ) )
1061   PORT_DIPSETTING(    0x00, "2" )                  // "6" in the "test mode"
1034   PORT_DIPNAME( 0x03, 0x03, DEF_STR( Lives ) )               PORT_DIPLOCATION("SW(C):1,2")
1035   PORT_DIPSETTING(    0x00, "2" )                           // "6" in the "test mode" and manual
10621036   PORT_DIPSETTING(    0x03, "3" )
10631037   PORT_DIPSETTING(    0x02, "4" )
10641038   PORT_DIPSETTING(    0x01, "5" )
1065   PORT_DIPNAME( 0x04, 0x04, "Freeze" )
1039   PORT_DIPNAME( 0x04, 0x04, "Freeze" )                     PORT_DIPLOCATION("SW(C):3")
10661040   PORT_DIPSETTING(    0x04, DEF_STR( Off ) )
10671041   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
1068   PORT_DIPNAME( 0x08, 0x08, DEF_STR( Free_Play ) )
1042   PORT_DIPNAME( 0x08, 0x08, DEF_STR( Free_Play ) )            PORT_DIPLOCATION("SW(C):4")
10691043   PORT_DIPSETTING(    0x08, DEF_STR( Off ) )
10701044   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
1071   PORT_DIPNAME( 0x10, 0x10, DEF_STR( Flip_Screen ) )
1045   PORT_DIPNAME( 0x10, 0x10, DEF_STR( Flip_Screen ) )            PORT_DIPLOCATION("SW(C):5")
10721046   PORT_DIPSETTING(    0x10, DEF_STR( Off ) )
10731047   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
1074   PORT_DIPNAME( 0x20, 0x20, DEF_STR( Demo_Sounds ) )
1048   PORT_DIPNAME( 0x20, 0x20, DEF_STR( Demo_Sounds ) )            PORT_DIPLOCATION("SW(C):6")
10751049   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
10761050   PORT_DIPSETTING(    0x20, DEF_STR( On ) )
1077   PORT_DIPNAME( 0x40, 0x40, DEF_STR( Allow_Continue ) )
1051   PORT_DIPNAME( 0x40, 0x40, DEF_STR( Allow_Continue ) )         PORT_DIPLOCATION("SW(C):7")
10781052   PORT_DIPSETTING(    0x00, DEF_STR( No ) )
10791053   PORT_DIPSETTING(    0x40, DEF_STR( Yes ) )
1080   PORT_DIPNAME( 0x80, 0x80, "Game Mode")
1054   PORT_DIPNAME( 0x80, 0x80, "Game Mode")                     PORT_DIPLOCATION("SW(C):8")
10811055   PORT_DIPSETTING(    0x80, "Game" )
1082   PORT_DIPSETTING(    0x00, DEF_STR( Test ) )            // To enable the "debug" features
1056   PORT_DIPSETTING(    0x00, DEF_STR( Test ) )                  // To enable the "debug" features
10831057
10841058   PORT_START_TAG("IN1")
10851059   PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_8WAY PORT_PLAYER(1)
r1293r1294
11121086   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
11131087
11141088   PORT_START_TAG("DSWC")
1115   PORT_DIPNAME( 0x80, 0x80, "Game Mode")
1116   PORT_DIPSETTING(    0x80, "Game" )
1117   PORT_DIPSETTING(    0x00, DEF_STR( Test ) )
1118   PORT_DIPNAME( 0x40, 0x40, DEF_STR( Allow_Continue ) )
1119   PORT_DIPSETTING(    0x00, DEF_STR( No ) )               // "ON"  in the "test mode"
1120   PORT_DIPSETTING(    0x40, DEF_STR( Yes ) )            // "OFF" in the "test mode"
1121   PORT_DIPNAME( 0x20, 0x20, DEF_STR( Demo_Sounds ) )
1122   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )            // "ON"  in the "test mode"
1123   PORT_DIPSETTING(    0x20, DEF_STR( On ) )               // "OFF" in the "test mode"
1124   PORT_DIPNAME( 0x10, 0x10, DEF_STR( Flip_Screen ) )
1089   PORT_DIPNAME( 0x01, 0x01, "Freeze" )                  PORT_DIPLOCATION("SW(C):1")
1090   PORT_DIPSETTING(    0x01, DEF_STR( Off ) )               // Also affects energy cost - read notes
1091   PORT_DIPSETTING(    0x00, DEF_STR( On ) )               // This switch is not documented in the manual
1092   PORT_DIPNAME( 0x02, 0x02, "Turbo Mode" )               PORT_DIPLOCATION("SW(C):2")
1093   PORT_DIPSETTING(    0x02, DEF_STR( Off ) )               // Also affects energy cost - read notes
1094   PORT_DIPSETTING(    0x00, DEF_STR( On ) )               // This switch is not documented in the manual
1095   PORT_DIPUNUSED_DIPLOC( 0x04, 0x04, "SW(C):3" )            // This switch is not documented in the manual
1096   PORT_DIPUNUSED_DIPLOC( 0x08, 0x08, "SW(C):4" )            // This switch is not documented in the manual
1097   PORT_DIPNAME( 0x10, 0x10, DEF_STR( Flip_Screen ) )         PORT_DIPLOCATION("SW(C):5")
11251098   PORT_DIPSETTING(    0x10, DEF_STR( Off ) )
11261099   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
1127   PORT_DIPNAME( 0x08, 0x08, DEF_STR( Unused ) )
1128   PORT_DIPSETTING(    0x08, DEF_STR( Off ) )
1129   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
1130   PORT_DIPNAME( 0x04, 0x04, DEF_STR( Unused ) )
1131   PORT_DIPSETTING(    0x04, DEF_STR( Off ) )
1132   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
1133   PORT_DIPNAME( 0x02, 0x02, "Turbo Mode" )               // Also affects energy cost - read notes
1134   PORT_DIPSETTING(    0x02, DEF_STR( Off ) )
1135   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
1136   PORT_DIPNAME( 0x01, 0x01, "Freeze" )               // Also affects energy cost - read notes
1137   PORT_DIPSETTING(    0x01, DEF_STR( Off ) )
1138   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
1100   PORT_DIPNAME( 0x20, 0x20, DEF_STR( Demo_Sounds ) )         PORT_DIPLOCATION("SW(C):6")
1101   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )               // "ON"  in the "test mode"
1102   PORT_DIPSETTING(    0x20, DEF_STR( On ) )               // "OFF" in the "test mode"
1103   PORT_DIPNAME( 0x40, 0x40, DEF_STR( Allow_Continue ) )      PORT_DIPLOCATION("SW(C):7")
1104   PORT_DIPSETTING(    0x00, DEF_STR( No ) )               // "ON"  in the "test mode"
1105   PORT_DIPSETTING(    0x40, DEF_STR( Yes ) )               // "OFF" in the "test mode"
1106   PORT_DIPNAME( 0x80, 0x80, "Game Mode")                  PORT_DIPLOCATION("SW(C):8")
1107   PORT_DIPSETTING(    0x80, "Game" )
1108   PORT_DIPSETTING(    0x00, DEF_STR( Test ) )
11391109
11401110   PORT_START_TAG("DSWB")
1141   PORT_DIPNAME( 0x80, 0x80, DEF_STR( Unused ) )
1142   PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
1143   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
1144   PORT_DIPNAME( 0x40, 0x40, DEF_STR( Unused ) )
1145   PORT_DIPSETTING(    0x40, DEF_STR( Off ) )
1146   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
1147   PORT_DIPNAME( 0x20, 0x20, DEF_STR( Unused ) )
1148   PORT_DIPSETTING(    0x20, DEF_STR( Off ) )
1149   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
1150   PORT_DIPNAME( 0x10, 0x10, DEF_STR( Unused ) )
1151   PORT_DIPSETTING(    0x10, DEF_STR( Off ) )
1152   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
1153   PORT_DIPNAME( 0x08, 0x08, DEF_STR( Unused ) )
1154   PORT_DIPSETTING(    0x08, DEF_STR( Off ) )
1155   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
1156   CPS1_DIFFICULTY_2
1111   CPS1_DIFFICULTY_2( "SW(B)" )
1112   PORT_DIPUNUSED_DIPLOC( 0x08, 0x08, "SW(B):4" )            // These five switches are not documented in the
1113   PORT_DIPUNUSED_DIPLOC( 0x10, 0x10, "SW(B):5" )            // manual
1114   PORT_DIPUNUSED_DIPLOC( 0x20, 0x20, "SW(B):6" )
1115   PORT_DIPUNUSED_DIPLOC( 0x40, 0x40, "SW(B):7" )
1116   PORT_DIPUNUSED_DIPLOC( 0x80, 0x80, "SW(B):8" )
11571117
11581118   PORT_START_TAG("DSWA")
1159   PORT_DIPNAME( 0x80, 0x80, DEF_STR( Free_Play ) )
1160   PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
1161   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
1162   PORT_DIPNAME( 0x40, 0x40, DEF_STR( Unused ) )
1163   PORT_DIPSETTING(    0x40, DEF_STR( Off ) )
1164   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
1165   /* According to the manual, ALL bits 0 to 5 must be ON to have
1119   /* According to the manual, ALL switches 1 to 6 must be ON to have
11661120       "2 Coins/1 Credit (1 to continue)" for both coin slots */
1167   CPS1_COINAGE_3
1121   CPS1_COINAGE_3( "SW(A)" )
1122   PORT_DIPUNUSED_DIPLOC( 0x40, 0x40, "SW(A):7" )            // This switch is not documented in the manual
1123   PORT_DIPNAME( 0x80, 0x80, DEF_STR( Free_Play ) )         PORT_DIPLOCATION("SW(A):8")
1124   PORT_DIPSETTING(    0x80, DEF_STR( Off ) )               // This switch is not documented in the manual
1125   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
11681126
11691127   PORT_START_TAG("IN1")
11701128   PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_8WAY PORT_PLAYER(1)
r1293r1294
11981156   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
11991157
12001158   PORT_START_TAG("DSWC")
1201   PORT_DIPNAME( 0x80, 0x80, "Game Mode")
1202   PORT_DIPSETTING(    0x80, "Game" )
1203   PORT_DIPSETTING(    0x00, DEF_STR( Test ) )            // To enable the "debug" features
1204   PORT_DIPNAME( 0x40, 0x40, DEF_STR( Allow_Continue ) )
1205   PORT_DIPSETTING(    0x00, DEF_STR( No ) )
1206   PORT_DIPSETTING(    0x40, DEF_STR( Yes ) )
1207   PORT_DIPNAME( 0x10, 0x10, DEF_STR( Flip_Screen ) )
1208   PORT_DIPSETTING(    0x10, DEF_STR( Off ) )
1209   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
12101159   /* Standard Dip Switches */
1211   PORT_DIPNAME( 0x20, 0x20, DEF_STR( Demo_Sounds ) )         PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x80)
1212   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )            PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x80)
1213   PORT_DIPSETTING(    0x20, DEF_STR( On ) )               PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x80)
1214   PORT_DIPNAME( 0x0c, 0x0c, "Vitality" )               PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x80)
1215   PORT_DIPSETTING(    0x00, "2" )                  PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x80)
1216   PORT_DIPSETTING(    0x0c, "3" )                  PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x80)
1217   PORT_DIPSETTING(    0x08, "4" )                  PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x80)
1218   PORT_DIPSETTING(    0x04, "5" )                  PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x80)
1219   PORT_DIPNAME( 0x03, 0x03, DEF_STR( Lives ) )            PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x80)
1220   PORT_DIPSETTING(    0x02, "1" )                  PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x80)
1221   PORT_DIPSETTING(    0x03, "2" )                  PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x80)
1222   PORT_DIPSETTING(    0x01, "3" )                  PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x80)
1223   PORT_DIPSETTING(    0x00, "4" )                  PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x80)
1160   PORT_DIPNAME( 0x03, 0x03, DEF_STR( Lives ) )            PORT_DIPLOCATION("SW(C):1,2")
1161                                                PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x80)
1162   PORT_DIPSETTING(    0x02, "1" )                        PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x80)
1163   PORT_DIPSETTING(    0x03, "2" )                        PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x80)
1164   PORT_DIPSETTING(    0x01, "3" )                        PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x80)
1165   PORT_DIPSETTING(    0x00, "4" )                        PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x80)
1166   PORT_DIPNAME( 0x0c, 0x0c, "Vitality" )                  PORT_DIPLOCATION("SW(C):3,4")
1167                                                PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x80)
1168   PORT_DIPSETTING(    0x00, "2" )                        PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x80)
1169   PORT_DIPSETTING(    0x0c, "3" )                        PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x80)
1170   PORT_DIPSETTING(    0x08, "4" )                        PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x80)
1171   PORT_DIPSETTING(    0x04, "5" )                        PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x80)
12241172   /* Debug Dip Switches */
1225   PORT_DIPNAME( 0x20, 0x20, "Display Debug Infos" )         PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x00)
1226   PORT_DIPSETTING(    0x20, DEF_STR( No ) )               PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x00)
1227   PORT_DIPSETTING(    0x00, DEF_STR( Yes ) )            PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x00)
1228   PORT_DIPNAME( 0x08, 0x08, "Invulnerability" )            PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x00)
1229   PORT_DIPSETTING(    0x08, DEF_STR( Off ) )            PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x00)
1173   PORT_DIPNAME( 0x01, 0x01, "Turbo Mode" )               PORT_DIPLOCATION("SW(C):1")
1174                                                PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x00)
1175   PORT_DIPSETTING(    0x01, DEF_STR( Off ) )               PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x00)
12301176   PORT_DIPSETTING(    0x00, DEF_STR( On ) )               PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x00)
1231   PORT_DIPNAME( 0x04, 0x04, "Slow Motion" )               PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x00)
1232   PORT_DIPSETTING(    0x04, DEF_STR( Off ) )            PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x00)
1177   PORT_DIPNAME( 0x02, 0x02, "Freeze" )                  PORT_DIPLOCATION("SW(C):2")
1178                                                PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x00)
1179   PORT_DIPSETTING(    0x02, DEF_STR( Off ) )               PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x00)
12331180   PORT_DIPSETTING(    0x00, DEF_STR( On ) )               PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x00)
1234   PORT_DIPNAME( 0x02, 0x02, "Freeze" )               PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x00)
1235   PORT_DIPSETTING(    0x02, DEF_STR( Off ) )            PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x00)
1181   PORT_DIPNAME( 0x04, 0x04, "Slow Motion" )               PORT_DIPLOCATION("SW(C):3")
1182                                                PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x00)
1183   PORT_DIPSETTING(    0x04, DEF_STR( Off ) )               PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x00)
12361184   PORT_DIPSETTING(    0x00, DEF_STR( On ) )               PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x00)
1237   PORT_DIPNAME( 0x01, 0x01, "Turbo Mode" )               PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x00)
1238   PORT_DIPSETTING(    0x01, DEF_STR( Off ) )            PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x00)
1185   PORT_DIPNAME( 0x08, 0x08, "Invulnerability" )            PORT_DIPLOCATION("SW(C):4")
1186                                                PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x00)
1187   PORT_DIPSETTING(    0x08, DEF_STR( Off ) )               PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x00)
12391188   PORT_DIPSETTING(    0x00, DEF_STR( On ) )               PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x00)
12401189
1190   PORT_DIPNAME( 0x10, 0x10, DEF_STR( Flip_Screen ) )         PORT_DIPLOCATION("SW(C):5")
1191   PORT_DIPSETTING(    0x10, DEF_STR( Off ) )
1192   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
1193
1194   /* Standard Dip Switches */
1195   PORT_DIPNAME( 0x20, 0x20, DEF_STR( Demo_Sounds ) )         PORT_DIPLOCATION("SW(C):6")
1196                                                PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x80)
1197   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )               PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x80)
1198   PORT_DIPSETTING(    0x20, DEF_STR( On ) )               PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x80)
1199   /* Debug Dip Switches */
1200   PORT_DIPNAME( 0x20, 0x20, "Display Debug Infos" )         PORT_DIPLOCATION("SW(C):6")
1201                                                PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x00)
1202   PORT_DIPSETTING(    0x20, DEF_STR( No ) )               PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x00)
1203   PORT_DIPSETTING(    0x00, DEF_STR( Yes ) )               PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x00)
1204
1205   PORT_DIPNAME( 0x40, 0x40, DEF_STR( Allow_Continue ) )      PORT_DIPLOCATION("SW(C):7")
1206   PORT_DIPSETTING(    0x00, DEF_STR( No ) )
1207   PORT_DIPSETTING(    0x40, DEF_STR( Yes ) )
1208   PORT_DIPNAME( 0x80, 0x80, "Game Mode")                  PORT_DIPLOCATION("SW(C):8")
1209   PORT_DIPSETTING(    0x80, "Game" )
1210   PORT_DIPSETTING(    0x00, DEF_STR( Test ) )               // To enable the "debug" features
1211
12411212   PORT_START_TAG("DSWB")
12421213   /* Standard Dip Switches */
1243   PORT_DIPNAME( 0x80, 0x80, "Stage Magic Continue" )         PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x80)
1244   PORT_DIPSETTING(    0x80, DEF_STR( Off ) )            PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x80)
1245   PORT_DIPSETTING(    0x00, DEF_STR( On ) )               PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x80)
1246   PORT_DIPNAME( 0x40, 0x40, DEF_STR( Unused ) )            PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x80)
1247   PORT_DIPSETTING(    0x40, DEF_STR( Off ) )            PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x80)
1248   PORT_DIPSETTING(    0x00, DEF_STR( On ) )               PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x80)
1249   PORT_DIPNAME( 0x20, 0x20, DEF_STR( Unused ) )            PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x80)
1250   PORT_DIPSETTING(    0x20, DEF_STR( Off ) )            PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x80)
1251   PORT_DIPSETTING(    0x00, DEF_STR( On ) )               PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x80)
1252   PORT_DIPNAME( 0x18, 0x18, "Nando Speed" )               PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x80)
1253   PORT_DIPSETTING(    0x10, "Slow" )                  PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x80)
1254   PORT_DIPSETTING(    0x18, DEF_STR( Normal ) )            PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x80)
1255   PORT_DIPSETTING(    0x08, "Fast" )                  PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x80)
1256   PORT_DIPSETTING(    0x00, "Very Fast" )               PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x80)
1257   PORT_DIPNAME( 0x07, 0x07, DEF_STR( Difficulty ) )         PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x80)
1214   PORT_DIPNAME( 0x07, 0x07, DEF_STR( Difficulty ) )         PORT_DIPLOCATION("SW(B):1,2,3")
1215                                                PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x80)
12581216   PORT_DIPSETTING(    0x04, "1 (Easiest)" )               PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x80)
1259   PORT_DIPSETTING(    0x05, "2" )                  PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x80)
1260   PORT_DIPSETTING(    0x06, "3" )                  PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x80)
1217   PORT_DIPSETTING(    0x05, "2" )                        PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x80)
1218   PORT_DIPSETTING(    0x06, "3" )                        PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x80)
12611219   PORT_DIPSETTING(    0x07, "4 (Normal)" )               PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x80)
1262   PORT_DIPSETTING(    0x03, "5" )                  PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x80)
1263   PORT_DIPSETTING(    0x02, "6" )                  PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x80)
1264   PORT_DIPSETTING(    0x01, "7" )                  PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x80)
1220   PORT_DIPSETTING(    0x03, "5" )                        PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x80)
1221   PORT_DIPSETTING(    0x02, "6" )                        PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x80)
1222   PORT_DIPSETTING(    0x01, "7" )                        PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x80)
12651223   PORT_DIPSETTING(    0x00, "8 (Hardest)" )               PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x80)
1224   PORT_DIPNAME( 0x18, 0x18, "Nando Speed" )               PORT_DIPLOCATION("SW(B):4,5")
1225                                                PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x80)
1226   PORT_DIPSETTING(    0x10, "Slow" )                     PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x80)
1227   PORT_DIPSETTING(    0x18, DEF_STR( Normal ) )            PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x80)
1228   PORT_DIPSETTING(    0x08, "Fast" )                     PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x80)
1229   PORT_DIPSETTING(    0x00, "Very Fast" )                  PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x80)
1230   PORT_DIPNAME( 0x20, 0x20, DEF_STR( Unused ) )            PORT_DIPLOCATION("SW(B):6")
1231                                                PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x80)
1232   PORT_DIPSETTING(    0x20, DEF_STR( Off ) )               PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x80)
1233   PORT_DIPSETTING(    0x00, DEF_STR( On ) )               PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x80)
1234   PORT_DIPNAME( 0x40, 0x40, DEF_STR( Unused ) )            PORT_DIPLOCATION("SW(B):7")
1235                                                PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x80)
1236   PORT_DIPSETTING(    0x40, DEF_STR( Off ) )               PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x80)
1237   PORT_DIPSETTING(    0x00, DEF_STR( On ) )               PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x80)
1238   PORT_DIPNAME( 0x80, 0x80, "Stage Magic Continue" )         PORT_DIPLOCATION("SW(B):8")
1239                                                PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x80)
1240   PORT_DIPSETTING(    0x80, DEF_STR( Off ) )               PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x80)
1241   PORT_DIPSETTING(    0x00, DEF_STR( On ) )               PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x80)
12661242   /* Debug Dip Switches */
1267   PORT_DIPNAME( 0xe0, 0xe0, "Starting Level" )            PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x00)
1268   PORT_DIPSETTING(    0xe0, "Level 1" )               PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x00)
1269   PORT_DIPSETTING(    0xc0, "Level 2" )               PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x00)
1270   PORT_DIPSETTING(    0xa0, "Level 3" )               PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x00)
1271   PORT_DIPSETTING(    0x80, "Level 4" )               PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x00)
1272   PORT_DIPSETTING(    0x60, "Level 5" )               PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x00)
1273   PORT_DIPSETTING(    0x40, "Level 6" )               PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x00)
1243   PORT_DIPNAME( 0x01, 0x01, DEF_STR( Unused ) )            PORT_DIPLOCATION("SW(B):1")
1244                                                PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x00)
1245   PORT_DIPSETTING(    0x01, DEF_STR( Off ) )               PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x00)
1246   PORT_DIPSETTING(    0x00, DEF_STR( On ) )               PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x00)
1247   PORT_DIPNAME( 0x1e, 0x1e, "Slow Motion Delay" )            PORT_DIPLOCATION("SW(B):2,3,4,5")
1248                                                PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x00)
1249   PORT_DIPSETTING(    0x1e, "2 Frames" )                  PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x00)
1250   PORT_DIPSETTING(    0x1c, "3 Frames" )                  PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x00)
1251   PORT_DIPSETTING(    0x1a, "4 Frames" )                  PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x00)
1252   PORT_DIPSETTING(    0x18, "5 Frames" )                  PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x00)
1253   PORT_DIPSETTING(    0x16, "6 Frames" )                  PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x00)
1254   PORT_DIPSETTING(    0x14, "7 Frames" )                  PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x00)
1255   PORT_DIPSETTING(    0x12, "8 Frames" )                  PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x00)
1256   PORT_DIPSETTING(    0x10, "9 Frames" )                  PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x00)
1257   PORT_DIPSETTING(    0x0e, "10 Frames" )                  PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x00)
1258   PORT_DIPSETTING(    0x0c, "11 Frames" )                  PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x00)
1259   PORT_DIPSETTING(    0x0a, "12 Frames" )                  PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x00)
1260   PORT_DIPSETTING(    0x08, "13 Frames" )                  PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x00)
1261   PORT_DIPSETTING(    0x06, "14 Frames" )                  PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x00)
1262   PORT_DIPSETTING(    0x04, "15 Frames" )                  PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x00)
1263   PORT_DIPSETTING(    0x02, "16 Frames" )                  PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x00)
1264   PORT_DIPSETTING(    0x00, "17 Frames" )                  PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x00)
1265   PORT_DIPNAME( 0xe0, 0xe0, "Starting Level" )            PORT_DIPLOCATION("SW(B):6,7,8")
1266                                                PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x00)
1267   PORT_DIPSETTING(    0xe0, "Level 1" )                  PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x00)
1268   PORT_DIPSETTING(    0xc0, "Level 2" )                  PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x00)
1269   PORT_DIPSETTING(    0xa0, "Level 3" )                  PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x00)
1270   PORT_DIPSETTING(    0x80, "Level 4" )                  PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x00)
1271   PORT_DIPSETTING(    0x60, "Level 5" )                  PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x00)
1272   PORT_DIPSETTING(    0x40, "Level 6" )                  PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x00)
12741273//  PORT_DIPSETTING(    0x20, "INVALID !" )                     PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x00)
12751274//  PORT_DIPSETTING(    0x00, "INVALID !" )                     PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x00)
1276   PORT_DIPNAME( 0x1e, 0x1e, "Slow Motion Delay" )            PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x00)
1277   PORT_DIPSETTING(    0x1e, "2 Frames" )               PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x00)
1278   PORT_DIPSETTING(    0x1c, "3 Frames" )               PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x00)
1279   PORT_DIPSETTING(    0x1a, "4 Frames" )               PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x00)
1280   PORT_DIPSETTING(    0x18, "5 Frames" )               PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x00)
1281   PORT_DIPSETTING(    0x16, "6 Frames" )               PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x00)
1282   PORT_DIPSETTING(    0x14, "7 Frames" )               PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x00)
1283   PORT_DIPSETTING(    0x12, "8 Frames" )               PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x00)
1284   PORT_DIPSETTING(    0x10, "9 Frames" )               PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x00)
1285   PORT_DIPSETTING(    0x0e, "10 Frames" )               PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x00)
1286   PORT_DIPSETTING(    0x0c, "11 Frames" )               PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x00)
1287   PORT_DIPSETTING(    0x0a, "12 Frames" )               PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x00)
1288   PORT_DIPSETTING(    0x08, "13 Frames" )               PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x00)
1289   PORT_DIPSETTING(    0x06, "14 Frames" )               PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x00)
1290   PORT_DIPSETTING(    0x04, "15 Frames" )               PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x00)
1291   PORT_DIPSETTING(    0x02, "16 Frames" )               PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x00)
1292   PORT_DIPSETTING(    0x00, "17 Frames" )               PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x00)
1293   PORT_DIPNAME( 0x01, 0x01, DEF_STR( Unused ) )            PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x00)
1294   PORT_DIPSETTING(    0x01, DEF_STR( Off ) )            PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x00)
1295   PORT_DIPSETTING(    0x00, DEF_STR( On ) )               PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x00)
12961275
12971276   PORT_START_TAG("DSWA")
12981277   /* Standard Dip Switches */
1299   PORT_DIPNAME( 0xc0, 0xc0, DEF_STR( Cabinet ) )            PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x80)
1300   PORT_DIPSETTING(    0xc0, "Upright 1 Player" )            PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x80)
1301   PORT_DIPSETTING(    0x80, "Upright 2 Players" )            PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x80)
1302//  PORT_DIPSETTING(    0x40, DEF_STR( Cocktail ) )             PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x80)
1303   PORT_DIPSETTING(    0x00, DEF_STR( Cocktail ) )            PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x80)
1304   PORT_DIPNAME( 0x07, 0x07, DEF_STR( Coin_A ) )            PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x80)
1278   PORT_DIPNAME( 0x07, 0x07, DEF_STR( Coin_A ) )            PORT_DIPLOCATION("SW(A):1,2,3")
1279                                                PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x80)
13051280   PORT_DIPSETTING(    0x01, DEF_STR( 4C_1C ) )            PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x80)
13061281   PORT_DIPSETTING(    0x02, DEF_STR( 3C_1C ) )            PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x80)
13071282   PORT_DIPSETTING(    0x03, DEF_STR( 2C_1C ) )            PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x80)
r1293r1294
13101285   PORT_DIPSETTING(    0x06, DEF_STR( 1C_2C ) )            PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x80)
13111286   PORT_DIPSETTING(    0x05, DEF_STR( 1C_3C ) )            PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x80)
13121287   PORT_DIPSETTING(    0x04, DEF_STR( 1C_4C ) )            PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x80)
1313   PORT_DIPNAME( 0x38, 0x38, DEF_STR( Coin_B ) )            PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x80)
1288   PORT_DIPNAME( 0x38, 0x38, DEF_STR( Coin_B ) )            PORT_DIPLOCATION("SW(A):4,5,6")
1289                                                PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x80)
13141290   PORT_DIPSETTING(    0x08, DEF_STR( 4C_1C ) )            PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x80)
13151291   PORT_DIPSETTING(    0x10, DEF_STR( 3C_1C ) )            PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x80)
13161292   PORT_DIPSETTING(    0x18, DEF_STR( 2C_1C ) )            PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x80)
r1293r1294
13191295   PORT_DIPSETTING(    0x30, DEF_STR( 1C_2C ) )            PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x80)
13201296   PORT_DIPSETTING(    0x28, DEF_STR( 1C_3C ) )            PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x80)
13211297   PORT_DIPSETTING(    0x20, DEF_STR( 1C_4C ) )            PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x80)
1298   PORT_DIPNAME( 0xc0, 0xc0, DEF_STR( Cabinet ) )            PORT_DIPLOCATION("SW(A):7,8")
1299                                                PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x80)
1300   PORT_DIPSETTING(    0xc0, "Upright 1 Player" )            PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x80)
1301   PORT_DIPSETTING(    0x80, "Upright 2 Players" )            PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x80)
1302//  PORT_DIPSETTING(    0x40, DEF_STR( Cocktail ) )             PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x80)
1303   PORT_DIPSETTING(    0x00, DEF_STR( Cocktail ) )            PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x80)
13221304   /* Debug Dip Switches */
1323   PORT_DIPNAME( 0x80, 0x80, "Maximum magic/sword power" )      PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x00)
1324   PORT_DIPSETTING(    0x80, DEF_STR( Off ) )            PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x00)
1325   PORT_DIPSETTING(    0x00, DEF_STR( On ) )               PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x00)
1326   PORT_DIPNAME( 0x40, 0x40, DEF_STR( Cabinet ) )            PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x00)
1327   PORT_DIPSETTING(    0x40, "Upright 1 Player" )            PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x00)
1328   PORT_DIPSETTING(    0x00, "Upright 2 Players" )            PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x00)
1329   PORT_DIPNAME( 0x3f, 0x3f, DEF_STR( Free_Play ) )         PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x00)
1330   PORT_DIPSETTING(    0x3f, DEF_STR( Off ) )            PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x00)
1305   PORT_DIPNAME( 0x3f, 0x3f, DEF_STR( Free_Play ) )         PORT_DIPLOCATION("SW(A):1,2,3,4,5,6")
1306                                                PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x00)
1307   PORT_DIPSETTING(    0x3f, DEF_STR( Off ) )               PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x00)
13311308   PORT_DIPSETTING(    0x38, DEF_STR( On ) )               PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x00)
13321309   /* Other values don't give free play */
1310   PORT_DIPNAME( 0x40, 0x40, DEF_STR( Cabinet ) )            PORT_DIPLOCATION("SW(A):7")
1311                                                PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x00)
1312   PORT_DIPSETTING(    0x40, "Upright 1 Player" )            PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x00)
1313   PORT_DIPSETTING(    0x00, "Upright 2 Players" )            PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x00)
1314   PORT_DIPNAME( 0x80, 0x80, "Maximum magic/sword power" )      PORT_DIPLOCATION("SW(A):8")
1315                                                PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x00)
1316   PORT_DIPSETTING(    0x80, DEF_STR( Off ) )               PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x00)
1317   PORT_DIPSETTING(    0x00, DEF_STR( On ) )               PORT_CONDITION("DSWC",0x80,PORTCOND_EQUALS,0x00)
13331318
13341319   PORT_START_TAG("IN1")
13351320   PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_8WAY PORT_PLAYER(1)
r1293r1294
13631348   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
13641349
13651350   PORT_START_TAG("DSWA")
1366   CPS1_COINAGE_3
1351   CPS1_COINAGE_3( "SW(A)" )
13671352   /* According to the manual, ALL bits 0 to 5 must be ON to have
13681353       "2 Coins/1 Credit (1 to continue)" for both coin slots */
1369   PORT_DIPNAME( 0x40, 0x40, DEF_STR( Unused ) )
1370   PORT_DIPSETTING(    0x40, DEF_STR( Off ) )
1371   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
1372   PORT_DIPNAME( 0x80, 0x80, DEF_STR( Unused ) )
1373   PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
1374   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
1354   PORT_DIPUNUSED_DIPLOC( 0x40, 0x40, "SW(A):7" )
1355   PORT_DIPUNUSED_DIPLOC( 0x80, 0x80, "SW(A):8" )
13751356
13761357   PORT_START_TAG("DSWB")
1377   CPS1_DIFFICULTY_1
1378   PORT_DIPNAME( 0x18, 0x18, "Damage" )            // Check code at 0x006f4e
1379   PORT_DIPSETTING(    0x10, "Small" )
1358   CPS1_DIFFICULTY_1( "SW(B)" )
1359   PORT_DIPNAME( 0x18, 0x18, "Damage" )               PORT_DIPLOCATION("SW(B):4,5")
1360   PORT_DIPSETTING(    0x10, "Small" )               // Check code at 0x006f4e
13801361   PORT_DIPSETTING(    0x18, DEF_STR( Normal ) )
13811362   PORT_DIPSETTING(    0x08, "Big" )
13821363   PORT_DIPSETTING(    0x00, "Biggest" )
1383   PORT_DIPNAME( 0x20, 0x20, DEF_STR( Unused ) )
1384   PORT_DIPSETTING(    0x20, DEF_STR( Off ) )
1385   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
1386   PORT_DIPNAME( 0x40, 0x40, DEF_STR( Unused ) )
1387   PORT_DIPSETTING(    0x40, DEF_STR( Off ) )
1388   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
1389   PORT_DIPNAME( 0x80, 0x80, DEF_STR( Unused ) )
1390   PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
1391   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
1364   PORT_DIPUNUSED_DIPLOC( 0x20, 0x20, "SW(B):6" )
1365   PORT_DIPUNUSED_DIPLOC( 0x40, 0x40, "SW(B):7" )
1366   PORT_DIPUNUSED_DIPLOC( 0x80, 0x80, "SW(B):8" )
13921367
13931368   PORT_START_TAG("DSWC")
1394   PORT_DIPNAME( 0x01, 0x01, DEF_STR( Unused ) )
1395   PORT_DIPSETTING(    0x01, DEF_STR( Off ) )
1396   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
1397   PORT_DIPNAME( 0x02, 0x02, DEF_STR( Unused ) )
1398   PORT_DIPSETTING(    0x02, DEF_STR( Off ) )
1399   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
1400   PORT_DIPNAME( 0x04, 0x04, DEF_STR( Free_Play ) )
1369   PORT_DIPUNUSED_DIPLOC( 0x01, 0x01, "SW(C):1" )
1370   PORT_DIPUNUSED_DIPLOC( 0x02, 0x02, "SW(C):2" )
1371   PORT_DIPNAME( 0x04, 0x04, DEF_STR( Free_Play ) )      PORT_DIPLOCATION("SW(C):3")
14011372   PORT_DIPSETTING(    0x04, DEF_STR( Off ) )
14021373   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
1403   PORT_DIPNAME( 0x08, 0x08, "Freeze" )
1374   PORT_DIPNAME( 0x08, 0x08, "Freeze" )               PORT_DIPLOCATION("SW(C):4")
14041375   PORT_DIPSETTING(    0x08, DEF_STR( Off ) )
14051376   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
1406   PORT_DIPNAME( 0x10, 0x10, DEF_STR( Flip_Screen ) )
1377   PORT_DIPNAME( 0x10, 0x10, DEF_STR( Flip_Screen ) )      PORT_DIPLOCATION("SW(C):5")
14071378   PORT_DIPSETTING(    0x10, DEF_STR( Off ) )
14081379   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
1409   PORT_DIPNAME( 0x20, 0x00, DEF_STR( Demo_Sounds ) )
1380   PORT_DIPNAME( 0x20, 0x00, DEF_STR( Demo_Sounds ) )      PORT_DIPLOCATION("SW(C):6")
14101381   PORT_DIPSETTING(    0x20, DEF_STR( Off ) )
14111382   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
1412   PORT_DIPNAME( 0x40, 0x00, DEF_STR( Allow_Continue ) )
1383   PORT_DIPNAME( 0x40, 0x00, DEF_STR( Allow_Continue ) )   PORT_DIPLOCATION("SW(C):7")
14131384   PORT_DIPSETTING(    0x40, DEF_STR( No ) )
14141385   PORT_DIPSETTING(    0x00, DEF_STR( Yes ) )
1415   PORT_DIPNAME( 0x80, 0x80, "Game Mode")
1386   PORT_DIPNAME( 0x80, 0x80, "Game Mode")               PORT_DIPLOCATION("SW(C):8")
14161387   PORT_DIPSETTING(    0x80, "Game" )
14171388   PORT_DIPSETTING(    0x00, DEF_STR( Test ) )
14181389
r1293r1294
14491420   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
14501421
14511422   PORT_START_TAG("DSWA")
1452   CPS1_COINAGE_1
1453   PORT_DIPNAME( 0x40, 0x40, "2 Coins to Start, 1 to Continue" )
1423   CPS1_COINAGE_1( "SW(A)" )
1424   PORT_DIPNAME( 0x40, 0x40, "2 Coins to Start, 1 to Continue" )   PORT_DIPLOCATION("SW(A):7")
14541425   PORT_DIPSETTING(    0x40, DEF_STR( Off ) )
14551426   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
1456   PORT_DIPNAME( 0x80, 0x80, DEF_STR( Unused ) )
1457   PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
1458   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
1427   PORT_DIPUNUSED_DIPLOC( 0x80, 0x80, "SW(A):8" )
14591428
14601429   PORT_START_TAG("DSWB")
1461   PORT_DIPNAME( 0x07, 0x04, "Difficulty Level 1" )
1430   PORT_DIPNAME( 0x07, 0x04, "Difficulty Level 1" )            PORT_DIPLOCATION("SW(B):1,2,3")
14621431   PORT_DIPSETTING(    0x07, DEF_STR( Easiest ) )      // "01"
14631432   PORT_DIPSETTING(    0x06, DEF_STR( Easier ) )      // "02"
1464   PORT_DIPSETTING(    0x05, DEF_STR( Easy ) )      // "03"
1433   PORT_DIPSETTING(    0x05, DEF_STR( Easy ) )         // "03"
14651434   PORT_DIPSETTING(    0x04, DEF_STR( Normal ) )      // "04"
14661435   PORT_DIPSETTING(    0x03, DEF_STR( Medium ) )      // "05"
1467   PORT_DIPSETTING(    0x02, DEF_STR( Hard ) )      // "06"
1436   PORT_DIPSETTING(    0x02, DEF_STR( Hard ) )         // "06"
14681437   PORT_DIPSETTING(    0x01, DEF_STR( Harder ) )      // "07"
14691438   PORT_DIPSETTING(    0x00, DEF_STR( Hardest ) )      // "08"
1470   PORT_DIPNAME( 0x18, 0x10, "Difficulty Level 2" )
1471   PORT_DIPSETTING(    0x18, DEF_STR( Easy ) )      // "01"
1439   PORT_DIPNAME( 0x18, 0x10, "Difficulty Level 2" )            PORT_DIPLOCATION("SW(B):4,5")
1440   PORT_DIPSETTING(    0x18, DEF_STR( Easy ) )         // "01"
14721441   PORT_DIPSETTING(    0x10, DEF_STR( Normal ) )      // "02"
1473   PORT_DIPSETTING(    0x08, DEF_STR( Hard ) )      // "03"
1442   PORT_DIPSETTING(    0x08, DEF_STR( Hard ) )         // "03"
14741443   PORT_DIPSETTING(    0x00, DEF_STR( Hardest ) )      // "04"
1475   PORT_DIPNAME( 0x60, 0x60, DEF_STR( Bonus_Life ) )
1444   PORT_DIPNAME( 0x60, 0x60, DEF_STR( Bonus_Life ) )            PORT_DIPLOCATION("SW(B):6,7")
14761445   PORT_DIPSETTING(    0x60, "100k" )
14771446   PORT_DIPSETTING(    0x40, "200k" )
14781447   PORT_DIPSETTING(    0x20, "100k and every 200k" )
14791448   PORT_DIPSETTING(    0x00, DEF_STR( None ) )
1480   PORT_DIPNAME( 0x80, 0x80, DEF_STR( Unused ) )
1481   PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
1482   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
1449   PORT_DIPUNUSED_DIPLOC( 0x80, 0x80, "SW(B):8" )
14831450
14841451   PORT_START_TAG("DSWC")
1485   PORT_DIPNAME( 0x03, 0x03, DEF_STR( Lives ) )
1452   PORT_DIPNAME( 0x03, 0x03, DEF_STR( Lives ) )               PORT_DIPLOCATION("SW(C):1,2")
14861453   PORT_DIPSETTING(    0x00, "1" )
14871454   PORT_DIPSETTING(    0x03, "2" )
14881455   PORT_DIPSETTING(    0x02, "3" )
14891456   PORT_DIPSETTING(    0x01, "4" )
1490   PORT_DIPNAME( 0x04, 0x04, DEF_STR( Free_Play ) )
1457   PORT_DIPNAME( 0x04, 0x04, DEF_STR( Free_Play ) )            PORT_DIPLOCATION("SW(C):3")
14911458   PORT_DIPSETTING(    0x04, DEF_STR( Off ) )
14921459   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
1493   PORT_DIPNAME( 0x08, 0x08, "Freeze" )
1460   PORT_DIPNAME( 0x08, 0x08, "Freeze" )                     PORT_DIPLOCATION("SW(C):4")
14941461   PORT_DIPSETTING(    0x08, DEF_STR( Off ) )
14951462   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
1496   PORT_DIPNAME( 0x10, 0x10, DEF_STR( Flip_Screen ) )
1463   PORT_DIPNAME( 0x10, 0x10, DEF_STR( Flip_Screen ) )            PORT_DIPLOCATION("SW(C):5")
14971464   PORT_DIPSETTING(    0x10, DEF_STR( Off ) )
14981465   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
1499   PORT_DIPNAME( 0x20, 0x00, DEF_STR( Demo_Sounds ) )
1466   PORT_DIPNAME( 0x20, 0x00, DEF_STR( Demo_Sounds ) )            PORT_DIPLOCATION("SW(C):6")
15001467   PORT_DIPSETTING(    0x20, DEF_STR( Off ) )
15011468   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
1502   PORT_DIPNAME( 0x40, 0x00, DEF_STR( Allow_Continue ) )
1469   PORT_DIPNAME( 0x40, 0x00, DEF_STR( Allow_Continue ) )         PORT_DIPLOCATION("SW(C):7")
15031470   PORT_DIPSETTING(    0x40, DEF_STR( No ) )
15041471   PORT_DIPSETTING(    0x00, DEF_STR( Yes ) )
1505   PORT_DIPNAME( 0x80, 0x80, "Game Mode")
1472   PORT_DIPNAME( 0x80, 0x80, "Game Mode")                     PORT_DIPLOCATION("SW(C):8")
15061473   PORT_DIPSETTING(    0x80, "Game" )
15071474   PORT_DIPSETTING(    0x00, DEF_STR( Test ) )
15081475
r1293r1294
15371504   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
15381505
15391506   PORT_START_TAG("DSWA")
1540   CPS1_COINAGE_1
1541   PORT_DIPNAME( 0x40, 0x40, "2 Coins to Start, 1 to Continue" )
1507   CPS1_COINAGE_1( "SW(A)" )
1508   PORT_DIPNAME( 0x40, 0x40, "2 Coins to Start, 1 to Continue" )   PORT_DIPLOCATION("SW(A):7")
15421509   PORT_DIPSETTING(    0x40, DEF_STR( Off ) )
15431510   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
1544   PORT_DIPNAME( 0x80, 0x80, DEF_STR( Unused ) )
1545   PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
1546   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
1511   PORT_DIPUNUSED_DIPLOC( 0x80, 0x80, "SW(A):8" )
15471512
15481513   PORT_START_TAG("DSWB")
1549   CPS1_DIFFICULTY_1
1550   PORT_DIPNAME( 0x18, 0x18, "Level Up Timer" )
1514   CPS1_DIFFICULTY_1( "SW(B)" )
1515   PORT_DIPNAME( 0x18, 0x18, "Level Up Timer" )               PORT_DIPLOCATION("SW(B):4,5")
15511516   PORT_DIPSETTING(    0x18, "More Slowly" )
15521517   PORT_DIPSETTING(    0x10, "Slowly" )
15531518   PORT_DIPSETTING(    0x08, "Quickly" )
15541519   PORT_DIPSETTING(    0x00, "More Quickly" )
1555   PORT_DIPNAME( 0x60, 0x60, "Bullet's Speed" )
1520   PORT_DIPNAME( 0x60, 0x60, "Bullet's Speed" )               PORT_DIPLOCATION("SW(B):6,7")
15561521   PORT_DIPSETTING(    0x60, "Very Slow" )
15571522   PORT_DIPSETTING(    0x40, "Slow" )
15581523   PORT_DIPSETTING(    0x20, "Fast" )
15591524   PORT_DIPSETTING(    0x00, "Very Fast" )
1560   PORT_DIPNAME( 0x80, 0x80, "Initial Vitality" )
1525   PORT_DIPNAME( 0x80, 0x80, "Initial Vitality" )               PORT_DIPLOCATION("SW(B):8")
15611526   PORT_DIPSETTING(    0x80, "3 Bars" )
15621527   PORT_DIPSETTING(    0x00, "4 Bars" )
15631528
15641529   PORT_START_TAG("DSWC")
1565   PORT_DIPNAME( 0x01, 0x01, "Throttle Game Speed" )    // turning this off will break the game
1566   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
1530   PORT_DIPNAME( 0x01, 0x01, "Throttle Game Speed" )            PORT_DIPLOCATION("SW(C):1")
1531   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )                  // turning this off will break the game
15671532   PORT_DIPSETTING(    0x01, DEF_STR( On ) )
1568   PORT_DIPNAME( 0x02, 0x02, DEF_STR( Unused ) )
1569   PORT_DIPSETTING(    0x02, DEF_STR( Off ) )
1570   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
1571   PORT_DIPNAME( 0x04, 0x04, DEF_STR( Free_Play ) )
1533   PORT_DIPUNUSED_DIPLOC( 0x02, 0x02, "SW(C):2" )
1534   PORT_DIPNAME( 0x04, 0x04, DEF_STR( Free_Play ) )            PORT_DIPLOCATION("SW(C):3")
15721535   PORT_DIPSETTING(    0x04, DEF_STR( Off ) )
15731536   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
1574   PORT_DIPNAME( 0x08, 0x08, "Freeze" )
1537   PORT_DIPNAME( 0x08, 0x08, "Freeze" )                     PORT_DIPLOCATION("SW(C):4")
15751538   PORT_DIPSETTING(    0x08, DEF_STR( Off ) )
15761539   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
1577   PORT_DIPNAME( 0x10, 0x10, DEF_STR( Flip_Screen ) )
1540   PORT_DIPNAME( 0x10, 0x10, DEF_STR( Flip_Screen ) )            PORT_DIPLOCATION("SW(C):5")
15781541   PORT_DIPSETTING(    0x10, DEF_STR( Off ) )
15791542   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
1580   PORT_DIPNAME( 0x20, 0x00, DEF_STR( Demo_Sounds ) )
1543   PORT_DIPNAME( 0x20, 0x00, DEF_STR( Demo_Sounds ) )            PORT_DIPLOCATION("SW(C):6")
15811544   PORT_DIPSETTING(    0x20, DEF_STR( Off ) )
15821545   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
1583   PORT_DIPNAME( 0x40, 0x00, DEF_STR( Allow_Continue ) )
1546   PORT_DIPNAME( 0x40, 0x00, DEF_STR( Allow_Continue ) )         PORT_DIPLOCATION("SW(C):7")
15841547   PORT_DIPSETTING(    0x40, DEF_STR( No ) )
15851548   PORT_DIPSETTING(    0x00, DEF_STR( Yes ) )
1586   PORT_DIPNAME( 0x80, 0x80, "Game Mode")
1549   PORT_DIPNAME( 0x80, 0x80, "Game Mode")                     PORT_DIPLOCATION("SW(C):8")
15871550   PORT_DIPSETTING(    0x80, "Game" )
15881551   PORT_DIPSETTING(    0x00, DEF_STR( Test ) )
15891552
r1293r1294
16181581   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
16191582
16201583   PORT_START_TAG("DSWA")
1621   CPS1_COINAGE_2
1622   PORT_DIPNAME( 0x08, 0x08, DEF_STR( Unused ) )
1623   PORT_DIPSETTING(    0x08, DEF_STR( Off ) )
1624   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
1625   PORT_DIPNAME( 0x10, 0x10, DEF_STR( Unused ) )
1626   PORT_DIPSETTING(    0x10, DEF_STR( Off ) )
1627   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
1628   PORT_DIPNAME( 0x20, 0x20, DEF_STR( Unused ) )
1629   PORT_DIPSETTING(    0x20, DEF_STR( Off ) )
1630   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
1631   PORT_DIPNAME( 0x40, 0x40, "2 Coins to Start, 1 to Continue" )
1584   CPS1_COINAGE_2( "SW(A)" )
1585   PORT_DIPUNUSED_DIPLOC( 0x08, 0x08, "SW(A):4" )               // These three switches are not documented in
1586   PORT_DIPUNUSED_DIPLOC( 0x10, 0x10, "SW(A):5" )               // the manual
1587   PORT_DIPUNUSED_DIPLOC( 0x20, 0x20, "SW(A):6" )
1588   PORT_DIPNAME( 0x40, 0x40, "2 Coins to Start, 1 to Continue" )   PORT_DIPLOCATION("SW(A):7")
16321589   PORT_DIPSETTING(    0x40, DEF_STR( Off ) )
16331590   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
1634   PORT_DIPNAME( 0x80, 0x80, DEF_STR( Unused ) )
1635   PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
1636   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
1591   PORT_DIPUNUSED_DIPLOC( 0x80, 0x80, "SW(A):8" )               // This switch is not documented in the manual
16371592
16381593   PORT_START_TAG("DSWB")
1639   CPS1_DIFFICULTY_1
1640   PORT_DIPNAME( 0x08, 0x08, "Coin Slots" )
1594   CPS1_DIFFICULTY_1( "SW(B)" )
1595   PORT_DIPNAME( 0x08, 0x08, "Coin Slots" )                  PORT_DIPLOCATION("SW(B):4")
16411596   PORT_DIPSETTING(    0x00, "1" )
1642   PORT_DIPSETTING(    0x08, "3" )
1643   PORT_DIPNAME( 0x10, 0x10, "Play Mode" )
1597   PORT_DIPSETTING(    0x08, "3" )                           // This setting can't be used in two-player mode
1598   PORT_DIPNAME( 0x10, 0x10, "Play Mode" )                     PORT_DIPLOCATION("SW(B):5")
16441599   PORT_DIPSETTING(    0x00, "2 Players" )
16451600   PORT_DIPSETTING(    0x10, "3 Players" )
1646   PORT_DIPNAME( 0x20, 0x20, DEF_STR( Unused ) )
1647   PORT_DIPSETTING(    0x20, DEF_STR( Off ) )
1648   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
1649   PORT_DIPNAME( 0x40, 0x40, DEF_STR( Unused ) )
1650   PORT_DIPSETTING(    0x40, DEF_STR( Off ) )
1651   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
1652   PORT_DIPNAME( 0x80, 0x80, DEF_STR( Unused ) )
1653   PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
1654   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
1601   PORT_DIPUNUSED_DIPLOC( 0x20, 0x20, "SW(B):6" )               // These three switches are not documented in
1602   PORT_DIPUNUSED_DIPLOC( 0x40, 0x40, "SW(B):7" )               // the manual
1603   PORT_DIPUNUSED_DIPLOC( 0x80, 0x80, "SW(B):8" )
16551604
16561605   PORT_START_TAG("DSWC")
1657   PORT_DIPNAME( 0x01, 0x01, DEF_STR( Unused ) )
1658   PORT_DIPSETTING(    0x01, DEF_STR( Off ) )
1659   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
1660   PORT_DIPNAME( 0x02, 0x02, DEF_STR( Unused ) )
1661   PORT_DIPSETTING(    0x02, DEF_STR( Off ) )
1662   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
1663   PORT_DIPNAME( 0x04, 0x04, DEF_STR( Unused ) )
1664   PORT_DIPSETTING(    0x04, DEF_STR( Off ) )
1665   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
1666   PORT_DIPNAME( 0x08, 0x08, "Freeze" )
1606   PORT_DIPUNUSED_DIPLOC( 0x01, 0x01, "SW(C):1" )               // These three switches are not documented in
1607   PORT_DIPUNUSED_DIPLOC( 0x02, 0x02, "SW(C):2" )               // the manual
1608   PORT_DIPUNUSED_DIPLOC( 0x04, 0x04, "SW(C):3" )
1609   PORT_DIPNAME( 0x08, 0x08, "Freeze" )                     PORT_DIPLOCATION("SW(C):4")
16671610   PORT_DIPSETTING(    0x08, DEF_STR( Off ) )
16681611   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
1669   PORT_DIPNAME( 0x10, 0x10, DEF_STR( Flip_Screen ) )
1612   PORT_DIPNAME( 0x10, 0x10, DEF_STR( Flip_Screen ) )            PORT_DIPLOCATION("SW(C):5")
16701613   PORT_DIPSETTING(    0x10, DEF_STR( Off ) )
16711614   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
1672   PORT_DIPNAME( 0x20, 0x00, DEF_STR( Demo_Sounds ) )
1615   PORT_DIPNAME( 0x20, 0x00, DEF_STR( Demo_Sounds ) )            PORT_DIPLOCATION("SW(C):6")
16731616   PORT_DIPSETTING(    0x20, DEF_STR( Off ) )
16741617   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
1675   PORT_DIPNAME( 0x40, 0x00, DEF_STR( Allow_Continue ) )
1618   PORT_DIPNAME( 0x40, 0x00, DEF_STR( Allow_Continue ) )         PORT_DIPLOCATION("SW(C):7")
16761619   PORT_DIPSETTING(    0x40, DEF_STR( No ) )
16771620   PORT_DIPSETTING(    0x00, DEF_STR( Yes ) )
1678   PORT_SERVICE( 0x80, IP_ACTIVE_LOW )
1621   PORT_SERVICE_DIPLOC( 0x80, IP_ACTIVE_LOW, "SW(C):8" )
16791622
16801623   PORT_START_TAG("IN1")
16811624   PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_8WAY PORT_PLAYER(1)
r1293r1294
17311674   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
17321675
17331676   PORT_START_TAG("DSWA")
1734   CPS1_COINAGE_1
1735   PORT_DIPNAME( 0x40, 0x40, DEF_STR( Unused ) )
1736   PORT_DIPSETTING(    0x40, DEF_STR( Off ) )
1737   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
1738   PORT_DIPNAME( 0x80, 0x80, DEF_STR( Unused ) )
1739   PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
1740   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
1677   CPS1_COINAGE_1( "SW(A)" )
1678   PORT_DIPUNUSED_DIPLOC( 0x40, 0x40, "SW(A):7" )
1679   PORT_DIPUNUSED_DIPLOC( 0x80, 0x80, "SW(A):8" )
17411680
17421681   PORT_START_TAG("DSWB")
1743   CPS1_DIFFICULTY_1
1744   PORT_DIPNAME( 0x38, 0x18, DEF_STR( Lives ) )
1745//  PORT_DIPSETTING(    0x30, "1" )                 // 0x38 energy, smallest damage
1746//  PORT_DIPSETTING(    0x38, "1" )                 // 0x38 energy, small damage
1747//  PORT_DIPSETTING(    0x28, "1" )                 // 0x38 energy, big damage
1748//  PORT_DIPSETTING(    0x20, "1" )                 // 0x38 energy, biggest damage
1749   PORT_DIPSETTING(    0x10, "1" )               // 0x20 energy, smallest damage
1750   PORT_DIPSETTING(    0x18, "2" )               // 0x20 energy, small damage
1751   PORT_DIPSETTING(    0x08, "3" )               // 0x20 energy, big damage
1752   PORT_DIPSETTING(    0x00, "4" )               // 0x20 energy, biggest damage
1753   PORT_DIPNAME( 0x40, 0x40, DEF_STR( Unused ) )
1754   PORT_DIPSETTING(    0x40, DEF_STR( Off ) )
1755   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
1756   PORT_DIPNAME( 0x80, 0x80, DEF_STR( Unused ) )
1757   PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
1758   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
1682   CPS1_DIFFICULTY_1( "SW(B)" )
1683   PORT_DIPNAME( 0x38, 0x18, DEF_STR( Lives ) )         PORT_DIPLOCATION("SW(B):4,5,6")
1684//  PORT_DIPSETTING(    0x30, "1" )                         // 0x38 energy, smallest damage
1685//  PORT_DIPSETTING(    0x38, "1" )                         // 0x38 energy, small damage
1686//  PORT_DIPSETTING(    0x28, "1" )                         // 0x38 energy, big damage
1687//  PORT_DIPSETTING(    0x20, "1" )                         // 0x38 energy, biggest damage
1688   PORT_DIPSETTING(    0x10, "1" )                     // 0x20 energy, smallest damage
1689   PORT_DIPSETTING(    0x18, "2" )                     // 0x20 energy, small damage
1690   PORT_DIPSETTING(    0x08, "3" )                     // 0x20 energy, big damage
1691   PORT_DIPSETTING(    0x00, "4" )                     // 0x20 energy, biggest damage
1692   PORT_DIPUNUSED_DIPLOC( 0x40, 0x40, "SW(B):7" )
1693   PORT_DIPUNUSED_DIPLOC( 0x80, 0x80, "SW(B):8" )
17591694
17601695   PORT_START_TAG("DSWC")
1761   PORT_DIPNAME( 0x01, 0x01, DEF_STR( Unused ) )
1762   PORT_DIPSETTING(    0x01, DEF_STR( Off ) )
1763   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
1764   PORT_DIPNAME( 0x02, 0x02, DEF_STR( Unused ) )
1765   PORT_DIPSETTING(    0x02, DEF_STR( Off ) )
1766   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
1767   PORT_DIPNAME( 0x04, 0x04, DEF_STR( Free_Play ) )
1696   PORT_DIPUNUSED_DIPLOC( 0x01, 0x01, "SW(C):1" )
1697   PORT_DIPUNUSED_DIPLOC( 0x02, 0x02, "SW(C):2" )
1698   PORT_DIPNAME( 0x04, 0x04, DEF_STR( Free_Play ) )      PORT_DIPLOCATION("SW(C):3")
17681699   PORT_DIPSETTING(    0x04, DEF_STR( Off ) )
17691700   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
1770   PORT_DIPNAME( 0x08, 0x08, "Freeze" )
1701   PORT_DIPNAME( 0x08, 0x08, "Freeze" )               PORT_DIPLOCATION("SW(C):4")
17711702   PORT_DIPSETTING(    0x08, DEF_STR( Off ) )
17721703   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
1773   PORT_DIPNAME( 0x10, 0x10, DEF_STR( Flip_Screen ) )
1704   PORT_DIPNAME( 0x10, 0x10, DEF_STR( Flip_Screen ) )      PORT_DIPLOCATION("SW(C):5")
17741705   PORT_DIPSETTING(    0x10, DEF_STR( Off ) )
17751706   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
1776   PORT_DIPNAME( 0x20, 0x00, DEF_STR( Demo_Sounds ) )
1707   PORT_DIPNAME( 0x20, 0x00, DEF_STR( Demo_Sounds ) )      PORT_DIPLOCATION("SW(C):6")
17771708   PORT_DIPSETTING(    0x20, DEF_STR( Off ) )
17781709   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
1779   PORT_DIPNAME( 0x40, 0x00, DEF_STR( Allow_Continue ) )
1710   PORT_DIPNAME( 0x40, 0x00, DEF_STR( Allow_Continue ) )   PORT_DIPLOCATION("SW(C):7")
17801711   PORT_DIPSETTING(    0x40, DEF_STR( No ) )
17811712   PORT_DIPSETTING(    0x00, DEF_STR( Yes ) )
1782   PORT_DIPNAME( 0x80, 0x80, "Game Mode")
1713   PORT_DIPNAME( 0x80, 0x80, "Game Mode")               PORT_DIPLOCATION("SW(C):8")
17831714   PORT_DIPSETTING(    0x80, "Game" )
17841715   PORT_DIPSETTING(    0x00, DEF_STR( Test ) )
17851716
r1293r1294
18021733   PORT_BIT( 0x8000, IP_ACTIVE_LOW, IPT_UNKNOWN )
18031734INPUT_PORTS_END
18041735
1805/* I guess that bit 7 of DSWB was used for debug purpose :
1736/* I guess that bit 8 of DSWB was used for debug purpose :
18061737     - code at 0x001094 : move players during "attract mode"
18071738     - code at 0x019b62 ('msword' and 'mswordr1'), 0x019bde ('mswordu') or 0x019c26 ('mswordj') : unknown effect
18081739     - code at 0x01c322 ('msword' and 'mswordr1'), 0x01c39e ('mswordu') or 0x01c3e0 ('mswordj') : unknown effect
r1293r1294
18191750   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
18201751
18211752   PORT_START_TAG("DSWA")
1822   CPS1_COINAGE_1
1823   PORT_DIPNAME( 0x40, 0x40, "2 Coins to Start, 1 to Continue" )
1753   CPS1_COINAGE_1( "SW(A)" )
1754   PORT_DIPNAME( 0x40, 0x40, "2 Coins to Start, 1 to Continue" )      PORT_DIPLOCATION("SW(A):7")
18241755   PORT_DIPSETTING(    0x40, DEF_STR( Off ) )
18251756   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
1826   PORT_DIPNAME( 0x80, 0x80, DEF_STR( Unused ) )
1827   PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
1828   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
1757   PORT_DIPUNUSED_DIPLOC( 0x80, 0x80, "SW(A):8" )
18291758
18301759   PORT_START_TAG("DSWB")
1831   PORT_DIPNAME( 0x07, 0x04, "Player's vitality consumption" )      // "Level 1"
1832   PORT_DIPSETTING(    0x07, "1 (Easiest)" )               // "Easy 3"     (-1 every 28 frames)
1833   PORT_DIPSETTING(    0x06, "2" )                  // "Easy 2"     (-1 every 24 frames)
1834   PORT_DIPSETTING(    0x05, "3" )                  // "Easy 1"     (-1 every 20 frames)
1835   PORT_DIPSETTING(    0x04, "4 (Normal)" )               // DEF_STR( Normal )        (-1 every 18 frames)
1836   PORT_DIPSETTING(    0x03, "5" )                  // "Difficult 1"    (-1 every 16 frames)
1837   PORT_DIPSETTING(    0x02, "6" )                  // "Difficult 2"    (-1 every 14 frames)
1838   PORT_DIPSETTING(    0x01, "7" )                  // "Difficult 3"    (-1 every 12 frames)
1839   PORT_DIPSETTING(    0x00, "8 (Hardest)" )               // "Difficult 4"    (-1 every 8 frames)
1840   PORT_DIPNAME( 0x38, 0x38, "Enemy's vitality and attacking power" )// "Level 2"
1760   PORT_DIPNAME( 0x07, 0x04, "Player's vitality consumption" )         PORT_DIPLOCATION("SW(B):1,2,3")   // "Level 1"
1761   PORT_DIPSETTING(    0x07, "1 (Easiest)" )               // "Easy 3"             (-1 every 28 frames)
1762   PORT_DIPSETTING(    0x06, "2" )                        // "Easy 2"             (-1 every 24 frames)
1763   PORT_DIPSETTING(    0x05, "3" )                        // "Easy 1"             (-1 every 20 frames)
1764   PORT_DIPSETTING(    0x04, "4 (Normal)" )               // DEF_STR( Normal )    (-1 every 18 frames)
1765   PORT_DIPSETTING(    0x03, "5" )                        // "Difficult 1"        (-1 every 16 frames)
1766   PORT_DIPSETTING(    0x02, "6" )                        // "Difficult 2"        (-1 every 14 frames)
1767   PORT_DIPSETTING(    0x01, "7" )                        // "Difficult 3"        (-1 every 12 frames)
1768   PORT_DIPSETTING(    0x00, "8 (Hardest)" )               // "Difficult 4"        (-1 every 8 frames)
1769   PORT_DIPNAME( 0x38, 0x38, "Enemy's vitality and attacking power" )   PORT_DIPLOCATION("SW(B):4,5,6") // "Level 2"
18411770   PORT_DIPSETTING(    0x20, "1 (Easiest)" )               // "Easy 3"
1842   PORT_DIPSETTING(    0x28, "2" )                  // "Easy 2"
1843   PORT_DIPSETTING(    0x30, "3" )                  // "Easy 1"
1771   PORT_DIPSETTING(    0x28, "2" )                        // "Easy 2"
1772   PORT_DIPSETTING(    0x30, "3" )                        // "Easy 1"
18441773   PORT_DIPSETTING(    0x38, "4 (Normal)" )               // DEF_STR( Normal )
1845   PORT_DIPSETTING(    0x18, "5" )                  // "Difficult 1"
1846   PORT_DIPSETTING(    0x10, "6" )                  // "Difficult 2"
1847   PORT_DIPSETTING(    0x08, "7" )                  // "Difficult 3"
1774   PORT_DIPSETTING(    0x18, "5" )                        // "Difficult 1"
1775   PORT_DIPSETTING(    0x10, "6" )                        // "Difficult 2"
1776   PORT_DIPSETTING(    0x08, "7" )                        // "Difficult 3"
18481777   PORT_DIPSETTING(    0x00, "8 (Hardest)" )               // "Difficult 4"
1849   PORT_DIPNAME( 0x40, 0x00, "Stage Select" )
1778   PORT_DIPNAME( 0x40, 0x00, "Stage Select" )                     PORT_DIPLOCATION("SW(B):7")
18501779   PORT_DIPSETTING(    0x40, DEF_STR( Off ) )
18511780   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
1852   PORT_DIPNAME( 0x80, 0x80, DEF_STR( Unused ) )
1853   PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
1854   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
1781   PORT_DIPUNUSED_DIPLOC( 0x80, 0x80, "SW(B):8" )
18551782
18561783   PORT_START_TAG("DSWC")
1857   PORT_DIPNAME( 0x03, 0x03, "Vitality Packs" )
1858   PORT_DIPSETTING(    0x00, "1" )                  // 0x0320
1859   PORT_DIPSETTING(    0x03, "2" )                  // 0x0640
1784   PORT_DIPNAME( 0x03, 0x03, "Vitality Packs" )                  PORT_DIPLOCATION("SW(C):1,2")
1785   PORT_DIPSETTING(    0x00, "1" )                        // 0x0320
1786   PORT_DIPSETTING(    0x03, "2" )                        // 0x0640
18601787   PORT_DIPSETTING(    0x02, "3 (2 when continue)" )         // 0x0960 (0x0640 when continue)
18611788   PORT_DIPSETTING(    0x01, "4 (3 when continue)" )         // 0x0c80 (0x0960 when continue)
1862   PORT_DIPNAME( 0x04, 0x04, DEF_STR( Free_Play ) )
1789   PORT_DIPNAME( 0x04, 0x04, DEF_STR( Free_Play ) )               PORT_DIPLOCATION("SW(C):3")
18631790   PORT_DIPSETTING(    0x04, DEF_STR( Off ) )
18641791   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
1865   PORT_DIPNAME( 0x08, 0x08, "Freeze" )
1792   PORT_DIPNAME( 0x08, 0x08, "Freeze" )                        PORT_DIPLOCATION("SW(C):4")
18661793   PORT_DIPSETTING(    0x08, DEF_STR( Off ) )
18671794   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
1868   PORT_DIPNAME( 0x10, 0x10, DEF_STR( Flip_Screen ) )
1795   PORT_DIPNAME( 0x10, 0x10, DEF_STR( Flip_Screen ) )               PORT_DIPLOCATION("SW(C):5")
18691796   PORT_DIPSETTING(    0x10, DEF_STR( Off ) )
18701797   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
1871   PORT_DIPNAME( 0x20, 0x00, DEF_STR( Demo_Sounds ) )
1798   PORT_DIPNAME( 0x20, 0x00, DEF_STR( Demo_Sounds ) )               PORT_DIPLOCATION("SW(C):6")
18721799   PORT_DIPSETTING(    0x20, DEF_STR( Off ) )
18731800   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
1874   PORT_DIPNAME( 0x40, 0x00, DEF_STR( Allow_Continue ) )
1801   PORT_DIPNAME( 0x40, 0x00, DEF_STR( Allow_Continue ) )            PORT_DIPLOCATION("SW(C):7")
18751802   PORT_DIPSETTING(    0x40, DEF_STR( No ) )
18761803   PORT_DIPSETTING(    0x00, DEF_STR( Yes ) )
1877   PORT_DIPNAME( 0x80, 0x80, "Game Mode")
1804   PORT_DIPNAME( 0x80, 0x80, "Game Mode")                        PORT_DIPLOCATION("SW(C):8")
18781805   PORT_DIPSETTING(    0x80, "Game" )
18791806   PORT_DIPSETTING(    0x00, DEF_STR( Test ) )
18801807
r1293r1294
19091836   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
19101837
19111838   PORT_START_TAG("DSWA")
1912   CPS1_COINAGE_1
1913   PORT_DIPNAME( 0x40, 0x40, "2 Coins to Start, 1 to Continue" )
1914   PORT_DIPSETTING(    0x40, DEF_STR( Off ) )
1915   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
1916   PORT_DIPNAME( 0x80, 0x80, DEF_STR( Unused ) )
1917   PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
1918   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
1839   CPS1_COINAGE_1( "SW(A)" )
1840   PORT_DIPNAME( 0x40, 0x40, "2 Coins to Start, 1 to Continue" )      PORT_DIPLOCATION("SW(A):7")
1841   PORT_DIPSETTING(    0x40, DEF_STR( Off ) )                     // Overrides all other coinage settings
1842   PORT_DIPSETTING(    0x00, DEF_STR( On ) )                     // according to manual
1843   PORT_DIPUNUSED_DIPLOC( 0x80, 0x80, "SW(A):8" )                  // This switch is not documented
19191844
19201845   PORT_START_TAG("DSWB")
1921   PORT_DIPNAME( 0x07, 0x04, "Difficulty Level (Enemy's Strength)" )
1846   PORT_DIPNAME( 0x07, 0x04, "Difficulty Level (Enemy's Strength)" )   PORT_DIPLOCATION("SW(B):1,2,3")
19221847   PORT_DIPSETTING(    0x07, "1 (Easiest)" )
19231848   PORT_DIPSETTING(    0x06, "2" )
19241849   PORT_DIPSETTING(    0x05, "3" )
r1293r1294
19271852   PORT_DIPSETTING(    0x02, "6" )
19281853   PORT_DIPSETTING(    0x01, "7" )
19291854   PORT_DIPSETTING(    0x00, "8 (Hardest)" )
1930   PORT_DIPNAME( 0x18, 0x18, "Difficulty Level (Player's Strength)" )
1855   PORT_DIPNAME( 0x18, 0x18, "Difficulty Level (Player's Strength)" )   PORT_DIPLOCATION("SW(B):4,5")
19311856   PORT_DIPSETTING(    0x10, DEF_STR( Easy ) )
19321857   PORT_DIPSETTING(    0x18, DEF_STR( Normal ) )
19331858   PORT_DIPSETTING(    0x08, DEF_STR( Hard ) )
19341859   PORT_DIPSETTING(    0x00, DEF_STR( Hardest ) )
1935   PORT_DIPNAME( 0x20, 0x20, DEF_STR( Unused ) )
1936   PORT_DIPSETTING(    0x20, DEF_STR( Off ) )
1937   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
1938   PORT_DIPNAME( 0x40, 0x40, DEF_STR( Unused ) )
1939   PORT_DIPSETTING(    0x40, DEF_STR( Off ) )
1940   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
1941   PORT_DIPNAME( 0x80, 0x80, DEF_STR( Unused ) )
1942   PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
1943   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
1860   PORT_DIPUNUSED_DIPLOC( 0x20, 0x20, "SW(B):6" )                  // This switch is not documented
1861   PORT_DIPUNUSED_DIPLOC( 0x40, 0x40, "SW(B):7" )                  // This switch is not documented
1862   PORT_DIPUNUSED_DIPLOC( 0x80, 0x80, "SW(B):8" )                  // This switch is not documented
19441863
19451864   PORT_START_TAG("DSWC")
1946   PORT_DIPNAME( 0x01, 0x01, DEF_STR( Unused ) )
1947   PORT_DIPSETTING(    0x01, DEF_STR( Off ) )
1948   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
1949   PORT_DIPNAME( 0x02, 0x02, DEF_STR( Unused ) )
1950   PORT_DIPSETTING(    0x02, DEF_STR( Off ) )
1951   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
1952   PORT_DIPNAME( 0x04, 0x04, DEF_STR( Free_Play ) )
1865   PORT_DIPUNUSED_DIPLOC( 0x01, 0x01, "SW(C):1" )                  // This switch is not documented
1866   PORT_DIPUNUSED_DIPLOC( 0x02, 0x02, "SW(C):2" )                  // This switch is not documented
1867   PORT_DIPNAME( 0x04, 0x04, DEF_STR( Free_Play ) )               PORT_DIPLOCATION("SW(C):3")
19531868   PORT_DIPSETTING(    0x04, DEF_STR( Off ) )
19541869   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
1955   PORT_DIPNAME( 0x08, 0x08, "Freeze" )
1870   PORT_DIPNAME( 0x08, 0x08, "Freeze" )                        PORT_DIPLOCATION("SW(C):4")
19561871   PORT_DIPSETTING(    0x08, DEF_STR( Off ) )
19571872   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
1958   PORT_DIPNAME( 0x10, 0x10, DEF_STR( Flip_Screen ) )
1873   PORT_DIPNAME( 0x10, 0x10, DEF_STR( Flip_Screen ) )               PORT_DIPLOCATION("SW(C):5")
19591874   PORT_DIPSETTING(    0x10, DEF_STR( Off ) )
19601875   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
1961   PORT_DIPNAME( 0x20, 0x00, DEF_STR( Demo_Sounds ) )
1876   PORT_DIPNAME( 0x20, 0x00, DEF_STR( Demo_Sounds ) )               PORT_DIPLOCATION("SW(C):6")
19621877   PORT_DIPSETTING(    0x20, DEF_STR( Off ) )
19631878   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
1964   PORT_DIPNAME( 0x40, 0x00, DEF_STR( Allow_Continue ) )
1879   PORT_DIPNAME( 0x40, 0x00, DEF_STR( Allow_Continue ) )            PORT_DIPLOCATION("SW(C):7")
19651880   PORT_DIPSETTING(    0x40, DEF_STR( No ) )
19661881   PORT_DIPSETTING(    0x00, DEF_STR( Yes ) )
1967   PORT_DIPNAME( 0x80, 0x80, "Game Mode")
1882   PORT_DIPNAME( 0x80, 0x80, "Game Mode")                        PORT_DIPLOCATION("SW(C):8")
19681883   PORT_DIPSETTING(    0x80, "Game" )
19691884   PORT_DIPSETTING(    0x00, DEF_STR( Test ) )
19701885
r1293r1294
20001915   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
20011916
20021917   PORT_START_TAG("DSWA")
2003   CPS1_COINAGE_1
2004   PORT_DIPNAME( 0x40, 0x40, "2 Coins to Start, 1 to Continue" )
1918   CPS1_COINAGE_1( "SW(A)" )
1919   PORT_DIPNAME( 0x40, 0x40, "2 Coins to Start, 1 to Continue" )   PORT_DIPLOCATION("SW(A):7")
20051920   PORT_DIPSETTING(    0x40, DEF_STR( Off ) )
20061921   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
2007   PORT_DIPNAME( 0x80, 0x80, DEF_STR( Unused ) )
2008   PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
2009   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
1922   PORT_DIPUNUSED_DIPLOC( 0x80, 0x80, "SW(A):8" )
20101923
20111924   PORT_START_TAG("DSWB")
2012   CPS1_DIFFICULTY_1
2013   PORT_DIPNAME( 0x18, 0x18, "Life Bar" )
1925   CPS1_DIFFICULTY_1( "SW(B)" )
1926   PORT_DIPNAME( 0x18, 0x18, "Life Bar" )                     PORT_DIPLOCATION("SW(B):4,5")
20141927   PORT_DIPSETTING(    0x00, "Minimun" )
20151928   PORT_DIPSETTING(    0x18, DEF_STR( Medium ) )
20161929//  PORT_DIPSETTING(    0x10, DEF_STR( Medium ) )
20171930   PORT_DIPSETTING(    0x08, "Maximum" )
2018   PORT_DIPNAME( 0x20, 0x20, DEF_STR( Unused ) )
2019   PORT_DIPSETTING(    0x20, DEF_STR( Off ) )
2020   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
2021   PORT_DIPNAME( 0x40, 0x40, DEF_STR( Unused ) )
2022   PORT_DIPSETTING(    0x40, DEF_STR( Off ) )
2023   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
2024   PORT_DIPNAME( 0x80, 0x80, DEF_STR( Unused ) )
2025   PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
2026   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
1931   PORT_DIPUNUSED_DIPLOC( 0x20, 0x20, "SW(B):6" )
1932   PORT_DIPUNUSED_DIPLOC( 0x40, 0x40, "SW(B):7" )
1933   PORT_DIPUNUSED_DIPLOC( 0x80, 0x80, "SW(B):8" )
20271934
20281935   PORT_START_TAG("DSWC")
2029   PORT_DIPNAME( 0x03, 0x03, DEF_STR( Lives ) )
1936   PORT_DIPNAME( 0x03, 0x03, DEF_STR( Lives ) )               PORT_DIPLOCATION("SW(C):1,2")
20301937   PORT_DIPSETTING(    0x02, "1" )
20311938   PORT_DIPSETTING(    0x03, "2" )
20321939   PORT_DIPSETTING(    0x01, "3" )
20331940   PORT_DIPSETTING(    0x00, "4" )
2034   PORT_DIPNAME( 0x04, 0x04, DEF_STR( Free_Play ) )
1941   PORT_DIPNAME( 0x04, 0x04, DEF_STR( Free_Play ) )            PORT_DIPLOCATION("SW(C):3")
20351942   PORT_DIPSETTING(    0x04, DEF_STR( Off ) )
20361943   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
2037   PORT_DIPNAME( 0x08, 0x08, "Freeze" )
1944   PORT_DIPNAME( 0x08, 0x08, "Freeze" )                     PORT_DIPLOCATION("SW(C):4")
20381945   PORT_DIPSETTING(    0x08, DEF_STR( Off ) )
20391946   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
2040   PORT_DIPNAME( 0x10, 0x10, DEF_STR( Flip_Screen ) )
1947   PORT_DIPNAME( 0x10, 0x10, DEF_STR( Flip_Screen ) )            PORT_DIPLOCATION("SW(C):5")
20411948   PORT_DIPSETTING(    0x10, DEF_STR( Off ) )
20421949   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
2043   PORT_DIPNAME( 0x20, 0x00, DEF_STR( Demo_Sounds ) )
1950   PORT_DIPNAME( 0x20, 0x00, DEF_STR( Demo_Sounds ) )            PORT_DIPLOCATION("SW(C):6")
20441951   PORT_DIPSETTING(    0x20, DEF_STR( Off ) )
20451952   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
2046   PORT_DIPNAME( 0x40, 0x00, DEF_STR( Allow_Continue ) )
1953   PORT_DIPNAME( 0x40, 0x00, DEF_STR( Allow_Continue ) )         PORT_DIPLOCATION("SW(C):7")
20471954   PORT_DIPSETTING(    0x40, DEF_STR( No ) )
20481955   PORT_DIPSETTING(    0x00, DEF_STR( Yes ) )
2049   PORT_DIPNAME( 0x80, 0x80, "Game Mode")
1956   PORT_DIPNAME( 0x80, 0x80, "Game Mode")                     PORT_DIPLOCATION("SW(C):8")
20501957   PORT_DIPSETTING(    0x80, "Game" )
20511958   PORT_DIPSETTING(    0x00, DEF_STR( Test ) )               // To enable the "debug" features
20521959
r1293r1294
20811988   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN  )
20821989
20831990   PORT_START_TAG("DSWA")
2084   CPS1_COINAGE_1
2085   PORT_DIPNAME( 0x40, 0x40, "2 Coins to Start, 1 to Continue" )
1991   CPS1_COINAGE_1( "SW(A)" )
1992   PORT_DIPNAME( 0x40, 0x40, "2 Coins to Start, 1 to Continue" )   PORT_DIPLOCATION("SW(A):7")
20861993   PORT_DIPSETTING(    0x40, DEF_STR( Off ) )
20871994   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
2088   PORT_DIPNAME( 0x80, 0x80, DEF_STR( Unused ) )
2089   PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
2090   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
1995   PORT_DIPUNUSED_DIPLOC( 0x80, 0x80, "SW(A):8" )
20911996
20921997   PORT_START_TAG("DSWB")
2093   CPS1_DIFFICULTY_1
2094   PORT_DIPNAME( 0x08, 0x08, DEF_STR( Unused ) )
2095   PORT_DIPSETTING(    0x08, DEF_STR( Off ) )
2096   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
2097   PORT_DIPNAME( 0x10, 0x10, DEF_STR( Unused ) )
2098   PORT_DIPSETTING(    0x10, DEF_STR( Off ) )
2099   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
2100   PORT_DIPNAME( 0x20, 0x20, DEF_STR( Unused ) )
2101   PORT_DIPSETTING(    0x20, DEF_STR( Off ) )
2102   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
2103   PORT_DIPNAME( 0x40, 0x40, DEF_STR( Unused ) )
2104   PORT_DIPSETTING(    0x40, DEF_STR( Off ) )
2105   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
2106   PORT_DIPNAME( 0x80, 0x80, DEF_STR( Unused ) )
2107   PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
2108   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
1998   CPS1_DIFFICULTY_1( "SW(B)" )
1999   PORT_DIPUNUSED_DIPLOC( 0x08, 0x08, "SW(B):4" )
2000   PORT_DIPUNUSED_DIPLOC( 0x10, 0x10, "SW(B):5" )
2001   PORT_DIPUNUSED_DIPLOC( 0x20, 0x20, "SW(B):6" )
2002   PORT_DIPUNUSED_DIPLOC( 0x40, 0x40, "SW(B):7" )
2003   PORT_DIPUNUSED_DIPLOC( 0x80, 0x80, "SW(B):8" )
21092004
21102005   PORT_START_TAG("DSWC")
2111   PORT_DIPNAME( 0x01, 0x01, DEF_STR( Unused ) )
2112   PORT_DIPSETTING(    0x01, DEF_STR( Off ) )
2113   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
2114   PORT_DIPNAME( 0x02, 0x02, DEF_STR( Unused ) )
2115   PORT_DIPSETTING(    0x02, DEF_STR( Off ) )
2116   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
2117   PORT_DIPNAME( 0x04, 0x04, DEF_STR( Free_Play ) )
2006   PORT_DIPUNUSED_DIPLOC( 0x01, 0x01, "SW(C):1" )
2007   PORT_DIPUNUSED_DIPLOC( 0x02, 0x02, "SW(C):2" )
2008   PORT_DIPNAME( 0x04, 0x04, DEF_STR( Free_Play ) )            PORT_DIPLOCATION("SW(C):3")
21182009   PORT_DIPSETTING(    0x04, DEF_STR( Off ) )
21192010   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
2120   PORT_DIPNAME( 0x08, 0x08, "Freeze" )
2011   PORT_DIPNAME( 0x08, 0x08, "Freeze" )                     PORT_DIPLOCATION("SW(C):4")
21212012   PORT_DIPSETTING(    0x08, DEF_STR( Off ) )
21222013   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
2123   PORT_DIPNAME( 0x10, 0x10, DEF_STR( Flip_Screen ) )
2014   PORT_DIPNAME( 0x10, 0x10, DEF_STR( Flip_Screen ) )            PORT_DIPLOCATION("SW(C):5")
21242015   PORT_DIPSETTING(    0x10, DEF_STR( Off ) )
21252016   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
2126   PORT_DIPNAME( 0x20, 0x00, DEF_STR( Demo_Sounds ) )
2017   PORT_DIPNAME( 0x20, 0x00, DEF_STR( Demo_Sounds ) )            PORT_DIPLOCATION("SW(C):6")
21272018   PORT_DIPSETTING(    0x20, DEF_STR( Off ) )
21282019   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
2129   PORT_DIPNAME( 0x40, 0x00, DEF_STR( Allow_Continue ) )
2020   PORT_DIPNAME( 0x40, 0x00, DEF_STR( Allow_Continue ) )         PORT_DIPLOCATION("SW(C):7")
21302021   PORT_DIPSETTING(    0x40, DEF_STR( No ) )
21312022   PORT_DIPSETTING(    0x00, DEF_STR( Yes ) )
2132   PORT_DIPNAME( 0x80, 0x80, "Game Mode")
2023   PORT_DIPNAME( 0x80, 0x80, "Game Mode")                     PORT_DIPLOCATION("SW(C):8")
21332024   PORT_DIPSETTING(    0x80, "Game" )
21342025   PORT_DIPSETTING(    0x00, DEF_STR( Test ) )
21352026
r1293r1294
21752066   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN  )
21762067
21772068   PORT_START_TAG("DSWA")
2178   CPS1_COINAGE_1
2179   PORT_DIPNAME( 0x40, 0x40, "2 Coins to Start, 1 to Continue" )
2069   CPS1_COINAGE_1( "SW(A)" )
2070   PORT_DIPNAME( 0x40, 0x40, "2 Coins to Start, 1 to Continue" )   PORT_DIPLOCATION("SW(A):7")
21802071   PORT_DIPSETTING(    0x40, DEF_STR( Off ) )
21812072   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
2182   PORT_DIPNAME( 0x80, 0x80, DEF_STR( Unused ) )
2183   PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
2184   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
2073   PORT_DIPUNUSED_DIPLOC( 0x80, 0x80, "SW(A):8" )
21852074
21862075   PORT_START_TAG("DSWB")
2187   CPS1_DIFFICULTY_1
2188   PORT_DIPNAME( 0x08, 0x00, "2 Players Game" )
2076   CPS1_DIFFICULTY_1( "SW(B)" )
2077   PORT_DIPNAME( 0x08, 0x00, "2 Players Game" )               PORT_DIPLOCATION("SW(B):4")
21892078   PORT_DIPSETTING(    0x08, "1 Credit/No Continue" )
21902079   PORT_DIPSETTING(    0x00, "2 Credits/Winner Continue" ) //Winner stays, loser pays, in other words.
2191   PORT_DIPNAME( 0x10, 0x10, DEF_STR( Unknown ) )
2192   PORT_DIPSETTING(    0x10, DEF_STR( Off ) )
2193   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
2194   PORT_DIPNAME( 0x20, 0x20, DEF_STR( Unknown ) )
2195   PORT_DIPSETTING(    0x20, DEF_STR( Off ) )
2196   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
2197   PORT_DIPNAME( 0x40, 0x40, DEF_STR( Unknown ) )
2198   PORT_DIPSETTING(    0x40, DEF_STR( Off ) )
2199   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
2200   PORT_DIPNAME( 0x80, 0x80, DEF_STR( Unknown ) )
2201   PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
2202   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
2080   PORT_DIPUNUSED_DIPLOC( 0x10, 0x10, "SW(B):5" )
2081   PORT_DIPUNUSED_DIPLOC( 0x20, 0x20, "SW(B):6" )
2082   PORT_DIPUNUSED_DIPLOC( 0x40, 0x40, "SW(B):7" )
2083   PORT_DIPUNUSED_DIPLOC( 0x80, 0x80, "SW(B):8" )
22032084
22042085   PORT_START_TAG("DSWC")
2205   PORT_DIPNAME( 0x01, 0x01, DEF_STR( Unknown ) )
2206   PORT_DIPSETTING(    0x01, DEF_STR( Off ) )
2207   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
2208   PORT_DIPNAME( 0x02, 0x02, DEF_STR( Unknown ) )
2209   PORT_DIPSETTING(    0x02, DEF_STR( Off ) )
2210   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
2211   PORT_DIPNAME( 0x04, 0x04, DEF_STR( Free_Play ) )
2086   PORT_DIPUNUSED_DIPLOC( 0x01, 0x01, "SW(C):1" )
2087   PORT_DIPUNUSED_DIPLOC( 0x02, 0x02, "SW(C):2" )
2088   PORT_DIPNAME( 0x04, 0x04, DEF_STR( Free_Play ) )            PORT_DIPLOCATION("SW(C):3")
22122089   PORT_DIPSETTING(    0x04, DEF_STR( Off ) )
22132090   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
2214   PORT_DIPNAME( 0x08, 0x08, "Freeze" )
2091   PORT_DIPNAME( 0x08, 0x08, "Freeze" )                     PORT_DIPLOCATION("SW(C):4")
22152092   PORT_DIPSETTING(    0x08, DEF_STR( Off ) )
22162093   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
2217   PORT_DIPNAME( 0x10, 0x10, DEF_STR( Flip_Screen ) )
2094   PORT_DIPNAME( 0x10, 0x10, DEF_STR( Flip_Screen ) )            PORT_DIPLOCATION("SW(C):5")
22182095   PORT_DIPSETTING(    0x10, DEF_STR( Off ) )
22192096   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
2220   PORT_DIPNAME( 0x20, 0x00, DEF_STR( Demo_Sounds ) )
2097   PORT_DIPNAME( 0x20, 0x00, DEF_STR( Demo_Sounds ) )            PORT_DIPLOCATION("SW(C):6")
22212098   PORT_DIPSETTING(    0x20, DEF_STR( Off ) )
22222099   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
2223   PORT_DIPNAME( 0x40, 0x00, DEF_STR( Allow_Continue ) )
2100   PORT_DIPNAME( 0x40, 0x00, DEF_STR( Allow_Continue ) )         PORT_DIPLOCATION("SW(C):7")
22242101   PORT_DIPSETTING(    0x40, DEF_STR( No ) )
22252102   PORT_DIPSETTING(    0x00, DEF_STR( Yes ) )
2226   PORT_DIPNAME( 0x80, 0x80, "Game Mode")
2103   PORT_DIPNAME( 0x80, 0x80, "Game Mode")                     PORT_DIPLOCATION("SW(C):8")
22272104   PORT_DIPSETTING(    0x80, "Game" )
22282105   PORT_DIPSETTING(    0x00, DEF_STR( Test ) )
22292106
r1293r1294
22682145   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
22692146
22702147   PORT_START_TAG("DSWA")
2271   CPS1_COINAGE_1
2272   PORT_DIPNAME( 0x40, 0x40, "2 Coins to Start, 1 to Continue" )
2273   PORT_DIPSETTING(    0x40, DEF_STR( Off ) )
2274   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
2148   CPS1_COINAGE_1( "SW(A)" )
2149   PORT_DIPNAME( 0x40, 0x40, "2 Coins to Start, 1 to Continue" )   PORT_DIPLOCATION("SW(A):7")
2150                                                   PORT_CONDITION("DSWA",0x3f,PORTCOND_NOTEQUALS,0x00)
2151   PORT_DIPSETTING(    0x40, DEF_STR( Off ) )                  PORT_CONDITION("DSWA",0x3f,PORTCOND_NOTEQUALS,0x00)
2152   PORT_DIPSETTING(    0x00, DEF_STR( On ) )                  PORT_CONDITION("DSWA",0x3f,PORTCOND_NOTEQUALS,0x00)
2153   PORT_DIPNAME( 0x40, 0x40, DEF_STR( Free_Play ) )            PORT_DIPLOCATION("SW(A):7")
2154                                                   PORT_CONDITION("DSWA",0x3f,PORTCOND_EQUALS,0x00)
2155   PORT_DIPSETTING(    0x40, DEF_STR( Off ) )                  PORT_CONDITION("DSWA",0x3f,PORTCOND_EQUALS,0x00)
2156   PORT_DIPSETTING(    0x00, DEF_STR( On ) )                  PORT_CONDITION("DSWA",0x3f,PORTCOND_EQUALS,0x00)
22752157   /* Free Play: ALL bits 0 to 7 must be ON ; 4C_1C, 4C_1C, 2 Coins to Start, 1 to Continue ON */
2276   PORT_DIPNAME( 0x80, 0x80, "Freeze" )
2158   PORT_DIPNAME( 0x80, 0x80, "Freeze" )                     PORT_DIPLOCATION("SW(A):8")
22772159   PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
22782160   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
22792161
22802162   PORT_START_TAG("DSWB")
2281   PORT_DIPNAME( 0x03, 0x02, "Lives (Midnight Wanderers)" )
2163   PORT_DIPNAME( 0x03, 0x02, "Lives (Midnight Wanderers)" )      PORT_DIPLOCATION("SW(B):1,2")
22822164   PORT_DIPSETTING(    0x03, "1" )
22832165   PORT_DIPSETTING(    0x02, "2" )
22842166   PORT_DIPSETTING(    0x01, "3" )
22852167   PORT_DIPSETTING(    0x00, "5" )
2286   PORT_DIPNAME( 0x0c, 0x08, "Difficulty (Midnight Wanderers)" )
2168   PORT_DIPNAME( 0x0c, 0x08, "Difficulty (Midnight Wanderers)" )   PORT_DIPLOCATION("SW(B):3,4")
22872169   PORT_DIPSETTING(    0x0c, DEF_STR( Easy ) )
22882170   PORT_DIPSETTING(    0x08, DEF_STR( Normal ) )
22892171   PORT_DIPSETTING(    0x04, DEF_STR( Hard ) )
22902172   PORT_DIPSETTING(    0x00, DEF_STR( Hardest ) )
2291   PORT_DIPNAME( 0x30, 0x10, "Lives (Chariot)" )
2173   PORT_DIPNAME( 0x30, 0x10, "Lives (Chariot)" )               PORT_DIPLOCATION("SW(B):5,6")
22922174   PORT_DIPSETTING(    0x30, "1" )
22932175   PORT_DIPSETTING(    0x20, "2" )
22942176   PORT_DIPSETTING(    0x10, "3" )
22952177   PORT_DIPSETTING(    0x00, "5" )
2296   PORT_DIPNAME( 0xc0, 0x80, "Difficulty (Chariot)" )
2178   PORT_DIPNAME( 0xc0, 0x80, "Difficulty (Chariot)" )            PORT_DIPLOCATION("SW(B):7,8")
22972179   PORT_DIPSETTING(    0xc0, DEF_STR( Easy ) )
22982180   PORT_DIPSETTING(    0x80, DEF_STR( Normal ) )
22992181   PORT_DIPSETTING(    0x40, DEF_STR( Hard ) )
23002182   PORT_DIPSETTING(    0x00, DEF_STR( Hardest ) )
23012183
23022184   PORT_START_TAG("DSWC")
2303   PORT_DIPNAME( 0x03, 0x01, "Lives (Don't Pull)" )
2185   PORT_DIPNAME( 0x03, 0x01, "Lives (Don't Pull)" )            PORT_DIPLOCATION("SW(C):1,2")
23042186   PORT_DIPSETTING(    0x03, "1" )
23052187   PORT_DIPSETTING(    0x02, "2" )
23062188   PORT_DIPSETTING(    0x01, "3" )
23072189   PORT_DIPSETTING(    0x00, "5" )
2308   PORT_DIPNAME( 0x0c, 0x08, "Difficulty (Don't Pull)" )
2190   PORT_DIPNAME( 0x0c, 0x08, "Difficulty (Don't Pull)" )         PORT_DIPLOCATION("SW(C):3,4")
23092191   PORT_DIPSETTING(    0x0c, DEF_STR( Easy ) )
23102192   PORT_DIPSETTING(    0x08, DEF_STR( Normal ) )
23112193   PORT_DIPSETTING(    0x04, DEF_STR( Hard ) )
23122194   PORT_DIPSETTING(    0x00, DEF_STR( Hardest ) )
2313   PORT_DIPNAME( 0x10, 0x10, DEF_STR( Flip_Screen ) )
2195   PORT_DIPNAME( 0x10, 0x10, DEF_STR( Flip_Screen ) )            PORT_DIPLOCATION("SW(C):5")
23142196   PORT_DIPSETTING(    0x10, DEF_STR( Off ) )
23152197   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
2316   PORT_DIPNAME( 0x20, 0x00, DEF_STR( Demo_Sounds ) )
2198   PORT_DIPNAME( 0x20, 0x00, DEF_STR( Demo_Sounds ) )            PORT_DIPLOCATION("SW(C):6")
23172199   PORT_DIPSETTING(    0x20, DEF_STR( Off ) )
23182200   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
2319   PORT_DIPNAME( 0x40, 0x00, DEF_STR( Allow_Continue ) )
2201   PORT_DIPNAME( 0x40, 0x00, DEF_STR( Allow_Continue ) )         PORT_DIPLOCATION("SW(C):7")
23202202   PORT_DIPSETTING(    0x40, DEF_STR( No ) )
23212203   PORT_DIPSETTING(    0x00, DEF_STR( Yes ) )
2322   PORT_DIPNAME( 0x80, 0x80, "Game Mode")
2204   PORT_DIPNAME( 0x80, 0x80, "Game Mode")                     PORT_DIPLOCATION("SW(C):8")
23232205   PORT_DIPSETTING(    0x80, "Game" )
23242206   PORT_DIPSETTING(    0x00, DEF_STR( Test ) )
23252207
r1293r1294
23542236   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
23552237
23562238   PORT_START_TAG("DSWA")
2357   CPS1_COINAGE_2
2358   PORT_DIPNAME( 0x08, 0x08, "Coin Slots" )
2239   CPS1_COINAGE_2( "SW(A)" )
2240   PORT_DIPNAME( 0x08, 0x08, "Coin Slots" )                  PORT_DIPLOCATION("SW(A):4")
23592241   PORT_DIPSETTING(    0x00, "1" )
23602242   PORT_DIPSETTING(    0x08, "3" )
2361   PORT_DIPNAME( 0x10, 0x10, "Play Mode" )
2243   PORT_DIPNAME( 0x10, 0x10, "Play Mode" )                     PORT_DIPLOCATION("SW(A):5")
23622244   PORT_DIPSETTING(    0x00, "2 Players" )
23632245   PORT_DIPSETTING(    0x10, "3 Players" )
2364   PORT_DIPNAME( 0x20, 0x20, DEF_STR( Unused ) )
2365   PORT_DIPSETTING(    0x20, DEF_STR( Off ) )
2366   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
2367   PORT_DIPNAME( 0x40, 0x40, "2 Coins to Start, 1 to Continue" )
2246   PORT_DIPUNUSED_DIPLOC( 0x20, 0x20, "SW(A):6" )
2247   PORT_DIPNAME( 0x40, 0x40, "2 Coins to Start, 1 to Continue" )   PORT_DIPLOCATION("SW(A):7")
23682248   PORT_DIPSETTING(    0x40, DEF_STR( Off ) )
23692249   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
2370   PORT_DIPNAME( 0x80, 0x80, DEF_STR( Unused ) )
2371   PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
2372   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
2250   PORT_DIPUNUSED_DIPLOC( 0x80, 0x80, "SW(A):8" )
23732251
23742252   PORT_START_TAG("DSWB")
2375   CPS1_DIFFICULTY_1
2376   PORT_DIPNAME( 0x38, 0x38, DEF_STR( Lives ) )
2253   CPS1_DIFFICULTY_1( "SW(B)" )
2254   PORT_DIPNAME( 0x38, 0x38, DEF_STR( Lives ) )               PORT_DIPLOCATION("SW(B):4,5,6")
23772255   PORT_DIPSETTING(    0x30, "1" )
23782256   PORT_DIPSETTING(    0x38, "2" )
23792257   PORT_DIPSETTING(    0x28, "3" )
r1293r1294
23822260   PORT_DIPSETTING(    0x10, "6" )
23832261   PORT_DIPSETTING(    0x08, "7" )
23842262   PORT_DIPSETTING(    0x00, "8" )
2385   PORT_DIPNAME( 0xc0, 0xc0, DEF_STR( Bonus_Life ) )
2263   PORT_DIPNAME( 0xc0, 0xc0, DEF_STR( Bonus_Life ) )            PORT_DIPLOCATION("SW(B):7,8")
23862264   PORT_DIPSETTING(    0x80, "80k and every 400k" )
23872265   PORT_DIPSETTING(    0xc0, "100k and every 450k" )
23882266   PORT_DIPSETTING(    0x40, "160k and every 450k" )
23892267   PORT_DIPSETTING(    0x00, DEF_STR( None ) )
23902268
23912269   PORT_START_TAG("DSWC")
2392   PORT_DIPNAME( 0x01, 0x01, DEF_STR( Unused ) )
2393   PORT_DIPSETTING(    0x01, DEF_STR( Off ) )
2394   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
2395   PORT_DIPNAME( 0x02, 0x02, DEF_STR( Unused ) )
2396   PORT_DIPSETTING(    0x02, DEF_STR( Off ) )
2397   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
2398   PORT_DIPNAME( 0x04, 0x04, DEF_STR( Free_Play ) )
2270   PORT_DIPUNUSED_DIPLOC( 0x01, 0x01, "SW(C):1" )
2271   PORT_DIPUNUSED_DIPLOC( 0x02, 0x02, "SW(C):2" )
2272   PORT_DIPNAME( 0x04, 0x04, DEF_STR( Free_Play ) )            PORT_DIPLOCATION("SW(C):3")
23992273   PORT_DIPSETTING(    0x04, DEF_STR( Off ) )
24002274   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
2401   PORT_DIPNAME( 0x08, 0x08, "Freeze" )
2275   PORT_DIPNAME( 0x08, 0x08, "Freeze" )                     PORT_DIPLOCATION("SW(C):4")
24022276   PORT_DIPSETTING(    0x08, DEF_STR( Off ) )
24032277   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
2404   PORT_DIPNAME( 0x10, 0x10, DEF_STR( Flip_Screen ) )
2278   PORT_DIPNAME( 0x10, 0x10, DEF_STR( Flip_Screen ) )            PORT_DIPLOCATION("SW(C):5")
24052279   PORT_DIPSETTING(    0x10, DEF_STR( Off ) )
24062280   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
2407   PORT_DIPNAME( 0x20, 0x00, DEF_STR( Demo_Sounds ) )
2281   PORT_DIPNAME( 0x20, 0x00, DEF_STR( Demo_Sounds ) )            PORT_DIPLOCATION("SW(C):6")
24082282   PORT_DIPSETTING(    0x20, DEF_STR( Off ) )
24092283   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
2410   PORT_DIPNAME( 0x40, 0x00, DEF_STR( Allow_Continue ) )
2284   PORT_DIPNAME( 0x40, 0x00, DEF_STR( Allow_Continue ) )         PORT_DIPLOCATION("SW(C):7")
24112285   PORT_DIPSETTING(    0x40, DEF_STR( No ) )
24122286   PORT_DIPSETTING(    0x00, DEF_STR( Yes ) )
2413   PORT_DIPNAME( 0x80, 0x80, "Game Mode")
2287   PORT_DIPNAME( 0x80, 0x80, "Game Mode")                     PORT_DIPLOCATION("SW(C):8")
24142288   PORT_DIPSETTING(    0x80, "Game" )
24152289   PORT_DIPSETTING(    0x00, DEF_STR( Test ) )
24162290
r1293r1294
24462320/* Needs further checking
24472321   Same as kod but different "Bonus_life" values */
24482322static INPUT_PORTS_START( kodj )
2449   PORT_START_TAG("IN0")
2450   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_COIN1 )
2451   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_COIN2 )
2452   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_SERVICE1 )
2453   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNKNOWN )
2454   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_START1 )
2455   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_START2 )
2456   PORT_SERVICE_NO_TOGGLE( 0x40, IP_ACTIVE_LOW )
2457   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
2323   PORT_INCLUDE( kod )
24582324
2459   PORT_START_TAG("DSWA")
2460   CPS1_COINAGE_2
2461   PORT_DIPNAME( 0x08, 0x08, "Coin Slots" )
2462   PORT_DIPSETTING(    0x00, "1" )
2463   PORT_DIPSETTING(    0x08, "3" )
2464   PORT_DIPNAME( 0x10, 0x10, "Play Mode" )
2465   PORT_DIPSETTING(    0x00, "2 Players" )
2466   PORT_DIPSETTING(    0x10, "3 Players" )
2467   PORT_DIPNAME( 0x20, 0x20, DEF_STR( Unused ) )
2468   PORT_DIPSETTING(    0x20, DEF_STR( Off ) )
2469   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
2470   PORT_DIPNAME( 0x40, 0x40, "2 Coins to Start, 1 to Continue" )
2471   PORT_DIPSETTING(    0x40, DEF_STR( Off ) )
2472   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
2473   PORT_DIPNAME( 0x80, 0x80, DEF_STR( Unused ) )
2474   PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
2475   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
2476
2477   PORT_START_TAG("DSWB")
2478   CPS1_DIFFICULTY_1
2479   PORT_DIPNAME( 0x38, 0x38, DEF_STR( Lives ) )
2480   PORT_DIPSETTING(    0x30, "1" )
2481   PORT_DIPSETTING(    0x38, "2" )
2482   PORT_DIPSETTING(    0x28, "3" )
2483   PORT_DIPSETTING(    0x20, "4" )
2484   PORT_DIPSETTING(    0x18, "5" )
2485   PORT_DIPSETTING(    0x10, "6" )
2486   PORT_DIPSETTING(    0x08, "7" )
2487   PORT_DIPSETTING(    0x00, "8" )
2488   PORT_DIPNAME( 0xc0, 0xc0, DEF_STR( Bonus_Life ) )
2325   PORT_MODIFY("DSWB")
2326   PORT_DIPNAME( 0xc0, 0xc0, DEF_STR( Bonus_Life ) )            PORT_DIPLOCATION("SW(B):7,8")
24892327   PORT_DIPSETTING(    0x80, "80k and every 400k" )
2490   PORT_DIPSETTING(    0xc0, "200k and every 450k" )
24912328   PORT_DIPSETTING(    0x40, "160k and every 450k" )
2329   PORT_DIPSETTING(    0xc0, "200k and every 450k" )
24922330   PORT_DIPSETTING(    0x00, DEF_STR( None ) )
2493
2494   PORT_START_TAG("DSWC")
2495   PORT_DIPNAME( 0x01, 0x01, DEF_STR( Unused ) )
2496   PORT_DIPSETTING(    0x01, DEF_STR( Off ) )
2497   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
2498   PORT_DIPNAME( 0x02, 0x02, DEF_STR( Unused ) )
2499   PORT_DIPSETTING(    0x02, DEF_STR( Off ) )
2500   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
2501   PORT_DIPNAME( 0x04, 0x04, DEF_STR( Free_Play ) )
2502   PORT_DIPSETTING(    0x04, DEF_STR( Off ) )
2503   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
2504   PORT_DIPNAME( 0x08, 0x08, "Freeze" )
2505   PORT_DIPSETTING(    0x08, DEF_STR( Off ) )
2506   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
2507   PORT_DIPNAME( 0x10, 0x10, DEF_STR( Flip_Screen ) )
2508   PORT_DIPSETTING(    0x10, DEF_STR( Off ) )
2509   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
2510   PORT_DIPNAME( 0x20, 0x00, DEF_STR( Demo_Sounds ) )
2511   PORT_DIPSETTING(    0x20, DEF_STR( Off ) )
2512   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
2513   PORT_DIPNAME( 0x40, 0x00, DEF_STR( Allow_Continue ) )
2514   PORT_DIPSETTING(    0x40, DEF_STR( No ) )
2515   PORT_DIPSETTING(    0x00, DEF_STR( Yes ) )
2516   PORT_DIPNAME( 0x80, 0x80, "Game Mode")
2517   PORT_DIPSETTING(    0x80, "Game" )
2518   PORT_DIPSETTING(    0x00, DEF_STR( Test ) )
2519
2520   PORT_START_TAG("IN1")
2521   PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_8WAY PORT_PLAYER(1)
2522   PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_8WAY PORT_PLAYER(1)
2523   PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_8WAY PORT_PLAYER(1)
2524   PORT_BIT( 0x0008, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_8WAY PORT_PLAYER(1)
2525   PORT_BIT( 0x0010, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(1)
2526   PORT_BIT( 0x0020, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(1)
2527   PORT_BIT( 0x0040, IP_ACTIVE_LOW, IPT_UNKNOWN )
2528   PORT_BIT( 0x0080, IP_ACTIVE_LOW, IPT_UNKNOWN )
2529   PORT_BIT( 0x0100, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_8WAY PORT_PLAYER(2)
2530   PORT_BIT( 0x0200, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_8WAY PORT_PLAYER(2)
2531   PORT_BIT( 0x0400, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_8WAY PORT_PLAYER(2)
2532   PORT_BIT( 0x0800, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_8WAY PORT_PLAYER(2)
2533   PORT_BIT( 0x1000, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(2)
2534   PORT_BIT( 0x2000, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(2)
2535   PORT_BIT( 0x4000, IP_ACTIVE_LOW, IPT_UNKNOWN )
2536   PORT_BIT( 0x8000, IP_ACTIVE_LOW, IPT_UNKNOWN )
2537
2538   PORT_START_TAG("IN2")      /* Player 3 */
2539   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_8WAY PORT_PLAYER(3)
2540   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_8WAY PORT_PLAYER(3)
2541   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_8WAY PORT_PLAYER(3)
2542   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_8WAY PORT_PLAYER(3)
2543   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(3)
2544   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(3)
2545   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_COIN3 )
2546   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_START3 )
25472331INPUT_PORTS_END
25482332
25492333
r1293r1294
25592343   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
25602344
25612345   PORT_START_TAG("DSWA")
2562   CPS1_COINAGE_2
2563   PORT_DIPNAME( 0x08, 0x08, DEF_STR( Unused ) )
2564   PORT_DIPSETTING(    0x08, DEF_STR( Off ) )
2565   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
2566   PORT_DIPNAME( 0x10, 0x10, DEF_STR( Unused ) )
2567   PORT_DIPSETTING(    0x10, DEF_STR( Off ) )
2568   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
2569   PORT_DIPNAME( 0x20, 0x20, DEF_STR( Unused ) )
2570   PORT_DIPSETTING(    0x20, DEF_STR( Off ) )
2571   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
2572   PORT_DIPNAME( 0x40, 0x40, "2 Coins to Start, 1 to Continue" )
2346   CPS1_COINAGE_2( "SW(A)" )
2347   PORT_DIPUNUSED_DIPLOC( 0x08, 0x08, "SW(A):4" )               // The manual says to leave these three
2348   PORT_DIPUNUSED_DIPLOC( 0x10, 0x10, "SW(A):5" )               // switches off.  Does turning them on cause
2349   PORT_DIPUNUSED_DIPLOC( 0x20, 0x20, "SW(A):6" )               // any "undesirable" behaviour?
2350   PORT_DIPNAME( 0x40, 0x40, "2 Coins to Start, 1 to Continue" )   PORT_DIPLOCATION("SW(A):7")
25732351   PORT_DIPSETTING(    0x40, DEF_STR( Off ) )
25742352   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
2575   PORT_DIPNAME( 0x80, 0x80, DEF_STR( Unused ) )
2576   PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
2577   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
2353   PORT_DIPUNUSED_DIPLOC( 0x80, 0x80, "SW(A):8" )               // Unused according to manual
25782354
25792355   PORT_START_TAG("DSWB")
2580   PORT_DIPNAME( 0x07, 0x04, "Difficulty 1" )
2356   PORT_DIPNAME( 0x07, 0x04, "Difficulty 1" )                  PORT_DIPLOCATION("SW(B):1,2,3")
25812357   PORT_DIPSETTING(    0x07, "1 (Easiest)" )
25822358   PORT_DIPSETTING(    0x06, "2" )
25832359   PORT_DIPSETTING(    0x05, "3" )
r1293r1294
25862362   PORT_DIPSETTING(    0x02, "6" )
25872363   PORT_DIPSETTING(    0x01, "7" )
25882364   PORT_DIPSETTING(    0x00, "8 (Hardest)" )
2589   PORT_DIPNAME( 0x18, 0x10, "Difficulty 2" )
2365   PORT_DIPNAME( 0x18, 0x10, "Difficulty 2" )                  PORT_DIPLOCATION("SW(B):4,5")
25902366   PORT_DIPSETTING(    0x18, DEF_STR( Easy ) )
25912367   PORT_DIPSETTING(    0x10, DEF_STR( Normal ) )
25922368   PORT_DIPSETTING(    0x08, DEF_STR( Hard ) )
25932369   PORT_DIPSETTING(    0x00, DEF_STR( Hardest ) )
2594   PORT_DIPNAME( 0x20, 0x20, DEF_STR( Unused ) )
2595   PORT_DIPSETTING(    0x20, DEF_STR( Off ) )
2596   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
2597   PORT_DIPNAME( 0xc0, 0xc0, "Play Mode" )
2370   PORT_DIPUNUSED_DIPLOC( 0x20, 0x20, "SW(B):6" )               // Manual says to leave this switch off.
2371   PORT_DIPNAME( 0xc0, 0xc0, "Play Mode" )                     PORT_DIPLOCATION("SW(B):7,8")
25982372   PORT_DIPSETTING(    0x40, "1 Players" ) // Actual setting is 4 players
25992373   PORT_DIPSETTING(    0xc0, "2 Players" )
26002374   PORT_DIPSETTING(    0x80, "3 Players" )
26012375   PORT_DIPSETTING(    0x00, "4 Players" )
26022376
26032377   PORT_START_TAG("DSWC")
2604   PORT_DIPNAME( 0x03, 0x03, DEF_STR( Lives ) )
2378   PORT_DIPNAME( 0x03, 0x03, DEF_STR( Lives ) )               PORT_DIPLOCATION("SW(C):1,2")
26052379   PORT_DIPSETTING(    0x00, "1" )
26062380   PORT_DIPSETTING(    0x03, "2" )
26072381   PORT_DIPSETTING(    0x02, "3" )
26082382   PORT_DIPSETTING(    0x01, "4" )
2609   PORT_DIPNAME( 0x04, 0x04, DEF_STR( Free_Play ) )
2383   PORT_DIPNAME( 0x04, 0x04, DEF_STR( Free_Play ) )            PORT_DIPLOCATION("SW(C):3")
26102384   PORT_DIPSETTING(    0x04, DEF_STR( Off ) )
26112385   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
2612   PORT_DIPNAME( 0x08, 0x08, "Freeze" )
2386   PORT_DIPNAME( 0x08, 0x08, "Freeze" )                     PORT_DIPLOCATION("SW(C):4")
26132387   PORT_DIPSETTING(    0x08, DEF_STR( Off ) )
26142388   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
2615   PORT_DIPNAME( 0x10, 0x10, DEF_STR( Flip_Screen ) )
2389   PORT_DIPNAME( 0x10, 0x10, DEF_STR( Flip_Screen ) )            PORT_DIPLOCATION("SW(C):5")
26162390   PORT_DIPSETTING(    0x10, DEF_STR( Off ) )
26172391   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
2618   PORT_DIPNAME( 0x20, 0x00, DEF_STR( Demo_Sounds ) )
2392   PORT_DIPNAME( 0x20, 0x00, DEF_STR( Demo_Sounds ) )            PORT_DIPLOCATION("SW(C):6")
26192393   PORT_DIPSETTING(    0x20, DEF_STR( Off ) )
26202394   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
2621   PORT_DIPNAME( 0x40, 0x00, DEF_STR( Allow_Continue ) )
2395   PORT_DIPNAME( 0x40, 0x00, DEF_STR( Allow_Continue ) )         PORT_DIPLOCATION("SW(C):7")
26222396   PORT_DIPSETTING(    0x40, DEF_STR( No ) )
26232397   PORT_DIPSETTING(    0x00, DEF_STR( Yes ) )
2624   PORT_DIPNAME( 0x80, 0x80, "Game Mode")
2398   PORT_DIPNAME( 0x80, 0x80, "Game Mode")                     PORT_DIPLOCATION("SW(C):8")
26252399   PORT_DIPSETTING(    0x80, "Game" )
26262400   PORT_DIPSETTING(    0x00, DEF_STR( Test ) )
26272401
r1293r1294
26762450   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
26772451
26782452   PORT_START_TAG("DSWA")
2679   CPS1_COINAGE_2
2680   PORT_DIPNAME( 0x08, 0x08, DEF_STR( Unused ) )
2681   PORT_DIPSETTING(    0x08, DEF_STR( Off ) )
2682   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
2683   PORT_DIPNAME( 0x10, 0x10, DEF_STR( Unused ) )
2684   PORT_DIPSETTING(    0x10, DEF_STR( Off ) )
2685   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
2686   PORT_DIPNAME( 0x20, 0x20, DEF_STR( Unused ) )
2687   PORT_DIPSETTING(    0x20, DEF_STR( Off ) )
2688   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
2689   PORT_DIPNAME( 0x40, 0x40, "2 Coins to Start, 1 to Continue" )
2453   CPS1_COINAGE_2( "SW(A)" )
2454   PORT_DIPUNUSED_DIPLOC( 0x08, 0x08, "SW(A):4" )
2455   PORT_DIPUNUSED_DIPLOC( 0x08, 0x08, "SW(A):5" )
2456   PORT_DIPUNUSED_DIPLOC( 0x08, 0x08, "SW(A):6" )
2457   PORT_DIPNAME( 0x40, 0x40, "2 Coins to Start, 1 to Continue" )   PORT_DIPLOCATION("SW(A):7")
26902458   PORT_DIPSETTING(    0x40, DEF_STR( Off ) )
26912459   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
2692   PORT_DIPNAME( 0x80, 0x80, DEF_STR( Unused ) )
2693   PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
2694   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
2460   PORT_DIPUNUSED_DIPLOC( 0x80, 0x80, "SW(A):8" )
26952461
26962462   PORT_START_TAG("DSWB")
2697   PORT_DIPNAME( 0x07, 0x04, "Enemy's attack frequency" )
2463   PORT_DIPNAME( 0x07, 0x04, "Enemy's attack frequency" )         PORT_DIPLOCATION("SW(B):1,2,3")
26982464   PORT_DIPSETTING(    0x07, "1 (Easiest)" )
26992465   PORT_DIPSETTING(    0x06, "2" )
27002466   PORT_DIPSETTING(    0x05, "3" )
r1293r1294
27032469   PORT_DIPSETTING(    0x02, "6" )
27042470   PORT_DIPSETTING(    0x01, "7" )
27052471   PORT_DIPSETTING(    0x00, "8 (Hardest)" )
2706   PORT_DIPNAME( 0x38, 0x38, "Enemy's attack power" )
2472   PORT_DIPNAME( 0x38, 0x38, "Enemy's attack power" )            PORT_DIPLOCATION("SW(B):4,5,6")
27072473   PORT_DIPSETTING(    0x00, "1 (Easiest)" )
27082474   PORT_DIPSETTING(    0x08, "2" )
27092475   PORT_DIPSETTING(    0x10, "3" )
r1293r1294
27122478   PORT_DIPSETTING(    0x28, "6" )
27132479   PORT_DIPSETTING(    0x20, "7" )
27142480   PORT_DIPSETTING(    0x18, "8 (Hardest)" )
2715   PORT_DIPNAME( 0x40, 0x40, "Coin Slots" )
2481   PORT_DIPNAME( 0x40, 0x40, "Coin Slots" )                  PORT_DIPLOCATION("SW(B):7")
27162482   PORT_DIPSETTING(    0x00, "1" )
27172483   PORT_DIPSETTING(    0x40, "3" )
2718   PORT_DIPNAME( 0x80, 0x80, "Play Mode" )
2484   PORT_DIPNAME( 0x80, 0x80, "Play Mode" )                     PORT_DIPLOCATION("SW(B):8")
27192485   PORT_DIPSETTING(    0x00, "2 Players" )
27202486   PORT_DIPSETTING(    0x80, "3 Players" )
27212487
27222488   PORT_START_TAG("DSWC")
2723   PORT_DIPNAME( 0x03, 0x03, DEF_STR( Lives ) )
2489   PORT_DIPNAME( 0x03, 0x03, DEF_STR( Lives ) )               PORT_DIPLOCATION("SW(C):1,2")
27242490   PORT_DIPSETTING(    0x00, "1" )
27252491   PORT_DIPSETTING(    0x03, "2" )
27262492   PORT_DIPSETTING(    0x02, "3" )
27272493   PORT_DIPSETTING(    0x01, "4" )
2728   PORT_DIPNAME( 0x04, 0x04, DEF_STR( Free_Play ) )
2494   PORT_DIPNAME( 0x04, 0x04, DEF_STR( Free_Play ) )            PORT_DIPLOCATION("SW(C):3")
27292495   PORT_DIPSETTING(    0x04, DEF_STR( Off ) )
27302496   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
2731   PORT_DIPNAME( 0x08, 0x08, "Freeze" )
2497   PORT_DIPNAME( 0x08, 0x08, "Freeze" )                     PORT_DIPLOCATION("SW(C):4")
27322498   PORT_DIPSETTING(    0x08, DEF_STR( Off ) )
27332499   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
2734   PORT_DIPNAME( 0x10, 0x10, DEF_STR( Flip_Screen ) )
2500   PORT_DIPNAME( 0x10, 0x10, DEF_STR( Flip_Screen ) )            PORT_DIPLOCATION("SW(C):5")
27352501   PORT_DIPSETTING(    0x10, DEF_STR( Off ) )
27362502   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
2737   PORT_DIPNAME( 0x20, 0x00, DEF_STR( Demo_Sounds ) )
2503   PORT_DIPNAME( 0x20, 0x00, DEF_STR( Demo_Sounds ) )            PORT_DIPLOCATION("SW(C):6")
27382504   PORT_DIPSETTING(    0x20, DEF_STR( Off ) )
27392505   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
2740   PORT_DIPNAME( 0x40, 0x00, DEF_STR( Allow_Continue ) )
2506   PORT_DIPNAME( 0x40, 0x00, DEF_STR( Allow_Continue ) )         PORT_DIPLOCATION("SW(C):7")
27412507   PORT_DIPSETTING(    0x40, DEF_STR( No ) )
27422508   PORT_DIPSETTING(    0x00, DEF_STR( Yes ) )
2743   PORT_DIPNAME( 0x80, 0x80, "Game Mode")
2509   PORT_DIPNAME( 0x80, 0x80, "Game Mode")                     PORT_DIPLOCATION("SW(C):8")
27442510   PORT_DIPSETTING(    0x80, "Game" )
27452511   PORT_DIPSETTING(    0x00, DEF_STR( Test ) )
27462512
r1293r1294
27852551   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
27862552
27872553   PORT_START_TAG("DSWA")
2788   CPS1_COINAGE_1
2789   PORT_DIPNAME( 0x40, 0x40, "2 Coins to Start, 1 to Continue" )
2554   CPS1_COINAGE_1( "SW(A)" )
2555   PORT_DIPNAME( 0x40, 0x40, "2 Coins to Start, 1 to Continue" )   PORT_DIPLOCATION("SW(A):7")
27902556   PORT_DIPSETTING(    0x40, DEF_STR( Off ) )
27912557   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
2792   PORT_DIPNAME( 0x80, 0x80, DEF_STR( Unused ) )
2793   PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
2794   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
2558   PORT_DIPUNUSED_DIPLOC( 0x80, 0x80, "SW(A):8" )
27952559
27962560   PORT_START_TAG("DSWB")
2797   CPS1_DIFFICULTY_1
2798   PORT_DIPNAME( 0x18, 0x10, DEF_STR( Bonus_Life ) )
2561   CPS1_DIFFICULTY_1( "SW(B)" )
2562   PORT_DIPNAME( 0x18, 0x10, DEF_STR( Bonus_Life ) )            PORT_DIPLOCATION("SW(B):4,5")
27992563   PORT_DIPSETTING(    0x18, "600k and every 1.400k" )
28002564   PORT_DIPSETTING(    0x10, "600k 2.000k and 4500k" )
28012565   PORT_DIPSETTING(    0x08, "1.200k 3.500k" )
28022566   PORT_DIPSETTING(    0x00, "2000k only" )
2803   PORT_DIPNAME( 0x20, 0x20, DEF_STR( Unused ) )
2804   PORT_DIPSETTING(    0x20, DEF_STR( Off ) )
2805   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
2806   PORT_DIPNAME( 0x40, 0x40, DEF_STR( Unused ) )
2807   PORT_DIPSETTING(    0x40, DEF_STR( Off ) )
2808   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
2809   PORT_DIPNAME( 0x80, 0x80, DEF_STR( Unused ) )
2810   PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
2811   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
2567   PORT_DIPUNUSED_DIPLOC( 0x20, 0x20, "SW(B):6" )
2568   PORT_DIPUNUSED_DIPLOC( 0x40, 0x40, "SW(B):7" )
2569   PORT_DIPUNUSED_DIPLOC( 0x80, 0x80, "SW(B):8" )
28122570
28132571   PORT_START_TAG("DSWC")
2814   PORT_DIPNAME( 0x03, 0x03, DEF_STR( Lives ) )
2572   PORT_DIPNAME( 0x03, 0x03, DEF_STR( Lives ) )               PORT_DIPLOCATION("SW(C):1,2")
28152573   PORT_DIPSETTING(    0x02, "1" )
28162574   PORT_DIPSETTING(    0x01, "2" )
28172575   PORT_DIPSETTING(    0x03, "3" )
28182576   PORT_DIPSETTING(    0x00, "4" )
2819   PORT_DIPNAME( 0x04, 0x04, DEF_STR( Free_Play ) )
2577   PORT_DIPNAME( 0x04, 0x04, DEF_STR( Free_Play ) )            PORT_DIPLOCATION("SW(C):3")
28202578   PORT_DIPSETTING(    0x04, DEF_STR( Off ) )
28212579   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
2822   PORT_DIPNAME( 0x08, 0x08, "Freeze" )
2580   PORT_DIPNAME( 0x08, 0x08, "Freeze" )                     PORT_DIPLOCATION("SW(C):4")
28232581   PORT_DIPSETTING(    0x08, DEF_STR( Off ) )
28242582   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
2825   PORT_DIPNAME( 0x10, 0x10, DEF_STR( Flip_Screen ) )
2583   PORT_DIPNAME( 0x10, 0x10, DEF_STR( Flip_Screen ) )            PORT_DIPLOCATION("SW(C):5")
28262584   PORT_DIPSETTING(    0x10, DEF_STR( Off ) )
28272585   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
2828   PORT_DIPNAME( 0x20, 0x00, DEF_STR( Demo_Sounds ) )
2586   PORT_DIPNAME( 0x20, 0x00, DEF_STR( Demo_Sounds ) )            PORT_DIPLOCATION("SW(C):6")
28292587   PORT_DIPSETTING(    0x20, DEF_STR( Off ) )
28302588   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
2831   PORT_DIPNAME( 0x40, 0x00, DEF_STR( Allow_Continue ) )
2589   PORT_DIPNAME( 0x40, 0x00, DEF_STR( Allow_Continue ) )         PORT_DIPLOCATION("SW(C):7")
28322590   PORT_DIPSETTING(    0x40, DEF_STR( No ) )
28332591   PORT_DIPSETTING(    0x00, DEF_STR( Yes ) )
2834   PORT_DIPNAME( 0x80, 0x80, "Game Mode")
2592   PORT_DIPNAME( 0x80, 0x80, "Game Mode")                     PORT_DIPLOCATION("SW(C):8")
28352593   PORT_DIPSETTING(    0x80, "Game" )
28362594   PORT_DIPSETTING(    0x00, DEF_STR( Test ) )
28372595
r1293r1294
28672625   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
28682626
28692627   PORT_START_TAG("DSWA")
2870   CPS1_COINAGE_2
2871   PORT_DIPNAME( 0x08, 0x08, DEF_STR( Unknown ) )
2872   PORT_DIPSETTING(    0x08, DEF_STR( Off ) )
2873   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
2874   PORT_DIPNAME( 0x10, 0x10, DEF_STR( Unknown ) )
2875   PORT_DIPSETTING(    0x10, DEF_STR( Off ) )
2876   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
2877   PORT_DIPNAME( 0x20, 0x20, DEF_STR( Unknown ) )
2878   PORT_DIPSETTING(    0x20, DEF_STR( Off ) )
2879   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
2880   PORT_DIPNAME( 0x40, 0x40, "2 Coins to Start, 1 to Continue" )
2628   CPS1_COINAGE_2( "SW(A)" )
2629   PORT_DIPUNKNOWN_DIPLOC( 0x08, 0x08, "SW(A):4" )
2630   PORT_DIPUNKNOWN_DIPLOC( 0x10, 0x10, "SW(A):5" )
2631   PORT_DIPUNKNOWN_DIPLOC( 0x20, 0x20, "SW(A):6" )
2632   PORT_DIPNAME( 0x40, 0x40, "2 Coins to Start, 1 to Continue" )   PORT_DIPLOCATION("SW(A):7")
28812633   PORT_DIPSETTING(    0x40, DEF_STR( Off ) )
28822634   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
2883   PORT_DIPNAME( 0x80, 0x80, "Extended Test Mode" )
2635   PORT_DIPNAME( 0x80, 0x80, "Extended Test Mode" )            PORT_DIPLOCATION("SW(A):8")
28842636   PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
28852637   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
28862638
28872639   PORT_START_TAG("DSWB")
2888   PORT_DIPNAME( 0x07, 0x06, DEF_STR( Difficulty ) )
2640   PORT_DIPNAME( 0x07, 0x06, DEF_STR( Difficulty ) )            PORT_DIPLOCATION("SW(B):1,2,3")
28892641   PORT_DIPSETTING(    0x06, "0" )
28902642   PORT_DIPSETTING(    0x05, "1" )
28912643   PORT_DIPSETTING(    0x04, "2" )
28922644   PORT_DIPSETTING(    0x03, "3" )
28932645   PORT_DIPSETTING(    0x02, "4" )
2894   PORT_DIPNAME( 0x18, 0x18, "Extend" )
2646   PORT_DIPNAME( 0x18, 0x18, "Extend" )                     PORT_DIPLOCATION("SW(B):4,5")
28952647   PORT_DIPSETTING(    0x18, "N" )
28962648   PORT_DIPSETTING(    0x10, "E" )
28972649   PORT_DIPSETTING(    0x00, "D" )
2898   PORT_DIPNAME( 0xe0, 0xe0, DEF_STR( Lives ) )
2650   PORT_DIPNAME( 0xe0, 0xe0, DEF_STR( Lives ) )               PORT_DIPLOCATION("SW(B):6,7,8")
28992651   PORT_DIPSETTING(    0x00, "1" )
29002652   PORT_DIPSETTING(    0x80, "2" )
29012653   PORT_DIPSETTING(    0xe0, "3" )
r1293r1294
29032655   PORT_DIPSETTING(    0xc0, "5" )
29042656
29052657   PORT_START_TAG("DSWC")
2906   PORT_DIPNAME( 0x01, 0x01, DEF_STR( Unknown ) )
2907   PORT_DIPSETTING(    0x01, DEF_STR( Off ) )
2908   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
2909   PORT_DIPNAME( 0x02, 0x02, DEF_STR( Unknown ) )
2910   PORT_DIPSETTING(    0x02, DEF_STR( Off ) )
2911   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
2912   PORT_DIPNAME( 0x04, 0x04, DEF_STR( Free_Play ) )
2658   PORT_DIPUNKNOWN_DIPLOC( 0x01, 0x01, "SW(C):1" )
2659   PORT_DIPUNKNOWN_DIPLOC( 0x02, 0x02, "SW(C):2" )
2660   PORT_DIPNAME( 0x04, 0x04, DEF_STR( Free_Play ) )            PORT_DIPLOCATION("SW(C):3")
29132661   PORT_DIPSETTING(    0x04, DEF_STR( Off ) )
29142662   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
2915   PORT_DIPNAME( 0x08, 0x08, "Freeze" )
2663   PORT_DIPNAME( 0x08, 0x08, "Freeze" )                     PORT_DIPLOCATION("SW(C):4")
29162664   PORT_DIPSETTING(    0x08, DEF_STR( Off ) )
29172665   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
2918   PORT_DIPNAME( 0x10, 0x10, DEF_STR( Flip_Screen ) )
2666   PORT_DIPNAME( 0x10, 0x10, DEF_STR( Flip_Screen ) )            PORT_DIPLOCATION("SW(C):5")
29192667   PORT_DIPSETTING(    0x10, DEF_STR( Off ) )
29202668   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
2921   PORT_DIPNAME( 0x20, 0x00, DEF_STR( Demo_Sounds ) )
2669   PORT_DIPNAME( 0x20, 0x00, DEF_STR( Demo_Sounds ) )            PORT_DIPLOCATION("SW(C):6")
29222670   PORT_DIPSETTING(    0x20, DEF_STR( Off ) )
29232671   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
2924   PORT_DIPNAME( 0x40, 0x40, DEF_STR( Allow_Continue ) )
2672   PORT_DIPNAME( 0x40, 0x40, DEF_STR( Allow_Continue ) )         PORT_DIPLOCATION("SW(C):7")
29252673   PORT_DIPSETTING(    0x00, DEF_STR( No ) )
29262674   PORT_DIPSETTING(    0x40, DEF_STR( Yes ) )
2927   PORT_DIPNAME( 0x80, 0x80, "Game Mode")
2675   PORT_DIPNAME( 0x80, 0x80, "Game Mode")                     PORT_DIPLOCATION("SW(C):8")
29282676   PORT_DIPSETTING(    0x80, "Game" )
29292677   PORT_DIPSETTING(    0x00, DEF_STR( Test ) )
29302678
r1293r1294
31752923   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
31762924
31772925   PORT_START_TAG("DSWA")
3178   CPS1_COINAGE_2
3179   PORT_DIPNAME( 0x08, 0x08, "Coin Slots" )
2926   CPS1_COINAGE_2( "SW(A)" )
2927   PORT_DIPNAME( 0x08, 0x08, "Coin Slots" )            PORT_DIPLOCATION("SW(A):4")
31802928   PORT_DIPSETTING(    0x08, "1" )
31812929   PORT_DIPSETTING(    0x00, "2" )
3182   PORT_DIPNAME( 0x10, 0x10, DEF_STR( Unknown ) )
3183   PORT_DIPSETTING(    0x10, DEF_STR( Off ) )
3184   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
3185   PORT_DIPNAME( 0x20, 0x20, DEF_STR( Unknown ) )
3186   PORT_DIPSETTING(    0x20, DEF_STR( Off ) )
3187   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
3188   PORT_DIPNAME( 0x40, 0x40, DEF_STR( Unknown ) )
3189   PORT_DIPSETTING(    0x40, DEF_STR( Off ) )
3190   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
3191   PORT_DIPNAME( 0x80, 0x80, DEF_STR( Unknown ) )
3192   PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
3193   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
2930   PORT_DIPUNKNOWN_DIPLOC( 0x10, 0x10, "SW(A):5" )
2931   PORT_DIPUNKNOWN_DIPLOC( 0x20, 0x20, "SW(A):6" )
2932   PORT_DIPUNKNOWN_DIPLOC( 0x40, 0x40, "SW(A):7" )
2933   PORT_DIPUNKNOWN_DIPLOC( 0x80, 0x80, "SW(A):8" )
31942934
31952935   PORT_START_TAG("DSWB")
3196   CPS1_DIFFICULTY_1
3197   PORT_DIPNAME( 0x08, 0x00, DEF_STR( Unknown ) )
3198   PORT_DIPSETTING(    0x08, DEF_STR( Off ) )
3199   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
3200   PORT_DIPNAME( 0x10, 0x10, DEF_STR( Unknown ) )
3201   PORT_DIPSETTING(    0x10, DEF_STR( Off ) )
3202   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
3203   PORT_DIPNAME( 0x20, 0x20, DEF_STR( Unknown ) )
3204   PORT_DIPSETTING(    0x20, DEF_STR( Off ) )
3205   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
3206   PORT_DIPNAME( 0xc0, 0xc0, "Vs Play Mode" )
2936   CPS1_DIFFICULTY_1( "SW(B)" )
2937   PORT_DIPUNKNOWN_DIPLOC( 0x08, 0x08, "SW(B):4" )
2938   PORT_DIPUNKNOWN_DIPLOC( 0x10, 0x10, "SW(B):5" )
2939   PORT_DIPUNKNOWN_DIPLOC( 0x20, 0x20, "SW(B):6" )
2940   PORT_DIPNAME( 0xc0, 0xc0, "Vs Play Mode" )            PORT_DIPLOCATION("SW(B):7,8")
32072941   PORT_DIPSETTING(    0xc0, "1 Game Match" )
32082942   PORT_DIPSETTING(    0x80, "3 Games Match" )
32092943   PORT_DIPSETTING(    0x40, "5 Games Match" )
32102944   PORT_DIPSETTING(    0x00, "7 Games Match" )
32112945
32122946   PORT_START_TAG("DSWC")
3213   PORT_DIPNAME( 0x01, 0x01, DEF_STR( Unknown ) )
3214   PORT_DIPSETTING(    0x01, DEF_STR( Off ) )
3215   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
3216   PORT_DIPNAME( 0x02, 0x02, DEF_STR( Unknown ) )
3217   PORT_DIPSETTING(    0x02, DEF_STR( Off ) )
3218   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
3219   PORT_DIPNAME( 0x04, 0x04, DEF_STR( Unknown ) )
3220   PORT_DIPSETTING(    0x04, DEF_STR( Off ) )
3221   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
3222   PORT_DIPNAME( 0x08, 0x08, "Freeze" )
2947   PORT_DIPUNKNOWN_DIPLOC( 0x01, 0x01, "SW(C):1" )
2948   PORT_DIPUNKNOWN_DIPLOC( 0x02, 0x02, "SW(C):2" )
2949   PORT_DIPUNKNOWN_DIPLOC( 0x04, 0x04, "SW(C):3" )
2950   PORT_DIPNAME( 0x08, 0x08, "Freeze" )               PORT_DIPLOCATION("SW(C):4")
32232951   PORT_DIPSETTING(    0x08, DEF_STR( Off ) )
32242952   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
3225   PORT_DIPNAME( 0x10, 0x10, DEF_STR( Flip_Screen ) )
2953   PORT_DIPNAME( 0x10, 0x10, DEF_STR( Flip_Screen ) )      PORT_DIPLOCATION("SW(C):5")
32262954   PORT_DIPSETTING(    0x10, DEF_STR( Off ) )
32272955   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
3228   PORT_DIPNAME( 0x20, 0x00, DEF_STR( Demo_Sounds ) )
2956   PORT_DIPNAME( 0x20, 0x00, DEF_STR( Demo_Sounds ) )      PORT_DIPLOCATION("SW(C):6")
32292957   PORT_DIPSETTING(    0x20, DEF_STR( Off ) )
32302958   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
3231   PORT_DIPNAME( 0x40, 0x40, DEF_STR( Unknown ) )
3232   PORT_DIPSETTING(    0x40, DEF_STR( Off ) )
3233   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
3234   PORT_DIPNAME( 0x80, 0x80, "Game Mode")
2959   PORT_DIPUNKNOWN_DIPLOC( 0x40, 0x40, "SW(C):7" )
2960   PORT_DIPNAME( 0x80, 0x80, "Game Mode")               PORT_DIPLOCATION("SW(C):8")
32352961   PORT_DIPSETTING(    0x80, "Game" )
32362962   PORT_DIPSETTING(    0x00, DEF_STR( Test ) )
32372963
r1293r1294
32672993   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
32682994
32692995   PORT_START_TAG("DSWA")
3270   CPS1_COINAGE_2
3271   PORT_DIPNAME( 0x08, 0x08, DEF_STR( Unknown ) )
3272   PORT_DIPSETTING(    0x08, DEF_STR( Off ) )
3273   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
3274   PORT_DIPNAME( 0x10, 0x10, DEF_STR( Unknown ) )
3275   PORT_DIPSETTING(    0x10, DEF_STR( Off ) )
3276   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
3277   PORT_DIPNAME( 0x20, 0x20, DEF_STR( Unknown ) )
3278   PORT_DIPSETTING(    0x20, DEF_STR( Off ) )
3279   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
3280   PORT_DIPNAME( 0x40, 0x40, "2 Coins to Start, 1 to Continue" )
2996   CPS1_COINAGE_2( "SW(A)" )
2997   PORT_DIPUNKNOWN_DIPLOC( 0x08, 0x08, "SW(A):4" )               // Manual says these are for coin 2, but they
2998   PORT_DIPUNKNOWN_DIPLOC( 0x10, 0x10, "SW(A):5" )               // coin to setting, but they clearly don't do
2999   PORT_DIPUNKNOWN_DIPLOC( 0x20, 0x20, "SW(A):6" )               // that.
3000   PORT_DIPNAME( 0x40, 0x40, "2 Coins to Start, 1 to Continue" )   PORT_DIPLOCATION("SW(A):7")
32813001   PORT_DIPSETTING(    0x40, DEF_STR( Off ) )
32823002   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
3283   PORT_DIPNAME( 0x80, 0x80, DEF_STR( Unused ) )
3284   PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
3285   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
3003   PORT_DIPUNUSED_DIPLOC( 0x80, 0x80, "SW(A):8" )
32863004
32873005   PORT_START_TAG("DSWB")
3288   PORT_DIPNAME( 0x07, 0x04, DEF_STR( Difficulty ) )
3289//  PORT_DIPSETTING(    0x07, DEF_STR( Easiest ) )
3290   PORT_DIPSETTING(    0x06, DEF_STR( Easiest ) )
3006   PORT_DIPNAME( 0x07, 0x04, DEF_STR( Difficulty ) )            PORT_DIPLOCATION("SW(B):1,2,3")
3007//  PORT_DIPSETTING(    0x07, DEF_STR( Easiest ) )                  // Controls overall difficulty
3008   PORT_DIPSETTING(    0x06, DEF_STR( Easiest ) )               // Manual documents duplicate settings
32913009   PORT_DIPSETTING(    0x05, DEF_STR( Easy ) )
32923010   PORT_DIPSETTING(    0x04, DEF_STR( Normal ) )
32933011   PORT_DIPSETTING(    0x03, DEF_STR( Hard ) )
32943012   PORT_DIPSETTING(    0x02, DEF_STR( Hardest ) )
32953013//  PORT_DIPSETTING(    0x01, DEF_STR( Hardest ) )
32963014//  PORT_DIPSETTING(    0x00, DEF_STR( Hardest ) )
3297   PORT_DIPNAME( 0x18, 0x10, "Wisdom" )
3298   PORT_DIPSETTING(    0x18, DEF_STR( Easy ) )
3015   PORT_DIPNAME( 0x18, 0x10, "Wisdom (questions to win game)" )   PORT_DIPLOCATION("SW(B):4,5")
3016   PORT_DIPSETTING(    0x18, DEF_STR( Easy ) )                  // Controls number of needed questions to finish
32993017   PORT_DIPSETTING(    0x10, DEF_STR( Normal ) )
33003018   PORT_DIPSETTING(    0x08, DEF_STR( Hard ) )
33013019   PORT_DIPSETTING(    0x00, DEF_STR( Hardest ) )
3302   PORT_DIPNAME( 0xe0, 0xe0, DEF_STR( Lives ) )
3020   PORT_DIPNAME( 0xe0, 0xe0, DEF_STR( Lives ) )               PORT_DIPLOCATION("SW(B):6,7,8")
33033021   PORT_DIPSETTING(    0x60, "1" )
33043022   PORT_DIPSETTING(    0x80, "2" )
33053023   PORT_DIPSETTING(    0xa0, "3" )
33063024   PORT_DIPSETTING(    0xc0, "4" )
33073025   PORT_DIPSETTING(    0xe0, "5" )
3308//  PORT_DIPSETTING(    0x40, "1" )
3026//  PORT_DIPSETTING(    0x40, "1" )                                 // These three settings are not documented
33093027//  PORT_DIPSETTING(    0x20, "1" )
33103028//  PORT_DIPSETTING(    0x00, "1" )
33113029
33123030   PORT_START_TAG("DSWC")
3313   PORT_DIPNAME( 0x01, 0x01, DEF_STR( Unused ) )
3314   PORT_DIPSETTING(    0x01, DEF_STR( Off ) )
3315   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
3316   PORT_DIPNAME( 0x02, 0x02, DEF_STR( Unused ) )
3317   PORT_DIPSETTING(    0x02, DEF_STR( Off ) )
3318   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
3319   PORT_DIPNAME( 0x04, 0x04, DEF_STR( Free_Play ) )
3031   PORT_DIPUNUSED_DIPLOC( 0x01, 0x01, "SW(C):1" )
3032   PORT_DIPUNUSED_DIPLOC( 0x02, 0x02, "SW(C):2" )
3033   PORT_DIPNAME( 0x04, 0x04, DEF_STR( Free_Play ) )            PORT_DIPLOCATION("SW(C):3")
33203034   PORT_DIPSETTING(    0x04, DEF_STR( Off ) )
33213035   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
3322   PORT_DIPNAME( 0x08, 0x08, "Freeze" )
3036   PORT_DIPNAME( 0x08, 0x08, "Freeze" )                     PORT_DIPLOCATION("SW(C):4")
33233037   PORT_DIPSETTING(    0x08, DEF_STR( Off ) )
33243038   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
3325   PORT_DIPNAME( 0x10, 0x10, DEF_STR( Flip_Screen ) )
3039   PORT_DIPNAME( 0x10, 0x10, DEF_STR( Flip_Screen ) )            PORT_DIPLOCATION("SW(C):5")
33263040   PORT_DIPSETTING(    0x10, DEF_STR( Off ) )
33273041   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
3328   PORT_DIPNAME( 0x20, 0x20, DEF_STR( Demo_Sounds ) )
3042   PORT_DIPNAME( 0x20, 0x20, DEF_STR( Demo_Sounds ) )            PORT_DIPLOCATION("SW(C):6")
33293043   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
33303044   PORT_DIPSETTING(    0x20, DEF_STR( On ) )
3331   PORT_DIPNAME( 0x40, 0x40, DEF_STR( Allow_Continue ) )
3045   PORT_DIPNAME( 0x40, 0x40, DEF_STR( Allow_Continue ) )         PORT_DIPLOCATION("SW(C):7")
33323046   PORT_DIPSETTING(    0x00, DEF_STR( No ) )
33333047   PORT_DIPSETTING(    0x40, DEF_STR( Yes ) )
3334   PORT_DIPNAME( 0x80, 0x80, "Game Mode")
3048   PORT_DIPNAME( 0x80, 0x80, "Game Mode")                     PORT_DIPLOCATION("SW(C):8")
33353049   PORT_DIPSETTING(    0x80, "Game" )
33363050   PORT_DIPSETTING(    0x00, DEF_STR( Test ) )
33373051
r1293r1294
33703084   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
33713085
33723086   PORT_START_TAG("DSWA")
3373   CPS1_COINAGE_2
3374   PORT_DIPNAME( 0x08, 0x08, DEF_STR( Unknown ) )
3375   PORT_DIPSETTING(    0x08, DEF_STR( Off ) )
3376   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
3377   PORT_DIPNAME( 0x10, 0x10, DEF_STR( Unknown ) )
3378   PORT_DIPSETTING(    0x10, DEF_STR( Off ) )
3379   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
3380   PORT_DIPNAME( 0x20, 0x20, DEF_STR( Unknown ) )
3381   PORT_DIPSETTING(    0x20, DEF_STR( Off ) )
3382   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
3383   PORT_DIPNAME( 0x40, 0x40, "2 Coins to Start, 1 to Continue" )
3087   CPS1_COINAGE_2( "SW(A)" )
3088   PORT_DIPUNKNOWN_DIPLOC( 0x08, 0x08, "SW(A):4" )               // Manual says these are for coin 2, but they
3089   PORT_DIPUNKNOWN_DIPLOC( 0x10, 0x10, "SW(A):5" )               // coin to setting, but they clearly don't do
3090   PORT_DIPUNKNOWN_DIPLOC( 0x20, 0x20, "SW(A):6" )               // that.
3091   PORT_DIPNAME( 0x40, 0x40, "2 Coins to Start, 1 to Continue" )   PORT_DIPLOCATION("SW(A):7")
33843092   PORT_DIPSETTING(    0x40, DEF_STR( Off ) )
33853093   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
3386   PORT_DIPNAME( 0x80, 0x80, DEF_STR( Unused ) )
3387   PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
3388   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
3094   PORT_DIPUNUSED_DIPLOC( 0x80, 0x80, "SW(A):8" )
33893095
33903096   PORT_START_TAG("DSWB")
3391   PORT_DIPNAME( 0x07, 0x07, DEF_STR( Difficulty ) )
3097   PORT_DIPNAME( 0x07, 0x07, DEF_STR( Difficulty ) )            PORT_DIPLOCATION("SW(B):1,2,3")
33923098   PORT_DIPSETTING(    0x07, "0" )
33933099   PORT_DIPSETTING(    0x06, "1" )
33943100   PORT_DIPSETTING(    0x05, "2" )
r1293r1294
33973103//  PORT_DIPSETTING(    0x02, "4" )
33983104//  PORT_DIPSETTING(    0x01, "4" )
33993105//  PORT_DIPSETTING(    0x00, "4" )
3400   PORT_DIPNAME( 0x08, 0x08, DEF_STR( Unknown ) )
3401   PORT_DIPSETTING(    0x08, DEF_STR( Off ) )
3402   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
3403   PORT_DIPNAME( 0x10, 0x10, DEF_STR( Unknown ) )
3404   PORT_DIPSETTING(    0x10, DEF_STR( Off ) )
3405   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
3406   PORT_DIPNAME( 0xe0, 0xe0, DEF_STR( Lives ) )
3106   PORT_DIPUNKNOWN_DIPLOC( 0x08, 0x08, "SW(B):4" )
3107   PORT_DIPUNKNOWN_DIPLOC( 0x10, 0x10, "SW(B):5" )
3108   PORT_DIPNAME( 0xe0, 0xe0, DEF_STR( Lives ) )               PORT_DIPLOCATION("SW(B):6,7,8")
34073109   PORT_DIPSETTING(    0xa0, "1" )
34083110   PORT_DIPSETTING(    0xc0, "2" )
34093111   PORT_DIPSETTING(    0xe0, "3" )
r1293r1294
34143116//  PORT_DIPSETTING(    0x60, "3" )
34153117
34163118   PORT_START_TAG("DSWC")
3417   PORT_DIPNAME( 0x01, 0x01, DEF_STR( Unknown ) )
3418   PORT_DIPSETTING(    0x01, DEF_STR( Off ) )
3419   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
3420   PORT_DIPNAME( 0x02, 0x02, DEF_STR( Unknown ) )
3421   PORT_DIPSETTING(    0x02, DEF_STR( Off ) )
3422   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
3423   PORT_DIPNAME( 0x04, 0x04, DEF_STR( Free_Play ) )
3119   PORT_DIPUNKNOWN_DIPLOC( 0x01, 0x01, "SW(C):1" )
3120   PORT_DIPUNKNOWN_DIPLOC( 0x02, 0x02, "SW(C):2" )
3121   PORT_DIPNAME( 0x04, 0x04, DEF_STR( Free_Play ) )            PORT_DIPLOCATION("SW(C):3")
34243122   PORT_DIPSETTING(    0x04, DEF_STR( Off ) )
34253123   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
3426   PORT_DIPNAME( 0x08, 0x08, "Freeze" )
3124   PORT_DIPNAME( 0x08, 0x08, "Freeze" )                     PORT_DIPLOCATION("SW(C):4")
34273125   PORT_DIPSETTING(    0x08, DEF_STR( Off ) )
34283126   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
3429   PORT_DIPNAME( 0x10, 0x10, DEF_STR( Flip_Screen ) )
3127   PORT_DIPNAME( 0x10, 0x10, DEF_STR( Flip_Screen ) )            PORT_DIPLOCATION("SW(C):5")
34303128   PORT_DIPSETTING(    0x10, DEF_STR( Off ) )
34313129   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
3432   PORT_DIPNAME( 0x20, 0x00, DEF_STR( Demo_Sounds ) )
3130   PORT_DIPNAME( 0x20, 0x00, DEF_STR( Demo_Sounds ) )            PORT_DIPLOCATION("SW(C):6")
34333131   PORT_DIPSETTING(    0x20, DEF_STR( Off ) )
34343132   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
3435   PORT_DIPNAME( 0x40, 0x40, DEF_STR( Allow_Continue ) )
3133   PORT_DIPNAME( 0x40, 0x40, DEF_STR( Allow_Continue ) )         PORT_DIPLOCATION("SW(C):7")
34363134   PORT_DIPSETTING(    0x00, DEF_STR( No ) )
34373135   PORT_DIPSETTING(    0x40, DEF_STR( Yes ) )
3438   PORT_DIPNAME( 0x80, 0x80, "Game Mode")
3136   PORT_DIPNAME( 0x80, 0x80, "Game Mode")                     PORT_DIPLOCATION("SW(C):8")
34393137   PORT_DIPSETTING(    0x80, "Game" )
34403138   PORT_DIPSETTING(    0x00, DEF_STR( Test ) )
34413139
r1293r1294
34773175   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
34783176
34793177   PORT_START_TAG("DSWA")
3480   CPS1_COINAGE_2
3481   PORT_DIPNAME( 0x08, 0x08, DEF_STR( Unknown ) )
3482   PORT_DIPSETTING(    0x08, DEF_STR( Off ) )
3483   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
3484   PORT_DIPNAME( 0x10, 0x10, DEF_STR( Unknown ) )
3485   PORT_DIPSETTING(    0x10, DEF_STR( Off ) )
3486   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
3487   PORT_DIPNAME( 0x20, 0x20, DEF_STR( Unknown ) )
3488   PORT_DIPSETTING(    0x20, DEF_STR( Off ) )
3489   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
3490   PORT_DIPNAME( 0x40, 0x40, "2 Coins to Start, 1 to Continue" )
3178   CPS1_COINAGE_2( "SW(A)" )
3179   PORT_DIPUNKNOWN_DIPLOC( 0x08, 0x08, "SW(A):4" )
3180   PORT_DIPUNKNOWN_DIPLOC( 0x10, 0x10, "SW(A):5" )
3181   PORT_DIPUNKNOWN_DIPLOC( 0x20, 0x20, "SW(A):6" )
3182   PORT_DIPNAME( 0x40, 0x40, "2 Coins to Start, 1 to Continue" )   PORT_DIPLOCATION("SW(A):7")
34913183   PORT_DIPSETTING(    0x40, DEF_STR( Off ) )
34923184   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
3493   PORT_DIPNAME( 0x80, 0x80, DEF_STR( Unknown ) )
3494   PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
3495   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
3185   PORT_DIPUNKNOWN_DIPLOC( 0x80, 0x80, "SW(A):8" )
34963186
34973187   PORT_START_TAG("DSWB")
3498   CPS1_DIFFICULTY_1
3499   PORT_DIPNAME( 0x08, 0x08, DEF_STR( Unknown ) )
3500   PORT_DIPSETTING(    0x08, DEF_STR( Off ) )
3501   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
3502   PORT_DIPNAME( 0x10, 0x10, DEF_STR( Unknown ) )
3503   PORT_DIPSETTING(    0x10, DEF_STR( Off ) )
3504   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
3505   PORT_DIPNAME( 0xe0, 0xe0, DEF_STR( Lives ) )
3188   CPS1_DIFFICULTY_1( "SW(B)" )
3189   PORT_DIPUNKNOWN_DIPLOC( 0x08, 0x08, "SW(B):4" )
3190   PORT_DIPUNKNOWN_DIPLOC( 0x10, 0x10, "SW(B):5" )
3191   PORT_DIPNAME( 0xe0, 0xe0, DEF_STR( Lives ) )               PORT_DIPLOCATION("SW(B):6,7,8")
35063192   PORT_DIPSETTING(    0x60, "1" )
35073193   PORT_DIPSETTING(    0x80, "2" )
35083194   PORT_DIPSETTING(    0xe0, "3" )
r1293r1294
35133199//  PORT_DIPSETTING(    0x00, "?" )
35143200
35153201   PORT_START_TAG("DSWC")
3516   PORT_DIPNAME( 0x01, 0x01, DEF_STR( Unknown ) )
3517   PORT_DIPSETTING(    0x01, DEF_STR( Off ) )
3518   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
3519   PORT_DIPNAME( 0x02, 0x02, "Infinite Lives (Cheat)")
3202   PORT_DIPUNKNOWN_DIPLOC( 0x01, 0x01, "SW(C):1" )
3203   PORT_DIPNAME( 0x02, 0x02, "Infinite Lives (Cheat)")            PORT_DIPLOCATION("SW(C):2")
35203204   PORT_DIPSETTING(    0x02, DEF_STR( Off ) )
35213205   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
3522   PORT_DIPNAME( 0x04, 0x04, DEF_STR( Free_Play ) )
3206   PORT_DIPNAME( 0x04, 0x04, DEF_STR( Free_Play ) )            PORT_DIPLOCATION("SW(C):3")
35233207   PORT_DIPSETTING(    0x04, DEF_STR( Off ) )
35243208   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
3525   PORT_DIPNAME( 0x08, 0x08, "Freeze" )
3209   PORT_DIPNAME( 0x08, 0x08, "Freeze" )                     PORT_DIPLOCATION("SW(C):4")
35263210   PORT_DIPSETTING(    0x08, DEF_STR( Off ) )
35273211   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
3528   PORT_DIPNAME( 0x10, 0x10, DEF_STR( Flip_Screen ) )
3212   PORT_DIPNAME( 0x10, 0x10, DEF_STR( Flip_Screen ) )            PORT_DIPLOCATION("SW(C):5")
35293213   PORT_DIPSETTING(    0x10, DEF_STR( Off ) )
35303214   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
3531   PORT_DIPNAME( 0x20, 0x00, DEF_STR( Demo_Sounds ) )
3215   PORT_DIPNAME( 0x20, 0x00, DEF_STR( Demo_Sounds ) )            PORT_DIPLOCATION("SW(C):6")
35323216   PORT_DIPSETTING(    0x20, DEF_STR( Off ) )
35333217   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
3534   PORT_DIPNAME( 0x40, 0x40, DEF_STR( Allow_Continue ) )
3218   PORT_DIPNAME( 0x40, 0x40, DEF_STR( Allow_Continue ) )         PORT_DIPLOCATION("SW(C):7")
35353219   PORT_DIPSETTING(    0x00, DEF_STR( No ) )
35363220   PORT_DIPSETTING(    0x40, DEF_STR( Yes ) )
3537   PORT_DIPNAME( 0x80, 0x80, "Game Mode")
3221   PORT_DIPNAME( 0x80, 0x80, "Game Mode")                     PORT_DIPLOCATION("SW(C):8")
35383222   PORT_DIPSETTING(    0x80, "Game" )
35393223   PORT_DIPSETTING(    0x00, DEF_STR( Test ) )
35403224
r1293r1294
36183302   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
36193303
36203304   PORT_START_TAG("DSWA")
3621   PORT_DIPNAME( 0x1f, 0x1f, DEF_STR( Coinage ) )
3305   PORT_DIPNAME( 0x1f, 0x1f, DEF_STR( Coinage ) )               PORT_DIPLOCATION("SW(A):1,2,3,4,5")
36223306   PORT_DIPSETTING(    0x0f, DEF_STR( 9C_1C ) )
36233307   PORT_DIPSETTING(    0x10, DEF_STR( 8C_1C ) )
36243308   PORT_DIPSETTING(    0x11, DEF_STR( 7C_1C ) )
r1293r1294
36393323   PORT_DIPSETTING(    0x17, DEF_STR( 1C_9C ) )
36403324   PORT_DIPSETTING(    0x0d, DEF_STR( Free_Play ) )
36413325   /* 0x00 to 0x0c 1 Coin/1 Credit */
3642   PORT_DIPNAME( 0x60, 0x60, "Coin slots" )
3326   PORT_DIPNAME( 0x60, 0x60, "Coin slots" )                  PORT_DIPLOCATION("SW(A):6,7")
36433327//  PORT_DIPSETTING(    0x00, "Invalid" )
3644   PORT_DIPSETTING(    0x40, "1, Individual" )
36453328   PORT_DIPSETTING(    0x20, "1, Common" )
36463329   PORT_DIPSETTING(    0x60, "2, Common" )
3647   PORT_DIPNAME( 0x80, 0x80, DEF_STR( Unknown ) )
3648   PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
3649   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
3330   PORT_DIPSETTING(    0x40, "2, Individual" )
3331   PORT_DIPUNKNOWN_DIPLOC( 0x80, 0x80, "SW(A):8" )
36503332
36513333   PORT_START_TAG("DSWB")
3652   PORT_DIPNAME( 0x03, 0x02, DEF_STR( Difficulty ) )
3334   PORT_DIPNAME( 0x03, 0x02, DEF_STR( Difficulty ) )            PORT_DIPLOCATION("SW(B):1,2")
36533335   PORT_DIPSETTING(    0x03, DEF_STR( Easy ) )
36543336   PORT_DIPSETTING(    0x02, DEF_STR( Normal ) )
36553337   PORT_DIPSETTING(    0x01, DEF_STR( Hard ) )
36563338   PORT_DIPSETTING(    0x00, DEF_STR( Hardest ) )
3657   PORT_DIPNAME( 0x0c, 0x0c, "Time" )
3339   PORT_DIPNAME( 0x0c, 0x0c, "Time" )                        PORT_DIPLOCATION("SW(B):3,4")
36583340   PORT_DIPSETTING(    0x0c, "100" )
36593341   PORT_DIPSETTING(    0x08, "90" )
36603342   PORT_DIPSETTING(    0x04, "70" )
36613343   PORT_DIPSETTING(    0x00, "60" )
3662   PORT_DIPNAME( 0x10, 0x10, DEF_STR( Unknown ) )
3663   PORT_DIPSETTING(    0x10, DEF_STR( Off ) )
3664   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
3665   PORT_DIPNAME( 0x20, 0x20, DEF_STR( Unknown ) )
3666   PORT_DIPSETTING(    0x20, DEF_STR( Off ) )
3667   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
3668   PORT_DIPNAME( 0x40, 0x40, "Voice" )
3344   PORT_DIPUNKNOWN_DIPLOC( 0x10, 0x10, "SW(B):5" )
3345   PORT_DIPUNKNOWN_DIPLOC( 0x20, 0x20, "SW(B):6" )
3346   PORT_DIPNAME( 0x40, 0x40, "Voice" )                        PORT_DIPLOCATION("SW(B):7")
36693347   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
36703348   PORT_DIPSETTING(    0x40, DEF_STR( On ) )
3671   PORT_DIPNAME( 0x80, 0x80, DEF_STR( Unknown ) )
3672   PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
3673   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
3349   PORT_DIPUNKNOWN_DIPLOC( 0x80, 0x80, "SW(B):8" )
36743350
36753351   PORT_START_TAG("DSWC")
3676   PORT_DIPNAME( 0x01, 0x01, DEF_STR( Flip_Screen ) )
3352   PORT_DIPNAME( 0x01, 0x01, DEF_STR( Flip_Screen ) )            PORT_DIPLOCATION("SW(C):1")
36773353   PORT_DIPSETTING(    0x01, DEF_STR( Off ) )
36783354   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
3679   PORT_DIPNAME( 0x02, 0x02, DEF_STR( Demo_Sounds ) )
3355   PORT_DIPNAME( 0x02, 0x02, DEF_STR( Demo_Sounds ) )            PORT_DIPLOCATION("SW(C):2")
36803356   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
36813357   PORT_DIPSETTING(    0x02, DEF_STR( On ) )
3682   PORT_DIPNAME( 0x04, 0x04, DEF_STR( Allow_Continue ) )
3358   PORT_DIPNAME( 0x04, 0x04, DEF_STR( Allow_Continue ) )         PORT_DIPLOCATION("SW(C):3")
36833359   PORT_DIPSETTING(    0x00, DEF_STR( No ) )
36843360   PORT_DIPSETTING(    0x04, DEF_STR( Yes ) )
3685   PORT_DIPNAME( 0x08, 0x08, DEF_STR( Unknown ) )
3686   PORT_DIPSETTING(    0x08, DEF_STR( Off ) )
3687   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
3688   PORT_DIPNAME( 0x10, 0x10, DEF_STR( Unknown ) )
3689   PORT_DIPSETTING(    0x10, DEF_STR( Off ) )
3690   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
3691   PORT_DIPNAME( 0x20, 0x20, DEF_STR( Unknown ) )
3692   PORT_DIPSETTING(    0x20, DEF_STR( Off ) )
3693   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
3694   PORT_DIPNAME( 0x40, 0x40, DEF_STR( Unknown ) )
3695   PORT_DIPSETTING(    0x40, DEF_STR( Off ) )
3696   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
3697   PORT_DIPNAME( 0x80, 0x80, "Game Mode")
3361   PORT_DIPUNKNOWN_DIPLOC( 0x08, 0x08, "SW(C):4" )
3362   PORT_DIPUNKNOWN_DIPLOC( 0x10, 0x10, "SW(C):5" )
3363   PORT_DIPUNKNOWN_DIPLOC( 0x20, 0x20, "SW(C):6" )
3364   PORT_DIPUNKNOWN_DIPLOC( 0x40, 0x40, "SW(C):7" )
3365   PORT_DIPNAME( 0x80, 0x80, "Game Mode")                     PORT_DIPLOCATION("SW(C):8")
36983366   PORT_DIPSETTING(    0x80, "Game" )
36993367   PORT_DIPSETTING(    0x00, DEF_STR( Test ) )
37003368
r1293r1294
37203388/* Needs further checking */
37213389/* Same as 'megaman' but no "Voice" Dip Switch */
37223390static INPUT_PORTS_START( rockmanj )
3723   PORT_START_TAG("IN0")
3724   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_COIN1 )
3725   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_COIN2 )
3726   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_SERVICE1 )
3727   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNKNOWN )
3728   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_START1 )
3729   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_START2 )
3730   PORT_SERVICE_NO_TOGGLE( 0x40, IP_ACTIVE_LOW )
3731   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
3391   PORT_INCLUDE(megaman)
37323392
3733   PORT_START_TAG("DSWA")
3734   PORT_DIPNAME( 0x1f, 0x1f, DEF_STR( Coinage ) )
3735   PORT_DIPSETTING(    0x0f, DEF_STR( 9C_1C ) )
3736   PORT_DIPSETTING(    0x10, DEF_STR( 8C_1C ) )
3737   PORT_DIPSETTING(    0x11, DEF_STR( 7C_1C ) )
3738   PORT_DIPSETTING(    0x12, DEF_STR( 6C_1C ) )
3739   PORT_DIPSETTING(    0x13, DEF_STR( 5C_1C ) )
3740   PORT_DIPSETTING(    0x14, DEF_STR( 4C_1C ) )
3741   PORT_DIPSETTING(    0x15, DEF_STR( 3C_1C ) )
3742   PORT_DIPSETTING(    0x16, DEF_STR( 2C_1C ) )
3743   PORT_DIPSETTING(    0x0e, "2 Coins to Start, 1 to Continue" )
3744   PORT_DIPSETTING(    0x1f, DEF_STR( 1C_1C ) )
3745   PORT_DIPSETTING(    0x1e, DEF_STR( 1C_2C ) )
3746   PORT_DIPSETTING(    0x1d, DEF_STR( 1C_3C ) )
3747   PORT_DIPSETTING(    0x1c, DEF_STR( 1C_4C ) )
3748   PORT_DIPSETTING(    0x1b, DEF_STR( 1C_5C ) )
3749   PORT_DIPSETTING(    0x1a, DEF_STR( 1C_6C ) )
3750   PORT_DIPSETTING(    0x19, DEF_STR( 1C_7C ) )
3751   PORT_DIPSETTING(    0x18, DEF_STR( 1C_8C ) )
3752   PORT_DIPSETTING(    0x17, DEF_STR( 1C_9C ) )
3753   PORT_DIPSETTING(    0x0d, DEF_STR( Free_Play ) )
3754   /* 0x00 to 0x0c 1 Coin/1 Credit */
3755   PORT_DIPNAME( 0x60, 0x60, "Coin slots" )
3756//  PORT_DIPSETTING(    0x00, "Invalid" )
3757   PORT_DIPSETTING(    0x40, "1, Individual" )
3758   PORT_DIPSETTING(    0x20, "1, Common" )
3759   PORT_DIPSETTING(    0x60, "2, Common" )
3760   PORT_DIPNAME( 0x80, 0x80, DEF_STR( Unknown ) )
3761   PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
3762   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
3763
3764   PORT_START_TAG("DSWB")
3765   PORT_DIPNAME( 0x03, 0x02, DEF_STR( Difficulty ) )
3766   PORT_DIPSETTING(    0x03, DEF_STR( Easy ) )
3767   PORT_DIPSETTING(    0x02, DEF_STR( Normal ) )
3768   PORT_DIPSETTING(    0x01, DEF_STR( Hard ) )
3769   PORT_DIPSETTING(    0x00, DEF_STR( Hardest ) )
3770   PORT_DIPNAME( 0x0c, 0x0c, "Time" )
3771   PORT_DIPSETTING(    0x0c, "100" )
3772   PORT_DIPSETTING(    0x08, "90" )
3773   PORT_DIPSETTING(    0x04, "70" )
3774   PORT_DIPSETTING(    0x00, "60" )
3775   PORT_DIPNAME( 0x10, 0x10, DEF_STR( Unknown ) )
3776   PORT_DIPSETTING(    0x10, DEF_STR( Off ) )
3777   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
3778   PORT_DIPNAME( 0x20, 0x20, DEF_STR( Unknown ) )
3779   PORT_DIPSETTING(    0x20, DEF_STR( Off ) )
3780   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
3781   PORT_DIPNAME( 0x40, 0x40, DEF_STR( Unknown ) )
3782   PORT_DIPSETTING(    0x40, DEF_STR( Off ) )
3783   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
3784   PORT_DIPNAME( 0x80, 0x80, DEF_STR( Unknown ) )
3785   PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
3786   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
3787
3788   PORT_START_TAG("DSWC")
3789   PORT_DIPNAME( 0x01, 0x01, DEF_STR( Flip_Screen ) )
3790   PORT_DIPSETTING(    0x01, DEF_STR( Off ) )
3791   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
3792   PORT_DIPNAME( 0x02, 0x02, DEF_STR( Demo_Sounds ) )
3793   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
3794   PORT_DIPSETTING(    0x02, DEF_STR( On ) )
3795   PORT_DIPNAME( 0x04, 0x04, DEF_STR( Allow_Continue ) )
3796   PORT_DIPSETTING(    0x00, DEF_STR( No ) )
3797   PORT_DIPSETTING(    0x04, DEF_STR( Yes ) )
3798   PORT_DIPNAME( 0x08, 0x08, DEF_STR( Unknown ) )
3799   PORT_DIPSETTING(    0x08, DEF_STR( Off ) )
3800   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
3801   PORT_DIPNAME( 0x10, 0x10, DEF_STR( Unknown ) )
3802   PORT_DIPSETTING(    0x10, DEF_STR( Off ) )
3803   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
3804   PORT_DIPNAME( 0x20, 0x20, DEF_STR( Unknown ) )
3805   PORT_DIPSETTING(    0x20, DEF_STR( Off ) )
3806   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
3807   PORT_DIPNAME( 0x40, 0x40, DEF_STR( Unknown ) )
3808   PORT_DIPSETTING(    0x40, DEF_STR( Off ) )
3809   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
3810   PORT_DIPNAME( 0x80, 0x80, "Game Mode")
3811   PORT_DIPSETTING(    0x80, "Game" )
3812   PORT_DIPSETTING(    0x00, DEF_STR( Test ) )
3813
3814   PORT_START_TAG("IN1")
3815   PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_8WAY PORT_PLAYER(1)
3816   PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_8WAY PORT_PLAYER(1)
3817   PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_8WAY PORT_PLAYER(1)
3818   PORT_BIT( 0x0008, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_8WAY PORT_PLAYER(1)
3819   PORT_BIT( 0x0010, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(1)
3820   PORT_BIT( 0x0020, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(1)
3821   PORT_BIT( 0x0040, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_PLAYER(1)
3822   PORT_BIT( 0x0080, IP_ACTIVE_LOW, IPT_UNKNOWN )
3823   PORT_BIT( 0x0100, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_8WAY PORT_PLAYER(2)
3824   PORT_BIT( 0x0200, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_8WAY PORT_PLAYER(2)
3825   PORT_BIT( 0x0400, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_8WAY PORT_PLAYER(2)
3826   PORT_BIT( 0x0800, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_8WAY PORT_PLAYER(2)
3827   PORT_BIT( 0x1000, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(2)
3828   PORT_BIT( 0x2000, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(2)
3829   PORT_BIT( 0x4000, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_PLAYER(2)
3830   PORT_BIT( 0x8000, IP_ACTIVE_LOW, IPT_UNKNOWN )
3393   PORT_MODIFY("DSWB")
3394   PORT_DIPUNKNOWN_DIPLOC( 0x40, 0x40, "SW(B):7" )
38313395INPUT_PORTS_END
38323396
38333397/*
r1293r1294
78567420GAME( 1992, sf2ceua,  sf2ce,    sf2,      sf2,      cps1,     ROT0,   "Capcom", "Street Fighter II' - Champion Edition (US 920313)", 0 )
78577421GAME( 1992, sf2ceub,  sf2ce,    sf2,      sf2,      cps1,     ROT0,   "Capcom", "Street Fighter II' - Champion Edition (US 920513)", 0 )
78587422GAME( 1992, sf2ceuc,  sf2ce,    sf2,      sf2,      cps1,     ROT0,   "Capcom", "Street Fighter II' - Champion Edition (US 920803)", 0 )
7859GAME( 1992, sf2cej,   sf2ce,    sf2,      sf2j,     cps1,     ROT0,   "Capcom", "Street Fighter II' - Champion Edition (Japan 920513)", 0 )
7423GAME( 1992, sf2cej,   sf2ce,    sf2,      sf2,      cps1,     ROT0,   "Capcom", "Street Fighter II' - Champion Edition (Japan 920513)", 0 )
78607424GAME( 1992, sf2rb,    sf2ce,    sf2,      sf2,      cps1,     ROT0,   "bootleg","Street Fighter II' - Champion Edition (Rainbow set 1)" , 0)   // 920322 - based on World version
78617425GAME( 1992, sf2rb2,   sf2ce,    sf2,      sf2,      cps1,     ROT0,   "bootleg","Street Fighter II' - Champion Edition (Rainbow set 2)" , 0)   // 920322 - based on World version
78627426GAME( 1992, sf2red,   sf2ce,    sf2,      sf2,      cps1,     ROT0,   "bootleg","Street Fighter II' - Champion Edition (Red Wave)" , 0)      // 920313 - based on World version
r1293r1294
78837447GAME( 1994, qadj,     qad,      cps1,     qadj,     cps1,     ROT0,   "Capcom", "Quiz & Dragons (Japan 940921)", 0 )
78847448GAME( 1995, qtono2,   0,        cps1,     qtono2,   cps1,     ROT0,   "Capcom", "Quiz Tonosama no Yabou 2 Zenkoku-ban (Japan 950123)", 0 )
78857449GAME( 1995, megaman,  0,        cps1,     megaman,  cps1,     ROT0,   "Capcom", "Mega Man - The Power Battle (CPS1 Asia 951006)", 0 )
7886GAME( 1995, rockmanj, megaman,  cps1,     megaman, cps1,     ROT0,   "Capcom", "Rockman - The Power Battle (CPS1 Japan 950922)", 0 )
7450GAME( 1995, rockmanj, megaman,  cps1,     rockmanj, cps1,     ROT0,   "Capcom", "Rockman - The Power Battle (CPS1 Japan 950922)", 0 )
78877451
78887452GAME( 1992, wof,      0,        qsound,   wof,      wof,      ROT0,   "Capcom", "Warriors of Fate (World 921002)" , 0)            // "ETC"
78897453GAME( 1992, wofa,     wof,      qsound,   wof,      wof,      ROT0,   "Capcom", "Sangokushi II (Asia 921005)" , 0)               // World "warning"
src/mame/drivers/wiz.c
r1293r1294
650650   16         /* Output bit is feedback bit */
651651};
652652
653DISCRETE_SOUND_START(stinger)
653static DISCRETE_SOUND_START(stinger)
654654
655655#define STINGER_SHOT_OUT   NODE_90
656656#define STINGER_BOOM_OUT   NODE_91
src/mame/drivers/gaelco3d.c
r1293r1294
162162static UINT8 analog_ports[4];
163163static UINT8 framenum;
164164
165static mame_timer *adsp_autobuffer_timer;
165static emu_timer *adsp_autobuffer_timer;
166166static UINT16 *adsp_control_regs;
167167static UINT16 *adsp_fastram_base;
168168static UINT8 adsp_ireg;
r1293r1294
197197   cpunum_set_info_fct(2, CPUINFO_PTR_ADSP2100_TX_HANDLER, (genf *)adsp_tx_callback);
198198
199199   /* allocate a timer for feeding the autobuffer */
200   adsp_autobuffer_timer = mame_timer_alloc(adsp_autobuffer_irq);
200   adsp_autobuffer_timer = timer_alloc(adsp_autobuffer_irq);
201201
202202   memory_configure_bank(1, 0, 256, memory_region(REGION_USER1), 0x4000);
203203   memory_set_bank(1, 0);
r1293r1294
527527         if ((data & 0x0800) == 0)
528528         {
529529            dmadac_enable(0, SOUND_CHANNELS, 0);
530            mame_timer_adjust(adsp_autobuffer_timer, time_never, 0, time_never);
530            timer_adjust(adsp_autobuffer_timer, attotime_never, 0, attotime_never);
531531         }
532532         break;
533533
r1293r1294
536536         if ((data & 0x0002) == 0)
537537         {
538538            dmadac_enable(0, SOUND_CHANNELS, 0);
539            mame_timer_adjust(adsp_autobuffer_timer, time_never, 0, time_never);
539            timer_adjust(adsp_autobuffer_timer, attotime_never, 0, attotime_never);
540540         }
541541         break;
542542
r1293r1294
607607         /* get the autobuffer registers */
608608         int      mreg, lreg;
609609         UINT16   source;
610         mame_time sample_period;
610         attotime sample_period;
611611
612612         adsp_ireg = (adsp_control_regs[S1_AUTOBUF_REG] >> 9) & 7;
613613         mreg = (adsp_control_regs[S1_AUTOBUF_REG] >> 7) & 3;
r1293r1294
632632         /* calculate how long until we generate an interrupt */
633633
634634         /* period per each bit sent */
635         sample_period = scale_up_mame_time(MAME_TIME_IN_HZ(Machine->drv->cpu[2].clock), 2 * (adsp_control_regs[S1_SCLKDIV_REG] + 1));
635         sample_period = attotime_mul(ATTOTIME_IN_HZ(Machine->drv->cpu[2].clock), 2 * (adsp_control_regs[S1_SCLKDIV_REG] + 1));
636636
637637         /* now put it down to samples, so we know what the channel frequency has to be */
638         sample_period = scale_up_mame_time(sample_period, 16 * SOUND_CHANNELS);
638         sample_period = attotime_mul(sample_period, 16 * SOUND_CHANNELS);
639639
640          dmadac_set_frequency(0, SOUND_CHANNELS, SUBSECONDS_TO_HZ(sample_period.subseconds));
640          dmadac_set_frequency(0, SOUND_CHANNELS, ATTOSECONDS_TO_HZ(sample_period.attoseconds));
641641         dmadac_enable(0, SOUND_CHANNELS, 1);
642642
643643         /* fire off a timer wich will hit every half-buffer */
644         sample_period = scale_down_mame_time(scale_up_mame_time(sample_period, adsp_size), SOUND_CHANNELS * adsp_incs);
644         sample_period = attotime_div(attotime_mul(sample_period, adsp_size), SOUND_CHANNELS * adsp_incs);
645645
646         mame_timer_adjust(adsp_autobuffer_timer, sample_period, 0, sample_period);
646         timer_adjust(adsp_autobuffer_timer, sample_period, 0, sample_period);
647647
648648         return;
649649      }
r1293r1294
655655   dmadac_enable(0, SOUND_CHANNELS, 0);
656656
657657   /* remove timer */
658   mame_timer_adjust(adsp_autobuffer_timer, time_never, 0, time_never);
658   timer_adjust(adsp_autobuffer_timer, attotime_never, 0, attotime_never);
659659}
660660
661661
r1293r1294
937937};
938938
939939
940MACHINE_DRIVER_START( gaelco3d )
940static MACHINE_DRIVER_START( gaelco3d )
941941
942942   /* basic machine hardware */
943943   MDRV_CPU_ADD_TAG("main", M68000, 15000000)
r1293r1294
987987MACHINE_DRIVER_END
988988
989989
990MACHINE_DRIVER_START( gaelco3d2 )
990static MACHINE_DRIVER_START( gaelco3d2 )
991991   MDRV_IMPORT_FROM(gaelco3d)
992992
993993   /* basic machine hardware */
src/mame/drivers/namcos11.c
r1293r1294
822822static DRIVER_INIT( namcos11 )
823823{
824824   int n_game;
825   mame_timer *timer;
825   emu_timer *timer;
826826
827   timer = mame_timer_alloc( mcu_timer );
828   mame_timer_adjust( timer, MAME_TIME_IN_HZ( 600 ), 0, MAME_TIME_IN_HZ( 600 ) );
827   timer = timer_alloc( mcu_timer );
828   timer_adjust( timer, ATTOTIME_IN_HZ( 600 ), 0, ATTOTIME_IN_HZ( 600 ) );
829829
830830   psx_driver_init();
831831   namcoc7x_on_driver_init();
src/mame/drivers/lethalj.c
r1293r1294
501501 *
502502 *************************************/
503503
504MACHINE_DRIVER_START( gameroom )
504static MACHINE_DRIVER_START( gameroom )
505505
506506   /* basic machine hardware */
507507   MDRV_CPU_ADD_TAG("main", TMS34010, 40000000/TMS34010_CLOCK_DIVIDER)
r1293r1294
536536MACHINE_DRIVER_END
537537
538538
539MACHINE_DRIVER_START( lethalj )
539static MACHINE_DRIVER_START( lethalj )
540540   MDRV_IMPORT_FROM( gameroom )
541541
542542   MDRV_CPU_MODIFY("main")
src/mame/drivers/itech8.c
r1293r1294
622622   machine_start_itech8(machine);
623623
624624   /* we need to update behind the beam as well */
625   mame_timer_set(video_screen_get_time_until_pos(0, 0, 0), 32, behind_the_beam_update);
625   timer_set(video_screen_get_time_until_pos(0, 0, 0), 32, behind_the_beam_update);
626626}
627627
628628static MACHINE_RESET( itech8 )
r1293r1294
674674   if (scanline >= 256) scanline = 0;
675675
676676   /* set a new timer */
677   mame_timer_set(video_screen_get_time_until_pos(0, scanline, 0), (scanline << 8) + interval, behind_the_beam_update);
677   timer_set(video_screen_get_time_until_pos(0, scanline, 0), (scanline << 8) + interval, behind_the_beam_update);
678678}
679679
680680
src/mame/drivers/gstriker.c
r1293r1294
176176******************************************************************************/
177177
178178
179UINT16 *gs_videoram3;
180UINT16 *gs_mixer_regs;
179//UINT16 *gs_videoram3;
180static UINT16 *gs_mixer_regs;
181181
182182/* in video */
183183VIDEO_UPDATE( gstriker );
r1293r1294
446446   MDRV_CPU_IO_MAP(sound_readport,sound_writeport)
447447
448448   MDRV_SCREEN_REFRESH_RATE(60)
449   MDRV_SCREEN_VBLANK_TIME(USEC_TO_SUBSECONDS(5000) /* hand-tuned, it needs a bit */)
449   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(5000) /* hand-tuned, it needs a bit */)
450450
451451   MDRV_VIDEO_ATTRIBUTES(VIDEO_TYPE_RASTER | VIDEO_UPDATE_AFTER_VBLANK)
452452   MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16)
src/mame/drivers/snk.c
r1293r1294
236236INTERRUPT_GEN( snk_irq_AB )
237237{
238238   cpunum_set_input_line(0, 0, HOLD_LINE);
239   mame_timer_set(MAME_TIME_IN_USEC(snk_irq_delay), 1, irq_trigger_callback);
239   timer_set(ATTOTIME_IN_USEC(snk_irq_delay), 1, irq_trigger_callback);
240240}
241241
242242INTERRUPT_GEN( snk_irq_BA )
243243{
244244   cpunum_set_input_line(1, 0, HOLD_LINE);
245   mame_timer_set(MAME_TIME_IN_USEC(snk_irq_delay), 0, irq_trigger_callback);
245   timer_set(ATTOTIME_IN_USEC(snk_irq_delay), 0, irq_trigger_callback);
246246}
247247
248248// NMI handshakes between CPUs are determined to be much simpler
r1293r1294
356356   return snk_sound_register;// | 0x2; /* hack; lets chopper1 play music */
357357}
358358
359void snk_sound_callback0_w( int state ){ /* ? */
359static void snk_sound_callback0_w( int state ){ /* ? */
360360   if( state ) snk_sound_register |= 0x01;
361361}
362362
363void snk_sound_callback1_w( int state ){ /* ? */
363static void snk_sound_callback1_w( int state ){ /* ? */
364364   if( state ) snk_sound_register |= 0x02;
365365}
366366
r1293r1294
11851185   MDRV_CPU_VBLANK_INT(irq0_line_hold,1)
11861186
11871187   MDRV_SCREEN_REFRESH_RATE(60)
1188   MDRV_SCREEN_VBLANK_TIME(USEC_TO_SUBSECONDS(1000))
1188   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(1000))
11891189   MDRV_INTERLEAVE(300)
11901190
11911191   /* video hardware */
r1293r1294
12301230   MDRV_CPU_VBLANK_INT(irq0_line_hold,1)
12311231
12321232   MDRV_SCREEN_REFRESH_RATE(60)
1233   MDRV_SCREEN_VBLANK_TIME(USEC_TO_SUBSECONDS(1000))
1233   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(1000))
12341234   MDRV_INTERLEAVE(300)
12351235
12361236   /* video hardware */
src/mame/drivers/hyprduel.c
r1293r1294
140140         cpunum_set_input_line(1, INPUT_LINE_RESET, CLEAR_LINE);
141141         subcpu_resetline = 0;
142142         if (pc == 0xbb0 || pc == 0x9d30 || pc == 0xb19c)
143            cpu_spinuntil_time(MAME_TIME_IN_USEC(15000));      /* sync semaphore */
143            cpu_spinuntil_time(ATTOTIME_IN_USEC(15000));      /* sync semaphore */
144144      }
145145      else if (subcpu_resetline == -1)
146146      {
r1293r1294
185185   cpunum_set_input_line(1, 2, HOLD_LINE);
186186}
187187
188INTERRUPT_GEN( hyprduel_interrupt )
188static INTERRUPT_GEN( hyprduel_interrupt )
189189{
190190   int line = RASTER_LINES - cpu_getiloops();
191191
r1293r1294
196196      cpunum_set_input_line(0, 2, HOLD_LINE);
197197      cpunum_set_input_line(1, 1, HOLD_LINE);
198198      /* the duration is a guess */
199      mame_timer_set(MAME_TIME_IN_USEC(2500), 0x20, vblank_end_callback);
199      timer_set(ATTOTIME_IN_USEC(2500), 0x20, vblank_end_callback);
200200      rastersplit = 0;
201201   } else {
202202      requested_int |= 0x12;      /* hsync */
r1293r1294
285285
286286***************************************************************************/
287287
288UINT16 *hyprduel_blitter_regs;
288static UINT16 *hyprduel_blitter_regs;
289289
290290static TIMER_CALLBACK( hyprduel_blit_done )
291291{
r1293r1294
367367                       another blit. */
368368               if (b1 == 0)
369369               {
370                  mame_timer_set(MAME_TIME_IN_USEC(500),0,hyprduel_blit_done);
370                  timer_set(ATTOTIME_IN_USEC(500),0,hyprduel_blit_done);
371371                  return;
372372               }
373373
src/mame/drivers/namconb1.c
r1293r1294
347347   }
348348   if( scanline < NAMCONB1_VBSTART )
349349   {
350      mame_timer_set( video_screen_get_time_until_pos(0, scanline, 0), scanline, namconb2_TriggerPOSIRQ );
350      timer_set( video_screen_get_time_until_pos(0, scanline, 0), scanline, namconb2_TriggerPOSIRQ );
351351   }
352352} /* namconb2_interrupt */
353353static INTERRUPT_GEN( namconb1_interrupt )
r1293r1294
395395   }
396396   if( scanline < NAMCONB1_VBSTART )
397397   {
398      mame_timer_set( video_screen_get_time_until_pos(0, scanline, 0), scanline, namconb1_TriggerPOSIRQ );
398      timer_set( video_screen_get_time_until_pos(0, scanline, 0), scanline, namconb1_TriggerPOSIRQ );
399399   }
400400} /* namconb1_interrupt */
401401
src/mame/drivers/fcrash.c
r1293r1294
4040/* not verified */
4141#define CPS1_ROWSCROLL_OFFS     0x20    /* base of row scroll offsets in other RAM */
4242
43void fcrash_update_transmasks(void)
43static void fcrash_update_transmasks(void)
4444{
4545   int i;
4646   int priority[4];
r1293r1294
6565   }
6666}
6767
68void fcrash_render_sprites(running_machine *machine, mame_bitmap *bitmap,const rectangle *cliprect)
68static void fcrash_render_sprites(running_machine *machine, mame_bitmap *bitmap,const rectangle *cliprect)
6969{
7070   int pos;
7171   int base=0x50c8/2; // and 10c8/2 for the buffer?
r1293r1294
9292
9393}
9494
95void fcrash_render_layer(running_machine *machine, mame_bitmap *bitmap,const rectangle *cliprect,int layer,int primask)
95static void fcrash_render_layer(running_machine *machine, mame_bitmap *bitmap,const rectangle *cliprect,int layer,int primask)
9696{
9797   switch (layer)
9898   {
r1293r1294
107107   }
108108}
109109
110void fcrash_render_high_layer(mame_bitmap *bitmap, const rectangle *cliprect, int layer)
110static void fcrash_render_high_layer(mame_bitmap *bitmap, const rectangle *cliprect, int layer)
111111{
112112   switch (layer)
113113   {
src/mame/drivers/suprslam.c
r1293r1294
336336   MDRV_CPU_IO_MAP(suprslam_sound_readport,suprslam_sound_writeport)
337337
338338   MDRV_SCREEN_REFRESH_RATE(60)
339   MDRV_SCREEN_VBLANK_TIME(USEC_TO_SUBSECONDS(2300) /* hand-tuned */)
339   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(2300) /* hand-tuned */)
340340
341341   MDRV_GFXDECODE(suprslam)
342342
src/mame/drivers/atetris.c
r1293r1294
8484   scanline += 32;
8585   if (scanline >= 256)
8686      scanline -= 256;
87   mame_timer_set(video_screen_get_time_until_pos(0, scanline, 0), scanline, interrupt_gen);
87   timer_set(video_screen_get_time_until_pos(0, scanline, 0), scanline, interrupt_gen);
8888}
8989
9090
r1293r1294
109109   memcpy(slapstic_base, &slapstic_source[current_bank * 0x4000], 0x4000);
110110
111111   /* start interrupts going (32V clocked by 16V) */
112   mame_timer_set(video_screen_get_time_until_pos(0, 48, 0), 48, interrupt_gen);
112   timer_set(video_screen_get_time_until_pos(0, 48, 0), 48, interrupt_gen);
113113}
114114
115115
src/mame/drivers/troangel.c
r1293r1294
205205   MDRV_CPU_VBLANK_INT(irq0_line_hold,1)
206206
207207   MDRV_SCREEN_REFRESH_RATE(57)
208   MDRV_SCREEN_VBLANK_TIME(USEC_TO_SUBSECONDS(1790)   /* accurate frequency, measured on a Moon Patrol board, is 56.75Hz. */)
208   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(1790)   /* accurate frequency, measured on a Moon Patrol board, is 56.75Hz. */)
209209            /* the Lode Runner manual (similar but different hardware) */
210210            /* talks about 55Hz and 1790ms vblank duration. */
211211
src/mame/drivers/sangho.c
r1293r1294
178178INPUT_PORTS_END
179179
180180
181void sangho_common_machine_reset(void)
181static void sangho_common_machine_reset(void)
182182{
183183   memory_set_bankptr(1,&sangho_ram[0]);
184184   memory_set_bankptr(2,&sangho_ram[0x4000]);
r1293r1294
211211   sangho_common_machine_reset();
212212}
213213
214void msx_vdp_interrupt(int i)
214static void msx_vdp_interrupt(int i)
215215{
216216   cpunum_set_input_line (0, 0, (i ? HOLD_LINE : CLEAR_LINE));
217217}
src/mame/drivers/shaolins.c
r1293r1294
2323extern VIDEO_UPDATE( shaolins );
2424
2525
26INTERRUPT_GEN( shaolins_interrupt )
26static INTERRUPT_GEN( shaolins_interrupt )
2727{
2828   if (cpu_getiloops() == 0) cpunum_set_input_line(0, 0, HOLD_LINE);
2929   else if (cpu_getiloops() % 2)
src/mame/drivers/model2.c
r1293r1294
7373
7474static UINT32 model2_timervals[4], model2_timerorig[4];
7575static int      model2_timerrun[4];
76static mame_timer *model2_timers[4];
76static emu_timer *model2_timers[4];
7777static int model2_ctrlmode;
7878
7979static UINT32 *tgp_program;
r1293r1294
176176      i960_stall();
177177
178178      /* spin the main cpu and let the TGP catch up */
179      cpu_spinuntil_time(MAME_TIME_IN_USEC(100));
179      cpu_spinuntil_time(ATTOTIME_IN_USEC(100));
180180
181181      return 0;
182182   }
r1293r1294
283283   if (model2_timerrun[offset])
284284   {
285285      // get elapsed time, convert to units of 25 MHz
286      UINT32 cur = mame_time_to_double(scale_up_mame_time(mame_timer_timeelapsed(model2_timers[offset]), 25000000));
286      UINT32 cur = attotime_to_double(attotime_mul(timer_timeelapsed(model2_timers[offset]), 25000000));
287287
288288      // subtract units from starting value
289289      model2_timervals[offset] = model2_timerorig[offset] - cur;
r1293r1294
294294
295295static WRITE32_HANDLER( timers_w )
296296{
297   mame_time period;
297   attotime period;
298298
299299   i960_noburst();
300300   COMBINE_DATA(&model2_timervals[offset]);
301301
302302   model2_timerorig[offset] = model2_timervals[offset];
303   period = scale_up_mame_time(MAME_TIME_IN_HZ(25000000), model2_timerorig[offset]);
304   mame_timer_adjust(model2_timers[offset], period, 0, time_zero);
303   period = attotime_mul(ATTOTIME_IN_HZ(25000000), model2_timerorig[offset]);
304   timer_adjust(model2_timers[offset], period, 0, attotime_zero);
305305   model2_timerrun[offset] = 1;
306306}
307307
308308static void model2_timer_exp(int tnum, int bit)
309309{
310   mame_timer_adjust(model2_timers[tnum], time_never, 0, time_never);
310   timer_adjust(model2_timers[tnum], attotime_never, 0, attotime_never);
311311
312312   model2_intreq |= (1<<bit);
313313   if (model2_intena & (1<<bit))
r1293r1294
341341
342342   model2_timerrun[0] = model2_timerrun[1] = model2_timerrun[2] = model2_timerrun[3] = 0;
343343
344   model2_timers[0] = mame_timer_alloc(model2_timer_0_cb);
345   model2_timers[1] = mame_timer_alloc(model2_timer_1_cb);
346   model2_timers[2] = mame_timer_alloc(model2_timer_2_cb);
347   model2_timers[3] = mame_timer_alloc(model2_timer_3_cb);
344   model2_timers[0] = timer_alloc(model2_timer_0_cb);
345   model2_timers[1] = timer_alloc(model2_timer_1_cb);
346   model2_timers[2] = timer_alloc(model2_timer_2_cb);
347   model2_timers[3] = timer_alloc(model2_timer_3_cb);
348348
349   mame_timer_adjust(model2_timers[0], time_never, 0, time_never);
350   mame_timer_adjust(model2_timers[1], time_never, 0, time_never);
351   mame_timer_adjust(model2_timers[2], time_never, 0, time_never);
352   mame_timer_adjust(model2_timers[3], time_never, 0, time_never);
349   timer_adjust(model2_timers[0], attotime_never, 0, attotime_never);
350   timer_adjust(model2_timers[1], attotime_never, 0, attotime_never);
351   timer_adjust(model2_timers[2], attotime_never, 0, attotime_never);
352   timer_adjust(model2_timers[3], attotime_never, 0, attotime_never);
353353}
354354
355355static MACHINE_RESET(model2o)
r1293r1294
658658        {
659659            logerror("Boot geo, %d dwords\n", model2_geocnt);
660660            cpunum_set_input_line(3, INPUT_LINE_HALT, CLEAR_LINE);
661            //cpu_spinuntil_time(MAME_TIME_IN_USEC(1000));       // Give the SHARC enough time to boot itself
661            //cpu_spinuntil_time(ATTOTIME_IN_USEC(1000));       // Give the SHARC enough time to boot itself
662662        }
663663    }
664664
r1293r1294
898898
899899   if ((sr & 0x0700) > 0x0100)
900900   {
901      cpu_spinuntil_time(MAME_TIME_IN_USEC(40));
901      cpu_spinuntil_time(ATTOTIME_IN_USEC(40));
902902      return 0;   // not ready yet, interrupts disabled
903903   }
904904
r1293r1294
909909{
910910   while (!snd_68k_ready_r())
911911   {
912      cpu_spinuntil_time(MAME_TIME_IN_USEC(40));
912      cpu_spinuntil_time(ATTOTIME_IN_USEC(40));
913913   }
914914
915915   to_68k = data;
r1293r1294
917917   cpunum_set_input_line(1, 2, HOLD_LINE);
918918
919919   // give the 68k time to notice
920   cpu_spinuntil_time(MAME_TIME_IN_USEC(40));
920   cpu_spinuntil_time(ATTOTIME_IN_USEC(40));
921921}
922922
923923static READ32_HANDLER( model2_serial_r )
r1293r1294
945945      SCSP_MidiIn(0, data&0xff, 0);
946946
947947      // give the 68k time to notice
948      cpu_spinuntil_time(MAME_TIME_IN_USEC(40));
948      cpu_spinuntil_time(ATTOTIME_IN_USEC(40));
949949   }
950950}
951951
src/mame/drivers/sshangha.c
r1293r1294
348348   MDRV_CPU_PROGRAM_MAP(sound_readmem,sound_writemem)
349349
350350   MDRV_SCREEN_REFRESH_RATE(60)
351   MDRV_SCREEN_VBLANK_TIME(USEC_TO_SUBSECONDS(529))
351   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(529))
352352   MDRV_MACHINE_RESET(sshangha)   /* init machine */
353353
354354   /* video hardware */
src/mame/drivers/blockade.c
r1293r1294
6363/* Need to check for a coin on the interrupt, */
6464/* This will reset the cpu                    */
6565
66INTERRUPT_GEN( blockade_interrupt )
66static INTERRUPT_GEN( blockade_interrupt )
6767{
6868   cpunum_resume(0, SUSPEND_ANY_REASON);
6969
src/mame/drivers/cps2.c
r1293r1294
573573
574574
575575static int readpaddle;
576int cps2networkpresent;
576static int cps2networkpresent;
577577
578578static INTERRUPT_GEN( cps2_interrupt )
579579{
r1293r1294
13611361   MDRV_CPU_PERIODIC_INT(irq0_line_hold, 251)   /* 251 is good (see 'mercy mercy mercy'section of sgemf attract mode for accurate sound sync */
13621362
13631363   MDRV_SCREEN_REFRESH_RATE(59.633333)
1364   MDRV_SCREEN_VBLANK_TIME(USEC_TO_SUBSECONDS(0))
1364   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(0))
13651365//  MDRV_INTERLEAVE(262)  /* 262 scanlines, for raster effects */
13661366
13671367   MDRV_NVRAM_HANDLER(cps2)
src/mame/drivers/lemmings.c
r1293r1294
281281   MDRV_CPU_PROGRAM_MAP(sound_readmem,sound_writemem)
282282
283283   MDRV_SCREEN_REFRESH_RATE(60)
284   MDRV_SCREEN_VBLANK_TIME(USEC_TO_SUBSECONDS(529))
284   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(529))
285285
286286   /* video hardware */
287287   MDRV_VIDEO_ATTRIBUTES(VIDEO_TYPE_RASTER | VIDEO_BUFFERS_SPRITERAM)
src/mame/drivers/tiamc1.c
r1293r1294
280280   MDRV_CPU_IO_MAP(tiamc1_readport,tiamc1_writeport)
281281
282282   MDRV_SCREEN_REFRESH_RATE(50)
283   MDRV_SCREEN_VBLANK_TIME(USEC_TO_SUBSECONDS(1600))
283   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(1600))
284284   MDRV_CPU_VBLANK_INT(irq1_line_hold,1)
285285
286286   MDRV_MACHINE_RESET(tiamc1)
src/mame/drivers/segag80r.c
r1293r1294
306306{
307307   soundlatch_w(0,data);
308308   cpunum_set_input_line(1, INPUT_LINE_NMI, PULSE_LINE);
309   cpu_boost_interleave(time_zero, MAME_TIME_IN_USEC(50));
309   cpu_boost_interleave(attotime_zero, ATTOTIME_IN_USEC(50));
310310}
311311
312312
r1293r1294
527527   PORT_INCLUDE(astrob)
528528
529529   PORT_MODIFY("D3D2")
530   PORT_DIPNAME( 0x03, 0x01, DEF_STR( Lives ))
530   PORT_DIPNAME( 0x03, 0x01, DEF_STR( Lives )) PORT_DIPLOCATION("SW1:8,7")
531531   PORT_DIPSETTING(    0x00, "2" )
532532   PORT_DIPSETTING(    0x01, "3" )
533533  //PORT_DIPSETTING(    0x02, "3" )
r1293r1294
539539   PORT_INCLUDE(astrob)
540540
541541   PORT_MODIFY("D3D2")
542   PORT_DIPNAME( 0x08, 0x00, DEF_STR( Unknown ))
542   PORT_DIPNAME( 0x08, 0x00, DEF_STR( Unknown )) PORT_DIPLOCATION("SW1:5")
543543   PORT_DIPSETTING(    0x08, DEF_STR( Off ))
544544   PORT_DIPSETTING(    0x00, DEF_STR( On ))
545545INPUT_PORTS_END
r1293r1294
599599    PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_8WAY
600600*/
601601   PORT_MODIFY("D3D2")
602   PORT_DIPNAME( 0x03, 0x00, DEF_STR( Lives ))
602   PORT_DIPNAME( 0x03, 0x00, DEF_STR( Lives )) PORT_DIPLOCATION("SW1:8,7")
603603   PORT_DIPSETTING(    0x00, "3" )
604604   PORT_DIPSETTING(    0x02, "4" )
605605   PORT_DIPSETTING(    0x01, "5" )
606606   PORT_DIPSETTING(    0x03, "6" )
607   PORT_DIPNAME( 0x04, 0x04, DEF_STR( Cabinet ))
607   PORT_DIPNAME( 0x04, 0x04, DEF_STR( Cabinet )) PORT_DIPLOCATION("SW1:6")
608608   PORT_DIPSETTING(    0x04, DEF_STR( Upright ))
609609   PORT_DIPSETTING(    0x00, DEF_STR( Cocktail ))
610   PORT_DIPNAME( 0x18, 0x00, DEF_STR( Bonus_Life ))
610   PORT_DIPNAME( 0x18, 0x00, DEF_STR( Bonus_Life )) PORT_DIPLOCATION("SW1:5,4")
611611   PORT_DIPSETTING(    0x00, "20000" )
612612   PORT_DIPSETTING(    0x10, "40000" )
613613   PORT_DIPSETTING(    0x08, "60000" )
614614   PORT_DIPSETTING(    0x18, "80000" )
615   PORT_DIPNAME( 0x80, 0x80, "Infinite Lives (Cheat)")
615   PORT_DIPNAME( 0x80, 0x80, "Infinite Lives (Cheat)") PORT_DIPLOCATION("SW1:1")
616616   PORT_DIPSETTING(    0x80, DEF_STR( Off ))
617617   PORT_DIPSETTING(    0x00, DEF_STR( On ))
618618
r1293r1294
688688   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_4WAY
689689
690690   PORT_MODIFY("D3D2")
691   PORT_DIPNAME( 0x01, 0x00, DEF_STR( Cabinet ))
691   PORT_DIPNAME( 0x01, 0x00, DEF_STR( Cabinet )) PORT_DIPLOCATION("SW1:8")
692692   PORT_DIPSETTING(    0x00, DEF_STR( Upright ))
693693   PORT_DIPSETTING(    0x01, DEF_STR( Cocktail ))
694   PORT_DIPNAME( 0x02, 0x02, DEF_STR( Demo_Sounds ))
694   PORT_DIPNAME( 0x02, 0x02, DEF_STR( Demo_Sounds )) PORT_DIPLOCATION("SW1:7")
695695   PORT_DIPSETTING(    0x00, DEF_STR( Off ))
696696   PORT_DIPSETTING(    0x02, DEF_STR( On ))
697   PORT_DIPNAME( 0x0c, 0x00, DEF_STR( Lives ))
697   PORT_DIPNAME( 0x0c, 0x00, DEF_STR( Lives )) PORT_DIPLOCATION("SW1:6,5")
698698   PORT_DIPSETTING(    0x00, "3" )
699699   PORT_DIPSETTING(    0x08, "4" )
700700   PORT_DIPSETTING(    0x04, "5" )
src/mame/drivers/shanghai.c
r1293r1294
293293
294294
295295
296void HD63484_command_w(UINT16 cmd)
296static void HD63484_command_w(UINT16 cmd)
297297{
298298   int len;
299299
src/mame/drivers/tmnt.c
r1293r1294
359359{
360360//  sound_nmi_enabled = 1;
361361   cpunum_set_input_line(1, INPUT_LINE_NMI, CLEAR_LINE);
362   mame_timer_set(MAME_TIME_IN_USEC(50),0,nmi_callback);   /* kludge until the K053260 is emulated correctly */
362   timer_set(ATTOTIME_IN_USEC(50),0,nmi_callback);   /* kludge until the K053260 is emulated correctly */
363363}
364364
365365
src/mame/drivers/jpmimpct.c
r1293r1294
55    driver by Phil Bennett
66
77    Games supported:
8        * Cluedo (2 sets)
8        * Cluedo (3 sets)
99        * Hangman
1010        * Scrabble
1111        * Trivial Pursuit
r1293r1294
1515        * Snakes and Ladders
1616
1717    Known issues:
18        * I/O documentation for lamps, reels, meters etc is incomplete.
19        * DUART emulation is very simplistic.
18        * I/O documentation for lamps, reels, meters etc is possibly incorrect.
19        * DUART emulation is very simplistic, in progress.
2020        * Digital volume control is not emulated.
2121
2222****************************************************************************
r1293r1294
3333    400000-403FFF   R/W   xxxxxxxx xxxxxxxx   Program RAM (battery-backed)
3434    480000-48001F   R/W   -------- xxxxxxxx   MC68681 DUART 1
3535    480020-480033   R     -------- xxxxxxxx   Inputs
36    480060-480067   R/W   -------- xxxxxxxx   D71055C?
36    480041          R     -xxxxxxx xxxxxxxx   Reel optos
37    480060-480067   R/W   -------- xxxxxxxx   D71055C? PPI?
3738    480080-480081     W   -------- xxxxxxxx   uPD7559 communications
3839    480082-480083     W   -------- xxxxxxxx   Sound control
3940                          -------- -------x      (uPD7759 reset)
r1293r1294
7677#include "cpu/tms34010/34010ops.h"
7778#include "sound/upd7759.h"
7879#include "jpmimpct.h"
80#include "machine/meters.h"
7981
80
8182/*************************************
8283 *
8384 *  Statics
r1293r1294
8889static UINT8 duart_1_irq;
8990static UINT8 touch_cnt;
9091static UINT8 touch_data[3];
91static mame_timer *duart_1_timer;
92static emu_timer *duart_1_timer;
9293
94static int lamp_strobe;
95static UINT8 Lamps[256];
9396static TIMER_CALLBACK( duart_1_timer_event );
9497
9598
r1293r1294
133136
134137   UINT8 IVR;
135138   UINT8 IP;
139   UINT8 OP;
140   UINT8 OPR;
136141   UINT8 OPCR;
137142} duart_1;//, duart_2;
138143
r1293r1294
169174{
170175   memset(&duart_1, 0, sizeof(duart_1));
171176
172   duart_1_timer = mame_timer_alloc(duart_1_timer_event);
177   duart_1_timer = timer_alloc(duart_1_timer_event);
173178
174179   /* Reset states */
175180   duart_1_irq = tms_irq = 0;
176181   touch_cnt = 0;
177182
183//  duart_1.IVR=0x0f;
178184   state_save_register_global(tms_irq);
179185   state_save_register_global(duart_1_irq);
180186   state_save_register_global(touch_cnt);
r1293r1294
236242{
237243   duart_1.tc = 0;
238244   duart_1.ISR |= 0x08;
245
239246   duart_1_irq = 1;
240247   update_irqs();
241248}
r1293r1294
243250static READ16_HANDLER( duart_1_r )
244251{
245252   UINT16 val = 0xffff;
246
247253   switch (offset)
248254   {
249255      case 0x1:
r1293r1294
252258         val = 0x04;
253259         break;
254260      }
261      case 0x2:
262      {
263         val = 0x00;
264         break;
265      }
266      case 0x3:
267      {
268         val = duart_1.RBA;
269         duart_1.ISR &= ~0x02;
270         duart_1.SRA &= ~0x03;
271         break;
272      }
273      case 0x4:
274      {
275         val = duart_1.IPCR;
276         duart_1.ISR &= ~0x80;
277         break;
278      }
255279      case 0x5:
256280      {
257281         val = duart_1.ISR;
r1293r1294
270294      }
271295      case 0xe:
272296      {
273         mame_time rate = scale_up_mame_time(MAME_TIME_IN_HZ(MC68681_1_CLOCK), 16 * duart_1.CT);
274         mame_timer_adjust(duart_1_timer, rate, 0, rate);
297         attotime rate = attotime_mul(ATTOTIME_IN_HZ(MC68681_1_CLOCK), 16 * duart_1.CT);
298         timer_adjust(duart_1_timer, rate, 0, rate);
275299         break;
276300      }
277301      case 0xf:
r1293r1294
288312
289313static WRITE16_HANDLER( duart_1_w )
290314{
315   int old_val;
291316   switch (offset)
292317   {
318      case 0x1:
319      {
320         duart_1.CSRA = data;
321         break;
322      }
293323      case 0x3:
294324      {
295325         //mame_printf_debug("%c", data);
r1293r1294
326356         //mame_printf_debug("%c",data);
327357         break;
328358      }
359      case 0xc:
360      {
361         duart_1.IVR = data;
362         break;
363      }
364      case 0xd:
365      {
366         duart_1.OPCR = data;
367         break;
368      }
329369      case 0xe:
330370      {
371          old_val = duart_1.OPR;
372          duart_1.OPR = duart_1.OPR | data;
373          duart_1.OP = ~duart_1.OPR;
331374         /* Output port bit set */
332375         break;
333376      }
334377      case 0xf:
335378      {
379          old_val = duart_1.OPR;
380          duart_1.OPR = duart_1.OPR &~data;
381          duart_1.OP = ~duart_1.OPR;
336382         /* Output port bit reset */
337383         break;
338384      }
r1293r1294
483529   return 0xffff;
484530}
485531
486
487532/*************************************
488533 *
489534 *  Mysterious stuff
r1293r1294
499544{
500545}
501546
547static void jpm_draw_lamps(int data, int lamp_strobe)
548{
549   int i;
550   for (i=0; i<16; i++)
551   {
552      Lamps[16*(lamp_strobe+i)] = data & 1;
553      output_set_lamp_value((16*lamp_strobe)+i, (Lamps[(16*lamp_strobe)+i]));
554       data = data >> 1;
555    }
556}
502557
558static READ16_HANDLER( jpmio_r )
559{
560   return 0xffff;
561}
562
563static WRITE16_HANDLER( jpmio_w )
564{
565   long cycles  = ATTOTIME_TO_CYCLES(0, timer_get_time() );
566   switch (offset)
567   {
568      case 0x02:
569      {
570         //reel 1
571         break;
572      }
573      case 0x04:
574      {
575         //reel 2
576         break;
577      }
578      case 0x06:
579      {
580         if ( data & 0x10 )
581         {   // PAYEN ?
582            if ( data & 0xf )
583            {
584         //      slide = 1;
585            }
586            else
587            {
588            //  slide = 0;
589            }
590         }
591         else
592//          slide = 0;
593         Mechmtr_update(0, cycles, data >> 10);
594         duart_1.IP &= ~0x10;
595         break;
596      }
597
598      case 0x08:
599      {
600         jpm_draw_lamps(data, lamp_strobe);
601         break;
602      }
603
604      case 0x0b:
605      {
606         output_set_digit_value(lamp_strobe,data);
607         break;
608      }
609      case 0x0f:
610      {
611         if (data & 0x10)
612         {
613            lamp_strobe = (data +1) & 0x0f;
614         }
615         break;
616      }
617   }
618}
619
503620/*************************************
504621 *
505622 *  Main CPU memory handlers
r1293r1294
512629   AM_RANGE(0x00480000, 0x0048001f) AM_READWRITE(duart_1_r, duart_1_w)
513630   AM_RANGE(0x00480020, 0x00480033) AM_READ(inputs1_r)
514631   AM_RANGE(0x00480034, 0x00480035) AM_READ(unk_r)
515   AM_RANGE(0x00480060, 0x00480067) AM_READWRITE(unk_r, unk_w)
516   AM_RANGE(0x004800a0, 0x004800af) AM_READWRITE(unk_r, unk_w)
632   AM_RANGE(0x00480060, 0x00480067) AM_READWRITE(unk_r, unk_w)//PPI
633   AM_RANGE(0x004800a0, 0x004800af) AM_READWRITE(jpmio_r, jpmio_w)
517634   AM_RANGE(0x004800e0, 0x004800e1) AM_WRITE(unk_w)
518635   AM_RANGE(0x004801dc, 0x004801dd) AM_READ(unk_r)
519636   AM_RANGE(0x004801de, 0x004801df) AM_READ(unk_r)
r1293r1294
689806 *
690807 *************************************/
691808
692void jpmimpct_tms_irq(int state)
809static void jpmimpct_tms_irq(int state)
693810{
694811   tms_irq = state;
695812   update_irqs();
r1293r1294
795912   ROM_LOAD( "1214.bin", 0x000000, 0x80000, CRC(fe43aeae) SHA1(017a471af5766ef41fa46982c02941fb4fc35174) )
796913ROM_END
797914
915ROM_START( cluedo2 )
916   ROM_REGION( 0x1000000, REGION_CPU1, 0 )
917   ROM_LOAD16_BYTE( "clu21.bin", 0x000000, 0x080000, CRC(b1aa0103)SHA1(52d10a428710cd04313a2638fc3c23fb9d0ab6db))
918   ROM_LOAD16_BYTE( "clu22.bin", 0x000001, 0x080000, CRC(90d8dd28)SHA1(3124a8313c6b362176283e145c4af27f5deac683))
919   ROM_LOAD16_BYTE( "clu23.bin", 0x100000, 0x080000, CRC(196bd993)SHA1(50920441707fc6cae9d36961d92ce213e53c4238))
920   ROM_LOAD16_BYTE( "clu24.bin", 0x100001, 0x080000, CRC(3f5c1259)SHA1(dfdbb66a81716a0ced7510e277f6f321516f57af))
921
922   ROM_LOAD16_BYTE( "6977.bin", 0xc00000, 0x080000, CRC(6030dfc1) SHA1(8746909b0b7f7eb99cf5388ac85db6addb6deee3) )
923   ROM_LOAD16_BYTE( "6978.bin", 0xc00001, 0x080000, CRC(21e30e06) SHA1(4e97baa9e39663b662dd202bbaf34be0e29930de) )
924   ROM_LOAD16_BYTE( "6979.bin", 0xd00000, 0x080000, CRC(5575162a) SHA1(27f7b5f4ee7d95319b03e2414a25d5b1a6c54fc7) )
925   ROM_LOAD16_BYTE( "6980.bin", 0xd00001, 0x080000, CRC(968224df) SHA1(726c278622681206a7f34bafe1b5bb4421232cc4) )
926   ROM_LOAD16_BYTE( "6981.bin", 0xe00000, 0x080000, CRC(2ad3ee20) SHA1(9370dab84a255864f40254772199211884d8557b) )
927   ROM_LOAD16_BYTE( "6982.bin", 0xe00001, 0x080000, CRC(7478e91b) SHA1(158b473b46aeccf011669cb58dc3a1596370d8f1) )
928   ROM_FILL(                    0xf00000, 0x100000, 0xff )
929
930   ROM_REGION16_LE( 0x200000, REGION_USER1, 0 )
931   ROM_LOAD16_BYTE( "clugrb1", 0x000000, 0x80000, CRC(176ae2df) SHA1(135fd2640c255e5321b1a6ba35f72fa2ba8f04b8) )
932   ROM_LOAD16_BYTE( "clugrb2", 0x000001, 0x80000, CRC(06ab2f78) SHA1(4325fd9096e73956310e97e244c7fe1ee8d27f5c) )
933   ROM_COPY( REGION_USER1, 0x000000, 0x100000, 0x100000 )
934
935   ROM_REGION( 0x80000, REGION_SOUND1, 0 )
936   ROM_LOAD( "clue2as1.bin", 0x000000, 0x80000, CRC(16b2bc45) SHA1(56963f5d63b5a091b89b96f4ca9327010006c024) )
937ROM_END
938
798939ROM_START( trivialp )
799940   ROM_REGION( 0x1000000, REGION_CPU1, 0 )
800941   ROM_LOAD16_BYTE( "1422.bin", 0x000000, 0x080000, CRC(5e39c946) SHA1(bae7f572a32e90d716813271f03e7868be603086) )
r1293r1294
8821023
8831024GAME( 1995, cluedo,   0,      jpmimpct, cluedo,   0, ROT0, "JPM", "Cluedo (prod. 2D)",          GAME_IMPERFECT_GRAPHICS | GAME_SUPPORTS_SAVE )
8841025GAME( 1995, cluedo2c, cluedo, jpmimpct, cluedo,   0, ROT0, "JPM", "Cluedo (prod. 2C)",          GAME_IMPERFECT_GRAPHICS | GAME_SUPPORTS_SAVE )
1026GAME( 1995, cluedo2,  cluedo, jpmimpct, cluedo,   0, ROT0, "JPM", "Cluedo (prod. 2)",            GAME_IMPERFECT_GRAPHICS | GAME_SUPPORTS_SAVE )
8851027GAME( 1996, trivialp, 0,      jpmimpct, trivialp, 0, ROT0, "JPM", "Trivial Pursuit (prod. 1D)", GAME_IMPERFECT_GRAPHICS | GAME_SUPPORTS_SAVE )
8861028GAME( 1997, scrabble, 0,      jpmimpct, scrabble, 0, ROT0, "JPM", "Scrabble (rev. F)",          GAME_IMPERFECT_GRAPHICS | GAME_SUPPORTS_SAVE )
8871029GAME( 1998, hngmnjpm, 0,      jpmimpct, hngmnjpm, 0, ROT0, "JPM", "Hangman (JPM)",              GAME_IMPERFECT_GRAPHICS | GAME_SUPPORTS_SAVE )
888
src/mame/drivers/namcos12.c
r1293r1294
13711371   MDRV_CPU_ADD(H83002, 14745600 )   /* verified 14.7456 MHz */
13721372   MDRV_CPU_PROGRAM_MAP( s12h8rwmap, 0 )
13731373   MDRV_CPU_IO_MAP( s12h8iomap, 0 )
1374   MDRV_CPU_VBLANK_INT( irq1_line_pulse, 1 );
1374   MDRV_CPU_VBLANK_INT( irq1_line_pulse, 1 )
13751375
13761376   MDRV_SCREEN_REFRESH_RATE( 60 )
13771377   MDRV_SCREEN_VBLANK_TIME(DEFAULT_60HZ_VBLANK_DURATION)
src/mame/drivers/scramble.c
r1293r1294
6868    speech_rom_bit        = 0;
6969}
7070
71int ad2083_speech_rom_read_bit(void)
71static int ad2083_speech_rom_read_bit(void)
7272{
7373   UINT8 *ROM = memory_region(REGION_SOUND1);
7474   int bit;
r1293r1294
552552   AM_RANGE(0xd800, 0xd800) AM_READ(monsterz_prot_r)
553553ADDRESS_MAP_END
554554
555ADDRESS_MAP_START( monsterz_sound_io_map, ADDRESS_SPACE_IO, 8 )
555static ADDRESS_MAP_START( monsterz_sound_io_map, ADDRESS_SPACE_IO, 8 )
556556   AM_RANGE(0x04, 0x04) AM_READ(monsterz_sound_status_r)
557557   AM_RANGE(0x10, 0x10) AM_WRITE(AY8910_control_port_0_w)
558558   AM_RANGE(0x20, 0x20) AM_READWRITE(AY8910_read_port_0_r, AY8910_write_port_0_w)
r1293r1294
24672467   MDRV_CPU_IO_MAP(hunchbks_readport,0)
24682468   MDRV_CPU_VBLANK_INT(hunchbks_vh_interrupt,1)
24692469
2470   MDRV_SCREEN_VBLANK_TIME(USEC_TO_SUBSECONDS(2500))
2470   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(2500))
24712471
24722472   /* video hardware */
24732473   MDRV_PALETTE_LENGTH(32+64+2+0)   /* 32 for characters, 64 for stars, 2 for bullets */
src/mame/drivers/mogura.c
r1293r1294
33#include "driver.h"
44#include "sound/dac.h"
55
6UINT8 *mogura_tileram;
7UINT8* mogura_gfxram;
6static UINT8 *mogura_tileram;
7static UINT8* mogura_gfxram;
88static tilemap *mogura_tilemap;
99
1010static PALETTE_INIT( mogura )
src/mame/drivers/berzerk.c
r1293r1294
4444static UINT8 last_shift_data;      /* 7-bit latch @ 7C */
4545static UINT8 intercept;            /* J-K flip-flop @ 6B */
4646
47static mame_timer *irq_timer;
48static mame_timer *nmi_timer;
47static emu_timer *irq_timer;
48static emu_timer *nmi_timer;
4949static UINT8 irq_enabled;         /* J-K flip-flop @ 3D */
5050static UINT8 nmi_enabled;         /* flip-flop made out of 2 NAND gates @ 1D */
5151
r1293r1294
164164   next_v256 = irq_trigger_v256s[next_irq_number];
165165
166166   next_vpos = vysnc_chain_counter_to_vpos(next_counter, next_v256);
167   mame_timer_adjust(irq_timer, video_screen_get_time_until_pos(0, next_vpos, 0), next_irq_number, time_zero);
167   timer_adjust(irq_timer, video_screen_get_time_until_pos(0, next_vpos, 0), next_irq_number, attotime_zero);
168168}
169169
170170
171171static void create_irq_timer(void)
172172{
173   irq_timer = mame_timer_alloc(irq_callback);
173   irq_timer = timer_alloc(irq_callback);
174174}
175175
176176
177177static void start_irq_timer(void)
178178{
179179   int vpos = vysnc_chain_counter_to_vpos(irq_trigger_counts[0], irq_trigger_v256s[0]);
180   mame_timer_adjust(irq_timer, video_screen_get_time_until_pos(0, vpos, 0), 0, time_zero);
180   timer_adjust(irq_timer, video_screen_get_time_until_pos(0, vpos, 0), 0, attotime_zero);
181181}
182182
183183
r1293r1294
241241   next_v256 = nmi_trigger_v256s[next_nmi_number];
242242
243243   next_vpos = vysnc_chain_counter_to_vpos(next_counter, next_v256);
244   mame_timer_adjust(nmi_timer, video_screen_get_time_until_pos(0, next_vpos, 0), next_nmi_number, time_zero);
244   timer_adjust(nmi_timer, video_screen_get_time_until_pos(0, next_vpos, 0), next_nmi_number, attotime_zero);
245245}
246246
247247
248248static void create_nmi_timer(void)
249249{
250   nmi_timer = mame_timer_alloc(nmi_callback);
250   nmi_timer = timer_alloc(nmi_callback);
251251}
252252
253253
254254static void start_nmi_timer(void)
255255{
256256   int vpos = vysnc_chain_counter_to_vpos(nmi_trigger_counts[0], nmi_trigger_v256s[0]);
257   mame_timer_adjust(nmi_timer, video_screen_get_time_until_pos(0, vpos, 0), 0, time_zero);
257   timer_adjust(nmi_timer, video_screen_get_time_until_pos(0, vpos, 0), 0, attotime_zero);
258258}
259259
260260
src/mame/drivers/tehkanwc.c
r1293r1294
175175
176176   /* in Gridiron, the sound CPU goes in a tight loop after the self test, */
177177   /* probably waiting to be reset by a watchdog */
178   if (activecpu_get_pc() == 0x08bc) mame_timer_set(MAME_TIME_IN_SEC(1),0,reset_callback);
178   if (activecpu_get_pc() == 0x08bc) timer_set(ATTOTIME_IN_SEC(1),0,reset_callback);
179179}
180180
181181
r1293r1294
208208   MSM5205_reset_w(0,data ? 0 : 1);
209209}
210210
211void tehkanwc_adpcm_int (int data)
211static void tehkanwc_adpcm_int (int data)
212212{
213213   static int toggle;
214214
src/mame/drivers/bionicc.c
r1293r1294
135135
136136********************************************************************/
137137
138INTERRUPT_GEN( bionicc_interrupt )
138static INTERRUPT_GEN( bionicc_interrupt )
139139{
140140   if (cpu_getiloops() == 0)
141141      cpunum_set_input_line(0, 2, HOLD_LINE);
src/mame/drivers/spy.c
r1293r1294
166166}
167167
168168//AT
169void spy_collision(void)
169static void spy_collision(void)
170170{
171171#define MAX_SPRITES 64
172172#define DEF_NEAR_PLANE 0x6400
src/mame/drivers/esd16.c
r1293r1294
7171   {
7272      soundlatch_w(0,data & 0xff);
7373      cpunum_set_input_line(1,0,ASSERT_LINE);      // Generate an IRQ
74      cpu_spinuntil_time(MAME_TIME_IN_USEC(50));   // Allow the other CPU to reply
74      cpu_spinuntil_time(ATTOTIME_IN_USEC(50));   // Allow the other CPU to reply
7575   }
7676}
7777
src/mame/drivers/model3.c
r1293r1294
364364#include "machine/53c810.h"
365365#include "sound/scsp.h"
366366
367int model3_irq_enable;
367static int model3_irq_enable;
368368int model3_irq_state;
369369int model3_step;
370370UINT32 *model3_vrom;
r1293r1294
13121312      SCSP_MidiIn(0, (data>>56)&0xff, 0);
13131313
13141314      // give the 68k time to notice
1315      cpu_spinuntil_time(MAME_TIME_IN_USEC(40));
1315      cpu_spinuntil_time(ATTOTIME_IN_USEC(40));
13161316   }
13171317}
13181318
src/mame/drivers/namcos21.c
r1293r1294
297297static UINT8 *pointram;
298298static int pointram_idx;
299299
300UINT16 *namcos21_dspram16;
301UINT16 *namcos21_spritepos;
300static UINT16 *namcos21_dspram16;
301//UINT16 *namcos21_spritepos;
302302
303303/* private data */
304304static UINT16 *mpDataROM;
r1293r1294
683683   return 1;
684684} /* dsp_port8_r */
685685
686int namcos21_irq_enable;
686static int namcos21_irq_enable;
687687
688688static WRITE16_HANDLER( dsp_port8_w )
689689{ /* IRQ-enable? */
src/mame/drivers/pgm.c
r1293r1294
335335}
336336#endif
337337
338//static mame_timer *   arm_comms_timer;
338//static emu_timer *   arm_comms_timer;
339339static WRITE32_HANDLER( arm7_latch_arm_w )
340340{
341341   if (PGMARM7LOGERROR) logerror("ARM7: Latch write: %08x (%08x) (%06x)\n", data, mem_mask, activecpu_get_pc() );
342342   COMBINE_DATA(&arm7_latch);
343343
344344#ifdef PGMARM7SPEEDHACK
345//  cpu_boost_interleave(time_zero, MAME_TIME_IN_USEC(100));
345//  cpu_boost_interleave(attotime_zero, ATTOTIME_IN_USEC(100));
346346   if (data!=0xaa) cpu_spinuntil_trigger(1000);
347347   cpu_trigger(1002);
348348#else
349   cpu_boost_interleave(time_zero, MAME_TIME_IN_USEC(100));
350   cpu_spinuntil_time(MAME_TIME_IN_CYCLES(100, 0));
349   cpu_boost_interleave(attotime_zero, ATTOTIME_IN_USEC(100));
350   cpu_spinuntil_time(ATTOTIME_IN_CYCLES(100, 0));
351351#endif
352352}
353353
r1293r1294
376376
377377#ifdef PGMARM7SPEEDHACK
378378   cpu_trigger(1000);
379   mame_timer_set(MAME_TIME_IN_USEC(50), 0, arm_irq); // i don't know how long..
379   timer_set(ATTOTIME_IN_USEC(50), 0, arm_irq); // i don't know how long..
380380   cpu_spinuntil_trigger(1002);
381381#else
382382   cpunum_set_input_line(2, ARM7_FIRQ_LINE, PULSE_LINE);
383   cpu_boost_interleave(time_zero, MAME_TIME_IN_USEC(200));
384   cpu_spinuntil_time(MAME_TIME_IN_CYCLES(200, 2)); // give the arm time to respond (just boosting the interleave doesn't help
383   cpu_boost_interleave(attotime_zero, ATTOTIME_IN_USEC(200));
384   cpu_spinuntil_time(ATTOTIME_IN_CYCLES(200, 2)); // give the arm time to respond (just boosting the interleave doesn't help
385385#endif
386386}
387387
r1293r1294
727727
728728/* Kov Superheroes */
729729
730UINT16 kovsh_highlatch, kovsh_lowlatch;
730static UINT16 kovsh_highlatch, kovsh_lowlatch;
731731
732732static READ32_HANDLER( kovsh_arm7_protlatch_r )
733733{
r1293r1294
748748      kovsh_lowlatch = data;
749749   }
750750
751//  cpu_boost_interleave(time_zero, MAME_TIME_IN_USEC(100));
752//  cpu_spinuntil_time(MAME_TIME_IN_CYCLES(100, 0));
751//  cpu_boost_interleave(attotime_zero, ATTOTIME_IN_USEC(100));
752//  cpu_spinuntil_time(ATTOTIME_IN_CYCLES(100, 0));
753753}
754754
755755static READ16_HANDLER( kovsh_68k_protlatch_r )
756756{
757   //cpu_boost_interleave(time_zero, MAME_TIME_IN_USEC(200));
758   cpu_spinuntil_time(MAME_TIME_IN_CYCLES(600, 0));
757   //cpu_boost_interleave(attotime_zero, ATTOTIME_IN_USEC(200));
758   cpu_spinuntil_time(ATTOTIME_IN_CYCLES(600, 0));
759759
760760   switch (offset)
761761   {
r1293r1294
21022102
21032103/* ddp2 rubbish */
21042104
2105UINT16 *ddp2_protram;
2105static UINT16 *ddp2_protram;
21062106static int ddp2_asic27_0xd10000 = 0;
21072107
21082108static WRITE16_HANDLER ( ddp2_asic27_0xd10000_w )
src/mame/drivers/gameplan.c
r1293r1294
182182 *
183183 *************************************/
184184
185static mame_timer *via_0_ca1_timer;
185static emu_timer *via_0_ca1_timer;
186186
187187
188188
r1293r1294
281281   /* Kaos sits in a tight loop polling the VIA irq flags register, but that register is
282282       cleared by the irq handler. Therefore, I wait a bit before triggering the irq to
283283       leave time for the program to see the flag change. */
284   mame_timer_set(MAME_TIME_IN_USEC(50), state, via_irq_delayed);
284   timer_set(ATTOTIME_IN_USEC(50), state, via_irq_delayed);
285285}
286286
287287
r1293r1294
311311   via_0_ca1_w(0, (UINT8)param);
312312
313313   if (param)
314      mame_timer_adjust(via_0_ca1_timer, video_screen_get_time_until_pos(0, VBSTART, 0), 0, time_zero);
314      timer_adjust(via_0_ca1_timer, video_screen_get_time_until_pos(0, VBSTART, 0), 0, attotime_zero);
315315   else
316      mame_timer_adjust(via_0_ca1_timer, video_screen_get_time_until_pos(0, VBEND, 0), 1, time_zero);
316      timer_adjust(via_0_ca1_timer, video_screen_get_time_until_pos(0, VBEND, 0), 1, attotime_zero);
317317}
318318
319319
320320static void create_via_0_timer(void)
321321{
322   via_0_ca1_timer = mame_timer_alloc(via_0_ca1_timer_callback);
322   via_0_ca1_timer = timer_alloc(via_0_ca1_timer_callback);
323323}
324324
325325
326326static void start_via_0_timer(void)
327327{
328   mame_timer_adjust(via_0_ca1_timer, video_screen_get_time_until_pos(0, VBSTART, 0), 0, time_zero);
328   timer_adjust(via_0_ca1_timer, video_screen_get_time_until_pos(0, VBSTART, 0), 0, attotime_zero);
329329}
330330
331331
src/mame/drivers/capbowl.c
r1293r1294
129129   video_screen_update_partial(0, scanline - 1);
130130   scanline += 32;
131131   if (scanline > 240) scanline = 32;
132   mame_timer_set(video_screen_get_time_until_pos(0, scanline, 0), scanline, capbowl_update);
132   timer_set(video_screen_get_time_until_pos(0, scanline, 0), scanline, capbowl_update);
133133}
134134
135135
136136static MACHINE_RESET( capbowl )
137137{
138   mame_timer_set(video_screen_get_time_until_pos(0, 32, 0), 32, capbowl_update);
138   timer_set(video_screen_get_time_until_pos(0, 32, 0), 32, capbowl_update);
139139}
140140
141141
src/mame/drivers/kinst.c
r1293r1294
249249static INTERRUPT_GEN( irq0_start )
250250{
251251   cpunum_set_input_line(0, 0, ASSERT_LINE);
252   mame_timer_set(MAME_TIME_IN_USEC(50), 0, irq0_stop);
252   timer_set(ATTOTIME_IN_USEC(50), 0, irq0_stop);
253253}
254254
255255
r1293r1294
392392      UINT32 r26 = activecpu_get_reg(MIPS3_R26) - *kinst_speedup;
393393      if (r26 < r3)
394394      {
395         mame_timer_set(MAME_TIME_IN_CYCLES((r3 - r26) * 2, 0), 0, end_spin);
395         timer_set(ATTOTIME_IN_CYCLES((r3 - r26) * 2, 0), 0, end_spin);
396396         cpu_spinuntil_int();
397397      }
398398   }
r1293r1294
650650};
651651
652652
653MACHINE_DRIVER_START( kinst )
653static MACHINE_DRIVER_START( kinst )
654654
655655   /* basic machine hardware */
656656   MDRV_CPU_ADD(R4600LE, MASTER_CLOCK*2)
src/mame/drivers/beathead.c
r1293r1294
156156   update_interrupts();
157157
158158   /* set the timer for the next one */
159   mame_timer_set(double_to_mame_time(mame_time_to_double(video_screen_get_time_until_pos(0, scanline, 0)) - hblank_offset), scanline, scanline_callback);
159   timer_set(double_to_attotime(attotime_to_double(video_screen_get_time_until_pos(0, scanline, 0)) - hblank_offset), scanline, scanline_callback);
160160}
161161
162162
r1293r1294
172172   memcpy(ram_base, rom_base, 0x40);
173173
174174   /* compute the timing of the HBLANK interrupt and set the first timer */
175   hblank_offset = mame_time_to_double(video_screen_get_scan_period(0)) * ((455. - 336. - 25.) / 455.);
176   mame_timer_set(double_to_mame_time(mame_time_to_double(video_screen_get_time_until_pos(0, 0, 0)) - hblank_offset), 0, scanline_callback);
175   hblank_offset = attotime_to_double(video_screen_get_scan_period(0)) * ((455. - 336. - 25.) / 455.);
176   timer_set(double_to_attotime(attotime_to_double(video_screen_get_time_until_pos(0, 0, 0)) - hblank_offset), 0, scanline_callback);
177177
178178   /* reset IRQs */
179179   irq_line_state = CLEAR_LINE;
src/mame/drivers/st0016.c
r1293r1294
392392//  GFXDECODE_ENTRY( 0, 0, charlayout,      0, 16*4  )
393393GFXDECODE_END
394394
395INTERRUPT_GEN(st0016_int)
395static INTERRUPT_GEN(st0016_int)
396396{
397397   if(!cpu_getiloops())
398398      cpunum_set_input_line(0,0,HOLD_LINE);
src/mame/drivers/funkyjet.c
r1293r1294
374374   MDRV_CPU_PROGRAM_MAP(sound_readmem,sound_writemem)
375375
376376   MDRV_SCREEN_REFRESH_RATE(58)
377   MDRV_SCREEN_VBLANK_TIME(USEC_TO_SUBSECONDS(529))
377   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(529))
378378
379379   /* video hardware */
380380   MDRV_VIDEO_ATTRIBUTES(VIDEO_TYPE_RASTER)
src/mame/drivers/skyarmy.c
r1293r1294
2323#include "driver.h"
2424#include "sound/ay8910.h"
2525
26UINT8 *skyarmy_videoram;
27UINT8 *skyarmy_colorram;
28UINT8 *skyarmy_scrollram;
26static UINT8 *skyarmy_videoram;
27static UINT8 *skyarmy_colorram;
28static UINT8 *skyarmy_scrollram;
2929static tilemap* skyarmy_tilemap;
3030
3131static TILE_GET_INFO( get_skyarmy_tile_info )
src/mame/drivers/xexex.c
r1293r1294
11#define XE_DEBUG 0
22#define XE_SKIPIDLE 1
3#define XE_DMADELAY MAME_TIME_IN_USEC(256)
3#define XE_DMADELAY ATTOTIME_IN_USEC(256)
44
55/***************************************************************************
66
r1293r1294
8282static int init_eeprom_count;
8383static INT32 cur_sound_region, xexex_strip0x1a;
8484static int suspension_active, resume_trigger;
85static mame_timer *dmadelay_timer;
85static emu_timer *dmadelay_timer;
8686
8787
8888static struct EEPROM_interface eeprom_interface =
r1293r1294
331331            xexex_objdma(0);
332332
333333            // schedule DMA end interrupt
334            mame_timer_adjust(dmadelay_timer, XE_DMADELAY, 0, time_zero);
334            timer_adjust(dmadelay_timer, XE_DMADELAY, 0, attotime_zero);
335335         }
336336
337337         // IRQ 4 is the V-blank interrupt. It controls color, sound and
r1293r1294
484484   /* audio CPU */
485485   MDRV_CPU_PROGRAM_MAP(sound_readmem,sound_writemem)
486486
487   MDRV_INTERLEAVE(32);
487   MDRV_INTERLEAVE(32)
488488   MDRV_SCREEN_REFRESH_RATE(60)
489489   MDRV_SCREEN_VBLANK_TIME(DEFAULT_60HZ_VBLANK_DURATION)
490490
r1293r1294
633633
634634   resume_trigger = 1000;
635635
636   dmadelay_timer = mame_timer_alloc(dmaend_callback);
636   dmadelay_timer = timer_alloc(dmaend_callback);
637637}
638638
639639
src/mame/drivers/skullxbo.c
r1293r1294
6262   /* the interrupt occurs on the HBLANK of the 6th scanline following */
6363   if (check < &atarigen_alpha[0x7c0] && (*check & 0x8000))
6464   {
65      mame_time period = video_screen_get_time_until_pos(scrnum, video_screen_get_vpos(scrnum) + 6, machine->screen[scrnum].width * 0.9);
66      mame_timer_set(period, 0, irq_gen);
65      attotime period = video_screen_get_time_until_pos(scrnum, video_screen_get_vpos(scrnum) + 6, machine->screen[scrnum].width * 0.9);
66      timer_set(period, 0, irq_gen);
6767   }
6868
6969   /* update the playfield and motion objects */
src/mame/drivers/konamigq.c
r1293r1294
377377   MDRV_CPU_PERIODIC_INT( irq2_line_hold, 480 )
378378
379379   MDRV_SCREEN_REFRESH_RATE( 60 )
380   MDRV_SCREEN_VBLANK_TIME(USEC_TO_SUBSECONDS( 0 ))
380   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC( 0 ))
381381
382382   MDRV_MACHINE_START( konamigq )
383383   MDRV_MACHINE_RESET( konamigq )
src/mame/drivers/mrflea.c
r1293r1294
153153   return mrflea_status^0x01;
154154}
155155
156INTERRUPT_GEN( mrflea_io_interrupt ){
156static INTERRUPT_GEN( mrflea_io_interrupt ){
157157   if( cpu_getiloops()==0 || (mrflea_status&0x08) )
158158      cpunum_set_input_line(1, 0, HOLD_LINE);
159159}
src/mame/drivers/cps3.c
r1293r1294
345345   #define DMA_XOR(a)   ((a) ^ 2)
346346#endif
347347
348int cps3_use_fastboot;
348static int cps3_use_fastboot;
349349
350350static UINT32* decrypted_bios;
351351static UINT32* decrypted_gamerom;
352352static UINT32 cram_gfxflash_bank;
353UINT32* cps3_nops;
353static UINT32* cps3_nops;
354354
355355static UINT32* tilemap20_regs_base;
356356static UINT32* tilemap30_regs_base;
357357static UINT32* tilemap40_regs_base;
358358static UINT32* tilemap50_regs_base;
359359
360UINT32* cps3_0xc0000000_ram;
361UINT32* cps3_0xc0000000_ram_decrypted;
360static UINT32* cps3_0xc0000000_ram;
361static UINT32* cps3_0xc0000000_ram_decrypted;
362362
363UINT32* cps3_char_ram;
363static UINT32* cps3_char_ram;
364364
365UINT32* cps3_spriteram;
366UINT32* cps3_eeprom;
367UINT32* cps3_fullscreenzoom;
365static UINT32* cps3_spriteram;
366static UINT32* cps3_eeprom;
367static UINT32* cps3_fullscreenzoom;
368368
369369UINT32 cps3_ss_pal_base = 0;
370UINT32* cps3_colourram;
371UINT32 cps3_unk_vidregs[0x20/4];
370static UINT32* cps3_colourram;
371static UINT32 cps3_unk_vidregs[0x20/4];
372372UINT32 cps3_ss_bank_base = 0;
373373
374UINT32 cps3_screenwidth;
375cdrom_file* cps3_cd;
374static UINT32 cps3_screenwidth;
375//cdrom_file* cps3_cd;
376376
377UINT32* cps3_mame_colours;//[0x20000]; // actual values to write to 32-bit bitmap
377static UINT32* cps3_mame_colours;//[0x20000]; // actual values to write to 32-bit bitmap
378378
379379static mame_bitmap *renderbuffer_bitmap;
380380static rectangle renderbuffer_clip;
r1293r1294
686686   { 0 }   // end of table
687687};
688688
689void cps3_decrypt_bios(void)
689static void cps3_decrypt_bios(void)
690690{
691691   int i;
692692   UINT32 *coderegion = (UINT32*)memory_region(REGION_USER1);
r1293r1294
804804   64*8
805805};
806806
807UINT32* cps3_ss_ram;
808UINT8* cps3_ss_ram_dirty;
809int cps3_ss_ram_is_dirty;
807static UINT32* cps3_ss_ram;
808static UINT8* cps3_ss_ram_dirty;
809static int cps3_ss_ram_is_dirty;
810810
811UINT8* cps3_char_ram_dirty;
812int cps3_char_ram_is_dirty;
811static UINT8* cps3_char_ram_dirty;
812static int cps3_char_ram_is_dirty;
813813
814void cps3_set_mame_colours( int colournum, UINT16 data, UINT32 fadeval )
814static void cps3_set_mame_colours( int colournum, UINT16 data, UINT32 fadeval )
815815{
816816   int r,g,b;
817817   UINT16* dst = (UINT16*)cps3_colourram;
r1293r1294
940940
941941// the 0x400 bit in the tilemap regs is "draw it upside-down"  (bios tilemap during flashing, otherwise capcom logo is flipped)
942942
943void cps3_draw_tilemapsprite_line(int tmnum, int drawline, mame_bitmap *bitmap, const rectangle *cliprect )
943static void cps3_draw_tilemapsprite_line(int tmnum, int drawline, mame_bitmap *bitmap, const rectangle *cliprect )
944944{
945945   UINT32* tmapregs[4] = { tilemap20_regs_base, tilemap30_regs_base, tilemap40_regs_base, tilemap50_regs_base };
946946   UINT32* regs;
r1293r1294
15761576
15771577
15781578
1579UINT32 cps3_flashmain_r(int base, UINT32 offset, UINT32 mem_mask)
1579static UINT32 cps3_flashmain_r(int base, UINT32 offset, UINT32 mem_mask)
15801580{
15811581   UINT32 result = 0;
15821582
r1293r1294
16091609/* In certain situations (SH2 DMA?) the reads must bypass the encryption device,
16101610   this is used when checking the flash roms, and performing rom tests.  Without
16111611   modification to the SH2 core this requires PC based hacks to work correctly */
1612UINT32 cps3_bios_test_hack;
1613UINT32 cps3_game_test_hack;
1612static UINT32 cps3_bios_test_hack;
1613static UINT32 cps3_game_test_hack;
16141614
16151615struct cps3_test_hacks
16161616{
r1293r1294
16901690   return retvalue;
16911691}
16921692
1693void cps3_flashmain_w(int base, UINT32 offset, UINT32 data, UINT32 mem_mask)
1693static void cps3_flashmain_w(int base, UINT32 offset, UINT32 data, UINT32 mem_mask)
16941694{
16951695   int command;
16961696   if (!(mem_mask & 0xff000000))   // Flash 1
r1293r1294
18581858
18591859/* EEPROM access is a little odd, I think it accesses eeprom through some kind of
18601860   additional interface, as these writes aren't normal for the type of eeprom we have */
1861UINT16 cps3_current_eeprom_read;
1861static UINT16 cps3_current_eeprom_read;
18621862
18631863static READ32_HANDLER( cps3_eeprom_r )
18641864{
r1293r1294
20892089   }
20902090}
20912091
2092void cps3_do_char_dma( UINT32 real_source, UINT32 real_destination, UINT32 real_length )
2092static void cps3_do_char_dma( UINT32 real_source, UINT32 real_destination, UINT32 real_length )
20932093{
20942094   UINT8* sourcedata = (UINT8*)memory_region(REGION_USER5);
20952095   int length_remaining;
r1293r1294
21762176    }
21772177 }
21782178
2179void cps3_do_alt_char_dma( UINT32 src, UINT32 real_dest, UINT32 real_length )
2179static void cps3_do_alt_char_dma( UINT32 src, UINT32 real_dest, UINT32 real_length )
21802180{
21812181   UINT8* px = (UINT8*)memory_region(REGION_USER5);
21822182   UINT32 start = real_dest;
r1293r1294
22172217   }
22182218}
22192219
2220void cps3_process_character_dma(UINT32 address)
2220static void cps3_process_character_dma(UINT32 address)
22212221{
22222222   int i;
22232223
r1293r1294
23512351   }
23522352}
23532353
2354UINT32* cps3_mainram;
2354static UINT32* cps3_mainram;
23552355
23562356/* there are more unknown writes, but you get the idea */
23572357static ADDRESS_MAP_START( cps3_map, ADDRESS_SPACE_PROGRAM, 32 )
r1293r1294
24842484};
24852485
24862486
2487static mame_timer* fastboot_timer;
2487static emu_timer* fastboot_timer;
24882488
24892489static TIMER_CALLBACK( fastboot_timer_callback )
24902490{
r1293r1294
25152515
25162516   if (cps3_use_fastboot)
25172517   {
2518      fastboot_timer = mame_timer_alloc(fastboot_timer_callback);
2518      fastboot_timer = timer_alloc(fastboot_timer_callback);
25192519   //  printf("reset\n");
2520      mame_timer_adjust(fastboot_timer, time_zero, 0, time_zero);
2520      timer_adjust(fastboot_timer, attotime_zero, 0, attotime_zero);
25212521   }
25222522}
25232523
r1293r1294
30223022ROM_END
30233023
30243024/* Idle loop skipping speedups */
3025UINT32 cps3_speedup_ram_address;
3026UINT32 cps3_speedup_code_address;
3025static UINT32 cps3_speedup_ram_address;
3026static UINT32 cps3_speedup_code_address;
30273027
30283028struct cps3_speedups
30293029{
src/mame/drivers/glass.c
r1293r1294
299299
300300***************************************************************************/
301301
302void glass_ROM16_split(int src_reg, int dst_reg, int start, int length, int dest1, int dest2)
302static void glass_ROM16_split(int src_reg, int dst_reg, int start, int length, int dest1, int dest2)
303303{
304304   int i;
305305
src/mame/drivers/toaplan2.c
r1293r1294
575575static void toaplan2_vblank_irq(int irq_line)
576576{
577577   /* the IRQ appears to fire at line 0xe6 */
578   mame_timer_set(video_screen_get_time_until_pos(0, 0xe6, 0), irq_line, toaplan2_raise_irq);
578   timer_set(video_screen_get_time_until_pos(0, 0xe6, 0), irq_line, toaplan2_raise_irq);
579579}
580580
581581static INTERRUPT_GEN( toaplan2_vblank_irq1 ) { toaplan2_vblank_irq(1); }
src/mame/drivers/mjkjidai.c
r1293r1294
7373   }
7474}
7575
76void *mjkjidai_adpcm_start (int clock, const struct CustomSound_interface *config)
76static void *mjkjidai_adpcm_start (int clock, const struct CustomSound_interface *config)
7777{
7878   struct mjkjidai_adpcm_state *state = &mjkjidai_adpcm;
7979   state->playing = 0;
src/mame/drivers/jchan.c
r1293r1294
219219***************************************************************************/
220220static UINT16 *mcu_ram, jchan_mcu_com[4];
221221
222void jchan_mcu_run(void)
222static void jchan_mcu_run(void)
223223{
224224   UINT16 mcu_command = mcu_ram[0x0010/2];      /* command nb */
225225   UINT16 mcu_offset  = mcu_ram[0x0012/2] / 2;   /* offset in shared RAM where MCU will write */
r1293r1294
398398
399399static UINT16 *jchan_spriteram;
400400
401INTERRUPT_GEN( jchan_vblank )
401static INTERRUPT_GEN( jchan_vblank )
402402{
403403   if (!cpu_getiloops())
404404      cpunum_set_input_line(0, 1, HOLD_LINE);
r1293r1294
532532   buffered_spriteram32[offset]=(jchan_spriteram[offset*2+1]<<16) | (jchan_spriteram[offset*2]);
533533}
534534
535UINT16* jchan_sprregs;
535static UINT16* jchan_sprregs;
536536
537537static WRITE16_HANDLER( jchan_suprnova_sprite32regs_w )
538538{
src/mame/drivers/gaelco.c
r1293r1294
1616extern UINT16 *gaelco_videoram;
1717extern UINT16 *gaelco_spriteram;
1818extern tilemap *gaelco_tilemap[2];
19UINT16 *gaelco_screen;
19static UINT16 *gaelco_screen;
2020
2121/* from video/gaelco.c */
2222WRITE16_HANDLER( gaelco_vram_w );
src/mame/drivers/wecleman.c
r1293r1294
12711271
12721272ROM_END
12731273
1274void wecleman_unpack_sprites(void)
1274static void wecleman_unpack_sprites(void)
12751275{
12761276   const int region       = REGION_GFX1;   // sprites
12771277
r1293r1294
13991399    in a ROM module definition.  This routine unpacks each sprite nibble
14001400    into a byte, doubling the memory consumption. */
14011401
1402void hotchase_sprite_decode( int num16_banks, int bank_size )
1402static void hotchase_sprite_decode( int num16_banks, int bank_size )
14031403{
14041404   UINT8 *base, *temp;
14051405   int i;
src/mame/drivers/dmndrby.c
r1293r1294
165165   return 0;
166166}
167167
168INTERRUPT_GEN( dderby_interrupt )
168static INTERRUPT_GEN( dderby_interrupt )
169169{
170170//  cpunum_set_input_line_and_vector(0, 0, HOLD_LINE, 0x8);  // almost certainly wrong?
171171//  cpunum_set_input_line_and_vector(0, 0, HOLD_LINE, 0x10); // almost certainly wrong?
src/mame/drivers/seattle.c
r1293r1294
215215 *************************************/
216216
217217#define SYSTEM_CLOCK         50000000
218#define TIMER_PERIOD         MAME_TIME_IN_HZ(SYSTEM_CLOCK)
218#define TIMER_PERIOD         ATTOTIME_IN_HZ(SYSTEM_CLOCK)
219219
220220/* various board configurations */
221221#define PHOENIX_CONFIG         (0)
r1293r1294
381381
382382struct galileo_timer
383383{
384   mame_timer *      timer;
384   emu_timer *      timer;
385385   UINT32         count;
386386   UINT8         active;
387387};
r1293r1294
541541   cpunum_set_info_int(0, CPUINFO_INT_MIPS3_FASTRAM_READONLY, 1);
542542
543543   /* allocate timers for the galileo */
544   galileo.timer[0].timer = mame_timer_alloc(galileo_timer_callback);
545   galileo.timer[1].timer = mame_timer_alloc(galileo_timer_callback);
546   galileo.timer[2].timer = mame_timer_alloc(galileo_timer_callback);
547   galileo.timer[3].timer = mame_timer_alloc(galileo_timer_callback);
544   galileo.timer[0].timer = timer_alloc(galileo_timer_callback);
545   galileo.timer[1].timer = timer_alloc(galileo_timer_callback);
546   galileo.timer[2].timer = timer_alloc(galileo_timer_callback);
547   galileo.timer[3].timer = timer_alloc(galileo_timer_callback);
548548   galileo.dma_active = -1;
549549
550550   vblank_irq_num = 0;
r1293r1294
915915
916916   /* if we're a timer, adjust the timer to fire again */
917917   if (galileo.reg[GREG_TIMER_CONTROL] & (2 << (2 * which)))
918      mame_timer_adjust(timer->timer, scale_up_mame_time(TIMER_PERIOD, timer->count), which, time_zero);
918      timer_adjust(timer->timer, attotime_mul(TIMER_PERIOD, timer->count), which, attotime_zero);
919919   else
920920      timer->active = timer->count = 0;
921921
r1293r1294
10951095         result = timer->count;
10961096         if (timer->active)
10971097         {
1098            UINT32 elapsed = mame_time_to_double(scale_up_mame_time(mame_timer_timeelapsed(timer->timer), SYSTEM_CLOCK));
1098            UINT32 elapsed = attotime_to_double(attotime_mul(timer_timeelapsed(timer->timer), SYSTEM_CLOCK));
10991099            result = (result > elapsed) ? (result - elapsed) : 0;
11001100         }
11011101
r1293r1294
12261226                  if (which != 0)
12271227                     timer->count &= 0xffffff;
12281228               }
1229               mame_timer_adjust(timer->timer, scale_up_mame_time(TIMER_PERIOD, timer->count), which, time_zero);
1229               timer_adjust(timer->timer, attotime_mul(TIMER_PERIOD, timer->count), which, attotime_zero);
12301230               if (LOG_TIMERS)
1231                  logerror("Adjusted timer to fire in %f secs\n", mame_time_to_double(scale_up_mame_time(TIMER_PERIOD, timer->count)));
1231                  logerror("Adjusted timer to fire in %f secs\n", attotime_to_double(attotime_mul(TIMER_PERIOD, timer->count)));
12321232            }
12331233            else if (timer->active && !(data & mask))
12341234            {
1235               UINT32 elapsed = mame_time_to_double(scale_up_mame_time(mame_timer_timeelapsed(timer->timer), SYSTEM_CLOCK));
1235               UINT32 elapsed = attotime_to_double(attotime_mul(timer_timeelapsed(timer->timer), SYSTEM_CLOCK));
12361236               timer->active = 0;
12371237               timer->count = (timer->count > elapsed) ? (timer->count - elapsed) : 0;
1238               mame_timer_adjust(timer->timer, time_never, which, time_zero);
1238               timer_adjust(timer->timer, attotime_never, which, attotime_zero);
12391239               if (LOG_TIMERS)
12401240                  logerror("Disabled timer\n");
12411241            }
r1293r1294
24542454   SYSTEM_CLOCK   /* system clock rate */
24552455};
24562456
2457MACHINE_DRIVER_START( seattle_common )
2457static MACHINE_DRIVER_START( seattle_common )
24582458
24592459   /* basic machine hardware */
24602460   MDRV_CPU_ADD_TAG("main", R5000LE, SYSTEM_CLOCK*3)
r1293r1294
24792479MACHINE_DRIVER_END
24802480
24812481
2482MACHINE_DRIVER_START( phoenixsa )
2482static MACHINE_DRIVER_START( phoenixsa )
24832483   MDRV_IMPORT_FROM(seattle_common)
24842484   MDRV_CPU_REPLACE("main", R4700LE, SYSTEM_CLOCK*2)
24852485   MDRV_IMPORT_FROM(dcs2_audio_2115)
24862486MACHINE_DRIVER_END
24872487
24882488
2489MACHINE_DRIVER_START( seattle150 )
2489static MACHINE_DRIVER_START( seattle150 )
24902490   MDRV_IMPORT_FROM(seattle_common)
24912491   MDRV_CPU_REPLACE("main", R5000LE, SYSTEM_CLOCK*3)
24922492   MDRV_IMPORT_FROM(dcs2_audio_2115)
24932493MACHINE_DRIVER_END
24942494
24952495
2496MACHINE_DRIVER_START( seattle200 )
2496static MACHINE_DRIVER_START( seattle200 )
24972497   MDRV_IMPORT_FROM(seattle_common)
24982498   MDRV_CPU_REPLACE("main", R5000LE, SYSTEM_CLOCK*4)
24992499   MDRV_IMPORT_FROM(dcs2_audio_2115)
25002500MACHINE_DRIVER_END
25012501
25022502
2503MACHINE_DRIVER_START( flagstaff )
2503static MACHINE_DRIVER_START( flagstaff )
25042504   MDRV_IMPORT_FROM(seattle_common)
25052505   MDRV_CPU_REPLACE("main", R5000LE, SYSTEM_CLOCK*4)
25062506   MDRV_VIDEO_START(flagstaff)
src/mame/drivers/btoads.c
r1293r1294
5555   cpu_triggerint(1);
5656
5757   /* use a timer to make long transfers faster */
58   mame_timer_set(MAME_TIME_IN_USEC(50), 0, 0);
58   timer_set(ATTOTIME_IN_USEC(50), 0, 0);
5959}
6060
6161
src/mame/drivers/tetrisp2.c
r1293r1294
3838#include "rocknms.lh"
3939
4040UINT16 tetrisp2_systemregs[0x10];
41UINT16 rocknms_sub_systemregs[0x10];
41static UINT16 rocknms_sub_systemregs[0x10];
4242
43UINT16 rockn_protectdata;
44UINT16 rockn_adpcmbank;
45UINT16 rockn_soundvolume;
43static UINT16 rockn_protectdata;
44static UINT16 rockn_adpcmbank;
45static UINT16 rockn_soundvolume;
4646
47static mame_timer *rockn_timer_l4;
48static mame_timer *rockn_timer_sub_l4;
47static emu_timer *rockn_timer_l4;
48static emu_timer *rockn_timer_sub_l4;
4949
5050/* Variables defined in video: */
5151
r1293r1294
102102   }
103103}
104104
105#define ROCKN_TIMER_BASE MAME_TIME_IN_NSEC(500000)
105#define ROCKN_TIMER_BASE ATTOTIME_IN_NSEC(500000)
106106
107107static WRITE16_HANDLER( rockn_systemregs_w )
108108{
r1293r1294
111111      tetrisp2_systemregs[offset] = data;
112112      if (offset == 0x0c)
113113      {
114         mame_time timer = scale_up_mame_time(ROCKN_TIMER_BASE, 4096 - data);
115         mame_timer_adjust(rockn_timer_l4, timer, 0, timer);
114         attotime timer = attotime_mul(ROCKN_TIMER_BASE, 4096 - data);
115         timer_adjust(rockn_timer_l4, timer, 0, timer);
116116      }
117117   }
118118}
r1293r1294
125125      rocknms_sub_systemregs[offset] = data;
126126      if (offset == 0x0c)
127127      {
128         mame_time timer = scale_up_mame_time(ROCKN_TIMER_BASE, 4096 - data);
129         mame_timer_adjust(rockn_timer_sub_l4, timer, 0, timer);
128         attotime timer = attotime_mul(ROCKN_TIMER_BASE, 4096 - data);
129         timer_adjust(rockn_timer_sub_l4, timer, 0, timer);
130130      }
131131   }
132132}
r1293r1294
10241024
10251025static void init_rockn_timer(running_machine *machine)
10261026{
1027   mame_timer_pulse(MAME_TIME_IN_MSEC(32), 0, rockn_timer_level1_callback);
1028   rockn_timer_l4 = mame_timer_alloc(rockn_timer_level4_callback);
1027   timer_pulse(ATTOTIME_IN_MSEC(32), 0, rockn_timer_level1_callback);
1028   rockn_timer_l4 = timer_alloc(rockn_timer_level4_callback);
10291029
10301030   state_save_register_global_array(tetrisp2_systemregs);
10311031   state_save_register_global_array(rocknms_sub_systemregs);
r1293r1294
10561056{
10571057   init_rockn_timer(machine);
10581058
1059   mame_timer_pulse(MAME_TIME_IN_MSEC(32), 0, rockn_timer_sub_level1_callback);
1060   rockn_timer_sub_l4 = mame_timer_alloc(rockn_timer_sub_level4_callback);
1059   timer_pulse(ATTOTIME_IN_MSEC(32), 0, rockn_timer_sub_level1_callback);
1060   rockn_timer_sub_l4 = timer_alloc(rockn_timer_sub_level4_callback);
10611061
10621062   rockn_protectdata = 3;
10631063
src/mame/drivers/boxer.c
r1293r1294
5757      {
5858         if (mask[i] != 0)
5959         {
60            mame_timer_set(video_screen_get_time_until_pos(0, i, 0), mask[i], pot_interrupt);
60            timer_set(video_screen_get_time_until_pos(0, i, 0), mask[i], pot_interrupt);
6161         }
6262      }
6363
r1293r1294
7171      scanline = 0;
7272   }
7373
74   mame_timer_set(video_screen_get_time_until_pos(0, scanline, 0), scanline, periodic_callback);
74   timer_set(video_screen_get_time_until_pos(0, scanline, 0), scanline, periodic_callback);
7575}
7676
7777
r1293r1294
8989
9090static MACHINE_RESET( boxer )
9191{
92   mame_timer_set(video_screen_get_time_until_pos(0, 0, 0), 0, periodic_callback);
92   timer_set(video_screen_get_time_until_pos(0, 0, 0), 0, periodic_callback);
9393
9494   pot_latch = 0;
9595}
src/mame/drivers/starfire.c
r1293r1294
7474   scanline += SCANLINE_UPDATE_CHUNK;
7575   if (scanline >= machine->screen[0].height)
7676      scanline = 32;
77   mame_timer_set(video_screen_get_time_until_pos(0, scanline + SCANLINE_UPDATE_CHUNK - 1, 0), scanline, update_callback);
77   timer_set(video_screen_get_time_until_pos(0, scanline + SCANLINE_UPDATE_CHUNK - 1, 0), scanline, update_callback);
7878}
7979
8080
8181static MACHINE_RESET( starfire )
8282{
83   mame_timer_set(video_screen_get_time_until_pos(0, 32 + SCANLINE_UPDATE_CHUNK - 1, 0), 32, update_callback);
83   timer_set(video_screen_get_time_until_pos(0, 32 + SCANLINE_UPDATE_CHUNK - 1, 0), 32, update_callback);
8484}
8585
8686
src/mame/drivers/tmaster.c
r1293r1294
1/* Touch Master */
1/***************************************************************************
22
3/*
3                          -=  Touch Master Games =-
44
5Main CPU: 68000
6Sound Chip: OKI6295
5                    driver by   Luca Elia (l.elia@tin.it)
76
8Protection (some sets): DS1225a?
97
10According to readme's TM3k might not be protected.
8CPU:    68000
9Video:  Blitter, double framebuffer
10Sound:  OKI6295
11Input:  Pressure sensitive touch screen
12Other:  Dallas NVRAM + optional RTC
1113
12GFX might be some kind of blitter device, with memory mapped framebuffer?
1314
14*/
15To Do:
1516
17- Proper touchscreen controller emulation. Currently it's flakey and
18  tends to stop registering user input (try coining up in that case)
19- Protection in tm4k
20- Coin optics
21- RTC emulation (there's code to check the upper bytes of NVRAM to see if
22  the real time clock is present, and to only use it in that case)
23
24
25***************************************************************************/
26
1627#include "driver.h"
1728#include "sound/okim6295.h"
1829
19static VIDEO_START( tmaster )
30/***************************************************************************
31
32                                   Sound
33
34***************************************************************************/
35
36int okibank;
37static WRITE16_HANDLER( tmaster_oki_bank_w )
2038{
39   if (ACCESSING_MSB)
40   {
41      // data & 0x0800?
42      okibank = ((data >> 8) & 3);
43      OKIM6295_set_bank_base(0, okibank * 0x40000);
44   }
45
46   if (ACCESSING_LSB)
47   {
48      // data & 0x0002?
49   }
2150}
2251
23static VIDEO_UPDATE( tmaster )
52/***************************************************************************
53
54                     Touch Screen Controller - PRELIMINARY
55
56***************************************************************************/
57
58int touchscreen;
59
60void show_touchscreen(void)
2461{
25   return 0;
62#ifdef MAME_DEBUG
63   popmessage("% d] %03x %03x - %d",touchscreen,readinputportbytag("TSCREEN_X")&0x1ff,readinputportbytag("TSCREEN_Y"),okibank);
64#endif
2665}
2766
28static READ16_HANDLER( tmaster_unk_0x300010_r )
67static WRITE16_HANDLER( tmaster_tscreen_reset_w )
2968{
30   return mame_rand(Machine);
69   if (ACCESSING_LSB && data == 0x05)
70   {
71      touchscreen = 0;
72      show_touchscreen();
73   }
3174}
3275
33static WRITE16_HANDLER( tmaster_unk_0x300020_w )
76static READ16_HANDLER( tmaster_tscreen_next_r )
3477{
78   if (touchscreen != -1)
79      touchscreen++;
80   if (touchscreen == 6)
81      touchscreen = -1;
82   show_touchscreen();
3583
84   return 0;
3685}
3786
38static WRITE16_HANDLER( tmaster_unk_0x300040_w )
87static READ16_HANDLER( tmaster_tscreen_x_hi_r )
3988{
40
89   switch (touchscreen)
90   {
91      case -1:   return 0xf1;
92   }
93   return 0x01;
4194}
4295
43static WRITE16_HANDLER( tmaster_unk_0x300070_w )
96static READ16_HANDLER( tmaster_tscreen_x_lo_r )
4497{
98   UINT16 val = 0;
4599
100   int press1 = readinputportbytag("TSCREEN_X") & 0x4000;
101   int press2 = readinputportbytag("TSCREEN_X") & 0x8000;
102   if (press1)   press2 = 1;
103
104   switch (touchscreen)
105   {
106      case 1:   val = press1 ? 0 : 1<<6;   break;   // press
107      case 2:   val = readinputportbytag("TSCREEN_X") & 0x003;   break;
108      case 3:   val = (readinputportbytag("TSCREEN_X") >> 2) & 0x7f;   break;
109      case 4:   val = 0;   break;
110      case 5:   val = ((readinputportbytag("TSCREEN_Y")^0xff) >> 1) & 0x7f;   break;
111
112      default:
113         return 0;
114   }
115   return val | (press2 ? 0x80 : 0);   // away : hover
46116}
47117
48static WRITE16_HANDLER( tmaster_unk_0x500010_w )
118static READ16_HANDLER( tmaster_tscreen_y_hi_r )   {   return 0x01;   }
119static READ16_HANDLER( tmaster_tscreen_y_lo_r )   {   return 0x00;   }
120
121
122
123/***************************************************************************
124
125                                Video & Blitter
126
127***************************************************************************/
128
129static mame_bitmap *tmaster_bitmap[2];
130UINT16 *tmaster_regs;
131UINT16 tmaster_color;
132UINT16 tmaster_addr;
133
134static VIDEO_START( tmaster )
49135{
136   int i;
137   for (i = 0; i < 2; i++)
138      tmaster_bitmap[i] = auto_bitmap_alloc(machine->screen[0].width,machine->screen[0].height,machine->screen[0].format);
139}
50140
141static VIDEO_UPDATE( tmaster )
142{
143   // double buffering
144   copybitmap(bitmap,tmaster_bitmap[(tmaster_regs[0x02/2]>>8)&1],0,0,0,0,&machine->screen[0].visarea,TRANSPARENCY_NONE,0);
145
146   show_touchscreen();
147   return 0;
51148}
52149
53static WRITE16_HANDLER( tmaster_unk_0x500020_w )
150static WRITE16_HANDLER( tmaster_color_w )
54151{
152   COMBINE_DATA( &tmaster_color );
153   if (tmaster_color & ~7)
154      logerror("%06x: color %04x\n", activecpu_get_pc(), tmaster_color);
155}
55156
157static WRITE16_HANDLER( tmaster_addr_w )
158{
159   COMBINE_DATA( &tmaster_addr );
56160}
57161
58static WRITE16_HANDLER( tmaster_unk_0x500000_range_w )
162static void tmaster_draw(void)
59163{
164   int x,y,x0,x1,y0,y1,dx,dy,flipx,flipy,sx,sy,sw,sh, addr, mode, dest;
60165
166   UINT8 *gfxdata   =   memory_region( REGION_GFX1 );
167   size_t size      =   memory_region_length( REGION_GFX1 );
168
169   UINT16 data;
170
171   mame_bitmap *bitmap;
172
173   dest   =    (tmaster_regs[0x02/2] >> 8) & 1;
174    sw      =     tmaster_regs[0x04/2];
175   sx      =     tmaster_regs[0x06/2];
176   sh      =     tmaster_regs[0x08/2] + 1;
177   sy      =     tmaster_regs[0x0a/2];
178   addr   =   ( tmaster_regs[0x0c/2] & 0xff) |
179            ((tmaster_regs[0x0e/2] & 0x1ff) << 8) | (tmaster_addr << 17);
180   mode   =     tmaster_regs[0x10/2];
181
182   dest   ^=   (mode >> 6) & 1;
183   bitmap   =   tmaster_bitmap[dest];
184
185   addr <<= 1;
186
187#if 0
188   logerror("%06x: blit w %03x, h %02x, x %03x, y %02x, addr %06x, mode %02x\n", activecpu_get_pc(),
189         sw,sh,sx,sy, addr, mode
190   );
191#endif
192
193   flipx = mode & 1;
194   flipy = mode & 2;
195
196   if (flipx)   { x0 = sw-1;   x1 = -1;   dx = -1;   sx -= sw-1;   }
197   else      { x0 = 0;      x1 = sw;   dx = +1;   }
198
199   if (flipy)   { y0 = sh-1;   y1 = -1;   dy = -1;   sy -= sh-1;   }
200   else      { y0 = 0;      y1 = sh;   dy = +1;   }
201
202   switch (mode & 0x20)
203   {
204      case 0x00:                     // blit with transparency
205         if (addr > (size - sw*sh))
206         {
207            logerror("%06x: blit error, addr %06x out of bounds\n", activecpu_get_pc(),addr);
208            return;
209         }
210
211         for (y = y0; y != y1; y += dy)
212         {
213            for (x = x0; x != x1; x += dx)
214            {
215               data = gfxdata[addr++];
216
217               if ((data != 0xff) && (sx + x >= 0) && (sx + x < 400) && (sy + y >= 0) && (sy + y < 256))
218                  *BITMAP_ADDR16(bitmap, sy + y, sx + x) = data + ((tmaster_color & 7) << 8);
219            }
220         }
221         break;
222
223      case 0x20:                     // solid fill
224         data = tmaster_addr & 0xff;
225         for (y = y0; y != y1; y += dy)
226         {
227            for (x = x0; x != x1; x += dx)
228            {
229               if ((sx + x >= 0) && (sx + x < 400) && (sy + y >= 0) && (sy + y < 256))
230                  *BITMAP_ADDR16(bitmap, sy + y, sx + x) = data + ((tmaster_color & 7) << 8);
231            }
232         }
233         break;
234
235   }
61236}
62237
63static WRITE16_HANDLER( tmaster_unk_0x800010_w )
238WRITE16_HANDLER( tmaster_blitter_w )
64239{
240   COMBINE_DATA( tmaster_regs + offset );
241   switch (offset*2)
242   {
243      case 0x0e:
244         tmaster_draw();
245         cpunum_set_input_line(0, 2, HOLD_LINE);
246         break;
247   }
248}
65249
250static READ16_HANDLER( tmaster_blitter_r )
251{
252   return 0x0000;   // bit 7 = 1 -> blitter busy
66253}
67254
68static READ16_HANDLER( tmaster_unk_0x500010_r )
255/***************************************************************************
256
257                                Memory Maps
258
259***************************************************************************/
260
261static READ16_HANDLER( tmaster_coins_r )
69262{
70   return mame_rand(Machine);
263   return readinputportbytag("COIN")|(mame_rand(Machine)&0x0800);
71264}
72265
73static ADDRESS_MAP_START( tmaster_readmem, ADDRESS_SPACE_PROGRAM, 16 )
74   AM_RANGE(0x000000, 0x1fffff) AM_READ(MRA16_ROM)
75   AM_RANGE(0x200000, 0x27ffff) AM_READ(MRA16_RAM)
266static ADDRESS_MAP_START( tmaster_map, ADDRESS_SPACE_PROGRAM, 16 )
267   AM_RANGE( 0x000000, 0x1fffff ) AM_ROM
268   AM_RANGE( 0x200000, 0x27ffff ) AM_RAM
269   AM_RANGE( 0x280000, 0x28ffff ) AM_RAM AM_BASE(&generic_nvram16) AM_SIZE(&generic_nvram_size)
76270
77   AM_RANGE(0x300010, 0x300011) AM_READ(tmaster_unk_0x300010_r)
271   AM_RANGE( 0x300010, 0x300011 ) AM_READ( tmaster_coins_r )
78272
79   AM_RANGE(0x500010, 0x500011) AM_READ(tmaster_unk_0x500010_r)
273   AM_RANGE( 0x300022, 0x300023 ) AM_READ ( tmaster_tscreen_x_hi_r )
274   AM_RANGE( 0x300024, 0x300025 ) AM_WRITE( tmaster_tscreen_reset_w )
275   AM_RANGE( 0x300026, 0x300027 ) AM_READ ( tmaster_tscreen_x_lo_r )
276   AM_RANGE( 0x300028, 0x300029 ) AM_READ ( tmaster_tscreen_next_r )
277   AM_RANGE( 0x300032, 0x300033 ) AM_READ ( tmaster_tscreen_y_hi_r )
278   AM_RANGE( 0x300036, 0x300037 ) AM_READ ( tmaster_tscreen_y_lo_r )
80279
81   AM_RANGE(0x600000, 0x600fff) AM_READ(MRA16_RAM)
280   AM_RANGE( 0x300040, 0x300041 ) AM_WRITE( tmaster_oki_bank_w )
82281
83ADDRESS_MAP_END
282   AM_RANGE( 0x300070, 0x300071 ) AM_WRITE( tmaster_addr_w )
84283
85static ADDRESS_MAP_START( tmaster_writemem, ADDRESS_SPACE_PROGRAM, 16 )
86   AM_RANGE(0x000000, 0x1fffff) AM_WRITE(MWA16_ROM)
87   AM_RANGE(0x200000, 0x27ffff) AM_WRITE(MWA16_RAM)
284   AM_RANGE( 0x500000, 0x500011 ) AM_WRITE( tmaster_blitter_w ) AM_BASE( &tmaster_regs )
285   AM_RANGE( 0x500010, 0x500011 ) AM_READ ( tmaster_blitter_r )
88286
89   AM_RANGE(0x300020, 0x300021) AM_WRITE(tmaster_unk_0x300020_w)
90   AM_RANGE(0x300040, 0x300041) AM_WRITE(tmaster_unk_0x300040_w)
91   AM_RANGE(0x300070, 0x300071) AM_WRITE(tmaster_unk_0x300070_w)
287   AM_RANGE( 0x580000, 0x580001 ) AM_WRITE(MWA16_NOP) // often
92288
93   /* blitter writes? */
94   AM_RANGE(0x500000, 0x50000f) AM_WRITE(tmaster_unk_0x500000_range_w)
95   AM_RANGE(0x500010, 0x500011) AM_WRITE(tmaster_unk_0x500010_w)
96   AM_RANGE(0x500020, 0x500021) AM_WRITE(tmaster_unk_0x500020_w)
289   AM_RANGE( 0x600000, 0x600fff ) AM_READWRITE( MRA16_RAM, paletteram16_xBBBBBGGGGGRRRRR_word_w ) AM_BASE(&paletteram16) // looks like palettes, maybe
97290
98   AM_RANGE(0x580000, 0x580001) AM_WRITE(MWA16_NOP) // often
291   AM_RANGE( 0x800000, 0x800001 ) AM_READWRITE( OKIM6295_status_0_lsb_r, OKIM6295_data_0_lsb_w )
99292
100   AM_RANGE(0x600000, 0x600fff) AM_WRITE(paletteram16_xRRRRRGGGGGBBBBB_word_w) AM_BASE(&paletteram16) // looks like palettes, maybe
101
102   AM_RANGE(0x800010, 0x800011) AM_WRITE(tmaster_unk_0x800010_w)
293   AM_RANGE( 0x800010, 0x800011 ) AM_WRITE( tmaster_color_w )
103294ADDRESS_MAP_END
104295
105296
297/***************************************************************************
106298
107static INPUT_PORTS_START( tmaster )
108    PORT_START
109    PORT_DIPNAME( 0x0001, 0x0001, "DSW" )
110    PORT_DIPSETTING(      0x0001, DEF_STR( Off ) )
111    PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
112    PORT_DIPNAME( 0x0002, 0x0002, DEF_STR( Unknown ) )
113    PORT_DIPSETTING(      0x0002, DEF_STR( Off ) )
114    PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
115    PORT_DIPNAME( 0x0004, 0x0004, DEF_STR( Unknown ) )
116    PORT_DIPSETTING(      0x0004, DEF_STR( Off ) )
117    PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
118    PORT_DIPNAME( 0x0008, 0x0008, DEF_STR( Unknown ) )
119    PORT_DIPSETTING(      0x0008, DEF_STR( Off ) )
120    PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
121    PORT_DIPNAME( 0x0010, 0x0010, DEF_STR( Unknown ) )
122    PORT_DIPSETTING(      0x0010, DEF_STR( Off ) )
123    PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
124    PORT_DIPNAME( 0x0020, 0x0020, DEF_STR( Unknown ) )
125    PORT_DIPSETTING(      0x0020, DEF_STR( Off ) )
126    PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
127    PORT_DIPNAME( 0x0040, 0x0040, DEF_STR( Unknown ) )
128    PORT_DIPSETTING(      0x0040, DEF_STR( Off ) )
129    PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
130    PORT_DIPNAME( 0x0080, 0x0080, DEF_STR( Unknown ) )
131    PORT_DIPSETTING(      0x0080, DEF_STR( Off ) )
132    PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
133    PORT_DIPNAME( 0x0100, 0x0100, DEF_STR( Unknown ) )
134    PORT_DIPSETTING(      0x0100, DEF_STR( Off ) )
135    PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
136    PORT_DIPNAME( 0x0200, 0x0200, DEF_STR( Unknown ) )
137    PORT_DIPSETTING(      0x0200, DEF_STR( Off ) )
138    PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
139    PORT_DIPNAME( 0x0400, 0x0400, DEF_STR( Unknown ) )
140    PORT_DIPSETTING(      0x0400, DEF_STR( Off ) )
141    PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
142    PORT_DIPNAME( 0x0800, 0x0800, DEF_STR( Unknown ) )
143    PORT_DIPSETTING(      0x0800, DEF_STR( Off ) )
144    PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
145    PORT_DIPNAME( 0x1000, 0x1000, DEF_STR( Unknown ) )
146    PORT_DIPSETTING(      0x1000, DEF_STR( Off ) )
147    PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
148    PORT_DIPNAME( 0x2000, 0x2000, DEF_STR( Unknown ) )
149    PORT_DIPSETTING(      0x2000, DEF_STR( Off ) )
150    PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
151    PORT_DIPNAME( 0x4000, 0x4000, DEF_STR( Unknown ) )
152    PORT_DIPSETTING(      0x4000, DEF_STR( Off ) )
153    PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
154    PORT_DIPNAME( 0x8000, 0x8000, DEF_STR( Unknown ) )
155    PORT_DIPSETTING(      0x8000, DEF_STR( Off ) )
156    PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
299                                Input Ports
300
301***************************************************************************/
302
303INPUT_PORTS_START( tmaster )
304   PORT_START_TAG("TSCREEN_X")
305   PORT_BIT( 0x01ff, 0x100, IPT_LIGHTGUN_X ) PORT_CROSSHAIR(X, 1, 0, 0) PORT_SENSITIVITY(35) PORT_KEYDELTA(3) PORT_PLAYER(1)
306   PORT_BIT( 0x4000, IP_ACTIVE_HIGH, IPT_BUTTON1 )   PORT_IMPULSE(5)   // press
307   PORT_BIT( 0x8000, IP_ACTIVE_HIGH, IPT_BUTTON2 )               // hover
308
309   PORT_START_TAG("TSCREEN_Y")
310   PORT_BIT( 0x0ff, 0x80, IPT_LIGHTGUN_Y ) PORT_CROSSHAIR(Y, 1, 0, 0) PORT_SENSITIVITY(35) PORT_KEYDELTA(3) PORT_PLAYER(1)
311
312   PORT_START_TAG("COIN") // IN3
313   PORT_BIT( 0x0001, IP_ACTIVE_LOW,  IPT_COIN1      )   PORT_IMPULSE(2)   // m. coin 1 (coin optics?)
314   PORT_BIT( 0x0002, IP_ACTIVE_LOW,  IPT_COIN1      )   PORT_IMPULSE(4)   // m. coin 2 (coin optics?)
315   PORT_BIT( 0x0004, IP_ACTIVE_LOW,  IPT_COIN1      )   PORT_IMPULSE(6)   // dbv input (coin optics?)
316   PORT_BIT( 0x0008, IP_ACTIVE_LOW,  IPT_UNKNOWN   )
317   PORT_BIT( 0x0010, IP_ACTIVE_LOW,  IPT_COIN1      )   // (service coin?)
318   PORT_SERVICE_NO_TOGGLE( 0x0020, IP_ACTIVE_LOW   )
319   PORT_BIT( 0x0040, IP_ACTIVE_LOW,  IPT_SERVICE1   )   // calibrate
320   PORT_BIT( 0x0080, IP_ACTIVE_LOW,  IPT_UNKNOWN   )
321   PORT_BIT( 0x0100, IP_ACTIVE_LOW,  IPT_UNKNOWN   )
322   PORT_BIT( 0x0200, IP_ACTIVE_LOW,  IPT_UNKNOWN   )
323   PORT_BIT( 0x0400, IP_ACTIVE_LOW,  IPT_UNKNOWN   )
324   PORT_BIT( 0x0800, IP_ACTIVE_HIGH, IPT_SPECIAL   )
325   PORT_BIT( 0x1000, IP_ACTIVE_LOW,  IPT_COIN1      )   // e. coin 1
326   PORT_BIT( 0x2000, IP_ACTIVE_LOW,  IPT_COIN2      )   // e. coin 2
327   PORT_BIT( 0x4000, IP_ACTIVE_LOW,  IPT_COIN3      )   // e. coin 3
328   PORT_BIT( 0x8000, IP_ACTIVE_LOW,  IPT_COIN4      )   // e. coin 4
157329INPUT_PORTS_END
158330
159331
160/* Gfx are not tile based...*/
161static const gfx_layout tmaster_layout =
162{
163   8,8,
164   RGN_FRAC(1,1),
165   4,
166   { 0,1,2,3 },
167   { 0,4,8,12,16,20,24,28 },
168   { 0*32, 1*32, 2*32, 3*32, 4*32, 5*32, 6*32, 7*32 },
169   8*32
170};
332/***************************************************************************
171333
172static GFXDECODE_START( tmaster )
173   GFXDECODE_ENTRY( REGION_GFX1, 0, tmaster_layout,   0x300, 2  )
174   GFXDECODE_ENTRY( REGION_GFX2, 0, tmaster_layout,   0x300, 2  )
175   GFXDECODE_ENTRY( REGION_GFX3, 0, tmaster_layout,   0x300, 2  )
176GFXDECODE_END
334                               Machine Drivers
177335
178static INTERRUPT_GEN( tmaster_interrupt )
336***************************************************************************/
337
338static MACHINE_RESET( tmaster )
179339{
180   cpunum_set_input_line(0, cpu_getiloops()+1, HOLD_LINE);   /* IRQs 1, 2, and 3 */
340   touchscreen = -1;
181341}
182342
183static MACHINE_DRIVER_START( tmaster )
184   MDRV_CPU_ADD_TAG("main", M68000, 12000000)    // or 6mhz?
185   MDRV_CPU_PROGRAM_MAP(tmaster_readmem,tmaster_writemem)
186   MDRV_CPU_VBLANK_INT(tmaster_interrupt,3) // ??
187   /* irqs 1,2,3 look valid */
343static INTERRUPT_GEN( tm3k_interrupt )
344{
345   switch (cpu_getiloops())
346   {
347      case 0:      cpunum_set_input_line(0, 2, HOLD_LINE);   break;
348      case 1:      cpunum_set_input_line(0, 3, HOLD_LINE);   break;
188349
350      case 2:
351      case 3:
352      case 4:
353      case 5:
354      case 6:      cpunum_set_input_line_and_vector(0, 4, HOLD_LINE, 0x100/4);   break;   // touch screen controller
355
356      default:   cpunum_set_input_line(0, 1, HOLD_LINE);   break;
357   }
358}
359
360static MACHINE_DRIVER_START( tm3k )
361   MDRV_CPU_ADD_TAG("main", M68000, 12000000)
362   MDRV_CPU_PROGRAM_MAP(tmaster_map,0)
363   MDRV_CPU_VBLANK_INT(tm3k_interrupt,2+5+20) // ??
364
189365   MDRV_SCREEN_REFRESH_RATE(60)
190366   MDRV_SCREEN_VBLANK_TIME(DEFAULT_60HZ_VBLANK_DURATION)
191367
192   MDRV_GFXDECODE(tmaster)
368   MDRV_MACHINE_RESET(tmaster)
369   MDRV_NVRAM_HANDLER(generic_0fill)
193370
194371   MDRV_VIDEO_ATTRIBUTES(VIDEO_TYPE_RASTER)
195372   MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16)
196   MDRV_SCREEN_SIZE(64*8, 32*8)
197   MDRV_SCREEN_VISIBLE_AREA(8*8, 48*8-1, 2*8, 30*8-1)
373   MDRV_SCREEN_SIZE(400, 256)
374   MDRV_SCREEN_VISIBLE_AREA(0, 400-1, 0, 256-1)
198375   MDRV_PALETTE_LENGTH(0x800)
199376
200377   MDRV_VIDEO_START(tmaster)
201378   MDRV_VIDEO_UPDATE(tmaster)
202379
203   MDRV_SPEAKER_STANDARD_STEREO("left", "right")
380   MDRV_SPEAKER_STANDARD_MONO("mono")
204381
205   MDRV_SOUND_ADD(OKIM6295, 1122000)
382   MDRV_SOUND_ADD_TAG("OKI",OKIM6295, 2000000)
206383   MDRV_SOUND_CONFIG(okim6295_interface_region_1_pin7high) // clock frequency & pin 7 not verified
207   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "left", 0.47)
208   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "right", 0.47)
384   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0)
209385MACHINE_DRIVER_END
210386
211/*
387
388static INTERRUPT_GEN( tm_interrupt )
389{
390   switch (cpu_getiloops())
391   {
392      case 0:      cpunum_set_input_line(0, 2, HOLD_LINE);   break;
393      case 1:      cpunum_set_input_line(0, 3, HOLD_LINE);   break;
394      case 2:      cpunum_set_input_line_and_vector(0, 4, HOLD_LINE, 0x100/4);   break;   // touch screen controller
395      default:   cpunum_set_input_line(0, 1, HOLD_LINE);   break;
396   }
397}
398
399static MACHINE_DRIVER_START( tm )
400   MDRV_IMPORT_FROM(tm3k)
401   MDRV_CPU_MODIFY("main")
402   MDRV_CPU_VBLANK_INT(tm_interrupt,3+20) // ??
403
404   MDRV_SOUND_REPLACE("OKI",OKIM6295, 1122000)
405   MDRV_SOUND_CONFIG(okim6295_interface_region_1_pin7high) // clock frequency & pin 7 not verified
406   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0)
407MACHINE_DRIVER_END
408
409
410/***************************************************************************
411
412                               ROMs Loading
413
414***************************************************************************/
415
416/***************************************************************************
417
212418Touch Master
2134191996, Midway
214420
r1293r1294
222428Xlinx XC3042a
223429
224430Dumped by ANY
225*/
226431
432***************************************************************************/
433
227434ROM_START( tm )
228   ROM_REGION( 0x200000, REGION_CPU1, 0 ) /* 68000 Code */
435   ROM_REGION( 0x200000, REGION_CPU1, 0 ) // 68000 Code
436   ROM_LOAD16_BYTE( "tmaster.u51", 0x000000, 0x080000, CRC(edaa5874) SHA1(48b99bc7f5a6453def265967ca7d8eefdf9dc97b) )
229437   ROM_LOAD16_BYTE( "tmaster.u52", 0x000001, 0x080000, CRC(e9fd30fc) SHA1(d91ea05d5f574603883336729fb9df705688945d) )
230   ROM_LOAD16_BYTE( "tmaster.u51", 0x000000, 0x080000, CRC(edaa5874) SHA1(48b99bc7f5a6453def265967ca7d8eefdf9dc97b) )
231438
232   ROM_REGION( 0x100000, REGION_SOUND1, 0 ) /* Samples */
233   ROM_LOAD( "tmaster.u8", 0x00000, 0x080000, CRC(f39ad4cf) SHA1(9bcb9a5dd3636d6541eeb3e737c7253ab0ed4e8d) )
439   ROM_REGION( 0x400000, REGION_GFX1, ROMREGION_ERASE )   // Blitter gfx
440   ROM_LOAD16_BYTE( "tmaster.u38", 0x100000, 0x080000, CRC(68885ef6) SHA1(010602b59c33c3e490491a296ddaf8952e315b83) )
441   ROM_LOAD16_BYTE( "tmaster.u36", 0x100001, 0x080000, CRC(204096ec) SHA1(9239923b7eedb6003c63ef2e8ff224edee657bbc) )
442   // unused gap
443   ROM_LOAD16_BYTE( "tmaster.u39", 0x300000, 0x080000, CRC(cbb716cb) SHA1(4e8d8f6cbfb25a8161ff8fe7505d6b209650dd2b) )
444   ROM_LOAD16_BYTE( "tmaster.u37", 0x300001, 0x080000, CRC(e0b6a9f7) SHA1(7e057ca87833c682e5be03668469259bbdefbf20) )
234445
235   ROM_REGION( 0x200000, REGION_GFX1, 0 )
236   ROM_LOAD16_BYTE( "tmaster.u36", 0x000000, 0x080000, CRC(204096ec) SHA1(9239923b7eedb6003c63ef2e8ff224edee657bbc) )
237   ROM_LOAD16_BYTE( "tmaster.u38", 0x000001, 0x080000, CRC(68885ef6) SHA1(010602b59c33c3e490491a296ddaf8952e315b83) )
446   ROM_REGION( 0x100000, REGION_SOUND1, 0 ) // Samples
447   ROM_LOAD( "tmaster.u8", 0x40000, 0x040000, CRC(f39ad4cf) SHA1(9bcb9a5dd3636d6541eeb3e737c7253ab0ed4e8d) )
448   ROM_CONTINUE(           0xc0000, 0x040000 )
449ROM_END
238450
239   ROM_REGION( 0x200000, REGION_GFX2, 0 )
240   ROM_LOAD16_BYTE( "tmaster.u37", 0x000000, 0x080000, CRC(e0b6a9f7) SHA1(7e057ca87833c682e5be03668469259bbdefbf20) )
241   ROM_LOAD16_BYTE( "tmaster.u39", 0x000001, 0x080000, CRC(cbb716cb) SHA1(4e8d8f6cbfb25a8161ff8fe7505d6b209650dd2b) )
451/***************************************************************************
242452
243   ROM_REGION( 0x200000, REGION_GFX3, ROMREGION_ERASEFF )
244ROM_END
245
246/*
247453Touchmaster 3000
248454by Midway
249455touchscreen game
r1293r1294
267473J12 (NOT INCLUDED)         N/A  Security Key(not required for this Version)
268474-----------------------------------------------------------------------------------
269475
476SCN68681c1n40
477xc3042A      www.xilinx.com
270478
271The TOUCHMASTER 3000 is a bar top game, with many different kinds of games in it
272including strip poker and Adult content (cool!). It does use a touchscreen but
273I'm sure a EMU can make this Transition to a mouse pointer.
479***************************************************************************/
274480
275CPU- SCN68681c1n40
276sound processor-xc3042A      www.xilinx.com
277*/
278
279481ROM_START( tm3k )
280   ROM_REGION( 0x200000, REGION_CPU1, 0 ) /* 68000 Code */
482   ROM_REGION( 0x200000, REGION_CPU1, 0 ) // 68000 Code
281483   ROM_LOAD16_BYTE( "tm3k_u52.bin", 0x000001, 0x100000, CRC(8c6a0db7) SHA1(6b0eae60ea471cd8c4001749ac2677d8d4532567) )
282484   ROM_LOAD16_BYTE( "tm3k_u51.bin", 0x000000, 0x100000, CRC(c9522279) SHA1(e613b791f831271722f05b7e96c35519fa9fc174) )
283485
284   ROM_REGION( 0x100000, REGION_SOUND1, 0 ) /* Samples */
486   ROM_REGION( 0x600000, REGION_GFX1, 0 )   // Blitter gfx
487   ROM_LOAD16_BYTE( "tm3k_u38.bin", 0x000000, 0x100000, CRC(a6683899) SHA1(d05024390917cdb1871d030996da8e1eb6460918) )
488   ROM_LOAD16_BYTE( "tm3k_u36.bin", 0x000001, 0x100000, CRC(7bde520d) SHA1(77750b689e2f0d47804042456e54bbd9c28deeac) )
489   ROM_LOAD16_BYTE( "tm3k_u39.bin", 0x200000, 0x100000, CRC(206b56a6) SHA1(09e5e05bffd0a09abd24d668e2c59b56f2c79134) )
490   ROM_LOAD16_BYTE( "tm3k_u37.bin", 0x200001, 0x100000, CRC(18f50eb3) SHA1(a7c9d3b24b5fd110380ec87d9200d55cad473efc) )
491   ROM_LOAD16_BYTE( "tm3k_u41.bin", 0x400000, 0x100000, BAD_DUMP CRC(74a36bca) SHA1(7ad594daa156dea40a25b390f26c2fd0550e66ff) )
492   ROM_LOAD16_BYTE( "tm3k_u40.bin", 0x400001, 0x100000, CRC(353df7ca) SHA1(d6c5d5449af6b6a3acee219778583904c5b554b4) )
493
494   ROM_REGION( 0x100000, REGION_SOUND1, 0 ) // Samples
285495   ROM_LOAD( "tm3k_u8.bin", 0x00000, 0x100000, CRC(d0ae33c1) SHA1(a079def9a086a091fcc4493a44fec756d2470415) )
496ROM_END
286497
287   ROM_REGION( 0x200000, REGION_GFX1, 0 )
288   ROM_LOAD16_BYTE( "tm3k_u36.bin", 0x000000, 0x100000, CRC(7bde520d) SHA1(77750b689e2f0d47804042456e54bbd9c28deeac) )
289   ROM_LOAD16_BYTE( "tm3k_u38.bin", 0x000001, 0x100000, CRC(a6683899) SHA1(d05024390917cdb1871d030996da8e1eb6460918) )
498/***************************************************************************
290499
291   ROM_REGION( 0x200000, REGION_GFX2, 0 )
292   ROM_LOAD16_BYTE( "tm3k_u37.bin", 0x000000, 0x100000, CRC(18f50eb3) SHA1(a7c9d3b24b5fd110380ec87d9200d55cad473efc) )
293   ROM_LOAD16_BYTE( "tm3k_u39.bin", 0x000001, 0x100000, CRC(206b56a6) SHA1(09e5e05bffd0a09abd24d668e2c59b56f2c79134) )
294
295   ROM_REGION( 0x200000, REGION_GFX3, 0 )
296   ROM_LOAD16_BYTE( "tm3k_u40.bin", 0x000000, 0x100000, CRC(353df7ca) SHA1(d6c5d5449af6b6a3acee219778583904c5b554b4) )
297   ROM_LOAD16_BYTE( "tm3k_u41.bin", 0x000001, 0x100000, CRC(74a36bca) SHA1(7ad594daa156dea40a25b390f26c2fd0550e66ff) )
298ROM_END
299
300/*
301500Touchmaster 4000
302501by Midway
303502touchscreen game
r1293r1294
321520J12 (NOT INCLUDED)         N/A  Security Key(required for this Version)
322521-----------------------------------------------------------------------------------
323522
523SCN68681c1n40
524xc3042A      www.xilinx.com
324525
325The TOUCHMASTER 4000 is a bar top game, with many different kinds of games in it
326including strip poker and Adult content (cool!). It does use a touchscreen but
327I'm sure a EMU can make this Transition to a mouse pointer.
526***************************************************************************/
328527
329CPU- SCN68681c1n40
330sound processor-xc3042A      www.xilinx.com
331*/
332
333528ROM_START( tm4k )
334   ROM_REGION( 0x200000, REGION_CPU1, 0 ) /* 68000 Code */
529   ROM_REGION( 0x200000, REGION_CPU1, 0 ) // 68000 Code
530   ROM_LOAD16_BYTE( "tm4k_u51.bin", 0x000000, 0x100000, CRC(3d8d7848) SHA1(31638f23cdd5e6cfbb2270e953f84fe1bd437950) )
335531   ROM_LOAD16_BYTE( "tm4k_u52.bin", 0x000001, 0x100000, CRC(6d412871) SHA1(ae27c7723b292daf6682c53bafac22e4a3cd1ece) )
336   ROM_LOAD16_BYTE( "tm4k_u51.bin", 0x000000, 0x100000, CRC(3d8d7848) SHA1(31638f23cdd5e6cfbb2270e953f84fe1bd437950) )
337532
338   ROM_REGION( 0x100000, REGION_SOUND1, 0 ) /* Samples */
533   ROM_REGION( 0x600000, REGION_GFX1, 0 )   // Blitter gfx
534   ROM_LOAD16_BYTE( "tm4k_u38.bin", 0x000000, 0x100000, CRC(a6683899) SHA1(d05024390917cdb1871d030996da8e1eb6460918) )
535   ROM_LOAD16_BYTE( "tm4k_u36.bin", 0x000001, 0x100000, CRC(7bde520d) SHA1(77750b689e2f0d47804042456e54bbd9c28deeac) )
536   ROM_LOAD16_BYTE( "tm4k_u39.bin", 0x200000, 0x100000, CRC(bac88cfb) SHA1(26ed169296b890c5f5b50c418c15299355a6592f) )
537   ROM_LOAD16_BYTE( "tm4k_u37.bin", 0x200001, 0x100000, CRC(bf49fafa) SHA1(b400667bf654dc9cd01a85c8b99670459400fd60) )
538   ROM_LOAD16_BYTE( "tm4k_u41.bin", 0x400000, 0x100000, CRC(e97edb1e) SHA1(75510676cf1692ad03efd4ccd57d25af1cc8ef2a) )
539   ROM_LOAD16_BYTE( "tm4k_u40.bin", 0x400001, 0x100000, CRC(f6771a09) SHA1(74f71d5e910006c83a38170f24aa811c38a3e020) )
540
541   ROM_REGION( 0x100000, REGION_SOUND1, 0 ) // Samples
339542   ROM_LOAD( "tm4k_u8.bin", 0x00000, 0x100000, CRC(48c3782b) SHA1(bfe105ddbde8bbbd84665dfdd565d6d41926834a) )
543ROM_END
340544
341   ROM_REGION( 0x200000, REGION_GFX1, 0 ) /* these match tm3k */
342   ROM_LOAD16_BYTE( "tm4k_u36.bin", 0x000000, 0x100000, CRC(7bde520d) SHA1(77750b689e2f0d47804042456e54bbd9c28deeac) )
343   ROM_LOAD16_BYTE( "tm4k_u38.bin", 0x000001, 0x100000, CRC(a6683899) SHA1(d05024390917cdb1871d030996da8e1eb6460918) )
545static DRIVER_INIT( tm3k )
546{
547   // try this if you need to calibrate
548#if 0
549   UINT16 *ROM = (UINT16 *)memory_region( REGION_CPU1 );
550   // tscreen test
551   ROM[0x75e3c/2] = 0x4ef9;
552   ROM[0x75e3e/2] = 0x0007;
553   ROM[0x75e40/2] = 0x5e4a;
344554
345   ROM_REGION( 0x200000, REGION_GFX2, 0 )
346   ROM_LOAD16_BYTE( "tm4k_u37.bin", 0x000000, 0x100000, CRC(bf49fafa) SHA1(b400667bf654dc9cd01a85c8b99670459400fd60) )
347   ROM_LOAD16_BYTE( "tm4k_u39.bin", 0x000001, 0x100000, CRC(bac88cfb) SHA1(26ed169296b890c5f5b50c418c15299355a6592f) )
555   // tscreen test
556   ROM[0x765ca/2] = 0x7001;
557#endif
558}
348559
349   ROM_REGION( 0x200000, REGION_GFX3, 0 )
350   ROM_LOAD16_BYTE( "tm4k_u40.bin", 0x000000, 0x100000, CRC(f6771a09) SHA1(74f71d5e910006c83a38170f24aa811c38a3e020) )
351   ROM_LOAD16_BYTE( "tm4k_u41.bin", 0x000001, 0x100000, CRC(e97edb1e) SHA1(75510676cf1692ad03efd4ccd57d25af1cc8ef2a) )
352ROM_END
560static DRIVER_INIT( tm4k )
561{
562   UINT16 *ROM = (UINT16 *)memory_region( REGION_CPU1 );
353563
354GAME( 1996, tm,      0,        tmaster,    tmaster,    0, ROT0,  "Midway", "Touchmaster", GAME_NOT_WORKING )
355GAME( 1997, tm3k,    0,        tmaster,    tmaster,    0, ROT0,  "Midway", "Touchmaster 3000 (v5.01)", GAME_NOT_WORKING )
356GAME( 1998, tm4k,    0,        tmaster,    tmaster,    0, ROT0,  "Midway", "Touchmaster 4000 (v6.02)", GAME_NOT_WORKING )
564   // protection
565   ROM[0x83476/2] = 0x4e75;
566
567   ROM[0x8342C/2] = 0x601a;
568   ROM[0x8346C/2] = 0x6002;
569}
570
571GAME( 1996, tm,   0, tm,   tmaster, 0,    ROT0, "Midway", "Touchmaster",              GAME_NOT_WORKING )
572GAME( 1997, tm3k, 0, tm3k, tmaster, tm3k, ROT0, "Midway", "Touchmaster 3000 (v5.01)", GAME_NOT_WORKING | GAME_IMPERFECT_GRAPHICS)
573GAME( 1998, tm4k, 0, tm3k, tmaster, tm4k, ROT0, "Midway", "Touchmaster 4000 (v6.02)", GAME_NOT_WORKING )
src/mame/drivers/cischeat.c
r1293r1294
523523
524524    Within $20 vblanks the motor must reach the target. */
525525
526static WRITE16_HANDLER( scudhamm_motor_command_w )
526WRITE16_HANDLER( scudhamm_motor_command_w )
527527{
528528   COMBINE_DATA( &scudhamm_motor_command );
529529}
r1293r1294
534534   return readinputport(1);
535535}
536536
537
538537/*
539538    I don't know how many leds are there, but each bit in the buttons input
540539    port (coins, tilt, buttons, select etc.) triggers the corresponding bit
r1293r1294
17231722
17241723/* CPU # 1 */
17251724#define CISCHEAT_INTERRUPT_NUM   3
1726INTERRUPT_GEN( cischeat_interrupt )
1725static INTERRUPT_GEN( cischeat_interrupt )
17271726{
17281727   if (cpu_getiloops()==0)
17291728      cpunum_set_input_line(0, 4, HOLD_LINE); /* Once */
r1293r1294
18771876    4]          == 3
18781877*/
18791878#define INTERRUPT_NUM_SCUDHAMM      30
1880INTERRUPT_GEN( interrupt_scudhamm )
1879static INTERRUPT_GEN( interrupt_scudhamm )
18811880{
18821881   switch ( cpu_getiloops() )
18831882   {
r1293r1294
19281927                            Arm Champs II
19291928**************************************************************************/
19301929
1931INTERRUPT_GEN( interrupt_armchmp2)
1930static INTERRUPT_GEN( interrupt_armchmp2)
19321931{
19331932   switch ( cpu_getiloops() )
19341933   {
r1293r1294
19671966
19681967    We need to untangle it
19691968*/
1970void cischeat_untangle_sprites(int region)
1969static void cischeat_untangle_sprites(int region)
19711970{
19721971   UINT8      *src = memory_region(region);
19731972   const UINT8   *end = memory_region(region) + memory_region_length(region);
src/mame/drivers/namcos22.c
r1293r1294
11831183      { /* SUBCPU enable on System 22 (guessed, but too early crashes Rave Racer so it's a good test) */
11841184         if (data == 0xff00)
11851185         {
1186            mame_timer_set(MAME_TIME_IN_MSEC(50), 0, start_subcpu);
1186            timer_set(ATTOTIME_IN_MSEC(50), 0, start_subcpu);
11871187         }
11881188      }
11891189   }
r1293r1294
18221822   MDRV_CPU_ADD(M37710, SS22_MASTER_CLOCK/3)
18231823   MDRV_CPU_PROGRAM_MAP(mcu_program, 0)
18241824   MDRV_CPU_IO_MAP( mcu_io, 0 )
1825   MDRV_CPU_VBLANK_INT(mcu_interrupt, 3);
1825   MDRV_CPU_VBLANK_INT(mcu_interrupt, 3)
18261826
18271827   MDRV_SCREEN_REFRESH_RATE(60)
18281828   MDRV_SCREEN_VBLANK_TIME(DEFAULT_REAL_60HZ_VBLANK_DURATION)
src/mame/drivers/flyball.c
r1293r1294
5252   {
5353      if (potsense[i] != 0)
5454      {
55         mame_timer_set(video_screen_get_time_until_pos(0, scanline + i, 0), potsense[i], flyball_joystick_callback);
55         timer_set(video_screen_get_time_until_pos(0, scanline + i, 0), potsense[i], flyball_joystick_callback);
5656      }
5757   }
5858
5959   scanline += 0x40;
6060   scanline &= 0xff;
6161
62   mame_timer_set(video_screen_get_time_until_pos(0, scanline, 0), scanline, flyball_quarter_callback);
62   timer_set(video_screen_get_time_until_pos(0, scanline, 0), scanline, flyball_quarter_callback);
6363
6464   flyball_potsense = 0;
6565   flyball_potmask = 0;
r1293r1294
7777   for (i = 0; i < 0x1000; i++)
7878      rombase[i] = ROM[i ^ 0x1ff];
7979
80   mame_timer_set(video_screen_get_time_until_pos(0, 0, 0), 0, flyball_quarter_callback);
80   timer_set(video_screen_get_time_until_pos(0, 0, 0), 0, flyball_quarter_callback);
8181}
8282
8383
src/mame/drivers/redclash.c
r1293r1294
4242  Interrupts are still used, but they are related to coin
4343  slots. Left slot generates an IRQ, Right slot a NMI.
4444*/
45INTERRUPT_GEN( redclash_interrupt )
45static INTERRUPT_GEN( redclash_interrupt )
4646{
4747   if (readinputport(4) & 1)   /* Left Coin */
4848      cpunum_set_input_line(0,0,ASSERT_LINE);
src/mame/drivers/vicdual.c
r1293r1294
9595      cpunum_set_input_line(0, INPUT_LINE_RESET, PULSE_LINE);
9696
9797      /* simulate the coin switch being closed for a while */
98      mame_timer_set(double_to_mame_time(4 * mame_time_to_double(video_screen_get_frame_period(0))), 0, clear_coin_status);
98      timer_set(double_to_attotime(4 * attotime_to_double(video_screen_get_frame_period(0))), 0, clear_coin_status);
9999   }
100100
101101   last_coin_input = coin_input;
r1293r1294
125125static int timer_started;
126126static UINT32 timer_value;
127127
128#define TIMER_HALF_PERIOD   MAME_TIME_IN_MSEC(4 / 2)   /* 4Mhz square wave */
128#define TIMER_HALF_PERIOD   ATTOTIME_IN_MSEC(4 / 2)   /* 4Mhz square wave */
129129
130130
131131static int get_vcounter(void)
r1293r1294
174174   {
175175      timer_started = 1;
176176
177      mame_timer_pulse(TIMER_HALF_PERIOD, 0, vicdual_timer_callback);
177      timer_pulse(TIMER_HALF_PERIOD, 0, vicdual_timer_callback);
178178   }
179179
180180   return timer_value;
src/mame/drivers/rockola.c
r1293r1294
177177
178178/* binary counter (1.4MHz update) */
179179static UINT8 sasuke_counter;
180static mame_timer *sasuke_timer;
180static emu_timer *sasuke_timer;
181181
182182static TIMER_CALLBACK( sasuke_update_counter )
183183{
r1293r1294
188188{
189189   sasuke_counter = 0;
190190
191   sasuke_timer = mame_timer_alloc(sasuke_update_counter);
192   mame_timer_adjust(sasuke_timer, time_zero, 0, MAME_TIME_IN_HZ(11289000/8));   // 1.4 MHz
191   sasuke_timer = timer_alloc(sasuke_update_counter);
192   timer_adjust(sasuke_timer, attotime_zero, 0, ATTOTIME_IN_HZ(11289000/8));   // 1.4 MHz
193193}
194194
195195
src/mame/drivers/centiped.c
r1293r1294
433433static UINT8 dsw_select, control_select;
434434static UINT8 *rambase;
435435
436static mame_timer *interrupt_timer;
436static emu_timer *interrupt_timer;
437437
438438
439439/*************************************
r1293r1294
455455   if (scanline >= 256)
456456      scanline = 0;
457457
458   mame_timer_adjust(interrupt_timer, video_screen_get_time_until_pos(0, scanline, 0), scanline, time_zero);
458   timer_adjust(interrupt_timer, video_screen_get_time_until_pos(0, scanline, 0), scanline, attotime_zero);
459459}
460460
461461
r1293r1294
469469
470470static MACHINE_RESET( centiped )
471471{
472   interrupt_timer = mame_timer_alloc(generate_interrupt);
473   mame_timer_adjust(interrupt_timer, video_screen_get_time_until_pos(0, 0, 0), 0, time_zero);
472   interrupt_timer = timer_alloc(generate_interrupt);
473   timer_adjust(interrupt_timer, video_screen_get_time_until_pos(0, 0, 0), 0, attotime_zero);
474474   cpunum_set_input_line(0, 0, CLEAR_LINE);
475475   dsw_select = 0;
476476   control_select = 0;
src/mame/drivers/atarisy1.c
r1293r1294
135135static UINT8 joystick_type;
136136static UINT8 trackball_type;
137137
138static mame_timer *joystick_timer;
138static emu_timer *joystick_timer;
139139static UINT8 joystick_int;
140140static UINT8 joystick_int_enable;
141141static UINT8 joystick_value;
r1293r1294
186186
187187   /* reset the joystick parameters */
188188   joystick_value = 0;
189   joystick_timer = mame_timer_alloc(delayed_joystick_int);
189   joystick_timer = timer_alloc(delayed_joystick_int);
190190   joystick_int = 0;
191191   joystick_int_enable = 0;
192192}
r1293r1294
228228
229229   /* clear any existing interrupt and set a timer for a new one */
230230   joystick_int = 0;
231   mame_timer_adjust(joystick_timer, MAME_TIME_IN_USEC(50), newval, time_zero);
231   timer_adjust(joystick_timer, ATTOTIME_IN_USEC(50), newval, attotime_zero);
232232   atarigen_update_interrupts();
233233
234234   return joystick_value;
src/mame/drivers/wgp.c
r1293r1294
488488
489489static INTERRUPT_GEN( wgp_cpub_interrupt )
490490{
491   mame_timer_set(MAME_TIME_IN_CYCLES(200000-500,0),0, wgp_cpub_interrupt6);
491   timer_set(ATTOTIME_IN_CYCLES(200000-500,0),0, wgp_cpub_interrupt6);
492492   cpunum_set_input_line(2, 4, HOLD_LINE);
493493}
494494
r1293r1294
611611       hardware has got the next a/d conversion ready. We set a token
612612       delay of 10000 cycles although our inputs are always ready. */
613613
614   mame_timer_set(MAME_TIME_IN_CYCLES(10000,0),0, wgp_interrupt6);
614   timer_set(ATTOTIME_IN_CYCLES(10000,0),0, wgp_interrupt6);
615615}
616616
617617
src/mame/drivers/welltris.c
r1293r1294
316316#include "sound/2610intf.h"
317317
318318UINT16 *welltris_spriteram;
319size_t welltris_spriteram_size;
319//size_t welltris_spriteram_size;
320320UINT16 *welltris_pixelram;
321321UINT16 *welltris_charvideoram;
322322
src/mame/drivers/sprint8.c
r1293r1294
117117   collision_reset = 0;
118118   collision_index = 0;
119119
120   mame_timer_pulse(video_screen_get_frame_period(0), 0, input_callback);
120   timer_pulse(video_screen_get_frame_period(0), 0, input_callback);
121121}
122122
123123
src/mame/drivers/pturn.c
r1293r1294
7777#include "driver.h"
7878#include "sound/ay8910.h"
7979
80tilemap *pturn_fgmap,*pturn_bgmap;
80static tilemap *pturn_fgmap,*pturn_bgmap;
8181static int bgbank=0;
8282static int fgbank=0;
8383static int bgpalette=0;
src/mame/drivers/scregg.c
r1293r1294
235235   MDRV_CPU_VBLANK_INT(irq0_line_hold,16)
236236
237237   MDRV_SCREEN_REFRESH_RATE(57)
238   MDRV_SCREEN_VBLANK_TIME(USEC_TO_SUBSECONDS(3072)        /* frames per second, vblank duration taken from Burger Time */)
238   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(3072)        /* frames per second, vblank duration taken from Burger Time */)
239239
240240   /* video hardware */
241241   MDRV_VIDEO_ATTRIBUTES(VIDEO_TYPE_RASTER)
r1293r1294
268268   MDRV_CPU_VBLANK_INT(irq0_line_hold,16)
269269
270270   MDRV_SCREEN_REFRESH_RATE(57)
271   MDRV_SCREEN_VBLANK_TIME(USEC_TO_SUBSECONDS(3072)        /* frames per second, vblank duration taken from Burger Time */)
271   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(3072)        /* frames per second, vblank duration taken from Burger Time */)
272272
273273   /* video hardware */
274274   MDRV_VIDEO_ATTRIBUTES(VIDEO_TYPE_RASTER)
src/mame/drivers/dec0.c
r1293r1294
936936   MDRV_CPU_PROGRAM_MAP(dec0_s_readmem,dec0_s_writemem)
937937
938938   MDRV_SCREEN_REFRESH_RATE(57.41)
939   MDRV_SCREEN_VBLANK_TIME(USEC_TO_SUBSECONDS(529) /* 57.41 Hz, 529us Vblank */)
939   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(529) /* 57.41 Hz, 529us Vblank */)
940940
941941   /* video hardware */
942942   MDRV_VIDEO_ATTRIBUTES(VIDEO_TYPE_RASTER)
r1293r1294
979979   MDRV_CPU_PROGRAM_MAP(dec0_s_readmem,dec0_s_writemem)
980980
981981   MDRV_SCREEN_REFRESH_RATE(57.41)
982   MDRV_SCREEN_VBLANK_TIME(USEC_TO_SUBSECONDS(529) /* 57.41 Hz, 529us Vblank */)
982   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(529) /* 57.41 Hz, 529us Vblank */)
983983
984984   /* video hardware */
985985   MDRV_VIDEO_ATTRIBUTES(VIDEO_TYPE_RASTER)
r1293r1294
10221022   MDRV_CPU_PROGRAM_MAP(dec0_s_readmem,dec0_s_writemem)
10231023
10241024   MDRV_SCREEN_REFRESH_RATE(57.41)
1025   MDRV_SCREEN_VBLANK_TIME(USEC_TO_SUBSECONDS(529) /* 57.41 Hz, 529us Vblank */)
1025   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(529) /* 57.41 Hz, 529us Vblank */)
10261026
10271027   /* video hardware */
10281028   MDRV_VIDEO_ATTRIBUTES(VIDEO_TYPE_RASTER)
r1293r1294
10681068   MDRV_CPU_PROGRAM_MAP(robocop_sub_readmem,robocop_sub_writemem)
10691069
10701070   MDRV_SCREEN_REFRESH_RATE(57.41)
1071   MDRV_SCREEN_VBLANK_TIME(USEC_TO_SUBSECONDS(529) /* 57.41 Hz, 529us Vblank */)
1071   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(529) /* 57.41 Hz, 529us Vblank */)
10721072   MDRV_INTERLEAVE(50)   /* Interleave between HuC6280 & 68000 */
10731073
10741074   /* video hardware */
r1293r1294
11121112   MDRV_CPU_PROGRAM_MAP(dec0_s_readmem,dec0_s_writemem)
11131113
11141114   MDRV_SCREEN_REFRESH_RATE(57.41)
1115   MDRV_SCREEN_VBLANK_TIME(USEC_TO_SUBSECONDS(529) /* 57.41 Hz, 529us Vblank */)
1115   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(529) /* 57.41 Hz, 529us Vblank */)
11161116
11171117   /* video hardware */
11181118   MDRV_VIDEO_ATTRIBUTES(VIDEO_TYPE_RASTER)
r1293r1294
11581158   MDRV_CPU_PROGRAM_MAP(hippodrm_sub_readmem,hippodrm_sub_writemem)
11591159
11601160   MDRV_SCREEN_REFRESH_RATE(57.41)
1161   MDRV_SCREEN_VBLANK_TIME(USEC_TO_SUBSECONDS(529) /* 57.41 Hz, 529us Vblank */)
1161   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(529) /* 57.41 Hz, 529us Vblank */)
11621162   MDRV_INTERLEAVE(5)   /* Interleave between H6280 & 68000 */
11631163
11641164   /* video hardware */
r1293r1294
12021202   MDRV_CPU_PROGRAM_MAP(slyspy_s_readmem,slyspy_s_writemem)
12031203
12041204   MDRV_SCREEN_REFRESH_RATE(57.41)
1205   MDRV_SCREEN_VBLANK_TIME(USEC_TO_SUBSECONDS(529) /* 57.41 Hz, 529us Vblank */)
1205   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(529) /* 57.41 Hz, 529us Vblank */)
12061206
12071207   /* video hardware */
12081208   MDRV_VIDEO_ATTRIBUTES(VIDEO_TYPE_RASTER)
r1293r1294
12451245   MDRV_CPU_PROGRAM_MAP(midres_s_readmem,midres_s_writemem)
12461246
12471247   MDRV_SCREEN_REFRESH_RATE(57.41)
1248   MDRV_SCREEN_VBLANK_TIME(USEC_TO_SUBSECONDS(529) /* 57.41 Hz, 529us Vblank */)
1248   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(529) /* 57.41 Hz, 529us Vblank */)
12491249
12501250   /* video hardware */
12511251   MDRV_VIDEO_ATTRIBUTES(VIDEO_TYPE_RASTER)
src/mame/drivers/ssv.c
r1293r1294
204204   cpunum_set_input_line(0, 0, (requested_int & irq_enable)? ASSERT_LINE : CLEAR_LINE);
205205}
206206
207int ssv_irq_callback(int level)
207static int ssv_irq_callback(int level)
208208{
209209   int i;
210210   for ( i = 0; i <= 7; i++ )
r1293r1294
251251
252252static int interrupt_ultrax;
253253
254INTERRUPT_GEN( ssv_interrupt )
254static INTERRUPT_GEN( ssv_interrupt )
255255{
256256   if (cpu_getiloops())
257257   {
r1293r1294
268268   }
269269}
270270
271INTERRUPT_GEN( gdfs_interrupt )
271static INTERRUPT_GEN( gdfs_interrupt )
272272{
273273   if (cpu_getiloops())
274274   {
r1293r1294
26942694
26952695***************************************************************************/
26962696
2697void init_ssv(void)
2697static void init_ssv(void)
26982698{
26992699   int i;
27002700   for (i = 0; i < 16; i++)
r1293r1294
27082708   eaglshot_dirty = 0;
27092709}
27102710
2711void init_ssv_hypreac2(void)
2711static void init_ssv_hypreac2(void)
27122712{
27132713   int i;
27142714
src/mame/drivers/metro.c
r1293r1294
186186
187187
188188/* For games that supply an *IRQ Vector* on the data bus */
189int metro_irq_callback(int int_level)
189static int metro_irq_callback(int int_level)
190190{
191191//  logerror("CPU #0 PC %06X: irq callback returns %04X\n",activecpu_get_pc(),metro_irq_vectors[int_level]);
192192   return metro_irq_vectors[int_level]&0xff;
r1293r1294
220220}
221221
222222
223INTERRUPT_GEN( metro_interrupt )
223static INTERRUPT_GEN( metro_interrupt )
224224{
225225   switch ( cpu_getiloops() )
226226   {
r1293r1294
237237}
238238
239239/* Lev 1. Lev 2 seems sound related */
240INTERRUPT_GEN( bangball_interrupt )
240static INTERRUPT_GEN( bangball_interrupt )
241241{
242242   requested_int[0] = 1;   // set scroll regs if a flag is set
243243   requested_int[4] = 1;   // clear that flag
r1293r1294
251251}
252252
253253/* lev 2-7 (lev 1 seems sound related) */
254INTERRUPT_GEN( karatour_interrupt )
254static INTERRUPT_GEN( karatour_interrupt )
255255{
256256   switch ( cpu_getiloops() )
257257   {
r1293r1294
259259         requested_int[0] = 1;
260260         requested_int[5] = 1;   // write the scroll registers
261261         /* the duration is a guess */
262         mame_timer_set(MAME_TIME_IN_USEC(2500), 0, vblank_end_callback);
262         timer_set(ATTOTIME_IN_USEC(2500), 0, vblank_end_callback);
263263         update_irq_state();
264264         break;
265265
r1293r1294
270270   }
271271}
272272
273static mame_timer *mouja_irq_timer;
273static emu_timer *mouja_irq_timer;
274274
275275static TIMER_CALLBACK( mouja_irq_callback )
276276{
r1293r1294
281281static WRITE16_HANDLER( mouja_irq_timer_ctrl_w )
282282{
283283   double freq = 58.0 + (0xff - (data & 0xff)) / 2.2;               /* 0xff=58Hz, 0x80=116Hz? */
284   mame_timer_adjust(mouja_irq_timer, time_zero, 0, MAME_TIME_IN_HZ(freq));
284   timer_adjust(mouja_irq_timer, attotime_zero, 0, ATTOTIME_IN_HZ(freq));
285285}
286286
287INTERRUPT_GEN( mouja_interrupt )
287static INTERRUPT_GEN( mouja_interrupt )
288288{
289289   requested_int[1] = 1;
290290   update_irq_state();
291291}
292292
293293
294INTERRUPT_GEN( gakusai_interrupt )
294static INTERRUPT_GEN( gakusai_interrupt )
295295{
296296   switch ( cpu_getiloops() )
297297   {
r1293r1294
302302   }
303303}
304304
305INTERRUPT_GEN( dokyusei_interrupt )
305static INTERRUPT_GEN( dokyusei_interrupt )
306306{
307307   switch ( cpu_getiloops() )
308308   {
r1293r1294
672672
673673***************************************************************************/
674674
675UINT16 *metro_blitter_regs;
675static UINT16 *metro_blitter_regs;
676676
677677static TIMER_CALLBACK( metro_blit_done )
678678{
r1293r1294
754754                       another blit. */
755755               if (b1 == 0)
756756               {
757                  mame_timer_set(MAME_TIME_IN_USEC(500),0,metro_blit_done);
757                  timer_set(ATTOTIME_IN_USEC(500),0,metro_blit_done);
758758                  return;
759759               }
760760
r1293r1294
13811381
13821382static int gakusai_oki_bank_lo, gakusai_oki_bank_hi;
13831383
1384void gakusai_oki_bank_set(void)
1384static void gakusai_oki_bank_set(void)
13851385{
13861386   int bank = (gakusai_oki_bank_lo & 7) + (gakusai_oki_bank_hi & 1) * 8;
13871387   OKIM6295_set_bank_base(0, bank * 0x40000);
r1293r1294
46674667{
46684668   metro_common();
46694669   irq_line = -1;   /* split interrupt handlers */
4670   mouja_irq_timer = mame_timer_alloc(mouja_irq_callback);
4670   mouja_irq_timer = timer_alloc(mouja_irq_callback);
46714671}
46724672
46734673static DRIVER_INIT( gakusai )
src/mame/drivers/laserbas.c
r1293r1294
118118      PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_COIN2 )
119119INPUT_PORTS_END
120120
121INTERRUPT_GEN( laserbas_interrupt )
121static INTERRUPT_GEN( laserbas_interrupt )
122122{
123123   if(video_screen_get_vblank(0))
124124       cpunum_set_input_line(0, 0, HOLD_LINE);
src/mame/drivers/midvunit.c
r1293r1294
4141static UINT16 last_port0;
4242static UINT8 shifter_state;
4343
44static mame_timer *timer[2];
44static emu_timer *timer[2];
4545static double timer_rate;
4646
4747static UINT32 *tms32031_control;
r1293r1294
6363
6464   memcpy(ram_base, memory_region(REGION_USER1), 0x20000*4);
6565
66   timer[0] = mame_timer_alloc(NULL);
67   timer[1] = mame_timer_alloc(NULL);
66   timer[0] = timer_alloc(NULL);
67   timer[1] = timer_alloc(NULL);
6868}
6969
7070
r1293r1294
7575
7676   memcpy(ram_base, memory_region(REGION_USER1), 0x20000*4);
7777
78   timer[0] = mame_timer_alloc(NULL);
79   timer[1] = mame_timer_alloc(NULL);
78   timer[0] = timer_alloc(NULL);
79   timer[1] = timer_alloc(NULL);
8080
8181   ide_controller_reset(0);
8282}
r1293r1294
154154      if (which < 0 || which > 2)
155155         logerror("adc_w: unexpected which = %02X\n", which + 4);
156156      adc_data = readinputport(3 + which);
157      mame_timer_set(MAME_TIME_IN_MSEC(1), 0, adc_ready);
157      timer_set(ATTOTIME_IN_MSEC(1), 0, adc_ready);
158158   }
159159   else
160160      logerror("adc_w without enabling writes!\n");
r1293r1294
255255   {
256256      /* timer is clocked at 100ns */
257257      int which = (offset >> 4) & 1;
258      INT32 result = mame_time_to_double(scale_up_mame_time(mame_timer_timeelapsed(timer[which]), timer_rate));
258      INT32 result = attotime_to_double(attotime_mul(timer_timeelapsed(timer[which]), timer_rate));
259259//      logerror("%06X:tms32031_control_r(%02X) = %08X\n", activecpu_get_pc(), offset, result);
260260      return result;
261261   }
r1293r1294
282282      int which = (offset >> 4) & 1;
283283//  logerror("%06X:tms32031_control_w(%02X) = %08X\n", activecpu_get_pc(), offset, data);
284284      if (data & 0x40)
285         mame_timer_adjust(timer[which], time_never, 0, time_never);
285         timer_adjust(timer[which], attotime_never, 0, attotime_never);
286286
287287      /* bit 0x200 selects internal clocking, which is 1/2 the main CPU clock rate */
288288      if (data & 0x200)
r1293r1294
988988 *
989989 *************************************/
990990
991MACHINE_DRIVER_START( midvcommon )
991static MACHINE_DRIVER_START( midvcommon )
992992
993993   /* basic machine hardware */
994994   MDRV_CPU_ADD_TAG("main", TMS32031, CPU_CLOCK)
r1293r1294
10101010MACHINE_DRIVER_END
10111011
10121012
1013MACHINE_DRIVER_START( midvunit )
1013static MACHINE_DRIVER_START( midvunit )
10141014   MDRV_IMPORT_FROM(midvcommon)
10151015
10161016   /* sound hardware */
r1293r1294
10181018MACHINE_DRIVER_END
10191019
10201020
1021MACHINE_DRIVER_START( midvplus )
1021static MACHINE_DRIVER_START( midvplus )
10221022   MDRV_IMPORT_FROM(midvcommon)
10231023
10241024   /* basic machine hardware */
src/mame/drivers/namcond1.c
r1293r1294
296296   MDRV_CPU_ADD(H83002, 16384000 )
297297   MDRV_CPU_PROGRAM_MAP( nd1h8rwmap, 0 )
298298   MDRV_CPU_IO_MAP( nd1h8iomap, 0 )
299   MDRV_CPU_VBLANK_INT( mcu_interrupt, 1 );
299   MDRV_CPU_VBLANK_INT( mcu_interrupt, 1 )
300300
301301   MDRV_SCREEN_REFRESH_RATE(60.0)
302302   MDRV_SCREEN_VBLANK_TIME(DEFAULT_REAL_60HZ_VBLANK_DURATION)
src/mame/drivers/suna16.c
r1293r1294
99Sound:  YM2151  +  DAC x 4
1010
1111
12---------------------------------------------------------------------------
13Year + Game                 By      Hardware
14---------------------------------------------------------------------------
1594  Suna Quiz 6000          SunA    68000 + Z80 x 2 + YM2151 + DAC x 2
1696  Ultra Balloon           SunA    68000 + Z80 x 2 + YM2151 + DAC x 2
1796  Back Street Soccer      SunA    68000 + Z80 x 3 + YM2151 + DAC x 4
18---------------------------------------------------------------------------
12-------------------------------------------------------------------------------------------
13Year + Game                 By      Board      Hardware
14-------------------------------------------------------------------------------------------
1594  Best Of Best            SunA    KRB-0026   68000 + Z80 x 2 + YM3526 + DAC x 4 + AY-8910
1694  Suna Quiz 6000 Academy  SunA    KRB-0027A  68000 + Z80 x 2 + YM2151 + DAC x 2
1796  Ultra Balloon           SunA               68000 + Z80 x 2 + YM2151 + DAC x 2
1896  Back Street Soccer      SunA               68000 + Z80 x 3 + YM2151 + DAC x 4
19-------------------------------------------------------------------------------------------
1920
2021
2122***************************************************************************/
r1293r1294
2324#include "driver.h"
2425#include "sound/dac.h"
2526#include "sound/2151intf.h"
27#include "sound/ay8910.h"
28#include "sound/3812intf.h"
2629
2730/* Variables and functions defined in video: */
2831
2932WRITE16_HANDLER( suna16_flipscreen_w );
33WRITE16_HANDLER( bestbest_flipscreen_w );
3034
3135READ16_HANDLER ( suna16_paletteram16_r );
3236WRITE16_HANDLER( suna16_paletteram16_w );
3337
3438VIDEO_START( suna16 );
3539VIDEO_UPDATE( suna16 );
40VIDEO_UPDATE( bestbest );
3641
3742
3843/***************************************************************************
r1293r1294
7984}
8085
8186
87static WRITE16_HANDLER( bestbest_coin_w )
88{
89   if (ACCESSING_LSB)
90   {
91      coin_counter_w(0, data & 0x04);
92   }
93   if (data & ~0x04)   logerror("CPU#0 PC %06X - Leds unknown bits: %04X\n", activecpu_get_pc(), data);
94}
95
96
8297/***************************************************************************
8398                            Back Street Soccer
8499***************************************************************************/
r1293r1294
100115static ADDRESS_MAP_START( bssoccer_writemem, ADDRESS_SPACE_PROGRAM, 16 )
101116   AM_RANGE(0x000000, 0x1fffff) AM_WRITE(MWA16_ROM             )   // ROM
102117   AM_RANGE(0x200000, 0x203fff) AM_WRITE(MWA16_RAM             )   // RAM
103   AM_RANGE(0x400000, 0x4001ff) AM_WRITE(suna16_paletteram16_w) AM_BASE(&paletteram16)  // Banked Palette
118   AM_RANGE(0x400000, 0x4001ff) AM_WRITE(suna16_paletteram16_w      )  // Banked Palette
104119   AM_RANGE(0x400200, 0x400fff) AM_WRITE(MWA16_RAM             )   //
105120   AM_RANGE(0x600000, 0x61ffff) AM_WRITE(MWA16_RAM) AM_BASE(&spriteram16   )   // Sprites
106121   AM_RANGE(0xa00000, 0xa00001) AM_WRITE(suna16_soundlatch_w      )   // To Sound CPU
r1293r1294
136151static ADDRESS_MAP_START( uballoon_writemem, ADDRESS_SPACE_PROGRAM, 16 )
137152   AM_RANGE(0x000000, 0x0fffff) AM_WRITE(MWA16_ROM             )   // ROM
138153   AM_RANGE(0x800000, 0x803fff) AM_WRITE(MWA16_RAM             )   // RAM
139   AM_RANGE(0x200000, 0x2001ff) AM_WRITE(suna16_paletteram16_w) AM_BASE(&paletteram16)  // Banked Palette
154   AM_RANGE(0x200000, 0x2001ff) AM_WRITE(suna16_paletteram16_w      )   // Banked Palette
140155   AM_RANGE(0x200200, 0x200fff) AM_WRITE(MWA16_RAM             )   //
141156   AM_RANGE(0x400000, 0x41ffff) AM_WRITE(MWA16_RAM) AM_BASE(&spriteram16   )   // Sprites
142157   AM_RANGE(0x5c0000, 0x5dffff) AM_WRITE(uballoon_spriteram16_w   )   // Sprites (Mirror?)
r1293r1294
148163   AM_RANGE(0xa00000, 0xa0ffff) AM_WRITE(MWA16_NOP               )   // Protection
149164ADDRESS_MAP_END
150165
166
151167/***************************************************************************
152                                Suna Quiz 6000
168                            Suna Quiz 6000 Academy
153169***************************************************************************/
154170
155171static ADDRESS_MAP_START( sunaq_readmem, ADDRESS_SPACE_PROGRAM, 16 )
r1293r1294
168184   AM_RANGE(0x000000, 0x0fffff) AM_WRITE(MWA16_ROM             )   // ROM
169185   AM_RANGE(0x500000, 0x500001) AM_WRITE(suna16_soundlatch_w      )   // To Sound CPU
170186   AM_RANGE(0x500002, 0x500003) AM_WRITE(suna16_flipscreen_w      )   // Flip Screen
171   AM_RANGE(0x540000, 0x5401ff) AM_WRITE(suna16_paletteram16_w) AM_BASE(&paletteram16)
187   AM_RANGE(0x540000, 0x5401ff) AM_WRITE(suna16_paletteram16_w      )
172188   AM_RANGE(0x540200, 0x540fff) AM_WRITE(MWA16_RAM                 )   // RAM
173189   AM_RANGE(0x580000, 0x583fff) AM_WRITE(MWA16_RAM             )   // RAM
174190   AM_RANGE(0x5c0000, 0x5dffff) AM_WRITE(uballoon_spriteram16_w) AM_BASE(&spriteram16 )   // Sprites
175191ADDRESS_MAP_END
176192
193
177194/***************************************************************************
195                            Best Of Best
196***************************************************************************/
178197
198static UINT16 prot;
179199
200static READ16_HANDLER( bestbest_prot_r )
201{
202   return prot;
203}
204
205static WRITE16_HANDLER( bestbest_prot_w )
206{
207   if (ACCESSING_LSB)
208   {
209      switch (data & 0xff)
210      {
211         case 0x00:   prot = prot ^ 0x0009;   break;
212         case 0x08:   prot = prot ^ 0x0002;   break;
213         case 0x0c:   prot = prot ^ 0x0003;   break;
214//          default:    logerror("CPU#0 PC %06X - Unknown protection value: %04X\n", activecpu_get_pc(), data);
215      }
216   }
217}
218
219
220static ADDRESS_MAP_START( bestbest_map, ADDRESS_SPACE_PROGRAM, 16 )
221   AM_RANGE( 0x000000, 0x03ffff ) AM_ROM AM_MIRROR(0xc0000)         // ROM
222   AM_RANGE( 0x200000, 0x2fffff ) AM_ROM AM_REGION(REGION_USER1, 0)   // ROM
223   AM_RANGE( 0x500000, 0x500001 ) AM_READWRITE( input_port_0_word_r, suna16_soundlatch_w   )   // P1 + Coins, To Sound CPU
224   AM_RANGE( 0x500002, 0x500003 ) AM_READWRITE( input_port_1_word_r, bestbest_flipscreen_w   )   // P2 + Coins, Flip Screen
225   AM_RANGE( 0x500004, 0x500005 ) AM_READWRITE( input_port_2_word_r, bestbest_coin_w      )   // Coin Counter
226   AM_RANGE( 0x500008, 0x500009 ) AM_WRITE( bestbest_prot_w )   // Protection
227   AM_RANGE( 0x500018, 0x500019 ) AM_READ ( bestbest_prot_r )   //
228   AM_RANGE( 0x540000, 0x540fff ) AM_READWRITE( suna16_paletteram16_r, suna16_paletteram16_w )   // Banked(?) Palette
229   AM_RANGE( 0x541000, 0x54ffff ) AM_RAM                                          //
230   AM_RANGE( 0x580000, 0x58ffff ) AM_RAM                     // RAM
231   AM_RANGE( 0x5c0000, 0x5dffff ) AM_RAM AM_BASE( &spriteram16   )   // Sprites (Chip 1)
232   AM_RANGE( 0x5e0000, 0x5fffff ) AM_RAM AM_BASE( &spriteram16_2 )   // Sprites (Chip 2)
233ADDRESS_MAP_END
234
235
236/***************************************************************************
237
238
180239                                    Z80 #1
181240
182241        Plays the music (YM2151) and controls the 2 Z80s in charge
r1293r1294
225284ADDRESS_MAP_END
226285
227286/***************************************************************************
228                                Suna Quiz 6000
287                            Suna Quiz 6000 Academy
229288***************************************************************************/
230289
231290static ADDRESS_MAP_START( sunaq_sound_readmem, ADDRESS_SPACE_PROGRAM, 8 )
r1293r1294
244303ADDRESS_MAP_END
245304
246305/***************************************************************************
306                            Best Of Best
307***************************************************************************/
247308
309static ADDRESS_MAP_START( bestbest_sound_map, ADDRESS_SPACE_PROGRAM, 8 )
310   AM_RANGE( 0x0000, 0xbfff ) AM_ROM                           // ROM
311   AM_RANGE( 0xc000, 0xc000 ) AM_WRITE( YM3526_control_port_0_w   )   // YM3526
312   AM_RANGE( 0xc001, 0xc001 ) AM_WRITE( YM3526_write_port_0_w      )   //
313   AM_RANGE( 0xc002, 0xc002 ) AM_WRITE( AY8910_control_port_0_w   )   // AY8910
314   AM_RANGE( 0xc003, 0xc003 ) AM_WRITE( AY8910_write_port_0_w      )   //
315   AM_RANGE( 0xe000, 0xe7ff ) AM_RAM                           // RAM
316   AM_RANGE( 0xf000, 0xf000 ) AM_WRITE( soundlatch2_w            )   // To PCM Z80
317   AM_RANGE( 0xf800, 0xf800 ) AM_READ ( soundlatch_r            )   // From Main CPU
318ADDRESS_MAP_END
248319
320/***************************************************************************
321
322
249323                                Z80 #2 & #3
250324
251325        Dumb PCM samples players (e.g they don't even have RAM!)
r1293r1294
371445
372446
373447/***************************************************************************
448                            Best Of Best
449***************************************************************************/
374450
451static ADDRESS_MAP_START( bestbest_pcm_1_map, ADDRESS_SPACE_PROGRAM, 8 )
452   AM_RANGE(0x0000, 0xffff) AM_ROM
453ADDRESS_MAP_END
375454
455static ADDRESS_MAP_START( bestbest_pcm_1_iomap, ADDRESS_SPACE_IO, 8 )
456   ADDRESS_MAP_FLAGS( AMEF_ABITS(8) )
457   AM_RANGE(0x00, 0x00) AM_READ (soundlatch2_r    )   // From The Sound Z80
458   AM_RANGE(0x00, 0x01) AM_WRITE(bssoccer_DAC_1_w   )   // 2 x DAC
459   AM_RANGE(0x02, 0x03) AM_WRITE(bssoccer_DAC_2_w   )   // 2 x DAC
460ADDRESS_MAP_END
461
462/***************************************************************************
463
464
376465                                Input Ports
377466
378467
r1293r1294
568657INPUT_PORTS_END
569658
570659/***************************************************************************
571                                Suna Quiz 6000
660                            Suna Quiz 6000 Academy
572661***************************************************************************/
573662
574663static INPUT_PORTS_START( sunaq )
r1293r1294
620709INPUT_PORTS_END
621710
622711/***************************************************************************
712                            Best Of Best
713***************************************************************************/
623714
715static INPUT_PORTS_START( bestbest )
716   PORT_START   // IN0 - 500000.w - Player 1
717   PORT_BIT(  0x0001, IP_ACTIVE_LOW, IPT_JOYSTICK_UP      ) PORT_PLAYER(1)
718   PORT_BIT(  0x0002, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN      ) PORT_PLAYER(1)
719   PORT_BIT(  0x0004, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT      ) PORT_PLAYER(1)
720   PORT_BIT(  0x0008, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT   ) PORT_PLAYER(1)
721   PORT_BIT(  0x0010, IP_ACTIVE_LOW, IPT_BUTTON1         ) PORT_PLAYER(1)
722   PORT_BIT(  0x0020, IP_ACTIVE_LOW, IPT_BUTTON2         ) PORT_PLAYER(1)
723   PORT_BIT(  0x0040, IP_ACTIVE_LOW, IPT_BUTTON3         ) PORT_PLAYER(1)
724   PORT_BIT(  0x0080, IP_ACTIVE_LOW, IPT_UNKNOWN         )
725   PORT_BIT(  0x0100, IP_ACTIVE_LOW, IPT_UNKNOWN         )
726   PORT_BIT(  0x0200, IP_ACTIVE_LOW, IPT_BUTTON4         ) PORT_PLAYER(1)
727   PORT_BIT(  0x0400, IP_ACTIVE_LOW, IPT_BUTTON5         ) PORT_PLAYER(1)
728   PORT_BIT(  0x0800, IP_ACTIVE_LOW, IPT_BUTTON6         ) PORT_PLAYER(1)
729   PORT_BIT(  0x1000, IP_ACTIVE_LOW, IPT_UNKNOWN         )
730   PORT_BIT(  0x2000, IP_ACTIVE_LOW, IPT_UNKNOWN         )
731   PORT_BIT(  0x4000, IP_ACTIVE_LOW, IPT_START1         )
732   PORT_BIT(  0x8000, IP_ACTIVE_LOW, IPT_COIN1            )
624733
734   PORT_START   // IN1 - 500002.w - Player 2
735   PORT_BIT(  0x0001, IP_ACTIVE_LOW, IPT_JOYSTICK_UP      ) PORT_PLAYER(2)
736   PORT_BIT(  0x0002, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN      ) PORT_PLAYER(2)
737   PORT_BIT(  0x0004, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT      ) PORT_PLAYER(2)
738   PORT_BIT(  0x0008, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT   ) PORT_PLAYER(2)
739   PORT_BIT(  0x0010, IP_ACTIVE_LOW, IPT_BUTTON1         ) PORT_PLAYER(2)
740   PORT_BIT(  0x0020, IP_ACTIVE_LOW, IPT_BUTTON2         ) PORT_PLAYER(2)
741   PORT_BIT(  0x0040, IP_ACTIVE_LOW, IPT_BUTTON3         ) PORT_PLAYER(2)
742   PORT_BIT(  0x0080, IP_ACTIVE_LOW, IPT_UNKNOWN         )
743   PORT_BIT(  0x0100, IP_ACTIVE_LOW, IPT_UNKNOWN         )
744   PORT_BIT(  0x0200, IP_ACTIVE_LOW, IPT_BUTTON4         ) PORT_PLAYER(2)
745   PORT_BIT(  0x0400, IP_ACTIVE_LOW, IPT_BUTTON5         ) PORT_PLAYER(2)
746   PORT_BIT(  0x0800, IP_ACTIVE_LOW, IPT_BUTTON6         ) PORT_PLAYER(2)
747   PORT_BIT(  0x1000, IP_ACTIVE_LOW, IPT_UNKNOWN         )
748   PORT_BIT(  0x2000, IP_ACTIVE_LOW, IPT_UNKNOWN         )
749   PORT_BIT(  0x4000, IP_ACTIVE_LOW, IPT_START2         )
750   PORT_BIT(  0x8000, IP_ACTIVE_LOW, IPT_COIN2            )
751
752   PORT_START   // IN2 - 500004.w - DSW x 2
753   PORT_DIPNAME( 0x0007, 0x0007, DEF_STR( Coinage ) )
754   PORT_DIPSETTING(     0x0000, DEF_STR( 5C_1C ) )
755   PORT_DIPSETTING(     0x0001, DEF_STR( 4C_1C ) )
756   PORT_DIPSETTING(     0x0002, DEF_STR( 3C_1C ) )
757   PORT_DIPSETTING(     0x0003, DEF_STR( 2C_1C ) )
758   PORT_DIPSETTING(     0x0007, DEF_STR( 1C_1C ) )
759   PORT_DIPSETTING(     0x0006, DEF_STR( 1C_2C ) )
760   PORT_DIPSETTING(     0x0005, DEF_STR( 1C_3C ) )
761   PORT_DIPSETTING(     0x0004, DEF_STR( 1C_4C ) )
762   PORT_DIPNAME( 0x0018, 0x0010, DEF_STR( Difficulty ) )
763   PORT_DIPSETTING(     0x0018, DEF_STR( Easy )   )
764   PORT_DIPSETTING(     0x0010, DEF_STR( Normal )     )
765   PORT_DIPSETTING(     0x0008, DEF_STR( Hard )     )
766   PORT_DIPSETTING(     0x0000, DEF_STR( Hardest )     )
767   PORT_DIPNAME( 0x0020, 0x0020, "Display Combos" )
768   PORT_DIPSETTING(     0x0000, DEF_STR( Off ) )
769   PORT_DIPSETTING(     0x0020, DEF_STR( On ) )
770   PORT_SERVICE( 0x0040, IP_ACTIVE_LOW )
771   PORT_DIPNAME( 0x0080, 0x0000, DEF_STR( Demo_Sounds ) )
772   PORT_DIPSETTING(     0x0080, DEF_STR( Off ) )
773   PORT_DIPSETTING(     0x0000, DEF_STR( On ) )
774
775   PORT_DIPNAME( 0x0100, 0x0100, DEF_STR( Flip_Screen ) )
776   PORT_DIPSETTING(     0x0100, DEF_STR( Off ) )
777   PORT_DIPSETTING(     0x0000, DEF_STR( On ) )
778   PORT_DIPNAME( 0x0600, 0x0400, "Play Time" )
779   PORT_DIPSETTING(     0x0600, "1:10" )
780   PORT_DIPSETTING(     0x0400, "1:20" )
781   PORT_DIPSETTING(     0x0200, "1:30" )
782   PORT_DIPSETTING(     0x0000, "1:40" )
783   PORT_DIPUNUSED( 0x0800, 0x0800 )
784   PORT_DIPUNUSED( 0x1000, 0x1000 )
785   PORT_DIPUNUSED( 0x2000, 0x2000 )
786   PORT_DIPUNUSED( 0x4000, 0x4000 )
787   PORT_DIPUNUSED( 0x8000, 0x8000 )
788INPUT_PORTS_END
789
790/***************************************************************************
791
792
625793                                Graphics Layouts
626794
627795
r1293r1294
644812   GFXDECODE_ENTRY( REGION_GFX1, 0, layout_8x8x4, 0, 16*2 ) // [0] Sprites
645813GFXDECODE_END
646814
815// Two sprites chips
816static GFXDECODE_START( bestbest )
817   GFXDECODE_ENTRY( REGION_GFX1, 0, layout_8x8x4, 0, 256*8/16 ) // [0] Sprites (Chip 1)
818   GFXDECODE_ENTRY( REGION_GFX2, 0, layout_8x8x4, 0, 256*8/16 ) // [1] Sprites (Chip 2)
819GFXDECODE_END
647820
648821
649822
r1293r1294
660833                            Back Street Soccer
661834***************************************************************************/
662835
663INTERRUPT_GEN( bssoccer_interrupt )
836static INTERRUPT_GEN( bssoccer_interrupt )
664837{
665838   switch (cpu_getiloops())
666839   {
r1293r1294
779952MACHINE_DRIVER_END
780953
781954/***************************************************************************
782                                Suna Quiz 6000
955                            Suna Quiz 6000 Academy
783956***************************************************************************/
784957
785958static MACHINE_DRIVER_START( sunaq )
r1293r1294
8291002   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "right", 0.50)
8301003MACHINE_DRIVER_END
8311004
1005/***************************************************************************
1006                            Best Of Best
1007***************************************************************************/
8321008
1009static void bestbest_ym3526_irqhandler(int state)
1010{
1011   cpunum_set_input_line(1, INPUT_LINE_IRQ0, state);
1012}
1013
1014static struct YM3526interface bestbest_ym3526_interface =
1015{
1016   bestbest_ym3526_irqhandler
1017};
1018
1019static WRITE8_HANDLER( bestbest_ay8910_port_a_w )
1020{
1021   // ?
1022}
1023
1024static struct AY8910interface bestbest_ay8910_interface =
1025{
1026   0,                     0,
1027   bestbest_ay8910_port_a_w,   0
1028};
1029
1030static MACHINE_DRIVER_START( bestbest )
1031   /* basic machine hardware */
1032   MDRV_CPU_ADD(M68000, 24000000/4)
1033   MDRV_CPU_PROGRAM_MAP(bestbest_map,0)
1034   MDRV_CPU_VBLANK_INT(bssoccer_interrupt,2)
1035
1036   MDRV_CPU_ADD(Z80, 24000000/4)
1037   MDRV_CPU_PROGRAM_MAP(bestbest_sound_map,0)
1038
1039   MDRV_CPU_ADD(Z80, 24000000/4)
1040   MDRV_CPU_PROGRAM_MAP(bestbest_pcm_1_map,0)
1041   MDRV_CPU_IO_MAP(bestbest_pcm_1_iomap,0)
1042
1043   /* 2nd PCM Z80 missing */
1044
1045   MDRV_SCREEN_REFRESH_RATE(60)
1046   MDRV_SCREEN_VBLANK_TIME(DEFAULT_60HZ_VBLANK_DURATION)
1047   MDRV_INTERLEAVE(100)
1048
1049   /* video hardware */
1050   MDRV_VIDEO_ATTRIBUTES(VIDEO_TYPE_RASTER)
1051   MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16)
1052   MDRV_SCREEN_SIZE(256, 256)
1053   MDRV_SCREEN_VISIBLE_AREA(0, 256-1, 0+16, 256-16-1)
1054   MDRV_GFXDECODE(bestbest)
1055   MDRV_PALETTE_LENGTH(256*8)
1056
1057   MDRV_VIDEO_START(suna16)
1058   MDRV_VIDEO_UPDATE(bestbest)
1059
1060   /* sound hardware */
1061   MDRV_SPEAKER_STANDARD_STEREO("left", "right")
1062
1063   MDRV_SOUND_ADD(AY8910, 24000000/16)
1064   MDRV_SOUND_CONFIG(bestbest_ay8910_interface)
1065   MDRV_SOUND_ROUTE(0, "left", 1.0)
1066   MDRV_SOUND_ROUTE(1, "right", 1.0)
1067
1068   MDRV_SOUND_ADD(YM3526, 24000000/8)
1069   MDRV_SOUND_CONFIG(bestbest_ym3526_interface)
1070   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "left", 1.0)
1071   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "right", 1.0)
1072
1073   MDRV_SOUND_ADD(DAC, 0)
1074   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "left", 0.40)
1075
1076   MDRV_SOUND_ADD(DAC, 0)
1077   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "right", 0.40)
1078
1079   MDRV_SOUND_ADD(DAC, 0)
1080   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "left", 0.40)
1081
1082   MDRV_SOUND_ADD(DAC, 0)
1083   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "right", 0.40)
1084MACHINE_DRIVER_END
1085
8331086/***************************************************************************
8341087
8351088
r1293r1294
9351188{
9361189   UINT16 *RAM = (UINT16 *) memory_region(REGION_CPU1);
9371190
938   /* Patch out the protection checks */
1191   // Patch out the protection checks
9391192   RAM[0x0113c/2] = 0x4e71;   // bne $646
9401193   RAM[0x0113e/2] = 0x4e71;   // ""
9411194   RAM[0x01784/2] = 0x600c;   // beq $1792
r1293r1294
9451198}
9461199
9471200/***************************************************************************
948                                Suna Quiz 6000
1201                            Suna Quiz 6000 Academy
9491202
9501203  KRB-0027A mainboard
9511204
r1293r1294
9831236
9841237/***************************************************************************
9851238
1239Best Of Best
1240Suna, 1994
9861241
1242PCB Layout
1243----------
1244
1245KRB-0026
1246SUNA ELECTRONICS IND CO., LTD.
1247|------------------------------------------------------------|
1248|VOL     AY3-8910   Z80B     5.BIN                           |
1249|UPD1242H    6.BIN  Z80B     6116            68000           |
1250| LM324              24MHz   YM3526                          |
1251| LM324                                                      |
1252|    YM3014                82S129.5     4.BIN       2.BIN    |
1253|                  82S129.6|-------|                         |
1254|      62256               |UNKNOWN|    3.BIN       1.BIN    |
1255|                          |PLCC84 |                         |
1256|      62256               |       |    62256       62256    |
1257|                          |-------|                         |
1258|J                                                           |
1259|A                         |-------|                         |
1260|M     DSW2(8)             |ACTEL  |                         |
1261|M                         |A1020B |                         |
1262|A                         |PLCC84 |                         |
1263|      DSW1(8) 62256       |-------|           62256         |
1264|                                                            |
1265|        6116  62256                           62256         |
1266|        6116                                                |
1267|        6116  62256                           62256         |
1268|        6116                |-------------------------------|
1269|        6116                | 18.BIN  17.BIN          10.BIN|
1270|        6116                |         16.BIN  13.BIN   9.BIN|
1271|CN1     6116                |         15.BIN  12.BIN   8.BIN|
1272|        6116                |         14.BIN  11.BIN   7.BIN|
1273|----------------------------|-------------------------------|
1274Notes:
1275      68000    - clock 6.000MHz [24/4]
1276      Z80B     - clock 6.000MHz [24/4] for both
1277      YM3526   - clock 3.000MHz [24/8]
1278      AY3-8910 - clock 1.500MHz [24/16]
1279      6116     - 2kx8 SRAM
1280      62256    - 32kx8 SRAM
1281      CN1      - Connector for extra controls
1282      VSync    - 60Hz
1283      HSync    - 15.68kHz
1284
1285      ROMs 7-18 located on a plug-in daughterboard
1286      Both PROMs are identical
1287
1288***************************************************************************/
1289
1290ROM_START( bestbest )
1291   ROM_REGION( 0x40000, REGION_CPU1, 0 )    /* 68000 Code */
1292   // V13.0 1993,3,25-11,29 KIM.H.T M=1:KDS=9
1293   ROM_LOAD16_BYTE( "4.bin", 0x00000, 0x20000, CRC(06741994) SHA1(e872e9e9d02360dda9c9b6df8e6424b0f3e18c1f) )   // 1xxxxxxxxxxxxxxxx = 0xFF
1294   ROM_LOAD16_BYTE( "2.bin", 0x00001, 0x20000, CRC(42843dec) SHA1(3705661a9740b3499297424e340da9a3606873fb) )   // 1xxxxxxxxxxxxxxxx = 0xFF
1295
1296   ROM_REGION16_BE( 0x100000, REGION_USER1, 0 )    /* 68000 Data */
1297   ROM_LOAD16_BYTE( "3.bin", 0x00000, 0x80000, CRC(e2bb8f26) SHA1(d73bbe034718c77774dede61e751a9ae2d29118a) )
1298   ROM_LOAD16_BYTE( "1.bin", 0x00001, 0x80000, CRC(d365e20a) SHA1(29706d6e422e71c7dad51a3369683a6539f72b54) )
1299
1300   ROM_REGION( 0x10000, REGION_CPU2, 0 )    /* Z80 #1 - Music */
1301   ROM_LOAD( "5.bin", 0x00000, 0x10000, CRC(bb9265e6) SHA1(424eceac4fd48c9a99653ece2f3fcbc8b37569cf) ) // BEST OF BEST V10 XILINX PROGRAM 3020 1994,1,17
1302
1303   ROM_REGION( 0x10000, REGION_CPU3, 0 )    /* Z80 #2 - PCM */
1304   ROM_LOAD( "6.bin", 0x00000, 0x10000, CRC(dd445f6b) SHA1(658417d72c003f25db273e3c731838317ed1876c) )
1305
1306   /* There's no Z80 #3 - PCM */
1307
1308   ROM_REGION( 0x200000, REGION_GFX1, ROMREGION_DISPOSE | ROMREGION_INVERT )   /* Sprites (Chip 1) */
1309   ROM_LOAD( "9.bin",  0x000000, 0x80000, CRC(b11994ea) SHA1(4ff2250a9dbb2e575982e2ffcad7686347368b5b) )
1310   ROM_LOAD( "10.bin", 0x080000, 0x80000, CRC(37b41ef5) SHA1(dd4500663537ffad369ee9415c56df90221bed23) )
1311   ROM_LOAD( "7.bin",  0x100000, 0x80000, CRC(16188b73) SHA1(1e67f9b100614466e2ff1169f25c90e34a2e7db9) )
1312   ROM_LOAD( "8.bin",  0x180000, 0x80000, CRC(765ce06b) SHA1(6cc6d7c27b49eedd58104c50e4887f86bff9357c) )
1313
1314   ROM_REGION( 0x400000, REGION_GFX2, ROMREGION_DISPOSE | ROMREGION_INVERT )   /* Sprites (Chip 2) */
1315   ROM_LOAD( "16.bin", 0x000000, 0x80000, CRC(dc46cdea) SHA1(d601f5464894223ce8459093ae53006155a3e680) )
1316   ROM_LOAD( "17.bin", 0x080000, 0x80000, CRC(c6fadd57) SHA1(ce9bc4d7a288feebdd19de09d00bec8489346878) )
1317   ROM_LOAD( "13.bin", 0x100000, 0x80000, CRC(23283ac4) SHA1(f7aa00f203b17b590f1c43990f3f1c4aba7ba0ad) )
1318   ROM_LOAD( "18.bin", 0x180000, 0x80000, CRC(674c4609) SHA1(f1de78c01d26dfb1174203415ccf3c771398d163) )
1319
1320   ROM_LOAD( "14.bin", 0x200000, 0x80000, CRC(c210fb53) SHA1(3d5a763bffaef922a77c95131b1e41f0f90629a5) )
1321   ROM_LOAD( "15.bin", 0x280000, 0x80000, CRC(3b1166c7) SHA1(7f2a0c9131fcf39dd67047b6e697c4076ca37b19) )
1322   ROM_LOAD( "11.bin", 0x300000, 0x80000, CRC(323eebc3) SHA1(0e82b583273c9ba5252f7a108538ae58edf39a03) )
1323   ROM_LOAD( "12.bin", 0x380000, 0x80000, CRC(ca7c8176) SHA1(1ec99db3e0840b4647d6ccdf6fda118fa9ad4f42) )
1324
1325   ROM_REGION( 0x200, REGION_PROMS, 0 )   // ?
1326   ROM_LOAD( "82s129.5", 0x000, 0x100, CRC(10bfcebb) SHA1(ae8708db7d3a8984f16e876867ecdbb4445e3378) )   // FIXED BITS (0000xx0x0000xxxx)
1327   ROM_LOAD( "82s129.6", 0x100, 0x100, CRC(10bfcebb) SHA1(ae8708db7d3a8984f16e876867ecdbb4445e3378) )   // identical to 82s129.5
1328ROM_END
1329
1330
1331/***************************************************************************
1332
1333
9871334                                Games Drivers
9881335
9891336
9901337***************************************************************************/
9911338
1339GAME( 1994, bestbest, 0, bestbest, bestbest, 0,        ROT0, "SunA", "Best Of Best", 0 )
1340GAME( 1994, sunaq,    0, sunaq,    sunaq,    0,        ROT0, "SunA", "SunA Quiz 6000 Academy (940620-6)", 0 )   // Date/Version on-screen is 940620-6, but in the program rom it's 1994,6,30  K.H.T  V6.00
9921341GAME( 1996, bssoccer, 0, bssoccer, bssoccer, 0,        ROT0, "SunA", "Back Street Soccer", 0 )
9931342GAME( 1996, uballoon, 0, uballoon, uballoon, uballoon, ROT0, "SunA", "Ultra Balloon", 0 )
994// Date/Version on-screen is 940620-6, but in the program rom it's 1994,6,30  K.H.T  V6.00
995GAME( 1994, sunaq,    0, sunaq,    sunaq,    0,        ROT0, "SunA", "SunA Quiz 6000 Academy (940620-6)", 0 )
src/mame/drivers/littlerb.c
r1293r1294
6060
6161#include "driver.h"
6262
63UINT16 littlerb_vdp_address_low;
64UINT16 littlerb_vdp_address_high;
65UINT16 littlerb_vdp_writemode;
66UINT32 littlerb_write_address;
63static UINT16 littlerb_vdp_address_low;
64static UINT16 littlerb_vdp_address_high;
65static UINT16 littlerb_vdp_writemode;
66static UINT32 littlerb_write_address;
6767
68void littlerb_recalc_regs(void)
68static void littlerb_recalc_regs(void)
6969{
7070   littlerb_vdp_address_low = littlerb_write_address&0xffff;
7171   littlerb_vdp_address_high = (littlerb_write_address>>16)&0xffff;
7272}
7373
74UINT16* littlerb_region1;
75UINT16* littlerb_region2;
76UINT16* littlerb_region3;
77UINT16* littlerb_region4;
74static UINT16* littlerb_region1;
75static UINT16* littlerb_region2;
76static UINT16* littlerb_region3;
77static UINT16* littlerb_region4;
7878
7979
80void littlerb_data_write(UINT16 data)
80static void littlerb_data_write(UINT16 data)
8181{
8282   UINT32 addr = littlerb_write_address>>4; // is this right? should we shift?
8383
r1293r1294
133133
134134
135135
136void littlerb_recalc_address(void)
136static void littlerb_recalc_address(void)
137137{
138138   littlerb_write_address = littlerb_vdp_address_low | littlerb_vdp_address_high<<16;
139139}
src/mame/drivers/firebeat.c
r1293r1294
133133static UINT8 extend_board_irq_enable;
134134static UINT8 extend_board_irq_active;
135135
136static mame_timer *keyboard_timer;
136static emu_timer *keyboard_timer;
137137
138138static GCU_REGS gcu[2];
139139
r1293r1294
22832283static void init_keyboard(void)
22842284{
22852285   // set keyboard timer
2286   keyboard_timer = mame_timer_alloc(keyboard_timer_callback);
2287   mame_timer_adjust(keyboard_timer, MAME_TIME_IN_MSEC(10), 0, MAME_TIME_IN_MSEC(10));
2286   keyboard_timer = timer_alloc(keyboard_timer_callback);
2287   timer_adjust(keyboard_timer, ATTOTIME_IN_MSEC(10), 0, ATTOTIME_IN_MSEC(10));
22882288}
22892289
22902290static DRIVER_INIT(kbm)
src/mame/drivers/clayshoo.c
r1293r1294
2222
2323static UINT8 input_port_select;
2424static UINT8 analog_port_val;
25static mame_timer *analog_timer_1;
26static mame_timer *analog_timer_2;
25static emu_timer *analog_timer_1;
26static emu_timer *analog_timer_2;
2727
2828
2929
r1293r1294
9191}
9292
9393
94static mame_time compute_duration(int analog_pos)
94static attotime compute_duration(int analog_pos)
9595{
9696   /* the 58 comes from the length of the loop used to
9797       read the analog position */
98   return MAME_TIME_IN_CYCLES(58 * analog_pos, 0);
98   return ATTOTIME_IN_CYCLES(58 * analog_pos, 0);
9999}
100100
101101
r1293r1294
107107
108108   analog_port_val = 0xff;
109109
110   mame_timer_adjust(analog_timer_1, compute_duration(readinputportbytag("AN1")), 0x02, time_zero);
111   mame_timer_adjust(analog_timer_2, compute_duration(readinputportbytag("AN2")), 0x01, time_zero);
110   timer_adjust(analog_timer_1, compute_duration(readinputportbytag("AN1")), 0x02, attotime_zero);
111   timer_adjust(analog_timer_2, compute_duration(readinputportbytag("AN2")), 0x01, attotime_zero);
112112}
113113
114114
r1293r1294
120120
121121static void create_analog_timers(void)
122122{
123   analog_timer_1 = mame_timer_alloc(reset_analog_bit);
124   analog_timer_2 = mame_timer_alloc(reset_analog_bit);
123   analog_timer_1 = timer_alloc(reset_analog_bit);
124   analog_timer_2 = timer_alloc(reset_analog_bit);
125125}
126126
127127
src/mame/drivers/tagteam.c
r1293r1294
279279   MDRV_CPU_VBLANK_INT(nmi_line_pulse,16)   /* IRQs are triggered by the main CPU */
280280
281281   MDRV_SCREEN_REFRESH_RATE(57)
282   MDRV_SCREEN_VBLANK_TIME(USEC_TO_SUBSECONDS(3072))
282   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(3072))
283283
284284   /* video hardware */
285285   MDRV_VIDEO_ATTRIBUTES(VIDEO_TYPE_RASTER)
src/mame/drivers/bagman.c
r1293r1294
125125}
126126
127127
128int bagman_speech_rom_read_bit(void)
128static int bagman_speech_rom_read_bit(void)
129129{
130130   UINT8 *ROM = memory_region(REGION_SOUND1);
131131   int bit_no = (ls259_buf[0]<<2) | (ls259_buf[1]<<1) | (ls259_buf[2]<<0);
src/mame/drivers/namcos23.c
r1293r1294
852852   REGION_SOUND1
853853};
854854
855MACHINE_DRIVER_START( s23 )
855static MACHINE_DRIVER_START( s23 )
856856
857857   /* basic machine hardware */
858858   MDRV_CPU_ADD(R4650BE, 166000000)
r1293r1294
862862   MDRV_CPU_ADD(H83002, 14745600 )
863863   MDRV_CPU_PROGRAM_MAP( s23h8rwmap, 0 )
864864   MDRV_CPU_IO_MAP( s23h8iomap, 0 )
865   MDRV_CPU_VBLANK_INT( irq1_line_pulse, 1 );
865   MDRV_CPU_VBLANK_INT( irq1_line_pulse, 1 )
866866
867867   MDRV_SCREEN_REFRESH_RATE(60)
868868   MDRV_SCREEN_VBLANK_TIME(DEFAULT_60HZ_VBLANK_DURATION)
r1293r1294
889889   MDRV_SOUND_ROUTE(3, "left", 1.00)
890890MACHINE_DRIVER_END
891891
892MACHINE_DRIVER_START( ss23 )
892static MACHINE_DRIVER_START( ss23 )
893893
894894   /* basic machine hardware */
895895   MDRV_CPU_ADD(R4650BE, 166000000)
r1293r1294
900900   MDRV_CPU_ADD(H83002, 14745600 )
901901   MDRV_CPU_PROGRAM_MAP( s23h8rwmap, 0 )
902902   MDRV_CPU_IO_MAP( s23h8iomap, 0 )
903   MDRV_CPU_VBLANK_INT( irq1_line_pulse, 1 );
903   MDRV_CPU_VBLANK_INT( irq1_line_pulse, 1 )
904904
905905   MDRV_SCREEN_REFRESH_RATE(60)
906906   MDRV_SCREEN_VBLANK_TIME(DEFAULT_60HZ_VBLANK_DURATION)
src/mame/drivers/mjsister.c
r1293r1294
3939   DAC_data_w(0,DACROM[(dac_bank * 0x10000 + dac_adr++) & 0x1ffff]);
4040
4141   if (((dac_adr & 0xff00 ) >> 8) !=  dac_adr_e )
42      mame_timer_set(scale_up_mame_time(MAME_TIME_IN_HZ(MCLK), 1024),0,dac_callback);
42      timer_set(attotime_mul(ATTOTIME_IN_HZ(MCLK), 1024),0,dac_callback);
4343   else
4444      dac_busy = 0;
4545}
src/mame/drivers/ninjakd2.c
r1293r1294
238238static INT16 *sampledata[8];
239239static int samplelen[8];
240240
241void ninjakd2_init_samples(void)
241static void ninjakd2_init_samples(void)
242242{
243243   int i,n;
244244   UINT8 *source = memory_region(REGION_SOUND1);
r1293r1294
255255}
256256
257257
258INTERRUPT_GEN( ninjakd2_interrupt )
258static INTERRUPT_GEN( ninjakd2_interrupt )
259259{
260260   cpunum_set_input_line_and_vector(0, 0, HOLD_LINE, 0xd7);   /* RST 10h */
261261}
r1293r1294
481481   MDRV_CPU_IO_MAP(ninjakd2_sound_io,0)
482482
483483   MDRV_SCREEN_REFRESH_RATE(60)
484   MDRV_SCREEN_VBLANK_TIME(USEC_TO_SUBSECONDS(10000))
484   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(10000))
485485
486486   /* video hardware */
487487   MDRV_VIDEO_ATTRIBUTES(VIDEO_TYPE_RASTER)
src/mame/drivers/spacefb.c
r1293r1294
117117 *
118118 *************************************/
119119
120static mame_timer *interrupt_timer;
120static emu_timer *interrupt_timer;
121121
122122
123123static TIMER_CALLBACK( interrupt_callback )
r1293r1294
135135   else
136136      next_vpos = SPACEFB_INT_TRIGGER_COUNT_1;
137137
138   mame_timer_adjust(interrupt_timer, video_screen_get_time_until_pos(0, next_vpos, 0), 0, time_zero);
138   timer_adjust(interrupt_timer, video_screen_get_time_until_pos(0, next_vpos, 0), 0, attotime_zero);
139139}
140140
141141
142142static void create_interrupt_timer(void)
143143{
144   interrupt_timer = mame_timer_alloc(interrupt_callback);
144   interrupt_timer = timer_alloc(interrupt_callback);
145145}
146146
147147
148148static void start_interrupt_timer(void)
149149{
150   mame_timer_adjust(interrupt_timer, video_screen_get_time_until_pos(0, SPACEFB_INT_TRIGGER_COUNT_1, 0), 0, time_zero);
150   timer_adjust(interrupt_timer, video_screen_get_time_until_pos(0, SPACEFB_INT_TRIGGER_COUNT_1, 0), 0, attotime_zero);
151151}
152152
153153
src/mame/drivers/cubocd32.c
r1293r1294
173173static ADDRESS_MAP_START( cd32_map, ADDRESS_SPACE_PROGRAM, 32 )
174174   ADDRESS_MAP_FLAGS( AMEF_UNMAP(1) )
175175   AM_RANGE(0x000000, 0x1fffff) AM_RAMBANK(1) AM_BASE(&amiga_chip_ram32) AM_SIZE(&amiga_chip_ram_size)
176   AM_RANGE(0x800000, 0x800003) AM_READ( dipswitch_r );
176   AM_RANGE(0x800000, 0x800003) AM_READ( dipswitch_r )
177177   AM_RANGE(0xb80000, 0xb8003f) AM_READWRITE(amiga_akiko32_r, amiga_akiko32_w)
178   AM_RANGE(0xbfa000, 0xbfa003) AM_WRITE(aga_overlay_w);
178   AM_RANGE(0xbfa000, 0xbfa003) AM_WRITE(aga_overlay_w)
179179   AM_RANGE(0xbfd000, 0xbfefff) AM_READWRITE(amiga_cia32_r, amiga_cia32_w)
180180   AM_RANGE(0xc00000, 0xdfffff) AM_READWRITE(amiga_custom32_r, amiga_custom32_w) AM_BASE((UINT32**)&amiga_custom_regs)
181181   AM_RANGE(0xe00000, 0xe7ffff) AM_ROM AM_REGION(REGION_USER1, 0x80000)   /* CD32 Extended ROM */
r1293r1294
271271   MDRV_CPU_VBLANK_INT(amiga_scanline_callback, 312)
272272
273273   MDRV_SCREEN_REFRESH_RATE(59.997)
274   MDRV_SCREEN_VBLANK_TIME(USEC_TO_SUBSECONDS(0))
274   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(0))
275275
276276   MDRV_MACHINE_RESET(amiga)
277277   MDRV_NVRAM_HANDLER(cd32)
src/mame/drivers/wheelfir.c
r1293r1294
537537   PORT_BIT( 0xff00, IP_ACTIVE_LOW, IPT_UNUSED )
538538INPUT_PORTS_END
539539
540static mame_timer* frame_timer;
541static mame_timer* scanline_timer;
540static emu_timer* frame_timer;
541static emu_timer* scanline_timer;
542542
543543static TIMER_CALLBACK( frame_timer_callback )
544544{
r1293r1294
548548static int scanline_counter = 0;
549549static int total_scanlines = 262;
550550
551void render_background_to_render_buffer(int scanline)
551static void render_background_to_render_buffer(int scanline)
552552{
553553   int x;
554554   UINT16 yscroll = (wheelfir_blitdata[0xb]&0x00ff) | (wheelfir_blitdata[0x8]&0x0080) << 1;
r1293r1294
575575   {
576576      scanline_counter++;
577577      cpunum_set_input_line(0, 5, HOLD_LINE); // raster IRQ, changes scroll values for road
578      mame_timer_adjust(scanline_timer, scale_down_mame_time(MAME_TIME_IN_HZ(60), total_scanlines), 0, time_zero);
578      timer_adjust(scanline_timer, attotime_div(ATTOTIME_IN_HZ(60), total_scanlines), 0, attotime_zero);
579579
580580      if (scanline_counter<256)
581581      {
r1293r1294
606606   scanline_counter = -1;
607607   fillbitmap(wheelfir_tmp_bitmap[0], 0,&machine->screen[0].visarea);
608608
609   mame_timer_adjust(frame_timer,  time_zero, 0, time_zero);
610   mame_timer_adjust(scanline_timer,  time_zero, 0, time_zero);
609   timer_adjust(frame_timer,  attotime_zero, 0, attotime_zero);
610   timer_adjust(scanline_timer,  attotime_zero, 0, attotime_zero);
611611}
612612
613613static MACHINE_RESET(wheelfir)
614614{
615   frame_timer = mame_timer_alloc(frame_timer_callback);
616   scanline_timer = mame_timer_alloc(scanline_timer_callback);
617   mame_timer_adjust(frame_timer, time_zero, 0, time_zero);
618   mame_timer_adjust(scanline_timer,  time_zero, 0, time_zero);
615   frame_timer = timer_alloc(frame_timer_callback);
616   scanline_timer = timer_alloc(scanline_timer_callback);
617   timer_adjust(frame_timer, attotime_zero, 0, attotime_zero);
618   timer_adjust(scanline_timer,  attotime_zero, 0, attotime_zero);
619619   scanline_counter = -1;
620620}
621621
src/mame/drivers/cbuster.c
r1293r1294
351351   MDRV_CPU_PROGRAM_MAP(sound_readmem,sound_writemem)
352352
353353   MDRV_SCREEN_REFRESH_RATE(58)
354   MDRV_SCREEN_VBLANK_TIME(USEC_TO_SUBSECONDS(529))
354   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(529))
355355
356356   /* video hardware */
357357   MDRV_VIDEO_ATTRIBUTES(VIDEO_TYPE_RASTER | VIDEO_BUFFERS_SPRITERAM)
src/mame/drivers/ghosteo.c
r1293r1294
470470   return 0;
471471}
472472
473INTERRUPT_GEN( bballoon_interrupt )
473static INTERRUPT_GEN( bballoon_interrupt )
474474{
475475   if(irq_en)
476476      cpunum_set_input_line(0, ARM7_IRQ_LINE, PULSE_LINE);
src/mame/drivers/dunhuang.c
r1293r1294
301301
302302// Palette: HMC HM86171 VGA 256 colour RAMDAC
303303
304int dunhuang_paloffs;
304static int dunhuang_paloffs;
305305static WRITE8_HANDLER( dunhuang_paloffs_w )   {   dunhuang_paloffs = data * 3;   }
306306static WRITE8_HANDLER( dunhuang_paldata_w )
307307{
r1293r1294
441441
442442static INPUT_PORTS_START( dunhuang )
443443   PORT_START   // IN0 - DSW1
444   PORT_DIPNAME( 0x0f, 0x0f, "Main Game Chance (%)" )
444   PORT_DIPNAME( 0x0f, 0x0f, "Main Game Chance (%)" )   PORT_DIPLOCATION("SW1:1,2,3,4")
445445   PORT_DIPSETTING(    0x00, "78" )
446446   PORT_DIPSETTING(    0x01, "80" )
447447   PORT_DIPSETTING(    0x02, "81" )
r1293r1294
458458   PORT_DIPSETTING(    0x0d, "96" )
459459   PORT_DIPSETTING(    0x0e, "97" )
460460   PORT_DIPSETTING(    0x0f, "98" )
461   PORT_DIPNAME( 0x30, 0x30, "Main Game Rate" )
461   PORT_DIPNAME( 0x30, 0x30, "Main Game Rate" )      PORT_DIPLOCATION("SW1:5,6")
462462   PORT_DIPSETTING(    0x30, "A" )
463463   PORT_DIPSETTING(    0x20, "B" )
464464   PORT_DIPSETTING(    0x10, "C" )
465465   PORT_DIPSETTING(    0x00, "D" )
466   PORT_DIPNAME( 0x40, 0x40, "Input Tokens" )
466   PORT_DIPNAME( 0x40, 0x40, "Input Tokens" )         PORT_DIPLOCATION("SW1:7")
467467   PORT_DIPSETTING(    0x40, "Keys" )
468468   PORT_DIPSETTING(    0x00, "Coins" )
469   PORT_DIPNAME( 0x80, 0x80, "Output Tokens" )
469   PORT_DIPNAME( 0x80, 0x80, "Output Tokens" )         PORT_DIPLOCATION("SW1:8")
470470   PORT_DIPSETTING(    0x80, "Keys" )
471471   PORT_DIPSETTING(    0x00, "Payout" )
472472
473473   PORT_START   // IN1 - DSW2
474   PORT_DIPNAME( 0x01, 0x01, DEF_STR( Unknown ) )
475   PORT_DIPSETTING(    0x01, DEF_STR( Off ) )
476   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
477   PORT_DIPNAME( 0x06, 0x06, "Credits Per Coin" )
474   PORT_DIPUNKNOWN_DIPLOC( 0x01, 0x01, "SW2:1" )
475   PORT_DIPNAME( 0x06, 0x06, "Credits Per Coin" )      PORT_DIPLOCATION("SW2:2,3")
478476   PORT_DIPSETTING(    0x06, "1" )
479477   PORT_DIPSETTING(    0x04, "2" )
480478   PORT_DIPSETTING(    0x02, "5" )
481479   PORT_DIPSETTING(    0x00, "20" )
482   PORT_DIPNAME( 0x18, 0x18, "Credits Per Key-In" )
480   PORT_DIPNAME( 0x18, 0x18, "Credits Per Key-In" )   PORT_DIPLOCATION("SW2:4,5")
483481   PORT_DIPSETTING(    0x18, "1" )
484482   PORT_DIPSETTING(    0x10, "10" )
485483   PORT_DIPSETTING(    0x08, "50" )
486484   PORT_DIPSETTING(    0x00, "100" )
487   PORT_DIPNAME( 0x20, 0x20, "Credits Per Key-Out" )
485   PORT_DIPNAME( 0x20, 0x20, "Credits Per Key-Out" )   PORT_DIPLOCATION("SW2:6")
488486   PORT_DIPSETTING(    0x20, "1" )
489487   PORT_DIPSETTING(    0x00, "100" )
490   PORT_DIPNAME( 0xc0, 0xc0, "Max Credits" )
488   PORT_DIPNAME( 0xc0, 0xc0, "Max Credits" )         PORT_DIPLOCATION("SW2:7,8")
491489   PORT_DIPSETTING(    0x00, "300" )
492490   PORT_DIPSETTING(    0x40, "500" )
493491   PORT_DIPSETTING(    0x80, "1000" )
494492   PORT_DIPSETTING(    0xc0, "3000" )
495493
496494   PORT_START   // IN2 - DSW3
497   PORT_DIPNAME( 0x03, 0x03, "Min Bet" )
495   PORT_DIPNAME( 0x03, 0x03, "Min Bet" )            PORT_DIPLOCATION("SW3:1,2")
498496   PORT_DIPSETTING(    0x03, "1" )
499497   PORT_DIPSETTING(    0x02, "2" )
500498   PORT_DIPSETTING(    0x01, "3" )
501499   PORT_DIPSETTING(    0x00, "5" )
502   PORT_DIPNAME( 0x0c, 0x0c, "Max Bet" )
500   PORT_DIPNAME( 0x0c, 0x0c, "Max Bet" )            PORT_DIPLOCATION("SW3:3,4")
503501   PORT_DIPSETTING(    0x0c, "1" )
504502   PORT_DIPSETTING(    0x08, "5" )
505503   PORT_DIPSETTING(    0x04, "10" )
506504   PORT_DIPSETTING(    0x00, "20" )
507   PORT_DIPNAME( 0x30, 0x30, "Renso Bonus Time" )
505   PORT_DIPNAME( 0x30, 0x30, "Renso Bonus Time" )      PORT_DIPLOCATION("SW3:5,6")
508506   PORT_DIPSETTING(    0x00, DEF_STR( None ) )
509507   PORT_DIPSETTING(    0x10, "3" )
510508   PORT_DIPSETTING(    0x20, "5" )
511509   PORT_DIPSETTING(    0x30, "6" )
512   PORT_DIPNAME( 0xc0, 0xc0, "DonDen Times" )
510   PORT_DIPNAME( 0xc0, 0xc0, "DonDen Times" )         PORT_DIPLOCATION("SW3:7,8")
513511   PORT_DIPSETTING(    0x00, DEF_STR( None ) )
514512   PORT_DIPSETTING(    0x40, "3" )
515513   PORT_DIPSETTING(    0x80, "5" )
516514   PORT_DIPSETTING(    0xc0, "6" )
517515
518516   PORT_START   // IN3 - DSW4
519   PORT_DIPNAME( 0x07, 0x07, "Credits Limit" )
517   PORT_DIPNAME( 0x07, 0x07, "Credits Limit" )         PORT_DIPLOCATION("SW4:1,2,3")
520518   PORT_DIPSETTING(    0x07, "2k" )
521519   PORT_DIPSETTING(    0x06, "3k" )
522520   PORT_DIPSETTING(    0x05, "5k" )
r1293r1294
525523   PORT_DIPSETTING(    0x02, "30k" )
526524   PORT_DIPSETTING(    0x01, "50k" )
527525   PORT_DIPSETTING(    0x00, "100k" )
528   PORT_DIPNAME( 0x38, 0x38, "Service-In Limit" )
526   PORT_DIPNAME( 0x38, 0x38, "Service-In Limit" )      PORT_DIPLOCATION("SW4:4,5,6")
529527   PORT_DIPSETTING(    0x00, "20k" )
530528   PORT_DIPSETTING(    0x08, "30k" )
531529   PORT_DIPSETTING(    0x10, "40k" )
r1293r1294
534532   PORT_DIPSETTING(    0x28, "100k" )
535533   PORT_DIPSETTING(    0x30, "200k" )
536534   PORT_DIPSETTING(    0x38, "990k" )
537   PORT_DIPNAME( 0x40, 0x40, "Hu Type" )
535   PORT_DIPNAME( 0x40, 0x40, "Hu Type" )            PORT_DIPLOCATION("SW4:7")
538536   PORT_DIPSETTING(    0x40, "Topple" )
539537   PORT_DIPSETTING(    0x00, "Non-Topple" )
540   PORT_DIPNAME( 0x80, 0x80, "Double Up" )
538   PORT_DIPNAME( 0x80, 0x80, "Double Up" )            PORT_DIPLOCATION("SW4:8")
541539   PORT_DIPSETTING(    0x00, DEF_STR( No ) )
542540   PORT_DIPSETTING(    0x80, DEF_STR( Yes ) )
543541
544542   PORT_START   // IN4 - DSW5
545   PORT_DIPNAME( 0x03, 0x03, "Douple Up Chance (%)" )
543   PORT_DIPNAME( 0x03, 0x03, "Douple Up Chance (%)" )   PORT_DIPLOCATION("SW5:1,2")
546544   PORT_DIPSETTING(    0x00, "50" )
547545   PORT_DIPSETTING(    0x01, "60" )
548546   PORT_DIPSETTING(    0x02, "70" )
549547   PORT_DIPSETTING(    0x03, "80" )
550   PORT_DIPNAME( 0x04, 0x04, "Chinese Word" )
548   PORT_DIPNAME( 0x04, 0x04, "Chinese Word" )         PORT_DIPLOCATION("SW5:3")
551549   PORT_DIPSETTING(    0x04, "3..6" )
552550   PORT_DIPSETTING(    0x00, "5..10" )
553   PORT_DIPNAME( 0x08, 0x08, "Big Odds Times" )
551   PORT_DIPNAME( 0x08, 0x08, "Big Odds Times" )      PORT_DIPLOCATION("SW5:4")
554552   PORT_DIPSETTING(    0x00, "3" )
555553   PORT_DIPSETTING(    0x08, "5" )
556   PORT_DIPNAME( 0x30, 0x30, "Hu Test Times" )
554   PORT_DIPNAME( 0x30, 0x30, "Hu Test Times" )         PORT_DIPLOCATION("SW5:5,6")
557555   PORT_DIPSETTING(    0x30, DEF_STR( None ) )
558556   PORT_DIPSETTING(    0x00, "5" )
559557   PORT_DIPSETTING(    0x10, "6" )
560558   PORT_DIPSETTING(    0x20, "8" )
561   PORT_DIPNAME( 0x40, 0x40, DEF_STR( Demo_Sounds ) )
559   PORT_DIPNAME( 0x40, 0x40, DEF_STR( Demo_Sounds ) )   PORT_DIPLOCATION("SW5:7")
562560   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
563561   PORT_DIPSETTING(    0x40, DEF_STR( On ) )
564   PORT_DIPNAME( 0x80, 0x80, "Computer Strength" )
562   PORT_DIPNAME( 0x80, 0x80, "Computer Strength" )      PORT_DIPLOCATION("SW5:8")
565563   PORT_DIPSETTING(    0x80, "Strong" )
566564   PORT_DIPSETTING(    0x00, "Weak" )
567565
568566   PORT_START   // IN5 - SERVICE
569   PORT_BIT( 0x01, IP_ACTIVE_LOW,  IPT_SERVICE3 )   // clear (during boot)
570   PORT_BIT( 0x02, IP_ACTIVE_LOW,  IPT_SERVICE2 )   // book
571   PORT_BIT( 0x04, IP_ACTIVE_LOW,  IPT_SERVICE  )   // test (in game: dips, during boot: service mode)
572   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_SPECIAL  )   // hopper sensor
573   PORT_BIT( 0x10, IP_ACTIVE_LOW,  IPT_SERVICE4 )   // payout
567   PORT_BIT( 0x01, IP_ACTIVE_LOW,  IPT_SERVICE3 )      // clear (during boot)
568   PORT_BIT( 0x02, IP_ACTIVE_LOW,  IPT_SERVICE2 )      // book
569   PORT_BIT( 0x04, IP_ACTIVE_LOW,  IPT_SERVICE  )      // test (in game: dips, during boot: service mode)
570   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_SPECIAL  )      // hopper sensor
571   PORT_BIT( 0x10, IP_ACTIVE_LOW,  IPT_SERVICE4 )      // payout
574572   PORT_BIT( 0x20, IP_ACTIVE_LOW,  IPT_COIN1 ) PORT_IMPULSE(2)   // "coin jam" otherwise
575573   PORT_BIT( 0x40, IP_ACTIVE_LOW,  IPT_UNKNOWN )
576   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_SPECIAL )   // 0 = tiles block transferrer busy
574   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_SPECIAL )      // 0 = tiles block transferrer busy
577575
578576   PORT_START   // IN6 - P1
579577   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_MAHJONG_A )
r1293r1294
590588   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_MAHJONG_F )
591589   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_MAHJONG_J )
592590   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_MAHJONG_N )
593   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_MAHJONG_RON )   // tin
591   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_MAHJONG_REACH )   // tin
594592   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_MAHJONG_BET )
595593   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )
596594   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
r1293r1294
599597   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_MAHJONG_C )
600598   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_MAHJONG_G )
601599   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_MAHJONG_K )
602   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_MAHJONG_REACH )   // eat
603   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_MAHJONG_CHI )   // hu
600   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_MAHJONG_CHI )   // eat
601   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_MAHJONG_RON )   // hu
604602   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_UNKNOWN )
605603   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )
606604   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
r1293r1294
609607   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_MAHJONG_D )
610608   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_MAHJONG_H )
611609   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_MAHJONG_L )
612   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_MAHJONG_PON )
610   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_MAHJONG_PON )   // pon
613611   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_UNKNOWN )
614612   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_UNKNOWN )
615613   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )
r1293r1294
679677
680678   MDRV_SCREEN_REFRESH_RATE(60)
681679   MDRV_SCREEN_VBLANK_TIME(DEFAULT_60HZ_VBLANK_DURATION)
682   MDRV_WATCHDOG_TIME_INIT(MAME_TIME_IN_SEC(5))
680   MDRV_WATCHDOG_TIME_INIT(ATTOTIME_IN_SEC(5))
683681
684682   /* video hardware */
685683   MDRV_VIDEO_ATTRIBUTES(VIDEO_TYPE_RASTER )
src/mame/drivers/onetwo.c
r1293r1294
273273   MDRV_CPU_IO_MAP(sound_cpu_io,0)
274274
275275   MDRV_SCREEN_REFRESH_RATE(60)
276   MDRV_SCREEN_VBLANK_TIME(USEC_TO_SUBSECONDS(16))
276   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(16))
277277
278278   /* video hardware */
279279   MDRV_VIDEO_ATTRIBUTES(VIDEO_TYPE_RASTER)
src/mame/drivers/kncljoe.c
r1293r1294
185185   MDRV_CPU_VBLANK_INT(irq0_line_hold,1)
186186
187187   MDRV_SCREEN_REFRESH_RATE(60)
188   MDRV_SCREEN_VBLANK_TIME(USEC_TO_SUBSECONDS(1500))
188   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(1500))
189189
190190   /* video hardware */
191191   MDRV_VIDEO_ATTRIBUTES(VIDEO_TYPE_RASTER | VIDEO_UPDATE_AFTER_VBLANK)
src/mame/drivers/liberate.c
r1293r1294
527527   MDRV_CPU_VBLANK_INT(nmi_line_pulse,16)
528528
529529   MDRV_SCREEN_REFRESH_RATE(60)
530   MDRV_SCREEN_VBLANK_TIME(USEC_TO_SUBSECONDS(529) /* 529ms Vblank duration?? */)
530   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(529) /* 529ms Vblank duration?? */)
531531   MDRV_INTERLEAVE(200)
532532
533533   /* video hardware */
r1293r1294
597597   MDRV_CPU_VBLANK_INT(nmi_line_pulse,16)
598598
599599   MDRV_SCREEN_REFRESH_RATE(60)
600   MDRV_SCREEN_VBLANK_TIME(USEC_TO_SUBSECONDS(529) /* 529ms Vblank duration?? */)
600   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(529) /* 529ms Vblank duration?? */)
601601   MDRV_INTERLEAVE(200)
602602
603603   /* video hardware */
src/mame/drivers/cvs.c
r1293r1294
182182    }
183183}
184184
185int cvs_speech_rom_read_bit(void)
185static int cvs_speech_rom_read_bit(void)
186186{
187187   UINT8 *ROM = memory_region(REGION_SOUND1);
188188    int bit;
r1293r1294
381381   MDRV_CPU_IO_MAP(cvs_cpu2_io,0)
382382
383383   MDRV_SCREEN_REFRESH_RATE(60)
384   MDRV_SCREEN_VBLANK_TIME(USEC_TO_SUBSECONDS(1000))
384   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(1000))
385385
386386   /* video hardware */
387387   MDRV_VIDEO_ATTRIBUTES(VIDEO_TYPE_RASTER)
src/mame/drivers/turbo.c
r1293r1294
14161416 *
14171417 *************************************/
14181418
1419void turbo_rom_decode(void)
1419static void turbo_rom_decode(void)
14201420{
14211421   /*
14221422     * The table is arranged this way (second half is mirror image of first)
src/mame/drivers/seta.c
r1293r1294
12381238    timer(uPD71054) struct
12391239------------------------------*/
12401240static struct st_chip {
1241   mame_timer *timer[3];         // Timer
1241   emu_timer *timer[3];         // Timer
12421242   UINT16   max[3];            // Max counter
12431243   UINT16   write_select;      // Max counter write select
12441244   UINT8   reg[4];            //
r1293r1294
12471247/*------------------------------
12481248    uppdate timer
12491249------------------------------*/
1250void uPD71054_update_timer( int no )
1250static void uPD71054_update_timer( int no )
12511251{
12521252   UINT16 max = uPD71054.max[no]&0xffff;
12531253
12541254   if( max != 0 ) {
1255      mame_time period = scale_up_mame_time(MAME_TIME_IN_HZ(Machine->drv->cpu[0].clock), 16 * max);
1256      mame_timer_adjust( uPD71054.timer[no], period, no, time_zero );
1255      attotime period = attotime_mul(ATTOTIME_IN_HZ(Machine->drv->cpu[0].clock), 16 * max);
1256      timer_adjust( uPD71054.timer[no], period, no, attotime_zero );
12571257   } else {
1258      mame_timer_adjust( uPD71054.timer[no], time_never, no, time_never);
1258      timer_adjust( uPD71054.timer[no], attotime_never, no, attotime_never);
12591259      logerror( "CPU #0 PC %06X: uPD71054 error, timer %d duration is 0\n",
12601260            activecpu_get_pc(), no );
12611261   }
r1293r1294
12771277/*------------------------------
12781278    initialize
12791279------------------------------*/
1280void uPD71054_timer_init( void )
1280static void uPD71054_timer_init( void )
12811281{
12821282   int no;
12831283
r1293r1294
12871287      uPD71054.max[no] = 0xffff;
12881288   }
12891289   for( no = 0; no < USED_TIMER_NUM; no++ ) {
1290      uPD71054.timer[no] = mame_timer_alloc( uPD71054_timer_callback );
1290      uPD71054.timer[no] = timer_alloc( uPD71054_timer_callback );
12911291   }
12921292}
12931293
r1293r1294
16091609   {
16101610      soundlatch_word_w(0,data,mem_mask);
16111611      cpunum_set_input_line(1, INPUT_LINE_NMI, PULSE_LINE);
1612      cpu_spinuntil_time(MAME_TIME_IN_USEC(50));   // Allow the other cpu to reply
1612      cpu_spinuntil_time(ATTOTIME_IN_USEC(50));   // Allow the other cpu to reply
16131613   }
16141614}
16151615
r1293r1294
24892489                            Pro Mahjong Kiwame
24902490***************************************************************************/
24912491
2492UINT16 *kiwame_nvram;
2492static UINT16 *kiwame_nvram;
24932493
24942494static READ16_HANDLER( kiwame_nvram_r )
24952495{
r1293r1294
28402840static WRITE8_HANDLER( calibr50_soundlatch2_w )
28412841{
28422842   soundlatch2_w(0,data);
2843   cpu_spinuntil_time(MAME_TIME_IN_USEC(50));   // Allow the other cpu to reply
2843   cpu_spinuntil_time(ATTOTIME_IN_USEC(50));   // Allow the other cpu to reply
28442844}
28452845
28462846static ADDRESS_MAP_START( calibr50_sub_readmem, ADDRESS_SPACE_PROGRAM, 8 )
r1293r1294
65336533*/
65346534
65356535#define calibr50_INTERRUPTS_NUM (4+1)
6536INTERRUPT_GEN( calibr50_interrupt )
6536static INTERRUPT_GEN( calibr50_interrupt )
65376537{
65386538   switch (cpu_getiloops())
65396539   {
r1293r1294
88588858
88598859
88608860/* Protection? NVRAM is handled writing commands here */
8861UINT16 downtown_protection[0x200/2];
8861static UINT16 downtown_protection[0x200/2];
88628862static READ16_HANDLER( downtown_protection_r )
88638863{
88648864   int job = downtown_protection[0xf8/2] & 0xff;
src/mame/drivers/truco.c
r1293r1294
155155   MDRV_SCREEN_VBLANK_TIME(DEFAULT_REAL_60HZ_VBLANK_DURATION)
156156   MDRV_CPU_VBLANK_INT(truco_interrupt,1)
157157
158   MDRV_MACHINE_RESET(truco);
158   MDRV_MACHINE_RESET(truco)
159159
160160   /* video hardware */
161161   MDRV_VIDEO_ATTRIBUTES(VIDEO_TYPE_RASTER)
src/mame/drivers/trvquest.c
r1293r1294
220220   /* Kaos sits in a tight loop polling the VIA irq flags register, but that register is
221221       cleared by the irq handler. Therefore, I wait a bit before triggering the irq to
222222       leave time for the program to see the flag change. */
223   mame_timer_set(MAME_TIME_IN_USEC(50), state, via_irq_delayed);
223   timer_set(ATTOTIME_IN_USEC(50), state, via_irq_delayed);
224224}
225225
226226
src/mame/drivers/tnzs.c
r1293r1294
234234static INT16 *sampledata[MAX_SAMPLES];
235235static int samplesize[MAX_SAMPLES];
236236
237void kageki_init_samples(void)
237static void kageki_init_samples(void)
238238{
239239   UINT8 *scan, *src;
240240   INT16 *dest;
src/mame/drivers/rohga.c
r1293r1294
822822   MDRV_CPU_PROGRAM_MAP(sound_readmem,sound_writemem)
823823
824824   MDRV_SCREEN_REFRESH_RATE(58)
825   MDRV_SCREEN_VBLANK_TIME(USEC_TO_SUBSECONDS(529))
825   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(529))
826826
827827   /* video hardware */
828828   MDRV_VIDEO_ATTRIBUTES(VIDEO_TYPE_RASTER | VIDEO_BUFFERS_SPRITERAM)
r1293r1294
865865   MDRV_CPU_PROGRAM_MAP(sound_readmem,sound_writemem)
866866
867867   MDRV_SCREEN_REFRESH_RATE(58)
868   MDRV_SCREEN_VBLANK_TIME(USEC_TO_SUBSECONDS(529))
868   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(529))
869869
870870   /* video hardware */
871871   MDRV_VIDEO_ATTRIBUTES(VIDEO_TYPE_RASTER | VIDEO_BUFFERS_SPRITERAM )
r1293r1294
908908   MDRV_CPU_PROGRAM_MAP(sound_readmem,sound_writemem)
909909
910910   MDRV_SCREEN_REFRESH_RATE(58)
911   MDRV_SCREEN_VBLANK_TIME(USEC_TO_SUBSECONDS(529))
911   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(529))
912912
913913   /* video hardware */
914914   MDRV_VIDEO_ATTRIBUTES(VIDEO_TYPE_RASTER | VIDEO_BUFFERS_SPRITERAM )
r1293r1294
951951   MDRV_CPU_PROGRAM_MAP(sound_readmem,sound_writemem)
952952
953953   MDRV_SCREEN_REFRESH_RATE(58)
954   MDRV_SCREEN_VBLANK_TIME(USEC_TO_SUBSECONDS(529))
954   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(529))
955955
956956   /* video hardware */
957957   MDRV_VIDEO_ATTRIBUTES(VIDEO_TYPE_RASTER | VIDEO_BUFFERS_SPRITERAM)
src/mame/drivers/higemaru.c
r1293r1294
1919extern VIDEO_UPDATE( higemaru );
2020
2121
22INTERRUPT_GEN( higemaru_interrupt )
22static INTERRUPT_GEN( higemaru_interrupt )
2323{
2424   if (cpu_getiloops() == 0)
2525      cpunum_set_input_line_and_vector(0,0,HOLD_LINE,0xcf);   /* RST 08h */
src/mame/drivers/plygonet.c
r1293r1294
681681   GFXDECODE_ENTRY( REGION_GFX2, 0, bglayout,     0x0000, 64 )
682682GFXDECODE_END
683683
684MACHINE_DRIVER_START( plygonet )
684static MACHINE_DRIVER_START( plygonet )
685685   MDRV_CPU_ADD(M68EC020, 16000000)   /* 16 MHz (xtal is 32.0 MHz) */
686686   MDRV_CPU_PROGRAM_MAP(polygonet_map, 0)
687687   MDRV_CPU_VBLANK_INT(polygonet_interrupt, 2)
src/mame/drivers/afega.c
r1293r1294
10761076   irq_handler
10771077};
10781078
1079INTERRUPT_GEN( interrupt_afega )
1079static INTERRUPT_GEN( interrupt_afega )
10801080{
10811081   switch ( cpu_getiloops() )
10821082   {
r1293r1294
12121212MACHINE_DRIVER_END
12131213
12141214
1215INTERRUPT_GEN( interrupt_twinactn )
1215static INTERRUPT_GEN( interrupt_twinactn )
12161216{
12171217   switch ( cpu_getiloops() )
12181218   {
src/mame/drivers/naomi.c
r1293r1294
480480static MACHINE_DRIVER_START( naomi )
481481   /* basic machine hardware */
482482   MDRV_CPU_ADD_TAG("main", SH4, CPU_CLOCK) // SH4!!!
483   MDRV_CPU_CONFIG(sh4cpu_config);
483   MDRV_CPU_CONFIG(sh4cpu_config)
484484   MDRV_CPU_PROGRAM_MAP(naomi_map,0)
485485
486486   MDRV_CPU_ADD_TAG("sound", ARM7, 45000000)
src/mame/drivers/nemesis.c
r1293r1294
9191
9292
9393
94INTERRUPT_GEN( nemesis_interrupt )
94static INTERRUPT_GEN( nemesis_interrupt )
9595{
9696   if (irq_on)
9797      cpunum_set_input_line(0, 1, HOLD_LINE);
r1293r1294
108108
109109static int gx400_irq1_cnt;
110110
111INTERRUPT_GEN( konamigt_interrupt )
111static INTERRUPT_GEN( konamigt_interrupt )
112112{
113113   if (cpu_getiloops() == 0)
114114   {
r1293r1294
120120   }
121121}
122122
123INTERRUPT_GEN( gx400_interrupt )
123static INTERRUPT_GEN( gx400_interrupt )
124124{
125125   switch (cpu_getiloops())
126126   {
r1293r1294
177177
178178
179179
180INTERRUPT_GEN( salamand_interrupt )
180static INTERRUPT_GEN( salamand_interrupt )
181181{
182182   if (irq_on)
183183      cpunum_set_input_line(0, 1, HOLD_LINE);
184184}
185185
186INTERRUPT_GEN( blkpnthr_interrupt )
186static INTERRUPT_GEN( blkpnthr_interrupt )
187187{
188188   if (irq_on)
189189      cpunum_set_input_line(0, 2, HOLD_LINE);
r1293r1294
22472247   MDRV_CPU_PROGRAM_MAP(sal_sound_readmem,sal_sound_writemem)
22482248
22492249   MDRV_SCREEN_REFRESH_RATE((18432000.0/4)/(288*264))      /* 60.606060 Hz */
2250   MDRV_SCREEN_VBLANK_TIME(USEC_TO_SUBSECONDS((264-256)*125/2))
2250   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC((264-256)*125/2))
22512251
22522252   MDRV_MACHINE_RESET(nemesis)
22532253
src/mame/drivers/progolf.c
r1293r1294
209209//  MDRV_CPU_VBLANK_INT(nmi_line_pulse,16)
210210
211211   MDRV_SCREEN_REFRESH_RATE(57)
212   MDRV_SCREEN_VBLANK_TIME(USEC_TO_SUBSECONDS(3072))
212   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(3072))
213213
214214   /* video hardware */
215215   MDRV_VIDEO_ATTRIBUTES(VIDEO_TYPE_RASTER)
src/mame/drivers/magmax.c
r1293r1294
2626static UINT8 LS74_q   = 0;
2727static UINT8 gain_control = 0;
2828
29static mame_timer *interrupt_timer;
29static emu_timer *interrupt_timer;
3030
3131static WRITE16_HANDLER( magmax_sound_w )
3232{
r1293r1294
6868   scanline += 128;
6969   scanline &= 255;
7070
71   mame_timer_adjust(interrupt_timer, video_screen_get_time_until_pos(0, scanline, 0), scanline, time_zero);
71   timer_adjust(interrupt_timer, video_screen_get_time_until_pos(0, scanline, 0), scanline, attotime_zero);
7272}
7373
7474static MACHINE_START( magmax )
7575{
7676   /* Create interrupt timer */
77   interrupt_timer = mame_timer_alloc(scanline_callback);
77   interrupt_timer = timer_alloc(scanline_callback);
7878
7979   /* Set up save state */
8080   state_save_register_global(sound_latch);
r1293r1294
8585
8686static MACHINE_RESET( magmax )
8787{
88   mame_timer_adjust(interrupt_timer, video_screen_get_time_until_pos(0, 64, 0), 64, time_zero);
88   timer_adjust(interrupt_timer, video_screen_get_time_until_pos(0, 64, 0), 64, attotime_zero);
8989
9090#if 0
9191   {
src/mame/drivers/stv.c
r1293r1294
251251
252252UINT32* stv_workram_l;
253253UINT32* stv_workram_h;
254UINT32* stv_backupram;
254static UINT32* stv_backupram;
255255extern UINT32* stv_scu;
256256static UINT32* ioga;
257257static UINT16* scsp_regs;
r1293r1294
292292
293293
294294int minit_boost,sinit_boost;
295mame_time minit_boost_timeslice, sinit_boost_timeslice;
295attotime minit_boost_timeslice, sinit_boost_timeslice;
296296
297297static int scanline;
298298
r1293r1294
20492049static WRITE32_HANDLER( minit_w )
20502050{
20512051   logerror("cpu #%d (PC=%08X) MINIT write = %08x\n",cpu_getactivecpu(), activecpu_get_pc(),data);
2052   cpu_boost_interleave(minit_boost_timeslice, MAME_TIME_IN_USEC(minit_boost));
2052   cpu_boost_interleave(minit_boost_timeslice, ATTOTIME_IN_USEC(minit_boost));
20532053   cpu_trigger(1000);
20542054   cpunum_set_info_int(1, CPUINFO_INT_SH2_FRT_INPUT, PULSE_LINE);
20552055}
r1293r1294
20572057static WRITE32_HANDLER( sinit_w )
20582058{
20592059   logerror("cpu #%d (PC=%08X) SINIT write = %08x\n",cpu_getactivecpu(), activecpu_get_pc(),data);
2060   cpu_boost_interleave(sinit_boost_timeslice, MAME_TIME_IN_USEC(sinit_boost));
2060   cpu_boost_interleave(sinit_boost_timeslice, ATTOTIME_IN_USEC(sinit_boost));
20612061   cpunum_set_info_int(0, CPUINFO_INT_SH2_FRT_INPUT, PULSE_LINE);
20622062}
20632063
r1293r1294
24992499   /* amount of time to boost interleave for on MINIT / SINIT, needed for communication to work */
25002500   minit_boost = 400;
25012501   sinit_boost = 400;
2502   minit_boost_timeslice = time_zero;
2503   sinit_boost_timeslice = time_zero;
2502   minit_boost_timeslice = attotime_zero;
2503   sinit_boost_timeslice = attotime_zero;
25042504
25052505   smpc_ram = auto_malloc (0x80);
25062506   stv_scu = auto_malloc (0x100);
r1293r1294
27432743   MDRV_CPU_PROGRAM_MAP(sound_mem, 0)
27442744
27452745   MDRV_SCREEN_REFRESH_RATE(60)
2746   MDRV_SCREEN_VBLANK_TIME(USEC_TO_SUBSECONDS(192))   // guess, needed to force video update after V-Blank OUT interrupt
2746   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(192))   // guess, needed to force video update after V-Blank OUT interrupt
27472747
27482748   MDRV_MACHINE_START(stv)
27492749   MDRV_MACHINE_RESET(stv)
src/mame/drivers/megatech.c
r1293r1294
230230
231231/* MEGATECH specific */
232232
233UINT8 mt_cart_select_reg;
233static UINT8 mt_cart_select_reg;
234234
235235static READ8_HANDLER( megatech_instr_r )
236236{
r1293r1294
268268   printf("unmapped z80 write %04x\n",offset);
269269}
270270
271UINT8* sms_mainram;
272UINT8* sms_rom;
271static UINT8* sms_mainram;
272static UINT8* sms_rom;
273273
274274
275275static WRITE8_HANDLER( mt_sms_standard_rom_bank_w )
r1293r1294
314314
315315
316316
317void megatech_set_genz80_as_sms_standard_ports(void)
317static void megatech_set_genz80_as_sms_standard_ports(void)
318318{
319319   /* INIT THE PORTS *********************************************************************************************/
320320   memory_install_read8_handler (1, ADDRESS_SPACE_IO, 0x0000, 0xffff, 0, 0, z80_unmapped_port_r);
r1293r1294
339339   memory_install_read8_handler (1, ADDRESS_SPACE_IO, 0xdf, 0xdf, 0, 0, megatech_sms_ioport_dd_r); // adams family
340340}
341341
342void megatech_set_genz80_as_sms_standard_map(void)
342static void megatech_set_genz80_as_sms_standard_map(void)
343343{
344344   /* INIT THE MEMMAP / BANKING *********************************************************************************/
345345
r1293r1294
372372
373373}
374374
375void megatech_select_game(int gameno)
375static void megatech_select_game(int gameno)
376376{
377377   UINT8* game_region;
378378   UINT8* bios_region;
r1293r1294
603603   init_for_megadrive(); // create an sms vdp too, for comptibility mode
604604   video_start_megadriv(Machine);
605605}
606//time_never
606//attotime_never
607607static VIDEO_UPDATE(mtnew)
608608{
609609   if (screen ==0)
src/mame/drivers/igs_blit.c
r1293r1294
367367
368368***************************************************************************/
369369
370void grtwall_decrypt(void)
370static void grtwall_decrypt(void)
371371{
372372   int i;
373373   UINT16 *src = (UINT16 *) (memory_region(REGION_CPU1));
r1293r1294
391391}
392392
393393
394void lhb_decrypt(void)
394static void lhb_decrypt(void)
395395{
396396   int i;
397397   UINT16 *src = (UINT16 *) (memory_region(REGION_CPU1));
r1293r1294
416416}
417417
418418
419void chindrag_decrypt(void)
419static void chindrag_decrypt(void)
420420{
421421   int i;
422422   UINT16 *src = (UINT16 *) (memory_region(REGION_CPU1));
r1293r1294
445445}
446446
447447
448void drgnwrld_decrypt(void)
448static void drgnwrld_decrypt(void)
449449{
450450   int i;
451451   UINT16 *src = (UINT16 *) (memory_region(REGION_CPU1));
r1293r1294
474474}
475475
476476
477void chmplst2_decrypt(void)
477static void chmplst2_decrypt(void)
478478{
479479   int i,j;
480480   int rom_size = 0x80000;
r1293r1294
506506
507507
508508
509void vbowlj_decrypt(void)
509static void vbowlj_decrypt(void)
510510{
511511   int i;
512512   UINT16 *src = (UINT16 *) (memory_region(REGION_CPU1));
r1293r1294
540540}
541541
542542// To do:
543#ifdef UNUSED_FUNCTION
543544void vbowl_decrypt(void)
544545{
545546   int i;
r1293r1294
563564
564565//  vbowlj_decrypt();
565566}
567#endif
566568
567569
568570/***************************************************************************
r1293r1294
572574***************************************************************************/
573575
574576
575void chmplst2_decrypt_gfx(void)
577static void chmplst2_decrypt_gfx(void)
576578{
577579   int i;
578580   unsigned rom_size = 0x200000;
r1293r1294
587589   free(result_data);
588590}
589591
590void chindrag_gfx_decrypt(void)
592static void chindrag_gfx_decrypt(void)
591593{
592594   int i;
593595   unsigned rom_size = 0x400000;
src/mame/drivers/bishi.c
r1293r1294
270270   MDRV_CPU_VBLANK_INT(bishi_interrupt, 2)
271271
272272   MDRV_SCREEN_REFRESH_RATE(60)
273   MDRV_SCREEN_VBLANK_TIME(USEC_TO_SUBSECONDS(1200))
273   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(1200))
274274
275275   MDRV_MACHINE_START(bishi)
276276   MDRV_MACHINE_RESET(bishi)
src/mame/drivers/vamphalf.c
r1293r1294
513513GFXDECODE_END
514514
515515
516UINT8 suplup_default_nvram[128] = {
516static UINT8 suplup_default_nvram[128] = {
517517   0xE8, 0xFE, 0xFF, 0xFF, 0x10, 0x80, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x96, 0x2D, 0xB4, 0x80, 0x00,
518518   0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
519519   0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
r1293r1294
524524   0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xAA, 0xAA
525525};
526526
527UINT8 misncrft_default_nvram[128] = {
527static UINT8 misncrft_default_nvram[128] = {
528528   0x67, 0xBE, 0x00, 0x01, 0x80, 0xFE, 0x04, 0x10, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
529529   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
530530   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
r1293r1294
535535   0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xAA, 0xAA
536536};
537537
538NVRAM_HANDLER( 93C46_vamphalf )
538static NVRAM_HANDLER( 93C46_vamphalf )
539539{
540540   if (read_or_write)
541541      EEPROM_save(file);
src/mame/drivers/alg.c
r1293r1294
2727
2828
2929static laserdisc_info *discinfo;
30static mame_timer *serial_timer;
30static emu_timer *serial_timer;
3131static UINT8 serial_timer_active;
3232static UINT16 input_select;
3333
r1293r1294
145145static MACHINE_START( alg )
146146{
147147   discinfo = laserdisc_init(LASERDISC_TYPE_LDP1450, get_disk_handle(0), 1);
148   serial_timer = mame_timer_alloc(response_timer);
148   serial_timer = timer_alloc(response_timer);
149149   serial_timer_active = FALSE;
150150}
151151
r1293r1294
177177
178178   /* if there's more to come, set another timer */
179179   if (laserdisc_line_r(discinfo, LASERDISC_LINE_DATA_AVAIL) == ASSERT_LINE)
180      mame_timer_adjust(serial_timer, amiga_get_serial_char_period(), 0, time_zero);
180      timer_adjust(serial_timer, amiga_get_serial_char_period(), 0, attotime_zero);
181181   else
182182      serial_timer_active = FALSE;
183183}
r1293r1294
191191   /* if we have data available, set a timer to read it */
192192   if (!serial_timer_active && laserdisc_line_r(discinfo, LASERDISC_LINE_DATA_AVAIL) == ASSERT_LINE)
193193   {
194      mame_timer_adjust(serial_timer, amiga_get_serial_char_period(), 0, time_zero);
194      timer_adjust(serial_timer, amiga_get_serial_char_period(), 0, attotime_zero);
195195      serial_timer_active = TRUE;
196196   }
197197}
r1293r1294
205205   /* if we have data available, set a timer to read it */
206206   if (!serial_timer_active && laserdisc_line_r(discinfo, LASERDISC_LINE_DATA_AVAIL) == ASSERT_LINE)
207207   {
208      mame_timer_adjust(serial_timer, amiga_get_serial_char_period(), 0, time_zero);
208      timer_adjust(serial_timer, amiga_get_serial_char_period(), 0, attotime_zero);
209209      serial_timer_active = TRUE;
210210   }
211211}
r1293r1294
457457   MDRV_CPU_VBLANK_INT(amiga_scanline_callback, 262)
458458
459459   MDRV_SCREEN_REFRESH_RATE(59.97)
460   MDRV_SCREEN_VBLANK_TIME(USEC_TO_SUBSECONDS(0))
460   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(0))
461461
462462   MDRV_MACHINE_START(alg)
463463   MDRV_MACHINE_RESET(alg)
src/mame/drivers/galaxia.c
r1293r1294
2525
2626#include "driver.h"
2727
28UINT8 *galaxia_video;
28static UINT8 *galaxia_video;
2929
3030static VIDEO_START( galaxia )
3131{
src/mame/drivers/gridlee.c
r1293r1294
119119{
120120   /* next interrupt after scanline 256 is scanline 64 */
121121   if (param == 256)
122      mame_timer_set(video_screen_get_time_until_pos(0, 64, 0), 64, irq_timer);
122      timer_set(video_screen_get_time_until_pos(0, 64, 0), 64, irq_timer);
123123   else
124      mame_timer_set(video_screen_get_time_until_pos(0, param + 64, 0), param + 64, irq_timer);
124      timer_set(video_screen_get_time_until_pos(0, param + 64, 0), param + 64, irq_timer);
125125
126126   /* IRQ starts on scanline 0, 64, 128, etc. */
127127   cpunum_set_input_line(0, M6809_IRQ_LINE, ASSERT_LINE);
128128
129129   /* it will turn off on the next HBLANK */
130   mame_timer_set(video_screen_get_time_until_pos(0, param, BALSENTE_HBSTART), 0, irq_off);
130   timer_set(video_screen_get_time_until_pos(0, param, BALSENTE_HBSTART), 0, irq_off);
131131}
132132
133133
r1293r1294
140140static TIMER_CALLBACK( firq_timer )
141141{
142142   /* same time next frame */
143   mame_timer_set(video_screen_get_time_until_pos(0, FIRQ_SCANLINE, 0), 0, firq_timer);
143   timer_set(video_screen_get_time_until_pos(0, FIRQ_SCANLINE, 0), 0, firq_timer);
144144
145145   /* IRQ starts on scanline FIRQ_SCANLINE? */
146146   cpunum_set_input_line(0, M6809_FIRQ_LINE, ASSERT_LINE);
147147
148148   /* it will turn off on the next HBLANK */
149   mame_timer_set(video_screen_get_time_until_pos(0, FIRQ_SCANLINE, BALSENTE_HBSTART), 0, firq_off);
149   timer_set(video_screen_get_time_until_pos(0, FIRQ_SCANLINE, BALSENTE_HBSTART), 0, firq_off);
150150}
151151
152152
153153static MACHINE_RESET( gridlee )
154154{
155155   /* start timers to generate interrupts */
156   mame_timer_set(video_screen_get_time_until_pos(0, 0, 0), 0, irq_timer);
157   mame_timer_set(video_screen_get_time_until_pos(0, FIRQ_SCANLINE, 0), 0, firq_timer);
156   timer_set(video_screen_get_time_until_pos(0, 0, 0), 0, irq_timer);
157   timer_set(video_screen_get_time_until_pos(0, FIRQ_SCANLINE, 0), 0, firq_timer);
158158
159159   /* create the polynomial tables */
160160   poly17_init();
src/mame/drivers/trucocl.c
r1293r1294
8282
8383   DAC_data_w( 0, rom[dac_address+cur_dac_address_index] );
8484
85   mame_timer_set( MAME_TIME_IN_HZ( 16000 ), 0, dac_irq );
85   timer_set( ATTOTIME_IN_HZ( 16000 ), 0, dac_irq );
8686}
8787
8888static ADDRESS_MAP_START( readmem, ADDRESS_SPACE_PROGRAM, 8 )
src/mame/drivers/gcpinbal.c
r1293r1294
6464{
6565   /* Unsure of actual sequence */
6666
67   mame_timer_set(MAME_TIME_IN_CYCLES(500,0),0, gcpinbal_interrupt1);
68//  mame_timer_set(MAME_TIME_IN_CYCLES(1000,0),0, gcpinbal_interrupt3);
67   timer_set(ATTOTIME_IN_CYCLES(500,0),0, gcpinbal_interrupt1);
68//  timer_set(ATTOTIME_IN_CYCLES(1000,0),0, gcpinbal_interrupt3);
6969   cpunum_set_input_line(0, 4, HOLD_LINE);
7070}
7171
src/mame/drivers/arcadia.c
r1293r1294
294294   MDRV_CPU_VBLANK_INT(amiga_scanline_callback, 262)
295295
296296   MDRV_SCREEN_REFRESH_RATE(59.997)
297   MDRV_SCREEN_VBLANK_TIME(USEC_TO_SUBSECONDS(0))
297   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(0))
298298
299299   MDRV_MACHINE_RESET(amiga)
300300   MDRV_NVRAM_HANDLER(generic_0fill)
src/mame/drivers/segag80v.c
r1293r1294
451451   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNUSED )               /* P1.21 */
452452
453453   PORT_START_TAG("D3D2")
454   PORT_DIPNAME( 0x01, 0x01, DEF_STR( Unknown )) PORT_DIPLOCATION("SW1:8")
455   PORT_DIPSETTING(   0x01, DEF_STR( Off ))
456   PORT_DIPSETTING(   0x00, DEF_STR( On ))
457   PORT_DIPNAME( 0x02, 0x02, DEF_STR( Unknown )) PORT_DIPLOCATION("SW1:7")
458   PORT_DIPSETTING(   0x02, DEF_STR( Off ))
459   PORT_DIPSETTING(   0x00, DEF_STR( On ))
460   PORT_DIPNAME( 0x04, 0x04, DEF_STR( Unknown )) PORT_DIPLOCATION("SW1:6")
461   PORT_DIPSETTING(   0x04, DEF_STR( Off ))
462   PORT_DIPSETTING(   0x00, DEF_STR( On ))
463   PORT_DIPNAME( 0x08, 0x08, DEF_STR( Unknown )) PORT_DIPLOCATION("SW1:5")
464   PORT_DIPSETTING(   0x08, DEF_STR( Off ))
465   PORT_DIPSETTING(   0x00, DEF_STR( On ))
466   PORT_DIPNAME( 0x10, 0x01, DEF_STR( Unknown )) PORT_DIPLOCATION("SW1:4")
467   PORT_DIPSETTING(   0x01, DEF_STR( Off ))
468   PORT_DIPSETTING(   0x00, DEF_STR( On ))
469   PORT_DIPNAME( 0x20, 0x02, DEF_STR( Unknown )) PORT_DIPLOCATION("SW1:3")
470   PORT_DIPSETTING(   0x02, DEF_STR( Off ))
471   PORT_DIPSETTING(   0x00, DEF_STR( On ))
472   PORT_DIPNAME( 0x40, 0x04, DEF_STR( Unknown )) PORT_DIPLOCATION("SW1:2")
473   PORT_DIPSETTING(   0x04, DEF_STR( Off ))
474   PORT_DIPSETTING(   0x00, DEF_STR( On ))
475   PORT_DIPNAME( 0x80, 0x08, DEF_STR( Unknown )) PORT_DIPLOCATION("SW1:1")
476   PORT_DIPSETTING(   0x08, DEF_STR( Off ))
477   PORT_DIPSETTING(   0x00, DEF_STR( On ))
454   PORT_DIPUNKNOWN_DIPLOC( 0x01, 0x01, "SW1:8" )
455   PORT_DIPUNKNOWN_DIPLOC( 0x02, 0x02, "SW1:7" )
456   PORT_DIPUNKNOWN_DIPLOC( 0x04, 0x04, "SW1:6" )
457   PORT_DIPUNKNOWN_DIPLOC( 0x08, 0x08, "SW1:5" )
458   PORT_DIPUNKNOWN_DIPLOC( 0x10, 0x01, "SW1:4" )
459   PORT_DIPUNKNOWN_DIPLOC( 0x20, 0x02, "SW1:3" )
460   PORT_DIPUNKNOWN_DIPLOC( 0x40, 0x04, "SW1:2" )
461   PORT_DIPUNKNOWN_DIPLOC( 0x80, 0x08, "SW1:1" )
478462
479463   PORT_START_TAG("D1D0")
480464   PORT_DIPNAME( 0x0f, 0x03, DEF_STR( Coin_A )) PORT_DIPLOCATION("SW2:8,7,6,5")
r1293r1294
549533   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_PLAYER(2)
550534
551535   PORT_MODIFY("D3D2")
552   PORT_DIPNAME( 0x01, 0x01, DEF_STR( Cabinet )) PORT_DIPLOCATION("SW1:1")
553   PORT_DIPSETTING(   0x01, DEF_STR( Upright ))
536   PORT_DIPNAME( 0x01, 0x01, DEF_STR( Cabinet ))      PORT_DIPLOCATION("SW1:8")
537   PORT_DIPSETTING(   0x01, DEF_STR( Upright ))      // This switch is not documented in the manual
554538   PORT_DIPSETTING(   0x00, DEF_STR( Cocktail ))
555   PORT_DIPNAME( 0x0c, 0x04, DEF_STR( Lives )) PORT_DIPLOCATION("SW1:3,4")
539   PORT_DIPUNUSED_DIPLOC( 0x02, 0x02, "SW1:7" )      // Unused according to manual
540   PORT_DIPNAME( 0x0c, 0x04, DEF_STR( Lives ))         PORT_DIPLOCATION("SW1:6,5")
556541   PORT_DIPSETTING(   0x04, "3" )
557542   PORT_DIPSETTING(   0x08, "4" )
558543   PORT_DIPSETTING(   0x0c, "5" )
559   PORT_DIPNAME( 0x30, 0x00, DEF_STR( Difficulty )) PORT_DIPLOCATION("SW1:5,6")
560   PORT_DIPSETTING(   0x00, DEF_STR( Easy ))
561   PORT_DIPSETTING(   0x10, DEF_STR( Normal ))
544   PORT_DIPNAME( 0x30, 0x00, DEF_STR( Difficulty ))   PORT_DIPLOCATION("SW1:4,3")
545   PORT_DIPSETTING(   0x00, DEF_STR( Easy ))         // This option is not documented in the manual
546   PORT_DIPSETTING(   0x10, DEF_STR( Medium ))
562547   PORT_DIPSETTING(   0x20, DEF_STR( Hard ))
563   PORT_DIPSETTING(   0x30, DEF_STR( Very_Hard ))
564   PORT_DIPNAME( 0xc0, 0x40, DEF_STR( Bonus_Life )) PORT_DIPLOCATION("SW1:7,8")
548   PORT_DIPSETTING(   0x30, DEF_STR( Hardest ))
549   PORT_DIPNAME( 0xc0, 0x40, DEF_STR( Bonus_Life ))   PORT_DIPLOCATION("SW1:2,1")
565550   PORT_DIPSETTING(   0xc0, DEF_STR( None ))
566551   PORT_DIPSETTING(   0x80, "10000" )
567552   PORT_DIPSETTING(   0x40, "20000" )
r1293r1294
611596   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT )
612597
613598   PORT_MODIFY("D3D2")
614   PORT_DIPNAME( 0x01, 0x01, DEF_STR( Cabinet )) PORT_DIPLOCATION("SW1:1")
615   PORT_DIPSETTING(   0x01, DEF_STR( Upright ))
599   PORT_DIPNAME( 0x01, 0x01, DEF_STR( Cabinet ))      PORT_DIPLOCATION("SW1:8")
600   PORT_DIPSETTING(   0x01, DEF_STR( Upright ))      // This switch is not documented in the manual
616601   PORT_DIPSETTING(   0x00, DEF_STR( Cocktail ))
617   PORT_DIPNAME( 0x0c, 0x04, DEF_STR( Lives )) PORT_DIPLOCATION("SW1:3,4")
602   PORT_DIPUNUSED_DIPLOC( 0x02, 0x02, "SW1:7" )      // This switch is not documented in the manual
603   PORT_DIPNAME( 0x0c, 0x04, DEF_STR( Lives ))         PORT_DIPLOCATION("SW1:6,5")
618604   PORT_DIPSETTING(   0x04, "3" )
619605   PORT_DIPSETTING(   0x08, "4" )
620606   PORT_DIPSETTING(   0x0c, "5" )
621   PORT_DIPNAME( 0x30, 0x00, DEF_STR( Difficulty )) PORT_DIPLOCATION("SW1:5,6")
622   PORT_DIPSETTING(   0x00, DEF_STR( Easy ))
623   PORT_DIPSETTING(   0x10, DEF_STR( Normal ))
607   PORT_DIPNAME( 0x30, 0x00, DEF_STR( Difficulty ))   PORT_DIPLOCATION("SW1:4,3")
608   PORT_DIPSETTING(   0x00, DEF_STR( Easy ))         // This option is not documented in the manual
609   PORT_DIPSETTING(   0x10, DEF_STR( Medium ))
624610   PORT_DIPSETTING(   0x20, DEF_STR( Hard ))
625   PORT_DIPSETTING(   0x30, DEF_STR( Very_Hard ))
626   PORT_DIPNAME( 0xc0, 0x40, DEF_STR( Bonus_Life )) PORT_DIPLOCATION("SW1:7,8")
611   PORT_DIPSETTING(   0x30, DEF_STR( Hardest ))
612   PORT_DIPNAME( 0xc0, 0x40, DEF_STR( Bonus_Life ))   PORT_DIPLOCATION("SW1:2,1")
627613   PORT_DIPSETTING(   0xc0, DEF_STR( None ))
628614   PORT_DIPSETTING(   0x80, "10000" )
629615   PORT_DIPSETTING(   0x40, "20000" )
630616   PORT_DIPSETTING(   0x00, "30000" )
631617
632618   PORT_MODIFY("D1D0")
633   PORT_DIPNAME( 0x01, 0x01, DEF_STR( Unknown )) PORT_DIPLOCATION("SW2:1")
634   PORT_DIPSETTING(   0x01, DEF_STR( Off ))
635   PORT_DIPSETTING(   0x00, DEF_STR( On ))
636   PORT_DIPNAME( 0x02, 0x02, DEF_STR( Unknown )) PORT_DIPLOCATION("SW2:2")
637   PORT_DIPSETTING(   0x02, DEF_STR( Off ))
638   PORT_DIPSETTING(   0x00, DEF_STR( On ))
639   PORT_DIPNAME( 0x04, 0x04, DEF_STR( Unknown )) PORT_DIPLOCATION("SW2:3")
640   PORT_DIPSETTING(   0x04, DEF_STR( Off ))
641   PORT_DIPSETTING(   0x00, DEF_STR( On ))
642   PORT_DIPNAME( 0x08, 0x08, DEF_STR( Unknown )) PORT_DIPLOCATION("SW2:4")
643   PORT_DIPSETTING(   0x08, DEF_STR( Off ))
644   PORT_DIPSETTING(   0x00, DEF_STR( On ))
645   PORT_DIPNAME( 0x10, 0x10, DEF_STR( Unknown )) PORT_DIPLOCATION("SW2:5")
646   PORT_DIPSETTING(    0x00, DEF_STR( Off ))
647   PORT_DIPSETTING(    0x10, DEF_STR( On ))
648   PORT_DIPNAME( 0xe0, 0x00, DEF_STR( Coin_A )) PORT_DIPLOCATION("SW2:6,7,8")
619   PORT_DIPUNKNOWN_DIPLOC( 0x01, 0x01, "SW2:8" )
620   PORT_DIPUNKNOWN_DIPLOC( 0x02, 0x02, "SW2:7" )
621   PORT_DIPUNKNOWN_DIPLOC( 0x04, 0x04, "SW2:6" )
622   PORT_DIPUNKNOWN_DIPLOC( 0x08, 0x08, "SW2:5" )
623   PORT_DIPUNKNOWN_DIPLOC( 0x10, 0x10, "SW2:4" )
624   PORT_DIPNAME( 0xe0, 0x00, DEF_STR( Coin_A ))      PORT_DIPLOCATION("SW2:3,2,1")
649625   PORT_DIPSETTING(   0xe0, DEF_STR( 8C_1C ))
650626   PORT_DIPSETTING(   0xc0, DEF_STR( 7C_1C ))
651627   PORT_DIPSETTING(   0xa0, DEF_STR( 6C_1C ))
r1293r1294
686662   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_BUTTON2 )
687663
688664   PORT_MODIFY("D3D2")
689   PORT_DIPNAME( 0x01, 0x01, DEF_STR( Cabinet )) PORT_DIPLOCATION("SW1:1")
665   PORT_DIPNAME( 0x01, 0x01, DEF_STR( Cabinet ))      PORT_DIPLOCATION("SW1:8")
690666   PORT_DIPSETTING(   0x01, DEF_STR( Upright ))
691667   PORT_DIPSETTING(   0x00, DEF_STR( Cocktail ))
692   PORT_DIPNAME( 0x02, 0x00, DEF_STR( Demo_Sounds )) PORT_DIPLOCATION("SW1:2")
668   PORT_DIPNAME( 0x02, 0x00, DEF_STR( Demo_Sounds ))   PORT_DIPLOCATION("SW1:7")
693669   PORT_DIPSETTING(   0x02, DEF_STR( Off ))
694670   PORT_DIPSETTING(   0x00, DEF_STR( On ))
695   PORT_DIPNAME( 0x0c, 0x0c, DEF_STR( Lives )) PORT_DIPLOCATION("SW1:3,4")
671   PORT_DIPNAME( 0x0c, 0x0c, DEF_STR( Lives ))         PORT_DIPLOCATION("SW1:6,5")
696672   PORT_DIPSETTING(   0x00, "2" )
697673   PORT_DIPSETTING(   0x04, "3" )
698674   PORT_DIPSETTING(   0x08, "4" )
699675   PORT_DIPSETTING(   0x0c, "5" )
700   PORT_DIPNAME( 0x30, 0x00, DEF_STR( Difficulty )) PORT_DIPLOCATION("SW1:5,6")
676   PORT_DIPNAME( 0x30, 0x00, DEF_STR( Difficulty ))   PORT_DIPLOCATION("SW1:4,3")
701677   PORT_DIPSETTING(   0x00, DEF_STR( Easy ))
702   PORT_DIPSETTING(   0x10, DEF_STR( Normal ))
678   PORT_DIPSETTING(   0x10, DEF_STR( Medium ))
703679   PORT_DIPSETTING(   0x20, DEF_STR( Hard ))
704   PORT_DIPSETTING(   0x30, DEF_STR( Very_Hard ))
705   PORT_DIPNAME( 0xc0, 0x80, DEF_STR( Bonus_Life )) PORT_DIPLOCATION("SW1:7,8")
680   PORT_DIPSETTING(   0x30, DEF_STR( Hardest ))
681   PORT_DIPNAME( 0xc0, 0x80, DEF_STR( Bonus_Life ))   PORT_DIPLOCATION("SW1:2,1")
706682   PORT_DIPSETTING(   0x00, "10000" )
707683   PORT_DIPSETTING(   0x40, "20000" )
708684   PORT_DIPSETTING(   0x80, "30000" )
r1293r1294
720696   PORT_INCLUDE( g80v_generic )
721697
722698   PORT_MODIFY("D3D2")
723   PORT_DIPNAME( 0x01, 0x01, DEF_STR( Cabinet )) PORT_DIPLOCATION("SW1:1")
699   PORT_DIPNAME( 0x01, 0x01, DEF_STR( Cabinet ))      PORT_DIPLOCATION("SW1:8")
724700   PORT_DIPSETTING(   0x01, DEF_STR( Upright ))
725701   PORT_DIPSETTING(   0x00, DEF_STR( Cocktail ))
726   PORT_DIPNAME( 0x02, 0x00, DEF_STR( Demo_Sounds )) PORT_DIPLOCATION("SW1:2")
702   PORT_DIPNAME( 0x02, 0x00, DEF_STR( Demo_Sounds ))   PORT_DIPLOCATION("SW1:7")
727703   PORT_DIPSETTING(   0x02, DEF_STR( Off ))
728704   PORT_DIPSETTING(   0x00, DEF_STR( On ))
729   PORT_DIPNAME( 0x0c, 0x0c, DEF_STR( Lives )) PORT_DIPLOCATION("SW1:3,4")
705   PORT_DIPNAME( 0x0c, 0x0c, DEF_STR( Lives ))         PORT_DIPLOCATION("SW1:6,5")
730706   PORT_DIPSETTING(   0x00, "2" )
731707   PORT_DIPSETTING(   0x04, "3" )
732708   PORT_DIPSETTING(   0x08, "4" )
733709   PORT_DIPSETTING(   0x0c, "5" )
734   PORT_DIPNAME( 0x30, 0x00, DEF_STR( Difficulty )) PORT_DIPLOCATION("SW1:5,6")
710   PORT_DIPNAME( 0x30, 0x00, DEF_STR( Difficulty ))   PORT_DIPLOCATION("SW1:4,3")
735711   PORT_DIPSETTING(   0x00, DEF_STR( Easy ))
736   PORT_DIPSETTING(   0x10, DEF_STR( Normal ))
712   PORT_DIPSETTING(   0x10, DEF_STR( Medium ))
737713   PORT_DIPSETTING(   0x20, DEF_STR( Hard ))
738   PORT_DIPSETTING(   0x30, DEF_STR( Very_Hard ))
739   PORT_DIPNAME( 0xc0, 0x80, DEF_STR( Bonus_Life )) PORT_DIPLOCATION("SW1:7,8")
740   PORT_DIPSETTING(   0x00, DEF_STR( None ))
714   PORT_DIPSETTING(   0x30, DEF_STR( Hardest ))
715   PORT_DIPNAME( 0xc0, 0x80, DEF_STR( Bonus_Life ))   PORT_DIPLOCATION("SW1:2,1")
716   PORT_DIPSETTING(   0x00, DEF_STR( None ))         // These switches are not documented in the manual
741717   PORT_DIPSETTING(   0xc0, "10000" )
742718   PORT_DIPSETTING(   0x80, "20000" )
743719   PORT_DIPSETTING(   0x40, "30000" )
r1293r1294
757733   PORT_INCLUDE( g80v_generic )
758734
759735   PORT_MODIFY("D3D2")
760   PORT_DIPNAME( 0x01, 0x01, DEF_STR( Cabinet )) PORT_DIPLOCATION("SW1:1")
736   PORT_DIPNAME( 0x01, 0x01, DEF_STR( Cabinet ))      PORT_DIPLOCATION("SW1:8")
761737   PORT_DIPSETTING(   0x01, DEF_STR( Upright ))
762738   PORT_DIPSETTING(   0x00, DEF_STR( Cocktail ))
763   PORT_DIPNAME( 0x02, 0x00, DEF_STR( Demo_Sounds )) PORT_DIPLOCATION("SW1:2")
764   PORT_DIPSETTING(   0x02, DEF_STR( Off ))
739   PORT_DIPNAME( 0x02, 0x00, DEF_STR( Demo_Sounds ))   PORT_DIPLOCATION("SW1:7")
740   PORT_DIPSETTING(   0x02, DEF_STR( Off ))         // This switch isn't documented in the manual
765741   PORT_DIPSETTING(   0x00, DEF_STR( On ))
766   PORT_DIPNAME( 0x0c, 0x0c, "Number of Ships" ) PORT_DIPLOCATION("SW1:3,4")
742   PORT_DIPNAME( 0x0c, 0x0c, "Number of Ships" )      PORT_DIPLOCATION("SW1:6,5")
767743   PORT_DIPSETTING(   0x00, "2" )
768744   PORT_DIPSETTING(   0x04, "4" )
769745   PORT_DIPSETTING(   0x08, "6" )
770746   PORT_DIPSETTING(   0x0c, "8" )
771   PORT_DIPNAME( 0x30, 0x00, DEF_STR( Difficulty )) PORT_DIPLOCATION("SW1:5,6")
747   PORT_DIPNAME( 0x30, 0x00, DEF_STR( Difficulty ))   PORT_DIPLOCATION("SW1:4,3")
772748   PORT_DIPSETTING(   0x00, DEF_STR( Easy ))
773749   PORT_DIPSETTING(   0x10, DEF_STR( Normal ))
774   PORT_DIPSETTING(   0x20, DEF_STR( Hard ))
750   PORT_DIPSETTING(   0x20, DEF_STR( Hard ))         // This option isn't documented in the manual
775751   PORT_DIPSETTING(   0x30, DEF_STR( Very_Hard ))
776   PORT_DIPNAME( 0xc0, 0x80, DEF_STR( Bonus_Life )) PORT_DIPLOCATION("SW1:7,8")
752   PORT_DIPNAME( 0xc0, 0x80, DEF_STR( Bonus_Life ))   PORT_DIPLOCATION("SW1:2,1")
777753   PORT_DIPSETTING(   0x00, DEF_STR( None ))
778754   PORT_DIPSETTING(   0xc0, "10000" )
779755   PORT_DIPSETTING(   0x80, "20000" )
r1293r1294
794770   PORT_INCLUDE( g80v_generic )
795771
796772   PORT_MODIFY("D3D2")
797   PORT_DIPNAME( 0x01, 0x01, DEF_STR( Cabinet )) PORT_DIPLOCATION("SW1:1")
798   PORT_DIPSETTING(   0x01, DEF_STR( Upright ))
773   PORT_DIPNAME( 0x01, 0x01, DEF_STR( Cabinet ))      PORT_DIPLOCATION("SW1:8")
774   PORT_DIPSETTING(   0x01, DEF_STR( Upright ))      // This switch isn't documented in the manual
799775   PORT_DIPSETTING(   0x00, DEF_STR( Cocktail ))
800   PORT_DIPNAME( 0x02, 0x00, DEF_STR( Demo_Sounds )) PORT_DIPLOCATION("SW1:2")
776   PORT_DIPNAME( 0x02, 0x00, DEF_STR( Demo_Sounds ))   PORT_DIPLOCATION("SW1:7")
801777   PORT_DIPSETTING(   0x02, DEF_STR( Off ))
802778   PORT_DIPSETTING(   0x00, DEF_STR( On ))
803   PORT_DIPNAME( 0x0c, 0x0c, "Photon Torpedoes" ) PORT_DIPLOCATION("SW1:3,4")
779   PORT_DIPNAME( 0x0c, 0x0c, "Photon Torpedoes" )      PORT_DIPLOCATION("SW1:6,5")
804780   PORT_DIPSETTING(   0x00, "1" )
805781   PORT_DIPSETTING(   0x04, "2" )
806782   PORT_DIPSETTING(   0x08, "3" )
807783   PORT_DIPSETTING(   0x0c, "4" )
808   PORT_DIPNAME( 0x30, 0x00, DEF_STR( Difficulty )) PORT_DIPLOCATION("SW1:5,6")
784   PORT_DIPNAME( 0x30, 0x00, DEF_STR( Difficulty ))   PORT_DIPLOCATION("SW1:4,3")
809785   PORT_DIPSETTING(   0x00, DEF_STR( Easy ))
810   PORT_DIPSETTING(   0x10, DEF_STR( Normal ))
786   PORT_DIPSETTING(   0x10, DEF_STR( Medium ))
811787   PORT_DIPSETTING(   0x20, DEF_STR( Hard ))
812788   PORT_DIPSETTING(   0x30, "Tournament" )
813   PORT_DIPNAME( 0xc0, 0x80, DEF_STR( Bonus_Life )) PORT_DIPLOCATION("SW1:7,8")
789   PORT_DIPNAME( 0xc0, 0x80, DEF_STR( Bonus_Life ))   PORT_DIPLOCATION("SW1:2,1")
814790   PORT_DIPSETTING(   0x00, "10000" )
815791   PORT_DIPSETTING(   0x40, "20000" )
816792   PORT_DIPSETTING(   0x80, "30000" )
src/mame/drivers/vmetal.c
r1293r1294
7979#include "sound/okim6295.h"
8080#include "sound/es8712.h"
8181
82UINT16 *vmetal_texttileram;
83UINT16 *vmetal_mid1tileram;
84UINT16 *vmetal_mid2tileram;
85UINT16 *vmetal_tlookup;
86UINT16 *vmetal_videoregs;
82static UINT16 *vmetal_texttileram;
83static UINT16 *vmetal_mid1tileram;
84static UINT16 *vmetal_mid2tileram;
85static UINT16 *vmetal_tlookup;
86static UINT16 *vmetal_videoregs;
8787
8888
8989static tilemap *vmetal_texttilemap;
src/mame/drivers/dreamwld.c
r1293r1294
4242#define MASTER_CLOCK 32000000
4343
4444
45UINT32*dreamwld_bg_videoram;
46UINT32*dreamwld_bg2_videoram;
47UINT32*dreamwld_bg_scroll;
48int dreamwld_tilebank[2], dreamwld_tilebankold[2];
45static UINT32*dreamwld_bg_videoram;
46static UINT32*dreamwld_bg2_videoram;
47static UINT32*dreamwld_bg_scroll;
48static int dreamwld_tilebank[2], dreamwld_tilebankold[2];
4949
5050static tilemap *dreamwld_bg_tilemap;
5151static tilemap *dreamwld_bg2_tilemap;
src/mame/drivers/xain.c
r1293r1294
174174   /* so let's resync every time they are changed to avoid deadlocks */
175175   if ((offset == 0x003d || offset == 0x003e)
176176         && xain_sharedram[offset] != data)
177      cpu_boost_interleave(time_zero, MAME_TIME_IN_USEC(20));
177      cpu_boost_interleave(attotime_zero, ATTOTIME_IN_USEC(20));
178178   xain_sharedram[offset] = data;
179179}
180180
src/mame/drivers/mrdo.c
r1293r1294
181181   MDRV_CPU_VBLANK_INT(irq0_line_hold,1)
182182
183183   MDRV_SCREEN_REFRESH_RATE(5000000.0/312/262)
184   MDRV_SCREEN_VBLANK_TIME(USEC_TO_SUBSECONDS(4368))
184   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(4368))
185185
186186   /* video hardware */
187187   MDRV_VIDEO_ATTRIBUTES(VIDEO_TYPE_RASTER)
src/mame/drivers/m62.c
r1293r1294
13661366   MDRV_CPU_VBLANK_INT(irq0_line_hold,1)
13671367
13681368   MDRV_SCREEN_REFRESH_RATE(55)
1369   MDRV_SCREEN_VBLANK_TIME(USEC_TO_SUBSECONDS(1790) /* frames per second and vblank duration from the Lode Runner manual */)
1369   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(1790) /* frames per second and vblank duration from the Lode Runner manual */)
13701370
13711371   /* video hardware */
13721372   MDRV_VIDEO_ATTRIBUTES(VIDEO_TYPE_RASTER)
src/mame/drivers/deco156.c
r1293r1294
428428   MDRV_CPU_VBLANK_INT(deco32_vbl_interrupt,1)
429429
430430   MDRV_SCREEN_REFRESH_RATE(58)
431   MDRV_SCREEN_VBLANK_TIME(USEC_TO_SUBSECONDS(529))
431   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(529))
432432   MDRV_NVRAM_HANDLER(93C46)
433433
434434   /* video hardware */
r1293r1294
464464   MDRV_CPU_VBLANK_INT(deco32_vbl_interrupt,1)
465465
466466   MDRV_SCREEN_REFRESH_RATE(58)
467   MDRV_SCREEN_VBLANK_TIME(USEC_TO_SUBSECONDS(529))
467   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(529))
468468   MDRV_NVRAM_HANDLER(93C46)
469469
470470   /* video hardware */
src/mame/drivers/dwarfd.c
r1293r1294
128128   I8275_COMMAND_LOAD_CURSOR_LENGTH=2,
129129   I8275_COMMAND_PRESET_LENGTH=0
130130};
131int i8275Command;
132int i8275HorizontalCharactersRow;
133int i8275CommandSeqCnt;
134int i8275SpacedRows;
135int i8275VerticalRows;
136int i8275VerticalRetraceRows;
137int i8275Underline;
138int i8275Lines;
139int i8275LineCounterMode;
140int i8275FieldAttributeMode;
141int i8275CursorFormat;
142int i8275HorizontalRetrace;
131static int i8275Command;
132static int i8275HorizontalCharactersRow;
133static int i8275CommandSeqCnt;
134static int i8275SpacedRows;
135static int i8275VerticalRows;
136static int i8275VerticalRetraceRows;
137static int i8275Underline;
138static int i8275Lines;
139static int i8275LineCounterMode;
140static int i8275FieldAttributeMode;
141static int i8275CursorFormat;
142static int i8275HorizontalRetrace;
143143
144144static WRITE8_HANDLER (i8275_preg_w) //param reg
145145{
r1293r1294
540540}
541541
542542#define NUM_LINES 25
543INTERRUPT_GEN( dwarfd_interrupt )
543static INTERRUPT_GEN( dwarfd_interrupt )
544544{
545545   if(cpu_getiloops() < NUM_LINES)
546546   {
src/mame/drivers/renegade.c
r1293r1294
164164   }
165165}
166166
167void *renegade_adpcm_start(int clock, const struct CustomSound_interface *config)
167static void *renegade_adpcm_start(int clock, const struct CustomSound_interface *config)
168168{
169169   struct renegade_adpcm_state *state = &renegade_adpcm;
170170   state->playing = 0;
src/mame/drivers/psychic5.c
r1293r1294
358358   }
359359}
360360
361INTERRUPT_GEN( psychic5_interrupt )
361static INTERRUPT_GEN( psychic5_interrupt )
362362{
363363   if (cpu_getiloops() == 0)
364364      cpunum_set_input_line_and_vector(0, 0, HOLD_LINE, 0xd7);      /* RST 10h */
src/mame/drivers/othunder.c
r1293r1294
430430       The ADC60808 clock is 512kHz. Conversion takes between 0 and 8 clock
431431       cycles, so would end in a maximum of 15.625us. We'll use 10. */
432432
433   mame_timer_set(MAME_TIME_IN_USEC(10),0, ad_interrupt);
433   timer_set(ATTOTIME_IN_USEC(10),0, ad_interrupt);
434434}
435435
436436
src/mame/drivers/ginganin.c
r1293r1294
311311
312312
313313/* Modified by Takahiro Nogi. 1999/09/27 */
314INTERRUPT_GEN( ginganin_sound_interrupt )
314static INTERRUPT_GEN( ginganin_sound_interrupt )
315315{
316316   /* MC6840 Emulation by Takahiro Nogi. 1999/09/27
317317    (This routine hasn't been completed yet.) */
src/mame/drivers/slapshot.c
r1293r1294
187187
188188static INTERRUPT_GEN( slapshot_interrupt )
189189{
190   mame_timer_set(MAME_TIME_IN_CYCLES(200000-500,0),0, slapshot_interrupt6);
190   timer_set(ATTOTIME_IN_CYCLES(200000-500,0),0, slapshot_interrupt6);
191191   cpunum_set_input_line(0,5,HOLD_LINE);
192192}
193193
src/mame/drivers/ertictac.c
r1293r1294
161161
162162static void startTimer(void)
163163{
164   mame_timer_set(MAME_TIME_IN_USEC( ((T1low&0xff)|((T1high&0xff)<<8))>>4), 0, ertictacTimer);
164   timer_set(ATTOTIME_IN_USEC( ((T1low&0xff)|((T1high&0xff)<<8))>>4), 0, ertictacTimer);
165165}
166166
167167static WRITE32_HANDLER(T1GO_w)
src/mame/drivers/cninja.c
r1293r1294
4444#include "sound/okim6295.h"
4545
4646static int cninja_scanline, cninja_irq_mask;
47static mame_timer *raster_irq_timer;
47static emu_timer *raster_irq_timer;
4848static UINT16 *cninja_ram;
4949
5050/**********************************************************************************/
r1293r1294
7777   deco16_raster_display_list[deco16_raster_display_position++]=deco16_pf34_control[4]&0xffff;
7878
7979   cpunum_set_input_line(0, (cninja_irq_mask&0x10) ? 3 : 4, ASSERT_LINE);
80   mame_timer_adjust(raster_irq_timer,time_never,0,time_zero);
80   timer_adjust(raster_irq_timer,attotime_never,0,attotime_zero);
8181}
8282
8383static READ16_HANDLER( cninja_irq_r )
r1293r1294
113113   case 1: /* Raster IRQ scanline position, only valid for values between 1 & 239 (0 and 240-256 do NOT generate IRQ's) */
114114      cninja_scanline=data&0xff;
115115      if ((cninja_irq_mask&0x2)==0 && cninja_scanline>0 && cninja_scanline<240)
116         mame_timer_adjust(raster_irq_timer, video_screen_get_time_until_pos(0, cninja_scanline, 0), cninja_scanline, time_never);
116         timer_adjust(raster_irq_timer, video_screen_get_time_until_pos(0, cninja_scanline, 0), cninja_scanline, attotime_never);
117117      else
118         mame_timer_adjust(raster_irq_timer,time_never,0,time_zero);
118         timer_adjust(raster_irq_timer,attotime_never,0,attotime_zero);
119119      return;
120120
121121   case 2: /* VBL irq ack */
r1293r1294
825825
826826static MACHINE_RESET( cninja )
827827{
828   raster_irq_timer = mame_timer_alloc(interrupt_gen);
828   raster_irq_timer = timer_alloc(interrupt_gen);
829829   cninja_scanline=0;
830830   cninja_irq_mask=0;
831831}
src/mame/drivers/mirage.c
r1293r1294
353353   MDRV_CPU_VBLANK_INT(irq6_line_hold,1)
354354
355355   MDRV_SCREEN_REFRESH_RATE(58)
356   MDRV_SCREEN_VBLANK_TIME(USEC_TO_SUBSECONDS(529))
356   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(529))
357357
358358   /* video hardware */
359359   MDRV_VIDEO_ATTRIBUTES(VIDEO_TYPE_RASTER)
src/mame/drivers/missile.c
r1293r1294
261261
262262static const UINT8 *writeprom;
263263
264static mame_timer *irq_timer;
265static mame_timer *cpu_timer;
264static emu_timer *irq_timer;
265static emu_timer *cpu_timer;
266266
267267static UINT8 irq_state;
268268static UINT8 ctrld;
r1293r1294
305305      curv = ((curv + 32) & 0xff) & ~0x10;
306306
307307   /* next one at the start of this scanline */
308   mame_timer_adjust(irq_timer, video_screen_get_time_until_pos(0, v_to_scanline(curv), 0), curv, time_zero);
308   timer_adjust(irq_timer, video_screen_get_time_until_pos(0, v_to_scanline(curv), 0), curv, attotime_zero);
309309}
310310
311311
r1293r1294
351351
352352   /* scanline for the next run */
353353   curv ^= 224;
354   mame_timer_adjust(cpu_timer, video_screen_get_time_until_pos(0, v_to_scanline(curv), 0), curv, time_zero);
354   timer_adjust(cpu_timer, video_screen_get_time_until_pos(0, v_to_scanline(curv), 0), curv, attotime_zero);
355355}
356356
357357
r1293r1294
391391   opcode_base = opcode_arg_base = videoram;
392392
393393   /* create a timer to speed/slow the CPU */
394   cpu_timer = mame_timer_alloc(adjust_cpu_speed);
395   mame_timer_adjust(cpu_timer, video_screen_get_time_until_pos(0, v_to_scanline(0), 0), 0, time_zero);
394   cpu_timer = timer_alloc(adjust_cpu_speed);
395   timer_adjust(cpu_timer, video_screen_get_time_until_pos(0, v_to_scanline(0), 0), 0, attotime_zero);
396396
397397   /* create a timer for IRQs and set up the first callback */
398   irq_timer = mame_timer_alloc(clock_irq);
398   irq_timer = timer_alloc(clock_irq);
399399   irq_state = 0;
400400   schedule_next_irq(-32);
401401
src/mame/drivers/jack.c
r1293r1294
911911   MDRV_CPU_VBLANK_INT(irq0_line_hold,2) /* tripool needs 2 or the palette is broken */
912912MACHINE_DRIVER_END
913913
914INTERRUPT_GEN( joinem_interrupts )
914static INTERRUPT_GEN( joinem_interrupts )
915915{
916916   if(cpu_getiloops() > 0)
917917   {
src/mame/drivers/tumblep.c
r1293r1294
327327   MDRV_CPU_PROGRAM_MAP(sound_readmem,sound_writemem)
328328
329329   MDRV_SCREEN_REFRESH_RATE(58)
330   MDRV_SCREEN_VBLANK_TIME(USEC_TO_SUBSECONDS(529))
330   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(529))
331331
332332   /* video hardware */
333333   MDRV_VIDEO_ATTRIBUTES(VIDEO_TYPE_RASTER)
r1293r1294
396396
397397/******************************************************************************/
398398
399#if TUMBLEP_HACK
399400void tumblep_patch_code(UINT16 offset)
400401{
401402   /* A hack which enables all Dip Switches effects */
r1293r1294
403404   RAM[(offset + 0)/2] = 0x0240;
404405   RAM[(offset + 2)/2] = 0xffff;   // andi.w  #$f3ff, D0
405406}
407#endif
406408
407409static DRIVER_INIT( tumblep )
408410{
src/mame/drivers/canyon.c
r1293r1294
245245   MDRV_WATCHDOG_VBLANK_INIT(8)
246246
247247   MDRV_SCREEN_REFRESH_RATE(60)
248   MDRV_SCREEN_VBLANK_TIME(USEC_TO_SUBSECONDS(22 * 1000000 / 15750))
248   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(22 * 1000000 / 15750))
249249
250250   /* video hardware */
251251   MDRV_VIDEO_ATTRIBUTES(VIDEO_TYPE_RASTER)
src/mame/drivers/splash.c
r1293r1294
5454extern UINT16 *splash_spriteram;
5555extern UINT16 *splash_pixelram;
5656extern UINT16 *roldfrog_bitmap_mode;
57UINT16 *roldfrog_protdata;
57static UINT16 *roldfrog_protdata;
5858
5959extern int splash_bitmap_type;
6060extern int splash_sprite_attr2_shift;
r1293r1294
8181   }
8282
8383   // give the z80 time to see it
84   cpu_spinuntil_time(MAME_TIME_IN_USEC(40));
84   cpu_spinuntil_time(ATTOTIME_IN_USEC(40));
8585}
8686
8787static ADDRESS_MAP_START( splash_readmem, ADDRESS_SPACE_PROGRAM, 16 )
src/mame/drivers/tecmosys.c
r1293r1294
660660   ROM[0x044A/2] = 0x4E71;
661661   ROM[0x04bc/2] = 0x0000;
662662   ROM[0x302c/2] = 0x60a4;
663   mame_timer_set(MAME_TIME_IN_SEC(2),0,reset_callback);
663   timer_set(ATTOTIME_IN_SEC(2),0,reset_callback);
664664   gametype=0;
665665}
666666
r1293r1294
682682   ROM[0x04822/2] = 0x4E71;
683683   ROM[0x04862/2] = 0x4E71;
684684
685   mame_timer_set(MAME_TIME_IN_SEC(2),0,reset_callback);
685   timer_set(ATTOTIME_IN_SEC(2),0,reset_callback);
686686   gametype=1;
687687
688688}
src/mame/drivers/polyplay.c
r1293r1294
107107
108108/* timer handling */
109109static TIMER_CALLBACK( timer_callback );
110static mame_timer* polyplay_timer;
110static emu_timer* polyplay_timer;
111111static WRITE8_HANDLER( polyplay_start_timer2 );
112112static WRITE8_HANDLER( polyplay_sound_channel );
113113
r1293r1294
133133   polyplay_set_channel2(0);
134134   polyplay_play_channel2(0);
135135
136   polyplay_timer = mame_timer_alloc(timer_callback);
136   polyplay_timer = timer_alloc(timer_callback);
137137}
138138
139139
r1293r1294
248248static WRITE8_HANDLER( polyplay_start_timer2 )
249249{
250250   if (data == 0x03)
251      mame_timer_adjust(polyplay_timer, time_never, 0, time_never);
251      timer_adjust(polyplay_timer, attotime_never, 0, attotime_never);
252252
253253   if (data == 0xb5)
254      mame_timer_adjust(polyplay_timer, MAME_TIME_IN_HZ(40), 0, MAME_TIME_IN_HZ(40));
254      timer_adjust(polyplay_timer, ATTOTIME_IN_HZ(40), 0, ATTOTIME_IN_HZ(40));
255255}
256256
257257static READ8_HANDLER( polyplay_random_read )
src/mame/drivers/tx1.c
r1293r1294
6666static int TS, z80_int = 0;
6767
6868UINT16 *tx1_vram;
69UINT16 *tx1_object_ram;
69static UINT16 *tx1_object_ram;
7070
7171UINT16 *buggyboy_vram;   /* Tile RAM (three monitor)   */
7272UINT16 *buggyb1_vram;   /* Tile RAM (single monitor)  */
7373static UINT8 *z80_ram;   /* Main 8086/Z80 shared RAM   */
7474UINT16 *bb_objram;
7575UINT16 *bb_sky;      /* Sky register */
76UINT16 *bb_rcram;
76static UINT16 *bb_rcram;
7777
78size_t tx1_objectram_size;
78static size_t tx1_objectram_size;
7979size_t bb_objectram_size;
80size_t bb_rcram_size;
80static size_t bb_rcram_size;
8181
8282tilemap *tx1_tilemap;
8383tilemap *buggyboy_tilemap;
r1293r1294
904904   MDRV_CPU_ADD(I8086,5000000 )
905905   MDRV_CPU_PROGRAM_MAP(tx1_master,0)
906906   MDRV_CPU_PERIODIC_INT(main_irq, 46 )        /* To do: measure HD46505 CUDISP output rate */
907   //MDRV_WATCHDOG_TIME_INIT(MAME_TIME_IN_SEC(5))  /* To do: measure watchdog time interval */
907   //MDRV_WATCHDOG_TIME_INIT(ATTOTIME_IN_SEC(5))  /* To do: measure watchdog time interval */
908908
909909   MDRV_CPU_ADD(I8086,5000000 )
910910   MDRV_CPU_PROGRAM_MAP(tx1_slave,0)
r1293r1294
957957   MDRV_CPU_ADD(I8086,5000000 )
958958   MDRV_CPU_PROGRAM_MAP(buggyboy_master,0)
959959   MDRV_CPU_PERIODIC_INT(main_irq, 46 )    /* To do: measure HD46505 CUDISP output rate */
960   //MDRV_WATCHDOG_TIME_INIT(MAME_TIME_IN_SEC(5))  /* To do: measure watchdog time interval */
960   //MDRV_WATCHDOG_TIME_INIT(ATTOTIME_IN_SEC(5))  /* To do: measure watchdog time interval */
961961
962962   MDRV_CPU_ADD(I8086,5000000 )
963963   MDRV_CPU_PROGRAM_MAP(buggyboy_slave,0)
r1293r1294
10201020   MDRV_CPU_ADD(I8086,5000000 )
10211021   MDRV_CPU_PROGRAM_MAP(buggyb1_master,0)
10221022   MDRV_CPU_PERIODIC_INT(main_irq, 46 )    /* To do: measure HD46505 CUDISP output rate */
1023   //MDRV_WATCHDOG_TIME_INIT(MAME_TIME_IN_SEC(5))  /* To do: measure watchdog time interval */
1023   //MDRV_WATCHDOG_TIME_INIT(ATTOTIME_IN_SEC(5))  /* To do: measure watchdog time interval */
10241024
10251025   MDRV_CPU_ADD(I8086,5000000 )
10261026   MDRV_CPU_PROGRAM_MAP(buggyboy_slave,0)
src/mame/drivers/thayers.c
r1293r1294
343343   AM_RANGE(COP400_PORT_G,  COP400_PORT_G)   AM_READWRITE(cop_g_read,cop_g_write)
344344   AM_RANGE(COP400_PORT_D,  COP400_PORT_D)   AM_WRITE(cop_d_write)
345345   AM_RANGE(COP400_PORT_SK, COP400_PORT_SK)  AM_WRITE(cop_sk_write)
346   AM_RANGE(COP400_PORT_SIO,COP400_PORT_SIO) AM_READWRITE(port_tag_to_handler8("THAYERS_LETTERS"),cop_sio_write)   /* Unemulated in COP40x core, so nothing happens ATM */
346   AM_RANGE(COP400_PORT_SIO,COP400_PORT_SIO) AM_READ_PORT("THAYERS_LETTERS") AM_WRITE(cop_sio_write)   /* Unemulated in COP40x core, so nothing happens ATM */
347347ADDRESS_MAP_END                                                                              /* This is also very wrong.  The keyboard interface needs to
348348                                                                                                                       be understood much better than what I have here */
349349
r1293r1294
463463   MDRV_MACHINE_START(thayers)
464464
465465/*  io device cpu */
466   MDRV_CPU_ADD(COP420, SCHEMATIC_CLOCK/2/8);      /* Can't read the schematics, but this is what daphne says */
466   MDRV_CPU_ADD(COP420, SCHEMATIC_CLOCK/2/8)      /* Can't read the schematics, but this is what daphne says */
467467   MDRV_CPU_PROGRAM_MAP(copmem,0)
468468   MDRV_CPU_IO_MAP(copio,0)
469469
src/mame/drivers/dassault.c
r1293r1294
566566   MDRV_CPU_PROGRAM_MAP(sound_readmem,sound_writemem)
567567
568568   MDRV_SCREEN_REFRESH_RATE(60)
569   MDRV_SCREEN_VBLANK_TIME(USEC_TO_SUBSECONDS(529))
569   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(529))
570570   MDRV_INTERLEAVE(140) /* 140 CPU slices per frame */
571571
572572   /* video hardware */
src/mame/drivers/tatsumi.c
r1293r1294
7474#include "sound/okim6295.h"
7575
7676static UINT16 *cyclwarr_cpua_ram, *cyclwarr_cpub_ram;
77UINT16 *tatsumi_c_ram, *apache3_g_ram;
77static UINT16 *tatsumi_c_ram, *apache3_g_ram;
7878UINT16 *roundup5_d0000_ram, *roundup5_e0000_ram;
7979UINT8 *tatsumi_rom_sprite_lookup1, *tatsumi_rom_sprite_lookup2;
8080UINT8 *tatsumi_rom_clut0, *tatsumi_rom_clut1;
8181UINT16 *roundup5_unknown0, *roundup5_unknown1, *roundup5_unknown2;
82UINT8 *apache3_bg_ram;
82static UINT8 *apache3_bg_ram;
8383
8484/***************************************************************************/
8585
src/mame/drivers/supbtime.c
r1293r1294
382382   MDRV_CPU_PROGRAM_MAP(sound_readmem,sound_writemem)
383383
384384   MDRV_SCREEN_REFRESH_RATE(58)
385   MDRV_SCREEN_VBLANK_TIME(USEC_TO_SUBSECONDS(529))
385   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(529))
386386
387387   /* video hardware */
388388   MDRV_VIDEO_ATTRIBUTES(VIDEO_TYPE_RASTER | VIDEO_UPDATE_BEFORE_VBLANK)
r1293r1294
421421   MDRV_CPU_PROGRAM_MAP(sound_readmem,sound_writemem)
422422
423423   MDRV_SCREEN_REFRESH_RATE(58)
424   MDRV_SCREEN_VBLANK_TIME(USEC_TO_SUBSECONDS(529))
424   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(529))
425425
426426   /* video hardware */
427427   MDRV_VIDEO_ATTRIBUTES(VIDEO_TYPE_RASTER | VIDEO_UPDATE_BEFORE_VBLANK)
src/mame/drivers/megaplay.c
r1293r1294
7373extern UINT8 *segae_vdp_regs[];      /* pointer to vdp's registers */
7474
7575// Interrupt handler - from drivers/segasyse.c
76INTERRUPT_GEN (megaplay_bios_irq)
76static INTERRUPT_GEN (megaplay_bios_irq)
7777{
7878   int sline;
7979   sline = 261 - cpu_getiloops();
r1293r1294
852852ROM_END
853853
854854
855void megplay_stat(void)
855static void megplay_stat(void)
856856{
857857   UINT8 *src = memory_region(REGION_CPU3);
858858   UINT8 *instruction_rom = memory_region(REGION_USER1);
src/mame/drivers/harddriv.c
r1293r1294
36653665}
36663666
36673667
3668UINT32 *rddsp32_speedup;
3669offs_t rddsp32_speedup_pc;
3668static UINT32 *rddsp32_speedup;
3669static offs_t rddsp32_speedup_pc;
36703670static READ32_HANDLER( rddsp32_speedup_r )
36713671{
36723672   if (activecpu_get_pc() == rddsp32_speedup_pc && (*rddsp32_speedup >> 16) == 0)
src/mame/drivers/konamigv.c
r1293r1294
346346   MDRV_CPU_VBLANK_INT( psx_vblank, 1 )
347347
348348   MDRV_SCREEN_REFRESH_RATE( 60 )
349   MDRV_SCREEN_VBLANK_TIME(USEC_TO_SUBSECONDS( 0 ))
349   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC( 0 ))
350350
351351   MDRV_MACHINE_RESET( konamigv )
352352   MDRV_NVRAM_HANDLER(konamigv_93C46)
src/mame/drivers/crgolf.c
r1293r1294
395395MACHINE_DRIVER_END
396396
397397
398MACHINE_DRIVER_START( crgolfhi )
398static MACHINE_DRIVER_START( crgolfhi )
399399   MDRV_IMPORT_FROM(crgolf)
400400
401401   MDRV_SOUND_ADD(MSM5205, 384000)
src/mame/drivers/mastboy.c
r1293r1294
438438#include "sound/msm5205.h"
439439
440440/* RAM areas */
441UINT8* mastboy_tileram;
442UINT8* mastboy_vram;
443UINT8* mastboy_colram;
444UINT8* mastboy_workram;
441static UINT8* mastboy_tileram;
442static UINT8* mastboy_vram;
443static UINT8* mastboy_colram;
444static UINT8* mastboy_workram;
445445
446446/* Bank Control */
447UINT8 mastboy_bank;
447static UINT8 mastboy_bank;
448448
449449/* General */
450int mastboy_irq0_ack;
451int mastboy_backupram_enabled;
450static int mastboy_irq0_ack;
451static int mastboy_backupram_enabled;
452452
453453/* MSM5205 */
454int mastboy_m5205_next;
455int mastboy_m5205_part;
456int mastboy_m5205_sambit0, mastboy_m5205_sambit1;
454static int mastboy_m5205_next;
455static int mastboy_m5205_part;
456static int mastboy_m5205_sambit0, mastboy_m5205_sambit1;
457457
458458/* VIDEO EMULATION */
459459
r1293r1294
658658   if ((data&1)==1) cpunum_set_input_line(0,0, CLEAR_LINE);
659659}
660660
661INTERRUPT_GEN( mastboy_interrupt )
661static INTERRUPT_GEN( mastboy_interrupt )
662662{
663663   if ((mastboy_irq0_ack&1)==1)
664664   {
src/mame/drivers/topspeed.c
r1293r1294
307307static INTERRUPT_GEN( topspeed_interrupt )
308308{
309309   /* Unsure how many int6's per frame */
310   mame_timer_set(MAME_TIME_IN_CYCLES(200000-500,0),0, topspeed_interrupt6);
310   timer_set(ATTOTIME_IN_CYCLES(200000-500,0),0, topspeed_interrupt6);
311311   cpunum_set_input_line(0, 5, HOLD_LINE);
312312}
313313
314314static INTERRUPT_GEN( topspeed_cpub_interrupt )
315315{
316316   /* Unsure how many int6's per frame */
317   mame_timer_set(MAME_TIME_IN_CYCLES(200000-500,0),0, topspeed_cpub_interrupt6);
317   timer_set(ATTOTIME_IN_CYCLES(200000-500,0),0, topspeed_cpub_interrupt6);
318318   cpunum_set_input_line(2, 5, HOLD_LINE);
319319}
320320
src/mame/drivers/zr107.c
r1293r1294
250250   mame_printf_debug("sysreg_w: %08X, %08X, %08X\n", offset, data, mem_mask);
251251}
252252
253double adc0838_callback(int input)
253static double adc0838_callback(int input)
254254{
255255   switch (input)
256256   {
src/mame/drivers/segae.c
r1293r1294
573573   GEN_VDP = 3   // Genesis VDP running in SMS2 Mode
574574};
575575
576int sms_vdp_null_irq_callback(int status)
576static int sms_vdp_null_irq_callback(int status)
577577{
578578   return -1;
579579}
580580
581int sms_vdp_cpu0_irq_callback(int status)
581static int sms_vdp_cpu0_irq_callback(int status)
582582{
583583   if (status==1)
584584   {
r1293r1294
592592   return 0;
593593}
594594
595int sms_vdp_cpu1_irq_callback(int status)
595static int sms_vdp_cpu1_irq_callback(int status)
596596{
597597   if (status==1)
598598   {
r1293r1294
607607}
608608
609609
610int sms_vdp_cpu2_irq_callback(int status)
610static int sms_vdp_cpu2_irq_callback(int status)
611611{
612612   if (status==1)
613613   {
r1293r1294
661661   int sms_scanline_counter;
662662   int sms_total_scanlines;
663663   int sms_framerate;
664   mame_timer* sms_scanline_timer;
664   emu_timer* sms_scanline_timer;
665665   UINT16* cram_mamecolours; // for use on RGB_DIRECT screen
666666   int    (*set_irq)(int state);
667667
r1293r1294
729729   chip->writemode = 0;
730730   chip->r_bitmap = auto_bitmap_alloc(machine->screen[0].width,machine->screen[0].height,machine->screen[0].format);
731731
732   chip->sms_scanline_timer = mame_timer_alloc_ptr(sms_scanline_timer_callback, chip);
732   chip->sms_scanline_timer = timer_alloc_ptr(sms_scanline_timer_callback, chip);
733733
734734   return chip;
735735}
r1293r1294
737737/* stop timer and clear ram.. used on megatech when we switch between genesis and sms mode */
738738void segae_md_sms_stop_scanline_timer(void)
739739{
740   mame_timer_adjust_ptr(md_sms_vdp->sms_scanline_timer,  time_never, time_never);
740   timer_adjust_ptr(md_sms_vdp->sms_scanline_timer,  attotime_never, attotime_never);
741741   memset(md_sms_vdp->vram,0x00,0x4000);
742742}
743743
r1293r1294
10561056   }
10571057}
10581058
1059void sms_render_spriteline(int scanline, struct sms_vdp* chip)
1059static void sms_render_spriteline(int scanline, struct sms_vdp* chip)
10601060{
10611061   int spritenum;
10621062   int height = 8;
r1293r1294
11771177   }
11781178}
11791179
1180void sms_render_tileline(int scanline, struct sms_vdp* chip)
1180static void sms_render_tileline(int scanline, struct sms_vdp* chip)
11811181{
11821182   int column = 0;
11831183   int count = 32;
r1293r1294
12301230
12311231}
12321232
1233void sms_copy_to_renderbuffer(int scanline, struct sms_vdp* chip)
1233static void sms_copy_to_renderbuffer(int scanline, struct sms_vdp* chip)
12341234{
12351235   int x;
12361236   UINT16* lineptr = BITMAP_ADDR16(chip->r_bitmap, scanline, 0);
r1293r1294
12711271
12721272}
12731273
1274void sms_draw_scanline(int scanline, struct sms_vdp* chip)
1274static void sms_draw_scanline(int scanline, struct sms_vdp* chip)
12751275{
12761276
12771277   if (scanline>=0 && scanline<sms_mode_table[chip->screen_mode].sms2_height)
r1293r1294
13041304   if (chip->sms_scanline_counter<(chip->sms_total_scanlines-1))
13051305   {
13061306      chip->sms_scanline_counter++;
1307      mame_timer_adjust_ptr(chip->sms_scanline_timer, MAME_TIME_IN_HZ(chip->sms_framerate * chip->sms_total_scanlines), time_zero);
1307      timer_adjust_ptr(chip->sms_scanline_timer, ATTOTIME_IN_HZ(chip->sms_framerate * chip->sms_total_scanlines), attotime_zero);
13081308
13091309      if (chip->sms_scanline_counter>sms_mode_table[chip->screen_mode].sms2_height)
13101310      {
r1293r1294
14511451      visarea.min_y = 0;
14521452      visarea.max_y = sms_mode_table[chip->screen_mode].sms2_height-1;
14531453
1454      if (chip->chip_id==3) video_screen_configure(0, 256, 256, &visarea, HZ_TO_SUBSECONDS(chip->sms_framerate));
1454      if (chip->chip_id==3) video_screen_configure(0, 256, 256, &visarea, HZ_TO_ATTOSECONDS(chip->sms_framerate));
14551455
14561456   }
14571457   else /* 160x144 */
r1293r1294
14691469
14701470   chip->sms_scanline_counter = -1;
14711471   chip->yscroll = chip->regs[0x9]; // this can't change mid-frame
1472   mame_timer_adjust_ptr(chip->sms_scanline_timer, time_zero, time_zero);
1472   timer_adjust_ptr(chip->sms_scanline_timer, attotime_zero, attotime_zero);
14731473}
14741474
14751475#ifdef UNUSED_FUNCTION
r1293r1294
14911491#ifdef UNUSED_FUNCTION
14921492MACHINE_RESET(sms)
14931493{
1494   mame_timer_adjust_ptr(vdp1->sms_scanline_timer, time_zero, time_zero);
1494   timer_adjust_ptr(vdp1->sms_scanline_timer, attotime_zero, attotime_zero);
14951495}
14961496#endif
14971497
r1293r1294
19491949
19501950static MACHINE_RESET(systeme)
19511951{
1952   mame_timer_adjust_ptr(vdp1->sms_scanline_timer, time_zero, time_zero);
1953   mame_timer_adjust_ptr(vdp2->sms_scanline_timer, time_zero, time_zero);
1952   timer_adjust_ptr(vdp1->sms_scanline_timer, attotime_zero, attotime_zero);
1953   timer_adjust_ptr(vdp2->sms_scanline_timer, attotime_zero, attotime_zero);
19541954}
19551955
19561956MACHINE_RESET(megatech_md_sms)
19571957{
1958   mame_timer_adjust_ptr(md_sms_vdp->sms_scanline_timer, time_zero, time_zero);
1958   timer_adjust_ptr(md_sms_vdp->sms_scanline_timer, attotime_zero, attotime_zero);
19591959}
19601960
19611961MACHINE_RESET(megatech_bios)
19621962{
1963   mame_timer_adjust_ptr(vdp1->sms_scanline_timer, time_zero, time_zero);
1963   timer_adjust_ptr(vdp1->sms_scanline_timer, attotime_zero, attotime_zero);
19641964}
19651965
19661966static VIDEO_EOF(systeme)
r1293r1294
20502050}
20512051
20522052
2053MACHINE_DRIVER_START( systeme )
2053static MACHINE_DRIVER_START( systeme )
20542054   MDRV_CPU_ADD_TAG("z80", Z80, 10738600/2) /* correct for hangonjr, and astroflash/transformer at least  */
20552055   MDRV_CPU_PROGRAM_MAP(systeme_readmem,systeme_writemem)
20562056   MDRV_CPU_IO_MAP(sms_readport,sms_writeport)
src/mame/drivers/ksys573.c
r1293r1294
450450#define ATAPI_DATA_SIZE ( 64 * 1024 )
451451
452452static UINT8 *atapi_regs;
453static mame_timer *atapi_timer;
453static emu_timer *atapi_timer;
454454static SCSIInstance *inserted_cdrom;
455455static SCSIInstance *available_cdroms[ 2 ];
456456static UINT8 *atapi_data;
r1293r1294
463463   int i, n_this;
464464   UINT8 sector_buffer[ 4096 ];
465465
466   mame_timer_adjust(atapi_timer, time_never, 0, time_never);
466   timer_adjust(atapi_timer, attotime_never, 0, attotime_never);
467467
468468//  verboselog( 2, "atapi_xfer_end( %d ) atapi_xferlen = %d, atapi_xfermod=%d\n", x, atapi_xfermod, atapi_xferlen );
469469
r1293r1294
508508      atapi_regs[ATAPI_REG_COUNTLOW] = atapi_xferlen & 0xff;
509509      atapi_regs[ATAPI_REG_COUNTHIGH] = (atapi_xferlen>>8)&0xff;
510510
511      mame_timer_adjust(atapi_timer, MAME_TIME_IN_CYCLES((ATAPI_CYCLES_PER_SECTOR * (atapi_xferlen/2048)), 0), 0, time_zero);
511      timer_adjust(atapi_timer, ATTOTIME_IN_CYCLES((ATAPI_CYCLES_PER_SECTOR * (atapi_xferlen/2048)), 0), 0, attotime_zero);
512512   }
513513   else
514514   {
r1293r1294
734734
735735               case 0x45: // PLAY
736736                  atapi_regs[ATAPI_REG_CMDSTATUS] = ATAPI_STAT_BSY;
737                  mame_timer_adjust( atapi_timer, MAME_TIME_IN_CYCLES( ATAPI_CYCLES_PER_SECTOR, 0 ), 0, time_zero );
737                  timer_adjust( atapi_timer, ATTOTIME_IN_CYCLES( ATAPI_CYCLES_PER_SECTOR, 0 ), 0, attotime_zero );
738738                  break;
739739            }
740740
r1293r1294
892892   atapi_data_len = 0;
893893   atapi_cdata_wait = 0;
894894
895   atapi_timer = mame_timer_alloc( atapi_xfer_end );
896   mame_timer_adjust(atapi_timer, time_never, 0, time_never);
895   atapi_timer = timer_alloc( atapi_xfer_end );
896   timer_adjust(atapi_timer, attotime_never, 0, attotime_never);
897897
898898   for( i = 0; i < 2; i++ )
899899   {
r1293r1294
959959   verboselog( 2, "atapi_xfer_end: %d %d\n", atapi_xferlen, atapi_xfermod );
960960
961961   // set a transfer complete timer (Note: CYCLES_PER_SECTOR can't be lower than 2000 or the BIOS ends up "out of order")
962   mame_timer_adjust(atapi_timer, MAME_TIME_IN_CYCLES((ATAPI_CYCLES_PER_SECTOR * (atapi_xferlen/2048)), 0), 0, time_zero);
962   timer_adjust(atapi_timer, ATTOTIME_IN_CYCLES((ATAPI_CYCLES_PER_SECTOR * (atapi_xferlen/2048)), 0), 0, attotime_zero);
963963}
964964
965965static UINT32 m_n_security_control;
r1293r1294
10961096
10971097/* Root Counters */
10981098
1099static mame_timer *m_p_timer_root[ 3 ];
1099static emu_timer *m_p_timer_root[ 3 ];
11001100static UINT16 m_p_n_root_count[ 3 ];
11011101static UINT16 m_p_n_root_mode[ 3 ];
11021102static UINT16 m_p_n_root_target[ 3 ];
r1293r1294
11711171{
11721172   if( ( m_p_n_root_mode[ n_counter ] & RC_STOP ) != 0 )
11731173   {
1174      mame_timer_adjust( m_p_timer_root[ n_counter ], time_never, n_counter, time_zero);
1174      timer_adjust( m_p_timer_root[ n_counter ], attotime_never, n_counter, attotime_zero);
11751175   }
11761176   else
11771177   {
r1293r1294
11851185
11861186      n_duration *= root_divider( n_counter );
11871187
1188      mame_timer_adjust( m_p_timer_root[ n_counter ], scale_up_mame_time(MAME_TIME_IN_HZ(33868800), n_duration), n_counter, time_zero);
1188      timer_adjust( m_p_timer_root[ n_counter ], attotime_mul(ATTOTIME_IN_HZ(33868800), n_duration), n_counter, attotime_zero);
11891189   }
11901190}
11911191
r1293r1294
14831483
14841484   for (i = 0; i < 3; i++)
14851485   {
1486      m_p_timer_root[i] = mame_timer_alloc(root_finished);
1486      m_p_timer_root[i] = timer_alloc(root_finished);
14871487   }
14881488
14891489   timekeeper_init( 0, TIMEKEEPER_M48T58, memory_region( REGION_USER11 ) );
r1293r1294
27162716   MDRV_CPU_VBLANK_INT( sys573_vblank, 1 )
27172717
27182718   MDRV_SCREEN_REFRESH_RATE( 60 )
2719   MDRV_SCREEN_VBLANK_TIME(USEC_TO_SUBSECONDS( 0 ))
2719   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC( 0 ))
27202720
27212721   MDRV_MACHINE_RESET( konami573 )
27222722   MDRV_NVRAM_HANDLER( konami573 )
src/mame/drivers/sbrkout.c
r1293r1294
5252 *
5353 *************************************/
5454
55#define TIME_4V MAME_TIME_IN_SEC(4075000/4)
55#define TIME_4V ATTOTIME_IN_SEC(4075000/4)
5656
5757static UINT8 *sbrkout_sound;
5858
r1293r1294
7777
7878static MACHINE_RESET( sbrkout )
7979{
80   mame_timer_pulse(TIME_4V, 0, sbrkout_tones_4V);
80   timer_pulse(TIME_4V, 0, sbrkout_tones_4V);
8181}
8282
8383
src/mame/drivers/ampoker.c
r1293r1294
543543*      Input ports       *
544544*************************/
545545
546INPUT_PORTS_START( ampoker2 )
546static INPUT_PORTS_START( ampoker2 )
547547   PORT_START_TAG("IN0")
548548   PORT_DIPNAME( 0x01, 0x01, DEF_STR( Unknown ) )
549549   PORT_DIPSETTING(    0x01, DEF_STR( Off ) )
r1293r1294
628628   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_SERVICE ) PORT_NAME("Clear Credits") PORT_CODE(KEYCODE_4)
629629INPUT_PORTS_END
630630
631INPUT_PORTS_START( ampkr95 )
631static INPUT_PORTS_START( ampkr95 )
632632   PORT_START_TAG("IN0")
633633   PORT_DIPNAME( 0x01, 0x01, DEF_STR( Unknown ) )
634634   PORT_DIPSETTING(    0x01, DEF_STR( Off ) )
r1293r1294
713713   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_SERVICE ) PORT_NAME("Clear Credits") PORT_CODE(KEYCODE_4)
714714INPUT_PORTS_END
715715
716INPUT_PORTS_START( sigmapkr )
716static INPUT_PORTS_START( sigmapkr )
717717   PORT_START_TAG("IN0")
718718   PORT_DIPNAME( 0x01, 0x01, DEF_STR( Unknown ) )
719719   PORT_DIPSETTING(    0x01, DEF_STR( Off ) )
r1293r1294
860860   MDRV_CPU_PROGRAM_MAP(ampoker2_map, 0)
861861   MDRV_CPU_IO_MAP(ampoker2_io_map, 0)
862862   MDRV_CPU_PERIODIC_INT(nmi_line_pulse, 1536)
863   MDRV_WATCHDOG_TIME_INIT(MAME_TIME_IN_HZ( 5 ))   /* 200 ms, measured */
863   MDRV_WATCHDOG_TIME_INIT(ATTOTIME_IN_HZ( 5 ))   /* 200 ms, measured */
864864   //MDRV_WATCHDOG_VBLANK_INIT(8)
865865   MDRV_SCREEN_REFRESH_RATE(60)
866866   /*  if VBLANK is used, the watchdog timer stop to work.
src/mame/drivers/mcr68.c
r1293r1294
13211321   mcr68_common_init(MCR_CHIP_SQUEAK_DELUXE, 0, 0);
13221322
13231323   /* Zwackery doesn't care too much about this value; currently taken from Blasted */
1324   mcr68_timing_factor = make_mame_time(0, MAX_SUBSECONDS / (machine->drv->cpu[0].clock / 10) * (256 + 16));
1324   mcr68_timing_factor = attotime_make(0, HZ_TO_ATTOSECONDS(machine->drv->cpu[0].clock / 10) * (256 + 16));
13251325}
13261326
13271327
r1293r1294
13301330   mcr68_common_init(MCR_SOUNDS_GOOD, 0, 0);
13311331
13321332   /* Xenophobe doesn't care too much about this value; currently taken from Blasted */
1333   mcr68_timing_factor = make_mame_time(0, MAX_SUBSECONDS / (machine->drv->cpu[0].clock / 10) * (256 + 16));
1333   mcr68_timing_factor = attotime_make(0, HZ_TO_ATTOSECONDS(machine->drv->cpu[0].clock / 10) * (256 + 16));
13341334
13351335   /* install control port handler */
13361336   memory_install_write16_handler(0, ADDRESS_SPACE_PROGRAM, 0x0c0000, 0x0cffff, 0, 0, xenophobe_control_w);
r1293r1294
13421342   mcr68_common_init(MCR_TURBO_CHIP_SQUEAK | MCR_SOUNDS_GOOD, 0, -6);
13431343
13441344   /* Spy Hunter 2 doesn't care too much about this value; currently taken from Blasted */
1345   mcr68_timing_factor = make_mame_time(0, MAX_SUBSECONDS / (machine->drv->cpu[0].clock / 10) * (256 + 16));
1345   mcr68_timing_factor = attotime_make(0, HZ_TO_ATTOSECONDS(machine->drv->cpu[0].clock / 10) * (256 + 16));
13461346
13471347   /* analog port handling is a bit tricky */
13481348   memory_install_write16_handler(0, ADDRESS_SPACE_PROGRAM, 0x0c0000, 0x0cffff, 0, 0, spyhunt2_control_w);
r1293r1294
13581358   /* Blasted checks the timing of VBLANK relative to the 493 interrupt */
13591359   /* VBLANK is required to come within 220-256 E clocks (i.e., 2200-2560 CPU clocks) */
13601360   /* after the 493; we also allow 16 E clocks for latency  */
1361   mcr68_timing_factor = make_mame_time(0, MAX_SUBSECONDS / (machine->drv->cpu[0].clock / 10) * (256 + 16));
1361   mcr68_timing_factor = attotime_make(0, HZ_TO_ATTOSECONDS(machine->drv->cpu[0].clock / 10) * (256 + 16));
13621362
13631363   /* handle control writes */
13641364   memory_install_write16_handler(0, ADDRESS_SPACE_PROGRAM, 0x0c0000, 0x0cffff, 0, 0, blasted_control_w);
r1293r1294
13741374   mcr68_common_init(MCR_WILLIAMS_SOUND, 16, 0);
13751375
13761376   /* Arch Rivals doesn't care too much about this value; currently taken from Blasted */
1377   mcr68_timing_factor = make_mame_time(0, MAX_SUBSECONDS / (machine->drv->cpu[0].clock / 10) * (256 + 16));
1377   mcr68_timing_factor = attotime_make(0, HZ_TO_ATTOSECONDS(machine->drv->cpu[0].clock / 10) * (256 + 16));
13781378
13791379   /* handle control writes */
13801380   memory_install_write16_handler(0, ADDRESS_SPACE_PROGRAM, 0x0c0000, 0x0cffff, 0, 0, archrivl_control_w);
r1293r1294
13931393   mcr68_common_init(MCR_WILLIAMS_SOUND, 16, 0);
13941394
13951395   /* Pigskin doesn't care too much about this value; currently taken from Tri-Sports */
1396   mcr68_timing_factor = make_mame_time(0, MAX_SUBSECONDS / (machine->drv->cpu[0].clock / 10) * 115);
1396   mcr68_timing_factor = attotime_make(0, HZ_TO_ATTOSECONDS(machine->drv->cpu[0].clock / 10) * 115);
13971397
13981398   state_save_register_global_array(protection_data);
13991399}
r1293r1294
14061406   /* Tri-Sports checks the timing of VBLANK relative to the 493 interrupt */
14071407   /* VBLANK is required to come within 87-119 E clocks (i.e., 870-1190 CPU clocks) */
14081408   /* after the 493 */
1409   mcr68_timing_factor = make_mame_time(0, MAX_SUBSECONDS / (machine->drv->cpu[0].clock / 10) * 115);
1409   mcr68_timing_factor = attotime_make(0, HZ_TO_ATTOSECONDS(machine->drv->cpu[0].clock / 10) * 115);
14101410}
14111411
14121412
src/mame/drivers/pbaction.c
r1293r1294
255255GFXDECODE_END
256256
257257
258INTERRUPT_GEN( pbaction_interrupt )
258static INTERRUPT_GEN( pbaction_interrupt )
259259{
260260   cpunum_set_input_line_and_vector(1, 0, HOLD_LINE, 0x02);   /* the CPU is in Interrupt Mode 2 */
261261}
src/mame/drivers/thunderx.c
r1293r1294
308308      calculate_collisions();
309309
310310      /* 100 cycle delay is arbitrary */
311      mame_timer_set(MAME_TIME_IN_CYCLES(100,0),0, thunderx_firq_callback);
311      timer_set(ATTOTIME_IN_CYCLES(100,0),0, thunderx_firq_callback);
312312   }
313313
314314   thunderx_1f98_data = data;
src/mame/drivers/mario.c
r1293r1294
248248   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_UNKNOWN )
249249
250250   PORT_START_TAG("DSW")
251   PORT_DIPNAME( 0x03, 0x00, DEF_STR( Lives ) ) PORT_DIPLOCATION("SW1:1,2")
251   PORT_DIPNAME( 0x03, 0x00, DEF_STR( Lives ) )      PORT_DIPLOCATION("SW1:!1,!2")
252252   PORT_DIPSETTING(    0x00, "3" )
253253   PORT_DIPSETTING(    0x01, "4" )
254254   PORT_DIPSETTING(    0x02, "5" )
255255   PORT_DIPSETTING(    0x03, "6" )
256   PORT_DIPNAME( 0x0c, 0x00, DEF_STR( Coinage ) ) PORT_DIPLOCATION("SW1:3,4")
256   PORT_DIPNAME( 0x0c, 0x00, DEF_STR( Coinage ) )      PORT_DIPLOCATION("SW1:!3,!4")
257257   PORT_DIPSETTING(    0x04, DEF_STR( 2C_1C ) )
258258   PORT_DIPSETTING(    0x00, DEF_STR( 1C_1C ) )
259259   PORT_DIPSETTING(    0x08, DEF_STR( 1C_2C ) )
260260   PORT_DIPSETTING(    0x0c, DEF_STR( 1C_3C ) )
261   PORT_DIPNAME( 0x30, 0x00, DEF_STR( Bonus_Life ) ) PORT_DIPLOCATION("SW1:5,6")
261   PORT_DIPNAME( 0x30, 0x00, DEF_STR( Bonus_Life ) )   PORT_DIPLOCATION("SW1:!5,!6")
262262   PORT_DIPSETTING(    0x00, "20k only" )
263263   PORT_DIPSETTING(    0x10, "30k only" )
264264   PORT_DIPSETTING(    0x20, "40k only" )
265265   PORT_DIPSETTING(    0x30, DEF_STR( None ) )
266   PORT_DIPNAME( 0xc0, 0x00, DEF_STR( Difficulty ) ) PORT_DIPLOCATION("SW1:7,8")
266   PORT_DIPNAME( 0xc0, 0x00, DEF_STR( Difficulty ) )   PORT_DIPLOCATION("SW1:!7,!8")
267267   PORT_DIPSETTING(    0x00, DEF_STR( Easy ) )
268268   PORT_DIPSETTING(    0x80, DEF_STR( Medium ) )
269269   PORT_DIPSETTING(    0x40, DEF_STR( Hard ) )
r1293r1294
282282   PORT_INCLUDE( mario )
283283
284284   PORT_MODIFY( "DSW" )
285   PORT_DIPNAME( 0x03, 0x00, DEF_STR( Lives ) ) PORT_DIPLOCATION("SW1:1,2")
285   PORT_DIPNAME( 0x03, 0x00, DEF_STR( Lives ) )      PORT_DIPLOCATION("SW1:!1,!2")
286286   PORT_DIPSETTING(    0x00, "3" )
287287   PORT_DIPSETTING(    0x01, "4" )
288288   PORT_DIPSETTING(    0x02, "5" )
289289   PORT_DIPSETTING(    0x03, "6" )
290   PORT_DIPNAME( 0x1c, 0x00, DEF_STR( Coinage ) ) PORT_DIPLOCATION("SW1:3,4,5")
290   PORT_DIPNAME( 0x1c, 0x00, DEF_STR( Coinage ) )      PORT_DIPLOCATION("SW1:!3,!4,!5")
291291   PORT_DIPSETTING(    0x08, DEF_STR( 3C_1C ) )
292292   PORT_DIPSETTING(    0x10, DEF_STR( 2C_1C ) )
293293   PORT_DIPSETTING(    0x00, DEF_STR( 1C_1C ) )
r1293r1294
296296   PORT_DIPSETTING(    0x0c, DEF_STR( 1C_4C ) )
297297   PORT_DIPSETTING(    0x14, DEF_STR( 1C_5C ) )
298298   PORT_DIPSETTING(    0x1c, DEF_STR( 1C_6C ) )
299   PORT_DIPNAME( 0x20, 0x20, "2 Players Game" ) PORT_DIPLOCATION("SW1:6")
299   PORT_DIPNAME( 0x20, 0x20, "2 Players Game" )      PORT_DIPLOCATION("SW1:!6")
300300   PORT_DIPSETTING(    0x00, "1 Credit" )
301301   PORT_DIPSETTING(    0x20, "2 Credits" )
302   PORT_DIPNAME( 0xc0, 0x00, DEF_STR( Bonus_Life ) ) PORT_DIPLOCATION("SW1:7,8")
302   PORT_DIPNAME( 0xc0, 0x00, DEF_STR( Bonus_Life ) )   PORT_DIPLOCATION("SW1:!7,!8")
303303   PORT_DIPSETTING(    0x00, "20k 50k 30k+" )
304304   PORT_DIPSETTING(    0x40, "30k 60k 30k+" )
305305   PORT_DIPSETTING(    0x80, "40k 70k 30k+" )
r1293r1294
310310   PORT_INCLUDE( marioo )
311311
312312   PORT_MODIFY( "DSW" )
313   PORT_DIPNAME( 0x30, 0x00, DEF_STR( Bonus_Life ) ) PORT_DIPLOCATION("SW1:5,6")
313   PORT_DIPNAME( 0x30, 0x00, DEF_STR( Bonus_Life ) )   PORT_DIPLOCATION("SW1:!5,!6")
314314   PORT_DIPSETTING(    0x00, "20k 40k 20k+" )
315315   PORT_DIPSETTING(    0x10, "30k 50k 20k+" )
316316   PORT_DIPSETTING(    0x20, "40k 60k 20k+" )
src/mame/drivers/atarifb.c
r1293r1294
530530   MDRV_CPU_VBLANK_INT(irq0_line_hold,4)
531531
532532   MDRV_SCREEN_REFRESH_RATE(60)
533   MDRV_SCREEN_VBLANK_TIME(USEC_TO_SUBSECONDS(2037)   /* 16.3ms * 1/8 = 2037.5. Is it 1/8th or 3/32nds? (1528?) */)
533   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(2037)   /* 16.3ms * 1/8 = 2037.5. Is it 1/8th or 3/32nds? (1528?) */)
534534
535535   /* video hardware */
536536   MDRV_VIDEO_ATTRIBUTES(VIDEO_TYPE_RASTER)
src/mame/drivers/lethal.c
r1293r1294
184184
185185/* Default Eeprom for the parent.. otherwise it will always complain first boot */
186186/* its easy to init but this saves me a bit of time.. */
187UINT8 lethalen_default_eeprom[48] = {
187static UINT8 lethalen_default_eeprom[48] = {
188188   0x02, 0x1E, 0x00, 0x00, 0x39, 0x31, 0x39, 0x31, 0x55, 0x45, 0x77, 0x00, 0x00, 0x00, 0x00, 0x01,
189189   0x02, 0x01, 0x00, 0x03, 0x05, 0x01, 0x01, 0x02, 0x28, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
190190   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF
src/mame/drivers/videopin.c
r1293r1294
1515#include "videopin.lh"
1616#include "sound/discrete.h"
1717
18static mame_time time_pushed;
19static mame_time time_released;
18static attotime time_pushed;
19static attotime time_released;
2020
2121static UINT8 prev = 0;
2222static UINT8 mask = 0;
r1293r1294
3333   {
3434      if (val == 0)
3535      {
36         time_released = mame_timer_get_time();
36         time_released = timer_get_time();
3737
3838         if (!mask)
3939         {
r1293r1294
4242      }
4343      else
4444      {
45         time_pushed = mame_timer_get_time();
45         time_pushed = timer_get_time();
4646      }
4747
4848      prev = val;
r1293r1294
6565      scanline = 32;
6666   }
6767
68   mame_timer_set(video_screen_get_time_until_pos(0, scanline, 0), scanline, interrupt_callback);
68   timer_set(video_screen_get_time_until_pos(0, scanline, 0), scanline, interrupt_callback);
6969}
7070
7171
7272static MACHINE_RESET( videopin )
7373{
74   mame_timer_set(video_screen_get_time_until_pos(0, 32, 0), 32, interrupt_callback);
74   timer_set(video_screen_get_time_until_pos(0, 32, 0), 32, interrupt_callback);
7575
7676   /* both output latches are cleared on reset */
7777
r1293r1294
8282
8383static double calc_plunger_pos(void)
8484{
85   return (mame_time_to_double(mame_timer_get_time()) - mame_time_to_double(time_released)) * (mame_time_to_double(time_released) - mame_time_to_double(time_pushed) + 0.2);
85   return (attotime_to_double(timer_get_time()) - attotime_to_double(time_released)) * (attotime_to_double(time_released) - attotime_to_double(time_pushed) + 0.2);
8686}
8787
8888
src/mame/drivers/naughtyb.c
r1293r1294
215215
216216***************************************************************************/
217217
218INTERRUPT_GEN( naughtyb_interrupt )
218static INTERRUPT_GEN( naughtyb_interrupt )
219219{
220220   if (readinputport(3) & 1)
221221      cpunum_set_input_line(0, INPUT_LINE_NMI, PULSE_LINE);
src/mame/drivers/runaway.c
r1293r1294
4141      scanline = 16;
4242   }
4343
44   mame_timer_set(video_screen_get_time_until_pos(0, scanline, 0), scanline, interrupt_callback);
44   timer_set(video_screen_get_time_until_pos(0, scanline, 0), scanline, interrupt_callback);
4545}
4646
4747
4848static MACHINE_RESET( runaway )
4949{
50   mame_timer_set(video_screen_get_time_until_pos(0, 16, 0), 16, interrupt_callback);
50   timer_set(video_screen_get_time_until_pos(0, 16, 0), 16, interrupt_callback);
5151}
5252
5353
src/mame/drivers/toypop.c
r1293r1294
180180   cpu_interrupt_enable(1,0);
181181}
182182
183INTERRUPT_GEN( toypop_main_interrupt )
183static INTERRUPT_GEN( toypop_main_interrupt )
184184{
185185   irq0_line_assert();   // this also checks if irq is enabled - IMPORTANT!
186186                  // so don't replace with cpunum_set_input_line(0, 0, ASSERT_LINE);
r1293r1294
226226   timer_call_after_resynch(0, disable_interrupts);
227227}
228228
229INTERRUPT_GEN( toypop_m68000_interrupt )
229static INTERRUPT_GEN( toypop_m68000_interrupt )
230230{
231231   if (interrupt_enable_68k)
232232      cpunum_set_input_line(2, 6, HOLD_LINE);
src/mame/drivers/tumbleb.c
r1293r1294
307307extern WRITE16_HANDLER( wlstar_tilebank_w );
308308
309309extern UINT16 *tumblepb_pf1_data,*tumblepb_pf2_data;
310UINT16* tumblepb_mainram;
310static UINT16* tumblepb_mainram;
311311UINT16* jumppop_control;
312312UINT16* suprtrio_control;
313313
r1293r1294
439439
440440
441441
442int tumblep_music_command;
443int tumblep_music_bank;
444int tumbleb2_music_is_playing;
442static int tumblep_music_command;
443static int tumblep_music_bank;
444static int tumbleb2_music_is_playing;
445445
446void tumbleb2_playmusic(void)
446static void tumbleb2_playmusic(void)
447447{
448448   int status = OKIM6295_status_0_r(0);
449449
r1293r1294
458458}
459459
460460
461INTERRUPT_GEN( tumbleb2_interrupt )
461static INTERRUPT_GEN( tumbleb2_interrupt )
462462{
463463   cpunum_set_input_line(0, 6, HOLD_LINE);
464464   tumbleb2_playmusic();
r1293r1294
485485};
486486
487487/* we use channels 1,2,3 for sound effects, and channel 4 for music */
488void tumbleb2_set_music_bank(int bank)
488static void tumbleb2_set_music_bank(int bank)
489489{
490490   UINT8 *oki = memory_region(REGION_SOUND1);
491491   memcpy(&oki[0x38000], &oki[0x80000+0x38000+0x8000*bank],0x8000);
492492}
493493
494void tumbleb2_play_sound (int data)
494static void tumbleb2_play_sound (int data)
495495{
496496   int status = OKIM6295_status_0_r(0);
497497
r1293r1294
524524// bank 7 = how to play?
525525// bank 8 = boss???
526526
527void process_tumbleb2_music_command(int data)
527static void process_tumbleb2_music_command(int data)
528528{
529529   int status = OKIM6295_status_0_r(0);
530530
r1293r1294
852852   {
853853      soundlatch_w(0,data & 0xff);
854854      // needed for Super Trio which reads the sound with polling
855//      cpu_spinuntil_time(MAME_TIME_IN_USEC(100));
856      cpu_boost_interleave(time_zero, MAME_TIME_IN_USEC(20));
855//      cpu_spinuntil_time(ATTOTIME_IN_USEC(100));
856      cpu_boost_interleave(attotime_zero, ATTOTIME_IN_USEC(20));
857857
858858   }
859859}
r1293r1294
20342034   MDRV_CPU_VBLANK_INT(irq6_line_hold,1)
20352035
20362036   MDRV_SCREEN_REFRESH_RATE(58)
2037   MDRV_SCREEN_VBLANK_TIME(USEC_TO_SUBSECONDS(529))
2037   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(529))
20382038
20392039   /* video hardware */
20402040   MDRV_VIDEO_ATTRIBUTES(VIDEO_TYPE_RASTER)
r1293r1294
20642064   MDRV_CPU_VBLANK_INT(tumbleb2_interrupt,1)
20652065
20662066   MDRV_SCREEN_REFRESH_RATE(58)
2067   MDRV_SCREEN_VBLANK_TIME(USEC_TO_SUBSECONDS(529))
2067   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(529))
20682068
20692069   /* video hardware */
20702070   MDRV_VIDEO_ATTRIBUTES(VIDEO_TYPE_RASTER)
r1293r1294
20972097   MDRV_CPU_PROGRAM_MAP(jumpkids_sound_map,0)
20982098
20992099   MDRV_SCREEN_REFRESH_RATE(60)
2100   MDRV_SCREEN_VBLANK_TIME(USEC_TO_SUBSECONDS(529))
2100   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(529))
21012101
21022102   /* video hardware */
21032103   MDRV_VIDEO_ATTRIBUTES(VIDEO_TYPE_RASTER)
r1293r1294
21252125   MDRV_CPU_VBLANK_INT(irq6_line_hold,1)
21262126
21272127   MDRV_SCREEN_REFRESH_RATE(60)
2128   MDRV_SCREEN_VBLANK_TIME(USEC_TO_SUBSECONDS(529))
2128   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(529))
21292129
21302130   /* video hardware */
21312131   MDRV_VIDEO_ATTRIBUTES(VIDEO_TYPE_RASTER)
r1293r1294
21882188   MDRV_CPU_PROGRAM_MAP(semicom_sound_readmem,semicom_sound_writemem)
21892189
21902190   MDRV_SCREEN_REFRESH_RATE(60)
2191   MDRV_SCREEN_VBLANK_TIME(USEC_TO_SUBSECONDS(2400)) // ?? cookbib needs it above ~2400 or the Joystick on the How to Play screen is the wrong colour?!
2191   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(2400)) // ?? cookbib needs it above ~2400 or the Joystick on the How to Play screen is the wrong colour?!
21922192
21932193   MDRV_MACHINE_RESET ( htchctch )
21942194
r1293r1294
22172217   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "right", 1.0)
22182218MACHINE_DRIVER_END
22192219
2220MACHINE_DRIVER_START( cookbib )
2220static MACHINE_DRIVER_START( cookbib )
22212221   MDRV_IMPORT_FROM(htchctch)
22222222   MDRV_VIDEO_UPDATE( semicom_altoffsets )
22232223MACHINE_DRIVER_END
22242224
2225MACHINE_DRIVER_START( bcstory )
2225static MACHINE_DRIVER_START( bcstory )
22262226   MDRV_IMPORT_FROM(htchctch)
22272227   MDRV_VIDEO_UPDATE( bcstory )
22282228
r1293r1294
22322232   MDRV_SOUND_ROUTE(1, "right", 0.10)
22332233MACHINE_DRIVER_END
22342234
2235MACHINE_DRIVER_START( semibase )
2235static MACHINE_DRIVER_START( semibase )
22362236   MDRV_IMPORT_FROM(bcstory)
22372237   MDRV_VIDEO_UPDATE(semibase )
22382238MACHINE_DRIVER_END
22392239
2240MACHINE_DRIVER_START( sdfight )
2240static MACHINE_DRIVER_START( sdfight )
22412241   MDRV_IMPORT_FROM(bcstory)
22422242   MDRV_VIDEO_START(sdfight)
22432243   MDRV_VIDEO_UPDATE(sdfight)
22442244MACHINE_DRIVER_END
22452245
22462246
2247MACHINE_DRIVER_START( metlsavr )
2247static MACHINE_DRIVER_START( metlsavr )
22482248   MDRV_IMPORT_FROM(cookbib)
22492249
22502250   MDRV_SOUND_REPLACE("ym2151", YM2151, 3427190)
r1293r1294
22662266   MDRV_CPU_PERIODIC_INT(nmi_line_pulse, 1953)   /* measured */
22672267
22682268   MDRV_SCREEN_REFRESH_RATE(60)
2269   MDRV_SCREEN_VBLANK_TIME(USEC_TO_SUBSECONDS(529))
2269   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(529))
22702270
22712271   /* video hardware */
22722272   MDRV_VIDEO_ATTRIBUTES(VIDEO_TYPE_RASTER)
r1293r1294
23032303   MDRV_CPU_PROGRAM_MAP(semicom_sound_readmem,semicom_sound_writemem)
23042304
23052305   MDRV_SCREEN_REFRESH_RATE(60)
2306   MDRV_SCREEN_VBLANK_TIME(USEC_TO_SUBSECONDS(529))
2306   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(529))
23072307
23082308   /* video hardware */
23092309   MDRV_VIDEO_ATTRIBUTES(VIDEO_TYPE_RASTER)
r1293r1294
23332333   MDRV_CPU_VBLANK_INT(tumbleb2_interrupt,1)
23342334
23352335   MDRV_SCREEN_REFRESH_RATE(58)
2336   MDRV_SCREEN_VBLANK_TIME(USEC_TO_SUBSECONDS(1529))
2336   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(1529))
23372337
23382338   /* video hardware */
23392339   MDRV_VIDEO_ATTRIBUTES(VIDEO_TYPE_RASTER)
r1293r1294
32793279
32803280/******************************************************************************/
32813281
3282#if TUMBLEP_HACK
32823283void tumblepb_patch_code(UINT16 offset)
32833284{
32843285   /* A hack which enables all Dip Switches effects */
r1293r1294
32863287   RAM[(offset + 0)/2] = 0x0240;
32873288   RAM[(offset + 2)/2] = 0xffff;   // andi.w  #$f3ff, D0
32883289}
3290#endif
32893291
32903292
32913293static void tumblepb_gfx1_rearrange(void)
src/mame/drivers/micro3d.c
r1293r1294
5353#define DRMATH_MONITOR_DISPLAY 0
5454#endif
5555
56UINT16 *micro3d_sprite_vram;
56static UINT16 *micro3d_sprite_vram;
5757static UINT16 *m68681_base;
5858static UINT16 *m68901_base;
5959
r1293r1294
395395   m68901_int_gen(GPIP4);
396396}
397397
398void micro3d_vblank(void)
398static void micro3d_vblank(void)
399399{
400400   m68901_int_gen(GPIP7);
401401}
r1293r1294
405405
406406static TIMER_CALLBACK( timera_int )
407407{
408//      mame_timer_set(scale_up_mame_time(MAME_TIME_IN_HZ(M68901_CLK), ((m68901_base[0xf]>>8) & 0xff) * 200),0,timera_int);     // Set the timer again.
409        mame_timer_set(MAME_TIME_IN_USEC(1000),0,timera_int);     // Set the timer again.
408//      timer_set(attotime_mul(ATTOTIME_IN_HZ(M68901_CLK), ((m68901_base[0xf]>>8) & 0xff) * 200),0,timera_int);     // Set the timer again.
409        timer_set(ATTOTIME_IN_USEC(1000),0,timera_int);     // Set the timer again.
410410        m68901_int_gen(TMRA);           // Fire an interrupt.
411411}
412412
413413#ifdef UNUSED_FUNCTION
414414static TIMER_CALLBACK( timerb_int )
415415{
416        mame_timer_set(scale_up_mame_time(MAME_TIME_IN_HZ(M68901_CLK), ((m68901_base[0x10]>>8) & 0xff) * 200),0,timera_int);
416        timer_set(attotime_mul(ATTOTIME_IN_HZ(M68901_CLK), ((m68901_base[0x10]>>8) & 0xff) * 200),0,timera_int);
417417        m68901_int_gen(TMRB);           // Fire an interrupt.
418418}
419419
420420static TIMER_CALLBACK( timerc_int )
421421{
422        mame_timer_set(scale_up_mame_time(MAME_TIME_IN_HZ(M68901_CLK), ((m68901_base[0x11]>>8) & 0xff) * 200),0,timera_int);
422        timer_set(attotime_mul(ATTOTIME_IN_HZ(M68901_CLK), ((m68901_base[0x11]>>8) & 0xff) * 200),0,timera_int);
423423        m68901_int_gen(TMRC);           // Fire an interrupt.
424424}
425425#endif
426426
427427static TIMER_CALLBACK( timerd_int )
428428{
429        mame_timer_set(MAME_TIME_IN_USEC(250),0,timerd_int);
429        timer_set(ATTOTIME_IN_USEC(250),0,timerd_int);
430430        m68901_int_gen(TMRD);           // Fire an interrupt.
431431}
432432
r1293r1294
473473                      break;
474474
475475        case 0x0f:    mame_printf_debug("Timer A Data:%4x\n",value);                                                       // Timer A Data Register
476                     mame_timer_set(MAME_TIME_IN_USEC(1000),0,timera_int);
476                     timer_set(ATTOTIME_IN_USEC(1000),0,timera_int);
477477                      break;
478478
479479        case 0x10:    mame_printf_debug("Timer B Data:%4x\n",value);                                                           // Timer B Data Register
480//                    mame_timer_set(scale_up_mame_time(MAME_TIME_IN_HZ(M68901_CLK), value * 200),0,timerb_int);
480//                    timer_set(attotime_mul(ATTOTIME_IN_HZ(M68901_CLK), value * 200),0,timerb_int);
481481                      break;
482482
483483        case 0x11:    mame_printf_debug("Timer C Data:%4x\n",value);                                                        // Timer C Data Register
484//                    mame_timer_set(scale_up_mame_time(MAME_TIME_IN_HZ(M68901_CLK), value * 200),0,timerc_int);
484//                    timer_set(attotime_mul(ATTOTIME_IN_HZ(M68901_CLK), value * 200),0,timerc_int);
485485                      break;
486486
487487        case 0x12:    mame_printf_debug("Timer D Data:%4x\n",value);
488                      mame_timer_set(MAME_TIME_IN_USEC(500),0,timerd_int);                 // Timer D Data Register
488                      timer_set(ATTOTIME_IN_USEC(500),0,timerd_int);                 // Timer D Data Register
489489                      break;
490490
491491}
src/mame/drivers/ultratnk.c
r1293r1294
6161      cpunum_set_input_line(0, INPUT_LINE_NMI, PULSE_LINE);
6262   }
6363
64   mame_timer_set(video_screen_get_time_until_pos(0, scanline, 0), scanline, nmi_callback);
64   timer_set(video_screen_get_time_until_pos(0, scanline, 0), scanline, nmi_callback);
6565}
6666
6767
6868static MACHINE_RESET( ultratnk )
6969{
70   mame_timer_set(video_screen_get_time_until_pos(0, 32, 0), 32, nmi_callback);
70   timer_set(video_screen_get_time_until_pos(0, 32, 0), 32, nmi_callback);
7171}
7272
7373
src/mame/drivers/tugboat.c
r1293r1294
2626#include "sound/ay8910.h"
2727
2828
29UINT8 *tugboat_ram,*tugboat_score;
29static UINT8 *tugboat_ram;
30//UINT8 *tugboat_score;
3031
3132
3233static UINT8 hd46505_0_reg[18],hd46505_1_reg[18];
r1293r1294
167168static TIMER_CALLBACK( interrupt_gen )
168169{
169170   cpunum_set_input_line(0, 0, HOLD_LINE);
170   mame_timer_set(video_screen_get_frame_period(0), 0, interrupt_gen);
171   timer_set(video_screen_get_frame_period(0), 0, interrupt_gen);
171172}
172173
173174static MACHINE_START( tugboat )
r1293r1294
179180static MACHINE_RESET( tugboat )
180181{
181182   pia_reset();
182   mame_timer_set(video_screen_get_time_until_pos(0, 30*8+4, 0), 0, interrupt_gen);
183   timer_set(video_screen_get_time_until_pos(0, 30*8+4, 0), 0, interrupt_gen);
183184}
184185
185186
src/mame/drivers/gunbustr.c
r1293r1294
6969
7070static INTERRUPT_GEN( gunbustr_interrupt )
7171{
72   mame_timer_set(MAME_TIME_IN_CYCLES(200000-500,0),0, gunbustr_interrupt5);
72   timer_set(ATTOTIME_IN_CYCLES(200000-500,0),0, gunbustr_interrupt5);
7373   cpunum_set_input_line(0, 4, HOLD_LINE);
7474}
7575
r1293r1294
181181static WRITE32_HANDLER( gunbustr_gun_w )
182182{
183183   /* 10000 cycle delay is arbitrary */
184   mame_timer_set(MAME_TIME_IN_CYCLES(10000,0),0, gunbustr_interrupt5);
184   timer_set(ATTOTIME_IN_CYCLES(10000,0),0, gunbustr_interrupt5);
185185}
186186
187187
src/mame/drivers/taito_z.c
r1293r1294
806806//static UINT16 *motor_ram;
807807
808808static size_t taitoz_sharedram_size;
809UINT16 *taitoz_sharedram;   /* read externally to draw Spacegun crosshair */
809static UINT16 *taitoz_sharedram;   /* read externally to draw Spacegun crosshair */
810810
811811static READ16_HANDLER( sharedram_r )
812812{
r1293r1294
911911   sci_int6 = !sci_int6;
912912
913913   if (sci_int6)
914      mame_timer_set(MAME_TIME_IN_CYCLES(200000-500,0),0, taitoz_interrupt6);
914      timer_set(ATTOTIME_IN_CYCLES(200000-500,0),0, taitoz_interrupt6);
915915   cpunum_set_input_line(0, 4, HOLD_LINE);
916916}
917917
r1293r1294
926926   dblaxle_int6 = !dblaxle_int6;
927927
928928   if (dblaxle_int6)
929      mame_timer_set(MAME_TIME_IN_CYCLES(200000-500,0),0, taitoz_interrupt6);
929      timer_set(ATTOTIME_IN_CYCLES(200000-500,0),0, taitoz_interrupt6);
930930
931931   cpunum_set_input_line(0, 4, HOLD_LINE);
932932}
r1293r1294
934934static INTERRUPT_GEN( dblaxle_cpub_interrupt )
935935{
936936   // Unsure how many int6's per frame
937   mame_timer_set(MAME_TIME_IN_CYCLES(200000-500,0),0, taitoz_interrupt6);
937   timer_set(ATTOTIME_IN_CYCLES(200000-500,0),0, taitoz_interrupt6);
938938   cpunum_set_input_line(2, 4, HOLD_LINE);
939939}
940940
r1293r1294
11751175       but we don't want CPUA to have an int6 before int4 is over (?)
11761176    */
11771177
1178   mame_timer_set(MAME_TIME_IN_CYCLES(10000,0),0, taitoz_interrupt6);
1178   timer_set(ATTOTIME_IN_CYCLES(10000,0),0, taitoz_interrupt6);
11791179}
11801180
11811181
r1293r1294
12581258       Four lightgun interrupts happen before the collected coords
12591259       are moved to shared ram where CPUA can use them. */
12601260
1261   mame_timer_set(MAME_TIME_IN_CYCLES(10000,0),0, taitoz_sg_cpub_interrupt5);
1261   timer_set(ATTOTIME_IN_CYCLES(10000,0),0, taitoz_sg_cpub_interrupt5);
12621262}
12631263
12641264
r1293r1294
29062906   MDRV_VIDEO_UPDATE(chasehq)
29072907
29082908   /* sound hardware */
2909   MDRV_SPEAKER_ADD("front",  0.0, 0.0, 0.7);
2910   MDRV_SPEAKER_ADD("rear",   0.0, 0.0, 1.3);
2909   MDRV_SPEAKER_ADD("front",  0.0, 0.0, 0.7)
2910   MDRV_SPEAKER_ADD("rear",   0.0, 0.0, 1.3)
29112911
29122912   MDRV_SOUND_ADD(YM2610, 16000000/2)
29132913   MDRV_SOUND_CONFIG(ym2610_interface)
r1293r1294
30813081   MDRV_VIDEO_UPDATE(chasehq)
30823082
30833083   /* sound hardware */
3084   MDRV_SPEAKER_ADD("front",  0.0, 0.0, 0.7);
3085   MDRV_SPEAKER_ADD("rear",   0.0, 0.0, 1.3);
3084   MDRV_SPEAKER_ADD("front",  0.0, 0.0, 0.7)
3085   MDRV_SPEAKER_ADD("rear",   0.0, 0.0, 1.3)
30863086
30873087   MDRV_SOUND_ADD(YM2610, 16000000/2)
30883088   MDRV_SOUND_CONFIG(ym2610_interface)
src/mame/drivers/superqix.c
r1293r1294
132132/* pbillian sample playback */
133133static INT16 *samplebuf;
134134
135void pbillian_sh_start(void)
135static void pbillian_sh_start(void)
136136{
137137   UINT8 *src = memory_region(REGION_SOUND1);
138138   int i;
r1293r1294
345345   from_z80 = param;
346346   from_mcu_pending = 0;
347347   cpunum_set_input_line(1, 0, HOLD_LINE);
348   cpu_boost_interleave(time_zero, MAME_TIME_IN_USEC(200));
348   cpu_boost_interleave(attotime_zero, ATTOTIME_IN_USEC(200));
349349}
350350
351351static TIMER_CALLBACK( delayed_mcu_z80_w )
src/mame/drivers/cojag.c
r1293r1294
474474{
475475   /* if a command is still pending, and we haven't maxed out our timer, set a new one */
476476   if (gpu_command_pending && param < 1000)
477      mame_timer_set(MAME_TIME_IN_USEC(50), ++param, gpu_sync_timer);
477      timer_set(ATTOTIME_IN_USEC(50), ++param, gpu_sync_timer);
478478}
479479
480480
r1293r1294
984984};
985985
986986
987MACHINE_DRIVER_START( cojagr3k )
987static MACHINE_DRIVER_START( cojagr3k )
988988
989989   /* basic machine hardware */
990990   MDRV_CPU_ADD(R3000BE, 66000000/2)
r1293r1294
10251025MACHINE_DRIVER_END
10261026
10271027
1028MACHINE_DRIVER_START( r3knarrow )
1028static MACHINE_DRIVER_START( r3knarrow )
10291029   MDRV_IMPORT_FROM(cojagr3k)
10301030
10311031   /* video hardware */
r1293r1294
10331033MACHINE_DRIVER_END
10341034
10351035
1036MACHINE_DRIVER_START( cojag68k )
1036static MACHINE_DRIVER_START( cojag68k )
10371037
10381038   /* basic machine hardware */
10391039   MDRV_CPU_ADD(M68EC020, 50000000/2)
src/mame/drivers/pntnpuzl.c
r1293r1294
180180
181181
182182
183UINT16* pntnpuzl_3a0000ram;
184UINT16* pntnpuzl_bank;
183static UINT16* pntnpuzl_3a0000ram;
184static UINT16* pntnpuzl_bank;
185185/* vid */
186186static VIDEO_START( pntnpuzl )
187187{
r1293r1294
409409ADDRESS_MAP_END
410410
411411
412INTERRUPT_GEN( pntnpuzl_irq )
412static INTERRUPT_GEN( pntnpuzl_irq )
413413{
414414   if (readinputport(0) & 0x02)   /* coin */
415415      cpunum_set_input_line(0, 1, PULSE_LINE);
src/mame/drivers/gijoe.c
r1293r1294
11#define JOE_DEBUG 0
2#define JOE_DMADELAY add_mame_times(MAME_TIME_IN_NSEC(42700), MAME_TIME_IN_NSEC(341300))
2#define JOE_DMADELAY attotime_add(ATTOTIME_IN_NSEC(42700), ATTOTIME_IN_NSEC(341300))
33
44/***************************************************************************
55
r1293r1294
5050static UINT16 *gijoe_workram;
5151static UINT16 cur_control2;
5252static int init_eeprom_count;
53static mame_timer *dmadelay_timer;
53static emu_timer *dmadelay_timer;
5454
5555static struct EEPROM_interface eeprom_interface =
5656{
r1293r1294
172172      gijoe_objdma();
173173
174174      // 42.7us(clr) + 341.3us(xfer) delay at 6Mhz dotclock
175      mame_timer_adjust(dmadelay_timer, JOE_DMADELAY, 0, time_zero);
175      timer_adjust(dmadelay_timer, JOE_DMADELAY, 0, attotime_zero);
176176   }
177177
178178   // trigger V-blank interrupt
r1293r1294
207207{
208208   state_save_register_global(cur_control2);
209209
210   dmadelay_timer = mame_timer_alloc(dmaend_callback);
210   dmadelay_timer = timer_alloc(dmaend_callback);
211211}
212212
213213
src/mame/drivers/wilytowr.c
r1293r1294
2929extern void fghtbskt_sh_start(void);
3030extern WRITE8_HANDLER( fghtbskt_samples_w );
3131
32UINT8 *wilytowr_videoram2, *wilytowr_scrollram;
32static UINT8 *wilytowr_videoram2, *wilytowr_scrollram;
3333
3434static int pal_bank, fg_flag, sy_offset;
3535
src/mame/drivers/looping.c
r1293r1294
302302 *
303303 *************************************/
304304
305INTERRUPT_GEN( looping_interrupt )
305static INTERRUPT_GEN( looping_interrupt )
306306{
307307   cpunum_set_input_line_and_vector(0, 0, ASSERT_LINE, 4);
308308}
r1293r1294
329329}
330330
331331
332void looping_spcint(int state)
332static void looping_spcint(int state)
333333{
334334   cpunum_set_input_line_and_vector(1, 0, state, 6);
335335}
src/mame/drivers/segas32.c
r1293r1294
348348
349349/* V60 interrupt controller */
350350static UINT8 v60_irq_control[0x10];
351static mame_timer *v60_irq_timer[2];
351static emu_timer *v60_irq_timer[2];
352352
353353/* sound interrupt controller */
354354static UINT8 sound_irq_control[4];
r1293r1294
392392   memset(v60_irq_control, 0xff, sizeof(v60_irq_control));
393393
394394   /* allocate timers */
395   v60_irq_timer[0] = mame_timer_alloc(signal_v60_irq_callback);
396   v60_irq_timer[1] = mame_timer_alloc(signal_v60_irq_callback);
395   v60_irq_timer[0] = timer_alloc(signal_v60_irq_callback);
396   v60_irq_timer[1] = timer_alloc(signal_v60_irq_callback);
397397
398398   /* clear IRQ lines */
399399   cpunum_set_input_line(0, 0, CLEAR_LINE);
r1293r1294
480480         duration = v60_irq_control[8] + ((v60_irq_control[9] << 8) & 0xf00);
481481         if (duration)
482482         {
483            mame_time period = make_mame_time(0, mame_time_to_subseconds(MAME_TIME_IN_HZ(TIMER_0_CLOCK)) * duration);
484            mame_timer_adjust(v60_irq_timer[0], period, MAIN_IRQ_TIMER0, time_never);
483            attotime period = attotime_make(0, attotime_to_attoseconds(ATTOTIME_IN_HZ(TIMER_0_CLOCK)) * duration);
484            timer_adjust(v60_irq_timer[0], period, MAIN_IRQ_TIMER0, attotime_never);
485485         }
486486         break;
487487
r1293r1294
491491         duration = v60_irq_control[10] + ((v60_irq_control[11] << 8) & 0xf00);
492492         if (duration)
493493         {
494            mame_time period = make_mame_time(0, mame_time_to_subseconds(MAME_TIME_IN_HZ(TIMER_1_CLOCK)) * duration);
495            mame_timer_adjust(v60_irq_timer[1], period, MAIN_IRQ_TIMER1, time_never);
494            attotime period = attotime_make(0, attotime_to_attoseconds(ATTOTIME_IN_HZ(TIMER_1_CLOCK)) * duration);
495            timer_adjust(v60_irq_timer[1], period, MAIN_IRQ_TIMER1, attotime_never);
496496         }
497497         break;
498498
r1293r1294
571571{
572572   signal_v60_irq(MAIN_IRQ_VBSTART);
573573   system32_set_vblank(1);
574   mame_timer_set(video_screen_get_time_until_pos(0, 0, 0), 0, end_of_vblank_int);
574   timer_set(video_screen_get_time_until_pos(0, 0, 0), 0, end_of_vblank_int);
575575   if (system32_prot_vblank)
576576      (*system32_prot_vblank)();
577577}
src/mame/drivers/darkhors.c
r1293r1294
7070static VIDEO_UPDATE( darkhors );
7171
7272static tilemap *darkhors_tmap, *darkhors_tmap2;
73UINT32 *darkhors_tmapram,  *darkhors_tmapscroll;
74UINT32 *darkhors_tmapram2, *darkhors_tmapscroll2;
73static UINT32 *darkhors_tmapram,  *darkhors_tmapscroll;
74static UINT32 *darkhors_tmapram2, *darkhors_tmapscroll2;
7575
7676static TILE_GET_INFO( get_tile_info_0 )
7777{
src/mame/drivers/mpatrol.c
r1293r1294
411411   MDRV_CPU_VBLANK_INT(irq0_line_hold,1)
412412
413413   MDRV_SCREEN_REFRESH_RATE(57)
414   MDRV_SCREEN_VBLANK_TIME(USEC_TO_SUBSECONDS(1790)   /* accurate frequency, measured on a real board, is 56.75Hz. */)
414   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(1790)   /* accurate frequency, measured on a real board, is 56.75Hz. */)
415415            /* the Lode Runner manual (similar but different hardware) */
416416            /* talks about 55Hz and 1790ms vblank duration. */
417417
r1293r1294
442442   MDRV_CPU_VBLANK_INT(irq0_line_hold,1)
443443
444444   MDRV_SCREEN_REFRESH_RATE(57)
445   MDRV_SCREEN_VBLANK_TIME(USEC_TO_SUBSECONDS(1790)   /* accurate frequency, measured on a real board, is 56.75Hz. */)
445   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(1790)   /* accurate frequency, measured on a real board, is 56.75Hz. */)
446446            /* the Lode Runner manual (similar but different hardware) */
447447            /* talks about 55Hz and 1790ms vblank duration. */
448448
src/mame/drivers/upscope.c
r1293r1294
293293   MDRV_CPU_VBLANK_INT(amiga_scanline_callback, 262)
294294
295295   MDRV_SCREEN_REFRESH_RATE(59.997)
296   MDRV_SCREEN_VBLANK_TIME(USEC_TO_SUBSECONDS(0))
296   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(0))
297297
298298   MDRV_MACHINE_RESET(amiga)
299299   MDRV_NVRAM_HANDLER(generic_0fill)
src/mame/drivers/equites.c
r1293r1294
243243int equites_flip;
244244
245245// Splendor Blast Hardware
246int splndrbt_flip;
246static int splndrbt_flip;
247247
248248/******************************************************************************/
249249// Local Functions
r1293r1294
691691   MDRV_CPU_VBLANK_INT(equites_interrupt, 2)
692692
693693   MDRV_SCREEN_REFRESH_RATE(60)
694   MDRV_SCREEN_VBLANK_TIME(USEC_TO_SUBSECONDS(600))
694   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(600))
695695
696696   /* video hardware */
697697   MDRV_VIDEO_ATTRIBUTES(VIDEO_TYPE_RASTER | VIDEO_UPDATE_AFTER_VBLANK)
r1293r1294
718718   MDRV_CPU_VBLANK_INT(splndrbt_interrupt, 2)
719719
720720   MDRV_SCREEN_REFRESH_RATE(60)
721   MDRV_SCREEN_VBLANK_TIME(USEC_TO_SUBSECONDS(600))
721   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(600))
722722   MDRV_MACHINE_RESET(splndrbt)
723723
724724   /* video hardware */
src/mame/drivers/esh.c
r1293r1294
274274{
275275   // IRQ
276276   cpunum_set_input_line(0, 0, ASSERT_LINE);
277   mame_timer_set(MAME_TIME_IN_USEC(50), 0, irq_stop);
277   timer_set(ATTOTIME_IN_USEC(50), 0, irq_stop);
278278
279279   laserdisc_vsync(discinfo);
280280}
src/mame/drivers/neodrvr.c
r1293r1294
67536753static DRIVER_INIT( svcpcb )
67546754{
67556755   /* start a timer that will check the BIOS select DIP every second */
6756   mame_timer_pulse(MAME_TIME_IN_MSEC(1000), 0, svcpcb_bios_timer_callback);
6756   timer_pulse(ATTOTIME_IN_MSEC(1000), 0, svcpcb_bios_timer_callback);
67576757   svcpcb_bios_timer_callback(machine, 0);
67586758
67596759   svcchaos_px_decrypt();
src/mame/drivers/decocass.c
r1293r1294
391391   MDRV_CPU_IO_MAP(decocass_mcu_portmap,0)
392392
393393   MDRV_SCREEN_REFRESH_RATE(57)
394   MDRV_SCREEN_VBLANK_TIME(USEC_TO_SUBSECONDS(3072)      /* frames per second, vblank duration */)
394   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(3072)      /* frames per second, vblank duration */)
395395   MDRV_INTERLEAVE(7)            /* interleave CPUs */
396396
397397   MDRV_MACHINE_RESET(decocass)
src/mame/drivers/mystwarr.c
r1293r1294
937937   MDRV_CPU_PROGRAM_MAP(sound_readmem,sound_writemem)
938938   MDRV_CPU_PERIODIC_INT(nmi_line_pulse, 480)
939939
940   MDRV_INTERLEAVE(32);
940   MDRV_INTERLEAVE(32)
941941   MDRV_SCREEN_REFRESH_RATE(60)
942   MDRV_SCREEN_VBLANK_TIME(USEC_TO_SUBSECONDS(600))
942   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(600))
943943
944944   MDRV_NVRAM_HANDLER(mystwarr)
945945   MDRV_MACHINE_START(mystwarr)
r1293r1294
978978   MDRV_CPU_MODIFY("main")
979979   MDRV_CPU_PROGRAM_MAP(vsreadmem,vswritemem)
980980   MDRV_CPU_VBLANK_INT(metamrph_interrupt, 40)
981   MDRV_SCREEN_VBLANK_TIME(USEC_TO_SUBSECONDS(900))
981   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(900))
982982
983983   /* video hardware */
984984   MDRV_VIDEO_START(viostorm)
r1293r1294
996996   MDRV_CPU_MODIFY("main")
997997   MDRV_CPU_PROGRAM_MAP(mmreadmem,mmwritemem)
998998   MDRV_CPU_VBLANK_INT(metamrph_interrupt, 40)
999   MDRV_SCREEN_VBLANK_TIME(USEC_TO_SUBSECONDS(900))
999   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(900))
10001000
10011001   /* video hardware */
10021002   MDRV_VIDEO_START(metamrph)
r1293r1294
10141014   MDRV_CPU_MODIFY("main")
10151015   MDRV_CPU_PROGRAM_MAP(dddreadmem, dddwritemem)
10161016   MDRV_CPU_VBLANK_INT(ddd_interrupt, 1)
1017   MDRV_SCREEN_VBLANK_TIME(USEC_TO_SUBSECONDS(600))
1017   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(600))
10181018
10191019   MDRV_GFXDECODE(dadandrn)
10201020
r1293r1294
10341034   MDRV_CPU_MODIFY("main")
10351035   MDRV_CPU_PROGRAM_MAP(gaiareadmem,gaiawritemem)
10361036   MDRV_CPU_VBLANK_INT(ddd_interrupt, 1)
1037   MDRV_SCREEN_VBLANK_TIME(USEC_TO_SUBSECONDS(600))
1037   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(600))
10381038
10391039   MDRV_GFXDECODE(gaiapols)
10401040
r1293r1294
10561056   MDRV_CPU_MODIFY("main")
10571057   MDRV_CPU_PROGRAM_MAP(mcreadmem,mcwritemem)
10581058   MDRV_CPU_VBLANK_INT(mchamp_interrupt, 2)
1059   MDRV_SCREEN_VBLANK_TIME(USEC_TO_SUBSECONDS(0))
1059   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(0))
10601060
10611061   MDRV_VIDEO_ATTRIBUTES(VIDEO_TYPE_RASTER | VIDEO_HAS_SHADOWS | VIDEO_HAS_HIGHLIGHTS | VIDEO_UPDATE_BEFORE_VBLANK)
10621062   MDRV_SCREEN_FORMAT(BITMAP_FORMAT_RGB32)
src/mame/drivers/dlair.c
r1293r1294
318318   if (sndti_exists(SOUND_BEEP, 0))
319319   {
320320      beep_set_state(0, 1);
321      beep_set_frequency(0, SUBSECONDS_TO_HZ(z80ctc_getperiod(0, 0).subseconds));
321      beep_set_frequency(0, ATTOSECONDS_TO_HZ(z80ctc_getperiod(0, 0).attoseconds));
322322   }
323323}
324324
r1293r1294
844844   MDRV_CPU_IO_MAP(dleuro_io_map,0)
845845   MDRV_CPU_VBLANK_INT(vblank_callback, 1)
846846
847   MDRV_WATCHDOG_TIME_INIT(MAME_TIME_IN_HZ(MASTER_CLOCK_EURO/(16*16*16*16*16*8)))
847   MDRV_WATCHDOG_TIME_INIT(ATTOTIME_IN_HZ(MASTER_CLOCK_EURO/(16*16*16*16*16*8)))
848848
849849   MDRV_MACHINE_START(dleuro)
850850   MDRV_MACHINE_RESET(dlair)
src/mame/drivers/halleys.c
r1293r1294
212212
213213static int game_id, blitter_busy, collision_count, stars_enabled, bgcolor, ffcount, ffhead, fftail;
214214static int mVectorType, sndnmi_mask, firq_level;
215static mame_timer *blitter_reset_timer;
215static emu_timer *blitter_reset_timer;
216216
217217static offs_t halleys_collision_detection;
218218
r1293r1294
10061006      else
10071007      {
10081008         blitter_busy = 1;
1009         mame_timer_adjust(blitter_reset_timer, MAME_TIME_IN_CYCLES(100, 0), 0, time_zero); // free blitter if no updates in 100 cycles
1009         timer_adjust(blitter_reset_timer, ATTOTIME_IN_CYCLES(100, 0), 0, attotime_zero); // free blitter if no updates in 100 cycles
10101010      }
10111011   }
10121012}
r1293r1294
22282228
22292229   init_common();
22302230
2231   blitter_reset_timer = mame_timer_alloc(blitter_reset);
2231   blitter_reset_timer = timer_alloc(blitter_reset);
22322232}
22332233
22342234
src/mame/drivers/ssfindo.c
r1293r1294
216216static void PS7500_startTimer0(void);
217217static void PS7500_startTimer1(void);
218218
219static mame_timer *PS7500timer0;
220static mame_timer *PS7500timer1;
219static emu_timer *PS7500timer0;
220static emu_timer *PS7500timer1;
221221
222222
223223static VIDEO_UPDATE(ssfindo)
r1293r1294
267267   int val=((PS7500_IO[T0low]&0xff)|((PS7500_IO[T0high]&0xff)<<8))>>1;
268268
269269   if(val==0)
270      mame_timer_adjust(PS7500timer0, time_never, 0, time_never);
270      timer_adjust(PS7500timer0, attotime_never, 0, attotime_never);
271271   else
272      mame_timer_adjust(PS7500timer0, MAME_TIME_IN_USEC(val ), 0, MAME_TIME_IN_USEC(val ));
272      timer_adjust(PS7500timer0, ATTOTIME_IN_USEC(val ), 0, ATTOTIME_IN_USEC(val ));
273273}
274274
275275static TIMER_CALLBACK( PS7500_Timer1_callback )
r1293r1294
285285{
286286   int val=((PS7500_IO[T1low]&0xff)|((PS7500_IO[T1high]&0xff)<<8))>>1;
287287   if(val==0)
288      mame_timer_adjust(PS7500timer1, time_never, 0, time_never);
288      timer_adjust(PS7500timer1, attotime_never, 0, attotime_never);
289289   else
290      mame_timer_adjust(PS7500timer1, MAME_TIME_IN_USEC(val ), 0, MAME_TIME_IN_USEC(val ));
290      timer_adjust(PS7500timer1, ATTOTIME_IN_USEC(val ), 0, ATTOTIME_IN_USEC(val ));
291291}
292292
293293static INTERRUPT_GEN( ssfindo_interrupt )
r1293r1294
304304      PS7500_IO[IOCR]         =   0x3f;
305305      PS7500_IO[VIDCR]      =   0;
306306
307      mame_timer_adjust( PS7500timer0, time_never, 0, time_never);
308      mame_timer_adjust( PS7500timer1, time_never, 0, time_never);
307      timer_adjust( PS7500timer0, attotime_never, 0, attotime_never);
308      timer_adjust( PS7500timer1, attotime_never, 0, attotime_never);
309309}
310310
311311static READ32_HANDLER(PS7500_IO_r)
r1293r1294
705705static DRIVER_INIT(ssfindo)
706706{
707707   flashType=0;
708   PS7500timer0 = mame_timer_alloc(PS7500_Timer0_callback);
709   PS7500timer1 = mame_timer_alloc(PS7500_Timer1_callback);
708   PS7500timer0 = timer_alloc(PS7500_Timer0_callback);
709   PS7500timer1 = timer_alloc(PS7500_Timer1_callback);
710710}
711711
712712static DRIVER_INIT(ppcar)
713713{
714714   flashType=1;
715   PS7500timer0 = mame_timer_alloc(PS7500_Timer0_callback);
716   PS7500timer1 = mame_timer_alloc(PS7500_Timer1_callback);
715   PS7500timer0 = timer_alloc(PS7500_Timer0_callback);
716   PS7500timer1 = timer_alloc(PS7500_Timer1_callback);
717717}
718718
719719GAME( 1999, ssfindo, 0,        ssfindo,  ssfindo,  ssfindo, ROT0, "Icarus", "See See Find Out", GAME_NO_SOUND )
src/mame/drivers/firetrk.c
r1293r1294
9999      scanline = 0;
100100   }
101101
102   mame_timer_set(video_screen_get_time_until_pos(0, scanline, 0), scanline, periodic_callback);
102   timer_set(video_screen_get_time_until_pos(0, scanline, 0), scanline, periodic_callback);
103103}
104104
105105
r1293r1294
223223
224224static MACHINE_RESET( firetrk )
225225{
226   mame_timer_pulse(video_screen_get_frame_period(0), 0, frame_callback);
226   timer_pulse(video_screen_get_frame_period(0), 0, frame_callback);
227227
228228   if (GAME_IS_MONTECARLO)
229229   {
src/mame/drivers/peplus.c
r1293r1294
9191* NVRAM Handlers *
9292******************/
9393
94NVRAM_HANDLER( peplus )
94static NVRAM_HANDLER( peplus )
9595{
9696   if (read_or_write)
9797   {
src/mame/drivers/mustache.c
r1293r1294
189189static void assert_irq(void)
190190{
191191   cpunum_set_input_line(0, 0, ASSERT_LINE);
192   mame_timer_set(MAME_TIME_IN_CYCLES(14288, 0), 0, clear_irq_cb);
192   timer_set(ATTOTIME_IN_CYCLES(14288, 0), 0, clear_irq_cb);
193193       /* Timing here is an educated GUESS, Z80 /INT must stay high so the irq
194194          fires no less than TWICE per frame, else game doesn't work right.
195195      6000000 / 56.747 = 105732.4616 cycles per frame, we'll call it A
src/mame/drivers/segas16a.c
r1293r1294
421421    */
422422   cpunum_set_input_line(2, INPUT_LINE_RESET, (data & 0x01) ? CLEAR_LINE : ASSERT_LINE);
423423   cpunum_set_input_line(2, 0, (data & 0x02) ? CLEAR_LINE : ASSERT_LINE);
424   cpu_boost_interleave(time_zero, MAME_TIME_IN_USEC(100));
424   cpu_boost_interleave(attotime_zero, ATTOTIME_IN_USEC(100));
425425}
426426
427427
src/mame/drivers/neogeo.c
r1293r1294
104104static UINT32 vblank_interrupt_pending;
105105static UINT32 display_position_interrupt_pending;
106106static UINT32 irq3_pending;
107static mame_timer *display_position_interrupt_timer;
108static mame_timer *display_position_vblank_timer;
109static mame_timer *vblank_interrupt_timer;
107static emu_timer *display_position_interrupt_timer;
108static emu_timer *display_position_vblank_timer;
109static emu_timer *vblank_interrupt_timer;
110110
111111static UINT8 controller_select;
112112
r1293r1294
159159{
160160   if ((display_counter + 1) != 0)
161161   {
162      mame_time period = scale_up_mame_time(MAME_TIME_IN_HZ(NEOGEO_PIXEL_CLOCK), display_counter + 1);
162      attotime period = attotime_mul(ATTOTIME_IN_HZ(NEOGEO_PIXEL_CLOCK), display_counter + 1);
163163      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(0), video_screen_get_hpos(0), (display_counter + 1) / NEOGEO_HTOTAL, (display_counter + 1) % NEOGEO_HTOTAL);
164164
165      mame_timer_adjust(display_position_interrupt_timer, period, 0, time_zero);
165      timer_adjust(display_position_interrupt_timer, period, 0, attotime_zero);
166166   }
167167}
168168
r1293r1294
250250   }
251251
252252   /* set timer for next screen */
253   mame_timer_adjust(display_position_vblank_timer, video_screen_get_time_until_pos(0, NEOGEO_VBSTART, NEOGEO_VBLANK_RELOAD_HPOS), 0, time_zero);
253   timer_adjust(display_position_vblank_timer, video_screen_get_time_until_pos(0, NEOGEO_VBSTART, NEOGEO_VBLANK_RELOAD_HPOS), 0, attotime_zero);
254254}
255255
256256
r1293r1294
266266   update_interrupts();
267267
268268   /* set timer for next screen */
269   mame_timer_adjust(vblank_interrupt_timer, video_screen_get_time_until_pos(0, NEOGEO_VBSTART, 0), 0, time_zero);
269   timer_adjust(vblank_interrupt_timer, video_screen_get_time_until_pos(0, NEOGEO_VBSTART, 0), 0, attotime_zero);
270270}
271271
272272
273273static void create_interrupt_timers(void)
274274{
275   display_position_interrupt_timer = mame_timer_alloc(display_position_interrupt_callback);
276   display_position_vblank_timer = mame_timer_alloc(display_position_vblank_callback);
277   vblank_interrupt_timer = mame_timer_alloc(vblank_interrupt_callback);
275   display_position_interrupt_timer = timer_alloc(display_position_interrupt_callback);
276   display_position_vblank_timer = timer_alloc(display_position_vblank_callback);
277   vblank_interrupt_timer = timer_alloc(vblank_interrupt_callback);
278278}
279279
280280
281281static void start_interrupt_timers(void)
282282{
283   mame_timer_adjust(vblank_interrupt_timer, video_screen_get_time_until_pos(0, NEOGEO_VBSTART, 0), 0, time_zero);
284   mame_timer_adjust(display_position_vblank_timer, video_screen_get_time_until_pos(0, NEOGEO_VBSTART, NEOGEO_VBLANK_RELOAD_HPOS), 0, time_zero);
283   timer_adjust(vblank_interrupt_timer, video_screen_get_time_until_pos(0, NEOGEO_VBSTART, 0), 0, attotime_zero);
284   timer_adjust(display_position_vblank_timer, video_screen_get_time_until_pos(0, NEOGEO_VBSTART, NEOGEO_VBLANK_RELOAD_HPOS), 0, attotime_zero);
285285}
286286
287287
r1293r1294
566566      audio_cpu_assert_nmi();
567567
568568      /* boost the interleave to let the audio CPU read the command */
569      cpu_boost_interleave(time_zero, MAME_TIME_IN_USEC(50));
569      cpu_boost_interleave(attotime_zero, ATTOTIME_IN_USEC(50));
570570
571571      if (LOG_CPU_COMM) logerror("MAIN CPU PC %06x: audio_command_w %04x - %04x\n", activecpu_get_pc(), data, mem_mask);
572572   }
r1293r1294
12301230   MDRV_CPU_PROGRAM_MAP(audio_map,0)
12311231   MDRV_CPU_IO_MAP(auido_io_map,0)
12321232
1233   MDRV_WATCHDOG_TIME_INIT(MAME_TIME_IN_USEC(128762))
1233   MDRV_WATCHDOG_TIME_INIT(ATTOTIME_IN_USEC(128762))
12341234
12351235   MDRV_MACHINE_START(neogeo)
12361236   MDRV_MACHINE_RESET(neogeo)
src/mame/drivers/konamigx.c
r1293r1294
131131WRITE32_HANDLER( konamigx_t1_psacmap_w );
132132WRITE32_HANDLER( konamigx_t4_psacmap_w );
133133
134int konamigx_cfgport;
134static int konamigx_cfgport;
135135
136136static UINT32 *gx_workram; /* workram pointer for ESC protection fun */
137137static UINT16 *gx_sndram;
138138static int gx_rdport1_3, gx_syncen;
139139
140static mame_timer *dmadelay_timer;
140static emu_timer *dmadelay_timer;
141141
142142/**********************************************************************************/
143143/*
r1293r1294
682682   }
683683
684684   // simulate DMA delay
685   mame_timer_adjust(dmadelay_timer, MAME_TIME_IN_USEC(120), 0, time_zero);
685   timer_adjust(dmadelay_timer, ATTOTIME_IN_USEC(120), 0, attotime_zero);
686686}
687687
688688
r1293r1294
864864   adc083x_cs_write( 0, ( data >> 26 ) & 1 );
865865}
866866
867double adc0834_callback( int input )
867static double adc0834_callback( int input )
868868{
869869   switch( input )
870870   {
r1293r1294
13221322   MDRV_CPU_PROGRAM_MAP(gxsndmap, 0)
13231323   MDRV_CPU_PERIODIC_INT(irq2_line_hold, 480)
13241324
1325   MDRV_INTERLEAVE(32);
1325   MDRV_INTERLEAVE(32)
13261326   MDRV_SCREEN_REFRESH_RATE(60)
1327   MDRV_SCREEN_VBLANK_TIME(USEC_TO_SUBSECONDS(600))
1327   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(600))
13281328
13291329   MDRV_MACHINE_START(konamigx)
13301330   MDRV_MACHINE_RESET(konamigx)
r1293r1294
35263526   snd020_hack = 0;
35273527   resume_trigger = 0;
35283528
3529   dmadelay_timer = mame_timer_alloc(dmaend_callback);
3529   dmadelay_timer = timer_alloc(dmaend_callback);
35303530
35313531   i = match = 0;
35323532   while ((gameDefs[i].cfgport != -1) && (!match))
src/mame/drivers/statriv2.c
r1293r1294
6565/* Default NVram, we seem to need one or statriv2 crashes during attract
6666   attempting to display an unterminated message */
6767
68UINT8 statriv2_default_eeprom[256] = {
68static UINT8 statriv2_default_eeprom[256] = {
6969   0x24,0x00,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
7070   0x00,0x00,0x00,0x00,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x00,0x00,0x11,0x00,
7171   0x00,0x00,0x00,0x00,0x01,0x02,0x01,0x05,0x00,0x00,0x11,0x49,0x41,0x41,0x00,0x00,
r1293r1294
8484   0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
8585};
8686
87UINT8 quaquiz2_default_eeprom[256] = {
87static UINT8 quaquiz2_default_eeprom[256] = {
8888   0x6f,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
8989   0x00,0x00,0x02,0x00,0x10,0x00,0x10,0x00,0x00,0x00,0x00,0x00,0xa5,0x6e,0x03,0xff,
9090   0x50,0x03,0xff,0xa0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
r1293r1294
103103   0x20,0x49,0x49,0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
104104};
105105
106UINT8 *statriv2_videoram;
106static UINT8 *statriv2_videoram;
107107static tilemap* statriv2_tilemap;
108108
109109/* Video Related, move to video later */
src/mame/drivers/carrera.c
r1293r1294
4545#include "sound/ay8910.h"
4646#include "video/crtc6845.h"
4747
48UINT8* carrera_tileram;
48static UINT8* carrera_tileram;
4949
5050static ADDRESS_MAP_START( readmem, ADDRESS_SPACE_PROGRAM, 8 )
5151   AM_RANGE(0x0000, 0x4fff) AM_READ(MRA8_ROM)
src/mame/drivers/thunderj.c
r1293r1294
120120static TIMER_CALLBACK( shared_sync_callback )
121121{
122122   if (--param)
123      mame_timer_set(MAME_TIME_IN_USEC(50), param, shared_sync_callback);
123      timer_set(ATTOTIME_IN_USEC(50), param, shared_sync_callback);
124124}
125125
126126
src/mame/drivers/parodius.c
r1293r1294
122122{
123123//  sound_nmi_enabled = 1;
124124   cpunum_set_input_line(1, INPUT_LINE_NMI, CLEAR_LINE);
125   mame_timer_set(MAME_TIME_IN_USEC(50),0,nmi_callback);   /* kludge until the K053260 is emulated correctly */
125   timer_set(ATTOTIME_IN_USEC(50),0,nmi_callback);   /* kludge until the K053260 is emulated correctly */
126126}
127127
128128/********************************************/
src/mame/drivers/combatsc.c
r1293r1294
231231   /* unknown. always write 0 */
232232}
233233
234static mame_timer *combasc_interleave_timer;
234static emu_timer *combasc_interleave_timer;
235235
236236static READ8_HANDLER ( combasc_YM2203_status_port_0_r )
237237{
r1293r1294
243243      if (boost)
244244      {
245245         boost = 0;
246         mame_timer_adjust(combasc_interleave_timer, time_zero, 0, MAME_TIME_IN_CYCLES(80,1));
246         timer_adjust(combasc_interleave_timer, attotime_zero, 0, ATTOTIME_IN_CYCLES(80,1));
247247      }
248248      else if (status & 2)
249249      {
250250         boost = 1;
251         mame_timer_adjust(combasc_interleave_timer, time_zero, 0, time_never);
251         timer_adjust(combasc_interleave_timer, attotime_zero, 0, attotime_never);
252252      }
253253   }
254254
r1293r1294
904904
905905static void combasc_init_common(void)
906906{
907   combasc_interleave_timer = mame_timer_alloc(NULL);
907   combasc_interleave_timer = timer_alloc(NULL);
908908}
909909
910910static DRIVER_INIT( combasct )
src/mame/drivers/stvinit.c
r1293r1294
1616extern int stv_enable_slave_sh2;
1717
1818extern int minit_boost,sinit_boost;
19extern mame_time minit_boost_timeslice, sinit_boost_timeslice;
19extern attotime minit_boost_timeslice, sinit_boost_timeslice;
2020
2121DRIVER_INIT ( stv );
2222
r1293r1294
203203static READ32_HANDLER( shienryu_slave_speedup_r )
204204{
205205 if (activecpu_get_pc()==0x06004410)
206  cpu_spinuntil_time(MAME_TIME_IN_USEC(20)); // is this safe... we can't skip till vbl because its not a vbl wait loop
206  cpu_spinuntil_time(ATTOTIME_IN_USEC(20)); // is this safe... we can't skip till vbl because its not a vbl wait loop
207207
208208 return stv_workram_h[0x0ae8e4/4];
209209}
r1293r1294
255255   driver_init_stv(machine);
256256
257257   minit_boost = sinit_boost = 0;
258   minit_boost_timeslice = sinit_boost_timeslice = MAME_TIME_IN_USEC(50);
258   minit_boost_timeslice = sinit_boost_timeslice = ATTOTIME_IN_USEC(50);
259259
260260}
261261
r1293r1294
321321
322322static READ32_HANDLER( puyosun_speedup_r )
323323{
324   if (activecpu_get_pc()==0x6021CF2) cpu_spinuntil_time(MAME_TIME_IN_USEC(400)); // spinuntilint breaks controls again .. urgh
324   if (activecpu_get_pc()==0x6021CF2) cpu_spinuntil_time(ATTOTIME_IN_USEC(400)); // spinuntilint breaks controls again .. urgh
325325
326326
327327   return stv_workram_h[0x0ffc10/4];
r1293r1294
342342   driver_init_ic13(machine);
343343
344344   minit_boost = sinit_boost = 0;
345   minit_boost_timeslice = sinit_boost_timeslice = MAME_TIME_IN_USEC(50);
345   minit_boost_timeslice = sinit_boost_timeslice = ATTOTIME_IN_USEC(50);
346346}
347347
348348/* mausuke
r1293r1294
357357
358358static READ32_HANDLER( mausuke_speedup_r )
359359{
360   if (activecpu_get_pc()==0x060461A2) cpu_spinuntil_time(MAME_TIME_IN_USEC(20)); // spinuntilint breaks controls again .. urgh
360   if (activecpu_get_pc()==0x060461A2) cpu_spinuntil_time(ATTOTIME_IN_USEC(20)); // spinuntilint breaks controls again .. urgh
361361
362362   return stv_workram_h[0x0ffc10/4];
363363}
r1293r1294
369369   driver_init_ic13(machine);
370370
371371   minit_boost = sinit_boost = 0;
372   minit_boost_timeslice = sinit_boost_timeslice = MAME_TIME_IN_USEC(50);
372   minit_boost_timeslice = sinit_boost_timeslice = ATTOTIME_IN_USEC(50);
373373}
374374
375375static READ32_HANDLER( cottonbm_speedup_r )
376376{
377   if (activecpu_get_pc()==0x06030EE4) cpu_spinuntil_time(MAME_TIME_IN_USEC(20)); // spinuntilint breaks lots of things
377   if (activecpu_get_pc()==0x06030EE4) cpu_spinuntil_time(ATTOTIME_IN_USEC(20)); // spinuntilint breaks lots of things
378378
379379   return stv_workram_h[0x0ffc10/4];
380380}
r1293r1294
406406
407407   driver_init_stv(machine);
408408
409   minit_boost_timeslice = sinit_boost_timeslice = MAME_TIME_IN_USEC(10);
409   minit_boost_timeslice = sinit_boost_timeslice = ATTOTIME_IN_USEC(10);
410410}
411411
412412static READ32_HANDLER( cotton2_speedup_r )
413413{
414   if (activecpu_get_pc()==0x06031c7c) cpu_spinuntil_time(MAME_TIME_IN_USEC(20)); // spinuntilint breaks lots of things
414   if (activecpu_get_pc()==0x06031c7c) cpu_spinuntil_time(ATTOTIME_IN_USEC(20)); // spinuntilint breaks lots of things
415415
416416   return stv_workram_h[0x0ffc10/4];
417417}
r1293r1294
442442
443443   driver_init_stv(machine);
444444
445   minit_boost_timeslice = sinit_boost_timeslice = MAME_TIME_IN_USEC(50);
445   minit_boost_timeslice = sinit_boost_timeslice = ATTOTIME_IN_USEC(50);
446446}
447447
448448static int dnmtdeka_pending_commands;
449449
450450static READ32_HANDLER( dnmtdeka_speedup_r )
451451{
452   if (activecpu_get_pc()==0x6027c92) cpu_spinuntil_int();//cpu_spinuntil_time(MAME_TIME_IN_USEC(20));
452   if (activecpu_get_pc()==0x6027c92) cpu_spinuntil_int();//cpu_spinuntil_time(ATTOTIME_IN_USEC(20));
453453   return stv_workram_h[0x0985a0/4];
454454}
455455
r1293r1294
575575
576576static READ32_HANDLER( fhboxers_speedup_r )
577577{
578   if (activecpu_get_pc()==0x060041c4) cpu_spinuntil_time(MAME_TIME_IN_USEC(20));
578   if (activecpu_get_pc()==0x060041c4) cpu_spinuntil_time(ATTOTIME_IN_USEC(20));
579579
580580   return stv_workram_h[0x00420c/4];
581581}
582582
583583static READ32_HANDLER( fhboxers_speedup2_r )
584584{
585   if (activecpu_get_pc()==0x0600bb0c) cpu_spinuntil_time(MAME_TIME_IN_USEC(20));
585   if (activecpu_get_pc()==0x0600bb0c) cpu_spinuntil_time(ATTOTIME_IN_USEC(20));
586586
587587
588588   return stv_workram_h[0x090740/4];
r1293r1294
692692   driver_init_stv(machine);
693693
694694   minit_boost = sinit_boost = 0;
695   minit_boost_timeslice = sinit_boost_timeslice = MAME_TIME_IN_USEC(50);
695   minit_boost_timeslice = sinit_boost_timeslice = ATTOTIME_IN_USEC(50);
696696}
697697
698698/* danchih hangs on the title screen without this hack .. */
r1293r1294
732732
733733static READ32_HANDLER( danchih_speedup_r )
734734{
735   if (activecpu_get_pc()==0x06028c90) cpu_spinuntil_time(MAME_TIME_IN_USEC(20));
735   if (activecpu_get_pc()==0x06028c90) cpu_spinuntil_time(ATTOTIME_IN_USEC(20));
736736   return stv_workram_h[0x0ffc10/4];
737737}
738738
r1293r1294
753753
754754   driver_init_stv(machine);
755755
756   minit_boost_timeslice = sinit_boost_timeslice = MAME_TIME_IN_USEC(5);
756   minit_boost_timeslice = sinit_boost_timeslice = ATTOTIME_IN_USEC(5);
757757
758758}
759759
r1293r1294
787787static READ32_HANDLER( astrass_speedup_r )
788788{
789789   if(activecpu_get_pc() == 0x0605b9dc )
790      cpu_spinuntil_time(MAME_TIME_IN_USEC(20));
790      cpu_spinuntil_time(ATTOTIME_IN_USEC(20));
791791
792792   return stv_workram_h[0x8e4d8/4];
793793}
r1293r1294
857857
858858   driver_init_ic13(machine);
859859
860   minit_boost_timeslice = sinit_boost_timeslice = MAME_TIME_IN_USEC(1);
860   minit_boost_timeslice = sinit_boost_timeslice = ATTOTIME_IN_USEC(1);
861861}
862862
863863static READ32_HANDLER(sandor_speedup_r)
r1293r1294
886886   memory_install_read32_handler(0, ADDRESS_SPACE_PROGRAM, 0x06075a2c, 0x06075a2f, 0, 0, sandor_speedup2_r );
887887   cpunum_set_info_fct(1, CPUINFO_PTR_SH2_FTCSR_READ_CALLBACK, (genf *)sandor_slave_speedup);
888888   driver_init_ic13(machine);
889   minit_boost_timeslice = sinit_boost_timeslice = MAME_TIME_IN_USEC(1);
889   minit_boost_timeslice = sinit_boost_timeslice = ATTOTIME_IN_USEC(1);
890890
891891}
892892
893893static READ32_HANDLER(grdforce_speedup_r)
894894{
895   if ( activecpu_get_pc() == 0x06041E34 ) cpu_spinuntil_time(MAME_TIME_IN_USEC(20));
895   if ( activecpu_get_pc() == 0x06041E34 ) cpu_spinuntil_time(ATTOTIME_IN_USEC(20));
896896   return stv_workram_h[0x000ffc10/4];
897897}
898898
r1293r1294
910910         {
911911            logerror("cpu1 skip %08x %08x\n",stv_workram_h[0x0ffc44/4],stv_workram_h[0x0ffc48/4]);
912912
913            //cpu_spinuntil_time(MAME_TIME_IN_USEC(200));
913            //cpu_spinuntil_time(ATTOTIME_IN_USEC(200));
914914            cpunum_spinuntil_trigger(1, 1000);
915915         }
916916      }
r1293r1294
934934
935935   driver_init_stv(machine);
936936
937   minit_boost_timeslice = sinit_boost_timeslice = MAME_TIME_IN_USEC(50);
937   minit_boost_timeslice = sinit_boost_timeslice = ATTOTIME_IN_USEC(50);
938938}
939939
940940static READ32_HANDLER( batmanfr_speedup_r )
r1293r1294
962962   driver_init_stv(machine);
963963
964964   minit_boost = sinit_boost = 0;
965   minit_boost_timeslice = sinit_boost_timeslice = MAME_TIME_IN_USEC(50);
965   minit_boost_timeslice = sinit_boost_timeslice = ATTOTIME_IN_USEC(50);
966966}
967967
968968static void colmns97_slave_speedup( UINT32 data )
r1293r1294
989989
990990static READ32_HANDLER(winterht_speedup_r)
991991{
992   if ( activecpu_get_pc() == 0x06098aec ) cpu_spinuntil_time(MAME_TIME_IN_USEC(20));//cpu_spinuntil_int();
992   if ( activecpu_get_pc() == 0x06098aec ) cpu_spinuntil_time(ATTOTIME_IN_USEC(20));//cpu_spinuntil_int();
993993   return stv_workram_h[0x000ffc10/4];
994994}
995995
r1293r1294
10081008
10091009   driver_init_ic13(machine);
10101010
1011   minit_boost_timeslice = sinit_boost_timeslice = MAME_TIME_IN_USEC(2);
1011   minit_boost_timeslice = sinit_boost_timeslice = ATTOTIME_IN_USEC(2);
10121012}
10131013
10141014static READ32_HANDLER(seabass_speedup_r)
10151015{
1016   if ( activecpu_get_pc() == 0x0602cbfc ) cpu_spinuntil_time(MAME_TIME_IN_USEC(20));
1016   if ( activecpu_get_pc() == 0x0602cbfc ) cpu_spinuntil_time(ATTOTIME_IN_USEC(20));
10171017   return stv_workram_h[0x000ffc10/4];
10181018}
10191019
r1293r1294
10331033
10341034   driver_init_ic13(machine);
10351035
1036   minit_boost_timeslice = sinit_boost_timeslice = MAME_TIME_IN_USEC(5);
1036   minit_boost_timeslice = sinit_boost_timeslice = ATTOTIME_IN_USEC(5);
10371037}
10381038
10391039static void vfremix_slave_speedup( UINT32 data )
r1293r1294
10561056
10571057   driver_init_ic13(machine);
10581058
1059   minit_boost_timeslice = sinit_boost_timeslice = MAME_TIME_IN_USEC(20);
1059   minit_boost_timeslice = sinit_boost_timeslice = ATTOTIME_IN_USEC(20);
10601060}
10611061
10621062
r1293r1294
10811081
10821082   driver_init_ic13(machine);
10831083
1084   minit_boost_timeslice = sinit_boost_timeslice = MAME_TIME_IN_USEC(50);
1084   minit_boost_timeslice = sinit_boost_timeslice = ATTOTIME_IN_USEC(50);
10851085}
10861086
10871087static READ32_HANDLER(othellos_speedup_r)
10881088{
1089   if ( activecpu_get_pc() == 0x0602bcc0 ) cpu_spinuntil_time(MAME_TIME_IN_USEC(20));
1089   if ( activecpu_get_pc() == 0x0602bcc0 ) cpu_spinuntil_time(ATTOTIME_IN_USEC(20));
10901090   return stv_workram_h[0x000ffc10/4];
10911091}
10921092
r1293r1294
11081108
11091109   driver_init_stv(machine);
11101110
1111   minit_boost_timeslice = sinit_boost_timeslice = MAME_TIME_IN_USEC(50);
1111   minit_boost_timeslice = sinit_boost_timeslice = ATTOTIME_IN_USEC(50);
11121112
11131113}
11141114
r1293r1294
11251125
11261126   driver_init_ic13(machine);
11271127
1128   minit_boost_timeslice = sinit_boost_timeslice = MAME_TIME_IN_USEC(2);
1128   minit_boost_timeslice = sinit_boost_timeslice = ATTOTIME_IN_USEC(2);
11291129}
11301130
11311131static READ32_HANDLER(gaxeduel_speedup_r)
r1293r1294
11721172   cpunum_set_info_fct(1, CPUINFO_PTR_SH2_FTCSR_READ_CALLBACK, (genf*)sokyugrt_slave_speedup );
11731173   memory_install_read32_handler(0, ADDRESS_SPACE_PROGRAM, 0x060788cc, 0x060788cf, 0, 0, sokyugrt_speedup_r);
11741174   driver_init_ic13(machine);
1175   minit_boost_timeslice = sinit_boost_timeslice = MAME_TIME_IN_USEC(50);
1175   minit_boost_timeslice = sinit_boost_timeslice = ATTOTIME_IN_USEC(50);
11761176
11771177}
11781178
11791179static READ32_HANDLER( znpwfv_speedup_r )
11801180{
1181   if (activecpu_get_pc()==0x6012ec4) cpu_spinuntil_time(MAME_TIME_IN_USEC(20));
1181   if (activecpu_get_pc()==0x6012ec4) cpu_spinuntil_time(ATTOTIME_IN_USEC(20));
11821182   return stv_workram_h[0x0ffc10/4];
11831183}
11841184
r1293r1294
12061206   memory_install_read32_handler(0, ADDRESS_SPACE_PROGRAM, 0x60ffc10, 0x60ffc13, 0, 0, znpwfv_speedup_r );
12071207
12081208   driver_init_ic13(machine);
1209   minit_boost_timeslice = sinit_boost_timeslice = MAME_TIME_IN_NSEC(500);
1209   minit_boost_timeslice = sinit_boost_timeslice = ATTOTIME_IN_NSEC(500);
12101210}
12111211
12121212static READ32_HANDLER( twcup98_speedup_r )
12131213{
1214   if (activecpu_get_pc()==0x605ede0) cpu_spinuntil_time(MAME_TIME_IN_USEC(20));
1214   if (activecpu_get_pc()==0x605ede0) cpu_spinuntil_time(ATTOTIME_IN_USEC(20));
12151215   return stv_workram_h[0x0ffc10/4];
12161216}
12171217
r1293r1294
12301230   driver_init_ic13(machine);
12311231   install_standard_protection();
12321232
1233   minit_boost_timeslice = sinit_boost_timeslice = MAME_TIME_IN_USEC(5);
1233   minit_boost_timeslice = sinit_boost_timeslice = ATTOTIME_IN_USEC(5);
12341234}
12351235
12361236static READ32_HANDLER( smleague_speedup_r )
12371237{
1238   if (activecpu_get_pc()==0x6063bf6) cpu_spinuntil_time(MAME_TIME_IN_USEC(20));
1238   if (activecpu_get_pc()==0x6063bf6) cpu_spinuntil_time(ATTOTIME_IN_USEC(20));
12391239   return stv_workram_h[0x0ffc10/4];
12401240}
12411241
r1293r1294
12531253
12541254   driver_init_ic13(machine);
12551255
1256   minit_boost_timeslice = sinit_boost_timeslice = MAME_TIME_IN_USEC(50);
1256   minit_boost_timeslice = sinit_boost_timeslice = ATTOTIME_IN_USEC(50);
12571257}
12581258
12591259static READ32_HANDLER( finlarch_speedup_r )
r1293r1294
12731273
12741274static READ32_HANDLER( maruchan_speedup_r )
12751275{
1276   if (activecpu_get_pc()==0x06012a54) cpu_spinuntil_time(MAME_TIME_IN_USEC(20));
1276   if (activecpu_get_pc()==0x06012a54) cpu_spinuntil_time(ATTOTIME_IN_USEC(20));
12771277   return stv_workram_h[0x0ffc10/4];
12781278}
12791279
r1293r1294
13001300
13011301   driver_init_ic13(machine);
13021302
1303   minit_boost_timeslice = sinit_boost_timeslice = MAME_TIME_IN_USEC(50);
1303   minit_boost_timeslice = sinit_boost_timeslice = ATTOTIME_IN_USEC(50);
13041304}
13051305
13061306static READ32_HANDLER( pblbeach_speedup_r )
r1293r1294
13341334
13351335static READ32_HANDLER( elandore_speedup_r )
13361336{
1337   if (activecpu_get_pc()==0x0604eac2) cpu_spinuntil_time(MAME_TIME_IN_USEC(20));
1337   if (activecpu_get_pc()==0x0604eac2) cpu_spinuntil_time(ATTOTIME_IN_USEC(20));
13381338   return stv_workram_h[0x0ffc10/4];
13391339}
13401340
r1293r1294
13571357   memory_install_read32_handler(0, ADDRESS_SPACE_PROGRAM, 0x60ffc10, 0x60ffc13, 0, 0, elandore_speedup_r );
13581358   cpunum_set_info_fct(1, CPUINFO_PTR_SH2_FTCSR_READ_CALLBACK, (genf *)elandore_slave_speedup);
13591359   driver_init_stv(machine);
1360   minit_boost_timeslice = sinit_boost_timeslice = MAME_TIME_IN_USEC(0);
1360   minit_boost_timeslice = sinit_boost_timeslice = ATTOTIME_IN_USEC(0);
13611361
13621362}
13631363
13641364static READ32_HANDLER( rsgun_speedup_r )
13651365{
1366   if (activecpu_get_pc()==0x06034d06) cpu_spinuntil_time(MAME_TIME_IN_USEC(20));
1366   if (activecpu_get_pc()==0x06034d06) cpu_spinuntil_time(ATTOTIME_IN_USEC(20));
13671367   return stv_workram_h[0x0ffc10/4];
13681368}
13691369
r1293r1294
13871387
13881388   driver_init_stv(machine);
13891389
1390   minit_boost_timeslice = sinit_boost_timeslice = MAME_TIME_IN_USEC(20);
1390   minit_boost_timeslice = sinit_boost_timeslice = ATTOTIME_IN_USEC(20);
13911391
13921392}
13931393
src/mame/drivers/egghunt.c
r1293r1294
4444#include "driver.h"
4545#include "sound/okim6295.h"
4646
47UINT8 *egghunt_bgram;
48UINT8 *egghunt_atram;
49UINT8 *egghunt_spram;
50UINT8 egghunt_vidram_bank;
47static UINT8 *egghunt_bgram;
48static UINT8 *egghunt_atram;
49static UINT8 *egghunt_spram;
50static UINT8 egghunt_vidram_bank;
5151
5252static tilemap *bg_tilemap;
5353static UINT8 egghunt_okibanking;
src/mame/drivers/taito_f2.c
r1293r1294
800800
801801static INTERRUPT_GEN( taitof2_interrupt )
802802{
803   mame_timer_set(MAME_TIME_IN_CYCLES(500,0),0, taitof2_interrupt6);
803   timer_set(ATTOTIME_IN_CYCLES(500,0),0, taitof2_interrupt6);
804804   cpunum_set_input_line(0, 5, HOLD_LINE);
805805}
806806
src/mame/drivers/gottlieb.c
r1293r1294
381381   }
382382}
383383
384INTERRUPT_GEN( gottlieb_interrupt )
384static INTERRUPT_GEN( gottlieb_interrupt )
385385{
386386   if (access_time > 0) {
387387      access_time--;
r1293r1294
444444ADDRESS_MAP_END
445445
446446
447ADDRESS_MAP_START( gottlieb_sound_readmem, ADDRESS_SPACE_PROGRAM, 8 )
447static ADDRESS_MAP_START( gottlieb_sound_readmem, ADDRESS_SPACE_PROGRAM, 8 )
448448   AM_RANGE(0x0000, 0x01ff) AM_READ(riot_ram_r)
449449   AM_RANGE(0x0200, 0x03ff) AM_READ(gottlieb_riot_r)
450450   AM_RANGE(0x6000, 0x7fff) AM_READ(MRA8_ROM)
r1293r1294
454454   AM_RANGE(0xe000, 0xffff) AM_READ(MRA8_ROM)
455455ADDRESS_MAP_END
456456
457ADDRESS_MAP_START( gottlieb_sound_writemem, ADDRESS_SPACE_PROGRAM, 8 )
457static ADDRESS_MAP_START( gottlieb_sound_writemem, ADDRESS_SPACE_PROGRAM, 8 )
458458   AM_RANGE(0x0000, 0x01ff) AM_WRITE(riot_ram_w) AM_BASE(&riot_ram)
459459   AM_RANGE(0x0200, 0x03ff) AM_WRITE(gottlieb_riot_w)
460460   AM_RANGE(0x1000, 0x1000) AM_WRITE(DAC_0_data_w)
r1293r1294
477477   AM_RANGE(0xe000, 0xffff) AM_READ(MRA8_ROM)
478478ADDRESS_MAP_END
479479
480ADDRESS_MAP_START( stooges_sound_writemem, ADDRESS_SPACE_PROGRAM, 8 )
480static ADDRESS_MAP_START( stooges_sound_writemem, ADDRESS_SPACE_PROGRAM, 8 )
481481   AM_RANGE(0x0000, 0x03ff) AM_WRITE(MWA8_RAM)
482482   AM_RANGE(0x4000, 0x4001) AM_WRITE(DAC_0_data_w)
483483   AM_RANGE(0xe000, 0xffff) AM_WRITE(MWA8_ROM)
r1293r1294
491491   AM_RANGE(0xc000, 0xffff) AM_READ(MRA8_ROM)
492492ADDRESS_MAP_END
493493
494ADDRESS_MAP_START( stooges_sound2_writemem, ADDRESS_SPACE_PROGRAM, 8 )
494static ADDRESS_MAP_START( stooges_sound2_writemem, ADDRESS_SPACE_PROGRAM, 8 )
495495   AM_RANGE(0x0000, 0x03ff) AM_WRITE(MWA8_RAM)
496496   AM_RANGE(0x2000, 0x2000) AM_WRITE(stooges_sp0250_latch_w)   /* speech chip. The game sends strings */
497497                           /* of 15 bytes (clocked by 4000). The chip also */
r1293r1294
15551555   MDRV_CPU_PROGRAM_MAP(gottlieb_sound_readmem,gottlieb_sound_writemem)
15561556                        /* NMIs are triggered by the Votrax SC-01 */
15571557   MDRV_SCREEN_REFRESH_RATE(61)
1558   MDRV_SCREEN_VBLANK_TIME(USEC_TO_SUBSECONDS(1018)   /* frames per second, vblank duration */)
1558   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(1018)   /* frames per second, vblank duration */)
15591559
15601560   MDRV_MACHINE_RESET(gottlieb)
15611561   MDRV_NVRAM_HANDLER(generic_1fill)
r1293r1294
16361636   MDRV_CPU_PROGRAM_MAP(stooges_sound2_readmem,stooges_sound2_writemem)
16371637
16381638   MDRV_SCREEN_REFRESH_RATE(61)
1639   MDRV_SCREEN_VBLANK_TIME(USEC_TO_SUBSECONDS(1018)   /* frames per second, vblank duration */)
1639   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(1018)   /* frames per second, vblank duration */)
16401640
16411641   MDRV_MACHINE_RESET(gottlieb)
16421642   MDRV_NVRAM_HANDLER(generic_1fill)
src/mame/drivers/sandscrp.c
r1293r1294
130130      latch1_full = 1;
131131      soundlatch_w(0, data & 0xff);
132132      cpunum_set_input_line(1, INPUT_LINE_NMI, PULSE_LINE);
133      cpu_spinuntil_time(MAME_TIME_IN_USEC(100));   // Allow the other cpu to reply
133      cpu_spinuntil_time(ATTOTIME_IN_USEC(100));   // Allow the other cpu to reply
134134   }
135135}
136136
src/mame/drivers/gpworld.c
r1293r1294
5959
6060
6161/* VIDEO GOODS */
62void gpworld_draw_tiles(running_machine *machine, mame_bitmap *bitmap,const rectangle *cliprect)
62static void gpworld_draw_tiles(running_machine *machine, mame_bitmap *bitmap,const rectangle *cliprect)
6363{
6464   UINT8 characterX, characterY;
6565
r1293r1294
9393   *BITMAP_ADDR32(bitmap, y, x) = color;
9494}
9595
96void gpworld_draw_sprites(mame_bitmap *bitmap, const rectangle *cliprect)
96static void gpworld_draw_sprites(mame_bitmap *bitmap, const rectangle *cliprect)
9797{
9898   const int SPR_Y_TOP     = 0;
9999   const int SPR_Y_BOTTOM  = 1;
r1293r1294
408408
409409   /* The time the IRQ line stays high is set just long enough to happen after the NMI - hacky? */
410410   cpunum_set_input_line(0, 0, ASSERT_LINE);
411   mame_timer_set(MAME_TIME_IN_USEC(100), 0, irq_stop);
411   timer_set(ATTOTIME_IN_USEC(100), 0, irq_stop);
412412
413413   laserdisc_vsync(discinfo);
414414}
src/mame/drivers/ddragon.c
r1293r1294
10031003   MDRV_CPU_PROGRAM_MAP(sound_readmem,sound_writemem)
10041004
10051005   MDRV_SCREEN_REFRESH_RATE(((12000000.0 / 256.0) / 3.0) / 272.0)
1006   MDRV_SCREEN_VBLANK_TIME(USEC_TO_SUBSECONDS(0))
1006   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(0))
10071007   MDRV_INTERLEAVE(1000) /* heavy interleaving to sync up sprite<->main cpu's */
10081008
10091009   MDRV_MACHINE_START(ddragon)
r1293r1294
10551055   MDRV_CPU_PROGRAM_MAP(mcu_readmem,mcu_writemem)
10561056
10571057   MDRV_SCREEN_REFRESH_RATE(((12000000.0 / 256.0) / 3.0) / 272.0)
1058   MDRV_SCREEN_VBLANK_TIME(USEC_TO_SUBSECONDS(0))
1058   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(0))
10591059   MDRV_INTERLEAVE(1000) /* heavy interleaving to sync up sprite<->main cpu's */
10601060
10611061   MDRV_MACHINE_RESET(ddragon)
r1293r1294
11031103   MDRV_CPU_PROGRAM_MAP(sound_readmem,sound_writemem)
11041104
11051105   MDRV_SCREEN_REFRESH_RATE(((12000000.0 / 256.0) / 3.0) / 272.0)
1106   MDRV_SCREEN_VBLANK_TIME(USEC_TO_SUBSECONDS(0))
1106   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(0))
11071107   MDRV_INTERLEAVE(100) /* heavy interleaving to sync up sprite<->main cpu's */
11081108
11091109   MDRV_MACHINE_START(ddragon)
r1293r1294
11531153   MDRV_CPU_PROGRAM_MAP(sound_readmem,sound_writemem)
11541154
11551155   MDRV_SCREEN_REFRESH_RATE(((12000000.0 / 256.0) / 3.0) / 272.0)
1156   MDRV_SCREEN_VBLANK_TIME(USEC_TO_SUBSECONDS(0))
1156   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(0))
11571157   MDRV_INTERLEAVE(100) /* heavy interleaving to sync up sprite<->main cpu's */
11581158
11591159   MDRV_MACHINE_START(ddragon)
r1293r1294
12031203   MDRV_CPU_PROGRAM_MAP(dd2_sound_readmem,dd2_sound_writemem)
12041204
12051205   MDRV_SCREEN_REFRESH_RATE(((12000000.0 / 256.0) / 3.0) / 272.0)
1206   MDRV_SCREEN_VBLANK_TIME(USEC_TO_SUBSECONDS(0))
1206   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(0))
12071207   MDRV_INTERLEAVE(100) /* heavy interleaving to sync up sprite<->main cpu's */
12081208
12091209   MDRV_MACHINE_RESET(ddragon2)
r1293r1294
12441244   MDRV_CPU_PROGRAM_MAP(sound_readmem,sound_writemem)
12451245
12461246   MDRV_SCREEN_REFRESH_RATE(((12000000.0 / 256.0) / 3.0) / 272.0)
1247   MDRV_SCREEN_VBLANK_TIME(USEC_TO_SUBSECONDS(0))
1247   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(0))
12481248
12491249   /* video hardware */
12501250   MDRV_VIDEO_ATTRIBUTES(VIDEO_TYPE_RASTER )
src/mame/drivers/asterix.c
r1293r1294
127127static WRITE8_HANDLER( sound_arm_nmi_w )
128128{
129129   cpunum_set_input_line(1, INPUT_LINE_NMI, CLEAR_LINE);
130   mame_timer_set(MAME_TIME_IN_USEC(5),0,nmi_callback);
130   timer_set(ATTOTIME_IN_USEC(5),0,nmi_callback);
131131}
132132
133133static WRITE16_HANDLER( sound_irq_w )
src/mame/drivers/tubep.c
r1293r1294
111111static UINT8 ls74 = 0;
112112static UINT8 ls377 = 0;
113113
114static mame_timer *interrupt_timer;
114static emu_timer *interrupt_timer;
115115
116116
117117static int curr_scanline=0;
r1293r1294
328328   if (scanline>=264)
329329      scanline=0;
330330
331   mame_timer_adjust(interrupt_timer, video_screen_get_time_until_pos(0, scanline, 0), scanline, time_zero);
331   timer_adjust(interrupt_timer, video_screen_get_time_until_pos(0, scanline, 0), scanline, attotime_zero);
332332}
333333
334334
r1293r1294
352352static MACHINE_START( tubep )
353353{
354354   /* Create interrupt timer */
355   interrupt_timer = mame_timer_alloc(tubep_scanline_callback);
355   interrupt_timer = timer_alloc(tubep_scanline_callback);
356356
357357   tubep_setup_save_state();
358358}
r1293r1294
360360
361361static MACHINE_RESET( tubep )
362362{
363   mame_timer_adjust(interrupt_timer, video_screen_get_time_until_pos(0, 0, 0), 0, time_zero);
363   timer_adjust(interrupt_timer, video_screen_get_time_until_pos(0, 0, 0), 0, attotime_zero);
364364}
365365
366366
r1293r1294
509509   if (scanline>=264)
510510      scanline=0;
511511
512   mame_timer_adjust(interrupt_timer, video_screen_get_time_until_pos(0, scanline, 0), scanline, time_zero);
512   timer_adjust(interrupt_timer, video_screen_get_time_until_pos(0, scanline, 0), scanline, attotime_zero);
513513}
514514
515515
516516static MACHINE_START( rjammer )
517517{
518518   /* Create interrupt timer */
519   interrupt_timer = mame_timer_alloc(rjammer_scanline_callback);
519   interrupt_timer = timer_alloc(rjammer_scanline_callback);
520520
521521   tubep_setup_save_state();
522522}
523523
524524static MACHINE_RESET( rjammer )
525525{
526   mame_timer_adjust(interrupt_timer, video_screen_get_time_until_pos(0, 0, 0), 0, time_zero);
526   timer_adjust(interrupt_timer, video_screen_get_time_until_pos(0, 0, 0), 0, attotime_zero);
527527}
528528
529529
src/mame/drivers/ppmast93.c
r1293r1294
132132
133133
134134static tilemap *ppmast93_fg_tilemap, *ppmast93_bg_tilemap;
135UINT8 *ppmast93_fgram, *ppmast93_bgram;
135static UINT8 *ppmast93_fgram, *ppmast93_bgram;
136136
137137static WRITE8_HANDLER( ppmast93_fgram_w )
138138{
src/mame/drivers/homedata.c
r1293r1294
564564/********************************************************************************/
565565
566566
567ADDRESS_MAP_START( mrokumei_readmem, ADDRESS_SPACE_PROGRAM, 8 )
567static ADDRESS_MAP_START( mrokumei_readmem, ADDRESS_SPACE_PROGRAM, 8 )
568568   AM_RANGE(0x0000, 0x3fff) AM_READ(MRA8_RAM) /* videoram */
569569   AM_RANGE(0x4000, 0x5fff) AM_READ(MRA8_RAM)
570570   AM_RANGE(0x6000, 0x6fff) AM_READ(MRA8_RAM) /* work ram */
r1293r1294
578578   AM_RANGE(0x8000, 0xffff) AM_READ(MRA8_ROM)
579579ADDRESS_MAP_END
580580
581ADDRESS_MAP_START( mrokumei_writemem, ADDRESS_SPACE_PROGRAM, 8 )
581static ADDRESS_MAP_START( mrokumei_writemem, ADDRESS_SPACE_PROGRAM, 8 )
582582   AM_RANGE(0x0000, 0x3fff) AM_WRITE(mrokumei_videoram_w) AM_BASE(&videoram)
583583   AM_RANGE(0x4000, 0x5fff) AM_WRITE(MWA8_RAM)
584584   AM_RANGE(0x6000, 0x6fff) AM_WRITE(MWA8_RAM)
r1293r1294
594594   AM_RANGE(0x8000, 0xffff) AM_WRITE(MWA8_ROM)
595595ADDRESS_MAP_END
596596
597ADDRESS_MAP_START( mrokumei_sound_readmem, ADDRESS_SPACE_PROGRAM, 8 )
597static ADDRESS_MAP_START( mrokumei_sound_readmem, ADDRESS_SPACE_PROGRAM, 8 )
598598   AM_RANGE(0x0000, 0x7fff) AM_READ(MRA8_ROM)
599599ADDRESS_MAP_END
600600
601ADDRESS_MAP_START( mrokumei_sound_writemem, ADDRESS_SPACE_PROGRAM, 8 )
601static ADDRESS_MAP_START( mrokumei_sound_writemem, ADDRESS_SPACE_PROGRAM, 8 )
602602   AM_RANGE(0x0000, 0x7fff) AM_WRITE(MWA8_ROM)
603603   AM_RANGE(0xfffc, 0xfffd) AM_WRITE(MWA8_NOP)   /* stack writes happen here, but there's no RAM */
604604   AM_RANGE(0x8080, 0x8080) AM_WRITE(mrokumei_sound_bank_w)
r1293r1294
614614
615615/********************************************************************************/
616616
617ADDRESS_MAP_START( reikaids_readmem, ADDRESS_SPACE_PROGRAM, 8 )
617static ADDRESS_MAP_START( reikaids_readmem, ADDRESS_SPACE_PROGRAM, 8 )
618618   AM_RANGE(0x0000, 0x3fff) AM_READ(MRA8_RAM) /* videoram */
619619   AM_RANGE(0x4000, 0x5fff) AM_READ(MRA8_RAM)
620620   AM_RANGE(0x6000, 0x6fff) AM_READ(MRA8_RAM) /* work ram */
r1293r1294
626626   AM_RANGE(0xc000, 0xffff) AM_READ(MRA8_ROM)
627627ADDRESS_MAP_END
628628
629ADDRESS_MAP_START( reikaids_writemem, ADDRESS_SPACE_PROGRAM, 8 )
629static ADDRESS_MAP_START( reikaids_writemem, ADDRESS_SPACE_PROGRAM, 8 )
630630   AM_RANGE(0x0000, 0x3fff) AM_WRITE(reikaids_videoram_w) AM_BASE(&videoram)
631631   AM_RANGE(0x4000, 0x5fff) AM_WRITE(MWA8_RAM)
632632   AM_RANGE(0x6000, 0x6fff) AM_WRITE(MWA8_RAM)
r1293r1294
666666/**************************************************************************/
667667
668668
669ADDRESS_MAP_START( pteacher_readmem, ADDRESS_SPACE_PROGRAM, 8 )
669static ADDRESS_MAP_START( pteacher_readmem, ADDRESS_SPACE_PROGRAM, 8 )
670670   AM_RANGE(0x0000, 0x3fff) AM_READ(MRA8_RAM)
671671   AM_RANGE(0x4000, 0x5fff) AM_READ(MRA8_RAM)
672672   AM_RANGE(0x6000, 0x6fff) AM_READ(MRA8_RAM) /* work ram */
r1293r1294
677677   AM_RANGE(0xc000, 0xffff) AM_READ(MRA8_ROM)
678678ADDRESS_MAP_END
679679
680ADDRESS_MAP_START( pteacher_writemem, ADDRESS_SPACE_PROGRAM, 8 )
680static ADDRESS_MAP_START( pteacher_writemem, ADDRESS_SPACE_PROGRAM, 8 )
681681   AM_RANGE(0x0000, 0x3fff) AM_WRITE(pteacher_videoram_w) AM_BASE(&videoram)
682682   AM_RANGE(0x4000, 0x5eff) AM_WRITE(MWA8_RAM)
683683   AM_RANGE(0x5f00, 0x5fff) AM_WRITE(MWA8_RAM)
src/mame/drivers/xxmissio.c
r1293r1294
7676   }
7777}
7878
79INTERRUPT_GEN( xxmissio_interrupt_m )
79static INTERRUPT_GEN( xxmissio_interrupt_m )
8080{
8181   xxmissio_status &= ~0x20;
8282   cpunum_set_input_line(0, 0, HOLD_LINE);
8383}
8484
85INTERRUPT_GEN( xxmissio_interrupt_s )
85static INTERRUPT_GEN( xxmissio_interrupt_s )
8686{
8787   xxmissio_status &= ~0x10;
8888   cpunum_set_input_line(1, 0, HOLD_LINE);
src/mame/drivers/hng64.c
r1293r1294
642642
643643
644644/* preliminary dma code, dma is used to copy program code -> ram */
645int hng_dma_start,hng_dma_dst,hng_dma_len;
646void hng64_do_dma (void)
645static int hng_dma_start,hng_dma_dst,hng_dma_len;
646static void hng64_do_dma (void)
647647{
648648   logerror("Performing DMA Start %08x Len %08x Dst %08x\n",hng_dma_start, hng_dma_len, hng_dma_dst);
649649
r1293r1294
14481448   }
14491449
14501450   cpunum_set_input_line(0, 0, ASSERT_LINE);
1451   mame_timer_set(MAME_TIME_IN_USEC(50), 0, irq_stop);
1451   timer_set(ATTOTIME_IN_USEC(50), 0, irq_stop);
14521452}
14531453
14541454
r1293r1294
15121512}
15131513
15141514
1515MACHINE_DRIVER_START( hng64 )
1515static MACHINE_DRIVER_START( hng64 )
15161516   /* basic machine hardware */
15171517   MDRV_CPU_ADD(R4600BE, MASTER_CLOCK)     // actually R4300
15181518   MDRV_CPU_CONFIG(config)
src/mame/drivers/macrossp.c
r1293r1294
281281      sndpending = 1;
282282      cpunum_set_input_line(1,2,HOLD_LINE);
283283      /* spin for a while to let the sound CPU read the command */
284      cpu_spinuntil_time(MAME_TIME_IN_USEC(50));
284      cpu_spinuntil_time(ATTOTIME_IN_USEC(50));
285285   }
286286}
287287
src/mame/drivers/moo.c
r1293r1294
178178      moo_objdma(game_type);
179179
180180      // schedule DMA end interrupt (delay shortened to catch up with V-blank)
181      mame_timer_set(MAME_TIME_IN_USEC(MOO_DMADELAY), 0, dmaend_callback);
181      timer_set(ATTOTIME_IN_USEC(MOO_DMADELAY), 0, dmaend_callback);
182182   }
183183
184184   // trigger V-blank interrupt
r1293r1294
191191   moo_objdma(game_type);
192192
193193   // schedule DMA end interrupt (delay shortened to catch up with V-blank)
194   mame_timer_set(MAME_TIME_IN_USEC(MOO_DMADELAY), 0, dmaend_callback);
194   timer_set(ATTOTIME_IN_USEC(MOO_DMADELAY), 0, dmaend_callback);
195195
196196   // trigger V-blank interrupt
197197   cpunum_set_input_line(0, 5, HOLD_LINE);
r1293r1294
635635   MDRV_CPU_PROGRAM_MAP(sound_readmem,sound_writemem)
636636
637637   MDRV_SCREEN_REFRESH_RATE(60)
638   MDRV_SCREEN_VBLANK_TIME(USEC_TO_SUBSECONDS(1200))    // should give IRQ4 sufficient time to update scroll registers
638   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(1200))    // should give IRQ4 sufficient time to update scroll registers
639639
640640   MDRV_MACHINE_START(moo)
641641   MDRV_MACHINE_RESET(moo)
r1293r1294
674674   MDRV_CPU_VBLANK_INT(moobl_interrupt, 1)
675675
676676   MDRV_SCREEN_REFRESH_RATE(60)
677   MDRV_SCREEN_VBLANK_TIME(USEC_TO_SUBSECONDS(1200)) // should give IRQ4 sufficient time to update scroll registers
677   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(1200)) // should give IRQ4 sufficient time to update scroll registers
678678
679679   MDRV_MACHINE_START(moo)
680680   MDRV_MACHINE_RESET(moo)
src/mame/drivers/skychut.c
r1293r1294
167167ADDRESS_MAP_END
168168
169169
170INTERRUPT_GEN( skychut_interrupt )
170static INTERRUPT_GEN( skychut_interrupt )
171171{
172172   if (readinputport(2) & 1)   /* Left Coin */
173173        cpunum_set_input_line(0, INPUT_LINE_NMI, PULSE_LINE);
src/mame/drivers/groundfx.c
r1293r1294
221221{
222222   /* One interrupt per input port (4 per frame, though only 2 used).
223223        1000 cycle delay is arbitrary */
224   mame_timer_set(MAME_TIME_IN_CYCLES(1000,0),0, groundfx_interrupt5);
224   timer_set(ATTOTIME_IN_CYCLES(1000,0),0, groundfx_interrupt5);
225225}
226226
227227static WRITE32_HANDLER( rotate_control_w )   /* only a guess that it's rotation */
src/mame/drivers/segald.c
r1293r1294
3535static UINT8 ldv1000_output_latch;
3636
3737/* VIDEO GOODS */
38void astron_draw_characters(running_machine *machine, mame_bitmap *bitmap,const rectangle *cliprect)
38static void astron_draw_characters(running_machine *machine, mame_bitmap *bitmap,const rectangle *cliprect)
3939{
4040   UINT8 characterX, characterY;
4141
r1293r1294
5050   }
5151}
5252
53void astron_draw_sprites(mame_bitmap *bitmap, const rectangle *cliprect)
53static void astron_draw_sprites(mame_bitmap *bitmap, const rectangle *cliprect)
5454{
5555   /* Heisted from Daphne */
5656   const UINT8 SPR_Y_TOP     = 0;
src/mame/drivers/cabal.c
r1293r1294
108108   seibu_main_word_w(4,data,mem_mask);
109109
110110   /* spin for a while to let the Z80 read the command, otherwise coins "stick" */
111   cpu_spinuntil_time(MAME_TIME_IN_USEC(50));
111   cpu_spinuntil_time(ATTOTIME_IN_USEC(50));
112112}
113113
114114static WRITE16_HANDLER( cabalbl_sound_irq_trigger_word_w )
src/mame/drivers/cidelsa.c
r1293r1294
680680{
681681   cdp1869_configure(&destryer_CDP1869_interface);
682682
683   mame_timer_set(MAME_TIME_IN_MSEC(200), 0, set_cpu_mode);
683   timer_set(ATTOTIME_IN_MSEC(200), 0, set_cpu_mode);
684684}
685685
686686static const CDP1869_interface draco_CDP1869_interface =
r1293r1294
699699
700700   cdp1869_configure(&draco_CDP1869_interface);
701701
702   mame_timer_set(MAME_TIME_IN_MSEC(200), 0, set_cpu_mode);
702   timer_set(ATTOTIME_IN_MSEC(200), 0, set_cpu_mode);
703703}
704704
705705/* ROMs */
src/mame/drivers/tickee.c
r1293r1294
301301 *
302302 *************************************/
303303
304MACHINE_DRIVER_START( tickee )
304static MACHINE_DRIVER_START( tickee )
305305
306306   /* basic machine hardware */
307307   MDRV_CPU_ADD_TAG("main", TMS34010, 40000000/TMS34010_CLOCK_DIVIDER)
r1293r1294
335335MACHINE_DRIVER_END
336336
337337
338MACHINE_DRIVER_START( ghoshunt )
338static MACHINE_DRIVER_START( ghoshunt )
339339   MDRV_IMPORT_FROM(tickee)
340340
341341   /* basic machine hardware */
src/mame/drivers/suprloco.c
r1293r1294
3434   soundlatch_w(0,data);
3535   cpunum_set_input_line(1,INPUT_LINE_NMI,PULSE_LINE);
3636   /* spin for a while to let the Z80 read the command (fixes hanging sound in Regulus) */
37   cpu_spinuntil_time(MAME_TIME_IN_USEC(50));
37   cpu_spinuntil_time(ATTOTIME_IN_USEC(50));
3838}
3939
4040
r1293r1294
193193   MDRV_CPU_VBLANK_INT(irq0_line_hold,4)         /* NMIs are caused by the main CPU */
194194
195195   MDRV_SCREEN_REFRESH_RATE(60)
196   MDRV_SCREEN_VBLANK_TIME(USEC_TO_SUBSECONDS(5000))
196   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(5000))
197197
198198   /* video hardware */
199199   MDRV_VIDEO_ATTRIBUTES(VIDEO_TYPE_RASTER)
src/mame/drivers/m92.c
r1293r1294
198198static UINT8 irqvector;
199199static UINT16 sound_status;
200200static UINT32 bankaddress;
201static mame_timer *scanline_timer;
201static emu_timer *scanline_timer;
202202
203203static UINT8 m92_irq_vectorbase;
204204
r1293r1294
225225   state_save_register_global(bankaddress);
226226   state_save_register_func_postload(set_m92_bank);
227227
228   scanline_timer = mame_timer_alloc(m92_scanline_interrupt);
228   scanline_timer = timer_alloc(m92_scanline_interrupt);
229229}
230230
231231static MACHINE_RESET( m92 )
232232{
233   mame_timer_adjust(scanline_timer, video_screen_get_time_until_pos(0, 0, 0), 0, time_never);
233   timer_adjust(scanline_timer, video_screen_get_time_until_pos(0, 0, 0), 0, attotime_never);
234234}
235235
236236/*****************************************************************************/
r1293r1294
256256   /* adjust for next scanline */
257257   if (++scanline >= machine->screen[0].height)
258258      scanline = 0;
259   mame_timer_adjust(scanline_timer, video_screen_get_time_until_pos(0, scanline, 0), scanline, time_never);
259   timer_adjust(scanline_timer, video_screen_get_time_until_pos(0, scanline, 0), scanline, attotime_never);
260260}
261261
262262/*****************************************************************************/
src/mame/drivers/vendetta.c
r1293r1294
244244{
245245   cpunum_set_input_line(1, INPUT_LINE_NMI, CLEAR_LINE );
246246
247   mame_timer_set( MAME_TIME_IN_USEC( 25 ), 0, z80_nmi_callback );
247   timer_set( ATTOTIME_IN_USEC( 25 ), 0, z80_nmi_callback );
248248}
249249
250250static WRITE8_HANDLER( z80_irq_w )
src/mame/drivers/destroyr.c
r1293r1294
4949
5050   /* PCB supports two dials, but cab has only got one */
5151
52   mame_timer_set(video_screen_get_time_until_pos(0, readinputport(3), 0), 0, destroyr_dial_callback);
53   mame_timer_set(video_screen_get_time_until_pos(0, 0, 0), 0, destroyr_frame_callback);
52   timer_set(video_screen_get_time_until_pos(0, readinputport(3), 0), 0, destroyr_dial_callback);
53   timer_set(video_screen_get_time_until_pos(0, 0, 0), 0, destroyr_frame_callback);
5454}
5555
5656
5757static MACHINE_RESET( destroyr )
5858{
59   mame_timer_set(video_screen_get_time_until_pos(0, 0, 0), 0, destroyr_frame_callback);
59   timer_set(video_screen_get_time_until_pos(0, 0, 0), 0, destroyr_frame_callback);
6060}
6161
6262
src/mame/drivers/segas16b.c
r1293r1294
10801080static MACHINE_RESET( atomicp )
10811081{
10821082   machine_reset_system16b(machine);
1083   mame_timer_pulse(MAME_TIME_IN_HZ(atomicp_sound_rate), 0, atomicp_sound_irq);
1083   timer_pulse(ATTOTIME_IN_HZ(atomicp_sound_rate), 0, atomicp_sound_irq);
10841084}
10851085
10861086
src/mame/drivers/marineb.c
r1293r1294
514514   MDRV_CPU_VBLANK_INT(nmi_line_pulse,1)
515515
516516   MDRV_SCREEN_REFRESH_RATE(60)
517   MDRV_SCREEN_VBLANK_TIME(USEC_TO_SUBSECONDS(5000)   /* frames per second, vblank duration */)
517   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(5000)   /* frames per second, vblank duration */)
518518
519519   MDRV_MACHINE_RESET(marineb)
520520
src/mame/drivers/fuukifg2.c
r1293r1294
3737#include "sound/3812intf.h"
3838#include "sound/okim6295.h"
3939
40static mame_timer *raster_interrupt_timer;
40static emu_timer *raster_interrupt_timer;
4141
4242/* Variables defined in video: */
4343
r1293r1294
6969   UINT16 new_data   =   COMBINE_DATA(&fuuki16_vregs[offset]);
7070   if ((offset == 0x1c/2) && old_data != new_data)
7171   {
72      mame_timer_adjust(raster_interrupt_timer, video_screen_get_time_until_pos(0, new_data, Machine->screen[0].visarea.max_x + 1), 0, video_screen_get_frame_period(0));
72      timer_adjust(raster_interrupt_timer, video_screen_get_time_until_pos(0, new_data, Machine->screen[0].visarea.max_x + 1), 0, video_screen_get_frame_period(0));
7373   }
7474}
7575
r1293r1294
7979   {
8080      soundlatch_w(0,data & 0xff);
8181      cpunum_set_input_line(1, INPUT_LINE_NMI, PULSE_LINE);
82//      cpu_spinuntil_time(MAME_TIME_IN_USEC(50));   // Allow the other CPU to reply
83      cpu_boost_interleave(time_zero, MAME_TIME_IN_USEC(50)); // Fixes glitching in rasters
82//      cpu_spinuntil_time(ATTOTIME_IN_USEC(50));   // Allow the other CPU to reply
83      cpu_boost_interleave(attotime_zero, ATTOTIME_IN_USEC(50)); // Fixes glitching in rasters
8484   }
8585}
8686
r1293r1294
524524static TIMER_CALLBACK( level_1_interrupt_callback )
525525{
526526   cpunum_set_input_line(0, 1, PULSE_LINE);
527   mame_timer_set(video_screen_get_time_until_pos(0, 248, 0), 0, level_1_interrupt_callback);
527   timer_set(video_screen_get_time_until_pos(0, 248, 0), 0, level_1_interrupt_callback);
528528}
529529
530530
531531static TIMER_CALLBACK( vblank_interrupt_callback )
532532{
533533   cpunum_set_input_line(0, 3, PULSE_LINE);   // VBlank IRQ
534   mame_timer_set(video_screen_get_time_until_pos(0, machine->screen[0].visarea.max_y + 1, 0), 0, vblank_interrupt_callback);
534   timer_set(video_screen_get_time_until_pos(0, machine->screen[0].visarea.max_y + 1, 0), 0, vblank_interrupt_callback);
535535}
536536
537537
r1293r1294
539539{
540540   cpunum_set_input_line(0, 5, PULSE_LINE);   // Raster Line IRQ
541541   video_screen_update_partial(0, video_screen_get_vpos(0));
542   mame_timer_adjust(raster_interrupt_timer, video_screen_get_frame_period(0), 0, time_zero);
542   timer_adjust(raster_interrupt_timer, video_screen_get_frame_period(0), 0, attotime_zero);
543543}
544544
545545
546546static MACHINE_START( fuuki16 )
547547{
548   raster_interrupt_timer = mame_timer_alloc(raster_interrupt_callback);
548   raster_interrupt_timer = timer_alloc(raster_interrupt_callback);
549549}
550550
551551
552552static MACHINE_RESET( fuuki16 )
553553{
554   mame_timer_set(video_screen_get_time_until_pos(0, 248, 0), 0, level_1_interrupt_callback);
555   mame_timer_set(video_screen_get_time_until_pos(0, machine->screen[0].visarea.max_y + 1, 0), 0, vblank_interrupt_callback);
556   mame_timer_adjust(raster_interrupt_timer, video_screen_get_time_until_pos(0, 0, machine->screen[0].visarea.max_x + 1), 0, time_zero);
554   timer_set(video_screen_get_time_until_pos(0, 248, 0), 0, level_1_interrupt_callback);
555   timer_set(video_screen_get_time_until_pos(0, machine->screen[0].visarea.max_y + 1, 0), 0, vblank_interrupt_callback);
556   timer_adjust(raster_interrupt_timer, video_screen_get_time_until_pos(0, 0, machine->screen[0].visarea.max_x + 1), 0, attotime_zero);
557557}
558558
559559
src/mame/drivers/circus.c
r1293r1294
275275   MDRV_CPU_VBLANK_INT(irq0_line_hold,1)
276276
277277   MDRV_SCREEN_REFRESH_RATE(57)
278   MDRV_SCREEN_VBLANK_TIME(USEC_TO_SUBSECONDS(3500)  /* frames per second, vblank duration (complete guess) */)
278   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(3500)  /* frames per second, vblank duration (complete guess) */)
279279
280280   /* video hardware */
281281   MDRV_VIDEO_ATTRIBUTES(VIDEO_TYPE_RASTER)
r1293r1294
310310   MDRV_CPU_VBLANK_INT(irq0_line_hold,1)
311311
312312   MDRV_SCREEN_REFRESH_RATE(57)
313   MDRV_SCREEN_VBLANK_TIME(USEC_TO_SUBSECONDS(3500)  /* frames per second, vblank duration (complete guess) */)
313   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(3500)  /* frames per second, vblank duration (complete guess) */)
314314
315315   /* video hardware */
316316   MDRV_VIDEO_ATTRIBUTES(VIDEO_TYPE_RASTER)
r1293r1294
344344   MDRV_CPU_VBLANK_INT(irq0_line_hold,2)
345345
346346   MDRV_SCREEN_REFRESH_RATE(57)
347   MDRV_SCREEN_VBLANK_TIME(USEC_TO_SUBSECONDS(3500)  /* frames per second, vblank duration (complete guess) */)
347   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(3500)  /* frames per second, vblank duration (complete guess) */)
348348
349349   /* video hardware */
350350   MDRV_VIDEO_ATTRIBUTES(VIDEO_TYPE_RASTER)
r1293r1294
378378   //MDRV_CPU_VBLANK_INT(ripcord_interrupt,1) //AT
379379
380380   MDRV_SCREEN_REFRESH_RATE(57)
381   MDRV_SCREEN_VBLANK_TIME(USEC_TO_SUBSECONDS(3500)  /* frames per second, vblank duration (complete guess) */)
381   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(3500)  /* frames per second, vblank duration (complete guess) */)
382382
383383   /* video hardware */
384384   MDRV_VIDEO_ATTRIBUTES(VIDEO_TYPE_RASTER)
src/mame/drivers/zac2650.c
r1293r1294
327327   MDRV_CPU_IO_MAP(readport,0)
328328
329329   MDRV_SCREEN_REFRESH_RATE(55)
330   MDRV_SCREEN_VBLANK_TIME(USEC_TO_SUBSECONDS(1041))
330   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(1041))
331331
332332   /* video hardware */
333333   MDRV_VIDEO_ATTRIBUTES(VIDEO_TYPE_RASTER)
src/mame/drivers/pkscram.c
r1293r1294
2525static UINT16* pkscramble_bgtilemap_ram;
2626
2727static tilemap *fg_tilemap, *md_tilemap, *bg_tilemap;
28static mame_timer *scanline_timer;
28static emu_timer *scanline_timer;
2929
3030static WRITE16_HANDLER( pkscramble_fgtilemap_w )
3131{
r1293r1294
212212   {
213213       if (out&0x2000)
214214          cpunum_set_input_line(0, 1, ASSERT_LINE);
215      mame_timer_adjust(scanline_timer, video_screen_get_time_until_pos(0, param+1, 0), param+1, time_zero);
215      timer_adjust(scanline_timer, video_screen_get_time_until_pos(0, param+1, 0), param+1, attotime_zero);
216216      interrupt_line_active = 1;
217217   }
218218   else
219219   {
220220      if (interrupt_line_active)
221221          cpunum_set_input_line(0, 1, CLEAR_LINE);
222      mame_timer_adjust(scanline_timer, video_screen_get_time_until_pos(0, interrupt_scanline, 0), interrupt_scanline, time_zero);
222      timer_adjust(scanline_timer, video_screen_get_time_until_pos(0, interrupt_scanline, 0), interrupt_scanline, attotime_zero);
223223      interrupt_line_active = 0;
224224   }
225225}
r1293r1294
274274{
275275   out = 0;
276276   interrupt_line_active=0;
277   scanline_timer = mame_timer_alloc(scanline_callback);
278   mame_timer_adjust(scanline_timer, video_screen_get_time_until_pos(0, interrupt_scanline, 0), interrupt_scanline, time_zero);
277   scanline_timer = timer_alloc(scanline_callback);
278   timer_adjust(scanline_timer, video_screen_get_time_until_pos(0, interrupt_scanline, 0), interrupt_scanline, attotime_zero);
279279
280280   state_save_register_global(out);
281281   state_save_register_global(interrupt_line_active);
src/mame/drivers/taito_f3.c
r1293r1294
393393static INTERRUPT_GEN( f3_interrupt2 )
394394{
395395   cpunum_set_input_line(0, 2, HOLD_LINE);   // vblank
396   mame_timer_set( MAME_TIME_IN_CYCLES(10000,0), 0, f3_interrupt3);
396   timer_set( ATTOTIME_IN_CYCLES(10000,0), 0, f3_interrupt3);
397397}
398398
399399static MACHINE_RESET( f3 )
r1293r1294
446446   TAITO_F3_SOUND_SYSTEM_CPU(16000000)
447447
448448   MDRV_SCREEN_REFRESH_RATE(58.97)
449   MDRV_SCREEN_VBLANK_TIME(USEC_TO_SUBSECONDS(624) /* 58.97 Hz, 624us vblank time */)
449   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(624) /* 58.97 Hz, 624us vblank time */)
450450
451451   MDRV_MACHINE_START(f3)
452452   MDRV_MACHINE_RESET(f3)
src/mame/drivers/beaminv.c
r1293r1294
7272
7373static const int interrupt_lines[INTERRUPTS_PER_FRAME] = { 0x00, 0x80 };
7474
75static mame_timer *interrupt_timer;
75static emu_timer *interrupt_timer;
7676
7777
7878static TIMER_CALLBACK( interrupt_callback )
r1293r1294
8787   next_interrupt_number = (interrupt_number + 1) % INTERRUPTS_PER_FRAME;
8888   next_vpos = interrupt_lines[next_interrupt_number];
8989
90   mame_timer_adjust(interrupt_timer, video_screen_get_time_until_pos(0, next_vpos, 0), next_interrupt_number, time_zero);
90   timer_adjust(interrupt_timer, video_screen_get_time_until_pos(0, next_vpos, 0), next_interrupt_number, attotime_zero);
9191}
9292
9393
9494static void create_interrupt_timer(void)
9595{
96   interrupt_timer = mame_timer_alloc(interrupt_callback);
96   interrupt_timer = timer_alloc(interrupt_callback);
9797}
9898
9999
100100static void start_interrupt_timer(void)
101101{
102102   int vpos = interrupt_lines[0];
103   mame_timer_adjust(interrupt_timer, video_screen_get_time_until_pos(0, vpos, 0), 0, time_zero);
103   timer_adjust(interrupt_timer, video_screen_get_time_until_pos(0, vpos, 0), 0, attotime_zero);
104104}
105105
106106
src/mame/drivers/m107.c
r1293r1294
2727
2828
2929
30static mame_timer *scanline_timer;
30static emu_timer *scanline_timer;
3131static UINT8 m107_irq_vectorbase;
3232
3333static TIMER_CALLBACK( m107_scanline_interrupt );
r1293r1294
4545
4646static MACHINE_START( m107 )
4747{
48   scanline_timer = mame_timer_alloc(m107_scanline_interrupt);
48   scanline_timer = timer_alloc(m107_scanline_interrupt);
4949}
5050
5151static MACHINE_RESET( m107 )
5252{
53   mame_timer_adjust(scanline_timer, video_screen_get_time_until_pos(0, 0, 0), 0, time_never);
53   timer_adjust(scanline_timer, video_screen_get_time_until_pos(0, 0, 0), 0, attotime_never);
5454}
5555
5656/*****************************************************************************/
r1293r1294
7676   /* adjust for next scanline */
7777   if (++scanline >= machine->screen[0].height)
7878      scanline = 0;
79   mame_timer_adjust(scanline_timer, video_screen_get_time_until_pos(0, scanline, 0), scanline, time_never);
79   timer_adjust(scanline_timer, video_screen_get_time_until_pos(0, scanline, 0), scanline, attotime_never);
8080}
8181
8282
src/mame/drivers/crshrace.c
r1293r1294
726726ROM_END
727727
728728
729#ifdef UNUSED_FUNCTION
729730void crshrace_patch_code(UINT16 offset)
730731{
731732   /* A hack which shows 3 player mode in code which is disabled */
r1293r1294
734735   RAM[(offset + 2)/2] = 0x4e71;
735736   RAM[(offset + 4)/2] = 0x4e71;
736737}
738#endif
737739
738740
739741static DRIVER_INIT( crshrace )
src/mame/drivers/clshroad.c
r1293r1294
2020#include "driver.h"
2121#include "sound/custom.h"
2222
23UINT8 *clshroad_sharedram;
23static UINT8 *clshroad_sharedram;
2424
2525/* Variables & functions defined in video: */
2626
src/mame/drivers/pacman.c
r1293r1294
355355#define VBSTART            (224)   /*(224+16)*/
356356
357357
358UINT8 cannonb_bit_to_read;
358static UINT8 cannonb_bit_to_read;
359359
360360
361361/*************************************
src/mame/drivers/bwing.c
r1293r1294
5858//****************************************************************************
5959// Interrupt Handlers
6060
61INTERRUPT_GEN ( bwp1_interrupt )
61static INTERRUPT_GEN ( bwp1_interrupt )
6262{
6363   static int coin = 0;
6464   UINT8 latch_data;
r1293r1294
9090}
9191
9292
93INTERRUPT_GEN ( bwp3_interrupt ) { if (!bwp3_nmimask) cpunum_set_input_line(2, INPUT_LINE_NMI, ASSERT_LINE); }
93static INTERRUPT_GEN ( bwp3_interrupt ) { if (!bwp3_nmimask) cpunum_set_input_line(2, INPUT_LINE_NMI, ASSERT_LINE); }
9494
9595//****************************************************************************
9696// Memory and I/O Handlers
r1293r1294
404404   MDRV_CPU_PERIODIC_INT(bwp3_interrupt, 1000)
405405
406406   MDRV_SCREEN_REFRESH_RATE(60)
407   MDRV_SCREEN_VBLANK_TIME(USEC_TO_SUBSECONDS(600))   // must be long enough for polling
407   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(600))   // must be long enough for polling
408408   MDRV_INTERLEAVE(300)      // high enough?
409409
410410   MDRV_MACHINE_RESET(bwing)
src/mame/drivers/srmp6.c
r1293r1294
702702    Machine driver
703703***************************************************************************/
704704
705INTERRUPT_GEN(srmp6_interrupt)
705static INTERRUPT_GEN(srmp6_interrupt)
706706{
707707   if(!cpu_getiloops())
708708   {
src/mame/drivers/cball.c
r1293r1294
6464      scanline = 16;
6565   }
6666
67   mame_timer_set(video_screen_get_time_until_pos(0, scanline, 0), scanline, interrupt_callback);
67   timer_set(video_screen_get_time_until_pos(0, scanline, 0), scanline, interrupt_callback);
6868}
6969
7070
7171static MACHINE_RESET( cball )
7272{
73   mame_timer_set(video_screen_get_time_until_pos(0, 16, 0), 16, interrupt_callback);
73   timer_set(video_screen_get_time_until_pos(0, 16, 0), 16, interrupt_callback);
7474}
7575
7676
src/mame/drivers/cave.c
r1293r1294
123123/* Called once/frame to generate the VBLANK interrupt */
124124static INTERRUPT_GEN( cave_interrupt )
125125{
126   mame_timer_set(MAME_TIME_IN_USEC(17376-time_vblank_irq), 0, cave_vblank_start);
127   mame_timer_set(MAME_TIME_IN_USEC(17376-time_vblank_irq + 2000), 0, cave_vblank_end);
126   timer_set(ATTOTIME_IN_USEC(17376-time_vblank_irq), 0, cave_vblank_start);
127   timer_set(ATTOTIME_IN_USEC(17376-time_vblank_irq + 2000), 0, cave_vblank_end);
128128}
129129
130130/* Called by the YMZ280B to set the IRQ state */
r1293r1294
222222//  sound_flag2 = 1;
223223   soundlatch_word_w(offset,data,mem_mask);
224224   cpunum_set_input_line(1, INPUT_LINE_NMI, PULSE_LINE);
225   cpu_spinuntil_time(MAME_TIME_IN_USEC(50));   // Allow the other cpu to reply
225   cpu_spinuntil_time(ATTOTIME_IN_USEC(50));   // Allow the other cpu to reply
226226}
227227
228228/* Sound CPU: read the low 8 bits of the 16 bit sound latch */
r1293r1294
41774177
41784178/* Tiles are 6 bit, 4 bits stored in one rom, 2 bits in the other.
41794179   Expand the 2 bit part into a 4 bit layout, so we can decode it */
4180void sailormn_unpack_tiles( const int region )
4180static void sailormn_unpack_tiles( const int region )
41814181{
41824182   UINT8 *src      =   memory_region(region) + (memory_region_length(region)/4)*3 - 1;
41834183   UINT8 *dst      =   memory_region(region) + (memory_region_length(region)/4)*4 - 2;
src/mame/drivers/brkthru.c
r1293r1294
5151#include "sound/3812intf.h"
5252
5353
54UINT8 *brkthru_nmi_enable; /* needs to be tracked down */
54//UINT8 *brkthru_nmi_enable; /* needs to be tracked down */
5555extern UINT8 *brkthru_videoram;
5656extern size_t brkthru_videoram_size;
5757
r1293r1294
158158
159159
160160
161INTERRUPT_GEN( brkthru_interrupt )
161static INTERRUPT_GEN( brkthru_interrupt )
162162{
163163   if (cpu_getiloops() == 0)
164164   {
src/mame/drivers/fuukifg3.c
r1293r1294
152152#include "sound/262intf.h"
153153#include "sound/ymf278b.h"
154154
155static mame_timer *raster_interrupt_timer;
155static emu_timer *raster_interrupt_timer;
156156static UINT8 fuuki32_shared_ram[16];
157157
158158// Described in src/video/fuuki32.c
r1293r1294
249249      COMBINE_DATA(&fuuki32_vregs[offset]);
250250      if (offset == 0x1c/4)
251251      {
252         mame_timer_adjust(raster_interrupt_timer, video_screen_get_time_until_pos(0, fuuki32_vregs[0x1c/4]>>16, Machine->screen[0].visarea.max_x + 1), 0, video_screen_get_frame_period(0));
252         timer_adjust(raster_interrupt_timer, video_screen_get_time_until_pos(0, fuuki32_vregs[0x1c/4]>>16, Machine->screen[0].visarea.max_x + 1), 0, video_screen_get_frame_period(0));
253253      }
254254   }
255255}
r1293r1294
539539static TIMER_CALLBACK( level_1_interrupt_callback )
540540{
541541   cpunum_set_input_line(0, 1, PULSE_LINE);
542   mame_timer_set(video_screen_get_time_until_pos(0, 248, 0), 0, level_1_interrupt_callback);
542   timer_set(video_screen_get_time_until_pos(0, 248, 0), 0, level_1_interrupt_callback);
543543}
544544
545545
546546static TIMER_CALLBACK( vblank_interrupt_callback )
547547{
548548   cpunum_set_input_line(0, 3, PULSE_LINE);   // VBlank IRQ
549   mame_timer_set(video_screen_get_time_until_pos(0, machine->screen[0].visarea.max_y + 1, 0), 0, vblank_interrupt_callback);
549   timer_set(video_screen_get_time_until_pos(0, machine->screen[0].visarea.max_y + 1, 0), 0, vblank_interrupt_callback);
550550}
551551
552552
r1293r1294
554554{
555555   cpunum_set_input_line(0, 5, PULSE_LINE);   // Raster Line IRQ
556556   video_screen_update_partial(0, video_screen_get_vpos(0));
557   mame_timer_adjust(raster_interrupt_timer, video_screen_get_frame_period(0), 0, time_zero);
557   timer_adjust(raster_interrupt_timer, video_screen_get_frame_period(0), 0, attotime_zero);
558558}
559559
560560
561561static MACHINE_START( fuuki32 )
562562{
563   raster_interrupt_timer = mame_timer_alloc(raster_interrupt_callback);
563   raster_interrupt_timer = timer_alloc(raster_interrupt_callback);
564564}
565565
566566
567567static MACHINE_RESET( fuuki32 )
568568{
569   mame_timer_set(video_screen_get_time_until_pos(0, 248, 0), 0, level_1_interrupt_callback);
570   mame_timer_set(video_screen_get_time_until_pos(0, machine->screen[0].visarea.max_y + 1, 0), 0, vblank_interrupt_callback);
571   mame_timer_adjust(raster_interrupt_timer, video_screen_get_time_until_pos(0, 0, machine->screen[0].visarea.max_x + 1), 0, time_zero);
569   timer_set(video_screen_get_time_until_pos(0, 248, 0), 0, level_1_interrupt_callback);
570   timer_set(video_screen_get_time_until_pos(0, machine->screen[0].visarea.max_y + 1, 0), 0, vblank_interrupt_callback);
571   timer_adjust(raster_interrupt_timer, video_screen_get_time_until_pos(0, 0, machine->screen[0].visarea.max_x + 1), 0, attotime_zero);
572572}
573573
574574
src/mame/drivers/dec8.c
r1293r1294
20932093   MDRV_CPU_PROGRAM_MAP(dec8_s_readmem,dec8_s_writemem)
20942094                        /* NMIs are caused by the main CPU */
20952095   MDRV_SCREEN_REFRESH_RATE(58)
2096   MDRV_SCREEN_VBLANK_TIME(USEC_TO_SUBSECONDS(529) /* 58Hz, 529ms Vblank duration */)
2096   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(529) /* 58Hz, 529ms Vblank duration */)
20972097
20982098   /* video hardware */
20992099   MDRV_VIDEO_ATTRIBUTES(VIDEO_TYPE_RASTER | VIDEO_BUFFERS_SPRITERAM)
r1293r1294
21322132   MDRV_CPU_PROGRAM_MAP(dec8_s_readmem,dec8_s_writemem)
21332133                        /* NMIs are caused by the main CPU */
21342134   MDRV_SCREEN_REFRESH_RATE(58)
2135   MDRV_SCREEN_VBLANK_TIME(USEC_TO_SUBSECONDS(2500) /* 58Hz, 529ms Vblank duration */)
2135   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(2500) /* 58Hz, 529ms Vblank duration */)
21362136
21372137   /* video hardware */
21382138   MDRV_VIDEO_ATTRIBUTES(VIDEO_TYPE_RASTER | VIDEO_BUFFERS_SPRITERAM)
r1293r1294
21732173   MDRV_CPU_PROGRAM_MAP(dec8_s_readmem,dec8_s_writemem)
21742174                        /* NMIs are caused by the main CPU */
21752175   MDRV_SCREEN_REFRESH_RATE(58)
2176   MDRV_SCREEN_VBLANK_TIME(USEC_TO_SUBSECONDS(529) /* 58Hz, 529ms Vblank duration */)
2176   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(529) /* 58Hz, 529ms Vblank duration */)
21772177
21782178   /* video hardware */
21792179   MDRV_VIDEO_ATTRIBUTES(VIDEO_TYPE_RASTER | VIDEO_BUFFERS_SPRITERAM)
r1293r1294
22122212   MDRV_CPU_PROGRAM_MAP(dec8_s_readmem,oscar_s_writemem)
22132213                        /* NMIs are caused by the main CPU */
22142214   MDRV_SCREEN_REFRESH_RATE(58)
2215   MDRV_SCREEN_VBLANK_TIME(USEC_TO_SUBSECONDS(529) /* 58Hz, 529ms Vblank duration */)
2215   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(529) /* 58Hz, 529ms Vblank duration */)
22162216
22172217   /* video hardware */
22182218   MDRV_VIDEO_ATTRIBUTES(VIDEO_TYPE_RASTER | VIDEO_BUFFERS_SPRITERAM)
r1293r1294
22552255   MDRV_CPU_PROGRAM_MAP(dec8_s_readmem,oscar_s_writemem)
22562256                        /* NMIs are caused by the main CPU */
22572257   MDRV_SCREEN_REFRESH_RATE(58)
2258   MDRV_SCREEN_VBLANK_TIME(USEC_TO_SUBSECONDS(2500) /* 58Hz, 529ms Vblank duration */)
2258   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(2500) /* 58Hz, 529ms Vblank duration */)
22592259   MDRV_INTERLEAVE(40) /* 40 CPU slices per frame */
22602260
22612261   /* video hardware */
r1293r1294
22972297   MDRV_CPU_PROGRAM_MAP(ym3526_s_readmem,ym3526_s_writemem)
22982298                        /* NMIs are caused by the main CPU */
22992299   MDRV_SCREEN_REFRESH_RATE(58)
2300   MDRV_SCREEN_VBLANK_TIME(USEC_TO_SUBSECONDS(2500) /* 58Hz, 529ms Vblank duration */)
2300   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(2500) /* 58Hz, 529ms Vblank duration */)
23012301   MDRV_INTERLEAVE(200)
23022302
23032303   /* video hardware */
r1293r1294
23392339   MDRV_CPU_PROGRAM_MAP(ym3526_s_readmem,ym3526_s_writemem)
23402340                        /* NMIs are caused by the main CPU */
23412341   MDRV_SCREEN_REFRESH_RATE(58)
2342   MDRV_SCREEN_VBLANK_TIME(USEC_TO_SUBSECONDS(2500) /* 58Hz, 529ms Vblank duration */)
2342   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(2500) /* 58Hz, 529ms Vblank duration */)
23432343   MDRV_INTERLEAVE(80)
23442344
23452345   /* video hardware */
r1293r1294
23822382   MDRV_CPU_PROGRAM_MAP(csilver_s_readmem,csilver_s_writemem)
23832383                        /* NMIs are caused by the main CPU */
23842384   MDRV_SCREEN_REFRESH_RATE(58)
2385   MDRV_SCREEN_VBLANK_TIME(USEC_TO_SUBSECONDS(529) /* 58Hz, 529ms Vblank duration */)
2385   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(529) /* 58Hz, 529ms Vblank duration */)
23862386   MDRV_INTERLEAVE(100)
23872387
23882388   /* video hardware */
r1293r1294
24262426   MDRV_CPU_PROGRAM_MAP(dec8_s_readmem,oscar_s_writemem)
24272427                        /* NMIs are caused by the main CPU */
24282428   MDRV_SCREEN_REFRESH_RATE(58)
2429   MDRV_SCREEN_VBLANK_TIME(USEC_TO_SUBSECONDS(529) /* 58Hz, 529ms Vblank duration */)
2429   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(529) /* 58Hz, 529ms Vblank duration */)
24302430
24312431   /* video hardware */
24322432   MDRV_VIDEO_ATTRIBUTES(VIDEO_TYPE_RASTER | VIDEO_BUFFERS_SPRITERAM)
src/mame/drivers/mnight.c
r1293r1294
3434   main_cpu_num = 0;
3535}
3636
37INTERRUPT_GEN( mnight_interrupt )
37static INTERRUPT_GEN( mnight_interrupt )
3838{
3939   cpunum_set_input_line_and_vector(0,0,HOLD_LINE,0xd7);   /* RST 10h */
4040}
r1293r1294
351351   MDRV_CPU_VBLANK_INT(irq0_line_hold,2)
352352
353353   MDRV_SCREEN_REFRESH_RATE(60)
354   MDRV_SCREEN_VBLANK_TIME(USEC_TO_SUBSECONDS(10000))
354   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(10000))
355355   MDRV_INTERLEAVE(10)
356356
357357   MDRV_MACHINE_RESET(mnight)
src/mame/drivers/battlane.c
r1293r1294
104104   AM_RANGE(0x4000, 0xffff) AM_ROM
105105ADDRESS_MAP_END
106106
107INTERRUPT_GEN( battlane_cpu1_interrupt )
107static INTERRUPT_GEN( battlane_cpu1_interrupt )
108108{
109109   /* See note in battlane_cpu_command_w */
110110
src/mame/drivers/genesis.c
r1293r1294
2828static UINT8      scanline_int;      /* INT4 - programmable */
2929static UINT8      vblank_int;         /* INT6 - on every VBLANK */
3030
31static mame_timer *   scan_timer;
31static emu_timer *   scan_timer;
3232
3333
3434static int z80running;
r1293r1294
103103      {
104104         scanline_int = 1;
105105         update_interrupts();
106         mame_timer_set(video_screen_get_time_until_pos(0, scanline + 1, 0), 0, vdp_int4_off);
106         timer_set(video_screen_get_time_until_pos(0, scanline + 1, 0), 0, vdp_int4_off);
107107      }
108108
109109   /* advance to the next scanline */
r1293r1294
114114      scanline = 0;
115115
116116   /* set a timer */
117   mame_timer_adjust(scan_timer, video_screen_get_time_until_pos(0, scanline, 320), scanline, time_zero);
117   timer_adjust(scan_timer, video_screen_get_time_until_pos(0, scanline, 320), scanline, attotime_zero);
118118}
119119
120120
r1293r1294
134134   update_interrupts();
135135
136136   /* set a timer to turn it off */
137   mame_timer_set(video_screen_get_time_until_pos(0, video_screen_get_vpos(0), 22), 0, vdp_int6_off);
137   timer_set(video_screen_get_time_until_pos(0, video_screen_get_vpos(0), 22), 0, vdp_int6_off);
138138}
139139
140140
r1293r1294
172172   logerror("Machine init\n");
173173
174174   /* set the first scanline 0 timer to go off */
175   scan_timer = mame_timer_alloc(vdp_reload_counter);
176   mame_timer_adjust(scan_timer, video_screen_get_time_until_pos(0, 0, 320), 0, time_zero);
175   scan_timer = timer_alloc(vdp_reload_counter);
176   timer_adjust(scan_timer, video_screen_get_time_until_pos(0, 0, 320), 0, attotime_zero);
177177}
178178
179179
src/mame/drivers/cloud9.c
r1293r1294
112112static UINT8 *nvram_stage;
113113static const UINT8 *syncprom;
114114static UINT8 irq_state;
115static mame_timer *irq_timer;
115static emu_timer *irq_timer;
116116
117117int cloud9_vblank_start;
118118int cloud9_vblank_end;
r1293r1294
131131   curscanline = (curscanline + 64) & 255;
132132
133133   /* next one at the start of this scanline */
134   mame_timer_adjust(irq_timer, video_screen_get_time_until_pos(0, curscanline, 0), curscanline, time_zero);
134   timer_adjust(irq_timer, video_screen_get_time_until_pos(0, curscanline, 0), curscanline, attotime_zero);
135135}
136136
137137
r1293r1294
193193   visarea.max_x = 255;
194194   visarea.min_y = cloud9_vblank_end + 1;
195195   visarea.max_y = cloud9_vblank_start;
196   video_screen_configure(0, 320, 256, &visarea, HZ_TO_SUBSECONDS(PIXEL_CLOCK) * VTOTAL * HTOTAL);
196   video_screen_configure(0, 320, 256, &visarea, HZ_TO_ATTOSECONDS(PIXEL_CLOCK) * VTOTAL * HTOTAL);
197197
198198   /* create a timer for IRQs and set up the first callback */
199   irq_timer = mame_timer_alloc(clock_irq);
199   irq_timer = timer_alloc(clock_irq);
200200   irq_state = 0;
201201   schedule_next_irq(0-64);
202202
src/mame/drivers/yard.c
r1293r1294
200200   MDRV_CPU_VBLANK_INT(irq0_line_hold, 1)
201201
202202   MDRV_SCREEN_REFRESH_RATE(57)
203   MDRV_SCREEN_VBLANK_TIME(USEC_TO_SUBSECONDS(1790))
203   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(1790))
204204   /* accurate frequency, measured on a Moon Patrol board, is 56.75Hz.
205205       the Lode Runner manual (similar but different hardware)
206206       talks about 55Hz and 1790ms vblank duration. */
src/mame/drivers/rabbit.c
r1293r1294
9595static UINT32 *rabbit_spriteregs;
9696static UINT32 *rabbit_blitterregs;
9797static mame_bitmap *rabbit_sprite_bitmap;
98rectangle rabbit_sprite_clip;
98static rectangle rabbit_sprite_clip;
9999
100100static int rabbit_vblirqlevel, rabbit_bltirqlevel, rabbit_banking;
101101
102UINT32 *rabbit_tilemap_ram[4];
102static UINT32 *rabbit_tilemap_ram[4];
103103
104UINT32 *rabbit_spriteram;
104static UINT32 *rabbit_spriteram;
105105static tilemap *rabbit_tilemap[4];
106106
107107/* call with tilesize = 0 for 8x8 or 1 for 16x16 */
r1293r1294
612612   cpunum_set_input_line(0, rabbit_bltirqlevel, HOLD_LINE);
613613}
614614
615void rabbit_do_blit(void)
615static void rabbit_do_blit(void)
616616{
617617   UINT8 *blt_data = memory_region(REGION_USER1);
618618   int blt_source = (rabbit_blitterregs[0]&0x000fffff)>>0;
r1293r1294
656656            if (!blt_amount)
657657            {
658658               if(BLITLOG) mame_printf_debug("end of blit list\n");
659               mame_timer_set(MAME_TIME_IN_USEC(500),0,rabbit_blit_done);
659               timer_set(ATTOTIME_IN_USEC(500),0,rabbit_blit_done);
660660               return;
661661            }
662662
src/mame/drivers/asuka.c
r1293r1294
239239   cpunum_set_input_line(0, 5, HOLD_LINE);
240240}
241241
242INTERRUPT_GEN( cadash_interrupt )
242static INTERRUPT_GEN( cadash_interrupt )
243243{
244   mame_timer_set(MAME_TIME_IN_CYCLES(500,0),0, cadash_interrupt5);
244   timer_set(ATTOTIME_IN_CYCLES(500,0),0, cadash_interrupt5);
245245   cpunum_set_input_line(0, 4, HOLD_LINE);  /* interrupt vector 4 */
246246}
247247
src/mame/drivers/backfire.c
r1293r1294
2323#include "deco16ic.h"
2424#include "rendlay.h"
2525
26UINT32 *backfire_spriteram32_1;
27UINT32 *backfire_spriteram32_2;
28UINT32 *backfire_mainram;
29mame_bitmap * backfire_left;
30mame_bitmap * backfire_right;
26static UINT32 *backfire_spriteram32_1;
27static UINT32 *backfire_spriteram32_2;
28static UINT32 *backfire_mainram;
29static mame_bitmap * backfire_left;
30static mame_bitmap * backfire_right;
3131
3232//UINT32 *backfire_180010, *backfire_188010;
33UINT32 *backfire_left_priority, *backfire_right_priority;
33static UINT32 *backfire_left_priority, *backfire_right_priority;
3434
3535/* I'm using the functions in deco16ic.c ... same chips, why duplicate code? */
3636
r1293r1294
491491   MDRV_CPU_VBLANK_INT(deco32_vbl_interrupt,1)
492492
493493   MDRV_SCREEN_REFRESH_RATE(58)
494   MDRV_SCREEN_VBLANK_TIME(USEC_TO_SUBSECONDS(529))
494   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(529))
495495   MDRV_NVRAM_HANDLER(93C46)
496496
497497   /* video hardware */
r1293r1294
678678{
679679//  mame_printf_debug( "%08x\n",activecpu_get_pc());
680680
681   if (activecpu_get_pc()==0xce44)  cpu_spinuntil_time(MAME_TIME_IN_USEC(400)); // backfire
682   if (activecpu_get_pc()==0xcee4)  cpu_spinuntil_time(MAME_TIME_IN_USEC(400)); // backfira
681   if (activecpu_get_pc()==0xce44)  cpu_spinuntil_time(ATTOTIME_IN_USEC(400)); // backfire
682   if (activecpu_get_pc()==0xcee4)  cpu_spinuntil_time(ATTOTIME_IN_USEC(400)); // backfira
683683
684684   return backfire_mainram[0x18/4];
685685}
src/mame/drivers/rollerg.c
r1293r1294
6767static WRITE8_HANDLER( sound_arm_nmi_w )
6868{
6969   cpunum_set_input_line(1, INPUT_LINE_NMI, CLEAR_LINE);
70   mame_timer_set(MAME_TIME_IN_USEC(50),0,nmi_callback);   /* kludge until the K053260 is emulated correctly */
70   timer_set(ATTOTIME_IN_USEC(50),0,nmi_callback);   /* kludge until the K053260 is emulated correctly */
7171}
7272
7373static READ8_HANDLER( pip_r )
src/mame/drivers/starwars.c
r1293r1294
382382   MDRV_CPU_ADD(M6809, MASTER_CLOCK / 8)
383383   MDRV_CPU_PROGRAM_MAP(main_map,0)
384384   MDRV_CPU_PERIODIC_INT(irq0_line_assert, (double)MASTER_CLOCK / 4096 / 12)
385   MDRV_WATCHDOG_TIME_INIT(MAME_TIME_IN_HZ(CLOCK_3KHZ / 128))
385   MDRV_WATCHDOG_TIME_INIT(ATTOTIME_IN_HZ(CLOCK_3KHZ / 128))
386386
387387   MDRV_CPU_ADD(M6809, MASTER_CLOCK / 8)
388388   /* audio CPU */
src/mame/drivers/wolfpack.c
r1293r1294
4747      scanline = 0;
4848   }
4949
50   mame_timer_set(video_screen_get_time_until_pos(0, scanline, 0), scanline, periodic_callback);
50   timer_set(video_screen_get_time_until_pos(0, scanline, 0), scanline, periodic_callback);
5151}
5252
5353
5454static MACHINE_RESET( wolfpack )
5555{
56   mame_timer_set(video_screen_get_time_until_pos(0, 0, 0), 0, periodic_callback);
56   timer_set(video_screen_get_time_until_pos(0, 0, 0), 0, periodic_callback);
5757}
5858
5959
src/mame/drivers/tankbatt.c
r1293r1294
174174   AM_RANGE(0x2000, 0x3fff) AM_WRITE(MWA8_ROM)
175175ADDRESS_MAP_END
176176
177INTERRUPT_GEN( tankbatt_interrupt )
177static INTERRUPT_GEN( tankbatt_interrupt )
178178{
179179   if ((readinputport (0) & 0x60) == 0) cpunum_set_input_line(0,0,HOLD_LINE);
180180   else if (tankbatt_nmi_enable) cpunum_set_input_line(0,INPUT_LINE_NMI,PULSE_LINE);
src/mame/drivers/segas18.c
r1293r1294
192192
193193static TIMER_CALLBACK( boost_interleave )
194194{
195   cpu_boost_interleave(time_zero, MAME_TIME_IN_MSEC(10));
195   cpu_boost_interleave(attotime_zero, ATTOTIME_IN_MSEC(10));
196196}
197197
198198
src/mame/drivers/ltcasino.c
r1293r1294
1616#include "driver.h"
1717#include "sound/ay8910.h"
1818
19UINT8 *ltcasino_tile_num_ram, *ltcasino_tile_atr_ram;
19static UINT8 *ltcasino_tile_num_ram, *ltcasino_tile_atr_ram;
2020
21tilemap *ltcasino_tilemap;
21static tilemap *ltcasino_tilemap;
2222
2323/* Video */
2424
src/mame/drivers/coolridr.c
r1293r1294
8585
8686/* end video */
8787
88UINT32* sysh1_workram_h;
89UINT16* sysh1_soundram;
88static UINT32* sysh1_workram_h;
89//UINT16* sysh1_soundram;
9090
9191// what's wrong:
9292//
src/mame/drivers/darkmist.c
r1293r1294
3535PALETTE_INIT(darkmist);
3636
3737UINT8 * darkmist_scroll;
38UINT8 * darkmist_workram;
38static UINT8 * darkmist_workram;
3939
4040int darkmist_hw;
4141
r1293r1294
236236   GFXDECODE_ENTRY( REGION_GFX3, 0, tilelayout,  0, 16*4 )
237237GFXDECODE_END
238238
239INTERRUPT_GEN( darkmist_interrupt )
239static INTERRUPT_GEN( darkmist_interrupt )
240240{
241241   if(cpu_getiloops())
242242   {
src/mame/drivers/exctsccr.c
r1293r1294
4444extern VIDEO_UPDATE( exctsccr );
4545
4646/* from machine */
47#if MCU_HACK
4748extern UINT8 *exctsccr_mcu_ram;
4849extern WRITE8_HANDLER( exctsccr_mcu_w );
4950extern WRITE8_HANDLER( exctsccr_mcu_control_w );
5051extern WRITE8_HANDLER( exctscc2_mcu_control_w );
52#endif
5153
5254
5355static WRITE8_HANDLER( exctsccr_DAC_data_w )
r1293r1294
108110static UINT8 *mcu_shared_ram;
109111static WRITE8_HANDLER( cexctsccr_mcu_halt_w )
110112{
113#if MCU_HACK
114   exctsccr_mcu_control_w(offset,data&1);
115#else
111116   const int *p;
112117
113118   data &= 1;
114#if MCU_HACK
115   exctsccr_mcu_control_w(offset,data);
116extern UINT8 *exctsccr_mcu_ram;
117#else
118119   cpunum_set_input_line(2, INPUT_LINE_HALT, data ? ASSERT_LINE : CLEAR_LINE);
119120   if( (p=mcu_patch_data) != NULL)
120121   {
r1293r1294
129130         p++;
130131      }
131132   }
133#endif
132134}
133#endif
134135
135136/***************************************************************************
136137
src/mame/drivers/mquake.c
r1293r1294
355355   MDRV_CPU_VBLANK_INT(amiga_scanline_callback, 262)
356356
357357   MDRV_SCREEN_REFRESH_RATE(59.997)
358   MDRV_SCREEN_VBLANK_TIME(USEC_TO_SUBSECONDS(0))
358   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(0))
359359
360360   MDRV_MACHINE_RESET(mquake)
361361   MDRV_NVRAM_HANDLER(generic_0fill)
src/mame/drivers/nitedrvr.c
r1293r1294
154154
155155static MACHINE_RESET( nitedrvr )
156156{
157   mame_timer_pulse(PERIOD_OF_555_ASTABLE(RES_K(180), 330, CAP_U(1)), 0, nitedrvr_crash_toggle_callback);
157   timer_pulse(PERIOD_OF_555_ASTABLE(RES_K(180), 330, CAP_U(1)), 0, nitedrvr_crash_toggle_callback);
158158   nitedrvr_register_machine_vars();
159159}
160160
src/osd/windows/input.c
r1293r1294
14421442   // set absolute mode
14431443   result = dinput_set_dword_property(devinfo->dinput.device, DIPROP_AXISMODE, 0, DIPH_DEVICE, DIPROPAXISMODE_ABS);
14441444    if (result != DI_OK)
1445    {
1446       mame_printf_error("DirectInput: Unable to set absolute mode for joystick %d (%s)\n", generic_device_index(joystick_list, devinfo), devinfo->name);
1447      goto error;
1448   }
1445       mame_printf_warning("DirectInput: Unable to set absolute mode for joystick %d (%s)\n", generic_device_index(joystick_list, devinfo), devinfo->name);
14491446
14501447   // turn off deadzone; we do our own calculations
14511448   result = dinput_set_dword_property(devinfo->dinput.device, DIPROP_DEADZONE, 0, DIPH_DEVICE, 0);
r1293r1294
15271524
15281525exit:
15291526   return DIENUM_CONTINUE;
1530
1531error:
1532   if (devinfo != NULL)
1533      dinput_device_release(devinfo);
1534   goto exit;
15351527}
15361528
15371529
src/osd/windows/drawdd.c
r1293r1294
13031303   // use those as the target for now
13041304   einfo.target_width = einfo.minimum_width * MAX(1, video_config.prescale);
13051305   einfo.target_height = einfo.minimum_height * MAX(1, video_config.prescale);
1306   einfo.target_refresh = SUBSECONDS_TO_HZ(Machine->screen[0].refresh);
1306   einfo.target_refresh = ATTOSECONDS_TO_HZ(Machine->screen[0].refresh);
13071307
13081308   // if we're not stretching, allow some slop on the minimum since we can handle it
13091309   if (!video_config.hwstretch)
src/osd/windows/osinline.h
r1293r1294
174174    divide and return the 32 bit quotient
175175-------------------------------------------------*/
176176
177/* TBD */
177#ifndef PTR64
178#define div_64x32 _div_64x32
179INLINE INT32 _div_64x32(INT64 a, INT32 b)
180{
181   INT32 result;
182   INT32 alow = a;
183   INT32 ahigh = a >> 32;
178184
185    __asm
186    {
187        mov   eax,alow
188        mov   edx,ahigh
189        idiv  b
190        mov   result,eax
191    }
179192
193   return result;
194}
195#endif
196
197
180198/*-------------------------------------------------
181199    divu_64x32 - perform an unsigned 64 bit x 32 bit
182200    divide and return the 32 bit quotient
183201-------------------------------------------------*/
184202
185/* TBD */
203#ifndef PTR64
204#define divu_64x32 _divu_64x32
205INLINE UINT32 _divu_64x32(UINT64 a, UINT32 b)
206{
207   UINT32 result;
208   UINT32 alow = a;
209   UINT32 ahigh = a >> 32;
186210
211    __asm
212    {
213        mov   eax,alow
214        mov   edx,ahigh
215        div   b
216        mov   result,eax
217    }
187218
219   return result;
220}
221#endif
222
223
188224/*-------------------------------------------------
225    div_64x32_rem - perform a signed 64 bit x 32
226    bit divide and return the 32 bit quotient and
227    32 bit remainder
228-------------------------------------------------*/
229
230#ifndef PTR64
231#define div_64x32_rem _div_64x32_rem
232INLINE INT32 _div_64x32_rem(INT64 a, INT32 b, INT32 *remainder)
233{
234   INT32 result;
235   INT32 alow = a;
236   INT32 ahigh = a >> 32;
237   INT32 rem;
238
239    __asm
240    {
241        mov   eax,alow
242        mov   edx,ahigh
243        idiv  b
244        mov   result,eax
245        mov   rem,edx
246    }
247
248   *remainder = rem;
249   return result;
250}
251#endif
252
253
254/*-------------------------------------------------
255    divu_64x32_rem - perform an unsigned 64 bit x
256    32 bit divide and return the 32 bit quotient
257    and 32 bit remainder
258-------------------------------------------------*/
259
260#ifndef PTR64
261#define divu_64x32_rem _divu_64x32_rem
262INLINE UINT32 _divu_64x32_rem(UINT64 a, UINT32 b, UINT32 *remainder)
263{
264   UINT32 result;
265   UINT32 alow = a;
266   UINT32 ahigh = a >> 32;
267   UINT32 rem;
268
269    __asm
270    {
271        mov   eax,alow
272        mov   edx,ahigh
273        div   b
274        mov   result,eax
275        mov   rem,edx
276    }
277
278   *remainder = rem;
279   return result;
280}
281#endif
282
283
284/*-------------------------------------------------
189285    div_32x32_shift - perform a signed divide of
190286    two 32 bit values, shifting the first before
191287    division, and returning the 32 bit quotient
r1293r1294
223319#define divu_32x32_shift _divu_32x32_shift
224320INLINE UINT32 _divu_32x32_shift(UINT32 a, UINT32 b, UINT8 shift)
225321{
226   INT32 result;
322   UINT32 result;
227323
228324    __asm
229325    {
r1293r1294
246342    divide and return the 32 bit remainder
247343-------------------------------------------------*/
248344
249/* TBD */
345#ifndef PTR64
346#define mod_64x32 _mod_64x32
347INLINE INT32 _mod_64x32(INT64 a, INT32 b)
348{
349   INT32 result;
350   INT32 alow = a;
351   INT32 ahigh = a >> 32;
250352
353    __asm
354    {
355        mov   eax,alow
356        mov   edx,ahigh
357        idiv  b
358        mov   result,edx
359    }
251360
361   return result;
362}
363#endif
364
365
252366/*-------------------------------------------------
253367    modu_64x32 - perform an unsigned 64 bit x 32 bit
254368    divide and return the 32 bit remainder
255369-------------------------------------------------*/
256370
257/* TBD */
371#ifndef PTR64
372#define modu_64x32 _modu_64x32
373INLINE UINT32 _modu_64x32(UINT64 a, UINT32 b)
374{
375   UINT32 result;
376   UINT32 alow = a;
377   UINT32 ahigh = a >> 32;
258378
379    __asm
380    {
381        mov   eax,alow
382        mov   edx,ahigh
383        div   b
384        mov   result,edx
385    }
259386
387   return result;
388}
389#endif
390
391
260392/*-------------------------------------------------
261393    recip_approx - compute an approximate floating
262394    point reciprocal
r1293r1294
408540-------------------------------------------------*/
409541
410542#define atomic_increment32 _atomic_increment32
411INLINE INT32 _atomic_increment32(INT32 volatile *ptr, INT32 delta)
543INLINE INT32 _atomic_increment32(INT32 volatile *ptr)
412544{
413545   return _InterlockedIncrement(ptr);
414546}
r1293r1294
421553-------------------------------------------------*/
422554
423555#define atomic_decrement32 _atomic_decrement32
424INLINE INT32 _atomic_decrement32(INT32 volatile *ptr, INT32 delta)
556INLINE INT32 _atomic_decrement32(INT32 volatile *ptr)
425557{
426558   return _InterlockedDecrement(ptr);
427559}
src/osd/windows/drawd3d.c
r1293r1294
706706   d3d->presentation.MultiSampleType            = D3DMULTISAMPLE_NONE;
707707   d3d->presentation.SwapEffect               = D3DSWAPEFFECT_DISCARD;
708708   d3d->presentation.hDeviceWindow               = window->hwnd;
709   d3d->presentation.Windowed                  = (!video_config.switchres || !window->fullscreen) || HAS_WINDOW_MENU;
709   d3d->presentation.Windowed                  = !window->fullscreen || HAS_WINDOW_MENU;
710710   d3d->presentation.EnableAutoDepthStencil      = FALSE;
711711   d3d->presentation.AutoDepthStencilFormat      = D3DFMT_D16;
712712   d3d->presentation.Flags                     = 0;
r1293r1294
11981198
11991199static void pick_best_mode(win_window_info *window)
12001200{
1201   double target_refresh = SUBSECONDS_TO_HZ(Machine->screen[0].refresh);
1201   double target_refresh = ATTOSECONDS_TO_HZ(Machine->screen[0].refresh);
12021202   INT32 target_width, target_height;
12031203   d3d_info *d3d = window->drawdata;
12041204   INT32 minwidth, minheight;
src/osd/winui/properties.c
r1293r1294
666666         sprintf(buf,"%d x %d (V) %f Hz",
667667         drv.screen[0].defstate.visarea.max_y - drv.screen[0].defstate.visarea.min_y + 1,
668668               drv.screen[0].defstate.visarea.max_x - drv.screen[0].defstate.visarea.min_x + 1,
669               SUBSECONDS_TO_HZ(drv.screen[0].defstate.refresh));
669               ATTOSECONDS_TO_HZ(drv.screen[0].defstate.refresh));
670670      else
671671         sprintf(buf,"%d x %d (H) %f Hz",
672672               drv.screen[0].defstate.visarea.max_x - drv.screen[0].defstate.visarea.min_x + 1,
673673               drv.screen[0].defstate.visarea.max_y - drv.screen[0].defstate.visarea.min_y + 1,
674               SUBSECONDS_TO_HZ(drv.screen[0].defstate.refresh));
674               ATTOSECONDS_TO_HZ(drv.screen[0].defstate.refresh));
675675   }
676676   return buf;
677677}
src/emu/debug/debugcpu.c
r1293r1294
6363static int break_on_interrupt_cpunum;
6464static int break_on_interrupt_irqline;
6565static int break_on_time;
66static mame_time break_on_time_target;
66static attotime break_on_time_target;
6767static int memory_modified;
6868static int memory_hook_cpunum;
6969
r1293r1294
430430   execution_state = EXECUTION_STATE_RUNNING;
431431   debug_cpuinfo[cpu_getactivecpu()].temp_breakpoint_pc = ~0;
432432   break_on_time = 1;
433   break_on_time_target = add_mame_times(
434      mame_timer_get_time(),
435      make_mame_time(milliseconds / 1000, (milliseconds % 1000) * (MAX_SUBSECONDS / 1000)));
433   break_on_time_target = attotime_add(
434      timer_get_time(),
435      attotime_make(milliseconds / 1000, (milliseconds % 1000) * (ATTOSECONDS_PER_SECOND / 1000)));
436436}
437437
438438
r1293r1294
746746      }
747747
748748      /* see if we hit a target time */
749      if (break_on_time && compare_mame_times(mame_timer_get_time(), break_on_time_target) > 0)
749      if (break_on_time && attotime_compare(timer_get_time(), break_on_time_target) > 0)
750750      {
751         debug_console_printf("Stopped at time interval %.1g\n", mame_time_to_double(mame_timer_get_time()));
751         debug_console_printf("Stopped at time interval %.1g\n", attotime_to_double(timer_get_time()));
752752         break_on_time = 0;
753753         execution_state = EXECUTION_STATE_STOPPED;
754754      }
src/emu/cpu/h83002/h8priv.h
r1293r1294
2828   UINT16 h8TCNT0, h8TCNT1, h8TCNT2, h8TCNT3, h8TCNT4;
2929   UINT8 h8TSTR;
3030
31   mame_timer *timer[5];
31   emu_timer *timer[5];
3232
3333   int cpu_number;
3434
src/emu/cpu/h83002/h8periph.c
r1293r1294
3434
3535static TIMER_CALLBACK( h8itu_timer_0_cb )
3636{
37   mame_timer_adjust(h8.timer[0], time_never, 0, time_zero);
37   timer_adjust(h8.timer[0], attotime_never, 0, attotime_zero);
3838   h8.h8TCNT0 = 0;
3939   h8.per_regs[TSR0] |= 4;
4040   // interrupt on overflow ?
r1293r1294
4646
4747static TIMER_CALLBACK( h8itu_timer_1_cb )
4848{
49   mame_timer_adjust(h8.timer[1], time_never, 0, time_zero);
49   timer_adjust(h8.timer[1], attotime_never, 0, attotime_zero);
5050   h8.h8TCNT1 = 0;
5151   h8.per_regs[TSR1] |= 4;
5252   // interrupt on overflow ?
r1293r1294
5858
5959static TIMER_CALLBACK( h8itu_timer_2_cb )
6060{
61   mame_timer_adjust(h8.timer[2], time_never, 0, time_zero);
61   timer_adjust(h8.timer[2], attotime_never, 0, attotime_zero);
6262   h8.h8TCNT2 = 0;
6363   h8.per_regs[TSR2] |= 4;
6464   // interrupt on overflow ?
r1293r1294
7070
7171static TIMER_CALLBACK( h8itu_timer_3_cb )
7272{
73   mame_timer_adjust(h8.timer[3], time_never, 0, time_zero);
73   timer_adjust(h8.timer[3], attotime_never, 0, attotime_zero);
7474   h8.h8TCNT3 = 0;
7575   h8.per_regs[TSR3] |= 4;
7676   // interrupt on overflow ?
r1293r1294
8282
8383static TIMER_CALLBACK( h8itu_timer_4_cb )
8484{
85   mame_timer_adjust(h8.timer[4], time_never, 0, time_zero);
85   timer_adjust(h8.timer[4], attotime_never, 0, attotime_zero);
8686   h8.h8TCNT4 = 0;
8787   h8.per_regs[TSR4] |= 4;
8888   // interrupt on overflow ?
r1293r1294
9696{
9797   int ourTCR = 0;
9898   int ourTVAL = 0;
99   mame_time period;
99   attotime period;
100100   static const int tscales[4] = { 1, 2, 4, 8 };
101101
102102   switch (tnum)
r1293r1294
123123         break;
124124   }
125125
126   period = scale_up_mame_time(MAME_TIME_IN_HZ(cpunum_get_clock(h8.cpu_number)), tscales[ourTCR & 3] * (65536 - ourTVAL));
126   period = attotime_mul(ATTOTIME_IN_HZ(cpunum_get_clock(h8.cpu_number)), tscales[ourTCR & 3] * (65536 - ourTVAL));
127127
128128   if (ourTCR & 4)
129129   {
130130      logerror("H8/3002: Timer %d is using an external clock.  Unsupported!\n", tnum);
131131   }
132132
133   mame_timer_adjust(h8.timer[tnum], period, 0, time_zero);
133   timer_adjust(h8.timer[tnum], period, 0, attotime_zero);
134134}
135135
136136static void h8_itu_sync_timers(int tnum)
137137{
138138   int ourTCR = 0;
139   mame_time cycle_time, cur;
139   attotime cycle_time, cur;
140140   UINT16 ratio;
141141   static const int tscales[4] = { 1, 2, 4, 8 };
142142
r1293r1294
160160   }
161161
162162   // get the time per unit
163   cycle_time = scale_up_mame_time(MAME_TIME_IN_HZ(cpunum_get_clock(h8.cpu_number)), tscales[ourTCR & 3]);
164   cur = mame_timer_timeelapsed(h8.timer[tnum]);
163   cycle_time = attotime_mul(ATTOTIME_IN_HZ(cpunum_get_clock(h8.cpu_number)), tscales[ourTCR & 3]);
164   cur = timer_timeelapsed(h8.timer[tnum]);
165165
166   ratio = mame_time_to_double(cur) / mame_time_to_double(cycle_time);
166   ratio = attotime_to_double(cur) / attotime_to_double(cycle_time);
167167
168168   switch (tnum)
169169   {
r1293r1294
484484
485485void h8_itu_init(void)
486486{
487   h8.timer[0] = mame_timer_alloc(h8itu_timer_0_cb);
488   h8.timer[1] = mame_timer_alloc(h8itu_timer_1_cb);
489   h8.timer[2] = mame_timer_alloc(h8itu_timer_2_cb);
490   h8.timer[3] = mame_timer_alloc(h8itu_timer_3_cb);
491   h8.timer[4] = mame_timer_alloc(h8itu_timer_4_cb);
487   h8.timer[0] = timer_alloc(h8itu_timer_0_cb);
488   h8.timer[1] = timer_alloc(h8itu_timer_1_cb);
489   h8.timer[2] = timer_alloc(h8itu_timer_2_cb);
490   h8.timer[3] = timer_alloc(h8itu_timer_3_cb);
491   h8.timer[4] = timer_alloc(h8itu_timer_4_cb);
492492
493493   h8_itu_reset();
494494
r1293r1294
498498void h8_itu_reset(void)
499499{
500500   // stop all the timers
501   mame_timer_adjust(h8.timer[0], time_never, 0, time_zero);
502   mame_timer_adjust(h8.timer[1], time_never, 0, time_zero);
503   mame_timer_adjust(h8.timer[2], time_never, 0, time_zero);
504   mame_timer_adjust(h8.timer[3], time_never, 0, time_zero);
505   mame_timer_adjust(h8.timer[4], time_never, 0, time_zero);
501   timer_adjust(h8.timer[0], attotime_never, 0, attotime_zero);
502   timer_adjust(h8.timer[1], attotime_never, 0, attotime_zero);
503   timer_adjust(h8.timer[2], attotime_never, 0, attotime_zero);
504   timer_adjust(h8.timer[3], attotime_never, 0, attotime_zero);
505   timer_adjust(h8.timer[4], attotime_never, 0, attotime_zero);
506506}
src/emu/cpu/ccpu/ccpu.c
r1293r1294
548548   remove section in brackets and uncomment line below.
549549   Speed Freak should run nice and smooth, with no flickering. */
550550{
551   mame_time scantime, abstime;
552   extern mame_timer *refresh_timer;
553   scantime = mame_timer_starttime(refresh_timer);
554   abstime = mame_timer_get_time();
555   while (compare_mame_times(abstime, scantime) >= 0)
556      scantime = add_mame_times(scantime, video_screen_get_frame_period(ccpu.scrnum));
557   cpu_spinuntil_time(sub_mame_times(scantime, abstime));
551   attotime scantime, abstime;
552   extern emu_timer *refresh_timer;
553   scantime = timer_starttime(refresh_timer);
554   abstime = timer_get_time();
555   while (attotime_compare(abstime, scantime) >= 0)
556      scantime = attotime_add(scantime, video_screen_get_frame_period(ccpu.scrnum));
557   cpu_spinuntil_time(attotime_sub(scantime, abstime));
558558}
559559/*              cpu_spinuntil_time(video_screen_get_time_until_pos(ccpu.scrnum, Machine->screen[ccpu.scrnum].visarea.max_y + 1, 0)); */
560560            NEXT_ACC_A(); CYCLES(1);
src/emu/cpu/tms34010/tms34010.c
r1293r1294
6565   UINT8 reset_deferred;
6666   int (*irq_callback)(int irqline);
6767   const tms34010_config *config;
68   mame_timer *scantimer;
68   emu_timer *scantimer;
6969
7070   /* A registers 0-15 map to regs[0]-regs[15] */
7171   /* B registers 0-15 map to regs[30]-regs[15] */
r1293r1294
616616      screen_to_cpu[config->scrnum] = index;
617617
618618   /* allocate a scanline timer and set it to go off at the start */
619   state.scantimer = mame_timer_alloc(scanline_callback);
620   mame_timer_adjust(state.scantimer, time_zero, index, time_zero);
619   state.scantimer = timer_alloc(scanline_callback);
620   timer_adjust(state.scantimer, attotime_zero, index, attotime_zero);
621621
622622   /* allocate the shiftreg */
623623   state.shiftreg = auto_malloc(SHIFTREG_SIZE);
r1293r1294
640640static void tms34010_reset(void)
641641{
642642   const tms34010_config *config;
643   mame_timer *save_scantimer;
643   emu_timer *save_scantimer;
644644   int (*save_irqcallback)(int);
645645   UINT16 *shiftreg;
646646
r1293r1294
963963         int htotal = SMART_IOREG(HTOTAL);
964964         if (htotal > 0 && vtotal > 0)
965965         {
966            subseconds_t refresh = HZ_TO_SUBSECONDS(state.config->pixclock) * (htotal + 1) * (vtotal + 1);
966            attoseconds_t refresh = HZ_TO_ATTOSECONDS(state.config->pixclock) * (htotal + 1) * (vtotal + 1);
967967            int width = (htotal + 1) * state.config->pixperclock;
968968            int height = vtotal + 1;
969969            rectangle visarea;
r1293r1294
984984            }
985985
986986            LOG(("Configuring screen: HTOTAL=%3d BLANK=%3d-%3d VTOTAL=%3d BLANK=%3d-%3d refresh=%f\n",
987                  htotal, SMART_IOREG(HEBLNK), SMART_IOREG(HSBLNK), vtotal, veblnk, vsblnk, SUBSECONDS_TO_HZ(refresh)));
987                  htotal, SMART_IOREG(HEBLNK), SMART_IOREG(HSBLNK), vtotal, veblnk, vsblnk, ATTOSECONDS_TO_HZ(refresh)));
988988
989989            /* interlaced timing not supported */
990990            if ((SMART_IOREG(DPYCTL) & 0x4000) == 0)
r1293r1294
10291029   if (vcount > vtotal)
10301030      vcount = 0;
10311031
1032   /* note that we add !master (0 or 1) as a subseconds value; this makes no practical difference */
1032   /* note that we add !master (0 or 1) as a attoseconds value; this makes no practical difference */
10331033   /* but helps ensure that masters are updated first before slaves */
1034   mame_timer_adjust(state.scantimer, add_subseconds_to_mame_time(video_screen_get_time_until_pos(state.config->scrnum, vcount, 0), !master), cpunum | (vcount << 8), time_zero);
1034   timer_adjust(state.scantimer, attotime_add_attoseconds(video_screen_get_time_until_pos(state.config->scrnum, vcount, 0), !master), cpunum | (vcount << 8), attotime_zero);
10351035
10361036   /* restore the context */
10371037   cpuintrf_pop_context();
r1293r1294
14601460         /* have an IRQ handler. For this reason, we return it signalled a bit early in order */
14611461         /* to make it past these loops. */
14621462         if (SMART_IOREG(VCOUNT) + 1 == SMART_IOREG(DPYINT) &&
1463            compare_mame_times(mame_timer_timeleft(state.scantimer), MAME_TIME_IN_HZ(40000000/TMS34010_CLOCK_DIVIDER/3)) < 0)
1463            attotime_compare(timer_timeleft(state.scantimer), ATTOTIME_IN_HZ(40000000/TMS34010_CLOCK_DIVIDER/3)) < 0)
14641464            result |= TMS34010_DI;
14651465         return result;
14661466   }
src/emu/cpu/tms32031/tms32031.h
r1293r1294
6666***************************************************************************/
6767
6868extern void tms32031_get_info(UINT32 state, cpuinfo *info);
69extern void tms32032_get_info(UINT32 state, cpuinfo *info);
6970
7071#endif /* _TMS32031_H */
src/emu/cpu/tms32031/tms32031.c
r1293r1294
641641 * Internal memory map
642642 **************************************************************************/
643643
644static ADDRESS_MAP_START( internal, ADDRESS_SPACE_PROGRAM, 32 )
644static ADDRESS_MAP_START( internal_32031, ADDRESS_SPACE_PROGRAM, 32 )
645645   AM_RANGE(0x809800, 0x809fff) AM_RAM
646646ADDRESS_MAP_END
647647
648static ADDRESS_MAP_START( internal_32032, ADDRESS_SPACE_PROGRAM, 32 )
649   AM_RANGE(0x87fe00, 0x87ffff) AM_RAM
650ADDRESS_MAP_END
648651
652
649653/**************************************************************************
650654 * Generic get_info
651655 **************************************************************************/
r1293r1294
745749      case CPUINFO_PTR_DISASSEMBLE:               info->disassemble = tms32031_dasm;      break;
746750#endif /* MAME_DEBUG */
747751      case CPUINFO_PTR_INSTRUCTION_COUNTER:         info->icount = &tms32031_icount;      break;
748      case CPUINFO_PTR_INTERNAL_MEMORY_MAP + ADDRESS_SPACE_PROGRAM: info->internal_map = construct_map_internal; break;
752      case CPUINFO_PTR_INTERNAL_MEMORY_MAP + ADDRESS_SPACE_PROGRAM: info->internal_map = construct_map_internal_32031; break;
749753
750754      /* --- the following bits of info are returned as NULL-terminated strings --- */
751755      case CPUINFO_STR_NAME:                     strcpy(info->s, "TMS32031");         break;
r1293r1294
809813      case CPUINFO_STR_REGISTER + TMS32031_RC:      sprintf(info->s, " RC:%08X", tms32031.r[TMR_RC].i32[0]); break;
810814   }
811815}
816
817void tms32032_get_info(UINT32 state, cpuinfo *info)
818{
819   switch (state)
820   {
821      /* --- the following bits of info are returned as pointers to data or functions --- */
822      case CPUINFO_PTR_INTERNAL_MEMORY_MAP + ADDRESS_SPACE_PROGRAM: info->internal_map = construct_map_internal_32032; break;
823
824      /* --- the following bits of info are returned as NULL-terminated strings --- */
825      case CPUINFO_STR_NAME:                     strcpy(info->s, "TMS32032");         break;
826
827      default:                              tms32031_get_info(state, info);         break;
828   }
829}
src/emu/cpu/cpu.mak
r1293r1294
15161516#-------------------------------------------------
15171517
15181518CPUDEFS += -DHAS_TMS32031=$(if $(filter TMS32031,$(CPUS)),1,0)
1519CPUDEFS += -DHAS_TMS32032=$(if $(filter TMS32032,$(CPUS)),1,0)
15191520
1520ifneq ($(filter TMS32031,$(CPUS)),)
1521ifneq ($(filter TMS32031 TMS32032,$(CPUS)),)
15211522OBJDIRS += $(CPUOBJ)/tms32031
15221523CPUOBJS += $(CPUOBJ)/tms32031/tms32031.o
15231524DBGOBJS += $(CPUOBJ)/tms32031/dis32031.o
src/emu/cpu/m37710/m37710.c
r1293r1294
271271   int cpunum = param;
272272
273273   cpuintrf_push_context(cpunum);
274   mame_timer_adjust(m37710i_cpu.timers[0], m37710i_cpu.reload[0], cpunum, time_zero);
274   timer_adjust(m37710i_cpu.timers[0], m37710i_cpu.reload[0], cpunum, attotime_zero);
275275
276276   m37710i_cpu.m37710_regs[m37710_irq_levels[12]] |= 0x04;
277277   m37710_set_irq_line(M37710_LINE_TIMERA0, PULSE_LINE);
r1293r1294
284284   int cpunum = param;
285285
286286   cpuintrf_push_context(cpunum);
287   mame_timer_adjust(m37710i_cpu.timers[1], m37710i_cpu.reload[1], cpunum, time_zero);
287   timer_adjust(m37710i_cpu.timers[1], m37710i_cpu.reload[1], cpunum, attotime_zero);
288288
289289   m37710i_cpu.m37710_regs[m37710_irq_levels[11]] |= 0x04;
290290   m37710_set_irq_line(M37710_LINE_TIMERA1, PULSE_LINE);
r1293r1294
297297   int cpunum = param;
298298
299299   cpuintrf_push_context(cpunum);
300   mame_timer_adjust(m37710i_cpu.timers[2], m37710i_cpu.reload[2], cpunum, time_zero);
300   timer_adjust(m37710i_cpu.timers[2], m37710i_cpu.reload[2], cpunum, attotime_zero);
301301
302302   m37710i_cpu.m37710_regs[m37710_irq_levels[10]] |= 0x04;
303303   m37710_set_irq_line(M37710_LINE_TIMERA2, PULSE_LINE);
r1293r1294
310310   int cpunum = param;
311311
312312   cpuintrf_push_context(cpunum);
313   mame_timer_adjust(m37710i_cpu.timers[3], m37710i_cpu.reload[3], cpunum, time_zero);
313   timer_adjust(m37710i_cpu.timers[3], m37710i_cpu.reload[3], cpunum, attotime_zero);
314314
315315   m37710i_cpu.m37710_regs[m37710_irq_levels[9]] |= 0x04;
316316   m37710_set_irq_line(M37710_LINE_TIMERA3, PULSE_LINE);
r1293r1294
323323   int cpunum = param;
324324
325325   cpuintrf_push_context(cpunum);
326   mame_timer_adjust(m37710i_cpu.timers[4], m37710i_cpu.reload[4], cpunum, time_zero);
326   timer_adjust(m37710i_cpu.timers[4], m37710i_cpu.reload[4], cpunum, attotime_zero);
327327
328328   m37710i_cpu.m37710_regs[m37710_irq_levels[8]] |= 0x04;
329329   m37710_set_irq_line(M37710_LINE_TIMERA4, PULSE_LINE);
r1293r1294
336336   int cpunum = param;
337337
338338   cpuintrf_push_context(cpunum);
339   mame_timer_adjust(m37710i_cpu.timers[5], m37710i_cpu.reload[5], cpunum, time_zero);
339   timer_adjust(m37710i_cpu.timers[5], m37710i_cpu.reload[5], cpunum, attotime_zero);
340340
341341   m37710i_cpu.m37710_regs[m37710_irq_levels[7]] |= 0x04;
342342   m37710_set_irq_line(M37710_LINE_TIMERB0, PULSE_LINE);
r1293r1294
349349   int cpunum = param;
350350
351351   cpuintrf_push_context(cpunum);
352   mame_timer_adjust(m37710i_cpu.timers[6], m37710i_cpu.reload[6], cpunum, time_zero);
352   timer_adjust(m37710i_cpu.timers[6], m37710i_cpu.reload[6], cpunum, attotime_zero);
353353
354354   m37710i_cpu.m37710_regs[m37710_irq_levels[6]] |= 0x04;
355355   m37710_set_irq_line(M37710_LINE_TIMERB1, PULSE_LINE);
r1293r1294
362362   int cpunum = param;
363363
364364   cpuintrf_push_context(cpunum);
365   mame_timer_adjust(m37710i_cpu.timers[7], m37710i_cpu.reload[7], cpunum, time_zero);
365   timer_adjust(m37710i_cpu.timers[7], m37710i_cpu.reload[7], cpunum, attotime_zero);
366366
367367   m37710i_cpu.m37710_regs[m37710_irq_levels[5]] |= 0x04;
368368   m37710_set_irq_line(M37710_LINE_TIMERB2, PULSE_LINE);
r1293r1294
405405   int cpunum = cpu_getactivecpu();
406406   int tval;
407407   static const int tcr[8] = { 0x56, 0x57, 0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d };
408   mame_time time;
408   attotime time;
409409   static const int tscales[4] = { 2, 16, 64, 512 };
410410
411411   // check if enabled
r1293r1294
425425         switch (m37710i_cpu.m37710_regs[0x56+timer] & 0x3)
426426         {
427427            case 0:            // timer mode
428               time = scale_up_mame_time(MAME_TIME_IN_HZ(16000000), tscales[m37710i_cpu.m37710_regs[tcr[timer]]>>6]);
429               time = scale_up_mame_time(time, tval + 1);
428               time = attotime_mul(ATTOTIME_IN_HZ(16000000), tscales[m37710i_cpu.m37710_regs[tcr[timer]]>>6]);
429               time = attotime_mul(time, tval + 1);
430430
431431               #if M37710_DEBUG
432               mame_printf_debug("Timer %d in timer mode, %f Hz\n", timer, 1.0 / mame_time_to_double(time));
432               mame_printf_debug("Timer %d in timer mode, %f Hz\n", timer, 1.0 / attotime_to_double(time));
433433               #endif
434434
435               mame_timer_adjust(m37710i_cpu.timers[timer], time, cpunum, time_zero);
435               timer_adjust(m37710i_cpu.timers[timer], time, cpunum, attotime_zero);
436436               m37710i_cpu.reload[timer] = time;
437437               break;
438438
r1293r1294
460460         switch (m37710i_cpu.m37710_regs[0x56+timer] & 0x3)
461461         {
462462            case 0:            // timer mode
463               time = scale_up_mame_time(MAME_TIME_IN_HZ(16000000), tscales[m37710i_cpu.m37710_regs[tcr[timer]]>>6]);
464               time = scale_up_mame_time(time, tval + 1);
463               time = attotime_mul(ATTOTIME_IN_HZ(16000000), tscales[m37710i_cpu.m37710_regs[tcr[timer]]>>6]);
464               time = attotime_mul(time, tval + 1);
465465
466466               #if M37710_DEBUG
467               mame_printf_debug("Timer %d in timer mode, %f Hz\n", timer, 1.0 / mame_time_to_double(time));
467               mame_printf_debug("Timer %d in timer mode, %f Hz\n", timer, 1.0 / attotime_to_double(time));
468468               #endif
469469
470               mame_timer_adjust(m37710i_cpu.timers[timer], time, cpunum, time_zero);
470               timer_adjust(m37710i_cpu.timers[timer], time, cpunum, attotime_zero);
471471               m37710i_cpu.reload[timer] = time;
472472               break;
473473
r1293r1294
10471047{
10481048   INT_ACK = irqcallback;
10491049
1050   m37710i_cpu.timers[0] = mame_timer_alloc(m37710_timer_a0_cb);
1051   m37710i_cpu.timers[1] = mame_timer_alloc(m37710_timer_a1_cb);
1052   m37710i_cpu.timers[2] = mame_timer_alloc(m37710_timer_a2_cb);
1053   m37710i_cpu.timers[3] = mame_timer_alloc(m37710_timer_a3_cb);
1054   m37710i_cpu.timers[4] = mame_timer_alloc(m37710_timer_a4_cb);
1055   m37710i_cpu.timers[5] = mame_timer_alloc(m37710_timer_b0_cb);
1056   m37710i_cpu.timers[6] = mame_timer_alloc(m37710_timer_b1_cb);
1057   m37710i_cpu.timers[7] = mame_timer_alloc(m37710_timer_b2_cb);
1050   m37710i_cpu.timers[0] = timer_alloc(m37710_timer_a0_cb);
1051   m37710i_cpu.timers[1] = timer_alloc(m37710_timer_a1_cb);
1052   m37710i_cpu.timers[2] = timer_alloc(m37710_timer_a2_cb);
1053   m37710i_cpu.timers[3] = timer_alloc(m37710_timer_a3_cb);
1054   m37710i_cpu.timers[4] = timer_alloc(m37710_timer_a4_cb);
1055   m37710i_cpu.timers[5] = timer_alloc(m37710_timer_b0_cb);
1056   m37710i_cpu.timers[6] = timer_alloc(m37710_timer_b1_cb);
1057   m37710i_cpu.timers[7] = timer_alloc(m37710_timer_b2_cb);
10581058
10591059   state_save_register_item("M377xx", index, m37710i_cpu.a);
10601060   state_save_register_item("M377xx", index, m37710i_cpu.b);
r1293r1294
10891089   state_save_register_item("M377xx", index, m37710i_cpu.stopped);
10901090   state_save_register_item_array("M377xx", index, m37710i_cpu.m37710_regs);
10911091   state_save_register_item("M377xx", index, m37710i_cpu.reload[0].seconds);
1092   state_save_register_item("M377xx", index, m37710i_cpu.reload[0].subseconds);
1092   state_save_register_item("M377xx", index, m37710i_cpu.reload[0].attoseconds);
10931093   state_save_register_item("M377xx", index, m37710i_cpu.reload[1].seconds);
1094   state_save_register_item("M377xx", index, m37710i_cpu.reload[1].subseconds);
1094   state_save_register_item("M377xx", index, m37710i_cpu.reload[1].attoseconds);
10951095   state_save_register_item("M377xx", index, m37710i_cpu.reload[2].seconds);
1096   state_save_register_item("M377xx", index, m37710i_cpu.reload[2].subseconds);
1096   state_save_register_item("M377xx", index, m37710i_cpu.reload[2].attoseconds);
10971097   state_save_register_item("M377xx", index, m37710i_cpu.reload[3].seconds);
1098   state_save_register_item("M377xx", index, m37710i_cpu.reload[3].subseconds);
1098   state_save_register_item("M377xx", index, m37710i_cpu.reload[3].attoseconds);
10991099   state_save_register_item("M377xx", index, m37710i_cpu.reload[4].seconds);
1100   state_save_register_item("M377xx", index, m37710i_cpu.reload[4].subseconds);
1100   state_save_register_item("M377xx", index, m37710i_cpu.reload[4].attoseconds);
11011101   state_save_register_item("M377xx", index, m37710i_cpu.reload[5].seconds);
1102   state_save_register_item("M377xx", index, m37710i_cpu.reload[5].subseconds);
1102   state_save_register_item("M377xx", index, m37710i_cpu.reload[5].attoseconds);
11031103   state_save_register_item("M377xx", index, m37710i_cpu.reload[6].seconds);
1104   state_save_register_item("M377xx", index, m37710i_cpu.reload[6].subseconds);
1104   state_save_register_item("M377xx", index, m37710i_cpu.reload[6].attoseconds);
11051105   state_save_register_item("M377xx", index, m37710i_cpu.reload[7].seconds);
1106   state_save_register_item("M377xx", index, m37710i_cpu.reload[7].subseconds);
1106   state_save_register_item("M377xx", index, m37710i_cpu.reload[7].attoseconds);
11071107
11081108   state_save_register_func_postload(m37710_restore_state);
11091109}
src/emu/cpu/m37710/m37710cm.h
r1293r1294
105105
106106   // on-board peripheral stuff
107107   UINT8 m37710_regs[128];
108   mame_time reload[8];
109   mame_timer *timers[8];
108   attotime reload[8];
109   emu_timer *timers[8];
110110} m37710i_cpu_struct;
111111
112112extern m37710i_cpu_struct m37710i_cpu;
src/emu/cpu/sc61860/sc61860.c
r1293r1294
9494static void sc61860_init(int index, int clock, const void *config, int (*irqcallback)(int))
9595{
9696   sc61860.config = (SC61860_CONFIG *) config;
97   mame_timer_pulse(MAME_TIME_IN_HZ(500), 0, sc61860_2ms_tick);
97   timer_pulse(ATTOTIME_IN_HZ(500), 0, sc61860_2ms_tick);
9898}
9999
100100static void sc61860_get_context (void *dst)
src/emu/cpu/dsp56k/dsp56k.c
r1293r1294
10331033            /* Maybe this isn't needed? */
10341034            if (!memtest3_hack)
10351035            {
1036               cpu_boost_interleave(time_zero, MAME_TIME_IN_USEC(100));
1036               cpu_boost_interleave(attotime_zero, ATTOTIME_IN_USEC(100));
10371037               memtest3_hack++;
10381038            }
10391039         }
src/emu/cpu/tlcs90/tlcs90.c
r1293r1294
2121   UINT32      ixbase,iybase;
2222
2323   // Timers: 4 x 8-bit + 1 x 16-bit
24   mame_timer   *timer[4+1];
24   emu_timer   *timer[4+1];
2525   UINT8      timer_value[4];
2626   UINT16      timer4_value;
27   mame_time   timer_period;
27   attotime   timer_period;
2828
2929}   t90_Regs;
3030
r1293r1294
23052305void t90_start_timer(int i)
23062306{
23072307   int prescaler;
2308   mame_time period;
2308   attotime period;
23092309
23102310   T90.timer_value[i] = 0;
23112311
r1293r1294
23422342   }
23432343
23442344
2345   period = scale_up_mame_time(T90.timer_period, prescaler);
2345   period = attotime_mul(T90.timer_period, prescaler);
23462346
2347   mame_timer_adjust(T90.timer[i], period, i, period);
2347   timer_adjust(T90.timer[i], period, i, period);
23482348
2349   logerror("%04X: CPU Timer %d started at %lf Hz\n", activecpu_get_pc(), i, 1.0 / mame_time_to_double(period));
2349   logerror("%04X: CPU Timer %d started at %lf Hz\n", activecpu_get_pc(), i, 1.0 / attotime_to_double(period));
23502350}
23512351
23522352void t90_start_timer4(void)
23532353{
23542354   int prescaler;
2355   mame_time period;
2355   attotime period;
23562356
23572357   T90.timer4_value = 0;
23582358
r1293r1294
23642364               return;
23652365   }
23662366
2367   period = scale_up_mame_time(T90.timer_period, prescaler);
2367   period = attotime_mul(T90.timer_period, prescaler);
23682368
2369   mame_timer_adjust(T90.timer[4], period, 4, period);
2369   timer_adjust(T90.timer[4], period, 4, period);
23702370
2371   logerror("%04X: CPU Timer 4 started at %lf Hz\n", activecpu_get_pc(), 1.0 / mame_time_to_double(period));
2371   logerror("%04X: CPU Timer 4 started at %lf Hz\n", activecpu_get_pc(), 1.0 / attotime_to_double(period));
23722372}
23732373
23742374
23752375void t90_stop_timer(int i)
23762376{
2377   mame_timer_adjust(T90.timer[i], time_never, i, time_zero);
2377   timer_adjust(T90.timer[i], attotime_never, i, attotime_zero);
23782378   logerror("%04X: CPU Timer %d stopped\n", activecpu_get_pc(), i);
23792379}
23802380
r1293r1294
26522652   memset(&T90, 0, sizeof(T90));
26532653   T90.irq_callback = irqcallback;
26542654
2655   T90.timer_period = scale_up_mame_time(MAME_TIME_IN_HZ(cpunum_get_clock(cpu_getactivecpu())), 8);
2655   T90.timer_period = attotime_mul(ATTOTIME_IN_HZ(cpunum_get_clock(cpu_getactivecpu())), 8);
26562656
26572657   // Reset registers to their initial values
26582658
r1293r1294
26622662   // Timers
26632663
26642664   for (i = 0; i < 4; i++)
2665      T90.timer[i] = mame_timer_alloc(t90_timer_callback);
2665      T90.timer[i] = timer_alloc(t90_timer_callback);
26662666
2667   T90.timer[4] = mame_timer_alloc(t90_timer4_callback);
2667   T90.timer[4] = timer_alloc(t90_timer4_callback);
26682668}
26692669
26702670static ADDRESS_MAP_START(tmp90840_mem, ADDRESS_SPACE_PROGRAM, 8)
src/emu/cpu/powerpc/ppc.c
r1293r1294
146146   UINT8 sptc;
147147   UINT8 sprb;
148148   UINT8 sptb;
149   mame_timer *rx_timer;
150   mame_timer *tx_timer;
149   emu_timer *rx_timer;
150   emu_timer *tx_timer;
151151} SPU_REGS;
152152
153153typedef union {
r1293r1294
921921   // !!! why is rfci here !!!
922922   optable19[51] = ppc_rfci;
923923
924   ppc.spu.rx_timer = mame_timer_alloc(ppc403_spu_rx_callback);
925   ppc.spu.tx_timer = mame_timer_alloc(ppc403_spu_tx_callback);
924   ppc.spu.rx_timer = timer_alloc(ppc403_spu_rx_callback);
925   ppc.spu.tx_timer = timer_alloc(ppc403_spu_tx_callback);
926926
927927   ppc.read8 = ppc403_read8;
928928   ppc.read16 = ppc403_read16;
src/emu/cpu/powerpc/ppcdrc.c
r1293r1294
177177   UINT8 sptc;
178178   UINT8 sprb;
179179   UINT8 sptb;
180   mame_timer *rx_timer;
181   mame_timer *tx_timer;
180   emu_timer *rx_timer;
181   emu_timer *tx_timer;
182182} SPU_REGS;
183183
184184typedef union {
r1293r1294
10741074   optable31[163] = recompile_wrteei;
10751075   optable19[51] = recompile_rfci;
10761076
1077   ppc.spu.rx_timer = mame_timer_alloc(ppc403_spu_rx_callback);
1078   ppc.spu.tx_timer = mame_timer_alloc(ppc403_spu_tx_callback);
1077   ppc.spu.rx_timer = timer_alloc(ppc403_spu_rx_callback);
1078   ppc.spu.tx_timer = timer_alloc(ppc403_spu_tx_callback);
10791079
10801080   ppc.is603 = 0;
10811081   ppc.is602 = 0;
src/emu/cpu/sh2/sh2.c
r1293r1294
150150   int    internal_irq_level;
151151   int    internal_irq_vector;
152152
153   mame_timer *timer;
154   mame_timer *dma_timer[2];
153   emu_timer *timer;
154   emu_timer *dma_timer[2];
155155   int     dma_timer_active[2];
156156
157157   int     is_slave, cpu_number;
r1293r1294
24112411   int max_delta = 0xfffff;
24122412   UINT16 frc;
24132413
2414   mame_timer_adjust(sh2.timer, time_never, 0, time_zero);
2414   timer_adjust(sh2.timer, attotime_never, 0, attotime_zero);
24152415
24162416   frc = sh2.frc;
24172417   if(!(sh2.m[4] & OCFA)) {
r1293r1294
24372437      if(divider) {
24382438         max_delta <<= divider;
24392439         sh2.frc_base = cpunum_gettotalcycles(sh2.cpu_number);
2440         mame_timer_adjust(sh2.timer, MAME_TIME_IN_CYCLES(max_delta, sh2.cpu_number), sh2.cpu_number, time_zero);
2440         timer_adjust(sh2.timer, ATTOTIME_IN_CYCLES(max_delta, sh2.cpu_number), sh2.cpu_number, attotime_zero);
24412441      } else {
24422442         logerror("SH2.%d: Timer event in %d cycles of external clock", sh2.cpu_number, max_delta);
24432443      }
r1293r1294
25572557         LOG(("SH2: DMA %d start %x, %x, %x, %04x, %d, %d, %d\n", dma, src, dst, count, sh2.m[0x63+4*dma], incs, incd, size));
25582558
25592559         sh2.dma_timer_active[dma] = 1;
2560         mame_timer_adjust(sh2.dma_timer[dma], MAME_TIME_IN_CYCLES(2*count+1, sh2.cpu_number), (sh2.cpu_number<<1)|dma, time_zero);
2560         timer_adjust(sh2.dma_timer[dma], ATTOTIME_IN_CYCLES(2*count+1, sh2.cpu_number), (sh2.cpu_number<<1)|dma, attotime_zero);
25612561
25622562         src &= AM;
25632563         dst &= AM;
r1293r1294
26362636      if(sh2.dma_timer_active[dma])
26372637      {
26382638         logerror("SH2: DMA %d cancelled in-flight", dma);
2639         mame_timer_adjust(sh2.dma_timer[dma], time_never, 0, time_zero);
2639         timer_adjust(sh2.dma_timer[dma], attotime_never, 0, attotime_zero);
26402640         sh2.dma_timer_active[dma] = 0;
26412641      }
26422642   }
r1293r1294
29332933{
29342934   const struct sh2_config *conf = config;
29352935
2936   sh2.timer = mame_timer_alloc(sh2_timer_callback);
2937   mame_timer_adjust(sh2.timer, time_never, 0, time_zero);
2936   sh2.timer = timer_alloc(sh2_timer_callback);
2937   timer_adjust(sh2.timer, attotime_never, 0, attotime_zero);
29382938
2939   sh2.dma_timer[0] = mame_timer_alloc(sh2_dmac_callback);
2940   mame_timer_adjust(sh2.dma_timer[0], time_never, 0, time_zero);
2939   sh2.dma_timer[0] = timer_alloc(sh2_dmac_callback);
2940   timer_adjust(sh2.dma_timer[0], attotime_never, 0, attotime_zero);
29412941
2942   sh2.dma_timer[1] = mame_timer_alloc(sh2_dmac_callback);
2943   mame_timer_adjust(sh2.dma_timer[1], time_never, 0, time_zero);
2942   sh2.dma_timer[1] = timer_alloc(sh2_dmac_callback);
2943   timer_adjust(sh2.dma_timer[1], attotime_never, 0, attotime_zero);
29442944
29452945   sh2.m = auto_malloc(0x200);
29462946
src/emu/cpu/sh4/sh4.c
r1293r1294
7373   int    internal_irq_level;
7474   int    internal_irq_vector;
7575
76   mame_timer *dma_timer[4];
77   mame_timer *refresh_timer;
78   mame_timer *rtc_timer;
79   mame_timer *timer0;
80   mame_timer *timer1;
81   mame_timer *timer2;
76   emu_timer *dma_timer[4];
77   emu_timer *refresh_timer;
78   emu_timer *rtc_timer;
79   emu_timer *timer0;
80   emu_timer *timer1;
81   emu_timer *timer2;
8282   UINT32   refresh_timer_base;
8383   int     dma_timer_active[2];
8484
r1293r1294
30503050static void sh4_reset(void)
30513051{
30523052   void *tsaved[4];
3053   mame_timer *tsave[5];
3053   emu_timer *tsave[5];
30543054   UINT32 *m;
30553055   int cpunum;
30563056   int save_is_slave;
r1293r1294
31003100   sh4_default_exception_priorities();
31013101   memset(sh4.exception_requesting, 0, sizeof(sh4.exception_requesting));
31023102
3103   mame_timer_adjust(sh4.rtc_timer, MAME_TIME_IN_HZ(128), cpunum, time_zero);
3103   timer_adjust(sh4.rtc_timer, ATTOTIME_IN_HZ(128), cpunum, attotime_zero);
31043104   sh4.m[RCR2] = 0x09;
31053105   sh4.m[TCOR0] = 0xffffffff;
31063106   sh4.m[TCNT0] = 0xffffffff;
r1293r1294
31923192      memcpy(&sh4, src, sizeof(SH4));
31933193}
31943194
3195static UINT32 compute_ticks_refresh_timer(mame_timer *timer, int hertz, int base, int divisor)
3195static UINT32 compute_ticks_refresh_timer(emu_timer *timer, int hertz, int base, int divisor)
31963196{
31973197   // elapsed:total = x : ticks
31983198   // x=elapsed*tics/total -> x=elapsed*(double)100000000/rtcnt_div[(sh4.m[RTCSR] >> 3) & 7]
31993199   // ticks/total=ticks / ((rtcnt_div[(sh4.m[RTCSR] >> 3) & 7] * ticks) / 100000000)=1/((rtcnt_div[(sh4.m[RTCSR] >> 3) & 7] / 100000000)=100000000/rtcnt_div[(sh4.m[RTCSR] >> 3) & 7]
3200   return base + (UINT32)((mame_time_to_double(mame_timer_timeelapsed(timer)) * (double)hertz) / (double)divisor);
3200   return base + (UINT32)((attotime_to_double(timer_timeelapsed(timer)) * (double)hertz) / (double)divisor);
32013201}
32023202
32033203static void sh4_refresh_timer_recompute(void)
r1293r1294
32103210   if (ticks < 0)
32113211      ticks = 256 + ticks;
32123212   //((double)rtcnt_div[(sh4.m[RTCSR] >> 3) & 7] / (double)100000000)*ticks
3213   mame_timer_adjust(sh4.refresh_timer, scale_up_mame_time(scale_up_mame_time(MAME_TIME_IN_HZ(sh4.bus_clock), rtcnt_div[(sh4.m[RTCSR] >> 3) & 7]), ticks), sh4.cpu_number, time_zero);
3213   timer_adjust(sh4.refresh_timer, attotime_mul(attotime_mul(ATTOTIME_IN_HZ(sh4.bus_clock), rtcnt_div[(sh4.m[RTCSR] >> 3) & 7]), ticks), sh4.cpu_number, attotime_zero);
32143214   sh4.refresh_timer_base = sh4.m[RTCNT];
32153215}
32163216
32173217/*-------------------------------------------------
3218    sh4_scale_up_mame_time - multiply a mame_time by
3218    sh4_scale_up_mame_time - multiply a attotime by
32193219    a (constant+1) where 0 <= constant < 2^32
32203220-------------------------------------------------*/
32213221
3222INLINE mame_time sh4_scale_up_mame_time(mame_time _time1, UINT32 factor1)
3222INLINE attotime sh4_scale_up_mame_time(attotime _time1, UINT32 factor1)
32233223{
3224   UINT32 subseclo, subsechi;
3225   UINT64 templo, temphi;
3226   UINT64 factor;
3227   mame_time result;
3228
3229   /* if one of the items is time_never, return time_never */
3230   if (_time1.seconds >= MAX_SECONDS)
3231      return time_never;
3232
3233   /* 0 times anything is zero */
32343224   if (factor1 == 0)
3235      return time_zero;
3236
3237   factor=factor1;
3238   factor++;
3239
3240   /* break subseconds into lower and upper halves */
3241   subseclo = (UINT32)(_time1.subseconds % MAX_SUBSECONDS_SQRT);
3242   subsechi = (UINT32)(_time1.subseconds / MAX_SUBSECONDS_SQRT);
3243
3244   /* get a 64-bit product for each one */
3245   templo = (UINT64)subseclo * (UINT64)factor;
3246   temphi = (UINT64)subsechi * (UINT64)factor;
3247
3248   /* separate out the low and carry into the high */
3249   subseclo = templo % MAX_SUBSECONDS_SQRT;
3250   temphi += templo / MAX_SUBSECONDS_SQRT;
3251   subsechi = temphi % MAX_SUBSECONDS_SQRT;
3252
3253   /* assemble the two parts into final subseconds and carry into seconds */
3254   result.subseconds = (subseconds_t)subseclo + MAX_SUBSECONDS_SQRT * (subseconds_t)subsechi;
3255   result.seconds = _time1.seconds * factor + temphi / MAX_SUBSECONDS_SQRT;
3256
3257   /* max out at never time */
3258   if (result.seconds >= MAX_SECONDS)
3259      return time_never;
3260
3261   return result;
3225      return attotime_zero;
3226   return attotime_mul(_time1, factor1 + 1);
32623227}
32633228
3264static UINT32 compute_ticks_timer(mame_timer *timer, int hertz, int divisor)
3229static UINT32 compute_ticks_timer(emu_timer *timer, int hertz, int divisor)
32653230{
32663231   double ret;
32673232
3268   ret=((mame_time_to_double(mame_timer_timeleft(timer)) * (double)hertz) / (double)divisor) - 1;
3233   ret=((attotime_to_double(timer_timeleft(timer)) * (double)hertz) / (double)divisor) - 1;
32693234   return (UINT32)ret;
32703235}
32713236
r1293r1294
32743239   double ticks;
32753240
32763241   ticks = sh4.m[TCNT0];
3277   mame_timer_adjust(sh4.timer0, sh4_scale_up_mame_time(scale_up_mame_time(MAME_TIME_IN_HZ(sh4.pm_clock), tcnt_div[sh4.m[TCR0] & 7]), ticks), sh4.cpu_number, time_zero);
3242   timer_adjust(sh4.timer0, sh4_scale_up_mame_time(attotime_mul(ATTOTIME_IN_HZ(sh4.pm_clock), tcnt_div[sh4.m[TCR0] & 7]), ticks), sh4.cpu_number, attotime_zero);
32783243}
32793244
32803245static void sh4_timer1_recompute(void)
r1293r1294
32823247   double ticks;
32833248
32843249   ticks = sh4.m[TCNT1];
3285   mame_timer_adjust(sh4.timer1, sh4_scale_up_mame_time(scale_up_mame_time(MAME_TIME_IN_HZ(sh4.pm_clock), tcnt_div[sh4.m[TCR1] & 7]), ticks), sh4.cpu_number, time_zero);
3250   timer_adjust(sh4.timer1, sh4_scale_up_mame_time(attotime_mul(ATTOTIME_IN_HZ(sh4.pm_clock), tcnt_div[sh4.m[TCR1] & 7]), ticks), sh4.cpu_number, attotime_zero);
32863251}
32873252
32883253static void sh4_timer2_recompute(void)
r1293r1294
32903255   double ticks;
32913256
32923257   ticks = sh4.m[TCNT2];
3293   mame_timer_adjust(sh4.timer2, sh4_scale_up_mame_time(scale_up_mame_time(MAME_TIME_IN_HZ(sh4.pm_clock), tcnt_div[sh4.m[TCR2] & 7]), ticks), sh4.cpu_number, time_zero);
3258   timer_adjust(sh4.timer2, sh4_scale_up_mame_time(attotime_mul(ATTOTIME_IN_HZ(sh4.pm_clock), tcnt_div[sh4.m[TCR2] & 7]), ticks), sh4.cpu_number, attotime_zero);
32943259}
32953260
32963261static TIMER_CALLBACK( sh4_refresh_timer_callback )
r1293r1294
34093374   int cpunum = param;
34103375
34113376   cpuintrf_push_context(cpunum);
3412   mame_timer_adjust(sh4.rtc_timer, MAME_TIME_IN_HZ(128), cpunum, time_zero);
3377   timer_adjust(sh4.rtc_timer, ATTOTIME_IN_HZ(128), cpunum, attotime_zero);
34133378   sh4.m[R64CNT] = (sh4.m[R64CNT]+1) & 0x7f;
34143379   if (sh4.m[R64CNT] == 64)
34153380   {
r1293r1294
35213486   if (timermode == 1)
35223487   {
35233488      sh4.dma_timer_active[channel] = 1;
3524      mame_timer_adjust(sh4.dma_timer[channel], MAME_TIME_IN_CYCLES(2*count+1, sh4.cpu_number), (sh4.cpu_number << 8) | channel, time_zero);
3489      timer_adjust(sh4.dma_timer[channel], ATTOTIME_IN_CYCLES(2*count+1, sh4.cpu_number), (sh4.cpu_number << 8) | channel, attotime_zero);
35253490   }
35263491   else if (timermode == 2)
35273492   {
35283493      sh4.dma_timer_active[channel] = 1;
3529      mame_timer_adjust(sh4.dma_timer[channel], time_zero, (sh4.cpu_number << 8) | channel, time_zero);
3494      timer_adjust(sh4.dma_timer[channel], attotime_zero, (sh4.cpu_number << 8) | channel, attotime_zero);
35303495   }
35313496
35323497   src &= AM;
r1293r1294
36693634      if (sh4.dma_timer_active[channel])
36703635      {
36713636         logerror("SH4: DMA %d cancelled in-flight but all data transferred", channel);
3672         mame_timer_adjust(sh4.dma_timer[channel], time_never, 0, time_zero);
3637         timer_adjust(sh4.dma_timer[channel], attotime_never, 0, attotime_zero);
36733638         sh4.dma_timer_active[channel] = 0;
36743639      }
36753640   }
r1293r1294
36853650      if (sh4.dma_timer_active[s])
36863651      {
36873652         logerror("SH4: DMA %d cancelled due to NMI but all data transferred", s);
3688         mame_timer_adjust(sh4.dma_timer[s], time_never, 0, time_zero);
3653         timer_adjust(sh4.dma_timer[s], attotime_never, 0, attotime_zero);
36893654         sh4.dma_timer_active[s] = 0;
36903655      }
36913656   }
r1293r1294
37113676      }
37123677      else
37133678      {
3714         mame_timer_adjust(sh4.refresh_timer, time_never, 0, time_zero);
3679         timer_adjust(sh4.refresh_timer, attotime_never, 0, attotime_zero);
37153680      }
37163681      break;
37173682
r1293r1294
37573722      }
37583723      if ((sh4.m[RCR2] & 8) && (~old & 8))
37593724      { // 0 -> 1
3760         mame_timer_adjust(sh4.rtc_timer, MAME_TIME_IN_HZ(128), sh4.cpu_number, time_zero);
3725         timer_adjust(sh4.rtc_timer, ATTOTIME_IN_HZ(128), sh4.cpu_number, attotime_zero);
37613726      }
37623727      else if (~(sh4.m[RCR2]) & 8)
37633728      { // 0
3764         mame_timer_adjust(sh4.rtc_timer, time_never, 0, time_zero);
3729         timer_adjust(sh4.rtc_timer, attotime_never, 0, attotime_zero);
37653730      }
37663731      break;
37673732
r1293r1294
37703735      if (old & 1)
37713736         sh4.m[TCNT0] = compute_ticks_timer(sh4.timer0, sh4.pm_clock, tcnt_div[sh4.m[TCR0] & 7]);
37723737      if ((sh4.m[TSTR] & 1) == 0) {
3773         mame_timer_adjust(sh4.timer0, time_never, 0, time_zero);
3738         timer_adjust(sh4.timer0, attotime_never, 0, attotime_zero);
37743739      } else
37753740         sh4_timer0_recompute();
37763741
37773742      if (old & 2)
37783743         sh4.m[TCNT1] = compute_ticks_timer(sh4.timer1, sh4.pm_clock, tcnt_div[sh4.m[TCR1] & 7]);
37793744      if ((sh4.m[TSTR] & 2) == 0) {
3780         mame_timer_adjust(sh4.timer1, time_never, 0, time_zero);
3745         timer_adjust(sh4.timer1, attotime_never, 0, attotime_zero);
37813746      } else
37823747         sh4_timer1_recompute();
37833748
37843749      if (old & 4)
37853750         sh4.m[TCNT2] = compute_ticks_timer(sh4.timer2, sh4.pm_clock, tcnt_div[sh4.m[TCR2] & 7]);
37863751      if ((sh4.m[TSTR] & 4) == 0) {
3787         mame_timer_adjust(sh4.timer2, time_never, 0, time_zero);
3752         timer_adjust(sh4.timer2, attotime_never, 0, attotime_zero);
37883753      } else
37893754         sh4_timer2_recompute();
37903755      break;
r1293r1294
41564121{
41574122   const struct sh4_config *conf = config;
41584123
4159   sh4.timer0 = mame_timer_alloc(sh4_timer0_callback);
4160   mame_timer_adjust(sh4.timer0, time_never, 0, time_zero);
4161   sh4.timer1 = mame_timer_alloc(sh4_timer1_callback);
4162   mame_timer_adjust(sh4.timer1, time_never, 0, time_zero);
4163   sh4.timer2 = mame_timer_alloc(sh4_timer2_callback);
4164   mame_timer_adjust(sh4.timer2, time_never, 0, time_zero);
4124   sh4.timer0 = timer_alloc(sh4_timer0_callback);
4125   timer_adjust(sh4.timer0, attotime_never, 0, attotime_zero);
4126   sh4.timer1 = timer_alloc(sh4_timer1_callback);
4127   timer_adjust(sh4.timer1, attotime_never, 0, attotime_zero);
4128   sh4.timer2 = timer_alloc(sh4_timer2_callback);
4129   timer_adjust(sh4.timer2, attotime_never, 0, attotime_zero);
41654130
4166   sh4.dma_timer[0] = mame_timer_alloc(sh4_dmac_callback);
4167   mame_timer_adjust(sh4.dma_timer[0], time_never, 0, time_zero);
4168   sh4.dma_timer[1] = mame_timer_alloc(sh4_dmac_callback);
4169   mame_timer_adjust(sh4.dma_timer[1], time_never, 0, time_zero);
4170   sh4.dma_timer[2] = mame_timer_alloc(sh4_dmac_callback);
4171   mame_timer_adjust(sh4.dma_timer[2], time_never, 0, time_zero);
4172   sh4.dma_timer[3] = mame_timer_alloc(sh4_dmac_callback);
4173   mame_timer_adjust(sh4.dma_timer[3], time_never, 0, time_zero);
4131   sh4.dma_timer[0] = timer_alloc(sh4_dmac_callback);
4132   timer_adjust(sh4.dma_timer[0], attotime_never, 0, attotime_zero);
4133   sh4.dma_timer[1] = timer_alloc(sh4_dmac_callback);
4134   timer_adjust(sh4.dma_timer[1], attotime_never, 0, attotime_zero);
4135   sh4.dma_timer[2] = timer_alloc(sh4_dmac_callback);
4136   timer_adjust(sh4.dma_timer[2], attotime_never, 0, attotime_zero);
4137   sh4.dma_timer[3] = timer_alloc(sh4_dmac_callback);
4138   timer_adjust(sh4.dma_timer[3], attotime_never, 0, attotime_zero);
41744139
4175   sh4.refresh_timer = mame_timer_alloc(sh4_refresh_timer_callback);
4176   mame_timer_adjust(sh4.refresh_timer, time_never, 0, time_zero);
4140   sh4.refresh_timer = timer_alloc(sh4_refresh_timer_callback);
4141   timer_adjust(sh4.refresh_timer, attotime_never, 0, attotime_zero);
41774142   sh4.refresh_timer_base = 0;
41784143
4179   sh4.rtc_timer = mame_timer_alloc(sh4_rtc_timer_callback);
4180   mame_timer_adjust(sh4.rtc_timer, time_never, 0, time_zero);
4144   sh4.rtc_timer = timer_alloc(sh4_rtc_timer_callback);
4145   timer_adjust(sh4.rtc_timer, attotime_never, 0, attotime_zero);
41814146
41824147   sh4.m = auto_malloc(16384*4);
41834148
src/emu/cpu/mips/mips3com.h
r1293r1294
193193   UINT32         system_clock;
194194   UINT32         cpu_clock;
195195   UINT64         count_zero_time;
196   mame_timer *   compare_int_timer;
196   emu_timer *   compare_int_timer;
197197
198198   /* memory accesses */
199199   UINT8         bigendian;
src/emu/cpu/mips/mips3com.c
r1293r1294
118118   mips->tlb_table = auto_malloc(sizeof(mips->tlb_table[0]) * (1 << (MIPS3_MAX_PADDR_SHIFT - MIPS3_MIN_PAGE_SHIFT)));
119119
120120   /* allocate a timer for the compare interrupt */
121   mips->compare_int_timer = mame_timer_alloc(compare_int_callback);
121   mips->compare_int_timer = timer_alloc(compare_int_callback);
122122
123123   /* reset the state */
124124   mips3com_reset(mips);
r1293r1294
179179      UINT32 count = (activecpu_gettotalcycles64() - mips->count_zero_time) / 2;
180180      UINT32 compare = mips->cpr[0][COP0_Compare];
181181      UINT32 cyclesleft = compare - count;
182      mame_time newtime = MAME_TIME_IN_CYCLES(((INT64)cyclesleft * 2), cpu_getactivecpu());
182      attotime newtime = ATTOTIME_IN_CYCLES(((INT64)cyclesleft * 2), cpu_getactivecpu());
183183
184184      /* due to accuracy issues, don't bother setting timers unless they're for less than 100msec */
185      if (compare_mame_times(newtime, MAME_TIME_IN_MSEC(100)) < 0)
186         mame_timer_adjust(mips->compare_int_timer, newtime, cpu_getactivecpu(), time_zero);
185      if (attotime_compare(newtime, ATTOTIME_IN_MSEC(100)) < 0)
186         timer_adjust(mips->compare_int_timer, newtime, cpu_getactivecpu(), attotime_zero);
187187   }
188188   else
189      mame_timer_adjust(mips->compare_int_timer, time_never, cpu_getactivecpu(), time_zero);
189      timer_adjust(mips->compare_int_timer, attotime_never, cpu_getactivecpu(), attotime_zero);
190190}
191191
192192
src/emu/cpu/f8/f3853.c
r1293r1294
3434    int priority_line; /* inverted level*/
3535    int external_interrupt_line;/* inverted level */
3636
37    mame_timer *timer;
37    emu_timer *timer;
3838} f3853= { { 0 } };
3939#define INTERRUPT_VECTOR(external) (external?f3853.low|(f3853.high<<8)|0x80 \
4040               :(f3853.low|(f3853.high<<8))&~0x80)
r1293r1294
5656
5757static void f3853_timer_start(UINT8 value)
5858{
59   mame_time period = (value != 0xff) ? scale_up_mame_time(MAME_TIME_IN_HZ(f3853.config.frequency), f3853_value_to_cycle[value]*31) : time_never;
59   attotime period = (value != 0xff) ? attotime_mul(ATTOTIME_IN_HZ(f3853.config.frequency), f3853_value_to_cycle[value]*31) : attotime_never;
6060
61   mame_timer_adjust(f3853.timer, period, 0, time_never);
61   timer_adjust(f3853.timer, period, 0, attotime_never);
6262}
6363
6464static TIMER_CALLBACK( f3853_timer_callback )
r1293r1294
9090
9191   f3853.priority_line=FALSE;
9292   f3853.external_interrupt_line=TRUE;
93   f3853.timer = mame_timer_alloc(f3853_timer_callback);
93   f3853.timer = timer_alloc(f3853_timer_callback);
9494}
9595
9696void f3853_reset(void)
src/emu/cpu/tms9900/99xxcore.h
r1293r1294
469469   UINT8 decrementer_enabled;
470470   UINT16 decrementer_interval;
471471   UINT16 decrementer_count;   /* used in event counter mode*/
472   mame_timer *timer;  /* used in timer mode */
472   emu_timer *timer;  /* used in timer mode */
473473#endif
474474
475475#if (TMS99XX_MODEL == TMS9995_ID)
r1293r1294
929929         /* read decrementer */
930930         if (I.decrementer_enabled && !(I.flag & 1))
931931            /* timer mode, timer enabled */
932            return ceil(MAME_TIME_TO_CYCLES(cpu_getactivecpu(), scale_down_mame_time(mame_timer_timeleft(I.timer), 16)));
932            return ceil(ATTOTIME_TO_CYCLES(cpu_getactivecpu(), attotime_div(timer_timeleft(I.timer), 16)));
933933         else
934934            /* event counter mode or timer mode, timer disabled */
935935            return I.decrementer_count;
r1293r1294
993993
994994         if (I.decrementer_enabled && !(I.flag & 1))
995995            /* timer mode, timer enabled */
996            value = ceil(MAME_TIME_TO_CYCLES(cpu_getactivecpu(), scale_down_mame_time(mame_timer_timeleft(I.timer), 16)));
996            value = ceil(ATTOTIME_TO_CYCLES(cpu_getactivecpu(), attotime_div(timer_timeleft(I.timer), 16)));
997997         else
998998            /* event counter mode or timer mode, timer disabled */
999999            value = I.decrementer_count;
r1293r1294
12841284   I.irq_callback = irqcallback;
12851285
12861286#if (TMS99XX_MODEL == TMS9995_ID)
1287   I.timer = mame_timer_alloc(decrementer_callback);
1287   I.timer = timer_alloc(decrementer_callback);
12881288#endif
12891289
12901290   I.idle_callback = param ? param->idle_callback : NULL;
r1293r1294
18161816*/
18171817static void reset_decrementer(void)
18181818{
1819   mame_timer_adjust(I.timer, time_never, 0, time_zero);
1819   timer_adjust(I.timer, attotime_never, 0, attotime_zero);
18201820
18211821   /* reload count */
18221822   I.decrementer_count = I.decrementer_interval;
r1293r1294
18261826
18271827   if (I.decrementer_enabled && ! (I.flag & 1))
18281828      {   /* timer */
1829      mame_time period = MAME_TIME_IN_CYCLES(I.decrementer_interval * 16L, cpu_getactivecpu());
1830      mame_timer_adjust(I.timer, period, 0, period);
1829      attotime period = ATTOTIME_IN_CYCLES(I.decrementer_interval * 16L, cpu_getactivecpu());
1830      timer_adjust(I.timer, period, 0, period);
18311831   }
18321832}
18331833
src/emu/cpu/m6800/m6800.c
r1293r1294
143143/* 680x registers */
144144static m6800_Regs m6800;
145145
146static mame_timer *m6800_rx_timer;
147static mame_timer *m6800_tx_timer;
146static emu_timer *m6800_rx_timer;
147static emu_timer *m6800_tx_timer;
148148
149149#define m6801   m6800
150150#define m6802   m6800
r1293r1294
887887
888888   m6800.trcsr = M6800_TRCSR_TDRE;
889889   m6800.rmcr = 0;
890   if (m6800_rx_timer) mame_timer_enable(m6800_rx_timer, 0);
891   if (m6800_tx_timer) mame_timer_enable(m6800_tx_timer, 0);
890   if (m6800_rx_timer) timer_enable(m6800_rx_timer, 0);
891   if (m6800_tx_timer) timer_enable(m6800_tx_timer, 0);
892892   m6800.txstate = M6800_TX_STATE_INIT;
893893   m6800.txbits = m6800.rxbits = 0;
894894   m6800.trcsr_read = 0;
r1293r1294
12741274   m6800.irq_callback = irqcallback;
12751275
12761276   m6800.clock = clock;
1277   m6800_rx_timer = mame_timer_alloc(m6800_rx_tick);
1278   m6800_tx_timer = mame_timer_alloc(m6800_tx_tick);
1277   m6800_rx_timer = timer_alloc(m6800_rx_tick);
1278   m6800_tx_timer = timer_alloc(m6800_tx_tick);
12791279
12801280   state_register("m6801", index);
12811281}
r1293r1294
13071307   m6800.irq_callback = irqcallback;
13081308
13091309   m6800.clock = clock;
1310   m6800_rx_timer = mame_timer_alloc(m6800_rx_tick);
1311   m6800_tx_timer = mame_timer_alloc(m6800_tx_tick);
1310   m6800_rx_timer = timer_alloc(m6800_rx_tick);
1311   m6800_tx_timer = timer_alloc(m6800_tx_tick);
13121312
13131313   state_register("m6803", index);
13141314}
r1293r1294
16501650   m6800.irq_callback = irqcallback;
16511651
16521652   m6800.clock = clock;
1653   m6800_rx_timer = mame_timer_alloc(m6800_rx_tick);
1654   m6800_tx_timer = mame_timer_alloc(m6800_tx_tick);
1653   m6800_rx_timer = timer_alloc(m6800_rx_tick);
1654   m6800_tx_timer = timer_alloc(m6800_tx_tick);
16551655
16561656   state_register("hd63701", index);
16571657}
r1293r1294
25202520         {
25212521         case 0:
25222522         case 3: // not implemented
2523            mame_timer_enable(m6800_rx_timer, 0);
2524            mame_timer_enable(m6800_tx_timer, 0);
2523            timer_enable(m6800_rx_timer, 0);
2524            timer_enable(m6800_tx_timer, 0);
25252525            break;
25262526
25272527         case 1:
r1293r1294
25292529            {
25302530               int divisor = M6800_RMCR_SS[m6800.rmcr & M6800_RMCR_SS_MASK];
25312531
2532               mame_timer_adjust(m6800_rx_timer, time_zero, cpu_getactivecpu(), MAME_TIME_IN_HZ(m6800.clock / divisor));
2533               mame_timer_adjust(m6800_tx_timer, time_zero, cpu_getactivecpu(), MAME_TIME_IN_HZ(m6800.clock / divisor));
2532               timer_adjust(m6800_rx_timer, attotime_zero, cpu_getactivecpu(), ATTOTIME_IN_HZ(m6800.clock / divisor));
2533               timer_adjust(m6800_tx_timer, attotime_zero, cpu_getactivecpu(), ATTOTIME_IN_HZ(m6800.clock / divisor));
25342534            }
25352535            break;
25362536         }
src/emu/streams.c
r1293r1294
9494   UINT32            bufalloc;            /* allocated size of output buffer, in samples */
9595
9696   /* resampling information */
97   subseconds_t      latency_subseconds;      /* latency between this stream and the input stream */
97   attoseconds_t      latency_attoseconds;   /* latency between this stream and the input stream */
9898   INT16            gain;               /* gain to apply to this input */
9999};
100100
r1293r1294
125125   UINT32            new_sample_rate;      /* newly-set sample rate for the stream */
126126
127127   /* timing information */
128   subseconds_t      subseconds_per_sample;   /* number of subseconds per sample */
128   attoseconds_t      attoseconds_per_sample;   /* number of attoseconds per sample */
129129   INT32            max_samples_per_update;   /* maximum samples per update */
130130
131131   /* input information */
r1293r1294
159159   sound_stream **      stream_tailptr;         /* pointer to pointer to last stream */
160160   void *            current_tag;         /* current tag to assign to new streams */
161161   int               stream_index;         /* index of the current stream */
162   subseconds_t      update_subseconds;      /* subseconds between global updates */
163   mame_time         last_update;         /* last update time */
162   attoseconds_t      update_attoseconds;      /* attoseconds between global updates */
163   attotime         last_update;         /* last update time */
164164};
165165
166166
r1293r1294
187187    time to a sample index in a given stream
188188-------------------------------------------------*/
189189
190INLINE INT32 time_to_sampindex(const streams_private *strdata, const sound_stream *stream, mame_time time)
190INLINE INT32 time_to_sampindex(const streams_private *strdata, const sound_stream *stream, attotime time)
191191{
192192   /* determine the number of samples since the start of this second */
193   INT32 sample = (INT32)(time.subseconds / stream->subseconds_per_sample);
193   INT32 sample = (INT32)(time.attoseconds / stream->attoseconds_per_sample);
194194
195195   /* if we're ahead of the last update, then adjust upwards */
196196   if (time.seconds > strdata->last_update.seconds)
r1293r1294
218218    streams_init - initialize the streams engine
219219-------------------------------------------------*/
220220
221void streams_init(running_machine *machine, subseconds_t update_subseconds)
221void streams_init(running_machine *machine, attoseconds_t update_attoseconds)
222222{
223223   streams_private *strdata;
224224
r1293r1294
228228
229229   /* reset globals */
230230   strdata->stream_tailptr = &strdata->stream_head;
231   strdata->update_subseconds = update_subseconds;
231   strdata->update_attoseconds = update_attoseconds;
232232
233233   /* set the global pointer */
234234   machine->streams_data = strdata;
235235
236236   /* register global states */
237237   state_save_register_global(strdata->last_update.seconds);
238   state_save_register_global(strdata->last_update.subseconds);
238   state_save_register_global(strdata->last_update.attoseconds);
239239}
240240
241241
r1293r1294
247247void streams_update(running_machine *machine)
248248{
249249   streams_private *strdata = machine->streams_data;
250   mame_time curtime = mame_timer_get_time();
250   attotime curtime = timer_get_time();
251251   int second_tick = FALSE;
252252   sound_stream *stream;
253253
r1293r1294
466466void stream_update(sound_stream *stream)
467467{
468468   streams_private *strdata = Machine->streams_data;
469   INT32 update_sampindex = time_to_sampindex(strdata, stream, mame_timer_get_time());
469   INT32 update_sampindex = time_to_sampindex(strdata, stream, timer_get_time());
470470
471471   /* generate samples to get us up to the appropriate time */
472472   assert(stream->output_sampindex - stream->output_base_sampindex >= 0);
r1293r1294
597597      memset(stream->output[outputnum].buffer, 0, stream->output_bufalloc * sizeof(stream->output[outputnum].buffer[0]));
598598
599599   /* recompute the sample indexes to make sense */
600   stream->output_sampindex = strdata->last_update.subseconds / stream->subseconds_per_sample;
600   stream->output_sampindex = strdata->last_update.attoseconds / stream->attoseconds_per_sample;
601601   stream->output_update_sampindex = stream->output_sampindex;
602602   stream->output_base_sampindex = stream->output_sampindex - stream->max_samples_per_update;
603603}
r1293r1294
673673   int inputnum;
674674
675675   /* recompute the timing parameters */
676   stream->subseconds_per_sample = MAX_SUBSECONDS / stream->sample_rate;
677   stream->max_samples_per_update = (strdata->update_subseconds + stream->subseconds_per_sample - 1) / stream->subseconds_per_sample;
676   stream->attoseconds_per_sample = ATTOSECONDS_PER_SECOND / stream->sample_rate;
677   stream->max_samples_per_update = (strdata->update_attoseconds + stream->attoseconds_per_sample - 1) / stream->attoseconds_per_sample;
678678
679679   /* update resample and output buffer sizes */
680680   allocate_resample_buffers(strdata, stream);
r1293r1294
689689      if (input->source != NULL)
690690      {
691691         sound_stream *input_stream = input->source->owner;
692         subseconds_t new_subsecs_per_sample = MAX_SUBSECONDS / input_stream->sample_rate;
693         subseconds_t latency;
692         attoseconds_t new_attosecs_per_sample = ATTOSECONDS_PER_SECOND / input_stream->sample_rate;
693         attoseconds_t latency;
694694
695695         /* okay, we have a new sample rate; recompute the latency to be the maximum
696696               sample period between us and our input */
697         latency = MAX(new_subsecs_per_sample, stream->subseconds_per_sample);
697         latency = MAX(new_attosecs_per_sample, stream->attoseconds_per_sample);
698698
699699         /* if the input stream's sample rate is lower, we will use linear interpolation */
700700         /* this requires an extra sample from the source */
701701         if (input_stream->sample_rate < stream->sample_rate)
702            latency += new_subsecs_per_sample;
702            latency += new_attosecs_per_sample;
703703
704704         /* if our sample rates match exactly, we don't need any latency */
705705         else if (input_stream->sample_rate == stream->sample_rate)
r1293r1294
707707
708708         /* we generally don't want to tweak the latency, so we just keep the greatest
709709               one we've computed thus far */
710         input->latency_subseconds = MAX(input->latency_subseconds, latency);
711         assert(input->latency_subseconds < strdata->update_subseconds);
710         input->latency_attoseconds = MAX(input->latency_attoseconds, latency);
711         assert(input->latency_attoseconds < strdata->update_attoseconds);
712712      }
713713   }
714714}
r1293r1294
776776   sound_stream *input_stream;
777777   stream_sample_t *source;
778778   stream_sample_t sample;
779   subseconds_t basetime;
779   attoseconds_t basetime;
780780   INT32 basesample;
781781   UINT32 basefrac;
782782   UINT32 step;
r1293r1294
795795
796796   /* determine the time at which the current sample begins, accounting for the
797797       latency we calculated between the input and output streams */
798   basetime = stream->output_sampindex * stream->subseconds_per_sample - input->latency_subseconds;
798   basetime = stream->output_sampindex * stream->attoseconds_per_sample - input->latency_attoseconds;
799799
800800   /* now convert that time into a sample in the input stream */
801801   if (basetime >= 0)
802      basesample = basetime / input_stream->subseconds_per_sample;
802      basesample = basetime / input_stream->attoseconds_per_sample;
803803   else
804      basesample = -(-basetime / input_stream->subseconds_per_sample) - 1;
804      basesample = -(-basetime / input_stream->attoseconds_per_sample) - 1;
805805
806806   /* compute a source pointer to the first sample */
807807   assert(basesample >= input_stream->output_base_sampindex);
808808   source = output->buffer + (basesample - input_stream->output_base_sampindex);
809809
810810   /* determine the current fraction of a sample */
811   basefrac = (basetime - basesample * input_stream->subseconds_per_sample) / (MAX_SUBSECONDS >> FRAC_BITS);
811   basefrac = (basetime - basesample * input_stream->attoseconds_per_sample) / (ATTOSECONDS_PER_SECOND >> FRAC_BITS);
812812   assert(basefrac >= 0);
813813   assert(basefrac < FRAC_ONE);
814814
src/emu/streams.h
r1293r1294
2929    FUNCTION PROTOTYPES
3030***************************************************************************/
3131
32void streams_init(running_machine *machine, subseconds_t update_subseconds);
32void streams_init(running_machine *machine, attoseconds_t update_subseconds);
3333void streams_set_tag(running_machine *machine, void *streamtag);
3434void streams_update(running_machine *machine);
3535
src/emu/eigccx86.h
r1293r1294
228228
229229
230230/*-------------------------------------------------
231    div_64x32_rem - perform a signed 64 bit x 32
232    bit divide and return the 32 bit quotient and
233    32 bit remainder
234-------------------------------------------------*/
235
236#ifndef __x86_64__
237#define div_64x32_rem _div_64x32_rem
238INLINE INT32 _div_64x32_rem(INT64 dividend, INT32 divisor, INT32 *remainder)
239{
240   INT32 quotient;
241
242   __asm__ (
243      " idivl  %[divisor] ;"
244      : [result]    "=a" (quotient)   /* Quotient ends up in eax */
245      , [remainder] "=d" (*remainder)   /* Remainder ends up in edx */
246      : [dividend]  "A"  (dividend)   /* 'dividend' in edx:eax */
247      , [divisor]   "rm" (divisor)   /* 'divisor' in register or memory */
248      : "%cc"                     /* Clobbers condition codes */
249   );
250
251   return quotient;
252}
253#endif
254
255
256/*-------------------------------------------------
257    divu_64x32_rem - perform an unsigned 64 bit x
258    32 bit divide and return the 32 bit quotient
259    and 32 bit remainder
260-------------------------------------------------*/
261
262#ifndef __x86_64__
263#define divu_64x32_rem _divu_64x32_rem
264INLINE UINT32 _divu_64x32_rem(UINT64 dividend, UINT32 divisor, UINT32 *remainder)
265{
266   UINT32 quotient;
267
268   __asm__ (
269      " divl  %[divisor] ;"
270      : [result]    "=a" (quotient)   /* Quotient ends up in eax */
271      , [remainder] "=d" (*remainder)   /* Remainder ends up in edx */
272      : [dividend]  "A"  (dividend)   /* 'dividend' in edx:eax */
273      , [divisor]   "rm" (divisor)   /* 'divisor' in register or memory */
274      : "%cc"                     /* Clobbers condition codes */
275   );
276
277   return quotient;
278}
279#endif
280
281
282/*-------------------------------------------------
231283    div_32x32_shift - perform a signed divide of
232284    two 32 bit values, shifting the first before
233285    division, and returning the 32 bit quotient
src/emu/video/cdp1869.c
r1293r1294
262262   return addr;
263263}
264264
265UINT8 cdp1869_read_pageram(UINT16 addr)
265static UINT8 cdp1869_read_pageram(UINT16 addr)
266266{
267267   if (addr >= cdp1869.pramsize)
268268   {
r1293r1294
274274   }
275275}
276276
277#ifdef UNUSED_FUNCTION
277278UINT8 cdp1869_read_charram(UINT16 addr)
278279{
279280   if (addr >= cdp1869.cramsize)
r1293r1294
285286      return cdp1869.cram[addr];
286287   }
287288}
289#endif
288290
289291WRITE8_HANDLER ( cdp1869_charram_w )
290292{
src/emu/video/tms34061.c
r1293r1294
3333   UINT8 *         latchram;
3434   UINT8         latchdata;
3535   UINT8 *         shiftreg;
36   mame_timer *      timer;
36   emu_timer *      timer;
3737   struct tms34061_interface intf;
3838};
3939
r1293r1294
117117   tms34061.regs[TMS34061_VERCOUNTER]   = 0x0000;
118118
119119   /* start vertical interrupt timer */
120   tms34061.timer = mame_timer_alloc(tms34061_interrupt);
120   tms34061.timer = timer_alloc(tms34061_interrupt);
121121}
122122
123123
r1293r1294
145145static TIMER_CALLBACK( tms34061_interrupt )
146146{
147147   /* set timer for next frame */
148   mame_timer_adjust(tms34061.timer, video_screen_get_frame_period(tms34061.intf.scrnum), 0, time_zero);
148   timer_adjust(tms34061.timer, video_screen_get_frame_period(tms34061.intf.scrnum), 0, attotime_zero);
149149
150150   /* set the interrupt bit in the status reg */
151151   tms34061.regs[TMS34061_STATUS] |= 1;
r1293r1294
191191         if (scanline < 0)
192192            scanline += tms34061.regs[TMS34061_VERTOTAL];
193193
194         mame_timer_adjust(tms34061.timer, video_screen_get_time_until_pos(tms34061.intf.scrnum, scanline, tms34061.regs[TMS34061_HORSTARTBLNK]), 0, time_zero);
194         timer_adjust(tms34061.timer, video_screen_get_time_until_pos(tms34061.intf.scrnum, scanline, tms34061.regs[TMS34061_HORSTARTBLNK]), 0, attotime_zero);
195195         break;
196196
197197      /* XY offset: set the X and Y masks */
src/emu/video/voodoo.c
r1293r1294
197197static void init_tmu_shared(tmu_shared_state *s);
198198static void init_tmu(voodoo_state *v, tmu_state *t, int type, voodoo_reg *reg, void *memory, int tmem);
199199static void soft_reset(voodoo_state *v);
200static void check_stalled_cpu(voodoo_state *v, mame_time current_time);
201static void flush_fifos(voodoo_state *v, mame_time current_time);
200static void check_stalled_cpu(voodoo_state *v, attotime current_time);
201static void flush_fifos(voodoo_state *v, attotime current_time);
202202static TIMER_CALLBACK_PTR( stall_cpu_callback );
203static void stall_cpu(voodoo_state *v, int state, mame_time current_time);
203static void stall_cpu(voodoo_state *v, int state, attotime current_time);
204204static TIMER_CALLBACK_PTR( vblank_callback );
205205static INT32 register_w(voodoo_state *v, offs_t offset, UINT32 data);
206206static INT32 lfb_w(voodoo_state *v, offs_t offset, UINT32 data, UINT32 mem_mask, int forcefront);
r1293r1294
368368   v->index = which;
369369   v->type = type;
370370   v->chipmask = 0x01;
371   v->subseconds_per_cycle = MAX_SUBSECONDS / v->freq;
371   v->attoseconds_per_cycle = ATTOSECONDS_PER_SECOND / v->freq;
372372   v->trigger = 51324 + which;
373373
374374   /* build the rasterizer table */
r1293r1294
380380   v->pci.fifo.size = 64*2;
381381   v->pci.fifo.in = v->pci.fifo.out = 0;
382382   v->pci.stall_state = NOT_STALLED;
383   v->pci.continue_timer = mame_timer_alloc_ptr(stall_cpu_callback, v);
383   v->pci.continue_timer = timer_alloc_ptr(stall_cpu_callback, v);
384384
385385   /* allocate memory */
386386   if (type <= VOODOO_2)
r1293r1294
803803   }
804804
805805   /* allocate a VBLANK timer */
806   f->vblank_timer = mame_timer_alloc_ptr(vblank_callback, v);
806   f->vblank_timer = timer_alloc_ptr(vblank_callback, v);
807807   f->vblank = FALSE;
808808
809809   /* initialize the memory FIFO */
r1293r1294
944944   int threadnum;
945945
946946   /* accumulate/reset statistics from all units */
947   for (threadnum = 0; threadnum < ARRAY_LENGTH(v->thread_stats); threadnum++)
947   for (threadnum = 0; threadnum < WORK_MAX_THREADS; threadnum++)
948948   {
949949      if (accumulate)
950950         accumulate_statistics(v, &v->thread_stats[threadnum]);
r1293r1294
10131013   /* reset the last_op_time to now and start processing the next command */
10141014   if (v->pci.op_pending)
10151015   {
1016      v->pci.op_end_time = mame_timer_get_time();
1016      v->pci.op_end_time = timer_get_time();
10171017      flush_fifos(v, v->pci.op_end_time);
10181018   }
10191019
10201020   /* we may be able to unstall now */
10211021   if (v->pci.stall_state != NOT_STALLED)
1022      check_stalled_cpu(v, mame_timer_get_time());
1022      check_stalled_cpu(v, timer_get_time());
10231023
10241024   /* periodically log rasterizer info */
10251025   v->stats.swaps++;
r1293r1294
10821082
10831083static void adjust_vblank_timer(voodoo_state *v)
10841084{
1085   mame_time vblank_period = video_screen_get_time_until_pos(v->scrnum, v->fbi.vsyncscan, 0);
1085   attotime vblank_period = video_screen_get_time_until_pos(v->scrnum, v->fbi.vsyncscan, 0);
10861086
10871087   /* if zero, adjust to next frame, otherwise we may get stuck in an infinite loop */
1088   if (compare_mame_times(vblank_period, time_zero) == 0)
1088   if (attotime_compare(vblank_period, attotime_zero) == 0)
10891089      vblank_period = video_screen_get_frame_period(v->scrnum);
1090   mame_timer_adjust_ptr(v->fbi.vblank_timer, vblank_period, time_never);
1090   timer_adjust_ptr(v->fbi.vblank_timer, vblank_period, attotime_never);
10911091}
10921092
10931093
r1293r1294
11171117   if (v->pci.op_pending)
11181118   {
11191119      if (LOG_VBLANK_SWAP) logerror("---- vblank flush begin\n");
1120      flush_fifos(v, mame_timer_get_time());
1120      flush_fifos(v, timer_get_time());
11211121      if (LOG_VBLANK_SWAP) logerror("---- vblank flush end\n");
11221122   }
11231123
r1293r1294
11351135      swap_buffers(v);
11361136
11371137   /* set a timer for the next off state */
1138   mame_timer_set_ptr(video_screen_get_time_until_pos(v->scrnum, 0, 0), v, vblank_off_callback);
1138   timer_set_ptr(video_screen_get_time_until_pos(v->scrnum, 0, 0), v, vblank_off_callback);
11391139
11401140   /* set internal state and call the client */
11411141   v->fbi.vblank = TRUE;
r1293r1294
21212121      if (cycles > 0)
21222122      {
21232123         v->pci.op_pending = TRUE;
2124         v->pci.op_end_time = add_subseconds_to_mame_time(mame_timer_get_time(), (subseconds_t)cycles * v->subseconds_per_cycle);
2124         v->pci.op_end_time = attotime_add_attoseconds(timer_get_time(), (attoseconds_t)cycles * v->attoseconds_per_cycle);
21252125
21262126         if (LOG_FIFO_VERBOSE) logerror("VOODOO.%d.FIFO:direct write start at %d.%08X%08X end at %d.%08X%08X\n", v->index,
2127            mame_timer_get_time().seconds, (UINT32)(mame_timer_get_time().subseconds >> 32), (UINT32)mame_timer_get_time().subseconds,
2128            v->pci.op_end_time.seconds, (UINT32)(v->pci.op_end_time.subseconds >> 32), (UINT32)v->pci.op_end_time.subseconds);
2127            timer_get_time().seconds, (UINT32)(timer_get_time().attoseconds >> 32), (UINT32)timer_get_time().attoseconds,
2128            v->pci.op_end_time.seconds, (UINT32)(v->pci.op_end_time.attoseconds >> 32), (UINT32)v->pci.op_end_time.attoseconds);
21292129      }
21302130   }
21312131}
r1293r1294
21412141
21422142static TIMER_CALLBACK_PTR( stall_cpu_callback )
21432143{
2144   check_stalled_cpu(param, mame_timer_get_time());
2144   check_stalled_cpu(param, timer_get_time());
21452145}
21462146
21472147
2148static void check_stalled_cpu(voodoo_state *v, mame_time current_time)
2148static void check_stalled_cpu(voodoo_state *v, attotime current_time)
21492149{
21502150   int resume = FALSE;
21512151
r1293r1294
21942194   /* if not, set a timer for the next one */
21952195   else
21962196   {
2197      mame_timer_adjust_ptr(v->pci.continue_timer, sub_mame_times(v->pci.op_end_time, current_time), time_never);
2197      timer_adjust_ptr(v->pci.continue_timer, attotime_sub(v->pci.op_end_time, current_time), attotime_never);
21982198   }
21992199}
22002200
22012201
2202static void stall_cpu(voodoo_state *v, int state, mame_time current_time)
2202static void stall_cpu(voodoo_state *v, int state, attotime current_time)
22032203{
22042204   /* sanity check */
22052205   if (!v->pci.op_pending) fatalerror("FIFOs not empty, no op pending!");
r1293r1294
22152215      cpu_spinuntil_trigger(v->trigger);
22162216
22172217   /* set a timer to clear the stall */
2218   mame_timer_adjust_ptr(v->pci.continue_timer, sub_mame_times(v->pci.op_end_time, current_time), time_never);
2218   timer_adjust_ptr(v->pci.continue_timer, attotime_sub(v->pci.op_end_time, current_time), attotime_never);
22192219}
22202220
22212221
r1293r1294
26122612               int hbp = (v->reg[backPorch].u & 0xff) + 2;
26132613               int vbp = (v->reg[backPorch].u >> 16) & 0xff;
26142614               screen_state *state = &Machine->screen[v->scrnum];
2615               subseconds_t stdperiod, medperiod, vgaperiod;
2616               subseconds_t stddiff, meddiff, vgadiff;
2615               attoseconds_t stdperiod, medperiod, vgaperiod;
2616               attoseconds_t stddiff, meddiff, vgadiff;
26172617               rectangle visarea;
26182618
26192619               /* create a new visarea */
r1293r1294
26272627               visarea.max_y = MIN(visarea.max_y, vtotal - 1);
26282628
26292629               /* compute the new period for standard res, medium res, and VGA res */
2630               stdperiod = HZ_TO_SUBSECONDS(15750) * vtotal;
2631               medperiod = HZ_TO_SUBSECONDS(25000) * vtotal;
2632               vgaperiod = HZ_TO_SUBSECONDS(31500) * vtotal;
2630               stdperiod = HZ_TO_ATTOSECONDS(15750) * vtotal;
2631               medperiod = HZ_TO_ATTOSECONDS(25000) * vtotal;
2632               vgaperiod = HZ_TO_ATTOSECONDS(31500) * vtotal;
26332633
26342634               /* compute a diff against the current refresh period */
26352635               stddiff = stdperiod - state->refresh;
r1293r1294
26472647               if (stddiff < meddiff && stddiff < vgadiff)
26482648               {
26492649                  video_screen_configure(v->scrnum, htotal, vtotal, &visarea, stdperiod);
2650                  mame_printf_debug("Standard resolution, %f Hz\n", SUBSECONDS_TO_HZ(stdperiod));
2650                  mame_printf_debug("Standard resolution, %f Hz\n", ATTOSECONDS_TO_HZ(stdperiod));
26512651               }
26522652               else if (meddiff < vgadiff)
26532653               {
26542654                  video_screen_configure(v->scrnum, htotal, vtotal, &visarea, medperiod);
2655                  mame_printf_debug("Medium resolution, %f Hz\n", SUBSECONDS_TO_HZ(medperiod));
2655                  mame_printf_debug("Medium resolution, %f Hz\n", ATTOSECONDS_TO_HZ(medperiod));
26562656               }
26572657               else
26582658               {
26592659                  video_screen_configure(v->scrnum, htotal, vtotal, &visarea, vgaperiod);
2660                  mame_printf_debug("VGA resolution, %f Hz\n", SUBSECONDS_TO_HZ(vgaperiod));
2660                  mame_printf_debug("VGA resolution, %f Hz\n", ATTOSECONDS_TO_HZ(vgaperiod));
26612661               }
26622662
26632663               /* configure the new framebuffer info */
r1293r1294
29572957   UINT32 destmax, depthmax;
29582958   int sr[2], sg[2], sb[2], sa[2], sw[2];
29592959   int x, y, scry, mask;
2960   int pixel, destbuf;
2960   int pix, destbuf;
29612961
29622962   /* statistics */
29632963   v->stats.lfb_writes++;
r1293r1294
32053205      COMPUTE_DITHER_POINTERS(v->reg[fbzMode].u, y);
32063206
32073207      /* loop over up to two pixels */
3208      for (pixel = 0; mask; pixel++)
3208      for (pix = 0; mask; pix++)
32093209      {
32103210         /* make sure we care about this pixel */
32113211         if (mask & 0x0f)
r1293r1294
32143214            if ((mask & LFB_RGB_PRESENT) && bufoffs < destmax)
32153215            {
32163216               /* apply dithering and write to the screen */
3217               APPLY_DITHER(v->reg[fbzMode].u, x, dither_lookup, sr[pixel], sg[pixel], sb[pixel]);
3218               dest[bufoffs] = (sr[pixel] << 11) | (sg[pixel] << 5) | sb[pixel];
3217               APPLY_DITHER(v->reg[fbzMode].u, x, dither_lookup, sr[pix], sg[pix], sb[pix]);
3218               dest[bufoffs] = (sr[pix] << 11) | (sg[pix] << 5) | sb[pix];
32193219            }
32203220
32213221            /* make sure we have an aux buffer to write to */
r1293r1294
32233223            {
32243224               /* write to the alpha buffer */
32253225               if ((mask & LFB_ALPHA_PRESENT) && FBZMODE_ENABLE_ALPHA_PLANES(v->reg[fbzMode].u))
3226                  depth[bufoffs] = sa[pixel];
3226                  depth[bufoffs] = sa[pix];
32273227
32283228               /* write to the depth buffer */
32293229               if ((mask & (LFB_DEPTH_PRESENT | LFB_DEPTH_PRESENT_MSW)) && !FBZMODE_ENABLE_ALPHA_PLANES(v->reg[fbzMode].u))
3230                  depth[bufoffs] = sw[pixel];
3230                  depth[bufoffs] = sw[pix];
32313231            }
32323232
32333233            /* track pixel writes to the frame buffer regardless of mask */
r1293r1294
32623262      COMPUTE_DITHER_POINTERS(v->reg[fbzMode].u, y);
32633263
32643264      /* loop over up to two pixels */
3265      for (pixel = 0; mask; pixel++)
3265      for (pix = 0; mask; pix++)
32663266      {
32673267         /* make sure we care about this pixel */
32683268         if (mask & 0x0f)
32693269         {
32703270            stats_block *stats = &v->fbi.lfb_stats;
3271            INT64 iterw = sw[pixel] << (30-16);
3272            INT32 iterz = sw[pixel] << 12;
3271            INT64 iterw = sw[pix] << (30-16);
3272            INT32 iterz = sw[pix] << 12;
32733273            rgb_union color;
32743274
32753275            /* apply clipping */
r1293r1294
32903290            PIXEL_PIPELINE_BEGIN(v, stats, x, y, v->reg[fbzColorPath].u, v->reg[fbzMode].u, iterz, iterw);
32913291
32923292            /* use the RGBA we stashed above */
3293            color.rgb.r = r = sr[pixel];
3294            color.rgb.g = g = sg[pixel];
3295            color.rgb.b = b = sb[pixel];
3296            color.rgb.a = a = sa[pixel];
3293            color.rgb.r = r = sr[pix];
3294            color.rgb.g = g = sg[pix];
3295            color.rgb.b = b = sb[pix];
3296            color.rgb.a = a = sa[pix];
32973297
32983298            /* apply chroma key, alpha mask, and alpha testing */
32993299            APPLY_CHROMAKEY(v, stats, v->reg[fbzMode].u, color);
r1293r1294
34463446 *
34473447 *************************************/
34483448
3449static void flush_fifos(voodoo_state *v, mame_time current_time)
3449static void flush_fifos(voodoo_state *v, attotime current_time)
34503450{
34513451   static UINT8 in_flush;
34523452
r1293r1294
34583458   if (!v->pci.op_pending) fatalerror("flush_fifos called with no pending operation");
34593459
34603460   if (LOG_FIFO_VERBOSE) logerror("VOODOO.%d.FIFO:flush_fifos start -- pending=%d.%08X%08X cur=%d.%08X%08X\n", v->index,
3461      v->pci.op_end_time.seconds, (UINT32)(v->pci.op_end_time.subseconds >> 32), (UINT32)v->pci.op_end_time.subseconds,
3462      current_time.seconds, (UINT32)(current_time.subseconds >> 32), (UINT32)current_time.subseconds);
3461      v->pci.op_end_time.seconds, (UINT32)(v->pci.op_end_time.attoseconds >> 32), (UINT32)v->pci.op_end_time.attoseconds,
3462      current_time.seconds, (UINT32)(current_time.attoseconds >> 32), (UINT32)current_time.attoseconds);
34633463
34643464   /* loop while we still have cycles to burn */
3465   while (compare_mame_times(v->pci.op_end_time, current_time) <= 0)
3465   while (attotime_compare(v->pci.op_end_time, current_time) <= 0)
34663466   {
34673467      INT32 extra_cycles = 0;
34683468      INT32 cycles;
r1293r1294
35533553      cycles += extra_cycles;
35543554
35553555      /* account for those cycles */
3556      v->pci.op_end_time = add_subseconds_to_mame_time(v->pci.op_end_time, (subseconds_t)cycles * v->subseconds_per_cycle);
3556      v->pci.op_end_time = attotime_add_attoseconds(v->pci.op_end_time, (attoseconds_t)cycles * v->attoseconds_per_cycle);
35573557
35583558      if (LOG_FIFO_VERBOSE) logerror("VOODOO.%d.FIFO:update -- pending=%d.%08X%08X cur=%d.%08X%08X\n", v->index,
3559         v->pci.op_end_time.seconds, (UINT32)(v->pci.op_end_time.subseconds >> 32), (UINT32)v->pci.op_end_time.subseconds,
3560         current_time.seconds, (UINT32)(current_time.subseconds >> 32), (UINT32)current_time.subseconds);
3559         v->pci.op_end_time.seconds, (UINT32)(v->pci.op_end_time.attoseconds >> 32), (UINT32)v->pci.op_end_time.attoseconds,
3560         current_time.seconds, (UINT32)(current_time.attoseconds >> 32), (UINT32)current_time.attoseconds);
35613561   }
35623562
35633563   if (LOG_FIFO_VERBOSE) logerror("VOODOO.%d.FIFO:flush_fifos end -- pending command complete at %d.%08X%08X\n", v->index,
3564      v->pci.op_end_time.seconds, (UINT32)(v->pci.op_end_time.subseconds >> 32), (UINT32)v->pci.op_end_time.subseconds);
3564      v->pci.op_end_time.seconds, (UINT32)(v->pci.op_end_time.attoseconds >> 32), (UINT32)v->pci.op_end_time.attoseconds);
35653565
35663566   in_flush = FALSE;
35673567}
r1293r1294
35873587
35883588   /* if we have something pending, flush the FIFOs up to the current time */
35893589   if (v->pci.op_pending)
3590      flush_fifos(v, mame_timer_get_time());
3590      flush_fifos(v, timer_get_time());
35913591
35923592   /* special handling for registers */
35933593   if ((offset & 0xc00000/4) == 0)
r1293r1294
36673667      if (cycles)
36683668      {
36693669         v->pci.op_pending = TRUE;
3670         v->pci.op_end_time = add_subseconds_to_mame_time(mame_timer_get_time(), (subseconds_t)cycles * v->subseconds_per_cycle);
3670         v->pci.op_end_time = attotime_add_attoseconds(timer_get_time(), (attoseconds_t)cycles * v->attoseconds_per_cycle);
36713671
36723672         if (LOG_FIFO_VERBOSE) logerror("VOODOO.%d.FIFO:direct write start at %d.%08X%08X end at %d.%08X%08X\n", v->index,
3673            mame_timer_get_time().seconds, (UINT32)(mame_timer_get_time().subseconds >> 32), (UINT32)mame_timer_get_time().subseconds,
3674            v->pci.op_end_time.seconds, (UINT32)(v->pci.op_end_time.subseconds >> 32), (UINT32)v->pci.op_end_time.subseconds);
3673            timer_get_time().seconds, (UINT32)(timer_get_time().attoseconds >> 32), (UINT32)timer_get_time().attoseconds,
3674            v->pci.op_end_time.seconds, (UINT32)(v->pci.op_end_time.attoseconds >> 32), (UINT32)v->pci.op_end_time.attoseconds);
36753675      }
36763676      profiler_mark(PROFILER_END);
36773677      return;
r1293r1294
37203720         fifo_items(&v->fbi.fifo) >= 2 * 32 * FBIINIT0_MEMORY_FIFO_HWM(v->reg[fbiInit0].u))
37213721      {
37223722         if (LOG_FIFO) logerror("VOODOO.%d.FIFO:voodoo_w hit memory FIFO HWM -- stalling\n", v->index);
3723         stall_cpu(v, STALLED_UNTIL_FIFO_LWM, mame_timer_get_time());
3723         stall_cpu(v, STALLED_UNTIL_FIFO_LWM, timer_get_time());
37243724      }
37253725   }
37263726
r1293r1294
37293729      fifo_space(&v->pci.fifo) <= 2 * FBIINIT0_PCI_FIFO_LWM(v->reg[fbiInit0].u))
37303730   {
37313731      if (LOG_FIFO) logerror("VOODOO.%d.FIFO:voodoo_w hit PCI FIFO free LWM -- stalling\n", v->index);
3732      stall_cpu(v, STALLED_UNTIL_FIFO_LWM, mame_timer_get_time());
3732      stall_cpu(v, STALLED_UNTIL_FIFO_LWM, timer_get_time());
37333733   }
37343734
37353735   /* if we weren't ready, and this is a non-FIFO access, stall until the FIFOs are clear */
37363736   if (stall)
37373737   {
37383738      if (LOG_FIFO_VERBOSE) logerror("VOODOO.%d.FIFO:voodoo_w wrote non-FIFO register -- stalling until clear\n", v->index);
3739      stall_cpu(v, STALLED_UNTIL_FIFO_EMPTY, mame_timer_get_time());
3739      stall_cpu(v, STALLED_UNTIL_FIFO_EMPTY, timer_get_time());
37403740   }
37413741
37423742   profiler_mark(PROFILER_END);
r1293r1294
40094009{
40104010   /* if we have something pending, flush the FIFOs up to the current time */
40114011   if (v->pci.op_pending)
4012      flush_fifos(v, mame_timer_get_time());
4012      flush_fifos(v, timer_get_time());
40134013
40144014   /* target the appropriate location */
40154015   if (!(offset & (0xc00000/4)))
r1293r1294
40954095
40964096   /* if we have something pending, flush the FIFOs up to the current time */
40974097   if (v->pci.op_pending)
4098      flush_fifos(v, mame_timer_get_time());
4098      flush_fifos(v, timer_get_time());
40994099
41004100   if (offset < 0x80000/4)
41014101      result = banshee_io_r(v, offset, mem_mask);
r1293r1294
41284128
41294129   /* if we have something pending, flush the FIFOs up to the current time */
41304130   if (v->pci.op_pending)
4131      flush_fifos(v, mame_timer_get_time());
4131      flush_fifos(v, timer_get_time());
41324132
41334133   if (offset < v->fbi.lfb_base)
41344134   {
r1293r1294
43844384{
43854385   /* if we have something pending, flush the FIFOs up to the current time */
43864386   if (v->pci.op_pending)
4387      flush_fifos(v, mame_timer_get_time());
4387      flush_fifos(v, timer_get_time());
43884388
43894389   if (offset < 0x80000/4)
43904390      banshee_io_w(v, offset, data, mem_mask);
r1293r1294
44164416
44174417   /* if we have something pending, flush the FIFOs up to the current time */
44184418   if (v->pci.op_pending)
4419      flush_fifos(v, mame_timer_get_time());
4419      flush_fifos(v, timer_get_time());
44204420
44214421   if (offset < v->fbi.lfb_base)
44224422   {
src/emu/video/rgbvmx.h
r1293r1294
1212#ifndef __RGBVMX__
1313#define __RGBVMX__
1414
15#include <altivec.h>
1516
17
1618/***************************************************************************
1719    TYPE DEFINITIONS
1820***************************************************************************/
r1293r1294
6062
6163INLINE void rgb_to_rgbint(rgbint *rgb, rgb_t color)
6264{
63   vector signed char temp = vec_perm(vec_lde(0, &color), vec_splat_s32(0), vec_lvsl(0, &color));
65   vector signed char temp = (vector signed char)vec_perm((vector signed int)vec_lde(0, &color), vec_splat_s32(0), vec_lvsl(0, &color));
6466   *rgb = vec_mergeh((vector signed char)vec_splat_s32(0), temp);
6567}
6668
r1293r1294
7274
7375INLINE void rgba_to_rgbaint(rgbaint *rgb, rgb_t color)
7476{
75   vector signed char temp = vec_perm(vec_lde(0, &color), vec_splat_s32(0), vec_lvsl(0, &color));
77   vector signed char temp = (vector signed char)vec_perm((vector signed int)vec_lde(0, &color), vec_splat_s32(0), vec_lvsl(0, &color));
7678   *rgb = vec_mergeh((vector signed char)vec_splat_s32(0), temp);
7779}
7880
r1293r1294
8486
8587INLINE rgb_t rgbint_to_rgb(const rgbint *color)
8688{
87   vector signed int temp = vec_splat((vector signed int)vec_packsu(*color, *color), 0);
89   vector unsigned int temp = vec_splat((vector unsigned int)vec_packsu(*color, *color), 0);
8890   rgb_t result;
8991   vec_ste(temp, 0, &result);
9092   return result;
r1293r1294
98100
99101INLINE rgb_t rgbaint_to_rgba(const rgbaint *color)
100102{
101   vector signed int temp = vec_splat((vector signed int)vec_packsu(*color, *color), 0);
103   vector unsigned int temp = vec_splat((vector unsigned int)vec_packsu(*color, *color), 0);
102104   rgb_t result;
103105   vec_ste(temp, 0, &result);
104106   return result;
r1293r1294
113115
114116INLINE rgb_t rgbint_to_rgb_clamp(const rgbint *color)
115117{
116   vector signed int temp = vec_splat((vector signed int)vec_packsu(*color, *color), 0);
118   vector unsigned int temp = vec_splat((vector unsigned int)vec_packsu(*color, *color), 0);
117119   rgb_t result;
118120   vec_ste(temp, 0, &result);
119121   return result;
r1293r1294
128130
129131INLINE rgb_t rgbaint_to_rgba_clamp(const rgbaint *color)
130132{
131   vector signed int temp = vec_splat((vector signed int)vec_packsu(*color, *color), 0);
133   vector unsigned int temp = vec_splat((vector unsigned int)vec_packsu(*color, *color), 0);
132134   rgb_t result;
133135   vec_ste(temp, 0, &result);
134136   return result;
r1293r1294
359361
360362INLINE void rgbint_blend(rgbint *color1, const rgbint *color2, UINT8 color1scale)
361363{
364   vector signed int temp;
362365   *color1 = vec_mergeh(*color1, *color2);
363   vector signed int temp = vec_msum(*color1, rgbvmx_statics.scale_table[color1scale], vec_splat_s32(0));
364   temp = vec_sr(temp, vec_splat_s32(8));
366   temp = vec_msum(*color1, rgbvmx_statics.scale_table[color1scale], vec_splat_s32(0));
367   temp = (vector signed int)vec_sr(temp, vec_splat_u32(8));
365368   *color1 = vec_packs(temp, temp);
366369}
367370
r1293r1294
373376
374377INLINE void rgbaint_blend(rgbaint *color1, const rgbaint *color2, UINT8 color1scale)
375378{
379   vector signed int temp;
376380   *color1 = vec_mergeh(*color1, *color2);
377   vector signed int temp = vec_msum(*color1, rgbvmx_statics.scale_table[color1scale], vec_splat_s32(0));
378   temp = vec_sr(temp, vec_splat_s32(8));
381   temp = vec_msum(*color1, rgbvmx_statics.scale_table[color1scale], vec_splat_s32(0));
382   temp = (vector signed int)vec_sr(temp, vec_splat_u32(8));
379383   *color1 = vec_packs(temp, temp);
380384}
381385
r1293r1294
390394{
391395   rgbint splatmap = vec_splat((rgbint)vec_lvsl(0, &colorscale), 0);
392396   rgbint vecscale = vec_lde(0, &colorscale);
393   vecscale = vec_perm(vecscale, vecscale, splatmap);
394   *color = vec_mergeh(*color, vec_splat_s32(0));
395   vector signed int temp = vec_msum(*color, vecscale, vec_splat_s32(0));
396   temp = vec_sr(temp, vec_splat_s32(8));
397   vector signed int temp;
398   vecscale = (rgbint)vec_perm(vecscale, vecscale, (vector unsigned char)splatmap);
399   *color = (rgbint)vec_mergeh(*color, (rgbint)vec_splat_s32(0));
400   temp = vec_msum(*color, vecscale, vec_splat_s32(0));
401   temp = (vector signed int)vec_sr(temp, vec_splat_u32(8));
397402   *color = vec_min(vec_packs(temp, temp), rgbvmx_statics.maxbyte);
398403}
399404
r1293r1294
408413{
409414   rgbaint splatmap = vec_splat((rgbaint)vec_lvsl(0, &colorscale), 0);
410415   rgbaint vecscale = vec_lde(0, &colorscale);
411   vecscale = vec_perm(vecscale, vecscale, splatmap);
412   *color = vec_mergeh(*color, vec_splat_s32(0));
413   vector signed int temp = vec_msum(*color, vecscale, vec_splat_s32(0));
414   temp = vec_sr(temp, vec_splat_s32(8));
416   vector signed int temp;
417   vecscale = (rgbaint)vec_perm(vecscale, vecscale, (vector unsigned char)splatmap);
418   *color = (rgbaint)vec_mergeh(*color, (rgbaint)vec_splat_s32(0));
419   temp = vec_msum(*color, vecscale, vec_splat_s32(0));
420   temp = (vector signed int)vec_sr(temp, vec_splat_u32(8));
415421   *color = vec_min(vec_packs(temp, temp), rgbvmx_statics.maxbyte);
416422}
417423
r1293r1294
423429
424430INLINE rgb_t rgb_bilinear_filter(rgb_t rgb00, rgb_t rgb01, rgb_t rgb10, rgb_t rgb11, UINT8 u, UINT8 v)
425431{
426   rgbint color00 = vec_perm(vec_lde(0, &rgb00), vec_splat_s32(0), vec_lvsl(0, &rgb00));
427   rgbint color01 = vec_perm(vec_lde(0, &rgb01), vec_splat_s32(0), vec_lvsl(0, &rgb01));
428   rgbint color10 = vec_perm(vec_lde(0, &rgb10), vec_splat_s32(0), vec_lvsl(0, &rgb10));
429   rgbint color11 = vec_perm(vec_lde(0, &rgb11), vec_splat_s32(0), vec_lvsl(0, &rgb11));
432   rgb_t   result;
433   rgbint   color00 = (rgbint)vec_perm((vector signed int)vec_lde(0, &rgb00), vec_splat_s32(0), vec_lvsl(0, &rgb00));
434   rgbint   color01 = (rgbint)vec_perm((vector signed int)vec_lde(0, &rgb01), vec_splat_s32(0), vec_lvsl(0, &rgb01));
435   rgbint   color10 = (rgbint)vec_perm((vector signed int)vec_lde(0, &rgb10), vec_splat_s32(0), vec_lvsl(0, &rgb10));
436   rgbint   color11 = (rgbint)vec_perm((vector signed int)vec_lde(0, &rgb11), vec_splat_s32(0), vec_lvsl(0, &rgb11));
430437
431438   /* interleave color01 and color00 at the byte level */
432439   color01 = vec_mergeh((vector signed char)color01, (vector signed char)color00);
r1293r1294
435442   color11 = vec_mergeh((vector signed char)vec_splat_s32(0), (vector signed char)color11);
436443   color01 = vec_msum(color01, rgbvmx_statics.scale_table[u], vec_splat_s32(0));
437444   color11 = vec_msum(color11, rgbvmx_statics.scale_table[u], vec_splat_s32(0));
438   color01 = vec_sr((vector signed int)color01, vec_splat_s32(1));
439   color11 = vec_sl((vector signed int)color11, vec_splat_s32(15));
445   color01 = (rgbint)vec_sr((vector signed int)color01, vec_splat_u32(1));
446   color11 = (rgbint)vec_sl((vector signed int)color11, vec_splat_u32(15));
440447   color01 = vec_max(color01, color11);
441448   color01 = vec_msum(color01, rgbvmx_statics.scale_table[v], vec_splat_s32(0));
442   color01 = vec_sr((vector signed int)color01, vec_splat_s32(15));
449   color01 = (rgbint)vec_sr((vector signed int)color01, vec_splat_u32(15));
443450   color01 = vec_packs((vector signed int)color01, (vector signed int)color01);
444451   color01 = vec_packsu(color01, color01);
445   rgb_t result;
446   vec_ste((vector signed int)color01, 0, &result);
452   vec_ste((vector unsigned int)color01, 0, &result);
447453   return result;
448454}
449455
r1293r1294
455461
456462INLINE rgb_t rgba_bilinear_filter(rgb_t rgb00, rgb_t rgb01, rgb_t rgb10, rgb_t rgb11, UINT8 u, UINT8 v)
457463{
458   rgbaint color00 = vec_perm(vec_lde(0, &rgb00), vec_splat_s32(0), vec_lvsl(0, &rgb00));
459   rgbaint color01 = vec_perm(vec_lde(0, &rgb01), vec_splat_s32(0), vec_lvsl(0, &rgb01));
460   rgbaint color10 = vec_perm(vec_lde(0, &rgb10), vec_splat_s32(0), vec_lvsl(0, &rgb10));
461   rgbaint color11 = vec_perm(vec_lde(0, &rgb11), vec_splat_s32(0), vec_lvsl(0, &rgb11));
464   rgb_t   result;
465   rgbaint   color00 = (rgbaint)vec_perm((vector signed int)vec_lde(0, &rgb00), vec_splat_s32(0), vec_lvsl(0, &rgb00));
466   rgbaint   color01 = (rgbaint)vec_perm((vector signed int)vec_lde(0, &rgb01), vec_splat_s32(0), vec_lvsl(0, &rgb01));
467   rgbaint   color10 = (rgbaint)vec_perm((vector signed int)vec_lde(0, &rgb10), vec_splat_s32(0), vec_lvsl(0, &rgb10));
468   rgbaint   color11 = (rgbaint)vec_perm((vector signed int)vec_lde(0, &rgb11), vec_splat_s32(0), vec_lvsl(0, &rgb11));
462469
463470   /* interleave color01 and color00 at the byte level */
464471   color01 = vec_mergeh((vector signed char)color01, (vector signed char)color00);
r1293r1294
467474   color11 = vec_mergeh((vector signed char)vec_splat_s32(0), (vector signed char)color11);
468475   color01 = vec_msum(color01, rgbvmx_statics.scale_table[u], vec_splat_s32(0));
469476   color11 = vec_msum(color11, rgbvmx_statics.scale_table[u], vec_splat_s32(0));
470   color01 = vec_sr((vector signed int)color01, vec_splat_s32(1));
471   color11 = vec_sl((vector signed int)color11, vec_splat_s32(15));
477   color01 = (rgbaint)vec_sr((vector signed int)color01, vec_splat_u32(1));
478   color11 = (rgbaint)vec_sl((vector signed int)color11, vec_splat_u32(15));
472479   color01 = vec_max(color01, color11);
473480   color01 = vec_msum(color01, rgbvmx_statics.scale_table[v], vec_splat_s32(0));
474   color01 = vec_sr((vector signed int)color01, vec_splat_s32(15));
481   color01 = (rgbaint)vec_sr((vector signed int)color01, vec_splat_u32(15));
475482   color01 = vec_packs((vector signed int)color01, (vector signed int)color01);
476483   color01 = vec_packsu(color01, color01);
477   rgb_t result;
478   vec_ste((vector signed int)color01, 0, &result);
484   vec_ste((vector unsigned int)color01, 0, &result);
479485   return result;
480486}
481487
r1293r1294
487493
488494INLINE void rgbint_bilinear_filter(rgbint *color, rgb_t rgb00, rgb_t rgb01, rgb_t rgb10, rgb_t rgb11, UINT8 u, UINT8 v)
489495{
490   rgbaint color00 = vec_perm(vec_lde(0, &rgb00), vec_splat_s32(0), vec_lvsl(0, &rgb00));
491   rgbaint color01 = vec_perm(vec_lde(0, &rgb01), vec_splat_s32(0), vec_lvsl(0, &rgb01));
492   rgbaint color10 = vec_perm(vec_lde(0, &rgb10), vec_splat_s32(0), vec_lvsl(0, &rgb10));
493   rgbaint color11 = vec_perm(vec_lde(0, &rgb11), vec_splat_s32(0), vec_lvsl(0, &rgb11));
496   rgbint color00 = (rgbint)vec_perm((vector signed int)vec_lde(0, &rgb00), vec_splat_s32(0), vec_lvsl(0, &rgb00));
497   rgbint color01 = (rgbint)vec_perm((vector signed int)vec_lde(0, &rgb01), vec_splat_s32(0), vec_lvsl(0, &rgb01));
498   rgbint color10 = (rgbint)vec_perm((vector signed int)vec_lde(0, &rgb10), vec_splat_s32(0), vec_lvsl(0, &rgb10));
499   rgbint color11 = (rgbint)vec_perm((vector signed int)vec_lde(0, &rgb11), vec_splat_s32(0), vec_lvsl(0, &rgb11));
494500
495501   /* interleave color01 and color00 at the byte level */
496502   color01 = vec_mergeh((vector signed char)color01, (vector signed char)color00);
r1293r1294
499505   color11 = vec_mergeh((vector signed char)vec_splat_s32(0), (vector signed char)color11);
500506   color01 = vec_msum(color01, rgbvmx_statics.scale_table[u], vec_splat_s32(0));
501507   color11 = vec_msum(color11, rgbvmx_statics.scale_table[u], vec_splat_s32(0));
502   color01 = vec_sr((vector signed int)color01, vec_splat_s32(1));
503   color11 = vec_sl((vector signed int)color11, vec_splat_s32(15));
508   color01 = (rgbint)vec_sr((vector signed int)color01, vec_splat_u32(1));
509   color11 = (rgbint)vec_sl((vector signed int)color11, vec_splat_u32(15));
504510   color01 = vec_max(color01, color11);
505511   color01 = vec_msum(color01, rgbvmx_statics.scale_table[v], vec_splat_s32(0));
506   color01 = vec_sr((vector signed int)color01, vec_splat_s32(15));
512   color01 = (rgbint)vec_sr((vector signed int)color01, vec_splat_u32(15));
507513   *color = vec_packs((vector signed int)color01, (vector signed int)color01);
508514}
509515
r1293r1294
515521
516522INLINE void rgbaint_bilinear_filter(rgbaint *color, rgb_t rgb00, rgb_t rgb01, rgb_t rgb10, rgb_t rgb11, UINT8 u, UINT8 v)
517523{
518   rgbaint color00 = vec_perm(vec_lde(0, &rgb00), vec_splat_s32(0), vec_lvsl(0, &rgb00));
519   rgbaint color01 = vec_perm(vec_lde(0, &rgb01), vec_splat_s32(0), vec_lvsl(0, &rgb01));
520   rgbaint color10 = vec_perm(vec_lde(0, &rgb10), vec_splat_s32(0), vec_lvsl(0, &rgb10));
521   rgbaint color11 = vec_perm(vec_lde(0, &rgb11), vec_splat_s32(0), vec_lvsl(0, &rgb11));
524   rgbaint color00 = (rgbaint)vec_perm((vector signed int)vec_lde(0, &rgb00), vec_splat_s32(0), vec_lvsl(0, &rgb00));
525   rgbaint color01 = (rgbaint)vec_perm((vector signed int)vec_lde(0, &rgb01), vec_splat_s32(0), vec_lvsl(0, &rgb01));
526   rgbaint color10 = (rgbaint)vec_perm((vector signed int)vec_lde(0, &rgb10), vec_splat_s32(0), vec_lvsl(0, &rgb10));
527   rgbaint color11 = (rgbaint)vec_perm((vector signed int)vec_lde(0, &rgb11), vec_splat_s32(0), vec_lvsl(0, &rgb11));
522528
523529   /* interleave color01 and color00 at the byte level */
524530   color01 = vec_mergeh((vector signed char)color01, (vector signed char)color00);
r1293r1294
527533   color11 = vec_mergeh((vector signed char)vec_splat_s32(0), (vector signed char)color11);
528534   color01 = vec_msum(color01, rgbvmx_statics.scale_table[u], vec_splat_s32(0));
529535   color11 = vec_msum(color11, rgbvmx_statics.scale_table[u], vec_splat_s32(0));
530   color01 = vec_sr((vector signed int)color01, vec_splat_s32(1));
531   color11 = vec_sl((vector signed int)color11, vec_splat_s32(15));
536   color01 = (rgbaint)vec_sr((vector signed int)color01, vec_splat_u32(1));
537   color11 = (rgbaint)vec_sl((vector signed int)color11, vec_splat_u32(15));
532538   color01 = vec_max(color01, color11);
533539   color01 = vec_msum(color01, rgbvmx_statics.scale_table[v], vec_splat_s32(0));
534   color01 = vec_sr((vector signed int)color01, vec_splat_s32(15));
540   color01 = (rgbaint)vec_sr((vector signed int)color01, vec_splat_u32(15));
535541   *color = vec_packs((vector signed int)color01, (vector signed int)color01);
536542}
537543
src/emu/video/vooddefs.h
r1293r1294
14341434   UINT8      stall_state;         /* state of the system if we're stalled */
14351435   void      (*stall_callback)(int); /* callback for stalling/unstalling */
14361436   UINT8      op_pending;            /* true if an operation is pending */
1437   mame_time   op_end_time;         /* time when the pending operation ends */
1438   mame_timer *continue_timer;         /* timer to use to continue processing */
1437   attotime   op_end_time;         /* time when the pending operation ends */
1438   emu_timer *continue_timer;         /* timer to use to continue processing */
14391439   UINT32      fifo_mem[64*2];         /* memory backing the PCI FIFO */
14401440};
14411441
r1293r1294
15491549   UINT32      tile_height;         /* height of video tiles */
15501550   UINT32      x_tiles;            /* number of tiles in the X direction */
15511551
1552   mame_timer *vblank_timer;         /* VBLANK timer */
1552   emu_timer *   vblank_timer;         /* VBLANK timer */
15531553   UINT8      vblank;               /* VBLANK state */
15541554   UINT8      vblank_count;         /* number of VBLANKs since last swap */
15551555   UINT8      vblank_swap_pending;   /* a swap is pending, waiting for a vblank */
r1293r1294
16751675   UINT8      type;               /* type of system */
16761676   UINT8      chipmask;            /* mask for which chips are available */
16771677   UINT32      freq;               /* operating frequency */
1678   subseconds_t subseconds_per_cycle;   /* subseconds per cycle */
1678   attoseconds_t attoseconds_per_cycle;/* attoseconds per cycle */
16791679   UINT32      extra_cycles;         /* extra cycles not yet accounted for */
16801680   int         trigger;            /* trigger used for stalling */
16811681
src/emu/video/crtc6845.c
r1293r1294
3535   UINT16   cursor;
3636   UINT16   light_pen;
3737
38   mame_timer *display_enable_changed_timer;
38   emu_timer *display_enable_changed_timer;
3939
4040   /* saved screen parameters so we don't call
4141       video_screen_configure() unneccessarily.
r1293r1294
9898   /* create the timer if the user is interested in getting display enable
9999       notifications */
100100   if (intf->display_enable_changed)
101      chip->display_enable_changed_timer = mame_timer_alloc_ptr(display_enable_changed_timer_cb, chip);
101      chip->display_enable_changed_timer = timer_alloc_ptr(display_enable_changed_timer_cb, chip);
102102}
103103
104104
r1293r1294
250250         {
251251            rectangle visarea;
252252
253            subseconds_t refresh = HZ_TO_SUBSECONDS(chip->intf->clock) * (chip->horiz_total + 1) * vert_total;
253            attoseconds_t refresh = HZ_TO_ATTOSECONDS(chip->intf->clock) * (chip->horiz_total + 1) * vert_total;
254254
255255            visarea.min_x = 0;
256256            visarea.min_y = 0;
r1293r1294
258258            visarea.max_y = max_y;
259259
260260            if (LOG) logerror("CRTC6845 config screen: HTOTAL: %x  VTOTAL: %x  MAX_X: %x  MAX_Y: %x  FPS: %f\n",
261                          horiz_total, vert_total, max_x, max_y, 1 / SUBSECONDS_TO_DOUBLE(refresh));
261                          horiz_total, vert_total, max_x, max_y, 1 / ATTOSECONDS_TO_DOUBLE(refresh));
262262
263263            video_screen_configure(chip->intf->scrnum, horiz_total, vert_total, &visarea, refresh);
264264
r1293r1294
291291{
292292   INT16 next_y;
293293   UINT16 next_x;
294   mame_time duration;
294   attotime duration;
295295
296296   if (chip->has_valid_parameters && (chip->display_enable_changed_timer != 0))
297297   {
r1293r1294
332332      if (next_y != -1)
333333         duration = video_screen_get_time_until_pos(chip->intf->scrnum, next_y, next_x);
334334      else
335         duration = time_never;
335         duration = attotime_never;
336336
337      mame_timer_adjust_ptr(chip->display_enable_changed_timer, duration, time_never);
337      timer_adjust_ptr(chip->display_enable_changed_timer, duration, attotime_never);
338338   }
339339}
340340
src/emu/info.c
r1293r1294
705705            fprintf(out, " height=\"%d\"", dy);
706706         }
707707
708         fprintf(out, " refresh=\"%f\"", SUBSECONDS_TO_HZ(driver.screen[scrnum].defstate.refresh));
708         fprintf(out, " refresh=\"%f\"", ATTOSECONDS_TO_HZ(driver.screen[scrnum].defstate.refresh));
709709
710710         fprintf(out, " />\n");
711711      }
src/emu/emuopts.h
r1293r1294
148148extern const options_entry mame_core_options[];
149149
150150
151
151152/***************************************************************************
152153    FUNCTION PROTOTYPES
153154***************************************************************************/
src/emu/uimenu.c
r1293r1294
11911191   char *bufptr = buf;
11921192   UINT32 selected = 0;
11931193   int ctrnum;
1194   mame_time total_time;
1194   attotime total_time;
11951195
11961196   /* show total time first */
1197   total_time = mame_timer_get_time();
1197   total_time = timer_get_time();
11981198   if (total_time.seconds >= 60 * 60)
11991199      bufptr += sprintf(bufptr, "%s: %d:%02d:%02d\n\n", ui_getstring(UI_totaltime), total_time.seconds / (60*60), (total_time.seconds / 60) % 60, total_time.seconds % 60);
12001200   else
src/emu/eminline.h
r1293r1294
147147
148148
149149/*-------------------------------------------------
150    div_64x32_rem - perform a signed 64 bit x 32
151    bit divide and return the 32 bit quotient and
152    32 bit remainder
153-------------------------------------------------*/
154
155#ifndef div_64x32_rem
156INLINE INT32 div_64x32_rem(INT64 a, INT32 b, INT32 *remainder)
157{
158   *remainder = a % (INT64)b;
159   return a / (INT64)b;
160}
161#endif
162
163
164/*-------------------------------------------------
165    divu_64x32_rem - perform an unsigned 64 bit x
166    32 bit divide and return the 32 bit quotient
167    and 32 bit remainder
168-------------------------------------------------*/
169
170#ifndef divu_64x32_rem
171INLINE UINT32 divu_64x32_rem(UINT64 a, UINT32 b, UINT32 *remainder)
172{
173   *remainder = a % (UINT64)b;
174   return a / (UINT64)b;
175}
176#endif
177
178
179/*-------------------------------------------------
150180    div_32x32_shift - perform a signed divide of
151181    two 32 bit values, shifting the first before
152182    division, and returning the 32 bit quotient
src/emu/video.c
r1293r1294
3636    CONSTANTS
3737***************************************************************************/
3838
39#define SUBSECONDS_PER_SPEED_UPDATE   (MAX_SUBSECONDS / 4)
39#define SUBSECONDS_PER_SPEED_UPDATE   (ATTOSECONDS_PER_SECOND / 4)
4040#define PAUSED_REFRESH_RATE         30
4141
4242
r1293r1294
6262   INT32               last_partial_scan;   /* scanline of last partial update */
6363
6464   /* screen timing */
65   subseconds_t         scantime;         /* subseconds per scanline */
66   subseconds_t         pixeltime;         /* subseconds per pixel */
67   mame_time             vblank_time;      /* time of last VBLANK start */
68   mame_timer *         scanline0_timer;   /* scanline 0 timer */
65   attoseconds_t         scantime;         /* attoseconds per scanline */
66   attoseconds_t         pixeltime;         /* attoseconds per pixel */
67   attotime             vblank_time;      /* time of last VBLANK start */
68   emu_timer *            scanline0_timer;   /* scanline 0 timer */
6969
7070   /* movie recording */
7171   mame_file *            movie_file;         /* handle to the open movie file */
r1293r1294
9797{
9898   /* throttling calculations */
9999   osd_ticks_t            throttle_last_ticks;/* osd_ticks the last call to throttle */
100   mame_time             throttle_realtime;   /* real time the last call to throttle */
101   mame_time             throttle_emutime;   /* emulated time the last call to throttle */
100   attotime             throttle_realtime;   /* real time the last call to throttle */
101   attotime             throttle_emutime;   /* emulated time the last call to throttle */
102102   UINT32                throttle_history;   /* history of frames where we were fast enough */
103103
104104   /* dynamic speed computation */
105105   osd_ticks_t          speed_last_realtime;/* real time at the last speed calculation */
106   mame_time             speed_last_emutime;   /* emulated time at the last speed calculation */
106   attotime             speed_last_emutime;   /* emulated time at the last speed calculation */
107107   double                speed_percent;      /* most recent speed percentage */
108108   UINT32                partial_updates_this_frame;/* partial update counter this frame */
109109
110110   /* overall speed computation */
111111   UINT32               overall_real_seconds;/* accumulated real seconds at normal speed */
112112   osd_ticks_t            overall_real_ticks;   /* accumulated real ticks at normal speed */
113   mame_time            overall_emutime;   /* accumulated emulated time at normal speed */
113   attotime            overall_emutime;   /* accumulated emulated time at normal speed */
114114   UINT32               overall_valid_counter;/* number of consecutive valid time periods */
115115
116116   /* configuration */
r1293r1294
177177static int finish_screen_updates(running_machine *machine);
178178
179179/* throttling/frameskipping/performance */
180static void update_throttle(mame_time emutime);
180static void update_throttle(attotime emutime);
181181static osd_ticks_t throttle_until_ticks(osd_ticks_t target_ticks);
182182static void update_frameskip(void);
183static void recompute_speed(mame_time emutime);
183static void recompute_speed(attotime emutime);
184184
185185/* screen snapshots */
186186static mame_bitmap *get_snapshot_bitmap(running_machine *machine, int scrnum);
r1293r1294
301301         internal_screen_info *info = &viddata->scrinfo[scrnum];
302302
303303         /* allocate a timer to reset partial updates */
304         info->scanline0_timer = mame_timer_alloc(scanline0_callback);
304         info->scanline0_timer = timer_alloc(scanline0_callback);
305305
306306         /* make pointers back to the config and state */
307307         info->config = &machine->drv->screen[scrnum];
r1293r1294
321321            render_container_set_yscale(container, info->config->yscale);
322322
323323         /* reset VBLANK timing */
324         info->vblank_time = sub_subseconds_from_mame_time(time_zero, machine->screen[0].vblank);
324         info->vblank_time = attotime_sub_attoseconds(attotime_zero, machine->screen[0].vblank);
325325
326326         /* register for save states */
327327         state_save_register_item("video", scrnum, info->vblank_time.seconds);
328         state_save_register_item("video", scrnum, info->vblank_time.subseconds);
328         state_save_register_item("video", scrnum, info->vblank_time.attoseconds);
329329      }
330330
331331   /* create spriteram buffers if necessary */
r1293r1294
415415   {
416416      osd_ticks_t tps = osd_ticks_per_second();
417417      double final_real_time = (double)global.overall_real_seconds + (double)global.overall_real_ticks / (double)tps;
418      double final_emu_time = mame_time_to_double(global.overall_emutime);
419      mame_printf_info("Average speed: %.2f%% (%d seconds)\n", 100 * final_emu_time / final_real_time, add_subseconds_to_mame_time(global.overall_emutime, MAX_SUBSECONDS / 2).seconds);
418      double final_emu_time = attotime_to_double(global.overall_emutime);
419      mame_printf_info("Average speed: %.2f%% (%d seconds)\n", 100 * final_emu_time / final_real_time, attotime_add_attoseconds(global.overall_emutime, ATTOSECONDS_PER_SECOND / 2).seconds);
420420   }
421421}
422422
r1293r1294
429429void video_vblank_start(running_machine *machine)
430430{
431431   video_private *viddata = machine->video_data;
432   mame_time curtime = mame_timer_get_time();
432   attotime curtime = timer_get_time();
433433   int scrnum;
434434
435435   /* kludge: we get called at time 0 to reset, but at that point,
436436       the time of last VBLANK is actually -vblank_duration */
437   if (curtime.seconds == 0 && curtime.subseconds == 0)
438      curtime = sub_subseconds_from_mame_time(time_zero, machine->screen[0].vblank);
437   if (curtime.seconds == 0 && curtime.attoseconds == 0)
438      curtime = attotime_sub_attoseconds(attotime_zero, machine->screen[0].vblank);
439439
440440   /* reset VBLANK timers for each screen -- fix me */
441441   for (scrnum = 0; scrnum < MAX_SCREENS; scrnum++)
r1293r1294
647647    of a screen
648648-------------------------------------------------*/
649649
650void video_screen_configure(int scrnum, int width, int height, const rectangle *visarea, subseconds_t refresh)
650void video_screen_configure(int scrnum, int width, int height, const rectangle *visarea, attoseconds_t refresh)
651651{
652652   video_private *viddata = Machine->video_data;
653653   internal_screen_info *info = &viddata->scrinfo[scrnum];
r1293r1294
727727      float minrefresh = render_get_max_update_rate();
728728      if (minrefresh != 0)
729729      {
730         UINT32 target_speed = floor(minrefresh * 100.0 / SUBSECONDS_TO_HZ(refresh));
730         UINT32 target_speed = floor(minrefresh * 100.0 / ATTOSECONDS_TO_HZ(refresh));
731731         target_speed = MIN(target_speed, global.original_speed);
732732         if (target_speed != global.speed)
733733         {
r1293r1294
743743   /* if we are on scanline 0 already, reset the update timer immediately */
744744   /* otherwise, defer until the next scanline 0 */
745745   if (video_screen_get_vpos(scrnum) == 0)
746      mame_timer_adjust(info->scanline0_timer, time_zero, scrnum, time_zero);
746      timer_adjust(info->scanline0_timer, attotime_zero, scrnum, attotime_zero);
747747   else
748      mame_timer_adjust(info->scanline0_timer, video_screen_get_time_until_pos(scrnum, 0, 0), scrnum, time_zero);
748      timer_adjust(info->scanline0_timer, video_screen_get_time_until_pos(scrnum, 0, 0), scrnum, attotime_zero);
749749}
750750
751751
r1293r1294
867867int video_screen_get_vpos(int scrnum)
868868{
869869   internal_screen_info *info = get_screen_info(Machine, scrnum);
870   subseconds_t delta = mame_time_to_subseconds(sub_mame_times(mame_timer_get_time(), info->vblank_time));
870   attoseconds_t delta = attotime_to_attoseconds(attotime_sub(timer_get_time(), info->vblank_time));
871871   int vpos;
872872
873873   /* round to the nearest pixel */
r1293r1294
890890int video_screen_get_hpos(int scrnum)
891891{
892892   internal_screen_info *info = get_screen_info(Machine, scrnum);
893   subseconds_t delta = mame_time_to_subseconds(sub_mame_times(mame_timer_get_time(), info->vblank_time));
893   attoseconds_t delta = attotime_to_attoseconds(attotime_sub(timer_get_time(), info->vblank_time));
894894   int vpos;
895895
896896   /* round to the nearest pixel */
r1293r1294
939939    at the given hpos,vpos
940940-------------------------------------------------*/
941941
942mame_time video_screen_get_time_until_pos(int scrnum, int vpos, int hpos)
942attotime video_screen_get_time_until_pos(int scrnum, int vpos, int hpos)
943943{
944944   internal_screen_info *info = get_screen_info(Machine, scrnum);
945   subseconds_t curdelta = mame_time_to_subseconds(sub_mame_times(mame_timer_get_time(), info->vblank_time));
946   subseconds_t targetdelta;
945   attoseconds_t curdelta = attotime_to_attoseconds(attotime_sub(timer_get_time(), info->vblank_time));
946   attoseconds_t targetdelta;
947947
948948   /* since we measure time relative to VBLANK, compute the scanline offset from VBLANK */
949949   vpos += info->state->height - (info->state->visarea.max_y + 1);
950950   vpos %= info->state->height;
951951
952952   /* compute the delta for the given X,Y position */
953   targetdelta = (subseconds_t)vpos * info->scantime + (subseconds_t)hpos * info->pixeltime;
953   targetdelta = (attoseconds_t)vpos * info->scantime + (attoseconds_t)hpos * info->pixeltime;
954954
955955   /* if we're past that time (within 1/2 of a pixel), head to the next frame */
956956   if (targetdelta <= curdelta + info->pixeltime / 2)
r1293r1294
959959      targetdelta += info->state->refresh;
960960
961961   /* return the difference */
962   return make_mame_time(0, targetdelta - curdelta);
962   return attotime_make(0, targetdelta - curdelta);
963963}
964964
965965
r1293r1294
969969    scanline
970970-------------------------------------------------*/
971971
972mame_time video_screen_get_scan_period(int scrnum)
972attotime video_screen_get_scan_period(int scrnum)
973973{
974974   internal_screen_info *info = get_screen_info(Machine, scrnum);
975   return make_mame_time(0, info->scantime);
975   return attotime_make(0, info->scantime);
976976}
977977
978978
r1293r1294
982982    complete frame
983983-------------------------------------------------*/
984984
985mame_time video_screen_get_frame_period(int scrnum)
985attotime video_screen_get_frame_period(int scrnum)
986986{
987   return make_mame_time(0, Machine->screen[scrnum].refresh);
987   return attotime_make(0, Machine->screen[scrnum].refresh);
988988}
989989
990990
r1293r1294
10071007   viddata->scrinfo[scrnum].last_partial_scan = 0;
10081008   global.partial_updates_this_frame = 0;
10091009
1010   mame_timer_adjust(viddata->scrinfo[scrnum].scanline0_timer, video_screen_get_time_until_pos(scrnum, 0, 0), scrnum, time_zero);
1010   timer_adjust(viddata->scrinfo[scrnum].scanline0_timer, video_screen_get_time_until_pos(scrnum, 0, 0), scrnum, attotime_zero);
10111011}
10121012
10131013
r1293r1294
10191019
10201020void video_frame_update(void)
10211021{
1022   mame_time current_time = mame_timer_get_time();
1022   attotime current_time = timer_get_time();
10231023   int skipped_it = global.skipping_this_frame;
10241024   int phase = mame_get_phase(Machine);
10251025
r1293r1294
13111311    natural speed
13121312-------------------------------------------------*/
13131313
1314static void update_throttle(mame_time emutime)
1314static void update_throttle(attotime emutime)
13151315{
13161316/*
13171317
r1293r1294
13571357      2,3,3,4,3,4,4,5, 3,4,4,5,4,5,5,6, 3,4,4,5,4,5,5,6, 4,5,5,6,5,6,6,7,
13581358      3,4,4,5,4,5,5,6, 4,5,5,6,5,6,6,7, 4,5,5,6,5,6,6,7, 5,6,6,7,6,7,7,8
13591359   };
1360   subseconds_t real_delta_subseconds;
1361   subseconds_t emu_delta_subseconds;
1362   subseconds_t real_is_ahead_subseconds;
1363   subseconds_t subseconds_per_tick;
1360   attoseconds_t real_delta_attoseconds;
1361   attoseconds_t emu_delta_attoseconds;
1362   attoseconds_t real_is_ahead_attoseconds;
1363   attoseconds_t attoseconds_per_tick;
13641364   osd_ticks_t ticks_per_second;
13651365   osd_ticks_t target_ticks;
13661366   osd_ticks_t diff_ticks;
r1293r1294
13691369   if (global.speed != 0 && global.speed != 100)
13701370   {
13711371      /* multiply emutime by 100 */
1372      emutime = scale_up_mame_time(emutime, 100);
1372      emutime = attotime_mul(emutime, 100);
13731373
13741374      /* divide emutime by the global speed factor */
1375      emutime.subseconds /= global.speed;
1376      emutime.subseconds += (emutime.seconds % global.speed) * (MAX_SUBSECONDS / global.speed);
1375      emutime.attoseconds /= global.speed;
1376      emutime.attoseconds += (emutime.seconds % global.speed) * (ATTOSECONDS_PER_SECOND / global.speed);
13771377      emutime.seconds /= global.speed;
13781378   }
13791379
13801380   /* compute conversion factors up front */
13811381   ticks_per_second = osd_ticks_per_second();
1382   subseconds_per_tick = MAX_SUBSECONDS / ticks_per_second;
1382   attoseconds_per_tick = ATTOSECONDS_PER_SECOND / ticks_per_second;
13831383
13841384   /* if we're paused, emutime will not advance; instead, we subtract a fixed
13851385       amount of time (1/60th of a second) from the emulated time that was passed in,
r1293r1294
13881388       ago, and was in sync in both real and emulated time */
13891389   if (mame_is_paused(Machine))
13901390   {
1391      global.throttle_emutime = sub_subseconds_from_mame_time(emutime, MAX_SUBSECONDS / PAUSED_REFRESH_RATE);
1391      global.throttle_emutime = attotime_sub_attoseconds(emutime, ATTOSECONDS_PER_SECOND / PAUSED_REFRESH_RATE);
13921392      global.throttle_realtime = global.throttle_emutime;
13931393   }
13941394
r1293r1294
13961396       reported value from our current value; this should be a small value somewhere
13971397       between 0 and 1/10th of a second ... anything outside of this range is obviously
13981398       wrong and requires a resync */
1399   emu_delta_subseconds = mame_time_to_subseconds(sub_mame_times(emutime, global.throttle_emutime));
1400   if (emu_delta_subseconds < 0 || emu_delta_subseconds > MAX_SUBSECONDS / 10)
1399   emu_delta_attoseconds = attotime_to_attoseconds(attotime_sub(emutime, global.throttle_emutime));
1400   if (emu_delta_attoseconds < 0 || emu_delta_attoseconds > ATTOSECONDS_PER_SECOND / 10)
14011401   {
14021402      if (LOG_THROTTLE)
1403         logerror("Resync due to weird emutime delta: 0.%09d%09d\n", (int)(emu_delta_subseconds / MAX_SUBSECONDS_SQRT), (int)(emu_delta_subseconds % MAX_SUBSECONDS_SQRT));
1403         logerror("Resync due to weird emutime delta: %s\n", attotime_string(attotime_make(0, emu_delta_attoseconds), 18));
14041404      goto resync;
14051405   }
14061406
r1293r1294
14191419      goto resync;
14201420   }
14211421
1422   /* convert this value into subseconds for easier comparison */
1423   real_delta_subseconds = diff_ticks * subseconds_per_tick;
1422   /* convert this value into attoseconds for easier comparison */
1423   real_delta_attoseconds = diff_ticks * attoseconds_per_tick;
14241424
14251425   /* now update our real and emulated timers with the current values */
14261426   global.throttle_emutime = emutime;
1427   global.throttle_realtime = add_subseconds_to_mame_time(global.throttle_realtime, real_delta_subseconds);
1427   global.throttle_realtime = attotime_add_attoseconds(global.throttle_realtime, real_delta_attoseconds);
14281428
14291429   /* keep a history of whether or not emulated time beat real time over the last few
14301430       updates; this can be used for future heuristics */
1431   global.throttle_history = (global.throttle_history << 1) | (emu_delta_subseconds > real_delta_subseconds);
1431   global.throttle_history = (global.throttle_history << 1) | (emu_delta_attoseconds > real_delta_attoseconds);
14321432
14331433   /* determine how far ahead real time is versus emulated time; note that we use the
14341434       accumulated times for this instead of the deltas for the current update because
14351435       we want to track time over a longer duration than a single update */
1436   real_is_ahead_subseconds = mame_time_to_subseconds(sub_mame_times(global.throttle_emutime, global.throttle_realtime));
1436   real_is_ahead_attoseconds = attotime_to_attoseconds(attotime_sub(global.throttle_emutime, global.throttle_realtime));
14371437
14381438   /* if we're more than 1/10th of a second out, or if we are behind at all and emulation
14391439       is taking longer than the real frame, we just need to resync */
1440   if (real_is_ahead_subseconds < -MAX_SUBSECONDS / 10 ||
1441      (real_is_ahead_subseconds < 0 && popcount[global.throttle_history & 0xff] < 6))
1440   if (real_is_ahead_attoseconds < -ATTOSECONDS_PER_SECOND / 10 ||
1441      (real_is_ahead_attoseconds < 0 && popcount[global.throttle_history & 0xff] < 6))
14421442   {
14431443      if (LOG_THROTTLE)
1444         logerror("Resync due to being behind: 0.%09d%09d (history=%08X)\n", (int)(-real_is_ahead_subseconds / MAX_SUBSECONDS_SQRT), (int)((-real_is_ahead_subseconds) % MAX_SUBSECONDS_SQRT), global.throttle_history);
1444         logerror("Resync due to being behind: %s (history=%08X)\n", attotime_string(attotime_make(0, -real_is_ahead_attoseconds), 18), global.throttle_history);
14451445      goto resync;
14461446   }
14471447
14481448   /* if we're behind, it's time to just get out */
1449   if (real_is_ahead_subseconds < 0)
1449   if (real_is_ahead_attoseconds < 0)
14501450      return;
14511451
14521452   /* compute the target real time, in ticks, where we want to be */
1453   target_ticks = global.throttle_last_ticks + real_is_ahead_subseconds / subseconds_per_tick;
1453   target_ticks = global.throttle_last_ticks + real_is_ahead_attoseconds / attoseconds_per_tick;
14541454
14551455   /* throttle until we read the target, and update real time to match the final time */
14561456   diff_ticks = throttle_until_ticks(target_ticks) - global.throttle_last_ticks;
14571457   global.throttle_last_ticks += diff_ticks;
1458   global.throttle_realtime = add_subseconds_to_mame_time(global.throttle_realtime, diff_ticks * subseconds_per_tick);
1458   global.throttle_realtime = attotime_add_attoseconds(global.throttle_realtime, diff_ticks * attoseconds_per_tick);
14591459   return;
14601460
14611461resync:
r1293r1294
15831583    if we did not skip a frame
15841584-------------------------------------------------*/
15851585
1586static void recompute_speed(mame_time emutime)
1586static void recompute_speed(attotime emutime)
15871587{
1588   subseconds_t delta_emutime;
1588   attoseconds_t delta_emutime;
15891589
15901590   /* if we don't have a starting time yet, or if we're paused, reset our starting point */
15911591   if (global.speed_last_realtime == 0 || mame_is_paused(Machine))
r1293r1294
15951595   }
15961596
15971597   /* if it has been more than the update interval, update the time */
1598   delta_emutime = mame_time_to_subseconds(sub_mame_times(emutime, global.speed_last_emutime));
1598   delta_emutime = attotime_to_attoseconds(attotime_sub(emutime, global.speed_last_emutime));
15991599   if (delta_emutime > SUBSECONDS_PER_SPEED_UPDATE)
16001600   {
16011601      osd_ticks_t realtime = osd_ticks();
16021602      osd_ticks_t delta_realtime = realtime - global.speed_last_realtime;
16031603      osd_ticks_t tps = osd_ticks_per_second();
16041604
1605      /* convert from ticks to subseconds */
1606      global.speed_percent = (double)delta_emutime * (double)tps / ((double)delta_realtime * (double)MAX_SUBSECONDS);
1605      /* convert from ticks to attoseconds */
1606      global.speed_percent = (double)delta_emutime * (double)tps / ((double)delta_realtime * (double)ATTOSECONDS_PER_SECOND);
16071607
16081608      /* remember the last times */
16091609      global.speed_last_realtime = realtime;
r1293r1294
16241624            global.overall_real_ticks -= tps;
16251625            global.overall_real_seconds++;
16261626         }
1627         global.overall_emutime = add_subseconds_to_mame_time(global.overall_emutime, delta_emutime);
1627         global.overall_emutime = attotime_add_attoseconds(global.overall_emutime, delta_emutime);
16281628      }
16291629   }
16301630
r1293r1294
18901890         png_add_text(&pnginfo, "System", text);
18911891
18921892         /* start the capture */
1893         error = mng_capture_start(mame_core_file(info->movie_file), bitmap, SUBSECONDS_TO_HZ(viddata->scrinfo[scrnum].state->refresh));
1893         error = mng_capture_start(mame_core_file(info->movie_file), bitmap, ATTOSECONDS_TO_HZ(viddata->scrinfo[scrnum].state->refresh));
18941894         if (error != PNGERR_NONE)
18951895         {
18961896            png_free(&pnginfo);
src/emu/video.h
r1293r1294
4545   int            width, height;            /* total width/height (HTOTAL, VTOTAL) */
4646   rectangle      visarea;               /* visible area (HBLANK end/start, VBLANK end/start) */
4747   UINT8         oldstyle_vblank_supplied;   /* MDRV_SCREEN_VBLANK_TIME macro used */
48   subseconds_t   refresh;               /* refresh period */
49   subseconds_t   vblank;                  /* duration of a VBLANK */
48   attoseconds_t   refresh;               /* refresh period */
49   attoseconds_t   vblank;                  /* duration of a VBLANK */
5050   bitmap_format   format;                  /* bitmap format */
5151};
5252
r1293r1294
8484/* ----- screen management ----- */
8585
8686/* set the resolution of a screen */
87void video_screen_configure(int scrnum, int width, int height, const rectangle *visarea, subseconds_t refresh);
87void video_screen_configure(int scrnum, int width, int height, const rectangle *visarea, attoseconds_t refresh);
8888
8989/* set the visible area of a screen; this is a subset of video_screen_configure */
9090void video_screen_set_visarea(int scrnum, int min_x, int max_x, int min_y, int max_y);
r1293r1294
101101int video_screen_get_hblank(int scrnum);
102102
103103/* return the time when the beam will reach a particular H,V position */
104mame_time video_screen_get_time_until_pos(int scrnum, int vpos, int hpos);
104attotime video_screen_get_time_until_pos(int scrnum, int vpos, int hpos);
105105
106106/* return the amount of time the beam takes to draw one scan line */
107mame_time video_screen_get_scan_period(int scrnum);
107attotime video_screen_get_scan_period(int scrnum);
108108
109109/* return the amount of time the beam takes to draw one complete frame */
110mame_time video_screen_get_frame_period(int scrnum);
110attotime video_screen_get_frame_period(int scrnum);
111111
112112/* returns whether a given screen exists */
113113int video_screen_exists(int scrnum);
src/emu/emu.mak
r1293r1294
3636#-------------------------------------------------
3737
3838EMUOBJS = \
39   $(EMUOBJ)/attotime.o \
3940   $(EMUOBJ)/audit.o \
4041   $(EMUOBJ)/cheat.o \
4142   $(EMUOBJ)/clifront.o \
src/emu/mame.c
r1293r1294
142142   UINT8         exit_pending;
143143   const game_driver *new_driver_pending;
144144   astring *      saveload_pending_file;
145   mame_timer *   soft_reset_timer;
145   emu_timer *   soft_reset_timer;
146146   mame_file *      logfile;
147147
148148   /* callbacks */
r1293r1294
154154
155155   /* load/save */
156156   void          (*saveload_schedule_callback)(running_machine *);
157   mame_time      saveload_schedule_time;
157   attotime      saveload_schedule_time;
158158
159159   /* array of memory regions */
160160   region_info      mem_region[MAX_MEMORY_REGIONS];
r1293r1294
640640{
641641   mame_private *mame = machine->mame_data;
642642
643   mame_timer_adjust(mame->soft_reset_timer, time_zero, 0, time_zero);
643   timer_adjust(mame->soft_reset_timer, attotime_zero, 0, attotime_zero);
644644
645645   /* we can't be paused since the timer needs to fire */
646646   mame_pause(machine, FALSE);
r1293r1294
684684
685685   /* note the start time and set a timer for the next timeslice to actually schedule it */
686686   mame->saveload_schedule_callback = handle_save;
687   mame->saveload_schedule_time = mame_timer_get_time();
687   mame->saveload_schedule_time = timer_get_time();
688688
689689   /* we can't be paused since we need to clear out anonymous timers */
690690   mame_pause(machine, FALSE);
r1293r1294
707707
708708   /* note the start time and set a timer for the next timeslice to actually schedule it */
709709   mame->saveload_schedule_callback = handle_load;
710   mame->saveload_schedule_time = mame_timer_get_time();
710   mame->saveload_schedule_time = timer_get_time();
711711
712712   /* we can't be paused since we need to clear out anonymous timers */
713713   mame_pause(machine, FALSE);
r1293r1294
15061506   /* initialize the timers and allocate a soft_reset timer */
15071507   /* this must be done before cpu_init so that CPU's can allocate timers */
15081508   timer_init(machine);
1509   mame->soft_reset_timer = mame_timer_alloc(soft_reset);
1509   mame->soft_reset_timer = timer_alloc(soft_reset);
15101510
15111511   /* init the osd layer */
15121512   osd_init(machine);
r1293r1294
16161616
16171617   /* set the global time to the current time */
16181618   /* this allows 0-time queued callbacks to run before any CPUs execute */
1619   mame_timer_set_global_time(mame_timer_get_time());
1619   timer_set_global_time(timer_get_time());
16201620}
16211621
16221622
r1293r1294
16791679   if (timer_count_anonymous() > 0)
16801680   {
16811681      /* if more than a second has passed, we're probably screwed */
1682      if (sub_mame_times(mame_timer_get_time(), mame->saveload_schedule_time).seconds > 0)
1682      if (attotime_sub(timer_get_time(), mame->saveload_schedule_time).seconds > 0)
16831683      {
16841684         popmessage("Unable to save due to pending anonymous timers. See error.log for details.");
16851685         goto cancel;
r1293r1294
17651765   if (timer_count_anonymous() > 0)
17661766   {
17671767      /* if more than a second has passed, we're probably screwed */
1768      if (sub_mame_times(mame_timer_get_time(), mame->saveload_schedule_time).seconds > 0)
1768      if (attotime_sub(timer_get_time(), mame->saveload_schedule_time).seconds > 0)
17691769      {
17701770         popmessage("Unable to load due to pending anonymous timers. See error.log for details.");
17711771         goto cancel;
r1293r1294
18851885void mame_get_current_datetime(running_machine *machine, mame_system_time *systime)
18861886{
18871887   mame_private *mame = machine->mame_data;
1888   fill_systime(systime, mame->base_time + mame_timer_get_time().seconds);
1888   fill_systime(systime, mame->base_time + timer_get_time().seconds);
18891889}
src/emu/machine/timekpr.c
r1293r1294
213213
214214void timekeeper_init( int chip, int type, UINT8 *data )
215215{
216   mame_timer *timer;
217   mame_time duration;
216   emu_timer *timer;
217   attotime duration;
218218   mame_system_time systime;
219219   struct timekeeper_chip *c;
220220
r1293r1294
300300   state_save_register_item( "timekeeper", chip, c->century );
301301   state_save_register_item_pointer( "timekeeper", chip, c->data, c->size );
302302
303   timer = mame_timer_alloc_ptr( timekeeper_tick, c );
304   duration = MAME_TIME_IN_SEC(1);
305   mame_timer_adjust_ptr( timer, duration, duration );
303   timer = timer_alloc_ptr( timekeeper_tick, c );
304   duration = ATTOTIME_IN_SEC(1);
305   timer_adjust_ptr( timer, duration, duration );
306306}
307307
308308static void timekeeper_nvram( int chip, mame_file *file, int read_or_write )
src/emu/machine/scsihd.c
r1293r1294
2222
2323// scsihd_exec_command
2424
25int scsihd_exec_command( SCSIInstance *scsiInstance, UINT8 *statusCode )
25static int scsihd_exec_command( SCSIInstance *scsiInstance, UINT8 *statusCode )
2626{
2727   UINT8 *command;
2828   int commandLength;
src/emu/machine/6526cia.c
r1293r1294
5454   UINT16      count;
5555   UINT8      mode;
5656   UINT8      irq;
57   mame_timer *timer;
57   emu_timer *timer;
5858   cia_state *   cia;
5959};
6060
r1293r1294
171171   for (t = 0; t < (sizeof(cia->timer) / sizeof(cia->timer[0])); t++)
172172   {
173173      cia_timer *timer = &cia->timer[t];
174      timer->timer = mame_timer_alloc_ptr(cia_timer_proc, timer);
174      timer->timer = timer_alloc_ptr(cia_timer_proc, timer);
175175      timer->cia = cia;
176176      timer->irq = 0x01 << t;
177177   }
178178
179179   /* setup TOD timer, if appropriate */
180180   if (intf->tod_clock)
181      mame_timer_pulse(MAME_TIME_IN_HZ(intf->tod_clock), which, cia_clock_tod_callback);
181      timer_pulse(ATTOTIME_IN_HZ(intf->tod_clock), which, cia_clock_tod_callback);
182182
183183   /* special case; for the first CIA, set up an exit handler to clear things out */
184184   if (which == 0)
r1293r1294
292292}
293293
294294
295static int is_timer_active(mame_timer *timer)
295static int is_timer_active(emu_timer *timer)
296296{
297   mame_time t = mame_timer_firetime(timer);
298   return compare_mame_times(t, time_never) != 0;
297   attotime t = timer_firetime(timer);
298   return attotime_compare(t, attotime_never) != 0;
299299}
300300
301301
302/* updates the count and mame_timer for a given CIA timer */
302/* updates the count and emu_timer for a given CIA timer */
303303static void cia_timer_update(cia_timer *timer, INT32 new_count)
304304{
305305   int which = timer - timer->cia->timer;
r1293r1294
310310   /* update the timer count, if necessary */
311311   if ((new_count == -1) && is_timer_active(timer->timer))
312312   {
313      UINT16 current_count = mame_time_to_double(scale_up_mame_time(mame_timer_timeelapsed(timer->timer), timer->cia->clock));
313      UINT16 current_count = attotime_to_double(attotime_mul(timer_timeelapsed(timer->timer), timer->cia->clock));
314314      timer->count = timer->count - MIN(timer->count, current_count);
315315   }
316316
r1293r1294
322322   if ((timer->mode & 0x01) && ((timer->mode & (which ? 0x60 : 0x20)) == 0x00))
323323   {
324324      /* timer is on and is connected to clock */
325      mame_time period = scale_up_mame_time(MAME_TIME_IN_HZ(timer->cia->clock), (timer->count ? timer->count : 0x10000));
326      mame_timer_adjust_ptr(timer->timer, period, time_zero);
325      attotime period = attotime_mul(ATTOTIME_IN_HZ(timer->cia->clock), (timer->count ? timer->count : 0x10000));
326      timer_adjust_ptr(timer->timer, period, attotime_zero);
327327   }
328328   else
329329   {
330330      /* timer is off or not connected to clock */
331      mame_timer_adjust_ptr(timer->timer, time_never, time_zero);
331      timer_adjust_ptr(timer->timer, attotime_never, attotime_zero);
332332   }
333333}
334334
src/emu/machine/74123.c
r1293r1294
2424   UINT8 A;         /* pin 1/9 */
2525   UINT8 B;         /* pin 2/10 */
2626   UINT8 clear;      /* pin 3/11 */
27   mame_timer *timer;
27   emu_timer *timer;
2828};
2929
3030static TTL74123_state chips[MAX_TTL74123];
3131
3232
33static mame_time compute_duration(TTL74123_state *chip)
33static attotime compute_duration(TTL74123_state *chip)
3434{
3535   double duration;
3636
r1293r1294
5454      break;
5555   }
5656
57   return double_to_mame_time(duration);
57   return double_to_attotime(duration);
5858}
5959
6060
6161static int timer_running(TTL74123_state *chip)
6262{
63   return (compare_mame_times(mame_timer_timeleft(chip->timer), time_zero) > 0) &&
64         (compare_mame_times(mame_timer_timeleft(chip->timer), time_never) != 0);
63   return (attotime_compare(timer_timeleft(chip->timer), attotime_zero) > 0) &&
64         (attotime_compare(timer_timeleft(chip->timer), attotime_never) != 0);
6565}
6666
6767
r1293r1294
9696
9797   chip->intf = intf;
9898   chip->which = which;
99   chip->timer = mame_timer_alloc_ptr(clear_callback, chip);
99   chip->timer = timer_alloc_ptr(clear_callback, chip);
100100
101101   /* start with the defaults */
102102   chip->A = intf->A;
r1293r1294
120120
121121static void start_pulse(TTL74123_state *chip)
122122{
123   mame_time duration = compute_duration(chip);
123   attotime duration = compute_duration(chip);
124124
125125   if (timer_running(chip))
126126   {
127127      /* retriggering, but not if we are called to quickly */
128      mame_time delay_time = make_mame_time(0, MAX_SUBSECONDS * chip->intf->cap * 220);
128      attotime delay_time = attotime_make(0, ATTOSECONDS_PER_SECOND * chip->intf->cap * 220);
129129
130      if (compare_mame_times(mame_timer_timeelapsed(chip->timer), delay_time) >= 0)
130      if (attotime_compare(timer_timeelapsed(chip->timer), delay_time) >= 0)
131131      {
132         mame_timer_adjust_ptr(chip->timer, duration, time_never);
132         timer_adjust_ptr(chip->timer, duration, attotime_never);
133133
134         if (LOG) logerror("74123 #%d:  Retriggering pulse.  Duration: %f\n", chip->which, mame_time_to_double(duration));
134         if (LOG) logerror("74123 #%d:  Retriggering pulse.  Duration: %f\n", chip->which, attotime_to_double(duration));
135135      }
136136      else
137137      {
r1293r1294
141141   else
142142   {
143143      /* starting */
144      mame_timer_adjust_ptr(chip->timer, duration, time_never);
144      timer_adjust_ptr(chip->timer, duration, attotime_never);
145145
146146      set_output(chip);
147147
148      if (LOG) logerror("74123 #%d:  Starting pulse.  Duration: %f\n", chip->which, mame_time_to_double(duration));
148      if (LOG) logerror("74123 #%d:  Starting pulse.  Duration: %f\n", chip->which, attotime_to_double(duration));
149149   }
150150}
151151
r1293r1294
181181   /* clear the output if A=LO, B=HI and falling edge on clear */
182182   if (!data && chip->clear && chip->B && !chip->A && !chip->clear)
183183   {
184      mame_timer_adjust_ptr(chip->timer, time_zero, time_never);
184      timer_adjust_ptr(chip->timer, attotime_zero, attotime_never);
185185
186186      if (LOG) logerror("74123 #%d:  Cleared\n", which);
187187   }
src/emu/machine/6850acia.c
r1293r1294
8484   enum    serial_state rx_state;
8585   enum    serial_state tx_state;
8686
87   mame_timer *rx_timer;
88   mame_timer *tx_timer;
87   emu_timer *rx_timer;
88   emu_timer *tx_timer;
8989
9090   void (*int_callback)(int param);
9191} acia_6850;
r1293r1294
168168   acia_p->cts_pin = intf->cts_pin;
169169   acia_p->rts_pin = intf->rts_pin;
170170   acia_p->dcd_pin = intf->dcd_pin;
171   acia_p->rx_timer = mame_timer_alloc(receive_event);
172   acia_p->tx_timer = mame_timer_alloc(transmit_event);
171   acia_p->rx_timer = timer_alloc(receive_event);
172   acia_p->tx_timer = timer_alloc(transmit_event);
173173   acia_p->int_callback = intf->int_callback;
174174   acia_p->first_reset = 1;
175175   acia_p->status_read = 0;
176176   acia_p->brk = 0;
177177
178   mame_timer_reset(acia_p->rx_timer, time_never);
179   mame_timer_reset(acia_p->tx_timer, time_never);
178   timer_reset(acia_p->rx_timer, attotime_never);
179   timer_reset(acia_p->tx_timer, attotime_never);
180180
181181   state_save_register_item("acia6850", which, acia_p->ctrl);
182182   state_save_register_item("acia6850", which, acia_p->status);
r1293r1294
204204/*
205205    Read Status Register
206206*/
207UINT8 acia6850_stat_r(int which)
207static UINT8 acia6850_stat_r(int which)
208208{
209209   acia_6850 *acia_p = &acia[which];
210210
r1293r1294
216216/*
217217    Write Control Register
218218*/
219void acia6850_ctrl_w(int which, UINT8 data)
219static void acia6850_ctrl_w(int which, UINT8 data)
220220{
221221   acia_6850 *acia_p = &acia[which];
222222
r1293r1294
297297
298298   if (!acia_p->reset)
299299   {
300      mame_time rx_period = scale_up_mame_time(MAME_TIME_IN_HZ(acia_p->rx_clock), acia_p->divide);
301      mame_time tx_period = scale_up_mame_time(MAME_TIME_IN_HZ(acia_p->tx_clock), acia_p->divide);
302      mame_timer_adjust(acia_p->rx_timer, rx_period, which, rx_period);
303      mame_timer_adjust(acia_p->tx_timer, tx_period, which, tx_period);
300      attotime rx_period = attotime_mul(ATTOTIME_IN_HZ(acia_p->rx_clock), acia_p->divide);
301      attotime tx_period = attotime_mul(ATTOTIME_IN_HZ(acia_p->tx_clock), acia_p->divide);
302      timer_adjust(acia_p->rx_timer, rx_period, which, rx_period);
303      timer_adjust(acia_p->tx_timer, tx_period, which, tx_period);
304304   }
305305}
306306
307void acia6850_check_interrupts(int which)
307static void acia6850_check_interrupts(int which)
308308{
309309   acia_6850 *acia_p = &acia[which];
310310
r1293r1294
334334/*
335335    Write transmit register
336336*/
337void acia6850_data_w(int which, UINT8 data)
337static void acia6850_data_w(int which, UINT8 data)
338338{
339339   acia_6850 *acia_p = &acia[which];
340340
r1293r1294
353353/*
354354    Read character
355355*/
356UINT8 acia6850_data_r(int which)
356static UINT8 acia6850_data_r(int which)
357357{
358358   acia_6850 *acia_p = &acia[which];
359359
src/emu/machine/mb3773.c
r1293r1294
99#include "driver.h"
1010#include "machine/mb3773.h"
1111
12static mame_timer *watchdog_timer;
12static emu_timer *watchdog_timer;
1313static UINT8 ck = 0;
1414
1515static TIMER_CALLBACK( watchdog_timeout )
r1293r1294
1919
2020static void reset_timer( void )
2121{
22   mame_timer_adjust( watchdog_timer, MAME_TIME_IN_SEC( 5 ), 0, time_zero );
22   timer_adjust( watchdog_timer, ATTOTIME_IN_SEC( 5 ), 0, attotime_zero );
2323}
2424
2525void mb3773_set_ck( UINT8 new_ck )
r1293r1294
3333
3434void mb3773_init( void )
3535{
36   watchdog_timer = mame_timer_alloc( watchdog_timeout );
36   watchdog_timer = timer_alloc( watchdog_timeout );
3737   reset_timer();
3838   state_save_register_global( ck );
3939}
src/emu/machine/idectrl.c
r1293r1294
4343
4444#define IDE_DISK_SECTOR_SIZE         512
4545
46#define MINIMUM_COMMAND_TIME         (MAME_TIME_IN_USEC(10))
46#define MINIMUM_COMMAND_TIME         (ATTOTIME_IN_USEC(10))
4747
48#define TIME_PER_SECTOR               (MAME_TIME_IN_USEC(100))
49#define TIME_PER_ROTATION            (MAME_TIME_IN_HZ(5400/60))
50#define TIME_SECURITY_ERROR            (MAME_TIME_IN_MSEC(1000))
48#define TIME_PER_SECTOR               (ATTOTIME_IN_USEC(100))
49#define TIME_PER_ROTATION            (ATTOTIME_IN_HZ(5400/60))
50#define TIME_SECURITY_ERROR            (ATTOTIME_IN_MSEC(1000))
5151
52#define TIME_SEEK_MULTISECTOR         (MAME_TIME_IN_MSEC(13))
53#define TIME_NO_SEEK_MULTISECTOR      (MAME_TIME_IN_NSEC(16300))
52#define TIME_SEEK_MULTISECTOR         (ATTOTIME_IN_MSEC(13))
53#define TIME_NO_SEEK_MULTISECTOR      (ATTOTIME_IN_NSEC(16300))
5454
5555#define IDE_STATUS_ERROR            0x01
5656#define IDE_STATUS_HIT_INDEX         0x02
r1293r1294
159159
160160   struct ide_interface *intf;
161161   hard_disk_file *   disk;
162   mame_timer *   last_status_timer;
163   mame_timer *   reset_timer;
162   emu_timer *   last_status_timer;
163   emu_timer *   reset_timer;
164164
165165   UINT8   master_password_enable;
166166   UINT8   user_password_enable;
r1293r1294
254254}
255255
256256
257INLINE void signal_delayed_interrupt(struct ide_state *ide, mame_time time, int buffer_ready)
257INLINE void signal_delayed_interrupt(struct ide_state *ide, attotime time, int buffer_ready)
258258{
259259   /* clear buffer ready and set the busy flag */
260260   ide->status &= ~IDE_STATUS_BUFFER_READY;
r1293r1294
262262
263263   /* set a timer */
264264   if (buffer_ready)
265      mame_timer_set_ptr(time, ide, delayed_interrupt_buffer_ready);
265      timer_set_ptr(time, ide, delayed_interrupt_buffer_ready);
266266   else
267      mame_timer_set_ptr(time, ide, delayed_interrupt);
267      timer_set_ptr(time, ide, delayed_interrupt);
268268}
269269
270270
r1293r1294
328328   ide_build_features(ide);
329329
330330   /* create a timer for timing status */
331   ide->last_status_timer = mame_timer_alloc(NULL);
332   ide->reset_timer = mame_timer_alloc_ptr(reset_callback, ide);
331   ide->last_status_timer = timer_alloc(NULL);
332   ide->reset_timer = timer_alloc_ptr(reset_callback, ide);
333333
334334   /* register ide status */
335335   state_save_register_item("ide", which, ide->adapter_control);
r1293r1294
752752   ide->status &= ~IDE_STATUS_DRIVE_READY;
753753
754754   /* just set a timer and mark ourselves error */
755   mame_timer_set_ptr(TIME_SECURITY_ERROR, ide, security_error_done);
755   timer_set_ptr(TIME_SECURITY_ERROR, ide, security_error_done);
756756}
757757
758758
r1293r1294
919919   if (ide->command == IDE_COMMAND_READ_MULTIPLE_BLOCK)
920920   {
921921      int new_lba = lba_address(ide);
922      mame_time seek_time;
922      attotime seek_time;
923923
924924      if (new_lba == ide->cur_lba || new_lba == ide->cur_lba + 1)
925925         seek_time = TIME_NO_SEEK_MULTISECTOR;
r1293r1294
927927         seek_time = TIME_SEEK_MULTISECTOR;
928928
929929      ide->cur_lba = new_lba;
930      mame_timer_set_ptr(seek_time, ide, read_sector_done_callback);
930      timer_set_ptr(seek_time, ide, read_sector_done_callback);
931931   }
932932   else
933      mame_timer_set_ptr(TIME_PER_SECTOR, ide, read_sector_done_callback);
933      timer_set_ptr(TIME_PER_SECTOR, ide, read_sector_done_callback);
934934}
935935
936936
r1293r1294
946946         read_sector_done(ide);
947947      else
948948         /* just set a timer */
949         mame_timer_set_ptr(MAME_TIME_IN_USEC(1), ide, read_sector_done_callback);
949         timer_set_ptr(ATTOTIME_IN_USEC(1), ide, read_sector_done_callback);
950950   }
951951   else
952952      /* just set a timer */
953      mame_timer_set_ptr(TIME_PER_SECTOR, ide, read_sector_done_callback);
953      timer_set_ptr(TIME_PER_SECTOR, ide, read_sector_done_callback);
954954}
955955
956956
r1293r1294
983983      else
984984      {
985985         /* set a timer to do the write */
986         mame_timer_set_ptr(TIME_PER_SECTOR, ide, write_sector_done_callback);
986         timer_set_ptr(TIME_PER_SECTOR, ide, write_sector_done_callback);
987987      }
988988   }
989989   else
990990   {
991991      /* set a timer to do the write */
992      mame_timer_set_ptr(TIME_PER_SECTOR, ide, write_sector_done_callback);
992      timer_set_ptr(TIME_PER_SECTOR, ide, write_sector_done_callback);
993993   }
994994}
995995
r1293r1294
13941394      /* return the current status but don't clear interrupts */
13951395      case IDE_ADDR_STATUS_CONTROL:
13961396         result = ide->status;
1397         if (compare_mame_times(mame_timer_timeelapsed(ide->last_status_timer), TIME_PER_ROTATION) > 0)
1397         if (attotime_compare(timer_timeelapsed(ide->last_status_timer), TIME_PER_ROTATION) > 0)
13981398         {
13991399            result |= IDE_STATUS_HIT_INDEX;
1400            mame_timer_adjust(ide->last_status_timer, time_never, 0, time_zero);
1400            timer_adjust(ide->last_status_timer, attotime_never, 0, attotime_zero);
14011401         }
14021402
14031403         /* clear interrutps only when reading the real status */
r1293r1294
15631563         {
15641564            ide->status |= IDE_STATUS_BUSY;
15651565            ide->status &= ~IDE_STATUS_DRIVE_READY;
1566            mame_timer_adjust_ptr(ide->reset_timer, MAME_TIME_IN_MSEC(5), time_zero);
1566            timer_adjust_ptr(ide->reset_timer, ATTOTIME_IN_MSEC(5), attotime_zero);
15671567         }
15681568         break;
15691569   }
src/emu/machine/6532riot.c
r1293r1294
3434
3535   int timer_irq_enable;
3636   int timer_irq;
37   mame_timer   *counter_timer;
37   emu_timer   *counter_timer;
3838
3939   int clock;
4040};
r1293r1294
4545
4646INLINE void r6532_set_timer(int which, UINT8 count)
4747{
48   mame_timer_adjust( r6532[which].counter_timer, scale_up_mame_time(MAME_TIME_IN_HZ(r6532[which].clock), (count << r6532[which].shift) + 1), which, time_zero );
48   timer_adjust( r6532[which].counter_timer, attotime_mul(ATTOTIME_IN_HZ(r6532[which].clock), (count << r6532[which].shift) + 1), which, attotime_zero );
4949}
5050
5151
r1293r1294
155155
156156INLINE UINT8 r6532_read_timer(int which)
157157{
158   int timer_cycles_left = ( mame_time_to_double(mame_timer_timeleft( r6532[which].counter_timer )) * r6532[which].clock ) - 1;
158   int timer_cycles_left = ( attotime_to_double(timer_timeleft( r6532[which].counter_timer )) * r6532[which].clock ) - 1;
159159   if ( timer_cycles_left >= 0)
160160   {
161161      timer_cycles_left = timer_cycles_left >> r6532[which].shift;
r1293r1294
194194
195195INLINE UINT8 r6532_read_irq_flags(int which)
196196{
197   int timer_cycles_left = ( mame_time_to_double(mame_timer_timeleft( r6532[which].counter_timer )) * r6532[which].clock ) - 1;
197   int timer_cycles_left = ( attotime_to_double(timer_timeleft( r6532[which].counter_timer )) * r6532[which].clock ) - 1;
198198   int res = 0;
199199
200200   if ( timer_cycles_left < 0 )
r1293r1294
286286
287287   r6532[which].shift = 10;
288288
289   r6532[which].counter_timer = mame_timer_alloc(r6532_irq_timer_callback);
289   r6532[which].counter_timer = timer_alloc(r6532_irq_timer_callback);
290290
291291   r6532_set_timer( which, 0xFF );
292292
src/emu/machine/6522via.c
r1293r1294
6262   UINT8 ier;
6363   UINT8 ifr;
6464
65   mame_timer *t1;
66   mame_time time1;
65   emu_timer *t1;
66   attotime time1;
6767   UINT8 t1_active;
68   mame_timer *t2;
69   mame_time time2;
68   emu_timer *t2;
69   attotime time2;
7070   UINT8 t2_active;
7171   UINT8 shift_counter;
7272
r1293r1294
162162   via[which].t1lh = 0xb5; /* ports are not written by kernel! */
163163   via[which].t2ll = 0xff; /* taken from vice */
164164   via[which].t2lh = 0xff;
165   via[which].time2 = via[which].time1 = mame_timer_get_time();
165   via[which].time2 = via[which].time1 = timer_get_time();
166166
167167   /* Default clock is from CPU1 */
168168   via_set_clock (which, Machine->drv->cpu[0].clock);
r1293r1294
212212}
213213
214214
215INLINE mame_time v_cycles_to_time(struct via6522 *v, int c)
215INLINE attotime v_cycles_to_time(struct via6522 *v, int c)
216216{
217   return scale_up_mame_time(MAME_TIME_IN_HZ(v->clock), c);
217   return attotime_mul(ATTOTIME_IN_HZ(v->clock), c);
218218}
219219
220220
221INLINE UINT32 v_time_to_cycles(struct via6522 *v, mame_time t)
221INLINE UINT32 v_time_to_cycles(struct via6522 *v, attotime t)
222222{
223   return mame_time_to_double(scale_up_mame_time(t, v->clock));
223   return attotime_to_double(attotime_mul(t, v->clock));
224224}
225225
226226
r1293r1294
251251      v->shift_counter = (v->shift_counter + 1) % 8;
252252
253253      if (v->shift_counter)
254         mame_timer_set(v_cycles_to_time(v, 2), which, via_shift_callback);
254         timer_set(v_cycles_to_time(v, 2), which, via_shift_callback);
255255      else
256256      {
257257         if (!(v->ifr & INT_SR))
r1293r1294
310310    {
311311      if (T1_SET_PB7(v->acr))
312312         v->out_b ^= 0x80;
313      mame_timer_adjust(v->t1, v_cycles_to_time(v, TIMER1_VALUE(v) + IFR_DELAY), which, time_zero);
313      timer_adjust(v->t1, v_cycles_to_time(v, TIMER1_VALUE(v) + IFR_DELAY), which, attotime_zero);
314314    }
315315   else
316316    {
317317      if (T1_SET_PB7(v->acr))
318318         v->out_b |= 0x80;
319319      v->t1_active = 0;
320      v->time1 = mame_timer_get_time();
320      v->time1 = timer_get_time();
321321    }
322322   if (v->ddr_b)
323323   {
r1293r1294
339339   struct via6522 *v = via + which;
340340
341341   v->t2_active = 0;
342   v->time2 = mame_timer_get_time();
342   v->time2 = timer_get_time();
343343
344344   if (!(v->ifr & INT_T2))
345345      via_set_int (which, INT_T2);
r1293r1294
365365      v.time2 = via[i].time2;
366366      v.clock = via[i].clock;
367367
368      v.t1 = mame_timer_alloc(via_t1_timeout);
368      v.t1 = timer_alloc(via_t1_timeout);
369369      v.t1_active = 0;
370      v.t2 = mame_timer_alloc(via_t2_timeout);
370      v.t2 = timer_alloc(via_t2_timeout);
371371      v.t2_active = 0;
372372
373373      via[i] = v;
r1293r1294
463463    case VIA_T1CL:
464464      via_clear_int (which, INT_T1);
465465      if (v->t1_active)
466         val = v_time_to_cycles(v, mame_timer_timeleft(v->t1)) & 0xff;
466         val = v_time_to_cycles(v, timer_timeleft(v->t1)) & 0xff;
467467      else
468468      {
469469         if ( T1_CONTINUOUS(v->acr) )
470            val = (TIMER1_VALUE(v) - (v_time_to_cycles(v, sub_mame_times(mame_timer_get_time(), v->time1)) % TIMER1_VALUE(v)) - 1) & 0xff;
470            val = (TIMER1_VALUE(v) - (v_time_to_cycles(v, attotime_sub(timer_get_time(), v->time1)) % TIMER1_VALUE(v)) - 1) & 0xff;
471471         else
472            val = (0x10000 - (v_time_to_cycles(v, sub_mame_times(mame_timer_get_time(), v->time1)) & 0xffff) - 1) & 0xff;
472            val = (0x10000 - (v_time_to_cycles(v, attotime_sub(timer_get_time(), v->time1)) & 0xffff) - 1) & 0xff;
473473      }
474474      break;
475475
476476    case VIA_T1CH:
477477      if (v->t1_active)
478         val = v_time_to_cycles(v, mame_timer_timeleft(v->t1)) >> 8;
478         val = v_time_to_cycles(v, timer_timeleft(v->t1)) >> 8;
479479      else
480480      {
481481         if ( T1_CONTINUOUS(v->acr) )
482            val = (TIMER1_VALUE(v)- (v_time_to_cycles(v, sub_mame_times(mame_timer_get_time(), v->time1)) % TIMER1_VALUE(v)) - 1) >> 8;
482            val = (TIMER1_VALUE(v)- (v_time_to_cycles(v, attotime_sub(timer_get_time(), v->time1)) % TIMER1_VALUE(v)) - 1) >> 8;
483483         else
484            val = (0x10000- (v_time_to_cycles(v, sub_mame_times(mame_timer_get_time(), v->time1)) & 0xffff) - 1) >> 8;
484            val = (0x10000- (v_time_to_cycles(v, attotime_sub(timer_get_time(), v->time1)) & 0xffff) - 1) >> 8;
485485      }
486486      break;
487487
r1293r1294
496496    case VIA_T2CL:
497497      via_clear_int (which, INT_T2);
498498      if (v->t2_active)
499         val = v_time_to_cycles(v, mame_timer_timeleft(v->t2)) & 0xff;
499         val = v_time_to_cycles(v, timer_timeleft(v->t2)) & 0xff;
500500      else
501501      {
502502         if (T2_COUNT_PB6(v->acr))
503503            val = v->t2cl;
504504         else
505            val = (0x10000- (v_time_to_cycles(v, sub_mame_times(mame_timer_get_time(), v->time2)) & 0xffff) - 1) & 0xff;
505            val = (0x10000- (v_time_to_cycles(v, attotime_sub(timer_get_time(), v->time2)) & 0xffff) - 1) & 0xff;
506506      }
507507      break;
508508
509509    case VIA_T2CH:
510510      if (v->t2_active)
511         val = v_time_to_cycles(v, mame_timer_timeleft(v->t2)) >> 8;
511         val = v_time_to_cycles(v, timer_timeleft(v->t2)) >> 8;
512512      else
513513      {
514514         if (T2_COUNT_PB6(v->acr))
515515            val = v->t2ch;
516516         else
517            val = (0x10000- (v_time_to_cycles(v, sub_mame_times(mame_timer_get_time(), v->time2)) & 0xffff) - 1) >> 8;
517            val = (0x10000- (v_time_to_cycles(v, attotime_sub(timer_get_time(), v->time2)) & 0xffff) - 1) >> 8;
518518      }
519519      break;
520520
r1293r1294
524524      if (SO_O2_CONTROL(v->acr))
525525      {
526526         v->shift_counter=0;
527         mame_timer_set(v_cycles_to_time(v, 2), which,via_shift_callback);
527         timer_set(v_cycles_to_time(v, 2), which,via_shift_callback);
528528      }
529529      break;
530530
r1293r1294
723723               logerror("6522VIA chip %d: Port B is being written to but has no handler.  PC: %08X - %02X\n", which, safe_activecpu_get_pc(), write_data);
724724         }
725725      }
726      mame_timer_adjust(v->t1, v_cycles_to_time(v, TIMER1_VALUE(v) + IFR_DELAY), which, time_zero);
726      timer_adjust(v->t1, v_cycles_to_time(v, TIMER1_VALUE(v) + IFR_DELAY), which, attotime_zero);
727727      v->t1_active = 1;
728728      break;
729729
r1293r1294
739739
740740      if (!T2_COUNT_PB6(v->acr))
741741      {
742         mame_timer_adjust(v->t2, v_cycles_to_time(v, TIMER2_VALUE(v) + IFR_DELAY), which, time_zero);
742         timer_adjust(v->t2, v_cycles_to_time(v, TIMER2_VALUE(v) + IFR_DELAY), which, attotime_zero);
743743         v->t2_active = 1;
744744      }
745745      else
746746      {
747         v->time2 = mame_timer_get_time();
747         v->time2 = timer_get_time();
748748      }
749749      break;
750750
r1293r1294
754754      via_clear_int(which, INT_SR);
755755      if (SO_O2_CONTROL(v->acr))
756756      {
757         mame_timer_set(v_cycles_to_time(v, 2), which,via_shift_callback);
757         timer_set(v_cycles_to_time(v, 2), which,via_shift_callback);
758758      }
759759      break;
760760
r1293r1294
804804      }
805805      if (T1_CONTINUOUS(data))
806806      {
807         mame_timer_adjust(v->t1, v_cycles_to_time(v, TIMER1_VALUE(v) + IFR_DELAY), which, time_zero);
807         timer_adjust(v->t1, v_cycles_to_time(v, TIMER1_VALUE(v) + IFR_DELAY), which, attotime_zero);
808808         v->t1_active = 1;
809809      }
810810      break;
src/emu/machine/wd33c93.c
r1293r1294
185185   UINT8      busphase;
186186   UINT8      identify;
187187   int         read_pending;
188   mame_timer *cmd_timer;
188   emu_timer *cmd_timer;
189189} _wd33c93_data;
190190
191191/* local instance of controller data */
r1293r1294
237237static void wd33c93_complete_immediate( int status )
238238{
239239   /* reset our timer */
240   mame_timer_reset( scsi_data.cmd_timer, time_never );
240   timer_reset( scsi_data.cmd_timer, attotime_never );
241241
242242   /* set the new status */
243243   scsi_data.regs[WD_SCSI_STATUS] = status & 0xff;
r1293r1294
286286static void wd33c93_complete_cmd( UINT8 status )
287287{
288288   /* fire off a timer to complete the command */
289   mame_timer_adjust( scsi_data.cmd_timer, MAME_TIME_IN_USEC(1), status, time_zero );
289   timer_adjust( scsi_data.cmd_timer, ATTOTIME_IN_USEC(1), status, attotime_zero );
290290}
291291
292292/* command handlers */
r1293r1294
351351      }
352352
353353      /* queue up a service request out in the future */
354      mame_timer_set( MAME_TIME_IN_USEC(50), 0, wd33c93_service_request );
354      timer_set( ATTOTIME_IN_USEC(50), 0, wd33c93_service_request );
355355   }
356356   else
357357   {
r1293r1294
423423         scsi_data.busphase = PHS_MESS_IN;
424424
425425         /* queue up a service request out in the future */
426         mame_timer_set( MAME_TIME_IN_MSEC(50), 0, wd33c93_service_request );
426         timer_set( ATTOTIME_IN_MSEC(50), 0, wd33c93_service_request );
427427      }
428428   }
429429   else
r1293r1294
453453   scsi_data.regs[WD_AUXILIARY_STATUS] |= ASR_CIP;
454454
455455   /* the command will be completed once the data is transferred */
456   mame_timer_set( MAME_TIME_IN_MSEC(1), 0, wd33c93_deassert_cip );
456   timer_set( ATTOTIME_IN_MSEC(1), 0, wd33c93_deassert_cip );
457457}
458458
459459/* Command handlers */
r1293r1294
802802   }
803803
804804   /* allocate a timer for commands */
805   scsi_data.cmd_timer = mame_timer_alloc(wd33c93_complete_cb);
805   scsi_data.cmd_timer = timer_alloc(wd33c93_complete_cb);
806806
807807   scsi_data.temp_input = auto_malloc( TEMP_INPUT_LEN );
808808
src/emu/machine/laserdsc.c
r1293r1294
9191#define STOP_SPEED               INT_TO_FRAC(0)      /* no movement */
9292#define PLAY_SPEED               INT_TO_FRAC(1)      /* regular playback speed */
9393
94#define GENERIC_SPINUP_TIME         (make_mame_time(3, 0))
95#define GENERIC_LOAD_TIME         (make_mame_time(10, 0))
94#define GENERIC_SPINUP_TIME         (attotime_make(3, 0))
95#define GENERIC_LOAD_TIME         (attotime_make(10, 0))
9696#define GENERIC_RESET_SPEED         INT_TO_FRAC(5000)
9797
9898/* Pioneer PR-7820 specific states */
r1293r1294
161161{
162162   UINT8         mode;               /* current mode */
163163   UINT16         commandtriplet[3];      /* current command triplet */
164   mame_time      commandtime;         /* command time */
164   attotime      commandtime;         /* command time */
165165   UINT8         commandbits;         /* command bit count */
166166   UINT8         seekstate;            /* state of the seek command */
167167};
r1293r1294
251251   UINT8         video;               /* video state: bit 0 = on/off */
252252   UINT8         audio;               /* audio state: bit 0 = audio 1, bit 1 = audio 2 */
253253   UINT8         display;            /* display state: bit 0 = on/off */
254   mame_time      lastvsynctime;         /* time of the last vsync */
254   attotime      lastvsynctime;         /* time of the last vsync */
255255
256256   /* deferred states */
257   mame_time      holdfinished;         /* time when current state will advance */
257   attotime      holdfinished;         /* time when current state will advance */
258258   UINT8         postholdstate;         /* state to switch into after holding */
259259   INT32         postholdfracspeed;      /* speed after the hold */
260260
r1293r1294
533533INLINE void set_state(laserdisc_info *info, laserdisc_state state, INT32 fracspeed, INT32 targetframe)
534534{
535535   info->holdfinished.seconds = 0;
536   info->holdfinished.subseconds = 0;
536   info->holdfinished.attoseconds = 0;
537537   info->state = state;
538538   info->curfracspeed = fracspeed;
539539   info->targetframe = targetframe;
r1293r1294
545545    a playback state to follow
546546-------------------------------------------------*/
547547
548INLINE void set_hold_state(laserdisc_info *info, mame_time holdtime, laserdisc_state state, INT32 fracspeed)
548INLINE void set_hold_state(laserdisc_info *info, attotime holdtime, laserdisc_state state, INT32 fracspeed)
549549{
550   info->holdfinished = add_mame_times(mame_timer_get_time(), holdtime);
550   info->holdfinished = attotime_add(timer_get_time(), holdtime);
551551   info->postholdstate = state;
552552   info->postholdfracspeed = fracspeed;
553553}
r1293r1294
832832   UINT8 hittarget;
833833
834834   /* remember the time */
835   info->lastvsynctime = mame_timer_get_time();
835   info->lastvsynctime = timer_get_time();
836836
837837   /* if we're holding, stay in this state until finished */
838   if (info->holdfinished.seconds != 0 || info->holdfinished.subseconds != 0)
838   if (info->holdfinished.seconds != 0 || info->holdfinished.attoseconds != 0)
839839   {
840      if (compare_mame_times(info->lastvsynctime, info->holdfinished) < 0)
840      if (attotime_compare(info->lastvsynctime, info->holdfinished) < 0)
841841         return;
842842      info->state = info->postholdstate;
843843      info->curfracspeed = info->postholdfracspeed;
844844      info->holdfinished.seconds = 0;
845      info->holdfinished.subseconds = 0;
845      info->holdfinished.attoseconds = 0;
846846   }
847847
848848   /* wait for previous read and decode to finish */
r1293r1294
17981798            INT32 prevspeed = info->curfracspeed;
17991799            set_state(info, LASERDISC_STOPPED, STOP_SPEED, NULL_TARGET_FRAME);
18001800            if (info->parameter != -1)
1801               set_hold_state(info, double_to_mame_time(info->parameter * 0.1), prevstate, prevspeed);
1801               set_hold_state(info, double_to_attotime(info->parameter * 0.1), prevstate, prevspeed);
18021802         }
18031803         break;
18041804
r1293r1294
19601960   info->audio = AUDIO_CH1_ENABLE  | AUDIO_CH2_ENABLE;
19611961   info->display = 0;
19621962   pr8210->mode = PR8210_MODE_GET_1ST;
1963   pr8210->commandtime = mame_timer_get_time();
1963   pr8210->commandtime = timer_get_time();
19641964   pr8210->commandbits = 0;
19651965   memset( pr8210->commandtriplet, 0, 3*sizeof(UINT16) );
19661966   pr8210->seekstate = 0;
r1293r1294
21652165   if ( data == ASSERT_LINE )
21662166   {
21672167      /* get the time difference from the last assert */
2168      mame_time delta = sub_mame_times(mame_timer_get_time(), pr8210->commandtime);
2168      attotime delta = attotime_sub(timer_get_time(), pr8210->commandtime);
21692169
21702170      /* and update our internal command time */
2171      pr8210->commandtime = mame_timer_get_time();
2171      pr8210->commandtime = timer_get_time();
21722172
21732173#if 0
21742174      {
2175         int usecdiff = (int)(delta.subseconds / USEC_TO_SUBSECONDS(1));
2175         int usecdiff = (int)(delta.attoseconds / ATTOSECONDS_IN_USEC(1));
21762176
21772177         printf( "bitdelta = %d\n", usecdiff );
21782178      }
21792179#endif
21802180
21812181      /* if the delay is less than 3 msec, we're receiving data */
2182      if ( delta.subseconds < MAME_TIME_IN_MSEC(3).subseconds )
2182      if ( delta.attoseconds < ATTOTIME_IN_MSEC(3).attoseconds )
21832183      {
21842184         /* 0 bit delta is 1.05 msec, 1 bit delta is 2.11 msec */
2185         int longpulse = ( delta.subseconds < MAME_TIME_IN_USEC(1500).subseconds ) ? 0 : 1;
2185         int longpulse = ( delta.attoseconds < ATTOTIME_IN_USEC(1500).attoseconds ) ? 0 : 1;
21862186         pr8210->commandtriplet[pr8210->mode] <<= 1;
21872187         pr8210->commandtriplet[pr8210->mode] |= longpulse;
21882188
r1293r1294
25082508            INT32 prevspeed = info->curfracspeed;
25092509            set_state(info, LASERDISC_STOPPED, STOP_SPEED, NULL_TARGET_FRAME);
25102510            if (info->parameter != -1)
2511               set_hold_state(info, double_to_mame_time(info->parameter * 0.1), prevstate, prevspeed);
2511               set_hold_state(info, double_to_attotime(info->parameter * 0.1), prevstate, prevspeed);
25122512         }
25132513         break;
25142514
r1293r1294
25692569{
25702570   /* the status strobe is asserted (active low) 500-650usec after VSYNC */
25712571   /* for a duration of 26usec; we pick 600-626usec */
2572   mame_time delta = sub_mame_times(mame_timer_get_time(), info->lastvsynctime);
2573   if (delta.subseconds >= MAME_TIME_IN_USEC(600).subseconds &&
2574      delta.subseconds < MAME_TIME_IN_USEC(626).subseconds)
2572   attotime delta = attotime_sub(timer_get_time(), info->lastvsynctime);
2573   if (delta.attoseconds >= ATTOTIME_IN_USEC(600).attoseconds &&
2574      delta.attoseconds < ATTOTIME_IN_USEC(626).attoseconds)
25752575      return ASSERT_LINE;
25762576
25772577   return CLEAR_LINE;
r1293r1294
25882588   /* the command strobe is asserted (active low) 54 or 84usec after the status */
25892589   /* strobe for a duration of 25usec; we pick 600+84 = 684-709usec */
25902590   /* for a duration of 26usec; we pick 600-626usec */
2591   mame_time delta = sub_mame_times(mame_timer_get_time(), info->lastvsynctime);
2592   if (delta.subseconds >= MAME_TIME_IN_USEC(684).subseconds &&
2593      delta.subseconds < MAME_TIME_IN_USEC(709).subseconds)
2591   attotime delta = attotime_sub(timer_get_time(), info->lastvsynctime);
2592   if (delta.attoseconds >= ATTOTIME_IN_USEC(684).attoseconds &&
2593      delta.attoseconds < ATTOTIME_IN_USEC(709).attoseconds)
25942594      return ASSERT_LINE;
25952595
25962596   return CLEAR_LINE;
src/emu/machine/pic8259.c
r1293r1294
3232
3333struct pic8259
3434{
35   mame_timer *timer;
35   emu_timer *timer;
3636   void (*set_int_line)(int which, int interrupt);
3737
3838   pic8259_state_t state;
r1293r1294
8181
8282   for (i = 0; i < count; i++)
8383   {
84      pic[i].timer = mame_timer_alloc(pic8259_timerproc);
84      pic[i].timer = timer_alloc(pic8259_timerproc);
8585      pic[i].set_int_line = set_int_line;
8686   }
8787
r1293r1294
128128
129129static void pic8259_set_timer(int which)
130130{
131   mame_timer_adjust(pic[which].timer, time_zero, which, time_zero);
131   timer_adjust(pic[which].timer, attotime_zero, which, attotime_zero);
132132}
133133
134134
src/emu/machine/intelfsh.c
r1293r1294
4242   INT32 flash_master_lock;
4343   int device_id;
4444   int maker_id;
45   mame_timer *timer;
45   emu_timer *timer;
4646   void *flash_memory;
4747};
4848
r1293r1294
131131   c->status = 0x80;
132132   c->flash_mode = FM_NORMAL;
133133   c->flash_master_lock = 0;
134   c->timer = mame_timer_alloc_ptr(erase_finished, c);
134   c->timer = timer_alloc_ptr(erase_finished, c);
135135   c->flash_memory = data;
136136
137137   state_save_register_item( "intelfsh", chip, c->status );
r1293r1294
335335         c->status = 1 << 3;
336336         c->flash_mode = FM_ERASEAMD4;
337337
338         mame_timer_adjust_ptr( c->timer, MAME_TIME_IN_SEC( 17 ), time_zero );
338         timer_adjust_ptr( c->timer, ATTOTIME_IN_SEC( 17 ), attotime_zero );
339339      }
340340      else if( ( data & 0xff ) == 0x30 )
341341      {
r1293r1294
360360         c->status = 1 << 3;
361361         c->flash_mode = FM_ERASEAMD4;
362362
363         mame_timer_adjust_ptr( c->timer, MAME_TIME_IN_SEC( 1 ), time_zero );
363         timer_adjust_ptr( c->timer, ATTOTIME_IN_SEC( 1 ), attotime_zero );
364364      }
365365      else
366366      {
r1293r1294
429429         c->status = 0x00;
430430         c->flash_mode = FM_READSTATUS;
431431
432         mame_timer_adjust_ptr( c->timer, MAME_TIME_IN_SEC( 1 ), time_zero );
432         timer_adjust_ptr( c->timer, ATTOTIME_IN_SEC( 1 ), attotime_zero );
433433         break;
434434      }
435435      else
src/emu/machine/ds2401.c
r1293r1294
4242   int rx;
4343   int tx;
4444   UINT8 *data;
45   mame_timer *timer;
46   mame_timer *reset_timer;
47   mame_time t_samp;
48   mame_time t_rdv;
49   mame_time t_rstl;
50   mame_time t_pdh;
51   mame_time t_pdl;
45   emu_timer *timer;
46   emu_timer *reset_timer;
47   attotime t_samp;
48   attotime t_rdv;
49   attotime t_rstl;
50   attotime t_pdh;
51   attotime t_pdl;
5252};
5353
5454#define SIZE_DATA ( 8 )
r1293r1294
7272   verboselog( 1, "ds2401_reset(%d)\n", which );
7373
7474   c->state = STATE_RESET;
75   mame_timer_adjust( c->timer, time_never, which, time_never );
75   timer_adjust( c->timer, attotime_never, which, attotime_never );
7676}
7777
7878static TIMER_CALLBACK( ds2401_tick )
r1293r1294
8686      verboselog( 2, "ds2401_tick(%d) state_reset1 %d\n", which, c->rx );
8787      c->tx = 0;
8888      c->state = STATE_RESET2;
89      mame_timer_adjust( c->timer, c->t_pdl, which, time_never );
89      timer_adjust( c->timer, c->t_pdl, which, attotime_never );
9090      break;
9191   case STATE_RESET2:
9292      verboselog( 2, "ds2401_tick(%d) state_reset2 %d\n", which, c->rx );
r1293r1294
154154   c->rx = 1;
155155   c->tx = 1;
156156   c->data = data;
157   c->t_samp = MAME_TIME_IN_USEC( 15 );
158   c->t_rdv = MAME_TIME_IN_USEC( 15 );
159   c->t_rstl = MAME_TIME_IN_USEC( 480 );
160   c->t_pdh = MAME_TIME_IN_USEC( 15 );
161   c->t_pdl = MAME_TIME_IN_USEC( 60 );
157   c->t_samp = ATTOTIME_IN_USEC( 15 );
158   c->t_rdv = ATTOTIME_IN_USEC( 15 );
159   c->t_rstl = ATTOTIME_IN_USEC( 480 );
160   c->t_pdh = ATTOTIME_IN_USEC( 15 );
161   c->t_pdl = ATTOTIME_IN_USEC( 60 );
162162
163163   state_save_register_item( "ds2401", which, c->state );
164164   state_save_register_item( "ds2401", which, c->bit );
r1293r1294
168168   state_save_register_item( "ds2401", which, c->tx );
169169   state_save_register_item_pointer( "ds2401", which, data, SIZE_DATA );
170170
171   c->timer = mame_timer_alloc( ds2401_tick );
172   c->reset_timer = mame_timer_alloc( ds2401_reset );
171   c->timer = timer_alloc( ds2401_tick );
172   c->reset_timer = timer_alloc( ds2401_reset );
173173}
174174
175175void ds2401_write( int which, int data )
r1293r1294
186186         break;
187187      case STATE_COMMAND:
188188         verboselog( 2, "ds2401_write(%d) state_command\n", which );
189         mame_timer_adjust( c->timer, c->t_samp, which, time_never );
189         timer_adjust( c->timer, c->t_samp, which, attotime_never );
190190         break;
191191      case STATE_READROM:
192192         if( c->bit == 0 )
r1293r1294
203203            c->byte++;
204204         }
205205         verboselog( 2, "ds2401_write(%d) state_readrom %d\n", which, c->tx );
206         mame_timer_adjust( c->timer, c->t_rdv, which, time_never );
206         timer_adjust( c->timer, c->t_rdv, which, attotime_never );
207207         break;
208208      default:
209209         verboselog( 0, "ds2401_write(%d) state not handled: %d\n", which, c->state );
210210         break;
211211      }
212      mame_timer_adjust( c->reset_timer, c->t_rstl, which, time_never );
212      timer_adjust( c->reset_timer, c->t_rstl, which, attotime_never );
213213   }
214214   else if( data == 1 && c->rx == 0 )
215215   {
r1293r1294
217217      {
218218      case STATE_RESET:
219219         c->state = STATE_RESET1;
220         mame_timer_adjust( c->timer, c->t_pdh, which, time_never );
220         timer_adjust( c->timer, c->t_pdh, which, attotime_never );
221221         break;
222222      }
223      mame_timer_adjust( c->reset_timer, time_never, which, time_never );
223      timer_adjust( c->reset_timer, attotime_never, which, attotime_never );
224224   }
225225   c->rx = data;
226226}
src/emu/machine/6840ptm.c
r1293r1294
7979   int external_clock[3];
8080
8181   // each PTM has 3 timers
82   mame_timer *timer[3];
82   emu_timer *timer[3];
8383
8484   UINT16 latch[3];
8585   UINT16 counter[3];
r1293r1294
164164
165165      /* store the result */
166166      currptr->counter[counter] = (msb << 8) | lsb;
167      mame_timer_adjust(currptr->timer[counter], scale_up_mame_time(MAME_TIME_IN_HZ(clock), currptr->counter[counter]), which, time_zero);
167      timer_adjust(currptr->timer[counter], attotime_mul(ATTOTIME_IN_HZ(clock), currptr->counter[counter]), which, attotime_zero);
168168   }
169169
170170   /* word mode */
171171   else
172172   {
173      mame_time duration;
173      attotime duration;
174174      int word = currptr->counter[counter];
175175
176176      /* count the clocks */
r1293r1294
188188
189189      /* store the result */
190190      currptr->counter[counter] = word;
191      duration = scale_up_mame_time(MAME_TIME_IN_HZ(clock), currptr->counter[counter]);
192      if (counter == 2) duration = scale_up_mame_time(duration, currptr->t3_divisor);
193      mame_timer_adjust(currptr->timer[counter], duration, which, time_zero);
191      duration = attotime_mul(ATTOTIME_IN_HZ(clock), currptr->counter[counter]);
192      if (counter == 2) duration = attotime_mul(duration, currptr->t3_divisor);
193      timer_adjust(currptr->timer[counter], duration, which, attotime_zero);
194194   }
195195}
196196
r1293r1294
246246      PLOG(("MC6840 #%d: %d external clock freq %d \n", which,counter,clock));
247247   }
248248   /* see how many are left */
249   remaining = mame_time_to_double(scale_up_mame_time(mame_timer_timeleft(currptr->timer[counter]), clock));
249   remaining = attotime_to_double(attotime_mul(timer_timeleft(currptr->timer[counter]), clock));
250250
251251   /* adjust the count for dual byte mode */
252252   if (currptr->control_reg[counter] & 0x04)
r1293r1294
270270{
271271   int clock;
272272   int count;
273   mame_time duration;
273   attotime duration;
274274   ptm6840 *currptr = ptm + which;
275275
276276   /* copy the latched value in */
r1293r1294
306306   /* set the timer */
307307   PLOG(("MC6840 #%d: reload_count(%d): clock = %d  count = %d\n", which, idx, clock, count));
308308
309   duration = scale_up_mame_time(MAME_TIME_IN_HZ(clock), count);
310   if (idx == 2) duration = scale_up_mame_time(duration, currptr->t3_divisor);
311   mame_timer_adjust(currptr->timer[idx], duration, which, time_zero);
312   PLOG(("MC6840 #%d: reload_count(%d): output = %lf\n", which, idx, mame_time_to_double(duration)));
309   duration = attotime_mul(ATTOTIME_IN_HZ(clock), count);
310   if (idx == 2) duration = attotime_mul(duration, currptr->t3_divisor);
311   timer_adjust(currptr->timer[idx], duration, which, attotime_zero);
312   PLOG(("MC6840 #%d: reload_count(%d): output = %lf\n", which, idx, attotime_to_double(duration)));
313313
314314   if (!currptr->control_reg[idx] & 0x02)
315315   {
316316      if (!currptr->intf->external_clock[idx])
317317      {
318318         currptr->enabled[idx] = 0;
319         mame_timer_enable(currptr->timer[idx],FALSE);
319         timer_enable(currptr->timer[idx],FALSE);
320320      }
321321   }
322322   else
323323   {
324324      currptr->enabled[idx] = 1;
325      mame_timer_enable(currptr->timer[idx],TRUE);
325      timer_enable(currptr->timer[idx],TRUE);
326326   }
327327}
328328
r1293r1294
355355      }
356356   }
357357
358   ptm[which].timer[0] = mame_timer_alloc(ptm6840_t1_timeout);
359   ptm[which].timer[1] = mame_timer_alloc(ptm6840_t2_timeout);
360   ptm[which].timer[2] = mame_timer_alloc(ptm6840_t3_timeout);
358   ptm[which].timer[0] = timer_alloc(ptm6840_t1_timeout);
359   ptm[which].timer[1] = timer_alloc(ptm6840_t2_timeout);
360   ptm[which].timer[2] = timer_alloc(ptm6840_t3_timeout);
361361
362362   for (i = 0; i < 3; i++)
363      mame_timer_enable(ptm[which].timer[i], FALSE);
363      timer_enable(ptm[which].timer[i], FALSE);
364364
365365   state_save_register_item("6840ptm", which, currptr->lsb_buffer);
366366   state_save_register_item("6840ptm", which, currptr->msb_buffer);
r1293r1294
521521               PLOG(("MC6840 #%d : Timer reset\n",which));
522522               for (i = 0; i < 3; i++)
523523               {
524                  mame_timer_enable(currptr->timer[i],FALSE);
524                  timer_enable(currptr->timer[i],FALSE);
525525                  currptr->enabled[i]=0;
526526               }
527527            }
src/emu/machine/pd4990a.c
r1293r1294
302302}
303303
304304
305void pd4990a_serial_control(UINT8 data)
305static void pd4990a_serial_control(UINT8 data)
306306{
307307   //Check for command end
308308   if(command_line && !(data&END_BIT)) //end of command
src/emu/machine/am53cf96.c
r1293r1294
159159         case 3:   // reset SCSI bus
160160            scsi_regs[REG_INTSTATE] = 4;   // command sent OK
161161            xfer_state = 0;
162            mame_timer_set( MAME_TIME_IN_HZ( 16384 ), 0, am53cf96_irq );
162            timer_set( ATTOTIME_IN_HZ( 16384 ), 0, am53cf96_irq );
163163            break;
164164         case 0x42:       // select with ATN steps
165            mame_timer_set( MAME_TIME_IN_HZ( 16384 ), 0, am53cf96_irq );
165            timer_set( ATTOTIME_IN_HZ( 16384 ), 0, am53cf96_irq );
166166            if ((fifo[1] == 0) || (fifo[1] == 0x48) || (fifo[1] == 0x4b))
167167            {
168168               scsi_regs[REG_INTSTATE] = 6;
r1293r1294
192192         case 0x10:   // information transfer (must not change xfer_state)
193193         case 0x11:   // second phase of information transfer
194194         case 0x12:   // message accepted
195            mame_timer_set( MAME_TIME_IN_HZ( 16384 ), 0, am53cf96_irq );
195            timer_set( ATTOTIME_IN_HZ( 16384 ), 0, am53cf96_irq );
196196            scsi_regs[REG_INTSTATE] = 6;   // command sent OK
197197            break;
198198         default:
src/emu/machine/pc16552d.c
r1293r1294
4747   int tx_fifo_read_ptr;
4848   int tx_fifo_write_ptr;
4949   int tx_fifo_num;
50   mame_timer *tx_fifo_timer;
50   emu_timer *tx_fifo_timer;
5151} PC16552D_CHANNEL;
5252
5353typedef struct
r1293r1294
152152   ch->pending_interrupt |= IRQ_TX_HOLDING_REG_EMPTY;
153153   check_interrupts(chip, channel);
154154
155   mame_timer_adjust(duart[chip].ch[channel].tx_fifo_timer, time_never, (chip * 2) + channel, time_never);
155   timer_adjust(duart[chip].ch[channel].tx_fifo_timer, attotime_never, (chip * 2) + channel, attotime_never);
156156}
157157
158158static void duart_push_tx_fifo(int chip, int channel, UINT8 data)
159159{
160   mame_time period;
160   attotime period;
161161   PC16552D_CHANNEL *ch = &duart[chip].ch[channel];
162162
163163   ch->tx_fifo_num++;
164164
165   period = scale_up_mame_time(MAME_TIME_IN_HZ(duart[chip].frequency), ch->divisor * 16 * 16 * 8);
165   period = attotime_mul(ATTOTIME_IN_HZ(duart[chip].frequency), ch->divisor * 16 * 16 * 8);
166166
167   mame_timer_adjust(duart[chip].ch[channel].tx_fifo_timer, period, (chip * 2) + channel, time_zero);
167   timer_adjust(duart[chip].ch[channel].tx_fifo_timer, period, (chip * 2) + channel, attotime_zero);
168168}
169169
170170#ifdef UNUSED_FUNCTION
r1293r1294
394394   duart[chip].ch[1].pending_interrupt = 0;
395395
396396   // allocate transmit timers
397   duart[chip].ch[0].tx_fifo_timer = mame_timer_alloc(tx_fifo_timer_callback);
398   mame_timer_adjust(duart[chip].ch[0].tx_fifo_timer, time_never, (chip * 2) + 0, time_never);
397   duart[chip].ch[0].tx_fifo_timer = timer_alloc(tx_fifo_timer_callback);
398   timer_adjust(duart[chip].ch[0].tx_fifo_timer, attotime_never, (chip * 2) + 0, attotime_never);
399399
400   duart[chip].ch[1].tx_fifo_timer = mame_timer_alloc(tx_fifo_timer_callback);
401   mame_timer_adjust(duart[chip].ch[1].tx_fifo_timer, time_never, (chip * 2) + 1, time_never);
400   duart[chip].ch[1].tx_fifo_timer = timer_alloc(tx_fifo_timer_callback);
401   timer_adjust(duart[chip].ch[1].tx_fifo_timer, attotime_never, (chip * 2) + 1, attotime_never);
402402}
403403
404404void pc16552d_rx_data(int chip, int channel, UINT8 data)
src/emu/machine/8042kbdc.c
r1293r1294
280280   kbdc8042.inport = 0xa0;
281281   at_8042_set_outport(0xfe, 1);
282282
283   mame_timer_pulse(MAME_TIME_IN_HZ(60), 0, kbdc8042_time);
283   timer_pulse(ATTOTIME_IN_HZ(60), 0, kbdc8042_time);
284284}
285285
286286static void at_8042_receive(int data)
r1293r1294
522522         break;
523523      case 0xaa:   /* selftest */
524524         if (Machine->drv->cpu[0].type == CPU_I486)
525            mame_timer_set(MAME_TIME_IN_MSEC(10), 0x55, at_8042_receive_timer); /* HACK */
525            timer_set(ATTOTIME_IN_MSEC(10), 0x55, at_8042_receive_timer); /* HACK */
526526         else
527527            at_8042_receive(0x55);
528528         break;
src/emu/machine/8237dma.c
r1293r1294
2525struct dma8237
2626{
2727   const struct dma8237_interface *intf;
28   mame_timer *timer;
29   mame_timer *msbflip_timer;
28   emu_timer *timer;
29   emu_timer *msbflip_timer;
3030
3131   struct
3232   {
r1293r1294
7575   for (which = 0; which < dma_count; which++)
7676   {
7777      dma[which].status = 0x0F;
78      dma[which].timer = mame_timer_alloc(dma8237_timerproc);
79      dma[which].msbflip_timer = mame_timer_alloc(dma8237_msbflip_timerproc);
78      dma[which].timer = timer_alloc(dma8237_timerproc);
79      dma[which].msbflip_timer = timer_alloc(dma8237_msbflip_timerproc);
8080      dma[which].eop = 1;
8181   }
8282   return 0;
r1293r1294
195195         dma[which].status |= 0x10 << channel;
196196         dma[which].status &= ~(0x01 << channel);
197197
198         mame_timer_adjust(dma[which].timer,
199            time_zero,
198         timer_adjust(dma[which].timer,
199            attotime_zero,
200200            which * 4 + channel,
201            double_to_mame_time(dma[which].intf->bus_speed));
201            double_to_attotime(dma[which].intf->bus_speed));
202202      }
203203      else
204204      {
205205         /* no transfers active right now */
206         mame_timer_reset(dma[which].timer, time_never);
206         timer_reset(dma[which].timer, attotime_never);
207207      }
208208
209209      /* set the halt line */
r1293r1294
236236
237237static void prepare_msb_flip(int which)
238238{
239   mame_timer_adjust(dma[which].msbflip_timer, time_zero, which, time_zero);
239   timer_adjust(dma[which].msbflip_timer, attotime_zero, which, attotime_zero);
240240}
241241
242242
src/emu/machine/z80sio.c
r1293r1294
170170   int         inbuf;            /* input buffer */
171171   int         outbuf;            /* output buffer */
172172   UINT8      int_on_next_rx;      /* interrupt on next rx? */
173   mame_timer *receive_timer;      /* timer to clock data in */
173   emu_timer *receive_timer;      /* timer to clock data in */
174174   UINT8      receive_buffer[16];   /* buffer for incoming data */
175175   UINT8      receive_inptr;      /* index of data coming in */
176176   UINT8      receive_outptr;      /* index of data going out */
r1293r1294
272272}
273273
274274
275INLINE mame_time compute_time_per_character(z80sio *sio, int which)
275INLINE attotime compute_time_per_character(z80sio *sio, int which)
276276{
277277   /* fix me -- should compute properly and include data, stop, parity bits */
278   return scale_up_mame_time(MAME_TIME_IN_HZ(9600), 10);
278   return attotime_mul(ATTOTIME_IN_HZ(9600), 10);
279279}
280280
281281
r1293r1294
296296
297297   memset(sio, 0, sizeof(*sio));
298298
299   sio->chan[0].receive_timer = mame_timer_alloc(serial_callback);
300   sio->chan[1].receive_timer = mame_timer_alloc(serial_callback);
299   sio->chan[0].receive_timer = timer_alloc(serial_callback);
300   sio->chan[1].receive_timer = timer_alloc(serial_callback);
301301
302302   sio->irq_cb = intf->irq_cb;
303303   sio->dtr_changed_cb = intf->dtr_changed_cb;
r1293r1294
316316
317317static void reset_channel(z80sio *sio, int ch)
318318{
319   mame_time tpc = compute_time_per_character(sio, ch);
319   attotime tpc = compute_time_per_character(sio, ch);
320320   sio_channel *chan = &sio->chan[ch];
321321
322322   chan->status[0] = SIO_RR0_TX_BUFFER_EMPTY;
r1293r1294
333333   interrupt_check(sio);
334334
335335   /* start the receive timer running */
336   mame_timer_adjust(chan->receive_timer, tpc, ((sio - sios) << 1) | ch, tpc);
336   timer_adjust(chan->receive_timer, tpc, ((sio - sios) << 1) | ch, tpc);
337337}
338338
339339
src/emu/machine/tmp68301.c
r1293r1294
1414UINT16 *tmp68301_regs;
1515
1616static UINT8 tmp68301_IE[3];      // 3 External Interrupt Lines
17static mame_timer *tmp68301_timer[3];      // 3 Timers
17static emu_timer *tmp68301_timer[3];      // 3 Timers
1818
1919static int tmp68301_irq_vector[8];
2020
21void tmp68301_update_timer( int i );
21static void tmp68301_update_timer( int i );
2222
23int tmp68301_irq_callback(int int_level)
23static int tmp68301_irq_callback(int int_level)
2424{
2525   int vector = tmp68301_irq_vector[int_level];
2626//  logerror("CPU #0 PC %06X: irq callback returns %04X for level %x\n",activecpu_get_pc(),vector,int_level);
r1293r1294
6868   UINT16 MAX2   =   tmp68301_regs[(0x206 + i * 0x20)/2];
6969
7070   int max = 0;
71   mame_time duration = time_zero;
71   attotime duration = attotime_zero;
7272
73   mame_timer_adjust(tmp68301_timer[i],time_never,i,time_never);
73   timer_adjust(tmp68301_timer[i],attotime_never,i,attotime_never);
7474
7575   // timers 1&2 only
7676   switch( (TCR & 0x0030)>>4 )                  // MR2..1
r1293r1294
9090      {
9191         int scale = (TCR & 0x3c00)>>10;         // P4..1
9292         if (scale > 8) scale = 8;
93         duration = scale_up_mame_time(MAME_TIME_IN_HZ(Machine->drv->cpu[0].clock), (1 << scale) * max);
93         duration = attotime_mul(ATTOTIME_IN_HZ(Machine->drv->cpu[0].clock), (1 << scale) * max);
9494      }
9595      break;
9696   }
r1293r1294
9999
100100   if (!(TCR & 0x0002))            // CS
101101   {
102      if (compare_mame_times(duration, time_zero))
103         mame_timer_adjust(tmp68301_timer[i],duration,i,time_zero);
102      if (attotime_compare(duration, attotime_zero))
103         timer_adjust(tmp68301_timer[i],duration,i,attotime_zero);
104104      else
105105         logerror("CPU #0 PC %06X: TMP68301 error, timer %d duration is 0\n",activecpu_get_pc(),i);
106106   }
r1293r1294
110110{
111111   int i;
112112   for (i = 0; i < 3; i++)
113      tmp68301_timer[i] = mame_timer_alloc(tmp68301_timer_callback);
113      tmp68301_timer[i] = timer_alloc(tmp68301_timer_callback);
114114
115115   for (i = 0; i < 3; i++)
116116      tmp68301_IE[i] = 0;
src/emu/machine/z80ctc.c
r1293r1294
8181{
8282   UINT8 vector;            /* interrupt vector */
8383   UINT32 clock;            /* system clock */
84   mame_time period16;         /* 16/system clock */
85   mame_time period256;      /* 256/system clock */
84   attotime period16;         /* 16/system clock */
85   attotime period256;      /* 256/system clock */
8686   void (*intr)(int which);   /* interrupt callback */
8787   write8_handler zc[4];      /* zero crossing callbacks */
8888   UINT8 notimer;            /* no timer masks */
r1293r1294
9090   UINT16 tconst[4];         /* time constant */
9191   UINT16 down[4];            /* down counter (clock mode only) */
9292   UINT8 extclk[4];         /* current signal from the external clock */
93   mame_timer *timer[4];            /* array of active timers */
93   emu_timer *timer[4];            /* array of active timers */
9494   UINT8 int_state[4];         /* interrupt status (for daisy chain) */
9595};
9696
r1293r1294
158158   memset(ctc, 0, sizeof(*ctc));
159159
160160   ctc->clock = intf->baseclock;
161   ctc->period16 = scale_up_mame_time(MAME_TIME_IN_HZ(intf->baseclock), 16);
162   ctc->period256 = scale_up_mame_time(MAME_TIME_IN_HZ(intf->baseclock), 256);
161   ctc->period16 = attotime_mul(ATTOTIME_IN_HZ(intf->baseclock), 16);
162   ctc->period256 = attotime_mul(ATTOTIME_IN_HZ(intf->baseclock), 256);
163163   ctc->notimer = intf->notimer;
164164   ctc->intr = intf->intr;
165   ctc->timer[0] = mame_timer_alloc(timercallback);
166   ctc->timer[1] = mame_timer_alloc(timercallback);
167   ctc->timer[2] = mame_timer_alloc(timercallback);
168   ctc->timer[3] = mame_timer_alloc(timercallback);
165   ctc->timer[0] = timer_alloc(timercallback);
166   ctc->timer[1] = timer_alloc(timercallback);
167   ctc->timer[2] = timer_alloc(timercallback);
168   ctc->timer[3] = timer_alloc(timercallback);
169169   ctc->zc[0] = intf->zc0;
170170   ctc->zc[1] = intf->zc1;
171171   ctc->zc[2] = intf->zc2;
r1293r1294
191191   {
192192      ctc->mode[i] = RESET_ACTIVE;
193193      ctc->tconst[i] = 0x100;
194      mame_timer_adjust(ctc->timer[i], time_never, 0, time_never);
194      timer_adjust(ctc->timer[i], attotime_never, 0, attotime_never);
195195      ctc->int_state[i] = 0;
196196   }
197197   interrupt_check(which);
r1293r1294
199199}
200200
201201
202mame_time z80ctc_getperiod(int which, int ch)
202attotime z80ctc_getperiod(int which, int ch)
203203{
204204   z80ctc *ctc = ctcs + which;
205   mame_time period;
205   attotime period;
206206
207207   /* if reset active, no period */
208208   if ((ctc->mode[ch] & RESET) == RESET_ACTIVE)
209      return time_zero;
209      return attotime_zero;
210210
211211   /* if counter mode, no real period */
212212   if ((ctc->mode[ch] & MODE) == MODE_COUNTER)
213213   {
214214      logerror("CTC %d is CounterMode : Can't calculate period\n", ch );
215      return time_zero;
215      return attotime_zero;
216216   }
217217
218218   /* compute the period */
219219   period = ((ctc->mode[ch] & PRESCALER) == PRESCALER_16) ? ctc->period16 : ctc->period256;
220   return scale_up_mame_time(period, ctc->tconst[ch]);
220   return attotime_mul(period, ctc->tconst[ch]);
221221}
222222
223223
r1293r1294
256256         {
257257            if (!(ctc->notimer & (1<<ch)))
258258            {
259               mame_time period = ((mode & PRESCALER) == PRESCALER_16) ? ctc->period16 : ctc->period256;
260               period = scale_up_mame_time(period, ctc->tconst[ch]);
259               attotime period = ((mode & PRESCALER) == PRESCALER_16) ? ctc->period16 : ctc->period256;
260               period = attotime_mul(period, ctc->tconst[ch]);
261261
262               mame_timer_adjust(ctc->timer[ch], period, (which << 2) + ch, period);
262               timer_adjust(ctc->timer[ch], period, (which << 2) + ch, period);
263263            }
264264            else
265               mame_timer_adjust(ctc->timer[ch], time_never, 0, time_never);
265               timer_adjust(ctc->timer[ch], attotime_never, 0, attotime_never);
266266         }
267267
268268         /* else set the bit indicating that we're waiting for the appropriate trigger */
r1293r1294
301301      /* if we're being reset, clear out any pending timers for this channel */
302302      if ((data & RESET) == RESET_ACTIVE)
303303      {
304         mame_timer_adjust(ctc->timer[ch], time_never, 0, time_zero);
304         timer_adjust(ctc->timer[ch], attotime_never, 0, attotime_zero);
305305         /* note that we don't clear the interrupt state here! */
306306      }
307307
r1293r1294
330330   /* else compute the down counter value */
331331   else
332332   {
333      mame_time period = ((ctc->mode[ch] & PRESCALER) == PRESCALER_16) ? ctc->period16 : ctc->period256;
333      attotime period = ((ctc->mode[ch] & PRESCALER) == PRESCALER_16) ? ctc->period16 : ctc->period256;
334334
335      VPRINTF(("CTC clock %f\n",SUBSECONDS_TO_HZ(period.subseconds)));
335      VPRINTF(("CTC clock %f\n",ATTOSECONDS_TO_HZ(period.attoseconds)));
336336
337337      if (ctc->timer[ch])
338         return ((int)(mame_time_to_double(mame_timer_timeleft(ctc->timer[ch])) * mame_time_to_double(period)) + 1) & 0xff;
338         return ((int)(attotime_to_double(timer_timeleft(ctc->timer[ch])) * attotime_to_double(period)) + 1) & 0xff;
339339      else
340340         return 0;
341341   }
r1293r1294
372372
373373            if (!(ctc->notimer & (1<<ch)))
374374            {
375               mame_time period = ((ctc->mode[ch] & PRESCALER) == PRESCALER_16) ? ctc->period16 : ctc->period256;
376               period = scale_up_mame_time(period, ctc->tconst[ch]);
375               attotime period = ((ctc->mode[ch] & PRESCALER) == PRESCALER_16) ? ctc->period16 : ctc->period256;
376               period = attotime_mul(period, ctc->tconst[ch]);
377377
378               mame_timer_adjust(ctc->timer[ch], period, (which << 2) + ch, period);
378               timer_adjust(ctc->timer[ch], period, (which << 2) + ch, period);
379379            }
380380            else
381               mame_timer_adjust(ctc->timer[ch], time_never, 0, time_never);
381               timer_adjust(ctc->timer[ch], attotime_never, 0, attotime_never);
382382         }
383383
384384         /* we're no longer waiting */
src/emu/machine/pit8253.c
r1293r1294
5656   void (*output_callback)(int);   /* callback function for when output changes */
5757   void (*freq_callback)(double);   /* callback function for when output frequency changes */
5858
59   mame_time last_updated;         /* time when last updated */
59   attotime last_updated;         /* time when last updated */
6060
61   mame_timer *outputtimer;      /* MAME timer for output change callback */
62   mame_timer *freqtimer;         /* MAME timer for output frequency change callback */
61   emu_timer *outputtimer;      /* MAME timer for output change callback */
62   emu_timer *freqtimer;         /* MAME timer for output frequency change callback */
6363
6464   UINT16 value;               /* current counter value ("CE" in Intel docs) */
6565   UINT16 latch;               /* latched counter value ("OL" in Intel docs) */
r1293r1294
223223
224224   if (timer->clockin == 0   || cycles == CYCLES_NEVER)
225225   {
226      mame_timer_reset(timer->freqtimer,time_never);
226      timer_reset(timer->freqtimer,attotime_never);
227227   }
228228   else
229229   {
230      mame_timer_reset(timer->freqtimer,double_to_mame_time(cycles / timer->clockin));
230      timer_reset(timer->freqtimer,double_to_attotime(cycles / timer->clockin));
231231   }
232232   timer->cycles_to_freq =   cycles;
233233}
r1293r1294
615615      timer->cycles_to_output   = cycles_to_output;
616616      if (cycles_to_output ==   CYCLES_NEVER ||   timer->clockin == 0)
617617      {
618         mame_timer_reset(timer->outputtimer,time_never);
618         timer_reset(timer->outputtimer,attotime_never);
619619      }
620620      else
621621      {
622         mame_timer_reset(timer->outputtimer,
623            double_to_mame_time(cycles_to_output / timer->clockin));
622         timer_reset(timer->outputtimer,
623            double_to_attotime(cycles_to_output / timer->clockin));
624624      }
625625   }
626626
r1293r1294
677677{
678678   /* With the 82C54's maximum clockin of 10MHz, 64 bits is nearly 60,000
679679       years of time. Should be enough for now. */
680   mame_time now =   mame_timer_get_time();
681   mame_time elapsed_time = sub_mame_times(now,timer->last_updated);
682   INT64 elapsed_cycles =   mame_time_to_double(elapsed_time) *   timer->clockin;
680   attotime now =   timer_get_time();
681   attotime elapsed_time = attotime_sub(now,timer->last_updated);
682   INT64 elapsed_cycles =   attotime_to_double(elapsed_time) *   timer->clockin;
683683
684   timer->last_updated   = add_mame_times(timer->last_updated,double_to_mame_time(elapsed_cycles/timer->clockin));
684   timer->last_updated   = attotime_add(timer->last_updated,double_to_attotime(elapsed_cycles/timer->clockin));
685685
686686   simulate(timer,elapsed_cycles);
687687}
r1293r1294
712712      timer->null_count =   1;
713713      timer->cycles_to_output   = timer->cycles_to_freq   = CYCLES_NEVER;
714714
715      timer->last_updated   = mame_timer_get_time();
715      timer->last_updated   = timer_get_time();
716716
717717      update(timer);
718718   }
r1293r1294
731731
732732   t = cycles / timer->clockin;
733733
734   timer->last_updated   = add_mame_times(timer->last_updated, double_to_mame_time(t));
734   timer->last_updated   = attotime_add(timer->last_updated, double_to_attotime(t));
735735}
736736
737737
r1293r1294
747747
748748   t = cycles / timer->clockin;
749749
750   timer->last_updated   = add_mame_times(timer->last_updated, double_to_mame_time(t));
750   timer->last_updated   = attotime_add(timer->last_updated, double_to_attotime(t));
751751}
752752
753753
r1293r1294
781781            timer->outputtimer = NULL;
782782         else
783783         {
784            timer->outputtimer = mame_timer_alloc(outputcallback);
785            mame_timer_adjust(timer->outputtimer, time_never, i   | (timerno<<4),   time_zero);
784            timer->outputtimer = timer_alloc(outputcallback);
785            timer_adjust(timer->outputtimer, attotime_never, i   | (timerno<<4),   attotime_zero);
786786         }
787787         if (timer->freq_callback ==   NULL)
788788            timer->freqtimer = NULL;
789789         else
790790         {
791            timer->freqtimer = mame_timer_alloc(freqcallback);
792            mame_timer_adjust(timer->freqtimer,   time_never,   i |   (timerno<<4), time_zero);
791            timer->freqtimer = timer_alloc(freqcallback);
792            timer_adjust(timer->freqtimer,   attotime_never,   i |   (timerno<<4), attotime_zero);
793793         }
794794
795795         /* set up state save values */
r1293r1294
812812         state_save_register_item("pit8253", n, timer->cycles_to_freq);
813813         state_save_register_item("pit8253", n, timer->freq_count);
814814         state_save_register_item("pit8253", n, timer->last_updated.seconds);
815         state_save_register_item("pit8253", n, timer->last_updated.subseconds);
815         state_save_register_item("pit8253", n, timer->last_updated.attoseconds);
816816         ++n;
817817      }
818818      pit8253_reset(i);
src/emu/machine/ds2404.c
r1293r1294
287287   struct tm ref_tm;
288288   time_t ref_time;
289289   time_t current_time;
290   mame_timer *timer;
290   emu_timer *timer;
291291
292292   memset( &ref_tm, 0, sizeof( ref_tm ) );
293293   ref_tm.tm_year = ref_year - 1900;
r1293r1294
305305   ds2404.rtc[ 3 ] = ( current_time >> 16 ) & 0xff;
306306   ds2404.rtc[ 4 ] = ( current_time >> 24 ) & 0xff;
307307
308   timer = mame_timer_alloc( DS2404_tick );
309   mame_timer_adjust( timer, MAME_TIME_IN_HZ( 256 ), 0, MAME_TIME_IN_HZ( 256 ) );
308   timer = timer_alloc( DS2404_tick );
309   timer_adjust( timer, ATTOTIME_IN_HZ( 256 ), 0, ATTOTIME_IN_HZ( 256 ) );
310310}
311311
312312void DS2404_load(mame_file *file)
src/emu/machine/z80ctc.h
r1293r1294
4242
4343void z80ctc_init(int which, z80ctc_interface *intf);
4444void z80ctc_reset(int which);
45mame_time z80ctc_getperiod (int which, int ch);
45attotime z80ctc_getperiod (int which, int ch);
4646
4747
4848
src/emu/machine/mc146818.c
r1293r1294
9090   UINT16 eindex;
9191   UINT8 edata[0x2000];
9292
93   mame_time last_refresh;
93   attotime last_refresh;
9494};
9595
9696static struct mc146818_chip *mc146818;
r1293r1294
190190      }
191191   }
192192
193   mc146818->last_refresh = mame_timer_get_time();
193   mc146818->last_refresh = timer_get_time();
194194}
195195
196196
r1293r1294
200200   mc146818 = auto_malloc(sizeof(*mc146818));
201201   memset(mc146818, 0, sizeof(*mc146818));
202202   mc146818->type = type;
203   mc146818->last_refresh = mame_timer_get_time();
204    mame_timer_pulse(MAME_TIME_IN_HZ(1), 0, mc146818_timer);
203   mc146818->last_refresh = timer_get_time();
204    timer_pulse(ATTOTIME_IN_HZ(1), 0, mc146818_timer);
205205   mc146818_set_base_datetime();
206206}
207207
r1293r1294
316316      switch (mc146818->index % MC146818_DATA_SIZE) {
317317      case 0xa:
318318         data = mc146818->data[mc146818->index  % MC146818_DATA_SIZE];
319         if (compare_mame_times(sub_mame_times(mame_timer_get_time(), mc146818->last_refresh), MAME_TIME_IN_HZ(32768)) < 0)
319         if (attotime_compare(attotime_sub(timer_get_time(), mc146818->last_refresh), ATTOTIME_IN_HZ(32768)) < 0)
320320            data |= 0x80;
321321#if 0
322322         /* for pc1512 bios realtime clock test */
src/emu/machine/rtc65271.c
r1293r1294
2525
2626/* Delay between the beginning (UIP asserted) and the end (UIP cleared and
2727update interrupt asserted) of the update cycle */
28#define UPDATE_CYCLE_TIME MAME_TIME_IN_USEC(1984)
28#define UPDATE_CYCLE_TIME ATTOTIME_IN_USEC(1984)
2929/* Delay between the assertion of UIP and the effective start of the update
3030cycle */
31/*#define UPDATE_CYCLE_DELAY MAME_TIME_IN_USEC(244)*/
31/*#define UPDATE_CYCLE_DELAY ATTOTIME_IN_USEC(244)*/
3232
3333static struct
3434{
r1293r1294
4242   int cur_xram_page;
4343
4444   /* update timer: called every second */
45   mame_timer *update_timer;
45   emu_timer *update_timer;
4646
4747   /* SQW timer: called every periodic clock half-period */
48   mame_timer *SQW_timer;
48   emu_timer *SQW_timer;
4949   int SQW_internal_state;
5050
5151   /* callback called when interrupt pin state changes (may be NULL) */
r1293r1294
316316
317317   rtc.xram = xram;
318318
319   rtc.update_timer = mame_timer_alloc(rtc_begin_update_callback);
320   mame_timer_adjust(rtc.update_timer, MAME_TIME_IN_SEC(1), 0, MAME_TIME_IN_SEC(1));
321   rtc.SQW_timer = mame_timer_alloc(rtc_SQW_callback);
319   rtc.update_timer = timer_alloc(rtc_begin_update_callback);
320   timer_adjust(rtc.update_timer, ATTOTIME_IN_SEC(1), 0, ATTOTIME_IN_SEC(1));
321   rtc.SQW_timer = timer_alloc(rtc_SQW_callback);
322322   rtc.interrupt_callback = interrupt_callback;
323323}
324324
r1293r1294
404404            {
405405               if (data & reg_A_RS)
406406               {
407                  mame_time period = MAME_TIME_IN_HZ(SQW_freq_table[data & reg_A_RS]);
408                  mame_time half_period = scale_down_mame_time(period, 2);
409                  mame_time elapsed = mame_timer_timeelapsed(rtc.update_timer);
407                  attotime period = ATTOTIME_IN_HZ(SQW_freq_table[data & reg_A_RS]);
408                  attotime half_period = attotime_div(period, 2);
409                  attotime elapsed = timer_timeelapsed(rtc.update_timer);
410410
411                  if (compare_mame_times(half_period, elapsed) > 0)
412                     mame_timer_adjust(rtc.SQW_timer, sub_mame_times(half_period, elapsed), 0, time_never);
411                  if (attotime_compare(half_period, elapsed) > 0)
412                     timer_adjust(rtc.SQW_timer, attotime_sub(half_period, elapsed), 0, attotime_never);
413413                  else
414                     mame_timer_adjust(rtc.SQW_timer, half_period, 0, time_never);
414                     timer_adjust(rtc.SQW_timer, half_period, 0, attotime_never);
415415               }
416416               else
417417               {
418418                  rtc.SQW_internal_state = 0;   /* right??? */
419419
420420                  /* Stop the divider used for SQW and periodic interrupts. */
421                  mame_timer_adjust(rtc.SQW_timer, time_never, 0, time_never);
421                  timer_adjust(rtc.SQW_timer, attotime_never, 0, attotime_never);
422422               }
423423            }
424424            /* The UIP bit is read-only */
r1293r1294
477477*/
478478static TIMER_CALLBACK( rtc_SQW_callback )
479479{
480   mame_time half_period;
480   attotime half_period;
481481
482482   rtc.SQW_internal_state = ! rtc.SQW_internal_state;
483483   if (! rtc.SQW_internal_state)
r1293r1294
487487      field_interrupts();
488488   }
489489
490   half_period = scale_down_mame_time(MAME_TIME_IN_HZ(SQW_freq_table[rtc.regs[reg_A] & reg_A_RS]), 2);
491   mame_timer_adjust(rtc.SQW_timer, half_period, 0, time_never);
490   half_period = attotime_div(ATTOTIME_IN_HZ(SQW_freq_table[rtc.regs[reg_A] & reg_A_RS]), 2);
491   timer_adjust(rtc.SQW_timer, half_period, 0, attotime_never);
492492}
493493
494494/*
r1293r1294
501501      rtc.regs[reg_A] |= reg_A_UIP;
502502
503503      /* schedule end of update cycle */
504      mame_timer_set(UPDATE_CYCLE_TIME, 0, rtc_end_update_callback);
504      timer_set(UPDATE_CYCLE_TIME, 0, rtc_end_update_callback);
505505   }
506506}
507507
src/emu/attotime.c
r0r1294
1/***************************************************************************
2
3    attotime.c
4
5    Support functions for working with attotime data.
6
7    Copyright (c) 1996-2007, Nicola Salmoria and the MAME Team.
8    Visit http://mamedev.org for licensing and usage restrictions.
9
10***************************************************************************/
11
12#include "mamecore.h"
13#include "attotime.h"
14#include "eminline.h"
15
16
17/***************************************************************************
18    GLOBAL VARIABLES
19***************************************************************************/
20
21const attotime       attotime_zero = STATIC_ATTOTIME_IN_SEC(0);
22const attotime       attotime_never = STATIC_ATTOTIME_IN_SEC(ATTOTIME_MAX_SECONDS);
23
24
25
26/***************************************************************************
27    CONVERSION HELPERS
28***************************************************************************/
29
30/*-------------------------------------------------
31    attotime_to_attoseconds - convert a attotime
32    to attoseconds, clamping to maximum positive/
33    negative values
34-------------------------------------------------*/
35
36attoseconds_t attotime_to_attoseconds(attotime _time)
37{
38   /* positive values between 0 and 1 second */
39   if (_time.seconds == 0)
40      return _time.attoseconds;
41
42   /* negative values between -1 and 0 seconds */
43   else if (_time.seconds == -1)
44      return _time.attoseconds - ATTOSECONDS_PER_SECOND;
45
46   /* out-of-range positive values */
47   else if (_time.seconds > 0)
48      return ATTOSECONDS_PER_SECOND;
49
50   /* out-of-range negative values */
51   else
52      return -ATTOSECONDS_PER_SECOND;
53}
54
55
56
57/***************************************************************************
58    CORE MATH FUNCTIONS
59***************************************************************************/
60
61/*-------------------------------------------------
62    attotime_add - add two attotimes
63-------------------------------------------------*/
64
65attotime attotime_add(attotime _time1, attotime _time2)
66{
67   attotime result;
68
69   /* if one of the items is attotime_never, return attotime_never */
70   if (_time1.seconds >= ATTOTIME_MAX_SECONDS || _time2.seconds >= ATTOTIME_MAX_SECONDS)
71      return attotime_never;
72
73   /* add the seconds and attoseconds */
74   result.attoseconds = _time1.attoseconds + _time2.attoseconds;
75   result.seconds = _time1.seconds + _time2.seconds;
76
77   /* normalize and return */
78   if (result.attoseconds >= ATTOSECONDS_PER_SECOND)
79   {
80      result.attoseconds -= ATTOSECONDS_PER_SECOND;
81      result.seconds++;
82   }
83
84   /* overflow */
85   if (result.seconds >= ATTOTIME_MAX_SECONDS)
86      return attotime_never;
87   return result;
88}
89
90
91/*-------------------------------------------------
92    attotime_add_attoseconds - add attoseconds
93    to a attotime
94-------------------------------------------------*/
95
96attotime attotime_add_attoseconds(attotime _time1, attoseconds_t _attoseconds)
97{
98   attotime result;
99
100   /* if one of the items is attotime_never, return attotime_never */
101   if (_time1.seconds >= ATTOTIME_MAX_SECONDS)
102      return attotime_never;
103
104   /* add the seconds and attoseconds */
105   result.attoseconds = _time1.attoseconds + _attoseconds;
106   result.seconds = _time1.seconds;
107
108   /* normalize and return */
109   if (result.attoseconds >= ATTOSECONDS_PER_SECOND)
110   {
111      result.attoseconds -= ATTOSECONDS_PER_SECOND;
112      result.seconds++;
113   }
114
115   /* overflow */
116   if (result.seconds >= ATTOTIME_MAX_SECONDS)
117      return attotime_never;
118   return result;
119}
120
121
122/*-------------------------------------------------
123    attotime_sub - subtract two attotimes
124-------------------------------------------------*/
125
126attotime attotime_sub(attotime _time1, attotime _time2)
127{
128   attotime result;
129
130   /* if time1 is attotime_never, return attotime_never */
131   if (_time1.seconds >= ATTOTIME_MAX_SECONDS)
132      return attotime_never;
133
134   /* add the seconds and attoseconds */
135   result.attoseconds = _time1.attoseconds - _time2.attoseconds;
136   result.seconds = _time1.seconds - _time2.seconds;
137
138   /* normalize and return */
139   if (result.attoseconds < 0)
140   {
141      result.attoseconds += ATTOSECONDS_PER_SECOND;
142      result.seconds--;
143   }
144   return result;
145}
146
147
148/*-------------------------------------------------
149    attotime_sub_attoseconds - subtract
150    attoseconds from a attotime
151-------------------------------------------------*/
152
153attotime attotime_sub_attoseconds(attotime _time1, attoseconds_t _attoseconds)
154{
155   attotime result;
156
157   /* if time1 is attotime_never, return attotime_never */
158   if (_time1.seconds >= ATTOTIME_MAX_SECONDS)
159      return attotime_never;
160
161   /* add the seconds and attoseconds */
162   result.attoseconds = _time1.attoseconds - _attoseconds;
163   result.seconds = _time1.seconds;
164
165   /* normalize and return */
166   if (result.attoseconds < 0)
167   {
168      result.attoseconds += ATTOSECONDS_PER_SECOND;
169      result.seconds--;
170   }
171   return result;
172}
173
174
175/*-------------------------------------------------
176    attotime_mul - multiply an attotime by
177    a constant
178-------------------------------------------------*/
179
180attotime attotime_mul(attotime _time1, UINT32 factor)
181{
182   INT32 attolo, attohi, reslo, reshi;
183   INT64 temp;
184
185   /* if one of the items is attotime_never, return attotime_never */
186   if (_time1.seconds >= ATTOTIME_MAX_SECONDS)
187      return attotime_never;
188
189   /* 0 times anything is zero */
190   if (factor == 0)
191      return attotime_zero;
192
193   /* split attoseconds into upper and lower halves which fit into 32 bits */
194   attohi = div_64x32_rem(_time1.attoseconds, ATTOSECONDS_PER_SECOND_SQRT, &attolo);
195
196   /* scale the lower half, then split into high/low parts */
197   temp = mul_32x32(attolo, factor);
198   temp = div_64x32_rem(temp, ATTOSECONDS_PER_SECOND_SQRT, &reslo);
199
200   /* scale the upper half, then split into high/low parts */
201   temp += mul_32x32(attohi, factor);
202   temp = div_64x32_rem(temp, ATTOSECONDS_PER_SECOND_SQRT, &reshi);
203
204   /* scale the seconds */
205   temp += mul_32x32(_time1.seconds, factor);
206   if (temp >= ATTOTIME_MAX_SECONDS)
207      return attotime_never;
208
209   /* build the result */
210   return attotime_make(temp, (attoseconds_t)reslo + mul_32x32(reshi, ATTOSECONDS_PER_SECOND_SQRT));
211}
212
213
214/*-------------------------------------------------
215    attotime_div - divide an attotime by
216    a constant
217-------------------------------------------------*/
218
219attotime attotime_div(attotime _time1, UINT32 factor)
220{
221   INT32 attolo, attohi, reshi, reslo, remainder;
222   attotime result;
223   INT64 temp;
224
225   /* if one of the items is attotime_never, return attotime_never */
226   if (_time1.seconds >= ATTOTIME_MAX_SECONDS)
227      return attotime_never;
228
229   /* ignore divide by zero */
230   if (factor == 0)
231      return _time1;
232
233   /* split attoseconds into upper and lower halves which fit into 32 bits */
234   attohi = div_64x32_rem(_time1.attoseconds, ATTOSECONDS_PER_SECOND_SQRT, &attolo);
235
236   /* divide the seconds and get the remainder */
237   result.seconds = div_64x32_rem(_time1.seconds, factor, &remainder);
238
239   /* combine the upper half of attoseconds with the remainder and divide that */
240   temp = (INT64)attohi + mul_32x32(remainder, ATTOSECONDS_PER_SECOND_SQRT);
241   reshi = div_64x32_rem(temp, factor, &remainder);
242
243   /* combine the lower half of attoseconds with the remainder and divide that */
244   temp = attolo + mul_32x32(remainder, ATTOSECONDS_PER_SECOND_SQRT);
245   reslo = div_64x32_rem(temp, factor, &remainder);
246
247   /* round based on the remainder */
248   result.attoseconds = (attoseconds_t)reslo + mul_32x32(reshi, ATTOSECONDS_PER_SECOND_SQRT);
249   if (remainder >= factor / 2)
250      if (++result.attoseconds >= ATTOSECONDS_PER_SECOND)
251      {
252         result.attoseconds = 0;
253         result.seconds++;
254      }
255   return result;
256}
257
258
259/*-------------------------------------------------
260    attotime_compare - compare two attotimes
261-------------------------------------------------*/
262
263int attotime_compare(attotime _time1, attotime _time2)
264{
265   if (_time1.seconds > _time2.seconds)
266      return 1;
267   if (_time1.seconds < _time2.seconds)
268      return -1;
269   if (_time1.attoseconds > _time2.attoseconds)
270      return 1;
271   if (_time1.attoseconds < _time2.attoseconds)
272      return -1;
273   return 0;
274}
275
276
277
278/***************************************************************************
279    MISC UTILITIES
280***************************************************************************/
281
282/*-------------------------------------------------
283    attotime_compare - return a temporary
284    printable string describing an attotime
285-------------------------------------------------*/
286
287const char *attotime_string(attotime _time, int precision)
288{
289   static char buffers[8][30];
290   static int nextbuf;
291   char *buffer = &buffers[nextbuf++ % 8][0];
292
293   /* case 1: we want no precision; seconds only */
294   if (precision == 0)
295      sprintf(buffer, "%d", _time.seconds);
296
297   /* case 2: we want 9 or fewer digits of precision */
298   else if (precision <= 9)
299   {
300      INT32 upper = _time.attoseconds / ATTOSECONDS_PER_SECOND_SQRT;
301      sprintf(buffer, "%d.%0*d", _time.seconds, precision, upper);
302   }
303
304   /* case 3: more than 9 digits of precision */
305   else
306   {
307      INT32 lower;
308      INT32 upper = div_64x32_rem(_time.attoseconds, ATTOSECONDS_PER_SECOND_SQRT, &lower);
309      sprintf(buffer, "%d.%09d%0*d", _time.seconds, upper, precision - 9, lower);
310   }
311   return buffer;
312}
src/emu/cpuintrf.c
r1293r1294
9696void tms32025_get_info(UINT32 state, cpuinfo *info);
9797void tms32026_get_info(UINT32 state, cpuinfo *info);
9898void tms32031_get_info(UINT32 state, cpuinfo *info);
99void tms32032_get_info(UINT32 state, cpuinfo *info);
99100void tms32051_get_info(UINT32 state, cpuinfo *info);
100101void ccpu_get_info(UINT32 state, cpuinfo *info);
101102void adsp2100_get_info(UINT32 state, cpuinfo *info);
r1293r1294
496497#if (HAS_TMS32031)
497498   { CPU_TMS32031, tms32031_get_info },
498499#endif
500#if (HAS_TMS32032)
501   { CPU_TMS32032, tms32032_get_info },
502#endif
499503#if (HAS_TMS32051)
500504   { CPU_TMS32051, tms32051_get_info },
501505#endif
src/emu/attotime.h
r0r1294
1/***************************************************************************
2
3    attotime.h
4
5    Support functions for working with attotime data.
6
7    Copyright (c) 1996-2007, Nicola Salmoria and the MAME Team.
8    Visit http://mamedev.org for licensing and usage restrictions.
9
10****************************************************************************
11
12    Attotime is an attosecond-accurate timing system implemented as
13    96-bit integers.
14
15        1 second      = 1e0 seconds
16        1 millisecond = 1e-3 seconds
17        1 microsecond = 1e-6 seconds
18        1 nanosecond  = 1e-9 seconds
19        1 picosecond  = 1e-12 seconds
20        1 femtosecond = 1e-15 seconds
21        1 attosecond  = 1e-18 seconds
22
23    This may seem insanely accurate, but it has its uses when multiple
24    clocks in the system are run by independent crystals. It is also
25    useful to compute the attotime for something small, say 1 clock tick,
26    and still have it be accurate and useful for scaling.
27
28    Attotime consists of a 32-bit seconds count and a 64-bit attoseconds
29    count. Because the lower bits are kept as attoseconds and not as a
30    full 64-bit value, there is headroom to make some operations simpler.
31
32***************************************************************************/
33
34#pragma once
35
36#ifndef __ATTOTIME_H__
37#define __ATTOTIME_H__
38
39#include "mamecore.h"
40#include <math.h>
41
42
43/***************************************************************************
44    CONSTANTS
45***************************************************************************/
46
47#define ATTOSECONDS_PER_SECOND_SQRT      ((attoseconds_t)1000000000)
48#define ATTOSECONDS_PER_SECOND         (ATTOSECONDS_PER_SECOND_SQRT * ATTOSECONDS_PER_SECOND_SQRT)
49#define ATTOSECONDS_PER_MILLISECOND      (ATTOSECONDS_PER_SECOND / 1000)
50#define ATTOSECONDS_PER_MICROSECOND      (ATTOSECONDS_PER_SECOND / 1000000)
51#define ATTOSECONDS_PER_NANOSECOND      (ATTOSECONDS_PER_SECOND / 1000000000)
52
53#define ATTOTIME_MAX_SECONDS         ((seconds_t)1000000000)
54
55
56
57/***************************************************************************
58    MACROS
59***************************************************************************/
60
61/* convert between a double and attoseconds */
62#define ATTOSECONDS_TO_DOUBLE(x)      ((double)(x) * 1e-18)
63#define DOUBLE_TO_ATTOSECONDS(x)      ((attoseconds_t)((x) * 1e18))
64
65/* convert between hertz (as a double) and attoseconds */
66#define ATTOSECONDS_TO_HZ(x)         ((double)ATTOSECONDS_PER_SECOND / (double)(x))
67#define HZ_TO_ATTOSECONDS(x)         ((attoseconds_t)(ATTOSECONDS_PER_SECOND / (x)))
68
69/* macros for converting other seconds types to attoseconds */
70#define ATTOSECONDS_IN_SEC(x)         ((x) * ATTOSECONDS_PER_SECOND)
71#define ATTOSECONDS_IN_MSEC(x)         ((x) * ATTOSECONDS_PER_MILLISECOND)
72#define ATTOSECONDS_IN_USEC(x)         ((x) * ATTOSECONDS_PER_MICROSECOND)
73#define ATTOSECONDS_IN_NSEC(x)         ((x) * ATTOSECONDS_PER_NANOSECOND)
74
75/* macros for building attotimes from other types at runtime */
76#define ATTOTIME_IN_HZ(hz)            attotime_make(0, HZ_TO_ATTOSECONDS(hz))
77#define ATTOTIME_IN_SEC(s)            attotime_make((s)  / 1, (s) % 1 /* mod here errors on doubles, which is intended */)
78#define ATTOTIME_IN_MSEC(ms)         attotime_make((ms) / 1000, ATTOSECONDS_IN_MSEC((ms) % 1000))
79#define ATTOTIME_IN_USEC(us)         attotime_make((us) / 1000000, ATTOSECONDS_IN_USEC((us) % 1000000))
80#define ATTOTIME_IN_NSEC(ns)         attotime_make((ns) / 1000000000, ATTOSECONDS_IN_NSEC((ns) % 1000000000))
81
82/* macros for building attotimes from other types at compile time */
83#define STATIC_ATTOTIME_IN_HZ(hz)      { 0, HZ_TO_ATTOSECONDS(hz) }
84#define STATIC_ATTOTIME_IN_SEC(s)      { (s)  / 1, (s) % 1 /* mod here errors on doubles, which is intended */ }
85#define STATIC_ATTOTIME_IN_MSEC(ms)      { (ms) / 1000, ATTOSECONDS_IN_MSEC((ms) % 1000) }
86#define STATIC_ATTOTIME_IN_USEC(us)      { (us) / 1000000, ATTOSECONDS_IN_USEC((us) % 1000000) }
87#define STATIC_ATTOTIME_IN_NSEC(ns)      { (ns) / 1000000000, ATTOSECONDS_IN_NSEC((ns) % 1000000000) }
88
89
90#define USEC_TO_ATTOSECONDS(us)         ((attoseconds_t)((us) * ATTOSECONDS_PER_MICROSECOND))
91
92
93
94/***************************************************************************
95    TYPE DEFINITIONS
96***************************************************************************/
97
98/* core components of the attotime structure */
99typedef INT64 attoseconds_t;
100typedef INT32 seconds_t;
101
102
103/* the attotime structure itself */
104typedef struct _attotime attotime;
105struct _attotime
106{
107   seconds_t      seconds;
108   attoseconds_t   attoseconds;
109};
110
111
112
113/***************************************************************************
114    GLOBAL VARIABLES
115***************************************************************************/
116
117/* constant times for zero and never */
118extern const attotime       attotime_zero;
119extern const attotime       attotime_never;
120
121
122
123/***************************************************************************
124    FUNCTION PROTOTYPES
125***************************************************************************/
126
127/* ----- conversion helpers ----- */
128
129/* convert an attotime to attoseconds, clamping to maximum positive/negative values */
130attoseconds_t attotime_to_attoseconds(attotime _time);
131
132
133/* ----- core math functions ----- */
134
135/* add two attotimes */
136attotime attotime_add(attotime _time1, attotime _time2);
137
138/* add attoseconds to an attotime */
139attotime attotime_add_attoseconds(attotime _time1, attoseconds_t _attoseconds);
140
141/* subtract two attotimes */
142attotime attotime_sub(attotime _time1, attotime _time2);
143
144/* subtract attoseconds from an attotime */
145attotime attotime_sub_attoseconds(attotime _time1, attoseconds_t _attoseconds);
146
147/* multiply an attotime by a constant */
148attotime attotime_mul(attotime _time1, UINT32 factor);
149
150/* divide an attotime by a constant */
151attotime attotime_div(attotime _time1, UINT32 factor);
152
153/* compare two attotimes */
154int attotime_compare(attotime _time1, attotime _time2);
155
156
157/* ----- misc utilities ----- */
158
159/* return a temporary printable string describing an attotime */
160const char *attotime_string(attotime _time, int precision);
161
162
163
164/***************************************************************************
165    INLINE FUNCTIONS
166***************************************************************************/
167
168/*-------------------------------------------------
169    attotime_make - assemble an attotime from
170    seconds and attoseconds components
171-------------------------------------------------*/
172
173INLINE attotime attotime_make(seconds_t _secs, attoseconds_t _subsecs)
174{
175   attotime result;
176   result.seconds = _secs;
177   result.attoseconds = _subsecs;
178   return result;
179}
180
181
182/*-------------------------------------------------
183    attotime_to_double - convert from attotime
184    to double
185-------------------------------------------------*/
186
187INLINE double attotime_to_double(attotime _time)
188{
189   return (double)_time.seconds + ATTOSECONDS_TO_DOUBLE(_time.attoseconds);
190}
191
192
193/*-------------------------------------------------
194    double_to_attotime - convert from double to
195    attotime
196-------------------------------------------------*/
197
198INLINE attotime double_to_attotime(double _time)
199{
200   attotime result;
201
202   /* set seconds to the integral part */
203   result.seconds = floor(_time);
204
205   /* set attoseconds to the fractional part */
206   _time -= (double)result.seconds;
207   result.attoseconds = DOUBLE_TO_ATTOSECONDS(_time);
208   return result;
209}
210
211
212#endif   /* __ATTOTIME_H__ */
src/emu/cpuexec.c
r1293r1294
9292   INT32    iloops;             /* number of interrupts remaining this frame */
9393
9494   UINT64    totalcycles;         /* total CPU cycles executed */
95   mame_time localtime;         /* local time, relative to the timer system's global time */
95   attotime localtime;         /* local time, relative to the timer system's global time */
9696   INT32   clock;               /* current active clock */
9797   double   clockscale;            /* current active clock scale factor */
9898
r1293r1294
101101   void *   vblankint_timer;      /* reference to elapsed time counter */
102102
103103   void *   timedint_timer;         /* reference to this CPU's timer */
104   mame_time timedint_period;       /* timing period of the timed interrupt */
104   attotime timedint_period;       /* timing period of the timed interrupt */
105105};
106106
107107
r1293r1294
129129 *
130130 *************************************/
131131
132static mame_timer *vblank_timer;
132static emu_timer *vblank_timer;
133133static INT32 vblank_countdown;
134134static INT32 vblank_multiplier;
135static mame_time vblank_period;
135static attotime vblank_period;
136136
137static mame_timer *update_timer;
137static emu_timer *update_timer;
138138
139mame_timer *refresh_timer;   /* temporarily made non-static (for ccpu) */
140static mame_time refresh_period;
139emu_timer *refresh_timer;   /* temporarily made non-static (for ccpu) */
140static attotime refresh_period;
141141
142static mame_timer *timeslice_timer;
143static mame_time timeslice_period;
142static emu_timer *timeslice_timer;
143static attotime timeslice_period;
144144
145static mame_timer *interleave_boost_timer;
146static mame_timer *interleave_boost_timer_end;
147static mame_time perfect_interleave;
145static emu_timer *interleave_boost_timer;
146static emu_timer *interleave_boost_timer_end;
147static attotime perfect_interleave;
148148
149static mame_timer *watchdog_timer;
149static emu_timer *watchdog_timer;
150150
151151
152152
r1293r1294
202202      machine->screen[0].vblank = (machine->screen[0].refresh / machine->screen[0].height) * (machine->screen[0].height - (machine->screen[0].visarea.max_y + 1 - machine->screen[0].visarea.min_y));
203203
204204   /* allocate vblank and refresh timers, and compute the initial timing */
205   vblank_timer = mame_timer_alloc(cpu_vblankcallback);
206   refresh_timer = mame_timer_alloc(NULL);
205   vblank_timer = timer_alloc(cpu_vblankcallback);
206   refresh_timer = timer_alloc(NULL);
207207   cpu_compute_vblank_timing();
208208
209209   /* loop over all our CPUs */
r1293r1294
221221      cpu[cpunum].suspend = SUSPEND_REASON_RESET;
222222      cpu[cpunum].clock = machine->drv->cpu[cpunum].clock;
223223      cpu[cpunum].clockscale = 1.0;
224      cpu[cpunum].localtime = time_zero;
224      cpu[cpunum].localtime = attotime_zero;
225225
226226      /* compute the cycle times */
227227      cycles_per_second[cpunum] = cpu[cpunum].clockscale * cpu[cpunum].clock;
228      subseconds_per_cycle[cpunum] = MAX_SUBSECONDS / (cpu[cpunum].clockscale * cpu[cpunum].clock);
228      attoseconds_per_cycle[cpunum] = ATTOSECONDS_PER_SECOND / (cpu[cpunum].clockscale * cpu[cpunum].clock);
229229
230230      /* register some of our variables for later */
231231      state_save_register_item("cpu", cpunum, cpu[cpunum].suspend);
r1293r1294
238238
239239      state_save_register_item("cpu", cpunum, cpu[cpunum].totalcycles);
240240      state_save_register_item("cpu", cpunum, cpu[cpunum].localtime.seconds);
241      state_save_register_item("cpu", cpunum, cpu[cpunum].localtime.subseconds);
241      state_save_register_item("cpu", cpunum, cpu[cpunum].localtime.attoseconds);
242242      state_save_register_item("cpu", cpunum, cpu[cpunum].clock);
243243      state_save_register_item("cpu", cpunum, cpu[cpunum].clockscale);
244244
r1293r1294
368368         /* Start a vblank based watchdog. */
369369         watchdog_counter = Machine->drv->watchdog_vblank_count;
370370      }
371      else if (compare_mame_times(Machine->drv->watchdog_time, time_zero) != 0)
371      else if (attotime_compare(Machine->drv->watchdog_time, attotime_zero) != 0)
372372      {
373373         /* Start a time based watchdog. */
374374         if (alloc_new)
375            watchdog_timer = mame_timer_alloc(watchdog_callback);
376         mame_timer_adjust(watchdog_timer, Machine->drv->watchdog_time, 0, time_zero);
375            watchdog_timer = timer_alloc(watchdog_callback);
376         timer_adjust(watchdog_timer, Machine->drv->watchdog_time, 0, attotime_zero);
377377         watchdog_counter = WATCHDOG_IS_TIMER_BASED;
378378      }
379379      else if (watchdog_counter == WATCHDOG_IS_INVALID)
r1293r1294
394394             * The 3 seconds delay is targeted at qzshowby, which otherwise
395395             * would reset at the start of a game.
396396             */
397         watchdog_counter = 3 * SUBSECONDS_TO_HZ(Machine->screen[0].refresh);
397         watchdog_counter = 3 * ATTOSECONDS_TO_HZ(Machine->screen[0].refresh);
398398      }
399399   }
400400}
r1293r1294
411411{
412412   if (watchdog_counter == WATCHDOG_IS_TIMER_BASED)
413413   {
414      mame_timer_reset(watchdog_timer, Machine->drv->watchdog_time);
414      timer_reset(watchdog_timer, Machine->drv->watchdog_time);
415415   }
416416   else
417417   {
r1293r1294
466466
467467void cpuexec_timeslice(void)
468468{
469   mame_time target = mame_timer_next_fire_time();
470   mame_time base = mame_timer_get_time();
469   attotime target = timer_next_fire_time();
470   attotime base = timer_get_time();
471471   int cpunum, ran;
472472
473473   LOG(("------------------\n"));
474   LOG(("cpu_timeslice: target = %.9f\n", mame_time_to_double(target)));
474   LOG(("cpu_timeslice: target = %s\n", attotime_string(target, 9)));
475475
476476   /* process any pending suspends */
477477   for (cpunum = 0; Machine->drv->cpu[cpunum].type != CPU_DUMMY; cpunum++)
r1293r1294
489489      if (!cpu[cpunum].suspend)
490490      {
491491         /* compute how long to run */
492         cycles_running = MAME_TIME_TO_CYCLES(cpunum, sub_mame_times(target, cpu[cpunum].localtime));
492         cycles_running = ATTOTIME_TO_CYCLES(cpunum, attotime_sub(target, cpu[cpunum].localtime));
493493         LOG(("  cpu %d: %d cycles\n", cpunum, cycles_running));
494494
495495         /* run for the requested number of cycles */
r1293r1294
512512
513513            /* account for these cycles */
514514            cpu[cpunum].totalcycles += ran;
515            cpu[cpunum].localtime = add_mame_times(cpu[cpunum].localtime, MAME_TIME_IN_CYCLES(ran, cpunum));
516            LOG(("         %d ran, %d total, time = %.9f\n", ran, (INT32)cpu[cpunum].totalcycles, mame_time_to_double(cpu[cpunum].localtime)));
515            cpu[cpunum].localtime = attotime_add(cpu[cpunum].localtime, ATTOTIME_IN_CYCLES(ran, cpunum));
516            LOG(("         %d ran, %d total, time = %s\n", ran, (INT32)cpu[cpunum].totalcycles, attotime_string(cpu[cpunum].localtime, 9)));
517517
518518            /* if the new local CPU time is less than our target, move the target up */
519            if (compare_mame_times(cpu[cpunum].localtime, target) < 0)
519            if (attotime_compare(cpu[cpunum].localtime, target) < 0)
520520            {
521               if (compare_mame_times(cpu[cpunum].localtime, base) > 0)
521               if (attotime_compare(cpu[cpunum].localtime, base) > 0)
522522                  target = cpu[cpunum].localtime;
523523               else
524524                  target = base;
r1293r1294
532532   for (cpunum = 0; Machine->drv->cpu[cpunum].type != CPU_DUMMY; cpunum++)
533533   {
534534      /* if we're suspended and counting, process */
535      if (cpu[cpunum].suspend && cpu[cpunum].eatcycles && compare_mame_times(cpu[cpunum].localtime, target) < 0)
535      if (cpu[cpunum].suspend && cpu[cpunum].eatcycles && attotime_compare(cpu[cpunum].localtime, target) < 0)
536536      {
537537         /* compute how long to run */
538         cycles_running = MAME_TIME_TO_CYCLES(cpunum, sub_mame_times(target, cpu[cpunum].localtime));
538         cycles_running = ATTOTIME_TO_CYCLES(cpunum, attotime_sub(target, cpu[cpunum].localtime));
539539         LOG(("  cpu %d: %d cycles (suspended)\n", cpunum, cycles_running));
540540
541541         cpu[cpunum].totalcycles += cycles_running;
542         cpu[cpunum].localtime = add_mame_times(cpu[cpunum].localtime, MAME_TIME_IN_CYCLES(cycles_running, cpunum));
543         LOG(("         %d skipped, %d total, time = %.9f\n", cycles_running, (INT32)cpu[cpunum].totalcycles, mame_time_to_double(cpu[cpunum].localtime)));
542         cpu[cpunum].localtime = attotime_add(cpu[cpunum].localtime, ATTOTIME_IN_CYCLES(cycles_running, cpunum));
543         LOG(("         %d skipped, %d total, time = %s\n", cycles_running, (INT32)cpu[cpunum].totalcycles, attotime_string(cpu[cpunum].localtime, 9)));
544544      }
545545
546546      /* update the suspend state */
r1293r1294
551551   }
552552
553553   /* update the global time */
554   mame_timer_set_global_time(target);
554   timer_set_global_time(target);
555555}
556556
557557
r1293r1294
587587 *
588588 *************************************/
589589
590mame_time cpunum_get_localtime(int cpunum)
590attotime cpunum_get_localtime(int cpunum)
591591{
592   mame_time result;
592   attotime result;
593593
594594   VERIFY_CPUNUM(cpunum_get_localtime);
595595
r1293r1294
598598   if (cpunum == cpu_getexecutingcpu())
599599   {
600600      int cycles = cycles_currently_ran();
601      result = add_mame_times(result, MAME_TIME_IN_CYCLES(cycles, cpunum));
601      result = attotime_add(result, ATTOTIME_IN_CYCLES(cycles, cpunum));
602602   }
603603   return result;
604604}
r1293r1294
687687
688688   cpu[cpunum].clock = clock;
689689   cycles_per_second[cpunum] = (double)clock * cpu[cpunum].clockscale;
690   subseconds_per_cycle[cpunum] = MAX_SUBSECONDS / ((double)clock * cpu[cpunum].clockscale);
690   attoseconds_per_cycle[cpunum] = ATTOSECONDS_PER_SECOND / ((double)clock * cpu[cpunum].clockscale);
691691
692692   /* re-compute the perfect interleave factor */
693693   compute_perfect_interleave();
r1293r1294
695695
696696
697697
698void cpunum_set_clock_period(int cpunum, subseconds_t clock_period)
698void cpunum_set_clock_period(int cpunum, attoseconds_t clock_period)
699699{
700700   VERIFY_CPUNUM(cpunum_set_clock);
701701
702   cpu[cpunum].clock = MAX_SUBSECONDS / clock_period;
703   cycles_per_second[cpunum] = (double) (MAX_SUBSECONDS / clock_period) * cpu[cpunum].clockscale;
704   subseconds_per_cycle[cpunum] = clock_period;
702   cpu[cpunum].clock = ATTOSECONDS_PER_SECOND / clock_period;
703   cycles_per_second[cpunum] = (double) (ATTOSECONDS_PER_SECOND / clock_period) * cpu[cpunum].clockscale;
704   attoseconds_per_cycle[cpunum] = clock_period;
705705
706706   /* re-compute the perfect interleave factor */
707707   compute_perfect_interleave();
r1293r1294
737737
738738   cpu[cpunum].clockscale = clockscale;
739739   cycles_per_second[cpunum] = (double)cpu[cpunum].clock * clockscale;
740   subseconds_per_cycle[cpunum] = MAX_SUBSECONDS / ((double)cpu[cpunum].clock * clockscale);
740   attoseconds_per_cycle[cpunum] = ATTOSECONDS_PER_SECOND / ((double)cpu[cpunum].clock * clockscale);
741741
742742   /* re-compute the perfect interleave factor */
743743   compute_perfect_interleave();
r1293r1294
752752 *
753753 *************************************/
754754
755void cpu_boost_interleave(mame_time timeslice_time, mame_time boost_duration)
755void cpu_boost_interleave(attotime timeslice_time, attotime boost_duration)
756756{
757757   /* if you pass 0 for the timeslice_time, it means pick something reasonable */
758   if (compare_mame_times(timeslice_time, perfect_interleave) < 0)
758   if (attotime_compare(timeslice_time, perfect_interleave) < 0)
759759      timeslice_time = perfect_interleave;
760760
761   LOG(("cpu_boost_interleave(%.9f, %.9f)\n", mame_time_to_double(timeslice_time), mame_time_to_double(boost_duration)));
761   LOG(("cpu_boost_interleave(%s, %s)\n", attotime_string(timeslice_time, 9), attotime_string(boost_duration, 9)));
762762
763763   /* adjust the interleave timer */
764   mame_timer_adjust(interleave_boost_timer, timeslice_time, 0, timeslice_time);
764   timer_adjust(interleave_boost_timer, timeslice_time, 0, timeslice_time);
765765
766766   /* adjust the end timer, but only if we are going to extend it */
767   if (!mame_timer_enabled(interleave_boost_timer_end) || compare_mame_times(mame_timer_timeleft(interleave_boost_timer_end), boost_duration) < 0)
768      mame_timer_adjust(interleave_boost_timer_end, boost_duration, 0, time_never);
767   if (!timer_enabled(interleave_boost_timer_end) || attotime_compare(timer_timeleft(interleave_boost_timer_end), boost_duration) < 0)
768      timer_adjust(interleave_boost_timer_end, boost_duration, 0, attotime_never);
769769}
770770
771771
r1293r1294
875875
876876int cpu_scalebyfcount(int value)
877877{
878   mame_time refresh_elapsed = mame_timer_timeelapsed(refresh_timer);
878   attotime refresh_elapsed = timer_timeelapsed(refresh_timer);
879879   int result;
880880
881881   /* shift off some bits to ensure no overflow */
882882   if (value < 65536)
883      result = value * (refresh_elapsed.subseconds >> 16) / (refresh_period.subseconds >> 16);
883      result = value * (refresh_elapsed.attoseconds >> 16) / (refresh_period.attoseconds >> 16);
884884   else
885      result = value * (refresh_elapsed.subseconds >> 32) / (refresh_period.subseconds >> 32);
885      result = value * (refresh_elapsed.attoseconds >> 32) / (refresh_period.attoseconds >> 32);
886886   if (value >= 0)
887887      return (result < value) ? result : value;
888888   else
r1293r1294
904904
905905void cpu_compute_vblank_timing(void)
906906{
907   refresh_period = make_mame_time(0, Machine->screen[0].refresh);
907   refresh_period = attotime_make(0, Machine->screen[0].refresh);
908908
909909   /* recompute the vblank period */
910   vblank_period = make_mame_time(0, Machine->screen[0].refresh / (vblank_multiplier ? vblank_multiplier : 1));
911   if (vblank_timer != NULL && mame_timer_enable(vblank_timer, FALSE))
910   vblank_period = attotime_make(0, Machine->screen[0].refresh / (vblank_multiplier ? vblank_multiplier : 1));
911   if (vblank_timer != NULL && timer_enable(vblank_timer, FALSE))
912912   {
913      mame_time remaining = mame_timer_timeleft(vblank_timer);
914      if (remaining.seconds == 0 && remaining.subseconds == 0)
913      attotime remaining = timer_timeleft(vblank_timer);
914      if (remaining.seconds == 0 && remaining.attoseconds == 0)
915915         remaining = vblank_period;
916      mame_timer_adjust(vblank_timer, remaining, 0, vblank_period);
916      timer_adjust(vblank_timer, remaining, 0, vblank_period);
917917   }
918918
919   LOG(("cpu_compute_vblank_timing: refresh=%.9f vblank=%.9f\n", mame_time_to_double(refresh_period), mame_time_to_double(vblank_period)));
919   LOG(("cpu_compute_vblank_timing: refresh=%s vblank=%s\n", attotime_string(refresh_period, 9), attotime_string(vblank_period, 9)));
920920}
921921
922922
r1293r1294
996996}
997997
998998
999void cpu_triggertime(mame_time duration, int trigger)
999void cpu_triggertime(attotime duration, int trigger)
10001000{
1001   mame_timer_set(duration, trigger, cpu_triggertime_callback);
1001   timer_set(duration, trigger, cpu_triggertime_callback);
10021002}
10031003
10041004
r1293r1294
11101110 *
11111111 *************************************/
11121112
1113void cpu_spinuntil_time(mame_time duration)
1113void cpu_spinuntil_time(attotime duration)
11141114{
11151115   static int timetrig = 0;
11161116
r1293r1294
11201120}
11211121
11221122
1123void cpu_yielduntil_time(mame_time duration)
1123void cpu_yielduntil_time(attotime duration)
11241124{
11251125   static int timetrig = 0;
11261126
r1293r1294
12101210static TIMER_CALLBACK( cpu_firstvblankcallback )
12111211{
12121212   /* now that we're synced up, pulse from here on out */
1213   mame_timer_adjust(vblank_timer, vblank_period, param, vblank_period);
1213   timer_adjust(vblank_timer, vblank_period, param, vblank_period);
12141214
12151215   /* but we need to call the standard routine as well */
12161216   cpu_vblankcallback(machine, param);
r1293r1294
12571257
12581258            /* reset the countdown and timer */
12591259            cpu[cpunum].vblankint_countdown = cpu[cpunum].vblankint_multiplier;
1260            mame_timer_adjust(cpu[cpunum].vblankint_timer, time_never, 0, time_never);
1260            timer_adjust(cpu[cpunum].vblankint_timer, attotime_never, 0, attotime_never);
12611261         }
12621262      }
12631263
12641264      /* else reset the VBLANK timer if this is going to be a real VBLANK */
12651265      else if (vblank_countdown == 1)
1266         mame_timer_adjust(cpu[cpunum].vblankint_timer, time_never, 0, time_never);
1266         timer_adjust(cpu[cpunum].vblankint_timer, attotime_never, 0, attotime_never);
12671267   }
12681268
12691269   /* is it a real VBLANK? */
r1293r1294
12741274         video_frame_update();
12751275
12761276      /* Set the timer to update the screen */
1277      mame_timer_adjust(update_timer, make_mame_time(0, machine->screen[0].vblank), 0, time_zero);
1277      timer_adjust(update_timer, attotime_make(0, machine->screen[0].vblank), 0, attotime_zero);
12781278
12791279      /* reset the globals */
12801280      cpu_vblankreset();
r1293r1294
13111311   current_frame++;
13121312
13131313   /* reset the refresh timer */
1314   mame_timer_adjust(refresh_timer, time_never, 0, time_never);
1314   timer_adjust(refresh_timer, attotime_never, 0, attotime_never);
13151315}
13161316
13171317
r1293r1294
13581358
13591359static TIMER_CALLBACK( end_interleave_boost )
13601360{
1361   mame_timer_adjust(interleave_boost_timer, time_never, 0, time_never);
1361   timer_adjust(interleave_boost_timer, attotime_never, 0, attotime_never);
13621362   LOG(("end_interleave_boost\n"));
13631363}
13641364
r1293r1294
13731373
13741374static void compute_perfect_interleave(void)
13751375{
1376   subseconds_t smallest = subseconds_per_cycle[0];
1376   attoseconds_t smallest = attoseconds_per_cycle[0];
13771377   int cpunum;
13781378
13791379   /* start with a huge time factor and find the 2nd smallest cycle time */
1380   perfect_interleave = time_zero;
1381   perfect_interleave.subseconds = MAX_SUBSECONDS - 1;
1380   perfect_interleave = attotime_zero;
1381   perfect_interleave.attoseconds = ATTOSECONDS_PER_SECOND - 1;
13821382   for (cpunum = 1; Machine->drv->cpu[cpunum].type != CPU_DUMMY; cpunum++)
13831383   {
13841384      /* find the 2nd smallest cycle interval */
1385      if (subseconds_per_cycle[cpunum] < smallest)
1385      if (attoseconds_per_cycle[cpunum] < smallest)
13861386      {
1387         perfect_interleave.subseconds = smallest;
1388         smallest = subseconds_per_cycle[cpunum];
1387         perfect_interleave.attoseconds = smallest;
1388         smallest = attoseconds_per_cycle[cpunum];
13891389      }
1390      else if (subseconds_per_cycle[cpunum] < perfect_interleave.subseconds)
1391         perfect_interleave.subseconds = subseconds_per_cycle[cpunum];
1390      else if (attoseconds_per_cycle[cpunum] < perfect_interleave.attoseconds)
1391         perfect_interleave.attoseconds = attoseconds_per_cycle[cpunum];
13921392   }
13931393
13941394   /* adjust the final value */
1395   if (perfect_interleave.subseconds == MAX_SUBSECONDS - 1)
1396      perfect_interleave.subseconds = subseconds_per_cycle[0];
1395   if (perfect_interleave.attoseconds == ATTOSECONDS_PER_SECOND - 1)
1396      perfect_interleave.attoseconds = attoseconds_per_cycle[0];
13971397
1398   LOG(("Perfect interleave = %.9f, smallest = %.9f\n", mame_time_to_double(perfect_interleave), SUBSECONDS_TO_DOUBLE(smallest)));
1398   LOG(("Perfect interleave = %s, smallest = %.9f\n", attotime_string(perfect_interleave), ATTOSECONDS_TO_DOUBLE(smallest)));
13991399}
14001400
14011401
r1293r1294
14081408
14091409static void cpu_inittimers(running_machine *machine)
14101410{
1411   mame_time first_time;
1411   attotime first_time;
14121412   int cpunum, max, ipf;
14131413
14141414   /* allocate a dummy timer at the minimum frequency to break things up */
14151415   ipf = machine->drv->cpu_slices_per_frame;
14161416   if (ipf <= 0)
14171417      ipf = 1;
1418   timeslice_period = make_mame_time(0, machine->screen[0].refresh / ipf);
1419   timeslice_timer = mame_timer_alloc(cpu_timeslicecallback);
1420   mame_timer_adjust(timeslice_timer, timeslice_period, 0, timeslice_period);
1418   timeslice_period = attotime_make(0, machine->screen[0].refresh / ipf);
1419   timeslice_timer = timer_alloc(cpu_timeslicecallback);
1420   timer_adjust(timeslice_timer, timeslice_period, 0, timeslice_period);
14211421
14221422   /* allocate timers to handle interleave boosts */
1423   interleave_boost_timer = mame_timer_alloc(NULL);
1424   interleave_boost_timer_end = mame_timer_alloc(end_interleave_boost);
1423   interleave_boost_timer = timer_alloc(NULL);
1424   interleave_boost_timer_end = timer_alloc(end_interleave_boost);
14251425
14261426   /*
14271427     *  The following code finds all the CPUs that are interrupting in sync with the VBLANK
r1293r1294
14641464   }
14651465
14661466   /* allocate a vblank timer at the frame rate * the LCD number of interrupts per frame */
1467   vblank_period = make_mame_time(0, machine->screen[0].refresh / vblank_multiplier);
1467   vblank_period = attotime_make(0, machine->screen[0].refresh / vblank_multiplier);
14681468   vblank_countdown = vblank_multiplier;
14691469
14701470   /* allocate an update timer that will be used to time the actual screen updates */
1471   update_timer = mame_timer_alloc(cpu_updatecallback);
1471   update_timer = timer_alloc(cpu_updatecallback);
14721472
14731473   /*
14741474     *      The following code creates individual timers for each CPU whose interrupts are not
r1293r1294
14831483      /* compute the average number of cycles per interrupt */
14841484      if (ipf <= 0)
14851485         ipf = 1;
1486      cpu[cpunum].vblankint_timer = mame_timer_alloc(NULL);
1486      cpu[cpunum].vblankint_timer = timer_alloc(NULL);
14871487
14881488      /* see if we need to allocate a CPU timer */
14891489      if (machine->drv->cpu[cpunum].timed_interrupt_period != 0)
14901490      {
1491         cpu[cpunum].timedint_period = make_mame_time(0, machine->drv->cpu[cpunum].timed_interrupt_period);
1492         cpu[cpunum].timedint_timer = mame_timer_alloc(cpu_timedintcallback);
1493         mame_timer_adjust(cpu[cpunum].timedint_timer, cpu[cpunum].timedint_period, cpunum, cpu[cpunum].timedint_period);
1491         cpu[cpunum].timedint_period = attotime_make(0, machine->drv->cpu[cpunum].timed_interrupt_period);
1492         cpu[cpunum].timedint_timer = timer_alloc(cpu_timedintcallback);
1493         timer_adjust(cpu[cpunum].timedint_timer, cpu[cpunum].timedint_period, cpunum, cpu[cpunum].timedint_period);
14941494      }
14951495   }
14961496
14971497   /* note that since we start the first frame on the refresh, we can't pulse starting
14981498       immediately; instead, we back up one VBLANK period, and inch forward until we hit
14991499       positive time. That time will be the time of the first VBLANK timer callback */
1500   first_time = sub_subseconds_from_mame_time(vblank_period, machine->screen[0].vblank);
1501   while (compare_mame_times(first_time, time_zero) < 0)
1500   first_time = attotime_sub_attoseconds(vblank_period, machine->screen[0].vblank);
1501   while (attotime_compare(first_time, attotime_zero) < 0)
15021502   {
15031503      cpu_vblankcallback(machine, -1);
1504      first_time = add_mame_times(first_time, vblank_period);
1504      first_time = attotime_add(first_time, vblank_period);
15051505   }
1506   mame_timer_set(first_time, 0, cpu_firstvblankcallback);
1506   timer_set(first_time, 0, cpu_firstvblankcallback);
15071507
15081508   /* reset the refresh timer to get ourself back in sync */
1509   mame_timer_adjust(refresh_timer, time_never, 0, time_never);
1509   timer_adjust(refresh_timer, attotime_never, 0, attotime_never);
15101510}
15111511
src/emu/cpuexec.h
r1293r1294
100100   CPU_TMS32025,
101101   CPU_TMS32026,
102102   CPU_TMS32031,
103   CPU_TMS32032,
103104   CPU_TMS32051,
104105   CPU_CCPU,
105106   CPU_ADSP2100,
r1293r1294
224225   void       (*vblank_interrupt)(void);   /* for interrupts tied to VBLANK */
225226   int       vblank_interrupts_per_frame;/* usually 1 */
226227   void       (*timed_interrupt)(void);   /* for interrupts not tied to VBLANK */
227   subseconds_t timed_interrupt_period;   /* period for periodic interrupts */
228   attoseconds_t timed_interrupt_period;   /* period for periodic interrupts */
228229   void *      reset_param;            /* parameter for cpu_reset */
229230   const char *tag;
230231};
r1293r1294
306307void activecpu_abort_timeslice(void);
307308
308309/* Returns the current local time for a CPU */
309mame_time cpunum_get_localtime(int cpunum);
310attotime cpunum_get_localtime(int cpunum);
310311
311312/* Returns the current CPU's unscaled running clock speed */
312313/* If you want to know the current effective running clock
r1293r1294
315316
316317/* Sets the current CPU's clock speed and then adjusts for scaling */
317318void cpunum_set_clock(int cpunum, int clock);
318void cpunum_set_clock_period(int cpunum, subseconds_t clock_period);
319void cpunum_set_clock_period(int cpunum, attoseconds_t clock_period);
319320
320321/* Returns the current scaling factor for a CPU's clock speed */
321322double cpunum_get_clockscale(int cpunum);
r1293r1294
324325void cpunum_set_clockscale(int cpunum, double clockscale);
325326
326327/* Temporarily boosts the interleave factor */
327void cpu_boost_interleave(mame_time timeslice_time, mame_time boost_duration);
328void cpu_boost_interleave(attotime timeslice_time, attotime boost_duration);
328329
329330
330331
r1293r1294
382383void cpu_trigger(int trigger);
383384
384385/* generate a trigger after a specific period of time */
385void cpu_triggertime(mame_time duration, int trigger);
386void cpu_triggertime(attotime duration, int trigger);
386387
387388/* generate a trigger corresponding to an interrupt on the given CPU */
388389void cpu_triggerint(int cpunum);
r1293r1294
409410void cpu_yield(void);
410411
411412/* burn CPU cycles for a specific period of time */
412void cpu_spinuntil_time(mame_time duration);
413void cpu_spinuntil_time(attotime duration);
413414
414415/* yield our timeslice for a specific period of time */
415void cpu_yielduntil_time(mame_time duration);
416void cpu_yielduntil_time(attotime duration);
416417
417418
418419
src/emu/sound/ym2413.c
r1293r1294
18581858#ifdef LOG_CYM_FILE
18591859   cymfile = fopen("2413_.cym","wb");
18601860   if (cymfile)
1861      mame_timer_pulse ( MAME_TIME_IN_HZ(110), 0, cymfile_callback); /*110 Hz pulse timer*/
1861      timer_pulse ( ATTOTIME_IN_HZ(110), 0, cymfile_callback); /*110 Hz pulse timer*/
18621862   else
18631863      logerror("Could not create file 2413_.cym\n");
18641864#endif
src/emu/sound/2612intf.c
r1293r1294
2020struct ym2612_info
2121{
2222   sound_stream *   stream;
23   mame_timer *   timer[2];
23   emu_timer *   timer[2];
2424   void *         chip;
2525   const struct YM2612interface *intf;
2626};
r1293r1294
5151   struct ym2612_info *info = param;
5252   if( count == 0 )
5353   {   /* Reset FM Timer */
54      mame_timer_enable(info->timer[c], 0);
54      timer_enable(info->timer[c], 0);
5555   }
5656   else
5757   {   /* Start FM Timer */
58      mame_time period = scale_up_mame_time(MAME_TIME_IN_HZ(clock), count);
59      if (!mame_timer_enable(info->timer[c], 1))
60         mame_timer_adjust_ptr(info->timer[c], period, time_zero);
58      attotime period = attotime_mul(ATTOTIME_IN_HZ(clock), count);
59      if (!timer_enable(info->timer[c], 1))
60         timer_adjust_ptr(info->timer[c], period, attotime_zero);
6161   }
6262}
6363
r1293r1294
9999
100100   /* FM init */
101101   /* Timer Handler set */
102   info->timer[0] = mame_timer_alloc_ptr(timer_callback_2612_0, info);
103   info->timer[1] = mame_timer_alloc_ptr(timer_callback_2612_1, info);
102   info->timer[0] = timer_alloc_ptr(timer_callback_2612_0, info);
103   info->timer[1] = timer_alloc_ptr(timer_callback_2612_1, info);
104104
105105   /* stream system initialize */
106106   info->stream = stream_create(0,2,rate,info,ym2612_stream_update);
src/emu/sound/k054539.c
r1293r1294
473473      // One or more of the registers must be the timer period
474474      // And anyway, this particular frequency is probably wrong
475475      // 480 hz is TRUSTED by gokuparo disco stage - the looping sample doesn't line up otherwise
476      mame_timer_pulse_ptr(MAME_TIME_IN_HZ(480), info, K054539_irq);
476      timer_pulse_ptr(ATTOTIME_IN_HZ(480), info, K054539_irq);
477477
478478   info->stream = stream_create(0, 2, clock, info, K054539_update);
479479
src/emu/sound/msm5205.c
r1293r1294
3636   sound_stream * stream;  /* number of stream system      */
3737   INT32 index;
3838   INT32 clock;            /* clock rate */
39   mame_timer *timer;        /* VCLK callback timer          */
39   emu_timer *timer;        /* VCLK callback timer          */
4040   INT32 data;               /* next adpcm data              */
4141   INT32 vclk;               /* vclk signal (external mode)  */
4242   INT32 reset;              /* reset pin signal             */
r1293r1294
184184
185185   /* stream system initialize */
186186   voice->stream = stream_create(0,1,clock,voice,MSM5205_update);
187   voice->timer = mame_timer_alloc_ptr(MSM5205_vclk_callback, voice);
187   voice->timer = timer_alloc_ptr(MSM5205_vclk_callback, voice);
188188
189189   /* initialize */
190190   msm5205_reset(voice);
r1293r1294
268268      /* timer set */
269269      if( prescaler )
270270      {
271         mame_time period = scale_up_mame_time(MAME_TIME_IN_HZ(voice->clock), prescaler);
272         mame_timer_adjust_ptr(voice->timer, period, period);
271         attotime period = attotime_mul(ATTOTIME_IN_HZ(voice->clock), prescaler);
272         timer_adjust_ptr(voice->timer, period, period);
273273      }
274274      else
275         mame_timer_adjust_ptr(voice->timer, time_never, time_zero);
275         timer_adjust_ptr(voice->timer, attotime_never, attotime_zero);
276276   }
277277
278278   if( voice->bitwidth != bitwidth )
src/emu/sound/3812intf.c
r1293r1294
2929struct ym3812_info
3030{
3131   sound_stream *   stream;
32   mame_timer *   timer[2];
32   emu_timer *   timer[2];
3333   void *         chip;
3434   const struct YM3812interface *intf;
3535};
r1293r1294
5151   YM3812TimerOver(info->chip,1);
5252}
5353
54static void TimerHandler_3812(void *param,int c,mame_time period)
54static void TimerHandler_3812(void *param,int c,attotime period)
5555{
5656   struct ym3812_info *info = param;
57   if( compare_mame_times(period, time_zero) == 0 )
57   if( attotime_compare(period, attotime_zero) == 0 )
5858   {   /* Reset FM Timer */
59      mame_timer_enable(info->timer[c], 0);
59      timer_enable(info->timer[c], 0);
6060   }
6161   else
6262   {   /* Start FM Timer */
63      mame_timer_adjust_ptr(info->timer[c], period, time_zero);
63      timer_adjust_ptr(info->timer[c], period, attotime_zero);
6464   }
6565}
6666
r1293r1294
101101   YM3812SetIRQHandler   (info->chip, IRQHandler_3812, info);
102102   YM3812SetUpdateHandler(info->chip, _stream_update_3812, info);
103103
104   info->timer[0] = mame_timer_alloc_ptr(timer_callback_3812_0, info);
105   info->timer[1] = mame_timer_alloc_ptr(timer_callback_3812_1, info);
104   info->timer[0] = timer_alloc_ptr(timer_callback_3812_0, info);
105   info->timer[1] = timer_alloc_ptr(timer_callback_3812_1, info);
106106
107107   return info;
108108}
r1293r1294
196196struct ym3526_info
197197{
198198   sound_stream *   stream;
199   mame_timer *   timer[2];
199   emu_timer *   timer[2];
200200   void *         chip;
201201   const struct YM3526interface *intf;
202202};
r1293r1294
220220   YM3526TimerOver(info->chip,1);
221221}
222222/* TimerHandler from fm.c */
223static void TimerHandler_3526(void *param,int c,mame_time period)
223static void TimerHandler_3526(void *param,int c,attotime period)
224224{
225225   struct ym3526_info *info = param;
226   if( compare_mame_times(period, time_zero) == 0 )
226   if( attotime_compare(period, attotime_zero) == 0 )
227227   {   /* Reset FM Timer */
228      mame_timer_enable(info->timer[c], 0);
228      timer_enable(info->timer[c], 0);
229229   }
230230   else
231231   {   /* Start FM Timer */
232      mame_timer_adjust_ptr(info->timer[c], period, time_zero);
232      timer_adjust_ptr(info->timer[c], period, attotime_zero);
233233   }
234234}
235235
r1293r1294
269269   YM3526SetIRQHandler   (info->chip, IRQHandler_3526, info);
270270   YM3526SetUpdateHandler(info->chip, _stream_update_3526, info);
271271
272   info->timer[0] = mame_timer_alloc_ptr(timer_callback_3526_0, info);
273   info->timer[1] = mame_timer_alloc_ptr(timer_callback_3526_1, info);
272   info->timer[0] = timer_alloc_ptr(timer_callback_3526_0, info);
273   info->timer[1] = timer_alloc_ptr(timer_callback_3526_1, info);
274274
275275   return info;
276276}
r1293r1294
364364struct y8950_info
365365{
366366   sound_stream *   stream;
367   mame_timer *   timer[2];
367   emu_timer *   timer[2];
368368   void *         chip;
369369   const struct Y8950interface *intf;
370370   int            index;
r1293r1294
385385   struct y8950_info *info = param;
386386   Y8950TimerOver(info->chip,1);
387387}
388static void TimerHandler_8950(void *param,int c,mame_time period)
388static void TimerHandler_8950(void *param,int c,attotime period)
389389{
390390   struct y8950_info *info = param;
391   if( compare_mame_times(period, time_zero) == 0 )
391   if( attotime_compare(period, attotime_zero) == 0 )
392392   {   /* Reset FM Timer */
393      mame_timer_enable(info->timer[c], 0);
393      timer_enable(info->timer[c], 0);
394394   }
395395   else
396396   {   /* Start FM Timer */
397      mame_timer_adjust_ptr(info->timer[c], period, time_zero);
397      timer_adjust_ptr(info->timer[c], period, attotime_zero);
398398   }
399399}
400400
r1293r1294
475475   Y8950SetIRQHandler   (info->chip, IRQHandler_8950, info);
476476   Y8950SetUpdateHandler(info->chip, _stream_update_8950, info);
477477
478   info->timer[0] = mame_timer_alloc_ptr(timer_callback_8950_0, info);
479   info->timer[1] = mame_timer_alloc_ptr(timer_callback_8950_1, info);
478   info->timer[0] = timer_alloc_ptr(timer_callback_8950_0, info);
479   info->timer[1] = timer_alloc_ptr(timer_callback_8950_1, info);
480480
481481   return info;
482482}
src/emu/sound/ymz280b.c
r1293r1294
199199      struct YMZ280BVoice *voice = &chip->voice[j];
200200      update_step(chip, voice);
201201      if(voice->irq_schedule)
202         mame_timer_set_ptr(time_zero, chip, update_irq_state_cb[j]);
202         timer_set_ptr(attotime_zero, chip, update_irq_state_cb[j]);
203203   }
204204}
205205
r1293r1294
575575            voice->playing = 0;
576576
577577            /* set update_irq_state_timer. IRQ is signaled on next CPU execution. */
578            mame_timer_set_ptr(time_zero, chip, update_irq_state_cb[v]);
578            timer_set_ptr(attotime_zero, chip, update_irq_state_cb[v]);
579579            voice->irq_schedule = 1;
580580         }
581581      }
src/emu/sound/ymf262.c
r1293r1294
256256   int clock;                  /* master clock  (Hz)           */
257257   int rate;                  /* sampling rate (Hz)           */
258258   double freqbase;            /* frequency base               */
259   mame_time TimerBase;         /* Timer base time (==sampling time)*/
259   attotime TimerBase;         /* Timer base time (==sampling time)*/
260260} OPL3;
261261
262262
r1293r1294
12991299   /* logerror("YMF262: freqbase=%f\n", chip->freqbase); */
13001300
13011301   /* Timer base time */
1302   chip->TimerBase = scale_up_mame_time(MAME_TIME_IN_HZ(chip->clock), 8*36);
1302   chip->TimerBase = attotime_mul(ATTOTIME_IN_HZ(chip->clock), 8*36);
13031303
13041304   /* make fnumber -> increment counter table */
13051305   for( i=0 ; i < 1024 ; i++ )
r1293r1294
17261726            /* timer 2 */
17271727            if(chip->st[1] != st2)
17281728            {
1729               mame_time period = st2 ? scale_up_mame_time(chip->TimerBase, chip->T[1]) : time_zero;
1729               attotime period = st2 ? attotime_mul(chip->TimerBase, chip->T[1]) : attotime_zero;
17301730               chip->st[1] = st2;
17311731               if (chip->timer_handler) (chip->timer_handler)(chip->TimerParam,1,period);
17321732            }
17331733            /* timer 1 */
17341734            if(chip->st[0] != st1)
17351735            {
1736               mame_time period = st1 ? scale_up_mame_time(chip->TimerBase, chip->T[0]) : time_zero;
1736               attotime period = st1 ? attotime_mul(chip->TimerBase, chip->T[0]) : attotime_zero;
17371737               chip->st[0] = st1;
17381738               if (chip->timer_handler) (chip->timer_handler)(chip->TimerParam,0,period);
17391739            }
r1293r1294
22552255#ifdef LOG_CYM_FILE
22562256   cymfile = fopen("ymf262_.cym","wb");
22572257   if (cymfile)
2258      mame_timer_pulse ( MAME_TIME_IN_HZ(110), 0, cymfile_callback); /*110 Hz pulse timer*/
2258      timer_pulse ( ATTOTIME_IN_HZ(110), 0, cymfile_callback); /*110 Hz pulse timer*/
22592259   else
22602260      logerror("Could not create ymf262_.cym file\n");
22612261#endif
r1293r1294
24502450      OPL3_STATUS_SET(chip,0x40);
24512451   }
24522452   /* reload timer */
2453   if (chip->timer_handler) (chip->timer_handler)(chip->TimerParam,c,scale_up_mame_time(chip->TimerBase, chip->T[c]));
2453   if (chip->timer_handler) (chip->timer_handler)(chip->TimerParam,c,attotime_mul(chip->TimerBase, chip->T[c]));
24542454   return chip->status>>7;
24552455}
24562456
src/emu/sound/ymf262.h
r1293r1294
2525#endif
2626*/
2727
28typedef void (*OPL3_TIMERHANDLER)(void *param,int timer,mame_time period);
28typedef void (*OPL3_TIMERHANDLER)(void *param,int timer,attotime period);
2929typedef void (*OPL3_IRQHANDLER)(void *param,int irq);
3030typedef void (*OPL3_UPDATEHANDLER)(void *param,int min_interval_us);
3131
src/emu/sound/upd7759.c
r1293r1294
153153   /* internal clock to output sample rate mapping */
154154   UINT32      pos;                  /* current output sample position */
155155   UINT32      step;                  /* step value per output sample */
156   mame_time   clock_period;            /* clock period */
157   mame_timer *timer;                  /* timer */
156   attotime   clock_period;            /* clock period */
157   emu_timer *timer;                  /* timer */
158158
159159   /* I/O lines */
160160   UINT8      fifo_in;               /* last data written to the sound chip */
r1293r1294
540540
541541   /* set a timer to go off when that is done */
542542   if (chip->state != STATE_IDLE)
543      mame_timer_adjust_ptr(chip->timer, scale_up_mame_time(chip->clock_period, chip->clocks_left), time_zero);
543      timer_adjust_ptr(chip->timer, attotime_mul(chip->clock_period, chip->clocks_left), attotime_zero);
544544}
545545
546546
r1293r1294
575575
576576   /* turn off any timer */
577577   if (chip->timer)
578      mame_timer_adjust_ptr(chip->timer, time_never, time_zero);
578      timer_adjust_ptr(chip->timer, attotime_never, attotime_zero);
579579}
580580
581581
r1293r1294
634634   chip->step = 4 * FRAC_ONE;
635635
636636   /* compute the clock period */
637   chip->clock_period = MAME_TIME_IN_HZ(clock);
637   chip->clock_period = ATTOTIME_IN_HZ(clock);
638638
639639   /* set the intial state */
640640   chip->state = STATE_IDLE;
r1293r1294
643643   if (intf->region != 0)
644644      chip->rom = chip->rombase = memory_region(intf->region);
645645   else
646      chip->timer = mame_timer_alloc_ptr(upd7759_slave_update, chip);
646      chip->timer = timer_alloc_ptr(upd7759_slave_update, chip);
647647
648648   /* set the DRQ callback */
649649   chip->drqcallback = intf->drqcallback;
r1293r1294
702702
703703      /* for slave mode, start the timer going */
704704      if (chip->timer)
705         mame_timer_adjust_ptr(chip->timer, time_zero, time_zero);
705         timer_adjust_ptr(chip->timer, attotime_zero, attotime_zero);
706706   }
707707}
708708
src/emu/sound/ymf271.c
r1293r1294
100100   INT8  status;
101101   INT8  enable;
102102
103   mame_timer *timA, *timB;
103   emu_timer *timA, *timB;
104104
105105   INT8  reg0, reg1, reg2, reg3, pcmreg, timerreg;
106106   UINT32 ext_address;
r1293r1294
13861386{
13871387   int slotnum;
13881388   YMF271Group *group;
1389   mame_time period;
1389   attotime period;
13901390
13911391   slotnum = fm_tab[chip->timerreg & 0xf];
13921392   group = &chip->groups[slotnum];
r1293r1294
14471447               if (chip->irq_callback) chip->irq_callback(0);
14481448
14491449               //period = (double)(256.0 - chip->timerAVal ) * ( 384.0 * 4.0 / (double)CLOCK);
1450               period = scale_up_mame_time(MAME_TIME_IN_HZ(chip->clock), 384 * (1024 - chip->timerAVal));
1450               period = attotime_mul(ATTOTIME_IN_HZ(chip->clock), 384 * (1024 - chip->timerAVal));
14511451
1452               mame_timer_adjust_ptr(chip->timA, period, period);
1452               timer_adjust_ptr(chip->timA, period, period);
14531453            }
14541454            if (data & 0x20)
14551455            {   // timer B reset
r1293r1294
14581458
14591459               if (chip->irq_callback) chip->irq_callback(0);
14601460
1461               period = scale_up_mame_time(MAME_TIME_IN_HZ(chip->clock), 384 * 16 * (256 - chip->timerBVal));
1461               period = attotime_mul(ATTOTIME_IN_HZ(chip->clock), 384 * 16 * (256 - chip->timerBVal));
14621462
1463               mame_timer_adjust_ptr(chip->timB, period, period);
1463               timer_adjust_ptr(chip->timB, period, period);
14641464            }
14651465
14661466            break;
r1293r1294
17191719
17201720static void ymf271_init(YMF271Chip *chip, UINT8 *rom, void (*cb)(int), read8_handler ext_read, write8_handler ext_write)
17211721{
1722   chip->timA = mame_timer_alloc_ptr(ymf271_timer_a_tick, chip);
1723   chip->timB = mame_timer_alloc_ptr(ymf271_timer_b_tick, chip);
1722   chip->timA = timer_alloc_ptr(ymf271_timer_a_tick, chip);
1723   chip->timB = timer_alloc_ptr(ymf271_timer_b_tick, chip);
17241724
17251725   chip->rom = rom;
17261726   chip->irq_callback = cb;
src/emu/sound/pokey.c
r1293r1294
1313 *  For more details read mame.txt that comes with MAME.
1414 *
1515 *  4.51:
16 *  - changed to use the mame_time datatype
16 *  - changed to use the attotime datatype
1717 *  4.5:
1818 *  - changed the 9/17 bit polynomial formulas such that the values
1919 *    required for the Tempest Pokey protection will be found.
r1293r1294
195195    UINT32 r17;             /* rand17 index */
196196   UINT32 clockmult;      /* clock multiplier */
197197    sound_stream * channel; /* streams channel */
198   mame_timer *timer[3];    /* timers for channel 1,2 and 4 events */
199   mame_time timer_period[3];   /* computed periods for these timers */
198   emu_timer *timer[3];    /* timers for channel 1,2 and 4 events */
199   attotime timer_period[3];   /* computed periods for these timers */
200200   int timer_param[3];      /* computed parameters for these timers */
201   mame_timer *rtimer;     /* timer for calculating the random offset */
202   mame_timer *ptimer[8];   /* pot timers */
201   emu_timer *rtimer;     /* timer for calculating the random offset */
202   emu_timer *ptimer[8];   /* pot timers */
203203   read8_handler pot_r[8];
204204   read8_handler allpot_r;
205205   read8_handler serin_r;
r1293r1294
219219   UINT8 SKSTAT;         /* SKSTAT (R/D20F) */
220220   UINT8 SKCTL;         /* SKCTL  (W/D20F) */
221221   struct POKEYinterface intf;
222   mame_time clock_period;
223   mame_time ad_time_fast;
224   mame_time ad_time_slow;
222   attotime clock_period;
223   attotime ad_time_fast;
224   attotime ad_time_slow;
225225   int index;
226226
227227   UINT8 poly4[0x0f];
r1293r1294
495495         PROCESS_SAMPLE(chip);                              \
496496      }                                                \
497497   }                                                   \
498   mame_timer_adjust(chip->rtimer, time_never, 0, time_zero)
498   timer_adjust(chip->rtimer, attotime_never, 0, attotime_zero)
499499
500500#else   /* no HEAVY_MACRO_USAGE */
501501/*
r1293r1294
546546         PROCESS_CHANNEL(chip,channel);                        \
547547      }                                                \
548548   }                                                   \
549   mame_timer_adjust(chip->rtimer, time_never, 0, time_zero)
549   timer_adjust(chip->rtimer, attotime_never, 0, attotime_zero)
550550
551551#endif
552552
r1293r1294
612612   state_save_register_item("pokey", index, chip->r17);
613613   state_save_register_item("pokey", index, chip->clockmult);
614614   state_save_register_item("pokey", index, chip->timer_period[0].seconds);
615   state_save_register_item("pokey", index, chip->timer_period[0].subseconds);
615   state_save_register_item("pokey", index, chip->timer_period[0].attoseconds);
616616   state_save_register_item("pokey", index, chip->timer_period[1].seconds);
617   state_save_register_item("pokey", index, chip->timer_period[1].subseconds);
617   state_save_register_item("pokey", index, chip->timer_period[1].attoseconds);
618618   state_save_register_item("pokey", index, chip->timer_period[2].seconds);
619   state_save_register_item("pokey", index, chip->timer_period[2].subseconds);
619   state_save_register_item("pokey", index, chip->timer_period[2].attoseconds);
620620   state_save_register_item_array("pokey", index, chip->timer_param);
621621   state_save_register_item_array("pokey", index, chip->AUDF);
622622   state_save_register_item_array("pokey", index, chip->AUDC);
r1293r1294
644644
645645   if (config)
646646      memcpy(&chip->intf, config, sizeof(struct POKEYinterface));
647   chip->clock_period = MAME_TIME_IN_HZ(clock);
647   chip->clock_period = ATTOTIME_IN_HZ(clock);
648648   chip->index = sndindex;
649649
650650   /* calculate the A/D times
r1293r1294
654654     * In quick mode (SK_PADDLE set) the conversion is done very fast
655655     * (takes two scanlines) but the result is not as accurate.
656656     */
657   chip->ad_time_fast = scale_down_mame_time(scale_up_mame_time(MAME_TIME_IN_NSEC(64000*2/228), FREQ_17_EXACT), clock);
658   chip->ad_time_slow = scale_down_mame_time(scale_up_mame_time(MAME_TIME_IN_NSEC(64000      ), FREQ_17_EXACT), clock);
657   chip->ad_time_fast = attotime_div(attotime_mul(ATTOTIME_IN_NSEC(64000*2/228), FREQ_17_EXACT), clock);
658   chip->ad_time_slow = attotime_div(attotime_mul(ATTOTIME_IN_NSEC(64000      ), FREQ_17_EXACT), clock);
659659
660660   /* initialize the poly counters */
661661   poly_init(chip->poly4,   4, 3, 1, 0x00004);
r1293r1294
675675   chip->clockmult = DIV_64;
676676   chip->KBCODE = 0x09;       /* Atari 800 'no key' */
677677   chip->SKCTL = SK_RESET;    /* let the RNG run after reset */
678   chip->rtimer = mame_timer_alloc(NULL);
678   chip->rtimer = timer_alloc(NULL);
679679
680   chip->timer[0] = mame_timer_alloc_ptr(pokey_timer_expire_1, chip);
681   chip->timer[1] = mame_timer_alloc_ptr(pokey_timer_expire_2, chip);
682   chip->timer[2] = mame_timer_alloc_ptr(pokey_timer_expire_4, chip);
680   chip->timer[0] = timer_alloc_ptr(pokey_timer_expire_1, chip);
681   chip->timer[1] = timer_alloc_ptr(pokey_timer_expire_2, chip);
682   chip->timer[2] = timer_alloc_ptr(pokey_timer_expire_4, chip);
683683
684   chip->ptimer[0] = mame_timer_alloc_ptr(pokey_pot_trigger_0, chip);
685   chip->ptimer[1] = mame_timer_alloc_ptr(pokey_pot_trigger_1, chip);
686   chip->ptimer[2] = mame_timer_alloc_ptr(pokey_pot_trigger_2, chip);
687   chip->ptimer[3] = mame_timer_alloc_ptr(pokey_pot_trigger_3, chip);
688   chip->ptimer[4] = mame_timer_alloc_ptr(pokey_pot_trigger_4, chip);
689   chip->ptimer[5] = mame_timer_alloc_ptr(pokey_pot_trigger_5, chip);
690   chip->ptimer[6] = mame_timer_alloc_ptr(pokey_pot_trigger_6, chip);
691   chip->ptimer[7] = mame_timer_alloc_ptr(pokey_pot_trigger_7, chip);
684   chip->ptimer[0] = timer_alloc_ptr(pokey_pot_trigger_0, chip);
685   chip->ptimer[1] = timer_alloc_ptr(pokey_pot_trigger_1, chip);
686   chip->ptimer[2] = timer_alloc_ptr(pokey_pot_trigger_2, chip);
687   chip->ptimer[3] = timer_alloc_ptr(pokey_pot_trigger_3, chip);
688   chip->ptimer[4] = timer_alloc_ptr(pokey_pot_trigger_4, chip);
689   chip->ptimer[5] = timer_alloc_ptr(pokey_pot_trigger_5, chip);
690   chip->ptimer[6] = timer_alloc_ptr(pokey_pot_trigger_6, chip);
691   chip->ptimer[7] = timer_alloc_ptr(pokey_pot_trigger_7, chip);
692692
693693   chip->pot_r[0] = chip->intf.pot_r[0];
694694   chip->pot_r[1] = chip->intf.pot_r[1];
r1293r1294
832832
833833static void pokey_pot_trigger_common(struct POKEYregisters *p, int pot)
834834{
835   LOG(("POKEY #%p POT%d triggers after %dus\n", p, pot, (int)(1000000 * mame_time_to_double(mame_timer_timeelapsed(p->ptimer[pot])))));
835   LOG(("POKEY #%p POT%d triggers after %dus\n", p, pot, (int)(1000000 * attotime_to_double(timer_timeelapsed(p->ptimer[pot])))));
836836   p->ALLPOT &= ~(1 << pot);   /* set the enabled timer irq status bits */
837837}
838838
r1293r1294
870870
871871                /* final value */
872872                p->POTx[pot] = r;
873            mame_timer_adjust_ptr(p->ptimer[pot], scale_up_mame_time(AD_TIME, r), time_zero);
873            timer_adjust_ptr(p->ptimer[pot], attotime_mul(AD_TIME, r), attotime_zero);
874874         }
875875      }
876876   }
r1293r1294
904904             */
905905         if( p->ALLPOT & (1 << pot) )
906906         {
907            data = mame_timer_timeelapsed(p->ptimer[pot]).subseconds / AD_TIME.subseconds;
907            data = timer_timeelapsed(p->ptimer[pot]).attoseconds / AD_TIME.attoseconds;
908908            LOG(("POKEY #%d read POT%d (interpolated) $%02x\n", chip, pot, data));
909909            }
910910         else
r1293r1294
954954         ****************************************************************/
955955      if( p->SKCTL & SK_RESET )
956956      {
957         adjust = mame_time_to_double(mame_timer_timeelapsed(p->rtimer)) / mame_time_to_double(p->clock_period);
957         adjust = attotime_to_double(timer_timeelapsed(p->rtimer)) / attotime_to_double(p->clock_period);
958958         p->r9 = (p->r9 + adjust) % 0x001ff;
959959         p->r17 = (p->r17 + adjust) % 0x1ffff;
960960      }
r1293r1294
976976         LOG_RAND(("POKEY #%d adjust %u rand17[$%05x]: $%02x\n", chip, adjust, p->r17, p->RANDOM));
977977      }
978978      if (adjust > 0)
979           mame_timer_adjust(p->rtimer, time_never, 0, time_zero);
979           timer_adjust(p->rtimer, attotime_never, 0, attotime_zero);
980980      data = p->RANDOM ^ 0xff;
981981      break;
982982
r1293r1294
11371137        /* first remove any existing timers */
11381138      LOG_TIMER(("POKEY #%d STIMER $%02x\n", chip, data));
11391139
1140      mame_timer_adjust_ptr(p->timer[TIMER1], time_never, time_zero);
1141      mame_timer_adjust_ptr(p->timer[TIMER2], time_never, time_zero);
1142      mame_timer_adjust_ptr(p->timer[TIMER4], time_never, time_zero);
1140      timer_adjust_ptr(p->timer[TIMER1], attotime_never, attotime_zero);
1141      timer_adjust_ptr(p->timer[TIMER2], attotime_never, attotime_zero);
1142      timer_adjust_ptr(p->timer[TIMER4], attotime_never, attotime_zero);
11431143
11441144        /* reset all counters to zero (side effect) */
11451145      p->polyadjust = 0;
r1293r1294
11551155         {
11561156            LOG_TIMER(("POKEY #%d timer1+2 after %d clocks\n", chip, p->divisor[CHAN2]));
11571157            /* set timer #1 _and_ #2 event after timer_div clocks of joined CHAN1+CHAN2 */
1158            p->timer_period[TIMER2] = scale_up_mame_time(p->clock_period, p->divisor[CHAN2]);
1158            p->timer_period[TIMER2] = attotime_mul(p->clock_period, p->divisor[CHAN2]);
11591159            p->timer_param[TIMER2] = (chip<<3)|IRQ_TIMR2|IRQ_TIMR1;
1160            mame_timer_adjust_ptr(p->timer[TIMER2], p->timer_period[TIMER2], p->timer_period[TIMER2]);
1160            timer_adjust_ptr(p->timer[TIMER2], p->timer_period[TIMER2], p->timer_period[TIMER2]);
11611161         }
11621162        }
11631163        else
r1293r1294
11661166         {
11671167            LOG_TIMER(("POKEY #%d timer1 after %d clocks\n", chip, p->divisor[CHAN1]));
11681168            /* set timer #1 event after timer_div clocks of CHAN1 */
1169            p->timer_period[TIMER1] = scale_up_mame_time(p->clock_period, p->divisor[CHAN1]);
1169            p->timer_period[TIMER1] = attotime_mul(p->clock_period, p->divisor[CHAN1]);
11701170            p->timer_param[TIMER1] = (chip<<3)|IRQ_TIMR1;
1171            mame_timer_adjust_ptr(p->timer[TIMER1], p->timer_period[TIMER1], p->timer_period[TIMER1]);
1171            timer_adjust_ptr(p->timer[TIMER1], p->timer_period[TIMER1], p->timer_period[TIMER1]);
11721172         }
11731173
11741174         if( p->divisor[CHAN2] > 4 )
11751175         {
11761176            LOG_TIMER(("POKEY #%d timer2 after %d clocks\n", chip, p->divisor[CHAN2]));
11771177            /* set timer #2 event after timer_div clocks of CHAN2 */
1178            p->timer_period[TIMER2] = scale_up_mame_time(p->clock_period, p->divisor[CHAN2]);
1178            p->timer_period[TIMER2] = attotime_mul(p->clock_period, p->divisor[CHAN2]);
11791179            p->timer_param[TIMER2] = (chip<<3)|IRQ_TIMR2;
1180            mame_timer_adjust_ptr(p->timer[TIMER2], p->timer_period[TIMER2], p->timer_period[TIMER2]);
1180            timer_adjust_ptr(p->timer[TIMER2], p->timer_period[TIMER2], p->timer_period[TIMER2]);
11811181         }
11821182        }
11831183
r1293r1294
11921192            {
11931193               LOG_TIMER(("POKEY #%d timer4 after %d clocks\n", chip, p->divisor[CHAN4]));
11941194               /* set timer #4 event after timer_div clocks of CHAN4 */
1195               p->timer_period[TIMER4] = scale_up_mame_time(p->clock_period, p->divisor[CHAN4]);
1195               p->timer_period[TIMER4] = attotime_mul(p->clock_period, p->divisor[CHAN4]);
11961196               p->timer_param[TIMER4] = (chip<<3)|IRQ_TIMR4;
1197               mame_timer_adjust_ptr(p->timer[TIMER4], p->timer_period[TIMER4], p->timer_period[TIMER4]);
1197               timer_adjust_ptr(p->timer[TIMER4], p->timer_period[TIMER4], p->timer_period[TIMER4]);
11981198            }
11991199            }
12001200        }
r1293r1294
12041204         {
12051205            LOG_TIMER(("POKEY #%d timer4 after %d clocks\n", chip, p->divisor[CHAN4]));
12061206            /* set timer #4 event after timer_div clocks of CHAN4 */
1207            p->timer_period[TIMER4] = scale_up_mame_time(p->clock_period, p->divisor[CHAN4]);
1207            p->timer_period[TIMER4] = attotime_mul(p->clock_period, p->divisor[CHAN4]);
12081208            p->timer_param[TIMER4] = (chip<<3)|IRQ_TIMR4;
1209            mame_timer_adjust_ptr(p->timer[TIMER4], p->timer_period[TIMER4], p->timer_period[TIMER4]);
1209            timer_adjust_ptr(p->timer[TIMER4], p->timer_period[TIMER4], p->timer_period[TIMER4]);
12101210         }
12111211        }
12121212
1213      mame_timer_enable(p->timer[TIMER1], p->IRQEN & IRQ_TIMR1);
1214      mame_timer_enable(p->timer[TIMER2], p->IRQEN & IRQ_TIMR2);
1215      mame_timer_enable(p->timer[TIMER4], p->IRQEN & IRQ_TIMR4);
1213      timer_enable(p->timer[TIMER1], p->IRQEN & IRQ_TIMR1);
1214      timer_enable(p->timer[TIMER2], p->IRQEN & IRQ_TIMR2);
1215      timer_enable(p->timer[TIMER4], p->IRQEN & IRQ_TIMR4);
12161216        break;
12171217
12181218    case SKREST_C:
r1293r1294
12361236         * loaders from Ballblazer and Escape from Fractalus
12371237         * The real times are unknown
12381238         */
1239        mame_timer_set_ptr(MAME_TIME_IN_USEC(200), p, pokey_serout_ready);
1239        timer_set_ptr(ATTOTIME_IN_USEC(200), p, pokey_serout_ready);
12401240        /* 10 bits (assumption 1 start, 8 data and 1 stop bit) take how long? */
1241        mame_timer_set_ptr(MAME_TIME_IN_USEC(2000), p, pokey_serout_complete);
1241        timer_set_ptr(ATTOTIME_IN_USEC(2000), p, pokey_serout_complete);
12421242        break;
12431243
12441244    case IRQEN_C:
r1293r1294
12551255         /* enable/disable timers now to avoid unneeded
12561256               breaking of the CPU cores for masked timers */
12571257         if( p->timer[TIMER1] && ((p->IRQEN^data) & IRQ_TIMR1) )
1258            mame_timer_enable(p->timer[TIMER1], data & IRQ_TIMR1);
1258            timer_enable(p->timer[TIMER1], data & IRQ_TIMR1);
12591259         if( p->timer[TIMER2] && ((p->IRQEN^data) & IRQ_TIMR2) )
1260            mame_timer_enable(p->timer[TIMER2], data & IRQ_TIMR2);
1260            timer_enable(p->timer[TIMER2], data & IRQ_TIMR2);
12611261         if( p->timer[TIMER4] && ((p->IRQEN^data) & IRQ_TIMR4) )
1262            mame_timer_enable(p->timer[TIMER4], data & IRQ_TIMR4);
1262            timer_enable(p->timer[TIMER4], data & IRQ_TIMR4);
12631263        }
12641264      /* store irq enable */
12651265      p->IRQEN = data;
r1293r1294
13031303      if( new_val < p->counter[CHAN1] )
13041304         p->counter[CHAN1] = new_val;
13051305      if( p->interrupt_cb && p->timer[TIMER1] )
1306         mame_timer_adjust_ptr(p->timer[TIMER1], scale_up_mame_time(p->clock_period, new_val), p->timer_period[TIMER1]);
1306         timer_adjust_ptr(p->timer[TIMER1], attotime_mul(p->clock_period, new_val), p->timer_period[TIMER1]);
13071307      p->audible[CHAN1] = !(
13081308         (p->AUDC[CHAN1] & VOLUME_ONLY) ||
13091309         (p->AUDC[CHAN1] & VOLUME_MASK) == 0 ||
r1293r1294
13391339      if( new_val < p->counter[CHAN2] )
13401340         p->counter[CHAN2] = new_val;
13411341      if( p->interrupt_cb && p->timer[TIMER2] )
1342         mame_timer_adjust_ptr(p->timer[TIMER2], scale_up_mame_time(p->clock_period, new_val), p->timer_period[TIMER2]);
1342         timer_adjust_ptr(p->timer[TIMER2], attotime_mul(p->clock_period, new_val), p->timer_period[TIMER2]);
13431343      p->audible[CHAN2] = !(
13441344         (p->AUDC[CHAN2] & VOLUME_ONLY) ||
13451345         (p->AUDC[CHAN2] & VOLUME_MASK) == 0 ||
r1293r1294
14041404      if( new_val < p->counter[CHAN4] )
14051405         p->counter[CHAN4] = new_val;
14061406      if( p->interrupt_cb && p->timer[TIMER4] )
1407         mame_timer_adjust_ptr(p->timer[TIMER4], scale_up_mame_time(p->clock_period, new_val), p->timer_period[TIMER4]);
1407         timer_adjust_ptr(p->timer[TIMER4], attotime_mul(p->clock_period, new_val), p->timer_period[TIMER4]);
14081408      p->audible[CHAN4] = !(
14091409         (p->AUDC[CHAN4] & VOLUME_ONLY) ||
14101410         (p->AUDC[CHAN4] & VOLUME_MASK) == 0 ||
r1293r1294
14521452void pokey1_serin_ready(int after)
14531453{
14541454   struct POKEYregisters *p = sndti_token(SOUND_POKEY, 0);
1455   mame_timer_set_ptr(scale_up_mame_time(p->clock_period, after), p, pokey_serin_ready);
1455   timer_set_ptr(attotime_mul(p->clock_period, after), p, pokey_serin_ready);
14561456}
14571457
14581458void pokey2_serin_ready(int after)
14591459{
14601460   struct POKEYregisters *p = sndti_token(SOUND_POKEY, 1);
1461   mame_timer_set_ptr(scale_up_mame_time(p->clock_period, after), p, pokey_serin_ready);
1461   timer_set_ptr(attotime_mul(p->clock_period, after), p, pokey_serin_ready);
14621462}
14631463
14641464void pokey3_serin_ready(int after)
14651465{
14661466   struct POKEYregisters *p = sndti_token(SOUND_POKEY, 2);
1467   mame_timer_set_ptr(scale_up_mame_time(p->clock_period, after), p, pokey_serin_ready);
1467   timer_set_ptr(attotime_mul(p->clock_period, after), p, pokey_serin_ready);
14681468}
14691469
14701470void pokey4_serin_ready(int after)
14711471{
14721472   struct POKEYregisters *p = sndti_token(SOUND_POKEY, 3);
1473   mame_timer_set_ptr(scale_up_mame_time(p->clock_period, after), p, pokey_serin_ready);
1473   timer_set_ptr(attotime_mul(p->clock_period, after), p, pokey_serin_ready);
14741474}
14751475
14761476void pokey_break_w(int chip, int shift)
src/emu/sound/sp0250.c
r1293r1294
200200   sp->RNG = 1;
201201   sp->drq = intf->drq_callback;
202202   sp->drq(ASSERT_LINE);
203   mame_timer_pulse_ptr(scale_up_mame_time(MAME_TIME_IN_HZ(clock), CLOCK_DIVIDER), sp, sp0250_timer_tick);
203   timer_pulse_ptr(attotime_mul(ATTOTIME_IN_HZ(clock), CLOCK_DIVIDER), sp, sp0250_timer_tick);
204204
205205   sp->stream = stream_create(0, 1, clock / CLOCK_DIVIDER, sp, sp0250_update);
206206
src/emu/sound/ym2151.c
r1293r1294
121121
122122#ifdef USE_MAME_TIMERS
123123/* ASG 980324 -- added for tracking timers */
124   mame_timer   *timer_A;
125   mame_timer   *timer_B;
126   mame_time   timer_A_time[1024];      /* timer A times for MAME */
127   mame_time   timer_B_time[256];      /* timer B times for MAME */
124   emu_timer   *timer_A;
125   emu_timer   *timer_B;
126   attotime   timer_A_time[1024];      /* timer A times for MAME */
127   attotime   timer_B_time[256];      /* timer B times for MAME */
128128   int         irqlinestate;
129129#else
130130   UINT8      tim_A;               /* timer A enable (0-disabled) */
r1293r1294
592592   int i,j;
593593   double mult,phaseinc,Hz;
594594   double scaler;
595   mame_time pom;
595   attotime pom;
596596
597597   scaler = ( (double)chip->clock / 64.0 ) / ( (double)chip->sampfreq );
598598   /*logerror("scaler    = %20.15f\n", scaler);*/
r1293r1294
697697   for (i=0; i<1024; i++)
698698   {
699699      /* ASG 980324: changed to compute both tim_A_tab and timer_A_time */
700      pom= scale_up_mame_time(MAME_TIME_IN_HZ(chip->clock), 64 * (1024 - i));
700      pom= attotime_mul(ATTOTIME_IN_HZ(chip->clock), 64 * (1024 - i));
701701      #ifdef USE_MAME_TIMERS
702702         chip->timer_A_time[i] = pom;
703703      #else
704         chip->tim_A_tab[i] = mame_time_to_double(pom) * (double)chip->sampfreq * mult;  /* number of samples that timer period takes (fixed point) */
704         chip->tim_A_tab[i] = attotime_to_double(pom) * (double)chip->sampfreq * mult;  /* number of samples that timer period takes (fixed point) */
705705      #endif
706706   }
707707   for (i=0; i<256; i++)
708708   {
709709      /* ASG 980324: changed to compute both tim_B_tab and timer_B_time */
710      pom= scale_up_mame_time(MAME_TIME_IN_HZ(chip->clock), 1024 * (256 - i));
710      pom= attotime_mul(ATTOTIME_IN_HZ(chip->clock), 1024 * (256 - i));
711711      #ifdef USE_MAME_TIMERS
712712         chip->timer_B_time[i] = pom;
713713      #else
714         chip->tim_B_tab[i] = mame_time_to_double(pom) * (double)chip->sampfreq * mult;  /* number of samples that timer period takes (fixed point) */
714         chip->tim_B_tab[i] = attotime_to_double(pom) * (double)chip->sampfreq * mult;  /* number of samples that timer period takes (fixed point) */
715715      #endif
716716   }
717717
r1293r1294
826826static TIMER_CALLBACK_PTR( timer_callback_a )
827827{
828828   YM2151 *chip = param;
829   mame_timer_adjust_ptr(chip->timer_A, chip->timer_A_time[ chip->timer_A_index ], time_zero);
829   timer_adjust_ptr(chip->timer_A, chip->timer_A_time[ chip->timer_A_index ], attotime_zero);
830830   chip->timer_A_index_old = chip->timer_A_index;
831831   if (chip->irq_enable & 0x04)
832832   {
833833      chip->status |= 1;
834      mame_timer_set_ptr(time_zero,chip,irqAon_callback);
834      timer_set_ptr(attotime_zero,chip,irqAon_callback);
835835   }
836836   if (chip->irq_enable & 0x80)
837837      chip->csm_req = 2;      /* request KEY ON / KEY OFF sequence */
r1293r1294
839839static TIMER_CALLBACK_PTR( timer_callback_b )
840840{
841841   YM2151 *chip = param;
842   mame_timer_adjust_ptr(chip->timer_B, chip->timer_B_time[ chip->timer_B_index ], time_zero);
842   timer_adjust_ptr(chip->timer_B, chip->timer_B_time[ chip->timer_B_index ], attotime_zero);
843843   chip->timer_B_index_old = chip->timer_B_index;
844844   if (chip->irq_enable & 0x08)
845845   {
846846      chip->status |= 2;
847      mame_timer_set_ptr(time_zero,chip,irqBon_callback);
847      timer_set_ptr(attotime_zero,chip,irqBon_callback);
848848   }
849849}
850850#if 0
r1293r1294
10561056#if 0
10571057   /* There is no info on what YM2151 really does when busy flag is set */
10581058   if ( chip->status & 0x80 ) return;
1059   mame_timer_set_ptr ( scale_up_mame_time(MAME_TIME_IN_HZ(chip->clock), 64), chip, timer_callback_chip_busy);
1059   timer_set_ptr ( attotime_mul(ATTOTIME_IN_HZ(chip->clock), 64), chip, timer_callback_chip_busy);
10601060   chip->status |= 0x80;   /* set busy flag for 64 chip clock cycles */
10611061#endif
10621062
r1293r1294
11071107         {
11081108#ifdef USE_MAME_TIMERS
11091109            chip->status &= ~1;
1110            mame_timer_set_ptr(time_zero,chip,irqAoff_callback);
1110            timer_set_ptr(attotime_zero,chip,irqAoff_callback);
11111111#else
11121112            int oldstate = chip->status & 3;
11131113            chip->status &= ~1;
r1293r1294
11191119         {
11201120#ifdef USE_MAME_TIMERS
11211121            chip->status &= ~2;
1122            mame_timer_set_ptr(time_zero,chip,irqBoff_callback);
1122            timer_set_ptr(attotime_zero,chip,irqBoff_callback);
11231123#else
11241124            int oldstate = chip->status & 3;
11251125            chip->status &= ~2;
r1293r1294
11311131            #ifdef USE_MAME_TIMERS
11321132            /* ASG 980324: added a real timer */
11331133            /* start timer _only_ if it wasn't already started (it will reload time value next round) */
1134               if (!mame_timer_enable(chip->timer_B, 1))
1134               if (!timer_enable(chip->timer_B, 1))
11351135               {
1136                  mame_timer_adjust_ptr(chip->timer_B, chip->timer_B_time[ chip->timer_B_index ], time_zero);
1136                  timer_adjust_ptr(chip->timer_B, chip->timer_B_time[ chip->timer_B_index ], attotime_zero);
11371137                  chip->timer_B_index_old = chip->timer_B_index;
11381138               }
11391139            #else
r1293r1294
11461146         }else{      /* stop timer B */
11471147            #ifdef USE_MAME_TIMERS
11481148            /* ASG 980324: added a real timer */
1149               mame_timer_enable(chip->timer_B, 0);
1149               timer_enable(chip->timer_B, 0);
11501150            #else
11511151               chip->tim_B = 0;
11521152            #endif
r1293r1294
11561156            #ifdef USE_MAME_TIMERS
11571157            /* ASG 980324: added a real timer */
11581158            /* start timer _only_ if it wasn't already started (it will reload time value next round) */
1159               if (!mame_timer_enable(chip->timer_A, 1))
1159               if (!timer_enable(chip->timer_A, 1))
11601160               {
1161                  mame_timer_adjust_ptr(chip->timer_A, chip->timer_A_time[ chip->timer_A_index ], time_zero);
1161                  timer_adjust_ptr(chip->timer_A, chip->timer_A_time[ chip->timer_A_index ], attotime_zero);
11621162                  chip->timer_A_index_old = chip->timer_A_index;
11631163               }
11641164            #else
r1293r1294
11711171         }else{      /* stop timer A */
11721172            #ifdef USE_MAME_TIMERS
11731173            /* ASG 980324: added a real timer */
1174               mame_timer_enable(chip->timer_A, 0);
1174               timer_enable(chip->timer_A, 0);
11751175            #else
11761176               chip->tim_A = 0;
11771177            #endif
r1293r1294
15421542
15431543#ifdef USE_MAME_TIMERS
15441544/* this must be done _before_ a call to YM2151ResetChip() */
1545   PSG->timer_A = mame_timer_alloc_ptr(timer_callback_a, PSG);
1546   PSG->timer_B = mame_timer_alloc_ptr(timer_callback_b, PSG);
1545   PSG->timer_A = timer_alloc_ptr(timer_callback_a, PSG);
1546   PSG->timer_B = timer_alloc_ptr(timer_callback_b, PSG);
15471547#else
15481548   PSG->tim_A      = 0;
15491549   PSG->tim_B      = 0;
r1293r1294
15541554#ifdef LOG_CYM_FILE
15551555   cymfile = fopen("2151_.cym","wb");
15561556   if (cymfile)
1557      mame_timer_pulse ( MAME_TIME_IN_HZ(110), 0, cymfile_callback); /*110 Hz pulse timer*/
1557      timer_pulse ( ATTOTIME_IN_HZ(110), 0, cymfile_callback); /*110 Hz pulse timer*/
15581558   else
15591559      logerror("Could not create file 2151_.cym\n");
15601560#endif
r1293r1294
16261626   chip->irq_enable = 0;
16271627#ifdef USE_MAME_TIMERS
16281628   /* ASG 980324 -- reset the timers before writing to the registers */
1629   mame_timer_enable(chip->timer_A, 0);
1630   mame_timer_enable(chip->timer_B, 0);
1629   timer_enable(chip->timer_A, 0);
1630   timer_enable(chip->timer_B, 0);
16311631#else
16321632   chip->tim_A      = 0;
16331633   chip->tim_B      = 0;
src/emu/sound/scsp.c
r1293r1294
205205   int TimCnt[3];
206206
207207   // timers
208   mame_timer *timerA, *timerB, *timerC;
208   emu_timer *timerA, *timerB, *timerC;
209209
210210   // DMA stuff
211211   UINT32 scsp_dmea;
r1293r1294
524524      }
525525   }
526526
527   SCSP->timerA = mame_timer_alloc_ptr(timerA_cb, SCSP);
528   SCSP->timerB = mame_timer_alloc_ptr(timerB_cb, SCSP);
529   SCSP->timerC = mame_timer_alloc_ptr(timerC_cb, SCSP);
527   SCSP->timerA = timer_alloc_ptr(timerA_cb, SCSP);
528   SCSP->timerB = timer_alloc_ptr(timerB_cb, SCSP);
529   SCSP->timerC = timer_alloc_ptr(timerC_cb, SCSP);
530530
531531   for(i=0;i<0x400;++i)
532532   {
r1293r1294
720720               time = (44100 / SCSP->TimPris[0]) / (255-(SCSP->udata.data[0x18/2]&0xff));
721721               if (time)
722722               {
723                  mame_timer_adjust_ptr(SCSP->timerA, MAME_TIME_IN_HZ(time), time_never);
723                  timer_adjust_ptr(SCSP->timerA, ATTOTIME_IN_HZ(time), attotime_never);
724724               }
725725            }
726726         }
r1293r1294
739739               time = (44100 / SCSP->TimPris[1]) / (255-(SCSP->udata.data[0x1A/2]&0xff));
740740               if (time)
741741               {
742                  mame_timer_adjust_ptr(SCSP->timerB, MAME_TIME_IN_HZ(time), time_never);
742                  timer_adjust_ptr(SCSP->timerB, ATTOTIME_IN_HZ(time), attotime_never);
743743               }
744744            }
745745         }
r1293r1294
758758               time = (44100 / SCSP->TimPris[2]) / (255-(SCSP->udata.data[0x1C/2]&0xff));
759759               if (time)
760760               {
761                  mame_timer_adjust_ptr(SCSP->timerC, MAME_TIME_IN_HZ(time), time_never);
761                  timer_adjust_ptr(SCSP->timerC, ATTOTIME_IN_HZ(time), attotime_never);
762762               }
763763            }
764764         }
src/emu/sound/2610intf.c
r1293r1294
2121struct ym2610_info
2222{
2323   sound_stream *   stream;
24   mame_timer *   timer[2];
24   emu_timer *   timer[2];
2525   void *         chip;
2626   void *         psg;
2727   const struct YM2610interface *intf;
r1293r1294
8686   struct ym2610_info *info = param;
8787   if( count == 0 )
8888   {   /* Reset FM Timer */
89      mame_timer_enable(info->timer[c], 0);
89      timer_enable(info->timer[c], 0);
9090   }
9191   else
9292   {   /* Start FM Timer */
93      mame_time period = scale_up_mame_time(MAME_TIME_IN_HZ(clock), count);
93      attotime period = attotime_mul(ATTOTIME_IN_HZ(clock), count);
9494
95      if (!mame_timer_enable(info->timer[c], 1))
96         mame_timer_adjust_ptr(info->timer[c], period, time_zero);
95      if (!timer_enable(info->timer[c], 1))
96         timer_adjust_ptr(info->timer[c], period, attotime_zero);
9797   }
9898}
9999
r1293r1294
138138   if (!info->psg) return NULL;
139139
140140   /* Timer Handler set */
141   info->timer[0] = mame_timer_alloc_ptr(timer_callback_0, info);
142   info->timer[1] = mame_timer_alloc_ptr(timer_callback_1, info);
141   info->timer[0] = timer_alloc_ptr(timer_callback_0, info);
142   info->timer[1] = timer_alloc_ptr(timer_callback_1, info);
143143
144144   /* stream system initialize */
145145   info->stream = stream_create(0,2,rate,info,ym2610_stream_update);
r1293r1294
190190   if (!info->psg) return NULL;
191191
192192   /* Timer Handler set */
193   info->timer[0] =mame_timer_alloc_ptr(timer_callback_0, info);
194   info->timer[1] =mame_timer_alloc_ptr(timer_callback_1, info);
193   info->timer[0] =timer_alloc_ptr(timer_callback_0, info);
194   info->timer[1] =timer_alloc_ptr(timer_callback_1, info);
195195
196196   /* stream system initialize */
197197   info->stream = stream_create(0,2,rate,info,ym2610b_stream_update);
src/emu/sound/fmopl.c
r1293r1294
317317   UINT32 clock;               /* master clock  (Hz)           */
318318   UINT32 rate;               /* sampling rate (Hz)           */
319319   double freqbase;            /* frequency base               */
320   mame_time TimerBase;         /* Timer base time (==sampling time)*/
320   attotime TimerBase;         /* Timer base time (==sampling time)*/
321321} FM_OPL;
322322
323323
r1293r1294
12721272   /*logerror("freqbase=%f\n", OPL->freqbase);*/
12731273
12741274   /* Timer base time */
1275   OPL->TimerBase = scale_up_mame_time(MAME_TIME_IN_HZ(OPL->clock), 72);
1275   OPL->TimerBase = attotime_mul(ATTOTIME_IN_HZ(OPL->clock), 72);
12761276
12771277   /* make fnumber -> increment counter table */
12781278   for( i=0 ; i < 1024 ; i++ )
r1293r1294
15011501            /* timer 2 */
15021502            if(OPL->st[1] != st2)
15031503            {
1504               mame_time period = st2 ? scale_up_mame_time(OPL->TimerBase, OPL->T[1]) : time_zero;
1504               attotime period = st2 ? attotime_mul(OPL->TimerBase, OPL->T[1]) : attotime_zero;
15051505               OPL->st[1] = st2;
15061506               if (OPL->timer_handler) (OPL->timer_handler)(OPL->TimerParam,1,period);
15071507            }
15081508            /* timer 1 */
15091509            if(OPL->st[0] != st1)
15101510            {
1511               mame_time period = st1 ? scale_up_mame_time(OPL->TimerBase, OPL->T[0]) : time_zero;
1511               attotime period = st1 ? attotime_mul(OPL->TimerBase, OPL->T[0]) : attotime_zero;
15121512               OPL->st[0] = st1;
15131513               if (OPL->timer_handler) (OPL->timer_handler)(OPL->TimerParam,0,period);
15141514            }
r1293r1294
17491749#ifdef LOG_CYM_FILE
17501750   cymfile = fopen("3812_.cym","wb");
17511751   if (cymfile)
1752      mame_timer_pulse ( MAME_TIME_IN_HZ(110), 0, cymfile_callback); /*110 Hz pulse timer*/
1752      timer_pulse ( ATTOTIME_IN_HZ(110), 0, cymfile_callback); /*110 Hz pulse timer*/
17531753   else
17541754      logerror("Could not create file 3812_.cym\n");
17551755#endif
r1293r1294
21602160      }
21612161   }
21622162   /* reload timer */
2163   if (OPL->timer_handler) (OPL->timer_handler)(OPL->TimerParam,c,scale_up_mame_time(OPL->TimerBase, OPL->T[c]));
2163   if (OPL->timer_handler) (OPL->timer_handler)(OPL->TimerParam,c,attotime_mul(OPL->TimerBase, OPL->T[c]));
21642164   return OPL->status>>7;
21652165}
21662166
src/emu/sound/fmopl.h
r1293r1294
3030#endif
3131*/
3232
33typedef void (*OPL_TIMERHANDLER)(void *param,int timer,mame_time period);
33typedef void (*OPL_TIMERHANDLER)(void *param,int timer,attotime period);
3434typedef void (*OPL_IRQHANDLER)(void *param,int irq);
3535typedef void (*OPL_UPDATEHANDLER)(void *param,int min_interval_us);
3636typedef void (*OPL_PORTHANDLER_W)(void *param,unsigned char data);
src/emu/sound/ics2115.c
r1293r1294
5555
5656   struct {
5757      UINT8 scale, preset;
58      mame_timer *timer;
58      emu_timer *timer;
5959      UINT64 period;   /* in nsec */
6060   } timer[2];
6161
r1293r1294
195195   if(chip->timer[timer].period != period) {
196196      chip->timer[timer].period = period;
197197      if(period)
198         mame_timer_adjust_ptr(chip->timer[timer].timer, MAME_TIME_IN_NSEC(period), MAME_TIME_IN_NSEC(period));
198         timer_adjust_ptr(chip->timer[timer].timer, ATTOTIME_IN_NSEC(period), ATTOTIME_IN_NSEC(period));
199199      else
200         mame_timer_adjust_ptr(chip->timer[timer].timer, time_never, time_zero);
200         timer_adjust_ptr(chip->timer[timer].timer, attotime_never, attotime_zero);
201201   }
202202}
203203
r1293r1294
458458   chip->intf = config;
459459   chip->index = sndindex;
460460   chip->rom = memory_region(chip->intf->region);
461   chip->timer[0].timer = mame_timer_alloc_ptr(timer_cb_0, chip);
462   chip->timer[1].timer = mame_timer_alloc_ptr(timer_cb_1, chip);
461   chip->timer[0].timer = timer_alloc_ptr(timer_cb_0, chip);
462   chip->timer[1].timer = timer_alloc_ptr(timer_cb_1, chip);
463463   chip->ulaw = auto_malloc(256*sizeof(INT16));
464464   chip->stream = stream_create(0, 2, 33075, chip, update);
465465
r1293r1294
532532   chip->irq_en = 0;
533533   chip->irq_pend = 0;
534534   memset(chip->voice, 0, sizeof(chip->voice));
535   mame_timer_adjust_ptr(chip->timer[0].timer, time_never, time_zero);
536   mame_timer_adjust_ptr(chip->timer[1].timer, time_never, time_zero);
535   timer_adjust_ptr(chip->timer[0].timer, attotime_never, attotime_zero);
536   timer_adjust_ptr(chip->timer[1].timer, attotime_never, attotime_zero);
537537   chip->timer[0].period = 0;
538538   chip->timer[1].period = 0;
539539   recalc_irq(chip);
src/emu/sound/fm.c
r1293r1294
852852}
853853INLINE void FM_BUSY_SET(FM_ST *ST,int busyclock )
854854{
855   TIME_TYPE expiry_period = MULTIPLY_TIME_BY_INT(MAME_TIME_IN_HZ(ST->clock), busyclock * ST->timer_prescaler);
855   TIME_TYPE expiry_period = MULTIPLY_TIME_BY_INT(ATTOTIME_IN_HZ(ST->clock), busyclock * ST->timer_prescaler);
856856   ST->busy_expiry_time = ADD_TIMES(FM_GET_TIME_NOW(), expiry_period);
857857}
858858#else
r1293r1294
16271627{
16281628#if FM_BUSY_FLAG_SUPPORT
16291629   state_save_register_item(state_name, num, ST->busy_expiry_time.seconds );
1630   state_save_register_item(state_name, num, ST->busy_expiry_time.subseconds );
1630   state_save_register_item(state_name, num, ST->busy_expiry_time.attoseconds );
16311631#endif
16321632   state_save_register_item(state_name, num, ST->address );
16331633   state_save_register_item(state_name, num, ST->irq     );
src/emu/sound/fm.h
r1293r1294
3636/* --- external callback funstions for realtime update --- */
3737
3838#if FM_BUSY_FLAG_SUPPORT
39#define TIME_TYPE                mame_time
40#define UNDEFINED_TIME            time_zero
41#define FM_GET_TIME_NOW()          mame_timer_get_time()
42#define ADD_TIMES(t1, t2)          add_mame_times((t1), (t2))
43#define COMPARE_TIMES(t1, t2)      compare_mame_times((t1), (t2))
44#define MULTIPLY_TIME_BY_INT(t,i)   scale_up_mame_time(t, i)
39#define TIME_TYPE                attotime
40#define UNDEFINED_TIME            attotime_zero
41#define FM_GET_TIME_NOW()          timer_get_time()
42#define ADD_TIMES(t1, t2)          attotime_add((t1), (t2))
43#define COMPARE_TIMES(t1, t2)      attotime_compare((t1), (t2))
44#define MULTIPLY_TIME_BY_INT(t,i)   attotime_mul(t, i)
4545#endif
4646
4747#if BUILD_YM2203
src/emu/sound/2608intf.c
r1293r1294
2020struct ym2608_info
2121{
2222   sound_stream *   stream;
23   mame_timer *   timer[2];
23   emu_timer *   timer[2];
2424   void *         chip;
2525   void *         psg;
2626   const struct YM2608interface *intf;
r1293r1294
8686   struct ym2608_info *info = param;
8787   if( count == 0 )
8888   {   /* Reset FM Timer */
89      mame_timer_enable(info->timer[c], 0);
89      timer_enable(info->timer[c], 0);
9090   }
9191   else
9292   {   /* Start FM Timer */
93      mame_time period = scale_up_mame_time(MAME_TIME_IN_HZ(clock), count);
94      if (!mame_timer_enable(info->timer[c], 1))
95         mame_timer_adjust_ptr(info->timer[c], period, time_zero);
93      attotime period = attotime_mul(ATTOTIME_IN_HZ(clock), count);
94      if (!timer_enable(info->timer[c], 1))
95         timer_adjust_ptr(info->timer[c], period, attotime_zero);
9696   }
9797}
9898
r1293r1294
135135   if (!info->psg) return NULL;
136136
137137   /* Timer Handler set */
138   info->timer[0] = mame_timer_alloc_ptr(timer_callback_2608_0, info);
139   info->timer[1] = mame_timer_alloc_ptr(timer_callback_2608_1, info);
138   info->timer[0] = timer_alloc_ptr(timer_callback_2608_0, info);
139   info->timer[1] = timer_alloc_ptr(timer_callback_2608_1, info);
140140
141141   /* stream system initialize */
142142   info->stream = stream_create(0,2,rate,info,ym2608_stream_update);
src/emu/sound/ymf278b.c
r1293r1294
113113   INT32 pcm_l, pcm_r;
114114
115115   UINT8 timer_a_count, timer_b_count, enable, current_irq;
116   mame_timer *timer_a, *timer_b;
116   emu_timer *timer_a, *timer_b;
117117   int irq_line;
118118
119119   UINT8 port_A, port_B, port_C;
r1293r1294
376376{
377377   if(chip->enable & 1)
378378   {
379      mame_time period = MAME_TIME_IN_NSEC((256-chip->timer_a_count) * 80800);
379      attotime period = ATTOTIME_IN_NSEC((256-chip->timer_a_count) * 80800);
380380
381381      if (chip->clock != YMF278B_STD_CLOCK)
382         period = scale_down_mame_time(scale_up_mame_time(period, chip->clock), YMF278B_STD_CLOCK);
382         period = attotime_div(attotime_mul(period, chip->clock), YMF278B_STD_CLOCK);
383383
384      mame_timer_adjust_ptr(chip->timer_a, period, period);
384      timer_adjust_ptr(chip->timer_a, period, period);
385385   }
386386   else
387      mame_timer_adjust_ptr(chip->timer_a, time_never, time_zero);
387      timer_adjust_ptr(chip->timer_a, attotime_never, attotime_zero);
388388}
389389
390390static void ymf278b_timer_b_reset(YMF278BChip *chip)
391391{
392392   if(chip->enable & 2)
393393   {
394      mame_time period = MAME_TIME_IN_NSEC((256-chip->timer_b_count) * 323100);
394      attotime period = ATTOTIME_IN_NSEC((256-chip->timer_b_count) * 323100);
395395
396396      if (chip->clock != YMF278B_STD_CLOCK)
397         period = scale_down_mame_time(scale_up_mame_time(period, chip->clock), YMF278B_STD_CLOCK);
397         period = attotime_div(attotime_mul(period, chip->clock), YMF278B_STD_CLOCK);
398398
399      mame_timer_adjust_ptr(chip->timer_a, period, period);
399      timer_adjust_ptr(chip->timer_a, period, period);
400400   }
401401   else
402      mame_timer_adjust_ptr(chip->timer_b, time_never, time_zero);
402      timer_adjust_ptr(chip->timer_b, attotime_never, attotime_zero);
403403}
404404
405405static void ymf278b_A_w(YMF278BChip *chip, UINT8 reg, UINT8 data)
r1293r1294
670670{
671671   chip->rom = rom;
672672   chip->irq_callback = cb;
673   chip->timer_a = mame_timer_alloc_ptr(ymf278b_timer_a_tick, chip);
674   chip->timer_b = mame_timer_alloc_ptr(ymf278b_timer_b_tick, chip);
673   chip->timer_a = timer_alloc_ptr(ymf278b_timer_a_tick, chip);
674   chip->timer_b = timer_alloc_ptr(ymf278b_timer_b_tick, chip);
675675   chip->irq_line = CLEAR_LINE;
676676   chip->clock = clock;
677677
src/emu/sound/2151intf.c
r1293r1294
1616struct ym2151_info
1717{
1818   sound_stream *   stream;
19   mame_timer *   timer[2];
19   emu_timer *   timer[2];
2020   void *         chip;
2121   const struct YM2151interface *intf;
2222};
src/emu/sound/k053260.c
r1293r1294
222222
223223   /* setup SH1 timer if necessary */
224224   if ( ic->intf->irq )
225      mame_timer_pulse( scale_up_mame_time(MAME_TIME_IN_HZ(clock), 32), 0, ic->intf->irq );
225      timer_pulse( attotime_mul(ATTOTIME_IN_HZ(clock), 32), 0, ic->intf->irq );
226226
227227    return ic;
228228}
src/emu/sound/2203intf.c
r1293r1294
88struct ym2203_info
99{
1010   sound_stream *   stream;
11   mame_timer *   timer[2];
11   emu_timer *   timer[2];
1212   void *         chip;
1313   void *         psg;
1414   const struct YM2203interface *intf;
r1293r1294
8080   struct ym2203_info *info = param;
8181   if( count == 0 )
8282   {   /* Reset FM Timer */
83      mame_timer_enable(info->timer[c], 0);
83      timer_enable(info->timer[c], 0);
8484   }
8585   else
8686   {   /* Start FM Timer */
87      mame_time period = scale_up_mame_time(MAME_TIME_IN_HZ(clock), count);
88      if (!mame_timer_enable(info->timer[c], 1))
89         mame_timer_adjust_ptr(info->timer[c], period, time_zero);
87      attotime period = attotime_mul(ATTOTIME_IN_HZ(clock), count);
88      if (!timer_enable(info->timer[c], 1))
89         timer_adjust_ptr(info->timer[c], period, attotime_zero);
9090   }
9191}
9292
r1293r1294
119119   if (!info->psg) return NULL;
120120
121121   /* Timer Handler set */
122   info->timer[0] = mame_timer_alloc_ptr(timer_callback_2203_0, info);
123   info->timer[1] = mame_timer_alloc_ptr(timer_callback_2203_1, info);
122   info->timer[0] = timer_alloc_ptr(timer_callback_2203_0, info);
123   info->timer[1] = timer_alloc_ptr(timer_callback_2203_1, info);
124124
125125   /* stream system initialize */
126126   info->stream = stream_create(0,1,rate,info,ym2203_stream_update);
src/emu/sound/es5503.c
r1293r1294
5555
5656   UINT32 accumulator;
5757   UINT8  irqpend;
58   mame_timer *timer;
58   emu_timer *timer;
5959} ES5503Osc;
6060
6161typedef struct
r1293r1294
262262      chip->oscillators[osc].irqpend = 0;
263263      chip->oscillators[osc].accumulator = 0;
264264
265      chip->oscillators[osc].timer = mame_timer_alloc_ptr(es5503_timer_cb, &chip->oscillators[osc]);
265      chip->oscillators[osc].timer = timer_alloc_ptr(es5503_timer_cb, &chip->oscillators[osc]);
266266      chip->oscillators[osc].chip = (void *)chip;
267267   }
268268
r1293r1294
436436                  int resshift = resshifts[chip->oscillators[osc].resolution] - chip->oscillators[osc].wavetblsize;
437437                  UINT32 sizemask = accmasks[chip->oscillators[osc].wavetblsize];
438438                  UINT32 ramptr, altram;
439                  mame_time period;
439                  attotime period;
440440
441441                  run = 1;
442442                  length = 0;
r1293r1294
458458                  }
459459
460460                  // ok, we run for this long
461                  period = scale_up_mame_time(MAME_TIME_IN_HZ(chip->output_rate), length);
461                  period = attotime_mul(ATTOTIME_IN_HZ(chip->output_rate), length);
462462
463                  mame_timer_adjust_ptr(chip->oscillators[osc].timer, period, period);
463                  timer_adjust_ptr(chip->oscillators[osc].timer, period, period);
464464               }
465465            }
466466            else if (!(chip->oscillators[osc].control & 1) && (data&1))
467467            {
468468               // key off
469               mame_timer_adjust_ptr(chip->oscillators[osc].timer, time_never, time_never);
469               timer_adjust_ptr(chip->oscillators[osc].timer, attotime_never, attotime_never);
470470            }
471471
472472            chip->oscillators[osc].control = data;
src/emu/sound/nes_apu.c
r1293r1294
676676   memset(info, 0, sizeof(*info));
677677
678678   /* Initialize global variables */
679   info->samps_per_sync = rate / SUBSECONDS_TO_HZ(Machine->screen[0].refresh);
679   info->samps_per_sync = rate / ATTOSECONDS_TO_HZ(Machine->screen[0].refresh);
680680   info->buffer_size = info->samps_per_sync;
681   info->real_rate = info->samps_per_sync * SUBSECONDS_TO_HZ(Machine->screen[0].refresh);
681   info->real_rate = info->samps_per_sync * ATTOSECONDS_TO_HZ(Machine->screen[0].refresh);
682682   info->apu_incsize = (float) (clock / (float) info->real_rate);
683683
684684   /* Use initializer calls */
src/emu/sound/262intf.c
r1293r1294
1414struct ymf262_info
1515{
1616   sound_stream *   stream;
17   mame_timer *   timer[2];
17   emu_timer *   timer[2];
1818   void *         chip;
1919   const struct YMF262interface *intf;
2020};
r1293r1294
4040   YMF262TimerOver(info->chip, 1);
4141}
4242
43static void timer_handler_262(void *param,int timer, mame_time period)
43static void timer_handler_262(void *param,int timer, attotime period)
4444{
4545   struct ymf262_info *info = param;
46   if( compare_mame_times(period, time_zero) == 0 )
46   if( attotime_compare(period, attotime_zero) == 0 )
4747   {   /* Reset FM Timer */
48      mame_timer_enable(info->timer[timer], 0);
48      timer_enable(info->timer[timer], 0);
4949   }
5050   else
5151   {   /* Start FM Timer */
52      mame_timer_adjust_ptr(info->timer[timer], period, time_zero);
52      timer_adjust_ptr(info->timer[timer], period, attotime_zero);
5353   }
5454}
5555
r1293r1294
8989   YMF262SetIRQHandler   (info->chip, IRQHandler_262, info);
9090   YMF262SetUpdateHandler(info->chip, _stream_update, info);
9191
92   info->timer[0] = mame_timer_alloc_ptr(timer_callback_262_0, info);
93   info->timer[1] = mame_timer_alloc_ptr(timer_callback_262_1, info);
92   info->timer[0] = timer_alloc_ptr(timer_callback_262_0, info);
93   info->timer[1] = timer_alloc_ptr(timer_callback_262_1, info);
9494
9595   return info;
9696}
src/emu/ui.c
r1293r1294
11471147            Machine->screen[0].visarea.max_x - Machine->screen[0].visarea.min_x + 1,
11481148            Machine->screen[0].visarea.max_y - Machine->screen[0].visarea.min_y + 1,
11491149            (Machine->gamedrv->flags & ORIENTATION_SWAP_XY) ? "V" : "H",
1150            SUBSECONDS_TO_HZ(Machine->screen[0].refresh));
1150            ATTOSECONDS_TO_HZ(Machine->screen[0].refresh));
11511151   return bufptr - buffer;
11521152}
11531153
r1293r1294
17481748
17491749static INT32 slider_refresh(INT32 newval, char *buffer, int arg)
17501750{
1751   double defrefresh = SUBSECONDS_TO_HZ(Machine->drv->screen[arg].defstate.refresh);
1751   double defrefresh = ATTOSECONDS_TO_HZ(Machine->drv->screen[arg].defstate.refresh);
17521752   double refresh;
17531753
17541754   if (buffer != NULL)
17551755   {
17561756      screen_state *state = &Machine->screen[arg];
1757      video_screen_configure(arg, state->width, state->height, &state->visarea, HZ_TO_SUBSECONDS(defrefresh + (double)newval * 0.001));
1758      sprintf(buffer, "Screen %d %s %.3f", arg, ui_getstring(UI_refresh_rate), SUBSECONDS_TO_HZ(Machine->screen[arg].refresh));
1757      video_screen_configure(arg, state->width, state->height, &state->visarea, HZ_TO_ATTOSECONDS(defrefresh + (double)newval * 0.001));
1758      sprintf(buffer, "Screen %d %s %.3f", arg, ui_getstring(UI_refresh_rate), ATTOSECONDS_TO_HZ(Machine->screen[arg].refresh));
17591759   }
1760   refresh = SUBSECONDS_TO_HZ(Machine->screen[arg].refresh);
1760   refresh = ATTOSECONDS_TO_HZ(Machine->screen[arg].refresh);
17611761   return floor((refresh - defrefresh) * 1000.0f + 0.5f);
17621762}
17631763
src/emu/profiler.c
r1293r1294
173173      }
174174      if (computed || showdelay[i])
175175      {
176         if (computed) showdelay[i] = SUBSECONDS_TO_HZ(Machine->screen[0].refresh);
176         if (computed) showdelay[i] = ATTOSECONDS_TO_HZ(Machine->screen[0].refresh);
177177         showdelay[i]--;
178178
179179         if (i < PROFILER_PROFILER)
src/emu/sound.c
r1293r1294
3737***************************************************************************/
3838
3939#define MAX_MIXER_CHANNELS      100
40#define SOUND_UPDATE_FREQUENCY   MAME_TIME_IN_HZ(50)
40#define SOUND_UPDATE_FREQUENCY   ATTOTIME_IN_HZ(50)
4141
4242
4343
r1293r1294
9191    GLOBAL VARIABLES
9292***************************************************************************/
9393
94static mame_timer *sound_update_timer;
94static emu_timer *sound_update_timer;
9595
9696static int totalsnd;
9797static sound_info sound[MAX_SOUND];
r1293r1294
176176
177177void sound_init(running_machine *machine)
178178{
179   mame_time update_frequency = SOUND_UPDATE_FREQUENCY;
179   attotime update_frequency = SOUND_UPDATE_FREQUENCY;
180180   const char *filename;
181181
182182   /* handle -nosound */
r1293r1294
194194   finalmix = auto_malloc(Machine->sample_rate * sizeof(*finalmix));
195195
196196   /* allocate a global timer for sound timing */
197   sound_update_timer = mame_timer_alloc(sound_update);
198   mame_timer_adjust(sound_update_timer, update_frequency, 0, update_frequency);
197   sound_update_timer = timer_alloc(sound_update);
198   timer_adjust(sound_update_timer, update_frequency, 0, update_frequency);
199199
200200   /* initialize the streams engine */
201201   VPRINTF(("streams_init\n"));
202   streams_init(machine, update_frequency.subseconds);
202   streams_init(machine, update_frequency.attoseconds);
203203
204204   /* now start up the sound chips and tag their streams */
205205   VPRINTF(("start_sound_chips\n"));
src/emu/driver.c
r1293r1294
5151{
5252   /* initialize the tag on the first screen */
5353   memset(output, 0, sizeof(*output));
54   output->watchdog_time = time_zero;
54   output->watchdog_time = attotime_zero;
5555
5656   /* keeping this function allows us to pre-init the driver before constructing it */
5757   (*constructor)(output);
r1293r1294
6262
6363   /* if no screens, set a dummy refresh for the main screen */
6464   if (output->screen[0].tag == NULL)
65      output->screen[0].defstate.refresh = HZ_TO_SUBSECONDS(60);
65      output->screen[0].defstate.refresh = HZ_TO_ATTOSECONDS(60);
6666}
6767
6868
src/emu/driver.h
r1293r1294
109109*/
110110
111111/* The default is to have no VBLANK timing -- this is historical, and a bad idea */
112#define DEFAULT_60HZ_VBLANK_DURATION      USEC_TO_SUBSECONDS(0)
113#define DEFAULT_30HZ_VBLANK_DURATION      USEC_TO_SUBSECONDS(0)
112#define DEFAULT_60HZ_VBLANK_DURATION      ATTOSECONDS_IN_USEC(0)
113#define DEFAULT_30HZ_VBLANK_DURATION      ATTOSECONDS_IN_USEC(0)
114114
115115/* If you use IPT_VBLANK, you need a duration different from 0 */
116#define DEFAULT_REAL_60HZ_VBLANK_DURATION   USEC_TO_SUBSECONDS(2500)
117#define DEFAULT_REAL_30HZ_VBLANK_DURATION   USEC_TO_SUBSECONDS(2500)
116#define DEFAULT_REAL_60HZ_VBLANK_DURATION   ATTOSECONDS_IN_USEC(2500)
117#define DEFAULT_REAL_30HZ_VBLANK_DURATION   ATTOSECONDS_IN_USEC(2500)
118118
119119
120120
r1293r1294
184184   cpu_config         cpu[MAX_CPU];            /* array of CPUs in the system */
185185   UINT32            cpu_slices_per_frame;      /* number of times to interleave execution per frame */
186186   INT32            watchdog_vblank_count;      /* number of VBLANKs until the watchdog kills us */
187   mame_time         watchdog_time;            /* length of time until the watchdog kills us */
187   attotime         watchdog_time;            /* length of time until the watchdog kills us */
188188
189189   void             (*machine_start)(running_machine *machine);      /* one-time machine start callback */
190190   void             (*machine_reset)(running_machine *machine);      /* machine reset callback */
r1293r1294
328328   if (cpu)                                             \
329329   {                                                   \
330330      cpu->timed_interrupt = func;                           \
331      cpu->timed_interrupt_period = HZ_TO_SUBSECONDS(rate);         \
331      cpu->timed_interrupt_period = HZ_TO_ATTOSECONDS(rate);         \
332332   }                                                   \
333333
334334
r1293r1294
408408   screen->defstate.format = (_format);                        \
409409
410410#define MDRV_SCREEN_RAW_PARAMS(pixclock, htotal, hbend, hbstart, vtotal, vbend, vbstart) \
411   screen->defstate.refresh = HZ_TO_SUBSECONDS(pixclock) * (htotal) * (vtotal); \
411   screen->defstate.refresh = HZ_TO_ATTOSECONDS(pixclock) * (htotal) * (vtotal); \
412412   screen->defstate.vblank = (screen->defstate.refresh / (vtotal)) * ((vtotal) - ((vbstart) - (vbend))); \
413413   screen->defstate.width = (htotal);                           \
414414   screen->defstate.height = (vtotal);                           \
r1293r1294
418418   screen->defstate.visarea.max_y = (vbstart) - 1;                  \
419419
420420#define MDRV_SCREEN_REFRESH_RATE(rate)                           \
421   screen->defstate.refresh = HZ_TO_SUBSECONDS(rate);               \
421   screen->defstate.refresh = HZ_TO_ATTOSECONDS(rate);               \
422422
423423#define MDRV_SCREEN_VBLANK_TIME(time)                           \
424   screen->defstate.vblank = time;            \
424   screen->defstate.vblank = time;                              \
425425   screen->defstate.oldstyle_vblank_supplied = 1;                  \
426426
427427#define MDRV_SCREEN_SIZE(_width, _height)                        \
src/emu/timer.c
r1293r1294
4242    TYPE DEFINITIONS
4343***************************************************************************/
4444
45/* in timer.h: typedef struct _mame_timer mame_timer; */
46struct _mame_timer
45/* in timer.h: typedef struct _emu_timer emu_timer; */
46struct _emu_timer
4747{
48   mame_timer *   next;
49   mame_timer *   prev;
48   emu_timer *   next;
49   emu_timer *   prev;
5050   void          (*callback)(running_machine *, int);
5151   void         (*callback_ptr)(running_machine *, void *);
5252   int          callback_param;
r1293r1294
5757   UINT8          enabled;
5858   UINT8          temporary;
5959   UINT8         ptr;
60   mame_time       period;
61   mame_time       start;
62   mame_time       expire;
60   attotime       period;
61   attotime       start;
62   attotime       expire;
6363};
6464
6565
r1293r1294
6969***************************************************************************/
7070
7171/* conversion constants */
72subseconds_t subseconds_per_cycle[MAX_CPU];
72attoseconds_t attoseconds_per_cycle[MAX_CPU];
7373UINT32 cycles_per_second[MAX_CPU];
7474
7575/* list of active timers */
76static mame_timer timers[MAX_TIMERS];
77static mame_timer *timer_head;
78static mame_timer *timer_free_head;
79static mame_timer *timer_free_tail;
76static emu_timer timers[MAX_TIMERS];
77static emu_timer *timer_head;
78static emu_timer *timer_free_head;
79static emu_timer *timer_free_tail;
8080
8181/* other internal states */
82static mame_time global_basetime;
83static mame_timer *callback_timer;
82static attotime global_basetime;
83static emu_timer *callback_timer;
8484static int callback_timer_modified;
85static mame_time callback_timer_expire_time;
85static attotime callback_timer_expire_time;
8686
87/* other constant times */
88mame_time time_zero;
89mame_time time_never;
9087
9188
92
9389/***************************************************************************
9490    FUNCTION PROTOTYPES
9591***************************************************************************/
9692
9793static void timer_postload(void);
9894static void timer_logtimers(void);
99static void timer_remove(mame_timer *which);
95static void timer_remove(emu_timer *which);
10096
10197
10298
r1293r1294
108104    get_current_time - return the current time
109105-------------------------------------------------*/
110106
111INLINE mame_time get_current_time(void)
107INLINE attotime get_current_time(void)
112108{
113109   int activecpu;
114110
r1293r1294
130126    timer_new - allocate a new timer
131127-------------------------------------------------*/
132128
133INLINE mame_timer *timer_new(void)
129INLINE emu_timer *timer_new(void)
134130{
135   mame_timer *timer;
131   emu_timer *timer;
136132
137133   /* remove an empty entry */
138134   if (!timer_free_head)
r1293r1294
154150    the list at the appropriate location
155151-------------------------------------------------*/
156152
157INLINE void timer_list_insert(mame_timer *timer)
153INLINE void timer_list_insert(emu_timer *timer)
158154{
159   mame_time expire = timer->enabled ? timer->expire : time_never;
160   mame_timer *t, *lt = NULL;
155   attotime expire = timer->enabled ? timer->expire : attotime_never;
156   emu_timer *t, *lt = NULL;
161157
162158   /* sanity checks for the debug build */
163159   #ifdef MAME_DEBUG
r1293r1294
179175   for (t = timer_head; t; lt = t, t = t->next)
180176   {
181177      /* if the current list entry expires after us, we should be inserted before it */
182      if (compare_mame_times(t->expire, expire) > 0)
178      if (attotime_compare(t->expire, expire) > 0)
183179      {
184180         /* link the new guy in before the current list entry */
185181         timer->prev = t->prev;
r1293r1294
209205    linked list
210206-------------------------------------------------*/
211207
212INLINE void timer_list_remove(mame_timer *timer)
208INLINE void timer_list_remove(emu_timer *timer)
213209{
214210   /* sanity checks for the debug build */
215211   #ifdef MAME_DEBUG
216212   {
217      mame_timer *t;
213      emu_timer *t;
218214
219215      /* loop over the timer list */
220216      for (t = timer_head; t && t != timer; t = t->next) ;
r1293r1294
246242{
247243   int i;
248244
249   /* init the constant times */
250   time_zero.seconds = time_zero.subseconds = 0;
251   time_never.seconds = MAX_SECONDS;
252   time_never.subseconds = MAX_SUBSECONDS - 1;
253
254245   /* we need to wait until the first call to timer_cyclestorun before using real CPU times */
255   global_basetime = time_zero;
246   global_basetime = attotime_zero;
256247   callback_timer = NULL;
257248   callback_timer_modified = FALSE;
258249
259250   /* register with the save state system */
260251   state_save_push_tag(0);
261252   state_save_register_item("timer", 0, global_basetime.seconds);
262   state_save_register_item("timer", 0, global_basetime.subseconds);
253   state_save_register_item("timer", 0, global_basetime.attoseconds);
263254   state_save_register_func_postload(timer_postload);
264255   state_save_pop_tag();
265256
r1293r1294
293284***************************************************************************/
294285
295286/*-------------------------------------------------
296    mame_timer_next_fire_time - return the
287    timer_next_fire_time - return the
297288    time when the next timer will fire
298289-------------------------------------------------*/
299290
300mame_time mame_timer_next_fire_time(void)
291attotime timer_next_fire_time(void)
301292{
302293   return timer_head->expire;
303294}
r1293r1294
308299    time; this is also where we fire the timers
309300-------------------------------------------------*/
310301
311void mame_timer_set_global_time(mame_time newbase)
302void timer_set_global_time(attotime newbase)
312303{
313   mame_timer *timer;
304   emu_timer *timer;
314305
315306   /* set the new global offset */
316307   global_basetime = newbase;
317308
318   LOG(("mame_timer_set_global_time: new=%.9f head->expire=%.9f\n", mame_time_to_double(newbase), mame_time_to_double(timer_head->expire)));
309   LOG(("timer_set_global_time: new=%s head->expire=%s\n", attotime_string(newbase), attotime_string(timer_head->expire)));
319310
320311   /* now process any timers that are overdue */
321   while (compare_mame_times(timer_head->expire, global_basetime) <= 0)
312   while (attotime_compare(timer_head->expire, global_basetime) <= 0)
322313   {
323314      int was_enabled = timer_head->enabled;
324315
325316      /* if this is a one-shot timer, disable it now */
326317      timer = timer_head;
327      if (compare_mame_times(timer->period, time_zero) == 0 || compare_mame_times(timer->period, time_never) == 0)
318      if (attotime_compare(timer->period, attotime_zero) == 0 || attotime_compare(timer->period, attotime_never) == 0)
328319         timer->enabled = FALSE;
329320
330321      /* set the global state of which callback we're in */
r1293r1294
337328      {
338329         if (!timer->ptr && timer->callback)
339330         {
340            LOG(("Timer %s:%d[%s] fired (expire=%.9f)\n", timer->file, timer->line, timer->func, mame_time_to_double(timer->expire)));
331            LOG(("Timer %s:%d[%s] fired (expire=%s)\n", timer->file, timer->line, timer->func, attotime_string(timer->expire, 9)));
341332            profiler_mark(PROFILER_TIMER_CALLBACK);
342333            (*timer->callback)(Machine, timer->callback_param);
343334            profiler_mark(PROFILER_END);
344335         }
345336         else if (timer->ptr && timer->callback_ptr)
346337         {
347            LOG(("Timer %s:%d[%s] fired (expire=%.9f)\n", timer->file, timer->line, timer->func, mame_time_to_double(timer->expire)));
338            LOG(("Timer %s:%d[%s] fired (expire=%s)\n", timer->file, timer->line, timer->func, attotime_string(timer->expire, 9)));
348339            profiler_mark(PROFILER_TIMER_CALLBACK);
349340            (*timer->callback_ptr)(Machine, timer->callback_ptr_param);
350341            profiler_mark(PROFILER_END);
r1293r1294
365356         else
366357         {
367358            timer->start = timer->expire;
368            timer->expire = add_mame_times(timer->expire, timer->period);
359            timer->expire = attotime_add(timer->expire, timer->period);
369360
370361            timer_list_remove(timer);
371362            timer_list_insert(timer);
r1293r1294
385376    the save state system
386377-------------------------------------------------*/
387378
388static void timer_register_save(mame_timer *timer)
379static void timer_register_save(emu_timer *timer)
389380{
390381   char buf[256];
391382   int count = 0;
392   mame_timer *t;
383   emu_timer *t;
393384
394385   /* find other timers that match our func name */
395386   for (t = timer_head; t; t = t->next)
r1293r1294
404395   state_save_register_item(buf, count, timer->callback_param);
405396   state_save_register_item(buf, count, timer->enabled);
406397   state_save_register_item(buf, count, timer->period.seconds);
407   state_save_register_item(buf, count, timer->period.subseconds);
398   state_save_register_item(buf, count, timer->period.attoseconds);
408399   state_save_register_item(buf, count, timer->start.seconds);
409   state_save_register_item(buf, count, timer->start.subseconds);
400   state_save_register_item(buf, count, timer->start.attoseconds);
410401   state_save_register_item(buf, count, timer->expire.seconds);
411   state_save_register_item(buf, count, timer->expire.subseconds);
402   state_save_register_item(buf, count, timer->expire.attoseconds);
412403   state_save_pop_tag();
413404}
414405
r1293r1294
419410
420411static void timer_postload(void)
421412{
422   mame_timer *privlist = NULL;
423   mame_timer *t;
413   emu_timer *privlist = NULL;
414   emu_timer *t;
424415
425416   /* remove all timers and make a private list */
426417   while (timer_head)
r1293r1294
457448
458449int timer_count_anonymous(void)
459450{
460   mame_timer *t;
451   emu_timer *t;
461452   int count = 0;
462453
463454   logerror("timer_count_anonymous:\n");
r1293r1294
483474    isn't primed yet
484475-------------------------------------------------*/
485476
486INLINE mame_timer *_mame_timer_alloc_common(void (*callback)(running_machine *, int), void (*callback_ptr)(running_machine *, void *), void *param, const char *file, int line, const char *func, int temp)
477INLINE emu_timer *_timer_alloc_common(void (*callback)(running_machine *, int), void (*callback_ptr)(running_machine *, void *), void *param, const char *file, int line, const char *func, int temp)
487478{
488   mame_time time = get_current_time();
489   mame_timer *timer = timer_new();
479   attotime time = get_current_time();
480   emu_timer *timer = timer_new();
490481
491482   /* fill in the record */
492483   timer->callback = callback;
r1293r1294
496487   timer->enabled = FALSE;
497488   timer->temporary = temp;
498489   timer->ptr = (callback_ptr != NULL);
499   timer->period = time_zero;
490   timer->period = attotime_zero;
500491   timer->file = file;
501492   timer->line = line;
502493   timer->func = func;
503494
504495   /* compute the time of the next firing and insert into the list */
505496   timer->start = time;
506   timer->expire = time_never;
497   timer->expire = attotime_never;
507498   timer_list_insert(timer);
508499
509500   /* if we're not temporary, register ourselve with the save state system */
r1293r1294
517508   return timer;
518509}
519510
520mame_timer *_mame_timer_alloc(void (*callback)(running_machine *, int), const char *file, int line, const char *func)
511emu_timer *_timer_alloc(void (*callback)(running_machine *, int), const char *file, int line, const char *func)
521512{
522   return _mame_timer_alloc_common(callback, NULL, NULL, file, line, func, FALSE);
513   return _timer_alloc_common(callback, NULL, NULL, file, line, func, FALSE);
523514}
524515
525mame_timer *_mame_timer_alloc_ptr(void (*callback_ptr)(running_machine *, void *), void *param, const char *file, int line, const char *func)
516emu_timer *_timer_alloc_ptr(void (*callback_ptr)(running_machine *, void *), void *param, const char *file, int line, const char *func)
526517{
527   return _mame_timer_alloc_common(NULL, callback_ptr, param, file, line, func, FALSE);
518   return _timer_alloc_common(NULL, callback_ptr, param, file, line, func, FALSE);
528519}
529520
530521
r1293r1294
533524    system
534525-------------------------------------------------*/
535526
536static void timer_remove(mame_timer *which)
527static void timer_remove(emu_timer *which)
537528{
538529   /* if this is a callback timer, note that */
539530   if (which == callback_timer)
r1293r1294
563554    fire periodically
564555-------------------------------------------------*/
565556
566INLINE void mame_timer_adjust_common(mame_timer *which, mame_time duration, INT32 param, mame_time period)
557INLINE void timer_adjust_common(emu_timer *which, attotime duration, INT32 param, attotime period)
567558{
568   mame_time time = get_current_time();
559   attotime time = get_current_time();
569560
570561   /* if this is the callback timer, mark it modified */
571562   if (which == callback_timer)
r1293r1294
577568
578569   /* clamp negative times to 0 */
579570   if (duration.seconds < 0)
580      duration = time_zero;
571      duration = attotime_zero;
581572
582573   /* set the start and expire times */
583574   which->start = time;
584   which->expire = add_mame_times(time, duration);
575   which->expire = attotime_add(time, duration);
585576   which->period = period;
586577
587578   /* remove and re-insert the timer in its new order */
r1293r1294
589580   timer_list_insert(which);
590581
591582   /* if this was inserted as the head, abort the current timeslice and resync */
592   LOG(("timer_adjust %s.%s:%d to expire @ %.9f\n", which->file, which->func, which->line, mame_time_to_double(which->expire)));
583   LOG(("timer_adjust %s.%s:%d to expire @ %s\n", which->file, which->func, which->line, attotime_string(which->expire, 9)));
593584   if (which == timer_head && cpu_getexecutingcpu() >= 0)
594585      activecpu_abort_timeslice();
595586}
596587
597void mame_timer_adjust(mame_timer *which, mame_time duration, INT32 param, mame_time period)
588void timer_adjust(emu_timer *which, attotime duration, INT32 param, attotime period)
598589{
599590   if (which->ptr)
600      fatalerror("mame_timer_adjust called on a ptr timer!");
601   mame_timer_adjust_common(which, duration, param, period);
591      fatalerror("timer_adjust called on a ptr timer!");
592   timer_adjust_common(which, duration, param, period);
602593}
603594
604void mame_timer_adjust_ptr(mame_timer *which, mame_time duration, mame_time period)
595void timer_adjust_ptr(emu_timer *which, attotime duration, attotime period)
605596{
606597   if (!which->ptr)
607      fatalerror("mame_timer_adjust_ptr called on a non-ptr timer!");
608   mame_timer_adjust_common(which, duration, 0, period);
598      fatalerror("timer_adjust_ptr called on a non-ptr timer!");
599   timer_adjust_common(which, duration, 0, period);
609600}
610601
611602
r1293r1294
620611    period
621612-------------------------------------------------*/
622613
623void _mame_timer_pulse(mame_time period, INT32 param, void (*callback)(running_machine *, int), const char *file, int line, const char *func)
614void _timer_pulse(attotime period, INT32 param, void (*callback)(running_machine *, int), const char *file, int line, const char *func)
624615{
625   mame_timer *timer = _mame_timer_alloc_common(callback, NULL, NULL, file, line, func, FALSE);
616   emu_timer *timer = _timer_alloc_common(callback, NULL, NULL, file, line, func, FALSE);
626617
627618   /* adjust to our liking */
628   mame_timer_adjust(timer, period, param, period);
619   timer_adjust(timer, period, param, period);
629620}
630621
631void _mame_timer_pulse_ptr(mame_time period, void *param, void (*callback)(running_machine *, void *), const char *file, int line, const char *func)
622void _timer_pulse_ptr(attotime period, void *param, void (*callback)(running_machine *, void *), const char *file, int line, const char *func)
632623{
633   mame_timer *timer = _mame_timer_alloc_common(NULL, callback, param, file, line, func, FALSE);
624   emu_timer *timer = _timer_alloc_common(NULL, callback, param, file, line, func, FALSE);
634625
635626   /* adjust to our liking */
636   mame_timer_adjust_ptr(timer, period, period);
627   timer_adjust_ptr(timer, period, period);
637628}
638629
639630
r1293r1294
642633    calls the callback after the given duration
643634-------------------------------------------------*/
644635
645void _mame_timer_set(mame_time duration, INT32 param, void (*callback)(running_machine *, int), const char *file, int line, const char *func)
636void _timer_set(attotime duration, INT32 param, void (*callback)(running_machine *, int), const char *file, int line, const char *func)
646637{
647   mame_timer *timer = _mame_timer_alloc_common(callback, NULL, NULL, file, line, func, TRUE);
638   emu_timer *timer = _timer_alloc_common(callback, NULL, NULL, file, line, func, TRUE);
648639
649640   /* adjust to our liking */
650   mame_timer_adjust(timer, duration, param, time_zero);
641   timer_adjust(timer, duration, param, attotime_zero);
651642}
652643
653void _mame_timer_set_ptr(mame_time duration, void *param, void (*callback)(running_machine *, void *), const char *file, int line, const char *func)
644void _timer_set_ptr(attotime duration, void *param, void (*callback)(running_machine *, void *), const char *file, int line, const char *func)
654645{
655   mame_timer *timer = _mame_timer_alloc_common(NULL, callback, param, file, line, func, TRUE);
646   emu_timer *timer = _timer_alloc_common(NULL, callback, param, file, line, func, TRUE);
656647
657648   /* adjust to our liking */
658   mame_timer_adjust_ptr(timer, duration, time_zero);
649   timer_adjust_ptr(timer, duration, attotime_zero);
659650}
660651
661652
r1293r1294
668659    timer_reset - reset the timing on a timer
669660-------------------------------------------------*/
670661
671void mame_timer_reset(mame_timer *which, mame_time duration)
662void timer_reset(emu_timer *which, attotime duration)
672663{
673664   /* adjust the timer */
674665   if (!which->ptr)
675      mame_timer_adjust(which, duration, which->callback_param, which->period);
666      timer_adjust(which, duration, which->callback_param, which->period);
676667   else
677      mame_timer_adjust_ptr(which, duration, which->period);
668      timer_adjust_ptr(which, duration, which->period);
678669}
679670
680671
r1293r1294
682673    timer_enable - enable/disable a timer
683674-------------------------------------------------*/
684675
685int mame_timer_enable(mame_timer *which, int enable)
676int timer_enable(emu_timer *which, int enable)
686677{
687678   int old;
688679
r1293r1294
703694    enabled
704695-------------------------------------------------*/
705696
706int mame_timer_enabled(mame_timer *which)
697int timer_enabled(emu_timer *which)
707698{
708699   return which->enabled;
709700}
r1293r1294
715706    parameter of a timer
716707-------------------------------------------------*/
717708
718int mame_timer_get_param(mame_timer *which)
709int timer_get_param(emu_timer *which)
719710{
720711   return which->callback_param;
721712}
722713
723714
724void *mame_timer_get_param_ptr(mame_timer *which)
715void *timer_get_param_ptr(emu_timer *which)
725716{
726717   return which->callback_ptr_param;
727718}
728719
729720
721
730722/***************************************************************************
731723    TIMING FUNCTIONS
732724***************************************************************************/
r1293r1294
736728    last trigger
737729-------------------------------------------------*/
738730
739mame_time mame_timer_timeelapsed(mame_timer *which)
731attotime timer_timeelapsed(emu_timer *which)
740732{
741   return sub_mame_times(get_current_time(), which->start);
733   return attotime_sub(get_current_time(), which->start);
742734}
743735
744736
r1293r1294
747739    next trigger
748740-------------------------------------------------*/
749741
750mame_time mame_timer_timeleft(mame_timer *which)
742attotime timer_timeleft(emu_timer *which)
751743{
752   return sub_mame_times(which->expire, get_current_time());
744   return attotime_sub(which->expire, get_current_time());
753745}
754746
755747
r1293r1294
757749    timer_get_time - return the current time
758750-------------------------------------------------*/
759751
760mame_time mame_timer_get_time(void)
752attotime timer_get_time(void)
761753{
762754   return get_current_time();
763755}
r1293r1294
768760    timer started counting
769761-------------------------------------------------*/
770762
771mame_time mame_timer_starttime(mame_timer *which)
763attotime timer_starttime(emu_timer *which)
772764{
773765   return which->start;
774766}
r1293r1294
779771    timer will fire next
780772-------------------------------------------------*/
781773
782mame_time mame_timer_firetime(mame_timer *which)
774attotime timer_firetime(emu_timer *which)
783775{
784776   return which->expire;
785777}
r1293r1294
796788
797789static void timer_logtimers(void)
798790{
799   mame_timer *t;
791   emu_timer *t;
800792
801793   logerror("===============\n");
802794   logerror("TIMER LOG START\n");
r1293r1294
805797   logerror("Enqueued timers:\n");
806798   for (t = timer_head; t; t = t->next)
807799      logerror("  Start=%15.6f Exp=%15.6f Per=%15.6f Ena=%d Tmp=%d (%s:%d[%s])\n",
808         mame_time_to_double(t->start), mame_time_to_double(t->expire), mame_time_to_double(t->period), t->enabled, t->temporary, t->file, t->line, t->func);
800         attotime_to_double(t->start), attotime_to_double(t->expire), attotime_to_double(t->period), t->enabled, t->temporary, t->file, t->line, t->func);
809801
810802   logerror("Free timers:\n");
811803   for (t = timer_free_head; t; t = t->next)
812804      logerror("  Start=%15.6f Exp=%15.6f Per=%15.6f Ena=%d Tmp=%d (%s:%d[%s])\n",
813         mame_time_to_double(t->start), mame_time_to_double(t->expire), mame_time_to_double(t->period), t->enabled, t->temporary, t->file, t->line, t->func);
805         attotime_to_double(t->start), attotime_to_double(t->expire), attotime_to_double(t->period), t->enabled, t->temporary, t->file, t->line, t->func);
814806
815807   logerror("==============\n");
816808   logerror("TIMER LOG STOP\n");
src/emu/cheat.c
r1293r1294
532532    GLOBAL VARIABLES
533533***************************************************************************/
534534
535static mame_timer         * periodic_timer;
535static emu_timer         * periodic_timer;
536536
537537static CheatEntry         * cheatList = NULL;
538538static INT32            cheatListLength = 0;
r1293r1294
15001500   /* ----- initialize string table ----- */
15011501   InitStringTable();
15021502
1503   periodic_timer = mame_timer_alloc(cheat_periodic);
1504   mame_timer_adjust(periodic_timer, make_mame_time(0, Machine->screen[0].refresh), 0, make_mame_time(0, Machine->screen[0].refresh));
1503   periodic_timer = timer_alloc(cheat_periodic);
1504   timer_adjust(periodic_timer, attotime_make(0, Machine->screen[0].refresh), 0, attotime_make(0, Machine->screen[0].refresh));
15051505
15061506   add_exit_callback(machine, cheat_exit);
15071507}
r1293r1294
94349434
94359435               refresh /= 65536.0;
94369436
9437               video_screen_configure(0, state->width, state->height, &state->visarea, HZ_TO_SUBSECONDS(refresh));
9437               video_screen_configure(0, state->width, state->height, &state->visarea, HZ_TO_ATTOSECONDS(refresh));
94389438            }
94399439            break;
94409440         }
r1293r1294
1140611406            /* ----- keep if one shot + restore prevous value + delay !=0 ----- */
1140711407            cheat_periodicOperation(action);
1140811408
11409            if(action->frameTimer >= (parameter * SUBSECONDS_TO_HZ(Machine->screen[0].refresh)))
11409            if(action->frameTimer >= (parameter * ATTOSECONDS_TO_HZ(Machine->screen[0].refresh)))
1141011410            {
1141111411               action->frameTimer = 0;
1141211412
r1293r1294
1141811418         else
1141911419         {
1142011420            /* ----- otherwise, delay ----- */
11421            if(action->frameTimer >= (parameter * SUBSECONDS_TO_HZ(Machine->screen[0].refresh)))
11421            if(action->frameTimer >= (parameter * ATTOSECONDS_TO_HZ(Machine->screen[0].refresh)))
1142211422            {
1142311423               action->frameTimer = 0;
1142411424
r1293r1294
1145711457
1145811458            if(currentValue != action->lastValue)
1145911459            {
11460               action->frameTimer = parameter * SUBSECONDS_TO_HZ(Machine->screen[0].refresh);
11460               action->frameTimer = parameter * ATTOSECONDS_TO_HZ(Machine->screen[0].refresh);
1146111461
1146211462               action->flags |= kActionFlag_WasModified;
1146311463            }
src/emu/timer.h
r1293r1294
1616#define __TIMER_H__
1717
1818#include "mamecore.h"
19#include <math.h>
19#include "attotime.h"
2020
2121
2222/***************************************************************************
23    CONSTANTS
24***************************************************************************/
25
26/* subseconds are tracked in attosecond (10^-18) increments */
27#define MAX_SUBSECONDS_SQRT         ((subseconds_t)1000000000)
28#define MAX_SUBSECONDS            (MAX_SUBSECONDS_SQRT * MAX_SUBSECONDS_SQRT)
29#define MAX_SECONDS               ((seconds_t)1000000000)
30
31
32
33/***************************************************************************
3423    MACROS
3524***************************************************************************/
3625
37/* convert between a double and subseconds */
38#define SUBSECONDS_TO_DOUBLE(x)      ((double)(x) * (1.0 / (double)MAX_SUBSECONDS))
39#define DOUBLE_TO_SUBSECONDS(x)      ((subseconds_t)((x) * (double)MAX_SUBSECONDS))
40#define USEC_TO_SUBSECONDS(us)      ((subseconds_t)((us) * (MAX_SUBSECONDS / 1000000)))
26/* convert cycles on a given CPU to/from attotime */
27#define ATTOTIME_TO_CYCLES(cpu,t)      ((t).seconds * cycles_per_second[cpu] + (t).attoseconds / attoseconds_per_cycle[cpu])
28#define ATTOTIME_IN_CYCLES(c,cpu)      (attotime_make((c) / cycles_per_second[cpu], (c) * attoseconds_per_cycle[cpu]))
4129
42/* hertz to subseconds macros */
43#define SUBSECONDS_TO_HZ(x)         ((double)MAX_SUBSECONDS / (double)(x))
44#define HZ_TO_SUBSECONDS(x)         (MAX_SUBSECONDS / (x))
45
46/* convert cycles on a given CPU to/from mame_time */
47#define MAME_TIME_TO_CYCLES(cpu,t)   ((t).seconds * cycles_per_second[cpu] + (t).subseconds / subseconds_per_cycle[cpu])
48#define MAME_TIME_IN_CYCLES(c,cpu)   (make_mame_time((c) / cycles_per_second[cpu], (c) * subseconds_per_cycle[cpu]))
49
50/* useful macros for describing mame_times */
51#define MAME_TIME_IN_HZ(hz)      make_mame_time(0, MAX_SUBSECONDS / (hz))
52#define MAME_TIME_IN_SEC(s)      make_mame_time((s)  / 1, (s) % 1 /* mod here errors on doubles, which is intended */)
53#define MAME_TIME_IN_MSEC(ms)   make_mame_time((ms) / 1000, ((ms) % 1000) * (MAX_SUBSECONDS / 1000))
54#define MAME_TIME_IN_USEC(us)   make_mame_time((us) / 1000000, ((us) % 1000000) * (MAX_SUBSECONDS / 1000000))
55#define MAME_TIME_IN_NSEC(ns)   make_mame_time((ns) / 1000000000, ((ns) % 1000000000) * (MAX_SUBSECONDS / 1000000000))
56
5730/* macro for the RC time constant on a 74LS123 with C > 1000pF */
5831/* R is in ohms, C is in farads */
5932#define TIME_OF_74LS123(r,c)         (0.45 * (double)(r) * (double)(c))
6033
6134/* macros for the RC time constant on a 555 timer IC */
6235/* R is in ohms, C is in farads */
63#define PERIOD_OF_555_MONOSTABLE(r,c)   MAME_TIME_IN_NSEC((subseconds_t)(1100000000 * (double)(r) * (double)(c)))
64#define PERIOD_OF_555_ASTABLE(r1,r2,c)   MAME_TIME_IN_NSEC((subseconds_t)( 693000000 * ((double)(r1) + 2.0 * (double)(r2)) * (double)(c)))
36#define PERIOD_OF_555_MONOSTABLE(r,c)   ATTOTIME_IN_NSEC((attoseconds_t)(1100000000 * (double)(r) * (double)(c)))
37#define PERIOD_OF_555_ASTABLE(r1,r2,c)   ATTOTIME_IN_NSEC((attoseconds_t)( 693000000 * ((double)(r1) + 2.0 * (double)(r2)) * (double)(c)))
6538
6639/* macros that map all allocations to provide file/line/functions to the callee */
67#define mame_timer_alloc(c)            _mame_timer_alloc(c, __FILE__, __LINE__, #c)
68#define mame_timer_alloc_ptr(c,p)      _mame_timer_alloc_ptr(c, p, __FILE__, __LINE__, #c)
69#define mame_timer_pulse(e,p,c)         _mame_timer_pulse(e, p, c, __FILE__, __LINE__, #c)
70#define mame_timer_pulse_ptr(e,p,c)      _mame_timer_pulse_ptr(e, p, c, __FILE__, __LINE__, #c)
71#define mame_timer_set(d,p,c)         _mame_timer_set(d, p, c, __FILE__, __LINE__, #c)
72#define mame_timer_set_ptr(d,p,c)      _mame_timer_set_ptr(d, p, c, __FILE__, __LINE__, #c)
40#define timer_alloc(c)               _timer_alloc(c, __FILE__, __LINE__, #c)
41#define timer_alloc_ptr(c,p)         _timer_alloc_ptr(c, p, __FILE__, __LINE__, #c)
42#define timer_pulse(e,p,c)            _timer_pulse(e, p, c, __FILE__, __LINE__, #c)
43#define timer_pulse_ptr(e,p,c)         _timer_pulse_ptr(e, p, c, __FILE__, __LINE__, #c)
44#define timer_set(d,p,c)            _timer_set(d, p, c, __FILE__, __LINE__, #c)
45#define timer_set_ptr(d,p,c)         _timer_set_ptr(d, p, c, __FILE__, __LINE__, #c)
7346
7447/* macros for a timer callback functions */
7548#define TIMER_CALLBACK(name)         void name(running_machine *machine, int param)
r1293r1294
8255***************************************************************************/
8356
8457/* opaque type for representing a timer */
85typedef struct _mame_timer mame_timer;
58typedef struct _emu_timer emu_timer;
8659
87/* these core types describe a 96-bit time value */
88typedef INT64 subseconds_t;
89typedef INT32 seconds_t;
9060
91typedef struct _mame_time mame_time;
92struct _mame_time
93{
94   seconds_t      seconds;
95   subseconds_t   subseconds;
96};
9761
98
99
10062/***************************************************************************
10163    GLOBAL VARIABLES
10264***************************************************************************/
10365
104/* constant times for zero and never */
105extern mame_time time_zero;
106extern mame_time time_never;
107
10866/* arrays containing mappings between CPU cycle times and timer values */
109extern subseconds_t subseconds_per_cycle[];
67extern attoseconds_t attoseconds_per_cycle[];
11068extern UINT32 cycles_per_second[];
11169
11270
r1293r1294
11573    FUNCTION PROTOTYPES
11674***************************************************************************/
11775
118void timer_init(running_machine *machine);
119void timer_destructor(void *ptr, size_t size);
120int timer_count_anonymous(void);
12176
122mame_time mame_timer_next_fire_time(void);
123void mame_timer_set_global_time(mame_time newbase);
124mame_timer *_mame_timer_alloc(void (*callback)(running_machine *, int), const char *file, int line, const char *func);
125mame_timer *_mame_timer_alloc_ptr(void (*callback)(running_machine *, void *), void *param, const char *file, int line, const char *func);
126void mame_timer_adjust(mame_timer *which, mame_time duration, INT32 param, mame_time period);
127void mame_timer_adjust_ptr(mame_timer *which, mame_time duration, mame_time period);
128void _mame_timer_pulse(mame_time period, INT32 param, void (*callback)(running_machine *, int), const char *file, int line, const char *func);
129void _mame_timer_pulse_ptr(mame_time period, void *param, void (*callback)(running_machine *, void *), const char *file, int line, const char *func);
130void _mame_timer_set(mame_time duration, INT32 param, void (*callback)(running_machine *, int), const char *file, int line, const char *func);
131void _mame_timer_set_ptr(mame_time duration, void *param, void (*callback)(running_machine *, void *), const char *file, int line, const char *func);
132void mame_timer_reset(mame_timer *which, mame_time duration);
133int mame_timer_enable(mame_timer *which, int enable);
134int mame_timer_enabled(mame_timer *which);
135int mame_timer_get_param(mame_timer *which);
136void *mame_timer_get_param_ptr(mame_timer *which);
137mame_time mame_timer_timeelapsed(mame_timer *which);
138mame_time mame_timer_timeleft(mame_timer *which);
139mame_time mame_timer_get_time(void);
140mame_time mame_timer_starttime(mame_timer *which);
141mame_time mame_timer_firetime(mame_timer *which);
77/* ----- initialization ----- */
14278
79/* initialize the timer system */
80void timer_init(running_machine *machine);
14381
82/* destruct a timer from a pool callback */
83void timer_destructor(void *ptr, size_t size);
14484
145/***************************************************************************
146    INLINE FUNCTIONS
147***************************************************************************/
14885
149/*-------------------------------------------------
150    make_mame_time - assemble a mame_time from
151    seconds and subseconds components
152-------------------------------------------------*/
15386
154INLINE mame_time make_mame_time(seconds_t _secs, subseconds_t _subsecs)
155{
156   mame_time result;
157   result.seconds = _secs;
158   result.subseconds = _subsecs;
159   return result;
160}
87/* ----- scheduling helpers ----- */
16188
89/* return the time when the next timer will fire */
90attotime timer_next_fire_time(void);
16291
163/*-------------------------------------------------
164    mame_time_to_subseconds - convert a mame_time
165    to subseconds, clamping to maximum positive/
166    negative values
167-------------------------------------------------*/
92/* adjust the global time; this is also where we fire the timers */
93void timer_set_global_time(attotime newbase);
16894
169INLINE subseconds_t mame_time_to_subseconds(mame_time _time)
170{
171   /* positive values between 0 and 1 second */
172   if (_time.seconds == 0)
173      return _time.subseconds;
17495
175   /* negative values between -1 and 0 seconds */
176   else if (_time.seconds == -1)
177      return _time.subseconds - MAX_SUBSECONDS;
17896
179   /* out-of-range positive values */
180   else if (_time.seconds > 0)
181      return MAX_SUBSECONDS;
97/* ----- save/restore helpers ----- */
18298
183   /* out-of-range negative values */
184   else
185      return -MAX_SUBSECONDS;
186}
99/* count the number of anonymous (non-saveable) timers */
100int timer_count_anonymous(void);
187101
188102
189/*-------------------------------------------------
190    mame_time_to_double - convert from mame_time
191    to double
192-------------------------------------------------*/
193103
194INLINE double mame_time_to_double(mame_time _time)
195{
196   return (double)_time.seconds + SUBSECONDS_TO_DOUBLE(_time.subseconds);
197}
104/* ----- core timer management ----- */
198105
106/* allocate a permament timer that isn't primed yet */
107emu_timer *_timer_alloc(void (*callback)(running_machine *, int), const char *file, int line, const char *func);
108emu_timer *_timer_alloc_ptr(void (*callback)(running_machine *, void *), void *param, const char *file, int line, const char *func);
199109
200/*-------------------------------------------------
201    double_to_mame_time - convert from double to
202    mame_time
203-------------------------------------------------*/
110/* adjust the time when this timer will fire, and whether or not it will fire periodically */
111void timer_adjust(emu_timer *which, attotime duration, INT32 param, attotime period);
112void timer_adjust_ptr(emu_timer *which, attotime duration, attotime period);
204113
205INLINE mame_time double_to_mame_time(double _time)
206{
207   mame_time abstime;
208114
209   /* set seconds to the integral part */
210   abstime.seconds = floor(_time);
211115
212   /* set subseconds to the fractional part */
213   _time -= (double)abstime.seconds;
214   abstime.subseconds = DOUBLE_TO_SUBSECONDS(_time);
215   return abstime;
216}
116/* ----- anonymous timer management ----- */
217117
118/* allocate a pulse timer, which repeatedly calls the callback using the given period */
119void _timer_pulse(attotime period, INT32 param, void (*callback)(running_machine *, int), const char *file, int line, const char *func);
120void _timer_pulse_ptr(attotime period, void *param, void (*callback)(running_machine *, void *), const char *file, int line, const char *func);
218121
219/*-------------------------------------------------
220    add_mame_times - add two mame_times
221-------------------------------------------------*/
122/* allocate a one-shot timer, which calls the callback after the given duration */
123void _timer_set(attotime duration, INT32 param, void (*callback)(running_machine *, int), const char *file, int line, const char *func);
124void _timer_set_ptr(attotime duration, void *param, void (*callback)(running_machine *, void *), const char *file, int line, const char *func);
222125
223INLINE mame_time add_mame_times(mame_time _time1, mame_time _time2)
224{
225   mame_time result;
226126
227   /* if one of the items is time_never, return time_never */
228   if (_time1.seconds >= MAX_SECONDS || _time2.seconds >= MAX_SECONDS)
229      return time_never;
230127
231   /* add the seconds and subseconds */
232   result.subseconds = _time1.subseconds + _time2.subseconds;
233   result.seconds = _time1.seconds + _time2.seconds;
128/* ----- miscellaneous controls ----- */
234129
235   /* normalize and return */
236   if (result.subseconds >= MAX_SUBSECONDS)
237   {
238      result.subseconds -= MAX_SUBSECONDS;
239      result.seconds++;
240   }
241   return result;
242}
130/* reset the timing on a timer */
131void timer_reset(emu_timer *which, attotime duration);
243132
133/* enable/disable a timer */
134int timer_enable(emu_timer *which, int enable);
244135
245/*-------------------------------------------------
246    add_subseconds_to_mame_time - add subseconds
247    to a mame_time
248-------------------------------------------------*/
136/* determine if a timer is enabled */
137int timer_enabled(emu_timer *which);
249138
250INLINE mame_time add_subseconds_to_mame_time(mame_time _time1, subseconds_t _subseconds)
251{
252   mame_time result;
139/* returns the callback parameter of a timer */
140int timer_get_param(emu_timer *which);
141void *timer_get_param_ptr(emu_timer *which);
253142
254   /* if one of the items is time_never, return time_never */
255   if (_time1.seconds >= MAX_SECONDS)
256      return time_never;
257143
258   /* add the seconds and subseconds */
259   result.subseconds = _time1.subseconds + _subseconds;
260   result.seconds = _time1.seconds;
261144
262   /* normalize and return */
263   if (result.subseconds >= MAX_SUBSECONDS)
264   {
265      result.subseconds -= MAX_SUBSECONDS;
266      result.seconds++;
267   }
268   return result;
269}
145/* ----- timing functions ----- */
270146
147/* return the time since the last trigger */
148attotime timer_timeelapsed(emu_timer *which);
271149
272/*-------------------------------------------------
273    sub_mame_times - subtract two mame_times
274-------------------------------------------------*/
150/* return the time until the next trigger */
151attotime timer_timeleft(emu_timer *which);
275152
276INLINE mame_time sub_mame_times(mame_time _time1, mame_time _time2)
277{
278   mame_time result;
153/* return the current time */
154attotime timer_get_time(void);
279155
280   /* if time1 is time_never, return time_never */
281   if (_time1.seconds >= MAX_SECONDS)
282      return time_never;
156/* return the time when this timer started counting */
157attotime timer_starttime(emu_timer *which);
283158
284   /* add the seconds and subseconds */
285   result.subseconds = _time1.subseconds - _time2.subseconds;
286   result.seconds = _time1.seconds - _time2.seconds;
159/* return the time when this timer will fire next */
160attotime timer_firetime(emu_timer *which);
287161
288   /* normalize and return */
289   if (result.subseconds < 0)
290   {
291      result.subseconds += MAX_SUBSECONDS;
292      result.seconds--;
293   }
294   return result;
295}
296162
297163
298/*-------------------------------------------------
299    sub_subseconds_from_mame_time - subtract
300    subseconds from a mame_time
301-------------------------------------------------*/
302164
303INLINE mame_time sub_subseconds_from_mame_time(mame_time _time1, subseconds_t _subseconds)
304{
305   mame_time result;
165/***************************************************************************
166    INLINE FUNCTIONS
167***************************************************************************/
306168
307   /* if time1 is time_never, return time_never */
308   if (_time1.seconds >= MAX_SECONDS)
309      return time_never;
310
311   /* add the seconds and subseconds */
312   result.subseconds = _time1.subseconds - _subseconds;
313   result.seconds = _time1.seconds;
314
315   /* normalize and return */
316   if (result.subseconds < 0)
317   {
318      result.subseconds += MAX_SUBSECONDS;
319      result.seconds--;
320   }
321   return result;
322}
323
324
325169/*-------------------------------------------------
326    scale_up_mame_time - multiply a mame_time by
327    a constant
328-------------------------------------------------*/
329
330INLINE mame_time scale_up_mame_time(mame_time _time1, UINT32 factor)
331{
332   UINT32 subseclo, subsechi;
333   UINT64 templo, temphi;
334   mame_time result;
335
336   /* if one of the items is time_never, return time_never */
337   if (_time1.seconds >= MAX_SECONDS)
338      return time_never;
339
340   /* 0 times anything is zero */
341   if (factor == 0)
342      return time_zero;
343
344   /* break subseconds into lower and upper halves */
345   subseclo = (UINT32)(_time1.subseconds % MAX_SUBSECONDS_SQRT);
346   subsechi = (UINT32)(_time1.subseconds / MAX_SUBSECONDS_SQRT);
347
348   /* get a 64-bit product for each one */
349   templo = (UINT64)subseclo * (UINT64)factor;
350   temphi = (UINT64)subsechi * (UINT64)factor;
351
352   /* separate out the low and carry into the high */
353   subseclo = templo % MAX_SUBSECONDS_SQRT;
354   temphi += templo / MAX_SUBSECONDS_SQRT;
355   subsechi = temphi % MAX_SUBSECONDS_SQRT;
356
357   /* assemble the two parts into final subseconds and carry into seconds */
358   result.subseconds = (subseconds_t)subseclo + MAX_SUBSECONDS_SQRT * (subseconds_t)subsechi;
359   result.seconds = _time1.seconds * factor + temphi / MAX_SUBSECONDS_SQRT;
360
361   /* max out at never time */
362   if (result.seconds >= MAX_SECONDS)
363      return time_never;
364
365   return result;
366}
367
368
369/*-------------------------------------------------
370    scale_down_mame_time - divide a mame_time by
371    a constant
372-------------------------------------------------*/
373
374INLINE mame_time scale_down_mame_time(mame_time _time1, UINT32 factor)
375{
376   mame_time result;
377   int shift_count;
378   int carry;
379
380   /* if one of the items is time_never, return time_never */
381   if (_time1.seconds >= MAX_SECONDS)
382      return time_never;
383
384   result.seconds = _time1.seconds / factor;
385   carry = _time1.seconds - (result.seconds * factor);
386
387   /* shift the subseconds to the right by log2 of the factor, so it won't overflow */
388   shift_count = (log(carry) / log(2)) + 1;
389   result.subseconds = (((carry * (MAX_SUBSECONDS >> shift_count)) + (_time1.subseconds >> shift_count)) / factor) << shift_count;
390
391   return result;
392}
393
394
395/*-------------------------------------------------
396    compare_mame_times - compare two mame_times
397-------------------------------------------------*/
398
399INLINE int compare_mame_times(mame_time _time1, mame_time _time2)
400{
401   if (_time1.seconds > _time2.seconds)
402      return 1;
403   if (_time1.seconds < _time2.seconds)
404      return -1;
405   if (_time1.subseconds > _time2.subseconds)
406      return 1;
407   if (_time1.subseconds < _time2.subseconds)
408      return -1;
409   return 0;
410}
411
412
413/*-------------------------------------------------
414170    timer_call_after_resynch - synchs the CPUs
415171    and calls the callback immediately
416172-------------------------------------------------*/
417173
418174INLINE void timer_call_after_resynch(INT32 param, void (*callback)(running_machine *, int))
419175{
420   mame_timer_set(time_zero, param, callback);
176   timer_set(attotime_zero, param, callback);
421177}
422178
423
424179INLINE void timer_call_after_resynch_ptr(void *param, void (*callback)(running_machine *, void *))
425180{
426   mame_timer_set_ptr(time_zero, param, callback);
181   timer_set_ptr(attotime_zero, param, callback);
427182}
428183
429184
src/emu/validity.c
r1293r1294
216216static int validate_inlines(void)
217217{
218218#undef rand
219   int test1 = rand() | (rand() << 15);
220   int test2 = rand() | (rand() << 15);
219   UINT64 testu64a = rand() + (rand() << 15) + ((UINT64)rand() << 30) + ((UINT64)rand() << 45) + 1;
220   INT64 testi64a = rand() + (rand() << 15) + ((INT64)rand() << 30) + ((INT64)rand() << 45) + 1;
221#ifdef PTR64
222   INT64 testi64b = rand() + (rand() << 15) + ((INT64)rand() << 30) + ((INT64)rand() << 45) + 1;
223#endif
224   UINT32 testu32a = rand() + (rand() << 15) + 1;
225   UINT32 testu32b = rand() + (rand() << 15) + 1;
226   INT32 testi32a = rand() + (rand() << 15) + 1;
227   INT32 testi32b = rand() + (rand() << 15) + 1;
228   INT32 resulti32, expectedi32;
229   UINT32 resultu32, expectedu32;
230   INT64 resulti64, expectedi64;
231   UINT64 resultu64, expectedu64;
232   INT32 remainder, expremainder;
233   UINT32 uremainder, expuremainder;
221234   int error = FALSE;
222235
223   if (mul_32x32(test1, test2) != (INT64)(INT32)test1 * (INT64)(INT32)test2) { mame_printf_error("Error testing mul_32x32\n"); error = TRUE; }
224   if (mulu_32x32(test1, test2) != (UINT64)(UINT32)test1 * (UINT64)(UINT32)test2) { mame_printf_error("Error testing mulu_32x32\n"); error = TRUE; }
225   if (mul_32x32_hi(test1, test2) != ((INT64)(INT32)test1 * (INT64)(INT32)test2) >> 32) { mame_printf_error("Error testing mul_32x32_hi\n"); error = TRUE; }
226   if (mulu_32x32_hi(test1, test2) != ((UINT64)(UINT32)test1 * (UINT64)(UINT32)test2) >> 32) { mame_printf_error("Error testing mulu_32x32_hi\n"); error = TRUE; }
227   if (mul_32x32_shift(test1, test2, 7) != (INT32)(((INT64)test1 * (INT64)test2) >> 7)) { mame_printf_error("Error testing mul_32x32_shift\n"); error = TRUE; }
228   if (mulu_32x32_shift(test1, test2, 7) != (UINT32)(((UINT64)(UINT32)test1 * (UINT64)(UINT32)test2) >> 7)) { mame_printf_error("Error testing mulu_32x32_shift\n"); error = TRUE; }
229   if (fabs(recip_approx(100.0) - 0.01) > 0.0001) { mame_printf_error("Error testing recip_approx\n"); error = TRUE; }
230   test1 = (test1 & 0x0000ffff) | 0x400000;
231   if (count_leading_zeros(test1) != 9) { mame_printf_error("Error testing count_leading_zeros\n"); error = TRUE; }
232   test1 = (test1 | 0xffff0000) & ~0x400000;
233   if (count_leading_ones(test1) != 9) { mame_printf_error("Error testing count_leading_ones\n"); error = TRUE; }
234   test2 = test1;
235   if (compare_exchange32(&test1, test2, 1000) != test2) { mame_printf_error("Error testing compare_exchange32\n"); error = TRUE; }
236   if (atomic_exchange32(&test1, test2) != 1000) { mame_printf_error("Error testing atomic_exchange32\n"); error = TRUE; }
237   if (atomic_add32(&test1, 45) != test2 + 45) { mame_printf_error("Error testing atomic_add32\n"); error = TRUE; }
236   resulti64 = mul_32x32(testi32a, testi32b);
237   expectedi64 = (INT64)testi32a * (INT64)testi32b;
238   if (resulti64 != expectedi64)
239      { mame_printf_error("Error testing mul_32x32 (%08X x %08X) = %08X%08X (expected %08X%08X)\n", testi32a, testi32b, (UINT32)(resulti64 >> 32), (UINT32)resulti64, (UINT32)(expectedi64 >> 32), (UINT32)expectedi64); error = TRUE; }
238240
241   resultu64 = mulu_32x32(testu32a, testu32b);
242   expectedu64 = (UINT64)testu32a * (UINT64)testu32b;
243   if (resultu64 != expectedu64)
244      { mame_printf_error("Error testing mulu_32x32 (%08X x %08X) = %08X%08X (expected %08X%08X)\n", testu32a, testu32b, (UINT32)(resultu64 >> 32), (UINT32)resultu64, (UINT32)(expectedu64 >> 32), (UINT32)expectedu64); error = TRUE; }
245
246   resulti32 = mul_32x32_hi(testi32a, testi32b);
247   expectedi32 = ((INT64)testi32a * (INT64)testi32b) >> 32;
248   if (resulti32 != expectedi32)
249      { mame_printf_error("Error testing mul_32x32_hi (%08X x %08X) = %08X (expected %08X)\n", testi32a, testi32b, resulti32, expectedi32); error = TRUE; }
250
251   resultu32 = mulu_32x32_hi(testu32a, testu32b);
252   expectedu32 = ((INT64)testu32a * (INT64)testu32b) >> 32;
253   if (resultu32 != expectedu32)
254      { mame_printf_error("Error testing mulu_32x32_hi (%08X x %08X) = %08X (expected %08X)\n", testu32a, testu32b, resultu32, expectedu32); error = TRUE; }
255
256   resulti32 = mul_32x32_shift(testi32a, testi32b, 7);
257   expectedi32 = ((INT64)testi32a * (INT64)testi32b) >> 7;
258   if (resulti32 != expectedi32)
259      { mame_printf_error("Error testing mul_32x32_shift (%08X x %08X) >> 7 = %08X (expected %08X)\n", testi32a, testi32b, resulti32, expectedi32); error = TRUE; }
260
261   resultu32 = mulu_32x32_shift(testu32a, testu32b, 7);
262   expectedu32 = ((INT64)testu32a * (INT64)testu32b) >> 7;
263   if (resultu32 != expectedu32)
264      { mame_printf_error("Error testing mulu_32x32_shift (%08X x %08X) >> 7 = %08X (expected %08X)\n", testu32a, testu32b, resultu32, expectedu32); error = TRUE; }
265
266   while ((INT64)testi32a * (INT64)0x7fffffff < testi64a)
267      testi64a /= 2;
268   while ((UINT64)testu32a * (UINT64)0xffffffff < testu64a)
269      testu64a /= 2;
270
271   resulti32 = div_64x32(testi64a, testi32a);
272   expectedi32 = testi64a / (INT64)testi32a;
273   if (resulti32 != expectedi32)
274      { mame_printf_error("Error testing div_64x32 (%08X%08X / %08X) = %08X (expected %08X)\n", (UINT32)(testi64a >> 32), (UINT32)testi64a, testi32a, resulti32, expectedi32); error = TRUE; }
275
276   resultu32 = divu_64x32(testu64a, testu32a);
277   expectedu32 = testu64a / (UINT64)testu32a;
278   if (resultu32 != expectedu32)
279      { mame_printf_error("Error testing divu_64x32 (%08X%08X / %08X) = %08X (expected %08X)\n", (UINT32)(testu64a >> 32), (UINT32)testu64a, testu32a, resultu32, expectedu32); error = TRUE; }
280
281   resulti32 = div_64x32_rem(testi64a, testi32a, &remainder);
282   expectedi32 = testi64a / (INT64)testi32a;
283   expremainder = testi64a % (INT64)testi32a;
284   if (resulti32 != expectedi32 || remainder != expremainder)
285      { mame_printf_error("Error testing div_64x32_rem (%08X%08X / %08X) = %08X,%08X (expected %08X,%08X)\n", (UINT32)(testi64a >> 32), (UINT32)testi64a, testi32a, resulti32, remainder, expectedi32, expremainder); error = TRUE; }
286
287   resultu32 = divu_64x32_rem(testu64a, testu32a, &uremainder);
288   expectedu32 = testu64a / (UINT64)testu32a;
289   expuremainder = testu64a % (UINT64)testu32a;
290   if (resultu32 != expectedu32 || uremainder != expuremainder)
291      { mame_printf_error("Error testing divu_64x32_rem (%08X%08X / %08X) = %08X,%08X (expected %08X,%08X)\n", (UINT32)(testu64a >> 32), (UINT32)testu64a, testu32a, resultu32, uremainder, expectedu32, expuremainder); error = TRUE; }
292
293   resulti32 = mod_64x32(testi64a, testi32a);
294   expectedi32 = testi64a % (INT64)testi32a;
295   if (resulti32 != expectedi32)
296      { mame_printf_error("Error testing mod_64x32 (%08X%08X / %08X) = %08X (expected %08X)\n", (UINT32)(testi64a >> 32), (UINT32)testi64a, testi32a, resulti32, expectedi32); error = TRUE; }
297
298   resultu32 = modu_64x32(testu64a, testu32a);
299   expectedu32 = testu64a % (UINT64)testu32a;
300   if (resultu32 != expectedu32)
301      { mame_printf_error("Error testing modu_64x32 (%08X%08X / %08X) = %08X (expected %08X)\n", (UINT32)(testu64a >> 32), (UINT32)testu64a, testu32a, resultu32, expectedu32); error = TRUE; }
302
303   while ((INT64)testi32a * (INT64)0x7fffffff < ((INT32)testi64a << 3))
304      testi64a /= 2;
305   while ((UINT64)testu32a * (UINT64)0xffffffff < ((UINT32)testu64a << 3))
306      testu64a /= 2;
307
308   resulti32 = div_32x32_shift((INT32)testi64a, testi32a, 3);
309   expectedi32 = ((INT64)(INT32)testi64a << 3) / (INT64)testi32a;
310   if (resulti32 != expectedi32)
311      { mame_printf_error("Error testing div_32x32_shift (%08X << 3) / %08X = %08X (expected %08X)\n", (INT32)testi64a, testi32a, resulti32, expectedi32); error = TRUE; }
312
313   resultu32 = divu_32x32_shift((UINT32)testu64a, testu32a, 3);
314   expectedu32 = ((UINT64)(UINT32)testu64a << 3) / (UINT64)testu32a;
315   if (resultu32 != expectedu32)
316      { mame_printf_error("Error testing divu_32x32_shift (%08X << 3) / %08X = %08X (expected %08X)\n", (UINT32)testu64a, testu32a, resultu32, expectedu32); error = TRUE; }
317
318   if (fabs(recip_approx(100.0) - 0.01) > 0.0001)
319      { mame_printf_error("Error testing recip_approx\n"); error = TRUE; }
320
321   testi32a = (testi32a & 0x0000ffff) | 0x400000;
322   if (count_leading_zeros(testi32a) != 9)
323      { mame_printf_error("Error testing count_leading_zeros\n"); error = TRUE; }
324   testi32a = (testi32a | 0xffff0000) & ~0x400000;
325   if (count_leading_ones(testi32a) != 9)
326      { mame_printf_error("Error testing count_leading_ones\n"); error = TRUE; }
327
328   testi32b = testi32a;
329   if (compare_exchange32(&testi32a, testi32b, 1000) != testi32b || testi32a != 1000)
330      { mame_printf_error("Error testing compare_exchange32\n"); error = TRUE; }
331#ifdef PTR64
332   testi64b = testi64a;
333   if (compare_exchange64(&testi64a, testi64b, 1000) != testi64b || testi64a != 1000)
334      { mame_printf_error("Error testing compare_exchange64\n"); error = TRUE; }
335#endif
336   if (atomic_exchange32(&testi32a, testi32b) != 1000)
337      { mame_printf_error("Error testing atomic_exchange32\n"); error = TRUE; }
338   if (atomic_add32(&testi32a, 45) != testi32b + 45)
339      { mame_printf_error("Error testing atomic_add32\n"); error = TRUE; }
340   if (atomic_increment32(&testi32a) != testi32b + 46)
341      { mame_printf_error("Error testing atomic_increment32\n"); error = TRUE; }
342   if (atomic_decrement32(&testi32a) != testi32b + 45)
343      { mame_printf_error("Error testing atomic_decrement32\n"); error = TRUE; }
344
239345   return error;
240346}
241347
src/mess/devices/cassette.c
r1293r1294
6969   double cur_time;
7070   double new_position;
7171
72   cur_time = mame_time_to_double(mame_timer_get_time());
72   cur_time = attotime_to_double(timer_get_time());
7373   tag = get_cassimg(cassette);
7474
7575   if (cassette_is_motor_on(cassette) && tag->cassette)
r1293r1294
180180   position = tag->position;
181181
182182   if (cassette_is_motor_on(cassette))
183      position += mame_time_to_double(mame_timer_get_time()) - tag->position_time;
183      position += attotime_to_double(timer_get_time()) - tag->position_time;
184184   return position;
185185}
186186
r1293r1294
294294
295295   /* reset the position */
296296   tag->position = 0.0;
297   tag->position_time = mame_time_to_double(mame_timer_get_time());
297   tag->position_time = attotime_to_double(timer_get_time());
298298
299299   return INIT_PASS;
300300
src/mess/devices/flopdrv.c
r1293r1294
4444   pDrive->flags = 0;
4545   pDrive->index_pulse_callback = NULL;
4646   pDrive->ready_state_change_callback = NULL;
47   pDrive->index_timer = mame_timer_alloc_ptr(floppy_drive_index_callback, img);
47   pDrive->index_timer = timer_alloc_ptr(floppy_drive_index_callback, img);
4848   pDrive->index = 0;
4949
5050   /* all drives are double-sided 80 track - can be overriden in driver! */
r1293r1294
7575   if (pDrive->index)
7676   {
7777      pDrive->index = 0;
78      mame_timer_adjust_ptr(pDrive->index_timer, double_to_mame_time(ms*19/20/1000.0), time_zero);
78      timer_adjust_ptr(pDrive->index_timer, double_to_attotime(ms*19/20/1000.0), attotime_zero);
7979   }
8080   else
8181   {
8282      pDrive->index = 1;
83      mame_timer_adjust_ptr(pDrive->index_timer, double_to_mame_time(ms/20/1000.0), time_zero);
83      timer_adjust_ptr(pDrive->index_timer, double_to_attotime(ms/20/1000.0), attotime_zero);
8484   }
8585
8686   if (pDrive->index_pulse_callback)
r1293r1294
214214         else
215215         {
216216            /* on->off */
217            mame_timer_adjust_ptr(pDrive->index_timer, time_zero, time_zero);
217            timer_adjust_ptr(pDrive->index_timer, attotime_zero, attotime_zero);
218218         }
219219      }
220220   }
src/mess/devices/sonydriv.c
r1293r1294
348348         break;
349349      case 0x0e:   /* Tachometer */
350350         /* (time in seconds) / (60 sec/minute) * (rounds/minute) * (60 pulses) * (2 pulse phases) */
351         result = ((int) (mame_time_to_double(mame_timer_get_time()) / 60.0 * sony_rpm(f, cur_image) * 60.0 * 2.0)) & 1;
351         result = ((int) (attotime_to_double(timer_get_time()) / 60.0 * sony_rpm(f, cur_image) * 60.0 * 2.0)) & 1;
352352         break;
353353      case 0x0f:   /* Drive installed: 0=drive connected, 1=drive not connected */
354354         result = 0;
src/mess/devices/bitbngr.c
r1293r1294
4747   bi->last_pulse_time = 0.0;
4848   bi->recorded_pulses = 0;
4949   bi->value = config->initial_value;
50   bi->timeout_timer = mame_timer_alloc(bitbanger_overthreshhold);
50   bi->timeout_timer = timer_alloc(bitbanger_overthreshhold);
5151   bi->over_threshhold = 1;
5252
5353   bitbangers[id] = bi;
r1293r1294
118118{
119119   int id = param;
120120   struct bitbanger_info *bi = bitbangers[id];
121   bitbanger_addpulse(id, bi, mame_time_to_double(mame_timer_get_time()) - bi->last_pulse_time);
121   bitbanger_addpulse(id, bi, attotime_to_double(timer_get_time()) - bi->last_pulse_time);
122122   bi->over_threshhold = 1;
123123   bi->recorded_pulses = 0;
124124}
r1293r1294
138138   /* only meaningful if we change */
139139   if (bi->value != value)
140140   {
141      current_time = mame_time_to_double(mame_timer_get_time());
141      current_time = attotime_to_double(timer_get_time());
142142      pulse_width = current_time - bi->last_pulse_time;
143143
144144      assert(pulse_width >= 0);
r1293r1294
152152      bi->over_threshhold = 0;
153153
154154      /* update timeout timer */
155      mame_timer_reset(bi->timeout_timer, double_to_mame_time(bi->config->pulse_threshhold));
155      timer_reset(bi->timeout_timer, double_to_attotime(bi->config->pulse_threshhold));
156156   }
157157}
158158
src/mess/devices/thomflop.c
r1293r1294
293293   else if ( offset == 8 )
294294      return to7_5p14_select;
295295   else
296      logerror ( "%f $%04x to7_5p14_r: invalid read offset %i\n", mame_time_to_double(mame_timer_get_time()), activecpu_get_previouspc(), offset );
296      logerror ( "%f $%04x to7_5p14_r: invalid read offset %i\n", attotime_to_double(timer_get_time()), activecpu_get_previouspc(), offset );
297297   return 0;
298298}
299299
r1293r1294
317317      case 4: drive = 2; side = 0; break;
318318      case 5: drive = 3; side = 1; break;
319319      default:
320         logerror( "%f $%04x to7_5p14_w: invalid drive select pattern $%02X\n", mame_time_to_double(mame_timer_get_time()), activecpu_get_previouspc(), data );
320         logerror( "%f $%04x to7_5p14_w: invalid drive select pattern $%02X\n", attotime_to_double(timer_get_time()), activecpu_get_previouspc(), data );
321321      }
322322   
323323      dens = (data & 0x80) ? DEN_FM_LO : DEN_MFM_LO;
r1293r1294
332332         wd17xx_set_drive( drive );
333333         wd17xx_set_side( side );
334334         LOG(( "%f $%04x to7_5p14_w: $%02X set drive=%i side=%i density=%s\n",
335               mame_time_to_double(mame_timer_get_time()), activecpu_get_previouspc(),
335               attotime_to_double(timer_get_time()), activecpu_get_previouspc(),
336336               data, drive, side, (dens == DEN_FM_LO) ? "FM" : "MFM" ));
337337      }
338338   }
339339   else
340340      logerror ( "%f $%04x to7_5p14_w: invalid write offset %i (data=$%02X)\n",
341            mame_time_to_double(mame_timer_get_time()), activecpu_get_previouspc(), offset, data );
341            attotime_to_double(timer_get_time()), activecpu_get_previouspc(), offset, data );
342342}
343343
344344
r1293r1294
390390   else if ( offset >= 8 && offset <= 9 )
391391      return to7_5p14sd_select;
392392   else
393      logerror ( "%f $%04x to7_5p14sd_r: invalid read offset %i\n",  mame_time_to_double(mame_timer_get_time()), activecpu_get_previouspc(), offset );
393      logerror ( "%f $%04x to7_5p14sd_r: invalid read offset %i\n",  attotime_to_double(timer_get_time()), activecpu_get_previouspc(), offset );
394394   return 0;
395395}
396396
r1293r1294
434434         mc6843_set_drive( drive );
435435         mc6843_set_side( side );
436436         LOG(( "%f $%04x to7_5p14sd_w: $%02X set drive=%i side=%i\n",
437               mame_time_to_double(mame_timer_get_time()), activecpu_get_previouspc(), data, drive, side ));
437               attotime_to_double(timer_get_time()), activecpu_get_previouspc(), data, drive, side ));
438438      }
439439   }
440440   else
441441      logerror ( "%f $%04x to7_5p14sd_w: invalid write offset %i (data=$%02X)\n",
442            mame_time_to_double(mame_timer_get_time()), activecpu_get_previouspc(), offset, data );
442            attotime_to_double(timer_get_time()), activecpu_get_previouspc(), offset, data );
443443}
444444
445445
r1293r1294
552552      to7qdd->data_size = 0;
553553   }
554554
555   VLOG(( "%f to7_qdd_pulse_cb: state=%i\n", mame_time_to_double(mame_timer_get_time()), state ));
555   VLOG(( "%f to7_qdd_pulse_cb: state=%i\n", attotime_to_double(timer_get_time()), state ));
556556}
557557
558558
r1293r1294
616616      data = to7qdd->data[ to7qdd->data_idx ];
617617 
618618   VLOG(( "%f $%04x to7_qdd_read_byte: RDATA off=%i/%i data=$%02X\n",
619          mame_time_to_double(mame_timer_get_time()), activecpu_get_previouspc(),
619          attotime_to_double(timer_get_time()), activecpu_get_previouspc(),
620620          to7qdd->data_idx, to7qdd->data_size, data ));
621621 
622622   to7qdd->data_idx++;
r1293r1294
657657      to7qdd->data_idx++;
658658   
659659      VLOG (( "%f $%04x to7_qdd_write_byte: got $%02X offs=%i-%i\n",
660         mame_time_to_double(mame_timer_get_time()), activecpu_get_previouspc(), data,
660         attotime_to_double(timer_get_time()), activecpu_get_previouspc(), data,
661661         to7qdd->start_idx, to7qdd->data_idx ));
662662   
663663      /* end of tentative id field */
r1293r1294
671671         UINT8 filler = 0xff;
672672     
673673         LOG(( "%f $%04x to7_qdd_write_byte: got id field for sector=%i\n",
674               mame_time_to_double(mame_timer_get_time()), activecpu_get_previouspc(), sector ));
674               attotime_to_double(timer_get_time()), activecpu_get_previouspc(), sector ));
675675     
676676         floppy_drive_format_sector( to7_qdd_image(),
677677                      0, sector, 0, 0, sector, 128, filler );
r1293r1294
700700            int sector = (int) to7qdd->data[ i + 1 ] * 256 + (int) to7qdd->data[ i + 2 ];
701701   
702702            LOG(( "%f $%04x to7_qdd_write_byte: goto data field for sector=%i\n",
703                  mame_time_to_double(mame_timer_get_time()), activecpu_get_previouspc(), sector ));
703                  attotime_to_double(timer_get_time()), activecpu_get_previouspc(), sector ));
704704           
705705            floppy_drive_write_sector_data( to7_qdd_image(), 0, sector, to7qdd->data + to7qdd->start_idx + 1, 128, 0 );
706706         }
r1293r1294
722722   case 0: /* MC6852 status */
723723      to7_qdd_stat_update();
724724      VLOG(( "%f $%04x to7_qdd_r: STAT=$%02X irq=%i pe=%i ovr=%i und=%i tr=%i rd=%i ncts=%i\n",
725             mame_time_to_double(mame_timer_get_time()), activecpu_get_previouspc(), to7qdd->status,
725             attotime_to_double(timer_get_time()), activecpu_get_previouspc(), to7qdd->status,
726726             to7qdd->status & QDD_S_IRQ  ? 1 : 0,
727727             to7qdd->status & QDD_S_PE   ? 1 : 0,
728728             to7qdd->status & QDD_S_OVR  ? 1 : 0,
r1293r1294
745745         data |= 0x40; /* disk present */
746746      if ( to7qdd->index_pulse )
747747         data |= 0x80; /* disk start */
748      VLOG(( "%f $%04x to7_qdd_r: STATUS8 $%02X\n", mame_time_to_double(mame_timer_get_time()), activecpu_get_previouspc(), data ));
748      VLOG(( "%f $%04x to7_qdd_r: STATUS8 $%02X\n", attotime_to_double(timer_get_time()), activecpu_get_previouspc(), data ));
749749      return data;
750750   }
751751 
752752   default:
753      logerror ( "%f $%04x to7_qdd_r: invalid read offset %i\n", mame_time_to_double(mame_timer_get_time()), activecpu_get_previouspc(), offset );
753      logerror ( "%f $%04x to7_qdd_r: invalid read offset %i\n", attotime_to_double(timer_get_time()), activecpu_get_previouspc(), offset );
754754      return 0;
755755   }
756756}
r1293r1294
772772      to7qdd->ctrl1 = ( data & ~(QDD_C1_RRESET | QDD_C1_TRESET) ) |( data &  (QDD_C1_RRESET | QDD_C1_TRESET) & to7qdd->ctrl1 );
773773      to7_qdd_stat_update();
774774      VLOG(( "%f $%04x to7_qdd_w: CTRL1=$%02X reset=%c%c %s%sirq=%c%c\n",
775             mame_time_to_double(mame_timer_get_time()), activecpu_get_previouspc(), data,
775             attotime_to_double(timer_get_time()), activecpu_get_previouspc(), data,
776776             data & QDD_C1_RRESET ? 'r' : '-', data & QDD_C1_TRESET ? 't' : '-',
777777             data & QDD_C1_STRIPSYNC ? "strip-sync " : "",
778778             data & QDD_C1_CLRSYNC ? "clear-sync " : "",
r1293r1294
796796         parity = par[ (data >> 3) & 7 ];
797797         to7_qdd_stat_update();
798798         VLOG(( "%f $%04x to7_qdd_w: CTRL2=$%02X bits=%i par=%s blen=%i under=%s%s\n",
799                mame_time_to_double(mame_timer_get_time()), activecpu_get_previouspc(), data,
799                attotime_to_double(timer_get_time()), activecpu_get_previouspc(), data,
800800                bits, parname[ parity ], data & QDD_C2_BLEN ? 1 : 2,
801801                data & QDD_C2_TSYNC ? "sync" : "ff",
802802                data & QDD_C2_EIE ? "irq-err" : "" ));
r1293r1294
814814            to7qdd->status &= ~QDD_S_NCTS;
815815         to7_qdd_stat_update();
816816         VLOG(( "%f $%04x to7_qdd_w: CTRL3=$%02X %s%ssync-len=%i sync-mode=%s\n",
817                mame_time_to_double(mame_timer_get_time()), activecpu_get_previouspc(), data,
817                attotime_to_double(timer_get_time()), activecpu_get_previouspc(), data,
818818                data & QDD_C3_CLRTUF ? "clr-tuf " : "",
819819                data & QDD_C3_CLRCTS ? "clr-cts " : "",
820820                data & QDD_C3_SYNCLEN ? 1 : 2,
r1293r1294
826826         break;
827827
828828      case 3: /* MC6852 data out => does not seem to be used */
829         VLOG(( "%f $%04x to7_qdd_w: ignored WDATA=$%02X\n", mame_time_to_double(mame_timer_get_time()), activecpu_get_previouspc(), data ));
829         VLOG(( "%f $%04x to7_qdd_w: ignored WDATA=$%02X\n", attotime_to_double(timer_get_time()), activecpu_get_previouspc(), data ));
830830         break;
831831
832832      }
r1293r1294
834834
835835   case 8: /* set drive */
836836      to7qdd->drive = data;
837      VLOG(( "%f $%04x to7_qdd_w: DRIVE=$%02X\n", mame_time_to_double(mame_timer_get_time()), activecpu_get_previouspc(), data ));
837      VLOG(( "%f $%04x to7_qdd_w: DRIVE=$%02X\n", attotime_to_double(timer_get_time()), activecpu_get_previouspc(), data ));
838838      break;
839839
840840   case 12: /* motor pulse ? */
841841      thom_floppy_active( 0 );
842      VLOG(( "%f $%04x to7_qdd_w: MOTOR=$%02X\n", mame_time_to_double(mame_timer_get_time()), activecpu_get_previouspc(), data ));
842      VLOG(( "%f $%04x to7_qdd_w: MOTOR=$%02X\n", attotime_to_double(timer_get_time()), activecpu_get_previouspc(), data ));
843843      break;
844844
845845   default:
846      logerror ( "%f $%04x to7_qdd_w: invalid write offset %i (data=$%02X)\n", mame_time_to_double(mame_timer_get_time()), activecpu_get_previouspc(), offset, data );
846      logerror ( "%f $%04x to7_qdd_w: invalid write offset %i (data=$%02X)\n", attotime_to_double(timer_get_time()), activecpu_get_previouspc(), offset, data );
847847   }
848848}
849849
r1293r1294
951951} * thmfc1;
952952
953953
954static mame_timer* thmfc_floppy_cmd;
954static emu_timer* thmfc_floppy_cmd;
955955
956956
957957
r1293r1294
994994         thmfc1->data_raw_idx = 0;
995995   }
996996
997   VLOG(( "%f thmfc_floppy_index_pulse_cb: state=%i\n", mame_time_to_double(mame_timer_get_time()), state ));
997   VLOG(( "%f thmfc_floppy_index_pulse_cb: state=%i\n", attotime_to_double(timer_get_time()), state ));
998998}
999999
10001000
r1293r1294
10391039static TIMER_CALLBACK( thmfc_floppy_cmd_complete_cb )
10401040{
10411041   LOG (( "%f thmfc_floppy_cmd_complete_cb: cmd=%i off=%i/%i/%i\n",
1042          mame_time_to_double(mame_timer_get_time()), thmfc1->op, thmfc1->data_idx,
1042          attotime_to_double(timer_get_time()), thmfc1->op, thmfc1->data_idx,
10431043          thmfc1->data_finish - 1, thmfc1->data_size - 1 ));
10441044
10451045   if ( thmfc1->op == THMFC1_OP_WRITE_SECT )
r1293r1294
10521052   thmfc1->stat0 |= THMFC1_STAT0_FINISHED;
10531053   thmfc1->data_idx = 0;
10541054   thmfc1->data_size = 0;
1055   mame_timer_adjust( thmfc_floppy_cmd, time_never, 0, time_never );
1055   timer_adjust( thmfc_floppy_cmd, attotime_never, 0, attotime_never );
10561056}
10571057
10581058
r1293r1294
10631063   UINT8 data = thmfc1->data[ thmfc1->data_idx ];
10641064 
10651065   VLOG(( "%f $%04x thmfc_floppy_read_byte: off=%i/%i/%i data=$%02X\n",
1066          mame_time_to_double(mame_timer_get_time()), activecpu_get_previouspc(),
1066          attotime_to_double(timer_get_time()), activecpu_get_previouspc(),
10671067          thmfc1->data_idx, thmfc1->data_finish - 1, thmfc1->data_size - 1,
10681068          data ));
10691069 
r1293r1294
11061106      data = thmfc1->data[ thmfc1->data_raw_idx ];
11071107
11081108   VLOG(( "%f $%04x thmfc_floppy_raw_read_byte: off=%i/%i data=$%02X\n",
1109          mame_time_to_double(mame_timer_get_time()), activecpu_get_previouspc(),
1109          attotime_to_double(timer_get_time()), activecpu_get_previouspc(),
11101110          thmfc1->data_raw_idx, thmfc1->data_raw_size, data ));
11111111 
11121112   thmfc1->data_raw_idx++;
r1293r1294
11441144      }
11451145   
11461146      VLOG (( "%f $%04x thmfc_floppy_qdd_write_byte: $%02X offs=%i-%i\n",
1147         mame_time_to_double(mame_timer_get_time()), activecpu_get_previouspc(), data,
1147         attotime_to_double(timer_get_time()), activecpu_get_previouspc(), data,
11481148         thmfc1->data_idx,thmfc1->data_raw_idx ));
11491149   
11501150      if ( thmfc1->data_raw_idx == thmfc1->data_idx + 3 &&
r1293r1294
11561156         int sector = (int) thmfc1->data[ thmfc1->data_idx ] * 256 + (int) thmfc1->data[ thmfc1->data_idx + 1 ];
11571157         UINT8 filler = 0xff;
11581158     
1159         LOG(( "%f $%04x thmfc_floppy_qdd_write_byte: id field, sector=%i\n", mame_time_to_double(mame_timer_get_time()), activecpu_get_previouspc(), sector ));
1159         LOG(( "%f $%04x thmfc_floppy_qdd_write_byte: id field, sector=%i\n", attotime_to_double(timer_get_time()), activecpu_get_previouspc(), sector ));
11601160     
11611161         floppy_drive_format_sector( thmfc_floppy_image(), 0, sector, 0, 0, sector, 128, filler );
11621162         thmfc1->data_idx = 0;
r1293r1294
11851185               (int) thmfc1->data[ i + 2 ];
11861186   
11871187            LOG(( "%f $%04x thmfc_floppy_qdd_write_byte: data field, sector=%i\n",
1188                  mame_time_to_double(mame_timer_get_time()), activecpu_get_previouspc(), sector ));
1188                  attotime_to_double(timer_get_time()), activecpu_get_previouspc(), sector ));
11891189           
11901190            floppy_drive_write_sector_data( img, 0, sector, thmfc1->data + thmfc1->data_idx, 128, 0 );
11911191         }
r1293r1294
11991199   else
12001200   {
12011201      thmfc1->data_raw_idx++;
1202      VLOG (( "%f $%04x thmfc_floppy_qdd_write_byte: ignored $%02X\n", mame_time_to_double(mame_timer_get_time()), activecpu_get_previouspc(), data ));
1202      VLOG (( "%f $%04x thmfc_floppy_qdd_write_byte: ignored $%02X\n", attotime_to_double(timer_get_time()), activecpu_get_previouspc(), data ));
12031203   }
12041204 
12051205}
r1293r1294
12101210static void thmfc_floppy_write_byte ( UINT8 data )
12111211{
12121212   VLOG (( "%f $%04x thmfc_floppy_write_byte: off=%i/%i data=$%02X\n",
1213      mame_time_to_double(mame_timer_get_time()), activecpu_get_previouspc(),
1213      attotime_to_double(timer_get_time()), activecpu_get_previouspc(),
12141214      thmfc1->data_idx, thmfc1->data_size - 1, data ));
12151215 
12161216   thmfc1->data_raw_size = 0;
r1293r1294
12241224/* intelligent formatting */
12251225static void thmfc_floppy_format_byte ( UINT8 data )
12261226{
1227   VLOG (( "%f $%04x thmfc_floppy_format_byte: $%02X\n", mame_time_to_double(mame_timer_get_time()), activecpu_get_previouspc(), data ));
1227   VLOG (( "%f $%04x thmfc_floppy_format_byte: $%02X\n", attotime_to_double(timer_get_time()), activecpu_get_previouspc(), data ));
12281228 
12291229   thmfc1->data_raw_size = 0;
12301230 
r1293r1294
12641264     
12651265   case 0: /* STAT0 */
12661266      thmfc1->stat0 ^= THMFC1_STAT0_SYNCHRO | THMFC1_STAT0_BYTE_READY_POL;
1267      VLOG(( "%f $%04x thmfc_floppy_r: STAT0=$%02X\n", mame_time_to_double(mame_timer_get_time()), activecpu_get_previouspc(), thmfc1->stat0 ));
1267      VLOG(( "%f $%04x thmfc_floppy_r: STAT0=$%02X\n", attotime_to_double(timer_get_time()), activecpu_get_previouspc(), thmfc1->stat0 ));
12681268      return thmfc1->stat0;
12691269   
12701270   case 1: /* STAT1 */
r1293r1294
12951295         data |= 0x10;
12961296      if ( flags & FLOPPY_DRIVE_DISK_WRITE_PROTECTED )
12971297         data |= 0x04;
1298      VLOG(( "%f $%04x thmfc_floppy_r: STAT1=$%02X\n", mame_time_to_double(mame_timer_get_time()), activecpu_get_previouspc(), data ));
1298      VLOG(( "%f $%04x thmfc_floppy_r: STAT1=$%02X\n", attotime_to_double(timer_get_time()), activecpu_get_previouspc(), data ));
12991299      return data;
13001300   }
13011301   
r1293r1294
13131313   {
13141314      /* undocumented => emulate TO7 QDD controller ? */
13151315      UINT8 data = thmfc1->ipl << 7;
1316      VLOG(( "%f $%04x thmfc_floppy_r: STAT8=$%02X\n", mame_time_to_double(mame_timer_get_time()), activecpu_get_previouspc(), data ));
1316      VLOG(( "%f $%04x thmfc_floppy_r: STAT8=$%02X\n", attotime_to_double(timer_get_time()), activecpu_get_previouspc(), data ));
13171317      return data;
13181318   }
13191319
13201320   default:
1321      logerror ( "%f $%04x thmfc_floppy_r: invalid read offset %i\n", mame_time_to_double(mame_timer_get_time()), activecpu_get_previouspc(), offset );
1321      logerror ( "%f $%04x thmfc_floppy_r: invalid read offset %i\n", attotime_to_double(timer_get_time()), activecpu_get_previouspc(), offset );
13221322      return 0;
13231323   }
13241324}
r1293r1294
13381338      thom_floppy_set_density( dens );
13391339      thmfc1->formatting = (data >> 2) & 1;
13401340      LOG (( "%f $%04x thmfc_floppy_w: CMD0=$%02X dens=%s wsync=%i dsync=%i fmt=%i op=%i\n",
1341             mame_time_to_double(mame_timer_get_time()), activecpu_get_previouspc(), data, 
1341             attotime_to_double(timer_get_time()), activecpu_get_previouspc(), data, 
13421342             (dens == DEN_FM_LO) ? "MF" : "MFM",
13431343             wsync, (data >> 3) & 1,
13441344             thmfc1->formatting, data & 3 ));
13451345     
13461346      /* abort previous command, if any */
13471347      thmfc1->op = THMFC1_OP_RESET;
1348      mame_timer_adjust( thmfc_floppy_cmd, time_never, 0, time_never );
1348      timer_adjust( thmfc_floppy_cmd, attotime_never, 0, attotime_never );
13491349     
13501350      switch ( data & 3 )
13511351      {
r1293r1294
13641364            thmfc1->data_finish = thmfc1->sector_size + 3;
13651365            thmfc1->stat0 |= THMFC1_STAT0_BYTE_READY_OP;
13661366            thmfc1->op = THMFC1_OP_WRITE_SECT;
1367            mame_timer_adjust( thmfc_floppy_cmd, MAME_TIME_IN_MSEC( 10 ), 0, time_never );
1367            timer_adjust( thmfc_floppy_cmd, ATTOTIME_IN_MSEC( 10 ), 0, attotime_never );
13681368         }
13691369         break;
13701370   
r1293r1294
13801380            thmfc1->data_idx = 1;
13811381            thmfc1->stat0 |= THMFC1_STAT0_BYTE_READY_OP;
13821382            thmfc1->op = THMFC1_OP_READ_ADDR;
1383            mame_timer_adjust( thmfc_floppy_cmd, MAME_TIME_IN_MSEC( 1 ), 0, time_never );
1383            timer_adjust( thmfc_floppy_cmd, ATTOTIME_IN_MSEC( 1 ), 0, attotime_never );
13841384         }
13851385         break;
13861386   
r1293r1294
13961396            thmfc1->data_idx = 1;
13971397            thmfc1->stat0 |= THMFC1_STAT0_BYTE_READY_OP;
13981398            thmfc1->op = THMFC1_OP_READ_SECT;
1399            mame_timer_adjust( thmfc_floppy_cmd, MAME_TIME_IN_MSEC( 10 ), 0, time_never );
1399            timer_adjust( thmfc_floppy_cmd, ATTOTIME_IN_MSEC( 10 ), 0, attotime_never );
14001400         }
14011401         break;
14021402      }
r1293r1294
14281428      }
14291429   
14301430      LOG (( "%f $%04x thmfc_floppy_w: CMD1=$%02X sect-size=%i comp=%i head=%i\n",
1431             mame_time_to_double(mame_timer_get_time()), activecpu_get_previouspc(), data,
1431             attotime_to_double(timer_get_time()), activecpu_get_previouspc(), data,
14321432             thmfc1->sector_size, (data >> 1) & 7, thmfc1->side ));
14331433      break;
14341434
r1293r1294
14561456      thom_floppy_active( 0 );
14571457     
14581458      LOG (( "%f $%04x thmfc_floppy_w: CMD2=$%02X drv=%i step=%i motor=%i\n",
1459             mame_time_to_double(mame_timer_get_time()), activecpu_get_previouspc(), data,
1459             attotime_to_double(timer_get_time()), activecpu_get_previouspc(), data,
14601460             thmfc1->drive, seek, motor ));
14611461 
14621462      if ( seek )
r1293r1294
14861486      {
14871487         /* TODO: implement other forms of raw track writing */
14881488         LOG (( "%f $%04x thmfc_floppy_w: ignored raw WDATA $%02X\n",
1489                mame_time_to_double(mame_timer_get_time()), activecpu_get_previouspc(), data ));
1489                attotime_to_double(timer_get_time()), activecpu_get_previouspc(), data ));
14901490      }
14911491      break;
14921492   
r1293r1294
14941494   case 4: /* WCLK (unemulated) */
14951495      /* clock configuration: FF for data, 0A for synchro */
14961496      LOG (( "%f $%04x thmfc_floppy_w: WCLK=$%02X (%s)\n",
1497             mame_time_to_double(mame_timer_get_time()), activecpu_get_previouspc(), data,
1497             attotime_to_double(timer_get_time()), activecpu_get_previouspc(), data,
14981498             (data == 0xff) ? "data" : (data == 0x0A) ? "synchro" : "?" ));
14991499      break;
15001500
15011501   case 5: /* WSECT */
15021502      thmfc1->sector = data;
15031503      LOG (( "%f $%04x thmfc_floppy_w: WSECT=%i\n",
1504             mame_time_to_double(mame_timer_get_time()), activecpu_get_previouspc(), data ));
1504             attotime_to_double(timer_get_time()), activecpu_get_previouspc(), data ));
15051505      break;
15061506
15071507   case 6: /* WTRCK */
15081508      thmfc1->track = data;
15091509      LOG (( "%f $%04x thmfc_floppy_w: WTRCK=%i (real=%i)\n",
1510             mame_time_to_double(mame_timer_get_time()), activecpu_get_previouspc(), data,
1510             attotime_to_double(timer_get_time()), activecpu_get_previouspc(), data,
15111511             floppy_drive_get_current_track( thmfc_floppy_image() ) ));
15121512      break;
15131513
15141514   case 7: /* WCELL */
15151515      /* precompensation (unemulated) */
15161516      LOG (( "%f $%04x thmfc_floppy_w: WCELL=$%02X\n",
1517             mame_time_to_double(mame_timer_get_time()), activecpu_get_previouspc(), data ));
1517             attotime_to_double(timer_get_time()), activecpu_get_previouspc(), data ));
15181518      break;
15191519     
15201520   default:
15211521      logerror ( "%f $%04x thmfc_floppy_w: invalid write offset %i (data=$%02X)\n",
1522            mame_time_to_double(mame_timer_get_time()), activecpu_get_previouspc(), offset, data );
1522            attotime_to_double(timer_get_time()), activecpu_get_previouspc(), offset, data );
15231523   }
15241524}
15251525
r1293r1294
15531553   thmfc1->data_raw_size = 0;
15541554   thmfc1->data_crc = 0;
15551555   thmfc1->wsync = 0;
1556   mame_timer_adjust( thmfc_floppy_cmd, time_never, 0, time_never );
1556   timer_adjust( thmfc_floppy_cmd, attotime_never, 0, attotime_never );
15571557}
15581558
15591559
r1293r1294
15651565   thmfc1 = auto_malloc( sizeof( *thmfc1 ) );
15661566   assert( thmfc1 );
15671567
1568   thmfc_floppy_cmd = mame_timer_alloc( thmfc_floppy_cmd_complete_cb );
1568   thmfc_floppy_cmd = timer_alloc( thmfc_floppy_cmd_complete_cb );
15691569
15701570   state_save_register_global( thmfc1->op );
15711571   state_save_register_global( thmfc1->sector );
r1293r1294
16031603
16041604static TIMER_CALLBACK( ans4 )
16051605{
1606   LOG(( "%f ans4\n", mame_time_to_double(mame_timer_get_time()) ));
1606   LOG(( "%f ans4\n", attotime_to_double(timer_get_time()) ));
16071607   mc6854_set_cts( 0 );
16081608}
16091609
16101610static TIMER_CALLBACK( ans3 )
16111611{
1612   LOG(( "%f ans3\n", mame_time_to_double(mame_timer_get_time()) ));
1612   LOG(( "%f ans3\n", attotime_to_double(timer_get_time()) ));
16131613   mc6854_set_cts( 1 );
1614   mame_timer_set(  MAME_TIME_IN_USEC( 100 ), 0, ans4 );
1614   timer_set(  ATTOTIME_IN_USEC( 100 ), 0, ans4 );
16151615}
16161616
16171617static TIMER_CALLBACK( ans2 )
16181618{
1619   LOG(( "%f ans2\n", mame_time_to_double(mame_timer_get_time()) ));
1619   LOG(( "%f ans2\n", attotime_to_double(timer_get_time()) ));
16201620   mc6854_set_cts( 0 );
1621   mame_timer_set(  MAME_TIME_IN_USEC( 100 ), 0, ans3 );
1621   timer_set(  ATTOTIME_IN_USEC( 100 ), 0, ans3 );
16221622}
16231623
16241624static TIMER_CALLBACK( ans )
16251625{
1626   LOG(( "%f ans\n", mame_time_to_double(mame_timer_get_time()) ));
1626   LOG(( "%f ans\n", attotime_to_double(timer_get_time()) ));
16271627   mc6854_set_cts( 1 );
1628   mame_timer_set(  MAME_TIME_IN_USEC( 100 ), 0, ans2 );
1628   timer_set(  ATTOTIME_IN_USEC( 100 ), 0, ans2 );
16291629}
16301630/* consigne DKBOOT
16311631
r1293r1294
16591659static void to7_network_got_frame( UINT8* data, int length )
16601660{
16611661   int i;
1662   LOG(( "%f to7_network_got_frame:", mame_time_to_double(mame_timer_get_time()) ));
1662   LOG(( "%f to7_network_got_frame:", attotime_to_double(timer_get_time()) ));
16631663   for ( i = 0; i < length; i++ )
16641664      LOG(( " $%02X", data[i] ));
16651665   LOG(( "\n" ));
r1293r1294
16671667   if ( data[1] == 0xff )
16681668   {
16691669      LOG(( "to7_network_got_frame: %i phones %i\n", data[2], data[0] ));
1670      mame_timer_set(  MAME_TIME_IN_USEC( 100 ), 0, ans  );
1670      timer_set(  ATTOTIME_IN_USEC( 100 ), 0, ans  );
16711671      mc6854_set_cts( 0 );
16721672   }
16731673   else if ( ! data[1] )
r1293r1294
17211721   {
17221722      /* network ID of the computer */
17231723      UINT8 id = readinputport( THOM_INPUT_FCONFIG ) >> 3;
1724      VLOG(( "%f $%04x to7_network_r: read id $%02X\n", mame_time_to_double(mame_timer_get_time()), activecpu_get_previouspc(), id ));
1724      VLOG(( "%f $%04x to7_network_r: read id $%02X\n", attotime_to_double(timer_get_time()), activecpu_get_previouspc(), id ));
17251725      return id;
17261726   }
17271727
1728   logerror( "%f $%04x to7_network_r: invalid read offset %i\n", mame_time_to_double(mame_timer_get_time()), activecpu_get_previouspc(), offset );
1728   logerror( "%f $%04x to7_network_r: invalid read offset %i\n", attotime_to_double(timer_get_time()), activecpu_get_previouspc(), offset );
17291729   return 0;
17301730}
17311731
r1293r1294
17381738   else
17391739   {
17401740      logerror( "%f $%04x to7_network_w: invalid write offset %i (data=$%02X)\n",
1741           mame_time_to_double(mame_timer_get_time()), activecpu_get_previouspc(), offset, data );
1741           attotime_to_double(timer_get_time()), activecpu_get_previouspc(), offset, data );
17421742   }
17431743}
17441744
src/mess/devices/snapquik.c
r1293r1294
6363
6464   delay = device_get_info_double(&si->dev->devclass, DEVINFO_FLOAT_SNAPSHOT_DELAY);
6565
66   mame_timer_set_ptr(double_to_mame_time(delay), si, snapquick_processsnapshot);
66   timer_set_ptr(double_to_attotime(delay), si, snapquick_processsnapshot);
6767   return INIT_PASS;
6868}
6969
src/mess/tools/messtest/testmess.c
r1293r1294
5656   messtest_command_type_t command_type;
5757   union
5858   {
59      mame_time wait_time;
59      attotime wait_time;
6060      struct
6161      {
6262         const char *input_chars;
63         mame_time rate;
63         attotime rate;
6464      } input_args;
6565      struct
6666      {
r1293r1294
9393   const char *name;
9494   const char *bios;
9595   const char *driver;
96   mame_time time_limit;   /* 0.0 = default */
96   attotime time_limit;   /* 0.0 = default */
9797   struct messtest_command *commands;
9898
9999   /* options */
r1293r1294
129129
130130static messtest_running_state_t state;
131131static int had_failure;
132static mame_time wait_target;
133static mame_time final_time;
132static attotime wait_target;
133static attotime final_time;
134134static const struct messtest_command *current_command;
135135static int test_flags;
136136static int screenshot_num;
r1293r1294
362362         if (had_failure)
363363         {
364364            report_message(MSG_FAILURE, "Test failed (real time %.2f; emu time %.2f [%i%%])",
365               real_run_time, mame_time_to_double(final_time), (int) ((mame_time_to_double(final_time) / real_run_time) * 100));
365               real_run_time, attotime_to_double(final_time), (int) ((attotime_to_double(final_time) / real_run_time) * 100));
366366            rc = MESSTEST_RESULT_RUNTIMEFAILURE;
367367         }
368368         else
369369         {
370370            report_message(MSG_INFO, "Test succeeded (real time %.2f; emu time %.2f [%i%%])",
371               real_run_time, mame_time_to_double(final_time), (int) ((mame_time_to_double(final_time) / real_run_time) * 100));
371               real_run_time, attotime_to_double(final_time), (int) ((attotime_to_double(final_time) / real_run_time) * 100));
372372            rc = MESSTEST_RESULT_SUCCESS;
373373         }
374374         break;
r1293r1294
492492
493493static void command_wait(void)
494494{
495   mame_time current_time = mame_timer_get_time();
495   attotime current_time = timer_get_time();
496496
497497   if (state == STATE_READY)
498498   {
499499      /* beginning a wait command */
500      wait_target = add_mame_times(current_time, current_command->u.wait_time);
500      wait_target = attotime_add(current_time, current_command->u.wait_time);
501501      state = STATE_INCOMMAND;
502502   }
503503   else
504504   {
505505      /* during a wait command */
506      state = (compare_mame_times(current_time, wait_target) >= 0) ? STATE_READY : STATE_INCOMMAND;
506      state = (attotime_compare(current_time, wait_target) >= 0) ? STATE_READY : STATE_INCOMMAND;
507507   }
508508}
509509
r1293r1294
536536static void command_rawinput(void)
537537{
538538   int parts;
539   mame_time current_time = mame_timer_get_time();
539   attotime current_time = timer_get_time();
540540   static const char *position;
541541#if 0
542542   int i;
543   double rate = MAME_TIME_IN_SEC(1);
543   double rate = ATTOTIME_IN_SEC(1);
544544   const char *s;
545545   char buf[256];
546546#endif
r1293r1294
553553      wait_target = current_time;
554554      state = STATE_INCOMMAND;
555555   }
556   else if (compare_mame_times(current_time, wait_target) > 0)
556   else if (attotime_compare(current_time, wait_target) > 0)
557557   {
558558#if 0
559559      do
r1293r1294
944944{
945945   /* at the end of our test */
946946   state = STATE_DONE;
947   final_time = mame_timer_get_time();
947   final_time = timer_get_time();
948948   mame_schedule_exit(Machine);
949949}
950950
r1293r1294
980980void osd_update(int skip_redraw)
981981{
982982   int i;
983   mame_time time_limit;
984   mame_time current_time;
983   attotime time_limit;
984   attotime current_time;
985985   int cpunum;
986986
987987   render_target_get_primitives(target);
r1293r1294
10011001   }
10021002
10031003   /* have we hit the time limit? */
1004   current_time = mame_timer_get_time();
1005   time_limit = (compare_mame_times(current_testcase.time_limit, time_zero) != 0) ? current_testcase.time_limit
1006      : MAME_TIME_IN_SEC(600);
1007   if (compare_mame_times(current_time, time_limit) > 0)
1004   current_time = timer_get_time();
1005   time_limit = (attotime_compare(current_testcase.time_limit, attotime_zero) != 0) ? current_testcase.time_limit
1006      : ATTOTIME_IN_SEC(600);
1007   if (attotime_compare(current_time, time_limit) > 0)
10081008   {
10091009      state = STATE_ABORTED;
10101010      report_message(MSG_FAILURE, "Time limit of %.2f seconds exceeded", time_limit);
r1293r1294
11581158{
11591159   /* <input> - inputs natural keyboard data into a system */
11601160   xml_attribute_node *attr_node;
1161   mame_time rate;
1161   attotime rate;
11621162
11631163   memset(&new_command, 0, sizeof(new_command));
11641164   new_command.command_type = MESSTEST_COMMAND_INPUT;
11651165   attr_node = xml_get_attribute(node, "rate");
1166   rate = attr_node ? parse_time(attr_node->value) : make_mame_time(0, 0);
1166   rate = attr_node ? parse_time(attr_node->value) : attotime_make(0, 0);
11671167   new_command.u.input_args.rate = rate;
11681168   new_command.u.input_args.input_chars = node->value;
11691169
src/mess/tools/messtest/core.c
r1293r1294
609609/*   if ((msgtype == MSG_FAILURE) && (state != STATE_ABORTED))
610610   {
611611      state = STATE_ABORTED;
612      final_time = mame_timer_get_time();
612      final_time = timer_get_time();
613613      if (final_time > 0.0)
614614         dump_screenshot();
615615   }
src/mess/tools/messtest/tstutils.c
r1293r1294
8585
8686
8787
88mame_time parse_time(const char *s)
88attotime parse_time(const char *s)
8989{
9090   double d = atof(s);
91   return double_to_mame_time(d);
91   return double_to_attotime(d);
9292}
9393
9494
src/mess/tools/messtest/core.h
r1293r1294
6666int memory_region_from_string(const char *region_name);
6767const char *memory_region_to_string(int region);
6868const char *find_attribute(const char **attributes, const char *seek_attribute);
69mame_time parse_time(const char *s);
69attotime parse_time(const char *s);
7070offs_t parse_offset(const char *s);
7171
7272/* reporting */
src/mess/audio/mea8000.c
r1293r1294
110110   UINT16 last_pitch, pitch;  /* pitch of sawtooth signal, in Hz */
111111   UINT8  noise;
112112
113   mame_timer *timer;
113   emu_timer *timer;
114114 
115115} mea8000;
116116
r1293r1294
133133#define SUPERSAMPLING 8
134134
135135/* actual output pediod */
136#define SAMPLING MAME_TIME_IN_HZ((SUPERSAMPLING*F0))
136#define SAMPLING ATTOTIME_IN_HZ((SUPERSAMPLING*F0))
137137
138138
139139
r1293r1294
457457static void mea8000_start_frame( void )
458458{
459459   /* enter or stay in active mode */
460   mame_timer_reset( mea8000.timer, SAMPLING );
460   timer_reset( mea8000.timer, SAMPLING );
461461   mea8000.framepos = 0;
462462}
463463
r1293r1294
466466static void mea8000_stop_frame( void )
467467{
468468   /* enter stop mode */
469   mame_timer_reset( mea8000.timer, time_never );
469   timer_reset( mea8000.timer, attotime_never );
470470   mea8000.state = MEA8000_STOPPED;
471471   DAC_signed_data_16_w(mea8000.channel, 0);
472472}
r1293r1294
502502      if (mea8000.bufpos == 4)
503503      {
504504         /* we have a successor */
505         LOG(( "%f mea8000_timer_expire: new frame\n", mame_time_to_double(mame_timer_get_time()) ));
505         LOG(( "%f mea8000_timer_expire: new frame\n", attotime_to_double(timer_get_time()) ));
506506         mea8000_decode_frame();
507507         mea8000_start_frame();
508508      }
509509      else if (mea8000.cont) 
510510      {
511511         /* repeat mode */
512         LOG(( "%f mea8000_timer_expire: repeat frame\n", mame_time_to_double(mame_timer_get_time()) ));
512         LOG(( "%f mea8000_timer_expire: repeat frame\n", attotime_to_double(timer_get_time()) ));
513513         mea8000_start_frame();
514514      }
515515      /* slow stop */
516516      else if (mea8000.state == MEA8000_STARTED)
517517      {
518518         mea8000.ampl = 0;
519         LOG(( "%f mea8000_timer_expire: fade frame\n", mame_time_to_double(mame_timer_get_time()) ));
519         LOG(( "%f mea8000_timer_expire: fade frame\n", attotime_to_double(timer_get_time()) ));
520520         mea8000_start_frame();
521521         mea8000.state = MEA8000_SLOWING;
522522      }
523523      else if (mea8000.state == MEA8000_SLOWING)
524524      {
525         LOG(( "%f mea8000_timer_expire: stop frame\n", mame_time_to_double(mame_timer_get_time()) ));
525         LOG(( "%f mea8000_timer_expire: stop frame\n", attotime_to_double(timer_get_time()) ));
526526         mea8000_stop_frame();
527527      }
528528      mea8000_update_req();
r1293r1294
530530   else
531531   {
532532      /* continue frame */
533      mame_timer_reset( mea8000.timer, SAMPLING );
533      timer_reset( mea8000.timer, SAMPLING );
534534   }
535535}
536536
r1293r1294
549549   case 1:
550550      /* ready to accept next frame */
551551#if 0
552      LOG(( "$%04x %f: mea8000_r ready=%i\n", activecpu_get_previouspc(), mame_time_to_double(mame_timer_get_time()), mea8000_accept_byte() ));
552      LOG(( "$%04x %f: mea8000_r ready=%i\n", activecpu_get_previouspc(), attotime_to_double(timer_get_time()), mea8000_accept_byte() ));
553553#endif
554554      return mea8000_accept_byte() << 7;
555555
r1293r1294
569569      {
570570         /* got pitch byte before first frame */
571571         mea8000.pitch = 2 * data;
572         LOG(( "$%04x %f: mea8000_w pitch %i\n", activecpu_get_previouspc(), mame_time_to_double(mame_timer_get_time()), mea8000.pitch ));
572         LOG(( "$%04x %f: mea8000_w pitch %i\n", activecpu_get_previouspc(), attotime_to_double(timer_get_time()), mea8000.pitch ));
573573         mea8000.state = MEA8000_WAIT_FIRST;
574574         mea8000.bufpos = 0;
575575      }
576576      else if (mea8000.bufpos == 4)
577577      {
578578         /* overflow */
579         LOG(( "$%04x %f: mea8000_w data overflow %02X\n", activecpu_get_previouspc(), mame_time_to_double(mame_timer_get_time()), data ));
579         LOG(( "$%04x %f: mea8000_w data overflow %02X\n", activecpu_get_previouspc(), attotime_to_double(timer_get_time()), data ));
580580      }
581581      else
582582      {
583583         /* enqueue frame byte */
584         LOG(( "$%04x %f: mea8000_w data %02X in frame pos %i\n", activecpu_get_previouspc(), mame_time_to_double(mame_timer_get_time()),
584         LOG(( "$%04x %f: mea8000_w data %02X in frame pos %i\n", activecpu_get_previouspc(), attotime_to_double(timer_get_time()),
585585               data, mea8000.bufpos ));
586586         mea8000.buf[mea8000.bufpos] = data;
587587         mea8000.bufpos++;
r1293r1294
615615         mea8000_stop_frame();
616616
617617      LOG(( "$%04x %f: mea8000_w command %02X stop=%i cont=%i roe=%i\n",
618            activecpu_get_previouspc(), mame_time_to_double(mame_timer_get_time()), data,
618            activecpu_get_previouspc(), attotime_to_double(timer_get_time()), data,
619619            stop, mea8000.cont, mea8000.roe ));     
620620
621621      mea8000_update_req();
r1293r1294
637637{
638638   int i;
639639   LOG (( "mea8000_reset\n" ));
640   mame_timer_reset( mea8000.timer, time_never );
640   timer_reset( mea8000.timer, attotime_never );
641641   mea8000.phi = 0;
642642   mea8000.cont = 0;
643643   mea8000.roe = 0;
r1293r1294
663663   mea8000_init_tables();
664664   mea8000.channel = channel;
665665   mea8000.req_out_func = req_out_func;
666   mea8000.timer = mame_timer_alloc( mea8000_timer_expire );
666   mea8000.timer = timer_alloc( mea8000_timer_expire );
667667
668668   state_save_register_item( "mea8000", 0, mea8000.state );
669669   state_save_register_item_array( "mea8000", 0, mea8000.buf );
src/mess/audio/dave.c
r1293r1294
167167   dave.one_khz_state = 0;
168168   dave.fifty_hz_count = DAVE_FIFTY_HZ_COUNTER_RELOAD;
169169   dave.one_hz_count = DAVE_ONE_HZ_COUNTER_RELOAD;
170   mame_timer_pulse(MAME_TIME_IN_HZ(1000), 0, dave_1khz_callback);
170   timer_pulse(ATTOTIME_IN_HZ(1000), 0, dave_1khz_callback);
171171   
172172   for (i=0; i<3; i++)
173173   {
src/mess/audio/t6721.c
r1293r1294
101101void c364_speech_init(void)
102102{
103103   memset(&speech, 0, sizeof(speech));
104   speech.timer = mame_timer_alloc(c364_speech_timer);
104   speech.timer = timer_alloc(c364_speech_timer);
105105}
106106
107107WRITE8_HANDLER(c364_speech_w)
r1293r1294
117117               speech.playing=FALSE;
118118               break;
119119            case 1: /* start */
120               mame_timer_adjust(speech.timer, time_zero, 0, MAME_TIME_IN_HZ(8000));
120               timer_adjust(speech.timer, attotime_zero, 0, ATTOTIME_IN_HZ(8000));
121121               speech.playing=TRUE;
122122               speech.endOfSample=FALSE;
123123               speech.sampleindex=0;
r1293r1294
125125            case 2:
126126               speech.endOfSample=FALSE;
127127               /*speech.busy=FALSE; */
128               mame_timer_reset(speech.timer, time_never);
128               timer_reset(speech.timer, attotime_never);
129129               speech.playing=FALSE;
130130               break;
131131            case 5: /* set rate (in next nibble) */
src/mess/audio/lynx.c
r1293r1294
219219
220220void lynx_audio_write(int offset, UINT8 data)
221221{
222//   logerror("%.6f audio write %.2x %.2x\n", mame_timer_get_time(), offset, data);
222//   logerror("%.6f audio write %.2x %.2x\n", timer_get_time(), offset, data);
223223    LYNX_AUDIO *channel=lynx_audio+((offset>>3)&3);
224224    stream_update(mixer_channel);
225225    switch (offset) {
src/mess/audio/svision.c
r1293r1294
2222
2323WRITE8_HANDLER( svision_sounddma_w )
2424{
25   logerror("%.6f svision snddma write %04x %02x\n", mame_time_to_double(mame_timer_get_time()),offset+0x18,data);
25   logerror("%.6f svision snddma write %04x %02x\n", attotime_to_double(timer_get_time()),offset+0x18,data);
2626   svision_dma.reg[offset] = data;
2727   switch (offset)
2828   {
r1293r1294
5151
5252WRITE8_HANDLER( svision_noise_w )
5353{
54   //  logerror("%.6f svision noise write %04x %02x\n",mame_timer_get_time(),offset+0x28,data);
54   //  logerror("%.6f svision noise write %04x %02x\n",timer_get_time(),offset+0x28,data);
5555   svision_noise.reg[offset]=data;
5656   switch (offset)
5757   {
src/mess/image.c
r1293r1294
561561      goto done;
562562
563563   /* do we need to reset the CPU? */
564   if ((compare_mame_times(mame_timer_get_time(), time_zero) > 0) && image->dev->reset_on_load)
564   if ((attotime_compare(timer_get_time(), attotime_zero) > 0) && image->dev->reset_on_load)
565565      mame_schedule_hard_reset(Machine);
566566
567567   /* determine open plan */
src/mess/includes/cbm.h
r1293r1294
3232        { \
3333     if(LEVEL>=N) { \
3434       if( M ) \
35              logerror("%11.6f: %-24s",mame_timer_get_time(), (char*)M );\
35              logerror("%11.6f: %-24s",timer_get_time(), (char*)M );\
3636       logerror A; \
3737     } \
3838        }
src/mess/includes/zx.h
r1293r1294
1919void zx_ula_bkgnd(int color);
2020int zx_ula_r(int offs, int region);
2121
22extern mame_timer *ula_nmi;
22extern emu_timer *ula_nmi;
2323extern int ula_irq_active;
2424extern int ula_nmi_active;
2525extern int ula_frame_vsync;
src/mess/includes/coco.h
r1293r1294
1414
1515#define COCO_CPU_SPEED_HZ      894886   /* 0.894886 MHz */
1616#define COCO_FRAMES_PER_SECOND   (COCO_CPU_SPEED_HZ / 57.0 / 263)
17#define COCO_CPU_SPEED         (MAME_TIME_IN_HZ(COCO_CPU_SPEED_HZ))
17#define COCO_CPU_SPEED         (ATTOTIME_IN_HZ(COCO_CPU_SPEED_HZ))
1818#define COCO_TIMER_CMPCARRIER   (COCO_CPU_SPEED * 0.25)
1919
2020/* ----------------------------------------------------------------------- *
src/mess/includes/vectrex.h
r1293r1294
1717extern UINT32 vectrex_beam_color;
1818extern unsigned char vectrex_via_out[2];
1919extern double imager_freq;
20extern mame_timer *imager_timer;
20extern emu_timer *imager_timer;
2121extern int vectrex_lightpen_port;
2222extern UINT8 *vectrex_ram_base;
2323extern size_t vectrex_ram_size;
src/mess/includes/apple1.h
r1293r1294
1616
1717void apple1_vh_dsp_w (int data);
1818void apple1_vh_dsp_clr (void);
19mame_time apple1_vh_dsp_time_to_ready (void);
19attotime apple1_vh_dsp_time_to_ready (void);
2020
2121extern int apple1_vh_clrscrn_pressed;
2222
src/mess/includes/cbmdrive.h
r1293r1294
4646         int forme;               /* i am selected */
4747         int last;               /* last byte to be sent */
4848         int broadcast;            /* sent to all */
49         mame_time time;
49         attotime time;
5050      }
5151      serial;
5252      struct
src/mess/video/zx.c
r1293r1294
2222#include "includes/zx.h"
2323#include "sound/dac.h"
2424
25mame_timer *ula_nmi = NULL;
26mame_timer *ula_irq = NULL;
25emu_timer *ula_nmi = NULL;
26emu_timer *ula_irq = NULL;
2727int ula_nmi_active, ula_irq_active;
2828int ula_frame_vsync = 0;
2929int ula_scancode_count = 0;
r1293r1294
145145      y = video_screen_get_vpos(0);
146146
147147      cycles = 4 * (64 - (rreg & 63));
148      mame_timer_set(MAME_TIME_IN_CYCLES(cycles, 0), 0, zx_ula_irq);
148      timer_set(ATTOTIME_IN_CYCLES(cycles, 0), 0, zx_ula_irq);
149149      ula_irq_active = 1;
150150      scanline = BITMAP_ADDR16(bitmap, y, 0);
151151
r1293r1294
185185
186186VIDEO_START( zx )
187187{
188   ula_nmi = mame_timer_alloc(zx_ula_nmi);
188   ula_nmi = timer_alloc(zx_ula_nmi);
189189   ula_irq_active = 0;
190190   video_start_generic_bitmapped(machine);
191191}
src/mess/video/vic6560.c
r1293r1294
257257   case 6:                     /*lightpen horicontal */
258258   case 7:                     /*lightpen vertical */
259259      if (LIGHTPEN_BUTTON
260         && ((mame_time_to_double(mame_timer_get_time ()) - lightpenreadtime) * VIC6560_VRETRACERATE >= 1))
260         && ((attotime_to_double(timer_get_time ()) - lightpenreadtime) * VIC6560_VRETRACERATE >= 1))
261261      {
262262         /* only 1 update each frame */
263263         /* and diode must recognize light */
r1293r1294
266266            vic6560[6] = VIC6560_X_VALUE;
267267            vic6560[7] = VIC6560_Y_VALUE;
268268         }
269         lightpenreadtime = mame_time_to_double(mame_timer_get_time ());
269         lightpenreadtime = attotime_to_double(timer_get_time ());
270270      }
271271      val = vic6560[offset];
272272      break;
src/mess/video/911_vdt.c
r1293r1294
237237   else
238238      vdt[unit].cursor_address_mask = 0x7ff;   /* 2 kb of RAM */
239239
240   mame_timer_set(time_zero, unit, setup_beep);
240   timer_set(attotime_zero, unit, setup_beep);
241241
242242   /* set up cursor blink clock.  2Hz frequency -> .25s half-period. */
243   /*vdt[unit].blink_clock =*/ mame_timer_pulse(MAME_TIME_IN_MSEC(250), unit, blink_callback);
243   /*vdt[unit].blink_clock =*/ timer_pulse(ATTOTIME_IN_MSEC(250), unit, blink_callback);
244244
245245   /* alloc beep timer */
246   vdt[unit].beep_timer = mame_timer_alloc(beep_callback);
246   vdt[unit].beep_timer = timer_alloc(beep_callback);
247247
248248   return 0;
249249}
r1293r1294
444444         /* beep enable strobe - not tested */
445445         beep_set_state(unit, 1);
446446
447         mame_timer_adjust(vdt[unit].beep_timer, MAME_TIME_IN_USEC(300), unit, time_zero);
447         timer_adjust(vdt[unit].beep_timer, ATTOTIME_IN_USEC(300), unit, attotime_zero);
448448         break;
449449
450450      case 0xf:
src/mess/video/gb.c
r1293r1294
8989   int mode_irq;
9090   int delayed_line_irq;
9191   struct layer_struct   layer[2];
92   mame_timer   *lcd_timer;
92   emu_timer   *lcd_timer;
9393} gb_lcd;
9494
9595void (*update_scanline)(void);
r1293r1294
320320   /* Make sure we're in mode 3 */
321321   if ( ( LCDSTAT & 0x03 ) == 0x03 ) {
322322      /* Calculate number of pixels to render based on time still left on the timer */
323      UINT32 cycles_to_go = MAME_TIME_TO_CYCLES( 0, mame_timer_timeleft( gb_lcd.lcd_timer ) );
323      UINT32 cycles_to_go = ATTOTIME_TO_CYCLES( 0, timer_timeleft( gb_lcd.lcd_timer ) );
324324      int l = 0;
325325
326326      if ( gb_lcd.start_x == 0 ) {
r1293r1294
603603
604604   if ( ( LCDSTAT & 0x03 ) == 0x03 ) {
605605      /* Calcuate number of pixels to render based on time still left on the timer */
606      UINT32 cycles_to_go = MAME_TIME_TO_CYCLES( 0, mame_timer_timeleft( gb_lcd.lcd_timer ) );
606      UINT32 cycles_to_go = ATTOTIME_TO_CYCLES( 0, timer_timeleft( gb_lcd.lcd_timer ) );
607607      int l = 0;
608608
609609      if ( gb_lcd.start_x == 0 ) {
r1293r1294
866866
867867   if ( ( LCDSTAT & 0x03 ) == 0x03 ) {
868868      /* Calcuate number of pixels to render based on time still left on the timer */
869      UINT32 cycles_to_go = MAME_TIME_TO_CYCLES( 0, mame_timer_timeleft( gb_lcd.lcd_timer ) );
869      UINT32 cycles_to_go = ATTOTIME_TO_CYCLES( 0, timer_timeleft( gb_lcd.lcd_timer ) );
870870      int l = 0;
871871
872872      if ( gb_lcd.start_x == 0 ) {
r1293r1294
10491049   /* set the scanline update function */
10501050   update_scanline = gb_update_scanline;
10511051
1052   gb_lcd.lcd_timer = mame_timer_alloc( gb_lcd_timer_proc );
1053   mame_timer_adjust( gb_lcd.lcd_timer, MAME_TIME_IN_CYCLES(456,0), 0, time_never );
1052   gb_lcd.lcd_timer = timer_alloc( gb_lcd_timer_proc );
1053   timer_adjust( gb_lcd.lcd_timer, ATTOTIME_IN_CYCLES(456,0), 0, attotime_never );
10541054}
10551055
10561056void sgb_video_init( void ) {
r1293r1294
11781178         /* Check for HBLANK DMA */
11791179         if( gbc_hdma_enabled )
11801180            gbc_hdma(0x10);
1181         mame_timer_adjust( gb_lcd.lcd_timer, MAME_TIME_IN_CYCLES(196 - 10 * gb_lcd.sprCount,0), GB_LCD_STATE_LYXX_M0_PRE_INC, time_never );
1181         timer_adjust( gb_lcd.lcd_timer, ATTOTIME_IN_CYCLES(196 - 10 * gb_lcd.sprCount,0), GB_LCD_STATE_LYXX_M0_PRE_INC, attotime_never );
11821182         break;
11831183      case GB_LCD_STATE_LYXX_M0_PRE_INC:   /* Just before incrementing the line counter go to mode 2 internally */
11841184         if ( CURLINE < 143 ) {
r1293r1294
11901190               }
11911191            }
11921192         }
1193         mame_timer_adjust( gb_lcd.lcd_timer, MAME_TIME_IN_CYCLES(4,0), GB_LCD_STATE_LYXX_M0_INC, time_never );
1193         timer_adjust( gb_lcd.lcd_timer, ATTOTIME_IN_CYCLES(4,0), GB_LCD_STATE_LYXX_M0_INC, attotime_never );
11941194         break;
11951195      case GB_LCD_STATE_LYXX_M0_INC:   /* Increment LY, stay in M0 for 4 more cycles */
11961196         gb_increment_scanline();
r1293r1294
12031203         LCDSTAT &= 0xFB;
12041204         /* Check if we're going into VBlank next */
12051205         if ( CURLINE == 144 ) {
1206            mame_timer_adjust( gb_lcd.lcd_timer, MAME_TIME_IN_CYCLES(4,0), GB_LCD_STATE_LY9X_M1, time_never );
1206            timer_adjust( gb_lcd.lcd_timer, ATTOTIME_IN_CYCLES(4,0), GB_LCD_STATE_LY9X_M1, attotime_never );
12071207         } else {
12081208            /* Internally switch to mode 2 */
12091209            gb_lcd.mode = 2;
r1293r1294
12151215            } else {
12161216               gb_lcd.mode_irq = 0;
12171217            }
1218            mame_timer_adjust( gb_lcd.lcd_timer, MAME_TIME_IN_CYCLES(4,0), GB_LCD_STATE_LYXX_M2, time_never );
1218            timer_adjust( gb_lcd.lcd_timer, ATTOTIME_IN_CYCLES(4,0), GB_LCD_STATE_LYXX_M2, attotime_never );
12191219         }
12201220         break;
12211221      case GB_LCD_STATE_LY00_M2:      /* Switch to mode 2 on line #0 */
r1293r1294
12271227            cpunum_set_input_line( 0, LCD_INT, HOLD_LINE );
12281228         }
12291229         /* Mode 2 lasts approximately 80 clock cycles */
1230         mame_timer_adjust( gb_lcd.lcd_timer, MAME_TIME_IN_CYCLES(80,0), GB_LCD_STATE_LYXX_M3, time_never );
1230         timer_adjust( gb_lcd.lcd_timer, ATTOTIME_IN_CYCLES(80,0), GB_LCD_STATE_LYXX_M3, attotime_never );
12311231         break;
12321232      case GB_LCD_STATE_LYXX_M2:      /* Switch to mode 2 */
12331233         /* Update STAT register to the correct state */
r1293r1294
12421242            LCDSTAT |= 0x04;
12431243         }
12441244         /* Mode 2 last for approximately 80 clock cycles */
1245         mame_timer_adjust( gb_lcd.lcd_timer, MAME_TIME_IN_CYCLES(80,0), GB_LCD_STATE_LYXX_M3, time_never );
1245         timer_adjust( gb_lcd.lcd_timer, ATTOTIME_IN_CYCLES(80,0), GB_LCD_STATE_LYXX_M3, attotime_never );
12461246         break;
12471247      case GB_LCD_STATE_LYXX_M3:      /* Switch to mode 3 */
12481248         gb_select_sprites();
r1293r1294
12501250         gb_lcd.mode = 3;
12511251         LCDSTAT = (LCDSTAT & 0xFC) | 0x03;
12521252         /* Mode 3 lasts for approximately 172+#sprites*10 clock cycles */
1253         mame_timer_adjust( gb_lcd.lcd_timer, MAME_TIME_IN_CYCLES(172 + 10 * gb_lcd.sprCount,0), GB_LCD_STATE_LYXX_M0, time_never );
1253         timer_adjust( gb_lcd.lcd_timer, ATTOTIME_IN_CYCLES(172 + 10 * gb_lcd.sprCount,0), GB_LCD_STATE_LYXX_M0, attotime_never );
12541254         gb_lcd.start_x = 0;
12551255         break;
12561256      case GB_LCD_STATE_LY9X_M1:      /* Switch to or stay in mode 1 */
r1293r1294
12691269         if ( CURLINE == CMPLINE ) {
12701270            LCDSTAT |= 0x04;
12711271         }
1272         mame_timer_adjust( gb_lcd.lcd_timer, MAME_TIME_IN_CYCLES(452,0), GB_LCD_STATE_LY9X_M1_INC, time_never );
1272         timer_adjust( gb_lcd.lcd_timer, ATTOTIME_IN_CYCLES(452,0), GB_LCD_STATE_LY9X_M1_INC, attotime_never );
12731273         break;
12741274      case GB_LCD_STATE_LY9X_M1_INC:      /* Increment scanline counter */
12751275         gb_increment_scanline();
r1293r1294
12811281         /* Reset LY==LYC STAT bit */
12821282         LCDSTAT &= 0xFB;
12831283         if ( gb_lcd.current_line == 153 ) {
1284            mame_timer_adjust( gb_lcd.lcd_timer, MAME_TIME_IN_CYCLES(4,0), GB_LCD_STATE_LY00_M1, time_never );
1284            timer_adjust( gb_lcd.lcd_timer, ATTOTIME_IN_CYCLES(4,0), GB_LCD_STATE_LY00_M1, attotime_never );
12851285         } else {
1286            mame_timer_adjust( gb_lcd.lcd_timer, MAME_TIME_IN_CYCLES(4,0), GB_LCD_STATE_LY9X_M1, time_never );
1286            timer_adjust( gb_lcd.lcd_timer, ATTOTIME_IN_CYCLES(4,0), GB_LCD_STATE_LY9X_M1, attotime_never );
12871287         }
12881288         break;
12891289      case GB_LCD_STATE_LY00_M1:      /* we stay in VBlank but current line counter should already be incremented */
r1293r1294
13041304//            cpunum_set_input_line( 0, LCD_INT, HOLD_LINE );
13051305//         }
13061306         LCDSTAT &= 0xFB;
1307         mame_timer_adjust( gb_lcd.lcd_timer, MAME_TIME_IN_CYCLES(4/*8*/,0), GB_LCD_STATE_LY00_M1_1, time_never );
1307         timer_adjust( gb_lcd.lcd_timer, ATTOTIME_IN_CYCLES(4/*8*/,0), GB_LCD_STATE_LY00_M1_1, attotime_never );
13081308         break;
13091309      case GB_LCD_STATE_LY00_M1_1:
13101310         if ( ! gb_lcd.delayed_line_irq && gb_lcd.line_irq ) {
13111311            cpunum_set_input_line( 0, LCD_INT, HOLD_LINE );
13121312         }
1313         mame_timer_adjust( gb_lcd.lcd_timer, MAME_TIME_IN_CYCLES(4,0), GB_LCD_STATE_LY00_M1_2, time_never );
1313         timer_adjust( gb_lcd.lcd_timer, ATTOTIME_IN_CYCLES(4,0), GB_LCD_STATE_LY00_M1_2, attotime_never );
13141314         break;
13151315      case GB_LCD_STATE_LY00_M1_2:   /* Rest of line #0 during VBlank */
13161316         if ( gb_lcd.delayed_line_irq && gb_lcd.line_irq ) {
r1293r1294
13191319         if ( CURLINE == CMPLINE ) {
13201320            LCDSTAT |= 0x04;
13211321         }
1322         mame_timer_adjust( gb_lcd.lcd_timer, MAME_TIME_IN_CYCLES(444,0), GB_LCD_STATE_LY00_M0, time_never );
1322         timer_adjust( gb_lcd.lcd_timer, ATTOTIME_IN_CYCLES(444,0), GB_LCD_STATE_LY00_M0, attotime_never );
13231323         break;
13241324      case GB_LCD_STATE_LY00_M0:      /* The STAT register seems to go to 0 for about 4 cycles */
13251325         /* Set Mode 0 lcdstat */
13261326         gb_lcd.mode = 0;
13271327         LCDSTAT = ( LCDSTAT & 0xFC );
1328         mame_timer_adjust( gb_lcd.lcd_timer, MAME_TIME_IN_CYCLES(4,0), GB_LCD_STATE_LY00_M2, time_never );
1328         timer_adjust( gb_lcd.lcd_timer, ATTOTIME_IN_CYCLES(4,0), GB_LCD_STATE_LY00_M2, attotime_never );
13291329         break;
13301330      }
13311331   } else {
r1293r1294
13331333      if ( gb_lcd.current_line < 144 ) {
13341334         update_scanline();
13351335      }
1336      mame_timer_adjust( gb_lcd.lcd_timer, MAME_TIME_IN_CYCLES(456,0), 0, time_never );
1336      timer_adjust( gb_lcd.lcd_timer, ATTOTIME_IN_CYCLES(456,0), 0, attotime_never );
13371337   }
13381338}
13391339
r1293r1294
13521352         cpunum_set_input_line( 0, LCD_INT, HOLD_LINE );
13531353      }
13541354   }
1355   mame_timer_adjust( gb_lcd.lcd_timer, MAME_TIME_IN_CYCLES(80,0), GB_LCD_STATE_LYXX_M3, time_never );
1355   timer_adjust( gb_lcd.lcd_timer, ATTOTIME_IN_CYCLES(80,0), GB_LCD_STATE_LYXX_M3, attotime_never );
13561356}
13571357
13581358/* Make sure the video information is up to date */
13591359void gb_video_up_to_date( void ) {
1360   mame_timer_set_global_time(mame_timer_get_time());
1360   timer_set_global_time(timer_get_time());
13611361}
13621362
13631363READ8_HANDLER( gb_video_r ) {
13641364//   if ( 0 && activecpu_get_pc() > 0x100 ) {
1365//      logerror("LCDSTAT/LY read, cycles left is %d\n", (int)MAME_TIME_TO_CYCLES(0,mame_timer_timeleft( gb_lcd.lcd_timer )) );
1365//      logerror("LCDSTAT/LY read, cycles left is %d\n", (int)ATTOTIME_TO_CYCLES(0,timer_timeleft( gb_lcd.lcd_timer )) );
13661366//   }
13671367   gb_video_up_to_date();
13681368   return gb_vid_regs[offset];
src/mess/video/pc_vga.c
r1293r1294
254254      int (*get_columns)(void);
255255      int (*get_sync_columns)(void);
256256
257      mame_time start_time;
257      attotime start_time;
258258      int retrace;
259259   } monitor;
260260
r1293r1294
670670         int clock=vga.monitor.get_clock();
671671         int lines=vga.monitor.get_lines();
672672         int columns=vga.monitor.get_columns();
673         int diff = (scale_up_mame_time(sub_mame_times(mame_timer_get_time(), vga.monitor.start_time), clock).seconds)
673         int diff = (attotime_mul(attotime_sub(timer_get_time(), vga.monitor.start_time), clock).seconds)
674674            %(lines*columns);
675675         if (diff<columns*vga.monitor.get_sync_lines()) data|=8;
676676         diff=diff/lines;
r1293r1294
680680      if (vga.monitor.retrace)
681681      {
682682         data |= 1;
683         if (compare_mame_times(sub_mame_times(mame_timer_get_time(), vga.monitor.start_time), MAME_TIME_IN_USEC(300)) > 0)
683         if (attotime_compare(attotime_sub(timer_get_time(), vga.monitor.start_time), ATTOTIME_IN_USEC(300)) > 0)
684684         {
685685            data |= 8;
686686            vga.monitor.retrace=0;
r1293r1294
688688      }
689689      else
690690      {
691         if (compare_mame_times(sub_mame_times(mame_timer_get_time(), vga.monitor.start_time), MAME_TIME_IN_MSEC(15)) > 0)
691         if (attotime_compare(attotime_sub(timer_get_time(), vga.monitor.start_time), ATTOTIME_IN_MSEC(15)) > 0)
692692            vga.monitor.retrace=1;
693         vga.monitor.start_time=mame_timer_get_time();
693         vga.monitor.start_time=timer_get_time();
694694      }
695695#else
696696      // not working with ps2m30
r1293r1294
945945         vga_cpu_interface();
946946   
947947         if (vga.sequencer.index == 0)
948            vga.monitor.start_time = mame_timer_get_time();
948            vga.monitor.start_time = timer_get_time();
949949      }
950950      break;
951951   case 6:
r1293r1294
11801180   vga.monitor.get_columns = ega_get_crtc_columns;
11811181   vga.monitor.get_sync_lines = vga_get_crtc_sync_lines;
11821182   vga.monitor.get_sync_columns = vga_get_crtc_sync_columns;
1183   mame_timer_pulse(MAME_TIME_IN_HZ(60), 0, vga_timer);
1183   timer_pulse(ATTOTIME_IN_HZ(60), 0, vga_timer);
11841184   pc_video_start(NULL, pc_ega_choosevideomode, 0);
11851185}
11861186
r1293r1294
11951195   vga.monitor.get_columns=vga_get_crtc_columns;
11961196   vga.monitor.get_sync_lines=vga_get_crtc_sync_lines;
11971197   vga.monitor.get_sync_columns=vga_get_crtc_sync_columns;
1198   mame_timer_pulse(MAME_TIME_IN_HZ(60), 0, vga_timer);
1198   timer_pulse(ATTOTIME_IN_HZ(60), 0, vga_timer);
11991199   pc_video_start(NULL, pc_vga_choosevideomode, 0);
12001200}
12011201
src/mess/video/mz700.c
r1293r1294
1717
1818#if VERBOSE
1919#define LOG(N,M,A)   \
20   if(VERBOSE>=N){ if( M )logerror("%11.6f: %-24s",mame_timer_get_time(),(char*)M ); logerror A; }
20   if(VERBOSE>=N){ if( M )logerror("%11.6f: %-24s",timer_get_time(),(char*)M ); logerror A; }
2121#else
2222#define LOG(N,M,A)
2323#endif
src/mess/video/vectrex.c
r1293r1294
4444static int x_center, y_center, x_max, y_max;
4545static int x_int, y_int; /* X, Y integrators IC LF347*/
4646static int lightpen_down=0, pen_x, pen_y; /* Lightpen position */
47static mame_timer *lp_t;
47static emu_timer *lp_t;
4848static int blank;
4949
5050/* Analog signals: 0 : X-axis sample and hold IC LF347
r1293r1294
9494   newpoint->y = y;
9595   newpoint->col = color;
9696   newpoint->intensity = intensity;
97   newpoint->time = mame_time_to_double(mame_timer_get_time());
97   newpoint->time = attotime_to_double(timer_get_time());
9898}
9999
100100/*********************************************************************
r1293r1294
166166   vectrex_configuration();
167167   lightpen_show();
168168
169   starttime = mame_time_to_double(mame_timer_get_time()) - vectrex_persistance;
169   starttime = attotime_to_double(timer_get_time()) - vectrex_persistance;
170170   if (starttime < 0) starttime = 0;
171171   i = vectrex_point_index;
172172
r1293r1294
206206{
207207   if (last_point)
208208      vector_add_point_function (last_point_x, last_point_y, vectrex_beam_color,
209      MIN((int)(last_point_z*((mame_time_to_double(mame_timer_get_time())-last_point_starttime)*3E4)),255));
209      MIN((int)(last_point_z*((attotime_to_double(timer_get_time())-last_point_starttime)*3E4)),255));
210210   last_point = 0;
211211
212212   x_int=x_center+(analog_sig[ASIG_ZR]*INT_PER_CLOCK);
r1293r1294
221221      last_point_x = x_int;
222222      last_point_y = y_int;
223223      last_point_z = analog_sig[ASIG_Z] > 0? (int)(analog_sig[ASIG_Z] * z_factor): 0;
224      last_point_starttime = mame_time_to_double(mame_timer_get_time());
224      last_point_starttime = attotime_to_double(timer_get_time());
225225      last_point = 1;
226226   }
227227}
r1293r1294
238238    * black (a move). */
239239   if (last_point && (!blank || !z))
240240      vector_add_point_function(last_point_x, last_point_y, vectrex_beam_color,
241              MIN((int)(last_point_z*((mame_time_to_double(mame_timer_get_time())-last_point_starttime)*3E4)),255));
241              MIN((int)(last_point_z*((attotime_to_double(timer_get_time())-last_point_starttime)*3E4)),255));
242242   last_point = 0;
243243
244244   x_int += (int)(length * (analog_sig[ASIG_X] - analog_sig[ASIG_ZR]));
r1293r1294
269269
270270   imager_freq = 1;
271271
272   imager_timer = mame_timer_alloc(vectrex_imager_right_eye);
273   mame_timer_adjust(imager_timer, MAME_TIME_IN_HZ(imager_freq), 2, MAME_TIME_IN_HZ(imager_freq));
272   imager_timer = timer_alloc(vectrex_imager_right_eye);
273   timer_adjust(imager_timer, ATTOTIME_IN_HZ(imager_freq), 2, ATTOTIME_IN_HZ(imager_freq));
274274
275   lp_t = mame_timer_alloc(lightpen_trigger);
275   lp_t = timer_alloc(lightpen_trigger);
276276
277277   video_start_vector(machine);
278278}
r1293r1294
296296      if ((vectrex_via_out[PORTB] & 0x80))
297297      {
298298         /* RAMP was inactive before */
299         start_time = mame_time_to_double(mame_timer_get_time())+RAMP_DELAY;
299         start_time = attotime_to_double(timer_get_time())+RAMP_DELAY;
300300
301301         if (lightpen_down)
302302         {
r1293r1294
329329                  +(double)(pen_y-y_int)*(pen_y-y_int);
330330               d2=b2-ab*ab/a2;
331331               if (d2<2e10 && analog_sig[ASIG_Z]*blank>0)
332                  mame_timer_adjust(lp_t, double_to_mame_time(ab/a2/(VECTREX_CLOCK*INT_PER_CLOCK)),0,time_zero);
332                  timer_adjust(lp_t, double_to_attotime(ab/a2/(VECTREX_CLOCK*INT_PER_CLOCK)),0,attotime_zero);
333333            }
334334         }
335335      }
r1293r1294
338338         /* MUX has been enabled */
339339         /* This is a rare case used by some new games */
340340      {
341         double time_now = mame_time_to_double(mame_timer_get_time())+SH_DELAY;
341         double time_now = attotime_to_double(timer_get_time())+SH_DELAY;
342342         vectrex_solid_line(time_now-start_time, blank);
343343         start_time = time_now;
344344      }
r1293r1294
349349      if (!(vectrex_via_out[PORTB] & 0x80))
350350      {
351351         /* RAMP was active before - we can draw the line */
352         vectrex_solid_line(mame_time_to_double(mame_timer_get_time())-start_time+RAMP_DELAY, blank);
352         vectrex_solid_line(attotime_to_double(timer_get_time())-start_time+RAMP_DELAY, blank);
353353         /* Cancel running timer, line already finished */
354354         if (lightpen_down)
355            mame_timer_adjust(lp_t,time_never,0,time_zero);
355            timer_adjust(lp_t,attotime_never,0,attotime_zero);
356356      }
357357   }
358358
r1293r1294
385385       * Draw the vector with the current settings
386386       * before updating the signals.
387387       */
388      time_now = mame_time_to_double(mame_timer_get_time()) + SH_DELAY;
388      time_now = attotime_to_double(timer_get_time()) + SH_DELAY;
389389      vectrex_solid_line(time_now - start_time, blank);
390390      start_time = time_now;
391391   }
r1293r1294
422422         /* RAMP active
423423          * Take MAX because RAMP is slower than BLANK
424424          */
425         time_now = MAX(mame_time_to_double(mame_timer_get_time()),start_time);
425         time_now = MAX(attotime_to_double(timer_get_time()),start_time);
426426         vectrex_solid_line(time_now - start_time, blank);
427427         start_time = time_now;
428428      }
src/mess/video/aim65.c
r1293r1294
1818
1919UINT16 *printerRAM;
2020
21static mame_timer *print_timer;
21static emu_timer *print_timer;
2222static int printer_level;
2323
2424
r1293r1294
9595   if (!data)
9696   {
9797      aim65_printer_cr();
98      mame_timer_adjust(print_timer, time_zero, 0, MAME_TIME_IN_USEC(10));
98      timer_adjust(print_timer, attotime_zero, 0, ATTOTIME_IN_USEC(10));
9999      via_0_cb1_w(0, 0);
100100      printer_level = 1;
101101   }
102102   else
103      mame_timer_reset(print_timer, time_never);
103      timer_reset(print_timer, attotime_never);
104104}
105105
106106
r1293r1294
122122
123123VIDEO_START( aim65 )
124124{
125   print_timer = mame_timer_alloc(aim65_printer_timer);
125   print_timer = timer_alloc(aim65_printer_timer);
126126
127127   /*
128128    videoram_size = 600 * 10 * 2;
src/mess/video/m6847.c
r1293r1294
116116   void (*custom_prepare_scanline)(int scanline);
117117
118118   /* timers */
119   mame_timer *fs_rise_timer;
120   mame_timer *fs_fall_timer;
121   mame_timer *hs_rise_timer;
122   mame_timer *hs_fall_timer;
119   emu_timer *fs_rise_timer;
120   emu_timer *fs_fall_timer;
121   emu_timer *hs_rise_timer;
122   emu_timer *hs_fall_timer;
123123
124124   /* things that vary according to chip version */
125   subseconds_t clock_period;
126   subseconds_t scanline_period;
127   subseconds_t field_sync_period;
128   subseconds_t horizontal_sync_period;
129   subseconds_t vblank_period;
125   attoseconds_t clock_period;
126   attoseconds_t scanline_period;
127   attoseconds_t field_sync_period;
128   attoseconds_t horizontal_sync_period;
129   attoseconds_t vblank_period;
130130   int top_border_scanlines;
131131   int display_scanlines;
132132   int bottom_border_scanlines;
r1293r1294
10431043
10441044
10451045
1046static const char *mame_time_string(mame_time t)
1047{
1048   static char return_buffer[32];
1049   char subseconds_buffer[24];
1050   char *s;
1051   char c;
1052   subseconds_t subseconds;
1053   subseconds_t max_subseconds;
1054
1055   s = subseconds_buffer + sizeof(subseconds_buffer);
1056   *(--s) = '\0';
1057
1058   subseconds = t.subseconds;
1059   max_subseconds = MAX_SUBSECONDS;
1060
1061   while(max_subseconds > 1)
1062   {
1063      c = (subseconds % 10) + '0';
1064      if ((c != '0') || s[1])
1065         *(--s) = c;
1066      subseconds /= 10;
1067      max_subseconds /= 10;
1068   }
1069
1070   if (*s == '\0')
1071      *(--s) = '0';
1072
1073   snprintf(return_buffer, sizeof(return_buffer), "%u.%s", t.seconds, s);
1074   return return_buffer;
1075}
1076
1077
1078
10791046static int attr_index_from_attribute(UINT8 attr)
10801047{
10811048   int result;
r1293r1294
14661433static int get_scanline(void)
14671434{
14681435   int result;
1469   mame_time duration;
1436   attotime duration;
14701437
14711438   /* get the time since last field sync */
1472   duration = sub_mame_times(
1473      mame_timer_starttime(m6847->hs_rise_timer),
1474      mame_timer_starttime(m6847->fs_rise_timer));
1439   duration = attotime_sub(
1440      timer_starttime(m6847->hs_rise_timer),
1441      timer_starttime(m6847->fs_rise_timer));
14751442   assert_always(duration.seconds == 0, "get_scanline(): duration exceeds one second");
14761443
1477   if (duration.subseconds < m6847->vblank_period)
1444   if (duration.attoseconds < m6847->vblank_period)
14781445   {
14791446      result = -1;   /* vblank */
14801447   }
14811448   else
14821449   {
1483      result = (duration.subseconds - m6847->vblank_period)
1450      result = (duration.attoseconds - m6847->vblank_period)
14841451         / m6847->scanline_period;
14851452   }
14861453   return result;
r1293r1294
14901457#ifdef MAME_DEBUG
14911458static int get_beamx(void)
14921459{
1493   mame_time scanline_time;
1460   attotime scanline_time;
14941461   int result;
14951462
1496   scanline_time = mame_timer_timeelapsed(m6847->hs_rise_timer);
1463   scanline_time = timer_timeelapsed(m6847->hs_rise_timer);
14971464   if (scanline_time.seconds != 0)
14981465      return 0;
14991466   assert(scanline_time.subseconds < m6847->scanline_period);
r1293r1294
16101577
16111578int m6847_get_horizontal_sync(void)
16121579{
1613   mame_time fire_time = mame_timer_firetime(m6847->hs_fall_timer);
1614   return compare_mame_times(fire_time, mame_timer_get_time()) > 0;
1580   attotime fire_time = timer_firetime(m6847->hs_fall_timer);
1581   return attotime_compare(fire_time, timer_get_time()) > 0;
16151582}
16161583
16171584
16181585
16191586static void set_horizontal_sync(void)
16201587{
1621   mame_time fire_time = mame_timer_firetime(m6847->hs_fall_timer);
1622   int horizontal_sync = compare_mame_times(fire_time, mame_timer_get_time()) > 0;
1588   attotime fire_time = timer_firetime(m6847->hs_fall_timer);
1589   int horizontal_sync = attotime_compare(fire_time, timer_get_time()) > 0;
16231590   if (m6847->horizontal_sync_callback)
16241591      m6847->horizontal_sync_callback(!horizontal_sync);
16251592}
r1293r1294
16281595
16291596int m6847_get_field_sync(void)
16301597{
1631   mame_time fire_time = mame_timer_firetime(m6847->fs_fall_timer);
1632   return compare_mame_times(fire_time, mame_timer_get_time()) > 0;
1598   attotime fire_time = timer_firetime(m6847->fs_fall_timer);
1599   return attotime_compare(fire_time, timer_get_time()) > 0;
16331600}
16341601
16351602
16361603
16371604static void set_field_sync(void)
16381605{
1639   mame_time fire_time = mame_timer_firetime(m6847->fs_fall_timer);
1640   int field_sync = compare_mame_times(fire_time, mame_timer_get_time()) > 0;
1606   attotime fire_time = timer_firetime(m6847->fs_fall_timer);
1607   int field_sync = attotime_compare(fire_time, timer_get_time()) > 0;
16411608   if (m6847->field_sync_callback)
16421609      m6847->field_sync_callback(field_sync);
16431610}
r1293r1294
16531620static TIMER_CALLBACK(hs_fall)
16541621{
16551622   if (LOG_HS)
1656      logerror("hs_fall(): time=%g\n", mame_time_to_double(mame_timer_get_time()));
1623      logerror("hs_fall(): time=%g\n", attotime_to_double(timer_get_time()));
16571624
16581625   set_horizontal_sync();
16591626}
r1293r1294
16611628static TIMER_CALLBACK(hs_rise)
16621629{
16631630   if (LOG_HS)
1664      logerror("hs_rise(): time=%g\n", mame_time_to_double(mame_timer_get_time()));
1631      logerror("hs_rise(): time=%g\n", attotime_to_double(timer_get_time()));
16651632
1666   mame_timer_adjust(m6847->hs_rise_timer,
1667      make_mame_time(0, m6847->scanline_period),
1668      0, time_never);
1669   mame_timer_adjust(m6847->hs_fall_timer,
1670      make_mame_time(0, m6847->horizontal_sync_period),
1671      0, time_never);
1633   timer_adjust(m6847->hs_rise_timer,
1634      attotime_make(0, m6847->scanline_period),
1635      0, attotime_never);
1636   timer_adjust(m6847->hs_fall_timer,
1637      attotime_make(0, m6847->horizontal_sync_period),
1638      0, attotime_never);
16721639
16731640   set_horizontal_sync();
16741641   prepare_scanline(0);
r1293r1294
16771644static TIMER_CALLBACK(fs_fall)
16781645{
16791646   if (LOG_FS)
1680      logerror("fs_fall(): time=%g scanline=%d\n", mame_time_to_double(mame_timer_get_time()), get_scanline());
1647      logerror("fs_fall(): time=%g scanline=%d\n", attotime_to_double(timer_get_time()), get_scanline());
16811648
16821649   set_field_sync();
16831650}
r1293r1294
16851652static TIMER_CALLBACK(fs_rise)
16861653{
16871654   if (LOG_FS)
1688      logerror("fs_rise(): time=%g scanline=%d\n", mame_time_to_double(mame_timer_get_time()), get_scanline());
1655      logerror("fs_rise(): time=%g scanline=%d\n", attotime_to_double(timer_get_time()), get_scanline());
16891656
16901657   /* adjust field sync falling edge timer */
1691   mame_timer_adjust(m6847->fs_fall_timer,
1692      make_mame_time(0, m6847->field_sync_period),
1693      0, time_never);
1658   timer_adjust(m6847->fs_fall_timer,
1659      attotime_make(0, m6847->field_sync_period),
1660      0, attotime_never);
16941661
16951662   /* adjust horizontal sync rising timer */
1696   mame_timer_adjust(m6847->hs_rise_timer, time_zero, 0, time_never);
1663   timer_adjust(m6847->hs_rise_timer, attotime_zero, 0, attotime_never);
16971664
16981665   /* this is a hook for the CoCo 3 code to extend this stuff */
16991666   if (m6847->new_frame_callback)
r1293r1294
18421809{
18431810   const m6847_variant *v;
18441811   UINT32 frequency;
1845   subseconds_t period, frame_period, cpu0_clock_period = 0;
1812   attoseconds_t period, frame_period, cpu0_clock_period = 0;
18461813   double total_scanlines;
18471814   int portnum;
18481815
r1293r1294
18841851   }
18851852
18861853   /* allocate timers */
1887   m6847->fs_rise_timer = mame_timer_alloc(fs_rise);
1888   m6847->fs_fall_timer = mame_timer_alloc(fs_fall);
1889   m6847->hs_rise_timer = mame_timer_alloc(hs_rise);
1890   m6847->hs_fall_timer = mame_timer_alloc(hs_fall);
1854   m6847->fs_rise_timer = timer_alloc(fs_rise);
1855   m6847->fs_fall_timer = timer_alloc(fs_fall);
1856   m6847->hs_rise_timer = timer_alloc(hs_rise);
1857   m6847->hs_fall_timer = timer_alloc(hs_fall);
18911858
18921859   /* setup dimensions */
18931860   m6847->top_border_scanlines = v->top_border_scanlines;
r1293r1294
18981865   frequency = v->frames_per_second
18991866      * ((UINT32) (v->scanlines_per_frame * FACTOR_SCANLINES_PER_FRAME))
19001867      * ((UINT32) (v->clocks_per_scanline * FACTOR_CLOCKS_PER_SCANLINE));
1901   period = MAX_SUBSECONDS / frequency;
1868   period = ATTOTIME_MAX_SECONDS / frequency;
19021869
19031870   /* choose CPU clock, if specified */
19041871   if (cfg->cpu0_timing_factor > 0)
r1293r1294
19221889   /* setup timing */
19231890   frame_period = period *
19241891      (UINT32) (v->clocks_per_scanline * total_scanlines * GROSS_FACTOR);
1925   mame_timer_adjust(m6847->fs_rise_timer, time_zero, 0, make_mame_time(0, frame_period));
1892   timer_adjust(m6847->fs_rise_timer, attotime_zero, 0, attotime_make(0, frame_period));
19261893
19271894   /* setup save states */
19281895   state_save_register_func_postload(set_field_sync);
r1293r1294
19411908   if (LOG_STATS)
19421909   {
19431910      logerror("m6847_init():\n");
1944      logerror("\tclock:      %30s sec\n", mame_time_string(make_mame_time(0, period * GROSS_FACTOR)));
1911      logerror("\tclock:      %30s sec\n", attotime_string(attotime_make(0, period * GROSS_FACTOR), 6));
19451912      if (cpu0_clock_period > 0)
1946         logerror("\tCPU0 clock: %30s sec\n", mame_time_string(make_mame_time(0, cpu0_clock_period)));
1947      logerror("\tscanline:   %30s sec\n", mame_time_string(make_mame_time(0, m6847->scanline_period)));
1948      logerror("\tfield sync: %30s sec\n", mame_time_string(make_mame_time(0, m6847->field_sync_period)));
1949      logerror("\thorz sync:  %30s sec\n", mame_time_string(make_mame_time(0, m6847->horizontal_sync_period)));
1950      logerror("\tvblank:     %30s sec\n", mame_time_string(make_mame_time(0, m6847->vblank_period)));
1951      logerror("\tframe:      %30s sec\n", mame_time_string(make_mame_time(0, frame_period)));
1913         logerror("\tCPU0 clock: %30s sec\n", attotime_string(attotime_make(0, cpu0_clock_period), 6));
1914      logerror("\tscanline:   %30s sec\n", attotime_string(attotime_make(0, m6847->scanline_period), 6));
1915      logerror("\tfield sync: %30s sec\n", attotime_string(attotime_make(0, m6847->field_sync_period), 6));
1916      logerror("\thorz sync:  %30s sec\n", attotime_string(attotime_make(0, m6847->horizontal_sync_period), 6));
1917      logerror("\tvblank:     %30s sec\n", attotime_string(attotime_make(0, m6847->vblank_period), 6));
1918      logerror("\tframe:      %30s sec\n", attotime_string(attotime_make(0, frame_period), 6));
19521919      logerror("\n");
19531920   }
19541921
r1293r1294
20111978 *
20121979 *************************************/
20131980
2014static UINT64 divide_mame_time(mame_time dividend, mame_time divisor)
1981static UINT64 divide_mame_time(attotime dividend, attotime divisor)
20151982{
20161983   /* TODO: it should not be necessary to use floating point here */
2017   double dividend_dbl = mame_time_to_double(dividend);
2018   double divisor_dbl = mame_time_to_double(divisor);
1984   double dividend_dbl = attotime_to_double(dividend);
1985   double divisor_dbl = attotime_to_double(divisor);
20191986   return (UINT64) (dividend_dbl / divisor_dbl);
20201987}
20211988
20221989
20231990
2024static mame_time multiply_mame_time(mame_time time, UINT64 factor)
1991static attotime interval(m6847_timing_type timing)
20251992{
2026   /* TODO: it should not be necessary to use floating point here */
2027   double d = mame_time_to_double(time);
1993   attotime result;
20281994
2029#if defined(_MSC_VER) && (_MSC_VER <= 1200)
2030   /* casting unsigned __int64 to double is not supported on VC6 or before */
2031   d *= (INT64) factor;
2032#else
2033   d *= factor;
2034#endif
2035
2036   return double_to_mame_time(d);
2037}
2038
2039
2040
2041static mame_time interval(m6847_timing_type timing)
2042{
2043   mame_time result;
2044
20451995   switch(timing)
20461996   {
20471997      case M6847_CLOCK:
2048         result = make_mame_time(0, m6847->clock_period);
1998         result = attotime_make(0, m6847->clock_period);
20491999         break;
20502000      case M6847_HSYNC:
2051         result = make_mame_time(0, m6847->scanline_period);
2001         result = attotime_make(0, m6847->scanline_period);
20522002         break;
20532003      default:
20542004         fatalerror("invalid timing type");
r1293r1294
20612011
20622012UINT64 m6847_time(m6847_timing_type timing)
20632013{
2064   mame_time current_time = mame_timer_get_time();
2065   mame_time divisor = interval(timing);
2014   attotime current_time = timer_get_time();
2015   attotime divisor = interval(timing);
20662016   return divide_mame_time(current_time, divisor);
20672017}
20682018
20692019
20702020
2071mame_time m6847_time_until(m6847_timing_type timing, UINT64 target_time)
2021attotime m6847_time_until(m6847_timing_type timing, UINT64 target_time)
20722022{
2073   mame_time target_mame_time, current_time;
2074   target_mame_time = multiply_mame_time(interval(timing), target_time);
2075   current_time = mame_timer_get_time();
2023   attotime target_mame_time, current_time;
2024   target_mame_time = attotime_mul(interval(timing), target_time);
2025   current_time = timer_get_time();
20762026
2077   if (compare_mame_times(target_mame_time, current_time) < 0)
2027   if (attotime_compare(target_mame_time, current_time) < 0)
20782028      fatalerror("m6847_time_until(): cannot target past times");
20792029
2080   return sub_mame_times(target_mame_time, current_time);
2030   return attotime_sub(target_mame_time, current_time);
20812031}
20822032
20832033
20842034
2085mame_time m6847_scanline_time(int scanline)
2035attotime m6847_scanline_time(int scanline)
20862036{
2087   return make_mame_time(0, m6847->scanline_period *
2037   return attotime_make(0, m6847->scanline_period *
20882038         (13 /* FIXME */ + scanline));
20892039}
20902040
src/mess/video/thomson.c
r1293r1294
103103
104104
105105
106static mame_timer* thom_video_timer; /* time elapsed from begining of frame */
106static emu_timer* thom_video_timer; /* time elapsed from begining of frame */
107107
108108
109109
r1293r1294
111111INLINE unsigned thom_video_elapsed ( void )
112112{
113113   unsigned u;
114   mame_time elapsed = mame_timer_timeelapsed( thom_video_timer );
115   u = scale_up_mame_time( elapsed, 1000000 ).seconds;
114   attotime elapsed = timer_timeelapsed( thom_video_timer );
115   u = attotime_mul( elapsed, 1000000 ).seconds;
116116   if ( u >= 19968 )
117117      u = 19968;
118118   return u;
r1293r1294
206206
207207
208208/* called thom_lightpen_nb times */
209static mame_timer *thom_lightpen_timer;
209static emu_timer *thom_lightpen_timer;
210210
211211
212212/* lightpen callback function to call from timer */
r1293r1294
216216
217217void thom_set_lightpen_callback ( int nb, void (*cb) ( int step ) )
218218{
219   LOG (( "%f thom_set_lightpen_callback called\n", mame_time_to_double(mame_timer_get_time()) ));
219   LOG (( "%f thom_set_lightpen_callback called\n", attotime_to_double(timer_get_time()) ));
220220   thom_lightpen_nb = nb;
221221   thom_lightpen_cb = cb;
222222}
r1293r1294
229229      thom_lightpen_cb( step );
230230
231231   if ( step < thom_lightpen_nb )
232      mame_timer_adjust( thom_lightpen_timer, MAME_TIME_IN_USEC( 64 ), step + 1, time_zero );
232      timer_adjust( thom_lightpen_timer, ATTOTIME_IN_USEC( 64 ), step + 1, attotime_zero );
233233}
234234
235235
r1293r1294
258258
259259UINT8* thom_vram; /* pointer to video memory */
260260
261static mame_timer* thom_scanline_timer; /* scan-line udpate */
261static emu_timer* thom_scanline_timer; /* scan-line udpate */
262262
263263static UINT16 thom_last_pal[16];   /* palette at last scanline start */
264264static UINT16 thom_pal[16];        /* current palette */
r1293r1294
829829
830830   /* prepare for next scanline */
831831   if ( y == 199 )
832      mame_timer_adjust( thom_scanline_timer, time_never, 0, time_zero);
832      timer_adjust( thom_scanline_timer, attotime_never, 0, attotime_zero);
833833   else
834834   {
835835
r1293r1294
854854         thom_pal_changed = 0;
855855      }
856856
857      mame_timer_adjust( thom_scanline_timer, MAME_TIME_IN_USEC(64), y + 1, time_zero);
857      timer_adjust( thom_scanline_timer, ATTOTIME_IN_USEC(64), y + 1, attotime_zero);
858858   }
859859}
860860
r1293r1294
920920   rectangle lrect = { 0, xbleft - 1, 0, 0 };
921921   rectangle rrect = { xbright, xright - 1, 0, 0 };
922922
923   LOG (( "%f thom: video update called\n", mame_time_to_double(mame_timer_get_time()) ));
923   LOG (( "%f thom: video update called\n", attotime_to_double(timer_get_time()) ));
924924
925925   /* upper border */
926926   for ( y = 0; y < THOM_BORDER_HEIGHT - thom_bheight; y++ )
r1293r1294
10161016
10171017
10181018
1019static mame_timer *thom_init_timer;
1019static emu_timer *thom_init_timer;
10201020
10211021static void (*thom_init_cb) ( int );
10221022
r1293r1294
10321032static TIMER_CALLBACK( thom_set_init )
10331033{
10341034   int init = param;
1035   LOG (( "%f thom_set_init: %i, at line %i col %i\n", mame_time_to_double(mame_timer_get_time()), init, thom_video_elapsed() / 64, thom_video_elapsed() % 64 ));
1035   LOG (( "%f thom_set_init: %i, at line %i col %i\n", attotime_to_double(timer_get_time()), init, thom_video_elapsed() / 64, thom_video_elapsed() % 64 ));
10361036
10371037   if ( thom_init_cb )
10381038      thom_init_cb( init );
10391039   if ( ! init )
1040      mame_timer_adjust( thom_init_timer, MAME_TIME_IN_USEC( 64 * THOM_ACTIVE_HEIGHT - 24 ), 1-init, time_zero );
1040      timer_adjust( thom_init_timer, ATTOTIME_IN_USEC( 64 * THOM_ACTIVE_HEIGHT - 24 ), 1-init, attotime_zero );
10411041}
10421042
10431043/* call this at the very begining of each new frame */
r1293r1294
10481048   UINT16 b = 0;
10491049   struct thom_vsignal l = thom_get_lightpen_vsignal( 0, -1, 0 );
10501050 
1051   LOG (( "%f thom: video eof called\n", mame_time_to_double(mame_timer_get_time()) ));
1051   LOG (( "%f thom: video eof called\n", attotime_to_double(timer_get_time()) ));
10521052
10531053   /* floppy indicator count */
10541054   if ( thom_floppy_wcount )
r1293r1294
10751075   thom_vstate_dirty = 0;
10761076 
10771077   /* schedule first init signal */
1078   mame_timer_adjust( thom_init_timer, MAME_TIME_IN_USEC( 64 * THOM_BORDER_HEIGHT + 7 ), 0, time_zero );
1078   timer_adjust( thom_init_timer, ATTOTIME_IN_USEC( 64 * THOM_BORDER_HEIGHT + 7 ), 0, attotime_zero );
10791079
10801080   /* schedule first lightpen signal */
10811081   l.line &= ~1; /* hack (avoid lock in MO6 palette selection) */
1082   mame_timer_adjust( thom_lightpen_timer,
1083            MAME_TIME_IN_USEC( 64 * ( THOM_BORDER_HEIGHT + l.line - 2 ) + 16 ),
1084            0, time_zero );
1082   timer_adjust( thom_lightpen_timer,
1083            ATTOTIME_IN_USEC( 64 * ( THOM_BORDER_HEIGHT + l.line - 2 ) + 16 ),
1084            0, attotime_zero );
10851085
10861086   /* schedule first active-area scanline call-back */
1087   mame_timer_adjust( thom_scanline_timer, MAME_TIME_IN_USEC( 64 * THOM_BORDER_HEIGHT + 7),
1088            -1, time_zero );
1087   timer_adjust( thom_scanline_timer, ATTOTIME_IN_USEC( 64 * THOM_BORDER_HEIGHT + 7),
1088            -1, attotime_zero );
10891089
10901090   /* reset video frame time */
1091   mame_timer_adjust( thom_video_timer, time_zero, 0, time_never );
1091   timer_adjust( thom_video_timer, attotime_zero, 0, attotime_never );
10921092
10931093   /* update screen size according to user options */
10941094   if ( thom_update_screen_size() )
r1293r1294
11621162   state_save_register_global( thom_floppy_rcount );
11631163   output_set_value( "floppy", 0 );
11641164
1165   thom_video_timer = mame_timer_alloc( NULL );
1165   thom_video_timer = timer_alloc( NULL );
11661166
1167   thom_scanline_timer = mame_timer_alloc( thom_scanline_start );
1167   thom_scanline_timer = timer_alloc( thom_scanline_start );
11681168
11691169   thom_lightpen_nb = 0;
11701170   thom_lightpen_cb = NULL;
1171   thom_lightpen_timer = mame_timer_alloc( thom_lightpen_step );
1171   thom_lightpen_timer = timer_alloc( thom_lightpen_step );
11721172   state_save_register_global( thom_lightpen_nb );
11731173
11741174   thom_init_cb = NULL;
1175   thom_init_timer = mame_timer_alloc( thom_set_init );
1175   thom_init_timer = timer_alloc( thom_set_init );
11761176 
11771177   video_eof_thom(machine);
11781178
src/mess/video/m6847.h
r1293r1294
7777
7878/* timing functions */
7979UINT64 m6847_time(m6847_timing_type timing);
80mame_time m6847_time_until(m6847_timing_type timing, UINT64 target_time);
80attotime m6847_time_until(m6847_timing_type timing, UINT64 target_time);
8181
8282/* CoCo 3 hooks */
83mame_time m6847_scanline_time(int scanline);
83attotime m6847_scanline_time(int scanline);
8484
8585INPUT_PORTS_EXTERN( m6847_artifacting );
8686
src/mess/video/abc80.c
r1293r1294
11#include "abc80.h"
22
33static tilemap *tx_tilemap;
4static mame_timer *abc80_blink_timer;
4static emu_timer *abc80_blink_timer;
55static int abc80_blink;
66static int abc80_bank;
77static int abc80_row;
r1293r1294
6161
6262VIDEO_START( abc80 )
6363{
64   abc80_blink_timer = mame_timer_alloc(abc80_blink_tick);
65   mame_timer_adjust(abc80_blink_timer, time_zero, 0, MAME_TIME_IN_HZ(ABC80_XTAL/2/6/64/312/16));
64   abc80_blink_timer = timer_alloc(abc80_blink_tick);
65   timer_adjust(abc80_blink_timer, attotime_zero, 0, ATTOTIME_IN_HZ(ABC80_XTAL/2/6/64/312/16));
6666
6767   tx_tilemap = tilemap_create(abc80_get_tile_info, abc80_tilemap_scan,
6868      TILEMAP_TYPE_PEN, 6, 10, 40, 24);
src/mess/video/x68k.c
r1293r1294
3333
3434extern struct x68k_system sys;
3535
36extern mame_timer* scanline_timer;
37extern mame_timer* raster_irq;
38extern mame_timer* vblank_irq;
36extern emu_timer* scanline_timer;
37extern emu_timer* raster_irq;
38extern emu_timer* vblank_irq;
3939
4040UINT16* gvram;  // Graphic VRAM
4141UINT16* tvram;  // Text VRAM
r1293r1294
174174   sys.crtc.hshift = (sys.crtc.width - sys.crtc.visible_width) / 2;
175175   sys.crtc.vshift = (sys.crtc.height - sys.crtc.visible_height) / 2;
176176
177   video_screen_configure(0,sys.crtc.video_width,sys.crtc.video_height,&rect,HZ_TO_SUBSECONDS(55.45));
177   video_screen_configure(0,sys.crtc.video_width,sys.crtc.video_height,&rect,HZ_TO_ATTOSECONDS(55.45));
178178   logerror("video_screen_configure(0,%i,%i,[%i,%i,%i,%i],55.45)\n",sys.crtc.video_width,sys.crtc.video_height,rect.min_x,rect.min_y,rect.max_x,rect.max_y);
179179//   x68k_scanline = video_screen_get_vpos(0);
180180   if(sys.crtc.reg[4] != 0)
181181   {
182//      scantime = MAME_TIME_IN_HZ(55.45) / sys.crtc.reg[4];
183//      mame_timer_adjust(scanline_timer,time_zero,0,scantime);
182//      scantime = ATTOTIME_IN_HZ(55.45) / sys.crtc.reg[4];
183//      timer_adjust(scanline_timer,attotime_zero,0,scantime);
184184   }
185185}
186186
187187TIMER_CALLBACK(x68k_hsync)
188188{
189189   int state = param;
190   mame_time irq_time = video_screen_get_scan_period(0);
191   mame_time hsync_time = MAME_TIME_IN_CYCLES(0,32);
190   attotime irq_time = video_screen_get_scan_period(0);
191   attotime hsync_time = ATTOTIME_IN_CYCLES(0,32);
192192
193193   sys.crtc.hblank = state;   
194194   if(state == 1)
195195   {
196196//      mfp_trigger_irq(MFP_IRQ_GPIP7);  // HSync
197      mame_timer_adjust(scanline_timer,hsync_time,0,time_never);
197      timer_adjust(scanline_timer,hsync_time,0,attotime_never);
198198   }
199199   if(state == 0)
200200   {
201      double time_to_irq = mame_time_to_double(irq_time) - mame_time_to_double(hsync_time);
202      mame_timer_adjust(scanline_timer,double_to_mame_time(time_to_irq),1,time_never);
201      double time_to_irq = attotime_to_double(irq_time) - attotime_to_double(hsync_time);
202      timer_adjust(scanline_timer,double_to_attotime(time_to_irq),1,attotime_never);
203203      if(!(sys.mfp.gpio & 0x40))  // if GPIP6 is active, clear it
204204         sys.mfp.gpio |= 0x40;
205205   }
r1293r1294
209209TIMER_CALLBACK(x68k_crtc_raster_irq)
210210{
211211   int scan = param;
212   mame_time irq_time;
212   attotime irq_time;
213213//   mfp_trigger_irq(MFP_IRQ_GPIP6);
214214   sys.mfp.gpio &= ~0x40;  // GPIP6
215215   if((readinputportbytag("options") & 0x01))
r1293r1294
218218   }
219219
220220   irq_time = video_screen_get_time_until_pos(0,scan,2);
221   if(mame_time_to_double(irq_time) > 0)
222      mame_timer_adjust(raster_irq,irq_time,scan,time_never);
221   if(attotime_to_double(irq_time) > 0)
222      timer_adjust(raster_irq,irq_time,scan,attotime_never);
223223   logerror("GPIP6: Raster triggered at line %i (%i)\n",scan,video_screen_get_vpos(0));
224224}
225225
226226TIMER_CALLBACK(x68k_crtc_vblank_irq)
227227{
228228   int val = param;
229   mame_time irq_time;
229   attotime irq_time;
230230   int vblank_line;
231231
232232   if(val == 1)  // VBlank on
r1293r1294
239239         irq_time = video_screen_get_time_until_pos(0,vblank_line / 2,2);
240240      else
241241         irq_time = video_screen_get_time_until_pos(0,vblank_line,2);
242      mame_timer_adjust(vblank_irq,irq_time,0,time_never);
242      timer_adjust(vblank_irq,irq_time,0,attotime_never);
243243      logerror("CRTC: VBlank on\n");
244244   }
245245   if(val == 0)  // VBlank off
r1293r1294
250250         irq_time = video_screen_get_time_until_pos(0,vblank_line / 2,2);
251251      else
252252         irq_time = video_screen_get_time_until_pos(0,vblank_line,2);
253      mame_timer_adjust(vblank_irq,irq_time,1,time_never);
253      timer_adjust(vblank_irq,irq_time,1,attotime_never);
254254      logerror("CRTC: VBlank off\n");
255255   }
256256}
r1293r1294
273273      x68k_crtc_refresh_mode();
274274      break;
275275   case 9:  // CRTC raster IRQ (GPIP6)
276      mame_timer_adjust(raster_irq,time_never,0,time_never);  // disable timer
276      timer_adjust(raster_irq,attotime_never,0,attotime_never);  // disable timer
277277      if(sys.crtc.height == 256)  // adjust to visible area
278278      {
279279         data = data / 2;
r1293r1294
289289      }
290290      if(data <= sys.crtc.video_height)
291291      {
292         mame_time irq_time;
292         attotime irq_time;
293293         irq_time = video_screen_get_time_until_pos(0,data - 1,2);
294294
295         if(mame_time_to_double(irq_time) > 0)
296            mame_timer_adjust(raster_irq,irq_time,data - 1,time_never);
297         logerror("CRTC: Time until next raster IRQ = %f\n",mame_time_to_double(irq_time));
295         if(attotime_to_double(irq_time) > 0)
296            timer_adjust(raster_irq,irq_time,data - 1,attotime_never);
297         logerror("CRTC: Time until next raster IRQ = %f\n",attotime_to_double(irq_time));
298298      }
299299      logerror("CRTC: Write to raster IRQ register - %i\n",data);
300300      break;
r1293r1294
341341      if(data & 0x08)  // text screen raster copy
342342      {
343343         x68k_crtc_text_copy((sys.crtc.reg[22] & 0xff00) >> 8,(sys.crtc.reg[22] & 0x00ff));
344         mame_timer_set(MAME_TIME_IN_MSEC(1),0x02,x68k_crtc_operation_end);  // time taken to do operation is a complete guess.
344         timer_set(ATTOTIME_IN_MSEC(1),0x02,x68k_crtc_operation_end);  // time taken to do operation is a complete guess.
345345      }
346346      if(data & 0x02)  // high-speed graphic screen clear
347347      {
r1293r1294
367367         {
368368            fillbitmap(x68k_gfx_3_bitmap_16,0,&rect);
369369         }
370         mame_timer_set(MAME_TIME_IN_MSEC(10),0x02,x68k_crtc_operation_end);  // time taken to do operation is a complete guess.
370         timer_set(ATTOTIME_IN_MSEC(10),0x02,x68k_crtc_operation_end);  // time taken to do operation is a complete guess.
371371//         popmessage("CRTC: High-speed gfx screen clear [0x%02x]",sys.crtc.reg[21] & 0x0f);
372372      }
373373      break;
r1293r1294
882882   tilemap_set_transparent_pen(x68k_bg0_16,0);
883883   tilemap_set_transparent_pen(x68k_bg1_16,0);
884884
885//   mame_timer_adjust(scanline_timer,time_zero,0,MAME_TIME_IN_HZ(55.45)/568);
885//   timer_adjust(scanline_timer,attotime_zero,0,ATTOTIME_IN_HZ(55.45)/568);
886886}
887887
888888VIDEO_UPDATE( x68000 )
src/mess/video/spectrum.c
r1293r1294
111111                pItem = EventList_GetFirstItem();
112112                set_last_border_color ( pItem[NumItems-1].Event_Data );
113113                EventList_Reset();
114            EventList_SetOffsetStartTime ( MAME_TIME_TO_CYCLES(0, scale_up_mame_time(video_screen_get_scan_period(0), video_screen_get_vpos(0))) );
114            EventList_SetOffsetStartTime ( ATTOTIME_TO_CYCLES(0, attotime_mul(video_screen_get_scan_period(0), video_screen_get_vpos(0))) );
115115                logerror ("Event log reset in callback fn.\n");
116116        }
117117}
r1293r1294
138138                pItem = EventList_GetFirstItem();
139139                set_last_border_color ( pItem[NumItems-1].Event_Data );
140140                EventList_Reset();
141            EventList_SetOffsetStartTime ( MAME_TIME_TO_CYCLES(0, scale_up_mame_time(video_screen_get_scan_period(0), video_screen_get_vpos(0))) );
141            EventList_SetOffsetStartTime ( ATTOTIME_TO_CYCLES(0, attotime_mul(video_screen_get_scan_period(0), video_screen_get_vpos(0))) );
142142                logerror ("Event log reset in callback fn.\n");
143143        }
144144}
src/mess/video/atarist.c
r1293r1294
3232   int h, v;
3333} shifter;
3434
35static mame_timer *atarist_glue_timer;
36static mame_timer *atarist_shifter_timer;
35static emu_timer *atarist_glue_timer;
36static emu_timer *atarist_shifter_timer;
3737static mame_bitmap *atarist_bitmap;
3838
3939static TIMER_CALLBACK(atarist_shifter_tick)
r1293r1294
375375   UINT32 srcbuf;
376376} blitter;
377377
378static mame_timer *blitter_timer;
378static emu_timer *blitter_timer;
379379
380380static void atarist_blitter_source(void)
381381{
r1293r1294
681681         if ((data >> 8) & ATARIST_BLITTER_CTRL_BUSY)
682682         {
683683            int nops = BLITTER_NOPS[blitter.op][blitter.hop]; // each NOP takes 4 cycles
684            mame_timer_pulse(MAME_TIME_IN_HZ((Y2/4)/(4*nops)), 0, atarist_blitter_tick);
684            timer_pulse(ATTOTIME_IN_HZ((Y2/4)/(4*nops)), 0, atarist_blitter_tick);
685685         }
686686      }
687687   }
r1293r1294
695695
696696VIDEO_START( atarist )
697697{
698   atarist_shifter_timer = mame_timer_alloc(atarist_shifter_tick);
699   atarist_glue_timer = mame_timer_alloc(atarist_glue_tick);
700   blitter_timer = mame_timer_alloc(atarist_blitter_tick);
698   atarist_shifter_timer = timer_alloc(atarist_shifter_tick);
699   atarist_glue_timer = timer_alloc(atarist_glue_tick);
700   blitter_timer = timer_alloc(atarist_blitter_tick);
701701
702   mame_timer_adjust(atarist_glue_timer, video_screen_get_time_until_pos(0,0,4), 0, MAME_TIME_IN_HZ(Y2/16)); // 500 ns
703   mame_timer_adjust(atarist_shifter_timer, video_screen_get_time_until_pos(0,0,0), 0, MAME_TIME_IN_HZ(Y2/4)); // 125 ns
702   timer_adjust(atarist_glue_timer, video_screen_get_time_until_pos(0,0,4), 0, ATTOTIME_IN_HZ(Y2/16)); // 500 ns
703   timer_adjust(atarist_shifter_timer, video_screen_get_time_until_pos(0,0,0), 0, ATTOTIME_IN_HZ(Y2/4)); // 125 ns
704704
705705   atarist_bitmap = auto_bitmap_alloc(Machine->screen[0].width, Machine->screen[0].height, Machine->screen[0].format);
706706
src/mess/video/border.c
r1293r1294
341341
342342   /* Assume all other routines have processed their data from the list */
343343   EventList_Reset();
344   EventList_SetOffsetStartTime ( MAME_TIME_TO_CYCLES(0, scale_up_mame_time(video_screen_get_scan_period(0), video_screen_get_vpos(0))) );
344   EventList_SetOffsetStartTime ( ATTOTIME_TO_CYCLES(0, attotime_mul(video_screen_get_scan_period(0), video_screen_get_vpos(0))) );
345345}
src/mess/video/crtc6845.c
r1293r1294
4949
5050#if VERBOSE
5151#define DBG_LOG(N,M,A)      \
52    if(VERBOSE>=N){ if( M )logerror("%11.6f: %-24s",mame_timer_get_time(),(char*)M ); logerror A; }
52    if(VERBOSE>=N){ if( M )logerror("%11.6f: %-24s",timer_get_time(),(char*)M ); logerror A; }
5353#else
5454#define DBG_LOG(N,M,A)
5555#endif
r1293r1294
135135
136136   crtc = auto_malloc(sizeof(struct mscrtc6845));
137137   memset(crtc, 0, sizeof(*crtc));
138   crtc->cursor_time = mame_time_to_double(mame_timer_get_time());
138   crtc->cursor_time = attotime_to_double(timer_get_time());
139139   crtc->config = *config;
140140   mscrtc6845 = crtc;
141141
r1293r1294
179179   double neu, ftime;
180180   struct mscrtc6845_cursor cursor;
181181
182   neu = mame_time_to_double(mame_timer_get_time());
182   neu = attotime_to_double(timer_get_time());
183183
184184   if (mscrtc6845_clocks_in_frame(crtc) == 0.0)
185185      return;
src/mess/video/oric.c
r1293r1294
6868   /* initialise flash timer */
6969   vh_state.flash_count = 0;
7070   vh_state.flash_state = 0;
71   mame_timer_pulse(MAME_TIME_IN_HZ(50), 0, oric_vh_timer_callback);
71   timer_pulse(ATTOTIME_IN_HZ(50), 0, oric_vh_timer_callback);
7272   /* mode */
7373   oric_vh_update_attribute((1<<3)|(1<<4));
7474}
src/mess/video/vic4567.c
r1293r1294
786786      if (LIGHTPEN_BUTTON)
787787      {
788788         /* lightpen timer starten */
789         mame_timer_set (make_mame_time(0, 0), 1, vic2_timer_timeout);
789         timer_set (attotime_make(0, 0), 1, vic2_timer_timeout);
790790      }
791791      //state_display(vic2.bitmap);
792792   }
src/mess/video/zx8301.c
r1293r1294
1212 
1313static const int ZX8301_COLOR_MODE4[] = { 0, 2, 4, 7 };
1414 
15static mame_timer *zx8301_flash_timer;
15static emu_timer *zx8301_flash_timer;
1616 
1717static TIMER_CALLBACK(zx8301_flash_tick)
1818{
r1293r1294
110110 
111111VIDEO_START( zx8301 )
112112{
113   zx8301_flash_timer = mame_timer_alloc(zx8301_flash_tick);
114   mame_timer_adjust(zx8301_flash_timer, MAME_TIME_IN_HZ(2), 0, MAME_TIME_IN_HZ(2));
113   zx8301_flash_timer = timer_alloc(zx8301_flash_tick);
114   timer_adjust(zx8301_flash_timer, ATTOTIME_IN_HZ(2), 0, ATTOTIME_IN_HZ(2));
115115 
116116   state_save_register_global(zx8301.dispoff);
117117   state_save_register_global(zx8301.mode8);
src/mess/video/apple1.c
r1293r1294
176176   signal in response to a video display write.  This signal indicates
177177   the display has completed the write and is ready to accept another
178178   write. */
179mame_time apple1_vh_dsp_time_to_ready (void)
179attotime apple1_vh_dsp_time_to_ready (void)
180180{
181181   int cursor_x, cursor_y;
182182   int cursor_scanline;
183   double scanline_period = mame_time_to_double(video_screen_get_scan_period(0));
183   double scanline_period = attotime_to_double(video_screen_get_scan_period(0));
184184   double cursor_hfrac;
185185
186186   /* The video hardware refreshes the screen by reading the
r1293r1294
208208      double current_hfrac = video_screen_get_hpos(0) /
209209                        Machine->screen[0].width;
210210      if (current_hfrac < cursor_hfrac)
211         return double_to_mame_time(scanline_period * (cursor_hfrac - current_hfrac));
211         return double_to_attotime(scanline_period * (cursor_hfrac - current_hfrac));
212212   }
213213
214   return double_to_mame_time(
215      mame_time_to_double(video_screen_get_time_until_pos(0, cursor_scanline, 0)) +
214   return double_to_attotime(
215      attotime_to_double(video_screen_get_time_until_pos(0, cursor_scanline, 0)) +
216216      scanline_period * cursor_hfrac);
217217}
218218
r1293r1294
228228      number of one-third-cycles elapsed, then checking the result
229229      modulo 3. */
230230
231   if (((int) (mame_time_to_double(mame_timer_get_time()) / CURSOR_OFF_LENGTH)) % 3 < 2)
231   if (((int) (attotime_to_double(timer_get_time()) / CURSOR_OFF_LENGTH)) % 3 < 2)
232232      new_blink_on = 1;
233233   else
234234      new_blink_on = 0;
src/mess/video/pc_mda.c
r1293r1294
1616
1717#if VERBOSE_MDA
1818#define MDA_LOG(N,M,A) \
19   if(VERBOSE_MDA>=N){ if( M )logerror("%11.6f: %-24s",mame_timer_get_time(),(char*)M ); logerror A; }
19   if(VERBOSE_MDA>=N){ if( M )logerror("%11.6f: %-24s",timer_get_time(),(char*)M ); logerror A; }
2020#else
2121#define MDA_LOG(n,m,a)
2222#endif
src/mess/video/vdc8563.c
r1293r1294
2525
2626#if VERBOSE
2727#define DBG_LOG(N,M,A)      \
28    if(VERBOSE>=N){ if( M )logerror("%11.6f: %-24s",mame_timer_get_time(),(char*)M );
28    if(VERBOSE>=N){ if( M )logerror("%11.6f: %-24s",timer_get_time(),(char*)M );
2929 logerror A; }
3030#else
3131#define DBG_LOG(N,M,A)
r1293r1294
386386static void vdc8563_time(void)
387387{
388388   double neu, ftime;
389   neu=mame_time_to_double(mame_timer_get_time());
389   neu=attotime_to_double(timer_get_time());
390390
391391   if (vdc8563_clocks_in_frame()==0.0) return;
392392   ftime=16*vdc8563_clocks_in_frame()/2000000.0;
src/mess/video/coco3.c
r1293r1294
6767   UINT32 composite_palette[64];
6868   UINT32 rgb_palette[64];
6969   UINT8 fontdata[128][8];
70   mame_timer *gime_fs_timer;
70   emu_timer *gime_fs_timer;
7171
7272   /* CoCo 3 palette status */
7373   UINT8 palette_ram[16];
r1293r1294
511511   }
512512
513513   /* set up GIME field sync */
514   mame_timer_adjust(video->gime_fs_timer,
514   timer_adjust(video->gime_fs_timer,
515515      m6847_scanline_time(gime_field_sync),
516516      0,
517      time_never);
517      attotime_never);
518518
519519   return video->legacy_video;
520520}
r1293r1294
811811   }
812812
813813   /* GIME field sync timer */
814   video->gime_fs_timer = mame_timer_alloc(gime_fs);
814   video->gime_fs_timer = timer_alloc(gime_fs);
815815
816816   /* initialize the CoCo video code */
817817   memset(&cfg, 0, sizeof(cfg));
src/mess/video/smsvdp.c
r1293r1294
106106   int         *line_buffer;
107107   int         current_palette[32];
108108   void (*int_callback)(int);
109   mame_timer   *smsvdp_display_timer;
109   emu_timer   *smsvdp_display_timer;
110110} smsvdp;
111111
112112static TIMER_CALLBACK(smsvdp_display_callback);
r1293r1294
210210
211211   set_display_settings();
212212
213   smsvdp.smsvdp_display_timer = mame_timer_alloc( smsvdp_display_callback );
214   mame_timer_adjust( smsvdp.smsvdp_display_timer, video_screen_get_time_until_pos( 0, 0, 0 ), 0, video_screen_get_scan_period( 0 ) );
213   smsvdp.smsvdp_display_timer = timer_alloc( smsvdp_display_callback );
214   timer_adjust( smsvdp.smsvdp_display_timer, video_screen_get_time_until_pos( 0, 0, 0 ), 0, video_screen_get_scan_period( 0 ) );
215215   return 0;
216216}
217217
r1293r1294
255255            smsvdp.status |= STATUS_HINT;
256256            if ( smsvdp.reg[0x00] & 0x10 ) {
257257               /* Delay triggering of interrupt to allow software to read the status bit before the irq */
258               mame_timer_set( video_screen_get_time_until_pos( 0, video_screen_get_vpos(0), video_screen_get_hpos(0) + 1 ), 0, smsvdp_set_irq );
258               timer_set( video_screen_get_time_until_pos( 0, video_screen_get_vpos(0), video_screen_get_hpos(0) + 1 ), 0, smsvdp_set_irq );
259259            }
260260         }
261261
r1293r1294
264264         smsvdp.status |= STATUS_VINT;
265265         if ( smsvdp.reg[0x01] & 0x20 ) {
266266            /* Delay triggering of interrupt to allow software to read the status bit before the irq */
267            mame_timer_set( video_screen_get_time_until_pos( 0, video_screen_get_vpos(0), video_screen_get_hpos(0) + 1 ), 0, smsvdp_set_irq );
267            timer_set( video_screen_get_time_until_pos( 0, video_screen_get_vpos(0), video_screen_get_hpos(0) + 1 ), 0, smsvdp_set_irq );
268268         }
269269      }
270270      if ( video_skip_this_frame() ) {
r1293r1294
299299         smsvdp.status |= STATUS_HINT;
300300         if ( smsvdp.reg[0x00] & 0x10 ) {
301301            /* Delay triggering of interrupt to allow software to read the status bit before the irq */
302            mame_timer_set( video_screen_get_time_until_pos( 0, video_screen_get_vpos(0), video_screen_get_hpos(0) + 1 ), 0, smsvdp_set_irq );
302            timer_set( video_screen_get_time_until_pos( 0, video_screen_get_vpos(0), video_screen_get_hpos(0) + 1 ), 0, smsvdp_set_irq );
303303         }
304304      } else {
305305         smsvdp.line_counter -= 1;
src/mess/video/pc_cga.c
r1293r1294
6161
6262#if VERBOSE_CGA
6363#define CGA_LOG(N,M,A) \
64   if(VERBOSE_CGA>=N){ if( M )logerror("%11.6f: %-24s",mame_timer_get_time(),(char*)M ); logerror A; }
64   if(VERBOSE_CGA>=N){ if( M )logerror("%11.6f: %-24s",timer_get_time(),(char*)M ); logerror A; }
6565#else
6666#define CGA_LOG(n,m,a)
6767#endif
r1293r1294
276276   state_save_register_item("pccga", 0, cga.status);
277277   state_save_register_item("pccga", 0, cga.plantronics);
278278
279   mame_timer_pulse(MAME_TIME_IN_USEC(133333), 0, cga_timerproc);
279   timer_pulse(ATTOTIME_IN_USEC(133333), 0, cga_timerproc);
280280   return 0;
281281}
282282
src/mess/video/cdp1864.c
r1293r1294
55
66static mame_bitmap *cdptmpbitmap;
77
8static mame_timer *cdp1864_int_timer;
9static mame_timer *cdp1864_efx_timer;
10static mame_timer *cdp1864_dma_timer;
8static emu_timer *cdp1864_int_timer;
9static emu_timer *cdp1864_efx_timer;
10static emu_timer *cdp1864_dma_timer;
1111
1212typedef struct
1313{
r1293r1294
3838         cdp1864.dmaptr = 0;
3939      }
4040
41      mame_timer_adjust(cdp1864_int_timer, video_screen_get_time_until_pos(0, CDP1864_SCANLINE_INT_END, 0), 0, time_zero);
41      timer_adjust(cdp1864_int_timer, video_screen_get_time_until_pos(0, CDP1864_SCANLINE_INT_END, 0), 0, attotime_zero);
4242   }
4343   else
4444   {
r1293r1294
4747         cpunum_set_input_line(0, CDP1802_INPUT_LINE_INT, CLEAR_LINE);
4848      }
4949
50      mame_timer_adjust(cdp1864_int_timer, video_screen_get_time_until_pos(0, CDP1864_SCANLINE_INT_START, 0), 0, time_zero);
50      timer_adjust(cdp1864_int_timer, video_screen_get_time_until_pos(0, CDP1864_SCANLINE_INT_START, 0), 0, attotime_zero);
5151   }
5252}
5353
r1293r1294
5959   {
6060   case CDP1864_SCANLINE_EFX_TOP_START:
6161      cdp1864_efx = ASSERT_LINE;
62      mame_timer_adjust(cdp1864_efx_timer, video_screen_get_time_until_pos(0, CDP1864_SCANLINE_EFX_TOP_END, 0), 0, time_zero);
62      timer_adjust(cdp1864_efx_timer, video_screen_get_time_until_pos(0, CDP1864_SCANLINE_EFX_TOP_END, 0), 0, attotime_zero);
6363      break;
6464
6565   case CDP1864_SCANLINE_EFX_TOP_END:
6666      cdp1864_efx = CLEAR_LINE;
67      mame_timer_adjust(cdp1864_efx_timer, video_screen_get_time_until_pos(0, CDP1864_SCANLINE_EFX_BOTTOM_START, 0), 0, time_zero);
67      timer_adjust(cdp1864_efx_timer, video_screen_get_time_until_pos(0, CDP1864_SCANLINE_EFX_BOTTOM_START, 0), 0, attotime_zero);
6868      break;
6969
7070   case CDP1864_SCANLINE_EFX_BOTTOM_START:
7171      cdp1864_efx = ASSERT_LINE;
72      mame_timer_adjust(cdp1864_efx_timer, video_screen_get_time_until_pos(0, CDP1864_SCANLINE_EFX_BOTTOM_END, 0), 0, time_zero);
72      timer_adjust(cdp1864_efx_timer, video_screen_get_time_until_pos(0, CDP1864_SCANLINE_EFX_BOTTOM_END, 0), 0, attotime_zero);
7373      break;
7474
7575   case CDP1864_SCANLINE_EFX_BOTTOM_END:
7676      cdp1864_efx = CLEAR_LINE;
77      mame_timer_adjust(cdp1864_efx_timer, video_screen_get_time_until_pos(0, CDP1864_SCANLINE_EFX_TOP_START, 0), 0, time_zero);
77      timer_adjust(cdp1864_efx_timer, video_screen_get_time_until_pos(0, CDP1864_SCANLINE_EFX_TOP_START, 0), 0, attotime_zero);
7878      break;
7979   }
8080}
r1293r1294
9393         }
9494      }
9595
96      mame_timer_adjust(cdp1864_dma_timer, MAME_TIME_IN_CYCLES(CDP1864_CYCLES_DMA_WAIT, 0), 0, time_zero);
96      timer_adjust(cdp1864_dma_timer, ATTOTIME_IN_CYCLES(CDP1864_CYCLES_DMA_WAIT, 0), 0, attotime_zero);
9797     
9898      cdp1864.dmaout = 0;
9999   }
r1293r1294
107107         }
108108      }
109109
110      mame_timer_adjust(cdp1864_dma_timer, MAME_TIME_IN_CYCLES(CDP1864_CYCLES_DMA_ACTIVE, 0), 0, time_zero);
110      timer_adjust(cdp1864_dma_timer, ATTOTIME_IN_CYCLES(CDP1864_CYCLES_DMA_ACTIVE, 0), 0, attotime_zero);
111111     
112112      cdp1864.dmaout = 1;
113113   }
r1293r1294
178178
179179MACHINE_RESET( cdp1864 )
180180{
181   mame_timer_adjust(cdp1864_int_timer, video_screen_get_time_until_pos(0, CDP1864_SCANLINE_INT_START, 0), 0, time_zero);
182   mame_timer_adjust(cdp1864_efx_timer, video_screen_get_time_until_pos(0, CDP1864_SCANLINE_EFX_TOP_START, 0), 0, time_zero);
183   mame_timer_adjust(cdp1864_dma_timer, MAME_TIME_IN_CYCLES(CDP1864_CYCLES_DMA_START, 0), 0, time_zero);
181   timer_adjust(cdp1864_int_timer, video_screen_get_time_until_pos(0, CDP1864_SCANLINE_INT_START, 0), 0, attotime_zero);
182   timer_adjust(cdp1864_efx_timer, video_screen_get_time_until_pos(0, CDP1864_SCANLINE_EFX_TOP_START, 0), 0, attotime_zero);
183   timer_adjust(cdp1864_dma_timer, ATTOTIME_IN_CYCLES(CDP1864_CYCLES_DMA_START, 0), 0, attotime_zero);
184184
185185   cdp1864.disp = 0;
186186   cdp1864.dmaout = 0;
r1293r1294
196196
197197VIDEO_START( cdp1864 )
198198{
199   cdp1864_int_timer = mame_timer_alloc(cdp1864_int_tick);
200   cdp1864_efx_timer = mame_timer_alloc(cdp1864_efx_tick);
201   cdp1864_dma_timer = mame_timer_alloc(cdp1864_dma_tick);
199   cdp1864_int_timer = timer_alloc(cdp1864_int_tick);
200   cdp1864_efx_timer = timer_alloc(cdp1864_efx_tick);
201   cdp1864_dma_timer = timer_alloc(cdp1864_dma_tick);
202202
203203   /* allocate the temporary bitmap */
204204   cdptmpbitmap = auto_bitmap_alloc(Machine->screen[0].width, Machine->screen[0].height, Machine->screen[0].format);
src/mess/video/vic6567.c
r1293r1294
13191319      if (LIGHTPEN_BUTTON)
13201320      {
13211321         /* lightpen timer starten */
1322         mame_timer_set (make_mame_time(0, 0), 1, vic2_timer_timeout);
1322         timer_set (attotime_make(0, 0), 1, vic2_timer_timeout);
13231323      }
13241324   }
13251325   if (vic2.rasterline == C64_2_RASTERLINE (RASTERLINE))
src/mess/video/odyssey2.c
r1293r1294
152152
153153static UINT8 collision[8];    /* only 7 used but easier to index */
154154static int line;
155static mame_time line_time;
155static attotime line_time;
156156static UINT32 o2_snd_shift[2];
157157static UINT8 x_beam_pos;
158158static UINT8 y_beam_pos;
r1293r1294
176176INLINE int get_horiz_clock_beam_pos( void )
177177{
178178    int h;
179    h = scale_up_mame_time(sub_mame_times(mame_timer_get_time(), line_time), Machine->drv->cpu[0].clock * 8).seconds;
179    h = attotime_mul(attotime_sub(timer_get_time(), line_time), Machine->drv->cpu[0].clock * 8).seconds;
180180
181181    return h;
182182}
r1293r1294
184184INLINE int get_horiz_clock( void )
185185{
186186    int h;
187    h = scale_up_mame_time(sub_mame_times(mame_timer_get_time(), line_time), Machine->drv->cpu[0].clock).seconds;
187    h = attotime_mul(attotime_sub(timer_get_time(), line_time), Machine->drv->cpu[0].clock).seconds;
188188
189189    return h;
190190}
r1293r1294
317317
318318INTERRUPT_GEN( odyssey2_line )
319319{
320    line_time = mame_timer_get_time();
320    line_time = timer_get_time();
321321    line = (line + 1) % 262;
322322
323323    switch (line)
src/mess/video/m6845.c
r1293r1294
790790{
791791   if (m6845_vsync_clear_timer!=NULL)
792792   {
793      mame_timer_reset(m6845_vsync_clear_timer, time_never);   /* FIXME - timers should only be allocated once */
793      timer_reset(m6845_vsync_clear_timer, attotime_never);   /* FIXME - timers should only be allocated once */
794794      m6845_vsync_clear_timer = NULL;
795795   }
796796}
r1293r1294
808808
809809        if (crtc_cycles_to_vsync_start!=-1)
810810   {
811                m6845_vsync_set_timer = mame_timer_set(MAME_TIME_IN_USEC(crtc_cycles_to_vsync_start), 0, m6845_vsync_set_timer_callback);
811                m6845_vsync_set_timer = timer_set(ATTOTIME_IN_USEC(crtc_cycles_to_vsync_start), 0, m6845_vsync_set_timer_callback);
812812   }
813813}
814814
r1293r1294
824824
825825   if (crtc_cycles_to_vsync_end!=-1)
826826   {
827                m6845_vsync_clear_timer = mame_timer_set(MAME_TIME_IN_USEC(crtc_cycles_to_vsync_end), 0, m6845_vsync_clear_timer_callback);
827                m6845_vsync_clear_timer = timer_set(ATTOTIME_IN_USEC(crtc_cycles_to_vsync_end), 0, m6845_vsync_clear_timer_callback);
828828   }
829829}
830830
r1293r1294
847847   m6845_set_new_vsync_set_time(m6845_cycles_per_frame()-m6845_vsync_length_in_cycles());
848848
849849   /* prevent timer from being free'd and don't let it trigger again */
850   mame_timer_reset(m6845_vsync_clear_timer, time_never);
850   timer_reset(m6845_vsync_clear_timer, attotime_never);
851851}
852852
853853/* called when vsync is set */
r1293r1294
868868    m6845_set_new_vsync_clear_time(m6845_vsync_length_in_cycles());
869869
870870   /* prevent timer from being free'd and don't let it trigger again */
871   mame_timer_reset(m6845_vsync_set_timer, time_never);
871   timer_reset(m6845_vsync_set_timer, attotime_never);
872872}
873873static void m6845_recalc_cycles_to_vsync_end(void)
874874{
src/mess/video/apple2.c
r1293r1294
465465   int new_flash;
466466   UINT32 new_a2;
467467
468   new_flash = (scale_up_mame_time(mame_timer_get_time(), 4).seconds & 1) ? 1 : 0;
468   new_flash = (attotime_mul(timer_get_time(), 4).seconds & 1) ? 1 : 0;
469469   if (flash != new_flash)
470470   {
471471      flash = new_flash;
src/mess/video/ted7360.c
r1293r1294
378378#define TIMER2 (TIMER2HELPER?TIMER2HELPER:0x10000)
379379#define TIMER3 (TIMER3HELPER?TIMER3HELPER:0x10000)
380380
381static mame_time TEDTIME_IN_CYCLES(int cycles)
381static attotime TEDTIME_IN_CYCLES(int cycles)
382382{
383383   double d = (double)(cycles)/TED7360_CLOCK;
384   return double_to_mame_time(d);
384   return double_to_attotime(d);
385385}
386386
387static int TEDTIME_TO_CYCLES(mame_time t)
387static int TEDTIME_TO_CYCLES(attotime t)
388388{
389   double d = mame_time_to_double(t);
389   double d = attotime_to_double(t);
390390   return (int)((d)*TED7360_CLOCK);
391391}
392392
r1293r1294
493493
494494static int lines;
495495static int timer1_active, timer2_active, timer3_active;
496static mame_timer *timer1, *timer2, *timer3;
496static emu_timer *timer1, *timer2, *timer3;
497497static int cursor1 = FALSE;
498498static read8_handler vic_dma_read;
499499static read8_handler vic_dma_read_rom;
r1293r1294
534534   lines = TED7360_LINES;
535535   chargenaddr = bitmapaddr = videoaddr = 0;
536536   timer1_active = timer2_active = timer3_active = 0;
537   timer1 = mame_timer_alloc(ted7360_timer_timeout);
538   timer2 = mame_timer_alloc(ted7360_timer_timeout);
539   timer3 = mame_timer_alloc(ted7360_timer_timeout);
537   timer1 = timer_alloc(ted7360_timer_timeout);
538   timer2 = timer_alloc(ted7360_timer_timeout);
539   timer3 = timer_alloc(ted7360_timer_timeout);
540540}
541541
542542void ted7360_set_dma (read8_handler dma_read,
r1293r1294
576576
577577static int ted7360_rastercolumn (void)
578578{
579   return (int) ((mame_time_to_double(mame_timer_get_time ()) - rastertime)
579   return (int) ((attotime_to_double(timer_get_time ()) - rastertime)
580580              * TED7360_VRETRACERATE * lines * 57 * 8 + 0.5);
581581}
582582
r1293r1294
588588   {
589589   case 1:
590590       // prooved by digisound of several intros like eoroidpro
591      mame_timer_adjust(timer1, TEDTIME_IN_CYCLES (TIMER1), 1, time_zero);
591      timer_adjust(timer1, TEDTIME_IN_CYCLES (TIMER1), 1, attotime_zero);
592592      timer1_active = 1;
593593      ted7360_set_interrupt (8);
594594      break;
595595   case 2:
596      mame_timer_adjust(timer2, TEDTIME_IN_CYCLES (0x10000), 2, time_zero);
596      timer_adjust(timer2, TEDTIME_IN_CYCLES (0x10000), 2, attotime_zero);
597597      timer2_active = 1;
598598      ted7360_set_interrupt (0x10);
599599      break;
600600   case 3:
601      mame_timer_adjust(timer3, TEDTIME_IN_CYCLES (0x10000), 3, time_zero);
601      timer_adjust(timer3, TEDTIME_IN_CYCLES (0x10000), 3, attotime_zero);
602602      timer3_active = 1;
603603      ted7360_set_interrupt (0x40);
604604      break;
r1293r1294
644644      ted7360[offset] = data;
645645      if (timer1_active)
646646      {
647         ted7360[1] = TEDTIME_TO_CYCLES (mame_timer_timeleft (timer1)) >> 8;
648         mame_timer_reset(timer1, time_never);
647         ted7360[1] = TEDTIME_TO_CYCLES (timer_timeleft (timer1)) >> 8;
648         timer_reset(timer1, attotime_never);
649649         timer1_active = 0;
650650      }
651651      break;
652652   case 1:                     /* start timer 1 */
653653      ted7360[offset] = data;
654      mame_timer_adjust(timer1, TEDTIME_IN_CYCLES (TIMER1), 1, time_zero);
654      timer_adjust(timer1, TEDTIME_IN_CYCLES (TIMER1), 1, attotime_zero);
655655      timer1_active = 1;
656656      break;
657657   case 2:                     /* stop timer 2 */
658658      ted7360[offset] = data;
659659      if (timer2_active)
660660      {
661         ted7360[3] = TEDTIME_TO_CYCLES (mame_timer_timeleft (timer2)) >> 8;
662         mame_timer_reset(timer2, time_never);
661         ted7360[3] = TEDTIME_TO_CYCLES (timer_timeleft (timer2)) >> 8;
662         timer_reset(timer2, attotime_never);
663663         timer2_active = 0;
664664      }
665665      break;
666666   case 3:                     /* start timer 2 */
667667      ted7360[offset] = data;
668      mame_timer_adjust(timer2, TEDTIME_IN_CYCLES (TIMER2), 2, time_zero);
668      timer_adjust(timer2, TEDTIME_IN_CYCLES (TIMER2), 2, attotime_zero);
669669      timer2_active = 1;
670670      break;
671671   case 4:                     /* stop timer 3 */
672672      ted7360[offset] = data;
673673      if (timer3_active)
674674      {
675         ted7360[5] = TEDTIME_TO_CYCLES (mame_timer_timeleft (timer3)) >> 8;
676         mame_timer_reset(timer3, time_never);
675         ted7360[5] = TEDTIME_TO_CYCLES (timer_timeleft (timer3)) >> 8;
676         timer_reset(timer3, attotime_never);
677677         timer3_active = 0;
678678      }
679679      break;
680680   case 5:                     /* start timer 3 */
681681      ted7360[offset] = data;
682      mame_timer_adjust(timer3, TEDTIME_IN_CYCLES (TIMER3), 3, time_zero);
682      timer_adjust(timer3, TEDTIME_IN_CYCLES (TIMER3), 3, attotime_zero);
683683      timer3_active = 1;
684684      break;
685685   case 6:
r1293r1294
858858   {
859859   case 0:
860860      if (timer1)
861         val = TEDTIME_TO_CYCLES (mame_timer_timeleft (timer1)) & 0xff;
861         val = TEDTIME_TO_CYCLES (timer_timeleft (timer1)) & 0xff;
862862      else
863863         val = ted7360[offset];
864864      break;
865865   case 1:
866866      if (timer1)
867         val = TEDTIME_TO_CYCLES (mame_timer_timeleft (timer1)) >> 8;
867         val = TEDTIME_TO_CYCLES (timer_timeleft (timer1)) >> 8;
868868      else
869869         val = ted7360[offset];
870870      break;
871871   case 2:
872872      if (timer2)
873         val = TEDTIME_TO_CYCLES (mame_timer_timeleft (timer2)) & 0xff;
873         val = TEDTIME_TO_CYCLES (timer_timeleft (timer2)) & 0xff;
874874      else
875875         val = ted7360[offset];
876876      break;
877877   case 3:
878878      if (timer2)
879         val = TEDTIME_TO_CYCLES (mame_timer_timeleft (timer2)) >> 8;
879         val = TEDTIME_TO_CYCLES (timer_timeleft (timer2)) >> 8;
880880      else
881881         val = ted7360[offset];
882882      break;
883883   case 4:
884884      if (timer3)
885         val = TEDTIME_TO_CYCLES (mame_timer_timeleft (timer3)) & 0xff;
885         val = TEDTIME_TO_CYCLES (timer_timeleft (timer3)) & 0xff;
886886      else
887887         val = ted7360[offset];
888888      break;
889889   case 5:
890890      if (timer3)
891         val = TEDTIME_TO_CYCLES (mame_timer_timeleft (timer3)) >> 8;
891         val = TEDTIME_TO_CYCLES (timer_timeleft (timer3)) >> 8;
892892      else
893893         val = ted7360[offset];
894894      break;
r1293r1294
12101210INTERRUPT_GEN( ted7360_raster_interrupt )
12111211{
12121212   rasterline++;
1213   rastertime = mame_time_to_double(mame_timer_get_time ());
1213   rastertime = attotime_to_double(timer_get_time ());
12141214   if (rasterline >= lines)
12151215   {
12161216      rasterline = 0;
src/mess/video/saa5050.c
r1293r1294
240240
241241MACHINE_DRIVER_START( vh_saa5050 )
242242   MDRV_SCREEN_REFRESH_RATE(50)
243   MDRV_SCREEN_VBLANK_TIME(USEC_TO_SUBSECONDS(SAA5050_VBLANK))
243   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(SAA5050_VBLANK))
244244   MDRV_INTERLEAVE(1)
245245
246246   MDRV_VIDEO_ATTRIBUTES(VIDEO_TYPE_RASTER)
src/mess/video/cdp1861.c
r1293r1294
55
66static mame_bitmap *cdptmpbitmap;
77
8static mame_timer *cdp1861_int_timer;
9static mame_timer *cdp1861_efx_timer;
10static mame_timer *cdp1861_dma_timer;
8static emu_timer *cdp1861_int_timer;
9static emu_timer *cdp1861_efx_timer;
10static emu_timer *cdp1861_dma_timer;
1111
1212typedef struct
1313{
r1293r1294
3030         cpunum_set_input_line(0, CDP1802_INPUT_LINE_INT, HOLD_LINE);
3131      }
3232
33      mame_timer_adjust(cdp1861_int_timer, video_screen_get_time_until_pos(0, CDP1861_SCANLINE_INT_END, 0), 0, time_zero);
33      timer_adjust(cdp1861_int_timer, video_screen_get_time_until_pos(0, CDP1861_SCANLINE_INT_END, 0), 0, attotime_zero);
3434   }
3535   else
3636   {
r1293r1294
3939         cpunum_set_input_line(0, CDP1802_INPUT_LINE_INT, CLEAR_LINE);
4040      }
4141
42      mame_timer_adjust(cdp1861_int_timer, video_screen_get_time_until_pos(0, CDP1861_SCANLINE_INT_START, 0), 0, time_zero);
42      timer_adjust(cdp1861_int_timer, video_screen_get_time_until_pos(0, CDP1861_SCANLINE_INT_START, 0), 0, attotime_zero);
4343   }
4444}
4545
r1293r1294
5151   {
5252   case CDP1861_SCANLINE_EFX_TOP_START:
5353      cdp1861_efx = ASSERT_LINE;
54      mame_timer_adjust(cdp1861_efx_timer, video_screen_get_time_until_pos(0, CDP1861_SCANLINE_EFX_TOP_END, 0), 0, time_zero);
54      timer_adjust(cdp1861_efx_timer, video_screen_get_time_until_pos(0, CDP1861_SCANLINE_EFX_TOP_END, 0), 0, attotime_zero);
5555      break;
5656
5757   case CDP1861_SCANLINE_EFX_TOP_END:
5858      cdp1861_efx = CLEAR_LINE;
59      mame_timer_adjust(cdp1861_efx_timer, video_screen_get_time_until_pos(0, CDP1861_SCANLINE_EFX_BOTTOM_START, 0), 0, time_zero);
59      timer_adjust(cdp1861_efx_timer, video_screen_get_time_until_pos(0, CDP1861_SCANLINE_EFX_BOTTOM_START, 0), 0, attotime_zero);
6060      break;
6161
6262   case CDP1861_SCANLINE_EFX_BOTTOM_START:
6363      cdp1861_efx = ASSERT_LINE;
64      mame_timer_adjust(cdp1861_efx_timer, video_screen_get_time_until_pos(0, CDP1861_SCANLINE_EFX_BOTTOM_END, 0), 0, time_zero);
64      timer_adjust(cdp1861_efx_timer, video_screen_get_time_until_pos(0, CDP1861_SCANLINE_EFX_BOTTOM_END, 0), 0, attotime_zero);
6565      break;
6666
6767   case CDP1861_SCANLINE_EFX_BOTTOM_END:
6868      cdp1861_efx = CLEAR_LINE;
69      mame_timer_adjust(cdp1861_efx_timer, video_screen_get_time_until_pos(0, CDP1861_SCANLINE_EFX_TOP_START, 0), 0, time_zero);
69      timer_adjust(cdp1861_efx_timer, video_screen_get_time_until_pos(0, CDP1861_SCANLINE_EFX_TOP_START, 0), 0, attotime_zero);
7070      break;
7171   }
7272}
r1293r1294
8585         }
8686      }
8787
88      mame_timer_adjust(cdp1861_dma_timer, MAME_TIME_IN_CYCLES(CDP1861_CYCLES_DMA_WAIT, 0), 0, time_zero);
88      timer_adjust(cdp1861_dma_timer, ATTOTIME_IN_CYCLES(CDP1861_CYCLES_DMA_WAIT, 0), 0, attotime_zero);
8989     
9090      cdp1861.dmaout = 0;
9191   }
r1293r1294
9999         }
100100      }
101101
102      mame_timer_adjust(cdp1861_dma_timer, MAME_TIME_IN_CYCLES(CDP1861_CYCLES_DMA_ACTIVE, 0), 0, time_zero);
102      timer_adjust(cdp1861_dma_timer, ATTOTIME_IN_CYCLES(CDP1861_CYCLES_DMA_ACTIVE, 0), 0, attotime_zero);
103103     
104104      cdp1861.dmaout = 1;
105105   }
r1293r1294
121121
122122MACHINE_RESET( cdp1861 )
123123{
124   mame_timer_adjust(cdp1861_int_timer, video_screen_get_time_until_pos(0, CDP1861_SCANLINE_INT_START, 0), 0, time_zero);
125   mame_timer_adjust(cdp1861_efx_timer, video_screen_get_time_until_pos(0, CDP1861_SCANLINE_EFX_TOP_START, 0), 0, time_zero);
126   mame_timer_adjust(cdp1861_dma_timer, MAME_TIME_IN_CYCLES(CDP1861_CYCLES_DMA_START, 0), 0, time_zero);
124   timer_adjust(cdp1861_int_timer, video_screen_get_time_until_pos(0, CDP1861_SCANLINE_INT_START, 0), 0, attotime_zero);
125   timer_adjust(cdp1861_efx_timer, video_screen_get_time_until_pos(0, CDP1861_SCANLINE_EFX_TOP_START, 0), 0, attotime_zero);
126   timer_adjust(cdp1861_dma_timer, ATTOTIME_IN_CYCLES(CDP1861_CYCLES_DMA_START, 0), 0, attotime_zero);
127127
128128   cdp1861.disp = 0;
129129   cdp1861.dmaout = 0;
r1293r1294
149149
150150VIDEO_START( cdp1861 )
151151{
152   cdp1861_int_timer = mame_timer_alloc(cdp1861_int_tick);
153   cdp1861_efx_timer = mame_timer_alloc(cdp1861_efx_tick);
154   cdp1861_dma_timer = mame_timer_alloc(cdp1861_dma_tick);
152   cdp1861_int_timer = timer_alloc(cdp1861_int_tick);
153   cdp1861_efx_timer = timer_alloc(cdp1861_efx_tick);
154   cdp1861_dma_timer = timer_alloc(cdp1861_dma_tick);
155155
156156   /* allocate the temporary bitmap */
157157   cdptmpbitmap = auto_bitmap_alloc(Machine->screen[0].width, Machine->screen[0].height, Machine->screen[0].format);
src/mess/video/kc.c
r1293r1294
110110/* set new blink state - record blink state in event list */
111111void   kc85_video_set_blink_state(int data)
112112{
113   EventList_AddItemOffset(KC85_VIDEO_EVENT_SET_BLINK_STATE, ((data & 0x01)<<7), MAME_TIME_TO_CYCLES(0, scale_up_mame_time(video_screen_get_scan_period(0), video_screen_get_vpos(0))));
113   EventList_AddItemOffset(KC85_VIDEO_EVENT_SET_BLINK_STATE, ((data & 0x01)<<7), ATTOTIME_TO_CYCLES(0, attotime_mul(video_screen_get_scan_period(0), video_screen_get_vpos(0))));
114114}
115115
116116
r1293r1294
551551   /* process remainder */
552552   kc85_common_vh_process_lines(&video_update, cycles_remaining_in_frame);
553553   EventList_Reset();
554   EventList_SetOffsetStartTime ( MAME_TIME_TO_CYCLES(0, scale_up_mame_time(video_screen_get_scan_period(0), video_screen_get_vpos(0))) );
554   EventList_SetOffsetStartTime ( ATTOTIME_TO_CYCLES(0, attotime_mul(video_screen_get_scan_period(0), video_screen_get_vpos(0))) );
555555}
556556
557557
r1293r1294
574574      {
575575         pItem = EventList_GetFirstItem();
576576         EventList_Reset();
577         EventList_SetOffsetStartTime ( MAME_TIME_TO_CYCLES(0, scale_up_mame_time(video_screen_get_scan_period(0), video_screen_get_vpos(0))) );
577         EventList_SetOffsetStartTime ( ATTOTIME_TO_CYCLES(0, attotime_mul(video_screen_get_scan_period(0), video_screen_get_vpos(0))) );
578578         logerror ("Event log reset in callback fn.\n");
579579      }
580580}
src/mess/inputx.c
r1293r1294
561561
562562static mess_input_code *codes;
563563static key_buffer *keybuffer;
564static mame_timer *inputx_timer;
564static emu_timer *inputx_timer;
565565static int (*queue_chars)(const unicode_char *text, size_t text_len);
566566static int (*accept_char)(unicode_char ch);
567567static int (*charqueue_empty)(void);
568static mame_time current_rate;
568static attotime current_rate;
569569
570570static TIMER_CALLBACK(inputx_timerproc);
571571
r1293r1294
582582
583583static void setup_keybuffer(void)
584584{
585   inputx_timer = mame_timer_alloc(inputx_timerproc);
585   inputx_timer = timer_alloc(inputx_timerproc);
586586   keybuffer = auto_malloc(sizeof(key_buffer));
587587   memset(keybuffer, 0, sizeof(*keybuffer));
588588}
r1293r1294
733733
734734
735735
736static mame_time choose_delay(unicode_char ch)
736static attotime choose_delay(unicode_char ch)
737737{
738   subseconds_t delay = 0;
738   attoseconds_t delay = 0;
739739
740   if (current_rate.seconds || current_rate.subseconds)
740   if (attotime_compare(current_rate, attotime_zero) != 0)
741741      return current_rate;
742742
743743   if (queue_chars)
744744   {
745745      /* systems with queue_chars can afford a much smaller delay */
746      delay = DOUBLE_TO_SUBSECONDS(0.01);
746      delay = DOUBLE_TO_ATTOSECONDS(0.01);
747747   }
748748   else
749749   {
750750      switch(ch) {
751751      case '\r':
752         delay = DOUBLE_TO_SUBSECONDS(0.2);
752         delay = DOUBLE_TO_ATTOSECONDS(0.2);
753753         break;
754754
755755      default:
756         delay = DOUBLE_TO_SUBSECONDS(0.05);
756         delay = DOUBLE_TO_ATTOSECONDS(0.05);
757757         break;
758758      }
759759   }
760   return make_mame_time(0, delay);
760   return attotime_make(0, delay);
761761}
762762
763763
r1293r1294
771771   /* need to start up the timer? */
772772   if (keybuf->begin_pos == keybuf->end_pos)
773773   {
774      mame_timer_adjust(inputx_timer, choose_delay(ch), 0, time_zero);
774      timer_adjust(inputx_timer, choose_delay(ch), 0, attotime_zero);
775775      keybuf->status_keydown = 0;
776776   }
777777
r1293r1294
790790
791791
792792
793void inputx_postn_rate(const unicode_char *text, size_t text_len, mame_time rate)
793void inputx_postn_rate(const unicode_char *text, size_t text_len, attotime rate)
794794{
795795   int last_cr = 0;
796796   unicode_char ch;
r1293r1294
852852static TIMER_CALLBACK(inputx_timerproc)
853853{
854854   key_buffer *keybuf;
855   mame_time delay;
855   attotime delay;
856856
857857   keybuf = get_buffer();
858858
r1293r1294
864864         keybuf->begin_pos++;
865865         keybuf->begin_pos %= sizeof(keybuf->buffer) / sizeof(keybuf->buffer[0]);
866866
867         if (current_rate.seconds || current_rate.subseconds)
867         if (attotime_compare(current_rate, attotime_zero) != 0)
868868            break;
869869      }
870870   }
r1293r1294
887887   if (keybuf->begin_pos != keybuf->end_pos)
888888   {
889889      delay = choose_delay(keybuf->buffer[keybuf->begin_pos]);
890      mame_timer_adjust(inputx_timer, delay, 0, time_zero);
890      timer_adjust(inputx_timer, delay, 0, attotime_zero);
891891   }
892892}
893893
r1293r1294
10081008
10091009***************************************************************************/
10101010
1011void inputx_postn_coded_rate(const char *text, size_t text_len, mame_time rate)
1011void inputx_postn_coded_rate(const char *text, size_t text_len, attotime rate)
10121012{
10131013   size_t i, j, key_len, increment;
10141014   unicode_char ch;
r1293r1294
10871087
10881088void inputx_postn(const unicode_char *text, size_t text_len)
10891089{
1090   inputx_postn_rate(text, text_len, make_mame_time(0, 0));
1090   inputx_postn_rate(text, text_len, attotime_make(0, 0));
10911091}
10921092
10931093
10941094
1095void inputx_post_rate(const unicode_char *text, mame_time rate)
1095void inputx_post_rate(const unicode_char *text, attotime rate)
10961096{
10971097   size_t len = 0;
10981098   while(text[len])
r1293r1294
11041104
11051105void inputx_post(const unicode_char *text)
11061106{
1107   inputx_post_rate(text, make_mame_time(0, 0));
1107   inputx_post_rate(text, attotime_make(0, 0));
11081108}
11091109
11101110
11111111
1112void inputx_postc_rate(unicode_char ch, mame_time rate)
1112void inputx_postc_rate(unicode_char ch, attotime rate)
11131113{
11141114   inputx_postn_rate(&ch, 1, rate);
11151115}
r1293r1294
11181118
11191119void inputx_postc(unicode_char ch)
11201120{
1121   inputx_postc_rate(ch, make_mame_time(0, 0));
1121   inputx_postc_rate(ch, attotime_make(0, 0));
11221122}
11231123
11241124
11251125
1126void inputx_postn_utf16_rate(const utf16_char *text, size_t text_len, mame_time rate)
1126void inputx_postn_utf16_rate(const utf16_char *text, size_t text_len, attotime rate)
11271127{
11281128   size_t len = 0;
11291129   unicode_char c;
r1293r1294
11801180
11811181void inputx_postn_utf16(const utf16_char *text, size_t text_len)
11821182{
1183   inputx_postn_utf16_rate(text, text_len, make_mame_time(0, 0));
1183   inputx_postn_utf16_rate(text, text_len, attotime_make(0, 0));
11841184}
11851185
11861186
11871187
1188void inputx_post_utf16_rate(const utf16_char *text, mame_time rate)
1188void inputx_post_utf16_rate(const utf16_char *text, attotime rate)
11891189{
11901190   size_t len = 0;
11911191   while(text[len])
r1293r1294
11971197
11981198void inputx_post_utf16(const utf16_char *text)
11991199{
1200   inputx_post_utf16_rate(text, make_mame_time(0, 0));
1200   inputx_post_utf16_rate(text, attotime_make(0, 0));
12011201}
12021202
12031203
12041204
1205void inputx_postn_utf8_rate(const char *text, size_t text_len, mame_time rate)
1205void inputx_postn_utf8_rate(const char *text, size_t text_len, attotime rate)
12061206{
12071207   size_t len = 0;
12081208   unicode_char buf[256];
r1293r1294
12341234
12351235void inputx_postn_utf8(const char *text, size_t text_len)
12361236{
1237   inputx_postn_utf8_rate(text, text_len, make_mame_time(0, 0));
1237   inputx_postn_utf8_rate(text, text_len, attotime_make(0, 0));
12381238}
12391239
12401240
12411241
1242void inputx_post_utf8_rate(const char *text, mame_time rate)
1242void inputx_post_utf8_rate(const char *text, attotime rate)
12431243{
12441244   inputx_postn_utf8_rate(text, strlen(text), rate);
12451245}
r1293r1294
12481248
12491249void inputx_post_utf8(const char *text)
12501250{
1251   inputx_post_utf8_rate(text, make_mame_time(0, 0));
1251   inputx_post_utf8_rate(text, attotime_make(0, 0));
12521252}
12531253
12541254
r1293r1294
12601260
12611261
12621262
1263void inputx_post_coded_rate(const char *text, mame_time rate)
1263void inputx_post_coded_rate(const char *text, attotime rate)
12641264{
12651265   inputx_postn_coded_rate(text, strlen(text), rate);
12661266}
r1293r1294
12691269
12701270void inputx_postn_coded(const char *text, size_t text_len)
12711271{
1272   inputx_postn_coded_rate(text, text_len, make_mame_time(0, 0));
1272   inputx_postn_coded_rate(text, text_len, attotime_make(0, 0));
12731273}
12741274
12751275
src/mess/inputx.h
r1293r1294
101101
102102/* various posting functions; can be called from FEs */
103103void inputx_post(const unicode_char *text);
104void inputx_post_rate(const unicode_char *text, mame_time rate);
104void inputx_post_rate(const unicode_char *text, attotime rate);
105105void inputx_postc(unicode_char ch);
106void inputx_postc_rate(unicode_char ch, mame_time rate);
106void inputx_postc_rate(unicode_char ch, attotime rate);
107107void inputx_postn(const unicode_char *text, size_t text_len);
108void inputx_postn_rate(const unicode_char *text, size_t text_len, mame_time rate);
108void inputx_postn_rate(const unicode_char *text, size_t text_len, attotime rate);
109109void inputx_post_utf16(const utf16_char *text);
110void inputx_post_utf16_rate(const utf16_char *text, mame_time rate);
110void inputx_post_utf16_rate(const utf16_char *text, attotime rate);
111111void inputx_postn_utf16(const utf16_char *text, size_t text_len);
112void inputx_postn_utf16_rate(const utf16_char *text, size_t text_len, mame_time rate);
112void inputx_postn_utf16_rate(const utf16_char *text, size_t text_len, attotime rate);
113113void inputx_post_utf8(const char *text);
114void inputx_post_utf8_rate(const char *text, mame_time rate);
114void inputx_post_utf8_rate(const char *text, attotime rate);
115115void inputx_postn_utf8(const char *text, size_t text_len);
116void inputx_postn_utf8_rate(const char *text, size_t text_len, mame_time rate);
116void inputx_postn_utf8_rate(const char *text, size_t text_len, attotime rate);
117117void inputx_post_coded(const char *text);
118void inputx_post_coded_rate(const char *text, mame_time rate);
118void inputx_post_coded_rate(const char *text, attotime rate);
119119void inputx_postn_coded(const char *text, size_t text_len);
120void inputx_postn_coded_rate(const char *text, size_t text_len, mame_time rate);
120void inputx_postn_coded_rate(const char *text, size_t text_len, attotime rate);
121121
122122/* miscellaneous functions */
123123int input_classify_port(const input_port_entry *in);
src/mess/machine/wswan.c
r1293r1294
259259
260260   /* Set up RTC timer */
261261   if ( rtc.present ) {
262      mame_timer_pulse( MAME_TIME_IN_SEC(1), 0, wswan_rtc_callback );
262      timer_pulse( ATTOTIME_IN_SEC(1), 0, wswan_rtc_callback );
263263   }
264264
265265}
src/mess/machine/zx.c
r1293r1294
7272{
7373   if ((offset & 2) == 0)
7474   {
75      mame_timer_reset(ula_nmi, time_never);
75      timer_reset(ula_nmi, attotime_never);
7676
7777      LOG_ZX81_IOW("ULA NMIs off");
7878   }
7979   else if ((offset & 1) == 0)
8080   {
81      mame_timer_adjust(ula_nmi, time_zero, 0, MAME_TIME_IN_CYCLES(207, 0));
81      timer_adjust(ula_nmi, attotime_zero, 0, ATTOTIME_IN_CYCLES(207, 0));
8282
8383      LOG_ZX81_IOW("ULA NMIs on");
8484
r1293r1294
145145         if ((cassette_input(image_from_devtype_and_index(IO_CASSETTE, 0)) < -0.75) && zx_tape_bit)
146146         {
147147            zx_tape_bit = 0x00;
148            mame_timer_set(MAME_TIME_IN_USEC(362), 0, zx_tape_pulse);
148            timer_set(ATTOTIME_IN_USEC(362), 0, zx_tape_pulse);
149149         }
150150
151151         data &= ~zx_tape_bit;
r1293r1294
209209         if ((cassette_input(image_from_devtype_and_index(IO_CASSETTE, 0)) < -0.75) && zx_tape_bit)
210210         {
211211            zx_tape_bit = 0x00;
212            mame_timer_set(MAME_TIME_IN_USEC(362), 0, zx_tape_pulse);
212            timer_set(ATTOTIME_IN_USEC(362), 0, zx_tape_pulse);
213213         }
214214
215215         data &= ~zx_tape_bit;
src/mess/machine/pdp1.c
r1293r1294
8888   int rby;      /* 1-bit reader binary mode flip-flop */
8989   int rcp;      /* 1-bit reader "need a completion pulse" flip-flop */
9090
91   mame_timer *timer;   /* timer to simulate reader timing */
91   emu_timer *timer;   /* timer to simulate reader timing */
9292} tape_reader_t;
9393
9494static tape_reader_t tape_reader;
r1293r1294
9999{
100100   mess_image *fd;   /* file descriptor of tape image */
101101
102   mame_timer *timer;   /* timer to generate completion pulses */
102   emu_timer *timer;   /* timer to generate completion pulses */
103103} tape_puncher_t;
104104
105105static tape_puncher_t tape_puncher;
r1293r1294
112112
113113   int tb;         /* typewriter buffer */
114114
115   mame_timer *tyo_timer;/* timer to generate completion pulses */
115   emu_timer *tyo_timer;/* timer to generate completion pulses */
116116} typewriter_t;
117117
118118static typewriter_t typewriter;
119119
120120
121121/* crt display timer */
122static mame_timer *dpy_timer;
122static emu_timer *dpy_timer;
123123
124124/* light pen config */
125125static lightpen_t lightpen;
r1293r1294
138138
139139   int dba;
140140
141   mame_timer *rotation_timer;   /* timer called each time dc is 0 */
142   mame_timer *il_timer;      /* timer called each time dc is il */
141   emu_timer *rotation_timer;   /* timer called each time dc is 0 */
142   emu_timer *il_timer;      /* timer called each time dc is il */
143143} parallel_drum_t;
144144
145145static parallel_drum_t parallel_drum;
146146
147#define PARALLEL_DRUM_WORD_TIME MAME_TIME_IN_NSEC(8500)
148#define PARALLEL_DRUM_ROTATION_TIME MAME_TIME_IN_NSEC(8500*4096)
147#define PARALLEL_DRUM_WORD_TIME ATTOTIME_IN_NSEC(8500)
148#define PARALLEL_DRUM_ROTATION_TIME ATTOTIME_IN_NSEC(8500*4096)
149149
150150
151151static OPBASE_HANDLER(setOPbasefunc)
r1293r1294
164164   pdp1_reset_param.hw_mul_div = (config >> pdp1_config_hw_mul_div_bit) & pdp1_config_hw_mul_div_mask;
165165   pdp1_reset_param.type_20_sbs = (config >> pdp1_config_type_20_sbs_bit) & pdp1_config_type_20_sbs_mask;
166166
167   tape_reader.timer = mame_timer_alloc(reader_callback);
168   tape_puncher.timer = mame_timer_alloc(puncher_callback);
169   typewriter.tyo_timer = mame_timer_alloc(tyo_callback);
170   dpy_timer = mame_timer_alloc(dpy_callback);
167   tape_reader.timer = timer_alloc(reader_callback);
168   tape_puncher.timer = timer_alloc(puncher_callback);
169   typewriter.tyo_timer = timer_alloc(tyo_callback);
170   dpy_timer = timer_alloc(dpy_callback);
171171
172172   /* reset device state */
173173   tape_reader.rcl = tape_reader.rc = 0;
r1293r1294
400400      /* restart reader IO when necessary */
401401      /* note that this function may be called before pdp1_init_machine, therefore
402402      before tape_reader.timer is allocated.  It does not matter, as the clutch is never
403      down at power-up, but we must not call mame_timer_enable with a NULL parameter! */
403      down at power-up, but we must not call timer_enable with a NULL parameter! */
404404      if (tape_reader.timer)
405405      {
406406         if (tape_reader.motor_on && tape_reader.rcl)
407407         {
408408            /* delay is approximately 1/400s */
409            mame_timer_adjust(tape_reader.timer, MAME_TIME_IN_USEC(2500), 0, time_zero);
409            timer_adjust(tape_reader.timer, ATTOTIME_IN_USEC(2500), 0, attotime_zero);
410410         }
411411         else
412412         {
413            mame_timer_enable(tape_reader.timer, 0);
413            timer_enable(tape_reader.timer, 0);
414414         }
415415      }
416416      break;
r1293r1294
438438      tape_reader.motor_on = 0;
439439
440440      if (tape_reader.timer)
441         mame_timer_enable(tape_reader.timer, 0);
441         timer_enable(tape_reader.timer, 0);
442442      break;
443443
444444   case 1:
r1293r1294
481481
482482   if (LOG_IOT_OVERLAP)
483483   {
484      if (mame_timer_enable(tape_reader.timer, 0))
484      if (timer_enable(tape_reader.timer, 0))
485485         logerror("Error: overlapped perforated tape reads (Read-in mode, RPA/RPB instruction)\n");
486486   }
487487   /* set up delay if tape is advancing */
488488   if (tape_reader.motor_on && tape_reader.rcl)
489489   {
490490      /* delay is approximately 1/400s */
491      mame_timer_adjust(tape_reader.timer, MAME_TIME_IN_USEC(2500), 0, time_zero);
491      timer_adjust(tape_reader.timer, ATTOTIME_IN_USEC(2500), 0, attotime_zero);
492492   }
493493   else
494494   {
495      mame_timer_enable(tape_reader.timer, 0);
495      timer_enable(tape_reader.timer, 0);
496496   }
497497}
498498
r1293r1294
541541
542542   if (tape_reader.motor_on && tape_reader.rcl)
543543      /* delay is approximately 1/400s */
544      mame_timer_adjust(tape_reader.timer, MAME_TIME_IN_USEC(2500), 0, time_zero);
544      timer_adjust(tape_reader.timer, ATTOTIME_IN_USEC(2500), 0, attotime_zero);
545545   else
546      mame_timer_enable(tape_reader.timer, 0);
546      timer_enable(tape_reader.timer, 0);
547547}
548548
549549/*
r1293r1294
675675   /* delay is approximately 1/63.3 second */
676676   if (LOG_IOT_OVERLAP)
677677   {
678      if (mame_timer_enable(tape_puncher.timer, 0))
678      if (timer_enable(tape_puncher.timer, 0))
679679         logerror("Error: overlapped PPA/PPB instructions: mb=0%06o, pc=0%06o\n", (unsigned) mb, (unsigned) cpunum_get_reg(0, PDP1_PC));
680680   }
681681
682   mame_timer_adjust(tape_puncher.timer, MAME_TIME_IN_USEC(15800), nac, time_zero);
682   timer_adjust(tape_puncher.timer, ATTOTIME_IN_USEC(15800), nac, attotime_zero);
683683}
684684
685685/*
r1293r1294
703703   /* delay is approximately 1/63.3 second */
704704   if (LOG_IOT_OVERLAP)
705705   {
706      if (mame_timer_enable(tape_puncher.timer, 0))
706      if (timer_enable(tape_puncher.timer, 0))
707707         logerror("Error: overlapped PPA/PPB instructions: mb=0%06o, pc=0%06o\n", (unsigned) mb, (unsigned) cpunum_get_reg(0, PDP1_PC));
708708   }
709   mame_timer_adjust(tape_puncher.timer, MAME_TIME_IN_USEC(15800), nac, time_zero);
709   timer_adjust(tape_puncher.timer, ATTOTIME_IN_USEC(15800), nac, attotime_zero);
710710}
711711
712712
r1293r1294
891891   }
892892   if (LOG_IOT_OVERLAP)
893893   {
894      if (mame_timer_enable(typewriter.tyo_timer, 0))
894      if (timer_enable(typewriter.tyo_timer, 0))
895895         logerror("Error: overlapped TYO instruction: mb=0%06o, pc=0%06o\n", (unsigned) mb, (unsigned) cpunum_get_reg(0, PDP1_PC));
896896   }
897897
898   mame_timer_adjust(typewriter.tyo_timer, MAME_TIME_IN_MSEC(delay), nac, time_zero);
898   timer_adjust(typewriter.tyo_timer, ATTOTIME_IN_MSEC(delay), nac, attotime_zero);
899899}
900900
901901/*
r1293r1294
10041004      {
10051005         /* note that overlap detection is incomplete: it will only work if both DPY
10061006         instructions require a completion pulse */
1007         if (mame_timer_enable(dpy_timer, 0))
1007         if (timer_enable(dpy_timer, 0))
10081008            logerror("Error: overlapped DPY instruction: mb=0%06o, pc=0%06o\n", (unsigned) mb, (unsigned) cpunum_get_reg(0, PDP1_PC));
10091009      }
1010      mame_timer_adjust(dpy_timer, MAME_TIME_IN_USEC(50), 0, time_zero);
1010      timer_adjust(dpy_timer, ATTOTIME_IN_USEC(50), 0, attotime_zero);
10111011   }
10121012}
10131013
r1293r1294
10191019
10201020static void parallel_drum_set_il(int il)
10211021{
1022   mame_time il_phase;
1022   attotime il_phase;
10231023
10241024   parallel_drum.il = il;
10251025
1026   il_phase = sub_mame_times(scale_up_mame_time(PARALLEL_DRUM_WORD_TIME, il), mame_timer_timeelapsed(parallel_drum.rotation_timer));
1027   if (compare_mame_times(il_phase, time_zero) < 0)
1028      il_phase = add_mame_times(il_phase, PARALLEL_DRUM_ROTATION_TIME);
1029   mame_timer_adjust(parallel_drum.il_timer, il_phase, 0, PARALLEL_DRUM_ROTATION_TIME);
1026   il_phase = attotime_sub(attotime_mul(PARALLEL_DRUM_WORD_TIME, il), timer_timeelapsed(parallel_drum.rotation_timer));
1027   if (attotime_compare(il_phase, attotime_zero) < 0)
1028      il_phase = attotime_add(il_phase, PARALLEL_DRUM_ROTATION_TIME);
1029   timer_adjust(parallel_drum.il_timer, il_phase, 0, PARALLEL_DRUM_ROTATION_TIME);
10301030}
10311031
10321032#ifdef UNUSED_FUNCTION
r1293r1294
10411041
10421042static void parallel_drum_init(void)
10431043{
1044   parallel_drum.rotation_timer = mame_timer_alloc(NULL);
1045   mame_timer_adjust(parallel_drum.rotation_timer, PARALLEL_DRUM_ROTATION_TIME, 0, PARALLEL_DRUM_ROTATION_TIME);
1044   parallel_drum.rotation_timer = timer_alloc(NULL);
1045   timer_adjust(parallel_drum.rotation_timer, PARALLEL_DRUM_ROTATION_TIME, 0, PARALLEL_DRUM_ROTATION_TIME);
10461046
1047   parallel_drum.il_timer = mame_timer_alloc(il_timer_callback);
1047   parallel_drum.il_timer = timer_alloc(il_timer_callback);
10481048   parallel_drum_set_il(0);
10491049}
10501050#endif
r1293r1294
11161116
11171117void iot_dcc(int op2, int nac, int mb, int *io, int ac)
11181118{
1119   mame_time delay;
1119   attotime delay;
11201120   int dc;
11211121
11221122   parallel_drum.rfb = ((*io) & 0370000) >> 12;
r1293r1294
11281128   /* clear status bit 5... */
11291129
11301130   /* do transfer */
1131   delay = mame_timer_timeleft(parallel_drum.il_timer);
1131   delay = timer_timeleft(parallel_drum.il_timer);
11321132   dc = parallel_drum.il;
11331133   do
11341134   {
r1293r1294
11461146      parallel_drum.wcl = (parallel_drum.wcl+1) & 0177777/*0007777???*/;
11471147      dc = (dc+1) & 07777;
11481148      if (parallel_drum.wc)
1149         delay = add_mame_times(delay, PARALLEL_DRUM_WORD_TIME);
1149         delay = attotime_add(delay, PARALLEL_DRUM_WORD_TIME);
11501150   } while (parallel_drum.wc);
1151   activecpu_adjust_icount(-MAME_TIME_TO_CYCLES(0, delay));
1151   activecpu_adjust_icount(-ATTOTIME_TO_CYCLES(0, delay));
11521152   /* if no error, skip */
11531153   cpunum_set_reg(0, PDP1_PC, cpunum_get_reg(0, PDP1_PC)+1);
11541154}
11551155
11561156void iot_dra(int op2, int nac, int mb, int *io, int ac)
11571157{
1158   (*io) = scale_up_mame_time(
1159      mame_timer_timeelapsed(parallel_drum.rotation_timer),
1160      MAX_SUBSECONDS / (PARALLEL_DRUM_WORD_TIME.subseconds)).seconds & 0007777;
1158   (*io) = attotime_mul(
1159      timer_timeelapsed(parallel_drum.rotation_timer),
1160      ATTOTIME_MAX_SECONDS / (attotime_to_attoseconds(PARALLEL_DRUM_WORD_TIME))).seconds & 0007777;
11611161
11621162   /* set parity error and timing error... */
11631163}
r1293r1294
12321232{
12331233   tape_reader.rcl = tape_reader.rc = 0;
12341234   if (tape_reader.timer)
1235      mame_timer_enable(tape_reader.timer, 0);
1235      timer_enable(tape_reader.timer, 0);
12361236
12371237   if (tape_puncher.timer)
1238      mame_timer_enable(tape_puncher.timer, 0);
1238      timer_enable(tape_puncher.timer, 0);
12391239
12401240   if (typewriter.tyo_timer)
1241      mame_timer_enable(typewriter.tyo_timer, 0);
1241      timer_enable(typewriter.tyo_timer, 0);
12421242
12431243   if (dpy_timer)
1244      mame_timer_enable(dpy_timer, 0);
1244      timer_enable(dpy_timer, 0);
12451245
12461246   io_status = io_st_tyo | io_st_ptp;
12471247}
src/mess/machine/nec765.c
r1293r1294
109109
110110   int command;
111111
112   mame_timer *seek_timer;
113   mame_timer *timer;
112   emu_timer *seek_timer;
113   emu_timer *timer;
114114   int timer_type;
115115
116   mame_timer *command_timer;
116   emu_timer *command_timer;
117117} NEC765;
118118
119119//static void nec765_setup_data_request(unsigned char Data);
r1293r1294
313313   /* seek complete */
314314   nec765_seek_complete();
315315
316   mame_timer_reset(fdc.seek_timer, time_never);
316   timer_reset(fdc.seek_timer, attotime_never);
317317}
318318
319319static TIMER_CALLBACK(nec765_timer_callback)
r1293r1294
329329      if (!(fdc.nec765_flags & NEC765_DMA_MODE))
330330      {
331331         /* for pcw */
332         mame_timer_reset(fdc.timer, MAME_TIME_IN_USEC(27));
332         timer_reset(fdc.timer, ATTOTIME_IN_USEC(27));
333333      }
334334      else
335335      {
r1293r1294
361361
362362      nec765_set_data_request();
363363
364      mame_timer_reset(fdc.timer, time_never);
364      timer_reset(fdc.timer, attotime_never);
365365   }
366366   else if (fdc.timer_type == 4)
367367   {
r1293r1294
380380         }
381381      }
382382
383      mame_timer_reset(fdc.timer, time_never);
383      timer_reset(fdc.timer, attotime_never);
384384   }
385385}
386386
r1293r1294
390390effectively disabled by reading the data before the NMI int can be set.
391391*/
392392
393static void nec765_setup_timed_generic(int timer_type, mame_time duration)
393static void nec765_setup_timed_generic(int timer_type, attotime duration)
394394{
395395   fdc.timer_type = timer_type;
396396
397397   if (!(fdc.nec765_flags & NEC765_DMA_MODE))
398398   {
399      mame_timer_adjust(fdc.timer, duration, 0, time_zero);     
399      timer_adjust(fdc.timer, duration, 0, attotime_zero);     
400400   }
401401   else
402402   {
403403      nec765_timer_callback(Machine, fdc.timer_type);
404      mame_timer_reset(fdc.timer, time_never);
404      timer_reset(fdc.timer, attotime_never);
405405   }
406406}
407407
r1293r1294
409409static void nec765_setup_timed_data_request(int bytes)
410410{
411411   /* setup timer to trigger in NEC765_DATA_RATE us */
412   nec765_setup_timed_generic(0, MAME_TIME_IN_USEC(32-27)   /*NEC765_DATA_RATE)*bytes*/);     
412   nec765_setup_timed_generic(0, ATTOTIME_IN_USEC(32-27)   /*NEC765_DATA_RATE)*bytes*/);     
413413}
414414
415415/* setup result data request */
416416static void nec765_setup_timed_result_data_request(void)
417417{
418   nec765_setup_timed_generic(2, MAME_TIME_IN_USEC(NEC765_DATA_RATE*2));
418   nec765_setup_timed_generic(2, ATTOTIME_IN_USEC(NEC765_DATA_RATE*2));
419419}
420420
421421
r1293r1294
423423static void nec765_setup_timed_int(int signed_tracks)
424424{
425425   /* setup timer to signal after seek time is complete */
426   mame_timer_adjust(fdc.seek_timer, time_zero, 0, double_to_mame_time(fdc.srt_in_ms*abs(signed_tracks)*0.001));
426   timer_adjust(fdc.seek_timer, attotime_zero, 0, double_to_attotime(fdc.srt_in_ms*abs(signed_tracks)*0.001));
427427}
428428
429429static void nec765_seek_setup(int is_recalibrate)
r1293r1294
673673   int i;
674674
675675   fdc.version = version;
676   fdc.timer = mame_timer_alloc(nec765_timer_callback);
677   fdc.seek_timer = mame_timer_alloc(nec765_seek_timer_callback);
678   fdc.command_timer = mame_timer_alloc(nec765_continue_command);
676   fdc.timer = timer_alloc(nec765_timer_callback);
677   fdc.seek_timer = timer_alloc(nec765_seek_timer_callback);
678   fdc.command_timer = timer_alloc(nec765_continue_command);
679679   memset(&nec765_iface, 0, sizeof(nec765_interface));
680680
681681   if (iface)
r1293r1294
719719         {
720720            if (fdc.timer_type==0)
721721            {
722               mame_timer_reset(fdc.timer, time_never);
722               timer_reset(fdc.timer, attotime_never);
723723
724724
725725            }
726726         }
727727
728728#ifdef NO_END_OF_CYLINDER
729         mame_timer_adjust(fdc.command_timer, time_zero, 0, time_zero);
729         timer_adjust(fdc.command_timer, attotime_zero, 0, attotime_zero);
730730#else
731731         nec765_update_state();
732732#endif
r1293r1294
15991599
16001600      if ((fdc.nec765_transfer_bytes_remaining==0) || (fdc.nec765_flags & NEC765_TC))
16011601      {
1602         mame_timer_adjust(fdc.command_timer, time_zero, 0, time_zero);
1602         timer_adjust(fdc.command_timer, attotime_zero, 0, attotime_zero);
16031603      }
16041604      else
16051605      {
r1293r1294
16671667
16681668      if ((fdc.nec765_transfer_bytes_remaining == 0) || (fdc.nec765_flags & NEC765_TC))
16691669      {
1670         mame_timer_adjust(fdc.command_timer, time_zero, 0, time_zero);
1670         timer_adjust(fdc.command_timer, attotime_zero, 0, attotime_zero);
16711671      }
16721672      else
16731673      {
src/mess/machine/pc1401.c
r1293r1294
3535
3636void pc1401_outc(int data)
3737{
38   logerror("%g outc %.2x\n", mame_time_to_double(mame_timer_get_time()), data);
38   logerror("%g outc %.2x\n", attotime_to_double(timer_get_time()), data);
3939   pc1401_portc=data;
4040}
4141
r1293r1294
292292#endif
293293   for (i=0; i<128; i++) gfx[i]=i;
294294
295   mame_timer_set(MAME_TIME_IN_SEC(1), 0, pc1401_power_up);
295   timer_set(ATTOTIME_IN_SEC(1), 0, pc1401_power_up);
296296
297297   if (RAM10K)
298298   {
src/mess/machine/apple2gs.c
r1293r1294
146146static INT8 apple2gs_mouse_dx;
147147static INT8 apple2gs_mouse_dy;
148148static mess_image *apple2gs_cur_slot6_image;
149static mame_timer *apple2gs_scanline_timer;
149static emu_timer *apple2gs_scanline_timer;
150150
151151
152152/* -----------------------------------------------------------------------
r1293r1294
178178   seconds_t current_interval;
179179
180180   /* update clock_curtime */
181   current_interval = mame_timer_get_time().seconds;
181   current_interval = timer_get_time().seconds;
182182   clock_curtime += current_interval - clock_curtime_interval;
183183   clock_curtime_interval = current_interval;
184184
r1293r1294
830830         apple2_interrupt();
831831   }
832832
833   mame_timer_adjust(apple2gs_scanline_timer, video_screen_get_time_until_pos(0, (scanline+1)%262, 0), 0, time_never);
833   timer_adjust(apple2gs_scanline_timer, video_screen_get_time_until_pos(0, (scanline+1)%262, 0), 0, attotime_never);
834834
835835   cpuintrf_pop_context();
836836}
r1293r1294
17171717
17181718MACHINE_RESET( apple2gs )
17191719{
1720   apple2gs_scanline_timer = mame_timer_alloc(apple2gs_scanline_tick);
1721   mame_timer_adjust(apple2gs_scanline_timer, time_never, 0, time_never);
1720   apple2gs_scanline_timer = timer_alloc(apple2gs_scanline_tick);
1721   timer_adjust(apple2gs_scanline_timer, attotime_never, 0, attotime_never);
17221722
17231723   // fire on scanline zero
1724   mame_timer_adjust(apple2gs_scanline_timer, video_screen_get_time_until_pos(0, 0, 0), 0, time_never);
1724   timer_adjust(apple2gs_scanline_timer, video_screen_get_time_until_pos(0, 0, 0), 0, attotime_never);
17251725}
17261726
17271727MACHINE_START( apple2gs )
src/mess/machine/applefdc.c
r1293r1294
8383};
8484
8585static int iwm_mode;      /* 0-31 */
86static mame_timer *motor_timer;
86static emu_timer *motor_timer;
8787static struct applefdc_interface iwm_intf;
8888
8989static TIMER_CALLBACK(iwm_turnmotor_onoff);
r1293r1294
101101{
102102   applefdc_lines = 0;
103103   iwm_mode = 0x1f;   /* default value needed by Lisa 2 - no, I don't know if it is true */
104   motor_timer = mame_timer_alloc(iwm_turnmotor_onoff);
104   motor_timer = timer_alloc(iwm_turnmotor_onoff);
105105   if (intf)
106106      iwm_intf = *intf;
107107   else
r1293r1294
308308   {
309309      case 0x08:
310310         /* Turn off motor */
311         mame_timer_adjust(motor_timer,
312            (iwm_mode & IWM_MODE_MOTOROFFDELAY) ? time_zero : MAME_TIME_IN_SEC(1),
311         timer_adjust(motor_timer,
312            (iwm_mode & IWM_MODE_MOTOROFFDELAY) ? attotime_zero : ATTOTIME_IN_SEC(1),
313313            0,
314            time_zero);
314            attotime_zero);
315315         break;
316316
317317      case 0x09:
318318         /* Turn on motor */
319         mame_timer_adjust(motor_timer, time_zero, 1, time_zero);
319         timer_adjust(motor_timer, attotime_zero, 1, attotime_zero);
320320         break;
321321
322322      case 0x0A:
src/mess/machine/hp48.c
r1293r1294
450450   hp48_card1=memory_region(REGION_CPU1)+0x140000;
451451   hp48_card2=memory_region(REGION_CPU1)+0x180000;
452452
453   mame_timer_pulse(MAME_TIME_IN_HZ(8192), 0, hp48_timer);
453   timer_pulse(ATTOTIME_IN_HZ(8192), 0, hp48_timer);
454454}
455455
456456DRIVER_INIT( hp48g )
r1293r1294
470470   hp48_card1=memory_region(REGION_CPU1)+0x140000;
471471   hp48_card2=memory_region(REGION_CPU1)+0x180000;
472472
473   mame_timer_pulse(MAME_TIME_IN_HZ(8192), 0, hp48_timer);
473   timer_pulse(ATTOTIME_IN_HZ(8192), 0, hp48_timer);
474474}
475475
476476MACHINE_RESET( hp48 )
src/mess/machine/uart8250.c
r1293r1294
1818
1919
2020#define LOG(LEVEL,N,M,A)  \
21if( M )logerror("%11.6f: %-24s",mame_timer_get_time(),(char*)M ); logerror A;
21if( M )logerror("%11.6f: %-24s",timer_get_time(),(char*)M ); logerror A;
2222
2323
2424//#define VERBOSE_COM 0
r1293r1294
316316      case 5:
317317
318318#if 0
319         if (uart[n].send.active && (mame_timer_get_time()-uart[n].send.time>uart_byte_time(n)))
319         if (uart[n].send.active && (timer_get_time()-uart[n].send.time>uart_byte_time(n)))
320320         {
321321            // currently polling is enough for pc1512
322322            uart[n].lsr |= 0x40; /* set TSRE */
src/mess/machine/dai.c
r1293r1294
137137   ppi8255_init(&dai_ppi82555_intf);
138138   pit8253_init(1, &dai_pit8253_intf);
139139
140   mame_timer_set(time_zero, 0, dai_bootstrap_callback);
140   timer_set(attotime_zero, 0, dai_bootstrap_callback);
141141}
142142
143143/***************************************************************************
src/mess/machine/c65.c
r1293r1294
294294
295295   UINT16 status;
296296
297   mame_time time;
297   attotime time;
298298   int head,track,sector;
299299} c65_fdc= { 0 };
300300
r1293r1294
311311{
312312   switch (c65_fdc.state) {
313313   case FDC_CMD_MOTOR_SPIN_UP:
314      if (mame_timer_get_time()-c65_fdc.time) {
314      if (timer_get_time()-c65_fdc.time) {
315315         c65_fdc.state=0;
316316         c65_fdc.status&=~FDC_BUSY;
317317      }
r1293r1294
333333      case 0x20: // wait for motor spin up
334334         c65_fdc.status&=~(FDC_IRQ|FDC_LOST|FDC_CRC|FDC_RNF);
335335         c65_fdc.status|=FDC_BUSY;
336         c65_fdc.time=mame_timer_get_time();
336         c65_fdc.time=timer_get_time();
337337         c65_fdc.state=FDC_CMD_MOTOR_SPIN_UP;
338338         break;
339339      case 0: // cancel
src/mess/machine/mac.c
r1293r1294
6565#endif
6666
6767static TIMER_CALLBACK(mac_scanline_tick);
68static mame_timer *mac_scanline_timer;
68static emu_timer *mac_scanline_timer;
6969static int scan_keyboard(void);
7070static TIMER_CALLBACK(inquiry_timeout_func);
7171static void keyboard_receive(int val);
r1293r1294
267267static int kbd_comm;
268268static int kbd_receive;
269269/* timer which is used to time out inquiry */
270static mame_timer *inquiry_timeout;
270static emu_timer *inquiry_timeout;
271271
272272static int kbd_shift_reg;
273273static int kbd_shift_count;
r1293r1294
445445   if (kbd_comm == TRUE)
446446   {
447447      kbd_shift_reg = data;
448      mame_timer_set(MAME_TIME_IN_MSEC(1), 0, kbd_clock);
448      timer_set(ATTOTIME_IN_MSEC(1), 0, kbd_clock);
449449   }
450450}
451451
r1293r1294
456456      /* Mac pulls CB2 down to initiate communication */
457457      kbd_comm = TRUE;
458458      kbd_receive = TRUE;
459      mame_timer_set(MAME_TIME_IN_USEC(100), 0, kbd_clock);
459      timer_set(ATTOTIME_IN_USEC(100), 0, kbd_clock);
460460   }
461461   if (kbd_comm == TRUE && kbd_receive == TRUE)
462462   {
r1293r1294
491491      if (keyboard_reply == 0x7B)
492492      {   
493493         /* if NULL, wait until key pressed or timeout */
494         mame_timer_adjust(inquiry_timeout,
495            make_mame_time(0, DOUBLE_TO_SUBSECONDS(0.25)),
496            0, time_zero);
494         timer_adjust(inquiry_timeout,
495            attotime_make(0, DOUBLE_TO_ATTOSECONDS(0.25)),
496            0, attotime_zero);
497497      }
498498      break;
499499
r1293r1294
13271327   mac_set_sound_buffer(0);
13281328
13291329   if (mac_model == MODEL_MAC_SE)
1330      mame_timer_set(time_zero, 0, set_memory_overlay_callback);
1330      timer_set(attotime_zero, 0, set_memory_overlay_callback);
13311331
1332   mac_scanline_timer = mame_timer_alloc(mac_scanline_tick);
1333   mame_timer_adjust(mac_scanline_timer, video_screen_get_time_until_pos(0, 0, 0), 0, time_never);
1332   mac_scanline_timer = timer_alloc(mac_scanline_tick);
1333   timer_adjust(mac_scanline_timer, video_screen_get_time_until_pos(0, 0, 0), 0, attotime_never);
13341334}
13351335
13361336
r1293r1294
13651365   /* setup keyboard */
13661366   keyboard_init();
13671367
1368   inquiry_timeout = mame_timer_alloc(inquiry_timeout_func);
1368   inquiry_timeout = timer_alloc(inquiry_timeout_func);
13691369
13701370   cpuintrf_set_dasm_override(0, mac_dasm_override);
13711371
r1293r1294
14351435
14361436         logerror("keyboard enquiry successful, keycode %X\n", keycode);
14371437
1438         mame_timer_reset(inquiry_timeout, time_never);
1438         timer_reset(inquiry_timeout, attotime_never);
14391439         kbd_shift_out(keycode);
14401440      }
14411441   }
r1293r1294
14741474   if (!(scanline % 10))
14751475      mouse_callback();
14761476
1477   mame_timer_adjust(mac_scanline_timer, video_screen_get_time_until_pos(0, (scanline+1) % MAC_V_TOTAL, 0), 0, time_never);
1477   timer_adjust(mac_scanline_timer, video_screen_get_time_until_pos(0, (scanline+1) % MAC_V_TOTAL, 0), 0, attotime_never);
14781478
14791479   cpuintrf_pop_context();
14801480}
src/mess/machine/pcf8593.c
r1293r1294
4545   int bits;
4646   UINT8 data_recv_index, data_recv[50];
4747   UINT8 mode, pos;
48   mame_timer *timer;
48   emu_timer *timer;
4949} PCF8593;
5050
5151static PCF8593 rtc;
r1293r1294
5656   memset( &rtc, 0, sizeof( rtc));
5757   rtc.size = 16;
5858   rtc.data = malloc( rtc.size);
59   rtc.timer = mame_timer_alloc( pcf8593_timer_callback );
60   mame_timer_adjust( rtc.timer, MAME_TIME_IN_SEC(1), 0, MAME_TIME_IN_SEC(1));
59   rtc.timer = timer_alloc( pcf8593_timer_callback );
60   timer_adjust( rtc.timer, ATTOTIME_IN_SEC(1), 0, ATTOTIME_IN_SEC(1));
6161   pcf8593_reset();
6262}
6363
src/mess/machine/cbmb.c
r1293r1294
240240   tpi6525[1].a.output=cbmb_keyboard_line_select_a;
241241   tpi6525[1].b.output=cbmb_keyboard_line_select_b;
242242   tpi6525[1].c.output=cbmb_keyboard_line_select_c;
243   mame_timer_pulse(MAME_TIME_IN_MSEC(10), 0, cbmb_frame_interrupt);
243   timer_pulse(ATTOTIME_IN_MSEC(10), 0, cbmb_frame_interrupt);
244244
245245   cbm500 = 0;
246246   cbm700 = 0;
src/mess/machine/i8271.c
r1293r1294
6161   {
6262      memcpy(&i8271.fdc_interface, iface, sizeof(i8271_interface));
6363   }
64   i8271.data_timer = mame_timer_alloc(i8271_data_timer_callback);
65   i8271.command_complete_timer = mame_timer_alloc(i8271_timed_command_complete_callback);
64   i8271.data_timer = timer_alloc(i8271_data_timer_callback);
65   i8271.command_complete_timer = timer_alloc(i8271_timed_command_complete_callback);
6666   i8271.drive = 0;
6767   i8271.pExecutionPhaseData = temp_buffer;
6868
r1293r1294
138138   i8271_data_request();
139139
140140   /* stop it */
141   mame_timer_reset(i8271.data_timer, time_never);
141   timer_reset(i8271.data_timer, attotime_never);
142142}
143143
144144/* setup a timed data request - data request will be triggered in a few usecs time */
r1293r1294
150150   usecs = 64;
151151
152152   /* set timers */
153   mame_timer_reset(i8271.command_complete_timer, time_never);
154   mame_timer_adjust(i8271.data_timer, MAME_TIME_IN_USEC(usecs), 0, time_zero);
153   timer_reset(i8271.command_complete_timer, attotime_never);
154   timer_adjust(i8271.data_timer, ATTOTIME_IN_USEC(usecs), 0, attotime_zero);
155155}
156156
157157
r1293r1294
160160   i8271_command_complete(1,1);
161161
162162   /* stop it, but don't allow it to be free'd */
163   mame_timer_reset(i8271.command_complete_timer, time_never);
163   timer_reset(i8271.command_complete_timer, attotime_never);
164164}
165165
166166/* setup a irq to occur 128us later - in reality this would be much later, because the int would
r1293r1294
174174   usecs = 64*2;
175175
176176   /* set timers */
177   mame_timer_reset(i8271.data_timer, time_never);
178   mame_timer_adjust(i8271.command_complete_timer, MAME_TIME_IN_USEC(usecs), 0, time_zero);
177   timer_reset(i8271.data_timer, attotime_never);
178   timer_adjust(i8271.command_complete_timer, ATTOTIME_IN_USEC(usecs), 0, attotime_zero);
179179}
180180
181181void i8271_reset()
r1293r1294
186186   i8271.ParameterCount = 0;
187187
188188   /* if timer is active remove */
189   mame_timer_reset(i8271.command_complete_timer, time_never);
190   mame_timer_reset(i8271.data_timer, time_never);
189   timer_reset(i8271.command_complete_timer, attotime_never);
190   timer_reset(i8271.data_timer, attotime_never);
191191
192192   /* clear irq */
193193   i8271_set_irq_state(0);
src/mess/machine/pc1350.c
r1293r1294
160160
161161MACHINE_START( pc1350 )
162162{
163   mame_timer_set(MAME_TIME_IN_SEC(1), 0, pc1350_power_up);
163   timer_set(ATTOTIME_IN_SEC(1), 0, pc1350_power_up);
164164
165165   memory_install_read8_handler(0,  ADDRESS_SPACE_PROGRAM, 0x6000, 0x6fff, 0, 0, MRA8_BANK1);
166166   memory_install_write8_handler(0, ADDRESS_SPACE_PROGRAM, 0x6000, 0x6fff, 0, 0, MWA8_BANK1);
src/mess/machine/pokemini.c
r1293r1294
1616struct TIMERS {
1717   UINT8      seconds_running;   /* Seconds timer running */
1818   UINT32      seconds_counter;   /* Seconds timer counter */
19   mame_timer   *seconds_timer;
19   emu_timer   *seconds_timer;
2020   UINT8      hz256_running;      /* 256Hz timer running */
2121   UINT8      hz256_counter;      /* 256Hz timer counter */
22   mame_timer   *hz256_timer;
22   emu_timer   *hz256_timer;
2323   UINT8      timers_enabled;      /* Timers 1 to 3 enabled */
2424   UINT16      timer1_counter;
25   mame_timer   *timer1_timer;      /* Timer 1 */
25   emu_timer   *timer1_timer;      /* Timer 1 */
2626   UINT16      timer2_counter;
27   mame_timer   *timer2_timer;      /* Timer 2 */
27   emu_timer   *timer2_timer;      /* Timer 2 */
2828   UINT16      timer3_counter;
29   mame_timer   *timer3_timer;      /* Timer 3 */
29   emu_timer   *timer3_timer;      /* Timer 3 */
3030};
3131
3232UINT8 pokemini_hwreg[0x100];
r1293r1294
9393   memset( &vdp, 0, sizeof(vdp) );
9494   memset( &timers, 0, sizeof(timers) );
9595   memset( pokemini_hwreg, 0, sizeof(pokemini_hwreg) );
96   timers.seconds_timer = mame_timer_alloc( pokemini_seconds_timer_callback );
97   timers.hz256_timer = mame_timer_alloc( pokemini_256hz_timer_callback );
98   timers.timer1_timer = mame_timer_alloc( pokemini_timer1_callback );
99   timers.timer2_timer = mame_timer_alloc( pokemini_timer2_callback );
100   timers.timer3_timer = mame_timer_alloc( pokemini_timer3_callback );
96   timers.seconds_timer = timer_alloc( pokemini_seconds_timer_callback );
97   timers.hz256_timer = timer_alloc( pokemini_256hz_timer_callback );
98   timers.timer1_timer = timer_alloc( pokemini_timer1_callback );
99   timers.timer2_timer = timer_alloc( pokemini_timer2_callback );
100   timers.timer3_timer = timer_alloc( pokemini_timer3_callback );
101101}
102102
103103WRITE8_HANDLER( pokemini_hwreg_w ) {
r1293r1294
123123         */
124124      if ( data & 0x01 ) {   /* enable timer */
125125         if ( ! timers.seconds_running ) {
126            mame_timer_adjust( timers.seconds_timer, MAME_TIME_IN_SEC(1), 0, time_zero );
126            timer_adjust( timers.seconds_timer, ATTOTIME_IN_SEC(1), 0, attotime_zero );
127127            timers.seconds_running = 1;
128128         }
129129      } else {      /* pause timer */
130130         if ( timers.seconds_running ) {
131            mame_timer_reset( timers.seconds_timer, time_never );
131            timer_reset( timers.seconds_timer, attotime_never );
132132            timers.seconds_running = 0;
133133         }
134134      }
r1293r1294
169169            Bit 4-7 R/W Unused
170170         */
171171      if ( ( data & 0x07 ) != ( pokemini_hwreg[0x18] & 0x07 ) ) {
172         mame_timer_adjust( timers.timer1_timer, MAME_TIME_IN_CYCLES( timer_to_cycles[data & 0x07], 0 ), 0, MAME_TIME_IN_CYCLES( timer_to_cycles[data & 0x07], 0 ) );
172         timer_adjust( timers.timer1_timer, ATTOTIME_IN_CYCLES( timer_to_cycles[data & 0x07], 0 ), 0, ATTOTIME_IN_CYCLES( timer_to_cycles[data & 0x07], 0 ) );
173173      }
174174      if ( ( data & 0x08 ) && timers.timers_enabled ) {
175         mame_timer_enable( timers.timer1_timer, 1 );
175         timer_enable( timers.timer1_timer, 1 );
176176      } else {
177         mame_timer_enable( timers.timer1_timer, 0 );
177         timer_enable( timers.timer1_timer, 0 );
178178      }
179179      break;
180180   case 0x19:   /* Timers 1 to 3 enabler
r1293r1294
187187      timers.timers_enabled = ( data & 0x20 ) ? 1 : 0;
188188      if ( timers.timers_enabled ) {
189189         if ( pokemini_hwreg[0x18] & 0x08 ) {
190            mame_timer_enable( timers.timer1_timer, 1 );
190            timer_enable( timers.timer1_timer, 1 );
191191         }
192192         if ( pokemini_hwreg[0x1A] & 0x08 ) {
193            mame_timer_enable( timers.timer2_timer, 1 );
193            timer_enable( timers.timer2_timer, 1 );
194194         }
195195         if ( pokemini_hwreg[0x1C] & 0x08 ) {
196            mame_timer_enable( timers.timer3_timer, 1 );
196            timer_enable( timers.timer3_timer, 1 );
197197         }
198198      } else {
199         mame_timer_enable( timers.timer1_timer, 0 );
200         mame_timer_enable( timers.timer2_timer, 0 );
201         mame_timer_enable( timers.timer3_timer, 0 );
199         timer_enable( timers.timer1_timer, 0 );
200         timer_enable( timers.timer2_timer, 0 );
201         timer_enable( timers.timer3_timer, 0 );
202202      }
203203      break;
204204   case 0x1A:   /* Timer 2 pre-scale + enable
r1293r1294
214214            Bit 4-7     Unused
215215         */
216216      if ( ( data & 0x07 ) != ( pokemini_hwreg[0x1A] & 0x07 ) ) {
217         mame_timer_adjust( timers.timer2_timer, MAME_TIME_IN_CYCLES( timer_to_cycles[data & 0x07], 0 ), 0, MAME_TIME_IN_CYCLES( timer_to_cycles[data & 0x07], 0 ) );
217         timer_adjust( timers.timer2_timer, ATTOTIME_IN_CYCLES( timer_to_cycles[data & 0x07], 0 ), 0, ATTOTIME_IN_CYCLES( timer_to_cycles[data & 0x07], 0 ) );
218218      }
219219      if ( ( data & 0x08 ) && timers.timers_enabled ) {
220         mame_timer_enable( timers.timer2_timer, 1 );
220         timer_enable( timers.timer2_timer, 1 );
221221      } else {
222         mame_timer_enable( timers.timer2_timer, 0 );
222         timer_enable( timers.timer2_timer, 0 );
223223      }
224224      break;
225225   case 0x1C:   /* Timer 3 pre-scale + enable
r1293r1294
235235            Bit 4-7     Unused
236236         */
237237      if ( ( data & 0x07 ) != ( pokemini_hwreg[0x1C] & 0x07 ) ) {
238         mame_timer_adjust( timers.timer3_timer, MAME_TIME_IN_CYCLES( timer_to_cycles[data & 0x07], 0 ), 0, MAME_TIME_IN_CYCLES( timer_to_cycles[data & 0x07], 0 ) );
238         timer_adjust( timers.timer3_timer, ATTOTIME_IN_CYCLES( timer_to_cycles[data & 0x07], 0 ), 0, ATTOTIME_IN_CYCLES( timer_to_cycles[data & 0x07], 0 ) );
239239      }
240240      if ( ( data & 0x08 ) && timers.timers_enabled ) {
241         mame_timer_enable( timers.timer3_timer, 1 );
241         timer_enable( timers.timer3_timer, 1 );
242242      } else {
243         mame_timer_enable( timers.timer3_timer, 0 );
243         timer_enable( timers.timer3_timer, 0 );
244244      }
245245      break;
246246   case 0x20:   /* Event #1-#8 primary enable
r1293r1294
412412         */
413413      if ( data & 0x01 ) {   /* enable timer */
414414         if ( ! timers.hz256_running ) {
415            mame_timer_adjust( timers.hz256_timer, MAME_TIME_IN_HZ(256), 0, time_zero );
415            timer_adjust( timers.hz256_timer, ATTOTIME_IN_HZ(256), 0, attotime_zero );
416416            timers.hz256_running = 1;
417417         }
418418      } else {      /* pause timer */
419419         if ( timers.hz256_running ) {
420            mame_timer_reset( timers.hz256_timer, time_never );
420            timer_reset( timers.hz256_timer, attotime_never );
421421            timers.hz256_running = 0;
422422         }
423423      }
src/mess/machine/rp5c15.c
r1293r1294
7171
7272struct rp5c15 rtc;
7373
74mame_timer* rtc_timer;
74emu_timer* rtc_timer;
7575
7676TIMER_CALLBACK(rtc_alarm_pulse)
7777{
r1293r1294
135135   rtc.test = 0x00;
136136   rtc.pulse_count = 0;
137137   
138   rtc_timer = mame_timer_alloc(rtc_alarm_pulse);
139   mame_timer_adjust(rtc_timer, time_zero, 0, MAME_TIME_IN_HZ(32));
138   rtc_timer = timer_alloc(rtc_alarm_pulse);
139   timer_adjust(rtc_timer, attotime_zero, 0, ATTOTIME_IN_HZ(32));
140140}
141141
142142int rp5c15_read(int offset, UINT16 mem_mask)
src/mess/machine/coco.c
r1293r1294
104104static UINT8 *coco_rom;
105105static int dclg_state, dclg_output_h, dclg_output_v, dclg_timer;
106106static UINT8 (*update_keyboard)(void);
107static mame_timer *update_keyboard_timer;
108static mame_timer *mux_sel1_timer;
109static mame_timer *mux_sel2_timer;
107static emu_timer *update_keyboard_timer;
108static emu_timer *mux_sel1_timer;
109static emu_timer *mux_sel2_timer;
110110static UINT8 mux_sel1, mux_sel2;
111111
112112static WRITE8_HANDLER ( d_pia1_pb_w );
r1293r1294
380380};
381381
382382static coco_cartridge *coco_cart;
383static mame_timer *cart_timer;
384static mame_timer *nmi_timer;
385static mame_timer *halt_timer;
383static emu_timer *cart_timer;
384static emu_timer *nmi_timer;
385static emu_timer *halt_timer;
386386
387387
388388
r1293r1294
875875{
876876   cpunum_set_input_line(0, INPUT_LINE_HALT, halt_line);
877877   if (halt_line == CLEAR_LINE)
878      mame_timer_set(MAME_TIME_IN_CYCLES(1,0), 0, recalc_interrupts);
878      timer_set(ATTOTIME_IN_CYCLES(1,0), 0, recalc_interrupts);
879879}
880880
881881
r1293r1294
982982***************************************************************************/
983983
984984static int coco_hiresjoy_ca = 1;
985static mame_time coco_hiresjoy_xtransitiontime;
986static mame_time coco_hiresjoy_ytransitiontime;
985static attotime coco_hiresjoy_xtransitiontime;
986static attotime coco_hiresjoy_ytransitiontime;
987987
988static mame_time coco_hiresjoy_computetransitiontime(const char *inputport)
988static attotime coco_hiresjoy_computetransitiontime(const char *inputport)
989989{
990990   double val;
991991
r1293r1294
10021002      val = val * 4160.0 + 592.0;
10031003   }
10041004
1005   return add_mame_times(mame_timer_get_time(), scale_up_mame_time(COCO_CPU_SPEED, val));
1005   return attotime_add(timer_get_time(), attotime_mul(COCO_CPU_SPEED, val));
10061006}
10071007
10081008static void coco_hiresjoy_w(int data)
r1293r1294
10161016   else if (data && !coco_hiresjoy_ca)
10171017   {
10181018      /* Lo to hi */
1019      coco_hiresjoy_ytransitiontime = time_zero;
1020      coco_hiresjoy_ytransitiontime = time_zero;
1019      coco_hiresjoy_ytransitiontime = attotime_zero;
1020      coco_hiresjoy_ytransitiontime = attotime_zero;
10211021   }
10221022   coco_hiresjoy_ca = data;
10231023   (*update_keyboard)();
10241024}
10251025
1026static int coco_hiresjoy_readone(mame_time transitiontime)
1026static int coco_hiresjoy_readone(attotime transitiontime)
10271027{
1028   return compare_mame_times(mame_timer_get_time(), transitiontime) >= 0;
1028   return attotime_compare(timer_get_time(), transitiontime) >= 0;
10291029}
10301030
10311031static int coco_hiresjoy_rx(void)
r1293r1294
11881188
11891189static WRITE8_HANDLER ( d_pia0_ca2_w )
11901190{
1191   mame_timer_adjust(mux_sel1_timer, MAME_TIME_IN_USEC(16), data, time_never);
1191   timer_adjust(mux_sel1_timer, ATTOTIME_IN_USEC(16), data, attotime_never);
11921192}
11931193
11941194static TIMER_CALLBACK(coco_update_sel1_timerproc)
r1293r1294
12001200
12011201static WRITE8_HANDLER ( d_pia0_cb2_w )
12021202{
1203   mame_timer_adjust(mux_sel2_timer, MAME_TIME_IN_USEC(16), data, time_never);
1203   timer_adjust(mux_sel2_timer, ATTOTIME_IN_USEC(16), data, attotime_never);
12041204}
12051205
12061206static TIMER_CALLBACK(coco_update_sel2_timerproc)
r1293r1294
12111211}
12121212
12131213
1214static mame_time get_relative_time(mame_time absolute_time)
1214static attotime get_relative_time(attotime absolute_time)
12151215{
1216   mame_time result;
1217   mame_time now = mame_timer_get_time();
1216   attotime result;
1217   attotime now = timer_get_time();
12181218
1219   if (compare_mame_times(absolute_time, now) > 0)
1220      result = sub_mame_times(absolute_time, now);
1219   if (attotime_compare(absolute_time, now) > 0)
1220      result = attotime_sub(absolute_time, now);
12211221   else
1222      result = time_never;
1222      result = attotime_never;
12231223   return result;
12241224}
12251225
r1293r1294
12311231   int joyval;
12321232   static const int joy_rat_table[] = {15, 24, 42, 33 };
12331233   static const int dclg_table[] = {0, 14, 30, 49 };
1234   mame_time dclg_time = time_zero;
1234   attotime dclg_time = attotime_zero;
12351235   UINT8 pia0_pb;
12361236   UINT8 dac = pia_get_output_a(1) & 0xFC;
12371237   int joystick_axis, joystick;
r1293r1294
13061306         break;
13071307   }
13081308   
1309   if( compare_mame_times(dclg_time, time_zero) )
1309   if( attotime_compare(dclg_time, attotime_zero) )
13101310   {
13111311      /* schedule lightgun events */
1312      mame_timer_reset(update_keyboard_timer, dclg_time );
1312      timer_reset(update_keyboard_timer, dclg_time );
13131313   }
13141314   else
13151315   {
13161316      /* schedule hires joystick events */
1317      mame_time xtrans = get_relative_time(coco_hiresjoy_xtransitiontime);
1318      mame_time ytrans = get_relative_time(coco_hiresjoy_ytransitiontime);
1317      attotime xtrans = get_relative_time(coco_hiresjoy_xtransitiontime);
1318      attotime ytrans = get_relative_time(coco_hiresjoy_ytransitiontime);
13191319
1320      mame_timer_reset(update_keyboard_timer,
1321         (compare_mame_times(xtrans, ytrans) > 0) ? ytrans : xtrans);
1320      timer_reset(update_keyboard_timer,
1321         (attotime_compare(xtrans, ytrans) > 0) ? ytrans : xtrans);
13221322   }
13231323
13241324   /* sample joystick buttons */
r1293r1294
20022002  FAQ agrees with this
20032003***************************************************************************/
20042004
2005static mame_timer *coco3_gime_timer;
2005static emu_timer *coco3_gime_timer;
20062006
20072007static void coco3_timer_reset(void)
20082008{
r1293r1294
20102010   UINT64 current_time;
20112011   UINT16 timer_value;
20122012   m6847_timing_type timing;
2013   mame_time target_time;
2013   attotime target_time;
20142014
20152015   /* value is from 0-4095 */
20162016   timer_value = ((coco3_gimereg[4] & 0x0F) * 0x100) | coco3_gimereg[5];
r1293r1294
20322032      /* calculate the time */
20332033      target_time = m6847_time_until(timing, current_time + timer_value);
20342034      if (LOG_TIMER)
2035         logerror("coco3_reset_timer(): target_time=%g\n", mame_time_to_double(target_time));
2035         logerror("coco3_reset_timer(): target_time=%g\n", attotime_to_double(target_time));
20362036
20372037      /* and adjust the timer */
2038      mame_timer_adjust(coco3_gime_timer, target_time, 0, time_zero);
2038      timer_adjust(coco3_gime_timer, target_time, 0, attotime_zero);
20392039   }
20402040   else
20412041   {
20422042      /* timer is shut off */
2043      mame_timer_reset(coco3_gime_timer, time_never);
2043      timer_reset(coco3_gime_timer, attotime_never);
20442044      if (LOG_TIMER)
20452045         logerror("coco3_reset_timer(): timer is off\n");
20462046   }
r1293r1294
20602060
20612061static void coco3_timer_init(void)
20622062{
2063   coco3_gime_timer = mame_timer_alloc(coco3_timer_proc);
2063   coco3_gime_timer = timer_alloc(coco3_timer_proc);
20642064}
20652065
20662066
r1293r1294
25732573
25742574   /* special code for Q state */
25752575   if ((data == 0x02) || (data == 0x03) || (data == 0x04))
2576      mame_timer_adjust(cart_timer, MAME_TIME_IN_USEC(0), data + 1, time_zero);
2576      timer_adjust(cart_timer, ATTOTIME_IN_USEC(0), data + 1, attotime_zero);
25772577}
25782578
25792579
r1293r1294
26272627   switch(line)
26282628   {
26292629      case COCOCART_LINE_CART:
2630         mame_timer_adjust(cart_timer, MAME_TIME_IN_USEC(0), (int) value, time_zero);
2630         timer_adjust(cart_timer, ATTOTIME_IN_USEC(0), (int) value, attotime_zero);
26312631         break;
26322632
26332633      case COCOCART_LINE_NMI:
2634         mame_timer_adjust(nmi_timer, MAME_TIME_IN_USEC(0), (int) value, time_zero);
2634         timer_adjust(nmi_timer, ATTOTIME_IN_USEC(0), (int) value, attotime_zero);
26352635         break;
26362636
26372637      case COCOCART_LINE_HALT:
2638         mame_timer_adjust(halt_timer, MAME_TIME_IN_CYCLES(7,0), (int) value, time_zero);
2638         timer_adjust(halt_timer, ATTOTIME_IN_CYCLES(7,0), (int) value, attotime_zero);
26392639         break;
26402640   }
26412641}
r1293r1294
26962696{
26972697   /* if the cartridge CART line is set to Q, trigger another round of pulses */
26982698   if ((coco_cart != NULL) && (cococart_get_line(coco_cart, COCOCART_LINE_CART) == COCOCART_LINE_VALUE_Q))
2699      mame_timer_adjust(cart_timer, MAME_TIME_IN_USEC(0), 0x02, time_zero);
2699      timer_adjust(cart_timer, ATTOTIME_IN_USEC(0), 0x02, attotime_zero);
27002700}
27012701
27022702
r1293r1294
27452745
27462746   /* clear static variables */
27472747   coco_hiresjoy_ca = 1;
2748   coco_hiresjoy_xtransitiontime = time_zero;
2749   coco_hiresjoy_ytransitiontime = time_zero;
2748   coco_hiresjoy_xtransitiontime = attotime_zero;
2749   coco_hiresjoy_ytransitiontime = attotime_zero;
27502750
27512751   /* set up function pointers */
27522752   update_keyboard = coco_update_keyboard;
27532753   recalc_interrupts = init->recalc_interrupts_;
27542754
27552755   /* this timer is used to schedule keyboard updating */
2756   update_keyboard_timer = mame_timer_alloc(coco_update_keyboard_timerproc);
2756   update_keyboard_timer = timer_alloc(coco_update_keyboard_timerproc);
27572757   
27582758   /* these are the timers to delay the MUX switching */
2759   mux_sel1_timer = mame_timer_alloc(coco_update_sel1_timerproc);
2760   mux_sel2_timer = mame_timer_alloc(coco_update_sel2_timerproc);
2759   mux_sel1_timer = timer_alloc(coco_update_sel1_timerproc);
2760   mux_sel2_timer = timer_alloc(coco_update_sel2_timerproc);
27612761
27622762   /* setup ROM */
27632763   coco_rom = memory_region(REGION_CPU1);
r1293r1294
27772777   pia_reset();
27782778
27792779   /* cartridge line timers */
2780   cart_timer = mame_timer_alloc(init->cart_timer_proc);
2781   nmi_timer = mame_timer_alloc(nmi_timer_proc);
2782   halt_timer = mame_timer_alloc(halt_timer_proc);
2780   cart_timer = timer_alloc(init->cart_timer_proc);
2781   nmi_timer = timer_alloc(nmi_timer_proc);
2782   halt_timer = timer_alloc(halt_timer_proc);
27832783
27842784   /* determine which cartridge hardware we should be using */
27852785   cart_image = cartslot_image();
src/mess/machine/amigacd.c
r1293r1294
6969   UINT32      wtc;      /* Word Transfer Count Register (RW) */
7070   UINT32      acr;      /* Address Count Register (RW) */
7171   UINT16      dawr;      /* DACK Width Register (W) */
72   mame_timer *dma_timer;
72   emu_timer *dma_timer;
7373} _dmac_data;
7474
7575static _dmac_data dmac_data;
r1293r1294
115115   if ( dmac_data.wtc > 0 )
116116   {
117117      matsucd_read_next_block();
118      mame_timer_adjust( dmac_data.dma_timer, MAME_TIME_IN_MSEC( CD_SECTOR_TIME ), 0, time_zero );
118      timer_adjust( dmac_data.dma_timer, ATTOTIME_IN_MSEC( CD_SECTOR_TIME ), 0, attotime_zero );
119119   }
120120   else
121121   {
r1293r1294
224224      case 0x70:   /* DMA start strobe */
225225      {
226226         LOG( "DMAC: PC=%08x - DMA Start Strobe\n", activecpu_get_pc() );
227         mame_timer_adjust( dmac_data.dma_timer, MAME_TIME_IN_MSEC( CD_SECTOR_TIME ), 0, time_zero );
227         timer_adjust( dmac_data.dma_timer, ATTOTIME_IN_MSEC( CD_SECTOR_TIME ), 0, attotime_zero );
228228      }
229229      break;
230230     
231231      case 0x71:   /* DMA stop strobe */
232232      {
233233         LOG( "DMAC: PC=%08x - DMA Stop Strobe\n", activecpu_get_pc() );
234         mame_timer_reset( dmac_data.dma_timer, time_never );
234         timer_reset( dmac_data.dma_timer, attotime_never );
235235      }
236236      break;
237237     
r1293r1294
350350      case 0x70:   /* DMA start strobe */
351351      {
352352         LOG( "DMAC: PC=%08x - DMA Start Strobe\n", activecpu_get_pc() );
353         mame_timer_adjust( dmac_data.dma_timer, MAME_TIME_IN_MSEC( CD_SECTOR_TIME ), 0, time_zero );
353         timer_adjust( dmac_data.dma_timer, ATTOTIME_IN_MSEC( CD_SECTOR_TIME ), 0, attotime_zero );
354354      }
355355      break;
356356     
357357      case 0x71:   /* DMA stop strobe */
358358      {
359359         LOG( "DMAC: PC=%08x - DMA Stop Strobe\n", activecpu_get_pc() );
360         mame_timer_reset( dmac_data.dma_timer, time_never );
360         timer_reset( dmac_data.dma_timer, attotime_never );
361361      }
362362      break;
363363     
r1293r1294
447447      matsucd_enable_w( data & 2 ); /* write to the /ENABLE signal */
448448}
449449
450static mame_timer *tp6525_delayed_timer;
450static emu_timer *tp6525_delayed_timer;
451451
452452static TIMER_CALLBACK(tp6525_delayed_irq)
453453{
r1293r1294
459459   }
460460   else
461461   {
462      mame_timer_adjust( tp6525_delayed_timer, MAME_TIME_IN_MSEC(1), 0, time_zero );
462      timer_adjust( tp6525_delayed_timer, ATTOTIME_IN_MSEC(1), 0, attotime_zero );
463463   }
464464}
465465
r1293r1294
476476      else
477477      {
478478         /* we *have to* deliver the irq, so if we can't, delay it and try again later */
479         mame_timer_adjust( tp6525_delayed_timer, MAME_TIME_IN_MSEC(1), 0, time_zero );
479         timer_adjust( tp6525_delayed_timer, ATTOTIME_IN_MSEC(1), 0, attotime_zero );
480480      }
481481   }
482482}
r1293r1294
507507   /* initialize the dmac */
508508   memset( &dmac_data, 0, sizeof( dmac_data ) );
509509   
510   dmac_data.dma_timer = mame_timer_alloc(dmac_dma_proc);
511   tp6525_delayed_timer = mame_timer_alloc(tp6525_delayed_irq);
510   dmac_data.dma_timer = timer_alloc(dmac_dma_proc);
511   tp6525_delayed_timer = timer_alloc(tp6525_delayed_irq);
512512   
513513   /* initialize the 6525 TPI */
514514   tpi6525_0_reset();
src/mess/machine/mc6854.c
r1293r1294
5252#define FLAG 0x7e
5353/* flag value, as defined by HDLC protocol: 01111110 */
5454
55#define BIT_LENGTH MAME_TIME_IN_HZ( 500000 )
55#define BIT_LENGTH ATTOTIME_IN_HZ( 500000 )
5656
5757
5858
r1293r1294
7575   UINT8  tstate;
7676   UINT16 tfifo[FIFO_SIZE];  /* X x 8-bit FIFO + full & last marker bits */
7777   UINT8  tones;             /* counter for zero-insertion */
78   mame_timer *ttimer;       /* when to ask for more data */
78   emu_timer *ttimer;       /* when to ask for more data */
7979
8080   /* receive state */
8181   UINT8  rstate;
r1293r1294
229229/* MC6854 fills bit queue */
230230static void mc6854_send_bits( UINT32 data, int len, int zi )
231231{
232   mame_time expire;
232   attotime expire;
233233   int i;
234234   if ( zi )
235235   {
r1293r1294
266266   }
267267
268268   /* schedule when to ask the MC6854 for more bits */
269   expire = mame_timer_timeleft( mc6854->ttimer );
270   if ( ! compare_mame_times( expire, time_never ) )
271      expire = time_zero;
272   mame_timer_reset( mc6854->ttimer, add_mame_times(expire, scale_up_mame_time(BIT_LENGTH, len)) );
269   expire = timer_timeleft( mc6854->ttimer );
270   if ( ! attotime_compare( expire, attotime_never ) )
271      expire = attotime_zero;
272   timer_reset( mc6854->ttimer, attotime_add(expire, attotime_mul(BIT_LENGTH, len)) );
273273}
274274
275275
r1293r1294
292292   if ( i >= 0 )
293293      mc6854->tfifo[ i ] = data | 0x100;
294294   else
295      logerror( "%f mc6854_tfifo_push: FIFO overrun\n", mame_time_to_double(mame_timer_get_time()) );
295      logerror( "%f mc6854_tfifo_push: FIFO overrun\n", attotime_to_double(timer_get_time()) );
296296
297297   /* start frame, if needed */
298298   if ( ! mc6854->tstate )
299299   {
300      LOG(( "%f mc6854_tfifo_push: start frame\n", mame_time_to_double(mame_timer_get_time()) ));
300      LOG(( "%f mc6854_tfifo_push: start frame\n", attotime_to_double(timer_get_time()) ));
301301      mc6854->tstate = 2;
302302      mc6854_send_bits( FLAG, 8, 0 );
303303   }
r1293r1294
347347      case 2: /* 8-bit address field */
348348         if ( ( data & 1 ) || ( ! AEX ) )
349349            mc6854->tstate = 3;
350         LOG(( "%f mc6854_tfifo_cb: address field $%02X\n", mame_time_to_double(mame_timer_get_time()), data & 0xff ));
350         LOG(( "%f mc6854_tfifo_cb: address field $%02X\n", attotime_to_double(timer_get_time()), data & 0xff ));
351351         break;
352352
353353      case 3: /* 8-bit control field */
r1293r1294
357357            mc6854->tstate = 5;
358358         else
359359            mc6854->tstate = 6;
360         LOG(( "%f mc6854_tfifo_cb: control field $%02X\n", mame_time_to_double(mame_timer_get_time()), data & 0xff ));
360         LOG(( "%f mc6854_tfifo_cb: control field $%02X\n", attotime_to_double(timer_get_time()), data & 0xff ));
361361         break;
362362     
363363      case 4: /* 8-bit extended control field (optional) */
r1293r1294
365365            mc6854->tstate = 5;
366366         else
367367            mc6854->tstate = 6;
368         LOG(( "%f mc6854_tfifo_cb: control field $%02X\n", mame_time_to_double(mame_timer_get_time()), data & 0xff ));
368         LOG(( "%f mc6854_tfifo_cb: control field $%02X\n", attotime_to_double(timer_get_time()), data & 0xff ));
369369         break;
370370     
371371      case 5: /* 8-bit logical control (optional) */
372372         if ( ! ( data & 0x80 ) )
373373            mc6854->tstate = 6;
374         LOG(( "%f mc6854_tfifo_cb: logical control field $%02X\n", mame_time_to_double(mame_timer_get_time()), data & 0xff ));
374         LOG(( "%f mc6854_tfifo_cb: logical control field $%02X\n", attotime_to_double(timer_get_time()), data & 0xff ));
375375         break;
376376     
377377      case 6: /* variable-length data */
378378         blen = TWL;
379         LOG(( "%f mc6854_tfifo_cb: data field $%02X, %i bits\n", mame_time_to_double(mame_timer_get_time()), data & 0xff, blen ));
379         LOG(( "%f mc6854_tfifo_cb: data field $%02X, %i bits\n", attotime_to_double(timer_get_time()), data & 0xff, blen ));
380380         break;
381381
382382      default:
383         LOG(( "%f mc6854_tfifo_cb: state=%i\n", mame_time_to_double(mame_timer_get_time()), mc6854->tstate));
383         LOG(( "%f mc6854_tfifo_cb: state=%i\n", attotime_to_double(timer_get_time()), mc6854->tstate));
384384      }
385385
386386      if ( mc6854->flen < MAX_FRAME_LENGTH )
r1293r1294
393393   else
394394   {
395395      /* data underrun => abort */
396      logerror( "%f mc6854_tfifo_cb: FIFO underrun\n", mame_time_to_double(mame_timer_get_time()) );
396      logerror( "%f mc6854_tfifo_cb: FIFO underrun\n", attotime_to_double(timer_get_time()) );
397397      mc6854->sr1 |= TU;
398398      mc6854->tstate = 0;
399399      mc6854_send_bits( 0xffff, ABTEX ? 16 : 8, 0 );
r1293r1294
405405   {
406406      int len = mc6854->flen;
407407
408      LOG(( "%f mc6854_tfifo_cb: end frame\n", mame_time_to_double(mame_timer_get_time()) ));
408      LOG(( "%f mc6854_tfifo_cb: end frame\n", attotime_to_double(timer_get_time()) ));
409409      mc6854_send_bits( 0xdeadbeef, 16, 1 );  /* send check-sum: TODO */
410410      mc6854_send_bits( FLAG, 8, 0 );         /* send closing flag */
411411   
412412      if ( mc6854->tfifo[ FIFO_SIZE - 1 ] & 0x100 )
413413      {
414414         /* re-open frame asap */
415         LOG(( "%f mc6854_tfifo_cb: start frame\n", mame_time_to_double(mame_timer_get_time()) ));
415         LOG(( "%f mc6854_tfifo_cb: start frame\n", attotime_to_double(timer_get_time()) ));
416416         if ( TWOINTER )
417417            mc6854_send_bits( FLAG, 8, 0 );
418418      }
r1293r1294
432432   memset( mc6854->tfifo, 0, sizeof( mc6854->tfifo ) );
433433   mc6854->tstate = 0;
434434   mc6854->flen = 0;
435   mame_timer_reset( mc6854->ttimer, time_never );
435   timer_reset( mc6854->ttimer, attotime_never );
436436}
437437
438438
r1293r1294
457457         mc6854->rstate = 3;
458458      else
459459         mc6854->rstate = 2;
460      LOG(( "%f mc6854_rfifo_push: address field $%02X\n", mame_time_to_double(mame_timer_get_time()), data ));
460      LOG(( "%f mc6854_rfifo_push: address field $%02X\n", attotime_to_double(timer_get_time()), data ));
461461      data |= 0x400; /* address marker */
462462      break;
463463
r1293r1294
468468         mc6854->rstate = 5;
469469      else
470470         mc6854->rstate = 6;
471      LOG(( "%f mc6854_rfifo_push: control field $%02X\n", mame_time_to_double(mame_timer_get_time()), data ));
471      LOG(( "%f mc6854_rfifo_push: control field $%02X\n", attotime_to_double(timer_get_time()), data ));
472472      break;
473473   
474474   case 4: /* 8-bit extended control field (optional) */
r1293r1294
476476         mc6854->rstate = 5;
477477      else
478478         mc6854->rstate = 6;
479      LOG(( "%f mc6854_rfifo_push: control field $%02X\n", mame_time_to_double(mame_timer_get_time()), data ));
479      LOG(( "%f mc6854_rfifo_push: control field $%02X\n", attotime_to_double(timer_get_time()), data ));
480480      break;
481481   
482482   case 5: /* 8-bit logical control (optional) */
483483      if ( ! ( data & 0x80 ) )
484484         mc6854->rstate = 6;
485      LOG(( "%f mc6854_rfifo_push: logical control field $%02X\n", mame_time_to_double(mame_timer_get_time()), data ));
485      LOG(( "%f mc6854_rfifo_push: logical control field $%02X\n", attotime_to_double(timer_get_time()), data ));
486486      break;
487487   
488488   case 6: /* variable-length data */
489489      blen = RWL;
490490      data >>= 8 - blen;
491      LOG(( "%f mc6854_rfifo_push: data field $%02X, %i bits\n", mame_time_to_double(mame_timer_get_time()), data, blen ));
491      LOG(( "%f mc6854_rfifo_push: data field $%02X, %i bits\n", attotime_to_double(timer_get_time()), data, blen ));
492492      break;
493493   }
494494
495495   /* no further FIFO fill until FV is cleared! */
496496   if ( mc6854->sr2 & FV )
497497   {
498      LOG(( "%f mc6854_rfifo_push: field not pushed\n", mame_time_to_double(mame_timer_get_time()) ));
498      LOG(( "%f mc6854_rfifo_push: field not pushed\n", attotime_to_double(timer_get_time()) ));
499499      return;
500500   }
501501
r1293r1294
515515      /* FIFO full */
516516      mc6854->sr2 |= OVRN;
517517      mc6854->rfifo[ 0 ] = data;
518      logerror( "%f mc6854_rfifo_push: FIFO overrun\n", mame_time_to_double(mame_timer_get_time()) );
518      logerror( "%f mc6854_rfifo_push: FIFO overrun\n", attotime_to_double(timer_get_time()) );
519519   }
520520
521521   mc6854->rsize -= blen;
r1293r1294
592592         {
593593            /* only in-frame abort */
594594            mc6854->sr2 |= RABT;
595            LOG(( "%f mc6854_receive_bit: abort\n", mame_time_to_double(mame_timer_get_time()) ));
595            LOG(( "%f mc6854_receive_bit: abort\n", attotime_to_double(timer_get_time()) ));
596596         }
597597      }
598598      else
r1293r1294
622622         if ( mc6854->rsize >= fieldlen + 24 ) /* last field */
623623            mc6854_rfifo_push( mc6854->rreg );
624624         mc6854_rfifo_terminate();
625         LOG(( "%f mc6854_receive_bit: end of frame\n", mame_time_to_double(mame_timer_get_time()) ));
625         LOG(( "%f mc6854_receive_bit: end of frame\n", attotime_to_double(timer_get_time()) ));
626626      }
627627      mc6854->rones = 0;
628628      mc6854->rstate = 1;
r1293r1294
783783   case 0: /* status register 1 */
784784      mc6854_update_sr1();
785785      LOG(( "%f $%04x mc6854_r: get SR1=$%02X (rda=%i,s2rq=%i,fd=%i,cts=%i,tu=%i,tdra=%i,irq=%i)\n",
786            mame_time_to_double(mame_timer_get_time()), activecpu_get_previouspc(), mc6854->sr1,
786            attotime_to_double(timer_get_time()), activecpu_get_previouspc(), mc6854->sr1,
787787            ( mc6854->sr1 & RDA) ? 1 : 0, ( mc6854->sr1 & S2RQ) ? 1 : 0,
788788            ( mc6854->sr1 & FD ) ? 1 : 0, ( mc6854->sr1 & CTS ) ? 1 : 0,
789789            ( mc6854->sr1 & TU ) ? 1 : 0, ( mc6854->sr1 & TDRA) ? 1 : 0,
r1293r1294
793793   case 1: /* status register 2 */
794794      mc6854_update_sr2();
795795      LOG(( "%f $%04x mc6854_r: get SR2=$%02X (ap=%i,fv=%i,ridle=%i,rabt=%i,err=%i,dcd=%i,ovrn=%i,rda2=%i)\n",
796            mame_time_to_double(mame_timer_get_time()), activecpu_get_previouspc(), mc6854->sr2,
796            attotime_to_double(timer_get_time()), activecpu_get_previouspc(), mc6854->sr2,
797797            ( mc6854->sr2 & AP   ) ? 1 : 0, ( mc6854->sr2 & FV  ) ? 1 : 0,
798798            ( mc6854->sr2 & RIDLE) ? 1 : 0, ( mc6854->sr2 & RABT) ? 1 : 0,
799799            ( mc6854->sr2 & ERR  ) ? 1 : 0, ( mc6854->sr2 & DCD ) ? 1 : 0,
r1293r1294
805805   {
806806      UINT8 data = mc6854_rfifo_pop();
807807      LOG(( "%f $%04x mc6854_r: get data $%02X\n",
808            mame_time_to_double(mame_timer_get_time()), activecpu_get_previouspc(), data ));
808            attotime_to_double(timer_get_time()), activecpu_get_previouspc(), data ));
809809      return data;
810810   }
811811
r1293r1294
825825   case 0: /* control register 1 */
826826      mc6854->cr1 = data;
827827      LOG(( "%f $%04x mc6854_w: set CR1=$%02X (ac=%i,irq=%c%c,%sreset=%c%c)\n",
828            mame_time_to_double(mame_timer_get_time()), activecpu_get_previouspc(), mc6854->cr1,
828            attotime_to_double(timer_get_time()), activecpu_get_previouspc(), mc6854->cr1,
829829            AC ? 1 : 0,
830830            RIE ? 'r' : '-', TIE ? 't' : '-',
831831            DISCONTINUE ? "discontinue," : "",
r1293r1294
862862         /* control register 3 */
863863         mc6854->cr3 = data;
864864         LOG(( "%f $%04x mc6854_w: set CR3=$%02X (lcf=%i,aex=%i,idl=%i,fdse=%i,loop=%i,tst=%i,dtr=%i)\n",
865               mame_time_to_double(mame_timer_get_time()), activecpu_get_previouspc(), mc6854->cr3,
865               attotime_to_double(timer_get_time()), activecpu_get_previouspc(), mc6854->cr3,
866866               LCF ? (CEX ? 16 : 8) : 0,  AEX ? 1 : 0,
867867               IDL0 ? 0 : 1, FDSE ? 1 : 0, LOOP ? 1 : 0,
868868               TST ? 1 : 0, DTR ? 1 : 0
r1293r1294
881881         /* control register 2 */
882882         mc6854->cr2 = data;
883883         LOG(( "%f $%04x mc6854_w: set CR2=$%02X (pse=%i,bytes=%i,fmidle=%i,%s,tlast=%i,clr=%c%c,rts=%i)\n",
884               mame_time_to_double(mame_timer_get_time()), activecpu_get_previouspc(), mc6854->cr2,
884               attotime_to_double(timer_get_time()), activecpu_get_previouspc(), mc6854->cr2,
885885               PSE ? 1 : 0,  TWOBYTES ? 2 : 1,  FMIDLE ? 1 : 0,
886886               FCTDRA ? "fc" : "tdra", TLAST ? 1 : 0,
887887               data & 0x20 ? 'r' : '-',  data & 0x40 ? 't' : '-',
r1293r1294
912912      break;
913913
914914   case 2: /* transmitter data: continue data */
915      LOG(( "%f $%04xmc6854_w: push data=$%02X\n", mame_time_to_double(mame_timer_get_time()), activecpu_get_previouspc(), data ));
915      LOG(( "%f $%04xmc6854_w: push data=$%02X\n", attotime_to_double(timer_get_time()), activecpu_get_previouspc(), data ));
916916      mc6854_tfifo_push( data );
917917      break;
918918
r1293r1294
921921      {
922922         /* control register 4 */
923923         mc6854->cr4 = data;
924         LOG(( "%f $%04x mc6854_w: set CR4=$%02X (interframe=%i,tlen=%i,rlen=%i,%s%s)\n", mame_time_to_double(mame_timer_get_time()), activecpu_get_previouspc(), mc6854->cr4,
924         LOG(( "%f $%04x mc6854_w: set CR4=$%02X (interframe=%i,tlen=%i,rlen=%i,%s%s)\n", attotime_to_double(timer_get_time()), activecpu_get_previouspc(), mc6854->cr4,
925925               TWOINTER ? 2 : 1,
926926               TWL, RWL,
927927               ABT ? ( ABTEX ? "abort-ext," : "abort,") : "",
r1293r1294
936936      else
937937      {
938938         /* transmitter data: last data */
939         LOG(( "%f $%04x mc6854_w: push last-data=$%02X\n", mame_time_to_double(mame_timer_get_time()), activecpu_get_previouspc(), data ));
939         LOG(( "%f $%04x mc6854_w: push last-data=$%02X\n", attotime_to_double(timer_get_time()), activecpu_get_previouspc(), data ));
940940         mc6854_tfifo_push( data );
941941         mc6854_tfifo_terminate();
942942      }
r1293r1294
980980   mc6854 = auto_malloc( sizeof( * mc6854 ) );
981981   assert( mc6854 );
982982   mc6854->iface = iface;
983   mc6854->ttimer = mame_timer_alloc( mc6854_tfifo_cb );
983   mc6854->ttimer = timer_alloc( mc6854_tfifo_cb );
984984   state_save_register_item( "mc6854", 0, mc6854->cr1 );
985985   state_save_register_item( "mc6854", 0, mc6854->cr2 );
986986   state_save_register_item( "mc6854", 0, mc6854->cr3 );
src/mess/machine/tc8521.c
r1293r1294
297297   memset(&rtc.interface, 0, sizeof(struct tc8521_interface));
298298   if (intf)
299299      memcpy(&rtc.interface, intf, sizeof(struct tc8521_interface));
300   mame_timer_pulse(MAME_TIME_IN_HZ(32), 0, tc8521_timer_callback);
300   timer_pulse(ATTOTIME_IN_HZ(32), 0, tc8521_timer_callback);
301301}
302302
303303 READ8_HANDLER(tc8521_r)
src/mess/machine/gb.c
r1293r1294
111111UINT8 gb_timer_shift;
112112/* Serial I/O related */
113113static UINT32 SIOCount;         /* Serial I/O counter                          */
114mame_timer   *gb_serial_timer = NULL;
114emu_timer   *gb_serial_timer = NULL;
115115
116116/*
117117  Prototypes
r1293r1294
233233   gb_sound_w( 0x16, 0x00 );       /* Initialize sound hardware */
234234
235235   /* Allocate the serial timer, and disable it */
236   gb_serial_timer = mame_timer_alloc( gb_serial_timer_proc );
237   mame_timer_enable( gb_serial_timer, 0 );
236   gb_serial_timer = timer_alloc( gb_serial_timer_proc );
237   timer_enable( gb_serial_timer, 0 );
238238
239239}
240240
r1293r1294
670670      case 0x81:            /* enabled & internal clock */
671671         SIODATA = 0xFF;
672672         SIOCount = 8;
673         mame_timer_adjust( gb_serial_timer, MAME_TIME_IN_CYCLES( 512, 0 ), 0, MAME_TIME_IN_CYCLES( 512, 0 ) );
674         mame_timer_enable( gb_serial_timer, 1 );
673         timer_adjust( gb_serial_timer, ATTOTIME_IN_CYCLES( 512, 0 ), 0, ATTOTIME_IN_CYCLES( 512, 0 ) );
674         timer_enable( gb_serial_timer, 1 );
675675         break;
676676      }
677677      break;
r1293r1294
17261726   /* If all bits done, stop timer and trigger interrupt */
17271727   if ( ! SIOCount ) {
17281728      SIOCONT &= 0x7F;
1729      mame_timer_enable( gb_serial_timer, 0 );
1729      timer_enable( gb_serial_timer, 0 );
17301730      cpunum_set_input_line(0, SIO_INT, HOLD_LINE);
17311731   }
17321732}
src/mess/machine/kim1.c
r1293r1294
2424   UINT8 irqen;   /* IRQ enabled ? */
2525   UINT8 state;   /* current timer state (bit 7) */
2626   double clock;   /* 100000/1(,8,64,1024) */
27   mame_timer *timer;   /* timer callback */
27   emu_timer *timer;   /* timer callback */
2828}
2929M6530;
3030
r1293r1294
598598
599599static void set_chip_clock(int chip, int data)
600600{
601   mame_timer_adjust(m6530[chip].timer, time_zero, chip, MAME_TIME_IN_HZ((data + 1) * m6530[chip].clock / 256 / 256));
601   timer_adjust(m6530[chip].timer, attotime_zero, chip, ATTOTIME_IN_HZ((data + 1) * m6530[chip].clock / 256 / 256));
602602}
603603
604604MACHINE_RESET( kim1 )
r1293r1294
624624   m6530[0].dria = 0xff;
625625   m6530[0].drib = 0xff;
626626   m6530[0].clock = (double) 1000000 / 1;
627   m6530[0].timer = mame_timer_alloc(m6530_timer_cb);
627   m6530[0].timer = timer_alloc(m6530_timer_cb);
628628   set_chip_clock(0, 255);
629629
630630   m6530[1].dria = 0xff;
631631   m6530[1].drib = 0xff;
632632   m6530[1].clock = (double) 1000000 / 1;
633   m6530[1].timer = mame_timer_alloc(m6530_timer_cb);
633   m6530[1].timer = timer_alloc(m6530_timer_cb);
634634   set_chip_clock(1, 255);
635635}
636636
r1293r1294
757757      break;
758758   case 0x04:
759759   case 0x0c:                     /* Timer count read (not supported?) */
760      data = scale_up_mame_time(mame_timer_timeleft(m6530[chip].timer), 256 * m6530[chip].clock).seconds;
760      data = attotime_mul(timer_timeleft(m6530[chip].timer), 256 * m6530[chip].clock).seconds;
761761      m6530[chip].irqen = (offset & 8) ? 1 : 0;
762762      logerror("m6530(%d) TIMR  read : $%02x%s\n", chip, data, (offset & 8) ? " (IRQ)" : "");
763763      break;
764764   case 0x05:
765765   case 0x0d:                     /* Timer count read (not supported?) */
766      data = scale_up_mame_time(mame_timer_timeleft(m6530[chip].timer), 256 * m6530[chip].clock).seconds;
766      data = attotime_mul(timer_timeleft(m6530[chip].timer), 256 * m6530[chip].clock).seconds;
767767      m6530[chip].irqen = (offset & 8) ? 1 : 0;
768768      logerror("m6530(%d) TIMR  read : $%02x%s\n", chip, data, (offset & 8) ? " (IRQ)" : "");
769769      break;
770770   case 0x06:
771771   case 0x0e:                     /* Timer count read */
772      data = scale_up_mame_time(mame_timer_timeleft(m6530[chip].timer), 256 * m6530[chip].clock).seconds;
772      data = attotime_mul(timer_timeleft(m6530[chip].timer), 256 * m6530[chip].clock).seconds;
773773      m6530[chip].irqen = (offset & 8) ? 1 : 0;
774774      logerror("m6530(%d) TIMR  read : $%02x%s\n", chip, data, (offset & 8) ? " (IRQ)" : "");
775775      break;
src/mess/machine/upd7002.c
r1293r1294
151151      if (uPD7002_status&0x08)
152152      {
153153         // 12 bit conversion takes 10ms
154         mame_timer_set(MAME_TIME_IN_MSEC(10), conversion_counter, uPD7002_conversioncomplete);
154         timer_set(ATTOTIME_IN_MSEC(10), conversion_counter, uPD7002_conversioncomplete);
155155      } else {
156156         // 8 bit conversion takes 4ms
157         mame_timer_set(MAME_TIME_IN_MSEC(4),  conversion_counter, uPD7002_conversioncomplete);
157         timer_set(ATTOTIME_IN_MSEC(4),  conversion_counter, uPD7002_conversioncomplete);
158158      }
159159      break;
160160
src/mess/machine/99_dsk.c
r1293r1294
370370
371371   DVENA = 0;
372372   motor_on = 0;
373   motor_on_timer = mame_timer_alloc(motor_on_timer_callback);
373   motor_on_timer = timer_alloc(motor_on_timer_callback);
374374
375375   ti99_peb_set_card_handlers(0x1100, & fdc_handlers);
376376
r1293r1294
484484      {   /* on rising edge, set DVENA for 4.23s */
485485         DVENA = 1;
486486         fdc_handle_hold();
487         mame_timer_adjust(motor_on_timer, MAME_TIME_IN_MSEC(4230), 0, time_zero);
487         timer_adjust(motor_on_timer, ATTOTIME_IN_MSEC(4230), 0, attotime_zero);
488488      }
489489      motor_on = data;
490490      break;
r1293r1294
635635
636636   DVENA = 0;
637637   motor_on = 0;
638   motor_on_timer = mame_timer_alloc(motor_on_timer_callback);
638   motor_on_timer = timer_alloc(motor_on_timer_callback);
639639
640640   ti99_peb_set_card_handlers(0x1100, & ccfdc_handlers);
641641
r1293r1294
696696      {   /* on rising edge, set DVENA for 4.23s */
697697         DVENA = 1;
698698         fdc_handle_hold();
699         mame_timer_adjust(motor_on_timer, MAME_TIME_IN_MSEC(4230), 0, time_zero);
699         timer_adjust(motor_on_timer, ATTOTIME_IN_MSEC(4230), 0, attotime_zero);
700700      }
701701      motor_on = data;
702702      break;
r1293r1294
854854
855855   DVENA = 0;
856856   motor_on = 0;
857   motor_on_timer = mame_timer_alloc(motor_on_timer_callback);
857   motor_on_timer = timer_alloc(motor_on_timer_callback);
858858
859859   ti99_peb_set_card_handlers(0x1100, & bwg_handlers);
860860
r1293r1294
917917      {   /* on rising edge, set DVENA for 4.23s */
918918         DVENA = 1;
919919         fdc_handle_hold();
920         mame_timer_adjust(motor_on_timer, MAME_TIME_IN_MSEC(4230), 0, time_zero);
920         timer_adjust(motor_on_timer, ATTOTIME_IN_MSEC(4230), 0, attotime_zero);
921921      }
922922      motor_on = data;
923923      break;
r1293r1294
12481248
12491249   DVENA = 0;
12501250   motor_on = 0;
1251   motor_on_timer = mame_timer_alloc(motor_on_timer_callback);
1251   motor_on_timer = timer_alloc(motor_on_timer_callback);
12521252
12531253   ti99_peb_set_card_handlers(0x1100, & hfdc_handlers);
12541254
r1293r1294
13311331      {
13321332         DVENA = 1;
13331333         fdc_handle_hold();
1334         mame_timer_adjust(motor_on_timer, MAME_TIME_IN_MSEC(4230), 0, time_zero);
1334         timer_adjust(motor_on_timer, ATTOTIME_IN_MSEC(4230), 0, attotime_zero);
13351335      }
13361336      motor_on = data;
13371337      break;
src/mess/machine/at29040.c
r1293r1294
6969   UINT8 toggle_bit;
7070   UINT8 programming_buffer[SECTOR_SIZE];
7171   int programming_last_offset;
72   mame_timer *programming_timer;
72   emu_timer *programming_timer;
7373} at29c040a[MAX_AT29C040A];
7474
7575
r1293r1294
9090      /* programming cycle start */
9191      at29c040a[id].s_pgm = s_pgm_3;
9292      /* max delay 10ms, typical delay 5 to 7 ms */
93      mame_timer_adjust(at29c040a[id].programming_timer, MAME_TIME_IN_MSEC(5), id, time_zero);
93      timer_adjust(at29c040a[id].programming_timer, ATTOTIME_IN_MSEC(5), id, attotime_zero);
9494      break;
9595
9696   case s_pgm_3:
r1293r1294
130130*/
131131void at29c040a_init(int id)
132132{
133   at29c040a[id].programming_timer = mame_timer_alloc(at29c040a_programming_timer_callback);
133   at29c040a[id].programming_timer = timer_alloc(at29c040a_programming_timer_callback);
134134}
135135
136136/*
r1293r1294
215215      at29c040a[id].s_pgm = s_pgm_0;
216216      at29c040a[id].s_enabling_sdb = FALSE;
217217      at29c040a[id].s_disabling_sdb = FALSE;
218      mame_timer_adjust(at29c040a[id].programming_timer, time_never, id, time_zero);
218      timer_adjust(at29c040a[id].programming_timer, attotime_never, id, attotime_zero);
219219   }
220220
221221
r1293r1294
250250      {   /* data polling starts the programming cycle (right???) */
251251         at29c040a[id].s_pgm = s_pgm_3;
252252         /* max delay 10ms, typical delay 5 to 7 ms */
253         mame_timer_adjust(at29c040a[id].programming_timer, MAME_TIME_IN_MSEC(5), id, time_zero);
253         timer_adjust(at29c040a[id].programming_timer, ATTOTIME_IN_MSEC(5), id, attotime_zero);
254254      }
255255
256256      reply = at29c040a[id].toggle_bit;
r1293r1294
318318         at29c040a[id].s_pgm = s_pgm_0;
319319         at29c040a[id].s_enabling_sdb = FALSE;
320320         at29c040a[id].s_disabling_sdb = FALSE;
321         mame_timer_adjust(at29c040a[id].programming_timer, time_never, id, time_zero);
321         timer_adjust(at29c040a[id].programming_timer, attotime_never, id, attotime_zero);
322322
323323         /* process command */
324324         switch (data)
r1293r1294
344344               at29c040a[id].s_pgm = s_pgm_1;
345345               at29c040a[id].s_disabling_sdb = TRUE;
346346               /* set command timeout (right???) */
347               //mame_timer_adjust(at29c040a[id].programming_timer, MAME_TIME_IN_USEC(150), id, 0.);
347               //timer_adjust(at29c040a[id].programming_timer, ATTOTIME_IN_USEC(150), id, 0.);
348348            }
349349            break;
350350
r1293r1294
364364            at29c040a[id].s_pgm = s_pgm_1;
365365            at29c040a[id].s_enabling_sdb = TRUE;
366366            /* set command timeout (right???) */
367            //mame_timer_adjust(at29c040a[id].programming_timer, MAME_TIME_IN_USEC(150), id, 0.);
367            //timer_adjust(at29c040a[id].programming_timer, ATTOTIME_IN_USEC(150), id, 0.);
368368            break;
369369
370370         case 0xf0:
r1293r1294
393393      at29c040a[id].s_pgm = s_pgm_0;
394394      at29c040a[id].s_enabling_sdb = FALSE;
395395      at29c040a[id].s_disabling_sdb = FALSE;
396      mame_timer_adjust(at29c040a[id].programming_timer, time_never, id, time_zero);
396      timer_adjust(at29c040a[id].programming_timer, attotime_never, id, attotime_zero);
397397   }
398398
399399   if (((at29c040a[id].s_pgm == s_pgm_0) && ! at29c040a[id].s_sdp)
r1293r1294
419419      /* write data to programming buffer */
420420      at29c040a[id].programming_buffer[offset & 0xff] = data;
421421      at29c040a[id].programming_last_offset = offset;
422      mame_timer_adjust(at29c040a[id].programming_timer, MAME_TIME_IN_USEC(150), id, time_zero);
422      timer_adjust(at29c040a[id].programming_timer, ATTOTIME_IN_USEC(150), id, attotime_zero);
423423   }
424424}
425425
src/mess/machine/gamecom.c
r1293r1294
5252UINT8 *cartridge = NULL;
5353UINT8 *dummy_bank = NULL;
5454
55static mame_timer *gamecom_clock_timer = NULL;
55static emu_timer *gamecom_clock_timer = NULL;
5656GAMECOM_DMA gamecom_dma;
5757GAMECOM_TIMER gamecom_timer[2];
5858
r1293r1294
7777
7878   /* should possibly go in a DRIVER_INIT piece? */
7979   if ( gamecom_clock_timer == NULL ) {
80      gamecom_clock_timer = mame_timer_alloc( gamecom_clock_timer_callback );
80      gamecom_clock_timer = timer_alloc( gamecom_clock_timer_callback );
8181   }
8282   /* intialize the empty dummy bank */
8383   if ( dummy_bank == NULL ) {
r1293r1294
327327         /* timer run */
328328         if ( data & 0x40 ) {
329329            /* timer resolution 1 minute */
330            mame_timer_adjust( gamecom_clock_timer, MAME_TIME_IN_SEC(1), 0, MAME_TIME_IN_SEC(60) );
330            timer_adjust( gamecom_clock_timer, ATTOTIME_IN_SEC(1), 0, ATTOTIME_IN_SEC(60) );
331331         } else {
332332            /* TImer resolution 1 second */
333            mame_timer_adjust( gamecom_clock_timer, MAME_TIME_IN_SEC(1), 0, MAME_TIME_IN_SEC(1) );
333            timer_adjust( gamecom_clock_timer, ATTOTIME_IN_SEC(1), 0, ATTOTIME_IN_SEC(1) );
334334         }
335335      } else {
336336         /* disable timer reset */
337         mame_timer_enable( gamecom_clock_timer, 0 );
337         timer_enable( gamecom_clock_timer, 0 );
338338         data &= 0xC0;
339339      }
340340      break;
src/mess/machine/mz700.c
r1293r1294
1919
2020#if VERBOSE
2121#define LOG(N,M,A)   \
22   if(VERBOSE>=N){ if( M )logerror("%11.6f: %-24s",mame_timer_get_time(), (const char*)M ); logerror A; }
22   if(VERBOSE>=N){ if( M )logerror("%11.6f: %-24s",timer_get_time(), (const char*)M ); logerror A; }
2323#else
2424#define LOG(N,M,A)
2525#endif
2626
2727typedef UINT32 data_t;
2828
29static mame_timer *ne556_timer[2] = {NULL,};     /* NE556 timer */
29static emu_timer *ne556_timer[2] = {NULL,};     /* NE556 timer */
3030static UINT8 ne556_out[2] = {0,};      /* NE556 current output status */
3131
3232static UINT8 mz700_motor_on = 0;   /* cassette motor key (play key) */
r1293r1294
8989
9090MACHINE_RESET(mz700)
9191{
92   ne556_timer[0] = mame_timer_alloc(ne556_callback);
93   mame_timer_adjust(ne556_timer[0], MAME_TIME_IN_HZ(1.5), 0, MAME_TIME_IN_HZ(1.5));
94   /*mame_timer_pulse(MAME_TIME_IN_HZ(1.5), 0, ne556_callback)*/
95   ne556_timer[1] = mame_timer_alloc(ne556_callback);
96   mame_timer_adjust(ne556_timer[1], MAME_TIME_IN_HZ(34.5), 1, MAME_TIME_IN_HZ(34.5));
97   /*mame_timer_pulse(MAME_TIME_IN_HZ(34.5), 1, ne556_callback)*/
92   ne556_timer[0] = timer_alloc(ne556_callback);
93   timer_adjust(ne556_timer[0], ATTOTIME_IN_HZ(1.5), 0, ATTOTIME_IN_HZ(1.5));
94   /*timer_pulse(ATTOTIME_IN_HZ(1.5), 0, ne556_callback)*/
95   ne556_timer[1] = timer_alloc(ne556_callback);
96   timer_adjust(ne556_timer[1], ATTOTIME_IN_HZ(34.5), 1, ATTOTIME_IN_HZ(34.5));
97   /*timer_pulse(ATTOTIME_IN_HZ(34.5), 1, ne556_callback)*/
9898}
9999
100100
r1293r1294
190190   LOG(2,"mz700_pio_port_b_w",("%02X\n", data));
191191
192192   /* enable/disable NE556 cursor flash timer */
193    mame_timer_enable(ne556_timer[0], (data & 0x80) ? 0 : 1);
193    timer_enable(ne556_timer[0], (data & 0x80) ? 0 : 1);
194194}
195195
196196static WRITE8_HANDLER ( pio_port_c_w )
src/mess/machine/ti990.c
r1293r1294
8484void ti990_hold_load(void)
8585{
8686   cpunum_set_input_line(0, INPUT_LINE_NMI, ASSERT_LINE);
87   mame_timer_set(MAME_TIME_IN_MSEC(100), 0, clear_load);
87   timer_set(ATTOTIME_IN_MSEC(100), 0, clear_load);
8888}
8989
9090/*
src/mess/machine/serial.c
r1293r1294
118118   serial_devices[id].data_form.word_length = num_data_bits;
119119   serial_devices[id].data_form.stop_bit_count = stop_bit_count;
120120   serial_devices[id].data_form.parity = parity_code;
121   serial_devices[id].timer = mame_timer_alloc(serial_device_baud_rate_callback);
121   serial_devices[id].timer = timer_alloc(serial_device_baud_rate_callback);
122122
123123   serial_connection_init(&serial_devices[id].connection);
124124   serial_connection_set_in_callback(&serial_devices[id].connection, serial_device_in_callback);
r1293r1294
205205      if (state)
206206      {
207207         /* start timer */
208         mame_timer_adjust(serial_devices[id].timer, time_zero, id, MAME_TIME_IN_HZ(serial_devices[id].BaudRate));
208         timer_adjust(serial_devices[id].timer, attotime_zero, id, ATTOTIME_IN_HZ(serial_devices[id].BaudRate));
209209      }
210210      else
211211      {
212212         /* remove timer */
213         mame_timer_reset(serial_devices[id].timer, time_never);
213         timer_reset(serial_devices[id].timer, attotime_never);
214214      }
215215   }
216216
src/mess/machine/vectrex.c
r1293r1294
2424UINT32 vectrex_beam_color = VC_WHITE;      /* the color of the vectrex beam */
2525int vectrex_imager_status = 0;      /* 0 = off, 1 = right eye, 2 = left eye */
2626double imager_freq;
27mame_timer *imager_timer;
27emu_timer *imager_timer;
2828int vectrex_lightpen_port=0;
2929UINT8 *vectrex_ram_base;
3030size_t vectrex_ram_size;
r1293r1294
238238   {
239239      vectrex_imager_status = param;
240240      coffset = param>1?3:0;
241      mame_timer_set (double_to_mame_time(rtime * vectrex_imager_angles[0]), imager_colors[coffset+2], vectrex_imager_change_color);
242      mame_timer_set (double_to_mame_time(rtime * vectrex_imager_angles[1]), imager_colors[coffset+1], vectrex_imager_change_color);
243      mame_timer_set (double_to_mame_time(rtime * vectrex_imager_angles[2]), imager_colors[coffset], vectrex_imager_change_color);
241      timer_set (double_to_attotime(rtime * vectrex_imager_angles[0]), imager_colors[coffset+2], vectrex_imager_change_color);
242      timer_set (double_to_attotime(rtime * vectrex_imager_angles[1]), imager_colors[coffset+1], vectrex_imager_change_color);
243      timer_set (double_to_attotime(rtime * vectrex_imager_angles[2]), imager_colors[coffset], vectrex_imager_change_color);
244244
245245      if (param == 2)
246246      {
247         mame_timer_set (double_to_mame_time(rtime * 0.50), 1, vectrex_imager_right_eye);
247         timer_set (double_to_attotime(rtime * 0.50), 1, vectrex_imager_right_eye);
248248
249249         /* Index hole sensor is connected to IO7 which triggers also CA1 of VIA */
250250         via_0_ca1_w (0, 1);
r1293r1294
269269   if (!mcontrol && mcontrol ^ state)
270270   {
271271      state = mcontrol;
272      tmp = mame_time_to_double(mame_timer_get_time());
272      tmp = attotime_to_double(timer_get_time());
273273      wavel = tmp - sl;
274274      sl = tmp;
275275
r1293r1294
286286
287287         if (imager_freq > 1)
288288         {
289            mame_timer_adjust (imager_timer,
290               double_to_mame_time(MIN(1.0/imager_freq, mame_time_to_double(mame_timer_timeleft(imager_timer)))),
289            timer_adjust (imager_timer,
290               double_to_attotime(MIN(1.0/imager_freq, attotime_to_double(timer_timeleft(imager_timer)))),
291291               2,
292               MAME_TIME_IN_HZ(imager_freq));
292               ATTOTIME_IN_HZ(imager_freq));
293293         }
294294      }
295295   }
296296   if (mcontrol && mcontrol ^ state)
297297   {
298298      state = mcontrol;
299      pwl = mame_time_to_double(mame_timer_get_time()) - sl;
299      pwl = attotime_to_double(timer_get_time()) - sl;
300300   }
301301}
302302
src/mess/machine/nes_mmc.c
r1293r1294
7878
7979static int mapper_warning;
8080
81static mame_timer   *nes_irq_timer;
81static emu_timer   *nes_irq_timer;
8282
8383static TIMER_CALLBACK(nes_irq_callback)
8484{
8585   cpunum_set_input_line (0, M6502_IRQ_LINE, HOLD_LINE);
86   mame_timer_adjust(nes_irq_timer, time_never, 0, time_never);
86   timer_adjust(nes_irq_timer, attotime_never, 0, attotime_never);
8787}
8888
8989WRITE8_HANDLER( nes_low_mapper_w )
r1293r1294
640640      {
641641         logerror("irq fired, scanline: %d (MAME %d, beam pos: %d)\n", scanline, video_screen_get_vpos(0), video_screen_get_hpos(0));
642642         cpunum_set_input_line (0, M6502_IRQ_LINE, HOLD_LINE);
643//         mame_timer_adjust(nes_irq_timer, MAME_TIME_IN_CYCLES(4, 0), 0, time_never);
643//         timer_adjust(nes_irq_timer, ATTOTIME_IN_CYCLES(4, 0), 0, attotime_never);
644644      }
645645   }
646646}
r1293r1294
42134213   ppu2c0x_set_hblank_callback (0, mapper ? mapper->mmc_hblank :  NULL);
42144214
42154215   if (!nes_irq_timer)
4216      nes_irq_timer = mame_timer_alloc(nes_irq_callback);
4216      nes_irq_timer = timer_alloc(nes_irq_callback);
42174217     
42184218   mapper_warning = 0;
42194219   /* 8k mask */
src/mess/machine/pclpt.c
r1293r1294
1010#include "memconv.h"
1111
1212#define LOG(LEVEL,N,M,A)  \
13if( M )logerror("%11.6f: %-24s",mame_time_to_double(mame_timer_get_time()),(char*)M ); logerror A;
13if( M )logerror("%11.6f: %-24s",attotime_to_double(timer_get_time()),(char*)M ); logerror A;
1414
1515
1616#define VERBOSE_LPT 1
src/mess/machine/pc_joy.c
r1293r1294
99#include "pc_joy.h"
1010#include "memconv.h"
1111
12static mame_time JOY_time;
12static attotime JOY_time;
1313
1414
1515READ8_HANDLER ( pc_JOY_r )
1616{
1717   UINT8 data = 0;
1818   int delta;
19   mame_time new_time = mame_timer_get_time();
19   attotime new_time = timer_get_time();
2020   int joystick_port = port_tag_to_index("pc_joy");
2121
2222   if (joystick_port >= 0)
r1293r1294
2424      data = readinputport(joystick_port + 0) ^ 0xf0;
2525
2626      /* timer overflow? */
27      if (compare_mame_times(sub_mame_times(new_time, JOY_time), MAME_TIME_IN_MSEC(10)) > 0)
27      if (attotime_compare(attotime_sub(new_time, JOY_time), ATTOTIME_IN_MSEC(10)) > 0)
2828      {
2929         /* do nothing */
3030      }
3131      else
3232      {
33         delta = scale_up_mame_time(sub_mame_times(new_time, JOY_time), 256 * 1000).seconds;
33         delta = attotime_mul(attotime_sub(new_time, JOY_time), 256 * 1000).seconds;
3434         if (readinputport(joystick_port + 1) < delta) data &= ~0x01;
3535         if (readinputport(joystick_port + 2) < delta) data &= ~0x02;
3636         if (readinputport(joystick_port + 3) < delta) data &= ~0x04;
r1293r1294
4444
4545WRITE8_HANDLER ( pc_JOY_w )
4646{
47   JOY_time = mame_timer_get_time();
47   JOY_time = timer_get_time();
4848}
4949
5050
src/mess/machine/vc1541.c
r1293r1294
579579         tme=vc1541_times[vc1541->frequency>>5]*8*2;
580580         if (vc1541->motor)
581581         {
582            if (mame_time_to_double(mame_timer_timeelapsed(vc1541->timer)) > 1.0e29)
583               mame_timer_reset(vc1541->timer, time_never);
582            if (attotime_to_double(timer_timeelapsed(vc1541->timer)) > 1.0e29)
583               timer_reset(vc1541->timer, attotime_never);
584584            else
585               mame_timer_adjust(vc1541->timer, time_zero, 0, double_to_mame_time(tme));
585               timer_adjust(vc1541->timer, attotime_zero, 0, double_to_attotime(tme));
586586         }
587587         else
588588         {
589            mame_timer_reset(vc1541->timer, time_never);
589            timer_reset(vc1541->timer, attotime_never);
590590         }
591591      }
592592      old=data;
r1293r1294
634634
635635   logerror("floppy image %s loaded\n", image_filename(image));
636636
637   vc1541->timer = mame_timer_alloc(vc1541_timer);
637   vc1541->timer = timer_alloc(vc1541_timer);
638638   return INIT_PASS;
639639}
640640
r1293r1294
642642{
643643   /* writeback of image data */
644644   vc1541->d64.data = NULL;
645   mame_timer_reset(vc1541->timer, time_never);   /* FIXME - timers should only be allocated once */
645   timer_reset(vc1541->timer, attotime_never);   /* FIXME - timers should only be allocated once */
646646}
647647
648648int vc1541_config (int id, int mode, VC1541_CONFIG *config)
r1293r1294
873873            tme=vc1541_times[vc1541->frequency>>5]*8*2;
874874            if (vc1541->motor)
875875            {
876               if (mame_time_to_double(mame_timer_timeelapsed(vc1541->timer)) > 1.0e29)
877                  mame_timer_reset(vc1541->timer, time_never);
876               if (attotime_to_double(timer_timeelapsed(vc1541->timer)) > 1.0e29)
877                  timer_reset(vc1541->timer, attotime_never);
878878               else
879                  mame_timer_adjust(vc1541->timer, time_zero, 0, double_to_mame_time(tme));
879                  timer_adjust(vc1541->timer, attotime_zero, 0, double_to_attotime(tme));
880880            }
881881            else
882882            {
883               mame_timer_reset(vc1541->timer, time_never);
883               timer_reset(vc1541->timer, attotime_never);
884884            }
885885         }
886886         old=data;
r1293r1294
956956
957957   /* time should be small enough to allow quitting of the irq
958958      line before the next interrupt is triggered */
959   vc1541->drive.c1551.timer = mame_timer_alloc(c1551_timer);
960   mame_timer_adjust(vc1541->drive.c1551.timer, time_zero, 0, MAME_TIME_IN_HZ(60));
959   vc1541->drive.c1551.timer = timer_alloc(c1551_timer);
960   timer_adjust(vc1541->drive.c1551.timer, attotime_zero, 0, ATTOTIME_IN_HZ(60));
961961   return 0;
962962}
963963
src/mess/machine/mc6846.c
r1293r1294
5858   UINT8  timer_started;
5959
6060   /* timers */
61   mame_timer *interval; /* interval programmable timer */
62   mame_timer *one_shot; /* 1-us x factor one-shot timer */
61   emu_timer *interval; /* interval programmable timer */
62   emu_timer *one_shot; /* 1-us x factor one-shot timer */
6363
6464} mc6846;
6565
r1293r1294
9292{
9393   if ( mc6846.timer_started )
9494   {
95      mame_time delay = mame_timer_timeleft( mc6846.interval );
96      return MAME_TIME_TO_CYCLES( mc6846.iface->cpunum, delay ) / FACTOR;
95      attotime delay = timer_timeleft( mc6846.interval );
96      return ATTOTIME_TO_CYCLES( mc6846.iface->cpunum, delay ) / FACTOR;
9797   }
9898   else
9999      return mc6846.preset;
r1293r1294
113113   if ( old_cif != cif )
114114   {
115115      LOG (( "%f: mc6846 interrupt %i (time=%i cp1=%i cp2=%i)\n",
116             mame_time_to_double(mame_timer_get_time()), cif,
116             attotime_to_double(timer_get_time()), cif,
117117             mc6846.csr & 1, (mc6846.csr >> 1 ) & 1, (mc6846.csr >> 2 ) & 1 ));
118118      old_cif = cif;
119119   }
r1293r1294
139139   static int old_cto;
140140   if ( cto != old_cto )
141141   {
142      LOG (( "%f: mc6846 CTO set to %i\n", mame_time_to_double(mame_timer_get_time()), cto ));
142      LOG (( "%f: mc6846 CTO set to %i\n", attotime_to_double(timer_get_time()), cto ));
143143      old_cto = cto;
144144   }
145145   if ( mc6846.iface->out_cto_func )
r1293r1294
151151INLINE void mc6846_timer_launch ( void )
152152{
153153   int delay = FACTOR * (mc6846.preset+1);
154   LOG (( "%f: mc6846 timer launch called, mode=%i, preset=%i (x%i)\n", mame_time_to_double(mame_timer_get_time()), MODE, mc6846.preset, FACTOR ));
154   LOG (( "%f: mc6846 timer launch called, mode=%i, preset=%i (x%i)\n", attotime_to_double(timer_get_time()), MODE, mc6846.preset, FACTOR ));
155155
156156   if ( ! (mc6846.tcr & 2) )
157157   {
r1293r1294
168168   
169169   case 0x20: /* single-shot */
170170      mc6846.cto = 0;
171      mame_timer_reset( mc6846.one_shot, MAME_TIME_IN_CYCLES( FACTOR, mc6846.iface->cpunum ) );
171      timer_reset( mc6846.one_shot, ATTOTIME_IN_CYCLES( FACTOR, mc6846.iface->cpunum ) );
172172      break;
173173   
174174   case 0x30:  /* cascaded single-shot */
r1293r1294
176176   
177177   default:
178178      logerror( "mc6846 timer mode %i not implemented\n", MODE );
179      mame_timer_reset( mc6846.interval, time_never );
179      timer_reset( mc6846.interval, attotime_never );
180180      mc6846.timer_started = 0;
181181      return;
182182   }
183183 
184   mame_timer_reset( mc6846.interval, MAME_TIME_IN_CYCLES( delay, mc6846.iface->cpunum ) );
184   timer_reset( mc6846.interval, ATTOTIME_IN_CYCLES( delay, mc6846.iface->cpunum ) );
185185   mc6846.timer_started = 1;
186186 
187187   mc6846.csr &= ~1;
r1293r1294
197197{
198198   int delay = FACTOR * (mc6846.latch+1);
199199
200   LOG (( "%f: mc6846 timer expire called, mode=%i, latch=%i (x%i)\n", mame_time_to_double(mame_timer_get_time()), MODE, mc6846.latch, FACTOR ));
200   LOG (( "%f: mc6846 timer expire called, mode=%i, latch=%i (x%i)\n", attotime_to_double(timer_get_time()), MODE, mc6846.latch, FACTOR ));
201201
202202   /* latch => counter */
203203   mc6846.preset = mc6846.latch;
r1293r1294
222222
223223   default:
224224      logerror( "mc6846 timer mode %i not implemented\n", MODE );
225      mame_timer_reset( mc6846.interval, time_never );
225      timer_reset( mc6846.interval, attotime_never );
226226      mc6846.timer_started = 0;
227227      return;
228228   }
229229
230   mame_timer_reset( mc6846.interval, MAME_TIME_IN_CYCLES( delay, mc6846.iface->cpunum ) );
230   timer_reset( mc6846.interval, ATTOTIME_IN_CYCLES( delay, mc6846.iface->cpunum ) );
231231
232232   mc6846.csr |= 1;
233233   mc6846_update_cto();
r1293r1294
238238
239239static TIMER_CALLBACK(mc6846_timer_one_shot)
240240{
241   LOG (( "%f: mc6846 timer one shot called\n", mame_time_to_double(mame_timer_get_time()) ));
241   LOG (( "%f: mc6846 timer one shot called\n", attotime_to_double(timer_get_time()) ));
242242
243243   /* 1 micro second after one-shot launch, we put cto to high */
244244   mc6846.cto = 1;
r1293r1294
258258   case 0:
259259   case 4:
260260      LOG (( "$%04x %f: mc6846 CSR read $%02X intr=%i (timer=%i, cp1=%i, cp2=%i)\n",
261             activecpu_get_previouspc(), mame_time_to_double(mame_timer_get_time()),
261             activecpu_get_previouspc(), attotime_to_double(timer_get_time()),
262262             mc6846.csr, (mc6846.csr >> 7) & 1,
263263             mc6846.csr & 1, (mc6846.csr >> 1) & 1, (mc6846.csr >> 2) & 1 ));
264264      mc6846.csr0_to_be_cleared = mc6846.csr & 1;
r1293r1294
267267      return mc6846.csr;
268268   
269269   case 1:
270      LOG (( "$%04x %f: mc6846 PCR read $%02X\n", activecpu_get_previouspc(), mame_time_to_double(mame_timer_get_time()), mc6846.pcr ));
270      LOG (( "$%04x %f: mc6846 PCR read $%02X\n", activecpu_get_previouspc(), attotime_to_double(timer_get_time()), mc6846.pcr ));
271271      return mc6846.pcr;
272272
273273   case 2:
274      LOG (( "$%04x %f: mc6846 DDR read $%02X\n", activecpu_get_previouspc(), mame_time_to_double(mame_timer_get_time()), mc6846.ddr ));
274      LOG (( "$%04x %f: mc6846 DDR read $%02X\n", activecpu_get_previouspc(), attotime_to_double(timer_get_time()), mc6846.ddr ));
275275      return mc6846.ddr;
276276
277277   case 3:
278      LOG (( "$%04x %f: mc6846 PORT read $%02X\n", activecpu_get_previouspc(), mame_time_to_double(mame_timer_get_time()), PORT ));
278      LOG (( "$%04x %f: mc6846 PORT read $%02X\n", activecpu_get_previouspc(), attotime_to_double(timer_get_time()), PORT ));
279279      if ( ! (mc6846.pcr & 0x80) )
280280      {
281281         if ( mc6846.csr1_to_be_cleared )
r1293r1294
289289      return PORT;
290290
291291   case 5:
292      LOG (( "$%04x %f: mc6846 TCR read $%02X\n",activecpu_get_previouspc(), mame_time_to_double(mame_timer_get_time()), mc6846.tcr ));
292      LOG (( "$%04x %f: mc6846 TCR read $%02X\n",activecpu_get_previouspc(), attotime_to_double(timer_get_time()), mc6846.tcr ));
293293      return mc6846.tcr;
294294
295295   case 6:
296      LOG (( "$%04x %f: mc6846 COUNTER hi read $%02X\n", activecpu_get_previouspc(), mame_time_to_double(mame_timer_get_time()), mc6846_counter() >> 8 ));
296      LOG (( "$%04x %f: mc6846 COUNTER hi read $%02X\n", activecpu_get_previouspc(), attotime_to_double(timer_get_time()), mc6846_counter() >> 8 ));
297297      if ( mc6846.csr0_to_be_cleared )
298298      {
299299         mc6846.csr &= ~1;
r1293r1294
303303      return mc6846_counter() >> 8;
304304
305305   case 7:
306      LOG (( "$%04x %f: mc6846 COUNTER low read $%02X\n", activecpu_get_previouspc(), mame_time_to_double(mame_timer_get_time()), mc6846_counter() & 0xff ));
306      LOG (( "$%04x %f: mc6846 COUNTER low read $%02X\n", activecpu_get_previouspc(), attotime_to_double(timer_get_time()), mc6846_counter() & 0xff ));
307307      if ( mc6846.csr0_to_be_cleared )
308308      {
309309         mc6846.csr &= ~1;
r1293r1294
343343         "latcged,pos-edge", "latcged,pos-edge,intr"
344344      };
345345      LOG (( "$%04x %f: mc6846 PCR write $%02X reset=%i cp2=%s cp1=%s\n",
346             activecpu_get_previouspc(), mame_time_to_double(mame_timer_get_time()), data,
346             activecpu_get_previouspc(), attotime_to_double(timer_get_time()), data,
347347             (data >> 7) & 1, cp2[ (data >> 3) & 7 ], cp1[ data & 7 ] ));
348348#endif
349349   }
r1293r1294
371371   break;
372372
373373   case 2:
374      LOG (( "$%04x %f: mc6846 DDR write $%02X\n", activecpu_get_previouspc(), mame_time_to_double(mame_timer_get_time()), data ));
374      LOG (( "$%04x %f: mc6846 DDR write $%02X\n", activecpu_get_previouspc(), attotime_to_double(timer_get_time()), data ));
375375      if ( ! (mc6846.pcr & 0x80) )
376376      {
377377         mc6846.ddr = data;
r1293r1294
381381      break;
382382     
383383   case 3:
384      LOG (( "$%04x %f: mc6846 PORT write $%02X (mask=$%02X)\n", activecpu_get_previouspc(), mame_time_to_double(mame_timer_get_time()), data,mc6846.ddr ));
384      LOG (( "$%04x %f: mc6846 PORT write $%02X (mask=$%02X)\n", activecpu_get_previouspc(), attotime_to_double(timer_get_time()), data,mc6846.ddr ));
385385      if ( ! (mc6846.pcr & 0x80) )
386386      {
387387         mc6846.pdr = data;
r1293r1294
390390         if ( mc6846.csr1_to_be_cleared && (mc6846.csr & 2) )
391391         {
392392            mc6846.csr &= ~2;
393            LOG (( "$%04x %f: mc6846 CP1 intr reset\n", activecpu_get_previouspc(), mame_time_to_double(mame_timer_get_time()) ));
393            LOG (( "$%04x %f: mc6846 CP1 intr reset\n", activecpu_get_previouspc(), attotime_to_double(timer_get_time()) ));
394394         }
395395         if ( mc6846.csr2_to_be_cleared && (mc6846.csr & 4) )
396396         {
397397            mc6846.csr &= ~4;
398            LOG (( "$%04x %f: mc6846 CP2 intr reset\n", activecpu_get_previouspc(), mame_time_to_double(mame_timer_get_time()) ));
398            LOG (( "$%04x %f: mc6846 CP2 intr reset\n", activecpu_get_previouspc(), attotime_to_double(timer_get_time()) ));
399399         }
400400         mc6846.csr1_to_be_cleared = 0;
401401         mc6846.csr2_to_be_cleared = 0;
r1293r1294
412412            "freq-cmp", "freq-cmp", "pulse-cmp", "pulse-cmp"
413413         };
414414      LOG (( "$%04x %f: mc6846 TCR write $%02X reset=%i clock=%s scale=%i mode=%s out=%s\n",
415             activecpu_get_previouspc(), mame_time_to_double(mame_timer_get_time()), data,
415             activecpu_get_previouspc(), attotime_to_double(timer_get_time()), data,
416416             (data >> 7) & 1, (data & 0x40) ? "extern" : "sys",
417417             (data & 0x40) ? 1 : 8, mode[ (data >> 1) & 7 ],
418418             (data & 1) ? "enabled" : "0" ));
r1293r1294
426426         if ( MODE != 0x30 )
427427            mc6846.cto = 0;
428428         mc6846_update_cto();
429         mame_timer_reset( mc6846.interval, time_never );
430         mame_timer_reset( mc6846.one_shot, time_never );
429         timer_reset( mc6846.interval, attotime_never );
430         timer_reset( mc6846.one_shot, attotime_never );
431431         mc6846.timer_started = 0;
432432      }
433433      else
r1293r1294
446446
447447   case 7:
448448      mc6846.latch = ( ((UINT16) mc6846.time_MSB) << 8 ) + data;
449      LOG (( "$%04x %f: mc6846 COUNT write %i\n", activecpu_get_previouspc(), mame_time_to_double(mame_timer_get_time()), mc6846.latch  ));
449      LOG (( "$%04x %f: mc6846 COUNT write %i\n", activecpu_get_previouspc(), attotime_to_double(timer_get_time()), mc6846.latch  ));
450450      if (!(mc6846.tcr & 0x38))
451451      {
452452         /* timer initialization */
r1293r1294
478478   if ( data == mc6846.cp1 )
479479      return;
480480   mc6846.cp1 = data;
481   LOG (( "%f: mc6846 input CP1 set to %i\n",  mame_time_to_double(mame_timer_get_time()), data ));
481   LOG (( "%f: mc6846 input CP1 set to %i\n",  attotime_to_double(timer_get_time()), data ));
482482   if (( data &&  (mc6846.pcr & 2)) || (!data && !(mc6846.pcr & 2)))
483483   {
484484      mc6846.csr |= 2;
r1293r1294
492492   if ( data == mc6846.cp2 )
493493      return;
494494   mc6846.cp2 = data;
495   LOG (( "%f: mc6846 input CP2 set to %i\n", mame_time_to_double(mame_timer_get_time()), data ));
495   LOG (( "%f: mc6846 input CP2 set to %i\n", attotime_to_double(timer_get_time()), data ));
496496   if (mc6846.pcr & 0x20)
497497   {
498498      if (( data &&  (mc6846.pcr & 0x10)) || (!data && !(mc6846.pcr & 0x10)))
r1293r1294
560560   mc6846.csr1_to_be_cleared = 0;
561561   mc6846.csr2_to_be_cleared = 0;
562562   mc6846.timer_started = 0;
563   mame_timer_reset( mc6846.interval, time_never );
564   mame_timer_reset( mc6846.one_shot, time_never );
563   timer_reset( mc6846.interval, attotime_never );
564   timer_reset( mc6846.one_shot, attotime_never );
565565}
566566
567567
r1293r1294
571571void mc6846_config ( const mc6846_interface* iface )
572572{
573573   mc6846.iface = iface;
574   mc6846.interval = mame_timer_alloc( mc6846_timer_expire );
575   mc6846.one_shot = mame_timer_alloc( mc6846_timer_one_shot );
574   mc6846.interval = timer_alloc( mc6846_timer_expire );
575   mc6846.one_shot = timer_alloc( mc6846_timer_one_shot );
576576 
577577   state_save_register_item( "mc6846", 0, mc6846.csr );
578578   state_save_register_item( "mc6846", 0, mc6846.pcr );
src/mess/machine/thomson.c
r1293r1294
7373
7474#if VERBOSE_IRQ
7575   if ( !old && thom_irq )
76      logerror( "%f thom_set_irq: irq line up %i\n", mame_time_to_double(mame_timer_get_time()), line );
76      logerror( "%f thom_set_irq: irq line up %i\n", attotime_to_double(timer_get_time()), line );
7777   if ( old && !thom_irq )
78      logerror( "%f thom_set_irq: irq line down %i\n", mame_time_to_double(mame_timer_get_time()), line );
78      logerror( "%f thom_set_irq: irq line down %i\n", attotime_to_double(timer_get_time()), line );
7979#endif
8080
8181   cpunum_set_input_line( 0, M6809_IRQ_LINE, thom_irq ? ASSERT_LINE : CLEAR_LINE );
r1293r1294
9797   
9898#if VERBOSE_IRQ
9999   if ( !old && thom_firq )
100      logerror( "%f thom_set_firq: firq line up %i\n", mame_time_to_double(mame_timer_get_time()), line );
100      logerror( "%f thom_set_firq: firq line up %i\n", attotime_to_double(timer_get_time()), line );
101101   if ( old && !thom_firq )
102      logerror( "%f thom_set_firq: firq line down %i\n", mame_time_to_double(mame_timer_get_time()), line );
102      logerror( "%f thom_set_firq: firq line down %i\n", attotime_to_double(timer_get_time()), line );
103103#endif
104104   
105105   cpunum_set_input_line( 0, M6809_FIRQ_LINE, thom_firq ? ASSERT_LINE : CLEAR_LINE );
r1293r1294
427427      return;
428428
429429#if VERBOSE_VIDEO
430   logerror( "%f to7_lightpen_cb: step=%i\n", mame_time_to_double(mame_timer_get_time()), step );
430   logerror( "%f to7_lightpen_cb: step=%i\n", attotime_to_double(timer_get_time()), step );
431431#endif
432432   
433433   pia_set_input_cb1( THOM_PIA_SYS, 1 );
r1293r1294
446446   /* INIT signal wired to system PIA 6821 */
447447
448448#if VERBOSE_VIDEO
449   logerror( "%f to7_set_init: init=%i\n", mame_time_to_double(mame_timer_get_time()), init );
449   logerror( "%f to7_set_init: init=%i\n", attotime_to_double(timer_get_time()), init );
450450#endif
451451
452452   pia_set_input_ca1( THOM_PIA_SYS, init );
r1293r1294
559559{
560560   /* acknowledge from centronics printer to PIA */
561561   int ack = (data & CENTRONICS_ACKNOWLEDGE) ? 1 : 0;
562   LOG (( "%f to7_io_ack: CENTRONICS new state $%02X (ack=%i)\n", mame_time_to_double(mame_timer_get_time()), data, ack ));
562   LOG (( "%f to7_io_ack: CENTRONICS new state $%02X (ack=%i)\n", attotime_to_double(timer_get_time()), data, ack ));
563563   pia_set_input_cb1( THOM_PIA_IO, ack );
564564}
565565
r1293r1294
571571   int dtr = ( data & 2 ) ? 1 : 0;
572572   
573573#if VERBOSE_IO
574   logerror( "$%04x %f to7_io_porta_out: tx=%i, dtr=%i\n",  activecpu_get_previouspc(), mame_time_to_double(mame_timer_get_time()), tx, dtr );
574   logerror( "$%04x %f to7_io_porta_out: tx=%i, dtr=%i\n",  activecpu_get_previouspc(), attotime_to_double(timer_get_time()), tx, dtr );
575575#endif
576576
577577   if ( dtr )
r1293r1294
597597      cts = ( centronics_read_handshake( 0 ) & CENTRONICS_NOT_BUSY ) ? 1 : 0;
598598 
599599#if VERBOSE_IO
600   logerror( "$%04x %f to7_io_porta_in: mode=%i cts=%i, dsr=%i, rd=%i\n", activecpu_get_previouspc(), mame_time_to_double(mame_timer_get_time()), to7_io_mode(), cts, dsr, rd );
600   logerror( "$%04x %f to7_io_porta_in: mode=%i cts=%i, dsr=%i, rd=%i\n", activecpu_get_previouspc(), attotime_to_double(timer_get_time()), to7_io_mode(), cts, dsr, rd );
601601#endif
602602   
603603   return (dsr ? 0x20 : 0) | (cts ? 0x40 : 0) | (rd ? 0x80: 0);
r1293r1294
610610   /* set 8-bit data */
611611
612612#if VERBOSE_IO     
613   logerror( "$%04x %f to7_io_portb_out: CENTRONICS set data=$%02X\n", activecpu_get_previouspc(), mame_time_to_double(mame_timer_get_time()), data );
613   logerror( "$%04x %f to7_io_portb_out: CENTRONICS set data=$%02X\n", activecpu_get_previouspc(), attotime_to_double(timer_get_time()), data );
614614#endif
615615
616616   centronics_write_data( 0, data );
r1293r1294
623623  /* send STROBE to printer */
624624
625625#if VERBOSE_IO     
626   logerror( "$%04x %f to7_io_cb2_out: CENTRONICS set strobe=%i\n", activecpu_get_previouspc(), mame_time_to_double(mame_timer_get_time()), data );
626   logerror( "$%04x %f to7_io_cb2_out: CENTRONICS set strobe=%i\n", activecpu_get_previouspc(), attotime_to_double(timer_get_time()), data );
627627#endif
628628
629629   centronics_write_handshake( 0, data ? CENTRONICS_STROBE : 0, CENTRONICS_STROBE );
r1293r1294
637637   to7_io_line.input_state = state;
638638
639639#if VERBOSE_IO
640   logerror( "%f to7_io_in_callback:  cts=%i dsr=%i rd=%i\n", mame_time_to_double(mame_timer_get_time()), (state & SERIAL_STATE_CTS) ? 1 : 0, (state & SERIAL_STATE_DSR) ? 1 : 0, (int)get_in_data_bit( state ) );
640   logerror( "%f to7_io_in_callback:  cts=%i dsr=%i rd=%i\n", attotime_to_double(timer_get_time()), (state & SERIAL_STATE_CTS) ? 1 : 0, (state & SERIAL_STATE_DSR) ? 1 : 0, (int)get_in_data_bit( state ) );
641641#endif
642642
643643}
r1293r1294
838838
839839
840840
841#define TO7_GAME_POLL_PERIOD  MAME_TIME_IN_USEC( 500 )
841#define TO7_GAME_POLL_PERIOD  ATTOTIME_IN_USEC( 500 )
842842
843843
844844
845845/* calls to7_game_update_cb periodically */
846static mame_timer* to7_game_timer;
846static emu_timer* to7_game_timer;
847847
848848static UINT8 to7_game_sound;
849849static UINT8 to7_game_mute;
r1293r1294
10081008{
10091009   LOG (( "to7_game_init called\n" ));
10101010   pia_config( THOM_PIA_GAME, &to7_game );
1011   to7_game_timer = mame_timer_alloc( to7_game_update_cb );
1012   mame_timer_adjust( to7_game_timer, TO7_GAME_POLL_PERIOD, 0, TO7_GAME_POLL_PERIOD );
1011   to7_game_timer = timer_alloc( to7_game_update_cb );
1012   timer_adjust( to7_game_timer, TO7_GAME_POLL_PERIOD, 0, TO7_GAME_POLL_PERIOD );
10131013   state_save_register_global( to7_game_sound );
10141014   state_save_register_global( to7_game_mute );
10151015}
r1293r1294
11161116      /* bit 7:     interrupt */
11171117#if VERBOSE_MIDI
11181118      logerror( "$%04x %f to7_midi_r: status $%02X (rdrf=%i, tdre=%i, ovrn=%i, irq=%i)\n",
1119           activecpu_get_previouspc(), mame_time_to_double(mame_timer_get_time()), to7_midi_status,
1119           activecpu_get_previouspc(), attotime_to_double(timer_get_time()), to7_midi_status,
11201120           (to7_midi_status & ACIA_6850_RDRF) ? 1 : 0,
11211121           (to7_midi_status & ACIA_6850_TDRE) ? 1 : 0,
11221122           (to7_midi_status & ACIA_6850_OVRN) ? 1 : 0,
r1293r1294
11361136      to7_midi_overrun = 0;
11371137#if VERBOSE_MIDI
11381138      logerror( "$%04x %f to7_midi_r: read data $%02X\n",
1139           activecpu_get_previouspc(), mame_time_to_double(mame_timer_get_time()), data );
1139           activecpu_get_previouspc(), attotime_to_double(timer_get_time()), data );
11401140#endif
11411141      to7_midi_update_irq();
11421142      return data;
r1293r1294
11651165      {
11661166         /* reset */
11671167#if VERBOSE_MIDI
1168         logerror( "$%04x %f to7_midi_w: reset (data=$%02X)\n", activecpu_get_previouspc(), mame_time_to_double(mame_timer_get_time()), data );
1168         logerror( "$%04x %f to7_midi_w: reset (data=$%02X)\n", activecpu_get_previouspc(), attotime_to_double(timer_get_time()), data );
11691169#endif
11701170         to7_midi_overrun = 0;
11711171         to7_midi_status = 2;
r1293r1294
11841184            static int stop[8] = { 2,2,1,1,2,1,1,1 };
11851185            static char parity[8] = { 'e','o','e','o','-','-','e','o' };
11861186            logerror( "$%04x %f to7_midi_w: set control to $%02X (bits=%i, stop=%i, parity=%c, intr in=%i out=%i)\n",
1187                 activecpu_get_previouspc(), mame_time_to_double(mame_timer_get_time()),
1187                 activecpu_get_previouspc(), attotime_to_double(timer_get_time()),
11881188                 data,
11891189                 bits[ (data >> 2) & 7 ],
11901190                 stop[ (data >> 2) & 7 ],
r1293r1294
12001200
12011201   case 1: /* output data */
12021202#if VERBOSE_MIDI
1203      logerror( "$%04x %f to7_midi_w: write data $%02X\n", activecpu_get_previouspc(), mame_time_to_double(mame_timer_get_time()), data );
1203      logerror( "$%04x %f to7_midi_w: write data $%02X\n", activecpu_get_previouspc(), attotime_to_double(timer_get_time()), data );
12041204#endif
12051205      if ( data == 0x55 )
12061206         /* cable-detect: shortcut */
r1293r1294
16281628
16291629
16301630
1631static mame_timer* mo5_periodic_timer;
1631static emu_timer* mo5_periodic_timer;
16321632
16331633
16341634
r1293r1294
16441644static void mo5_init_timer(void)
16451645{
16461646   /* time is a faster than 50 Hz to match video framerate */
1647   mame_timer_adjust( mo5_periodic_timer, time_zero, 0, MAME_TIME_IN_USEC( 19968 ) );
1647   timer_adjust( mo5_periodic_timer, attotime_zero, 0, ATTOTIME_IN_USEC( 19968 ) );
16481648}
16491649
16501650
r1293r1294
19301930   to7_modem_init();
19311931   to7_midi_init();
19321932   to7_rf57932_init();
1933   mo5_periodic_timer = mame_timer_alloc( mo5_periodic_cb );
1933   mo5_periodic_timer = timer_alloc( mo5_periodic_cb );
19341934   mea8000_config( THOM_SOUND_SPEECH, NULL );
19351935
19361936   /* memory */
r1293r1294
19691969
19701970WRITE8_HANDLER ( to9_ieee_w )
19711971{
1972   logerror( "$%04x %f to9_ieee_w: unhandled write $%02X to register %i\n", activecpu_get_previouspc(), mame_time_to_double(mame_timer_get_time()), data, offset );
1972   logerror( "$%04x %f to9_ieee_w: unhandled write $%02X to register %i\n", activecpu_get_previouspc(), attotime_to_double(timer_get_time()), data, offset );
19731973}
19741974
19751975
19761976
19771977READ8_HANDLER  ( to9_ieee_r )
19781978{
1979   logerror( "$%04x %f to9_ieee_r: unhandled read from register %i\n", activecpu_get_previouspc(), mame_time_to_double(mame_timer_get_time()), offset );
1979   logerror( "$%04x %f to9_ieee_r: unhandled read from register %i\n", activecpu_get_previouspc(), attotime_to_double(timer_get_time()), offset );
19801980   return 0;
19811981}
19821982
r1293r1294
21032103WRITE8_HANDLER ( to9_vreg_w )
21042104{
21052105#if VERBOSE_VIDEO
2106   logerror( "$%04x %f to9_vreg_w: off=%i ($%04X) data=$%02X\n", activecpu_get_previouspc(), mame_time_to_double(mame_timer_get_time()), offset, 0xe7da + offset, data );
2106   logerror( "$%04x %f to9_vreg_w: off=%i ($%04X) data=$%02X\n", activecpu_get_previouspc(), attotime_to_double(timer_get_time()), offset, 0xe7da + offset, data );
21072107#endif
21082108
21092109   switch ( offset )
r1293r1294
22972297
22982298
22992299/* normal mode: polling interval */
2300#define TO9_KBD_POLL_PERIOD  MAME_TIME_IN_MSEC( 10 )
2300#define TO9_KBD_POLL_PERIOD  ATTOTIME_IN_MSEC( 10 )
23012301
23022302/* peripherial mode: time between two bytes, and after last byte */
2303#define TO9_KBD_BYTE_SPACE   MAME_TIME_IN_USEC( 300 )
2304#define TO9_KBD_END_SPACE    MAME_TIME_IN_USEC( 9100 )
2303#define TO9_KBD_BYTE_SPACE   ATTOTIME_IN_USEC( 300 )
2304#define TO9_KBD_END_SPACE    ATTOTIME_IN_USEC( 9100 )
23052305
23062306/* first and subsequent repeat periods, in TO9_KBD_POLL_PERIOD units */
23072307#define TO9_KBD_REPEAT_DELAY  80 /* 800 ms */
r1293r1294
23252325static UINT8  to9_kbd_caps;  /* caps-lock */
23262326static UINT8  to9_kbd_pad;   /* keypad outputs special codes */
23272327
2328static mame_timer* to9_kbd_timer;
2328static emu_timer* to9_kbd_timer;
23292329
23302330
23312331
r1293r1294
23862386      /* bit 7:     interrupt */
23872387#if VERBOSE_KBD
23882388      logerror( "$%04x %f to9_kbd_r: status $%02X (rdrf=%i, tdre=%i, ovrn=%i, pe=%i, irq=%i)\n",
2389           activecpu_get_previouspc(), mame_time_to_double(mame_timer_get_time()), to9_kbd_status,
2389           activecpu_get_previouspc(), attotime_to_double(timer_get_time()), to9_kbd_status,
23902390           (to9_kbd_status & ACIA_6850_RDRF) ? 1 : 0,
23912391           (to9_kbd_status & ACIA_6850_TDRE) ? 1 : 0,
23922392           (to9_kbd_status & ACIA_6850_OVRN) ? 1 : 0,
r1293r1294
24032403         to9_kbd_status &= ~(ACIA_6850_OVRN | ACIA_6850_RDRF);
24042404      to9_kbd_overrun = 0;
24052405#if VERBOSE_KBD
2406      logerror( "$%04x %f to9_kbd_r: read data $%02X\n", activecpu_get_previouspc(), mame_time_to_double(mame_timer_get_time()), to9_kbd_in );
2406      logerror( "$%04x %f to9_kbd_r: read data $%02X\n", activecpu_get_previouspc(), attotime_to_double(timer_get_time()), to9_kbd_in );
24072407#endif
24082408      to9_kbd_update_irq();
24092409      return to9_kbd_in;
r1293r1294
24322432         to9_kbd_status = ACIA_6850_TDRE;
24332433         to9_kbd_intr = 0;
24342434#if VERBOSE_KBD
2435         logerror( "$%04x %f to9_kbd_w: reset (data=$%02X)\n", activecpu_get_previouspc(), mame_time_to_double(mame_timer_get_time()), data );
2435         logerror( "$%04x %f to9_kbd_w: reset (data=$%02X)\n", activecpu_get_previouspc(), attotime_to_double(timer_get_time()), data );
24362436#endif
24372437      }
24382438      else
r1293r1294
24472447         to9_kbd_intr = data >> 5;
24482448#if VERBOSE_KBD
24492449         logerror( "$%04x %f to9_kbd_w: set control to $%02X (parity=%i, intr in=%i out=%i)\n",
2450              activecpu_get_previouspc(), mame_time_to_double(mame_timer_get_time()),
2450              activecpu_get_previouspc(), attotime_to_double(timer_get_time()),
24512451              data, to9_kbd_parity, to9_kbd_intr >> 2,
24522452              (to9_kbd_intr & 3) ? 1 : 0 );
24532453#endif
r1293r1294
24792479      case 0xFE: to9_kbd_periph = 0; break;
24802480
24812481      default:
2482         logerror( "$%04x %f to9_kbd_w: unknown kbd command %02X\n", activecpu_get_previouspc(), mame_time_to_double(mame_timer_get_time()), data );
2482         logerror( "$%04x %f to9_kbd_w: unknown kbd command %02X\n", activecpu_get_previouspc(), attotime_to_double(timer_get_time()), data );
24832483      }
24842484
24852485      thom_set_caps_led( ! to9_kbd_caps );
24862486
24872487      LOG(( "$%04x %f to9_kbd_w: kbd command %02X (caps=%i, pad=%i, periph=%i)\n",
2488            activecpu_get_previouspc(), mame_time_to_double(mame_timer_get_time()), data,
2488            activecpu_get_previouspc(), attotime_to_double(timer_get_time()), data,
24892489            to9_kbd_caps, to9_kbd_pad, to9_kbd_periph ));
24902490
24912491      break;
r1293r1294
25082508      /* overrun will be set when the current valid byte is read */
25092509      to9_kbd_overrun = 1;
25102510#if VERBOSE_KBD
2511      logerror( "%f to9_kbd_send: overrun => drop data=$%02X, parity=%i\n", mame_time_to_double(mame_timer_get_time()), data, parity );
2511      logerror( "%f to9_kbd_send: overrun => drop data=$%02X, parity=%i\n", attotime_to_double(timer_get_time()), data, parity );
25122512#endif
25132513   }
25142514   else
r1293r1294
25212521      else
25222522         to9_kbd_status |= ACIA_6850_PE;  /* parity error */
25232523#if VERBOSE_KBD
2524      logerror( "%f to9_kbd_send: data=$%02X, parity=%i, status=$%02X\n", mame_time_to_double(mame_timer_get_time()), data, parity, to9_kbd_status );
2524      logerror( "%f to9_kbd_send: data=$%02X, parity=%i, status=$%02X\n", attotime_to_double(timer_get_time()), data, parity, to9_kbd_status );
25252525#endif
25262526   }
25272527   to9_kbd_update_irq();
r1293r1294
27012701      }
27022702
27032703      to9_kbd_byte_count = ( to9_kbd_byte_count + 1 ) & 3;
2704      mame_timer_adjust( to9_kbd_timer, to9_kbd_byte_count ? TO9_KBD_BYTE_SPACE : TO9_KBD_END_SPACE, 0, time_never );
2704      timer_adjust( to9_kbd_timer, to9_kbd_byte_count ? TO9_KBD_BYTE_SPACE : TO9_KBD_END_SPACE, 0, attotime_never );
27052705   }
27062706   else
27072707   {
r1293r1294
27092709      /* keyboard mode: send a byte only if a key is down */
27102710      if ( key )
27112711         to9_kbd_send( key, 0 );
2712      mame_timer_adjust( to9_kbd_timer, TO9_KBD_POLL_PERIOD, 0, time_never );
2712      timer_adjust( to9_kbd_timer, TO9_KBD_POLL_PERIOD, 0, attotime_never );
27132713   }
27142714}
27152715
r1293r1294
27292729   to9_kbd_key_count = 0;
27302730   to9_kbd_last_key = 0xff;
27312731   to9_kbd_update_irq();
2732   mame_timer_adjust( to9_kbd_timer, TO9_KBD_POLL_PERIOD, 0, time_never );
2732   timer_adjust( to9_kbd_timer, TO9_KBD_POLL_PERIOD, 0, attotime_never );
27332733}
27342734
27352735
r1293r1294
27372737static void to9_kbd_init ( void )
27382738{
27392739   LOG(( "to9_kbd_init called\n" ));
2740   to9_kbd_timer = mame_timer_alloc( to9_kbd_timer_cb );
2740   to9_kbd_timer = timer_alloc( to9_kbd_timer_cb );
27412741   state_save_register_global( to9_kbd_parity );
27422742   state_save_register_global( to9_kbd_intr );
27432743   state_save_register_global( to9_kbd_in );
r1293r1294
27702770
27712771#if VERBOSE_IO 
27722772   logerror( "$%04x %f to9_update_centronics: data=$%02X strobe=%i\n",
2773        activecpu_get_previouspc(), mame_time_to_double(mame_timer_get_time()), data,
2773        activecpu_get_previouspc(), attotime_to_double(timer_get_time()), data,
27742774        (b & 2) ? 1 : 0 );
27752775#endif
27762776}
r1293r1294
29592959
29602960
29612961/* polling interval */
2962#define TO8_KBD_POLL_PERIOD  MAME_TIME_IN_MSEC( 1 )
2962#define TO8_KBD_POLL_PERIOD  ATTOTIME_IN_MSEC( 1 )
29632963
29642964/* first and subsequent repeat periods, in TO8_KBD_POLL_PERIOD units */
29652965#define TO8_KBD_REPEAT_DELAY  800 /* 800 ms */
29662966#define TO8_KBD_REPEAT_PERIOD  70 /*  70 ms */
29672967
29682968/* timeout waiting for CPU */
2969#define TO8_KBD_TIMEOUT  MAME_TIME_IN_MSEC( 100 )
2969#define TO8_KBD_TIMEOUT  ATTOTIME_IN_MSEC( 100 )
29702970
29712971
29722972
r1293r1294
29782978static UINT32 to8_kbd_key_count; /* keypress time (for repetition)  */
29792979static UINT8  to8_kbd_caps;      /* caps lock */
29802980
2981static mame_timer* to8_kbd_timer;   /* bit-send */
2982static mame_timer* to8_kbd_signal;  /* signal from CPU */
2981static emu_timer* to8_kbd_timer;   /* bit-send */
2982static emu_timer* to8_kbd_signal;  /* signal from CPU */
29832983
29842984
29852985
r1293r1294
30833083/* keyboard automaton */
30843084static TIMER_CALLBACK(to8_kbd_timer_cb)
30853085{
3086   mame_time d;
3086   attotime d;
30873087
30883088#if VERBOSE_KBD
3089   logerror( "%f to8_kbd_timer_cb: step=%i ack=%i data=$%03X\n", mame_time_to_double(mame_timer_get_time()), to8_kbd_step, to8_kbd_ack, to8_kbd_data );
3089   logerror( "%f to8_kbd_timer_cb: step=%i ack=%i data=$%03X\n", attotime_to_double(timer_get_time()), to8_kbd_step, to8_kbd_ack, to8_kbd_data );
30903090#endif
30913091
30923092   if( ! to8_kbd_step )
r1293r1294
31103110#endif
31113111         to8_kbd_data = k;
31123112         to8_kbd_step = 1;
3113         d = MAME_TIME_IN_USEC( 100 );
3113         d = ATTOTIME_IN_USEC( 100 );
31143114      }
31153115   }
31163116   else if ( to8_kbd_step == 255 )
r1293r1294
31403140   {
31413141      /* send silence between bits */
31423142      mc6846_set_input_cp1( 0 );
3143      d = MAME_TIME_IN_USEC( 100 );
3143      d = ATTOTIME_IN_USEC( 100 );
31443144      to8_kbd_step++;
31453145   }
31463146   else
r1293r1294
31493149      int bpos = 8 - ( (to8_kbd_step - 100) / 2);
31503150      int bit = (to8_kbd_data >> bpos) & 1;
31513151      mc6846_set_input_cp1( 1 );
3152      d = MAME_TIME_IN_USEC( bit ? 56 : 38 );
3152      d = ATTOTIME_IN_USEC( bit ? 56 : 38 );
31533153      to8_kbd_step++;
31543154   }
3155   mame_timer_adjust( to8_kbd_timer, d, 0, time_never );
3155   timer_adjust( to8_kbd_timer, d, 0, attotime_never );
31563156}
31573157
31583158
r1293r1294
31663166 
31673167   if ( data )
31683168   {
3169      double len = mame_time_to_double(mame_timer_timeelapsed( to8_kbd_signal )) * 1000. - 2.;
3169      double len = attotime_to_double(timer_timeelapsed( to8_kbd_signal )) * 1000. - 2.;
31703170#if VERBOSE_KBD
3171      logerror( "%f to8_kbd_set_ack: CPU end ack, len=%f\n", mame_time_to_double(mame_timer_get_time()), len );
3171      logerror( "%f to8_kbd_set_ack: CPU end ack, len=%f\n", attotime_to_double(timer_get_time()), len );
31723172#endif
31733173      if ( to8_kbd_data == 0xfff )
31743174      {
31753175         /* end signal from CPU */
31763176         if ( len >= 0.6 && len <= 0.8 )
31773177         {
3178            LOG (( "%f to8_kbd_set_ack: INIT signal\n", mame_time_to_double(mame_timer_get_time()) ));
3178            LOG (( "%f to8_kbd_set_ack: INIT signal\n", attotime_to_double(timer_get_time()) ));
31793179            to8_kbd_last_key = 0xff;
31803180            to8_kbd_key_count = 0;
31813181            to8_kbd_caps = 1;
31823182            /* send back signal: TODO returned codes ? */
31833183            to8_kbd_data = 0;
31843184            to8_kbd_step = 0;
3185            mame_timer_adjust( to8_kbd_timer, MAME_TIME_IN_MSEC( 1 ), 0, time_never );
3185            timer_adjust( to8_kbd_timer, ATTOTIME_IN_MSEC( 1 ), 0, attotime_never );
31863186         }
31873187         else
31883188         {
31893189            to8_kbd_step = 0;
3190            mame_timer_adjust( to8_kbd_timer, TO8_KBD_POLL_PERIOD, 0, time_never );
3190            timer_adjust( to8_kbd_timer, TO8_KBD_POLL_PERIOD, 0, attotime_never );
31913191            if ( len >= 1.2 && len <= 1.4 )
31923192            {
3193               LOG (( "%f to8_kbd_set_ack: CAPS on signal\n", mame_time_to_double(mame_timer_get_time()) ));
3193               LOG (( "%f to8_kbd_set_ack: CAPS on signal\n", attotime_to_double(timer_get_time()) ));
31943194               to8_kbd_caps = 1;
31953195            }
31963196            else if ( len >= 1.8 && len <= 2.0 )
31973197            {
3198               LOG (( "%f to8_kbd_set_ack: CAPS off signal\n", mame_time_to_double(mame_timer_get_time()) ));
3198               LOG (( "%f to8_kbd_set_ack: CAPS off signal\n", attotime_to_double(timer_get_time()) ));
31993199               to8_kbd_caps = 0;
32003200            }
32013201         }
r1293r1294
32053205      {
32063206         /* end key transmission */
32073207         to8_kbd_step = 0;
3208         mame_timer_adjust( to8_kbd_timer, TO8_KBD_POLL_PERIOD, 0, time_never );
3208         timer_adjust( to8_kbd_timer, TO8_KBD_POLL_PERIOD, 0, attotime_never );
32093209      }
32103210   }
32113211
r1293r1294
32153215      {
32163216         /* CPU accepts key */
32173217         to8_kbd_step = 99;
3218         mame_timer_adjust( to8_kbd_timer, MAME_TIME_IN_USEC( 400 ), 0, time_never );
3218         timer_adjust( to8_kbd_timer, ATTOTIME_IN_USEC( 400 ), 0, attotime_never );
32193219      }
32203220      else
32213221      {
32223222         /* start signal from CPU */
32233223         to8_kbd_data = 0xfff;
32243224         to8_kbd_step = 91;
3225         mame_timer_adjust( to8_kbd_timer, MAME_TIME_IN_USEC( 400 ), 0, time_never );
3226         mame_timer_adjust( to8_kbd_signal, time_never, 0, time_never );
3225         timer_adjust( to8_kbd_timer, ATTOTIME_IN_USEC( 400 ), 0, attotime_never );
3226         timer_adjust( to8_kbd_signal, attotime_never, 0, attotime_never );
32273227      }
32283228#if VERBOSE_KBD
3229      logerror( "%f to8_kbd_set_ack: CPU ack, data=$%03X\n", mame_time_to_double(mame_timer_get_time()), to8_kbd_data );
3229      logerror( "%f to8_kbd_set_ack: CPU ack, data=$%03X\n", attotime_to_double(timer_get_time()), to8_kbd_data );
32303230#endif
32313231   }
32323232}
r1293r1294
32493249
32503250static void to8_kbd_init ( void )
32513251{
3252   to8_kbd_timer = mame_timer_alloc( to8_kbd_timer_cb );
3253   to8_kbd_signal = mame_timer_alloc( NULL );
3252   to8_kbd_timer = timer_alloc( to8_kbd_timer_cb );
3253   to8_kbd_signal = timer_alloc( NULL );
32543254   state_save_register_global( to8_kbd_ack );
32553255   state_save_register_global( to8_kbd_data );
32563256   state_save_register_global( to8_kbd_step );
r1293r1294
35433543
35443544#if VERBOSE_VIDEO
35453545   logerror( "$%04x %f to8_gatearray_r: off=%i ($%04X) res=$%02X lightpen=%i\n",
3546        activecpu_get_previouspc(), mame_time_to_double(mame_timer_get_time()),
3546        activecpu_get_previouspc(), attotime_to_double(timer_get_time()),
35473547        offset, 0xe7e4 + offset, res, to7_lightpen );
35483548#endif
35493549
r1293r1294
35563556{
35573557#if VERBOSE_VIDEO
35583558   logerror( "$%04x %f to8_gatearray_w: off=%i ($%04X) data=$%02X\n", 
3559        activecpu_get_previouspc(), mame_time_to_double(mame_timer_get_time()),
3559        activecpu_get_previouspc(), attotime_to_double(timer_get_time()),
35603560        offset, 0xe7e4 + offset, data );
35613561#endif
35623562
r1293r1294
36393639{
36403640#if VERBOSE_VIDEO
36413641   logerror( "$%04x %f to8_vreg_w: off=%i ($%04X) data=$%02X\n", 
3642        activecpu_get_previouspc(), mame_time_to_double(mame_timer_get_time()),
3642        activecpu_get_previouspc(), attotime_to_double(timer_get_time()),
36433643        offset, 0xe7da + offset, data );
36443644#endif
36453645
r1293r1294
36973697   int ktest = to8_kbd_ktest ();
36983698
36993699#if VERBOSE_KBD
3700   logerror( "$%04x %f: to8_sys_porta_in ktest=%i\n", activecpu_get_previouspc(), mame_time_to_double(mame_timer_get_time()), ktest );
3700   logerror( "$%04x %f: to8_sys_porta_in ktest=%i\n", activecpu_get_previouspc(), attotime_to_double(timer_get_time()), ktest );
37013701#endif
37023702
37033703   return ktest;
r1293r1294
42184218static WRITE8_HANDLER ( mo6_game_porta_out )
42194219{
42204220   /* centronics data */
4221   LOG (( "$%04x %f mo6_game_porta_out: CENTRONICS set data=$%02X\n", activecpu_get_previouspc(), mame_time_to_double(mame_timer_get_time()), data ));
4221   LOG (( "$%04x %f mo6_game_porta_out: CENTRONICS set data=$%02X\n", activecpu_get_previouspc(), attotime_to_double(timer_get_time()), data ));
42224222   centronics_write_data( 0, data );
42234223}
42244224
r1293r1294
42284228{
42294229   int dtr = ( centronics_read_handshake( 0 ) & CENTRONICS_NOT_BUSY ) ? 0 : 1;
42304230   /* note: printer busy signal replaces button */
4231   LOG (( "$%04x %f mo6_game_cb1_in: CENTRONICS get dtr=%i\n", activecpu_get_previouspc(), mame_time_to_double(mame_timer_get_time()), dtr ));
4231   LOG (( "$%04x %f mo6_game_cb1_in: CENTRONICS get dtr=%i\n", activecpu_get_previouspc(), attotime_to_double(timer_get_time()), dtr ));
42324232   return dtr;
42334233}
42344234
r1293r1294
42374237static WRITE8_HANDLER ( mo6_game_cb2_out )
42384238{
42394239   /* centronics strobe */
4240   LOG (( "$%04x %f mo6_game_cb2_out: CENTRONICS set strobe=%i\n", activecpu_get_previouspc(), mame_time_to_double(mame_timer_get_time()), data ));
4240   LOG (( "$%04x %f mo6_game_cb2_out: CENTRONICS set strobe=%i\n", activecpu_get_previouspc(), attotime_to_double(timer_get_time()), data ));
42414241   centronics_write_handshake( 0, data ? CENTRONICS_STROBE : 0,
42424242                CENTRONICS_STROBE );
42434243}
r1293r1294
42784278{
42794279   LOG (( "mo6_game_init called\n" ));
42804280   pia_config( THOM_PIA_GAME, &mo6_game );
4281   to7_game_timer = mame_timer_alloc( mo6_game_update_cb );
4282   mame_timer_adjust( to7_game_timer, TO7_GAME_POLL_PERIOD, 0, TO7_GAME_POLL_PERIOD );
4281   to7_game_timer = timer_alloc( mo6_game_update_cb );
4282   timer_adjust( to7_game_timer, TO7_GAME_POLL_PERIOD, 0, TO7_GAME_POLL_PERIOD );
42834283   state_save_register_global( to7_game_sound );
42844284   state_save_register_global( to7_game_mute );
42854285}
r1293r1294
44234423
44244424#if VERBOSE_VIDEO
44254425   logerror( "$%04x %f mo6_gatearray_r: off=%i ($%04X) res=$%02X lightpen=%i\n",
4426        activecpu_get_previouspc(), mame_time_to_double(mame_timer_get_time()),
4426        activecpu_get_previouspc(), attotime_to_double(timer_get_time()),
44274427        offset, 0xa7e4 + offset, res, to7_lightpen );
44284428#endif
44294429
r1293r1294
44364436{
44374437#if VERBOSE_VIDEO
44384438   logerror( "$%04x %f mo6_gatearray_w: off=%i ($%04X) data=$%02X\n", 
4439        activecpu_get_previouspc(), mame_time_to_double(mame_timer_get_time()),
4439        activecpu_get_previouspc(), attotime_to_double(timer_get_time()),
44404440        offset, 0xa7e4 + offset, data );
44414441#endif
44424442
r1293r1294
45054505{
45064506#if VERBOSE_VIDEO
45074507   logerror( "$%04x %f mo6_vreg_w: off=%i ($%04X) data=$%02X\n", 
4508        activecpu_get_previouspc(), mame_time_to_double(mame_timer_get_time()),
4508        activecpu_get_previouspc(), attotime_to_double(timer_get_time()),
45094509        offset, 0xa7da + offset, data );
45104510#endif
45114511
r1293r1294
46074607   to7_modem_init();
46084608   to7_midi_init();
46094609   to7_rf57932_init();
4610   mo5_periodic_timer = mame_timer_alloc( mo5_periodic_cb );
4610   mo5_periodic_timer = timer_alloc( mo5_periodic_cb );
46114611   mea8000_config( THOM_SOUND_SPEECH, NULL );
46124612 
46134613   /* memory */
r1293r1294
46604660   if ( to7_controller_type )
46614661      return to7_floppy_r ( offset );
46624662
4663   logerror( "$%04x %f mo5nr_net_r: read from reg %i\n", activecpu_get_previouspc(), mame_time_to_double(mame_timer_get_time()), offset );
4663   logerror( "$%04x %f mo5nr_net_r: read from reg %i\n", activecpu_get_previouspc(), attotime_to_double(timer_get_time()), offset );
46644664
46654665   if ( to7_controller_type )
46664666      return to7_floppy_r ( offset );
r1293r1294
46764676      to7_floppy_w ( offset, data );
46774677   else
46784678      logerror( "$%04x %f mo5nr_net_w: write $%02X to reg %i\n",
4679           activecpu_get_previouspc(), mame_time_to_double(mame_timer_get_time()), data, offset );
4679           activecpu_get_previouspc(), attotime_to_double(timer_get_time()), data, offset );
46804680}
46814681
46824682
r1293r1294
47044704         return 0x80;
47054705
47064706   default:
4707      logerror( "$%04x %f mo5nr_prn_r: unhandled read from reg %i\n", activecpu_get_previouspc(), mame_time_to_double(mame_timer_get_time()), offset ); 
4707      logerror( "$%04x %f mo5nr_prn_r: unhandled read from reg %i\n", activecpu_get_previouspc(), attotime_to_double(timer_get_time()), offset ); 
47084708      return 0;
47094709   }
47104710}
r1293r1294
47264726      break;
47274727
47284728   default:
4729      logerror( "$%04x %f mo5nr_prn_w: unhandled to reg %i (data=$%02X)\n", activecpu_get_previouspc(), mame_time_to_double(mame_timer_get_time()), offset, data );
4729      logerror( "$%04x %f mo5nr_prn_w: unhandled to reg %i (data=$%02X)\n", activecpu_get_previouspc(), attotime_to_double(timer_get_time()), offset, data );
47304730   }
47314731}
47324732
r1293r1294
47924792{
47934793   LOG (( "mo5nr_game_init called\n" ));
47944794   pia_config( THOM_PIA_GAME, &mo5nr_game );
4795   to7_game_timer = mame_timer_alloc( mo6_game_update_cb );
4796   mame_timer_adjust( to7_game_timer, TO7_GAME_POLL_PERIOD, 0, TO7_GAME_POLL_PERIOD );
4795   to7_game_timer = timer_alloc( mo6_game_update_cb );
4796   timer_adjust( to7_game_timer, TO7_GAME_POLL_PERIOD, 0, TO7_GAME_POLL_PERIOD );
47974797   state_save_register_global( to7_game_sound );
47984798   state_save_register_global( to7_game_mute );
47994799}
r1293r1294
48744874   to7_modem_init();
48754875   to7_midi_init();
48764876   to7_rf57932_init();
4877   mo5_periodic_timer = mame_timer_alloc( mo5_periodic_cb );
4877   mo5_periodic_timer = timer_alloc( mo5_periodic_cb );
48784878   mea8000_config( THOM_SOUND_SPEECH, NULL );
48794879 
48804880   /* memory */
src/mess/machine/lisa.c
r1293r1294
644644
645645      case 0x7:   /* send mouse command */
646646         if (immediate & 0x8)
647            mame_timer_adjust(mouse_timer, time_zero, 0, MAME_TIME_IN_MSEC((immediate & 0x7)*4)); /* enable mouse */
647            timer_adjust(mouse_timer, attotime_zero, 0, ATTOTIME_IN_MSEC((immediate & 0x7)*4)); /* enable mouse */
648648         else
649            mame_timer_reset(mouse_timer, time_never);
649            timer_reset(mouse_timer, attotime_never);
650650         break;
651651      }
652652   }
r1293r1294
689689   COPS_Ready = TRUE;
690690
691691   /* impulsion width : +/- 20us */
692   mame_timer_set(MAME_TIME_IN_USEC(20), 0, read_COPS_command);
692   timer_set(ATTOTIME_IN_USEC(20), 0, read_COPS_command);
693693}
694694
695695static void reset_COPS(void)
r1293r1294
704704   for (i=0; i<8; i++)
705705      key_matrix[i] = 0;
706706
707   mame_timer_reset(mouse_timer, time_never);
707   timer_reset(mouse_timer, attotime_never);
708708}
709709
710710static void unplug_keyboard(void)
r1293r1294
753753   COPS_Ready = FALSE;
754754
755755   /* read command every ms (don't know the real value) */
756   mame_timer_pulse(MAME_TIME_IN_MSEC(1), 0, set_COPS_ready);
756   timer_pulse(ATTOTIME_IN_MSEC(1), 0, set_COPS_ready);
757757
758758   reset_COPS();
759759}
r1293r1294
11221122
11231123MACHINE_RESET( lisa )
11241124{
1125   mouse_timer = mame_timer_alloc(handle_mouse);
1125   mouse_timer = timer_alloc(handle_mouse);
11261126
11271127   lisa_ram_ptr = memory_region(REGION_CPU1) + RAM_OFFSET;
11281128   lisa_rom_ptr = memory_region(REGION_CPU1) + ROM_OFFSET;
src/mess/machine/lynx.c
r1293r1294
7272
7373    int everon;
7474    int memory_accesses;
75    mame_time time;
75    attotime time;
7676} blitter;
7777
7878UINT8 *lynx_mem_0000;
r1293r1294
610610    }
611611
612612   if (0)
613      mame_timer_set(MAME_TIME_IN_CYCLES(blitter.memory_accesses*20,0), 0, lynx_blitter_timer);
613      timer_set(ATTOTIME_IN_CYCLES(blitter.memory_accesses*20,0), 0, lynx_blitter_timer);
614614}
615615
616616static void lynx_divide(void)
r1293r1294
672672      data=1; // must not be 0 for correct power up
673673      break;
674674   case 0x92:
675      if (!compare_mame_times(blitter.time, time_zero))
675      if (!attotime_compare(blitter.time, attotime_zero))
676676      {
677         if ( MAME_TIME_TO_CYCLES(0,sub_mame_times(mame_timer_get_time(), blitter.time)) > blitter.memory_accesses*20)
677         if ( ATTOTIME_TO_CYCLES(0,attotime_sub(timer_get_time(), blitter.time)) > blitter.memory_accesses*20)
678678         {
679679            suzy.u.data[offset]&=~1; //blitter finished
680            blitter.time = time_zero;
680            blitter.time = attotime_zero;
681681         }
682682      }
683683      data=suzy.u.data[offset];
r1293r1294
744744   case 0x63: lynx_divide();break;
745745   case 0x91:
746746       if (data&1) {
747      blitter.time=mame_timer_get_time();
747      blitter.time=timer_get_time();
748748      lynx_blitter();
749749       }
750750//       logerror("suzy write %.2x %.2x\n",offset,data);
r1293r1294
820820static void lynx_timer_init(int which)
821821{
822822   memset( &lynx_timer[which], 0, sizeof(LYNX_TIMER) );
823   lynx_timer[which].timer = mame_timer_alloc( lynx_timer_shot );
823   lynx_timer[which].timer = timer_alloc( lynx_timer_shot );
824824   lynx_timer[which].settime = 0.0;
825825}
826826
r1293r1294
916916      else
917917      {
918918         if ( lynx_timer[which].timer_active )
919            data = (UINT8) ( lynx_timer[which].bakup - scale_up_mame_time(mame_timer_timeleft(lynx_timer[which].timer), lynx_time_factor( lynx_timer[which].cntrl1 & 7 )).seconds);
919            data = (UINT8) ( lynx_timer[which].bakup - attotime_mul(timer_timeleft(lynx_timer[which].timer), lynx_time_factor( lynx_timer[which].cntrl1 & 7 )).seconds);
920920      }
921921      break;
922922
r1293r1294
938938      break;
939939   case 1:
940940      lynx_timer[which].cntrl1 = data;
941      mame_timer_reset( lynx_timer[which].timer, time_never);
941      timer_reset( lynx_timer[which].timer, attotime_never);
942942      lynx_timer[which].timer_active = 0;
943943      if ( ( lynx_timer[which].cntrl1 & 0x08 ) )
944944      {
945945         if ( ( lynx_timer[which].cntrl1 & 7 ) != 7 )
946946         {
947            mame_time t = scale_up_mame_time(MAME_TIME_IN_HZ( lynx_time_factor( lynx_timer[which].cntrl1 & 7 ) ), lynx_timer[which].bakup + 1 );
947            attotime t = attotime_mul(ATTOTIME_IN_HZ( lynx_time_factor( lynx_timer[which].cntrl1 & 7 ) ), lynx_timer[which].bakup + 1 );
948948            if ( lynx_timer[which].cntrl1 & 0x10 )
949               mame_timer_adjust( lynx_timer[which].timer, time_zero, which, t);
949               timer_adjust( lynx_timer[which].timer, attotime_zero, which, t);
950950            else
951               mame_timer_adjust( lynx_timer[which].timer, t, which, time_zero);
951               timer_adjust( lynx_timer[which].timer, t, which, attotime_zero);
952952            lynx_timer[which].timer_active = 1;
953953         }
954954      }
r1293r1294
983983    if (uart.buffer_loaded) {
984984   uart.data_to_send=uart.buffer;
985985   uart.buffer_loaded=FALSE;
986   mame_timer_set(MAME_TIME_IN_USEC(11), 0, lynx_uart_timer);   
986   timer_set(ATTOTIME_IN_USEC(11), 0, lynx_uart_timer);   
987987    } else {
988988   uart.sending=FALSE;
989989    }
r1293r1294
10251025   } else {
10261026       uart.sending=TRUE;
10271027       uart.data_to_send=data;
1028       mame_timer_set(MAME_TIME_IN_USEC(11), 0, lynx_uart_timer);
1028       timer_set(ATTOTIME_IN_USEC(11), 0, lynx_uart_timer);
10291029   }
10301030   break;
10311031    }
src/mess/machine/pmd85.c
r1293r1294
3232
3333static UINT8 pmd85_model;
3434
35static mame_timer * pmd85_cassette_timer;
35static emu_timer * pmd85_cassette_timer;
3636
3737static void pmd851_update_memory (void)
3838{
r1293r1294
784784
785785   msm8251_init(&pmd85_msm8251_interface);
786786
787   pmd85_cassette_timer = mame_timer_alloc(pmd85_cassette_timer_callback);
788   mame_timer_adjust(pmd85_cassette_timer, time_zero, 0, MAME_TIME_IN_HZ(2400));
787   pmd85_cassette_timer = timer_alloc(pmd85_cassette_timer_callback);
788   timer_adjust(pmd85_cassette_timer, attotime_zero, 0, ATTOTIME_IN_HZ(2400));
789789
790790   serial_connection_init(&pmd85_cassette_serial_connection);
791791   serial_connection_set_in_callback(&pmd85_cassette_serial_connection, pmd85_cassette_write);
src/mess/machine/rriot.c
r1293r1294
6666
6767   UINT8   irqen;      /* IRQ enabled ? */
6868   enum { Delay1, Delay8, Delay64, Delay1024, TimerShot } state;
69   mame_time shottime;
69   attotime shottime;
7070   int   irq;
71   mame_timer *timer;    /* timer callback */
71   emu_timer *timer;    /* timer callback */
7272} RRIOT;
7373
7474static RRIOT rriot[MAX_RRIOTS]= { {0} };
r1293r1294
7979{
8080   memset(&rriot[nr], 0, sizeof(rriot[nr]));
8181   rriot[nr].config = config;
82   rriot[nr].timer = mame_timer_alloc(rriot_timer_cb);
82   rriot[nr].timer = timer_alloc(rriot_timer_cb);
8383
8484    LOG("RRIOT - successfully initialised\n");
8585}
r1293r1294
134134      case 0: /* Timer count read */
135135         switch (rriot[chip].state) {
136136         case Delay1:
137            data = scale_up_mame_time(mame_timer_timeleft(rriot[chip].timer), rriot[chip].config->baseclock).seconds;
137            data = attotime_mul(timer_timeleft(rriot[chip].timer), rriot[chip].config->baseclock).seconds;
138138            break;
139139         case Delay8:
140            data = scale_up_mame_time(mame_timer_timeleft(rriot[chip].timer), rriot[chip].config->baseclock).seconds>>3;
140            data = attotime_mul(timer_timeleft(rriot[chip].timer), rriot[chip].config->baseclock).seconds>>3;
141141            break;
142142         case Delay64:
143            data = scale_up_mame_time(mame_timer_timeleft(rriot[chip].timer), rriot[chip].config->baseclock).seconds>>6;
143            data = attotime_mul(timer_timeleft(rriot[chip].timer), rriot[chip].config->baseclock).seconds>>6;
144144            break;
145145         case Delay1024:
146            data = scale_up_mame_time(mame_timer_timeleft(rriot[chip].timer), rriot[chip].config->baseclock).seconds>>10;
146            data = attotime_mul(timer_timeleft(rriot[chip].timer), rriot[chip].config->baseclock).seconds>>10;
147147            break;
148148         case TimerShot:
149            data=255- scale_up_mame_time(sub_mame_times(mame_timer_get_time(), rriot[chip].shottime), rriot[chip].config->baseclock).seconds;
149            data=255- attotime_mul(attotime_sub(timer_get_time(), rriot[chip].shottime), rriot[chip].config->baseclock).seconds;
150150            if (data <0 ) data=0;
151151            break;
152152         }
r1293r1294
174174   LOG(("rriot(%d) timer expired\n", chip));
175175   rriot[chip].irq=1;
176176   rriot[chip].state=TimerShot;
177   rriot[chip].shottime=mame_timer_get_time();
177   rriot[chip].shottime=timer_get_time();
178178   if( rriot[chip].irqen ) /* with IRQ? */
179179   {
180180      if( rriot[chip].config->irq_callback )
r1293r1294
221221      switch (offset&3) {
222222      case 0: /* Timer 1 start */
223223         LOG(("rriot(%d) TMR1  write: $%02x%s\n", chip, data, (char*)((offset & 8) ? " (IRQ)":" ")));
224         mame_timer_adjust(rriot[chip].timer, scale_up_mame_time(MAME_TIME_IN_HZ(rriot[chip].config->baseclock), (data+1) ), chip, time_zero);
224         timer_adjust(rriot[chip].timer, attotime_mul(ATTOTIME_IN_HZ(rriot[chip].config->baseclock), (data+1) ), chip, attotime_zero);
225225         rriot[chip].state=Delay1;
226226         break;
227227      case 1: /* Timer 8 start */
228228         LOG(("rriot(%d) TMR8  write: $%02x%s\n", chip, data, (char*)((offset & 8) ? " (IRQ)":" ")));
229         mame_timer_adjust(rriot[chip].timer, scale_up_mame_time(MAME_TIME_IN_HZ(rriot[chip].config->baseclock), (data+1) * 8 ), chip, time_zero);
229         timer_adjust(rriot[chip].timer, attotime_mul(ATTOTIME_IN_HZ(rriot[chip].config->baseclock), (data+1) * 8 ), chip, attotime_zero);
230230         rriot[chip].state=Delay8;
231231         break;
232232      case 2: /* Timer 64 start */
233233         LOG(("rriot(%d) TMR64 write: $%02x%s\n", chip, data, (char*)((offset & 8) ? " (IRQ)":" ")));
234234//         LOG(("rriot(%d) TMR64 write: time is $%f\n", chip, (double)(64.0 * (data + 1) / rriot[chip].clock)));
235         mame_timer_adjust(rriot[chip].timer, scale_up_mame_time(MAME_TIME_IN_HZ(rriot[chip].config->baseclock), (data+1) * 64 ), chip, time_zero);
235         timer_adjust(rriot[chip].timer, attotime_mul(ATTOTIME_IN_HZ(rriot[chip].config->baseclock), (data+1) * 64 ), chip, attotime_zero);
236236         rriot[chip].state=Delay64;
237237         break;
238238      case 3: /* Timer 1024 start */
239239         LOG(("rriot(%d) TMR1K write: $%02x%s\n", chip, data, (char*)((offset & 8) ? " (IRQ)":" ")));
240         mame_timer_adjust(rriot[chip].timer, scale_up_mame_time(MAME_TIME_IN_HZ(rriot[chip].config->baseclock), (data+1) * 1024 ), chip, time_zero);
240         timer_adjust(rriot[chip].timer, attotime_mul(ATTOTIME_IN_HZ(rriot[chip].config->baseclock), (data+1) * 1024 ), chip, attotime_zero);
241241         rriot[chip].state=Delay1024;
242242         break;
243243      }
src/mess/machine/geneve.c
r1293r1294
371371   {
372372      /* Weirdly enough, we are always seeing some problems even though
373373      everything is working fine. */
374      /*mame_time time_to_ready = double_to_mame_time(tms5220_time_to_ready());
374      /*attotime time_to_ready = double_to_attotime(tms5220_time_to_ready());
375375      logerror("ti99/4a speech says aaargh!\n");
376376      logerror("(time to ready: %f -> %d)\n", time_to_ready, (int) ceil(3000000*time_to_ready));*/
377377   }
r1293r1294
393393   complex. */
394394   if (! tms5220_ready_r())
395395   {
396      mame_time time_to_ready = double_to_mame_time(tms5220_time_to_ready());
397      int cycles_to_ready = ceil(MAME_TIME_TO_CYCLES(0, time_to_ready));
396      attotime time_to_ready = double_to_attotime(tms5220_time_to_ready());
397      int cycles_to_ready = ceil(ATTOTIME_TO_CYCLES(0, time_to_ready));
398398
399      logerror("time to ready: %f -> %d\n", mame_time_to_double(time_to_ready), (int) cycles_to_ready);
399      logerror("time to ready: %f -> %d\n", attotime_to_double(time_to_ready), (int) cycles_to_ready);
400400
401401      activecpu_adjust_icount(-cycles_to_ready);
402      mame_timer_set(time_zero, 0, /*speech_kludge_callback*/NULL);
402      timer_set(attotime_zero, 0, /*speech_kludge_callback*/NULL);
403403   }
404404#endif
405405
src/mess/machine/tx0.c
r1293r1294
2727   int rcl;      /* 1-bit reader clutch */
2828   int rc;         /* 2-bit reader counter */
2929
30   mame_timer *timer;   /* timer to simulate reader timing */
30   emu_timer *timer;   /* timer to simulate reader timing */
3131} tape_reader_t;
3232
3333static tape_reader_t tape_reader;
r1293r1294
3838{
3939   mess_image *fd;   /* file descriptor of tape image */
4040
41   mame_timer *timer;   /* timer to generate completion pulses */
41   emu_timer *timer;   /* timer to generate completion pulses */
4242} tape_puncher_t;
4343
4444static tape_puncher_t tape_puncher;
r1293r1294
4949{
5050   mess_image *fd;   /* file descriptor of output image */
5151
52   mame_timer *prt_timer;/* timer to generate completion pulses */
52   emu_timer *prt_timer;/* timer to generate completion pulses */
5353} typewriter_t;
5454
5555static typewriter_t typewriter;
5656
5757
5858/* crt display timer */
59static mame_timer *dis_timer;
59static emu_timer *dis_timer;
6060
6161
6262/* magnetic tape unit registers */
r1293r1294
126126
127127   int long_parity;
128128
129   mame_timer *timer;   /* timer to simulate reader timing */
129   emu_timer *timer;   /* timer to simulate reader timing */
130130} magtape_t;
131131
132132static magtape_t magtape;
r1293r1294
166166{
167167   memory_set_opbase_handler(0, setOPbasefunc);;
168168
169   tape_reader.timer = mame_timer_alloc(reader_callback);
170   tape_puncher.timer = mame_timer_alloc(puncher_callback);
171   typewriter.prt_timer = mame_timer_alloc(prt_callback);
172   dis_timer = mame_timer_alloc(dis_callback);
169   tape_reader.timer = timer_alloc(reader_callback);
170   tape_puncher.timer = timer_alloc(puncher_callback);
171   typewriter.prt_timer = timer_alloc(prt_callback);
172   dis_timer = timer_alloc(dis_callback);
173173
174174   add_reset_callback(machine, tx0_machine_reset);
175175   add_exit_callback(machine, tx0_machine_stop);
r1293r1294
226226      /* restart reader IO when necessary */
227227      /* note that this function may be called before tx0_init_machine, therefore
228228      before tape_reader.timer is allocated.  It does not matter, as the clutch is never
229      down at power-up, but we must not call mame_timer_enable with a NULL parameter! */
229      down at power-up, but we must not call timer_enable with a NULL parameter! */
230230      if (tape_reader.timer)
231231      {
232232         if (tape_reader.motor_on && tape_reader.rcl)
233233         {
234234            /* delay is approximately 1/400s */
235            mame_timer_adjust(tape_reader.timer, MAME_TIME_IN_USEC(2500), 0, time_zero);
235            timer_adjust(tape_reader.timer, ATTOTIME_IN_USEC(2500), 0, attotime_zero);
236236         }
237237         else
238238         {
239            mame_timer_enable(tape_reader.timer, 0);
239            timer_enable(tape_reader.timer, 0);
240240         }
241241      }
242242      break;
r1293r1294
264264      tape_reader.motor_on = 0;
265265
266266      if (tape_reader.timer)
267         mame_timer_enable(tape_reader.timer, 0);
267         timer_enable(tape_reader.timer, 0);
268268      break;
269269
270270   case 1:
r1293r1294
306306   if (tape_reader.motor_on && tape_reader.rcl)
307307   {
308308      /* delay is approximately 1/400s */
309      mame_timer_adjust(tape_reader.timer, MAME_TIME_IN_USEC(2500), 0, time_zero);
309      timer_adjust(tape_reader.timer, ATTOTIME_IN_USEC(2500), 0, attotime_zero);
310310   }
311311   else
312312   {
313      mame_timer_enable(tape_reader.timer, 0);
313      timer_enable(tape_reader.timer, 0);
314314   }
315315}
316316
r1293r1294
357357
358358   if (tape_reader.motor_on && tape_reader.rcl)
359359      /* delay is approximately 1/400s */
360      mame_timer_adjust(tape_reader.timer, MAME_TIME_IN_USEC(2500), 0, time_zero);
360      timer_adjust(tape_reader.timer, ATTOTIME_IN_USEC(2500), 0, attotime_zero);
361361   else
362      mame_timer_enable(tape_reader.timer, 0);
362      timer_enable(tape_reader.timer, 0);
363363}
364364
365365/*
r1293r1294
398398   /* shuffle and punch 6-bit word */
399399   tape_write(((ac & 0100000) >> 15) | ((ac & 0010000) >> 11) | ((ac & 0001000) >> 7) | ((ac & 0000100) >> 3) | ((ac & 0000010) << 1) | ((ac & 0000001) << 5));
400400
401   mame_timer_adjust(tape_puncher.timer, MAME_TIME_IN_USEC(15800), 0, time_zero);
401   timer_adjust(tape_puncher.timer, ATTOTIME_IN_USEC(15800), 0, attotime_zero);
402402}
403403
404404/*
r1293r1294
413413   /* shuffle and punch 6-bit word */
414414   tape_write(((ac & 0100000) >> 15) | ((ac & 0010000) >> 11) | ((ac & 0001000) >> 7) | ((ac & 0000100) >> 3) | ((ac & 0000010) << 1) | ((ac & 0000001) << 5) | 0100);
415415
416   mame_timer_adjust(tape_puncher.timer, MAME_TIME_IN_USEC(15800), 0, time_zero);
416   timer_adjust(tape_puncher.timer, ATTOTIME_IN_USEC(15800), 0, attotime_zero);
417417}
418418
419419
r1293r1294
472472   ch = ((ac & 0100000) >> 15) | ((ac & 0010000) >> 11) | ((ac & 0001000) >> 7) | ((ac & 0000100) >> 3) | ((ac & 0000010) << 1) | ((ac & 0000001) << 5);
473473   typewriter_out(ch);
474474
475   mame_timer_adjust(typewriter.prt_timer, MAME_TIME_IN_MSEC(100), 0, time_zero);
475   timer_adjust(typewriter.prt_timer, ATTOTIME_IN_MSEC(100), 0, attotime_zero);
476476}
477477
478478
r1293r1294
498498   y = ac & 0777;
499499   tx0_plot(x, y);
500500
501   mame_timer_adjust(dis_timer, MAME_TIME_IN_USEC(50), 0, time_zero);
501   timer_adjust(dis_timer, ATTOTIME_IN_USEC(50), 0, attotime_zero);
502502}
503503
504504
r1293r1294
514514
515515static void schedule_select(void)
516516{
517   mame_time delay = time_zero;
517   attotime delay = attotime_zero;
518518
519519   switch (magtape.command)
520520   {
521521   case 0:   /* backspace */
522      delay = MAME_TIME_IN_USEC(4600);
522      delay = ATTOTIME_IN_USEC(4600);
523523      break;
524524   case 1:   /* read */
525      delay = MAME_TIME_IN_USEC(8600);
525      delay = ATTOTIME_IN_USEC(8600);
526526      break;
527527   case 2:   /* rewind */
528      delay = MAME_TIME_IN_USEC(12000);
528      delay = ATTOTIME_IN_USEC(12000);
529529      break;
530530   case 3:   /* write */
531      delay = MAME_TIME_IN_USEC(4600);
531      delay = ATTOTIME_IN_USEC(4600);
532532      break;
533533   }
534   mame_timer_adjust(magtape.timer, delay, 0, time_zero);
534   timer_adjust(magtape.timer, delay, 0, attotime_zero);
535535}
536536
537537static void schedule_unselect(void)
538538{
539   mame_time delay = time_zero;
539   attotime delay = attotime_zero;
540540
541541   switch (magtape.command)
542542   {
543543   case 0:   /* backspace */
544      delay = MAME_TIME_IN_USEC(5750);
544      delay = ATTOTIME_IN_USEC(5750);
545545      break;
546546   case 1:   /* read */
547      delay = MAME_TIME_IN_USEC(1750);
547      delay = ATTOTIME_IN_USEC(1750);
548548      break;
549549   case 2:   /* rewind */
550      delay = MAME_TIME_IN_USEC(0);
550      delay = ATTOTIME_IN_USEC(0);
551551      break;
552552   case 3:   /* write */
553      delay = MAME_TIME_IN_USEC(5750);
553      delay = ATTOTIME_IN_USEC(5750);
554554      break;
555555   }
556   mame_timer_adjust(magtape.timer, delay, 0, time_zero);
556   timer_adjust(magtape.timer, delay, 0, attotime_zero);
557557}
558558
559559DEVICE_INIT( tx0_magtape )
r1293r1294
574574
575575   /* restart IO when necessary */
576576   /* note that this function may be called before tx0_init_machine, therefore
577   before magtape.timer is allocated.  We must not call mame_timer_enable with a
577   before magtape.timer is allocated.  We must not call timer_enable with a
578578   NULL parameter! */
579579   if (magtape.timer)
580580   {
r1293r1294
593593   {
594594      if (magtape.state == MTS_SELECTING)
595595         /* I/O has not actually started, we can cancel the selection */
596         mame_timer_enable(tape_reader.timer, 0);
596         timer_enable(tape_reader.timer, 0);
597597      if ((magtape.state == MTS_SELECTED) || ((magtape.state == MTS_SELECTING) && (magtape.command == 2)))
598598      {   /* unit has become unavailable */
599599         magtape.state = MTS_UNSELECTING;
r1293r1294
783783               break;
784784            }
785785            if (magtape.state != MTS_UNSELECTING)
786               mame_timer_adjust(magtape.timer, MAME_TIME_IN_USEC(66), 0, time_zero);
786               timer_adjust(magtape.timer, ATTOTIME_IN_USEC(66), 0, attotime_zero);
787787         }
788788         break;
789789
r1293r1294
942942               break;
943943            }
944944            if (magtape.state != MTS_UNSELECTING)
945               mame_timer_adjust(magtape.timer, MAME_TIME_IN_USEC(66), 0, time_zero);
945               timer_adjust(magtape.timer, ATTOTIME_IN_USEC(66), 0, attotime_zero);
946946         }
947947         break;
948948
949949      case 2:   /* rewind */
950950         magtape.state = MTS_UNSELECTING;
951951         /* we rewind at 10*read speed (I don't know the real value) */
952         mame_timer_adjust(magtape.timer, scale_up_mame_time(MAME_TIME_IN_NSEC(6600), image_ftell(magtape.img)), 0, time_zero);
952         timer_adjust(magtape.timer, attotime_mul(ATTOTIME_IN_NSEC(6600), image_ftell(magtape.img)), 0, attotime_zero);
953953         //schedule_unselect();
954954         image_fseek(magtape.img, 0, SEEK_END);
955955         magtape.irg_pos = MTIRGP_END;
r1293r1294
10371037               image_unload(magtape.img);
10381038            }
10391039            else
1040               mame_timer_adjust(magtape.timer, MAME_TIME_IN_USEC(66), 0, time_zero);
1040               timer_adjust(magtape.timer, ATTOTIME_IN_USEC(66), 0, attotime_zero);
10411041         }
10421042         break;
10431043      }
r1293r1294
10531053   {
10541054      if (0)
10551055         magtape_callback(0);
1056      mame_timer_adjust(magtape.timer, time_zero, 0, time_zero);
1056      timer_adjust(magtape.timer, attotime_zero, 0, attotime_zero);
10571057   }
10581058}
10591059
r1293r1294
10951095{
10961096   tape_reader.rcl = tape_reader.rc = 0;
10971097   if (tape_reader.timer)
1098      mame_timer_enable(tape_reader.timer, 0);
1098      timer_enable(tape_reader.timer, 0);
10991099
11001100   if (tape_puncher.timer)
1101      mame_timer_enable(tape_puncher.timer, 0);
1101      timer_enable(tape_puncher.timer, 0);
11021102
11031103   if (typewriter.prt_timer)
1104      mame_timer_enable(typewriter.prt_timer, 0);
1104      timer_enable(typewriter.prt_timer, 0);
11051105
11061106   if (dis_timer)
1107      mame_timer_enable(dis_timer, 0);
1107      timer_enable(dis_timer, 0);
11081108}
11091109
11101110
src/mess/machine/pc_turbo.c
r1293r1294
4949   ti->cur_val = -1;
5050   ti->off_speed = off_speed;
5151   ti->on_speed = on_speed;
52   mame_timer_pulse_ptr(MAME_TIME_IN_MSEC(100), ti, pc_turbo_callback);
52   timer_pulse_ptr(ATTOTIME_IN_MSEC(100), ti, pc_turbo_callback);
5353   return 0;
5454}
src/mess/machine/lviv.c
r1293r1294
226226   memory_set_bankptr(3, memory_region(REGION_CPU1) + 0x010000);
227227   memory_set_bankptr(4, memory_region(REGION_CPU1) + 0x010000);
228228
229   /*mame_timer_pulse(TIME_IN_NSEC(200), 0, lviv_draw_pixel);*/
229   /*timer_pulse(TIME_IN_NSEC(200), 0, lviv_draw_pixel);*/
230230
231231   /*memset(mess_ram, 0, sizeof(unsigned char)*0xffff);*/
232232}
src/mess/machine/ay3600.c
r1293r1294
316316
317317   /* We poll the keyboard periodically to scan the keys.  This is
318318   actually consistent with how the AY-3600 keyboard controller works. */
319   mame_timer_pulse(MAME_TIME_IN_HZ(60), 0, AY3600_poll);
319   timer_pulse(ATTOTIME_IN_HZ(60), 0, AY3600_poll);
320320
321321   /* Set Caps Lock light to ON, since that's how we default it. */
322322   set_led_status(1,1);
src/mess/machine/pc8801.c
r1293r1294
175175   interrupt_mask_reg=0xf8;
176176   interrupt_trig_reg=0x0;
177177   cpunum_set_irq_callback(0,pc8801_interupt_callback);
178   mame_timer_pulse(MAME_TIME_IN_HZ(600),0,pc8801_timer_interrupt);
178   timer_pulse(ATTOTIME_IN_HZ(600),0,pc8801_timer_interrupt);
179179}
180180
181181WRITE8_HANDLER(pc88sr_outport_30)
src/mess/machine/tms9901.c
r1293r1294
197197{
198198   int i;
199199
200   tms9901[which].timer = mame_timer_alloc(decrementer_callback);
200   tms9901[which].timer = timer_alloc(decrementer_callback);
201201
202202   tms9901[which].supported_int_mask = param->supported_int_mask;
203203
r1293r1294
223223{
224224   if (tms9901[which].timer)
225225   {
226      mame_timer_reset(tms9901[which].timer, time_never);   /* FIXME - timers should only be allocated once */
226      timer_reset(tms9901[which].timer, attotime_never);   /* FIXME - timers should only be allocated once */
227227      tms9901[which].timer = NULL;
228228   }
229229}
r1293r1294
328328{
329329   if (tms9901[which].clockinvl)
330330   {   /* reset clock interval */
331      mame_timer_adjust(tms9901[which].timer, double_to_mame_time((double) tms9901[which].clockinvl / (tms9901[which].clock_rate / 64.)), which, double_to_mame_time((double) tms9901[which].clockinvl / (tms9901[which].clock_rate / 64.)));
331      timer_adjust(tms9901[which].timer, double_to_attotime((double) tms9901[which].clockinvl / (tms9901[which].clock_rate / 64.)), which, double_to_attotime((double) tms9901[which].clockinvl / (tms9901[which].clock_rate / 64.)));
332332   }
333333   else
334334   {   /* clock interval == 0 -> no timer */
335      mame_timer_enable(tms9901[which].timer, 0);
335      timer_enable(tms9901[which].timer, 0);
336336   }
337337}
338338
r1293r1294
452452            /* we are switching to clock mode: latch the current value of
453453            the decrementer register */
454454            if (tms9901[which].clockinvl)
455               tms9901[which].latchedtimer = ceil(mame_time_to_double(mame_timer_timeleft(tms9901[which].timer)) * (tms9901[which].clock_rate / 64.));
455               tms9901[which].latchedtimer = ceil(attotime_to_double(timer_timeleft(tms9901[which].timer)) * (tms9901[which].clock_rate / 64.));
456456            else
457457               tms9901[which].latchedtimer = 0;      /* timer inactive... */
458458         }
src/mess/machine/pet.c
r1293r1294
452452   }
453453
454454   /* pet clock */
455   mame_timer_pulse(MAME_TIME_IN_MSEC(10), 0, pet_interrupt);
455   timer_pulse(ATTOTIME_IN_MSEC(10), 0, pet_interrupt);
456456
457457   via_config(0, &pet_via);
458458   pia_config(1, &pet_pia1);
src/mess/machine/oric.c
r1293r1294
11011101   oric_irqs = 0;
11021102   oric_ram_0x0c000 = NULL;
11031103
1104    mame_timer_pulse(MAME_TIME_IN_HZ(4800), 0, oric_refresh_tape);
1104    timer_pulse(ATTOTIME_IN_HZ(4800), 0, oric_refresh_tape);
11051105
11061106   via_reset();
11071107   via_config(0, &oric_6522_interface);
src/mess/machine/europc.c
r1293r1294
225225   UINT8 data[0x10];
226226   int reg;
227227   int state;
228   mame_timer *timer;
228   emu_timer *timer;
229229} europc_rtc;
230230
231231void europc_rtc_set_time(void)
r1293r1294
277277   memset(&europc_rtc,0,sizeof(europc_rtc));
278278   europc_rtc.data[0xf]=1;
279279
280   europc_rtc.timer = mame_timer_alloc(europc_rtc_timer);
281   mame_timer_adjust(europc_rtc.timer, time_zero, 0, make_mame_time(1, 0));
280   europc_rtc.timer = timer_alloc(europc_rtc_timer);
281   timer_adjust(europc_rtc.timer, attotime_zero, 0, attotime_make(1, 0));
282282}
283283
284284 READ8_HANDLER( europc_rtc_r )
src/mess/machine/6551.c
r1293r1294
8888   memset(&acia, 0, sizeof(struct acia6551));
8989   /* transmit data reg is empty */
9090   acia.status_register |= (1<<4);
91   acia.timer = mame_timer_alloc(acia_6551_timer_callback);
91   acia.timer = timer_alloc(acia_6551_timer_callback);
9292
9393   serial_connection_init(&acia.connection);
9494   serial_connection_set_in_callback(&acia.connection, acia_6551_in_callback);
r1293r1294
359359                rate = data & 0x07;
360360
361361            /* baud rate changed? */
362            mame_timer_reset(acia.timer, time_never);
362            timer_reset(acia.timer, attotime_never);
363363
364364            if (rate==0)
365365            {
r1293r1294
465465                  break;
466466               }
467467
468               mame_timer_adjust(acia.timer, time_zero, 0, MAME_TIME_IN_HZ(baud_rate));
468               timer_adjust(acia.timer, attotime_zero, 0, ATTOTIME_IN_HZ(baud_rate));
469469            }
470470         }
471471
src/mess/machine/atom.c
r1293r1294
251251   via_reset();
252252
253253   timer_state = 0;
254   mame_timer_pulse(MAME_TIME_IN_HZ(2400*2), 0, atom_timer_callback);
254   timer_pulse(ATTOTIME_IN_HZ(2400*2), 0, atom_timer_callback);
255255
256256   memory_set_opbase_handler(0,atom_opbase_handler);
257257}
src/mess/machine/pc1403.c
r1293r1294
187187void pc1403_outc(int data)
188188{
189189    pc1403_portc=data;
190    logerror("%g pc %.4x outc %.2x\n", mame_time_to_double(mame_timer_get_time()), activecpu_get_pc(), data);
190    logerror("%g pc %.4x outc %.2x\n", attotime_to_double(timer_get_time()), activecpu_get_pc(), data);
191191}
192192
193193
r1293r1294
236236
237237   for (i=0; i<128; i++) gfx[i]=i;
238238
239   mame_timer_set(MAME_TIME_IN_SEC(1), 0, pc1403_power_up);
239   timer_set(ATTOTIME_IN_SEC(1), 0, pc1403_power_up);
240240
241241   memory_set_bankptr(1, memory_region(REGION_USER1));
242242   if (RAM32K)
src/mess/machine/electron.c
r1293r1294
1313#include "devices/cassette.h"
1414
1515ULA ula;
16mame_timer *electron_tape_timer;
16emu_timer *electron_tape_timer;
1717
1818static mess_image *cassette_device_image( void ) {
1919   return image_from_devtype_and_index( IO_CASSETTE, 0 );
r1293r1294
2828   ula.high_tone_set = 0;
2929   ula.bit_count = 0;
3030   ula.tape_running = 1;
31   mame_timer_adjust( electron_tape_timer, time_zero, 0, MAME_TIME_IN_HZ(4800) );
31   timer_adjust( electron_tape_timer, attotime_zero, 0, ATTOTIME_IN_HZ(4800) );
3232}
3333
3434static void electron_tape_stop( void ) {
3535   ula.tape_running = 0;
36   mame_timer_reset( electron_tape_timer, time_never );
36   timer_reset( electron_tape_timer, attotime_never );
3737}
3838
3939#define TAPE_LOW   0x00;
r1293r1294
292292   
293293   ula.interrupt_status = 0x82;
294294   ula.interrupt_control = 0x00;
295   mame_timer_set( time_zero, 0, setup_beep );
296   electron_tape_timer = mame_timer_alloc( electron_tape_timer_handler );
295   timer_set( attotime_zero, 0, setup_beep );
296   electron_tape_timer = timer_alloc( electron_tape_timer_handler );
297297   add_reset_callback(machine, electron_reset);
298298}
299299
src/mess/machine/mfm.c
r1293r1294
105105   {
106106      if (drive->index_timer!=NULL)
107107      {
108         mame_timer_reset(drive->index_timer, time_never);   /* FIXME - timers should only be allocated once */
108         timer_reset(drive->index_timer, attotime_never);   /* FIXME - timers should only be allocated once */
109109         drive->index_timer = NULL;
110110      }
111111   }
r1293r1294
137137      /* shut off timer */
138138      if (drive->index_timer!=NULL)
139139      {
140         mame_timer_reset(drive->index_timer, time_never);   /* FIXME - timers should only be allocated once */
140         timer_reset(drive->index_timer, attotime_never);   /* FIXME - timers should only be allocated once */
141141         drive->index_timer = NULL;
142142      }
143143
r1293r1294
147147         /* this is not quite correct. if the motor is stopped in the middle
148148         of the track, the next index pulse will occur in half a track time, from
149149         there after it will occur every 300hz */
150         drive->index_timer = mame_timer_pulse(MAME_TIME_IN_HZ(300), drive_id, index_timer_callback);
150         drive->index_timer = timer_pulse(ATTOTIME_IN_HZ(300), drive_id, index_timer_callback);
151151      }
152152
153153      drive->motor_state = motor;
src/mess/machine/pc_hdc.c
r1293r1294
9292static int status[MAX_BOARD];         /* drive status */
9393static int error[MAX_BOARD];          /* error code */
9494static int dip[MAX_BOARD];            /* dip switches */
95static mame_timer *timer[MAX_BOARD];
95static emu_timer *timer[MAX_BOARD];
9696
9797
9898static int data_cnt = 0;                /* data count */
r1293r1294
178178      status[i] = 0;
179179      error[i] = 0;
180180      dip[i] = 0xff;
181      timer[i] = mame_timer_alloc(pc_hdc_command);
181      timer[i] = timer_alloc(pc_hdc_command);
182182      if (!timer[i])
183183         return -1;
184184   }
r1293r1294
633633         status[n] |= STA_INPUT;
634634         
635635         assert(timer[n]);
636         mame_timer_adjust(timer[n], MAME_TIME_IN_MSEC(1), n, time_zero);
636         timer_adjust(timer[n], ATTOTIME_IN_MSEC(1), n, attotime_zero);
637637        }
638638   }
639639}
src/mess/machine/centroni.c
r1293r1294
1111   UINT8 data;
1212   UINT8 control;
1313   double time_;
14   mame_timer *timer;
14   emu_timer *timer;
1515
1616   /* These bytes are used in the timer callback. When the timer callback
1717   is executed, the control value is updated with the new data. The mask
r1293r1294
3737{
3838   CENTRONICS *This=cent+nr;
3939   This->config=config;
40   This->timer = mame_timer_alloc(centronics_timer_callback);
40   This->timer = timer_alloc(centronics_timer_callback);
4141}
4242
4343void centronics_write_data(int nr, UINT8 data)
r1293r1294
7272   {
7373      This->new_control_mask = CENTRONICS_ACKNOWLEDGE;
7474      This->new_control_data = 0;
75      mame_timer_adjust(This->timer, MAME_TIME_IN_USEC(2), nr, time_zero);
75      timer_adjust(This->timer, ATTOTIME_IN_USEC(2), nr, attotime_zero);
7676   }
7777   /* phase 3: end */
7878   else if ( This->control & CENTRONICS_NOT_BUSY )
7979   {
80      mame_timer_adjust(This->timer, time_never, nr, time_zero);
80      timer_adjust(This->timer, attotime_never, nr, attotime_zero);
8181   }
8282   /* phase 1: schedule not busy & ack */
8383   else
8484   {
8585      This->new_control_mask = CENTRONICS_NOT_BUSY | CENTRONICS_ACKNOWLEDGE;
8686      This->new_control_data = CENTRONICS_NOT_BUSY | CENTRONICS_ACKNOWLEDGE;
87      mame_timer_adjust(This->timer, MAME_TIME_IN_USEC(15), nr, time_zero);
87      timer_adjust(This->timer, ATTOTIME_IN_USEC(15), nr, attotime_zero);
8888   }
8989}
9090
r1293r1294
102102         /* schedule busy */
103103         This->new_control_mask = CENTRONICS_NOT_BUSY;
104104         This->new_control_data = 0;
105         mame_timer_adjust(This->timer, MAME_TIME_IN_USEC(5), nr, time_zero);
105         timer_adjust(This->timer, ATTOTIME_IN_USEC(5), nr, attotime_zero);
106106
107107         /* output */
108108         printer_output(image_from_devtype_and_index(IO_PRINTER, nr), This->data);
src/mess/machine/apple1.c
r1293r1294
165165
166166      A 120-Hz poll rate seems to be fast enough to ensure no
167167      keystrokes are missed. */
168   mame_timer_pulse(MAME_TIME_IN_HZ(120), 0, apple1_kbd_poll);
168   timer_pulse(ATTOTIME_IN_HZ(120), 0, apple1_kbd_poll);
169169}
170170
171171
r1293r1294
371371      /* The keyboard will pulse its strobe line when a key is
372372         pressed.  A 10-usec pulse is typical. */
373373      pia_set_input_ca1(0, 1);
374      mame_timer_set(MAME_TIME_IN_USEC(10), 0, apple1_kbd_strobe_end);
374      timer_set(ATTOTIME_IN_USEC(10), 0, apple1_kbd_strobe_end);
375375   }
376376}
377377
r1293r1294
414414      write.  Thus the write delay depends on the cursor position and
415415      where the display is in the refresh cycle. */
416416   if (!data)
417      mame_timer_set(apple1_vh_dsp_time_to_ready(), 0, apple1_dsp_ready_start);
417      timer_set(apple1_vh_dsp_time_to_ready(), 0, apple1_dsp_ready_start);
418418}
419419
420420static TIMER_CALLBACK(apple1_dsp_ready_start)
r1293r1294
424424      input CB1.  The end of this pulse will tell the PIA that the
425425      display is ready for another write. */
426426   pia_set_input_cb1(0, 0);
427   mame_timer_set(MAME_TIME_IN_NSEC(3500), 0, apple1_dsp_ready_end);
427   timer_set(ATTOTIME_IN_NSEC(3500), 0, apple1_dsp_ready_end);
428428}
429429
430430static TIMER_CALLBACK(apple1_dsp_ready_end)
src/mess/machine/mc6843.c
r1293r1294
7272   UINT8  index_pulse;
7373
7474   /* trigger delayed actions (bottom halves) */
75   mame_timer* timer_cont;
75   emu_timer* timer_cont;
7676   
7777} * mc6843;
7878
r1293r1294
9090#define CMD_FFR 0xa /* free format read */
9191
9292/* coarse delays */
93#define DELAY_SEEK   MAME_TIME_IN_USEC( 100 )  /* track seek time */
94#define DELAY_ADDR   MAME_TIME_IN_USEC( 100 )  /* search-address time */
93#define DELAY_SEEK   ATTOTIME_IN_USEC( 100 )  /* track seek time */
94#define DELAY_ADDR   ATTOTIME_IN_USEC( 100 )  /* search-address time */
9595
9696
9797
r1293r1294
209209      floppy_drive_seek( img, -1 );
210210   }
211211
212   LOG(( "%f mc6843_finish_STZ: actual=%i\n", mame_time_to_double(mame_timer_get_time()), floppy_drive_get_current_track( img ) ));
212   LOG(( "%f mc6843_finish_STZ: actual=%i\n", attotime_to_double(timer_get_time()), floppy_drive_get_current_track( img ) ));
213213     
214214   /* update state */
215215   mc6843->CTAR = 0;
r1293r1294
232232   /* seek to track */
233233   floppy_drive_seek( img, mc6843->GCR - mc6843->CTAR );
234234
235   LOG(( "%f mc6843_finish_SEK: from %i to %i (actual=%i)\n", mame_time_to_double(mame_timer_get_time()), mc6843->CTAR, mc6843->GCR, floppy_drive_get_current_track( img ) ));
235   LOG(( "%f mc6843_finish_SEK: from %i to %i (actual=%i)\n", attotime_to_double(timer_get_time()), mc6843->CTAR, mc6843->GCR, floppy_drive_get_current_track( img ) ));
236236
237237   /* update state */
238238   mc6843->CTAR = mc6843->GCR;
r1293r1294
254254      if ( ( ! floppy_drive_get_next_id( img, mc6843->side, id ) ) || ( id->flags & ID_FLAG_CRC_ERROR_IN_ID_FIELD ) || ( id->N != 0 ) )
255255      {
256256         /* read address error */
257         LOG(( "%f mc6843_address_search: get_next_id failed\n", mame_time_to_double(mame_timer_get_time()) ));
257         LOG(( "%f mc6843_address_search: get_next_id failed\n", attotime_to_double(timer_get_time()) ));
258258         mc6843->STRB |= 0x0a; /* set CRC error & Sector Address Undetected */
259259         mc6843_cmd_end();
260260         return 0;
r1293r1294
263263      if ( id->C != mc6843->LTAR )
264264      {
265265         /* track mismatch */
266         LOG(( "%f mc6843_address_search: track mismatch: logical=%i real=%i\n", mame_time_to_double(mame_timer_get_time()), mc6843->LTAR, id->C ));
266         LOG(( "%f mc6843_address_search: track mismatch: logical=%i real=%i\n", attotime_to_double(timer_get_time()), mc6843->LTAR, id->C ));
267267         mc6843->data[0] = id->C; /* make the track number available to the CPU */
268268         mc6843->STRA |= 0x20;    /* set Track Not Equal */
269269         mc6843_cmd_end();
r1293r1294
273273      if ( id->R == mc6843->SAR )
274274      {
275275         /* found! */
276         LOG(( "%f mc6843_address_search: sector %i found on track %i\n", mame_time_to_double(mame_timer_get_time()), id->R, id->C ));
276         LOG(( "%f mc6843_address_search: sector %i found on track %i\n", attotime_to_double(timer_get_time()), id->R, id->C ));
277277         if ( ! (mc6843->CMR & 0x20) )
278278         {
279279            mc6843->ISR |= 0x04; /* if no DMA, set Status Sense */
r1293r1294
287287         if ( r >= 4 )
288288         {
289289            /* time-out after 3 full revolutions */
290            LOG(( "%f mc6843_address_search: no sector %i found after 3 revolutions\n", mame_time_to_double(mame_timer_get_time()), mc6843->SAR ));
290            LOG(( "%f mc6843_address_search: no sector %i found after 3 revolutions\n", attotime_to_double(timer_get_time()), mc6843->SAR ));
291291            mc6843->STRB |= 0x08; /* set Sector Address Undetected */
292292            mc6843_cmd_end();
293293            return 0;
r1293r1294
308308
309309   if ( id->flags & ID_FLAG_CRC_ERROR_IN_DATA_FIELD )
310310   {
311      LOG(( "%f mc6843_address_search_read: data CRC error\n", mame_time_to_double(mame_timer_get_time()) ));
311      LOG(( "%f mc6843_address_search_read: data CRC error\n", attotime_to_double(timer_get_time()) ));
312312      mc6843->STRB |= 0x06; /* set CRC error & Data Mark Undetected */
313313      mc6843_cmd_end();
314314      return 0;
r1293r1294
316316
317317   if ( id->flags & ID_FLAG_DELETED_DATA )
318318   {
319      LOG(( "%f mc6843_address_search_read: deleted data\n", mame_time_to_double(mame_timer_get_time()) ));
319      LOG(( "%f mc6843_address_search_read: deleted data\n", attotime_to_double(timer_get_time()) ));
320320      mc6843->STRA |= 0x02; /* set Delete Data Mark Detected */
321321   }
322322
r1293r1294
381381{
382382   int cmd = mc6843->CMR & 0x0f;
383383
384   LOG(( "%f mc6843_cont: timer called for cmd=%s(%i)\n", mame_time_to_double(mame_timer_get_time()), mc6843_cmd[cmd], cmd ));
384   LOG(( "%f mc6843_cont: timer called for cmd=%s(%i)\n", attotime_to_double(timer_get_time()), mc6843_cmd[cmd], cmd ));
385385
386   mame_timer_adjust( mc6843->timer_cont, time_never, 0, time_never );
386   timer_adjust( mc6843->timer_cont, attotime_never, 0, attotime_never );
387387
388388   switch ( cmd )
389389   {
r1293r1294
415415      int cmd = mc6843->CMR & 0x0f;
416416
417417      LOG(( "%f $%04x mc6843_r: data input cmd=%s(%i), pos=%i/%i, GCR=%i, ",
418            mame_time_to_double(mame_timer_get_time()), activecpu_get_previouspc(),
418            attotime_to_double(timer_get_time()), activecpu_get_previouspc(),
419419            mc6843_cmd[cmd], cmd, mc6843->data_idx,
420420            mc6843->data_size, mc6843->GCR ));
421421
r1293r1294
451451               }
452452               else
453453               {
454                  mame_timer_adjust( mc6843->timer_cont, DELAY_ADDR, 0, time_never );
454                  timer_adjust( mc6843->timer_cont, DELAY_ADDR, 0, attotime_never );
455455               }
456456            }
457457            else
r1293r1294
479479   case 1: /* Current-Track Address Register (CTAR) */
480480      data = mc6843->CTAR;
481481      LOG(( "%f $%04x mc6843_r: read CTAR %i (actual=%i)\n",
482            mame_time_to_double(mame_timer_get_time()), activecpu_get_previouspc(), data,
482            attotime_to_double(timer_get_time()), activecpu_get_previouspc(), data,
483483            floppy_drive_get_current_track( mc6843_floppy_image() ) ));
484484      break;
485485
486486   case 2: /* Interrupt Status Register (ISR) */
487487      data = mc6843->ISR;
488488      LOG(( "%f $%04x mc6843_r: read ISR %02X: cmd=%scomplete settle=%scomplete sense-rq=%i STRB=%i\n",
489            mame_time_to_double(mame_timer_get_time()), activecpu_get_previouspc(), data,
489            attotime_to_double(timer_get_time()), activecpu_get_previouspc(), data,
490490            (data & 1) ? "" : "not-" , (data & 2) ? "" : "not-",
491491            (data >> 2) & 1, (data >> 3) & 1 ));
492492
r1293r1294
512512
513513      data = mc6843->STRA;
514514      LOG(( "%f $%04x mc6843_r: read STRA %02X: data-rq=%i del-dta=%i ready=%i t0=%i wp=%i trk-dif=%i idx=%i busy=%i\n",
515            mame_time_to_double(mame_timer_get_time()), activecpu_get_previouspc(), data,
515            attotime_to_double(timer_get_time()), activecpu_get_previouspc(), data,
516516            data & 1, (data >> 1) & 1, (data >> 2) & 1, (data >> 3) & 1,
517517            (data >> 4) & 1, (data >> 5) & 1, (data >> 6) & 1, (data >> 7) & 1 ));
518518      break;
r1293r1294
521521   case 4: /* Status Register B (STRB) */
522522      data = mc6843->STRB;
523523      LOG(( "%f $%04x mc6843_r: read STRB %02X: data-err=%i CRC-err=%i dta--mrk-err=%i sect-mrk-err=%i seek-err=%i fi=%i wr-err=%i hard-err=%i\n",
524            mame_time_to_double(mame_timer_get_time()), activecpu_get_previouspc(), data,
524            attotime_to_double(timer_get_time()), activecpu_get_previouspc(), data,
525525            data & 1, (data >> 1) & 1, (data >> 2) & 1, (data >> 3) & 1,
526526            (data >> 4) & 1, (data >> 5) & 1, (data >> 6) & 1, (data >> 7) & 1 ));
527527
r1293r1294
533533   case 7: /* Logical-Track Address Register (LTAR) */
534534      data = mc6843->LTAR;
535535      LOG(( "%f $%04x mc6843_r: read LTAR %i (actual=%i)\n",
536            mame_time_to_double(mame_timer_get_time()), activecpu_get_previouspc(), data,
536            attotime_to_double(timer_get_time()), activecpu_get_previouspc(), data,
537537            floppy_drive_get_current_track( mc6843_floppy_image() ) ));
538538      break;
539539
r1293r1294
554554      int FWF = (mc6843->CMR >> 4) & 1;
555555
556556      LOG(( "%f $%04x mc6843_w: data output cmd=%s(%i), pos=%i/%i, GCR=%i, data=%02X\n",
557            mame_time_to_double(mame_timer_get_time()), activecpu_get_previouspc(),
557            attotime_to_double(timer_get_time()), activecpu_get_previouspc(),
558558            mc6843_cmd[cmd], cmd, mc6843->data_idx,
559559            mc6843->data_size, mc6843->GCR, data ));
560560
r1293r1294
571571            /* end of sector write */
572572            mess_image* img = mc6843_floppy_image();
573573
574            LOG(( "%f $%04x mc6843_w: write sector %i\n", mame_time_to_double(mame_timer_get_time()), activecpu_get_previouspc(), mc6843->data_id ));
574            LOG(( "%f $%04x mc6843_w: write sector %i\n", attotime_to_double(timer_get_time()), activecpu_get_previouspc(), mc6843->data_id ));
575575
576576            floppy_drive_write_sector_data(
577577               img, mc6843->side, mc6843->data_id,
r1293r1294
596596               }
597597               else
598598               {
599                  mame_timer_adjust( mc6843->timer_cont, DELAY_ADDR, 0, time_never );
599                  timer_adjust( mc6843->timer_cont, DELAY_ADDR, 0, attotime_never );
600600               }
601601            }
602602            else
r1293r1294
635635               UINT8 track  = mc6843->data[1];
636636               UINT8 sector = mc6843->data[3];
637637               UINT8 filler = 0xe5; /* standard Thomson filler */
638               LOG(( "%f $%04x mc6843_w: address id detected track=%i sector=%i\n", mame_time_to_double(mame_timer_get_time()), activecpu_get_previouspc(), track, sector));
638               LOG(( "%f $%04x mc6843_w: address id detected track=%i sector=%i\n", attotime_to_double(timer_get_time()), activecpu_get_previouspc(), track, sector));
639639               floppy_drive_format_sector( img, mc6843->side, sector, track, 0, sector, 0, filler );
640640            }
641641            else
r1293r1294
665665   case 1: /* Current-Track Address Register (CTAR) */
666666      mc6843->CTAR = data & 0x7f;
667667      LOG(( "%f $%04x mc6843_w: set CTAR to %i %02X (actual=%i) \n",
668            mame_time_to_double(mame_timer_get_time()), activecpu_get_previouspc(), mc6843->CTAR, data,
668            attotime_to_double(timer_get_time()), activecpu_get_previouspc(), mc6843->CTAR, data,
669669            floppy_drive_get_current_track( mc6843_floppy_image() ) ));
670670      break;
671671
r1293r1294
674674      int cmd = data & 15;
675675
676676      LOG(( "%f $%04x mc6843_w: set CMR to $%02X: cmd=%s(%i) FWF=%i DMA=%i ISR3-intr=%i fun-intr=%i\n",
677            mame_time_to_double(mame_timer_get_time()), activecpu_get_previouspc(),
677            attotime_to_double(timer_get_time()), activecpu_get_previouspc(),
678678            data, mc6843_cmd[cmd], cmd, (data >> 4) & 1, (data >> 5) & 1,
679679            (data >> 6) & 1, (data >> 7) & 1 ));
680680
r1293r1294
697697         mc6843->STRA |=  0x80; /* set Busy */
698698         mc6843->STRA &= ~0x22; /* clear Track Not Equal & Delete Data Mark Detected */
699699         mc6843->STRB &= ~0x04; /* clear Data Mark Undetected */
700         mame_timer_adjust( mc6843->timer_cont, DELAY_ADDR, 0, time_never );
700         timer_adjust( mc6843->timer_cont, DELAY_ADDR, 0, attotime_never );
701701         break;
702702      case CMD_STZ:
703703      case CMD_SEK:
704704         mc6843->STRA |= 0x80; /* set Busy */
705         mame_timer_adjust( mc6843->timer_cont, DELAY_SEEK, 0, time_never );
705         timer_adjust( mc6843->timer_cont, DELAY_SEEK, 0, attotime_never );
706706         break;
707707      case CMD_FFW:
708708      case CMD_FFR:
r1293r1294
721721
722722      /* assume CLK freq = 1MHz (IBM 3740 compatibility) */
723723      LOG(( "%f $%04x mc6843_w: set SUR to $%02X: head settling time=%fms, track-to-track seek time=%f\n",
724            mame_time_to_double(mame_timer_get_time()), activecpu_get_previouspc(),
724            attotime_to_double(timer_get_time()), activecpu_get_previouspc(),
725725            data, 4.096 * (data & 15), 1.024 * ((data >> 4) & 15) ));
726726      break;
727727
728728   case 4: /* Sector Address Register (SAR) */
729729      mc6843->SAR = data & 0x1f;
730      LOG(( "%f $%04x mc6843_w: set SAR to %i (%02X)\n", mame_time_to_double(mame_timer_get_time()), activecpu_get_previouspc(), mc6843->SAR, data ));
730      LOG(( "%f $%04x mc6843_w: set SAR to %i (%02X)\n", attotime_to_double(timer_get_time()), activecpu_get_previouspc(), mc6843->SAR, data ));
731731      break;
732732
733733   case 5: /* General Count Register (GCR) */
734734      mc6843->GCR = data & 0x7f;
735      LOG(( "%f $%04x mc6843_w: set GCR to %i (%02X)\n", mame_time_to_double(mame_timer_get_time()), activecpu_get_previouspc(), mc6843->GCR, data ));
735      LOG(( "%f $%04x mc6843_w: set GCR to %i (%02X)\n", attotime_to_double(timer_get_time()), activecpu_get_previouspc(), mc6843->GCR, data ));
736736      break;
737737
738738   case 6: /* CRC Control Register (CCR) */
739739      mc6843->CCR = data & 3;
740740      LOG(( "%f $%04x mc6843_w: set CCR to %02X: CRC=%s shift=%i\n",
741            mame_time_to_double(mame_timer_get_time()), activecpu_get_previouspc(), data,
741            attotime_to_double(timer_get_time()), activecpu_get_previouspc(), data,
742742            (data & 1) ? "enabled" : "disabled", (data >> 1) & 1 ));
743743      break;
744744
745745   case 7: /* Logical-Track Address Register (LTAR) */
746746      mc6843->LTAR = data & 0x7f;
747747      LOG(( "%f $%04x mc6843_w: set LTAR to %i %02X (actual=%i)\n",
748            mame_time_to_double(mame_timer_get_time()), activecpu_get_previouspc(), mc6843->LTAR, data,
748            attotime_to_double(timer_get_time()), activecpu_get_previouspc(), mc6843->LTAR, data,
749749            floppy_drive_get_current_track( mc6843_floppy_image() ) ));
750750      break;
751751     
r1293r1294
785785
786786   mc6843->data_size = 0;
787787   mc6843->data_idx = 0;
788   mame_timer_adjust( mc6843->timer_cont, time_never, 0, time_never );
788   timer_adjust( mc6843->timer_cont, attotime_never, 0, attotime_never );
789789}
790790
791791
r1293r1294
801801   assert( mc6843 );
802802   memset( mc6843, 0, sizeof( * mc6843 ) );
803803   mc6843->iface = iface;
804   mc6843->timer_cont = mame_timer_alloc( mc6843_cont );
804   mc6843->timer_cont = timer_alloc( mc6843_cont );
805805
806806   state_save_register_item( "mc6843", 0, mc6843->CTAR );
807807   state_save_register_item( "mc6843", 0, mc6843->CMR );
src/mess/machine/mm58274c.c
r1293r1294
7171   int_ctl_dly = 0x7      /* 0 no interrupt, 1 = .1 second, 2=.5, 3=1, 4=5, 5=10, 6=30, 7=60 */
7272};
7373
74static mame_time interrupt_period_table(int val)
74static attotime interrupt_period_table(int val)
7575{
7676   switch(val)
7777   {
78      case 0:   return MAME_TIME_IN_MSEC(0);
79      case 1:   return MAME_TIME_IN_MSEC(100);
80      case 2:   return MAME_TIME_IN_MSEC(500);
81      case 3:   return MAME_TIME_IN_SEC(1);
82      case 4:   return MAME_TIME_IN_SEC(5);
83      case 5:   return MAME_TIME_IN_SEC(10);
84      case 6:   return MAME_TIME_IN_SEC(30);
85      case 7:   return MAME_TIME_IN_SEC(60);
78      case 0:   return ATTOTIME_IN_MSEC(0);
79      case 1:   return ATTOTIME_IN_MSEC(100);
80      case 2:   return ATTOTIME_IN_MSEC(500);
81      case 3:   return ATTOTIME_IN_SEC(1);
82      case 4:   return ATTOTIME_IN_SEC(5);
83      case 5:   return ATTOTIME_IN_SEC(10);
84      case 6:   return ATTOTIME_IN_SEC(30);
85      case 7:   return ATTOTIME_IN_SEC(60);
8686      default: fatalerror("out of range");
8787   }
8888};
r1293r1294
9292{
9393   memset(&rtc[which], 0, sizeof(rtc[which]));
9494
95   mame_timer_pulse(MAME_TIME_IN_MSEC(100), which, increment_rtc);
96   rtc[which].interrupt_timer = mame_timer_alloc(rtc_interrupt_callback);
95   timer_pulse(ATTOTIME_IN_MSEC(100), which, increment_rtc);
96   rtc[which].interrupt_timer = timer_alloc(rtc_interrupt_callback);
9797
9898   {
9999      mame_system_time systime;
r1293r1294
239239   case 0x0:   /* Control Register (test mode and interrupt not emulated) */
240240      if ((! (rtc[which].control & ctl_intstop)) && (data & ctl_intstop))
241241         /* interrupt stop */
242         mame_timer_enable(rtc[which].interrupt_timer, 0);
242         timer_enable(rtc[which].interrupt_timer, 0);
243243      else if ((rtc[which].control & ctl_intstop) && (! (data & ctl_intstop)))
244244      {
245245         /* interrupt run */
246         mame_time period = interrupt_period_table(rtc[which].int_ctl & int_ctl_dly);
246         attotime period = interrupt_period_table(rtc[which].int_ctl & int_ctl_dly);
247247
248         mame_timer_adjust(rtc[which].interrupt_timer, period, which, rtc[which].int_ctl & int_ctl_rpt ? period : time_zero);
248         timer_adjust(rtc[which].interrupt_timer, period, which, rtc[which].int_ctl & int_ctl_rpt ? period : attotime_zero);
249249      }
250250      if (data & ctl_clkstop)
251251         /* stopping the clock clears the tenth counter */
r1293r1294
316316         if (! (rtc[which].control & ctl_intstop))
317317         {
318318            /* interrupt run */
319            mame_time period = interrupt_period_table(rtc[which].int_ctl & int_ctl_dly);
319            attotime period = interrupt_period_table(rtc[which].int_ctl & int_ctl_dly);
320320
321            mame_timer_adjust(rtc[which].interrupt_timer, period, which, rtc[which].int_ctl & int_ctl_rpt ? period : time_zero);
321            timer_adjust(rtc[which].interrupt_timer, period, which, rtc[which].int_ctl & int_ctl_rpt ? period : attotime_zero);
322322         }
323323      }
324324      else
src/mess/machine/ibmpc.c
r1293r1294
1111
1212#if VERBOSE_DBG
1313#define DBG_LOG(N,M,A) \
14   if(VERBOSE_DBG>=N){ if( M )logerror("%11.6f: %-24s",mame_timer_get_time(),(char*)M ); logerror A; }
14   if(VERBOSE_DBG>=N){ if( M )logerror("%11.6f: %-24s",timer_get_time(),(char*)M ); logerror A; }
1515#else
1616#define DBG_LOG(n,m,a)
1717#endif
1818
1919#if VERBOSE_PIO
2020#define PIO_LOG(N,M,A) \
21   if(VERBOSE_PIO>=N){ if( M )logerror("%11.6f: %-24s",mame_timer_get_time(),(char*)M ); logerror A; }
21   if(VERBOSE_PIO>=N){ if( M )logerror("%11.6f: %-24s",timer_get_time(),(char*)M ); logerror A; }
2222#else
2323#define PIO_LOG(n,m,a)
2424#endif
r1293r1294
198198// will do more when I have a program supporting it
199199static struct {
200200   int data[0x18];
201   mame_timer *timer;
201   emu_timer *timer;
202202} pc_rtc;
203203
204204static TIMER_CALLBACK(pc_rtc_timer)
r1293r1294
227227void pc_rtc_init(void)
228228{
229229   memset(&pc_rtc,0,sizeof(pc_rtc));
230   pc_rtc.timer = mame_timer_alloc(pc_rtc_timer);
231   mame_timer_adjust(pc_rtc.timer, time_zero, 0, make_mame_time(1, 0));
230   pc_rtc.timer = timer_alloc(pc_rtc_timer);
231   timer_adjust(pc_rtc.timer, attotime_zero, 0, attotime_make(1, 0));
232232}
233233
234234READ8_HANDLER( pc_rtc_r )
src/mess/machine/68901mfp.c
r1293r1294
4545
4646   UINT16 ier, ipr, isr, imr;
4747   UINT8 vr;
48   mame_timer *irq_timer;
48   emu_timer *irq_timer;
4949
5050   UINT8 tacr, tbcr, tcdcr;
5151   UINT8 tdr[MFP68901_MAX_TIMERS];
5252   UINT8 tmc[MFP68901_MAX_TIMERS];
5353   int to[MFP68901_MAX_TIMERS];
5454   int ti[MFP68901_MAX_TIMERS];
55   mame_timer *timer[MFP68901_MAX_TIMERS];
55   emu_timer *timer[MFP68901_MAX_TIMERS];
5656
5757   UINT8 ucr;
5858   UINT8 udr;
r1293r1294
6464   int   rx_state, tx_state, xmit_state;
6565   int rxtx_word, rxtx_start, rxtx_stop;
6666
67   mame_timer *rx_timer, *tx_timer;
67   emu_timer *rx_timer, *tx_timer;
6868} mfp_68901;
6969
7070static mfp_68901 mfp[MAX_MFP];
r1293r1294
632632      {
633633      case MFP68901_TCR_TIMER_STOPPED:
634634         logerror("MFP68901 #%u Timer A Stopped\n", which);
635         mame_timer_enable(mfp_p->timer[MFP68901_TIMER_A], 0);
635         timer_enable(mfp_p->timer[MFP68901_TIMER_A], 0);
636636         break;
637637
638638      case MFP68901_TCR_TIMER_DELAY_4:
r1293r1294
645645         {
646646         int divisor = PRESCALER[mfp_p->tacr & 0x07];
647647         logerror("MFP68901 #%u Timer A Delay Mode : %u Prescale\n", which, divisor);
648         mame_timer_adjust(mfp_p->timer[MFP68901_TIMER_A], MAME_TIME_IN_HZ(mfp_p->intf->timer_clock / divisor), which, MAME_TIME_IN_HZ(mfp_p->intf->timer_clock / divisor));
648         timer_adjust(mfp_p->timer[MFP68901_TIMER_A], ATTOTIME_IN_HZ(mfp_p->intf->timer_clock / divisor), which, ATTOTIME_IN_HZ(mfp_p->intf->timer_clock / divisor));
649649         }
650650         break;
651651
652652      case MFP68901_TCR_TIMER_EVENT:
653653         logerror("MFP68901 #%u Timer A Event Count Mode\n", which);
654         mame_timer_enable(mfp_p->timer[MFP68901_TIMER_A], 0);
654         timer_enable(mfp_p->timer[MFP68901_TIMER_A], 0);
655655         break;
656656
657657      case MFP68901_TCR_TIMER_PULSE_4:
r1293r1294
664664         {
665665         int divisor = PRESCALER[mfp_p->tacr & 0x07];
666666         logerror("MFP68901 #%u Timer A Pulse Width Mode : %u Prescale\n", which, divisor);
667         mame_timer_adjust(mfp_p->timer[MFP68901_TIMER_A], time_never, which, MAME_TIME_IN_HZ(mfp_p->intf->timer_clock / divisor));
668         mame_timer_enable(mfp_p->timer[MFP68901_TIMER_A], 0);
667         timer_adjust(mfp_p->timer[MFP68901_TIMER_A], attotime_never, which, ATTOTIME_IN_HZ(mfp_p->intf->timer_clock / divisor));
668         timer_enable(mfp_p->timer[MFP68901_TIMER_A], 0);
669669         }
670670         break;
671671      }
r1293r1294
690690      {
691691      case MFP68901_TCR_TIMER_STOPPED:
692692         logerror("MFP68901 #%u Timer B Stopped\n", which);
693         mame_timer_enable(mfp_p->timer[MFP68901_TIMER_B], 0);
693         timer_enable(mfp_p->timer[MFP68901_TIMER_B], 0);
694694         break;
695695
696696      case MFP68901_TCR_TIMER_DELAY_4:
r1293r1294
703703         {
704704         int divisor = PRESCALER[mfp_p->tbcr & 0x07];
705705         logerror("MFP68901 #%u Timer B Delay Mode : %u Prescale\n", which, divisor);
706         mame_timer_adjust(mfp_p->timer[MFP68901_TIMER_B], MAME_TIME_IN_HZ(mfp_p->intf->timer_clock / divisor), which, MAME_TIME_IN_HZ(mfp_p->intf->timer_clock / divisor));
706         timer_adjust(mfp_p->timer[MFP68901_TIMER_B], ATTOTIME_IN_HZ(mfp_p->intf->timer_clock / divisor), which, ATTOTIME_IN_HZ(mfp_p->intf->timer_clock / divisor));
707707         }
708708         break;
709709
710710      case MFP68901_TCR_TIMER_EVENT:
711711         logerror("MFP68901 #%u Timer B Event Count Mode\n", which);
712         mame_timer_enable(mfp_p->timer[MFP68901_TIMER_B], 0);
712         timer_enable(mfp_p->timer[MFP68901_TIMER_B], 0);
713713         break;
714714
715715      case MFP68901_TCR_TIMER_PULSE_4:
r1293r1294
722722         {
723723         int divisor = PRESCALER[mfp_p->tbcr & 0x07];
724724         logerror("MFP68901 #%u Timer B Pulse Width Mode : %u Prescale\n", which, DIVISOR);
725         mame_timer_adjust(mfp_p->timer[MFP68901_TIMER_B], time_never, which, MAME_TIME_IN_HZ(mfp_p->intf->timer_clock / divisor));
726         mame_timer_enable(mfp_p->timer[MFP68901_TIMER_B], 0);
725         timer_adjust(mfp_p->timer[MFP68901_TIMER_B], attotime_never, which, ATTOTIME_IN_HZ(mfp_p->intf->timer_clock / divisor));
726         timer_enable(mfp_p->timer[MFP68901_TIMER_B], 0);
727727         }
728728         break;
729729      }
r1293r1294
748748      {
749749      case MFP68901_TCR_TIMER_STOPPED:
750750         logerror("MFP68901 #%u Timer D Stopped\n", which);
751         mame_timer_enable(mfp_p->timer[MFP68901_TIMER_D], 0);
751         timer_enable(mfp_p->timer[MFP68901_TIMER_D], 0);
752752         break;
753753
754754      case MFP68901_TCR_TIMER_DELAY_4:
r1293r1294
761761         {
762762         int divisor = PRESCALER[mfp_p->tcdcr & 0x07];
763763         logerror("MFP68901 #%u Timer D Delay Mode : %u Prescale\n", which, divisor);
764         mame_timer_adjust(mfp_p->timer[MFP68901_TIMER_D], MAME_TIME_IN_HZ(mfp_p->intf->timer_clock / divisor), which, MAME_TIME_IN_HZ(mfp_p->intf->timer_clock / divisor));
764         timer_adjust(mfp_p->timer[MFP68901_TIMER_D], ATTOTIME_IN_HZ(mfp_p->intf->timer_clock / divisor), which, ATTOTIME_IN_HZ(mfp_p->intf->timer_clock / divisor));
765765         }
766766         break;
767767      }
r1293r1294
770770      {
771771      case MFP68901_TCR_TIMER_STOPPED:
772772         logerror("MFP68901 #%u Timer C Stopped\n", which);
773         mame_timer_enable(mfp_p->timer[MFP68901_TIMER_C], 0);
773         timer_enable(mfp_p->timer[MFP68901_TIMER_C], 0);
774774         break;
775775
776776      case MFP68901_TCR_TIMER_DELAY_4:
r1293r1294
783783         {
784784         int divisor = PRESCALER[(mfp_p->tcdcr >> 4) & 0x07];
785785         logerror("MFP68901 #%u Timer C Delay Mode : %u Prescale\n", which, divisor);
786         mame_timer_adjust(mfp_p->timer[MFP68901_TIMER_C], MAME_TIME_IN_HZ(mfp_p->intf->timer_clock / divisor), which, MAME_TIME_IN_HZ(mfp_p->intf->timer_clock / divisor));
786         timer_adjust(mfp_p->timer[MFP68901_TIMER_C], ATTOTIME_IN_HZ(mfp_p->intf->timer_clock / divisor), which, ATTOTIME_IN_HZ(mfp_p->intf->timer_clock / divisor));
787787         }
788788         break;
789789      }
r1293r1294
794794
795795      mfp_p->tdr[MFP68901_TIMER_A] = data;
796796
797      if (!mame_timer_enabled(mfp_p->timer[MFP68901_TIMER_A]))
797      if (!timer_enabled(mfp_p->timer[MFP68901_TIMER_A]))
798798      {
799799         mfp_p->tmc[MFP68901_TIMER_A] = data;
800800      }
r1293r1294
805805
806806      mfp_p->tdr[MFP68901_TIMER_B] = data;
807807
808      if (!mame_timer_enabled(mfp_p->timer[MFP68901_TIMER_B]))
808      if (!timer_enabled(mfp_p->timer[MFP68901_TIMER_B]))
809809      {
810810         mfp_p->tmc[MFP68901_TIMER_B] = data;
811811      }
r1293r1294
816816
817817      mfp_p->tdr[MFP68901_TIMER_C] = data;
818818
819      if (!mame_timer_enabled(mfp_p->timer[MFP68901_TIMER_C]))
819      if (!timer_enabled(mfp_p->timer[MFP68901_TIMER_C]))
820820      {
821821         mfp_p->tmc[MFP68901_TIMER_C] = data;
822822      }
r1293r1294
827827
828828      mfp_p->tdr[MFP68901_TIMER_D] = data;
829829
830      if (!mame_timer_enabled(mfp_p->timer[MFP68901_TIMER_D]))
830      if (!timer_enabled(mfp_p->timer[MFP68901_TIMER_D]))
831831      {
832832         mfp_p->tmc[MFP68901_TIMER_D] = data;
833833      }
r1293r1294
988988      {
989989         if (mfp_p->intf->rx_clock == MFP68901_LOOPBACK_TIMER[index])
990990         {
991            mame_timer_adjust(mfp_p->rx_timer, time_zero, which, time_never);
991            timer_adjust(mfp_p->rx_timer, attotime_zero, which, attotime_never);
992992         }
993993
994994         if (mfp_p->intf->tx_clock == MFP68901_LOOPBACK_TIMER[index])
995995         {
996            mame_timer_adjust(mfp_p->tx_timer, time_zero, which, time_never);
996            timer_adjust(mfp_p->tx_timer, attotime_zero, which, attotime_never);
997997         }
998998      }
999999
r1293r1294
10401040   case MFP68901_TCR_TIMER_PULSE_64:
10411041   case MFP68901_TCR_TIMER_PULSE_100:
10421042   case MFP68901_TCR_TIMER_PULSE_200:
1043      mame_timer_enable(mfp_p->timer[index], (value == aer) ? 1 : 0);
1043      timer_enable(mfp_p->timer[index], (value == aer) ? 1 : 0);
10441044
10451045      if (((mfp_p->ti[index] ^ aer) == 0) && ((value ^ aer) == 1))
10461046      {
r1293r1294
11501150
11511151   mfp_p->intf = intf;
11521152
1153   mfp_p->timer[MFP68901_TIMER_A] = mame_timer_alloc(timer_a);
1154   mfp_p->timer[MFP68901_TIMER_B] = mame_timer_alloc(timer_b);
1155   mfp_p->timer[MFP68901_TIMER_C] = mame_timer_alloc(timer_c);
1156   mfp_p->timer[MFP68901_TIMER_D] = mame_timer_alloc(timer_d);
1153   mfp_p->timer[MFP68901_TIMER_A] = timer_alloc(timer_a);
1154   mfp_p->timer[MFP68901_TIMER_B] = timer_alloc(timer_b);
1155   mfp_p->timer[MFP68901_TIMER_C] = timer_alloc(timer_c);
1156   mfp_p->timer[MFP68901_TIMER_D] = timer_alloc(timer_d);
11571157
1158   mfp_p->rx_timer = mame_timer_alloc(rx_tick);
1158   mfp_p->rx_timer = timer_alloc(rx_tick);
11591159   
11601160   if (mfp_p->intf->rx_clock > 0)
11611161   {
1162      mame_timer_adjust(mfp_p->rx_timer, time_zero, which, MAME_TIME_IN_HZ(mfp_p->intf->rx_clock));
1162      timer_adjust(mfp_p->rx_timer, attotime_zero, which, ATTOTIME_IN_HZ(mfp_p->intf->rx_clock));
11631163   }
11641164   
1165   mfp_p->tx_timer = mame_timer_alloc(tx_tick);
1165   mfp_p->tx_timer = timer_alloc(tx_tick);
11661166
11671167   if (mfp_p->intf->tx_clock > 0)
11681168   {
1169      mame_timer_adjust(mfp_p->tx_timer, time_zero, which, MAME_TIME_IN_HZ(mfp_p->intf->tx_clock));
1169      timer_adjust(mfp_p->tx_timer, attotime_zero, which, ATTOTIME_IN_HZ(mfp_p->intf->tx_clock));
11701170   }
11711171
1172   mfp_p->irq_timer = mame_timer_alloc(mfp68901_tick);
1173   mame_timer_adjust(mfp_p->irq_timer, time_zero, which, MAME_TIME_IN_HZ(mfp_p->intf->chip_clock / 4));
1172   mfp_p->irq_timer = timer_alloc(mfp68901_tick);
1173   timer_adjust(mfp_p->irq_timer, attotime_zero, which, ATTOTIME_IN_HZ(mfp_p->intf->chip_clock / 4));
11741174
11751175   state_save_register_item("mfp68901", which, mfp_p->gpip);
11761176   state_save_register_item("mfp68901", which, mfp_p->aer);
src/mess/machine/cbmdrive.c
r1293r1294
676676#endif
677677}
678678
679static int vc1541_time_greater(CBM_Drive * vc1541, mame_time threshold)
679static int vc1541_time_greater(CBM_Drive * vc1541, attotime threshold)
680680{
681   return compare_mame_times(
682      sub_mame_times(mame_timer_get_time (), vc1541->i.serial.time),
681   return attotime_compare(
682      attotime_sub(timer_get_time (), vc1541->i.serial.time),
683683      threshold) > 0;
684684}
685685
r1293r1294
719719         vc1541->i.serial.state = 100;
720720         vc1541->i.serial.last = 0;
721721         vc1541->i.serial.value = 0;
722         vc1541->i.serial.time = mame_timer_get_time ();
722         vc1541->i.serial.time = timer_get_time ();
723723         break;
724724      }
725725      break;
r1293r1294
731731         vc1541->i.serial.state = 100;
732732         vc1541->i.serial.last = 0;
733733         vc1541->i.serial.value = 0;
734         vc1541->i.serial.time = mame_timer_get_time ();
734         vc1541->i.serial.time = timer_get_time ();
735735         break;
736736      }
737737      break;
r1293r1294
843843         {
844844            cbm_command (vc1541);
845845         }
846         vc1541->i.serial.time = mame_timer_get_time ();
846         vc1541->i.serial.time = timer_get_time ();
847847         vc1541->i.serial.data = 0;
848848         break;
849849      }
r1293r1294
873873      }
874874      if (cbm_serial.clock[0])
875875      {
876         vc1541->i.serial.time = mame_timer_get_time ();
876         vc1541->i.serial.time = timer_get_time ();
877877         vc1541->i.serial.broadcast = !cbm_serial.atn[0];
878878         vc1541->i.serial.data = 1;
879879         vc1541->i.serial.value = 0;
r1293r1294
891891         vc1541->i.serial.data = 1;
892892         break;
893893      }
894      if (vc1541_time_greater(vc1541, MAME_TIME_IN_USEC(200)))
894      if (vc1541_time_greater(vc1541, ATTOTIME_IN_USEC(200)))
895895      {
896896         vc1541->i.serial.data = 0;
897897         vc1541->i.serial.last = 1;
898898         vc1541->i.serial.state++;
899         vc1541->i.serial.time = mame_timer_get_time ();
899         vc1541->i.serial.time = timer_get_time ();
900900         break;
901901      }
902902      break;
903903   case 119:
904      if (vc1541_time_greater(vc1541, MAME_TIME_IN_USEC(60)))
904      if (vc1541_time_greater(vc1541, ATTOTIME_IN_USEC(60)))
905905      {
906906         vc1541->i.serial.value = 0;
907907         vc1541->i.serial.data = 1;
r1293r1294
911911      break;
912912
913913   case 130:                     /* last byte of talk */
914      if (vc1541_time_greater(vc1541, MAME_TIME_IN_USEC(60)))
914      if (vc1541_time_greater(vc1541, ATTOTIME_IN_USEC(60)))
915915      {
916916         vc1541->i.serial.data = 1;
917917         vc1541->i.serial.state = 0;
r1293r1294
937937      if (cbm_serial.atn[0])
938938      {
939939         vc1541->i.serial.state++;
940         vc1541->i.serial.time = mame_timer_get_time ();
940         vc1541->i.serial.time = timer_get_time ();
941941         break;
942942      }
943943      break;
944944   case 151:
945      if (vc1541_time_greater(vc1541, MAME_TIME_IN_USEC(1000)))
945      if (vc1541_time_greater(vc1541, ATTOTIME_IN_USEC(1000)))
946946      {
947947         vc1541->i.serial.state++;
948948         vc1541->i.serial.clock = 0;
949         vc1541->i.serial.time = mame_timer_get_time ();
949         vc1541->i.serial.time = timer_get_time ();
950950         break;
951951      }
952952      break;
953953   case 152:
954      if (vc1541_time_greater(vc1541, MAME_TIME_IN_USEC(50)))
954      if (vc1541_time_greater(vc1541, ATTOTIME_IN_USEC(50)))
955955      {
956956         vc1541->i.serial.state++;
957957         vc1541->i.serial.clock = 1;
r1293r1294
969969      if (cbm_serial.atn[0])
970970      {
971971         vc1541->i.serial.state = 0;
972         vc1541->i.serial.time = mame_timer_get_time ();
972         vc1541->i.serial.time = timer_get_time ();
973973         break;
974974      }
975975      break;
r1293r1294
979979      {
980980         vc1541->i.serial.state++;
981981         vc1541->i.serial.clock = 0;
982         vc1541->i.serial.time = mame_timer_get_time ();
982         vc1541->i.serial.time = timer_get_time ();
983983         break;
984984      }
985985      break;
986986   case 201:
987      if (vc1541_time_greater(vc1541, MAME_TIME_IN_USEC(80)))
987      if (vc1541_time_greater(vc1541, ATTOTIME_IN_USEC(80)))
988988      {
989989         vc1541->i.serial.clock = 1;
990990         vc1541->i.serial.data = 1;
r1293r1294
10071007         vc1541->i.serial.clock = 0;
10081008         vc1541->i.serial.data = (vc1541->i.serial.value & 1) ? 1 : 0;
10091009         vc1541->i.serial.state++;
1010         vc1541->i.serial.time = mame_timer_get_time ();
1010         vc1541->i.serial.time = timer_get_time ();
10111011         break;
10121012      }
10131013      break;
r1293r1294
10191019         vc1541->i.serial.clock = 1;
10201020         break;
10211021      }
1022      if (vc1541_time_greater(vc1541, MAME_TIME_IN_USEC(40)))
1022      if (vc1541_time_greater(vc1541, ATTOTIME_IN_USEC(40)))
10231023      {
10241024         vc1541->i.serial.clock = 1;
10251025         vc1541->i.serial.state++;
1026         vc1541->i.serial.time = mame_timer_get_time ();
1026         vc1541->i.serial.time = timer_get_time ();
10271027         break;
10281028      }
10291029      break;
r1293r1294
10411041         vc1541->i.serial.clock = 1;
10421042         break;
10431043      }
1044      if (vc1541_time_greater(vc1541, MAME_TIME_IN_USEC(20)))
1044      if (vc1541_time_greater(vc1541, ATTOTIME_IN_USEC(20)))
10451045      {
10461046         vc1541->i.serial.clock = 1;
10471047         vc1541->i.serial.state++;
1048         vc1541->i.serial.time = mame_timer_get_time ();
1048         vc1541->i.serial.time = timer_get_time ();
10491049         break;
10501050      }
10511051      break;
r1293r1294
10571057         vc1541->i.serial.clock = 1;
10581058         break;
10591059      }
1060      if (vc1541_time_greater(vc1541, MAME_TIME_IN_USEC(20)))
1060      if (vc1541_time_greater(vc1541, ATTOTIME_IN_USEC(20)))
10611061      {
10621062         vc1541->i.serial.data = vc1541->i.serial.value & 2 ? 1 : 0;
10631063         vc1541->i.serial.clock = 0;
10641064         vc1541->i.serial.state++;
1065         vc1541->i.serial.time = mame_timer_get_time ();
1065         vc1541->i.serial.time = timer_get_time ();
10661066         break;
10671067      }
10681068      break;
r1293r1294
10741074         vc1541->i.serial.clock = 1;
10751075         break;
10761076      }
1077      if (vc1541_time_greater(vc1541, MAME_TIME_IN_USEC(20)))
1077      if (vc1541_time_greater(vc1541, ATTOTIME_IN_USEC(20)))
10781078      {
10791079         vc1541->i.serial.data = vc1541->i.serial.value & 4 ? 1 : 0;
10801080         vc1541->i.serial.clock = 0;
10811081         vc1541->i.serial.state++;
1082         vc1541->i.serial.time = mame_timer_get_time ();
1082         vc1541->i.serial.time = timer_get_time ();
10831083         break;
10841084      }
10851085      break;
r1293r1294
10911091         vc1541->i.serial.clock = 1;
10921092         break;
10931093      }
1094      if (vc1541_time_greater(vc1541, MAME_TIME_IN_USEC(20)))
1094      if (vc1541_time_greater(vc1541, ATTOTIME_IN_USEC(20)))
10951095      {
10961096         vc1541->i.serial.data = vc1541->i.serial.value & 8 ? 1 : 0;
10971097         vc1541->i.serial.clock = 0;
10981098         vc1541->i.serial.state++;
1099         vc1541->i.serial.time = mame_timer_get_time ();
1099         vc1541->i.serial.time = timer_get_time ();
11001100         break;
11011101      }
11021102      break;
r1293r1294
11081108         vc1541->i.serial.clock = 1;
11091109         break;
11101110      }
1111      if (vc1541_time_greater(vc1541, MAME_TIME_IN_USEC(20)))
1111      if (vc1541_time_greater(vc1541, ATTOTIME_IN_USEC(20)))
11121112      {
11131113         vc1541->i.serial.data = vc1541->i.serial.value & 0x10 ? 1 : 0;
11141114         vc1541->i.serial.clock = 0;
11151115         vc1541->i.serial.state++;
1116         vc1541->i.serial.time = mame_timer_get_time ();
1116         vc1541->i.serial.time = timer_get_time ();
11171117         break;
11181118      }
11191119      break;
r1293r1294
11251125         vc1541->i.serial.clock = 1;
11261126         break;
11271127      }
1128      if (vc1541_time_greater(vc1541, MAME_TIME_IN_USEC(20)))
1128      if (vc1541_time_greater(vc1541, ATTOTIME_IN_USEC(20)))
11291129      {
11301130         vc1541->i.serial.data = vc1541->i.serial.value & 0x20 ? 1 : 0;
11311131         vc1541->i.serial.clock = 0;
11321132         vc1541->i.serial.state++;
1133         vc1541->i.serial.time = mame_timer_get_time ();
1133         vc1541->i.serial.time = timer_get_time ();
11341134         break;
11351135      }
11361136      break;
r1293r1294
11421142         vc1541->i.serial.clock = 1;
11431143         break;
11441144      }
1145      if (vc1541_time_greater(vc1541, MAME_TIME_IN_USEC(20)))
1145      if (vc1541_time_greater(vc1541, ATTOTIME_IN_USEC(20)))
11461146      {
11471147         vc1541->i.serial.data = vc1541->i.serial.value & 0x40 ? 1 : 0;
11481148         vc1541->i.serial.clock = 0;
11491149         vc1541->i.serial.state++;
1150         vc1541->i.serial.time = mame_timer_get_time ();
1150         vc1541->i.serial.time = timer_get_time ();
11511151         break;
11521152      }
11531153      break;
r1293r1294
11591159         vc1541->i.serial.clock = 1;
11601160         break;
11611161      }
1162      if (vc1541_time_greater(vc1541, MAME_TIME_IN_USEC(20)))
1162      if (vc1541_time_greater(vc1541, ATTOTIME_IN_USEC(20)))
11631163      {
11641164         vc1541->i.serial.data = vc1541->i.serial.value & 0x80 ? 1 : 0;
11651165         vc1541->i.serial.clock = 0;
11661166         vc1541->i.serial.state++;
1167         vc1541->i.serial.time = mame_timer_get_time ();
1167         vc1541->i.serial.time = timer_get_time ();
11681168         break;
11691169      }
11701170      break;
r1293r1294
11761176         vc1541->i.serial.clock = 1;
11771177         break;
11781178      }
1179      if (vc1541_time_greater(vc1541, MAME_TIME_IN_USEC(20)))
1179      if (vc1541_time_greater(vc1541, ATTOTIME_IN_USEC(20)))
11801180      {
11811181         DBG_LOG (1, "vc1541", ("%.2x written\n", vc1541->i.serial.value));
11821182         vc1541->i.serial.data = 1;
11831183         vc1541->i.serial.clock = 0;
11841184         vc1541->i.serial.state++;
1185         vc1541->i.serial.time = mame_timer_get_time ();
1185         vc1541->i.serial.time = timer_get_time ();
11861186         break;
11871187      }
11881188      break;
r1293r1294
11971197      if (!cbm_serial.data[0])
11981198      {
11991199         vc1541->i.serial.state++;
1200         vc1541->i.serial.time = mame_timer_get_time ();
1200         vc1541->i.serial.time = timer_get_time ();
12011201         break;
12021202      }
12031203      break;
r1293r1294
12211221         vc1541->i.serial.state = 320;
12221222         break;
12231223      }
1224      if (vc1541_time_greater(vc1541, MAME_TIME_IN_USEC(100)))
1224      if (vc1541_time_greater(vc1541, ATTOTIME_IN_USEC(100)))
12251225      {
12261226         vc1541->pos++;
12271227         vc1541->i.serial.clock = 1;
r1293r1294
12371237         vc1541->i.serial.clock = 1;
12381238         break;
12391239      }
1240      if (vc1541_time_greater(vc1541, MAME_TIME_IN_USEC(100)))
1240      if (vc1541_time_greater(vc1541, ATTOTIME_IN_USEC(100)))
12411241      {
12421242         vc1541->i.serial.clock = 1;
12431243         vc1541->i.serial.state++;
src/mess/machine/amigafdc.c
r1293r1294
4545   int tracklen;
4646   UINT8 mfm[MAX_MFM_TRACK_LEN];
4747   int   cached;
48   mame_timer *rev_timer;
49   mame_timer *sync_timer;
50   mame_timer *dma_timer;
48   emu_timer *rev_timer;
49   emu_timer *sync_timer;
50   emu_timer *dma_timer;
5151   int rev_timer_started;
5252   int pos;
5353   int len;
r1293r1294
7474   fdc_status[id].dir = 0;
7575   fdc_status[id].wprot = 1;
7676   fdc_status[id].cyl = 0;
77   fdc_status[id].rev_timer = mame_timer_alloc(fdc_rev_proc);
78   fdc_status[id].dma_timer = mame_timer_alloc(fdc_dma_proc);
79   fdc_status[id].sync_timer = mame_timer_alloc(fdc_sync_proc);
77   fdc_status[id].rev_timer = timer_alloc(fdc_rev_proc);
78   fdc_status[id].dma_timer = timer_alloc(fdc_dma_proc);
79   fdc_status[id].sync_timer = timer_alloc(fdc_sync_proc);
8080   fdc_status[id].rev_timer_started = 0;
8181   fdc_status[id].cached = -1;
8282   fdc_status[id].pos = 0;
r1293r1294
149149   fdc_status[id].cached = -1;
150150   fdc_status[id].motor_on = 0;
151151   fdc_status[id].rev_timer_started = 0;
152   mame_timer_reset( fdc_status[id].rev_timer, time_never );
153   mame_timer_reset( fdc_status[id].sync_timer, time_never );
154   mame_timer_reset( fdc_status[id].dma_timer, time_never );
152   timer_reset( fdc_status[id].rev_timer, attotime_never );
153   timer_reset( fdc_status[id].sync_timer, attotime_never );
154   timer_reset( fdc_status[id].dma_timer, attotime_never );
155155   fdc_rdy = 0;
156156   
157157   check_extended_image( id );
r1293r1294
168168   fdc_status[id].cached = -1;
169169   fdc_status[id].motor_on = 0;
170170   fdc_status[id].rev_timer_started = 0;
171   mame_timer_reset( fdc_status[id].rev_timer, time_never );
172   mame_timer_reset( fdc_status[id].sync_timer, time_never );
173   mame_timer_reset( fdc_status[id].dma_timer, time_never );
171   timer_reset( fdc_status[id].rev_timer, attotime_never );
172   timer_reset( fdc_status[id].sync_timer, attotime_never );
173   timer_reset( fdc_status[id].dma_timer, attotime_never );
174174   fdc_rdy = 0;
175175}
176176
r1293r1294
186186      return 0;
187187   }
188188
189   elapsed = mame_time_to_double(mame_timer_timeelapsed( fdc_status[drive].rev_timer ));
189   elapsed = attotime_to_double(timer_timeelapsed( fdc_status[drive].rev_timer ));
190190   speed = ( CUSTOM_REG(REG_ADKCON) & 0x100 ) ? 2 : 4;
191191
192   bytes = elapsed / mame_time_to_double( MAME_TIME_IN_USEC( speed * 8 ) );
192   bytes = elapsed / attotime_to_double( ATTOTIME_IN_USEC( speed * 8 ) );
193193   pos = bytes % ( fdc_status[drive].tracklen );
194194
195195   return pos;
r1293r1294
275275      time = ONE_SECTOR_BYTES;
276276      time *= ( CUSTOM_REG(REG_ADKCON) & 0x0100 ) ? 2 : 4;
277277      time *= 8;
278      mame_timer_adjust( fdc_status[drive].sync_timer, MAME_TIME_IN_USEC( time ), drive, time_zero );
278      timer_adjust( fdc_status[drive].sync_timer, ATTOTIME_IN_USEC( time ), drive, attotime_zero );
279279      return;
280280   }
281281   
282282bail:
283   mame_timer_reset( fdc_status[drive].sync_timer, time_never );
283   timer_reset( fdc_status[drive].sync_timer, attotime_never );
284284}
285285
286286static TIMER_CALLBACK(fdc_dma_proc)
r1293r1294
352352         time = len_words * 2;
353353         time *= ( CUSTOM_REG(REG_ADKCON) & 0x0100 ) ? 2 : 4;
354354         time *= 8;
355         mame_timer_adjust( fdc_status[drive].dma_timer, MAME_TIME_IN_USEC( time ), drive, time_zero );
355         timer_adjust( fdc_status[drive].dma_timer, ATTOTIME_IN_USEC( time ), drive, attotime_zero );
356356         return;
357357      }
358358   }
359359   
360360bail:
361   mame_timer_reset( fdc_status[drive].dma_timer, time_never );
361   timer_reset( fdc_status[drive].dma_timer, attotime_never );
362362}
363363
364364void amiga_fdc_setup_dma( void ) {
r1293r1294
423423   time += len_words * 2;
424424   time *= ( CUSTOM_REG(REG_ADKCON) & 0x0100 ) ? 2 : 4;
425425   time *= 8;
426   mame_timer_adjust( fdc_status[drive].dma_timer, MAME_TIME_IN_USEC( time ), drive, time_zero );
426   timer_adjust( fdc_status[drive].dma_timer, ATTOTIME_IN_USEC( time ), drive, attotime_zero );
427427   
428428   return;
429429   
430430bail:
431   mame_timer_reset( fdc_status[drive].dma_timer, time_never );
431   timer_reset( fdc_status[drive].dma_timer, attotime_never );
432432}
433433
434434static void setup_fdc_buffer( int drive )
r1293r1294
599599   /* Issue a index pulse when a disk revolution completes */
600600   cia_issue_index(1);
601601
602   mame_timer_adjust(fdc_status[drive].rev_timer, MAME_TIME_IN_MSEC( ONE_REV_TIME ), drive, time_zero);
602   timer_adjust(fdc_status[drive].rev_timer, ATTOTIME_IN_MSEC( ONE_REV_TIME ), drive, attotime_zero);
603603   fdc_status[drive].rev_timer_started = 1;
604604   
605605   if ( fdc_status[drive].is_ext_image == 0 )
r1293r1294
608608      time = GAP_TRACK_BYTES + 6;
609609      time *= ( CUSTOM_REG(REG_ADKCON) & 0x0100 ) ? 2 : 4;
610610      time *= 8;
611      mame_timer_adjust( fdc_status[drive].sync_timer, MAME_TIME_IN_USEC( time ), drive, time_zero );
611      timer_adjust( fdc_status[drive].sync_timer, ATTOTIME_IN_USEC( time ), drive, attotime_zero );
612612   }
613613}
614614
r1293r1294
620620      return;
621621   }
622622
623   mame_timer_adjust(fdc_status[drive].rev_timer, MAME_TIME_IN_MSEC( ONE_REV_TIME ), drive, time_zero);
623   timer_adjust(fdc_status[drive].rev_timer, ATTOTIME_IN_MSEC( ONE_REV_TIME ), drive, attotime_zero);
624624   fdc_status[drive].rev_timer_started = 1;
625625}
626626
r1293r1294
630630      return;
631631   }
632632
633   mame_timer_reset( fdc_status[drive].rev_timer, time_never );
633   timer_reset( fdc_status[drive].rev_timer, attotime_never );
634634   fdc_status[drive].rev_timer_started = 0;
635   mame_timer_reset( fdc_status[drive].dma_timer, time_never );
636   mame_timer_reset( fdc_status[drive].sync_timer, time_never );
635   timer_reset( fdc_status[drive].dma_timer, attotime_never );
636   timer_reset( fdc_status[drive].sync_timer, attotime_never );
637637}
638638
639639static void fdc_setup_leds( int drive ) {
src/mess/machine/z80dart.c
r1293r1294
149149   int         inbuf;            /* input buffer */
150150   int         outbuf;            /* output buffer */
151151   UINT8      int_on_next_rx;      /* interrupt on next rx? */
152   mame_timer *receive_timer;      /* timer to clock data in */
152   emu_timer *receive_timer;      /* timer to clock data in */
153153   UINT8      receive_buffer[16];   /* buffer for incoming data */
154154   UINT8      receive_inptr;      /* index of data coming in */
155155   UINT8      receive_outptr;      /* index of data going out */
r1293r1294
251251}
252252
253253
254INLINE mame_time compute_time_per_character(z80dart *dart, int which)
254INLINE attotime compute_time_per_character(z80dart *dart, int which)
255255{
256256   /* fix me -- should compute properly and include data, stop, parity bits */
257   return MAME_TIME_IN_HZ(9600 / 10);
257   return ATTOTIME_IN_HZ(9600 / 10);
258258}
259259
260260
r1293r1294
275275
276276   memset(dart, 0, sizeof(*dart));
277277
278   dart->chan[0].receive_timer = mame_timer_alloc(serial_callback);
279   dart->chan[1].receive_timer = mame_timer_alloc(serial_callback);
278   dart->chan[0].receive_timer = timer_alloc(serial_callback);
279   dart->chan[1].receive_timer = timer_alloc(serial_callback);
280280
281281   dart->irq_cb = intf->irq_cb;
282282   dart->dtr_changed_cb = intf->dtr_changed_cb;
r1293r1294
295295
296296static void reset_channel(z80dart *dart, int ch)
297297{
298   mame_time tpc = compute_time_per_character(dart, ch);
298   attotime tpc = compute_time_per_character(dart, ch);
299299   dart_channel *chan = &dart->chan[ch];
300300
301301   chan->status[0] = DART_RR0_TX_BUFFER_EMPTY;
r1293r1294
312312   interrupt_check(dart);
313313
314314   /* start the receive timer running */
315   mame_timer_adjust(chan->receive_timer, tpc, ((dart - darts) << 1) | ch, tpc);
315   timer_adjust(chan->receive_timer, tpc, ((dart - darts) << 1) | ch, tpc);
316316}
317317
318318
r1293r1294
579579void z80dart_set_cts(int which, int ch, int state)
580580{
581581   /* operate deferred */
582   mame_timer_set(time_zero, (DART_RR0_CTS << 8) + (state != 0) * 0x80 + which * 2 + ch, change_input_line);
582   timer_set(attotime_zero, (DART_RR0_CTS << 8) + (state != 0) * 0x80 + which * 2 + ch, change_input_line);
583583}
584584
585585
r1293r1294
591591void z80dart_set_dcd(int which, int ch, int state)
592592{
593593   /* operate deferred */
594   mame_timer_set(time_zero, (DART_RR0_DCD << 8) + (state != 0) * 0x80 + which * 2 + ch, change_input_line);
594   timer_set(attotime_zero, (DART_RR0_DCD << 8) + (state != 0) * 0x80 + which * 2 + ch, change_input_line);
595595}
596596
597597
r1293r1294
603603void z80dart_set_ri(int which, int state)
604604{
605605   /* operate deferred */
606   mame_timer_set(time_zero, (DART_RR0_RI << 8) + (state != 0) * 0x80 + which * 2, change_input_line);
606   timer_set(attotime_zero, (DART_RR0_RI << 8) + (state != 0) * 0x80 + which * 2, change_input_line);
607607}
608608
609609
src/mess/machine/amigakbd.c
r1293r1294
1616static UINT8 *key_buf = NULL;
1717static int key_buf_pos = 0;
1818static int key_cur_pos = 0;
19static mame_timer *kbd_timer;
19static emu_timer *kbd_timer;
2020
2121static void kbd_sendscancode( UINT8 scancode )
2222{
r1293r1294
4949   /* if we still have more data, schedule another update */
5050   if ( key_buf_pos != key_cur_pos )
5151   {
52      mame_timer_adjust( kbd_timer, scale_down_mame_time(video_screen_get_frame_period(0),4), 0, time_zero);
52      timer_adjust( kbd_timer, attotime_div(video_screen_get_frame_period(0),4), 0, attotime_zero);
5353   }
5454}
5555
r1293r1294
8989      /* if the buffer was empty and we have new data, start a timer to send the keystrokes */
9090      if ( key_buf_was_empty && ( key_buf_pos != key_cur_pos ) )
9191      {
92         mame_timer_adjust( kbd_timer, scale_down_mame_time(video_screen_get_frame_period(0),4), 0, time_zero);
92         timer_adjust( kbd_timer, attotime_div(video_screen_get_frame_period(0),4), 0, attotime_zero);
9393      }
9494   }
9595}
r1293r1294
112112   key_buf = auto_malloc( KEYBOARD_BUFFER_SIZE );
113113   key_buf_pos = 0;
114114   key_cur_pos = 0;
115   kbd_timer = mame_timer_alloc(kbd_update_callback);
116   mame_timer_reset( kbd_timer, time_never );
115   kbd_timer = timer_alloc(kbd_update_callback);
116   timer_reset( kbd_timer, attotime_never );
117117}
118118
119119/*********************************************************************************************/
src/mess/machine/matsucd.c
r1293r1294
5050   void (*stch_cb)( int level );   /* Status changed callback */
5151   void (*scor_cb)( int level );   /* Subcode ready callback */
5252   cdrom_file *cdrom;
53   mame_timer *frame_timer;
53   emu_timer *frame_timer;
5454} matsucd;
5555
5656static matsucd cd;
r1293r1294
6666   
6767   cd.cdrom = mess_cd_get_cdrom_file_by_number(0);
6868   
69   cd.frame_timer = mame_timer_alloc(matsu_subcode_proc);
69   cd.frame_timer = timer_alloc(matsu_subcode_proc);
7070   
7171   cd.stch_signal = 1;
7272}
r1293r1294
139139   if (cddanum != -1)
140140   {
141141      cdda_stop_audio(cddanum);
142      mame_timer_reset( cd.frame_timer, time_never );
142      timer_reset( cd.frame_timer, attotime_never );
143143   }
144144}
145145
r1293r1294
149149   if (cddanum != -1)
150150   {
151151      cdda_start_audio(cddanum, lba, num_blocks);
152      mame_timer_adjust( cd.frame_timer, MAME_TIME_IN_HZ( 75 ), 0, time_zero );
152      timer_adjust( cd.frame_timer, ATTOTIME_IN_HZ( 75 ), 0, attotime_zero );
153153   }
154154}
155155
r1293r1294
162162     
163163      if ( pause )
164164      {
165         mame_timer_reset( cd.frame_timer, time_never );
165         timer_reset( cd.frame_timer, attotime_never );
166166      }
167167      else
168168      {
169         mame_timer_adjust( cd.frame_timer, MAME_TIME_IN_HZ( 75 ), 0, time_zero );
169         timer_adjust( cd.frame_timer, ATTOTIME_IN_HZ( 75 ), 0, attotime_zero );
170170      }
171171   }
172172}
r1293r1294
270270      if ( cd.stch_signal != 0 )
271271      {
272272         update_status_changed( 0 );
273         mame_timer_set( MAME_TIME_IN_MSEC(1), 0, matsucd_set_status_end );
273         timer_set( ATTOTIME_IN_MSEC(1), 0, matsucd_set_status_end );
274274      }
275275   }
276276}
r1293r1294
296296         
297297         newstatus |= MATSU_STATUS_PLAYING;
298298         
299         mame_timer_adjust( cd.frame_timer, MAME_TIME_IN_HZ( 75 ), 0, time_zero );
299         timer_adjust( cd.frame_timer, ATTOTIME_IN_HZ( 75 ), 0, attotime_zero );
300300      }
301301      else
302302      {
src/mess/machine/microtan.c
r1293r1294
3030static UINT8 microtan_keypad_column;
3131static UINT8 microtan_keyboard_ascii;
3232
33static mame_timer *microtan_timer = NULL;
33static emu_timer *microtan_timer = NULL;
3434
3535static int via_0_irq_line = CLEAR_LINE;
3636static int via_1_irq_line = CLEAR_LINE;
r1293r1294
434434        break;
435435    case 1: /* BFF1: write delayed NMI */
436436        LOG(("microtan_bff1_w: %d <- %02x (delayed NMI)\n", offset, data));
437        mame_timer_set(MAME_TIME_IN_CYCLES(8,0), 0, microtan_pulse_nmi);
437        timer_set(ATTOTIME_IN_CYCLES(8,0), 0, microtan_pulse_nmi);
438438        break;
439439    case 2: /* BFF2: write keypad column write (what is this meant for?) */
440440        LOG(("microtan_bff2_w: %d <- %02x (keypad column)\n", offset, data));
r1293r1294
965965
966966   acia_6551_init();
967967
968   microtan_timer = mame_timer_alloc(microtan_read_cassette);
968   microtan_timer = timer_alloc(microtan_read_cassette);
969969}
src/mess/machine/intv.c
r1293r1294
311311
312312WRITE16_HANDLER( intv_ram16_w )
313313{
314   //logerror("%g: WRITING TO GRAM offset = %d\n",mame_timer_get_time(),offset);
314   //logerror("%g: WRITING TO GRAM offset = %d\n",timer_get_time(),offset);
315315   //logerror("ram16_w(%x) = %x\n",offset,data);
316316   intv_ram16[offset] = data&0xffff;
317317}
r1293r1294
434434{
435435   cpunum_set_input_line(0, CP1610_INT_INTRM, ASSERT_LINE);
436436   sr1_int_pending = 1;
437   mame_timer_set(MAME_TIME_IN_CYCLES(3791, 0), 0, intv_interrupt_complete);
437   timer_set(ATTOTIME_IN_CYCLES(3791, 0), 0, intv_interrupt_complete);
438438   stic_screenrefresh();
439439}
440440
src/mess/machine/amigacrt.c
r1293r1294
100100   
101101      /* trigger NMI irq */
102102      amiga_ar1_spurious = 0;
103      mame_timer_set( MAME_TIME_IN_CYCLES(28,0), 0, amiga_ar1_delayed_nmi );
103      timer_set( ATTOTIME_IN_CYCLES(28,0), 0, amiga_ar1_delayed_nmi );
104104   }
105105}
106106
r1293r1294
117117      {
118118         /* trigger an NMI or spurious irq */
119119         amiga_ar1_spurious = (offset == 0x60/2) ? 0 : 1;
120         mame_timer_set( MAME_TIME_IN_CYCLES(28,0), 0, amiga_ar1_delayed_nmi );
120         timer_set( ATTOTIME_IN_CYCLES(28,0), 0, amiga_ar1_delayed_nmi );
121121      }
122122   }
123123   
src/mess/machine/tms9902.c
r1293r1294
136136   tms9902[which].brk_callback = param->brk_callback;
137137   tms9902[which].xmit_callback = param->xmit_callback;
138138
139   tms9902[which].timer = mame_timer_alloc(decrementer_callback);
139   tms9902[which].timer = timer_alloc(decrementer_callback);
140140
141141   reset(which);
142142}
r1293r1294
146146{
147147   if (tms9902[which].timer)
148148   {
149      mame_timer_reset(tms9902[which].timer, time_never);   /* FIXME - timers should only be allocated once */
149      timer_reset(tms9902[which].timer, attotime_never);   /* FIXME - timers should only be allocated once */
150150      tms9902[which].timer = NULL;
151151   }
152152}
r1293r1294
281281{
282282   if (tms9902[which].TMR)
283283   {   /* reset clock interval */
284      mame_timer_adjust(tms9902[which].timer,
285                  double_to_mame_time((double) tms9902[which].TMR / (tms9902[which].clock_rate / ((tms9902[which].CLK4M) ? 4. : 3.) / 64.)),
284      timer_adjust(tms9902[which].timer,
285                  double_to_attotime((double) tms9902[which].TMR / (tms9902[which].clock_rate / ((tms9902[which].CLK4M) ? 4. : 3.) / 64.)),
286286                  which,
287                  double_to_mame_time((double) tms9902[which].TMR / (tms9902[which].clock_rate / ((tms9902[which].CLK4M) ? 4. : 3.) / 64.)));
287                  double_to_attotime((double) tms9902[which].TMR / (tms9902[which].clock_rate / ((tms9902[which].CLK4M) ? 4. : 3.) / 64.)));
288288   }
289289   else
290290   {   /* clock interval == 0 -> no timer */
291      mame_timer_enable(tms9902[which].timer, 0);
291      timer_enable(tms9902[which].timer, 0);
292292   }
293293}
294294
src/mess/machine/osborne1.c
r1293r1294
3737   /* video related */
3838   UINT8   new_start_x;
3939   UINT8   new_start_y;
40   mame_timer   *video_timer;
40   emu_timer   *video_timer;
4141   UINT8   *charrom;
4242   UINT8   charline;
4343   UINT8   start_y;
r1293r1294
356356      beep_set_state( 0, 0 );
357357   }
358358
359   mame_timer_adjust( osborne1.video_timer, video_screen_get_time_until_pos( 0, y + 1, 0 ), 0, time_never );
359   timer_adjust( osborne1.video_timer, video_screen_get_time_until_pos( 0, y + 1, 0 ), 0, attotime_never );
360360}
361361
362362/*
r1293r1294
432432
433433   memset( mess_ram + 0x10000, 0xFF, 0x1000 );
434434
435   osborne1.video_timer = mame_timer_alloc( osborne1_video_callback );
436   mame_timer_adjust( osborne1.video_timer, video_screen_get_time_until_pos( 0, 1, 0 ), 0, time_never );
435   osborne1.video_timer = timer_alloc( osborne1_video_callback );
436   timer_adjust( osborne1.video_timer, video_screen_get_time_until_pos( 0, 1, 0 ), 0, attotime_never );
437437   pia_1_ca1_w( 0, 0 );
438438
439   mame_timer_set( time_zero, 0, setup_beep );
439   timer_set( attotime_zero, 0, setup_beep );
440440
441441   memory_set_opbase_handler( 0, osborne1_opbase );
442442}
src/mess/machine/sms.c
r1293r1294
3434UINT8 sms_input_port1;
3535
3636/* Data needed for Rapid Fire Unit support */
37mame_timer   *rapid_fire_timer;
37emu_timer   *rapid_fire_timer;
3838UINT8 rapid_fire_state_1;
3939UINT8 rapid_fire_state_2;
4040
r1293r1294
955955
956956   rapid_fire_state_1 = 0;
957957   rapid_fire_state_2 = 0;
958   rapid_fire_timer = mame_timer_alloc( rapid_fire_callback );
959   mame_timer_adjust( rapid_fire_timer, MAME_TIME_IN_HZ(10), 0, MAME_TIME_IN_HZ(10) );
958   rapid_fire_timer = timer_alloc( rapid_fire_callback );
959   timer_adjust( rapid_fire_timer, ATTOTIME_IN_HZ(10), 0, ATTOTIME_IN_HZ(10) );
960960
961961   last_paddle_read_time = 0;
962962   paddle_read_state = 0;
src/mess/machine/wd17xx.c
r1293r1294
174174
175175   UINT8   ddam;               /* ddam of sector found - used when reading */
176176   UINT8   sector_data_id;
177   mame_timer   *timer, *timer_rs, *timer_ws, *timer_rid;
177   emu_timer   *timer, *timer_rs, *timer_ws, *timer_rid;
178178   int      data_direction;
179179
180180   UINT8   ipl;               /* index pulse */
r1293r1294
245245static void wd17xx_set_data_request(void);
246246static void wd17xx_timed_data_request(void);
247247static void wd17xx_set_irq(wd17xx_info *);
248static mame_timer *busy_timer = NULL;
248static emu_timer *busy_timer = NULL;
249249
250250/* one wd controlling multiple drives */
251251static wd17xx_info wd;
r1293r1294
304304{
305305   wd17xx_info *info = (wd17xx_info *) param;
306306   wd17xx_set_irq(info);         
307   mame_timer_reset(busy_timer, time_never);
307   timer_reset(busy_timer, attotime_never);
308308}
309309
310310
311311
312static void wd17xx_set_busy(wd17xx_info *w, mame_time duration)
312static void wd17xx_set_busy(wd17xx_info *w, attotime duration)
313313{
314314   w->status |= STA_1_BUSY;
315   mame_timer_adjust_ptr(busy_timer, duration, time_zero);
315   timer_adjust_ptr(busy_timer, duration, attotime_zero);
316316}
317317
318318
r1293r1294
361361   /* when command completes set irq */
362362   wd17xx_set_irq(w);
363363#endif
364   wd17xx_set_busy(w, MAME_TIME_IN_USEC(100));
364   wd17xx_set_busy(w, ATTOTIME_IN_USEC(100));
365365}
366366
367367
r1293r1294
397397   wd.callback_param = param;
398398//   wd.status_ipl = STA_1_IPL;
399399   wd.density = DEN_MFM_LO;
400   busy_timer = mame_timer_alloc_ptr(wd17xx_busy_callback, &wd);
401   wd.timer = mame_timer_alloc(wd17xx_misc_timer_callback);
402   wd.timer_rs = mame_timer_alloc(wd17xx_read_sector_callback);
403   wd.timer_ws = mame_timer_alloc(wd17xx_write_sector_callback);
400   busy_timer = timer_alloc_ptr(wd17xx_busy_callback, &wd);
401   wd.timer = timer_alloc(wd17xx_misc_timer_callback);
402   wd.timer_rs = timer_alloc(wd17xx_read_sector_callback);
403   wd.timer_ws = timer_alloc(wd17xx_write_sector_callback);
404404
405405   wd17xx_reset();
406406}
r1293r1294
805805   }
806806
807807   /* stop it, but don't allow it to be free'd */
808   mame_timer_reset(w->timer, time_never);
808   timer_reset(w->timer, attotime_never);
809809}
810810
811811
r1293r1294
830830   usecs *= delay;
831831
832832   /* set new timer */
833   mame_timer_adjust(w->timer, MAME_TIME_IN_USEC(usecs), MISCCALLBACK_COMMAND, time_zero);
833   timer_adjust(w->timer, ATTOTIME_IN_USEC(usecs), MISCCALLBACK_COMMAND, attotime_zero);
834834}
835835
836836
r1293r1294
947947      wd17xx_read_sector(w);
948948
949949   /* stop it, but don't allow it to be free'd */
950   mame_timer_reset(w->timer_rs, time_never);
950   timer_reset(w->timer_rs, attotime_never);
951951}
952952
953953
r1293r1294
998998   }
999999
10001000   /* stop it, but don't allow it to be free'd */
1001   mame_timer_reset(w->timer_ws, time_never);
1001   timer_reset(w->timer_ws, attotime_never);
10021002}
10031003
10041004
r1293r1294
10121012   usecs = floppy_drive_get_datarate_in_us(w->density);
10131013
10141014   /* set new timer */
1015   mame_timer_adjust(w->timer, MAME_TIME_IN_USEC(usecs), MISCCALLBACK_DATA, time_zero);
1015   timer_adjust(w->timer, ATTOTIME_IN_USEC(usecs), MISCCALLBACK_DATA, attotime_zero);
10161016}
10171017
10181018
r1293r1294
10261026   usecs = 40; /* How long should we wait? How about 40 micro seconds? */
10271027
10281028   /* set new timer */
1029   mame_timer_reset(w->timer_rs, MAME_TIME_IN_USEC(usecs));
1029   timer_reset(w->timer_rs, ATTOTIME_IN_USEC(usecs));
10301030}
10311031
10321032
r1293r1294
10401040   usecs = 40; /* How long should we wait? How about 40 micro seconds? */
10411041
10421042   /* set new timer */
1043   mame_timer_reset(w->timer_ws, MAME_TIME_IN_USEC(usecs));
1043   timer_reset(w->timer_ws, ATTOTIME_IN_USEC(usecs));
10441044}
10451045
10461046
r1293r1294
14191419#if 0
14201420      wd17xx_set_irq(w);
14211421#endif
1422      wd17xx_set_busy(w, MAME_TIME_IN_USEC(100));
1422      wd17xx_set_busy(w, ATTOTIME_IN_USEC(100));
14231423
14241424   }
14251425
r1293r1294
14411441#if 0
14421442      wd17xx_set_irq(w);
14431443#endif
1444      wd17xx_set_busy(w, MAME_TIME_IN_USEC(100));
1444      wd17xx_set_busy(w, ATTOTIME_IN_USEC(100));
14451445
14461446
14471447   }
r1293r1294
14631463#if 0
14641464      wd17xx_set_irq(w);
14651465#endif
1466      wd17xx_set_busy(w, MAME_TIME_IN_USEC(100));
1466      wd17xx_set_busy(w, ATTOTIME_IN_USEC(100));
14671467
14681468   }
14691469
r1293r1294
14861486#if 0
14871487      wd17xx_set_irq(w);
14881488#endif
1489      wd17xx_set_busy(w, MAME_TIME_IN_USEC(100));
1489      wd17xx_set_busy(w, ATTOTIME_IN_USEC(100));
14901490   }
14911491
14921492//   if (w->busy_count==0)
src/mess/machine/pc_mouse.c
r1293r1294
2121   UINT8 queue[256];
2222   UINT8 head, tail, mb;
2323
24   mame_timer *timer;
24   emu_timer *timer;
2525
2626} pc_mouse;
2727
r1293r1294
3030void pc_mouse_initialise(void)
3131{
3232   pc_mouse.head = pc_mouse.tail = 0;
33   pc_mouse.timer = mame_timer_alloc(pc_mouse_scan);
33   pc_mouse.timer = timer_alloc(pc_mouse_scan);
3434   pc_mouse.inputs=UART8250_HANDSHAKE_IN_DSR|UART8250_HANDSHAKE_IN_CTS;
3535   if (pc_mouse.serial_port!=-1)
3636      uart8250_handshake_in(pc_mouse.serial_port, pc_mouse.inputs);
r1293r1294
229229         }
230230
231231         /* start a timer to scan the mouse input */
232         mame_timer_adjust(pc_mouse.timer, time_zero, pc_mouse.serial_port, MAME_TIME_IN_HZ(240));
232         timer_adjust(pc_mouse.timer, attotime_zero, pc_mouse.serial_port, ATTOTIME_IN_HZ(240));
233233      }
234234      else
235235      {
236236         /* CTS just went to 0 */
237         mame_timer_adjust(pc_mouse.timer, time_zero, pc_mouse.serial_port, time_zero);
237         timer_adjust(pc_mouse.timer, attotime_zero, pc_mouse.serial_port, attotime_zero);
238238         pc_mouse.head = pc_mouse.tail = 0;
239239      }
240240   }
src/mess/machine/trs80.c
r1293r1294
282282   if (cas_size)
283283   {
284284      LOG(("trs80_init_machine: schedule cas_copy_callback (%d)\n", cas_size));
285      mame_timer_set(MAME_TIME_IN_MSEC(500), 0, cas_copy_callback);
285      timer_set(ATTOTIME_IN_MSEC(500), 0, cas_copy_callback);
286286   }
287287}
288288
src/mess/machine/odyssey2.c
r1293r1294
6767{
6868    UINT8 data = p1;
6969
70    logerror("%.9f p1 read %.2x\n", mame_time_to_double(mame_timer_get_time()), data);
70    logerror("%.9f p1 read %.2x\n", attotime_to_double(timer_get_time()), data);
7171    return data;
7272}
7373
r1293r1294
7878    /* ROM is mirrored so this will be OK for all sizes 2k/4k/8k */
7979    memory_set_bankptr(1, memory_region(REGION_USER1) + (0x800 * (p1 & 0x03)));
8080
81    logerror("%.6f p1 written %.2x\n", mame_time_to_double(mame_timer_get_time()), data);
81    logerror("%.6f p1 written %.2x\n", attotime_to_double(timer_get_time()), data);
8282}
8383
8484READ8_HANDLER( odyssey2_getp2 )
r1293r1294
109109    else
110110        p2 = p2 | 0xF0;
111111   
112    logerror("%.6f p2 read %.2x\n", mame_time_to_double(mame_timer_get_time()), p2);
112    logerror("%.6f p2 read %.2x\n", attotime_to_double(timer_get_time()), p2);
113113    return p2;
114114}
115115
r1293r1294
117117{
118118    p2 = data;
119119
120    logerror("%.6f p2 written %.2x\n", mame_time_to_double(mame_timer_get_time()), data);
120    logerror("%.6f p2 written %.2x\n", attotime_to_double(timer_get_time()), data);
121121}
122122
123123READ8_HANDLER( odyssey2_getbus )
r1293r1294
130130    if ((p2 & P2_KEYBOARD_SELECT_MASK) == 0)
131131      data &= readinputport(7);       /* read joystick 2 */
132132
133    logerror("%.6f bus read %.2x\n", mame_time_to_double(mame_timer_get_time()), data);
133    logerror("%.6f bus read %.2x\n", attotime_to_double(timer_get_time()), data);
134134    return data;
135135}
136136
137137WRITE8_HANDLER( odyssey2_putbus )
138138{
139    logerror("%.6f bus written %.2x\n", mame_time_to_double(mame_timer_get_time()), data);
139    logerror("%.6f bus written %.2x\n", attotime_to_double(timer_get_time()), data);
140140}
141141
142142///////////////////////////////////
src/mess/machine/apple2.c
r1293r1294
10291029         break;
10301030      case 0x04:
10311031         /* X Joystick 1 axis */
1032         result = mame_time_to_double(mame_timer_get_time()) < joystick_x1_time;
1032         result = attotime_to_double(timer_get_time()) < joystick_x1_time;
10331033         break;
10341034      case 0x05:
10351035         /* Y Joystick 1 axis */
1036         result = mame_time_to_double(mame_timer_get_time()) < joystick_y1_time;
1036         result = attotime_to_double(timer_get_time()) < joystick_y1_time;
10371037         break;
10381038      case 0x06:
10391039         /* X Joystick 2 axis */
1040         result = mame_time_to_double(mame_timer_get_time()) < joystick_x2_time;
1040         result = attotime_to_double(timer_get_time()) < joystick_x2_time;
10411041         break;
10421042      case 0x07:
10431043         /* Y Joystick 2 axis */
1044         result = mame_time_to_double(mame_timer_get_time()) < joystick_y2_time;
1044         result = attotime_to_double(timer_get_time()) < joystick_y2_time;
10451045         break;
10461046      default:
10471047         /* c060 Empty Cassette head read
r1293r1294
10611061
10621062READ8_HANDLER ( apple2_c07x_r )
10631063{
1064   double x_calibration = mame_time_to_double(MAME_TIME_IN_USEC(12));
1065   double y_calibration = mame_time_to_double(MAME_TIME_IN_USEC(13));
1064   double x_calibration = attotime_to_double(ATTOTIME_IN_USEC(12));
1065   double y_calibration = attotime_to_double(ATTOTIME_IN_USEC(13));
10661066
10671067   if (offset == 0)
10681068   {
1069      joystick_x1_time = mame_time_to_double(mame_timer_get_time()) + x_calibration * readinputportbytag("joystick_1_x");
1070      joystick_y1_time = mame_time_to_double(mame_timer_get_time()) + y_calibration * readinputportbytag("joystick_1_y");
1071      joystick_x2_time = mame_time_to_double(mame_timer_get_time()) + x_calibration * readinputportbytag("joystick_2_x");
1072      joystick_y2_time = mame_time_to_double(mame_timer_get_time()) + y_calibration * readinputportbytag("joystick_2_y");
1069      joystick_x1_time = attotime_to_double(timer_get_time()) + x_calibration * readinputportbytag("joystick_1_x");
1070      joystick_y1_time = attotime_to_double(timer_get_time()) + y_calibration * readinputportbytag("joystick_1_y");
1071      joystick_x2_time = attotime_to_double(timer_get_time()) + x_calibration * readinputportbytag("joystick_2_x");
1072      joystick_y2_time = attotime_to_double(timer_get_time()) + y_calibration * readinputportbytag("joystick_2_y");
10731073   }
10741074   return 0;
10751075}
src/mess/machine/ti85.c
r1293r1294
193193
194194   ti_calculator_model = TI_81;
195195
196   mame_timer_pulse(MAME_TIME_IN_HZ(200), 0, ti85_timer_callback);
196   timer_pulse(ATTOTIME_IN_HZ(200), 0, ti85_timer_callback);
197197
198198   memory_install_write8_handler(0, ADDRESS_SPACE_PROGRAM, 0x0000, 0x3fff, 0, 0, MWA8_ROM);
199199   memory_install_write8_handler(0, ADDRESS_SPACE_PROGRAM, 0x4000, 0x7fff, 0, 0, MWA8_ROM);
r1293r1294
223223
224224   ti_calculator_model = TI_85;
225225
226   mame_timer_pulse(MAME_TIME_IN_HZ(200), 0, ti85_timer_callback);
226   timer_pulse(ATTOTIME_IN_HZ(200), 0, ti85_timer_callback);
227227
228228   memory_install_write8_handler(0, ADDRESS_SPACE_PROGRAM, 0x0000, 0x3fff, 0, 0, MWA8_ROM);
229229   memory_install_write8_handler(0, ADDRESS_SPACE_PROGRAM, 0x4000, 0x7fff, 0, 0, MWA8_ROM);
r1293r1294
267267
268268      ti_calculator_model = TI_86;
269269
270      mame_timer_pulse(MAME_TIME_IN_HZ(200), 0, ti85_timer_callback);
270      timer_pulse(ATTOTIME_IN_HZ(200), 0, ti85_timer_callback);
271271   }
272272
273273   add_reset_callback(machine, ti85_reset_serial);
src/mess/machine/hd63450.c
r1293r1294
2121   dmac.intf = intf;
2222   for(x=0;x<4;x++)
2323   {
24      dmac.timer[x] = mame_timer_alloc(dma_transfer_timer);
24      dmac.timer[x] = timer_alloc(dma_transfer_timer);
2525      dmac.reg[x].niv = 0x0f;  // defaults?
2626      dmac.reg[x].eiv = 0x0f;
2727   }
r1293r1294
205205   if((dmac.reg[channel].dcr & 0xc0) == 0x00)  // Burst transfer
206206   {
207207      cpunum_set_input_line(dmac.intf->cpu,INPUT_LINE_HALT,ASSERT_LINE);
208      mame_timer_adjust(dmac.timer[channel],time_zero,channel, double_to_mame_time(dmac.intf->burst_clock[channel]));
208      timer_adjust(dmac.timer[channel],attotime_zero,channel, double_to_attotime(dmac.intf->burst_clock[channel]));
209209   }
210210   else
211      mame_timer_adjust(dmac.timer[channel],MAME_TIME_IN_USEC(500),channel, double_to_mame_time(dmac.intf->clock[channel]));
211      timer_adjust(dmac.timer[channel],ATTOTIME_IN_USEC(500),channel, double_to_attotime(dmac.intf->clock[channel]));
212212
213213
214214   dmac.transfer_size[channel] = dmac.reg[channel].mtc;
r1293r1294
224224void dma_transfer_abort(int channel)
225225{
226226   logerror("DMA#%i: Transfer aborted\n",channel);
227   mame_timer_adjust(dmac.timer[channel],time_zero,0,time_zero);
227   timer_adjust(dmac.timer[channel],attotime_zero,0,attotime_zero);
228228   dmac.in_progress[channel] = 0;
229229   dmac.reg[channel].mtc = dmac.transfer_size[channel];
230230   dmac.reg[channel].csr |= 0xe0;  // channel operation complete, block transfer complete
r1293r1294
234234void dma_transfer_halt(int channel)
235235{
236236   dmac.halted[channel] = 1;
237   mame_timer_adjust(dmac.timer[channel],time_zero,0,time_zero);
237   timer_adjust(dmac.timer[channel],attotime_zero,0,attotime_zero);
238238}
239239
240240void dma_transfer_continue(int channel)
r1293r1294
242242   if(dmac.halted[channel] != 0)
243243   {
244244      dmac.halted[channel] = 0;
245      mame_timer_adjust(dmac.timer[channel],time_zero,channel, double_to_mame_time(dmac.intf->clock[channel]));
245      timer_adjust(dmac.timer[channel],attotime_zero,channel, double_to_attotime(dmac.intf->clock[channel]));
246246   }
247247}
248248
r1293r1294
361361               dmac.reg[x].mtc = program_read_word(dmac.reg[x].bar+4);
362362               return;
363363            }
364            mame_timer_adjust(dmac.timer[x],time_zero,0,time_zero);
364            timer_adjust(dmac.timer[x],attotime_zero,0,attotime_zero);
365365            dmac.in_progress[x] = 0;
366366            dmac.reg[x].mtc = dmac.transfer_size[x];
367367            dmac.reg[x].csr |= 0xe0;  // channel operation complete, block transfer complete
src/mess/machine/hd63450.h
r1293r1294
3838      unsigned char bfc;  // [39]  Base Function Code (R/W)
3939      unsigned char gcr;  // [3f]  General Control Register (R/W)
4040   } reg[4];
41   mame_timer* timer[4];  // for timing data reading/writing each channel
41   emu_timer* timer[4];  // for timing data reading/writing each channel
4242   int in_progress[4];  // if a channel is in use
4343   int transfer_size[4];
4444   int halted[4];  // non-zero if a channel has been halted, and can be continued later.
src/mess/machine/pce.c
r1293r1294
7171   UINT8   *subcode_buffer;
7272   cdrom_file   *cd;
7373   const cdrom_toc*   toc;
74   mame_timer   *data_timer;
75   mame_timer   *adpcm_dma_timer;
74   emu_timer   *data_timer;
75   emu_timer   *adpcm_dma_timer;
7676} pce_cd;
7777
7878/* MSM5205 ADPCM decoder definition */
r1293r1294
358358   if ( frame_count == 0 ) {
359359      pce_cd_reply_status_byte( SCSI_STATUS_OK );
360360   } else {
361      mame_timer_adjust( pce_cd.data_timer, MAME_TIME_IN_HZ( PCE_CD_DATA_FRAMES_PER_SECOND ), 0, MAME_TIME_IN_HZ( PCE_CD_DATA_FRAMES_PER_SECOND ) );
361      timer_adjust( pce_cd.data_timer, ATTOTIME_IN_HZ( PCE_CD_DATA_FRAMES_PER_SECOND ), 0, ATTOTIME_IN_HZ( PCE_CD_DATA_FRAMES_PER_SECOND ) );
362362   }
363363}
364364
r1293r1294
790790         /* We are done, disable the timer */
791791         logerror("Last frame read from CD\n");
792792         pce_cd.data_transferred = 1;
793         mame_timer_adjust( pce_cd.data_timer, time_never, 0, time_never );
793         timer_adjust( pce_cd.data_timer, attotime_never, 0, attotime_never );
794794      } else {
795795         pce_cd.data_transferred = 0;
796796      }
r1293r1294
834834      pce_cd.end_frame = pce_cd.last_frame;
835835   }
836836
837   pce_cd.data_timer = mame_timer_alloc( pce_cd_data_timer_callback );
838   mame_timer_adjust( pce_cd.data_timer, time_never, 0, time_never );
839   pce_cd.adpcm_dma_timer = mame_timer_alloc( pce_cd_adpcm_dma_timer_callback );
840   mame_timer_adjust( pce_cd.adpcm_dma_timer, time_never, 0, time_never );
837   pce_cd.data_timer = timer_alloc( pce_cd_data_timer_callback );
838   timer_adjust( pce_cd.data_timer, attotime_never, 0, attotime_never );
839   pce_cd.adpcm_dma_timer = timer_alloc( pce_cd_adpcm_dma_timer_callback );
840   timer_adjust( pce_cd.adpcm_dma_timer, attotime_never, 0, attotime_never );
841841}
842842
843843WRITE8_HANDLER( pce_cd_bram_w ) {
r1293r1294
891891   case 0x0B:   /* ADPCM DMA control */
892892      if ( ! ( pce_cd.regs[0x0B] & 0x02 ) && ( data & 0x02 ) ) {
893893         /* Start CD to ADPCM transfer */
894         mame_timer_adjust( pce_cd.adpcm_dma_timer, MAME_TIME_IN_HZ( PCE_CD_DATA_FRAMES_PER_SECOND * 2048 ), 0, MAME_TIME_IN_HZ( PCE_CD_DATA_FRAMES_PER_SECOND * 2048 ) );
894         timer_adjust( pce_cd.adpcm_dma_timer, ATTOTIME_IN_HZ( PCE_CD_DATA_FRAMES_PER_SECOND * 2048 ), 0, ATTOTIME_IN_HZ( PCE_CD_DATA_FRAMES_PER_SECOND * 2048 ) );
895895      }
896896      if ( ( pce_cd.regs[0x0B] & 0x02 ) && ! ( data & 0x02 ) ) {
897897         /* Stop CD to ADPCM transfer (?) */
898         mame_timer_adjust( pce_cd.adpcm_dma_timer, time_never, 0, time_never );
898         timer_adjust( pce_cd.adpcm_dma_timer, attotime_never, 0, attotime_never );
899899      }
900900      break;
901901   case 0x0C:   /* ADPCM status */
r1293r1294
944944   if ( pce_cd.scsi_REQ && ! pce_cd.scsi_ACK && ! pce_cd.scsi_CD ) {
945945      if ( pce_cd.scsi_IO ) {
946946         pce_cd.scsi_ACK = 1;
947         mame_timer_set( MAME_TIME_IN_CYCLES( 15, 0 ), 0, pce_cd_clear_ack );
947         timer_set( ATTOTIME_IN_CYCLES( 15, 0 ), 0, pce_cd_clear_ack );
948948      }
949949   }
950950   return data;
src/mess/machine/ti99_4x.c
r1293r1294
12031203   {
12041204      /* Weirdly enough, we are always seeing some problems even though
12051205      everything is working fine. */
1206      mame_time time_to_ready = double_to_mame_time(tms5220_time_to_ready());
1206      attotime time_to_ready = double_to_attotime(tms5220_time_to_ready());
12071207      logerror("ti99/4a speech says aaargh!\n");
12081208      logerror("(time to ready: %f -> %d)\n", time_to_ready, (int) ceil(3000000*time_to_ready));
12091209   }
r1293r1294
12251225   complex. */
12261226   if (! tms5220_ready_r())
12271227   {
1228      mame_time time_to_ready = double_to_mame_time(tms5220_time_to_ready());
1229      int cycles_to_ready = ceil(MAME_TIME_TO_CYCLES(0, time_to_ready));
1228      attotime time_to_ready = double_to_attotime(tms5220_time_to_ready());
1229      int cycles_to_ready = ceil(ATTOTIME_TO_CYCLES(0, time_to_ready));
12301230
1231      logerror("time to ready: %f -> %d\n", mame_time_to_double(time_to_ready), (int) cycles_to_ready);
1231      logerror("time to ready: %f -> %d\n", attotime_to_double(time_to_ready), (int) cycles_to_ready);
12321232
12331233      activecpu_adjust_icount(-cycles_to_ready);
1234      mame_timer_set(time_zero, 0, /*speech_kludge_callback*/NULL);
1234      timer_set(attotime_zero, 0, /*speech_kludge_callback*/NULL);
12351235   }
12361236#endif
12371237
r1293r1294
15861586               complex. */
15871587               if (! tms5220_ready_r())
15881588               {
1589                  mame_time time_to_ready = double_to_mame_time(tms5220_time_to_ready());
1590                  double d = ceil(MAME_TIME_TO_CYCLES(0, time_to_ready));
1589                  attotime time_to_ready = double_to_attotime(tms5220_time_to_ready());
1590                  double d = ceil(ATTOTIME_TO_CYCLES(0, time_to_ready));
15911591                  int cycles_to_ready = ((int) (d + 3)) & ~3;
15921592
1593                  logerror("time to ready: %f -> %d\n", mame_time_to_double(time_to_ready)
1593                  logerror("time to ready: %f -> %d\n", attotime_to_double(time_to_ready)
15941594                     , (int) cycles_to_ready);
15951595
15961596                  activecpu_adjust_icount(-cycles_to_ready);
1597                  mame_timer_set(time_zero, 0, /*speech_kludge_callback*/NULL);
1597                  timer_set(attotime_zero, 0, /*speech_kludge_callback*/NULL);
15981598               }
15991599
16001600               tms5220_data_w(offset, data);
r1293r1294
17421742      of next message is not requested for either, so we need to decide on
17431743      our own when we can post a new event.  Currently, we wait for 1000us
17441744      after the DSR acknowledges the second nybble. */
1745      mame_timer_set(MAME_TIME_IN_USEC(1000), 0, ti99_handset_ack_callback);
1745      timer_set(ATTOTIME_IN_USEC(1000), 0, ti99_handset_ack_callback);
17461746   }
17471747
17481748   if (handset_buflen == 0)
r1293r1294
17621762      handset_ack = data;
17631763      if (data == handset_clock)
17641764         /* I don't know what the real delay is, but 30us apears to be enough */
1765         mame_timer_set(MAME_TIME_IN_USEC(30), 0, ti99_handset_ack_callback);
1765         timer_set(ATTOTIME_IN_USEC(30), 0, ti99_handset_ack_callback);
17661766   }
17671767}
17681768
src/mess/machine/pc1251.c
r1293r1294
156156   UINT8 *gfx = memory_region(REGION_GFX1);
157157   for (i=0; i<128; i++) gfx[i]=i;
158158
159   mame_timer_set(MAME_TIME_IN_SEC(1), 0, pc1251_power_up);
159   timer_set(ATTOTIME_IN_SEC(1), 0, pc1251_power_up);
160160
161161   // c600 b800 b000 a000 8000 tested   
162162   // 4 kb memory feedback 512 bytes too few???
src/mess/machine/tms5501.c
r1293r1294
8989
9090   /* internal timers */
9191   UINT8 timer_counter[5];
92   mame_timer * timer[5];
92   emu_timer * timer[5];
9393   double clock_rate;
9494} tms5501_t;
9595
r1293r1294
195195{
196196   if (tms5501[which].timer_counter[timer])
197197   {   /* reset clock interval */
198      mame_timer_adjust(tms5501[which].timer[timer], double_to_mame_time((double) tms5501[which].timer_counter[0] / (tms5501[which].clock_rate / 128.)), which, double_to_mame_time((double) tms5501[which].timer_counter[timer] / (tms5501[which].clock_rate / 128.)));
198      timer_adjust(tms5501[which].timer[timer], double_to_attotime((double) tms5501[which].timer_counter[0] / (tms5501[which].clock_rate / 128.)), which, double_to_attotime((double) tms5501[which].timer_counter[timer] / (tms5501[which].clock_rate / 128.)));
199199   }
200200   else
201201   {   /* clock interval == 0 -> no timer */
r1293r1294
207207         case 3: tms5501_timer_3_decrementer_callback(Machine, which); break;
208208         case 4: tms5501_timer_4_decrementer_callback(Machine, which); break;
209209      }
210      mame_timer_enable(tms5501[which].timer[timer], 0);
210      timer_enable(tms5501[which].timer[timer], 0);
211211   }
212212}
213213
r1293r1294
223223   for (i=0; i<5; i++)
224224   {
225225      tms5501[which].timer_counter[i] = 0;
226      mame_timer_enable(tms5501[which].timer[i], 0);
226      timer_enable(tms5501[which].timer[i], 0);
227227   }
228228
229229   LOG_TMS5501(which, "Reset", 0);
r1293r1294
232232void tms5501_init (int which, const tms5501_init_param *param)
233233{
234234   tms5501[which].clock_rate = param->clock_rate;
235   tms5501[which].timer[0] = mame_timer_alloc(tms5501_timer_0_decrementer_callback);
236   tms5501[which].timer[1] = mame_timer_alloc(tms5501_timer_1_decrementer_callback);
237   tms5501[which].timer[2] = mame_timer_alloc(tms5501_timer_2_decrementer_callback);
238   tms5501[which].timer[3] = mame_timer_alloc(tms5501_timer_3_decrementer_callback);
239   tms5501[which].timer[4] = mame_timer_alloc(tms5501_timer_4_decrementer_callback);
235   tms5501[which].timer[0] = timer_alloc(tms5501_timer_0_decrementer_callback);
236   tms5501[which].timer[1] = timer_alloc(tms5501_timer_1_decrementer_callback);
237   tms5501[which].timer[2] = timer_alloc(tms5501_timer_2_decrementer_callback);
238   tms5501[which].timer[3] = timer_alloc(tms5501_timer_3_decrementer_callback);
239   tms5501[which].timer[4] = timer_alloc(tms5501_timer_4_decrementer_callback);
240240
241241   tms5501[which].pio_read_callback = param->pio_read_callback;
242242   tms5501[which].pio_write_callback = param->pio_write_callback;
r1293r1294
267267   {
268268      if (tms5501[which].timer[i])
269269      {
270         mame_timer_reset(tms5501[which].timer[i], time_never);   /* FIXME - timers should only be allocated once */
270         timer_reset(tms5501[which].timer[i], attotime_never);   /* FIXME - timers should only be allocated once */
271271         tms5501[which].timer[i] = NULL;
272272      }
273273   }
src/mess/machine/sgi.c
r1293r1294
568568   nMC_DMAGIO64Addr = 0;
569569   nMC_DMAMode = 0;
570570   nMC_DMAZoomByteCnt = 0;
571   tMC_UpdateTimer = mame_timer_alloc( mc_update );
572   mame_timer_adjust( tMC_UpdateTimer, MAME_TIME_IN_HZ(10000), 0, MAME_TIME_IN_HZ(10000) );
571   tMC_UpdateTimer = timer_alloc( mc_update );
572   timer_adjust( tMC_UpdateTimer, ATTOTIME_IN_HZ(10000), 0, ATTOTIME_IN_HZ(10000) );
573573
574574   // if Indigo2, ID appropriately
575575   if (!strcmp(Machine->gamedrv->name, "ip244415"))
src/mess/machine/vc20tape.c
r1293r1294
4141struct
4242{
4343   int state;
44   mame_timer *timer;
44   emu_timer *timer;
4545   int pos;
4646   struct GameSample *sample;
4747   mess_image *img;
r1293r1294
5151struct
5252{
5353   int state;
54   mame_timer *prg_timer;
55   mame_timer *timer;
54   emu_timer *prg_timer;
55   emu_timer *timer;
5656   int pos;
5757
5858#define VC20_SHORT      (176e-6)
r1293r1294
6161#define C16_SHORT   (246e-6)         /* messured */
6262#define C16_MIDDLE   (483e-6)
6363#define C16_LONG   (965e-6)
64#define PCM_SHORT   (double_to_mame_time(prg.c16?C16_SHORT:VC20_SHORT))
65#define PCM_MIDDLE   (double_to_mame_time(prg.c16?C16_MIDDLE:VC20_MIDDLE))
66#define PCM_LONG   (double_to_mame_time(prg.c16?C16_LONG:VC20_LONG))
64#define PCM_SHORT   (double_to_attotime(prg.c16?C16_SHORT:VC20_SHORT))
65#define PCM_MIDDLE   (double_to_attotime(prg.c16?C16_MIDDLE:VC20_MIDDLE))
66#define PCM_LONG   (double_to_attotime(prg.c16?C16_LONG:VC20_LONG))
6767   int c16;
6868   UINT8 *prg;
6969   int length;
r1293r1294
7171   int prgdata;
7272   char name[16];                  /*name for cbm */
7373   UINT8 chksum;
74   mame_time lasttime;
74   attotime lasttime;
7575   mess_image *img;
7676} prg;
7777
r1293r1294
233233      if (tape.motor && tape.play)
234234      {
235235         wav.state = 3;
236         mame_timer_adjust(wav.timer, 0, 0, 1.0 / wav.sample->smpfreq);
236         timer_adjust(wav.timer, 0, 0, 1.0 / wav.sample->smpfreq);
237237         break;
238238      }
239239      if (tape.motor && tape.record)
r1293r1294
249249         tape.play = 0;
250250         tape.record = 0;
251251         DAC_data_w (0, 0);
252         mame_timer_reset(wav.timer, time_never);
252         timer_reset(wav.timer, attotime_never);
253253         break;
254254      }
255255      if (!tape.motor || !tape.play)
256256      {
257257         wav.state = 2;
258         mame_timer_reset(wav.timer, time_never);
258         timer_reset(wav.timer, attotime_never);
259259         DAC_data_w (0, 0);
260260         break;
261261      }
r1293r1294
360360      if (tape.motor && tape.play)
361361      {
362362         prg.state = 3;
363         mame_timer_reset(prg.timer, time_zero);
363         timer_reset(prg.timer, attotime_zero);
364364         break;
365365      }
366366      if (tape.motor && tape.record)
r1293r1294
376376         tape.play = 0;
377377         tape.record = 0;
378378         DAC_data_w (0, 0);
379         mame_timer_reset(prg.timer, time_never);
379         timer_reset(prg.timer, attotime_never);
380380         break;
381381      }
382382      if (!tape.motor || !tape.play)
383383      {
384384         prg.state = 2;
385         mame_timer_reset(prg.timer, time_never);
385         timer_reset(prg.timer, attotime_never);
386386         DAC_data_w (0, 0);
387387         break;
388388      }
r1293r1294
451451
452452   if (old != data)
453453   {
454      double neu = mame_timer_get_time ();
454      double neu = timer_get_time ();
455455      int diff = (neu - time) * 1000000;
456456
457457      count++;
r1293r1294
527527         }
528528      }
529529      old = data;
530      time = mame_timer_get_time ();
530      time = timer_get_time ();
531531   }
532532#endif
533533   if (tape.noise)
r1293r1294
541541   case 0:
542542      if (bit)
543543      {
544         mame_timer_reset (prg.timer, prg.lasttime = PCM_MIDDLE);
544         timer_reset (prg.timer, prg.lasttime = PCM_MIDDLE);
545545         prg.statebit = 2;
546546      }
547547      else
548548      {
549549         prg.statebit++;
550         mame_timer_reset (prg.timer, prg.lasttime = PCM_SHORT);
550         timer_reset (prg.timer, prg.lasttime = PCM_SHORT);
551551      }
552552      break;
553553   case 1:
554      mame_timer_reset (prg.timer, prg.lasttime = PCM_MIDDLE);
554      timer_reset (prg.timer, prg.lasttime = PCM_MIDDLE);
555555      prg.statebit = 0;
556556      break;
557557   case 2:
558      mame_timer_reset (prg.timer, prg.lasttime = PCM_SHORT);
558      timer_reset (prg.timer, prg.lasttime = PCM_SHORT);
559559      prg.statebit = 0;
560560      break;
561561   }
r1293r1294
578578   switch (prg.statebyte)
579579   {
580580   case 0:
581      mame_timer_reset (prg.timer, prg.lasttime = PCM_LONG);
581      timer_reset (prg.timer, prg.lasttime = PCM_LONG);
582582      prg.statebyte++;
583583      break;
584584   case 1:
585      mame_timer_reset (prg.timer, prg.lasttime = PCM_MIDDLE);
585      timer_reset (prg.timer, prg.lasttime = PCM_MIDDLE);
586586      prg.statebyte++;
587587      bit = 1;
588588      parity = 0;
r1293r1294
684684      prg.pos = (9 + 192 + 1) * 2 + (9 + prg.length - 2 + 1) * 2;
685685      i = 0;
686686      prg.stateblock++;
687      mame_timer_reset (prg.timer, prg.lasttime = PCM_SHORT);
687      timer_reset (prg.timer, prg.lasttime = PCM_SHORT);
688688      break;
689689   case 1:
690690      i++;
691691      if (i < 12000 /*27136 */ )
692692      {                        /* this time is not so important */
693         mame_timer_reset (prg.timer, prg.lasttime = PCM_SHORT);
693         timer_reset (prg.timer, prg.lasttime = PCM_SHORT);
694694         break;
695695      }
696696      /* writing countdown $89 ... $80 */
r1293r1294
709709      vc20_tape_prgheader ();
710710      break;
711711   case 3:
712      mame_timer_reset (prg.timer, prg.lasttime = PCM_LONG);
712      timer_reset (prg.timer, prg.lasttime = PCM_LONG);
713713      prg.stateblock++;
714714      i = 0;
715715      break;
r1293r1294
717717      if (i < 80)
718718      {
719719         i++;
720         mame_timer_reset (prg.timer, prg.lasttime = PCM_SHORT);
720         timer_reset (prg.timer, prg.lasttime = PCM_SHORT);
721721         break;
722722      }
723723      /* writing countdown $09 ... $00 */
r1293r1294
736736      vc20_tape_prgheader ();
737737      break;
738738   case 6:
739      mame_timer_reset (prg.timer, prg.lasttime = PCM_LONG);
739      timer_reset (prg.timer, prg.lasttime = PCM_LONG);
740740      prg.stateblock++;
741741      i = 0;
742742      break;
r1293r1294
744744      if (i < 80)
745745      {
746746         i++;
747         mame_timer_reset (prg.timer, prg.lasttime = PCM_SHORT);
747         timer_reset (prg.timer, prg.lasttime = PCM_SHORT);
748748         break;
749749      }
750750      i = 0;
751751      prg.stateblock++;
752      mame_timer_reset (prg.timer, prg.lasttime = PCM_SHORT);
752      timer_reset (prg.timer, prg.lasttime = PCM_SHORT);
753753      break;
754754   case 8:
755755      if (i < 3000 /*5376 */ )
756756      {
757757         i++;
758         mame_timer_reset (prg.timer, prg.lasttime = PCM_SHORT);
758         timer_reset (prg.timer, prg.lasttime = PCM_SHORT);
759759         break;
760760      }
761761      prg.prgdata = 0x89;
r1293r1294
789789      prg.stateblock++;
790790      break;
791791   case 11:
792      mame_timer_reset (prg.timer, prg.lasttime = PCM_LONG);
792      timer_reset (prg.timer, prg.lasttime = PCM_LONG);
793793      prg.stateblock++;
794794      i = 0;
795795      break;
r1293r1294
797797      if (i < 80)
798798      {
799799         i++;
800         mame_timer_reset (prg.timer, prg.lasttime = PCM_SHORT);
800         timer_reset (prg.timer, prg.lasttime = PCM_SHORT);
801801         break;
802802      }
803803      /* writing countdown $09 ... $00 */
r1293r1294
832832      prg.stateblock++;
833833      break;
834834   case 15:
835      mame_timer_reset (prg.timer, prg.lasttime = PCM_LONG);
835      timer_reset (prg.timer, prg.lasttime = PCM_LONG);
836836      prg.stateblock++;
837837      i = 0;
838838      break;
r1293r1294
840840      if (i < 80)
841841      {
842842         i++;
843         mame_timer_reset (prg.timer, prg.lasttime = PCM_SHORT);
843         timer_reset (prg.timer, prg.lasttime = PCM_SHORT);
844844         break;
845845      }
846846      prg.stateblock = 0;
r1293r1294
856856      if (tape.noise)
857857         DAC_data_w (0, 0);
858858      tape.data = 1;
859      mame_timer_reset (prg.timer, prg.lasttime);
859      timer_reset (prg.timer, prg.lasttime);
860860   }
861861   else
862862   {
r1293r1294
902902   tape.data = 0;
903903#endif
904904   prg.c16 = 0;
905   wav.timer = mame_timer_alloc(vc20_wav_timer);
906   prg.prg_timer = mame_timer_alloc(vc20_prg_timer);
905   wav.timer = timer_alloc(vc20_wav_timer);
906   prg.prg_timer = timer_alloc(vc20_prg_timer);
907907}
908908
909909void c16_tape_open (void)
src/mess/machine/bbc.c
r1293r1294
13861386static int len2=0;
13871387static int len3=0;
13881388
1389mame_timer *bbc_tape_timer;
1389emu_timer *bbc_tape_timer;
13901390
13911391static TIMER_CALLBACK(bbc_tape_timer_cb)
13921392{
r1293r1294
14531453   if (status)
14541454   {
14551455      cassette_change_state(image_from_devtype_and_index(IO_CASSETTE, 0),CASSETTE_MOTOR_ENABLED ,CASSETTE_MASK_MOTOR);
1456      mame_timer_adjust(bbc_tape_timer, time_zero, 0, MAME_TIME_IN_HZ(44100));
1456      timer_adjust(bbc_tape_timer, attotime_zero, 0, ATTOTIME_IN_HZ(44100));
14571457   } else {
14581458      cassette_change_state(image_from_devtype_and_index(IO_CASSETTE, 0),CASSETTE_MOTOR_DISABLED,CASSETTE_MASK_MOTOR);
1459      mame_timer_reset(bbc_tape_timer, time_never);
1459      timer_reset(bbc_tape_timer, attotime_never);
14601460      MC6850_Reset(wav_len);
14611461      len0=0;
14621462      len1=0;
r1293r1294
20912091DRIVER_INIT( bbc )
20922092{
20932093   bbc_Master=0;
2094   bbc_tape_timer = mame_timer_alloc(bbc_tape_timer_cb);
2094   bbc_tape_timer = timer_alloc(bbc_tape_timer_cb);
20952095}
20962096DRIVER_INIT( bbcm )
20972097{
20982098   bbc_Master=1;
2099   bbc_tape_timer = mame_timer_alloc(bbc_tape_timer_cb);
2099   bbc_tape_timer = timer_alloc(bbc_tape_timer_cb);
21002100    mc146818_init(MC146818_STANDARD);
21012101}
21022102
src/mess/machine/compis.c
r1293r1294
5353   UINT16   maxA;
5454   UINT16   maxB;
5555   UINT16   count;
56   mame_timer *   int_timer;
57   mame_timer *   time_timer;
56   emu_timer *   int_timer;
57   emu_timer *   time_timer;
5858   UINT8   time_timer_active;
59   mame_time   last_time;
59   attotime   last_time;
6060};
6161
6262struct dma_state
r1293r1294
6666   UINT16   count;
6767   UINT16   control;
6868   UINT8   finished;
69   mame_timer *   finish_timer;
69   emu_timer *   finish_timer;
7070};
7171
7272struct intr_state
r1293r1294
567567static int int_callback(int line)
568568{
569569   if (LOG_INTERRUPTS)
570      logerror("(%f) **** Acknowledged interrupt vector %02X\n", mame_time_to_double(mame_timer_get_time()), i186.intr.poll_status & 0x1f);
570      logerror("(%f) **** Acknowledged interrupt vector %02X\n", attotime_to_double(timer_get_time()), i186.intr.poll_status & 0x1f);
571571
572572   /* clear the interrupt */
573573   activecpu_set_input_line(0, CLEAR_LINE);
r1293r1294
682682   i186.intr.pending = 1;
683683   cpu_trigger(CPU_RESUME_TRIGGER);
684684   if (LOG_OPTIMIZATION) logerror("  - trigger due to interrupt pending\n");
685   if (LOG_INTERRUPTS) logerror("(%f) **** Requesting interrupt vector %02X\n", mame_time_to_double(mame_timer_get_time()), new_vector);
685   if (LOG_INTERRUPTS) logerror("(%f) **** Requesting interrupt vector %02X\n", attotime_to_double(timer_get_time()), new_vector);
686686}
687687
688688
r1293r1294
707707         case 0x0f:   i186.intr.in_service &= ~0x80;   break;
708708         default:   logerror("%05X:ERROR - 80186 EOI with unknown vector %02X\n", activecpu_get_pc(), data & 0x1f);
709709      }
710      if (LOG_INTERRUPTS) logerror("(%f) **** Got EOI for vector %02X\n", mame_time_to_double(mame_timer_get_time()), data & 0x1f);
710      if (LOG_INTERRUPTS) logerror("(%f) **** Got EOI for vector %02X\n", attotime_to_double(timer_get_time()), data & 0x1f);
711711   }
712712
713713   /* non-specific case */
r1293r1294
720720         if ((i186.intr.timer & 7) == i && (i186.intr.in_service & 0x01))
721721         {
722722            i186.intr.in_service &= ~0x01;
723            if (LOG_INTERRUPTS) logerror("(%f) **** Got EOI for timer\n", mame_time_to_double(mame_timer_get_time()));
723            if (LOG_INTERRUPTS) logerror("(%f) **** Got EOI for timer\n", attotime_to_double(timer_get_time()));
724724            return;
725725         }
726726
r1293r1294
729729            if ((i186.intr.dma[j] & 7) == i && (i186.intr.in_service & (0x04 << j)))
730730            {
731731               i186.intr.in_service &= ~(0x04 << j);
732               if (LOG_INTERRUPTS) logerror("(%f) **** Got EOI for DMA%d\n", mame_time_to_double(mame_timer_get_time()), j);
732               if (LOG_INTERRUPTS) logerror("(%f) **** Got EOI for DMA%d\n", attotime_to_double(timer_get_time()), j);
733733               return;
734734            }
735735
r1293r1294
738738            if ((i186.intr.ext[j] & 7) == i && (i186.intr.in_service & (0x10 << j)))
739739            {
740740               i186.intr.in_service &= ~(0x10 << j);
741               if (LOG_INTERRUPTS) logerror("(%f) **** Got EOI for INT%d\n", mame_time_to_double(mame_timer_get_time()), j);
741               if (LOG_INTERRUPTS) logerror("(%f) **** Got EOI for INT%d\n", attotime_to_double(timer_get_time()), j);
742742               return;
743743            }
744744      }
r1293r1294
774774   if (t->control & 0x0001)
775775   {
776776      int count = t->maxA ? t->maxA : 0x10000;
777      mame_timer_adjust(t->int_timer, scale_up_mame_time(MAME_TIME_IN_HZ(2000000), count), which, time_zero);
777      timer_adjust(t->int_timer, attotime_mul(ATTOTIME_IN_HZ(2000000), count), which, attotime_zero);
778778      if (LOG_TIMER) logerror("  Repriming interrupt\n");
779779   }
780780   else
781      mame_timer_adjust(t->int_timer, time_never, which, time_zero);
781      timer_adjust(t->int_timer, attotime_never, which, attotime_zero);
782782}
783783
784784
r1293r1294
789789   /* if we have a timing timer running, adjust the count */
790790   if (t->time_timer_active)
791791   {
792      mame_time current_time = mame_timer_timeelapsed(t->time_timer);
793      int net_clocks = scale_up_mame_time(sub_mame_times(current_time, t->last_time),  2000000).seconds;
792      attotime current_time = timer_timeelapsed(t->time_timer);
793      int net_clocks = attotime_mul(attotime_sub(current_time, t->last_time),  2000000).seconds;
794794      t->last_time = current_time;
795795
796796      /* set the max count bit if we passed the max */
r1293r1294
889889            internal_timer_sync(which);
890890
891891            /* nuke the timer and force the interrupt timer to be recomputed */
892            mame_timer_adjust(t->time_timer, time_never, which, time_zero);
892            timer_adjust(t->time_timer, attotime_never, which, attotime_zero);
893893            t->time_timer_active = 0;
894894            update_int_timer = 1;
895895         }
r1293r1294
898898         else if ((diff & 0x8000) && (new_control & 0x8000))
899899         {
900900            /* start the timing */
901            mame_timer_adjust(t->time_timer, time_never, which, time_zero);
901            timer_adjust(t->time_timer, attotime_never, which, attotime_zero);
902902            t->time_timer_active = 1;
903903            update_int_timer = 1;
904904         }
r1293r1294
923923              int diff = t->maxA - t->count;
924924               if (diff <= 0)
925925                  diff += 0x10000;
926               mame_timer_adjust(t->int_timer, scale_up_mame_time(MAME_TIME_IN_HZ(2000000), diff), which, time_zero);
926               timer_adjust(t->int_timer, attotime_mul(ATTOTIME_IN_HZ(2000000), diff), which, attotime_zero);
927927               if (LOG_TIMER) logerror("Set interrupt timer for %d\n", which);
928928            }
929929            else
930930            {
931              mame_timer_adjust(t->int_timer, time_never, which, time_zero);
931              timer_adjust(t->int_timer, attotime_never, which, attotime_zero);
932932      }
933933   }
934934}
r1293r1294
10101010         if (LOG_DMA) logerror("Initiated DMA %d - count = %04X, source = %04X, dest = %04X\n", which, d->count, d->source, d->dest);
10111011
10121012         d->finished = 0;
1013/*         mame_timer_adjust(d->finish_timer,
1014         MAME_TIME_IN_HZ(dac[dacnum].frequency) * (double)count, which, 0);*/
1013/*         timer_adjust(d->finish_timer,
1014         ATTOTIME_IN_HZ(dac[dacnum].frequency) * (double)count, which, 0);*/
10151015      }
10161016   }
10171017
r1293r1294
15191519void compis_cpu_init(void)
15201520{
15211521   /* create timers here so they stick around */
1522   i186.timer[0].int_timer = mame_timer_alloc(internal_timer_int);
1523   i186.timer[1].int_timer = mame_timer_alloc(internal_timer_int);
1524   i186.timer[2].int_timer = mame_timer_alloc(internal_timer_int);
1525   i186.timer[0].time_timer = mame_timer_alloc(NULL);
1526   i186.timer[1].time_timer = mame_timer_alloc(NULL);
1527   i186.timer[2].time_timer = mame_timer_alloc(NULL);
1528   i186.dma[0].finish_timer = mame_timer_alloc(dma_timer_callback);
1529   i186.dma[1].finish_timer = mame_timer_alloc(dma_timer_callback);
1522   i186.timer[0].int_timer = timer_alloc(internal_timer_int);
1523   i186.timer[1].int_timer = timer_alloc(internal_timer_int);
1524   i186.timer[2].int_timer = timer_alloc(internal_timer_int);
1525   i186.timer[0].time_timer = timer_alloc(NULL);
1526   i186.timer[1].time_timer = timer_alloc(NULL);
1527   i186.timer[2].time_timer = timer_alloc(NULL);
1528   i186.dma[0].finish_timer = timer_alloc(dma_timer_callback);
1529   i186.dma[1].finish_timer = timer_alloc(dma_timer_callback);
15301530}
15311531
15321532/*-------------------------------------------------------------------------*/
src/mess/machine/kc.c
r1293r1294
231231
232232static void kc_disc_interface_init(void)
233233{
234   mame_timer_set(time_zero, 0, kc85_disk_reset_timer_callback);
234   timer_set(attotime_zero, 0, kc85_disk_reset_timer_callback);
235235
236236   nec765_init(&kc_fdc_interface,NEC765A);
237237
r1293r1294
382382*/
383383
384384
385#define KC_CASSETTE_TIMER_FREQUENCY MAME_TIME_IN_HZ(4800)
385#define KC_CASSETTE_TIMER_FREQUENCY ATTOTIME_IN_HZ(4800)
386386
387387/* this timer is used to update the cassette */
388static mame_timer *kc_cassette_timer;
388static emu_timer *kc_cassette_timer;
389389/* this is the current state of the cassette motor */
390390static int kc_cassette_motor_state;
391391/* ardy output from pio */
r1293r1294
410410
411411static void   kc_cassette_init(void)
412412{
413   kc_cassette_timer = mame_timer_alloc(kc_cassette_timer_callback);
413   kc_cassette_timer = timer_alloc(kc_cassette_timer_callback);
414414}
415415
416416static void   kc_cassette_set_motor(int motor_state)
r1293r1294
426426      if (motor_state)
427427      {
428428         /* start timer */
429         mame_timer_adjust(kc_cassette_timer, time_zero, 0, KC_CASSETTE_TIMER_FREQUENCY);
429         timer_adjust(kc_cassette_timer, attotime_zero, 0, KC_CASSETTE_TIMER_FREQUENCY);
430430      }
431431      else
432432      {
433433         /* stop timer */
434         mame_timer_reset(kc_cassette_timer, time_never);
434         timer_reset(kc_cassette_timer, attotime_never);
435435      }
436436   }
437437
r1293r1294
902902   keyboard_data.head = (keyboard_data.tail = 0);
903903
904904   /* 50hz is just a arbitrary value - used to put scan-codes into the queue for transmitting */
905   mame_timer_pulse(MAME_TIME_IN_HZ(50), 0, kc_keyboard_update);
905   timer_pulse(ATTOTIME_IN_HZ(50), 0, kc_keyboard_update);
906906
907907   /* timer to transmit pulses to kc base unit */
908   mame_timer_pulse(MAME_TIME_IN_USEC(1024), 0, kc_keyboard_transmit_timer_callback);
908   timer_pulse(ATTOTIME_IN_USEC(1024), 0, kc_keyboard_transmit_timer_callback);
909909
910910   /* kc keyboard is not transmitting */
911911   keyboard_data.transmit_state = KC_KEYBOARD_TRANSMIT_IDLE;
r1293r1294
18911891   kc85_50hz_state = 0;
18921892   kc85_15khz_state = 0;
18931893   kc85_15khz_count = 0;
1894   mame_timer_pulse(MAME_TIME_IN_HZ(15625), 0, kc85_15khz_timer_callback);
1895   mame_timer_set(time_zero, 0, kc85_reset_timer_callback);
1894   timer_pulse(ATTOTIME_IN_HZ(15625), 0, kc85_15khz_timer_callback);
1895   timer_set(attotime_zero, 0, kc85_reset_timer_callback);
18961896   kc85_module_system_init();
18971897}
18981898
src/mess/machine/corvushd.c
r1293r1294
108108   // Timing-related values
109109   UINT16   last_cylinder;      // Last cylinder accessed - for calculating seek times
110110   UINT32   delay;            // Delay in microseconds for callback
111   mame_timer   *timeout_timer;   // Four-second timer for timeouts
111   emu_timer   *timeout_timer;   // Four-second timer for timeouts
112112
113113   //
114114   // Union below represents both an input and output buffer and interpretations of it
r1293r1294
13911391   //
13921392   // Set up timers for command completion and timeout from host
13931393   //
1394   mame_timer_set(MAME_TIME_IN_USEC(c->delay), CALLBACK_CTH_MODE, corvus_hdc_callback);
1395   mame_timer_enable(c->timeout_timer, 0);         // We've received enough data, disable the timeout timer
1394   timer_set(ATTOTIME_IN_USEC(c->delay), CALLBACK_CTH_MODE, corvus_hdc_callback);
1395   timer_enable(c->timeout_timer, 0);         // We've received enough data, disable the timeout timer
13961396
13971397   c->delay = 0;                           // Reset delay for next function
13981398}
r1293r1294
14581458         assert(0);
14591459   }
14601460   if(function != CALLBACK_SAME_MODE) {
1461      mame_timer_enable(c->timeout_timer, 0);            // Disable the four-second timer now that we're done
1461      timer_enable(c->timeout_timer, 0);            // Disable the four-second timer now that we're done
14621462   }
14631463}
14641464
r1293r1294
14961496   c->xmit_bytes = 0;                     // We don't have anything to say to the host
14971497   c->recv_bytes = 0;                     // We aren't waiting on additional data from the host
14981498
1499   c->timeout_timer = mame_timer_alloc(corvus_hdc_callback);   // Set up a timer to handle the four-second host-to-controller timeout
1500   mame_timer_adjust(c->timeout_timer, MAME_TIME_IN_SEC(4), CALLBACK_TIMEOUT, time_zero);
1501   mame_timer_enable(c->timeout_timer, 0);      // Start this timer out disabled
1499   c->timeout_timer = timer_alloc(corvus_hdc_callback);   // Set up a timer to handle the four-second host-to-controller timeout
1500   timer_adjust(c->timeout_timer, ATTOTIME_IN_SEC(4), CALLBACK_TIMEOUT, attotime_zero);
1501   timer_enable(c->timeout_timer, 0);      // Start this timer out disabled
15021502
15031503   #if VERBOSE
15041504   logerror("corvus_hdc_init: Attached to drive image: H:%d, C:%d, S:%d\n", info->heads, info->cylinders, info->sectors);
r1293r1294
16701670      c->xmit_bytes = 0;      // We don't have anything more to say
16711671      c->recv_bytes = 0;      // No active commands
16721672     
1673      mame_timer_set((MAME_TIME_IN_USEC(INTERBYTE_DELAY)), CALLBACK_HTC_MODE, corvus_hdc_callback);
1673      timer_set((ATTOTIME_IN_USEC(INTERBYTE_DELAY)), CALLBACK_HTC_MODE, corvus_hdc_callback);
16741674
16751675//      c->status &= ~(CONTROLLER_DIRECTION | CONTROLLER_BUSY);   // Put us in Idle, Host-to-Controller mode
16761676   } else {
16771677      //
16781678      // Not finished with this packet.  Insert an interbyte delay and then let the host continue
16791679      //
1680      mame_timer_set((MAME_TIME_IN_USEC(INTERBYTE_DELAY)), CALLBACK_SAME_MODE, corvus_hdc_callback);     
1680      timer_set((ATTOTIME_IN_USEC(INTERBYTE_DELAY)), CALLBACK_SAME_MODE, corvus_hdc_callback);     
16811681   }
16821682
16831683   return result;
r1293r1294
17241724      logerror("corvus_hdc_data_w: Received a byte with c->offset == 0.  Processing as command: 0x%2.2x\n", data);
17251725      #endif
17261726      invalid_command_flag = parse_hdc_command(data);
1727      mame_timer_reset(c->timeout_timer, (MAME_TIME_IN_SEC(4)));
1728      mame_timer_enable(c->timeout_timer, 1);                        // Start our four-second timer
1727      timer_reset(c->timeout_timer, (ATTOTIME_IN_SEC(4)));
1728      timer_enable(c->timeout_timer, 1);                        // Start our four-second timer
17291729   } else if(c->offset == 1 && c->awaiting_modifier) {                  // Second byte of a packet
17301730      #if VERBOSE
17311731      logerror("corvus_hdc_data_w: Received a byte while awaiting modifier with c->offset == 0.  Processing as modifier: 0x%2.2x\n", data);
r1293r1294
17501750      //
17511751      // Reset the four-second timer since we received some data
17521752      //
1753      mame_timer_reset(c->timeout_timer, (MAME_TIME_IN_SEC(4)));
1753      timer_reset(c->timeout_timer, (ATTOTIME_IN_SEC(4)));
17541754
17551755      //
17561756      // Make the controller busy for a few microseconds while the command is processed
17571757      //
17581758      c->status |= CONTROLLER_BUSY;
1759      mame_timer_set((MAME_TIME_IN_USEC(INTERBYTE_DELAY)), CALLBACK_SAME_MODE, corvus_hdc_callback);
1759      timer_set((ATTOTIME_IN_USEC(INTERBYTE_DELAY)), CALLBACK_SAME_MODE, corvus_hdc_callback);
17601760   }
17611761}
src/mess/formats/mz_cas.c
r1293r1294
77
88#if VERBOSE
99#define LOG(N,M,A)   \
10   if(VERBOSE>=N){ if( M )logerror("%11.6f: %-24s",mame_timer_get_time(), (const char*)M ); logerror A; }
10   if(VERBOSE>=N){ if( M )logerror("%11.6f: %-24s",timer_get_time(), (const char*)M ); logerror A; }
1111#else
1212#define LOG(N,M,A)
1313#endif
src/mess/formats/thom_dsk.c
r1293r1294
225225      physical_track = 0;
226226   if ( physical_track >= 80 )
227227      physical_track = 79;
228   LOG(( "%f thom_floppy_seek: dev=%li track=%i\n", mame_time_to_double(mame_timer_get_time()), d - thom_floppy_drives, physical_track ));
228   LOG(( "%f thom_floppy_seek: dev=%li track=%i\n", attotime_to_double(timer_get_time()), d - thom_floppy_drives, physical_track ));
229229   d->cur_track = physical_track;
230230}
231231
src/mess/formats/thom_cas.c
r1293r1294
117117         if ( bitpos >= to7_k7_bitsize )
118118            bitpos = to7_k7_bitsize -1;
119119         VLOG (( "$%04x %f to7_get_cassette: state=$%X pos=%f samppos=%i bit=%i\n",
120            activecpu_get_previouspc(), mame_time_to_double(mame_timer_get_time()), state, pos, bitpos,
120            activecpu_get_previouspc(), attotime_to_double(timer_get_time()), state, pos, bitpos,
121121            to7_k7_bits[ bitpos ] ));
122122         return to7_k7_bits[ bitpos ];
123123      }
r1293r1294
138138         }
139139         k = ( chg >= 13 ) ? 1 : 0;
140140         VLOG (( "$%04x %f to7_get_cassette: state=$%X pos=%f samppos=%i bit=%i (%i)\n",
141            activecpu_get_previouspc(), mame_time_to_double(mame_timer_get_time()), state, pos, bitpos,
141            activecpu_get_previouspc(), attotime_to_double(timer_get_time()), state, pos, bitpos,
142142            k, chg ));
143143         return k;
144144      }
r1293r1294
166166   double pos = cassette_get_position(img);
167167
168168   LOG (( "$%04x %f to7_set_cassette_motor: cassette motor %s bitpos=%i\n",
169          activecpu_get_previouspc(), mame_time_to_double(mame_timer_get_time()), data ? "off" : "on",
169          activecpu_get_previouspc(), attotime_to_double(timer_get_time()), data ? "off" : "on",
170170          (int) (pos / TO7_BIT_LENGTH) ));
171171
172172   if ( (state & CASSETTE_MASK_MOTOR) == CASSETTE_MOTOR_DISABLED && !data && pos > 0.3 )
r1293r1294
216216      hbit = hbit >= 0;
217217   
218218      VLOG (( "$%04x %f mo5_get_cassette: state=$%X pos=%f hbitpos=%i hbit=%i\n",
219         activecpu_get_previouspc(), mame_time_to_double(mame_timer_get_time()), state, pos,
219         activecpu_get_previouspc(), attotime_to_double(timer_get_time()), state, pos,
220220         (int) (pos / MO5_HBIT_LENGTH), hbit ));
221221      return hbit;
222222   }
r1293r1294
241241   double pos = cassette_get_position(img);
242242
243243   LOG (( "$%04x %f mo5_set_cassette_motor: cassette motor %s hbitpos=%i\n",
244          activecpu_get_previouspc(), mame_time_to_double(mame_timer_get_time()), data ? "off" : "on",
244          activecpu_get_previouspc(), attotime_to_double(timer_get_time()), data ? "off" : "on",
245245          (int) (pos / MO5_HBIT_LENGTH) ));
246246
247247   if ( (state & CASSETTE_MASK_MOTOR) == CASSETTE_MOTOR_DISABLED &&  !data && pos > 0.3 )
src/mess/mess.mak
r1293r1294
8686#CPUS += TMS32025
8787#CPUS += TMS32026
8888#CPUS += TMS32031
89#CPUS += TMS32032
8990#CPUS += TMS32051
9091#CPUS += CCPU
9192#CPUS += ADSP2100
src/mess/drivers/vip.c
r1293r1294
278278   // turn on power led
279279   set_led_status(0, 1);
280280
281   mame_timer_set(time_zero, 0, setup_beep);
281   timer_set(attotime_zero, 0, setup_beep);
282282}
283283
284284/* System Drivers */
src/mess/drivers/zx.c
r1293r1294
401401   MDRV_CPU_PROGRAM_MAP(zx80_map, 0)
402402   MDRV_CPU_IO_MAP(zx80_io_map, 0)
403403   MDRV_SCREEN_REFRESH_RATE(ZX81_PAL_FRAMES_PER_SECOND)
404   MDRV_SCREEN_VBLANK_TIME(USEC_TO_SUBSECONDS(ZX81_VBLANK_DURATION))
404   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(ZX81_VBLANK_DURATION))
405405
406406   MDRV_MACHINE_RESET(zx80)
407407
src/mess/drivers/dgn_beta.c
r1293r1294
333333   MDRV_CPU_PROGRAM_MAP(dgnbeta_map,0)
334334
335335   MDRV_SCREEN_REFRESH_RATE(DGNBETA_FRAMES_PER_SECOND)
336   MDRV_SCREEN_VBLANK_TIME(USEC_TO_SUBSECONDS(100))
336   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(100))
337337   
338338   MDRV_MACHINE_START( dgnbeta )
339339
src/mess/drivers/mac.c
r1293r1294
7474   MDRV_CPU_ADD_TAG("main", M68000, 7833600)        /* 7.8336 Mhz */
7575   MDRV_CPU_PROGRAM_MAP(mac512ke_map, 0)
7676   MDRV_SCREEN_REFRESH_RATE(60.15)
77   MDRV_SCREEN_VBLANK_TIME(USEC_TO_SUBSECONDS(1260))
77   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(1260))
7878   MDRV_INTERLEAVE(1)
7979
8080   MDRV_MACHINE_RESET( mac )
src/mess/drivers/atari.c
r1293r1294
705705static MACHINE_DRIVER_START( atari_common_nodac )
706706   /* basic machine hardware */
707707   MDRV_CPU_ADD_TAG("main", M6510, FREQ_17_EXACT)
708   MDRV_SCREEN_VBLANK_TIME(USEC_TO_SUBSECONDS(1))
708   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(1))
709709
710710   /* video hardware */
711711   MDRV_VIDEO_ATTRIBUTES( VIDEO_TYPE_RASTER )
src/mess/drivers/nc.c
r1293r1294
114114
115115/* the serial clock is generated by the nc hardware and connected to the msm8251
116116receive clock and transmit clock inputs */
117static mame_timer *nc_serial_timer;
117static emu_timer *nc_serial_timer;
118118
119119static void nc_printer_update(int);
120120
r1293r1294
122122
123123static char nc_memory_config[4];
124124unsigned long nc_display_memory_start;
125static mame_timer *nc_keyboard_timer = NULL;
125static emu_timer *nc_keyboard_timer = NULL;
126126
127127static int nc_membank_rom_mask;
128128static int nc_membank_internal_ram_mask;
r1293r1294
324324        nc_update_interrupts();
325325
326326        /* don't trigger again, but don't free it */
327        mame_timer_reset(nc_keyboard_timer, time_never);
327        timer_reset(nc_keyboard_timer, attotime_never);
328328}
329329
330330
r1293r1294
600600   nc_update_interrupts();
601601
602602   /* keyboard timer */
603   nc_keyboard_timer = mame_timer_alloc(nc_keyboard_timer_callback);
604   mame_timer_adjust(nc_keyboard_timer, MAME_TIME_IN_MSEC(10), 0, time_zero);
603   nc_keyboard_timer = timer_alloc(nc_keyboard_timer_callback);
604   timer_adjust(nc_keyboard_timer, ATTOTIME_IN_MSEC(10), 0, attotime_zero);
605605
606606   /* dummy timer */
607   mame_timer_pulse(MAME_TIME_IN_HZ(50), 0, dummy_timer_callback);
607   timer_pulse(ATTOTIME_IN_HZ(50), 0, dummy_timer_callback);
608608
609609   /* serial timer */
610   nc_serial_timer = mame_timer_alloc(nc_serial_timer_callback);
610   nc_serial_timer = timer_alloc(nc_serial_timer_callback);
611611
612612   /* at reset set to 0x0ff */
613613   nc_uart_control = 0x0ff;
r1293r1294
665665      if ((data & (1<<3))!=0)
666666      {
667667         /* set timer to occur again */
668         mame_timer_reset(nc_keyboard_timer, MAME_TIME_IN_MSEC(10));
668         timer_reset(nc_keyboard_timer, ATTOTIME_IN_MSEC(10));
669669
670670         nc_update_interrupts();
671671      }
r1293r1294
682682           )
683683        {
684684         /* set timer to occur again */
685         mame_timer_reset(nc_keyboard_timer, MAME_TIME_IN_MSEC(10));
685         timer_reset(nc_keyboard_timer, ATTOTIME_IN_MSEC(10));
686686        }
687687#endif
688688        nc_irq_status &=~data;
r1293r1294
704704      nc_irq_status &= ~(1<<3);
705705
706706      /* set timer to occur again */
707      mame_timer_reset(nc_keyboard_timer, MAME_TIME_IN_MSEC(10));
707      timer_reset(nc_keyboard_timer, ATTOTIME_IN_MSEC(10));
708708
709709      nc_update_interrupts();
710710   }
r1293r1294
815815      }
816816   }
817817
818   mame_timer_adjust(nc_serial_timer, time_zero, 0, MAME_TIME_IN_HZ(baud_rate_table[(data & 0x07)]));
818   timer_adjust(nc_serial_timer, attotime_zero, 0, ATTOTIME_IN_HZ(baud_rate_table[(data & 0x07)]));
819819
820820   nc_uart_control = data;
821821}
src/mess/drivers/adam.c
r1293r1294
617617   clear_keyboard_buffer();
618618
619619   memset(&memory_region(REGION_CPU1)[0x0000], 0xFF, 0x20000); /* Initializing RAM */
620   mame_timer_pulse(MAME_TIME_IN_MSEC(20), 0, adam_paddle_callback);
620   timer_pulse(ATTOTIME_IN_MSEC(20), 0, adam_paddle_callback);
621621}
622622
623623static MACHINE_DRIVER_START( adam )
src/mess/drivers/nes.c
r1293r1294
287287   // the number of cycles in each scanline for the PPU scanline timer. Since the PPU has 20 vblank scanlines + 2
288288   // non-rendering scanlines, we compensate. This ends up being 2500 cycles for the non-rendering portion, 2273
289289   // cycles for the actual vblank period.
290   MDRV_SCREEN_VBLANK_TIME(USEC_TO_SUBSECONDS((113.66/(NTSC_CLOCK/1000000)) * (PPU_VBLANK_LAST_SCANLINE_NTSC-PPU_VBLANK_FIRST_SCANLINE+1+2)))
290   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC((113.66/(NTSC_CLOCK/1000000)) * (PPU_VBLANK_LAST_SCANLINE_NTSC-PPU_VBLANK_FIRST_SCANLINE+1+2)))
291291
292292   MDRV_MACHINE_START( nes )
293293
r1293r1294
315315   /* basic machine hardware */
316316   MDRV_CPU_REPLACE("main", N2A03, PAL_CLOCK)
317317   MDRV_SCREEN_REFRESH_RATE(53.355)
318   MDRV_SCREEN_VBLANK_TIME(USEC_TO_SUBSECONDS((106.53/(PAL_CLOCK/1000000)) * (PPU_VBLANK_LAST_SCANLINE_PAL-PPU_VBLANK_FIRST_SCANLINE+1+2)))
318   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC((106.53/(PAL_CLOCK/1000000)) * (PPU_VBLANK_LAST_SCANLINE_PAL-PPU_VBLANK_FIRST_SCANLINE+1+2)))
319319
320320   MDRV_VIDEO_START(nes_pal)
321321
src/mess/drivers/mk1.c
r1293r1294
158158
159159
160160static MACHINE_START( mk1 ) {
161   mame_timer_pulse( MAME_TIME_IN_HZ(30), 0, mk1_update_leds );
161   timer_pulse( ATTOTIME_IN_HZ(30), 0, mk1_update_leds );
162162}
163163
164164static MACHINE_DRIVER_START( mk1 )
src/mess/drivers/z88.c
r1293r1294
278278{
279279   memset(mess_ram, 0x0ff, mess_ram_size);
280280
281   mame_timer_pulse(MAME_TIME_IN_MSEC(5), 0, z88_rtc_timer_callback);
281   timer_pulse(ATTOTIME_IN_MSEC(5), 0, z88_rtc_timer_callback);
282282
283283   blink_reset();
284284
src/mess/drivers/pcw16.c
r1293r1294
13511351   pcw16_interrupt_counter = 0;
13521352
13531353   /* video ints */
1354   mame_timer_pulse(MAME_TIME_IN_USEC(5830), 0,pcw16_timer_callback);
1354   timer_pulse(ATTOTIME_IN_USEC(5830), 0,pcw16_timer_callback);
13551355   /* rtc timer */
1356   mame_timer_pulse(MAME_TIME_IN_HZ(256), 0, rtc_timer_callback);
1356   timer_pulse(ATTOTIME_IN_HZ(256), 0, rtc_timer_callback);
13571357   /* keyboard timer */
1358   mame_timer_pulse(MAME_TIME_IN_HZ(50), 0, pcw16_keyboard_timer_callback);
1358   timer_pulse(ATTOTIME_IN_HZ(50), 0, pcw16_keyboard_timer_callback);
13591359
13601360
13611361   pc_fdc_init(&pcw16_fdc_interface);
src/mess/drivers/glasgow.c
r1293r1294
509509  key_selector=0;
510510  irq_flag=0;
511511  lcd_shift_counter=3;
512   mame_timer_pulse(MAME_TIME_IN_HZ(50), 0, update_nmi);
512   timer_pulse(ATTOTIME_IN_HZ(50), 0, update_nmi);
513513  beep_set_frequency(0, 44);
514514}
515515 
r1293r1294
518518{
519519  lcd_shift_counter=3;
520520 
521   mame_timer_pulse(MAME_TIME_IN_HZ(50), 0, update_nmi32);
521   timer_pulse(ATTOTIME_IN_HZ(50), 0, update_nmi32);
522522  beep_set_frequency(0, 44);
523523}
524524 
src/mess/drivers/mz700.c
r1293r1294
7474
7575#if VERBOSE
7676#define LOG(N,M,A)   \
77   if(VERBOSE>=N){ if( M )logerror("%11.6f: %-24s",mame_timer_get_time(),(char*)M ); logerror A; }
77   if(VERBOSE>=N){ if( M )logerror("%11.6f: %-24s",timer_get_time(),(char*)M ); logerror A; }
7878#else
7979#define LOG(N,M,A)
8080#endif
src/mess/drivers/tm990189.c
r1293r1294
5353static int segment;
5454
5555static void *displayena_timer;
56#define displayena_duration MAME_TIME_IN_USEC(4500)   /* Can anyone confirm this? 74LS123 connected to C=0.1uF and R=100kOhm */
56#define displayena_duration ATTOTIME_IN_USEC(4500)   /* Can anyone confirm this? 74LS123 connected to C=0.1uF and R=100kOhm */
5757static UINT8 segment_state[10];
5858static UINT8 old_segment_state[10];
5959static UINT8 LED_state;
r1293r1294
185185
186186static mess_image *rs232_fp;
187187static UINT8 rs232_rts;
188static mame_timer *rs232_input_timer;
188static emu_timer *rs232_input_timer;
189189
190190static MACHINE_RESET( tm990_189 )
191191{
192   displayena_timer = mame_timer_alloc(NULL);
192   displayena_timer = timer_alloc(NULL);
193193
194194   hold_load();
195195
r1293r1294
216216
217217static MACHINE_RESET( tm990_189_v )
218218{
219   displayena_timer = mame_timer_alloc(NULL);
219   displayena_timer = timer_alloc(NULL);
220220
221   joy1x_timer = mame_timer_alloc(NULL);
222   joy1y_timer = mame_timer_alloc(NULL);
223   joy2x_timer = mame_timer_alloc(NULL);
224   joy2y_timer = mame_timer_alloc(NULL);
221   joy1x_timer = timer_alloc(NULL);
222   joy1y_timer = timer_alloc(NULL);
223   joy2x_timer = timer_alloc(NULL);
224   joy2y_timer = timer_alloc(NULL);
225225
226226   hold_load();
227227
r1293r1294
357357{
358358   load_state = TRUE;
359359   field_interrupts();
360   mame_timer_set(MAME_TIME_IN_MSEC(100), 0, clear_load);
360   timer_set(ATTOTIME_IN_MSEC(100), 0, clear_load);
361361}
362362
363363/*
r1293r1294
417417   else
418418   {
419419      segment &= ~ (1 << (offset-4));
420      if ((compare_mame_times(mame_timer_timeleft(displayena_timer), time_zero) > 0) && (digitsel < 10))
420      if ((attotime_compare(timer_timeleft(displayena_timer), attotime_zero) > 0) && (digitsel < 10))
421421         draw_digit();
422422   }
423423}
r1293r1294
426426{
427427   if ((!data) && (digitsel < 10))
428428   {
429      mame_timer_reset(displayena_timer, displayena_duration);
429      timer_reset(displayena_timer, displayena_duration);
430430      draw_digit();
431431   }
432432}
r1293r1294
477477   rs232_fp = image;
478478
479479   tms9902_set_dsr(id, 1);
480   rs232_input_timer = mame_timer_alloc(rs232_input_callback);
481   mame_timer_adjust(rs232_input_timer, time_zero, 0, MAME_TIME_IN_MSEC(10));
480   rs232_input_timer = timer_alloc(rs232_input_callback);
481   timer_adjust(rs232_input_timer, attotime_zero, 0, ATTOTIME_IN_MSEC(10));
482482
483483   return INIT_PASS;
484484}
r1293r1294
497497
498498   tms9902_set_dsr(id, 0);
499499
500   mame_timer_reset(rs232_input_timer, time_never);   /* FIXME - timers should only be allocated once */
500   timer_reset(rs232_input_timer, attotime_never);   /* FIXME - timers should only be allocated once */
501501}
502502
503503static void rts_callback(int which, int RTS)
r1293r1294
615615   int reply = readinputport(9);
616616
617617
618   if (compare_mame_times(mame_timer_timeleft(joy1x_timer), time_zero) < 0)
618   if (attotime_compare(timer_timeleft(joy1x_timer), attotime_zero) < 0)
619619      reply |= 0x01;
620620
621   if (compare_mame_times(mame_timer_timeleft(joy1y_timer), time_zero) < 0)
621   if (attotime_compare(timer_timeleft(joy1y_timer), attotime_zero) < 0)
622622      reply |= 0x02;
623623
624   if (compare_mame_times(mame_timer_timeleft(joy2x_timer), time_zero) < 0)
624   if (attotime_compare(timer_timeleft(joy2x_timer), attotime_zero) < 0)
625625      reply |= 0x08;
626626
627   if (compare_mame_times(mame_timer_timeleft(joy2y_timer), time_zero) < 0)
627   if (attotime_compare(timer_timeleft(joy2y_timer), attotime_zero) < 0)
628628      reply |= 0x10;
629629
630630   return reply;
r1293r1294
632632
633633static WRITE8_HANDLER(video_joy_w)
634634{
635   mame_timer_reset(joy1x_timer, MAME_TIME_IN_USEC(readinputport(10)*28+28));
636   mame_timer_reset(joy1y_timer, MAME_TIME_IN_USEC(readinputport(11)*28+28));
637   mame_timer_reset(joy2x_timer, MAME_TIME_IN_USEC(readinputport(12)*28+28));
638   mame_timer_reset(joy2y_timer, MAME_TIME_IN_USEC(readinputport(13)*28+28));
635   timer_reset(joy1x_timer, ATTOTIME_IN_USEC(readinputport(10)*28+28));
636   timer_reset(joy1y_timer, ATTOTIME_IN_USEC(readinputport(11)*28+28));
637   timer_reset(joy2x_timer, ATTOTIME_IN_USEC(readinputport(12)*28+28));
638   timer_reset(joy2y_timer, ATTOTIME_IN_USEC(readinputport(13)*28+28));
639639}
640640
641641
src/mess/drivers/abc80.c
r1293r1294
8282#include "machine/abcbus.h"
8383#include "video/abc80.h"
8484
85static mame_timer *abc80_keyboard_timer;
85static emu_timer *abc80_keyboard_timer;
8686
8787/* Read/Write Handlers */
8888
r1293r1294
441441{
442442   state_save_register_global(keylatch);
443443
444   abc80_keyboard_timer = mame_timer_alloc(abc80_keyboard_tick);
445   mame_timer_adjust(abc80_keyboard_timer, time_zero, 0, MAME_TIME_IN_USEC(2500));
444   abc80_keyboard_timer = timer_alloc(abc80_keyboard_tick);
445   timer_adjust(abc80_keyboard_timer, attotime_zero, 0, ATTOTIME_IN_USEC(2500));
446446}
447447
448448/* Machine Drivers */
src/mess/drivers/x68k.c
r1293r1294
168168extern tilemap* x68k_bg0_16;  // two 64x64 tilemaps, 16x16 characters
169169extern tilemap* x68k_bg1_16;
170170
171mame_timer* kb_timer;
172//mame_timer* mfp_timer[4];
173//mame_timer* mfp_irq;
174mame_timer* scanline_timer;
175mame_timer* raster_irq;
176mame_timer* vblank_irq;
177mame_timer* mouse_timer;  // to set off the mouse interrupts via the SCC
171emu_timer* kb_timer;
172//emu_timer* mfp_timer[4];
173//emu_timer* mfp_irq;
174emu_timer* scanline_timer;
175emu_timer* raster_irq;
176emu_timer* vblank_irq;
177emu_timer* mouse_timer;  // to set off the mouse interrupts via the SCC
178178
179179// MFP is clocked at 4MHz, so at /4 prescaler the timer is triggered after 1us (4 cycles)
180180// No longer necessary with the new MFP core
181/*static mame_time prescale(int val)
181/*static attotime prescale(int val)
182182{
183183   switch(val)
184184   {
185      case 0:   return MAME_TIME_IN_NSEC(0);
186      case 1:   return MAME_TIME_IN_NSEC(1000);
187      case 2:   return MAME_TIME_IN_NSEC(2500);
188      case 3:   return MAME_TIME_IN_NSEC(4000);
189      case 4:   return MAME_TIME_IN_NSEC(12500);
190      case 5:   return MAME_TIME_IN_NSEC(16000);
191      case 6:   return MAME_TIME_IN_NSEC(25000);
192      case 7:   return MAME_TIME_IN_NSEC(50000);
185      case 0:   return ATTOTIME_IN_NSEC(0);
186      case 1:   return ATTOTIME_IN_NSEC(1000);
187      case 2:   return ATTOTIME_IN_NSEC(2500);
188      case 3:   return ATTOTIME_IN_NSEC(4000);
189      case 4:   return ATTOTIME_IN_NSEC(12500);
190      case 5:   return ATTOTIME_IN_NSEC(16000);
191      case 6:   return ATTOTIME_IN_NSEC(25000);
192      case 7:   return ATTOTIME_IN_NSEC(50000);
193193      default:
194194         fatalerror("out of range");
195195   }
r1293r1294
205205   sys.mfp.irqline = 6;  // MFP is connected to 68000 IRQ line 6
206206   sys.mfp.current_irq = -1;  // No current interrupt
207207
208/*   mfp_timer[0] = mame_timer_alloc(mfp_timer_a_callback);
209   mfp_timer[1] = mame_timer_alloc(mfp_timer_b_callback);
210   mfp_timer[2] = mame_timer_alloc(mfp_timer_c_callback);
211   mfp_timer[3] = mame_timer_alloc(mfp_timer_d_callback);
212   mfp_irq = mame_timer_alloc(mfp_update_irq);
213   mame_timer_adjust(mfp_irq, time_zero, 0, MAME_TIME_IN_USEC(32));
208/*   mfp_timer[0] = timer_alloc(mfp_timer_a_callback);
209   mfp_timer[1] = timer_alloc(mfp_timer_b_callback);
210   mfp_timer[2] = timer_alloc(mfp_timer_c_callback);
211   mfp_timer[3] = timer_alloc(mfp_timer_d_callback);
212   mfp_irq = timer_alloc(mfp_update_irq);
213   timer_adjust(mfp_irq, attotime_zero, 0, ATTOTIME_IN_USEC(32));
214214*/
215215}
216216/*
r1293r1294
331331{
332332   if((data & 0x07) == 0x0000)
333333   {  // Timer stop
334      mame_timer_adjust(mfp_timer[timer],time_zero,0,time_zero);
334      timer_adjust(mfp_timer[timer],attotime_zero,0,attotime_zero);
335335      logerror("MFP: Timer #%i stopped. \n",timer);
336336      return;
337337   }
338338
339   mame_timer_adjust(mfp_timer[timer], time_zero, 0, prescale(data & 0x07));
340   logerror("MFP: Timer #%i set to %2.1fus\n",timer, mame_time_to_double(prescale(data & 0x07)) * 1000000);
339   timer_adjust(mfp_timer[timer], attotime_zero, 0, prescale(data & 0x07));
340   logerror("MFP: Timer #%i set to %2.1fus\n",timer, attotime_to_double(prescale(data & 0x07)) * 1000000);
341341
342342}
343343*/
r1293r1294
13291329      offset *= 2;
13301330      if(ACCESSING_LSB)
13311331         offset++;
1332      mame_timer_set(MAME_TIME_IN_CYCLES(16,0),0xeafa00+offset,x68k_fake_bus_error);
1332      timer_set(ATTOTIME_IN_CYCLES(16,0),0xeafa00+offset,x68k_fake_bus_error);
13331333//      cpunum_set_input_line_and_vector(0,2,ASSERT_LINE,current_vector[2]);
13341334   }
13351335   return 0xffff;
r1293r1294
13451345      offset *= 2;
13461346      if(ACCESSING_LSB)
13471347         offset++;
1348      mame_timer_set(MAME_TIME_IN_CYCLES(16,0),0xeafa00+offset,x68k_fake_bus_error);
1348      timer_set(ATTOTIME_IN_CYCLES(16,0),0xeafa00+offset,x68k_fake_bus_error);
13491349//      cpunum_set_input_line_and_vector(0,2,ASSERT_LINE,current_vector[2]);
13501350   }
13511351}
r1293r1294
18531853
18541854   int drive;
18551855   UINT8* romdata = memory_region(REGION_USER2);
1856   mame_time irq_time;
1856   attotime irq_time;
18571857
18581858   memset(mess_ram,0,mess_ram_size);
18591859   memcpy(mess_ram,romdata,8);
r1293r1294
18901890   // start VBlank timer
18911891   sys.crtc.vblank = 1;
18921892   irq_time = video_screen_get_time_until_pos(0,sys.crtc.reg[6],2);
1893   mame_timer_adjust(vblank_irq,irq_time,0,time_never);
1893   timer_adjust(vblank_irq,irq_time,0,attotime_never);
18941894   
18951895   // start HBlank timer
1896   mame_timer_adjust(scanline_timer,video_screen_get_scan_period(0),1,time_never);
1896   timer_adjust(scanline_timer,video_screen_get_scan_period(0),1,attotime_never);
18971897
18981898   sys.mfp.gpio = 0xfb;
18991899}
r1293r1294
19161916   memory_set_bankptr(4,generic_nvram16);  // so that code in SRAM is executable, there is an option for booting from SRAM
19171917
19181918   // start keyboard timer
1919   mame_timer_adjust(kb_timer,time_zero,0,MAME_TIME_IN_MSEC(5));  // every 5ms
1919   timer_adjust(kb_timer,attotime_zero,0,ATTOTIME_IN_MSEC(5));  // every 5ms
19201920
19211921   // start mouse timer
1922   mame_timer_adjust(mouse_timer,time_zero,0,MAME_TIME_IN_MSEC(2));  // a guess for now
1922   timer_adjust(mouse_timer,attotime_zero,0,ATTOTIME_IN_MSEC(2));  // a guess for now
19231923   sys.mouse.inputtype = 0;
19241924}
19251925
r1293r1294
19631963   // init keyboard
19641964   sys.keyboard.delay = 500;  // 3*100+200
19651965   sys.keyboard.repeat = 110;  // 4^2*5+30
1966   kb_timer = mame_timer_alloc(x68k_keyboard_poll);
1967   scanline_timer = mame_timer_alloc(x68k_hsync);
1968   raster_irq = mame_timer_alloc(x68k_crtc_raster_irq);
1969   vblank_irq = mame_timer_alloc(x68k_crtc_vblank_irq);
1970   mouse_timer = mame_timer_alloc(x68k_scc_ack);
1966   kb_timer = timer_alloc(x68k_keyboard_poll);
1967   scanline_timer = timer_alloc(x68k_hsync);
1968   raster_irq = timer_alloc(x68k_crtc_raster_irq);
1969   vblank_irq = timer_alloc(x68k_crtc_vblank_irq);
1970   mouse_timer = timer_alloc(x68k_scc_ack);
19711971}
19721972
19731973
src/mess/drivers/spectrum.c
r1293r1294
193193   if ((Changed & 0x07)!=0)
194194   {
195195      /* yes - send event */
196      EventList_AddItemOffset(0x0fe, data & 0x07, MAME_TIME_TO_CYCLES(0,scale_up_mame_time(video_screen_get_scan_period(0), video_screen_get_vpos(0))));
196      EventList_AddItemOffset(0x0fe, data & 0x07, ATTOTIME_TO_CYCLES(0,attotime_mul(video_screen_get_scan_period(0), video_screen_get_vpos(0))));
197197   }
198198
199199   if ((Changed & (1<<4))!=0)
src/mess/drivers/super80.c
r1293r1294
7272   keyboard_scan();
7373   /* enable ROM in base >0000, and re-enable RAM shortly thereafter */
7474   memory_set_bankptr(1, memory_region(REGION_CPU1) + 0xC000);
75   mame_timer_set(MAME_TIME_IN_USEC(10), 0, reset_timer_callback);
75   timer_set(ATTOTIME_IN_USEC(10), 0, reset_timer_callback);
7676}
7777
7878static VIDEO_START( super80 )
src/mess/drivers/atarist.c
r1293r1294
469469
470470static const int DMASOUND_RATE[] = { Y2/640/8, Y2/640/4, Y2/640/2, Y2/640 };
471471
472static mame_timer *dmasound_timer;
472static emu_timer *dmasound_timer;
473473
474474static void atariste_dmasound_set_state(int state)
475475{
r1293r1294
529529      }
530530      else
531531      {
532         mame_timer_enable(dmasound_timer, 0);
532         timer_enable(dmasound_timer, 0);
533533      }
534534   }
535535}
r1293r1294
598598      if (!dmasound.active)
599599      {
600600         atariste_dmasound_set_state(1);
601         mame_timer_adjust(dmasound_timer, time_zero, 0, MAME_TIME_IN_HZ(DMASOUND_RATE[dmasound.mode & 0x03]));
601         timer_adjust(dmasound_timer, attotime_zero, 0, ATTOTIME_IN_HZ(DMASOUND_RATE[dmasound.mode & 0x03]));
602602      }
603603   }
604604   else
605605   {
606606      atariste_dmasound_set_state(0);
607      mame_timer_enable(dmasound_timer, 0);
607      timer_enable(dmasound_timer, 0);
608608   }
609609}
610610
r1293r1294
663663   int shift;
664664} mwire;
665665
666static mame_timer *microwire_timer;
666static emu_timer *microwire_timer;
667667
668668static void atariste_microwire_shift(void)
669669{
r1293r1294
698698      atariste_microwire_shift();
699699      lmc1992_enable_w(1);
700700      mwire.shift = 0;
701      mame_timer_enable(microwire_timer, 0);
701      timer_enable(microwire_timer, 0);
702702      break;
703703   }
704704}
r1293r1294
710710
711711static WRITE16_HANDLER( atariste_microwire_data_w )
712712{
713   if (!mame_timer_enabled(microwire_timer))
713   if (!timer_enabled(microwire_timer))
714714   {
715715      mwire.data = data;
716      mame_timer_adjust(microwire_timer, time_zero, 0, MAME_TIME_IN_USEC(2));
716      timer_adjust(microwire_timer, attotime_zero, 0, ATTOTIME_IN_USEC(2));
717717   }
718718}
719719
r1293r1294
724724
725725static WRITE16_HANDLER( atariste_microwire_mask_w )
726726{
727   if (!mame_timer_enabled(microwire_timer))
727   if (!timer_enabled(microwire_timer))
728728   {
729729      mwire.mask = data;
730730   }
r1293r1294
15971597
15981598   cpunum_set_irq_callback(0, atarist_int_ack);
15991599
1600   dmasound_timer = mame_timer_alloc(atariste_dmasound_tick);
1601   microwire_timer = mame_timer_alloc(atariste_microwire_tick);
1600   dmasound_timer = timer_alloc(atariste_dmasound_tick);
1601   microwire_timer = timer_alloc(atariste_microwire_tick);
16021602}
16031603
16041604static MACHINE_START( megaste )
src/mess/drivers/ip22.c
r1293r1294
11311131            return;
11321132         }
11331133      }
1134      mame_timer_set(MAME_TIME_IN_HZ(44100), 0, ip22_dma);
1134      timer_set(ATTOTIME_IN_HZ(44100), 0, ip22_dma);
11351135   }
11361136}
11371137
r1293r1294
12011201      verboselog( 0, "    FIFO End: Rowe %04x\n", ( data & PBUS_CTRL_FIFO_END ) >> 24 );
12021202      if( ( data & PBUS_CTRL_DMASTART ) || ( data & PBUS_CTRL_LOAD_EN ) )
12031203      {
1204         mame_timer_set(MAME_TIME_IN_HZ(44100), 0, ip22_dma);
1204         timer_set(ATTOTIME_IN_HZ(44100), 0, ip22_dma);
12051205         nPBUS_DMA_Active = 1;
12061206      }
12071207      return;
r1293r1294
12341234{
12351235   mc_update(machine, 0);
12361236
1237   mame_timer_set(MAME_TIME_IN_MSEC(1), 0, ip22_timer);
1237   timer_set(ATTOTIME_IN_MSEC(1), 0, ip22_timer);
12381238}
12391239
12401240static MACHINE_RESET( ip225015 )
r1293r1294
12461246   RTC_REGISTERB = 0x08;
12471247   RTC_REGISTERD = 0x80;
12481248
1249   mame_timer_set(MAME_TIME_IN_MSEC(1), 0, ip22_timer);
1249   timer_set(ATTOTIME_IN_MSEC(1), 0, ip22_timer);
12501250
12511251   // set up low RAM mirror
12521252   memory_set_bankptr(1, ip22_mainram);
src/mess/drivers/exidy.c
r1293r1294
123123static WRITE8_HANDLER(exidy_fe_port_w);
124124
125125/* timer for exidy serial chip transmit and receive */
126static mame_timer *serial_timer;
126static emu_timer *serial_timer;
127127
128128static TIMER_CALLBACK(exidy_serial_timer_callback)
129129{
r1293r1294
257257
258258static MACHINE_START( exidy )
259259{
260   serial_timer = mame_timer_alloc(exidy_serial_timer_callback);
261   cassette_timer = mame_timer_alloc(exidy_cassette_timer_callback);
260   serial_timer = timer_alloc(exidy_serial_timer_callback);
261   cassette_timer = timer_alloc(exidy_cassette_timer_callback);
262262
263263   wd17xx_init(WD_TYPE_179X, NULL, NULL);
264264}
r1293r1294
278278   
279279   exidy_fe_port_w(0,0);
280280
281   mame_timer_set(time_zero, 0, exidy_reset_timer_callback);
281   timer_set(attotime_zero, 0, exidy_reset_timer_callback);
282282   
283283   floppy_drive_set_geometry(image_from_devtype_and_index(IO_FLOPPY, 0), FLOPPY_DRIVE_DS_80);
284284
r1293r1294
307307   
308308   exidy_fe_port_w(0,0);
309309
310   mame_timer_set(time_zero, 0, exidy_reset_timer_callback);
310   timer_set(attotime_zero, 0, exidy_reset_timer_callback);
311311   
312312   floppy_drive_set_geometry(image_from_devtype_and_index(IO_FLOPPY, 0), FLOPPY_DRIVE_DS_80);
313313}
r1293r1294
466466         /* both are now off */
467467
468468         /* stop timer */
469         mame_timer_adjust(cassette_timer, time_zero, 0, time_zero);
469         timer_adjust(cassette_timer, attotime_zero, 0, attotime_zero);
470470      }
471471      else
472472      {
r1293r1294
478478            cassette_clock_state = 0;
479479            /* start timer */
480480            /* the correct baud rate should be being used here (see bit 6 below) */
481            mame_timer_adjust(cassette_timer, time_zero, 0, MAME_TIME_IN_HZ(4800));
481            timer_adjust(cassette_timer, attotime_zero, 0, ATTOTIME_IN_HZ(4800));
482482         }
483483      }
484484   }
r1293r1294
515515         baud_rate = 1200;
516516      }
517517
518      mame_timer_adjust(serial_timer, time_zero, 0, MAME_TIME_IN_HZ(baud_rate));
518      timer_adjust(serial_timer, attotime_zero, 0, ATTOTIME_IN_HZ(baud_rate));
519519   }
520520
521521   exidy_fe = data;
r1293r1294
792792   MDRV_CPU_PROGRAM_MAP(exidy_mem, 0)
793793   MDRV_CPU_IO_MAP(exidy_io, 0)
794794   MDRV_SCREEN_REFRESH_RATE(50)
795   MDRV_SCREEN_VBLANK_TIME(USEC_TO_SUBSECONDS(200))
795   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(200))
796796   MDRV_INTERLEAVE(1)
797797
798798   MDRV_MACHINE_START( exidy )
src/mess/drivers/a2600.c
r1293r1294
102102   UINT8   latch_64;
103103   UINT8   dlc;
104104   UINT8   shift_reg;
105   mame_timer   *oscillator;
105   emu_timer   *oscillator;
106106} dpc;
107107
108108static UINT8* extra_RAM;
r1293r1294
13721372      if ( data >= supported_screen_heights[i] - 3 && data <= supported_screen_heights[i] + 3 ) {
13731373         if ( supported_screen_heights[i] != current_screen_height ) {
13741374            current_screen_height = supported_screen_heights[i];
1375//            video_screen_configure( 0, 228, current_screen_height, &visarea[i], HZ_TO_SUBSECONDS( MASTER_CLOCK_NTSC ) * 228 * current_screen_height );
1375//            video_screen_configure( 0, 228, current_screen_height, &visarea[i], HZ_TO_ATTOSECONDS( MASTER_CLOCK_NTSC ) * 228 * current_screen_height );
13761376         }
13771377      }
13781378   }
r1293r1294
13851385      if ( data >= supported_screen_heights[i] - 3 && data <= supported_screen_heights[i] + 3 ) {
13861386         if ( supported_screen_heights[i] != current_screen_height ) {
13871387            current_screen_height = supported_screen_heights[i];
1388//            video_screen_configure( 0, 228, current_screen_height, &visarea[i], HZ_TO_SUBSECONDS( MASTER_CLOCK_PAL ) * 228 * current_screen_height );
1388//            video_screen_configure( 0, 228, current_screen_height, &visarea[i], HZ_TO_ATTOSECONDS( MASTER_CLOCK_PAL ) * 228 * current_screen_height );
13891389         }
13901390      }
13911391   }
r1293r1294
17411741            dpc.df[data_fetcher].music_mode = 0;
17421742         }
17431743      }
1744      dpc.oscillator = mame_timer_alloc( modeDPC_timer_callback );
1745      mame_timer_adjust( dpc.oscillator, MAME_TIME_IN_HZ(42000), 0, MAME_TIME_IN_HZ(42000) );
1744      dpc.oscillator = timer_alloc( modeDPC_timer_callback );
1745      timer_adjust( dpc.oscillator, ATTOTIME_IN_HZ(42000), 0, ATTOTIME_IN_HZ(42000) );
17461746      break;
17471747
17481748   case mode32in1:
src/mess/drivers/studio2.c
r1293r1294
400400
401401static DRIVER_INIT( studio2 )
402402{
403   mame_timer_set(time_zero, 0, setup_beep);
404   mame_timer_set(MAME_TIME_IN_MSEC(200), 0, set_cpu_mode);
403   timer_set(attotime_zero, 0, setup_beep);
404   timer_set(ATTOTIME_IN_MSEC(200), 0, set_cpu_mode);
405405}
406406
407407static int mpt02_colorram_r(UINT16 addr)
r1293r1294
426426
427427static DRIVER_INIT( mpt02 )
428428{
429   mame_timer_set(time_zero, 0, mpt02_setup_beep);
429   timer_set(attotime_zero, 0, mpt02_setup_beep);
430430   cdp1864_configure(&mpt02_CDP1864_interface);
431431}
432432
src/mess/drivers/pcw.c
r1293r1294
776776   roller_ram_offset = 0;
777777
778778   /* timer interrupt */
779   mame_timer_pulse(MAME_TIME_IN_HZ(300), 0, pcw_timer_interrupt);
779   timer_pulse(ATTOTIME_IN_HZ(300), 0, pcw_timer_interrupt);
780780
781   mame_timer_set(time_zero, 0, setup_beep);
781   timer_set(attotime_zero, 0, setup_beep);
782782}
783783
784784
src/mess/drivers/mk2.c
r1293r1294
9494
9595static MACHINE_START( mk2 )
9696{
97   mame_timer_pulse(MAME_TIME_IN_HZ(60), 0, update_leds);
97   timer_pulse(ATTOTIME_IN_HZ(60), 0, update_leds);
9898}
9999
100100static MACHINE_RESET( mk2 )
src/mess/drivers/coleco.c
r1293r1294
228228{
229229    cpunum_set_input_line_vector(0, 0, 0xff);
230230   memset(&memory_region(REGION_CPU1)[0x6000], 0xff, 0x400);   // initialize RAM
231    mame_timer_pulse(MAME_TIME_IN_MSEC(20), 0, paddle_callback);
231    timer_pulse(ATTOTIME_IN_MSEC(20), 0, paddle_callback);
232232}
233233
234234static MACHINE_DRIVER_START( coleco )
src/mess/drivers/saturn.c
r1293r1294
18621862static WRITE32_HANDLER( minit_w )
18631863{
18641864   logerror("cpu #%d (PC=%08X) MINIT write = %08x\n",cpu_getactivecpu(), activecpu_get_pc(),data);
1865   cpu_boost_interleave(double_to_mame_time(minit_boost_timeslice), MAME_TIME_IN_USEC(minit_boost));
1865   cpu_boost_interleave(double_to_attotime(minit_boost_timeslice), ATTOTIME_IN_USEC(minit_boost));
18661866   cpu_trigger(1000);
18671867   cpunum_set_info_int(1, CPUINFO_INT_SH2_FRT_INPUT, PULSE_LINE);
18681868}
r1293r1294
18701870static WRITE32_HANDLER( sinit_w )
18711871{
18721872   logerror("cpu #%d (PC=%08X) SINIT write = %08x\n",cpu_getactivecpu(), activecpu_get_pc(),data);
1873   cpu_boost_interleave(double_to_mame_time(sinit_boost_timeslice), MAME_TIME_IN_USEC(sinit_boost));
1873   cpu_boost_interleave(double_to_attotime(sinit_boost_timeslice), ATTOTIME_IN_USEC(sinit_boost));
18741874   cpunum_set_info_int(0, CPUINFO_INT_SH2_FRT_INPUT, PULSE_LINE);
18751875}
18761876
r1293r1294
22882288   MDRV_CPU_PROGRAM_MAP(sound_mem, 0)
22892289
22902290   MDRV_SCREEN_REFRESH_RATE(60)
2291   MDRV_SCREEN_VBLANK_TIME(USEC_TO_SUBSECONDS(192))   // guess, needed to force video update after V-Blank OUT interrupt
2291   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(192))   // guess, needed to force video update after V-Blank OUT interrupt
22922292
22932293   MDRV_MACHINE_START(saturn)
22942294   MDRV_MACHINE_RESET(saturn)
src/mess/drivers/ql.c
r1293r1294
8181   int mdrdw, mdselck, mdseld, erase, raw1, raw2;
8282} zx8302;
8383
84static mame_timer *zx8302_txd_timer, *zx8302_ipc_timer, *zx8302_rtc_timer;
84static emu_timer *zx8302_txd_timer, *zx8302_ipc_timer, *zx8302_rtc_timer;
8585
8686static void zx8302_interrupt(UINT8 line)
8787{
r1293r1294
200200   }
201201   */
202202
203   mame_timer_adjust(zx8302_txd_timer, time_zero, 0, MAME_TIME_IN_HZ(baud));
204   mame_timer_adjust(zx8302_ipc_timer, time_zero, 0, MAME_TIME_IN_HZ(baudx4));
203   timer_adjust(zx8302_txd_timer, attotime_zero, 0, ATTOTIME_IN_HZ(baud));
204   timer_adjust(zx8302_ipc_timer, attotime_zero, 0, ATTOTIME_IN_HZ(baudx4));
205205
206206   //logerror("ZX8302 Baud Rate : %u\n", baud);
207207}
r1293r1294
664664   zx8302.comctl = 1;
665665   zx8302.comdata = 1;
666666
667   zx8302_txd_timer = mame_timer_alloc(zx8302_txd_tick);
668   zx8302_ipc_timer = mame_timer_alloc(zx8302_ipc_tick);
669   zx8302_rtc_timer = mame_timer_alloc(zx8302_rtc_tick);
667   zx8302_txd_timer = timer_alloc(zx8302_txd_tick);
668   zx8302_ipc_timer = timer_alloc(zx8302_ipc_tick);
669   zx8302_rtc_timer = timer_alloc(zx8302_rtc_tick);
670670
671   mame_timer_adjust(zx8302_rtc_timer, time_zero, 0, MAME_TIME_IN_HZ(X2/32768));
671   timer_adjust(zx8302_rtc_timer, attotime_zero, 0, ATTOTIME_IN_HZ(X2/32768));
672672
673673   zx8302.ctr = time(NULL) + 283996800;
674674
src/mess/drivers/amiga.c
r1293r1294
191191   MDRV_CPU_VBLANK_INT(amiga_scanline_callback, 262)
192192
193193   MDRV_SCREEN_REFRESH_RATE(59.997)
194   MDRV_SCREEN_VBLANK_TIME(USEC_TO_SUBSECONDS(0))
194   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(0))
195195
196196   MDRV_MACHINE_RESET( amiga )
197197
src/mess/drivers/apple1.c
r1293r1294
242242      are visible, and each character time is 7 dot times; a dot time
243243      is 2 cycles of the fundamental 14.31818 MHz oscillator.  The
244244      total blanking time is about 4450 microseconds. */
245   MDRV_SCREEN_VBLANK_TIME(USEC_TO_SUBSECONDS((int) (70 * 65 * 7 * 2 / 14.31818)))
245   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC((int) (70 * 65 * 7 * 2 / 14.31818)))
246246   MDRV_INTERLEAVE(1)
247247
248248   MDRV_MACHINE_RESET( apple1 )
src/mess/drivers/abc80x.c
r1293r1294
8484#include "machine/abcbus.h"
8585#include "video/abc80x.h"
8686
87static mame_timer *abc800_ctc_timer;
87static emu_timer *abc800_ctc_timer;
8888
8989/* Read/Write Handlers */
9090
r1293r1294
651651   state_save_register_global(abc77_keylatch);
652652   state_save_register_global(abc77_clock);
653653
654   abc800_ctc_timer = mame_timer_alloc(abc800_ctc_tick);
655   mame_timer_adjust(abc800_ctc_timer, time_zero, 0, MAME_TIME_IN_HZ(ABC800_X01/2/2/2));
654   abc800_ctc_timer = timer_alloc(abc800_ctc_tick);
655   timer_adjust(abc800_ctc_timer, attotime_zero, 0, ATTOTIME_IN_HZ(ABC800_X01/2/2/2));
656656
657657   z80ctc_init(0, &abc800_ctc_intf);
658658   z80sio_init(0, &abc800_sio_intf);
src/mess/drivers/tmc2000e.c
r1293r1294
283283   // enable power led
284284   set_led_status(2, 1);
285285
286   mame_timer_set(time_zero, 0, setup_beep);
286   timer_set(attotime_zero, 0, setup_beep);
287287
288288   cdp1864_configure(&tmc2000e_CDP1864_interface);
289289}
src/mess/drivers/tmc1800.c
r1293r1294
420420
421421static DRIVER_INIT( tmc1800 )
422422{
423   mame_timer_set(time_zero, 0, setup_beep);
423   timer_set(attotime_zero, 0, setup_beep);
424424}
425425
426426static DRIVER_INIT( tmc2000 )
427427{
428   mame_timer_set(time_zero, 0, setup_beep);
428   timer_set(attotime_zero, 0, setup_beep);
429429   cdp1864_configure(&tmc2000_CDP1864_interface);
430430}
431431
src/mess/drivers/crvision.c
r1293r1294
357357   sn76489_ready = 0;
358358
359359   // wait 32 cycles of 2 MHz to synchronize CPU and SN76489
360   mame_timer_set(MAME_TIME_IN_USEC(16), 0, sn76489_set_ready);
360   timer_set(ATTOTIME_IN_USEC(16), 0, sn76489_set_ready);
361361}
362362
363363static WRITE8_HANDLER( pia_cb2_w )
src/mess/drivers/einstein.c
r1293r1294
14531453   /* the einstein keyboard can generate a interrupt */
14541454   /* the int is actually clocked at the system clock 4Mhz, but this would be too fast for our
14551455   driver. So we update at 50Hz and hope this is good enough. */
1456   mame_timer_pulse(MAME_TIME_IN_HZ(50), 0, einstein_keyboard_timer_callback);
1456   timer_pulse(ATTOTIME_IN_HZ(50), 0, einstein_keyboard_timer_callback);
14571457
14581458   /* the input to channel 0 and 1 of the ctc is a 2mhz clock */
14591459   einstein_ctc_trigger = 0;
1460   mame_timer_pulse(MAME_TIME_IN_HZ(2000000), 0, einstein_ctc_trigger_callback);
1460   timer_pulse(ATTOTIME_IN_HZ(2000000), 0, einstein_ctc_trigger_callback);
14611461
14621462   centronics_config(0, einstein_cent_config);
14631463   /* assumption: select is tied low */
src/mess/drivers/exelv.c
r1293r1294
209209         io_state = IOS_NOP;
210210         break;
211211      case IOS_RESET:
212         mame_timer_set(MAME_TIME_IN_USEC(100), 0, io_reset_timer);
212         timer_set(ATTOTIME_IN_USEC(100), 0, io_reset_timer);
213213         break;
214214      case IOS_STSPEECH1:
215215         io_state = IOS_STSPEECH2;
src/mess/drivers/mephisto.c
r1293r1294
183183static MACHINE_START( mephisto )
184184{
185185  lcd_shift_counter=3;
186  // mame_timer_pulse(MAME_TIME_IN_HZ(60), 0, update_leds);
187   mame_timer_pulse(MAME_TIME_IN_HZ(600), 0, update_nmi);
186  // timer_pulse(ATTOTIME_IN_HZ(60), 0, update_leds);
187   timer_pulse(ATTOTIME_IN_HZ(600), 0, update_nmi);
188188  // cpunum_set_input_line(0, M65C02_IRQ_LINE,CLEAR_LINE);
189189  //beep_set_frequency(0, 4000);
190190}
src/mess/drivers/amstrad.c
r1293r1294
17981798The CRTC generates a memory address using it's MA and RA signal outputs
17991799The Gate-Array fetches two bytes for each address*/
18001800
1801//   mame_timer_pulse(MAME_TIME_IN_USEC(AMSTRAD_US_PER_SCANLINE), 0, amstrad_vh_execute_crtc_cycles);
1802   mame_timer_pulse(MAME_TIME_IN_USEC(1), 0, amstrad_vh_execute_crtc_cycles_callback);
1801//   timer_pulse(ATTOTIME_IN_USEC(AMSTRAD_US_PER_SCANLINE), 0, amstrad_vh_execute_crtc_cycles);
1802   timer_pulse(ATTOTIME_IN_USEC(1), 0, amstrad_vh_execute_crtc_cycles_callback);
18031803
18041804   /* The opcode timing in the Amstrad is different to the opcode
18051805   timing in the core for the Z80 CPU.
r1293r1294
22872287
22882288   MDRV_SCREEN_REFRESH_RATE(AMSTRAD_FPS)
22892289   MDRV_INTERLEAVE(1)
2290   MDRV_SCREEN_VBLANK_TIME(USEC_TO_SUBSECONDS(19968))
2290   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(19968))
22912291
22922292   MDRV_MACHINE_RESET( amstrad )
22932293
src/mess/drivers/a310.c
r1293r1294
8383static UINT32 a310_timercnt[4], a310_timerout[4];
8484static UINT32 a310_sndstart, a310_sndend, a310_sndcur;
8585
86static mame_timer *vbl_timer, *timer[4], *snd_timer;
86static emu_timer *vbl_timer, *timer[4], *snd_timer;
8787
8888VIDEO_START( a310 )
8989{
r1293r1294
139139   a310_request_irq_a(A310_IRQA_VBL);
140140
141141   // set up for next vbl
142   mame_timer_adjust(vbl_timer, video_screen_get_time_until_pos(0, a310_vidregs[0xb4], 0), 0, time_never);
142   timer_adjust(vbl_timer, video_screen_get_time_until_pos(0, a310_vidregs[0xb4], 0), 0, attotime_never);
143143}
144144
145145static void a310_set_timer(int tmr)
r1293r1294
148148
149149//   logerror("IOC: starting timer %d, %d ticks, freq %f Hz\n", tmr, a310_timercnt[tmr], freq);
150150
151   mame_timer_adjust(timer[tmr], MAME_TIME_IN_HZ(freq), tmr, time_never);
151   timer_adjust(timer[tmr], ATTOTIME_IN_HZ(freq), tmr, attotime_never);
152152}
153153
154154// param
r1293r1294
216216   a310_pagesize = 0;
217217   wd17xx_init(WD_TYPE_1772, a310_wd177x_callback, NULL);
218218
219   vbl_timer = mame_timer_alloc(a310_vblank);
220   mame_timer_adjust(vbl_timer, time_never, 0, time_never);
219   vbl_timer = timer_alloc(a310_vblank);
220   timer_adjust(vbl_timer, attotime_never, 0, attotime_never);
221221
222   timer[0] = mame_timer_alloc(a310_timer);
223   timer[1] = mame_timer_alloc(a310_timer);
224   timer[2] = mame_timer_alloc(a310_timer);
225   timer[3] = mame_timer_alloc(a310_timer);
226   mame_timer_adjust(timer[0], time_never, 0, time_never);
227   mame_timer_adjust(timer[1], time_never, 0, time_never);
228   mame_timer_adjust(timer[2], time_never, 0, time_never);
229   mame_timer_adjust(timer[3], time_never, 0, time_never);
222   timer[0] = timer_alloc(a310_timer);
223   timer[1] = timer_alloc(a310_timer);
224   timer[2] = timer_alloc(a310_timer);
225   timer[3] = timer_alloc(a310_timer);
226   timer_adjust(timer[0], attotime_never, 0, attotime_never);
227   timer_adjust(timer[1], attotime_never, 0, attotime_never);
228   timer_adjust(timer[2], attotime_never, 0, attotime_never);
229   timer_adjust(timer[3], attotime_never, 0, attotime_never);
230230
231   snd_timer = mame_timer_alloc(a310_audio_tick);
232   mame_timer_adjust(snd_timer, time_never, 0, time_never);
231   snd_timer = timer_alloc(a310_audio_tick);
232   timer_adjust(snd_timer, attotime_never, 0, attotime_never);
233233
234234   // reset the DAC to centerline
235235   DAC_signed_data_w(0, 0x80);
r1293r1294
371371{
372372   double time;
373373
374   time = mame_time_to_double(mame_timer_timeelapsed(timer[tmr]));
374   time = attotime_to_double(timer_timeelapsed(timer[tmr]));
375375   time *= 2000000.0;   // find out how many 2 MHz ticks have gone by
376376   a310_timerout[tmr] = a310_timercnt[tmr] - (UINT32)time;
377377}
r1293r1294
600600         video_screen_configure(0, a310_vidregs[0x80], a310_vidregs[0xa0], &visarea, Machine->screen[0].refresh);
601601
602602         // slightly hacky: fire off a VBL right now.  the BIOS doesn't wait long enough otherwise.
603         mame_timer_adjust(vbl_timer, time_zero, 0, time_never);
603         timer_adjust(vbl_timer, attotime_zero, 0, attotime_never);
604604      }
605605   
606606      a310_vidregs[reg] = val>>12;
r1293r1294
647647
648648               a310_sndcur = a310_sndstart;
649649
650               mame_timer_adjust(snd_timer, MAME_TIME_IN_HZ(sndhz), 0, MAME_TIME_IN_HZ(sndhz));
650               timer_adjust(snd_timer, ATTOTIME_IN_HZ(sndhz), 0, ATTOTIME_IN_HZ(sndhz));
651651            }
652652            else
653653            {
654               mame_timer_adjust(snd_timer, time_never, 0, time_never);
654               timer_adjust(snd_timer, attotime_never, 0, attotime_never);
655655               DAC_signed_data_w(0, 0x80);
656656            }
657657            break;
src/mess/drivers/avigo.c
r1293r1294
453453{
454454   /* a timer used to check status of pen */
455455   /* an interrupt is generated when the pen is pressed to the screen */
456   mame_timer_pulse(MAME_TIME_IN_HZ(50), 0, avigo_dummy_timer_callback);
456   timer_pulse(ATTOTIME_IN_HZ(50), 0, avigo_dummy_timer_callback);
457457
458458   add_reset_callback(machine, avigo_machine_reset);
459459}
src/mess/drivers/psx.c
r1293r1294
186186      if( !m_pad[ n_port ].b_ack )
187187      {
188188         m_pad[ n_port ].b_ack = 1;
189         mame_timer_set( MAME_TIME_IN_USEC( 2 ), n_port, psx_pad_ack );
189         timer_set( ATTOTIME_IN_USEC( 2 ), n_port, psx_pad_ack );
190190      }
191191   }
192192}
r1293r1294
299299   if( b_ack )
300300   {
301301      m_pad[ n_port ].b_ack = 0;
302      mame_timer_set( MAME_TIME_IN_USEC( 10 ), n_port, psx_pad_ack );
302      timer_set( ATTOTIME_IN_USEC( 10 ), n_port, psx_pad_ack );
303303   }
304304}
305305
src/mess/drivers/tutor.c
r1293r1294
8787static TIMER_CALLBACK(tape_interrupt_handler);
8888
8989static char tape_interrupt_enable;
90static mame_timer *tape_interrupt_timer;
90static emu_timer *tape_interrupt_timer;
9191
9292/* parallel interface state */
9393static UINT8 printer_data;
r1293r1294
102102
103103static DRIVER_INIT(tutor)
104104{
105   tape_interrupt_timer = mame_timer_alloc(tape_interrupt_handler);
105   tape_interrupt_timer = timer_alloc(tape_interrupt_handler);
106106
107107   memory_configure_bank(1, 0, 1, memory_region(REGION_CPU1) + basic_base, 0);
108108   memory_configure_bank(1, 1, 1, memory_region(REGION_CPU1) + cartridge_base, 0);
r1293r1294
289289         {
290290            tape_interrupt_enable = ! data;
291291            if (tape_interrupt_enable)
292               mame_timer_adjust(tape_interrupt_timer, /*MAME_TIME_IN_HZ(44100)*/time_zero, 0, MAME_TIME_IN_HZ(44100));
292               timer_adjust(tape_interrupt_timer, /*ATTOTIME_IN_HZ(44100)*/attotime_zero, 0, ATTOTIME_IN_HZ(44100));
293293            else
294294            {
295               mame_timer_adjust(tape_interrupt_timer, time_never, 0, time_zero);
295               timer_adjust(tape_interrupt_timer, attotime_never, 0, attotime_zero);
296296               cpunum_set_input_line(0, 1, CLEAR_LINE);
297297            }
298298         }
src/mess/drivers/svision.c
r1293r1294
3131
3232struct
3333{
34   mame_timer *timer1;
34   emu_timer *timer1;
3535   int timer_shot;
3636} svision;
3737
r1293r1294
4040   int state;
4141   int on, clock, data;
4242   UINT8 input;
43   mame_timer *timer;
43   emu_timer *timer;
4444} svision_pet;
4545
4646struct
r1293r1294
8686static TIMER_CALLBACK(svision_timer)
8787{
8888    svision.timer_shot = TRUE;
89    mame_timer_enable(svision.timer1, FALSE);
89    timer_enable(svision.timer1, FALSE);
9090    svision_irq();
9191}
9292
r1293r1294
125125         svision_irq();
126126         break;
127127      default:
128         logerror("%.6f svision read %04x %02x\n", mame_time_to_double(mame_timer_get_time()),offset,data);
128         logerror("%.6f svision read %04x %02x\n", attotime_to_double(timer_get_time()),offset,data);
129129         break;
130130   }
131131
r1293r1294
145145      case 3:
146146         break;
147147      case 0x26: /* bits 5,6 memory management for a000? */
148         logerror("%.6f svision write %04x %02x\n", mame_time_to_double(mame_timer_get_time()),offset,data);
148         logerror("%.6f svision write %04x %02x\n", attotime_to_double(timer_get_time()),offset,data);
149149         memory_set_bankptr(1, memory_region(REGION_USER1) + ((svision_reg[0x26] & 0xe0) << 9));
150150         svision_irq();
151151         break;
r1293r1294
157157            delay = 16384;
158158         else
159159            delay = 256;
160         mame_timer_enable(svision.timer1, TRUE);
161         mame_timer_reset(svision.timer1, MAME_TIME_IN_CYCLES(value * delay, 0));
160         timer_enable(svision.timer1, TRUE);
161         timer_reset(svision.timer1, ATTOTIME_IN_CYCLES(value * delay, 0));
162162         break;
163163      case 0x10: case 0x11: case 0x12: case 0x13:
164164         svision_soundport_w(svision_channel + 0, offset & 3, data);
r1293r1294
173173         svision_noise_w(offset - 0x28, data);
174174         break;
175175      default:
176         logerror("%.6f svision write %04x %02x\n", mame_time_to_double(mame_timer_get_time()), offset, data);
176         logerror("%.6f svision write %04x %02x\n", attotime_to_double(timer_get_time()), offset, data);
177177         break;
178178   }
179179}
r1293r1294
432432
433433static DRIVER_INIT( svision )
434434{
435   svision.timer1 = mame_timer_alloc(svision_timer);
435   svision.timer1 = timer_alloc(svision_timer);
436436   svision_pet.on = FALSE;
437437   memory_set_bankptr(2, memory_region(REGION_USER1) + 0x1c000);
438438}
439439
440440static DRIVER_INIT( svisions )
441441{
442   svision.timer1 = mame_timer_alloc(svision_timer);
442   svision.timer1 = timer_alloc(svision_timer);
443443   memory_set_bankptr(2, memory_region(REGION_USER1) + 0x1c000);
444   svision.timer1 = mame_timer_alloc(svision_timer);
444   svision.timer1 = timer_alloc(svision_timer);
445445   svision_pet.on = TRUE;
446   svision_pet.timer = mame_timer_alloc(svision_pet_timer);
447   mame_timer_pulse(scale_up_mame_time(MAME_TIME_IN_SEC(8), 256/Machine->drv->cpu[0].clock), 0, svision_pet_timer); 
446   svision_pet.timer = timer_alloc(svision_pet_timer);
447   timer_pulse(attotime_mul(ATTOTIME_IN_SEC(8), 256/Machine->drv->cpu[0].clock), 0, svision_pet_timer); 
448448}
449449
450450static MACHINE_RESET( svision )
src/mess/drivers/bbc.c
r1293r1294
728728   MDRV_CPU_VBLANK_INT(bbcb_vsync, 1)            /* screen refresh interrupts */
729729   MDRV_CPU_PERIODIC_INT(bbcb_keyscan, 1000)      /* scan keyboard */
730730   MDRV_SCREEN_REFRESH_RATE(50)
731   MDRV_SCREEN_VBLANK_TIME(USEC_TO_SUBSECONDS(128))
731   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(128))
732732   MDRV_INTERLEAVE(1)
733733
734734   MDRV_MACHINE_START( bbca )
r1293r1294
792792   MDRV_CPU_VBLANK_INT(bbcb_vsync, 1)            /* screen refresh interrupts */
793793   MDRV_CPU_PERIODIC_INT(bbcm_keyscan, 1000)      /* scan keyboard */
794794   MDRV_SCREEN_REFRESH_RATE(50)
795   MDRV_SCREEN_VBLANK_TIME(USEC_TO_SUBSECONDS(128))
795   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(128))
796796   MDRV_INTERLEAVE(1)
797797
798798   MDRV_MACHINE_START( bbcm )
docs/messnew.txt
r1293r1294
10.120.1
10.121
22
33New System Drivers Supported (in no particular order):
44------------------------------------------------------
whatsnew.txt
r1293r1294
10.12
10.121
22-----
33
44
55MAMETesters Bugs Fixed
66----------------------
7dunhuang0120u3gra [Vas Crabb]
78
89
10
911Source Changes
1012--------------
11Added "native" architecture option to the makefile. Use this to have
12gcc automatically pick the most appropriate architecture based on
13the system that it is compiling on. [Christophe Jaillet]
13Updated DIP locations in the following drivers: [Vas Crabb]
14 - bublbobl.c: bublbobl, tokio
15 - cps1.c: all games
16 - dunhuang.c: dunhuang
17 - mario.c: marked all as active high (confirmed from manuals)
18 - segag80r.c: astrob2, astrob1, spaceod and pignewt
19 - segag80v.c: all games, fixed switch ordering
1420
15Hooked up the KL5C80 communications CPU to the HNG64 BIOS and emulated
16some of its features. [Andrew Gardner, Justin Kerk]
21Made more functions static to reduce namespace pollution.
22[Atari Ace]
1723
18Fixed a few pointer truncation bugs in the Windows 64-bit code.
19Enabled warnings for 64-bit pointer truncations. Merged the x86 and
20x64 manifests. [Atari Ace]
24Improvements to the Touchmaster driver, still labelled not working.
25You can actually play tm and tm3k, but sometimes you have to reset
26because they stop registering the touchscreen input. tm4k is
27protected and hence totally unplayable. [Luca Elia]
2128
22Changed 6821 PIA logging so that it only logs core messages once.
23[Tim Lindner]
29Fixed compilation problems with altivec accelerators. [Vas Crabb]
2430
25Updates to various NeoGeo ROMsets. Some ROM names updated to match
26verified names from chip labels. A lot of "older" sets have been
27redumped to investigate the "64k m1/s1 issue" (also the m1
28"overdumps"). Result was, ALL m1 ARE at least 128kx8; ALL s1 ARE
29128kx8. The old m1 "overdumps" were incomplete dumps. In addition,
30it has been discovered that all "p-roms" do have a minimum size of
314mbit. A number of sets have been restored to their "original"
32state, and a number of others have been marked as bad dumps where
33appropriate. Specific changes include: [Johnboy]
34 - bjourney: readded 128k m1 from Mame v0.34b5
35 - bstars: fully redumped, added correct m1
36 - bstars2: fully redumped, added correct m1
37 - goalx3: readded 128k m1 from Mame v0.34b5
38 - janshin: readded 128k m1 from Mame v0.34b5
39 - joyjoy: added correct m1
40 - legendos: readded 128k m1 from Mame v0.34b5
41 - maglord: fully redumped, added correct m1
42 - mutnat: partially redumped, added correct m1
43 - nam1975: fully redumped, added correct m1/s1
44 - ncombata: fully redumped, renamed set to ncombath
45 - neomrdo: readded 128k s1 from Mame v0.34b5
46 - pbobblen: readded 128k m1 from Mame v0.34b5
47 - puzzledp: readded 128k s1 from Mame v0.34b5
48 - ridhero: fully redumped, added correct s1
49 - socbrawl: readded 128k s1 from Mame v0.34b5
50 - ssideki2: fully redumped
51 - strhoop: readded 128k m1 from Mame v0.34b5
52 - svc: removed MVS tag, only one version exists (AES/MVS/PCB)
53 - svcboot: removed MVS tag
54 - tws96: readded 128k m1 from Mame v0.34b5
55 - viewpoin: readded 128k m1/s1 from Mame v0.34b5
56 - wh2j: partially redumped, renamed to wh2jh, is verified AES version
57 - wh2j: fully redumped, is verified MVS version
58 - wh1h: fully redumped, is verified AES version
59 - wh1ha: renamed from wh1h to wh1ha
31Fixed bug in Voodoo statistics accumulation. [Atari Ace]
6032
61Made several more traditional optimizations to the voodoo emulations,
62gaining a few percent improvement. [Aaron Giles]
33Reverted to old behavior where even with -switchres disabled,
34MAME will use exclusive mode when rendering with Direct3D. This
35means some of the switching to/from fullscreen mode problems will
36come back, but should prevent confusion over poor performance by
37default. [Aaron Giles]
6338
64Further tweaked the work code to appropriately check for work items
65versus checking for the number of outstanding items. [Aaron Giles]
39Made it a non-fatal error if we are unable to change a joystick to
40absolute mode in the Windows input code. Some drivers apparently
41freak out about this. [Aaron Giles]
6642
67Simplified some of the model2 rendering code. [Aaron Giles]
43Defined a couple more inline functions: div_64x32_rem and the
44unsigned equivalent divu_64x32_rem. Added inline implementations
45for GCC x86 and MSVC. [Aaron Giles, Vas Crabb]
6846
69Moved a number of files from mame/machine and mame/video to
70emu/machine and emu/video. In general, files that emulate a common
71industry standard chip (as opposed to custom, manufacturer-specific
72chips) were moved. Further moves may happen in the future to
73isolate common system-level components (such as amiga, snes, etc.).
74[Aaron Giles, Curt Coder]
47Cleaned up timer interfaces. Created new module attotime which manages
48a new structure type attotime, equivalent to the old mame_time. All
49time math functions are now implemented in attotime and have been
50removed from timer.h. The following search/replace over the code has
51been made:
7552
53   mame_time              -> attotime
54   subseconds_t           -> attoseconds_t
55   time_zero              -> attotime_zero
56   time_never             -> attotime_never
57   
58   make_mame_make         -> attotime_make
59   mame_time_to_subseconds-> attotime_to_attoseconds
60   mame_time_to_double    -> attotime_to_double
61   double_to_mame_time    -> double_to_attotime
62   add_mame_times         -> attotime_add
63   add_subseconds_to_mame_time -> attotime_add_subseconds
64   sub_mame_times         -> attotime_sub
65   sub_subseconds_from_mame_time -> attotime_sub_subseconds
66   scale_up_mame_time     -> attotime_mul
67   scale_down_mame_time   -> attotime_div
68   compare_mame_times     -> attotime_compare
7669
70   SUBSECONDS_TO_DOUBLE   -> ATTOSECONDS_TO_DOUBLE
71   DOUBLE_TO_SUBSECONDS   -> DOUBLE_TO_ATTOSECONDS
72   USEC_TO_SUBSECONDS     -> ATTOSECONDS_IN_USEC
73   SUBSECONDS_TO_HZ       -> ATTOSECONDS_TO_HZ
74   HZ_TO_SUBSECONDS       -> HZ_TO_ATTOSECONDS
75   MAME_TIME_IN_HZ        -> ATTOTIME_IN_HZ
76   MAME_TIME_IN_SEC       -> ATTOTIME_IN_SEC
77   MAME_TIME_IN_MSEC      -> ATTOTIME_IN_MSEC
78   MAME_TIME_IN_USEC      -> ATTOTIME_IN_USEC
79   MAME_TIME_IN_NSEC      -> ATTOTIME_IN_NSEC
80   MAME_TIME_TO_CYCLES    -> ATTOTIME_TO_CYCLES
81   MAME_TIME_IN_CYCLES    -> ATTOTIME_IN_CYCLES
82   
83In addition, all the mame_timer_* functions have been renamed back to
84their original names timer_*, so it is timer_set() instead of
85mame_timer_set() once again. The mame_timer object itself has been
86renamed to emu_timer.
7787
88
89
7890New games added or promoted from NOT_WORKING status
7991---------------------------------------------------
80Hayaoshi Quiz Ouza Ketteisen - The King Of Quiz [Luca Elia]
92Best Of Best [Luca Elia]
8193
8294
8395
8496New clones added
8597----------------
86World Heroes (set 3) [Johnboy]
87World Heroes 2 Jet (set 2) [Johnboy]
88Nightmare in the Dark (bootleg) [Johnboy]
98Cluedo (prod. 2) [James Wallace]
8999
90100
91101
920.119u4
1020.120u4
93103-------
94104
95NOTE TO OSD PORTERS: The work interfaces have changed again. Please
96read details below. The updated interfaces remove functionality, so
97in the end it should be simpler(!) to port.
98105
99
100
101106MAMETesters Bugs Fixed
102107----------------------
103parodius0111u3gra [Mike Green]
104ghostb0105u4gra [Mike Green]
105seibuspisingle099u9yel [couriersud]
106futspy0114gra [Mike Green]
107finalizr0102u5gra [Mike Green]
108gijoe0114gra [Mike Green]
109playch10_0109gre [Mike Green]
108gradius4_0120u3yel [Aaron Giles]
109vegas.c0120u3yel [Aaron Giles]
110110
111111
112112
113113Source Changes
114114--------------
115Moved Hayaoshi Quiz Ouza Ketteisen to its own driver. [David Haywood]
115Made some minor changes in the inline code. The result of
116atomic_add32 isn't used a lot of the time, so the final addition was
117brought out to allow it to be optimized away. Removed the unnecessary
118delta argument from atomic_increment32 and atomic_decrement32 in
119eminline.h, and added implementations.  Changed the condition for
120using rgbsse.h to include 32-bit platforms with SSE enabled.
121[Vas Crabb]
116122
117Added coin counters to cabal bootleg and hooked up the 2 sample player
118CPUs in cabal bootleg. It seems there still are some problems, because
119the coin up music is played during the game. [Pierpaolo Prazzoli]
123Did a major clean-up of the input ports in ssv.c. Brought out the
124common joystick, mahjong and quiz input setups, and then used 
125PORT_INCLUDE to pull them in when needed. Also brought out the 
126common coinage settings, to avoid needless repetition. [Vas Crabb]
120127
121More improvements to the Vs. Janshi Brandnew Stars driver.
122[David Haywood]
128Analyzed all driver interfaces (DRIVER_INIT, READ8_HANDLER, etc.) to
129determine which ones should be made static and properly tagged them
130all to reduce global namespace pollution. Some cases turned out to be
131dead code, which was also properly tagged. [Atari Ace]
123132
124More SCSP improvements: [El Semi]
125 - Fixed endianness issue on 8-bit samples and added interpolation
126 - Disabled modulation attempt (should fix the crash problems)
127 - Tweeked pitch calculation
133Updated the Tube Panic driver, fixing the background scroll-in (it's
134smooth again now). The problem was caused by wrong synchronization
135between main and slave CPUs. Also modified the video driver to be
136scanline accurate and implemented more accurate interrupt handling.
137[Jarek Burczynski]
128138
129Added the repeat count register (reg 0x34) access and immediate value
130load to the MB86233 core (needed by Pilot kids). [El Semi]
139Altered TTL low high levels in res_net.c. This will broaden the color
140range a bit. Since the results are normalized, there is only a limited
141effect visible. [couriersud]
131142
132Cleaned up the inputs, and fixed flipscreen in dynax.c. [Luca Elia]
143Cleaned up inputs and added dip locations in ms32.c. Also fixed dips
144in "47pie2" and "akiss". [Sonikos]
133145
134Fixed several issues in seibuspi.c: [couriersud]
135 - added sound to rdft2us
136 - added coin-handling to single board games
137 - fix interrupt handling
138 - for rfjetus, adds a hack to enable Test-Switch to enter testmode
139    if no nvram exists
146Fixed bug that caused incorrect input to be read if multiple inputs
147were mapped to the same mouse input under Windows. [Nathan Woods]
140148
141Fixed several issues in the i386 core: [couriersud]
142 - the INTR-line for i386 is a "level" line; changed interrupt
143    handling to trigger on asserted line
144 - in 32bit mode, determine trap/interrupt from gate-header
145 - interrupt line is read during two bus cycles. Adjust CYCLES
146    accordingly.
149Fixed a bug in the i8051 core that improperly fired the Timer2
150interrupt when it wasn't enabled. [Jim Stolis]
147151
148Added coin DIP switches and "teleport hole" DIP switch to crushs.
149[sonikos]
152Updates to the peplus driver: [Jim Stolis]
153 * Added lightpen support
154 * Added PE+ Superboard support
155 * Added ABC coin optics support
156 * Added full I2C eeprom support
157 * Added NVRAM support
158 * Corrected door closure issues
159 * Removed most memory hacks
160 * Consolidated machines and inputs
161 * New layout for pepp0158
150162
151Bug fixes for the z80gb cpu core: [Wilbert Pol]
152 - Fixed cycle count for taking an interrupt
153 - Fixed cycle count for BIT X,(HL) instructions
154 - Fixed flags in RRCA instruction
155 - Fixed DAA instruction
156 - Fixed flags in ADD SP,n8 instruction
157 - Fixed flags in LD HL,SP+n8 instruction
163Split up the MPU4 driver into a core and driver set up a la NeoGeo.
164Also made some timer fixes, and added some new ROMs added.
165[James Wallace]
158166
159Fixed the linking issues when specifying MSVC_BUILD=1 and DEBUG=1.
160[Oliver Stoneberg]
167Fixed problems introduced when the junofrst blitter code was
168simplified. [Chris Hardy]
161169
162Fixed a compile error on architectures where "char" is unsigned
163(notably some PowerPC configurations). [Bill Blake]
170American Poker II major rewrite: [Roberto Fresca]
171 - Properly dervied clocks from crystals
172 - Reworked TILE_GET_INFO to handle the proper tiles/color codes.
173 - Fixed interrupts (NMI).
174 - Corrected AY8910 frequency to 1.5 MHz to match the real thing.
175 - Arranged the AY8910 volume in all games avoiding clips.
176 - Corrected the screen visible area.
177 - Added NVRAM support.
178 - Reworked the memory map, mapping all the hardware I/O ports.
179 - Reworked the Inputs for all sets.
180 - Added implementation of Operator and Supervisor Keys.
181 - Fixed some timing troubles.
182 - Added partial DIP switch support with diplocations to all sets.
183 - Removed the hack in DRIVER_INIT.
184 - Hooked write handlers for output ports.
185 - Added watchdog routines.
186 - Dumped, hooked, wired and decoded the color PROM in all sets.
187 - Modified the refresh rate according to hardware measurements.
188 - Wired the lamps for all sets. Created their respective layouts.
189 - Splitted the driver to driver/video.
190 - Other minor fixes.
164191
165Added two more filters to the headon crash sound. Now, only the
166envelopes for the crash sound filters are missing. [couriersud]
192SCSP fixes: [kingshriek]
193 * Fixed DECAY1 envelope state to not exit immediately
194 * Improved support for LPSLNK and SBCTL
195 * Fixed panning calculation bug
196 * Fixed case where key-rate scaling is off
167197
168Loverboy input fixes: [wolf676]
169 - added and verified all DSW
170 - added and verified Button1 for both players
198Added support for indicating that DIP switches are reversed in the
199DIP locations view. [Vas Crabb]
171200
172Added color PROMs for Cannon Ball. [Rob Walmsley]
201Added DIP locations for Midway Tron and the Nintendo Donkey Kong
202series (dkong.c). [Vas Crabb]
173203
174Fixed several out-of-bounds array accesses in the code. [Andi]
204Added an Altivec/VMX implementation of the RGB utilities for our
205friends with G4, G5 and POWER5 CPUs (rgbvmx.h) and added
206rgbint_bilinear_filter and rgbaint_bilinear_filter to rgbsse.h (based 
207on rgb_bilinear_filter/rgba_bilinear_filter) for completeness, as 
208these functions exist in rgbgen.h. [Vas Crabb]
175209
176Fixed mask rom test in prmrsocr. [Pierpaolo Prazzoli]
177
178Fixed 64-bit DRC bug that broke kinst in the previous release.
210Updated model2.c, taitojc.c, and gticlub.c to use the new polygon
211routines. Deprecated the old poly.c and renamed polynew.* to poly.*.
179212[Aaron Giles]
180213
181Added code to detect potential hotspots in the 64-bit DRC. Added
182hotspots to all the seattle.c games and several of the vegas.c games.
214Unified poly.c callbacks so that tri and quad callbacks work the
215same way. [Aaron Giles]
216
217Fixed display of floating point TMS32031 registers in the debugger.
183218[Aaron Giles]
184219
185Simplified the osd_work implementation. Removed the concept of shared
186work items. Added new function osd_work_item_queue_multiple() which
187allows efficient queueing of large numbers of work items. Changed
188previous osd_work_item_queue() function into an inline that calls the
189new function. [Aaron Giles]
220Fixed TMS32031 ABSF opcode to work as documented and not produce a
221proper negative. [Aaron Giles]
190222
191Updated Voodoo code to use the new work functions. It now queues
192small scanline chunks as independent items rather than using shared
193items. Updated code to also copy some parameters to allow for greater
194overlapping of emulation and rendering. [Aaron Giles]
195223
196For Windows work functions, added new scalable lock implementation
197that hopefully has better performance characteristics when scaling
198above 2 CPUs. [Aaron Giles]
199224
200For Windows work functions, added statistics gathering code. This is
201on by default for the moment to help point to problems that might be
202encountered with this version. [Aaron Giles]
203
204
205
206225New games added or promoted from NOT_WORKING status
207226---------------------------------------------------
208Jongkyo [David Haywood, Nicola Salmoria]
209Hayaoshi Quiz Grand Champion Taikai [David Haywood]
210Hayaoshi Quiz Nettou Namahousou [David Haywood]
211Super Real Mahjong Part 1 (Japan) [David Haywood]
212Hana wo Yaraneba! (Japan) [Luca Elia]
213Hanafuda Hana Tengoku (Japan) [Luca Elia]
214227Player's Edge Plus (PP0516) Double Bonus Poker [Jim Stolis]
228Player's Edge Plus (PP0158) 4 of a Kind Bonus Poker [Jim Stolis]
229Player's Edge Plus (PP0188) Standard Draw Poker [Jim Stolis]
230Player's Edge Plus (Set038) Set Chip [Jim Stolis]
231Player's Edge Plus (BE0014) Blackjack [Jim Stolis]
232Player's Edge Plus (KE1012) Keno [Jim Stolis]
233Player's Edge Plus (PS0615) Video Slots [Jim Stolis]
234Player's Edge Plus (PS0716) Video Slots [Jim Stolis]
235Player's Edge Plus (XP000019) Deuces Wild Poker [Jim Stolis]
236Player's Edge Plus (XS000006) Triple Triple Diamond Slots [Jim Stolis]
237MPU4 Unit Test [James Wallace]
238Sigma Poker [Roberto Fresca]
215239
216240
217241
218242New clones added
219243----------------
220Toride II Adauchi Gaiden (Japan) [David Haywood]
221Pang (bootleg, set 3) [David Haywood]
222Super Bobble Bobble (set 1) [David Haywood]
223Airwolf (US) [David Haywood]
224Golden Tee '97 Tournament (v2.43) [Brian Troha]
244Slipstream (950515 HISPANIC) [Guru]
245Kick and Run (US) [Brian Troha]
246American Poker 95 [Roberto Fresca]
247Poker De Win [Roberto Fresca]
225248
226249
227250
228251New games marked as GAME_NOT_WORKING
229252------------------------------------
230GTI Poker [David Haywood]
231Poker? (IGS) [David Haywood]
232Hanajingi [Luca Elia]
233GP World [Andrew Gardner]
253Vegas Poker (Prototype) [James Wallace]
254Sigma Poker 2000 [Roberto Fresca]
234255
235256
236257
2370.119u3
2580.120u3
238259-------
239260
240IMPORTANT NOTE FOR OSD PORTERS: This build requires a pair of new
241primitives in the OSD synchronization module, as well as some extended
242functionality in the work item management. See below for details.
243261
244
245
246262MAMETesters Bugs Fixed
247263----------------------
248cabal0119u2ora [David Haywood]
264neodriv0117u3red [Hairu]
265kof10th0120u2yel [Robbbert]
2666800basedgames0120u2red [Curt Coder]
267mpatrol0120u2yel [Curt Coder]
249268
250269
251270
252271Source Changes
253272--------------
254Fixed Cabal (joystick) submission from previous release.
255[David Haywood]
273Cleaned up the inline assembly for both x86 and PPC, enabled the
274mul32 family assembly stuff on 32-bit x86, and fixed some compiler
275warnings on 64-bit GCC. In addition: [Vas Crabb]
276 * Provided single-precision reciprocal approximation code for
277    PowerPC and x86 with SSE2.
278 * Filled in all other TBD functions in eigccx86.h for completeness.
279 * Conditionalised some code in eigccppc.h so that it isn't used
280    when the compiler has 64-bit instructions available.
256281
257Made a few improvements to dealem (well you can see the game now..)
258[David Haywood]
282Added static qualifiers and renamed symbols in MAME in an effort
283to further tidy up the global namespace. Generally generic names were
284targeted and some symbols that were both static and extern. Some
285specifics: [Atari Ace]
286 * K053247_ram was made static throughout and the existing
287    K053247_export_config was used to obtain the value in xmen.c.
288 * The enums DS1991_STATE and DSP_TYPE were unused and were therefore
289    removed.
290 * Dead code in cps3.c and thayers.c was discovered and commented out.
259291
260Fixed broken SCSP from last update. [R. Belmont]
292Made almost all input port definitions static. [Aaron Giles]
261293
262Changed parameters to read/write handlers from "address" to an
263unmodified "original_address" parameter (having the passed parameter
264being unmodified makes it easier to determine the original value while
265debugging). [Nathan Woods]
294Obsoleted the GAMEB macro, which is no longer necessary. [Atari Ace]
266295
267Fixed colors in dynduke. [David Haywood]
296Fixed casting issues in new inline validity checks. [R. Belmont]
268297
269Changed the following x86 instructions to read/write an entire word
270rather than two separate bytes: [Philip Bennett]
271 - mov_axdisp
272 - mov_dispax
273 - stosw (8086 only)
274 - rep stosw (8086 only)
275Also tweaked handling of x86 WAIT instruction.
298Some build-related improvements to the sound cores: [Atari Ace]
299 * The SCSP dependency on mame/drivers/stv.c was removed allowing it
300    to built independent of the driver.
301 * The WAVE dependency on MESS code was made explicit, so it can be
302    built independentally of MESS.
303 * VOTRAX can now be built independentally of SAMPLES.
304 * The YM2612 core now can be built without including the YM3438 core.
305 * Unnecessary uses of BUILD_ and HAS_ macros have been removed.
306 * BUILD_ instead of HAS_ macros are used in 3812intf.c for
307    consistency with the other fm cores.
276308
277Several more opcode fixes for Risky Challenge. [robiza]
309Added DIP locations to several SSV games (in ssv.c). [Vas Crabb]
278310
279Cleaned up the include file usage in the code: [Atari Ace]
280 - Removed dead prototypes
281 - Added missing self-#includes
282 - Added missing source comments in mame/includes
283 - Migrated the few #include "driver.h" lines from driver header
284    files to source files (which is the common idiom).
285 - Eliminated #include "mame.h", "osdcore.h" et cetera from driver
286    files where #include "driver.h" would suffice.
287 - Removed unused srmp6.h and 9900stat.h
311Corrected some errors in the SH4 core and implemented store queues
312and the basics of DMA. Added a call to simulate dma transfers with
313external devices. [Samuele Zannoli]
288314
289Added the rom loading for the various 5*XX roms, which are dumped but
290not yet hooked up. [David Haywood]
291
292Fixed error messages output from option.c. [Christophe Jaillet]
293
294gstream driver update: [Pierpaolo Prazzoli]
295 - Changed to use a default nvram handler
296 - Checked the inputs
297 - Aligned the sprites
298 - Added some comments about oki banking
299 
300Major Sega Model 2 rewrite: [Ernesto Corvi]
301 - Decoupled the geometry engine code from the hardware rasterizer.
302    At this point, we could add emulation of the geometry DSPs for
303    the 2B and 2C models, and hook them directly to the rasterizer.
304    For the original and 2A models, an HLE geometry engine is provided
305    (currently in use for all models).
306 - Full Geometry Engine simulation, including support for specular,
307    multiple centers and dual polygon RAM.
308 - Support for all textured/transparent/checkered rendering modes.
309 - Improved texel/luma modulation
310 - Improved viewport clipping
311 - Improved z clipping
312 - Extensive notes and documentation.
313 - Greatly improved near Z-Clipping, still not perfect though.
314 - Improved perspective-correct texturing for large textures.
315 - Improved Z-Sorting
316 
317Changed Machine to machine in several places where feasible.
318[Atari Ace]
319
320Added decryption of Jongkyo. [Nicola Salmoria]
321
322The OSD layer is now required to supply to additional synchronization
323primitives: osd_compare_exchange32() and osd_compare_exchange64().
324These primitives should implement an atomic compare and exchange of
32532-bit and 64-bit values, respectively. Added implementations of these
326functions to the Windows OSD layer. [Aaron Giles]
327
328Defined two new inline functions that are built on the new OSD
329primitives: osd_compare_exchange_ptr(), which performs an atomic
330compare/exchange on a pointer of the appropriate size, and
331osd_sync_add() which atomically adds a value to a location in memory.
315Expanded polynew.c to support quad rendering. Converted midvunit.c
316over to using the new quad rendering, which fixes a number of
317rendering issues that have plagued the driver since the start.
332318[Aaron Giles]
333319
334Changed implementation of OSD work queues that are created with the
335WORK_QUEUE_FLAG_MULTI hint. Such queues now create n-1 threads, where
336n in the number of logical processors in the system. This allows the
337main thread to continue accomplishing things while other threads
338process the work. If the main thread subsequently calls
339osd_work_queue_wait(), it will then dynamically "jump in" and help
340the other threads complete all the work items. [Aaron Giles]
320Added Z-clipping logic to polynew.c. Converted namcos22 over to using
321that code. Simplified namcos22 significantly, working in quads
322throughout the lower-level pipeline and then handing the results off
323to polynew.c. [Aaron Giles]
341324
342Added new work item flag WORK_ITEM_FLAG_SHARED. When specified on a
343work item that is queued to a work queue created with the
344WORK_QUEUE_FLAG_MULTI hint, it means that all threads will be
345dispatched to process the one work item, instead of the first thread
346removing it. These "shared" work items are only considered complete
347when all processing threads have returned. [Aaron Giles]
325Updated model3.c to use the new poly code, and changed much of the
326low-level implementation to make things easier. [Aaron Giles]
348327
349Added support for controlling multithreading behavior through an
350environment variable OSDPROCESSORS. To override the default behavior,
351set OSDPROCESSORS equal to the number of logical processors you wish
352the OSD layer to pretend you have. [Aaron Giles]
328Defined a couple of new functions in eminline.h: atomic_increment32
329and atomic_decrement32. [Aaron Giles]
353330
354Changed the 3dfx Voodoo emulation code to take advantage of the new
355threading mechanisms above. It now creates a work queue with the
356WORK_QUEUE_FLAG_MULTI flag set, and uses shared work items to spread
357rasterization work across multiple processors. Note that this support
358should be considered experimental; under some circumstances it is
359known to deadlock. If you encounter problems, set OSDPROCESSORS to 1
360to effectively produce the previous behavior. [Aaron Giles]
361331
362Added "top 20" dedicated rasterizers for all the Seattle games and
363Gauntlet Legends/Dark Legacy. These improve rasterization performance
364by another 10-20%. [Aaron Giles]
365332
366Fixed several more bugs in the 64-bit MIPS recompiler. It is now
367capable of running the Seattle games and the 3D Gauntlets.
368[Aaron Giles]
369
370
371
372333New games added or promoted from NOT_WORKING status
373334---------------------------------------------------
374Super Hana Paradise [Luca Elia]
375Hanafuda Hana Gokou [Luca Elia]
376Mahjong Tian Jiang Shen Bing [Pierpaolo Prazzoli]
335Every Second Counts [Philip Bennett]
336Treble Top [Philip Bennett]
337Quizvaders [Philip Bennett]
377338
378339
379340
380341New clones added
381342----------------
382Nekketsu Koukou Dodgeball Bu (Japan) [David Haywood, Team Japump!]
383Puzzle Game Rong Rong (Japan) [Luca Elia]
384Legend of Hero Tonma (Japan) [David Haywood]
385Legend of Hero Tonma (bootleg, set 2) [David Haywood]
386IQ-Block (V127M, V113FR) [Pierpaolo Prazzoli]
387Cabal (Alpha Trading) [David Haywood]
388Puzzle & Action: Tant-R (Japan) (bootleg set 3) [David Haywood]
389Shinobi (Datsu bootleg) [David Haywood]
390Shinobi (Star bootleg, System 16A) [David Haywood]
391Crack Down (World, FD1094 317-0058-04c) [Arzeno Fabrice, Chris Hardy]
392Super Pang (World 900914, bootleg) [David Haywood]
393Pang (bootleg, set 2) [David Haywood]
394Tehkan World Cup (set 2, bootleg?) [David Haywood]
395DJ Boy (set 2) [David Haywood]
396Hunchback (set 2) [David Haywood]
397Double Dragon (bootleg with M6803) [David Haywood]
398Cannon Ball (Pacman Hardware) [David Haywood]
343Extermination (Japan) [Corrado Tomaselli]
344Gang Busters (set 2) [Patrik Styrnell]
345Trog (rev LA5 03/29/91) [icronnya77]
399346
400347
401348
402349New games marked as GAME_NOT_WORKING
403350------------------------------------
404Jongkyo [David Haywood, Nicola Salmoria]
405Vs. Janshi Brandnew Stars [David Haywood]
351Inquizitor [Philip Bennett]
406352
407353
408354
4090.119u2
3550.120u2
410356-------
411357
412358
413359MAMETesters Bugs Fixed
414360----------------------
415model2c_crx0119u1red [R. Belmont]
361hornet0120u1red [Ville Linde]
362srmp6_0120u1ora [Aaron Giles]
416363
417364
418365
419366Source Changes
420367--------------
421Changed gfx_decode structures so that they are defined abstractly
422by macros rather than directly specifying the structures. Added
423new macros GFXDECODE_START/GFXDECODE_ENTRY/GFXDECODE_END to
424describe the gfx_decode information. Converted all drivers over to
425using the new macros. [Atari Ace]
368Rewrote ACIA6850 implementation. [Curt Coder]
426369
427Fixed NMI handling in h6280 CPU core. [Wilbert Pol]
370Did a complete overhaul of the Mad Alien driver. [Stefan Jokish]
371 - merged memory maps and added mirror addresses
372 - doubled sound chip frequency
373 - implemented IRQ acknowledge for the sound CPU
374 - added stub functions for missing discrete sounds
375 - re-implemented tilemaps (now the tunnel walls scroll into view)
376 - hooked up 6845 CRT controller
377 - made several fixes related to color handling
378 - cleaned up inputs and added dip switch locations
379 - raised main CPU speed (guesswork)
380 - added save state support
428381
429Fixed vaportra to use an ASSERT/CLEAR mechanism instead of PULSE_LINE
430for interrupt signally. [Wilbert Pol]
382Repaired the IC24 timer behaviour to fix some of Deal 'Em's bugs,
383and also added inputs. [James Wallace]
431384
432Cleaned up input ports in sg1000a.c. Added DIP switch for the coins
433in dokidoki and service switch. Added DIP switch for flip screen in
434psychic5. [sonikos]
385Added save state support to skykid. [Mike Haaland]
435386
436Cleans up the input port for macrossp.c driver and adds dip
437locations. [Brian Troha]
387Fixed tiny.mak based on new source reorg. [Tiago Pierezan Camargo]
438388
439Adds dip locations and changes the Japanese inputs into
440PORT_INCLUDE and PORT_MODIFY. [Brian Troha]
389Added support for CR-589 firmware to the System 573 driver. Made
390substantial changes to the SCSI support, making it require fewer
391hacks, and allowing one device to be derived from another. Also
392added save state support. [smf]
441393
442Added macros to clean up definitions of the discrete sound
443interfaces. At the same time, made them all const. [Atari Ace]
394Added SCI support to M6803/HD63701. [Curt Coder]
444395
445Some miscellaneous changes to the megatech driver. [David Haywood]
396Fixed several misnamed sound samples interfaces. [Atari Ace]
446397
447More srmp6 improvements. [686]
398Switched model1 lookup functions to be index based rather than
399requiring a linear scan. [Atari Ace]
448400
449Two small Model 2 fixes: [Ernesto Corvi]
450 - fixed triangle parser; all objects should be structurally
451    correct now
452 - fixed normal transform to not use the translation vectors
401Added generic I2C bus memory support. Hooked up to the cubocd32
402driver. [smf]
453403
454Cleaned up code to make code and data static where possible and
455remove some dead code. [Atari Ace]
404Cleaned up inline assembly support: [Aaron Giles]
405 * moved all inlinable functions into new module eminline.h
406 * defined a number of new inline functions, including:
407    - 32x32 -> 64 bit multiply
408    - fast approximate floating point reciprocal
409 * removed old inline definitions from osinline.h, osd_cpu.h, etc.
410 * eminline.h contains C implementations of everything
411 * new module eigccx86.h contains GCC-compatible x86/64 versions
412 * new module eigccppc.h contains GCC-compatible PowerPC versions
413 * eminline.h automatically detects GCC environments and includes
414    appropriate file
415 * osinline.h now only used in non-GCC environments
416 * updated osd/windows/osinline.h to contain MSVC-compatible versions
456417
457SCSP improvements: [R. Belmont, ElSemi]
458 - fixed issue with changing the pitch of an active voice set to
459    backwards or bidirectional loop
460 - removed fake reverb
461 - fixed internal DSP to operate properly
462 - rewrote timers and interrupt handling
463 - fixed operation when 2 SCSPs are present
418Added NORM implementation to the TMS32031 core. [Aaron Giles]
464419
465Fixed sound in almost all SCSP-equipped Model 2 games. [R. Belmont]
420Created new rgbutil module which consists of inline functions for
421common RGB manipulation. This module can be accelerated with SSE2 or
422other SIMD operations. By default, only 64-bit Intel builds make use
423of SSE, since it can be assumed on those platforms. Reimplemented the
424namcos22 rasterizer in terms of these inline functions. Also updated
425the gaelco3d rasterizer to use this module for faster bilinear
426filtering. [Aaron Giles]
466427
467Added sound hardware and fixed sound ROM loading in Model 3 games.
468[R. Belmont]
469
470Created an options_output_diff_ini_file() API, which is similar to
471options_output_ini_file(), but only outputs the options which are
472different than a base core_options. Changed INI outputting (and
473hence the -cc option) to omit headers that do not contain any
474options. [Nathan Woods]
475
476Hooked up sound in discoboy. [Tomasz Slanina]
477
478Renamed old gfx_decode structure to gfx_decode_entry in order to
479catch remaining/new drivers that aren't using the new macros.
428Made some progress on the Midway Zeus-based system. The 3d command
429stream is now parsed and the format is partially understood, enough to
430display some polygons but with incorrect textures in Mortal Kombat 4.
480431[Aaron Giles]
481432
482Changed profiler so that it is independently selected versus the
483debug build. Built with MAME_PROFILER=1 to enable the profiler on
484a non-debug build. [Aaron Giles]
485433
486Fixed MIPS3 disassembly of j/jal instructions. [Aaron Giles]
487434
488Switched MIPS3 64-bit DRC over to new system that is more aggressive
489about register allocation and mapping. Sadly, there is little to no
490obvious performance benefit, but the resulting code is better
491organized. [Aaron Giles]
492
493Fixed nasty x86emit bug involving 16-bit opcodes on 64-bit systems.
494[Aaron Giles]
495
496Created new generic x86/x64 logging system x86log, and updated both
497MIPS3 DRC cores to use it. [Aaron Giles]
498
499Created new generic DRC frontend management. Future work involves
500retooling the MIPS3 frontend around this new architecture.
501[Aaron Giles]
502
503
504
505435New games added or promoted from NOT_WORKING status
506436---------------------------------------------------
507Loverboy [David Haywood]
508Mahjong Shinkirou Deja Vu (Japan) [Luca Elia]
509Final Godori (Korea, version 2.20.5915) [Pierpaolo Prazzoli]
510Jibun wo Migaku cultures School Mahjon Hen [Pierpaolo Prazzoli]
511Mahjong Fantastic Love (Japan) [Luca Elia]
512Domino Block [Tomasz Slanina, David Haywood]
437Konami CD-ROM Drive Updater (700A04) [smf]
438Vs. Janshi Brandnew Stars [sonikos]
513439
514440
515441
516442New clones added
517443----------------
518Fighter's History (Japan ver 42-03) [Team Japump!]
519Janyou Part II (ver 7.03, July 1 1983) [Team Japump!]
444Eco Fighters (USA 940215) [Nicola Salmoria, Razoola]
520445
521446
522447
523448New games marked as GAME_NOT_WORKING
524449------------------------------------
525Jan Oh [Luca Elia]
526Mahjong Vegas (Japan) [Luca Elia]
527Esh's Aurunmilla [Andrew Gardner]
528Mirage Youjuu Mahjongden (Japan) [Team Japump!]
450Time Machine v2.0 [James Wallace]
451Jet Wave [Ville Linde, Guru]
529452
530453
531454
5320.119u1
4550.120u1
533456-------
534457
535458
536459MAMETesters Bugs Fixed
537460----------------------
538createconfig+debug0119yel [Nathan Woods]
539jrpacman0119gre [Aaron Giles]
461ikki0120yel [robiza]
462buckrog0118u2yel [couriersud]
540463
541464
542465
543466Source Changes
544467--------------
545Fixed crash/display corruption in System C2 and System 18 games.
546[David Haywood]
468Documented information about the various Cannonball sets.
469[stephh]
547470
548Synchronized the MB86233 core with ElSemi's, fixing a few bugs
549along the way. [Ernesto Corvi]
471Hooked up the roz layer, fg layer and sprites to f1gpb. Still
472missing some video offsets, oki banking and sprites priority.
473[Pierpaolo Prazzoli]
550474
551Fixed synchronization code in the Model 2 driver. [Ernesto Corvi]
475Updates for the dominob.c driver: [stephh]
476 - fixed dip switches
477 - fixed inputs
478 - added a couple of notes
552479
553Fixed SCALER, SCALERL, and ATANRL opcodes in the i960 core.
554[Ernesto Corvi]
480Updated peplus driver and related components: [Jim Stolis]
481 - added internal layouts for the games
482 - fixed several i8051 issues...
483    * Fixed a bug with some opcodes having the wrong cycle counts
484    * Fixed a bug where determining the proper timer mode
485    * Fixed a bug where determining the proper serial transmit mode
486    * Added support for split timer mode
555487
556Updates to the gdrawpkr driver: [Roberto Fresca]
557 - Added sound support to "El Grande - 5 Card Draw".
558 - All CPU and sound clocks derived from #defined crystal values.
559 - Some minor input cleanups.
488Improved multiprocessor Voodoo performance by reducing contention
489during rendering. Extended the system to allow for more overlap
490between rendering and emulation. [couriersud, Aaron Giles]
560491
561ARM7 core fixes: [R. Belmont]
562 - Fixed unaligned reads/writes (again)
563 - Fixed minimum instruction bytes to account for Thumb mode
564 - Fixed missing dependency in ARM7 build rule
565 - Fixed Thumb mode ASR instruction
492Fixed a crash in the input system when you configure joypads and
493then unplug them and press Esc on the system info screen.
494[R. Belmont]
566495
567Added newly-dumped BIOS ROMs and preliminary emulation of the SPU
568board in Pop'n Music 7 to the Firebeat driver. [Ville Linde]
496Defined strict types for CPU and sound chips. Removed unnecessary
497cpu_ prefix from several structure members. [Atari Ace]
569498
570Cleaned up input ports in the taito_z.c driver. [Brian Troha]
499Fixed the m4510 cpu core from not updating the instruction cycle
500counter. [Wilbert Pol]
571501
572Updated the sources to support removing -wno-unused-function. Dead
573code has been identified with #ifdef UNUSED_FUNCTION to allow for
574further analysis and potential future removal. [Atari Ace]
502Fixed memory access for m6509 instructions 91 and b1. [Wilbert Pol]
575503
576Fixed a number of issues in the h6280 CPU core: [Wilbert Pol]
577 - Taking of interrupts is delayed to respect a pending instruction
578    already in the instruction pipeline.
579 - Added 1 cycle for decimal mode ADC and SBC instructions.
580 - Changed cycle counts for CSH and CSL instructions to 3.
581 - Added T flag support to the SBC instruction.
582 - Fixed ADC T flag to set the Z flag based on the value read.
583 - Added 3 cycle penalty to ADC, AND, EOR, ORA, and SBC instructions
584    when the T flag is set.
585 - Fixed cycle count and support for 65536 byte blocks for the TAI,
586    TDD, TIA, TII, and TIN instructions.
587 - Fixed RDWORD macro in the disassembler.
588 - Fixed setting of N and V flags in the TST instructions.
589 - Removed unneeded debug_mmr code.
590 - Fixed TSB and TRB instructions.
591 - Added 1 delay when accessing the VDC or VCE areas.
592 - Implemented low and high speed cpu modes.
504Changed osdcore.h to include osinline.h and allow for external
505inline definitions of synchronization primitives. Also added a new
506work queue hint WORK_QUEUE_FLAG_HIGH_FREQ which indicates that we
507should spin aggressively waiting for new items.
508[couriersud, Vas Crabb]
593509
594Moved srmp5 (Super Real Mahjong P5) to separate driver (from
595st0016.c). Preliminary video hw emulation. Not playable, no sound.
596[Tomasz Slanina]
510Enabled common linker warnings in the makefile. [Oliver Stoneberg]
597511
598Fixed DIP switches in the mario driver. [stephh]
512Fixed a corner case in the SCSP involving timers which are polled
513with their IRQ enable shut off. [R. Belmont]
599514
600Major Namco System 21 update. Changes include: [Phil Stroffolino]
601 - corrections to eprom handling (affects Namco System2 as well)
602 - scroll fix for sprite emulation in namcoic.c
603 - working Starblade, Cybersled, Solvalou with full 3d
604 - graphics should be 100% except for the depth cueing tables, which
605    are internal and need to be reconstructed
606 - Air Combat is improved, but is locking up in 118s because of
607    incomplete watchdog emulation
608 - Winning Run hardware is not yet working in this update
515Namco System 21 update: [Phil Stroffolino]
516 - namconb1 sprites no longer broken
517 - fixed missing 3d gfx in Cybersled
518 - gradient colors in starblade
519 - more accurate depth cueing
520 - fixed crash in 2nd stage of Starblade
521 - fixed lockups in Air Combat and Solvalou
522 - fixes to sprite priority (see Solvalou mountain range)
523 - hooked up translucency (palette shift) effect
609524
610Fixed regression in undoukai caused by the REGION_CPU1 decoupling
611from RAM. [Pierpaolo Prazzoli]
612
613SCSP fixes: [R. Belmont]
614 * Fix writes to the hole in the SCSP address space (0x430 to 0x5ff)
615    to not trash global registers
616 * Fixed SCSP DMA to not read random memory for its' registers
617
618Added minimal built-in layout for showing the lamps in Video Pinball.
619[Mr. Do!]
620
621Big Model 2 update. There's so much stuff improved, I'm just going to
622list what's not working: [Ernesto Corvi, El Semi]
623 - There's still a glitch on the triangle parser somewhere.
624    Noticeable on the Sega logo in motoraid, the selection arrow in
625    dynamcop's player select screen and many other games. It might be
626    the culprit of the road in daytona looking wacky.
627 - There's a problem with the z clipping. Some tri's close to the
628    camera are clipped before they should. Some others should be
629    clipped but are not, and are blocking the viewport for a frame
630    or two.
631 - Sub-windows are not implemented yet. Visible on dynacop's mission
632    select, Sega Rally car select, and others.
633 - Most decal textures flicker on and off between frames. Maybe a z
634    coordinate float resolution issue after projection?
635 - Textures wrap by default. They should only wrap when the
636    appropriate flag is set only. Not sure what to do when we're not
637    wrapping.
638
639Improvements to the Z180 core: [Pierpaolo Prazzoli]
640 - added the 2 Programmable Reload Timers
641 - fixed the Internal I/O Registers remapping
642 - added logical -> physical memory translation
643 - disabled loops hack
644 - removed "extra icount"
645 - changed interrupts handling. Now they're checked as in Z80 core
646 - simplified RETN and EI opcodes
647 - fixed PRT interrupts
648 - cleared both interrupts flip flops when taking any irq
649 - added _IFF2 = _IFF1; just before _IFF1 = 0; when taking an NMI
650
651Removed kludge in 20pacgal which is no longer necessary with proper
652Z180 emulation. Sound now works as well. [Pierpaolo Prazzoli]
653
654Fixed some Dip Switches and added some extra notes to othunder.c
655driver. Also added some notes to opwolf.c driver. [stephh]
656
657Began moving the MegaTech/MegaPlay drivers over to the new Genesis
658core code. [David Haywood]
659
660Identified a number of additional new opcodes for Risky Challenge/
661Gussun. [robiza]
662
663Fixed Voodoo video timing according to the manual, including blanking
664periods and vsync interrupts. This makes Carnevil and some other games
665run once again at their proper speed. [Aaron Giles]
666
667Updated Voodoo drawing code to track changes to the front buffer and
668allow skipping unrendered frames for more even framerates.
525Changed Model 2 rendering to use pre-clipped Z values for sorting.
669526[Aaron Giles]
670527
671Fixed hang when attempting to move windows with the debugger active
672and multithreading enabled. [Aaron Giles]
673
674Added preliminary attempt at a new x64 dynamic recompiler for the
675MIPS 3/4 CPUs. The current version works enough to run a few basic
676games (kinst, carnevil), but many others fail. Furthermore, this
677version is already being supplanted by a more advanced version that
678does register allocation and constant folding. For now it is disabled
679by default. [Aaron Giles]
680
681Fixed a few more 64-bit disassembler problems in i386dasm.c. Also
682fixed several 64-bit errors in the code generators in x86emit.h.
528Properly identified bill inputs in Midway Y-unit driver games.
683529[Aaron Giles]
684530
685Added support in the debugger memory view for 8-byte chunk sizes.
686Fixed long-standing bug that failed to show unmapped logical addresses
687as asterisks. Also added new menu items to the Windows debugger to
688support viewing logical or physical memory. [Aaron Giles]
531Added more instrumentation and added some extra paranoia to the
532winwork code. [Aaron Giles]
689533
690Removed limitation that tilemap tile widths must be divisible by
6912, except in the 4bpp case, where an assert now catches this case.
534Fixed some incorrect code in the ADSP2100 external flag handling.
692535[Aaron Giles]
693536
694Experimentally changed full screen behavior when using Direct3D so
695that if -switchres is NOT enabled, then we don't create a fullscreen
696Direct3D device. This minimizes large graphics card transitions (in
697particular it does not disable glass in Vista) when you go full
698screen. If you want the old behavior, run with -switchres and specify
699a -resolution parameter equal to your desktop screen size.
700[Aaron Giles]
537Created new module polynew.c which combines triangle setup,
538rasterization, and Voodoo-like multiprocessor support. Coverted
539Gaelco3D, Midway V-Unit, Namco System 22, and Voodoo drivers over
540to the new system. [Aaron Giles]
701541
542Added threadid parameter to work item callbacks. This allows for
543keeping per-thread information by the callbacks. [Aaron Giles]
702544
703545
546
704547New games added or promoted from NOT_WORKING status
705548---------------------------------------------------
706Deer Hunting USA [Luca Elia]
707Turkey Hunting USA [Luca Elia]
708Wing Shooting Championship [Luca Elia]
709Trophy Hunting - Bear & Moose [Luca Elia]
710Panel & Variety Akamaru Q Jousyou Dont-R [Team Japump]
711Cyber Sled [Phil Stroffolino]
712Solvalou [Phil Stroffolino]
713Super Real Mahjong P6 (Japan) [686]
714Ippatsu Gyakuten [BET] (Japan) [Luca Elia]
715Joryuu Syougi Kyoushitsu (Japan) [Luca Elia]
716Mazin Wars / Mazin Saga (Mega Play) [David Haywood]
717Grand Slam (Mega Play) [David Haywood]
549Mahjong Hot Gimmick Integral (Japan) [Guru, David Haywood]
550Tottemo E Jong [David Haywood, Team Japump!]
551Good E Jong -Kachinuki Mahjong Syoukin Oh!!-
552  [David Haywood, Team Japump!]
553Teraburst [icronnya77, Ville Linde]
718554
719555
720556
721557New clones added
722558----------------
723Scramble (bootleg) [David Haywood]
724Alien Storm (bootleg, set 2) [David Haywood]
725Zero Team Selection [David Haywood]
726Passing Shot (Japan, 4 Players, System 16A, FD1094 317-0071)
727  [Arzeno Fabrice, ShinobiZ, Gerald Coy]
728Pound for Pound (Japan) [Team Japump]
729Big Event Golf (Japan) [Team Japump]
730Special Criminal Investigation (Japan) [Team Japump]
731Royal Mahjong (Japan, v1.13) [Team Japump]
732Cyber Sled (Japan) [Brian Troha]
733Crowns Golf (new set) [Arzeno Fabrice]
734Don Den Lover Vol. 1 - Shiro Kuro Tsukeyo! (Japan) [Team Jampump]
735Mario Bros. (US, set 2) [stephh]
736Puzznic (Italy) [Corrado Tomaselli]
737Don Den Lover Vol. 1 (Korea, bootleg) [David Haywood]
738Boomer Rang'r / Genesis (set 2) [Team Japump]
739Narazumono Sentai Bloody Wolf (Japan) [Team Japump]
740Open Mahjong [BET] (Japan) [Team Japump]
559Tube Panic (bootleg) [sonikos]
560Player's Edge Plus (PP0188) Standard Draw Poker [Jim Stolis]
561Player's Edge Plus (Set038) Set Chip [Jim Stolis]
562Mortal Kombat 4 (set 2) [icronnya77]
563Meteor [Andreas]
741564
742565
743566
744567New games marked as GAME_NOT_WORKING
745568------------------------------------
746Laser Grand Prix [Andrew Gardner]
747Saloon (France, encrypted) [Roberto Fresca]
748Mahjong Cafe Doll (Japan) [Team Japump]
569GameCristal [f205v, R. Belmont]

Previous 15994 Revisions Next


© 1998-2018 The MESS Team