| Previous | 15994 Revisions | Next |
| r2725 Saturday 24th May, 2008 at 15:17:10 UTC by Nathan Woods |
|---|
| Updated to MAME 0.125u2 core; almost certainly broken some natural keyboard functionality and some Win32 frontend code; will rectify these soon Also reverted Robbbert's imgtool change; it looks breaking to me |
| [docs] | messnew.txt |
| [src/emu] | cheat.c config.c config.h crsshair.c emuopts.c info.c inptport.c inptport.h inpttype.h* inputseq.h mame.c mame.h mamecore.h memory.c memory.h render.c sound.c ui.c uigfx.c uimenu.c uimenu.h validity.c |
| [src/emu/cpu] | cpu.mak drcbec.c drcbeut.c drcbeut.h drcbex64.c drcbex86.c drcfe.c drcfe.h drcuml.c drcuml.h drcumld.c drcumlsh.h x86emit.h |
| [src/emu/cpu/mips] | mips3.c mips3com.c mips3com.h mips3drc.c mips3fe.c mips3fe.h r3000.c |
| [src/emu/cpu/powerpc] | ppcdrco.c* |
| [src/emu/cpu/saturn] | satops.c sattable.c saturn.c saturn.h saturnds.c |
| [src/emu/debug] | debugcpu.c |
| [src/emu/machine] | 53c810.c 53c810.h 6522via.c 6522via.h 6526cia.c 6526cia.h 6532riot.c 6532riot.h 6821pia.c 6821pia.h 6840ptm.c 6840ptm.h 68681.c 68681.h am53cf96.c am53cf96.h generic.c pc16552d.c pc16552d.h smc91c9x.c smc91c9x.h tmp68301.c tmp68301.h wd33c93.c wd33c93.h z80ctc.c z80ctc.h z80pio.c z80pio.h z80sio.c z80sio.h |
| [src/emu/sound] | 2151intf.h 2203intf.c 2203intf.h 2608intf.c 2608intf.h 2610intf.c 2610intf.h 2612intf.c 2612intf.h 262intf.c 262intf.h 3812intf.c 3812intf.h 5220intf.h aica.c aica.h disc_inp.c es5503.c es5503.h es5506.c es5506.h ics2115.c ics2115.h k054539.c k054539.h msm5205.c msm5205.h pokey.c pokey.h psx.c psx.h scsp.c scsp.h tms5110.c tms5110r.c tms5220.c tms5220.h ym2151.c ym2151.h ymf271.c ymf271.h ymf278b.c ymf278b.h ymz280b.c ymz280b.h |
| [src/emu/video] | tms9928a.c tms9928a.h v9938.c v9938.h vooddefs.h voodoo.c voodoo.h |
| [src/mame] | mame.mak mamedriv.c |
| [src/mame/audio] | cage.c cage.h cchasm.c cinemat.c cyberbal.c dcs.c exidy.c harddriv.c irem.c jaguar.c jedi.c m72.c m72.h mcr.c seibu.c seibu.h senjyo.c t5182.c taito_en.c williams.c |
| [src/mame/drivers] | 2mindril.c 8080bw.c ace.c acefruit.c actfancr.c aerofgt.c airbustr.c alg.c alpha68k.c amspdwy.c angelkds.c appoooh.c aquarium.c argus.c artmagic.c ashnojoe.c astinvad.c astrocde.c astrof.c asuka.c atarigt.c backfire.c battlane.c battlera.c bbusters.c beathead.c berzerk.c bfcobra.c bfm_sc2.c bigfghtr.c bishi.c bishjan.c blktiger.c blmbycar.c blockout.c bmcbowl.c bnstars.c boogwing.c brkthru.c btime.c bublbobl.c bwing.c cabal.c capbowl.c carrera.c cave.c cbuster.c ccastles.c cchasm.c cclimber.c centiped.c cheekyms.c chinagat.c chinsan.c chqflag.c cinemat.c cischeat.c cliffhgr.c cloud9.c cninja.c compgolf.c cps1.c crbaloon.c crgolf.c crospang.c crshrace.c darius.c darkseal.c dassault.c dblewing.c dbz.c dcheese.c ddealer.c ddragon.c ddragon3.c ddrible.c dec0.c dec8.c deco156.c deco32.c deco_mlc.c deniam.c dgpix.c dietgo.c discoboy.c dlair.c dmndrby.c docastle.c dooyong.c dorachan.c drmicro.c dynax.c enigma2.c eolith.c ertictac.c exerion.c exidy.c exidy440.c exprraid.c exzisus.c f1gp.c fantland.c fcombat.c fcrash.c filetto.c firebeat.c firetrap.c firetrk.c fitfight.c flstory.c fortecar.c fromanc2.c fromance.c funkyjet.c fuukifg2.c fuukifg3.c gaiden.c galaxian.c galdrvr.c galivan.c galpanic.c galspnbl.c gameplan.c gauntlet.c genesis.c gijoe.c gladiatr.c goal92.c gotcha.c gottlieb.c gstriker.c gticlub.c gtipoker.c guab.c gumbo.c gunpey.c hcastle.c hnayayoi.c hng64.c hornet.c hshavoc.c hyperspt.c hyprduel.c igs_blit.c intrscti.c inufuku.c itech32.c itech8.c jchan.c jpmimpct.c jrpacman.c kaneko16.c karnov.c kchamp.c kingpin.c konamigq.c konamigv.c ksys573.c ladybug.c laserbat.c lasso.c lastduel.c lastfght.c lemmings.c lethal.c lethalj.c lkage.c lockon.c looping.c lordgun.c lsasquad.c lwings.c m10.c m107.c m62.c m92.c macrossp.c madalien.c madmotor.c mappy.c mastboy.c matmania.c maxaflex.c mcatadv.c mcr3.c mcr68.c meadows.c megadriv.c megasys1.c meritm.c metlclsh.c metro.c mgolf.c midas.c midzeus.c mirage.c missb2.c missile.c mitchell.c mlanding.c model2.c model3.c mpu4.c mpu4drvr.c mugsmash.c mw8080bw.c mystston.c namcona1.c namconb1.c namcos1.c namcos12.c naomi.c nbmj9195.c nemesis.c neodrvr.c neogeo.c ninjakd2.c ninjaw.c niyanpai.c nmg5.c nmk16.c nwk-tr.c nycaptor.c nyny.c ojankohs.c oneshot.c onetwo.c opwolf.c othldrby.c othunder.c pacman.c pcktgal.c pengo.c pgm.c phoenix.c pipedrm.c pipeline.c pkscram.c pntnpuzl.c polyplay.c powerins.c prehisle.c psikyo.c psikyo4.c psikyosh.c psychic5.c pushman.c qdrmfgp.c r2dtank.c rabbit.c rainbow.c rastan.c rbmk.c realbrk.c renegade.c rohga.c rollrace.c rpunch.c sandscrp.c sangho.c scramble.c seattle.c segag80r.c segag80v.c segahang.c segas16b.c segas24.c segas32.c segaxbd.c segaybd.c seibuspi.c seta.c seta2.c sf.c sg1000a.c shadfrce.c shangha3.c shanghai.c shootout.c sidearms.c sidepckt.c simpsons.c slapfght.c slapshot.c smstrv.c snk.c snk68.c snookr10.c snowbros.c spbactn.c spcforce.c spdodgeb.c spiders.c splash.c spy.c srmp2.c ssfindo.c sshangha.c ssv.c stactics.c stadhero.c steaser.c stepstag.c stfight.c strnskil.c stv.c suna16.c suna8.c supbtime.c superqix.c suprgolf.c suprnova.c suprridr.c suprslam.c surpratk.c system16.c system18.c tail2nos.c taito_b.c taito_f2.c taito_h.c taito_l.c taito_x.c taito_z.c taitoair.c taitojc.c taitosj.c taotaido.c tatsumi.c tbowl.c tecmo.c tecmo16.c tecmosys.c tehkanwc.c tempest.c tetrisp2.c tetriunk.c thedeep.c tigeroad.c tmaster.c tmnt.c tnzs.c toaplan1.c toaplan2.c toki.c topshoot.c topspeed.c toratora.c trackfld.c triplhnt.c trvquest.c tsamurai.c ttchamp.c tubep.c tumbleb.c tumblep.c twincobr.c ultratnk.c ultrsprt.c undrfire.c vaportra.c vball.c vegas.c vicdual.c videopin.c volfied.c vsnes.c wardner.c warriorb.c wc90.c wc90b.c welltris.c wgp.c wheelfir.c wrally.c wwfsstar.c wwfwfest.c xain.c yunsun16.c yunsung8.c zac2650.c zaccaria.c zaxxon.c zn.c zr107.c |
| [src/mame/includes] | atari.h dynax.h genesis.h namcona1.h psx.h |
| [src/mame/layout] | shuttlei.lay* |
| [src/mame/machine] | ajax.c amiga.c atari.c atarigen.c atarigen.h beezer.c daikaiju.c galaxold.c kaneko16.c konamigx.c konamiic.c konamiic.h mcr.c midwayic.c midwayic.h namcos1.c namcos2.c nmk004.c nmk004.h pckeybrd.c psx.c qix.c segaic16.c segaic16.h seicop.c starwars.c stfight.c twincobr.c williams.c |
| [src/mame/video] | aerofgt.c atari.c dkong.c dynax.c exidy440.c f1gp.c galpani2.c gameplan.c groundfx.c gtia.c homedata.c jagobj.c jaguar.c macrossp.c midvunit.c midzeus.c n64.c namcona1.c pacland.c phoenix.c psx.c st0016.c stactics.c taitojc.c undrfire.c victory.c |
| [src/mess] | configms.c filemngr.c inputx.c inputx.h mess.h mesvalid.c tapectrl.c uimess.c uimess.h |
| [src/mess/drivers] | a2600.c adam.c apf.c at.c bbcbc.c cgenie.c coleco.c crvision.c dc.c einstein.c ex800.c geneve.c ip20.c ip22.c kim1.c mpf1.c pc.c pdp1.c psx.c saturn.c sg1000.c sord.c super80.c ti99_4p.c ti99_4x.c ti99_8.c tutor.c x68k.c |
| [src/mess/includes] | apple2gs.h hp48.h msx.h pc8801.h svi318.h vectrex.h |
| [src/mess/machine] | 99_peb.c 99_peb.h aim65.c amigakbd.c apple2gs.c apple3.c atom.c ay3600.c bbc.c bebox.c c64.c cbmb.c coco.c comx35.c concept.c dgn_beta.c geneve.c hp48.c kc.c lisa.c mac.c mbee.c mc6846.c mc6846.h microtan.c msx.c mtx.c oric.c osborne1.c pc8801.c pc_joy.c pce.c pet.c svi318.c sym1.c thomson.c ti99_4x.c ti99_4x.h vc1541.c vc20.c vectrex.c |
| [src/mess/osd/windows] | dialog.c dialog.h menu.c |
| [src/mess/osd/winui] | msuiutil.c |
| [src/mess/tools/imgtool] | imgtool.c |
| [src/mess/tools/messtest] | testmess.c tststubs.c |
| [src/mess/video] | pc_cga.c |
| [src/osd] | osdepend.h |
| [src/osd/windows] | debugwin.c drawd3d.c input.c video.c |
| [src/osd/winui] | mui_util.c |
| r2724 | r2725 | |
|---|---|---|
| 6 | 6 | |
| 7 | 7 | #include "driver.h" |
| 8 | 8 | #include "streams.h" |
| 9 | #include "deprecat.h" | |
| 10 | 9 | #include "cpu/z80/z80.h" |
| 11 | 10 | #include "machine/z80ctc.h" |
| 12 | 11 | #include "cchasm.h" |
| r2724 | r2725 | |
| 132 | 131 | static int channel_active[2]; |
| 133 | 132 | static int output[2]; |
| 134 | 133 | |
| 135 | static void ctc_interrupt (int state) | |
| 134 | static void ctc_interrupt (running_machine *machine, int state) | |
| 136 | 135 | { |
| 137 | cpunum_set_input_line( | |
| 136 | cpunum_set_input_line(machine, 1, 0, state); | |
| 138 | 137 | } |
| 139 | 138 | |
| 140 | 139 | static WRITE8_HANDLER( ctc_timer_1_w ) |
| r2724 | r2725 | |
|---|---|---|
| 261 | 261 | jaguar_wave_rom[0x200 + i] = (int)(32767. * sin(2.0 * M_PI * (double)i / (double)0x80)); |
| 262 | 262 | |
| 263 | 263 | /* F1DA00 = traingle wave with noise */ |
| 264 | jaguar_wave_rom[0x280 + i] = jaguar_wave_rom[0x000 + i] * (mame_rand( | |
| 264 | jaguar_wave_rom[0x280 + i] = jaguar_wave_rom[0x000 + i] * (mame_rand(machine) % 32768) / 32768; | |
| 265 | 265 | |
| 266 | 266 | /* F1DC00 = spike */ |
| 267 | 267 | jaguar_wave_rom[0x300 + i] = (i == 0x40) ? 32767 : 0; |
| 268 | 268 | |
| 269 | 269 | /* F1DE00 = white noise */ |
| 270 | jaguar_wave_rom[0x380 + i] = mame_rand( | |
| 270 | jaguar_wave_rom[0x380 + i] = mame_rand(machine) % 32768; | |
| 271 | 271 | } |
| 272 | 272 | |
| 273 | 273 | #if ENABLE_SPEEDUP_HACKS |
| r2724 | r2725 | |
|---|---|---|
| 1490 | 1490 | }; |
| 1491 | 1491 | |
| 1492 | 1492 | |
| 1493 | static void ctc_interrupt(int state) | |
| 1493 | static void ctc_interrupt(running_machine *machine, int state) | |
| 1494 | 1494 | { |
| 1495 | cpunum_set_input_line( | |
| 1495 | cpunum_set_input_line(machine, 1, 0, state); | |
| 1496 | 1496 | } |
| 1497 | 1497 | |
| 1498 | 1498 |
| r2724 | r2725 | |
|---|---|---|
| 5 | 5 | ****************************************************************************/ |
| 6 | 6 | |
| 7 | 7 | #include "driver.h" |
| 8 | #include "deprecat.h" | |
| 9 | 8 | #include "machine/atarigen.h" |
| 10 | 9 | #include "sound/dac.h" |
| 11 | 10 | #include "includes/cyberbal.h" |
| r2724 | r2725 | |
| 84 | 83 | if (!io_68k_int) |
| 85 | 84 | { |
| 86 | 85 | io_68k_int = 1; |
| 87 | update_sound_68k_interrupts( | |
| 86 | update_sound_68k_interrupts(machine); | |
| 88 | 87 | } |
| 89 | 88 | } |
| 90 | 89 | |
| r2724 | r2725 | |
| 127 | 126 | if (io_68k_int) |
| 128 | 127 | { |
| 129 | 128 | io_68k_int = 0; |
| 130 | update_sound_68k_interrupts( | |
| 129 | update_sound_68k_interrupts(machine); | |
| 131 | 130 | } |
| 132 | 131 | } |
| 133 | 132 | |
| r2724 | r2725 | |
| 161 | 160 | if (fast_68k_int) |
| 162 | 161 | { |
| 163 | 162 | fast_68k_int = 0; |
| 164 | update_sound_68k_interrupts( | |
| 163 | update_sound_68k_interrupts(machine); | |
| 165 | 164 | } |
| 166 | 165 | } |
| r2724 | r2725 | |
|---|---|---|
| 40 | 40 | static UINT8 cpu_to_cage_ready; |
| 41 | 41 | static UINT8 cage_to_cpu_ready; |
| 42 | 42 | |
| 43 | static void (*cage_irqhandler)(int); | |
| 43 | static void (*cage_irqhandler)(running_machine *, int); | |
| 44 | 44 | |
| 45 | 45 | static attotime serial_period_per_word; |
| 46 | 46 | |
| r2724 | r2725 | |
| 161 | 161 | memory_set_bankptr(10, memory_region(boot_region)); |
| 162 | 162 | memory_set_bankptr(11, memory_region(boot_region + 1)); |
| 163 | 163 | |
| 164 | cage_cpu = mame_find_cpu_index( | |
| 164 | cage_cpu = mame_find_cpu_index(machine, "cage"); | |
| 165 | 165 | cage_cpu_clock_period = ATTOTIME_IN_HZ(cpunum_get_clock(cage_cpu)); |
| 166 | 166 | cage_cpu_h1_clock_period = attotime_mul(cage_cpu_clock_period, 2); |
| 167 | 167 | |
| r2724 | r2725 | |
| 174 | 174 | } |
| 175 | 175 | |
| 176 | 176 | |
| 177 | void cage_set_irq_handler(void (*irqhandler)(int)) | |
| 177 | void cage_set_irq_handler(void (*irqhandler)(running_machine *, int)) | |
| 178 | 178 | { |
| 179 | 179 | cage_irqhandler = irqhandler; |
| 180 | 180 | } |
| r2724 | r2725 | |
| 447 | 447 | if ((cage_control & 2) && cage_to_cpu_ready) |
| 448 | 448 | reason |= CAGE_IRQ_REASON_DATA_READY; |
| 449 | 449 | |
| 450 | (*cage_irqhandler)(reason); | |
| 450 | (*cage_irqhandler)(Machine, reason); | |
| 451 | 451 | } |
| 452 | 452 | |
| 453 | 453 | /* set the IOF input lines */ |
| r2724 | r2725 | |
|---|---|---|
| 11 | 11 | MACHINE_DRIVER_EXTERN( cage_seattle ); |
| 12 | 12 | |
| 13 | 13 | void cage_init(running_machine *machine, int boot_region, offs_t speedup); |
| 14 | void cage_set_irq_handler(void (*irqhandler)(int)); | |
| 14 | void cage_set_irq_handler(void (*irqhandler)(running_machine *, int)); | |
| 15 | 15 | void cage_reset_w(int state); |
| 16 | 16 | |
| 17 | 17 | UINT16 main_from_cage_r(void); |
| r2724 | r2725 | |
|---|---|---|
| 6 | 6 | |
| 7 | 7 | |
| 8 | 8 | /* z80 pio */ |
| 9 | static void pio_interrupt(int state) | |
| 9 | static void pio_interrupt(running_machine *machine, int state) | |
| 10 | 10 | { |
| 11 | cpunum_set_input_line( | |
| 11 | cpunum_set_input_line(machine, 1, 0, state); | |
| 12 | 12 | } |
| 13 | 13 | |
| 14 | 14 | static const z80pio_interface pio_intf = |
| r2724 | r2725 | |
| 19 | 19 | }; |
| 20 | 20 | |
| 21 | 21 | /* z80 ctc */ |
| 22 | static void ctc_interrupt (int state) | |
| 22 | static void ctc_interrupt (running_machine *machine, int state) | |
| 23 | 23 | { |
| 24 | cpunum_set_input_line( | |
| 24 | cpunum_set_input_line(machine, 1, 0, state); | |
| 25 | 25 | } |
| 26 | 26 | |
| 27 | 27 | static z80ctc_interface ctc_intf = |
| r2724 | r2725 | |
|---|---|---|
| 530 | 530 | if (~z_mask & 0x20) csdeluxe_status = (csdeluxe_status & ~2) | ((data >> 4) & 2); |
| 531 | 531 | } |
| 532 | 532 | |
| 533 | static void csdeluxe_irq(int state) | |
| 533 | static void csdeluxe_irq(running_machine *machine, int state) | |
| 534 | 534 | { |
| 535 | 535 | int combined_state = pia_get_irq_a(0) | pia_get_irq_b(0); |
| 536 | 536 | |
| 537 | cpunum_set_input_line( | |
| 537 | cpunum_set_input_line(machine, csdeluxe_sound_cpu, 4, combined_state ? ASSERT_LINE : CLEAR_LINE); | |
| 538 | 538 | } |
| 539 | 539 | |
| 540 | 540 | static TIMER_CALLBACK( csdeluxe_delayed_data_w ) |
| r2724 | r2725 | |
| 653 | 653 | if (~z_mask & 0x20) soundsgood_status = (soundsgood_status & ~2) | ((data >> 4) & 2); |
| 654 | 654 | } |
| 655 | 655 | |
| 656 | static void soundsgood_irq(int state) | |
| 656 | static void soundsgood_irq(running_machine *machine, int state) | |
| 657 | 657 | { |
| 658 | 658 | int combined_state = pia_get_irq_a(1) | pia_get_irq_b(1); |
| 659 | 659 | |
| 660 | cpunum_set_input_line( | |
| 660 | cpunum_set_input_line(machine, soundsgood_sound_cpu, 4, combined_state ? ASSERT_LINE : CLEAR_LINE); | |
| 661 | 661 | } |
| 662 | 662 | |
| 663 | 663 | static TIMER_CALLBACK( soundsgood_delayed_data_w ) |
| r2724 | r2725 | |
| 747 | 747 | turbocs_status = (data >> 4) & 3; |
| 748 | 748 | } |
| 749 | 749 | |
| 750 | static void turbocs_irq(int state) | |
| 750 | static void turbocs_irq(running_machine *machine, int state) | |
| 751 | 751 | { |
| 752 | 752 | int combined_state = pia_get_irq_a(0) | pia_get_irq_b(0); |
| 753 | 753 | |
| 754 | cpunum_set_input_line( | |
| 754 | cpunum_set_input_line(machine, turbocs_sound_cpu, M6809_IRQ_LINE, combined_state ? ASSERT_LINE : CLEAR_LINE); | |
| 755 | 755 | } |
| 756 | 756 | |
| 757 | 757 | static TIMER_CALLBACK( turbocs_delayed_data_w ) |
| r2724 | r2725 | |
| 880 | 880 | squawkntalk_tms_strobes = data; |
| 881 | 881 | } |
| 882 | 882 | |
| 883 | static void squawkntalk_irq(int state) | |
| 883 | static void squawkntalk_irq(running_machine *machine, int state) | |
| 884 | 884 | { |
| 885 | 885 | int combined_state = pia_get_irq_a(0) | pia_get_irq_b(0) | pia_get_irq_a(1) | pia_get_irq_b(1); |
| 886 | 886 | |
| 887 | cpunum_set_input_line( | |
| 887 | cpunum_set_input_line(machine, squawkntalk_sound_cpu, M6808_IRQ_LINE, combined_state ? ASSERT_LINE : CLEAR_LINE); | |
| 888 | 888 | } |
| 889 | 889 | |
| 890 | 890 | static TIMER_CALLBACK( squawkntalk_delayed_data_w ) |
| r2724 | r2725 | |
|---|---|---|
| 190 | 190 | timer_call_after_resynch(NULL, CPU_CLEAR,setirq_callback); |
| 191 | 191 | } |
| 192 | 192 | |
| 193 | static void t5182_ym2151_irq_handler(int irq) | |
| 193 | static void t5182_ym2151_irq_handler(running_machine *machine, int irq) | |
| 194 | 194 | { |
| 195 | 195 | if (irq) |
| 196 | 196 | timer_call_after_resynch(NULL, YM2151_ASSERT,setirq_callback); |
| r2724 | r2725 | |
|---|---|---|
| 5 | 5 | ***************************************************************************/ |
| 6 | 6 | |
| 7 | 7 | #include "driver.h" |
| 8 | #include "deprecat.h" | |
| 9 | 8 | #include "irem.h" |
| 10 | 9 | #include "cpu/m6800/m6800.h" |
| 11 | 10 | #include "sound/ay8910.h" |
| r2724 | r2725 | |
| 174 | 173 | * |
| 175 | 174 | *************************************/ |
| 176 | 175 | |
| 177 | static void adpcm_int(int data) | |
| 176 | static void adpcm_int(running_machine *machine, int data) | |
| 178 | 177 | { |
| 179 | cpunum_set_input_line( | |
| 178 | cpunum_set_input_line(machine, 1, INPUT_LINE_NMI, PULSE_LINE); | |
| 180 | 179 | |
| 181 | 180 | /* the first MSM5205 clocks the second */ |
| 182 | 181 | if (sndti_exists(SOUND_MSM5205, 1)) |
| r2724 | r2725 | |
|---|---|---|
| 178 | 178 | */ |
| 179 | 179 | // offset<<=1; |
| 180 | 180 | |
| 181 | //if (offset<7 && es5510_dsp_ram[0]!=0xff) return mame_rand( | |
| 181 | //if (offset<7 && es5510_dsp_ram[0]!=0xff) return mame_rand(machine)%0xffff; | |
| 182 | 182 | |
| 183 | 183 | if (offset==0x12) return 0; |
| 184 | 184 |
| r2724 | r2725 | |
|---|---|---|
| 5 | 5 | ****************************************************************************/ |
| 6 | 6 | |
| 7 | 7 | #include "driver.h" |
| 8 | #include "deprecat.h" | |
| 9 | 8 | #include "cpu/tms32010/tms32010.h" |
| 10 | 9 | #include "sound/dac.h" |
| 11 | 10 | #include "machine/atarigen.h" |
| r2724 | r2725 | |
| 121 | 120 | cpunum_set_input_line(machine, hdcpu_sound, INPUT_LINE_RESET, ASSERT_LINE); |
| 122 | 121 | cpunum_set_input_line(machine, hdcpu_sound, INPUT_LINE_RESET, CLEAR_LINE); |
| 123 | 122 | mainflag = soundflag = 0; |
| 124 | update_68k_interrupts( | |
| 123 | update_68k_interrupts(machine); | |
| 125 | 124 | logerror("%06X:Reset sound\n", activecpu_get_previouspc()); |
| 126 | 125 | } |
| 127 | 126 | |
| r2724 | r2725 | |
| 136 | 135 | READ16_HANDLER( hdsnd68k_data_r ) |
| 137 | 136 | { |
| 138 | 137 | mainflag = 0; |
| 139 | update_68k_interrupts( | |
| 138 | update_68k_interrupts(machine); | |
| 140 | 139 | logerror("%06X:sound read from main=%04X\n", activecpu_get_previouspc(), maindata); |
| 141 | 140 | return maindata; |
| 142 | 141 | } |
| r2724 | r2725 | |
| 240 | 239 | WRITE16_HANDLER( hdsnd68k_irqclr_w ) |
| 241 | 240 | { |
| 242 | 241 | irq68k = 0; |
| 243 | update_68k_interrupts( | |
| 242 | update_68k_interrupts(machine); | |
| 244 | 243 | } |
| 245 | 244 | |
| 246 | 245 | |
| r2724 | r2725 | |
| 358 | 357 | { |
| 359 | 358 | /* generate 68k IRQ */ |
| 360 | 359 | irq68k = 1; |
| 361 | update_68k_interrupts( | |
| 360 | update_68k_interrupts(machine); | |
| 362 | 361 | } |
| 363 | 362 | |
| 364 | 363 |
| r2724 | r2725 | |
|---|---|---|
| 113 | 113 | state_save_register_global(sample_addr); |
| 114 | 114 | } |
| 115 | 115 | |
| 116 | void m72_ym2151_irq_handler(int irq) | |
| 116 | void m72_ym2151_irq_handler(running_machine *machine, int irq) | |
| 117 | 117 | { |
| 118 | 118 | if (irq) |
| 119 | 119 | timer_call_after_resynch(NULL, YM2151_ASSERT,setvector_callback); |
| r2724 | r2725 | |
|---|---|---|
| 34 | 34 | |
| 35 | 35 | #include "driver.h" |
| 36 | 36 | #include "streams.h" |
| 37 | #include "deprecat.h" | |
| 38 | 37 | #include "audio/seibu.h" |
| 39 | 38 | #include "sound/3812intf.h" |
| 40 | 39 | #include "sound/2151intf.h" |
| r2724 | r2725 | |
| 336 | 335 | update_irq_lines(machine, RST18_CLEAR); |
| 337 | 336 | } |
| 338 | 337 | |
| 339 | void seibu_ym3812_irqhandler(int linestate) | |
| 338 | void seibu_ym3812_irqhandler(running_machine *machine, int linestate) | |
| 340 | 339 | { |
| 341 | update_irq_lines( | |
| 340 | update_irq_lines(machine, linestate ? RST10_ASSERT : RST10_CLEAR); | |
| 342 | 341 | } |
| 343 | 342 | |
| 344 | void seibu_ym2151_irqhandler(int linestate) | |
| 343 | void seibu_ym2151_irqhandler(running_machine *machine, int linestate) | |
| 345 | 344 | { |
| 346 | update_irq_lines( | |
| 345 | update_irq_lines(machine, linestate ? RST10_ASSERT : RST10_CLEAR); | |
| 347 | 346 | } |
| 348 | 347 | |
| 349 | void seibu_ym2203_irqhandler(int linestate) | |
| 348 | void seibu_ym2203_irqhandler(running_machine *machine, int linestate) | |
| 350 | 349 | { |
| 351 | update_irq_lines( | |
| 350 | update_irq_lines(machine, linestate ? RST10_ASSERT : RST10_CLEAR); | |
| 352 | 351 | } |
| 353 | 352 | |
| 354 | 353 | /***************************************************************************/ |
| r2724 | r2725 | |
|---|---|---|
| 5 | 5 | ****************************************************************************/ |
| 6 | 6 | |
| 7 | 7 | MACHINE_RESET( m72_sound ); |
| 8 | void m72_ym2151_irq_handler(int irq); | |
| 8 | void m72_ym2151_irq_handler(running_machine *machine, int irq); | |
| 9 | 9 | WRITE8_HANDLER( m72_sound_command_byte_w ); |
| 10 | 10 | WRITE16_HANDLER( m72_sound_command_w ); |
| 11 | 11 | WRITE8_HANDLER( m72_sound_irq_ack_w ); |
| r2724 | r2725 | |
|---|---|---|
| 47 | 47 | WRITE8_HANDLER( seibu_rst18_ack_w ); |
| 48 | 48 | WRITE8_HANDLER( seibu_bank_w ); |
| 49 | 49 | WRITE8_HANDLER( seibu_coin_w ); |
| 50 | void seibu_ym3812_irqhandler(int linestate); | |
| 51 | void seibu_ym2151_irqhandler(int linestate); | |
| 52 | void seibu_ym2203_irqhandler(int linestate); | |
| 50 | void seibu_ym3812_irqhandler(running_machine *machine, int linestate); | |
| 51 | void seibu_ym2151_irqhandler(running_machine *machine, int linestate); | |
| 52 | void seibu_ym2203_irqhandler(running_machine *machine, int linestate); | |
| 53 | 53 | READ8_HANDLER( seibu_soundlatch_r ); |
| 54 | 54 | READ8_HANDLER( seibu_main_data_pending_r ); |
| 55 | 55 | WRITE8_HANDLER( seibu_main_data_w ); |
| r2724 | r2725 | |
|---|---|---|
| 65 | 65 | |
| 66 | 66 | static void init_audio_state(running_machine *machine); |
| 67 | 67 | |
| 68 | static void cvsd_ym2151_irq(int state); | |
| 69 | static void adpcm_ym2151_irq(int state); | |
| 70 | static void cvsd_irqa(int state); | |
| 71 | static void cvsd_irqb(int state); | |
| 68 | static void cvsd_ym2151_irq(running_machine *machine, int state); | |
| 69 | static void adpcm_ym2151_irq(running_machine *machine, int state); | |
| 70 | static void cvsd_irqa(running_machine *machine, int state); | |
| 71 | static void cvsd_irqb(running_machine *machine, int state); | |
| 72 | 72 | |
| 73 | 73 | static WRITE8_HANDLER( cvsd_bank_select_w ); |
| 74 | 74 | static READ8_HANDLER( cvsd_pia_r ); |
| r2724 | r2725 | |
| 404 | 404 | CVSD IRQ GENERATION CALLBACKS |
| 405 | 405 | ****************************************************************************/ |
| 406 | 406 | |
| 407 | static void cvsd_ym2151_irq(int state) | |
| 407 | static void cvsd_ym2151_irq(running_machine *machine, int state) | |
| 408 | 408 | { |
| 409 | 409 | pia_set_input_ca1(williams_pianum, !state); |
| 410 | 410 | } |
| 411 | 411 | |
| 412 | 412 | |
| 413 | static void cvsd_irqa(int state) | |
| 413 | static void cvsd_irqa(running_machine *machine, int state) | |
| 414 | 414 | { |
| 415 | cpunum_set_input_line( | |
| 415 | cpunum_set_input_line(machine, sound_cpunum, M6809_FIRQ_LINE, state ? ASSERT_LINE : CLEAR_LINE); | |
| 416 | 416 | } |
| 417 | 417 | |
| 418 | 418 | |
| 419 | static void cvsd_irqb(int state) | |
| 419 | static void cvsd_irqb(running_machine *machine, int state) | |
| 420 | 420 | { |
| 421 | cpunum_set_input_line( | |
| 421 | cpunum_set_input_line(machine, sound_cpunum, INPUT_LINE_NMI, state ? ASSERT_LINE : CLEAR_LINE); | |
| 422 | 422 | } |
| 423 | 423 | |
| 424 | 424 | |
| r2724 | r2725 | |
| 427 | 427 | ADPCM IRQ GENERATION CALLBACKS |
| 428 | 428 | ****************************************************************************/ |
| 429 | 429 | |
| 430 | static void adpcm_ym2151_irq(int state) | |
| 430 | static void adpcm_ym2151_irq(running_machine *machine, int state) | |
| 431 | 431 | { |
| 432 | cpunum_set_input_line( | |
| 432 | cpunum_set_input_line(machine, sound_cpunum, M6809_FIRQ_LINE, state ? ASSERT_LINE : CLEAR_LINE); | |
| 433 | 433 | } |
| 434 | 434 | |
| 435 | 435 |
| r2724 | r2725 | |
|---|---|---|
| 935 | 935 | memset(&dcs, 0, sizeof(dcs)); |
| 936 | 936 | |
| 937 | 937 | /* find the DCS CPU and the sound ROMs */ |
| 938 | dcs.cpunum = mame_find_cpu_index( | |
| 938 | dcs.cpunum = mame_find_cpu_index(machine, "dcs2"); | |
| 939 | 939 | dcs.rev = 2; |
| 940 | 940 | if ((INT8)dcs.cpunum == -1) |
| 941 | 941 | { |
| 942 | dcs.cpunum = mame_find_cpu_index( | |
| 942 | dcs.cpunum = mame_find_cpu_index(machine, "dsio"); | |
| 943 | 943 | dcs.rev = 3; |
| 944 | 944 | } |
| 945 | 945 | if ((INT8)dcs.cpunum == -1) |
| 946 | 946 | { |
| 947 | dcs.cpunum = mame_find_cpu_index( | |
| 947 | dcs.cpunum = mame_find_cpu_index(machine, "denver"); | |
| 948 | 948 | dcs.rev = 4; |
| 949 | 949 | } |
| 950 | 950 | dcs.channels = 2; |
| r2724 | r2725 | |
| 989 | 989 | dcs_register_state(); |
| 990 | 990 | |
| 991 | 991 | /* reset the system */ |
| 992 | dcs_reset( | |
| 992 | dcs_reset(machine, NULL, 0); | |
| 993 | 993 | } |
| 994 | 994 | |
| 995 | 995 |
| r2724 | r2725 | |
|---|---|---|
| 103 | 103 | |
| 104 | 104 | CUSTOM_INPUT( jedi_audio_comm_stat_r ) |
| 105 | 105 | { |
| 106 | jedi_state *state = machine->driver_data; | |
| 106 | jedi_state *state = field->port->machine->driver_data; | |
| 107 | 107 | return *state->audio_comm_stat >> 6; |
| 108 | 108 | } |
| 109 | 109 |
| r2724 | r2725 | |
|---|---|---|
| 130 | 130 | * |
| 131 | 131 | *************************************/ |
| 132 | 132 | |
| 133 | static void update_irq_state(/* unused */ int state) | |
| 133 | static void update_irq_state(running_machine *machine, /* unused */ int state) | |
| 134 | 134 | { |
| 135 | cpunum_set_input_line( | |
| 135 | cpunum_set_input_line(machine, 1, M6502_IRQ_LINE, (pia_get_irq_b(1) | riot_irq_state) ? ASSERT_LINE : CLEAR_LINE); | |
| 136 | 136 | } |
| 137 | 137 | |
| 138 | 138 | |
| r2724 | r2725 | |
| 415 | 415 | /* generate the IRQ */ |
| 416 | 416 | riot_irq_flag |= 0x80; |
| 417 | 417 | riot_irq_state = riot_timer_irq_enable; |
| 418 | update_irq_state(0); | |
| 418 | update_irq_state(machine, 0); | |
| 419 | 419 | |
| 420 | 420 | /* now start counting clock cycles down */ |
| 421 | 421 | riot_state = RIOT_POST_COUNT; |
| r2724 | r2725 | |
| 493 | 493 | if (riot_state != RIOT_COUNT) |
| 494 | 494 | riot_irq_flag &= ~0x80; |
| 495 | 495 | riot_irq_state = 0; |
| 496 | update_irq_state(0); | |
| 496 | update_irq_state(machine, 0); | |
| 497 | 497 | |
| 498 | 498 | /* set the enable from the offset */ |
| 499 | 499 | riot_timer_irq_enable = (offset & 0x08) ? 1 : 0; |
| r2724 | r2725 | |
| 546 | 546 | int temp = riot_irq_flag; |
| 547 | 547 | riot_irq_flag = 0; |
| 548 | 548 | riot_irq_state = 0; |
| 549 | update_irq_state(0); | |
| 549 | update_irq_state(machine, 0); | |
| 550 | 550 | return temp; |
| 551 | 551 | } |
| 552 | 552 |
| r2724 | r2725 | |
|---|---|---|
| 1 | 1 | #include "driver.h" |
| 2 | #include "deprecat.h" | |
| 3 | 2 | #include "nmk004.h" |
| 4 | 3 | #include "sound/2203intf.h" |
| 5 | 4 | #include "sound/okim6295.h" |
| r2724 | r2725 | |
| 997 | 996 | |
| 998 | 997 | |
| 999 | 998 | |
| 1000 | void NMK004_irq(int irq) | |
| 999 | void NMK004_irq(running_machine *machine, int irq) | |
| 1001 | 1000 | { |
| 1002 | 1001 | int status; |
| 1003 | 1002 | |
| 1004 | 1003 | if (!irq) return; |
| 1005 | 1004 | |
| 1006 | status = YM2203_status_port_0_r( | |
| 1005 | status = YM2203_status_port_0_r(machine,0); | |
| 1007 | 1006 | |
| 1008 | 1007 | if (status & 1) // timer A expired |
| 1009 | 1008 | { |
| 1010 | oki_update_state(Machine); | |
| 1011 | get_command(Machine); | |
| 1012 | update_music(Machine); | |
| 1009 | oki_update_state(machine); | |
| 1010 | get_command(machine); | |
| 1011 | update_music(machine); | |
| 1013 | 1012 | |
| 1014 | 1013 | // restart timer |
| 1015 | YM2203_control_port_0_w(Machine, 0, 0x27); | |
| 1016 | YM2203_write_port_0_w(Machine, 0, 0x15); | |
| 1014 | YM2203_control_port_0_w(machine, 0, 0x27); | |
| 1015 | YM2203_write_port_0_w(machine, 0, 0x15); | |
| 1017 | 1016 | } |
| 1018 | 1017 | } |
| 1019 | 1018 |
| r2724 | r2725 | |
|---|---|---|
| 1 | 1 | void NMK004_init(void); |
| 2 | void NMK004_irq(int irq); | |
| 2 | void NMK004_irq(running_machine *machine, int irq); | |
| 3 | 3 | READ16_HANDLER( NMK004_r ); |
| 4 | 4 | WRITE16_HANDLER( NMK004_w ); |
| r2724 | r2725 | |
|---|---|---|
| 40 | 40 | |
| 41 | 41 | static void pokey_reset(running_machine *machine); |
| 42 | 42 | |
| 43 | void atari_interrupt_cb(int mask) | |
| 43 | void atari_interrupt_cb(running_machine *machine, int mask) | |
| 44 | 44 | { |
| 45 | 45 | |
| 46 | 46 | if (VERBOSE_POKEY) |
| r2724 | r2725 | |
| 69 | 69 | logerror("atari interrupt_cb TIMR1\n"); |
| 70 | 70 | } |
| 71 | 71 | |
| 72 | cpunum_set_input_line( | |
| 72 | cpunum_set_input_line(machine, 0, 0, HOLD_LINE); | |
| 73 | 73 | } |
| 74 | 74 | |
| 75 | 75 | /************************************************************** |
| r2724 | r2725 | |
| 135 | 135 | /* check if self-test ROM changed */ |
| 136 | 136 | if ( new_mmu & 0x80 ) |
| 137 | 137 | { |
| 138 | logerror("%s MMU SELFTEST RAM\n", | |
| 138 | logerror("%s MMU SELFTEST RAM\n", machine->gamedrv->name); | |
| 139 | 139 | rbank2 = SMH_NOP; |
| 140 | 140 | wbank2 = SMH_NOP; |
| 141 | 141 | } |
| 142 | 142 | else |
| 143 | 143 | { |
| 144 | logerror("%s MMU SELFTEST ROM\n", | |
| 144 | logerror("%s MMU SELFTEST ROM\n", machine->gamedrv->name); | |
| 145 | 145 | rbank2 = SMH_BANK2; |
| 146 | 146 | wbank2 = SMH_UNMAP; |
| 147 | 147 | } |
| r2724 | r2725 | |
| 159 | 159 | /* check if memory C000-FFFF changed */ |
| 160 | 160 | if( new_mmu & 0x01 ) |
| 161 | 161 | { |
| 162 | logerror("%s MMU BIOS ROM\n", | |
| 162 | logerror("%s MMU BIOS ROM\n", machine->gamedrv->name); | |
| 163 | 163 | rbank3 = SMH_BANK3; |
| 164 | 164 | wbank3 = SMH_UNMAP; |
| 165 | 165 | base3 = memory_region(REGION_CPU1)+0x14000; /* 8K lo BIOS */ |
| r2724 | r2725 | |
| 169 | 169 | } |
| 170 | 170 | else |
| 171 | 171 | { |
| 172 | logerror("%s MMU BIOS RAM\n", | |
| 172 | logerror("%s MMU BIOS RAM\n", machine->gamedrv->name); | |
| 173 | 173 | rbank3 = SMH_BANK3; |
| 174 | 174 | wbank3 = SMH_BANK3; |
| 175 | 175 | base3 = memory_region(REGION_CPU1)+0x0c000; /* 8K RAM */ |
| r2724 | r2725 | |
| 185 | 185 | /* check if BASIC changed */ |
| 186 | 186 | if( new_mmu & 0x02 ) |
| 187 | 187 | { |
| 188 | logerror("%s MMU BASIC RAM\n", | |
| 188 | logerror("%s MMU BASIC RAM\n", machine->gamedrv->name); | |
| 189 | 189 | rbank1 = SMH_BANK1; |
| 190 | 190 | wbank1 = SMH_BANK1; |
| 191 | 191 | base1 = memory_region(REGION_CPU1)+0x0a000; /* 8K RAM */ |
| 192 | 192 | } |
| 193 | 193 | else |
| 194 | 194 | { |
| 195 | logerror("%s MMU BASIC ROM\n", | |
| 195 | logerror("%s MMU BASIC ROM\n", machine->gamedrv->name); | |
| 196 | 196 | rbank1 = SMH_BANK1; |
| 197 | 197 | wbank1 = SMH_UNMAP; |
| 198 | 198 | base1 = memory_region(REGION_CPU1)+0x10000; /* 8K BASIC */ |
| r2724 | r2725 | |
| 203 | 203 | /* check if self-test ROM changed */ |
| 204 | 204 | if( new_mmu & 0x80 ) |
| 205 | 205 | { |
| 206 | logerror("%s MMU SELFTEST RAM\n", | |
| 206 | logerror("%s MMU SELFTEST RAM\n", machine->gamedrv->name); | |
| 207 | 207 | rbank2 = SMH_BANK2; |
| 208 | 208 | wbank2 = SMH_BANK2; |
| 209 | 209 | base2 = memory_region(REGION_CPU1)+0x05000; /* 0x0800 bytes */ |
| 210 | 210 | } |
| 211 | 211 | else |
| 212 | 212 | { |
| 213 | logerror("%s MMU SELFTEST ROM\n", | |
| 213 | logerror("%s MMU SELFTEST ROM\n", machine->gamedrv->name); | |
| 214 | 214 | rbank2 = SMH_BANK2; |
| 215 | 215 | wbank2 = SMH_UNMAP; |
| 216 | 216 | base2 = memory_region(REGION_CPU1)+0x15000; /* 0x0800 bytes */ |
| r2724 | r2725 | |
| 742 | 742 | |
| 743 | 743 | /* GTIA */ |
| 744 | 744 | memset(>ia_intf, 0, sizeof(gtia_intf)); |
| 745 | if (port_tag | |
| 745 | if (input_port_by_tag(machin | |
| 746 | 746 | gtia_intf.console_read = console_read; |
| 747 | 747 | if (sndti_exists(SOUND_DAC, 0)) |
| 748 | 748 | gtia_intf.console_write = console_write; |
| 749 | 749 | gtia_init(machine, >ia_intf); |
| 750 | 750 | |
| 751 | 751 | /* pokey */ |
| 752 | add_reset_callback( | |
| 752 | add_reset_callback(machine, pokey_reset); | |
| 753 | 753 | |
| 754 | 754 | /* PIA */ |
| 755 | 755 | if (pia_intf) |
| 756 | 756 | { |
| 757 | 757 | pia_config(0, pia_intf); |
| 758 | add_reset_callback( | |
| 758 | add_reset_callback(machine, _pia_reset); | |
| 759 | 759 | } |
| 760 | 760 | |
| 761 | 761 | /* ANTIC */ |
| 762 | add_reset_callback( | |
| 762 | add_reset_callback(machine, _antic_reset); | |
| 763 | 763 | |
| 764 | 764 | /* cartridge */ |
| 765 | 765 | if (has_cart) |
| 766 | add_reset_callback( | |
| 766 | add_reset_callback(machine, cart_reset); | |
| 767 | 767 | |
| 768 | 768 | #ifdef MESS |
| 769 | 769 | { |
| 770 | 770 | offs_t ram_top; |
| 771 | 771 | offs_t ram_size; |
| 772 | 772 | |
| 773 | if (!strcmp(Machine->gamedrv->name, "a400") | |
| 774 | || !strcmp(Machine->gamedrv->name, "a400pal") | |
| 775 | || !strcmp(Machine->gamedrv->name, "a800") | |
| 776 | || !strcmp(Machine->gamedrv->name, "a800pal") | |
| 777 | || !strcmp(Machine->gamedrv->name, "a800xl")) | |
| 773 | if (!strcmp(machine->gamedrv->name, "a400") | |
| 774 | || !strcmp(machine->gamedrv->name, "a400pal") | |
| 775 | || !strcmp(machine->gamedrv->name, "a800") | |
| 776 | || !strcmp(machine->gamedrv->name, "a800pal") | |
| 777 | || !strcmp(machine->gamedrv->name, "a800xl")) | |
| 778 | 778 | { |
| 779 | 779 | ram_size = 0xA000; |
| 780 | 780 | } |
| r2724 | r2725 | |
|---|---|---|
| 4 | 4 | ****************************************************************************/ |
| 5 | 5 | |
| 6 | 6 | #include "driver.h" |
| 7 | #include "deprecat.h" | |
| 8 | 7 | #include "cpu/m68000/m68000.h" |
| 9 | 8 | #include "cpu/tms32010/tms32010.h" |
| 10 | 9 | #include "twincobr.h" |
| r2724 | r2725 | |
| 191 | 190 | } |
| 192 | 191 | |
| 193 | 192 | |
| 194 | static void twincobr_dsp(int enable) | |
| 193 | static void twincobr_dsp(running_machine *machine, int enable) | |
| 195 | 194 | { |
| 196 | 195 | twincobr_dsp_on = enable; |
| 197 | 196 | if (enable) { |
| 198 | 197 | LOG(("Turning DSP on and main CPU off\n")); |
| 199 | cpunum_set_input_line(Machine, 2, INPUT_LINE_HALT, CLEAR_LINE); | |
| 200 | cpunum_set_input_line(Machine, 2, 0, ASSERT_LINE); /* TMS32010 INT */ | |
| 201 | cpunum_set_input_line(Machine, 0, INPUT_LINE_HALT, ASSERT_LINE); | |
| 198 | cpunum_set_input_line(machine, 2, INPUT_LINE_HALT, CLEAR_LINE); | |
| 199 | cpunum_set_input_line(machine, 2, 0, ASSERT_LINE); /* TMS32010 INT */ | |
| 200 | cpunum_set_input_line(machine, 0, INPUT_LINE_HALT, ASSERT_LINE); | |
| 202 | 201 | } |
| 203 | 202 | else { |
| 204 | 203 | LOG(("Turning DSP off\n")); |
| 205 | cpunum_set_input_line(Machine, 2, 0, CLEAR_LINE); /* TMS32010 INT */ | |
| 206 | cpunum_set_input_line(Machine, 2, INPUT_LINE_HALT, ASSERT_LINE); | |
| 204 | cpunum_set_input_line(machine, 2, 0, CLEAR_LINE); /* TMS32010 INT */ | |
| 205 | cpunum_set_input_line(machine, 2, INPUT_LINE_HALT, ASSERT_LINE); | |
| 207 | 206 | } |
| 208 | 207 | } |
| 209 | 208 | |
| 210 | 209 | static STATE_POSTLOAD( twincobr_restore_dsp ) |
| 211 | 210 | { |
| 212 | twincobr_dsp(twincobr_dsp_on); | |
| 211 | twincobr_dsp(machine, twincobr_dsp_on); | |
| 213 | 212 | } |
| 214 | 213 | |
| 215 | 214 | |
| 216 | static void toaplan0_control_w(int offset, int data) | |
| 215 | static void toaplan0_control_w(running_machine *machine, int offset, int data) | |
| 217 | 216 | { |
| 218 | 217 | LOG(("CPU0:%08x Writing %08x to %08x.\n",activecpu_get_pc(),data,toaplan_port_type[toaplan_main_cpu] - offset)); |
| 219 | 218 | |
| r2724 | r2725 | |
| 231 | 230 | case 0x0009: twincobr_bg_ram_bank = 0x1000; break; |
| 232 | 231 | case 0x000a: twincobr_fg_rom_bank = 0x0000; break; |
| 233 | 232 | case 0x000b: twincobr_fg_rom_bank = 0x1000; break; |
| 234 | case 0x000c: twincobr_dsp(1); break; /* Enable the INT line to the DSP */ | |
| 235 | case 0x000d: twincobr_dsp(0); break; /* Inhibit the INT line to the DSP */ | |
| 233 | case 0x000c: twincobr_dsp(machine, 1); break; /* Enable the INT line to the DSP */ | |
| 234 | case 0x000d: twincobr_dsp(machine, 0); break; /* Inhibit the INT line to the DSP */ | |
| 236 | 235 | case 0x000e: twincobr_display(0); break; /* Turn display off */ |
| 237 | 236 | case 0x000f: twincobr_display(1); break; /* Turn display on */ |
| 238 | 237 | } |
| r2724 | r2725 | |
| 242 | 241 | { |
| 243 | 242 | if (ACCESSING_BITS_0_7) |
| 244 | 243 | { |
| 245 | toaplan0_control_w(offset, data & 0xff); | |
| 244 | toaplan0_control_w(machine, offset, data & 0xff); | |
| 246 | 245 | } |
| 247 | 246 | } |
| 248 | 247 | |
| 249 | 248 | WRITE8_HANDLER( wardner_control_w ) |
| 250 | 249 | { |
| 251 | toaplan0_control_w(offset, data); | |
| 250 | toaplan0_control_w(machine, offset, data); | |
| 252 | 251 | } |
| 253 | 252 | |
| 254 | 253 | |
| r2724 | r2725 | |
| 266 | 265 | } |
| 267 | 266 | |
| 268 | 267 | |
| 269 | static void toaplan0_coin_dsp_w(int offset, int data) | |
| 268 | static void toaplan0_coin_dsp_w(running_machine *machine, int offset, int data) | |
| 270 | 269 | { |
| 271 | 270 | if (data > 1) |
| 272 | 271 | LOG(("CPU0:%08x Writing %08x to %08x.\n",activecpu_get_pc(),data,toaplan_port_type[toaplan_main_cpu] - offset)); |
| r2724 | r2725 | |
| 282 | 281 | /****** The following apply to Flying Shark/Wardner only ******/ |
| 283 | 282 | case 0x00: /* This means assert the INT line to the DSP */ |
| 284 | 283 | LOG(("Turning DSP on and main CPU off\n")); |
| 285 | cpunum_set_input_line(Machine, 2, INPUT_LINE_HALT, CLEAR_LINE); | |
| 286 | cpunum_set_input_line(Machine, 2, 0, ASSERT_LINE); /* TMS32010 INT */ | |
| 287 | cpunum_set_input_line(Machine, 0, INPUT_LINE_HALT, ASSERT_LINE); | |
| 284 | cpunum_set_input_line(machine, 2, INPUT_LINE_HALT, CLEAR_LINE); | |
| 285 | cpunum_set_input_line(machine, 2, 0, ASSERT_LINE); /* TMS32010 INT */ | |
| 286 | cpunum_set_input_line(machine, 0, INPUT_LINE_HALT, ASSERT_LINE); | |
| 288 | 287 | break; |
| 289 | 288 | case 0x01: /* This means inhibit the INT line to the DSP */ |
| 290 | 289 | LOG(("Turning DSP off\n")); |
| 291 | cpunum_set_input_line(Machine, 2, 0, CLEAR_LINE); /* TMS32010 INT */ | |
| 292 | cpunum_set_input_line(Machine, 2, INPUT_LINE_HALT, ASSERT_LINE); | |
| 290 | cpunum_set_input_line(machine, 2, 0, CLEAR_LINE); /* TMS32010 INT */ | |
| 291 | cpunum_set_input_line(machine, 2, INPUT_LINE_HALT, ASSERT_LINE); | |
| 293 | 292 | break; |
| 294 | 293 | } |
| 295 | 294 | } |
| r2724 | r2725 | |
| 299 | 298 | { |
| 300 | 299 | if (ACCESSING_BITS_0_7) |
| 301 | 300 | { |
| 302 | toaplan0_coin_dsp_w(offset, data & 0xff); | |
| 301 | toaplan0_coin_dsp_w(machine, offset, data & 0xff); | |
| 303 | 302 | } |
| 304 | 303 | } |
| 305 | 304 | |
| 306 | 305 | WRITE8_HANDLER( twincobr_coin_w ) |
| 307 | 306 | { |
| 308 | toaplan0_coin_dsp_w(offset, data); | |
| 307 | toaplan0_coin_dsp_w(machine, offset, data); | |
| 309 | 308 | } |
| 310 | 309 | |
| 311 | 310 | WRITE8_HANDLER( wardner_coin_dsp_w ) |
| 312 | 311 | { |
| 313 | toaplan0_coin_dsp_w(offset, data); | |
| 312 | toaplan0_coin_dsp_w(machine, offset, data); | |
| 314 | 313 | } |
| 315 | 314 | |
| 316 | 315 |
| r2724 | r2725 | |
|---|---|---|
| 74 | 74 | UINT8 shuffle_type; |
| 75 | 75 | UINT8 shuffle_active; |
| 76 | 76 | const UINT8 * shuffle_map; |
| 77 | void (*irq_callback)(int); | |
| 77 | void (*irq_callback)(running_machine *, int); | |
| 78 | 78 | UINT8 irq_state; |
| 79 | 79 | UINT16 sound_irq_state; |
| 80 | 80 | UINT8 auto_ack; |
| r2724 | r2725 | |
| 570 | 570 | static void ioasic_input_empty(int state); |
| 571 | 571 | static void ioasic_output_full(int state); |
| 572 | 572 | static void update_ioasic_irq(void); |
| 573 | static void cage_irq_handler(int state); | |
| 573 | static void cage_irq_handler(running_machine *machine, int state); | |
| 574 | 574 | |
| 575 | 575 | |
| 576 | 576 | static void ioasic_register_state(void) |
| r2724 | r2725 | |
| 589 | 589 | } |
| 590 | 590 | |
| 591 | 591 | |
| 592 | void midway_ioasic_init(int shuffle, int upper, int yearoffs, void (*irq_callback)(int)) | |
| 592 | void midway_ioasic_init(int shuffle, int upper, int yearoffs, void (*irq_callback)(running_machine *, int)) | |
| 593 | 593 | { |
| 594 | 594 | static const UINT8 shuffle_maps[][16] = |
| 595 | 595 | { |
| r2724 | r2725 | |
| 685 | 685 | { |
| 686 | 686 | ioasic.irq_state = new_state; |
| 687 | 687 | if (ioasic.irq_callback) |
| 688 | (*ioasic.irq_callback)(ioasic.irq_state ? ASSERT_LINE : CLEAR_LINE); | |
| 688 | (*ioasic.irq_callback)(Machine, ioasic.irq_state ? ASSERT_LINE : CLEAR_LINE); | |
| 689 | 689 | } |
| 690 | 690 | } |
| 691 | 691 | |
| 692 | 692 | |
| 693 | static void cage_irq_handler(int reason) | |
| 693 | static void cage_irq_handler(running_machine *machine, int reason) | |
| 694 | 694 | { |
| 695 | 695 | logerror("CAGE irq handler: %d\n", reason); |
| 696 | 696 | ioasic.sound_irq_state = 0; |
| r2724 | r2725 | |
|---|---|---|
| 23 | 23 | |
| 24 | 24 | |
| 25 | 25 | /* I/O ASIC connected to 2nd generation PIC */ |
| 26 | void midway_ioasic_init(int shuffle, int upper, int yearoffs, void (*irq_callback)(int)); | |
| 26 | void midway_ioasic_init(int shuffle, int upper, int yearoffs, void (*irq_callback)(running_machine *, int)); | |
| 27 | 27 | void midway_ioasic_set_auto_ack(int auto_ack); |
| 28 | 28 | void midway_ioasic_set_shuffle_state(int state); |
| 29 | 29 | void midway_ioasic_reset(void); |
| r2724 | r2725 | |
|---|---|---|
| 1680 | 1680 | } |
| 1681 | 1681 | color &= K055555_COLORMASK; |
| 1682 | 1682 | |
| 1683 | if (drawmode >= 4) palette_set_shadow_mode( | |
| 1683 | if (drawmode >= 4) palette_set_shadow_mode(machine, order & 0x0f); | |
| 1684 | 1684 | |
| 1685 | 1685 | if (!(mixerflags & GXMIX_NOZBUF)) |
| 1686 | 1686 | { |
| r2724 | r2725 | |
| 1951 | 1951 | else |
| 1952 | 1952 | if (dy < 0) i = 0x80; |
| 1953 | 1953 | else |
| 1954 | i = mame_rand( | |
| 1954 | i = mame_rand(machine) & 0xff; // vector direction indeterminate | |
| 1955 | 1955 | |
| 1956 | 1956 | prot_data[0x10] = i; |
| 1957 | 1957 | break; |
| r2724 | r2725 | |
|---|---|---|
| 98 | 98 | |
| 99 | 99 | ***************************************************************************/ |
| 100 | 100 | #include "driver.h" |
| 101 | #include "deprecat.h" | |
| 102 | 101 | #include "cpu/z80/z80.h" |
| 103 | 102 | |
| 104 | 103 | #define ID_DAIKAIJU 0x5a |
| r2724 | r2725 | |
| 341 | 340 | { |
| 342 | 341 | int res = input_port_read_indexed(machine, 3); |
| 343 | 342 | |
| 344 | res^=mame_rand( | |
| 343 | res^=mame_rand(machine)&3; | |
| 345 | 344 | res |=((lsasquad_sound_pending & 0x02)^2)<<3; //inverted flag |
| 346 | 345 | lsasquad_sound_pending &= ~0x02; |
| 347 | 346 | return res; |
| r2724 | r2725 | |
|---|---|---|
| 1 | 1 | #include "driver.h" |
| 2 | #include "deprecat.h" | |
| 3 | 2 | #include "sound/ym2151.h" |
| 4 | 3 | #include "sound/namco.h" |
| 5 | 4 | |
| r2724 | r2725 | |
| 531 | 530 | op = (offset & 0x70) >> 4; |
| 532 | 531 | |
| 533 | 532 | if (op == key_reg) return key_id; |
| 534 | if (op == key_rng) return mame_rand( | |
| 533 | if (op == key_rng) return mame_rand(machine); | |
| 535 | 534 | if (op == key_swap4) return (key[key_swap4_arg] << 4) | (key[key_swap4_arg] >> 4); |
| 536 | 535 | if (op == key_bottom4) return (offset << 4) | (key[key_swap4_arg] & 0x0f); |
| 537 | 536 | if (op == key_top4) return (offset << 4) | (key[key_swap4_arg] >> 4); |
| r2724 | r2725 | |
|---|---|---|
| 61 | 61 | UINT16 counter; |
| 62 | 62 | UINT8 bit; |
| 63 | 63 | void (*sound_w)(UINT8); |
| 64 | void (*timer_ack)( | |
| 64 | void (*timer_ack)(running_machine *); | |
| 65 | 65 | }; |
| 66 | 66 | |
| 67 | 67 | |
| r2724 | r2725 | |
| 218 | 218 | /* 03 - maybe controls halt and reset lines together? */ |
| 219 | 219 | if ((oldval ^ chip->regs[offset]) & 3) |
| 220 | 220 | { |
| 221 | cpunum_set_input_line( | |
| 221 | cpunum_set_input_line(machine, chip->cpunum, INPUT_LINE_RESET, (chip->regs[offset] & 3) == 3 ? ASSERT_LINE : CLEAR_LINE); | |
| 222 | 222 | if ((chip->regs[offset] & 3) == 3) |
| 223 | 223 | fd1094_machine_init(); |
| 224 | 224 | } |
| r2724 | r2725 | |
| 232 | 232 | case 0x04: |
| 233 | 233 | /* controls IRQ lines to 68000, negative logic -- write $B to signal IRQ4 */ |
| 234 | 234 | if ((chip->regs[offset] & 7) != 7) |
| 235 | cpunum_set_input_line( | |
| 235 | cpunum_set_input_line(machine, chip->cpunum, (~chip->regs[offset] & 7), HOLD_LINE); | |
| 236 | 236 | break; |
| 237 | 237 | |
| 238 | 238 | case 0x05: |
| r2724 | r2725 | |
| 585 | 585 | * |
| 586 | 586 | *************************************/ |
| 587 | 587 | |
| 588 | void segaic16_compare_timer_init(int which, void (*sound_write_callback)(UINT8), void (*timer_ack_callback)( | |
| 588 | void segaic16_compare_timer_init(int which, void (*sound_write_callback)(UINT8), void (*timer_ack_callback)(running_machine *)) | |
| 589 | 589 | { |
| 590 | 590 | compare_timer[which].sound_w = sound_write_callback; |
| 591 | 591 | compare_timer[which].timer_ack = timer_ack_callback; |
| r2724 | r2725 | |
| 644 | 644 | static void timer_interrupt_ack(int which) |
| 645 | 645 | { |
| 646 | 646 | if (compare_timer[which].timer_ack) |
| 647 | (*compare_timer[which].timer_ack)(); | |
| 647 | (*compare_timer[which].timer_ack)(Machine); | |
| 648 | 648 | } |
| 649 | 649 | |
| 650 | 650 |
| r2724 | r2725 | |
|---|---|---|
| 188 | 188 | int scan_code_set; |
| 189 | 189 | int last_code; |
| 190 | 190 | |
| 191 | int ports[8]; | |
| 191 | const input_port_config *ports[8]; | |
| 192 | 192 | } at_keyboard; |
| 193 | 193 | |
| 194 | 194 | static at_keyboard keyboard; |
| r2724 | r2725 | |
| 343 | 343 | for (i = 0; i < sizeof(keyboard.ports) / sizeof(keyboard.ports[0]); i++) |
| 344 | 344 | { |
| 345 | 345 | sprintf(buf, "pc_keyboard_%d", i); |
| 346 | keyboard.ports[i] = port_tag | |
| 346 | keyboard.ports[i] = input_port_by_tag(Machin | |
| 347 | 347 | } |
| 348 | 348 | |
| 349 | 349 | #ifdef MESS |
| r2724 | r2725 | |
| 508 | 508 | static UINT32 at_keyboard_readport(int port) |
| 509 | 509 | { |
| 510 | 510 | UINT32 result = 0; |
| 511 | if (keyboard.ports[port] >= 0) | |
| 512 | result = input_port_read_indexed(Machine, keyboard.ports[port]); | |
| 511 | if (keyboard.ports[port] != NULL) | |
| 512 | result = input_port_read_direct(keyboard.ports[port]); | |
| 513 | 513 | return result; |
| 514 | 514 | } |
| 515 | 515 |
| r2724 | r2725 | |
|---|---|---|
| 47 | 47 | WRITE16_HANDLER( segaic16_divide_2_w ); |
| 48 | 48 | |
| 49 | 49 | /* compare/timer chip */ |
| 50 | void segaic16_compare_timer_init(int which, void (*sound_write_callback)(UINT8), void (*timer_ack_callback)( | |
| 50 | void segaic16_compare_timer_init(int which, void (*sound_write_callback)(UINT8), void (*timer_ack_callback)(running_machine *)); | |
| 51 | 51 | int segaic16_compare_timer_clock(int which); |
| 52 | 52 | READ16_HANDLER( segaic16_compare_timer_0_r ); |
| 53 | 53 | READ16_HANDLER( segaic16_compare_timer_1_r ); |
| r2724 | r2725 | |
|---|---|---|
| 182 | 182 | static int adpcm_data_offs; |
| 183 | 183 | static int adpcm_data_end; |
| 184 | 184 | |
| 185 | void stfight_adpcm_int( int data ) | |
| 185 | void stfight_adpcm_int( running_machine *machine, int data ) | |
| 186 | 186 | { |
| 187 | 187 | static int toggle; |
| 188 | 188 | UINT8 *SAMPLES = memory_region(REGION_SOUND1); |
| r2724 | r2725 | |
|---|---|---|
| 7 | 7 | ***************************************************************************/ |
| 8 | 8 | |
| 9 | 9 | #include "driver.h" |
| 10 | #include "deprecat.h" | |
| 11 | 10 | #include "machine/6821pia.h" |
| 12 | 11 | #include "cpu/m6800/m6800.h" |
| 13 | 12 | #include "cpu/m6805/m6805.h" |
| r2724 | r2725 | |
| 34 | 33 | static WRITE8_HANDLER( qix_coinctl_w ); |
| 35 | 34 | static WRITE8_HANDLER( slither_coinctl_w ); |
| 36 | 35 | |
| 37 | static void qix_pia_sint(int state); | |
| 38 | static void qix_pia_dint(int state); | |
| 36 | static void qix_pia_sint(running_machine *machine, int state); | |
| 37 | static void qix_pia_dint(running_machine *machine, int state); | |
| 39 | 38 | |
| 40 | 39 | static WRITE8_HANDLER( slither_76489_0_w ); |
| 41 | 40 | static WRITE8_HANDLER( slither_76489_1_w ); |
| r2724 | r2725 | |
| 375 | 374 | * |
| 376 | 375 | *************************************/ |
| 377 | 376 | |
| 378 | static void qix_pia_dint(int state) | |
| 377 | static void qix_pia_dint(running_machine *machine, int state) | |
| 379 | 378 | { |
| 380 | 379 | int combined_state = pia_get_irq_a(3) | pia_get_irq_b(3); |
| 381 | 380 | |
| 382 | 381 | /* DINT is connected to the data CPU's IRQ line */ |
| 383 | cpunum_set_input_line( | |
| 382 | cpunum_set_input_line(machine, 0, M6809_IRQ_LINE, combined_state ? ASSERT_LINE : CLEAR_LINE); | |
| 384 | 383 | } |
| 385 | 384 | |
| 386 | 385 | |
| 387 | static void qix_pia_sint(int state) | |
| 386 | static void qix_pia_sint(running_machine *machine, int state) | |
| 388 | 387 | { |
| 389 | 388 | int combined_state = pia_get_irq_a(4) | pia_get_irq_b(4); |
| 390 | 389 | |
| 391 | 390 | /* SINT is connected to the sound CPU's IRQ line */ |
| 392 | cpunum_set_input_line( | |
| 391 | cpunum_set_input_line(machine, 2, M6802_IRQ_LINE, combined_state ? ASSERT_LINE : CLEAR_LINE); | |
| 393 | 392 | } |
| 394 | 393 | |
| 395 | 394 |
| r2724 | r2725 | |
|---|---|---|
| 175 | 175 | |
| 176 | 176 | static void custom_reset(void); |
| 177 | 177 | static void autoconfig_reset(void); |
| 178 | static void amiga_cia_0_irq(int state); | |
| 179 | static void amiga_cia_1_irq(int state); | |
| 178 | static void amiga_cia_0_irq(running_machine *machine, int state); | |
| 179 | static void amiga_cia_1_irq(running_machine *machine, int state); | |
| 180 | 180 | static TIMER_CALLBACK( amiga_irq_proc ); |
| 181 | 181 | static TIMER_CALLBACK( amiga_blitter_proc ); |
| 182 | 182 | static TIMER_CALLBACK( scanline_callback ); |
| r2724 | r2725 | |
| 462 | 462 | |
| 463 | 463 | CUSTOM_INPUT( amiga_joystick_convert ) |
| 464 | 464 | { |
| 465 | UINT8 bits = input_port_read(machine, param); | |
| 465 | UINT8 bits = input_port_read(field->port->machine, param); | |
| 466 | 466 | int up = (bits >> 0) & 1; |
| 467 | 467 | int down = (bits >> 1) & 1; |
| 468 | 468 | int left = (bits >> 2) & 1; |
| r2724 | r2725 | |
| 1133 | 1133 | * |
| 1134 | 1134 | *************************************/ |
| 1135 | 1135 | |
| 1136 | static void amiga_cia_0_irq(int state) | |
| 1136 | static void amiga_cia_0_irq(running_machine *machine, int state) | |
| 1137 | 1137 | { |
| 1138 | amiga_custom_w( | |
| 1138 | amiga_custom_w(machine, REG_INTREQ, (state ? 0x8000 : 0x0000) | INTENA_PORTS, 0xffff); | |
| 1139 | 1139 | } |
| 1140 | 1140 | |
| 1141 | 1141 | |
| 1142 | static void amiga_cia_1_irq(int state) | |
| 1142 | static void amiga_cia_1_irq(running_machine *machine, int state) | |
| 1143 | 1143 | { |
| 1144 | amiga_custom_w( | |
| 1144 | amiga_custom_w(machine, REG_INTREQ, (state ? 0x8000 : 0x0000) | INTENA_EXTER, 0xffff); | |
| 1145 | 1145 | } |
| 1146 | 1146 | |
| 1147 | 1147 |
| r2724 | r2725 | |
|---|---|---|
| 668 | 668 | IRQ line. |
| 669 | 669 | ---------------------------------------------------------------*/ |
| 670 | 670 | |
| 671 | void atarigen_ym2151_irq_gen(int irq) | |
| 671 | void atarigen_ym2151_irq_gen(running_machine *machine, int irq) | |
| 672 | 672 | { |
| 673 | 673 | ym2151_int = irq; |
| 674 | update_6502_irq( | |
| 674 | update_6502_irq(machine); | |
| 675 | 675 | } |
| 676 | 676 | |
| 677 | 677 |
| r2724 | r2725 | |
|---|---|---|
| 151 | 151 | READ8_HANDLER( atarigen_6502_irq_ack_r ); |
| 152 | 152 | WRITE8_HANDLER( atarigen_6502_irq_ack_w ); |
| 153 | 153 | |
| 154 | void atarigen_ym2151_irq_gen(int irq); | |
| 154 | void atarigen_ym2151_irq_gen(running_machine *machine, int irq); | |
| 155 | 155 | |
| 156 | 156 | WRITE16_HANDLER( atarigen_sound_w ); |
| 157 | 157 | READ16_HANDLER( atarigen_sound_r ); |
| r2724 | r2725 | |
|---|---|---|
| 355 | 355 | // case 3: return 0x142; |
| 356 | 356 | case 4: return 0x142; |
| 357 | 357 | // case 3: popmessage("blah %08x",activecpu_get_pc()); |
| 358 | default: return mame_rand( | |
| 358 | default: return mame_rand(machine); | |
| 359 | 359 | } |
| 360 | 360 | break; |
| 361 | 361 | |
| r2724 | r2725 | |
| 412 | 412 | |
| 413 | 413 | |
| 414 | 414 | |
| 415 | return mame_rand( | |
| 415 | return mame_rand(machine)&0xffff; | |
| 416 | 416 | } |
| 417 | 417 | |
| 418 | 418 | WRITE16_HANDLER( namcos2_68k_key_w ) |
| r2724 | r2725 | |
|---|---|---|
| 79 | 79 | * |
| 80 | 80 | *************************************/ |
| 81 | 81 | |
| 82 | static void subtract_from_counter(int counter, int count); | |
| 82 | static void subtract_from_counter(running_machine *machine, int counter, int count); | |
| 83 | 83 | |
| 84 | 84 | static TIMER_CALLBACK( mcr68_493_callback ); |
| 85 | 85 | static TIMER_CALLBACK( zwackery_493_callback ); |
| r2724 | r2725 | |
| 87 | 87 | static WRITE8_HANDLER( zwackery_pia_2_w ); |
| 88 | 88 | static WRITE8_HANDLER( zwackery_pia_3_w ); |
| 89 | 89 | static WRITE8_HANDLER( zwackery_ca2_w ); |
| 90 | static void zwackery_pia_irq(int state); | |
| 90 | static void zwackery_pia_irq(running_machine *machine, int state); | |
| 91 | 91 | |
| 92 | 92 | static void reload_count(int counter); |
| 93 | 93 | static TIMER_CALLBACK( counter_fired_callback ); |
| r2724 | r2725 | |
| 188 | 188 | * |
| 189 | 189 | *************************************/ |
| 190 | 190 | |
| 191 | static void ctc_interrupt(int state) | |
| 191 | static void ctc_interrupt(running_machine *machine, int state) | |
| 192 | 192 | { |
| 193 | cpunum_set_input_line( | |
| 193 | cpunum_set_input_line(machine, 0, 0, state); | |
| 194 | 194 | } |
| 195 | 195 | |
| 196 | 196 | |
| 197 | static void ipu_ctc_interrupt(int state) | |
| 197 | static void ipu_ctc_interrupt(running_machine *machine, int state) | |
| 198 | 198 | { |
| 199 | cpunum_set_input_line( | |
| 199 | cpunum_set_input_line(machine, 3, 0, state); | |
| 200 | 200 | } |
| 201 | 201 | |
| 202 | 202 | |
| r2724 | r2725 | |
| 453 | 453 | { |
| 454 | 454 | /* update the 6840 VBLANK clock */ |
| 455 | 455 | if (!m6840_state[0].timer_active) |
| 456 | subtract_from_counter(0, 1); | |
| 456 | subtract_from_counter(machine, 0, 1); | |
| 457 | 457 | |
| 458 | 458 | logerror("--- VBLANK ---\n"); |
| 459 | 459 | |
| r2724 | r2725 | |
| 471 | 471 | * |
| 472 | 472 | *************************************/ |
| 473 | 473 | |
| 474 | static void update_mcr68_interrupts( | |
| 474 | static void update_mcr68_interrupts(running_machine *machine) | |
| 475 | 475 | { |
| 476 | 476 | int newstate = 0; |
| 477 | 477 | |
| r2724 | r2725 | |
| 483 | 483 | |
| 484 | 484 | /* set the new state of the IRQ lines */ |
| 485 | 485 | if (newstate) |
| 486 | cpunum_set_input_line( | |
| 486 | cpunum_set_input_line(machine, 0, newstate, ASSERT_LINE); | |
| 487 | 487 | else |
| 488 | cpunum_set_input_line( | |
| 488 | cpunum_set_input_line(machine, 0, 7, CLEAR_LINE); | |
| 489 | 489 | } |
| 490 | 490 | |
| 491 | 491 | |
| 492 | 492 | static TIMER_CALLBACK( mcr68_493_off_callback ) |
| 493 | 493 | { |
| 494 | 494 | v493_irq_state = 0; |
| 495 | update_mcr68_interrupts(); | |
| 495 | update_mcr68_interrupts(machine); | |
| 496 | 496 | } |
| 497 | 497 | |
| 498 | 498 | |
| 499 | 499 | static TIMER_CALLBACK( mcr68_493_callback ) |
| 500 | 500 | { |
| 501 | 501 | v493_irq_state = 1; |
| 502 | update_mcr68_interrupts(); | |
| 502 | update_mcr68_interrupts(machine); | |
| 503 | 503 | timer_set(video_screen_get_scan_period(machine->primary_screen), NULL, 0, mcr68_493_off_callback); |
| 504 | 504 | logerror("--- (INT1) ---\n"); |
| 505 | 505 | } |
| r2724 | r2725 | |
| 605 | 605 | } |
| 606 | 606 | |
| 607 | 607 | |
| 608 | static void zwackery_pia_irq(int state) | |
| 608 | static void zwackery_pia_irq(running_machine *machine, int state) | |
| 609 | 609 | { |
| 610 | 610 | v493_irq_state = pia_get_irq_a(2) | pia_get_irq_b(2); |
| 611 | update_mcr68_interrupts(); | |
| 611 | update_mcr68_interrupts(machine); | |
| 612 | 612 | } |
| 613 | 613 | |
| 614 | 614 | |
| r2724 | r2725 | |
| 632 | 632 | * |
| 633 | 633 | *************************************/ |
| 634 | 634 | |
| 635 | INLINE void update_interrupts( | |
| 635 | INLINE void update_interrupts(running_machine *machine) | |
| 636 | 636 | { |
| 637 | 637 | m6840_status &= ~0x80; |
| 638 | 638 | |
| r2724 | r2725 | |
| 641 | 641 | if ((m6840_status & 0x04) && (m6840_state[2].control & 0x40)) m6840_status |= 0x80; |
| 642 | 642 | |
| 643 | 643 | m6840_irq_state = m6840_status >> 7; |
| 644 | update_mcr68_interrupts(); | |
| 644 | update_mcr68_interrupts(machine); | |
| 645 | 645 | } |
| 646 | 646 | |
| 647 | 647 | |
| 648 | static void subtract_from_counter(int counter, int count) | |
| 648 | static void subtract_from_counter(running_machine *machine, int counter, int count) | |
| 649 | 649 | { |
| 650 | 650 | /* dual-byte mode */ |
| 651 | 651 | if (m6840_state[counter].control & 0x04) |
| r2724 | r2725 | |
| 668 | 668 | { |
| 669 | 669 | m6840_status |= 1 << counter; |
| 670 | 670 | m6840_status_read_since_int &= ~(1 << counter); |
| 671 | update_interrupts(); | |
| 671 | update_interrupts(machine); | |
| 672 | 672 | msb = (m6840_state[counter].latch >> 8) + 1; |
| 673 | 673 | LOG(("** Counter %d fired\n", counter)); |
| 674 | 674 | } |
| r2724 | r2725 | |
| 695 | 695 | /* we've expired */ |
| 696 | 696 | m6840_status |= 1 << counter; |
| 697 | 697 | m6840_status_read_since_int &= ~(1 << counter); |
| 698 | update_interrupts(); | |
| 698 | update_interrupts(machine); | |
| 699 | 699 | LOG(("** Counter %d fired\n", counter)); |
| 700 | 700 | } |
| 701 | 701 | |
| r2724 | r2725 | |
| 714 | 714 | m6840_state[counter].timer_active = 0; |
| 715 | 715 | |
| 716 | 716 | /* subtract it all from the counter; this will generate an interrupt */ |
| 717 | subtract_from_counter(counter, count); | |
| 717 | subtract_from_counter(machine, counter, count); | |
| 718 | 718 | } |
| 719 | 719 | |
| 720 | 720 | |
| r2724 | r2725 | |
| 827 | 827 | } |
| 828 | 828 | |
| 829 | 829 | m6840_status = 0; |
| 830 | update_interrupts(); | |
| 830 | update_interrupts(machine); | |
| 831 | 831 | } |
| 832 | 832 | |
| 833 | 833 | /* changing the clock source? (needed for Zwackery) */ |
| r2724 | r2725 | |
| 852 | 852 | |
| 853 | 853 | /* clear the interrupt */ |
| 854 | 854 | m6840_status &= ~(1 << counter); |
| 855 | update_interrupts(); | |
| 855 | update_interrupts(machine); | |
| 856 | 856 | |
| 857 | 857 | /* reload the count if in an appropriate mode */ |
| 858 | 858 | if (!(m6840_state[counter].control & 0x10)) |
| r2724 | r2725 | |
| 886 | 886 | /* clear the interrupt if the status has been read */ |
| 887 | 887 | if (m6840_status_read_since_int & (1 << counter)) |
| 888 | 888 | m6840_status &= ~(1 << counter); |
| 889 | update_interrupts(); | |
| 889 | update_interrupts(machine); | |
| 890 | 890 | |
| 891 | 891 | m6840_lsb_buffer = result & 0xff; |
| 892 | 892 |
| r2724 | r2725 | |
|---|---|---|
| 8 | 8 | |
| 9 | 9 | static emu_timer *K056800_sound_cpu_timer; |
| 10 | 10 | static int K056800_sound_cpu_irq1_enable; |
| 11 | static void (*K056800_sound_irq_callback)(int); | |
| 11 | static void (*K056800_sound_irq_callback)(running_machine *, int); | |
| 12 | 12 | |
| 13 | 13 | static UINT8 K056800_host_reg_r(int reg) |
| 14 | 14 | { |
| r2724 | r2725 | |
| 20 | 20 | return value; |
| 21 | 21 | } |
| 22 | 22 | |
| 23 | static void K056800_host_reg_w(int reg, UINT8 data) | |
| 23 | static void K056800_host_reg_w(running_machine *machine, int reg, UINT8 data) | |
| 24 | 24 | { |
| 25 | 25 | K056800_sound_reg[reg] = data; |
| 26 | 26 | |
| 27 | 27 | if (reg == 7) |
| 28 | 28 | { |
| 29 | K056800_sound_irq_callback(1); | |
| 29 | K056800_sound_irq_callback(machine, 1); | |
| 30 | 30 | } |
| 31 | 31 | } |
| 32 | 32 | |
| r2724 | r2725 | |
| 49 | 49 | { |
| 50 | 50 | if (K056800_sound_cpu_irq1_enable) |
| 51 | 51 | { |
| 52 | K056800_sound_irq_callback(0); | |
| 52 | K056800_sound_irq_callback(machine, 0); | |
| 53 | 53 | } |
| 54 | 54 | } |
| 55 | 55 | |
| 56 | void K056800_init(void (* irq_callback)(int)) | |
| 56 | void K056800_init(void (* irq_callback)(running_machine *, int)) | |
| 57 | 57 | { |
| 58 | 58 | attotime timer_period; |
| 59 | 59 | K056800_sound_irq_callback = irq_callback; |
| r2724 | r2725 | |
| 95 | 95 | { |
| 96 | 96 | if (ACCESSING_BITS_24_31) |
| 97 | 97 | { |
| 98 | K056800_host_reg_w((offset*4)+0, (data >> 24) & 0xff); | |
| 98 | K056800_host_reg_w(machine, (offset*4)+0, (data >> 24) & 0xff); | |
| 99 | 99 | } |
| 100 | 100 | if (ACCESSING_BITS_16_23) |
| 101 | 101 | { |
| 102 | K056800_host_reg_w((offset*4)+1, (data >> 16) & 0xff); | |
| 102 | K056800_host_reg_w(machine, (offset*4)+1, (data >> 16) & 0xff); | |
| 103 | 103 | } |
| 104 | 104 | if (ACCESSING_BITS_8_15) |
| 105 | 105 | { |
| 106 | K056800_host_reg_w((offset*4)+2, (data >> 8) & 0xff); | |
| 106 | K056800_host_reg_w(machine, (offset*4)+2, (data >> 8) & 0xff); | |
| 107 | 107 | } |
| 108 | 108 | if (ACCESSING_BITS_0_7) |
| 109 | 109 | { |
| 110 | K056800_host_reg_w((offset*4)+3, (data >> 0) & 0xff); | |
| 110 | K056800_host_reg_w(machine, (offset*4)+3, (data >> 0) & 0xff); | |
| 111 | 111 | } |
| 112 | 112 | } |
| 113 | 113 |
| r2724 | r2725 | |
|---|---|---|
| 236 | 236 | that it's working, doesn't actually use return value, so we can just use |
| 237 | 237 | rand() */ |
| 238 | 238 | |
| 239 | return (input_port_read_indexed(machine, 1) & ~0x20) | (mame_rand( | |
| 239 | return (input_port_read_indexed(machine, 1) & ~0x20) | (mame_rand(machine) & 0x20); | |
| 240 | 240 | } |
| 241 | 241 | |
| 242 | 242 | WRITE8_HANDLER( kingball_speech_dip_w ) |
| r2724 | r2725 | |
|---|---|---|
| 1 | 1 | #ifndef _KONAMIIC_H |
| 2 | 2 | #define _KONAMIIC_H |
| 3 | 3 | |
| 4 | void K056800_init(void (* irq_callback)(int)); | |
| 4 | void K056800_init(void (* irq_callback)(running_machine *, int)); | |
| 5 | 5 | READ32_HANDLER(K056800_host_r); |
| 6 | 6 | WRITE32_HANDLER(K056800_host_w); |
| 7 | 7 | READ16_HANDLER(K056800_sound_r); |
| r2724 | r2725 | |
|---|---|---|
| 7 | 7 | ***************************************************************************/ |
| 8 | 8 | |
| 9 | 9 | #include "driver.h" |
| 10 | #include "deprecat.h" | |
| 11 | 10 | #include "cpu/mips/psx.h" |
| 12 | 11 | #include "includes/psx.h" |
| 13 | 12 | |
| r2724 | r2725 | |
| 67 | 66 | static UINT32 m_n_irqdata; |
| 68 | 67 | static UINT32 m_n_irqmask; |
| 69 | 68 | |
| 70 | static void psx_irq_update( | |
| 69 | static void psx_irq_update( running_machine *machine ) | |
| 71 | 70 | { |
| 72 | 71 | if( ( m_n_irqdata & m_n_irqmask ) != 0 ) |
| 73 | 72 | { |
| 74 | 73 | verboselog( 2, "psx irq assert\n" ); |
| 75 | cpunum_set_input_line( | |
| 74 | cpunum_set_input_line(machine, 0, MIPS_IRQ0, ASSERT_LINE ); | |
| 76 | 75 | } |
| 77 | 76 | else |
| 78 | 77 | { |
| 79 | 78 | verboselog( 2, "psx irq clear\n" ); |
| 80 | cpunum_set_input_line( | |
| 79 | cpunum_set_input_line(machine, 0, MIPS_IRQ0, CLEAR_LINE ); | |
| 81 | 80 | } |
| 82 | 81 | } |
| 83 | 82 | |
| r2724 | r2725 | |
| 88 | 87 | case 0x00: |
| 89 | 88 | verboselog( 2, "psx irq data ( %08x, %08x ) %08x -> %08x\n", data, mem_mask, m_n_irqdata, ( m_n_irqdata & ~mem_mask ) | ( m_n_irqdata & m_n_irqmask & data ) ); |
| 90 | 89 | m_n_irqdata = ( m_n_irqdata & ~mem_mask ) | ( m_n_irqdata & m_n_irqmask & data ); |
| 91 | psx_irq_update(); | |
| 90 | psx_irq_update(machine); | |
| 92 | 91 | break; |
| 93 | 92 | case 0x01: |
| 94 | 93 | verboselog( 2, "psx irq mask ( %08x, %08x ) %08x -> %08x\n", data, mem_mask, m_n_irqmask, ( m_n_irqmask & ~mem_mask ) | data ); |
| r2724 | r2725 | |
| 97 | 96 | { |
| 98 | 97 | verboselog( 0, "psx_irq_w( %08x, %08x, %08x ) unknown irq\n", offset, data, mem_mask ); |
| 99 | 98 | } |
| 100 | psx_irq_update(); | |
| 99 | psx_irq_update(machine); | |
| 101 | 100 | break; |
| 102 | 101 | default: |
| 103 | 102 | verboselog( 0, "psx_irq_w( %08x, %08x, %08x ) unknown register\n", offset, data, mem_mask ); |
| r2724 | r2725 | |
| 122 | 121 | return 0; |
| 123 | 122 | } |
| 124 | 123 | |
| 125 | void psx_irq_set( UINT32 data ) | |
| 124 | void psx_irq_set( running_machine *machine, UINT32 data ) | |
| 126 | 125 | { |
| 127 | 126 | verboselog( 2, "psx_irq_set %08x\n", data ); |
| 128 | 127 | m_n_irqdata |= data; |
| 129 | psx_irq_update(); | |
| 128 | psx_irq_update(machine); | |
| 130 | 129 | } |
| 131 | 130 | |
| 132 | 131 | /* DMA */ |
| r2724 | r2725 | |
| 167 | 166 | } |
| 168 | 167 | } |
| 169 | 168 | |
| 170 | static void dma_interrupt_update( | |
| 169 | static void dma_interrupt_update( running_machine *machine ) | |
| 171 | 170 | { |
| 172 | 171 | int n_int; |
| 173 | 172 | int n_mask; |
| r2724 | r2725 | |
| 179 | 178 | { |
| 180 | 179 | verboselog( 2, "dma_interrupt_update( %02x, %02x ) interrupt triggered\n", n_int, n_mask ); |
| 181 | 180 | m_n_dicr |= 0x80000000; |
| 182 | psx_irq_set( 0x0008 ); | |
| 181 | psx_irq_set( machine, 0x0008 ); | |
| 183 | 182 | } |
| 184 | 183 | else if( ( m_n_dicr & 0x80000000 ) != 0 ) |
| 185 | 184 | { |
| r2724 | r2725 | |
| 194 | 193 | m_n_dicr &= 0x00ffffff | ( m_n_dicr << 8 ); |
| 195 | 194 | } |
| 196 | 195 | |
| 197 | static void dma_finished(int n_channel) | |
| 196 | static void dma_finished(running_machine *machine, int n_channel) | |
| 198 | 197 | { |
| 199 | 198 | if( m_p_n_dmachannelcontrol[ n_channel ] == 0x01000401 && n_channel == 2 ) |
| 200 | 199 | { |
| r2724 | r2725 | |
| 250 | 249 | m_p_n_dmachannelcontrol[ n_channel ] &= ~( ( 1L << 0x18 ) | ( 1L << 0x1c ) ); |
| 251 | 250 | |
| 252 | 251 | m_n_dicr |= 1 << ( 24 + n_channel ); |
| 253 | dma_interrupt_update(); | |
| 252 | dma_interrupt_update(machine); | |
| 254 | 253 | dma_stop_timer( n_channel ); |
| 255 | 254 | } |
| 256 | 255 | |
| 257 | 256 | static TIMER_CALLBACK( dma_finished_callback ) |
| 258 | 257 | { |
| 259 | dma_finished(param); | |
| 258 | dma_finished(machine, param); | |
| 260 | 259 | } |
| 261 | 260 | |
| 262 | 261 | void psx_dma_install_read_handler( int n_channel, psx_dma_read_handler p_fn_dma_read ) |
| r2724 | r2725 | |
| 315 | 314 | { |
| 316 | 315 | verboselog( 1, "dma %d read block %08x %08x\n", n_channel, n_address, n_size ); |
| 317 | 316 | m_p_fn_dma_read[ n_channel ]( n_address, n_size ); |
| 318 | dma_finished( n_channel ); | |
| 317 | dma_finished( machine, n_channel ); | |
| 319 | 318 | } |
| 320 | 319 | else if( m_p_n_dmachannelcontrol[ n_channel ] == 0x01000200 && |
| 321 | 320 | m_p_fn_dma_read[ n_channel ] != NULL ) |
| r2724 | r2725 | |
| 328 | 327 | } |
| 329 | 328 | else |
| 330 | 329 | { |
| 331 | dma_finished( n_channel ); | |
| 330 | dma_finished( machine, n_channel ); | |
| 332 | 331 | } |
| 333 | 332 | } |
| 334 | 333 | else if( m_p_n_dmachannelcontrol[ n_channel ] == 0x01000201 && |
| r2724 | r2725 | |
| 336 | 335 | { |
| 337 | 336 | verboselog( 1, "dma %d write block %08x %08x\n", n_channel, n_address, n_size ); |
| 338 | 337 | m_p_fn_dma_write[ n_channel ]( n_address, n_size ); |
| 339 | dma_finished( n_channel ); | |
| 338 | dma_finished( machine, n_channel ); | |
| 340 | 339 | } |
| 341 | 340 | else if( m_p_n_dmachannelcontrol[ n_channel ] == 0x11050100 && |
| 342 | 341 | m_p_fn_dma_write[ n_channel ] != NULL ) |
| r2724 | r2725 | |
| 344 | 343 | /* todo: check this is a write not a read... */ |
| 345 | 344 | verboselog( 1, "dma %d write block %08x %08x\n", n_channel, n_address, n_size ); |
| 346 | 345 | m_p_fn_dma_write[ n_channel ]( n_address, n_size ); |
| 347 | dma_finished( n_channel ); | |
| 346 | dma_finished( machine, n_channel ); | |
| 348 | 347 | } |
| 349 | 348 | else if( m_p_n_dmachannelcontrol[ n_channel ] == 0x11150100 && |
| 350 | 349 | m_p_fn_dma_write[ n_channel ] != NULL ) |
| r2724 | r2725 | |
| 352 | 351 | /* todo: check this is a write not a read... */ |
| 353 | 352 | verboselog( 1, "dma %d write block %08x %08x\n", n_channel, n_address, n_size ); |
| 354 | 353 | m_p_fn_dma_write[ n_channel ]( n_address, n_size ); |
| 355 | dma_finished( n_channel ); | |
| 354 | dma_finished( machine, n_channel ); | |
| 356 | 355 | } |
| 357 | 356 | else if( m_p_n_dmachannelcontrol[ n_channel ] == 0x01000401 && |
| 358 | 357 | n_channel == 2 && |
| r2724 | r2725 | |
| 361 | 360 | verboselog( 1, "dma %d write linked list %08x\n", |
| 362 | 361 | n_channel, m_p_n_dmabase[ n_channel ] ); |
| 363 | 362 | |
| 364 | dma_finished( n_channel ); | |
| 363 | dma_finished( machine, n_channel ); | |
| 365 | 364 | } |
| 366 | 365 | else if( m_p_n_dmachannelcontrol[ n_channel ] == 0x11000002 && |
| 367 | 366 | n_channel == 6 ) |
| r2724 | r2725 | |
| 418 | 417 | } |
| 419 | 418 | */ |
| 420 | 419 | verboselog( 1, "psx_dma_w( %04x, %08x, %08x ) dicr -> %08x\n", offset, data, mem_mask, m_n_dicr ); |
| 421 | dma_interrupt_update(); | |
| 420 | dma_interrupt_update(machine); | |
| 422 | 421 | break; |
| 423 | 422 | default: |
| 424 | 423 | verboselog( 0, "psx_dma_w( %04x, %08x, %08x ) Unknown dma control register\n", offset, data, mem_mask ); |
| r2724 | r2725 | |
| 580 | 579 | if( ( m_p_n_root_mode[ n_counter ] & RC_IRQOVERFLOW ) != 0 || |
| 581 | 580 | ( m_p_n_root_mode[ n_counter ] & RC_IRQTARGET ) != 0 ) |
| 582 | 581 | { |
| 583 | psx_irq_set( 0x10 << n_counter ); | |
| 582 | psx_irq_set( machine, 0x10 << n_counter ); | |
| 584 | 583 | } |
| 585 | 584 | } |
| 586 | 585 | |
| r2724 | r2725 | |
| 688 | 687 | #define SIO_CONTROL_DSR_IENA ( 1 << 12 ) |
| 689 | 688 | #define SIO_CONTROL_DTR ( 1 << 13 ) |
| 690 | 689 | |
| 691 | static void sio_interrupt( int n_port ) | |
| 690 | static void sio_interrupt( running_machine *machine, int n_port ) | |
| 692 | 691 | { |
| 693 | 692 | verboselog( 1, "sio_interrupt( %d )\n", n_port ); |
| 694 | 693 | m_p_n_sio_status[ n_port ] |= SIO_STATUS_IRQ; |
| 695 | 694 | if( n_port == 0 ) |
| 696 | 695 | { |
| 697 | psx_irq_set( 0x80 ); | |
| 696 | psx_irq_set( machine, 0x80 ); | |
| 698 | 697 | } |
| 699 | 698 | else |
| 700 | 699 | { |
| 701 | psx_irq_set( 0x100 ); | |
| 700 | psx_irq_set( machine, 0x100 ); | |
| 702 | 701 | } |
| 703 | 702 | } |
| 704 | 703 | |
| r2724 | r2725 | |
| 784 | 783 | if( m_p_n_sio_tx_bits[ n_port ] == 0 && |
| 785 | 784 | ( m_p_n_sio_control[ n_port ] & SIO_CONTROL_TX_IENA ) != 0 ) |
| 786 | 785 | { |
| 787 | sio_interrupt( n_port ); | |
| 786 | sio_interrupt( machine, n_port ); | |
| 788 | 787 | } |
| 789 | 788 | } |
| 790 | 789 | |
| r2724 | r2725 | |
| 806 | 805 | } |
| 807 | 806 | if( ( m_p_n_sio_control[ n_port ] & SIO_CONTROL_RX_IENA ) != 0 ) |
| 808 | 807 | { |
| 809 | sio_interrupt( n_port ); | |
| 808 | sio_interrupt( machine, n_port ); | |
| 810 | 809 | } |
| 811 | 810 | } |
| 812 | 811 | } |
| r2724 | r2725 | |
| 814 | 813 | sio_timer_adjust( n_port ); |
| 815 | 814 | } |
| 816 | 815 | |
| 817 | void psx_sio_input( int n_port, int n_mask, int n_data ) | |
| 816 | void psx_sio_input( running_machine *machine, int n_port, int n_mask, int n_data ) | |
| 818 | 817 | { |
| 819 | 818 | verboselog( 1, "psx_sio_input( %d, %02x, %02x )\n", n_port, n_mask, n_data ); |
| 820 | 819 | m_p_n_sio_rx[ n_port ] = ( m_p_n_sio_rx[ n_port ] & ~n_mask ) | ( n_data & n_mask ); |
| r2724 | r2725 | |
| 825 | 824 | if( ( m_p_n_sio_rx_prev[ n_port ] & PSX_SIO_IN_DSR ) == 0 && |
| 826 | 825 | ( m_p_n_sio_control[ n_port ] & SIO_CONTROL_DSR_IENA ) != 0 ) |
| 827 | 826 | { |
| 828 | sio_interrupt( n_port ); | |
| 827 | sio_interrupt( machine, n_port ); | |
| 829 | 828 | } |
| 830 | 829 | } |
| 831 | 830 | else |
| r2724 | r2725 | |
| 1539 | 1538 | { |
| 1540 | 1539 | int n; |
| 1541 | 1540 | |
| 1542 | psx_irq_update(); | |
| 1541 | psx_irq_update(machine); | |
| 1543 | 1542 | |
| 1544 | 1543 | for( n = 0; n < 7; n++ ) |
| 1545 | 1544 | { |
| r2724 | r2725 | |
|---|---|---|
| 1 | 1 | #include "driver.h" |
| 2 | #include "deprecat.h" | |
| 3 | 2 | #include "cpu/m6809/m6809.h" |
| 4 | 3 | #include "machine/6522via.h" |
| 5 | 4 | |
| r2724 | r2725 | |
| 13 | 12 | static WRITE8_HANDLER( b_via_0_pb_w ); |
| 14 | 13 | static READ8_HANDLER( b_via_0_ca2_r ); |
| 15 | 14 | static WRITE8_HANDLER( b_via_0_ca2_w ); |
| 16 | static void b_via_0_irq (int level); | |
| 15 | static void b_via_0_irq (running_machine *machine, int level); | |
| 17 | 16 | |
| 18 | 17 | static READ8_HANDLER( b_via_1_pa_r ); |
| 19 | 18 | static READ8_HANDLER( b_via_1_pb_r ); |
| 20 | 19 | static WRITE8_HANDLER( b_via_1_pa_w ); |
| 21 | 20 | static WRITE8_HANDLER( b_via_1_pb_w ); |
| 22 | static void b_via_1_irq (int level); | |
| 21 | static void b_via_1_irq (running_machine *machine, int level); | |
| 23 | 22 | |
| 24 | 23 | static const struct via6522_interface b_via_0_interface = |
| 25 | 24 | { |
| r2724 | r2725 | |
| 48 | 47 | { |
| 49 | 48 | } |
| 50 | 49 | |
| 51 | static void b_via_0_irq (int level) | |
| 50 | static void b_via_0_irq (running_machine *machine, int level) | |
| 52 | 51 | { |
| 53 | cpunum_set_input_line( | |
| 52 | cpunum_set_input_line(machine, 0, M6809_IRQ_LINE, level); | |
| 54 | 53 | } |
| 55 | 54 | |
| 56 | 55 | static READ8_HANDLER( b_via_0_pb_r ) |
| r2724 | r2725 | |
| 90 | 89 | pbus = data; |
| 91 | 90 | } |
| 92 | 91 | |
| 93 | static void b_via_1_irq (int level) | |
| 92 | static void b_via_1_irq (running_machine *machine, int level) | |
| 94 | 93 | { |
| 95 | cpunum_set_input_line( | |
| 94 | cpunum_set_input_line(machine, 1, M6809_IRQ_LINE, level); | |
| 96 | 95 | } |
| 97 | 96 | |
| 98 | 97 | static READ8_HANDLER( b_via_1_pa_r ) |
| r2724 | r2725 | |
|---|---|---|
| 13 | 13 | ***************************************************************************/ |
| 14 | 14 | |
| 15 | 15 | #include "driver.h" |
| 16 | #include "deprecat.h" | |
| 17 | 16 | #include "includes/kaneko16.h" |
| 18 | 17 | |
| 19 | 18 | #include "kanekotb.h" // TOYBOX MCU trojaning results |
| r2724 | r2725 | |
| 87 | 86 | return (((UINT32)hit.mult_a * (UINT32)hit.mult_b) & 0xffff); |
| 88 | 87 | |
| 89 | 88 | case 0x14/2: |
| 90 | return (mame_rand( | |
| 89 | return (mame_rand(machine) & 0xffff); | |
| 91 | 90 | |
| 92 | 91 | default: |
| 93 | 92 | logerror("CPU #0 PC %06x: warning - read unmapped calc address %06x\n",activecpu_get_pc(),offset<<1); |
| r2724 | r2725 | |
| 218 | 217 | return data; |
| 219 | 218 | |
| 220 | 219 | case 0x14/2: |
| 221 | return (mame_rand( | |
| 220 | return (mame_rand(machine) & 0xffff); | |
| 222 | 221 | |
| 223 | 222 | case 0x20/2: return hit.x1p; |
| 224 | 223 | case 0x22/2: return hit.x1s; |
| r2724 | r2725 | |
| 597 | 596 | case 0x02: // Read from NVRAM |
| 598 | 597 | { |
| 599 | 598 | mame_file *f; |
| 600 | if ((f = nvram_fopen( | |
| 599 | if ((f = nvram_fopen(machine, OPEN_FLAG_READ)) != 0) | |
| 601 | 600 | { |
| 602 | 601 | mame_fread(f,&kaneko16_mcu_ram[mcu_offset], 128); |
| 603 | 602 | mame_fclose(f); |
| r2724 | r2725 | |
| 609 | 608 | case 0x42: // Write to NVRAM |
| 610 | 609 | { |
| 611 | 610 | mame_file *f; |
| 612 | if ((f = nvram_fopen( | |
| 611 | if ((f = nvram_fopen(machine, OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS)) != 0) | |
| 613 | 612 | { |
| 614 | 613 | mame_fwrite(f,&kaneko16_mcu_ram[mcu_offset], 128); |
| 615 | 614 | mame_fclose(f); |
| r2724 | r2725 | |
| 712 | 711 | case 0x02: // Read from NVRAM |
| 713 | 712 | { |
| 714 | 713 | mame_file *f; |
| 715 | if ((f = nvram_fopen( | |
| 714 | if ((f = nvram_fopen(machine, OPEN_FLAG_READ)) != 0) | |
| 716 | 715 | { |
| 717 | 716 | mame_fread(f,&kaneko16_mcu_ram[mcu_offset], 128); |
| 718 | 717 | mame_fclose(f); |
| r2724 | r2725 | |
| 724 | 723 | case 0x42: // Write to NVRAM |
| 725 | 724 | { |
| 726 | 725 | mame_file *f; |
| 727 | if ((f = nvram_fopen( | |
| 726 | if ((f = nvram_fopen(machine, OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS)) != 0) | |
| 728 | 727 | { |
| 729 | 728 | mame_fwrite(f,&kaneko16_mcu_ram[mcu_offset], 128); |
| 730 | 729 | mame_fclose(f); |
| r2724 | r2725 | |
| 736 | 735 | case 0x43: // Initialize NVRAM - MCU writes Default Data Set directly to NVRAM |
| 737 | 736 | { |
| 738 | 737 | mame_file *f; |
| 739 | if ((f = nvram_fopen( | |
| 738 | if ((f = nvram_fopen(machine, OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS)) != 0) | |
| 740 | 739 | { |
| 741 | 740 | mame_fwrite(f, bonkadv_mcu_43, sizeof(bonkadv_mcu_43)); |
| 742 | 741 | mame_fclose(f); |
| r2724 | r2725 | |
| 834 | 833 | case 0x02: // Read from NVRAM |
| 835 | 834 | { |
| 836 | 835 | mame_file *f; |
| 837 | if ((f = nvram_fopen( | |
| 836 | if ((f = nvram_fopen(machine, OPEN_FLAG_READ)) != 0) | |
| 838 | 837 | { |
| 839 | 838 | mame_fread(f,&kaneko16_mcu_ram[mcu_offset], 128); |
| 840 | 839 | mame_fclose(f); |
| r2724 | r2725 | |
| 845 | 844 | case 0x42: // Write to NVRAM |
| 846 | 845 | { |
| 847 | 846 | mame_file *f; |
| 848 | if ((f = nvram_fopen( | |
| 847 | if ((f = nvram_fopen(machine, OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS)) != 0) | |
| 849 | 848 | { |
| 850 | 849 | mame_fwrite(f,&kaneko16_mcu_ram[mcu_offset], 128); |
| 851 | 850 | mame_fclose(f); |
| r2724 | r2725 | |
| 861 | 860 | |
| 862 | 861 | case 0x04: // TEST (2 versions) |
| 863 | 862 | { |
| 864 | if (strcmp(Machine->gamedrv->name, "gtmr") == 0 || | |
| 865 | strcmp(Machine->gamedrv->name, "gtmra") == 0) | |
| 863 | if (strcmp(machine->gamedrv->name, "gtmr") == 0 || | |
| 864 | strcmp(machine->gamedrv->name, "gtmra") == 0) | |
| 866 | 865 | { |
| 867 | 866 | /* MCU writes the string "MM0525-TOYBOX199" to shared ram */ |
| 868 | 867 | kaneko16_mcu_ram[mcu_offset+0] = 0x4d4d; |
| r2724 | r2725 | |
|---|---|---|
| 5 | 5 | ***************************************************************************/ |
| 6 | 6 | |
| 7 | 7 | #include "driver.h" |
| 8 | #include "deprecat.h" | |
| 9 | 8 | #include "audio/williams.h" |
| 10 | 9 | #include "cpu/m6800/m6800.h" |
| 11 | 10 | #include "cpu/m6809/m6809.h" |
| r2724 | r2725 | |
| 32 | 31 | static UINT16 joust2_current_sound_data; |
| 33 | 32 | |
| 34 | 33 | /* older-Williams routines */ |
| 35 | static void williams_main_irq(int state); | |
| 36 | static void williams_main_firq(int state); | |
| 37 | static void williams_snd_irq(int state); | |
| 34 | static void williams_main_irq(running_machine *machine, int state); | |
| 35 | static void williams_main_firq(running_machine *machine, int state); | |
| 36 | static void williams_snd_irq(running_machine *machine, int state); | |
| 38 | 37 | static WRITE8_HANDLER( williams_snd_cmd_w ); |
| 39 | 38 | static WRITE8_HANDLER( playball_snd_cmd_w ); |
| 40 | 39 | |
| r2724 | r2725 | |
| 48 | 47 | |
| 49 | 48 | /* newer-Williams routines */ |
| 50 | 49 | static WRITE8_HANDLER( williams2_snd_cmd_w ); |
| 51 | static void mysticm_main_irq(int state); | |
| 52 | static void tshoot_main_irq(int state); | |
| 50 | static void mysticm_main_irq(running_machine *machine, int state); | |
| 51 | static void tshoot_main_irq(running_machine *machine, int state); | |
| 53 | 52 | |
| 54 | 53 | /* Lotto Fun-specific code */ |
| 55 | 54 | static READ8_HANDLER( lottofun_input_port_0_r ); |
| r2724 | r2725 | |
| 297 | 296 | } |
| 298 | 297 | |
| 299 | 298 | |
| 300 | static void williams_main_irq(int state) | |
| 299 | static void williams_main_irq(running_machine *machine, int state) | |
| 301 | 300 | { |
| 302 | 301 | int combined_state = pia_get_irq_a(1) | pia_get_irq_b(1); |
| 303 | 302 | |
| 304 | 303 | /* IRQ to the main CPU */ |
| 305 | cpunum_set_input_line( | |
| 304 | cpunum_set_input_line(machine, 0, M6809_IRQ_LINE, combined_state ? ASSERT_LINE : CLEAR_LINE); | |
| 306 | 305 | } |
| 307 | 306 | |
| 308 | 307 | |
| 309 | static void williams_main_firq(int state) | |
| 308 | static void williams_main_firq(running_machine *machine, int state) | |
| 310 | 309 | { |
| 311 | 310 | /* FIRQ to the main CPU */ |
| 312 | cpunum_set_input_line( | |
| 311 | cpunum_set_input_line(machine, 0, M6809_FIRQ_LINE, state ? ASSERT_LINE : CLEAR_LINE); | |
| 313 | 312 | } |
| 314 | 313 | |
| 315 | 314 | |
| 316 | static void williams_snd_irq(int state) | |
| 315 | static void williams_snd_irq(running_machine *machine, int state) | |
| 317 | 316 | { |
| 318 | 317 | int combined_state = pia_get_irq_a(2) | pia_get_irq_b(2); |
| 319 | 318 | |
| 320 | 319 | /* IRQ to the sound CPU */ |
| 321 | cpunum_set_input_line( | |
| 320 | cpunum_set_input_line(machine, 1, M6800_IRQ_LINE, combined_state ? ASSERT_LINE : CLEAR_LINE); | |
| 322 | 321 | } |
| 323 | 322 | |
| 324 | 323 | |
| r2724 | r2725 | |
| 329 | 328 | * |
| 330 | 329 | *************************************/ |
| 331 | 330 | |
| 332 | static void mysticm_main_irq(int state) | |
| 331 | static void mysticm_main_irq(running_machine *machine, int state) | |
| 333 | 332 | { |
| 334 | 333 | int combined_state = pia_get_irq_b(0) | pia_get_irq_a(1) | pia_get_irq_b(1); |
| 335 | 334 | |
| 336 | 335 | /* IRQ to the main CPU */ |
| 337 | cpunum_set_input_line( | |
| 336 | cpunum_set_input_line(machine, 0, M6809_IRQ_LINE, combined_state ? ASSERT_LINE : CLEAR_LINE); | |
| 338 | 337 | } |
| 339 | 338 | |
| 340 | 339 | |
| 341 | static void tshoot_main_irq(int state) | |
| 340 | static void tshoot_main_irq(running_machine *machine, int state) | |
| 342 | 341 | { |
| 343 | 342 | int combined_state = pia_get_irq_a(0) | pia_get_irq_b(0) | pia_get_irq_a(1) | pia_get_irq_b(1); |
| 344 | 343 | |
| 345 | 344 | /* IRQ to the main CPU */ |
| 346 | cpunum_set_input_line( | |
| 345 | cpunum_set_input_line(machine, 0, M6809_IRQ_LINE, combined_state ? ASSERT_LINE : CLEAR_LINE); | |
| 347 | 346 | } |
| 348 | 347 | |
| 349 | 348 |
| r2724 | r2725 | |
|---|---|---|
| 8 | 8 | ***************************************************************************/ |
| 9 | 9 | |
| 10 | 10 | #include "driver.h" |
| 11 | #include "deprecat.h" | |
| 12 | 11 | #include "starwars.h" |
| 13 | 12 | #include "video/avgdvg.h" |
| 14 | 13 | |
| r2724 | r2725 | |
| 414 | 413 | */ |
| 415 | 414 | |
| 416 | 415 | /* Use MAME's PRNG for now */ |
| 417 | return mame_rand( | |
| 416 | return mame_rand(machine); | |
| 418 | 417 | } |
| 419 | 418 | |
| 420 | 419 |
| r2724 | r2725 | |
|---|---|---|
| 1494 | 1494 | { |
| 1495 | 1495 | //UINT32 dst = cop_register[0]; |
| 1496 | 1496 | //UINT32 dst = cop_register[1]; |
| 1497 | //program_write_word(dst, mame_rand(Machine)/*program_read_word(src)*/); | |
| 1498 | //program_write_word(dst+2,mame_rand(Machine)/*program_read_word(src+2)*/); | |
| 1499 | //program_write_word(dst+4,mame_rand(Machine)/*program_read_word(src+4)*/); | |
| 1500 | //program_write_word(dst+6,mame_rand(Machine)/*program_read_word(src+6)*/); | |
| 1497 | //program_write_word(dst, mame_rand(machine)/*program_read_word(src)*/); | |
| 1498 | //program_write_word(dst+2,mame_rand(machine)/*program_read_word(src+2)*/); | |
| 1499 | //program_write_word(dst+4,mame_rand(machine)/*program_read_word(src+4)*/); | |
| 1500 | //program_write_word(dst+6,mame_rand(machine)/*program_read_word(src+6)*/); | |
| 1501 | 1501 | //logerror("%04x\n",cop_register[0]); |
| 1502 | 1502 | break; |
| 1503 | 1503 | } |
| r2724 | r2725 | |
|---|---|---|
| 8 | 8 | ***************************************************************************/ |
| 9 | 9 | |
| 10 | 10 | #include "driver.h" |
| 11 | #include "deprecat.h" | |
| 12 | 11 | #include "cpu/m6809/m6809.h" |
| 13 | 12 | #include "cpu/z80/z80.h" |
| 14 | 13 | #include "cpu/konami/konami.h" |
| r2724 | r2725 | |
| 113 | 112 | |
| 114 | 113 | switch ((offset & 0x01c0) >> 6){ |
| 115 | 114 | case 0x00: /* ??? */ |
| 116 | data = mame_rand( | |
| 115 | data = mame_rand(machine); | |
| 117 | 116 | break; |
| 118 | 117 | case 0x04: /* 2P inputs */ |
| 119 | 118 | data = input_port_read_indexed(machine, 5); |
| r2724 | r2725 | |
|---|---|---|
| 3505 | 3505 | DRIVER( shinoblb ) /* (c) 1987 (but bootleg) */ |
| 3506 | 3506 | DRIVER( shinobld ) /* (c) 1987 (but bootleg) */ |
| 3507 | 3507 | DRIVER( tetrisbl ) /* (c) 1988 (but bootleg) */ |
| 3508 | DRIVER( beautyb ) /* (c) 1991 AMT */ | |
| 3508 | 3509 | DRIVER( tturfbl ) /* (c) 1989 (Datsu bootleg) */ |
| 3509 | 3510 | DRIVER( wb3bbl ) /* BOOTLEG */ |
| 3510 | 3511 | |
| r2724 | r2725 | |
| 6670 | 6671 | DRIVER( sarukani ) /* (c) 1997 Kaneko / Mediaworks (Japan) */ |
| 6671 | 6672 | DRIVER( cyvern ) /* (c) 1998 Kaneko (Japan) */ |
| 6672 | 6673 | DRIVER( galpans2 ) /* (c) 1999 Kaneko (Japan) */ |
| 6674 | DRIVER( galpansu ) /* (c) 1999 Kaneko (Korea) */ | |
| 6673 | 6675 | DRIVER( panicstr ) /* (c) 1999 Kaneko (Japan) */ |
| 6674 | 6676 | DRIVER( senknow ) /* (c) 1999 Kaneko / Kouyousha (Japan) */ |
| 6675 | 6677 | DRIVER( gutsn ) /* (c) 2000 Kaneko / Kouyousha (Japan) */ |
| r2724 | r2725 | |
| 6990 | 6992 | DRIVER( dharmak ) /* (c) 1994 */ |
| 6991 | 6993 | DRIVER( lastfort ) /* (c) 1994 */ |
| 6992 | 6994 | DRIVER( lastfero ) /* (c) 1994 */ |
| 6995 | DRIVER( lastfork ) /* (c) 1994 */ | |
| 6993 | 6996 | DRIVER( lastforg ) /* (c) 1994 */ |
| 6994 | 6997 | DRIVER( toride2g ) /* (c) 1994 */ |
| 6995 | 6998 | DRIVER( torid2gg ) /* (c) 1994 */ |
| r2724 | r2725 | |
| 7680 | 7683 | DRIVER( 9ballsh2 ) /* (c) 1993 E-Scape EnterMedia + "marketed by Bundra Games" */ |
| 7681 | 7684 | DRIVER( 9ballsh3 ) /* (c) 1993 E-Scape EnterMedia + "marketed by Bundra Games" */ |
| 7682 | 7685 | DRIVER( gumbo ) /* (c) 1994 Min Corp. */ |
| 7686 | DRIVER( mspuzzlg ) /* (c) 1994 Min Corp. */ | |
| 7683 | 7687 | DRIVER( mspuzzle ) /* (c) 1994 Min Corp. */ |
| 7684 | 7688 | DRIVER( mspuzzln ) /* (c) 1994 Min Corp. */ |
| 7685 | 7689 | DRIVER( msbingo ) /* (C) 1994 Min Corp. */ |
| r2724 | r2725 | |
|---|---|---|
| 50 | 50 | |
| 51 | 51 | READ8_HANDLER ( atari_serin_r ); |
| 52 | 52 | WRITE8_HANDLER ( atari_serout_w ); |
| 53 | void atari_interrupt_cb(int mask); | |
| 53 | void atari_interrupt_cb(running_machine *machine, int mask); | |
| 54 | 54 | |
| 55 | 55 | void a800_handle_keyboard(running_machine *machine); |
| 56 | 56 | void a5200_handle_keypads(running_machine *machine); |
| r2724 | r2725 | |
|---|---|---|
| 8 | 8 | |
| 9 | 9 | extern UINT8 dynax_blitter_irq, dynax_blitter2_irq; |
| 10 | 10 | |
| 11 | void sprtmtch_update_irq(void); | |
| 12 | void jantouki_update_irq(void); | |
| 13 | void mjelctrn_update_irq(void); | |
| 14 | void neruton_update_irq(void); | |
| 11 | void sprtmtch_update_irq(running_machine *machine); | |
| 12 | void jantouki_update_irq(running_machine *machine); | |
| 13 | void mjelctrn_update_irq(running_machine *machine); | |
| 14 | void neruton_update_irq(running_machine *machine); | |
| 15 | 15 | |
| 16 | 16 | //----------- defined in video/dynax.c ----------- |
| 17 | 17 |
| r2724 | r2725 | |
|---|---|---|
| 22 | 22 | |
| 23 | 23 | #define NA1_NVRAM_SIZE (0x800) |
| 24 | 24 | |
| 25 | extern UINT16 *namcona1_rozvideoram; | |
| 26 | 25 | extern UINT16 *namcona1_workram; |
| 27 | 26 | extern UINT16 *namcona1_vreg; |
| 28 | 27 | extern UINT16 *namcona1_scroll; |
| 29 | 28 | |
| 30 | extern WRITE16_HANDLER( namcona1_rozvideoram_w ); | |
| 31 | extern READ16_HANDLER( namcona1_rozvideoram_r ); | |
| 32 | ||
| 33 | 29 | extern WRITE16_HANDLER( namcona1_videoram_w ); |
| 34 | 30 | extern READ16_HANDLER( namcona1_videoram_r ); |
| 35 | 31 |
| r2724 | r2725 | |
|---|---|---|
| 30 | 30 | READ32_HANDLER( psx_com_delay_r ); |
| 31 | 31 | WRITE32_HANDLER( psx_irq_w ); |
| 32 | 32 | READ32_HANDLER( psx_irq_r ); |
| 33 | extern void psx_irq_set( UINT32 ); | |
| 33 | extern void psx_irq_set( running_machine *, UINT32 ); | |
| 34 | 34 | extern void psx_dma_install_read_handler( int, psx_dma_read_handler ); |
| 35 | 35 | extern void psx_dma_install_write_handler( int, psx_dma_read_handler ); |
| 36 | 36 | WRITE32_HANDLER( psx_dma_w ); |
| r2724 | r2725 | |
| 41 | 41 | READ32_HANDLER( psx_sio_r ); |
| 42 | 42 | typedef void ( *psx_sio_handler )( int ); |
| 43 | 43 | extern void psx_sio_install_handler( int, psx_sio_handler ); |
| 44 | extern void psx_sio_input( int, int, int ); | |
| 44 | extern void psx_sio_input( running_machine *, int, int, int ); | |
| 45 | 45 | |
| 46 | 46 | #define PSX_SIO_OUT_DATA ( 1 ) /* COMMAND */ |
| 47 | 47 | #define PSX_SIO_OUT_DTR ( 2 ) /* ATT */ |
| r2724 | r2725 | |
|---|---|---|
| 34 | 34 | extern READ16_HANDLER ( genesis_io_r ); |
| 35 | 35 | extern READ16_HANDLER ( genesis_68k_to_z80_r ); |
| 36 | 36 | extern INTERRUPT_GEN( genesis_vblank_interrupt ); |
| 37 | extern void genesis_irq2_interrupt(int state); | |
| 37 | extern void genesis_irq2_interrupt(running_machine *machine, int state); | |
| 38 | 38 | |
| 39 | 39 | /*----------- defined in video/genesis.c -----------*/ |
| 40 | 40 |
| r2724 | r2725 | |
|---|---|---|
| 1640 | 1640 | # layout dependencies |
| 1641 | 1641 | #------------------------------------------------- |
| 1642 | 1642 | |
| 1643 | $(DRIVERS)/8080bw.o: $(LAYOUT)/invrvnge.lh | |
| 1643 | $(DRIVERS)/8080bw.o: $(LAYOUT)/invrvnge.lh \ | |
| 1644 | $(LAYOUT)/shuttlei.lh | |
| 1644 | 1645 | |
| 1645 | 1646 | $(DRIVERS)/acefruit.o: $(LAYOUT)/sidewndr.lh |
| 1646 | 1647 |
| r2724 | r2725 | |
|---|---|---|
| 573 | 573 | |
| 574 | 574 | if (!code) continue; |
| 575 | 575 | |
| 576 | xpos = (aerofgt_spriteram3[i + 2] & 0x01ff) - 1 | |
| 576 | xpos = (aerofgt_spriteram3[i + 2] & 0x01ff) - 13; | |
| 577 | 577 | ypos = 256 - (aerofgt_spriteram3[i + 1] & 0x00ff) - 26; |
| 578 | 578 | flipy = 0; |
| 579 | 579 | flipx = aerofgt_spriteram3[i + 3] & 0x8000; |
| r2724 | r2725 | |
|---|---|---|
| 8 | 8 | ***************************************************************************/ |
| 9 | 9 | |
| 10 | 10 | #include "driver.h" |
| 11 | #include "deprecat.h" | |
| 12 | 11 | #include "kaneko16.h" |
| 13 | 12 | |
| 14 | 13 | /* |
| r2724 | r2725 | |
| 37 | 36 | { \ |
| 38 | 37 | switch (offset * 2) \ |
| 39 | 38 | { \ |
| 40 | case 0x16: return mame_rand( | |
| 39 | case 0x16: return mame_rand(machine) & 1; \ | |
| 41 | 40 | default: \ |
| 42 | 41 | logerror("CPU #0 PC %06X : Warning, bg8 #%d screen reg %04X read\n",activecpu_get_pc(),_n_,offset*2); \ |
| 43 | 42 | } \ |
| r2724 | r2725 | |
|---|---|---|
| 77 | 77 | |
| 78 | 78 | static int layer_layout; |
| 79 | 79 | |
| 80 | static void (*update_irq_func)( | |
| 80 | static void (*update_irq_func)(running_machine *machine); // some games trigger IRQ at blitter end, some don't | |
| 81 | 81 | |
| 82 | 82 | // up to 8 layers, 2 images per layer (interleaved on screen) |
| 83 | 83 | static UINT8 *dynax_pixmap[8][2]; |
| r2724 | r2725 | |
| 503 | 503 | |
| 504 | 504 | |
| 505 | 505 | |
| 506 | static void dynax_blitter_start(int flags) | |
| 506 | static void dynax_blitter_start(running_machine *machine, int flags) | |
| 507 | 507 | { |
| 508 | 508 | int blit_newsrc; |
| 509 | 509 | |
| r2724 | r2725 | |
| 528 | 528 | if (update_irq_func) |
| 529 | 529 | { |
| 530 | 530 | dynax_blitter_irq = 1; |
| 531 | update_irq_func(); | |
| 531 | update_irq_func(machine); | |
| 532 | 532 | } |
| 533 | 533 | } |
| 534 | 534 | |
| 535 | static void jantouki_blitter_start(int flags) | |
| 535 | static void jantouki_blitter_start(running_machine *machine, int flags) | |
| 536 | 536 | { |
| 537 | 537 | int blit_newsrc; |
| 538 | 538 | |
| r2724 | r2725 | |
| 557 | 557 | if (update_irq_func) |
| 558 | 558 | { |
| 559 | 559 | dynax_blitter_irq = 1; |
| 560 | update_irq_func(); | |
| 560 | update_irq_func(machine); | |
| 561 | 561 | } |
| 562 | 562 | } |
| 563 | 563 | |
| 564 | static void jantouki_blitter2_start(int flags) | |
| 564 | static void jantouki_blitter2_start(running_machine *machine, int flags) | |
| 565 | 565 | { |
| 566 | 566 | int blit2_newsrc; |
| 567 | 567 | |
| r2724 | r2725 | |
| 586 | 586 | if (update_irq_func) |
| 587 | 587 | { |
| 588 | 588 | dynax_blitter2_irq = 1; |
| 589 | update_irq_func(); | |
| 589 | update_irq_func(machine); | |
| 590 | 590 | } |
| 591 | 591 | } |
| 592 | 592 | |
| r2724 | r2725 | |
| 650 | 650 | { |
| 651 | 651 | switch (offset) |
| 652 | 652 | { |
| 653 | case 0: dynax_blitter_start(data); break; | |
| 653 | case 0: dynax_blitter_start(machine,data); break; | |
| 654 | 654 | case 1: blit_x = data; break; |
| 655 | 655 | case 2: blit_y = data; break; |
| 656 | 656 | case 3: blit_src = (blit_src & 0xffff00) | (data << 0); break; |
| r2724 | r2725 | |
| 665 | 665 | { |
| 666 | 666 | switch (offset) |
| 667 | 667 | { |
| 668 | case 0: dynax_blitter_start(data); break; | |
| 668 | case 0: dynax_blitter_start(machine,data); break; | |
| 669 | 669 | case 1: blit_x = data; break; |
| 670 | 670 | case 2: blit_y = data; break; |
| 671 | 671 | case 3: blit_src = (blit_src & 0xffff00) | (data << 0); break; |
| r2724 | r2725 | |
| 680 | 680 | { |
| 681 | 681 | switch (offset) |
| 682 | 682 | { |
| 683 | case 0: jantouki_blitter_start(data); break; | |
| 683 | case 0: jantouki_blitter_start(machine,data); break; | |
| 684 | 684 | case 1: blit_x = data; break; |
| 685 | 685 | case 2: blit_y = data; break; |
| 686 | 686 | case 3: blit_src = (blit_src & 0xffff00) | (data << 0); break; |
| r2724 | r2725 | |
| 694 | 694 | { |
| 695 | 695 | switch (offset) |
| 696 | 696 | { |
| 697 | case 0: jantouki_blitter2_start(data); break; | |
| 697 | case 0: jantouki_blitter2_start(machine,data); break; | |
| 698 | 698 | case 1: blit2_x = data; break; |
| 699 | 699 | case 2: blit2_y = data; break; |
| 700 | 700 | case 3: blit2_src = (blit2_src & 0xffff00) | (data << 0); break; |
| r2724 | r2725 | |
|---|---|---|
| 435 | 435 | pointless - it's always hidden by other layers. Does it |
| 436 | 436 | serve some blending pupose ? */ |
| 437 | 437 | |
| 438 | TC0100SCN_tilemap_draw(screen->machine,bitmap,cliprect,0,pivlayer[0], | |
| 438 | TC0100SCN_tilemap_draw(screen->machine,bitmap,cliprect,0,pivlayer[0],TILEMAP_DRAW_OPAQUE,0); | |
| 439 | 439 | TC0100SCN_tilemap_draw(screen->machine,bitmap,cliprect,0,pivlayer[1],0,0); |
| 440 | 440 | |
| 441 | 441 | #ifdef MAME_DEBUG |
| r2724 | r2725 | |
|---|---|---|
| 5 | 5 | **************************************************************************/ |
| 6 | 6 | |
| 7 | 7 | #include "driver.h" |
| 8 | #include "deprecat.h" | |
| 9 | 8 | #include "eminline.h" |
| 10 | 9 | #include "includes/midzeus.h" |
| 11 | 10 | #include "video/poly.h" |
| r2724 | r2725 | |
| 85 | 84 | static void exit_handler(running_machine *machine); |
| 86 | 85 | |
| 87 | 86 | static void zeus_pointer_w(UINT32 which, UINT32 data, int logit); |
| 88 | static void zeus_register16_w(offs_t offset, UINT16 data, int logit); | |
| 89 | static void zeus_register32_w(offs_t offset, UINT32 data, int logit); | |
| 90 | static void zeus_register_update(offs_t offset); | |
| 91 | static int zeus_fifo_process(const UINT32 *data, int numwords); | |
| 92 | static void zeus_draw_model(UINT32 texdata, int logit); | |
| 87 | static void zeus_register16_w(running_machine *machine, offs_t offset, UINT16 data, int logit); | |
| 88 | static void zeus_register32_w(running_machine *machine, offs_t offset, UINT32 data, int logit); | |
| 89 | static void zeus_register_update(running_machine *machine, offs_t offset); | |
| 90 | static int zeus_fifo_process(running_machine *machine, const UINT32 *data, int numwords); | |
| 91 | static void zeus_draw_model(running_machine *machine, UINT32 texdata, int logit); | |
| 93 | 92 | static void zeus_draw_quad(const UINT32 *databuffer, UINT32 texdata, int logit); |
| 94 | 93 | |
| 95 | 94 | static void render_poly_4bit(void *dest, INT32 scanline, const poly_extent *extent, const void *extradata, int threadid); |
| r2724 | r2725 | |
| 444 | 443 | |
| 445 | 444 | /* 32-bit mode */ |
| 446 | 445 | if (zeusbase[0x80] & 0x00020000) |
| 447 | zeus_register32_w(offset, data, logit); | |
| 446 | zeus_register32_w(machine, offset, data, logit); | |
| 448 | 447 | |
| 449 | 448 | /* 16-bit mode */ |
| 450 | 449 | else |
| 451 | zeus_register16_w(offset, data, logit); | |
| 450 | zeus_register16_w(machine, offset, data, logit); | |
| 452 | 451 | } |
| 453 | 452 | |
| 454 | 453 | |
| r2724 | r2725 | |
| 522 | 521 | * |
| 523 | 522 | *************************************/ |
| 524 | 523 | |
| 525 | static void zeus_register16_w(offs_t offset, UINT16 data, int logit) | |
| 524 | static void zeus_register16_w(running_machine *machine, offs_t offset, UINT16 data, int logit) | |
| 526 | 525 | { |
| 527 | 526 | /* writes to register $CC need to force a partial update */ |
| 528 | 527 | if ((offset & ~1) == 0xcc) |
| 529 | video_screen_update_partial( | |
| 528 | video_screen_update_partial(machine->primary_screen, video_screen_get_vpos(machine->primary_screen)); | |
| 530 | 529 | |
| 531 | 530 | /* write to high part on odd addresses */ |
| 532 | 531 | if (offset & 1) |
| r2724 | r2725 | |
| 542 | 541 | |
| 543 | 542 | /* handle the update */ |
| 544 | 543 | if ((offset & 1) == 0) |
| 545 | zeus_register_update(offset); | |
| 544 | zeus_register_update(machine, offset); | |
| 546 | 545 | } |
| 547 | 546 | |
| 548 | 547 | |
| 549 | static void zeus_register32_w(offs_t offset, UINT32 data, int logit) | |
| 548 | static void zeus_register32_w(running_machine *machine, offs_t offset, UINT32 data, int logit) | |
| 550 | 549 | { |
| 551 | 550 | /* writes to register $CC need to force a partial update */ |
| 552 | 551 | if ((offset & ~1) == 0xcc) |
| 553 | video_screen_update_partial( | |
| 552 | video_screen_update_partial(machine->primary_screen, video_screen_get_vpos(machine->primary_screen)); | |
| 554 | 553 | |
| 555 | 554 | /* always write to low word? */ |
| 556 | 555 | zeusbase[offset & ~1] = data; |
| r2724 | r2725 | |
| 568 | 567 | |
| 569 | 568 | /* handle the update */ |
| 570 | 569 | if ((offset & 1) == 0) |
| 571 | zeus_register_update(offset); | |
| 570 | zeus_register_update(machine, offset); | |
| 572 | 571 | } |
| 573 | 572 | |
| 574 | 573 | |
| r2724 | r2725 | |
| 579 | 578 | * |
| 580 | 579 | *************************************/ |
| 581 | 580 | |
| 582 | static void zeus_register_update(offs_t offset) | |
| 581 | static void zeus_register_update(running_machine *machine, offs_t offset) | |
| 583 | 582 | { |
| 584 | 583 | /* handle the writes; only trigger on low accesses */ |
| 585 | 584 | switch (offset) |
| r2724 | r2725 | |
| 656 | 655 | we simply assert immediately if this is enabled. invasn needs this for proper |
| 657 | 656 | operations */ |
| 658 | 657 | if (zeusbase[0x80] & 0x02000000) |
| 659 | cpunum_set_input_line( | |
| 658 | cpunum_set_input_line(machine, 0, 2, ASSERT_LINE); | |
| 660 | 659 | else |
| 661 | cpunum_set_input_line( | |
| 660 | cpunum_set_input_line(machine, 0, 2, CLEAR_LINE); | |
| 662 | 661 | break; |
| 663 | 662 | |
| 664 | 663 | case 0x84: |
| r2724 | r2725 | |
| 717 | 716 | case 0xc6: |
| 718 | 717 | case 0xc8: |
| 719 | 718 | case 0xca: |
| 720 | video_screen_update_partial( | |
| 719 | video_screen_update_partial(machine->primary_screen, video_screen_get_vpos(machine->primary_screen)); | |
| 721 | 720 | { |
| 722 | 721 | int vtotal = zeusbase[0xca] >> 16; |
| 723 | 722 | int htotal = zeusbase[0xc6] >> 16; |
| r2724 | r2725 | |
| 729 | 728 | visarea.max_y = zeusbase[0xc8] & 0xffff; |
| 730 | 729 | if (htotal > 0 && vtotal > 0 && visarea.min_x < visarea.max_x && visarea.max_y < vtotal) |
| 731 | 730 | { |
| 732 | video_screen_configure( | |
| 731 | video_screen_configure(machine->primary_screen, htotal, vtotal, &visarea, HZ_TO_ATTOSECONDS((double)MIDZEUS_VIDEO_CLOCK / 8.0 / (htotal * vtotal))); | |
| 733 | 732 | zeus_cliprect = visarea; |
| 734 | 733 | zeus_cliprect.max_x -= zeus_cliprect.min_x; |
| 735 | 734 | zeus_cliprect.min_x = 0; |
| r2724 | r2725 | |
| 738 | 737 | break; |
| 739 | 738 | |
| 740 | 739 | case 0xcc: |
| 741 | video_screen_update_partial( | |
| 740 | video_screen_update_partial(machine->primary_screen, video_screen_get_vpos(machine->primary_screen)); | |
| 742 | 741 | log_fifo = input_code_pressed(KEYCODE_L); |
| 743 | 742 | break; |
| 744 | 743 | |
| 745 | 744 | case 0xe0: |
| 746 | 745 | zeus_fifo[zeus_fifo_words++] = zeusbase[0xe0]; |
| 747 | if (zeus_fifo_process(zeus_fifo, zeus_fifo_words)) | |
| 746 | if (zeus_fifo_process(machine, zeus_fifo, zeus_fifo_words)) | |
| 748 | 747 | zeus_fifo_words = 0; |
| 749 | 748 | break; |
| 750 | 749 | } |
| r2724 | r2725 | |
| 758 | 757 | * |
| 759 | 758 | *************************************/ |
| 760 | 759 | |
| 761 | static int zeus_fifo_process(const UINT32 *data, int numwords) | |
| 760 | static int zeus_fifo_process(running_machine *machine, const UINT32 *data, int numwords) | |
| 762 | 761 | { |
| 763 | 762 | /* handle logging */ |
| 764 | 763 | switch (data[0] >> 24) |
| r2724 | r2725 | |
| 778 | 777 | case 0x13: /* invasn */ |
| 779 | 778 | if (log_fifo) |
| 780 | 779 | log_fifo_command(data, numwords, ""); |
| 781 | zeus_draw_model((zeusbase[0x06] << 16), log_fifo); | |
| 780 | zeus_draw_model(machine, (zeusbase[0x06] << 16), log_fifo); | |
| 782 | 781 | break; |
| 783 | 782 | |
| 784 | 783 | /* 0x17: write 16-bit value to low registers */ |
| 785 | 784 | case 0x17: |
| 786 | 785 | if (log_fifo) |
| 787 | 786 | log_fifo_command(data, numwords, " -- reg16"); |
| 788 | zeus_register16_w((data[0] >> 16) & 0x7f, data[0], log_fifo); | |
| 787 | zeus_register16_w(machine, (data[0] >> 16) & 0x7f, data[0], log_fifo); | |
| 789 | 788 | break; |
| 790 | 789 | |
| 791 | 790 | /* 0x18: write 32-bit value to low registers */ |
| r2724 | r2725 | |
| 795 | 794 | return FALSE; |
| 796 | 795 | if (log_fifo) |
| 797 | 796 | log_fifo_command(data, numwords, " -- reg32"); |
| 798 | zeus_register32_w((data[0] >> 16) & 0x7f, data[1], log_fifo); | |
| 797 | zeus_register32_w(machine, (data[0] >> 16) & 0x7f, data[1], log_fifo); | |
| 799 | 798 | break; |
| 800 | 799 | |
| 801 | 800 | /* 0x1A: sync pipeline(?) */ |
| r2724 | r2725 | |
| 939 | 938 | if (log_fifo) |
| 940 | 939 | log_fifo_command(data, numwords, ""); |
| 941 | 940 | zeus_objdata = data[1]; |
| 942 | zeus_draw_model(data[2], log_fifo); | |
| 941 | zeus_draw_model(machine, data[2], log_fifo); | |
| 943 | 942 | break; |
| 944 | 943 | |
| 945 | 944 | default: |
| r2724 | r2725 | |
| 959 | 958 | * |
| 960 | 959 | *************************************/ |
| 961 | 960 | |
| 962 | static void zeus_draw_model(UINT32 texdata, int logit) | |
| 961 | static void zeus_draw_model(running_machine *machine, UINT32 texdata, int logit) | |
| 963 | 962 | { |
| 964 | 963 | UINT32 databuffer[32]; |
| 965 | 964 | int databufcount = 0; |
| r2724 | r2725 | |
| 1018 | 1017 | case 0x17: /* mk4 */ |
| 1019 | 1018 | if (logit) |
| 1020 | 1019 | logerror("reg16"); |
| 1021 | zeus_register16_w((databuffer[0] >> 16) & 0x7f, databuffer[0], logit); | |
| 1020 | zeus_register16_w(machine, (databuffer[0] >> 16) & 0x7f, databuffer[0], logit); | |
| 1022 | 1021 | if (((databuffer[0] >> 16) & 0x7f) == 0x06) |
| 1023 | 1022 | texdata = (texdata & 0xffff) | (zeusbase[0x06] << 16); |
| 1024 | 1023 | break; |
| r2724 | r2725 | |
| 1026 | 1025 | case 0x19: /* invasn */ |
| 1027 | 1026 | if (logit) |
| 1028 | 1027 | logerror("reg32"); |
| 1029 | zeus_register32_w((databuffer[0] >> 16) & 0x7f, databuffer[1], logit); | |
| 1028 | zeus_register32_w(machine, (databuffer[0] >> 16) & 0x7f, databuffer[1], logit); | |
| 1030 | 1029 | if (((databuffer[0] >> 16) & 0x7f) == 0x06) |
| 1031 | 1030 | texdata = (texdata & 0xffff) | (zeusbase[0x06] << 16); |
| 1032 | 1031 | break; |
| r2724 | r2725 | |
|---|---|---|
| 16 | 16 | UINT16 *namcona1_scroll; |
| 17 | 17 | UINT16 *namcona1_workram; |
| 18 | 18 | UINT16 *namcona1_sparevram; |
| 19 | UINT16 *namcona1_rozvideoram; | |
| 20 | 19 | UINT16 *namcona1_pixmap; |
| 21 | 20 | |
| 22 | 21 | /* private variables */ |
| r2724 | r2725 | |
| 92 | 91 | { |
| 93 | 92 | /* each logical tile is constructed from 4*4 normal tiles */ |
| 94 | 93 | int tilemap_color = roz_palette; |
| 95 | int use_4bpp_gfx = namcona1_vreg[0xbc/2]&16; | |
| 94 | int use_4bpp_gfx = namcona1_vreg[0xbc/2]&16; /* ? */ | |
| 96 | 95 | int c = tile_index%0x40; |
| 97 | 96 | int r = tile_index/0x40; |
| 98 | int data = namcona1_rozvideoram[(r/4)*0x40+c/4]+(c%4)+(r%4)*0x40; | |
| 99 | int tile = data&0xfff; | |
| 97 | int data = videoram16[0x8000/2+(r/4)*0x40+c/4]&0xfbf; /* mask out bit 0x40 - patch for Emeraldia Japan */ | |
| 98 | int tile = (data+(c%4)+(r%4)*0x40)&0xfff; | |
| 100 | 99 | int gfx = use_4bpp_gfx; |
| 101 | 100 | if( use_4bpp_gfx ) |
| 102 | 101 | { |
| r2724 | r2725 | |
| 129 | 128 | } |
| 130 | 129 | } /* roz_get_info */ |
| 131 | 130 | |
| 132 | WRITE16_HANDLER( namcona1_rozvideoram_w ) | |
| 133 | { | |
| 134 | COMBINE_DATA( &namcona1_rozvideoram[offset] ); | |
| 135 | roz_dirty = 1; | |
| 136 | } | |
| 137 | READ16_HANDLER( namcona1_rozvideoram_r ) | |
| 138 | { | |
| 139 | return namcona1_rozvideoram[offset]; | |
| 140 | } | |
| 141 | ||
| 142 | 131 | /*************************************************************************/ |
| 143 | 132 | |
| 144 | 133 | WRITE16_HANDLER( namcona1_videoram_w ) |
| 145 | 134 | { |
| 146 | 135 | COMBINE_DATA( &videoram16[offset] ); |
| 147 | tilemap_mark_tile_dirty( bg_tilemap[offset/0x1000], offset&0xfff ); | |
| 136 | if( offset<0x8000/2 ) | |
| 137 | { | |
| 138 | tilemap_mark_tile_dirty( bg_tilemap[offset/0x1000], offset&0xfff ); | |
| 139 | } | |
| 140 | else if( offset<0xa000/2 ) | |
| 141 | { | |
| 142 | roz_dirty = 1; | |
| 143 | } | |
| 148 | 144 | } /* namcona1_videoram_w */ |
| 149 | 145 | |
| 150 | 146 | READ16_HANDLER( namcona1_videoram_r ) |
| r2724 | r2725 | |
| 157 | 153 | static void |
| 158 | 154 | UpdatePalette(running_machine *machine, int offset ) |
| 159 | 155 | { |
| 160 | UINT16 color = paletteram16[offset]; /* -RRRRRGGGGGBBBBB */ | |
| 161 | palette_set_color_rgb( machine, offset, pal5bit(color >> 10), pal5bit(color >> 5), pal5bit(color >> 0)); | |
| 156 | UINT16 data = paletteram16[offset]; /* -RRRRRGG GGGBBBBB */ | |
| 157 | /** | |
| 158 | * sprites can be configured to use an alternate interpretation of palette ram | |
| 159 | * (used in-game in Emeraldia) | |
| 160 | * | |
| 161 | * RRRGGGBB RRRGGGBB | |
| 162 | */ | |
| 163 | int r = (((data&0x00e0)>>5)+((data&0xe000)>>13)*2)*0xff/(0x7*3); | |
| 164 | int g = (((data&0x001c)>>2)+((data&0x1c00)>>10)*2)*0xff/(0x7*3); | |
| 165 | int b = (((data&0x0003)>>0)+((data&0x0300)>>8)*2)*0xff/(0x3*3); | |
| 166 | palette_set_color_rgb( machine, offset+0x1000, r, g, b); | |
| 167 | ||
| 168 | palette_set_color_rgb( machine, offset, pal5bit(data >> 10), pal5bit(data >> 5), pal5bit(data >> 0)); | |
| 162 | 169 | } /* namcona1_paletteram_w */ |
| 163 | 170 | |
| 164 | 171 | READ16_HANDLER( namcona1_paletteram_r ) |
| r2724 | r2725 | |
| 170 | 177 | { |
| 171 | 178 | COMBINE_DATA( &paletteram16[offset] ); |
| 172 | 179 | if( namcona1_vreg[0x8e/2] ) |
| 173 | { | |
| 174 | /* graphics enabled; update palette immediately */ | |
| 180 | { /* graphics enabled; update palette immediately */ | |
| 175 | 181 | UpdatePalette(machine, offset ); |
| 176 | 182 | } |
| 177 | 183 | else |
| r2724 | r2725 | |
| 293 | 299 | } |
| 294 | 300 | } |
| 295 | 301 | |
| 296 | pSource = namcona1_rozvideoram; | |
| 297 | for( i=0; i<0x800; i++ ) | |
| 302 | for( i=0; i<0x1000; i++ ) | |
| 298 | 303 | { |
| 299 | 304 | if( dirtychar[*pSource++ & 0xfff] ) |
| 300 | 305 | { |
| r2724 | r2725 | |
| 303 | 308 | } |
| 304 | 309 | } |
| 305 | 310 | |
| 306 | for( i = 0;i < | |
| 311 | for( i = 0;i < | |
| 307 | 312 | { |
| 308 | 313 | if( dirtychar[i] ) |
| 309 | 314 | { |
| r2724 | r2725 | |
| 333 | 338 | } |
| 334 | 339 | |
| 335 | 340 | shaperam = auto_malloc( 0x2000*4 ); |
| 336 | cgram = auto_malloc( 0x1000*0x | |
| 341 | cgram = auto_malloc( 0x1000*0x40 | |
| 337 | 342 | dirtychar = auto_malloc( 0x1000 ); |
| 338 | namcona1_rozvideoram = auto_malloc( 0x4000 ); | |
| 339 | 343 | |
| 340 | 344 | gfx0 = allocgfx( &cg_layout_8bpp ); |
| 341 | 345 | gfx0->total_colors = machine->config->total_colors/256; |
| r2724 | r2725 | |
| 476 | 480 | dest[x] = palette_shadow_table[dest[x]]; |
| 477 | 481 | } |
| 478 | 482 | else |
| 479 | { // bad? | |
| 480 | dest[x] = pal_base+c; | |
| 483 | { | |
| 484 | dest[x] = pal_base + c + 0x1000; | |
| 481 | 485 | } |
| 482 | 486 | } |
| 483 | 487 | else |
| r2724 | r2725 | |
| 584 | 588 | static void draw_pixel_line( UINT16 *pDest, UINT8 *pPri, UINT16 *pSource, const pen_t *paldata ) |
| 585 | 589 | { |
| 586 | 590 | int x; |
| 587 | UINT16 data; | |
| 588 | ||
| 589 | 591 | for( x=0; x<38*8; x+=2 ) |
| 590 | 592 | { |
| 591 | pPri[x / 2] = 0xff; | |
| 592 | data = *pSource++; | |
| 593 | pDest[x] = paldata[data>>8]; | |
| 593 | UINT16 data = *pSource++; | |
| 594 | pPri[x+0] = 0xff; | |
| 595 | pPri[x+1] = 0xff; | |
| 596 | pDest[x+0] = paldata[data>>8]; | |
| 594 | 597 | pDest[x+1] = paldata[data&0xff]; |
| 595 | 598 | } /* next x */ |
| 596 | 599 | } /* draw_pixel_line */ |
| r2724 | r2725 | |
| 647 | 650 | draw_pixel_line( |
| 648 | 651 | BITMAP_ADDR16(bitmap, line, 0), |
| 649 | 652 | BITMAP_ADDR8(priority_bitmap, line, 0), |
| 650 | | |
| 653 | | |
| 651 | 654 | paldata ); |
| 652 | 655 | } |
| 653 | 656 | else |
| 654 | 657 | { |
| 655 | // used in emeraldia | |
| 656 | if(which == NAMCONA1_NUM_TILEMAPS )// && namcona1_vreg[0x8a/2] == 0xfd /* maybe reg & 0x4 */) | |
| 658 | if(which == NAMCONA1_NUM_TILEMAPS ) | |
| 657 | 659 | { |
| 658 | int incxx = ((INT16)namcona1_vreg[0xc0/2])<<8; | |
| 660 | int incxx = ((INT16)namcona1_vreg[0xc0/2])<<8; | |
| 659 | 661 | int incxy = ((INT16)namcona1_vreg[0xc2/2])<<8; |
| 660 | 662 | int incyx = ((INT16)namcona1_vreg[0xc4/2])<<8; |
| 661 | int incyy = ((INT16)namcona1_vreg[0xc6/2])<<8; | |
| 663 | int incyy = ((INT16)namcona1_vreg[0xc6/2])<<8; | |
| 662 | 664 | INT16 xoffset = namcona1_vreg[0xc8/2]; |
| 663 | 665 | INT16 yoffset = namcona1_vreg[0xca/2]; |
| 664 | int dx = 46; | |
| 665 | int dy = -8; | |
| 666 | ||
| 667 | // now, apply adjustments to startx, starty to translate the | |
| 668 | // ROZ plane. Note that these are corrected by the inc parameters | |
| 669 | // to account for scale/rotate state. | |
| 666 | int dx = 46; /* horizontal adjust */ | |
| 667 | int dy = -8; /* vertical adjust */ | |
| 670 | 668 | UINT32 startx = (xoffset<<12)+incxx*dx+incyx*dy; |
| 671 | 669 | UINT32 starty = (yoffset<<12)+incxy*dx+incyy*dy; |
| 672 | ||
| 673 | 670 | tilemap_draw_roz_primask(bitmap, &clip, roz_tilemap, |
| 674 | startx, starty, incxx, incxy, incyx, incyy, | |
| 675 | 0, 0, primask, 0); | |
| 671 | startx, starty, incxx, incxy, incyx, incyy, 0, 0, primask, 0); | |
| 676 | 672 | } |
| 677 | 673 | else |
| 678 | 674 | { |
| r2724 | r2725 | |
| 737 | 733 | { |
| 738 | 734 | for( which=4; which>=0; which-- ) |
| 739 | 735 | { |
| 740 | int pri = namcona1_vreg[0xa0/2+which]&0x7; /* likely wrong for roz plane */ | |
| 736 | int pri; | |
| 737 | if( which==4 ) | |
| 738 | { | |
| 739 | pri = namcona1_vreg[0xa0/2+5]&0x7; | |
| 740 | } | |
| 741 | else | |
| 742 | { | |
| 743 | pri = namcona1_vreg[0xa0/2+which]&0x7; | |
| 744 | } | |
| 741 | 745 | if( pri == priority ) |
| 742 | 746 | { |
| 743 | 747 | draw_background(screen->machine,bitmap,cliprect,which,priority); |
| r2724 | r2725 | |
| 751 | 755 | } |
| 752 | 756 | |
| 753 | 757 | /* |
| 758 | roz bad in emeraldaj - blit param? | |
| 759 | ||
| 754 | 760 | $efff20: sprite control: 0x3a,0x3e,0x3f |
| 755 | 761 | bit 0x01 selects spriteram bank |
| 756 | 762 | |
| r2724 | r2725 | |
| 758 | 764 | $efff00: src0 src1 src2 dst0 dst1 dst2 BANK [src |
| 759 | 765 | $efff10: src] [dst dst] #BYT BLIT eINT 001f 0001 |
| 760 | 766 | $efff20: 003f 003f IACK ---- ---- ---- ---- ---- |
| 761 | $efff80: 0050 0170 0020 0100 0000 POSI 0000 GFXE POSI: scanline for POSIRQ | |
| 767 | ... | |
| 768 | $efff80: 0050 0170 0020 0100 0170 POS? 0000 GFXE | |
| 762 | 769 | $efff90: 0000 0001 0002 0003 FLIP ---- ---- ---- |
| 763 | $efffa0: PRI PRI PRI PRI ---- PRI? --?? ---- priority (0..7) | |
| 764 | $efffb0: CLR CLR CLR CLR 0001 CLR? BPP ---- color (0..f), bpp flag per layer | |
| 765 | $efffc0: RZXX RZXY RZYX RZYY RZX0 RZY0 ???? ---- ROZ | |
| 770 | $efffa0: PRI PRI PRI PRI ???? PRI 00c0 ---- priority (0..7) | |
| 771 | $efffb0: CLR CLR CLR CLR 0001 CLR BPP ---- color (0..f), bpp flag per layer | |
| 772 | $efffc0: RZXX RZXY RZYX RZYY RZX0 RZY0 0044 ---- ROZ | |
| 773 | ||
| 774 | ||
| 775 | Emeralda: 0048 0177 0020 0100 0000 00f0 0000 0001 in-game | |
| 776 | 0050 0170 0020 0100 0000 00f0 0000 0001 self test | |
| 777 | ||
| 778 | NumanAth: 0050 0170 0020 0100 0170 00d8 0000 0001 in-game | |
| 779 | ||
| 780 | ||
| 766 | 781 | */ |
| 767 |
| r2724 | r2725 | |
|---|---|---|
| 834 | 834 | static void check_palette(running_machine *machine) |
| 835 | 835 | { |
| 836 | 836 | dkong_state *state = machine->driver_data; |
| 837 | const input_port_config *port; | |
| 837 | 838 | int newset; |
| 838 | int num; | |
| 839 | 839 | |
| 840 | num = port_tag_to_index("VIDHW"); | |
| 841 | if (num>=0) | |
| 840 | port = input_port_by_tag(machine->portconfig, "VIDHW"); | |
| 841 | if (port != NULL) | |
| 842 | 842 | { |
| 843 | newset = input_port_read_ | |
| 843 | newset = input_port_read_ | |
| 844 | 844 | if (newset != state->vidhw) |
| 845 | 845 | { |
| 846 | 846 | state->vidhw = newset; |
| r2724 | r2725 | |
|---|---|---|
| 624 | 624 | int n_level2; |
| 625 | 625 | int n_shade; |
| 626 | 626 | int n_shaded; |
| 627 | int width = video_screen_get_width(Machine->primary_screen); | |
| 628 | int height = video_screen_get_height(Machine->primary_screen); | |
| 627 | int width = video_screen_get_width(machine->primary_screen); | |
| 628 | int height = video_screen_get_height(machine->primary_screen); | |
| 629 | 629 | |
| 630 | 630 | #if defined( MAME_DEBUG ) |
| 631 | 631 | DebugMeshInit(); |
| r2724 | r2725 | |
| 3902 | 3902 | #endif |
| 3903 | 3903 | |
| 3904 | 3904 | m_n_gpustatus ^= ( 1L << 31 ); |
| 3905 | psx_irq_set( 0x0001 ); | |
| 3905 | psx_irq_set( machine, 0x0001 ); | |
| 3906 | 3906 | } |
| 3907 | 3907 | |
| 3908 | 3908 | void psx_gpu_reset( void ) |
| r2724 | r2725 | |
|---|---|---|
| 114 | 114 | |
| 115 | 115 | CUSTOM_INPUT( stactics_get_frame_count_d3 ) |
| 116 | 116 | { |
| 117 | stactics_state *state = machine->driver_data; | |
| 117 | stactics_state *state = field->port->machine->driver_data; | |
| 118 | 118 | |
| 119 | 119 | return (state->frame_count >> 3) & 0x01; |
| 120 | 120 | } |
| r2724 | r2725 | |
| 172 | 172 | |
| 173 | 173 | CUSTOM_INPUT( stactics_get_shot_standby ) |
| 174 | 174 | { |
| 175 | stactics_state *state = machine->driver_data; | |
| 175 | stactics_state *state = field->port->machine->driver_data; | |
| 176 | 176 | |
| 177 | 177 | return state->shot_standby; |
| 178 | 178 | } |
| r2724 | r2725 | |
| 180 | 180 | |
| 181 | 181 | CUSTOM_INPUT( stactics_get_not_shot_arrive ) |
| 182 | 182 | { |
| 183 | stactics_state *state = machine->driver_data; | |
| 183 | stactics_state *state = field->port->machine->driver_data; | |
| 184 | 184 | |
| 185 | 185 | return !state->shot_arrive; |
| 186 | 186 | } |
| r2724 | r2725 | |
|---|---|---|
| 900 | 900 | * |
| 901 | 901 | *************************************/ |
| 902 | 902 | |
| 903 | static void process_object_list(int vc, UINT16 *_scanline) | |
| 903 | static void process_object_list(running_machine *machine, int vc, UINT16 *_scanline) | |
| 904 | 904 | { |
| 905 | 905 | int done = 0, count = 0; |
| 906 | 906 | UINT32 *objdata; |
| r2724 | r2725 | |
| 960 | 960 | fprintf(stderr, "stop int=%d\n", interrupt); |
| 961 | 961 | #endif |
| 962 | 962 | cpu_irq_state |= 4; |
| 963 | update_cpu_irq(); | |
| 963 | update_cpu_irq(machine); | |
| 964 | 964 | } |
| 965 | 965 | break; |
| 966 | 966 | } |
| r2724 | r2725 | |
|---|---|---|
| 62 | 62 | if (taitojc_dirty_map[i]) |
| 63 | 63 | { |
| 64 | 64 | taitojc_dirty_map[i] = 0; |
| 65 | decodechar( | |
| 65 | decodechar(machine->gfx[taitojc_gfx_index], i, (UINT8 *)taitojc_char_ram); | |
| 66 | 66 | } |
| 67 | 67 | } |
| 68 | 68 | tilemap_mark_all_tiles_dirty(taitojc_tilemap); |
| r2724 | r2725 | |
|---|---|---|
| 214 | 214 | } |
| 215 | 215 | |
| 216 | 216 | |
| 217 | static void via_irq(int state) | |
| 217 | static void via_irq(running_machine *machine, int state) | |
| 218 | 218 | { |
| 219 | 219 | /* Kaos sits in a tight loop polling the VIA irq flags register, but that register is |
| 220 | 220 | cleared by the irq handler. Therefore, I wait a bit before triggering the irq to |
| r2724 | r2725 | |
|---|---|---|
| 4 | 4 | ************************************/ |
| 5 | 5 | |
| 6 | 6 | #include "driver.h" |
| 7 | #include "deprecat.h" | |
| 8 | 7 | #include "st0016.h" |
| 9 | 8 | |
| 10 | 9 | UINT8 *st0016_charram,*st0016_spriteram,*st0016_paletteram; |
| r2724 | r2725 | |
| 144 | 143 | { |
| 145 | 144 | case 0: |
| 146 | 145 | case 1: |
| 147 | return mame_rand( | |
| 146 | return mame_rand(machine); | |
| 148 | 147 | } |
| 149 | 148 | |
| 150 | 149 | return st0016_vregs[offset]; |
| r2724 | r2725 | |
|---|---|---|
| 5 | 5 | **************************************************************************/ |
| 6 | 6 | |
| 7 | 7 | #include "driver.h" |
| 8 | #include "deprecat.h" | |
| 9 | 8 | #include "cpu/tms34010/tms34010.h" |
| 10 | 9 | #include "cpu/adsp2100/adsp2100.h" |
| 11 | 10 | #include "audio/williams.h" |
| r2724 | r2725 | |
| 399 | 398 | { |
| 400 | 399 | if (LOG_DMA && input_code_pressed(KEYCODE_L)) |
| 401 | 400 | logerror("%06X:trigger\n", activecpu_get_pc()); |
| 402 | process_dma_queue( | |
| 401 | process_dma_queue(machine); | |
| 403 | 402 | dma_data_index = 0; |
| 404 | 403 | } |
| 405 | 404 | return 0; |
| r2724 | r2725 | |
|---|---|---|
| 9 | 9 | ***************************************************************************/ |
| 10 | 10 | |
| 11 | 11 | #include "driver.h" |
| 12 | #include "deprecat.h" | |
| 13 | 12 | #include "cpu/m6502/m6502.h" |
| 14 | 13 | #include "includes/atari.h" |
| 15 | 14 | #include "video/gtia.h" |
| r2724 | r2725 | |
| 69 | 68 | memset(>ia, 0, sizeof(gtia)); |
| 70 | 69 | gtia.intf = *intf; |
| 71 | 70 | |
| 72 | add_reset_callback( | |
| 71 | add_reset_callback(machine, gtia_reset); | |
| 73 | 72 | |
| 74 | 73 | /* state saves */ |
| 75 | 74 | gtia_state(machine); |
| r2724 | r2725 | |
|---|---|---|
| 211 | 211 | |
| 212 | 212 | /* from jagobj.c */ |
| 213 | 213 | static void jagobj_init(void); |
| 214 | static void process_object_list(int vc, UINT16 *_scanline); | |
| 214 | static void process_object_list(running_machine *machine, int vc, UINT16 *_scanline); | |
| 215 | 215 | |
| 216 | 216 | /* from jagblit.c */ |
| 217 | 217 | static void generic_blitter(UINT32 command, UINT32 a1flags, UINT32 a2flags); |
| r2724 | r2725 | |
| 325 | 325 | * |
| 326 | 326 | *************************************/ |
| 327 | 327 | |
| 328 | static void update_cpu_irq( | |
| 328 | static void update_cpu_irq(running_machine *machine) | |
| 329 | 329 | { |
| 330 | 330 | if (cpu_irq_state & gpu_regs[INT1] & 0x1f) |
| 331 | cpunum_set_input_line( | |
| 331 | cpunum_set_input_line(machine, 0, cojag_is_r3000 ? R3000_IRQ4 : MC68000_IRQ_6, ASSERT_LINE); | |
| 332 | 332 | else |
| 333 | cpunum_set_input_line( | |
| 333 | cpunum_set_input_line(machine, 0, cojag_is_r3000 ? R3000_IRQ4 : MC68000_IRQ_6, CLEAR_LINE); | |
| 334 | 334 | } |
| 335 | 335 | |
| 336 | 336 | |
| 337 | 337 | void jaguar_gpu_cpu_int(void) |
| 338 | 338 | { |
| 339 | 339 | cpu_irq_state |= 2; |
| 340 | update_cpu_irq(); | |
| 340 | update_cpu_irq(Machine); | |
| 341 | 341 | } |
| 342 | 342 | |
| 343 | 343 | |
| 344 | 344 | void jaguar_dsp_cpu_int(void) |
| 345 | 345 | { |
| 346 | 346 | cpu_irq_state |= 16; |
| 347 | update_cpu_irq(); | |
| 347 | update_cpu_irq(Machine); | |
| 348 | 348 | } |
| 349 | 349 | |
| 350 | 350 | |
| r2724 | r2725 | |
| 654 | 654 | { |
| 655 | 655 | case INT1: |
| 656 | 656 | cpu_irq_state &= ~(gpu_regs[INT1] >> 8); |
| 657 | update_cpu_irq(); | |
| 657 | update_cpu_irq(machine); | |
| 658 | 658 | break; |
| 659 | 659 | |
| 660 | 660 | case VMODE: |
| r2724 | r2725 | |
| 778 | 778 | } |
| 779 | 779 | |
| 780 | 780 | /* process the object list for this counter value */ |
| 781 | process_object_list(vc, scanline); | |
| 781 | process_object_list(machine, vc, scanline); | |
| 782 | 782 | |
| 783 | 783 | /* copy the data to the target, clipping */ |
| 784 | 784 | for (x = 0; x < 360 && hdb <= maxx && hdb < hde; x++, hdb++) |
| r2724 | r2725 | |
| 792 | 792 | if (vc == gpu_regs[VI]) |
| 793 | 793 | { |
| 794 | 794 | cpu_irq_state |= 1; |
| 795 | update_cpu_irq(); | |
| 795 | update_cpu_irq(machine); | |
| 796 | 796 | } |
| 797 | 797 | |
| 798 | 798 | /* point to the next counter value */ |
| r2724 | r2725 | |
| 804 | 804 | |
| 805 | 805 | static STATE_POSTLOAD( cojag_postload ) |
| 806 | 806 | { |
| 807 | update_cpu_irq(); | |
| 807 | update_cpu_irq(machine); | |
| 808 | 808 | } |
| 809 | 809 | |
| 810 | 810 | VIDEO_START( cojag ) |
| r2724 | r2725 | |
|---|---|---|
| 101 | 101 | * |
| 102 | 102 | *************************************/ |
| 103 | 103 | |
| 104 | static void victory_update_irq( | |
| 104 | static void victory_update_irq(running_machine *machine) | |
| 105 | 105 | { |
| 106 | 106 | if (vblank_irq || fgcoll || (bgcoll && (video_control & 0x20))) |
| 107 | cpunum_set_input_line( | |
| 107 | cpunum_set_input_line(machine, 0, 0, ASSERT_LINE); | |
| 108 | 108 | else |
| 109 | cpunum_set_input_line( | |
| 109 | cpunum_set_input_line(machine, 0, 0, CLEAR_LINE); | |
| 110 | 110 | } |
| 111 | 111 | |
| 112 | 112 | |
| r2724 | r2725 | |
| 114 | 114 | { |
| 115 | 115 | vblank_irq = 1; |
| 116 | 116 | |
| 117 | victory_update_irq(); | |
| 117 | victory_update_irq(machine); | |
| 118 | 118 | } |
| 119 | 119 | |
| 120 | 120 | |
| r2724 | r2725 | |
| 167 | 167 | if (fgcoll) |
| 168 | 168 | { |
| 169 | 169 | fgcoll = 0; |
| 170 | victory_update_irq(); | |
| 170 | victory_update_irq(machine); | |
| 171 | 171 | } |
| 172 | 172 | if (LOG_COLLISION) logerror("%04X:5CLFIQ read = %02X\n", activecpu_get_previouspc(), result); |
| 173 | 173 | return result; |
| r2724 | r2725 | |
| 182 | 182 | if (bgcoll) |
| 183 | 183 | { |
| 184 | 184 | bgcoll = 0; |
| 185 | victory_update_irq(); | |
| 185 | victory_update_irq(machine); | |
| 186 | 186 | } |
| 187 | 187 | if (LOG_COLLISION) logerror("%04X:5BACKY read = %02X\n", activecpu_get_previouspc(), result); |
| 188 | 188 | return result; |
| r2724 | r2725 | |
| 321 | 321 | case 0x0b: /* CLRVIRQ */ |
| 322 | 322 | if (LOG_MICROCODE) logerror("%04X:CLRVIRQ write = %02X\n", activecpu_get_previouspc(), data); |
| 323 | 323 | vblank_irq = 0; |
| 324 | victory_update_irq(); | |
| 324 | victory_update_irq(machine); | |
| 325 | 325 | break; |
| 326 | 326 | |
| 327 | 327 | default: |
| r2724 | r2725 | |
| 674 | 674 | rram[dstoffs + 0] ^= src >> shift; |
| 675 | 675 | rram[dstoffs + 1] ^= src << nshift; |
| 676 | 676 | } |
| 677 | if (fgcoll) victory_update_irq(); | |
| 677 | if (fgcoll) victory_update_irq(Machine); | |
| 678 | 678 | } |
| 679 | 679 | } |
| 680 | 680 | } |
| r2724 | r2725 | |
| 874 | 874 | } |
| 875 | 875 | acc &= 0xff; |
| 876 | 876 | } |
| 877 | if (fgcoll) victory_update_irq(); | |
| 877 | if (fgcoll) victory_update_irq(Machine); | |
| 878 | 878 | } |
| 879 | 879 | |
| 880 | 880 | micro.xp = x; |
| r2724 | r2725 | |
| 1004 | 1004 | rram[addr + 0] ^= micro.r >> shift; |
| 1005 | 1005 | rram[addr + 1] ^= micro.r << nshift; |
| 1006 | 1006 | } |
| 1007 | if (fgcoll) victory_update_irq(); | |
| 1007 | if (fgcoll) victory_update_irq(Machine); | |
| 1008 | 1008 | } |
| 1009 | 1009 | |
| 1010 | 1010 | count_states(4); |
| r2724 | r2725 | |
| 1087 | 1087 | bgcollx = param & 0xff; |
| 1088 | 1088 | bgcolly = param >> 8; |
| 1089 | 1089 | bgcoll = 1; |
| 1090 | victory_update_irq(); | |
| 1090 | victory_update_irq(machine); | |
| 1091 | 1091 | } |
| 1092 | 1092 | |
| 1093 | 1093 |
| r2724 | r2725 | |
|---|---|---|
| 25 | 25 | ***************************************************************************/ |
| 26 | 26 | |
| 27 | 27 | #include "driver.h" |
| 28 | #include "deprecat.h" | |
| 29 | 28 | |
| 30 | 29 | |
| 31 | 30 | UINT8 *pacland_videoram,*pacland_videoram2,*pacland_spriteram; |
| r2724 | r2725 | |
| 273 | 272 | if (palette_bank != ((data & 0x18) >> 3)) |
| 274 | 273 | { |
| 275 | 274 | palette_bank = (data & 0x18) >> 3; |
| 276 | switch_palette( | |
| 275 | switch_palette(machine); | |
| 277 | 276 | } |
| 278 | 277 | } |
| 279 | 278 |
| r2724 | r2725 | |
|---|---|---|
| 1 | 1 | #include "driver.h" |
| 2 | #include "deprecat.h" | |
| 3 | 2 | #include "video/konamiic.h" |
| 4 | 3 | #include "f1gp.h" |
| 5 | 4 | |
| r2724 | r2725 | |
| 292 | 291 | if((spriteram16[attr_start + 1] & 0x00f0) && (spriteram16[attr_start + 1] & 0x00f0) != 0xc0) |
| 293 | 292 | { |
| 294 | 293 | printf("attr %X\n",spriteram16[attr_start + 1] & 0x00f0); |
| 295 | code = mame_rand( | |
| 294 | code = mame_rand(machine); | |
| 296 | 295 | } |
| 297 | 296 | |
| 298 | 297 | /* |
| r2724 | r2725 | |
|---|---|---|
| 5 | 5 | ***************************************************************************/ |
| 6 | 6 | |
| 7 | 7 | #include "driver.h" |
| 8 | #include "deprecat.h" | |
| 9 | 8 | #include "exidy440.h" |
| 10 | 9 | |
| 11 | 10 | |
| r2724 | r2725 | |
| 154 | 153 | { |
| 155 | 154 | /* clear the FIRQ on a read here */ |
| 156 | 155 | exidy440_firq_beam = 0; |
| 157 | exidy440_update_firq( | |
| 156 | exidy440_update_firq(machine); | |
| 158 | 157 | |
| 159 | 158 | /* according to the schems, this value is only latched on an FIRQ |
| 160 | 159 | * caused by collision or beam */ |
| r2724 | r2725 | |
| 208 | 207 | palettebank_vis = data & 1; |
| 209 | 208 | |
| 210 | 209 | /* update the FIRQ in case we enabled something */ |
| 211 | exidy440_update_firq( | |
| 210 | exidy440_update_firq(machine); | |
| 212 | 211 | |
| 213 | 212 | /* if we're swapping palettes, change all the colors */ |
| 214 | 213 | if (oldvis != palettebank_vis) |
| r2724 | r2725 | |
| 231 | 230 | { |
| 232 | 231 | /* clear the VBLANK FIRQ on a write here */ |
| 233 | 232 | exidy440_firq_vblank = 0; |
| 234 | exidy440_update_firq( | |
| 233 | exidy440_update_firq(machine); | |
| 235 | 234 | } |
| 236 | 235 | |
| 237 | 236 |
| r2724 | r2725 | |
|---|---|---|
| 293 | 293 | CUSTOM_INPUT( player_input_r ) |
| 294 | 294 | { |
| 295 | 295 | if (cocktail_mode) |
| 296 | return (input_port_read(machine, "CTRL") & 0xf0) >> 4; | |
| 296 | return (input_port_read(field->port->machine, "CTRL") & 0xf0) >> 4; | |
| 297 | 297 | else |
| 298 | return (input_port_read(machine, "CTRL") & 0x0f) >> 0; | |
| 298 | return (input_port_read(field->port->machine, "CTRL") & 0x0f) >> 0; | |
| 299 | 299 | } |
| 300 | 300 | |
| 301 | 301 | CUSTOM_INPUT( pleiads_protection_r ) |
| r2724 | r2725 | |
|---|---|---|
| 1523 | 1523 | handle_keyboard(machine); |
| 1524 | 1524 | |
| 1525 | 1525 | /* do nothing new for the rest of the frame */ |
| 1526 | antic.modelines = video_screen_get_height( | |
| 1526 | antic.modelines = video_screen_get_height(machine->primary_screen) - VBL_START; | |
| 1527 | 1527 | antic_renderer = antic_mode_0_xx; |
| 1528 | 1528 | |
| 1529 | 1529 | /* if the CPU want's to be interrupted at vertical blank... */ |
| r2724 | r2725 | |
| 1532 | 1532 | LOG((" cause VBL NMI\n")); |
| 1533 | 1533 | /* set the VBL NMI status bit */ |
| 1534 | 1534 | antic.r.nmist |= VBL_NMI; |
| 1535 | cpunum_set_input_line( | |
| 1535 | cpunum_set_input_line(machine, 0, INPUT_LINE_NMI, PULSE_LINE); | |
| 1536 | 1536 | } |
| 1537 | 1537 | } |
| 1538 | 1538 |
| r2724 | r2725 | |
|---|---|---|
| 335 | 335 | int r = ((pix >> 11) & 0x1f) << 3; |
| 336 | 336 | int g = ((pix >> 6) & 0x1f) << 3; |
| 337 | 337 | int b = ((pix >> 1) & 0x1f) << 3; |
| 338 | d[i | |
| 338 | d[BYTE_XOR_BE(i) | |
| 339 | 339 | } |
| 340 | 340 | } |
| 341 | 341 | } |
| r2724 | r2725 | |
|---|---|---|
| 1 | 1 | #include "driver.h" |
| 2 | #include "deprecat.h" | |
| 3 | 2 | #include "cpu/m6809/m6809.h" |
| 4 | 3 | #include "homedata.h" |
| 5 | 4 | |
| r2724 | r2725 | |
| 133 | 132 | } /* for(;;) */ |
| 134 | 133 | |
| 135 | 134 | finish: |
| 136 | cpunum_set_input_line( | |
| 135 | cpunum_set_input_line(machine, 0,M6809_FIRQ_LINE,HOLD_LINE); | |
| 137 | 136 | } |
| 138 | 137 | |
| 139 | 138 | static void reikaids_handleblit( running_machine *machine, int rom_base ) |
| r2724 | r2725 | |
| 233 | 232 | } |
| 234 | 233 | |
| 235 | 234 | finish: |
| 236 | cpunum_set_input_line( | |
| 235 | cpunum_set_input_line(machine, 0,M6809_FIRQ_LINE,HOLD_LINE); | |
| 237 | 236 | } |
| 238 | 237 | |
| 239 | 238 | static void pteacher_handleblit( running_machine *machine, int rom_base ) |
| r2724 | r2725 | |
| 321 | 320 | } /* for(;;) */ |
| 322 | 321 | |
| 323 | 322 | finish: |
| 324 | cpunum_set_input_line( | |
| 323 | cpunum_set_input_line(machine, 0,M6809_FIRQ_LINE,HOLD_LINE); | |
| 325 | 324 | } |
| 326 | 325 | |
| 327 | 326 |
| r2724 | r2725 | |
|---|---|---|
| 2 | 2 | see DRIVER file for notes */ |
| 3 | 3 | |
| 4 | 4 | #include "driver.h" |
| 5 | #include "deprecat.h" | |
| 6 | 5 | |
| 7 | 6 | |
| 8 | 7 | UINT32 *macrossp_scra_videoram, *macrossp_scra_videoregs; |
| r2724 | r2725 | |
| 44 | 43 | break; |
| 45 | 44 | |
| 46 | 45 | default: |
| 47 | color = mame_rand( | |
| 46 | color = mame_rand(machine) & 7; | |
| 48 | 47 | break; |
| 49 | 48 | } |
| 50 | 49 | |
| r2724 | r2725 | |
| 79 | 78 | break; |
| 80 | 79 | |
| 81 | 80 | default: |
| 82 | color = mame_rand( | |
| 81 | color = mame_rand(machine) & 7; | |
| 83 | 82 | break; |
| 84 | 83 | } |
| 85 | 84 | |
| r2724 | r2725 | |
| 114 | 113 | break; |
| 115 | 114 | |
| 116 | 115 | default: |
| 117 | color = mame_rand( | |
| 116 | color = mame_rand(machine) & 7; | |
| 118 | 117 | break; |
| 119 | 118 | } |
| 120 | 119 | |
| r2724 | r2725 | |
| 232 | 231 | break; |
| 233 | 232 | |
| 234 | 233 | default: |
| 235 | col = mame_rand( | |
| 234 | col = mame_rand(machine); | |
| 236 | 235 | break; |
| 237 | 236 | } |
| 238 | 237 |
| r2724 | r2725 | |
|---|---|---|
| 242 | 242 | fillbitmap(priority_bitmap,0,cliprect); |
| 243 | 243 | fillbitmap(bitmap,0,cliprect); /* wrong color? */ |
| 244 | 244 | |
| 245 | TC0100SCN_tilemap_draw(screen->machine,bitmap,cliprect,0,pivlayer[0], | |
| 245 | TC0100SCN_tilemap_draw(screen->machine,bitmap,cliprect,0,pivlayer[0],TILEMAP_DRAW_OPAQUE,0); | |
| 246 | 246 | TC0100SCN_tilemap_draw(screen->machine,bitmap,cliprect,0,pivlayer[1],0,0); |
| 247 | 247 | |
| 248 | 248 | /* BIG HACK! |
| r0 | r2725 | |
|---|---|---|
| 1 | <mamelayout version="2"> | |
| 2 | <element name="overlay"> | |
| 3 | <rect> | |
| 4 | <bounds left="0" top="0" right="168" bottom="161.5" /> | |
| 5 | <color red="0.125" green="1" blue="0.125" /> | |
| 6 | </rect> | |
| 7 | <rect> | |
| 8 | <bounds left="0" top="161.5" right="168" bottom="175.5" /> | |
| 9 | <color red="1" green="0.5" blue="0.0625" /> | |
| 10 | </rect> | |
| 11 | <rect> | |
| 12 | <bounds left="0" top="175.5" right="168" bottom="224" /> | |
| 13 | <color red="1" green="0.125" blue="0.125" /> | |
| 14 | </rect> | |
| 15 | </element> | |
| 16 | <view name="Color_Overlay"> | |
| 17 | <screen index="0"> | |
| 18 | <bounds x="0" y="0" width="168" height="224" /> | |
| 19 | </screen> | |
| 20 | <overlay element="overlay"> | |
| 21 | <bounds x="0" y="0" width="168" height="224" /> | |
| 22 | </overlay> | |
| 23 | <bezel element="overlay"> | |
| 24 | <bounds x="0" y="0" width="168" height="224" /> | |
| 25 | <color alpha="0.1" /> | |
| 26 | </bezel> | |
| 27 | </view> | |
| 28 | </mamelayout> |
| r2724 | r2725 | |
|---|---|---|
| 848 | 848 | val = 0x1; |
| 849 | 849 | |
| 850 | 850 | /* TODO */ |
| 851 | update_irqs( | |
| 851 | update_irqs(machine); | |
| 852 | 852 | break; |
| 853 | 853 | } |
| 854 | 854 | case 0x1C: |
| r2724 | r2725 | |
|---|---|---|
| 12 | 12 | */ |
| 13 | 13 | |
| 14 | 14 | #include "driver.h" |
| 15 | #include "deprecat.h" | |
| 16 | 15 | |
| 17 | 16 | static READ8_HANDLER( unk_r ) |
| 18 | 17 | { |
| 19 | return mame_rand( | |
| 18 | return mame_rand(machine); | |
| 20 | 19 | } |
| 21 | 20 | |
| 22 | 21 | static UINT8 *intrscti_ram; |
| r2724 | r2725 | |
|---|---|---|
| 456 | 456 | |
| 457 | 457 | static READ8_HANDLER(cyclshtg_mcu_status_r1) |
| 458 | 458 | { |
| 459 | return mame_rand( | |
| 459 | return mame_rand(machine); | |
| 460 | 460 | } |
| 461 | 461 | |
| 462 | 462 | static WRITE8_HANDLER( cyclshtg_generic_control_w ) |
| r2724 | r2725 | |
| 534 | 534 | |
| 535 | 535 | static READ8_HANDLER(unk_r) |
| 536 | 536 | { |
| 537 | return mame_rand( | |
| 537 | return mame_rand(machine); | |
| 538 | 538 | } |
| 539 | 539 | |
| 540 | 540 | static ADDRESS_MAP_START( bronx_readmem, ADDRESS_SPACE_PROGRAM, 8 ) |
| r2724 | r2725 | |
|---|---|---|
| 1413 | 1413 | |
| 1414 | 1414 | |
| 1415 | 1415 | |
| 1416 | static void spangbl_adpcm_int(int data) | |
| 1416 | static void spangbl_adpcm_int(running_machine *machine, int data) | |
| 1417 | 1417 | { |
| 1418 | 1418 | MSM5205_data_w(0, sample_buffer & 0x0F); |
| 1419 | 1419 | sample_buffer >>= 4; |
| 1420 | 1420 | sample_select ^= 1; |
| 1421 | 1421 | if(sample_select == 0) |
| 1422 | cpunum_set_input_line( | |
| 1422 | cpunum_set_input_line(machine, 1, INPUT_LINE_NMI, PULSE_LINE); | |
| 1423 | 1423 | } |
| 1424 | 1424 | |
| 1425 | 1425 |
| r2724 | r2725 | |
|---|---|---|
| 237 | 237 | ***************************************************************************/ |
| 238 | 238 | |
| 239 | 239 | #include "driver.h" |
| 240 | #include "deprecat.h" | |
| 241 | 240 | #include "taitoipt.h" |
| 242 | 241 | #include "video/taitoic.h" |
| 243 | 242 | #include "audio/taitosnd.h" |
| r2724 | r2725 | |
| 597 | 596 | |
| 598 | 597 | /* handler called by the YM2151 emulator when the internal timers cause an IRQ */ |
| 599 | 598 | |
| 600 | static void irqhandler(int irq) | |
| 599 | static void irqhandler(running_machine *machine, int irq) | |
| 601 | 600 | { |
| 602 | cpunum_set_input_line( | |
| 601 | cpunum_set_input_line(machine, 1,0,irq ? ASSERT_LINE : CLEAR_LINE); | |
| 603 | 602 | } |
| 604 | 603 | |
| 605 | 604 | static const struct YM2151interface ym2151_interface = |
| r2724 | r2725 | |
|---|---|---|
| 19 | 19 | ***************************************************************************/ |
| 20 | 20 | |
| 21 | 21 | #include "driver.h" |
| 22 | #include "deprecat.h" | |
| 23 | 22 | #include "cpu/z80/z80.h" |
| 24 | 23 | #include "sound/okim6295.h" |
| 25 | 24 | #include "sound/3812intf.h" |
| r2724 | r2725 | |
| 264 | 263 | |
| 265 | 264 | |
| 266 | 265 | |
| 267 | static void irqhandler(int linestate) | |
| 266 | static void irqhandler(running_machine *machine, int linestate) | |
| 268 | 267 | { |
| 269 | cpunum_set_input_line( | |
| 268 | cpunum_set_input_line(machine, 1,0,linestate); | |
| 270 | 269 | } |
| 271 | 270 | |
| 272 | 271 | static const struct YM3812interface ym3812_interface = |
| r2724 | r2725 | |
|---|---|---|
| 14 | 14 | ***************************************************************************/ |
| 15 | 15 | |
| 16 | 16 | #include "driver.h" |
| 17 | #include "deprecat.h" | |
| 18 | 17 | #include "cpu/z80/z80.h" |
| 19 | 18 | #include "sound/2203intf.h" |
| 20 | 19 | |
| r2724 | r2725 | |
| 229 | 228 | |
| 230 | 229 | |
| 231 | 230 | /* handler called by the 2203 emulator when the internal timers cause an IRQ */ |
| 232 | static void irqhandler(int irq) | |
| 231 | static void irqhandler(running_machine *machine, int irq) | |
| 233 | 232 | { |
| 234 | cpunum_set_input_line( | |
| 233 | cpunum_set_input_line(machine, 1,0,irq ? ASSERT_LINE : CLEAR_LINE); | |
| 235 | 234 | } |
| 236 | 235 | |
| 237 | 236 | static const struct YM2203interface ym2203_interface = |
| r2724 | r2725 | |
|---|---|---|
| 5 | 5 | ***************************************************************************/ |
| 6 | 6 | |
| 7 | 7 | #include "driver.h" |
| 8 | #include "deprecat.h" | |
| 9 | 8 | |
| 10 | 9 | static UINT8* mgolf_video_ram; |
| 11 | 10 | |
| r2724 | r2725 | |
| 82 | 81 | time_released = timer_get_time(); |
| 83 | 82 | |
| 84 | 83 | if (!mask) |
| 85 | cpunum_set_input_line( | |
| 84 | cpunum_set_input_line(machine, 0, INPUT_LINE_NMI, PULSE_LINE); | |
| 86 | 85 | } |
| 87 | 86 | else |
| 88 | 87 | time_pushed = timer_get_time(); |
| r2724 | r2725 | |
|---|---|---|
| 96 | 96 | ***************************************************************************/ |
| 97 | 97 | |
| 98 | 98 | #include "driver.h" |
| 99 | #include "deprecat.h" | |
| 100 | 99 | #include "machine/eeprom.h" |
| 101 | 100 | #include "sound/ymz280b.h" |
| 102 | 101 | #include "decoprot.h" |
| r2724 | r2725 | |
| 126 | 125 | // if (offset==0) |
| 127 | 126 | // return input_port_read_indexed(machine, 0); //0xffffffff; |
| 128 | 127 | // logerror("%08x: Test2_r %d\n",activecpu_get_pc(),offset); |
| 129 | return mame_rand( | |
| 128 | return mame_rand(machine); //0xffffffff; | |
| 130 | 129 | } |
| 131 | 130 | |
| 132 | 131 | static READ32_HANDLER(test3_r) |
| r2724 | r2725 | |
| 136 | 135 | |
| 137 | 136 | */ |
| 138 | 137 | //if (offset==0) |
| 139 | // return mame_rand( | |
| 138 | // return mame_rand(machine)|(mame_rand(machine)<<16); | |
| 140 | 139 | // logerror("%08x: Test3_r %d\n",activecpu_get_pc(),offset); |
| 141 | 140 | return 0xffffffff; |
| 142 | 141 | } |
| r2724 | r2725 | |
|---|---|---|
| 278 | 278 | ***************************************************************************/ |
| 279 | 279 | |
| 280 | 280 | #include "driver.h" |
| 281 | #include "deprecat.h" | |
| 282 | 281 | #include "machine/mathbox.h" |
| 283 | 282 | #include "video/avgdvg.h" |
| 284 | 283 | #include "video/vector.h" |
| r2724 | r2725 | |
| 305 | 304 | static WRITE8_HANDLER( wdclr_w ) |
| 306 | 305 | { |
| 307 | 306 | cpunum_set_input_line(machine, 0, 0, CLEAR_LINE); |
| 308 | watchdog_reset( | |
| 307 | watchdog_reset(machine); | |
| 309 | 308 | } |
| 310 | 309 | |
| 311 | 310 | /************************************* |
| r2724 | r2725 | |
| 320 | 319 | |
| 321 | 320 | if (tempest_player_select) |
| 322 | 321 | { |
| 323 | ret = input_port_read(machine, TEMPEST_KNOB_P2_TAG); | |
| 322 | ret = input_port_read(field->port->machine, TEMPEST_KNOB_P2_TAG); | |
| 324 | 323 | } |
| 325 | 324 | else |
| 326 | 325 | { |
| 327 | ret = input_port_read(machine, TEMPEST_KNOB_P1_TAG); | |
| 326 | ret = input_port_read(field->port->machine, TEMPEST_KNOB_P1_TAG); | |
| 328 | 327 | } |
| 329 | 328 | |
| 330 | 329 | return ret; |
| r2724 | r2725 | |
| 336 | 335 | |
| 337 | 336 | if (tempest_player_select) |
| 338 | 337 | { |
| 339 | ret = input_port_read(machine, TEMPEST_BUTTONS_P2_TAG); | |
| 338 | ret = input_port_read(field->port->machine, TEMPEST_BUTTONS_P2_TAG); | |
| 340 | 339 | } |
| 341 | 340 | else |
| 342 | 341 | { |
| 343 | ret = input_port_read(machine, TEMPEST_BUTTONS_P1_TAG); | |
| 342 | ret = input_port_read(field->port->machine, TEMPEST_BUTTONS_P1_TAG); | |
| 344 | 343 | } |
| 345 | 344 | |
| 346 | 345 | return ret; |
| r2724 | r2725 | |
|---|---|---|
| 13 | 13 | ***************************************************************************/ |
| 14 | 14 | |
| 15 | 15 | #include "driver.h" |
| 16 | #include "deprecat.h" | |
| 17 | 16 | #include "cpu/h6280/h6280.h" |
| 18 | 17 | #include "sound/2203intf.h" |
| 19 | 18 | #include "sound/2151intf.h" |
| r2724 | r2725 | |
| 272 | 271 | |
| 273 | 272 | /******************************************************************************/ |
| 274 | 273 | |
| 275 | static void sound_irq(int state) | |
| 274 | static void sound_irq(running_machine *machine, int state) | |
| 276 | 275 | { |
| 277 | cpunum_set_input_line( | |
| 276 | cpunum_set_input_line(machine, 1,1,state); /* IRQ 2 */ | |
| 278 | 277 | } |
| 279 | 278 | |
| 280 | 279 | static const struct YM2151interface ym2151_interface = |
| r2724 | r2725 | |
|---|---|---|
| 716 | 716 | #define VBLANK 1 / VSYNC * (40 / 264) |
| 717 | 717 | |
| 718 | 718 | // handler called by the 2203 emulator when the internal timers cause an IRQ |
| 719 | static void irqhandler(int irq) | |
| 719 | static void irqhandler(running_machine *machine, int irq) | |
| 720 | 720 | { |
| 721 | cpunum_set_input_line( | |
| 721 | cpunum_set_input_line(machine, 2, 0, irq ? ASSERT_LINE : CLEAR_LINE); | |
| 722 | 722 | } |
| 723 | 723 | |
| 724 | 724 | static const struct YM2203interface ym2203_interface = |
| r2724 | r2725 | |
|---|---|---|
| 40 | 40 | */ |
| 41 | 41 | |
| 42 | 42 | #include "driver.h" |
| 43 | #include "deprecat.h" | |
| 44 | 43 | #include "machine/mc8123.h" |
| 45 | 44 | #include "sound/2203intf.h" |
| 46 | 45 | |
| r2724 | r2725 | |
| 153 | 152 | } |
| 154 | 153 | |
| 155 | 154 | printf("chinsan_input_port_0_r unk_r %02x\n", chinsan_port_select); |
| 156 | return mame_rand( | |
| 155 | return mame_rand(machine); | |
| 157 | 156 | } |
| 158 | 157 | |
| 159 | 158 | static READ8_HANDLER( chinsan_input_port_1_r ) |
| r2724 | r2725 | |
| 182 | 181 | } |
| 183 | 182 | |
| 184 | 183 | printf("chinsan_input_port_1_r unk_r %02x\n", chinsan_port_select); |
| 185 | return mame_rand( | |
| 184 | return mame_rand(machine); | |
| 186 | 185 | } |
| 187 | 186 | |
| 188 | 187 |
| r2724 | r2725 | |
|---|---|---|
| 59 | 59 | ***************************************************************************/ |
| 60 | 60 | |
| 61 | 61 | #include "driver.h" |
| 62 | #include "deprecat.h" | |
| 63 | 62 | #include "cpu/z80/z80.h" |
| 64 | 63 | #include "sound/2610intf.h" |
| 65 | 64 | #include "sound/3812intf.h" |
| r2724 | r2725 | |
| 1193 | 1192 | 16,16, |
| 1194 | 1193 | RGN_FRAC(1,4), |
| 1195 | 1194 | 4, |
| 1196 | { RGN_FRAC( | |
| 1195 | { RGN_FRAC(3,4), RGN_FRAC(2,4), RGN_FRAC(1,4), RGN_FRAC(0,4) }, | |
| 1197 | 1196 | { 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15 }, |
| 1198 | 1197 | { 0*16, 1*16, 2*16, 3*16, 4*16, 5*16, 6*16, 7*16, |
| 1199 | 1198 | 8*16, 9*16, 10*16, 11*16, 12*16, 13*16, 14*16, 15*16 }, |
| r2724 | r2725 | |
| 1300 | 1299 | GFXDECODE_ENTRY( REGION_GFX2, 0, wbbc97_spritelayout, 1024, 64 ) /* colors 1024-2047 in 4 banks */ |
| 1301 | 1300 | GFXDECODE_END |
| 1302 | 1301 | |
| 1303 | static void irqhandler(int irq) | |
| 1302 | static void irqhandler(running_machine *machine, int irq) | |
| 1304 | 1303 | { |
| 1305 | cpunum_set_input_line( | |
| 1304 | cpunum_set_input_line(machine, 1,0,irq ? ASSERT_LINE : CLEAR_LINE); | |
| 1306 | 1305 | } |
| 1307 | 1306 | |
| 1308 | 1307 | static const struct YM2610interface ym2610_interface = |
| r2724 | r2725 | |
| 1909 | 1908 | ROM_LOAD( "5.ic74", 0x40000, 0x20000, CRC(d7fcd97c) SHA1(eb7c8ac111f5916350aae0ee3edc019207fef654) ) |
| 1910 | 1909 | ROM_LOAD( "6.ic73", 0x60000, 0x20000, CRC(e6b9107f) SHA1(aaab2f2dfb85ee764091253c9a4ab89bc51d7518) ) |
| 1911 | 1910 | |
| 1912 | ROM_REGION( 0x100000, REGION_GFX2, ROMREGION_DISPOSE ) | |
| 1911 | ROM_REGION( 0x100000, REGION_GFX2, ROMREGION_DISPOSE | ROMREGION_INVERT ) | |
| 1913 | 1912 | ROM_LOAD( "11.ic118", 0x00000, 0x40000, CRC(6e65b4b2) SHA1(5296e8095ec60f79a5cd3f9db829c7d491670282) ) |
| 1914 | 1913 | ROM_LOAD( "12.ic119", 0x40000, 0x40000, CRC(60e0d3e0) SHA1(93efc58b03610e7f18ff076ac985428a446454f9) ) |
| 1915 | 1914 | ROM_LOAD( "13.ic120", 0x80000, 0x40000, CRC(89213a8c) SHA1(8524d5c14669d9b03f1fe050c4318d4111bc8ef7) ) |
| r2724 | r2725 | |
| 2448 | 2447 | GAME( 1991, pspikesk, pspikes, pspikes, pspikes, 0, ROT0, "Video System Co.", "Power Spikes (Korea)", GAME_NO_COCKTAIL ) |
| 2449 | 2448 | GAME( 1991, svolly91, pspikes, pspikes, pspikes, 0, ROT0, "Video System Co.", "Super Volley '91 (Japan)", GAME_NO_COCKTAIL ) |
| 2450 | 2449 | GAME( 1991, pspikesb, pspikes, pspikesb, pspikesb, 0, ROT0, "bootleg", "Power Spikes (bootleg)", GAME_NO_COCKTAIL ) |
| 2451 | GAME( 1991, spikes91, pspikes, spikes91, pspikes, 0, ROT0, "bootleg", "1991 Spikes (Italian bootleg)", GAME_NO | |
| 2450 | GAME( 1991, spikes91, pspikes, spikes91, pspikes, 0, ROT0, "bootleg", "1991 Spikes (Italian bootleg)", GAME_NO | |
| 2452 | 2451 | GAME( 1991, pspikesc, pspikes, pspikesc, pspikesc, 0, ROT0, "bootleg", "Power Spikes (China)", GAME_NO_COCKTAIL | GAME_IMPERFECT_SOUND ) |
| 2453 | 2452 | GAME( 1991, karatblz, 0, karatblz, karatblz, 0, ROT0, "Video System Co.", "Karate Blazers (World?)", GAME_NO_COCKTAIL ) |
| 2454 | 2453 | GAME( 1991, karatblu, karatblz, karatblz, karatblz, 0, ROT0, "Video System Co.", "Karate Blazers (US)", GAME_NO_COCKTAIL ) |
| r2724 | r2725 | |
|---|---|---|
| 159 | 159 | |
| 160 | 160 | static int adpcm_pos, adpcm_idle; |
| 161 | 161 | |
| 162 | static void idsoccer_adpcm_int(int chip) | |
| 162 | static void idsoccer_adpcm_int(running_machine *machine, int chip) | |
| 163 | 163 | { |
| 164 | 164 | static int adpcm_data = -1; |
| 165 | 165 |
| r2724 | r2725 | |
|---|---|---|
| 5 | 5 | */ |
| 6 | 6 | |
| 7 | 7 | #include "driver.h" |
| 8 | #include "deprecat.h" | |
| 9 | 8 | #include "cpu/powerpc/ppc.h" |
| 10 | 9 | #include "sound/k054539.h" |
| 11 | 10 | #include "machine/eeprom.h" |
| r2724 | r2725 | |
| 260 | 259 | MDRV_SOUND_ROUTE(1, "right", 1.0) |
| 261 | 260 | MACHINE_DRIVER_END |
| 262 | 261 | |
| 263 | static void sound_irq_callback(int irq) | |
| 262 | static void sound_irq_callback(running_machine *machine, int irq) | |
| 264 | 263 | { |
| 265 | 264 | if (irq == 0) |
| 266 | /*cpunum_set_input_line( | |
| 265 | /*cpunum_set_input_line(machine, 1, INPUT_LINE_IRQ5, PULSE_LINE)*/; | |
| 267 | 266 | else |
| 268 | cpunum_set_input_line( | |
| 267 | cpunum_set_input_line(machine, 1, INPUT_LINE_IRQ6, PULSE_LINE); | |
| 269 | 268 | } |
| 270 | 269 | |
| 271 | 270 | static DRIVER_INIT( ultrsprt ) |
| r2724 | r2725 | |
|---|---|---|
| 58 | 58 | static INPUT_CHANGED( coin_inserted ) |
| 59 | 59 | { |
| 60 | 60 | /* coin insertion causes an NMI */ |
| 61 | cpunum_set_input_line(machine, 0, INPUT_LINE_NMI, newval ? CLEAR_LINE : ASSERT_LINE); | |
| 61 | cpunum_set_input_line(field->port->machine, 0, INPUT_LINE_NMI, newval ? CLEAR_LINE : ASSERT_LINE); | |
| 62 | 62 | } |
| 63 | 63 | |
| 64 | 64 |
| r2724 | r2725 | |
|---|---|---|
| 1515 | 1515 | GFXDECODE_END |
| 1516 | 1516 | |
| 1517 | 1517 | /* handler called by the 3812/2151 emulator when the internal timers cause an IRQ */ |
| 1518 | static void irqhandler(int irq) | |
| 1518 | static void irqhandler(running_machine *machine, int irq) | |
| 1519 | 1519 | { |
| 1520 | cpunum_set_input_line( | |
| 1520 | cpunum_set_input_line(machine, 1,0,irq ? ASSERT_LINE : CLEAR_LINE); | |
| 1521 | 1521 | } |
| 1522 | 1522 | |
| 1523 | 1523 | /* SnowBros Sound */ |
| r2724 | r2725 | |
|---|---|---|
| 95 | 95 | * |
| 96 | 96 | *************************************/ |
| 97 | 97 | |
| 98 | static void update_main_irqs( | |
| 98 | static void update_main_irqs(running_machine *machine) | |
| 99 | 99 | { |
| 100 | 100 | int irq = 0; |
| 101 | 101 | |
| r2724 | r2725 | |
| 111 | 111 | /* assert the lines that are live, or clear everything if nothing is live */ |
| 112 | 112 | if (irq != 0) |
| 113 | 113 | { |
| 114 | cpunum_set_input_line( | |
| 114 | cpunum_set_input_line(machine, 0, irq, ASSERT_LINE); | |
| 115 | 115 | cpu_boost_interleave(attotime_zero, ATTOTIME_IN_USEC(100)); |
| 116 | 116 | } |
| 117 | 117 | else |
| 118 | cpunum_set_input_line( | |
| 118 | cpunum_set_input_line(machine, 0, 7, CLEAR_LINE); | |
| 119 | 119 | } |
| 120 | 120 | |
| 121 | 121 | |
| r2724 | r2725 | |
| 148 | 148 | |
| 149 | 149 | /* update IRQs on the main CPU */ |
| 150 | 150 | if (update) |
| 151 | update_main_irqs(); | |
| 151 | update_main_irqs(machine); | |
| 152 | 152 | |
| 153 | 153 | /* come back in 2 scanlines */ |
| 154 | 154 | timer_set(video_screen_get_time_until_pos(machine->primary_screen, next_scanline, 0), NULL, next_scanline, scanline_callback); |
| 155 | 155 | } |
| 156 | 156 | |
| 157 | 157 | |
| 158 | static void timer_ack_callback( | |
| 158 | static void timer_ack_callback(running_machine *machine) | |
| 159 | 159 | { |
| 160 | 160 | /* clear the timer IRQ */ |
| 161 | 161 | timer_irq_state = 0; |
| 162 | update_main_irqs(); | |
| 162 | update_main_irqs(machine); | |
| 163 | 163 | } |
| 164 | 164 | |
| 165 | 165 | |
| r2724 | r2725 | |
| 183 | 183 | } |
| 184 | 184 | |
| 185 | 185 | |
| 186 | static void sound_cpu_irq(int state) | |
| 186 | static void sound_cpu_irq(running_machine *machine, int state) | |
| 187 | 187 | { |
| 188 | cpunum_set_input_line( | |
| 188 | cpunum_set_input_line(machine, 2, 0, state); | |
| 189 | 189 | } |
| 190 | 190 | |
| 191 | 191 |
| r2724 | r2725 | |
|---|---|---|
| 20 | 20 | ******************************************************************************/ |
| 21 | 21 | |
| 22 | 22 | #include "driver.h" |
| 23 | #include "deprecat.h" | |
| 24 | 23 | #include "machine/z80ctc.h" |
| 25 | 24 | #include "sound/3812intf.h" |
| 26 | 25 | #include "sound/dac.h" |
| r2724 | r2725 | |
| 487 | 486 | static WRITE8_HANDLER( tmpz84c011_1_dir_pe_w ) { pio_dir[9] = data; } |
| 488 | 487 | |
| 489 | 488 | |
| 490 | static void ctc0_interrupt(int state) | |
| 489 | static void ctc0_interrupt(running_machine *machine, int state) | |
| 491 | 490 | { |
| 492 | cpunum_set_input_line( | |
| 491 | cpunum_set_input_line(machine, 0, 0, state); | |
| 493 | 492 | } |
| 494 | 493 | |
| 495 | static void ctc1_interrupt(int state) | |
| 494 | static void ctc1_interrupt(running_machine *machine, int state) | |
| 496 | 495 | { |
| 497 | cpunum_set_input_line( | |
| 496 | cpunum_set_input_line(machine, 1, 0, state); | |
| 498 | 497 | } |
| 499 | 498 | |
| 500 | 499 | /* CTC of main cpu, ch0 trigger is vblank */ |
| r2724 | r2725 | |
|---|---|---|
| 7 | 7 | ***************************************************************************/ |
| 8 | 8 | |
| 9 | 9 | #include "driver.h" |
| 10 | #include "deprecat.h" | |
| 11 | 10 | #include "cpu/konami/konami.h" |
| 12 | 11 | #include "cpu/z80/z80.h" |
| 13 | 12 | #include "sound/3812intf.h" |
| r2724 | r2725 | |
| 242 | 241 | |
| 243 | 242 | /*****************************************************************************/ |
| 244 | 243 | |
| 245 | static void irqhandler(int linestate) | |
| 244 | static void irqhandler(running_machine *machine, int linestate) | |
| 246 | 245 | { |
| 247 | // cpunum_set_input_line( | |
| 246 | // cpunum_set_input_line(machine, 1,0,linestate); | |
| 248 | 247 | } |
| 249 | 248 | |
| 250 | 249 | static void volume_callback(int v) |
| r2724 | r2725 | |
|---|---|---|
| 75 | 75 | |
| 76 | 76 | #include "driver.h" |
| 77 | 77 | #include "render.h" |
| 78 | #include "deprecat.h" | |
| 79 | 78 | #include "machine/laserdsc.h" |
| 80 | 79 | #include "video/tms9928a.h" |
| 81 | 80 | #include "sound/discrete.h" |
| r2724 | r2725 | |
| 228 | 227 | { |
| 229 | 228 | /* clock the laserdisc and video chip every 60Hz */ |
| 230 | 229 | laserdisc_vsync(discinfo); |
| 231 | TMS9928A_interrupt(); | |
| 230 | TMS9928A_interrupt(machine); | |
| 232 | 231 | } |
| 233 | 232 | |
| 234 | 233 | static TIMER_CALLBACK( cliff_irq_callback ) |
| r2724 | r2725 | |
| 255 | 254 | timer_adjust_oneshot(irq_timer, video_screen_get_time_until_pos(machine->primary_screen, param, 0), param); |
| 256 | 255 | } |
| 257 | 256 | |
| 258 | static void vdp_interrupt (int state) | |
| 257 | static void vdp_interrupt (running_machine *machine, int state) | |
| 259 | 258 | { |
| 260 | cpunum_set_input_line( | |
| 259 | cpunum_set_input_line(machine, 0, INPUT_LINE_NMI, state ? ASSERT_LINE : CLEAR_LINE ); | |
| 261 | 260 | } |
| 262 | 261 | |
| 263 | 262 |
| r2724 | r2725 | |
|---|---|---|
| 144 | 144 | if (activecpu_get_pc() == 0x18c2) |
| 145 | 145 | { |
| 146 | 146 | hack_irq = 1; |
| 147 | update_irq_state( | |
| 147 | update_irq_state(machine); | |
| 148 | 148 | hack_irq = 0; |
| 149 | update_irq_state( | |
| 149 | update_irq_state(machine); | |
| 150 | 150 | } |
| 151 | 151 | return input_port_read_indexed(machine, 0); |
| 152 | 152 | } |
| r2724 | r2725 | |
| 401 | 401 | prot_bit_index = 0; |
| 402 | 402 | |
| 403 | 403 | /* update the protection state */ |
| 404 | (*protection_handler)( | |
| 404 | (*protection_handler)(machine); | |
| 405 | 405 | } |
| 406 | 406 | } |
| 407 | 407 |
| r2724 | r2725 | |
|---|---|---|
| 188 | 188 | |
| 189 | 189 | |
| 190 | 190 | #include "driver.h" |
| 191 | #include "deprecat.h" | |
| 192 | 191 | #include "cpu/m68000/m68000.h" |
| 193 | 192 | #include "cpu/tms32010/tms32010.h" |
| 194 | 193 | #include "twincobr.h" |
| r2724 | r2725 | |
| 634 | 633 | |
| 635 | 634 | |
| 636 | 635 | /* handler called by the 3812 emulator when the internal timers cause an IRQ */ |
| 637 | static void irqhandler(int linestate) | |
| 636 | static void irqhandler(running_machine *machine, int linestate) | |
| 638 | 637 | { |
| 639 | cpunum_set_input_line( | |
| 638 | cpunum_set_input_line(machine, 1,0,linestate); | |
| 640 | 639 | } |
| 641 | 640 | |
| 642 | 641 | static const struct YM3812interface ym3812_interface = |
| r2724 | r2725 | |
|---|---|---|
| 271 | 271 | |
| 272 | 272 | mame_printf_debug("dblewing prot r %08x, %04x, %04x\n",activecpu_get_pc(), offset*2, mem_mask); |
| 273 | 273 | |
| 274 | return 0;//mame_rand( | |
| 274 | return 0;//mame_rand(machine); | |
| 275 | 275 | } |
| 276 | 276 | |
| 277 | 277 | static WRITE16_HANDLER( dblewing_prot_w ) |
| r2724 | r2725 | |
| 526 | 526 | |
| 527 | 527 | INPUT_PORTS_END |
| 528 | 528 | |
| 529 | static void sound_irq(int irq) | |
| 529 | static void sound_irq(running_machine *machine, int irq) | |
| 530 | 530 | { |
| 531 | // cpunum_set_input_line( | |
| 531 | // cpunum_set_input_line(machine, 1,0,irq ? ASSERT_LINE : CLEAR_LINE); | |
| 532 | 532 | // mame_printf_debug("sound irq\n"); |
| 533 | 533 | } |
| 534 | 534 |
| r2724 | r2725 | |
|---|---|---|
| 486 | 486 | |
| 487 | 487 | static int voodoo_version = 0; |
| 488 | 488 | |
| 489 | static void voodoo_vblank_0(int param) | |
| 489 | static void voodoo_vblank_0(running_machine *machine, int param) | |
| 490 | 490 | { |
| 491 | cpunum_set_input_line( | |
| 491 | cpunum_set_input_line(machine, 0, INPUT_LINE_IRQ0, ASSERT_LINE); | |
| 492 | 492 | } |
| 493 | 493 | |
| 494 | static void voodoo_vblank_1(int param) | |
| 494 | static void voodoo_vblank_1(running_machine *machine, int param) | |
| 495 | 495 | { |
| 496 | cpunum_set_input_line( | |
| 496 | cpunum_set_input_line(machine, 0, INPUT_LINE_IRQ1, ASSERT_LINE); | |
| 497 | 497 | } |
| 498 | 498 | |
| 499 | 499 | static void hornet_exit(running_machine *machine) |
| r2724 | r2725 | |
| 1166 | 1166 | jamma_jvs_cmd_exec(); |
| 1167 | 1167 | } |
| 1168 | 1168 | |
| 1169 | static void sound_irq_callback(int irq) | |
| 1169 | static void sound_irq_callback(running_machine *machine, int irq) | |
| 1170 | 1170 | { |
| 1171 | 1171 | if (irq == 0) |
| 1172 | cpunum_set_input_line( | |
| 1172 | cpunum_set_input_line(machine, 1, INPUT_LINE_IRQ1, PULSE_LINE); | |
| 1173 | 1173 | else |
| 1174 | cpunum_set_input_line( | |
| 1174 | cpunum_set_input_line(machine, 1, INPUT_LINE_IRQ2, PULSE_LINE); | |
| 1175 | 1175 | } |
| 1176 | 1176 | |
| 1177 | 1177 | static UINT8 backup_ram[0x2000]; |
| r2724 | r2725 | |
|---|---|---|
| 104 | 104 | |
| 105 | 105 | |
| 106 | 106 | #include "driver.h" |
| 107 | #include "deprecat.h" | |
| 108 | 107 | #include "cpu/z80/z80.h" |
| 109 | 108 | #include "fromance.h" |
| 110 | 109 | #include "sound/2608intf.h" |
| r2724 | r2725 | |
| 525 | 524 | * |
| 526 | 525 | *************************************/ |
| 527 | 526 | |
| 528 | static void irqhandler(int irq) | |
| 527 | static void irqhandler(running_machine *machine, int irq) | |
| 529 | 528 | { |
| 530 | cpunum_set_input_line( | |
| 529 | cpunum_set_input_line(machine, 1, 0, irq ? ASSERT_LINE : CLEAR_LINE); | |
| 531 | 530 | } |
| 532 | 531 | |
| 533 | 532 | |
| 534 | 533 | static const struct YM2608interface ym2608_interface = |
| 535 | 534 | { |
| 536 | 535 | { |
| 537 | AY8910_LEGACY_OUTPUT, | |
| 536 | AY8910_LEGACY_OUTPUT | AY8910_SINGLE_OUTPUT, | |
| 538 | 537 | AY8910_DEFAULT_LOADS, |
| 539 | 538 | NULL, NULL, NULL, NULL |
| 540 | 539 | }, |
| r2724 | r2725 | |
|---|---|---|
| 187 | 187 | |
| 188 | 188 | static CUSTOM_INPUT( get_vblank ) |
| 189 | 189 | { |
| 190 | int scanline = video_screen_get_vpos(machine->primary_screen); | |
| 190 | int scanline = video_screen_get_vpos(field->port->machine->primary_screen); | |
| 191 | 191 | return syncprom[scanline & 0xff] & 1; |
| 192 | 192 | } |
| 193 | 193 |
| r2724 | r2725 | |
|---|---|---|
| 475 | 475 | |
| 476 | 476 | /* Sound Interfaces */ |
| 477 | 477 | |
| 478 | static void dd3_ymirq_handler(int irq) | |
| 478 | static void dd3_ymirq_handler(running_machine *machine, int irq) | |
| 479 | 479 | { |
| 480 | cpunum_set_input_line( | |
| 480 | cpunum_set_input_line(machine, 1, 0 , irq ? ASSERT_LINE : CLEAR_LINE ); | |
| 481 | 481 | } |
| 482 | 482 | |
| 483 | 483 | static const struct YM2151interface ym2151_interface = |
| r2724 | r2725 | |
|---|---|---|
| 253 | 253 | printf( "unk rb2_r\n"); |
| 254 | 254 | } |
| 255 | 255 | |
| 256 | return mame_rand( | |
| 256 | return mame_rand(machine); | |
| 257 | 257 | } |
| 258 | 258 | |
| 259 | 259 | static WRITE8_HANDLER( rambank2_w ) |
| r2724 | r2725 | |
| 336 | 336 | // adpcm_data = data; |
| 337 | 337 | //} |
| 338 | 338 | |
| 339 | static void splash_msm5205_int(int data) | |
| 339 | static void splash_msm5205_int(running_machine *machine, int data) | |
| 340 | 340 | { |
| 341 | 341 | MSM5205_data_w(0,adpcm_data >> 4); |
| 342 | 342 | // adpcm_data = (adpcm_data << 4) & 0xf0; |
| r2724 | r2725 | |
|---|---|---|
| 669 | 669 | */ |
| 670 | 670 | |
| 671 | 671 | #include "driver.h" |
| 672 | #include "deprecat.h" | |
| 673 | 672 | #include "machine/ds2404.h" |
| 674 | 673 | #include "machine/eeprom.h" |
| 675 | 674 | #include "machine/intelfsh.h" |
| r2724 | r2725 | |
| 1105 | 1104 | } |
| 1106 | 1105 | } |
| 1107 | 1106 | |
| 1108 | static void irqhandler(int state) | |
| 1107 | static void irqhandler(running_machine *machine, int state) | |
| 1109 | 1108 | { |
| 1110 | 1109 | if (state) |
| 1111 | cpunum_set_input_line_and_vector( | |
| 1110 | cpunum_set_input_line_and_vector(machine, 1, 0, ASSERT_LINE, 0xd7); // IRQ is RST10 | |
| 1112 | 1111 | else |
| 1113 | cpunum_set_input_line( | |
| 1112 | cpunum_set_input_line(machine, 1, 0, CLEAR_LINE); | |
| 1114 | 1113 | } |
| 1115 | 1114 | |
| 1116 | 1115 | static const struct YMF271interface ymf271_interface = |
| r2724 | r2725 | |
|---|---|---|
| 45 | 45 | |
| 46 | 46 | static int pcm_adr; |
| 47 | 47 | |
| 48 | static void pcm_w(int irq) | |
| 48 | static void pcm_w(running_machine *machine, int irq) | |
| 49 | 49 | { |
| 50 | 50 | UINT8 *PCM = memory_region(REGION_SOUND1); |
| 51 | 51 | |
| r2724 | r2725 | |
| 68 | 68 | static WRITE8_HANDLER( pcm_set_w ) |
| 69 | 69 | { |
| 70 | 70 | pcm_adr = ((data & 0x3f) << 9); |
| 71 | pcm_w(0); | |
| 71 | pcm_w(machine, 0); | |
| 72 | 72 | } |
| 73 | 73 | |
| 74 | 74 | /****************************************************************************/ |
| r2724 | r2725 | |
|---|---|---|
| 9 | 9 | */ |
| 10 | 10 | |
| 11 | 11 | #include "driver.h" |
| 12 | #include "deprecat.h" | |
| 13 | 12 | |
| 14 | 13 | static int crtindex; |
| 15 | 14 | static int crtdata[256]; |
| r2724 | r2725 | |
| 21 | 20 | |
| 22 | 21 | static READ8_HANDLER( tetriunk_random_r ) |
| 23 | 22 | { |
| 24 | return mame_rand( | |
| 23 | return mame_rand(machine); | |
| 25 | 24 | } |
| 26 | 25 | |
| 27 | 26 | static WRITE8_HANDLER(crt_index_w) |
| r2724 | r2725 | |
|---|---|---|
| 25 | 25 | ***************************************************************************/ |
| 26 | 26 | |
| 27 | 27 | #include "driver.h" |
| 28 | #include "deprecat.h" | |
| 29 | 28 | #include "machine/nmk112.h" |
| 30 | 29 | #include "sound/okim6295.h" |
| 31 | 30 | #include "sound/2203intf.h" |
| r2724 | r2725 | |
| 333 | 332 | } |
| 334 | 333 | |
| 335 | 334 | |
| 336 | static void irqhandler(int irq) | |
| 335 | static void irqhandler(running_machine *machine, int irq) | |
| 337 | 336 | { |
| 338 | cpunum_set_input_line( | |
| 337 | cpunum_set_input_line(machine, 1,0,irq ? ASSERT_LINE : CLEAR_LINE); | |
| 339 | 338 | } |
| 340 | 339 | |
| 341 | 340 | static const struct YM2203interface ym2203_interface = |
| r2724 | r2725 | |
|---|---|---|
| 33 | 33 | ******************************************************************************/ |
| 34 | 34 | |
| 35 | 35 | #include "driver.h" |
| 36 | #include "deprecat.h" | |
| 37 | 36 | #include "machine/m68kfmly.h" |
| 38 | 37 | #include "machine/z80ctc.h" |
| 39 | 38 | #include "nb1413m3.h" |
| r2724 | r2725 | |
| 185 | 184 | static WRITE8_HANDLER( tmpz84c011_0_dir_pe_w ) { pio_dir[4] = data; } |
| 186 | 185 | |
| 187 | 186 | |
| 188 | static void ctc0_interrupt(int state) | |
| 187 | static void ctc0_interrupt(running_machine *machine, int state) | |
| 189 | 188 | { |
| 190 | cpunum_set_input_line( | |
| 189 | cpunum_set_input_line(machine, 1, 0, state); | |
| 191 | 190 | } |
| 192 | 191 | |
| 193 | 192 | static z80ctc_interface ctc_intf = |
| r2724 | r2725 | |
|---|---|---|
| 137 | 137 | ***************************************************************************/ |
| 138 | 138 | |
| 139 | 139 | #include "driver.h" |
| 140 | #include "deprecat.h" | |
| 141 | 140 | #include "cpu/m6809/m6809.h" |
| 142 | 141 | |
| 143 | 142 | #include "video/bfm_adr2.h" |
| r2724 | r2725 | |
| 512 | 511 | watchdog_cnt++; |
| 513 | 512 | if ( watchdog_cnt > 2 ) // this is a hack, i don't know what the watchdog timeout is, 3 IRQ's works fine |
| 514 | 513 | { // reset board |
| 515 | mame_schedule_soft_reset( | |
| 514 | mame_schedule_soft_reset(machine); // reset entire machine. CPU 0 should be enough, but that doesn't seem to work !! | |
| 516 | 515 | on_scorpion2_reset(); |
| 517 | 516 | return; |
| 518 | 517 | } |
| r2724 | r2725 | |
|---|---|---|
| 1233 | 1233 | ROM_LOAD( "gs230000.u1", 0x000000, 0x400000, CRC(0348e8e1) SHA1(8a21c7e5cea0bc08a2595213d689c58c0251fdb5) ) |
| 1234 | 1234 | ROM_END |
| 1235 | 1235 | |
| 1236 | /* | |
| 1237 | ||
| 1238 | Gals Panic SU (Kaneko 1999) | |
| 1239 | Korean hacked version. Runs on Super Kaneko Nova System mainboard | |
| 1240 | and original Super Kaneko Nova System ROM board labelled "ROM-BOARD" | |
| 1241 | EPROMs at U8, U10 and mainboard U10 are new to this version. | |
| 1242 | The ROM board is wired to accept 16MBit SOP44 maskROMs. | |
| 1243 | The actual ROMs used are 32M. There are some wire mods to enable the | |
| 1244 | higher capacity ROMs, basically wiring pin 44 of the SOP44's to | |
| 1245 | some logic to enable it. | |
| 1246 | All of the SOP44 ROMs are from Gals Panic 2, but because Gals Panic 2 | |
| 1247 | uses a different ROM board the Gals Panic SU ROMs are at different | |
| 1248 | locations. | |
| 1249 | For Gals Panic SU, the 32M ROMs can be taken from the existing | |
| 1250 | Gals Panic 2 set. | |
| 1251 | ||
| 1252 | */ | |
| 1253 | ||
| 1254 | ROM_START( galpansu ) | |
| 1255 | ROM_REGION( 0x080000, REGION_CPU1, 0 ) /* SH-2 Code */ | |
| 1256 | ROM_LOAD ( "bios.u10", 0x000000, 0x080000, CRC(161fb79e) SHA1(dfb5517de3a14a94344e0f58bbe90b69c5cb5b57) ) /* Korea BIOS */ | |
| 1257 | ||
| 1258 | ROM_REGION32_BE( 0x200000, REGION_USER1, 0 ) /* SH-2 Code mapped at 0x04000000 */ | |
| 1259 | ROM_LOAD16_BYTE( "su.u10", 0x000000, 0x100000, CRC(5ae66218) SHA1(c3f32603e1da945efb984ff99e1a30202e535773) ) | |
| 1260 | ROM_LOAD16_BYTE( "su.u8", 0x000001, 0x100000, CRC(10977a03) SHA1(2ab95398d6b88d8819f368ee6104d7f8b485778d) ) | |
| 1261 | ||
| 1262 | /* the rest of the roms match Gals Panic S2, but are in different locations */ | |
| 1263 | ROM_REGION( 0x1000000, REGION_GFX1, 0 ) | |
| 1264 | ROM_LOAD( "24", 0x000000, 0x400000, CRC(294b2f14) SHA1(90cbd0acdaa2d89d208c28aae33ab57c03624089) ) | |
| 1265 | ROM_LOAD( "20", 0x400000, 0x400000, CRC(f75c5a9a) SHA1(3919643cee6c88185a1aa3c58c5bc80599bf734e) ) | |
| 1266 | ROM_LOAD( "17", 0x800000, 0x400000, CRC(25b4f56b) SHA1(f9a33d5ed54a04ecece3035e75508d191bbe74b1) ) | |
| 1267 | ROM_LOAD( "32", 0xc00000, 0x400000, CRC(db6d4424) SHA1(0a88dafd0ee2490ff2ef39ce8eb1931c41bdda42) ) | |
| 1268 | ||
| 1269 | ROM_REGION( 0x800000, REGION_GFX2, ROMREGION_DISPOSE ) | |
| 1270 | ROM_LOAD( "16", 0x000000, 0x400000, CRC(5caae1c0) SHA1(8f77e4cf018d7290b2d804cbff9fccf0bf4d2404) ) | |
| 1271 | ROM_LOAD( "13", 0x400000, 0x400000, CRC(8d51f197) SHA1(19d2afab823ea179918e7bcbf4df2283e77570f0) ) | |
| 1272 | ||
| 1273 | ROM_REGION( 0x800000, REGION_GFX3, ROMREGION_ERASE00 ) /* Tiles Plane B */ | |
| 1274 | /* First 0x040000 bytes (0x03ff Tiles) are RAM Based Tiles */ | |
| 1275 | /* 0x040000 - 0x3fffff empty? */ | |
| 1276 | ROM_LOAD( "7", 0x400000, 0x400000, CRC(58800a18) SHA1(5e6d55ecd12275662d6f59559e137b759f23fff6) ) | |
| 1277 | ||
| 1278 | ROM_REGION( 0x400000, REGION_SOUND1, 0 ) /* Samples */ | |
| 1279 | ROM_LOAD( "4", 0x000000, 0x400000, CRC(0348e8e1) SHA1(8a21c7e5cea0bc08a2595213d689c58c0251fdb5) ) | |
| 1280 | ROM_END | |
| 1281 | ||
| 1282 | ||
| 1236 | 1283 | ROM_START( gutsn ) |
| 1237 | 1284 | ROM_REGION( 0x080000, REGION_CPU1, 0 ) /* SH-2 Code */ |
| 1238 | 1285 | ROM_LOAD ( "sknsj1.u10", 0x000000, 0x080000, CRC(7e2b836c) SHA1(92c5a7a2472496028bff0e5980d41dd294f42144) ) /* Japan BIOS */ |
| r2724 | r2725 | |
| 1604 | 1651 | GAME( 1997, galpanis, skns, skns, galpanis, galpanis, ROT0, "Kaneko", "Gals Panic S - Extra Edition (Japan)", GAME_IMPERFECT_GRAPHICS ) |
| 1605 | 1652 | GAME( 1998, cyvern, skns, skns, cyvern, cyvern, ROT90, "Kaneko", "Cyvern (Japan)", GAME_IMPERFECT_GRAPHICS ) |
| 1606 | 1653 | GAME( 1999, galpans2, skns, skns, galpanis, galpans2, ROT0, "Kaneko", "Gals Panic S2 (Japan)", GAME_IMPERFECT_GRAPHICS ) |
| 1654 | GAME( 1999, galpansu, galpans2,skns, galpanis, galpans2, ROT0, "Kaneko", "Gals Panic SU (Korea)", GAME_IMPERFECT_GRAPHICS ) // official or hack? | |
| 1607 | 1655 | GAME( 1999, panicstr, skns, skns, galpanis, panicstr, ROT0, "Kaneko", "Panic Street (Japan)", GAME_IMPERFECT_GRAPHICS ) |
| 1608 | 1656 | GAME( 1999, senknow , skns, skns, skns, senknow, ROT0, "Kaneko / Kouyousha", "Sen-Know (Japan)", GAME_IMPERFECT_GRAPHICS ) |
| 1609 | 1657 | GAME( 2000, gutsn, skns, skns, skns, gutsn, ROT0, "Kaneko / Kouyousha", "Guts'n (Japan)", GAME_IMPERFECT_GRAPHICS ) // quite fragile, started working of it's own accord in 0.69 :) |
| r2724 | r2725 | |
|---|---|---|
| 686 | 686 | |
| 687 | 687 | static READ16_HANDLER( pzlbowl_coins_r ) |
| 688 | 688 | { |
| 689 | return input_port_read_indexed(machine, 4) | (mame_rand( | |
| 689 | return input_port_read_indexed(machine, 4) | (mame_rand(machine) & 0x80 ); | |
| 690 | 690 | } |
| 691 | 691 | |
| 692 | 692 | static WRITE16_HANDLER( pzlbowl_coin_counter_w ) |
| r2724 | r2725 | |
| 1785 | 1785 | { |
| 1786 | 1786 | case 0: |
| 1787 | 1787 | /* VBlank is connected to INT0 (external interrupts pin 0) */ |
| 1788 | tmp68301_external_interrupt_0(); | |
| 1788 | tmp68301_external_interrupt_0(machine); | |
| 1789 | 1789 | break; |
| 1790 | 1790 | } |
| 1791 | 1791 | } |
| r2724 | r2725 | |
| 1795 | 1795 | switch ( cpu_getiloops() ) |
| 1796 | 1796 | { |
| 1797 | 1797 | case 0: |
| 1798 | tmp68301_external_interrupt_0(); // vblank | |
| 1798 | tmp68301_external_interrupt_0(machine); // vblank | |
| 1799 | 1799 | break; |
| 1800 | 1800 | case 1: |
| 1801 | tmp68301_external_interrupt_2(); // to do: hook up x1-10 interrupts | |
| 1801 | tmp68301_external_interrupt_2(machine); // to do: hook up x1-10 interrupts | |
| 1802 | 1802 | break; |
| 1803 | 1803 | } |
| 1804 | 1804 | } |
| r2724 | r2725 | |
|---|---|---|
| 99 | 99 | static UINT8 dynax_vblank_irq; |
| 100 | 100 | |
| 101 | 101 | /* It runs in IM 0, thus needs an opcode on the data bus */ |
| 102 | void sprtmtch_update_irq( | |
| 102 | void sprtmtch_update_irq(running_machine *machine) | |
| 103 | 103 | { |
| 104 | 104 | int irq = ((dynax_sound_irq) ? 0x08 : 0) | |
| 105 | 105 | ((dynax_vblank_irq) ? 0x10 : 0) | |
| 106 | 106 | ((dynax_blitter_irq) ? 0x20 : 0) ; |
| 107 | cpunum_set_input_line_and_vector( | |
| 107 | cpunum_set_input_line_and_vector(machine, 0, 0, irq ? ASSERT_LINE : CLEAR_LINE, 0xc7 | irq); /* rst $xx */ | |
| 108 | 108 | } |
| 109 | 109 | |
| 110 | 110 | static WRITE8_HANDLER( dynax_vblank_ack_w ) |
| 111 | 111 | { |
| 112 | 112 | dynax_vblank_irq = 0; |
| 113 | sprtmtch_update_irq(); | |
| 113 | sprtmtch_update_irq(machine); | |
| 114 | 114 | } |
| 115 | 115 | |
| 116 | 116 | static WRITE8_HANDLER( dynax_blitter_ack_w ) |
| 117 | 117 | { |
| 118 | 118 | dynax_blitter_irq = 0; |
| 119 | sprtmtch_update_irq(); | |
| 119 | sprtmtch_update_irq(machine); | |
| 120 | 120 | } |
| 121 | 121 | |
| 122 | 122 | static INTERRUPT_GEN( sprtmtch_vblank_interrupt ) |
| 123 | 123 | { |
| 124 | 124 | dynax_vblank_irq = 1; |
| 125 | sprtmtch_update_irq(); | |
| 125 | sprtmtch_update_irq(machine); | |
| 126 | 126 | } |
| 127 | 127 | |
| 128 | static void sprtmtch_sound_callback(int state) | |
| 128 | static void sprtmtch_sound_callback(running_machine *machine, int state) | |
| 129 | 129 | { |
| 130 | 130 | dynax_sound_irq = state; |
| 131 | sprtmtch_update_irq(); | |
| 131 | sprtmtch_update_irq(machine); | |
| 132 | 132 | } |
| 133 | 133 | |
| 134 | 134 | |
| r2724 | r2725 | |
| 139 | 139 | UINT8 dynax_blitter2_irq; |
| 140 | 140 | |
| 141 | 141 | /* It runs in IM 0, thus needs an opcode on the data bus */ |
| 142 | void jantouki_update_irq( | |
| 142 | void jantouki_update_irq(running_machine *machine) | |
| 143 | 143 | { |
| 144 | 144 | int irq = ((dynax_blitter_irq) ? 0x08 : 0) | |
| 145 | 145 | ((dynax_blitter2_irq) ? 0x10 : 0) | |
| 146 | 146 | ((dynax_vblank_irq) ? 0x20 : 0) ; |
| 147 | cpunum_set_input_line_and_vector( | |
| 147 | cpunum_set_input_line_and_vector(machine, 0, 0, irq ? ASSERT_LINE : CLEAR_LINE, 0xc7 | irq); /* rst $xx */ | |
| 148 | 148 | } |
| 149 | 149 | |
| 150 | 150 | static WRITE8_HANDLER( jantouki_vblank_ack_w ) |
| 151 | 151 | { |
| 152 | 152 | dynax_vblank_irq = 0; |
| 153 | jantouki_update_irq(); | |
| 153 | jantouki_update_irq(machine); | |
| 154 | 154 | } |
| 155 | 155 | |
| 156 | 156 | static WRITE8_HANDLER( jantouki_blitter_ack_w ) |
| 157 | 157 | { |
| 158 | 158 | dynax_blitter_irq = data; |
| 159 | jantouki_update_irq(); | |
| 159 | jantouki_update_irq(machine); | |
| 160 | 160 | } |
| 161 | 161 | |
| 162 | 162 | static WRITE8_HANDLER( jantouki_blitter2_ack_w ) |
| 163 | 163 | { |
| 164 | 164 | dynax_blitter2_irq = data; |
| 165 | jantouki_update_irq(); | |
| 165 | jantouki_update_irq(machine); | |
| 166 | 166 | } |
| 167 | 167 | |
| 168 | 168 | static INTERRUPT_GEN( jantouki_vblank_interrupt ) |
| 169 | 169 | { |
| 170 | 170 | dynax_vblank_irq = 1; |
| 171 | jantouki_update_irq(); | |
| 171 | jantouki_update_irq(machine); | |
| 172 | 172 | } |
| 173 | 173 | |
| 174 | 174 | |
| r2724 | r2725 | |
| 179 | 179 | static UINT8 dynax_soundlatch_irq; |
| 180 | 180 | static UINT8 dynax_sound_vblank_irq; |
| 181 | 181 | |
| 182 | static void jantouki_sound_update_irq( | |
| 182 | static void jantouki_sound_update_irq(running_machine *machine) | |
| 183 | 183 | { |
| 184 | 184 | int irq = ((dynax_sound_irq) ? 0x08 : 0) | |
| 185 | 185 | ((dynax_soundlatch_irq) ? 0x10 : 0) | |
| 186 | 186 | ((dynax_sound_vblank_irq) ? 0x20 : 0) ; |
| 187 | cpunum_set_input_line_and_vector( | |
| 187 | cpunum_set_input_line_and_vector(machine, 1, 0, irq ? ASSERT_LINE : CLEAR_LINE, 0xc7 | irq); /* rst $xx */ | |
| 188 | 188 | } |
| 189 | 189 | |
| 190 | 190 | static INTERRUPT_GEN( jantouki_sound_vblank_interrupt ) |
| 191 | 191 | { |
| 192 | 192 | dynax_sound_vblank_irq = 1; |
| 193 | jantouki_sound_update_irq(); | |
| 193 | jantouki_sound_update_irq(machine); | |
| 194 | 194 | } |
| 195 | 195 | |
| 196 | 196 | static WRITE8_HANDLER( jantouki_sound_vblank_ack_w ) |
| 197 | 197 | { |
| 198 | 198 | dynax_sound_vblank_irq = 0; |
| 199 | jantouki_sound_update_irq(); | |
| 199 | jantouki_sound_update_irq(machine); | |
| 200 | 200 | } |
| 201 | 201 | |
| 202 | static void jantouki_sound_callback(int state) | |
| 202 | static void jantouki_sound_callback(running_machine *machine, int state) | |
| 203 | 203 | { |
| 204 | 204 | dynax_sound_irq = state; |
| 205 | jantouki_sound_update_irq(); | |
| 205 | jantouki_sound_update_irq(machine); | |
| 206 | 206 | } |
| 207 | 207 | |
| 208 | 208 | |
| r2724 | r2725 | |
| 396 | 396 | static int msm5205next; |
| 397 | 397 | static int resetkludge; |
| 398 | 398 | |
| 399 | static void adpcm_int(int data) | |
| 399 | static void adpcm_int(running_machine *machine, int data) | |
| 400 | 400 | { |
| 401 | 401 | static int toggle; |
| 402 | 402 | |
| r2724 | r2725 | |
| 407 | 407 | if (toggle) |
| 408 | 408 | { |
| 409 | 409 | if (resetkludge) // don't know what's wrong, but NMIs when the 5205 is reset make the game crash |
| 410 | cpunum_set_input_line( | |
| 410 | cpunum_set_input_line(machine, 0, INPUT_LINE_NMI, PULSE_LINE); | |
| 411 | 411 | } |
| 412 | 412 | } |
| 413 | static void adpcm_int_cpu1(int data) | |
| 413 | static void adpcm_int_cpu1(running_machine *machine, int data) | |
| 414 | 414 | { |
| 415 | 415 | static int toggle; |
| 416 | 416 | |
| r2724 | r2725 | |
| 421 | 421 | if (toggle) |
| 422 | 422 | { |
| 423 | 423 | if (resetkludge) // don't know what's wrong, but NMIs when the 5205 is reset make the game crash |
| 424 | cpunum_set_input_line( | |
| 424 | cpunum_set_input_line(machine, 1, INPUT_LINE_NMI, PULSE_LINE); // cpu1 | |
| 425 | 425 | } |
| 426 | 426 | } |
| 427 | 427 | |
| r2724 | r2725 | |
| 863 | 863 | dynax_soundlatch_full = 1; |
| 864 | 864 | dynax_soundlatch_irq = 1; |
| 865 | 865 | latch = data; |
| 866 | jantouki_sound_update_irq(); | |
| 866 | jantouki_sound_update_irq(machine); | |
| 867 | 867 | } |
| 868 | 868 | |
| 869 | 869 | static READ8_HANDLER( jantouki_blitter_busy_r ) |
| r2724 | r2725 | |
| 919 | 919 | { |
| 920 | 920 | dynax_soundlatch_ack = data; |
| 921 | 921 | dynax_soundlatch_irq = 0; |
| 922 | jantouki_sound_update_irq(); | |
| 922 | jantouki_sound_update_irq(machine); | |
| 923 | 923 | } |
| 924 | 924 | |
| 925 | 925 | static READ8_HANDLER( jantouki_soundlatch_r ) |
| r2724 | r2725 | |
| 3829 | 3829 | dynax_sound_irq = 1; |
| 3830 | 3830 | } |
| 3831 | 3831 | |
| 3832 | sprtmtch_update_irq(); | |
| 3832 | sprtmtch_update_irq(machine); | |
| 3833 | 3833 | } |
| 3834 | 3834 | |
| 3835 | 3835 | static MACHINE_DRIVER_START( yarunara ) |
| r2724 | r2725 | |
| 3970 | 3970 | /* It runs in IM 2, thus needs a vector on the data bus: |
| 3971 | 3971 | 0xfa and 0xfc are very similar, they should be triggered by the blitter |
| 3972 | 3972 | 0xf8 is vblank */ |
| 3973 | void mjelctrn_update_irq( | |
| 3973 | void mjelctrn_update_irq(running_machine *machine) | |
| 3974 | 3974 | { |
| 3975 | 3975 | dynax_blitter_irq = 1; |
| 3976 | cpunum_set_input_line_and_vector( | |
| 3976 | cpunum_set_input_line_and_vector(machine, 0, 0, HOLD_LINE, 0xfa); | |
| 3977 | 3977 | } |
| 3978 | 3978 | |
| 3979 | 3979 | static INTERRUPT_GEN( mjelctrn_vblank_interrupt ) |
| r2724 | r2725 | |
| 4004 | 4004 | 0x42 and 0x44 are very similar, they should be triggered by the blitter |
| 4005 | 4005 | 0x40 is vblank |
| 4006 | 4006 | 0x46 is a periodic irq? */ |
| 4007 | void neruton_update_irq( | |
| 4007 | void neruton_update_irq(running_machine *machine) | |
| 4008 | 4008 | { |
| 4009 | 4009 | dynax_blitter_irq = 1; |
| 4010 | cpunum_set_input_line_and_vector( | |
| 4010 | cpunum_set_input_line_and_vector(machine, 0, 0, HOLD_LINE, 0x42); | |
| 4011 | 4011 | } |
| 4012 | 4012 | |
| 4013 | 4013 | static INTERRUPT_GEN( neruton_vblank_interrupt ) |
| r2724 | r2725 | |
|---|---|---|
| 38 | 38 | */ |
| 39 | 39 | |
| 40 | 40 | #include "driver.h" |
| 41 | #include "deprecat.h" | |
| 42 | 41 | #include "cpu/m6502/m6502.h" |
| 43 | 42 | #include "sound/2203intf.h" |
| 44 | 43 | |
| r2724 | r2725 | |
| 263 | 262 | GFXDECODE_ENTRY( REGION_GFX3, 0, tile_layout, 0, 16 ) /* tiles */ |
| 264 | 263 | GFXDECODE_END |
| 265 | 264 | |
| 266 | static void shootout_snd_irq(int linestate) | |
| 265 | static void shootout_snd_irq(running_machine *machine, int linestate) | |
| 267 | 266 | { |
| 268 | cpunum_set_input_line( | |
| 267 | cpunum_set_input_line(machine, 1,0,linestate); | |
| 269 | 268 | } |
| 270 | 269 | |
| 271 | static void shootout_snd2_irq(int linestate) | |
| 270 | static void shootout_snd2_irq(running_machine *machine, int linestate) | |
| 272 | 271 | { |
| 273 | cpunum_set_input_line( | |
| 272 | cpunum_set_input_line(machine, 0,0,linestate); | |
| 274 | 273 | } |
| 275 | 274 | |
| 276 | 275 | static const struct YM2203interface ym2203_interface = |
| r2724 | r2725 | |
|---|---|---|
| 199 | 199 | { |
| 200 | 200 | if( m_b_lastclock ) |
| 201 | 201 | { |
| 202 | psx_sio_input( 0, PSX_SIO_IN_DATA, ( znsec_step( 0, ( n_data & PSX_SIO_OUT_DATA ) / PSX_SIO_OUT_DATA ) & 1 ) * PSX_SIO_IN_DATA ); | |
| 202 | psx_sio_input( Machine, 0, PSX_SIO_IN_DATA, ( znsec_step( 0, ( n_data & PSX_SIO_OUT_DATA ) / PSX_SIO_OUT_DATA ) & 1 ) * PSX_SIO_IN_DATA ); | |
| 203 | 203 | } |
| 204 | 204 | m_b_lastclock = 0; |
| 205 | 205 | } |
| r2724 | r2725 | |
| 215 | 215 | { |
| 216 | 216 | if( m_b_lastclock ) |
| 217 | 217 | { |
| 218 | psx_sio_input( 0, PSX_SIO_IN_DATA, ( znsec_step( 1, ( n_data & PSX_SIO_OUT_DATA ) / PSX_SIO_OUT_DATA ) & 1 ) * PSX_SIO_IN_DATA ); | |
| 218 | psx_sio_input( Machine, 0, PSX_SIO_IN_DATA, ( znsec_step( 1, ( n_data & PSX_SIO_OUT_DATA ) / PSX_SIO_OUT_DATA ) & 1 ) * PSX_SIO_IN_DATA ); | |
| 219 | 219 | } |
| 220 | 220 | m_b_lastclock = 0; |
| 221 | 221 | } |
| r2724 | r2725 | |
| 237 | 237 | } |
| 238 | 238 | |
| 239 | 239 | verboselog( 2, "read pad %04x %04x %02x\n", m_n_znsecsel, m_b_znsecport, n_data ); |
| 240 | psx_sio_input( 0, PSX_SIO_IN_DATA | PSX_SIO_IN_DSR, PSX_SIO_IN_DATA | PSX_SIO_IN_DSR ); | |
| 240 | psx_sio_input( Machine, 0, PSX_SIO_IN_DATA | PSX_SIO_IN_DSR, PSX_SIO_IN_DATA | PSX_SIO_IN_DSR ); | |
| 241 | 241 | } |
| 242 | 242 | |
| 243 | 243 | static void sio_dip_handler( int n_data ) |
| r2724 | r2725 | |
| 247 | 247 | if( m_b_lastclock ) |
| 248 | 248 | { |
| 249 | 249 | verboselog( 2, "read dip %02x -> %02x\n", n_data, ( ( input_port_read_indexed(Machine, 7 ) >> m_n_dip_bit ) & 1 ) * PSX_SIO_IN_DATA ); |
| 250 | psx_sio_input( 0, PSX_SIO_IN_DATA, ( ( input_port_read_indexed(Machine, 7 ) >> m_n_dip_bit ) & 1 ) * PSX_SIO_IN_DATA ); | |
| 250 | psx_sio_input( Machine, 0, PSX_SIO_IN_DATA, ( ( input_port_read_indexed(Machine, 7 ) >> m_n_dip_bit ) & 1 ) * PSX_SIO_IN_DATA ); | |
| 251 | 251 | m_n_dip_bit++; |
| 252 | 252 | m_n_dip_bit &= 7; |
| 253 | 253 | } |
| r2724 | r2725 | |
| 391 | 391 | n_game = 0; |
| 392 | 392 | while( zn_config_table[ n_game ].s_name != NULL ) |
| 393 | 393 | { |
| 394 | if( strcmp( | |
| 394 | if( strcmp( machine->gamedrv->name, zn_config_table[ n_game ].s_name ) == 0 ) | |
| 395 | 395 | { |
| 396 | 396 | znsec_init( 0, zn_config_table[ n_game ].p_n_mainsec ); |
| 397 | 397 | znsec_init( 1, zn_config_table[ n_game ].p_n_gamesec ); |
| r2724 | r2725 | |
| 1269 | 1269 | ADDRESS_MAP_END |
| 1270 | 1270 | |
| 1271 | 1271 | /* handler called by the YM2610 emulator when the internal timers cause an IRQ */ |
| 1272 | static void irq_handler(int irq) | |
| 1272 | static void irq_handler(running_machine *machine, int irq) | |
| 1273 | 1273 | { |
| 1274 | cpunum_set_input_line( | |
| 1274 | cpunum_set_input_line(machine, 1,0,irq ? ASSERT_LINE : CLEAR_LINE); | |
| 1275 | 1275 | } |
| 1276 | 1276 | |
| 1277 | 1277 | static const struct YM2610interface ym2610_interface = |
| r2724 | r2725 | |
| 1653 | 1653 | *2 - Unpopulated DIP28 socket |
| 1654 | 1654 | */ |
| 1655 | 1655 | |
| 1656 | static void atpsx_interrupt(const device_config * | |
| 1656 | static void atpsx_interrupt(const device_config *dev | |
| 1657 | 1657 | { |
| 1658 | 1658 | if (state) |
| 1659 | 1659 | { |
| 1660 | psx_irq_set(0x400); | |
| 1660 | psx_irq_set(device->machine, 0x400); | |
| 1661 | 1661 | } |
| 1662 | 1662 | } |
| 1663 | 1663 | |
| r2724 | r2725 | |
| 2117 | 2117 | { |
| 2118 | 2118 | if (state) |
| 2119 | 2119 | { |
| 2120 | psx_irq_set(0x400); | |
| 2120 | psx_irq_set(device->machine, 0x400); | |
| 2121 | 2121 | } |
| 2122 | 2122 | } |
| 2123 | 2123 | |
| r2724 | r2725 | |
| 2181 | 2181 | static WRITE32_HANDLER( nbajamex_80_w ) |
| 2182 | 2182 | { |
| 2183 | 2183 | verboselog( 0, "nbajamex_80_w( %08x, %08x, %08x )\n", offset, data, mem_mask ); |
| 2184 | psx_irq_set(0x400); | |
| 2184 | psx_irq_set(machine, 0x400); | |
| 2185 | 2185 | } |
| 2186 | 2186 | |
| 2187 | 2187 | static READ32_HANDLER( nbajamex_08_r ) |
| r2724 | r2725 | |
|---|---|---|
| 40 | 40 | ********************************************************************/ |
| 41 | 41 | |
| 42 | 42 | #include "driver.h" |
| 43 | #include "deprecat.h" | |
| 44 | 43 | #include "taitoipt.h" |
| 45 | 44 | #include "video/taitoic.h" |
| 46 | 45 | #include "audio/taitosnd.h" |
| r2724 | r2725 | |
| 215 | 214 | |
| 216 | 215 | /* handler called by the YM2203 emulator when the internal timers cause an IRQ */ |
| 217 | 216 | |
| 218 | static void irqhandler(int irq) | |
| 217 | static void irqhandler(running_machine *machine, int irq) | |
| 219 | 218 | { |
| 220 | cpunum_set_input_line( | |
| 219 | cpunum_set_input_line(machine, 1, 0, irq ? ASSERT_LINE : CLEAR_LINE); | |
| 221 | 220 | } |
| 222 | 221 | |
| 223 | 222 | static const struct YM2203interface ym2203_interface = |
| r2724 | r2725 | |
|---|---|---|
| 53 | 53 | |
| 54 | 54 | #define MEGADRIV_VDP_VRAM(address) megadrive_vdp_vram[(address)&0x7fff] |
| 55 | 55 | |
| 56 | #ifdef MESS | |
| 57 | extern void setup_megadriv_custom_mappers(running_machine *); | |
| 58 | #endif | |
| 59 | ||
| 60 | 56 | /* the same on all systems? */ |
| 61 | 57 | #define MASTER_CLOCK 53693100 |
| 62 | 58 | /* timing details */ |
| r2724 | r2725 | |
| 1305 | 1301 | case 0x06: |
| 1306 | 1302 | // if ((!ACCESSING_BITS_8_15) || (!ACCESSING_BITS_0_7)) mame_printf_debug("8-bit VDP read control port access, offset %04x mem_mask %04x\n",offset,mem_mask); |
| 1307 | 1303 | retvalue = megadriv_vdp_ctrl_port_r(); |
| 1308 | // retvalue = mame_rand( | |
| 1304 | // retvalue = mame_rand(machine); | |
| 1309 | 1305 | // mame_printf_debug("%06x: Read Control Port at scanline %d hpos %d (return %04x)\n",activecpu_get_pc(),genesis_scanline_counter, get_hposition(),retvalue); |
| 1310 | 1306 | break; |
| 1311 | 1307 | |
| r2724 | r2725 | |
| 1315 | 1311 | case 0x0e: |
| 1316 | 1312 | // if ((!ACCESSING_BITS_8_15) || (!ACCESSING_BITS_0_7)) mame_printf_debug("8-bit VDP read HV counter port access, offset %04x mem_mask %04x\n",offset,mem_mask); |
| 1317 | 1313 | retvalue = megadriv_read_hv_counters(); |
| 1318 | // retvalue = mame_rand( | |
| 1314 | // retvalue = mame_rand(machine); | |
| 1319 | 1315 | // mame_printf_debug("%06x: Read HV counters at scanline %d hpos %d (return %04x)\n",activecpu_get_pc(),genesis_scanline_counter, get_hposition(),retvalue); |
| 1320 | 1316 | break; |
| 1321 | 1317 | |
| r2724 | r2725 | |
| 1971 | 1967 | D0 : Bit 0 of version number |
| 1972 | 1968 | */ |
| 1973 | 1969 | |
| 1974 | //return (mame_rand( | |
| 1970 | //return (mame_rand(machine)&0x0f0f)|0xf0f0;//0x0000; | |
| 1975 | 1971 | switch (offset) |
| 1976 | 1972 | { |
| 1977 | 1973 | case 0: |
| r2724 | r2725 | |
| 2182 | 2178 | else |
| 2183 | 2179 | { |
| 2184 | 2180 | logerror("%06x: 68000 attempting to access Z80 (read) address space without bus\n", activecpu_get_pc()); |
| 2185 | return mame_rand( | |
| 2181 | return mame_rand(machine); | |
| 2186 | 2182 | } |
| 2187 | 2183 | } |
| 2188 | 2184 | |
| r2724 | r2725 | |
| 2224 | 2220 | the value is never zero. Time Killers is the most fussy, and doesn't like the |
| 2225 | 2221 | read_next_instruction function from system16, so I just return a random value |
| 2226 | 2222 | in the unused bits */ |
| 2227 | UINT16 nextvalue = mame_rand( | |
| 2223 | UINT16 nextvalue = mame_rand(machine);//read_next_instruction()&0xff00; | |
| 2228 | 2224 | |
| 2229 | 2225 | |
| 2230 | 2226 | /* Check if the 68k has the z80 bus */ |
| r2724 | r2725 | |
| 2435 | 2431 | static READ8_HANDLER( megadriv_z80_vdp_read ) |
| 2436 | 2432 | { |
| 2437 | 2433 | mame_printf_debug("megadriv_z80_vdp_read %02x\n",offset); |
| 2438 | return mame_rand( | |
| 2434 | return mame_rand(machine); | |
| 2439 | 2435 | } |
| 2440 | 2436 | |
| 2441 | 2437 | static READ8_HANDLER( megadriv_z80_unmapped_read ) |
| r2724 | r2725 | |
| 2476 | 2472 | |
| 2477 | 2473 | static READ16_HANDLER( _32x_reg_r ) |
| 2478 | 2474 | { |
| 2479 | return mame_rand( | |
| 2475 | return mame_rand(machine); | |
| 2480 | 2476 | } |
| 2481 | 2477 | |
| 2482 | 2478 | static UINT16 _32x_68k_comms[0x8]; |
| r2724 | r2725 | |
| 4320 | 4316 | |
| 4321 | 4317 | case 0xa000: // shadow set, highlight set - not possible |
| 4322 | 4318 | case 0xe000: // shadow set, highlight set, normal set, not possible |
| 4323 | lineptr[x] = megadrive_vdp_palette_lookup_highlight[mame_rand( | |
| 4319 | lineptr[x] = megadrive_vdp_palette_lookup_highlight[mame_rand(machine)&0x3f]; | |
| 4324 | 4320 | break; |
| 4325 | 4321 | |
| 4326 | 4322 | |
| r2724 | r2725 | |
| 4820 | 4816 | |
| 4821 | 4817 | memset(megadrive_ram,0x00,0x10000); |
| 4822 | 4818 | |
| 4823 | #ifdef MESS | |
| 4824 | setup_megadriv_custom_mappers(machine); | |
| 4825 | #endif | |
| 4826 | 4819 | |
| 4827 | 4820 | } |
| 4828 | 4821 | |
| r2724 | r2725 | |
| 5012 | 5005 | { |
| 5013 | 5006 | int x; |
| 5014 | 5007 | for (x=0;x<megadriv_backupram_length/2;x++) |
| 5015 | megadriv_backupram[x]=0xffff;//mame_rand( | |
| 5008 | megadriv_backupram[x]=0xffff;//mame_rand(machine); // dino dini's needs 0xff or game rules are broken | |
| 5016 | 5009 | } |
| 5017 | 5010 | } |
| 5018 | 5011 | } |
| r2724 | r2725 | |
|---|---|---|
| 631 | 631 | * |
| 632 | 632 | *************************************/ |
| 633 | 633 | |
| 634 | static void via_irq(int state) | |
| 634 | static void via_irq(running_machine *machine, int state) | |
| 635 | 635 | { |
| 636 | 636 | if (state) |
| 637 | cpunum_set_input_line( | |
| 637 | cpunum_set_input_line(machine, 1, M6809_FIRQ_LINE, ASSERT_LINE); | |
| 638 | 638 | else |
| 639 | cpunum_set_input_line( | |
| 639 | cpunum_set_input_line(machine, 1, M6809_FIRQ_LINE, CLEAR_LINE); | |
| 640 | 640 | } |
| 641 | 641 | |
| 642 | 642 | |
| r2724 | r2725 | |
| 781 | 781 | else |
| 782 | 782 | { |
| 783 | 783 | for (i = 0x80; i < main_ram_size; i++) |
| 784 | ((UINT8 *)main_ram)[i] = mame_rand( | |
| 784 | ((UINT8 *)main_ram)[i] = mame_rand(machine); | |
| 785 | 785 | |
| 786 | 786 | /* due to accessing uninitialized RAM, we need this hack */ |
| 787 | 787 | if (is_drivedge) |
| r2724 | r2725 | |
| 801 | 801 | else |
| 802 | 802 | { |
| 803 | 803 | for (i = 0; i < nvram_size; i++) |
| 804 | ((UINT8 *)nvram)[i] = mame_rand( | |
| 804 | ((UINT8 *)nvram)[i] = mame_rand(machine); | |
| 805 | 805 | } |
| 806 | 806 | } |
| 807 | 807 |
| r2724 | r2725 | |
|---|---|---|
| 82 | 82 | */ |
| 83 | 83 | |
| 84 | 84 | #include "driver.h" |
| 85 | #include "deprecat.h" | |
| 86 | 85 | #include "cpu/upd7810/upd7810.h" |
| 87 | 86 | #include "sound/okim6295.h" |
| 88 | 87 | |
| r2724 | r2725 | |
| 234 | 233 | static READ8_HANDLER(snd_porta_r) |
| 235 | 234 | { |
| 236 | 235 | //mame_printf_debug("PA R @%x\n",activecpu_get_pc()); |
| 237 | return mame_rand( | |
| 236 | return mame_rand(machine); | |
| 238 | 237 | } |
| 239 | 238 | |
| 240 | 239 | static READ8_HANDLER(snd_portb_r) |
| 241 | 240 | { |
| 242 | 241 | //mame_printf_debug("PB R @%x\n",activecpu_get_pc()); |
| 243 | return mame_rand( | |
| 242 | return mame_rand(machine); | |
| 244 | 243 | } |
| 245 | 244 | |
| 246 | 245 | static READ8_HANDLER(snd_portc_r) |
| 247 | 246 | { |
| 248 | 247 | //mame_printf_debug("PC R @%x\n",activecpu_get_pc()); |
| 249 | return mame_rand( | |
| 248 | return mame_rand(machine); | |
| 250 | 249 | } |
| 251 | 250 | |
| 252 | 251 | static WRITE8_HANDLER(snd_porta_w) |
| r2724 | r2725 | |
|---|---|---|
| 381 | 381 | |
| 382 | 382 | static READ8_HANDLER( kludge_r ) |
| 383 | 383 | { |
| 384 | return mame_rand( | |
| 384 | return mame_rand(machine); | |
| 385 | 385 | } |
| 386 | 386 | |
| 387 | 387 | static PIT8253_OUTPUT_CHANGED( pc_timer0_w ) |
| r2724 | r2725 | |
|---|---|---|
| 77 | 77 | *************************************************************************/ |
| 78 | 78 | |
| 79 | 79 | #include "driver.h" |
| 80 | #include "deprecat.h" | |
| 81 | 80 | #include "sound/2203intf.h" |
| 82 | 81 | #include "sound/msm5205.h" |
| 83 | 82 | |
| r2724 | r2725 | |
| 146 | 145 | /* FIXME: earlier attemts to remove ? |
| 147 | 146 | return 1; |
| 148 | 147 | return 0; |
| 149 | return mame_rand( | |
| 148 | return mame_rand(machine); | |
| 150 | 149 | */ |
| 151 | 150 | } |
| 152 | 151 | |
| r2724 | r2725 | |
| 290 | 289 | GFXDECODE_ENTRY( REGION_GFX5, 0, tiles16x16_layout, 0, 0x100 ) |
| 291 | 290 | GFXDECODE_END |
| 292 | 291 | |
| 293 | static void irqhandler(int irq) | |
| 292 | static void irqhandler(running_machine *machine, int irq) | |
| 294 | 293 | { |
| 295 | cpunum_set_input_line( | |
| 294 | cpunum_set_input_line(machine, 1,0,irq ? ASSERT_LINE : CLEAR_LINE); | |
| 296 | 295 | } |
| 297 | 296 | |
| 298 | 297 | static WRITE8_HANDLER(writeA) |
| r2724 | r2725 | |
| 307 | 306 | memory_set_bankptr(4, memory_region(REGION_SOUND1) + ((data & 0xf) * 0x8000)); |
| 308 | 307 | } |
| 309 | 308 | |
| 310 | static void ashnojoe_adpcm_int (int data) | |
| 309 | static void ashnojoe_adpcm_int (running_machine *machine, int data) | |
| 311 | 310 | { |
| 312 | cpunum_set_input_line( | |
| 311 | cpunum_set_input_line(machine, 1, INPUT_LINE_NMI, PULSE_LINE); | |
| 313 | 312 | } |
| 314 | 313 | |
| 315 | 314 | static const struct MSM5205interface msm5205_interface = |
| r2724 | r2725 | |
|---|---|---|
| 600 | 600 | PORT_BIT( 0xff, 0x80, IPT_LIGHTGUN_Y ) PORT_CROSSHAIR(Y, 1.0, 0.0, 0) PORT_SENSITIVITY(20) PORT_KEYDELTA(25) PORT_PLAYER(2) |
| 601 | 601 | |
| 602 | 602 | PORT_START_TAG("FAKE") |
| 603 | PORT_ | |
| 603 | PORT_DIPNAME( | |
| 604 | 604 | PORT_DIPSETTING( 0x00, DEF_STR( No ) ) |
| 605 | 605 | PORT_DIPSETTING( 0x01, DEF_STR( Yes ) ) |
| 606 | 606 | INPUT_PORTS_END |
| r2724 | r2725 | |
| 1024 | 1024 | GAME( 1993, undrfire, 0, undrfire, undrfire, undrfire, ROT0, "Taito Corporation Japan", "Under Fire (World)", 0 ) |
| 1025 | 1025 | GAME( 1993, undrfiru, undrfire, undrfire, undrfire, undrfire, ROT0, "Taito America Corporation", "Under Fire (US)", 0 ) |
| 1026 | 1026 | GAME( 1993, undrfirj, undrfire, undrfire, undrfire, undrfire, ROT0, "Taito Corporation", "Under Fire (Japan)", 0 ) |
| 1027 | GAME( 1994, cbombers, 0, cbombers, cbombers, cbombers, ROT0, "Taito Corporation", "Chase Bombers", | |
| 1027 | GAME( 1994, cbombers, 0, cbombers, cbombers, cbombers, ROT0, "Taito Corporation", "Chase Bombers", GAME_IMPERFECT_GRAPHICS ) |
| r2724 | r2725 | |
|---|---|---|
| 381 | 381 | static READ32_HANDLER( lockload_gun_mirror_r ) |
| 382 | 382 | { |
| 383 | 383 | //logerror("%08x:Read gun %d\n",activecpu_get_pc(),offset); |
| 384 | //return ((mame_rand( | |
| 384 | //return ((mame_rand(machine)%0xffff)<<16) | mame_rand(machine)%0xffff; | |
| 385 | 385 | if (offset) /* Mirror of player 1 and player 2 fire buttons */ |
| 386 | return input_port_read_indexed(machine, 5) | ((mame_rand(Machine)%0xff)<<16); | |
| 387 | return input_port_read_indexed(machine, 4) | input_port_read_indexed(machine, 6) | (input_port_read_indexed(machine, 6)<<16) | (input_port_read_indexed(machine, 6)<<24); //((mame_rand(Machine)%0xff)<<16); | |
| 386 | return input_port_read_indexed(machine, 5) | ((mame_rand(machine)%0xff)<<16); | |
| 387 | return input_port_read_indexed(machine, 4) | input_port_read_indexed(machine, 6) | (input_port_read_indexed(machine, 6)<<16) | (input_port_read_indexed(machine, 6)<<24); //((mame_rand(machine)%0xff)<<16); | |
| 388 | 388 | } |
| 389 | 389 | |
| 390 | 390 | static READ32_HANDLER( dragngun_prot_r ) |
| r2724 | r2725 | |
| 1777 | 1777 | |
| 1778 | 1778 | /**********************************************************************************/ |
| 1779 | 1779 | |
| 1780 | static void sound_irq(int state) | |
| 1780 | static void sound_irq(running_machine *machine, int state) | |
| 1781 | 1781 | { |
| 1782 | cpunum_set_input_line( | |
| 1782 | cpunum_set_input_line(machine, 1,1,state); /* IRQ 2 */ | |
| 1783 | 1783 | } |
| 1784 | 1784 | |
| 1785 | static void sound_irq_nslasher(int state) | |
| 1785 | static void sound_irq_nslasher(running_machine *machine, int state) | |
| 1786 | 1786 | { |
| 1787 | 1787 | /* bit 0 of nslasher_sound_irq specifies IRQ from sound chip */ |
| 1788 | 1788 | if (state) |
| 1789 | 1789 | nslasher_sound_irq |= 0x01; |
| 1790 | 1790 | else |
| 1791 | 1791 | nslasher_sound_irq &= ~0x01; |
| 1792 | cpunum_set_input_line( | |
| 1792 | cpunum_set_input_line(machine, 1, 0, (nslasher_sound_irq != 0) ? ASSERT_LINE : CLEAR_LINE); | |
| 1793 | 1793 | } |
| 1794 | 1794 | |
| 1795 | 1795 | static WRITE8_HANDLER( sound_bankswitch_w ) |
| r2724 | r2725 | |
|---|---|---|
| 25 | 25 | **************************************************************************/ |
| 26 | 26 | |
| 27 | 27 | #include "driver.h" |
| 28 | #include "deprecat.h" | |
| 29 | 28 | #include "cpu/tms34010/tms34010.h" |
| 30 | 29 | #include "cpu/adsp2100/adsp2100.h" |
| 31 | 30 | #include "includes/midzeus.h" |
| r2724 | r2725 | |
| 451 | 450 | static const UINT8 translate49[7] = { 0x8, 0xc, 0xe, 0xf, 0x3, 0x1, 0x0 }; |
| 452 | 451 | const char *namex = param; |
| 453 | 452 | const char *namey = namex + strlen(namex) + 1; |
| 454 | return (translate49[input_port_read(machine, namey) >> 4] << 4) | translate49[input_port_read(machine, namex) >> 4]; | |
| 453 | return (translate49[input_port_read(field->port->machine, namey) >> 4] << 4) | translate49[input_port_read(field->port->machine, namex) >> 4]; | |
| 455 | 454 | } |
| 456 | 455 | |
| 457 | 456 | |
| r2724 | r2725 | |
| 464 | 463 | |
| 465 | 464 | static CUSTOM_INPUT( keypad_r ) |
| 466 | 465 | { |
| 467 | UINT32 bits = input_port_read(machine, param); | |
| 466 | UINT32 bits = input_port_read(field->port->machine, param); | |
| 468 | 467 | UINT8 select = keypad_select; |
| 469 | 468 | while ((select & 1) != 0) |
| 470 | 469 | { |
| r2724 | r2725 | |
| 540 | 539 | /* bits 0-1 enable IRQs (?) */ |
| 541 | 540 | /* bits 2-3 reset IRQ states */ |
| 542 | 541 | gun_irq_state &= ~((gun_control >> 2) & 3); |
| 543 | update_gun_irq( | |
| 542 | update_gun_irq(machine); | |
| 544 | 543 | |
| 545 | 544 | for (player = 0; player < 2; player++) |
| 546 | 545 | { |
| r2724 | r2725 | |
|---|---|---|
| 171 | 171 | } |
| 172 | 172 | |
| 173 | 173 | /* Handler called by the YM2203 emulator when the internal timers cause an IRQ */ |
| 174 | static void irqhandler(int irq) | |
| 174 | static void irqhandler(running_machine *machine, int irq) | |
| 175 | 175 | { |
| 176 | cpunum_set_input_line( | |
| 176 | cpunum_set_input_line(machine, 1, 0, irq ? ASSERT_LINE : CLEAR_LINE); | |
| 177 | 177 | } |
| 178 | 178 | |
| 179 | 179 | static const struct YM2203interface ym2203_interface = |
| r2724 | r2725 | |
| 554 | 554 | PORT_DIPUNUSED_DIPLOC( 0x40, 0x40, "SW1:2" ) /* Listed as "Unused" */ |
| 555 | 555 | PORT_DIPUNUSED_DIPLOC( 0x80, 0x80, "SW1:1" ) /* Listed as "Unused" */ |
| 556 | 556 | |
| 557 | PORT_ | |
| 557 | PORT_MODIFY | |
| 558 | 558 | PORT_DIPNAME( 0x01, 0x01, DEF_STR( Flip_Screen ) ) PORT_DIPLOCATION("SW2:8") |
| 559 | 559 | PORT_DIPSETTING( 0x01, DEF_STR( Off ) ) |
| 560 | 560 | PORT_DIPSETTING( 0x00, DEF_STR( On ) ) |
| r2724 | r2725 | |
|---|---|---|
| 27 | 27 | ***************************************************************************/ |
| 28 | 28 | |
| 29 | 29 | #include "driver.h" |
| 30 | #include "deprecat.h" | |
| 31 | 30 | #include "cpu/z80/z80.h" |
| 32 | 31 | #include "cpu/m6805/m6805.h" |
| 33 | 32 | #include "sound/2203intf.h" |
| r2724 | r2725 | |
| 309 | 308 | GFXDECODE_ENTRY( REGION_GFX1, 0x0000, sprite_layout, 0, 16 ) |
| 310 | 309 | GFXDECODE_END |
| 311 | 310 | |
| 312 | static void irqhandler(int irq) | |
| 311 | static void irqhandler(running_machine *machine, int irq) | |
| 313 | 312 | { |
| 314 | cpunum_set_input_line( | |
| 313 | cpunum_set_input_line(machine, 1,0,irq ? ASSERT_LINE : CLEAR_LINE); | |
| 315 | 314 | } |
| 316 | 315 | |
| 317 | 316 | static const struct YM2203interface ym2203_interface = |
| r2724 | r2725 | |
|---|---|---|
| 125 | 125 | |
| 126 | 126 | |
| 127 | 127 | #include "driver.h" |
| 128 | #include "deprecat.h" | |
| 129 | 128 | #include "cpu/m68000/m68000.h" |
| 130 | 129 | #include "cpu/z80/z80.h" |
| 131 | 130 | #include "sound/2203intf.h" |
| r2724 | r2725 | |
| 957 | 956 | GFXDECODE_END |
| 958 | 957 | |
| 959 | 958 | /* handler called by the 2203 emulator when the internal timers cause an IRQ */ |
| 960 | static void irqhandler(int irq) | |
| 959 | static void irqhandler(running_machine *machine, int irq) | |
| 961 | 960 | { |
| 962 | cpunum_set_input_line( | |
| 961 | cpunum_set_input_line(machine, 1,0,irq ? ASSERT_LINE : CLEAR_LINE); | |
| 963 | 962 | } |
| 964 | 963 | |
| 965 | 964 | static const struct YM2203interface ym2203_interface = |
| r2724 | r2725 | |
|---|---|---|
| 358 | 358 | { |
| 359 | 359 | /* pressing the service switch sends an NMI */ |
| 360 | 360 | if (newval) |
| 361 | cpunum_set_input_line(machine, 0, INPUT_LINE_NMI, PULSE_LINE); | |
| 361 | cpunum_set_input_line(field->port->machine, 0, INPUT_LINE_NMI, PULSE_LINE); | |
| 362 | 362 | } |
| 363 | 363 | |
| 364 | 364 | |
| r2724 | r2725 | |
| 421 | 421 | int num = (FPTR)param; |
| 422 | 422 | int delta, res; |
| 423 | 423 | |
| 424 | delta = input_port_read(machine, dialname[num]); | |
| 424 | delta = input_port_read(field->port->machine, dialname[num]); | |
| 425 | 425 | |
| 426 | 426 | if (delta < 0x80) |
| 427 | 427 | { |
| r2724 | r2725 | |
| 1469 | 1469 | nprinces_decode(); |
| 1470 | 1470 | |
| 1471 | 1471 | /* additional input ports are wired */ |
| 1472 | memory_install_read8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0xc004, 0xc004, 0, 0x18f3, port_tag_to_handler8("SW04")); | |
| 1473 | memory_install_read8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0xc008, 0xc008, 0, 0x18f3, port_tag_to_handler8("SW08")); | |
| 1474 | memory_install_read8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0xc00c, 0xc00c, 0, 0x18f3, port_tag_to_handler8("SW0C")); | |
| 1472 | memory_install_read8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0xc004, 0xc004, 0, 0x18f3, input_port_read_handler8(machine->portconfig, "SW04")); | |
| 1473 | memory_install_read8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0xc008, 0xc008, 0, 0x18f3, input_port_read_handler8(machine->portconfig, "SW08")); | |
| 1474 | memory_install_read8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0xc00c, 0xc00c, 0, 0x18f3, input_port_read_handler8(machine->portconfig, "SW0C")); | |
| 1475 | 1475 | |
| 1476 | 1476 | /* unknown behavior expected here */ |
| 1477 | 1477 | memory_install_read8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0xc80a, 0xc80a, 0, 0, razmataz_counter_r); |
| r2724 | r2725 | |
|---|---|---|
| 53 | 53 | */ |
| 54 | 54 | static UINT8 *nvram; |
| 55 | 55 | static size_t nvram_size; |
| 56 | static int we_flipped_the_switch; | |
| 57 | 56 | |
| 58 | 57 | static NVRAM_HANDLER( trackfld ) |
| 59 | 58 | { |
| 60 | 59 | if (read_or_write) |
| 61 | { | |
| 62 | 60 | mame_fwrite(file,nvram,nvram_size); |
| 63 | ||
| 64 | if (we_flipped_the_switch) | |
| 65 | { | |
| 66 | input_port_entry *in; | |
| 67 | ||
| 68 | ||
| 69 | /* find the dip switch which resets the high score table, and set it */ | |
| 70 | /* back to off. */ | |
| 71 | in = machine->input_ports; | |
| 72 | ||
| 73 | while (in->type != IPT_END) | |
| 74 | { | |
| 75 | if (in->name != NULL && in->name != IP_NAME_DEFAULT && | |
| 76 | strcmp(in->name,"World Records") == 0) | |
| 77 | { | |
| 78 | if (in->default_value == 0) | |
| 79 | in->default_value = in->mask; | |
| 80 | break; | |
| 81 | } | |
| 82 | ||
| 83 | in++; | |
| 84 | } | |
| 85 | ||
| 86 | we_flipped_the_switch = 0; | |
| 87 | } | |
| 88 | } | |
| 89 | else | |
| 90 | { | |
| 91 | if (file) | |
| 92 | { | |
| 93 | mame_fread(file,nvram,nvram_size); | |
| 94 | we_flipped_the_switch = 0; | |
| 95 | } | |
| 96 | else | |
| 97 | { | |
| 98 | input_port_entry *in; | |
| 99 | ||
| 100 | ||
| 101 | /* find the dip switch which resets the high score table, and set it on */ | |
| 102 | in = machine->input_ports; | |
| 103 | ||
| 104 | while (in->type != IPT_END) | |
| 105 | { | |
| 106 | if (in->name != NULL && in->name != IP_NAME_DEFAULT && | |
| 107 | strcmp(in->name,"World Records") == 0) | |
| 108 | { | |
| 109 | if (in->default_value == in->mask) | |
| 110 | { | |
| 111 | in->default_value = 0; | |
| 112 | we_flipped_the_switch = 1; | |
| 113 | } | |
| 114 | break; | |
| 115 | } | |
| 116 | ||
| 117 | in++; | |
| 118 | } | |
| 119 | } | |
| 120 | } | |
| 61 | else if (file) | |
| 62 | mame_fread(file,nvram,nvram_size); | |
| 121 | 63 | } |
| 122 | 64 | |
| 123 | 65 | static NVRAM_HANDLER( mastkin ) |
| r2724 | r2725 | |
|---|---|---|
| 109 | 109 | static INPUT_CHANGED( coin_inserted ) |
| 110 | 110 | { |
| 111 | 111 | /* coin insertion causes an NMI */ |
| 112 | cpunum_set_input_line(machine, 0, INPUT_LINE_NMI, newval ? ASSERT_LINE : CLEAR_LINE); | |
| 112 | cpunum_set_input_line(field->port->machine, 0, INPUT_LINE_NMI, newval ? ASSERT_LINE : CLEAR_LINE); | |
| 113 | 113 | coin_counter_w(0, newval); |
| 114 | 114 | } |
| 115 | 115 | |
| r2724 | r2725 | |
| 117 | 117 | static INPUT_CHANGED( service_coin_inserted ) |
| 118 | 118 | { |
| 119 | 119 | /* service coin insertion causes an NMI */ |
| 120 | cpunum_set_input_line(machine, 0, INPUT_LINE_NMI, newval ? ASSERT_LINE : CLEAR_LINE); | |
| 120 | cpunum_set_input_line(field->port->machine, 0, INPUT_LINE_NMI, newval ? ASSERT_LINE : CLEAR_LINE); | |
| 121 | 121 | } |
| 122 | 122 | |
| 123 | 123 | |
| 124 | 124 | static CUSTOM_INPUT( astrof_p1_controls_r ) |
| 125 | 125 | { |
| 126 | return input_port_read(machine, "P1"); | |
| 126 | return input_port_read(field->port->machine, "P1"); | |
| 127 | 127 | } |
| 128 | 128 | |
| 129 | 129 | |
| r2724 | r2725 | |
| 134 | 134 | /* on an upright cabinets, a single set of controls |
| 135 | 135 | is connected to both sets of pins on the edge |
| 136 | 136 | connector */ |
| 137 | if (input_port_read(machine, "CAB")) | |
| 138 | ret = input_port_read(machine, "P2"); | |
| 137 | if (input_port_read(field->port->machine, "CAB")) | |
| 138 | ret = input_port_read(field->port->machine, "P2"); | |
| 139 | 139 | else |
| 140 | ret = input_port_read(machine, "P1"); | |
| 140 | ret = input_port_read(field->port->machine, "P1"); | |
| 141 | 141 | |
| 142 | 142 | return ret; |
| 143 | 143 | } |
| r2724 | r2725 | |
|---|---|---|
| 668 | 668 | cpunum_set_input_line(machine, 0,7,HOLD_LINE); /* VBL */ |
| 669 | 669 | } |
| 670 | 670 | |
| 671 | static void sound_irq(int linestate) | |
| 671 | static void sound_irq(running_machine *machine, int linestate) | |
| 672 | 672 | { |
| 673 | cpunum_set_input_line( | |
| 673 | cpunum_set_input_line(machine, 1,0,linestate); /* IRQ */ | |
| 674 | 674 | } |
| 675 | 675 | |
| 676 | 676 | static const struct YM3526interface ym3526_interface = |
| r2724 | r2725 | |
|---|---|---|
| 385 | 385 | AM_RANGE(0x01, 0x01) AM_WRITE(msm5205_w) |
| 386 | 386 | ADDRESS_MAP_END |
| 387 | 387 | |
| 388 | static INPUT_PORTS_START( sectionz ) | |
| 389 | PORT_START /* IN0 */ | |
| 388 | /************************************* | |
| 389 | * | |
| 390 | * Generic port definitions | |
| 391 | * | |
| 392 | *************************************/ | |
| 393 | ||
| 394 | static INPUT_PORTS_START( lwings_generic ) | |
| 395 | PORT_START_TAG("SERVICE") | |
| 390 | 396 | PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_START1 ) |
| 391 | 397 | PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_START2 ) |
| 392 | 398 | PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNKNOWN ) /* probably unused */ |
| r2724 | r2725 | |
| 396 | 402 | PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_COIN1 ) |
| 397 | 403 | PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_COIN2 ) |
| 398 | 404 | |
| 399 | PORT_START | |
| 405 | PORT_START_TAG("P | |
| 400 | 406 | PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_8WAY |
| 401 | 407 | PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_8WAY |
| 402 | 408 | PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_8WAY |
| r2724 | r2725 | |
| 406 | 412 | PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN ) /* probably unused */ |
| 407 | 413 | PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN ) /* probably unused */ |
| 408 | 414 | |
| 409 | PORT_START /* IN2 */ | |
| 415 | PORT_START_TAG("P2") | |
| 416 | PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_8WAY PORT_PLAYER(2) | |
| 417 | PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_8WAY PORT_PLAYER(2) | |
| 418 | PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_8WAY PORT_PLAYER(2) | |
| 419 | PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_8WAY PORT_PLAYER(2) | |
| 420 | PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(2) | |
| 421 | PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(2) | |
| 422 | PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN ) /* probably unused */ | |
| 423 | PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN ) /* probably unused */ | |
| 424 | INPUT_PORTS_END | |
| 425 | ||
| 426 | /************************************* | |
| 427 | * | |
| 428 | * Game-specific port definitions | |
| 429 | * | |
| 430 | *************************************/ | |
| 431 | ||
| 432 | static INPUT_PORTS_START( sectionz ) | |
| 433 | PORT_INCLUDE( lwings_generic ) | |
| 434 | ||
| 435 | PORT_MODIFY("P2") | |
| 410 | 436 | PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_8WAY PORT_COCKTAIL |
| 411 | 437 | PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_8WAY PORT_COCKTAIL |
| 412 | 438 | PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_8WAY PORT_COCKTAIL |
| 413 | 439 | PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_8WAY PORT_COCKTAIL |
| 414 | 440 | PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_COCKTAIL |
| 415 | 441 | PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_COCKTAIL |
| 416 | PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN ) /* probably unused */ | |
| 417 | PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN ) /* probably unused */ | |
| 418 | 442 | |
| 419 | PORT_START /* DSW0 */ | |
| 420 | PORT_SERVICE( 0x01, IP_ACTIVE_LOW ) | |
| 421 | PORT_DIPNAME( 0x02, 0x02, DEF_STR( Flip_Screen ) ) | |
| 443 | PORT_START_TAG("DSWA") | |
| 444 | PORT_SERVICE_DIPLOC( 0x01, IP_ACTIVE_LOW, "SWA:8" ) | |
| 445 | PORT_DIPNAME( 0x02, 0x02, DEF_STR( Flip_Screen ) ) PORT_DIPLOCATION("SWA:7") | |
| 422 | 446 | PORT_DIPSETTING( 0x02, DEF_STR( Off ) ) |
| 423 | 447 | PORT_DIPSETTING( 0x00, DEF_STR( On ) ) |
| 424 | PORT_DIPNAME( 0x0c, 0x0c, DEF_STR( Lives ) ) | |
| 448 | PORT_DIPNAME( 0x0c, 0x0c, DEF_STR( Lives ) ) PORT_DIPLOCATION("SWA:6,5") | |
| 425 | 449 | PORT_DIPSETTING( 0x04, "2" ) |
| 426 | 450 | PORT_DIPSETTING( 0x0c, "3" ) |
| 427 | 451 | PORT_DIPSETTING( 0x08, "4" ) |
| 428 | 452 | PORT_DIPSETTING( 0x00, "5" ) |
| 429 | PORT_DIPNAME( 0x30, 0x30, DEF_STR( Coin_A ) ) | |
| 453 | PORT_DIPNAME( 0x30, 0x30, DEF_STR( Coin_A ) ) PORT_DIPLOCATION("SWA:4,3") | |
| 430 | 454 | PORT_DIPSETTING( 0x00, DEF_STR( 4C_1C ) ) |
| 431 | 455 | PORT_DIPSETTING( 0x20, DEF_STR( 3C_1C ) ) |
| 432 | 456 | PORT_DIPSETTING( 0x10, DEF_STR( 2C_1C ) ) |
| 433 | 457 | PORT_DIPSETTING( 0x30, DEF_STR( 1C_1C ) ) |
| 434 | PORT_DIPNAME( 0xc0, 0xc0, DEF_STR( Coin_B ) ) | |
| 458 | PORT_DIPNAME( 0xc0, 0xc0, DEF_STR( Coin_B ) ) PORT_DIPLOCATION("SWA:2,1") | |
| 435 | 459 | PORT_DIPSETTING( 0x00, DEF_STR( 2C_1C ) ) |
| 436 | 460 | PORT_DIPSETTING( 0xc0, DEF_STR( 1C_1C ) ) |
| 437 | 461 | PORT_DIPSETTING( 0x40, DEF_STR( 1C_2C ) ) |
| 438 | 462 | PORT_DIPSETTING( 0x80, DEF_STR( 1C_3C ) ) |
| 439 | 463 | |
| 440 | PORT_START /* DSW1 */ | |
| 441 | PORT_DIPNAME( 0x01, 0x01, DEF_STR( Allow_Continue ) ) | |
| 464 | PORT_START_TAG("DSWB") | |
| 465 | PORT_DIPNAME( 0x01, 0x01, DEF_STR( Allow_Continue ) ) PORT_DIPLOCATION("SWB:8") | |
| 442 | 466 | PORT_DIPSETTING( 0x00, DEF_STR( No ) ) |
| 443 | 467 | PORT_DIPSETTING( 0x01, DEF_STR( Yes ) ) |
| 444 | PORT_DIPNAME( 0x06, 0x06, DEF_STR( Difficulty ) ) | |
| 468 | PORT_DIPNAME( 0x06, 0x06, DEF_STR( Difficulty ) ) PORT_DIPLOCATION("SWB:7,6") | |
| 445 | 469 | PORT_DIPSETTING( 0x02, DEF_STR( Easy ) ) |
| 446 | 470 | PORT_DIPSETTING( 0x06, DEF_STR( Normal ) ) |
| 447 | PORT_DIPSETTING( 0x04, "Difficult" ) | |
| 448 | PORT_DIPSETTING( 0x00, "Very Difficult" ) | |
| 449 | PORT_DIPNAME( 0x38, 0x38, DEF_STR( Bonus_Life ) ) | |
| 471 | PORT_DIPSETTING( 0x04, DEF_STR( Hard ) ) | |
| 472 | PORT_DIPSETTING( 0x00, DEF_STR( Very_Hard ) ) | |
| 473 | PORT_DIPNAME( 0x38, 0x38, DEF_STR( Bonus_Life ) ) PORT_DIPLOCATION("SWB:5,4,3") | |
| 450 | 474 | PORT_DIPSETTING( 0x38, "20000 50000" ) |
| 451 | 475 | PORT_DIPSETTING( 0x18, "20000 60000" ) |
| 452 | 476 | PORT_DIPSETTING( 0x28, "20000 70000" ) |
| r2724 | r2725 | |
| 455 | 479 | PORT_DIPSETTING( 0x10, "30000 80000" ) |
| 456 | 480 | PORT_DIPSETTING( 0x20, "40000 100000" ) |
| 457 | 481 | PORT_DIPSETTING( 0x00, DEF_STR( None ) ) |
| 458 | PORT_DIPNAME( 0xc0, 0x00, DEF_STR( Cabinet ) ) | |
| 482 | PORT_DIPNAME( 0xc0, 0x00, DEF_STR( Cabinet ) ) PORT_DIPLOCATION("SWB:2,1") | |
| 459 | 483 | PORT_DIPSETTING( 0x00, "Upright One Player" ) |
| 460 | 484 | PORT_DIPSETTING( 0x40, "Upright Two Players" ) |
| 461 | 485 | /* PORT_DIPSETTING( 0x80, "???" ) probably unused */ |
| r2724 | r2725 | |
| 463 | 487 | INPUT_PORTS_END |
| 464 | 488 | |
| 465 | 489 | static INPUT_PORTS_START( lwings ) |
| 466 | PORT_START /* IN0 */ | |
| 467 | PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_START1 ) | |
| 468 | PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_START2 ) | |
| 469 | PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNKNOWN ) /* probably unused */ | |
| 470 | PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNKNOWN ) /* probably unused */ | |
| 471 | PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_UNKNOWN ) /* probably unused */ | |
| 472 | PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_UNKNOWN ) /* probably unused */ | |
| 473 | PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_COIN1 ) | |
| 474 | PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_COIN2 ) | |
| 490 | PORT_INCLUDE( lwings_generic ) | |
| 475 | 491 | |
| 476 | PORT_START /* IN1 */ | |
| 477 | PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_8WAY | |
| 478 | PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_8WAY | |
| 479 | PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_8WAY | |
| 480 | PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_8WAY | |
| 481 | PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 ) | |
| 482 | PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON2 ) | |
| 483 | PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN ) /* probably unused */ | |
| 484 | PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN ) /* probably unused */ | |
| 485 | ||
| 486 | PORT_START /* IN2 */ | |
| 487 | PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_8WAY PORT_PLAYER(2) | |
| 488 | PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_8WAY PORT_PLAYER(2) | |
| 489 | PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_8WAY PORT_PLAYER(2) | |
| 490 | PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_8WAY PORT_PLAYER(2) | |
| 491 | PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(2) | |
| 492 | PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(2) | |
| 493 | PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN ) /* probably unused */ | |
| 494 | PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN ) /* probably unused */ | |
| 495 | ||
| 496 | PORT_START /* DSW0 */ | |
| 497 | PORT_DIPNAME( 0x01, 0x01, DEF_STR( Unused ) ) | |
| 498 | PORT_DIPSETTING( 0x01, DEF_STR( Off ) ) | |
| 499 | PORT_DIPSETTING( 0x00, DEF_STR( On ) ) | |
| 500 | PORT_DIPNAME( 0x02, 0x02, DEF_STR( Flip_Screen ) ) | |
| 492 | PORT_START_TAG("DSWA") | |
| 493 | PORT_DIPUNUSED_DIPLOC( 0x0001, 0x0001, "SWA:8" ) | |
| 494 | PORT_DIPNAME( 0x02, 0x02, DEF_STR( Flip_Screen ) ) PORT_DIPLOCATION("SWA:7") | |
| 501 | 495 | PORT_DIPSETTING( 0x02, DEF_STR( Off ) ) |
| 502 | 496 | PORT_DIPSETTING( 0x00, DEF_STR( On ) ) |
| 503 | PORT_DIPNAME( 0x0c, 0x0c, DEF_STR( Lives ) ) | |
| 497 | PORT_DIPNAME( 0x0c, 0x0c, DEF_STR( Lives ) ) PORT_DIPLOCATION("SWA:6,5") | |
| 504 | 498 | PORT_DIPSETTING( 0x0c, "3" ) |
| 505 | 499 | PORT_DIPSETTING( 0x04, "4" ) |
| 506 | 500 | PORT_DIPSETTING( 0x08, "5" ) |
| 507 | 501 | PORT_DIPSETTING( 0x00, "6" ) |
| 508 | PORT_DIPNAME( 0x30, 0x30, DEF_STR( Coin_B ) ) | |
| 502 | PORT_DIPNAME( 0x30, 0x30, DEF_STR( Coin_B ) ) PORT_DIPLOCATION("SWA:4,3") | |
| 509 | 503 | PORT_DIPSETTING( 0x00, DEF_STR( 4C_1C ) ) |
| 510 | 504 | PORT_DIPSETTING( 0x20, DEF_STR( 3C_1C ) ) |
| 511 | 505 | PORT_DIPSETTING( 0x10, DEF_STR( 2C_1C ) ) |
| 512 | 506 | PORT_DIPSETTING( 0x30, DEF_STR( 1C_1C ) ) |
| 513 | PORT_DIPNAME( 0xc0, 0xc0, DEF_STR( Coin_A ) ) | |
| 507 | PORT_DIPNAME( 0xc0, 0xc0, DEF_STR( Coin_A ) ) PORT_DIPLOCATION("SWA:2,1") | |
| 514 | 508 | PORT_DIPSETTING( 0xc0, DEF_STR( 1C_1C ) ) |
| 515 | 509 | PORT_DIPSETTING( 0x00, DEF_STR( 2C_4C ) ) |
| 516 | 510 | PORT_DIPSETTING( 0x40, DEF_STR( 1C_2C ) ) |
| 517 | 511 | PORT_DIPSETTING( 0x80, DEF_STR( 1C_3C ) ) |
| 518 | 512 | |
| 519 | PORT_START /* DSW1 */ | |
| 520 | PORT_DIPNAME( 0x01, 0x01, DEF_STR( Unused ) ) | |
| 521 | PORT_DIPSETTING( 0x01, DEF_STR( Off ) ) | |
| 522 | PORT_DIPSETTING( 0x00, DEF_STR( On ) ) | |
| 523 | PORT_DIPNAME( 0x06, 0x06, DEF_STR( Difficulty ) ) | |
| 513 | PORT_START_TAG("DSWB") | |
| 514 | PORT_DIPUNUSED_DIPLOC( 0x0001, 0x0001, "SWB:8" ) | |
| 515 | PORT_DIPNAME( 0x06, 0x06, DEF_STR( Difficulty ) ) PORT_DIPLOCATION("SWB:7,6") | |
| 524 | 516 | PORT_DIPSETTING( 0x02, DEF_STR( Easy ) ) |
| 525 | 517 | PORT_DIPSETTING( 0x06, DEF_STR( Medium ) ) |
| 526 | 518 | PORT_DIPSETTING( 0x04, DEF_STR( Hard ) ) |
| 527 | 519 | PORT_DIPSETTING( 0x00, DEF_STR( Hardest ) ) |
| 528 | PORT_DIPNAME( 0x08, 0x08, DEF_STR( Demo_Sounds ) ) | |
| 520 | PORT_DIPNAME( 0x08, 0x08, DEF_STR( Demo_Sounds ) ) PORT_DIPLOCATION("SWB:5") | |
| 529 | 521 | PORT_DIPSETTING( 0x00, DEF_STR( Off ) ) |
| 530 | 522 | PORT_DIPSETTING( 0x08, DEF_STR( On ) ) |
| 531 | PORT_DIPNAME( 0x10, 0x10, DEF_STR( Allow_Continue ) ) | |
| 523 | PORT_DIPNAME( 0x10, 0x10, DEF_STR( Allow_Continue ) ) PORT_DIPLOCATION("SWB:4") | |
| 532 | 524 | PORT_DIPSETTING( 0x00, DEF_STR( No ) ) |
| 533 | 525 | PORT_DIPSETTING( 0x10, DEF_STR( Yes ) ) |
| 534 | PORT_DIPNAME( 0xe0, 0xe0, DEF_STR( Bonus_Life ) ) | |
| 526 | PORT_DIPNAME( 0xe0, 0xe0, DEF_STR( Bonus_Life ) ) PORT_DIPLOCATION("SWB:3,2,1") | |
| 535 | 527 | PORT_DIPSETTING( 0xe0, "20000 and every 50000" ) |
| 536 | 528 | PORT_DIPSETTING( 0x60, "20000 and every 60000" ) |
| 537 | 529 | PORT_DIPSETTING( 0xa0, "20000 and every 70000" ) |
| r2724 | r2725 | |
| 542 | 534 | PORT_DIPSETTING( 0x00, DEF_STR( None ) ) |
| 543 | 535 | INPUT_PORTS_END |
| 544 | 536 | |
| 545 | static INPUT_PORTS_START( trojan ) | |
| 546 | PORT_START /* IN0 */ | |
| 547 | PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_START1 ) | |
| 548 | PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_START2 ) | |
| 549 | PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNKNOWN ) /* probably unused */ | |
| 550 | PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNKNOWN ) /* probably unused */ | |
| 551 | PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_UNKNOWN ) /* probably unused */ | |
| 552 | PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_UNKNOWN ) /* probably unused */ | |
| 553 | PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_COIN1 ) | |
| 554 | PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_COIN2 ) | |
| 537 | static INPUT_PORTS_START( lwingsb ) | |
| 538 | PORT_INCLUDE( lwings ) | |
| 555 | 539 | |
| 556 | PORT_START /* IN1 */ | |
| 557 | PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_8WAY | |
| 558 | PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_8WAY | |
| 559 | PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_8WAY | |
| 560 | PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_8WAY | |
| 561 | PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 ) | |
| 562 | PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON2 ) | |
| 563 | PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN ) | |
| 564 | PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN ) /* probably unused */ | |
| 565 | ||
| 566 | PORT_START /* IN2 */ | |
| 567 | PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_8WAY PORT_COCKTAIL | |
| 568 | PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_8WAY PORT_COCKTAIL | |
| 569 | PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_8WAY PORT_COCKTAIL | |
| 570 | PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_8WAY PORT_COCKTAIL | |
| 571 | PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_COCKTAIL | |
| 572 | PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_COCKTAIL | |
| 573 | PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN ) | |
| 574 | PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN ) /* probably unused */ | |
| 575 | ||
| 576 | PORT_START /* DSW0 */ | |
| 577 | PORT_DIPNAME( 0x03, 0x00, DEF_STR( Cabinet ) ) | |
| 578 | PORT_DIPSETTING( 0x00, "Upright 1 Player" ) | |
| 579 | PORT_DIPSETTING( 0x02, "Upright 2 Players" ) | |
| 580 | PORT_DIPSETTING( 0x03, DEF_STR( Cocktail ) ) | |
| 581 | /* 0x01 same as 0x02 or 0x03 */ | |
| 582 | PORT_DIPNAME( 0x1c, 0x1c, DEF_STR( Bonus_Life ) ) | |
| 583 | PORT_DIPSETTING( 0x10, "20000 60000" ) | |
| 584 | PORT_DIPSETTING( 0x0c, "20000 70000" ) | |
| 585 | PORT_DIPSETTING( 0x08, "20000 80000" ) | |
| 586 | PORT_DIPSETTING( 0x1c, "30000 60000" ) | |
| 587 | PORT_DIPSETTING( 0x18, "30000 70000" ) | |
| 588 | PORT_DIPSETTING( 0x14, "30000 80000" ) | |
| 589 | PORT_DIPSETTING( 0x04, "40000 80000" ) | |
| 590 | PORT_DIPSETTING( 0x00, DEF_STR( None ) ) | |
| 591 | PORT_DIPNAME( 0xe0, 0xe0, "Starting Level" ) | |
| 592 | PORT_DIPSETTING( 0xe0, "1" ) | |
| 593 | PORT_DIPSETTING( 0xc0, "2" ) | |
| 594 | PORT_DIPSETTING( 0xa0, "3" ) | |
| 595 | PORT_DIPSETTING( 0x80, "4" ) | |
| 596 | PORT_DIPSETTING( 0x60, "5" ) | |
| 597 | PORT_DIPSETTING( 0x40, "6" ) | |
| 598 | /* 0x00 and 0x20 start at level 6 */ | |
| 599 | ||
| 600 | PORT_START /* DSW1 */ | |
| 601 | PORT_DIPNAME( 0x03, 0x03, DEF_STR( Coin_A ) ) | |
| 602 | PORT_DIPSETTING( 0x00, DEF_STR( 2C_1C ) ) | |
| 603 | PORT_DIPSETTING( 0x03, DEF_STR( 1C_1C ) ) | |
| 604 | PORT_DIPSETTING( 0x02, DEF_STR( 1C_2C ) ) | |
| 605 | PORT_DIPSETTING( 0x01, DEF_STR( 1C_3C ) ) | |
| 606 | PORT_DIPNAME( 0x0c, 0x0c, DEF_STR( Coin_B ) ) | |
| 607 | PORT_DIPSETTING( 0x00, DEF_STR( 4C_1C ) ) | |
| 608 | PORT_DIPSETTING( 0x04, DEF_STR( 3C_1C ) ) | |
| 609 | PORT_DIPSETTING( 0x08, DEF_STR( 2C_1C ) ) | |
| 610 | PORT_DIPSETTING( 0x0c, DEF_STR( 1C_1C ) ) | |
| 611 | PORT_DIPNAME( 0x30, 0x30, DEF_STR( Lives ) ) | |
| 612 | PORT_DIPSETTING( 0x20, "2" ) | |
| 613 | PORT_DIPSETTING( 0x30, "3" ) | |
| 614 | PORT_DIPSETTING( 0x10, "4" ) | |
| 540 | PORT_MODIFY("DSWA") | |
| 541 | PORT_DIPNAME( 0x0c, 0x0c, DEF_STR( Lives ) ) PORT_DIPLOCATION("SWA:6,5") | |
| 542 | PORT_DIPSETTING( 0x0c, "2" ) | |
| 543 | PORT_DIPSETTING( 0x04, "3" ) | |
| 544 | PORT_DIPSETTING( 0x08, "4" ) | |
| 615 | 545 | PORT_DIPSETTING( 0x00, "5" ) |
| 616 | PORT_DIPNAME( 0x40, 0x40, DEF_STR( Flip_Screen ) ) | |
| 617 | PORT_DIPSETTING( 0x40, DEF_STR( Off ) ) | |
| 618 | PORT_DIPSETTING( 0x00, DEF_STR( On ) ) | |
| 619 | PORT_DIPNAME( 0x80, 0x80, DEF_STR( Allow_Continue ) ) | |
| 620 | PORT_DIPSETTING( 0x00, DEF_STR( No ) ) | |
| 621 | PORT_DIPSETTING( 0x80, DEF_STR( Yes ) ) | |
| 622 | 546 | INPUT_PORTS_END |
| 623 | 547 | |
| 624 | 548 | /* Trojan with level selection - starting level dip switches not used */ |
| 625 | 549 | static INPUT_PORTS_START( trojanls ) |
| 626 | PORT_START /* IN0 */ | |
| 627 | PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_START1 ) | |
| 628 | PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_START2 ) | |
| 629 | PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNKNOWN ) /* probably unused */ | |
| 630 | PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNKNOWN ) /* probably unused */ | |
| 631 | PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_UNKNOWN ) /* probably unused */ | |
| 632 | PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_UNKNOWN ) /* probably unused */ | |
| 633 | PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_COIN1 ) | |
| 634 | PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_COIN2 ) | |
| 550 | PORT_INCLUDE( lwings_generic ) | |
| 635 | 551 | |
| 636 | PORT_START /* IN1 */ | |
| 637 | PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_8WAY | |
| 638 | PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_8WAY | |
| 639 | PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_8WAY | |
| 640 | PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_8WAY | |
| 641 | PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 ) | |
| 642 | PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON2 ) | |
| 643 | PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN ) | |
| 644 | PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN ) /* probably unused */ | |
| 645 | ||
| 646 | PORT_START /* IN2 */ | |
| 552 | PORT_MODIFY("P2") | |
| 647 | 553 | PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_8WAY PORT_COCKTAIL |
| 648 | 554 | PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_8WAY PORT_COCKTAIL |
| 649 | 555 | PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_8WAY PORT_COCKTAIL |
| 650 | 556 | PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_8WAY PORT_COCKTAIL |
| 651 | 557 | PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_COCKTAIL |
| 652 | 558 | PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_COCKTAIL |
| 653 | PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN ) | |
| 654 | PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN ) /* probably unused */ | |
| 655 | 559 | |
| 656 | PORT_START /* DSW0 */ | |
| 657 | PORT_DIPNAME( 0x03, 0x00, DEF_STR( Cabinet ) ) | |
| 560 | PORT_START_TAG("DSWB") | |
| 561 | PORT_DIPNAME( 0x03, 0x00, DEF_STR( Cabinet ) ) PORT_DIPLOCATION("SWB:8,7") | |
| 658 | 562 | PORT_DIPSETTING( 0x00, "Upright 1 Player" ) |
| 659 | 563 | PORT_DIPSETTING( 0x02, "Upright 2 Players" ) |
| 660 | 564 | PORT_DIPSETTING( 0x03, DEF_STR( Cocktail ) ) |
| 661 | 565 | /* 0x01 same as 0x02 or 0x03 */ |
| 662 | PORT_DIPNAME( 0x1c, 0x1c, DEF_STR( Bonus_Life ) ) | |
| 566 | PORT_DIPNAME( 0x1c, 0x1c, DEF_STR( Bonus_Life ) ) PORT_DIPLOCATION("SWB:6,5,4") | |
| 663 | 567 | PORT_DIPSETTING( 0x10, "20000 60000" ) |
| 664 | 568 | PORT_DIPSETTING( 0x0c, "20000 70000" ) |
| 665 | 569 | PORT_DIPSETTING( 0x08, "20000 80000" ) |
| r2724 | r2725 | |
| 668 | 572 | PORT_DIPSETTING( 0x14, "30000 80000" ) |
| 669 | 573 | PORT_DIPSETTING( 0x04, "40000 80000" ) |
| 670 | 574 | PORT_DIPSETTING( 0x00, DEF_STR( None ) ) |
| 671 | PORT_DIPNAME( 0x20, 0x20, DEF_STR( Unknown ) ) | |
| 672 | PORT_DIPSETTING( 0x20, DEF_STR( Off ) ) | |
| 673 | PORT_DIPSETTING( 0x00, DEF_STR( On ) ) | |
| 674 | PORT_DIPNAME( 0x40, 0x40, DEF_STR( Unknown ) ) | |
| 675 | PORT_DIPSETTING( 0x40, DEF_STR( Off ) ) | |
| 676 | PORT_DIPSETTING( 0x00, DEF_STR( On ) ) | |
| 677 | PORT_DIPNAME( 0x80, 0x80, DEF_STR( Unknown ) ) | |
| 678 | PORT_DIPSETTING( 0x80, DEF_STR( Off ) ) | |
| 679 | PORT_DIPSETTING( 0x00, DEF_STR( On ) ) | |
| 575 | PORT_DIPUNUSED_DIPLOC( 0x20, 0x20, "SWB:3" ) | |
| 576 | PORT_DIPUNUSED_DIPLOC( 0x40, 0x40, "SWB:2" ) | |
| 577 | PORT_DIPUNUSED_DIPLOC( 0x40, 0x40, "SWB:1" ) | |
| 680 | 578 | |
| 681 | PORT_START /* DSW1 */ | |
| 682 | PORT_DIPNAME( 0x03, 0x03, DEF_STR( Coin_A ) ) | |
| 579 | PORT_START_TAG("DSWA") | |
| 580 | PORT_DIPNAME( 0x03, 0x03, DEF_STR( Coin_A ) ) PORT_DIPLOCATION("SWA:8,7") | |
| 683 | 581 | PORT_DIPSETTING( 0x00, DEF_STR( 2C_1C ) ) |
| 684 | 582 | PORT_DIPSETTING( 0x03, DEF_STR( 1C_1C ) ) |
| 685 | 583 | PORT_DIPSETTING( 0x02, DEF_STR( 1C_2C ) ) |
| 686 | 584 | PORT_DIPSETTING( 0x01, DEF_STR( 1C_3C ) ) |
| 687 | PORT_DIPNAME( 0x0c, 0x0c, DEF_STR( Coin_B ) ) | |
| 585 | PORT_DIPNAME( 0x0c, 0x0c, DEF_STR( Coin_B ) ) PORT_DIPLOCATION("SWA:6,5") | |
| 688 | 586 | PORT_DIPSETTING( 0x00, DEF_STR( 4C_1C ) ) |
| 689 | 587 | PORT_DIPSETTING( 0x04, DEF_STR( 3C_1C ) ) |
| 690 | 588 | PORT_DIPSETTING( 0x08, DEF_STR( 2C_1C ) ) |
| 691 | 589 | PORT_DIPSETTING( 0x0c, DEF_STR( 1C_1C ) ) |
| 692 | PORT_DIPNAME( 0x30, 0x30, DEF_STR( Lives ) ) | |
| 590 | PORT_DIPNAME( 0x30, 0x30, DEF_STR( Lives ) ) PORT_DIPLOCATION("SWA:4,3") | |
| 693 | 591 | PORT_DIPSETTING( 0x20, "2" ) |
| 694 | 592 | PORT_DIPSETTING( 0x30, "3" ) |
| 695 | 593 | PORT_DIPSETTING( 0x10, "4" ) |
| 696 | 594 | PORT_DIPSETTING( 0x00, "5" ) |
| 697 | PORT_DIPNAME( 0x40, 0x40, DEF_STR( Flip_Screen ) ) | |
| 595 | PORT_DIPNAME( 0x40, 0x40, DEF_STR( Flip_Screen ) ) PORT_DIPLOCATION("SWA:2") | |
| 698 | 596 | PORT_DIPSETTING( 0x40, DEF_STR( Off ) ) |
| 699 | 597 | PORT_DIPSETTING( 0x00, DEF_STR( On ) ) |
| 700 | PORT_DIPNAME( 0x80, 0x80, DEF_STR( Allow_Continue ) ) | |
| 598 | PORT_DIPNAME( 0x80, 0x80, DEF_STR( Allow_Continue ) ) PORT_DIPLOCATION("SWA:1") | |
| 701 | 599 | PORT_DIPSETTING( 0x00, DEF_STR( No ) ) |
| 702 | 600 | PORT_DIPSETTING( 0x80, DEF_STR( Yes ) ) |
| 703 | 601 | INPUT_PORTS_END |
| 704 | 602 | |
| 705 | static INPUT_PORTS_START( avengers ) | |
| 706 | PORT_START /* IN0 */ | |
| 707 | PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_START1 ) | |
| 708 | PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_START2 ) | |
| 709 | PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNKNOWN ) /* probably unused */ | |
| 710 | PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_UNKNOWN ) /* probably unused */ | |
| 711 | PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_UNKNOWN ) /* probably unused */ | |
| 712 | PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_UNKNOWN ) /* probably unused */ | |
| 713 | PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_COIN1 ) | |
| 714 | PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_COIN2 ) | |
| 603 | static INPUT_PORTS_START( trojan ) | |
| 604 | PORT_INCLUDE( trojanls ) | |
| 715 | 605 | |
| 716 | PORT_START /* IN1 */ | |
| 717 | PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_8WAY | |
| 718 | PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_8WAY | |
| 719 | PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_8WAY | |
| 720 | PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_8WAY | |
| 721 | PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 ) | |
| 722 | PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON2 ) | |
| 723 | PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN ) | |
| 724 | PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN ) /* probably unused */ | |
| 606 | PORT_MODIFY("DSWB") | |
| 607 | PORT_DIPNAME( 0xe0, 0xe0, "Starting Level" ) PORT_DIPLOCATION("SWB:3,2,1") | |
| 608 | PORT_DIPSETTING( 0xe0, "1" ) | |
| 609 | PORT_DIPSETTING( 0xc0, "2" ) | |
| 610 | PORT_DIPSETTING( 0xa0, "3" ) | |
| 611 | PORT_DIPSETTING( 0x80, "4" ) | |
| 612 | PORT_DIPSETTING( 0x60, "5" ) | |
| 613 | PORT_DIPSETTING( 0x40, "6" ) | |
| 614 | /* 0x00 and 0x20 start at level 6 */ | |
| 615 | INPUT_PORTS_END | |
| 725 | 616 | |
| 726 | PORT_START /* IN2 */ | |
| 727 | PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_8WAY PORT_PLAYER(2) | |
| 728 | PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_8WAY PORT_PLAYER(2) | |
| 729 | PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_8WAY PORT_PLAYER(2) | |
| 730 | PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_8WAY PORT_PLAYER(2) | |
| 731 | PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(2) | |
| 732 | PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(2) | |
| 733 | PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN ) | |
| 734 | PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN ) /* probably unused */ | |
| 617 | static INPUT_PORTS_START( avengers ) | |
| 618 | PORT_INCLUDE( lwings_generic ) | |
| 735 | 619 | |
| 736 | PORT_START /* DSWB */ | |
| 737 | PORT_DIPNAME( 0x01, 0x01, DEF_STR( Allow_Continue ) ) | |
| 620 | PORT_START_TAG("DSWB") | |
| 621 | PORT_DIPNAME( 0x01, 0x01, DEF_STR( Allow_Continue ) ) PORT_DIPLOCATION("SWB:8") | |
| 738 | 622 | PORT_DIPSETTING( 0x00, DEF_STR( No ) ) |
| 739 | 623 | PORT_DIPSETTING( 0x01, DEF_STR( Yes ) ) |
| 740 | PORT_DIPNAME( 0x02, 0x02, DEF_STR( Demo_Sounds ) ) | |
| 624 | PORT_DIPNAME( 0x02, 0x02, DEF_STR( Demo_Sounds ) ) PORT_DIPLOCATION("SWB:7") | |
| 741 | 625 | PORT_DIPSETTING( 0x00, DEF_STR( Off ) ) |
| 742 | 626 | PORT_DIPSETTING( 0x02, DEF_STR( On ) ) |
| 743 | PORT_DIPNAME( 0x0c, 0x0c, DEF_STR( Difficulty ) ) | |
| 627 | PORT_DIPNAME( 0x0c, 0x0c, DEF_STR( Difficulty ) ) PORT_DIPLOCATION("SWB:6,5") | |
| 744 | 628 | PORT_DIPSETTING( 0x04, DEF_STR( Easy ) ) |
| 745 | 629 | PORT_DIPSETTING( 0x0c, DEF_STR( Normal ) ) |
| 746 | 630 | PORT_DIPSETTING( 0x08, DEF_STR( Hard ) ) |
| 747 | 631 | PORT_DIPSETTING( 0x00, DEF_STR( Very_Hard ) ) |
| 748 | PORT_DIPNAME( 0x30, 0x30, | |
| 632 | PORT_DIPNAME( 0x30, 0x30, DEF_STR( Bonus_Life ) ) PORT_DIPLOCATION("SWB:4,3") | |
| 749 | 633 | PORT_DIPSETTING( 0x30, "20k 60k" ) |
| 750 | 634 | PORT_DIPSETTING( 0x10, "20k 70k" ) |
| 751 | 635 | PORT_DIPSETTING( 0x20, "20k 80k" ) |
| 752 | 636 | PORT_DIPSETTING( 0x00, "30k 80k" ) |
| 753 | PORT_DIPNAME( 0xc0, 0xc0, DEF_STR( Lives ) ) | |
| 637 | PORT_DIPNAME( 0xc0, 0xc0, DEF_STR( Lives ) ) PORT_DIPLOCATION("SWB:2,1") | |
| 754 | 638 | PORT_DIPSETTING( 0xc0, "3" ) |
| 755 | 639 | PORT_DIPSETTING( 0x40, "4" ) |
| 756 | 640 | PORT_DIPSETTING( 0x80, "5" ) |
| 757 | 641 | PORT_DIPSETTING( 0x00, "6" ) |
| 758 | 642 | |
| 759 | PORT_START /* DSWA */ | |
| 760 | PORT_SERVICE( 0x01, IP_ACTIVE_LOW ) | |
| 761 | PORT_DIPNAME( 0x02, 0x02, DEF_STR( Flip_Screen ) ) | |
| 643 | PORT_START_TAG("DSWA") | |
| 644 | PORT_SERVICE_DIPLOC( 0x01, IP_ACTIVE_LOW, "SWA:8") | |
| 645 | PORT_DIPNAME( 0x02, 0x02, DEF_STR( Flip_Screen ) ) PORT_DIPLOCATION("SWA:7") | |
| 762 | 646 | PORT_DIPSETTING( 0x02, DEF_STR( Off ) ) |
| 763 | 647 | PORT_DIPSETTING( 0x00, DEF_STR( On ) ) |
| 764 | PORT_DIPNAME( 0x1c, 0x1c, DEF_STR( Coin_B ) ) | |
| 648 | PORT_DIPNAME( 0x1c, 0x1c, DEF_STR( Coin_B ) ) PORT_DIPLOCATION("SWA:6,5,4") | |
| 765 | 649 | PORT_DIPSETTING( 0x00, DEF_STR( 4C_1C ) ) |
| 766 | 650 | PORT_DIPSETTING( 0x10, DEF_STR( 3C_1C ) ) |
| 767 | 651 | PORT_DIPSETTING( 0x08, DEF_STR( 2C_1C ) ) |
| r2724 | r2725 | |
| 770 | 654 | PORT_DIPSETTING( 0x14, DEF_STR( 1C_3C ) ) |
| 771 | 655 | PORT_DIPSETTING( 0x04, DEF_STR( 1C_4C ) ) |
| 772 | 656 | PORT_DIPSETTING( 0x18, DEF_STR( 1C_6C ) ) |
| 773 | PORT_DIPNAME( 0xe0, 0xe0, DEF_STR( Coin_A ) ) | |
| 657 | PORT_DIPNAME( 0xe0, 0xe0, DEF_STR( Coin_A ) ) PORT_DIPLOCATION("SWA:3,2,1") | |
| 774 | 658 | PORT_DIPSETTING( 0x00, DEF_STR( 4C_1C ) ) |
| 775 | 659 | PORT_DIPSETTING( 0x80, DEF_STR( 3C_1C ) ) |
| 776 | 660 | PORT_DIPSETTING( 0x40, DEF_STR( 2C_1C ) ) |
| r2724 | r2725 | |
| 781 | 665 | PORT_DIPSETTING( 0xc0, DEF_STR( 1C_6C ) ) |
| 782 | 666 | INPUT_PORTS_END |
| 783 | 667 | |
| 668 | /************************************* | |
| 669 | * | |
| 670 | * Graphics definitions | |
| 671 | * | |
| 672 | *************************************/ | |
| 673 | ||
| 784 | 674 | static const gfx_layout charlayout = |
| 785 | 675 | { |
| 786 | 676 | 8,8, |
| r2724 | r2725 | |
| 845 | 735 | GFXDECODE_ENTRY( REGION_GFX4, 0, bg2_tilelayout, 0, 8 ) /* colors 0-127 */ |
| 846 | 736 | GFXDECODE_END |
| 847 | 737 | |
| 738 | /************************************* | |
| 739 | * | |
| 740 | * Sound definitions | |
| 741 | * | |
| 742 | *************************************/ | |
| 743 | ||
| 848 | 744 | static const struct MSM5205interface msm5205_interface = |
| 849 | 745 | { |
| 850 | 746 | 0, /* interrupt function */ |
| 851 | 747 | MSM5205_SEX_4B /* slave mode */ |
| 852 | 748 | }; |
| 853 | 749 | |
| 750 | /************************************* | |
| 751 | * | |
| 752 | * Machine driver | |
| 753 | * | |
| 754 | *************************************/ | |
| 755 | ||
| 854 | 756 | static MACHINE_DRIVER_START( lwings ) |
| 855 | 757 | |
| 856 | 758 | /* basic machine hardware */ |
| 857 | MDRV_CPU_ADD(Z80, 6000000) /* 4 MHz (?) */ | |
| 759 | MDRV_CPU_ADD_TAG("main", Z80, 6000000) /* 4 MHz (?) */ | |
| 858 | 760 | MDRV_CPU_PROGRAM_MAP(readmem,writemem) |
| 859 | 761 | MDRV_CPU_VBLANK_INT("main", lwings_interrupt) |
| 860 | 762 | |
| 861 | MDRV_CPU_ADD(Z80, 4000000) | |
| 763 | MDRV_CPU_ADD_TAG("sound", Z80, 4000000) | |
| 862 | 764 | /* audio CPU */ |
| 863 | 765 | MDRV_CPU_PROGRAM_MAP(sound_readmem,sound_writemem) |
| 864 | 766 | MDRV_CPU_VBLANK_INT_HACK(irq0_line_hold,4) |
| r2724 | r2725 | |
| 883 | 785 | /* sound hardware */ |
| 884 | 786 | MDRV_SPEAKER_STANDARD_MONO("mono") |
| 885 | 787 | |
| 886 | MDRV_SOUND_ADD(YM2203, 1500000) | |
| 788 | MDRV_SOUND_ADD_TAG("2203a", YM2203, 1500000) | |
| 887 | 789 | MDRV_SOUND_ROUTE(0, "mono", 0.20) |
| 888 | 790 | MDRV_SOUND_ROUTE(1, "mono", 0.20) |
| 889 | 791 | MDRV_SOUND_ROUTE(2, "mono", 0.20) |
| 890 | 792 | MDRV_SOUND_ROUTE(3, "mono", 0.10) |
| 891 | 793 | |
| 892 | MDRV_SOUND_ADD(YM2203, 1500000) | |
| 794 | MDRV_SOUND_ADD_TAG("2203b", YM2203, 1500000) | |
| 893 | 795 | MDRV_SOUND_ROUTE(0, "mono", 0.20) |
| 894 | 796 | MDRV_SOUND_ROUTE(1, "mono", 0.20) |
| 895 | 797 | MDRV_SOUND_ROUTE(2, "mono", 0.20) |
| 896 | 798 | MDRV_SOUND_ROUTE(3, "mono", 0.10) |
| 897 | 799 | MACHINE_DRIVER_END |
| 898 | 800 | |
| 899 | ||
| 900 | 801 | static MACHINE_DRIVER_START( trojan ) |
| 802 | MDRV_IMPORT_FROM( lwings ) | |
| 901 | 803 | |
| 902 | /* basic machine hardware */ | |
| 903 | MDRV_CPU_ADD(Z80, 6000000) /* 4 MHz (?) */ | |
| 804 | MDRV_CPU_MODIFY("main") | |
| 904 | 805 | MDRV_CPU_PROGRAM_MAP(readmem,trojan_writemem) |
| 905 | MDRV_CPU_VBLANK_INT("main", lwings_interrupt) | |
| 906 | 806 | |
| 907 | MDRV_CPU_ADD(Z80, 4000000) | |
| 908 | /* audio CPU */ | |
| 909 | MDRV_CPU_PROGRAM_MAP(sound_readmem,sound_writemem) | |
| 910 | MDRV_CPU_VBLANK_INT_HACK(irq0_line_hold,4) | |
| 911 | ||
| 912 | MDRV_CPU_ADD(Z80, 4000000) // 3.579545 Mhz (?) | |
| 807 | MDRV_CPU_ADD_TAG("adpcm", Z80, 4000000) // 3.579545 Mhz (?) | |
| 913 | 808 | /* audio CPU */ /* ? */ |
| 914 | 809 | MDRV_CPU_PROGRAM_MAP(adpcm_readmem,adpcm_writemem) |
| 915 | 810 | MDRV_CPU_IO_MAP(adpcm_readport,adpcm_writeport) |
| 916 | 811 | MDRV_CPU_PERIODIC_INT(irq0_line_hold, 4000) |
| 917 | 812 | |
| 918 | 813 | /* video hardware */ |
| 919 | MDRV_VIDEO_ATTRIBUTES(VIDEO_BUFFERS_SPRITERAM) | |
| 920 | ||
| 921 | MDRV_SCREEN_ADD("main", RASTER) | |
| 922 | MDRV_SCREEN_REFRESH_RATE(60) | |
| 923 | MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(0)) | |
| 924 | MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16) | |
| 925 | MDRV_SCREEN_SIZE(32*8, 32*8) | |
| 926 | MDRV_SCREEN_VISIBLE_AREA(0*8, 32*8-1, 1*8, 31*8-1) | |
| 927 | ||
| 928 | 814 | MDRV_GFXDECODE(trojan) |
| 929 | MDRV_PALETTE_LENGTH(1024) | |
| 930 | 815 | |
| 931 | 816 | MDRV_VIDEO_START(trojan) |
| 932 | MDRV_VIDEO_EOF(lwings) | |
| 933 | 817 | MDRV_VIDEO_UPDATE(trojan) |
| 934 | 818 | |
| 935 | 819 | /* sound hardware */ |
| 936 | MDRV_SPEAKER_STANDARD_MONO("mono") | |
| 937 | ||
| 938 | MDRV_SOUND_ADD(YM2203, 1500000) | |
| 939 | MDRV_SOUND_ROUTE(0, "mono", 0.20) | |
| 940 | MDRV_SOUND_ROUTE(1, "mono", 0.20) | |
| 941 | MDRV_SOUND_ROUTE(2, "mono", 0.20) | |
| 942 | MDRV_SOUND_ROUTE(3, "mono", 0.10) | |
| 943 | ||
| 944 | MDRV_SOUND_ADD(YM2203, 1500000) | |
| 945 | MDRV_SOUND_ROUTE(0, "mono", 0.20) | |
| 946 | MDRV_SOUND_ROUTE(1, "mono", 0.20) | |
| 947 | MDRV_SOUND_ROUTE(2, "mono", 0.20) | |
| 948 | MDRV_SOUND_ROUTE(3, "mono", 0.10) | |
| 949 | ||
| 950 | MDRV_SOUND_ADD(MSM5205, 384000) | |
| 820 | MDRV_SOUND_ADD_TAG("5205", MSM5205, 384000) | |
| 951 | 821 | MDRV_SOUND_CONFIG(msm5205_interface) |
| 952 | 822 | MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50) |
| 953 | 823 | MACHINE_DRIVER_END |
| 954 | 824 | |
| 955 | ||
| 956 | 825 | static MACHINE_DRIVER_START( avengers ) |
| 826 | MDRV_IMPORT_FROM( trojan ) | |
| 957 | 827 | |
| 958 | /* basic machine hardware */ | |
| 959 | MDRV_CPU_ADD(Z80, 6000000) //AT: (avengers37b16gre) | |
| 828 | MDRV_CPU_MODIFY("main") //AT: (avengers37b16gre) | |
| 960 | 829 | MDRV_CPU_PROGRAM_MAP(avengers_readmem,avengers_writemem) |
| 961 | 830 | MDRV_CPU_VBLANK_INT("main", nmi_line_pulse) // RST 38h triggered by software |
| 962 | 831 | |
| 963 | MDRV_CPU_ADD(Z80, 4000000) | |
| 964 | /* audio CPU */ | |
| 965 | MDRV_CPU_PROGRAM_MAP(sound_readmem,sound_writemem) | |
| 966 | MDRV_CPU_VBLANK_INT_HACK(irq0_line_hold,4) | |
| 967 | ||
| 968 | MDRV_CPU_ADD(Z80, 4000000) // 3.579545 Mhz (?) | |
| 969 | /* audio CPU */ /* ? */ | |
| 970 | MDRV_CPU_PROGRAM_MAP(adpcm_readmem,adpcm_writemem) | |
| 832 | MDRV_CPU_MODIFY("adpcm") | |
| 971 | 833 | MDRV_CPU_IO_MAP(avengers_adpcm_readport,adpcm_writeport) |
| 972 | MDRV_CPU_PERIODIC_INT(irq0_line_hold, 4000) | |
| 973 | 834 | |
| 974 | 835 | /* video hardware */ |
| 975 | MDRV_VIDEO_ATTRIBUTES(VIDEO_BUFFERS_SPRITERAM) | |
| 976 | ||
| 977 | MDRV_SCREEN_ADD("main", RASTER) | |
| 978 | MDRV_SCREEN_REFRESH_RATE(60) | |
| 979 | MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(0)) | |
| 980 | MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16) | |
| 981 | MDRV_SCREEN_SIZE(32*8, 32*8) | |
| 982 | MDRV_SCREEN_VISIBLE_AREA(0*8, 32*8-1, 1*8, 31*8-1) | |
| 983 | ||
| 984 | MDRV_GFXDECODE(trojan) | |
| 985 | MDRV_PALETTE_LENGTH(1024) | |
| 986 | ||
| 987 | 836 | MDRV_VIDEO_START(avengers) |
| 988 | MDRV_VIDEO_EOF(lwings) | |
| 989 | MDRV_VIDEO_UPDATE(trojan) | |
| 990 | ||
| 991 | /* sound hardware */ | |
| 992 | MDRV_SPEAKER_STANDARD_MONO("mono") | |
| 993 | ||
| 994 | MDRV_SOUND_ADD(YM2203, 1500000) | |
| 995 | MDRV_SOUND_ROUTE(0, "mono", 0.20) | |
| 996 | MDRV_SOUND_ROUTE(1, "mono", 0.20) | |
| 997 | MDRV_SOUND_ROUTE(2, "mono", 0.20) | |
| 998 | MDRV_SOUND_ROUTE(3, "mono", 0.10) | |
| 999 | ||
| 1000 | MDRV_SOUND_ADD(YM2203, 1500000) | |
| 1001 | MDRV_SOUND_ROUTE(0, "mono", 0.20) | |
| 1002 | MDRV_SOUND_ROUTE(1, "mono", 0.20) | |
| 1003 | MDRV_SOUND_ROUTE(2, "mono", 0.20) | |
| 1004 | MDRV_SOUND_ROUTE(3, "mono", 0.10) | |
| 1005 | ||
| 1006 | MDRV_SOUND_ADD(MSM5205, 384000) | |
| 1007 | MDRV_SOUND_CONFIG(msm5205_interface) | |
| 1008 | MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50) | |
| 1009 | 837 | MACHINE_DRIVER_END |
| 1010 | 838 | |
| 1011 | /*************************************************************************** | |
| 839 | /************************************* | |
| 840 | * | |
| 841 | * ROM definition(s) | |
| 842 | * | |
| 843 | *************************************/ | |
| 1012 | 844 | |
| 1013 | Game driver(s) | |
| 1014 | ||
| 1015 | ***************************************************************************/ | |
| 1016 | ||
| 1017 | 845 | ROM_START( lwings ) |
| 1018 | 846 | ROM_REGION( 0x20000, REGION_CPU1, 0 ) /* 64k for code + 3*16k for the banked ROMs images */ |
| 1019 | 847 | ROM_LOAD( "6c_lw01.bin", 0x00000, 0x8000, CRC(b55a7f60) SHA1(e28cc540892a9ad050693900356744f8f5d05237) ) |
| r2724 | r2725 | |
| 1488 | 1316 | ROM_LOAD( "tbb_1bpr.1e", 0x0100, 0x0100, CRC(5052fa9d) SHA1(8cd240f4795a7ae76499573c09069dba37182be2) ) /* priority (not used) */ |
| 1489 | 1317 | ROM_END |
| 1490 | 1318 | |
| 1319 | /************************************* | |
| 1320 | * | |
| 1321 | * Game driver(s) | |
| 1322 | * | |
| 1323 | *************************************/ | |
| 1324 | ||
| 1491 | 1325 | GAME( 1985, sectionz, 0, lwings, sectionz, 0, ROT0, "Capcom", "Section Z (set 1)", 0 ) |
| 1492 | 1326 | GAME( 1985, sctionza, sectionz, lwings, sectionz, 0, ROT0, "Capcom", "Section Z (set 2)", 0 ) |
| 1493 | 1327 | GAME( 1986, lwings, 0, lwings, lwings, 0, ROT90, "Capcom", "Legendary Wings (US set 1)", 0 ) |
| 1494 | 1328 | GAME( 1986, lwings2, lwings, lwings, lwings, 0, ROT90, "Capcom", "Legendary Wings (US set 2)", 0 ) |
| 1495 | 1329 | GAME( 1986, lwingsjp, lwings, lwings, lwings, 0, ROT90, "Capcom", "Ares no Tsubasa (Japan)", 0 ) |
| 1496 | GAME( 1986, lwingsb, lwings, lwings, lwings, | |
| 1330 | GAME( 1986, lwingsb, lwings, lwings, lwingsb, | |
| 1497 | 1331 | GAME( 1986, trojan, 0, trojan, trojanls, 0, ROT0, "Capcom", "Trojan (US)", 0 ) |
| 1498 | 1332 | GAME( 1986, trojanr, trojan, trojan, trojan, 0, ROT0, "Capcom (Romstar license)", "Trojan (Romstar)", 0 ) |
| 1499 | 1333 | GAME( 1986, trojanj, trojan, trojan, trojan, 0, ROT0, "Capcom", "Tatakai no Banka (Japan)", 0 ) |
| r2724 | r2725 | |
|---|---|---|
| 226 | 226 | static INPUT_CHANGED( coin_inserted ) |
| 227 | 227 | { |
| 228 | 228 | if (!newval) |
| 229 | cpunum_set_input_line(machine, 1, M6805_IRQ_LINE, HOLD_LINE ); | |
| 229 | cpunum_set_input_line(field->port->machine, 1, M6805_IRQ_LINE, HOLD_LINE ); | |
| 230 | 230 | } |
| 231 | 231 | |
| 232 | 232 | int atari_input_disabled(void) |
| r2724 | r2725 | |
|---|---|---|
| 273 | 273 | **************************************************************************/ |
| 274 | 274 | |
| 275 | 275 | #include "driver.h" |
| 276 | #include "deprecat.h" | |
| 277 | 276 | #include "cpu/adsp2100/adsp2100.h" |
| 278 | 277 | #include "cpu/mips/mips3.h" |
| 279 | 278 | #include "audio/dcs.h" |
| r2724 | r2725 | |
| 502 | 501 | * |
| 503 | 502 | *************************************/ |
| 504 | 503 | |
| 505 | static void vblank_assert(int state); | |
| 504 | static void vblank_assert(running_machine *machine, int state); | |
| 506 | 505 | static TIMER_CALLBACK( nile_timer_callback ); |
| 507 | 506 | static void ide_interrupt(const device_config *device, int state); |
| 508 | 507 | static void remap_dynamic_addresses(running_machine *machine); |
| r2724 | r2725 | |
| 600 | 599 | /* reset subsystems */ |
| 601 | 600 | devtag_reset(machine, IDE_CONTROLLER, "ide"); |
| 602 | 601 | voodoo_reset(0); |
| 603 | smc91c94_reset(); | |
| 602 | smc91c94_reset(machine); | |
| 604 | 603 | |
| 605 | 604 | /* initialize IRQ states */ |
| 606 | 605 | ide_irq_state = 0; |
| r2724 | r2725 | |
| 892 | 891 | * |
| 893 | 892 | *************************************/ |
| 894 | 893 | |
| 895 | static void update_nile_irqs( | |
| 894 | static void update_nile_irqs(running_machine *machine) | |
| 896 | 895 | { |
| 897 | 896 | UINT32 intctll = nile_regs[NREG_INTCTRL+0]; |
| 898 | 897 | UINT32 intctlh = nile_regs[NREG_INTCTRL+1]; |
| r2724 | r2725 | |
| 944 | 943 | if (irq[i]) |
| 945 | 944 | { |
| 946 | 945 | if (LOG_NILE_IRQS) logerror(" 1"); |
| 947 | cpunum_set_input_line( | |
| 946 | cpunum_set_input_line(machine, 0, MIPS3_IRQ0 + i, ASSERT_LINE); | |
| 948 | 947 | } |
| 949 | 948 | else |
| 950 | 949 | { |
| 951 | 950 | if (LOG_NILE_IRQS) logerror(" 0"); |
| 952 | cpunum_set_input_line( | |
| 951 | cpunum_set_input_line(machine, 0, MIPS3_IRQ0 + i, CLEAR_LINE); | |
| 953 | 952 | } |
| 954 | 953 | } |
| 955 | 954 | if (LOG_NILE_IRQS) logerror("\n"); |
| r2724 | r2725 | |
| 977 | 976 | if (which == 3) |
| 978 | 977 | nile_irq_state |= 1 << 5; |
| 979 | 978 | |
| 980 | update_nile_irqs(); | |
| 979 | update_nile_irqs(machine); | |
| 981 | 980 | } |
| 982 | 981 | |
| 983 | 982 | |
| r2724 | r2725 | |
| 1119 | 1118 | case NREG_INTCTRL+1: /* Interrupt control */ |
| 1120 | 1119 | if (LOG_NILE) logerror("%08X:NILE WRITE: interrupt control(%03X) = %08X & %08X\n", activecpu_get_pc(), offset*4, data, mem_mask); |
| 1121 | 1120 | logit = 0; |
| 1122 | update_nile_irqs(); | |
| 1121 | update_nile_irqs(machine); | |
| 1123 | 1122 | break; |
| 1124 | 1123 | |
| 1125 | 1124 | case NREG_INTSTAT0+0: /* Interrupt status 0 */ |
| 1126 | 1125 | case NREG_INTSTAT0+1: /* Interrupt status 0 */ |
| 1127 | 1126 | if (LOG_NILE) logerror("%08X:NILE WRITE: interrupt status 0(%03X) = %08X & %08X\n", activecpu_get_pc(), offset*4, data, mem_mask); |
| 1128 | 1127 | logit = 0; |
| 1129 | update_nile_irqs(); | |
| 1128 | update_nile_irqs(machine); | |
| 1130 | 1129 | break; |
| 1131 | 1130 | |
| 1132 | 1131 | case NREG_INTSTAT1+0: /* Interrupt status 1 */ |
| 1133 | 1132 | case NREG_INTSTAT1+1: /* Interrupt status 1 */ |
| 1134 | 1133 | if (LOG_NILE) logerror("%08X:NILE WRITE: interrupt status 1/enable(%03X) = %08X & %08X\n", activecpu_get_pc(), offset*4, data, mem_mask); |
| 1135 | 1134 | logit = 0; |
| 1136 | update_nile_irqs(); | |
| 1135 | update_nile_irqs(machine); | |
| 1137 | 1136 | break; |
| 1138 | 1137 | |
| 1139 | 1138 | case NREG_INTCLR+0: /* Interrupt clear */ |
| r2724 | r2725 | |
| 1141 | 1140 | if (LOG_NILE) logerror("%08X:NILE WRITE: interrupt clear(%03X) = %08X & %08X\n", activecpu_get_pc(), offset*4, data, mem_mask); |
| 1142 | 1141 | logit = 0; |
| 1143 | 1142 | nile_irq_state &= ~(nile_regs[offset] & ~0xf00); |
| 1144 | update_nile_irqs(); | |
| 1143 | update_nile_irqs(machine); | |
| 1145 | 1144 | break; |
| 1146 | 1145 | |
| 1147 | 1146 | case NREG_INTPPES+0: /* PCI Interrupt control */ |
| r2724 | r2725 | |
| 1216 | 1215 | logit = 0; |
| 1217 | 1216 | break; |
| 1218 | 1217 | case NREG_UARTIER: /* serial interrupt enable */ |
| 1219 | update_nile_irqs(); | |
| 1218 | update_nile_irqs(machine); | |
| 1220 | 1219 | break; |
| 1221 | 1220 | |
| 1222 | 1221 | case NREG_VID: |
| r2724 | r2725 | |
| 1273 | 1272 | nile_irq_state |= 0x800; |
| 1274 | 1273 | else |
| 1275 | 1274 | nile_irq_state &= ~0x800; |
| 1276 | update_nile_irqs(); | |
| 1275 | update_nile_irqs(device->machine); | |
| 1277 | 1276 | } |
| 1278 | 1277 | |
| 1279 | 1278 | |
| r2724 | r2725 | |
| 1284 | 1283 | * |
| 1285 | 1284 | *************************************/ |
| 1286 | 1285 | |
| 1287 | static void update_sio_irqs( | |
| 1286 | static void update_sio_irqs(running_machine *machine) | |
| 1288 | 1287 | { |
| 1289 | 1288 | if (sio_irq_state & sio_irq_enable) |
| 1290 | 1289 | nile_irq_state |= 0x400; |
| 1291 | 1290 | else |
| 1292 | 1291 | nile_irq_state &= ~0x400; |
| 1293 | update_nile_irqs(); | |
| 1292 | update_nile_irqs(machine); | |
| 1294 | 1293 | } |
| 1295 | 1294 | |
| 1296 | 1295 | |
| 1297 | static void vblank_assert(int state) | |
| 1296 | static void vblank_assert(running_machine *machine, int state) | |
| 1298 | 1297 | { |
| 1299 | 1298 | if (!vblank_state && state) |
| 1300 | 1299 | { |
| 1301 | 1300 | sio_irq_state |= 0x20; |
| 1302 | update_sio_irqs(); | |
| 1301 | update_sio_irqs(machine); | |
| 1303 | 1302 | } |
| 1304 | 1303 | vblank_state = state; |
| 1305 | 1304 | |
| r2724 | r2725 | |
| 1311 | 1310 | } |
| 1312 | 1311 | |
| 1313 | 1312 | |
| 1314 | static void ioasic_irq(int state) | |
| 1313 | static void ioasic_irq(running_machine *machine, int state) | |
| 1315 | 1314 | { |
| 1316 | 1315 | if (state) |
| 1317 | 1316 | sio_irq_state |= 0x04; |
| 1318 | 1317 | else |
| 1319 | 1318 | sio_irq_state &= ~0x04; |
| 1320 | update_sio_irqs(); | |
| 1319 | update_sio_irqs(machine); | |
| 1321 | 1320 | } |
| 1322 | 1321 | |
| 1323 | 1322 | |
| 1324 | static void ethernet_interrupt(int state) | |
| 1323 | static void ethernet_interrupt(running_machine *machine, int state) | |
| 1325 | 1324 | { |
| 1326 | 1325 | if (state) |
| 1327 | 1326 | sio_irq_state |= 0x10; |
| 1328 | 1327 | else |
| 1329 | 1328 | sio_irq_state &= ~0x10; |
| 1330 | update_sio_irqs(); | |
| 1329 | update_sio_irqs(machine); | |
| 1331 | 1330 | } |
| 1332 | 1331 | |
| 1333 | 1332 | |
| r2724 | r2725 | |
| 1354 | 1353 | if (!(data & 0x08)) |
| 1355 | 1354 | { |
| 1356 | 1355 | sio_irq_state &= ~0x20; |
| 1357 | update_sio_irqs(); | |
| 1356 | update_sio_irqs(machine); | |
| 1358 | 1357 | } |
| 1359 | 1358 | } |
| 1360 | 1359 | } |
| r2724 | r2725 | |
| 1371 | 1370 | if (ACCESSING_BITS_0_7) |
| 1372 | 1371 | { |
| 1373 | 1372 | sio_irq_enable = data; |
| 1374 | update_sio_irqs(); | |
| 1373 | update_sio_irqs(machine); | |
| 1375 | 1374 | } |
| 1376 | 1375 | } |
| 1377 | 1376 |
| r2724 | r2725 | |
|---|---|---|
| 46 | 46 | |
| 47 | 47 | ***************************************************************************/ |
| 48 | 48 | #include "driver.h" |
| 49 | #include "deprecat.h" | |
| 50 | 49 | #include "cpu/z80/z80.h" |
| 51 | 50 | #include "sound/3812intf.h" |
| 52 | 51 | #include "sound/msm5205.h" |
| r2724 | r2725 | |
| 98 | 97 | { |
| 99 | 98 | MSM5205_set_volume(0,(data & 0x0f) * 100 / 15); |
| 100 | 99 | } |
| 101 | static void tecmo_adpcm_int(int num) | |
| 100 | static void tecmo_adpcm_int(running_machine *machine, int num) | |
| 102 | 101 | { |
| 103 | 102 | static int adpcm_data = -1; |
| 104 | 103 | |
| r2724 | r2725 | |
| 545 | 544 | |
| 546 | 545 | |
| 547 | 546 | |
| 548 | static void irqhandler(int linestate) | |
| 547 | static void irqhandler(running_machine *machine, int linestate) | |
| 549 | 548 | { |
| 550 | cpunum_set_input_line( | |
| 549 | cpunum_set_input_line(machine, 1,0,linestate); | |
| 551 | 550 | } |
| 552 | 551 | |
| 553 | 552 | static const struct YM3526interface ym3812_interface = |
| r2724 | r2725 | |
|---|---|---|
| 237 | 237 | |
| 238 | 238 | static READ16_HANDLER( kludge ) |
| 239 | 239 | { |
| 240 | return mame_rand( | |
| 240 | return mame_rand(machine) & 0x0700; | |
| 241 | 241 | } |
| 242 | 242 | |
| 243 | 243 | /* a kludge! */ |
| r2724 | r2725 | |
| 246 | 246 | UINT16 retvalue; |
| 247 | 247 | |
| 248 | 248 | // retvalue = OKIM6295_status_0_msb_r(offset,mem_mask); // doesn't work, causes lockups when girls change.. |
| 249 | retvalue = mame_rand( | |
| 249 | retvalue = mame_rand(machine); | |
| 250 | 250 | |
| 251 | 251 | return retvalue; |
| 252 | 252 | } |
| r2724 | r2725 | |
| 345 | 345 | /* |
| 346 | 346 | READ16_HANDLER( zipzap_random_read ) |
| 347 | 347 | { |
| 348 | return mame_rand( | |
| 348 | return mame_rand(machine); | |
| 349 | 349 | } |
| 350 | 350 | */ |
| 351 | 351 | static ADDRESS_MAP_START( zipzap_readmem, ADDRESS_SPACE_PROGRAM, 16 ) |
| r2724 | r2725 | |
|---|---|---|
| 10 | 10 | ***************************************************************************/ |
| 11 | 11 | |
| 12 | 12 | #include "driver.h" |
| 13 | #include "deprecat.h" | |
| 14 | 13 | #include "system16.h" |
| 15 | 14 | #include "cpu/m68000/m68000.h" |
| 16 | 15 | #include "machine/segaic16.h" |
| r2724 | r2725 | |
| 65 | 64 | * |
| 66 | 65 | *************************************/ |
| 67 | 66 | |
| 68 | static void update_main_irqs( | |
| 67 | static void update_main_irqs(running_machine *machine) | |
| 69 | 68 | { |
| 70 | 69 | int irq = 0; |
| 71 | 70 | |
| r2724 | r2725 | |
| 78 | 77 | /* assert the lines that are live, or clear everything if nothing is live */ |
| 79 | 78 | if (irq != 0) |
| 80 | 79 | { |
| 81 | cpunum_set_input_line(Machine, 0, irq, ASSERT_LINE); | |
| 82 | cpunum_set_input_line(Machine, 1, irq, ASSERT_LINE); | |
| 83 | cpunum_set_input_line(Machine, 2, irq, ASSERT_LINE); | |
| 80 | cpunum_set_input_line(machine, 0, irq, ASSERT_LINE); | |
| 81 | cpunum_set_input_line(machine, 1, irq, ASSERT_LINE); | |
| 82 | cpunum_set_input_line(machine, 2, irq, ASSERT_LINE); | |
| 84 | 83 | cpu_boost_interleave(attotime_zero, ATTOTIME_IN_USEC(50)); |
| 85 | 84 | } |
| 86 | 85 | else |
| 87 | 86 | { |
| 88 | cpunum_set_input_line(Machine, 0, 7, CLEAR_LINE); | |
| 89 | cpunum_set_input_line(Machine, 1, 7, CLEAR_LINE); | |
| 90 | cpunum_set_input_line(Machine, 2, 7, CLEAR_LINE); | |
| 87 | cpunum_set_input_line(machine, 0, 7, CLEAR_LINE); | |
| 88 | cpunum_set_input_line(machine, 1, 7, CLEAR_LINE); | |
| 89 | cpunum_set_input_line(machine, 2, 7, CLEAR_LINE); | |
| 91 | 90 | } |
| 92 | 91 | } |
| 93 | 92 | |
| r2724 | r2725 | |
| 161 | 160 | } |
| 162 | 161 | |
| 163 | 162 | /* update IRQs on the main CPU */ |
| 164 | update_main_irqs(); | |
| 163 | update_main_irqs(machine); | |
| 165 | 164 | |
| 166 | 165 | /* come back at the next appropriate scanline */ |
| 167 | 166 | timer_adjust_oneshot(interrupt_timer, video_screen_get_time_until_pos(machine->primary_screen, scanline, 0), scanline); |
| r2724 | r2725 | |
| 202 | 201 | * |
| 203 | 202 | *************************************/ |
| 204 | 203 | |
| 205 | static void sound_cpu_irq(int state) | |
| 204 | static void sound_cpu_irq(running_machine *machine, int state) | |
| 206 | 205 | { |
| 207 | cpunum_set_input_line( | |
| 206 | cpunum_set_input_line(machine, 3, 0, state); | |
| 208 | 207 | } |
| 209 | 208 | |
| 210 | 209 |
| r2724 | r2725 | |
|---|---|---|
| 466 | 466 | PORT_DIPNAME( 0x04, 0x00, DEF_STR( Unknown ) ) // Look code at 0x03c4 : 0x8076 is never tested ! |
| 467 | 467 | PORT_DIPSETTING( 0x00, DEF_STR( Off ) ) |
| 468 | 468 | PORT_DIPSETTING( 0x04, DEF_STR( On ) ) |
| 469 | PORT_ | |
| 469 | PORT_DIPNAME( | |
| 470 | 470 | PORT_DIPSETTING( 0x00, DEF_STR( Off ) ) |
| 471 | 471 | PORT_DIPSETTING( 0x08, DEF_STR( On ) ) |
| 472 | 472 | PORT_DIPNAME( 0x30, 0x00, DEF_STR( Coin_A ) ) |
| r2724 | r2725 | |
| 497 | 497 | PORT_DIPNAME( 0x04, 0x00, DEF_STR( Bonus_Life ) ) |
| 498 | 498 | PORT_DIPSETTING( 0x00, "30000" ) |
| 499 | 499 | PORT_DIPSETTING( 0x04, "50000" ) |
| 500 | PORT_ | |
| 500 | PORT_DIPNAME( | |
| 501 | 501 | PORT_DIPSETTING( 0x00, DEF_STR( Off ) ) |
| 502 | 502 | PORT_DIPSETTING( 0x08, DEF_STR( On ) ) |
| 503 | 503 | PORT_DIPNAME( 0x30, 0x00, DEF_STR( Coin_A ) ) |
| r2724 | r2725 | |
|---|---|---|
| 375 | 375 | |
| 376 | 376 | static CUSTOM_INPUT( p1_controls_r ) |
| 377 | 377 | { |
| 378 | return input_port_read(machine, "P1CONTROLS"); | |
| 378 | return input_port_read(field->port->machine, "P1CONTROLS"); | |
| 379 | 379 | } |
| 380 | 380 | |
| 381 | 381 | |
| 382 | 382 | static CUSTOM_INPUT( p2_controls_r ) |
| 383 | 383 | { |
| 384 | 384 | if (engima2_flip_screen) |
| 385 | return input_port_read(machine, "P2CONTROLS"); | |
| 385 | return input_port_read(field->port->machine, "P2CONTROLS"); | |
| 386 | 386 | else |
| 387 | return input_port_read(machine, "P1CONTROLS"); | |
| 387 | return input_port_read(field->port->machine, "P1CONTROLS"); | |
| 388 | 388 | } |
| 389 | 389 | |
| 390 | 390 |
| r2724 | r2725 | |
|---|---|---|
| 77 | 77 | palette_set_color_rgb(machine, offset, pal5bit(data >> 10), pal5bit(data >> 5), pal5bit(data >> 0)); |
| 78 | 78 | } |
| 79 | 79 | |
| 80 | static void voodoo_vblank_0(int param) | |
| 80 | static void voodoo_vblank_0(running_machine *machine, int param) | |
| 81 | 81 | { |
| 82 | cpunum_set_input_line( | |
| 82 | cpunum_set_input_line(machine, 0, INPUT_LINE_IRQ0, ASSERT_LINE); | |
| 83 | 83 | } |
| 84 | 84 | |
| 85 | static void voodoo_vblank_1(int param) | |
| 85 | static void voodoo_vblank_1(running_machine *machine, int param) | |
| 86 | 86 | { |
| 87 | cpunum_set_input_line( | |
| 87 | cpunum_set_input_line(machine, 0, INPUT_LINE_IRQ1, ASSERT_LINE); | |
| 88 | 88 | } |
| 89 | 89 | |
| 90 | 90 | static VIDEO_START( hangplt ) |
| r2724 | r2725 | |
| 1000 | 1000 | ROM_LOAD32_WORD( "685a14.12w", 0x000000, 0x400000, CRC(87437739) SHA1(0d45637af40938a54d5efd29c125b0fafd55f9a4) ) |
| 1001 | 1001 | ROM_END |
| 1002 | 1002 | |
| 1003 | static void sound_irq_callback(int irq) | |
| 1003 | static void sound_irq_callback(running_machine *machine, int irq) | |
| 1004 | 1004 | { |
| 1005 | 1005 | if (irq == 0) |
| 1006 | cpunum_set_input_line( | |
| 1006 | cpunum_set_input_line(machine, 1, INPUT_LINE_IRQ1, PULSE_LINE); | |
| 1007 | 1007 | else |
| 1008 | cpunum_set_input_line( | |
| 1008 | cpunum_set_input_line(machine, 1, INPUT_LINE_IRQ2, PULSE_LINE); | |
| 1009 | 1009 | } |
| 1010 | 1010 | |
| 1011 | 1011 | static DRIVER_INIT(gticlub) |
| r2724 | r2725 | |
|---|---|---|
| 828 | 828 | { |
| 829 | 829 | namcona1_gfxram_w( machine, (dest-0xf40000)/2, data, 0xffff ); |
| 830 | 830 | } |
| 831 | else if( dest>=0xff0000 && dest<0xff | |
| 831 | else if( dest>=0xff0000 && dest<0xffc000 ) | |
| 832 | 832 | { |
| 833 | 833 | namcona1_videoram_w( machine, (dest-0xff0000)/2, data, 0xffff ); |
| 834 | 834 | } |
| 835 | else if( dest>=0xff8000 && dest<0xffc000 ) | |
| 836 | { | |
| 837 | namcona1_rozvideoram_w( machine, (dest-0xff8000)/2, data, 0xffff ); | |
| 838 | } | |
| 839 | 835 | else if( dest>=0xfff000 && dest<0x1000000 ) |
| 840 | 836 | { |
| 841 | 837 | spriteram16[(dest-0xfff000)/2] = data; |
| r2724 | r2725 | |
| 1049 | 1045 | AM_RANGE(0xefff00, 0xefffff) AM_READWRITE(namcona1_vreg_r, namcona1_vreg_w) AM_BASE(&namcona1_vreg) |
| 1050 | 1046 | AM_RANGE(0xf00000, 0xf01fff) AM_READWRITE(namcona1_paletteram_r, namcona1_paletteram_w) AM_BASE(&paletteram16) |
| 1051 | 1047 | AM_RANGE(0xf40000, 0xf7ffff) AM_READWRITE(namcona1_gfxram_r, namcona1_gfxram_w) |
| 1052 | AM_RANGE(0xff0000, 0xff7fff) AM_READWRITE(namcona1_videoram_r, namcona1_videoram_w) AM_BASE(&videoram16) | |
| 1053 | AM_RANGE(0xff8000, 0xffbfff) AM_READWRITE(namcona1_rozvideoram_r, namcona1_rozvideoram_w) AM_BASE(&namcona1_rozvideoram) | |
| 1048 | AM_RANGE(0xff0000, 0xffbfff) AM_READWRITE(namcona1_videoram_r, namcona1_videoram_w) AM_BASE(&videoram16) | |
| 1054 | 1049 | AM_RANGE(0xffd000, 0xffdfff) AM_RAM /* unknown */ |
| 1055 | 1050 | AM_RANGE(0xffe000, 0xffefff) AM_RAM AM_BASE(&namcona1_scroll) /* scroll registers */ |
| 1056 | 1051 | AM_RANGE(0xfff000, 0xffffff) AM_RAM AM_BASE(&spriteram16) /* spriteram */ |
| r2724 | r2725 | |
| 1309 | 1304 | MDRV_SCREEN_SIZE(38*8, 32*8) |
| 1310 | 1305 | MDRV_SCREEN_VISIBLE_AREA(8, 38*8-1-8, 4*8, 32*8-1) |
| 1311 | 1306 | |
| 1312 | MDRV_PALETTE_LENGTH(0x | |
| 1307 | MDRV_PALETTE_LENGTH(0x2000) | |
| 1313 | 1308 | |
| 1314 | 1309 | MDRV_VIDEO_START(namcona1) |
| 1315 | 1310 | MDRV_VIDEO_UPDATE(namcona1) |
| r2724 | r2725 | |
| 1345 | 1340 | AM_RANGE(0xefff00, 0xefffff) AM_READ(namcona1_vreg_r) |
| 1346 | 1341 | AM_RANGE(0xf00000, 0xf01fff) AM_READ(namcona1_paletteram_r) |
| 1347 | 1342 | AM_RANGE(0xf40000, 0xf7ffff) AM_READ(namcona1_gfxram_r) |
| 1348 | AM_RANGE(0xff0000, 0xff7fff) AM_READ(namcona1_videoram_r) | |
| 1349 | AM_RANGE(0xff8000, 0xffbfff) AM_READ(namcona1_rozvideoram_r ) | |
| 1343 | AM_RANGE(0xff0000, 0xffbfff) AM_READ(namcona1_videoram_r) | |
| 1350 | 1344 | AM_RANGE(0xffd000, 0xffdfff) AM_READ(SMH_RAM) /* unknown */ |
| 1351 | 1345 | AM_RANGE(0xffe000, 0xffefff) AM_READ(SMH_RAM) /* scroll registers */ |
| 1352 | 1346 | AM_RANGE(0xfff000, 0xffffff) AM_READ(SMH_RAM) /* spriteram */ |
| r2724 | r2725 | |
| 1366 | 1360 | AM_RANGE(0xefff00, 0xefffff) AM_WRITE(namcona1_vreg_w) AM_BASE(&namcona1_vreg) |
| 1367 | 1361 | AM_RANGE(0xf00000, 0xf01fff) AM_WRITE(namcona1_paletteram_w) AM_BASE(&paletteram16) |
| 1368 | 1362 | AM_RANGE(0xf40000, 0xf7ffff) AM_WRITE(namcona1_gfxram_w) |
| 1369 | AM_RANGE(0xff0000, 0xff7fff) AM_WRITE(namcona1_videoram_w) AM_BASE(&videoram16) | |
| 1370 | AM_RANGE(0xff8000, 0xffbfff) AM_WRITE(namcona1_rozvideoram_w) AM_BASE(&namcona1_rozvideoram) | |
| 1363 | AM_RANGE(0xff0000, 0xffbfff) AM_WRITE(namcona1_videoram_w) AM_BASE(&videoram16) | |
| 1371 | 1364 | AM_RANGE(0xffd000, 0xffdfff) AM_WRITE(SMH_RAM) /* unknown */ |
| 1372 | 1365 | AM_RANGE(0xffe000, 0xffefff) AM_WRITE(SMH_RAM) AM_BASE(&namcona1_scroll) |
| 1373 | 1366 | AM_RANGE(0xfff000, 0xffffff) AM_WRITE(SMH_RAM) AM_BASE(&spriteram16) |
| r2724 | r2725 | |
| 1398 | 1391 | MDRV_SCREEN_SIZE(38*8, 32*8) |
| 1399 | 1392 | MDRV_SCREEN_VISIBLE_AREA(8, 38*8-1-8, 4*8, 32*8-1) |
| 1400 | 1393 | |
| 1401 | MDRV_PALETTE_LENGTH(0x | |
| 1394 | MDRV_PALETTE_LENGTH(0x2000) | |
| 1402 | 1395 | |
| 1403 | 1396 | MDRV_VIDEO_START(namcona1) |
| 1404 | 1397 | MDRV_VIDEO_UPDATE(namcona1) |
| r2724 | r2725 | |
|---|---|---|
| 146 | 146 | switch (bit_mask) |
| 147 | 147 | { |
| 148 | 148 | case 0x01: |
| 149 | return ((input_port_read(machine, "PAYOUT") & bit_mask) >> 0); | |
| 149 | return ((input_port_read(field->port->machine, "PAYOUT") & bit_mask) >> 0); | |
| 150 | 150 | case 0x02: |
| 151 | return ((input_port_read(machine, "PAYOUT") & bit_mask) >> 1); | |
| 151 | return ((input_port_read(field->port->machine, "PAYOUT") & bit_mask) >> 1); | |
| 152 | 152 | default: |
| 153 | 153 | logerror("sidewndr_payout_r : invalid %02X bit_mask\n",bit_mask); |
| 154 | 154 | return 0; |
| r2724 | r2725 | |
| 162 | 162 | switch (bit_mask) |
| 163 | 163 | { |
| 164 | 164 | case 0x01: |
| 165 | return ((input_port_read(machine, "COINAGE") & bit_mask) >> 0); | |
| 165 | return ((input_port_read(field->port->machine, "COINAGE") & bit_mask) >> 0); | |
| 166 | 166 | case 0x02: |
| 167 | return ((input_port_read(machine, "COINAGE") & bit_mask) >> 1); | |
| 167 | return ((input_port_read(field->port->machine, "COINAGE") & bit_mask) >> 1); | |
| 168 | 168 | case 0x04: |
| 169 | return ((input_port_read(machine, "COINAGE") & bit_mask) >> 2); | |
| 169 | return ((input_port_read(field->port->machine, "COINAGE") & bit_mask) >> 2); | |
| 170 | 170 | case 0x08: |
| 171 | return ((input_port_read(machine, "COINAGE") & bit_mask) >> 3); | |
| 171 | return ((input_port_read(field->port->machine, "COINAGE") & bit_mask) >> 3); | |
| 172 | 172 | default: |
| 173 | 173 | logerror("starspnr_coinage_r : invalid %02X bit_mask\n",bit_mask); |
| 174 | 174 | return 0; |
| r2724 | r2725 | |
| 182 | 182 | switch (bit_mask) |
| 183 | 183 | { |
| 184 | 184 | case 0x01: |
| 185 | return ((input_port_read(machine, "PAYOUT") & bit_mask) >> 0); | |
| 185 | return ((input_port_read(field->port->machine, "PAYOUT") & bit_mask) >> 0); | |
| 186 | 186 | case 0x02: |
| 187 | return ((input_port_read(machine, "PAYOUT") & bit_mask) >> 1); | |
| 187 | return ((input_port_read(field->port->machine, "PAYOUT") & bit_mask) >> 1); | |
| 188 | 188 | case 0x04: |
| 189 | return ((input_port_read(machine, "PAYOUT") & bit_mask) >> 2); | |
| 189 | return ((input_port_read(field->port->machine, "PAYOUT") & bit_mask) >> 2); | |
| 190 | 190 | default: |
| 191 | 191 | logerror("starspnr_payout_r : invalid %02X bit_mask\n",bit_mask); |
| 192 | 192 | return 0; |
| r2724 | r2725 | |
|---|---|---|
| 56 | 56 | static UINT8 *adpcmptr = 0; |
| 57 | 57 | static int appoooh_adpcm_data; |
| 58 | 58 | |
| 59 | static void appoooh_adpcm_int(int num) | |
| 59 | static void appoooh_adpcm_int(running_machine *machine, int num) | |
| 60 | 60 | { |
| 61 | 61 | if( adpcmptr ) |
| 62 | 62 | { |
| r2724 | r2725 | |
|---|---|---|
| 287 | 287 | |
| 288 | 288 | ***************************************************************************/ |
| 289 | 289 | |
| 290 | static void metlclsh_irqhandler(int linestate) | |
| 290 | static void metlclsh_irqhandler(running_machine *machine, int linestate) | |
| 291 | 291 | { |
| 292 | cpunum_set_input_line( | |
| 292 | cpunum_set_input_line(machine, 0,M6809_IRQ_LINE,linestate); | |
| 293 | 293 | } |
| 294 | 294 | |
| 295 | 295 | static const struct YM3526interface ym3526_interface = |
| r2724 | r2725 | |
|---|---|---|
| 69 | 69 | |
| 70 | 70 | |
| 71 | 71 | #include "driver.h" |
| 72 | #include "deprecat.h" | |
| 73 | 72 | #include "cpu/m6809/m6809.h" |
| 74 | 73 | #include "cpu/z80/z80.h" |
| 75 | 74 | #include "cpu/i8039/i8039.h" |
| r2724 | r2725 | |
| 257 | 256 | } |
| 258 | 257 | return 0; |
| 259 | 258 | } |
| 260 | static void saiyugb1_m5205_irq_w(int num) | |
| 259 | static void saiyugb1_m5205_irq_w(running_machine *machine, int num) | |
| 261 | 260 | { |
| 262 | 261 | adpcm_sound_irq = 1; |
| 263 | 262 | } |
| r2724 | r2725 | |
| 457 | 456 | GFXDECODE_ENTRY( REGION_GFX3, 0, tilelayout, 256, 8 ) /* 16x16 background tiles */ |
| 458 | 457 | GFXDECODE_END |
| 459 | 458 | |
| 460 | static void chinagat_irq_handler(int irq) { | |
| 461 | cpunum_set_input_line(Machine, 2, 0, irq ? ASSERT_LINE : CLEAR_LINE ); | |
| 459 | static void chinagat_irq_handler(running_machine *machine, int irq) | |
| 460 | { | |
| 461 | cpunum_set_input_line(machine, 2, 0, irq ? ASSERT_LINE : CLEAR_LINE ); | |
| 462 | 462 | } |
| 463 | 463 | |
| 464 | 464 | static const struct YM2151interface ym2151_interface = |
| r2724 | r2725 | |
|---|---|---|
| 243 | 243 | |
| 244 | 244 | static READ16_HANDLER( kaneko16_rnd_r ) |
| 245 | 245 | { |
| 246 | return mame_rand( | |
| 246 | return mame_rand(machine) & 0xffff; | |
| 247 | 247 | } |
| 248 | 248 | |
| 249 | 249 | static WRITE16_HANDLER( kaneko16_coin_lockout_w ) |
| r2724 | r2725 | |
|---|---|---|
| 138 | 138 | cpunum_set_input_line(machine, 1, INPUT_LINE_NMI, PULSE_LINE); |
| 139 | 139 | } |
| 140 | 140 | |
| 141 | static void dbz_sound_irq(int irq) | |
| 141 | static void dbz_sound_irq(running_machine *machine, int irq) | |
| 142 | 142 | { |
| 143 | 143 | if (irq) |
| 144 | cpunum_set_input_line( | |
| 144 | cpunum_set_input_line(machine, 1, 0, ASSERT_LINE); | |
| 145 | 145 | else |
| 146 | cpunum_set_input_line( | |
| 146 | cpunum_set_input_line(machine, 1, 0, CLEAR_LINE); | |
| 147 | 147 | } |
| 148 | 148 | |
| 149 | 149 | static ADDRESS_MAP_START( dbz_readmem, ADDRESS_SPACE_PROGRAM, 16 ) |
| r2724 | r2725 | |
|---|---|---|
| 52 | 52 | */ |
| 53 | 53 | |
| 54 | 54 | #include "driver.h" |
| 55 | #include "deprecat.h" | |
| 56 | 55 | #include "cpu/z80/z80.h" |
| 57 | 56 | #include "sound/2608intf.h" |
| 58 | 57 | |
| r2724 | r2725 | |
| 302 | 301 | |
| 303 | 302 | |
| 304 | 303 | /* handler called by the 2608 emulator when the internal timers cause an IRQ */ |
| 305 | static void irqhandler(int irq) | |
| 304 | static void irqhandler(running_machine *machine, int irq) | |
| 306 | 305 | { |
| 307 | cpunum_set_input_line( | |
| 306 | cpunum_set_input_line(machine, 2,0,irq ? ASSERT_LINE : CLEAR_LINE); | |
| 308 | 307 | } |
| 309 | 308 | |
| 310 | 309 | static const struct YM2608interface ym2608_interface = |
| 311 | 310 | { |
| 312 | 311 | { |
| 313 | AY8910_LEGACY_OUTPUT, | |
| 312 | AY8910_LEGACY_OUTPUT | AY8910_SINGLE_OUTPUT, | |
| 314 | 313 | AY8910_DEFAULT_LOADS, |
| 315 | 314 | NULL, NULL, NULL, NULL |
| 316 | 315 | }, |
| r2724 | r2725 | |
|---|---|---|
| 378 | 378 | |
| 379 | 379 | static INPUT_PORTS_START( gauntlet ) |
| 380 | 380 | PORT_START_TAG("IN0") /* 803000 */ |
| 381 | PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_START1 ) | |
| 382 | 381 | PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(1) |
| 383 | 382 | PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(1) |
| 384 | 383 | PORT_BIT( 0x000c, IP_ACTIVE_LOW, IPT_UNUSED ) |
| r2724 | r2725 | |
| 389 | 388 | PORT_BIT( 0xff00, IP_ACTIVE_LOW, IPT_UNUSED ) |
| 390 | 389 | |
| 391 | 390 | PORT_START_TAG("IN1") /* 803002 */ |
| 392 | PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_START2 ) | |
| 393 | 391 | PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(2) |
| 394 | 392 | PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(2) |
| 395 | 393 | PORT_BIT( 0x000c, IP_ACTIVE_LOW, IPT_UNUSED ) |
| r2724 | r2725 | |
| 400 | 398 | PORT_BIT( 0xff00, IP_ACTIVE_LOW, IPT_UNUSED ) |
| 401 | 399 | |
| 402 | 400 | PORT_START_TAG("IN2") /* 803004 */ |
| 403 | PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_START3 ) | |
| 404 | 401 | PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(3) |
| 405 | 402 | PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(3) |
| 406 | 403 | PORT_BIT( 0x000c, IP_ACTIVE_LOW, IPT_UNUSED ) |
| r2724 | r2725 | |
| 411 | 408 | PORT_BIT( 0xff00, IP_ACTIVE_LOW, IPT_UNUSED ) |
| 412 | 409 | |
| 413 | 410 | PORT_START_TAG("IN3") /* 803006 */ |
| 414 | PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_START4 ) | |
| 415 | 411 | PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(4) |
| 416 | 412 | PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(4) |
| 417 | 413 | PORT_BIT( 0x000c, IP_ACTIVE_LOW, IPT_UNUSED ) |
| r2724 | r2725 | |
|---|---|---|
| 440 | 440 | |
| 441 | 441 | |
| 442 | 442 | /* 6809 IRQ handler */ |
| 443 | static void cpu0_irq(int state) | |
| 443 | static void cpu0_irq(running_machine *machine, int state) | |
| 444 | 444 | { |
| 445 | 445 | /* The PIA and PTM IRQ lines are all connected to a common PCB track, leading directly to the 6809 IRQ line. */ |
| 446 | 446 | int combined_state = pia_get_irq_a(0) | pia_get_irq_b(0) | |
| r2724 | r2725 | |
| 453 | 453 | |
| 454 | 454 | if (!serial_card_connected) |
| 455 | 455 | { |
| 456 | cpunum_set_input_line( | |
| 456 | cpunum_set_input_line(machine, 0, M6809_IRQ_LINE, combined_state ? ASSERT_LINE : CLEAR_LINE); | |
| 457 | 457 | LOG(("6809 int%d \n", combined_state)); |
| 458 | 458 | } |
| 459 | 459 | else |
| 460 | 460 | { |
| 461 | cpunum_set_input_line( | |
| 461 | cpunum_set_input_line(machine, 0, M6809_FIRQ_LINE, combined_state ? ASSERT_LINE : CLEAR_LINE); | |
| 462 | 462 | LOG(("6809 fint%d \n", combined_state)); |
| 463 | 463 | } |
| 464 | 464 | } |
| r2724 | r2725 | |
|---|---|---|
| 11 | 11 | ***************************************************************************/ |
| 12 | 12 | |
| 13 | 13 | #include "driver.h" |
| 14 | #include "deprecat.h" | |
| 15 | 14 | #include "cpu/h6280/h6280.h" |
| 16 | 15 | #include "sound/2203intf.h" |
| 17 | 16 | #include "sound/2151intf.h" |
| r2724 | r2725 | |
| 274 | 273 | |
| 275 | 274 | /******************************************************************************/ |
| 276 | 275 | |
| 277 | static void sound_irq(int state) | |
| 276 | static void sound_irq(running_machine *machine, int state) | |
| 278 | 277 | { |
| 279 | cpunum_set_input_line( | |
| 278 | cpunum_set_input_line(machine, 1,1,state); /* IRQ 2 */ | |
| 280 | 279 | } |
| 281 | 280 | |
| 282 | 281 | static const struct YM2151interface ym2151_interface = |
| r2724 | r2725 | |
|---|---|---|
| 126 | 126 | *******************************************************************************/ |
| 127 | 127 | |
| 128 | 128 | #include "driver.h" |
| 129 | #include "deprecat.h" | |
| 130 | 129 | #include "sound/okim6295.h" |
| 131 | 130 | #include "sound/3812intf.h" |
| 132 | 131 | |
| r2724 | r2725 | |
| 342 | 341 | GFXDECODE_ENTRY( REGION_GFX3, 0, spritelayout, 0x0000, 16 + 384 ) |
| 343 | 342 | GFXDECODE_END |
| 344 | 343 | |
| 345 | static void irqhandler(int linestate) | |
| 344 | static void irqhandler(running_machine *machine, int linestate) | |
| 346 | 345 | { |
| 347 | cpunum_set_input_line( | |
| 346 | cpunum_set_input_line(machine, 1,0,linestate); | |
| 348 | 347 | } |
| 349 | 348 | |
| 350 | 349 | static const struct YM3812interface ym3812_interface = |
| r2724 | r2725 | |
|---|---|---|
| 160 | 160 | */ |
| 161 | 161 | |
| 162 | 162 | #include "driver.h" |
| 163 | #include "deprecat.h" | |
| 164 | 163 | #include "cpu/z80/z80.h" |
| 165 | 164 | #include "cpu/i8039/i8039.h" |
| 166 | 165 | #include "system16.h" |
| r2724 | r2725 | |
| 269 | 268 | sample_buffer = data; |
| 270 | 269 | } |
| 271 | 270 | |
| 272 | static void tturfbl_msm5205_callback(int data) | |
| 271 | static void tturfbl_msm5205_callback(running_machine *machine, int data) | |
| 273 | 272 | { |
| 274 | 273 | MSM5205_data_w(0, (sample_buffer >> 4) & 0x0F); |
| 275 | 274 | sample_buffer <<= 4; |
| 276 | 275 | sample_select ^= 1; |
| 277 | 276 | if(sample_select == 0) |
| 278 | cpunum_set_input_line( | |
| 277 | cpunum_set_input_line(machine, 1, INPUT_LINE_NMI, PULSE_LINE); | |
| 279 | 278 | } |
| 280 | 279 | |
| 281 | 280 | static const struct MSM5205interface tturfbl_msm5205_interface = |
| r2724 | r2725 | |
| 1834 | 1833 | AM_RANGE(0xffc000, 0xffffff) AM_WRITE(SYS16_MWA16_WORKINGRAM) AM_BASE(&sys16_workingram) |
| 1835 | 1834 | ADDRESS_MAP_END |
| 1836 | 1835 | |
| 1836 | ||
| 1837 | ||
| 1838 | static READ16_HANDLER(beautyb_unk1_r) | |
| 1839 | { | |
| 1840 | ||
| 1841 | return mame_rand(machine);; | |
| 1842 | } | |
| 1843 | ||
| 1844 | ||
| 1845 | static READ16_HANDLER(beautyb_unk2_r) | |
| 1846 | { | |
| 1847 | return mame_rand(machine); | |
| 1848 | } | |
| 1849 | ||
| 1850 | static ADDRESS_MAP_START( beautyb_map, ADDRESS_SPACE_PROGRAM, 16 ) | |
| 1851 | AM_RANGE(0x000000, 0x00ffff) AM_READWRITE(SMH_ROM, SMH_NOP) | |
| 1852 | //AM_RANGE(0x010000, 0x03ffff) AM_WRITE(SMH_NOP) | |
| 1853 | ||
| 1854 | AM_RANGE(0x0280D6, 0x0280D7) AM_READ(beautyb_unk2_r) | |
| 1855 | AM_RANGE(0x0280D8, 0x0280D9) AM_READ(beautyb_unk2_r) | |
| 1856 | ||
| 1857 | AM_RANGE(0x400000, 0x40ffff) AM_RAM AM_READWRITE(SYS16_MRA16_TILERAM, SYS16_MWA16_TILERAM) AM_BASE(&sys16_tileram) | |
| 1858 | AM_RANGE(0x410000, 0x410fff) AM_RAM AM_READWRITE(SYS16_MRA16_TEXTRAM, SYS16_MWA16_TEXTRAM) AM_BASE(&sys16_textram) | |
| 1859 | AM_RANGE(0x418000, 0x41803f) AM_RAM AM_READWRITE(SYS16_MRA16_EXTRAM2, SYS16_MWA16_EXTRAM2) AM_BASE(&sys16_extraram2) | |
| 1860 | AM_RANGE(0x440000, 0x440fff) AM_RAM AM_READWRITE(SYS16_MRA16_SPRITERAM, SYS16_MWA16_SPRITERAM) AM_BASE(&sys16_spriteram) | |
| 1861 | AM_RANGE(0x840000, 0x840fff) AM_RAM AM_READWRITE(SYS16_MRA16_PALETTERAM, SYS16_MWA16_PALETTERAM) AM_BASE(&paletteram16) | |
| 1862 | ||
| 1863 | AM_RANGE(0xC41000, 0xC41001) AM_READ(beautyb_unk1_r ) | |
| 1864 | AM_RANGE(0xC41002, 0xC41003) AM_READ(beautyb_unk1_r ) | |
| 1865 | ||
| 1866 | AM_RANGE(0xc40000, 0xc40001) AM_WRITE(SMH_NOP) | |
| 1867 | AM_RANGE(0xc80000, 0xc80001) AM_WRITE(SMH_NOP) | |
| 1868 | ||
| 1869 | AM_RANGE(0xffc000, 0xffffff) AM_RAM AM_WRITE(SYS16_MWA16_WORKINGRAM) AM_BASE(&sys16_workingram) | |
| 1870 | ADDRESS_MAP_END | |
| 1871 | ||
| 1837 | 1872 | /***************************************************************************/ |
| 1838 | 1873 | |
| 1839 | 1874 | |
| r2724 | r2725 | |
| 1905 | 1940 | MDRV_MACHINE_RESET(tetrisbl) |
| 1906 | 1941 | MACHINE_DRIVER_END |
| 1907 | 1942 | |
| 1943 | static MACHINE_DRIVER_START( beautyb ) | |
| 1944 | ||
| 1945 | /* basic machine hardware */ | |
| 1946 | MDRV_IMPORT_FROM(system16) | |
| 1947 | MDRV_CPU_MODIFY("main") | |
| 1948 | MDRV_CPU_PROGRAM_MAP(beautyb_map, 0) | |
| 1949 | ||
| 1950 | MDRV_MACHINE_RESET(tetrisbl) | |
| 1951 | MACHINE_DRIVER_END | |
| 1952 | ||
| 1953 | ||
| 1908 | 1954 | /***************************************************************************/ |
| 1909 | 1955 | |
| 1910 | 1956 | static READ16_HANDLER( tt_io_player1_r ) |
| r2724 | r2725 | |
| 2801 | 2847 | GAME( 1988, tetrisbl, tetris, tetrisbl, tetris, tetrisbl, ROT0, "bootleg", "Tetris (bootleg)", 0 ) |
| 2802 | 2848 | GAME( 1989, tturfbl, tturf, tturfbl, tturf, tturfbl, ROT0, "bootleg", "Tough Turf (bootleg)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND | GAME_NOT_WORKING ) |
| 2803 | 2849 | GAME( 1988, wb3bbl, wb3, wb3bbl, wb3b, wb3bbl, ROT0, "bootleg", "Wonder Boy III - Monster Lair (bootleg)", 0 ) |
| 2850 | ||
| 2851 | DRIVER_INIT( beautyb ) | |
| 2852 | { | |
| 2853 | UINT16*rom = (UINT16*)memory_region( REGION_CPU1 ); | |
| 2854 | int x; | |
| 2855 | ||
| 2856 | for (x=0;x<0x8000;x++) | |
| 2857 | { | |
| 2858 | rom[x] = rom[x] ^ 0x2400; | |
| 2859 | ||
| 2860 | if (x&8) rom[x] = BITSWAP16(rom[x],15,14,10,12, 11,13,9,8, | |
| 2861 | 7,6,5,4, 3,2,1,0 ); | |
| 2862 | ||
| 2863 | } | |
| 2864 | ||
| 2865 | MACHINE_RESET_CALL(sys16_onetime); | |
| 2866 | ||
| 2867 | } | |
| 2868 | ||
| 2869 | /* Program Roms contain | |
| 2870 | ||
| 2871 | Designed and Programmed by A.M.T. Research & Development Department 03/30/1991. | |
| 2872 | Copying or Revising for Commercial Use Is Not Permitted. | |
| 2873 | ||
| 2874 | */ | |
| 2875 | ||
| 2876 | ROM_START( beautyb ) | |
| 2877 | ROM_REGION( 0x010000, REGION_CPU1, ROMREGION_ERASEFF ) /* 68000 code */ | |
| 2878 | ROM_LOAD16_BYTE( "b13.u3", 0x00000, 0x8000, CRC(90c4489b) SHA1(240275ad6dfd02feab636ceb620264d339e79b6a) ) | |
| 2879 | ROM_LOAD16_BYTE( "b23.u2", 0x00001, 0x8000, CRC(79b8f9ed) SHA1(5926852ea00b60d91684dbea4687b67894a397a1) ) | |
| 2880 | ||
| 2881 | ROM_REGION( 0x30000, REGION_GFX1, ROMREGION_DISPOSE ) /* tiles */ | |
| 2882 | ROM_LOAD( "b43.bin", 0x00000, 0x10000, CRC(67fe3f0c) SHA1(c9479512dd7a80895740c7fbd2133ab4d4c679d6) ) | |
| 2883 | ROM_LOAD( "b53.bin", 0x10000, 0x10000, CRC(aca8e330) SHA1(912e636e3c1e238682ea29620e8e2c6089c77209) ) | |
| 2884 | ROM_LOAD( "b63.bin", 0x20000, 0x10000, CRC(f2af2fd5) SHA1(0a95ebb5eae7cdc6535533d73d06419c23d01ac3) ) | |
| 2885 | ||
| 2886 | ROM_REGION( 0x020000, REGION_GFX2, ROMREGION_ERASEFF ) /* sprites */ | |
| 2887 | /* no sprites on this */ | |
| 2888 | ||
| 2889 | ROM_REGION( 0x40000, REGION_CPU2, 0 ) /* sound CPU */ | |
| 2890 | ROM_LOAD( "1.bin", 0x0000, 0x8000, CRC(bd9ba01b) SHA1(fafa7dc36cc057a50ae4cdf7a35f3594292336f4) ) | |
| 2891 | ||
| 2892 | ROM_REGION( 0x0020, REGION_PROMS, 0 ) | |
| 2893 | ROM_LOAD( "82s123.2", 0x0000, 0x0020, CRC(58bcf8bd) SHA1(e4d3d179b08c0f3424a6bec0f15058fb1b56f8d8) ) | |
| 2894 | ||
| 2895 | ROM_REGION( 0x0144, REGION_USER1, 0 ) | |
| 2896 | ROM_LOAD( "pal16r4acn.1", 0x0000, 0x0104, CRC(826be9e7) SHA1(893fc49c38aa8e7d6e98f6320157ba627a5d1748) ) | |
| 2897 | ROM_LOAD( "pal16r4acn.2", 0x0000, 0x0104, CRC(b3084ffe) SHA1(086ad2f89bdd8524ae358fd49b0803f9bb4aff33) ) | |
| 2898 | ROM_LOAD( "pal16r4acn.3", 0x0000, 0x0104, CRC(741cd872) SHA1(d53bdcadcd25d44b6423e0740e88209f85c709bd) ) | |
| 2899 | ROM_LOAD( "pal20l8acn", 0x0000, 0x0144, CRC(36e30d71) SHA1(e38f0257f9beedccc9421eec78701a86465d16ad) ) | |
| 2900 | ROM_LOAD( "pal16l8ajc.u4", 0x0000, 0x0104, NO_DUMP) | |
| 2901 | ROM_END | |
| 2902 | ||
| 2903 | ||
| 2904 | GAME( 1991, beautyb, 0, beautyb, tetris, beautyb, ROT0, "AMT", "Beauty Block", GAME_NO_SOUND|GAME_NOT_WORKING ) | |
| 2905 |
| r2724 | r2725 | |
|---|---|---|
| 32 | 32 | ***************************************************************************/ |
| 33 | 33 | |
| 34 | 34 | #include "driver.h" |
| 35 | #include "deprecat.h" | |
| 36 | 35 | #include "cpu/z80/z80.h" |
| 37 | 36 | #include "sound/okim6295.h" |
| 38 | 37 | #include "sound/3812intf.h" |
| r2724 | r2725 | |
| 305 | 304 | GFXDECODE_END |
| 306 | 305 | |
| 307 | 306 | |
| 308 | static void irqhandler(int linestate) | |
| 307 | static void irqhandler(running_machine *machine, int linestate) | |
| 309 | 308 | { |
| 310 | 309 | /* system 16c doesn't have the sound CPU */ |
| 311 | if (Machine->config->cpu[1].type != CPU_DUMMY) | |
| 312 | cpunum_set_input_line(Machine, 1,0,linestate); | |
| 310 | if (machine->config->cpu[1].type != CPU_DUMMY) | |
| 311 | cpunum_set_input_line(machine, 1,0,linestate); | |
| 313 | 312 | } |
| 314 | 313 | |
| 315 | 314 | static const struct YM3812interface ym3812_interface = |
| r2724 | r2725 | |
|---|---|---|
| 112 | 112 | * |
| 113 | 113 | *************************************/ |
| 114 | 114 | |
| 115 | static void main_cpu_irq(int state) | |
| 115 | static void main_cpu_irq(running_machine *machine, int state) | |
| 116 | 116 | { |
| 117 | 117 | int combined_state = pia_get_irq_a(1) | pia_get_irq_b(1) | pia_get_irq_b(2); |
| 118 | 118 | |
| 119 | cpunum_set_input_line( | |
| 119 | cpunum_set_input_line(machine, 0, M6809_IRQ_LINE, combined_state ? ASSERT_LINE : CLEAR_LINE); | |
| 120 | 120 | } |
| 121 | 121 | |
| 122 | 122 | |
| 123 | static void main_cpu_firq(int state) | |
| 123 | static void main_cpu_firq(running_machine *machine, int state) | |
| 124 | 124 | { |
| 125 | cpunum_set_input_line( | |
| 125 | cpunum_set_input_line(machine, 0, M6809_FIRQ_LINE, state ? ASSERT_LINE : CLEAR_LINE); | |
| 126 | 126 | } |
| 127 | 127 | |
| 128 | 128 |
| r2724 | r2725 | |
|---|---|---|
| 718 | 718 | PORT_DIPSETTING( 0x40, DEF_STR( 1C_4C ) ) |
| 719 | 719 | PORT_DIPSETTING( 0x30, DEF_STR( 1C_5C ) ) |
| 720 | 720 | PORT_DIPSETTING( 0x20, DEF_STR( 1C_6C ) ) |
| 721 | PORT_ | |
| 721 | PORT_DIPNAME( 0x80, | |
| 722 | 722 | PORT_DIPSETTING( 0x80, DEF_STR( Off ) ) |
| 723 | 723 | PORT_DIPSETTING( 0x00, DEF_STR( On ) ) |
| 724 | 724 | |
| r2724 | r2725 | |
| 779 | 779 | PORT_DIPNAME( 0x40, 0x40, DEF_STR( Demo_Sounds ) ) |
| 780 | 780 | PORT_DIPSETTING( 0x00, DEF_STR( Off ) ) |
| 781 | 781 | PORT_DIPSETTING( 0x40, DEF_STR( On ) ) |
| 782 | PORT_ | |
| 782 | PORT_DIPNAME( 0x80, | |
| 783 | 783 | PORT_DIPSETTING( 0x80, DEF_STR( Off ) ) |
| 784 | 784 | PORT_DIPSETTING( 0x00, DEF_STR( On ) ) |
| 785 | 785 |
| r2724 | r2725 | |
|---|---|---|
| 48 | 48 | */ |
| 49 | 49 | |
| 50 | 50 | #include "driver.h" |
| 51 | #include "deprecat.h" | |
| 52 | 51 | #include "machine/z80ctc.h" |
| 53 | 52 | #include "sound/2203intf.h" |
| 54 | 53 | #include "machine/8255ppi.h" |
| r2724 | r2725 | |
| 286 | 285 | GFXDECODE_ENTRY( REGION_GFX2, 0, layout_8x8x3, 0x100, 32 ) // 3bpp tiles |
| 287 | 286 | GFXDECODE_END |
| 288 | 287 | |
| 289 | static void ctc0_interrupt(int state) | |
| 288 | static void ctc0_interrupt(running_machine *machine, int state) | |
| 290 | 289 | { |
| 291 | cpunum_set_input_line( | |
| 290 | cpunum_set_input_line(machine, 1, 0, state); | |
| 292 | 291 | } |
| 293 | 292 | |
| 294 | 293 | static z80ctc_interface ctc_intf = |
| r2724 | r2725 | |
|---|---|---|
| 190 | 190 | PORT_DIPSETTING( 0x10, "3" ) |
| 191 | 191 | PORT_DIPSETTING( 0x08, "4" ) |
| 192 | 192 | PORT_DIPSETTING( 0x00, "5" ) |
| 193 | PORT_ | |
| 193 | PORT_DIPNAME( | |
| 194 | 194 | PORT_DIPSETTING( 0x20, DEF_STR( Off ) ) |
| 195 | 195 | PORT_DIPSETTING( 0x00, DEF_STR( On ) ) |
| 196 | 196 | PORT_DIPNAME( 0xc0, 0x80, DEF_STR( Difficulty ) ) |
| r2724 | r2725 | |
| 274 | 274 | PORT_DIPSETTING( 0x10, "15000" ) |
| 275 | 275 | PORT_DIPSETTING( 0x20, "20000" ) |
| 276 | 276 | PORT_DIPSETTING( 0x30, "30000" ) |
| 277 | PORT_ | |
| 277 | PORT_DIPNAME( 0x40, 0x40, | |
| 278 | 278 | PORT_DIPSETTING( 0x40, DEF_STR( Off ) ) |
| 279 | 279 | PORT_DIPSETTING( 0x00, DEF_STR( On ) ) |
| 280 | 280 | PORT_DIPNAME( 0x80, 0x80, DEF_STR( Cabinet ) ) |
| r2724 | r2725 | |
|---|---|---|
| 7 | 7 | ***************************************************************************/ |
| 8 | 8 | |
| 9 | 9 | #include "driver.h" |
| 10 | #include "deprecat.h" | |
| 11 | 10 | #include "cpu/m6502/m6502.h" |
| 12 | 11 | #include "sound/2203intf.h" |
| 13 | 12 | #include "sound/3812intf.h" |
| r2724 | r2725 | |
| 231 | 230 | |
| 232 | 231 | /******************************************************************************/ |
| 233 | 232 | |
| 234 | static void irqhandler(int linestate) | |
| 233 | static void irqhandler(running_machine *machine, int linestate) | |
| 235 | 234 | { |
| 236 | cpunum_set_input_line( | |
| 235 | cpunum_set_input_line(machine, 1,0,linestate); | |
| 237 | 236 | } |
| 238 | 237 | |
| 239 | 238 | static const struct YM3812interface ym3812_interface = |
| r2724 | r2725 | |
|---|---|---|
| 9 | 9 | ***************************************************************************/ |
| 10 | 10 | |
| 11 | 11 | #include "driver.h" |
| 12 | #include "deprecat.h" | |
| 13 | 12 | #include "sound/upd7759.h" |
| 14 | 13 | #include "sound/3812intf.h" |
| 15 | 14 | |
| r2724 | r2725 | |
| 215 | 214 | |
| 216 | 215 | /******************************************************************************/ |
| 217 | 216 | |
| 218 | static void irqhandler(int irq) | |
| 217 | static void irqhandler(running_machine *machine, int irq) | |
| 219 | 218 | { |
| 220 | cpunum_set_input_line( | |
| 219 | cpunum_set_input_line(machine, 1,0,irq ? ASSERT_LINE : CLEAR_LINE); | |
| 221 | 220 | } |
| 222 | 221 | |
| 223 | 222 | static const struct YM3812interface ym3812_interface = |
| r2724 | r2725 | |
|---|---|---|
| 9 | 9 | ***************************************************************************/ |
| 10 | 10 | |
| 11 | 11 | #include "driver.h" |
| 12 | #include "deprecat.h" | |
| 13 | 12 | #include "cpu/konami/konami.h" /* for the callback and the firq irq definition */ |
| 14 | 13 | #include "cpu/z80/z80.h" |
| 15 | 14 | #include "video/konamiic.h" |
| r2724 | r2725 | |
| 69 | 68 | #if 0 |
| 70 | 69 | static int nmi_enabled; |
| 71 | 70 | |
| 72 | static void sound_nmi_callback( int param ) | |
| 71 | static void sound_nmi_callback( running_machine *machine, int param ) | |
| 73 | 72 | { |
| 74 | cpunum_set_input_line( | |
| 73 | cpunum_set_input_line(machine, 1, INPUT_LINE_NMI, ( nmi_enabled ) ? CLEAR_LINE : ASSERT_LINE ); | |
| 75 | 74 | |
| 76 | 75 | nmi_enabled = 0; |
| 77 | 76 | } |
| r2724 | r2725 | |
|---|---|---|
| 328 | 328 | Straight from Ddragon 3 |
| 329 | 329 | *******************************************************************************/ |
| 330 | 330 | |
| 331 | static void wwfsstar_ymirq_handler(int irq) | |
| 331 | static void wwfsstar_ymirq_handler(running_machine *machine, int irq) | |
| 332 | 332 | { |
| 333 | cpunum_set_input_line( | |
| 333 | cpunum_set_input_line(machine, 1, 0 , irq ? ASSERT_LINE : CLEAR_LINE ); | |
| 334 | 334 | } |
| 335 | 335 | |
| 336 | 336 | static const struct YM2151interface ym2151_interface = |
| r2724 | r2725 | |
|---|---|---|
| 23 | 23 | *******************************************************************************/ |
| 24 | 24 | |
| 25 | 25 | #include "driver.h" |
| 26 | #include "deprecat.h" | |
| 27 | 26 | #include "cpu/m6502/m6502.h" |
| 28 | 27 | #include "cpu/h6280/h6280.h" |
| 29 | 28 | #include "sound/2203intf.h" |
| r2724 | r2725 | |
| 335 | 334 | |
| 336 | 335 | /******************************************************************************/ |
| 337 | 336 | |
| 338 | static void sound_irq(int linestate) | |
| 337 | static void sound_irq(running_machine *machine, int linestate) | |
| 339 | 338 | { |
| 340 | cpunum_set_input_line( | |
| 339 | cpunum_set_input_line(machine, 1,0,linestate); /* IRQ */ | |
| 341 | 340 | } |
| 342 | 341 | |
| 343 | 342 | static const struct YM3812interface ym3812_interface = |
| r2724 | r2725 | |
|---|---|---|
| 1380 | 1380 | PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN ) |
| 1381 | 1381 | PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN ) |
| 1382 | 1382 | |
| 1383 | PORT_START_TAG("IN | |
| 1383 | PORT_START_TAG("IN1") | |
| 1384 | 1384 | TAITO_B_PLAYERS_INPUT( 2 ) |
| 1385 | 1385 | PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN ) |
| 1386 | 1386 | PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN ) |
| r2724 | r2725 | |
| 2566 | 2566 | |
| 2567 | 2567 | |
| 2568 | 2568 | /* handler called by the YM2610 emulator when the internal timers cause an IRQ */ |
| 2569 | static void irqhandler(int irq) | |
| 2569 | static void irqhandler(running_machine *machine, int irq) | |
| 2570 | 2570 | { |
| 2571 | cpunum_set_input_line( | |
| 2571 | cpunum_set_input_line(machine, 1,0,irq ? ASSERT_LINE : CLEAR_LINE); | |
| 2572 | 2572 | } |
| 2573 | 2573 | |
| 2574 | 2574 | static const struct YM2610interface ym2610_interface_rsaga2 = |
| r2724 | r2725 | |
|---|---|---|
| 318 | 318 | |
| 319 | 319 | static CUSTOM_INPUT( seawolf_erase_input_r ) |
| 320 | 320 | { |
| 321 | return input_port_read(machine, SEAWOLF_ERASE_SW_PORT_TAG) & | |
| 322 | input_port_read(machine, SEAWOLF_ERASE_DIP_PORT_TAG); | |
| 321 | return input_port_read(field->port->machine, SEAWOLF_ERASE_SW_PORT_TAG) & | |
| 322 | input_port_read(field->port->machine, SEAWOLF_ERASE_DIP_PORT_TAG); | |
| 323 | 323 | } |
| 324 | 324 | |
| 325 | 325 | |
| r2724 | r2725 | |
| 549 | 549 | |
| 550 | 550 | static CUSTOM_INPUT( tornbase_hit_left_input_r ) |
| 551 | 551 | { |
| 552 | return input_port_read(machine, TORNBASE_L_HIT_PORT_TAG); | |
| 552 | return input_port_read(field->port->machine, TORNBASE_L_HIT_PORT_TAG); | |
| 553 | 553 | } |
| 554 | 554 | |
| 555 | 555 | |
| r2724 | r2725 | |
| 557 | 557 | { |
| 558 | 558 | UINT32 ret; |
| 559 | 559 | |
| 560 | switch (tornbase_get_cabinet_type(machine)) | |
| 560 | switch (tornbase_get_cabinet_type(field->port->machine)) | |
| 561 | 561 | { |
| 562 | 562 | case TORNBASE_CAB_TYPE_UPRIGHT_OLD: |
| 563 | ret = input_port_read(machine, TORNBASE_L_HIT_PORT_TAG); | |
| 563 | ret = input_port_read(field->port->machine, TORNBASE_L_HIT_PORT_TAG); | |
| 564 | 564 | break; |
| 565 | 565 | |
| 566 | 566 | case TORNBASE_CAB_TYPE_UPRIGHT_NEW: |
| 567 | 567 | case TORNBASE_CAB_TYPE_COCKTAIL: |
| 568 | 568 | default: |
| 569 | ret = input_port_read(machine, TORNBASE_R_HIT_PORT_TAG); | |
| 569 | ret = input_port_read(field->port->machine, TORNBASE_R_HIT_PORT_TAG); | |
| 570 | 570 | break; |
| 571 | 571 | } |
| 572 | 572 | |
| r2724 | r2725 | |
| 578 | 578 | { |
| 579 | 579 | UINT32 ret; |
| 580 | 580 | |
| 581 | switch (tornbase_get_cabinet_type(machine)) | |
| 581 | switch (tornbase_get_cabinet_type(field->port->machine)) | |
| 582 | 582 | { |
| 583 | 583 | case TORNBASE_CAB_TYPE_UPRIGHT_OLD: |
| 584 | 584 | case TORNBASE_CAB_TYPE_UPRIGHT_NEW: |
| 585 | ret = input_port_read(machine, TORNBASE_L_PITCH_PORT_TAG); | |
| 585 | ret = input_port_read(field->port->machine, TORNBASE_L_PITCH_PORT_TAG); | |
| 586 | 586 | break; |
| 587 | 587 | |
| 588 | 588 | case TORNBASE_CAB_TYPE_COCKTAIL: |
| 589 | 589 | default: |
| 590 | ret = input_port_read(machine, TORNBASE_R_PITCH_PORT_TAG); | |
| 590 | ret = input_port_read(field->port->machine, TORNBASE_R_PITCH_PORT_TAG); | |
| 591 | 591 | break; |
| 592 | 592 | } |
| 593 | 593 | |
| r2724 | r2725 | |
| 597 | 597 | |
| 598 | 598 | static CUSTOM_INPUT( tornbase_pitch_right_input_r ) |
| 599 | 599 | { |
| 600 | return input_port_read(machine, TORNBASE_L_PITCH_PORT_TAG); | |
| 600 | return input_port_read(field->port->machine, TORNBASE_L_PITCH_PORT_TAG); | |
| 601 | 601 | } |
| 602 | 602 | |
| 603 | 603 | |
| 604 | 604 | static CUSTOM_INPUT( tornbase_score_input_r ) |
| 605 | 605 | { |
| 606 | return input_port_read(machine, TORNBASE_SCORE_SW_PORT_TAG) & | |
| 607 | input_port_read(machine, TORNBASE_SCORE_DIP_PORT_TAG); | |
| 606 | return input_port_read(field->port->machine, TORNBASE_SCORE_SW_PORT_TAG) & | |
| 607 | input_port_read(field->port->machine, TORNBASE_SCORE_DIP_PORT_TAG); | |
| 608 | 608 | } |
| 609 | 609 | |
| 610 | 610 | |
| r2724 | r2725 | |
| 1181 | 1181 | UINT32 ret; |
| 1182 | 1182 | |
| 1183 | 1183 | if (desertgu_controller_select) |
| 1184 | ret = input_port_read(machine, DESERTGU_GUN_X_PORT_TAG); | |
| 1184 | ret = input_port_read(field->port->machine, DESERTGU_GUN_X_PORT_TAG); | |
| 1185 | 1185 | else |
| 1186 | ret = input_port_read(machine, DESERTGU_GUN_Y_PORT_TAG); | |
| 1186 | ret = input_port_read(field->port->machine, DESERTGU_GUN_Y_PORT_TAG); | |
| 1187 | 1187 | |
| 1188 | 1188 | return ret; |
| 1189 | 1189 | } |
| r2724 | r2725 | |
| 1194 | 1194 | UINT32 ret; |
| 1195 | 1195 | |
| 1196 | 1196 | if (desertgu_controller_select) |
| 1197 | ret = input_port_read(machine, DESERTGU_DIP_SW_0_1_SET_2_TAG); | |
| 1197 | ret = input_port_read(field->port->machine, DESERTGU_DIP_SW_0_1_SET_2_TAG); | |
| 1198 | 1198 | else |
| 1199 | ret = input_port_read(machine, DESERTGU_DIP_SW_0_1_SET_1_TAG); | |
| 1199 | ret = input_port_read(field->port->machine, DESERTGU_DIP_SW_0_1_SET_1_TAG); | |
| 1200 | 1200 | |
| 1201 | 1201 | return ret; |
| 1202 | 1202 | } |
| r2724 | r2725 | |
| 1307 | 1307 | { |
| 1308 | 1308 | UINT32 ret; |
| 1309 | 1309 | |
| 1310 | if (input_port_read(machine, DPLAY_CAB_TYPE_PORT_TAG) == DPLAY_CAB_TYPE_UPRIGHT) | |
| 1311 | ret = input_port_read(machine, DPLAY_L_PITCH_PORT_TAG); | |
| 1310 | if (input_port_read(field->port->machine, DPLAY_CAB_TYPE_PORT_TAG) == DPLAY_CAB_TYPE_UPRIGHT) | |
| 1311 | ret = input_port_read(field->port->machine, DPLAY_L_PITCH_PORT_TAG); | |
| 1312 | 1312 | else |
| 1313 | ret = input_port_read(machine, DPLAY_R_PITCH_PORT_TAG); | |
| 1313 | ret = input_port_read(field->port->machine, DPLAY_R_PITCH_PORT_TAG); | |
| 1314 | 1314 | |
| 1315 | 1315 | return ret; |
| 1316 | 1316 | } |
| r2724 | r2725 | |
| 1318 | 1318 | |
| 1319 | 1319 | static CUSTOM_INPUT( dplay_pitch_right_input_r ) |
| 1320 | 1320 | { |
| 1321 | return input_port_read(machine, DPLAY_L_PITCH_PORT_TAG); | |
| 1321 | return input_port_read(field->port->machine, DPLAY_L_PITCH_PORT_TAG); | |
| 1322 | 1322 | } |
| 1323 | 1323 | |
| 1324 | 1324 | |
| r2724 | r2725 | |
| 1697 | 1697 | |
| 1698 | 1698 | if (clowns_controller_select) |
| 1699 | 1699 | { |
| 1700 | ret = input_port_read(machine, CLOWNS_CONTROLLER_P2_TAG); | |
| 1700 | ret = input_port_read(field->port->machine, CLOWNS_CONTROLLER_P2_TAG); | |
| 1701 | 1701 | } |
| 1702 | 1702 | else |
| 1703 | 1703 | { |
| 1704 | ret = input_port_read(machine, CLOWNS_CONTROLLER_P1_TAG); | |
| 1704 | ret = input_port_read(field->port->machine, CLOWNS_CONTROLLER_P1_TAG); | |
| 1705 | 1705 | } |
| 1706 | 1706 | |
| 1707 | 1707 | return ret; |
| r2724 | r2725 | |
| 2446 | 2446 | |
| 2447 | 2447 | static CUSTOM_INPUT( invaders_coin_input_r ) |
| 2448 | 2448 | { |
| 2449 | UINT32 ret = input_port_read(machine, INVADERS_COIN_INPUT_PORT_TAG); | |
| 2449 | UINT32 ret = input_port_read(field->port->machine, INVADERS_COIN_INPUT_PORT_TAG); | |
| 2450 | 2450 | |
| 2451 | 2451 | coin_counter_w(0, !ret); |
| 2452 | 2452 | |
| r2724 | r2725 | |
| 2461 | 2461 | /* upright PCB : switches visible |
| 2462 | 2462 | cocktail PCB: HI */ |
| 2463 | 2463 | |
| 2464 | if (invaders_is_cabinet_cocktail(machine)) | |
| 2464 | if (invaders_is_cabinet_cocktail(field->port->machine)) | |
| 2465 | 2465 | ret = 0x03; |
| 2466 | 2466 | else |
| 2467 | ret = input_port_read(machine, INVADERS_SW6_SW7_PORT_TAG); | |
| 2467 | ret = input_port_read(field->port->machine, INVADERS_SW6_SW7_PORT_TAG); | |
| 2468 | 2468 | |
| 2469 | 2469 | return ret; |
| 2470 | 2470 | } |
| r2724 | r2725 | |
| 2477 | 2477 | /* upright PCB : switch visible |
| 2478 | 2478 | cocktail PCB: HI */ |
| 2479 | 2479 | |
| 2480 | if (invaders_is_cabinet_cocktail(machine)) | |
| 2480 | if (invaders_is_cabinet_cocktail(field->port->machine)) | |
| 2481 | 2481 | ret = 0x01; |
| 2482 | 2482 | else |
| 2483 | ret = input_port_read(machine, INVADERS_SW5_PORT_TAG); | |
| 2483 | ret = input_port_read(field->port->machine, INVADERS_SW5_PORT_TAG); | |
| 2484 | 2484 | |
| 2485 | 2485 | return ret; |
| 2486 | 2486 | } |
| r2724 | r2725 | |
| 2493 | 2493 | /* upright PCB : P1 controls |
| 2494 | 2494 | cocktail PCB: HI */ |
| 2495 | 2495 | |
| 2496 | if (invaders_is_cabinet_cocktail(machine)) | |
| 2496 | if (invaders_is_cabinet_cocktail(field->port->machine)) | |
| 2497 | 2497 | ret = 0x07; |
| 2498 | 2498 | else |
| 2499 | ret = input_port_read(machine, INVADERS_P1_CONTROL_PORT_TAG); | |
| 2499 | ret = input_port_read(field->port->machine, INVADERS_P1_CONTROL_PORT_TAG); | |
| 2500 | 2500 | |
| 2501 | 2501 | return ret; |
| 2502 | 2502 | } |
| r2724 | r2725 | |
| 2509 | 2509 | /* upright PCB : P1 controls |
| 2510 | 2510 | cocktail PCB: P2 controls */ |
| 2511 | 2511 | |
| 2512 | if (invaders_is_cabinet_cocktail(machine)) | |
| 2513 | ret = input_port_read(machine, INVADERS_P2_CONTROL_PORT_TAG); | |
| 2512 | if (invaders_is_cabinet_cocktail(field->port->machine)) | |
| 2513 | ret = input_port_read(field->port->machine, INVADERS_P2_CONTROL_PORT_TAG); | |
| 2514 | 2514 | else |
| 2515 | ret = input_port_read(machine, INVADERS_P1_CONTROL_PORT_TAG); | |
| 2515 | ret = input_port_read(field->port->machine, INVADERS_P1_CONTROL_PORT_TAG); | |
| 2516 | 2516 | |
| 2517 | 2517 | return ret; |
| 2518 | 2518 | } |
| r2724 | r2725 | |
| 2646 | 2646 | |
| 2647 | 2647 | static CUSTOM_INPUT( blueshrk_coin_input_r ) |
| 2648 | 2648 | { |
| 2649 | UINT32 ret = input_port_read(machine, BLUESHRK_COIN_INPUT_PORT_TAG); | |
| 2649 | UINT32 ret = input_port_read(field->port->machine, BLUESHRK_COIN_INPUT_PORT_TAG); | |
| 2650 | 2650 | |
| 2651 | 2651 | coin_counter_w(0, !ret); |
| 2652 | 2652 |
| r2724 | r2725 | |
|---|---|---|
| 1518 | 1518 | |
| 1519 | 1519 | ***************************************************************************/ |
| 1520 | 1520 | |
| 1521 | static void soundirq(int state) | |
| 1521 | static void soundirq(running_machine *machine, int state) | |
| 1522 | 1522 | { |
| 1523 | cpunum_set_input_line( | |
| 1523 | cpunum_set_input_line(machine, 1, 0, state); | |
| 1524 | 1524 | } |
| 1525 | 1525 | |
| 1526 | 1526 | /* In games with only 2 CPUs, port A&B of the AY8910 are used |
| r2724 | r2725 | |
|---|---|---|
| 9 | 9 | ***************************************************************************/ |
| 10 | 10 | |
| 11 | 11 | #include "driver.h" |
| 12 | #include "deprecat.h" | |
| 13 | 12 | #include "cpu/h6280/h6280.h" |
| 14 | 13 | #include "sound/2203intf.h" |
| 15 | 14 | #include "sound/2151intf.h" |
| r2724 | r2725 | |
| 231 | 230 | |
| 232 | 231 | /******************************************************************************/ |
| 233 | 232 | |
| 234 | static void sound_irq(int state) | |
| 233 | static void sound_irq(running_machine *machine, int state) | |
| 235 | 234 | { |
| 236 | cpunum_set_input_line( | |
| 235 | cpunum_set_input_line(machine, 1,1,state); /* IRQ 2 */ | |
| 237 | 236 | } |
| 238 | 237 | |
| 239 | 238 | static const struct YM2151interface ym2151_interface = |
| r2724 | r2725 | |
|---|---|---|
| 386 | 386 | static INPUT_CHANGED( coin_inserted_irq_hi ) |
| 387 | 387 | { |
| 388 | 388 | if (newval) |
| 389 | cpunum_set_input_line(machine, 0, 0, HOLD_LINE); | |
| 389 | cpunum_set_input_line(field->port->machine, 0, 0, HOLD_LINE); | |
| 390 | 390 | } |
| 391 | 391 | |
| 392 | 392 | static INPUT_CHANGED( coin_inserted_irq_lo ) |
| 393 | 393 | { |
| 394 | 394 | if (!newval) |
| 395 | cpunum_set_input_line(machine, 0, 0, HOLD_LINE); | |
| 395 | cpunum_set_input_line(field->port->machine, 0, 0, HOLD_LINE); | |
| 396 | 396 | } |
| 397 | 397 | |
| 398 | 398 | static INPUT_CHANGED( coin_inserted_nmi_lo ) |
| 399 | 399 | { |
| 400 | cpunum_set_input_line(machine, 0, INPUT_LINE_NMI, newval ? CLEAR_LINE : ASSERT_LINE); | |
| 400 | cpunum_set_input_line(field->port->machine, 0, INPUT_LINE_NMI, newval ? CLEAR_LINE : ASSERT_LINE); | |
| 401 | 401 | } |
| 402 | 402 | |
| 403 | 403 |
| r2724 | r2725 | |
|---|---|---|
| 593 | 593 | * |
| 594 | 594 | *************************************/ |
| 595 | 595 | |
| 596 | static void sound_irq( | |
| 596 | static void sound_irq(running_machine *machine) | |
| 597 | 597 | { |
| 598 | 598 | if (control & 0x0001) |
| 599 | cpunum_set_input_line( | |
| 599 | cpunum_set_input_line(machine, 0, 1, HOLD_LINE); | |
| 600 | 600 | } |
| 601 | 601 | |
| 602 | 602 | static const struct K054539interface k054539_interface = |
| r2724 | r2725 | |
|---|---|---|
| 153 | 153 | ***************************************************************************/ |
| 154 | 154 | |
| 155 | 155 | #include "driver.h" |
| 156 | #include "deprecat.h" | |
| 157 | 156 | #include "machine/eeprom.h" |
| 158 | 157 | #include "sound/2151intf.h" |
| 159 | 158 | #include "sound/okim6295.h" |
| r2724 | r2725 | |
| 3503 | 3502 | |
| 3504 | 3503 | |
| 3505 | 3504 | |
| 3506 | static void cps1_irq_handler_mus(int irq) | |
| 3505 | static void cps1_irq_handler_mus(running_machine *machine, int irq) | |
| 3507 | 3506 | { |
| 3508 | cpunum_set_input_line( | |
| 3507 | cpunum_set_input_line(machine, 1,0,irq ? ASSERT_LINE : CLEAR_LINE); | |
| 3509 | 3508 | } |
| 3510 | 3509 | |
| 3511 | 3510 | static const struct YM2151interface ym2151_interface = |
| r2724 | r2725 | |
|---|---|---|
| 86 | 86 | ***************************************************************************/ |
| 87 | 87 | |
| 88 | 88 | #include "driver.h" |
| 89 | #include "deprecat.h" | |
| 90 | 89 | #include "sound/okim6295.h" |
| 91 | 90 | #include "sound/3812intf.h" |
| 92 | 91 | |
| r2724 | r2725 | |
| 571 | 570 | Magic Bubble |
| 572 | 571 | ***************************************************************************/ |
| 573 | 572 | |
| 574 | static void soundirq(int state) | |
| 573 | static void soundirq(running_machine *machine, int state) | |
| 575 | 574 | { |
| 576 | cpunum_set_input_line( | |
| 575 | cpunum_set_input_line(machine, 1, 0, state); | |
| 577 | 576 | } |
| 578 | 577 | |
| 579 | 578 | static const struct YM3812interface magicbub_ym3812_intf = |
| r2724 | r2725 | |
|---|---|---|
| 54 | 54 | |
| 55 | 55 | static CUSTOM_INPUT( get_motor_not_ready ) |
| 56 | 56 | { |
| 57 | stactics_state *state = machine->driver_data; | |
| 57 | stactics_state *state = field->port->machine->driver_data; | |
| 58 | 58 | |
| 59 | 59 | /* if the motor is self-centering, but not centered yet */ |
| 60 | 60 | return ((*state->motor_on & 0x01) == 0) && |
| r2724 | r2725 | |
| 129 | 129 | static CUSTOM_INPUT( get_rng ) |
| 130 | 130 | { |
| 131 | 131 | /* this is a 555 timer, but cannot read one of the resistor values */ |
| 132 | return mame_rand(machine) & 0x07; | |
| 132 | return mame_rand(field->port->machine) & 0x07; | |
| 133 | 133 | } |
| 134 | 134 | |
| 135 | 135 |
| r2724 | r2725 | |
|---|---|---|
| 64 | 64 | |
| 65 | 65 | static CUSTOM_INPUT( ticket_status ) |
| 66 | 66 | { |
| 67 | return ticket_dispenser_0_r(machine, 0) >> 7; | |
| 67 | return ticket_dispenser_0_r(field->port->machine, 0) >> 7; | |
| 68 | 68 | } |
| 69 | 69 | |
| 70 | 70 | |
| 71 | 71 | static CUSTOM_INPUT( cclownz_paddle ) |
| 72 | 72 | { |
| 73 | int value = input_port_read(machine, "PADDLE"); | |
| 73 | int value = input_port_read(field->port->machine, "PADDLE"); | |
| 74 | 74 | return ((value << 4) & 0xf00) | (value & 0x00f); |
| 75 | 75 | } |
| 76 | 76 |
| r2724 | r2725 | |
|---|---|---|
| 453 | 453 | |
| 454 | 454 | |
| 455 | 455 | #include "driver.h" |
| 456 | #include "deprecat.h" | |
| 457 | 456 | #include "cpu/m6809/m6809.h" |
| 458 | 457 | #include "machine/6821pia.h" |
| 459 | 458 | #include "machine/6522via.h" |
| r2724 | r2725 | |
| 519 | 518 | * |
| 520 | 519 | *************************************/ |
| 521 | 520 | |
| 522 | static void via_irq(int state); | |
| 521 | static void via_irq(running_machine *machine, int state); | |
| 523 | 522 | |
| 524 | 523 | static const struct via6522_interface via_interface = |
| 525 | 524 | { |
| r2724 | r2725 | |
| 596 | 595 | } |
| 597 | 596 | |
| 598 | 597 | |
| 599 | static void generate_sound_irq(int state) | |
| 598 | static void generate_sound_irq(running_machine *machine, int state) | |
| 600 | 599 | { |
| 601 | cpunum_set_input_line( | |
| 600 | cpunum_set_input_line(machine, 1, M6809_FIRQ_LINE, state ? ASSERT_LINE : CLEAR_LINE); | |
| 602 | 601 | } |
| 603 | 602 | |
| 604 | 603 | |
| r2724 | r2725 | |
| 815 | 814 | * |
| 816 | 815 | *************************************/ |
| 817 | 816 | |
| 818 | static void via_irq(int state) | |
| 817 | static void via_irq(running_machine *machine, int state) | |
| 819 | 818 | { |
| 820 | 819 | if (state) |
| 821 | cpunum_set_input_line( | |
| 820 | cpunum_set_input_line(machine, 1, M6809_FIRQ_LINE, ASSERT_LINE); | |
| 822 | 821 | else |
| 823 | cpunum_set_input_line( | |
| 822 | cpunum_set_input_line(machine, 1, M6809_FIRQ_LINE, CLEAR_LINE); | |
| 824 | 823 | } |
| 825 | 824 | |
| 826 | 825 | |
| r2724 | r2725 | |
| 869 | 868 | mame_fread(file, main_ram, main_ram_size); |
| 870 | 869 | else |
| 871 | 870 | for (i = 0; i < main_ram_size; i++) |
| 872 | main_ram[i] = mame_rand( | |
| 871 | main_ram[i] = mame_rand(machine); | |
| 873 | 872 | } |
| 874 | 873 | |
| 875 | 874 |
| r2724 | r2725 | |
|---|---|---|
| 841 | 841 | |
| 842 | 842 | /* select the bank and graphics bank based on it */ |
| 843 | 843 | memory_set_bank(1, gmgalax_selected_game); |
| 844 | galaxian_gfxbank_w(machine, 0, gmgalax_selected_game); | |
| 844 | galaxian_gfxbank_w(field->port->machine, 0, gmgalax_selected_game); | |
| 845 | 845 | |
| 846 | 846 | /* reset the starts */ |
| 847 | galaxian_stars_enable_w(machine, 0, 0); | |
| 847 | galaxian_stars_enable_w(field->port->machine, 0, 0); | |
| 848 | 848 | |
| 849 | 849 | /* reset the CPU */ |
| 850 | cpunum_set_input_line(machine, 0, INPUT_LINE_RESET, PULSE_LINE); | |
| 850 | cpunum_set_input_line(field->port->machine, 0, INPUT_LINE_RESET, PULSE_LINE); | |
| 851 | 851 | } |
| 852 | 852 | |
| 853 | 853 | |
| r2724 | r2725 | |
| 856 | 856 | const char *portname = param; |
| 857 | 857 | if (gmgalax_selected_game != 0) |
| 858 | 858 | portname += strlen(portname) + 1; |
| 859 | return input_port_read(machine, portname); | |
| 859 | return input_port_read(field->port->machine, portname); | |
| 860 | 860 | } |
| 861 | 861 | |
| 862 | 862 | |
| r2724 | r2725 | |
| 912 | 912 | |
| 913 | 913 | static CUSTOM_INPUT( azurian_port_r ) |
| 914 | 914 | { |
| 915 | return (input_port_read(machine, "FAKE") >> (FPTR)param) & 1; | |
| 915 | return (input_port_read(field->port->machine, "FAKE") >> (FPTR)param) & 1; | |
| 916 | 916 | } |
| 917 | 917 | |
| 918 | 918 | |
| r2724 | r2725 | |
| 926 | 926 | static CUSTOM_INPUT( kingball_muxbit_r ) |
| 927 | 927 | { |
| 928 | 928 | /* multiplex the service mode switch with a speech DIP switch */ |
| 929 | return (input_port_read(machine, "FAKE") >> kingball_speech_dip) & 1; | |
| 929 | return (input_port_read(field->port->machine, "FAKE") >> kingball_speech_dip) & 1; | |
| 930 | 930 | } |
| 931 | 931 | |
| 932 | 932 | |
| r2724 | r2725 | |
| 935 | 935 | /* bit 5 is the NOISE line from the sound circuit. The code just verifies |
| 936 | 936 | that it's working, doesn't actually use return value, so we can just use |
| 937 | 937 | rand() */ |
| 938 | return mame_rand(machine) & 1; | |
| 938 | return mame_rand(field->port->machine) & 1; | |
| 939 | 939 | } |
| 940 | 940 | |
| 941 | 941 | |
| r2724 | r2725 | |
| 2323 | 2323 | memory_configure_bank(1, 0, 2, memory_region(REGION_CPU1) + 0x10000, 0x4000); |
| 2324 | 2324 | |
| 2325 | 2325 | /* callback when the game select is toggled */ |
| 2326 | gmgalax_game_changed(machine, NULL, 0, 0); | |
| 2326 | gmgalax_game_changed(machine->portconfig->fieldlist, NULL, 0, 0); | |
| 2327 | 2327 | state_save_register_global(gmgalax_selected_game); |
| 2328 | 2328 | } |
| 2329 | 2329 |
| r2724 | r2725 | |
|---|---|---|
| 15 | 15 | ***************************************************************************/ |
| 16 | 16 | |
| 17 | 17 | #include "driver.h" |
| 18 | #include "deprecat.h" | |
| 19 | 18 | #include "sound/okim6295.h" |
| 20 | 19 | |
| 21 | 20 | |
| r2724 | r2725 | |
| 39 | 38 | |
| 40 | 39 | static READ16_HANDLER( pap ) |
| 41 | 40 | { |
| 42 | return mame_rand( | |
| 41 | return mame_rand(machine); | |
| 43 | 42 | } |
| 44 | 43 | |
| 45 | 44 |
| r2724 | r2725 | |
|---|---|---|
| 666 | 666 | |
| 667 | 667 | /******************************************************************************/ |
| 668 | 668 | |
| 669 | static void sound_irq( int irq ) | |
| 669 | static void sound_irq( running_machine *machine, int irq ) | |
| 670 | 670 | { |
| 671 | cpunum_set_input_line( | |
| 671 | cpunum_set_input_line(machine, 1,0,irq ? ASSERT_LINE : CLEAR_LINE); | |
| 672 | 672 | } |
| 673 | 673 | |
| 674 | 674 | static const struct YM2608interface ym2608_interface = |
| 675 | 675 | { |
| 676 | 676 | { |
| 677 | AY8910_LEGACY_OUTPUT, | |
| 677 | AY8910_LEGACY_OUTPUT | AY8910_SINGLE_OUTPUT, | |
| 678 | 678 | AY8910_DEFAULT_LOADS, |
| 679 | 679 | NULL, NULL, NULL, NULL |
| 680 | 680 | }, |
| r2724 | r2725 | |
|---|---|---|
| 33 | 33 | ******************************************************************************/ |
| 34 | 34 | |
| 35 | 35 | #include "driver.h" |
| 36 | #include "deprecat.h" | |
| 37 | 36 | #include "gstriker.h" |
| 38 | 37 | #include "sound/2610intf.h" |
| 39 | 38 | |
| r2724 | r2725 | |
| 271 | 270 | |
| 272 | 271 | /*** MORE SOUND RELATED ******************************************************/ |
| 273 | 272 | |
| 274 | static void gs_ym2610_irq(int irq) | |
| 273 | static void gs_ym2610_irq(running_machine *machine, int irq) | |
| 275 | 274 | { |
| 276 | 275 | if (irq) |
| 277 | cpunum_set_input_line( | |
| 276 | cpunum_set_input_line(machine, 1, 0, ASSERT_LINE); | |
| 278 | 277 | else |
| 279 | cpunum_set_input_line( | |
| 278 | cpunum_set_input_line(machine, 1, 0, CLEAR_LINE); | |
| 280 | 279 | } |
| 281 | 280 | |
| 282 | 281 | static const struct YM2610interface ym2610_interface = |
| r2724 | r2725 | |
|---|---|---|
| 247 | 247 | } |
| 248 | 248 | |
| 249 | 249 | // NMI handshakes between CPUs are determined to be much simpler |
| 250 | READ8_HANDLER ( snk_cpuA_nmi_trigger_r ) { cpunum_set_input_line(Machine, 0, INPUT_LINE_NMI, ASSERT_LINE); return 0; } | |
| 251 | WRITE8_HANDLER( snk_cpuA_nmi_ack_w ) { cpunum_set_input_line(Machine, 0, INPUT_LINE_NMI, CLEAR_LINE); } | |
| 250 | READ8_HANDLER ( snk_cpuA_nmi_trigger_r ) { cpunum_set_input_line(machine, 0, INPUT_LINE_NMI, ASSERT_LINE); return 0; } | |
| 251 | WRITE8_HANDLER( snk_cpuA_nmi_ack_w ) { cpunum_set_input_line(machine, 0, INPUT_LINE_NMI, CLEAR_LINE); } | |
| 252 | 252 | |
| 253 | READ8_HANDLER ( snk_cpuB_nmi_trigger_r ) { cpunum_set_input_line(Machine, 1, INPUT_LINE_NMI, ASSERT_LINE); return 0; } | |
| 254 | WRITE8_HANDLER( snk_cpuB_nmi_ack_w ) { cpunum_set_input_line(Machine, 1, INPUT_LINE_NMI, CLEAR_LINE); } | |
| 253 | READ8_HANDLER ( snk_cpuB_nmi_trigger_r ) { cpunum_set_input_line(machine, 1, INPUT_LINE_NMI, ASSERT_LINE); return 0; } | |
| 254 | WRITE8_HANDLER( snk_cpuB_nmi_ack_w ) { cpunum_set_input_line(machine, 1, INPUT_LINE_NMI, CLEAR_LINE); } | |
| 255 | 255 | |
| 256 | 256 | /*********************************************************************/ |
| 257 | 257 | |
| r2724 | r2725 | |
| 357 | 357 | return snk_sound_register;// | 0x2; /* hack; lets chopper1 play music */ |
| 358 | 358 | } |
| 359 | 359 | |
| 360 | static void snk_sound_callback0_w( int state ){ /* ? */ | |
| 360 | static void snk_sound_callback0_w( running_machine *machine, int state ){ /* ? */ | |
| 361 | 361 | if( state ) snk_sound_register |= 0x01; |
| 362 | 362 | } |
| 363 | 363 | |
| 364 | static void snk_sound_callback1_w( int state ){ /* ? */ | |
| 364 | static void snk_sound_callback1_w( running_machine *machine, int state ){ /* ? */ | |
| 365 | 365 | if( state ) snk_sound_register |= 0x02; |
| 366 | 366 | } |
| 367 | 367 |
| r2724 | r2725 | |
|---|---|---|
| 93 | 93 | COMBINE_DATA(&hypr_sub_sharedram2_2[offset-0x4000/2]); |
| 94 | 94 | } |
| 95 | 95 | |
| 96 | static void update_irq_state( | |
| 96 | static void update_irq_state(running_machine *machine) | |
| 97 | 97 | { |
| 98 | 98 | int irq = requested_int & ~*hypr_irq_enable; |
| 99 | 99 | |
| 100 | cpunum_set_input_line( | |
| 100 | cpunum_set_input_line(machine, 0, 3, (irq & int_num) ? ASSERT_LINE : CLEAR_LINE); | |
| 101 | 101 | } |
| 102 | 102 | |
| 103 | 103 | static READ16_HANDLER( hyprduel_irq_cause_r ) |
| r2724 | r2725 | |
| 114 | 114 | else |
| 115 | 115 | requested_int &= ~(data & *hypr_irq_enable); |
| 116 | 116 | |
| 117 | update_irq_state(); | |
| 117 | update_irq_state(machine); | |
| 118 | 118 | } |
| 119 | 119 | } |
| 120 | 120 | |
| r2724 | r2725 | |
| 204 | 204 | rastersplit = line + 1; |
| 205 | 205 | } |
| 206 | 206 | |
| 207 | update_irq_state(); | |
| 207 | update_irq_state(machine); | |
| 208 | 208 | } |
| 209 | 209 | |
| 210 | 210 | static MACHINE_RESET( hyprduel ) |
| r2724 | r2725 | |
| 291 | 291 | static TIMER_CALLBACK( hyprduel_blit_done ) |
| 292 | 292 | { |
| 293 | 293 | requested_int |= 1 << blitter_bit; |
| 294 | update_irq_state(); | |
| 294 | update_irq_state(machine); | |
| 295 | 295 | } |
| 296 | 296 | |
| 297 | 297 | INLINE int blt_read(const UINT8 *ROM, const int offs) |
| r2724 | r2725 | |
| 691 | 691 | Sound Communication |
| 692 | 692 | ***************************************************************************/ |
| 693 | 693 | |
| 694 | static void sound_irq(int state) | |
| 694 | static void sound_irq(running_machine *machine, int state) | |
| 695 | 695 | { |
| 696 | cpunum_set_input_line( | |
| 696 | cpunum_set_input_line(machine, 1, 1, HOLD_LINE); | |
| 697 | 697 | } |
| 698 | 698 | |
| 699 | 699 | static const struct YM2151interface ym2151_interface = |
| r2724 | r2725 | |
|---|---|---|
| 525 | 525 | |
| 526 | 526 | do |
| 527 | 527 | { /* pick a random number, but don't pick the same twice in a row */ |
| 528 | count = mame_rand( | |
| 528 | count = mame_rand(machine); | |
| 529 | 529 | } while( count==old_count ); |
| 530 | 530 | |
| 531 | 531 | switch( namcos2_gametype ) |
| r2724 | r2725 | |
| 675 | 675 | static |
| 676 | 676 | READ32_HANDLER( randgen_r ) |
| 677 | 677 | { |
| 678 | return mame_rand( | |
| 678 | return mame_rand(machine); | |
| 679 | 679 | } /* randgen_r */ |
| 680 | 680 | |
| 681 | 681 | static |
| r2724 | r2725 | |
|---|---|---|
| 373 | 373 | PORT_DIPNAME( 0x20, 0x20, "Leave Off") // Check code at 0x7859 |
| 374 | 374 | PORT_DIPSETTING( 0x20, DEF_STR( Off ) ) // (must be OFF or the game will |
| 375 | 375 | PORT_DIPSETTING( 0x00, DEF_STR( On ) ) // hang after the game is over !) |
| 376 | PORT_ | |
| 376 | PORT_DIPNAME( | |
| 377 | 377 | PORT_DIPSETTING( 0x40, DEF_STR( Off ) ) |
| 378 | 378 | PORT_DIPSETTING( 0x00, DEF_STR( On ) ) |
| 379 | 379 | PORT_DIPNAME( 0x80, 0x80, "Coin Slots" ) |
| r2724 | r2725 | |
|---|---|---|
| 33 | 33 | */ |
| 34 | 34 | |
| 35 | 35 | #include "driver.h" |
| 36 | #include "deprecat.h" | |
| 37 | 36 | #include "cpu/m68000/m68kmame.h" |
| 38 | 37 | #include "cps1.h" |
| 39 | 38 | #include "sound/2203intf.h" |
| r2724 | r2725 | |
| 64 | 63 | memory_set_bankptr(1,&RAM[0x10000 + bankaddr]); |
| 65 | 64 | } |
| 66 | 65 | |
| 67 | static void m5205_int1(int data) | |
| 66 | static void m5205_int1(running_machine *machine, int data) | |
| 68 | 67 | { |
| 69 | 68 | MSM5205_data_w(0, sample_buffer1 & 0x0F); |
| 70 | 69 | sample_buffer1 >>= 4; |
| 71 | 70 | sample_select1 ^= 1; |
| 72 | 71 | if (sample_select1 == 0) |
| 73 | cpunum_set_input_line( | |
| 72 | cpunum_set_input_line(machine, 1, INPUT_LINE_NMI, PULSE_LINE); | |
| 74 | 73 | } |
| 75 | 74 | |
| 76 | static void m5205_int2(int data) | |
| 75 | static void m5205_int2(running_machine *machine, int data) | |
| 77 | 76 | { |
| 78 | 77 | MSM5205_data_w(1, sample_buffer2 & 0x0F); |
| 79 | 78 | sample_buffer2 >>= 4; |
| r2724 | r2725 | |
|---|---|---|
| 81 | 81 | ******************************************************************************/ |
| 82 | 82 | |
| 83 | 83 | #include "driver.h" |
| 84 | #include "deprecat.h" | |
| 85 | 84 | #include "video/konamiic.h" |
| 86 | 85 | #include "sound/2610intf.h" |
| 87 | 86 | |
| r2724 | r2725 | |
| 312 | 311 | |
| 313 | 312 | /*** MORE SOUND **************************************************************/ |
| 314 | 313 | |
| 315 | static void irqhandler(int irq) | |
| 314 | static void irqhandler(running_machine *machine, int irq) | |
| 316 | 315 | { |
| 317 | cpunum_set_input_line( | |
| 316 | cpunum_set_input_line(machine, 1,0,irq ? ASSERT_LINE : CLEAR_LINE); | |
| 318 | 317 | } |
| 319 | 318 | |
| 320 | 319 | static const struct YM2610interface ym2610_interface = |
| r2724 | r2725 | |
|---|---|---|
| 51 | 51 | case 0x6066: res = 0xa5; break; |
| 52 | 52 | case 0x60dc: res = 0x20; break; /* bits 0-3 unknown */ |
| 53 | 53 | case 0x615d: res = 0x30; break; /* bits 0-3 unknown */ |
| 54 | case 0x61b9: res = 0x60|(mame_rand( | |
| 54 | case 0x61b9: res = 0x60|(mame_rand(machine)&0x0f); break; /* bits 0-3 unknown */ | |
| 55 | 55 | case 0x6219: res = 0x77; break; |
| 56 | 56 | case 0x626c: res = 0xb4; break; |
| 57 | 57 | default: res = 0xff; break; |
| r2724 | r2725 | |
| 70 | 70 | case 0x6094: res = 0xa5; break; |
| 71 | 71 | case 0x6118: res = 0x20; break; /* bits 0-3 unknown */ |
| 72 | 72 | case 0x6199: res = 0x30; break; /* bits 0-3 unknown */ |
| 73 | case 0x61f5: res = 0x60|(mame_rand( | |
| 73 | case 0x61f5: res = 0x60|(mame_rand(machine)&0x0f); break; /* bits 0-3 unknown */ | |
| 74 | 74 | case 0x6255: res = 0x77; break; |
| 75 | 75 | case 0x62a8: res = 0xb4; break; |
| 76 | 76 | default: res = 0xff; break; |
| r2724 | r2725 | |
|---|---|---|
| 26 | 26 | You could even multiply the PC by the stack pointer if you wanted." |
| 27 | 27 | |
| 28 | 28 | |
| 29 | ||
| 30 | 29 | driver by Pierpaolo Prazzoli & Tomasz Slanina |
| 31 | 30 | |
| 32 | 31 | - Pierpaolo Prazzoli 2006.05.06 |
| r2724 | r2725 | |
|---|---|---|
| 212 | 212 | sangho_common_machine_reset(); |
| 213 | 213 | } |
| 214 | 214 | |
| 215 | static void msx_vdp_interrupt(int i) | |
| 215 | static void msx_vdp_interrupt(running_machine *machine, int i) | |
| 216 | 216 | { |
| 217 | cpunum_set_input_line ( | |
| 217 | cpunum_set_input_line (machine, 0, 0, (i ? HOLD_LINE : CLEAR_LINE)); | |
| 218 | 218 | } |
| 219 | 219 | |
| 220 | 220 | static INTERRUPT_GEN( sangho_interrupt ) |
| r2724 | r2725 | |
|---|---|---|
| 1687 | 1687 | |
| 1688 | 1688 | static int scsp_last_line = 0; |
| 1689 | 1689 | |
| 1690 | static void scsp_irq(int irq) | |
| 1690 | static void scsp_irq(running_machine *machine, int irq) | |
| 1691 | 1691 | { |
| 1692 | 1692 | if (irq > 0) |
| 1693 | 1693 | { |
| 1694 | 1694 | scsp_last_line = irq; |
| 1695 | cpunum_set_input_line( | |
| 1695 | cpunum_set_input_line(machine, 1, irq, PULSE_LINE); | |
| 1696 | 1696 | } |
| 1697 | 1697 | } |
| 1698 | 1698 |
| r2724 | r2725 | |
|---|---|---|
| 175 | 175 | |
| 176 | 176 | static READ16_HANDLER( bmc_random_read ) |
| 177 | 177 | { |
| 178 | return mame_rand( | |
| 178 | return mame_rand(machine); | |
| 179 | 179 | } |
| 180 | 180 | |
| 181 | 181 | static READ16_HANDLER( bmc_protection_r ) |
| r2724 | r2725 | |
| 192 | 192 | break; |
| 193 | 193 | } |
| 194 | 194 | logerror("Protection read @ %X\n",activecpu_get_previouspc()); |
| 195 | return mame_rand( | |
| 195 | return mame_rand(machine); | |
| 196 | 196 | } |
| 197 | 197 | |
| 198 | 198 | static WRITE16_HANDLER( bmc_RAMDAC_offset_w ) |
| r2724 | r2725 | |
| 245 | 245 | } |
| 246 | 246 | |
| 247 | 247 | |
| 248 | static void via_irq(int state) | |
| 248 | static void via_irq(running_machine *machine, int state) | |
| 249 | 249 | { |
| 250 | 250 | //used |
| 251 | 251 | } |
| r2724 | r2725 | |
|---|---|---|
| 52 | 52 | ***************************************************************************/ |
| 53 | 53 | |
| 54 | 54 | #include "driver.h" |
| 55 | #include "deprecat.h" | |
| 56 | 55 | #include "sound/2203intf.h" |
| 57 | 56 | #include "sound/okim6295.h" |
| 58 | 57 | |
| r2724 | r2725 | |
| 327 | 326 | |
| 328 | 327 | /******************************************************************************/ |
| 329 | 328 | |
| 330 | static void irqhandler(int state) | |
| 329 | static void irqhandler(running_machine *machine, int state) | |
| 331 | 330 | { |
| 332 | cpunum_set_input_line( | |
| 331 | cpunum_set_input_line(machine, 1,0,state); | |
| 333 | 332 | } |
| 334 | 333 | |
| 335 | 334 | static const struct YM2203interface ym2203_interface = |
| r2724 | r2725 | |
|---|---|---|
| 11 | 11 | ****************************************************************************************/ |
| 12 | 12 | |
| 13 | 13 | #include "driver.h" |
| 14 | #include "deprecat.h" | |
| 15 | 14 | #include "sound/2203intf.h" |
| 16 | 15 | |
| 17 | 16 | extern UINT8 *compgolf_bg_ram; |
| r2724 | r2725 | |
| 194 | 193 | |
| 195 | 194 | /***************************************************************************/ |
| 196 | 195 | |
| 197 | static void sound_irq(int linestate) | |
| 196 | static void sound_irq(running_machine *machine, int linestate) | |
| 198 | 197 | { |
| 199 | cpunum_set_input_line( | |
| 198 | cpunum_set_input_line(machine, 0,0,linestate); | |
| 200 | 199 | } |
| 201 | 200 | |
| 202 | 201 | static const struct YM2203interface ym2203_interface = |
| r2724 | r2725 | |
|---|---|---|
| 26 | 26 | ***************************************************************************/ |
| 27 | 27 | |
| 28 | 28 | #include "driver.h" |
| 29 | #include "deprecat.h" | |
| 30 | 29 | #include "machine/8255ppi.h" |
| 31 | 30 | #include "machine/eeprom.h" |
| 32 | 31 | #include "sound/3812intf.h" |
| r2724 | r2725 | |
| 427 | 426 | } |
| 428 | 427 | }; |
| 429 | 428 | |
| 430 | static void soundirq(int state) | |
| 429 | static void soundirq(running_machine *machine, int state) | |
| 431 | 430 | { |
| 432 | cpunum_set_input_line( | |
| 431 | cpunum_set_input_line(machine, 1, 0, state); | |
| 433 | 432 | } |
| 434 | 433 | |
| 435 | 434 | static const struct YM3812interface lordgun_ym3812_interface = |
| r2724 | r2725 | |
|---|---|---|
| 16 | 16 | ***************************************************************************/ |
| 17 | 17 | |
| 18 | 18 | #include "driver.h" |
| 19 | #include "deprecat.h" | |
| 20 | 19 | #include "lemmings.h" |
| 21 | 20 | #include "sound/2151intf.h" |
| 22 | 21 | #include "sound/okim6295.h" |
| r2724 | r2725 | |
| 260 | 259 | |
| 261 | 260 | /******************************************************************************/ |
| 262 | 261 | |
| 263 | static void sound_irq(int state) | |
| 262 | static void sound_irq(running_machine *machine, int state) | |
| 264 | 263 | { |
| 265 | cpunum_set_input_line( | |
| 264 | cpunum_set_input_line(machine, 1,0,state); | |
| 266 | 265 | } |
| 267 | 266 | |
| 268 | 267 | static const struct YM2151interface ym2151_interface = |
| r2724 | r2725 | |
|---|---|---|
| 22 | 22 | ***************************************************************************/ |
| 23 | 23 | |
| 24 | 24 | #include "driver.h" |
| 25 | #include "deprecat.h" | |
| 26 | 25 | #include "cpu/z80/z80.h" |
| 27 | 26 | #include "cpu/m6805/m6805.h" |
| 28 | 27 | #include "sound/2203intf.h" |
| r2724 | r2725 | |
| 419 | 418 | |
| 420 | 419 | /******************************************************************************/ |
| 421 | 420 | |
| 422 | static void irqhandler(int irq) | |
| 421 | static void irqhandler(running_machine *machine, int irq) | |
| 423 | 422 | { |
| 424 | ||
| 423 | | |
| 425 | 424 | } |
| 426 | 425 | |
| 427 | 426 | static const struct YM2203interface ym2203_interface = |
| r2724 | r2725 | |
|---|---|---|
| 63 | 63 | */ |
| 64 | 64 | static UINT8 *nvram; |
| 65 | 65 | static size_t nvram_size; |
| 66 | static int we_flipped_the_switch; | |
| 67 | 66 | |
| 68 | 67 | static NVRAM_HANDLER( hyperspt ) |
| 69 | 68 | { |
| 70 | 69 | if (read_or_write) |
| 71 | { | |
| 72 | 70 | mame_fwrite(file,nvram,nvram_size); |
| 73 | ||
| 74 | if (we_flipped_the_switch) | |
| 75 | { | |
| 76 | input_port_entry *in; | |
| 77 | ||
| 78 | ||
| 79 | /* find the dip switch which resets the high score table, and set it */ | |
| 80 | /* back to off. */ | |
| 81 | in = machine->input_ports; | |
| 82 | ||
| 83 | while (in->type != IPT_END) | |
| 84 | { | |
| 85 | if (in->name != NULL && in->name != IP_NAME_DEFAULT && | |
| 86 | strcmp(in->name,"World Records") == 0) | |
| 87 | { | |
| 88 | if (in->default_value == 0) | |
| 89 | in->default_value = in->mask; | |
| 90 | break; | |
| 91 | } | |
| 92 | ||
| 93 | in++; | |
| 94 | } | |
| 95 | ||
| 96 | we_flipped_the_switch = 0; | |
| 97 | } | |
| 98 | } | |
| 99 | else | |
| 100 | { | |
| 101 | if (file) | |
| 102 | { | |
| 103 | mame_fread(file,nvram,nvram_size); | |
| 104 | we_flipped_the_switch = 0; | |
| 105 | } | |
| 106 | else | |
| 107 | { | |
| 108 | input_port_entry *in; | |
| 109 | ||
| 110 | ||
| 111 | /* find the dip switch which resets the high score table, and set it on */ | |
| 112 | in = machine->input_ports; | |
| 113 | ||
| 114 | while (in->type != IPT_END) | |
| 115 | { | |
| 116 | if (in->name != NULL && in->name != IP_NAME_DEFAULT && | |
| 117 | strcmp(in->name,"World Records") == 0) | |
| 118 | { | |
| 119 | if (in->default_value == in->mask) | |
| 120 | { | |
| 121 | in->default_value = 0; | |
| 122 | we_flipped_the_switch = 1; | |
| 123 | } | |
| 124 | break; | |
| 125 | } | |
| 126 | ||
| 127 | in++; | |
| 128 | } | |
| 129 | } | |
| 130 | } | |
| 71 | else if (file) | |
| 72 | mame_fread(file,nvram,nvram_size); | |
| 131 | 73 | } |
| 132 | 74 | |
| 133 | 75 |
| r2724 | r2725 | |
|---|---|---|
| 62 | 62 | ***************************************************************************/ |
| 63 | 63 | |
| 64 | 64 | #include "driver.h" |
| 65 | #include "deprecat.h" | |
| 66 | 65 | #include "cpu/tms32010/tms32010.h" |
| 67 | 66 | #include "toaplan1.h" |
| 68 | 67 | #include "sound/3812intf.h" |
| r2724 | r2725 | |
| 1104 | 1103 | PORT_INCLUDE( vimana ) |
| 1105 | 1104 | |
| 1106 | 1105 | PORT_MODIFY("DSWA") /* DSW A */ |
| 1106 | PORT_DIPNAME( 0x08, 0x00, DEF_STR( Unused ) ) | |
| 1107 | 1107 | PORT_DIPSETTING( 0x08, DEF_STR( Off ) ) |
| 1108 | 1108 | PORT_DIPSETTING( 0x00, DEF_STR( On ) ) |
| 1109 | 1109 | PORT_DIPNAME( 0x10, 0x00, DEF_STR( Unused ) ) |
| r2724 | r2725 | |
| 1208 | 1208 | GFXDECODE_END |
| 1209 | 1209 | |
| 1210 | 1210 | |
| 1211 | static void irqhandler(int linestate) | |
| 1211 | static void irqhandler(running_machine *machine, int linestate) | |
| 1212 | 1212 | { |
| 1213 | cpunum_set_input_line( | |
| 1213 | cpunum_set_input_line(machine, 1,0,linestate); | |
| 1214 | 1214 | } |
| 1215 | 1215 | |
| 1216 | 1216 | static const struct YM3812interface ym3812_interface = |
| r2724 | r2725 | |
|---|---|---|
| 160 | 160 | { |
| 161 | 161 | /* pressing the service switch sends an NMI */ |
| 162 | 162 | if (newval) |
| 163 | cpunum_set_input_line(machine, 0, INPUT_LINE_NMI, PULSE_LINE); | |
| 163 | cpunum_set_input_line(field->port->machine, 0, INPUT_LINE_NMI, PULSE_LINE); | |
| 164 | 164 | } |
| 165 | 165 | |
| 166 | 166 |
| r2724 | r2725 | |
|---|---|---|
| 595 | 595 | |
| 596 | 596 | |
| 597 | 597 | |
| 598 | static void irqhandler(int irq) | |
| 598 | static void irqhandler(running_machine *machine, int irq) | |
| 599 | 599 | { |
| 600 | 600 | popmessage("irq"); |
| 601 | // cpunum_set_input_line( | |
| 601 | // cpunum_set_input_line(machine, 2,0,irq ? ASSERT_LINE : CLEAR_LINE); | |
| 602 | 602 | } |
| 603 | 603 | |
| 604 | 604 |
| r2724 | r2725 | |
|---|---|---|
| 20 | 20 | ***************************************************************************/ |
| 21 | 21 | |
| 22 | 22 | #include "driver.h" |
| 23 | #include "deprecat.h" | |
| 24 | 23 | #include "audio/seibu.h" |
| 25 | 24 | |
| 26 | 25 | /* the on-chip FIFO is 16 bytes long, but we use a larger one to simplify */ |
| r2724 | r2725 | |
| 788 | 787 | |
| 789 | 788 | static READ16_HANDLER(shanghai_rand_r) |
| 790 | 789 | { |
| 791 | return mame_rand( | |
| 790 | return mame_rand(machine); | |
| 792 | 791 | } |
| 793 | 792 | |
| 794 | 793 | static READ16_HANDLER( kothello_HD63484_status_r ) |
| r2724 | r2725 | |
|---|---|---|
| 372 | 372 | /* 0xffffff, and returning 0 causes the game to mess up - locking up in a */ |
| 373 | 373 | /* loop where the ball is continuously bouncing from the basket. Returning */ |
| 374 | 374 | /* a random number seems to prevent that. */ |
| 375 | return mame_rand( | |
| 375 | return mame_rand(machine); | |
| 376 | 376 | } |
| 377 | 377 | |
| 378 | 378 | |
| r2724 | r2725 | |
| 2285 | 2285 | INPUT_PORTS_END |
| 2286 | 2286 | |
| 2287 | 2287 | |
| 2288 | static void cuebrick_irq_handler(int state) | |
| 2288 | static void cuebrick_irq_handler(running_machine *machine, int state) | |
| 2289 | 2289 | { |
| 2290 | 2290 | cuebrick_snd_irqlatch = state; |
| 2291 | 2291 | } |
| r2724 | r2725 | |
| 2627 | 2627 | MACHINE_DRIVER_END |
| 2628 | 2628 | |
| 2629 | 2629 | |
| 2630 | static void sound_nmi( | |
| 2630 | static void sound_nmi(running_machine *machine) | |
| 2631 | 2631 | { |
| 2632 | cpunum_set_input_line( | |
| 2632 | cpunum_set_input_line(machine, 1, INPUT_LINE_NMI, PULSE_LINE); | |
| 2633 | 2633 | } |
| 2634 | 2634 | |
| 2635 | 2635 | static const struct K054539interface k054539_interface = |
| r2724 | r2725 | |
|---|---|---|
| 154 | 154 | * |
| 155 | 155 | *************************************/ |
| 156 | 156 | |
| 157 | static void update_irqs( | |
| 157 | static void update_irqs(running_machine *machine) | |
| 158 | 158 | { |
| 159 | 159 | int newstate = 0; |
| 160 | 160 | |
| r2724 | r2725 | |
| 164 | 164 | newstate = 5; |
| 165 | 165 | |
| 166 | 166 | if (newstate) |
| 167 | cpunum_set_input_line( | |
| 167 | cpunum_set_input_line(machine, 0, newstate, ASSERT_LINE); | |
| 168 | 168 | else |
| 169 | cpunum_set_input_line( | |
| 169 | cpunum_set_input_line(machine, 0, 7, CLEAR_LINE); | |
| 170 | 170 | } |
| 171 | 171 | |
| 172 | 172 | |
| r2724 | r2725 | |
| 250 | 250 | duart_1.ISR |= 0x08; |
| 251 | 251 | |
| 252 | 252 | duart_1_irq = 1; |
| 253 | update_irqs(); | |
| 253 | update_irqs(machine); | |
| 254 | 254 | } |
| 255 | 255 | |
| 256 | 256 | static READ16_HANDLER( duart_1_r ) |
| r2724 | r2725 | |
| 307 | 307 | case 0xf: |
| 308 | 308 | { |
| 309 | 309 | duart_1_irq = 0; |
| 310 | update_irqs(); | |
| 310 | update_irqs(machine); | |
| 311 | 311 | duart_1.ISR |= ~0x8; |
| 312 | 312 | break; |
| 313 | 313 | } |
| r2724 | r2725 | |
| 815 | 815 | static void jpmimpct_tms_irq(int state) |
| 816 | 816 | { |
| 817 | 817 | tms_irq = state; |
| 818 | update_irqs(); | |
| 818 | update_irqs(Machine); | |
| 819 | 819 | } |
| 820 | 820 | |
| 821 | 821 | static const tms34010_config tms_config = |
| r2724 | r2725 | |
|---|---|---|
| 1382 | 1382 | |
| 1383 | 1383 | static READ8_HANDLER( s12_mcu_gun_h_r ) |
| 1384 | 1384 | { |
| 1385 | int index = port_tag_to_index("IN3"); | |
| 1386 | if( index != -1 ) | |
| 1385 | const input_port_config *port = input_port_by_tag(machine->portconfig, "IN3"); | |
| 1386 | if( port != NULL ) | |
| 1387 | 1387 | { |
| 1388 | int rv = input_port_read_ | |
| 1388 | int rv = input_port_read_ | |
| 1389 | 1389 | |
| 1390 | 1390 | if( ( offset & 1 ) != 0 ) |
| 1391 | 1391 | { |
| r2724 | r2725 | |
| 1401 | 1401 | |
| 1402 | 1402 | static READ8_HANDLER( s12_mcu_gun_v_r ) |
| 1403 | 1403 | { |
| 1404 | int index = port_tag_to_index("IN4"); | |
| 1405 | if( index != -1 ) | |
| 1404 | const input_port_config *port = input_port_by_tag(machine->portconfig, "IN4"); | |
| 1405 | if( port != NULL ) | |
| 1406 | 1406 | { |
| 1407 | int rv = input_port_read_ | |
| 1407 | int rv = input_port_read_ | |
| 1408 | 1408 | |
| 1409 | 1409 | if( ( offset & 1 ) != 0 ) |
| 1410 | 1410 | { |
| r2724 | r2725 | |
|---|---|---|
| 928 | 928 | PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_4WAY |
| 929 | 929 | PORT_SERVICE( 0x20, IP_ACTIVE_HIGH ) |
| 930 | 930 | PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_4WAY |
| 931 | PORT_ | |
| 931 | PORT_DIPNAME( | |
| 932 | 932 | PORT_DIPSETTING( 0x00, DEF_STR( Off ) ) |
| 933 | 933 | PORT_DIPSETTING( 0x80, DEF_STR( On ) ) |
| 934 | 934 | INPUT_PORTS_END |
| r2724 | r2725 | |
|---|---|---|
| 62 | 62 | */ |
| 63 | 63 | |
| 64 | 64 | #include "driver.h" |
| 65 | #include "deprecat.h" | |
| 66 | 65 | #include "cpu/z80/z80.h" |
| 67 | 66 | #include "system16.h" |
| 68 | 67 | #include "cpu/m68000/m68000.h" |
| r2724 | r2725 | |
| 175 | 174 | sample_buffer = data; |
| 176 | 175 | } |
| 177 | 176 | |
| 178 | static void shdancbl_msm5205_callback(int data) | |
| 177 | static void shdancbl_msm5205_callback(running_machine *machine, int data) | |
| 179 | 178 | { |
| 180 | 179 | MSM5205_data_w(0, sample_buffer & 0x0F); |
| 181 | 180 | sample_buffer >>= 4; |
| 182 | 181 | sample_select ^= 1; |
| 183 | 182 | if(sample_select == 0) |
| 184 | cpunum_set_input_line( | |
| 183 | cpunum_set_input_line(machine, 1, INPUT_LINE_NMI, PULSE_LINE); | |
| 185 | 184 | } |
| 186 | 185 | |
| 187 | 186 | static const struct MSM5205interface shdancbl_msm5205_interface = |
| r2724 | r2725 | |
|---|---|---|
| 350 | 350 | */ |
| 351 | 351 | |
| 352 | 352 | #include "driver.h" |
| 353 | #include "deprecat.h" | |
| 354 | 353 | #include "taito_f3.h" |
| 355 | 354 | #include "cpu/mc68hc11/mc68hc11.h" |
| 356 | 355 | #include "sound/es5506.h" |
| r2724 | r2725 | |
| 455 | 454 | { |
| 456 | 455 | if (ACCESSING_BITS_24_31) |
| 457 | 456 | { |
| 458 | //r |= (mame_rand( | |
| 457 | //r |= (mame_rand(machine) & 0xff) << 24; | |
| 459 | 458 | } |
| 460 | 459 | return r; |
| 461 | 460 | } |
| r2724 | r2725 | |
|---|---|---|
| 343 | 343 | /* Sound Interfaces */ |
| 344 | 344 | |
| 345 | 345 | // Handler called by the 3526 emulator when the internal timers cause an IRQ |
| 346 | static void irqhandler(int irq) | |
| 346 | static void irqhandler(running_machine *machine, int irq) | |
| 347 | 347 | { |
| 348 | 348 | logerror("YM3526 firing an IRQ\n"); |
| 349 | // cpunum_set_input_line( | |
| 349 | // cpunum_set_input_line(machine, 2,0,irq ? ASSERT_LINE : CLEAR_LINE); | |
| 350 | 350 | } |
| 351 | 351 | |
| 352 | 352 | static const struct YM3526interface ym3526_interface = |
| r2724 | r2725 | |
|---|---|---|
| 103 | 103 | |
| 104 | 104 | |
| 105 | 105 | #include "driver.h" |
| 106 | #include "deprecat.h" | |
| 107 | 106 | |
| 108 | 107 | static UINT16 *shared_ram; |
| 109 | 108 | |
| r2724 | r2725 | |
| 230 | 229 | if (resp[respcount]<0) |
| 231 | 230 | { |
| 232 | 231 | respcount = 0; |
| 233 | ddealer_protection( | |
| 232 | ddealer_protection(machine); | |
| 234 | 233 | |
| 235 | 234 | } |
| 236 | 235 | return res; |
| r2724 | r2725 | |
|---|---|---|
| 665 | 665 | PORT_DIPSETTING( 0x00, DEF_STR( Cocktail ) ) |
| 666 | 666 | |
| 667 | 667 | PORT_START /* IN3 */ |
| 668 | PORT_ | |
| 668 | PORT_DIPNAME( | |
| 669 | 669 | PORT_DIPSETTING( 0x00, DEF_STR( Off ) ) |
| 670 | 670 | PORT_DIPSETTING( 0x01, DEF_STR( On ) ) |
| 671 | PORT_ | |
| 671 | PORT_DIPNAME( | |
| 672 | 672 | PORT_DIPSETTING( 0x00, DEF_STR( Off ) ) |
| 673 | 673 | PORT_DIPSETTING( 0x02, DEF_STR( On ) ) |
| 674 | 674 | PORT_BIT( 0x3c, IP_ACTIVE_LOW, IPT_UNUSED ) |
| r2724 | r2725 | |
| 679 | 679 | PORT_DIPSETTING( 0xc0, DEF_STR( Spanish ) ) |
| 680 | 680 | |
| 681 | 681 | PORT_START /* IN4 */ |
| 682 | PORT_ | |
| 682 | PORT_DIPNAME( | |
| 683 | 683 | PORT_DIPSETTING( 0x00, DEF_STR( Off ) ) |
| 684 | 684 | PORT_DIPSETTING( 0x03, DEF_STR( On ) ) |
| 685 | 685 | PORT_BIT( 0x3c, IP_ACTIVE_LOW, IPT_UNUSED ) |
| r2724 | r2725 | |
| 768 | 768 | |
| 769 | 769 | PORT_START /* IN4 */ |
| 770 | 770 | PORT_BIT( 0x03, IP_ACTIVE_HIGH, IPT_UNUSED ) /* Bit 0 does some more hardware tests */ |
| 771 | PORT_ | |
| 771 | PORT_DIPNAME( | |
| 772 | 772 | PORT_DIPSETTING( 0x00, DEF_STR( Off ) ) |
| 773 | 773 | PORT_DIPSETTING( 0x04, DEF_STR( On ) ) |
| 774 | PORT_ | |
| 774 | PORT_DIPNAME( | |
| 775 | 775 | PORT_DIPSETTING( 0x00, DEF_STR( Off ) ) |
| 776 | 776 | PORT_DIPSETTING( 0x08, DEF_STR( On ) ) |
| 777 | 777 | PORT_BIT( 0xf0, IP_ACTIVE_LOW, IPT_UNUSED ) |
| r2724 | r2725 | |
|---|---|---|
| 212 | 212 | MSM5205_reset_w(0,data ? 0 : 1); |
| 213 | 213 | } |
| 214 | 214 | |
| 215 | static void tehkanwc_adpcm_int | |
| 215 | static void tehkanwc_adpcm_int | |
| 216 | 216 | { |
| 217 | 217 | static int toggle; |
| 218 | 218 |
| r2724 | r2725 | |
|---|---|---|
| 228 | 228 | |
| 229 | 229 | /* screen flip multiplexes controls */ |
| 230 | 230 | if (suprridr_is_screen_flipped()) |
| 231 | ret = input_port_read(machine, SUPRRIDR_P2_CONTROL_PORT_TAG); | |
| 231 | ret = input_port_read(field->port->machine, SUPRRIDR_P2_CONTROL_PORT_TAG); | |
| 232 | 232 | else |
| 233 | ret = input_port_read(machine, SUPRRIDR_P1_CONTROL_PORT_TAG); | |
| 233 | ret = input_port_read(field->port->machine, SUPRRIDR_P1_CONTROL_PORT_TAG); | |
| 234 | 234 | |
| 235 | 235 | return ret; |
| 236 | 236 | } |
| r2724 | r2725 | |
|---|---|---|
| 18 | 18 | ***************************************************************************/ |
| 19 | 19 | |
| 20 | 20 | #include "driver.h" |
| 21 | #include "deprecat.h" | |
| 22 | 21 | #include "cpu/m6809/m6809.h" |
| 23 | 22 | #include "video/konamiic.h" |
| 24 | 23 | #include "sound/3812intf.h" |
| r2724 | r2725 | |
| 311 | 310 | { |
| 312 | 311 | /* we should handle collision here */ |
| 313 | 312 | //AT |
| 314 | /* | |
| 315 | int i; | |
| 313 | if (0) | |
| 314 | { | |
| 315 | int i; | |
| 316 | 316 | |
| 317 | logerror("collision test:\n"); | |
| 318 | for (i = 0;i < 0xfe;i++) | |
| 319 | { | |
| 320 | logerror("%02x ",pmcram[i]); | |
| 321 | if (i == 0x0f || (i > 0x10 && (i - 0x10) % 14 == 13)) | |
| 322 | logerror("\n"); | |
| 323 | } | |
| 324 | */ | |
| 317 | logerror("collision test:\n"); | |
| 318 | for (i = 0;i < 0xfe;i++) | |
| 319 | { | |
| 320 | logerror("%02x ",pmcram[i]); | |
| 321 | if (i == 0x0f || (i > 0x10 && (i - 0x10) % 14 == 13)) | |
| 322 | logerror("\n"); | |
| 323 | } | |
| 324 | } | |
| 325 | 325 | spy_collision(); |
| 326 | 326 | //ZT |
| 327 | cpunum_set_input_line( | |
| 327 | cpunum_set_input_line(machine, 0,M6809_FIRQ_LINE,HOLD_LINE); | |
| 328 | 328 | } |
| 329 | 329 | |
| 330 | 330 | old = data; |
| r2724 | r2725 | |
| 521 | 521 | }; |
| 522 | 522 | |
| 523 | 523 | |
| 524 | static void irqhandler(int linestate) | |
| 524 | static void irqhandler(running_machine *machine, int linestate) | |
| 525 | 525 | { |
| 526 | cpunum_set_input_line( | |
| 526 | cpunum_set_input_line(machine, 1, INPUT_LINE_NMI, linestate); | |
| 527 | 527 | } |
| 528 | 528 | |
| 529 | 529 | static const struct YM3812interface ym3812_interface = |
| r2724 | r2725 | |
|---|---|---|
| 61 | 61 | *****/ |
| 62 | 62 | |
| 63 | 63 | #include "driver.h" |
| 64 | #include "deprecat.h" | |
| 65 | 64 | #include "sound/2610intf.h" |
| 66 | 65 | #include "sound/ymf278b.h" |
| 67 | 66 | |
| r2724 | r2725 | |
| 369 | 368 | |
| 370 | 369 | ***************************************************************************/ |
| 371 | 370 | |
| 372 | static void sound_irq( int irq ) | |
| 371 | static void sound_irq( running_machine *machine, int irq ) | |
| 373 | 372 | { |
| 374 | cpunum_set_input_line( | |
| 373 | cpunum_set_input_line(machine, 1,0,irq ? ASSERT_LINE : CLEAR_LINE); | |
| 375 | 374 | } |
| 376 | 375 | |
| 377 | 376 | static READ8_HANDLER( psikyo_soundlatch_r ) |
| r2724 | r2725 | |
| 1662 | 1661 | ***************************************************************************/ |
| 1663 | 1662 | |
| 1664 | 1663 | |
| 1665 | static void irqhandler(int linestate) | |
| 1664 | static void irqhandler(running_machine *machine, int linestate) | |
| 1666 | 1665 | { |
| 1667 | 1666 | if (linestate) |
| 1668 | cpunum_set_input_line( | |
| 1667 | cpunum_set_input_line(machine, 1, 0, ASSERT_LINE); | |
| 1669 | 1668 | else |
| 1670 | cpunum_set_input_line( | |
| 1669 | cpunum_set_input_line(machine, 1, 0, CLEAR_LINE); | |
| 1671 | 1670 | } |
| 1672 | 1671 | |
| 1673 | 1672 | static const struct YMF278B_interface ymf278b_interface = |
| r2724 | r2725 | |
|---|---|---|
| 755 | 755 | { |
| 756 | 756 | int reg = offset*8; |
| 757 | 757 | if (ACCESSING_BITS_56_63) { |
| 758 | lsi53c810_reg_w(reg+0, data >> 56); | |
| 758 | lsi53c810_reg_w(machine, reg+0, data >> 56); | |
| 759 | 759 | } |
| 760 | 760 | if (ACCESSING_BITS_48_55) { |
| 761 | lsi53c810_reg_w(reg+1, data >> 48); | |
| 761 | lsi53c810_reg_w(machine, reg+1, data >> 48); | |
| 762 | 762 | } |
| 763 | 763 | if (ACCESSING_BITS_40_47) { |
| 764 | lsi53c810_reg_w(reg+2, data >> 40); | |
| 764 | lsi53c810_reg_w(machine, reg+2, data >> 40); | |
| 765 | 765 | } |
| 766 | 766 | if (ACCESSING_BITS_32_39) { |
| 767 | lsi53c810_reg_w(reg+3, data >> 32); | |
| 767 | lsi53c810_reg_w(machine, reg+3, data >> 32); | |
| 768 | 768 | } |
| 769 | 769 | if (ACCESSING_BITS_24_31) { |
| 770 | lsi53c810_reg_w(reg+4, data >> 24); | |
| 770 | lsi53c810_reg_w(machine, reg+4, data >> 24); | |
| 771 | 771 | } |
| 772 | 772 | if (ACCESSING_BITS_16_23) { |
| 773 | lsi53c810_reg_w(reg+5, data >> 16); | |
| 773 | lsi53c810_reg_w(machine, reg+5, data >> 16); | |
| 774 | 774 | } |
| 775 | 775 | if (ACCESSING_BITS_8_15) { |
| 776 | lsi53c810_reg_w(reg+6, data >> 8); | |
| 776 | lsi53c810_reg_w(machine, reg+6, data >> 8); | |
| 777 | 777 | } |
| 778 | 778 | if (ACCESSING_BITS_0_7) { |
| 779 | lsi53c810_reg_w(reg+7, data >> 0); | |
| 779 | lsi53c810_reg_w(machine, reg+7, data >> 0); | |
| 780 | 780 | } |
| 781 | 781 | } |
| 782 | 782 | |
| r2724 | r2725 | |
| 787 | 787 | return BYTE_REVERSE32(result); |
| 788 | 788 | } |
| 789 | 789 | |
| 790 | static void scsi_irq_callback( | |
| 790 | static void scsi_irq_callback(running_machine *machine) | |
| 791 | 791 | { |
| 792 | 792 | model3_irq_state |= model3_irq_enable & ~0x60; /* FIXME: enable only SCSI interrupt */ |
| 793 | cpunum_set_input_line( | |
| 793 | cpunum_set_input_line(machine, 0, INPUT_LINE_IRQ1, ASSERT_LINE); | |
| 794 | 794 | } |
| 795 | 795 | |
| 796 | 796 | /*****************************************************************************/ |
| r2724 | r2725 | |
| 846 | 846 | real3d_dma_callback(dma_source, dma_dest, length, 1); |
| 847 | 847 | } |
| 848 | 848 | dma_irq |= 0x01; |
| 849 | scsi_irq_callback(); | |
| 849 | scsi_irq_callback(machine); | |
| 850 | 850 | return; |
| 851 | 851 | } |
| 852 | 852 | else if(ACCESSING_BITS_16_23) |
| r2724 | r2725 | |
| 4010 | 4010 | |
| 4011 | 4011 | static int scsp_last_line = 0; |
| 4012 | 4012 | |
| 4013 | static void scsp_irq(int irq) | |
| 4013 | static void scsp_irq(running_machine *machine, int irq) | |
| 4014 | 4014 | { |
| 4015 | 4015 | if (irq > 0) |
| 4016 | 4016 | { |
| 4017 | 4017 | scsp_last_line = irq; |
| 4018 | cpunum_set_input_line( | |
| 4018 | cpunum_set_input_line(machine, 1, irq, PULSE_LINE); | |
| 4019 | 4019 | } |
| 4020 | 4020 | } |
| 4021 | 4021 |
| r2724 | r2725 | |
|---|---|---|
| 456 | 456 | soundlatch3_w(machine, 0, data); |
| 457 | 457 | } |
| 458 | 458 | |
| 459 | static void sound_irq(int level) | |
| 459 | static void sound_irq(running_machine *machine, int level) | |
| 460 | 460 | { |
| 461 | cpunum_set_input_line( | |
| 461 | cpunum_set_input_line(machine, 1, 0, level); | |
| 462 | 462 | } |
| 463 | 463 | |
| 464 | 464 | static const struct ics2115_interface pgm_ics2115_interface = { |
| r2724 | r2725 | |
|---|---|---|
| 64 | 64 | ****************************************************************************/ |
| 65 | 65 | |
| 66 | 66 | #include "driver.h" |
| 67 | #include "deprecat.h" | |
| 68 | 67 | #include "machine/6532riot.h" |
| 69 | 68 | #include "machine/6522via.h" |
| 70 | 69 | #include "sound/ay8910.h" |
| r2724 | r2725 | |
| 167 | 166 | * |
| 168 | 167 | *************************************/ |
| 169 | 168 | |
| 170 | static void r6532_irq(int state) | |
| 169 | static void r6532_irq(running_machine *machine, int state) | |
| 171 | 170 | { |
| 172 | cpunum_set_input_line( | |
| 171 | cpunum_set_input_line(machine, 1, 0, state); | |
| 173 | 172 | } |
| 174 | 173 | |
| 175 | 174 |
| r2724 | r2725 | |
|---|---|---|
| 88 | 88 | ***************************************************************************/ |
| 89 | 89 | |
| 90 | 90 | #include "driver.h" |
| 91 | #include "deprecat.h" | |
| 92 | 91 | #include "machine/ticket.h" |
| 93 | 92 | #include "cpu/m6809/m6809.h" |
| 94 | 93 | #include "capbowl.h" |
| r2724 | r2725 | |
| 205 | 204 | * |
| 206 | 205 | *************************************/ |
| 207 | 206 | |
| 208 | static void firqhandler(int irq) | |
| 207 | static void firqhandler(running_machine *machine, int irq) | |
| 209 | 208 | { |
| 210 | cpunum_set_input_line( | |
| 209 | cpunum_set_input_line(machine, 1, 1, irq ? ASSERT_LINE : CLEAR_LINE); | |
| 211 | 210 | } |
| 212 | 211 | |
| 213 | 212 |
| r2724 | r2725 | |
|---|---|---|
| 515 | 515 | ADDRESS_MAP_END |
| 516 | 516 | |
| 517 | 517 | |
| 518 | static void darius_adpcm_int (int data) | |
| 518 | static void darius_adpcm_int (running_machine *machine, int data) | |
| 519 | 519 | { |
| 520 | 520 | if (nmi_enable) |
| 521 | cpunum_set_input_line( | |
| 521 | cpunum_set_input_line(machine, 3, INPUT_LINE_NMI, PULSE_LINE); | |
| 522 | 522 | } |
| 523 | 523 | |
| 524 | 524 | static const struct MSM5205interface msm5205_interface = |
| r2724 | r2725 | |
| 801 | 801 | **************************************************************/ |
| 802 | 802 | |
| 803 | 803 | /* handler called by the YM2203 emulator when the internal timers cause an IRQ */ |
| 804 | static void irqhandler(int irq) /* assumes Z80 sandwiched between 68Ks */ | |
| 804 | static void irqhandler(running_machine *machine, int irq) /* assumes Z80 sandwiched between 68Ks */ | |
| 805 | 805 | { |
| 806 | cpunum_set_input_line( | |
| 806 | cpunum_set_input_line(machine, 1,0,irq ? ASSERT_LINE : CLEAR_LINE); | |
| 807 | 807 | } |
| 808 | 808 | |
| 809 | 809 | static const struct YM2203interface ym2203_interface_1 = |
| r2724 | r2725 | |
|---|---|---|
| 98 | 98 | |
| 99 | 99 | |
| 100 | 100 | #include "driver.h" |
| 101 | #include "deprecat.h" | |
| 102 | 101 | #include "cpu/asap/asap.h" |
| 103 | 102 | #include "machine/atarigen.h" |
| 104 | 103 | #include "audio/atarijsa.h" |
| r2724 | r2725 | |
| 226 | 225 | irq_state[0] = irq_state[1] = irq_state[2] = 0; |
| 227 | 226 | |
| 228 | 227 | /* update the current state */ |
| 229 | update_interrupts( | |
| 228 | update_interrupts(machine); | |
| 230 | 229 | } |
| 231 | 230 | |
| 232 | 231 |
| r2724 | r2725 | |
|---|---|---|
| 13 | 13 | ***************************************************************************/ |
| 14 | 14 | |
| 15 | 15 | #include "driver.h" |
| 16 | #include "deprecat.h" | |
| 17 | 16 | #include "video/vector.h" |
| 18 | 17 | #include "machine/6840ptm.h" |
| 19 | 18 | #include "machine/z80ctc.h" |
| r2724 | r2725 | |
| 58 | 57 | AM_RANGE(0x00, 0x03) AM_READWRITE(z80ctc_0_r,z80ctc_0_w) |
| 59 | 58 | ADDRESS_MAP_END |
| 60 | 59 | |
| 61 | static void cchasm_6840_irq(int state) | |
| 60 | static void cchasm_6840_irq(running_machine *machine, int state) | |
| 62 | 61 | { |
| 63 | cpunum_set_input_line( | |
| 62 | cpunum_set_input_line(machine, 0, 4, state?ASSERT_LINE:CLEAR_LINE); | |
| 64 | 63 | } |
| 65 | 64 | static const ptm6840_interface cchasm_6840_intf = |
| 66 | 65 | { |
| r2724 | r2725 | |
|---|---|---|
| 86 | 86 | */ |
| 87 | 87 | |
| 88 | 88 | #include "driver.h" |
| 89 | #include "deprecat.h" | |
| 90 | 89 | #include "sound/ay8910.h" |
| 91 | 90 | #include "machine/8255ppi.h" |
| 92 | 91 | |
| r2724 | r2725 | |
| 98 | 97 | int pc = activecpu_get_pc(); |
| 99 | 98 | if(pc != 0x81cb) |
| 100 | 99 | printf("r1 @ %X\n",activecpu_get_pc()); |
| 101 | return mame_rand( | |
| 100 | return mame_rand(machine); | |
| 102 | 101 | } |
| 103 | 102 | static READ8_HANDLER( r2 ) |
| 104 | 103 | { |
| 105 | 104 | int pc = activecpu_get_pc(); |
| 106 | 105 | if(pc != 0x81cb) |
| 107 | 106 | printf("r2 @ %X\n",activecpu_get_pc()); |
| 108 | return mame_rand( | |
| 107 | return mame_rand(machine); | |
| 109 | 108 | } |
| 110 | 109 | static READ8_HANDLER( r3 ) |
| 111 | 110 | { |
| 112 | 111 | int pc = activecpu_get_pc(); |
| 113 | 112 | if(pc != 0x81cb && pc != 0x90fa && pc != 0x911b && pc != 0x90d3 && pc != 0x90c4) |
| 114 | 113 | printf("r3 @ %X\n",activecpu_get_pc()); |
| 115 | return mame_rand( | |
| 114 | return mame_rand(machine) & ~1; //with 1 jumps back (infinite loop): a status ready for something? | |
| 116 | 115 | } |
| 117 | 116 | static READ8_HANDLER( r4 ) |
| 118 | 117 | { |
| 119 | 118 | int pc = activecpu_get_pc(); |
| 120 | 119 | if(pc != 0x81cb) |
| 121 | 120 | printf("r4 @ %X\n",activecpu_get_pc()); |
| 122 | return mame_rand( | |
| 121 | return mame_rand(machine); | |
| 123 | 122 | } |
| 124 | 123 | static READ8_HANDLER( r5 ) |
| 125 | 124 | { |
| 126 | 125 | int pc = activecpu_get_pc(); |
| 127 | 126 | if(pc != 0x81cb) |
| 128 | 127 | printf("r5 @ %X\n",activecpu_get_pc()); |
| 129 | return mame_rand( | |
| 128 | return mame_rand(machine); | |
| 130 | 129 | } |
| 131 | 130 | static READ8_HANDLER( r6 ) |
| 132 | 131 | { |
| r2724 | r2725 | |
| 134 | 133 | if(pc != 0x81cb) |
| 135 | 134 | printf("r6 @ %X\n",activecpu_get_pc()); |
| 136 | 135 | |
| 137 | return mame_rand( | |
| 136 | return mame_rand(machine); | |
| 138 | 137 | } |
| 139 | 138 | |
| 140 | 139 | static WRITE8_HANDLER( w1 ) |
| r2724 | r2725 | |
|---|---|---|
| 88 | 88 | ***************************************************************************/ |
| 89 | 89 | |
| 90 | 90 | #include "driver.h" |
| 91 | #include "deprecat.h" | |
| 92 | 91 | #include "cpu/h6280/h6280.h" |
| 93 | 92 | #include "sound/2151intf.h" |
| 94 | 93 | #include "sound/okim6295.h" |
| r2724 | r2725 | |
| 353 | 352 | |
| 354 | 353 | /******************************************************************************/ |
| 355 | 354 | |
| 356 | static void sound_irq(int state) | |
| 355 | static void sound_irq(running_machine *machine, int state) | |
| 357 | 356 | { |
| 358 | cpunum_set_input_line( | |
| 357 | cpunum_set_input_line(machine, 1,1,state); /* IRQ 2 */ | |
| 359 | 358 | } |
| 360 | 359 | |
| 361 | 360 | static const struct YM2151interface ym2151_interface = |
| r2724 | r2725 | |
|---|---|---|
| 15 | 15 | ***************************************************************************/ |
| 16 | 16 | |
| 17 | 17 | #include "driver.h" |
| 18 | #include "deprecat.h" | |
| 19 | 18 | #include "sound/2203intf.h" |
| 20 | 19 | |
| 21 | 20 | static tilemap *suprgolf_tilemap; |
| r2724 | r2725 | |
| 92 | 91 | |
| 93 | 92 | static READ8_HANDLER( suprgolf_random ) |
| 94 | 93 | { |
| 95 | return mame_rand( | |
| 94 | return mame_rand(machine); | |
| 96 | 95 | } |
| 97 | 96 | |
| 98 | 97 | static ADDRESS_MAP_START( io_map, ADDRESS_SPACE_IO, 8 ) |
| r2724 | r2725 | |
| 257 | 256 | mame_printf_debug("ymwA\n"); |
| 258 | 257 | } |
| 259 | 258 | |
| 260 | static void irqhandler(int irq) | |
| 259 | static void irqhandler(running_machine *machine, int irq) | |
| 261 | 260 | { |
| 262 | // cpunum_set_input_line( | |
| 261 | // cpunum_set_input_line(machine, 1,0,irq ? ASSERT_LINE : CLEAR_LINE); | |
| 263 | 262 | } |
| 264 | 263 | |
| 265 | 264 | static const struct YM2203interface ym2203_interface = |
| r2724 | r2725 | |
|---|---|---|
| 320 | 320 | { |
| 321 | 321 | } |
| 322 | 322 | |
| 323 | static void scsi_irq( | |
| 323 | static void scsi_irq(running_machine *machine) | |
| 324 | 324 | { |
| 325 | psx_irq_set(0x400); | |
| 325 | psx_irq_set(machine, 0x400); | |
| 326 | 326 | } |
| 327 | 327 | |
| 328 | 328 | static const SCSIConfigTable dev_table = |
| r2724 | r2725 | |
|---|---|---|
| 230 | 230 | * |
| 231 | 231 | *************************************/ |
| 232 | 232 | |
| 233 | static void main_cpu_irq(int state) | |
| 233 | static void main_cpu_irq(running_machine *machine, int state) | |
| 234 | 234 | { |
| 235 | 235 | int combined_state = pia_get_irq_a(1) | pia_get_irq_b(1) | |
| 236 | 236 | pia_get_irq_b(2) | |
| 237 | 237 | pia_get_irq_a(3) | pia_get_irq_b(3); |
| 238 | 238 | |
| 239 | cpunum_set_input_line( | |
| 239 | cpunum_set_input_line(machine, 0, M6809_IRQ_LINE, combined_state ? ASSERT_LINE : CLEAR_LINE); | |
| 240 | 240 | } |
| 241 | 241 | |
| 242 | 242 | |
| 243 | static void main_cpu_firq(int state) | |
| 243 | static void main_cpu_firq(running_machine *machine, int state) | |
| 244 | 244 | { |
| 245 | cpunum_set_input_line( | |
| 245 | cpunum_set_input_line(machine, 0, M6809_FIRQ_LINE, state ? ASSERT_LINE : CLEAR_LINE); | |
| 246 | 246 | } |
| 247 | 247 | |
| 248 | 248 | |
| 249 | static void audio_cpu_irq(int state) | |
| 249 | static void audio_cpu_irq(running_machine *machine, int state) | |
| 250 | 250 | { |
| 251 | cpunum_set_input_line( | |
| 251 | cpunum_set_input_line(machine, 1, M6802_IRQ_LINE, state ? ASSERT_LINE : CLEAR_LINE); | |
| 252 | 252 | } |
| 253 | 253 | |
| 254 | 254 |
| r2724 | r2725 | |
|---|---|---|
| 136 | 136 | ******************************************************************************/ |
| 137 | 137 | |
| 138 | 138 | #include "driver.h" |
| 139 | #include "deprecat.h" | |
| 140 | 139 | #include "sound/2610intf.h" |
| 141 | 140 | |
| 142 | 141 | VIDEO_UPDATE( mcatadv ); |
| r2724 | r2725 | |
| 478 | 477 | |
| 479 | 478 | |
| 480 | 479 | /* Stolen from Psikyo.c */ |
| 481 | static void sound_irq( int irq ) | |
| 480 | static void sound_irq( running_machine *machine, int irq ) | |
| 482 | 481 | { |
| 483 | cpunum_set_input_line( | |
| 482 | cpunum_set_input_line(machine, 1,0,irq ? ASSERT_LINE : CLEAR_LINE); | |
| 484 | 483 | } |
| 485 | 484 | static const struct YM2610interface mcatadv_ym2610_interface = |
| 486 | 485 | { |
| r2724 | r2725 | |
|---|---|---|
| 151 | 151 | |
| 152 | 152 | static UINT8 joystick_read(void) |
| 153 | 153 | { |
| 154 | if (port_tag_to_index("ANALOGX") != -1) | |
| 155 | { | |
| 156 | int xval = (INT16)(cpunum_get_reg(0, CCPU_X) << 4) >> 4; | |
| 157 | return (input_port_read(Machine, mux_select ? "ANALOGX" : "ANALOGY") - xval) < 0x800; | |
| 158 | } | |
| 159 | return 0; | |
| 154 | int xval = (INT16)(cpunum_get_reg(0, CCPU_X) << 4) >> 4; | |
| 155 | return (input_port_read_safe(Machine, mux_select ? "ANALOGX" : "ANALOGY", 0) - xval) < 0x800; | |
| 160 | 156 | } |
| 161 | 157 | |
| 162 | 158 |
| r2724 | r2725 | |
|---|---|---|
| 1368 | 1368 | } |
| 1369 | 1369 | |
| 1370 | 1370 | |
| 1371 | static void bbakraid_irqhandler | |
| 1371 | static void bbakraid_irqhandler | |
| 1372 | 1372 | { |
| 1373 | 1373 | /* Not used ??? Connected to a test pin (TP082) */ |
| 1374 | 1374 | logerror("YMZ280 is generating an interrupt. State=%08x\n",state); |
| r2724 | r2725 | |
| 3405 | 3405 | GFXDECODE_ENTRY( REGION_GFX2, 0, fixeighblayout , 0, 128 ) |
| 3406 | 3406 | GFXDECODE_END |
| 3407 | 3407 | |
| 3408 | static void irqhandler(int linestate) | |
| 3408 | static void irqhandler(running_machine *machine, int linestate) | |
| 3409 | 3409 | { |
| 3410 | cpunum_set_input_line( | |
| 3410 | cpunum_set_input_line(machine, 1,0,linestate); | |
| 3411 | 3411 | } |
| 3412 | 3412 | |
| 3413 | 3413 | static const struct YM3812interface ym3812_interface = |
| r2724 | r2725 | |
| 3902 | 3902 | #endif |
| 3903 | 3903 | } |
| 3904 | 3904 | |
| 3905 | void batsugun_ym2151_irqhandler(int linestate) | |
| 3905 | void batsugun_ym2151_irqhandler(running_machine *machine, int linestate) | |
| 3906 | 3906 | { |
| 3907 | 3907 | logerror("batsugun_ym2151_irqhandler %02x\n",linestate); |
| 3908 | // update_irq_lines( | |
| 3908 | // update_irq_lines(machine, linestate ? assert : clear); | |
| 3909 | 3909 | } |
| 3910 | 3910 | |
| 3911 | 3911 | const struct YM2151interface batsugun_ym2151_interface = |
| r2724 | r2725 | |
|---|---|---|
| 250 | 250 | mcu_ram[mcu_offset + 6] = 0x3939; mcu_ram[mcu_offset + 7] = 0x3420; |
| 251 | 251 | break; |
| 252 | 252 | case 0x3e: |
| 253 | if ( strcmp( | |
| 253 | if ( strcmp(machine->gamedrv->name, "jchan") == 0 ) /* $f72 ($f6a-$fc6) */ | |
| 254 | 254 | { |
| 255 | 255 | /* MCU writes the string "1995/05/24 The kung-Fu Master Jackie Chan " to shared ram */ |
| 256 | 256 | mcu_ram[mcu_offset + 0] = 0x3139; mcu_ram[mcu_offset + 1] = 0x3935; |
| r2724 | r2725 | |
| 265 | 265 | mcu_ram[mcu_offset + 18] = 0x2043; mcu_ram[mcu_offset + 19] = 0x6861; |
| 266 | 266 | mcu_ram[mcu_offset + 20] = 0x6E20; mcu_ram[mcu_offset + 21] = 0x2020; |
| 267 | 267 | } |
| 268 | else if ( strcmp( | |
| 268 | else if ( strcmp(machine->gamedrv->name, "jchan2") == 0 ) | |
| 269 | 269 | { |
| 270 | 270 | /* MCU writes the string "1995/10/24 Fists Of Fire" to shared ram */ |
| 271 | 271 | mcu_ram[mcu_offset + 0] = 0x3139; mcu_ram[mcu_offset + 1] = 0x3935; |
| r2724 | r2725 | |
| 341 | 341 | mcu_ram[mcu_offset + 63] = 0x0062; |
| 342 | 342 | #endif |
| 343 | 343 | mame_file *f; |
| 344 | if ((f = nvram_fopen( | |
| 344 | if ((f = nvram_fopen(machine, OPEN_FLAG_READ)) != 0) | |
| 345 | 345 | { |
| 346 | 346 | mame_fread(f,&mcu_ram[mcu_offset], 128); |
| 347 | 347 | mame_fclose(f); |
| r2724 | r2725 | |
| 353 | 353 | case 0x42: /* save game settings to 93C46 EEPROM ($50d4) */ |
| 354 | 354 | { |
| 355 | 355 | mame_file *f; |
| 356 | if ((f = nvram_fopen( | |
| 356 | if ((f = nvram_fopen(machine, OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS)) != 0) | |
| 357 | 357 | { |
| 358 | 358 | mame_fwrite(f,&mcu_ram[mcu_offset], 128); |
| 359 | 359 | mame_fclose(f); |
| r2724 | r2725 | |
|---|---|---|
| 89 | 89 | |
| 90 | 90 | static int adpcm_pos; |
| 91 | 91 | |
| 92 | static void ml_msm5205_vck(int chip) | |
| 92 | static void ml_msm5205_vck(running_machine *machine, int chip) | |
| 93 | 93 | { |
| 94 | 94 | static int adpcm_data = -1; |
| 95 | 95 | |
| r2724 | r2725 | |
| 336 | 336 | |
| 337 | 337 | INPUT_PORTS_END |
| 338 | 338 | |
| 339 | static void irq_handler(int irq) | |
| 339 | static void irq_handler(running_machine *machine, int irq) | |
| 340 | 340 | { |
| 341 | cpunum_set_input_line( | |
| 341 | cpunum_set_input_line(machine, 1,0,irq ? ASSERT_LINE : CLEAR_LINE); | |
| 342 | 342 | } |
| 343 | 343 | |
| 344 | 344 | static GFXDECODE_START( mlanding ) |
| r2724 | r2725 | |
|---|---|---|
| 75 | 75 | |
| 76 | 76 | /* enable coin & start input? Wild guess!!! */ |
| 77 | 77 | if (pc3092_data[1] & 0x02) |
| 78 | ret = input_port_read(machine, "PC3092"); | |
| 78 | ret = input_port_read(field->port->machine, "PC3092"); | |
| 79 | 79 | else |
| 80 | 80 | ret = 0x00; |
| 81 | 81 |
| r2724 | r2725 | |
|---|---|---|
| 36 | 36 | */ |
| 37 | 37 | |
| 38 | 38 | #include "driver.h" |
| 39 | #include "deprecat.h" | |
| 40 | 39 | |
| 41 | 40 | static UINT8* dderby_vid; |
| 42 | 41 | |
| 43 | 42 | static READ8_HANDLER( dderby_random_reader ) |
| 44 | 43 | { |
| 45 | return mame_rand( | |
| 44 | return mame_rand(machine); | |
| 46 | 45 | } |
| 47 | 46 | |
| 48 | 47 | static ADDRESS_MAP_START( memmap, ADDRESS_SPACE_PROGRAM, 8 ) |
| r2724 | r2725 | |
|---|---|---|
| 465 | 465 | * |
| 466 | 466 | *************************************/ |
| 467 | 467 | |
| 468 | static void vblank_assert(int state); | |
| 469 | static void update_vblank_irq(void); | |
| 468 | static void vblank_assert(running_machine *machine, int state); | |
| 469 | static void update_vblank_irq(running_machine *machine); | |
| 470 | 470 | static void galileo_reset(void); |
| 471 | 471 | static TIMER_CALLBACK( galileo_timer_callback ); |
| 472 | 472 | static void galileo_perform_dma(running_machine *machine, int which); |
| 473 | static void voodoo_stall(int stall); | |
| 473 | static void voodoo_stall(running_machine *machine, int stall); | |
| 474 | 474 | static void widget_reset(void); |
| 475 | static void update_widget_irq( | |
| 475 | static void update_widget_irq(running_machine *machine); | |
| 476 | 476 | |
| 477 | 477 | |
| 478 | 478 | |
| r2724 | r2725 | |
| 571 | 571 | if (board_config == SEATTLE_WIDGET_CONFIG) |
| 572 | 572 | widget_reset(); |
| 573 | 573 | if (board_config == FLAGSTAFF_CONFIG) |
| 574 | smc91c94_reset(); | |
| 574 | smc91c94_reset(machine); | |
| 575 | 575 | } |
| 576 | 576 | |
| 577 | 577 | |
| r2724 | r2725 | |
| 595 | 595 | * |
| 596 | 596 | *************************************/ |
| 597 | 597 | |
| 598 | static void ethernet_interrupt(int state) | |
| 598 | static void ethernet_interrupt(running_machine *machine, int state) | |
| 599 | 599 | { |
| 600 | 600 | ethernet_irq_state = state; |
| 601 | 601 | if (board_config == FLAGSTAFF_CONFIG) |
| 602 | 602 | { |
| 603 | 603 | UINT8 assert = ethernet_irq_state && (*interrupt_enable & (1 << ETHERNET_IRQ_SHIFT)); |
| 604 | 604 | if (ethernet_irq_num != 0) |
| 605 | cpunum_set_input_line( | |
| 605 | cpunum_set_input_line(machine, 0, ethernet_irq_num, assert ? ASSERT_LINE : CLEAR_LINE); | |
| 606 | 606 | } |
| 607 | 607 | else if (board_config == SEATTLE_WIDGET_CONFIG) |
| 608 | update_widget_irq(); | |
| 608 | update_widget_irq(machine); | |
| 609 | 609 | } |
| 610 | 610 | |
| 611 | 611 | |
| r2724 | r2725 | |
| 622 | 622 | * |
| 623 | 623 | *************************************/ |
| 624 | 624 | |
| 625 | static void ioasic_irq(int state) | |
| 625 | static void ioasic_irq(running_machine *machine, int state) | |
| 626 | 626 | { |
| 627 | cpunum_set_input_line( | |
| 627 | cpunum_set_input_line(machine, 0, IOASIC_IRQ_NUM, state); | |
| 628 | 628 | } |
| 629 | 629 | |
| 630 | 630 | |
| r2724 | r2725 | |
| 690 | 690 | } |
| 691 | 691 | |
| 692 | 692 | /* update the states */ |
| 693 | update_vblank_irq(); | |
| 694 | ethernet_interrupt(ethernet_irq_state); | |
| 693 | update_vblank_irq(machine); | |
| 694 | ethernet_interrupt(machine, ethernet_irq_state); | |
| 695 | 695 | } |
| 696 | 696 | |
| 697 | 697 | |
| r2724 | r2725 | |
| 702 | 702 | if (old != *interrupt_enable) |
| 703 | 703 | { |
| 704 | 704 | if (vblank_latch) |
| 705 | update_vblank_irq(); | |
| 705 | update_vblank_irq(machine); | |
| 706 | 706 | if (ethernet_irq_state) |
| 707 | ethernet_interrupt(ethernet_irq_state); | |
| 707 | ethernet_interrupt(machine, ethernet_irq_state); | |
| 708 | 708 | } |
| 709 | 709 | } |
| 710 | 710 | |
| r2724 | r2725 | |
| 716 | 716 | * |
| 717 | 717 | *************************************/ |
| 718 | 718 | |
| 719 | static void update_vblank_irq( | |
| 719 | static void update_vblank_irq(running_machine *machine) | |
| 720 | 720 | { |
| 721 | 721 | int state = CLEAR_LINE; |
| 722 | 722 | |
| r2724 | r2725 | |
| 727 | 727 | /* if the VBLANK has been latched, and the interrupt is enabled, assert */ |
| 728 | 728 | if (vblank_latch && (*interrupt_enable & (1 << VBLANK_IRQ_SHIFT))) |
| 729 | 729 | state = ASSERT_LINE; |
| 730 | cpunum_set_input_line( | |
| 730 | cpunum_set_input_line(machine, 0, vblank_irq_num, state); | |
| 731 | 731 | } |
| 732 | 732 | |
| 733 | 733 | |
| r2724 | r2725 | |
| 735 | 735 | { |
| 736 | 736 | /* clear the latch and update the IRQ */ |
| 737 | 737 | vblank_latch = 0; |
| 738 | update_vblank_irq(); | |
| 738 | update_vblank_irq(machine); | |
| 739 | 739 | } |
| 740 | 740 | |
| 741 | 741 | |
| 742 | static void vblank_assert(int state) | |
| 742 | static void vblank_assert(running_machine *machine, int state) | |
| 743 | 743 | { |
| 744 | 744 | /* cache the raw state */ |
| 745 | 745 | vblank_state = state; |
| r2724 | r2725 | |
| 748 | 748 | if ((state && !(*interrupt_enable & 0x100)) || (!state && (*interrupt_enable & 0x100))) |
| 749 | 749 | { |
| 750 | 750 | vblank_latch = 1; |
| 751 | update_vblank_irq(); | |
| 751 | update_vblank_irq(machine); | |
| 752 | 752 | } |
| 753 | 753 | } |
| 754 | 754 | |
| r2724 | r2725 | |
| 881 | 881 | * |
| 882 | 882 | *************************************/ |
| 883 | 883 | |
| 884 | static void update_galileo_irqs( | |
| 884 | static void update_galileo_irqs(running_machine *machine) | |
| 885 | 885 | { |
| 886 | 886 | int state = CLEAR_LINE; |
| 887 | 887 | |
| 888 | 888 | /* if any unmasked interrupts are live, we generate */ |
| 889 | 889 | if (galileo.reg[GREG_INT_STATE] & galileo.reg[GREG_INT_MASK]) |
| 890 | 890 | state = ASSERT_LINE; |
| 891 | cpunum_set_input_line( | |
| 891 | cpunum_set_input_line(machine, 0, GALILEO_IRQ_NUM, state); | |
| 892 | 892 | |
| 893 | 893 | if (LOG_GALILEO) |
| 894 | 894 | logerror("Galileo IRQ %s\n", (state == ASSERT_LINE) ? "asserted" : "cleared"); |
| r2724 | r2725 | |
| 916 | 916 | |
| 917 | 917 | /* trigger the interrupt */ |
| 918 | 918 | galileo.reg[GREG_INT_STATE] |= 1 << (GINT_T0EXP_SHIFT + which); |
| 919 | update_galileo_irqs(); | |
| 919 | update_galileo_irqs(machine); | |
| 920 | 920 | } |
| 921 | 921 | |
| 922 | 922 | |
| r2724 | r2725 | |
| 942 | 942 | if (galileo.reg[GREG_DMA0_CONTROL + which] & 0x400) |
| 943 | 943 | { |
| 944 | 944 | galileo.reg[GREG_INT_STATE] |= 1 << (GINT_DMA0COMP_SHIFT + which); |
| 945 | update_galileo_irqs(); | |
| 945 | update_galileo_irqs(Machine); | |
| 946 | 946 | } |
| 947 | 947 | galileo.reg[GREG_DMA0_CONTROL + which] &= ~0x5000; |
| 948 | 948 | return 0; |
| r2724 | r2725 | |
| 1051 | 1051 | if (!(galileo.reg[GREG_DMA0_CONTROL + which] & 0x400)) |
| 1052 | 1052 | { |
| 1053 | 1053 | galileo.reg[GREG_INT_STATE] |= 1 << (GINT_DMA0COMP_SHIFT + which); |
| 1054 | update_galileo_irqs(); | |
| 1054 | update_galileo_irqs(machine); | |
| 1055 | 1055 | } |
| 1056 | 1056 | } while (galileo_dma_fetch_next(which)); |
| 1057 | 1057 | |
| r2724 | r2725 | |
| 1242 | 1242 | if (LOG_GALILEO) |
| 1243 | 1243 | logerror("%08X:Galileo write to IRQ clear = %08X & %08X\n", offset*4, data, mem_mask); |
| 1244 | 1244 | galileo.reg[offset] = oldata & data; |
| 1245 | update_galileo_irqs(); | |
| 1245 | update_galileo_irqs(machine); | |
| 1246 | 1246 | break; |
| 1247 | 1247 | |
| 1248 | 1248 | case GREG_CONFIG_DATA: |
| r2724 | r2725 | |
| 1320 | 1320 | } |
| 1321 | 1321 | |
| 1322 | 1322 | |
| 1323 | static void voodoo_stall(int stall) | |
| 1323 | static void voodoo_stall(running_machine *machine, int stall) | |
| 1324 | 1324 | { |
| 1325 | 1325 | /* set the new state */ |
| 1326 | 1326 | voodoo_stalled = stall; |
| r2724 | r2725 | |
| 1356 | 1356 | |
| 1357 | 1357 | /* resume execution */ |
| 1358 | 1358 | cpuintrf_push_context(0); |
| 1359 | galileo_perform_dma( | |
| 1359 | galileo_perform_dma(machine, which); | |
| 1360 | 1360 | cpuintrf_pop_context(); |
| 1361 | 1361 | break; |
| 1362 | 1362 | } |
| r2724 | r2725 | |
| 1366 | 1366 | { |
| 1367 | 1367 | /* if the CPU had a pending write, do it now */ |
| 1368 | 1368 | if (cpu_stalled_on_voodoo) |
| 1369 | voodoo_0_w( | |
| 1369 | voodoo_0_w(machine, cpu_stalled_offset, cpu_stalled_data, cpu_stalled_mem_mask); | |
| 1370 | 1370 | cpu_stalled_on_voodoo = FALSE; |
| 1371 | 1371 | |
| 1372 | 1372 | /* resume CPU execution */ |
| 1373 | 1373 | if (LOG_DMA) logerror("Resuming CPU on voodoo\n"); |
| 1374 | cpu_trigger( | |
| 1374 | cpu_trigger(machine, 45678); | |
| 1375 | 1375 | } |
| 1376 | 1376 | } |
| 1377 | 1377 | } |
| r2724 | r2725 | |
| 1494 | 1494 | UINT8 saved_irq = widget.irq_num; |
| 1495 | 1495 | memset(&widget, 0, sizeof(widget)); |
| 1496 | 1496 | widget.irq_num = saved_irq; |
| 1497 | smc91c94_reset(); | |
| 1497 | smc91c94_reset(Machine); | |
| 1498 | 1498 | } |
| 1499 | 1499 | |
| 1500 | 1500 | |
| 1501 | static void update_widget_irq( | |
| 1501 | static void update_widget_irq(running_machine *machine) | |
| 1502 | 1502 | { |
| 1503 | 1503 | UINT8 state = ethernet_irq_state << WINT_ETHERNET_SHIFT; |
| 1504 | 1504 | UINT8 mask = widget.irq_mask; |
| r2724 | r2725 | |
| 1506 | 1506 | |
| 1507 | 1507 | /* update the IRQ state */ |
| 1508 | 1508 | if (widget.irq_num != 0) |
| 1509 | cpunum_set_input_line( | |
| 1509 | cpunum_set_input_line(machine, 0, widget.irq_num, assert ? ASSERT_LINE : CLEAR_LINE); | |
| 1510 | 1510 | } |
| 1511 | 1511 | |
| 1512 | 1512 | |
| r2724 | r2725 | |
| 1553 | 1553 | |
| 1554 | 1554 | case WREG_INTERRUPT: |
| 1555 | 1555 | widget.irq_mask = data; |
| 1556 | update_widget_irq(); | |
| 1556 | update_widget_irq(machine); | |
| 1557 | 1557 | break; |
| 1558 | 1558 | |
| 1559 | 1559 | case WREG_ANALOG: |
| r2724 | r2725 | |
|---|---|---|
| 34 | 34 | ***************************************************************************/ |
| 35 | 35 | |
| 36 | 36 | #include "driver.h" |
| 37 | #include "deprecat.h" | |
| 38 | 37 | #include "sound/okim6295.h" |
| 39 | 38 | #include "sound/ymz280b.h" |
| 40 | 39 | #include "rocknms.lh" |
| r2724 | r2725 | |
| 265 | 264 | static READ16_HANDLER( tetrisp2_ip_1_word_r ) |
| 266 | 265 | { |
| 267 | 266 | return ( input_port_read(machine, "IN1") & 0xfcff ) | |
| 268 | ( mame_rand(Machine) & ~0xfcff ) | | |
| 269 | ( 1 << (8 + (mame_rand(Machine)&1)) ); | |
| 267 | ( mame_rand(machine) & ~0xfcff ) | | |
| 268 | ( 1 << (8 + (mame_rand(machine)&1)) ); | |
| 270 | 269 | } |
| 271 | 270 | |
| 272 | 271 |
| r2724 | r2725 | |
|---|---|---|
| 232 | 232 | /******************************************************************************/ |
| 233 | 233 | |
| 234 | 234 | /* handler called by the 2203 emulator when the internal timers cause an IRQ */ |
| 235 | static void irqhandler(int irq) | |
| 235 | static void irqhandler(running_machine *machine, int irq) | |
| 236 | 236 | { |
| 237 | cpunum_set_input_line( | |
| 237 | cpunum_set_input_line(machine, 1,0,irq ? ASSERT_LINE : CLEAR_LINE); | |
| 238 | 238 | } |
| 239 | 239 | |
| 240 | 240 | static const struct YM2203interface ym2203_interface = |
| r2724 | r2725 | |
|---|---|---|
| 1965 | 1965 | } |
| 1966 | 1966 | }; |
| 1967 | 1967 | |
| 1968 | static void YM3812_irq(int param) | |
| 1968 | static void YM3812_irq(running_machine *machine, int param) | |
| 1969 | 1969 | { |
| 1970 | cpunum_set_input_line( | |
| 1970 | cpunum_set_input_line(machine, 1, 0, (param) ? HOLD_LINE : CLEAR_LINE); | |
| 1971 | 1971 | } |
| 1972 | 1972 | |
| 1973 | 1973 | static const struct YM3812interface ym3812_interface = |
| r2724 | r2725 | |
|---|---|---|
| 25 | 25 | Touch Master 2000 |
| 26 | 26 | Touch Master 6000 |
| 27 | 27 | Touch Master 7000 * |
| 28 | Touch Master 8000 * | |
| 28 | Touch Master 8000 * | |
| 29 | 29 | |
| 30 | 30 | * There is a reported "Minnesota" version with modifications due to legal issues |
| 31 | 31 | Touch Master (current set) is a Euro version, all other sets are "DOMESTIC" (AKA "Standard"). |
| r2724 | r2725 | |
| 134 | 134 | |
| 135 | 135 | ***************************************************************************/ |
| 136 | 136 | |
| 137 | static void duart_irq_handler( | |
| 137 | static void duart_irq_handler(running_machine *machine, int vector) | |
| 138 | 138 | { |
| 139 | cpunum_set_input_line_and_vector( | |
| 139 | cpunum_set_input_line_and_vector(machine, 0, 4, HOLD_LINE, vector); | |
| 140 | 140 | }; |
| 141 | 141 | |
| 142 | 142 | static void duart_tx(int channel, UINT8 data) |
| r2724 | r2725 | |
| 151 | 151 | static void microtouch_tx(UINT8 data) |
| 152 | 152 | { |
| 153 | 153 | //logerror( "microtouch->duart: %02x %c\n", data, (char)data); |
| 154 | duart_68681_rx_data(0, data); | |
| 154 | duart_68681_rx_data(Machine, 0, data); | |
| 155 | 155 | } |
| 156 | 156 | |
| 157 | 157 | |
| r2724 | r2725 | |
| 640 | 640 | PORT_INCLUDE(microtouch) |
| 641 | 641 | |
| 642 | 642 | PORT_START_TAG("COIN") // IN3 |
| 643 | PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_UNKNOWN ) // m. coin 1 (coin optics?) | |
| 644 | PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_UNKNOWN ) // m. coin 2 (coin optics?) | |
| 645 | PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_UNKNOWN ) // dbv input (coin optics?) | |
| 643 | PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_COIN5 ) // "M. Coin 1 Input" | |
| 644 | PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_COIN6 ) // "M. Coin 2 Input" | |
| 645 | PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_BILL1 ) PORT_IMPULSE(2) // "DBV Input" | |
| 646 | 646 | PORT_BIT( 0x0008, IP_ACTIVE_LOW, IPT_UNKNOWN ) |
| 647 | PORT_BIT( 0x0010, IP_ACTIVE_LOW, IPT_ | |
| 647 | PORT_BIT( 0x0010, IP_ACTIVE_LOW, IPT_UNKNOWN | |
| 648 | 648 | PORT_SERVICE_NO_TOGGLE( 0x0020, IP_ACTIVE_LOW ) |
| 649 | PORT_BIT( 0x0040, IP_ACTIVE_LOW, IPT_SERVICE1 ) // | |
| 649 | PORT_BIT( 0x0040, IP_ACTIVE_LOW, IPT_SERVICE1 ) // "Calibrate" | |
| 650 | 650 | PORT_BIT( 0x0080, IP_ACTIVE_LOW, IPT_UNKNOWN ) |
| 651 | 651 | PORT_BIT( 0x0100, IP_ACTIVE_LOW, IPT_UNKNOWN ) |
| 652 | 652 | PORT_BIT( 0x0200, IP_ACTIVE_LOW, IPT_UNKNOWN ) |
| 653 | 653 | PORT_BIT( 0x0400, IP_ACTIVE_LOW, IPT_UNKNOWN ) |
| 654 | 654 | PORT_BIT( 0x0800, IP_ACTIVE_HIGH, IPT_SPECIAL ) |
| 655 | PORT_BIT( 0x1000, IP_ACTIVE_LOW, IPT_COIN1 ) PORT_IMPULSE(2) // e. coin 1 | |
| 656 | PORT_BIT( 0x2000, IP_ACTIVE_LOW, IPT_UNKNOWN ) // e. coin 2 | |
| 657 | PORT_BIT( 0x4000, IP_ACTIVE_LOW, IPT_UNKNOWN ) // e. coin 3 | |
| 658 | PORT_BIT( 0x8000, IP_ACTIVE_LOW, IPT_UNKNOWN ) // e. coin 4 | |
| 655 | PORT_BIT( 0x1000, IP_ACTIVE_LOW, IPT_COIN1 ) // "E. Coin 1" (ECA?) tmaster defaults to e. coin, | |
| 656 | PORT_BIT( 0x2000, IP_ACTIVE_LOW, IPT_COIN2 ) // "E. Coin 2" (ECA?) rather than m. coin | |
| 657 | PORT_BIT( 0x4000, IP_ACTIVE_LOW, IPT_COIN3 ) // "E. Coin 3" (ECA?) so they're coin1-coin4 | |
| 658 | PORT_BIT( 0x8000, IP_ACTIVE_LOW, IPT_COIN4 ) // "E. Coin 4" (ECA?) | |
| 659 | 659 | INPUT_PORTS_END |
| 660 | 660 | |
| 661 | 661 | static INPUT_PORTS_START( tmaster ) |
| 662 | 662 | PORT_INCLUDE(microtouch) |
| 663 | 663 | |
| 664 | 664 | PORT_START_TAG("COIN") // IN3 |
| 665 | PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_COIN1 ) PORT_IMPULSE(2) // m. coin 1 (coin optics?) | |
| 666 | PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_UNKNOWN ) // m. coin 2 (coin optics?) | |
| 667 | PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_UNKNOWN ) // dbv input (coin optics?) | |
| 665 | PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_COIN1 ) // "M. Coin 1 Input" | |
| 666 | PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_COIN2 ) // "M. Coin 2 Input" | |
| 667 | PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_BILL1 ) PORT_IMPULSE(2) // "DBV Input" | |
| 668 | 668 | PORT_BIT( 0x0008, IP_ACTIVE_LOW, IPT_UNKNOWN ) |
| 669 | PORT_BIT( 0x0010, IP_ACTIVE_LOW, IPT_ | |
| 669 | PORT_BIT( 0x0010, IP_ACTIVE_LOW, IPT_UNKNOWN | |
| 670 | 670 | PORT_SERVICE_NO_TOGGLE( 0x0020, IP_ACTIVE_LOW ) |
| 671 | PORT_BIT( 0x0040, IP_ACTIVE_LOW, IPT_SERVICE1 ) // | |
| 671 | PORT_BIT( 0x0040, IP_ACTIVE_LOW, IPT_SERVICE1 ) // "Calibrate" | |
| 672 | 672 | PORT_BIT( 0x0080, IP_ACTIVE_LOW, IPT_UNKNOWN ) |
| 673 | 673 | PORT_BIT( 0x0100, IP_ACTIVE_LOW, IPT_UNKNOWN ) |
| 674 | 674 | PORT_BIT( 0x0200, IP_ACTIVE_LOW, IPT_UNKNOWN ) |
| 675 | 675 | PORT_BIT( 0x0400, IP_ACTIVE_LOW, IPT_UNKNOWN ) |
| 676 | 676 | PORT_BIT( 0x0800, IP_ACTIVE_HIGH, IPT_SPECIAL ) |
| 677 | PORT_BIT( 0x1000, IP_ACTIVE_LOW, IPT_UNKNOWN ) // e. coin 1 | |
| 678 | PORT_BIT( 0x2000, IP_ACTIVE_LOW, IPT_UNKNOWN ) // e. coin 2 | |
| 679 | PORT_BIT( 0x4000, IP_ACTIVE_LOW, IPT_UNKNOWN ) // e. coin 3 | |
| 680 | PORT_BIT( 0x8000, IP_ACTIVE_LOW, IPT_UNKNOWN ) // e. coin 4 | |
| 677 | PORT_BIT( 0x1000, IP_ACTIVE_LOW, IPT_COIN3 ) // "E. Coin 1" (ECA mech) The rest of the tm games | |
| 678 | PORT_BIT( 0x2000, IP_ACTIVE_LOW, IPT_COIN4 ) // "E. Coin 2" (ECA mech) Default to m. coin | |
| 679 | PORT_BIT( 0x4000, IP_ACTIVE_LOW, IPT_COIN5 ) // "E. Coin 3" (ECA mech) So these are coin3-coin6 | |
| 680 | PORT_BIT( 0x8000, IP_ACTIVE_LOW, IPT_COIN6 ) // "E. Coin 4" (ECA mech) | |
| 681 | 681 | INPUT_PORTS_END |
| 682 | 682 | |
| 683 | 683 | static INPUT_PORTS_START( galgames ) |
| r2724 | r2725 | |
|---|---|---|
| 505 | 505 | |
| 506 | 506 | READ16_HANDLER( scudhamm_motor_status_r ) |
| 507 | 507 | { |
| 508 | // return 1 << (mame_rand( | |
| 508 | // return 1 << (mame_rand(machine)&1); // Motor Status | |
| 509 | 509 | return scudhamm_motor_command; // Motor Status |
| 510 | 510 | } |
| 511 | 511 |
| r2724 | r2725 | |
|---|---|---|
| 95 | 95 | coin_counter_w(0, 1); |
| 96 | 96 | coin_counter_w(0, 0); |
| 97 | 97 | |
| 98 | cpunum_set_input_line(machine, 0, INPUT_LINE_RESET, PULSE_LINE); | |
| 98 | cpunum_set_input_line(field->port->machine, 0, INPUT_LINE_RESET, PULSE_LINE); | |
| 99 | 99 | |
| 100 | 100 | /* simulate the coin switch being closed for a while */ |
| 101 | timer_set(double_to_attotime(4 * attotime_to_double(video_screen_get_frame_period(machine->primary_screen))), NULL, 0, clear_coin_status); | |
| 101 | timer_set(double_to_attotime(4 * attotime_to_double(video_screen_get_frame_period(field->port->machine->primary_screen))), NULL, 0, clear_coin_status); | |
| 102 | 102 | } |
| 103 | 103 | } |
| 104 | 104 | |
| r2724 | r2725 | |
| 142 | 142 | |
| 143 | 143 | static CUSTOM_INPUT( vicdual_get_64v ) |
| 144 | 144 | { |
| 145 | return (get_vcounter(machine) >> 6) & 0x01; | |
| 145 | return (get_vcounter(field->port->machine) >> 6) & 0x01; | |
| 146 | 146 | } |
| 147 | 147 | |
| 148 | 148 | |
| 149 | 149 | static CUSTOM_INPUT( vicdual_get_vblank_comp ) |
| 150 | 150 | { |
| 151 | return (get_vcounter(machine) < VICDUAL_VBSTART); | |
| 151 | return (get_vcounter(field->port->machine) < VICDUAL_VBSTART); | |
| 152 | 152 | } |
| 153 | 153 | |
| 154 | 154 | |
| 155 | 155 | static CUSTOM_INPUT( vicdual_get_composite_blank_comp ) |
| 156 | 156 | { |
| 157 | return (vicdual_get_vblank_comp( | |
| 157 | return (vicdual_get_vblank_comp(f | |
| 158 | 158 | } |
| 159 | 159 | |
| 160 | 160 | |
| r2724 | r2725 | |
| 2023 | 2023 | PORT_DIPNAME( 0x04, 0x04, DEF_STR( Lives ) ) |
| 2024 | 2024 | PORT_DIPSETTING( 0x04, "3" ) |
| 2025 | 2025 | PORT_DIPSETTING( 0x00, "4" ) |
| 2026 | PORT_ | |
| 2026 | PORT_DIPNAME( | |
| 2027 | 2027 | PORT_DIPSETTING( 0x08, DEF_STR( Off ) ) |
| 2028 | 2028 | PORT_DIPSETTING( 0x00, DEF_STR( On ) ) |
| 2029 | 2029 | PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_4WAY |
| r2724 | r2725 | |
|---|---|---|
| 417 | 417 | ***************************************************************************/ |
| 418 | 418 | |
| 419 | 419 | #include "driver.h" |
| 420 | #include "deprecat.h" | |
| 421 | 420 | #include "cpu/s2650/s2650.h" |
| 422 | 421 | #include "machine/atari_vg.h" |
| 423 | 422 | #include "centiped.h" |
| r2724 | r2725 | |
| 621 | 620 | |
| 622 | 621 | static READ8_HANDLER( caterplr_rand_r ) |
| 623 | 622 | { |
| 624 | return mame_rand( | |
| 623 | return mame_rand(machine) % 0xff; | |
| 625 | 624 | } |
| 626 | 625 | |
| 627 | 626 |
| r2724 | r2725 | |
|---|---|---|
| 914 | 914 | **************************************************************/ |
| 915 | 915 | |
| 916 | 916 | /* handler called by the YM2610 emulator when the internal timers cause an IRQ */ |
| 917 | static void irqhandler(int irq) // assumes Z80 sandwiched between 68Ks | |
| 917 | static void irqhandler(running_machine *machine, int irq) // assumes Z80 sandwiched between 68Ks | |
| 918 | 918 | { |
| 919 | cpunum_set_input_line( | |
| 919 | cpunum_set_input_line(machine, 1,0,irq ? ASSERT_LINE : CLEAR_LINE); | |
| 920 | 920 | } |
| 921 | 921 | |
| 922 | 922 | static const struct YM2610interface ym2610_interface = |
| r2724 | r2725 | |
|---|---|---|
| 313 | 313 | #define WELLTRIS_4P_HACK 0 |
| 314 | 314 | |
| 315 | 315 | #include "driver.h" |
| 316 | #include "deprecat.h" | |
| 317 | 316 | #include "sound/2610intf.h" |
| 318 | 317 | |
| 319 | 318 | UINT16 *welltris_spriteram; |
| r2724 | r2725 | |
| 688 | 687 | |
| 689 | 688 | |
| 690 | 689 | |
| 691 | static void irqhandler(int irq) | |
| 690 | static void irqhandler(running_machine *machine, int irq) | |
| 692 | 691 | { |
| 693 | cpunum_set_input_line( | |
| 692 | cpunum_set_input_line(machine, 1, 0, irq ? ASSERT_LINE : CLEAR_LINE); | |
| 694 | 693 | } |
| 695 | 694 | |
| 696 | 695 | static const struct YM2610interface ym2610_interface = |
| r2724 | r2725 | |
|---|---|---|
| 355 | 355 | ROM_LOAD( "u210.bin", 0x00000, 0x40000, CRC(16fbe06b) SHA1(4e40e62341dc886fcabdb07f64217dc086f43c67) ) |
| 356 | 356 | |
| 357 | 357 | ROM_REGION( 0x100000, REGION_GFX1, 0 ) |
| 358 | ROM_LOAD( "u421.bin", 0x00000, 0x80000, CRC(42445132) SHA1(f29d09d040644c8ef12a1cfdfc0d066e8ed9b82d) ) | |
| 358 | ROM_LOAD( "u421.bin", 0x00000, 0x80000, CRC(42445132) SHA1(f29d09d040644c8ef12a1cfdfc0d066e8ed9b82d) ) /* Nude & semi-nude girls, both real pictures & hand drawn */ | |
| 359 | 359 | ROM_LOAD( "u420.bin", 0x80000, 0x80000, CRC(de1f0e2f) SHA1(3f46d19af48392794838a4b54f8c45b809c67d49) ) |
| 360 | 360 | |
| 361 | 361 | ROM_REGION( 0x40000, REGION_GFX2, 0 ) /* BG Tiles */ |
| r2724 | r2725 | |
| 363 | 363 | ROM_LOAD( "u511.bin", 0x20000, 0x20000, CRC(1411451b) SHA1(941d5f311f727e3a8d41ecbbe35b687d48cc2cef) ) |
| 364 | 364 | ROM_END |
| 365 | 365 | |
| 366 | ROM_START( mspuzzlg ) /* This version is a clone of Gumbo... NOT the other Miss Puzzle sets */ | |
| 367 | ROM_REGION( 0x80000, REGION_CPU1, 0 ) /* 68000 Code */ | |
| 368 | ROM_LOAD16_BYTE( "u1", 0x00001, 0x20000, CRC(95218ff1) SHA1(9617d979d026872dbe68eaae21c3ab1f5f9f4bfd) ) /* Korean bootleg / clone / hack??? */ | |
| 369 | ROM_LOAD16_BYTE( "u2", 0x00000, 0x20000, CRC(7ea7d96c) SHA1(17b9afb3214a07b1af5913f1926c7aeac27ea0e8) ) | |
| 370 | ||
| 371 | ROM_REGION( 0x040000, REGION_SOUND1, 0 ) /* Samples */ | |
| 372 | ROM_LOAD( "u210.bin", 0x00000, 0x40000, CRC(16fbe06b) SHA1(4e40e62341dc886fcabdb07f64217dc086f43c67) ) | |
| 373 | ||
| 374 | ROM_REGION( 0x200000, REGION_GFX1, 0 ) | |
| 375 | ROM_LOAD( "u421", 0x100000, 0x80000, CRC(afa06a93) SHA1(5c77b7aafd07d19a1eedf22858a00766a3e37389) ) /* Non-nude graphics, hand drawn girls & animals */ | |
| 376 | ROM_LOAD( "u420", 0x000000, 0x80000, CRC(2b387153) SHA1(c36f93d4f3a7ea8af58babeb33250d726067a35d) ) | |
| 377 | ||
| 378 | ROM_REGION( 0x40000, REGION_GFX2, 0 ) /* BG Tiles */ | |
| 379 | ROM_LOAD( "u512.bin", 0x00000, 0x20000, CRC(97741798) SHA1(3603e14511817da19f6819d5612728d333695e99) ) | |
| 380 | ROM_LOAD( "u511.bin", 0x20000, 0x20000, CRC(1411451b) SHA1(941d5f311f727e3a8d41ecbbe35b687d48cc2cef) ) | |
| 381 | ROM_END | |
| 382 | ||
| 366 | 383 | ROM_START( msbingo ) |
| 367 | 384 | ROM_REGION( 0x80000, REGION_CPU1, 0 ) /* 68000 Code */ |
| 368 | 385 | ROM_LOAD16_BYTE( "u1.bin", 0x00001, 0x20000, CRC(6eeb6d89) SHA1(d3e8870a2e95a1ee1c0ce80995c902a97b25a85c) ) |
| r2724 | r2725 | |
| 456 | 473 | ROM_END |
| 457 | 474 | |
| 458 | 475 | GAME( 1994, gumbo, 0, gumbo, gumbo, 0, ROT0, "Min Corp.", "Gumbo", 0 ) |
| 476 | GAME( 1994, mspuzzlg, gumbo, gumbo, gumbo, 0, ROT0, "Min Corp.", "Miss Puzzle (Clone of Gumbo)", 0 ) | |
| 459 | 477 | GAME( 1994, msbingo, 0, mspuzzle, msbingo, 0, ROT0, "Min Corp.", "Miss Bingo", 0 ) |
| 460 | 478 | GAME( 1994, mspuzzle, 0, mspuzzle, mspuzzle, 0, ROT90, "Min Corp.", "Miss Puzzle", 0 ) |
| 461 | 479 | GAME( 1994, mspuzzln, mspuzzle, mspuzzle, mspuzzle, 0, ROT90, "Min Corp.", "Miss Puzzle (Nudes)", GAME_NOT_WORKING ) |
| r2724 | r2725 | |
|---|---|---|
| 39 | 39 | ***************************************************************************/ |
| 40 | 40 | |
| 41 | 41 | #include "driver.h" |
| 42 | #include "deprecat.h" | |
| 43 | 42 | #include "cpu/m6502/m6502.h" |
| 44 | 43 | #include "cpu/h6280/h6280.h" |
| 45 | 44 | #include "dec0.h" |
| r2724 | r2725 | |
| 903 | 902 | |
| 904 | 903 | /******************************************************************************/ |
| 905 | 904 | |
| 906 | static void sound_irq(int linestate) | |
| 905 | static void sound_irq(running_machine *machine, int linestate) | |
| 907 | 906 | { |
| 908 | cpunum_set_input_line( | |
| 907 | cpunum_set_input_line(machine, 1,0,linestate); /* IRQ */ | |
| 909 | 908 | } |
| 910 | 909 | |
| 911 | static void sound_irq2(int linestate) | |
| 910 | static void sound_irq2(running_machine *machine, int linestate) | |
| 912 | 911 | { |
| 913 | cpunum_set_input_line( | |
| 912 | cpunum_set_input_line(machine, 1,1,linestate); /* IRQ2 */ | |
| 914 | 913 | } |
| 915 | 914 | |
| 916 | 915 | static const struct YM3812interface ym3812_interface = |
| r2724 | r2725 | |
|---|---|---|
| 199 | 199 | static UINT16 *ssv_mainram; |
| 200 | 200 | |
| 201 | 201 | /* Update the IRQ state based on all possible causes */ |
| 202 | static void update_irq_state( | |
| 202 | static void update_irq_state(running_machine *machine) | |
| 203 | 203 | { |
| 204 | cpunum_set_input_line( | |
| 204 | cpunum_set_input_line(machine, 0, 0, (requested_int & irq_enable)? ASSERT_LINE : CLEAR_LINE); | |
| 205 | 205 | } |
| 206 | 206 | |
| 207 | 207 | static IRQ_CALLBACK(ssv_irq_callback) |
| r2724 | r2725 | |
| 223 | 223 | int level = ((offset * 2) & 0x70) >> 4; |
| 224 | 224 | requested_int &= ~(1 << level); |
| 225 | 225 | |
| 226 | update_irq_state(); | |
| 226 | update_irq_state(machine); | |
| 227 | 227 | } |
| 228 | 228 | |
| 229 | 229 | /* |
| r2724 | r2725 | |
| 258 | 258 | if(interrupt_ultrax) |
| 259 | 259 | { |
| 260 | 260 | requested_int |= 1 << 1; // needed by ultrax to coin up, breaks cairblad |
| 261 | update_irq_state(); | |
| 261 | update_irq_state(machine); | |
| 262 | 262 | } |
| 263 | 263 | } |
| 264 | 264 | else |
| 265 | 265 | { |
| 266 | 266 | requested_int |= 1 << 3; // vblank |
| 267 | update_irq_state(); | |
| 267 | update_irq_state(machine); | |
| 268 | 268 | } |
| 269 | 269 | } |
| 270 | 270 | |
| r2724 | r2725 | |
| 273 | 273 | if (cpu_getiloops()) |
| 274 | 274 | { |
| 275 | 275 | requested_int |= 1 << 6; // reads lightgun (4 times for 4 axis) |
| 276 | update_irq_state(); | |
| 276 | update_irq_state(machine); | |
| 277 | 277 | } |
| 278 | 278 | else |
| 279 | 279 | { |
| 280 | 280 | requested_int |= 1 << 3; // vblank |
| 281 | update_irq_state(); | |
| 281 | update_irq_state(machine); | |
| 282 | 282 | } |
| 283 | 283 | } |
| 284 | 284 | |
| r2724 | r2725 | |
| 461 | 461 | |
| 462 | 462 | static READ16_HANDLER( drifto94_rand_r ) |
| 463 | 463 | { |
| 464 | return mame_rand( | |
| 464 | return mame_rand(machine) & 0xffff; | |
| 465 | 465 | } |
| 466 | 466 | |
| 467 | 467 | static ADDRESS_MAP_START( drifto94_readmem, ADDRESS_SPACE_PROGRAM, 16 ) |
| r2724 | r2725 | |
|---|---|---|
| 216 | 216 | ****************************************************************************/ |
| 217 | 217 | |
| 218 | 218 | #include "driver.h" |
| 219 | #include "deprecat.h" | |
| 220 | 219 | #include "taitoipt.h" |
| 221 | 220 | #include "audio/taitosnd.h" |
| 222 | 221 | #include "video/taitoic.h" |
| r2724 | r2725 | |
| 439 | 438 | TAITO_COINAGE_WORLD_LOC(SWA) |
| 440 | 439 | |
| 441 | 440 | /* 0xa00202 -> 0x0c0d7e (-$7283,A5) */ |
| 442 | PORT_START_TAG("DSW | |
| 441 | PORT_START_TAG("DSWB") | |
| 443 | 442 | TAITO_DIFFICULTY_LOC(SWA) |
| 444 | 443 | PORT_DIPUNUSED_DIPLOC( 0x04, IP_ACTIVE_LOW, "SWB:3" ) |
| 445 | 444 | PORT_DIPUNUSED_DIPLOC( 0x08, IP_ACTIVE_LOW, "SWB:4" ) |
| r2724 | r2725 | |
| 575 | 574 | ************************************************************/ |
| 576 | 575 | |
| 577 | 576 | /* Handler called by the YM2610 emulator when the internal timers cause an IRQ */ |
| 578 | static void irqhandler(int irq) | |
| 577 | static void irqhandler(running_machine *machine, int irq) | |
| 579 | 578 | { |
| 580 | cpunum_set_input_line( | |
| 579 | cpunum_set_input_line(machine, 1,0,irq ? ASSERT_LINE : CLEAR_LINE); | |
| 581 | 580 | } |
| 582 | 581 | |
| 583 | 582 | static const struct YM2610interface airsys_ym2610_interface = |
| r2724 | r2725 | |
|---|---|---|
| 269 | 269 | */ |
| 270 | 270 | |
| 271 | 271 | |
| 272 | static void update_mpu68_interrupts( | |
| 272 | static void update_mpu68_interrupts(running_machine *machine) | |
| 273 | 273 | { |
| 274 | 274 | int newstate = 0; |
| 275 | 275 | |
| r2724 | r2725 | |
| 284 | 284 | if (newstate) |
| 285 | 285 | { |
| 286 | 286 | LOGSTUFF(("68k IRQ, %x\n", newstate)); |
| 287 | cpunum_set_input_line( | |
| 287 | cpunum_set_input_line(machine, 1, newstate, ASSERT_LINE); | |
| 288 | 288 | } |
| 289 | 289 | else |
| 290 | 290 | { |
| 291 | 291 | LOGSTUFF(("68k IRQ Clear, %x\n", newstate)); |
| 292 | cpunum_set_input_line( | |
| 292 | cpunum_set_input_line(machine, 1, 7, CLEAR_LINE); | |
| 293 | 293 | } |
| 294 | 294 | } |
| 295 | 295 | |
| r2724 | r2725 | |
| 307 | 307 | { |
| 308 | 308 | m6809_acia_cts = state; |
| 309 | 309 | m6850_irq_state = state; |
| 310 | update_mpu68_interrupts(); | |
| 310 | update_mpu68_interrupts(Machine); | |
| 311 | 311 | } |
| 312 | 312 | |
| 313 | 313 | |
| r2724 | r2725 | |
| 337 | 337 | }; |
| 338 | 338 | |
| 339 | 339 | |
| 340 | static void cpu1_ptm_irq(int state) | |
| 340 | static void cpu1_ptm_irq(running_machine *machine, int state) | |
| 341 | 341 | { |
| 342 | 342 | m6840_irq_state = state; |
| 343 | update_mpu68_interrupts(); | |
| 343 | update_mpu68_interrupts(machine); | |
| 344 | 344 | } |
| 345 | 345 | |
| 346 | 346 | |
| r2724 | r2725 | |
| 794 | 794 | { |
| 795 | 795 | scn2674_irq_state = 1; |
| 796 | 796 | } |
| 797 | update_mpu68_interrupts(); | |
| 797 | update_mpu68_interrupts(Machine); | |
| 798 | 798 | } |
| 799 | 799 | if ((data&0xe0)==0x80) |
| 800 | 800 | { |
| r2724 | r2725 | |
| 820 | 820 | scn2674_irq_state = 1; |
| 821 | 821 | } |
| 822 | 822 | } |
| 823 | update_mpu68_interrupts(); | |
| 823 | update_mpu68_interrupts(Machine); | |
| 824 | 824 | |
| 825 | 825 | } |
| 826 | 826 | |
| r2724 | r2725 | |
| 845 | 845 | scn2674_irq_state = 1; |
| 846 | 846 | } |
| 847 | 847 | } |
| 848 | update_mpu68_interrupts(); | |
| 848 | update_mpu68_interrupts(Machine); | |
| 849 | 849 | } |
| 850 | 850 | |
| 851 | 851 | /* Delayed Commands */ |
| r2724 | r2725 | |
| 1353 | 1353 | { |
| 1354 | 1354 | LOGSTUFF(("vblank irq\n")); |
| 1355 | 1355 | scn2674_irq_state = 1; |
| 1356 | update_mpu68_interrupts(); | |
| 1356 | update_mpu68_interrupts(machine); | |
| 1357 | 1357 | |
| 1358 | 1358 | scn2674_irq_register |= 0x10; |
| 1359 | 1359 | } |
| r2724 | r2725 | |
|---|---|---|
| 50 | 50 | |
| 51 | 51 | |
| 52 | 52 | #include "driver.h" |
| 53 | #include "deprecat.h" | |
| 54 | 53 | #include "sound/2151intf.h" |
| 55 | 54 | #include "sound/okim6295.h" |
| 56 | 55 | |
| r2724 | r2725 | |
| 335 | 334 | GFXDECODE_ENTRY( REGION_GFX4, 0, char5bpplayout, 0x400, 32 ) |
| 336 | 335 | GFXDECODE_END |
| 337 | 336 | |
| 338 | static void irq_handler(int irq) | |
| 337 | static void irq_handler(running_machine *machine, int irq) | |
| 339 | 338 | { |
| 340 | cpunum_set_input_line( | |
| 339 | cpunum_set_input_line(machine, 1, 0 , irq ? ASSERT_LINE : CLEAR_LINE ); | |
| 341 | 340 | } |
| 342 | 341 | |
| 343 | 342 | static const struct YM2151interface ym2151_interface = |
| r2724 | r2725 | |
|---|---|---|
| 151 | 151 | |
| 152 | 152 | |
| 153 | 153 | /* Update the IRQ state based on all possible causes */ |
| 154 | static void update_irq_state( | |
| 154 | static void update_irq_state(running_machine *machine) | |
| 155 | 155 | { |
| 156 | 156 | /* Get the pending IRQs (only the enabled ones, e.g. where |
| 157 | 157 | irq_enable is *0*) */ |
| 158 | UINT16 irq = metro_irq_cause_r( | |
| 158 | UINT16 irq = metro_irq_cause_r(machine,0,0xffff) & ~*metro_irq_enable; | |
| 159 | 159 | |
| 160 | 160 | if (irq_line == -1) /* mouja, gakusai, gakusai2, dokyusei, dokyusp */ |
| 161 | 161 | { |
| r2724 | r2725 | |
| 167 | 167 | { |
| 168 | 168 | if (irq & (1 << i)) |
| 169 | 169 | { |
| 170 | cpunum_set_input_line( | |
| 170 | cpunum_set_input_line(machine, 0, metro_irq_levels[i]&7, ASSERT_LINE); | |
| 171 | 171 | return; |
| 172 | 172 | } |
| 173 | 173 | i++; |
| 174 | 174 | } |
| 175 | cpunum_set_input_line( | |
| 175 | cpunum_set_input_line(machine, 0, 0, ASSERT_LINE); | |
| 176 | 176 | } |
| 177 | 177 | else |
| 178 | 178 | { |
| r2724 | r2725 | |
| 181 | 181 | source by peeking a register (metro_irq_cause_r) */ |
| 182 | 182 | |
| 183 | 183 | int state = (irq ? ASSERT_LINE : CLEAR_LINE); |
| 184 | cpunum_set_input_line( | |
| 184 | cpunum_set_input_line(machine, 0, irq_line, state); | |
| 185 | 185 | } |
| 186 | 186 | } |
| 187 | 187 | |
| r2724 | r2725 | |
| 218 | 218 | if (data & 0x80) requested_int[7] = 0; |
| 219 | 219 | } |
| 220 | 220 | |
| 221 | update_irq_state(); | |
| 221 | update_irq_state(machine); | |
| 222 | 222 | } |
| 223 | 223 | |
| 224 | 224 | |
| r2724 | r2725 | |
| 228 | 228 | { |
| 229 | 229 | case 0: |
| 230 | 230 | requested_int[0] = 1; |
| 231 | update_irq_state(); | |
| 231 | update_irq_state(machine); | |
| 232 | 232 | break; |
| 233 | 233 | |
| 234 | 234 | default: |
| 235 | 235 | requested_int[4] = 1; |
| 236 | update_irq_state(); | |
| 236 | update_irq_state(machine); | |
| 237 | 237 | break; |
| 238 | 238 | } |
| 239 | 239 | } |
| r2724 | r2725 | |
| 243 | 243 | { |
| 244 | 244 | requested_int[0] = 1; // set scroll regs if a flag is set |
| 245 | 245 | requested_int[4] = 1; // clear that flag |
| 246 | update_irq_state(); | |
| 246 | update_irq_state(machine); | |
| 247 | 247 | } |
| 248 | 248 | |
| 249 | 249 | |
| r2724 | r2725 | |
| 262 | 262 | requested_int[5] = 1; // write the scroll registers |
| 263 | 263 | /* the duration is a guess */ |
| 264 | 264 | timer_set(ATTOTIME_IN_USEC(2500), NULL, 0, vblank_end_callback); |
| 265 | update_irq_state(); | |
| 265 | update_irq_state(machine); | |
| 266 | 266 | break; |
| 267 | 267 | |
| 268 | 268 | default: |
| 269 | 269 | requested_int[4] = 1; |
| 270 | update_irq_state(); | |
| 270 | update_irq_state(machine); | |
| 271 | 271 | break; |
| 272 | 272 | } |
| 273 | 273 | } |
| r2724 | r2725 | |
| 277 | 277 | static TIMER_CALLBACK( mouja_irq_callback ) |
| 278 | 278 | { |
| 279 | 279 | requested_int[0] = 1; |
| 280 | update_irq_state(); | |
| 280 | update_irq_state(machine); | |
| 281 | 281 | } |
| 282 | 282 | |
| 283 | 283 | static WRITE16_HANDLER( mouja_irq_timer_ctrl_w ) |
| r2724 | r2725 | |
| 289 | 289 | static INTERRUPT_GEN( mouja_interrupt ) |
| 290 | 290 | { |
| 291 | 291 | requested_int[1] = 1; |
| 292 | update_irq_state(); | |
| 292 | update_irq_state(machine); | |
| 293 | 293 | } |
| 294 | 294 | |
| 295 | 295 | |
| r2724 | r2725 | |
| 299 | 299 | { |
| 300 | 300 | case 0: |
| 301 | 301 | requested_int[1] = 1; |
| 302 | update_irq_state(); | |
| 302 | update_irq_state(machine); | |
| 303 | 303 | break; |
| 304 | 304 | } |
| 305 | 305 | } |
| r2724 | r2725 | |
| 310 | 310 | { |
| 311 | 311 | case 0: |
| 312 | 312 | requested_int[1] = 1; |
| 313 | update_irq_state(); | |
| 313 | update_irq_state(machine); | |
| 314 | 314 | break; |
| 315 | 315 | case 1: // needed? |
| 316 | 316 | requested_int[5] = 1; |
| 317 | update_irq_state(); | |
| 317 | update_irq_state(machine); | |
| 318 | 318 | break; |
| 319 | 319 | } |
| 320 | 320 | } |
| 321 | 321 | |
| 322 | static void ymf278b_interrupt(int active) | |
| 322 | static void ymf278b_interrupt(running_machine *machine, int active) | |
| 323 | 323 | { |
| 324 | cpunum_set_input_line( | |
| 324 | cpunum_set_input_line(machine, 0, 2, active); | |
| 325 | 325 | } |
| 326 | 326 | |
| 327 | 327 | /*************************************************************************** |
| r2724 | r2725 | |
| 514 | 514 | portb = data; |
| 515 | 515 | } |
| 516 | 516 | |
| 517 | static void metro_sound_irq_handler(int state) | |
| 517 | static void metro_sound_irq_handler(running_machine *machine, int state) | |
| 518 | 518 | { |
| 519 | cpunum_set_input_line( | |
| 519 | cpunum_set_input_line(machine, 1, UPD7810_INTF2, state ? ASSERT_LINE : CLEAR_LINE); | |
| 520 | 520 | } |
| 521 | 521 | |
| 522 | 522 | static const struct YM2151interface ym2151_interface = |
| r2724 | r2725 | |
| 679 | 679 | static TIMER_CALLBACK( metro_blit_done ) |
| 680 | 680 | { |
| 681 | 681 | requested_int[blitter_bit] = 1; |
| 682 | update_irq_state(); | |
| 682 | update_irq_state(machine); | |
| 683 | 683 | } |
| 684 | 684 | |
| 685 | 685 | INLINE int blt_read(const UINT8 *ROM, const int offs) |
| r2724 | r2725 | |
| 1939 | 1939 | memory_set_bankptr(1, &RAM[bankaddress]); |
| 1940 | 1940 | } |
| 1941 | 1941 | |
| 1942 | static void blzntrnd_irqhandler(int irq) | |
| 1942 | static void blzntrnd_irqhandler(running_machine *machine, int irq) | |
| 1943 | 1943 | { |
| 1944 | cpunum_set_input_line( | |
| 1944 | cpunum_set_input_line(machine, 1, 0, irq ? ASSERT_LINE : CLEAR_LINE); | |
| 1945 | 1945 | } |
| 1946 | 1946 | |
| 1947 | 1947 | static const struct YM2610interface blzntrnd_ym2610_interface = |
| r2724 | r2725 | |
| 4653 | 4653 | { |
| 4654 | 4654 | case 0: |
| 4655 | 4655 | requested_int[1] = 1; |
| 4656 | update_irq_state(); | |
| 4656 | update_irq_state(machine); | |
| 4657 | 4657 | break; |
| 4658 | 4658 | |
| 4659 | 4659 | case 1: |
| 4660 | 4660 | requested_int[3] = 1; |
| 4661 | update_irq_state(); | |
| 4661 | update_irq_state(machine); | |
| 4662 | 4662 | break; |
| 4663 | 4663 | |
| 4664 | 4664 | case 2: |
| 4665 | 4665 | requested_int[5] = 1; |
| 4666 | update_irq_state(); | |
| 4666 | update_irq_state(machine); | |
| 4667 | 4667 | break; |
| 4668 | 4668 | |
| 4669 | 4669 | case 3: |
| 4670 | 4670 | requested_int[2] = 1; |
| 4671 | update_irq_state(); | |
| 4671 | update_irq_state(machine); | |
| 4672 | 4672 | break; |
| 4673 | 4673 | |
| 4674 | 4674 | default: |
| r2724 | r2725 | |
| 5458 | 5458 | ROM_LOAD( "tr_jb11", 0x000000, 0x020000, CRC(83786a09) SHA1(910cf0ccf4493f2a80062149f6364dbb6a1c2a5d) ) |
| 5459 | 5459 | ROM_END |
| 5460 | 5460 | |
| 5461 | ROM_START( lastfork ) | |
| 5462 | ROM_REGION( 0x040000, REGION_CPU1, 0 ) /* 68000 Code */ | |
| 5463 | ROM_LOAD16_BYTE( "7f-9", 0x000000, 0x020000, CRC(d2894c1f) SHA1(4f4ab6d8ce69999cd7c4a9ddabec8d1e8fefc6fc) ) | |
| 5464 | ROM_LOAD16_BYTE( "8f-10", 0x000001, 0x020000, CRC(9696ea39) SHA1(27af0c6399cd7be40aa8a1c1b58e0db8408aff11) ) | |
| 5465 | ||
| 5466 | ROM_REGION( 0x02c000, REGION_CPU2, 0 ) /* NEC78C10 Code */ | |
| 5467 | ROM_LOAD( "tr_jb12", 0x000000, 0x004000, CRC(8a8f5fef) SHA1(530b4966ec058cd80a2fc5f9e961239ce59d0b89) ) // (c)1992 Imagetek (11xxxxxxxxxxxxxxx = 0xFF) | |
| 5468 | ROM_CONTINUE( 0x010000, 0x01c000 ) | |
| 5469 | ||
| 5470 | ROM_REGION( 0x200000, REGION_GFX1, 0 ) /* Gfx + Data (Addressable by CPU & Blitter) */ | |
| 5471 | ROMX_LOAD( "7i-2", 0x000000, 0x040000, CRC(d1fe8d7b) SHA1(88b1973ebb47b91a49f6b4f722c9cc33e5330694) , ROM_SKIP(7)) | |
| 5472 | ROMX_LOAD( "10i-4", 0x000001, 0x040000, CRC(058126d4) SHA1(985177556c8545e6a65a41083246b31509de7130) , ROM_SKIP(7)) | |
| 5473 | ROMX_LOAD( "13i-6", 0x000002, 0x040000, CRC(39a9dea2) SHA1(9f8067cff15be93771d42b3776ee7ca1b7c61798) , ROM_SKIP(7)) | |
| 5474 | ROMX_LOAD( "16i-8", 0x000003, 0x040000, CRC(4c050baa) SHA1(3e0b2029d7c0b6cd32b22f147663cd22975ce8c3) , ROM_SKIP(7)) | |
| 5475 | ROMX_LOAD( "5i-1", 0x000004, 0x040000, CRC(0d503f05) SHA1(0b1ce22630bb2326930f0f3b5710c6c191730c45) , ROM_SKIP(7)) | |
| 5476 | ROMX_LOAD( "8i-3", 0x000005, 0x040000, CRC(b6d4f753) SHA1(2864ad5fe4186e4e15bb7d5dafa6a9b8c803d7d0) , ROM_SKIP(7)) | |
| 5477 | ROMX_LOAD( "12i-5", 0x000006, 0x040000, CRC(ce69c805) SHA1(88debdbd8e73da54c1c25a1a60f27a05dac3f104) , ROM_SKIP(7)) | |
| 5478 | ROMX_LOAD( "14i-7", 0x000007, 0x040000, CRC(0cb38317) SHA1(6e18096f6616aa0d9c4f3a2394561ed3f636731e) , ROM_SKIP(7)) | |
| 5479 | ||
| 5480 | ROM_REGION( 0x020000, REGION_SOUND1, 0 ) /* Samples */ | |
| 5481 | ROM_LOAD( "tr_jb11", 0x000000, 0x020000, CRC(83786a09) SHA1(910cf0ccf4493f2a80062149f6364dbb6a1c2a5d) ) | |
| 5482 | ROM_END | |
| 5483 | ||
| 5461 | 5484 | /* German version on PCB VG460-(A) */ |
| 5462 | 5485 | |
| 5463 | 5486 | ROM_START( lastforg ) |
| r2724 | r2725 | |
| 5466 | 5489 | ROM_LOAD16_BYTE( "trma03.bin", 0x000001, 0x020000, CRC(b00fb126) SHA1(7dd4b7a2d1c5401fde2275ef76fac1ccc586a0bd) ) |
| 5467 | 5490 | |
| 5468 | 5491 | ROM_REGION( 0x02c000, REGION_CPU2, 0 ) /* NEC78C10 Code */ |
| 5469 | ROM_LOAD( "trma01.bin", 0x000000, 0x004000, CRC(8a8f5fef) SHA1(530b4966ec058cd80a2fc5f9e961239ce59d0b89) ) // 11xxxxxxxxxxxxxxx = 0xFF | |
| 5470 | ROM_CONTINUE( 0x010000, 0x01c000 ) | |
| 5492 | ROM_LOAD( "trma01.bin", 0x000000, 0x004000, CRC(8a8f5fef) SHA1(530b4966ec058cd80a2fc5f9e961239ce59d0b89) ) /* Same as parent set, but different label */ | |
| 5493 | ROM_CONTINUE( 0x010000, 0x01c000 ) | |
| 5471 | 5494 | |
| 5472 | 5495 | ROM_REGION( 0x200000, REGION_GFX1, 0 ) /* Gfx + Data (Addressable by CPU & Blitter) */ |
| 5473 | 5496 | ROMX_LOAD( "trma04.bin", 0x000000, 0x080000, CRC(5feafc6f) SHA1(eb50905eb0d25eb342e08d591907f79b5eadff43) , ROM_GROUPWORD | ROM_SKIP(6)) |
| r2724 | r2725 | |
| 5476 | 5499 | ROMX_LOAD( "trma06.bin", 0x000006, 0x080000, CRC(d366c04e) SHA1(e0a67688043cb45916860d32ff1076d9257e6ad9) , ROM_GROUPWORD | ROM_SKIP(6)) |
| 5477 | 5500 | |
| 5478 | 5501 | ROM_REGION( 0x020000, REGION_SOUND1, 0 ) /* Samples */ |
| 5479 | ROM_LOAD( "trma08.bin", 0x000000, 0x020000, CRC(83786a09) SHA1(910cf0ccf4493f2a80062149f6364dbb6a1c2a5d) ) | |
| 5502 | ROM_LOAD( "trma08.bin", 0x000000, 0x020000, CRC(83786a09) SHA1(910cf0ccf4493f2a80062149f6364dbb6a1c2a5d) ) /* Same as parent set, but different label */ | |
| 5480 | 5503 | ROM_END |
| 5481 | 5504 | |
| 5482 | 5505 | /*************************************************************************** |
| r2724 | r2725 | |
| 6140 | 6163 | GAME( 1994, dharmak, dharma, dharma, dharma, dharmak, ROT0, "Metro", "Dharma Doujou (Korea)", 0 ) |
| 6141 | 6164 | GAME( 1994, lastfort, 0, lastfort, lastfort, metro, ROT0, "Metro", "Last Fortress - Toride", 0 ) |
| 6142 | 6165 | GAME( 1994, lastfero, lastfort, lastfort, lastfero, metro, ROT0, "Metro", "Last Fortress - Toride (Erotic)", 0 ) |
| 6166 | GAME( 1994, lastfork, lastfort, lastfort, lastfero, metro, ROT0, "Metro", "Last Fortress - Toride (Korea)", 0 ) | |
| 6143 | 6167 | GAME( 1994, lastforg, lastfort, lastforg, ladykill, metro, ROT0, "Metro", "Last Fortress - Toride (German)", 0 ) |
| 6144 | 6168 | GAME( 1994, toride2g, 0, toride2g, toride2g, metro, ROT0, "Metro", "Toride II Adauchi Gaiden", GAME_IMPERFECT_GRAPHICS ) |
| 6145 | 6169 | GAME( 1994, torid2gg, toride2g, toride2g, toride2g, metro, ROT0, "Metro", "Toride II Adauchi Gaiden (German)", GAME_IMPERFECT_GRAPHICS ) |
| r2724 | r2725 | |
|---|---|---|
| 127 | 127 | |
| 128 | 128 | |
| 129 | 129 | #include "driver.h" |
| 130 | #include "deprecat.h" | |
| 131 | 130 | #include "cpu/z80/z80.h" |
| 132 | 131 | #include "machine/segacrpt.h" |
| 133 | 132 | #include "sound/2203intf.h" |
| r2724 | r2725 | |
| 533 | 532 | } |
| 534 | 533 | |
| 535 | 534 | |
| 536 | static void irqhandler(int irq) | |
| 535 | static void irqhandler(running_machine *machine, int irq) | |
| 537 | 536 | { |
| 538 | cpunum_set_input_line( | |
| 537 | cpunum_set_input_line(machine, 1,0,irq ? ASSERT_LINE : CLEAR_LINE); | |
| 539 | 538 | } |
| 540 | 539 | |
| 541 | 540 | static const struct YM2203interface ym2203_interface = |
| r2724 | r2725 | |
|---|---|---|
| 160 | 160 | PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_4WAY |
| 161 | 161 | PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_4WAY |
| 162 | 162 | PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_4WAY |
| 163 | PORT_ | |
| 163 | PORT_DIPNAME( 0x10, 0x10, | |
| 164 | 164 | PORT_DIPSETTING( 0x10, DEF_STR( Off ) ) |
| 165 | 165 | PORT_DIPSETTING( 0x00, DEF_STR( On ) ) |
| 166 | 166 | PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_COIN1 ) |
| r2724 | r2725 | |
|---|---|---|
| 35 | 35 | |
| 36 | 36 | |
| 37 | 37 | #include "driver.h" |
| 38 | #include "deprecat.h" | |
| 39 | 38 | #include "genesis.h" |
| 40 | 39 | |
| 41 | 40 | #define MASTER_CLOCK 53693100 |
| r2724 | r2725 | |
| 201 | 200 | |
| 202 | 201 | static READ16_HANDLER( vdp_fake_r ) |
| 203 | 202 | { |
| 204 | return mame_rand( | |
| 203 | return mame_rand(machine); | |
| 205 | 204 | } |
| 206 | 205 | |
| 207 | 206 | static DRIVER_INIT(genesis) |
| r2724 | r2725 | |
|---|---|---|
| 20 | 20 | */ |
| 21 | 21 | |
| 22 | 22 | #include "driver.h" |
| 23 | #include "deprecat.h" | |
| 24 | 23 | #include "video/tms9928a.h" |
| 25 | 24 | #include "sound/ay8910.h" |
| 26 | 25 | |
| r2724 | r2725 | |
| 128 | 127 | |
| 129 | 128 | static INTERRUPT_GEN( kingpin_video_interrupt ) |
| 130 | 129 | { |
| 131 | TMS9928A_interrupt(); | |
| 130 | TMS9928A_interrupt(machine); | |
| 132 | 131 | } |
| 133 | 132 | |
| 134 | static void vdp_interrupt (int state) | |
| 133 | static void vdp_interrupt (running_machine *machine, int state) | |
| 135 | 134 | { |
| 136 | cpunum_set_input_line( | |
| 135 | cpunum_set_input_line(machine, 0,0, HOLD_LINE); | |
| 137 | 136 | } |
| 138 | 137 | |
| 139 | 138 | static const TMS9928a_interface tms9928a_interface = |
| r2724 | r2725 | |
|---|---|---|
| 94 | 94 | ***************************************************************************/ |
| 95 | 95 | |
| 96 | 96 | #include "driver.h" |
| 97 | #include "deprecat.h" | |
| 98 | 97 | #include "taitoipt.h" |
| 99 | 98 | #include "video/taitoic.h" |
| 100 | 99 | #include "audio/taitosnd.h" |
| r2724 | r2725 | |
| 311 | 310 | MSM5205_reset_w(1, 1); |
| 312 | 311 | } |
| 313 | 312 | |
| 314 | static void opwolf_msm5205_vck(int chip) | |
| 313 | static void opwolf_msm5205_vck(running_machine *machine, int chip) | |
| 315 | 314 | { |
| 316 | 315 | static int adpcm_data[2] = { -1, -1 }; |
| 317 | 316 | |
| r2724 | r2725 | |
| 537 | 536 | |
| 538 | 537 | /* handler called by the YM2151 emulator when the internal timers cause an IRQ */ |
| 539 | 538 | |
| 540 | static void irq_handler(int irq) | |
| 539 | static void irq_handler(running_machine *machine, int irq) | |
| 541 | 540 | { |
| 542 | cpunum_set_input_line( | |
| 541 | cpunum_set_input_line(machine, 1,0,irq ? ASSERT_LINE : CLEAR_LINE); | |
| 543 | 542 | } |
| 544 | 543 | |
| 545 | 544 |
| r2724 | r2725 | |
|---|---|---|
| 9 | 9 | ***************************************************************************/ |
| 10 | 10 | |
| 11 | 11 | #include "driver.h" |
| 12 | #include "deprecat.h" | |
| 13 | 12 | #include "cpu/konami/konami.h" /* for the callback and the firq irq definition */ |
| 14 | 13 | #include "video/konamiic.h" |
| 15 | 14 | #include "sound/2151intf.h" |
| r2724 | r2725 | |
| 222 | 221 | |
| 223 | 222 | |
| 224 | 223 | |
| 225 | static void irqhandler(int linestate) | |
| 224 | static void irqhandler(running_machine *machine, int linestate) | |
| 226 | 225 | { |
| 227 | cpunum_set_input_line( | |
| 226 | cpunum_set_input_line(machine, 0,KONAMI_FIRQ_LINE,linestate); | |
| 228 | 227 | } |
| 229 | 228 | |
| 230 | 229 | static const struct YM2151interface ym2151_interface = |
| r2724 | r2725 | |
|---|---|---|
| 1018 | 1018 | Best Of Best |
| 1019 | 1019 | ***************************************************************************/ |
| 1020 | 1020 | |
| 1021 | static void bestbest_ym3526_irqhandler(int state) | |
| 1021 | static void bestbest_ym3526_irqhandler(running_machine *machine, int state) | |
| 1022 | 1022 | { |
| 1023 | cpunum_set_input_line( | |
| 1023 | cpunum_set_input_line(machine, 1, INPUT_LINE_IRQ0, state); | |
| 1024 | 1024 | } |
| 1025 | 1025 | |
| 1026 | 1026 | static const struct YM3526interface bestbest_ym3526_interface = |
| r2724 | r2725 | |
|---|---|---|
| 34 | 34 | ***************************************************************************/ |
| 35 | 35 | |
| 36 | 36 | #include "driver.h" |
| 37 | #include "deprecat.h" | |
| 38 | 37 | #include "machine/6821pia.h" |
| 39 | 38 | #include "machine/8255ppi.h" |
| 40 | 39 | #include "sound/ay8910.h" |
| r2724 | r2725 | |
| 100 | 99 | } |
| 101 | 100 | |
| 102 | 101 | |
| 103 | static void zaccaria_irq0a(int state) { cpunum_set_input_line(Machine, 1, INPUT_LINE_NMI, state ? ASSERT_LINE : CLEAR_LINE); } | |
| 104 | static void zaccaria_irq0b(int state) { cpunum_set_input_line(Machine, 1,0,state ? ASSERT_LINE : CLEAR_LINE); } | |
| 102 | static void zaccaria_irq0a(running_machine *machine, int state) { cpunum_set_input_line(machine, 1, INPUT_LINE_NMI, state ? ASSERT_LINE : CLEAR_LINE); } | |
| 103 | static void zaccaria_irq0b(running_machine *machine, int state) { cpunum_set_input_line(machine, 1,0,state ? ASSERT_LINE : CLEAR_LINE); } | |
| 105 | 104 | |
| 106 | 105 | static int active_8910,port0a,acs; |
| 107 | 106 | |
| r2724 | r2725 | |
| 208 | 207 | |
| 209 | 208 | } |
| 210 | 209 | |
| 211 | static void tms5220_irq_handler(int state) | |
| 210 | static void tms5220_irq_handler(running_machine *machine, int state) | |
| 212 | 211 | { |
| 213 | pia_1_cb1_w( | |
| 212 | pia_1_cb1_w(machine,0,state ? 0 : 1); | |
| 214 | 213 | } |
| 215 | 214 | |
| 216 | 215 |
| r2724 | r2725 | |
|---|---|---|
| 532 | 532 | |
| 533 | 533 | /* Machine Driver Bits */ |
| 534 | 534 | |
| 535 | static void irq_handler(int irq) | |
| 535 | static void irq_handler(running_machine *machine, int irq) | |
| 536 | 536 | { |
| 537 | cpunum_set_input_line( | |
| 537 | cpunum_set_input_line(machine, 1, 0, irq ? ASSERT_LINE : CLEAR_LINE ); | |
| 538 | 538 | } |
| 539 | 539 | |
| 540 | 540 | static const struct YM2151interface ym2151_interface = |
| r2724 | r2725 | |
|---|---|---|
| 1262 | 1262 | } |
| 1263 | 1263 | } |
| 1264 | 1264 | |
| 1265 | static void comm_uart_irq_callback(int channel, int value) | |
| 1265 | static void comm_uart_irq_callback(running_machine *machine, int channel, int value) | |
| 1266 | 1266 | { |
| 1267 | 1267 | // TODO |
| 1268 | //cpunum_set_input_line( | |
| 1268 | //cpunum_set_input_line(machine, 0, INPUT_LINE_IRQ2, ASSERT_LINE); | |
| 1269 | 1269 | } |
| 1270 | 1270 | |
| 1271 | 1271 | /*****************************************************************************/ |
| r2724 | r2725 | |
| 1413 | 1413 | } |
| 1414 | 1414 | } |
| 1415 | 1415 | |
| 1416 | static void midi_uart_irq_callback(int channel, int value) | |
| 1416 | static void midi_uart_irq_callback(running_machine *machine, int channel, int value) | |
| 1417 | 1417 | { |
| 1418 | 1418 | if (channel == 0) |
| 1419 | 1419 | { |
| 1420 | 1420 | if ((extend_board_irq_enable & 0x02) == 0) |
| 1421 | 1421 | { |
| 1422 | 1422 | extend_board_irq_active |= 0x02; |
| 1423 | cpunum_set_input_line( | |
| 1423 | cpunum_set_input_line(machine, 0, INPUT_LINE_IRQ1, ASSERT_LINE); | |
| 1424 | 1424 | } |
| 1425 | 1425 | } |
| 1426 | 1426 | else |
| r2724 | r2725 | |
| 1428 | 1428 | if ((extend_board_irq_enable & 0x01) == 0) |
| 1429 | 1429 | { |
| 1430 | 1430 | extend_board_irq_active |= 0x01; |
| 1431 | cpunum_set_input_line( | |
| 1431 | cpunum_set_input_line(machine, 0, INPUT_LINE_IRQ1, ASSERT_LINE); | |
| 1432 | 1432 | } |
| 1433 | 1433 | } |
| 1434 | 1434 | } |
| r2724 | r2725 | |
| 1483 | 1483 | if ((keyboard_state[keyboard] & (1 << i)) != 0 && (kbstate & (1 << i)) == 0) |
| 1484 | 1484 | { |
| 1485 | 1485 | // key was on, now off -> send Note Off message |
| 1486 | pc16552d_rx_data(1, uart_channel, 0x80); | |
| 1487 | pc16552d_rx_data(1, uart_channel, kbnote); | |
| 1488 | pc16552d_rx_data(1, uart_channel, 0x7f); | |
| 1486 | pc16552d_rx_data(machine, 1, uart_channel, 0x80); | |
| 1487 | pc16552d_rx_data(machine, 1, uart_channel, kbnote); | |
| 1488 | pc16552d_rx_data(machine, 1, uart_channel, 0x7f); | |
| 1489 | 1489 | } |
| 1490 | 1490 | else if ((keyboard_state[keyboard] & (1 << i)) == 0 && (kbstate & (1 << i)) != 0) |
| 1491 | 1491 | { |
| 1492 | 1492 | // key was off, now on -> send Note On message |
| 1493 | pc16552d_rx_data(1, uart_channel, 0x90); | |
| 1494 | pc16552d_rx_data(1, uart_channel, kbnote); | |
| 1495 | pc16552d_rx_data(1, uart_channel, 0x7f); | |
| 1493 | pc16552d_rx_data(machine, 1, uart_channel, 0x90); | |
| 1494 | pc16552d_rx_data(machine, 1, uart_channel, kbnote); | |
| 1495 | pc16552d_rx_data(machine, 1, uart_channel, 0x7f); | |
| 1496 | 1496 | } |
| 1497 | 1497 | } |
| 1498 | 1498 | } |
| 1499 | 1499 | else |
| 1500 | 1500 | { |
| 1501 | 1501 | // no messages, send Active Sense message instead |
| 1502 | pc16552d_rx_data(1, uart_channel, 0xfe); | |
| 1502 | pc16552d_rx_data(machine, 1, uart_channel, 0xfe); | |
| 1503 | 1503 | } |
| 1504 | 1504 | |
| 1505 | 1505 | keyboard_state[keyboard] = kbstate; |
| r2724 | r2725 | |
| 1790 | 1790 | { |
| 1791 | 1791 | } |
| 1792 | 1792 | |
| 1793 | static void sound_irq_callback(int state) | |
| 1793 | static void sound_irq_callback(running_machine *machine, int state) | |
| 1794 | 1794 | { |
| 1795 | 1795 | } |
| 1796 | 1796 |
| r2724 | r2725 | |
|---|---|---|
| 104 | 104 | */ |
| 105 | 105 | eolith_speedup_read(); |
| 106 | 106 | |
| 107 | return (input_port_read_indexed(machine, 0) & ~0x308) | (EEPROM_read_bit() << 3) | (mame_rand( | |
| 107 | return (input_port_read_indexed(machine, 0) & ~0x308) | (EEPROM_read_bit() << 3) | (mame_rand(machine) & 0x300); | |
| 108 | 108 | } |
| 109 | 109 | |
| 110 | 110 | static WRITE32_HANDLER( systemcontrol_w ) |
| r2724 | r2725 | |
|---|---|---|
| 68 | 68 | ******************************************************************************/ |
| 69 | 69 | |
| 70 | 70 | #include "driver.h" |
| 71 | #include "deprecat.h" | |
| 72 | 71 | #include "cpu/m68000/m68000.h" |
| 73 | 72 | #include "cpu/z80/z80.h" |
| 74 | 73 | #include "machine/eeprom.h" |
| r2724 | r2725 | |
| 377 | 376 | |
| 378 | 377 | ******************************************************************************/ |
| 379 | 378 | |
| 380 | static void irqhandler(int irq) | |
| 379 | static void irqhandler(running_machine *machine, int irq) | |
| 381 | 380 | { |
| 382 | cpunum_set_input_line( | |
| 381 | cpunum_set_input_line(machine, 1, 0, irq ? ASSERT_LINE : CLEAR_LINE); | |
| 383 | 382 | } |
| 384 | 383 | |
| 385 | 384 | static const struct YM2610interface ym2610_interface = |
| r2724 | r2725 | |
|---|---|---|
| 121 | 121 | ******************************************************************************/ |
| 122 | 122 | |
| 123 | 123 | #include "driver.h" |
| 124 | #include "deprecat.h" | |
| 125 | 124 | #include "sound/2203intf.h" |
| 126 | 125 | #include "sound/samples.h" |
| 127 | 126 | #include "machine/mc8123.h" |
| r2724 | r2725 | |
| 897 | 896 | * |
| 898 | 897 | *************************************/ |
| 899 | 898 | |
| 900 | static void irqhandler(int irq) | |
| 899 | static void irqhandler(running_machine *machine, int irq) | |
| 901 | 900 | { |
| 902 | cpunum_set_input_line( | |
| 901 | cpunum_set_input_line(machine, 1, 0, irq ? ASSERT_LINE : CLEAR_LINE); | |
| 903 | 902 | } |
| 904 | 903 | |
| 905 | 904 | static const struct YM2203interface ym2203_interface = |
| r2724 | r2725 | |
|---|---|---|
| 30 | 30 | ***************************************************************************/ |
| 31 | 31 | |
| 32 | 32 | #include "driver.h" |
| 33 | #include "deprecat.h" | |
| 34 | 33 | #include "cpu/z80/z80.h" |
| 35 | 34 | #include "sound/3812intf.h" |
| 36 | 35 | #include "sound/msm5205.h" |
| r2724 | r2725 | |
| 485 | 484 | ***************************************************************************/ |
| 486 | 485 | |
| 487 | 486 | |
| 488 | static void yunsung8_adpcm_int(int irq) | |
| 487 | static void yunsung8_adpcm_int(running_machine *machine, int irq) | |
| 489 | 488 | { |
| 490 | 489 | static int toggle=0; |
| 491 | 490 | |
| r2724 | r2725 | |
| 494 | 493 | |
| 495 | 494 | toggle ^= 1; |
| 496 | 495 | if (toggle) |
| 497 | cpunum_set_input_line( | |
| 496 | cpunum_set_input_line(machine, 1, INPUT_LINE_NMI, PULSE_LINE); | |
| 498 | 497 | } |
| 499 | 498 | |
| 500 | 499 | static const struct MSM5205interface yunsung8_msm5205_interface = |
| r2724 | r2725 | |
|---|---|---|
| 59 | 59 | |
| 60 | 60 | |
| 61 | 61 | |
| 62 | return input_port_read_indexed(machine, 0)^toggle_bit;// mame_rand( | |
| 62 | return input_port_read_indexed(machine, 0)^toggle_bit;// mame_rand(machine); | |
| 63 | 63 | } |
| 64 | 64 | |
| 65 | 65 | static READ16_HANDLER( wheelfir_rand2 ) |
| 66 | 66 | { |
| 67 | return input_port_read_indexed(machine, 1);// mame_rand( | |
| 67 | return input_port_read_indexed(machine, 1);// mame_rand(machine); | |
| 68 | 68 | } |
| 69 | 69 | |
| 70 | 70 | |
| 71 | 71 | static READ16_HANDLER( wheelfir_rand4 ) |
| 72 | 72 | { |
| 73 | return mame_rand( | |
| 73 | return mame_rand(machine); | |
| 74 | 74 | } |
| 75 | 75 | |
| 76 | 76 | static UINT16 *wheelfir_myram; |
| r2724 | r2725 | |
|---|---|---|
| 35 | 35 | |
| 36 | 36 | |
| 37 | 37 | #include "driver.h" |
| 38 | #include "deprecat.h" | |
| 39 | 38 | |
| 40 | 39 | static VIDEO_START(steaser) |
| 41 | 40 | { |
| r2724 | r2725 | |
| 48 | 47 | |
| 49 | 48 | static READ16_HANDLER( steaser_bd0000_r ) |
| 50 | 49 | { |
| 51 | return mame_rand( | |
| 50 | return mame_rand(machine); | |
| 52 | 51 | } |
| 53 | 52 | |
| 54 | 53 | static ADDRESS_MAP_START( steaser_map, ADDRESS_SPACE_PROGRAM, 16 ) |
| r2724 | r2725 | |
|---|---|---|
| 14 | 14 | ***************************************************************************/ |
| 15 | 15 | |
| 16 | 16 | #include "driver.h" |
| 17 | #include "deprecat.h" | |
| 18 | 17 | #include "cpu/h6280/h6280.h" |
| 19 | 18 | #include "sound/2203intf.h" |
| 20 | 19 | #include "sound/2151intf.h" |
| r2724 | r2725 | |
| 331 | 330 | |
| 332 | 331 | /******************************************************************************/ |
| 333 | 332 | |
| 334 | static void sound_irq(int state) | |
| 333 | static void sound_irq(running_machine *machine, int state) | |
| 335 | 334 | { |
| 336 | cpunum_set_input_line( | |
| 335 | cpunum_set_input_line(machine, 1,1,state); /* IRQ 2 */ | |
| 337 | 336 | } |
| 338 | 337 | |
| 339 | 338 | static const struct YM2151interface ym2151_interface = |
| r2724 | r2725 | |
|---|---|---|
| 260 | 260 | return 0; |
| 261 | 261 | } |
| 262 | 262 | |
| 263 | static void irqhandler(int linestate) | |
| 263 | static void irqhandler(running_machine *machine, int linestate) | |
| 264 | 264 | { |
| 265 | cpunum_set_input_line( | |
| 265 | cpunum_set_input_line(machine, 1,0,linestate); | |
| 266 | 266 | } |
| 267 | 267 | |
| 268 | 268 | static const struct YM3812interface ym3812_interface = |
| r2724 | r2725 | |
|---|---|---|
| 32 | 32 | ******************************************************************************/ |
| 33 | 33 | |
| 34 | 34 | #include "driver.h" |
| 35 | #include "deprecat.h" | |
| 36 | 35 | #include "cpu/z80/z80.h" |
| 37 | 36 | #include "sound/ay8910.h" |
| 38 | 37 | #include "sound/msm5205.h" |
| r2724 | r2725 | |
| 106 | 105 | ojankohs_vclk_left = 2; |
| 107 | 106 | } |
| 108 | 107 | |
| 109 | static void ojankohs_adpcm_int(int irq) | |
| 108 | static void ojankohs_adpcm_int(running_machine *machine, int irq) | |
| 110 | 109 | { |
| 111 | 110 | /* skip if we're reset */ |
| 112 | 111 | if (!ojankohs_adpcm_reset) |
| r2724 | r2725 | |
| 121 | 120 | |
| 122 | 121 | /* generate an NMI if we're out of data */ |
| 123 | 122 | if (!ojankohs_vclk_left) |
| 124 | cpunum_set_input_line( | |
| 123 | cpunum_set_input_line(machine, 0, INPUT_LINE_NMI, PULSE_LINE); | |
| 125 | 124 | } |
| 126 | 125 | |
| 127 | 126 | static WRITE8_HANDLER( ojankoc_ctrl_w ) |
| r2724 | r2725 | |
|---|---|---|
| 83 | 83 | */ |
| 84 | 84 | |
| 85 | 85 | #include "driver.h" |
| 86 | #include "deprecat.h" | |
| 87 | 86 | #include "cpu/z80/z80.h" |
| 88 | 87 | #include "sound/2203intf.h" |
| 89 | 88 | #include "sound/msm5205.h" |
| r2724 | r2725 | |
| 348 | 347 | |
| 349 | 348 | |
| 350 | 349 | /* handler called by the 2203 emulator when the internal timers cause an IRQ */ |
| 351 | static void irqhandler(int irq) | |
| 350 | static void irqhandler(running_machine *machine, int irq) | |
| 352 | 351 | { |
| 353 | cpunum_set_input_line( | |
| 352 | cpunum_set_input_line(machine, 2, INPUT_LINE_NMI, irq ? ASSERT_LINE : CLEAR_LINE); | |
| 354 | 353 | } |
| 355 | 354 | |
| 356 | 355 | static const struct YM2203interface ym2203_interface = |
| r2724 | r2725 | |
| 363 | 362 | irqhandler |
| 364 | 363 | }; |
| 365 | 364 | |
| 366 | static void adpcm_int(int data) | |
| 365 | static void adpcm_int(running_machine *machine, int data) | |
| 367 | 366 | { |
| 368 | 367 | static int toggle = 0; |
| 369 | 368 | |
| r2724 | r2725 | |
| 372 | 371 | |
| 373 | 372 | toggle ^= 1; |
| 374 | 373 | if(toggle) |
| 375 | cpunum_set_input_line( | |
| 374 | cpunum_set_input_line(machine, 2, INPUT_LINE_NMI, PULSE_LINE); | |
| 376 | 375 | |
| 377 | 376 | } |
| 378 | 377 |
| r2724 | r2725 | |
|---|---|---|
| 76 | 76 | } |
| 77 | 77 | } |
| 78 | 78 | |
| 79 | static void spd_adpcm_int(int chip) | |
| 79 | static void spd_adpcm_int(running_machine *machine, int chip) | |
| 80 | 80 | { |
| 81 | 81 | static int adpcm_data[2] = { -1, -1 }; |
| 82 | 82 | |
| r2724 | r2725 | |
| 412 | 412 | GFXDECODE_END |
| 413 | 413 | |
| 414 | 414 | |
| 415 | static void irq_handler(int irq) | |
| 415 | static void irq_handler(running_machine *machine, int irq) | |
| 416 | 416 | { |
| 417 | cpunum_set_input_line( | |
| 417 | cpunum_set_input_line(machine, | |
| 418 | 418 | } |
| 419 | 419 | |
| 420 | 420 | static const struct YM3812interface ym3812_interface = |
| r2724 | r2725 | |
|---|---|---|
| 1422 | 1422 | 0x1000, /* address */ |
| 1423 | 1423 | }; |
| 1424 | 1424 | |
| 1425 | static void utoukond_ym3438_interrupt(int linestate) | |
| 1425 | static void utoukond_ym3438_interrupt(running_machine *machine, int linestate) | |
| 1426 | 1426 | { |
| 1427 | cpunum_set_input_line( | |
| 1427 | cpunum_set_input_line(machine, 1, INPUT_LINE_NMI, linestate); | |
| 1428 | 1428 | } |
| 1429 | 1429 | |
| 1430 | 1430 | static const struct YM3438interface utoukond_ym3438_intf = |
| r2724 | r2725 | |
|---|---|---|
| 17 | 17 | */ |
| 18 | 18 | |
| 19 | 19 | #include "driver.h" |
| 20 | #include "deprecat.h" | |
| 21 | 20 | #include "cpu/s2650/s2650.h" |
| 22 | 21 | #include "machine/6821pia.h" |
| 23 | 22 | #include "video/s2636.h" |
| r2724 | r2725 | |
| 594 | 593 | |
| 595 | 594 | /* Cat'N Mouse sound ***********************************/ |
| 596 | 595 | |
| 597 | static void zaccaria_irq0a(int state) { cpunum_set_input_line(Machine, 1, INPUT_LINE_NMI, state ? ASSERT_LINE : CLEAR_LINE); } | |
| 598 | static void zaccaria_irq0b(int state) { cpunum_set_input_line(Machine, 1,0,state ? ASSERT_LINE : CLEAR_LINE); } | |
| 596 | static void zaccaria_irq0a(running_machine *machine, int state) { cpunum_set_input_line(machine, 1, INPUT_LINE_NMI, state ? ASSERT_LINE : CLEAR_LINE); } | |
| 597 | static void zaccaria_irq0b(running_machine *machine, int state) { cpunum_set_input_line(machine, 1,0,state ? ASSERT_LINE : CLEAR_LINE); } | |
| 599 | 598 | |
| 600 | 599 | static int active_8910,port0a; |
| 601 | 600 |
| r2724 | r2725 | |
|---|---|---|
| 152 | 152 | cpunum_set_input_line(machine, 0, 0, param); |
| 153 | 153 | } |
| 154 | 154 | |
| 155 | static void via_irq(int state) | |
| 155 | static void via_irq(running_machine *machine, int state) | |
| 156 | 156 | { |
| 157 | 157 | // from gameplan.c |
| 158 | 158 |
| r2724 | r2725 | |
|---|---|---|
| 246 | 246 | |
| 247 | 247 | |
| 248 | 248 | #include "driver.h" |
| 249 | #include "deprecat.h" | |
| 250 | 249 | #include "cpu/i8x41/i8x41.h" |
| 251 | 250 | #include "sound/2203intf.h" |
| 252 | 251 | #include "sound/dac.h" |
| r2724 | r2725 | |
| 560 | 559 | b = (paldata >> 8) & 0x000f; |
| 561 | 560 | // the other bits seem to be used, and the colours are wrong.. |
| 562 | 561 | |
| 563 | palette_set_color_rgb( | |
| 562 | palette_set_color_rgb(machine,offset,r<<4, g<<4, b<<4); | |
| 564 | 563 | } |
| 565 | 564 | |
| 566 | 565 | static ADDRESS_MAP_START( jpopnics_main_map, ADDRESS_SPACE_PROGRAM, 8 ) |
| r2724 | r2725 | |
| 1428 | 1427 | |
| 1429 | 1428 | |
| 1430 | 1429 | /* handler called by the 2203 emulator when the internal timers cause an IRQ */ |
| 1431 | static void irqhandler(int irq) | |
| 1430 | static void irqhandler(running_machine *machine, int irq) | |
| 1432 | 1431 | { |
| 1433 | cpunum_set_input_line( | |
| 1432 | cpunum_set_input_line(machine, 2, INPUT_LINE_NMI, irq ? ASSERT_LINE : CLEAR_LINE); | |
| 1434 | 1433 | } |
| 1435 | 1434 | |
| 1436 | 1435 | static const struct YM2203interface kageki_ym2203_interface = |
| r2724 | r2725 | |
|---|---|---|
| 108 | 108 | ***************************************************************************/ |
| 109 | 109 | |
| 110 | 110 | #include "driver.h" |
| 111 | #include "deprecat.h" | |
| 112 | 111 | #include "cpu/h6280/h6280.h" |
| 113 | 112 | #include "decocrpt.h" |
| 114 | 113 | #include "decoprot.h" |
| r2724 | r2725 | |
| 793 | 792 | |
| 794 | 793 | /**********************************************************************************/ |
| 795 | 794 | |
| 796 | static void sound_irq(int state) | |
| 795 | static void sound_irq(running_machine *machine, int state) | |
| 797 | 796 | { |
| 798 | cpunum_set_input_line( | |
| 797 | cpunum_set_input_line(machine, 1,1,state); /* IRQ 2 */ | |
| 799 | 798 | } |
| 800 | 799 | |
| 801 | 800 | static WRITE8_HANDLER( sound_bankswitch_w ) |
| r2724 | r2725 | |
|---|---|---|
| 387 | 387 | GFXDECODE_ENTRY( REGION_GFX2, 0, spritelayout, 128, 8 ) /* 16x16 sprites */ |
| 388 | 388 | GFXDECODE_END |
| 389 | 389 | |
| 390 | static void vball_irq_handler(int irq) | |
| 390 | static void vball_irq_handler(running_machine *machine, int irq) | |
| 391 | 391 | { |
| 392 | cpunum_set_input_line( | |
| 392 | cpunum_set_input_line(machine, 1, 0 , irq ? ASSERT_LINE : CLEAR_LINE ); | |
| 393 | 393 | } |
| 394 | 394 | |
| 395 | 395 | static const struct YM2151interface ym2151_interface = |
| r2724 | r2725 | |
|---|---|---|
| 510 | 510 | #include "cpu/arm7/arm7core.h" |
| 511 | 511 | #include "sound/aica.h" |
| 512 | 512 | #include "dc.h" |
| 513 | #include "deprecat.h" | |
| 514 | 513 | |
| 515 | 514 | #define CPU_CLOCK (200000000) |
| 516 | 515 | /* MD2 MD1 MD0 MD6 MD4 MD3 MD5 MD7 MD8 */ |
| r2724 | r2725 | |
| 715 | 714 | return -1; |
| 716 | 715 | } |
| 717 | 716 | |
| 718 | static void aica_irq(int irq) | |
| 717 | static void aica_irq(running_machine *machine, int irq) | |
| 719 | 718 | { |
| 720 | cpunum_set_input_line( | |
| 719 | cpunum_set_input_line(machine, 1, ARM7_FIRQ_LINE, irq ? ASSERT_LINE : CLEAR_LINE); | |
| 721 | 720 | } |
| 722 | 721 | |
| 723 | 722 | static ADDRESS_MAP_START( dc_audio_map, ADDRESS_SPACE_PROGRAM, 32 ) |
| r2724 | r2725 | |
|---|---|---|
| 2114 | 2114 | REGION_SOUND1 /* prom memory region */ |
| 2115 | 2115 | }; |
| 2116 | 2116 | |
| 2117 | static void sound_irq(int state) | |
| 2117 | static void sound_irq(running_machine *machine, int state) | |
| 2118 | 2118 | { |
| 2119 | 2119 | /* Interrupts _are_ generated, I wonder where they go.. */ |
| 2120 | /*cpunum_set_input_line( | |
| 2120 | /*cpunum_set_input_line(machine, 1,0,HOLD_LINE);*/ | |
| 2121 | 2121 | } |
| 2122 | 2122 | |
| 2123 | 2123 | static const struct YM2151interface ym2151_interface = |
| r2724 | r2725 | |
|---|---|---|
| 26 | 26 | { |
| 27 | 27 | /* this starts a 556 one-shot timer (and triggers a sound effect) */ |
| 28 | 28 | if (newval) |
| 29 | cpunum_set_input_line(machine, 0, INPUT_LINE_NMI, PULSE_LINE); | |
| 29 | cpunum_set_input_line(field->port->machine, 0, INPUT_LINE_NMI, PULSE_LINE); | |
| 30 | 30 | } |
| 31 | 31 | |
| 32 | 32 |
| r2724 | r2725 | |
|---|---|---|
| 2646 | 2646 | |
| 2647 | 2647 | static int scsp_last_line = 0; |
| 2648 | 2648 | |
| 2649 | static void scsp_irq(int irq) | |
| 2649 | static void scsp_irq(running_machine *machine, int irq) | |
| 2650 | 2650 | { |
| 2651 | 2651 | // don't bother the 68k if it's off |
| 2652 | 2652 | if (!en_68k) |
| r2724 | r2725 | |
| 2657 | 2657 | if (irq > 0) |
| 2658 | 2658 | { |
| 2659 | 2659 | scsp_last_line = irq; |
| 2660 | cpunum_set_input_line( | |
| 2660 | cpunum_set_input_line(machine, 2, irq, ASSERT_LINE); | |
| 2661 | 2661 | } |
| 2662 | 2662 | else if (irq < 0) |
| 2663 | 2663 | { |
| 2664 | cpunum_set_input_line( | |
| 2664 | cpunum_set_input_line(machine, 2, -irq, CLEAR_LINE); | |
| 2665 | 2665 | } |
| 2666 | 2666 | else |
| 2667 | 2667 | { |
| 2668 | cpunum_set_input_line( | |
| 2668 | cpunum_set_input_line(machine, 2, scsp_last_line, CLEAR_LINE); | |
| 2669 | 2669 | } |
| 2670 | 2670 | } |
| 2671 | 2671 |
| r2724 | r2725 | |
|---|---|---|
| 144 | 144 | ***************************************************************************/ |
| 145 | 145 | |
| 146 | 146 | #include "driver.h" |
| 147 | #include "deprecat.h" | |
| 148 | 147 | #include "taitoipt.h" |
| 149 | 148 | #include "rendlay.h" |
| 150 | 149 | #include "cpu/m68000/m68000.h" |
| r2724 | r2725 | |
| 401 | 400 | **************************************************************/ |
| 402 | 401 | |
| 403 | 402 | /* handler called by the YM2610 emulator when the internal timers cause an IRQ */ |
| 404 | static void irqhandler(int irq) | |
| 403 | static void irqhandler(running_machine *machine, int irq) | |
| 405 | 404 | { |
| 406 | cpunum_set_input_line( | |
| 405 | cpunum_set_input_line(machine, 1,0,irq ? ASSERT_LINE : CLEAR_LINE); | |
| 407 | 406 | } |
| 408 | 407 | |
| 409 | 408 | static const struct YM2610interface ym2610_interface = |
| r2724 | r2725 | |
|---|---|---|
| 2456 | 2456 | |
| 2457 | 2457 | |
| 2458 | 2458 | |
| 2459 | static void sound_irq(int state) | |
| 2459 | static void sound_irq(running_machine *machine, int state) | |
| 2460 | 2460 | { |
| 2461 | // cpunum_set_input_line( | |
| 2461 | // cpunum_set_input_line(machine, 0, 3, state); | |
| 2462 | 2462 | } |
| 2463 | 2463 | |
| 2464 | 2464 | static const struct ics2115_interface pgm_ics2115_interface = { |
| r2724 | r2725 | |
|---|---|---|
| 8 | 8 | ***************************************************************************/ |
| 9 | 9 | |
| 10 | 10 | #include "driver.h" |
| 11 | #include "deprecat.h" | |
| 12 | 11 | #include "sound/2203intf.h" |
| 13 | 12 | #include "sound/okim6295.h" |
| 14 | 13 | #include "sound/msm5205.h" |
| r2724 | r2725 | |
| 233 | 232 | INPUT_PORTS_END |
| 234 | 233 | |
| 235 | 234 | /* handler called by the 2203 emulator when the internal timers cause an IRQ */ |
| 236 | static void irqhandler(int irq) | |
| 235 | static void irqhandler(running_machine *machine, int irq) | |
| 237 | 236 | { |
| 238 | cpunum_set_input_line( | |
| 237 | cpunum_set_input_line(machine, 1, INPUT_LINE_NMI, irq ? ASSERT_LINE : CLEAR_LINE); | |
| 239 | 238 | } |
| 240 | 239 | |
| 241 | 240 | static const struct YM2203interface ym2203_interface = |
| r2724 | r2725 | |
| 248 | 247 | irqhandler |
| 249 | 248 | }; |
| 250 | 249 | |
| 251 | static void goal92_adpcm_int(int data) | |
| 250 | static void goal92_adpcm_int(running_machine *machine, int data) | |
| 252 | 251 | { |
| 253 | 252 | static int toggle = 0; |
| 254 | 253 | |
| r2724 | r2725 | |
| 257 | 256 | |
| 258 | 257 | toggle ^= 1; |
| 259 | 258 | if(toggle) |
| 260 | cpunum_set_input_line( | |
| 259 | cpunum_set_input_line(machine, 1, INPUT_LINE_NMI, PULSE_LINE); | |
| 261 | 260 | } |
| 262 | 261 | |
| 263 | 262 | static const struct MSM5205interface msm5205_interface = |
| r2724 | r2725 | |
|---|---|---|
| 321 | 321 | { |
| 322 | 322 | } |
| 323 | 323 | |
| 324 | static void sound_irq_gen(int state) | |
| 324 | static void sound_irq_gen(running_machine *machine, int state) | |
| 325 | 325 | { |
| 326 | 326 | if (state) |
| 327 | cpunum_set_input_line( | |
| 327 | cpunum_set_input_line(machine, 0, MC68000_IRQ_1, ASSERT_LINE); | |
| 328 | 328 | else |
| 329 | cpunum_set_input_line( | |
| 329 | cpunum_set_input_line(machine, 0, MC68000_IRQ_1, CLEAR_LINE); | |
| 330 | 330 | } |
| 331 | 331 | |
| 332 | 332 | static const struct YMZ280Binterface ymz280b_intf = |
| r2724 | r2725 | |
|---|---|---|
| 244 | 244 | int x = 0, y = 0; |
| 245 | 245 | |
| 246 | 246 | /* get the position based on the input select */ |
| 247 | get_lightgun_pos(machine->primary_screen, input_select, &x, &y); | |
| 247 | get_lightgun_pos(field->port->machine->primary_screen, input_select, &x, &y); | |
| 248 | 248 | return (y << 8) | (x >> 2); |
| 249 | 249 | } |
| 250 | 250 | |
| r2724 | r2725 | |
| 252 | 252 | static CUSTOM_INPUT( lightgun_trigger_r ) |
| 253 | 253 | { |
| 254 | 254 | /* read the trigger control based on the input select */ |
| 255 | return (input_port_read(machine, "TRIGGERS") >> input_select) & 1; | |
| 255 | return (input_port_read(field->port->machine, "TRIGGERS") >> input_select) & 1; | |
| 256 | 256 | } |
| 257 | 257 | |
| 258 | 258 | |
| 259 | 259 | static CUSTOM_INPUT( lightgun_holster_r ) |
| 260 | 260 | { |
| 261 | 261 | /* read the holster control based on the input select */ |
| 262 | return (input_port_read(machine, "TRIGGERS") >> (2 + input_select)) & 1; | |
| 262 | return (input_port_read(field->port->machine, "TRIGGERS") >> (2 + input_select)) & 1; | |
| 263 | 263 | } |
| 264 | 264 | |
| 265 | 265 |
| r2724 | r2725 | |
|---|---|---|
| 22 | 22 | ******************************************************************************/ |
| 23 | 23 | |
| 24 | 24 | #include "driver.h" |
| 25 | #include "deprecat.h" | |
| 26 | 25 | #include "cpu/m68000/m68000.h" |
| 27 | 26 | #include "cpu/z80/z80.h" |
| 28 | 27 | #include "machine/eeprom.h" |
| r2724 | r2725 | |
| 683 | 682 | // |
| 684 | 683 | // ---------------------------------------------------------------------------- |
| 685 | 684 | |
| 686 | static void irqhandler(int irq) | |
| 685 | static void irqhandler(running_machine *machine, int irq) | |
| 687 | 686 | { |
| 688 | cpunum_set_input_line( | |
| 687 | cpunum_set_input_line(machine, 1, 0, irq ? ASSERT_LINE : CLEAR_LINE); | |
| 689 | 688 | } |
| 690 | 689 | |
| 691 | 690 | static const struct YM2610interface ym2610_interface = |
| r2724 | r2725 | |
|---|---|---|
| 1299 | 1299 | return i; |
| 1300 | 1300 | } |
| 1301 | 1301 | |
| 1302 | static void irq_init( | |
| 1302 | static void irq_init(running_machine *machine) | |
| 1303 | 1303 | { |
| 1304 | 1304 | irqreq = 0; |
| 1305 | cpunum_set_input_line( | |
| 1305 | cpunum_set_input_line(machine, 0, 0, CLEAR_LINE); | |
| 1306 | 1306 | cpunum_set_irq_callback(0, irq_callback); |
| 1307 | 1307 | } |
| 1308 | 1308 | |
| 1309 | static void irq_raise(int level) | |
| 1309 | static void irq_raise(running_machine *machine, int level) | |
| 1310 | 1310 | { |
| 1311 | 1311 | irqreq |= (1<<level); |
| 1312 | cpunum_set_input_line( | |
| 1312 | cpunum_set_input_line(machine, 0, 0, ASSERT_LINE); | |
| 1313 | 1313 | } |
| 1314 | 1314 | |
| 1315 | 1315 | |
| 1316 | 1316 | static INTERRUPT_GEN(ms32_interrupt) |
| 1317 | 1317 | { |
| 1318 | if( cpu_getiloops() == 0 ) irq_raise(10); | |
| 1319 | if( cpu_getiloops() == 1 ) irq_raise(9); | |
| 1318 | if( cpu_getiloops() == 0 ) irq_raise(machine, 10); | |
| 1319 | if( cpu_getiloops() == 1 ) irq_raise(machine, 9); | |
| 1320 | 1320 | /* hayaosi1 needs at least 12 IRQ 0 per frame to work (see code at FFE02289) |
| 1321 | 1321 | kirarast needs it too, at least 8 per frame, but waits for a variable amount |
| 1322 | 1322 | 47pi2 needs ?? per frame (otherwise it hangs when you lose) |
| r2724 | r2725 | |
| 1325 | 1325 | desertwr |
| 1326 | 1326 | p47aces |
| 1327 | 1327 | */ |
| 1328 | if( cpu_getiloops() >= 3 && cpu_getiloops() <= 32 ) irq_raise(0); | |
| 1328 | if( cpu_getiloops() >= 3 && cpu_getiloops() <= 32 ) irq_raise(machine, 0); | |
| 1329 | 1329 | } |
| 1330 | 1330 | |
| 1331 | 1331 | static MACHINE_RESET( ms32 ) |
| 1332 | 1332 | { |
| 1333 | irq_init(); | |
| 1333 | irq_init(machine); | |
| 1334 | 1334 | } |
| 1335 | 1335 | |
| 1336 | 1336 |
| r2724 | r2725 | |
|---|---|---|
| 673 | 673 | { |
| 674 | 674 | case 0: |
| 675 | 675 | /* VBlank is connected to INT1 (external interrupts pin 1) */ |
| 676 | tmp68301_external_interrupt_1(); | |
| 676 | tmp68301_external_interrupt_1(machine); | |
| 677 | 677 | break; |
| 678 | 678 | } |
| 679 | 679 | } |
| r2724 | r2725 | |
|---|---|---|
| 182 | 182 | { |
| 183 | 183 | /* pressing the service switch sends an NMI */ |
| 184 | 184 | if (newval) |
| 185 | cpunum_set_input_line(machine, 0, INPUT_LINE_NMI, PULSE_LINE); | |
| 185 | cpunum_set_input_line(field->port->machine, 0, INPUT_LINE_NMI, PULSE_LINE); | |
| 186 | 186 | } |
| 187 | 187 | |
| 188 | 188 | |
| r2724 | r2725 | |
| 313 | 313 | |
| 314 | 314 | static CUSTOM_INPUT( elim4_joint_coin_r ) |
| 315 | 315 | { |
| 316 | return (input_port_read(machine, "COINS") & 0xf) != 0xf; | |
| 316 | return (input_port_read(field->port->machine, "COINS") & 0xf) != 0xf; | |
| 317 | 317 | } |
| 318 | 318 | |
| 319 | 319 |
| r2724 | r2725 | |
|---|---|---|
| 38 | 38 | ****************************************************************************/ |
| 39 | 39 | |
| 40 | 40 | #include "driver.h" |
| 41 | #include "deprecat.h" | |
| 42 | 41 | |
| 43 | 42 | |
| 44 | 43 | static UINT8 *ace_scoreram; |
| r2724 | r2725 | |
| 139 | 138 | |
| 140 | 139 | static READ8_HANDLER( unk_r ) |
| 141 | 140 | { |
| 142 | return mame_rand( | |
| 141 | return mame_rand(machine)&0xff; | |
| 143 | 142 | } |
| 144 | 143 | |
| 145 | 144 |
| r2724 | r2725 | |
|---|---|---|
| 103 | 103 | |
| 104 | 104 | static int msm5205next; |
| 105 | 105 | |
| 106 | static void battlera_adpcm_int(int data) | |
| 106 | static void battlera_adpcm_int(running_machine *machine, int data) | |
| 107 | 107 | { |
| 108 | 108 | static int toggle; |
| 109 | 109 | |
| r2724 | r2725 | |
| 112 | 112 | |
| 113 | 113 | toggle = 1 - toggle; |
| 114 | 114 | if (toggle) |
| 115 | cpunum_set_input_line( | |
| 115 | cpunum_set_input_line(machine, 1, 1, HOLD_LINE); | |
| 116 | 116 | } |
| 117 | 117 | |
| 118 | 118 | static WRITE8_HANDLER( battlera_adpcm_data_w ) |
| r2724 | r2725 | |
|---|---|---|
| 432 | 432 | |
| 433 | 433 | |
| 434 | 434 | /* handler called by the 2203 emulator when the internal timers cause an IRQ */ |
| 435 | static void irqhandler(int irq) | |
| 435 | static void irqhandler(running_machine *machine, int irq) | |
| 436 | 436 | { |
| 437 | cpunum_set_input_line( | |
| 437 | cpunum_set_input_line(machine, 2,M6809_FIRQ_LINE,irq ? ASSERT_LINE : CLEAR_LINE); | |
| 438 | 438 | } |
| 439 | 439 | |
| 440 | 440 | static const struct YM2203interface ym2203_interface = |
| r2724 | r2725 | |
|---|---|---|
| 755 | 755 | PORT_BIT( 0xf0, IP_ACTIVE_HIGH, IPT_UNUSED ) |
| 756 | 756 | |
| 757 | 757 | PORT_START_TAG("GAMESEL") /* fake - game select */ |
| 758 | PORT_ | |
| 758 | PORT_DIPNAME( 0x01, 0x00, | |
| 759 | 759 | PORT_DIPSETTING( 0x00, "Ghost Muncher" ) |
| 760 | 760 | PORT_DIPSETTING( 0x01, "Galaxian" ) |
| 761 | 761 | INPUT_PORTS_END |
| r2724 | r2725 | |
|---|---|---|
| 339 | 339 | ***********************************************************************/ |
| 340 | 340 | |
| 341 | 341 | #include "driver.h" |
| 342 | #include "deprecat.h" | |
| 343 | 342 | #include "cpu/m6809/m6809.h" |
| 344 | 343 | #include "cpu/m6800/m6800.h" |
| 345 | 344 | #include "sound/2151intf.h" |
| r2724 | r2725 | |
| 970 | 969 | |
| 971 | 970 | |
| 972 | 971 | |
| 973 | static void namcos1_sound_interrupt( int irq ) | |
| 972 | static void namcos1_sound_interrupt( running_machine *machine, int irq ) | |
| 974 | 973 | { |
| 975 | cpunum_set_input_line( | |
| 974 | cpunum_set_input_line(machine, 2, M6809_FIRQ_LINE, irq ? ASSERT_LINE : CLEAR_LINE); | |
| 976 | 975 | } |
| 977 | 976 | |
| 978 | 977 | static const struct YM2151interface ym2151_interface = |
| r2724 | r2725 | |
|---|---|---|
| 853 | 853 | PORT_DIPNAME( 0x40, 0x40, "Invulnerability (Cheat)") |
| 854 | 854 | PORT_DIPSETTING( 0x40, DEF_STR( Off ) ) |
| 855 | 855 | PORT_DIPSETTING( 0x00, DEF_STR( On ) ) |
| 856 | PORT_ | |
| 856 | PORT_DIPNAME( | |
| 857 | 857 | PORT_DIPSETTING( 0x80, DEF_STR( Off ) ) |
| 858 | 858 | PORT_DIPSETTING( 0x00, DEF_STR( On ) ) |
| 859 | 859 | INPUT_PORTS_END |
| r2724 | r2725 | |
|---|---|---|
| 110 | 110 | ****************************************************************************/ |
| 111 | 111 | |
| 112 | 112 | #include "driver.h" |
| 113 | #include "deprecat.h" | |
| 114 | 113 | #include "cpu/z80/z80daisy.h" |
| 115 | 114 | #include "includes/astrocde.h" |
| 116 | 115 | #include "machine/z80ctc.h" |
| r2724 | r2725 | |
| 258 | 257 | static CUSTOM_INPUT( ebases_trackball_r ) |
| 259 | 258 | { |
| 260 | 259 | static const char *const names[] = { "TRACKX2", "TRACKY2", "TRACKX1", "TRACKY1" }; |
| 261 | return input_port_read(machine, names[input_select]); | |
| 260 | return input_port_read(field->port->machine, names[input_select]); | |
| 262 | 261 | } |
| 263 | 262 | |
| 264 | 263 | |
| r2724 | r2725 | |
| 474 | 473 | static CUSTOM_INPUT( demndragn_joystick_r ) |
| 475 | 474 | { |
| 476 | 475 | static const char *const names[] = { "MOVEX", "MOVEY" }; |
| 477 | return input_port_read(machine, names[input_select]); | |
| 476 | return input_port_read(field->port->machine, names[input_select]); | |
| 478 | 477 | } |
| 479 | 478 | |
| 480 | 479 | |
| r2724 | r2725 | |
| 491 | 490 | * |
| 492 | 491 | *************************************/ |
| 493 | 492 | |
| 494 | static void ctc_interrupt(int state) | |
| 493 | static void ctc_interrupt(running_machine *machine, int state) | |
| 495 | 494 | { |
| 496 | cpunum_set_input_line( | |
| 495 | cpunum_set_input_line(machine, 1, 0, state); | |
| 497 | 496 | } |
| 498 | 497 | |
| 499 | 498 | |
| r2724 | r2725 | |
| 1420 | 1419 | |
| 1421 | 1420 | MDRV_SOUND_ADD(SAMPLES, 0) |
| 1422 | 1421 | MDRV_SOUND_CONFIG(gorf_samples_interface) |
| 1423 | MDRV_SOUND_ROUTE(ALL_OUTPUTS, "upper", 0. | |
| 1422 | MDRV_SOUND_ROUTE(ALL_OUTPUTS, "upper", 0.85) | |
| 1424 | 1423 | MACHINE_DRIVER_END |
| 1425 | 1424 | |
| 1426 | 1425 | |
| r2724 | r2725 | |
| 1740 | 1739 | { |
| 1741 | 1740 | astrocade_video_config = 0x00; |
| 1742 | 1741 | memory_install_read8_handler(machine, 0, ADDRESS_SPACE_IO, 0x14, 0x14, 0x1fff, 0xff00, demndrgn_io_r); |
| 1743 | memory_install_read8_handler(machine, 0, ADDRESS_SPACE_IO, 0x1c, 0x1c, 0x0000, 0xff00, port_tag_to_handler8("FIREX")); | |
| 1744 | memory_install_read8_handler(machine, 0, ADDRESS_SPACE_IO, 0x1d, 0x1d, 0x0000, 0xff00, port_tag_to_handler8("FIREY")); | |
| 1742 | memory_install_read8_handler(machine, 0, ADDRESS_SPACE_IO, 0x1c, 0x1c, 0x0000, 0xff00, input_port_read_handler8(machine->portconfig, "FIREX")); | |
| 1743 | memory_install_read8_handler(machine, 0, ADDRESS_SPACE_IO, 0x1d, 0x1d, 0x0000, 0xff00, input_port_read_handler8(machine->portconfig, "FIREY")); | |
| 1745 | 1744 | memory_install_write8_handler(machine, 0, ADDRESS_SPACE_IO, 0x97, 0x97, 0x0000, 0xff00, demndrgn_sound_w); |
| 1746 | 1745 | |
| 1747 | 1746 | /* reset banking */ |
| r2724 | r2725 | |
| 1753 | 1752 | static DRIVER_INIT( tenpindx ) |
| 1754 | 1753 | { |
| 1755 | 1754 | astrocade_video_config = 0x00; |
| 1756 | memory_install_read8_handler(machine, 0, ADDRESS_SPACE_IO, 0x60, 0x60, 0x0000, 0xff00, port_tag_to_handler8("P60")); | |
| 1757 | memory_install_read8_handler(machine, 0, ADDRESS_SPACE_IO, 0x61, 0x61, 0x0000, 0xff00, port_tag_to_handler8("P61")); | |
| 1758 | memory_install_read8_handler(machine, 0, ADDRESS_SPACE_IO, 0x62, 0x62, 0x0000, 0xff00, port_tag_to_handler8("P62")); | |
| 1759 | memory_install_read8_handler(machine, 0, ADDRESS_SPACE_IO, 0x63, 0x63, 0x0000, 0xff00, port_tag_to_handler8("P63")); | |
| 1760 | memory_install_read8_handler(machine, 0, ADDRESS_SPACE_IO, 0x64, 0x64, 0x0000, 0xff00, port_tag_to_handler8("P64")); | |
| 1755 | memory_install_read8_handler(machine, 0, ADDRESS_SPACE_IO, 0x60, 0x60, 0x0000, 0xff00, input_port_read_handler8(machine->portconfig, "P60")); | |
| 1756 | memory_install_read8_handler(machine, 0, ADDRESS_SPACE_IO, 0x61, 0x61, 0x0000, 0xff00, input_port_read_handler8(machine->portconfig, "P61")); | |
| 1757 | memory_install_read8_handler(machine, 0, ADDRESS_SPACE_IO, 0x62, 0x62, 0x0000, 0xff00, input_port_read_handler8(machine->portconfig, "P62")); | |
| 1758 | memory_install_read8_handler(machine, 0, ADDRESS_SPACE_IO, 0x63, 0x63, 0x0000, 0xff00, input_port_read_handler8(machine->portconfig, "P63")); | |
| 1759 | memory_install_read8_handler(machine, 0, ADDRESS_SPACE_IO, 0x64, 0x64, 0x0000, 0xff00, input_port_read_handler8(machine->portconfig, "P64")); | |
| 1761 | 1760 | memory_install_write8_handler(machine, 0, ADDRESS_SPACE_IO, 0x65, 0x66, 0x0000, 0xff00, tenpindx_lamp_w); |
| 1762 | 1761 | memory_install_write8_handler(machine, 0, ADDRESS_SPACE_IO, 0x67, 0x67, 0x0000, 0xff00, tenpindx_counter_w); |
| 1763 | 1762 | memory_install_write8_handler(machine, 0, ADDRESS_SPACE_IO, 0x68, 0x68, 0x0000, 0xff00, tenpindx_lights_w); |
| r2724 | r2725 | |
|---|---|---|
| 404 | 404 | |
| 405 | 405 | /**********************************************************************************/ |
| 406 | 406 | |
| 407 | static void sound_irq_gen(int state) | |
| 407 | static void sound_irq_gen(running_machine *machine, int state) | |
| 408 | 408 | { |
| 409 | 409 | logerror("sound irq\n"); |
| 410 | 410 | } |
| r2724 | r2725 | |
|---|---|---|
| 35 | 35 | ***************************************************************************/ |
| 36 | 36 | |
| 37 | 37 | #include "driver.h" |
| 38 | #include "deprecat.h" | |
| 39 | 38 | #include "cpu/z80/z80.h" |
| 40 | 39 | #include "audio/seibu.h" |
| 41 | 40 | #include "sound/3812intf.h" |
| r2724 | r2725 | |
| 73 | 72 | |
| 74 | 73 | static int msm5205next; |
| 75 | 74 | |
| 76 | static void toki_adpcm_int (int data) | |
| 75 | static void toki_adpcm_int (running_machine *machine, int data) | |
| 77 | 76 | { |
| 78 | 77 | static int toggle=0; |
| 79 | 78 | |
| r2724 | r2725 | |
| 82 | 81 | |
| 83 | 82 | toggle ^= 1; |
| 84 | 83 | if (toggle) |
| 85 | cpunum_set_input_line( | |
| 84 | cpunum_set_input_line(machine, 1, INPUT_LINE_NMI, PULSE_LINE); | |
| 86 | 85 | } |
| 87 | 86 | |
| 88 | 87 | static WRITE8_HANDLER( toki_adpcm_control_w ) |
| r2724 | r2725 | |
|---|---|---|
| 765 | 765 | |
| 766 | 766 | |
| 767 | 767 | /* handler called by the 3526 emulator when the internal timers cause an IRQ */ |
| 768 | static void irqhandler(int linestate) | |
| 768 | static void irqhandler(running_machine *machine, int linestate) | |
| 769 | 769 | { |
| 770 | cpunum_set_input_line( | |
| 770 | cpunum_set_input_line(machine, 1, M6809_FIRQ_LINE, linestate); | |
| 771 | 771 | } |
| 772 | 772 | |
| 773 | 773 | static const struct YM3526interface ym3526_interface = |
| r2724 | r2725 | |
|---|---|---|
| 112 | 112 | ******************************************************/ |
| 113 | 113 | |
| 114 | 114 | #include "driver.h" |
| 115 | #include "deprecat.h" | |
| 116 | 115 | #include "sound/sn76496.h" |
| 117 | 116 | #include "video/tms9928a.h" |
| 118 | 117 | #include "machine/segacrpt.h" |
| r2724 | r2725 | |
| 244 | 243 | |
| 245 | 244 | static INTERRUPT_GEN( sg100a_interrupt ) |
| 246 | 245 | { |
| 247 | TMS9928A_interrupt(); | |
| 246 | TMS9928A_interrupt(machine); | |
| 248 | 247 | } |
| 249 | 248 | |
| 250 | static void vdp_interrupt (int state) | |
| 249 | static void vdp_interrupt (running_machine *machine, int state) | |
| 251 | 250 | { |
| 252 | cpunum_set_input_line( | |
| 251 | cpunum_set_input_line(machine, 0,0, HOLD_LINE); | |
| 253 | 252 | } |
| 254 | 253 | |
| 255 | 254 | static const TMS9928a_interface tms9928a_interface = |
| r2724 | r2725 | |
|---|---|---|
| 38 | 38 | static INPUT_CHANGED( coin_inserted ) |
| 39 | 39 | { |
| 40 | 40 | /* coin insertion causes an NMI */ |
| 41 | cpunum_set_input_line(machine, 0, INPUT_LINE_NMI, newval ? CLEAR_LINE : ASSERT_LINE); | |
| 41 | cpunum_set_input_line(field->port->machine, 0, INPUT_LINE_NMI, newval ? CLEAR_LINE : ASSERT_LINE); | |
| 42 | 42 | } |
| 43 | 43 | |
| 44 | 44 |
| r2724 | r2725 | |
|---|---|---|
| 535 | 535 | |
| 536 | 536 | |
| 537 | 537 | |
| 538 | static void irqhandler(int irq) | |
| 538 | static void irqhandler(running_machine *machine, int irq) | |
| 539 | 539 | { |
| 540 | cpunum_set_input_line( | |
| 540 | cpunum_set_input_line(machine, 1,0,irq ? ASSERT_LINE : CLEAR_LINE); | |
| 541 | 541 | } |
| 542 | 542 | |
| 543 | 543 | static const struct YM2203interface ym2203_interface = |
| r2724 | r2725 | |
|---|---|---|
| 128 | 128 | |
| 129 | 129 | |
| 130 | 130 | #include "driver.h" |
| 131 | #include "deprecat.h" | |
| 132 | 131 | #include "taitoipt.h" |
| 133 | 132 | #include "audio/taitosnd.h" |
| 134 | 133 | #include "video/taitoic.h" |
| r2724 | r2725 | |
| 159 | 158 | ***************************************************************************/ |
| 160 | 159 | |
| 161 | 160 | /* Handler called by the YM2610 emulator when the internal timers cause an IRQ */ |
| 162 | static void irqhandler(int irq) | |
| 161 | static void irqhandler(running_machine *machine, int irq) | |
| 163 | 162 | { |
| 164 | cpunum_set_input_line( | |
| 163 | cpunum_set_input_line(machine, 1,0,irq ? ASSERT_LINE : CLEAR_LINE); | |
| 165 | 164 | } |
| 166 | 165 | |
| 167 | 166 | static const struct YM2610interface syvalion_ym2610_interface = |
| r2724 | r2725 | |
|---|---|---|
| 89 | 89 | #include "machine/mb14241.h" |
| 90 | 90 | |
| 91 | 91 | #include "invrvnge.lh" |
| 92 | #include "shuttlei.lh" | |
| 92 | 93 | |
| 93 | 94 | /*******************************************************/ |
| 94 | 95 | /* */ |
| r2724 | r2725 | |
| 1412 | 1413 | case 0x5ffc: return 0; |
| 1413 | 1414 | } |
| 1414 | 1415 | logerror("unknown port 0 read @ %x\n",activecpu_get_pc()); |
| 1415 | return mame_rand( | |
| 1416 | return mame_rand(machine); | |
| 1416 | 1417 | } |
| 1417 | 1418 | |
| 1418 | 1419 | static ADDRESS_MAP_START( indianbt_io_map, ADDRESS_SPACE_IO, 8 ) |
| r2724 | r2725 | |
| 2380 | 2381 | GAME( 1979, spaceph, ozmawars, invaders, spaceph, 0, ROT270, "Zilec Games", "Space Phantoms", 0 ) |
| 2381 | 2382 | GAME( 1979, yosakdon, 0, yosakdon, yosakdon, 0, ROT270, "Wing", "Yosaku To Donbei (set 1)", GAME_IMPERFECT_SOUND ) /* bootleg? */ |
| 2382 | 2383 | GAME( 1979, yosakdoa, yosakdon, yosakdon, yosakdon, 0, ROT270, "Wing", "Yosaku To Donbei (set 2)", GAME_IMPERFECT_SOUND ) /* bootleg? */ |
| 2383 | GAME( | |
| 2384 | GAMEL( |
| r2724 | r2725 | |
|---|---|---|
| 231 | 231 | ***************************************************************************/ |
| 232 | 232 | |
| 233 | 233 | #include "driver.h" |
| 234 | #include "deprecat.h" | |
| 235 | 234 | #include "taitoipt.h" |
| 236 | 235 | #include "cpu/m68000/m68000.h" |
| 237 | 236 | #include "machine/eeprom.h" |
| r2724 | r2725 | |
| 257 | 256 | last_irq_level = 0; |
| 258 | 257 | } |
| 259 | 258 | |
| 260 | static void update_irq( | |
| 259 | static void update_irq(running_machine *machine) | |
| 261 | 260 | { |
| 262 | 261 | int curr_level; |
| 263 | 262 | |
| r2724 | r2725 | |
| 270 | 269 | |
| 271 | 270 | if (curr_level != last_irq_level) |
| 272 | 271 | { |
| 273 | cpunum_set_input_line( | |
| 272 | cpunum_set_input_line(machine, 0,curr_level,curr_level ? ASSERT_LINE : CLEAR_LINE); | |
| 274 | 273 | last_irq_level = curr_level; |
| 275 | 274 | } |
| 276 | 275 | } |
| r2724 | r2725 | |
| 288 | 287 | break; |
| 289 | 288 | } |
| 290 | 289 | |
| 291 | update_irq(); | |
| 290 | update_irq(machine); | |
| 292 | 291 | } |
| 293 | 292 | |
| 294 | 293 | static INTERRUPT_GEN( vblank_interrupt ) |
| 295 | 294 | { |
| 296 | 295 | vblank_irq = 1; |
| 297 | update_irq(); | |
| 296 | update_irq(machine); | |
| 298 | 297 | } |
| 299 | 298 | |
| 300 | 299 | static TIMER_CALLBACK( ad_interrupt ) |
| 301 | 300 | { |
| 302 | 301 | ad_irq = 1; |
| 303 | update_irq(); | |
| 302 | update_irq(machine); | |
| 304 | 303 | } |
| 305 | 304 | |
| 306 | 305 | |
| r2724 | r2725 | |
| 685 | 684 | **************************************************************/ |
| 686 | 685 | |
| 687 | 686 | /* handler called by the YM2610 emulator when the internal timers cause an IRQ */ |
| 688 | static void irqhandler(int irq) | |
| 687 | static void irqhandler(running_machine *machine, int irq) | |
| 689 | 688 | { |
| 690 | cpunum_set_input_line( | |
| 689 | cpunum_set_input_line(machine, 1,0,irq ? ASSERT_LINE : CLEAR_LINE); | |
| 691 | 690 | } |
| 692 | 691 | |
| 693 | 692 | static const struct YM2610interface ym2610_interface = |
| r2724 | r2725 | |
|---|---|---|
| 10 | 10 | ***************************************************************************/ |
| 11 | 11 | |
| 12 | 12 | #include "driver.h" |
| 13 | #include "deprecat.h" | |
| 14 | 13 | #include "video/konamiic.h" |
| 15 | 14 | #include "cpu/z80/z80.h" |
| 16 | 15 | #include "sound/2608intf.h" |
| r2724 | r2725 | |
| 217 | 216 | |
| 218 | 217 | |
| 219 | 218 | |
| 220 | static void irqhandler(int irq) | |
| 219 | static void irqhandler(running_machine *machine, int irq) | |
| 221 | 220 | { |
| 222 | cpunum_set_input_line( | |
| 221 | cpunum_set_input_line(machine, 1,0,irq ? ASSERT_LINE : CLEAR_LINE); | |
| 223 | 222 | } |
| 224 | 223 | |
| 225 | 224 | static const struct YM2608interface ym2608_interface = |
| 226 | 225 | { |
| 227 | 226 | { |
| 228 | AY8910_LEGACY_OUTPUT, | |
| 227 | AY8910_LEGACY_OUTPUT | AY8910_SINGLE_OUTPUT, | |
| 229 | 228 | AY8910_DEFAULT_LOADS, |
| 230 | 229 | NULL, |
| 231 | 230 | NULL, |
| r2724 | r2725 | |
|---|---|---|
| 216 | 216 | |
| 217 | 217 | static void meritm_microtouch_tx_callback(UINT8 data) |
| 218 | 218 | { |
| 219 | pc16552d_rx_data(0, 0, data); | |
| 219 | pc16552d_rx_data(Machine, 0, 0, data); | |
| 220 | 220 | }; |
| 221 | 221 | |
| 222 | 222 | /************************************* |
| r2724 | r2725 | |
| 271 | 271 | v9938_interrupt(1); |
| 272 | 272 | } |
| 273 | 273 | |
| 274 | static void meritm_vdp0_interrupt(int i) | |
| 274 | static void meritm_vdp0_interrupt(running_machine *machine, int i) | |
| 275 | 275 | { |
| 276 | 276 | if ( meritm_interrupt_vdp0_state != i ) |
| 277 | 277 | { |
| r2724 | r2725 | |
| 286 | 286 | } |
| 287 | 287 | } |
| 288 | 288 | |
| 289 | static void meritm_vdp1_interrupt(int i) | |
| 289 | static void meritm_vdp1_interrupt(running_machine *machine, int i) | |
| 290 | 290 | { |
| 291 | 291 | if ( meritm_interrupt_vdp1_state != i ) |
| 292 | 292 | { |
| r2724 | r2725 | |
| 730 | 730 | * |
| 731 | 731 | *************************************/ |
| 732 | 732 | |
| 733 | static void meritm_audio_pio_interrupt(int state) | |
| 733 | static void meritm_audio_pio_interrupt(running_machine *machine, int state) | |
| 734 | 734 | { |
| 735 | 735 | //logerror( "PIO(0) interrupt line: %d, V = %d, H = %d\n", state, video_screen_get_vpos(0), video_screen_get_hpos(0) ); |
| 736 | cpunum_set_input_line( | |
| 736 | cpunum_set_input_line(machine, 0, 0, state); | |
| 737 | 737 | } |
| 738 | 738 | |
| 739 | static void meritm_io_pio_interrupt(int state) | |
| 739 | static void meritm_io_pio_interrupt(running_machine *machine, int state) | |
| 740 | 740 | { |
| 741 | 741 | //logerror( "PIO(1) interrupt line: %d, V = %d, H = %d\n", state, video_screen_get_vpos(0), video_screen_get_hpos(0) ); |
| 742 | cpunum_set_input_line( | |
| 742 | cpunum_set_input_line(machine, 0, 0, state); | |
| 743 | 743 | } |
| 744 | 744 | |
| 745 | 745 |
| r2724 | r2725 | |
|---|---|---|
| 132 | 132 | ***************************************************************************/ |
| 133 | 133 | |
| 134 | 134 | #include "driver.h" |
| 135 | #include "deprecat.h" | |
| 136 | 135 | #include "cpu/m68000/m68000.h" |
| 137 | 136 | #include "video/taitoic.h" |
| 138 | 137 | #include "audio/taitosnd.h" |
| r2724 | r2725 | |
| 533 | 532 | **************************************************************/ |
| 534 | 533 | |
| 535 | 534 | /* handler called by the YM2610 emulator when the internal timers cause an IRQ */ |
| 536 | static void irqhandler(int irq) | |
| 535 | static void irqhandler(running_machine *machine, int irq) | |
| 537 | 536 | { |
| 538 | cpunum_set_input_line( | |
| 537 | cpunum_set_input_line(machine, 1,0,irq ? ASSERT_LINE : CLEAR_LINE); | |
| 539 | 538 | } |
| 540 | 539 | |
| 541 | 540 | static const struct YM2610interface ym2610_interface = |
| r2724 | r2725 | |
|---|---|---|
| 27 | 27 | |
| 28 | 28 | **********************************************************************/ |
| 29 | 29 | #include "driver.h" |
| 30 | #include "deprecat.h" | |
| 31 | 30 | #include "cpu/arm/arm.h" |
| 32 | 31 | |
| 33 | 32 | static UINT32 *ertictac_mainram; |
| r2724 | r2725 | |
| 80 | 79 | |
| 81 | 80 | static READ32_HANDLER(IRQRQB_r) |
| 82 | 81 | { |
| 83 | return mame_rand( | |
| 82 | return mame_rand(machine)&IRQMSKB; /* hack 0x20 - controls, 0x02 - ?sound? */ | |
| 84 | 83 | } |
| 85 | 84 | |
| 86 | 85 | static READ32_HANDLER(IRQMSKB_r) |
| r2724 | r2725 | |
|---|---|---|
| 1022 | 1022 | PORT_DIPNAME( 0x40, 0x00, DEF_STR( Unknown ) ) |
| 1023 | 1023 | PORT_DIPSETTING( 0x00, DEF_STR( Off ) ) |
| 1024 | 1024 | PORT_DIPSETTING( 0x40, DEF_STR( On ) ) |
| 1025 | PORT_ | |
| 1025 | PORT_DIPNAME( | |
| 1026 | 1026 | PORT_DIPSETTING( 0x00, DEF_STR( Off ) ) |
| 1027 | 1027 | PORT_DIPSETTING( 0x80, DEF_STR( On ) ) |
| 1028 | 1028 | |
| r2724 | r2725 | |
| 1049 | 1049 | PORT_DIPNAME( 0x40, 0x00, DEF_STR( Unknown ) ) |
| 1050 | 1050 | PORT_DIPSETTING( 0x00, DEF_STR( Off ) ) |
| 1051 | 1051 | PORT_DIPSETTING( 0x40, DEF_STR( On ) ) |
| 1052 | PORT_ | |
| 1052 | PORT_DIPNAME( | |
| 1053 | 1053 | PORT_DIPSETTING( 0x00, DEF_STR( Off ) ) |
| 1054 | 1054 | PORT_DIPSETTING( 0x80, DEF_STR( On ) ) |
| 1055 | 1055 | INPUT_PORTS_END |
| r2724 | r2725 | |
|---|---|---|
| 41 | 41 | ***************************************************************************/ |
| 42 | 42 | |
| 43 | 43 | #include "driver.h" |
| 44 | #include "deprecat.h" | |
| 45 | 44 | #include "cninja.h" |
| 46 | 45 | #include "cpu/h6280/h6280.h" |
| 47 | 46 | #include "deco16ic.h" |
| r2724 | r2725 | |
| 751 | 750 | cninja_irq_mask=0; |
| 752 | 751 | } |
| 753 | 752 | |
| 754 | static void sound_irq(int state) | |
| 753 | static void sound_irq(running_machine *machine, int state) | |
| 755 | 754 | { |
| 756 | cpunum_set_input_line( | |
| 755 | cpunum_set_input_line(machine, 1,1,state); /* IRQ 2 */ | |
| 757 | 756 | } |
| 758 | 757 | |
| 759 | static void sound_irq2(int state) | |
| 758 | static void sound_irq2(running_machine *machine, int state) | |
| 760 | 759 | { |
| 761 | cpunum_set_input_line( | |
| 760 | cpunum_set_input_line(machine, 1,0,state); | |
| 762 | 761 | } |
| 763 | 762 | |
| 764 | 763 | static WRITE8_HANDLER( sound_bankswitch_w ) |
| r2724 | r2725 | |
|---|---|---|
| 127 | 127 | ----------------------------------------------------------------*/ |
| 128 | 128 | |
| 129 | 129 | #include "driver.h" |
| 130 | #include "deprecat.h" | |
| 131 | 130 | |
| 132 | 131 | #include "cpu/sh2/sh2.h" |
| 133 | 132 | #include "machine/eeprom.h" |
| r2724 | r2725 | |
| 474 | 473 | AM_RANGE(0x06000000, 0x060fffff) AM_WRITE(SMH_RAM) AM_BASE(&ps4_ram) // work RAM |
| 475 | 474 | ADDRESS_MAP_END |
| 476 | 475 | |
| 477 | static void irqhandler(int linestate) | |
| 476 | static void irqhandler(running_machine *machine, int linestate) | |
| 478 | 477 | { |
| 479 | 478 | if (linestate) |
| 480 | cpunum_set_input_line( | |
| 479 | cpunum_set_input_line(machine, 0, 12, ASSERT_LINE); | |
| 481 | 480 | else |
| 482 | cpunum_set_input_line( | |
| 481 | cpunum_set_input_line(machine, 0, 12, CLEAR_LINE); | |
| 483 | 482 | } |
| 484 | 483 | |
| 485 | 484 | static const struct YMF278B_interface ymf278b_interface = |
| r2724 | r2725 | |
|---|---|---|
| 124 | 124 | |
| 125 | 125 | |
| 126 | 126 | #include "driver.h" |
| 127 | #include "deprecat.h" | |
| 128 | 127 | #include "cpu/tms32010/tms32010.h" |
| 129 | 128 | #include "twincobr.h" |
| 130 | 129 | #include "sound/3812intf.h" |
| r2724 | r2725 | |
| 443 | 442 | |
| 444 | 443 | |
| 445 | 444 | /* handler called by the 3812 emulator when the internal timers cause an IRQ */ |
| 446 | static void irqhandler(int linestate) | |
| 445 | static void irqhandler(running_machine *machine, int linestate) | |
| 447 | 446 | { |
| 448 | cpunum_set_input_line( | |
| 447 | cpunum_set_input_line(machine, 1,0,linestate); | |
| 449 | 448 | } |
| 450 | 449 | |
| 451 | 450 | static const struct YM3812interface ym3812_interface = |
| r2724 | r2725 | |
|---|---|---|
| 151 | 151 | PORT_DIPSETTING( 0x00, DEF_STR( Off ) ) |
| 152 | 152 | PORT_DIPSETTING( 0x40, DEF_STR( On ) ) |
| 153 | 153 | /* PORT_DIPNAME( 0x80, 0x00, "Free Run" ) */ |
| 154 | PORT_ | |
| 154 | PORT_DIPNAME( | |
| 155 | 155 | PORT_DIPSETTING( 0x00, DEF_STR( Off ) ) /* test mode, you are invulnerable */ |
| 156 | 156 | PORT_DIPSETTING( 0x80, DEF_STR( On ) ) /* to 'static' objects */ |
| 157 | 157 |
| r2724 | r2725 | |
|---|---|---|
| 31 | 31 | */ |
| 32 | 32 | |
| 33 | 33 | #include "driver.h" |
| 34 | #include "deprecat.h" | |
| 35 | 34 | #include "decocrpt.h" |
| 36 | 35 | #include "decoprot.h" |
| 37 | 36 | #include "deco16ic.h" |
| r2724 | r2725 | |
| 138 | 137 | |
| 139 | 138 | static READ16_HANDLER( random_readers ) |
| 140 | 139 | { |
| 141 | return mame_rand( | |
| 140 | return mame_rand(machine); | |
| 142 | 141 | } |
| 143 | 142 | |
| 144 | 143 | static READ16_HANDLER( mirage_input_r ) |
| r2724 | r2725 | |
|---|---|---|
| 239 | 239 | ******************************************************************************************/ |
| 240 | 240 | |
| 241 | 241 | #include "driver.h" |
| 242 | #include "deprecat.h" | |
| 243 | 242 | #include "sound/pokey.h" |
| 244 | 243 | |
| 245 | 244 | |
| r2724 | r2725 | |
| 328 | 327 | |
| 329 | 328 | static CUSTOM_INPUT( get_vblank ) |
| 330 | 329 | { |
| 331 | int v = scanline_to_v(video_screen_get_vpos(machine->primary_screen)); | |
| 330 | int v = scanline_to_v(video_screen_get_vpos(field->port->machine->primary_screen)); | |
| 332 | 331 | return v < 24; |
| 333 | 332 | } |
| 334 | 333 | |
| r2724 | r2725 | |
| 610 | 609 | |
| 611 | 610 | /* watchdog */ |
| 612 | 611 | else if (offset >= 0x4c00 && offset < 0x4d00) |
| 613 | watchdog_reset( | |
| 612 | watchdog_reset(machine); | |
| 614 | 613 | |
| 615 | 614 | /* interrupt ack */ |
| 616 | 615 | else if (offset >= 0x4d00 && offset < 0x4e00) |
| r2724 | r2725 | |
|---|---|---|
| 7 | 7 | ***************************************************************************/ |
| 8 | 8 | |
| 9 | 9 | #include "driver.h" |
| 10 | #include "deprecat.h" | |
| 11 | 10 | #include "cpu/m6809/m6809.h" |
| 12 | 11 | #include "sound/2203intf.h" |
| 13 | 12 | #include "sound/vlm5030.h" |
| r2724 | r2725 | |
| 91 | 90 | |
| 92 | 91 | static READ8_HANDLER( ddrible_vlm5030_busy_r ) |
| 93 | 92 | { |
| 94 | return mame_rand( | |
| 93 | return mame_rand(machine); /* patch */ | |
| 95 | 94 | /* FIXME: remove ? */ |
| 96 | 95 | #if 0 |
| 97 | 96 | if (VLM5030_BSY()) return 1; |
| r2724 | r2725 | |
|---|---|---|
| 36 | 36 | ***************************************************************************/ |
| 37 | 37 | |
| 38 | 38 | #include "driver.h" |
| 39 | #include "deprecat.h" | |
| 40 | 39 | #include "sound/2203intf.h" |
| 41 | 40 | #include "sound/2151intf.h" |
| 42 | 41 | |
| r2724 | r2725 | |
| 698 | 697 | GFXDECODE_END |
| 699 | 698 | |
| 700 | 699 | /* handler called by the 2203 emulator when the internal timers cause an IRQ */ |
| 701 | static void irqhandler(int irq) | |
| 700 | static void irqhandler(running_machine *machine, int irq) | |
| 702 | 701 | { |
| 703 | cpunum_set_input_line( | |
| 702 | cpunum_set_input_line(machine, 1,0,irq ? ASSERT_LINE : CLEAR_LINE); | |
| 704 | 703 | } |
| 705 | 704 | |
| 706 | 705 | static const struct YM2203interface ym2203_interface = |
| r2724 | r2725 | |
|---|---|---|
| 311 | 311 | ***************************************************************************/ |
| 312 | 312 | |
| 313 | 313 | #include "driver.h" |
| 314 | #include "deprecat.h" | |
| 315 | 314 | #include "taitoipt.h" |
| 316 | 315 | #include "audio/taitosnd.h" |
| 317 | 316 | #include "seta.h" |
| r2724 | r2725 | |
| 971 | 970 | /**************************************************************************/ |
| 972 | 971 | |
| 973 | 972 | /* handler called by the YM2610 emulator when the internal timers cause an IRQ */ |
| 974 | static void irqhandler(int irq) | |
| 973 | static void irqhandler(running_machine *machine, int irq) | |
| 975 | 974 | { |
| 976 | cpunum_set_input_line( | |
| 975 | cpunum_set_input_line(machine, 1,0,irq ? ASSERT_LINE : CLEAR_LINE); | |
| 977 | 976 | } |
| 978 | 977 | |
| 979 | 978 | static const struct YM2610interface ym2610_interface = |
| r2724 | r2725 | |
|---|---|---|
| 40 | 40 | ***************************************************************************/ |
| 41 | 41 | |
| 42 | 42 | #include "driver.h" |
| 43 | #include "deprecat.h" | |
| 44 | 43 | #include "cpu/h6280/h6280.h" |
| 45 | 44 | #include "decocrpt.h" |
| 46 | 45 | #include "sound/2151intf.h" |
| r2724 | r2725 | |
| 289 | 288 | |
| 290 | 289 | /***************************************************************************/ |
| 291 | 290 | |
| 292 | static void sound_irq(int state) | |
| 291 | static void sound_irq(running_machine *machine, int state) | |
| 293 | 292 | { |
| 294 | cpunum_set_input_line( | |
| 293 | cpunum_set_input_line(machine, 1,1,state); /* IRQ 2 */ | |
| 295 | 294 | } |
| 296 | 295 | |
| 297 | 296 | static const struct YM2151interface ym2151_interface = |
| r2724 | r2725 | |
|---|---|---|
| 5 | 5 | */ |
| 6 | 6 | |
| 7 | 7 | #include "driver.h" |
| 8 | #include "deprecat.h" | |
| 9 | 8 | #include "cpu/h6280/h6280.h" |
| 10 | 9 | #include "sound/2151intf.h" |
| 11 | 10 | #include "sound/okim6295.h" |
| r2724 | r2725 | |
| 186 | 185 | GFXDECODE_ENTRY( REGION_GFX2, 0, spritelayout, 512, 16 ) /* Sprites (16x16) */ |
| 187 | 186 | GFXDECODE_END |
| 188 | 187 | |
| 189 | static void sound_irq(int state) | |
| 188 | static void sound_irq(running_machine *machine, int state) | |
| 190 | 189 | { |
| 191 | cpunum_set_input_line( | |
| 190 | cpunum_set_input_line(machine, 1,1,state); /* IRQ 2 */ | |
| 192 | 191 | } |
| 193 | 192 | |
| 194 | 193 | static const struct YM2151interface ym2151_interface = |
| r2724 | r2725 | |
|---|---|---|
| 336 | 336 | port_tag = "GEARP2"; |
| 337 | 337 | |
| 338 | 338 | /* gear MUST be 1, 2 or 3 */ |
| 339 | if (input_port_read(machine, port_tag) & 0x01) kikstart_gears[player] = 0x02; | |
| 340 | if (input_port_read(machine, port_tag) & 0x02) kikstart_gears[player] = 0x03; | |
| 341 | if (input_port_read(machine, port_tag) & 0x04) kikstart_gears[player] = 0x01; | |
| 339 | if (input_port_read(field->port->machine, port_tag) & 0x01) kikstart_gears[player] = 0x02; | |
| 340 | if (input_port_read(field->port->machine, port_tag) & 0x02) kikstart_gears[player] = 0x03; | |
| 341 | if (input_port_read(field->port->machine, port_tag) & 0x04) kikstart_gears[player] = 0x01; | |
| 342 | 342 | |
| 343 | 343 | return kikstart_gears[player]; |
| 344 | 344 | } |
| r2724 | r2725 | |
|---|---|---|
| 28 | 28 | ***************************************************************************/ |
| 29 | 29 | |
| 30 | 30 | #include "driver.h" |
| 31 | #include "deprecat.h" | |
| 32 | 31 | #include "sound/dac.h" |
| 33 | 32 | #include "sound/3812intf.h" |
| 34 | 33 | |
| r2724 | r2725 | |
| 1023 | 1022 | |
| 1024 | 1023 | static READ8_HANDLER( youmab_8a_r ) |
| 1025 | 1024 | { |
| 1026 | return mame_rand( | |
| 1025 | return mame_rand(machine); | |
| 1027 | 1026 | } |
| 1028 | 1027 | |
| 1029 | 1028 | static WRITE8_HANDLER( youmab_81_w ) |
| r2724 | r2725 | |
|---|---|---|
| 186 | 186 | INPUT_PORTS_END |
| 187 | 187 | |
| 188 | 188 | /* handler called by the 2151 emulator when the internal timers cause an IRQ */ |
| 189 | static void blockout_irq_handler(int irq) | |
| 189 | static void blockout_irq_handler(running_machine *machine, int irq) | |
| 190 | 190 | { |
| 191 | cpunum_set_input_line_and_vector( | |
| 191 | cpunum_set_input_line_and_vector(machine, 1,0,irq ? ASSERT_LINE : CLEAR_LINE,0xff); | |
| 192 | 192 | } |
| 193 | 193 | |
| 194 | 194 | static const struct YM2151interface ym2151_interface = |
| r2724 | r2725 | |
|---|---|---|
| 563 | 563 | TS_IN2 |
| 564 | 564 | TS_DSW1 |
| 565 | 565 | |
| 566 | PORT_START_TAG("DSW | |
| 566 | PORT_START_TAG("DSW2") | |
| 567 | 567 | PORT_DIPNAME( 0x01, 0x00, DEF_STR( Unknown ) ) |
| 568 | 568 | PORT_DIPSETTING( 0x00, DEF_STR( Off ) ) |
| 569 | 569 | PORT_DIPSETTING( 0x01, DEF_STR( On ) ) |
| r2724 | r2725 | |
|---|---|---|
| 143 | 143 | adpcm_data = data; |
| 144 | 144 | } |
| 145 | 145 | |
| 146 | static void splash_msm5205_int(int data) | |
| 146 | static void splash_msm5205_int(running_machine *machine, int data) | |
| 147 | 147 | { |
| 148 | 148 | MSM5205_data_w(0,adpcm_data >> 4); |
| 149 | 149 | adpcm_data = (adpcm_data << 4) & 0xf0; |
| r2724 | r2725 | |
| 467 | 467 | MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.80) |
| 468 | 468 | MACHINE_DRIVER_END |
| 469 | 469 | |
| 470 | static void ym_irq(int state) | |
| 470 | static void ym_irq(running_machine *machine, int state) | |
| 471 | 471 | { |
| 472 | 472 | logerror("2203 IRQ: %d\n", state); |
| 473 | 473 | } |
| r2724 | r2725 | |
|---|---|---|
| 20 | 20 | ***************************************************************************/ |
| 21 | 21 | |
| 22 | 22 | #include "driver.h" |
| 23 | #include "deprecat.h" | |
| 24 | 23 | #include "video/konamiic.h" |
| 25 | 24 | #include "f1gp.h" |
| 26 | 25 | #include "sound/2610intf.h" |
| r2724 | r2725 | |
| 549 | 548 | |
| 550 | 549 | |
| 551 | 550 | |
| 552 | static void irqhandler(int irq) | |
| 551 | static void irqhandler(running_machine *machine, int irq) | |
| 553 | 552 | { |
| 554 | cpunum_set_input_line( | |
| 553 | cpunum_set_input_line(machine, 2,0,irq ? ASSERT_LINE : CLEAR_LINE); | |
| 555 | 554 | } |
| 556 | 555 | |
| 557 | 556 | static const struct YM2610interface ym2610_interface = |
| r2724 | r2725 | |
|---|---|---|
| 171 | 171 | */ |
| 172 | 172 | |
| 173 | 173 | #include "driver.h" |
| 174 | #include "deprecat.h" | |
| 175 | 174 | #include "machine/eeprom.h" |
| 176 | 175 | #include "cpu/m68000/m68k.h" |
| 177 | 176 | #include "sound/okim6295.h" |
| r2724 | r2725 | |
| 585 | 584 | */ |
| 586 | 585 | |
| 587 | 586 | |
| 588 | static void sound_irq(int irq) | |
| 587 | static void sound_irq(running_machine *machine, int irq) | |
| 589 | 588 | { |
| 590 | 589 | /* IRQ */ |
| 591 | cpunum_set_input_line( | |
| 590 | cpunum_set_input_line(machine, 1,0,irq ? ASSERT_LINE : CLEAR_LINE); | |
| 592 | 591 | } |
| 593 | 592 | |
| 594 | 593 | static const struct YMF262interface ymf262_interface = |
| r2724 | r2725 | |
|---|---|---|
| 79 | 79 | ***************************************************************************/ |
| 80 | 80 | |
| 81 | 81 | #include "driver.h" |
| 82 | #include "deprecat.h" | |
| 83 | 82 | #include "cpu/z80/z80.h" |
| 84 | 83 | #include "sound/samples.h" |
| 85 | 84 | |
| r2724 | r2725 | |
| 253 | 252 | |
| 254 | 253 | static READ8_HANDLER( polyplay_random_read ) |
| 255 | 254 | { |
| 256 | return mame_rand( | |
| 255 | return mame_rand(machine) & 0xff; | |
| 257 | 256 | } |
| 258 | 257 | |
| 259 | 258 | /* graphic structures */ |
| r2724 | r2725 | |
|---|---|---|
| 28 | 28 | ****************************************************************************/ |
| 29 | 29 | |
| 30 | 30 | #include "driver.h" |
| 31 | #include "deprecat.h" | |
| 32 | 31 | #include "taitoipt.h" |
| 33 | 32 | #include "audio/taitosnd.h" |
| 34 | 33 | #include "sound/2151intf.h" |
| r2724 | r2725 | |
| 311 | 310 | |
| 312 | 311 | |
| 313 | 312 | |
| 314 | static void irqhandler(int irq) | |
| 313 | static void irqhandler(running_machine *machine, int irq) | |
| 315 | 314 | { |
| 316 | cpunum_set_input_line( | |
| 315 | cpunum_set_input_line(machine, 1, 0, irq ? ASSERT_LINE : CLEAR_LINE); | |
| 317 | 316 | } |
| 318 | 317 | |
| 319 | 318 | static const struct YM2151interface ym2151_interface = |
| r2724 | r2725 | |
|---|---|---|
| 264 | 264 | { |
| 265 | 265 | /* if we got a coin, set the IRQ on the main CPU */ |
| 266 | 266 | if (newval == 0) |
| 267 | cpunum_set_input_line(machine, 0, 0, ASSERT_LINE); | |
| 267 | cpunum_set_input_line(field->port->machine, 0, 0, ASSERT_LINE); | |
| 268 | 268 | } |
| 269 | 269 | |
| 270 | 270 | |
| r2724 | r2725 | |
| 290 | 290 | static CUSTOM_INPUT( hitnmiss_button1_r ) |
| 291 | 291 | { |
| 292 | 292 | /* button 1 shows up in two bits */ |
| 293 | UINT32 button1 = input_port_read(machine, "HITNMISS_BUTTON1"); | |
| 293 | UINT32 button1 = input_port_read(field->port->machine, "HITNMISS_BUTTON1"); | |
| 294 | 294 | return (button1 << 1) | button1; |
| 295 | 295 | } |
| 296 | 296 |
| r2724 | r2725 | |
|---|---|---|
| 134 | 134 | */ |
| 135 | 135 | |
| 136 | 136 | #include "driver.h" |
| 137 | #include "deprecat.h" | |
| 138 | 137 | #include "genesis.h" |
| 139 | 138 | |
| 140 | 139 | |
| r2724 | r2725 | |
| 297 | 296 | |
| 298 | 297 | static READ16_HANDLER( vdp_fake_r ) |
| 299 | 298 | { |
| 300 | return mame_rand( | |
| 299 | return mame_rand(machine); | |
| 301 | 300 | } |
| 302 | 301 | |
| 303 | 302 | static DRIVER_INIT(topshoot) |
| r2724 | r2725 | |
|---|---|---|
| 119 | 119 | ***************************************************************************/ |
| 120 | 120 | |
| 121 | 121 | #include "driver.h" |
| 122 | #include "deprecat.h" | |
| 123 | 122 | #include "cpu/h6280/h6280.h" |
| 124 | 123 | #include "deco16ic.h" |
| 125 | 124 | #include "sound/2203intf.h" |
| r2724 | r2725 | |
| 532 | 531 | |
| 533 | 532 | /**********************************************************************************/ |
| 534 | 533 | |
| 535 | static void sound_irq(int state) | |
| 534 | static void sound_irq(running_machine *machine, int state) | |
| 536 | 535 | { |
| 537 | cpunum_set_input_line( | |
| 536 | cpunum_set_input_line(machine, 2,1,state); | |
| 538 | 537 | } |
| 539 | 538 | |
| 540 | 539 | static WRITE8_HANDLER( sound_bankswitch_w ) |
| r2724 | r2725 | |
|---|---|---|
| 2 | 2 | /* Nothing else is known about this set / game */ |
| 3 | 3 | |
| 4 | 4 | #include "driver.h" |
| 5 | #include "deprecat.h" | |
| 6 | 5 | |
| 7 | 6 | static VIDEO_START(gtipoker) |
| 8 | 7 | { |
| r2724 | r2725 | |
| 16 | 15 | |
| 17 | 16 | static READ8_HANDLER( gtipoker_unk_r ) |
| 18 | 17 | { |
| 19 | return mame_rand( | |
| 18 | return mame_rand(machine); | |
| 20 | 19 | } |
| 21 | 20 | |
| 22 | 21 | static ADDRESS_MAP_START( gtipoker_memmap, ADDRESS_SPACE_PROGRAM, 8 ) |
| r2724 | r2725 | |
|---|---|---|
| 138 | 138 | ***************************************************************************/ |
| 139 | 139 | |
| 140 | 140 | #include "driver.h" |
| 141 | #include "deprecat.h" | |
| 142 | 141 | #include "tatsumi.h" |
| 143 | 142 | #include "sound/2151intf.h" |
| 144 | 143 | #include "sound/okim6295.h" |
| r2724 | r2725 | |
| 806 | 805 | |
| 807 | 806 | /******************************************************************************/ |
| 808 | 807 | |
| 809 | static void sound_irq(int state) | |
| 808 | static void sound_irq(running_machine *machine, int state) | |
| 810 | 809 | { |
| 811 | cpunum_set_input_line( | |
| 810 | cpunum_set_input_line(machine, 2, INPUT_LINE_IRQ0, state); | |
| 812 | 811 | } |
| 813 | 812 | |
| 814 | 813 | static const struct YM2151interface ym2151_interface = |
| r2724 | r2725 | |
|---|---|---|
| 21 | 21 | ***************************************************************************/ |
| 22 | 22 | |
| 23 | 23 | #include "driver.h" |
| 24 | #include "deprecat.h" | |
| 25 | 24 | #include "cpu/h6280/h6280.h" |
| 26 | 25 | #include "sound/2151intf.h" |
| 27 | 26 | #include "sound/okim6295.h" |
| r2724 | r2725 | |
| 361 | 360 | |
| 362 | 361 | /******************************************************************************/ |
| 363 | 362 | |
| 364 | static void sound_irq(int state) | |
| 363 | static void sound_irq(running_machine *machine, int state) | |
| 365 | 364 | { |
| 366 | cpunum_set_input_line( | |
| 365 | cpunum_set_input_line(machine, 1,1,state); /* IRQ 2 */ | |
| 367 | 366 | } |
| 368 | 367 | |
| 369 | 368 | static const struct YM2151interface ym2151_interface = |
| r2724 | r2725 | |
|---|---|---|
| 24 | 24 | ***************************************************************************/ |
| 25 | 25 | |
| 26 | 26 | #include "driver.h" |
| 27 | #include "deprecat.h" | |
| 28 | 27 | #include "sound/okim6295.h" |
| 29 | 28 | |
| 30 | 29 | /* Variables defined in video: */ |
| r2724 | r2725 | |
| 94 | 93 | static READ16_HANDLER( blmbycar_pot_wheel_r ) |
| 95 | 94 | { |
| 96 | 95 | return ((pot_wheel & 0x80) ? 0x04 : 0) | |
| 97 | (mame_rand( | |
| 96 | (mame_rand(machine) & 0x08); | |
| 98 | 97 | } |
| 99 | 98 | |
| 100 | 99 |
| r2724 | r2725 | |
|---|---|---|
| 18 | 18 | ***************************************************************************/ |
| 19 | 19 | |
| 20 | 20 | #include "driver.h" |
| 21 | #include "deprecat.h" | |
| 22 | 21 | #include "machine/6821pia.h" |
| 23 | 22 | #include "sound/sn76477.h" |
| 24 | 23 | |
| r2724 | r2725 | |
| 117 | 116 | * |
| 118 | 117 | *************************************/ |
| 119 | 118 | |
| 120 | static void main_cpu_irq(int state) | |
| 119 | static void main_cpu_irq(running_machine *machine, int state) | |
| 121 | 120 | { |
| 122 | 121 | int combined_state = pia_get_irq_a(0) | pia_get_irq_b(0); |
| 123 | 122 | |
| 124 | 123 | logerror("GEN IRQ: %x\n", combined_state); |
| 125 | cpunum_set_input_line( | |
| 124 | cpunum_set_input_line(machine, 0, 0, combined_state ? ASSERT_LINE : CLEAR_LINE); | |
| 126 | 125 | } |
| 127 | 126 | |
| 128 | 127 |
| r2724 | r2725 | |
|---|---|---|
| 207 | 207 | |
| 208 | 208 | static INPUT_CHANGED( coin_inserted ) |
| 209 | 209 | { |
| 210 | cpunum_set_input_line_and_vector(machine, 0, 0, (newval ? ASSERT_LINE : CLEAR_LINE), 0x82); | |
| 210 | cpunum_set_input_line_and_vector(field->port->machine, 0, 0, (newval ? ASSERT_LINE : CLEAR_LINE), 0x82); | |
| 211 | 211 | } |
| 212 | 212 | |
| 213 | 213 |
| r2724 | r2725 | |
|---|---|---|
| 235 | 235 | } |
| 236 | 236 | |
| 237 | 237 | |
| 238 | static void srmp2_adpcm_int(int num) | |
| 238 | static void srmp2_adpcm_int(running_machine *machine, int num) | |
| 239 | 239 | { |
| 240 | 240 | UINT8 *ROM = memory_region(REGION_SOUND1); |
| 241 | 241 |
| r2724 | r2725 | |
|---|---|---|
| 72 | 72 | * |
| 73 | 73 | *************************************/ |
| 74 | 74 | |
| 75 | static void main_cpu_irq(int state) | |
| 75 | static void main_cpu_irq(running_machine *machine, int state) | |
| 76 | 76 | { |
| 77 | 77 | int combined_state = pia_get_irq_a(0) | pia_get_irq_b(0) | |
| 78 | 78 | pia_get_irq_a(1) | pia_get_irq_b(1); |
| 79 | 79 | |
| 80 | cpunum_set_input_line( | |
| 80 | cpunum_set_input_line(machine, 0, M6809_IRQ_LINE, combined_state ? ASSERT_LINE : CLEAR_LINE); | |
| 81 | 81 | } |
| 82 | 82 | |
| 83 | 83 |
| r2724 | r2725 | |
|---|---|---|
| 34 | 34 | ***************************************************************************/ |
| 35 | 35 | |
| 36 | 36 | #include "driver.h" |
| 37 | #include "deprecat.h" | |
| 38 | 37 | #include "cpu/z80/z80.h" |
| 39 | 38 | #include "sound/3812intf.h" |
| 40 | 39 | #include "sound/upd7759.h" |
| r2724 | r2725 | |
| 678 | 677 | |
| 679 | 678 | /******************************************************************************/ |
| 680 | 679 | |
| 681 | static void irqhandler(int irq) | |
| 680 | static void irqhandler(running_machine *machine, int irq) | |
| 682 | 681 | { |
| 683 | cpunum_set_input_line( | |
| 682 | cpunum_set_input_line(machine, 1,0,irq ? ASSERT_LINE : CLEAR_LINE); | |
| 684 | 683 | } |
| 685 | 684 | |
| 686 | 685 | static const struct YM3812interface ym3812_interface = |
| r2724 | r2725 | |
|---|---|---|
| 22 | 22 | static INPUT_CHANGED( coin_inserted ) |
| 23 | 23 | { |
| 24 | 24 | /* coin insertion causes an NMI */ |
| 25 | cpunum_set_input_line(machine, 0, INPUT_LINE_NMI, newval ? CLEAR_LINE : ASSERT_LINE); | |
| 25 | cpunum_set_input_line(field->port->machine, 0, INPUT_LINE_NMI, newval ? CLEAR_LINE : ASSERT_LINE); | |
| 26 | 26 | } |
| 27 | 27 | |
| 28 | 28 |
| r2724 | r2725 | |
|---|---|---|
| 287 | 287 | } |
| 288 | 288 | } |
| 289 | 289 | |
| 290 | static void scsi_irq( | |
| 290 | static void scsi_irq(running_machine *machine) | |
| 291 | 291 | { |
| 292 | psx_irq_set(0x400); | |
| 292 | psx_irq_set(machine, 0x400); | |
| 293 | 293 | } |
| 294 | 294 | |
| 295 | 295 | static const SCSIConfigTable dev_table = |
| r2724 | r2725 | |
|---|---|---|
| 220 | 220 | |
| 221 | 221 | static int msm5205next; |
| 222 | 222 | |
| 223 | static void firetrap_adpcm_int (int data) | |
| 223 | static void firetrap_adpcm_int (running_machine *machine, int data) | |
| 224 | 224 | { |
| 225 | 225 | static int toggle=0; |
| 226 | 226 | |
| r2724 | r2725 | |
| 229 | 229 | |
| 230 | 230 | toggle ^= 1; |
| 231 | 231 | if (firetrap_irq_enable && toggle) |
| 232 | cpunum_set_input_line ( | |
| 232 | cpunum_set_input_line (machine, 1, M6502_IRQ_LINE, HOLD_LINE); | |
| 233 | 233 | } |
| 234 | 234 | |
| 235 | 235 | static WRITE8_HANDLER( firetrap_adpcm_data_w ) |
| r2724 | r2725 | |
|---|---|---|
| 169 | 169 | * |
| 170 | 170 | *************************************/ |
| 171 | 171 | |
| 172 | static void vck_callback(int data) | |
| 172 | static void vck_callback(running_machine *machine, int data) | |
| 173 | 173 | { |
| 174 | 174 | /* only play back if we have data remaining */ |
| 175 | 175 | if (sample_count != 0xff) |
| r2724 | r2725 | |
|---|---|---|
| 434 | 434 | */ |
| 435 | 435 | |
| 436 | 436 | #include "driver.h" |
| 437 | #include "deprecat.h" | |
| 438 | 437 | #include "sound/saa1099.h" |
| 439 | 438 | #include "sound/msm5205.h" |
| 440 | 439 | |
| r2724 | r2725 | |
| 634 | 633 | mastboy_m5205_next = data; |
| 635 | 634 | } |
| 636 | 635 | |
| 637 | static void mastboy_adpcm_int(int data) | |
| 636 | static void mastboy_adpcm_int(running_machine *machine, int data) | |
| 638 | 637 | { |
| 639 | 638 | MSM5205_data_w (0,mastboy_m5205_next); |
| 640 | 639 | mastboy_m5205_next>>=4; |
| 641 | 640 | |
| 642 | 641 | mastboy_m5205_part ^= 1; |
| 643 | 642 | if(!mastboy_m5205_part) |
| 644 | | |
| 643 | | |
| 645 | 644 | } |
| 646 | 645 | |
| 647 | 646 |
| r2724 | r2725 | |
|---|---|---|
| 321 | 321 | |
| 322 | 322 | ***************************************************************************/ |
| 323 | 323 | |
| 324 | static void irqhandler(int irq) | |
| 324 | static void irqhandler(running_machine *machine, int irq) | |
| 325 | 325 | { |
| 326 | cpunum_set_input_line( | |
| 326 | cpunum_set_input_line(machine, 1,0,irq ? ASSERT_LINE : CLEAR_LINE); | |
| 327 | 327 | } |
| 328 | 328 | |
| 329 | 329 | static const struct YM2203interface thedeep_ym2203_intf = |
| r2724 | r2725 | |
|---|---|---|
| 30 | 30 | */ |
| 31 | 31 | |
| 32 | 32 | #include "driver.h" |
| 33 | #include "deprecat.h" | |
| 34 | 33 | #include "sound/okim6295.h" |
| 35 | 34 | #include "sound/3812intf.h" |
| 36 | 35 | |
| r2724 | r2725 | |
| 357 | 356 | GFXDECODE_ENTRY( REGION_GFX1, 0, oneshot8x8_layout, 0x00, 4 ) /* sprites */ |
| 358 | 357 | GFXDECODE_END |
| 359 | 358 | |
| 360 | static void irq_handler(int irq) | |
| 359 | static void irq_handler(running_machine *machine, int irq) | |
| 361 | 360 | { |
| 362 | cpunum_set_input_line( | |
| 361 | cpunum_set_input_line(machine, 1, 0, irq ? ASSERT_LINE : CLEAR_LINE); | |
| 363 | 362 | } |
| 364 | 363 | |
| 365 | 364 | static const struct YM3812interface ym3812_interface = |
| r2724 | r2725 | |
|---|---|---|
| 377 | 377 | switch (offset) |
| 378 | 378 | { |
| 379 | 379 | case 0x0: |
| 380 | return (mame_rand( | |
| 380 | return (mame_rand(machine) &0xff); /* motor status ?? */ | |
| 381 | 381 | |
| 382 | 382 | case 0x101: |
| 383 | 383 | return 0x55; /* motor cpu status ? */ |
| r2724 | r2725 | |
| 416 | 416 | |
| 417 | 417 | static int adpcm_pos; |
| 418 | 418 | |
| 419 | static void topspeed_msm5205_vck(int chip) | |
| 419 | static void topspeed_msm5205_vck(running_machine *machine, int chip) | |
| 420 | 420 | { |
| 421 | 421 | static int adpcm_data = -1; |
| 422 | 422 | |
| r2724 | r2725 | |
| 657 | 657 | |
| 658 | 658 | /* handler called by the YM2151 emulator when the internal timers cause an IRQ */ |
| 659 | 659 | |
| 660 | static void irq_handler(int irq) /* assumes Z80 sandwiched between 68Ks */ | |
| 660 | static void irq_handler(running_machine *machine, int irq) /* assumes Z80 sandwiched between 68Ks */ | |
| 661 | 661 | { |
| 662 | cpunum_set_input_line( | |
| 662 | cpunum_set_input_line(machine, 1,0,irq ? ASSERT_LINE : CLEAR_LINE); | |
| 663 | 663 | } |
| 664 | 664 | |
| 665 | 665 | static const struct YM2151interface ym2151_interface = |
| r2724 | r2725 | |
|---|---|---|
| 659 | 659 | |
| 660 | 660 | /*****************************************************************************/ |
| 661 | 661 | |
| 662 | static void sound_irq_callback(int irq) | |
| 662 | static void sound_irq_callback(running_machine *machine, int irq) | |
| 663 | 663 | { |
| 664 | 664 | if (irq == 0) |
| 665 | cpunum_set_input_line( | |
| 665 | cpunum_set_input_line(machine, 1, INPUT_LINE_IRQ1, PULSE_LINE); | |
| 666 | 666 | else |
| 667 | cpunum_set_input_line( | |
| 667 | cpunum_set_input_line(machine, 1, INPUT_LINE_IRQ2, PULSE_LINE); | |
| 668 | 668 | } |
| 669 | 669 | |
| 670 | 670 | static DRIVER_INIT(zr107) |
| r2724 | r2725 | |
|---|---|---|
| 14 | 14 | ***************************************************************************/ |
| 15 | 15 | |
| 16 | 16 | #include "driver.h" |
| 17 | #include "deprecat.h" | |
| 18 | 17 | #include "sound/2151intf.h" |
| 19 | 18 | |
| 20 | 19 | /* Variables & functions defined in video: */ |
| r2724 | r2725 | |
| 240 | 239 | ***************************************************************************/ |
| 241 | 240 | |
| 242 | 241 | |
| 243 | static void irq_handler(int irq) | |
| 242 | static void irq_handler(running_machine *machine, int irq) | |
| 244 | 243 | { |
| 245 | cpunum_set_input_line( | |
| 244 | cpunum_set_input_line(machine, 1,0,irq ? ASSERT_LINE : CLEAR_LINE); | |
| 246 | 245 | } |
| 247 | 246 | |
| 248 | 247 | static const struct YM2151interface amspdwy_ym2151_interface = |
| r2724 | r2725 | |
|---|---|---|
| 44 | 44 | ***************************************************************************************/ |
| 45 | 45 | |
| 46 | 46 | #include "driver.h" |
| 47 | #include "deprecat.h" | |
| 48 | 47 | #include "sound/2151intf.h" |
| 49 | 48 | #include "sound/3812intf.h" |
| 50 | 49 | #include "sound/dac.h" |
| r2724 | r2725 | |
| 335 | 334 | } |
| 336 | 335 | } |
| 337 | 336 | |
| 338 | static void borntofi_adpcm_int(int voice) | |
| 337 | static void borntofi_adpcm_int(running_machine *machine, int voice) | |
| 339 | 338 | { |
| 340 | 339 | UINT8 *rom; |
| 341 | 340 | size_t len; |
| r2724 | r2725 | |
| 696 | 695 | static CUSTOM_INPUT( wheelrun_wheel_r ) |
| 697 | 696 | { |
| 698 | 697 | int player = (FPTR)param; |
| 699 | int delta = input_port_read_indexed(machine, 4 + player); | |
| 698 | int delta = input_port_read_indexed(field->port->machine, 4 + player); | |
| 700 | 699 | delta = (delta & 0x7f) - (delta & 0x80) + 4; |
| 701 | 700 | |
| 702 | 701 | if (delta > 7) delta = 7; |
| r2724 | r2725 | |
| 849 | 848 | MACHINE_DRIVER_END |
| 850 | 849 | |
| 851 | 850 | |
| 852 | static void galaxygn_sound_irq(int line) | |
| 851 | static void galaxygn_sound_irq(running_machine *machine, int line) | |
| 853 | 852 | { |
| 854 | cpunum_set_input_line_and_vector( | |
| 853 | cpunum_set_input_line_and_vector(machine, 1, 0, line ? ASSERT_LINE : CLEAR_LINE, 0x80/4); | |
| 855 | 854 | } |
| 856 | 855 | |
| 857 | 856 | static const struct YM2151interface galaxygn_ym2151_interface = |
| r2724 | r2725 | |
| 949 | 948 | |
| 950 | 949 | |
| 951 | 950 | |
| 952 | static void wheelrun_ym3526_irqhandler(int state) | |
| 951 | static void wheelrun_ym3526_irqhandler(running_machine *machine, int state) | |
| 953 | 952 | { |
| 954 | cpunum_set_input_line( | |
| 953 | cpunum_set_input_line(machine, 1, INPUT_LINE_IRQ0, state); | |
| 955 | 954 | } |
| 956 | 955 | |
| 957 | 956 | static const struct YM3526interface wheelrun_ym3526_interface = |
| r2724 | r2725 | |
|---|---|---|
| 518 | 518 | atapi_regs[ATAPI_REG_INTREASON] = ATAPI_INTREASON_IO | ATAPI_INTREASON_COMMAND; |
| 519 | 519 | } |
| 520 | 520 | |
| 521 | psx_irq_set(0x400); | |
| 521 | psx_irq_set(machine, 0x400); | |
| 522 | 522 | |
| 523 | 523 | verboselog( 2, "atapi_xfer_end: %d %d\n", atapi_xferlen, atapi_xfermod ); |
| 524 | 524 | } |
| r2724 | r2725 | |
| 568 | 568 | atapi_regs[ATAPI_REG_COUNTLOW] = atapi_xferlen & 0xff; |
| 569 | 569 | atapi_regs[ATAPI_REG_COUNTHIGH] = (atapi_xferlen>>8)&0xff; |
| 570 | 570 | |
| 571 | psx_irq_set(0x400); | |
| 571 | psx_irq_set(machine, 0x400); | |
| 572 | 572 | } |
| 573 | 573 | |
| 574 | 574 | if( atapi_data_ptr < atapi_data_len ) |
| r2724 | r2725 | |
| 585 | 585 | { |
| 586 | 586 | atapi_regs[ATAPI_REG_CMDSTATUS] = 0; |
| 587 | 587 | atapi_regs[ATAPI_REG_INTREASON] = ATAPI_INTREASON_IO; |
| 588 | psx_irq_set(0x400); | |
| 588 | psx_irq_set(machine, 0x400); | |
| 589 | 589 | } |
| 590 | 590 | } |
| 591 | 591 | } |
| r2724 | r2725 | |
| 667 | 667 | SCSIWriteData( inserted_cdrom, atapi_data, atapi_cdata_wait ); |
| 668 | 668 | |
| 669 | 669 | // assert IRQ |
| 670 | psx_irq_set(0x400); | |
| 670 | psx_irq_set(machine, 0x400); | |
| 671 | 671 | |
| 672 | 672 | // not sure here, but clear DRQ at least? |
| 673 | 673 | atapi_regs[ATAPI_REG_CMDSTATUS] = 0; |
| r2724 | r2725 | |
| 740 | 740 | } |
| 741 | 741 | |
| 742 | 742 | // assert IRQ |
| 743 | psx_irq_set(0x400); | |
| 743 | psx_irq_set(machine, 0x400); | |
| 744 | 744 | } |
| 745 | 745 | else |
| 746 | 746 | { |
| r2724 | r2725 | |
| 857 | 857 | atapi_regs[ATAPI_REG_COUNTLOW] = 0; |
| 858 | 858 | atapi_regs[ATAPI_REG_COUNTHIGH] = 2; |
| 859 | 859 | |
| 860 | psx_irq_set(0x400); | |
| 860 | psx_irq_set(machine, 0x400); | |
| 861 | 861 | break; |
| 862 | 862 | |
| 863 | 863 | case 0xef: // SET FEATURES |
| r2724 | r2725 | |
| 866 | 866 | atapi_data_ptr = 0; |
| 867 | 867 | atapi_data_len = 0; |
| 868 | 868 | |
| 869 | psx_irq_set(0x400); | |
| 869 | psx_irq_set(machine, 0x400); | |
| 870 | 870 | break; |
| 871 | 871 | |
| 872 | 872 | default: |
| r2724 | r2725 | |
| 1221 | 1221 | if( ( m_p_n_root_mode[ n_counter ] & RC_IRQOVERFLOW ) != 0 || |
| 1222 | 1222 | ( m_p_n_root_mode[ n_counter ] & RC_IRQTARGET ) != 0 ) |
| 1223 | 1223 | { |
| 1224 | psx_irq_set( 0x10 << n_counter ); | |
| 1224 | psx_irq_set( machine, 0x10 << n_counter ); | |
| 1225 | 1225 | } |
| 1226 | 1226 | } |
| 1227 | 1227 | |
| r2724 | r2725 | |
| 1524 | 1524 | if( chiptype[ 0 ] != 0 ) |
| 1525 | 1525 | { |
| 1526 | 1526 | /* security cart */ |
| 1527 | psx_sio_input( 1, PSX_SIO_IN_DSR, PSX_SIO_IN_DSR ); | |
| 1527 | psx_sio_input( machine, 1, PSX_SIO_IN_DSR, PSX_SIO_IN_DSR ); | |
| 1528 | 1528 | } |
| 1529 | 1529 | |
| 1530 | 1530 | flash_bank = -1; |
| r2724 | r2725 | |
| 1880 | 1880 | |
| 1881 | 1881 | static CUSTOM_INPUT( gn845pwbb_read ) |
| 1882 | 1882 | { |
| 1883 | return input_port_read(machine, "STAGE" ) & stage_mask; | |
| 1883 | return input_port_read(field->port->machine, "STAGE" ) & stage_mask; | |
| 1884 | 1884 | } |
| 1885 | 1885 | |
| 1886 | 1886 | static void gn845pwbb_output_callback( int offset, int data ) |
| r2724 | r2725 | |
|---|---|---|
| 426 | 426 | INPUT_PORTS_END |
| 427 | 427 | |
| 428 | 428 | |
| 429 | static void livequiz_irqhandler | |
| 429 | static void livequiz_irqhandler | |
| 430 | 430 | { |
| 431 | 431 | logerror("YMZ280 is generating an interrupt. State=%08x\n",state); |
| 432 | 432 | } |
| r2724 | r2725 | |
|---|---|---|
| 561 | 561 | PORT_DIPSETTING( 0x0040, "45 sec" ) |
| 562 | 562 | PORT_DIPSETTING( 0x0060, "60 sec" ) |
| 563 | 563 | PORT_DIPSETTING( 0x0020, "90 sec" ) |
| 564 | PORT_ | |
| 564 | PORT_DIPNAME( 0x0080, | |
| 565 | 565 | PORT_DIPSETTING( 0x0080, DEF_STR( Off ) ) |
| 566 | 566 | PORT_DIPSETTING( 0x0000, DEF_STR( On ) ) |
| 567 | 567 | PORT_BIT( 0xff00, IP_ACTIVE_LOW, IPT_UNUSED ) |
| r2724 | r2725 | |
| 626 | 626 | PORT_DIPNAME( 0x0040, 0x0040, DEF_STR( Demo_Sounds ) ) |
| 627 | 627 | PORT_DIPSETTING( 0x0000, DEF_STR( Off ) ) |
| 628 | 628 | PORT_DIPSETTING( 0x0040, DEF_STR( On ) ) |
| 629 | PORT_ | |
| 629 | PORT_DIPNAME( 0x0080, | |
| 630 | 630 | PORT_DIPSETTING( 0x0080, DEF_STR( Off ) ) |
| 631 | 631 | PORT_DIPSETTING( 0x0000, DEF_STR( On ) ) |
| 632 | 632 | PORT_BIT( 0xff00, IP_ACTIVE_LOW, IPT_UNUSED ) |
| r2724 | r2725 | |
|---|---|---|
| 32 | 32 | ***************************************************************************/ |
| 33 | 33 | |
| 34 | 34 | #include "driver.h" |
| 35 | #include "deprecat.h" | |
| 36 | 35 | #include "cpu/i8085/i8085.h" |
| 37 | 36 | #include "cpu/i8039/i8039.h" |
| 38 | 37 | #include "sound/sn76496.h" |
| r2724 | r2725 | |
| 69 | 68 | static READ8_HANDLER( spcforce_t0_r ) |
| 70 | 69 | { |
| 71 | 70 | /* SN76496 status according to Al - not supported by MAME?? */ |
| 72 | return mame_rand( | |
| 71 | return mame_rand(machine) & 1; | |
| 73 | 72 | } |
| 74 | 73 | |
| 75 | 74 |
| r2724 | r2725 | |
|---|---|---|
| 220 | 220 | */ |
| 221 | 221 | |
| 222 | 222 | #include "driver.h" |
| 223 | #include "deprecat.h" | |
| 224 | 223 | #include "sound/okim6295.h" |
| 225 | 224 | #include "sound/3812intf.h" |
| 226 | 225 | |
| r2724 | r2725 | |
| 957 | 956 | GFXDECODE_END |
| 958 | 957 | |
| 959 | 958 | |
| 960 | static void soundirq(int state) | |
| 959 | static void soundirq(running_machine *machine, int state) | |
| 961 | 960 | { |
| 962 | cpunum_set_input_line( | |
| 961 | cpunum_set_input_line(machine, 1, 0, state); | |
| 963 | 962 | } |
| 964 | 963 | |
| 965 | 964 | static const struct YM3812interface ym3812_intf = |
| r2724 | r2725 | |
|---|---|---|
| 165 | 165 | ***************************************************************************/ |
| 166 | 166 | |
| 167 | 167 | #include "driver.h" |
| 168 | #include "deprecat.h" | |
| 169 | 168 | #include "video/konamiic.h" |
| 170 | 169 | #include "cpu/m6809/m6809.h" |
| 171 | 170 | #include "cpu/hd6309/hd6309.h" |
| r2724 | r2725 | |
| 270 | 269 | return 0xf; |
| 271 | 270 | } |
| 272 | 271 | |
| 273 | static void sound_nmi( | |
| 272 | static void sound_nmi(running_machine *machine) | |
| 274 | 273 | { |
| 275 | cpunum_set_input_line( | |
| 274 | cpunum_set_input_line(machine, 1, INPUT_LINE_NMI, PULSE_LINE); | |
| 276 | 275 | } |
| 277 | 276 | |
| 278 | 277 | static WRITE8_HANDLER( le_bankswitch_w ) |
| r2724 | r2725 | |
|---|---|---|
| 11 | 11 | *************************************************************************/ |
| 12 | 12 | |
| 13 | 13 | #include "driver.h" |
| 14 | #include "deprecat.h" | |
| 15 | 14 | #include "videopin.h" |
| 16 | 15 | #include "videopin.lh" |
| 17 | 16 | #include "sound/discrete.h" |
| r2724 | r2725 | |
| 37 | 36 | time_released = timer_get_time(); |
| 38 | 37 | |
| 39 | 38 | if (!mask) |
| 40 | cpunum_set_input_line( | |
| 39 | cpunum_set_input_line(machine, 0, INPUT_LINE_NMI, ASSERT_LINE); | |
| 41 | 40 | } |
| 42 | 41 | else |
| 43 | 42 | time_pushed = timer_get_time(); |
| r2724 | r2725 | |
|---|---|---|
| 61 | 61 | ***************************************************************************/ |
| 62 | 62 | |
| 63 | 63 | #include "driver.h" |
| 64 | #include "deprecat.h" | |
| 65 | 64 | #include "cpu/m6809/m6809.h" |
| 66 | 65 | #include "sound/2203intf.h" |
| 67 | 66 | #include "sound/3812intf.h" |
| r2724 | r2725 | |
| 274 | 273 | |
| 275 | 274 | |
| 276 | 275 | /* handler called by the 3812 emulator when the internal timers cause an IRQ */ |
| 277 | static void irqhandler(int linestate) | |
| 276 | static void irqhandler(running_machine *machine, int linestate) | |
| 278 | 277 | { |
| 279 | cpunum_set_input_line_and_vector( | |
| 278 | cpunum_set_input_line_and_vector(machine, 1,0,linestate,0xff); | |
| 280 | 279 | } |
| 281 | 280 | |
| 282 | 281 | static const struct YM3526interface ym3526_interface = |
| r2724 | r2725 | |
|---|---|---|
| 24 | 24 | ******************************************************************************/ |
| 25 | 25 | |
| 26 | 26 | #include "driver.h" |
| 27 | #include "deprecat.h" | |
| 28 | 27 | #include "cpu/m68000/m68000.h" |
| 29 | 28 | #include "cpu/z80/z80.h" |
| 30 | 29 | #include "sound/2151intf.h" |
| r2724 | r2725 | |
| 426 | 425 | |
| 427 | 426 | /******************************************************************************/ |
| 428 | 427 | |
| 429 | static void irqhandler(int irq) | |
| 428 | static void irqhandler(running_machine *machine, int irq) | |
| 430 | 429 | { |
| 431 | cpunum_set_input_line( | |
| 430 | cpunum_set_input_line(machine, 1,0,irq ? ASSERT_LINE : CLEAR_LINE); | |
| 432 | 431 | } |
| 433 | 432 | |
| 434 | 433 | static const struct YM2151interface ym2151_interface = |
| r2724 | r2725 | |
|---|---|---|
| 51 | 51 | */ |
| 52 | 52 | |
| 53 | 53 | #include "driver.h" |
| 54 | #include "deprecat.h" | |
| 55 | 54 | #include "sound/2610intf.h" |
| 56 | 55 | |
| 57 | 56 | static UINT16 *unkram; |
| r2724 | r2725 | |
| 180 | 179 | cpunum_set_input_line(machine, 0, 4, HOLD_LINE); |
| 181 | 180 | } |
| 182 | 181 | |
| 183 | static void irqhandler(int irq) | |
| 182 | static void irqhandler(running_machine *machine, int irq) | |
| 184 | 183 | { |
| 185 | cpunum_set_input_line( | |
| 184 | cpunum_set_input_line(machine, 0,5,irq ? ASSERT_LINE : CLEAR_LINE); | |
| 186 | 185 | } |
| 187 | 186 | |
| 188 | 187 | static const struct YM2610interface ym2610_interface = |
| r2724 | r2725 | |
|---|---|---|
| 262 | 262 | ***************************************************************************/ |
| 263 | 263 | |
| 264 | 264 | #include "driver.h" |
| 265 | #include "deprecat.h" | |
| 266 | 265 | #include "cpu/h6280/h6280.h" |
| 267 | 266 | #include "decocrpt.h" |
| 268 | 267 | #include "sound/2151intf.h" |
| r2724 | r2725 | |
| 719 | 718 | |
| 720 | 719 | static READ16_HANDLER( semibase_unknown_r ) |
| 721 | 720 | { |
| 722 | return mame_rand( | |
| 721 | return mame_rand(machine); | |
| 723 | 722 | } |
| 724 | 723 | static ADDRESS_MAP_START( htchctch_readmem, ADDRESS_SPACE_PROGRAM, 16 ) |
| 725 | 724 | AM_RANGE(0x000000, 0x0fffff) AM_READ(SMH_ROM) |
| r2724 | r2725 | |
| 2154 | 2153 | |
| 2155 | 2154 | |
| 2156 | 2155 | |
| 2157 | static void semicom_irqhandler(int irq) | |
| 2156 | static void semicom_irqhandler(running_machine *machine, int irq) | |
| 2158 | 2157 | { |
| 2159 | cpunum_set_input_line( | |
| 2158 | cpunum_set_input_line(machine, 1,0,irq ? ASSERT_LINE : CLEAR_LINE); | |
| 2160 | 2159 | } |
| 2161 | 2160 | |
| 2162 | 2161 |
| r2724 | r2725 | |
|---|---|---|
| 62 | 62 | |
| 63 | 63 | ***************************************************************************/ |
| 64 | 64 | #include "driver.h" |
| 65 | #include "deprecat.h" | |
| 66 | 65 | #include "cpu/z80/z80.h" |
| 67 | 66 | #include "sound/ay8910.h" |
| 68 | 67 | #include "sound/dac.h" |
| r2724 | r2725 | |
| 403 | 402 | cpunum_set_input_line(machine, 0, INPUT_LINE_NMI, PULSE_LINE); |
| 404 | 403 | } |
| 405 | 404 | |
| 406 | static void msmint( int data ) { | |
| 405 | static void msmint( running_machine *machine, int data ) { | |
| 407 | 406 | |
| 408 | 407 | static int counter = 0; |
| 409 | 408 | |
| r2724 | r2725 | |
| 416 | 415 | |
| 417 | 416 | if ( !( counter ^= 1 ) ) { |
| 418 | 417 | if ( sound_nmi_enable ) { |
| 419 | cpunum_set_input_line( | |
| 418 | cpunum_set_input_line(machine, 1, INPUT_LINE_NMI, PULSE_LINE ); | |
| 420 | 419 | } |
| 421 | 420 | } |
| 422 | 421 | } |
| r2724 | r2725 | |
|---|---|---|
| 28 | 28 | |
| 29 | 29 | static CUSTOM_INPUT( get_joystick ) |
| 30 | 30 | { |
| 31 | UINT8 joy = input_port_read(machine, param) & 3; | |
| 31 | UINT8 joy = input_port_read(field->port->machine, param) & 3; | |
| 32 | 32 | |
| 33 | 33 | if (joy == 1) |
| 34 | 34 | { |
| r2724 | r2725 | |
|---|---|---|
| 2767 | 2767 | **************************************************************/ |
| 2768 | 2768 | |
| 2769 | 2769 | /* handler called by the YM2610 emulator when the internal timers cause an IRQ */ |
| 2770 | static void irqhandler(int irq) // assumes Z80 sandwiched between 68Ks | |
| 2770 | static void irqhandler(running_machine *machine, int irq) // assumes Z80 sandwiched between 68Ks | |
| 2771 | 2771 | { |
| 2772 | cpunum_set_input_line( | |
| 2772 | cpunum_set_input_line(machine, 1,0,irq ? ASSERT_LINE : CLEAR_LINE); | |
| 2773 | 2773 | } |
| 2774 | 2774 | |
| 2775 | 2775 | /* handler called by the YM2610 emulator when the internal timers cause an IRQ */ |
| 2776 | static void irqhandlerb(int irq) | |
| 2776 | static void irqhandlerb(running_machine *machine, int irq) | |
| 2777 | 2777 | { |
| 2778 | 2778 | // DG: this is probably specific to Z80 and wrong? |
| 2779 | // cpunum_set_input_line( | |
| 2779 | // cpunum_set_input_line(machine, 1,0,irq ? ASSERT_LINE : CLEAR_LINE); | |
| 2780 | 2780 | } |
| 2781 | 2781 | |
| 2782 | 2782 | static const struct YM2610interface ym2610_interface = |
| r2724 | r2725 | |
|---|---|---|
| 1022 | 1022 | static DRIVER_INIT( condor ) |
| 1023 | 1023 | { |
| 1024 | 1024 | /* additional inputs for coinage */ |
| 1025 | memory_install_read8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x5000, 0x5000, 0, 0, port_ | |
| 1025 | memory_install_read8_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x5000, 0x5000, 0, 0, input_port_read_ | |
| 1026 | 1026 | } |
| 1027 | 1027 | |
| 1028 | 1028 | static DRIVER_INIT( survival ) |
| r2724 | r2725 | |
|---|---|---|
| 306 | 306 | { |
| 307 | 307 | // high byte: |
| 308 | 308 | // mask 0x1c: from sound? |
| 309 | return (mame_rand( | |
| 309 | return (mame_rand(machine) & 0x1c00) | input_port_read_indexed(machine, 0); | |
| 310 | 310 | } |
| 311 | 311 | |
| 312 | 312 | static READ16_HANDLER( lastfght_c00004_r ) |
| r2724 | r2725 | |
|---|---|---|
| 485 | 485 | { |
| 486 | 486 | // logerror("%04x: ay_port_a_r\n",activecpu_get_pc()); |
| 487 | 487 | /* bits 76------ MCU status bits */ |
| 488 | return (mame_rand( | |
| 488 | return (mame_rand(machine)&0xc0)|input_port_read_indexed(machine, 3); | |
| 489 | 489 | } |
| 490 | 490 | |
| 491 | 491 |
| r2724 | r2725 | |
|---|---|---|
| 10 | 10 | ***************************************************************************/ |
| 11 | 11 | |
| 12 | 12 | #include "driver.h" |
| 13 | #include "deprecat.h" | |
| 14 | 13 | #include "sound/2203intf.h" |
| 15 | 14 | #include "sound/flt_vol.h" |
| 16 | 15 | #include "lockon.h" |
| r2724 | r2725 | |
| 441 | 440 | flt_volume_set_volume(5, rgain); |
| 442 | 441 | } |
| 443 | 442 | |
| 444 | static void ym2203_irq(int irq) | |
| 443 | static void ym2203_irq(running_machine *machine, int irq) | |
| 445 | 444 | { |
| 446 | cpunum_set_input_line( | |
| 445 | cpunum_set_input_line(machine, SOUND_CPU, 0, irq ? ASSERT_LINE : CLEAR_LINE ); | |
| 447 | 446 | } |
| 448 | 447 | |
| 449 | 448 | static WRITE8_HANDLER( ym2203_out_b ) |
| r2724 | r2725 | |
|---|---|---|
| 1260 | 1260 | PORT_DIPNAME( 0x20, 0x20, DEF_STR( Demo_Sounds ) ) |
| 1261 | 1261 | PORT_DIPSETTING( 0x00, DEF_STR( Off ) ) |
| 1262 | 1262 | PORT_DIPSETTING( 0x20, DEF_STR( On ) ) |
| 1263 | PORT_ | |
| 1263 | PORT_DIPNAME( | |
| 1264 | 1264 | PORT_DIPSETTING( 0x40, DEF_STR( Off ) ) |
| 1265 | 1265 | PORT_DIPSETTING( 0x00, DEF_STR( On ) ) |
| 1266 | 1266 | PORT_DIPNAME( 0x80, 0x80, "Freeze" ) |
| r2724 | r2725 | |
|---|---|---|
| 159 | 159 | ***************************************************************************/ |
| 160 | 160 | |
| 161 | 161 | #include "driver.h" |
| 162 | #include "deprecat.h" | |
| 163 | 162 | #include "taitoipt.h" |
| 164 | 163 | #include "video/taitoic.h" |
| 165 | 164 | #include "audio/taitosnd.h" |
| r2724 | r2725 | |
| 187 | 186 | |
| 188 | 187 | static int adpcm_pos; |
| 189 | 188 | |
| 190 | static void rastan_msm5205_vck(int chip) | |
| 189 | static void rastan_msm5205_vck(running_machine *machine, int chip) | |
| 191 | 190 | { |
| 192 | 191 | static int adpcm_data = -1; |
| 193 | 192 | |
| r2724 | r2725 | |
| 359 | 358 | |
| 360 | 359 | |
| 361 | 360 | /* handler called by the YM2151 emulator when the internal timers cause an IRQ */ |
| 362 | static void irqhandler(int irq) | |
| 361 | static void irqhandler(running_machine *machine, int irq) | |
| 363 | 362 | { |
| 364 | cpunum_set_input_line( | |
| 363 | cpunum_set_input_line(machine, 1,0,irq ? ASSERT_LINE : CLEAR_LINE); | |
| 365 | 364 | } |
| 366 | 365 | |
| 367 | 366 | static const struct YM2151interface ym2151_interface = |
| r2724 | r2725 | |
|---|---|---|
| 121 | 121 | */ |
| 122 | 122 | |
| 123 | 123 | #include "driver.h" |
| 124 | #include "deprecat.h" | |
| 125 | 124 | #include "machine/eeprom.h" |
| 126 | 125 | |
| 127 | 126 | |
| r2724 | r2725 | |
| 275 | 274 | #ifdef UNUSED_FUNCTION |
| 276 | 275 | READ16_HANDLER ( pntnpuzl_random_r ) |
| 277 | 276 | { |
| 278 | return mame_rand( | |
| 277 | return mame_rand(machine); | |
| 279 | 278 | } |
| 280 | 279 | #endif |
| 281 | 280 |
| r2724 | r2725 | |
|---|---|---|
| 37 | 37 | ***************************************************************************/ |
| 38 | 38 | |
| 39 | 39 | #include "driver.h" |
| 40 | #include "deprecat.h" | |
| 41 | 40 | #include "video/konamiic.h" |
| 42 | 41 | #include "cpu/z80/z80.h" |
| 43 | 42 | #include "machine/eeprom.h" |
| r2724 | r2725 | |
| 199 | 198 | return soundlatch2_r(machine,0); |
| 200 | 199 | } |
| 201 | 200 | |
| 202 | static void sound_nmi( | |
| 201 | static void sound_nmi(running_machine *machine) | |
| 203 | 202 | { |
| 204 | cpunum_set_input_line( | |
| 203 | cpunum_set_input_line(machine, 1, INPUT_LINE_NMI, PULSE_LINE); | |
| 205 | 204 | } |
| 206 | 205 | |
| 207 | 206 | static MACHINE_START( gijoe ) |
| r2724 | r2725 | |
|---|---|---|
| 20 | 20 | ***************************************************************************/ |
| 21 | 21 | |
| 22 | 22 | #include "driver.h" |
| 23 | #include "deprecat.h" | |
| 24 | 23 | #include "cpu/z80/z80.h" |
| 25 | 24 | #include "sound/2203intf.h" |
| 26 | 25 | #include "sound/msm5205.h" |
| r2724 | r2725 | |
| 527 | 526 | |
| 528 | 527 | |
| 529 | 528 | /* handler called by the 2203 emulator when the internal timers cause an IRQ */ |
| 530 | static void irqhandler(int irq) | |
| 529 | static void irqhandler(running_machine *machine, int irq) | |
| 531 | 530 | { |
| 532 | cpunum_set_input_line( | |
| 531 | cpunum_set_input_line(machine, 1,0,irq ? ASSERT_LINE : CLEAR_LINE); | |
| 533 | 532 | } |
| 534 | 533 | |
| 535 | 534 | static const struct YM2203interface ym2203_interface = |
| r2724 | r2725 | |
|---|---|---|
| 52 | 52 | */ |
| 53 | 53 | |
| 54 | 54 | #include "driver.h" |
| 55 | #include "deprecat.h" | |
| 56 | 55 | #include "sound/ay8910.h" |
| 57 | 56 | #include "sound/dac.h" |
| 58 | 57 | #include "sound/5220intf.h" |
| r2724 | r2725 | |
| 330 | 329 | } |
| 331 | 330 | |
| 332 | 331 | |
| 333 | static void looping_spcint(int state) | |
| 332 | static void looping_spcint(running_machine *machine, int state) | |
| 334 | 333 | { |
| 335 | cpunum_set_input_line_and_vector( | |
| 334 | cpunum_set_input_line_and_vector(machine, 1, 0, state, 6); | |
| 336 | 335 | } |
| 337 | 336 | |
| 338 | 337 |
| r2724 | r2725 | |
|---|---|---|
| 292 | 292 | ***************************************************************************/ |
| 293 | 293 | |
| 294 | 294 | #include "driver.h" |
| 295 | #include "deprecat.h" | |
| 296 | 295 | #include "rendlay.h" |
| 297 | 296 | #include "segas32.h" |
| 298 | 297 | #include "machine/eeprom.h" |
| r2724 | r2725 | |
| 375 | 374 | * |
| 376 | 375 | *************************************/ |
| 377 | 376 | |
| 378 | static void signal_v60_irq(int data); | |
| 377 | static void signal_v60_irq(running_machine *machine, int data); | |
| 379 | 378 | static TIMER_CALLBACK( signal_v60_irq_callback ); |
| 380 | static void signal_sound_irq(int which); | |
| 379 | static void signal_sound_irq(running_machine *machine, int which); | |
| 381 | 380 | |
| 382 | 381 | |
| 383 | 382 | |
| r2724 | r2725 | |
| 408 | 407 | * |
| 409 | 408 | *************************************/ |
| 410 | 409 | |
| 411 | static void update_irq_state( | |
| 410 | static void update_irq_state(running_machine *machine) | |
| 412 | 411 | { |
| 413 | 412 | UINT8 effirq = v60_irq_control[7] & ~v60_irq_control[6] & 0x1f; |
| 414 | 413 | int vector; |
| r2724 | r2725 | |
| 418 | 417 | for (vector = 0; vector < 5; vector++) |
| 419 | 418 | if (effirq & (1 << vector)) |
| 420 | 419 | { |
| 421 | cpunum_set_input_line_and_vector( | |
| 420 | cpunum_set_input_line_and_vector(machine, 0, 0, ASSERT_LINE, vector); | |
| 422 | 421 | break; |
| 423 | 422 | } |
| 424 | 423 | |
| 425 | 424 | /* if we didn't find any, clear the interrupt line */ |
| 426 | 425 | if (vector == 5) |
| 427 | cpunum_set_input_line( | |
| 426 | cpunum_set_input_line(machine, 0, 0, CLEAR_LINE); | |
| 428 | 427 | } |
| 429 | 428 | |
| 430 | 429 | |
| 431 | static void signal_v60_irq(int which) | |
| 430 | static void signal_v60_irq(running_machine *machine, int which) | |
| 432 | 431 | { |
| 433 | 432 | int i; |
| 434 | 433 | |
| r2724 | r2725 | |
| 436 | 435 | for (i = 0; i < 5; i++) |
| 437 | 436 | if (v60_irq_control[i] == which) |
| 438 | 437 | v60_irq_control[7] |= 1 << i; |
| 439 | update_irq_state(); | |
| 438 | update_irq_state(machine); | |
| 440 | 439 | } |
| 441 | 440 | |
| 442 | 441 | |
| 443 | 442 | static TIMER_CALLBACK( signal_v60_irq_callback ) |
| 444 | 443 | { |
| 445 | signal_v60_irq(param); | |
| 444 | signal_v60_irq(machine, param); | |
| 446 | 445 | } |
| 447 | 446 | |
| 448 | 447 | |
| 449 | static void int_control_w(int offset, UINT8 data) | |
| 448 | static void int_control_w(running_machine *machine, int offset, UINT8 data) | |
| 450 | 449 | { |
| 451 | 450 | int duration; |
| 452 | 451 | |
| r2724 | r2725 | |
| 467 | 466 | |
| 468 | 467 | case 6: /* mask */ |
| 469 | 468 | v60_irq_control[offset] = data; |
| 470 | update_irq_state(); | |
| 469 | update_irq_state(machine); | |
| 471 | 470 | break; |
| 472 | 471 | |
| 473 | 472 | case 7: /* acknowledge */ |
| 474 | 473 | v60_irq_control[offset] &= data; |
| 475 | update_irq_state(); | |
| 474 | update_irq_state(machine); | |
| 476 | 475 | break; |
| 477 | 476 | |
| 478 | 477 | case 8: |
| r2724 | r2725 | |
| 501 | 500 | case 13: |
| 502 | 501 | case 14: |
| 503 | 502 | case 15: /* signal IRQ to sound CPU */ |
| 504 | signal_sound_irq(SOUND_IRQ_V60); | |
| 503 | signal_sound_irq(machine, SOUND_IRQ_V60); | |
| 505 | 504 | break; |
| 506 | 505 | } |
| 507 | 506 | } |
| r2724 | r2725 | |
| 528 | 527 | static WRITE16_HANDLER( interrupt_control_16_w ) |
| 529 | 528 | { |
| 530 | 529 | if (ACCESSING_BITS_0_7) |
| 531 | int_control_w(offset*2+0, data); | |
| 530 | int_control_w(machine, offset*2+0, data); | |
| 532 | 531 | if (ACCESSING_BITS_8_15) |
| 533 | int_control_w(offset*2+1, data >> 8); | |
| 532 | int_control_w(machine, offset*2+1, data >> 8); | |
| 534 | 533 | } |
| 535 | 534 | |
| 536 | 535 | |
| r2724 | r2725 | |
| 551 | 550 | static WRITE32_HANDLER( interrupt_control_32_w ) |
| 552 | 551 | { |
| 553 | 552 | if (ACCESSING_BITS_0_7) |
| 554 | int_control_w(offset*4+0, data); | |
| 553 | int_control_w(machine, offset*4+0, data); | |
| 555 | 554 | if (ACCESSING_BITS_8_15) |
| 556 | int_control_w(offset*4+1, data >> 8); | |
| 555 | int_control_w(machine, offset*4+1, data >> 8); | |
| 557 | 556 | if (ACCESSING_BITS_16_23) |
| 558 | int_control_w(offset*4+2, data >> 16); | |
| 557 | int_control_w(machine, offset*4+2, data >> 16); | |
| 559 | 558 | if (ACCESSING_BITS_24_31) |
| 560 | int_control_w(offset*4+3, data >> 24); | |
| 559 | int_control_w(machine, offset*4+3, data >> 24); | |
| 561 | 560 | } |
| 562 | 561 | |
| 563 | 562 | |
| 564 | 563 | static TIMER_CALLBACK( end_of_vblank_int ) |
| 565 | 564 | { |
| 566 | signal_v60_irq(MAIN_IRQ_VBSTOP); | |
| 565 | signal_v60_irq(machine, MAIN_IRQ_VBSTOP); | |
| 567 | 566 | system32_set_vblank(0); |
| 568 | 567 | } |
| 569 | 568 | |
| 570 | 569 | |
| 571 | 570 | static INTERRUPT_GEN( start_of_vblank_int ) |
| 572 | 571 | { |
| 573 | signal_v60_irq(MAIN_IRQ_VBSTART); | |
| 572 | signal_v60_irq(machine, MAIN_IRQ_VBSTART); | |
| 574 | 573 | system32_set_vblank(1); |
| 575 | 574 | timer_set(video_screen_get_time_until_pos(machine->primary_screen, 0, 0), NULL, 0, end_of_vblank_int); |
| 576 | 575 | if (system32_prot_vblank) |
| r2724 | r2725 | |
| 637 | 636 | } |
| 638 | 637 | |
| 639 | 638 | |
| 640 | static void common_io_chip_w(int which, offs_t offset, UINT16 data, UINT16 mem_mask) | |
| 639 | static void common_io_chip_w(running_machine *machine, int which, offs_t offset, UINT16 data, UINT16 mem_mask) | |
| 641 | 640 | { |
| 642 | 641 | UINT8 old; |
| 643 | 642 | |
| r2724 | r2725 | |
| 692 | 691 | case 0x1c/2: |
| 693 | 692 | system32_displayenable[which] = (data & 0x02); |
| 694 | 693 | if (which == 0) |
| 695 | cpunum_set_input_line( | |
| 694 | cpunum_set_input_line(machine, 1, INPUT_LINE_RESET, (data & 0x04) ? CLEAR_LINE : ASSERT_LINE); | |
| 696 | 695 | break; |
| 697 | 696 | } |
| 698 | 697 | } |
| r2724 | r2725 | |
| 706 | 705 | |
| 707 | 706 | static WRITE16_HANDLER( io_chip_w ) |
| 708 | 707 | { |
| 709 | common_io_chip_w(0, offset, data, mem_mask); | |
| 708 | common_io_chip_w(machine, 0, offset, data, mem_mask); | |
| 710 | 709 | } |
| 711 | 710 | |
| 712 | 711 | |
| r2724 | r2725 | |
| 720 | 719 | static WRITE32_HANDLER( io_chip_0_w ) |
| 721 | 720 | { |
| 722 | 721 | if (ACCESSING_BITS_0_15) |
| 723 | common_io_chip_w(0, offset*2+0, data, mem_mask); | |
| 722 | common_io_chip_w(machine, 0, offset*2+0, data, mem_mask); | |
| 724 | 723 | if (ACCESSING_BITS_16_31) |
| 725 | common_io_chip_w(0, offset*2+1, data >> 16, mem_mask >> 16); | |
| 724 | common_io_chip_w(machine, 0, offset*2+1, data >> 16, mem_mask >> 16); | |
| 726 | 725 | } |
| 727 | 726 | |
| 728 | 727 | |
| r2724 | r2725 | |
| 736 | 735 | static WRITE32_HANDLER( io_chip_1_w ) |
| 737 | 736 | { |
| 738 | 737 | if (ACCESSING_BITS_0_15) |
| 739 | common_io_chip_w(1, offset*2+0, data, mem_mask); | |
| 738 | common_io_chip_w(machine, 1, offset*2+0, data, mem_mask); | |
| 740 | 739 | if (ACCESSING_BITS_16_31) |
| 741 | common_io_chip_w(1, offset*2+1, data >> 16, mem_mask >> 16); | |
| 740 | common_io_chip_w(machine, 1, offset*2+1, data >> 16, mem_mask >> 16); | |
| 742 | 741 | } |
| 743 | 742 | |
| 744 | 743 | |
| r2724 | r2725 | |
| 964 | 963 | |
| 965 | 964 | static READ16_HANDLER( random_number_16_r ) |
| 966 | 965 | { |
| 967 | return mame_rand( | |
| 966 | return mame_rand(machine); | |
| 968 | 967 | } |
| 969 | 968 | |
| 970 | 969 | static WRITE32_HANDLER( random_number_32_w ) |
| r2724 | r2725 | |
| 974 | 973 | |
| 975 | 974 | static READ32_HANDLER( random_number_32_r ) |
| 976 | 975 | { |
| 977 | return mame_rand( | |
| 976 | return mame_rand(machine) ^ (mame_rand(machine) << 16); | |
| 978 | 977 | } |
| 979 | 978 | |
| 980 | 979 | |
| r2724 | r2725 | |
| 1027 | 1026 | * |
| 1028 | 1027 | *************************************/ |
| 1029 | 1028 | |
| 1030 | static void update_sound_irq_state( | |
| 1029 | static void update_sound_irq_state(running_machine *machine) | |
| 1031 | 1030 | { |
| 1032 | 1031 | UINT8 effirq = sound_irq_input & ~sound_irq_control[3] & 0x07; |
| 1033 | 1032 | int vector; |
| r2724 | r2725 | |
| 1037 | 1036 | for (vector = 0; vector < 3; vector++) |
| 1038 | 1037 | if (effirq & (1 << vector)) |
| 1039 | 1038 | { |
| 1040 | cpunum_set_input_line_and_vector( | |
| 1039 | cpunum_set_input_line_and_vector(machine, 1, 0, ASSERT_LINE, 2 * vector); | |
| 1041 | 1040 | break; |
| 1042 | 1041 | } |
| 1043 | 1042 | |
| 1044 | 1043 | /* if we didn't find any, clear the interrupt line */ |
| 1045 | 1044 | if (vector == 3) |
| 1046 | cpunum_set_input_line( | |
| 1045 | cpunum_set_input_line(machine, 1, 0, CLEAR_LINE); | |
| 1047 | 1046 | } |
| 1048 | 1047 | |
| 1049 | 1048 | |
| 1050 | static void signal_sound_irq(int which) | |
| 1049 | static void signal_sound_irq(running_machine *machine, int which) | |
| 1051 | 1050 | { |
| 1052 | 1051 | int i; |
| 1053 | 1052 | |
| r2724 | r2725 | |
| 1055 | 1054 | for (i = 0; i < 3; i++) |
| 1056 | 1055 | if (sound_irq_control[i] == which) |
| 1057 | 1056 | sound_irq_input |= 1 << i; |
| 1058 | update_sound_irq_state(); | |
| 1057 | update_sound_irq_state(machine); | |
| 1059 | 1058 | } |
| 1060 | 1059 | |
| 1061 | 1060 | |
| 1062 | static void clear_sound_irq(int which) | |
| 1061 | static void clear_sound_irq(running_machine *machine, int which) | |
| 1063 | 1062 | { |
| 1064 | 1063 | int i; |
| 1065 | 1064 | for (i = 0; i < 3; i++) |
| 1066 | 1065 | if (sound_irq_control[i] == which) |
| 1067 | 1066 | sound_irq_input &= ~(1 << i); |
| 1068 | update_sound_irq_state(); | |
| 1067 | update_sound_irq_state(machine); | |
| 1069 | 1068 | } |
| 1070 | 1069 | |
| 1071 | 1070 | |
| r2724 | r2725 | |
| 1075 | 1074 | if (offset & 1) |
| 1076 | 1075 | { |
| 1077 | 1076 | sound_irq_input &= data; |
| 1078 | update_sound_irq_state(); | |
| 1077 | update_sound_irq_state(machine); | |
| 1079 | 1078 | } |
| 1080 | 1079 | |
| 1081 | 1080 | /* high offsets signal an IRQ to the v60 */ |
| 1082 | 1081 | if (offset & 4) |
| 1083 | signal_v60_irq(MAIN_IRQ_SOUND); | |
| 1082 | signal_v60_irq(machine, MAIN_IRQ_SOUND); | |
| 1084 | 1083 | } |
| 1085 | 1084 | |
| 1086 | 1085 | |
| 1087 | 1086 | static WRITE8_HANDLER( sound_int_control_hi_w ) |
| 1088 | 1087 | { |
| 1089 | 1088 | sound_irq_control[offset] = data; |
| 1090 | update_sound_irq_state(); | |
| 1089 | update_sound_irq_state(machine); | |
| 1091 | 1090 | } |
| 1092 | 1091 | |
| 1093 | 1092 | |
| 1094 | static void ym3438_irq_handler(int state) | |
| 1093 | static void ym3438_irq_handler(running_machine *machine, int state) | |
| 1095 | 1094 | { |
| 1096 | 1095 | if (state) |
| 1097 | signal_sound_irq(SOUND_IRQ_YM3438); | |
| 1096 | signal_sound_irq(machine, SOUND_IRQ_YM3438); | |
| 1098 | 1097 | else |
| 1099 | clear_sound_irq(SOUND_IRQ_YM3438); | |
| 1098 | clear_sound_irq(machine, SOUND_IRQ_YM3438); | |
| 1100 | 1099 | } |
| 1101 | 1100 | |
| 1102 | 1101 |
| r2724 | r2725 | |
|---|---|---|
| 462 | 462 | PORT_DIPSETTING( 0x00, DEF_STR( On ) ) |
| 463 | 463 | PORT_SERVICE( 0x40, IP_ACTIVE_LOW ) |
| 464 | 464 | /* Actually, the following DIPSW doesnt seem to do anything */ |
| 465 | PORT_ | |
| 465 | PORT_DIPNAME( | |
| 466 | 466 | PORT_DIPSETTING( 0x20, DEF_STR( Off ) ) |
| 467 | 467 | PORT_DIPSETTING( 0x00, DEF_STR( On ) ) |
| 468 | 468 | PORT_DIPNAME( 0x10, 0x00, DEF_STR( Cabinet ) ) |
| r2724 | r2725 | |
| 575 | 575 | PORT_DIPNAME( 0x10, 0x10, DEF_STR( Demo_Sounds ) ) |
| 576 | 576 | PORT_DIPSETTING( 0x00, DEF_STR( Off ) ) |
| 577 | 577 | PORT_DIPSETTING( 0x10, DEF_STR( On ) ) |
| 578 | PORT_ | |
| 578 | PORT_DIPNAME( | |
| 579 | 579 | PORT_DIPSETTING( 0x20, DEF_STR( Off ) ) |
| 580 | 580 | PORT_DIPSETTING( 0x00, DEF_STR( On ) ) |
| 581 | 581 | PORT_DIPNAME( 0x40, 0x40, DEF_STR( Flip_Screen ) ) |
| r2724 | r2725 | |
|---|---|---|
| 212 | 212 | static INPUT_CHANGED( spaceint_coin_inserted ) |
| 213 | 213 | { |
| 214 | 214 | /* coin insertion causes an NMI */ |
| 215 | cpunum_set_input_line(machine, 0, INPUT_LINE_NMI, newval ? ASSERT_LINE : CLEAR_LINE); | |
| 215 | cpunum_set_input_line(field->port->machine, 0, INPUT_LINE_NMI, newval ? ASSERT_LINE : CLEAR_LINE); | |
| 216 | 216 | } |
| 217 | 217 | |
| 218 | 218 |
| r2724 | r2725 | |
|---|---|---|
| 270 | 270 | */ |
| 271 | 271 | |
| 272 | 272 | #include "driver.h" |
| 273 | #include "deprecat.h" | |
| 274 | 273 | |
| 275 | 274 | #include "cpu/sh2/sh2.h" |
| 276 | 275 | #include "machine/eeprom.h" |
| r2724 | r2725 | |
| 580 | 579 | AM_RANGE(0x06000000, 0x060fffff) AM_WRITE(SMH_RAM) AM_BASE(&psh_ram) |
| 581 | 580 | ADDRESS_MAP_END |
| 582 | 581 | |
| 583 | static void irqhandler(int linestate) | |
| 582 | static void irqhandler(running_machine *machine, int linestate) | |
| 584 | 583 | { |
| 585 | 584 | if (linestate) |
| 586 | cpunum_set_input_line( | |
| 585 | cpunum_set_input_line(machine, 0, 12, ASSERT_LINE); | |
| 587 | 586 | else |
| 588 | cpunum_set_input_line( | |
| 587 | cpunum_set_input_line(machine, 0, 12, CLEAR_LINE); | |
| 589 | 588 | } |
| 590 | 589 | |
| 591 | 590 | static const struct YMF278B_interface ymf278b_interface = |
| r2724 | r2725 | |
|---|---|---|
| 75 | 75 | */ |
| 76 | 76 | |
| 77 | 77 | #include "driver.h" |
| 78 | #include "deprecat.h" | |
| 79 | 78 | #include "cpu/m68000/m68000.h" |
| 80 | 79 | #include "cpu/h6280/h6280.h" |
| 81 | 80 | #include "decocrpt.h" |
| r2724 | r2725 | |
| 283 | 282 | |
| 284 | 283 | /**********************************************************************************/ |
| 285 | 284 | |
| 286 | static void sound_irq(int state) | |
| 285 | static void sound_irq(running_machine *machine, int state) | |
| 287 | 286 | { |
| 288 | cpunum_set_input_line( | |
| 287 | cpunum_set_input_line(machine, 1,1,state); /* IRQ 2 */ | |
| 289 | 288 | } |
| 290 | 289 | |
| 291 | 290 | static WRITE8_HANDLER( sound_bankswitch_w ) |
| r2724 | r2725 | |
|---|---|---|
| 205 | 205 | static READ16_HANDLER( bishjan_unk_r ) |
| 206 | 206 | { |
| 207 | 207 | return |
| 208 | (mame_rand( | |
| 208 | (mame_rand(machine) & 0x9800) | // bit 7 eeprom? | |
| 209 | 209 | (((bishjan_sel==0x12) ? 0x40:0x00) << 8) | |
| 210 | 210 | // (mame_rand() & 0xff); |
| 211 | 211 | // (((video_screen_get_frame_number(machine->primary_screen)%60)==0)?0x18:0x00); |
| r2724 | r2725 | |
|---|---|---|
| 7202 | 7202 | memory_install_readwrite16_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x200000, 0x201fff, 0, 0, SMH_BANK8, SMH_BANK8); |
| 7203 | 7203 | memory_set_bankptr(NEOGEO_BANK_EXTRA_RAM, extra_ram); |
| 7204 | 7204 | |
| 7205 | // memory_install_read16_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x280000, 0x280001, 0, 0, port_tag_to_handler16("IN5") ); | |
| 7206 | // memory_install_read16_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x2c0000, 0x2c0001, 0, 0, port_tag_to_handler16("IN6") ); | |
| 7205 | // memory_install_read16_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x280000, 0x280001, 0, 0, input_port_read_handler16(machine->portconfig, "IN5") ); | |
| 7206 | // memory_install_read16_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x2c0000, 0x2c0001, 0, 0, input_port_read_handler16(machine->portconfig, "IN6") ); | |
| 7207 | 7207 | |
| 7208 | 7208 | DRIVER_INIT_CALL(neogeo); |
| 7209 | 7209 | } |
| r2724 | r2725 | |
| 7219 | 7219 | memory_install_readwrite16_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x200000, 0x201fff, 0, 0, SMH_BANK8, SMH_BANK8); |
| 7220 | 7220 | memory_set_bankptr(NEOGEO_BANK_EXTRA_RAM, extra_ram); |
| 7221 | 7221 | |
| 7222 | memory_install_read16_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x280000, 0x280001, 0, 0, port_tag_to_handler16("IN5") ); | |
| 7223 | memory_install_read16_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x2c0000, 0x2c0001, 0, 0, port_tag_to_handler16("IN6") ); | |
| 7222 | memory_install_read16_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x280000, 0x280001, 0, 0, input_port_read_handler16(machine->portconfig, "IN5") ); | |
| 7223 | memory_install_read16_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x2c0000, 0x2c0001, 0, 0, input_port_read_handler16(machine->portconfig, "IN6") ); | |
| 7224 | 7224 | |
| 7225 | 7225 | DRIVER_INIT_CALL(neogeo); |
| 7226 | 7226 | } |
| r2724 | r2725 | |
| 7229 | 7229 | static DRIVER_INIT( kog ) |
| 7230 | 7230 | { |
| 7231 | 7231 | /* overlay cartridge ROM */ |
| 7232 | memory_install_read16_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x0ffffe, 0x0fffff, 0, 0, port_ | |
| 7232 | memory_install_read16_handler(machine, 0, ADDRESS_SPACE_PROGRAM, 0x0ffffe, 0x0fffff, 0, 0, input_port_read_ | |
| 7233 | 7233 | |
| 7234 | 7234 | kog_px_decrypt(); |
| 7235 | 7235 | neogeo_bootleg_sx_decrypt(1); |
| r2724 | r2725 | |
|---|---|---|
| 40 | 40 | ******************************************************************************/ |
| 41 | 41 | |
| 42 | 42 | #include "driver.h" |
| 43 | #include "deprecat.h" | |
| 44 | 43 | #include "cpu/z80/z80.h" |
| 45 | 44 | #include "fromance.h" |
| 46 | 45 | #include "sound/ay8910.h" |
| r2724 | r2725 | |
| 165 | 164 | } |
| 166 | 165 | |
| 167 | 166 | |
| 168 | static void fromance_adpcm_int(int irq) | |
| 167 | static void fromance_adpcm_int(running_machine *machine, int irq) | |
| 169 | 168 | { |
| 170 | 169 | /* skip if we're reset */ |
| 171 | 170 | if (!fromance_adpcm_reset) |
| r2724 | r2725 | |
| 181 | 180 | |
| 182 | 181 | /* generate an NMI if we're out of data */ |
| 183 | 182 | if (!fromance_vclk_left) |
| 184 | cpunum_set_input_line( | |
| 183 | cpunum_set_input_line(machine, 1, INPUT_LINE_NMI, PULSE_LINE); | |
| 185 | 184 | } |
| 186 | 185 | |
| 187 | 186 |
| r2724 | r2725 | |
|---|---|---|
| 34 | 34 | |
| 35 | 35 | #include "driver.h" |
| 36 | 36 | #include "render.h" |
| 37 | #include "deprecat.h" | |
| 38 | 37 | #include "cpu/z80/z80daisy.h" |
| 39 | 38 | #include "machine/laserdsc.h" |
| 40 | 39 | #include "machine/z80ctc.h" |
| r2724 | r2725 | |
| 89 | 88 | * |
| 90 | 89 | *************************************/ |
| 91 | 90 | |
| 92 | static void dleuro_interrupt(int state) | |
| 91 | static void dleuro_interrupt(running_machine *machine, int state) | |
| 93 | 92 | { |
| 94 | cpunum_set_input_line( | |
| 93 | cpunum_set_input_line(machine, 0, 0, state); | |
| 95 | 94 | } |
| 96 | 95 | |
| 97 | 96 |
| r2724 | r2725 | |
|---|---|---|
| 121 | 121 | */ |
| 122 | 122 | |
| 123 | 123 | #include "driver.h" |
| 124 | #include "deprecat.h" | |
| 125 | 124 | #include "cpu/arm7/arm7core.h" |
| 126 | 125 | |
| 127 | 126 | enum |
| r2724 | r2725 | |
| 315 | 314 | switch(offset) |
| 316 | 315 | { |
| 317 | 316 | case MSECR: |
| 318 | return mame_rand( | |
| 317 | return mame_rand(machine); | |
| 319 | 318 | break; |
| 320 | 319 | |
| 321 | 320 | case IOLINES: //TODO: eeprom 24c01 |
| r2724 | r2725 | |
| 326 | 325 | if(flashType==1) |
| 327 | 326 | return 0; |
| 328 | 327 | else |
| 329 | return mame_rand( | |
| 328 | return mame_rand(machine); | |
| 330 | 329 | |
| 331 | 330 | case IRQSTA: |
| 332 | 331 | return (PS7500_IO[offset]&(~2))|0x80; |
| r2724 | r2725 | |
| 354 | 353 | //default: |
| 355 | 354 | //mame_printf_debug("ior %i @%x\n",offset,activecpu_get_pc()); |
| 356 | 355 | } |
| 357 | return mame_rand( | |
| 356 | return mame_rand(machine);//PS7500_IO[offset]; | |
| 358 | 357 | } |
| 359 | 358 | |
| 360 | 359 | static WRITE32_HANDLER(PS7500_IO_w) |
| r2724 | r2725 | |
| 476 | 475 | |
| 477 | 476 | static READ32_HANDLER(ff4_r) |
| 478 | 477 | { |
| 479 | return mame_rand( | |
| 478 | return mame_rand(machine)&0x20; | |
| 480 | 479 | } |
| 481 | 480 | |
| 482 | 481 | static READ32_HANDLER(SIMPLEIO_r) |
| 483 | 482 | { |
| 484 | return mame_rand( | |
| 483 | return mame_rand(machine)&1; | |
| 485 | 484 | } |
| 486 | 485 | |
| 487 | 486 | static READ32_HANDLER(randomized_r) |
| 488 | 487 | { |
| 489 | return mame_rand( | |
| 488 | return mame_rand(machine); | |
| 490 | 489 | } |
| 491 | 490 | |
| 492 | 491 | static ADDRESS_MAP_START( ssfindo_map, ADDRESS_SPACE_PROGRAM, 32 ) |
| r2724 | r2725 | |
|---|---|---|
| 34 | 34 | |
| 35 | 35 | static INPUT_CHANGED( service_mode_switch_changed ) |
| 36 | 36 | { |
| 37 | set_service_mode(machine, newval); | |
| 37 | set_service_mode(field->port->machine, newval); | |
| 38 | 38 | } |
| 39 | 39 | |
| 40 | 40 | |
| 41 | 41 | static INPUT_CHANGED( firetrk_horn_changed ) |
| 42 | 42 | { |
| 43 | discrete_sound_w(machine, FIRETRUCK_HORN_EN, newval); | |
| 43 | discrete_sound_w(field->port->machine, FIRETRUCK_HORN_EN, newval); | |
| 44 | 44 | } |
| 45 | 45 | |
| 46 | 46 |
| r2724 | r2725 | |
|---|---|---|
| 978 | 978 | } |
| 979 | 979 | } |
| 980 | 980 | |
| 981 | static void irq_ym(int irq) | |
| 981 | static void irq_ym(running_machine *machine, int irq) | |
| 982 | 982 | { |
| 983 | 983 | irq_yms = irq; |
| 984 | cpunum_set_input_line(Machine, 0, IRQ_YM2151+1, irq_yms && (irq_allow0 & (1 << IRQ_YM2151)) ? ASSERT_LINE : CLEAR_LINE); | |
| 985 | cpunum_set_input_line(Machine, 1, IRQ_YM2151+1, irq_yms && (irq_allow1 & (1 << IRQ_YM2151)) ? ASSERT_LINE : CLEAR_LINE); | |
| 984 | cpunum_set_input_line(machine, 0, IRQ_YM2151+1, irq_yms && (irq_allow0 & (1 << IRQ_YM2151)) ? ASSERT_LINE : CLEAR_LINE); | |
| 985 | cpunum_set_input_line(machine, 1, IRQ_YM2151+1, irq_yms && (irq_allow1 & (1 << IRQ_YM2151)) ? ASSERT_LINE : CLEAR_LINE); | |
| 986 | 986 | } |
| 987 | 987 | |
| 988 | 988 |
| r2724 | r2725 | |
|---|---|---|
| 295 | 295 | * |
| 296 | 296 | *************************************/ |
| 297 | 297 | |
| 298 | static void audio_cpu_irq(int assert) | |
| 298 | static void audio_cpu_irq(running_machine *machine, int assert) | |
| 299 | 299 | { |
| 300 | cpunum_set_input_line( | |
| 300 | cpunum_set_input_line(machine, 1, 0, assert ? ASSERT_LINE : CLEAR_LINE); | |
| 301 | 301 | } |
| 302 | 302 | |
| 303 | 303 | |
| 304 | static void audio_cpu_assert_nmi( | |
| 304 | static void audio_cpu_assert_nmi(running_machine *machine) | |
| 305 | 305 | { |
| 306 | cpunum_set_input_line( | |
| 306 | cpunum_set_input_line(machine, 1, INPUT_LINE_NMI, ASSERT_LINE); | |
| 307 | 307 | } |
| 308 | 308 | |
| 309 | 309 | |
| r2724 | r2725 | |
| 332 | 332 | |
| 333 | 333 | sprintf(tag, "IN%s-%d", (const char *)param, controller_select & 0x01); |
| 334 | 334 | |
| 335 | return input_port_read(machine, tag); | |
| 335 | return input_port_read(field->port->machine, tag); | |
| 336 | 336 | } |
| 337 | 337 | |
| 338 | 338 | |
| r2724 | r2725 | |
| 351 | 351 | { |
| 352 | 352 | default: |
| 353 | 353 | case 0x00: ret = 0x0000; break; /* nothing? */ |
| 354 | case 0x09: ret = input_port_read(machine, "MAHJONG1"); break; | |
| 355 | case 0x12: ret = input_port_read(machine, "MAHJONG2"); break; | |
| 356 | case 0x1b: ret = input_port_read(machine, "MAHJONG3"); break; /* player 1 normal inputs? */ | |
| 357 | case 0x24: ret = input_port_read(machine, "MAHJONG4"); break; | |
| 354 | case 0x09: ret = input_port_read(field->port->machine, "MAHJONG1"); break; | |
| 355 | case 0x12: ret = input_port_read(field->port->machine, "MAHJONG2"); break; | |
| 356 | case 0x1b: ret = input_port_read(field->port->machine, "MAHJONG3"); break; /* player 1 normal inputs? */ | |
| 357 | case 0x24: ret = input_port_read(field->port->machine, "MAHJONG4"); break; | |
| 358 | 358 | } |
| 359 | 359 | |
| 360 | 360 | return ret; |
| r2724 | r2725 | |
| 444 | 444 | |
| 445 | 445 | static CUSTOM_INPUT( get_calendar_status ) |
| 446 | 446 | { |
| 447 | return (pd4990a_databit_r(machine, 0) << 1) | pd4990a_testbit_r(machine, 0); | |
| 447 | return (pd4990a_databit_r(field->port->machine, 0) << 1) | pd4990a_testbit_r(field->port->machine, 0); | |
| 448 | 448 | } |
| 449 | 449 | |
| 450 | 450 | |
| r2724 | r2725 | |
| 566 | 566 | { |
| 567 | 567 | soundlatch_w(machine, 0, data >> 8); |
| 568 | 568 | |
| 569 | audio_cpu_assert_nmi(); | |
| 569 | audio_cpu_assert_nmi(machine); | |
| 570 | 570 | |
| 571 | 571 | /* boost the interleave to let the audio CPU read the command */ |
| 572 | 572 | cpu_boost_interleave(attotime_zero, ATTOTIME_IN_USEC(50)); |
| r2724 | r2725 | |
|---|---|---|
| 21 | 21 | |
| 22 | 22 | CPU: 1x 65SC02 at 2MHz. |
| 23 | 23 | |
| 24 | Sound: 1x AD-65 or U6295 (OKI6295 compatible) | |
| 24 | Sound: 1x AD-65 or U6295 (OKI6295 compatible) at 1MHz, pin7 HIGH. | |
| 25 | 25 | 1x LM358N |
| 26 | 26 | 1x TDA2003 |
| 27 | 27 | |
| r2724 | r2725 | |
| 48 | 48 | *************************************************************************************** |
| 49 | 49 | |
| 50 | 50 | |
| 51 | All | |
| 51 | All | |
| 52 | 52 | changing hardware accesses, program logics, graphics, plus protection and some I/O |
| 53 | 53 | through the 2x high density PLDs. |
| 54 | 54 | |
| r2724 | r2725 | |
| 86 | 86 | |
| 87 | 87 | To clear credits (and stats), just re-initialize the NVRAM. |
| 88 | 88 | |
| 89 | Only for the new hardware revision (snookr10 & apple10), pressing STOP 1 (key 'Z') in the | |
| 89 | Only for the new hardware revision (snookr10 & apple10), pressing STOP 1 (key 'Z') into the | |
| 90 | 90 | stats mode, make the hidden Input Test mode to appear. Press RESET (F3) to exit the mode. |
| 91 | 91 | |
| 92 | 92 | |
| r2724 | r2725 | |
| 199 | 199 | To properly decrypt the thing 'on the fly' as the hardware does, I applied a bitswap into TILE_GET_INFO. |
| 200 | 200 | This method rearrange the tile number for each tile called to be drawn. |
| 201 | 201 | |
| 202 | The final algor | |
| 202 | The final algor | |
| 203 | 203 | digit #3 |
| 204 | 204 | +-------+ swapped digits 1 & 2 |
| 205 | 205 | | | +-------+------+ |
| r2724 | r2725 | |
| 231 | 231 | 0xE0-0xEF | 0x70-0x7F |
| 232 | 232 | 0xF0-0xFF | 0xF0-0xFF |
| 233 | 233 | |
| 234 | And each one of these segments are internally scrambled too. | |
| 234 | 235 | |
| 235 | So, the algor | |
| 236 | So, the algori | |
| 236 | 237 | |
| 237 | 238 | 1st nibble |
| 238 | 239 | inverted bitorder |
| r2724 | r2725 | |
| 248 | 249 | *********************************************************************************** |
| 249 | 250 | |
| 250 | 251 | |
| 251 | Memory Maps | |
| 252 | ----------- | |
| 252 | * MEMORY MAPS * | |
| 253 | --------------- | |
| 253 | 254 | |
| 254 | 255 | (Old hardware) |
| 255 | 256 | |
| r2724 | r2725 | |
| 261 | 262 | $4003 - $4003 Input Port 3 ;R , DIP switches. |
| 262 | 263 | $5000 - $5000 Output Port A ;W , lamps. |
| 263 | 264 | $5001 - $5001 Output Port B ;W , lamps. |
| 264 | $6000 - $6FFF VideoRAM | |
| 265 | $7000 - $7FFF ColorRAM | |
| 265 | $6000 - $6FFF Video RAM | |
| 266 | $7000 - $7FFF Color RAM | |
| 266 | 267 | $8000 - $FFFF ROM Space |
| 267 | 268 | |
| 268 | 269 | |
| r2724 | r2725 | |
| 274 | 275 | $3001 - $3001 Input Port 1 ;R |
| 275 | 276 | $3002 - $3002 Input Port 2 ;R |
| 276 | 277 | $3003 - $3003 Input Port 3 ;R , DIP switches. |
| 277 | $3004 - $3004 | |
| 278 | $3004 - $3004 (unknown) ;R , the code is constantly polling bit 7. | |
| 278 | 279 | $5000 - $5000 Output Port A ;W , lamps. |
| 279 | 280 | $5001 - $5001 Output Port B ;W , lamps. |
| 280 | $6000 - $6FFF VideoRAM | |
| 281 | $7000 - $7FFF ColorRAM | |
| 281 | $6000 - $6FFF Video RAM | |
| 282 | $7000 - $7FFF Color RAM | |
| 282 | 283 | $8000 - $FFFF ROM Space |
| 283 | 284 | |
| 284 | 285 | |
| r2724 | r2725 | |
| 288 | 289 | *** Driver Updates *** |
| 289 | 290 | |
| 290 | 291 | |
| 292 | [2008/05/22] | |
| 293 | - Confirmed the CPU clock after some PCB measurements. | |
| 294 | - Changed the SND clock to 1MHz to match the PCB measurement. | |
| 295 | - Corrected the internal OKI6295 frequency turning the pin 7 state to HIGH. | |
| 296 | - Inputs: Eliminated all pulse limitations. | |
| 297 | Affected buttons have a rattled sound in the real thing too. | |
| 298 | - Updated technical notes. | |
| 299 | ||
| 291 | 300 | [2008/04/28] |
| 292 | 301 | - Created a new machine driver for tenballs due to different memory map. |
| 293 | 302 | - Worked all the input ports from the scratch. |
| r2724 | r2725 | |
| 318 | 327 | *** TO DO *** |
| 319 | 328 | |
| 320 | 329 | - Figure out the unknown reads to offset $3004, bit 7. |
| 321 | - Get CPU and sound clocks properly measured. | |
| 322 | - Get the OKI6295 pin 7 measured to know the real status. | |
| 323 | 330 | - Hook lamps. |
| 331 | - Turn the color system to resnet calculation. | |
| 324 | 332 | |
| 325 | 333 | |
| 326 | 334 | ***********************************************************************************/ |
| r2724 | r2725 | |
| 440 | 448 | static INPUT_PORTS_START( snookr10 ) |
| 441 | 449 | PORT_START_TAG("IN0") |
| 442 | 450 | PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_SERVICE ) PORT_NAME("Remote x100") PORT_CODE(KEYCODE_Q) |
| 443 | PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_IMPULSE(2) PORT_NAME("Stop 1") PORT_CODE(KEYCODE_Z) /* Input Test in stats mode */ | |
| 444 | PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_BUTTON6 ) PORT_IMPULSE(2) PORT_NAME("Cancella (Cancel) / Play / Bet") PORT_CODE(KEYCODE_N) | |
| 451 | PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_NAME("Stop 1") PORT_CODE(KEYCODE_Z) /* Input Test in stats mode */ | |
| 452 | PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_BUTTON6 ) PORT_NAME("Cancella (Cancel) / Play / Bet") PORT_CODE(KEYCODE_N) | |
| 445 | 453 | PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_START1 ) PORT_NAME("Start (Deal) / Raddoppio (Double-Up)") |
| 446 | PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON5 ) PORT_ | |
| 454 | PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON5 ) PORT_ | |
| 447 | 455 | PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_SERVICE1 ) PORT_NAME("Estatistica (Stats)") |
| 448 | 456 | PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_SERVICE2 ) PORT_NAME("Management") |
| 449 | PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_BUTTON4 ) PORT_ | |
| 457 | PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_BUTTON4 ) PORT_ | |
| 450 | 458 | |
| 451 | 459 | PORT_START_TAG("IN1") |
| 452 | PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_IMPULSE(2) PORT_NAME("Stop 2 / Bassa (Low)") PORT_CODE(KEYCODE_X) | |
| 453 | PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_IMPULSE(2) PORT_NAME("Stop 3") PORT_CODE(KEYCODE_C) | |
| 460 | PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_NAME("Stop 2 / Bassa (Low)") PORT_CODE(KEYCODE_X) | |
| 461 | PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_NAME("Stop 3") PORT_CODE(KEYCODE_C) | |
| 454 | 462 | PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_SERVICE ) PORT_NAME("Ticket") PORT_CODE(KEYCODE_T) |
| 455 | 463 | PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_SERVICE ) PORT_NAME("Hopper") PORT_CODE(KEYCODE_H) |
| 456 | 464 | PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_UNKNOWN ) |
| r2724 | r2725 | |
| 495 | 503 | static INPUT_PORTS_START( apple10 ) |
| 496 | 504 | PORT_START_TAG("IN0") |
| 497 | 505 | PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_SERVICE ) PORT_NAME("Remote x100") PORT_CODE(KEYCODE_Q) |
| 498 | PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_IMPULSE(2) PORT_NAME("Stop 1") PORT_CODE(KEYCODE_Z) /* Input Test in stats mode */ | |
| 499 | PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_BUTTON6 ) PORT_IMPULSE(2) PORT_NAME("Cancella (Cancel) / Play / Bet") PORT_CODE(KEYCODE_N) | |
| 506 | PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_NAME("Stop 1") PORT_CODE(KEYCODE_Z) /* Input Test in stats mode */ | |
| 507 | PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_BUTTON6 ) PORT_NAME("Cancella (Cancel) / Play / Bet") PORT_CODE(KEYCODE_N) | |
| 500 | 508 | PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_START1 ) PORT_NAME("Start (Deal) / Raddoppio (Double-Up)") |
| 501 | PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON5 ) PORT_ | |
| 509 | PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON5 ) PORT_ | |
| 502 | 510 | PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_SERVICE1 ) PORT_NAME("Estatistica (Stats)") |
| 503 | 511 | PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_SERVICE2 ) PORT_NAME("Management") |
| 504 | PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_BUTTON4 ) PORT_ | |
| 512 | PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_BUTTON4 ) PORT_ | |
| 505 | 513 | |
| 506 | 514 | PORT_START_TAG("IN1") |
| 507 | PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_IMPULSE(2) PORT_NAME("Stop 2 / Bassa (Low)") PORT_CODE(KEYCODE_X) | |
| 508 | PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_IMPULSE(2) PORT_NAME("Stop 3") PORT_CODE(KEYCODE_C) | |
| 515 | PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_NAME("Stop 2 / Bassa (Low)") PORT_CODE(KEYCODE_X) | |
| 516 | PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_NAME("Stop 3") PORT_CODE(KEYCODE_C) | |
| 509 | 517 | PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_SERVICE ) PORT_NAME("Ticket") PORT_CODE(KEYCODE_T) |
| 510 | 518 | PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_SERVICE ) PORT_NAME("Hopper") PORT_CODE(KEYCODE_H) |
| 511 | 519 | PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_UNKNOWN ) |
| r2724 | r2725 | |
| 550 | 558 | static INPUT_PORTS_START( tenballs ) |
| 551 | 559 | PORT_START_TAG("IN0") |
| 552 | 560 | PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_SERVICE ) PORT_NAME("Remote x100") PORT_CODE(KEYCODE_Q) |
| 553 | PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_IMPULSE(2) PORT_NAME("Stop 1") PORT_CODE(KEYCODE_Z) /* no Input Test in stats mode */ | |
| 554 | PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_BUTTON6 ) PORT_IMPULSE(2) PORT_NAME("Cancella (Cancel) / Play / Bet") PORT_CODE(KEYCODE_N) | |
| 561 | PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_NAME("Stop 1") PORT_CODE(KEYCODE_Z) /* no Input Test in stats mode */ | |
| 562 | PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_BUTTON6 ) PORT_NAME("Cancella (Cancel) / Play / Bet") PORT_CODE(KEYCODE_N) | |
| 555 | 563 | PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_START1 ) PORT_NAME("Start (Deal) / Raddoppio (Double-Up)") |
| 556 | PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON5 ) PORT_ | |
| 564 | PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON5 ) PORT_ | |
| 557 | 565 | PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_SERVICE1 ) PORT_NAME("Estatistica (Stats)") |
| 558 | 566 | PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_SERVICE2 ) PORT_NAME("Management") |
| 559 | PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_BUTTON4 ) PORT_ | |
| 567 | PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_BUTTON4 ) PORT_ | |
| 560 | 568 | |
| 561 | 569 | PORT_START_TAG("IN1") |
| 562 | PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_IMPULSE(2) PORT_NAME("Stop 2 / Bassa (Low)") PORT_CODE(KEYCODE_X) | |
| 563 | PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_IMPULSE(2) PORT_NAME("Stop 3") PORT_CODE(KEYCODE_C) | |
| 570 | PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_NAME("Stop 2 / Bassa (Low)") PORT_CODE(KEYCODE_X) | |
| 571 | PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_NAME("Stop 3") PORT_CODE(KEYCODE_C) | |
| 564 | 572 | PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_SERVICE ) PORT_NAME("Ticket") PORT_CODE(KEYCODE_T) |
| 565 | 573 | PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_SERVICE ) PORT_NAME("Hopper") PORT_CODE(KEYCODE_H) |
| 566 | 574 | PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_UNKNOWN ) |
| r2724 | r2725 | |
| 644 | 652 | static MACHINE_DRIVER_START( snookr10 ) |
| 645 | 653 | |
| 646 | 654 | /* basic machine hardware */ |
| 647 | MDRV_CPU_ADD_TAG("main", M65SC02, MASTER_CLOCK/8) /* 2MHz */ | |
| 655 | MDRV_CPU_ADD_TAG("main", M65SC02, MASTER_CLOCK/8) /* 2 MHz (1.999 MHz measured) */ | |
| 648 | 656 | MDRV_CPU_PROGRAM_MAP(snookr10_map, 0) |
| 649 | 657 | MDRV_CPU_VBLANK_INT("main", nmi_line_pulse) |
| 650 | 658 | |
| r2724 | r2725 | |
| 668 | 676 | |
| 669 | 677 | /* sound hardware */ |
| 670 | 678 | MDRV_SPEAKER_STANDARD_MONO("mono") |
| 671 | MDRV_SOUND_ADD(OKIM6295, MASTER_CLOCK/12) /* guess */ | |
| 672 | MDRV_SOUND_CONFIG(okim6295_interface_region_1_pin7low) /* pin7 not checked */ | |
| 679 | MDRV_SOUND_ADD(OKIM6295, MASTER_CLOCK/16) /* 1 MHz (995.5 kHz measured) */ | |
| 680 | MDRV_SOUND_CONFIG(okim6295_interface_region_1_pin7high) /* pin7 checked on PCB */ | |
| 673 | 681 | MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.8) |
| 674 | 682 | |
| 675 | 683 | MACHINE_DRIVER_END |
| r2724 | r2725 | |
|---|---|---|
| 343 | 343 | * |
| 344 | 344 | *************************************/ |
| 345 | 345 | |
| 346 | static void sound_irq(int irq) | |
| 346 | static void sound_irq(running_machine *machine, int irq) | |
| 347 | 347 | { |
| 348 | cpunum_set_input_line( | |
| 348 | cpunum_set_input_line(machine, 2, 0, irq ? ASSERT_LINE : CLEAR_LINE); | |
| 349 | 349 | } |
| 350 | 350 | |
| 351 | 351 |
| r2724 | r2725 | |
|---|---|---|
| 42 | 42 | #define MASTER_CLOCK 22118400 |
| 43 | 43 | |
| 44 | 44 | #include "driver.h" |
| 45 | #include "deprecat.h" | |
| 46 | 45 | #include "sound/ay8910.h" |
| 47 | 46 | #include "video/mc6845.h" |
| 48 | 47 | |
| r2724 | r2725 | |
| 266 | 265 | |
| 267 | 266 | static READ8_HANDLER( unknown_r ) |
| 268 | 267 | { |
| 269 | return mame_rand( | |
| 268 | return mame_rand(machine); | |
| 270 | 269 | } |
| 271 | 270 | |
| 272 | 271 | /* these are set as input, but I have no idea which input port it uses is for the AY */ |
| r2724 | r2725 | |
|---|---|---|
| 119 | 119 | { |
| 120 | 120 | /* to avoid resetting (when player 2 starts) bit 0 need to be |
| 121 | 121 | inverted when screen is flipped */ |
| 122 | return ((video_screen_get_vpos(machine->primary_screen) >> 7) & 0x01) ^ dorachan_flip_screen; | |
| 122 | return ((video_screen_get_vpos(field->port->machine->primary_screen) >> 7) & 0x01) ^ dorachan_flip_screen; | |
| 123 | 123 | } |
| 124 | 124 | |
| 125 | 125 |
| r2724 | r2725 | |
|---|---|---|
| 138 | 138 | static INPUT_CHANGED( coin1_inserted ) |
| 139 | 139 | { |
| 140 | 140 | /* left coin insertion causes an NMI */ |
| 141 | cpunum_set_input_line(machine, 0, INPUT_LINE_NMI, newval ? ASSERT_LINE : CLEAR_LINE); | |
| 141 | cpunum_set_input_line(field->port->machine, 0, INPUT_LINE_NMI, newval ? ASSERT_LINE : CLEAR_LINE); | |
| 142 | 142 | } |
| 143 | 143 | |
| 144 | 144 | static INPUT_CHANGED( coin2_inserted ) |
| 145 | 145 | { |
| 146 | 146 | /* right coin insertion causes an IRQ */ |
| 147 | 147 | if (newval) |
| 148 | cpunum_set_input_line(machine, 0, 0, HOLD_LINE); | |
| 148 | cpunum_set_input_line(field->port->machine, 0, 0, HOLD_LINE); | |
| 149 | 149 | } |
| 150 | 150 | |
| 151 | 151 | |
| r2724 | r2725 | |
| 154 | 154 | |
| 155 | 155 | static CUSTOM_INPUT( ladybug_p1_control_r ) |
| 156 | 156 | { |
| 157 | return input_port_read(machine, LADYBUG_P1_CONTROL_PORT_TAG); | |
| 157 | return input_port_read(field->port->machine, LADYBUG_P1_CONTROL_PORT_TAG); | |
| 158 | 158 | } |
| 159 | 159 | |
| 160 | 160 | static CUSTOM_INPUT( ladybug_p2_control_r ) |
| r2724 | r2725 | |
| 162 | 162 | UINT32 ret; |
| 163 | 163 | |
| 164 | 164 | /* upright cabinet only uses a single set of controls */ |
| 165 | if (input_port_read(machine, "DSW0") & 0x20) | |
| 166 | ret = input_port_read(machine, LADYBUG_P2_CONTROL_PORT_TAG); | |
| 165 | if (input_port_read(field->port->machine, "DSW0") & 0x20) | |
| 166 | ret = input_port_read(field->port->machine, LADYBUG_P2_CONTROL_PORT_TAG); | |
| 167 | 167 | else |
| 168 | ret = input_port_read(machine, LADYBUG_P1_CONTROL_PORT_TAG); | |
| 168 | ret = input_port_read(field->port->machine, LADYBUG_P1_CONTROL_PORT_TAG); | |
| 169 | 169 | |
| 170 | 170 | return ret; |
| 171 | 171 | } |
| r2724 | r2725 | |
| 202 | 202 | PORT_DIPNAME( 0x04, 0x04, "High Score Names" ) |
| 203 | 203 | PORT_DIPSETTING( 0x00, "3 Letters" ) |
| 204 | 204 | PORT_DIPSETTING( 0x04, "10 Letters" ) |
| 205 | PORT_ | |
| 205 | PORT_DIPNAME( | |
| 206 | 206 | PORT_DIPSETTING( 0x08, DEF_STR( Off ) ) |
| 207 | 207 | PORT_DIPSETTING( 0x00, DEF_STR( On ) ) |
| 208 | 208 | PORT_DIPNAME( 0x10, 0x10, "Freeze" ) |
| r2724 | r2725 | |
| 474 | 474 | PORT_DIPNAME( 0x04, 0x04, DEF_STR( Bonus_Life ) ) |
| 475 | 475 | PORT_DIPSETTING( 0x04, "20000" ) |
| 476 | 476 | PORT_DIPSETTING( 0x00, "30000" ) |
| 477 | PORT_ | |
| 477 | PORT_DIPNAME( | |
| 478 | 478 | PORT_DIPSETTING( 0x08, DEF_STR( Off ) ) |
| 479 | 479 | PORT_DIPSETTING( 0x00, DEF_STR( On ) ) |
| 480 | 480 | PORT_DIPNAME( 0x10, 0x10, "Freeze" ) |
| r2724 | r2725 | |
|---|---|---|
| 42 | 42 | */ |
| 43 | 43 | |
| 44 | 44 | #include "driver.h" |
| 45 | #include "deprecat.h" | |
| 46 | 45 | |
| 47 | 46 | static UINT16 *peno_vram; |
| 48 | 47 | |
| r2724 | r2725 | |
| 110 | 109 | |
| 111 | 110 | static READ16_HANDLER( peno_rand ) |
| 112 | 111 | { |
| 113 | return 0xffff;// mame_rand( | |
| 112 | return 0xffff;// mame_rand(machine); | |
| 114 | 113 | } |
| 115 | 114 | |
| 116 | 115 | #ifdef UNUSED_FUNCTION |
| 117 | 116 | static READ16_HANDLER( peno_rand2 ) |
| 118 | 117 | { |
| 119 | return mame_rand( | |
| 118 | return mame_rand(machine); | |
| 120 | 119 | } |
| 121 | 120 | #endif |
| 122 | 121 |
| r2724 | r2725 | |
|---|---|---|
| 58 | 58 | ***************************************************************************/ |
| 59 | 59 | |
| 60 | 60 | #include "driver.h" |
| 61 | #include "deprecat.h" | |
| 62 | 61 | #include "sound/2151intf.h" |
| 63 | 62 | #include "sound/okim6295.h" |
| 64 | 63 | |
| r2724 | r2725 | |
| 260 | 259 | |
| 261 | 260 | |
| 262 | 261 | |
| 263 | static void irqhandler(int linestate) | |
| 262 | static void irqhandler(running_machine *machine, int linestate) | |
| 264 | 263 | { |
| 265 | cpunum_set_input_line( | |
| 264 | cpunum_set_input_line(machine, 1,0,linestate); | |
| 266 | 265 | } |
| 267 | 266 | |
| 268 | 267 | static const struct YM2151interface ym2151_interface = |
| r2724 | r2725 | |
|---|---|---|
| 289 | 289 | ***************************************************************************/ |
| 290 | 290 | |
| 291 | 291 | #include "driver.h" |
| 292 | #include "deprecat.h" | |
| 293 | 292 | #include "cpu/m68000/m68000.h" |
| 294 | 293 | #include "video/taitoic.h" |
| 295 | 294 | #include "audio/taitosnd.h" |
| r2724 | r2725 | |
| 3819 | 3818 | |
| 3820 | 3819 | |
| 3821 | 3820 | /* handler called by the YM2610 emulator when the internal timers cause an IRQ */ |
| 3822 | static void irq_handler(int irq) | |
| 3821 | static void irq_handler(running_machine *machine, int irq) | |
| 3823 | 3822 | { |
| 3824 | cpunum_set_input_line( | |
| 3823 | cpunum_set_input_line(machine, 1,0,irq ? ASSERT_LINE : CLEAR_LINE); | |
| 3825 | 3824 | } |
| 3826 | 3825 | |
| 3827 | 3826 | static const struct YM2610interface ym2610_interface = |
| r2724 | r2725 | |
|---|---|---|
| 245 | 245 | WRITE8_HANDLER( stfight_coin_w ); |
| 246 | 246 | WRITE8_HANDLER( stfight_e800_w ); |
| 247 | 247 | READ8_HANDLER( stfight_fm_r ); |
| 248 | void stfight_adpcm_int( int data ); | |
| 248 | void stfight_adpcm_int( running_machine *machine, int data ); | |
| 249 | 249 | WRITE8_HANDLER( stfight_adpcm_control_w ); |
| 250 | 250 | |
| 251 | 251 | // video |
| r2724 | r2725 | |
|---|---|---|
| 1817 | 1817 | ROM_LOAD( "mqb-rom0.bin", 0xe000, 0x2000, CRC(12a90cb2) SHA1(a33203aea79fe43d1233a16e3fdddaceac6e4a20) ) |
| 1818 | 1818 | |
| 1819 | 1819 | ROM_REGION( 0x10000, REGION_CPU2, 0 ) |
| 1820 | ROM_LOAD( "mqb-snd1.bin", 0x7000, 0x800, CRC(e704b450) SHA1(d509f54658e9f0264b9ab865a6f36e5423a28904) ) | |
| 1821 | ROM_LOAD( "mqb-snd2.bin", 0x7800, 0x800, CRC(c6a98bf8) SHA1(cc5b5bb5966f5d79226f1f665a3f9fc934f4ef7f) ) | |
| 1820 | ROM_LOAD( "mqb-snd1.bin", 0x7000, 0x800, CRC(495ffcd2) SHA1(b2c16fffbd6af1c17fdb1a99844819e6ee0550ee) ) | |
| 1821 | ROM_LOAD( "mqb-snd2.bin", 0x7800, 0x800, CRC(9bbaa945) SHA1(13791b69cd6f426ad77a7d0537b10012feb0bc87) ) | |
| 1822 | 1822 | |
| 1823 | 1823 | ROM_REGION( 0x2000, REGION_GFX1, ROMREGION_DISPOSE ) |
| 1824 | 1824 | ROM_LOAD( "qb-bg0.bin", 0x0000, 0x1000, CRC(7a9ba824) SHA1(12aa6df499eb6996ee35f56acac403ff6290f844) ) /* chars */ |
| r2724 | r2725 | |
| 1970 | 1970 | ROM_LOAD( "qq-rom0.bin", 0xe000, 0x2000, CRC(8ddbe438) SHA1(31112d711af5d4039491e99a0be0c088b3272482) ) |
| 1971 | 1971 | |
| 1972 | 1972 | ROM_REGION( 0x10000, REGION_CPU2, 0 ) |
| 1973 | ROM_LOAD( "qq-snd1.bin", 0x7000, 0x800, BAD_DUMP CRC(15787c07) SHA1(8b7d03fbf2ebaa71b3a7e2f636a0d1bb9b796e43) ) | |
| 1974 | ROM_LOAD( "qq-snd2.bin", 0x7800, 0x800, BAD_DUMP CRC(58437508) SHA1(09d8053e7e99679b602dcda230d64db7fe6cb7f5) ) | |
| 1973 | ROM_LOAD( "qq-snd1.bin", 0x7000, 0x800, CRC(e704b450) SHA1(d509f54658e9f0264b9ab865a6f36e5423a28904) ) | |
| 1974 | ROM_LOAD( "qq-snd2.bin", 0x7800, 0x800, CRC(c6a98bf8) SHA1(cc5b5bb5966f5d79226f1f665a3f9fc934f4ef7f) ) | |
| 1975 | 1975 | |
| 1976 | 1976 | ROM_REGION( 0x2000, REGION_GFX1, ROMREGION_DISPOSE ) |
| 1977 | 1977 | ROM_LOAD( "qq-bg0.bin", 0x0000, 0x1000, CRC(050badde) SHA1(d049367e262cc6080e01d32227e86310166e00bb) ) /* chars */ |
| r2724 | r2725 | |
| 2260 | 2260 | GAME( 1983, krull, 0, krull, krull, 0, ROT270, "Gottlieb", "Krull", 0 ) |
| 2261 | 2261 | GAME( 1983, kngtmare, 0, gottlieb, kngtmare, 0, ROT0, "Gottlieb", "Knightmare (prototype)", GAME_NO_SOUND ) |
| 2262 | 2262 | GAME( 1983, sqbert, 0, qbert, qbert, 0, ROT270, "Mylstar", "Faster, Harder, More Challenging Q*bert (prototype)", 0 ) |
| 2263 | GAME( 1983, qbertqub, 0, qbert, qbertqub, 0, ROT270, "Mylstar", "Q*bert's Qubes", | |
| 2263 | GAME( 1983, qbertqub, 0, qbert, qbertqub, 0, ROT270, "Mylstar", "Q*bert's Qubes", 0 | |
| 2264 | 2264 | GAME( 1983, mach3, 0, gottlieb2,mach3, laserdsc, ROT0, "Mylstar", "M.A.C.H. 3", GAME_NOT_WORKING ) |
| 2265 | 2265 | GAME( 1983, screwloo, 0, gottlieb2,screwloo, gottlieb, ROT0, "Mylstar", "Screw Loose (prototype)", 0 ) |
| 2266 | 2266 | GAME( 1984, cobram3, 0, gottlieb2,mach3, laserdsc, ROT0, "Data East","Cobra Command", GAME_NOT_WORKING ) |
| r2724 | r2725 | |
|---|---|---|
| 71 | 71 | */ |
| 72 | 72 | |
| 73 | 73 | #include "driver.h" |
| 74 | #include "deprecat.h" | |
| 75 | 74 | #include "machine/eeprom.h" |
| 76 | 75 | #include "includes/kaneko16.h" |
| 77 | 76 | #include "sound/2203intf.h" |
| r2724 | r2725 | |
| 101 | 100 | |
| 102 | 101 | |
| 103 | 102 | /* Update the IRQ state based on all possible causes */ |
| 104 | static void update_irq_state( | |
| 103 | static void update_irq_state(running_machine *machine) | |
| 105 | 104 | { |
| 106 | 105 | if (vblank_irq || sprite_irq || unknown_irq) |
| 107 | cpunum_set_input_line( | |
| 106 | cpunum_set_input_line(machine, 0, 1, ASSERT_LINE); | |
| 108 | 107 | else |
| 109 | cpunum_set_input_line( | |
| 108 | cpunum_set_input_line(machine, 0, 1, CLEAR_LINE); | |
| 110 | 109 | } |
| 111 | 110 | |
| 112 | 111 | |
| r2724 | r2725 | |
| 115 | 114 | static INTERRUPT_GEN( sandscrp_interrupt ) |
| 116 | 115 | { |
| 117 | 116 | vblank_irq = 1; |
| 118 | update_irq_state(); | |
| 117 | update_irq_state(machine); | |
| 119 | 118 | } |
| 120 | 119 | |
| 121 | 120 | |
| 122 | 121 | static VIDEO_EOF( sandscrp ) |
| 123 | 122 | { |
| 124 | 123 | sprite_irq = 1; |
| 125 | update_irq_state(); | |
| 124 | update_irq_state(machine); | |
| 126 | 125 | pandora_eof(machine); |
| 127 | 126 | } |
| 128 | 127 | |
| r2724 | r2725 | |
| 148 | 147 | if (data & 0x20) vblank_irq = 0; |
| 149 | 148 | } |
| 150 | 149 | |
| 151 | update_irq_state(); | |
| 150 | update_irq_state(machine); | |
| 152 | 151 | } |
| 153 | 152 | |
| 154 | 153 | |
| r2724 | r2725 | |
| 415 | 414 | |
| 416 | 415 | /* YM3014B + YM2203C */ |
| 417 | 416 | |
| 418 | static void irq_handler(int irq) | |
| 417 | static void irq_handler(running_machine *machine, int irq) | |
| 419 | 418 | { |
| 420 | cpunum_set_input_line( | |
| 419 | cpunum_set_input_line(machine, 1,0,irq ? ASSERT_LINE : CLEAR_LINE); | |
| 421 | 420 | } |
| 422 | 421 | |
| 423 | 422 | static const struct YM2203interface ym2203_intf_sandscrp = |
| r2724 | r2725 | |
|---|---|---|
| 65 | 65 | ***************************************************************************/ |
| 66 | 66 | |
| 67 | 67 | #include "driver.h" |
| 68 | #include "deprecat.h" | |
| 69 | 68 | #include "cpu/m6800/m6800.h" |
| 70 | 69 | #include "cpu/m6805/m6805.h" |
| 71 | 70 | #include "cpu/m6809/m6809.h" |
| r2724 | r2725 | |
| 348 | 347 | } |
| 349 | 348 | |
| 350 | 349 | |
| 351 | static void irq_handler(int irq) | |
| 350 | static void irq_handler(running_machine *machine, int irq) | |
| 352 | 351 | { |
| 353 | cpunum_set_input_line( | |
| 352 | cpunum_set_input_line(machine, snd_cpu, ym_irq , irq ? ASSERT_LINE : CLEAR_LINE ); | |
| 354 | 353 | } |
| 355 | 354 | |
| 356 | 355 | |
| r2724 | r2725 | |
| 458 | 457 | } |
| 459 | 458 | |
| 460 | 459 | |
| 461 | static void dd_adpcm_int(int chip) | |
| 460 | static void dd_adpcm_int(running_machine *machine, int chip) | |
| 462 | 461 | { |
| 463 | 462 | static int adpcm_data[2] = { -1, -1 }; |
| 464 | 463 |
| r2724 | r2725 | |
|---|---|---|
| 99 | 99 | |
| 100 | 100 | |
| 101 | 101 | #include "driver.h" |
| 102 | #include "deprecat.h" | |
| 103 | 102 | #include "cpu/z80/z80.h" |
| 104 | 103 | #include "cpu/m6805/m6805.h" |
| 105 | 104 | #include "sound/ay8910.h" |
| r2724 | r2725 | |
| 565 | 564 | } |
| 566 | 565 | |
| 567 | 566 | |
| 568 | static void rjammer_adpcm_vck (int data) | |
| 567 | static void rjammer_adpcm_vck (running_machine *machine, int data) | |
| 569 | 568 | { |
| 570 | 569 | ls74 = (ls74+1) & 1; |
| 571 | 570 | |
| 572 | 571 | if (ls74==1) |
| 573 | 572 | { |
| 574 | 573 | MSM5205_data_w(0, (ls377>>0) & 15 ); |
| 575 | cpunum_set_input_line( | |
| 574 | cpunum_set_input_line(machine, 2, 0, ASSERT_LINE ); | |
| 576 | 575 | } |
| 577 | 576 | else |
| 578 | 577 | { |
| r2724 | r2725 | |
|---|---|---|
| 145 | 145 | static CUSTOM_INPUT( teetert_input_direction_r ) |
| 146 | 146 | { |
| 147 | 147 | int result = 0; |
| 148 | UINT8 dial = input_port_read(machine, "DIAL"); | |
| 148 | UINT8 dial = input_port_read(field->port->machine, "DIAL"); | |
| 149 | 149 | |
| 150 | 150 | if (dial != last_dial) |
| 151 | 151 | { |
| r2724 | r2725 | |
| 164 | 164 | |
| 165 | 165 | static CUSTOM_INPUT( teetert_input_movement_r ) |
| 166 | 166 | { |
| 167 | UINT8 dial = input_port_read(machine, "DIAL"); | |
| 167 | UINT8 dial = input_port_read(field->port->machine, "DIAL"); | |
| 168 | 168 | |
| 169 | 169 | return (dial != last_dial) ? 1 : 0; |
| 170 | 170 | } |
| r2724 | r2725 | |
| 500 | 500 | PORT_START_TAG("IN2") |
| 501 | 501 | PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_NAME("Yellow Button") |
| 502 | 502 | PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_NAME("Red Button") |
| 503 | PORT_ | |
| 503 | PORT_DIPNAME( 0x04, 0x04, | |
| 504 | 504 | PORT_DIPSETTING( 0x04, DEF_STR( Off ) ) |
| 505 | 505 | PORT_DIPSETTING( 0x00, DEF_STR( On ) ) |
| 506 | 506 | PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_BUTTON4 ) PORT_NAME("Blue Button") |
| r2724 | r2725 | |
|---|---|---|
| 40 | 40 | */ |
| 41 | 41 | |
| 42 | 42 | #include "driver.h" |
| 43 | #include "deprecat.h" | |
| 44 | 43 | #include "sound/2151intf.h" |
| 45 | 44 | #include "sound/okim6295.h" |
| 46 | 45 | |
| r2724 | r2725 | |
| 417 | 416 | GFXDECODE_ENTRY( REGION_GFX2, 0, mugsmash2_layout, 0x100, 256 ) /* bg tiles */ |
| 418 | 417 | GFXDECODE_END |
| 419 | 418 | |
| 420 | static void irq_handler(int irq) | |
| 419 | static void irq_handler(running_machine *machine, int irq) | |
| 421 | 420 | { |
| 422 | cpunum_set_input_line( | |
| 421 | cpunum_set_input_line(machine, 1, 0 , irq ? ASSERT_LINE : CLEAR_LINE ); | |
| 423 | 422 | } |
| 424 | 423 | |
| 425 | 424 | static const struct YM2151interface ym2151_interface = |
| r2724 | r2725 | |
|---|---|---|
| 13 | 13 | ***************************************************************************/ |
| 14 | 14 | |
| 15 | 15 | #include "driver.h" |
| 16 | #include "deprecat.h" | |
| 17 | 16 | #include "cpu/m6502/m6502.h" |
| 18 | 17 | #include "sound/2203intf.h" |
| 19 | 18 | #include "sound/3812intf.h" |
| r2724 | r2725 | |
| 52 | 51 | |
| 53 | 52 | static int msm5205next; |
| 54 | 53 | |
| 55 | static void pcktgal_adpcm_int(int data) | |
| 54 | static void pcktgal_adpcm_int(running_machine *machine, int data) | |
| 56 | 55 | { |
| 57 | 56 | static int toggle; |
| 58 | 57 | |
| r2724 | r2725 | |
| 61 | 60 | |
| 62 | 61 | toggle = 1 - toggle; |
| 63 | 62 | if (toggle) |
| 64 | cpunum_set_input_line( | |
| 63 | cpunum_set_input_line(machine, 1,M6502_IRQ_LINE,HOLD_LINE); | |
| 65 | 64 | } |
| 66 | 65 | |
| 67 | 66 | static WRITE8_HANDLER( pcktgal_adpcm_data_w ) |
| r2724 | r2725 | |
|---|---|---|
| 565 | 565 | |
| 566 | 566 | static READ32_HANDLER( hng64_random_read ) |
| 567 | 567 | { |
| 568 | return mame_rand( | |
| 568 | return mame_rand(machine)&0xffffffff; | |
| 569 | 569 | } |
| 570 | 570 | |
| 571 | 571 | |
| r2724 | r2725 | |
| 620 | 620 | a = ((paletteram32[offset] & 0xff000000) >>24); |
| 621 | 621 | |
| 622 | 622 | // a sure ain't alpha. |
| 623 | // alpha_set_level(mame_rand( | |
| 623 | // alpha_set_level(mame_rand(machine)) ; | |
| 624 | 624 | // mame_printf_debug("Alpha : %d %d %d %d\n", a, b, g, r) ; |
| 625 | 625 | |
| 626 | 626 | //if (a != 0) |
| r2724 | r2725 | |
| 638 | 638 | |
| 639 | 639 | if(offset==0x85b) return 0x00000010; |
| 640 | 640 | |
| 641 | return mame_rand( | |
| 641 | return mame_rand(machine)&0xffffffff; | |
| 642 | 642 | } |
| 643 | 643 | |
| 644 | 644 | |
| r2724 | r2725 | |
| 740 | 740 | case 0x600: return no_machine_error_code; |
| 741 | 741 | } |
| 742 | 742 | |
| 743 | return mame_rand( | |
| 743 | return mame_rand(machine)&0xffffffff; | |
| 744 | 744 | //return hng64_dualport[offset]; |
| 745 | 745 | } |
| 746 | 746 |
| r2724 | r2725 | |
|---|---|---|
| 38 | 38 | ******************************************************************************/ |
| 39 | 39 | |
| 40 | 40 | #include "driver.h" |
| 41 | #include "deprecat.h" | |
| 42 | 41 | #include "sound/es5506.h" |
| 43 | 42 | |
| 44 | 43 | /*** README INFO ************************************************************** |
| r2724 | r2725 | |
| 511 | 510 | |
| 512 | 511 | /*** MACHINE DRIVER **********************************************************/ |
| 513 | 512 | |
| 514 | static void irqhandler(int irq) | |
| 513 | static void irqhandler(running_machine *machine, int irq) | |
| 515 | 514 | { |
| 516 | 515 | logerror("ES5506 irq %d\n",irq); |
| 517 | 516 | |
| 518 | 517 | /* IRQ lines 1 & 4 on the sound 68000 are definitely triggered by the ES5506, |
| 519 | 518 | but I haven't noticed the ES5506 ever assert the line - maybe only used when developing the game? */ |
| 520 | // cpunum_set_input_line( | |
| 519 | // cpunum_set_input_line(machine, 1,1,irq ? ASSERT_LINE : CLEAR_LINE); | |
| 521 | 520 | } |
| 522 | 521 | |
| 523 | 522 | static const struct ES5506interface es5506_interface = |
| r2724 | r2725 | |
|---|---|---|
| 182 | 182 | ***************************************************************************/ |
| 183 | 183 | |
| 184 | 184 | #include "driver.h" |
| 185 | #include "deprecat.h" | |
| 186 | 185 | #include "machine/tait8741.h" |
| 187 | 186 | #include "cpu/z80/z80.h" |
| 188 | 187 | #include "sound/2203intf.h" |
| r2724 | r2725 | |
| 288 | 287 | /* bit 0 : ?? */ |
| 289 | 288 | } |
| 290 | 289 | /* YM2203 IRQ */ |
| 291 | static void gladiator_ym_irq(int irq) | |
| 290 | static void gladiator_ym_irq(running_machine *machine, int irq) | |
| 292 | 291 | { |
| 293 | 292 | /* NMI IRQ is not used by gladiator sound program */ |
| 294 | cpunum_set_input_line( | |
| 293 | cpunum_set_input_line(machine, 1, INPUT_LINE_NMI, irq ? ASSERT_LINE : CLEAR_LINE); | |
| 295 | 294 | } |
| 296 | 295 | |
| 297 | 296 | /*Sound Functions*/ |
| r2724 | r2725 | |
| 362 | 361 | |
| 363 | 362 | static WRITE8_HANDLER(qx3_w){ } |
| 364 | 363 | |
| 365 | static READ8_HANDLER(qx2_r){ return mame_rand( | |
| 364 | static READ8_HANDLER(qx2_r){ return mame_rand(machine); } | |
| 366 | 365 | |
| 367 | static READ8_HANDLER(qx3_r){ return mame_rand( | |
| 366 | static READ8_HANDLER(qx3_r){ return mame_rand(machine)&0xf; } | |
| 368 | 367 | |
| 369 | 368 | static READ8_HANDLER(qx0_r) |
| 370 | 369 | { |
| r2724 | r2725 | |
| 651 | 650 | |
| 652 | 651 | static READ8_HANDLER(f1_r) |
| 653 | 652 | { |
| 654 | return mame_rand( | |
| 653 | return mame_rand(machine); | |
| 655 | 654 | } |
| 656 | 655 | |
| 657 | 656 | static const struct YM2203interface ppking_ym2203_interface = |
| r2724 | r2725 | |
|---|---|---|
| 8 | 8 | */ |
| 9 | 9 | |
| 10 | 10 | #include "driver.h" |
| 11 | #include "deprecat.h" | |
| 12 | 11 | |
| 13 | 12 | static READ16_HANDLER( unknown_read_0xc00000 ) |
| 14 | 13 | { |
| 15 | return mame_rand( | |
| 14 | return mame_rand(machine); | |
| 16 | 15 | } |
| 17 | 16 | |
| 18 | 17 | static READ16_HANDLER( unknown_read_0xd00000 ) |
| 19 | 18 | { |
| 20 | return mame_rand( | |
| 19 | return mame_rand(machine); | |
| 21 | 20 | } |
| 22 | 21 | |
| 23 | 22 | static READ16_HANDLER( unknown_read_0xffff00 ) |
| 24 | 23 | { |
| 25 | return mame_rand( | |
| 24 | return mame_rand(machine); | |
| 26 | 25 | } |
| 27 | 26 | |
| 28 | 27 | static ADDRESS_MAP_START( stepstag_readmem, ADDRESS_SPACE_PROGRAM, 16 ) |
| r2724 | r2725 | |
| 71 | 70 | |
| 72 | 71 | static READ16_HANDLER( unknown_sub_read_0xbe0004 ) |
| 73 | 72 | { |
| 74 | return mame_rand( | |
| 73 | return mame_rand(machine); | |
| 75 | 74 | } |
| 76 | 75 | |
| 77 | 76 |
| r2724 | r2725 | |
|---|---|---|
| 577 | 577 | |
| 578 | 578 | static int adpcm_pos; |
| 579 | 579 | |
| 580 | static void champwr_msm5205_vck(int chip) | |
| 580 | static void champwr_msm5205_vck(running_machine *machine, int chip) | |
| 581 | 581 | { |
| 582 | 582 | static int adpcm_data = -1; |
| 583 | 583 | |
| r2724 | r2725 | |
| 2246 | 2246 | |
| 2247 | 2247 | |
| 2248 | 2248 | |
| 2249 | static void irqhandler(int irq) | |
| 2249 | static void irqhandler(running_machine *machine, int irq) | |
| 2250 | 2250 | { |
| 2251 | cpunum_set_input_line( | |
| 2251 | cpunum_set_input_line(machine, 1,0,irq ? ASSERT_LINE : CLEAR_LINE); | |
| 2252 | 2252 | } |
| 2253 | 2253 | |
| 2254 | 2254 | static WRITE8_HANDLER( portA_w ) |
| r2724 | r2725 | |
|---|---|---|
| 41 | 41 | ******************************************************************/ |
| 42 | 42 | |
| 43 | 43 | #include "driver.h" |
| 44 | #include "deprecat.h" | |
| 45 | 44 | #include "cpu/z80/z80.h" |
| 46 | 45 | #include "audio/seibu.h" |
| 47 | 46 | #include "sound/2151intf.h" |
| r2724 | r2725 | |
| 513 | 512 | GFXDECODE_END |
| 514 | 513 | |
| 515 | 514 | |
| 516 | static void irqhandler(int irq) | |
| 515 | static void irqhandler(running_machine *machine, int irq) | |
| 517 | 516 | { |
| 518 | cpunum_set_input_line( | |
| 517 | cpunum_set_input_line(machine, 1,0,irq ? ASSERT_LINE : CLEAR_LINE); | |
| 519 | 518 | } |
| 520 | 519 | |
| 521 | 520 | static const struct YM2151interface cabalbl_ym2151_interface = |
| r2724 | r2725 | |
|---|---|---|
| 932 | 932 | |
| 933 | 933 | /***************************************************************************/ |
| 934 | 934 | |
| 935 | static void sound_irq(int state) | |
| 935 | static void sound_irq(running_machine *machine, int state) | |
| 936 | 936 | { |
| 937 | 937 | if (state) |
| 938 | 938 | timer_call_after_resynch(NULL, YM2151_ASSERT, setvector_callback); |
| r2724 | r2725 | |
|---|---|---|
| 61 | 61 | static INPUT_CHANGED( coin_inserted ) |
| 62 | 62 | { |
| 63 | 63 | /* coin insertion causes an NMI */ |
| 64 | cpunum_set_input_line(machine, 0, INPUT_LINE_NMI, newval ? CLEAR_LINE : ASSERT_LINE); | |
| 64 | cpunum_set_input_line(field->port->machine, 0, INPUT_LINE_NMI, newval ? CLEAR_LINE : ASSERT_LINE); | |
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 |
| r2724 | r2725 | |
|---|---|---|
| 1054 | 1054 | disable_screen_blanking = 0; |
| 1055 | 1055 | |
| 1056 | 1056 | /* see if we have a sound CPU and a UPD7759 chip */ |
| 1057 | has_sound_cpu = (mame_find_cpu_index( | |
| 1057 | has_sound_cpu = (mame_find_cpu_index(machine, "sound") != -1); | |
| 1058 | 1058 | } |
| 1059 | 1059 | |
| 1060 | 1060 |
| r2724 | r2725 | |
|---|---|---|
| 364 | 364 | Straight from Ddragon 3 with some adjusted volumes |
| 365 | 365 | *******************************************************************************/ |
| 366 | 366 | |
| 367 | static void dd3_ymirq_handler(int irq) | |
| 367 | static void dd3_ymirq_handler(running_machine *machine, int irq) | |
| 368 | 368 | { |
| 369 | cpunum_set_input_line( | |
| 369 | cpunum_set_input_line(machine, 1, 0 , irq ? ASSERT_LINE : CLEAR_LINE ); | |
| 370 | 370 | } |
| 371 | 371 | |
| 372 | 372 | static const struct YM2151interface ym2151_interface = |
| r2724 | r2725 | |
|---|---|---|
| 33 | 33 | ***************************************************************************/ |
| 34 | 34 | |
| 35 | 35 | #include "driver.h" |
| 36 | #include "deprecat.h" | |
| 37 | 36 | #include "sound/2203intf.h" |
| 38 | 37 | #include "sound/3812intf.h" |
| 39 | 38 | #include "sound/okim6295.h" |
| r2724 | r2725 | |
| 500 | 499 | |
| 501 | 500 | ***************************************************************************/ |
| 502 | 501 | |
| 503 | static void soundirq(int state) | |
| 502 | static void soundirq(running_machine *machine, int state) | |
| 504 | 503 | { |
| 505 | cpunum_set_input_line( | |
| 504 | cpunum_set_input_line(machine, 1, 0, state); | |
| 506 | 505 | } |
| 507 | 506 | |
| 508 | 507 | static const struct YM3812interface fuuki16_ym3812_intf = |
| r2724 | r2725 | |
|---|---|---|
| 521 | 521 | |
| 522 | 522 | |
| 523 | 523 | |
| 524 | static void voodoo_vblank_0(int param) | |
| 524 | static void voodoo_vblank_0(running_machine *machine, int param) | |
| 525 | 525 | { |
| 526 | cpunum_set_input_line( | |
| 526 | cpunum_set_input_line(machine, 0, INPUT_LINE_IRQ0, ASSERT_LINE); | |
| 527 | 527 | } |
| 528 | 528 | |
| 529 | 529 | static VIDEO_START( nwktr ) |
| r2724 | r2725 | |
| 962 | 962 | //jamma_jvs_cmd_exec(); |
| 963 | 963 | } |
| 964 | 964 | |
| 965 | static void sound_irq_callback(int irq) | |
| 965 | static void sound_irq_callback(running_machine *machine, int irq) | |
| 966 | 966 | { |
| 967 | 967 | if (irq == 0) |
| 968 | cpunum_set_input_line( | |
| 968 | cpunum_set_input_line(machine, 1, INPUT_LINE_IRQ1, PULSE_LINE); | |
| 969 | 969 | else |
| 970 | cpunum_set_input_line( | |
| 970 | cpunum_set_input_line(machine, 1, INPUT_LINE_IRQ2, PULSE_LINE); | |
| 971 | 971 | } |
| 972 | 972 | |
| 973 | 973 | static DRIVER_INIT( nwktr ) |
| r2724 | r2725 | |
|---|---|---|
| 217 | 217 | PORT_DIPSETTING( 0x80, DEF_STR( On ) ) |
| 218 | 218 | |
| 219 | 219 | PORT_START_TAG("1E86") |
| 220 | PORT_ | |
| 220 | PORT_DIPNAME( | |
| 221 | 221 | PORT_DIPSETTING( 0x00, DEF_STR( Off ) ) |
| 222 | 222 | PORT_DIPSETTING( 0x01, DEF_STR( On ) ) |
| 223 | 223 |
| r2724 | r2725 | |
|---|---|---|
| 20 | 20 | ***************************************************************************/ |
| 21 | 21 | |
| 22 | 22 | #include "driver.h" |
| 23 | #include "deprecat.h" | |
| 24 | 23 | #include "cpu/z80/z80.h" |
| 25 | 24 | #include "sound/ay8910.h" |
| 26 | 25 | #include "sound/okim6295.h" |
| r2724 | r2725 | |
| 487 | 486 | NULL |
| 488 | 487 | }; |
| 489 | 488 | |
| 490 | static void irqhandler(int linestate) | |
| 489 | static void irqhandler(running_machine *machine, int linestate) | |
| 491 | 490 | { |
| 492 | cpunum_set_input_line( | |
| 491 | cpunum_set_input_line(machine, 1, INPUT_LINE_NMI, linestate); | |
| 493 | 492 | } |
| 494 | 493 | |
| 495 | 494 | static const struct YM3438interface ym3438_interface = |
| r2724 | r2725 | |
|---|---|---|
| 12 | 12 | */ |
| 13 | 13 | |
| 14 | 14 | #include "driver.h" |
| 15 | #include "deprecat.h" | |
| 16 | 15 | #include "sound/2203intf.h" |
| 17 | 16 | |
| 18 | 17 | static int interrupt_scanline=192; |
| r2724 | r2725 | |
| 258 | 257 | GFXDECODE_ENTRY( REGION_GFX1, 0, tiles8x8_layout, 0, 0x80 ) |
| 259 | 258 | GFXDECODE_END |
| 260 | 259 | |
| 261 | static void irqhandler(int irq) | |
| 260 | static void irqhandler(running_machine *machine, int irq) | |
| 262 | 261 | { |
| 263 | 262 | if(out & 0x10) |
| 264 | cpunum_set_input_line( | |
| 263 | cpunum_set_input_line(machine, 0,2,irq ? ASSERT_LINE : CLEAR_LINE); | |
| 265 | 264 | } |
| 266 | 265 | |
| 267 | 266 | static const struct YM2203interface ym2203_interface = |
| r2724 | r2725 | |
|---|---|---|
| 64 | 64 | |
| 65 | 65 | |
| 66 | 66 | #include "driver.h" |
| 67 | #include "deprecat.h" | |
| 68 | 67 | #include "sound/2610intf.h" |
| 69 | 68 | |
| 70 | 69 | #define TAOTAIDO_SHOW_ALL_INPUTS 0 |
| r2724 | r2725 | |
| 319 | 318 | GFXDECODE_ENTRY( REGION_GFX2, 0, taotaido_layout, 0x300, 256 ) /* bg tiles */ |
| 320 | 319 | GFXDECODE_END |
| 321 | 320 | |
| 322 | static void irqhandler(int irq) | |
| 321 | static void irqhandler(running_machine *machine, int irq) | |
| 323 | 322 | { |
| 324 | cpunum_set_input_line( | |
| 323 | cpunum_set_input_line(machine, 1,0,irq ? ASSERT_LINE : CLEAR_LINE); | |
| 325 | 324 | } |
| 326 | 325 | |
| 327 | 326 | static const struct YM2610interface ym2610_interface = |
| r2724 | r2725 | |
|---|---|---|
| 19 | 19 | |
| 20 | 20 | |
| 21 | 21 | #include "driver.h" |
| 22 | #include "deprecat.h" | |
| 23 | 22 | |
| 24 | 23 | static UINT8 *fortecar_ram; |
| 25 | 24 | |
| r2724 | r2725 | |
| 34 | 33 | #ifdef UNUSED_FUNCTION |
| 35 | 34 | READ8_HANDLER( fortecar_read62 ) |
| 36 | 35 | { |
| 37 | return mame_rand( | |
| 36 | return mame_rand(machine); | |
| 38 | 37 | } |
| 39 | 38 | #endif |
| 40 | 39 |
| r2724 | r2725 | |
|---|---|---|
| 46 | 46 | */ |
| 47 | 47 | |
| 48 | 48 | #include "driver.h" |
| 49 | #include "deprecat.h" | |
| 50 | 49 | |
| 51 | 50 | static UINT16 *unkram; |
| 52 | 51 | static UINT16 *mainram; |
| r2724 | r2725 | |
| 73 | 72 | // 40,41,44 = ? |
| 74 | 73 | // 4a = flags? |
| 75 | 74 | if(offset==0xc9/2 )//|| offset==0x40 || offset==0x41 || offset==0x44) |
| 76 | return mame_rand( | |
| 75 | return mame_rand(machine); | |
| 77 | 76 | return unkram[offset]; |
| 78 | 77 | } |
| 79 | 78 |
| r2724 | r2725 | |
|---|---|---|
| 59 | 59 | * |
| 60 | 60 | *************************************/ |
| 61 | 61 | |
| 62 | static void ptm_irq(int state) | |
| 62 | static void ptm_irq(running_machine *machine, int state) | |
| 63 | 63 | { |
| 64 | cpunum_set_input_line( | |
| 64 | cpunum_set_input_line(machine, 0, INT_6840PTM, state); | |
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | static const ptm6840_interface ptm_intf = |
| r2724 | r2725 | |
|---|---|---|
| 455 | 455 | |
| 456 | 456 | /***************************************************************************/ |
| 457 | 457 | |
| 458 | static void sound_irq(int state) | |
| 458 | static void sound_irq(running_machine *machine, int state) | |
| 459 | 459 | { |
| 460 | 460 | if (state) |
| 461 | 461 | timer_call_after_resynch(NULL, YM2151_ASSERT,setvector_callback); |
| r2724 | r2725 | |
|---|---|---|
| 569 | 569 | **************************************************************/ |
| 570 | 570 | |
| 571 | 571 | /* handler called by the YM2610 emulator when the internal timers cause an IRQ */ |
| 572 | static void irqhandler(int irq) | |
| 572 | static void irqhandler(running_machine *machine, int irq) | |
| 573 | 573 | { |
| 574 | cpunum_set_input_line( | |
| 574 | cpunum_set_input_line(machine, 1,0,irq ? ASSERT_LINE : CLEAR_LINE); | |
| 575 | 575 | } |
| 576 | 576 | |
| 577 | 577 | static const struct YM2610interface ym2610_interface = |
| r2724 | r2725 | |
|---|---|---|
| 391 | 391 | |
| 392 | 392 | |
| 393 | 393 | /* handler called by the 3526 emulator when the internal timers cause an IRQ */ |
| 394 | static void irqhandler(int linestate) | |
| 394 | static void irqhandler(running_machine *machine, int linestate) | |
| 395 | 395 | { |
| 396 | cpunum_set_input_line( | |
| 396 | cpunum_set_input_line(machine, 1,1,linestate); | |
| 397 | 397 | } |
| 398 | 398 | |
| 399 | 399 | static const struct YM3526interface ym3526_interface = |
| r2724 | r2725 | |
|---|---|---|
| 456 | 456 | */ |
| 457 | 457 | |
| 458 | 458 | /* YM2151 IRQ */ |
| 459 | static void megasys1_sound_irq(int irq) | |
| 459 | static void megasys1_sound_irq(running_machine *machine, int irq) | |
| 460 | 460 | { |
| 461 | 461 | if (irq) |
| 462 | cpunum_set_input_line( | |
| 462 | cpunum_set_input_line(machine, 1, 4, HOLD_LINE); | |
| 463 | 463 | } |
| 464 | 464 | |
| 465 | 465 | static READ16_HANDLER( oki_status_0_r ) |
| r2724 | r2725 | |
| 787 | 787 | ***************************************************************************/ |
| 788 | 788 | |
| 789 | 789 | |
| 790 | static void irq_handler(int irq) | |
| 790 | static void irq_handler(running_machine *machine, int irq) | |
| 791 | 791 | { |
| 792 | cpunum_set_input_line( | |
| 792 | cpunum_set_input_line(machine, 1,0,irq ? ASSERT_LINE : CLEAR_LINE); | |
| 793 | 793 | } |
| 794 | 794 | |
| 795 | 795 |
| r2724 | r2725 | |
|---|---|---|
| 124 | 124 | ***************************************************************************/ |
| 125 | 125 | |
| 126 | 126 | #include "driver.h" |
| 127 | #include "deprecat.h" | |
| 128 | 127 | #include "video/konamiic.h" |
| 129 | 128 | #include "sound/2610intf.h" |
| 130 | 129 | #include "crshrace.h" |
| r2724 | r2725 | |
| 606 | 605 | |
| 607 | 606 | |
| 608 | 607 | |
| 609 | static void irqhandler(int irq) | |
| 608 | static void irqhandler(running_machine *machine, int irq) | |
| 610 | 609 | { |
| 611 | cpunum_set_input_line( | |
| 610 | cpunum_set_input_line(machine, 1,0,irq ? ASSERT_LINE : CLEAR_LINE); | |
| 612 | 611 | } |
| 613 | 612 | |
| 614 | 613 | static const struct YM2610interface ym2610_interface = |
| r2724 | r2725 | |
|---|---|---|
| 266 | 266 | /* Reading eff4, F0 times must yield at most 80-1 consecutive |
| 267 | 267 | equal values */ |
| 268 | 268 | case 0xff4: |
| 269 | return mame_rand( | |
| 269 | return mame_rand(machine); | |
| 270 | 270 | |
| 271 | 271 | default: |
| 272 | 272 | return devram[offset]; |
| r2724 | r2725 | |
|---|---|---|
| 402 | 402 | /* and that the speedup button is pressed */ |
| 403 | 403 | else |
| 404 | 404 | { |
| 405 | int portnum = port_tag_to_index("FAKE"); | |
| 406 | if (portnum != -1) | |
| 407 | { | |
| 408 | UINT8 value = input_port_read_indexed(machine, portnum); | |
| 409 | if ((value & 7) == 5 || (value & 6) == 2) | |
| 410 | irq0_line_hold(machine, cpunum); | |
| 411 | } | |
| 405 | UINT8 value = input_port_read_safe(machine, "FAKE", 0); | |
| 406 | if ((value & 7) == 5 || (value & 6) == 2) | |
| 407 | irq0_line_hold(machine, cpunum); | |
| 412 | 408 | } |
| 413 | 409 | } |
| 414 | 410 | |
| r2724 | r2725 | |
| 534 | 530 | { |
| 535 | 531 | /* The return value determines what the mystery item is. Each bit corresponds |
| 536 | 532 | to a question mark */ |
| 537 | return mame_rand( | |
| 533 | return mame_rand(machine) & 0x0f; | |
| 538 | 534 | } |
| 539 | 535 | |
| 540 | 536 | |
| r2724 | r2725 | |
| 1285 | 1281 | PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_4WAY |
| 1286 | 1282 | PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_4WAY |
| 1287 | 1283 | PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_4WAY |
| 1288 | PORT_ | |
| 1284 | PORT_DIPNAME( | |
| 1289 | 1285 | PORT_DIPSETTING( 0x10, DEF_STR( Off ) ) |
| 1290 | 1286 | PORT_DIPSETTING( 0x00, DEF_STR( On ) ) |
| 1291 | 1287 | PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_COIN1 ) |
| r2724 | r2725 | |
| 1346 | 1342 | PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_4WAY |
| 1347 | 1343 | PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_4WAY |
| 1348 | 1344 | PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_4WAY |
| 1349 | PORT_ | |
| 1345 | PORT_DIPNAME( | |
| 1350 | 1346 | PORT_DIPSETTING( 0x10, DEF_STR( Off ) ) |
| 1351 | 1347 | PORT_DIPSETTING( 0x00, DEF_STR( On ) ) |
| 1352 | 1348 | PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_COIN1 ) |
| r2724 | r2725 | |
| 1397 | 1393 | PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_4WAY |
| 1398 | 1394 | PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_4WAY |
| 1399 | 1395 | PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_4WAY |
| 1400 | PORT_ | |
| 1396 | PORT_DIPNAME( | |
| 1401 | 1397 | PORT_DIPSETTING( 0x10, DEF_STR( Off ) ) |
| 1402 | 1398 | PORT_DIPSETTING( 0x00, DEF_STR( On ) ) |
| 1403 | 1399 | PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_COIN1 ) |
| r2724 | r2725 | |
| 2065 | 2061 | PORT_DIPNAME( 0x01, 0x00, DEF_STR( Unknown ) ) |
| 2066 | 2062 | PORT_DIPSETTING( 0x00, DEF_STR( Off ) ) |
| 2067 | 2063 | PORT_DIPSETTING( 0x01, DEF_STR( On ) ) |
| 2068 | PORT_ | |
| 2064 | PORT_DIPNAME( | |
| 2069 | 2065 | PORT_DIPSETTING( 0x00, DEF_STR( Off ) ) |
| 2070 | 2066 | PORT_DIPSETTING( 0x02, DEF_STR( On ) ) |
| 2071 | 2067 | PORT_DIPNAME( 0x04, 0x00, DEF_STR( Unknown ) ) |
| r2724 | r2725 | |
| 2139 | 2135 | PORT_DIPNAME( 0x01, 0x00, DEF_STR( Unknown ) ) |
| 2140 | 2136 | PORT_DIPSETTING( 0x00, DEF_STR( Off ) ) |
| 2141 | 2137 | PORT_DIPSETTING( 0x01, DEF_STR( On ) ) |
| 2142 | PORT_ | |
| 2138 | PORT_DIPNAME( | |
| 2143 | 2139 | PORT_DIPSETTING( 0x00, DEF_STR( Off ) ) |
| 2144 | 2140 | PORT_DIPSETTING( 0x02, DEF_STR( On ) ) |
| 2145 | 2141 | PORT_DIPNAME( 0x04, 0x00, DEF_STR( Unknown ) ) |
| r2724 | r2725 | |
| 2226 | 2222 | PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_4WAY |
| 2227 | 2223 | PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_4WAY |
| 2228 | 2224 | PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_4WAY |
| 2229 | PORT_BIT(0x10, 0x10, IPT_DIPSWITCH_NAME ) PORT_NAME("Rack Test (Cheat)") PORT_CODE(KEYCODE_F1) | |
| 2230 | PORT_DIPSETTING(0x10, DEF_STR( Off ) ) | |
| 2231 | PORT_DIPSETTING(0x00, DEF_STR( On ) ) | |
| 2225 | PORT_DIPNAME( 0x10, 0x10, "Rack Test (Cheat)" ) PORT_CODE(KEYCODE_F1) | |
| 2226 | PORT_DIPSETTING( 0x10, DEF_STR( Off ) ) | |
| 2227 | PORT_DIPSETTING( 0x00, DEF_STR( On ) ) | |
| 2232 | 2228 | PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_COIN1 ) |
| 2233 | 2229 | PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_BUTTON1 ) |
| 2234 | 2230 | PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_COIN2 ) |
| r2724 | r2725 | |
| 2553 | 2549 | PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_4WAY |
| 2554 | 2550 | PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_4WAY |
| 2555 | 2551 | PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_4WAY |
| 2556 | PORT_ | |
| 2552 | PORT_DIPNAME( | |
| 2557 | 2553 | PORT_DIPSETTING( 0x10, DEF_STR( Off ) ) |
| 2558 | 2554 | PORT_DIPSETTING( 0x00, DEF_STR( On ) ) |
| 2559 | 2555 | PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_COIN1 ) |
| r2724 | r2725 | |
| 2606 | 2602 | PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_4WAY |
| 2607 | 2603 | PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_4WAY |
| 2608 | 2604 | PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_4WAY |
| 2609 | PORT_ | |
| 2605 | PORT_DIPNAME( | |
| 2610 | 2606 | PORT_DIPSETTING( 0x10, DEF_STR( Off ) ) |
| 2611 | 2607 | PORT_DIPSETTING( 0x00, DEF_STR( On ) ) |
| 2612 | 2608 | PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_COIN1 ) |
| r2724 | r2725 | |
|---|---|---|
| 59 | 59 | * |
| 60 | 60 | *************************************/ |
| 61 | 61 | |
| 62 | static void update_irq_state( | |
| 62 | static void update_irq_state(running_machine *machine) | |
| 63 | 63 | { |
| 64 | 64 | int i; |
| 65 | 65 | |
| r2724 | r2725 | |
| 67 | 67 | for (i = 4; i >= 0; i--) |
| 68 | 68 | if (irq_state[i]) |
| 69 | 69 | { |
| 70 | cpunum_set_input_line( | |
| 70 | cpunum_set_input_line(machine, 0, i, ASSERT_LINE); | |
| 71 | 71 | return; |
| 72 | 72 | } |
| 73 | 73 | |
| 74 | 74 | /* otherwise, clear them all */ |
| 75 | cpunum_set_input_line( | |
| 75 | cpunum_set_input_line(machine, 0, 7, CLEAR_LINE); | |
| 76 | 76 | } |
| 77 | 77 | |
| 78 | 78 | |
| r2724 | r2725 | |
| 80 | 80 | { |
| 81 | 81 | /* auto-ack the IRQ */ |
| 82 | 82 | irq_state[irqline] = 0; |
| 83 | update_irq_state(); | |
| 83 | update_irq_state(machine); | |
| 84 | 84 | |
| 85 | 85 | /* vector is 0x40 + index */ |
| 86 | 86 | return 0x40 + irqline; |
| r2724 | r2725 | |
| 90 | 90 | void dcheese_signal_irq(int which) |
| 91 | 91 | { |
| 92 | 92 | irq_state[which] = 1; |
| 93 | update_irq_state(); | |
| 93 | update_irq_state(Machine); | |
| 94 | 94 | } |
| 95 | 95 | |
| 96 | 96 |
| r2724 | r2725 | |
|---|---|---|
| 318 | 318 | |
| 319 | 319 | |
| 320 | 320 | |
| 321 | static void chqflag_ym2151_irq_w(int data) | |
| 321 | static void chqflag_ym2151_irq_w(running_machine *machine, int data) | |
| 322 | 322 | { |
| 323 | cpunum_set_input_line( | |
| 323 | cpunum_set_input_line(machine, 1,INPUT_LINE_NMI,PULSE_LINE); | |
| 324 | 324 | } |
| 325 | 325 | |
| 326 | 326 |
| r2724 | r2725 | |
|---|---|---|
| 98 | 98 | |
| 99 | 99 | static WRITE8_HANDLER( bwp12_sharedram1_w ) { bwp1_sharedram1[offset] = bwp2_sharedram1[offset] = data; } |
| 100 | 100 | static WRITE8_HANDLER( bwp3_u8F_w ) { bwp3_u8F_d = data; } // prepares custom chip for various operations |
| 101 | static WRITE8_HANDLER( bwp3_nmiack_w ) { cpunum_set_input_line( | |
| 101 | static WRITE8_HANDLER( bwp3_nmiack_w ) { cpunum_set_input_line(machine, 2, INPUT_LINE_NMI, CLEAR_LINE); } | |
| 102 | 102 | static WRITE8_HANDLER( bwp3_nmimask_w ) { bwp3_nmimask = data & 0x80; } |
| 103 | 103 | |
| 104 | 104 |
| r2724 | r2725 | |
|---|---|---|
| 10 | 10 | ***************************************************************************/ |
| 11 | 11 | |
| 12 | 12 | #include "driver.h" |
| 13 | #include "deprecat.h" | |
| 14 | 13 | #include "cpu/z80/z80.h" |
| 15 | 14 | #include "cpu/m68000/m68000.h" |
| 16 | 15 | #include "sound/2151intf.h" |
| r2724 | r2725 | |
| 799 | 798 | |
| 800 | 799 | |
| 801 | 800 | |
| 802 | static void irq_handler(int irq) | |
| 801 | static void irq_handler(running_machine *machine, int irq) | |
| 803 | 802 | { |
| 804 | cpunum_set_input_line( | |
| 803 | cpunum_set_input_line(machine, 1,0,irq ? ASSERT_LINE : CLEAR_LINE); | |
| 805 | 804 | } |
| 806 | 805 | |
| 807 | 806 | static const struct YM2151interface ym2151_interface = |
| r2724 | r2725 | |
|---|---|---|
| 147 | 147 | ***************************************************************************/ |
| 148 | 148 | |
| 149 | 149 | #include "driver.h" |
| 150 | #include "deprecat.h" | |
| 151 | 150 | #include "cpu/m6805/m6805.h" |
| 152 | 151 | #include "sound/ay8910.h" |
| 153 | 152 | #include "sound/2203intf.h" |
| r2724 | r2725 | |
| 565 | 564 | |
| 566 | 565 | |
| 567 | 566 | |
| 568 | static void irqhandler(int irq) | |
| 567 | static void irqhandler(running_machine *machine, int irq) | |
| 569 | 568 | { |
| 570 | cpunum_set_input_line( | |
| 569 | cpunum_set_input_line(machine, 1,0,irq ? ASSERT_LINE : CLEAR_LINE); | |
| 571 | 570 | } |
| 572 | 571 | |
| 573 | 572 | static WRITE8_HANDLER( unk ) |
| r2724 | r2725 | |
|---|---|---|
| 69 | 69 | ***************************************************************************/ |
| 70 | 70 | |
| 71 | 71 | #include "driver.h" |
| 72 | #include "deprecat.h" | |
| 73 | 72 | #include "machine/eeprom.h" |
| 74 | 73 | #include "machine/nmk112.h" |
| 75 | 74 | #include "cpu/z80/z80.h" |
| r2724 | r2725 | |
| 129 | 128 | } |
| 130 | 129 | |
| 131 | 130 | /* Called by the YMZ280B to set the IRQ state */ |
| 132 | static void sound_irq_gen(int state) | |
| 131 | static void sound_irq_gen(running_machine *machine, int state) | |
| 133 | 132 | { |
| 134 | 133 | sound_irq = (state != 0); |
| 135 | update_irq_state( | |
| 134 | update_irq_state(machine); | |
| 136 | 135 | } |
| 137 | 136 | |
| 138 | 137 | |
| r2724 | r2725 | |
| 162 | 161 | if (offset == 4/2) vblank_irq = 0; |
| 163 | 162 | if (offset == 6/2) unknown_irq = 0; |
| 164 | 163 | |
| 165 | update_irq_state( | |
| 164 | update_irq_state(machine); | |
| 166 | 165 | |
| 167 | 166 | /* |
| 168 | 167 | sailormn and agallet wait for bit 2 of $b80001 to go 1 -> 0. |
| r2724 | r2725 | |
| 1993 | 1992 | sound_irq_gen |
| 1994 | 1993 | }; |
| 1995 | 1994 | |
| 1996 | static void irqhandler(int irq) | |
| 1995 | static void irqhandler(running_machine *machine, int irq) | |
| 1997 | 1996 | { |
| 1998 | cpunum_set_input_line( | |
| 1997 | cpunum_set_input_line(machine, 1,0,irq ? ASSERT_LINE : CLEAR_LINE); | |
| 1999 | 1998 | } |
| 2000 | 1999 | |
| 2001 | 2000 | static const struct YM2151interface ym2151_interface = |
| r2724 | r2725 | |
|---|---|---|
| 898 | 898 | GFXDECODE_ENTRY( REGION_GFX2, 0, popbingo_tilelayout, 256, 1 ) |
| 899 | 899 | GFXDECODE_END |
| 900 | 900 | |
| 901 | static void irqhandler(int irq) | |
| 901 | static void irqhandler(running_machine *machine, int irq) | |
| 902 | 902 | { |
| 903 | cpunum_set_input_line( | |
| 903 | cpunum_set_input_line(machine, 1,0,irq ? ASSERT_LINE : CLEAR_LINE); | |
| 904 | 904 | } |
| 905 | 905 | |
| 906 | 906 | static READ8_HANDLER( unk_r ) |
| r2724 | r2725 | |
|---|---|---|
| 46 | 46 | ***************************************************************************/ |
| 47 | 47 | |
| 48 | 48 | #include "driver.h" |
| 49 | #include "deprecat.h" | |
| 50 | 49 | #include "cpu/m6809/m6809.h" |
| 51 | 50 | #include "sound/2203intf.h" |
| 52 | 51 | #include "sound/3812intf.h" |
| r2724 | r2725 | |
| 92 | 91 | static INPUT_CHANGED( coin_inserted ) |
| 93 | 92 | { |
| 94 | 93 | /* coin insertion causes an IRQ */ |
| 95 | cpunum_set_input_line(machine, 0, 0, newval ? CLEAR_LINE : ASSERT_LINE); | |
| 94 | cpunum_set_input_line(field->port->machine, 0, 0, newval ? CLEAR_LINE : ASSERT_LINE); | |
| 96 | 95 | } |
| 97 | 96 | |
| 98 | 97 | |
| r2724 | r2725 | |
| 374 | 373 | GFXDECODE_END |
| 375 | 374 | |
| 376 | 375 | /* handler called by the 3812 emulator when the internal timers cause an IRQ */ |
| 377 | static void irqhandler(int linestate) | |
| 376 | static void irqhandler(running_machine *machine, int linestate) | |
| 378 | 377 | { |
| 379 | cpunum_set_input_line( | |
| 378 | cpunum_set_input_line(machine, 1,M6809_IRQ_LINE,linestate); | |
| 380 | 379 | } |
| 381 | 380 | |
| 382 | 381 | static const struct YM3526interface ym3526_interface = |
| r2724 | r2725 | |
|---|---|---|
| 158 | 158 | |
| 159 | 159 | |
| 160 | 160 | #include "driver.h" |
| 161 | #include "deprecat.h" | |
| 162 | 161 | #include "sound/262intf.h" |
| 163 | 162 | #include "sound/ymf278b.h" |
| 164 | 163 | |
| r2724 | r2725 | |
| 586 | 585 | } |
| 587 | 586 | |
| 588 | 587 | |
| 589 | static void irqhandler(int irq) | |
| 588 | static void irqhandler(running_machine *machine, int irq) | |
| 590 | 589 | { |
| 591 | cpunum_set_input_line( | |
| 590 | cpunum_set_input_line(machine, 1, 0, irq ? ASSERT_LINE : CLEAR_LINE); | |
| 592 | 591 | } |
| 593 | 592 | |
| 594 | 593 | static const struct YMF278B_interface ymf278b_interface = |
| r2724 | r2725 | |
|---|---|---|
| 38 | 38 | ***************************************************************************/ |
| 39 | 39 | |
| 40 | 40 | #include "driver.h" |
| 41 | #include "deprecat.h" | |
| 42 | 41 | #include "cpu/m6809/m6809.h" |
| 43 | 42 | #include "cpu/m6502/m6502.h" |
| 44 | 43 | #include "sound/2203intf.h" |
| r2724 | r2725 | |
| 436 | 435 | cpunum_set_input_line(machine, 2,INPUT_LINE_NMI,PULSE_LINE); |
| 437 | 436 | } |
| 438 | 437 | |
| 439 | static void csilver_adpcm_int(int data) | |
| 438 | static void csilver_adpcm_int(running_machine *machine, int data) | |
| 440 | 439 | { |
| 441 | 440 | static int toggle =0; |
| 442 | 441 | |
| 443 | 442 | toggle ^= 1; |
| 444 | 443 | if (toggle) |
| 445 | cpunum_set_input_line( | |
| 444 | cpunum_set_input_line(machine, 2,M6502_IRQ_LINE,HOLD_LINE); | |
| 446 | 445 | |
| 447 | 446 | MSM5205_data_w (0,msm5205next>>4); |
| 448 | 447 | msm5205next<<=4; |
| r2724 | r2725 | |
| 2010 | 2009 | /******************************************************************************/ |
| 2011 | 2010 | |
| 2012 | 2011 | /* handler called by the 3812 emulator when the internal timers cause an IRQ */ |
| 2013 | static void irqhandler(int linestate) | |
| 2012 | static void irqhandler(running_machine *machine, int linestate) | |
| 2014 | 2013 | { |
| 2015 | cpunum_set_input_line( | |
| 2014 | cpunum_set_input_line(machine, 1,0,linestate); /* M6502_IRQ_LINE */ | |
| 2016 | 2015 | } |
| 2017 | 2016 | |
| 2018 | static void oscar_irqhandler(int linestate) | |
| 2017 | static void oscar_irqhandler(running_machine *machine, int linestate) | |
| 2019 | 2018 | { |
| 2020 | cpunum_set_input_line( | |
| 2019 | cpunum_set_input_line(machine, 2,0,linestate); /* M6502_IRQ_LINE */ | |
| 2021 | 2020 | } |
| 2022 | 2021 | |
| 2023 | 2022 | static const struct YM3526interface ym3526_interface = |
| r2724 | r2725 | |
|---|---|---|
| 13 | 13 | ***/ |
| 14 | 14 | |
| 15 | 15 | #include "driver.h" |
| 16 | #include "deprecat.h" | |
| 17 | 16 | #include "cpu/z80/z80.h" |
| 18 | 17 | #include "sound/3812intf.h" |
| 19 | 18 | #include "sound/msm5205.h" |
| r2724 | r2725 | |
| 197 | 196 | MSM5205_set_volume(offset & 1, (data & 0x7f) * 100 / 0x7f); |
| 198 | 197 | } |
| 199 | 198 | |
| 200 | static void tbowl_adpcm_int(int num) | |
| 199 | static void tbowl_adpcm_int(running_machine *machine, int num) | |
| 201 | 200 | { |
| 202 | 201 | static int adpcm_data[2] = { -1, -1 }; |
| 203 | 202 | |
| r2724 | r2725 | |
| 556 | 555 | |
| 557 | 556 | */ |
| 558 | 557 | |
| 559 | static void irqhandler(int linestate) | |
| 558 | static void irqhandler(running_machine *machine, int linestate) | |
| 560 | 559 | { |
| 561 | cpunum_set_input_line( | |
| 560 | cpunum_set_input_line(machine, 2,0,linestate); | |
| 562 | 561 | } |
| 563 | 562 | |
| 564 | 563 | static const struct YM3526interface ym3812_interface = |
| r2724 | r2725 | |
|---|---|---|
| 10 | 10 | ***************************************************************************/ |
| 11 | 11 | |
| 12 | 12 | #include "driver.h" |
| 13 | #include "deprecat.h" | |
| 14 | 13 | #include "cpu/m6809/m6809.h" |
| 15 | 14 | #include "sound/3812intf.h" |
| 16 | 15 | |
| r2724 | r2725 | |
| 242 | 241 | GFXDECODE_END |
| 243 | 242 | |
| 244 | 243 | |
| 245 | static void irqhandler(int irq) | |
| 244 | static void irqhandler(running_machine *machine, int irq) | |
| 246 | 245 | { |
| 247 | cpunum_set_input_line( | |
| 246 | cpunum_set_input_line(machine, 0, M6809_FIRQ_LINE, irq ? ASSERT_LINE : CLEAR_LINE); | |
| 248 | 247 | } |
| 249 | 248 | |
| 250 | 249 | static const struct YM3526interface ym3526_interface = |
| r2724 | r2725 | |
|---|---|---|
| 19 | 19 | |
| 20 | 20 | |
| 21 | 21 | #include "driver.h" |
| 22 | #include "deprecat.h" | |
| 23 | 22 | #include "machine/atarigen.h" |
| 24 | 23 | #include "video/atarirle.h" |
| 25 | 24 | #include "cpu/m68000/m68000.h" |
| r2724 | r2725 | |
| 45 | 44 | static void (*protection_w)(offs_t offset, UINT16 data); |
| 46 | 45 | static void (*protection_r)(offs_t offset, UINT16 *data); |
| 47 | 46 | |
| 48 | static void cage_irq_callback(int reason); | |
| 47 | static void cage_irq_callback(running_machine *machine, int reason); | |
| 49 | 48 | |
| 50 | 49 | |
| 51 | 50 | |
| r2724 | r2725 | |
| 88 | 87 | * |
| 89 | 88 | *************************************/ |
| 90 | 89 | |
| 91 | static void cage_irq_callback(int reason) | |
| 90 | static void cage_irq_callback(running_machine *machine, int reason) | |
| 92 | 91 | { |
| 93 | 92 | if (reason) |
| 94 | atarigen_sound_int_gen( | |
| 93 | atarigen_sound_int_gen(machine, 0); | |
| 95 | 94 | else |
| 96 | atarigen_sound_int_ack_w( | |
| 95 | atarigen_sound_int_ack_w(machine,0,0,0xffff); | |
| 97 | 96 | } |
| 98 | 97 | |
| 99 | 98 |
| r2724 | r2725 | |
|---|---|---|
| 56 | 56 | */ |
| 57 | 57 | |
| 58 | 58 | #include "driver.h" |
| 59 | #include "deprecat.h" | |
| 60 | 59 | #include "sound/okim6295.h" |
| 61 | 60 | #include "machine/eeprom.h" |
| 62 | 61 | |
| r2724 | r2725 | |
| 67 | 66 | |
| 68 | 67 | static READ16_HANDLER( gms_read ) |
| 69 | 68 | { |
| 70 | return mame_rand( | |
| 69 | return mame_rand(machine); | |
| 71 | 70 | } |
| 72 | 71 | |
| 73 | 72 |
| r2724 | r2725 | |
|---|---|---|
| 312 | 312 | if(read_latch) |
| 313 | 313 | { |
| 314 | 314 | read_latch=0; |
| 315 | return mame_rand( | |
| 315 | return mame_rand(machine); | |
| 316 | 316 | } |
| 317 | 317 | break; |
| 318 | 318 |
| r2724 | r2725 | |
|---|---|---|
| 12 | 12 | */ |
| 13 | 13 | |
| 14 | 14 | #include "driver.h" |
| 15 | #include "deprecat.h" | |
| 16 | 15 | #include "genesis.h" |
| 17 | 16 | |
| 18 | 17 | #define MASTER_CLOCK 53693100 |
| r2724 | r2725 | |
| 140 | 139 | |
| 141 | 140 | |
| 142 | 141 | /* interrupt callback to generate the YM3438 interrupt */ |
| 143 | void genesis_irq2_interrupt(int state) | |
| 142 | void genesis_irq2_interrupt(running_machine *machine, int state) | |
| 144 | 143 | { |
| 145 | 144 | irq2_int = state; |
| 146 | update_interrupts( | |
| 145 | update_interrupts(machine); | |
| 147 | 146 | } |
| 148 | 147 | |
| 149 | 148 |
| r2724 | r2725 | |
|---|---|---|
| 154 | 154 | |
| 155 | 155 | static CUSTOM_INPUT( get_vblank ) |
| 156 | 156 | { |
| 157 | int scanline = video_screen_get_vpos(machine->primary_screen); | |
| 157 | int scanline = video_screen_get_vpos(field->port->machine->primary_screen); | |
| 158 | 158 | return (~syncprom[scanline & 0xff] >> 1) & 1; |
| 159 | 159 | } |
| 160 | 160 |
| r2724 | r2725 | |
|---|---|---|
| 105 | 105 | |
| 106 | 106 | |
| 107 | 107 | #include "driver.h" |
| 108 | #include "deprecat.h" | |
| 109 | 108 | #include "cpu/m6809/m6809.h" |
| 110 | 109 | #include "sound/2151intf.h" |
| 111 | 110 | #include "sound/upd7759.h" |
| r2724 | r2725 | |
| 143 | 142 | * |
| 144 | 143 | *************************************/ |
| 145 | 144 | |
| 146 | static void ym2151_irq_gen(int state) | |
| 145 | static void ym2151_irq_gen(running_machine *machine, int state) | |
| 147 | 146 | { |
| 148 | 147 | ym2151_irq = state; |
| 149 | cpunum_set_input_line( | |
| 148 | cpunum_set_input_line(machine, 1, 0, (ym2151_irq | sound_busy) ? ASSERT_LINE : CLEAR_LINE); | |
| 150 | 149 | } |
| 151 | 150 | |
| 152 | 151 |
| r2724 | r2725 | |
|---|---|---|
| 498 | 498 | |
| 499 | 499 | static READ32_HANDLER( randomrabbits ) |
| 500 | 500 | { |
| 501 | return mame_rand( | |
| 501 | return mame_rand(machine); | |
| 502 | 502 | } |
| 503 | 503 | |
| 504 | 504 | static ADDRESS_MAP_START( rabbit_readmem, ADDRESS_SPACE_PROGRAM, 32 ) |
| r2724 | r2725 | |
|---|---|---|
| 213 | 213 | ***************************************************************************/ |
| 214 | 214 | |
| 215 | 215 | #include "driver.h" |
| 216 | #include "deprecat.h" | |
| 217 | 216 | #include "taitoipt.h" |
| 218 | 217 | #include "video/taitoic.h" |
| 219 | 218 | #include "audio/taitosnd.h" |
| r2724 | r2725 | |
| 268 | 267 | |
| 269 | 268 | static int adpcm_pos; |
| 270 | 269 | |
| 271 | static void asuka_msm5205_vck(int chip) | |
| 270 | static void asuka_msm5205_vck(running_machine *machine, int chip) | |
| 272 | 271 | { |
| 273 | 272 | static int adpcm_data = -1; |
| 274 | 273 | |
| r2724 | r2725 | |
| 754 | 753 | SOUND |
| 755 | 754 | **************************************************************/ |
| 756 | 755 | |
| 757 | static void irq_handler(int irq) | |
| 756 | static void irq_handler(running_machine *machine, int irq) | |
| 758 | 757 | { |
| 759 | cpunum_set_input_line( | |
| 758 | cpunum_set_input_line(machine, 1,0,irq ? ASSERT_LINE : CLEAR_LINE); | |
| 760 | 759 | } |
| 761 | 760 | |
| 762 | 761 | static const struct YM2610interface ym2610_interface = |
| r2724 | r2725 | |
|---|---|---|
| 197 | 197 | PORT_START /* 0C48 */ |
| 198 | 198 | // default to service enabled to make users calibrate gun |
| 199 | 199 | // PORT_SERVICE( 0x40, IP_ACTIVE_LOW ) |
| 200 | PORT_ | |
| 200 | PORT_DIPNAME( | |
| 201 | 201 | PORT_DIPSETTING( 0x40, DEF_STR( Off ) ) |
| 202 | 202 | PORT_DIPSETTING( 0x00, DEF_STR( On ) ) |
| 203 | 203 | PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_BUTTON1 ) |
| r2724 | r2725 | |
|---|---|---|
| 14 | 14 | extern void decrypt156(void); |
| 15 | 15 | |
| 16 | 16 | #include "driver.h" |
| 17 | #include "deprecat.h" | |
| 18 | 17 | #include "decocrpt.h" |
| 19 | 18 | #include "deco32.h" |
| 20 | 19 | #include "machine/eeprom.h" |
| r2724 | r2725 | |
| 230 | 229 | static READ32_HANDLER(backfire_eeprom_r) |
| 231 | 230 | { |
| 232 | 231 | /* some kind of screen indicator? checked by backfira set before it will boot */ |
| 233 | int backfire_screen = mame_rand( | |
| 232 | int backfire_screen = mame_rand(machine)&1; | |
| 234 | 233 | return ((EEPROM_read_bit()<<24) | input_port_read_indexed(machine, 0) | (input_port_read_indexed(machine, 3)<<16)) ^ (backfire_screen << 26) ; |
| 235 | 234 | } |
| 236 | 235 | |
| r2724 | r2725 | |
| 311 | 310 | |
| 312 | 311 | READ32_HANDLER( backfire_wheel1_r ) |
| 313 | 312 | { |
| 314 | return mame_rand( | |
| 313 | return mame_rand(machine); | |
| 315 | 314 | } |
| 316 | 315 | |
| 317 | 316 | READ32_HANDLER( backfire_wheel2_r ) |
| 318 | 317 | { |
| 319 | return mame_rand( | |
| 318 | return mame_rand(machine); | |
| 320 | 319 | } |
| 321 | 320 | #endif |
| 322 | 321 | |
| r2724 | r2725 | |
| 465 | 464 | GFXDECODE_END |
| 466 | 465 | |
| 467 | 466 | |
| 468 | static void sound_irq_gen(int state) | |
| 467 | static void sound_irq_gen(running_machine *machine, int state) | |
| 469 | 468 | { |
| 470 | 469 | logerror("sound irq\n"); |
| 471 | 470 | } |
| r2724 | r2725 | |
|---|---|---|
| 14 | 14 | ***************************************************************************/ |
| 15 | 15 | |
| 16 | 16 | #include "driver.h" |
| 17 | #include "deprecat.h" | |
| 18 | 17 | #include "cpu/m6809/m6809.h" |
| 19 | 18 | #include "cpu/m6502/m6502.h" |
| 20 | 19 | #include "sound/2203intf.h" |
| r2724 | r2725 | |
| 278 | 277 | |
| 279 | 278 | |
| 280 | 279 | /* handler called by the 3526 emulator when the internal timers cause an IRQ */ |
| 281 | static void irqhandler(int linestate) | |
| 280 | static void irqhandler(running_machine *machine, int linestate) | |
| 282 | 281 | { |
| 283 | cpunum_set_input_line( | |
| 282 | cpunum_set_input_line(machine, 1,0,linestate); | |
| 284 | 283 | } |
| 285 | 284 | |
| 286 | 285 | static const struct YM3526interface ym3526_interface = |
| r2724 | r2725 | |
|---|---|---|
| 38 | 38 | static INPUT_CHANGED( coin_inserted ) |
| 39 | 39 | { |
| 40 | 40 | /* coin insertion causes an NMI */ |
| 41 | cpunum_set_input_line(machine, 0, INPUT_LINE_NMI, newval ? CLEAR_LINE : ASSERT_LINE); | |
| 41 | cpunum_set_input_line(field->port->machine, 0, INPUT_LINE_NMI, newval ? CLEAR_LINE : ASSERT_LINE); | |
| 42 | 42 | } |
| 43 | 43 | |
| 44 | 44 |
| r2724 | r2725 | |
|---|---|---|
| 80 | 80 | * 2xMS6264A-20NC (8KB SRAM) @ C8 & C9 (palette RAM (xxxxBBBBRRRRGGGG)) |
| 81 | 81 | * 2x74HCT273 (octal D-Type flip-flop with clear) @ B8 & B9 (connected to RGB output) |
| 82 | 82 | |
| 83 | Controls related: (added by Mirko Mattioli) | |
| 84 | ================= | |
| 85 | When optical wheel is selected (via dipswitch), then gear shift (low/high) is enabled. | |
| 86 | On the real PCB the optical wheel encoder is connected to 74LS169 ICs (@A16 and @A17) | |
| 87 | via a flip-flop IC mounted in the steering wheel assembly. As a result, the output | |
| 88 | of the flip-flop generates a signal that contains the information about the steering | |
| 89 | direction; this signal is routed to pin #1 (U/D) at ICs A16 and A17 (high when turn | |
| 90 | left and low when turn right). The second signal of the optical encoder goes directly | |
| 91 | to pin #2 (CLK) at ICs A16 and A17 and it is a clock for the 74LS169 ICs; this clock | |
| 92 | frequency is proportional to the movements of the steering wheel: fast movements | |
| 93 | produces a high clock frequency, slow movements a low freq. | |
| 94 | ||
| 83 | 95 | ***************************************************************************/ |
| 84 | 96 | |
| 85 | 97 | #include "driver.h" |
| r2724 | r2725 | |
| 91 | 103 | extern UINT16 *wrally_vregs; |
| 92 | 104 | extern UINT16 *wrally_videoram; |
| 93 | 105 | extern UINT16 *wrally_spriteram; |
| 106 | static UINT16 *wrally_shareram; | |
| 94 | 107 | |
| 95 | 108 | VIDEO_START( wrally ); |
| 96 | 109 | VIDEO_UPDATE( wrally ); |
| r2724 | r2725 | |
| 123 | 136 | AM_RANGE(0x70004a, 0x70004b) AM_WRITE(SMH_NOP) /* Sound muting */ |
| 124 | 137 | AM_RANGE(0x70005a, 0x70005b) AM_WRITE(wrally_flipscreen_w) /* Flip screen */ |
| 125 | 138 | AM_RANGE(0x70006a, 0x70007b) AM_WRITE(SMH_NOP) /* ??? */ |
| 126 | AM_RANGE(0xfec000, 0xfeffff) AM_RAM AM_ | |
| 139 | AM_RANGE(0xfec000, 0xfeffff) AM_RAM AM_B | |
| 127 | 140 | ADDRESS_MAP_END |
| 128 | 141 | |
| 142 | static READ8_HANDLER( dallas_share_r ) | |
| 143 | { | |
| 144 | UINT8 *shareram = (UINT8 *)wrally_shareram; | |
| 145 | ||
| 146 | return shareram[BYTE_XOR_LE(offset)]; | |
| 147 | } | |
| 148 | ||
| 149 | static WRITE8_HANDLER( dallas_share_w ) | |
| 150 | { | |
| 151 | UINT8 *shareram = (UINT8 *)wrally_shareram; | |
| 152 | ||
| 153 | shareram[BYTE_XOR_LE(offset)] = data; | |
| 154 | } | |
| 155 | ||
| 129 | 156 | static ADDRESS_MAP_START( dallas_rom, ADDRESS_SPACE_PROGRAM, 8 ) |
| 130 | 157 | AM_RANGE(0x0000, 0x7fff) AM_ROM /* Code in NVRAM */ |
| 131 | 158 | ADDRESS_MAP_END |
| 132 | 159 | |
| 133 | 160 | static ADDRESS_MAP_START( dallas_ram, ADDRESS_SPACE_DATA, 8 ) |
| 134 | AM_RANGE(0x0000, 0xffff) AM_RA | |
| 161 | AM_RANGE(0x0000, 0xffff) AM_READW | |
| 135 | 162 | ADDRESS_MAP_END |
| 136 | 163 | |
| 137 | 164 | /* DS5002FP configuration */ |
| r2724 | r2725 | |
| 193 | 220 | PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_8WAY PORT_PLAYER(1) |
| 194 | 221 | PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_8WAY PORT_PLAYER(1) |
| 195 | 222 | PORT_BIT( 0x0008, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_8WAY PORT_PLAYER(1) |
| 196 | PORT_BIT( 0x0010, IP_ACTIVE_ | |
| 223 | PORT_BIT( 0x0010, IP_ACTIVE_HIGH, IPT_BUTTON2 ) PORT_PLAYER(1) PORT_NAME("Gear Shift") PORT_TOGGLE PORT_REVERSE | |
| 197 | 224 | PORT_BIT( 0x0020, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(1) |
| 198 | 225 | PORT_BIT( 0x0040, IP_ACTIVE_LOW, IPT_COIN1 ) |
| 199 | 226 | PORT_BIT( 0x0080, IP_ACTIVE_LOW, IPT_COIN2 ) |
| r2724 | r2725 | |
| 206 | 233 | PORT_BIT( 0x4000, IP_ACTIVE_LOW, IPT_START1 ) |
| 207 | 234 | PORT_BIT( 0x8000, IP_ACTIVE_LOW, IPT_START2 ) |
| 208 | 235 | |
| 209 | PORT_START /* Wheel control? */ | |
| 210 | PORT_BIT( 0xffff, IP_ACTIVE_LOW, IPT_UNKNOWN ) /* not implemented */ | |
| 236 | PORT_START /* Wheel control */ | |
| 237 | PORT_BIT( 0xff00, 0x0000, IPT_DIAL ) PORT_SENSITIVITY(70) PORT_KEYDELTA(10) PORT_CODE_DEC(KEYCODE_RIGHT) PORT_CODE_INC(KEYCODE_LEFT) PORT_REVERSE | |
| 238 | PORT_BIT( 0x00ff, IP_ACTIVE_LOW, IPT_UNKNOWN ) | |
| 211 | 239 | |
| 212 | 240 | PORT_START /* INPUTS, TEST & SERVICE */ |
| 213 | 241 | PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_SERVICE1 ) |
| r2724 | r2725 | |
|---|---|---|
| 27 | 27 | */ |
| 28 | 28 | |
| 29 | 29 | #include "driver.h" |
| 30 | #include "deprecat.h" | |
| 31 | 30 | #include "sound/okim6295.h" |
| 32 | 31 | #include "sound/3812intf.h" |
| 33 | 32 | |
| r2724 | r2725 | |
| 391 | 390 | GFXDECODE_END |
| 392 | 391 | |
| 393 | 392 | |
| 394 | static void irqhandler(int linestate) | |
| 393 | static void irqhandler(running_machine *machine, int linestate) | |
| 395 | 394 | { |
| 396 | cpunum_set_input_line( | |
| 395 | cpunum_set_input_line(machine, 1,0,linestate); | |
| 397 | 396 | } |
| 398 | 397 | |
| 399 | 398 | static const struct YM3812interface ym3812_interface = |
| r2724 | r2725 | |
|---|---|---|
| 3684 | 3684 | NMK004_irq |
| 3685 | 3685 | }; |
| 3686 | 3686 | |
| 3687 | static void ym2203_irqhandler(int irq) | |
| 3687 | static void ym2203_irqhandler(running_machine *machine, int irq) | |
| 3688 | 3688 | { |
| 3689 | cpunum_set_input_line( | |
| 3689 | cpunum_set_input_line(machine, 1,0,irq ? ASSERT_LINE : CLEAR_LINE); | |
| 3690 | 3690 | } |
| 3691 | 3691 | |
| 3692 | 3692 | static const struct YM2203interface ym2203_interface = |
| r2724 | r2725 | |
| 5024 | 5024 | |
| 5025 | 5025 | ***************************************************************************/ |
| 5026 | 5026 | |
| 5027 | static void irq_handler(int irq) | |
| 5027 | static void irq_handler(running_machine *machine, int irq) | |
| 5028 | 5028 | { |
| 5029 | cpunum_set_input_line( | |
| 5029 | cpunum_set_input_line(machine, 1,0,irq ? ASSERT_LINE : CLEAR_LINE); | |
| 5030 | 5030 | } |
| 5031 | 5031 | |
| 5032 | 5032 | static const struct YM2151interface afega_ym2151_intf = |
| r2724 | r2725 | |
|---|---|---|
| 429 | 429 | static INPUT_CHANGED( coin_inserted ) |
| 430 | 430 | { |
| 431 | 431 | /* coin insertion causes an NMI */ |
| 432 | cpunum_set_input_line(machine, 0, INPUT_LINE_NMI, newval ? ASSERT_LINE : CLEAR_LINE); | |
| 432 | cpunum_set_input_line(field->port->machine, 0, INPUT_LINE_NMI, newval ? ASSERT_LINE : CLEAR_LINE); | |
| 433 | 433 | } |
| 434 | 434 | |
| 435 | 435 |
| r2724 | r2725 | |
|---|---|---|
| 40 | 40 | |
| 41 | 41 | #include "mamecore.h" |
| 42 | 42 | #include "osdcore.h" |
| 43 | #include "inptport.h" | |
| 43 | 44 | #include "timer.h" |
| 44 | 45 | |
| 45 | 46 | |
| r2724 | r2725 | |
| 145 | 146 | This function is called on startup, before reading the configuration from disk. |
| 146 | 147 | Scan the list, and change the keys/joysticks you want. |
| 147 | 148 | */ |
| 148 | void osd_customize_input | |
| 149 | void osd_customize_input_ | |
| 149 | 150 | |
| 150 | 151 | |
| 151 | 152 |
| r2724 | r2725 | |
|---|---|---|
| 699 | 699 | |
| 700 | 700 | |
| 701 | 701 | //============================================================ |
| 702 | // osd_customize_ | |
| 702 | // osd_customize_map | |
| 703 | 703 | //============================================================ |
| 704 | 704 | |
| 705 | void osd_customize_input | |
| 705 | void osd_customize_input_ | |
| 706 | 706 | { |
| 707 | input_ | |
| 707 | input_ | |
| 708 | 708 | |
| 709 | // loop over all the defaults | |
| 710 | for (idef = defaults; idef->type != IPT_END; idef++) | |
| 711 | switch (idef->type) | |
| 709 | // loop over the defaults | |
| 710 | for (typedesc = typelist; typedesc != NULL; typedesc = typedesc->next) | |
| 711 | switch (typedesc->type) | |
| 712 | 712 | { |
| 713 | 713 | // disable the config menu if the ALT key is down |
| 714 | 714 | // (allows ALT-TAB to switch between windows apps) |
| 715 | 715 | case IPT_UI_CONFIGURE: |
| 716 | input_seq_set_5(& | |
| 716 | input_seq_set_5(&typedesc-> | |
| 717 | 717 | break; |
| 718 | 718 | |
| 719 | 719 | // alt-enter for fullscreen |
| 720 | 720 | case IPT_OSD_1: |
| 721 | idef->token = "TOGGLE_FULLSCREEN"; | |
| 722 | idef->name = "Toggle Fullscreen"; | |
| 723 | input_seq_set_2(&idef->defaultseq, KEYCODE_LALT, KEYCODE_ENTER); | |
| 721 | typedesc->token = "TOGGLE_FULLSCREEN"; | |
| 722 | typedesc->name = "Toggle Fullscreen"; | |
| 723 | input_seq_set_2(&typedesc->seq[SEQ_TYPE_STANDARD], KEYCODE_LALT, KEYCODE_ENTER); | |
| 724 | 724 | break; |
| 725 | 725 | |
| 726 | 726 | #ifdef MESS |
| 727 | 727 | case IPT_OSD_2: |
| 728 | 728 | if (mess_use_new_ui()) |
| 729 | 729 | { |
| 730 | idef->token = "TOGGLE_MENUBAR"; | |
| 731 | idef->name = "Toggle Menubar"; | |
| 732 | input_seq_set_1 (&idef->defaultseq, KEYCODE_SCRLOCK); | |
| 730 | typedesc->token = "TOGGLE_MENUBAR"; | |
| 731 | typedesc->name = "Toggle Menubar"; | |
| 732 | input_seq_set_1 (&typedesc->seq[SEQ_TYPE_STANDARD], KEYCODE_SCRLOCK); | |
| 733 | 733 | } |
| 734 | 734 | break; |
| 735 | 735 | |
| 736 | 736 | case IPT_UI_THROTTLE: |
| 737 | input_seq_set_0(& | |
| 737 | input_seq_set_0(&typedesc-> | |
| 738 | 738 | break; |
| 739 | 739 | #endif /* MESS */ |
| 740 | 740 | } |
| r2724 | r2725 | |
|---|---|---|
| 427 | 427 | { |
| 428 | 428 | // see if the interrupt key is pressed and break if it is |
| 429 | 429 | temporarily_fake_that_we_are_not_visible = TRUE; |
| 430 | if (input_ui_pressed(IPT_UI_DEBUG_BREAK)) | |
| 430 | if (input_ui_pressed(Machine, IPT_UI_DEBUG_BREAK)) | |
| 431 | 431 | { |
| 432 | 432 | debugwin_info *info; |
| 433 | 433 | HWND focuswnd = GetFocus(); |
| r2724 | r2725 | |
| 2891 | 2891 | int ignoreme; |
| 2892 | 2892 | |
| 2893 | 2893 | /* ignore any keys that are received while the debug key is down */ |
| 2894 | ignoreme = input_ui_pressed(IPT_UI_DEBUG_BREAK); | |
| 2894 | ignoreme = input_ui_pressed(Machine, IPT_UI_DEBUG_BREAK); | |
| 2895 | 2895 | if (ignoreme) |
| 2896 | 2896 | return 1; |
| 2897 | 2897 |
| r2724 | r2725 | |
|---|---|---|
| 71 | 71 | static BOOL CALLBACK monitor_enum_callback(HMONITOR handle, HDC dc, LPRECT rect, LPARAM data); |
| 72 | 72 | static win_monitor_info *pick_monitor(int index); |
| 73 | 73 | |
| 74 | static void check_osd_inputs( | |
| 74 | static void check_osd_inputs(running_machine *machine); | |
| 75 | 75 | |
| 76 | 76 | static void extract_video_config(running_machine *machine); |
| 77 | 77 | static void load_effect_overlay(running_machine *machine, const char *filename); |
| r2724 | r2725 | |
| 211 | 211 | // poll the joystick values here |
| 212 | 212 | winwindow_process_events(machine, TRUE); |
| 213 | 213 | wininput_poll(machine); |
| 214 | check_osd_inputs(); | |
| 214 | check_osd_inputs(machine); | |
| 215 | 215 | } |
| 216 | 216 | |
| 217 | 217 | |
| r2724 | r2725 | |
| 352 | 352 | // check_osd_inputs |
| 353 | 353 | //============================================================ |
| 354 | 354 | |
| 355 | static void check_osd_inputs( | |
| 355 | static void check_osd_inputs(running_machine *machine) | |
| 356 | 356 | { |
| 357 | 357 | // check for toggling fullscreen mode |
| 358 | if (input_ui_pressed(IPT_OSD_1)) | |
| 358 | if (input_ui_pressed(machine, IPT_OSD_1)) | |
| 359 | 359 | winwindow_toggle_full_screen(); |
| 360 | 360 | |
| 361 | 361 | #ifdef MESS |
| 362 | 362 | // check for toggling menu bar |
| 363 | if (input_ui_pressed(IPT_OSD_2)) | |
| 363 | if (input_ui_pressed(machine, IPT_OSD_2)) | |
| 364 | 364 | win_toggle_menubar(); |
| 365 | 365 | #endif |
| 366 | 366 | } |
| r2724 | r2725 | |
|---|---|---|
| 765 | 765 | |
| 766 | 766 | // set the max texture size |
| 767 | 767 | render_target_set_max_texture_size(window->target, d3d->texture_max_width, d3d->texture_max_height); |
| 768 | mame_printf_verbose("Direct3D: Max texture size = %dx%d\n", (int)d3d->texture_max_width, (int)d3d->texture_max_height); | |
| 768 | 769 | |
| 769 | 770 | // set the gamma if we need to |
| 770 | 771 | if (window->fullscreen) |
| r2724 | r2725 | |
|---|---|---|
| 356 | 356 | struct DriversInfo *gameinfo = &drivers_info[ndriver]; |
| 357 | 357 | const rom_entry *region, *rom; |
| 358 | 358 | machine_config *config; |
| 359 | const input_port_entry *input_ports; | |
| 360 | 359 | int num_speakers; |
| 361 | 360 | |
| 362 | 361 | /* Allocate machine config */ |
| r2724 | r2725 | |
| 431 | 430 | gameinfo->usesLightGun = FALSE; |
| 432 | 431 | if (gamedrv->ipt != NULL) |
| 433 | 432 | { |
| 434 | begin_resource_tracking(); | |
| 435 | input_ports = input_port_allocate(gamedrv->ipt, NULL); | |
| 436 | while (1) | |
| 437 | { | |
| 438 | UINT32 type; | |
| 439 | type = input_ports->type; | |
| 440 | if (type == IPT_END) | |
| 441 | break; | |
| 442 | if (type == IPT_DIAL || type == IPT_PADDLE || | |
| 443 | type == IPT_TRACKBALL_X || type == IPT_TRACKBALL_Y || | |
| 444 | type == IPT_AD_STICK_X || type == IPT_AD_STICK_Y) | |
| 445 | gameinfo->usesTrackball = TRUE; | |
| 446 | if (type == IPT_LIGHTGUN_X || type == IPT_LIGHTGUN_Y) | |
| 447 | gameinfo->usesLightGun = TRUE; | |
| 448 | input_ports++; | |
| 449 | } | |
| 450 | end_resource_tracking(); | |
| 451 | 433 | } |
| 452 | 434 | } |
| 453 | 435 | } |
| r2724 | r2725 | |
|---|---|---|
| 86 | 86 | * |
| 87 | 87 | *************************************/ |
| 88 | 88 | |
| 89 | void config_register(const char *nodename, config_callback_func load, config_callback_func save) | |
| 89 | void config_register(running_machine *machine, const char *nodename, config_callback_func load, config_callback_func save) | |
| 90 | 90 | { |
| 91 | 91 | config_type *newtype; |
| 92 | 92 | config_type **ptype; |
| r2724 | r2725 | |
| 122 | 122 | |
| 123 | 123 | /* loop over all registrants and call their init function */ |
| 124 | 124 | for (type = typelist; type; type = type->next) |
| 125 | (*type->load)(CONFIG_TYPE_INIT, NULL); | |
| 125 | (*type->load)(machine, CONFIG_TYPE_INIT, NULL); | |
| 126 | 126 | |
| 127 | 127 | /* now load the controller file */ |
| 128 | 128 | if (controller[0] != 0) |
| r2724 | r2725 | |
| 162 | 162 | |
| 163 | 163 | /* loop over all registrants and call their final function */ |
| 164 | 164 | for (type = typelist; type; type = type->next) |
| 165 | (*type->load)(CONFIG_TYPE_FINAL, NULL); | |
| 165 | (*type->load)(machine, CONFIG_TYPE_FINAL, NULL); | |
| 166 | 166 | |
| 167 | 167 | /* if we didn't find a saved config, return 0 so the main core knows that it */ |
| 168 | 168 | /* is the first time the game is run and it should diplay the disclaimer. */ |
| r2724 | r2725 | |
| 179 | 179 | |
| 180 | 180 | /* loop over all registrants and call their init function */ |
| 181 | 181 | for (type = typelist; type; type = type->next) |
| 182 | (*type->save)(CONFIG_TYPE_INIT, NULL); | |
| 182 | (*type->save)(machine, CONFIG_TYPE_INIT, NULL); | |
| 183 | 183 | |
| 184 | 184 | /* save the defaults file */ |
| 185 | 185 | filerr = mame_fopen(SEARCHPATH_CONFIG, "default.cfg", OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS, &file); |
| r2724 | r2725 | |
| 202 | 202 | |
| 203 | 203 | /* loop over all registrants and call their final function */ |
| 204 | 204 | for (type = typelist; type; type = type->next) |
| 205 | (*type->save)(CONFIG_TYPE_FINAL, NULL); | |
| 205 | (*type->save)(machine, CONFIG_TYPE_FINAL, NULL); | |
| 206 | 206 | } |
| 207 | 207 | |
| 208 | 208 | |
| r2724 | r2725 | |
| 288 | 288 | |
| 289 | 289 | /* loop over all registrants and call their load function */ |
| 290 | 290 | for (type = typelist; type; type = type->next) |
| 291 | (*type->load)(which_type, xml_get_sibling(systemnode->child, type->name)); | |
| 291 | (*type->load)(machine, which_type, xml_get_sibling(systemnode->child, type->name)); | |
| 292 | 292 | count++; |
| 293 | 293 | } |
| 294 | 294 | |
| r2724 | r2725 | |
| 343 | 343 | xml_data_node *curnode = xml_add_child(systemnode, type->name, NULL); |
| 344 | 344 | if (!curnode) |
| 345 | 345 | goto error; |
| 346 | (*type->save)(which_type, curnode); | |
| 346 | (*type->save)(machine, which_type, curnode); | |
| 347 | 347 | |
| 348 | 348 | /* if nothing was added, just nuke the node */ |
| 349 | 349 | if (!curnode->value && !curnode->child) |
| r2724 | r2725 | |
|---|---|---|
| 828 | 828 | if (execution_state != EXECUTION_STATE_STOPPED && ++key_check_counter > 10000) |
| 829 | 829 | { |
| 830 | 830 | key_check_counter = 0; |
| 831 | if (input_ui_pressed(IPT_UI_DEBUG_BREAK)) | |
| 831 | if (input_ui_pressed(Machine, IPT_UI_DEBUG_BREAK)) | |
| 832 | 832 | { |
| 833 | 833 | execution_state = EXECUTION_STATE_STOPPED; |
| 834 | 834 | debug_console_printf("User-initiated break\n"); |
| r2724 | r2725 | |
|---|---|---|
| 1137 | 1137 | DBGOBJS += $(CPUOBJ)/powerpc/ppc_dasm.o |
| 1138 | 1138 | |
| 1139 | 1139 | ifdef X86_PPC_DRC |
| 1140 | CPUOBJS += $(CPUOBJ)/powerpc/ppcdrc.o $(DRCOBJ) | |
| 1140 | CPUOBJS += $(CPUOBJ)/powerpc/ppcdrco.o $(DRCOBJ) | |
| 1141 | 1141 | else |
| 1142 | 1142 | CPUOBJS += $(CPUOBJ)/powerpc/ppc.o |
| 1143 | 1143 | endif |
| r2724 | r2725 | |
| 1151 | 1151 | $(CPUSRC)/powerpc/ppc602.c \ |
| 1152 | 1152 | $(CPUSRC)/powerpc/ppc603.c |
| 1153 | 1153 | |
| 1154 | $(CPUOBJ)/powerpc/ppcdrc.o: | |
| 1154 | $(CPUOBJ)/powerpc/ppcdrco.o: | |
| 1155 | 1155 | $(CPUSRC)/powerpc/ppc.h \ |
| 1156 | 1156 | $(CPUSRC)/powerpc/drc_ops.c \ |
| 1157 | 1157 | $(CPUSRC)/powerpc/drc_ops.h \ |
| r2724 | r2725 | |
| 1328 | 1328 | $(CPUOBJ)/saturn/saturn.o: $(CPUSRC)/saturn/saturn.c \ |
| 1329 | 1329 | $(CPUSRC)/saturn/sattable.c \ |
| 1330 | 1330 | $(CPUSRC)/saturn/satops.c \ |
| 1331 | $(CPUSRC)/saturn/saturn.h \ | |
| 1332 | $(CPUSRC)/saturn/sat.h | |
| 1331 | $(CPUSRC)/saturn/saturn.h | |
| 1333 | 1332 | |
| 1334 | 1333 | |
| 1335 | 1334 |
| r2724 | r2725 | |
|---|---|---|
| 217 | 217 | /* allocate a new description and describe this instruction */ |
| 218 | 218 | drcfe->desc_array[curpc - minpc] = curdesc = describe_one(drcfe, curpc); |
| 219 | 219 | |
| 220 | /* first instruction in a sequence is always a branch target */ | |
| 221 | if (curpc == curstack->targetpc) | |
| 222 | curdesc->flags |= OPFLAG_IS_BRANCH_TARGET; | |
| 223 | ||
| 220 | 224 | /* stop if we hit a page fault */ |
| 221 | 225 | if (curdesc->flags & OPFLAG_COMPILER_PAGE_FAULT) |
| 222 | 226 | break; |
| r2724 | r2725 | |
| 225 | 229 | if (curpc == startpc && drcfe->pageshift != 0) |
| 226 | 230 | curdesc->flags |= OPFLAG_VALIDATE_TLB | OPFLAG_CAN_CAUSE_EXCEPTION; |
| 227 | 231 | |
| 228 | /* first instruction in a sequence is always a branch target */ | |
| 229 | if (curpc == curstack->targetpc) | |
| 230 | curdesc->flags |= OPFLAG_IS_BRANCH_TARGET; | |
| 231 | ||
| 232 | 232 | /* if we are a branch within the block range, add the branch target to our stack */ |
| 233 | 233 | if ((curdesc->flags & OPFLAG_IS_BRANCH) && curdesc->targetpc >= minpc && curdesc->targetpc < maxpc && pcstackptr < &pcstack[MAX_STACK_DEPTH]) |
| 234 | 234 | { |
| r2724 | r2725 | |
| 278 | 278 | { |
| 279 | 279 | /* uh-oh: a page fault; leave the description empty and just if this is the first instruction, leave it empty and */ |
| 280 | 280 | /* mark as needing to validate; otherwise, just end the sequence here */ |
| 281 | desc->flags |= OPFLAG_VALIDATE_TLB | OPFLAG_CAN_CAUSE_EXCEPTION | OPFLAG_COMPILER_PAGE_FAULT | OPFLAG_VIRTUAL_NOOP; | |
| 281 | desc->flags |= OPFLAG_VALIDATE_TLB | OPFLAG_CAN_CAUSE_EXCEPTION | OPFLAG_COMPILER_PAGE_FAULT | OPFLAG_VIRTUAL_NOOP | OPFLAG_END_SEQUENCE; | |
| 282 | 282 | return desc; |
| 283 | 283 | } |
| 284 | 284 | |
| r2724 | r2725 | |
| 289 | 289 | if (desc->opptr.v == NULL) |
| 290 | 290 | { |
| 291 | 291 | /* address is unmapped; report it as such */ |
| 292 | desc->flags |= OPFLAG_VALIDATE_TLB | OPFLAG_CAN_CAUSE_EXCEPTION | OPFLAG_COMPILER_UNMAPPED | OPFLAG_VIRTUAL_NOOP; | |
| 292 | desc->flags |= OPFLAG_VALIDATE_TLB | OPFLAG_CAN_CAUSE_EXCEPTION | OPFLAG_COMPILER_UNMAPPED | OPFLAG_VIRTUAL_NOOP | OPFLAG_END_SEQUENCE; | |
| 293 | 293 | return desc; |
| 294 | 294 | } |
| 295 | 295 | |
| r2724 | r2725 | |
| 373 | 373 | } |
| 374 | 374 | |
| 375 | 375 | /* start a new sequence if we aren't already in the middle of one */ |
| 376 | if (seqstart == -1) | |
| 376 | if (seqstart == -1 && skipsleft == 0) | |
| 377 | { | |
| 378 | /* tag all start-of-sequence instructions as needing TLB verification */ | |
| 379 | curdesc->flags |= OPFLAG_VALIDATE_TLB | OPFLAG_CAN_CAUSE_EXCEPTION; | |
| 377 | 380 | seqstart = descnum; |
| 381 | } | |
| 378 | 382 | |
| 379 | 383 | /* if we are the last instruction, indicate end-of-sequence and redispatch */ |
| 380 | 384 | if (nextdesc == NULL) |
| r2724 | r2725 | |
| 418 | 422 | /* loop until all the registers have been accounted for */ |
| 419 | 423 | gprread = gprwrite = 0; |
| 420 | 424 | fprread = fprwrite = 0; |
| 421 | for (backdesc = descnum; backdesc != seqstart - 1; backdesc--) | |
| 422 | if (drcfe->desc_array[backdesc] != NULL) | |
| 423 | accumulate_live_info_backwards(drcfe->desc_array[backdesc], &gprread, &gprwrite, &fprread, &fprwrite); | |
| 425 | if (seqstart != -1) | |
| 426 | for (backdesc = descnum; backdesc != seqstart - 1; backdesc--) | |
| 427 | if (drcfe->desc_array[backdesc] != NULL) | |
| 428 | accumulate_live_info_backwards(drcfe->desc_array[backdesc], &gprread, &gprwrite, &fprread, &fprwrite); | |
| 424 | 429 | |
| 425 | 430 | /* reset the register states */ |
| 426 | 431 | seqstart = -1; |
| r2724 | r2725 | |
|---|---|---|
| 19 | 19 | * Extend registers to 16? Depends on if PPC can use them |
| 20 | 20 | |
| 21 | 21 | * New instructions? |
| 22 | - EXTRACT dst,src,shift,mask | |
| 23 | dst = (src >> shift) & mask | |
| 24 | ||
| 25 | - INSERT dst,src,shift,mask | |
| 26 | dst = (dst & ~mask) | ((src << shift) & mask) | |
| 27 | ||
| 28 | 22 | - VALID opcode_desc,handle,param |
| 29 | 23 | checksum/compare code referenced by opcode_desc; if not |
| 30 | 24 | matching, generate exception with handle,param |
| r2724 | r2725 | |
| 32 | 26 | - RECALL handle |
| 33 | 27 | change code at caller to call handle in the future |
| 34 | 28 | |
| 35 | * Add interface for getting hints from the backend: | |
| 36 | - number of direct-mapped integer registers | |
| 37 | - number of direct-mapped floating point registers | |
| 38 | ||
| 39 | 29 | ***************************************************************************/ |
| 40 | 30 | |
| 41 | 31 | #include "drcuml.h" |
| 42 | 32 | #include "drcumlsh.h" |
| 43 | 33 | #include "drcumld.h" |
| 34 | #include "deprecat.h" | |
| 44 | 35 | #include "mame.h" |
| 45 | #include "deprecat.h" | |
| 46 | 36 | #include <stdarg.h> |
| 47 | 37 | #include <setjmp.h> |
| 48 | 38 | |
| 49 | 39 | |
| 50 | 40 | /*************************************************************************** |
| 41 | DEBUGGING | |
| 42 | ***************************************************************************/ | |
| 43 | ||
| 44 | #define VALIDATE_BACKEND (0) | |
| 45 | ||
| 46 | ||
| 47 | ||
| 48 | /*************************************************************************** | |
| 51 | 49 | CONSTANTS |
| 52 | 50 | ***************************************************************************/ |
| 53 | 51 | |
| 54 | 52 | /* opcode validation condition/flag valid bitmasks */ |
| 55 | 53 | #define OV_CONDFLAG_NONE 0x00 |
| 56 | 54 | #define OV_CONDFLAG_COND 0x80 |
| 55 | #define OV_CONDFLAG_SZ (DRCUML_FLAG_S | DRCUML_FLAG_Z) | |
| 56 | #define OV_CONDFLAG_SZC (DRCUML_FLAG_S | DRCUML_FLAG_Z | DRCUML_FLAG_C) | |
| 57 | #define OV_CONDFLAG_SZVC (DRCUML_FLAG_S | DRCUML_FLAG_Z | DRCUML_FLAG_V | DRCUML_FLAG_C) | |
| 58 | #define OV_CONDFLAG_UZC (DRCUML_FLAG_U | DRCUML_FLAG_Z | DRCUML_FLAG_C) | |
| 57 | 59 | #define OV_CONDFLAG_FLAGS 0x1f |
| 58 | 60 | |
| 59 | /* o | |
| 61 | /* bitmasks of | |
| 60 | 62 | #define OV_PARAM_ALLOWED_NONE (1 << DRCUML_PTYPE_NONE) |
| 61 | 63 | #define OV_PARAM_ALLOWED_IMM (1 << DRCUML_PTYPE_IMMEDIATE) |
| 62 | 64 | #define OV_PARAM_ALLOWED_IREG (1 << DRCUML_PTYPE_INT_REGISTER) |
| 63 | 65 | #define OV_PARAM_ALLOWED_FREG (1 << DRCUML_PTYPE_FLOAT_REGISTER) |
| 64 | 66 | #define OV_PARAM_ALLOWED_MVAR (1 << DRCUML_PTYPE_MAPVAR) |
| 65 | 67 | #define OV_PARAM_ALLOWED_MEM (1 << DRCUML_PTYPE_MEMORY) |
| 66 | #define OV_PARAM_ALLOWED_NCMEM (OV_PARAM_ALLOWED_MEM | 0x80) | |
| 68 | #define OV_PARAM_FLAG_ANYMEM 0x100 | |
| 69 | #define OV_PARAM_FLAG_FIXED4 0x200 | |
| 70 | #define OV_PARAM_FLAG_FIXED8 0x400 | |
| 71 | ||
| 72 | /* opcode validation parameter valid bitmasks */ | |
| 73 | #define OV_PARAM_ALLOWED_ANYMEM (OV_PARAM_ALLOWED_MEM | OV_PARAM_FLAG_ANYMEM) | |
| 67 | 74 | #define OV_PARAM_ALLOWED_IMV (OV_PARAM_ALLOWED_IMM | OV_PARAM_ALLOWED_MVAR) |
| 75 | #define OV_PARAM_ALLOWED_IMV4 (OV_PARAM_ALLOWED_IMM | OV_PARAM_ALLOWED_MVAR | OV_PARAM_FLAG_FIXED4) | |
| 76 | #define OV_PARAM_ALLOWED_IMV8 (OV_PARAM_ALLOWED_IMM | OV_PARAM_ALLOWED_MVAR | OV_PARAM_FLAG_FIXED8) | |
| 68 | 77 | #define OV_PARAM_ALLOWED_IRM (OV_PARAM_ALLOWED_IREG | OV_PARAM_ALLOWED_MEM) |
| 78 | #define OV_PARAM_ALLOWED_IRM4 (OV_PARAM_ALLOWED_IREG | OV_PARAM_ALLOWED_MEM | OV_PARAM_FLAG_FIXED4) | |
| 79 | #define OV_PARAM_ALLOWED_IRM8 (OV_PARAM_ALLOWED_IREG | OV_PARAM_ALLOWED_MEM | OV_PARAM_FLAG_FIXED8) | |
| 69 | 80 | #define OV_PARAM_ALLOWED_FRM (OV_PARAM_ALLOWED_FREG | OV_PARAM_ALLOWED_MEM) |
| 81 | #define OV_PARAM_ALLOWED_FRM4 (OV_PARAM_ALLOWED_FREG | OV_PARAM_ALLOWED_MEM | OV_PARAM_FLAG_FIXED4) | |
| 82 | #define OV_PARAM_ALLOWED_FRM8 (OV_PARAM_ALLOWED_FREG | OV_PARAM_ALLOWED_MEM | OV_PARAM_FLAG_FIXED8) | |
| 70 | 83 | #define OV_PARAM_ALLOWED_IANY (OV_PARAM_ALLOWED_IRM | OV_PARAM_ALLOWED_IMV) |
| 84 | #define OV_PARAM_ALLOWED_IANY4 (OV_PARAM_ALLOWED_IRM | OV_PARAM_ALLOWED_IMV | OV_PARAM_FLAG_FIXED4) | |
| 85 | #define OV_PARAM_ALLOWED_IANY8 (OV_PARAM_ALLOWED_IRM | OV_PARAM_ALLOWED_IMV | OV_PARAM_FLAG_FIXED8) | |
| 71 | 86 | #define OV_PARAM_ALLOWED_FANY (OV_PARAM_ALLOWED_FRM) |
| 87 | #define OV_PARAM_ALLOWED_FANY4 (OV_PARAM_ALLOWED_FRM | OV_PARAM_FLAG_FIXED4) | |
| 88 | #define OV_PARAM_ALLOWED_FANY8 (OV_PARAM_ALLOWED_FRM | OV_PARAM_FLAG_FIXED8) | |
| 72 | 89 | |
| 73 | 90 | |
| 74 | 91 | |
| r2724 | r2725 | |
| 121 | 138 | drcuml_opcode opcode; /* the opcode itself */ |
| 122 | 139 | UINT8 sizes; /* allowed sizes */ |
| 123 | 140 | UINT8 condflags; /* allowed conditions/flags */ |
| 124 | UINT8 p0types; /* allowed types for parameter 0 */ | |
| 125 | UINT8 p1types; /* allowed types for parameter 1 */ | |
| 126 | UINT8 p2types; /* allowed types for parameter 2 */ | |
| 127 | UINT8 p3types; /* allowed types for parameter 3 */ | |
| 141 | UINT16 ptypes[4]; /* allowed types for parameters */ | |
| 128 | 142 | }; |
| 129 | 143 | |
| 130 | 144 | |
| 145 | /* structure describing back-end validation test */ | |
| 146 | typedef struct _bevalidate_test bevalidate_test; | |
| 147 | struct _bevalidate_test | |
| 148 | { | |
| 149 | drcuml_opcode opcode; | |
| 150 | UINT8 size; | |
| 151 | UINT8 destmask; | |
| 152 | UINT8 iflags; | |
| 153 | UINT8 flags; | |
| 154 | UINT64 param[4]; | |
| 155 | }; | |
| 131 | 156 | |
| 157 | ||
| 158 | ||
| 132 | 159 | /*************************************************************************** |
| 133 | 160 | TABLES |
| 134 | 161 | ***************************************************************************/ |
| 135 | 162 | |
| 136 | 163 | /* macro to simplify the table */ |
| 137 | #define OPVALID_ENTRY_0(op,sizes,condflag) { DRCUML_OP_##op, sizes, OV_CONDFLAG_##condflag, OV_PARAM_ALLOWED_NONE, OV_PARAM_ALLOWED_NONE, OV_PARAM_ALLOWED_NONE, OV_PARAM_ALLOWED_NONE }, | |
| 138 | #define OPVALID_ENTRY_1(op,sizes,condflag,p0) { DRCUML_OP_##op, sizes, OV_CONDFLAG_##condflag, OV_PARAM_ALLOWED_##p0, OV_PARAM_ALLOWED_NONE, OV_PARAM_ALLOWED_NONE, OV_PARAM_ALLOWED_NONE }, | |
| 139 | #define OPVALID_ENTRY_2(op,sizes,condflag,p0,p1) { DRCUML_OP_##op, sizes, OV_CONDFLAG_##condflag, OV_PARAM_ALLOWED_##p0, OV_PARAM_ALLOWED_##p1, OV_PARAM_ALLOWED_NONE, OV_PARAM_ALLOWED_NONE }, | |
| 140 | #define OPVALID_ENTRY_3(op,sizes,condflag,p0,p1,p2) { DRCUML_OP_##op, sizes, OV_CONDFLAG_##condflag, OV_PARAM_ALLOWED_##p0, OV_PARAM_ALLOWED_##p1, OV_PARAM_ALLOWED_##p2, OV_PARAM_ALLOWED_NONE }, | |
| 141 | #define OPVALID_ENTRY_4(op,sizes,condflag,p0,p1,p2,p3) { DRCUML_OP_##op, sizes, OV_CONDFLAG_##condflag, OV_PARAM_ALLOWED_##p0, OV_PARAM_ALLOWED_##p1, OV_PARAM_ALLOWED_##p2, OV_PARAM_ALLOWED_##p3 }, | |
| 164 | #define OPVALID_ENTRY_0(op,sizes,condflag) { DRCUML_OP_##op, sizes, OV_CONDFLAG_##condflag, { OV_PARAM_ALLOWED_NONE, OV_PARAM_ALLOWED_NONE, OV_PARAM_ALLOWED_NONE, OV_PARAM_ALLOWED_NONE } }, | |
| 165 | #define OPVALID_ENTRY_1(op,sizes,condflag,p0) { DRCUML_OP_##op, sizes, OV_CONDFLAG_##condflag, { OV_PARAM_ALLOWED_##p0, OV_PARAM_ALLOWED_NONE, OV_PARAM_ALLOWED_NONE, OV_PARAM_ALLOWED_NONE } }, | |
| 166 | #define OPVALID_ENTRY_2(op,sizes,condflag,p0,p1) { DRCUML_OP_##op, sizes, OV_CONDFLAG_##condflag, { OV_PARAM_ALLOWED_##p0, OV_PARAM_ALLOWED_##p1, OV_PARAM_ALLOWED_NONE, OV_PARAM_ALLOWED_NONE } }, | |
| 167 | #define OPVALID_ENTRY_3(op,sizes,condflag,p0,p1,p2) { DRCUML_OP_##op, sizes, OV_CONDFLAG_##condflag, { OV_PARAM_ALLOWED_##p0, OV_PARAM_ALLOWED_##p1, OV_PARAM_ALLOWED_##p2, OV_PARAM_ALLOWED_NONE } }, | |
| 168 | #define OPVALID_ENTRY_4(op,sizes,condflag,p0,p1,p2,p3) { DRCUML_OP_##op, sizes, OV_CONDFLAG_##condflag, { OV_PARAM_ALLOWED_##p0, OV_PARAM_ALLOWED_##p1, OV_PARAM_ALLOWED_##p2, OV_PARAM_ALLOWED_##p3 } }, | |
| 142 | 169 | |
| 143 | 170 | /* opcode validation table */ |
| 144 | 171 | static const drcuml_opcode_valid opcode_valid_list[] = |
| r2724 | r2725 | |
| 147 | 174 | OPVALID_ENTRY_1(HANDLE, 4, NONE, MEM) |
| 148 | 175 | OPVALID_ENTRY_2(HASH, 4, NONE, IMV, IMV) |
| 149 | 176 | OPVALID_ENTRY_1(LABEL, 4, NONE, IMV) |
| 150 | OPVALID_ENTRY_1(COMMENT, 4, NONE, N | |
| 177 | OPVALID_ENTRY_1(COMMENT, 4, NONE, ANYMEM) | |
| 151 | 178 | OPVALID_ENTRY_2(MAPVAR, 4, NONE, MVAR, IMV) |
| 152 | 179 | |
| 153 | 180 | /* Control Flow Operations */ |
| r2724 | r2725 | |
| 159 | 186 | OPVALID_ENTRY_2(EXH, 4, COND, MEM, IANY) |
| 160 | 187 | OPVALID_ENTRY_1(CALLH, 4, COND, MEM) |
| 161 | 188 | OPVALID_ENTRY_0(RET, 4, COND) |
| 162 | OPVALID_ENTRY_2(CALLC, 4, COND, N | |
| 189 | OPVALID_ENTRY_2(CALLC, 4, COND, ANYMEM,ANYMEM) | |
| 163 | 190 | OPVALID_ENTRY_2(RECOVER, 4, NONE, IRM, MVAR) |
| 164 | 191 | |
| 165 | 192 | /* Internal Register Operations */ |
| 166 | 193 | OPVALID_ENTRY_1(SETFMOD, 4, NONE, IANY) |
| 167 | 194 | OPVALID_ENTRY_1(GETFMOD, 4, NONE, IRM) |
| 168 | 195 | OPVALID_ENTRY_1(GETEXP, 4, NONE, IRM) |
| 196 | OPVALID_ENTRY_1(SAVE, 4, NONE, ANYMEM) | |
| 197 | OPVALID_ENTRY_1(RESTORE, 4, NONE, ANYMEM) | |
| 169 | 198 | |
| 170 | 199 | /* Integer Operations */ |
| 171 | OPVALID_ENTRY_3(LOAD1U, 4|8, NONE, IRM, NCMEM,IANY) | |
| 172 | OPVALID_ENTRY_3(LOAD1S, 4|8, NONE, IRM, NCMEM,IANY) | |
| 173 | OPVALID_ENTRY_3(LOAD2U, 4|8, NONE, IRM, NCMEM,IANY) | |
| 174 | OPVALID_ENTRY_3(LOAD2S, 4|8, NONE, IRM, NCMEM,IANY) | |
| 175 | OPVALID_ENTRY_3(LOAD4U, 4|8, NONE, IRM, NCMEM,IANY) | |
| 176 | OPVALID_ENTRY_3(LOAD4S, 8, NONE, IRM, NCMEM,IANY) | |
| 177 | OPVALID_ENTRY_3(LOAD8U, 8, NONE, IRM, NCMEM,IANY) | |
| 178 | OPVALID_ENTRY_3(STORE1, 4|8, NONE, NCMEM,IANY, IANY) | |
| 179 | OPVALID_ENTRY_3(STORE2, 4|8, NONE, NCMEM,IANY, IANY) | |
| 180 | OPVALID_ENTRY_3(STORE4, 4|8, NONE, NCMEM,IANY, IANY) | |
| 181 | OPVALID_ENTRY_3(STORE8, 8, NONE, NCMEM,IANY, IANY) | |
| 182 | OPVALID_ENTRY_3(READ1U, 4|8, NONE, IRM, IMV, IANY) | |
| 183 | OPVALID_ENTRY_3(READ1S, 4|8, NONE, IRM, IMV, IANY) | |
| 184 | OPVALID_ENTRY_3(READ2U, 4|8, NONE, IRM, IMV, IANY) | |
| 185 | OPVALID_ENTRY_3(READ2S, 4|8, NONE, IRM, IMV, IANY) | |
| 186 | OPVALID_ENTRY_4(READ2M, 4|8, NONE, IRM, IMV, IANY, IANY) | |
| 187 | OPVALID_ENTRY_3(READ4U, 4|8, NONE, IRM, IMV, IANY) | |
| 188 | OPVALID_ENTRY_3(READ4S, 8, NONE, IRM, IMV, IANY) | |
| 189 | OPVALID_ENTRY_4(READ4M, 4|8, NONE, IRM, IMV, IANY, IANY) | |
| 190 | OPVALID_ENTRY_3(READ8U, 8, NONE, IRM, IMV, IANY) | |
| 191 | OPVALID_ENTRY_4(READ8M, 8, NONE, IRM, IMV, IANY, IANY) | |
| 192 | OPVALID_ENTRY_3(WRITE1, 4|8, NONE, IMV, IANY, IANY) | |
| 193 | OPVALID_ENTRY_3(WRITE2, 4|8, NONE, IMV, IANY, IANY) | |
| 194 | OPVALID_ENTRY_4(WRIT2M, 4|8, NONE, IMV, IANY, IANY, IANY) | |
| 195 | OPVALID_ENTRY_3(WRITE4, 4|8, NONE, IMV, IANY, IANY) | |
| 196 | OPVALID_ENTRY_4(WRIT4M, 4|8, NONE, IMV, IANY, IANY, IANY) | |
| 197 | OPVALID_ENTRY_3(WRITE8, 8, NONE, IMV, IANY, IANY) | |
| 198 | OPVALID_ENTRY_4(WRIT8M, 8, NONE, IMV, IANY, IANY, IANY) | |
| 199 | OPVALID_ENTRY_3(FLAGS, 4|8, NONE, IRM, IMV, MEM) | |
| 200 | OPVALID_ENTRY_2(MOV, 4|8, COND, IRM, IANY) | |
| 201 | OPVALID_ENTRY_2(ZEXT1, 4|8, NONE, IRM, IANY) | |
| 202 | OPVALID_ENTRY_2(ZEXT2, 4|8, NONE, IRM, IANY) | |
| 203 | OPVALID_ENTRY_2(ZEXT4, 8, NONE, IRM, IANY) | |
| 204 | OPVALID_ENTRY_2(SEXT1, 4|8, NONE, IRM, IANY) | |
| 205 | OPVALID_ENTRY_2(SEXT2, 4|8, NONE, IRM, IANY) | |
| 206 | OPVALID_ENTRY_2(SEXT4, 8, NONE, IRM, IANY) | |
| 207 | OPVALID_ENTRY_3(ADD, 4|8, FLAGS, IRM, IANY, IANY) | |
| 208 | OPVALID_ENTRY_3(ADDC, 4|8, FLAGS, IRM, IANY, IANY) | |
| 209 | OPVALID_ENTRY_3(SUB, 4|8, FLAGS, IRM, IANY, IANY) | |
| 210 | OPVALID_ENTRY_3(SUBB, 4|8, FLAGS, IRM, IANY, IANY) | |
| 211 | OPVALID_ENTRY_2(CMP, 4|8, FLAGS, IANY, IANY) | |
| 212 | OPVALID_ENTRY_4(MULU, 4|8, FLAGS, IRM, IRM, IANY, IANY) | |
| 213 | OPVALID_ENTRY_4(MULS, 4|8, FLAGS, IRM, IRM, IANY, IANY) | |
| 214 | OPVALID_ENTRY_4(DIVU, 4|8, FLAGS, IRM, IRM, IANY, IANY) | |
| 215 | OPVALID_ENTRY_4(DIVS, 4|8, FLAGS, IRM, IRM, IANY, IANY) | |
| 216 | OPVALID_ENTRY_3(AND, 4|8, FLAGS, IRM, IANY, IANY) | |
| 217 | OPVALID_ENTRY_2(TEST, 4|8, FLAGS, IANY, IANY) | |
| 218 | OPVALID_ENTRY_3(OR, 4|8, FLAGS, IRM, IANY, IANY) | |
| 219 | OPVALID_ENTRY_3(XOR, 4|8, FLAGS, IRM, IANY, IANY) | |
| 220 | OPVALID_ENTRY_3(SHL, 4|8, FLAGS, IRM, IANY, IANY) | |
| 221 | OPVALID_ENTRY_3(SHR, 4|8, FLAGS, IRM, IANY, IANY) | |
| 222 | OPVALID_ENTRY_3(SAR, 4|8, FLAGS, IRM, IANY, IANY) | |
| 223 | OPVALID_ENTRY_3(ROL, 4|8, FLAGS, IRM, IANY, IANY) | |
| 224 | OPVALID_ENTRY_3(ROLC, 4|8, FLAGS, IRM, IANY, IANY) | |
| 225 | OPVALID_ENTRY_3(ROR, 4|8, FLAGS, IRM, IANY, IANY) | |
| 226 | OPVALID_ENTRY_3(RORC, 4|8, FLAGS, IRM, IANY, IANY) | |
| 200 | OPVALID_ENTRY_3(LOAD1U, 4|8, NONE, IRM, ANYMEM,IANY4) | |
| 201 | OPVALID_ENTRY_3(LOAD1S, 4|8, NONE, IRM, ANYMEM,IANY4) | |
| 202 | OPVALID_ENTRY_3(LOAD2U, 4|8, NONE, IRM, ANYMEM,IANY4) | |
| 203 | OPVALID_ENTRY_3(LOAD2S, 4|8, NONE, IRM, ANYMEM,IANY4) | |
| 204 | OPVALID_ENTRY_3(LOAD4U, 4|8, NONE, IRM, ANYMEM,IANY4) | |
| 205 | OPVALID_ENTRY_3(LOAD4S, 8, NONE, IRM, ANYMEM,IANY4) | |
| 206 | OPVALID_ENTRY_3(LOAD8U, 8, NONE, IRM, ANYMEM,IANY4) | |
| 207 | OPVALID_ENTRY_3(STORE1, 4|8, NONE, ANYMEM,IANY4, IANY) | |
| 208 | OPVALID_ENTRY_3(STORE2, 4|8, NONE, ANYMEM,IANY4, IANY) | |
| 209 | OPVALID_ENTRY_3(STORE4, 4|8, NONE, ANYMEM,IANY4, IANY) | |
| 210 | OPVALID_ENTRY_3(STORE8, 8, NONE, ANYMEM,IANY4, IANY) | |
| 211 | OPVALID_ENTRY_3(READ1U, 4|8, NONE, IRM, IMV4, IANY4) | |
| 212 | OPVALID_ENTRY_3(READ1S, 4|8, NONE, IRM, IMV4, IANY4) | |
| 213 | OPVALID_ENTRY_3(READ2U, 4|8, NONE, IRM, IMV4, IANY4) | |
| 214 | OPVALID_ENTRY_3(READ2S, 4|8, NONE, IRM, IMV4, IANY4) | |
| 215 | OPVALID_ENTRY_4(READ2M, 4|8, NONE, IRM, IMV4, IANY4, IANY) | |
| 216 | OPVALID_ENTRY_3(READ4U, 4|8, NONE, IRM, IMV4, IANY4) | |
| 217 | OPVALID_ENTRY_3(READ4S, 8, NONE, IRM, IMV4, IANY4) | |
| 218 | OPVALID_ENTRY_4(READ4M, 4|8, NONE, IRM, IMV4, IANY4, IANY) | |
| 219 | OPVALID_ENTRY_3(READ8U, 8, NONE, IRM, IMV4, IANY4) | |
| 220 | OPVALID_ENTRY_4(READ8M, 8, NONE, IRM, IMV4, IANY4, IANY) | |
| 221 | OPVALID_ENTRY_3(WRITE1, 4|8, NONE, IMV4, IANY4, IANY) | |
| 222 | OPVALID_ENTRY_3(WRITE2, 4|8, NONE, IMV4, IANY4, IANY) | |
| 223 | OPVALID_ENTRY_4(WRIT2M, 4|8, NONE, IMV4, IANY4, IANY, IANY) | |
| 224 | OPVALID_ENTRY_3(WRITE4, 4|8, NONE, IMV4, IANY4, IANY) | |
| 225 | OPVALID_ENTRY_4(WRIT4M, 4|8, NONE, IMV4, IANY4, IANY, IANY) | |
| 226 | OPVALID_ENTRY_3(WRITE8, 8, NONE, IMV4, IANY4, IANY) | |
| 227 | OPVALID_ENTRY_4(WRIT8M, 8, NONE, IMV4, IANY4, IANY, IANY) | |
| 228 | OPVALID_ENTRY_3(FLAGS, 4|8, NONE, IRM, IMV, MEM) | |
| 229 | OPVALID_ENTRY_2(MOV, 4|8, COND, IRM, IANY) | |
| 230 | OPVALID_ENTRY_2(ZEXT1, 4|8, NONE, IRM, IANY4) | |
| 231 | OPVALID_ENTRY_2(ZEXT2, 4|8, NONE, IRM, IANY4) | |
| 232 | OPVALID_ENTRY_2(ZEXT4, 8, NONE, IRM, IANY4) | |
| 233 | OPVALID_ENTRY_2(SEXT1, 4|8, NONE, IRM, IANY4) | |
| 234 | OPVALID_ENTRY_2(SEXT2, 4|8, NONE, IRM, IANY4) | |
| 235 | OPVALID_ENTRY_2(SEXT4, 8, NONE, IRM, IANY4) | |
| 236 | OPVALID_ENTRY_4(XTRACT, 4|8, NONE, IRM, IANY, IANY, IANY) | |
| 237 | OPVALID_ENTRY_4(INSERT, 4|8, NONE, IRM, IANY, IANY, IANY) | |
| 238 | OPVALID_ENTRY_3(ADD, 4|8, SZVC, IRM, IANY, IANY) | |
| 239 | OPVALID_ENTRY_3(ADDC, 4|8, SZVC, IRM, IANY, IANY) | |
| 240 | OPVALID_ENTRY_3(SUB, 4|8, SZVC, IRM, IANY, IANY) | |
| 241 | OPVALID_ENTRY_3(SUBB, 4|8, SZVC, IRM, IANY, IANY) | |
| 242 | OPVALID_ENTRY_2(CMP, 4|8, SZVC, IANY, IANY) | |
| 243 | OPVALID_ENTRY_4(MULU, 4|8, SZ, IRM, IRM, IANY, IANY) | |
| 244 | OPVALID_ENTRY_4(MULS, 4|8, SZ, IRM, IRM, IANY, IANY) | |
| 245 | OPVALID_ENTRY_4(DIVU, 4|8, SZ, IRM, IRM, IANY, IANY) | |
| 246 | OPVALID_ENTRY_4(DIVS, 4|8, SZ, IRM, IRM, IANY, IANY) | |
| 247 | OPVALID_ENTRY_3(AND, 4|8, SZ, IRM, IANY, IANY) | |
| 248 | OPVALID_ENTRY_2(TEST, 4|8, SZ, IANY, IANY) | |
| 249 | OPVALID_ENTRY_3(OR, 4|8, SZ, IRM, IANY, IANY) | |
| 250 | OPVALID_ENTRY_3(XOR, 4|8, SZ, IRM, IANY, IANY) | |
| 251 | OPVALID_ENTRY_2(LZCNT, 4|8, NONE, IRM, IANY) | |
| 252 | OPVALID_ENTRY_3(SHL, 4|8, SZC, IRM, IANY, IANY) | |
| 253 | OPVALID_ENTRY_3(SHR, 4|8, SZC, IRM, IANY, IANY) | |
| 254 | OPVALID_ENTRY_3(SAR, 4|8, SZC, IRM, IANY, IANY) | |
| 255 | OPVALID_ENTRY_3(ROL, 4|8, SZC, IRM, IANY, IANY) | |
| 256 | OPVALID_ENTRY_3(ROLC, 4|8, SZC, IRM, IANY, IANY) | |
| 257 | OPVALID_ENTRY_3(ROR, 4|8, SZC, IRM, IANY, IANY) | |
| 258 | OPVALID_ENTRY_3(RORC, 4|8, SZC, IRM, IANY, IANY) | |
| 227 | 259 | |
| 228 | 260 | /* Floating Point Operations */ |
| 229 | OPVALID_ENTRY_3(FLOAD, 4|8, NONE, FRM, NCMEM,IANY) | |
| 230 | OPVALID_ENTRY_3(FSTORE, 4|8, NONE, NCMEM,IANY, FANY) | |
| 231 | OPVALID_ENTRY_3(FREAD, 4|8, NONE, FRM, IMV, IANY) | |
| 232 | OPVALID_ENTRY_3(FWRITE, 4|8, NONE, IMV, IANY, FANY) | |
| 233 | OPVALID_ENTRY_2(FMOV, 4|8, COND, FRM, FANY) | |
| 234 | OPVALID_ENTRY_2(FTOI4, 4|8, NONE, IRM, FANY) | |
| 235 | OPVALID_ENTRY_2(FTOI4T, 4|8, NONE, IRM, FANY) | |
| 236 | OPVALID_ENTRY_2(FTOI4R, 4|8, NONE, IRM, FANY) | |
| 237 | OPVALID_ENTRY_2(FTOI4F, 4|8, NONE, IRM, FANY) | |
| 238 | OPVALID_ENTRY_2(FTOI4C, 4|8, NONE, IRM, FANY) | |
| 239 | OPVALID_ENTRY_2(FTOI8, 4|8, NONE, IRM, FANY) | |
| 240 | OPVALID_ENTRY_2(FTOI8T, 4|8, NONE, IRM, FANY) | |
| 241 | OPVALID_ENTRY_2(FTOI8R, 4|8, NONE, IRM, FANY) | |
| 242 | OPVALID_ENTRY_2(FTOI8F, 4|8, NONE, IRM, FANY) | |
| 243 | OPVALID_ENTRY_2(FTOI8C, 4|8, NONE, IRM, FANY) | |
| 244 | OPVALID_ENTRY_2(FFRFS, 8, NONE, FRM, FANY) | |
| 245 | OPVALID_ENTRY_2(FFRFD, 4 , NONE, FRM, FANY) | |
| 246 | OPVALID_ENTRY_2(FFRI4, 4|8, NONE, FRM, IANY) | |
| 247 | OPVALID_ENTRY_2(FFRI8, 4|8, NONE, FRM, IANY) | |
| 248 | OPVALID_ENTRY_3(FADD, 4|8, FLAGS, FRM, FANY, FANY) | |
| 249 | OPVALID_ENTRY_3(FSUB, 4|8, FLAGS, FRM, FANY, FANY) | |
| 250 | OPVALID_ENTRY_2(FCMP, 4|8, FLAGS, FANY, FANY) | |
| 251 | OPVALID_ENTRY_3(FMUL, 4|8, FLAGS, FRM, FANY, FANY) | |
| 252 | OPVALID_ENTRY_3(FDIV, 4|8, FLAGS, FRM, FANY, FANY) | |
| 253 | OPVALID_ENTRY_2(FNEG, 4|8, FLAGS, FRM, FANY) | |
| 254 | OPVALID_ENTRY_2(FABS, 4|8, FLAGS, FRM, FANY) | |
| 255 | OPVALID_ENTRY_2(FSQRT, 4|8, FLAGS, FRM, FANY) | |
| 256 | OPVALID_ENTRY_2(FRECIP, 4|8, NONE, FRM, FANY) | |
| 257 | OPVALID_ENTRY_2(FRSQRT, 4|8, NONE, FRM, FANY) | |
| 261 | OPVALID_ENTRY_3(FLOAD, 4|8, NONE, FRM, ANYMEM,IANY4) | |
| 262 | OPVALID_ENTRY_3(FSTORE, 4|8, NONE, ANYMEM,IANY4, FANY) | |
| 263 | OPVALID_ENTRY_3(FREAD, 4|8, NONE, FRM, IMV4, IANY4) | |
| 264 | OPVALID_ENTRY_3(FWRITE, 4|8, NONE, IMV4, IANY4, FANY) | |
| 265 | OPVALID_ENTRY_2(FMOV, 4|8, COND, FRM, FANY) | |
| 266 | OPVALID_ENTRY_2(FTOI4, 4|8, NONE, IRM4, FANY) | |
| 267 | OPVALID_ENTRY_2(FTOI4T, 4|8, NONE, IRM4, FANY) | |
| 268 | OPVALID_ENTRY_2(FTOI4R, 4|8, NONE, IRM4, FANY) | |
| 269 | OPVALID_ENTRY_2(FTOI4F, 4|8, NONE, IRM4, FANY) | |
| 270 | OPVALID_ENTRY_2(FTOI4C, 4|8, NONE, IRM4, FANY) | |
| 271 | OPVALID_ENTRY_2(FTOI8, 4|8, NONE, IRM8, FANY) | |
| 272 | OPVALID_ENTRY_2(FTOI8T, 4|8, NONE, IRM8, FANY) | |
| 273 | OPVALID_ENTRY_2(FTOI8R, 4|8, NONE, IRM8, FANY) | |
| 274 | OPVALID_ENTRY_2(FTOI8F, 4|8, NONE, IRM8, FANY) | |
| 275 | OPVALID_ENTRY_2(FTOI8C, 4|8, NONE, IRM8, FANY) | |
| 276 | OPVALID_ENTRY_2(FFRFS, 8, NONE, FRM, FANY4) | |
| 277 | OPVALID_ENTRY_2(FFRFD, 4 , NONE, FRM, FANY8) | |
| 278 | OPVALID_ENTRY_2(FFRI4, 4|8, NONE, FRM, IANY4) | |
| 279 | OPVALID_ENTRY_2(FFRI8, 4|8, NONE, FRM, IANY8) | |
| 280 | OPVALID_ENTRY_3(FADD, 4|8, NONE, FRM, FANY, FANY) | |
| 281 | OPVALID_ENTRY_3(FSUB, 4|8, NONE, FRM, FANY, FANY) | |
| 282 | OPVALID_ENTRY_2(FCMP, 4|8, UZC, FANY, FANY) | |
| 283 | OPVALID_ENTRY_3(FMUL, 4|8, NONE, FRM, FANY, FANY) | |
| 284 | OPVALID_ENTRY_3(FDIV, 4|8, NONE, FRM, FANY, FANY) | |
| 285 | OPVALID_ENTRY_2(FNEG, 4|8, NONE, FRM, FANY) | |
| 286 | OPVALID_ENTRY_2(FABS, 4|8, NONE, FRM, FANY) | |
| 287 | OPVALID_ENTRY_2(FSQRT, 4|8, NONE, FRM, FANY) | |
| 288 | OPVALID_ENTRY_2(FRECIP, 4|8, NONE, FRM, FANY) | |
| 289 | OPVALID_ENTRY_2(FRSQRT, 4|8, NONE, FRM, FANY) | |
| 258 | 290 | }; |
| 259 | 291 | |
| 260 | 292 | |
| r2724 | r2725 | |
| 282 | 314 | FUNCTION PROTOTYPES |
| 283 | 315 | ***************************************************************************/ |
| 284 | 316 | |
| 285 | #ifdef MAME_DEBUG | |
| 286 | 317 | static void validate_instruction(drcuml_block *block, const drcuml_instruction *inst); |
| 287 | #else | |
| 288 | #define validate_instruction(block, inst) do { } while (0) | |
| 289 | #endif | |
| 318 | static void validate_backend(drcuml_state *drcuml); | |
| 319 | static void bevalidate_iterate_over_params(drcuml_state *drcuml, drcuml_codehandle **handles, const bevalidate_test *test, drcuml_parameter *paramlist, int pnum); | |
| 320 | static void bevalidate_iterate_over_flags(drcuml_state *drcuml, drcuml_codehandle **handles, const bevalidate_test *test, drcuml_parameter *paramlist); | |
| 321 | static void bevalidate_execute(drcuml_state *drcuml, drcuml_codehandle **handles, const bevalidate_test *test, const drcuml_parameter *paramlist, UINT8 flagmask); | |
| 322 | static void bevalidate_initialize_random_state(drcuml_block *block, drcuml_machine_state *state); | |
| 323 | static int bevalidate_populate_state(drcuml_block *block, drcuml_machine_state *state, const bevalidate_test *test, const drcuml_parameter *paramlist, drcuml_parameter *params, UINT64 *parammem); | |
| 324 | static int bevalidate_verify_state(drcuml_state *drcuml, const drcuml_machine_state *istate, drcuml_machine_state *state, const bevalidate_test *test, const drcuml_parameter *params, const drcuml_instruction *testinst, drccodeptr codestart, drccodeptr codeend, UINT8 flagmask); | |
| 290 | 325 | |
| 291 | 326 | |
| 292 | 327 | |
| 293 | 328 | /*************************************************************************** |
| 329 | INLINE FUNCTIONS | |
| 330 | ***************************************************************************/ | |
| 331 | ||
| 332 | /*------------------------------------------------- | |
| 333 | size_for_param - given a set of parameter | |
| 334 | flags and the instruction size, return the | |
| 335 | size of the parameter | |
| 336 | -------------------------------------------------*/ | |
| 337 | ||
| 338 | INLINE int size_for_param(int instsize, UINT16 flags) | |
| 339 | { | |
| 340 | if (flags & OV_PARAM_FLAG_FIXED4) | |
| 341 | return 4; | |
| 342 | else if (flags & OV_PARAM_FLAG_FIXED8) | |
| 343 | return 8; | |
| 344 | else | |
| 345 | return instsize; | |
| 346 | } | |
| 347 | ||
| 348 | ||
| 349 | /*------------------------------------------------- | |
| 350 | mask_for_param - given a set of parameter | |
| 351 | flags and the instruction size, return a | |
| 352 | mask of valid bits for that parameter | |
| 353 | -------------------------------------------------*/ | |
| 354 | ||
| 355 | INLINE UINT64 mask_for_param(int instsize, UINT16 flags) | |
| 356 | { | |
| 357 | switch (size_for_param(instsize, flags)) | |
| 358 | { | |
| 359 | case 4: return U64(0x00000000ffffffff); | |
| 360 | case 8: return U64(0xffffffffffffffff); | |
| 361 | } | |
| 362 | return 0; | |
| 363 | } | |
| 364 | ||
| 365 | ||
| 366 | ||
| 367 | /*************************************************************************** | |
| 294 | 368 | INITIALIZATION/TEARDOWN |
| 295 | 369 | ***************************************************************************/ |
| 296 | 370 | |
| r2724 | r2725 | |
| 335 | 409 | |
| 336 | 410 | |
| 337 | 411 | /*------------------------------------------------- |
| 412 | drcuml_get_backend_info - return information | |
| 413 | about the back-end | |
| 414 | -------------------------------------------------*/ | |
| 415 | ||
| 416 | void drcuml_get_backend_info(drcuml_state *drcuml, drcbe_info *info) | |
| 417 | { | |
| 418 | (*drcuml->beintf->be_get_info)(drcuml->bestate, info); | |
| 419 | } | |
| 420 | ||
| 421 | ||
| 422 | /*------------------------------------------------- | |
| 338 | 423 | drcuml_reset - reset the state completely, |
| 339 | 424 | flushing the cache and all information |
| 340 | 425 | -------------------------------------------------*/ |
| r2724 | r2725 | |
| 357 | 442 | |
| 358 | 443 | /* call the backend to reset */ |
| 359 | 444 | (*drcuml->beintf->be_reset)(drcuml->bestate); |
| 445 | ||
| 446 | /* do a one-time validation if requested */ | |
| 447 | if (VALIDATE_BACKEND) | |
| 448 | { | |
| 449 | static int validated = FALSE; | |
| 450 | if (!validated) | |
| 451 | { | |
| 452 | validated = TRUE; | |
| 453 | validate_backend(drcuml); | |
| 454 | } | |
| 455 | } | |
| 360 | 456 | } |
| 361 | 457 | |
| 362 | 458 | |
| r2724 | r2725 | |
| 817 | 913 | instruction created meets all requirements |
| 818 | 914 | -------------------------------------------------*/ |
| 819 | 915 | |
| 820 | #ifdef MAME_DEBUG | |
| 821 | 916 | static void validate_instruction(drcuml_block *block, const drcuml_instruction *inst) |
| 822 | 917 | { |
| 823 | 918 | const drcuml_opcode_valid *opvalid = &opcode_valid_table[inst->opcode]; |
| r2724 | r2725 | |
| 829 | 924 | if (inst->numparams > 0) |
| 830 | 925 | { |
| 831 | 926 | assert(inst->param[0].type > DRCUML_PTYPE_NONE && inst->param[0].type < DRCUML_PTYPE_MAX); |
| 832 | assert(((opvalid->p0types >> inst->param[0].type) & 1) != 0); | |
| 833 | if (inst->param[0].type == DRCUML_PTYPE_MEMORY && !(opvalid->p0types & 0x80)) | |
| 927 | assert(((opvalid->ptypes[0] >> inst->param[0].type) & 1) != 0); | |
| 928 | if (inst->param[0].type == DRCUML_PTYPE_MEMORY && !(opvalid->ptypes[0] & OV_PARAM_FLAG_ANYMEM)) | |
| 834 | 929 | assert_in_near_cache(block->drcuml->cache, (void *)(FPTR)inst->param[0].value); |
| 835 | 930 | } |
| 836 | 931 | if (inst->numparams > 1) |
| 837 | 932 | { |
| 838 | 933 | assert(inst->param[1].type > DRCUML_PTYPE_NONE && inst->param[1].type < DRCUML_PTYPE_MAX); |
| 839 | assert(((opvalid->p1types >> inst->param[1].type) & 1) != 0); | |
| 840 | if (inst->param[1].type == DRCUML_PTYPE_MEMORY && !(opvalid->p1types & 0x80)) | |
| 934 | assert(((opvalid->ptypes[1] >> inst->param[1].type) & 1) != 0); | |
| 935 | if (inst->param[1].type == DRCUML_PTYPE_MEMORY && !(opvalid->ptypes[1] & OV_PARAM_FLAG_ANYMEM)) | |
| 841 | 936 | assert_in_near_cache(block->drcuml->cache, (void *)(FPTR)inst->param[1].value); |
| 842 | 937 | } |
| 843 | 938 | if (inst->numparams > 2) |
| 844 | 939 | { |
| 845 | 940 | assert(inst->param[2].type > DRCUML_PTYPE_NONE && inst->param[2].type < DRCUML_PTYPE_MAX); |
| 846 | assert(((opvalid->p2types >> inst->param[2].type) & 1) != 0); | |
| 847 | if (inst->param[2].type == DRCUML_PTYPE_MEMORY && !(opvalid->p2types & 0x80)) | |
| 941 | assert(((opvalid->ptypes[2] >> inst->param[2].type) & 1) != 0); | |
| 942 | if (inst->param[2].type == DRCUML_PTYPE_MEMORY && !(opvalid->ptypes[2] & OV_PARAM_FLAG_ANYMEM)) | |
| 848 | 943 | assert_in_near_cache(block->drcuml->cache, (void *)(FPTR)inst->param[2].value); |
| 849 | 944 | } |
| 850 | 945 | if (inst->numparams > 3) |
| 851 | 946 | { |
| 852 | 947 | assert(inst->param[3].type > DRCUML_PTYPE_NONE && inst->param[3].type < DRCUML_PTYPE_MAX); |
| 853 | assert(((opvalid->p3types >> inst->param[3].type) & 1) != 0); | |
| 854 | if (inst->param[3].type == DRCUML_PTYPE_MEMORY && !(opvalid->p3types & 0x80)) | |
| 948 | assert(((opvalid->ptypes[3] >> inst->param[3].type) & 1) != 0); | |
| 949 | if (inst->param[3].type == DRCUML_PTYPE_MEMORY && !(opvalid->ptypes[3] & OV_PARAM_FLAG_ANYMEM)) | |
| 855 | 950 | assert_in_near_cache(block->drcuml->cache, (void *)(FPTR)inst->param[3].value); |
| 856 | 951 | } |
| 857 | 952 | } |
| 858 | #endif | |
| 953 | ||
| 954 | ||
| 955 | ||
| 956 | /*************************************************************************** | |
| 957 | BACK-END VALIDATION | |
| 958 | ***************************************************************************/ | |
| 959 | ||
| 960 | #define TEST_ENTRY_DSS(op, size, p1, p2, p3, flags) { DRCUML_OP_##op, size, 0x01, 0, flags, { U64(p1), U64(p2), U64(p3) } }, | |
| 961 | #define TEST_ENTRY_DSSI(op, size, p1, p2, p3, iflags, flags) { DRCUML_OP_##op, size, 0x01, iflags, flags, { U64(p1), U64(p2), U64(p3) } }, | |
| 962 | ||
| 963 | static const bevalidate_test bevalidate_test_list[] = | |
| 964 | { | |
| 965 | TEST_ENTRY_DSS(ADD, 4, 0x7fffffff, 0x12345678, 0x6dcba987, 0) | |
| 966 | TEST_ENTRY_DSS(ADD, 4, 0x80000000, 0x12345678, 0x6dcba988, FLAGS_V | FLAGS_S) | |
| 967 | TEST_ENTRY_DSS(ADD, 4, 0xffffffff, 0x92345678, 0x6dcba987, FLAGS_S) | |
| 968 | TEST_ENTRY_DSS(ADD, 4, 0x00000000, 0x92345678, 0x6dcba988, FLAGS_C | FLAGS_Z) | |
| 969 | ||
| 970 | TEST_ENTRY_DSS(ADD, 8, 0x7fffffffffffffff, 0x0123456789abcdef, 0x7edcba9876543210, 0) | |
| 971 | TEST_ENTRY_DSS(ADD, 8, 0x8000000000000000, 0x0123456789abcdef, 0x7edcba9876543211, FLAGS_V | FLAGS_S) | |
| 972 | TEST_ENTRY_DSS(ADD, 8, 0xffffffffffffffff, 0x8123456789abcdef, 0x7edcba9876543210, FLAGS_S) | |
| 973 | TEST_ENTRY_DSS(ADD, 8, 0x0000000000000000, 0x8123456789abcdef, 0x7edcba9876543211, FLAGS_C | FLAGS_Z) | |
| 974 | ||
| 975 | TEST_ENTRY_DSSI(ADDC, 4, 0x7fffffff, 0x12345678, 0x6dcba987, 0, 0) | |
| 976 | TEST_ENTRY_DSSI(ADDC, 4, 0x7fffffff, 0x12345678, 0x6dcba986, FLAGS_C, 0) | |
| 977 | TEST_ENTRY_DSSI(ADDC, 4, 0x80000000, 0x12345678, 0x6dcba988, 0, FLAGS_V | FLAGS_S) | |
| 978 | TEST_ENTRY_DSSI(ADDC, 4, 0x80000000, 0x12345678, 0x6dcba987, FLAGS_C, FLAGS_V | FLAGS_S) | |
| 979 | TEST_ENTRY_DSSI(ADDC, 4, 0xffffffff, 0x92345678, 0x6dcba987, 0, FLAGS_S) | |
| 980 | TEST_ENTRY_DSSI(ADDC, 4, 0xffffffff, 0x92345678, 0x6dcba986, FLAGS_C, FLAGS_S) | |
| 981 | TEST_ENTRY_DSSI(ADDC, 4, 0x00000000, 0x92345678, 0x6dcba988, 0, FLAGS_C | FLAGS_Z) | |
| 982 | TEST_ENTRY_DSSI(ADDC, 4, 0x00000000, 0x92345678, 0x6dcba987, FLAGS_C, FLAGS_C | FLAGS_Z) | |
| 983 | TEST_ENTRY_DSSI(ADDC, 4, 0x12345678, 0x12345678, 0xffffffff, FLAGS_C, FLAGS_C) | |
| 984 | ||
| 985 | TEST_ENTRY_DSSI(ADDC, 8, 0x7fffffffffffffff, 0x0123456789abcdef, 0x7edcba9876543210, 0, 0) | |
| 986 | TEST_ENTRY_DSSI(ADDC, 8, 0x7fffffffffffffff, 0x0123456789abcdef, 0x7edcba987654320f, FLAGS_C, 0) | |
| 987 | TEST_ENTRY_DSSI(ADDC, 8, 0x8000000000000000, 0x0123456789abcdef, 0x7edcba9876543211, 0, FLAGS_V | FLAGS_S) | |
| 988 | TEST_ENTRY_DSSI(ADDC, 8, 0x8000000000000000, 0x0123456789abcdef, 0x7edcba9876543210, FLAGS_C, FLAGS_V | FLAGS_S) | |
| 989 | TEST_ENTRY_DSSI(ADDC, 8, 0xffffffffffffffff, 0x8123456789abcdef, 0x7edcba9876543210, 0, FLAGS_S) | |
| 990 | TEST_ENTRY_DSSI(ADDC, 8, 0xffffffffffffffff, 0x8123456789abcdef, 0x7edcba987654320f, FLAGS_C, FLAGS_S) | |
| 991 | TEST_ENTRY_DSSI(ADDC, 8, 0x0000000000000000, 0x8123456789abcdef, 0x7edcba9876543211, 0, FLAGS_C | FLAGS_Z) | |
| 992 | TEST_ENTRY_DSSI(ADDC, 8, 0x0000000000000000, 0x8123456789abcdef, 0x7edcba9876543210, FLAGS_C, FLAGS_C | FLAGS_Z) | |
| 993 | TEST_ENTRY_DSSI(ADDC, 8, 0x123456789abcdef0, 0x123456789abcdef0, 0xffffffffffffffff, FLAGS_C, FLAGS_C) | |
| 994 | }; | |
| 995 | ||
| 996 | ||
| 997 | /*------------------------------------------------- | |
| 998 | validate_backend - execute a number of | |
| 999 | generic tests on the backend code generator | |
| 1000 | -------------------------------------------------*/ | |
| 1001 | ||
| 1002 | static void validate_backend(drcuml_state *drcuml) | |
| 1003 | { | |
| 1004 | drcuml_codehandle *handles[3]; | |
| 1005 | int tnum; | |
| 1006 | ||
| 1007 | /* allocate handles for the code */ | |
| 1008 | handles[0] = drcuml_handle_alloc(drcuml, "test_entry"); | |
| 1009 | handles[1] = drcuml_handle_alloc(drcuml, "code_start"); | |
| 1010 | handles[2] = drcuml_handle_alloc(drcuml, "code_end"); | |
| 1011 | ||
| 1012 | /* iterate over test entries */ | |
| 1013 | printf("Backend validation....\n"); | |
| 1014 | for (tnum = 0; tnum < ARRAY_LENGTH(bevalidate_test_list); tnum++) | |
| 1015 | { | |
| 1016 | const bevalidate_test *test = &bevalidate_test_list[tnum]; | |
| 1017 | drcuml_parameter param[ARRAY_LENGTH(test->param)]; | |
| 1018 | ||
| 1019 | /* reset parameter list and iterate */ | |
| 1020 | memset(param, 0, sizeof(param)); | |
| 1021 | printf("Executing test %d/%d", tnum + 1, (int)ARRAY_LENGTH(bevalidate_test_list)); | |
| 1022 | bevalidate_iterate_over_params(drcuml, handles, test, param, 0); | |
| 1023 | printf("\n"); | |
| 1024 | } | |
| 1025 | fatalerror("All tests passed!"); | |
| 1026 | } | |
| 1027 | ||
| 1028 | ||
| 1029 | /*------------------------------------------------- | |
| 1030 | bevalidate_iterate_over_params - iterate over | |
| 1031 | all supported types and values of a parameter | |
| 1032 | and recursively hand off to the next parameter, | |
| 1033 | or else move on to iterate over the flags | |
| 1034 | -------------------------------------------------*/ | |
| 1035 | ||
| 1036 | static void bevalidate_iterate_over_params(drcuml_state *drcuml, drcuml_codehandle **handles, const bevalidate_test *test, drcuml_parameter *paramlist, int pnum) | |
| 1037 | { | |
| 1038 | const drcuml_opcode_valid *opvalid = &opcode_valid_table[test->opcode]; | |
| 1039 | ||
| 1040 | /* if no parameters, execute now */ | |
| 1041 | if (pnum >= ARRAY_LENGTH(opvalid->ptypes) || opvalid->ptypes[pnum] == OV_PARAM_ALLOWED_NONE) | |
| 1042 | { | |
| 1043 | bevalidate_iterate_over_flags(drcuml, handles, test, paramlist); | |
| 1044 | return; | |
| 1045 | } | |
| 1046 | ||
| 1047 | /* iterate over valid parameter types */ | |
| 1048 | for (paramlist[pnum].type = DRCUML_PTYPE_IMMEDIATE; paramlist[pnum].type < DRCUML_PTYPE_MAX; paramlist[pnum].type++) | |
| 1049 | if (opvalid->ptypes[pnum] & (1 << paramlist[pnum].type)) | |
| 1050 | { | |
| 1051 | int pindex, pcount; | |
| 1052 | ||
| 1053 | /* mapvars can only do 32-bit tests */ | |
| 1054 | if (paramlist[pnum].type == DRCUML_PTYPE_MAPVAR && size_for_param(test->size, opvalid->ptypes[pnum]) == 8) | |
| 1055 | continue; | |
| 1056 | ||
| 1057 | /* for some parameter types, we wish to iterate over all possibilities */ | |
| 1058 | switch (paramlist[pnum].type) | |
| 1059 | { | |
| 1060 | case DRCUML_PTYPE_INT_REGISTER: pcount = DRCUML_REG_I_END - DRCUML_REG_I0; break; | |
| 1061 | case DRCUML_PTYPE_FLOAT_REGISTER: pcount = DRCUML_REG_F_END - DRCUML_REG_F0; break; | |
| 1062 | case DRCUML_PTYPE_MAPVAR: pcount = DRCUML_MAPVAR_END - DRCUML_MAPVAR_M0; break; | |
| 1063 | default: pcount = 1; break; | |
| 1064 | } | |
| 1065 | ||
| 1066 | /* iterate over possibilities */ | |
| 1067 | for (pindex = 0; pindex < pcount; pindex++) | |
| 1068 | { | |
| 1069 | int skip = FALSE; | |
| 1070 | int pscannum; | |
| 1071 | ||
| 1072 | /* for param 0, print a dot */ | |
| 1073 | if (pnum == 0) | |
| 1074 | printf("."); | |
| 1075 | ||
| 1076 | /* can't duplicate multiple source parameters unless they are immediates */ | |
| 1077 | if (paramlist[pnum].type != DRCUML_PTYPE_IMMEDIATE && ((test->destmask >> pnum) & 1) == 0) | |
| 1078 | ||
| 1079 | /* loop over all parameters we've done before; if the parameter is a source and matches us, skip this case */ | |
| 1080 | for (pscannum = 0; pscannum < pnum; pscannum++) | |
| 1081 | if (((test->destmask >> pscannum) & 1) == 0 && paramlist[pnum].type == paramlist[pscannum].type && pindex == paramlist[pscannum].value) | |
| 1082 | skip = TRUE; | |
| 1083 | ||
| 1084 | /* iterate over the next parameter in line */ | |
| 1085 | if (!skip) | |
| 1086 | { | |
| 1087 | paramlist[pnum].value = pindex; | |
| 1088 | bevalidate_iterate_over_params(drcuml, handles, test, paramlist, pnum + 1); | |
| 1089 | } | |
| 1090 | } | |
| 1091 | } | |
| 1092 | } | |
| 1093 | ||
| 1094 | ||
| 1095 | /*------------------------------------------------- | |
| 1096 | bevalidate_iterate_over_flags - iterate over | |
| 1097 | all supported flag masks | |
| 1098 | -------------------------------------------------*/ | |
| 1099 | ||
| 1100 | static void bevalidate_iterate_over_flags(drcuml_state *drcuml, drcuml_codehandle **handles, const bevalidate_test *test, drcuml_parameter *paramlist) | |
| 1101 | { | |
| 1102 | const drcuml_opcode_valid *opvalid = &opcode_valid_table[test->opcode]; | |
| 1103 | UINT8 flagmask = opvalid->condflags & 0x1f; | |
| 1104 | UINT8 curmask; | |
| 1105 | ||
| 1106 | /* iterate over all possible flag combinations */ | |
| 1107 | for (curmask = 0; curmask <= flagmask; curmask++) | |
| 1108 | if ((curmask & flagmask) == curmask) | |
| 1109 | bevalidate_execute(drcuml, handles, test, paramlist, curmask); | |
| 1110 | } | |
| 1111 | ||
| 1112 | ||
| 1113 | /*------------------------------------------------- | |
| 1114 | bevalidate_execute - execute a single instance | |
| 1115 | of a test, generating code and verifying the | |
| 1116 | results | |
| 1117 | -------------------------------------------------*/ | |
| 1118 | ||
| 1119 | static void bevalidate_execute(drcuml_state *drcuml, drcuml_codehandle **handles, const bevalidate_test *test, const drcuml_parameter *paramlist, UINT8 flagmask) | |
| 1120 | { | |
| 1121 | drcuml_parameter params[ARRAY_LENGTH(test->param)]; | |
| 1122 | drcuml_machine_state istate, fstate; | |
| 1123 | drcuml_instruction testinst; | |
| 1124 | drcuml_block *block; | |
| 1125 | UINT64 *parammem; | |
| 1126 | int numparams; | |
| 1127 | ||
| 1128 | /* allocate memory for parameters */ | |
| 1129 | parammem = drccache_memory_alloc_near(drcuml->cache, sizeof(UINT64) * ARRAY_LENGTH(test->param)); | |
| 1130 | ||
| 1131 | /* flush the cache */ | |
| 1132 | drcuml_reset(drcuml); | |
| 1133 | ||
| 1134 | /* start a new block */ | |
| 1135 | block = drcuml_block_begin(drcuml, 30, NULL); | |
| 1136 | UML_HANDLE(block, handles[0]); | |
| 1137 | ||
| 1138 | /* set up a random initial state */ | |
| 1139 | bevalidate_initialize_random_state(block, &istate); | |
| 1140 | ||
| 1141 | /* then populate the state with the parameters */ | |
| 1142 | numparams = bevalidate_populate_state(block, &istate, test, paramlist, params, parammem); | |
| 1143 | ||
| 1144 | /* generate the code */ | |
| 1145 | UML_RESTORE(block, &istate); | |
| 1146 | UML_HANDLE(block, handles[1]); | |
| 1147 | switch (numparams) | |
| 1148 | { | |
| 1149 | case 0: | |
| 1150 | drcuml_block_append_0(block, test->opcode, test->size, flagmask); | |
| 1151 | break; | |
| 1152 | ||
| 1153 | case 1: | |
| 1154 | drcuml_block_append_1(block, test->opcode, test->size, flagmask, params[0].type, params[0].value); | |
| 1155 | break; | |
| 1156 | ||
| 1157 | case 2: | |
| 1158 | drcuml_block_append_2(block, test->opcode, test->size, flagmask, params[0].type, params[0].value, params[1].type, params[1].value); | |
| 1159 | break; | |
| 1160 | ||
| 1161 | case 3: | |
| 1162 | drcuml_block_append_3(block, test->opcode, test->size, flagmask, params[0].type, params[0].value, params[1].type, params[1].value, params[2].type, params[2].value); | |
| 1163 | break; | |
| 1164 | ||
| 1165 | case 4: | |
| 1166 | drcuml_block_append_4(block, test->opcode, test->size, flagmask, params[0].type, params[0].value, params[1].type, params[1].value, params[2].type, params[2].value, params[3].type, params[3].value); | |
| 1167 | break; | |
| 1168 | } | |
| 1169 | testinst = block->inst[block->nextinst - 1]; | |
| 1170 | UML_HANDLE(block, handles[2]); | |
| 1171 | UML_SAVE(block, &fstate); | |
| 1172 | UML_EXIT(block, IMM(0)); | |
| 1173 | ||
| 1174 | /* end the block */ | |
| 1175 | drcuml_block_end(block); | |
| 1176 | ||
| 1177 | /* execute */ | |
| 1178 | drcuml_execute(drcuml, handles[0]); | |
| 1179 | ||
| 1180 | /* verify the results */ | |
| 1181 | bevalidate_verify_state(drcuml, &istate, &fstate, test, params, &testinst, handles[1]->code, handles[2]->code, flagmask); | |
| 1182 | ||
| 1183 | /* free memory */ | |
| 1184 | drccache_memory_free(drcuml->cache, parammem, sizeof(UINT64) * ARRAY_LENGTH(test->param)); | |
| 1185 | } | |
| 1186 | ||
| 1187 | ||
| 1188 | /*------------------------------------------------- | |
| 1189 | bevalidate_initialize_random_state - | |
| 1190 | initialize the machine state to randomness | |
| 1191 | -------------------------------------------------*/ | |
| 1192 | ||
| 1193 | static void bevalidate_initialize_random_state(drcuml_block *block, drcuml_machine_state *state) | |
| 1194 | { | |
| 1195 | int regnum; | |
| 1196 | ||
| 1197 | /* initialize core state to random values */ | |
| 1198 | state->fmod = mame_rand(Machine) & 0x03; | |
| 1199 | state->flags = mame_rand(Machine) & 0x1f; | |
| 1200 | state->exp = mame_rand(Machine); | |
| 1201 | ||
| 1202 | /* initialize integer registers to random values */ | |
| 1203 | for (regnum = 0; regnum < ARRAY_LENGTH(state->r); regnum++) | |
| 1204 | { | |
| 1205 | state->r[regnum].w.h = mame_rand(Machine); | |
| 1206 | state->r[regnum].w.l = mame_rand(Machine); | |
| 1207 | } | |
| 1208 | ||
| 1209 | /* initialize float registers to random values */ | |
| 1210 | for (regnum = 0; regnum < ARRAY_LENGTH(state->f); regnum++) | |
| 1211 | { | |
| 1212 | *(UINT32 *)&state->f[regnum].s.h = mame_rand(Machine); | |
| 1213 | *(UINT32 *)&state->f[regnum].s.l = mame_rand(Machine); | |
| 1214 | } | |
| 1215 | ||
| 1216 | /* initialize map variables to random values */ | |
| 1217 | for (regnum = 0; regnum < DRCUML_MAPVAR_END - DRCUML_MAPVAR_M0; regnum++) | |
| 1218 | UML_MAPVAR(block, MVAR(regnum), mame_rand(Machine)); | |
| 1219 | } | |
| 1220 | ||
| 1221 | ||
| 1222 | /*------------------------------------------------- | |
| 1223 | bevalidate_populate_state - populate the | |
| 1224 | machine state with the proper values prior | |
| 1225 | to executing a test | |
| 1226 | -------------------------------------------------*/ | |
| 1227 | ||
| 1228 | static int bevalidate_populate_state(drcuml_block *block, drcuml_machine_state *state, const bevalidate_test *test, const drcuml_parameter *paramlist, drcuml_parameter *params, UINT64 *parammem) | |
| 1229 | { | |
| 1230 | const drcuml_opcode_valid *opvalid = &opcode_valid_table[test->opcode]; | |
| 1231 | int numparams = ARRAY_LENGTH(test->param); | |
| 1232 | int pnum; | |
| 1233 | ||
| 1234 | /* copy flags as-is */ | |
| 1235 | state->flags = test->iflags; | |
| 1236 | ||
| 1237 | /* iterate over parameters */ | |
| 1238 | for (pnum = 0; pnum < ARRAY_LENGTH(test->param); pnum++) | |
| 1239 | { | |
| 1240 | int psize = size_for_param(test->size, opvalid->ptypes[pnum]); | |
| 1241 | drcuml_parameter *curparam = ¶ms[pnum]; | |
| 1242 | ||
| 1243 | /* start with a copy of the parameter from the list */ | |
| 1244 | *curparam = paramlist[pnum]; | |
| 1245 | ||
| 1246 | /* switch off the type */ | |
| 1247 | switch (curparam->type) | |
| 1248 | { | |
| 1249 | /* immediate parameters: take the value from the test entry */ | |
| 1250 | case DRCUML_PTYPE_IMMEDIATE: | |
| 1251 | curparam->value = test->param[pnum]; | |
| 1252 | break; | |
| 1253 | ||
| 1254 | /* register parameters: set the register value in the state and set the parameter value to the register index */ | |
| 1255 | case DRCUML_PTYPE_INT_REGISTER: | |
| 1256 | state->r[curparam->value].d = test->param[pnum]; | |
| 1257 | curparam->value += DRCUML_REG_I0; | |
| 1258 | break; | |
| 1259 | ||
| 1260 | /* register parameters: set the register value in the state and set the parameter value to the register index */ | |
| 1261 | case DRCUML_PTYPE_FLOAT_REGISTER: | |
| 1262 | state->f[curparam->value].d = test->param[pnum]; | |
| 1263 | curparam->value += DRCUML_REG_F0; | |
| 1264 | break; | |
| 1265 | ||
| 1266 | /* memory parameters: set the memory value in the parameter space and set the parameter value to point to it */ | |
| 1267 | case DRCUML_PTYPE_MEMORY: | |
| 1268 | curparam->value = (FPTR)¶mmem[pnum]; | |
| 1269 | if (psize == 4) | |
| 1270 | *(UINT32 *)(FPTR)curparam->value = test->param[pnum]; | |
| 1271 | else | |
| 1272 | *(UINT64 *)(FPTR)curparam->value = test->param[pnum]; | |
| 1273 | break; | |
| 1274 | ||
| 1275 | /* map variables: issue a MAPVAR instruction to set the value and set the parameter value to the mapvar index */ | |
| 1276 | case DRCUML_PTYPE_MAPVAR: | |
| 1277 | UML_MAPVAR(block, MVAR(curparam->value), test->param[pnum]); | |
| 1278 | curparam->value += DRCUML_MAPVAR_M0; | |
| 1279 | break; | |
| 1280 | ||
| 1281 | /* use anything else to count the number of parameters */ | |
| 1282 | default: | |
| 1283 | numparams = MIN(numparams, pnum); | |
| 1284 | break; | |
| 1285 | } | |
| 1286 | } | |
| 1287 | ||
| 1288 | /* return the total number of parameters */ | |
| 1289 | return numparams; | |
| 1290 | } | |
| 1291 | ||
| 1292 | ||
| 1293 | /*------------------------------------------------- | |
| 1294 | bevalidate_verify_state - verify the final | |
| 1295 | state after executing a test, and report any | |
| 1296 | discrepancies | |
| 1297 | -------------------------------------------------*/ | |
| 1298 | ||
| 1299 | static int bevalidate_verify_state(drcuml_state *drcuml, const drcuml_machine_state *istate, drcuml_machine_state *state, const bevalidate_test *test, const drcuml_parameter *params, const drcuml_instruction *testinst, drccodeptr codestart, drccodeptr codeend, UINT8 flagmask) | |
| 1300 | { | |
| 1301 | const drcuml_opcode_valid *opvalid = &opcode_valid_table[test->opcode]; | |
| 1302 | UINT8 ireg[DRCUML_REG_I_END - DRCUML_REG_I0] = { 0 }; | |
| 1303 | UINT8 freg[DRCUML_REG_F_END - DRCUML_REG_F0] = { 0 }; | |
| 1304 | char errorbuf[1024]; | |
| 1305 | char *errend = errorbuf; | |
| 1306 | int pnum, regnum; | |
| 1307 | ||
| 1308 | *errend = 0; | |
| 1309 | ||
| 1310 | /* check flags */ | |
| 1311 | if ((state->flags & flagmask) != (test->flags & flagmask)) | |
| 1312 | { | |
| 1313 | errend += sprintf(errend, " Flags ... result:%c%c%c%c%c expected:%c%c%c%c%c\n", | |
| 1314 | (flagmask & DRCUML_FLAG_U) ? ((state->flags & DRCUML_FLAG_U) ? 'U' : '.') : '-', | |
| 1315 | (flagmask & DRCUML_FLAG_S) ? ((state->flags & DRCUML_FLAG_S) ? 'S' : '.') : '-', | |
| 1316 | (flagmask & DRCUML_FLAG_Z) ? ((state->flags & DRCUML_FLAG_Z) ? 'Z' : '.') : '-', | |
| 1317 | (flagmask & DRCUML_FLAG_V) ? ((state->flags & DRCUML_FLAG_V) ? 'V' : '.') : '-', | |
| 1318 | (flagmask & DRCUML_FLAG_C) ? ((state->flags & DRCUML_FLAG_C) ? 'C' : '.') : '-', | |
| 1319 | (flagmask & DRCUML_FLAG_U) ? ((test->flags & DRCUML_FLAG_U) ? 'U' : '.') : '-', | |
| 1320 | (flagmask & DRCUML_FLAG_S) ? ((test->flags & DRCUML_FLAG_S) ? 'S' : '.') : '-', | |
| 1321 | (flagmask & DRCUML_FLAG_Z) ? ((test->flags & DRCUML_FLAG_Z) ? 'Z' : '.') : '-', | |
| 1322 | (flagmask & DRCUML_FLAG_V) ? ((test->flags & DRCUML_FLAG_V) ? 'V' : '.') : '-', | |
| 1323 | (flagmask & DRCUML_FLAG_C) ? ((test->flags & DRCUML_FLAG_C) ? 'C' : '.') : '-'); | |
| 1324 | } | |
| 1325 | ||
| 1326 | /* check destination parameters */ | |
| 1327 | for (pnum = 0; pnum < ARRAY_LENGTH(test->param); pnum++) | |
| 1328 | if (test->destmask & (1 << pnum)) | |
| 1329 | { | |
| 1330 | UINT64 mask = mask_for_param(test->size, opvalid->ptypes[pnum]); | |
| 1331 | int psize = size_for_param(test->size, opvalid->ptypes[pnum]); | |
| 1332 | UINT64 result = 0; | |
| 1333 | ||
| 1334 | /* fetch the result from the parameters */ | |
| 1335 | switch (params[pnum].type) | |
| 1336 | { | |
| 1337 | /* integer registers fetch from the state */ | |
| 1338 | case DRCUML_PTYPE_INT_REGISTER: | |
| 1339 | ireg[params[pnum].value - DRCUML_REG_I0] = 1; | |
| 1340 | result = state->r[params[pnum].value - DRCUML_REG_I0].d; | |
| 1341 | break; | |
| 1342 | ||
| 1343 | /* float registers fetch from the state */ | |
| 1344 | case DRCUML_PTYPE_FLOAT_REGISTER: | |
| 1345 | freg[params[pnum].value - DRCUML_REG_I0] = 1; | |
| 1346 | result = state->f[params[pnum].value - DRCUML_REG_F0].d; | |
| 1347 | break; | |
| 1348 | ||
| 1349 | /* memory registers fetch from the memory address */ | |
| 1350 | case DRCUML_PTYPE_MEMORY: | |
| 1351 | if (psize == 4) | |
| 1352 | result = *(UINT32 *)(FPTR)params[pnum].value; | |
| 1353 | else | |
| 1354 | result = *(UINT64 *)(FPTR)params[pnum].value; | |
| 1355 | break; | |
| 1356 | ||
| 1357 | default: | |
| 1358 | break; | |
| 1359 | } | |
| 1360 | ||
| 1361 | /* check against the mask */ | |
| 1362 | if ((result & mask) != (test->param[pnum] & mask)) | |
| 1363 | { | |
| 1364 | if ((UINT32)mask == mask) | |
| 1365 | errend += sprintf(errend, " Parameter %d ... result:%08X expected:%08X\n", pnum, | |
| 1366 | (UINT32)(result & mask), (UINT32)(test->param[pnum] & mask)); | |
| 1367 | else | |
| 1368 | errend += sprintf(errend, " Parameter %d ... result:%08X%08X expected:%08X%08X\n", pnum, | |
| 1369 | (UINT32)((result & mask) >> 32), (UINT32)(result & mask), | |
| 1370 | (UINT32)((test->param[pnum] & mask) >> 32), (UINT32)(test->param[pnum] & mask)); | |
| 1371 | } | |
| 1372 | } | |
| 1373 | ||
| 1374 | /* check source integer parameters for unexpected alterations */ | |
| 1375 | for (regnum = 0; regnum < ARRAY_LENGTH(state->r); regnum++) | |
| 1376 | if (ireg[regnum] == 0 && istate->r[regnum].d != state->r[regnum].d) | |
| 1377 | errend += sprintf(errend, " Register i%d ... result:%08X%08X originally:%08X%08X\n", regnum, | |
| 1378 | (UINT32)(state->r[regnum].d >> 32), (UINT32)state->r[regnum].d, | |
| 1379 | (UINT32)(istate->r[regnum].d >> 32), (UINT32)istate->r[regnum].d); | |
| 1380 | ||
| 1381 | /* check source float parameters for unexpected alterations */ | |
| 1382 | for (regnum = 0; regnum < ARRAY_LENGTH(state->f); regnum++) | |
| 1383 | if (freg[regnum] == 0 && *(UINT64 *)&istate->f[regnum].d != *(UINT64 *)&state->f[regnum].d) | |
| 1384 | errend += sprintf(errend, " Register f%d ... result:%08X%08X originally:%08X%08X\n", regnum, | |
| 1385 | (UINT32)(*(UINT64 *)&state->f[regnum].d >> 32), (UINT32)*(UINT64 *)&state->f[regnum].d, | |
| 1386 | (UINT32)(*(UINT64 *)&istate->f[regnum].d >> 32), (UINT32)*(UINT64 *)&istate->f[regnum].d); | |
| 1387 | ||
| 1388 | /* output the error if we have one */ | |
| 1389 | if (errend != errorbuf) | |
| 1390 | { | |
| 1391 | char disasm[100]; | |
| 1392 | ||
| 1393 | /* disassemble the test instruction */ | |
| 1394 | drcuml_disasm(testinst, disasm); | |
| 1395 | ||
| 1396 | /* output a description of what went wrong */ | |
| 1397 | printf("\n"); | |
| 1398 | printf("----------------------------------------------\n"); | |
| 1399 | printf("Backend validation error:\n"); | |
| 1400 | printf(" %s\n", disasm); | |
| 1401 | printf("\n"); | |
| 1402 | printf("Errors:\n"); | |
| 1403 | printf("%s\n", errorbuf); | |
| 1404 | fatalerror("Error during validation"); | |
| 1405 | } | |
| 1406 | return errend != errorbuf; | |
| 1407 | } |
| r2724 | r2725 | |
|---|---|---|
| 76 | 76 | /* execution semantics */ |
| 77 | 77 | #define OPFLAG_READS_MEMORY 0x00080000 /* instruction reads memory */ |
| 78 | 78 | #define OPFLAG_WRITES_MEMORY 0x00100000 /* instruction writes memory */ |
| 79 | #define OPFLAG_VARIABLE_SHIFT 0x00200000 /* instruction performs a variable count shift */ | |
| 80 | #define OPFLAG_MULTIPLY_DIVIDE 0x00400000 /* instruction performs a multiply/divide */ | |
| 81 | 79 | |
| 82 | 80 | |
| 83 | 81 |
| r2724 | r2725 | |
|---|---|---|
| 176 | 176 | DRCUML_OP_SETFMOD, /* SETFMOD src */ |
| 177 | 177 | DRCUML_OP_GETFMOD, /* GETFMOD dst */ |
| 178 | 178 | DRCUML_OP_GETEXP, /* GETEXP dst,index */ |
| 179 | DRCUML_OP_SAVE, /* SAVE mem */ | |
| 180 | DRCUML_OP_RESTORE, /* RESTORE mem */ | |
| 179 | 181 | |
| 180 | 182 | /* Integer Operations */ |
| 181 | 183 | DRCUML_OP_LOAD1U, /* LOAD1U dst,base,index */ |
| r2724 | r2725 | |
| 214 | 216 | DRCUML_OP_SEXT1, /* SEXT1 dst,src */ |
| 215 | 217 | DRCUML_OP_SEXT2, /* SEXT2 dst,src */ |
| 216 | 218 | DRCUML_OP_SEXT4, /* SEXT4 dst,src */ |
| 219 | DRCUML_OP_XTRACT, /* XTRACT dst,src,shift,mask */ | |
| 220 | DRCUML_OP_INSERT, /* INSERT dst,src,shift,mask */ | |
| 217 | 221 | DRCUML_OP_ADD, /* ADD dst,src1,src2[,f] */ |
| 218 | 222 | DRCUML_OP_ADDC, /* ADDC dst,src1,src2[,f] */ |
| 219 | 223 | DRCUML_OP_SUB, /* SUB dst,src1,src2[,f] */ |
| r2724 | r2725 | |
| 227 | 231 | DRCUML_OP_TEST, /* TEST src1,src2[,f] */ |
| 228 | 232 | DRCUML_OP_OR, /* OR dst,src1,src2[,f] */ |
| 229 | 233 | DRCUML_OP_XOR, /* XOR dst,src1,src2[,f] */ |
| 234 | DRCUML_OP_LZCNT, /* LZCNT dst,src */ | |
| 230 | 235 | DRCUML_OP_SHL, /* SHL dst,src,count[,f] */ |
| 231 | 236 | DRCUML_OP_SHR, /* SHR dst,src,count[,f] */ |
| 232 | 237 | DRCUML_OP_SAR, /* SAR dst,src,count[,f] */ |
| r2724 | r2725 | |
| 317 | 322 | }; |
| 318 | 323 | |
| 319 | 324 | |
| 325 | /* an integer register, with low/high parts */ | |
| 326 | typedef union _drcuml_ireg drcuml_ireg; | |
| 327 | union _drcuml_ireg | |
| 328 | { | |
| 329 | #ifdef LSB_FIRST | |
| 330 | struct { UINT32 l,h; } w; /* 32-bit low, high parts of the register */ | |
| 331 | #else | |
| 332 | struct { UINT32 h,l; } w; /* 32-bit low, high parts of the register */ | |
| 333 | #endif | |
| 334 | UINT64 d; /* 64-bit full register */ | |
| 335 | }; | |
| 336 | ||
| 337 | ||
| 338 | /* a floating-point register, with low/high parts */ | |
| 339 | typedef union _drcuml_freg drcuml_freg; | |
| 340 | union _drcuml_freg | |
| 341 | { | |
| 342 | #ifdef LSB_FIRST | |
| 343 | struct { float l,h; } s; /* 32-bit low, high parts of the register */ | |
| 344 | #else | |
| 345 | struct { float h,l; } s; /* 32-bit low, high parts of the register */ | |
| 346 | #endif | |
| 347 | double d; /* 64-bit full register */ | |
| 348 | }; | |
| 349 | ||
| 350 | ||
| 351 | /* the collected machine state of a system */ | |
| 352 | typedef struct _drcuml_machine_state drcuml_machine_state; | |
| 353 | struct _drcuml_machine_state | |
| 354 | { | |
| 355 | drcuml_ireg r[DRCUML_REG_I_END - DRCUML_REG_I0]; /* integer registers */ | |
| 356 | drcuml_freg f[DRCUML_REG_F_END - DRCUML_REG_F0]; /* floating-point registers */ | |
| 357 | UINT32 exp; /* exception parameter register */ | |
| 358 | UINT8 fmod; /* fmod (floating-point mode) register */ | |
| 359 | UINT8 flags; /* flags state */ | |
| 360 | }; | |
| 361 | ||
| 362 | ||
| 363 | /* hints and information about the back-end */ | |
| 364 | typedef struct _drcbe_info drcbe_info; | |
| 365 | struct _drcbe_info | |
| 366 | { | |
| 367 | UINT8 direct_iregs; /* number of direct-mapped integer registers */ | |
| 368 | UINT8 direct_fregs; /* number of direct-mapped floating point registers */ | |
| 369 | }; | |
| 370 | ||
| 371 | ||
| 320 | 372 | /* typedefs for back-end callback functions */ |
| 321 | 373 | typedef drcbe_state *(*drcbe_alloc_func)(drcuml_state *drcuml, drccache *cache, UINT32 flags, int modes, int addrbits, int ignorebits); |
| 322 | 374 | typedef void (*drcbe_free_func)(drcbe_state *state); |
| r2724 | r2725 | |
| 324 | 376 | typedef int (*drcbe_execute_func)(drcbe_state *state, drcuml_codehandle *entry); |
| 325 | 377 | typedef void (*drcbe_generate_func)(drcbe_state *state, drcuml_block *block, const drcuml_instruction *instlist, UINT32 numinst); |
| 326 | 378 | typedef int (*drcbe_hash_exists)(drcbe_state *state, UINT32 mode, UINT32 pc); |
| 379 | typedef void (*drcbe_get_info)(drcbe_state *state, drcbe_info *info); | |
| 327 | 380 | |
| 328 | 381 | |
| 329 | 382 | /* interface structure for a back-end */ |
| r2724 | r2725 | |
| 336 | 389 | drcbe_execute_func be_execute; |
| 337 | 390 | drcbe_generate_func be_generate; |
| 338 | 391 | drcbe_hash_exists be_hash_exists; |
| 392 | drcbe_get_info be_get_info; | |
| 339 | 393 | }; |
| 340 | 394 | |
| 341 | 395 | |
| r2724 | r2725 | |
| 349 | 403 | /* allocate state for the code generator and initialize the back-end */ |
| 350 | 404 | drcuml_state *drcuml_alloc(drccache *cache, UINT32 flags, int modes, int addrbits, int ignorebits); |
| 351 | 405 | |
| 406 | /* return information about the back-end */ | |
| 407 | void drcuml_get_backend_info(drcuml_state *drcuml, drcbe_info *info); | |
| 408 | ||
| 352 | 409 | /* reset the state completely, flushing the cache and all information */ |
| 353 | 410 | void drcuml_reset(drcuml_state *drcuml); |
| 354 | 411 |
| r2724 | r2725 | |
|---|---|---|
| 168 | 168 | #include "drcbeut.h" |
| 169 | 169 | #include "debugger.h" |
| 170 | 170 | #include "x86emit.h" |
| 171 | #include "eminline.h" | |
| 171 | 172 | #undef REG_SP |
| 172 | 173 | #include "x86log.h" |
| 173 | 174 | #include <math.h> |
| 175 | #include <stddef.h> | |
| 174 | 176 | |
| 175 | 177 | |
| 176 | 178 | |
| r2724 | r2725 | |
| 265 | 267 | x86code * drcmap_get_value; /* map lookup helper */ |
| 266 | 268 | data_accessors accessors[ADDRESS_SPACES];/* memory accessors */ |
| 267 | 269 | |
| 270 | UINT8 sse41; /* do we have SSE4.1 support? */ | |
| 268 | 271 | UINT32 ssemode; /* saved SSE mode */ |
| 269 | 272 | UINT32 ssemodesave; /* temporary location for saving */ |
| 270 | 273 | UINT32 ssecontrol[4]; /* copy of the sse_control array */ |
| r2724 | r2725 | |
| 276 | 279 | |
| 277 | 280 | UINT8 * rbpvalue; /* value of RBP */ |
| 278 | 281 | UINT8 flagsmap[0x1000]; /* flags map */ |
| 282 | UINT64 flagsunmap[0x20]; /* flags unmapper */ | |
| 279 | 283 | |
| 280 | 284 | x86log_context * log; /* logging */ |
| 281 | 285 | }; |
| r2724 | r2725 | |
| 293 | 297 | static int drcbex64_execute(drcbe_state *drcbe, drcuml_codehandle *entry); |
| 294 | 298 | static void drcbex64_generate(drcbe_state *drcbe, drcuml_block *block, const drcuml_instruction *instlist, UINT32 numinst); |
| 295 | 299 | static int drcbex64_hash_exists(drcbe_state *drcbe, UINT32 mode, UINT32 pc); |
| 300 | static void drcbex64_get_info(drcbe_state *state, drcbe_info *info); | |
| 296 | 301 | |
| 297 | 302 | /* private helper functions */ |
| 298 | 303 | static void fixup_label(void *parameter, drccodeptr labelcodeptr); |
| r2724 | r2725 | |
| 311 | 316 | drcbex64_reset, |
| 312 | 317 | drcbex64_execute, |
| 313 | 318 | drcbex64_generate, |
| 314 | drcbex64_hash_exists | |
| 319 | drcbex64_hash_exists, | |
| 320 | drcbex64_get_info | |
| 315 | 321 | }; |
| 316 | 322 | |
| 317 | 323 | /* opcode table */ |
| r2724 | r2725 | |
| 356 | 362 | COND_GE, /* DRCUML_COND_GE, requires SV */ |
| 357 | 363 | }; |
| 358 | 364 | |
| 365 | /* rounding mode mapping table */ | |
| 366 | static const UINT8 fprnd_map[4] = | |
| 367 | { | |
| 368 | FPRND_CHOP, /* DRCUML_FMOD_TRUNC, truncate */ | |
| 369 | FPRND_NEAR, /* DRCUML_FMOD_ROUND, round */ | |
| 370 | FPRND_UP, /* DRCUML_FMOD_CEIL, round up */ | |
| 371 | FPRND_DOWN /* DRCUML_FMOD_FLOOR round down */ | |
| 372 | }; | |
| 359 | 373 | |
| 360 | 374 | |
| 375 | ||
| 361 | 376 | /*************************************************************************** |
| 362 | 377 | TABLES |
| 363 | 378 | ***************************************************************************/ |
| r2724 | r2725 | |
| 381 | 396 | static x86code *op_setfmod(drcbe_state *drcbe, x86code *dst, const drcuml_instruction *inst); |
| 382 | 397 | static x86code *op_getfmod(drcbe_state *drcbe, x86code *dst, const drcuml_instruction *inst); |
| 383 | 398 | static x86code *op_getexp(drcbe_state *drcbe, x86code *dst, const drcuml_instruction *inst); |
| 399 | static x86code *op_save(drcbe_state *drcbe, x86code *dst, const drcuml_instruction *inst); | |
| 400 | static x86code *op_restore(drcbe_state *drcbe, x86code *dst, const drcuml_instruction *inst); | |
| 384 | 401 | |
| 385 | 402 | static x86code *op_load1u(drcbe_state *drcbe, x86code *dst, const drcuml_instruction *inst); |
| 386 | 403 | static x86code *op_load1s(drcbe_state *drcbe, x86code *dst, const drcuml_instruction *inst); |
| r2724 | r2725 | |
| 418 | 435 | static x86code *op_sext1(drcbe_state *drcbe, x86code *dst, const drcuml_instruction *inst); |
| 419 | 436 | static x86code *op_sext2(drcbe_state *drcbe, x86code *dst, const drcuml_instruction *inst); |
| 420 | 437 | static x86code *op_sext4(drcbe_state *drcbe, x86code *dst, const drcuml_instruction *inst); |
| 438 | static x86code *op_xtract(drcbe_state *drcbe, x86code *dst, const drcuml_instruction *inst); | |
| 439 | static x86code *op_insert(drcbe_state *drcbe, x86code *dst, const drcuml_instruction *inst); | |
| 421 | 440 | static x86code *op_add(drcbe_state *drcbe, x86code *dst, const drcuml_instruction *inst); |
| 422 | 441 | static x86code *op_addc(drcbe_state *drcbe, x86code *dst, const drcuml_instruction *inst); |
| 423 | 442 | static x86code *op_sub(drcbe_state *drcbe, x86code *dst, const drcuml_instruction *inst); |
| r2724 | r2725 | |
| 431 | 450 | static x86code *op_test(drcbe_state *drcbe, x86code *dst, const drcuml_instruction *inst); |
| 432 | 451 | static x86code *op_or(drcbe_state *drcbe, x86code *dst, const drcuml_instruction *inst); |
| 433 | 452 | static x86code *op_xor(drcbe_state *drcbe, x86code *dst, const drcuml_instruction *inst); |
| 453 | static x86code *op_lzcnt(drcbe_state *drcbe, x86code *dst, const drcuml_instruction *inst); | |
| 434 | 454 | static x86code *op_shl(drcbe_state *drcbe, x86code *dst, const drcuml_instruction *inst); |
| 435 | 455 | static x86code *op_shr(drcbe_state *drcbe, x86code *dst, const drcuml_instruction *inst); |
| 436 | 456 | static x86code *op_sar(drcbe_state *drcbe, x86code *dst, const drcuml_instruction *inst); |
| r2724 | r2725 | |
| 493 | 513 | { DRCUML_OP_SETFMOD, op_setfmod }, /* SETFMOD src */ |
| 494 | 514 | { DRCUML_OP_GETFMOD, op_getfmod }, /* GETFMOD dst */ |
| 495 | 515 | { DRCUML_OP_GETEXP, op_getexp }, /* GETEXP dst,index */ |
| 516 | { DRCUML_OP_SAVE, op_save }, /* SAVE dst,index */ | |
| 517 | { DRCUML_OP_RESTORE, op_restore }, /* RESTORE dst,index */ | |
| 496 | 518 | |
| 497 | 519 | /* Integer Operations */ |
| 498 | 520 | { DRCUML_OP_LOAD1U, op_load1u }, /* LOAD1U dst,base,index */ |
| r2724 | r2725 | |
| 531 | 553 | { DRCUML_OP_SEXT1, op_sext1 }, /* SEXT1 dst,src */ |
| 532 | 554 | { DRCUML_OP_SEXT2, op_sext2 }, /* SEXT2 dst,src */ |
| 533 | 555 | { DRCUML_OP_SEXT4, op_sext4 }, /* SEXT4 dst,src */ |
| 556 | { DRCUML_OP_XTRACT, op_xtract }, /* XTRACT dst,src1,src2,src3 */ | |
| 557 | { DRCUML_OP_INSERT, op_insert }, /* INSERT dst,src1,src2,src3 */ | |
| 534 | 558 | { DRCUML_OP_ADD, op_add }, /* ADD dst,src1,src2[,f] */ |
| 535 | 559 | { DRCUML_OP_ADDC, op_addc }, /* ADDC dst,src1,src2[,f] */ |
| 536 | 560 | { DRCUML_OP_SUB, op_sub }, /* SUB dst,src1,src2[,f] */ |
| r2724 | r2725 | |
| 544 | 568 | { DRCUML_OP_TEST, op_test }, /* TEST src1,src2[,f] */ |
| 545 | 569 | { DRCUML_OP_OR, op_or }, /* OR dst,src1,src2[,f] */ |
| 546 | 570 | { DRCUML_OP_XOR, op_xor }, /* XOR dst,src1,src2[,f] */ |
| 571 | { DRCUML_OP_LZCNT, op_lzcnt }, /* LZCNT dst,src[,f] */ | |
| 547 | 572 | { DRCUML_OP_SHL, op_shl }, /* SHL dst,src,count[,f] */ |
| 548 | 573 | { DRCUML_OP_SHR, op_shr }, /* SHR dst,src,count[,f] */ |
| 549 | 574 | { DRCUML_OP_SAR, op_sar }, /* SAR dst,src,count[,f] */ |
| r2724 | r2725 | |
| 605 | 630 | |
| 606 | 631 | |
| 607 | 632 | /*------------------------------------------------- |
| 633 | param_select_register2 - select a register | |
| 634 | to use, avoiding conflicts with the optional | |
| 635 | checkparam | |
| 636 | -------------------------------------------------*/ | |
| 637 | ||
| 638 | INLINE int param_select_register2(int defreg, const drcuml_parameter *param, const drcuml_parameter *checkparam1, const drcuml_parameter *checkparam2) | |
| 639 | { | |
| 640 | if (param->type == DRCUML_PTYPE_INT_REGISTER && (param->type != checkparam1->type || param->value != checkparam1->value) && (param->type != checkparam2->type || param->value != checkparam2->value)) | |
| 641 | return param->value; | |
| 642 | return defreg; | |
| 643 | } | |
| 644 | ||
| 645 | ||
| 646 | /*------------------------------------------------- | |
| 608 | 647 | offset_from_rbp - return the verified offset |
| 609 | 648 | from rbp |
| 610 | 649 | -------------------------------------------------*/ |
| r2724 | r2725 | |
| 765 | 804 | if (entry & 0x800) flags |= DRCUML_FLAG_V; |
| 766 | 805 | drcbe->flagsmap[entry] = flags; |
| 767 | 806 | } |
| 807 | for (entry = 0; entry < ARRAY_LENGTH(drcbe->flagsunmap); entry++) | |
| 808 | { | |
| 809 | UINT64 flags = 0; | |
| 810 | if (entry & DRCUML_FLAG_C) flags |= 0x001; | |
| 811 | if (entry & DRCUML_FLAG_U) flags |= 0x004; | |
| 812 | if (entry & DRCUML_FLAG_Z) flags |= 0x040; | |
| 813 | if (entry & DRCUML_FLAG_S) flags |= 0x080; | |
| 814 | if (entry & DRCUML_FLAG_V) flags |= 0x800; | |
| 815 | drcbe->flagsunmap[entry] = flags; | |
| 816 | } | |
| 768 | 817 | |
| 769 | 818 | /* create the log */ |
| 770 | 819 | if (flags & DRCUML_OPTION_LOG_NATIVE) |
| r2724 | r2725 | |
| 792 | 841 | |
| 793 | 842 | static void drcbex64_reset(drcbe_state *drcbe) |
| 794 | 843 | { |
| 844 | UINT32 (*cpuid_ecx_stub)(void); | |
| 795 | 845 | x86code **dst; |
| 796 | 846 | int spacenum; |
| 797 | 847 | |
| r2724 | r2725 | |
| 809 | 859 | if (dst == NULL) |
| 810 | 860 | fatalerror("Out of cache space after a reset!"); |
| 811 | 861 | |
| 862 | /* generate a simple CPUID stub */ | |
| 863 | cpuid_ecx_stub = (UINT32 (*)(void))*dst; | |
| 864 | emit_push_r64(dst, REG_RBX); // push rbx | |
| 865 | emit_mov_r32_imm(dst, REG_EAX, 1); // mov eax,1 | |
| 866 | emit_cpuid(dst); // cpuid | |
| 867 | emit_mov_r32_r32(dst, REG_EAX, REG_ECX); // mov eax,ecx | |
| 868 | emit_pop_r64(dst, REG_RBX); // pop rbx | |
| 869 | emit_ret(dst); // ret | |
| 870 | ||
| 871 | /* call it to determine if we have SSE4.1 support */ | |
| 872 | drcbe->sse41 = (((*cpuid_ecx_stub)() & 0x80000) != 0); | |
| 873 | ||
| 812 | 874 | /* generate an entry point */ |
| 813 | 875 | drcbe->entry = (x86_entry_point_func)*dst; |
| 814 | 876 | emit_push_r64(dst, REG_RBX); // push rbx |
| r2724 | r2725 | |
| 862 | 924 | |
| 863 | 925 | |
| 864 | 926 | /*------------------------------------------------- |
| 927 | drcbex64_execute - execute a block of code | |
| 928 | referenced by the given handle | |
| 929 | -------------------------------------------------*/ | |
| 930 | ||
| 931 | static int drcbex64_execute(drcbe_state *drcbe, drcuml_codehandle *entry) | |
| 932 | { | |
| 933 | /* call our entry point which will jump to the destination */ | |
| 934 | return (*drcbe->entry)(drcbe->rbpvalue, (x86code *)drcuml_handle_codeptr(entry)); | |
| 935 | } | |
| 936 | ||
| 937 | ||
| 938 | /*------------------------------------------------- | |
| 865 | 939 | drcbex64_generate - generate code |
| 866 | 940 | -------------------------------------------------*/ |
| 867 | 941 | |
| r2724 | r2725 | |
| 945 | 1019 | |
| 946 | 1020 | |
| 947 | 1021 | /*------------------------------------------------- |
| 948 | drcbec_execute - execute a block of code | |
| 949 | registered at the given mode/pc | |
| 1022 | drcbex64_get_info - return information about | |
| 1023 | the back-end implementation | |
| 950 | 1024 | -------------------------------------------------*/ |
| 951 | 1025 | |
| 952 | static i | |
| 1026 | static void | |
| 953 | 1027 | { |
| 954 | /* call our entry point which will jump to the destination */ | |
| 955 | return (*drcbe->entry)(drcbe->rbpvalue, (x86code *)drcuml_handle_codeptr(entry)); | |
| 1028 | for (info->direct_iregs = 0; info->direct_iregs < DRCUML_REG_I_END - DRCUML_REG_I0; info->direct_iregs++) | |
| 1029 | if (int_register_map[info->direct_iregs] == 0) | |
| 1030 | break; | |
| 1031 | for (info->direct_fregs = 0; info->direct_fregs < DRCUML_REG_F_END - DRCUML_REG_F0; info->direct_fregs++) | |
| 1032 | if (float_register_map[info->direct_fregs] == 0) | |
| 1033 | break; | |
| 956 | 1034 | } |
| 957 | 1035 | |
| 958 | 1036 | |
| r2724 | r2725 | |
| 1461 | 1539 | { |
| 1462 | 1540 | if (param->type == DRCUML_PTYPE_IMMEDIATE) |
| 1463 | 1541 | { |
| 1464 | if (inst->condflags | |
| 1542 | if (inst->condflags == 0 && (UINT32)param->value == 0xffffffff) | |
| 1465 | 1543 | /* skip */; |
| 1466 | 1544 | else if (inst->condflags != 0 && (UINT32)param->value == 0) |
| 1467 | 1545 | emit_xor_r32_r32(dst, reg, reg); // xor reg,reg |
| r2724 | r2725 | |
| 1484 | 1562 | { |
| 1485 | 1563 | if (param->type == DRCUML_PTYPE_IMMEDIATE) |
| 1486 | 1564 | { |
| 1487 | if (inst->condflags | |
| 1565 | if (inst->condflags == 0 && (UINT32)param->value == 0xffffffff) | |
| 1488 | 1566 | /* skip */; |
| 1489 | 1567 | else if (inst->condflags != 0 && (UINT32)param->value == 0) |
| 1490 | 1568 | emit_mov_m32_imm(dst, MEMPARAMS, 0); // mov [dest],0 |
| r2724 | r2725 | |
| 1544 | 1622 | { |
| 1545 | 1623 | if (param->type == DRCUML_PTYPE_IMMEDIATE) |
| 1546 | 1624 | { |
| 1547 | if (inst->condflags | |
| 1625 | if (inst->condflags == 0 && (UINT32)param->value == 0) | |
| 1548 | 1626 | /* skip */; |
| 1549 | 1627 | else if (inst->condflags != 0 && (UINT32)param->value == 0xffffffff) |
| 1550 | 1628 | emit_mov_r32_imm(dst, reg, -1); // mov reg,-1 |
| r2724 | r2725 | |
| 1567 | 1645 | { |
| 1568 | 1646 | if (param->type == DRCUML_PTYPE_IMMEDIATE) |
| 1569 | 1647 | { |
| 1570 | if (inst->condflags | |
| 1648 | if (inst->condflags == 0 && (UINT32)param->value == 0) | |
| 1571 | 1649 | /* skip */; |
| 1572 | 1650 | else if (inst->condflags != 0 && (UINT32)param->value == 0xffffffff) |
| 1573 | 1651 | emit_mov_m32_imm(dst, MEMPARAMS, -1); // mov [dest],-1 |
| r2724 | r2725 | |
| 1592 | 1670 | { |
| 1593 | 1671 | if (param->type == DRCUML_PTYPE_IMMEDIATE) |
| 1594 | 1672 | { |
| 1595 | if (inst->condflags | |
| 1673 | if (inst->condflags == 0 && (UINT32)param->value == 0) | |
| 1596 | 1674 | /* skip */; |
| 1597 | 1675 | else if (inst->condflags != 0 && (UINT32)param->value == 0xffffffff) |
| 1598 | 1676 | emit_not_r32(dst, reg); // not reg |
| r2724 | r2725 | |
| 1615 | 1693 | { |
| 1616 | 1694 | if (param->type == DRCUML_PTYPE_IMMEDIATE) |
| 1617 | 1695 | { |
| 1618 | if (inst->condflags | |
| 1696 | if (inst->condflags == 0 && (UINT32)param->value == 0) | |
| 1619 | 1697 | /* skip */; |
| 1620 | 1698 | else if (inst->condflags != 0 && (UINT32)param->value == 0xffffffff) |
| 1621 | 1699 | emit_not_m32(dst, MEMPARAMS); // not [dest] |
| r2724 | r2725 | |
| 1640 | 1718 | { |
| 1641 | 1719 | if (param->type == DRCUML_PTYPE_IMMEDIATE) |
| 1642 | 1720 | { |
| 1643 | if (inst->condflags | |
| 1721 | if (inst->condflags == 0 && (UINT32)param->value == 0) | |
| 1644 | 1722 | /* skip */; |
| 1645 | 1723 | else |
| 1646 | 1724 | emit_shl_r32_imm(dst, reg, param->value); // shl reg,param |
| r2724 | r2725 | |
| 1662 | 1740 | { |
| 1663 | 1741 | if (param->type == DRCUML_PTYPE_IMMEDIATE) |
| 1664 | 1742 | { |
| 1665 | if (inst->condflags | |
| 1743 | if (inst->condflags == 0 && (UINT32)param->value == 0) | |
| 1666 | 1744 | /* skip */; |
| 1667 | 1745 | else |
| 1668 | 1746 | emit_shl_m32_imm(dst, MEMPARAMS, param->value); // shl [dest],param |
| r2724 | r2725 | |
| 1684 | 1762 | { |
| 1685 | 1763 | if (param->type == DRCUML_PTYPE_IMMEDIATE) |
| 1686 | 1764 | { |
| 1687 | if (inst->condflags | |
| 1765 | if (inst->condflags == 0 && (UINT32)param->value == 0) | |
| 1688 | 1766 | /* skip */; |
| 1689 | 1767 | else |
| 1690 | 1768 | emit_shr_r32_imm(dst, reg, param->value); // shr reg,param |
| r2724 | r2725 | |
| 1706 | 1784 | { |
| 1707 | 1785 | if (param->type == DRCUML_PTYPE_IMMEDIATE) |
| 1708 | 1786 | { |
| 1709 | if (inst->condflags | |
| 1787 | if (inst->condflags == 0 && (UINT32)param->value == 0) | |
| 1710 | 1788 | /* skip */; |
| 1711 | 1789 | else |
| 1712 | 1790 | emit_shr_m32_imm(dst, MEMPARAMS, param->value); // shr [dest],param |
| r2724 | r2725 | |
| 1728 | 1806 | { |
| 1729 | 1807 | if (param->type == DRCUML_PTYPE_IMMEDIATE) |
| 1730 | 1808 | { |
| 1731 | if (inst->condflags | |
| 1809 | if (inst->condflags == 0 && (UINT32)param->value == 0) | |
| 1732 | 1810 | /* skip */; |
| 1733 | 1811 | else |
| 1734 | 1812 | emit_sar_r32_imm(dst, reg, param->value); // sar reg,param |
| r2724 | r2725 | |
| 1750 | 1828 | { |
| 1751 | 1829 | if (param->type == DRCUML_PTYPE_IMMEDIATE) |
| 1752 | 1830 | { |
| 1753 | if (inst->condflags | |
| 1831 | if (inst->condflags == 0 && (UINT32)param->value == 0) | |
| 1754 | 1832 | /* skip */; |
| 1755 | 1833 | else |
| 1756 | 1834 | emit_sar_m32_imm(dst, MEMPARAMS, param->value); // sar [dest],param |
| r2724 | r2725 | |
| 1772 | 1850 | { |
| 1773 | 1851 | if (param->type == DRCUML_PTYPE_IMMEDIATE) |
| 1774 | 1852 | { |
| 1775 | if (inst->condflags | |
| 1853 | if (inst->condflags == 0 && (UINT32)param->value == 0) | |
| 1776 | 1854 | /* skip */; |
| 1777 | 1855 | else |
| 1778 | 1856 | emit_rol_r32_imm(dst, reg, param->value); // rol reg,param |
| r2724 | r2725 | |
| 1794 | 1872 | { |
| 1795 | 1873 | if (param->type == DRCUML_PTYPE_IMMEDIATE) |
| 1796 | 1874 | { |
| 1797 | if (inst->condflags | |
| 1875 | if (inst->condflags == 0 && (UINT32)param->value == 0) | |
| 1798 | 1876 | /* skip */; |
| 1799 | 1877 | else |
| 1800 | 1878 | emit_rol_m32_imm(dst, MEMPARAMS, param->value); // rol [dest],param |
| r2724 | r2725 | |
| 1816 | 1894 | { |
| 1817 | 1895 | if (param->type == DRCUML_PTYPE_IMMEDIATE) |
| 1818 | 1896 | { |
| 1819 | if (inst->condflags | |
| 1897 | if (inst->condflags == 0 && (UINT32)param->value == 0) | |
| 1820 | 1898 | /* skip */; |
| 1821 | 1899 | else |
| 1822 | 1900 | emit_ror_r32_imm(dst, reg, param->value); // ror reg,param |
| r2724 | r2725 | |
| 1838 | 1916 | { |
| 1839 | 1917 | if (param->type == DRCUML_PTYPE_IMMEDIATE) |
| 1840 | 1918 | { |
| 1841 | if (inst->condflags | |
| 1919 | if (inst->condflags == 0 && (UINT32)param->value == 0) | |
| 1842 | 1920 | /* skip */; |
| 1843 | 1921 | else |
| 1844 | 1922 | emit_ror_m32_imm(dst, MEMPARAMS, param->value); // ror [dest],param |
| r2724 | r2725 | |
| 1860 | 1938 | { |
| 1861 | 1939 | if (param->type == DRCUML_PTYPE_IMMEDIATE) |
| 1862 | 1940 | { |
| 1863 | if (inst->condflags | |
| 1941 | if (inst->condflags == 0 && (UINT32)param->value == 0) | |
| 1864 | 1942 | /* skip */; |
| 1865 | 1943 | else |
| 1866 | 1944 | emit_rcl_r32_imm(dst, reg, param->value); // rcl reg,param |
| r2724 | r2725 | |
| 1882 | 1960 | { |
| 1883 | 1961 | if (param->type == DRCUML_PTYPE_IMMEDIATE) |
| 1884 | 1962 | { |
| 1885 | if (inst->condflags | |
| 1963 | if (inst->condflags == 0 && (UINT32)param->value == 0) | |
| 1886 | 1964 | /* skip */; |
| 1887 | 1965 | else |
| 1888 | 1966 | emit_rcl_m32_imm(dst, MEMPARAMS, param->value); // rcl [dest],param |
| r2724 | r2725 | |
| 1904 | 1982 | { |
| 1905 | 1983 | if (param->type == DRCUML_PTYPE_IMMEDIATE) |
| 1906 | 1984 | { |
| 1907 | if (inst->condflags | |
| 1985 | if (inst->condflags == 0 && (UINT32)param->value == 0) | |
| 1908 | 1986 | /* skip */; |
| 1909 | 1987 | else |
| 1910 | 1988 | emit_rcr_r32_imm(dst, reg, param->value); // rcr reg,param |
| r2724 | r2725 | |
| 1926 | 2004 | { |
| 1927 | 2005 | if (param->type == DRCUML_PTYPE_IMMEDIATE) |
| 1928 | 2006 | { |
| 1929 | if (inst->condflags | |
| 2007 | if (inst->condflags == 0 && (UINT32)param->value == 0) | |
| 1930 | 2008 | /* skip */; |
| 1931 | 2009 | else |
| 1932 | 2010 | emit_rcr_m32_imm(dst, MEMPARAMS, param->value); // rcr [dest],param |
| r2724 | r2725 | |
| 2448 | 2526 | { |
| 2449 | 2527 | if (param->type == DRCUML_PTYPE_IMMEDIATE) |
| 2450 | 2528 | { |
| 2451 | if (inst->condflags | |
| 2529 | if (inst->condflags == 0 && (UINT32)param->value == 0) | |
| 2452 | 2530 | /* skip */; |
| 2453 | 2531 | else |
| 2454 | 2532 | emit_shl_r64_imm(dst, reg, param->value); // shl reg,param |
| r2724 | r2725 | |
| 2470 | 2548 | { |
| 2471 | 2549 | if (param->type == DRCUML_PTYPE_IMMEDIATE) |
| 2472 | 2550 | { |
| 2473 | if (inst->condflags | |
| 2551 | if (inst->condflags == 0 && (UINT64)param->value == 0) | |
| 2474 | 2552 | /* skip */; |
| 2475 | 2553 | else |
| 2476 | 2554 | emit_shl_m64_imm(dst, MEMPARAMS, param->value); // shl [dest],param |
| r2724 | r2725 | |
| 2492 | 2570 | { |
| 2493 | 2571 | if (param->type == DRCUML_PTYPE_IMMEDIATE) |
| 2494 | 2572 | { |
| 2495 | if (inst->condflags | |
| 2573 | if (inst->condflags == 0 && (UINT32)param->value == 0) | |
| 2496 | 2574 | /* skip */; |
| 2497 | 2575 | else |
| 2498 | 2576 | emit_shr_r64_imm(dst, reg, param->value); // shr reg,param |
| r2724 | r2725 | |
| 2514 | 2592 | { |
| 2515 | 2593 | if (param->type == DRCUML_PTYPE_IMMEDIATE) |
| 2516 | 2594 | { |
| 2517 | if (inst->condflags | |
| 2595 | if (inst->condflags == 0 && (UINT64)param->value == 0) | |
| 2518 | 2596 | /* skip */; |
| 2519 | 2597 | else |
| 2520 | 2598 | emit_shr_m64_imm(dst, MEMPARAMS, param->value); // shr [dest],param |
| r2724 | r2725 | |
| 2536 | 2614 | { |
| 2537 | 2615 | if (param->type == DRCUML_PTYPE_IMMEDIATE) |
| 2538 | 2616 | { |
| 2539 | if (inst->condflags | |
| 2617 | if (inst->condflags == 0 && (UINT32)param->value == 0) | |
| 2540 | 2618 | /* skip */; |
| 2541 | 2619 | else |
| 2542 | 2620 | emit_sar_r64_imm(dst, reg, param->value); // sar reg,param |
| r2724 | r2725 | |
| 2558 | 2636 | { |
| 2559 | 2637 | if (param->type == DRCUML_PTYPE_IMMEDIATE) |
| 2560 | 2638 | { |
| 2561 | if (inst->condflags | |
| 2639 | if (inst->condflags == 0 && (UINT64)param->value == 0) | |
| 2562 | 2640 | /* skip */; |
| 2563 | 2641 | else |
| 2564 | 2642 | emit_sar_m64_imm(dst, MEMPARAMS, param->value); // sar [dest],param |
| r2724 | r2725 | |
| 2580 | 2658 | { |
| 2581 | 2659 | if (param->type == DRCUML_PTYPE_IMMEDIATE) |
| 2582 | 2660 | { |
| 2583 | if (inst->condflags | |
| 2661 | if (inst->condflags == 0 && (UINT32)param->value == 0) | |
| 2584 | 2662 | /* skip */; |
| 2585 | 2663 | else |
| 2586 | 2664 | emit_rol_r64_imm(dst, reg, param->value); // rol reg,param |
| r2724 | r2725 | |
| 2602 | 2680 | { |
| 2603 | 2681 | if (param->type == DRCUML_PTYPE_IMMEDIATE) |
| 2604 | 2682 | { |
| 2605 | if (inst->condflags | |
| 2683 | if (inst->condflags == 0 && (UINT64)param->value == 0) | |
| 2606 | 2684 | /* skip */; |
| 2607 | 2685 | else |
| 2608 | 2686 | emit_rol_m64_imm(dst, MEMPARAMS, param->value); // rol [dest],param |
| r2724 | r2725 | |
| 2624 | 2702 | { |
| 2625 | 2703 | if (param->type == DRCUML_PTYPE_IMMEDIATE) |
| 2626 | 2704 | { |
| 2627 | if (inst->condflags | |
| 2705 | if (inst->condflags == 0 && (UINT32)param->value == 0) | |
| 2628 | 2706 | /* skip */; |
| 2629 | 2707 | else |
| 2630 | 2708 | emit_ror_r64_imm(dst, reg, param->value); // ror reg,param |
| r2724 | r2725 | |
| 2646 | 2724 | { |
| 2647 | 2725 | if (param->type == DRCUML_PTYPE_IMMEDIATE) |
| 2648 | 2726 | { |
| 2649 | if (inst->condflags | |
| 2727 | if (inst->condflags == 0 && (UINT64)param->value == 0) | |
| 2650 | 2728 | /* skip */; |
| 2651 | 2729 | else |
| 2652 | 2730 | emit_ror_m64_imm(dst, MEMPARAMS, param->value); // ror [dest],param |
| r2724 | r2725 | |
| 2668 | 2746 | { |
| 2669 | 2747 | if (param->type == DRCUML_PTYPE_IMMEDIATE) |
| 2670 | 2748 | { |
| 2671 | if (inst->condflags | |
| 2749 | if (inst->condflags == 0 && (UINT32)param->value == 0) | |
| 2672 | 2750 | /* skip */; |
| 2673 | 2751 | else |
| 2674 | 2752 | emit_rcl_r64_imm(dst, reg, param->value); // rcl reg,param |
| r2724 | r2725 | |
| 2690 | 2768 | { |
| 2691 | 2769 | if (param->type == DRCUML_PTYPE_IMMEDIATE) |
| 2692 | 2770 | { |
| 2693 | if (inst->condflags | |
| 2771 | if (inst->condflags == 0 && (UINT64)param->value == 0) | |
| 2694 | 2772 | /* skip */; |
| 2695 | 2773 | else |
| 2696 | 2774 | emit_rcl_m64_imm(dst, MEMPARAMS, param->value); // rcl [dest],param |
| r2724 | r2725 | |
| 2712 | 2790 | { |
| 2713 | 2791 | if (param->type == DRCUML_PTYPE_IMMEDIATE) |
| 2714 | 2792 | { |
| 2715 | if (inst->condflags | |
| 2793 | if (inst->condflags == 0 && (UINT32)param->value == 0) | |
| 2716 | 2794 | /* skip */; |
| 2717 | 2795 | else |
| 2718 | 2796 | emit_rcr_r64_imm(dst, reg, param->value); // rcr reg,param |
| r2724 | r2725 | |
| 2734 | 2812 | { |
| 2735 | 2813 | if (param->type == DRCUML_PTYPE_IMMEDIATE) |
| 2736 | 2814 | { |
| 2737 | if (inst->condflags | |
| 2815 | if (inst->condflags == 0 && (UINT64)param->value == 0) | |
| 2738 | 2816 | /* skip */; |
| 2739 | 2817 | else |
| 2740 | 2818 | emit_rcr_m64_imm(dst, MEMPARAMS, param->value); // rcr [dest],param |
| r2724 | r2725 | |
| 2969 | 3047 | drcuml_handle_set_codeptr((drcuml_codehandle *)(FPTR)inst->param[0].value, dst); |
| 2970 | 3048 | |
| 2971 | 3049 | /* by default, the handle points to prolog code that moves the stack pointer */ |
| 2972 | emit_ | |
| 3050 | emit_lea_r64_ | |
| 2973 | 3051 | return dst; |
| 2974 | 3052 | } |
| 2975 | 3053 | |
| r2724 | r2725 | |
| 3172 | 3250 | } |
| 3173 | 3251 | |
| 3174 | 3252 | /* in all cases, if there is no code, we return here to generate the exception */ |
| 3175 | emit_mov_m32_p32(drcbe, &dst, MABS(drcbe, &drcbe->state.exp | |
| 3253 | emit_mov_m32_p32(drcbe, &dst, MABS(drcbe, &drcbe->state.exp | |
| 3176 | 3254 | emit_sub_r64_imm(&dst, REG_RSP, 8); // sub rsp,8 |
| 3177 | 3255 | emit_call_m64(&dst, MABS(drcbe, exp.value)); // call [exp] |
| 3178 | 3256 | |
| r2724 | r2725 | |
| 3231 | 3309 | /* perform the exception processing inline if unconditional */ |
| 3232 | 3310 | if (inst->condflags == DRCUML_COND_ALWAYS) |
| 3233 | 3311 | { |
| 3234 | emit_mov_m32_p32(drcbe, &dst, MABS(drcbe, &drcbe->state.exp | |
| 3312 | emit_mov_m32_p32(drcbe, &dst, MABS(drcbe, &drcbe->state.exp | |
| 3235 | 3313 | if (*targetptr != NULL) |
| 3236 | 3314 | emit_call(&dst, *targetptr); // call *targetptr |
| 3237 | 3315 | else |
| r2724 | r2725 | |
| 3303 | 3381 | emit_jcc_short_link(&dst, X86_NOT_CONDITION(inst->condflags), &skip); // jcc skip |
| 3304 | 3382 | |
| 3305 | 3383 | /* return */ |
| 3306 | emit_a | |
| 3384 | emit_lea | |
| 3307 | 3385 | emit_ret(&dst); // ret |
| 3308 | 3386 | |
| 3309 | 3387 | /* resolve the conditional link */ |
| r2724 | r2725 | |
| 3459 | 3537 | |
| 3460 | 3538 | /* fetch the exception parameter and store to the destination */ |
| 3461 | 3539 | if (dstp.type == DRCUML_PTYPE_INT_REGISTER) |
| 3462 | emit_mov_r32_m32(&dst, dstp.value, MABS(drcbe, &drcbe->state.exp | |
| 3540 | emit_mov_r32_m32(&dst, dstp.value, MABS(drcbe, &drcbe->state.exp | |
| 3463 | 3541 | else |
| 3464 | 3542 | { |
| 3465 | emit_mov_r32_m32(&dst, REG_EAX, MABS(drcbe, &drcbe->state.exp | |
| 3543 | emit_mov_r32_m32(&dst, REG_EAX, MABS(drcbe, &drcbe->state.exp | |
| 3466 | 3544 | emit_mov_m32_r32(&dst, MABS(drcbe, dstp.value), REG_EAX); // mov [dstp],eax |
| 3467 | 3545 | } |
| 3468 | 3546 | |
| r2724 | r2725 | |
| 3470 | 3548 | } |
| 3471 | 3549 | |
| 3472 | 3550 | |
| 3551 | /*------------------------------------------------- | |
| 3552 | op_save - process a SAVE opcode | |
| 3553 | -------------------------------------------------*/ | |
| 3473 | 3554 | |
| 3555 | static x86code *op_save(drcbe_state *drcbe, x86code *dst, const drcuml_instruction *inst) | |
| 3556 | { | |
| 3557 | drcuml_parameter dstp; | |
| 3558 | int regnum; | |
| 3559 | ||
| 3560 | /* validate instruction */ | |
| 3561 | assert(inst->size == 4); | |
| 3562 | assert(inst->condflags == DRCUML_COND_ALWAYS); | |
| 3563 | ||
| 3564 | /* normalize parameters */ | |
| 3565 | param_normalize_1(drcbe, inst, &dstp, PTYPE_M); | |
| 3566 | ||
| 3567 | /* copy live state to the destination */ | |
| 3568 | emit_mov_r64_imm(&dst, REG_RCX, dstp.value); // mov rcx,dstp | |
| 3569 | ||
| 3570 | /* copy flags */ | |
| 3571 | emit_pushf(&dst); // pushf | |
| 3572 | emit_pop_r64(&dst, REG_RAX); // pop rax | |
| 3573 | emit_and_r32_imm(&dst, REG_EAX, 0x8c5); // and eax,0x8c5 | |
| 3574 | emit_mov_r8_m8(&dst, REG_AL, MBISD(REG_RBP, REG_RAX, 1, offset_from_rbp(drcbe, (FPTR)&drcbe->flagsmap[0]))); | |
| 3575 | // mov al,[flags_map] | |
| 3576 | emit_mov_m8_r8(&dst, MBD(REG_RCX, offsetof(drcuml_machine_state, flags)), REG_AL); // mov state->flags,al | |
| 3577 | ||
| 3578 | /* copy fmod and exp */ | |
| 3579 | emit_mov_r8_m8(&dst, REG_AL, MABS(drcbe, &drcbe->state.fmod)); // mov al,[fmod] | |
| 3580 | emit_mov_m8_r8(&dst, MBD(REG_RCX, offsetof(drcuml_machine_state, fmod)), REG_AL); // mov state->fmod,al | |
| 3581 | emit_mov_r32_m32(&dst, REG_EAX, MABS(drcbe, &drcbe->state.exp)); // mov eax,[exp] | |
| 3582 | emit_mov_m32_r32(&dst, MBD(REG_RCX, offsetof(drcuml_machine_state, exp)), REG_EAX); // mov state->exp,eax | |
| 3583 | ||
| 3584 | /* copy integer registers */ | |
| 3585 | for (regnum = 0; regnum < ARRAY_LENGTH(drcbe->state.r); regnum++) | |
| 3586 | { | |
| 3587 | if (int_register_map[regnum] != 0) | |
| 3588 | emit_mov_m64_r64(&dst, MBD(REG_RCX, offsetof(drcuml_machine_state, r[regnum].d)), int_register_map[regnum]); | |
| 3589 | else | |
| 3590 | { | |
| 3591 | emit_mov_r64_m64(&dst, REG_RAX, MABS(drcbe, &drcbe->state.r[regnum].d)); | |
| 3592 | emit_mov_m64_r64(&dst, MBD(REG_RCX, offsetof(drcuml_machine_state, r[regnum].d)), REG_RAX); | |
| 3593 | } | |
| 3594 | } | |
| 3595 | ||
| 3596 | /* copy FP registers */ | |
| 3597 | for (regnum = 0; regnum < ARRAY_LENGTH(drcbe->state.f); regnum++) | |
| 3598 | { | |
| 3599 | if (float_register_map[regnum] != 0) | |
| 3600 | emit_movsd_m64_r128(&dst, MBD(REG_RCX, offsetof(drcuml_machine_state, f[regnum].d)), float_register_map[regnum]); | |
| 3601 | else | |
| 3602 | { | |
| 3603 | emit_mov_r64_m64(&dst, REG_RAX, MABS(drcbe, &drcbe->state.f[regnum].d)); | |
| 3604 | emit_mov_m64_r64(&dst, MBD(REG_RCX, offsetof(drcuml_machine_state, f[regnum].d)), REG_RAX); | |
| 3605 | } | |
| 3606 | } | |
| 3607 | ||
| 3608 | return dst; | |
| 3609 | } | |
| 3610 | ||
| 3611 | ||
| 3612 | /*------------------------------------------------- | |
| 3613 | op_restore - process a RESTORE opcode | |
| 3614 | -------------------------------------------------*/ | |
| 3615 | ||
| 3616 | static x86code *op_restore(drcbe_state *drcbe, x86code *dst, const drcuml_instruction *inst) | |
| 3617 | { | |
| 3618 | drcuml_parameter dstp; | |
| 3619 | int regnum; | |
| 3620 | ||
| 3621 | /* validate instruction */ | |
| 3622 | assert(inst->size == 4); | |
| 3623 | assert(inst->condflags == DRCUML_COND_ALWAYS); | |
| 3624 | ||
| 3625 | /* normalize parameters */ | |
| 3626 | param_normalize_1(drcbe, inst, &dstp, PTYPE_M); | |
| 3627 | ||
| 3628 | /* copy live state from the destination */ | |
| 3629 | emit_mov_r64_imm(&dst, REG_ECX, dstp.value); // mov rcx,dstp | |
| 3630 | ||
| 3631 | /* copy integer registers */ | |
| 3632 | for (regnum = 0; regnum < ARRAY_LENGTH(drcbe->state.r); regnum++) | |
| 3633 | { | |
| 3634 | if (int_register_map[regnum] != 0) | |
| 3635 | emit_mov_r64_m64(&dst, int_register_map[regnum], MBD(REG_RCX, offsetof(drcuml_machine_state, r[regnum].d))); | |
| 3636 | else | |
| 3637 | { | |
| 3638 | emit_mov_r64_m64(&dst, REG_RAX, MBD(REG_RCX, offsetof(drcuml_machine_state, r[regnum].d))); | |
| 3639 | emit_mov_m64_r64(&dst, MABS(drcbe, &drcbe->state.r[regnum].d), REG_RAX); | |
| 3640 | } | |
| 3641 | } | |
| 3642 | ||
| 3643 | /* copy FP registers */ | |
| 3644 | for (regnum = 0; regnum < ARRAY_LENGTH(drcbe->state.f); regnum++) | |
| 3645 | { | |
| 3646 | if (float_register_map[regnum] != 0) | |
| 3647 | emit_movsd_r128_m64(&dst, float_register_map[regnum], MBD(REG_RCX, offsetof(drcuml_machine_state, f[regnum].d))); | |
| 3648 | else | |
| 3649 | { | |
| 3650 | emit_mov_r64_m64(&dst, REG_RAX, MBD(REG_RCX, offsetof(drcuml_machine_state, f[regnum].d))); | |
| 3651 | emit_mov_m64_r64(&dst, MABS(drcbe, &drcbe->state.f[regnum].d), REG_RAX); | |
| 3652 | } | |
| 3653 | } | |
| 3654 | ||
| 3655 | /* copy fmod and exp */ | |
| 3656 | emit_movzx_r32_m8(&dst, REG_EAX, MBD(REG_RCX, offsetof(drcuml_machine_state, fmod)));// movzx eax,state->fmod | |
| 3657 | emit_and_r32_imm(&dst, REG_EAX, 3); // and eax,3 | |
| 3658 | emit_mov_m8_r8(&dst, MABS(drcbe, &drcbe->state.fmod), REG_AL); // mov [fmod],al | |
| 3659 | emit_ldmxcsr_m32(&dst, MBISD(REG_RBP, REG_RAX, 4, offset_from_rbp(drcbe, (FPTR)&drcbe->ssecontrol[0]))); | |
| 3660 | emit_mov_r32_m32(&dst, REG_EAX, MBD(REG_RCX, offsetof(drcuml_machine_state, exp))); // mov eax,state->exp | |
| 3661 | emit_mov_m32_r32(&dst, MABS(drcbe, &drcbe->state.exp), REG_EAX); // mov [exp],eax | |
| 3662 | ||
| 3663 | /* copy flags */ | |
| 3664 | emit_movzx_r32_m8(&dst, REG_EAX, MBD(REG_RCX, offsetof(drcuml_machine_state, flags)));// movzx eax,state->flags | |
| 3665 | emit_push_m64(&dst, MBISD(REG_RBP, REG_RAX, 8, offset_from_rbp(drcbe, (FPTR)&drcbe->flagsunmap[0]))); | |
| 3666 | // push flags_unmap[eax*8] | |
| 3667 | emit_popf(&dst); // popf | |
| 3668 | ||
| 3669 | return dst; | |
| 3670 | } | |
| 3671 | ||
| 3672 | ||
| 3673 | ||
| 3474 | 3674 | /*************************************************************************** |
| 3475 | 3675 | INTEGER OPERATIONS |
| 3476 | 3676 | ***************************************************************************/ |
| r2724 | r2725 | |
| 4991 | 5191 | |
| 4992 | 5192 | |
| 4993 | 5193 | /*------------------------------------------------- |
| 5194 | op_xtract - process an XTRACT opcode | |
| 5195 | -------------------------------------------------*/ | |
| 5196 | ||
| 5197 | static x86code *op_xtract(drcbe_state *drcbe, x86code *dst, const drcuml_instruction *inst) | |
| 5198 | { | |
| 5199 | drcuml_parameter dstp, srcp, shiftp, maskp; | |
| 5200 | int dstreg; | |
| 5201 | ||
| 5202 | /* validate instruction */ | |
| 5203 | assert(inst->size == 4 || inst->size == 8); | |
| 5204 | assert(inst->condflags == DRCUML_COND_ALWAYS); | |
| 5205 | ||
| 5206 | /* normalize parameters */ | |
| 5207 | param_normalize_4(drcbe, inst, &dstp, PTYPE_MR, &srcp, PTYPE_MRI, &shiftp, PTYPE_MRI, &maskp, PTYPE_MRI); | |
| 5208 | ||
| 5209 | /* degenerate cases -- convert to a move or simple shift */ | |
| 5210 | if (srcp.type == DRCUML_PTYPE_IMMEDIATE && shiftp.type == DRCUML_PTYPE_IMMEDIATE && maskp.type == DRCUML_PTYPE_IMMEDIATE) | |
| 5211 | { | |
| 5212 | if (inst->size == 4) | |
| 5213 | return convert_to_mov_imm(drcbe, dst, inst, &dstp, ((srcp.value << shiftp.value) | (srcp.value >> (32 - shiftp.value))) & maskp.value); | |
| 5214 | else if (inst->size == 8) | |
| 5215 | return convert_to_mov_imm(drcbe, dst, inst, &dstp, ((srcp.value << shiftp.value) | (srcp.value >> (64 - shiftp.value))) & maskp.value); | |
| 5216 | } | |
| 5217 | if (shiftp.type == DRCUML_PTYPE_IMMEDIATE && maskp.type == DRCUML_PTYPE_IMMEDIATE) | |
| 5218 | { | |
| 5219 | if ((inst->size == 4 && maskp.value == (UINT32)(0xffffffffUL << shiftp.value)) || (inst->size == 8 && maskp.value == U64(0xffffffffffffffff) << shiftp.value)) | |
| 5220 | { | |
| 5221 | drcuml_instruction temp = *inst; | |
| 5222 | temp.numparams = 3; | |
| 5223 | return op_shl(drcbe, dst, &temp); | |
| 5224 | } | |
| 5225 | if ((inst->size == 4 && maskp.value == (UINT32)(0xffffffffUL >> (32 - shiftp.value))) || (inst->size == 8 && maskp.value == U64(0xffffffffffffffff) >> (64 - shiftp.value))) | |
| 5226 | { | |
| 5227 | drcuml_instruction temp = *inst; | |
| 5228 | temp.numparams = 3; | |
| 5229 | temp.param[2].value = inst->size * 8 - temp.param[2].value; | |
| 5230 | return op_shr(drcbe, dst, &temp); | |
| 5231 | } | |
| 5232 | } | |
| 5233 | ||
| 5234 | /* pick a target register for the general case */ | |
| 5235 | dstreg = param_select_register2(REG_EAX, &dstp, &shiftp, &maskp); | |
| 5236 | ||
| 5237 | /* 32-bit form */ | |
| 5238 | if (inst->size == 4) | |
| 5239 | { | |
| 5240 | emit_mov_r32_p32(drcbe, &dst, dstreg, &srcp); // mov dstreg,srcp | |
| 5241 | emit_rol_r32_p32(drcbe, &dst, dstreg, &shiftp, inst); // rol dstreg,shiftp | |
| 5242 | emit_and_r32_p32(drcbe, &dst, dstreg, &maskp, inst); // and dstreg,maskp | |
| 5243 | emit_mov_p32_r32(drcbe, &dst, &dstp, dstreg); // mov dstp,dstreg | |
| 5244 | } | |
| 5245 | ||
| 5246 | /* 64-bit form */ | |
| 5247 | else if (inst->size == 8) | |
| 5248 | { | |
| 5249 | emit_mov_r64_p64(drcbe, &dst, dstreg, &srcp); // mov dstreg,srcp | |
| 5250 | emit_rol_r64_p64(drcbe, &dst, dstreg, &shiftp, inst); // rol dstreg,shiftp | |
| 5251 | emit_and_r64_p64(drcbe, &dst, dstreg, &maskp, inst); // and dstreg,maskp | |
| 5252 | emit_mov_p64_r64(drcbe, &dst, &dstp, dstreg); // mov dstp,dstreg | |
| 5253 | } | |
| 5254 | return dst; | |
| 5255 | } | |
| 5256 | ||
| 5257 | ||
| 5258 | /*------------------------------------------------- | |
| 5259 | op_insert - process an INSERT opcode | |
| 5260 | -------------------------------------------------*/ | |
| 5261 | ||
| 5262 | static x86code *op_insert(drcbe_state *drcbe, x86code *dst, const drcuml_instruction *inst) | |
| 5263 | { | |
| 5264 | drcuml_parameter dstp, srcp, shiftp, maskp; | |
| 5265 | int dstreg; | |
| 5266 | ||
| 5267 | /* validate instruction */ | |
| 5268 | assert(inst->size == 4 || inst->size == 8); | |
| 5269 | assert(inst->condflags == DRCUML_COND_ALWAYS); | |
| 5270 | ||
| 5271 | /* normalize parameters */ | |
| 5272 | param_normalize_4(drcbe, inst, &dstp, PTYPE_MR, &srcp, PTYPE_MRI, &shiftp, PTYPE_MRI, &maskp, PTYPE_MRI); | |
| 5273 | ||
| 5274 | /* pick a target register for the general case */ | |
| 5275 | dstreg = param_select_register2(REG_ECX, &dstp, &shiftp, &maskp); | |
| 5276 | ||
| 5277 | /* 32-bit form */ | |
| 5278 | if (inst->size == 4) | |
| 5279 | { | |
| 5280 | emit_mov_r32_p32(drcbe, &dst, REG_EAX, &srcp); // mov eax,srcp | |
| 5281 | emit_rol_r32_p32(drcbe, &dst, REG_EAX, &shiftp, inst); // rol eax,shiftp | |
| 5282 | emit_mov_r32_p32(drcbe, &dst, dstreg, &dstp); // mov dstreg,dstp | |
| 5283 | if (maskp.type == DRCUML_PTYPE_IMMEDIATE) | |
| 5284 | { | |
| 5285 | emit_and_r32_imm(&dst, REG_EAX, maskp.value); // and eax,maskp | |
| 5286 | emit_and_r32_imm(&dst, dstreg, ~maskp.value); // and dstreg,~maskp | |
| 5287 | } | |
| 5288 | else | |
| 5289 | { | |
| 5290 | emit_mov_r32_p32(drcbe, &dst, REG_EDX, &maskp); // mov edx,maskp | |
| 5291 | emit_and_r32_r32(&dst, REG_EAX, REG_EDX); // and eax,edx | |
| 5292 | emit_not_r32(&dst, REG_EDX); // not edx | |
| 5293 | emit_and_r32_r32(&dst, dstreg, REG_EDX); // and dstreg,edx | |
| 5294 | } | |
| 5295 | emit_or_r32_r32(&dst, dstreg, REG_EAX); // or dstreg,eax | |
| 5296 | emit_mov_p32_r32(drcbe, &dst, &dstp, dstreg); // mov dstp,dstreg | |
| 5297 | } | |
| 5298 | ||
| 5299 | /* 64-bit form */ | |
| 5300 | else if (inst->size == 8) | |
| 5301 | { | |
| 5302 | emit_mov_r64_p64(drcbe, &dst, REG_RAX, &srcp); // mov rax,srcp | |
| 5303 | emit_mov_r64_p64(drcbe, &dst, REG_RDX, &maskp); // mov rdx,maskp | |
| 5304 | emit_rol_r64_p64(drcbe, &dst, REG_RAX, &shiftp, inst); // rol rax,shiftp | |
| 5305 | emit_mov_r64_p64(drcbe, &dst, dstreg, &dstp); // mov dstreg,dstp | |
| 5306 | emit_and_r64_r64(&dst, REG_RAX, REG_RDX); // and eax,rdx | |
| 5307 | emit_not_r64(&dst, REG_RDX); // not rdx | |
| 5308 | emit_and_r64_r64(&dst, dstreg, REG_RDX); // and dstreg,rdx | |
| 5309 | emit_or_r64_r64(&dst, dstreg, REG_RAX); // or dstreg,rax | |
| 5310 | emit_mov_p64_r64(drcbe, &dst, &dstp, dstreg); // mov dstp,dstreg | |
| 5311 | } | |
| 5312 | return dst; | |
| 5313 | } | |
| 5314 | ||
| 5315 | ||
| 5316 | /*------------------------------------------------- | |
| 4994 | 5317 | op_add - process a ADD opcode |
| 4995 | 5318 | -------------------------------------------------*/ |
| 4996 | 5319 | |
| r2724 | r2725 | |
| 5020 | 5343 | { |
| 5021 | 5344 | /* dstp == src1p in memory */ |
| 5022 | 5345 | if (dstp.type == DRCUML_PTYPE_MEMORY && src1p.type == DRCUML_PTYPE_MEMORY && src1p.value == dstp.value) |
| 5023 | emit_add_m32_p32(drcbe, &dst, MABS(drcbe, dstp.value), &src2p, inst); | |
| 5346 | emit_add_m32_p32(drcbe, &dst, MABS(drcbe, dstp.value), &src2p, inst); | |
| 5024 | 5347 | |
| 5025 | 5348 | /* reg = reg + imm */ |
| 5026 | 5349 | else if (dstp.type == DRCUML_PTYPE_INT_REGISTER && src1p.type == DRCUML_PTYPE_INT_REGISTER && src2p.type == DRCUML_PTYPE_IMMEDIATE && inst->condflags == 0) |
| r2724 | r2725 | |
| 5902 | 6225 | |
| 5903 | 6226 | |
| 5904 | 6227 | /*------------------------------------------------- |
| 6228 | op_lzcnt - process a LZCNT opcode | |
| 6229 | -------------------------------------------------*/ | |
| 6230 | ||
| 6231 | static x86code *op_lzcnt(drcbe_state *drcbe, x86code *dst, const drcuml_instruction *inst) | |
| 6232 | { | |
| 6233 | drcuml_parameter dstp, srcp; | |
| 6234 | int dstreg; | |
| 6235 | ||
| 6236 | /* validate instruction */ | |
| 6237 | assert(inst->size == 4 || inst->size == 8); | |
| 6238 | assert(inst->condflags == 0); | |
| 6239 | ||
| 6240 | /* normalize parameters */ | |
| 6241 | param_normalize_2(drcbe, inst, &dstp, PTYPE_MR, &srcp, PTYPE_MRI); | |
| 6242 | ||
| 6243 | /* degenerate cases -- convert to a move */ | |
| 6244 | if (srcp.type == DRCUML_PTYPE_IMMEDIATE && inst->condflags == 0) | |
| 6245 | return convert_to_mov_imm(drcbe, dst, inst, &dstp, count_leading_zeros(srcp.value)); | |
| 6246 | ||
| 6247 | /* pick a target register for the general case */ | |
| 6248 | dstreg = param_select_register(REG_EAX, &dstp, &srcp); | |
| 6249 | ||
| 6250 | /* 32-bit form */ | |
| 6251 | if (inst->size == 4) | |
| 6252 | { | |
| 6253 | emit_mov_r32_p32(drcbe, &dst, dstreg, &srcp); // mov dstreg,src1p | |
| 6254 | emit_mov_r32_imm(&dst, REG_ECX, 32); // mov ecx,32 | |
| 6255 | emit_bsr_r32_r32(&dst, dstreg, dstreg); // bsr dstreg,dstreg | |
| 6256 | emit_cmovcc_r32_r32(&dst, COND_Z, dstreg, REG_ECX); // cmovz dstreg,ecx | |
| 6257 | emit_mov_p32_r32(drcbe, &dst, &dstp, dstreg); // mov dstp,dstreg | |
| 6258 | } | |
| 6259 | ||
| 6260 | /* 64-bit form */ | |
| 6261 | else if (inst->size == 8) | |
| 6262 | { | |
| 6263 | emit_mov_r64_p64(drcbe, &dst, dstreg, &srcp); // mov dstreg,src1p | |
| 6264 | emit_mov_r64_imm(&dst, REG_RCX, 64); // mov rcx,64 | |
| 6265 | emit_bsr_r64_r64(&dst, dstreg, dstreg); // bsr dstreg,dstreg | |
| 6266 | emit_cmovcc_r64_r64(&dst, COND_Z, dstreg, REG_RCX); // cmovz dstreg,rcx | |
| 6267 | emit_mov_p64_r64(drcbe, &dst, &dstp, dstreg); // mov dstp,dstreg | |
| 6268 | } | |
| 6269 | return dst; | |
| 6270 | } | |
| 6271 | ||
| 6272 | ||
| 6273 | /*------------------------------------------------- | |
| 5905 | 6274 | op_shl - process a SHL opcode |
| 5906 | 6275 | -------------------------------------------------*/ |
| 5907 | 6276 | |
| r2724 | r2725 | |
| 6654 | 7023 | |
| 6655 | 7024 | |
| 6656 | 7025 | /*------------------------------------------------- |
| 6657 | op_ftoi4 | |
| 7026 | op_ftoi4x - process a FTOI4R/F/C opcode | |
| 6658 | 7027 | -------------------------------------------------*/ |
| 6659 | 7028 | |
| 6660 | static x86code *op_ftoi4 | |
| 7029 | static x86code *op_ftoi4x(drcbe_state *drcbe, x86code *dst, const drcuml_instruction *inst, int mode) | |
| 6661 | 7030 | { |
| 6662 | 7031 | drcuml_parameter dstp, srcp; |
| 6663 | 7032 | int dstreg; |
| r2724 | r2725 | |
| 6672 | 7041 | /* pick a target register for the general case */ |
| 6673 | 7042 | dstreg = param_select_register(REG_EAX, &dstp, NULL); |
| 6674 | 7043 | |
| 6675 | /* save and set the control word */ | |
| 6676 | emit_stmxcsr_m32(&dst, MABS(drcbe, &drcbe->ssemodesave)); // stmxcsr [ssemodesave] | |
| 6677 | emit_ldmxcsr_m32(&dst, MABS(drcbe, &drcbe->ssecontrol[DRCUML_FMOD_ROUND])); // ldmxcsr fpcontrol[DRCUML_FMOD_ROUND] | |
| 7044 | /* non-SSE4.1 case */ | |
| 7045 | if (!drcbe->sse41 || inst->size == 8) | |
| 7046 | { | |
| 7047 | /* save and set the control word */ | |
| 7048 | emit_stmxcsr_m32(&dst, MABS(drcbe, &drcbe->ssemodesave)); // stmxcsr [ssemodesave] | |
| 7049 | emit_ldmxcsr_m32(&dst, MABS(drcbe, &drcbe->ssecontrol[mode])); // ldmxcsr fpcontrol[mode] | |
| 6678 | 7050 | |
| 6679 | /* 32-bit form */ | |
| 6680 | if (inst->size == 4) | |
| 6681 | { | |
| 6682 | if (srcp.type == DRCUML_PTYPE_MEMORY) | |
| 6683 | emit_cvtss2si_r32_m32(&dst, dstreg, MABS(drcbe, srcp.value)); // cvtss2si dstreg,[srcp] | |
| 6684 | else if (srcp.type == DRCUML_PTYPE_FLOAT_REGISTER) | |
| 6685 | emit_cvtss2si_r32_r128(&dst, dstreg, srcp.value); // cvtss2si dstreg,srcp | |
| 7051 | /* 32-bit form */ | |
| 7052 | if (inst->size == 4) | |
| 7053 | { | |
| 7054 | if (srcp.type == DRCUML_PTYPE_MEMORY) | |
| 7055 | emit_cvtss2si_r32_m32(&dst, dstreg, MABS(drcbe, srcp.value)); // cvtss2si dstreg,[srcp] | |
| 7056 | else if (srcp.type == DRCUML_PTYPE_FLOAT_REGISTER) | |
| 7057 | emit_cvtss2si_r32_r128(&dst, dstreg, srcp.value); // cvtss2si dstreg,srcp | |
| 7058 | } | |
| 7059 | ||
| 7060 | /* 64-bit form */ | |
| 7061 | else if (inst->size == 8) | |
| 7062 | { | |
| 7063 | if (srcp.type == DRCUML_PTYPE_MEMORY) | |
| 7064 | emit_cvtsd2si_r32_m64(&dst, dstreg, MABS(drcbe, srcp.value)); // cvtsd2si dstreg,[srcp] | |
| 7065 | else if (srcp.type == DRCUML_PTYPE_FLOAT_REGISTER) | |
| 7066 | emit_cvtsd2si_r32_r128(&dst, dstreg, srcp.value); // cvtsd2si dstreg,srcp | |
| 7067 | } | |
| 7068 | ||
| 7069 | /* restore control word and proceed */ | |
| 7070 | emit_mov_p32_r32(drcbe, &dst, &dstp, dstreg); // mov dstp,dstreg | |
| 7071 | emit_ldmxcsr_m32(&dst, MABS(drcbe, &drcbe->ssemodesave)); // ldmxcsr [ssemodesave] | |
| 6686 | 7072 | } |
| 6687 | 7073 | |
| 6688 | /* 64-bit form */ | |
| 6689 | else if (inst->size == 8) | |
| 7074 | /* SSE4.1 case */ | |
| 7075 | else | |
| 6690 | 7076 | { |
| 7077 | /* 32-bit form */ | |
| 6691 | 7078 | if (srcp.type == DRCUML_PTYPE_MEMORY) |
| 6692 | emit_cvtsd2si_r32_m64(&dst, dstreg, MABS(drcbe, srcp.value)); // cvtsd2si dstreg,[srcp] | |
| 7079 | emit_roundss_r128_m32_imm(&dst, REG_XMM0, MABS(drcbe, srcp.value), fprnd_map[mode]); | |
| 7080 | // roundss xmm0,[srcp],mode | |
| 6693 | 7081 | else if (srcp.type == DRCUML_PTYPE_FLOAT_REGISTER) |
| 6694 | emit_cvtsd2si_r32_r128(&dst, dstreg, srcp.value); // cvtsd2si dstreg,srcp | |
| 7082 | emit_roundss_r128_r128_imm(&dst, REG_XMM0, srcp.value, fprnd_map[mode]); // roundss xmm0,srcp,mode | |
| 7083 | ||
| 7084 | /* store to the destination */ | |
| 7085 | if (dstp.type == DRCUML_PTYPE_MEMORY) | |
| 7086 | emit_movd_m32_r128(&dst, MABS(drcbe, dstp.value), REG_XMM0); // movd [dstp],xmm0 | |
| 7087 | else if (dstp.type == DRCUML_PTYPE_INT_REGISTER) | |
| 7088 | emit_movd_r32_r128(&dst, dstp.value, REG_XMM0); // movd dstp,xmm0 | |
| 6695 | 7089 | } |
| 7090 | return dst; | |
| 6696 | 7091 | |
| 6697 | /* restore control word and proceed */ | |
| 6698 | emit_mov_p32_r32(drcbe, &dst, &dstp, dstreg); // mov dstp,dstreg | |
| 6699 | emit_ldmxcsr_m32(&dst, MABS(drcbe, &drcbe->ssemodesave)); // ldmxcsr [ssemodesave] | |
| 6700 | return dst; | |
| 6701 | 7092 | } |
| 6702 | 7093 | |
| 7094 | static x86code *op_ftoi4r(drcbe_state *drcbe, x86code *dst, const drcuml_instruction *inst) | |
| 7095 | { | |
| 7096 | return op_ftoi4x(drcbe, dst, inst, DRCUML_FMOD_ROUND); | |
| 7097 | } | |
| 6703 | 7098 | |
| 6704 | /*------------------------------------------------- | |
| 6705 | op_ftoi4f - process a FTOI4F opcode | |
| 6706 | -------------------------------------------------*/ | |
| 6707 | ||
| 6708 | 7099 | static x86code *op_ftoi4f(drcbe_state *drcbe, x86code *dst, const drcuml_instruction *inst) |
| 6709 | 7100 | { |
| 6710 | drcuml_parameter dstp, srcp; | |
| 6711 | int dstreg; | |
| 6712 | ||
| 6713 | /* validate instruction */ | |
| 6714 | assert(inst->size == 4 || inst->size == 8); | |
| 6715 | assert(inst->condflags == DRCUML_COND_ALWAYS); | |
| 6716 | ||
| 6717 | /* normalize parameters */ | |
| 6718 | param_normalize_2(drcbe, inst, &dstp, PTYPE_MR, &srcp, PTYPE_MF); | |
| 6719 | ||
| 6720 | /* pick a target register for the general case */ | |
| 6721 | dstreg = param_select_register(REG_EAX, &dstp, NULL); | |
| 6722 | ||
| 6723 | /* save and set the control word */ | |
| 6724 | emit_stmxcsr_m32(&dst, MABS(drcbe, &drcbe->ssemodesave)); // stmxcsr [ssemodesave] | |
| 6725 | emit_ldmxcsr_m32(&dst, MABS(drcbe, &drcbe->ssecontrol[DRCUML_FMOD_FLOOR])); // ldmxcsr fpcontrol[DRCUML_FMOD_FLOOR] | |
| 6726 | ||
| 6727 | /* 32-bit form */ | |
| 6728 | if (inst->size == 4) | |
| 6729 | { | |
| 6730 | if (srcp.type == DRCUML_PTYPE_MEMORY) | |
| 6731 | emit_cvtss2si_r32_m32(&dst, dstreg, MABS(drcbe, srcp.value)); // cvtss2si dstreg,[srcp] | |
| 6732 | else if (srcp.type == DRCUML_PTYPE_FLOAT_REGISTER) | |
| 6733 | emit_cvtss2si_r32_r128(&dst, dstreg, srcp.value); // cvtss2si dstreg,srcp | |
| 6734 | } | |
| 6735 | ||
| 6736 | /* 64-bit form */ | |
| 6737 | else if (inst->size == 8) | |
| 6738 | { | |
| 6739 | if (srcp.type == DRCUML_PTYPE_MEMORY) | |
| 6740 | emit_cvtsd2si_r32_m64(&dst, dstreg, MABS(drcbe, srcp.value)); // cvtsd2si dstreg,[srcp] | |
| 6741 | else if (srcp.type == DRCUML_PTYPE_FLOAT_REGISTER) | |
| 6742 | emit_cvtsd2si_r32_r128(&dst, dstreg, srcp.value); // cvtsd2si dstreg,srcp | |
| 6743 | } | |
| 6744 | ||
| 6745 | /* restore control word and proceed */ | |
| 6746 | emit_mov_p32_r32(drcbe, &dst, &dstp, dstreg); // mov dstp,dstreg | |
| 6747 | emit_ldmxcsr_m32(&dst, MABS(drcbe, &drcbe->ssemodesave)); // ldmxcsr [ssemodesave] | |
| 6748 | return dst; | |
| 7101 | return op_ftoi4x(drcbe, dst, inst, DRCUML_FMOD_FLOOR); | |
| 6749 | 7102 | } |
| 6750 | 7103 | |
| 6751 | ||
| 6752 | /*------------------------------------------------- | |
| 6753 | op_ftoi4c - process a FTOI4C opcode | |
| 6754 | -------------------------------------------------*/ | |
| 6755 | ||
| 6756 | 7104 | static x86code *op_ftoi4c(drcbe_state *drcbe, x86code *dst, const drcuml_instruction *inst) |
| 6757 | 7105 | { |
| 6758 | drcuml_parameter dstp, srcp; | |
| 6759 | int dstreg; | |
| 6760 | ||
| 6761 | /* validate instruction */ | |
| 6762 | assert(inst->size == 4 || inst->size == 8); | |
| 6763 | assert(inst->condflags == DRCUML_COND_ALWAYS); | |
| 6764 | ||
| 6765 | /* normalize parameters */ | |
| 6766 | param_normalize_2(drcbe, inst, &dstp, PTYPE_MR, &srcp, PTYPE_MF); | |
| 6767 | ||
| 6768 | /* pick a target register for the general case */ | |
| 6769 | dstreg = param_select_register(REG_EAX, &dstp, NULL); | |
| 6770 | ||
| 6771 | /* save and set the control word */ | |
| 6772 | emit_stmxcsr_m32(&dst, MABS(drcbe, &drcbe->ssemodesave)); // stmxcsr [ssemodesave] | |
| 6773 | emit_ldmxcsr_m32(&dst, MABS(drcbe, &drcbe->ssecontrol[DRCUML_FMOD_CEIL])); // ldmxcsr fpcontrol[DRCUML_FMOD_CEIL] | |
| 6774 | ||
| 6775 | /* 32-bit form */ | |
| 6776 | if (inst->size == 4) | |
| 6777 | { | |
| 6778 | if (srcp.type == DRCUML_PTYPE_MEMORY) | |
| 6779 | emit_cvtss2si_r32_m32(&dst, dstreg, MABS(drcbe, srcp.value)); // cvtss2si dstreg,[srcp] | |
| 6780 | else if (srcp.type == DRCUML_PTYPE_FLOAT_REGISTER) | |
| 6781 | emit_cvtss2si_r32_r128(&dst, dstreg, srcp.value); // cvtss2si dstreg,srcp | |
| 6782 | } | |
| 6783 | ||
| 6784 | /* 64-bit form */ | |
| 6785 | else if (inst->size == 8) | |
| 6786 | { | |
| 6787 | if (srcp.type == DRCUML_PTYPE_MEMORY) | |
| 6788 | emit_cvtsd2si_r32_m64(&dst, dstreg, MABS(drcbe, srcp.value)); // cvtsd2si dstreg,[srcp] | |
| 6789 | else if (srcp.type == DRCUML_PTYPE_FLOAT_REGISTER) | |
| 6790 | emit_cvtsd2si_r32_r128(&dst, dstreg, srcp.value); // cvtsd2si dstreg,srcp | |
| 6791 | } | |
| 6792 | ||
| 6793 | /* restore control word and proceed */ | |
| 6794 | emit_mov_p32_r32(drcbe, &dst, &dstp, dstreg); // mov dstp,dstreg | |
| 6795 | emit_ldmxcsr_m32(&dst, MABS(drcbe, &drcbe->ssemodesave)); // ldmxcsr [ssemodesave] | |
| 6796 | return dst; | |
| 7106 | return op_ftoi4x(drcbe, dst, inst, DRCUML_FMOD_CEIL); | |
| 6797 | 7107 | } |
| 6798 | 7108 | |
| 6799 | 7109 | |
| r2724 | r2725 | |
| 6884 | 7194 | |
| 6885 | 7195 | |
| 6886 | 7196 | /*------------------------------------------------- |
| 6887 | op_ftoi8 | |
| 7197 | op_ftoi8x - process a FTOI8R/F/C opcode | |
| 6888 | 7198 | -------------------------------------------------*/ |
| 6889 | 7199 | |
| 6890 | static x86code *op_ftoi8 | |
| 7200 | static x86code *op_ftoi8x(drcbe_state *drcbe, x86code *dst, const drcuml_instruction *inst, int mode) | |
| 6891 | 7201 | { |
| 6892 | 7202 | drcuml_parameter dstp, srcp; |
| 6893 | 7203 | int dstreg; |
| r2724 | r2725 | |
| 6902 | 7212 | /* pick a target register for the general case */ |
| 6903 | 7213 | dstreg = param_select_register(REG_EAX, &dstp, NULL); |
| 6904 | 7214 | |
| 6905 | /* save and set the control word */ | |
| 6906 | emit_stmxcsr_m32(&dst, MABS(drcbe, &drcbe->ssemodesave)); // stmxcsr [ssemodesave] | |
| 6907 | emit_ldmxcsr_m32(&dst, MABS(drcbe, &drcbe->ssecontrol[DRCUML_FMOD_ROUND])); // ldmxcsr fpcontrol[DRCUML_FMOD_ROUND] | |
| 7215 | /* non-SSE4.1 case */ | |
| 7216 | if (!drcbe->sse41 || inst->size == 4) | |
| 7217 | { | |
| 7218 | /* save and set the control word */ | |
| 7219 | emit_stmxcsr_m32(&dst, MABS(drcbe, &drcbe->ssemodesave)); // stmxcsr [ssemodesave] | |
| 7220 | emit_ldmxcsr_m32(&dst, MABS(drcbe, &drcbe->ssecontrol[mode])); // ldmxcsr fpcontrol[mode] | |
| 6908 | 7221 | |
| 6909 | /* 32-bit form */ | |
| 6910 | if (inst->size == 4) | |
| 6911 | { | |
| 6912 | if (srcp.type == DRCUML_PTYPE_MEMORY) | |
| 6913 | emit_cvtss2si_r64_m32(&dst, dstreg, MABS(drcbe, srcp.value)); // cvtss2si dstreg,[srcp] | |
| 6914 | else if (srcp.type == DRCUML_PTYPE_FLOAT_REGISTER) | |
| 6915 | emit_cvtss2si_r64_r128(&dst, dstreg, srcp.value); // cvtss2si dstreg,srcp | |
| 7222 | /* 32-bit form */ | |
| 7223 | if (inst->size == 4) | |
| 7224 | { | |
| 7225 | if (srcp.type == DRCUML_PTYPE_MEMORY) | |
| 7226 | emit_cvtss2si_r64_m32(&dst, dstreg, MABS(drcbe, srcp.value)); // cvtss2si dstreg,[srcp] | |
| 7227 | else if (srcp.type == DRCUML_PTYPE_FLOAT_REGISTER) | |
| 7228 | emit_cvtss2si_r64_r128(&dst, dstreg, srcp.value); // cvtss2si dstreg,srcp | |
| 7229 | } | |
| 7230 | ||
| 7231 | /* 64-bit form */ | |
| 7232 | else if (inst->size == 8) | |
| 7233 | { | |
| 7234 | if (srcp.type == DRCUML_PTYPE_MEMORY) | |
| 7235 | emit_cvtsd2si_r64_m64(&dst, dstreg, MABS(drcbe, srcp.value)); // cvtsd2si dstreg,[srcp] | |
| 7236 | else if (srcp.type == DRCUML_PTYPE_FLOAT_REGISTER) | |
| 7237 | emit_cvtsd2si_r64_r128(&dst, dstreg, srcp.value); // cvtsd2si dstreg,srcp | |
| 7238 | } | |
| 7239 | ||
| 7240 | /* restore control word and proceed */ | |
| 7241 | emit_mov_p64_r64(drcbe, &dst, &dstp, dstreg); // mov dstp,dstreg | |
| 7242 | emit_ldmxcsr_m32(&dst, MABS(drcbe, &drcbe->ssemodesave)); // ldmxcsr [ssemodesave] | |
| 6916 | 7243 | } |
| 6917 | 7244 | |
| 6918 | /* 64-bit form */ | |
| 6919 | else if (inst->size == 8) | |
| 7245 | /* SSE4.1 case */ | |
| 7246 | else | |
| 6920 | 7247 | { |
| 7248 | /* 64-bit form */ | |
| 6921 | 7249 | if (srcp.type == DRCUML_PTYPE_MEMORY) |
| 6922 | emit_cvtsd2si_r64_m64(&dst, dstreg, MABS(drcbe, srcp.value)); // cvtsd2si dstreg,[srcp] | |
| 7250 | emit_roundsd_r128_m64_imm(&dst, REG_XMM0, MABS(drcbe, srcp.value), fprnd_map[mode]); | |
| 7251 | // roundsd xmm0,[srcp],mode | |
| 6923 | 7252 | else if (srcp.type == DRCUML_PTYPE_FLOAT_REGISTER) |
| 6924 | emit_cvtsd2si_r64_r128(&dst, dstreg, srcp.value); // cvtsd2si dstreg,srcp | |
| 7253 | emit_roundsd_r128_r128_imm(&dst, REG_XMM0, srcp.value, fprnd_map[mode]); // roundsd xmm0,srcp,mode | |
| 7254 | ||
| 7255 | /* store to the destination */ | |
| 7256 | if (dstp.type == DRCUML_PTYPE_MEMORY) | |
| 7257 | emit_movq_m64_r128(&dst, MABS(drcbe, dstp.value), REG_XMM0); // movq [dstp],xmm0 | |
| 7258 | else if (dstp.type == DRCUML_PTYPE_INT_REGISTER) | |
| 7259 | emit_movq_r64_r128(&dst, dstp.value, REG_XMM0); // movq dstp,xmm0 | |
| 6925 | 7260 | } |
| 7261 | return dst; | |
| 6926 | 7262 | |
| 6927 | /* restore control word and proceed */ | |
| 6928 | emit_mov_p64_r64(drcbe, &dst, &dstp, dstreg); // mov dstp,dstreg | |
| 6929 | emit_ldmxcsr_m32(&dst, MABS(drcbe, &drcbe->ssemodesave)); // ldmxcsr [ssemodesave] | |
| 6930 | return dst; | |
| 6931 | 7263 | } |
| 6932 | 7264 | |
| 7265 | static x86code *op_ftoi8r(drcbe_state *drcbe, x86code *dst, const drcuml_instruction *inst) | |
| 7266 | { | |
| 7267 | return op_ftoi8x(drcbe, dst, inst, DRCUML_FMOD_ROUND); | |
| 7268 | } | |
| 6933 | 7269 | |
| 6934 | /*------------------------------------------------- | |
| 6935 | op_ftoi8f - process a FTOI8F opcode | |
| 6936 | -------------------------------------------------*/ | |
| 6937 | ||
| 6938 | 7270 | static x86code *op_ftoi8f(drcbe_state *drcbe, x86code *dst, const drcuml_instruction *inst) |
| 6939 | 7271 | { |
| 6940 | drcuml_parameter dstp, srcp; | |
| 6941 | int dstreg; | |
| 6942 | ||
| 6943 | /* validate instruction */ | |
| 6944 | assert(inst->size == 4 || inst->size == 8); | |
| 6945 | assert(inst->condflags == DRCUML_COND_ALWAYS); | |
| 6946 | ||
| 6947 | /* normalize parameters */ | |
| 6948 | param_normalize_2(drcbe, inst, &dstp, PTYPE_MR, &srcp, PTYPE_MF); | |
| 6949 | ||
| 6950 | /* pick a target register for the general case */ | |
| 6951 | dstreg = param_select_register(REG_EAX, &dstp, NULL); | |
| 6952 | ||
| 6953 | /* save and set the control word */ | |
| 6954 | emit_stmxcsr_m32(&dst, MABS(drcbe, &drcbe->ssemodesave)); // stmxcsr [ssemodesave] | |
| 6955 | emit_ldmxcsr_m32(&dst, MABS(drcbe, &drcbe->ssecontrol[DRCUML_FMOD_FLOOR])); // ldmxcsr fpcontrol[DRCUML_FMOD_FLOOR] | |
| 6956 | ||
| 6957 | /* 32-bit form */ | |
| 6958 | if (inst->size == 4) | |
| 6959 | { | |
| 6960 | if (srcp.type == DRCUML_PTYPE_MEMORY) | |
| 6961 | emit_cvtss2si_r64_m32(&dst, dstreg, MABS(drcbe, srcp.value)); // cvtss2si dstreg,[srcp] | |
| 6962 | else if (srcp.type == DRCUML_PTYPE_FLOAT_REGISTER) | |
| 6963 | emit_cvtss2si_r64_r128(&dst, dstreg, srcp.value); // cvtss2si dstreg,srcp | |
| 6964 | } | |
| 6965 | ||
| 6966 | /* 64-bit form */ | |
| 6967 | else if (inst->size == 8) | |
| 6968 | { | |
| 6969 | if (srcp.type == DRCUML_PTYPE_MEMORY) | |
| 6970 | emit_cvtsd2si_r64_m64(&dst, dstreg, MABS(drcbe, srcp.value)); // cvtsd2si dstreg,[srcp] | |
| 6971 | else if (srcp.type == DRCUML_PTYPE_FLOAT_REGISTER) | |
| 6972 | emit_cvtsd2si_r64_r128(&dst, dstreg, srcp.value); // cvtsd2si dstreg,srcp | |
| 6973 | } | |
| 6974 | ||
| 6975 | /* restore control word and proceed */ | |
| 6976 | emit_mov_p64_r64(drcbe, &dst, &dstp, dstreg); // mov dstp,dstreg | |
| 6977 | emit_ldmxcsr_m32(&dst, MABS(drcbe, &drcbe->ssemodesave)); // ldmxcsr [ssemodesave] | |
| 6978 | return dst; | |
| 7272 | return op_ftoi8x(drcbe, dst, inst, DRCUML_FMOD_FLOOR); | |
| 6979 | 7273 | } |
| 6980 | 7274 | |
| 6981 | ||
| 6982 | /*------------------------------------------------- | |
| 6983 | op_ftoi8c - process a FTOI8C opcode | |
| 6984 | -------------------------------------------------*/ | |
| 6985 | ||
| 6986 | 7275 | static x86code *op_ftoi8c(drcbe_state *drcbe, x86code *dst, const drcuml_instruction *inst) |
| 6987 | 7276 | { |
| 6988 | drcuml_parameter dstp, srcp; | |
| 6989 | int dstreg; | |
| 6990 | ||
| 6991 | /* validate instruction */ | |
| 6992 | assert(inst->size == 4 || inst->size == 8); | |
| 6993 | assert(inst->condflags == DRCUML_COND_ALWAYS); | |
| 6994 | ||
| 6995 | /* normalize parameters */ | |
| 6996 | param_normalize_2(drcbe, inst, &dstp, PTYPE_MR, &srcp, PTYPE_MF); | |
| 6997 | ||
| 6998 | /* pick a target register for the general case */ | |
| 6999 | dstreg = param_select_register(REG_EAX, &dstp, NULL); | |
| 7000 | ||
| 7001 | /* save and set the control word */ | |
| 7002 | emit_stmxcsr_m32(&dst, MABS(drcbe, &drcbe->ssemodesave)); // stmxcsr [ssemodesave] | |
| 7003 | emit_ldmxcsr_m32(&dst, MABS(drcbe, &drcbe->ssecontrol[DRCUML_FMOD_CEIL])); // ldmxcsr fpcontrol[DRCUML_FMOD_CEIL] | |
| 7004 | ||
| 7005 | /* 32-bit form */ | |
| 7006 | if (inst->size == 4) | |
| 7007 | { | |
| 7008 | if (srcp.type == DRCUML_PTYPE_MEMORY) | |
| 7009 | emit_cvtss2si_r64_m32(&dst, dstreg, MABS(drcbe, srcp.value)); // cvtss2si dstreg,[srcp] | |
| 7010 | else if (srcp.type == DRCUML_PTYPE_FLOAT_REGISTER) | |
| 7011 | emit_cvtss2si_r64_r128(&dst, dstreg, srcp.value); // cvtss2si dstreg,srcp | |
| 7012 | } | |
| 7013 | ||
| 7014 | /* 64-bit form */ | |
| 7015 | else if (inst->size == 8) | |
| 7016 | { | |
| 7017 | if (srcp.type == DRCUML_PTYPE_MEMORY) | |
| 7018 | emit_cvtsd2si_r64_m64(&dst, dstreg, MABS(drcbe, srcp.value)); // cvtsd2si dstreg,[srcp] | |
| 7019 | else if (srcp.type == DRCUML_PTYPE_FLOAT_REGISTER) | |
| 7020 | emit_cvtsd2si_r64_r128(&dst, dstreg, srcp.value); // cvtsd2si dstreg,srcp | |
| 7021 | } | |
| 7022 | ||
| 7023 | /* restore control word and proceed */ | |
| 7024 | emit_mov_p64_r64(drcbe, &dst, &dstp, dstreg); // mov dstp,dstreg | |
| 7025 | emit_ldmxcsr_m32(&dst, MABS(drcbe, &drcbe->ssemodesave)); // ldmxcsr [ssemodesave] | |
| 7026 | return dst; | |
| 7277 | return op_ftoi8x(drcbe, dst, inst, DRCUML_FMOD_CEIL); | |
| 7027 | 7278 | } |
| 7028 | 7279 | |
| 7029 | 7280 |
| r2724 | r2725 | |
|---|---|---|
| 154 | 154 | float * pfloat; |
| 155 | 155 | double * pdouble; |
| 156 | 156 | void (*cfunc)(void *); |
| 157 | drcuml_machine_state *state; | |
| 157 | 158 | const drcuml_codehandle *handle; |
| 158 | 159 | const drcbec_instruction *inst; |
| 159 | 160 | const drcbec_instruction **pinst; |
| r2724 | r2725 | |
| 172 | 173 | static int drcbec_execute(drcbe_state *state, drcuml_codehandle *entry); |
| 173 | 174 | static void drcbec_generate(drcbe_state *drcbe, drcuml_block *block, const drcuml_instruction *instlist, UINT32 numinst); |
| 174 | 175 | static int drcbec_hash_exists(drcbe_state *state, UINT32 mode, UINT32 pc); |
| 176 | static void drcbec_get_info(drcbe_state *state, drcbe_info *info); | |
| 175 | 177 | |
| 176 | 178 | /* private helper functions */ |
| 177 | static void output_parameter(drcbe_state *drcbe, drcbec_instruction **dstptr, void **immedptr, int size, | |
| 179 | static void output_parameter(drcbe_state *drcbe, drcbec_instruction **dstptr, void **immedptr, int size, | |
| 178 | 180 | static void fixup_label(void *parameter, drccodeptr labelcodeptr); |
| 179 | 181 | static int dmulu(UINT64 *dstlo, UINT64 *dsthi, UINT64 src1, UINT64 src2, int flags); |
| 180 | 182 | static int dmuls(UINT64 *dstlo, UINT64 *dsthi, INT64 src1, INT64 src2, int flags); |
| r2724 | r2725 | |
| 236 | 238 | drcbec_reset, |
| 237 | 239 | drcbec_execute, |
| 238 | 240 | drcbec_generate, |
| 239 | drcbec_hash_exists | |
| 241 | drcbec_hash_exists, | |
| 242 | drcbec_get_info | |
| 240 | 243 | }; |
| 241 | 244 | |
| 242 | 245 | |
| r2724 | r2725 | |
| 331 | 334 | for (inum = 0; inum < numinst; inum++) |
| 332 | 335 | { |
| 333 | 336 | const drcuml_instruction *inst = &instlist[inum]; |
| 337 | UINT8 psize[ARRAY_LENGTH(instlist->param)]; | |
| 334 | 338 | drcuml_instruction modified_inst; |
| 335 | int immed | |
| 339 | int immed | |
| 336 | 340 | void *immed; |
| 337 | 341 | |
| 338 | 342 | /* handle most instructions generally, but a few special cases */ |
| r2724 | r2725 | |
| 391 | 395 | inst = &modified_inst; |
| 392 | 396 | } |
| 393 | 397 | |
| 394 | /* determine the maximum size of an immediate; mostly this is just the instruction size */ | |
| 395 | immedsize = inst->size; | |
| 398 | /* determine the operand size for each operand; mostly this is just the instruction size */ | |
| 399 | for (pnum = 0; pnum < inst->numparams; pnum++) | |
| 400 | psize[pnum] = inst->size; | |
| 401 | if ((inst->opcode >= DRCUML_OP_LOAD1U && inst->opcode <= DRCUML_OP_LOAD8U) || inst->opcode == DRCUML_OP_FLOAD) | |
| 402 | psize[2] = 4; | |
| 403 | if ((inst->opcode >= DRCUML_OP_STORE1 && inst->opcode <= DRCUML_OP_STORE8) || inst->opcode == DRCUML_OP_FSTORE) | |
| 404 | psize[1] = 4; | |
| 405 | if ((inst->opcode >= DRCUML_OP_READ1U && inst->opcode <= DRCUML_OP_READ8M) || inst->opcode == DRCUML_OP_FREAD) | |
| 406 | psize[1] = psize[2] = 4; | |
| 407 | if ((inst->opcode >= DRCUML_OP_WRITE1 && inst->opcode <= DRCUML_OP_WRIT8M) || inst->opcode == DRCUML_OP_FWRITE) | |
| 408 | psize[0] = psize[1] = 4; | |
| 409 | if (inst->opcode >= DRCUML_OP_FTOI4 && inst->opcode <= DRCUML_OP_FTOI4C) | |
| 410 | psize[0] = 4; | |
| 411 | if (inst->opcode >= DRCUML_OP_FTOI8 && inst->opcode <= DRCUML_OP_FTOI8C) | |
| 412 | psize[0] = 8; | |
| 413 | if ((inst->opcode >= DRCUML_OP_ZEXT1 && inst->opcode <= DRCUML_OP_SEXT4) || inst->opcode == DRCUML_OP_FFRFS || inst->opcode == DRCUML_OP_FFRI4) | |
| 414 | psize[1] = 4; | |
| 396 | 415 | if (inst->opcode == DRCUML_OP_FFRFD || inst->opcode == DRCUML_OP_FFRI8) |
| 397 | | |
| 416 | p | |
| 398 | 417 | |
| 399 | 418 | /* count how many bytes of immediates we need */ |
| 400 | 419 | immedbytes = 0; |
| 401 | 420 | for (pnum = 0; pnum < inst->numparams; pnum++) |
| 402 | 421 | if (inst->param[pnum].type == DRCUML_PTYPE_MAPVAR || |
| 403 | 422 | (inst->param[pnum].type == DRCUML_PTYPE_IMMEDIATE && inst->param[pnum].value != 0)) |
| 404 | immedbytes += | |
| 423 | immedbytes += p | |
| 405 | 424 | |
| 406 | 425 | /* compute how many instruction words we need for that */ |
| 407 | 426 | immedwords = (immedbytes + sizeof(drcbec_instruction) - 1) / sizeof(drcbec_instruction); |
| r2724 | r2725 | |
| 414 | 433 | |
| 415 | 434 | /* output each of the parameters */ |
| 416 | 435 | for (pnum = 0; pnum < inst->numparams; pnum++) |
| 417 | output_parameter(drcbe, &dst, &immed, | |
| 436 | output_parameter(drcbe, &dst, &immed, p | |
| 418 | 437 | |
| 419 | 438 | /* point past the end of the immediates */ |
| 420 | 439 | dst += immedwords; |
| r2724 | r2725 | |
| 444 | 463 | } |
| 445 | 464 | |
| 446 | 465 | |
| 466 | /*------------------------------------------------- | |
| 467 | drcbec_get_info - return information about | |
| 468 | the back-end implementation | |
| 469 | -------------------------------------------------*/ | |
| 447 | 470 | |
| 471 | static void drcbec_get_info(drcbe_state *state, drcbe_info *info) | |
| 472 | { | |
| 473 | info->direct_iregs = 0; | |
| 474 | info->direct_fregs = 0; | |
| 475 | } | |
| 476 | ||
| 477 | ||
| 478 | ||
| 448 | 479 | /*************************************************************************** |
| 449 | 480 | BACK-END EXECUTION |
| 450 | 481 | ***************************************************************************/ |
| r2724 | r2725 | |
| 497 | 528 | if (newinst == NULL) |
| 498 | 529 | { |
| 499 | 530 | assert(sp < ARRAY_LENGTH(callstack)); |
| 500 | drcbe->state.exp | |
| 531 | drcbe->state.exp | |
| 501 | 532 | newinst = (const drcbec_instruction *)drcuml_handle_codeptr(inst[2].handle); |
| 502 | 533 | callstack[sp++] = inst; |
| 503 | 534 | } |
| r2724 | r2725 | |
| 558 | 589 | assert(sp < ARRAY_LENGTH(callstack)); |
| 559 | 590 | newinst = (const drcbec_instruction *)drcuml_handle_codeptr(inst[0].handle); |
| 560 | 591 | assert_in_cache(drcbe->cache, newinst); |
| 561 | drcbe->state.exp | |
| 592 | drcbe->state.exp | |
| 562 | 593 | callstack[sp++] = inst; |
| 563 | 594 | inst = newinst; |
| 564 | 595 | continue; |
| r2724 | r2725 | |
| 589 | 620 | break; |
| 590 | 621 | |
| 591 | 622 | case MAKE_OPCODE_SHORT(DRCUML_OP_GETEXP, 4, 0): /* GETEXP dst */ |
| 592 | PARAM0 = drcbe->state.exp | |
| 623 | PARAM0 = drcbe->state.exp | |
| 593 | 624 | break; |
| 594 | 625 | |
| 626 | case MAKE_OPCODE_SHORT(DRCUML_OP_SAVE, 4, 0): /* SAVE dst */ | |
| 627 | *inst[0].state = drcbe->state; | |
| 628 | inst[0].state->flags = flags; | |
| 629 | break; | |
| 595 | 630 | |
| 631 | case MAKE_OPCODE_SHORT(DRCUML_OP_RESTORE, 4, 0): /* RESTORE dst */ | |
| 632 | drcbe->state = *inst[0].state; | |
| 633 | flags = inst[0].state->flags; | |
| 634 | break; | |
| 635 | ||
| 636 | ||
| 596 | 637 | /* ----------------------- 32-Bit Integer Operations ----------------------- */ |
| 597 | 638 | |
| 598 | 639 | case MAKE_OPCODE_SHORT(DRCUML_OP_LOAD1U, 4, 0): /* LOAD1U dst,base,index */ |
| r2724 | r2725 | |
| 704 | 745 | PARAM0 = (INT16)PARAM1; |
| 705 | 746 | break; |
| 706 | 747 | |
| 748 | case MAKE_OPCODE_SHORT(DRCUML_OP_XTRACT, 4, 0): /* XTRACT dst,src,count,mask[,f] */ | |
| 749 | shift = PARAM2 & 31; | |
| 750 | PARAM0 = ((PARAM1 << shift) | (PARAM1 >> (32 - shift))) & PARAM3; | |
| 751 | break; | |
| 752 | ||
| 753 | case MAKE_OPCODE_SHORT(DRCUML_OP_INSERT, 4, 0): /* INSERT dst,src,count,mask[,f] */ | |
| 754 | shift = PARAM2 & 31; | |
| 755 | PARAM0 = (PARAM0 & ~PARAM3) | (((PARAM1 << shift) | (PARAM1 >> (32 - shift))) & PARAM3); | |
| 756 | break; | |
| 757 | ||
| 707 | 758 | case MAKE_OPCODE_SHORT(DRCUML_OP_ADD, 4, 0): /* ADD dst,src1,src2[,f] */ |
| 708 | 759 | PARAM0 = PARAM1 + PARAM2; |
| 709 | 760 | break; |
| r2724 | r2725 | |
| 720 | 771 | |
| 721 | 772 | case MAKE_OPCODE_SHORT(DRCUML_OP_ADDC, 4, 1): |
| 722 | 773 | temp32 = PARAM1 + PARAM2 + (flags & DRCUML_FLAG_C); |
| 723 | flags = FLAGS32_NZCV_ADD(temp32, PARAM1, PARAM2); | |
| 774 | if (PARAM2 + 1 != 0) | |
| 775 | flags = FLAGS32_NZCV_ADD(temp32, PARAM1, PARAM2 + (flags & DRCUML_FLAG_C)); | |
| 776 | else | |
| 777 | flags = FLAGS32_NZCV_ADD(temp32, PARAM1 + (flags & DRCUML_FLAG_C), PARAM2); | |
| 724 | 778 | PARAM0 = temp32; |
| 725 | 779 | break; |
| 726 | 780 | |
| r2724 | r2725 | |
| 740 | 794 | |
| 741 | 795 | case MAKE_OPCODE_SHORT(DRCUML_OP_SUBB, 4, 1): |
| 742 | 796 | temp32 = PARAM1 - PARAM2 - (flags & DRCUML_FLAG_C); |
| 743 | flags = FLAGS32_NZCV_SUB(temp32, PARAM1, PARAM2); | |
| 797 | if (PARAM2 + 1 != 0) | |
| 798 | flags = FLAGS32_NZCV_SUB(temp32, PARAM1, PARAM2 + (flags & DRCUML_FLAG_C)); | |
| 799 | else | |
| 800 | flags = FLAGS32_NZCV_SUB(temp32, PARAM1 - (flags & DRCUML_FLAG_C), PARAM2); | |
| 744 | 801 | PARAM0 = temp32; |
| 745 | 802 | break; |
| 746 | 803 | |
| r2724 | r2725 | |
| 848 | 905 | PARAM0 = temp32; |
| 849 | 906 | break; |
| 850 | 907 | |
| 908 | case MAKE_OPCODE_SHORT(DRCUML_OP_LZCNT, 4, 0): /* LZCNT dst,src[,f] */ | |
| 909 | PARAM0 = count_leading_zeros(PARAM1); | |
| 910 | break; | |
| 911 | ||
| 912 | case MAKE_OPCODE_SHORT(DRCUML_OP_LZCNT, 4, 1): | |
| 913 | temp32 = count_leading_zeros(PARAM1); | |
| 914 | flags = (temp32 == 0) ? DRCUML_FLAG_Z : 0; | |
| 915 | PARAM0 = temp32; | |
| 916 | break; | |
| 917 | ||
| 851 | 918 | case MAKE_OPCODE_SHORT(DRCUML_OP_SHL, 4, 0): /* SHL dst,src,count[,f] */ |
| 852 | 919 | PARAM0 = PARAM1 << (PARAM2 & 31); |
| 853 | 920 | break; |
| r2724 | r2725 | |
| 1081 | 1148 | break; |
| 1082 | 1149 | |
| 1083 | 1150 | case MAKE_OPCODE_SHORT(DRCUML_OP_ZEXT1, 8, 0): /* DZEXT1 dst,src */ |
| 1084 | DPARAM0 = (UINT8) | |
| 1151 | DPARAM0 = (UINT8) | |
| 1085 | 1152 | break; |
| 1086 | 1153 | |
| 1087 | 1154 | case MAKE_OPCODE_SHORT(DRCUML_OP_ZEXT2, 8, 0): /* DZEXT2 dst,src */ |
| 1088 | DPARAM0 = (UINT16) | |
| 1155 | DPARAM0 = (UINT16) | |
| 1089 | 1156 | break; |
| 1090 | 1157 | |
| 1091 | 1158 | case MAKE_OPCODE_SHORT(DRCUML_OP_ZEXT4, 8, 0): /* DZEXT4 dst,src */ |
| 1092 | DPARAM0 = (UINT32) | |
| 1159 | DPARAM0 = (UINT32) | |
| 1093 | 1160 | break; |
| 1094 | 1161 | |
| 1095 | 1162 | case MAKE_OPCODE_SHORT(DRCUML_OP_SEXT1, 8, 0): /* DSEXT1 dst,src */ |
| 1096 | DPARAM0 = (INT8) | |
| 1163 | DPARAM0 = (INT8) | |
| 1097 | 1164 | break; |
| 1098 | 1165 | |
| 1099 | 1166 | case MAKE_OPCODE_SHORT(DRCUML_OP_SEXT2, 8, 0): /* DSEXT2 dst,src */ |
| 1100 | DPARAM0 = (INT16) | |
| 1167 | DPARAM0 = (INT16) | |
| 1101 | 1168 | break; |
| 1102 | 1169 | |
| 1103 | 1170 | case MAKE_OPCODE_SHORT(DRCUML_OP_SEXT4, 8, 0): /* DSEXT4 dst,src */ |
| 1104 | DPARAM0 = (INT32) | |
| 1171 | DPARAM0 = (INT32) | |
| 1105 | 1172 | break; |
| 1106 | 1173 | |
| 1174 | case MAKE_OPCODE_SHORT(DRCUML_OP_XTRACT, 8, 0): /* DXTRACT dst,src,count,mask[,f] */ | |
| 1175 | shift = DPARAM2 & 63; | |
| 1176 | DPARAM0 = ((DPARAM1 << shift) | (DPARAM1 >> (64 - shift))) & DPARAM3; | |
| 1177 | break; | |
| 1178 | ||
| 1179 | case MAKE_OPCODE_SHORT(DRCUML_OP_INSERT, 8, 0): /* DINSERT dst,src,count,mask[,f] */ | |
| 1180 | shift = DPARAM2 & 63; | |
| 1181 | DPARAM0 = (DPARAM0 & ~DPARAM3) | (((DPARAM1 << shift) | (DPARAM1 >> (64 - shift))) & DPARAM3); | |
| 1182 | break; | |
| 1183 | ||
| 1107 | 1184 | case MAKE_OPCODE_SHORT(DRCUML_OP_ADD, 8, 0): /* DADD dst,src1,src2[,f] */ |
| 1108 | 1185 | DPARAM0 = DPARAM1 + DPARAM2; |
| 1109 | 1186 | break; |
| r2724 | r2725 | |
| 1120 | 1197 | |
| 1121 | 1198 | case MAKE_OPCODE_SHORT(DRCUML_OP_ADDC, 8, 1): |
| 1122 | 1199 | temp64 = DPARAM1 + DPARAM2 + (flags & DRCUML_FLAG_C); |
| 1123 | flags = FLAGS64_NZCV_ADD(temp64, DPARAM1, DPARAM2); | |
| 1200 | if (DPARAM2 + 1 != 0) | |
| 1201 | flags = FLAGS64_NZCV_ADD(temp64, DPARAM1, DPARAM2 + (flags & DRCUML_FLAG_C)); | |
| 1202 | else | |
| 1203 | flags = FLAGS64_NZCV_ADD(temp64, DPARAM1 + (flags & DRCUML_FLAG_C), DPARAM2); | |
| 1124 | 1204 | DPARAM0 = temp64; |
| 1125 | 1205 | break; |
| 1126 | 1206 | |
| r2724 | r2725 | |
| 1140 | 1220 | |
| 1141 | 1221 | case MAKE_OPCODE_SHORT(DRCUML_OP_SUBB, 8, 1): |
| 1142 | 1222 | temp64 = DPARAM1 - DPARAM2 - (flags & DRCUML_FLAG_C); |
| 1143 | flags = FLAGS64_NZCV_SUB(temp64, DPARAM1, DPARAM2); | |
| 1223 | if (DPARAM2 + 1 != 0) | |
| 1224 | flags = FLAGS64_NZCV_SUB(temp64, DPARAM1, DPARAM2 + (flags & DRCUML_FLAG_C)); | |
| 1225 | else | |
| 1226 | flags = FLAGS64_NZCV_SUB(temp64, DPARAM1 - (flags & DRCUML_FLAG_C), DPARAM2); | |
| 1144 | 1227 | DPARAM0 = temp64; |
| 1145 | 1228 | break; |
| 1146 | 1229 | |
| r2724 | r2725 | |
| 1238 | 1321 | DPARAM0 = temp64; |
| 1239 | 1322 | break; |
| 1240 | 1323 | |
| 1324 | case MAKE_OPCODE_SHORT(DRCUML_OP_LZCNT, 8, 0): /* DLZCNT dst,src[,f] */ | |
| 1325 | if ((UINT32)(DPARAM1 >> 32) != 0) | |
| 1326 | DPARAM0 = count_leading_zeros(DPARAM1 >> 32); | |
| 1327 | else | |
| 1328 | DPARAM0 = 32 + count_leading_zeros(DPARAM1); | |
| 1329 | break; | |
| 1330 | ||
| 1331 | case MAKE_OPCODE_SHORT(DRCUML_OP_LZCNT, 8, 1): | |
| 1332 | if ((UINT32)(DPARAM1 >> 32) != 0) | |
| 1333 | temp32 = count_leading_zeros(DPARAM1 >> 32); | |
| 1334 | else | |
| 1335 | temp32 = 32 + count_leading_zeros(DPARAM1); | |
| 1336 | flags = (temp32 == 0) ? DRCUML_FLAG_Z : 0; | |
| 1337 | DPARAM0 = temp32; | |
| 1338 | break; | |
| 1339 | ||
| 1241 | 1340 | case MAKE_OPCODE_SHORT(DRCUML_OP_SHL, 8, 0): /* DSHL dst,src,count[,f] */ |
| 1242 | 1341 | DPARAM0 = DPARAM1 << (DPARAM2 & 63); |
| 1243 | 1342 | break; |
| r2724 | r2725 | |
| 1489 | 1588 | break; |
| 1490 | 1589 | |
| 1491 | 1590 | case MAKE_OPCODE_SHORT(DRCUML_OP_FREAD, 8, 0): /* FDREAD dst,space,src1 */ |
| 1492 | PARAM0 = (UINT64)(*active_address_space[PARAM1].accessors->read_qword)(PARAM2); | |
| 1591 | DPARAM0 = (UINT64)(*active_address_space[PARAM1].accessors->read_qword)(PARAM2); | |
| 1493 | 1592 | break; |
| 1494 | 1593 | |
| 1495 | 1594 | case MAKE_OPCODE_SHORT(DRCUML_OP_FWRITE, 8, 0): /* FDWRITE space,dst,src1 */ |
| 1496 | (*active_address_space[PARAM0].accessors->write_qword)(PARAM1, PARAM2); | |
| 1595 | (*active_address_space[PARAM0].accessors->write_qword)(PARAM1, DPARAM2); | |
| 1497 | 1596 | break; |
| 1498 | 1597 | |
| 1499 | 1598 | case MAKE_OPCODE_SHORT(DRCUML_OP_FMOV, 8, 1): /* FDMOV dst,src[,c] */ |
| r2724 | r2725 | |
| 1634 | 1733 | output_parameter - output a parameter |
| 1635 | 1734 | -------------------------------------------------*/ |
| 1636 | 1735 | |
| 1637 | static void output_parameter(drcbe_state *drcbe, drcbec_instruction **dstptr, void **immedptr, int size, | |
| 1736 | static void output_parameter(drcbe_state *drcbe, drcbec_instruction **dstptr, void **immedptr, int size, | |
| 1638 | 1737 | { |
| 1639 | 1738 | drcbec_instruction *dst = *dstptr; |
| 1640 | 1739 | void *immed = *immedptr; |
| r2724 | r2725 | |
| 1655 | 1754 | else |
| 1656 | 1755 | { |
| 1657 | 1756 | (dst++)->v = immed; |
| 1658 | if ( | |
| 1757 | if ( | |
| 1659 | 1758 | *(UINT32 *)immed = (UINT32)param->value; |
| 1660 | 1759 | else |
| 1661 | 1760 | *(UINT64 *)immed = (UINT64)param->value; |
| 1662 | immed = (UINT8 *)immed + | |
| 1761 | immed = (UINT8 *)immed + | |
| 1663 | 1762 | } |
| 1664 | 1763 | break; |
| 1665 | 1764 | |
| 1666 | 1765 | /* int registers point to the appropriate part of the integer register state */ |
| 1667 | 1766 | case DRCUML_PTYPE_INT_REGISTER: |
| 1668 | 1767 | if (size == 4) |
| 1669 | (dst++)->puint32 = &drcbe->state.r[param->value - DRCUML_REG_I0].l; | |
| 1768 | (dst++)->puint32 = &drcbe->state.r[param->value - DRCUML_REG_I0].w.l; | |
| 1670 | 1769 | else |
| 1671 | 1770 | (dst++)->puint64 = &drcbe->state.r[param->value - DRCUML_REG_I0].d; |
| 1672 | 1771 | break; |
| r2724 | r2725 | |
| 1674 | 1773 | /* float registers point to the appropriate part of the floating point register state */ |
| 1675 | 1774 | case DRCUML_PTYPE_FLOAT_REGISTER: |
| 1676 | 1775 | if (size == 4) |
| 1677 | (dst++)->pfloat = &drcbe->state.f[param->value - DRCUML_REG_F0].l; | |
| 1776 | (dst++)->pfloat = &drcbe->state.f[param->value - DRCUML_REG_F0].s.l; | |
| 1678 | 1777 | else |
| 1679 | 1778 | (dst++)->pdouble = &drcbe->state.f[param->value - DRCUML_REG_F0].d; |
| 1680 | 1779 | break; |
| r0 | r2725 | |
|---|---|---|
| 1 | /* | |
| 2 | PowerPC 4xx/6xx Dynamic Recompiler for x86 | |
| 3 | ||
| 4 | Written by Ville Linde | |
| 5 | */ | |
| 6 | ||
| 7 | #include "debugger.h" | |
| 8 | #include "ppc.h" | |
| 9 | #include "cpu/x86drc.h" | |
| 10 | ||
| 11 | ||
| 12 | #define PPC_DRC | |
| 13 | #define LOG_CODE (0) | |
| 14 | ||
| 15 | #define CACHE_SIZE (16 * 1024 * 1024) | |
| 16 | #define MAX_INSTRUCTIONS 512 | |
| 17 | ||
| 18 | ||
| 19 | #if (HAS_PPC603) | |
| 20 | static void ppcdrc603_init(int index, int clock, const void *_config, int (*irqcallback)(int)); | |
| 21 | static void ppcdrc603_exit(void); | |
| 22 | #endif | |
| 23 | #if (HAS_PPC601 || HAS_PPC603 || HAS_MPC8240 || HAS_PPC604) | |
| 24 | static void ppcdrc603_reset(void); | |
| 25 | static int ppcdrc603_execute(int cycles); | |
| 26 | static void ppcdrc603_set_irq_line(int irqline, int state); | |
| 27 | #endif | |
| 28 | #if (HAS_PPC602) | |
| 29 | static void ppcdrc602_init(int index, int clock, const void *_config, int (*irqcallback)(int)); | |
| 30 | static void ppcdrc602_exit(void); | |
| 31 | static void ppcdrc602_reset(void); | |
| 32 | static int ppcdrc602_execute(int cycles); | |
| 33 | static void ppcdrc602_set_irq_line(int irqline, int state); | |
| 34 | #endif | |
| 35 | #if (HAS_PPC403) | |
| 36 | static UINT8 ppc403_spu_r(UINT32 a); | |
| 37 | static void ppc403_spu_w(UINT32 a, UINT8 d); | |
| 38 | static void ppcdrc403_init(int index, int clock, const void *_config, int (*irqcallback)(int)); | |
| 39 | static void ppcdrc403_exit(void); | |
| 40 | static void ppcdrc403_reset(void); | |
| 41 | static int ppcdrc403_execute(int cycles); | |
| 42 | static void ppcdrc403_set_irq_line(int irqline, int state); | |
| 43 | #endif | |
| 44 | ||
| 45 | static void ppcdrc_init(void); | |
| 46 | static void ppcdrc_reset(drc_core *drc); | |
| 47 | static void ppcdrc_recompile(drc_core *drc); | |
| 48 | static void ppcdrc_entrygen(drc_core *drc); | |
| 49 | ||
| 50 | #define RD ((op >> 21) & 0x1F) | |
| 51 | #define RT ((op >> 21) & 0x1f) | |
| 52 | #define RS ((op >> 21) & 0x1f) | |
| 53 | #define RA ((op >> 16) & 0x1f) | |
| 54 | #define RB ((op >> 11) & 0x1f) | |
| 55 | #define RC ((op >> 6) & 0x1f) | |
| 56 | ||
| 57 | #define MB ((op >> 6) & 0x1f) | |
| 58 | #define ME ((op >> 1) & 0x1f) | |
| 59 | #define SH ((op >> 11) & 0x1f) | |
| 60 | #define BO ((op >> 21) & 0x1f) | |
| 61 | #define BI ((op >> 16) & 0x1f) | |
| 62 | #define CRFD ((op >> 23) & 0x7) | |
| 63 | #define CRFA ((op >> 18) & 0x7) | |
| 64 | #define FXM ((op >> 12) & 0xff) | |
| 65 | #define SPR (((op >> 16) & 0x1f) | ((op >> 6) & 0x3e0)) | |
| 66 | ||
| 67 | #define SIMM16 (INT32)(INT16)(op & 0xffff) | |
| 68 | #define UIMM16 (UINT32)(op & 0xffff) | |
| 69 | ||
| 70 | #define RCBIT (op & 0x1) | |
| 71 | #define OEBIT (op & 0x400) | |
| 72 | #define AABIT (op & 0x2) | |
| 73 | #define LKBIT (op & 0x1) | |
| 74 | ||
| 75 | #define REG(x) (ppc.r[x]) | |
| 76 | #define LR (ppc.lr) | |
| 77 | #define CTR (ppc.ctr) | |
| 78 | #define XER (ppc.xer) | |
| 79 | #define CR(x) (ppc.cr[x]) | |
| 80 | #define MSR (ppc.msr) | |
| 81 | #define SRR0 (ppc.srr0) | |
| 82 | #define SRR1 (ppc.srr1) | |
| 83 | #define SRR2 (ppc.srr2) | |
| 84 | #define SRR3 (ppc.srr3) | |
| 85 | #define EVPR (ppc.evpr) | |
| 86 | #define EXIER (ppc.exier) | |
| 87 | #define EXISR (ppc.exisr) | |
| 88 | #define DEC (ppc.dec) | |
| 89 | ||
| 90 | ||
| 91 | // Stuff added for the 6xx | |
| 92 | #define FPR(x) (ppc.fpr[x]) | |
| 93 | #define FM ((op >> 17) & 0xFF) | |
| 94 | #define SPRF (((op >> 6) & 0x3E0) | ((op >> 16) & 0x1F)) | |
| 95 | ||
| 96 | ||
| 97 | #define CHECK_SUPERVISOR() \ | |
| 98 | if((ppc.msr & 0x4000) != 0){ \ | |
| 99 | } | |
| 100 | ||
| 101 | #define CHECK_FPU_AVAILABLE() \ | |
| 102 | if((ppc.msr & 0x2000) == 0){ \ | |
| 103 | } | |
| 104 | ||
| 105 | #if (HAS_PPC601||HAS_PPC602||HAS_PPC603||HAS_PPC604||HAS_MPC8240) | |
| 106 | static UINT32 ppc_field_xlat[256]; | |
| 107 | #endif | |
| 108 | ||
| 109 | ||
| 110 | ||
| 111 | #define FPSCR_FX 0x80000000 | |
| 112 | #define FPSCR_FEX 0x40000000 | |
| 113 | #define FPSCR_VX 0x20000000 | |
| 114 | #define FPSCR_OX 0x10000000 | |
| 115 | #define FPSCR_UX 0x08000000 | |
| 116 | #define FPSCR_ZX 0x04000000 | |
| 117 | #define FPSCR_XX 0x02000000 | |
| 118 | ||
| 119 | ||
| 120 | ||
| 121 | #define BITMASK_0(n) (UINT32)(((UINT64)1 << n) - 1) | |
| 122 | #define CRBIT(x) ((ppc.cr[x / 4] & (1 << (3 - (x % 4)))) ? 1 : 0) | |
| 123 | #define _BIT(n) (1 << (n)) | |
| 124 | #define GET_ROTATE_MASK(mb,me) (ppc_rotate_mask[mb][me]) | |
| 125 | #define ADD_CA(r,a,b) ((UINT32)r < (UINT32)a) | |
| 126 | #define SUB_CA(r,a,b) (!((UINT32)a < (UINT32)b)) | |
| 127 | #define ADD_OV(r,a,b) ((~((a) ^ (b)) & ((a) ^ (r))) & 0x80000000) | |
| 128 | #define SUB_OV(r,a,b) (( ((a) ^ (b)) & ((a) ^ (r))) & 0x80000000) | |
| 129 | ||
| 130 | #define XER_SO 0x80000000 | |
| 131 | #define XER_OV 0x40000000 | |
| 132 | #define XER_CA 0x20000000 | |
| 133 | ||
| 134 | #define MSR_AP 0x00800000 /* Access privilege state (PPC602) */ | |
| 135 | #define MSR_SA 0x00400000 /* Supervisor access mode (PPC602) */ | |
| 136 | #define MSR_POW 0x00040000 /* Power Management Enable */ | |
| 137 | #define MSR_WE 0x00040000 | |
| 138 | #define MSR_CE 0x00020000 | |
| 139 | #define MSR_ILE 0x00010000 /* Interrupt Little Endian Mode */ | |
| 140 | #define MSR_EE 0x00008000 /* External Interrupt Enable */ | |
| 141 | #define MSR_PR 0x00004000 /* Problem State */ | |
| 142 | #define MSR_FP 0x00002000 /* Floating Point Available */ | |
| 143 | #define MSR_ME 0x00001000 /* Machine Check Enable */ | |
| 144 | #define MSR_FE0 0x00000800 | |
| 145 | #define MSR_SE 0x00000400 /* Single Step Trace Enable */ | |
| 146 | #define MSR_BE 0x00000200 /* Branch Trace Enable */ | |
| 147 | #define MSR_DE 0x00000200 | |
| 148 | #define MSR_FE1 0x00000100 | |
| 149 | #define MSR_IP 0x00000040 /* Interrupt Prefix */ | |
| 150 | #define MSR_IR 0x00000020 /* Instruction Relocate */ | |
| 151 | #define MSR_DR 0x00000010 /* Data Relocate */ | |
| 152 | #define MSR_PE 0x00000008 | |
| 153 | #define MSR_PX 0x00000004 | |
| 154 | #define MSR_RI 0x00000002 /* Recoverable Interrupt Enable */ | |
| 155 | #define MSR_LE 0x00000001 | |
| 156 | ||
| 157 | #define TSR_ENW 0x80000000 | |
| 158 | #define TSR_WIS 0x40000000 | |
| 159 | ||
| 160 | #define BYTE_REVERSE16(x) ((((x) >> 8) & 0xff) | (((x) << 8) & 0xff00)) | |
| 161 | #define BYTE_REVERSE32(x) ((((x) >> 24) & 0xff) | (((x) >> 8) & 0xff00) | (((x) << 8) & 0xff0000) | (((x) << 24) & 0xff000000)) | |
| 162 | ||
| 163 | typedef struct { | |
| 164 | UINT32 cr; | |
| 165 | UINT32 da; | |
| 166 | UINT32 sa; | |
| 167 | UINT32 ct; | |
| 168 | UINT32 cc; | |
| 169 | } DMA_REGS; | |
| 170 | ||
| 171 | typedef struct { | |
| 172 | UINT8 spls; | |
| 173 | UINT8 sphs; | |
| 174 | UINT16 brd; | |
| 175 | UINT8 spctl; | |
| 176 | UINT8 sprc; | |
| 177 | UINT8 sptc; | |
| 178 | UINT8 sprb; | |
| 179 | UINT8 sptb; | |
| 180 | emu_timer *rx_timer; | |
| 181 | emu_timer *tx_timer; | |
| 182 | } SPU_REGS; | |
| 183 | ||
| 184 | typedef union { | |
| 185 | UINT64 id; | |
| 186 | double fd; | |
| 187 | } FPR; | |
| 188 | ||
| 189 | typedef union { | |
| 190 | UINT32 i; | |
| 191 | float f; | |
| 192 | } FPR32; | |
| 193 | ||
| 194 | typedef struct { | |
| 195 | UINT32 u; | |
| 196 | UINT32 l; | |
| 197 | } BATENT; | |
| 198 | ||
| 199 | ||
| 200 | typedef struct { | |
| 201 | UINT32 r[32]; | |
| 202 | UINT32 pc; | |
| 203 | UINT32 npc; | |
| 204 | ||
| 205 | UINT32 lr; | |
| 206 | UINT32 ctr; | |
| 207 | UINT32 xer; | |
| 208 | UINT32 msr; | |
| 209 | UINT8 cr[8]; | |
| 210 | UINT32 pvr; | |
| 211 | UINT32 srr0; | |
| 212 | UINT32 srr1; | |
| 213 | UINT32 srr2; | |
| 214 | UINT32 srr3; | |
| 215 | UINT32 hid0; | |
| 216 | UINT32 hid1; | |
| 217 | UINT32 hid2; | |
| 218 | UINT32 sdr1; | |
| 219 | UINT32 sprg[4]; | |
| 220 | ||
| 221 | UINT32 dsisr; | |
| 222 | UINT32 dar; | |
| 223 | UINT32 ear; | |
| 224 | UINT32 dmiss; | |
| 225 | UINT32 dcmp; | |
| 226 | UINT32 hash1; | |
| 227 | UINT32 hash2; | |
| 228 | UINT32 imiss; | |
| 229 | UINT32 icmp; | |
| 230 | UINT32 rpa; | |
| 231 | ||
| 232 | BATENT ibat[4]; | |
| 233 | BATENT dbat[4]; | |
| 234 | ||
| 235 | UINT32 evpr; | |
| 236 | UINT32 exier; | |
| 237 | UINT32 exisr; | |
| 238 | UINT32 bear; | |
| 239 | UINT32 besr; | |
| 240 | UINT32 iocr; | |
| 241 | UINT32 br[8]; | |
| 242 | UINT32 iabr; | |
| 243 | UINT32 esr; | |
| 244 | UINT32 iccr; | |
| 245 | UINT32 dccr; | |
| 246 | UINT32 pit; | |
| 247 | UINT32 tsr; | |
| 248 | UINT32 tcr; | |
| 249 | UINT32 dbsr; | |
| 250 | UINT32 sgr; | |
| 251 | UINT32 pid; | |
| 252 | UINT32 pbl1, pbl2, pbu1, pbu2; | |
| 253 | UINT32 fit_bit; | |
| 254 | UINT32 fit_int_enable; | |
| 255 | UINT32 wdt_bit; | |
| 256 | UINT32 wdt_int_enable; | |
| 257 | UINT32 dac1, dac2; | |
| 258 | UINT32 iac1, iac2; | |
| 259 | ||
| 260 | SPU_REGS spu; | |
| 261 | DMA_REGS dma[4]; | |
| 262 | UINT32 dmasr; | |
| 263 | ||
| 264 | int reserved; | |
| 265 | UINT32 reserved_address; | |
| 266 | ||
| 267 | int exception_pending; | |
| 268 | ||
| 269 | UINT64 tb; /* 56-bit timebase register */ | |
| 270 | ||
| 271 | int (*irq_callback)(int irqline); | |
| 272 | drc_core *drc; | |
| 273 | UINT32 drcoptions; | |
| 274 | ||
| 275 | x86code * invoke_exception_handler; | |
| 276 | x86code * generate_interrupt_exception; | |
| 277 | x86code * generate_syscall_exception; | |
| 278 | x86code * generate_decrementer_exception; | |
| 279 | x86code * generate_trap_exception; | |
| 280 | x86code * generate_dsi_exception; | |
| 281 | x86code * generate_isi_exception; | |
| 282 | x86code * generate_fit_exception; | |
| 283 | ||
| 284 | // PowerPC 60x specific registers */ | |
| 285 | UINT32 dec, dec_frac; | |
| 286 | UINT32 fpscr; | |
| 287 | ||
| 288 | FPR fpr[32]; | |
| 289 | UINT32 sr[16]; | |
| 290 | ||
| 291 | int is603; | |
| 292 | int is602; | |
| 293 | ||
| 294 | /* PowerPC 602 specific registers */ | |
| 295 | UINT32 lt; | |
| 296 | UINT32 sp; | |
| 297 | UINT32 ibr; | |
| 298 | UINT32 esasrr; | |
| 299 | UINT32 sebr; | |
| 300 | UINT32 ser; | |
| 301 | ||
| 302 | /* PowerPC function pointers for memory accesses/exceptions */ | |
| 303 | UINT8 (*read8)(offs_t address); | |
| 304 | UINT16 (*read16)(offs_t address); | |
| 305 | UINT32 (*read32)(offs_t address); | |
| 306 | UINT64 (*read64)(offs_t address); | |
| 307 | void (*write8)(offs_t address, UINT8 data); | |
| 308 | void (*write16)(offs_t address, UINT16 data); | |
| 309 | void (*write32)(offs_t address, UINT32 data); | |
| 310 | void (*write64)(offs_t address, UINT64 data); | |
| 311 | UINT16 (*read16_unaligned)(offs_t address); | |
| 312 | UINT32 (*read32_unaligned)(offs_t address); | |
| 313 | UINT64 (*read64_unaligned)(offs_t address); | |
| 314 | void (*write16_unaligned)(offs_t address, UINT16 data); | |
| 315 | void (*write32_unaligned)(offs_t address, UINT32 data); | |
| 316 | void (*write64_unaligned)(offs_t address, UINT64 data); | |
| 317 | ||
| 318 | /* saved ESP when entering entry point */ | |
| 319 | UINT32 host_esp; | |
| 320 | ||
| 321 | UINT32 (* optable19[1024])(drc_core *, UINT32); | |
| 322 | UINT32 (* optable31[1024])(drc_core *, UINT32); | |
| 323 | UINT32 (* optable59[1024])(drc_core *, UINT32); | |
| 324 | UINT32 (* optable63[1024])(drc_core *, UINT32); | |
| 325 | UINT32 (* optable[64])(drc_core *, UINT32); | |
| 326 | } PPC_REGS; | |
| 327 | ||
| 328 | ||
| 329 | ||
| 330 | typedef struct { | |
| 331 | int code; | |
| 332 | int subcode; | |
| 333 | UINT32 (* handler)(drc_core *, UINT32); | |
| 334 | } PPC_OPCODE; | |
| 335 | ||
| 336 | ||
| 337 | /* code logging info */ | |
| 338 | typedef struct _code_log_entry code_log_entry; | |
| 339 | struct _code_log_entry | |
| 340 | { | |
| 341 | UINT32 pc; | |
| 342 | UINT32 op; | |
| 343 | void * base; | |
| 344 | }; | |
| 345 | ||
| 346 | ||
| 347 | ||
| 348 | static int ppc_icount; | |
| 349 | static int ppc_tb_base_icount; | |
| 350 | static int ppc_dec_base_icount; | |
| 351 | static int ppc_dec_trigger_cycle; | |
| 352 | static int bus_freq_multiplier = 1; | |
| 353 | static int ppc_fit_trigger_cycle; | |
| 354 | static PPC_REGS ppc; | |
| 355 | static UINT32 ppc_rotate_mask[32][32]; | |
| 356 | ||
| 357 | #define ROPCODE(pc) cpu_readop32(pc) | |
| 358 | #define ROPCODE64(pc) cpu_readop64(DWORD_XOR_BE(pc)) | |
| 359 | ||
| 360 | INLINE void SET_CR0(INT32 rd) | |
| 361 | { | |
| 362 | if( rd < 0 ) { | |
| 363 | CR(0) = 0x8; | |
| 364 | } else if( rd > 0 ) { | |
| 365 | CR(0) = 0x4; | |
| 366 | } else { | |
| 367 | CR(0) = 0x2; | |
| 368 | } | |
| 369 | ||
| 370 | if( XER & XER_SO ) | |
| 371 | CR(0) |= 0x1; | |
| 372 | } | |
| 373 | ||
| 374 | INLINE void SET_CR1(void) | |
| 375 | { | |
| 376 | CR(1) = (ppc.fpscr >> 28) & 0xf; | |
| 377 | } | |
| 378 | ||
| 379 | INLINE void SET_ADD_OV(UINT32 rd, UINT32 ra, UINT32 rb) | |
| 380 | { | |
| 381 | if( ADD_OV(rd, ra, rb) ) | |
| 382 | XER |= XER_SO | XER_OV; | |
| 383 | else | |
| 384 | XER &= ~XER_OV; | |
| 385 | } | |
| 386 | ||
| 387 | INLINE void SET_SUB_OV(UINT32 rd, UINT32 ra, UINT32 rb) | |
| 388 | { | |
| 389 | if( SUB_OV(rd, ra, rb) ) | |
| 390 | XER |= XER_SO | XER_OV; | |
| 391 | else | |
| 392 | XER &= ~XER_OV; | |
| 393 | } | |
| 394 | ||
| 395 | INLINE void SET_ADD_CA(UINT32 rd, UINT32 ra, UINT32 rb) | |
| 396 | { | |
| 397 | if( ADD_CA(rd, ra, rb) ) | |
| 398 | XER |= XER_CA; | |
| 399 | else | |
| 400 | XER &= ~XER_CA; | |
| 401 | } | |
| 402 | ||
| 403 | INLINE void SET_SUB_CA(UINT32 rd, UINT32 ra, UINT32 rb) | |
| 404 | { | |
| 405 | if( SUB_CA(rd, ra, rb) ) | |
| 406 | XER |= XER_CA; | |
| 407 | else | |
| 408 | XER &= ~XER_CA; | |
| 409 | } | |
| 410 | ||
| 411 | INLINE UINT32 check_condition_code(UINT32 bo, UINT32 bi) | |
| 412 | { | |
| 413 | UINT32 ctr_ok; | |
| 414 | UINT32 condition_ok; | |
| 415 | UINT32 bo0 = (bo & 0x10) ? 1 : 0; | |
| 416 | UINT32 bo1 = (bo & 0x08) ? 1 : 0; | |
| 417 | UINT32 bo2 = (bo & 0x04) ? 1 : 0; | |
| 418 | UINT32 bo3 = (bo & 0x02) ? 1 : 0; | |
| 419 | ||
| 420 | if( bo2 == 0 ) | |
| 421 | --CTR; | |
| 422 | ||
| 423 | ctr_ok = bo2 | ((CTR != 0) ^ bo3); | |
| 424 | condition_ok = bo0 | (CRBIT(bi) ^ (~bo1 & 0x1)); | |
| 425 | ||
| 426 | return ctr_ok && condition_ok; | |
| 427 | } | |
| 428 | ||
| 429 | INLINE UINT64 ppc_read_timebase(void) | |
| 430 | { | |
| 431 | int cycles = ppc_tb_base_icount - ppc_icount; | |
| 432 | ||
| 433 | if (ppc.is603 || ppc.is602) | |
| 434 | { | |
| 435 | // timebase is incremented once every four core clock cycles, so adjust the cycles accordingly | |
| 436 | return ppc.tb + (cycles / 4); | |
| 437 | } | |
| 438 | else | |
| 439 | { | |
| 440 | // timebase is incremented once every core cycle on PPC403 | |
| 441 | return ppc.tb + cycles; | |
| 442 | } | |
| 443 | } | |
| 444 | ||
| 445 | INLINE void ppc_write_timebase_l(UINT32 tbl) | |
| 446 | { | |
| 447 | ppc_tb_base_icount = ppc_icount; | |
| 448 | ||
| 449 | ppc.tb &= ~0xffffffff; | |
| 450 | ppc.tb |= tbl; | |
| 451 | } | |
| 452 | ||
| 453 | INLINE void ppc_write_timebase_h(UINT32 tbh) | |
| 454 | { | |
| 455 | ppc_tb_base_icount = ppc_icount; | |
| 456 | ||
| 457 | ppc.tb &= 0xffffffff; | |
| 458 | ppc.tb |= (UINT64)(tbh) << 32; | |
| 459 | } | |
| 460 | ||
| 461 | INLINE UINT32 read_decrementer(void) | |
| 462 | { | |
| 463 | int cycles = ppc_dec_base_icount - ppc_icount; | |
| 464 | ||
| 465 | // decrementer is decremented once every four bus clock cycles, so adjust the cycles accordingly | |
| 466 | return DEC - (cycles / (bus_freq_multiplier * 2)); | |
| 467 | } | |
| 468 | ||
| 469 | INLINE void write_decrementer(UINT32 value) | |
| 470 | { | |
| 471 | ppc_dec_base_icount = ppc_icount + (ppc_dec_base_icount - ppc_icount) % (bus_freq_multiplier * 2); | |
| 472 | ||
| 473 | DEC = value; | |
| 474 | ||
| 475 | // check if decrementer exception occurs during execution | |
| 476 | if ((UINT32)(DEC - ppc_icount) > (UINT32)(DEC)) | |
| 477 | { | |
| 478 | ppc_dec_trigger_cycle = ppc_icount - DEC; | |
| 479 | } | |
| 480 | else | |
| 481 | { | |
| 482 | ppc_dec_trigger_cycle = 0x7fffffff; | |
| 483 | } | |
| 484 | } | |
| 485 | ||
| 486 | /*********************************************************************/ | |
| 487 | ||
| 488 | INLINE void ppc_exception(int exception_type) | |
| 489 | { | |
| 490 | void *exception_code = NULL; | |
| 491 | void (*invoke_exception_handler)(void *handler); | |
| 492 | ||
| 493 | switch(exception_type) | |
| 494 | { | |
| 495 | case EXCEPTION_DECREMENTER: | |
| 496 | exception_code = ppc.generate_decrementer_exception; | |
| 497 | break; | |
| 498 | case EXCEPTION_DSI: | |
| 499 | exception_code = ppc.generate_dsi_exception; | |
| 500 | break; | |
| 501 | case EXCEPTION_ISI: | |
| 502 | exception_code = ppc.generate_isi_exception; | |
| 503 | break; | |
| 504 | default: | |
| 505 | fatalerror("Unknown exception %d", exception_type); | |
| 506 | break; | |
| 507 | } | |
| 508 | ||
| 509 | memcpy(&invoke_exception_handler, &ppc.invoke_exception_handler, sizeof(invoke_exception_handler)); | |
| 510 | invoke_exception_handler(exception_code); | |
| 511 | } | |
| 512 | ||
| 513 | /*********************************************************************/ | |
| 514 | ||
| 515 | INLINE void ppc_set_spr(int spr, UINT32 value) | |
| 516 | { | |
| 517 | switch (spr) | |
| 518 | { | |
| 519 | case SPR_LR: LR = value; return; | |
| 520 | case SPR_CTR: CTR = value; return; | |
| 521 | case SPR_XER: XER = value; return; | |
| 522 | case SPR_SRR0: ppc.srr0 = value; return; | |
| 523 | case SPR_SRR1: ppc.srr1 = value; return; | |
| 524 | case SPR_SPRG0: ppc.sprg[0] = value; return; | |
| 525 | case SPR_SPRG1: ppc.sprg[1] = value; return; | |
| 526 | case SPR_SPRG2: ppc.sprg[2] = value; return; | |
| 527 | case SPR_SPRG3: ppc.sprg[3] = value; return; | |
| 528 | case SPR_PVR: return; | |
| 529 | } | |
| 530 | ||
| 531 | #if (HAS_PPC603 || HAS_PPC602 || HAS_PPC601 || HAS_PPC604) | |
| 532 | if(ppc.is603 || ppc.is602) { | |
| 533 | switch(spr) | |
| 534 | { | |
| 535 | case SPR603E_DEC: | |
| 536 | if((value & 0x80000000) && !(DEC & 0x80000000)) | |
| 537 | { | |
| 538 | /* trigger interrupt */ | |
| 539 | if( MSR & MSR_EE ) | |
| 540 | ppc_exception(EXCEPTION_DECREMENTER); | |
| 541 | } | |
| 542 | write_decrementer(value); | |
| 543 | return; | |
| 544 | ||
| 545 | case SPR603E_TBL_W: | |
| 546 | case SPR603E_TBL_R: // special 603e case | |
| 547 | ppc_write_timebase_l(value); | |
| 548 | return; | |
| 549 | ||
| 550 | case SPR603E_TBU_R: | |
| 551 | case SPR603E_TBU_W: // special 603e case | |
| 552 | ppc_write_timebase_h(value); | |
| 553 | return; | |
| 554 | ||
| 555 | case SPR603E_HID0: | |
| 556 | ppc.hid0 = value; | |
| 557 | return; | |
| 558 | ||
| 559 | case SPR603E_HID1: | |
| 560 | ppc.hid1 = value; | |
| 561 | return; | |
| 562 | ||
| 563 | case SPR603E_HID2: | |
| 564 | ppc.hid1 = value; | |
| 565 | return; | |
| 566 | ||
| 567 | case SPR603E_DSISR: ppc.dsisr = value; return; | |
| 568 | case SPR603E_DAR: ppc.dar = value; return; | |
| 569 | case SPR603E_EAR: ppc.ear = value; return; | |
| 570 | case SPR603E_DMISS: ppc.dmiss = value; return; | |
| 571 | case SPR603E_DCMP: ppc.dcmp = value; return; | |
| 572 | case SPR603E_HASH1: ppc.hash1 = value; return; | |
| 573 | case SPR603E_HASH2: ppc.hash2 = value; return; | |
| 574 | case SPR603E_IMISS: ppc.imiss = value; return; | |
| 575 | case SPR603E_ICMP: ppc.icmp = value; return; | |
| 576 | case SPR603E_RPA: ppc.rpa = value; return; | |
| 577 | ||
| 578 | case SPR603E_IBAT0L: ppc.ibat[0].l = value; return; | |
| 579 | case SPR603E_IBAT0U: ppc.ibat[0].u = value; return; | |
| 580 | case SPR603E_IBAT1L: ppc.ibat[1].l = value; return; | |
| 581 | case SPR603E_IBAT1U: ppc.ibat[1].u = value; return; | |
| 582 | case SPR603E_IBAT2L: ppc.ibat[2].l = value; return; | |
| 583 | case SPR603E_IBAT2U: ppc.ibat[2].u = value; return; | |
| 584 | case SPR603E_IBAT3L: ppc.ibat[3].l = value; return; | |
| 585 | case SPR603E_IBAT3U: ppc.ibat[3].u = value; return; | |
| 586 | case SPR603E_DBAT0L: ppc.dbat[0].l = value; return; | |
| 587 | case SPR603E_DBAT0U: ppc.dbat[0].u = value; return; | |
| 588 | case SPR603E_DBAT1L: ppc.dbat[1].l = value; return; | |
| 589 | case SPR603E_DBAT1U: ppc.dbat[1].u = value; return; | |
| 590 | case SPR603E_DBAT2L: ppc.dbat[2].l = value; return; | |
| 591 | case SPR603E_DBAT2U: ppc.dbat[2].u = value; return; | |
| 592 | case SPR603E_DBAT3L: ppc.dbat[3].l = value; return; | |
| 593 | case SPR603E_DBAT3U: ppc.dbat[3].u = value; return; | |
| 594 | ||
| 595 | case SPR603E_SDR1: | |
| 596 | ppc.sdr1 = value; | |
| 597 | return; | |
| 598 | ||
| 599 | case SPR603E_IABR: ppc.iabr = value; return; | |
| 600 | } | |
| 601 | } | |
| 602 | #endif | |
| 603 | ||
| 604 | #if (HAS_PPC602) | |
| 605 | if (ppc.is602) { | |
| 606 | switch(spr) | |
| 607 | { | |
| 608 | case SPR602_LT: ppc.lt = value; return; | |
| 609 | case SPR602_IBR: ppc.ibr = value; return; | |
| 610 | case SPR602_SP: ppc.sp = value; return; | |
| 611 | case SPR602_SEBR: ppc.sebr = value; return; | |
| 612 | case SPR602_SER: ppc.ser = value; return; | |
| 613 | case SPR602_TCR: ppc.tcr = value; return; | |
| 614 | } | |
| 615 | } | |
| 616 | #endif | |
| 617 | ||
| 618 | #if (HAS_PPC403) | |
| 619 | if (!ppc.is603 && !ppc.is602) { | |
| 620 | switch(spr) | |
| 621 | { | |
| 622 | case SPR403_TBHI: ppc_write_timebase_h(value); return; | |
| 623 | case SPR403_TBLO: ppc_write_timebase_l(value); return; | |
| 624 | ||
| 625 | case SPR403_TSR: | |
| 626 | ppc.tsr &= ~value; // 1 clears, 0 does nothing | |
| 627 | return; | |
| 628 | ||
| 629 | case SPR403_TCR: | |
| 630 | switch((value >> 24) & 0x3) | |
| 631 | { | |
| 632 | case 0: ppc.fit_bit = 1 << 8; break; | |
| 633 | case 1: ppc.fit_bit = 1 << 12; break; | |
| 634 | case 2: ppc.fit_bit = 1 << 16; break; | |
| 635 | case 3: ppc.fit_bit = 1 << 20; break; | |
| 636 | } | |
| 637 | switch((value >> 30) & 0x3) | |
| 638 | { | |
| 639 | case 0: ppc.wdt_bit = 1 << 16; break; | |
| 640 | case 1: ppc.wdt_bit = 1 << 20; break; | |
| 641 | case 2: ppc.wdt_bit = 1 << 24; break; | |
| 642 | case 3: ppc.wdt_bit = 1 << 28; break; | |
| 643 | } | |
| 644 | ppc.fit_int_enable = (value >> 23) & 0x1; | |
| 645 | ppc.wdt_int_enable = (value >> 27) & 0x1; | |
| 646 | ppc.tcr = value; | |
| 647 | ||
| 648 | if (!ppc.fit_int_enable) | |
| 649 | { | |
| 650 | ppc.exception_pending &= ~0x4; | |
| 651 | } | |
| 652 | return; | |
| 653 | ||
| 654 | case SPR403_ESR: ppc.esr = value; return; | |
| 655 | case SPR403_ICCR: ppc.iccr = value; return; | |
| 656 | case SPR403_DCCR: ppc.dccr = value; return; | |
| 657 | case SPR403_EVPR: EVPR = value & 0xffff0000; return; | |
| 658 | case SPR403_PIT: ppc.pit = value; return; | |
| 659 | case SPR403_SGR: ppc.sgr = value; return; | |
| 660 | case SPR403_DBSR: ppc.dbsr = value; return; | |
| 661 | case SPR403_DCWR: return; | |
| 662 | case SPR403_PID: ppc.pid = value; return; | |
| 663 | case SPR403_PBL1: ppc.pbl1 = value; return; | |
| 664 | case SPR403_PBU1: ppc.pbu1 = value; return; | |
| 665 | case SPR403_PBL2: ppc.pbl2 = value; return; | |
| 666 | case SPR403_PBU2: ppc.pbu2 = value; return; | |
| 667 | case SPR403_SRR2: ppc.srr2 = value; return; | |
| 668 | case SPR403_SRR3: ppc.srr3 = value; return; | |
| 669 | case SPR403_DAC1: ppc.dac1 = value; return; | |
| 670 | case SPR403_DAC2: ppc.dac2 = value; return; | |
| 671 | case SPR403_IAC1: ppc.iac1 = value; return; | |
| 672 | case SPR403_IAC2: ppc.iac2 = value; return; | |
| 673 | } | |
| 674 | } | |
| 675 | #endif | |
| 676 | ||
| 677 | fatalerror("ppc: set_spr: unknown spr %d (%03X) !", spr, spr); | |
| 678 | } | |
| 679 | ||
| 680 | INLINE UINT32 ppc_get_spr(int spr) | |
| 681 | { | |
| 682 | switch(spr) | |
| 683 | { | |
| 684 | case SPR_LR: return LR; | |
| 685 | case SPR_CTR: return CTR; | |
| 686 | case SPR_XER: return XER; | |
| 687 | case SPR_SRR0: return ppc.srr0; | |
| 688 | case SPR_SRR1: return ppc.srr1; | |
| 689 | case SPR_SPRG0: return ppc.sprg[0]; | |
| 690 | case SPR_SPRG1: return ppc.sprg[1]; | |
| 691 | case SPR_SPRG2: return ppc.sprg[2]; | |
| 692 | case SPR_SPRG3: return ppc.sprg[3]; | |
| 693 | case SPR_PVR: return ppc.pvr; | |
| 694 | } | |
| 695 | ||
| 696 | #if (HAS_PPC403) | |
| 697 | if (!ppc.is603 && !ppc.is602) | |
| 698 | { | |
| 699 | switch (spr) | |
| 700 | { | |
| 701 | case SPR403_TBLU: | |
| 702 | case SPR403_TBLO: return (UINT32)(ppc_read_timebase()); | |
| 703 | case SPR403_TBHU: | |
| 704 | case SPR403_TBHI: return (UINT32)(ppc_read_timebase() >> 32); | |
| 705 | ||
| 706 | case SPR403_EVPR: return EVPR; | |
| 707 | case SPR403_ESR: return ppc.esr; | |
| 708 | case SPR403_TCR: return ppc.tcr; | |
| 709 | case SPR403_ICCR: return ppc.iccr; | |
| 710 | case SPR403_DCCR: return ppc.dccr; | |
| 711 | case SPR403_PIT: return ppc.pit; | |
| 712 | case SPR403_DBSR: return ppc.dbsr; | |
| 713 | case SPR403_SGR: return ppc.sgr; | |
| 714 | case SPR403_TSR: return ppc.tsr; | |
| 715 | case SPR403_PBL1: return ppc.pbl1; | |
| 716 | case SPR403_PBU1: return ppc.pbu1; | |
| 717 | case SPR403_PBL2: return ppc.pbl2; | |
| 718 | case SPR403_PBU2: return ppc.pbu2; | |
| 719 | case SPR403_SRR2: return ppc.srr2; | |
| 720 | case SPR403_SRR3: return ppc.srr3; | |
| 721 | case SPR403_DAC1: return ppc.dac1; | |
| 722 | case SPR403_DAC2: return ppc.dac2; | |
| 723 | case SPR403_IAC1: return ppc.iac1; | |
| 724 | case SPR403_IAC2: return ppc.iac2; | |
| 725 | } | |
| 726 | } | |
| 727 | #endif | |
| 728 | ||
| 729 | #if (HAS_PPC602) | |
| 730 | if (ppc.is602) { | |
| 731 | switch(spr) | |
| 732 | { | |
| 733 | case SPR602_LT: return ppc.lt; | |
| 734 | case SPR602_IBR: return ppc.ibr; | |
| 735 | case SPR602_ESASRR: return ppc.esasrr; | |
| 736 | case SPR602_SEBR: return ppc.sebr; | |
| 737 | case SPR602_SER: return ppc.ser; | |
| 738 | case SPR602_SP: return ppc.sp; | |
| 739 | case SPR602_TCR: return ppc.tcr; | |
| 740 | } | |
| 741 | } | |
| 742 | #endif | |
| 743 | ||
| 744 | #if (HAS_PPC603 || HAS_PPC602 || HAS_PPC601 || HAS_PPC604) | |
| 745 | if (ppc.is603 || ppc.is602) | |
| 746 | { | |
| 747 | switch (spr) | |
| 748 | { | |
| 749 | case SPR603E_TBL_R: | |
| 750 | fatalerror("ppc: get_spr: TBL_R "); | |
| 751 | break; | |
| 752 | ||
| 753 | case SPR603E_TBU_R: | |
| 754 | fatalerror("ppc: get_spr: TBU_R "); | |
| 755 | break; | |
| 756 | ||
| 757 | case SPR603E_TBL_W: return (UINT32)(ppc_read_timebase()); | |
| 758 | case SPR603E_TBU_W: return (UINT32)(ppc_read_timebase() >> 32); | |
| 759 | case SPR603E_HID0: return ppc.hid0; | |
| 760 | case SPR603E_HID1: return ppc.hid1; | |
| 761 | case SPR603E_HID2: return ppc.hid2; | |
| 762 | case SPR603E_DEC: return read_decrementer(); | |
| 763 | case SPR603E_SDR1: return ppc.sdr1; | |
| 764 | case SPR603E_DSISR: return ppc.dsisr; | |
| 765 | case SPR603E_DAR: return ppc.dar; | |
| 766 | case SPR603E_EAR: return ppc.ear; | |
| 767 | case SPR603E_IBAT0L: return ppc.ibat[0].l; | |
| 768 | case SPR603E_IBAT0U: return ppc.ibat[0].u; | |
| 769 | case SPR603E_IBAT1L: return ppc.ibat[1].l; | |
| 770 | case SPR603E_IBAT1U: return ppc.ibat[1].u; | |
| 771 | case SPR603E_IBAT2L: return ppc.ibat[2].l; | |
| 772 | case SPR603E_IBAT2U: return ppc.ibat[2].u; | |
| 773 | case SPR603E_IBAT3L: return ppc.ibat[3].l; | |
| 774 | case SPR603E_IBAT3U: return ppc.ibat[3].u; | |
| 775 | case SPR603E_DBAT0L: return ppc.dbat[0].l; | |
| 776 | case SPR603E_DBAT0U: return ppc.dbat[0].u; | |
| 777 | case SPR603E_DBAT1L: return ppc.dbat[1].l; | |
| 778 | case SPR603E_DBAT1U: return ppc.dbat[1].u; | |
| 779 | case SPR603E_DBAT2L: return ppc.dbat[2].l; | |
| 780 | case SPR603E_DBAT2U: return ppc.dbat[2].u; | |
| 781 | case SPR603E_DBAT3L: return ppc.dbat[3].l; | |
| 782 | case SPR603E_DBAT3U: return ppc.dbat[3].u; | |
| 783 | } | |
| 784 | } | |
| 785 | #endif | |
| 786 | ||
| 787 | fatalerror("ppc: get_spr: unknown spr %d (%03X) !", spr, spr); | |
| 788 | return 0; | |
| 789 | } | |
| 790 | ||
| 791 | static UINT8 ppc_read8_translated(offs_t address); | |
| 792 | static UINT16 ppc_read16_translated(offs_t address); | |
| 793 | static UINT32 ppc_read32_translated(offs_t address); | |
| 794 | static UINT64 ppc_read64_translated(offs_t address); | |
| 795 | static void ppc_write8_translated(offs_t address, UINT8 data); | |
| 796 | static void ppc_write16_translated(offs_t address, UINT16 data); | |
| 797 | static void ppc_write32_translated(offs_t address, UINT32 data); | |
| 798 | static void ppc_write64_translated(offs_t address, UINT64 data); | |
| 799 | ||
| 800 | INLINE void ppc_set_msr(UINT32 value) | |
| 801 | { | |
| 802 | if( value & (MSR_ILE | MSR_LE) ) | |
| 803 | fatalerror("ppc: set_msr: little_endian mode not supported !"); | |
| 804 | ||
| 805 | MSR = value; | |
| 806 | ||
| 807 | if (ppc.is603 || ppc.is602) | |
| 808 | { | |
| 809 | if (!(MSR & MSR_DR)) | |
| 810 | { | |
| 811 | ppc.read8 = program_read_byte_64be; | |
| 812 | ppc.read16 = program_read_word_64be; | |
| 813 | ppc.read32 = program_read_dword_64be; | |
| 814 | ppc.read64 = program_read_qword_64be; | |
| 815 | ppc.write8 = program_write_byte_64be; | |
| 816 | ppc.write16 = program_write_word_64be; | |
| 817 | ppc.write32 = program_write_dword_64be; | |
| 818 | ppc.write64 = program_write_qword_64be; | |
| 819 | } | |
| 820 | else | |
| 821 | { | |
| 822 | ppc.read8 = ppc_read8_translated; | |
| 823 | ppc.read16 = ppc_read16_translated; | |
| 824 | ppc.read32 = ppc_read32_translated; | |
| 825 | ppc.read64 = ppc_read64_translated; | |
| 826 | ppc.write8 = ppc_write8_translated; | |
| 827 | ppc.write16 = ppc_write16_translated; | |
| 828 | ppc.write32 = ppc_write32_translated; | |
| 829 | ppc.write64 = ppc_write64_translated; | |
| 830 | } | |
| 831 | } | |
| 832 | } | |
| 833 | ||
| 834 | INLINE UINT32 ppc_get_msr(void) | |
| 835 | { | |
| 836 | return MSR; | |
| 837 | } | |
| 838 | ||
| 839 | INLINE void ppc_set_cr(UINT32 value) | |
| 840 | { | |
| 841 | CR(0) = (value >> 28) & 0xf; | |
| 842 | CR(1) = (value >> 24) & 0xf; | |
| 843 | CR(2) = (value >> 20) & 0xf; | |
| 844 | CR(3) = (value >> 16) & 0xf; | |
| 845 | CR(4) = (value >> 12) & 0xf; | |
| 846 | CR(5) = (value >> 8) & 0xf; | |
| 847 | CR(6) = (value >> 4) & 0xf; | |
| 848 | CR(7) = (value >> 0) & 0xf; | |
| 849 | } | |
| 850 | ||
| 851 | INLINE UINT32 ppc_get_cr(void) | |
| 852 | { | |
| 853 | return CR(0) << 28 | CR(1) << 24 | CR(2) << 20 | CR(3) << 16 | CR(4) << 12 | CR(5) << 8 | CR(6) << 4 | CR(7); | |
| 854 | } | |
| 855 | ||
| 856 | #ifdef UNUSED_FUNCTION | |
| 857 | static void log_code(drc_core *drc) | |
| 858 | { | |
| 859 | #if LOG_CODE | |
| 860 | FILE *temp; | |
| 861 | temp = fopen("code.bin", "wb"); | |
| 862 | fwrite(drc->cache_base, 1, drc->cache_top - drc->cache_base, temp); | |
| 863 | fclose(temp); | |
| 864 | #endif | |
| 865 | } | |
| 866 | #endif | |
| 867 | ||
| 868 | /***********************************************************************/ | |
| 869 | ||
| 870 | #include "ppc_mem.c" | |
| 871 | ||
| 872 | #if (HAS_PPC403) | |
| 873 | #include "ppc403.c" | |
| 874 | #endif | |
| 875 | ||
| 876 | #if (HAS_PPC602) | |
| 877 | #include "ppc602.c" | |
| 878 | #endif | |
| 879 | ||
| 880 | /*************************************************************************** | |
| 881 | CODE LOGGING | |
| 882 | ***************************************************************************/ | |
| 883 | ||
| 884 | #if LOG_CODE | |
| 885 | ||
| 886 | static code_log_entry code_log_buffer[MAX_INSTRUCTIONS*2]; | |
| 887 | static int code_log_index; | |
| 888 | static FILE *logfile; | |
| 889 | ||
| 890 | ||
| 891 | /*------------------------------------------------- | |
| 892 | open_logfile - open the log file if it is | |
| 893 | not already opened | |
| 894 | -------------------------------------------------*/ | |
| 895 | ||
| 896 | INLINE int open_logfile(void) | |
| 897 | { | |
| 898 | if (logfile == NULL) | |
| 899 | logfile = fopen("ppcdrc.asm", "w"); | |
| 900 | return (logfile != NULL); | |
| 901 | } | |
| 902 | ||
| 903 | ||
| 904 | /*------------------------------------------------- | |
| 905 | code_log_reset - reset the logging index | |
| 906 | -------------------------------------------------*/ | |
| 907 | ||
| 908 | INLINE void code_log_reset(void) | |
| 909 | { | |
| 910 | code_log_index = 0; | |
| 911 | } | |
| 912 | ||
| 913 | ||
| 914 | /*------------------------------------------------- | |
| 915 | code_log_add_entry - add an entry to the log | |
| 916 | -------------------------------------------------*/ | |
| 917 | ||
| 918 | INLINE void code_log_add_entry(UINT32 pc, UINT32 op, void *base) | |
| 919 | { | |
| 920 | code_log_buffer[code_log_index].pc = pc; | |
| 921 | code_log_buffer[code_log_index].op = op; | |
| 922 | code_log_buffer[code_log_index].base = base; | |
| 923 | code_log_index++; | |
| 924 | } | |
| 925 | ||
| 926 | ||
| 927 | /*------------------------------------------------- | |
| 928 | code_log - actually log some code | |
| 929 | -------------------------------------------------*/ | |
| 930 | ||
| 931 | static void code_log(const char *label, x86code *start, x86code *stop) | |
| 932 | { | |
| 933 | extern int i386_dasm_one(char *buffer, UINT32 eip, UINT8 *oprom, int mode); | |
| 934 | offs_t ppc_dasm_one(char *buffer, UINT32 pc, UINT32 op); | |
| 935 | UINT8 *cur = start; | |
| 936 | ||
| 937 | /* open the file, creating it if necessary */ | |
| 938 | if (!open_logfile()) | |
| 939 | return; | |
| 940 | fprintf(logfile, "\n%s\n", label); | |
| 941 | ||
| 942 | /* loop from the start until the cache top */ | |
| 943 | while (cur < stop) | |
| 944 | { | |
| 945 | char buffer[100]; | |
| 946 | int bytes; | |
| 947 | int op; | |
| 948 | ||
| 949 | /* skip filler opcodes */ | |
| 950 | if (*cur == 0xcc) | |
| 951 | { | |
| 952 | cur++; | |
| 953 | continue; | |
| 954 | } | |
| 955 | ||
| 956 | /* disassemble this instruction */ | |
| 957 | #ifdef PTR64 | |
| 958 | bytes = i386_dasm_one(buffer, (UINT32)(FPTR)cur, cur, 64) & DASMFLAG_LENGTHMASK; | |
| 959 | #else | |
| 960 | bytes = i386_dasm_one(buffer, (UINT32)cur, cur, 32) & DASMFLAG_LENGTHMASK; | |
| 961 | #endif | |
| 962 | ||
| 963 | /* look for a match in the registered opcodes */ | |
| 964 | for (op = 0; op < code_log_index; op++) | |
| 965 | if (code_log_buffer[op].base == (void *)cur) | |
| 966 | break; | |
| 967 | ||
| 968 | /* if no match, just output the current instruction */ | |
| 969 | if (op == code_log_index) | |
| 970 | fprintf(logfile, "%p: %s\n", cur, buffer); | |
| 971 | ||
| 972 | /* otherwise, output with the original instruction to the right */ | |
| 973 | else | |
| 974 | { | |
| 975 | char buffer2[100]; | |
| 976 | ppc_dasm_one(buffer2, code_log_buffer[op].pc, code_log_buffer[op].op); | |
| 977 | fprintf(logfile, "%p: %-50s %08X: %s\n", cur, buffer, code_log_buffer[op].pc, buffer2); | |
| 978 | } | |
| 979 | ||
| 980 | /* advance past this instruction */ | |
| 981 | cur += bytes; | |
| 982 | } | |
| 983 | ||
| 984 | /* flush the file */ | |
| 985 | fflush(logfile); | |
| 986 | } | |
| 987 | ||
| 988 | #else | |
| 989 | ||
| 990 | #define code_log_reset() | |
| 991 | #define code_log_add_entry(a,b,c) | |
| 992 | #define code_log(a,b,c) | |
| 993 | ||
| 994 | #endif | |
| 995 | ||
| 996 | ||
| 997 | /********************************************************************/ | |
| 998 | ||
| 999 | #include "ppc_ops.c" | |
| 1000 | #include "drc_ops.c" | |
| 1001 | #include "drc_ops.h" | |
| 1002 | ||
| 1003 | /* Initialization and shutdown */ | |
| 1004 | ||
| 1005 | static void ppc_init(void) | |
| 1006 | { | |
| 1007 | int i,j; | |
| 1008 | ||
| 1009 | for( i=0; i < 64; i++ ) { | |
| 1010 | ppc.optable[i] = recompile_invalid; | |
| 1011 | } | |
| 1012 | for( i=0; i < 1024; i++ ) { | |
| 1013 | ppc.optable19[i] = recompile_invalid; | |
| 1014 | ppc.optable31[i] = recompile_invalid; | |
| 1015 | ppc.optable59[i] = recompile_invalid; | |
| 1016 | ppc.optable63[i] = recompile_invalid; | |
| 1017 | } | |
| 1018 | ||
| 1019 | /* Fill the opcode tables */ | |
| 1020 | for( i=0; i < (sizeof(ppcdrc_opcode_common) / sizeof(PPC_OPCODE)); i++ ) { | |
| 1021 | ||
| 1022 | switch(ppcdrc_opcode_common[i].code) | |
| 1023 | { | |
| 1024 | case 19: | |
| 1025 | ppc.optable19[ppcdrc_opcode_common[i].subcode] = ppcdrc_opcode_common[i].handler; | |
| 1026 | break; | |
| 1027 | ||
| 1028 | case 31: | |
| 1029 | ppc.optable31[ppcdrc_opcode_common[i].subcode] = ppcdrc_opcode_common[i].handler; | |
| 1030 | break; | |
| 1031 | ||
| 1032 | case 59: | |
| 1033 | case 63: | |
| 1034 | break; | |
| 1035 | ||
| 1036 | default: | |
| 1037 | ppc.optable[ppcdrc_opcode_common[i].code] = ppcdrc_opcode_common[i].handler; | |
| 1038 | } | |
| 1039 | ||
| 1040 | } | |
| 1041 | ||
| 1042 | /* Calculate rotate mask table */ | |
| 1043 | for( i=0; i < 32; i++ ) { | |
| 1044 | for( j=0; j < 32; j++ ) { | |
| 1045 | UINT32 mask; | |
| 1046 | int mb = i; | |
| 1047 | int me = j; | |
| 1048 | mask = ((UINT32)0xFFFFFFFF >> mb) ^ ((me >= 31) ? 0 : ((UINT32)0xFFFFFFFF >> (me + 1))); | |
| 1049 | if( mb > me ) | |
| 1050 | mask = ~mask; | |
| 1051 | ||
| 1052 | ppc_rotate_mask[i][j] = mask; | |
| 1053 | } | |
| 1054 | } | |
| 1055 | } | |
| 1056 | ||
| 1057 | #if (HAS_PPC403) | |
| 1058 | static void ppcdrc403_init(int index, int clock, const void *_config, int (*irqcallback)(int)) | |
| 1059 | { | |
| 1060 | const ppc_config *config = _config; | |
| 1061 | ||
| 1062 | ppc_init(); | |
| 1063 | ppcdrc_init(); | |
| 1064 | ||
| 1065 | /* PPC403 specific opcodes */ | |
| 1066 | ppc.optable31[454] = recompile_dccci; | |
| 1067 | ppc.optable31[486] = recompile_dcread; | |
| 1068 | ppc.optable31[262] = recompile_icbt; | |
| 1069 | ppc.optable31[966] = recompile_iccci; | |
| 1070 | ppc.optable31[998] = recompile_icread; | |
| 1071 | ppc.optable31[323] = recompile_mfdcr; | |
| 1072 | ppc.optable31[451] = recompile_mtdcr; | |
| 1073 | ppc.optable31[131] = recompile_wrtee; | |
| 1074 | ppc.optable31[163] = recompile_wrteei; | |
| 1075 | ppc.optable19[51] = recompile_rfci; | |
| 1076 | ||
| 1077 | ppc.spu.rx_timer = timer_alloc(ppc403_spu_rx_callback, NULL); | |
| 1078 | ppc.spu.tx_timer = timer_alloc(ppc403_spu_tx_callback, NULL); | |
| 1079 | ||
| 1080 | ppc.is603 = 0; | |
| 1081 | ppc.is602 = 0; | |
| 1082 | ||
| 1083 | ppc.read8 = ppc403_read8; | |
| 1084 | ppc.read16 = ppc403_read16; | |
| 1085 | ppc.read32 = ppc403_read32; | |
| 1086 | ppc.write8 = ppc403_write8; | |
| 1087 | ppc.write16 = ppc403_write16; | |
| 1088 | ppc.write32 = ppc403_write32; | |
| 1089 | ppc.read16_unaligned = ppc403_read16_unaligned; | |
| 1090 | ppc.read32_unaligned = ppc403_read32_unaligned; | |
| 1091 | ppc.write16_unaligned = ppc403_write16_unaligned; | |
| 1092 | ppc.write32_unaligned = ppc403_write32_unaligned; | |
| 1093 | ||
| 1094 | ppc.irq_callback = irqcallback; | |
| 1095 | ||
| 1096 | ppc.pvr = config->pvr; | |
| 1097 | } | |
| 1098 | ||
| 1099 | static void ppcdrc403_exit(void) | |
| 1100 | { | |
| 1101 | #if LOG_CODE | |
| 1102 | //if (symfile) fclose(symfile); | |
| 1103 | #endif | |
| 1104 | ppcdrc_exit(); | |
| 1105 | } | |
| 1106 | ||
| 1107 | static void ppcdrc403_reset(void) | |
| 1108 | { | |
| 1109 | ppc.pc = ppc.npc = 0xfffffffc; | |
| 1110 | ||
| 1111 | ppc_set_msr(0); | |
| 1112 | change_pc(ppc.pc); | |
| 1113 | ||
| 1114 | /* reset the DRC */ | |
| 1115 | drc_cache_reset(ppc.drc); | |
| 1116 | } | |
| 1117 | ||
| 1118 | static int ppcdrc403_execute(int cycles) | |
| 1119 | { | |
| 1120 | /* count cycles and interrupt cycles */ | |
| 1121 | ppc_icount = cycles; | |
| 1122 | ppc_tb_base_icount = cycles; | |
| 1123 | ||
| 1124 | ppc_fit_trigger_cycle = 0x7fffffff; | |
| 1125 | ||
| 1126 | if (ppc.fit_int_enable) | |
| 1127 | { | |
| 1128 | UINT32 tb = (UINT32)ppc.tb; | |
| 1129 | UINT32 fit_cycles = 0; | |
| 1130 | ||
| 1131 | if (ppc.tb & ppc.fit_bit) | |
| 1132 | { | |
| 1133 | fit_cycles += ppc.fit_bit; | |
| 1134 | tb += fit_cycles; | |
| 1135 | } | |
| 1136 | ||
| 1137 | fit_cycles += ppc.fit_bit - (tb & (ppc.fit_bit-1)); | |
| 1138 | ||
| 1139 | ppc_fit_trigger_cycle = ppc_icount - fit_cycles; | |
| 1140 | } | |
| 1141 | ||
| 1142 | drc_execute(ppc.drc); | |
| 1143 | ||
| 1144 | // update timebase | |
| 1145 | ppc.tb += (ppc_tb_base_icount - ppc_icount); | |
| 1146 | ||
| 1147 | return cycles - ppc_icount; | |
| 1148 | } | |
| 1149 | ||
| 1150 | static void ppcdrc403_set_irq_line(int irqline, int state) | |
| 1151 | { | |
| 1152 | if (irqline >= INPUT_LINE_IRQ0 && irqline <= INPUT_LINE_IRQ4) | |
| 1153 | { | |
| 1154 | UINT32 mask = (1 << (4 - irqline)); | |
| 1155 | if( state == ASSERT_LINE) { | |
| 1156 | if (EXIER & mask) | |
| 1157 | { | |
| 1158 | ppc.exisr |= mask; | |
| 1159 | ppc.exception_pending |= 0x1; | |
| 1160 | ||
| 1161 | if (ppc.irq_callback) | |
| 1162 | { | |
| 1163 | ppc.irq_callback(irqline); | |
| 1164 | } | |
| 1165 | } | |
| 1166 | } | |
| 1167 | // clear line is used to clear the interrupt when the interrupts are level-sensitive | |
| 1168 | else if (state == CLEAR_LINE) | |
| 1169 | { | |
| 1170 | ppc.exisr &= ~mask; | |
| 1171 | } | |
| 1172 | } | |
| 1173 | else if (irqline == PPC403_SPU_RX) | |
| 1174 | { | |
| 1175 | UINT32 mask = 0x08000000; | |
| 1176 | if (state) { | |
| 1177 | if( EXIER & mask ) { | |
| 1178 | ppc.exisr |= mask; | |
| 1179 | ppc.exception_pending |= 0x1; | |
| 1180 | } | |
| 1181 | } | |
| 1182 | } | |
| 1183 | else if (irqline == PPC403_SPU_TX) | |
| 1184 | { | |
| 1185 | UINT32 mask = 0x04000000; | |
| 1186 | if (state) { | |
| 1187 | if( EXIER & mask ) { | |
| 1188 | ppc.exisr |= mask; | |
| 1189 | ppc.exception_pending |= 0x1; | |
| 1190 | } | |
| 1191 | } | |
| 1192 | } | |
| 1193 | else | |
| 1194 | { | |
| 1195 | fatalerror("PPC: Unknown IRQ line %d", irqline); | |
| 1196 | } | |
| 1197 | } | |
| 1198 | #endif | |
| 1199 | ||
| 1200 | #if (HAS_PPC603) | |
| 1201 | static void ppcdrc603_init(int index, int clock, const void *_config, int (*irqcallback)(int)) | |
| 1202 | { | |
| 1203 | int pll_config = 0; | |
| 1204 | float multiplier; | |
| 1205 | const ppc_config *config = _config; | |
| 1206 | int i; | |
| 1207 | ||
| 1208 | ppc_init(); | |
| 1209 | ppcdrc_init(); | |
| 1210 | ||
| 1211 | ppc.optable[48] = recompile_lfs; | |
| 1212 | ppc.optable[49] = recompile_lfsu; | |
| 1213 | ppc.optable[50] = recompile_lfd; | |
| 1214 | ppc.optable[51] = recompile_lfdu; | |
| 1215 | ppc.optable[52] = recompile_stfs; | |
| 1216 | ppc.optable[53] = recompile_stfsu; | |
| 1217 | ppc.optable[54] = recompile_stfd; | |
| 1218 | ppc.optable[55] = recompile_stfdu; | |
| 1219 | ppc.optable31[631] = recompile_lfdux; | |
| 1220 | ppc.optable31[599] = recompile_lfdx; | |
| 1221 | ppc.optable31[567] = recompile_lfsux; | |
| 1222 | ppc.optable31[535] = recompile_lfsx; | |
| 1223 | ppc.optable31[595] = recompile_mfsr; | |
| 1224 | ppc.optable31[659] = recompile_mfsrin; | |
| 1225 | ppc.optable31[371] = recompile_mftb; | |
| 1226 | ppc.optable31[210] = recompile_mtsr; | |
| 1227 | ppc.optable31[242] = recompile_mtsrin; | |
| 1228 | ppc.optable31[758] = recompile_dcba; | |
| 1229 | ppc.optable31[759] = recompile_stfdux; | |
| 1230 | ppc.optable31[727] = recompile_stfdx; | |
| 1231 | ppc.optable31[983] = recompile_stfiwx; | |
| 1232 | ppc.optable31[695] = recompile_stfsux; | |
| 1233 | ppc.optable31[663] = recompile_stfsx; | |
| 1234 | ppc.optable31[370] = recompile_tlbia; | |
| 1235 | ppc.optable31[306] = recompile_tlbie; | |
| 1236 | ppc.optable31[566] = recompile_tlbsync; | |
| 1237 | ppc.optable31[310] = recompile_eciwx; | |
| 1238 | ppc.optable31[438] = recompile_ecowx; | |
| 1239 | ||
| 1240 | ppc.optable63[264] = recompile_fabsx; | |
| 1241 | ppc.optable63[21] = recompile_faddx; | |
| 1242 | ppc.optable63[32] = recompile_fcmpo; | |
| 1243 | ppc.optable63[0] = recompile_fcmpu; | |
| 1244 | ppc.optable63[14] = recompile_fctiwx; | |
| 1245 | ppc.optable63[15] = recompile_fctiwzx; | |
| 1246 | ppc.optable63[18] = recompile_fdivx; | |
| 1247 | ppc.optable63[72] = recompile_fmrx; | |
| 1248 | ppc.optable63[136] = recompile_fnabsx; | |
| 1249 | ppc.optable63[40] = recompile_fnegx; | |
| 1250 | ppc.optable63[12] = recompile_frspx; | |
| 1251 | ppc.optable63[26] = recompile_frsqrtex; | |
| 1252 | ppc.optable63[22] = recompile_fsqrtx; | |
| 1253 | ppc.optable63[20] = recompile_fsubx; | |
| 1254 | ppc.optable63[583] = recompile_mffsx; | |
| 1255 | ppc.optable63[70] = recompile_mtfsb0x; | |
| 1256 | ppc.optable63[38] = recompile_mtfsb1x; | |
| 1257 | ppc.optable63[711] = recompile_mtfsfx; | |
| 1258 | ppc.optable63[134] = recompile_mtfsfix; | |
| 1259 | ppc.optable63[64] = recompile_mcrfs; | |
| 1260 | ||
| 1261 | ppc.optable59[21] = recompile_faddsx; | |
| 1262 | ppc.optable59[18] = recompile_fdivsx; | |
| 1263 | ppc.optable59[24] = recompile_fresx; | |
| 1264 | ppc.optable59[22] = recompile_fsqrtsx; | |
| 1265 | ppc.optable59[20] = recompile_fsubsx; | |
| 1266 | ||
| 1267 | for(i = 0; i < 32; i++) | |
| 1268 | { | |
| 1269 | ppc.optable63[i * 32 | 29] = recompile_fmaddx; | |
| 1270 | ppc.optable63[i * 32 | 28] = recompile_fmsubx; | |
| 1271 | ppc.optable63[i * 32 | 25] = recompile_fmulx; | |
| 1272 | ppc.optable63[i * 32 | 31] = recompile_fnmaddx; | |
| 1273 | ppc.optable63[i * 32 | 30] = recompile_fnmsubx; | |
| 1274 | ppc.optable63[i * 32 | 23] = recompile_fselx; | |
| 1275 | ||
| 1276 | ppc.optable59[i * 32 | 29] = recompile_fmaddsx; | |
| 1277 | ppc.optable59[i * 32 | 28] = recompile_fmsubsx; | |
| 1278 | ppc.optable59[i * 32 | 25] = recompile_fmulsx; | |
| 1279 | ppc.optable59[i * 32 | 31] = recompile_fnmaddsx; | |
| 1280 | ppc.optable59[i * 32 | 30] = recompile_fnmsubsx; | |
| 1281 | } | |
| 1282 | ||
| 1283 | #if (HAS_PPC602 || HAS_MPC8240) | |
| 1284 | ppc.optable31[978] = recompile_tlbld; | |
| 1285 | #endif /* (HAS_PPC602 || HAS_MPC8240) */ | |
| 1286 | ||
| 1287 | for(i = 0; i < 256; i++) | |
| 1288 | { | |
| 1289 | ppc_field_xlat[i] = | |
| 1290 | ((i & 0x80) ? 0xF0000000 : 0) | | |
| 1291 | ((i & 0x40) ? 0x0F000000 : 0) | | |
| 1292 | ((i & 0x20) ? 0x00F00000 : 0) | | |
| 1293 | ((i & 0x10) ? 0x000F0000 : 0) | | |
| 1294 | ((i & 0x08) ? 0x0000F000 : 0) | | |
| 1295 | ((i & 0x04) ? 0x00000F00 : 0) | | |
| 1296 | ((i & 0x02) ? 0x000000F0 : 0) | | |
| 1297 | ((i & 0x01) ? 0x0000000F : 0); | |
| 1298 | } | |
| 1299 | ||
| 1300 | ppc.is603 = 1; | |
| 1301 | ||
| 1302 | ppc.read8 = program_read_byte_64be; | |
| 1303 | ppc.read16 = program_read_word_64be; | |
| 1304 | ppc.read32 = program_read_dword_64be; | |
| 1305 | ppc.read64 = program_read_qword_64be; | |
| 1306 | ppc.write8 = program_write_byte_64be; | |
| 1307 | ppc.write16 = program_write_word_64be; | |
| 1308 | ppc.write32 = program_write_dword_64be; | |
| 1309 | ppc.write64 = program_write_qword_64be; | |
| 1310 | ppc.read16_unaligned = ppc_read16_unaligned; | |
| 1311 | ppc.read32_unaligned = ppc_read32_unaligned; | |
| 1312 | ppc.read64_unaligned = ppc_read64_unaligned; | |
| 1313 | ppc.write16_unaligned = ppc_write16_unaligned; | |
| 1314 | ppc.write32_unaligned = ppc_write32_unaligned; | |
| 1315 | ppc.write64_unaligned = ppc_write64_unaligned; | |
| 1316 | ||
| 1317 | ppc.irq_callback = irqcallback; | |
| 1318 | ||
| 1319 | ppc.pvr = config->pvr; | |
| 1320 | ||
| 1321 | multiplier = (float)((config->bus_frequency_multiplier >> 4) & 0xf) + | |
| 1322 | (float)(config->bus_frequency_multiplier & 0xf) / 10.0f; | |
| 1323 | bus_freq_multiplier = (int)(multiplier * 2); | |
| 1324 | ||
| 1325 | switch(config->pvr) | |
| 1326 | { | |
| 1327 | case PPC_MODEL_603E: pll_config = mpc603e_pll_config[bus_freq_multiplier-1][config->bus_frequency]; break; | |
| 1328 | case PPC_MODEL_603EV: pll_config = mpc603ev_pll_config[bus_freq_multiplier-1][config->bus_frequency]; break; | |
| 1329 | case PPC_MODEL_603R: pll_config = mpc603r_pll_config[bus_freq_multiplier-1][config->bus_frequency]; break; | |
| 1330 | default: break; | |
| 1331 | } | |
| 1332 | ||
| 1333 | if (pll_config == -1) | |
| 1334 | { | |
| 1335 | fatalerror("PPC: Invalid bus/multiplier combination (bus frequency = %d, multiplier = %1.1f)", config->bus_frequency, multiplier); | |
| 1336 | } | |
| 1337 | ||
| 1338 | ppc.hid1 = pll_config << 28; | |
| 1339 | } | |
| 1340 | ||
| 1341 | static void ppcdrc603_exit(void) | |
| 1342 | { | |
| 1343 | #if LOG_CODE | |
| 1344 | //if (symfile) fclose(symfile); | |
| 1345 | #endif | |
| 1346 | ppcdrc_exit(); | |
| 1347 | } | |
| 1348 | #endif | |
| 1349 | ||
| 1350 | #if (HAS_PPC601 || HAS_PPC603 || HAS_MPC8240 || HAS_PPC604) | |
| 1351 | static void ppcdrc603_reset(void) | |
| 1352 | { | |
| 1353 | ppc.pc = ppc.npc = 0xfff00100; | |
| 1354 | ||
| 1355 | ppc_set_msr(0x40); | |
| 1356 | change_pc(ppc.pc); | |
| 1357 | ||
| 1358 | /* reset the DRC */ | |
| 1359 | drc_cache_reset(ppc.drc); | |
| 1360 | } | |
| 1361 | ||
| 1362 | static int ppcdrc603_execute(int cycles) | |
| 1363 | { | |
| 1364 | /* count cycles and interrupt cycles */ | |
| 1365 | ppc_icount = cycles; | |
| 1366 | ppc_tb_base_icount = cycles; | |
| 1367 | ppc_dec_base_icount = cycles + ppc.dec_frac; | |
| 1368 | ||
| 1369 | // check if decrementer exception occurs during execution | |
| 1370 | if ((UINT32)(DEC - ppc_icount) > (UINT32)(DEC)) | |
| 1371 | { | |
| 1372 | ppc_dec_trigger_cycle = ppc_icount - DEC; | |
| 1373 | } | |
| 1374 | else | |
| 1375 | { | |
| 1376 | ppc_dec_trigger_cycle = 0x7fffffff; | |
| 1377 | } | |
| 1378 | ||
| 1379 | drc_execute(ppc.drc); | |
| 1380 | ||
| 1381 | // update timebase | |
| 1382 | // timebase is incremented once every four core clock cycles, so adjust the cycles accordingly | |
| 1383 | ppc.tb += ((ppc_tb_base_icount - ppc_icount) / 4); | |
| 1384 | ||
| 1385 | // update decrementer | |
| 1386 | ppc.dec_frac = ((ppc_dec_base_icount - ppc_icount) % (bus_freq_multiplier * 2)); | |
| 1387 | DEC -= ((ppc_dec_base_icount - ppc_icount) / (bus_freq_multiplier * 2)); | |
| 1388 | ||
| 1389 | return cycles - ppc_icount; | |
| 1390 | } | |
| 1391 | ||
| 1392 | static void ppcdrc603_set_irq_line(int irqline, int state) | |
| 1393 | { | |
| 1394 | if( state ) { | |
| 1395 | ppc.exception_pending |= 0x1; | |
| 1396 | if (ppc.irq_callback) | |
| 1397 | { | |
| 1398 | ppc.irq_callback(irqline); | |
| 1399 | } | |
| 1400 | } | |
| 1401 | } | |
| 1402 | #endif | |
| 1403 | ||
| 1404 | #if (HAS_PPC602) | |
| 1405 | static void ppcdrc602_init(int index, int clock, const void *_config, int (*irqcallback)(int)) | |
| 1406 | { | |
| 1407 | float multiplier; | |
| 1408 | const ppc_config *config = _config; | |
| 1409 | int i; | |
| 1410 | ||
| 1411 | ppc_init(); | |
| 1412 | ppcdrc_init(); | |
| 1413 | ||
| 1414 | ppc.optable[48] = recompile_lfs; | |
| 1415 | ppc.optable[49] = recompile_lfsu; | |
| 1416 | ppc.optable[50] = recompile_lfd; | |
| 1417 | ppc.optable[51] = recompile_lfdu; | |
| 1418 | ppc.optable[52] = recompile_stfs; | |
| 1419 | ppc.optable[53] = recompile_stfsu; | |
| 1420 | ppc.optable[54] = recompile_stfd; | |
| 1421 | ppc.optable[55] = recompile_stfdu; | |
| 1422 | ppc.optable31[631] = recompile_lfdux; | |
| 1423 | ppc.optable31[599] = recompile_lfdx; | |
| 1424 | ppc.optable31[567] = recompile_lfsux; | |
| 1425 | ppc.optable31[535] = recompile_lfsx; | |
| 1426 | ppc.optable31[595] = recompile_mfsr; | |
| 1427 | ppc.optable31[659] = recompile_mfsrin; | |
| 1428 | ppc.optable31[371] = recompile_mftb; | |
| 1429 | ppc.optable31[210] = recompile_mtsr; | |
| 1430 | ppc.optable31[242] = recompile_mtsrin; | |
| 1431 | ppc.optable31[758] = recompile_dcba; | |
| 1432 | ppc.optable31[759] = recompile_stfdux; | |
| 1433 | ppc.optable31[727] = recompile_stfdx; | |
| 1434 | ppc.optable31[983] = recompile_stfiwx; | |
| 1435 | ppc.optable31[695] = recompile_stfsux; | |
| 1436 | ppc.optable31[663] = recompile_stfsx; | |
| 1437 | ppc.optable31[370] = recompile_tlbia; | |
| 1438 | ppc.optable31[306] = recompile_tlbie; | |
| 1439 | ppc.optable31[566] = recompile_tlbsync; | |
| 1440 | ppc.optable31[310] = recompile_eciwx; | |
| 1441 | ppc.optable31[438] = recompile_ecowx; | |
| 1442 | ||
| 1443 | ppc.optable63[264] = recompile_fabsx; | |
| 1444 | ppc.optable63[21] = recompile_faddx; | |
| 1445 | ppc.optable63[32] = recompile_fcmpo; | |
| 1446 | ppc.optable63[0] = recompile_fcmpu; | |
| 1447 | ppc.optable63[14] = recompile_fctiwx; | |
| 1448 | ppc.optable63[15] = recompile_fctiwzx; | |
| 1449 | ppc.optable63[18] = recompile_fdivx; | |
| 1450 | ppc.optable63[72] = recompile_fmrx; | |
| 1451 | ppc.optable63[136] = recompile_fnabsx; | |
| 1452 | ppc.optable63[40] = recompile_fnegx; | |
| 1453 | ppc.optable63[12] = recompile_frspx; | |
| 1454 | ppc.optable63[26] = recompile_frsqrtex; | |
| 1455 | ppc.optable63[22] = recompile_fsqrtx; | |
| 1456 | ppc.optable63[20] = recompile_fsubx; | |
| 1457 | ppc.optable63[583] = recompile_mffsx; | |
| 1458 | ppc.optable63[70] = recompile_mtfsb0x; | |
| 1459 | ppc.optable63[38] = recompile_mtfsb1x; | |
| 1460 | ppc.optable63[711] = recompile_mtfsfx; | |
| 1461 | ppc.optable63[134] = recompile_mtfsfix; | |
| 1462 | ppc.optable63[64] = recompile_mcrfs; | |
| 1463 | ||
| 1464 | ppc.optable59[21] = recompile_faddsx; | |
| 1465 | ppc.optable59[18] = recompile_fdivsx; | |
| 1466 | ppc.optable59[24] = recompile_fresx; | |
| 1467 | ppc.optable59[22] = recompile_fsqrtsx; | |
| 1468 | ppc.optable59[20] = recompile_fsubsx; | |
| 1469 | ||
| 1470 | for(i = 0; i < 32; i++) | |
| 1471 | { | |
| 1472 | ppc.optable63[i * 32 | 29] = recompile_fmaddx; | |
| 1473 | ppc.optable63[i * 32 | 28] = recompile_fmsubx; | |
| 1474 | ppc.optable63[i * 32 | 25] = recompile_fmulx; | |
| 1475 | ppc.optable63[i * 32 | 31] = recompile_fnmaddx; | |
| 1476 | ppc.optable63[i * 32 | 30] = recompile_fnmsubx; | |
| 1477 | ppc.optable63[i * 32 | 23] = recompile_fselx; | |
| 1478 | ||
| 1479 | ppc.optable59[i * 32 | 29] = recompile_fmaddsx; | |
| 1480 | ppc.optable59[i * 32 | 28] = recompile_fmsubsx; | |
| 1481 | ppc.optable59[i * 32 | 25] = recompile_fmulsx; | |
| 1482 | ppc.optable59[i * 32 | 31] = recompile_fnmaddsx; | |
| 1483 | ppc.optable59[i * 32 | 30] = recompile_fnmsubsx; | |
| 1484 | } | |
| 1485 | ||
| 1486 | for(i = 0; i < 256; i++) | |
| 1487 | { | |
| 1488 | ppc_field_xlat[i] = | |
| 1489 | ((i & 0x80) ? 0xF0000000 : 0) | | |
| 1490 | ((i & 0x40) ? 0x0F000000 : 0) | | |
| 1491 | ((i & 0x20) ? 0x00F00000 : 0) | | |
| 1492 | ((i & 0x10) ? 0x000F0000 : 0) | | |
| 1493 | ((i & 0x08) ? 0x0000F000 : 0) | | |
| 1494 | ((i & 0x04) ? 0x00000F00 : 0) | | |
| 1495 | ((i & 0x02) ? 0x000000F0 : 0) | | |
| 1496 | ((i & 0x01) ? 0x0000000F : 0); | |
| 1497 | } | |
| 1498 | ||
| 1499 | // PPC602 specific opcodes | |
| 1500 | ppc.optable31[596] = recompile_esa; | |
| 1501 | ppc.optable31[628] = recompile_dsa; | |
| 1502 | ppc.optable31[1010] = recompile_tlbli; | |
| 1503 | ppc.optable31[978] = recompile_tlbld; | |
| 1504 | ||
| 1505 | ppc.is603 = 0; | |
| 1506 | ppc.is602 = 1; | |
| 1507 | ||
| 1508 | ppc.read8 = program_read_byte_64be; | |
| 1509 | ppc.read16 = program_read_word_64be; | |
| 1510 | ppc.read32 = program_read_dword_64be; | |
| 1511 | ppc.read64 = program_read_qword_64be; | |
| 1512 | ppc.write8 = program_write_byte_64be; | |
| 1513 | ppc.write16 = program_write_word_64be; | |
| 1514 | ppc.write32 = program_write_dword_64be; | |
| 1515 | ppc.write64 = program_write_qword_64be; | |
| 1516 | ppc.read16_unaligned = ppc_read16_unaligned; | |
| 1517 | ppc.read32_unaligned = ppc_read32_unaligned; | |
| 1518 | ppc.read64_unaligned = ppc_read64_unaligned; | |
| 1519 | ppc.write16_unaligned = ppc_write16_unaligned; | |
| 1520 | ppc.write32_unaligned = ppc_write32_unaligned; | |
| 1521 | ppc.write64_unaligned = ppc_write64_unaligned; | |
| 1522 | ||
| 1523 | ppc.irq_callback = irqcallback; | |
| 1524 | ||
| 1525 | ppc.pvr = config->pvr; | |
| 1526 | ||
| 1527 | multiplier = (float)((config->bus_frequency_multiplier >> 4) & 0xf) + | |
| 1528 | (float)(config->bus_frequency_multiplier & 0xf) / 10.0f; | |
| 1529 | bus_freq_multiplier = (int)(multiplier * 2); | |
| 1530 | } | |
| 1531 | ||
| 1532 | static void ppcdrc602_exit(void) | |
| 1533 | { | |
| 1534 | #if LOG_CODE | |
| 1535 | //if (symfile) fclose(symfile); | |
| 1536 | #endif | |
| 1537 | ppcdrc_exit(); | |
| 1538 | } | |
| 1539 | ||
| 1540 | static void ppcdrc602_reset(void) | |
| 1541 | { | |
| 1542 | ppc.pc = ppc.npc = 0xfff00100; | |
| 1543 | ||
| 1544 | ppc_set_msr(0x40); | |
| 1545 | change_pc(ppc.pc); | |
| 1546 | ||
| 1547 | ppc.hid0 = 1; | |
| 1548 | ||
| 1549 | /* reset the DRC */ | |
| 1550 | drc_cache_reset(ppc.drc); | |
| 1551 | } | |
| 1552 | ||
| 1553 | static int ppcdrc602_execute(int cycles) | |
| 1554 | { | |
| 1555 | /* count cycles and interrupt cycles */ | |
| 1556 | ppc_icount = cycles; | |
| 1557 | ppc_tb_base_icount = cycles; | |
| 1558 | ppc_dec_base_icount = cycles; | |
| 1559 | ||
| 1560 | // check if decrementer exception occurs during execution | |
| 1561 | if ((UINT32)(DEC - ppc_icount) > (UINT32)(DEC)) | |
| 1562 | { | |
| 1563 | ppc_dec_trigger_cycle = ppc_icount - DEC; | |
| 1564 | } | |
| 1565 | else | |
| 1566 | { | |
| 1567 | ppc_dec_trigger_cycle = 0x7fffffff; | |
| 1568 | } | |
| 1569 | ||
| 1570 | drc_execute(ppc.drc); | |
| 1571 | ||
| 1572 | // update timebase | |
| 1573 | // timebase is incremented once every four core clock cycles, so adjust the cycles accordingly | |
| 1574 | ppc.tb += ((ppc_tb_base_icount - ppc_icount) / 4); | |
| 1575 | ||
| 1576 | // update decrementer | |
| 1577 | DEC -= ((ppc_dec_base_icount - ppc_icount) / (bus_freq_multiplier * 2)); | |
| 1578 | ||
| 1579 | return cycles - ppc_icount; | |
| 1580 | } | |
| 1581 | ||
| 1582 | static void ppcdrc602_set_irq_line(int irqline, int state) | |
| 1583 | { | |
| 1584 | if( state ) { | |
| 1585 | ppc.exception_pending |= 0x1; | |
| 1586 | if (ppc.irq_callback) | |
| 1587 | { | |
| 1588 | ppc.irq_callback(irqline); | |
| 1589 | } | |
| 1590 | } | |
| 1591 | } | |
| 1592 | #endif | |
| 1593 | ||
| 1594 | #if (HAS_MPC8240) | |
| 1595 | static void mpc8240drc_init(int index, int clock, const void *_config, int (*irqcallback)(int)) | |
| 1596 | { | |
| 1597 | float multiplier; | |
| 1598 | const ppc_config *config = _config; | |
| 1599 | int i; | |
| 1600 | ||
| 1601 | ppc_init(); | |
| 1602 | ppcdrc_init(); | |
| 1603 | ||
| 1604 | ppc.optable[48] = recompile_lfs; | |
| 1605 | ppc.optable[49] = recompile_lfsu; | |
| 1606 | ppc.optable[50] = recompile_lfd; | |
| 1607 | ppc.optable[51] = recompile_lfdu; | |
| 1608 | ppc.optable[52] = recompile_stfs; | |
| 1609 | ppc.optable[53] = recompile_stfsu; | |
| 1610 | ppc.optable[54] = recompile_stfd; | |
| 1611 | ppc.optable[55] = recompile_stfdu; | |
| 1612 | ppc.optable31[631] = recompile_lfdux; | |
| 1613 | ppc.optable31[599] = recompile_lfdx; | |
| 1614 | ppc.optable31[567] = recompile_lfsux; | |
| 1615 | ppc.optable31[535] = recompile_lfsx; | |
| 1616 | ppc.optable31[595] = recompile_mfsr; | |
| 1617 | ppc.optable31[659] = recompile_mfsrin; | |
| 1618 | ppc.optable31[371] = recompile_mftb; | |
| 1619 | ppc.optable31[210] = recompile_mtsr; | |
| 1620 | ppc.optable31[242] = recompile_mtsrin; | |
| 1621 | ppc.optable31[758] = recompile_dcba; | |
| 1622 | ppc.optable31[759] = recompile_stfdux; | |
| 1623 | ppc.optable31[727] = recompile_stfdx; | |
| 1624 | ppc.optable31[983] = recompile_stfiwx; | |
| 1625 | ppc.optable31[695] = recompile_stfsux; | |
| 1626 | ppc.optable31[663] = recompile_stfsx; | |
| 1627 | ppc.optable31[370] = recompile_tlbia; | |
| 1628 | ppc.optable31[306] = recompile_tlbie; | |
| 1629 | ppc.optable31[566] = recompile_tlbsync; | |
| 1630 | ppc.optable31[310] = recompile_eciwx; | |
| 1631 | ppc.optable31[438] = recompile_ecowx; | |
| 1632 | ||
| 1633 | ppc.optable63[264] = recompile_fabsx; | |
| 1634 | ppc.optable63[21] = recompile_faddx; | |
| 1635 | ppc.optable63[32] = recompile_fcmpo; | |
| 1636 | ppc.optable63[0] = recompile_fcmpu; | |
| 1637 | ppc.optable63[14] = recompile_fctiwx; | |
| 1638 | ppc.optable63[15] = recompile_fctiwzx; | |
| 1639 | ppc.optable63[18] = recompile_fdivx; | |
| 1640 | ppc.optable63[72] = recompile_fmrx; | |
| 1641 | ppc.optable63[136] = recompile_fnabsx; | |
| 1642 | ppc.optable63[40] = recompile_fnegx; | |
| 1643 | ppc.optable63[12] = recompile_frspx; | |
| 1644 | ppc.optable63[26] = recompile_frsqrtex; | |
| 1645 | ppc.optable63[22] = recompile_fsqrtx; | |
| 1646 | ppc.optable63[20] = recompile_fsubx; | |
| 1647 | ppc.optable63[583] = recompile_mffsx; | |
| 1648 | ppc.optable63[70] = recompile_mtfsb0x; | |
| 1649 | ppc.optable63[38] = recompile_mtfsb1x; | |
| 1650 | ppc.optable63[711] = recompile_mtfsfx; | |
| 1651 | ppc.optable63[134] = recompile_mtfsfix; | |
| 1652 | ppc.optable63[64] = recompile_mcrfs; | |
| 1653 | ||
| 1654 | ppc.optable59[21] = recompile_faddsx; | |
| 1655 | ppc.optable59[18] = recompile_fdivsx; | |
| 1656 | ppc.optable59[24] = recompile_fresx; | |
| 1657 | ppc.optable59[22] = recompile_fsqrtsx; | |
| 1658 | ppc.optable59[20] = recompile_fsubsx; | |
| 1659 | ||
| 1660 | for(i = 0; i < 32; i++) | |
| 1661 | { | |
| 1662 | ppc.optable63[i * 32 | 29] = recompile_fmaddx; | |
| 1663 | ppc.optable63[i * 32 | 28] = recompile_fmsubx; | |
| 1664 | ppc.optable63[i * 32 | 25] = recompile_fmulx; | |
| 1665 | ppc.optable63[i * 32 | 31] = recompile_fnmaddx; | |
| 1666 | ppc.optable63[i * 32 | 30] = recompile_fnmsubx; | |
| 1667 | ppc.optable63[i * 32 | 23] = recompile_fselx; | |
| 1668 | ||
| 1669 | ppc.optable59[i * 32 | 29] = recompile_fmaddsx; | |
| 1670 | ppc.optable59[i * 32 | 28] = recompile_fmsubsx; | |
| 1671 | ppc.optable59[i * 32 | 25] = recompile_fmulsx; | |
| 1672 | ppc.optable59[i * 32 | 31] = recompile_fnmaddsx; | |
| 1673 | ppc.optable59[i * 32 | 30] = recompile_fnmsubsx; | |
| 1674 | } | |
| 1675 | ||
| 1676 | for(i = 0; i < 256; i++) | |
| 1677 | { | |
| 1678 | ppc_field_xlat[i] = | |
| 1679 | ((i & 0x80) ? 0xF0000000 : 0) | | |
| 1680 | ((i & 0x40) ? 0x0F000000 : 0) | | |
| 1681 | ((i & 0x20) ? 0x00F00000 : 0) | | |
| 1682 | ((i & 0x10) ? 0x000F0000 : 0) | | |
| 1683 | ((i & 0x08) ? 0x0000F000 : 0) | | |
| 1684 | ((i & 0x04) ? 0x00000F00 : 0) | | |
| 1685 | ((i & 0x02) ? 0x000000F0 : 0) | | |
| 1686 | ((i & 0x01) ? 0x0000000F : 0); | |
| 1687 | } | |
| 1688 | ||
| 1689 | // MPC8240 specific opcodes | |
| 1690 | ppc.optable31[978] = recompile_tlbld; | |
| 1691 | ppc.optable31[1010] = recompile_tlbli; | |
| 1692 | ||
| 1693 | ppc.is603 = 1; | |
| 1694 | ||
| 1695 | ppc.read8 = program_read_byte_64be; | |
| 1696 | ppc.read16 = program_read_word_64be; | |
| 1697 | ppc.read32 = program_read_dword_64be; | |
| 1698 | ppc.read64 = program_read_qword_64be; | |
| 1699 | ppc.write8 = program_write_byte_64be; | |
| 1700 | ppc.write16 = program_write_word_64be; | |
| 1701 | ppc.write32 = program_write_dword_64be; | |
| 1702 | ppc.write64 = program_write_qword_64be; | |
| 1703 | ppc.read16_unaligned = ppc_read16_unaligned; | |
| 1704 | ppc.read32_unaligned = ppc_read32_unaligned; | |
| 1705 | ppc.read64_unaligned = ppc_read64_unaligned; | |
| 1706 | ppc.write16_unaligned = ppc_write16_unaligned; | |
| 1707 | ppc.write32_unaligned = ppc_write32_unaligned; | |
| 1708 | ppc.write64_unaligned = ppc_write64_unaligned; | |
| 1709 | ||
| 1710 | ppc.irq_callback = irqcallback; | |
| 1711 | ||
| 1712 | ppc.pvr = config->pvr; | |
| 1713 | ||
| 1714 | multiplier = (float)((config->bus_frequency_multiplier >> 4) & 0xf) + | |
| 1715 | (float)(config->bus_frequency_multiplier & 0xf) / 10.0f; | |
| 1716 | bus_freq_multiplier = (int)(multiplier * 2); | |
| 1717 | } | |
| 1718 | ||
| 1719 | static void mpc8240drc_exit(void) | |
| 1720 | { | |
| 1721 | ppcdrc_exit(); | |
| 1722 | } | |
| 1723 | #endif | |
| 1724 | ||
| 1725 | ||
| 1726 | #if (HAS_PPC601) | |
| 1727 | static void ppc601drc_init(int index, int clock, const void *_config, int (*irqcallback)(int)) | |
| 1728 | { | |
| 1729 | int pll_config = 0; | |
| 1730 | float multiplier; | |
| 1731 | const ppc_config *config = _config; | |
| 1732 | int i; | |
| 1733 | ||
| 1734 | ppc_init(); | |
| 1735 | ppcdrc_init(); | |
| 1736 | ||
| 1737 | ppc.optable[48] = recompile_lfs; | |
| 1738 | ppc.optable[49] = recompile_lfsu; | |
| 1739 | ppc.optable[50] = recompile_lfd; | |
| 1740 | ppc.optable[51] = recompile_lfdu; | |
| 1741 | ppc.optable[52] = recompile_stfs; | |
| 1742 | ppc.optable[53] = recompile_stfsu; | |
| 1743 | ppc.optable[54] = recompile_stfd; | |
| 1744 | ppc.optable[55] = recompile_stfdu; | |
| 1745 | ppc.optable31[631] = recompile_lfdux; | |
| 1746 | ppc.optable31[599] = recompile_lfdx; | |
| 1747 | ppc.optable31[567] = recompile_lfsux; | |
| 1748 | ppc.optable31[535] = recompile_lfsx; | |
| 1749 | ppc.optable31[595] = recompile_mfsr; | |
| 1750 | ppc.optable31[659] = recompile_mfsrin; | |
| 1751 | ppc.optable31[371] = recompile_mftb; | |
| 1752 | ppc.optable31[210] = recompile_mtsr; | |
| 1753 | ppc.optable31[242] = recompile_mtsrin; | |
| 1754 | ppc.optable31[758] = recompile_dcba; | |
| 1755 | ppc.optable31[759] = recompile_stfdux; | |
| 1756 | ppc.optable31[727] = recompile_stfdx; | |
| 1757 | ppc.optable31[983] = recompile_stfiwx; | |
| 1758 | ppc.optable31[695] = recompile_stfsux; | |
| 1759 | ppc.optable31[663] = recompile_stfsx; | |
| 1760 | ppc.optable31[370] = recompile_tlbia; | |
| 1761 | ppc.optable31[306] = recompile_tlbie; | |
| 1762 | ppc.optable31[566] = recompile_tlbsync; | |
| 1763 | ppc.optable31[310] = recompile_eciwx; | |
| 1764 | ppc.optable31[438] = recompile_ecowx; | |
| 1765 | ||
| 1766 | ppc.optable63[264] = recompile_fabsx; | |
| 1767 | ppc.optable63[21] = recompile_faddx; | |
| 1768 | ppc.optable63[32] = recompile_fcmpo; | |
| 1769 | ppc.optable63[0] = recompile_fcmpu; | |
| 1770 | ppc.optable63[14] = recompile_fctiwx; | |
| 1771 | ppc.optable63[15] = recompile_fctiwzx; | |
| 1772 | ppc.optable63[18] = recompile_fdivx; | |
| 1773 | ppc.optable63[72] = recompile_fmrx; | |
| 1774 | ppc.optable63[136] = recompile_fnabsx; | |
| 1775 | ppc.optable63[40] = recompile_fnegx; | |
| 1776 | ppc.optable63[12] = recompile_frspx; | |
| 1777 | ppc.optable63[26] = recompile_frsqrtex; | |
| 1778 | ppc.optable63[22] = recompile_fsqrtx; | |
| 1779 | ppc.optable63[20] = recompile_fsubx; | |
| 1780 | ppc.optable63[583] = recompile_mffsx; | |
| 1781 | ppc.optable63[70] = recompile_mtfsb0x; | |
| 1782 | ppc.optable63[38] = recompile_mtfsb1x; | |
| 1783 | ppc.optable63[711] = recompile_mtfsfx; | |
| 1784 | ppc.optable63[134] = recompile_mtfsfix; | |
| 1785 | ppc.optable63[64] = recompile_mcrfs; | |
| 1786 | ||
| 1787 | ppc.optable59[21] = recompile_faddsx; | |
| 1788 | ppc.optable59[18] = recompile_fdivsx; | |
| 1789 | ppc.optable59[24] = recompile_fresx; | |
| 1790 | ppc.optable59[22] = recompile_fsqrtsx; | |
| 1791 | ppc.optable59[20] = recompile_fsubsx; | |
| 1792 | ||
| 1793 | for(i = 0; i < 32; i++) | |
| 1794 | { | |
| 1795 | ppc.optable63[i * 32 | 29] = recompile_fmaddx; | |
| 1796 | ppc.optable63[i * 32 | 28] = recompile_fmsubx; | |
| 1797 | ppc.optable63[i * 32 | 25] = recompile_fmulx; | |
| 1798 | ppc.optable63[i * 32 | 31] = recompile_fnmaddx; | |
| 1799 | ppc.optable63[i * 32 | 30] = recompile_fnmsubx; | |
| 1800 | ppc.optable63[i * 32 | 23] = recompile_fselx; | |
| 1801 | ||
| 1802 | ppc.optable59[i * 32 | 29] = recompile_fmaddsx; | |
| 1803 | ppc.optable59[i * 32 | 28] = recompile_fmsubsx; | |
| 1804 | ppc.optable59[i * 32 | 25] = recompile_fmulsx; | |
| 1805 | ppc.optable59[i * 32 | 31] = recompile_fnmaddsx; | |
| 1806 | ppc.optable59[i * 32 | 30] = recompile_fnmsubsx; | |
| 1807 | } | |
| 1808 | ||
| 1809 | for(i = 0; i < 256; i++) | |
| 1810 | { | |
| 1811 | ppc_field_xlat[i] = | |
| 1812 | ((i & 0x80) ? 0xF0000000 : 0) | | |
| 1813 | ((i & 0x40) ? 0x0F000000 : 0) | | |
| 1814 | ((i & 0x20) ? 0x00F00000 : 0) | | |
| 1815 | ((i & 0x10) ? 0x000F0000 : 0) | | |
| 1816 | ((i & 0x08) ? 0x0000F000 : 0) | | |
| 1817 | ((i & 0x04) ? 0x00000F00 : 0) | | |
| 1818 | ((i & 0x02) ? 0x000000F0 : 0) | | |
| 1819 | ((i & 0x01) ? 0x0000000F : 0); | |
| 1820 | } | |
| 1821 | ||
| 1822 | ppc.is603 = 1; | |
| 1823 | ||
| 1824 | ppc.read8 = program_read_byte_64be; | |
| 1825 | ppc.read16 = program_read_word_64be; | |
| 1826 | ppc.read32 = program_read_dword_64be; | |
| 1827 | ppc.read64 = program_read_qword_64be; | |
| 1828 | ppc.write8 = program_write_byte_64be; | |
| 1829 | ppc.write16 = program_write_word_64be; | |
| 1830 | ppc.write32 = program_write_dword_64be; | |
| 1831 | ppc.write64 = program_write_qword_64be; | |
| 1832 | ppc.read16_unaligned = ppc_read16_unaligned; | |
| 1833 | ppc.read32_unaligned = ppc_read32_unaligned; | |
| 1834 | ppc.read64_unaligned = ppc_read64_unaligned; | |
| 1835 | ppc.write16_unaligned = ppc_write16_unaligned; | |
| 1836 | ppc.write32_unaligned = ppc_write32_unaligned; | |
| 1837 | ppc.write64_unaligned = ppc_write64_unaligned; | |
| 1838 | ||
| 1839 | ppc.irq_callback = irqcallback; | |
| 1840 | ||
| 1841 | ppc.pvr = config->pvr; | |
| 1842 | ||
| 1843 | multiplier = (float)((config->bus_frequency_multiplier >> 4) & 0xf) + | |
| 1844 | (float)(config->bus_frequency_multiplier & 0xf) / 10.0f; | |
| 1845 | bus_freq_multiplier = (int)(multiplier * 2); | |
| 1846 | ||
| 1847 | switch(config->pvr) | |
| 1848 | { | |
| 1849 | case PPC_MODEL_603E: pll_config = mpc603e_pll_config[bus_freq_multiplier-1][config->bus_frequency]; break; | |
| 1850 | case PPC_MODEL_603EV: pll_config = mpc603ev_pll_config[bus_freq_multiplier-1][config->bus_frequency]; break; | |
| 1851 | case PPC_MODEL_603R: pll_config = mpc603r_pll_config[bus_freq_multiplier-1][config->bus_frequency]; break; | |
| 1852 | default: break; | |
| 1853 | } | |
| 1854 | ||
| 1855 | if (pll_config == -1) | |
| 1856 | { | |
| 1857 | fatalerror("PPC: Invalid bus/multiplier combination (bus frequency = %d, multiplier = %1.1f)", config->bus_frequency, multiplier); | |
| 1858 | } | |
| 1859 | ||
| 1860 | ppc.hid1 = pll_config << 28; | |
| 1861 | } | |
| 1862 | ||
| 1863 | static void ppc601drc_exit(void) | |
| 1864 | { | |
| 1865 | #if LOG_CODE | |
| 1866 | //if (symfile) fclose(symfile); | |
| 1867 | #endif | |
| 1868 | ppcdrc_exit(); | |
| 1869 | } | |
| 1870 | #endif | |
| 1871 | ||
| 1872 | ||
| 1873 | #if (HAS_PPC604) | |
| 1874 | static void ppc604drc_init(int index, int clock, const void *_config, int (*irqcallback)(int)) | |
| 1875 | { | |
| 1876 | float multiplier; | |
| 1877 | const ppc_config *config = _config; | |
| 1878 | int i; | |
| 1879 | ||
| 1880 | ppc_init(); | |
| 1881 | ppcdrc_init(); | |
| 1882 | ||
| 1883 | ppc.optable[48] = recompile_lfs; | |
| 1884 | ppc.optable[49] = recompile_lfsu; | |
| 1885 | ppc.optable[50] = recompile_lfd; | |
| 1886 | ppc.optable[51] = recompile_lfdu; | |
| 1887 | ppc.optable[52] = recompile_stfs; | |
| 1888 | ppc.optable[53] = recompile_stfsu; | |
| 1889 | ppc.optable[54] = recompile_stfd; | |
| 1890 | ppc.optable[55] = recompile_stfdu; | |
| 1891 | ppc.optable31[631] = recompile_lfdux; | |
| 1892 | ppc.optable31[599] = recompile_lfdx; | |
| 1893 | ppc.optable31[567] = recompile_lfsux; | |
| 1894 | ppc.optable31[535] = recompile_lfsx; | |
| 1895 | ppc.optable31[595] = recompile_mfsr; | |
| 1896 | ppc.optable31[659] = recompile_mfsrin; | |
| 1897 | ppc.optable31[371] = recompile_mftb; | |
| 1898 | ppc.optable31[210] = recompile_mtsr; | |
| 1899 | ppc.optable31[242] = recompile_mtsrin; | |
| 1900 | ppc.optable31[758] = recompile_dcba; | |
| 1901 | ppc.optable31[759] = recompile_stfdux; | |
| 1902 | ppc.optable31[727] = recompile_stfdx; | |
| 1903 | ppc.optable31[983] = recompile_stfiwx; | |
| 1904 | ppc.optable31[695] = recompile_stfsux; | |
| 1905 | ppc.optable31[663] = recompile_stfsx; | |
| 1906 | ppc.optable31[370] = recompile_tlbia; | |
| 1907 | ppc.optable31[306] = recompile_tlbie; | |
| 1908 | ppc.optable31[566] = recompile_tlbsync; | |
| 1909 | ppc.optable31[310] = recompile_eciwx; | |
| 1910 | ppc.optable31[438] = recompile_ecowx; | |
| 1911 | ||
| 1912 | ppc.optable63[264] = recompile_fabsx; | |
| 1913 | ppc.optable63[21] = recompile_faddx; | |
| 1914 | ppc.optable63[32] = recompile_fcmpo; | |
| 1915 | ppc.optable63[0] = recompile_fcmpu; | |
| 1916 | ppc.optable63[14] = recompile_fctiwx; | |
| 1917 | ppc.optable63[15] = recompile_fctiwzx; | |
| 1918 | ppc.optable63[18] = recompile_fdivx; | |
| 1919 | ppc.optable63[72] = recompile_fmrx; | |
| 1920 | ppc.optable63[136] = recompile_fnabsx; | |
| 1921 | ppc.optable63[40] = recompile_fnegx; | |
| 1922 | ppc.optable63[12] = recompile_frspx; | |
| 1923 | ppc.optable63[26] = recompile_frsqrtex; | |
| 1924 | ppc.optable63[22] = recompile_fsqrtx; | |
| 1925 | ppc.optable63[20] = recompile_fsubx; | |
| 1926 | ppc.optable63[583] = recompile_mffsx; | |
| 1927 | ppc.optable63[70] = recompile_mtfsb0x; | |
| 1928 | ppc.optable63[38] = recompile_mtfsb1x; | |
| 1929 | ppc.optable63[711] = recompile_mtfsfx; | |
| 1930 | ppc.optable63[134] = recompile_mtfsfix; | |
| 1931 | ppc.optable63[64] = recompile_mcrfs; | |
| 1932 | ||
| 1933 | ppc.optable59[21] = recompile_faddsx; | |
| 1934 | ppc.optable59[18] = recompile_fdivsx; | |
| 1935 | ppc.optable59[24] = recompile_fresx; | |
| 1936 | ppc.optable59[22] = recompile_fsqrtsx; | |
| 1937 | ppc.optable59[20] = recompile_fsubsx; | |
| 1938 | ||
| 1939 | for(i = 0; i < 32; i++) | |
| 1940 | { | |
| 1941 | ppc.optable63[i * 32 | 29] = recompile_fmaddx; | |
| 1942 | ppc.optable63[i * 32 | 28] = recompile_fmsubx; | |
| 1943 | ppc.optable63[i * 32 | 25] = recompile_fmulx; | |
| 1944 | ppc.optable63[i * 32 | 31] = recompile_fnmaddx; | |
| 1945 | ppc.optable63[i * 32 | 30] = recompile_fnmsubx; | |
| 1946 | ppc.optable63[i * 32 | 23] = recompile_fselx; | |
| 1947 | ||
| 1948 | ppc.optable59[i * 32 | 29] = recompile_fmaddsx; | |
| 1949 | ppc.optable59[i * 32 | 28] = recompile_fmsubsx; | |
| 1950 | ppc.optable59[i * 32 | 25] = recompile_fmulsx; | |
| 1951 | ppc.optable59[i * 32 | 31] = recompile_fnmaddsx; | |
| 1952 | ppc.optable59[i * 32 | 30] = recompile_fnmsubsx; | |
| 1953 | } | |
| 1954 | ||
| 1955 | ppc.optable31[978] = recompile_tlbld; | |
| 1956 | ||
| 1957 | for(i = 0; i < 256; i++) | |
| 1958 | { | |
| 1959 | ppc_field_xlat[i] = | |
| 1960 | ((i & 0x80) ? 0xF0000000 : 0) | | |
| 1961 | ((i & 0x40) ? 0x0F000000 : 0) | | |
| 1962 | ((i & 0x20) ? 0x00F00000 : 0) | | |
| 1963 | ((i & 0x10) ? 0x000F0000 : 0) | | |
| 1964 | ((i & 0x08) ? 0x0000F000 : 0) | | |
| 1965 | ((i & 0x04) ? 0x00000F00 : 0) | | |
| 1966 | ((i & 0x02) ? 0x000000F0 : 0) | | |
| 1967 | ((i & 0x01) ? 0x0000000F : 0); | |
| 1968 | } | |
| 1969 | ||
| 1970 | ppc.is603 = 1; | |
| 1971 | ||
| 1972 | ppc.read8 = program_read_byte_64be; | |
| 1973 | ppc.read16 = program_read_word_64be; | |
| 1974 | ppc.read32 = program_read_dword_64be; | |
| 1975 | ppc.read64 = program_read_qword_64be; | |
| 1976 | ppc.write8 = program_write_byte_64be; | |
| 1977 | ppc.write16 = program_write_word_64be; | |
| 1978 | ppc.write32 = program_write_dword_64be; | |
| 1979 | ppc.write64 = program_write_qword_64be; | |
| 1980 | ppc.read16_unaligned = ppc_read16_unaligned; | |
| 1981 | ppc.read32_unaligned = ppc_read32_unaligned; | |
| 1982 | ppc.read64_unaligned = ppc_read64_unaligned; | |
| 1983 | ppc.write16_unaligned = ppc_write16_unaligned; | |
| 1984 | ppc.write32_unaligned = ppc_write32_unaligned; | |
| 1985 | ppc.write64_unaligned = ppc_write64_unaligned; | |
| 1986 | ||
| 1987 | ppc.irq_callback = irqcallback; | |
| 1988 | ||
| 1989 | ppc.pvr = config->pvr; | |
| 1990 | ||
| 1991 | multiplier = (float)((config->bus_frequency_multiplier >> 4) & 0xf) + | |
| 1992 | (float)(config->bus_frequency_multiplier & 0xf) / 10.0f; | |
| 1993 | bus_freq_multiplier = (int)(multiplier * 2); | |
| 1994 | } | |
| 1995 | ||
| 1996 | static void ppc604drc_exit(void) | |
| 1997 | { | |
| 1998 | #if LOG_CODE | |
| 1999 | //if (symfile) fclose(symfile); | |
| 2000 | #endif | |
| 2001 | ppcdrc_exit(); | |
| 2002 | } | |
| 2003 | #endif | |
| 2004 | ||
| 2005 | ||
| 2006 | static void ppc_get_context(void *dst) | |
| 2007 | { | |
| 2008 | /* copy the context */ | |
| 2009 | if (dst) | |
| 2010 | *(PPC_REGS *)dst = ppc; | |
| 2011 | } | |
| 2012 | ||
| 2013 | ||
| 2014 | static void ppc_set_context(void *src) | |
| 2015 | { | |
| 2016 | /* copy the context */ | |
| 2017 | if (src) | |
| 2018 | ppc = *(PPC_REGS *)src; | |
| 2019 | ||
| 2020 | change_pc(ppc.pc); | |
| 2021 | } | |
| 2022 | ||
| 2023 | ||
| 2024 | /************************************************************************** | |
| 2025 | * Generic set_info | |
| 2026 | **************************************************************************/ | |
| 2027 | ||
| 2028 | static void ppc_set_info(UINT32 state, cpuinfo *info) | |
| 2029 | { | |
| 2030 | switch (state) | |
| 2031 | { | |
| 2032 | case CPUINFO_INT_PC: | |
| 2033 | case CPUINFO_INT_REGISTER + PPC_PC: ppc.pc = info->i; break; | |
| 2034 | case CPUINFO_INT_REGISTER + PPC_MSR: ppc_set_msr(info->i); break; | |
| 2035 | case CPUINFO_INT_REGISTER + PPC_CR: ppc_set_cr(info->i); break; | |
| 2036 | case CPUINFO_INT_REGISTER + PPC_LR: LR = info->i; break; | |
| 2037 | case CPUINFO_INT_REGISTER + PPC_CTR: CTR = info->i; break; | |
| 2038 | case CPUINFO_INT_REGISTER + PPC_XER: XER = info->i; break; | |
| 2039 | case CPUINFO_INT_REGISTER + PPC_SRR0: SRR0 = info->i; break; | |
| 2040 | case CPUINFO_INT_REGISTER + PPC_SRR1: SRR1 = info->i; break; | |
| 2041 | ||
| 2042 | case CPUINFO_INT_REGISTER + PPC_R0: ppc.r[0] = info->i; break; | |
| 2043 | case CPUINFO_INT_REGISTER + PPC_R1: ppc.r[1] = info->i; break; | |
| 2044 | case CPUINFO_INT_REGISTER + PPC_R2: ppc.r[2] = info->i; break; | |
| 2045 | case CPUINFO_INT_REGISTER + PPC_R3: ppc.r[3] = info->i; break; | |
| 2046 | case CPUINFO_INT_REGISTER + PPC_R4: ppc.r[4] = info->i; break; | |
| 2047 | case CPUINFO_INT_REGISTER + PPC_R5: ppc.r[5] = info->i; break; | |
| 2048 | case CPUINFO_INT_REGISTER + PPC_R6: ppc.r[6] = info->i; break; | |
| 2049 | case CPUINFO_INT_REGISTER + PPC_R7: ppc.r[7] = info->i; break; | |
| 2050 | case CPUINFO_INT_REGISTER + PPC_R8: ppc.r[8] = info->i; break; | |
| 2051 | case CPUINFO_INT_REGISTER + PPC_R9: ppc.r[9] = info->i; break; | |
| 2052 | case CPUINFO_INT_REGISTER + PPC_R10: ppc.r[10] = info->i; break; | |
| 2053 | case CPUINFO_INT_REGISTER + PPC_R11: ppc.r[11] = info->i; break; | |
| 2054 | case CPUINFO_INT_REGISTER + PPC_R12: ppc.r[12] = info->i; break; | |
| 2055 | case CPUINFO_INT_REGISTER + PPC_R13: ppc.r[13] = info->i; break; | |
| 2056 | case CPUINFO_INT_REGISTER + PPC_R14: ppc.r[14] = info->i; break; | |
| 2057 | case CPUINFO_INT_REGISTER + PPC_R15: ppc.r[15] = info->i; break; | |
| 2058 | case CPUINFO_INT_REGISTER + PPC_R16: ppc.r[16] = info->i; break; | |
| 2059 | case CPUINFO_INT_REGISTER + PPC_R17: ppc.r[17] = info->i; break; | |
| 2060 | case CPUINFO_INT_REGISTER + PPC_R18: ppc.r[18] = info->i; break; | |
| 2061 | case CPUINFO_INT_REGISTER + PPC_R19: ppc.r[19] = info->i; break; | |
| 2062 | case CPUINFO_INT_REGISTER + PPC_R20: ppc.r[20] = info->i; break; | |
| 2063 | case CPUINFO_INT_REGISTER + PPC_R21: ppc.r[21] = info->i; break; | |
| 2064 | case CPUINFO_INT_REGISTER + PPC_R22: ppc.r[22] = info->i; break; | |
| 2065 | case CPUINFO_INT_REGISTER + PPC_R23: ppc.r[23] = info->i; break; | |
| 2066 | case CPUINFO_INT_REGISTER + PPC_R24: ppc.r[24] = info->i; break; | |
| 2067 | case CPUINFO_INT_REGISTER + PPC_R25: ppc.r[25] = info->i; break; | |
| 2068 | case CPUINFO_INT_REGISTER + PPC_R26: ppc.r[26] = info->i; break; | |
| 2069 | case CPUINFO_INT_REGISTER + PPC_R27: ppc.r[27] = info->i; break; | |
| 2070 | case CPUINFO_INT_REGISTER + PPC_R28: ppc.r[28] = info->i; break; | |
| 2071 | case CPUINFO_INT_REGISTER + PPC_R29: ppc.r[29] = info->i; break; | |
| 2072 | case CPUINFO_INT_REGISTER + PPC_R30: ppc.r[30] = info->i; break; | |
| 2073 | case CPUINFO_INT_REGISTER + PPC_R31: ppc.r[31] = info->i; break; | |
| 2074 | ||
| 2075 | case CPUINFO_INT_PPC_DRC_OPTIONS: ppc.drcoptions = info->i; break; | |
| 2076 | } | |
| 2077 | } | |
| 2078 | ||
| 2079 | static void ppc_get_info(UINT32 state, cpuinfo *info) | |
| 2080 | { | |
| 2081 | switch(state) | |
| 2082 | { | |
| 2083 | /* --- the following bits of info are returned as 64-bit signed integers --- */ | |
| 2084 | case CPUINFO_INT_CONTEXT_SIZE: info->i = sizeof(ppc); break; | |
| 2085 | case CPUINFO_INT_INPUT_LINES: info->i = 1; break; | |
| 2086 | case CPUINFO_INT_DEFAULT_IRQ_VECTOR: info->i = 0; break; | |
| 2087 | case CPUINFO_INT_ENDIANNESS: info->i = CPU_IS_BE; break; | |
| 2088 | case CPUINFO_INT_CLOCK_MULTIPLIER: info->i = 1; break; | |
| 2089 | case CPUINFO_INT_CLOCK_DIVIDER: info->i = 1; break; | |
| 2090 | case CPUINFO_INT_MIN_INSTRUCTION_BYTES: info->i = 4; break; | |
| 2091 | case CPUINFO_INT_MAX_INSTRUCTION_BYTES: info->i = 4; break; | |
| 2092 | case CPUINFO_INT_MIN_CYCLES: info->i = 1; break; | |
| 2093 | case CPUINFO_INT_MAX_CYCLES: info->i = 40; break; | |
| 2094 | ||
| 2095 | case CPUINFO_INT_DATABUS_WIDTH + ADDRESS_SPACE_PROGRAM: info->i = 32; break; | |
| 2096 | case CPUINFO_INT_ADDRBUS_WIDTH + ADDRESS_SPACE_PROGRAM: info->i = 32; break; | |
| 2097 | case CPUINFO_INT_ADDRBUS_SHIFT + ADDRESS_SPACE_PROGRAM: info->i = 0; break; | |
| 2098 | case CPUINFO_INT_DATABUS_WIDTH + ADDRESS_SPACE_DATA: info->i = 0; break; | |
| 2099 | case CPUINFO_INT_ADDRBUS_WIDTH + ADDRESS_SPACE_DATA: info->i = 0; break; | |
| 2100 | case CPUINFO_INT_ADDRBUS_SHIFT + ADDRESS_SPACE_DATA: info->i = 0; break; | |
| 2101 | case CPUINFO_INT_DATABUS_WIDTH + ADDRESS_SPACE_IO: info->i = 0; break; | |
| 2102 | case CPUINFO_INT_ADDRBUS_WIDTH + ADDRESS_SPACE_IO: info->i = 0; break; | |
| 2103 | case CPUINFO_INT_ADDRBUS_SHIFT + ADDRESS_SPACE_IO: info->i = 0; break; | |
| 2104 | ||
| 2105 | case CPUINFO_INT_INPUT_STATE: info->i = CLEAR_LINE; break; | |
| 2106 | ||
| 2107 | case CPUINFO_INT_PREVIOUSPC: /* not implemented */ break; | |
| 2108 | ||
| 2109 | case CPUINFO_INT_PC: /* intentional fallthrough */ | |
| 2110 | case CPUINFO_INT_REGISTER + PPC_PC: info->i = ppc.pc; break; | |
| 2111 | case CPUINFO_INT_REGISTER + PPC_MSR: info->i = ppc_get_msr(); break; | |
| 2112 | case CPUINFO_INT_REGISTER + PPC_CR: info->i = ppc_get_cr(); break; | |
| 2113 | case CPUINFO_INT_REGISTER + PPC_LR: info->i = LR; break; | |
| 2114 | case CPUINFO_INT_REGISTER + PPC_CTR: info->i = CTR; break; | |
| 2115 | case CPUINFO_INT_REGISTER + PPC_XER: info->i = XER; break; | |
| 2116 | case CPUINFO_INT_REGISTER + PPC_SRR0: info->i = SRR0; break; | |
| 2117 | case CPUINFO_INT_REGISTER + PPC_SRR1: info->i = SRR1; break; | |
| 2118 | ||
| 2119 | case CPUINFO_INT_REGISTER + PPC_R0: info->i = ppc.r[0]; break; | |
| 2120 | case CPUINFO_INT_REGISTER + PPC_R1: info->i = ppc.r[1]; break; | |
| 2121 | case CPUINFO_INT_REGISTER + PPC_R2: info->i = ppc.r[2]; break; | |
| 2122 | case CPUINFO_INT_REGISTER + PPC_R3: info->i = ppc.r[3]; break; | |
| 2123 | case CPUINFO_INT_REGISTER + PPC_R4: info->i = ppc.r[4]; break; | |
| 2124 | case CPUINFO_INT_REGISTER + PPC_R5: info->i = ppc.r[5]; break; | |
| 2125 | case CPUINFO_INT_REGISTER + PPC_R6: info->i = ppc.r[6]; break; | |
| 2126 | case CPUINFO_INT_REGISTER + PPC_R7: info->i = ppc.r[7]; break; | |
| 2127 | case CPUINFO_INT_REGISTER + PPC_R8: info->i = ppc.r[8]; break; | |
| 2128 | case CPUINFO_INT_REGISTER + PPC_R9: info->i = ppc.r[9]; break; | |
| 2129 | case CPUINFO_INT_REGISTER + PPC_R10: info->i = ppc.r[10]; break; | |
| 2130 | case CPUINFO_INT_REGISTER + PPC_R11: info->i = ppc.r[11]; break; | |
| 2131 | case CPUINFO_INT_REGISTER + PPC_R12: info->i = ppc.r[12]; break; | |
| 2132 | case CPUINFO_INT_REGISTER + PPC_R13: info->i = ppc.r[13]; break; | |
| 2133 | case CPUINFO_INT_REGISTER + PPC_R14: info->i = ppc.r[14]; break; | |
| 2134 | case CPUINFO_INT_REGISTER + PPC_R15: info->i = ppc.r[15]; break; | |
| 2135 | case CPUINFO_INT_REGISTER + PPC_R16: info->i = ppc.r[16]; break; | |
| 2136 | case CPUINFO_INT_REGISTER + PPC_R17: info->i = ppc.r[17]; break; | |
| 2137 | case CPUINFO_INT_REGISTER + PPC_R18: info->i = ppc.r[18]; break; | |
| 2138 | case CPUINFO_INT_REGISTER + PPC_R19: info->i = ppc.r[19]; break; | |
| 2139 | case CPUINFO_INT_REGISTER + PPC_R20: info->i = ppc.r[20]; break; | |
| 2140 | case CPUINFO_INT_REGISTER + PPC_R21: info->i = ppc.r[21]; break; | |
| 2141 | case CPUINFO_INT_REGISTER + PPC_R22: info->i = ppc.r[22]; break; | |
| 2142 | case CPUINFO_INT_REGISTER + PPC_R23: info->i = ppc.r[23]; break; | |
| 2143 | case CPUINFO_INT_REGISTER + PPC_R24: info->i = ppc.r[24]; break; | |
| 2144 | case CPUINFO_INT_REGISTER + PPC_R25: info->i = ppc.r[25]; break; | |
| 2145 | case CPUINFO_INT_REGISTER + PPC_R26: info->i = ppc.r[26]; break; | |
| 2146 | case CPUINFO_INT_REGISTER + PPC_R27: info->i = ppc.r[27]; break; | |
| 2147 | case CPUINFO_INT_REGISTER + PPC_R28: info->i = ppc.r[28]; break; | |
| 2148 | case CPUINFO_INT_REGISTER + PPC_R29: info->i = ppc.r[29]; break; | |
| 2149 | case CPUINFO_INT_REGISTER + PPC_R30: info->i = ppc.r[30]; break; | |
| 2150 | case CPUINFO_INT_REGISTER + PPC_R31: info->i = ppc.r[31]; break; | |
| 2151 | ||
| 2152 | /* --- the following bits of info are returned as pointers to data or functions --- */ | |
| 2153 | case CPUINFO_PTR_GET_CONTEXT: info->getcontext = ppc_get_context; break; | |
| 2154 | case CPUINFO_PTR_SET_CONTEXT: info->setcontext = ppc_set_context; break; | |
| 2155 | case CPUINFO_PTR_BURN: info->burn = NULL; break; | |
| 2156 | #ifdef ENABLE_DEBUGGER | |
| 2157 | case CPUINFO_PTR_DISASSEMBLE: info->disassemble = ppc_dasm; break; | |
| 2158 | #endif /* ENABLE_DEBUGGER */ | |
| 2159 | case CPUINFO_PTR_INSTRUCTION_COUNTER: info->icount = &ppc_icount; break; | |
| 2160 | ||
| 2161 | /* --- the following bits of info are returned as NULL-terminated strings --- */ | |
| 2162 | case CPUINFO_STR_NAME: strcpy(info->s, "PPC403"); break; | |
| 2163 | case CPUINFO_STR_CORE_FAMILY: strcpy(info->s, "PowerPC"); break; | |
| 2164 | case CPUINFO_STR_CORE_VERSION: strcpy(info->s, "1.0"); break; | |
| 2165 | case CPUINFO_STR_CORE_FILE: strcpy(info->s, __FILE__); break; | |
| 2166 | case CPUINFO_STR_CORE_CREDITS: strcpy(info->s, "Copyright Nicola Salmoria and the MAME Team"); break; | |
| 2167 | ||
| 2168 | case CPUINFO_STR_FLAGS: strcpy(info->s, " "); break; | |
| 2169 | ||
| 2170 | case CPUINFO_STR_REGISTER + PPC_PC: sprintf(info->s, "PC: %08X", ppc.pc); break; | |
| 2171 | case CPUINFO_STR_REGISTER + PPC_MSR: sprintf(info->s, "MSR: %08X", ppc_get_msr()); break; | |
| 2172 | case CPUINFO_STR_REGISTER + PPC_CR: sprintf(info->s, "CR: %08X", ppc_get_cr()); break; | |
| 2173 | case CPUINFO_STR_REGISTER + PPC_LR: sprintf(info->s, "LR: %08X", LR); break; | |
| 2174 | case CPUINFO_STR_REGISTER + PPC_CTR: sprintf(info->s, "CTR: %08X", CTR); break; | |
| 2175 | case CPUINFO_STR_REGISTER + PPC_XER: sprintf(info->s, "XER: %08X", XER); break; | |
| 2176 | case CPUINFO_STR_REGISTER + PPC_SRR0: sprintf(info->s, "SRR0: %08X", SRR0); break; | |
| 2177 | case CPUINFO_STR_REGISTER + PPC_SRR1: sprintf(info->s, "SRR1: %08X", SRR1); break; | |
| 2178 | ||
| 2179 | case CPUINFO_STR_REGISTER + PPC_R0: sprintf(info->s, "R0: %08X", ppc.r[0]); break; | |
| 2180 | case CPUINFO_STR_REGISTER + PPC_R1: sprintf(info->s, "R1: %08X", ppc.r[1]); break; | |
| 2181 | case CPUINFO_STR_REGISTER + PPC_R2: sprintf(info->s, "R2: %08X", ppc.r[2]); break; | |
| 2182 | case CPUINFO_STR_REGISTER + PPC_R3: sprintf(info->s, "R3: %08X", ppc.r[3]); break; | |
| 2183 | case CPUINFO_STR_REGISTER + PPC_R4: sprintf(info->s, "R4: %08X", ppc.r[4]); break; | |
| 2184 | case CPUINFO_STR_REGISTER + PPC_R5: sprintf(info->s, "R5: %08X", ppc.r[5]); break; | |
| 2185 | case CPUINFO_STR_REGISTER + PPC_R6: sprintf(info->s, "R6: %08X", ppc.r[6]); break; | |
| 2186 | case CPUINFO_STR_REGISTER + PPC_R7: sprintf(info->s, "R7: %08X", ppc.r[7]); break; | |
| 2187 | case CPUINFO_STR_REGISTER + PPC_R8: sprintf(info->s, "R8: %08X", ppc.r[8]); break; | |
| 2188 | case CPUINFO_STR_REGISTER + PPC_R9: sprintf(info->s, "R9: %08X", ppc.r[9]); break; | |
| 2189 | case CPUINFO_STR_REGISTER + PPC_R10: sprintf(info->s, "R10: %08X", ppc.r[10]); break; | |
| 2190 | case CPUINFO_STR_REGISTER + PPC_R11: sprintf(info->s, "R11: %08X", ppc.r[11]); break; | |
| 2191 | case CPUINFO_STR_REGISTER + PPC_R12: sprintf(info->s, "R12: %08X", ppc.r[12]); break; | |
| 2192 | case CPUINFO_STR_REGISTER + PPC_R13: sprintf(info->s, "R13: %08X", ppc.r[13]); break; | |
| 2193 | case CPUINFO_STR_REGISTER + PPC_R14: sprintf(info->s, "R14: %08X", ppc.r[14]); break; | |
| 2194 | case CPUINFO_STR_REGISTER + PPC_R15: sprintf(info->s, "R15: %08X", ppc.r[15]); break; | |
| 2195 | case CPUINFO_STR_REGISTER + PPC_R16: sprintf(info->s, "R16: %08X", ppc.r[16]); break; | |
| 2196 | case CPUINFO_STR_REGISTER + PPC_R17: sprintf(info->s, "R17: %08X", ppc.r[17]); break; | |
| 2197 | case CPUINFO_STR_REGISTER + PPC_R18: sprintf(info->s, "R18: %08X", ppc.r[18]); break; | |
| 2198 | case CPUINFO_STR_REGISTER + PPC_R19: sprintf(info->s, "R19: %08X", ppc.r[19]); break; | |
| 2199 | case CPUINFO_STR_REGISTER + PPC_R20: sprintf(info->s, "R20: %08X", ppc.r[20]); break; | |
| 2200 | case CPUINFO_STR_REGISTER + PPC_R21: sprintf(info->s, "R21: %08X", ppc.r[21]); break; | |
| 2201 | case CPUINFO_STR_REGISTER + PPC_R22: sprintf(info->s, "R22: %08X", ppc.r[22]); break; | |
| 2202 | case CPUINFO_STR_REGISTER + PPC_R23: sprintf(info->s, "R23: %08X", ppc.r[23]); break; | |
| 2203 | case CPUINFO_STR_REGISTER + PPC_R24: sprintf(info->s, "R24: %08X", ppc.r[24]); break; | |
| 2204 | case CPUINFO_STR_REGISTER + PPC_R25: sprintf(info->s, "R25: %08X", ppc.r[25]); break; | |
| 2205 | case CPUINFO_STR_REGISTER + PPC_R26: sprintf(info->s, "R26: %08X", ppc.r[26]); break; | |
| 2206 | case CPUINFO_STR_REGISTER + PPC_R27: sprintf(info->s, "R27: %08X", ppc.r[27]); break; | |
| 2207 | case CPUINFO_STR_REGISTER + PPC_R28: sprintf(info->s, "R28: %08X", ppc.r[28]); break; | |
| 2208 | case CPUINFO_STR_REGISTER + PPC_R29: sprintf(info->s, "R29: %08X", ppc.r[29]); break; | |
| 2209 | case CPUINFO_STR_REGISTER + PPC_R30: sprintf(info->s, "R30: %08X", ppc.r[30]); break; | |
| 2210 | case CPUINFO_STR_REGISTER + PPC_R31: sprintf(info->s, "R31: %08X", ppc.r[31]); break; | |
| 2211 | } | |
| 2212 | } | |
| 2213 | ||
| 2214 | ||
| 2215 | ||
| 2216 | /* PowerPC 403 */ | |
| 2217 | #if (HAS_PPC403) | |
| 2218 | static void ppc403_set_info(UINT32 state, cpuinfo *info) | |
| 2219 | { | |
| 2220 | if (state >= CPUINFO_INT_INPUT_STATE && state <= CPUINFO_INT_INPUT_STATE + 5) | |
| 2221 | { | |
| 2222 | ppcdrc403_set_irq_line(state-CPUINFO_INT_INPUT_STATE, info->i); | |
| 2223 | return; | |
| 2224 | } | |
| 2225 | switch(state) | |
| 2226 | { | |
| 2227 | default: ppc_set_info(state, info); break; | |
| 2228 | } | |
| 2229 | } | |
| 2230 | ||
| 2231 | void ppc403_get_info(UINT32 state, cpuinfo *info) | |
| 2232 | { | |
| 2233 | switch(state) | |
| 2234 | { | |
| 2235 | /* --- the following bits of info are returned as 64-bit signed integers --- */ | |
| 2236 | case CPUINFO_INT_INPUT_LINES: info->i = 7; break; | |
| 2237 | case CPUINFO_INT_ENDIANNESS: info->i = CPU_IS_BE; break; | |
| 2238 | ||
| 2239 | /* --- the following bits of info are returned as pointers to data or functions --- */ | |
| 2240 | case CPUINFO_PTR_SET_INFO: info->setinfo = ppc403_set_info; break; | |
| 2241 | case CPUINFO_PTR_INIT: info->init = ppcdrc403_init; break; | |
| 2242 | case CPUINFO_PTR_RESET: info->reset = ppcdrc403_reset; break; | |
| 2243 | case CPUINFO_PTR_EXIT: info->exit = ppcdrc403_exit; break; | |
| 2244 | case CPUINFO_PTR_EXECUTE: info->execute = ppcdrc403_execute; break; | |
| 2245 | ||
| 2246 | /* --- the following bits of info are returned as NULL-terminated strings --- */ | |
| 2247 | case CPUINFO_STR_NAME: strcpy(info->s, "PPC403"); break; | |
| 2248 | ||
| 2249 | default: ppc_get_info(state, info); break; | |
| 2250 | } | |
| 2251 | } | |
| 2252 | #endif | |
| 2253 | ||
| 2254 | /* PowerPC 603 */ | |
| 2255 | #if (HAS_PPC603) | |
| 2256 | static void ppc603_set_info(UINT32 state, cpuinfo *info) | |
| 2257 | { | |
| 2258 | if (state >= CPUINFO_INT_INPUT_STATE && state <= CPUINFO_INT_INPUT_STATE + 5) | |
| 2259 | { | |
| 2260 | ppcdrc603_set_irq_line(state-CPUINFO_INT_INPUT_STATE, info->i); | |
| 2261 | return; | |
| 2262 | } | |
| 2263 | switch(state) | |
| 2264 | { | |
| 2265 | case CPUINFO_INT_REGISTER + PPC_DEC: write_decrementer(info->i); break; | |
| 2266 | default: ppc_set_info(state, info); break; | |
| 2267 | } | |
| 2268 | } | |
| 2269 | ||
| 2270 | void ppc603_get_info(UINT32 state, cpuinfo *info) | |
| 2271 | { | |
| 2272 | switch(state) | |
| 2273 | { | |
| 2274 | /* --- the following bits of info are returned as 64-bit signed integers --- */ | |
| 2275 | case CPUINFO_INT_INPUT_LINES: info->i = 5; break; | |
| 2276 | case CPUINFO_INT_ENDIANNESS: info->i = CPU_IS_BE; break; | |
| 2277 | case CPUINFO_INT_REGISTER + PPC_DEC: info->i = read_decrementer(); break; | |
| 2278 | ||
| 2279 | case CPUINFO_INT_DATABUS_WIDTH + ADDRESS_SPACE_PROGRAM: info->i = 64; break; | |
| 2280 | case CPUINFO_INT_ADDRBUS_WIDTH + ADDRESS_SPACE_PROGRAM: info->i = 32; break; | |
| 2281 | case CPUINFO_INT_LOGADDR_WIDTH + ADDRESS_SPACE_PROGRAM: info->i = 32; break; | |
| 2282 | case CPUINFO_INT_PAGE_SHIFT + ADDRESS_SPACE_PROGRAM: info->i = 17; break; | |
| 2283 | ||
| 2284 | /* --- the following bits of info are returned as pointers to data or functions --- */ | |
| 2285 | case CPUINFO_PTR_SET_INFO: info->setinfo = ppc603_set_info; break; | |
| 2286 | case CPUINFO_PTR_INIT: info->init = ppcdrc603_init; break; | |
| 2287 | case CPUINFO_PTR_RESET: info->reset = ppcdrc603_reset; break; | |
| 2288 | case CPUINFO_PTR_EXIT: info->exit = ppcdrc603_exit; break; | |
| 2289 | case CPUINFO_PTR_EXECUTE: info->execute = ppcdrc603_execute; break; | |
| 2290 | case CPUINFO_PTR_READ: info->read = ppc_read; break; | |
| 2291 | case CPUINFO_PTR_WRITE: info->write = ppc_write; break; | |
| 2292 | case CPUINFO_PTR_READOP: info->readop = ppc_readop; break; | |
| 2293 | case CPUINFO_PTR_TRANSLATE: info->translate = ppc_translate_address_cb; break; | |
| 2294 | ||
| 2295 | /* --- the following bits of info are returned as NULL-terminated strings --- */ | |
| 2296 | case CPUINFO_STR_NAME: strcpy(info->s, "PPC603"); break; | |
| 2297 | case CPUINFO_STR_REGISTER + PPC_DEC: sprintf(info->s, "DEC: %08X", read_decrementer()); break; | |
| 2298 | ||
| 2299 | default: ppc_get_info(state, info); break; | |
| 2300 | } | |
| 2301 | } | |
| 2302 | #endif | |
| 2303 | ||
| 2304 | /* PowerPC 602 */ | |
| 2305 | #if (HAS_PPC602) | |
| 2306 | static void ppc602_set_info(UINT32 state, cpuinfo *info) | |
| 2307 | { | |
| 2308 | if (state >= CPUINFO_INT_INPUT_STATE && state <= CPUINFO_INT_INPUT_STATE + 5) | |
| 2309 | { | |
| 2310 | ppcdrc602_set_irq_line(state-CPUINFO_INT_INPUT_STATE, info->i); | |
| 2311 | return; | |
| 2312 | } | |
| 2313 | switch(state) | |
| 2314 | { | |
| 2315 | default: ppc_set_info(state, info); break; | |
| 2316 | } | |
| 2317 | } | |
| 2318 | ||
| 2319 | void ppc602_get_info(UINT32 state, cpuinfo *info) | |
| 2320 | { | |
| 2321 | switch(state) | |
| 2322 | { | |
| 2323 | /* --- the following bits of info are returned as 64-bit signed integers --- */ | |
| 2324 | case CPUINFO_INT_INPUT_LINES: info->i = 5; break; | |
| 2325 | case CPUINFO_INT_ENDIANNESS: info->i = CPU_IS_BE; break; | |
| 2326 | ||
| 2327 | case CPUINFO_INT_DATABUS_WIDTH + ADDRESS_SPACE_PROGRAM: info->i = 64; break; | |
| 2328 | case CPUINFO_INT_ADDRBUS_WIDTH + ADDRESS_SPACE_PROGRAM: info->i = 32; break; | |
| 2329 | case CPUINFO_INT_LOGADDR_WIDTH + ADDRESS_SPACE_PROGRAM: info->i = 32; break; | |
| 2330 | case CPUINFO_INT_PAGE_SHIFT + ADDRESS_SPACE_PROGRAM: info->i = 17; break; | |
| 2331 | ||
| 2332 | /* --- the following bits of info are returned as pointers to data or functions --- */ | |
| 2333 | case CPUINFO_PTR_SET_INFO: info->setinfo = ppc602_set_info; break; | |
| 2334 | case CPUINFO_PTR_INIT: info->init = ppcdrc602_init; break; | |
| 2335 | case CPUINFO_PTR_RESET: info->reset = ppcdrc602_reset; break; | |
| 2336 | case CPUINFO_PTR_EXIT: info->exit = ppcdrc602_exit; break; | |
| 2337 | case CPUINFO_PTR_EXECUTE: info->execute = ppcdrc602_execute; break; | |
| 2338 | case CPUINFO_PTR_READ: info->read = ppc_read; break; | |
| 2339 | case CPUINFO_PTR_WRITE: info->write = ppc_write; break; | |
| 2340 | case CPUINFO_PTR_READOP: info->readop = ppc_readop; break; | |
| 2341 | case CPUINFO_PTR_TRANSLATE: info->translate = ppc_translate_address_cb; break; | |
| 2342 | ||
| 2343 | /* --- the following bits of info are returned as NULL-terminated strings --- */ | |
| 2344 | case CPUINFO_STR_NAME: strcpy(info->s, "PPC602"); break; | |
| 2345 | ||
| 2346 | default: ppc_get_info(state, info); break; | |
| 2347 | } | |
| 2348 | } | |
| 2349 | #endif | |
| 2350 | ||
| 2351 | /* Motorola MPC8240 */ | |
| 2352 | ||
| 2353 | #if (HAS_MPC8240) | |
| 2354 | static void mpc8240_set_info(UINT32 state, cpuinfo *info) | |
| 2355 | { | |
| 2356 | if (state >= CPUINFO_INT_INPUT_STATE && state <= CPUINFO_INT_INPUT_STATE + 5) | |
| 2357 | { | |
| 2358 | ppcdrc603_set_irq_line(state-CPUINFO_INT_INPUT_STATE, info->i); | |
| 2359 | return; | |
| 2360 | } | |
| 2361 | switch(state) | |
| 2362 | { | |
| 2363 | default: ppc_set_info(state, info); break; | |
| 2364 | } | |
| 2365 | } | |
| 2366 | ||
| 2367 | void mpc8240_get_info(UINT32 state, cpuinfo *info) | |
| 2368 | { | |
| 2369 | switch(state) | |
| 2370 | { | |
| 2371 | /* --- the following bits of info are returned as 64-bit signed integers --- */ | |
| 2372 | case CPUINFO_INT_INPUT_LINES: info->i = 5; break; | |
| 2373 | case CPUINFO_INT_ENDIANNESS: info->i = CPU_IS_BE; break; | |
| 2374 | ||
| 2375 | case CPUINFO_INT_DATABUS_WIDTH + ADDRESS_SPACE_PROGRAM: info->i = 64; break; | |
| 2376 | case CPUINFO_INT_ADDRBUS_WIDTH + ADDRESS_SPACE_PROGRAM: info->i = 32; break; | |
| 2377 | ||
| 2378 | /* --- the following bits of info are returned as pointers to data or functions --- */ | |
| 2379 | case CPUINFO_PTR_SET_INFO: info->setinfo = mpc8240_set_info; break; | |
| 2380 | case CPUINFO_PTR_INIT: info->init = mpc8240drc_init; break; | |
| 2381 | case CPUINFO_PTR_RESET: info->reset = ppcdrc603_reset; break; | |
| 2382 | case CPUINFO_PTR_EXIT: info->exit = mpc8240drc_exit; break; | |
| 2383 | case CPUINFO_PTR_EXECUTE: info->execute = ppcdrc603_execute; break; | |
| 2384 | case CPUINFO_PTR_READ: info->read = ppc_read; break; | |
| 2385 | case CPUINFO_PTR_WRITE: info->write = ppc_write; break; | |
| 2386 | case CPUINFO_PTR_READOP: info->readop = ppc_readop; break; | |
| 2387 | ||
| 2388 | /* --- the following bits of info are returned as NULL-terminated strings --- */ | |
| 2389 | case CPUINFO_STR_NAME: strcpy(info->s, "MPC8240"); break; | |
| 2390 | ||
| 2391 | default: ppc_get_info(state, info); break; | |
| 2392 | } | |
| 2393 | } | |
| 2394 | #endif | |
| 2395 | ||
| 2396 | ||
| 2397 | /* PPC601 */ | |
| 2398 | ||
| 2399 | #if (HAS_PPC601) | |
| 2400 | static void ppc601_set_info(UINT32 state, cpuinfo *info) | |
| 2401 | { | |
| 2402 | if (state >= CPUINFO_INT_INPUT_STATE && state <= CPUINFO_INT_INPUT_STATE + 5) | |
| 2403 | { | |
| 2404 | ppcdrc603_set_irq_line(state-CPUINFO_INT_INPUT_STATE, info->i); | |
| 2405 | return; | |
| 2406 | } | |
| 2407 | switch(state) | |
| 2408 | { | |
| 2409 | default: ppc_set_info(state, info); break; | |
| 2410 | } | |
| 2411 | } | |
| 2412 | ||
| 2413 | void ppc601_get_info(UINT32 state, cpuinfo *info) | |
| 2414 | { | |
| 2415 | switch(state) | |
| 2416 | { | |
| 2417 | /* --- the following bits of info are returned as 64-bit signed integers --- */ | |
| 2418 | case CPUINFO_INT_INPUT_LINES: info->i = 5; break; | |
| 2419 | case CPUINFO_INT_ENDIANNESS: info->i = CPU_IS_BE; break; | |
| 2420 | ||
| 2421 | case CPUINFO_INT_DATABUS_WIDTH + ADDRESS_SPACE_PROGRAM: info->i = 64; break; | |
| 2422 | case CPUINFO_INT_ADDRBUS_WIDTH + ADDRESS_SPACE_PROGRAM: info->i = 32; break; | |
| 2423 | ||
| 2424 | /* --- the following bits of info are returned as pointers to data or functions --- */ | |
| 2425 | case CPUINFO_PTR_SET_INFO: info->setinfo = ppc601_set_info; break; | |
| 2426 | case CPUINFO_PTR_INIT: info->init = ppc601drc_init; break; | |
| 2427 | case CPUINFO_PTR_RESET: info->reset = ppcdrc603_reset; break; | |
| 2428 | case CPUINFO_PTR_EXIT: info->exit = ppc601drc_exit; break; | |
| 2429 | case CPUINFO_PTR_EXECUTE: info->execute = ppcdrc603_execute; break; | |
| 2430 | case CPUINFO_PTR_READ: info->read = ppc_read; break; | |
| 2431 | case CPUINFO_PTR_WRITE: info->write = ppc_write; break; | |
| 2432 | case CPUINFO_PTR_READOP: info->readop = ppc_readop; break; | |
| 2433 | ||
| 2434 | /* --- the following bits of info are returned as NULL-terminated strings --- */ | |
| 2435 | case CPUINFO_STR_NAME: strcpy(info->s, "PPC601"); break; | |
| 2436 | ||
| 2437 | default: ppc_get_info(state, info); break; | |
| 2438 | } | |
| 2439 | } | |
| 2440 | #endif | |
| 2441 | ||
| 2442 | /* PPC604 */ | |
| 2443 | ||
| 2444 | #if (HAS_PPC604) | |
| 2445 | static void ppc604_set_info(UINT32 state, cpuinfo *info) | |
| 2446 | { | |
| 2447 | if (state >= CPUINFO_INT_INPUT_STATE && state <= CPUINFO_INT_INPUT_STATE + 5) | |
| 2448 | { | |
| 2449 | ppcdrc603_set_irq_line(state-CPUINFO_INT_INPUT_STATE, info->i); | |
| 2450 | return; | |
| 2451 | } | |
| 2452 | switch(state) | |
| 2453 | { | |
| 2454 | default: ppc_set_info(state, info); break; | |
| 2455 | } | |
| 2456 | } | |
| 2457 | ||
| 2458 | void ppc604_get_info(UINT32 state, cpuinfo *info) | |
| 2459 | { | |
| 2460 | switch(state) | |
| 2461 | { | |
| 2462 | /* --- the following bits of info are returned as 64-bit signed integers --- */ | |
| 2463 | case CPUINFO_INT_INPUT_LINES: info->i = 5; break; | |
| 2464 | case CPUINFO_INT_ENDIANNESS: info->i = CPU_IS_BE; break; | |
| 2465 | ||
| 2466 | case CPUINFO_INT_DATABUS_WIDTH + ADDRESS_SPACE_PROGRAM: info->i = 64; break; | |
| 2467 | case CPUINFO_INT_ADDRBUS_WIDTH + ADDRESS_SPACE_PROGRAM: info->i = 32; break; | |
| 2468 | ||
| 2469 | /* --- the following bits of info are returned as pointers to data or functions --- */ | |
| 2470 | case CPUINFO_PTR_SET_INFO: info->setinfo = ppc604_set_info; break; | |
| 2471 | case CPUINFO_PTR_INIT: info->init = ppc604drc_init; break; | |
| 2472 | case CPUINFO_PTR_RESET: info->reset = ppcdrc603_reset; break; | |
| 2473 | case CPUINFO_PTR_EXIT: info->exit = ppc604drc_exit; break; | |
| 2474 | case CPUINFO_PTR_EXECUTE: info->execute = ppcdrc603_execute; break; | |
| 2475 | case CPUINFO_PTR_READ: info->read = ppc_read; break; | |
| 2476 | case CPUINFO_PTR_WRITE: info->write = ppc_write; break; | |
| 2477 | case CPUINFO_PTR_READOP: info->readop = ppc_readop; break; | |
| 2478 | ||
| 2479 | /* --- the following bits of info are returned as NULL-terminated strings --- */ | |
| 2480 | case CPUINFO_STR_NAME: strcpy(info->s, "PPC604"); break; | |
| 2481 | ||
| 2482 | default: ppc_get_info(state, info); break; | |
| 2483 | } | |
| 2484 | } | |
| 2485 | #endif |
| r2724 | r2725 | |
|---|---|---|
| 86 | 86 | #define FREG(x) DRCUML_PTYPE_FLOAT_REGISTER, (DRCUML_REG_F0 + (x)) |
| 87 | 87 | #define MVAR(x) DRCUML_PTYPE_MAPVAR, (DRCUML_MAPVAR_M0 + (x)) |
| 88 | 88 | #define MEM(x) DRCUML_PTYPE_MEMORY, (FPTR)(x) |
| 89 | #define PARAM(t,v) (t), (v) | |
| 89 | 90 | |
| 90 | 91 | |
| 91 | 92 | |
| r2724 | r2725 | |
| 128 | 129 | |
| 129 | 130 | |
| 130 | 131 | /* ----- Internal Register Operations ----- */ |
| 131 | #define UML_SETMODE(block, mode) do { drcuml_block_append_1(block, DRCUML_OP_SETMODE, 4, IF_ALWAYS, mode); } while (0) | |
| 132 | #define UML_GETMODE(block, dst) do { drcuml_block_append_1(block, DRCUML_OP_GETMODE, 4, IF_ALWAYS, dst); } while (0) | |
| 133 | 132 | #define UML_SETFMOD(block, mode) do { drcuml_block_append_1(block, DRCUML_OP_SETFMOD, 4, IF_ALWAYS, mode); } while (0) |
| 134 | 133 | #define UML_GETFMOD(block, dst) do { drcuml_block_append_1(block, DRCUML_OP_GETFMOD, 4, IF_ALWAYS, dst); } while (0) |
| 135 | #define UML_SUBICNT(block, delta, param) do { drcuml_block_append_2(block, DRCUML_OP_SUBICNT, 4, IF_ALWAYS, delta, param); } while (0) | |
| 136 | 134 | #define UML_GETEXP(block, dst) do { drcuml_block_append_1(block, DRCUML_OP_GETEXP, 4, IF_ALWAYS, dst); } while (0) |
| 135 | #define UML_SAVE(block, dst) do { drcuml_block_append_1(block, DRCUML_OP_SAVE, 4, IF_ALWAYS, MEM(dst)); } while (0) | |
| 136 | #define UML_RESTORE(block, src) do { drcuml_block_append_1(block, DRCUML_OP_RESTORE, 4, IF_ALWAYS, MEM(src)); } while (0) | |
| 137 | 137 | |
| 138 | 138 | |
| 139 | 139 | /* ----- 32-Bit Integer Operations ----- */ |
| r2724 | r2725 | |
| 170 | 170 | #define UML_SEXT1(block, dst, src1) do { drcuml_block_append_2(block, DRCUML_OP_SEXT1, 4, IF_ALWAYS, dst, src1); } while (0) |
| 171 | 171 | #define UML_SEXT2(block, dst, src1) do { drcuml_block_append_2(block, DRCUML_OP_SEXT2, 4, IF_ALWAYS, dst, src1); } while (0) |
| 172 | 172 | |
| 173 | #define UML_XTRACT(block, dst, src, shift, mask) do { drcuml_block_append_4(block, DRCUML_OP_XTRACT, 4, IF_ALWAYS, dst, src, shift, mask); } while (0) | |
| 174 | #define UML_INSERT(block, dst, src, shift, mask) do { drcuml_block_append_4(block, DRCUML_OP_INSERT, 4, IF_ALWAYS, dst, src, shift, mask); } while (0) | |
| 175 | ||
| 173 | 176 | #define UML_NEG(block, dst, src1) do { drcuml_block_append_2(block, DRCUML_OP_NEG, 4, FLAGS_NONE, dst, src1); } while (0) |
| 174 | 177 | #define UML_NEGf(block, dst, src1, flags) do { drcuml_block_append_2(block, DRCUML_OP_NEG, 4, flags, dst, src1); } while (0) |
| 175 | 178 | |
| r2724 | r2725 | |
| 274 | 277 | #define UML_DSEXT2(block, dst, src1) do { drcuml_block_append_2(block, DRCUML_OP_SEXT2, 8, IF_ALWAYS, dst, src1); } while (0) |
| 275 | 278 | #define UML_DSEXT4(block, dst, src1) do { drcuml_block_append_2(block, DRCUML_OP_SEXT4, 8, IF_ALWAYS, dst, src1); } while (0) |
| 276 | 279 | |
| 280 | #define UML_DXTRACT(block, dst, src, shift, mask) do { drcuml_block_append_4(block, DRCUML_OP_XTRACT, 8, IF_ALWAYS, dst, src, shift, mask); } while (0) | |
| 281 | #define UML_DINSERT(block, dst, src, shift, mask) do { drcuml_block_append_4(block, DRCUML_OP_INSERT, 8, IF_ALWAYS, dst, src, shift, mask); } while (0) | |
| 282 | ||
| 277 | 283 | #define UML_DNEG(block, dst, src1) do { drcuml_block_append_2(block, DRCUML_OP_NEG, 8, FLAGS_NONE, dst, src1); } while (0) |
| 278 | 284 | #define UML_DNEGf(block, dst, src1, flags) do { drcuml_block_append_2(block, DRCUML_OP_NEG, 8, flags, dst, src1); } while (0) |
| 279 | 285 |
| r2724 | r2725 | |
|---|---|---|
| 44 | 44 | }; |
| 45 | 45 | typedef enum _mips3_flavor mips3_flavor; |
| 46 | 46 | |
| 47 | /* TLB bits */ | |
| 48 | #define TLB_GLOBAL 0x01 | |
| 49 | #define TLB_VALID 0x02 | |
| 50 | #define TLB_DIRTY 0x04 | |
| 51 | #define TLB_PRESENT 0x08 | |
| 52 | ||
| 47 | 53 | /* COP0 registers */ |
| 48 | #define COP0_Index 0 | |
| 49 | #define COP0_Random 1 | |
| 50 | #define COP0_EntryLo 2 | |
| 51 | #define COP0_EntryLo0 2 | |
| 52 | #define COP0_EntryLo1 3 | |
| 53 | #define COP0_Context 4 | |
| 54 | #define COP0_PageMask 5 | |
| 55 | #define COP0_Wired 6 | |
| 56 | #define COP0_BadVAddr 8 | |
| 57 | #define COP0_Count 9 | |
| 58 | #define COP0_EntryHi 10 | |
| 59 | #define COP0_Compare 11 | |
| 60 | #define COP0_Status 12 | |
| 61 | #define COP0_Cause 13 | |
| 62 | #define COP0_EPC 14 | |
| 63 | #define COP0_PRId 15 | |
| 64 | #define COP0_Config 16 | |
| 65 | #define COP0_XContext 20 | |
| 54 | #define COP0_Index 0 | |
| 55 | #define COP0_Random 1 | |
| 56 | #define COP0_EntryLo 2 | |
| 57 | #define COP0_EntryLo0 2 | |
| 58 | #define COP0_EntryLo1 3 | |
| 59 | #define COP0_Context 4 | |
| 60 | #define COP0_PageMask 5 | |
| 61 | #define COP0_Wired 6 | |
| 62 | #define COP0_BadVAddr 8 | |
| 63 | #define COP0_Count 9 | |
| 64 | #define COP0_EntryHi 10 | |
| 65 | #define COP0_Compare 11 | |
| 66 | #define COP0_Status 12 | |
| 67 | #define COP0_Cause 13 | |
| 68 | #define COP0_EPC 14 | |
| 69 | #define COP0_PRId 15 | |
| 70 | #define COP0_Config 16 | |
| 71 | #define COP0_LLAddr 17 | |
| 72 | #define COP0_XContext 20 | |
| 73 | #define COP0_ECC 26 | |
| 74 | #define COP0_CacheErr 27 | |
| 75 | #define COP0_TagLo 28 | |
| 76 | #define COP0_TagHi 29 | |
| 77 | #define COP0_ErrorPC 30 | |
| 66 | 78 | |
| 67 | 79 | /* Status register bits */ |
| 68 | #define SR_IE 0x00000001 | |
| 69 | #define SR_EXL 0x00000002 | |
| 70 | #define SR_ERL 0x00000004 | |
| 71 | #define SR_KSU_MASK 0x00000018 | |
| 72 | #define SR_KSU_KERNEL 0x00000000 | |
| 73 | #define SR_KSU_SUPERVISOR 0x00000008 | |
| 74 | #define SR_KSU_USER 0x00000010 | |
| 75 | #define SR_IMSW0 0x00000100 | |
| 76 | #define SR_IMSW1 0x00000200 | |
| 77 | #define SR_IMEX0 0x00000400 | |
| 78 | #define SR_IMEX1 0x00000800 | |
| 79 | #define SR_IMEX2 0x00001000 | |
| 80 | #define SR_IMEX3 0x00002000 | |
| 81 | #define SR_IMEX4 0x00004000 | |
| 82 | #define SR_IMEX5 0x00008000 | |
| 83 | #define SR_DE 0x00010000 | |
| 84 | #define SR_CE 0x00020000 | |
| 85 | #define SR_CH 0x00040000 | |
| 86 | #define SR_SR 0x00100000 | |
| 87 | #define SR_TS 0x00200000 | |
| 88 | #define SR_BEV 0x00400000 | |
| 89 | #define SR_RE 0x02000000 | |
| 90 | #define SR_FR 0x04000000 | |
| 91 | #define SR_RP 0x08000000 | |
| 92 | #define SR_COP0 0x10000000 | |
| 93 | #define SR_COP1 0x20000000 | |
| 94 | #define SR_COP2 0x40000000 | |
| 95 | #define SR_COP3 0x80000000 | |
| 80 | #define SR_IE 0x00000001 | |
| 81 | #define SR_EXL 0x00000002 | |
| 82 | #define SR_ERL 0x00000004 | |
| 83 | #define SR_KSU_MASK 0x00000018 | |
| 84 | #define SR_KSU_KERNEL 0x00000000 | |
| 85 | #define SR_KSU_SUPERVISOR 0x00000008 | |
| 86 | #define SR_KSU_USER 0x00000010 | |
| 87 | #define SR_IMSW0 0x00000100 | |
| 88 | #define SR_IMSW1 0x00000200 | |
| 89 | #define SR_IMEX0 0x00000400 | |
| 90 | #define SR_IMEX1 0x00000800 | |
| 91 | #define SR_IMEX2 0x00001000 | |
| 92 | #define SR_IMEX3 0x00002000 | |
| 93 | #define SR_IMEX4 0x00004000 | |
| 94 | #define SR_IMEX5 0x00008000 | |
| 95 | #define SR_DE 0x00010000 | |
| 96 | #define SR_CE 0x00020000 | |
| 97 | #define SR_CH 0x00040000 | |
| 98 | #define SR_SR 0x00100000 | |
| 99 | #define SR_TS 0x00200000 | |
| 100 | #define SR_BEV 0x00400000 | |
| 101 | #define SR_RE 0x02000000 | |
| 102 | #define SR_FR 0x04000000 | |
| 103 | #define SR_RP 0x08000000 | |
| 104 | #define SR_COP0 0x10000000 | |
| 105 | #define SR_COP1 0x20000000 | |
| 106 | #define SR_COP2 0x40000000 | |
| 107 | #define SR_COP3 0x80000000 | |
| 96 | 108 | |
| 97 | 109 | /* exception types */ |
| 98 | #define EXCEPTION_INTERRUPT 0 | |
| 99 | #define EXCEPTION_TLBMOD 1 | |
| 100 | #define EXCEPTION_TLBLOAD 2 | |
| 101 | #define EXCEPTION_TLBSTORE 3 | |
| 102 | #define EXCEPTION_ADDRLOAD 4 | |
| 103 | #define EXCEPTION_ADDRSTORE 5 | |
| 104 | #define EXCEPTION_BUSINST 6 | |
| 105 | #define EXCEPTION_BUSDATA 7 | |
| 106 | #define EXCEPTION_SYSCALL 8 | |
| 107 | #define EXCEPTION_BREAK 9 | |
| 108 | #define EXCEPTION_INVALIDOP 10 | |
| 109 | #define EXCEPTION_BADCOP 11 | |
| 110 | #define EXCEPTION_OVERFLOW 12 | |
| 111 | #define EXCEPTION_TRAP 13 | |
| 112 | #define EXCEPTION_COUNT 16 | |
| 110 | #define EXCEPTION_INTERRUPT 0 | |
| 111 | #define EXCEPTION_TLBMOD 1 | |
| 112 | #define EXCEPTION_TLBLOAD 2 | |
| 113 | #define EXCEPTION_TLBSTORE 3 | |
| 114 | #define EXCEPTION_ADDRLOAD 4 | |
| 115 | #define EXCEPTION_ADDRSTORE 5 | |
| 116 | #define EXCEPTION_BUSINST 6 | |
| 117 | #define EXCEPTION_BUSDATA 7 | |
| 118 | #define EXCEPTION_SYSCALL 8 | |
| 119 | #define EXCEPTION_BREAK 9 | |
| 120 | #define EXCEPTION_INVALIDOP 10 | |
| 121 | #define EXCEPTION_BADCOP 11 | |
| 122 | #define EXCEPTION_OVERFLOW 12 | |
| 123 | #define EXCEPTION_TRAP 13 | |
| 124 | #define EXCEPTION_TLBLOAD_FILL 16 | |
| 125 | #define EXCEPTION_TLBSTORE_FILL 17 | |
| 126 | #define EXCEPTION_COUNT 18 | |
| 113 | 127 | |
| 114 | 128 | |
| 115 | 129 |
| r2724 | r2725 | |
|---|---|---|
| 7 | 7 | ***************************************************************************/ |
| 8 | 8 | |
| 9 | 9 | #include "debugger.h" |
| 10 | #include "deprecat.h" | |
| 11 | 10 | #include "r3000.h" |
| 12 | 11 | |
| 13 | 12 |
| r2724 | r2725 | |
|---|---|---|
| 516 | 516 | return TRUE; |
| 517 | 517 | |
| 518 | 518 | case 0x18: /* ERET */ |
| 519 | desc->flags |= OPFLAG_IS_UNCONDITIONAL_BRANCH | OPFLAG_END_SEQUENCE; | |
| 519 | desc->flags |= OPFLAG_CAN_CHANGE_MODES | OPFLAG_IS_UNCONDITIONAL_BRANCH | OPFLAG_END_SEQUENCE; | |
| 520 | 520 | return TRUE; |
| 521 | 521 | } |
| 522 | 522 | return FALSE; |
| r2724 | r2725 | |
|---|---|---|
| 30 | 30 | |
| 31 | 31 | |
| 32 | 32 | /*************************************************************************** |
| 33 | CONSTANTS | |
| 34 | ***************************************************************************/ | |
| 35 | ||
| 36 | /* this defines a branch targetpc that is dynamic at runtime */ | |
| 37 | #define BRANCH_TARGET_DYNAMIC (~0) | |
| 38 | ||
| 39 | ||
| 40 | /* opcode branch flags */ | |
| 41 | #define OPFLAG_IS_UNCONDITIONAL_BRANCH 0x00000001 /* instruction is unconditional branch */ | |
| 42 | ||
| 43 | ||
| 44 | /*************************************************************************** | |
| 45 | 33 | FUNCTION PROTOTYPES |
| 46 | 34 | ***************************************************************************/ |
| 47 | 35 |
| r2724 | r2725 | |
|---|---|---|
| 14 | 14 | |
| 15 | 15 | * Add DRC option to flush PC before calling memory handlers |
| 16 | 16 | |
| 17 | * Map MIPS registers to i5-i7 (or more) | |
| 18 | - should rely on backend hints to know how many to assign | |
| 19 | - add instrumentation to figure out which ones are most used | |
| 20 | - on entry, load registers; on exit, flush them | |
| 21 | - also flush before calling debugger | |
| 22 | ||
| 23 | 17 | * Constant tracking? (hasn't bought us much in the past) |
| 24 | 18 | |
| 25 | 19 | * Customized mapped/unmapped memory handlers |
| r2724 | r2725 | |
| 53 | 47 | #define LOG_UML (0) |
| 54 | 48 | #define LOG_NATIVE (0) |
| 55 | 49 | |
| 50 | #define DISABLE_FAST_REGISTERS (0) | |
| 56 | 51 | #define SINGLE_INSTRUCTION_MODE (0) |
| 52 | ||
| 57 | 53 | #define PRINTF_EXCEPTIONS (0) |
| 54 | #define PRINTF_MMU (0) | |
| 58 | 55 | |
| 59 | 56 | #define PROBE_ADDRESS ~0 |
| 60 | 57 | |
| r2724 | r2725 | |
| 68 | 65 | #define MAPVAR_PC MVAR(0) |
| 69 | 66 | #define MAPVAR_CYCLES MVAR(1) |
| 70 | 67 | |
| 68 | /* modes */ | |
| 69 | #define MODE_KERNEL 0 | |
| 70 | #define MODE_SUPER 1 | |
| 71 | #define MODE_USER 2 | |
| 72 | ||
| 71 | 73 | /* size of the execution code cache */ |
| 72 | 74 | #define CACHE_SIZE (32 * 1024 * 1024) |
| 73 | 75 | |
| r2724 | r2725 | |
| 80 | 82 | /* exit codes */ |
| 81 | 83 | #define EXECUTE_OUT_OF_CYCLES 0 |
| 82 | 84 | #define EXECUTE_MISSING_CODE 1 |
| 85 | #define EXECUTE_UNMAPPED_CODE 2 | |
| 86 | #define EXECUTE_RESET_CACHE 3 | |
| 83 | 87 | |
| 84 | 88 | |
| 85 | 89 | |
| r2724 | r2725 | |
| 93 | 97 | #define LOPTR(x) ((UINT32 *)(x) + 1) |
| 94 | 98 | #endif |
| 95 | 99 | |
| 96 | #define R32(reg) | |
| 100 | #define R32(reg) mips3.regmaplo[ | |
| 97 | 101 | #define LO32 R32(REG_LO) |
| 98 | 102 | #define HI32 R32(REG_HI) |
| 99 | 103 | #define CPR032(reg) MEM(LOPTR(&mips3.core->cpr[0][reg])) |
| 100 | 104 | #define CCR032(reg) MEM(LOPTR(&mips3.core->ccr[0][reg])) |
| 101 | #define FPR32(reg) MEM((mips3.cstate->mode == 0) ? &((float *)&mips3.core->cpr[1][0])[reg] : (float *)&mips3.core->cpr[1][reg]) | |
| 105 | #define FPR32(reg) MEM(((mips3.cstate->mode & 1) == 0) ? &((float *)&mips3.core->cpr[1][0])[reg] : (float *)&mips3.core->cpr[1][reg]) | |
| 102 | 106 | #define CCR132(reg) MEM(LOPTR(&mips3.core->ccr[1][reg])) |
| 103 | 107 | #define CPR232(reg) MEM(LOPTR(&mips3.core->cpr[2][reg])) |
| 104 | 108 | #define CCR232(reg) MEM(LOPTR(&mips3.core->ccr[2][reg])) |
| 105 | 109 | |
| 106 | #define R64(reg) | |
| 110 | #define R64(reg) mips3.regmap[ | |
| 107 | 111 | #define LO64 R64(REG_LO) |
| 108 | 112 | #define HI64 R64(REG_HI) |
| 109 | 113 | #define CPR064(reg) MEM(&mips3.core->cpr[0][reg]) |
| 110 | 114 | #define CCR064(reg) MEM(&mips3.core->ccr[0][reg]) |
| 111 | #define FPR64(reg) MEM((mips3.cstate->mode == 0) ? (double *)&mips3.core->cpr[1][(reg)/2] : (double *)&mips3.core->cpr[1][reg]) | |
| 115 | #define FPR64(reg) MEM(((mips3.cstate->mode & 1) == 0) ? (double *)&mips3.core->cpr[1][(reg)/2] : (double *)&mips3.core->cpr[1][reg]) | |
| 112 | 116 | #define CCR164(reg) MEM(&mips3.core->ccr[1][reg]) |
| 113 | 117 | #define CPR264(reg) MEM(&mips3.core->cpr[2][reg]) |
| 114 | 118 | #define CCR264(reg) MEM(&mips3.core->ccr[2][reg]) |
| r2724 | r2725 | |
| 160 | 164 | /* parameters for subroutines */ |
| 161 | 165 | UINT64 numcycles; /* return value from gettotalcycles */ |
| 162 | 166 | UINT32 mode; /* current global mode */ |
| 167 | UINT32 arg0; /* print_debug argument 1 */ | |
| 168 | UINT32 arg1; /* print_debug argument 2 */ | |
| 163 | 169 | |
| 164 | 170 | /* tables */ |
| 165 | 171 | UINT8 fpmode[4]; /* FPU mode table */ |
| r2724 | r2725 | |
| 190 | 196 | /* internal stuff */ |
| 191 | 197 | UINT8 cache_dirty; /* true if we need to flush the cache */ |
| 192 | 198 | |
| 199 | /* register mappings */ | |
| 200 | drcuml_parameter regmap[34]; /* parameter to register mappings for all 32 integer registers */ | |
| 201 | drcuml_parameter regmaplo[34]; /* parameter to register mappings for all 32 integer registers */ | |
| 202 | ||
| 193 | 203 | /* subroutines */ |
| 194 | 204 | drcuml_codehandle * entry; /* entry point */ |
| 195 | 205 | drcuml_codehandle * nocode; /* nocode exception handler */ |
| 196 | 206 | drcuml_codehandle * out_of_cycles; /* out of cycles exception handler */ |
| 197 | drcuml_codehandle * tlb_mismatch; /* tlb mismatch at current PC */ | |
| 198 | drcuml_codehandle * read8; /* read byte */ | |
| 199 | drcuml_codehandle * write8; /* write byte */ | |
| 200 | drcuml_codehandle * read16; /* read half */ | |
| 201 | drcuml_codehandle * write16; /* write half */ | |
| 202 | drcuml_codehandle * read32; /* read word */ | |
| 203 | drcuml_codehandle * read32mask; /* read word masked */ | |
| 204 | drcuml_codehandle * write32; /* write word */ | |
| 205 | drcuml_codehandle * write32mask; /* write word masked */ | |
| 206 | drcuml_codehandle * read64; /* read double */ | |
| 207 | drcuml_codehandle * read64mask; /* read double masked */ | |
| 208 | drcuml_codehandle * write64; /* write double */ | |
| 209 | drcuml_codehandle * write64mask; /* write double masked */ | |
| 207 | drcuml_codehandle * tlb_mismatch; /* tlb mismatch handler */ | |
| 208 | drcuml_codehandle * read8[3]; /* read byte */ | |
| 209 | drcuml_codehandle * write8[3]; /* write byte */ | |
| 210 | drcuml_codehandle * read16[3]; /* read half */ | |
| 211 | drcuml_codehandle * write16[3]; /* write half */ | |
| 212 | drcuml_codehandle * read32[3]; /* read word */ | |
| 213 | drcuml_codehandle * read32mask[3]; /* read word masked */ | |
| 214 | drcuml_codehandle * write32[3]; /* write word */ | |
| 215 | drcuml_codehandle * write32mask[3]; /* write word masked */ | |
| 216 | drcuml_codehandle * read64[3]; /* read double */ | |
| 217 | drcuml_codehandle * read64mask[3]; /* read double masked */ | |
| 218 | drcuml_codehandle * write64[3]; /* write double */ | |
| 219 | drcuml_codehandle * write64mask[3]; /* write double masked */ | |
| 210 | 220 | drcuml_codehandle * exception[EXCEPTION_COUNT]; /* array of exception handlers */ |
| 211 | 221 | drcuml_codehandle * exception_norecover[EXCEPTION_COUNT]; /* array of no-recover exception handlers */ |
| 212 | 222 | |
| r2724 | r2725 | |
| 235 | 245 | static void static_generate_entry_point(drcuml_state *drcuml); |
| 236 | 246 | static void static_generate_nocode_handler(drcuml_state *drcuml); |
| 237 | 247 | static void static_generate_out_of_cycles(drcuml_state *drcuml); |
| 248 | static void static_generate_tlb_mismatch(drcuml_state *drcuml); | |
| 238 | 249 | static void static_generate_exception(drcuml_state *drcuml, UINT8 exception, int recover, const char *name); |
| 239 | static void static_generate_memory_accessor(drcuml_state *drcuml, int size, int iswrite, int ismasked, const char *name, drcuml_codehandle **handleptr); | |
| 250 | static void static_generate_memory_accessor(drcuml_state *drcuml, int mode, int size, int iswrite, int ismasked, const char *name, drcuml_codehandle **handleptr); | |
| 240 | 251 | |
| 241 | static void generate_update_cycles(drcuml_block *block, compiler_state *compiler, UINT32 nextpc, UINT32 *mempc, int allow_exception); | |
| 252 | static void generate_update_mode(drcuml_block *block); | |
| 253 | static void generate_update_cycles(drcuml_block *block, compiler_state *compiler, drcuml_ptype ptype, UINT64 pvalue, int allow_exception); | |
| 242 | 254 | static void generate_checksum_block(drcuml_block *block, compiler_state *compiler, const opcode_desc *seqhead, const opcode_desc *seqlast); |
| 243 | 255 | static void generate_sequence_instruction(drcuml_block *block, compiler_state *compiler, const opcode_desc *desc); |
| 244 | 256 | static void generate_delay_slot_and_branch(drcuml_block *block, compiler_state *compiler, const opcode_desc *desc, UINT8 linkreg); |
| r2724 | r2725 | |
| 640 | 652 | } |
| 641 | 653 | |
| 642 | 654 | |
| 655 | /*------------------------------------------------- | |
| 656 | load_fast_iregs - load any fast integer | |
| 657 | registers | |
| 658 | -------------------------------------------------*/ | |
| 643 | 659 | |
| 660 | INLINE void load_fast_iregs(drcuml_block *block) | |
| 661 | { | |
| 662 | int regnum; | |
| 663 | ||
| 664 | for (regnum = 0; regnum < ARRAY_LENGTH(mips3.regmap); regnum++) | |
| 665 | if (mips3.regmap[regnum].type == DRCUML_PTYPE_INT_REGISTER) | |
| 666 | UML_DMOV(block, IREG(mips3.regmap[regnum].value - DRCUML_REG_I0), MEM(&mips3.core->r[regnum])); | |
| 667 | } | |
| 668 | ||
| 669 | ||
| 670 | /*------------------------------------------------- | |
| 671 | save_fast_iregs - save any fast integer | |
| 672 | registers | |
| 673 | -------------------------------------------------*/ | |
| 674 | ||
| 675 | INLINE void save_fast_iregs(drcuml_block *block) | |
| 676 | { | |
| 677 | int regnum; | |
| 678 | ||
| 679 | for (regnum = 0; regnum < ARRAY_LENGTH(mips3.regmap); regnum++) | |
| 680 | if (mips3.regmap[regnum].type == DRCUML_PTYPE_INT_REGISTER) | |
| 681 | UML_DMOV(block, MEM(&mips3.core->r[regnum]), IREG(mips3.regmap[regnum].value - DRCUML_REG_I0)); | |
| 682 | } | |
| 683 | ||
| 684 | ||
| 685 | ||
| 644 | 686 | /*************************************************************************** |
| 645 | 687 | CORE CALLBACKS |
| 646 | 688 | ***************************************************************************/ |
| r2724 | r2725 | |
| 658 | 700 | COMPILE_MAX_SEQUENCE, /* maximum instructions to include in a sequence */ |
| 659 | 701 | mips3fe_describe /* callback to describe a single instruction */ |
| 660 | 702 | }; |
| 703 | drcbe_info beinfo; | |
| 661 | 704 | UINT32 flags = 0; |
| 662 | 705 | size_t extrasize; |
| 663 | 706 | void *extramem; |
| 707 | int regnum; | |
| 664 | 708 | |
| 665 | 709 | /* determine how much memory beyond the core size we need */ |
| 666 | 710 | extrasize = mips3com_init(NULL, flavor, bigendian, index, clock, config, irqcallback, NULL); |
| r2724 | r2725 | |
| 698 | 742 | flags |= DRCUML_OPTION_LOG_UML; |
| 699 | 743 | if (LOG_NATIVE) |
| 700 | 744 | flags |= DRCUML_OPTION_LOG_NATIVE; |
| 701 | mips3.drcuml = drcuml_alloc(mips3.cache, flags, | |
| 745 | mips3.drcuml = drcuml_alloc(mips3.cache, flags, 8, 32, 2); | |
| 702 | 746 | if (mips3.drcuml == NULL) |
| 703 | 747 | fatalerror("Error initializing the UML"); |
| 704 | 748 | |
| r2724 | r2725 | |
| 707 | 751 | feconfig.max_sequence = 1; |
| 708 | 752 | mips3.drcfe = drcfe_init(&feconfig, mips3.core); |
| 709 | 753 | |
| 754 | /* compute the register parameters */ | |
| 755 | for (regnum = 0; regnum < 34; regnum++) | |
| 756 | { | |
| 757 | mips3.regmap[regnum].type = (regnum == 0) ? DRCUML_PTYPE_IMMEDIATE : DRCUML_PTYPE_MEMORY; | |
| 758 | mips3.regmap[regnum].value = (regnum == 0) ? 0 : (FPTR)&mips3.core->r[regnum]; | |
| 759 | mips3.regmaplo[regnum].type = (regnum == 0) ? DRCUML_PTYPE_IMMEDIATE : DRCUML_PTYPE_MEMORY; | |
| 760 | mips3.regmaplo[regnum].value = (regnum == 0) ? 0 : (FPTR)LOPTR(&mips3.core->r[regnum]); | |
| 761 | } | |
| 762 | ||
| 763 | /* if we have registers to spare, assign r2, r3, r4 to leftovers */ | |
| 764 | if (!DISABLE_FAST_REGISTERS) | |
| 765 | { | |
| 766 | drcuml_get_backend_info(mips3.drcuml, &beinfo); | |
| 767 | if (beinfo.direct_iregs > 4) | |
| 768 | { | |
| 769 | mips3.regmap[2].type = mips3.regmaplo[2].type = DRCUML_PTYPE_INT_REGISTER; | |
| 770 | mips3.regmap[2].value = mips3.regmaplo[2].value = DRCUML_REG_I4; | |
| 771 | } | |
| 772 | if (beinfo.direct_iregs > 5) | |
| 773 | { | |
| 774 | mips3.regmap[3].type = mips3.regmaplo[3].type = DRCUML_PTYPE_INT_REGISTER; | |
| 775 | mips3.regmap[3].value = mips3.regmaplo[3].value = DRCUML_REG_I5; | |
| 776 | } | |
| 777 | if (beinfo.direct_iregs > 6) | |
| 778 | { | |
| 779 | mips3.regmap[4].type = mips3.regmaplo[4].type = DRCUML_PTYPE_INT_REGISTER; | |
| 780 | mips3.regmap[4].value = mips3.regmaplo[4].value = DRCUML_REG_I6; | |
| 781 | } | |
| 782 | } | |
| 783 | ||
| 710 | 784 | /* mark the cache dirty so it is updated on next execute */ |
| 711 | 785 | mips3.cache_dirty = TRUE; |
| 712 | 786 | } |
| r2724 | r2725 | |
| 720 | 794 | { |
| 721 | 795 | /* reset the common code and mark the cache dirty */ |
| 722 | 796 | mips3com_reset(mips3.core); |
| 797 | mips3.cstate->mode = (MODE_KERNEL << 1) | 0; | |
| 723 | 798 | mips3.cache_dirty = TRUE; |
| 724 | 799 | } |
| 725 | 800 | |
| r2724 | r2725 | |
| 749 | 824 | /* if we need to recompile, do it */ |
| 750 | 825 | if (execute_result == EXECUTE_MISSING_CODE) |
| 751 | 826 | code_compile_block(drcuml, mips3.cstate->mode, mips3.core->pc); |
| 827 | else if (execute_result == EXECUTE_UNMAPPED_CODE) | |
| 828 | fatalerror("Attempted to execute unmapped code at PC=%08X\n", mips3.core->pc); | |
| 829 | else if (execute_result == EXECUTE_RESET_CACHE) | |
| 830 | code_flush_cache(drcuml); | |
| 752 | 831 | |
| 753 | 832 | } while (execute_result != EXECUTE_OUT_OF_CYCLES); |
| 754 | 833 | |
| r2724 | r2725 | |
| 830 | 909 | |
| 831 | 910 | static void code_flush_cache(drcuml_state *drcuml) |
| 832 | 911 | { |
| 912 | int mode; | |
| 913 | ||
| 833 | 914 | /* empty the transient cache contents */ |
| 834 | 915 | drcuml_reset(drcuml); |
| 835 | 916 | |
| r2724 | r2725 | |
| 837 | 918 | static_generate_entry_point(drcuml); |
| 838 | 919 | static_generate_nocode_handler(drcuml); |
| 839 | 920 | static_generate_out_of_cycles(drcuml); |
| 921 | static_generate_tlb_mismatch(drcuml); | |
| 840 | 922 | |
| 841 | 923 | /* append exception handlers for various types */ |
| 842 | static_generate_exception(drcuml, EXCEPTION_INTERRUPT, TRUE, "exception_interrupt"); | |
| 843 | static_generate_exception(drcuml, EXCEPTION_INTERRUPT, FALSE, "exception_interrupt_norecover"); | |
| 844 | static_generate_exception(drcuml, EXCEPTION_TLBMOD, TRUE, "exception_tlbmod"); | |
| 845 | static_generate_exception(drcuml, EXCEPTION_TLBLOAD, TRUE, "exception_tlbload"); | |
| 846 | static_generate_exception(drcuml, EXCEPTION_TLBSTORE, TRUE, "exception_tlbstore"); | |
| 847 | static_generate_exception(drcuml, EXCEPTION_SYSCALL, TRUE, "exception_syscall"); | |
| 848 | static_generate_exception(drcuml, EXCEPTION_BREAK, TRUE, "exception_break"); | |
| 849 | static_generate_exception(drcuml, EXCEPTION_INVALIDOP, TRUE, "exception_invalidop"); | |
| 850 | static_generate_exception(drcuml, EXCEPTION_BADCOP, TRUE, "exception_badcop"); | |
| 851 | static_generate_exception(drcuml, EXCEPTION_OVERFLOW, TRUE, "exception_overflow"); | |
| 852 | static_generate_exception(drcuml, EXCEPTION_TRAP, TRUE, "exception_trap"); | |
| 924 | static_generate_exception(drcuml, EXCEPTION_INTERRUPT, TRUE, "exception_interrupt"); | |
| 925 | static_generate_exception(drcuml, EXCEPTION_INTERRUPT, FALSE, "exception_interrupt_norecover"); | |
| 926 | static_generate_exception(drcuml, EXCEPTION_TLBMOD, TRUE, "exception_tlbmod"); | |
| 927 | static_generate_exception(drcuml, EXCEPTION_TLBLOAD, TRUE, "exception_tlbload"); | |
| 928 | static_generate_exception(drcuml, EXCEPTION_TLBSTORE, TRUE, "exception_tlbstore"); | |
| 929 | static_generate_exception(drcuml, EXCEPTION_TLBLOAD_FILL, TRUE, "exception_tlbload_fill"); | |
| 930 | static_generate_exception(drcuml, EXCEPTION_TLBSTORE_FILL, TRUE, "exception_tlbstore_fill"); | |
| 931 | static_generate_exception(drcuml, EXCEPTION_ADDRLOAD, TRUE, "exception_addrload"); | |
| 932 | static_generate_exception(drcuml, EXCEPTION_ADDRSTORE, TRUE, "exception_addrstore"); | |
| 933 | static_generate_exception(drcuml, EXCEPTION_SYSCALL, TRUE, "exception_syscall"); | |
| 934 | static_generate_exception(drcuml, EXCEPTION_BREAK, TRUE, "exception_break"); | |
| 935 | static_generate_exception(drcuml, EXCEPTION_INVALIDOP, TRUE, "exception_invalidop"); | |
| 936 | static_generate_exception(drcuml, EXCEPTION_BADCOP, TRUE, "exception_badcop"); | |
| 937 | static_generate_exception(drcuml, EXCEPTION_OVERFLOW, TRUE, "exception_overflow"); | |
| 938 | static_generate_exception(drcuml, EXCEPTION_TRAP, TRUE, "exception_trap"); | |
| 853 | 939 | |
| 854 | 940 | /* add subroutines for memory accesses */ |
| 855 | static_generate_memory_accessor(drcuml, 1, FALSE, FALSE, "read8", &mips3.read8); | |
| 856 | static_generate_memory_accessor(drcuml, 1, TRUE, FALSE, "write8", &mips3.write8); | |
| 857 | static_generate_memory_accessor(drcuml, 2, FALSE, FALSE, "read16", &mips3.read16); | |
| 858 | static_generate_memory_accessor(drcuml, 2, TRUE, FALSE, "write16", &mips3.write16); | |
| 859 | static_generate_memory_accessor(drcuml, 4, FALSE, FALSE, "read32", &mips3.read32); | |
| 860 | static_generate_memory_accessor(drcuml, 4, FALSE, TRUE, "read32mask", &mips3.read32mask); | |
| 861 | static_generate_memory_accessor(drcuml, 4, TRUE, FALSE, "write32", &mips3.write32); | |
| 862 | static_generate_memory_accessor(drcuml, 4, TRUE, TRUE, "write32mask", &mips3.write32mask); | |
| 863 | static_generate_memory_accessor(drcuml, 8, FALSE, FALSE, "read64", &mips3.read64); | |
| 864 | static_generate_memory_accessor(drcuml, 8, FALSE, TRUE, "read64mask", &mips3.read64mask); | |
| 865 | static_generate_memory_accessor(drcuml, 8, TRUE, FALSE, "write64", &mips3.write64); | |
| 866 | static_generate_memory_accessor(drcuml, 8, TRUE, TRUE, "write64mask", &mips3.write64mask); | |
| 941 | for (mode = 0; mode < 3; mode++) | |
| 942 | { | |
| 943 | static_generate_memory_accessor(drcuml, mode, 1, FALSE, FALSE, "read8", &mips3.read8[mode]); | |
| 944 | static_generate_memory_accessor(drcuml, mode, 1, TRUE, FALSE, "write8", &mips3.write8[mode]); | |
| 945 | static_generate_memory_accessor(drcuml, mode, 2, FALSE, FALSE, "read16", &mips3.read16[mode]); | |
| 946 | static_generate_memory_accessor(drcuml, mode, 2, TRUE, FALSE, "write16", &mips3.write16[mode]); | |
| 947 | static_generate_memory_accessor(drcuml, mode, 4, FALSE, FALSE, "read32", &mips3.read32[mode]); | |
| 948 | static_generate_memory_accessor(drcuml, mode, 4, FALSE, TRUE, "read32mask", &mips3.read32mask[mode]); | |
| 949 | static_generate_memory_accessor(drcuml, mode, 4, TRUE, FALSE, "write32", &mips3.write32[mode]); | |
| 950 | static_generate_memory_accessor(drcuml, mode, 4, TRUE, TRUE, "write32mask", &mips3.write32mask[mode]); | |
| 951 | static_generate_memory_accessor(drcuml, mode, 8, FALSE, FALSE, "read64", &mips3.read64[mode]); | |
| 952 | static_generate_memory_accessor(drcuml, mode, 8, FALSE, TRUE, "read64mask", &mips3.read64mask[mode]); | |
| 953 | static_generate_memory_accessor(drcuml, mode, 8, TRUE, FALSE, "write64", &mips3.write64[mode]); | |
| 954 | static_generate_memory_accessor(drcuml, mode, 8, TRUE, TRUE, "write64mask", &mips3.write64mask[mode]); | |
| 955 | } | |
| 867 | 956 | } |
| 868 | 957 | |
| 869 | 958 | |
| r2724 | r2725 | |
| 883 | 972 | |
| 884 | 973 | /* get a description of this sequence */ |
| 885 | 974 | desclist = drcfe_describe_code(mips3.drcfe, pc); |
| 886 | if (LOG_UML) | |
| 975 | if (LOG_UML || LOG_NATIVE) | |
| 887 | 976 | log_opcode_desc(drcuml, desclist, 0); |
| 888 | 977 | |
| 889 | 978 | /* if we get an error back, flush the cache and try again */ |
| r2724 | r2725 | |
| 951 | 1040 | nextpc = seqlast->pc + (seqlast->skipslots + 1) * 4; |
| 952 | 1041 | |
| 953 | 1042 | /* count off cycles and go there */ |
| 954 | generate_update_cycles(block, &compiler, nextpc | |
| 1043 | generate_update_cycles(block, &compiler, IMM(nextpc) | |
| 955 | 1044 | |
| 956 | 1045 | /* if the last instruction can change modes, use a variable mode; otherwise, assume the same mode */ |
| 957 | 1046 | if (seqlast->flags & OPFLAG_CAN_CHANGE_MODES) |
| r2724 | r2725 | |
| 971 | 1060 | ***************************************************************************/ |
| 972 | 1061 | |
| 973 | 1062 | /*------------------------------------------------- |
| 1063 | cfunc_get_cycles - compute the total number | |
| 1064 | of cycles executed so far | |
| 1065 | -------------------------------------------------*/ | |
| 1066 | ||
| 1067 | static void cfunc_get_cycles(void *param) | |
| 1068 | { | |
| 1069 | UINT64 *dest = param; | |
| 1070 | *dest = activecpu_gettotalcycles(); | |
| 1071 | } | |
| 1072 | ||
| 1073 | ||
| 1074 | /*------------------------------------------------- | |
| 974 | 1075 | cfunc_printf_exception - log any exceptions that |
| 975 | 1076 | aren't interrupts |
| 976 | 1077 | -------------------------------------------------*/ |
| r2724 | r2725 | |
| 983 | 1084 | |
| 984 | 1085 | |
| 985 | 1086 | /*------------------------------------------------- |
| 986 | cfunc_get_cycles - compute the total number | |
| 987 | of cycles executed so far | |
| 1087 | cfunc_printf_debug - generic printf for | |
| 1088 | debugging | |
| 988 | 1089 | -------------------------------------------------*/ |
| 989 | 1090 | |
| 990 | static void cfunc_ | |
| 1091 | static void cfunc_printf_d | |
| 991 | 1092 | { |
| 992 | UINT64 *dest = param; | |
| 993 | *dest = activecpu_gettotalcycles(); | |
| 1093 | const char *format = param; | |
| 1094 | printf(format, mips3.cstate->arg0, mips3.cstate->arg1); | |
| 994 | 1095 | } |
| 995 | 1096 | |
| 996 | 1097 | |
| r2724 | r2725 | |
| 1049 | 1150 | } |
| 1050 | 1151 | |
| 1051 | 1152 | |
| 1153 | /*------------------------------------------------- | |
| 1154 | cfunc_unimplemented - handler for | |
| 1155 | unimplemented opcdes | |
| 1156 | -------------------------------------------------*/ | |
| 1052 | 1157 | |
| 1158 | static void cfunc_unimplemented(void *param) | |
| 1159 | { | |
| 1160 | UINT32 opcode = (FPTR)param; | |
| 1161 | fatalerror("PC=%08X: Unimplemented op %08X (%02X,%02X)", mips3.core->pc, opcode, opcode >> 26, opcode & 0x3f); | |
| 1162 | } | |
| 1163 | ||
| 1164 | ||
| 1165 | ||
| 1053 | 1166 | /*************************************************************************** |
| 1054 | 1167 | STATIC CODEGEN |
| 1055 | 1168 | ***************************************************************************/ |
| r2724 | r2725 | |
| 1080 | 1193 | UML_HANDLE(block, mips3.entry); // handle entry |
| 1081 | 1194 | |
| 1082 | 1195 | /* reset the FPU mode */ |
| 1083 | UML_AND(block, IREG(0), CCR1 | |
| 1196 | UML_AND(block, IREG(0), CCR132(31), IMM(3)); // and i0,ccr1[31],3 | |
| 1084 | 1197 | UML_LOAD1U(block, IREG(0), &mips3.cstate->fpmode[0], IREG(0)); // load1u i0,fpmode,i0 |
| 1085 | 1198 | UML_SETFMOD(block, IREG(0)); // setfmod i0 |
| 1086 | 1199 | |
| 1200 | /* load fast integer registers */ | |
| 1201 | load_fast_iregs(block); | |
| 1202 | ||
| 1087 | 1203 | /* check for interrupts */ |
| 1088 | 1204 | UML_AND(block, IREG(0), CPR032(COP0_Cause), CPR032(COP0_Status)); // and i0,[Cause],[Status] |
| 1089 | 1205 | UML_ANDf(block, IREG(0), IREG(0), IMM(0xfc00), FLAGS_Z); // and i0,i0,0xfc00,Z |
| r2724 | r2725 | |
| 1126 | 1242 | UML_HANDLE(block, mips3.nocode); // handle nocode |
| 1127 | 1243 | UML_GETEXP(block, IREG(0)); // getexp i0 |
| 1128 | 1244 | UML_MOV(block, MEM(&mips3.core->pc), IREG(0)); // mov [pc],i0 |
| 1245 | save_fast_iregs(block); | |
| 1129 | 1246 | UML_EXIT(block, IMM(EXECUTE_MISSING_CODE)); // exit EXECUTE_MISSING_CODE |
| 1130 | 1247 | |
| 1131 | 1248 | drcuml_block_end(block); |
| r2724 | r2725 | |
| 1154 | 1271 | UML_HANDLE(block, mips3.out_of_cycles); // handle out_of_cycles |
| 1155 | 1272 | UML_GETEXP(block, IREG(0)); // getexp i0 |
| 1156 | 1273 | UML_MOV(block, MEM(&mips3.core->pc), IREG(0)); // mov <pc>,i0 |
| 1274 | save_fast_iregs(block); | |
| 1157 | 1275 | UML_EXIT(block, IMM(EXECUTE_OUT_OF_CYCLES)); // exit EXECUTE_OUT_OF_CYCLES |
| 1158 | 1276 | |
| 1159 | 1277 | drcuml_block_end(block); |
| r2724 | r2725 | |
| 1161 | 1279 | |
| 1162 | 1280 | |
| 1163 | 1281 | /*------------------------------------------------- |
| 1282 | static_generate_tlb_mismatch - generate a | |
| 1283 | TLB mismatch handler | |
| 1284 | -------------------------------------------------*/ | |
| 1285 | ||
| 1286 | static void static_generate_tlb_mismatch(drcuml_state *drcuml) | |
| 1287 | { | |
| 1288 | drcuml_block *block; | |
| 1289 | jmp_buf errorbuf; | |
| 1290 | ||
| 1291 | /* if we get an error back, we're screwed */ | |
| 1292 | if (setjmp(errorbuf) != 0) | |
| 1293 | fatalerror("Unrecoverable error in static_generate_tlb_mismatch"); | |
| 1294 | ||
| 1295 | /* forward references */ | |
| 1296 | alloc_handle(drcuml, &mips3.exception[EXCEPTION_TLBLOAD], "exception_tlbload"); | |
| 1297 | alloc_handle(drcuml, &mips3.exception[EXCEPTION_TLBLOAD_FILL], "exception_tlbload_fill"); | |
| 1298 | ||
| 1299 | /* begin generating */ | |
| 1300 | block = drcuml_block_begin(drcuml, 20, &errorbuf); | |
| 1301 | ||
| 1302 | /* generate a hash jump via the current mode and PC */ | |
| 1303 | alloc_handle(drcuml, &mips3.tlb_mismatch, "tlb_mismatch"); | |
| 1304 | UML_HANDLE(block, mips3.tlb_mismatch); // handle tlb_mismatch | |
| 1305 | UML_RECOVER(block, IREG(0), MAPVAR_PC); // recover i0,PC | |
| 1306 | UML_MOV(block, MEM(&mips3.core->pc), IREG(0)); // mov <pc>,i0 | |
| 1307 | UML_SHR(block, IREG(1), IREG(0), IMM(12)); // shr i1,i0,12 | |
| 1308 | UML_LOAD4(block, IREG(1), mips3.core->tlb_table, IREG(1)); // load4 i1,[tlb_table],i1 | |
| 1309 | if (PRINTF_MMU) | |
| 1310 | { | |
| 1311 | UML_MOV(block, MEM(&mips3.cstate->arg0), IREG(0)); // mov [arg0],i0 | |
| 1312 | UML_MOV(block, MEM(&mips3.cstate->arg1), IREG(1)); // mov [arg1],i1 | |
| 1313 | UML_CALLC(block, cfunc_printf_debug, "TLB mismatch @ %08X (ent=%08X)\n"); // callc printf_debug | |
| 1314 | } | |
| 1315 | UML_TEST(block, IREG(1), IMM(TLB_VALID)); // test i1,TLB_VALID | |
| 1316 | UML_JMPc(block, IF_NZ, 1); // jmp 1,nz | |
| 1317 | UML_TEST(block, IREG(1), IMM(TLB_PRESENT)); // test i1,TLB_PRESENT | |
| 1318 | UML_EXHc(block, IF_NZ, mips3.exception[EXCEPTION_TLBLOAD], IREG(0)); // exh exception[TLBLOAD],i0,nz | |
| 1319 | UML_EXH(block, mips3.exception[EXCEPTION_TLBLOAD_FILL], IREG(0)); // exh exception[TLBLOAD_FILL],i0 | |
| 1320 | UML_LABEL(block, 1); // 1: | |
| 1321 | save_fast_iregs(block); | |
| 1322 | UML_EXIT(block, IMM(EXECUTE_MISSING_CODE)); // exit EXECUTE_MISSING_CODE | |
| 1323 | ||
| 1324 | drcuml_block_end(block); | |
| 1325 | } | |
| 1326 | ||
| 1327 | ||
| 1328 | /*------------------------------------------------- | |
| 1164 | 1329 | static_generate_exception - generate a static |
| 1165 | 1330 | exception handler |
| 1166 | 1331 | -------------------------------------------------*/ |
| 1167 | 1332 | |
| 1168 | 1333 | static void static_generate_exception(drcuml_state *drcuml, UINT8 exception, int recover, const char *name) |
| 1169 | 1334 | { |
| 1170 | UINT32 offset = (exception >= EXCEPTION_TLBMOD && exception <= EXCEPTION_TLBSTORE) ? 0x00 : 0x180; | |
| 1335 | drcuml_codehandle **exception_handle = recover ? &mips3.exception[exception] : &mips3.exception_norecover[exception]; | |
| 1336 | UINT32 offset = 0x180; | |
| 1171 | 1337 | drcuml_codelabel next = 1; |
| 1172 | 1338 | drcuml_block *block; |
| 1173 | 1339 | jmp_buf errorbuf; |
| r2724 | r2725 | |
| 1176 | 1342 | if (setjmp(errorbuf) != 0) |
| 1177 | 1343 | fatalerror("Unrecoverable error in static_generate_exception"); |
| 1178 | 1344 | |
| 1345 | /* translate our fake fill exceptions into real exceptions */ | |
| 1346 | if (exception == EXCEPTION_TLBLOAD_FILL || exception == EXCEPTION_TLBSTORE_FILL) | |
| 1347 | { | |
| 1348 | offset = 0x000; | |
| 1349 | exception = (exception - EXCEPTION_TLBLOAD_FILL) + EXCEPTION_TLBLOAD; | |
| 1350 | } | |
| 1351 | ||
| 1179 | 1352 | /* begin generating */ |
| 1180 | 1353 | block = drcuml_block_begin(drcuml, 1024, &errorbuf); |
| 1181 | 1354 | |
| 1182 | 1355 | /* add a global entry for this */ |
| 1183 | if (recover) | |
| 1356 | alloc_handle(drcuml, exception_handle, name); | |
| 1357 | UML_HANDLE(block, *exception_handle); // handle name | |
| 1358 | ||
| 1359 | /* exception parameter is expected to be the fault address in this case */ | |
| 1360 | if (exception == EXCEPTION_TLBLOAD || exception == EXCEPTION_TLBSTORE || exception == EXCEPTION_ADDRLOAD || exception == EXCEPTION_ADDRSTORE) | |
| 1184 | 1361 | { |
| 1185 | alloc_handle(drcuml, &mips3.exception[exception], name); | |
| 1186 | UML_HANDLE(block, mips3.exception[exception]); // handle name | |
| 1362 | /* set BadVAddr to the fault address */ | |
| 1363 | UML_GETEXP(block, IREG(0)); // getexp i0 | |
| 1364 | UML_TEST(block, CPR032(COP0_Status), IMM(SR_EXL)); // test [Status],SR_EXL | |
| 1365 | UML_MOVc(block, IF_Z, CPR032(COP0_BadVAddr), IREG(0)); // mov [BadVAddr],i0,Z | |
| 1187 | 1366 | } |
| 1188 | else | |
| 1189 | { | |
| 1190 | alloc_handle(drcuml, &mips3.exception_norecover[exception], name); | |
| 1191 | UML_HANDLE(block, mips3.exception_norecover[exception]); // handle name | |
| 1192 | } | |
| 1193 | 1367 | |
| 1194 | /* exception parameter is expected to be the fault address in this case */ | |
| 1195 | 1368 | if (exception == EXCEPTION_TLBLOAD || exception == EXCEPTION_TLBSTORE) |
| 1196 | 1369 | { |
| 1197 | /* set BadVAddr to the fault address */ | |
| 1198 | UML_GETEXP(block, CPR032(COP0_BadVAddr)); // mov [BadVAddr],exp | |
| 1199 | ||
| 1200 | /* set the upper bits of EntryHi to the fault page */ | |
| 1201 | UML_AND(block, IREG(0), IREG(0), IMM(0xffffe000)); // and i0,i0,0xffffe000 | |
| 1202 | UML_AND(block, IREG(1), CPR032(COP0_EntryHi), IMM(0x000000ff)); // and i1,[EntryHi],0x000000ff | |
| 1203 | UML_OR(block, CPR032(COP0_EntryHi), IREG(0), IREG(1)); // or [EntryHi],i0,i1 | |
| 1204 | ||
| 1205 | /* set the lower bits of Context to the fault page */ | |
| 1206 | UML_SHR(block, IREG(0), IREG(0), IMM(9)); // shr i0,i0,9 | |
| 1207 | UML_AND(block, IREG(1), CPR032(COP0_Context), IMM(0xff800000)); // and i1,[Context],0xff800000 | |
| 1208 | UML_OR(block, CPR032(COP0_Context), IREG(0), IREG(1)); // or [Context],i0,i1 | |
| 1370 | /* set the upper bits of EntryHi and the lower bits of Context to the fault page */ | |
| 1371 | UML_INSERT(block, CPR032(COP0_EntryHi), IREG(0), IMM(0), IMM(0xffffe000)); // insert [EntryHi],i0,0,0xffffe000 | |
| 1372 | UML_INSERT(block, CPR032(COP0_Context), IREG(0), IMM(32-9), IMM(0x7fffff)); // insert [Context],i0,32-9,0x7fffff | |
| 1209 | 1373 | } |
| 1210 | 1374 | |
| 1211 | 1375 | /* set the EPC and Cause registers */ |
| r2724 | r2725 | |
| 1221 | 1385 | UML_OR(block, IREG(2), IREG(2), IMM(0x80000000)); // or i2,i2,0x80000000 |
| 1222 | 1386 | UML_SUB(block, IREG(0), IREG(0), IMM(1)); // sub i0,i0,1 |
| 1223 | 1387 | UML_LABEL(block, next); // <next>: |
| 1224 | UML_MOV(block, CPR032(COP0_EPC), IREG(0)); // mov [EPC],i0 | |
| 1388 | UML_TEST(block, CPR032(COP0_Status), IMM(SR_EXL)); // test [Status],SR_EXL | |
| 1389 | UML_MOVc(block, IF_Z, CPR032(COP0_EPC), IREG(0)); // mov [EPC],i0,Z | |
| 1225 | 1390 | UML_OR(block, CPR032(COP0_Cause), IREG(2), IMM(exception << 2)); // or [Cause],i2,exception << 2 |
| 1226 | 1391 | |
| 1227 | 1392 | /* set EXL in the SR */ |
| 1228 | UML_OR(block, CPR032(COP0_Status), CPR032(COP0_Status), IMM(SR_EXL)); // or [Status],[Status],SR_EXL | |
| 1393 | UML_OR(block, IREG(0), CPR032(COP0_Status), IMM(SR_EXL)); // or i0,[Status],SR_EXL | |
| 1394 | UML_MOV(block, CPR032(COP0_Status), IREG(0)); // mov [Status],i0 | |
| 1395 | generate_update_mode(block); | |
| 1229 | 1396 | |
| 1230 | 1397 | /* optionally print exceptions */ |
| 1231 | if (PRINTF_EXCEPTIONS && exception != EXCEPTION_INTERRUPT && exception != EXCEPTION_SYSCALL) | |
| 1398 | if ((PRINTF_EXCEPTIONS && exception != EXCEPTION_INTERRUPT && exception != EXCEPTION_SYSCALL) || | |
| 1399 | (PRINTF_MMU && (exception == EXCEPTION_TLBLOAD || exception == EXCEPTION_TLBSTORE))) | |
| 1232 | 1400 | UML_CALLC(block, cfunc_printf_exception, NULL); // callc cfunc_printf_exception,NULL |
| 1233 | 1401 | |
| 1234 | 1402 | /* choose our target PC */ |
| 1235 | 1403 | UML_MOV(block, IREG(0), IMM(0xbfc00200 + offset)); // mov i0,0xbfc00200 + offset |
| 1236 | UML_TEST(block, | |
| 1404 | UML_TEST(block, I | |
| 1237 | 1405 | UML_MOVc(block, IF_Z, IREG(0), IMM(0x80000000 + offset)); // mov i0,0x80000000 + offset,z |
| 1238 | 1406 | |
| 1239 | 1407 | /* adjust cycles */ |
| r2724 | r2725 | |
| 1250 | 1418 | static_generate_memory_accessor |
| 1251 | 1419 | ------------------------------------------------------------------*/ |
| 1252 | 1420 | |
| 1253 | static void static_generate_memory_accessor(drcuml_state *drcuml, int size, int iswrite, int ismasked, const char *name, drcuml_codehandle **handleptr) | |
| 1421 | static void static_generate_memory_accessor(drcuml_state *drcuml, int mode, int size, int iswrite, int ismasked, const char *name, drcuml_codehandle **handleptr) | |
| 1254 | 1422 | { |
| 1255 | 1423 | /* on entry, address is in I0; data for writes is in I1; mask for accesses is in I2 */ |
| 1256 | 1424 | /* on exit, read result is in I0 */ |
| 1257 | 1425 | /* routine trashes I0-I3 */ |
| 1258 | drcuml_codehandle *exception_target = mips3.exception[iswrite ? EXCEPTION_TLBSTORE : EXCEPTION_TLBLOAD]; | |
| 1426 | drcuml_codehandle *exception_tlb = mips3.exception[iswrite ? EXCEPTION_TLBSTORE : EXCEPTION_TLBLOAD]; | |
| 1427 | drcuml_codehandle *exception_tlbfill = mips3.exception[iswrite ? EXCEPTION_TLBSTORE_FILL : EXCEPTION_TLBLOAD_FILL]; | |
| 1428 | drcuml_codehandle *exception_addrerr = mips3.exception[iswrite ? EXCEPTION_ADDRSTORE : EXCEPTION_ADDRLOAD]; | |
| 1259 | 1429 | drcuml_block *block; |
| 1260 | 1430 | jmp_buf errorbuf; |
| 1261 | int label = 0; | |
| 1431 | int tlbmiss = 0; | |
| 1432 | int label = 1; | |
| 1262 | 1433 | int ramnum; |
| 1263 | 1434 | |
| 1264 | 1435 | /* if we get an error back, we're screwed */ |
| r2724 | r2725 | |
| 1272 | 1443 | alloc_handle(drcuml, handleptr, name); |
| 1273 | 1444 | UML_HANDLE(block, *handleptr); // handle *handleptr |
| 1274 | 1445 | |
| 1446 | /* user mode? generate address exception if top bit is set */ | |
| 1447 | if (mode == MODE_USER) | |
| 1448 | { | |
| 1449 | UML_TEST(block, IREG(0), IMM(0x80000000)); // test i0,0x80000000 | |
| 1450 | UML_EXHc(block, IF_NZ, exception_addrerr, IREG(0)); // exh addrerr,i0,nz | |
| 1451 | } | |
| 1452 | ||
| 1453 | /* supervisor mode? generate address exception if not in user space or in $C0000000-DFFFFFFF */ | |
| 1454 | if (mode == MODE_SUPER) | |
| 1455 | { | |
| 1456 | int addrok; | |
| 1457 | UML_TEST(block, IREG(0), IMM(0x80000000)); // test i0,0x80000000 | |
| 1458 | UML_JMPc(block, IF_Z, addrok = label++); // jz addrok | |
| 1459 | UML_SHR(block, IREG(3), IREG(0), IMM(29)); // shr i3,i0,29 | |
| 1460 | UML_CMP(block, IREG(3), IMM(6)); // cmp i3,6 | |
| 1461 | UML_EXHc(block, IF_NE, exception_addrerr, IREG(0)); // exh addrerr,i0,ne | |
| 1462 | UML_LABEL(block, addrok); // addrok: | |
| 1463 | } | |
| 1464 | ||
| 1275 | 1465 | /* general case: assume paging and perform a translation */ |
| 1276 | 1466 | UML_SHR(block, IREG(3), IREG(0), IMM(12)); // shr i3,i0,12 |
| 1277 | 1467 | UML_LOAD4(block, IREG(3), mips3.core->tlb_table, IREG(3)); // load4 i3,[tlb_table],i3 |
| 1278 | UML_TEST(block, IREG(3), IMM(iswrite ? 1 : 2)); // test i3,iswrite ? 1 : 2 | |
| 1279 | UML_EXHc(block, IF_NZ, exception_target, IREG(0)); // exnz exception_target,i0 | |
| 1280 | UML_AND(block, IREG(0), IREG(0), IMM(0xfff)); // and i0,i0,0xfff | |
| 1281 | UML_AND(block, IREG(3), IREG(3), IMM(~0xfff)); // and i3,i3,~0xfff | |
| 1282 | UML_OR(block, IREG(0), IREG(0), IREG(3)); // or i0,i0,i3 | |
| 1468 | UML_TEST(block, IREG(3), IMM(iswrite ? TLB_DIRTY : TLB_VALID)); // test i3,iswrite ? TLB_DIRTY : TLB_VALID | |
| 1469 | UML_JMPc(block, IF_Z, tlbmiss = label++); // jmp tlbmiss,z | |
| 1470 | UML_INSERT(block, IREG(0), IREG(3), IMM(0), IMM(0xfffff000)); // insert i0,i3,0,0xfffff000 | |
| 1283 | 1471 | |
| 1284 | 1472 | for (ramnum = 0; ramnum < MIPS3_MAX_FASTRAM; ramnum++) |
| 1285 | 1473 | if (!Machine->debug_mode && mips3.fastram[ramnum].base != NULL && (!iswrite || !mips3.fastram[ramnum].readonly)) |
| r2724 | r2725 | |
| 1347 | 1535 | if (ismasked) |
| 1348 | 1536 | { |
| 1349 | 1537 | UML_LOAD4(block, IREG(3), fastbase, IREG(0)); // load4 i3,fastbase,i0 |
| 1350 | UML_AND(block, IREG(1), IREG(1), IREG(2)); // and i1,i1,i2 | |
| 1351 | UML_XOR(block, IREG(2), IREG(2), IMM(0xffffffff)); // xor i2,i2,0xfffffffff | |
| 1352 | UML_AND(block, IREG(3), IREG(3), IREG(2)); // and i3,i3,i2 | |
| 1353 | UML_OR(block, IREG(1), IREG(1), IREG(3)); // or i1,i1,i3 | |
| 1538 | UML_INSERT(block, IREG(3), IREG(1), IMM(0), IREG(2)); // insert i3,i1,0,i2 | |
| 1539 | UML_STORE4(block, fastbase, IREG(0), IREG(3)); // store4 fastbase,i0,i3 | |
| 1354 | 1540 | } |
| 1355 | UML_STORE4(block, fastbase, IREG(0), IREG(1)); // store4 fastbase,i0,i1 | |
| 1541 | else | |
| 1542 | UML_STORE4(block, fastbase, IREG(0), IREG(1)); // store4 fastbase,i0,i1 | |
| 1356 | 1543 | } |
| 1357 | 1544 | else if (size == 8) |
| 1358 | 1545 | { |
| r2724 | r2725 | |
| 1364 | 1551 | UML_DROR(block, IREG(2), IREG(2), IMM(32 * (mips3.core->bigendian ? BYTE_XOR_BE(0) : BYTE_XOR_LE(0)))); |
| 1365 | 1552 | // dror i2,i2,32*bytexor |
| 1366 | 1553 | UML_DLOAD8(block, IREG(3), fastbase, IREG(0)); // dload8 i3,fastbase,i0 |
| 1367 | UML_DAND(block, IREG(1), IREG(1), IREG(2)); // dand i1,i1,i2 | |
| 1368 | UML_DXOR(block, IREG(2), IREG(2), IMM(U64(0xffffffffffffffff))); | |
| 1369 | // dxor i2,i2,0xfffffffffffffffff | |
| 1370 | UML_DAND(block, IREG(3), IREG(3), IREG(2)); // dand i3,i3,i2 | |
| 1371 | UML_DOR(block, IREG(1), IREG(1), IREG(3)); // dor i1,i1,i3 | |
| 1554 | UML_DINSERT(block, IREG(3), IREG(1), IMM(0), IREG(2)); // dinsert i3,i1,0,i2 | |
| 1555 | UML_DSTORE8(block, fastbase, IREG(0), IREG(3)); // dstore8 fastbase,i0,i3 | |
| 1372 | 1556 | } |
| 1373 | UML_DSTORE8(block, fastbase, IREG(0), IREG(1)); // dstore8 fastbase,i0,i1 | |
| 1557 | else | |
| 1558 | UML_DSTORE8(block, fastbase, IREG(0), IREG(1)); // dstore8 fastbase,i0,i1 | |
| 1374 | 1559 | } |
| 1375 | 1560 | UML_RET(block); // ret |
| 1376 | 1561 | } |
| r2724 | r2725 | |
| 1430 | 1615 | } |
| 1431 | 1616 | UML_RET(block); // ret |
| 1432 | 1617 | |
| 1618 | if (tlbmiss != 0) | |
| 1619 | { | |
| 1620 | UML_LABEL(block, tlbmiss); // tlbmiss: | |
| 1621 | if (iswrite) | |
| 1622 | { | |
| 1623 | UML_TEST(block, IREG(3), IMM(TLB_VALID)); // test i3,TLB_VALID | |
| 1624 | UML_EXHc(block, IF_NZ, mips3.exception[EXCEPTION_TLBMOD], IREG(0)); // exh tlbmod,i0,nz | |
| 1625 | } | |
| 1626 | UML_TEST(block, IREG(3), IMM(TLB_PRESENT)); // test i3,TLB_PRESENT | |
| 1627 | UML_EXHc(block, IF_NZ, exception_tlb, IREG(0)); // exh tlb,i0,nz | |
| 1628 | UML_EXH(block, exception_tlbfill, IREG(0)); // exh tlbfill,i0 | |
| 1629 | } | |
| 1630 | ||
| 1433 | 1631 | drcuml_block_end(block); |
| 1434 | 1632 | } |
| 1435 | 1633 | |
| r2724 | r2725 | |
| 1440 | 1638 | ***************************************************************************/ |
| 1441 | 1639 | |
| 1442 | 1640 | /*------------------------------------------------- |
| 1641 | generate_update_mode - update the mode based | |
| 1642 | on a new SR (in i0); trashes i2 | |
| 1643 | -------------------------------------------------*/ | |
| 1644 | ||
| 1645 | static void generate_update_mode(drcuml_block *block) | |
| 1646 | { | |
| 1647 | UML_XTRACT(block, IREG(2), IREG(0), IMM(32-2), IMM(0x06)); // xtract i2,i0,32-2,0x06 | |
| 1648 | UML_TEST(block, IREG(0), IMM(SR_EXL | SR_ERL)); // test i0,SR_EXL | SR_ERL | |
| 1649 | UML_MOVc(block, IF_NZ, IREG(2), IMM(0)); // mov i2,0,nz | |
| 1650 | UML_INSERT(block, IREG(2), IREG(0), IMM(32-26), IMM(0x01)); // insert i2,i0,32-26,0x01 | |
| 1651 | UML_MOV(block, MEM(&mips3.cstate->mode), IREG(2)); // mov [mode],i2 | |
| 1652 | } | |
| 1653 | ||
| 1654 | ||
| 1655 | /*------------------------------------------------- | |
| 1443 | 1656 | generate_update_cycles - generate code to |
| 1444 | 1657 | subtract cycles from the icount and generate |
| 1445 | 1658 | an exception if out |
| 1446 | 1659 | -------------------------------------------------*/ |
| 1447 | 1660 | |
| 1448 | static void generate_update_cycles(drcuml_block *block, compiler_state *compiler, | |
| 1661 | static void generate_update_cycles(drcuml_block *block, compiler_state *compiler, drcuml_ptype ptype, UINT64 | |
| 1449 | 1662 | { |
| 1450 | 1663 | /* check software interrupts if pending */ |
| 1451 | 1664 | if (compiler->checksoftints) |
| r2724 | r2725 | |
| 1456 | 1669 | UML_AND(block, IREG(0), CPR032(COP0_Cause), CPR032(COP0_Status)); // and i0,[Cause],[Status] |
| 1457 | 1670 | UML_ANDf(block, IREG(0), IREG(0), IMM(0x0300), FLAGS_Z); // and i0,i0,0x0300,Z |
| 1458 | 1671 | UML_JMPc(block, IF_Z, skip = compiler->labelnum++); // jmp skip,Z |
| 1459 | if (mempc == NULL) | |
| 1460 | UML_MOV(block, IREG(0), IMM(nextpc)); // mov i0,nextpc | |
| 1461 | else | |
| 1462 | UML_MOV(block, IREG(0), MEM(mempc)); // mov i0,[mempc] | |
| 1672 | UML_MOV(block, IREG(0), PARAM(ptype, pvalue)); // mov i0,nextpc | |
| 1463 | 1673 | UML_MOV(block, IREG(1), IMM(compiler->cycles)); // mov i1,cycles |
| 1464 | 1674 | UML_CALLH(block, mips3.exception_norecover[EXCEPTION_INTERRUPT]); // callh interrupt_norecover |
| 1465 | 1675 | UML_LABEL(block, skip); // skip: |
| r2724 | r2725 | |
| 1478 | 1688 | UML_JMPc(block, IF_Z, skip); // jmp skip,Z |
| 1479 | 1689 | UML_TEST(block, CPR032(COP0_Status), IMM(SR_EXL | SR_ERL)); // test [Status],SR_EXL | SR_ERL |
| 1480 | 1690 | UML_JMPc(block, IF_NZ, skip); // jmp skip,NZ |
| 1481 | if (mempc == NULL) | |
| 1482 | UML_MOV(block, IREG(0), IMM(nextpc)); // mov i0,nextpc | |
| 1483 | else | |
| 1484 | UML_MOV(block, IREG(0), MEM(mempc)); // mov i0,[mempc] | |
| 1691 | UML_MOV(block, IREG(0), PARAM(ptype, pvalue)); // mov i0,nextpc | |
| 1485 | 1692 | UML_MOV(block, IREG(1), IMM(compiler->cycles)); // mov i1,cycles |
| 1486 | 1693 | UML_CALLH(block, mips3.exception_norecover[EXCEPTION_INTERRUPT]); // callh interrupt_norecover |
| 1487 | 1694 | UML_LABEL(block, skip); // skip: |
| r2724 | r2725 | |
| 1494 | 1701 | // sub icount,icount,cycles,S |
| 1495 | 1702 | UML_MAPVAR(block, MAPVAR_CYCLES, 0); // mapvar cycles,0 |
| 1496 | 1703 | if (allow_exception) |
| 1497 | { | |
| 1498 | if (mempc == NULL) | |
| 1499 | UML_EXHc(block, IF_S, mips3.out_of_cycles, IMM(nextpc)); // exh out_of_cycles,nextpc | |
| 1500 | else | |
| 1501 | UML_EXHc(block, IF_S, mips3.out_of_cycles, MEM(mempc)); // exh out_of_cycles,<mempc> | |
| 1502 | } | |
| 1704 | UML_EXHc(block, IF_S, mips3.out_of_cycles, PARAM(ptype, pvalue)); // exh out_of_cycles,nextpc | |
| 1503 | 1705 | } |
| 1504 | 1706 | compiler->cycles = 0; |
| 1505 | 1707 | } |
| r2724 | r2725 | |
| 1519 | 1721 | /* loose verify or single instruction: just compare and fail */ |
| 1520 | 1722 | if (!(mips3.drcoptions & MIPS3DRC_STRICT_VERIFY) || seqhead->next == NULL) |
| 1521 | 1723 | { |
| 1522 | UML_LOAD4(block, IREG(0), seqhead->opptr.l, IMM(0)); // load4 i0,*opptr | |
| 1523 | UML_CMP(block, IREG(0), IMM(*seqhead->opptr.l)); // cmp i0,*opptr | |
| 1524 | UML_EXHc(block, IF_NE, mips3.nocode, IMM(epc(seqhead))); // exne nocode,seqhead->pc | |
| 1724 | if (!(seqhead->flags & OPFLAG_VIRTUAL_NOOP)) | |
| 1725 | { | |
| 1726 | UML_LOAD4(block, IREG(0), seqhead->opptr.l, IMM(0)); // load4 i0,*opptr | |
| 1727 | UML_CMP(block, IREG(0), IMM(*seqhead->opptr.l)); // cmp i0,*opptr | |
| 1728 | UML_EXHc(block, IF_NE, mips3.nocode, IMM(epc(seqhead))); // exne nocode,seqhead->pc | |
| 1729 | } | |
| 1525 | 1730 | } |
| 1526 | 1731 | |
| 1527 | 1732 | /* full verification; sum up everything */ |
| 1528 | 1733 | else |
| 1529 | 1734 | { |
| 1735 | #if 0 | |
| 1736 | for (curdesc = seqhead->next; curdesc != seqlast->next; curdesc = curdesc->next) | |
| 1737 | if (!(curdesc->flags & OPFLAG_VIRTUAL_NOOP)) | |
| 1738 | { | |
| 1739 | UML_LOAD4(block, IREG(0), curdesc->opptr.l, IMM(0)); // load4 i0,*opptr | |
| 1740 | UML_CMP(block, IREG(0), IMM(*curdesc->opptr.l)); // cmp i0,*opptr | |
| 1741 | UML_EXHc(block, IF_NE, mips3.nocode, IMM(epc(seqhead))); // exne nocode,seqhead->pc | |
| 1742 | } | |
| 1743 | #else | |
| 1530 | 1744 | UINT32 sum = 0; |
| 1531 | 1745 | UML_LOAD4(block, IREG(0), seqhead->opptr.l, IMM(0)); // load4 i0,*opptr |
| 1532 | 1746 | sum += *seqhead->opptr.l; |
| 1533 | 1747 | for (curdesc = seqhead->next; curdesc != seqlast->next; curdesc = curdesc->next) |
| 1534 | { | |
| 1535 | UML_LOAD4(block, IREG(1), curdesc->opptr.l, IMM(0)); // load4 i1,*opptr | |
| 1536 | UML_ADD(block, IREG(0), IREG(0), IREG(1)); // add i0,i0,i1 | |
| 1537 | sum += *curdesc->opptr.l; | |
| 1538 | } | |
| 1748 | if (!(curdesc->flags & OPFLAG_VIRTUAL_NOOP)) | |
| 1749 | { | |
| 1750 | UML_LOAD4(block, IREG(1), curdesc->opptr.l, IMM(0)); // load4 i1,*opptr | |
| 1751 | UML_ADD(block, IREG(0), IREG(0), IREG(1)); // add i0,i0,i1 | |
| 1752 | sum += *curdesc->opptr.l; | |
| 1753 | } | |
| 1539 | 1754 | UML_CMP(block, IREG(0), IMM(sum)); // cmp i0,sum |
| 1540 | 1755 | UML_EXHc(block, IF_NE, mips3.nocode, IMM(epc(seqhead))); // exne nocode,seqhead->pc |
| 1756 | #endif | |
| 1541 | 1757 | } |
| 1542 | 1758 | } |
| 1543 | 1759 | |
| r2724 | r2725 | |
| 1553 | 1769 | int hotnum; |
| 1554 | 1770 | |
| 1555 | 1771 | /* add an entry for the log */ |
| 1556 | if (LOG_UML) | |
| 1772 | if (LOG_UML && !(desc->flags & OPFLAG_VIRTUAL_NOOP)) | |
| 1557 | 1773 | log_add_disasm_comment(block, desc->pc, *desc->opptr.l); |
| 1558 | 1774 | |
| 1559 | 1775 | /* set the PC map variable */ |
| r2724 | r2725 | |
| 1565 | 1781 | |
| 1566 | 1782 | /* is this a hotspot? */ |
| 1567 | 1783 | for (hotnum = 0; hotnum < MIPS3_MAX_HOTSPOTS; hotnum++) |
| 1568 | if (desc->pc == mips3.hotspot[hotnum].pc && *desc->opptr.l == mips3.hotspot[hotnum].opcode) | |
| 1784 | if (mips3.hotspot[hotnum].pc != 0 && desc->pc == mips3.hotspot[hotnum].pc && *desc->opptr.l == mips3.hotspot[hotnum].opcode) | |
| 1569 | 1785 | { |
| 1570 | 1786 | compiler->cycles += mips3.hotspot[hotnum].cycles; |
| 1571 | 1787 | break; |
| r2724 | r2725 | |
| 1582 | 1798 | if (Machine->debug_mode) |
| 1583 | 1799 | { |
| 1584 | 1800 | UML_MOV(block, MEM(&mips3.core->pc), IMM(desc->pc)); // mov [pc],desc->pc |
| 1801 | save_fast_iregs(block); | |
| 1585 | 1802 | UML_DEBUG(block, IMM(desc->pc)); // debug desc->pc |
| 1586 | 1803 | } |
| 1587 | 1804 | |
| 1588 | /* validate our TLB entry at this PC; if we fail, we need to recompile */ | |
| 1805 | /* if we hit an unmapped address, fatal error */ | |
| 1806 | if (desc->flags & OPFLAG_COMPILER_UNMAPPED) | |
| 1807 | { | |
| 1808 | UML_MOV(block, MEM(&mips3.core->pc), IMM(desc->pc)); // mov [pc],desc->pc | |
| 1809 | save_fast_iregs(block); | |
| 1810 | UML_EXIT(block, IMM(EXECUTE_UNMAPPED_CODE)); // exit EXECUTE_UNMAPPED_CODE | |
| 1811 | } | |
| 1812 | ||
| 1813 | /* if we hit a compiler page fault, it's just like a TLB mismatch */ | |
| 1814 | if (desc->flags & OPFLAG_COMPILER_PAGE_FAULT) | |
| 1815 | { | |
| 1816 | if (PRINTF_MMU) | |
| 1817 | { | |
| 1818 | UML_MOV(block, MEM(&mips3.cstate->arg0), IMM(desc->pc)); // mov [arg0],desc->pc | |
| 1819 | UML_CALLC(block, cfunc_printf_debug, "Compiler page fault @ %08X\n"); // callc printf_debug | |
| 1820 | } | |
| 1821 | UML_EXH(block, mips3.tlb_mismatch, IMM(0)); // exh tlb_mismatch,0 | |
| 1822 | } | |
| 1823 | ||
| 1824 | /* validate our TLB entry at this PC; if we fail, we need to handle it */ | |
| 1589 | 1825 | if ((desc->flags & OPFLAG_VALIDATE_TLB) && (desc->pc < 0x80000000 || desc->pc >= 0xc0000000)) |
| 1590 | 1826 | { |
| 1591 | UML_CMP(block, MEM(&mips3.core->tlb_table[desc->pc >> 12]), | |
| 1592 | IMM(mips3.core->tlb_table[desc->pc >> 12])); // cmp [tlbentry],*tlbentry | |
| 1593 | UML_EXHc(block, IF_NE, mips3.tlb_mismatch, IMM(0)); // exh tlb_mismatch,0,NE | |
| 1827 | /* if we currently have a valid TLB read entry, we just verify */ | |
| 1828 | if (mips3.core->tlb_table[desc->pc >> 12] & TLB_VALID) | |
| 1829 | { | |
| 1830 | if (PRINTF_MMU) | |
| 1831 | { | |
| 1832 | UML_MOV(block, MEM(&mips3.cstate->arg0), IMM(desc->pc)); // mov [arg0],desc->pc | |
| 1833 | UML_CALLC(block, cfunc_printf_debug, "Checking TLB at @ %08X\n"); // callc printf_debug | |
| 1834 | } | |
| 1835 | UML_LOAD4(block, IREG(0), &mips3.core->tlb_table[desc->pc >> 12], IMM(0));// load4 i0,tlb_table[desc->pc >> 12] | |
| 1836 | UML_CMP(block, IREG(0), IMM(mips3.core->tlb_table[desc->pc >> 12])); // cmp i0,*tlbentry | |
| 1837 | UML_EXHc(block, IF_NE, mips3.tlb_mismatch, IMM(0)); // exh tlb_mismatch,0,NE | |
| 1838 | } | |
| 1839 | ||
| 1840 | /* otherwise, we generate an unconditional exception */ | |
| 1841 | else | |
| 1842 | { | |
| 1843 | if (PRINTF_MMU) | |
| 1844 | { | |
| 1845 | UML_MOV(block, MEM(&mips3.cstate->arg0), IMM(desc->pc)); // mov [arg0],desc->pc | |
| 1846 | UML_CALLC(block, cfunc_printf_debug, "No valid TLB @ %08X\n"); // callc printf_debug | |
| 1847 | } | |
| 1848 | UML_EXH(block, mips3.tlb_mismatch, IMM(0)); // exh tlb_mismatch,0 | |
| 1849 | } | |
| 1594 | 1850 | } |
| 1595 | 1851 | |
| 1596 | 1852 | /* if this is an invalid opcode, generate the exception now */ |
| 1597 | 1853 | if (desc->flags & OPFLAG_INVALID_OPCODE) |
| 1598 | 1854 | UML_EXH(block, mips3.exception[EXCEPTION_INVALIDOP], IMM(0)); // exh invalidop,0 |
| 1599 | 1855 | |
| 1600 | /* otherwise, it's a regular instruction */ | |
| 1601 | else | |
| 1856 | /* otherwise, unless this is a virtual no-op, it's a regular instruction */ | |
| 1857 | else if (!(desc->flags & OPFLAG_VIRTUAL_NOOP)) | |
| 1602 | 1858 | { |
| 1603 | 1859 | /* compile the instruction */ |
| 1604 | 1860 | if (!generate_opcode(block, compiler, desc)) |
| 1605 | fatalerror("Unimplemented op %08X (%02X,%02X)", *desc->opptr.l, *desc->opptr.l >> 26, *desc->opptr.l & 0x3f); | |
| 1861 | { | |
| 1862 | UML_MOV(block, MEM(&mips3.core->pc), IMM(desc->pc)); // mov [pc],desc->pc | |
| 1863 | UML_CALLC(block, cfunc_unimplemented, (void *)(FPTR)*desc->opptr.l); // callc cfunc_unimplemented | |
| 1864 | } | |
| 1606 | 1865 | } |
| 1607 | 1866 | } |
| 1608 | 1867 | |
| r2724 | r2725 | |
| 1627 | 1886 | /* update the cycles and jump through the hash table to the target */ |
| 1628 | 1887 | if (desc->targetpc != BRANCH_TARGET_DYNAMIC) |
| 1629 | 1888 | { |
| 1630 | generate_update_cycles(block, &compiler_temp, desc->targetpc | |
| 1889 | generate_update_cycles(block, &compiler_temp, IMM(desc->targetpc) | |
| 1631 | 1890 | if (desc->flags & OPFLAG_INTRABLOCK_BRANCH) |
| 1632 | 1891 | UML_JMP(block, desc->targetpc | 0x80000000); // jmp desc->targetpc | 0x80000000 |
| 1633 | 1892 | else |
| r2724 | r2725 | |
| 1636 | 1895 | } |
| 1637 | 1896 | else |
| 1638 | 1897 | { |
| 1639 | generate_update_cycles(block, &compiler_temp, | |
| 1898 | generate_update_cycles(block, &compiler_temp, | |
| 1640 | 1899 | // <subtract cycles> |
| 1641 | 1900 | UML_HASHJMP(block, IMM(mips3.cstate->mode), R32(RSREG), mips3.nocode); // hashjmp <mode>,<rsreg>,nocode |
| 1642 | 1901 | } |
| r2724 | r2725 | |
| 1803 | 2062 | |
| 1804 | 2063 | case 0x20: /* LB - MIPS I */ |
| 1805 | 2064 | UML_ADD(block, IREG(0), R32(RSREG), IMM(SIMMVAL)); // add i0,<rsreg>,SIMMVAL |
| 1806 | UML_CALLH(block, mips3.read8); | |
| 2065 | UML_CALLH(block, mips3.read8[mips3.cstate->mode >> 1]); | |
| 1807 | 2066 | if (RTREG != 0) |
| 1808 | 2067 | UML_DSEXT1(block, R64(RTREG), IREG(0)); // dsext1 <rtreg>,i0 |
| 1809 | 2068 | if (!in_delay_slot) |
| 1810 | generate_update_cycles(block, compiler, desc->pc + 4 | |
| 2069 | generate_update_cycles(block, compiler, IMM(desc->pc + 4) | |
| 1811 | 2070 | return TRUE; |
| 1812 | 2071 | |
| 1813 | 2072 | case 0x21: /* LH - MIPS I */ |
| 1814 | 2073 | UML_ADD(block, IREG(0), R32(RSREG), IMM(SIMMVAL)); // add i0,<rsreg>,SIMMVAL |
| 1815 | UML_CALLH(block, mips3.read16); | |
| 2074 | UML_CALLH(block, mips3.read16[mips3.cstate->mode >> 1]); | |
| 1816 | 2075 | if (RTREG != 0) |
| 1817 | 2076 | UML_DSEXT2(block, R64(RTREG), IREG(0)); // dsext2 <rtreg>,i0 |
| 1818 | 2077 | if (!in_delay_slot) |
| 1819 | generate_update_cycles(block, compiler, desc->pc + 4 | |
| 2078 | generate_update_cycles(block, compiler, IMM(desc->pc + 4) | |
| 1820 | 2079 | return TRUE; |
| 1821 | 2080 | |
| 1822 | 2081 | case 0x23: /* LW - MIPS I */ |
| 1823 | 2082 | UML_ADD(block, IREG(0), R32(RSREG), IMM(SIMMVAL)); // add i0,<rsreg>,SIMMVAL |
| 1824 | UML_CALLH(block, mips3.read32); | |
| 2083 | UML_CALLH(block, mips3.read32[mips3.cstate->mode >> 1]); | |
| 1825 | 2084 | if (RTREG != 0) |
| 1826 | 2085 | UML_DSEXT4(block, R64(RTREG), IREG(0)); // dsext4 <rtreg>,i0 |
| 1827 | 2086 | if (!in_delay_slot) |
| 1828 | generate_update_cycles(block, compiler, desc->pc + 4 | |
| 2087 | generate_update_cycles(block, compiler, IMM(desc->pc + 4) | |
| 1829 | 2088 | return TRUE; |
| 1830 | 2089 | |
| 1831 | 2090 | case 0x24: /* LBU - MIPS I */ |
| 1832 | 2091 | UML_ADD(block, IREG(0), R32(RSREG), IMM(SIMMVAL)); // add i0,<rsreg>,SIMMVAL |
| 1833 | UML_CALLH(block, mips3.read8); | |
| 2092 | UML_CALLH(block, mips3.read8[mips3.cstate->mode >> 1]); | |
| 1834 | 2093 | if (RTREG != 0) |
| 1835 | 2094 | UML_DZEXT1(block, R64(RTREG), IREG(0)); // dzext1 <rtreg>,i0 |
| 1836 | 2095 | if (!in_delay_slot) |
| 1837 | generate_update_cycles(block, compiler, desc->pc + 4 | |
| 2096 | generate_update_cycles(block, compiler, IMM(desc->pc + 4) | |
| 1838 | 2097 | return TRUE; |
| 1839 | 2098 | |
| 1840 | 2099 | case 0x25: /* LHU - MIPS I */ |
| 1841 | 2100 | UML_ADD(block, IREG(0), R32(RSREG), IMM(SIMMVAL)); // add i0,<rsreg>,SIMMVAL |
| 1842 | UML_CALLH(block, mips3.read16); | |
| 2101 | UML_CALLH(block, mips3.read16[mips3.cstate->mode >> 1]); | |
| 1843 | 2102 | if (RTREG != 0) |
| 1844 | 2103 | UML_DZEXT2(block, R64(RTREG), IREG(0)); // dzext2 <rtreg>,i0 |
| 1845 | 2104 | if (!in_delay_slot) |
| 1846 | generate_update_cycles(block, compiler, desc->pc + 4 | |
| 2105 | generate_update_cycles(block, compiler, IMM(desc->pc + 4) | |
| 1847 | 2106 | return TRUE; |
| 1848 | 2107 | |
| 1849 | 2108 | case 0x27: /* LWU - MIPS III */ |
| 1850 | 2109 | UML_ADD(block, IREG(0), R32(RSREG), IMM(SIMMVAL)); // add i0,<rsreg>,SIMMVAL |
| 1851 | UML_CALLH(block, mips3.read32); | |
| 2110 | UML_CALLH(block, mips3.read32[mips3.cstate->mode >> 1]); | |
| 1852 | 2111 | if (RTREG != 0) |
| 1853 | 2112 | UML_DZEXT4(block, R64(RTREG), IREG(0)); // dzext4 <rtreg>,i0 |
| 1854 | 2113 | if (!in_delay_slot) |
| 1855 | generate_update_cycles(block, compiler, desc->pc + 4 | |
| 2114 | generate_update_cycles(block, compiler, IMM(desc->pc + 4) | |
| 1856 | 2115 | return TRUE; |
| 1857 | 2116 | |
| 1858 | 2117 | case 0x37: /* LD - MIPS III */ |
| 1859 | 2118 | UML_ADD(block, IREG(0), R32(RSREG), IMM(SIMMVAL)); // add i0,<rsreg>,SIMMVAL |
| 1860 | UML_CALLH(block, mips3.read64); | |
| 2119 | UML_CALLH(block, mips3.read64[mips3.cstate->mode >> 1]); | |
| 1861 | 2120 | if (RTREG != 0) |
| 1862 | 2121 | UML_DMOV(block, R64(RTREG), IREG(0)); // dmov <rtreg>,i0 |
| 1863 | 2122 | if (!in_delay_slot) |
| 1864 | generate_update_cycles(block, compiler, desc->pc + 4 | |
| 2123 | generate_update_cycles(block, compiler, IMM(desc->pc + 4) | |
| 1865 | 2124 | return TRUE; |
| 1866 | 2125 | |
| 1867 | 2126 | case 0x22: /* LWL - MIPS I */ |
| 1868 | 2127 | UML_ADD(block, IREG(0), R32(RSREG), IMM(SIMMVAL)); // add i0,<rsreg>,SIMMVAL |
| 1869 | UML_SHL(block, IREG( | |
| 2128 | UML_SHL(block, IREG(1), IREG(0), IMM(3)); // shl i1,i0,3 | |
| 1870 | 2129 | if (!mips3.core->bigendian) |
| 1871 | UML_XOR(block, IREG(4), IREG(4), IMM(0x18)); // xor i4,i4,0x18 | |
| 1872 | UML_SHR(block, IREG(2), IMM(~0), IREG(4)); // shr i2,~0,i4 | |
| 1873 | UML_CALLH(block, mips3.read32mask); // callh read32mask | |
| 2130 | UML_XOR(block, IREG(1), IREG(1), IMM(0x18)); // xor i1,i1,0x18 | |
| 2131 | UML_SHR(block, IREG(2), IMM(~0), IREG(1)); // shr i2,~0,i1 | |
| 2132 | UML_CALLH(block, mips3.read32mask[mips3.cstate->mode >> 1]); // callh read32mask | |
| 1874 | 2133 | if (RTREG != 0) |
| 1875 | 2134 | { |
| 1876 | UML_SHL(block, IREG(2), IMM(~0), IREG(4)); // shl i2,~0,i4 | |
| 1877 | UML_XOR(block, IREG(2), IREG(2), IMM(~0)); // xor i2,i2,~0 | |
| 1878 | UML_SHL(block, IREG(0), IREG(0), IREG(4)); // shl i0,i0,i4 | |
| 1879 | UML_AND(block, IREG(2), IREG(2), R32(RTREG)); // and i2,i2,<rtreg> | |
| 1880 | UML_OR(block, IREG(0), IREG(0), IREG(2)); // or i0,i0,i2 | |
| 1881 | UML_DSEXT4(block, R64(RTREG), IREG(0)); // dsext4 <rtreg>,i0 | |
| 2135 | UML_SHL(block, IREG(2), IMM(~0), IREG(1)); // shl i2,~0,i1 | |
| 2136 | UML_MOV(block, IREG(3), R32(RTREG)); // mov i3,<rtreg> | |
| 2137 | UML_INSERT(block, IREG(3), IREG(0), IREG(1), IREG(2)); // insert i3,i0,i1,i2 | |
| 2138 | UML_DSEXT4(block, R64(RTREG), IREG(3)); // dsext4 <rtreg>,i3 | |
| 1882 | 2139 | } |
| 1883 | 2140 | if (!in_delay_slot) |
| 1884 | generate_update_cycles(block, compiler, desc->pc + 4 | |
| 2141 | generate_update_cycles(block, compiler, IMM(desc->pc + 4) | |
| 1885 | 2142 | return TRUE; |
| 1886 | 2143 | |
| 1887 | 2144 | case 0x26: /* LWR - MIPS I */ |
| 1888 | 2145 | UML_ADD(block, IREG(0), R32(RSREG), IMM(SIMMVAL)); // add i0,<rsreg>,SIMMVAL |
| 1889 | UML_SHL(block, IREG( | |
| 2146 | UML_SHL(block, IREG(1), IREG(0), IMM(3)); // shl i1,i0,3 | |
| 1890 | 2147 | if (mips3.core->bigendian) |
| 1891 | UML_XOR(block, IREG(4), IREG(4), IMM(0x18)); // xor i4,i4,0x18 | |
| 1892 | UML_SHL(block, IREG(2), IMM(~0), IREG(4)); // shl i2,~0,i4 | |
| 1893 | UML_CALLH(block, mips3.read32mask); // callh read32mask | |
| 2148 | UML_XOR(block, IREG(1), IREG(1), IMM(0x18)); // xor i1,i1,0x18 | |
| 2149 | UML_SHL(block, IREG(2), IMM(~0), IREG(1)); // shl i2,~0,i1 | |
| 2150 | UML_CALLH(block, mips3.read32mask[mips3.cstate->mode >> 1]); // callh read32mask | |
| 1894 | 2151 | if (RTREG != 0) |
| 1895 | 2152 | { |
| 1896 | UML_SHR(block, IREG(2), IMM(~0), IREG(4)); // shr i2,~0,i4 | |
| 1897 | UML_XOR(block, IREG(2), IREG(2), IMM(~0)); // xor i2,i2,~0 | |
| 1898 | UML_SHR(block, IREG(0), IREG(0), IREG(4)); // shr i0,i0,i4 | |
| 1899 | UML_AND(block, IREG(2), IREG(2), R32(RTREG)); // and i2,i2,<rtreg> | |
| 1900 | UML_OR(block, IREG(0), IREG(0), IREG(2)); // or i0,i0,i2 | |
| 1901 | UML_DSEXT4(block, R64(RTREG), IREG(0)); // dsext4 <rtreg>,i0 | |
| 2153 | UML_SHR(block, IREG(2), IMM(~0), IREG(1)); // shr i2,~0,i1 | |
| 2154 | UML_SUB(block, IREG(1), IMM(32), IREG(1)); // sub i1,32,i1 | |
| 2155 | UML_MOV(block, IREG(3), R32(RTREG)); // mov i3,<rtreg> | |
| 2156 | UML_INSERT(block, IREG(3), IREG(0), IREG(1), IREG(2)); // insert i3,i0,i1,i2 | |
| 2157 | UML_DSEXT4(block, R64(RTREG), IREG(3)); // dsext4 <rtreg>,i3 | |
| 1902 | 2158 | } |
| 1903 | 2159 | if (!in_delay_slot) |
| 1904 | generate_update_cycles(block, compiler, desc->pc + 4 | |
| 2160 | generate_update_cycles(block, compiler, IMM(desc->pc + 4) | |
| 1905 | 2161 | return TRUE; |
| 1906 | 2162 | |
| 1907 | 2163 | case 0x1a: /* LDL - MIPS III */ |
| 1908 | 2164 | UML_ADD(block, IREG(0), R32(RSREG), IMM(SIMMVAL)); // add i0,<rsreg>,SIMMVAL |
| 1909 | UML_SHL(block, IREG( | |
| 2165 | UML_SHL(block, IREG(1), IREG(0), IMM(3)); // shl i1,i0,3 | |
| 1910 | 2166 | if (!mips3.core->bigendian) |
| 1911 | UML_XOR(block, IREG(4), IREG(4), IMM(0x38)); // xor i4,i4,0x38 | |
| 1912 | UML_DSHR(block, IREG(2), IMM((UINT64)~0), IREG(4)); // dshr i2,~0,i4 | |
| 1913 | UML_CALLH(block, mips3.read64mask); // callh read64mask | |
| 2167 | UML_XOR(block, IREG(1), IREG(1), IMM(0x38)); // xor i1,i1,0x38 | |
| 2168 | UML_DSHR(block, IREG(2), IMM((UINT64)~0), IREG(1)); // dshr i2,~0,i1 | |
| 2169 | UML_CALLH(block, mips3.read64mask[mips3.cstate->mode >> 1]); // callh read64mask | |
| 1914 | 2170 | if (RTREG != 0) |
| 1915 | 2171 | { |
| 1916 | UML_DSHL(block, IREG(2), IMM((UINT64)~0), IREG(4)); // dshl i2,~0,i4 | |
| 1917 | UML_DXOR(block, IREG(2), IREG(2), IMM((UINT64)~0)); // dxor i2,i2,~0 | |
| 1918 | UML_DSHL(block, IREG(0), IREG(0), IREG(4)); // dshl i0,i0,i4 | |
| 1919 | UML_DAND(block, IREG(2), IREG(2), R64(RTREG)); // dand i2,i2,<rtreg> | |
| 1920 | UML_DOR(block, R64(RTREG), IREG(0), IREG(2)); // dor <rtreg>,i0,i2 | |
| 2172 | UML_DSHL(block, IREG(2), IMM((UINT64)~0), IREG(1)); // dshl i2,~0,i1 | |
| 2173 | UML_DINSERT(block, R64(RTREG), IREG(0), IREG(1), IREG(2)); // dinsert <rtreg>,i0,i1,i2 | |
| 1921 | 2174 | } |
| 1922 | 2175 | if (!in_delay_slot) |
| 1923 | generate_update_cycles(block, compiler, desc->pc + 4 | |
| 2176 | generate_update_cycles(block, compiler, IMM(desc->pc + 4) | |
| 1924 | 2177 | return TRUE; |
| 1925 | 2178 | |
| 1926 | 2179 | case 0x1b: /* LDR - MIPS III */ |
| 1927 | 2180 | UML_ADD(block, IREG(0), R32(RSREG), IMM(SIMMVAL)); // add i0,<rsreg>,SIMMVAL |
| 1928 | UML_SHL(block, IREG( | |
| 2181 | UML_SHL(block, IREG(1), IREG(0), IMM(3)); // shl i1,i0,3 | |
| 1929 | 2182 | if (mips3.core->bigendian) |
| 1930 | UML_XOR(block, IREG(4), IREG(4), IMM(0x38)); // xor i4,i4,0x38 | |
| 1931 | UML_DSHL(block, IREG(2), IMM((UINT64)~0), IREG(4)); // dshl i2,~0,i4 | |
| 1932 | UML_CALLH(block, mips3.read64mask); // callh read64mask | |
| 2183 | UML_XOR(block, IREG(1), IREG(1), IMM(0x38)); // xor i1,i1,0x38 | |
| 2184 | UML_DSHL(block, IREG(2), IMM((UINT64)~0), IREG(1)); // dshl i2,~0,i1 | |
| 2185 | UML_CALLH(block, mips3.read64mask[mips3.cstate->mode >> 1]); // callh read64mask | |
| 1933 | 2186 | if (RTREG != 0) |
| 1934 | 2187 | { |
| 1935 | UML_DSHR(block, IREG(2), IMM((UINT64)~0), IREG(4)); // dshr i2,~0,i4 | |
| 1936 | UML_DXOR(block, IREG(2), IREG(2), IMM((UINT64)~0)); // dxor i2,i2,~0 | |
| 1937 | UML_DSHR(block, IREG(0), IREG(0), IREG(4)); // dshr i0,i0,i4 | |
| 1938 | UML_DAND(block, IREG(2), IREG(2), R64(RTREG)); // dand i2,i2,<rtreg> | |
| 1939 | UML_DOR(block, R64(RTREG), IREG(0), IREG(2)); // dor <rtreg>,i0,i2 | |
| 2188 | UML_DSHR(block, IREG(2), IMM((UINT64)~0), IREG(1)); // dshr i2,~0,i1 | |
| 2189 | UML_SUB(block, IREG(1), IMM(64), IREG(1)); // sub i1,64,i1 | |
| 2190 | UML_DINSERT(block, R64(RTREG), IREG(0), IREG(1), IREG(2)); // dinsert <rtreg>,i0,i1,i2 | |
| 1940 | 2191 | } |
| 1941 | 2192 | if (!in_delay_slot) |
| 1942 | generate_update_cycles(block, compiler, desc->pc + 4 | |
| 2193 | generate_update_cycles(block, compiler, IMM(desc->pc + 4) | |
| 1943 | 2194 | return TRUE; |
| 1944 | 2195 | |
| 1945 | 2196 | case 0x31: /* LWC1 - MIPS I */ |
| 1946 | 2197 | UML_ADD(block, IREG(0), R32(RSREG), IMM(SIMMVAL)); // add i0,<rsreg>,SIMMVAL |
| 1947 | UML_CALLH(block, mips3.read32); | |
| 2198 | UML_CALLH(block, mips3.read32[mips3.cstate->mode >> 1]); | |
| 1948 | 2199 | UML_MOV(block, FPR32(RTREG), IREG(0)); // mov <cpr1_rt>,i0 |
| 1949 | 2200 | if (!in_delay_slot) |
| 1950 | generate_update_cycles(block, compiler, desc->pc + 4 | |
| 2201 | generate_update_cycles(block, compiler, IMM(desc->pc + 4) | |
| 1951 | 2202 | return TRUE; |
| 1952 | 2203 | |
| 1953 | 2204 | case 0x35: /* LDC1 - MIPS III */ |
| 1954 | 2205 | UML_ADD(block, IREG(0), R32(RSREG), IMM(SIMMVAL)); // add i0,<rsreg>,SIMMVAL |
| 1955 | UML_CALLH(block, mips3.read64); | |
| 2206 | UML_CALLH(block, mips3.read64[mips3.cstate->mode >> 1]); | |
| 1956 | 2207 | UML_DMOV(block, FPR64(RTREG), IREG(0)); // dmov <cpr1_rt>,i0 |
| 1957 | 2208 | if (!in_delay_slot) |
| 1958 | generate_update_cycles(block, compiler, desc->pc + 4 | |
| 2209 | generate_update_cycles(block, compiler, IMM(desc->pc + 4) | |
| 1959 | 2210 | return TRUE; |
| 1960 | 2211 | |
| 1961 | 2212 | case 0x32: /* LWC2 - MIPS I */ |
| 1962 | 2213 | UML_ADD(block, IREG(0), R32(RSREG), IMM(SIMMVAL)); // add i0,<rsreg>,SIMMVAL |
| 1963 | UML_CALLH(block, mips3.read32); | |
| 2214 | UML_CALLH(block, mips3.read32[mips3.cstate->mode >> 1]); | |
| 1964 | 2215 | UML_DZEXT4(block, CPR264(RTREG), IREG(0)); // dzext4 <cpr2_rt>,i0 |
| 1965 | 2216 | if (!in_delay_slot) |
| 1966 | generate_update_cycles(block, compiler, desc->pc + 4 | |
| 2217 | generate_update_cycles(block, compiler, IMM(desc->pc + 4) | |
| 1967 | 2218 | return TRUE; |
| 1968 | 2219 | |
| 1969 | 2220 | case 0x36: /* LDC2 - MIPS II */ |
| 1970 | 2221 | UML_ADD(block, IREG(0), R32(RSREG), IMM(SIMMVAL)); // add i0,<rsreg>,SIMMVAL |
| 1971 | UML_CALLH(block, mips3.read64); | |
| 2222 | UML_CALLH(block, mips3.read64[mips3.cstate->mode >> 1]); | |
| 1972 | 2223 | UML_DMOV(block, CPR264(RTREG), IREG(0)); // dmov <cpr2_rt>,i0 |
| 1973 | 2224 | if (!in_delay_slot) |
| 1974 | generate_update_cycles(block, compiler, desc->pc + 4 | |
| 2225 | generate_update_cycles(block, compiler, IMM(desc->pc + 4) | |
| 1975 | 2226 | return TRUE; |
| 1976 | 2227 | |
| 1977 | 2228 | |
| r2724 | r2725 | |
| 1980 | 2231 | case 0x28: /* SB - MIPS I */ |
| 1981 | 2232 | UML_ADD(block, IREG(0), R32(RSREG), IMM(SIMMVAL)); // add i0,<rsreg>,SIMMVAL |
| 1982 | 2233 | UML_MOV(block, IREG(1), R32(RTREG)); // mov i1,<rtreg> |
| 1983 | UML_CALLH(block, mips3.write8); | |
| 2234 | UML_CALLH(block, mips3.write8[mips3.cstate->mode >> 1]); | |
| 1984 | 2235 | if (!in_delay_slot) |
| 1985 | generate_update_cycles(block, compiler, desc->pc + 4 | |
| 2236 | generate_update_cycles(block, compiler, IMM(desc->pc + 4) | |
| 1986 | 2237 | return TRUE; |
| 1987 | 2238 | |
| 1988 | 2239 | case 0x29: /* SH - MIPS I */ |
| 1989 | 2240 | UML_ADD(block, IREG(0), R32(RSREG), IMM(SIMMVAL)); // add i0,<rsreg>,SIMMVAL |
| 1990 | 2241 | UML_MOV(block, IREG(1), R32(RTREG)); // mov i1,<rtreg> |
| 1991 | UML_CALLH(block, mips3.write16); | |
| 2242 | UML_CALLH(block, mips3.write16[mips3.cstate->mode >> 1]); | |
| 1992 | 2243 | if (!in_delay_slot) |
| 1993 | generate_update_cycles(block, compiler, desc->pc + 4 | |
| 2244 | generate_update_cycles(block, compiler, IMM(desc->pc + 4) | |
| 1994 | 2245 | return TRUE; |
| 1995 | 2246 | |
| 1996 | 2247 | case 0x2b: /* SW - MIPS I */ |
| 1997 | 2248 | UML_ADD(block, IREG(0), R32(RSREG), IMM(SIMMVAL)); // add i0,<rsreg>,SIMMVAL |
| 1998 | 2249 | UML_MOV(block, IREG(1), R32(RTREG)); // mov i1,<rtreg> |
| 1999 | UML_CALLH(block, mips3.write32); | |
| 2250 | UML_CALLH(block, mips3.write32[mips3.cstate->mode >> 1]); | |
| 2000 | 2251 | if (!in_delay_slot) |
| 2001 | generate_update_cycles(block, compiler, desc->pc + 4 | |
| 2252 | generate_update_cycles(block, compiler, IMM(desc->pc + 4) | |
| 2002 | 2253 | return TRUE; |
| 2003 | 2254 | |
| 2004 | 2255 | case 0x3f: /* SD - MIPS III */ |
| 2005 | 2256 | UML_ADD(block, IREG(0), R32(RSREG), IMM(SIMMVAL)); // add i0,<rsreg>,SIMMVAL |
| 2006 | 2257 | UML_DMOV(block, IREG(1), R64(RTREG)); // dmov i1,<rtreg> |
| 2007 | UML_CALLH(block, mips3.write64); | |
| 2258 | UML_CALLH(block, mips3.write64[mips3.cstate->mode >> 1]); | |
| 2008 | 2259 | if (!in_delay_slot) |
| 2009 | generate_update_cycles(block, compiler, desc->pc + 4 | |
| 2260 | generate_update_cycles(block, compiler, IMM(desc->pc + 4) | |
| 2010 | 2261 | return TRUE; |
| 2011 | 2262 | |
| 2012 | 2263 | case 0x2a: /* SWL - MIPS I */ |
| 2013 | 2264 | UML_ADD(block, IREG(0), R32(RSREG), IMM(SIMMVAL)); // add i0,<rsreg>,SIMMVAL |
| 2014 | UML_SHL(block, IREG( | |
| 2265 | UML_SHL(block, IREG(3), IREG(0), IMM(3)); // shl i3,i0,3 | |
| 2015 | 2266 | UML_MOV(block, IREG(1), R32(RTREG)); // mov i1,<rtreg> |
| 2016 | 2267 | if (!mips3.core->bigendian) |
| 2017 | UML_XOR(block, IREG(4), IREG(4), IMM(0x18)); // xor i4,i4,0x18 | |
| 2018 | UML_SHR(block, IREG(2), IMM(~0), IREG(4)); // shr i2,~0,i4 | |
| 2019 | UML_SHR(block, IREG(1), IREG(1), IREG(4)); // shr i1,i1,i4 | |
| 2020 | UML_CALLH(block, mips3.write32mask); // callh write32mask | |
| 2268 | UML_XOR(block, IREG(3), IREG(3), IMM(0x18)); // xor i3,i3,0x18 | |
| 2269 | UML_SHR(block, IREG(2), IMM(~0), IREG(3)); // shr i2,~0,i3 | |
| 2270 | UML_SHR(block, IREG(1), IREG(1), IREG(3)); // shr i1,i1,i3 | |
| 2271 | UML_CALLH(block, mips3.write32mask[mips3.cstate->mode >> 1]); // callh write32mask | |
| 2021 | 2272 | if (!in_delay_slot) |
| 2022 | generate_update_cycles(block, compiler, desc->pc + 4 | |
| 2273 | generate_update_cycles(block, compiler, IMM(desc->pc + 4) | |
| 2023 | 2274 | return TRUE; |
| 2024 | 2275 | |
| 2025 | 2276 | case 0x2e: /* SWR - MIPS I */ |
| 2026 | 2277 | UML_ADD(block, IREG(0), R32(RSREG), IMM(SIMMVAL)); // add i0,<rsreg>,SIMMVAL |
| 2027 | UML_SHL(block, IREG( | |
| 2278 | UML_SHL(block, IREG(3), IREG(0), IMM(3)); // shl i3,i0,3 | |
| 2028 | 2279 | UML_MOV(block, IREG(1), R32(RTREG)); // mov i1,<rtreg> |
| 2029 | 2280 | if (mips3.core->bigendian) |
| 2030 | UML_XOR(block, IREG(4), IREG(4), IMM(0x18)); // xor i4,i4,0x18 | |
| 2031 | UML_SHL(block, IREG(2), IMM(~0), IREG(4)); // shl i2,~0,i4 | |
| 2032 | UML_SHL(block, IREG(1), IREG(1), IREG(4)); // shl i1,i1,i4 | |
| 2033 | UML_CALLH(block, mips3.write32mask); // callh write32mask | |
| 2281 | UML_XOR(block, IREG(3), IREG(3), IMM(0x18)); // xor i3,i3,0x18 | |
| 2282 | UML_SHL(block, IREG(2), IMM(~0), IREG(3)); // shl i2,~0,i3 | |
| 2283 | UML_SHL(block, IREG(1), IREG(1), IREG(3)); // shl i1,i1,i3 | |
| 2284 | UML_CALLH(block, mips3.write32mask[mips3.cstate->mode >> 1]); // callh write32mask | |
| 2034 | 2285 | if (!in_delay_slot) |
| 2035 | generate_update_cycles(block, compiler, desc->pc + 4 | |
| 2286 | generate_update_cycles(block, compiler, IMM(desc->pc + 4) | |
| 2036 | 2287 | return TRUE; |
| 2037 | 2288 | |
| 2038 | 2289 | case 0x2c: /* SDL - MIPS III */ |
| 2039 | 2290 | UML_ADD(block, IREG(0), R32(RSREG), IMM(SIMMVAL)); // add i0,<rsreg>,SIMMVAL |
| 2040 | UML_SHL(block, IREG( | |
| 2291 | UML_SHL(block, IREG(3), IREG(0), IMM(3)); // shl i3,i0,3 | |
| 2041 | 2292 | UML_DMOV(block, IREG(1), R64(RTREG)); // dmov i1,<rtreg> |
| 2042 | 2293 | if (!mips3.core->bigendian) |
| 2043 | UML_XOR(block, IREG(4), IREG(4), IMM(0x38)); // xor i4,i4,0x38 | |
| 2044 | UML_DSHR(block, IREG(2), IMM((UINT64)~0), IREG(4)); // dshr i2,~0,i4 | |
| 2045 | UML_DSHR(block, IREG(1), IREG(1), IREG(4)); // dshr i1,i1,i4 | |
| 2046 | UML_CALLH(block, mips3.write64mask); // callh write64mask | |
| 2294 | UML_XOR(block, IREG(3), IREG(3), IMM(0x38)); // xor i3,i3,0x38 | |
| 2295 | UML_DSHR(block, IREG(2), IMM((UINT64)~0), IREG(3)); // dshr i2,~0,i3 | |
| 2296 | UML_DSHR(block, IREG(1), IREG(1), IREG(3)); // dshr i1,i1,i3 | |
| 2297 | UML_CALLH(block, mips3.write64mask[mips3.cstate->mode >> 1]); // callh write64mask | |
| 2047 | 2298 | if (!in_delay_slot) |
| 2048 | generate_update_cycles(block, compiler, desc->pc + 4 | |
| 2299 | generate_update_cycles(block, compiler, IMM(desc->pc + 4) | |
| 2049 | 2300 | return TRUE; |
| 2050 | 2301 | |
| 2051 | 2302 | case 0x2d: /* SDR - MIPS III */ |
| 2052 | 2303 | UML_ADD(block, IREG(0), R32(RSREG), IMM(SIMMVAL)); // add i0,<rsreg>,SIMMVAL |
| 2053 | UML_SHL(block, IREG( | |
| 2304 | UML_SHL(block, IREG(3), IREG(0), IMM(3)); // shl i3,i0,3 | |
| 2054 | 2305 | UML_DMOV(block, IREG(1), R64(RTREG)); // dmov i1,<rtreg> |
| 2055 | 2306 | if (mips3.core->bigendian) |
| 2056 | UML_XOR(block, IREG(4), IREG(4), IMM(0x38)); // xor i4,i4,0x38 | |
| 2057 | UML_DSHL(block, IREG(2), IMM((UINT64)~0), IREG(4)); // dshl i2,~0,i4 | |
| 2058 | UML_DSHL(block, IREG(1), IREG(1), IREG(4)); // dshl i1,i1,i4 | |
| 2059 | UML_CALLH(block, mips3.write64mask); // callh write64mask | |
| 2307 | UML_XOR(block, IREG(3), IREG(3), IMM(0x38)); // xor i3,i3,0x38 | |
| 2308 | UML_DSHL(block, IREG(2), IMM((UINT64)~0), IREG(3)); // dshl i2,~0,i3 | |
| 2309 | UML_DSHL(block, IREG(1), IREG(1), IREG(3)); // dshl i1,i1,i3 | |
| 2310 | UML_CALLH(block, mips3.write64mask[mips3.cstate->mode >> 1]); // callh write64mask | |
| 2060 | 2311 | if (!in_delay_slot) |
| 2061 | generate_update_cycles(block, compiler, desc->pc + 4 | |
| 2312 | generate_update_cycles(block, compiler, IMM(desc->pc + 4) | |
| 2062 | 2313 | return TRUE; |
| 2063 | 2314 | |
| 2064 | 2315 | case 0x39: /* SWC1 - MIPS I */ |
| 2065 | 2316 | UML_ADD(block, IREG(0), R32(RSREG), IMM(SIMMVAL)); // add i0,<rsreg>,SIMMVAL |
| 2066 | 2317 | UML_MOV(block, IREG(1), FPR32(RTREG)); // mov i1,<cpr1_rt> |
| 2067 | UML_CALLH(block, mips3.write32); | |
| 2318 | UML_CALLH(block, mips3.write32[mips3.cstate->mode >> 1]); | |
| 2068 | 2319 | if (!in_delay_slot) |
| 2069 | generate_update_cycles(block, compiler, desc->pc + 4 | |
| 2320 | generate_update_cycles(block, compiler, IMM(desc->pc + 4) | |
| 2070 | 2321 | return TRUE; |
| 2071 | 2322 | |
| 2072 | 2323 | case 0x3d: /* SDC1 - MIPS III */ |
| 2073 | 2324 | UML_ADD(block, IREG(0), R32(RSREG), IMM(SIMMVAL)); // add i0,<rsreg>,SIMMVAL |
| 2074 | 2325 | UML_DMOV(block, IREG(1), FPR64(RTREG)); // dmov i1,<cpr1_rt> |
| 2075 | UML_CALLH(block, mips3.write64); | |
| 2326 | UML_CALLH(block, mips3.write64[mips3.cstate->mode >> 1]); | |
| 2076 | 2327 | if (!in_delay_slot) |
| 2077 | generate_update_cycles(block, compiler, desc->pc + 4 | |
| 2328 | generate_update_cycles(block, compiler, IMM(desc->pc + 4) | |
| 2078 | 2329 | return TRUE; |
| 2079 | 2330 | |
| 2080 | 2331 | case 0x3a: /* SWC2 - MIPS I */ |
| 2081 | 2332 | UML_ADD(block, IREG(0), R32(RSREG), IMM(SIMMVAL)); // add i0,<rsreg>,SIMMVAL |
| 2082 | 2333 | UML_MOV(block, IREG(1), CPR232(RTREG)); // mov i1,<cpr2_rt> |
| 2083 | UML_CALLH(block, mips3.write32); | |
| 2334 | UML_CALLH(block, mips3.write32[mips3.cstate->mode >> 1]); | |
| 2084 | 2335 | if (!in_delay_slot) |
| 2085 | generate_update_cycles(block, compiler, desc->pc + 4 | |
| 2336 | generate_update_cycles(block, compiler, IMM(desc->pc + 4) | |
| 2086 | 2337 | return TRUE; |
| 2087 | 2338 | |
| 2088 | 2339 | case 0x3e: /* SDC2 - MIPS II */ |
| 2089 | 2340 | UML_ADD(block, IREG(0), R32(RSREG), IMM(SIMMVAL)); // add i0,<rsreg>,SIMMVAL |
| 2090 | 2341 | UML_DMOV(block, IREG(1), CPR264(RTREG)); // dmov i1,<cpr2_rt> |
| 2091 | UML_CALLH(block, mips3.write64); | |
| 2342 | UML_CALLH(block, mips3.write64[mips3.cstate->mode >> 1]); | |
| 2092 | 2343 | if (!in_delay_slot) |
| 2093 | generate_update_cycles(block, compiler, desc->pc + 4 | |
| 2344 | generate_update_cycles(block, compiler, IMM(desc->pc + 4) | |
| 2094 | 2345 | return TRUE; |
| 2095 | 2346 | |
| 2096 | 2347 | |
| r2724 | r2725 | |
| 2604 | 2855 | |
| 2605 | 2856 | static int generate_idt(drcuml_block *block, compiler_state *compiler, const opcode_desc *desc) |
| 2606 | 2857 | { |
| 2607 | fatalerror("Unimplemented IDT instructions"); | |
| 2608 | #if 0 | |
| 2609 | 2858 | UINT32 op = *desc->opptr.l; |
| 2610 | 2859 | UINT8 opswitch = op & 0x1f; |
| 2611 | 2860 | |
| 2861 | /* only enabled on IDT processors */ | |
| 2862 | if (mips3.core->flavor != MIPS3_TYPE_R4650) | |
| 2863 | return FALSE; | |
| 2864 | ||
| 2612 | 2865 | switch (opswitch) |
| 2613 | 2866 | { |
| 2614 | 2867 | case 0: /* MAD */ |
| 2615 | 2868 | if (RSREG != 0 && RTREG != 0) |
| 2616 | 2869 | { |
| 2617 | emit_mov_r32_m32(REG_EAX, REGADDR(RSREG)); // mov eax,[rsreg] | |
| 2618 | emit_mov_r32_m32(REG_EDX, REGADDR(RTREG)); // mov edx,[rtreg] | |
| 2619 | emit_imul_r32(DRCTOP, REG_EDX); // imul edx | |
| 2620 | emit_add_r32_m32(DRCTOP, LOADDR); // add eax,[lo] | |
| 2621 | emit_adc_r32_m32(DRCTOP, HIADDR); // adc edx,[hi] | |
| 2622 | emit_mov_r32_r32(DRCTOP, REG_EBX, REG_EDX); // mov ebx,edx | |
| 2623 | emit_cdq(DRCTOP); // cdq | |
| 2624 | emit_mov_m64_r64(DRCTOP, LOADDR, REG_EAX); // mov [lo],edx:eax | |
| 2625 | emit_mov_r32_r32(DRCTOP, REG_EAX, REG_EBX); // mov eax,ebx | |
| 2626 | emit_cdq(DRCTOP); // cdq | |
| 2627 | emit_mov_m64_r64(DRCTOP, HIADDR, REG_EAX); // mov [hi],edx:eax | |
| 2870 | UML_MULS(block, IREG(0), IREG(1), R32(RSREG), R32(RTREG)); // muls i0,i1,rsreg,rtreg | |
| 2871 | UML_ADDf(block, FLAGS_C, IREG(0), IREG(0), LO32); // add i0,i0,lo | |
| 2872 | UML_ADDC(block, IREG(1), IREG(1), HI32); // addc i1,i1,hi | |
| 2873 | UML_DSEXT4(block, LO64, IREG(0)); // dsext4 lo,i0 | |
| 2874 | UML_DSEXT4(block, HI64, IREG(1)); // dsext4 hi,i0 | |
| 2628 | 2875 | } |
| 2629 | return | |
| 2876 | return TR | |
| 2630 | 2877 | |
| 2631 | 2878 | case 1: /* MADU */ |
| 2632 | 2879 | if (RSREG != 0 && RTREG != 0) |
| 2633 | 2880 | { |
| 2634 | emit_mov_r32_m32(REG_EAX, REGADDR(RSREG)); // mov eax,[rsreg] | |
| 2635 | emit_mov_r32_m32(REG_EDX, REGADDR(RTREG)); // mov edx,[rtreg] | |
| 2636 | emit_mul_r32(DRCTOP, REG_EDX); // mul edx | |
| 2637 | emit_add_r32_m32(DRCTOP, LOADDR); // add eax,[lo] | |
| 2638 | emit_adc_r32_m32(DRCTOP, HIADDR); // adc edx,[hi] | |
| 2639 | emit_mov_r32_r32(DRCTOP, REG_EBX, REG_EDX); // mov ebx,edx | |
| 2640 | emit_cdq(DRCTOP); // cdq | |
| 2641 | emit_mov_m64_r64(DRCTOP, LOADDR, REG_EDX, REG_EAX); // mov [lo],edx:eax | |
| 2642 | emit_mov_r32_r32(DRCTOP, REG_EAX, REG_EBX); // mov eax,ebx | |
| 2643 | emit_cdq(DRCTOP); // cdq | |
| 2644 | emit_mov_m64_r64(DRCTOP, HIADDR, REG_EDX, REG_EAX); // mov [hi],edx:eax | |
| 2881 | UML_MULU(block, IREG(0), IREG(1), R32(RSREG), R32(RTREG)); // mulu i0,i1,rsreg,rtreg | |
| 2882 | UML_ADDf(block, FLAGS_C, IREG(0), IREG(0), LO32); // add i0,i0,lo | |
| 2883 | UML_ADDC(block, IREG(1), IREG(1), HI32); // addc i1,i1,hi | |
| 2884 | UML_DSEXT4(block, LO64, IREG(0)); // dsext4 lo,i0 | |
| 2885 | UML_DSEXT4(block, HI64, IREG(1)); // dsext4 hi,i0 | |
| 2645 | 2886 | } |
| 2646 | return | |
| 2887 | return TR | |
| 2647 | 2888 | |
| 2648 | 2889 | case 2: /* MUL */ |
| 2649 | 2890 | if (RDREG != 0) |
| 2650 | 2891 | { |
| 2651 | if (RSREG != 0 && RTREG != 0) | |
| 2652 | { | |
| 2653 | emit_mov_r32_m32(REG_EAX, REGADDR(RSREG)); // mov eax,[rsreg] | |
| 2654 | emit_imul_r32_m32(REG_EAX, REGADDR(RTREG)); // imul eax,[rtreg] | |
| 2655 | emit_cdq(DRCTOP); // cdq | |
| 2656 | emit_mov_m64_r64(REG_ESI, REGADDR(RDREG), REG_EDX, REG_EAX); // mov [rd],edx:eax | |
| 2657 | } | |
| 2658 | else | |
| 2659 | emit_zero_m64(REG_ESI, REGADDR(RDREG)); | |
| 2892 | UML_MULS(block, IREG(0), IREG(0), R32(RSREG), R32(RTREG)); // muls i0,i0,rsreg,rtreg | |
| 2893 | UML_DSEXT4(block, R64(RDREG), IREG(0)); // dsext4 rdreg,i0 | |
| 2660 | 2894 | } |
| 2661 | return | |
| 2895 | return TR | |
| 2662 | 2896 | } |
| 2663 | #endif | |
| 2664 | 2897 | return FALSE; |
| 2665 | 2898 | } |
| 2666 | 2899 | |
| r2724 | r2725 | |
| 2678 | 2911 | switch (reg) |
| 2679 | 2912 | { |
| 2680 | 2913 | case COP0_Cause: |
| 2681 | UML_AND(block, IREG(0), IREG(0), IMM(~0xfc00)); // and i0,i0,~0xfc00 | |
| 2682 | UML_AND(block, IREG(1), CPR032(COP0_Cause), IMM(0xfc00)); // and i1,[Cause],0xfc00 | |
| 2683 | UML_OR(block, CPR032(COP0_Cause), IREG(0), IREG(1)); // or [Cause],i0,i1 | |
| 2914 | UML_INSERT(block, CPR032(COP0_Cause), IREG(0), IMM(0), IMM(~0xfc00)); // insert [Cause],i0,0,~0xfc00 | |
| 2684 | 2915 | compiler->checksoftints = TRUE; |
| 2685 | 2916 | if (!in_delay_slot) |
| 2686 | generate_update_cycles(block, compiler, desc->pc + 4 | |
| 2917 | generate_update_cycles(block, compiler, IMM(desc->pc + 4) | |
| 2687 | 2918 | return TRUE; |
| 2688 | 2919 | |
| 2689 | 2920 | case COP0_Status: |
| 2690 | generate_update_cycles(block, compiler, desc->pc, | |
| 2921 | generate_update_cycles(block, compiler, IMM(desc->pc), | |
| 2691 | 2922 | UML_MOV(block, IREG(1), CPR032(COP0_Status)); // mov i1,[Status] |
| 2692 | 2923 | UML_MOV(block, CPR032(COP0_Status), IREG(0)); // mov [Status],i0 |
| 2693 | UML_SHR(block, IREG(2), IREG(1), IMM(26)); // shr i2,i1,26 | |
| 2694 | UML_AND(block, MEM(&mips3.cstate->mode), IREG(2), IMM(1)); // and [mode],i2,1 | |
| 2924 | generate_update_mode(block); | |
| 2695 | 2925 | UML_XOR(block, IREG(0), IREG(0), IREG(1)); // xor i0,i0,i1 |
| 2696 | 2926 | UML_TEST(block, IREG(0), IMM(0x8000)); // test i0,0x8000 |
| 2697 | 2927 | UML_CALLCc(block, IF_NZ, mips3com_update_cycle_counting, mips3.core); // callc mips3com_update_cycle_counting,mips.core,NZ |
| 2698 | 2928 | compiler->checkints = TRUE; |
| 2699 | 2929 | if (!in_delay_slot) |
| 2700 | generate_update_cycles(block, compiler, desc->pc + 4 | |
| 2930 | generate_update_cycles(block, compiler, IMM(desc->pc + 4) | |
| 2701 | 2931 | return TRUE; |
| 2702 | 2932 | |
| 2703 | 2933 | case COP0_Count: |
| 2704 | generate_update_cycles(block, compiler, desc->pc, | |
| 2934 | generate_update_cycles(block, compiler, IMM(desc->pc), | |
| 2705 | 2935 | UML_MOV(block, CPR032(COP0_Count), IREG(0)); // mov [Count],i0 |
| 2706 | 2936 | UML_CALLC(block, cfunc_get_cycles, &mips3.cstate->numcycles); // callc cfunc_get_cycles,&mips3.numcycles |
| 2707 | 2937 | UML_DZEXT4(block, IREG(0), IREG(0)); // dzext4 i0,i0 |
| r2724 | r2725 | |
| 2712 | 2942 | return TRUE; |
| 2713 | 2943 | |
| 2714 | 2944 | case COP0_Compare: |
| 2715 | generate_update_cycles(block, compiler, desc->pc, | |
| 2945 | generate_update_cycles(block, compiler, IMM(desc->pc), | |
| 2716 | 2946 | UML_MOV(block, CPR032(COP0_Compare), IREG(0)); // mov [Compare],i0 |
| 2717 | UML_AND(block, CPR032(COP0_Cause), CPR032(COP0_Cause), IMM(~0x8000)); // and [Cause],[Cause],~0x8000 | |
| 2947 | UML_AND(block, CPR032(COP0_Cause), CPR032(COP0_Cause), IMM(~0x8000)); // and [Cause],[Cause],~0x8000 | |
| 2718 | 2948 | UML_CALLC(block, mips3com_update_cycle_counting, mips3.core); // callc mips3com_update_cycle_counting,mips.core |
| 2719 | 2949 | return TRUE; |
| 2720 | 2950 | |
| r2724 | r2725 | |
| 2722 | 2952 | return TRUE; |
| 2723 | 2953 | |
| 2724 | 2954 | case COP0_Config: |
| 2725 | UML_AND(block, IREG(0), IREG(0), IMM(0x0007)); // and i0,i0,0x0007 | |
| 2726 | UML_AND(block, IREG(1), CPR032(COP0_Config), IMM(~0x0007)); // and i1,[Config],~0x0007 | |
| 2727 | UML_OR(block, CPR032(COP0_Config), IREG(0), IREG(1)); // or [Config],i0,i1 | |
| 2955 | UML_INSERT(block, CPR032(COP0_Config), IREG(0), IMM(0), IMM(0x0007)); // insert [Config],i0,0,0x0007 | |
| 2728 | 2956 | return TRUE; |
| 2729 | 2957 | |
| 2730 | 2958 | case COP0_EntryHi: |
| r2724 | r2725 | |
| 2756 | 2984 | switch (reg) |
| 2757 | 2985 | { |
| 2758 | 2986 | case COP0_Count: |
| 2759 | generate_update_cycles(block, compiler, desc->pc | |
| 2987 | generate_update_cycles(block, compiler, IMM(desc->pc) | |
| 2760 | 2988 | UML_CALLC(block, cfunc_get_cycles, &mips3.cstate->numcycles); // callc cfunc_get_cycles,&mips3.numcycles |
| 2761 | 2989 | UML_DSUB(block, IREG(0), MEM(&mips3.cstate->numcycles), MEM(&mips3.core->count_zero_time)); |
| 2762 | 2990 | // dsub i0,[numcycles],[count_zero_time] |
| r2724 | r2725 | |
| 2765 | 2993 | return TRUE; |
| 2766 | 2994 | |
| 2767 | 2995 | case COP0_Random: |
| 2768 | generate_update_cycles(block, compiler, desc->pc | |
| 2996 | generate_update_cycles(block, compiler, IMM(desc->pc) | |
| 2769 | 2997 | UML_CALLC(block, cfunc_get_cycles, &mips3.cstate->numcycles); // callc cfunc_get_cycles,&mips3.numcycles |
| 2770 | 2998 | UML_DSUB(block, IREG(0), MEM(&mips3.cstate->numcycles), MEM(&mips3.core->count_zero_time)); |
| 2771 | 2999 | // dsub i0,[numcycles],[count_zero_time] |
| r2724 | r2725 | |
| 2797 | 3025 | { |
| 2798 | 3026 | UINT32 op = *desc->opptr.l; |
| 2799 | 3027 | UINT8 opswitch = RSREG; |
| 3028 | drcuml_codelabel okay; | |
| 3029 | int skip; | |
| 2800 | 3030 | |
| 2801 | 3031 | /* generate an exception if COP0 is disabled or we are not in kernel mode */ |
| 2802 | if (mips3.drcoptions & MIPS3DRC_STRICT_COP0) | |
| 2803 | { | |
| 2804 | drcuml_codelabel okay; | |
| 3032 | UML_TEST(block, CPR032(COP0_Status), IMM(SR_KSU_MASK)); // test [Status],SR_KSU_MASK | |
| 3033 | UML_JMPc(block, IF_Z, okay = compiler->labelnum++); // jmp okay,Z | |
| 3034 | UML_TEST(block, CPR032(COP0_Status), IMM(SR_COP0)); // test [Status],SR_COP0 | |
| 3035 | UML_EXHc(block, IF_Z, mips3.exception[EXCEPTION_BADCOP], IMM(0)); // exh cop,0,Z | |
| 3036 | UML_LABEL(block, okay); // okay: | |
| 2805 | 3037 | |
| 2806 | UML_TEST(block, CPR032(COP0_Status), IMM(SR_KSU_MASK)); // test [Status],SR_KSU_MASK | |
| 2807 | UML_JMPc(block, IF_Z, okay = compiler->labelnum++); // jmp okay,Z | |
| 2808 | UML_TEST(block, CPR032(COP0_Status), IMM(SR_COP0)); // test [Status],SR_COP0 | |
| 2809 | UML_EXHc(block, IF_Z, mips3.exception[EXCEPTION_BADCOP], IMM(0)); // exh cop,0,Z | |
| 2810 | UML_LABEL(block, okay); // okay: | |
| 2811 | } | |
| 2812 | ||
| 2813 | 3038 | switch (opswitch) |
| 2814 | 3039 | { |
| 2815 | 3040 | case 0x00: /* MFCz */ |
| r2724 | r2725 | |
| 2830 | 3055 | |
| 2831 | 3056 | case 0x02: /* CFCz */ |
| 2832 | 3057 | if (RTREG != 0) |
| 2833 | UML_DSEXT4(block, R | |
| 3058 | UML_DSEXT4(block, R64(RTREG), CCR032(RDREG)); // dsext4 <rtreg>,ccr0[rdreg] | |
| 2834 | 3059 | return TRUE; |
| 2835 | 3060 | |
| 2836 | 3061 | case 0x04: /* MTCz */ |
| r2724 | r2725 | |
| 2882 | 3107 | return TRUE; |
| 2883 | 3108 | |
| 2884 | 3109 | case 0x18: /* ERET */ |
| 2885 | UML_AND(block, CPR032(COP0_Status), CPR032(COP0_Status), IMM(~SR_EXL)); | |
| 2886 | // and [Status],[Status],~SR_EXL | |
| 3110 | UML_MOV(block, IREG(0), CPR032(COP0_Status)); // mov i0,[Status] | |
| 3111 | UML_TEST(block, IREG(0), IMM(SR_ERL)); // test i0,SR_ERL | |
| 3112 | UML_JMPc(block, IF_NZ, skip = compiler->labelnum++); // jmp skip,nz | |
| 3113 | UML_AND(block, IREG(0), IREG(0), IMM(~SR_EXL)); // and i0,i0,~SR_EXL | |
| 3114 | UML_MOV(block, CPR032(COP0_Status), IREG(0)); // mov [Status],i0 | |
| 3115 | generate_update_mode(block); | |
| 2887 | 3116 | compiler->checkints = TRUE; |
| 2888 | generate_update_cycles(block, compiler, 0, LOPTR(&mips3.core->cpr[0][COP0_EPC]), TRUE); | |
| 3117 | generate_update_cycles(block, compiler, CPR032(COP0_EPC), TRUE);// <subtract cycles> | |
| 3118 | UML_HASHJMP(block, MEM(&mips3.cstate->mode), CPR032(COP0_EPC), mips3.nocode); | |
| 3119 | // hashjmp <mode>,[EPC],nocode | |
| 3120 | UML_LABEL(block, skip); // skip: | |
| 3121 | UML_AND(block, IREG(0), IREG(0), IMM(~SR_ERL)); // and i0,i0,~SR_ERL | |
| 3122 | UML_MOV(block, CPR032(COP0_Status), IREG(0)); // mov [Status],i0 | |
| 3123 | generate_update_mode(block); | |
| 3124 | compiler->checkints = TRUE; | |
| 3125 | generate_update_cycles(block, compiler, CPR032(COP0_ErrorPC), TRUE); | |
| 2889 | 3126 | // <subtract cycles> |
| 2890 | UML_HASHJMP(block, | |
| 3127 | UML_HASHJMP(block, | |
| 2891 | 3128 | // hashjmp <mode>,[EPC],nocode |
| 2892 | 3129 | return TRUE; |
| 2893 | 3130 | |
| r2724 | r2725 | |
| 3282 | 3519 | { |
| 3283 | 3520 | case 0x00: /* LWXC1 - MIPS IV */ |
| 3284 | 3521 | UML_ADD(block, IREG(0), R32(RSREG), R32(RTREG)); // add i0,<rsreg>,<rtreg> |
| 3285 | UML_CALLH(block, mips3.read32); | |
| 3522 | UML_CALLH(block, mips3.read32[mips3.cstate->mode >> 1]); | |
| 3286 | 3523 | UML_MOV(block, FPR32(RDREG), IREG(0)); // mov <cpr1_rd>,i0 |
| 3287 | 3524 | if (!in_delay_slot) |
| 3288 | generate_update_cycles(block, compiler, desc->pc + 4 | |
| 3525 | generate_update_cycles(block, compiler, IMM(desc->pc + 4) | |
| 3289 | 3526 | return TRUE; |
| 3290 | 3527 | |
| 3291 | 3528 | case 0x01: /* LDXC1 - MIPS IV */ |
| 3292 | 3529 | UML_ADD(block, IREG(0), R32(RSREG), R32(RTREG)); // add i0,<rsreg>,<rtreg> |
| 3293 | UML_CALLH(block, mips3.read64); | |
| 3530 | UML_CALLH(block, mips3.read64[mips3.cstate->mode >> 1]); | |
| 3294 | 3531 | UML_DMOV(block, FPR64(RDREG), IREG(0)); // dmov <cpr1_rd>,i0 |
| 3295 | 3532 | if (!in_delay_slot) |
| 3296 | generate_update_cycles(block, compiler, desc->pc + 4 | |
| 3533 | generate_update_cycles(block, compiler, IMM(desc->pc + 4) | |
| 3297 | 3534 | return TRUE; |
| 3298 | 3535 | |
| 3299 | 3536 | case 0x08: /* SWXC1 - MIPS IV */ |
| 3300 | 3537 | UML_ADD(block, IREG(0), R32(RSREG), R32(RTREG)); // add i0,<rsreg>,<rtreg> |
| 3301 | 3538 | UML_MOV(block, IREG(1), FPR32(RTREG)); // mov i1,<cpr1_rt> |
| 3302 | UML_CALLH(block, mips3.write32); | |
| 3539 | UML_CALLH(block, mips3.write32[mips3.cstate->mode >> 1]); | |
| 3303 | 3540 | if (!in_delay_slot) |
| 3304 | generate_update_cycles(block, compiler, desc->pc + 4 | |
| 3541 | generate_update_cycles(block, compiler, IMM(desc->pc + 4) | |
| 3305 | 3542 | return TRUE; |
| 3306 | 3543 | |
| 3307 | 3544 | case 0x09: /* SDXC1 - MIPS IV */ |
| 3308 | 3545 | UML_ADD(block, IREG(0), R32(RSREG), R32(RTREG)); // add i0,<rsreg>,<rtreg> |
| 3309 | 3546 | UML_DMOV(block, IREG(1), FPR64(RTREG)); // dmov i1,<cpr1_rt> |
| 3310 | UML_CALLH(block, mips3.write64); | |
| 3547 | UML_CALLH(block, mips3.write64[mips3.cstate->mode >> 1]); | |
| 3311 | 3548 | if (!in_delay_slot) |
| 3312 | generate_update_cycles(block, compiler, desc->pc + 4 | |
| 3549 | generate_update_cycles(block, compiler, IMM(desc->pc + 4) | |
| 3313 | 3550 | return TRUE; |
| 3314 | 3551 | |
| 3315 | 3552 | case 0x0f: /* PREFX */ |
| r2724 | r2725 | |
| 3489 | 3726 | char buffer[100]; |
| 3490 | 3727 | |
| 3491 | 3728 | /* disassemle the current instruction and output it to the log */ |
| 3492 | #if LOG_UML | |
| 3493 | dasmmips3(buffer, desclist->pc, *desclist->opptr.l); | |
| 3729 | #if (LOG_UML || LOG_NATIVE) | |
| 3730 | if (desclist->flags & OPFLAG_VIRTUAL_NOOP) | |
| 3731 | strcpy(buffer, "<virtual nop>"); | |
| 3732 | else | |
| 3733 | dasmmips3(buffer, desclist->pc, *desclist->opptr.l); | |
| 3494 | 3734 | #else |
| 3495 | 3735 | strcpy(buffer, "???"); |
| 3496 | 3736 | #endif |
| r2724 | r2725 | |
| 3904 | 4144 | DISASSEMBLERS |
| 3905 | 4145 | ***************************************************************************/ |
| 3906 | 4146 | |
| 3907 | #if !defined(MAME_DEBUG) && (LOG_UML) | |
| 4147 | #if !defined(MAME_DEBUG) && (LOG_UML || LOG_NATIVE) | |
| 3908 | 4148 | #include "mips3dsm.c" |
| 3909 | 4149 | #endif |
| 3910 | 4150 |
| r2724 | r2725 | |
|---|---|---|
| 82 | 82 | |
| 83 | 83 | size_t mips3com_init(mips3_state *mips, mips3_flavor flavor, int bigendian, int index, int clock, const struct mips3_config *config, int (*irqcallback)(int), void *memory) |
| 84 | 84 | { |
| 85 | int tlbindex; | |
| 86 | ||
| 85 | 87 | /* if no memory, return the amount needed */ |
| 86 | 88 | if (memory == NULL) |
| 87 | 89 | return config->icache + config->dcache + (sizeof(mips->tlb_table[0]) * (1 << (MIPS3_MAX_PADDR_SHIFT - MIPS3_MIN_PAGE_SHIFT))); |
| 88 | 90 | |
| 89 | /* initialize | |
| 91 | /* initialize based on th | |
| 90 | 92 | memset(mips, 0, sizeof(*mips)); |
| 91 | ||
| 92 | /* initialize based on the config */ | |
| 93 | 93 | mips->flavor = flavor; |
| 94 | 94 | mips->bigendian = bigendian; |
| 95 | 95 | mips->cpu_clock = clock; |
| r2724 | r2725 | |
| 109 | 109 | mips->dcache = (void *)((UINT8 *)memory + config->icache); |
| 110 | 110 | mips->tlb_table = (void *)((UINT8 *)memory + config->dcache); |
| 111 | 111 | |
| 112 | /* initialize the TLB state */ | |
| 113 | for (tlbindex = 0; tlbindex < ARRAY_LENGTH(mips->tlb); tlbindex++) | |
| 114 | { | |
| 115 | mips3_tlb_entry *tlbent = &mips->tlb[tlbindex]; | |
| 116 | tlbent->page_mask = 0; | |
| 117 | tlbent->entry_hi = 0xffffffff; | |
| 118 | tlbent->entry_lo[0] = 0xfffffff8; | |
| 119 | tlbent->entry_lo[1] = 0xfffffff8; | |
| 120 | } | |
| 121 | ||
| 112 | 122 | /* allocate a timer for the compare interrupt */ |
| 113 | 123 | mips->compare_int_timer = timer_alloc(compare_int_callback, NULL); |
| 114 | 124 | |
| r2724 | r2725 | |
| 128 | 138 | /* initialize the state */ |
| 129 | 139 | mips->pc = 0xbfc00000; |
| 130 | 140 | mips->cpr[0][COP0_Status] = SR_BEV | SR_ERL; |
| 141 | mips->cpr[0][COP0_Wired] = 0; | |
| 131 | 142 | mips->cpr[0][COP0_Compare] = 0xffffffff; |
| 132 | 143 | mips->cpr[0][COP0_Count] = 0; |
| 133 | 144 | mips->cpr[0][COP0_Config] = compute_config_register(mips); |
| r2724 | r2725 | |
| 202 | 213 | { |
| 203 | 214 | mips3_tlb_entry *tlbent = &mips->tlb[index]; |
| 204 | 215 | |
| 205 | /* only process if global or if the ASID matches */ | |
| 206 | if ((tlbent->entry_hi & 0x1000) || valid_asid == (tlbent->entry_hi & 0xff)) | |
| 216 | /* only process if the ASID matches or if global */ | |
| 217 | if (valid_asid == (tlbent->entry_hi & 0xff) || ((tlbent->entry_lo[0] & tlbent->entry_lo[1]) & TLB_GLOBAL)) | |
| 207 | 218 | { |
| 208 | 219 | UINT32 count = (tlbent->page_mask >> 13) & 0x00fff; |
| 209 | 220 | UINT32 vpn = ((tlbent->entry_hi >> 13) & 0x07ffffff) << 1; |
| r2724 | r2725 | |
| 216 | 227 | for (which = 0; which < 2; which++) |
| 217 | 228 | { |
| 218 | 229 | UINT64 lo = tlbent->entry_lo[which]; |
| 230 | UINT32 pfn = (lo >> 6) & 0x00ffffff; | |
| 231 | UINT32 wp = (lo & 7) | TLB_PRESENT; | |
| 219 | 232 | |
| 220 | /* only map if the TLB entry is valid */ | |
| 221 | if (lo & 2) | |
| 222 | { | |
| 223 | UINT32 pfn = (lo >> 6) & 0x00ffffff; | |
| 224 | UINT32 wp = (~lo >> 2) & 1; | |
| 233 | /* ensure that if the valid bit is clear, the dirty bit is as well */ | |
| 234 | /* this way we can always test dirty for writes, and valid for reads */ | |
| 235 | if (!(wp & TLB_VALID)) | |
| 236 | wp &= ~TLB_DIRTY; | |
| 225 | 237 | |
| 226 | for (i = 0; i <= count; i++, vpn++, pfn++) | |
| 227 | if (vpn < 0x80000 || vpn >= 0xc0000) | |
| 228 | mips->tlb_table[vpn] = (pfn << MIPS3_MIN_PAGE_SHIFT) | wp; | |
| 229 | } | |
| 230 | ||
| 231 | /* otherwise, advance by the number of pages we would have mapped */ | |
| 232 | else | |
| 233 | vpn += count + 1; | |
| 238 | for (i = 0; i <= count; i++, vpn++, pfn++) | |
| 239 | if (vpn < 0x80000 || vpn >= 0xc0000) | |
| 240 | mips->tlb_table[vpn] = (pfn << MIPS3_MIN_PAGE_SHIFT) | wp; | |
| 234 | 241 | } |
| 235 | 242 | } |
| 236 | 243 | } |
| r2724 | r2725 | |
| 261 | 268 | for (which = 0; which < 2; which++) |
| 262 | 269 | for (i = 0; i <= count; i++, vpn++) |
| 263 | 270 | if (vpn < 0x80000 || vpn >= 0xc0000) |
| 264 | mips->tlb_table[vpn] = 0 | |
| 271 | mips->tlb_table[vpn] = 0 | |
| 265 | 272 | } |
| 266 | 273 | } |
| 267 | 274 | |
| r2724 | r2725 | |
| 277 | 284 | |
| 278 | 285 | /* map in the hard-coded spaces */ |
| 279 | 286 | for (addr = 0x80000000; addr < 0xc0000000; addr += MIPS3_MIN_PAGE_SIZE) |
| 280 | mips->tlb_table[addr >> MIPS3_MIN_PAGE_SHIFT] = addr & 0x1ffff000; | |
| 287 | mips->tlb_table[addr >> MIPS3_MIN_PAGE_SHIFT] = (addr & 0x1ffff000) | TLB_PRESENT | TLB_DIRTY | TLB_VALID | TLB_GLOBAL; | |
| 281 | 288 | |
| 282 | 289 | /* reset everything else to unmapped */ |
| 283 | memset(&mips->tlb_table[0x00000000 >> MIPS3_MIN_PAGE_SHIFT], 0xff, sizeof(mips->tlb_table[0]) * (0x80000000 >> MIPS3_MIN_PAGE_SHIFT)); | |
| 284 | memset(&mips->tlb_table[0xc0000000 >> MIPS3_MIN_PAGE_SHIFT], 0xff, sizeof(mips->tlb_table[0]) * (0x40000000 >> MIPS3_MIN_PAGE_SHIFT)); | |
| 290 | memset(&mips->tlb_table[0x00000000 >> MIPS3_MIN_PAGE_SHIFT], 0, sizeof(mips->tlb_table[0]) * (0x80000000 >> MIPS3_MIN_PAGE_SHIFT)); | |
| 291 | memset(&mips->tlb_table[0xc0000000 >> MIPS3_MIN_PAGE_SHIFT], 0, sizeof(mips->tlb_table[0]) * (0x40000000 >> MIPS3_MIN_PAGE_SHIFT)); | |
| 285 | 292 | |
| 286 | 293 | /* remap all the entries in the TLB */ |
| 287 | 294 | mips3com_map_tlb_entries(mips); |
| r2724 | r2725 | |
| 299 | 306 | if (space == ADDRESS_SPACE_PROGRAM) |
| 300 | 307 | { |
| 301 | 308 | UINT32 result = mips->tlb_table[*address >> MIPS3_MIN_PAGE_SHIFT]; |
| 302 | if (result | |
| 309 | if (!(result & | |
| 303 | 310 | return FALSE; |
| 304 | 311 | *address = (result & ~MIPS3_MIN_PAGE_MASK) | (*address & MIPS3_MIN_PAGE_MASK); |
| 305 | 312 | } |
| r2724 | r2725 | |
| 378 | 385 | if ((tlbent->entry_hi & mask) == (mips->cpr[0][COP0_EntryHi] & mask)) |
| 379 | 386 | |
| 380 | 387 | /* and if we are either global or matching the current ASID, then stop */ |
| 381 | if ((tlbent->entry_hi & 0x | |
| 388 | if ((tlbent->entry_hi & 0x | |
| 382 | 389 | break; |
| 383 | 390 | } |
| 384 | 391 | |
| r2724 | r2725 | |
| 386 | 393 | vpn = ((mips->cpr[0][COP0_EntryHi] >> 13) & 0x07ffffff) << 1; |
| 387 | 394 | if (index != ARRAY_LENGTH(mips->tlb)) |
| 388 | 395 | { |
| 389 | /* we can't assert this because the TLB entry may not be valid */ | |
| 390 | /* assert(mips->tlb_table[vpn & 0xfffff] != 0xffffffff); */ | |
| 396 | assert(mips->tlb_table[vpn & 0xfffff] & TLB_PRESENT); | |
| 391 | 397 | mips->cpr[0][COP0_Index] = index; |
| 392 | 398 | } |
| 393 | 399 | else |
| 394 | 400 | { |
| 395 | assert(mips->tlb_table[vpn & 0xfffff] | |
| 401 | assert(!(mips->tlb_table[vpn & 0xfffff] & | |
| 396 | 402 | mips->cpr[0][COP0_Index] = 0x80000000; |
| 397 | 403 | } |
| 398 | 404 | } |
| r2724 | r2725 | |
| 920 | 926 | |
| 921 | 927 | mame_printf_debug("index=%08X pagesize=%08X vaddr=%08X%08X paddr=%08X%08X asid=%02X r=%X c=%X dvg=%c%c%c\n", |
| 922 | 928 | index, pagesize, (UINT32)(vaddr >> 32), (UINT32)vaddr, (UINT32)(paddr >> 32), (UINT32)paddr, |
| 923 | asid, r, c, (lo & 4) ? 'd' : '.', (lo & 2) ? 'v' : '.', ( | |
| 929 | asid, r, c, (lo & 4) ? 'd' : '.', (lo & 2) ? 'v' : '.', (lo & | |
| 924 | 930 | #endif |
| 925 | 931 | } |
| r2724 | r2725 | |
|---|---|---|
| 10 | 10 | ***************************************************************************/ |
| 11 | 11 | |
| 12 | 12 | #include "debugger.h" |
| 13 | #include "deprecat.h" | |
| 14 | 13 | #include "mips3com.h" |
| 15 | 14 | |
| 16 | 15 |
| r2724 | r2725 | |
|---|---|---|
| 14 | 14 | |
| 15 | 15 | |
| 16 | 16 | /*************************************************************************** |
| 17 | DEBUGGING | |
| 18 | ***************************************************************************/ | |
| 19 | ||
| 20 | #define LOG_RECOVER (0) | |
| 21 | ||
| 22 | ||
| 23 | /*************************************************************************** | |
| 17 | 24 | TYPE DEFINITIONS |
| 18 | 25 | ***************************************************************************/ |
| 19 | 26 | |
| r2724 | r2725 | |
| 308 | 315 | /* reset the tailptr and count */ |
| 309 | 316 | drcmap->tailptr = &drcmap->head; |
| 310 | 317 | drcmap->numvalues = 0; |
| 318 | ||
| 319 | /* reset the variable values */ | |
| 320 | memset(drcmap->mapvalue, 0, sizeof(drcmap->mapvalue)); | |
| 311 | 321 | } |
| 312 | 322 | |
| 313 | 323 | |
| r2724 | r2725 | |
| 317 | 327 | |
| 318 | 328 | void drcmap_block_end(drcmap_state *drcmap, drcuml_block *block) |
| 319 | 329 | { |
| 320 | UINT32 curvalue[DRCUML_MAPVAR_END - DRCUML_MAPVAR_M0]; | |
| 321 | UINT8 changed[DRCUML_MAPVAR_END - DRCUML_MAPVAR_M0]; | |
| 330 | UINT32 curvalue[DRCUML_MAPVAR_END - DRCUML_MAPVAR_M0] = { 0 }; | |
| 331 | UINT8 changed[DRCUML_MAPVAR_END - DRCUML_MAPVAR_M0] = { 0 }; | |
| 322 | 332 | drcmap_entry *entry; |
| 323 | 333 | drccodeptr lastptr; |
| 324 | 334 | drccodeptr *top; |
| r2724 | r2725 | |
| 343 | 353 | *dest = (drccodeptr)dest - lastptr; |
| 344 | 354 | dest++; |
| 345 | 355 | |
| 346 | /* reset the current values */ | |
| 347 | memset(curvalue, 0, sizeof(curvalue)); | |
| 348 | memset(changed, 0, sizeof(changed)); | |
| 349 | ||
| 350 | 356 | /* now iterate over entries and store them */ |
| 351 | 357 | for (entry = drcmap->head; entry != NULL; entry = entry->next) |
| 352 | 358 | { |
| r2724 | r2725 | |
| 503 | 509 | /* low 4 bits contain the total number of words of data */ |
| 504 | 510 | data += controlword & 0x0f; |
| 505 | 511 | } |
| 512 | if (LOG_RECOVER) | |
| 513 | printf("recover %d @ %p = %08X\n", mapvar, codebase, result); | |
| 506 | 514 | return result; |
| 507 | 515 | } |
| 508 | 516 |
| r2724 | r2725 | |
|---|---|---|
| 89 | 89 | { DRCUML_OP_SETFMOD, "setfmod", { output_param } }, |
| 90 | 90 | { DRCUML_OP_GETFMOD, "getfmod", { output_param } }, |
| 91 | 91 | { DRCUML_OP_GETEXP, "getexp", { output_param } }, |
| 92 | { DRCUML_OP_SAVE, "save", { output_param } }, | |
| 93 | { DRCUML_OP_RESTORE, "restore", { output_param } }, | |
| 92 | 94 | |
| 93 | 95 | /* Integer Operations */ |
| 94 | 96 | { DRCUML_OP_LOAD1U, "!load1u", { output_param, output_param, output_param } }, |
| r2724 | r2725 | |
| 127 | 129 | { DRCUML_OP_SEXT1, "!sext1", { output_param, output_param } }, |
| 128 | 130 | { DRCUML_OP_SEXT2, "!sext2", { output_param, output_param } }, |
| 129 | 131 | { DRCUML_OP_SEXT4, "!sext4", { output_param, output_param } }, |
| 132 | { DRCUML_OP_XTRACT, "!xtract", { output_param, output_param, output_param, output_param } }, | |
| 133 | { DRCUML_OP_INSERT, "!insert", { output_param, output_param, output_param, output_param } }, | |
| 130 | 134 | { DRCUML_OP_ADD, "!add", { output_param, output_param, output_param, output_flags } }, |
| 131 | 135 | { DRCUML_OP_ADDC, "!addc", { output_param, output_param, output_param, output_flags } }, |
| 132 | 136 | { DRCUML_OP_SUB, "!sub", { output_param, output_param, output_param, output_flags } }, |
| r2724 | r2725 | |
| 140 | 144 | { DRCUML_OP_TEST, "!test", { output_param, output_param, output_flags_cmptest } }, |
| 141 | 145 | { DRCUML_OP_OR, "!or", { output_param, output_param, output_param, output_flags } }, |
| 142 | 146 | { DRCUML_OP_XOR, "!xor", { output_param, output_param, output_param, output_flags } }, |
| 147 | { DRCUML_OP_LZCNT, "!lzcnt", { output_param, output_param } }, | |
| 143 | 148 | { DRCUML_OP_SHL, "!shl", { output_param, output_param, output_param, output_flags } }, |
| 144 | 149 | { DRCUML_OP_SHR, "!shr", { output_param, output_param, output_param, output_flags } }, |
| 145 | 150 | { DRCUML_OP_SAR, "!sar", { output_param, output_param, output_param, output_flags } }, |
| r2724 | r2725 | |
|---|---|---|
| 57 | 57 | }; |
| 58 | 58 | |
| 59 | 59 | |
| 60 | /* an integer register, with low/high parts */ | |
| 61 | typedef union _drcuml_ireg drcuml_ireg; | |
| 62 | union _drcuml_ireg | |
| 63 | { | |
| 64 | #ifdef LSB_FIRST | |
| 65 | UINT32 l,h; /* 32-bit low, high parts of the register */ | |
| 66 | #else | |
| 67 | UINT32 h,l; /* 32-bit low, high parts of the register */ | |
| 68 | #endif | |
| 69 | UINT64 d; /* 64-bit full register */ | |
| 70 | }; | |
| 71 | 60 | |
| 72 | ||
| 73 | /* an floating-point register, with low/high parts */ | |
| 74 | typedef union _drcuml_freg drcuml_freg; | |
| 75 | union _drcuml_freg | |
| 76 | { | |
| 77 | #ifdef LSB_FIRST | |
| 78 | float l,unused; /* 32-bit low, high parts of the register */ | |
| 79 | #else | |
| 80 | float unused,l; /* 32-bit low, high parts of the register */ | |
| 81 | #endif | |
| 82 | double d; /* 64-bit full register */ | |
| 83 | }; | |
| 84 | ||
| 85 | ||
| 86 | /* the collected machine state of a system */ | |
| 87 | typedef struct _drcuml_machine_state drcuml_machine_state; | |
| 88 | struct _drcuml_machine_state | |
| 89 | { | |
| 90 | drcuml_ireg r[DRCUML_REG_I_END - DRCUML_REG_I0]; /* integer registers */ | |
| 91 | drcuml_freg f[DRCUML_REG_F_END - DRCUML_REG_F0]; /* floating-point registers */ | |
| 92 | drcuml_ireg exp; /* exception parameter register */ | |
| 93 | UINT8 fmod; /* fmod (floating-point mode) register */ | |
| 94 | }; | |
| 95 | ||
| 96 | ||
| 97 | ||
| 98 | 61 | /*************************************************************************** |
| 99 | 62 | FUNCTION PROTOTYPES |
| 100 | 63 | ***************************************************************************/ |
| r2724 | r2725 | |
|---|---|---|
| 518 | 518 | #define OP_INVD 0x0f08 |
| 519 | 519 | #define OP_WBINVD 0x0f09 |
| 520 | 520 | #define OP_UD2 0x0f0b |
| 521 | #define OP_NOP0d_Ev 0x0f0d | |
| 521 | 522 | |
| 522 | 523 | #define OP_MOVUPS_Vps_Wps 0x0f10 |
| 523 | 524 | #define OP_MOVSS_Vss_Wss 0xf30f10 |
| r2724 | r2725 | |
| 545 | 546 | #define OP_MOVHPS_Mq_Vq 0x0f17 |
| 546 | 547 | #define OP_MOVHPD_Mq_Vq 0x660f17 |
| 547 | 548 | #define OP_PREFETCH_G16 0x0f18 |
| 549 | #define OP_NOP1f_Ev 0x0f1f | |
| 548 | 550 | |
| 549 | 551 | #define OP_MOV_Rd_Cd 0x0f20 |
| 550 | 552 | #define OP_MOV_Rd_Dd 0x0f21 |
| r2724 | r2725 | |
| 579 | 581 | #define OP_RDPMC 0x0f33 |
| 580 | 582 | #define OP_SYSENTER 0x0f34 |
| 581 | 583 | #define OP_SYSEXIT 0x0f35 |
| 584 | #define OP_GETSEC 0x0f37 | |
| 582 | 585 | |
| 583 | 586 | #define OP_CMOV_O_Gv_Ev 0x0f40 |
| 584 | 587 | #define OP_CMOV_NO_Gv_Ev 0x0f41 |
| r2724 | r2725 | |
| 703 | 706 | #define OP_PCMPEQD_Pq_Qq 0x0f76 |
| 704 | 707 | #define OP_PCMPEQD_Vdq_Wdq 0x660f76 |
| 705 | 708 | #define OP_EMMS 0x0f77 |
| 709 | #define OP_VMREAD_Ed_Gd 0x0f78 | |
| 710 | #define OP_VMWRITE_Gd_Ed 0x0f79 | |
| 706 | 711 | #define OP_HADDPD_Vpd_Wpd 0x660f7c |
| 707 | 712 | #define OP_HADDPS_Vps_Wps 0xf20f7c |
| 708 | 713 | #define OP_HSUBPD_Vpd_Wpd 0x660f7d |
| r2724 | r2725 | |
| 799 | 804 | #define OP_LGS_Mp 0x0fb5 |
| 800 | 805 | #define OP_MOVZX_Gv_Eb (0x0fb6 | OPFLAG_8BITRM) |
| 801 | 806 | #define OP_MOVZX_Gv_Ew 0x0fb7 |
| 807 | #define OP_JMPE 0x0fb8 | |
| 808 | #define OP_POPCNT_Gv_Ev 0xf30fb8 | |
| 802 | 809 | #define OP_G10_INVALID 0x0fb9 |
| 803 | 810 | #define OP_G8_Ev_Ib 0x0fba |
| 804 | 811 | #define OP_BTC_Ev_Gv 0x0fbb |
| r2724 | r2725 | |
| 929 | 936 | #define OP_PADDD_Vdq_Wdq 0x660ffe |
| 930 | 937 | |
| 931 | 938 | |
| 939 | /* triple byte opcodes (0f 38) */ | |
| 940 | #define OP_PSHUFB_Pq_Qq 0x0f3800 | |
| 941 | #define OP_PSHUFB_Vdq_Wdq 0x660f3800 | |
| 942 | #define OP_PHADDW_Pq_Qq 0x0f3801 | |
| 943 | #define OP_PHADDW_Vdq_Wdq 0x660f3801 | |
| 944 | #define OP_PHADDD_Pq_Qq 0x0f3802 | |
| 945 | #define OP_PHADDD_Vdq_Wdq 0x660f3802 | |
| 946 | #define OP_PHADDSW_Pq_Qq 0x0f3803 | |
| 947 | #define OP_PHADDSW_Vdq_Wdq 0x660f3803 | |
| 948 | #define OP_PMADDUBSW_Pq_Qq 0x0f3804 | |
| 949 | #define OP_PMADDUBSW_Vdq_Wdq 0x660f3804 | |
| 950 | #define OP_PHSUBW_Pq_Qq 0x0f3805 | |
| 951 | #define OP_PHSUBW_Vdq_Wdq 0x660f3805 | |
| 952 | #define OP_PHSUBD_Pq_Qq 0x0f3806 | |
| 953 | #define OP_PHSUBD_Vdq_Wdq 0x660f3806 | |
| 954 | #define OP_PHSUBSW_Pq_Qq 0x0f3807 | |
| 955 | #define OP_PHSUBSW_Vdq_Wdq 0x660f3807 | |
| 956 | #define OP_PSIGNB_Pq_Qq 0x0f3808 | |
| 957 | #define OP_PSIGNB_Vdq_Wdq 0x660f3808 | |
| 958 | #define OP_PSIGNW_Pq_Qq 0x0f3809 | |
| 959 | #define OP_PSIGNW_Vdq_Wdq 0x660f3809 | |
| 960 | #define OP_PSIGND_Pq_Qq 0x0f380a | |
| 961 | #define OP_PSIGND_Vdq_Wdq 0x660f380a | |
| 962 | #define OP_PMULHRSW_Pq_Qq 0x0f380b | |
| 963 | #define OP_PMULHRSW_Vdq_Wdq 0x660f380b | |
| 964 | ||
| 965 | #define OP_PBLENDVB_Vdq_Wdq 0x660f3810 | |
| 966 | #define OP_PBLENDVPS_Vdq_Wdq 0x660f3814 | |
| 967 | #define OP_PBLENDVPD_Vdq_Wdq 0x660f3815 | |
| 968 | #define OP_PTEST_Vdq_Wdq 0x660f3817 | |
| 969 | #define OP_PABSB_Pq_Qq 0x0f381c | |
| 970 | #define OP_PABSB_Vdq_Wdq 0x660f381c | |
| 971 | #define OP_PABSW_Pq_Qq 0x0f381d | |
| 972 | #define OP_PABSW_Vdq_Wdq 0x660f381d | |
| 973 | #define OP_PABSD_Pq_Qq 0x0f381e | |
| 974 | #define OP_PABSD_Vdq_Wdq 0x660f381e | |
| 975 | ||
| 976 | #define OP_PMOVSXBW_Vdq_Udq 0x660f3820 | |
| 977 | #define OP_PMOVSXBD_Vdq_Udq 0x660f3821 | |
| 978 | #define OP_PMOVSXBQ_Vdq_Udq 0x660f3822 | |
| 979 | #define OP_PMOVSXWD_Vdq_Udq 0x660f3823 | |
| 980 | #define OP_PMOVSXWQ_Vdq_Udq 0x660f3824 | |
| 981 | #define OP_PMOVSXDQ_Vdq_Udq 0x660f3825 | |
| 982 | #define OP_PMULDQ_Vdq_Udq 0x660f3828 | |
| 983 | #define OP_PCMPEQQ_Vdq_Udq 0x660f3829 | |
| 984 | #define OP_MOVNTDQA_Vdq_Udq 0x660f382a | |
| 985 | #define OP_PACKUSDW_Vdq_Udq 0x660f382b | |
| 986 | ||
| 987 | #define OP_PMOVZXBW_Vdq_Udq 0x660f3830 | |
| 988 | #define OP_PMOVZXBD_Vdq_Udq 0x660f3831 | |
| 989 | #define OP_PMOVZXBQ_Vdq_Udq 0x660f3832 | |
| 990 | #define OP_PMOVZXWD_Vdq_Udq 0x660f3833 | |
| 991 | #define OP_PMOVZXWQ_Vdq_Udq 0x660f3834 | |
| 992 | #define OP_PMOVZXDQ_Vdq_Udq 0x660f3835 | |
| 993 | #define OP_PMINSB_Vdq_Udq 0x660f3838 | |
| 994 | #define OP_PMINSD_Vdq_Udq 0x660f3839 | |
| 995 | #define OP_PMINUW_Vdq_Udq 0x660f383a | |
| 996 | #define OP_PMINUD_Vdq_Udq 0x660f383b | |
| 997 | #define OP_PMAXSB_Vdq_Udq 0x660f383c | |
| 998 | #define OP_PMAXSD_Vdq_Udq 0x660f383d | |
| 999 | #define OP_PMAXUW_Vdq_Udq 0x660f383e | |
| 1000 | #define OP_PMAXUD_Vdq_Udq 0x660f383f | |
| 1001 | ||
| 1002 | #define OP_MULLD_Vdq_Wdq 0x660f3840 | |
| 1003 | #define OP_PHMINPOSUW_Vdq_Wdq 0x660f3841 | |
| 1004 | ||
| 1005 | #define OP_NVEPT_Gd_Mdq 0x660f3880 | |
| 1006 | #define OP_NVVPID_Gd_Mdq 0x660f3881 | |
| 1007 | ||
| 1008 | #define OP_MOVBE_Gv_Mv 0x0f38f0 | |
| 1009 | #define OP_CRC32_Gd_Eb 0xf20f38f0 | |
| 1010 | #define OP_MOVBE_Mv_Gv 0x0f38f1 | |
| 1011 | #define OP_CRC32_Gd_Ev 0xf20f38f1 | |
| 1012 | ||
| 1013 | ||
| 1014 | /* triple byte opcodes (0f 3a) */ | |
| 1015 | #define OP_ROUNDPS_Vdq_Wdq_Ib 0x660f3a08 | |
| 1016 | #define OP_ROUNDPD_Vdq_Wdq_Ib 0x660f3a09 | |
| 1017 | #define OP_ROUNDSS_Vss_Wss_Ib 0x660f3a0a | |
| 1018 | #define OP_ROUNDSD_Vsd_Wsd_Ib 0x660f3a0b | |
| 1019 | #define OP_BLENDPS_Vdq_Wdq_Ib 0x660f3a0c | |
| 1020 | #define OP_BLENDPD_Vdq_Wdq_Ib 0x660f3a0d | |
| 1021 | #define OP_PBLENDW_Vdq_Wdq_Ib 0x660f3a0e | |
| 1022 | #define OP_PALIGNR_Pq_Qq_Ib 0x0f3a0f | |
| 1023 | #define OP_PALIGNR_Vdq_Wdq_Ib 0x660f3a0f | |
| 1024 | ||
| 1025 | #define OP_EXTRB_Rd_Vdq_Ib 0x660f3a14 | |
| 1026 | #define OP_EXTRW_Rd_Vdq_Ib 0x660f3a15 | |
| 1027 | #define OP_EXTRD_Rd_Vdq_Ib 0x660f3a16 | |
| 1028 | #define OP_EXTRACTPS_Ed_Vdq_Ib 0x660f3a17 | |
| 1029 | ||
| 1030 | #define OP_PINSRB_Vdq_Rd_Ib 0x660f3a20 | |
| 1031 | #define OP_INSERTPS_Vdq_Udq_Ib 0x660f3a21 | |
| 1032 | #define OP_PINSRD_Vdq_Ed_Ib 0x660f3a22 | |
| 1033 | ||
| 1034 | #define OP_DPPS_Vdq_Wdq_Ib 0x660f3a40 | |
| 1035 | #define OP_DPPD_Vdq_Wdq_Ib 0x660f3a41 | |
| 1036 | #define OP_MPSADBW_Vdq_Wdq_Ib 0x660f3a42 | |
| 1037 | ||
| 1038 | #define OP_PCMPESTRM_Vdq_Wdq_Ib 0x660f3a60 | |
| 1039 | #define OP_PCMPESTRI_Vdq_Wdq_Ib 0x660f3a61 | |
| 1040 | #define OP_PCMPISTRM_Vdq_Wdq_Ib 0x660f3a62 | |
| 1041 | #define OP_PCMPISTRI_Vdq_Wdq_Ib 0x660f3a63 | |
| 1042 | ||
| 1043 | ||
| 932 | 1044 | /* floating point opcodes */ |
| 933 | 1045 | #define OP_FADD_ST0_STn 0xd8c0 |
| 934 | 1046 | #define OP_FMUL_ST0_STn 0xd8c8 |
| r2724 | r2725 | |
| 1459 | 1571 | INLINE void emit_cmc(x86code **emitptr) { emit_op_simple(emitptr, OP_CMC, OP_32BIT); } |
| 1460 | 1572 | INLINE void emit_pushf(x86code **emitptr) { emit_op_simple(emitptr, OP_PUSHF_Fv, OP_32BIT); } |
| 1461 | 1573 | INLINE void emit_popf(x86code **emitptr) { emit_op_simple(emitptr, OP_POPF_Fv, OP_32BIT); } |
| 1574 | INLINE void emit_cpuid(x86code **emitptr) { emit_op_simple(emitptr, OP_CPUID, OP_32BIT); } | |
| 1462 | 1575 | |
| 1463 | 1576 | #ifndef PTR64 |
| 1464 | 1577 | INLINE void emit_pushad(x86code **emitptr) { emit_op_simple(emitptr, OP_PUSHA, OP_32BIT); } |
| r2724 | r2725 | |
| 2854 | 2967 | INLINE void emit_cvttss2si_r64_m32(x86code **emitptr, UINT8 dreg, DECLARE_MEMPARAMS) { emit_op_modrm_mem(emitptr, OP_CVTTSS2SI_Gd_Wss, OP_64BIT, dreg, MEMPARAMS); } |
| 2855 | 2968 | #endif |
| 2856 | 2969 | |
| 2970 | INLINE void emit_roundss_r128_r128_imm(x86code **emitptr, UINT8 dreg, UINT8 sreg, UINT8 imm) { emit_op_modrm_reg(emitptr, OP_ROUNDSS_Vss_Wss_Ib, OP_32BIT, dreg, sreg); emit_byte(emitptr, imm); } | |
| 2971 | INLINE void emit_roundss_r128_m32_imm(x86code **emitptr, UINT8 dreg, DECLARE_MEMPARAMS, UINT8 imm) { emit_op_modrm_mem(emitptr, OP_ROUNDSS_Vss_Wss_Ib, OP_32BIT, dreg, MEMPARAMS); emit_byte(emitptr, imm); } | |
| 2857 | 2972 | |
| 2858 | 2973 | |
| 2974 | ||
| 2859 | 2975 | /*************************************************************************** |
| 2860 | 2976 | SSE PACKED SINGLE EMITTERS |
| 2861 | 2977 | ***************************************************************************/ |
| r2724 | r2725 | |
| 2909 | 3025 | INLINE void emit_cvttps2dq_r128_r128(x86code **emitptr, UINT8 dreg, UINT8 sreg) { emit_op_modrm_reg(emitptr, OP_CVTTPS2DQ_Vdq_Wps, OP_32BIT, dreg, sreg); } |
| 2910 | 3026 | INLINE void emit_cvttps2dq_r128_m128(x86code **emitptr, UINT8 dreg, DECLARE_MEMPARAMS) { emit_op_modrm_mem(emitptr, OP_CVTTPS2DQ_Vdq_Wps, OP_32BIT, dreg, MEMPARAMS); } |
| 2911 | 3027 | |
| 3028 | INLINE void emit_roundps_r128_r128_imm(x86code **emitptr, UINT8 dreg, UINT8 sreg, UINT8 imm) { emit_op_modrm_reg(emitptr, OP_ROUNDPS_Vdq_Wdq_Ib, OP_32BIT, dreg, sreg); emit_byte(emitptr, imm); } | |
| 3029 | INLINE void emit_roundps_r128_m128_imm(x86code **emitptr, UINT8 dreg, DECLARE_MEMPARAMS, UINT8 imm) { emit_op_modrm_mem(emitptr, OP_ROUNDPS_Vdq_Wdq_Ib, OP_32BIT, dreg, MEMPARAMS); emit_byte(emitptr, imm); } | |
| 2912 | 3030 | |
| 2913 | 3031 | |
| 3032 | ||
| 2914 | 3033 | /*************************************************************************** |
| 2915 | 3034 | SSE SCALAR DOUBLE EMITTERS |
| 2916 | 3035 | ***************************************************************************/ |
| r2724 | r2725 | |
| 2967 | 3086 | INLINE void emit_cvttsd2si_r64_m64(x86code **emitptr, UINT8 dreg, DECLARE_MEMPARAMS) { emit_op_modrm_mem(emitptr, OP_CVTTSD2SI_Gd_Wsd, OP_64BIT, dreg, MEMPARAMS); } |
| 2968 | 3087 | #endif |
| 2969 | 3088 | |
| 3089 | INLINE void emit_roundsd_r128_r128_imm(x86code **emitptr, UINT8 dreg, UINT8 sreg, UINT8 imm) { emit_op_modrm_reg(emitptr, OP_ROUNDSD_Vsd_Wsd_Ib, OP_32BIT, dreg, sreg); emit_byte(emitptr, imm); } | |
| 3090 | INLINE void emit_roundsd_r128_m64_imm(x86code **emitptr, UINT8 dreg, DECLARE_MEMPARAMS, UINT8 imm) { emit_op_modrm_mem(emitptr, OP_ROUNDSD_Vsd_Wsd_Ib, OP_32BIT, dreg, MEMPARAMS); emit_byte(emitptr, imm); } | |
| 2970 | 3091 | |
| 2971 | 3092 | |
| 3093 | ||
| 2972 | 3094 | /*************************************************************************** |
| 2973 | 3095 | SSE PACKED DOUBLE EMITTERS |
| 2974 | 3096 | ***************************************************************************/ |
| r2724 | r2725 | |
| 3016 | 3138 | INLINE void emit_cvttpd2dq_r128_r128(x86code **emitptr, UINT8 dreg, UINT8 sreg) { emit_op_modrm_reg(emitptr, OP_CVTTPD2DQ_Vdq_Wpd, OP_32BIT, dreg, sreg); } |
| 3017 | 3139 | INLINE void emit_cvttpd2dq_r128_m128(x86code **emitptr, UINT8 dreg, DECLARE_MEMPARAMS) { emit_op_modrm_mem(emitptr, OP_CVTTPD2DQ_Vdq_Wpd, OP_32BIT, dreg, MEMPARAMS); } |
| 3018 | 3140 | |
| 3141 | INLINE void emit_roundpd_r128_r128_imm(x86code **emitptr, UINT8 dreg, UINT8 sreg, UINT8 imm) { emit_op_modrm_reg(emitptr, OP_ROUNDPD_Vdq_Wdq_Ib, OP_32BIT, dreg, sreg); emit_byte(emitptr, imm); } | |
| 3142 | INLINE void emit_roundpd_r128_m128_imm(x86code **emitptr, UINT8 dreg, DECLARE_MEMPARAMS, UINT8 imm) { emit_op_modrm_mem(emitptr, OP_ROUNDPD_Vdq_Wdq_Ib, OP_32BIT, dreg, MEMPARAMS); emit_byte(emitptr, imm); } | |
| 3143 | ||
| 3019 | 3144 | #endif |
| r2724 | r2725 | |
|---|---|---|
| 78 | 78 | #include "drcbeut.h" |
| 79 | 79 | #include "debugger.h" |
| 80 | 80 | #include "x86emit.h" |
| 81 | #include "eminline.h" | |
| 81 | 82 | #undef REG_SP |
| 82 | 83 | #include "x86log.h" |
| 83 | 84 | #include <math.h> |
| 85 | #include <stddef.h> | |
| 84 | 86 | |
| 85 | 87 | |
| 86 | 88 | |
| r2724 | r2725 | |
| 155 | 157 | UINT32 * reghi[REG_MAX]; /* pointer to high part of data for each register */ |
| 156 | 158 | double fptemp; /* temporary storage for floating point */ |
| 157 | 159 | |
| 160 | UINT8 sse3; /* do we have SSE3 support? */ | |
| 158 | 161 | UINT16 fpumode; /* saved FPU mode */ |
| 159 | 162 | UINT16 fmodesave; /* temporary location for saving */ |
| 160 | 163 | |
| r2724 | r2725 | |
| 179 | 182 | static int drcbex86_execute(drcbe_state *drcbe, drcuml_codehandle *entry); |
| 180 | 183 | static void drcbex86_generate(drcbe_state *drcbe, drcuml_block *block, const drcuml_instruction *instlist, UINT32 numinst); |
| 181 | 184 | static int drcbex86_hash_exists(drcbe_state *drcbe, UINT32 mode, UINT32 pc); |
| 185 | static void drcbex86_get_info(drcbe_state *state, drcbe_info *info); | |
| 182 | 186 | |
| 183 | 187 | /* private helper functions */ |
| 184 | 188 | static void fixup_label(void *parameter, drccodeptr labelcodeptr); |
| r2724 | r2725 | |
| 203 | 207 | drcbex86_reset, |
| 204 | 208 | drcbex86_execute, |
| 205 | 209 | drcbex86_generate, |
| 206 | drcbex86_hash_exists | |
| 210 | drcbex86_hash_exists, | |
| 211 | drcbex86_get_info | |
| 207 | 212 | }; |
| 208 | 213 | |
| 209 | 214 | /* opcode table */ |
| r2724 | r2725 | |
| 220 | 225 | |
| 221 | 226 | /* flags mapping tables */ |
| 222 | 227 | static UINT8 flags_map[0x1000]; |
| 228 | static UINT32 flags_unmap[0x20]; | |
| 223 | 229 | |
| 224 | 230 | /* condition mapping table */ |
| 225 | 231 | static UINT8 condition_map[DRCUML_COND_MAX - DRCUML_COND_Z] = |
| r2724 | r2725 | |
| 276 | 282 | static x86code *op_setfmod(drcbe_state *drcbe, x86code *dst, const drcuml_instruction *inst); |
| 277 | 283 | static x86code *op_getfmod(drcbe_state *drcbe, x86code *dst, const drcuml_instruction *inst); |
| 278 | 284 | static x86code *op_getexp(drcbe_state *drcbe, x86code *dst, const drcuml_instruction *inst); |
| 285 | static x86code *op_save(drcbe_state *drcbe, x86code *dst, const drcuml_instruction *inst); | |
| 286 | static x86code *op_restore(drcbe_state *drcbe, x86code *dst, const drcuml_instruction *inst); | |
| 279 | 287 | |
| 280 | 288 | static x86code *op_load1u(drcbe_state *drcbe, x86code *dst, const drcuml_instruction *inst); |
| 281 | 289 | static x86code *op_load1s(drcbe_state *drcbe, x86code *dst, const drcuml_instruction *inst); |
| r2724 | r2725 | |
| 313 | 321 | static x86code *op_sext1(drcbe_state *drcbe, x86code *dst, const drcuml_instruction *inst); |
| 314 | 322 | static x86code *op_sext2(drcbe_state *drcbe, x86code *dst, const drcuml_instruction *inst); |
| 315 | 323 | static x86code *op_sext4(drcbe_state *drcbe, x86code *dst, const drcuml_instruction *inst); |
| 324 | static x86code *op_xtract(drcbe_state *drcbe, x86code *dst, const drcuml_instruction *inst); | |
| 325 | static x86code *op_insert(drcbe_state *drcbe, x86code *dst, const drcuml_instruction *inst); | |
| 316 | 326 | static x86code *op_add(drcbe_state *drcbe, x86code *dst, const drcuml_instruction *inst); |
| 317 | 327 | static x86code *op_addc(drcbe_state *drcbe, x86code *dst, const drcuml_instruction *inst); |
| 318 | 328 | static x86code *op_sub(drcbe_state *drcbe, x86code *dst, const drcuml_instruction *inst); |
| r2724 | r2725 | |
| 326 | 336 | static x86code *op_test(drcbe_state *drcbe, x86code *dst, const drcuml_instruction *inst); |
| 327 | 337 | static x86code *op_or(drcbe_state *drcbe, x86code *dst, const drcuml_instruction *inst); |
| 328 | 338 | static x86code *op_xor(drcbe_state *drcbe, x86code *dst, const drcuml_instruction *inst); |
| 339 | static x86code *op_lzcnt(drcbe_state *drcbe, x86code *dst, const drcuml_instruction *inst); | |
| 329 | 340 | static x86code *op_shl(drcbe_state *drcbe, x86code *dst, const drcuml_instruction *inst); |
| 330 | 341 | static x86code *op_shr(drcbe_state *drcbe, x86code *dst, const drcuml_instruction *inst); |
| 331 | 342 | static x86code *op_sar(drcbe_state *drcbe, x86code *dst, const drcuml_instruction *inst); |
| r2724 | r2725 | |
| 388 | 399 | { DRCUML_OP_SETFMOD, op_setfmod }, /* SETFMOD src */ |
| 389 | 400 | { DRCUML_OP_GETFMOD, op_getfmod }, /* GETFMOD dst */ |
| 390 | 401 | { DRCUML_OP_GETEXP, op_getexp }, /* GETEXP dst,index */ |
| 402 | { DRCUML_OP_SAVE, op_save }, /* SAVE dst,index */ | |
| 403 | { DRCUML_OP_RESTORE, op_restore }, /* RESTORE dst,index */ | |
| 391 | 404 | |
| 392 | 405 | /* Integer Operations */ |
| 393 | 406 | { DRCUML_OP_LOAD1U, op_load1u }, /* LOAD1U dst,base,index */ |
| r2724 | r2725 | |
| 426 | 439 | { DRCUML_OP_SEXT1, op_sext1 }, /* SEXT1 dst,src */ |
| 427 | 440 | { DRCUML_OP_SEXT2, op_sext2 }, /* SEXT2 dst,src */ |
| 428 | 441 | { DRCUML_OP_SEXT4, op_sext4 }, /* SEXT4 dst,src */ |
| 442 | { DRCUML_OP_XTRACT, op_xtract }, /* XTRACT dst,src1,src2,src3 */ | |
| 443 | { DRCUML_OP_INSERT, op_insert }, /* INSERT dst,src1,src2,src3 */ | |
| 429 | 444 | { DRCUML_OP_ADD, op_add }, /* ADD dst,src1,src2[,f] */ |
| 430 | 445 | { DRCUML_OP_ADDC, op_addc }, /* ADDC dst,src1,src2[,f] */ |
| 431 | 446 | { DRCUML_OP_SUB, op_sub }, /* SUB dst,src1,src2[,f] */ |
| r2724 | r2725 | |
| 439 | 454 | { DRCUML_OP_TEST, op_test }, /* TEST src1,src2[,f] */ |
| 440 | 455 | { DRCUML_OP_OR, op_or }, /* OR dst,src1,src2[,f] */ |
| 441 | 456 | { DRCUML_OP_XOR, op_xor }, /* XOR dst,src1,src2[,f] */ |
| 457 | { DRCUML_OP_LZCNT, op_lzcnt }, /* LZCNT dst,src */ | |
| 442 | 458 | { DRCUML_OP_SHL, op_shl }, /* SHL dst,src,count[,f] */ |
| 443 | 459 | { DRCUML_OP_SHR, op_shr }, /* SHR dst,src,count[,f] */ |
| 444 | 460 | { DRCUML_OP_SAR, op_sar }, /* SAR dst,src,count[,f] */ |
| r2724 | r2725 | |
| 500 | 516 | |
| 501 | 517 | |
| 502 | 518 | /*------------------------------------------------- |
| 519 | param_select_register2 - select a register | |
| 520 | to use, avoiding conflicts with the optional | |
| 521 | checkparam | |
| 522 | -------------------------------------------------*/ | |
| 523 | ||
| 524 | INLINE int param_select_register2(int defreg, const drcuml_parameter *param, const drcuml_parameter *checkparam1, const drcuml_parameter *checkparam2) | |
| 525 | { | |
| 526 | if (param->type == DRCUML_PTYPE_INT_REGISTER && (param->type != checkparam1->type || param->value != checkparam1->value) && (param->type != checkparam2->type || param->value != checkparam2->value)) | |
| 527 | return param->value; | |
| 528 | return defreg; | |
| 529 | } | |
| 530 | ||
| 531 | ||
| 532 | /*------------------------------------------------- | |
| 503 | 533 | emit_combine_z_flags - combine the Z flag from |
| 504 | 534 | two 32-bit operations |
| 505 | 535 | -------------------------------------------------*/ |
| r2724 | r2725 | |
| 589 | 619 | if (entry & 0x800) flags |= DRCUML_FLAG_V; |
| 590 | 620 | flags_map[entry] = flags; |
| 591 | 621 | } |
| 622 | for (entry = 0; entry < ARRAY_LENGTH(flags_unmap); entry++) | |
| 623 | { | |
| 624 | UINT32 flags = 0; | |
| 625 | if (entry & DRCUML_FLAG_C) flags |= 0x001; | |
| 626 | if (entry & DRCUML_FLAG_U) flags |= 0x004; | |
| 627 | if (entry & DRCUML_FLAG_Z) flags |= 0x040; | |
| 628 | if (entry & DRCUML_FLAG_S) flags |= 0x080; | |
| 629 | if (entry & DRCUML_FLAG_V) flags |= 0x800; | |
| 630 | flags_unmap[entry] = flags; | |
| 631 | } | |
| 592 | 632 | |
| 593 | 633 | /* compute hi pointers for each register */ |
| 594 | 634 | for (regnum = 0; regnum < ARRAY_LENGTH(int_register_map); regnum++) |
| 595 | 635 | if (int_register_map[regnum] != 0) |
| 596 | 636 | { |
| 597 | drcbe->reglo[int_register_map[regnum]] = &drcbe->state.r[regnum].l; | |
| 598 | drcbe->reghi[int_register_map[regnum]] = &drcbe->state.r[regnum].h; | |
| 637 | drcbe->reglo[int_register_map[regnum]] = &drcbe->state.r[regnum].w.l; | |
| 638 | drcbe->reghi[int_register_map[regnum]] = &drcbe->state.r[regnum].w.h; | |
| 599 | 639 | } |
| 600 | 640 | |
| 601 | 641 | /* create the log */ |
| r2724 | r2725 | |
| 624 | 664 | |
| 625 | 665 | static void drcbex86_reset(drcbe_state *drcbe) |
| 626 | 666 | { |
| 667 | UINT32 (*cpuid_ecx_stub)(void); | |
| 627 | 668 | x86code **dst; |
| 628 | 669 | |
| 629 | 670 | /* output a note to the log */ |
| r2724 | r2725 | |
| 635 | 676 | if (dst == NULL) |
| 636 | 677 | fatalerror("Out of cache space after a reset!"); |
| 637 | 678 | |
| 679 | /* generate a simple CPUID stub */ | |
| 680 | cpuid_ecx_stub = (UINT32 (*)(void))*dst; | |
| 681 | emit_push_r32(dst, REG_EBX); // push ebx | |
| 682 | emit_mov_r32_imm(dst, REG_EAX, 1); // mov eax,1 | |
| 683 | emit_cpuid(dst); // cpuid | |
| 684 | emit_mov_r32_r32(dst, REG_EAX, REG_ECX); // mov eax,ecx | |
| 685 | emit_pop_r32(dst, REG_EBX); // pop ebx | |
| 686 | emit_ret(dst); // ret | |
| 687 | ||
| 688 | /* call it to determine if we have SSE3 support */ | |
| 689 | drcbe->sse3 = (((*cpuid_ecx_stub)() & 1) != 0); | |
| 690 | ||
| 638 | 691 | /* generate an entry point */ |
| 639 | 692 | drcbe->entry = (x86_entry_point_func)*dst; |
| 640 | 693 | emit_mov_r32_m32(dst, REG_EAX, MBD(REG_ESP, 4)); // mov eax,[esp+4] |
| r2724 | r2725 | |
| 678 | 731 | |
| 679 | 732 | |
| 680 | 733 | /*------------------------------------------------- |
| 734 | drcbex86_execute - execute a block of code | |
| 735 | referenced by the given handle | |
| 736 | -------------------------------------------------*/ | |
| 737 | ||
| 738 | static int drcbex86_execute(drcbe_state *drcbe, drcuml_codehandle *entry) | |
| 739 | { | |
| 740 | /* call our entry point which will jump to the destination */ | |
| 741 | return (*drcbe->entry)((x86code *)drcuml_handle_codeptr(entry)); | |
| 742 | } | |
| 743 | ||
| 744 | ||
| 745 | /*------------------------------------------------- | |
| 681 | 746 | drcbex86_generate - generate code |
| 682 | 747 | -------------------------------------------------*/ |
| 683 | 748 | |
| r2724 | r2725 | |
| 761 | 826 | |
| 762 | 827 | |
| 763 | 828 | /*------------------------------------------------- |
| 764 | drcbec_execute - execute a block of code | |
| 765 | registered at the given mode/pc | |
| 829 | drcbex86_get_info - return information about | |
| 830 | the back-end implementation | |
| 766 | 831 | -------------------------------------------------*/ |
| 767 | 832 | |
| 768 | static i | |
| 833 | static void | |
| 769 | 834 | { |
| 770 | /* call our entry point which will jump to the destination */ | |
| 771 | return (*drcbe->entry)((x86code *)drcuml_handle_codeptr(entry)); | |
| 835 | for (info->direct_iregs = 0; info->direct_iregs < DRCUML_REG_I_END - DRCUML_REG_I0; info->direct_iregs++) | |
| 836 | if (int_register_map[info->direct_iregs] == 0) | |
| 837 | break; | |
| 838 | info->direct_fregs = 0; | |
| 772 | 839 | } |
| 773 | 840 | |
| 774 | 841 | |
| r2724 | r2725 | |
| 1322 | 1389 | { |
| 1323 | 1390 | if (param->type == DRCUML_PTYPE_IMMEDIATE) |
| 1324 | 1391 | { |
| 1325 | if (inst->condflags | |
| 1392 | if (inst->condflags == 0 && (UINT32)param->value == 0xffffffff) | |
| 1326 | 1393 | /* skip */; |
| 1327 | 1394 | else if (inst->condflags != 0 && (UINT32)param->value == 0) |
| 1328 | 1395 | emit_xor_r32_r32(dst, reg, reg); // xor reg,reg |
| r2724 | r2725 | |
| 1345 | 1412 | { |
| 1346 | 1413 | if (param->type == DRCUML_PTYPE_IMMEDIATE) |
| 1347 | 1414 | { |
| 1348 | if (inst->condflags | |
| 1415 | if (inst->condflags == 0 && (UINT32)param->value == 0xffffffff) | |
| 1349 | 1416 | /* skip */; |
| 1350 | 1417 | else if (inst->condflags != 0 && (UINT32)param->value == 0) |
| 1351 | 1418 | emit_mov_m32_imm(dst, MEMPARAMS, 0); // mov [dest],0 |
| r2724 | r2725 | |
| 1405 | 1472 | { |
| 1406 | 1473 | if (param->type == DRCUML_PTYPE_IMMEDIATE) |
| 1407 | 1474 | { |
| 1408 | if (inst->condflags | |
| 1475 | if (inst->condflags == 0 && (UINT32)param->value == 0) | |
| 1409 | 1476 | /* skip */; |
| 1410 | 1477 | else if (inst->condflags != 0 && (UINT32)param->value == 0xffffffff) |
| 1411 | 1478 | emit_mov_r32_imm(dst, reg, -1); // mov reg,-1 |
| r2724 | r2725 | |
| 1428 | 1495 | { |
| 1429 | 1496 | if (param->type == DRCUML_PTYPE_IMMEDIATE) |
| 1430 | 1497 | { |
| 1431 | if (inst->condflags | |
| 1498 | if (inst->condflags == 0 && (UINT32)param->value == 0) | |
| 1432 | 1499 | /* skip */; |
| 1433 | 1500 | else if (inst->condflags != 0 && (UINT32)param->value == 0xffffffff) |
| 1434 | 1501 | emit_mov_m32_imm(dst, MEMPARAMS, -1); // mov [dest],-1 |
| r2724 | r2725 | |
| 1453 | 1520 | { |
| 1454 | 1521 | if (param->type == DRCUML_PTYPE_IMMEDIATE) |
| 1455 | 1522 | { |
| 1456 | if (inst->condflags | |
| 1523 | if (inst->condflags == 0 && (UINT32)param->value == 0) | |
| 1457 | 1524 | /* skip */; |
| 1458 | 1525 | else if (inst->condflags != 0 && (UINT32)param->value == 0xffffffff) |
| 1459 | 1526 | emit_not_r32(dst, reg); // not reg |
| r2724 | r2725 | |
| 1476 | 1543 | { |
| 1477 | 1544 | if (param->type == DRCUML_PTYPE_IMMEDIATE) |
| 1478 | 1545 | { |
| 1479 | if (inst->condflags | |
| 1546 | if (inst->condflags == 0 && (UINT32)param->value == 0) | |
| 1480 | 1547 | /* skip */; |
| 1481 | 1548 | else if (inst->condflags != 0 && (UINT32)param->value == 0xffffffff) |
| 1482 | 1549 | emit_not_m32(dst, MEMPARAMS); // not [dest] |
| r2724 | r2725 | |
| 1501 | 1568 | { |
| 1502 | 1569 | if (param->type == DRCUML_PTYPE_IMMEDIATE) |
| 1503 | 1570 | { |
| 1504 | if (inst->condflags | |
| 1571 | if (inst->condflags == 0 && (UINT32)param->value == 0) | |
| 1505 | 1572 | /* skip */; |
| 1506 | 1573 | else |
| 1507 | 1574 | emit_shl_r32_imm(dst, reg, param->value); // shl reg,param |
| r2724 | r2725 | |
| 1523 | 1590 | { |
| 1524 | 1591 | if (param->type == DRCUML_PTYPE_IMMEDIATE) |
| 1525 | 1592 | { |
| 1526 | if (inst->condflags | |
| 1593 | if (inst->condflags == 0 && (UINT32)param->value == 0) | |
| 1527 | 1594 | /* skip */; |
| 1528 | 1595 | else |
| 1529 | 1596 | emit_shl_m32_imm(dst, MEMPARAMS, param->value); // shl [dest],param |
| r2724 | r2725 | |
| 1545 | 1612 | { |
| 1546 | 1613 | if (param->type == DRCUML_PTYPE_IMMEDIATE) |
| 1547 | 1614 | { |
| 1548 | if (inst->condflags | |
| 1615 | if (inst->condflags == 0 && (UINT32)param->value == 0) | |
| 1549 | 1616 | /* skip */; |
| 1550 | 1617 | else |
| 1551 | 1618 | emit_shr_r32_imm(dst, reg, param->value); // shr reg,param |
| r2724 | r2725 | |
| 1567 | 1634 | { |
| 1568 | 1635 | if (param->type == DRCUML_PTYPE_IMMEDIATE) |
| 1569 | 1636 | { |
| 1570 | if (inst->condflags | |
| 1637 | if (inst->condflags == 0 && (UINT32)param->value == 0) | |
| 1571 | 1638 | /* skip */; |
| 1572 | 1639 | else |
| 1573 | 1640 | emit_shr_m32_imm(dst, MEMPARAMS, param->value); // shr [dest],param |
| r2724 | r2725 | |
| 1589 | 1656 | { |
| 1590 | 1657 | if (param->type == DRCUML_PTYPE_IMMEDIATE) |
| 1591 | 1658 | { |
| 1592 | if (inst->condflags | |
| 1659 | if (inst->condflags == 0 && (UINT32)param->value == 0) | |
| 1593 | 1660 | /* skip */; |
| 1594 | 1661 | else |
| 1595 | 1662 | emit_sar_r32_imm(dst, reg, param->value); // sar reg,param |
| r2724 | r2725 | |
| 1611 | 1678 | { |
| 1612 | 1679 | if (param->type == DRCUML_PTYPE_IMMEDIATE) |
| 1613 | 1680 | { |
| 1614 | if (inst->condflags | |
| 1681 | if (inst->condflags == 0 && (UINT32)param->value == 0) | |
| 1615 | 1682 | /* skip */; |
| 1616 | 1683 | else |
| 1617 | 1684 | emit_sar_m32_imm(dst, MEMPARAMS, param->value); // sar [dest],param |
| r2724 | r2725 | |
| 1633 | 1700 | { |
| 1634 | 1701 | if (param->type == DRCUML_PTYPE_IMMEDIATE) |
| 1635 | 1702 | { |
| 1636 | if (inst->condflags | |
| 1703 | if (inst->condflags == 0 && (UINT32)param->value == 0) | |
| 1637 | 1704 | /* skip */; |
| 1638 | 1705 | else |
| 1639 | 1706 | emit_rol_r32_imm(dst, reg, param->value); // rol reg,param |
| r2724 | r2725 | |
| 1655 | 1722 | { |
| 1656 | 1723 | if (param->type == DRCUML_PTYPE_IMMEDIATE) |
| 1657 | 1724 | { |
| 1658 | if (inst->condflags | |
| 1725 | if (inst->condflags == 0 && (UINT32)param->value == 0) | |
| 1659 | 1726 | /* skip */; |
| 1660 | 1727 | else |
| 1661 | 1728 | emit_rol_m32_imm(dst, MEMPARAMS, param->value); // rol [dest],param |
| r2724 | r2725 | |
| 1677 | 1744 | { |
| 1678 | 1745 | if (param->type == DRCUML_PTYPE_IMMEDIATE) |
| 1679 | 1746 | { |
| 1680 | if (inst->condflags | |
| 1747 | if (inst->condflags == 0 && (UINT32)param->value == 0) | |
| 1681 | 1748 | /* skip */; |
| 1682 | 1749 | else |
| 1683 | 1750 | emit_ror_r32_imm(dst, reg, param->value); // ror reg,param |
| r2724 | r2725 | |
| 1699 | 1766 | { |
| 1700 | 1767 | if (param->type == DRCUML_PTYPE_IMMEDIATE) |
| 1701 | 1768 | { |
| 1702 | if (inst->condflags | |
| 1769 | if (inst->condflags == 0 && (UINT32)param->value == 0) | |
| 1703 | 1770 | /* skip */; |
| 1704 | 1771 | else |
| 1705 | 1772 | emit_ror_m32_imm(dst, MEMPARAMS, param->value); // ror [dest],param |
| r2724 | r2725 | |
| 1721 | 1788 | { |
| 1722 | 1789 | if (param->type == DRCUML_PTYPE_IMMEDIATE) |
| 1723 | 1790 | { |
| 1724 | if (inst->condflags | |
| 1791 | if (inst->condflags == 0 && (UINT32)param->value == 0) | |
| 1725 | 1792 | /* skip */; |
| 1726 | 1793 | else |
| 1727 | 1794 | emit_rcl_r32_imm(dst, reg, param->value); // rcl reg,param |
| r2724 | r2725 | |
| 1743 | 1810 | { |
| 1744 | 1811 | if (param->type == DRCUML_PTYPE_IMMEDIATE) |
| 1745 | 1812 | { |
| 1746 | if (inst->condflags | |
| 1813 | if (inst->condflags == 0 && (UINT32)param->value == 0) | |
| 1747 | 1814 | /* skip */; |
| 1748 | 1815 | else |
| 1749 | 1816 | emit_rcl_m32_imm(dst, MEMPARAMS, param->value); // rcl [dest],param |
| r2724 | r2725 | |
| 1765 | 1832 | { |
| 1766 | 1833 | if (param->type == DRCUML_PTYPE_IMMEDIATE) |
| 1767 | 1834 | { |
| 1768 | if (inst->condflags | |
| 1835 | if (inst->condflags == 0 && (UINT32)param->value == 0) | |
| 1769 | 1836 | /* skip */; |
| 1770 | 1837 | else |
| 1771 | 1838 | emit_rcr_r32_imm(dst, reg, param->value); // rcr reg,param |
| r2724 | r2725 | |
| 1787 | 1854 | { |
| 1788 | 1855 | if (param->type == DRCUML_PTYPE_IMMEDIATE) |
| 1789 | 1856 | { |
| 1790 | if (inst->condflags | |
| 1857 | if (inst->condflags == 0 && (UINT32)param->value == 0) | |
| 1791 | 1858 | /* skip */; |
| 1792 | 1859 | else |
| 1793 | 1860 | emit_rcr_m32_imm(dst, MEMPARAMS, param->value); // rcr [dest],param |
| r2724 | r2725 | |
| 2419 | 2486 | if (param->type == DRCUML_PTYPE_IMMEDIATE) |
| 2420 | 2487 | { |
| 2421 | 2488 | int count = param->value & 63; |
| 2422 | if (inst->condflags | |
| 2489 | if (inst->condflags == 0 && count == 0) | |
| 2423 | 2490 | /* skip */; |
| 2424 | 2491 | else |
| 2425 | 2492 | { |
| r2724 | r2725 | |
| 2490 | 2557 | if (param->type == DRCUML_PTYPE_IMMEDIATE) |
| 2491 | 2558 | { |
| 2492 | 2559 | int count = param->value & 63; |
| 2493 | if (inst->condflags | |
| 2560 | if (inst->condflags == 0 && count == 0) | |
| 2494 | 2561 | /* skip */; |
| 2495 | 2562 | else |
| 2496 | 2563 | { |
| r2724 | r2725 | |
| 2561 | 2628 | if (param->type == DRCUML_PTYPE_IMMEDIATE) |
| 2562 | 2629 | { |
| 2563 | 2630 | int count = param->value & 63; |
| 2564 | if (inst->condflags | |
| 2631 | if (inst->condflags == 0 && count == 0) | |
| 2565 | 2632 | /* skip */; |
| 2566 | 2633 | else |
| 2567 | 2634 | { |
| r2724 | r2725 | |
| 2632 | 2699 | if (param->type == DRCUML_PTYPE_IMMEDIATE) |
| 2633 | 2700 | { |
| 2634 | 2701 | int count = param->value & 63; |
| 2635 | if (inst->condflags | |
| 2702 | if (inst->condflags == 0 && count == 0) | |
| 2636 | 2703 | /* skip */; |
| 2637 | 2704 | else |
| 2638 | 2705 | { |
| r2724 | r2725 | |
| 2688 | 2755 | emit_shld_r32_r32_cl(dst, reglo, reghi); // shld reglo,reghi,cl |
| 2689 | 2756 | if (saveflags) emit_pushf(dst); // pushf |
| 2690 | 2757 | emit_shld_r32_r32_cl(dst, reghi, REG_EBX); // shld reghi,ebx,cl |
| 2691 | emit_mov_r32_m32(dst, MBD(REG_ESP, saveflags ? -4 : -8) | |
| 2758 | emit_mov_r32_m32(dst, REG_EBX, MBD(REG_ESP, saveflags ? -4 : -8) | |
| 2692 | 2759 | } |
| 2693 | 2760 | if (saveflags) |
| 2694 | 2761 | emit_combine_z_flags(dst); |
| r2724 | r2725 | |
| 2706 | 2773 | if (param->type == DRCUML_PTYPE_IMMEDIATE) |
| 2707 | 2774 | { |
| 2708 | 2775 | int count = param->value & 63; |
| 2709 | if (inst->condflags | |
| 2776 | if (inst->condflags == 0 && count == 0) | |
| 2710 | 2777 | /* skip */; |
| 2711 | 2778 | else |
| 2712 | 2779 | { |
| r2724 | r2725 | |
| 2762 | 2829 | emit_shrd_r32_r32_cl(dst, reglo, reghi); // shrd reglo,reghi,cl |
| 2763 | 2830 | if (saveflags) emit_pushf(dst); // pushf |
| 2764 | 2831 | emit_shrd_r32_r32_cl(dst, reghi, REG_EBX); // shrd reghi,ebx,cl |
| 2765 | emit_mov_r32_m32(dst, MBD(REG_ESP, saveflags ? -4 : -8) | |
| 2832 | emit_mov_r32_m32(dst, REG_EBX, MBD(REG_ESP, saveflags ? -4 : -8) | |
| 2766 | 2833 | } |
| 2767 | 2834 | if (saveflags) |
| 2768 | 2835 | emit_combine_z_flags(dst); |
| r2724 | r2725 | |
| 3141 | 3208 | |
| 3142 | 3209 | /* validate instruction */ |
| 3143 | 3210 | assert(inst->size == 4); |
| 3144 | assert(inst->condflags == DRCUML_COND_ALWAYS || (inst->condflags >= COND_Z && inst->condflags < DRCUML_COND_MAX)); | |
| 3211 | assert(inst->condflags == DRCUML_COND_ALWAYS || (inst->condflags >= DRCUML_COND_Z && inst->condflags < DRCUML_COND_MAX)); | |
| 3145 | 3212 | |
| 3146 | 3213 | /* normalize parameters */ |
| 3147 | 3214 | param_normalize_1(drcbe, inst, &retp, PTYPE_MRI); |
| r2724 | r2725 | |
| 3234 | 3301 | } |
| 3235 | 3302 | |
| 3236 | 3303 | /* in all cases, if there is no code, we return here to generate the exception */ |
| 3237 | emit_mov_m32_p32(drcbe, &dst, MABS(&drcbe->state.exp | |
| 3304 | emit_mov_m32_p32(drcbe, &dst, MABS(&drcbe->state.exp | |
| 3238 | 3305 | emit_sub_r32_imm(&dst, REG_ESP, 4); // sub esp,4 |
| 3239 | 3306 | emit_call_m32(&dst, MABS(exp.value)); // call [exp] |
| 3240 | 3307 | |
| r2724 | r2725 | |
| 3253 | 3320 | |
| 3254 | 3321 | /* validate instruction */ |
| 3255 | 3322 | assert(inst->size == 4); |
| 3256 | assert(inst->condflags == DRCUML_COND_ALWAYS || (inst->condflags >= COND_Z && inst->condflags < DRCUML_COND_MAX)); | |
| 3323 | assert(inst->condflags == DRCUML_COND_ALWAYS || (inst->condflags >= DRCUML_COND_Z && inst->condflags < DRCUML_COND_MAX)); | |
| 3257 | 3324 | |
| 3258 | 3325 | /* normalize parameters */ |
| 3259 | 3326 | param_normalize_1(drcbe, inst, &labelp, PTYPE_I); |
| r2724 | r2725 | |
| 3280 | 3347 | |
| 3281 | 3348 | /* validate instruction */ |
| 3282 | 3349 | assert(inst->size == 4); |
| 3283 | assert(inst->condflags == DRCUML_COND_ALWAYS || (inst->condflags >= COND_Z && inst->condflags < DRCUML_COND_MAX)); | |
| 3350 | assert(inst->condflags == DRCUML_COND_ALWAYS || (inst->condflags >= DRCUML_COND_Z && inst->condflags < DRCUML_COND_MAX)); | |
| 3284 | 3351 | |
| 3285 | 3352 | /* normalize parameters */ |
| 3286 | 3353 | param_normalize_2(drcbe, inst, &handp, PTYPE_M, &exp, PTYPE_MRI); |
| r2724 | r2725 | |
| 3291 | 3358 | /* perform the exception processing inline if unconditional */ |
| 3292 | 3359 | if (inst->condflags == DRCUML_COND_ALWAYS) |
| 3293 | 3360 | { |
| 3294 | emit_mov_m32_p32(drcbe, &dst, MABS(&drcbe->state.exp | |
| 3361 | emit_mov_m32_p32(drcbe, &dst, MABS(&drcbe->state.exp | |
| 3295 | 3362 | if (*targetptr != NULL) |
| 3296 | 3363 | emit_call(&dst, *targetptr); // call *targetptr |
| 3297 | 3364 | else |
| r2724 | r2725 | |
| 3320 | 3387 | |
| 3321 | 3388 | /* validate instruction */ |
| 3322 | 3389 | assert(inst->size == 4); |
| 3323 | assert(inst->condflags == DRCUML_COND_ALWAYS || (inst->condflags >= COND_Z && inst->condflags < DRCUML_COND_MAX)); | |
| 3390 | assert(inst->condflags == DRCUML_COND_ALWAYS || (inst->condflags >= DRCUML_COND_Z && inst->condflags < DRCUML_COND_MAX)); | |
| 3324 | 3391 | |
| 3325 | 3392 | /* normalize parameters */ |
| 3326 | 3393 | param_normalize_1(drcbe, inst, &handp, PTYPE_M); |
| r2724 | r2725 | |
| 3355 | 3422 | |
| 3356 | 3423 | /* validate instruction */ |
| 3357 | 3424 | assert(inst->size == 4); |
| 3358 | assert(inst->condflags == DRCUML_COND_ALWAYS || (inst->condflags >= COND_Z && inst->condflags < DRCUML_COND_MAX)); | |
| 3425 | assert(inst->condflags == DRCUML_COND_ALWAYS || (inst->condflags >= DRCUML_COND_Z && inst->condflags < DRCUML_COND_MAX)); | |
| 3359 | 3426 | assert(inst->numparams == 0); |
| 3360 | 3427 | |
| 3361 | 3428 | /* skip if conditional */ |
| r2724 | r2725 | |
| 3383 | 3450 | |
| 3384 | 3451 | /* validate instruction */ |
| 3385 | 3452 | assert(inst->size == 4); |
| 3386 | assert(inst->condflags == DRCUML_COND_ALWAYS || (inst->condflags >= COND_Z && inst->condflags < DRCUML_COND_MAX)); | |
| 3453 | assert(inst->condflags == DRCUML_COND_ALWAYS || (inst->condflags >= DRCUML_COND_Z && inst->condflags < DRCUML_COND_MAX)); | |
| 3387 | 3454 | |
| 3388 | 3455 | /* normalize parameters */ |
| 3389 | 3456 | param_normalize_2(drcbe, inst, &funcp, PTYPE_M, ¶mp, PTYPE_M); |
| r2724 | r2725 | |
| 3520 | 3587 | |
| 3521 | 3588 | /* fetch the exception parameter and store to the destination */ |
| 3522 | 3589 | if (dstp.type == DRCUML_PTYPE_INT_REGISTER) |
| 3523 | emit_mov_r32_m32(&dst, dstp.value, MABS(&drcbe->state.exp | |
| 3590 | emit_mov_r32_m32(&dst, dstp.value, MABS(&drcbe->state.exp | |
| 3524 | 3591 | else |
| 3525 | 3592 | { |
| 3526 | emit_mov_r32_m32(&dst, REG_EAX, MABS(&drcbe->state.exp | |
| 3593 | emit_mov_r32_m32(&dst, REG_EAX, MABS(&drcbe->state.exp | |
| 3527 | 3594 | emit_mov_m32_r32(&dst, MABS(dstp.value), REG_EAX); // mov [dstp],eax |
| 3528 | 3595 | } |
| 3529 | 3596 | |
| r2724 | r2725 | |
| 3531 | 3598 | } |
| 3532 | 3599 | |
| 3533 | 3600 | |
| 3601 | /*------------------------------------------------- | |
| 3602 | op_save - process a SAVE opcode | |
| 3603 | -------------------------------------------------*/ | |
| 3534 | 3604 | |
| 3605 | static x86code *op_save(drcbe_state *drcbe, x86code *dst, const drcuml_instruction *inst) | |
| 3606 | { | |
| 3607 | drcuml_parameter dstp; | |
| 3608 | int regnum; | |
| 3609 | ||
| 3610 | /* validate instruction */ | |
| 3611 | assert(inst->size == 4); | |
| 3612 | assert(inst->condflags == DRCUML_COND_ALWAYS); | |
| 3613 | ||
| 3614 | /* normalize parameters */ | |
| 3615 | param_normalize_1(drcbe, inst, &dstp, PTYPE_M); | |
| 3616 | ||
| 3617 | /* copy live state to the destination */ | |
| 3618 | emit_mov_r32_imm(&dst, REG_ECX, dstp.value); // mov ecx,dstp | |
| 3619 | ||
| 3620 | /* copy flags */ | |
| 3621 | emit_pushf(&dst); // pushf | |
| 3622 | emit_pop_r32(&dst, REG_EAX); // pop eax | |
| 3623 | emit_and_r32_imm(&dst, REG_EAX, 0x8c5); // and eax,0x8c5 | |
| 3624 | emit_mov_r8_m8(&dst, REG_AL, MBD(REG_EAX, flags_map)); // mov al,[flags_map] | |
| 3625 | emit_mov_m8_r8(&dst, MBD(REG_ECX, offsetof(drcuml_machine_state, flags)), REG_AL); // mov state->flags,al | |
| 3626 | ||
| 3627 | /* copy fmod and exp */ | |
| 3628 | emit_mov_r8_m8(&dst, REG_AL, MABS(&drcbe->state.fmod)); // mov al,[fmod] | |
| 3629 | emit_mov_m8_r8(&dst, MBD(REG_ECX, offsetof(drcuml_machine_state, fmod)), REG_AL); // mov state->fmod,al | |
| 3630 | emit_mov_r32_m32(&dst, REG_EAX, MABS(&drcbe->state.exp)); // mov eax,[exp] | |
| 3631 | emit_mov_m32_r32(&dst, MBD(REG_ECX, offsetof(drcuml_machine_state, exp)), REG_EAX); // mov state->exp,eax | |
| 3632 | ||
| 3633 | /* copy integer registers */ | |
| 3634 | for (regnum = 0; regnum < ARRAY_LENGTH(drcbe->state.r); regnum++) | |
| 3635 | { | |
| 3636 | if (int_register_map[regnum] != 0) | |
| 3637 | emit_mov_m32_r32(&dst, MBD(REG_ECX, offsetof(drcuml_machine_state, r[regnum].w.l)), int_register_map[regnum]); | |
| 3638 | else | |
| 3639 | { | |
| 3640 | emit_mov_r32_m32(&dst, REG_EAX, MABS(&drcbe->state.r[regnum].w.l)); | |
| 3641 | emit_mov_m32_r32(&dst, MBD(REG_ECX, offsetof(drcuml_machine_state, r[regnum].w.l)), REG_EAX); | |
| 3642 | } | |
| 3643 | emit_mov_r32_m32(&dst, REG_EAX, MABS(&drcbe->state.r[regnum].w.h)); | |
| 3644 | emit_mov_m32_r32(&dst, MBD(REG_ECX, offsetof(drcuml_machine_state, r[regnum].w.h)), REG_EAX); | |
| 3645 | } | |
| 3646 | ||
| 3647 | /* copy FP registers */ | |
| 3648 | for (regnum = 0; regnum < ARRAY_LENGTH(drcbe->state.f); regnum++) | |
| 3649 | { | |
| 3650 | emit_mov_r32_m32(&dst, REG_EAX, MABS(&drcbe->state.f[regnum].s.l)); | |
| 3651 | emit_mov_m32_r32(&dst, MBD(REG_ECX, offsetof(drcuml_machine_state, f[regnum].s.l)), REG_EAX); | |
| 3652 | emit_mov_r32_m32(&dst, REG_EAX, MABS(&drcbe->state.f[regnum].s.h)); | |
| 3653 | emit_mov_m32_r32(&dst, MBD(REG_ECX, offsetof(drcuml_machine_state, f[regnum].s.h)), REG_EAX); | |
| 3654 | } | |
| 3655 | ||
| 3656 | return dst; | |
| 3657 | } | |
| 3658 | ||
| 3659 | ||
| 3660 | /*------------------------------------------------- | |
| 3661 | op_restore - process a RESTORE opcode | |
| 3662 | -------------------------------------------------*/ | |
| 3663 | ||
| 3664 | static x86code *op_restore(drcbe_state *drcbe, x86code *dst, const drcuml_instruction *inst) | |
| 3665 | { | |
| 3666 | drcuml_parameter dstp; | |
| 3667 | int regnum; | |
| 3668 | ||
| 3669 | /* validate instruction */ | |
| 3670 | assert(inst->size == 4); | |
| 3671 | assert(inst->condflags == DRCUML_COND_ALWAYS); | |
| 3672 | ||
| 3673 | /* normalize parameters */ | |
| 3674 | param_normalize_1(drcbe, inst, &dstp, PTYPE_M); | |
| 3675 | ||
| 3676 | /* copy live state from the destination */ | |
| 3677 | emit_mov_r32_imm(&dst, REG_ECX, dstp.value); // mov ecx,dstp | |
| 3678 | ||
| 3679 | /* copy integer registers */ | |
| 3680 | for (regnum = 0; regnum < ARRAY_LENGTH(drcbe->state.r); regnum++) | |
| 3681 | { | |
| 3682 | if (int_register_map[regnum] != 0) | |
| 3683 | emit_mov_r32_m32(&dst, int_register_map[regnum], MBD(REG_ECX, offsetof(drcuml_machine_state, r[regnum].w.l))); | |
| 3684 | else | |
| 3685 | { | |
| 3686 | emit_mov_r32_m32(&dst, REG_EAX, MBD(REG_ECX, offsetof(drcuml_machine_state, r[regnum].w.l))); | |
| 3687 | emit_mov_m32_r32(&dst, MABS(&drcbe->state.r[regnum].w.l), REG_EAX); | |
| 3688 | } | |
| 3689 | emit_mov_r32_m32(&dst, REG_EAX, MBD(REG_ECX, offsetof(drcuml_machine_state, r[regnum].w.h))); | |
| 3690 | emit_mov_m32_r32(&dst, MABS(&drcbe->state.r[regnum].w.h), REG_EAX); | |
| 3691 | } | |
| 3692 | ||
| 3693 | /* copy FP registers */ | |
| 3694 | for (regnum = 0; regnum < ARRAY_LENGTH(drcbe->state.f); regnum++) | |
| 3695 | { | |
| 3696 | emit_mov_r32_m32(&dst, REG_EAX, MBD(REG_ECX, offsetof(drcuml_machine_state, f[regnum].s.l))); | |
| 3697 | emit_mov_m32_r32(&dst, MABS(&drcbe->state.f[regnum].s.l), REG_EAX); | |
| 3698 | emit_mov_r32_m32(&dst, REG_EAX, MBD(REG_ECX, offsetof(drcuml_machine_state, f[regnum].s.h))); | |
| 3699 | emit_mov_m32_r32(&dst, MABS(&drcbe->state.f[regnum].s.h), REG_EAX); | |
| 3700 | } | |
| 3701 | ||
| 3702 | /* copy fmod and exp */ | |
| 3703 | emit_movzx_r32_m8(&dst, REG_EAX, MBD(REG_ECX, offsetof(drcuml_machine_state, fmod)));// movzx eax,state->fmod | |
| 3704 | emit_and_r32_imm(&dst, REG_EAX, 3); // and eax,3 | |
| 3705 | emit_mov_m8_r8(&dst, MABS(&drcbe->state.fmod), REG_AL); // mov [fmod],al | |
| 3706 | emit_fldcw_m16(&dst, MISD(REG_EAX, 2, &fp_control[0])); // fldcw fp_control[eax] | |
| 3707 | emit_mov_r32_m32(&dst, REG_EAX, MBD(REG_ECX, offsetof(drcuml_machine_state, exp))); // mov eax,state->exp | |
| 3708 | emit_mov_m32_r32(&dst, MABS(&drcbe->state.exp), REG_EAX); // mov [exp],eax | |
| 3709 | ||
| 3710 | /* copy flags */ | |
| 3711 | emit_movzx_r32_m8(&dst, REG_EAX, MBD(REG_ECX, offsetof(drcuml_machine_state, flags)));// movzx eax,state->flags | |
| 3712 | emit_push_m32(&dst, MISD(REG_EAX, 4, flags_unmap)); // push flags_unmap[eax*4] | |
| 3713 | emit_popf(&dst); // popf | |
| 3714 | ||
| 3715 | return dst; | |
| 3716 | } | |
| 3717 | ||
| 3718 | ||
| 3719 | ||
| 3535 | 3720 | /*************************************************************************** |
| 3536 | 3721 | INTEGER OPERATIONS |
| 3537 | 3722 | ***************************************************************************/ |
| r2724 | r2725 | |
| 4706 | 4891 | |
| 4707 | 4892 | /* validate instruction */ |
| 4708 | 4893 | assert(inst->size == 4 || inst->size == 8); |
| 4709 | assert(inst->condflags == DRCUML_COND_ALWAYS || (inst->condflags >= COND_Z && inst->condflags < DRCUML_COND_MAX)); | |
| 4894 | assert(inst->condflags == DRCUML_COND_ALWAYS || (inst->condflags >= DRCUML_COND_Z && inst->condflags < DRCUML_COND_MAX)); | |
| 4710 | 4895 | |
| 4711 | 4896 | /* normalize parameters, but only if we got here directly */ |
| 4712 | 4897 | /* other opcodes call through here with pre-normalized parameters */ |
| r2724 | r2725 | |
| 5085 | 5270 | |
| 5086 | 5271 | |
| 5087 | 5272 | /*------------------------------------------------- |
| 5273 | op_xtract - process an XTRACT opcode | |
| 5274 | -------------------------------------------------*/ | |
| 5275 | ||
| 5276 | static x86code *op_xtract(drcbe_state *drcbe, x86code *dst, const drcuml_instruction *inst) | |
| 5277 | { | |
| 5278 | drcuml_parameter dstp, srcp, shiftp, maskp; | |
| 5279 | int dstreg; | |
| 5280 | ||
| 5281 | /* validate instruction */ | |
| 5282 | assert(inst->size == 4 || inst->size == 8); | |
| 5283 | assert(inst->condflags == DRCUML_COND_ALWAYS); | |
| 5284 | ||
| 5285 | /* normalize parameters */ | |
| 5286 | param_normalize_4(drcbe, inst, &dstp, PTYPE_MR, &srcp, PTYPE_MRI, &shiftp, PTYPE_MRI, &maskp, PTYPE_MRI); | |
| 5287 | ||
| 5288 | /* degenerate cases -- convert to a move or simple shift */ | |
| 5289 | if (srcp.type == DRCUML_PTYPE_IMMEDIATE && shiftp.type == DRCUML_PTYPE_IMMEDIATE && maskp.type == DRCUML_PTYPE_IMMEDIATE) | |
| 5290 | { | |
| 5291 | if (inst->size == 4) | |
| 5292 | return convert_to_mov_imm(drcbe, dst, inst, &dstp, ((srcp.value << shiftp.value) | (srcp.value >> (32 - shiftp.value))) & maskp.value); | |
| 5293 | else if (inst->size == 8) | |
| 5294 | return convert_to_mov_imm(drcbe, dst, inst, &dstp, ((srcp.value << shiftp.value) | (srcp.value >> (64 - shiftp.value))) & maskp.value); | |
| 5295 | } | |
| 5296 | if (shiftp.type == DRCUML_PTYPE_IMMEDIATE && maskp.type == DRCUML_PTYPE_IMMEDIATE) | |
| 5297 | { | |
| 5298 | if ((inst->size == 4 && maskp.value == (UINT32)(0xffffffffUL << shiftp.value)) || (inst->size == 8 && maskp.value == U64(0xffffffffffffffff) << shiftp.value)) | |
| 5299 | { | |
| 5300 | drcuml_instruction temp = *inst; | |
| 5301 | temp.numparams = 3; | |
| 5302 | return op_shl(drcbe, dst, &temp); | |
| 5303 | } | |
| 5304 | if ((inst->size == 4 && maskp.value == (UINT32)(0xffffffffUL >> (32 - shiftp.value))) || (inst->size == 8 && maskp.value == U64(0xffffffffffffffff) >> (64 - shiftp.value))) | |
| 5305 | { | |
| 5306 | drcuml_instruction temp = *inst; | |
| 5307 | temp.numparams = 3; | |
| 5308 | temp.param[2].value = inst->size * 8 - temp.param[2].value; | |
| 5309 | return op_shr(drcbe, dst, &temp); | |
| 5310 | } | |
| 5311 | } | |
| 5312 | ||
| 5313 | /* pick a target register for the general case */ | |
| 5314 | dstreg = param_select_register2(REG_EAX, &dstp, &shiftp, &maskp); | |
| 5315 | ||
| 5316 | /* 32-bit form */ | |
| 5317 | if (inst->size == 4) | |
| 5318 | { | |
| 5319 | emit_mov_r32_p32(drcbe, &dst, dstreg, &srcp); // mov dstreg,srcp | |
| 5320 | emit_rol_r32_p32(drcbe, &dst, dstreg, &shiftp, inst); // rol dstreg,shiftp | |
| 5321 | emit_and_r32_p32(drcbe, &dst, dstreg, &maskp, inst); // and dstreg,maskp | |
| 5322 | emit_mov_p32_r32(drcbe, &dst, &dstp, dstreg); // mov dstp,dstreg | |
| 5323 | } | |
| 5324 | ||
| 5325 | /* 64-bit form */ | |
| 5326 | else if (inst->size == 8) | |
| 5327 | { | |
| 5328 | emit_mov_r64_p64(drcbe, &dst, dstreg, REG_EDX, &srcp); // mov edx:dstreg,srcp | |
| 5329 | emit_rol_r64_p64(drcbe, &dst, dstreg, REG_EDX, &shiftp, inst); // rol edx:dstreg,shiftp | |
| 5330 | emit_and_r64_p64(drcbe, &dst, dstreg, REG_EDX, &maskp, inst); // and edx:dstreg,maskp | |
| 5331 | emit_mov_p64_r64(drcbe, &dst, &dstp, dstreg, REG_EDX); // mov dstp,edx:dstreg | |
| 5332 | } | |
| 5333 | return dst; | |
| 5334 | } | |
| 5335 | ||
| 5336 | ||
| 5337 | /*------------------------------------------------- | |
| 5338 | op_insert - process an INSERT opcode | |
| 5339 | -------------------------------------------------*/ | |
| 5340 | ||
| 5341 | static x86code *op_insert(drcbe_state *drcbe, x86code *dst, const drcuml_instruction *inst) | |
| 5342 | { | |
| 5343 | drcuml_parameter dstp, srcp, shiftp, maskp; | |
| 5344 | int dstreg; | |
| 5345 | ||
| 5346 | /* validate instruction */ | |
| 5347 | assert(inst->size == 4 || inst->size == 8); | |
| 5348 | assert(inst->condflags == DRCUML_COND_ALWAYS); | |
| 5349 | ||
| 5350 | /* normalize parameters */ | |
| 5351 | param_normalize_4(drcbe, inst, &dstp, PTYPE_MR, &srcp, PTYPE_MRI, &shiftp, PTYPE_MRI, &maskp, PTYPE_MRI); | |
| 5352 | ||
| 5353 | /* pick a target register for the general case */ | |
| 5354 | dstreg = param_select_register2(REG_ECX, &dstp, &shiftp, &maskp); | |
| 5355 | ||
| 5356 | /* 32-bit form */ | |
| 5357 | if (inst->size == 4) | |
| 5358 | { | |
| 5359 | emit_mov_r32_p32(drcbe, &dst, REG_EAX, &srcp); // mov eax,srcp | |
| 5360 | emit_rol_r32_p32(drcbe, &dst, REG_EAX, &shiftp, inst); // rol eax,shiftp | |
| 5361 | emit_mov_r32_p32(drcbe, &dst, dstreg, &dstp); // mov dstreg,dstp | |
| 5362 | if (maskp.type == DRCUML_PTYPE_IMMEDIATE) | |
| 5363 | { | |
| 5364 | emit_and_r32_imm(&dst, REG_EAX, maskp.value); // and eax,maskp | |
| 5365 | emit_and_r32_imm(&dst, dstreg, ~maskp.value); // and dstreg,~maskp | |
| 5366 | } | |
| 5367 | else | |
| 5368 | { | |
| 5369 | emit_mov_r32_p32(drcbe, &dst, REG_EDX, &maskp); // mov edx,maskp | |
| 5370 | emit_and_r32_r32(&dst, REG_EAX, REG_EDX); // and eax,edx | |
| 5371 | emit_not_r32(&dst, REG_EDX); // not edx | |
| 5372 | emit_and_r32_r32(&dst, dstreg, REG_EDX); // and dstreg,edx | |
| 5373 | } | |
| 5374 | emit_or_r32_r32(&dst, dstreg, REG_EAX); // or dstreg,eax | |
| 5375 | emit_mov_p32_r32(drcbe, &dst, &dstp, dstreg); // mov dstp,dstreg | |
| 5376 | } | |
| 5377 | ||
| 5378 | /* 64-bit form */ | |
| 5379 | else if (inst->size == 8) | |
| 5380 | { | |
| 5381 | emit_mov_r64_p64(drcbe, &dst, REG_EAX, REG_EDX, &srcp); // mov edx:eax,srcp | |
| 5382 | emit_rol_r64_p64(drcbe, &dst, REG_EAX, REG_EDX, &shiftp, inst); // rol edx:eax,shiftp | |
| 5383 | if (maskp.type == DRCUML_PTYPE_IMMEDIATE) | |
| 5384 | { | |
| 5385 | emit_and_r32_imm(&dst, REG_EAX, maskp.value); // and eax,maskp | |
| 5386 | emit_and_r32_imm(&dst, REG_EDX, maskp.value >> 32); // and edx,maskp >> 32 | |
| 5387 | if (dstp.type == DRCUML_PTYPE_INT_REGISTER) | |
| 5388 | { | |
| 5389 | emit_and_r32_imm(&dst, dstp.value, ~maskp.value); // and dstp.lo,~maskp | |
| 5390 | emit_and_m32_imm(&dst, MABS(drcbe->reghi[dstp.value]), ~maskp.value >> 32);// and dstp.hi,~maskp >> 32 | |
| 5391 | emit_or_r32_r32(&dst, dstp.value, REG_EAX); // or dstp.lo,eax | |
| 5392 | emit_or_m32_r32(&dst, MABS(drcbe->reghi[dstp.value]), REG_EDX); // or dstp.hi,edx | |
| 5393 | } | |
| 5394 | else | |
| 5395 | { | |
| 5396 | emit_and_m32_imm(&dst, MABS(dstp.value), ~maskp.value); // and dstp.lo,~maskp | |
| 5397 | emit_and_m32_imm(&dst, MABS(dstp.value + 4), ~maskp.value >> 32); // and dstp.hi,~maskp >> 32 | |
| 5398 | emit_or_m32_r32(&dst, MABS(dstp.value), REG_EAX); // or dstp.lo,eax | |
| 5399 | emit_or_m32_r32(&dst, MABS(dstp.value + 4), REG_EDX); // or dstp.hi,edx | |
| 5400 | } | |
| 5401 | } | |
| 5402 | else | |
| 5403 | { | |
| 5404 | emit_mov_m32_r32(&dst, MBD(REG_ESP, -8), REG_EBX); // mov [esp-8],ebx | |
| 5405 | emit_mov_r64_p64(drcbe, &dst, REG_EBX, REG_ECX, &maskp); // mov ecx:ebx,maskp | |
| 5406 | emit_and_r32_r32(&dst, REG_EAX, REG_EBX); // and eax,ebx | |
| 5407 | emit_and_r32_r32(&dst, REG_EDX, REG_ECX); // and edx,ecx | |
| 5408 | emit_not_r32(&dst, REG_EBX); // not ebx | |
| 5409 | emit_not_r32(&dst, REG_ECX); // not ecx | |
| 5410 | if (dstp.type == DRCUML_PTYPE_INT_REGISTER) | |
| 5411 | { | |
| 5412 | emit_and_r32_r32(&dst, dstp.value, REG_EBX); // and dstp.lo,ebx | |
| 5413 | emit_and_m32_r32(&dst, MABS(drcbe->reghi[dstp.value]), REG_ECX); // and dstp.hi,ecx | |
| 5414 | emit_or_r32_r32(&dst, dstp.value, REG_EAX); // or dstp.lo,eax | |
| 5415 | emit_or_m32_r32(&dst, MABS(drcbe->reghi[dstp.value]), REG_EDX); // or dstp.hi,edx | |
| 5416 | } | |
| 5417 | else | |
| 5418 | { | |
| 5419 | emit_and_m32_r32(&dst, MABS(dstp.value), REG_EBX); // and dstp.lo,ebx | |
| 5420 | emit_and_m32_r32(&dst, MABS(dstp.value + 4), REG_ECX); // and dstp.hi,ecx | |
| 5421 | emit_or_m32_r32(&dst, MABS(dstp.value), REG_EAX); // or dstp.lo,eax | |
| 5422 | emit_or_m32_r32(&dst, MABS(dstp.value + 4), REG_EDX); // or dstp.hi,edx | |
| 5423 | } | |
| 5424 | emit_mov_r32_m32(&dst, REG_EBX, MBD(REG_ESP, -8)); // mov ebx,[esp-8] | |
| 5425 | } | |
| 5426 | } | |
| 5427 | return dst; | |
| 5428 | } | |
| 5429 | ||
| 5430 | ||
| 5431 | /*------------------------------------------------- | |
| 5088 | 5432 | op_add - process a ADD opcode |
| 5089 | 5433 | -------------------------------------------------*/ |
| 5090 | 5434 | |
| r2724 | r2725 | |
| 6038 | 6382 | |
| 6039 | 6383 | |
| 6040 | 6384 | /*------------------------------------------------- |
| 6385 | op_lzcnt - process a LZCNT opcode | |
| 6386 | -------------------------------------------------*/ | |
| 6387 | ||
| 6388 | static x86code *op_lzcnt(drcbe_state *drcbe, x86code *dst, const drcuml_instruction *inst) | |
| 6389 | { | |
| 6390 | drcuml_parameter dstp, srcp; | |
| 6391 | int dstreg; | |
| 6392 | ||
| 6393 | /* validate instruction */ | |
| 6394 | assert(inst->size == 4 || inst->size == 8); | |
| 6395 | assert(inst->condflags == 0); | |
| 6396 | ||
| 6397 | /* normalize parameters */ | |
| 6398 | param_normalize_2(drcbe, inst, &dstp, PTYPE_MR, &srcp, PTYPE_MRI); | |
| 6399 | ||
| 6400 | /* degenerate cases -- convert to a move */ | |
| 6401 | if (srcp.type == DRCUML_PTYPE_IMMEDIATE && inst->condflags == 0) | |
| 6402 | return convert_to_mov_imm(drcbe, dst, inst, &dstp, count_leading_zeros(srcp.value)); | |
| 6403 | ||
| 6404 | /* pick a target register for the general case */ | |
| 6405 | dstreg = param_select_register(REG_EAX, &dstp, &srcp); | |
| 6406 | ||
| 6407 | /* 32-bit form */ | |
| 6408 | if (inst->size == 4) | |
| 6409 | { | |
| 6410 | emit_mov_r32_p32(drcbe, &dst, dstreg, &srcp); // mov dstreg,src1p | |
| 6411 | emit_mov_r32_imm(&dst, REG_ECX, 32); // mov ecx,32 | |
| 6412 | emit_bsr_r32_r32(&dst, dstreg, dstreg); // bsr dstreg,dstreg | |
| 6413 | emit_cmovcc_r32_r32(&dst, COND_Z, dstreg, REG_ECX); // cmovz dstreg,ecx | |
| 6414 | emit_mov_p32_r32(drcbe, &dst, &dstp, dstreg); // mov dstp,dstreg | |
| 6415 | } | |
| 6416 | ||
| 6417 | /* 64-bit form */ | |
| 6418 | else if (inst->size == 8) | |
| 6419 | { | |
| 6420 | emit_link skip; | |
| 6421 | ||
| 6422 | emit_mov_r64_p64(drcbe, &dst, REG_EDX, dstreg, &srcp); // mov dstreg:edx,srcp | |
| 6423 | emit_bsr_r32_r32(&dst, dstreg, dstreg); // bsr dstreg,dstreg | |
| 6424 | emit_jcc_short_link(&dst, COND_NZ, &skip); // jnz skip | |
| 6425 | emit_mov_r32_imm(&dst, REG_ECX, 32); // mov ecx,32 | |
| 6426 | emit_bsr_r32_r32(&dst, dstreg, REG_EDX); // bsr dstreg,edx | |
| 6427 | emit_cmovcc_r32_r32(&dst, COND_Z, dstreg, REG_ECX); // cmovz dstreg,ecx | |
| 6428 | emit_add_r32_imm(&dst, REG_ECX, 32); // add ecx,32 | |
| 6429 | resolve_link(&dst, &skip); // skip: | |
| 6430 | emit_xor_r32_r32(&dst, REG_EDX, REG_EDX); // xor edx,edx | |
| 6431 | emit_mov_p64_r64(drcbe, &dst, &dstp, dstreg, REG_EDX); // mov dstp,edx:dstreg | |
| 6432 | } | |
| 6433 | return dst; | |
| 6434 | } | |
| 6435 | ||
| 6436 | ||
| 6437 | /*------------------------------------------------- | |
| 6041 | 6438 | op_shl - process a SHL opcode |
| 6042 | 6439 | -------------------------------------------------*/ |
| 6043 | 6440 | |
| r2724 | r2725 | |
| 6576 | 6973 | |
| 6577 | 6974 | /* validate instruction */ |
| 6578 | 6975 | assert(inst->size == 4 || inst->size == 8); |
| 6579 | assert(inst->condflags == DRCUML_COND_ALWAYS || (inst->condflags >= COND_Z && inst->condflags < DRCUML_COND_MAX)); | |
| 6976 | assert(inst->condflags == DRCUML_COND_ALWAYS || (inst->condflags >= DRCUML_COND_Z && inst->condflags < DRCUML_COND_MAX)); | |
| 6580 | 6977 | |
| 6581 | 6978 | /* normalize parameters */ |
| 6582 | 6979 | param_normalize_2(drcbe, inst, &dstp, PTYPE_MF, &srcp, PTYPE_MF); |
| r2724 | r2725 | |
| 6639 | 7036 | /* normalize parameters */ |
| 6640 | 7037 | param_normalize_2(drcbe, inst, &dstp, PTYPE_MR, &srcp, PTYPE_MF); |
| 6641 | 7038 | |
| 6642 | /* general case */ | |
| 6643 | emit_fld_p(&dst, inst->size, &srcp); // fld srcp | |
| 6644 | if (dstp.type == DRCUML_PTYPE_MEMORY) | |
| 6645 | emit_fisttp_m32(&dst, MABS(dstp.value)); // fisttp [dstp] | |
| 6646 | else if (dstp.type == DRCUML_PTYPE_INT_REGISTER) | |
| 7039 | /* non-SSE3 case */ | |
| 7040 | if (!drcbe->sse3) | |
| 6647 | 7041 | { |
| 6648 | emit_fisttp_m32(&dst, MABS(drcbe->reglo[dstp.value])); // fisttp reglo[dstp] | |
| 6649 | emit_mov_r32_m32(&dst, dstp.value, MABS(drcbe->reglo[dstp.value])); // mov dstp,reglo[dstp] | |
| 7042 | /* save and set the control word */ | |
| 7043 | emit_fstcw_m16(&dst, MABS(&drcbe->fmodesave)); // fstcw [fmodesave] | |
| 7044 | emit_fldcw_m16(&dst, MABS(&fp_control[DRCUML_FMOD_TRUNC])); // fldcw fpcontrol[DRCUML_FMOD_TRUNC] | |
| 7045 | ||
| 7046 | /* general case */ | |
| 7047 | emit_fld_p(&dst, inst->size, &srcp); // fld srcp | |
| 7048 | if (dstp.type == DRCUML_PTYPE_MEMORY) | |
| 7049 | emit_fistp_m32(&dst, MABS(dstp.value)); // fistp [dstp] | |
| 7050 | else if (dstp.type == DRCUML_PTYPE_INT_REGISTER) | |
| 7051 | { | |
| 7052 | emit_fistp_m32(&dst, MABS(drcbe->reglo[dstp.value])); // fistp reglo[dstp] | |
| 7053 | emit_mov_r32_m32(&dst, dstp.value, MABS(drcbe->reglo[dstp.value])); // mov dstp,reglo[dstp] | |
| 7054 | } | |
| 7055 | ||
| 7056 | /* restore control word and proceed */ | |
| 7057 | emit_fldcw_m16(&dst, MABS(&drcbe->fmodesave)); // fldcw [fmodesave] | |
| 6650 | 7058 | } |
| 7059 | ||
| 7060 | /* SSE3 case */ | |
| 7061 | else | |
| 7062 | { | |
| 7063 | /* general case */ | |
| 7064 | emit_fld_p(&dst, inst->size, &srcp); // fld srcp | |
| 7065 | if (dstp.type == DRCUML_PTYPE_MEMORY) | |
| 7066 | emit_fisttp_m32(&dst, MABS(dstp.value)); // fisttp [dstp] | |
| 7067 | else if (dstp.type == DRCUML_PTYPE_INT_REGISTER) | |
| 7068 | { | |
| 7069 | emit_fisttp_m32(&dst, MABS(drcbe->reglo[dstp.value])); // fisttp reglo[dstp] | |
| 7070 | emit_mov_r32_m32(&dst, dstp.value, MABS(drcbe->reglo[dstp.value])); // mov dstp,reglo[dstp] | |
| 7071 | } | |
| 7072 | } | |
| 6651 | 7073 | return dst; |
| 6652 | 7074 | } |
| 6653 | 7075 | |
| r2724 | r2725 | |
| 6800 | 7222 | /* normalize parameters */ |
| 6801 | 7223 | param_normalize_2(drcbe, inst, &dstp, PTYPE_MR, &srcp, PTYPE_MF); |
| 6802 | 7224 | |
| 6803 | /* general case */ | |
| 6804 | emit_fld_p(&dst, inst->size, &srcp); // fld srcp | |
| 6805 | if (dstp.type == DRCUML_PTYPE_MEMORY) | |
| 6806 | emit_fisttp_m64(&dst, MABS(dstp.value)); // fisttp [dstp] | |
| 6807 | else if (dstp.type == DRCUML_PTYPE_INT_REGISTER) | |
| 7225 | /* non-SSE3 case */ | |
| 7226 | if (!drcbe->sse3) | |
| 6808 | 7227 | { |
| 6809 | emit_fisttp_m64(&dst, MABS(drcbe->reglo[dstp.value])); // fisttp reglo[dstp] | |
| 6810 | emit_mov_r32_m32(&dst, dstp.value, MABS(drcbe->reglo[dstp.value])); // mov dstp,reglo[dstp] | |
| 7228 | /* save and set the control word */ | |
| 7229 | emit_fstcw_m16(&dst, MABS(&drcbe->fmodesave)); // fstcw [fmodesave] | |
| 7230 | emit_fldcw_m16(&dst, MABS(&fp_control[DRCUML_FMOD_TRUNC])); // fldcw fpcontrol[DRCUML_FMOD_TRUNC] | |
| 7231 | ||
| 7232 | /* general case */ | |
| 7233 | emit_fld_p(&dst, inst->size, &srcp); // fld srcp | |
| 7234 | if (dstp.type == DRCUML_PTYPE_MEMORY) | |
| 7235 | emit_fistp_m64(&dst, MABS(dstp.value)); // fistp [dstp] | |
| 7236 | else if (dstp.type == DRCUML_PTYPE_INT_REGISTER) | |
| 7237 | { | |
| 7238 | emit_fistp_m64(&dst, MABS(drcbe->reglo[dstp.value])); // fistp reglo[dstp] | |
| 7239 | emit_mov_r32_m32(&dst, dstp.value, MABS(drcbe->reglo[dstp.value])); // mov dstp,reglo[dstp] | |
| 7240 | } | |
| 7241 | ||
| 7242 | /* restore control word and proceed */ | |
| 7243 | emit_fldcw_m16(&dst, MABS(&drcbe->fmodesave)); // fldcw [fmodesave] | |
| 6811 | 7244 | } |
| 7245 | ||
| 7246 | /* SSE3 case */ | |
| 7247 | else | |
| 7248 | { | |
| 7249 | /* general case */ | |
| 7250 | emit_fld_p(&dst, inst->size, &srcp); // fld srcp | |
| 7251 | if (dstp.type == DRCUML_PTYPE_MEMORY) | |
| 7252 | emit_fisttp_m64(&dst, MABS(dstp.value)); // fisttp [dstp] | |
| 7253 | else if (dstp.type == DRCUML_PTYPE_INT_REGISTER) | |
| 7254 | { | |
| 7255 | emit_fisttp_m64(&dst, MABS(drcbe->reglo[dstp.value])); // fisttp reglo[dstp] | |
| 7256 | emit_mov_r32_m32(&dst, dstp.value, MABS(drcbe->reglo[dstp.value])); // mov dstp,reglo[dstp] | |
| 7257 | } | |
| 7258 | } | |
| 6812 | 7259 | return dst; |
| 6813 | 7260 | } |
| 6814 | 7261 | |
| r2724 | r2725 | |
| 7091 | 7538 | |
| 7092 | 7539 | /* validate instruction */ |
| 7093 | 7540 | assert(inst->size == 4 || inst->size == 8); |
| 7094 | assert((inst->condflags & ~(DRCUML_FLAG_C | DRCUML_FLAG_ | |
| 7541 | assert((inst->condflags & ~(DRCUML_FLAG_C | DRCUML_FLAG_ | |
| 7095 | 7542 | |
| 7096 | 7543 | /* normalize parameters */ |
| 7097 | 7544 | param_normalize_2(drcbe, inst, &src1p, PTYPE_MF, &src2p, PTYPE_MF); |
| r2724 | r2725 | |
|---|---|---|
| 1 | 1 | static const int adr_a_begin[]={ |
| 2 | 2 | -1, -1, BEGIN_XS, BEGIN_X, BEGIN_S, BEGIN_M, BEGIN_B, BEGIN_W, |
| 3 | -1, -1, -1, -1, -1, -1, -1, -1, | |
| 3 | 4 | }; |
| 4 | 5 | |
| 5 | 6 | static const int adr_a_count[]={ |
| 6 | 7 | -1, -1, COUNT_XS, COUNT_X, COUNT_S, COUNT_M, COUNT_B, COUNT_W, |
| 8 | -1, -1, -1, -1, -1, -1, -1, -1, | |
| 7 | 9 | }; |
| 8 | 10 | |
| 9 | 11 | static const int adr_b_begin[]={ |
| r2724 | r2725 | |
| 26 | 28 | -1, -1, -1, -1, -1, -1, -1, COUNT_A |
| 27 | 29 | }; |
| 28 | 30 | |
| 29 | static const int reg_left[]={A,B,C,D,B,C,A,C}; | |
| 30 | static const int reg_right[]={B,C,A,C,A,B,C,D}; | |
| 31 | static const int add_left[]={ A,B,C,D, 0,0,0,0, B,C,A,C }; | |
| 32 | static const int add_right[]={ B,C,A,C, 0,0,0,0, A,B,C,D }; | |
| 33 | static const int sub_left[]={A,B,C,D, 0,0,0,0, B,C,A,C, A,B,C,D}; | |
| 34 | static const int sub_right[]={B,C,A,C, 0,0,0,0, A,B,C,D, A,B,C,D }; | |
| 31 | static const int reg_left[] ={A,B,C,D, B,C,A,C, I,I,I,I, I,I,I,I}; | |
| 32 | static const int reg_right[]={B,C,A,C, A,B,C,D, I,I,I,I, I,I,I,I}; | |
| 33 | static const int add_left[] ={A,B,C,D, I,I,I,I, B,C,A,C, I,I,I,I}; | |
| 34 | static const int add_right[]={B,C,A,C, I,I,I,I, A,B,C,D, I,I,I,I}; | |
| 35 | static const int sub_left[] ={A,B,C,D, I,I,I,I, B,C,A,C, A,B,C,D}; | |
| 36 | static const int sub_right[]={B,C,A,C, I,I,I,I, A,B,C,D, B,C,A,C}; | |
| 35 | 37 | |
| 38 | void saturn_invalid3( int op1, int op2, int op3 ) | |
| 39 | { | |
| 40 | logerror( "SATURN#%d invalid opcode %x%x%x at %05x\n", | |
| 41 | cpu_getactivecpu(), op1, op2, op3, saturn.pc-3 ); | |
| 42 | } | |
| 43 | ||
| 44 | void saturn_invalid4( int op1, int op2, int op3, int op4 ) | |
| 45 | { | |
| 46 | logerror( "SATURN#%d invalid opcode %x%x%x%x at %05x\n", | |
| 47 | cpu_getactivecpu(), op1, op2, op3, op4, saturn.pc-4 ); | |
| 48 | } | |
| 49 | ||
| 50 | void saturn_invalid5( int op1, int op2, int op3, int op4, int op5 ) | |
| 51 | { | |
| 52 | logerror( "SATURN#%d invalid opcode %x%x%x%x%x at %05x\n", | |
| 53 | cpu_getactivecpu(), op1, op2, op3, op4, op5, saturn.pc-5 ); | |
| 54 | } | |
| 55 | ||
| 56 | void saturn_invalid6( int op1, int op2, int op3, int op4, int op5, int op6 ) | |
| 57 | { | |
| 58 | logerror( "SATURN#%d invalid opcode %x%x%x%x%x%x at %05x\n", | |
| 59 | cpu_getactivecpu(), op1, op2, op3, op4, op5, op6, saturn.pc-6 ); | |
| 60 | } | |
| 61 | ||
| 62 | ||
| 36 | 63 | INLINE void saturn_instruction_0e(void) |
| 37 | 64 | { |
| 38 | 65 | int reg, adr; |
| r2724 | r2725 | |
| 68 | 95 | break; //A=A!B xs |
| 69 | 96 | } |
| 70 | 97 | break; |
| 98 | default: | |
| 99 | saturn_invalid3( 0, 0xe, adr ); | |
| 100 | break; | |
| 71 | 101 | } |
| 72 | 102 | } |
| 73 | 103 | |
| r2724 | r2725 | |
| 84 | 114 | case 8: case 9: case 0xa: case 0xb: case 0xc: |
| 85 | 115 | saturn_copy(R0+(reg&7), BEGIN_W, COUNT_W, C); |
| 86 | 116 | break; // r0=c w |
| 117 | default: | |
| 118 | saturn_invalid3( 1, adr, reg ); | |
| 119 | break; | |
| 87 | 120 | } |
| 88 | 121 | break; |
| 89 | 122 | case 1: |
| r2724 | r2725 | |
| 94 | 127 | case 8: case 9: case 0xa: case 0xb: case 0xc: |
| 95 | 128 | saturn_copy(C, BEGIN_W, COUNT_W, R0+(reg&7)); |
| 96 | 129 | break; // c=r0 w |
| 130 | default: | |
| 131 | saturn_invalid3( 1, adr, reg ); | |
| 132 | break; | |
| 97 | 133 | } |
| 98 | 134 | break; |
| 99 | 135 | case 2: |
| r2724 | r2725 | |
| 104 | 140 | case 8: case 9: case 0xa: case 0xb: case 0xc: |
| 105 | 141 | saturn_exchange(C, BEGIN_W, COUNT_W, R0+(reg&7)); |
| 106 | 142 | break; // cr0ex w |
| 143 | default: | |
| 144 | saturn_invalid3( 2, adr, reg ); | |
| 145 | break; | |
| 107 | 146 | } |
| 108 | 147 | break; |
| 109 | 148 | case 3: |
| r2724 | r2725 | |
| 159 | 198 | case 2: case 3: case 4: case 5: case 6: case 7: |
| 160 | 199 | saturn_store_nibbles(oper&4?C:A,adr_a_begin[adr],adr_a_count[adr],oper&1); |
| 161 | 200 | break; |
| 201 | default: | |
| 202 | saturn_invalid4( 1, 5, oper, adr ); | |
| 203 | break; | |
| 162 | 204 | } |
| 163 | 205 | break; |
| 164 | 206 | case 2: case 3: case 6: case 7: |
| r2724 | r2725 | |
| 172 | 214 | case 2: case 3: case 4: case 5: case 6: case 7: |
| 173 | 215 | saturn_load_nibbles(oper&4?C:A,adr_a_begin[adr],adr_a_count[adr],oper&1); |
| 174 | 216 | break; |
| 217 | default: | |
| 218 | saturn_invalid4( 1, 5, oper, adr ); | |
| 219 | break; | |
| 175 | 220 | } |
| 176 | 221 | break; |
| 177 | 222 | case 8: saturn_store_nibbles(A, 0, READ_OP()+1, 0); break; |
| r2724 | r2725 | |
| 184 | 229 | case 0xf: saturn_load_nibbles(C, 0, READ_OP()+1, 1); break; |
| 185 | 230 | } |
| 186 | 231 | break; |
| 232 | case 6: saturn_add_adr(0);break; | |
| 233 | case 7: saturn_add_adr(1);break; | |
| 234 | case 8: saturn_sub_adr(0);break; | |
| 187 | 235 | case 9: saturn_load_adr(0,2);break; |
| 188 | 236 | case 0xa: saturn_load_adr(0,4);break; |
| 189 | 237 | case 0xb: saturn_load_adr(0,5);break; |
| 238 | case 0xc: saturn_sub_adr(1);break; | |
| 190 | 239 | case 0xd: saturn_load_adr(1,2);break; |
| 191 | 240 | case 0xe: saturn_load_adr(1,4);break; |
| 192 | 241 | case 0xf: saturn_load_adr(1,5);break; |
| 193 | case 6: saturn_add_adr(0);break; | |
| 194 | case 7: saturn_add_adr(1);break; | |
| 195 | case 8: saturn_sub_adr(0);break; | |
| 196 | case 0xc: saturn_sub_adr(1);break; | |
| 197 | 242 | } |
| 198 | 243 | } |
| 199 | 244 | |
| 200 | 245 | static void saturn_instruction_80(void) |
| 201 | 246 | { |
| 247 | int op; | |
| 202 | 248 | switch(READ_OP()) { |
| 203 | 249 | case 0: saturn_out_cs();break; |
| 204 | 250 | case 1: saturn_out_c();break; |
| r2724 | r2725 | |
| 212 | 258 | switch(READ_OP()) { |
| 213 | 259 | case 0: saturn_interrupt_on();break; |
| 214 | 260 | case 1: |
| 215 | switch(READ_OP()) { | |
| 261 | switch(op=READ_OP()) { | |
| 216 | 262 | case 0: saturn_reset_interrupt();break; |
| 263 | default: saturn_invalid5( 8, 0, 8, 1, op ); break; | |
| 217 | 264 | } |
| 218 | 265 | break; |
| 219 | 266 | case 2: saturn_load_reg(A);break; //la |
| 220 | case 3: saturn_bus_command_ | |
| 267 | case 3: saturn_bus_command_b();break; | |
| 221 | 268 | case 4: saturn_clear_bit(A);break; // abit=0 |
| 222 | 269 | case 5: saturn_set_bit(A);break; // abit=1 |
| 223 | 270 | case 6: saturn_jump_bit_clear(A);break; |
| r2724 | r2725 | |
| 244 | 291 | |
| 245 | 292 | static void saturn_instruction_81a(void) |
| 246 | 293 | { |
| 247 | int reg, adr; | |
| 294 | int reg, adr,op; | |
| 248 | 295 | switch(adr=READ_OP()) { |
| 249 | 296 | case 0: |
| 250 | switch(READ_OP()) { | |
| 297 | switch(op=READ_OP()) { | |
| 251 | 298 | case 0: |
| 252 | 299 | switch(reg=READ_OP()) { |
| 253 | 300 | case 0: case 1: case 2: case 3: case 4: |
| r2724 | r2725 | |
| 256 | 303 | case 8: case 9: case 0xa: case 0xb: case 0xc: |
| 257 | 304 | saturn_copy(R0+(reg&7),saturn.p,1,C); |
| 258 | 305 | break; //r0=c p |
| 306 | default: | |
| 307 | saturn_invalid6( 8, 1, 0xa, adr, op, reg); | |
| 308 | break; | |
| 259 | 309 | } |
| 260 | 310 | break; |
| 261 | 311 | case 1: |
| r2724 | r2725 | |
| 266 | 316 | case 8: case 9: case 0xa: case 0xb: case 0xc: |
| 267 | 317 | saturn_copy(C,saturn.p,1,R0+(reg&7)); |
| 268 | 318 | break; //c=r0 p |
| 319 | default: | |
| 320 | saturn_invalid6( 8, 1, 0xa, adr, op, reg); | |
| 321 | break; | |
| 269 | 322 | } |
| 270 | 323 | break; |
| 271 | 324 | case 2: |
| r2724 | r2725 | |
| 276 | 329 | case 8: case 9: case 0xa: case 0xb: case 0xc: |
| 277 | 330 | saturn_exchange(C, saturn.p,1,R0+(reg&7)); |
| 278 | 331 | break; // cr0ex p |
| 332 | default: | |
| 333 | saturn_invalid6( 8, 1, 0xa, adr, op, reg); | |
| 334 | break; | |
| 279 | 335 | } |
| 280 | 336 | break; |
| 337 | default: | |
| 338 | saturn_invalid5( 8, 1, 0xa, adr, op ); | |
| 339 | break; | |
| 281 | 340 | } |
| 282 | 341 | break; |
| 283 | 342 | case 1: |
| 284 | switch(READ_OP()) { | |
| 343 | switch(op=READ_OP()) { | |
| 285 | 344 | case 0: |
| 286 | 345 | switch(reg=READ_OP()) { |
| 287 | 346 | case 0: case 1: case 2: case 3: case 4: |
| r2724 | r2725 | |
| 290 | 349 | case 8: case 9: case 0xa: case 0xb: case 0xc: |
| 291 | 350 | saturn_copy(R0+(reg&7),0,saturn.p+1,C); |
| 292 | 351 | break; //r0=c wp |
| 352 | default: | |
| 353 | saturn_invalid6( 8, 1, 0xa, adr, op, reg); | |
| 354 | break; | |
| 293 | 355 | } |
| 294 | 356 | break; |
| 295 | 357 | case 1: |
| r2724 | r2725 | |
| 300 | 362 | case 8: case 9: case 0xa: case 0xb: case 0xc: |
| 301 | 363 | saturn_copy(C,0,saturn.p+1,R0+(reg&7)); |
| 302 | 364 | break; //c=r0 wp |
| 365 | default: | |
| 366 | saturn_invalid6( 8, 1, 0xa, adr, op, reg); | |
| 367 | break; | |
| 303 | 368 | } |
| 304 | 369 | break; |
| 305 | 370 | case 2: |
| r2724 | r2725 | |
| 310 | 375 | case 8: case 9: case 0xa: case 0xb: case 0xc: |
| 311 | 376 | saturn_exchange(C, 0, saturn.p+1, R0+(reg&7)); |
| 312 | 377 | break; // cr0ex wp |
| 378 | default: | |
| 379 | saturn_invalid6( 8, 1, 0xa, adr, op, reg); | |
| 380 | break; | |
| 313 | 381 | } |
| 314 | 382 | break; |
| 383 | default: | |
| 384 | saturn_invalid5( 8, 1, 0xa, adr, op ); | |
| 385 | break; | |
| 315 | 386 | } |
| 316 | 387 | break; |
| 317 | 388 | case 2: case 3: case 4: case 5: case 6: case 7: case 0xf: |
| 318 | switch(READ_OP()) { | |
| 389 | switch(op=READ_OP()) { | |
| 319 | 390 | case 0: |
| 320 | 391 | switch(reg=READ_OP()) { |
| 321 | 392 | case 0: case 1: case 2: case 3: case 4: |
| r2724 | r2725 | |
| 324 | 395 | case 8: case 9: case 0xa: case 0xb: case 0xc: |
| 325 | 396 | saturn_copy(R0+(reg&7),adr_af_begin[adr], adr_af_count[adr],C); |
| 326 | 397 | break; //r0=c xs |
| 398 | default: | |
| 399 | saturn_invalid6( 8, 1, 0xa, adr, op, reg); | |
| 400 | break; | |
| 327 | 401 | } |
| 328 | 402 | break; |
| 329 | 403 | case 1: |
| r2724 | r2725 | |
| 334 | 408 | case 8: case 9: case 0xa: case 0xb: case 0xc: |
| 335 | 409 | saturn_copy(C,adr_af_begin[adr],adr_af_count[adr],R0+(reg&7)); |
| 336 | 410 | break; //c=r0 xs |
| 411 | default: | |
| 412 | saturn_invalid6( 8, 1, 0xa, adr, op, reg); | |
| 413 | break; | |
| 337 | 414 | } |
| 338 | 415 | break; |
| 339 | 416 | case 2: |
| r2724 | r2725 | |
| 344 | 421 | case 8: case 9: case 0xa: case 0xb: case 0xc: |
| 345 | 422 | saturn_exchange(C, adr_af_begin[adr], adr_af_count[adr], R0+(reg&7)); |
| 346 | 423 | break; // cr0ex xs |
| 424 | default: | |
| 425 | saturn_invalid6( 8, 1, 0xa, adr, op, reg); | |
| 426 | break; | |
| 347 | 427 | } |
| 348 | 428 | break; |
| 429 | default: | |
| 430 | saturn_invalid5( 8, 1, 0xa, adr, op ); | |
| 431 | break; | |
| 349 | 432 | } |
| 350 | 433 | break; |
| 434 | default: | |
| 435 | saturn_invalid4( 8, 1, 0xa, adr ); | |
| 436 | break; | |
| 351 | 437 | } |
| 352 | 438 | } |
| 353 | 439 | |
| r2724 | r2725 | |
| 368 | 454 | saturn_add_const(A+reg, saturn.p, 1, READ_OP()+1); |
| 369 | 455 | break; |
| 370 | 456 | case 8: case 9: case 0xa: case 0xb: |
| 371 | saturn_sub_const(A+reg, saturn.p, 1, READ_OP()+1); | |
| 457 | saturn_sub_const(A+(reg&3), saturn.p, 1, READ_OP()+1); | |
| 372 | 458 | break; |
| 459 | default: | |
| 460 | saturn_invalid5( 8, 1, 8, adr, reg ); | |
| 461 | break; | |
| 373 | 462 | } |
| 374 | 463 | break; |
| 375 | 464 | case 1: |
| 376 | 465 | switch (reg=READ_OP()) { |
| 377 | 466 | case 0: case 1: case 2: case 3: |
| 378 | saturn_add_const(A+reg, | |
| 467 | saturn_add_const(A+reg, 0, saturn.p+1, READ_OP()+1); | |
| 379 | 468 | break; |
| 380 | 469 | case 8: case 9: case 0xa: case 0xb: |
| 381 | saturn_sub_const(A+reg, | |
| 470 | saturn_sub_const(A+(reg&3), 0, saturn.p+1, READ_OP()+1); | |
| 382 | 471 | break; |
| 472 | default: | |
| 473 | saturn_invalid5( 8, 1, 8, adr, reg ); | |
| 474 | break; | |
| 383 | 475 | } |
| 384 | 476 | break; |
| 385 | 477 | case 2: case 3: case 4: case 5: case 6: case 7: case 0xf: |
| r2724 | r2725 | |
| 388 | 480 | saturn_add_const(A+reg, adr_af_begin[adr], adr_af_count[adr], READ_OP()+1); |
| 389 | 481 | break; |
| 390 | 482 | case 8: case 9: case 0xa: case 0xb: |
| 391 | saturn_sub_const(A+reg, adr_af_begin[adr], adr_af_count[adr], READ_OP()+1); | |
| 483 | saturn_sub_const(A+(reg&3), adr_af_begin[adr], adr_af_count[adr], READ_OP()+1); | |
| 392 | 484 | break; |
| 485 | default: | |
| 486 | saturn_invalid5( 8, 1, 8, adr, reg ); | |
| 487 | break; | |
| 393 | 488 | } |
| 394 | 489 | break; |
| 490 | default: | |
| 491 | saturn_invalid4( 8, 1, 8, adr ); | |
| 492 | break; | |
| 395 | 493 | } |
| 396 | 494 | break; |
| 397 | 495 | case 9: |
| r2724 | r2725 | |
| 401 | 499 | case 0: case 1: case 2: case 3: |
| 402 | 500 | saturn_shift_right(A+reg,saturn.p,1); |
| 403 | 501 | break; // asrb p |
| 502 | default: | |
| 503 | saturn_invalid5( 8, 1, 9, adr, reg ); | |
| 504 | break; | |
| 404 | 505 | } |
| 405 | 506 | break; |
| 406 | 507 | case 1: |
| r2724 | r2725 | |
| 408 | 509 | case 0: case 1: case 2: case 3: |
| 409 | 510 | saturn_shift_right(A+reg, 0,saturn.p+1); |
| 410 | 511 | break; // asrb wp |
| 512 | default: | |
| 513 | saturn_invalid5( 8, 1, 9, adr, reg ); | |
| 514 | break; | |
| 411 | 515 | } |
| 412 | 516 | break; |
| 413 | case 2: | |
| 517 | case 2: | |
| 414 | 518 | switch(reg=READ_OP()){ |
| 415 | 519 | case 0: case 1: case 2: case 3: |
| 416 | 520 | saturn_shift_right(A+reg, adr_af_begin[adr], adr_af_count[adr]); |
| 417 | 521 | break; // asrb xs |
| 522 | default: | |
| 523 | saturn_invalid5( 8, 1, 9, adr, reg ); | |
| 524 | break; | |
| 418 | 525 | } |
| 419 | 526 | break; |
| 527 | default: | |
| 528 | saturn_invalid4( 8, 1, 9, adr ); | |
| 529 | break; | |
| 420 | 530 | } |
| 421 | 531 | break; |
| 422 | 532 | case 0xa: |
| 423 | 533 | saturn_instruction_81a(); |
| 424 | 534 | break; |
| 425 | 535 | case 0xb: |
| 426 | switch(READ_OP()) { | |
| 536 | switch(adr=READ_OP()) { | |
| 427 | 537 | case 2: saturn_load_pc(A);break; |
| 428 | 538 | case 3: saturn_load_pc(C);break; |
| 429 | 539 | case 4: saturn_store_pc(A);break; |
| 430 | 540 | case 5: saturn_store_pc(C);break; |
| 431 | 541 | case 6: saturn_exchange_pc(A);break; |
| 432 | 542 | case 7: saturn_exchange_pc(C);break; |
| 543 | default: saturn_invalid4( 8, 1, reg, adr ); break; | |
| 433 | 544 | } |
| 434 | 545 | break; |
| 435 | 546 | case 0xc: case 0xd: case 0xe: case 0xf: |
| r2724 | r2725 | |
| 440 | 551 | |
| 441 | 552 | static void saturn_instruction_8(void) |
| 442 | 553 | { |
| 443 | int oper; | |
| 554 | int oper, adr; | |
| 444 | 555 | |
| 445 | 556 | switch(READ_OP()) { |
| 446 | 557 | case 0: |
| r2724 | r2725 | |
| 489 | 600 | break; |
| 490 | 601 | } |
| 491 | 602 | break; |
| 492 | case 0xc: saturn_jump((READ_OP_DIS16()+saturn.pc-4)&0xfffff,1);break; | |
| 493 | case 0xd: saturn_jump(READ_OP_ARG20(),1);break; | |
| 494 | case 0xe: saturn_call((READ_OP_DIS16()+saturn.pc)&0xfffff);break; | |
| 495 | case 0xf: saturn_call(READ_OP_ARG20());break; | |
| 603 | case 0xc: | |
| 604 | adr=READ_OP_DIS16(); | |
| 605 | saturn_jump((adr+saturn.pc-4)&0xfffff,1); | |
| 606 | break; | |
| 607 | case 0xd: | |
| 608 | adr=READ_OP_ARG20(); | |
| 609 | saturn_jump(adr,1); | |
| 610 | break; | |
| 611 | case 0xe: | |
| 612 | adr=READ_OP_DIS16(); | |
| 613 | saturn_call((adr+saturn.pc)&0xfffff); | |
| 614 | break; | |
| 615 | case 0xf: | |
| 616 | adr=READ_OP_ARG20(); | |
| 617 | saturn_call(adr); | |
| 618 | break; | |
| 496 | 619 | } |
| 497 | 620 | } |
| 498 | 621 | |
| r2724 | r2725 | |
| 533 | 656 | break; |
| 534 | 657 | } |
| 535 | 658 | break; |
| 536 | case 2: case 3: case 4: case 5: | |
| 537 | case 6: case 7: | |
| 659 | case 2: case 3: case 4: case 5: case 6: case 7: | |
| 538 | 660 | switch(oper=READ_OP()) { |
| 539 | 661 | case 0: case 1: case 2: case 3: |
| 540 | 662 | saturn_equals(reg_left[oper&3] ,adr_a_begin[adr], adr_a_count[adr], reg_right[oper&3]); |
| r2724 | r2725 | |
| 612 | 734 | case 8: case 9: case 0xa: case 0xb: |
| 613 | 735 | saturn_add(add_left[reg], saturn.p, 1, add_right[reg]); |
| 614 | 736 | break; |
| 615 | break; | |
| 616 | 737 | case 4: case 5: case 6: case 7: |
| 617 | saturn_ | |
| 738 | saturn_add | |
| 618 | 739 | break; |
| 619 | 740 | case 0xc: case 0xd: case 0xe: case 0xf: |
| 620 | 741 | saturn_decrement(A+(reg&3), saturn.p, 1); |
| r2724 | r2725 | |
| 625 | 746 | switch (reg=READ_OP()) { |
| 626 | 747 | case 0: case 1: case 2: case 3: |
| 627 | 748 | case 8: case 9: case 0xa: case 0xb: |
| 628 | saturn_add(add_left[reg], | |
| 749 | saturn_add(add_left[reg], 0, saturn.p+1, add_right[reg]); | |
| 629 | 750 | break; |
| 630 | 751 | case 4: case 5: case 6: case 7: |
| 631 | saturn_ | |
| 752 | saturn_add | |
| 632 | 753 | break; |
| 633 | 754 | case 0xc: case 0xd: case 0xe: case 0xf: |
| 634 | saturn_decrement(A+(reg&3), | |
| 755 | saturn_decrement(A+(reg&3), 0, saturn.p+1); | |
| 635 | 756 | break; |
| 636 | 757 | } |
| 637 | 758 | break; |
| r2724 | r2725 | |
| 642 | 763 | saturn_add(add_left[reg], adr_a_begin[adr], adr_a_count[adr], add_right[reg]); |
| 643 | 764 | break; |
| 644 | 765 | case 4: case 5: case 6: case 7: |
| 645 | saturn_ | |
| 766 | saturn_add | |
| 646 | 767 | break; |
| 647 | 768 | case 0xc: case 0xd: case 0xe: case 0xf: |
| 648 | 769 | saturn_decrement(A+(reg&3), adr_a_begin[adr], adr_a_count[adr]); |
| r2724 | r2725 | |
| 656 | 777 | break; // a=0 p |
| 657 | 778 | case 4: case 5: case 6: case 7: |
| 658 | 779 | case 8: case 9: case 0xa: case 0xb: |
| 659 | saturn_copy(reg_right[reg&7], saturn.p,1,reg_left[reg&7]); | |
| 780 | saturn_copy(reg_right[reg&7], saturn.p,1,reg_left[reg&7]); | |
| 660 | 781 | break; // a=b p |
| 661 | 782 | case 0xc: case 0xd: case 0xe: case 0xf: |
| 662 | 783 | saturn_exchange(reg_left[reg&3], saturn.p,1,reg_right[reg&3]); |
| r2724 | r2725 | |
| 670 | 791 | break; // a=0 wp |
| 671 | 792 | case 4: case 5: case 6: case 7: |
| 672 | 793 | case 8: case 9: case 0xa: case 0xb: |
| 673 | saturn_copy(reg_right[reg&7], 0, saturn.p+1, reg_left[reg&7]); | |
| 794 | saturn_copy(reg_right[reg&7], 0, saturn.p+1, reg_left[reg&7]); | |
| 674 | 795 | break; // a=b wp |
| 675 | 796 | case 0xc: case 0xd: case 0xe: case 0xf: |
| 676 | 797 | saturn_exchange(reg_left[reg&3], 0, saturn.p+1, reg_right[reg&3]); |
| r2724 | r2725 | |
| 684 | 805 | break; // a=0 xs |
| 685 | 806 | case 4: case 5: case 6: case 7: |
| 686 | 807 | case 8: case 9: case 0xa: case 0xb: |
| 687 | saturn_copy(reg_right[reg&7], adr_b_begin[adr], adr_b_count[adr], | |
| 688 | reg_left[reg&7]); //correct | |
| 808 | saturn_copy(reg_right[reg&7], adr_b_begin[adr], adr_b_count[adr], reg_left[reg&7]); | |
| 689 | 809 | break; // a=b xs |
| 690 | 810 | case 0xc: case 0xd: case 0xe: case 0xf: |
| 691 | saturn_exchange(reg_left[reg&3], adr_b_begin[adr], adr_b_count[adr], | |
| 692 | reg_right[reg&3]); | |
| 811 | saturn_exchange(reg_left[reg&3], adr_b_begin[adr], adr_b_count[adr], reg_right[reg&3]); | |
| 693 | 812 | break; // abex xs |
| 694 | 813 | } |
| 695 | 814 | break; |
| r2724 | r2725 | |
| 705 | 824 | switch(reg=READ_OP()) { |
| 706 | 825 | case 0: case 1: case 2: case 3: |
| 707 | 826 | case 8: case 9: case 0xa: case 0xb: |
| 708 | saturn_sub(sub_left[reg], saturn.p, 1, | |
| 827 | saturn_sub(sub_left[reg], saturn.p, 1, | |
| 709 | 828 | break; |
| 710 | 829 | case 4: case 5: case 6: case 7: |
| 711 | 830 | saturn_increment(A+(reg&3), saturn.p, 1); break; // a=a+1 p |
| 712 | 831 | case 0xc: case 0xd: case 0xe: case 0xf: |
| 713 | saturn_sub2(sub_left[reg], saturn.p, 1, | |
| 832 | saturn_sub2(sub_left[reg], saturn.p, 1, | |
| 714 | 833 | break; |
| 715 | 834 | } |
| 716 | 835 | break; |
| r2724 | r2725 | |
| 718 | 837 | switch(reg=READ_OP()) { |
| 719 | 838 | case 0: case 1: case 2: case 3: |
| 720 | 839 | case 8: case 9: case 0xa: case 0xb: |
| 721 | saturn_sub(sub_left[reg], | |
| 840 | saturn_sub(sub_left[reg], 0, saturn.p+1, sub_right[reg]); | |
| 722 | 841 | break; |
| 723 | 842 | case 4: case 5: case 6: case 7: |
| 724 | saturn_increment(A+(reg&3), | |
| 843 | saturn_increment(A+(reg&3), 0, saturn.p+1); break; // a=a+1 wp | |
| 725 | 844 | case 0xc: case 0xd: case 0xe: case 0xf: |
| 726 | saturn_sub2(sub_left[reg], | |
| 845 | saturn_sub2(sub_left[reg], 0, saturn.p+1, sub_right[reg]); | |
| 727 | 846 | break; |
| 728 | 847 | } |
| 729 | 848 | break; |
| r2724 | r2725 | |
| 731 | 850 | switch(reg=READ_OP()) { |
| 732 | 851 | case 0: case 1: case 2: case 3: |
| 733 | 852 | case 8: case 9: case 0xa: case 0xb: |
| 734 | saturn_sub(sub_left[reg], adr_a_begin[adr], adr_a_count[adr], | |
| 735 | sub_right[reg]); | |
| 853 | saturn_sub(sub_left[reg], adr_a_begin[adr], adr_a_count[adr], sub_right[reg]); | |
| 736 | 854 | break; |
| 737 | 855 | case 4: case 5: case 6: case 7: |
| 738 | 856 | saturn_increment(A+(reg&3), adr_a_begin[adr], adr_a_count[adr]); |
| r2724 | r2725 | |
| 750 | 868 | case 4: case 5: case 6: case 7: |
| 751 | 869 | saturn_shift_nibble_right(A+(reg&3), saturn.p, 1); break; // asr p |
| 752 | 870 | case 8: case 9: case 0xa: case 0xb: |
| 753 | saturn_ | |
| 871 | saturn_ | |
| 754 | 872 | case 0xc: case 0xd: case 0xe: case 0xf: |
| 755 | saturn_ne | |
| 873 | saturn_inver | |
| 756 | 874 | } |
| 757 | 875 | break; |
| 758 | 876 | case 9: |
| r2724 | r2725 | |
| 762 | 880 | case 4: case 5: case 6: case 7: |
| 763 | 881 | saturn_shift_nibble_right(A+(reg&3),0,saturn.p+1); break; // asr wp |
| 764 | 882 | case 8: case 9: case 0xa: case 0xb: |
| 765 | saturn_ | |
| 883 | saturn_ | |
| 766 | 884 | case 0xc: case 0xd: case 0xe: case 0xf: |
| 767 | saturn_ne | |
| 885 | saturn_inver | |
| 768 | 886 | } |
| 769 | 887 | break; |
| 770 | 888 | case 0xa: case 0xb: case 0xc: case 0xd: case 0xe: case 0xf: |
| r2724 | r2725 | |
| 776 | 894 | saturn_shift_nibble_right(A+(reg&3), adr_b_begin[adr], adr_b_count[adr]); |
| 777 | 895 | break; |
| 778 | 896 | case 8: case 9: case 0xa: case 0xb: |
| 779 | saturn_ | |
| 897 | saturn_ | |
| 780 | 898 | break; |
| 781 | 899 | case 0xc: case 0xd: case 0xe: case 0xf: |
| 782 | saturn_ne | |
| 900 | saturn_inver | |
| 783 | 901 | break; |
| 784 | 902 | } |
| 785 | 903 | break; |
| r2724 | r2725 | |
| 806 | 924 | case 9: saturn_st_to_c();break; |
| 807 | 925 | case 0xa: saturn_c_to_st();break; |
| 808 | 926 | case 0xb: saturn_exchange_c_st();break; |
| 809 | case 0xc: | |
| 810 | saturn_inc_p(); | |
| 811 | break; | |
| 812 | case 0xd: | |
| 813 | saturn_dec_p(); | |
| 814 | break; | |
| 927 | case 0xc: saturn_inc_p();break; | |
| 928 | case 0xd: saturn_dec_p();break; | |
| 929 | case 0xe: saturn_instruction_0e();break; | |
| 815 | 930 | case 0xf: saturn_return_interrupt();break; |
| 816 | case 0xe: | |
| 817 | saturn_instruction_0e(); | |
| 818 | break; | |
| 819 | 931 | } |
| 820 | 932 | break; |
| 821 | 933 | case 1: |
| r2724 | r2725 | |
| 824 | 936 | case 2: |
| 825 | 937 | saturn_load_p(); |
| 826 | 938 | break; |
| 827 | case 3: saturn_load_reg(C);break; // lc | |
| 939 | case 3: | |
| 940 | saturn_load_reg(C); | |
| 941 | break; // lc | |
| 828 | 942 | case 4: |
| 829 | 943 | adr=READ_OP_DIS8(); |
| 830 | 944 | if (adr==0) { |
| 831 | 945 | saturn_return(saturn.carry); |
| 832 | } else { | |
| 946 | } | |
| 947 | else { | |
| 833 | 948 | saturn_jump((saturn.pc+adr-2)&0xfffff, saturn.carry); |
| 834 | 949 | } |
| 835 | 950 | break; |
| r2724 | r2725 | |
| 837 | 952 | adr=READ_OP_DIS8(); |
| 838 | 953 | if (adr==0) { |
| 839 | 954 | saturn_return(!saturn.carry); |
| 840 | } else { | |
| 955 | } | |
| 956 | else { | |
| 841 | 957 | saturn_jump((saturn.pc+adr-2)&0xfffff,!saturn.carry); |
| 842 | 958 | } |
| 843 | 959 | break; |
| r2724 | r2725 | |
| 866 | 982 | saturn_add(add_left[reg], BEGIN_A, COUNT_A, add_right[reg]); |
| 867 | 983 | break; |
| 868 | 984 | case 4: case 5: case 6: case 7: |
| 869 | saturn_ | |
| 985 | saturn_add | |
| 870 | 986 | break; |
| 871 | 987 | case 0xc: case 0xd: case 0xe: case 0xf: |
| 872 | 988 | saturn_decrement(A+(reg&3), BEGIN_A, COUNT_A); |
| r2724 | r2725 | |
| 880 | 996 | break; // a=0 a |
| 881 | 997 | case 4: case 5: case 6: case 7: |
| 882 | 998 | case 8: case 9: case 0xa: case 0xb: |
| 883 | saturn_copy(reg_right[reg&7], BEGIN_A, COUNT_A, reg_left[reg&7]); | |
| 999 | saturn_copy(reg_right[reg&7], BEGIN_A, COUNT_A, reg_left[reg&7]); | |
| 884 | 1000 | break; // a=b a |
| 885 | 1001 | case 0xc: case 0xd: case 0xe: case 0xf: |
| 886 | 1002 | saturn_exchange(reg_left[reg&3], BEGIN_A, COUNT_A, reg_right[reg&3]); |
| r2724 | r2725 | |
| 891 | 1007 | switch(reg=READ_OP()) { |
| 892 | 1008 | case 0: case 1: case 2: case 3: |
| 893 | 1009 | case 8: case 9: case 0xa: case 0xb: |
| 894 | saturn_sub(sub_left[reg], BEGIN_A, COUNT_A, | |
| 1010 | saturn_sub(sub_left[reg], BEGIN_A, COUNT_A, | |
| 895 | 1011 | break; |
| 896 | 1012 | case 4: case 5: case 6: case 7: |
| 897 | 1013 | saturn_increment(A+(reg&3), BEGIN_A, COUNT_A); |
| 898 | 1014 | break; // a=a+1 a |
| 899 | 1015 | case 0xc: case 0xd: case 0xe: case 0xf: |
| 900 | saturn_sub2(sub_left[reg], BEGIN_A, COUNT_A, | |
| 1016 | saturn_sub2(sub_left[reg], BEGIN_A, COUNT_A, | |
| 901 | 1017 | break; |
| 902 | 1018 | } |
| 903 | 1019 | break; |
| r2724 | r2725 | |
| 910 | 1026 | saturn_shift_nibble_right(A+(reg&3),BEGIN_A, COUNT_A); |
| 911 | 1027 | break; // asr a |
| 912 | 1028 | case 8: case 9: case 0xa: case 0xb: |
| 913 | saturn_ | |
| 1029 | saturn_ | |
| 914 | 1030 | break; // A=-A a |
| 915 | 1031 | case 0xc: case 0xd: case 0xe: case 0xf: |
| 916 | saturn_ne | |
| 1032 | saturn_inver | |
| 917 | 1033 | break; // A=-A-1 a |
| 918 | 1034 | } |
| 919 | 1035 | break; |
| r2724 | r2725 | |
|---|---|---|
| 6 | 6 | * |
| 7 | 7 | * Copyright Peter Trauner, all rights reserved. |
| 8 | 8 | * |
| 9 | * Modified by Antoine Mine' | |
| 10 | * | |
| 9 | 11 | * - This source code is released as freeware for non-commercial purposes. |
| 10 | 12 | * - You are free to use and redistribute this code in modified or |
| 11 | 13 | * unmodified form, provided you list me in the credits. |
| r2724 | r2725 | |
| 49 | 51 | |
| 50 | 52 | typedef struct |
| 51 | 53 | { |
| 52 | void (*out)(int); | |
| 53 | int (*in)(void); | |
| 54 | void (*reset)(void); | |
| 55 | void (*config)(int v); | |
| 56 | void (*unconfig)(int v); | |
| 57 | int (*id)(void); | |
| 58 | void (*crc)(int addr, int data); | |
| 54 | void (*out)(running_machine*,int); | |
| 55 | int (*in)(running_machine*); | |
| 56 | void (*reset)(running_machine*); | |
| 57 | void (*config)(running_machine*,int v); | |
| 58 | void (*unconfig)(running_machine*,int v); | |
| 59 | int (*id)(running_machine*); | |
| 60 | void (*crc)(running_machine*,int addr, int data); | |
| 61 | void (*rsi)(running_machine*); | |
| 59 | 62 | } SATURN_CONFIG; |
| 60 | 63 | |
| 64 | enum { | |
| 65 | SATURN_A=1, SATURN_B, SATURN_C, SATURN_D, | |
| 66 | SATURN_R0, SATURN_R1, SATURN_R2, SATURN_R3, SATURN_R4, | |
| 67 | SATURN_RSTK0, SATURN_RSTK1, SATURN_RSTK2, SATURN_RSTK3, | |
| 68 | SATURN_RSTK4, SATURN_RSTK5, SATURN_RSTK6, SATURN_RSTK7, | |
| 69 | SATURN_PC, SATURN_D0, SATURN_D1, | |
| 70 | ||
| 71 | SATURN_P, | |
| 72 | SATURN_OUT, | |
| 73 | SATURN_CARRY, | |
| 74 | SATURN_ST, | |
| 75 | SATURN_HST, | |
| 76 | ||
| 77 | SATURN_IRQ_STATE, | |
| 78 | SATURN_SLEEPING, | |
| 79 | }; | |
| 80 | ||
| 81 | #define SATURN_IRQ_LINE 0 | |
| 82 | #define SATURN_NMI_LINE 1 | |
| 83 | #define SATURN_WAKEUP_LINE 2 | |
| 84 | ||
| 61 | 85 | #ifdef ENABLE_DEBUGGER |
| 62 | 86 | unsigned saturn_dasm(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram); |
| 63 | 87 | #endif /* ENABLE_DEBUGGER */ |
| r2724 | r2725 | |
|---|---|---|
| 1 | 1 | /***************************************************************************** |
| 2 | 2 | * |
| 3 | * saturn.c | |
| 3 | * saturnds.c | |
| 4 | 4 | * portable saturn emulator interface |
| 5 | 5 | * (hp calculators) |
| 6 | 6 | * |
| 7 | 7 | * Copyright Peter Trauner, all rights reserved. |
| 8 | 8 | * |
| 9 | * Modified by Antoine Mine' | |
| 10 | * | |
| 9 | 11 | * - This source code is released as freeware for non-commercial purposes. |
| 10 | 12 | * - You are free to use and redistribute this code in modified or |
| 11 | 13 | * unmodified form, provided you list me in the credits. |
| r2724 | r2725 | |
| 24 | 26 | #include "debugger.h" |
| 25 | 27 | |
| 26 | 28 | #include "saturn.h" |
| 27 | #include "sat.h" | |
| 28 | 29 | |
| 30 | #define SATURN_HP_MNEMONICS | |
| 31 | ||
| 29 | 32 | #if defined SATURN_HP_MNEMONICS |
| 30 | 33 | // class/hp mnemonics |
| 31 | 34 | static int set=0; |
| r2724 | r2725 | |
| 51 | 54 | { P, WP, XS, X, S, M, B, W, 0, 0, 0, 0, 0, 0, 0, A }; |
| 52 | 55 | |
| 53 | 56 | static const char *const adr_a[]= |
| 54 | { P, WP, XS, X, S, M, B, W }; | |
| 57 | { P, WP, XS, X, S, M, B, W }; | |
| 55 | 58 | |
| 56 | 59 | static const char number_2_hex[]= |
| 57 | 60 | { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' }; |
| r2724 | r2725 | |
| 80 | 83 | CcopyP, PcopyC, sreq, CswapP, |
| 81 | 84 | |
| 82 | 85 | inton, AloadImm, buscb, |
| 83 | clearAbit, setAbit, Abitclear, Abitset, | |
| 84 | clearCbit, setCbit, Cbitclear, Cbitset, | |
| 86 | clearAbit, setAbit, | |
| 87 | branchAbitclear, returnAbitclear, | |
| 88 | branchAbitset, returnAbitset, | |
| 89 | clearCbit, setCbit, | |
| 90 | branchCbitclear, returnCbitclear, | |
| 91 | branchCbitset, returnCbitset, | |
| 85 | 92 | PCloadA, buscd, PCloadC, intoff, rsi, |
| 86 | 93 | |
| 87 | 94 | jumpA, jumpC, PCcopyA, PCcopyC, AcopyPC, CcopyPC, |
| r2724 | r2725 | |
| 132 | 139 | branchDnotgreaterC, returnDnotgreaterC, |
| 133 | 140 | |
| 134 | 141 | SetHexMode, SetDecMode, |
| 135 | P | |
| 142 | PushC, Pop | |
| 136 | 143 | |
| 137 | 144 | D0loadImm2, D0loadImm4, D0loadImm5, |
| 138 | 145 | D1loadImm2, D1loadImm4, D1loadImm5, |
| r2724 | r2725 | |
| 232 | 239 | { { "Abit=0 %x", "CLRB %x,A" } }, |
| 233 | 240 | { { "Abit=1 %x", "SETB %x,A" } }, |
| 234 | 241 | { { "?Abit=0 %x,%05x", "BRBC %x,A,%05x" } }, |
| 242 | { { "?Abit=0 %x,rtn", "RETBC %x,A" } }, | |
| 235 | 243 | { { "?Abit=1 %x,%05x", "BRBS %x,A,%05x" } }, |
| 244 | { { "?Abit=1 %x,rtn", "RETBS %x,A" } }, | |
| 236 | 245 | { { "Cbit=0 %x", "CLRB %x,C" } }, |
| 237 | 246 | { { "Cbit=1 %x", "SETB %x,C" } }, |
| 238 | 247 | { { "?Cbit=0 %x,%05x", "BRBC %x,C,%05x" } }, |
| 248 | { { "?Cbit=0 %x,rtn", "RETBC %x,C" } }, | |
| 239 | 249 | { { "?Cbit=1 %x,%05x", "BRBS %x,C,%05x" } }, |
| 250 | { { "?Cbit=1 %x,rtn", "RETBS %x,C" } }, | |
| 240 | 251 | { { "PC=(A)", "JUMP.A @A" } }, |
| 241 | 252 | { { "!buscd", "!BUSCD" } }, |
| 242 | 253 | { { "PC=(C)", "JUMP.A @C" } }, |
| r2724 | r2725 | |
| 252 | 263 | |
| 253 | 264 | { { "HST=0 %x", "CLRHST %x" } }, |
| 254 | 265 | { { "?HST=0 %x,%05x", "BRBCHST %x,%05x" } }, |
| 255 | { { "?HST=0 %x", "RETBCHST %x" } }, | |
| 266 | { { "?HST=0 %x,rtn", "RETBCHST %x" } }, | |
| 256 | 267 | { { "ST=0 %x", "CLRB %x,ST" } }, |
| 257 | 268 | { { "ST=1 %x", "SETB %x,ST" } }, |
| 258 | 269 | { { "?ST=0 %x,%05x", "BRBC ST,%x,%05x" } }, |
| 259 | { { "?ST=0 %x", "RETBC ST,%x" } }, | |
| 270 | { { "?ST=0 %x,rtn", "RETBC ST,%x" } }, | |
| 260 | 271 | { { "?ST=1 %x,%05x", "BRBS ST,%x,%05x" } }, |
| 261 | { { "?ST=1 %x", "RETBS ST,%x" } }, | |
| 272 | { { "?ST=1 %x,rtn", "RETBS ST,%x" } }, | |
| 262 | 273 | { { "?P# %x,%05x", "BRNE P,%x,%05x" } }, |
| 263 | { { "?P# %x", "RETNE P,%x" } }, | |
| 274 | { { "?P# %x,rtn", "RETNE P,%x" } }, | |
| 264 | 275 | { { "?P= %x,%05x", "BREQ P,%x,%05x" } }, |
| 265 | { { "?P= %x", "RETEQ P,%x" } }, | |
| 276 | { { "?P= %x,rtn", "RETEQ P,%x" } }, | |
| 266 | 277 | |
| 267 | { { "?A=B %x,%05x", "BREQ.%-2s A,B,%05x" } }, | |
| 268 | { { "?A=B %x", "RETEQ.%-2s A,B" } }, | |
| 269 | { { "?B=C %x,%05x", "BREQ.%-2s B,C,%05x" } }, | |
| 270 | { { "?B=C %x", "RETEQ.%-2s B,C" } }, | |
| 271 | { { "?A=C %x,%05x", "BREQ.%-2s A,C,%05x" } }, | |
| 272 | { { "?A=C %x", "RETEQ.%-2s A,C" } }, | |
| 273 | { { "?C=D %x,%05x", "BREQ.%-2s C,D,%05x" } }, | |
| 274 | { { "?C=D %x", "RETEQ.%-2s C,D" } }, | |
| 275 | { { "?A#B %x,%05x", "BRNE.%-2s A,B,%05x" } }, | |
| 276 | { { "?A#B %x", "RETNE.%-2s A,B" } }, | |
| 277 | { { "?B#C %x,%05x", "BRNE.%-2s B,C,%05x" } }, | |
| 278 | { { "?B#C %x", "RETNE.%-2s B,C" } }, | |
| 279 | { { "?A#C %x,%05x", "BRNE.%-2s A,C,%05x" } }, | |
| 280 | { { "?A#C %x", "RETNE.%-2s A,C" } }, | |
| 281 | { { "?C#D %x,%05x", "BRNE.%-2s C,D,%05x" } }, | |
| 282 | { { "?C#D %x", "RETNE.%-2s C,D" } }, | |
| 283 | { { "?A=0 %x,%05x", "BRZ.%-2s A,%05x" } }, | |
| 284 | { { "?A=0 %x", "RETZ.%-2s A" } }, | |
| 285 | { { "?B=0 %x,%05x", "BRZ.%-2s B,%05x" } }, | |
| 286 | { { "?B=0 %x", "RETZ.%-2s B" } }, | |
| 287 | { { "?C=0 %x,%05x", "BRZ.%-2s C,%05x" } }, | |
| 288 | { { "?C=0 %x", "RETZ.%-2s C" } }, | |
| 289 | { { "?D=0 %x,%05x", "BRZ.%-2s D,%05x" } }, | |
| 290 | { { "?D=0 %x", "RETZ.%-2s D" } }, | |
| 291 | { { "?A#0 %x,%05x", "BRNZ.%-2s A,%05x" } }, | |
| 292 | { { "?A#0 %x", "RETNZ.%-2s A" } }, | |
| 293 | { { "?B#0 %x,%05x", "BRNZ.%-2s B,%05x" } }, | |
| 294 | { { "?B#0 %x", "RETNZ.%-2s B" } }, | |
| 295 | { { "?C#0 %x,%05x", "BRNZ.%-2s C,%05x" } }, | |
| 296 | { { "?C#0 %x", "RETNZ.%-2s C" } }, | |
| 297 | { { "?D#0 %x,%05x", "BRNZ.%-2s D,%05x" } }, | |
| 298 | { { "?D#0 %x", "RETNZ.%-2s D" } }, | |
| 278 | { { "?A=B %s,%05x", "BREQ.%-2s A,B,%05x" } }, | |
| 279 | { { "?A=B %s,rtn", "RETEQ.%-2s A,B" } }, | |
| 280 | { { "?B=C %s,%05x", "BREQ.%-2s B,C,%05x" } }, | |
| 281 | { { "?B=C %s,rtn", "RETEQ.%-2s B,C" } }, | |
| 282 | { { "?A=C %s,%05x", "BREQ.%-2s A,C,%05x" } }, | |
| 283 | { { "?A=C %s,rtn", "RETEQ.%-2s A,C" } }, | |
| 284 | { { "?C=D %s,%05x", "BREQ.%-2s C,D,%05x" } }, | |
| 285 | { { "?C=D %s,rtn", "RETEQ.%-2s C,D" } }, | |
| 286 | { { "?A#B %s,%05x", "BRNE.%-2s A,B,%05x" } }, | |
| 287 | { { "?A#B %s,rtn", "RETNE.%-2s A,B" } }, | |
| 288 | { { "?B#C %s,%05x", "BRNE.%-2s B,C,%05x" } }, | |
| 289 | { { "?B#C %s,rtn", "RETNE.%-2s B,C" } }, | |
| 290 | { { "?A#C %s,%05x", "BRNE.%-2s A,C,%05x" } }, | |
| 291 | { { "?A#C %s,rtn", "RETNE.%-2s A,C" } }, | |
| 292 | { { "?C#D %s,%05x", "BRNE.%-2s C,D,%05x" } }, | |
| 293 | { { "?C#D %s,rtn", "RETNE.%-2s C,D" } }, | |
| 294 | { { "?A=0 %s,%05x", "BRZ.%-2s A,%05x" } }, | |
| 295 | { { "?A=0 %s,rtn", "RETZ.%-2s A" } }, | |
| 296 | { { "?B=0 %s,%05x", "BRZ.%-2s B,%05x" } }, | |
| 297 | { { "?B=0 %s,rtn", "RETZ.%-2s B" } }, | |
| 298 | { { "?C=0 %s,%05x", "BRZ.%-2s C,%05x" } }, | |
| 299 | { { "?C=0 %s,rtn", "RETZ.%-2s C" } }, | |
| 300 | { { "?D=0 %s,%05x", "BRZ.%-2s D,%05x" } }, | |
| 301 | { { "?D=0 %s,rtn", "RETZ.%-2s D" } }, | |
| 302 | { { "?A#0 %s,%05x", "BRNZ.%-2s A,%05x" } }, | |
| 303 | { { "?A#0 %s,rtn", "RETNZ.%-2s A" } }, | |
| 304 | { { "?B#0 %s,%05x", "BRNZ.%-2s B,%05x" } }, | |
| 305 | { { "?B#0 %s,rtn", "RETNZ.%-2s B" } }, | |
| 306 | { { "?C#0 %s,%05x", "BRNZ.%-2s C,%05x" } }, | |
| 307 | { { "?C#0 %s,rtn", "RETNZ.%-2s C" } }, | |
| 308 | { { "?D#0 %s,%05x", "BRNZ.%-2s D,%05x" } }, | |
| 309 | { { "?D#0 %s,rtn", "RETNZ.%-2s D" } }, | |
| 299 | 310 | |
| 300 | { { "?A>B %x,%05x", "BRGT.%-2s A,B,%05x" } }, | |
| 301 | { { "?A>B %x", "RETGT.%-2s A,B" } }, | |
| 302 | { { "?B>C %x,%05x", "BRGT.%-2s B,C,%05x" } }, | |
| 303 | { { "?B>C %x", "RETGT.%-2s B,C" } }, | |
| 304 | { { "?C>A %x,%05x", "BRGT.%-2s C,A,%05x" } }, | |
| 305 | { { "?C>A %x", "RETGT.%-2s C,A" } }, | |
| 306 | { { "?D>C %x,%05x", "BRGT.%-2s D,C,%05x" } }, | |
| 307 | { { "?D>C %x", "RETGT.%-2s D,C" } }, | |
| 308 | { { "?A<B %x,%05x", "BRLT.%-2s A,B,%05x" } }, | |
| 309 | { { "?A<B %x", "RETLT.%-2s A,B" } }, | |
| 310 | { { "?B<C %x,%05x", "BRLT.%-2s B,C,%05x" } }, | |
| 311 | { { "?B<C %x", "RETLT.%-2s B,C" } }, | |
| 312 | { { "?C<A %x,%05x", "BRLT.%-2s C,A,%05x" } }, | |
| 313 | { { "?C<A %x", "RETLT.%-2s C,A" } }, | |
| 314 | { { "?D<C %x,%05x", "BRLT.%-2s D,C,%05x" } }, | |
| 315 | { { "?D<C %x", "RETLT.%-2s D,C" } }, | |
| 316 | { { "?A>=B %x,%05x", "BRGE.%-2s A,B,%05x" } }, | |
| 317 | { { "?A>=B %x", "RETGE.%-2s A,B" } }, | |
| 318 | { { "?B>=C %x,%05x", "BRGE.%-2s B,C,%05x" } }, | |
| 319 | { { "?B>=C %x", "RETGE.%-2s B,C" } }, | |
| 320 | { { "?C>=A %x,%05x", "BRGE.%-2s C,A,%05x" } }, | |
| 321 | { { "?C>=A %x", "RETGE.%-2s C,A" } }, | |
| 322 | { { "?D>=C %x,%05x", "BRGE.%-2s D,C,%05x" } }, | |
| 323 | { { "?D>=C %x", "RETGE.%-2s D,C" } }, | |
| 324 | { { "?A<=B %x,%05x", "BRLE.%-2s A,B,%05x" } }, | |
| 325 | { { "?A<=B %x", "RETLE.%-2s A,B" } }, | |
| 326 | { { "?B<=C %x,%05x", "BRLE.%-2s B,C,%05x" } }, | |
| 327 | { { "?B<=C %x", "RETLE.%-2s B,C" } }, | |
| 328 | { { "?C<=A %x,%05x", "BRLE.%-2s C,A,%05x" } }, | |
| 329 | { { "?C<=A %x", "RETLE.%-2s C,A" } }, | |
| 330 | { { "?D<=C %x,%05x", "BRLE.%-2s D,C,%05x" } }, | |
| 331 | { { "?D<=C %x", "RETLE.%-2s D,C" } }, | |
| 311 | { { "?A>B %s,%05x", "BRGT.%-2s A,B,%05x" } }, | |
| 312 | { { "?A>B %s,rtn", "RETGT.%-2s A,B" } }, | |
| 313 | { { "?B>C %s,%05x", "BRGT.%-2s B,C,%05x" } }, | |
| 314 | { { "?B>C %s,rtn", "RETGT.%-2s B,C" } }, | |
| 315 | { { "?C>A %s,%05x", "BRGT.%-2s C,A,%05x" } }, | |
| 316 | { { "?C>A %s,rtn", "RETGT.%-2s C,A" } }, | |
| 317 | { { "?D>C %s,%05x", "BRGT.%-2s D,C,%05x" } }, | |
| 318 | { { "?D>C %s,rtn", "RETGT.%-2s D,C" } }, | |
| 319 | { { "?A<B %s,%05x", "BRLT.%-2s A,B,%05x" } }, | |
| 320 | { { "?A<B %s,rtn", "RETLT.%-2s A,B" } }, | |
| 321 | { { "?B<C %s,%05x", "BRLT.%-2s B,C,%05x" } }, | |
| 322 | { { "?B<C %s,rtn", "RETLT.%-2s B,C" } }, | |
| 323 | { { "?C<A %s,%05x", "BRLT.%-2s C,A,%05x" } }, | |
| 324 | { { "?C<A %s,rtn", "RETLT.%-2s C,A" } }, | |
| 325 | { { "?D<C %s,%05x", "BRLT.%-2s D,C,%05x" } }, | |
| 326 | { { "?D<C %s,rtn", "RETLT.%-2s D,C" } }, | |
| 327 | { { "?A>=B %s,%05x", "BRGE.%-2s A,B,%05x" } }, | |
| 328 | { { "?A>=B %s,rtn", "RETGE.%-2s A,B" } }, | |
| 329 | { { "?B>=C %s,%05x", "BRGE.%-2s B,C,%05x" } }, | |
| 330 | { { "?B>=C %s,rtn", "RETGE.%-2s B,C" } }, | |
| 331 | { { "?C>=A %s,%05x", "BRGE.%-2s C,A,%05x" } }, | |
| 332 | { { "?C>=A %s,rtn", "RETGE.%-2s C,A" } }, | |
| 333 | { { "?D>=C %s,%05x", "BRGE.%-2s D,C,%05x" } }, | |
| 334 | { { "?D>=C %s,rtn", "RETGE.%-2s D,C" } }, | |
| 335 | { { "?A<=B %s,%05x", "BRLE.%-2s A,B,%05x" } }, | |
| 336 | { { "?A<=B %s,rtn", "RETLE.%-2s A,B" } }, | |
| 337 | { { "?B<=C %s,%05x", "BRLE.%-2s B,C,%05x" } }, | |
| 338 | { { "?B<=C %s,rtn", "RETLE.%-2s B,C" } }, | |
| 339 | { { "?C<=A %s,%05x", "BRLE.%-2s C,A,%05x" } }, | |
| 340 | { { "?C<=A %s,rtn", "RETLE.%-2s C,A" } }, | |
| 341 | { { "?D<=C %s,%05x", "BRLE.%-2s D,C,%05x" } }, | |
| 342 | { { "?D<=C %s,rtn", "RETLE.%-2s D,C" } }, | |
| 332 | 343 | |
| 333 | 344 | { { "sethex", "SETHEX" } }, |
| 334 | 345 | { { "setdec", "SETDEC" } }, |
| r2724 | r2725 | |
| 456 | 467 | { { "A=A!C %s", "OR.%-2s C,A" } }, |
| 457 | 468 | { { "C=C!D %s", "OR.%-2s D,C" } }, |
| 458 | 469 | |
| 459 | { { "Asrb %x", "SRB.%-2s A" } }, | |
| 460 | { { "Bsrb %x", "SRB.%-2s B" } }, | |
| 461 | { { "Csrb %x", "SRB.%-2s C" } }, | |
| 462 | { { "Dsrb %x", "SRB.%-2s D" } }, | |
| 470 | { { "Asrb %s", "SRB.%-2s A" } }, | |
| 471 | { { "Bsrb %s", "SRB.%-2s B" } }, | |
| 472 | { { "Csrb %s", "SRB.%-2s C" } }, | |
| 473 | { { "Dsrb %s", "SRB.%-2s D" } }, | |
| 463 | 474 | |
| 464 | 475 | { { "Aslc %s", "RLN.%-2s A" } }, |
| 465 | 476 | { { "Bslc %s", "RLN.%-2s B" } }, |
| 466 | 477 | { { "Cslc %s", "RLN.%-2s C" } }, |
| 467 | 478 | { { "Dslc %s", "RLN.%-2s D" } }, |
| 468 | { { "Aslc %s", "RRN.%-2s A" } }, | |
| 469 | { { "Bslc %s", "RRN.%-2s B" } }, | |
| 470 | { { "Cslc %s", "RRN.%-2s C" } }, | |
| 471 | { { "Dslc %s", "RRN.%-2s D" } }, | |
| 479 | { { "Asrc %s", "RRN.%-2s A" } }, | |
| 480 | { { "Bsrc %s", "RRN.%-2s B" } }, | |
| 481 | { { "Csrc %s", "RRN.%-2s C" } }, | |
| 482 | { { "Dsrc %s", "RRN.%-2s D" } }, | |
| 472 | 483 | |
| 473 | 484 | { { "A=A+B %s", "ADD.%-2s B,A" } }, |
| 474 | 485 | { { "B=B+C %s", "ADD.%-2s C,B" } }, |
| r2724 | r2725 | |
| 566 | 577 | xBranchReturn, // address field specified in previous opcode entry |
| 567 | 578 | Imm, ImmCount, ImmCload, Imm2, Imm4, Imm5, |
| 568 | 579 | Dis3, Dis3Call, Dis4, Dis4Call, Abs, |
| 569 | FieldP, FieldWP, FieldXS, FieldX, FieldS, FieldM, FieldB, FieldW, FieldA | |
| 580 | FieldP, FieldWP, FieldXS, FieldX, FieldS, FieldM, FieldB, FieldW, FieldA, | |
| 581 | AdrImmCount | |
| 570 | 582 | } adr; |
| 571 | 583 | MNEMONICS mnemonic; |
| 572 | 584 | } OPCODE; |
| r2724 | r2725 | |
| 613 | 625 | { Complete, AdrNone, ReturnClearCarry }, |
| 614 | 626 | { Complete, AdrNone, SetHexMode }, |
| 615 | 627 | { Complete, AdrNone, SetDecMode }, |
| 628 | { Complete, AdrNone, PushC }, | |
| 616 | 629 | { Complete, AdrNone, PopC }, |
| 617 | { Complete, AdrNone, PushC }, | |
| 618 | 630 | { Complete, AdrNone, clearST }, |
| 619 | 631 | { Complete, AdrNone, CcopyST }, |
| 620 | 632 | { Complete, AdrNone, STcopyC }, |
| r2724 | r2725 | |
| 817 | 829 | { Complete, AdrNone, buscb }, |
| 818 | 830 | { Complete, Imm, clearAbit }, |
| 819 | 831 | { Complete, Imm, setAbit }, |
| 820 | { Complete, ImmBranch, Abitclear }, | |
| 821 | { Complete, ImmBranch, Abitset }, | |
| 832 | { Complete, TestBranchRet, branchAbitclear }, | |
| 833 | { Complete, TestBranchRet, branchAbitset }, | |
| 822 | 834 | { Complete, Imm, clearCbit }, |
| 823 | 835 | { Complete, Imm, setCbit }, |
| 824 | { Complete, ImmBranch, Cbitclear }, | |
| 825 | { Complete, ImmBranch, Cbitset }, | |
| 836 | { Complete, TestBranchRet, branchCbitclear }, | |
| 837 | { Complete, TestBranchRet, branchCbitset }, | |
| 826 | 838 | { Complete, AdrNone, PCloadA }, |
| 827 | 839 | { Complete, AdrNone, buscd }, |
| 828 | 840 | { Complete, AdrNone, PCloadC }, |
| r2724 | r2725 | |
| 833 | 845 | }, { //81 |
| 834 | 846 | { Complete, FieldW, AshiftleftCarry }, |
| 835 | 847 | { Complete, FieldW, BshiftleftCarry }, |
| 848 | { Complete, FieldW, CshiftleftCarry }, | |
| 836 | 849 | { Complete, FieldW, DshiftleftCarry }, |
| 837 | { Complete, FieldW, DshiftleftCarry }, | |
| 838 | 850 | { Complete, FieldW, AshiftrightCarry }, |
| 839 | { Complete, FieldW, AshiftrightCarry }, | |
| 840 | { Complete, FieldW, AshiftrightCarry }, | |
| 841 | { Complete, FieldW, AshiftrightCarry }, | |
| 851 | { Complete, FieldW, BshiftrightCarry }, | |
| 852 | { Complete, FieldW, CshiftrightCarry }, | |
| 853 | { Complete, FieldW, DshiftrightCarry }, | |
| 842 | 854 | { Opcode818 }, |
| 843 | 855 | { Opcode819 }, |
| 844 | 856 | { Opcode81A }, |
| r2724 | r2725 | |
| 865 | 877 | { Illegal }, |
| 866 | 878 | { Opcode818a, AdrAF }, |
| 867 | 879 | }, { //818a |
| 868 | { Complete, AdrNone, AaddImm }, | |
| 869 | { Complete, AdrNone, BaddImm }, | |
| 870 | { Complete, AdrNone, CaddImm }, | |
| 871 | { Complete, AdrNone, DaddImm }, | |
| 872 | { Complete, AdrNone, AsubImm }, | |
| 873 | { Complete, AdrNone, BsubImm }, | |
| 874 | { Complete, AdrNone, CsubImm }, | |
| 875 | { Complete, AdrNone, DsubImm } | |
| 876 | //! rest illegal | |
| 880 | { Complete, AdrImmCount, AaddImm }, | |
| 881 | { Complete, AdrImmCount, BaddImm }, | |
| 882 | { Complete, AdrImmCount, CaddImm }, | |
| 883 | { Complete, AdrImmCount, DaddImm }, | |
| 884 | { Illegal }, | |
| 885 | { Illegal }, | |
| 886 | { Illegal }, | |
| 887 | { Illegal }, | |
| 888 | { Complete, AdrImmCount, AsubImm }, | |
| 889 | { Complete, AdrImmCount, BsubImm }, | |
| 890 | { Complete, AdrImmCount, CsubImm }, | |
| 891 | { Complete, AdrImmCount, DsubImm }, | |
| 892 | { Illegal }, | |
| 893 | { Illegal }, | |
| 894 | { Illegal }, | |
| 895 | { Illegal }, | |
| 877 | 896 | }, { //819 |
| 878 | 897 | { Opcode819a, AdrAF }, |
| 879 | 898 | { Opcode819a, AdrAF }, |
| r2724 | r2725 | |
| 1269 | 1288 | |
| 1270 | 1289 | while (cont) |
| 1271 | 1290 | { |
| 1272 | op = oprom[pos++]; | |
| 1291 | op = oprom[pos++] & 0xf; | |
| 1273 | 1292 | level+=op; |
| 1274 | 1293 | switch (level->sel) { |
| 1275 | 1294 | case Illegal: |
| r2724 | r2725 | |
| 1311 | 1330 | case ImmCount: |
| 1312 | 1331 | sprintf(dst, mnemonics[level->mnemonic].name[set], oprom[pos++]+1); |
| 1313 | 1332 | break; |
| 1333 | case AdrImmCount: | |
| 1334 | sprintf(dst, mnemonics[level->mnemonic].name[set], field_2_string(adr), oprom[pos++]+1); | |
| 1335 | break; | |
| 1314 | 1336 | case AdrCount: // mnemonics have string %s for address field |
| 1315 | 1337 | snprintf(number,sizeof(number),"%x",oprom[pos++]+1); |
| 1316 | 1338 | sprintf(dst, mnemonics[level->mnemonic].name[set], number); |
| r2724 | r2725 | |
| 1336 | 1358 | sprintf(dst, mnemonics[level->mnemonic].name[set], v); |
| 1337 | 1359 | break; |
| 1338 | 1360 | case ImmCload: |
| 1339 | c=i=oprom[pos++]; | |
| 1361 | c=i=oprom[pos++] & 0xf; | |
| 1340 | 1362 | number[i+1]=0; |
| 1341 | for (;i>=0; i--) number[i]=number_2_hex[oprom[pos++]]; | |
| 1363 | for (;i>=0; i--) number[i]=number_2_hex[oprom[pos++] & 0xf]; | |
| 1342 | 1364 | sprintf(dst, mnemonics[level->mnemonic].name[set], c+1, number); |
| 1343 | 1365 | break; |
| 1344 | 1366 | case Dis3: |
| 1345 | 1367 | SATURN_PEEKOP_DIS12(v); |
| 1346 | c=(pc+pos-3+v) | |
| 1368 | c=(pc+pos-3+v)&0xfffff; | |
| 1347 | 1369 | sprintf(dst, mnemonics[level->mnemonic].name[set], c ); |
| 1348 | 1370 | break; |
| 1349 | 1371 | case Dis3Call: |
| 1350 | 1372 | SATURN_PEEKOP_DIS12(v); |
| 1351 | c=(pc+pos | |
| 1373 | c=(pc+pos | |
| 1352 | 1374 | sprintf(dst, mnemonics[level->mnemonic].name[set], c ); |
| 1353 | 1375 | break; |
| 1354 | 1376 | case Dis4: |
| 1355 | 1377 | SATURN_PEEKOP_DIS16(v); |
| 1356 | c=(pc+pos-4+v) | |
| 1378 | c=(pc+pos-4+v)&0xfffff; | |
| 1357 | 1379 | sprintf(dst, mnemonics[level->mnemonic].name[set], c ); |
| 1358 | 1380 | break; |
| 1359 | 1381 | case Dis4Call: |
| 1360 | 1382 | SATURN_PEEKOP_DIS16(v); |
| 1361 | c=(pc+pos | |
| 1383 | c=(pc+pos | |
| 1362 | 1384 | sprintf(dst, mnemonics[level->mnemonic].name[set], c ); |
| 1363 | 1385 | break; |
| 1364 | 1386 | case Abs: |
| r2724 | r2725 | |
| 1436 | 1458 | sprintf(dst, mnemonics[level->mnemonic].name[set], W ); |
| 1437 | 1459 | break; |
| 1438 | 1460 | case AdrA: |
| 1439 | sprintf(dst, mnemonics[level->mnemonic].name[set], adr_a[oprom[pos++]] ); | |
| 1461 | sprintf(dst, mnemonics[level->mnemonic].name[set], adr_a[oprom[pos++] & 0x7] ); | |
| 1440 | 1462 | break; |
| 1441 | 1463 | case AdrAF: |
| 1442 | sprintf(dst, mnemonics[level->mnemonic].name[set], adr_af[oprom[pos++]] ); | |
| 1464 | sprintf(dst, mnemonics[level->mnemonic].name[set], adr_af[oprom[pos++] & 0xf] ); | |
| 1443 | 1465 | break; |
| 1444 | 1466 | case AdrB: |
| 1445 | sprintf(dst, mnemonics[level->mnemonic].name[set], adr_b[oprom[pos++]&0x7] ); | |
| 1467 | sprintf(dst, mnemonics[level->mnemonic].name[set], adr_b[oprom[pos++] & 0x7] ); | |
| 1446 | 1468 | break; |
| 1447 | 1469 | } |
| 1448 | 1470 | break; |
| r2724 | r2725 | |
|---|---|---|
| 1 | 1 | #define IRQ_ADDRESS 0xf |
| 2 | 2 | |
| 3 | #define saturn_assert(x) \ | |
| 4 | do { if (!(x)) logerror("SATURN%d assertion failed: %s at %s:%i, pc=%05x\n", cpu_getactivecpu(), #x, __FILE__, __LINE__, saturn.pc); } while (0) | |
| 5 | ||
| 3 | 6 | INLINE int READ_OP(void) |
| 4 | 7 | { |
| 8 | UINT8 data; | |
| 5 | 9 | saturn_ICount-=3; |
| 6 | return cpu_readop(saturn.pc++); | |
| 10 | data=cpu_readop(saturn.pc); | |
| 11 | saturn_assert(data<0x10); | |
| 12 | saturn.pc=(saturn.pc+1)&0xfffff; | |
| 13 | return data; | |
| 7 | 14 | } |
| 8 | 15 | |
| 9 | 16 | INLINE int READ_OP_ARG(void) |
| 10 | 17 | { |
| 18 | UINT8 data; | |
| 11 | 19 | saturn_ICount-=3; |
| 12 | return cpu_readop_arg(saturn.pc++); | |
| 20 | data=cpu_readop_arg(saturn.pc); | |
| 21 | saturn_assert(data<0x10); | |
| 22 | saturn.pc=(saturn.pc+1)&0xfffff; | |
| 23 | return data; | |
| 13 | 24 | } |
| 14 | 25 | |
| 15 | 26 | INLINE int READ_OP_ARG8(void) |
| 16 | 27 | { |
| 17 | return READ_OP_ARG()|(READ_OP_ARG()<<4); | |
| 28 | int n0=READ_OP_ARG(); | |
| 29 | int n1=READ_OP_ARG(); | |
| 30 | return n0|(n1<<4); | |
| 18 | 31 | } |
| 19 | 32 | |
| 20 | 33 | INLINE INT8 READ_OP_DIS8(void) |
| 21 | 34 | { |
| 22 | return | |
| 35 | return | |
| 23 | 36 | } |
| 24 | 37 | |
| 25 | 38 | INLINE int READ_OP_ARG12(void) |
| 26 | 39 | { |
| 27 | return READ_OP_ARG()|(READ_OP_ARG()<<4)|(READ_OP_ARG()<<8); | |
| 40 | int n0=READ_OP_ARG(); | |
| 41 | int n1=READ_OP_ARG(); | |
| 42 | int n2=READ_OP_ARG(); | |
| 43 | return n0|(n1<<4)|(n2<<8); | |
| 28 | 44 | } |
| 29 | 45 | |
| 30 | 46 | INLINE int READ_OP_DIS12(void) |
| 31 | 47 | { |
| 32 | int temp=READ_OP_ARG()|(READ_OP_ARG()<<4)|(READ_OP_ARG()<<8); | |
| 33 | if (temp&0x800) return -0x1000+temp; | |
| 34 | else return temp; | |
| 48 | int temp=READ_OP_ARG12(); | |
| 49 | if (temp&0x800) temp-=0x1000; | |
| 50 | return temp; | |
| 35 | 51 | } |
| 36 | 52 | |
| 37 | 53 | INLINE int READ_OP_ARG16(void) |
| 38 | 54 | { |
| 39 | return READ_OP_ARG()|(READ_OP_ARG()<<4)|(READ_OP_ARG()<<8)|(READ_OP_ARG()<<12); | |
| 55 | int n0=READ_OP_ARG(); | |
| 56 | int n1=READ_OP_ARG(); | |
| 57 | int n2=READ_OP_ARG(); | |
| 58 | int n3=READ_OP_ARG(); | |
| 59 | return n0|(n1<<4)|(n2<<8)|(n3<<12); | |
| 40 | 60 | } |
| 41 | 61 | |
| 42 | 62 | INLINE INT16 READ_OP_DIS16(void) |
| 43 | 63 | { |
| 44 | return | |
| 64 | return | |
| 45 | 65 | } |
| 46 | 66 | |
| 47 | 67 | INLINE int READ_OP_ARG20(void) |
| 48 | 68 | { |
| 49 | return READ_OP_ARG()|(READ_OP_ARG()<<4)|(READ_OP_ARG()<<8) | |
| 50 | |(READ_OP_ARG()<<12)|(READ_OP_ARG()<<16); | |
| 69 | int n0=READ_OP_ARG(); | |
| 70 | int n1=READ_OP_ARG(); | |
| 71 | int n2=READ_OP_ARG(); | |
| 72 | int n3=READ_OP_ARG(); | |
| 73 | int n4=READ_OP_ARG(); | |
| 74 | return n0|(n1<<4)|(n2<<8)|(n3<<12)|(n4<<16); | |
| 51 | 75 | } |
| 52 | 76 | |
| 53 | 77 | INLINE int READ_NIBBLE(SaturnAdr adr) |
| 54 | 78 | { |
| 55 | | |
| 79 | UINT8 data; | |
| 56 | 80 | saturn_ICount-=3; |
| 57 | data = program_read_byte(adr); | |
| 58 | if (saturn.config&&saturn.config->crc) saturn.config->crc(adr, data); | |
| 81 | data=program_read_byte(adr&0xfffff); | |
| 82 | saturn_assert(data<0x10); | |
| 83 | if (saturn.config&&saturn.config->crc) saturn.config->crc(Machine, adr&0xfffff, data); | |
| 59 | 84 | return data; |
| 60 | 85 | } |
| 61 | 86 | |
| r2724 | r2725 | |
| 71 | 96 | |
| 72 | 97 | INLINE int READ_16(SaturnAdr adr) |
| 73 | 98 | { |
| 74 | return READ_NIBBLE(adr)|(READ_NIBBLE(adr+1)<<4) | |
| 75 | |(READ_NIBBLE(adr+2)<<8)|(READ_NIBBLE(adr+3)<<12); | |
| 99 | return READ_NIBBLE(adr)|(READ_NIBBLE(adr+1)<<4)|(READ_NIBBLE(adr+2)<<8)|(READ_NIBBLE(adr+3)<<12); | |
| 76 | 100 | } |
| 77 | 101 | |
| 78 | 102 | INLINE int READ_20(SaturnAdr adr) |
| 79 | 103 | { |
| 80 | return READ_NIBBLE(adr)|(READ_NIBBLE(adr+1)<<4) | |
| 81 | |(READ_NIBBLE(adr+2)<<8)|(READ_NIBBLE(adr+3)<<12)|(READ_NIBBLE(adr+4)<<16); | |
| 104 | return READ_NIBBLE(adr)|(READ_NIBBLE(adr+1)<<4)|(READ_NIBBLE(adr+2)<<8)|(READ_NIBBLE(adr+3)<<12)|(READ_NIBBLE(adr+4)<<16); | |
| 82 | 105 | } |
| 83 | 106 | |
| 84 | 107 | INLINE void WRITE_NIBBLE(SaturnAdr adr, SaturnNib nib) |
| 85 | 108 | { |
| 86 | saturn_ICount -= 3; | |
| 87 | program_write_byte(adr, nib); | |
| 109 | saturn_ICount-=3; | |
| 110 | saturn_assert(nib<0x10); | |
| 111 | program_write_byte(adr&0xfffff,nib); | |
| 88 | 112 | } |
| 89 | 113 | |
| 90 | #ifdef LSB_FIRST | |
| 91 | #define S64_BYTE(r, x) saturn.reg[r].b[x] | |
| 92 | #define S64_WORD(r, x) saturn.reg[r].w[x] | |
| 93 | #define S64_DOUBLE(r, x) saturn.reg[r].d[x] | |
| 94 | #else | |
| 95 | #define S64_BYTE(r, x) saturn.reg[r].b[7-x] | |
| 96 | #define S64_WORD(r, x) saturn.reg[r].w[3-x] | |
| 97 | #define S64_DOUBLE(r, x) saturn.reg[r].d[1-x] | |
| 98 | #endif | |
| 99 | ||
| 100 | #define S64_QUAD(r) saturn.reg[r].q | |
| 101 | ||
| 102 | 114 | #define BEGIN_B 0 |
| 103 | 115 | #define COUNT_B 2 |
| 104 | 116 | #define BEGIN_X 0 |
| r2724 | r2725 | |
| 114 | 126 | #define BEGIN_W 0 |
| 115 | 127 | #define COUNT_W 16 |
| 116 | 128 | |
| 117 | #define S64_READ_NIBBLE(r, x) (((x)&1) ? (S64_BYTE(r, ((x)>>1))>>4) : (S64_BYTE(r, ((x)>>1))&0xf) ) | |
| 118 | #define S64_WRITE_NIBBLE(r, x, v) \ | |
| 119 | (S64_BYTE(r, ((x)>>1)) = ((x)&1) \ | |
| 120 | ?(S64_BYTE(r, ((x)>>1))&0xf)|((v)<<4) \ | |
| 121 | :(S64_BYTE(r, ((x)>>1))&0xf0)|(v) ) | |
| 122 | 129 | |
| 123 | #define S64_READ_B(r) S64_BYTE(r,0) | |
| 124 | #define S64_WRITE_B(r,v) (S64_BYTE(r,0)=v) | |
| 130 | INLINE int S64_READ_X(int r) | |
| 131 | { | |
| 132 | return saturn.reg[r][0]|(saturn.reg[r][1]<<4)|(saturn.reg[r][2]<<8); | |
| 133 | } | |
| 125 | 134 | |
| 126 | #define S64_READ_XS(r) S64_READ_NIBBLE(r,2) | |
| 127 | #define S64_WRITE_XS(r,v) S64_WRITE_NIBBLE(r,2,v) | |
| 135 | INLINE int S64_READ_WORD(int r) | |
| 136 | { | |
| 137 | return saturn.reg[r][0]|(saturn.reg[r][1]<<4)|(saturn.reg[r][2]<<8)|(saturn.reg[r][3]<<12); | |
| 138 | } | |
| 128 | 139 | |
| 129 | #define S64_READ_S(r) S64_READ_NIBBLE(r,15) | |
| 130 | #define S64_WRITE_S(r,v) S64_WRITE_NIBBLE(r,15,v) | |
| 140 | INLINE int S64_READ_A(int r) | |
| 141 | { | |
| 142 | return saturn.reg[r][0]|(saturn.reg[r][1]<<4)|(saturn.reg[r][2]<<8)|(saturn.reg[r][3]<<12)|(saturn.reg[r][4]<<16); | |
| 143 | } | |
| 131 | 144 | |
| 132 | #define S64_READ_P(r) S64_READ_NIBBLE(r,saturn.p) | |
| 133 | #define S64_WRITE_P(r,v) S64_WRITE_NIBBLE(r,saturn.p,v) | |
| 145 | INLINE void S64_WRITE_X(int r, int v) | |
| 146 | { | |
| 147 | saturn.reg[r][0]=v&0xf; | |
| 148 | saturn.reg[r][1]=(v>>4)&0xf; | |
| 149 | saturn.reg[r][2]=(v>>8)&0xf; | |
| 150 | } | |
| 134 | 151 | |
| 135 | #define S64_READ_X(r) (S64_WORD(r,0)&0xfff) | |
| 136 | #define S64_WRITE_X(r,v) (S64_WORD(r,0)=(S64_WORD(r,0)&~0xfff)|(v)) | |
| 152 | INLINE void S64_WRITE_WORD(int r, int v) | |
| 153 | { | |
| 154 | saturn.reg[r][0]=v&0xf; | |
| 155 | saturn.reg[r][1]=(v>>4)&0xf; | |
| 156 | saturn.reg[r][2]=(v>>8)&0xf; | |
| 157 | saturn.reg[r][3]=(v>>12)&0xf; | |
| 158 | } | |
| 137 | 159 | |
| 138 | // for address reg operations | |
| 139 | #define S64_READ_WORD(r,nr) S64_WORD(r,nr) | |
| 140 | #define S64_WRITE_WORD(r,nr,v) (S64_WORD(r,nr)=v) | |
| 160 | INLINE void S64_WRITE_A(int r, int v) | |
| 161 | { | |
| 162 | saturn.reg[r][0]=v&0xf; | |
| 163 | saturn.reg[r][1]=(v>>4)&0xf; | |
| 164 | saturn.reg[r][2]=(v>>8)&0xf; | |
| 165 | saturn.reg[r][3]=(v>>12)&0xf; | |
| 166 | saturn.reg[r][4]=(v>>16)&0xf; | |
| 167 | } | |
| 141 | 168 | |
| 142 | #define S64_READ_A(r) (S64_DOUBLE(r,0)&0xfffff) | |
| 143 | #define S64_WRITE_A(r,v) (S64_DOUBLE(r,0)=(S64_DOUBLE(r,0)&~0xfffff)|(v)) | |
| 144 | 169 | |
| 145 | #define S64_READ_M(r) ((S64_QUAD(r)>>12)&0xffffffffffffULL) | |
| 146 | #define S64_WRITE_M(r,v) (S64_QUAD(r)=(S64_QUAD(r)&~0xffffffffffff000ULL)|((v)<<12)) | |
| 147 | 170 | |
| 148 | #define S64_READ_W(r) S64_QUAD(r) | |
| 149 | #define S64_WRITE_W(r,v) (S64_QUAD(r)=(v)) | |
| 150 | 171 | |
| 172 | ||
| 151 | 173 | INLINE SaturnAdr saturn_pop(void) |
| 152 | 174 | { |
| 153 | 175 | SaturnAdr temp=saturn.rstk[0]; |
| 154 | 176 | memmove(saturn.rstk, saturn.rstk+1, sizeof(saturn.rstk)-sizeof(saturn.rstk[0])); |
| 155 | 177 | saturn.rstk[7]=0; |
| 156 | saturn.stackpointer--; | |
| 157 | 178 | return temp; |
| 158 | 179 | } |
| 159 | 180 | |
| r2724 | r2725 | |
| 161 | 182 | { |
| 162 | 183 | memmove(saturn.rstk+1, saturn.rstk, sizeof(saturn.rstk)-sizeof(saturn.rstk[0])); |
| 163 | 184 | saturn.rstk[0]=adr; |
| 164 | saturn.stackpointer++; | |
| 165 | 185 | } |
| 166 | 186 | |
| 167 | 187 | INLINE void saturn_interrupt_on(void) |
| 168 | 188 | { |
| 169 | ||
| 189 | LOG(( "SATURN#%d at %05x: INTON\n", cpu_getactivecpu(), saturn.pc-4 )); | |
| 190 | saturn.irq_enable=1; | |
| 191 | if (saturn.irq_state) | |
| 192 | { | |
| 193 | LOG(( "SATURN#%d set_irq_line(ASSERT)\n", cpu_getactivecpu())); | |
| 194 | saturn.pending_irq=1; | |
| 195 | } | |
| 170 | 196 | } |
| 171 | 197 | |
| 172 | 198 | INLINE void saturn_interrupt_off(void) |
| 173 | 199 | { |
| 174 | ||
| 200 | LOG(( "SATURN#%d at %05x: INTOFF\n", cpu_getactivecpu(), saturn.pc-4 )); | |
| 201 | saturn.irq_enable=0; | |
| 175 | 202 | } |
| 176 | 203 | |
| 177 | 204 | INLINE void saturn_reset_interrupt(void) |
| 178 | 205 | { |
| 179 | ||
| 206 | LOG(( "SATURN#%d at %05x: RSI\n", cpu_getactivecpu(), saturn.pc-5 )); | |
| 207 | if (saturn.config&&saturn.config->rsi) saturn.config->rsi(Machine); | |
| 180 | 208 | } |
| 181 | 209 | |
| 182 | 210 | INLINE void saturn_mem_reset(void) |
| 183 | 211 | { |
| 184 | if (saturn.config->reset) saturn.config->reset(); | |
| 212 | if (saturn.config&&saturn.config->reset) saturn.config->reset(Machine); | |
| 185 | 213 | } |
| 186 | 214 | |
| 187 | 215 | INLINE void saturn_mem_config(void) |
| 188 | 216 | { |
| 189 | if (saturn.config->config) saturn.config->config(S64_READ_A(C)); | |
| 217 | if (saturn.config&&saturn.config->config) saturn.config->config(Machine, S64_READ_A(C)); | |
| 190 | 218 | } |
| 191 | 219 | |
| 192 | 220 | INLINE void saturn_mem_unconfig(void) |
| 193 | 221 | { |
| 194 | if (saturn.config->unconfig) saturn.config->unconfig(S64_READ_A(C)); | |
| 222 | if (saturn.config&&saturn.config->unconfig) saturn.config->unconfig(Machine, S64_READ_A(C)); | |
| 195 | 223 | } |
| 196 | 224 | |
| 197 | INLINE int saturn_mem_id(void) | |
| 225 | int monitor_id; | |
| 226 | ||
| 227 | INLINE void saturn_mem_id(void) | |
| 198 | 228 | { |
| 199 | if (saturn.config->id) return saturn.config->id(); | |
| 200 | return 0; | |
| 229 | int id=0; | |
| 230 | if (saturn.config&&saturn.config->id) id=saturn.config->id(Machine); | |
| 231 | S64_WRITE_A(C,id); | |
| 232 | monitor_id = id; | |
| 201 | 233 | } |
| 202 | 234 | |
| 203 | 235 | INLINE void saturn_shutdown(void) |
| 204 | 236 | { |
| 237 | saturn.sleeping=1; | |
| 238 | saturn.irq_enable=1; | |
| 239 | LOG(( "SATURN#%d at %05x: SHUTDN\n", cpu_getactivecpu(), saturn.pc-3 )); | |
| 205 | 240 | } |
| 206 | 241 | |
| 207 | 242 | INLINE void saturn_bus_command_b(void) |
| 208 | 243 | { |
| 244 | logerror( "SATURN#%d at %05x: BUSCB opcode not handled\n", cpu_getactivecpu(), saturn.pc-4 ); | |
| 209 | 245 | } |
| 210 | 246 | |
| 211 | 247 | INLINE void saturn_bus_command_c(void) |
| 212 | 248 | { |
| 249 | logerror( "SATURN#%d at %05x: BUSCC opcode not handled\n", cpu_getactivecpu(), saturn.pc-3 ); | |
| 213 | 250 | } |
| 214 | 251 | |
| 215 | 252 | INLINE void saturn_bus_command_d(void) |
| 216 | 253 | { |
| 254 | logerror( "SATURN#%d at %05x: BUSCD opcode not handled\n", cpu_getactivecpu(), saturn.pc-4 ); | |
| 217 | 255 | } |
| 218 | 256 | |
| 219 | 257 | INLINE void saturn_serial_request(void) |
| 220 | 258 | { |
| 259 | logerror( "SATURN#%d at %05x: SREQ? opcode not handled\n", cpu_getactivecpu(), saturn.pc-3 ); | |
| 221 | 260 | } |
| 222 | 261 | |
| 223 | 262 | INLINE void saturn_out_c(void) |
| 224 | 263 | { |
| 225 | if (saturn.config&&saturn.config->out) saturn.config->out(S64_READ_X(C)); | |
| 264 | saturn.out=S64_READ_X(C); | |
| 265 | if (saturn.config&&saturn.config->out) saturn.config->out(Machine, saturn.out); | |
| 226 | 266 | } |
| 227 | 267 | |
| 228 | 268 | INLINE void saturn_out_cs(void) |
| 229 | 269 | { |
| 230 | if (saturn.config&&saturn.config->out) | |
| 231 | saturn.config->out(S64_READ_NIBBLE(C,0)|(saturn.out&0xff0)); | |
| 270 | saturn.out=(saturn.out&0xff0)|saturn.reg[C][0]; | |
| 271 | if (saturn.config&&saturn.config->out) saturn.config->out(Machine, saturn.out); | |
| 232 | 272 | } |
| 233 | 273 | |
| 274 | int monitor_in; | |
| 275 | ||
| 234 | 276 | INLINE void saturn_in(int reg) |
| 235 | 277 | { |
| 236 | if (saturn.config&&saturn.config->in) S64_WORD(reg,0)=saturn.config->in(); | |
| 278 | int in = 0; | |
| 279 | saturn_assert(reg>=0 && reg<9); | |
| 280 | if (!(saturn.pc&1)) | |
| 281 | logerror( "SATURN#%d at %05x: reg=IN opcode at odd addresse\n", | |
| 282 | cpu_getactivecpu(), saturn.pc-3 ); | |
| 283 | if (saturn.config&&saturn.config->in) in = saturn.config->in(Machine); | |
| 284 | S64_WRITE_WORD(reg,in); | |
| 285 | monitor_in = in; | |
| 237 | 286 | } |
| 238 | 287 | |
| 239 | 288 | INLINE void saturn_sethex(void) { saturn.decimal=0; } |
| r2724 | r2725 | |
| 242 | 291 | /* st related */ |
| 243 | 292 | INLINE void saturn_clear_st(void) |
| 244 | 293 | { |
| 245 | saturn.st=0; | |
| 294 | saturn.st&=0xf000; | |
| 246 | 295 | } |
| 247 | 296 | |
| 248 | 297 | INLINE void saturn_st_to_c(void) |
| 249 | 298 | { |
| 250 | S64_WRITE_X(C, | |
| 299 | S64_WRITE_X(C, | |
| 251 | 300 | } |
| 252 | 301 | |
| 253 | 302 | INLINE void saturn_c_to_st(void) |
| 254 | 303 | { |
| 255 | saturn.st=(saturn.st& | |
| 304 | saturn.st=(saturn.st& | |
| 256 | 305 | } |
| 257 | 306 | |
| 258 | 307 | INLINE void saturn_exchange_c_st(void) |
| 259 | 308 | { |
| 260 | int t=saturn.st&0xfff; | |
| 261 | saturn.st=(saturn.st&~0xfff)|S64_READ_X(C); | |
| 262 | S64_WRITE_X(C, t); | |
| 309 | int t=saturn.st; | |
| 310 | saturn.st=(t&0xf000)|(S64_READ_X(C)); | |
| 311 | S64_WRITE_X(C,t); | |
| 263 | 312 | } |
| 264 | 313 | |
| 265 | INLINE void saturn_ | |
| 314 | INLINE void saturn_jump_ | |
| 266 | 315 | { |
| 267 | switch(READ_OP_ARG()) { | |
| 268 | case 0: saturn.st&=~1;break; | |
| 269 | case 1: saturn.st&=~2;break; | |
| 270 | case 2: saturn.st&=~4;break; | |
| 271 | case 3: saturn.st&=~8;break; | |
| 272 | case 4: saturn.st&=~0x10;break; | |
| 273 | case 5: saturn.st&=~0x20;break; | |
| 274 | case 6: saturn.st&=~0x40;break; | |
| 275 | case 7: saturn.st&=~0x80;break; | |
| 276 | case 8: saturn.st&=~0x100;break; | |
| 277 | case 9: saturn.st&=~0x200;break; | |
| 278 | case 0xa: saturn.st&=~0x400;break; | |
| 279 | case 0xb: saturn.st&=~0x800;break; | |
| 280 | case 0xc: saturn.st&=~0x1000;break; | |
| 281 | case 0xd: saturn.st&=~0x2000;break; | |
| 282 | case 0xe: saturn.st&=~0x4000;break; | |
| 283 | case 0xf: saturn.st&=~0x8000;break; | |
| 316 | int adr=READ_OP_DIS8(); | |
| 317 | if (saturn.carry) { | |
| 318 | if (adr==0) { | |
| 319 | saturn.pc=saturn_pop(); | |
| 320 | } else { | |
| 321 | saturn.pc=(saturn.pc+adr-2)&0xfffff; | |
| 322 | } | |
| 323 | change_pc(saturn.pc); | |
| 284 | 324 | } |
| 285 | 325 | } |
| 326 | INLINE void saturn_st_clear_bit(void) | |
| 327 | { | |
| 328 | saturn.st &= ~(1<<(READ_OP_ARG())); | |
| 329 | } | |
| 286 | 330 | |
| 287 | 331 | INLINE void saturn_st_set_bit(void) |
| 288 | 332 | { |
| 289 | switch(READ_OP_ARG()) { | |
| 290 | case 0: saturn.st|=1;break; | |
| 291 | case 1: saturn.st|=2;break; | |
| 292 | case 2: saturn.st|=4;break; | |
| 293 | case 3: saturn.st|=8;break; | |
| 294 | case 4: saturn.st|=0x10;break; | |
| 295 | case 5: saturn.st|=0x20;break; | |
| 296 | case 6: saturn.st|=0x40;break; | |
| 297 | case 7: saturn.st|=0x80;break; | |
| 298 | case 8: saturn.st|=0x100;break; | |
| 299 | case 9: saturn.st|=0x200;break; | |
| 300 | case 0xa: saturn.st|=0x400;break; | |
| 301 | case 0xb: saturn.st|=0x800;break; | |
| 302 | case 0xc: saturn.st|=0x1000;break; | |
| 303 | case 0xd: saturn.st|=0x2000;break; | |
| 304 | case 0xe: saturn.st|=0x4000;break; | |
| 305 | case 0xf: saturn.st|=0x8000;break; | |
| 306 | } | |
| 333 | saturn.st |= (1<<(READ_OP_ARG())); | |
| 307 | 334 | } |
| 308 | 335 | |
| 309 | 336 | INLINE void saturn_st_jump_bit_clear(void) |
| 310 | 337 | { |
| 311 | int adr; | |
| 312 | switch(READ_OP_ARG()) { | |
| 313 | case 0: saturn.carry=!saturn.st&1;break; | |
| 314 | case 1: saturn.carry=!saturn.st&2;break; | |
| 315 | case 2: saturn.carry=!saturn.st&4;break; | |
| 316 | case 3: saturn.carry=!saturn.st&8;break; | |
| 317 | case 4: saturn.carry=!saturn.st&0x10;break; | |
| 318 | case 5: saturn.carry=!saturn.st&0x20;break; | |
| 319 | case 6: saturn.carry=!saturn.st&0x40;break; | |
| 320 | case 7: saturn.carry=!saturn.st&0x80;break; | |
| 321 | case 8: saturn.carry=!saturn.st&0x100;break; | |
| 322 | case 9: saturn.carry=!saturn.st&0x200;break; | |
| 323 | case 0xa: saturn.carry=!saturn.st&0x400;break; | |
| 324 | case 0xb: saturn.carry=!saturn.st&0x800;break; | |
| 325 | case 0xc: saturn.carry=!saturn.st&0x1000;break; | |
| 326 | case 0xd: saturn.carry=!saturn.st&0x2000;break; | |
| 327 | case 0xe: saturn.carry=!saturn.st&0x4000;break; | |
| 328 | case 0xf: saturn.carry=!saturn.st&0x8000;break; | |
| 329 | } | |
| 330 | adr=READ_OP_DIS8(); | |
| 331 | if (saturn.carry) { | |
| 332 | if (adr==0) { | |
| 333 | saturn.pc=saturn_pop(); | |
| 334 | } else { | |
| 335 | saturn.pc=(saturn.pc+adr-2)&0xfffff; | |
| 336 | } | |
| 337 | change_pc(saturn.pc); | |
| 338 | } | |
| 338 | saturn.carry=!((saturn.st>>(READ_OP_ARG()))&1); | |
| 339 | saturn_jump_after_test(); | |
| 339 | 340 | } |
| 340 | 341 | |
| 341 | 342 | INLINE void saturn_st_jump_bit_set(void) |
| 342 | 343 | { |
| 343 | int adr; | |
| 344 | switch(READ_OP_ARG()) { | |
| 345 | case 0: saturn.carry=saturn.st&1;break; | |
| 346 | case 1: saturn.carry=saturn.st&2;break; | |
| 347 | case 2: saturn.carry=saturn.st&4;break; | |
| 348 | case 3: saturn.carry=saturn.st&8;break; | |
| 349 | case 4: saturn.carry=saturn.st&0x10;break; | |
| 350 | case 5: saturn.carry=saturn.st&0x20;break; | |
| 351 | case 6: saturn.carry=saturn.st&0x40;break; | |
| 352 | case 7: saturn.carry=saturn.st&0x80;break; | |
| 353 | case 8: saturn.carry=saturn.st&0x100;break; | |
| 354 | case 9: saturn.carry=saturn.st&0x200;break; | |
| 355 | case 0xa: saturn.carry=saturn.st&0x400;break; | |
| 356 | case 0xb: saturn.carry=saturn.st&0x800;break; | |
| 357 | case 0xc: saturn.carry=saturn.st&0x1000;break; | |
| 358 | case 0xd: saturn.carry=saturn.st&0x2000;break; | |
| 359 | case 0xe: saturn.carry=saturn.st&0x4000;break; | |
| 360 | case 0xf: saturn.carry=saturn.st&0x8000;break; | |
| 361 | } | |
| 362 | adr=READ_OP_DIS8(); | |
| 363 | if (saturn.carry) { | |
| 364 | if (adr==0) { | |
| 365 | saturn.pc=saturn_pop(); | |
| 366 | } else { | |
| 367 | saturn.pc=(saturn.pc+adr-2)&0xfffff; | |
| 368 | } | |
| 369 | change_pc(saturn.pc); | |
| 370 | } | |
| 344 | saturn.carry=(saturn.st>>(READ_OP_ARG()))&1; | |
| 345 | saturn_jump_after_test(); | |
| 371 | 346 | } |
| 372 | 347 | |
| 373 | 348 | INLINE void saturn_hst_clear_bits(void) |
| 374 | 349 | { |
| 375 | saturn.hst&=~READ_OP_ARG(); | |
| 350 | saturn.hst&=~(READ_OP_ARG()); | |
| 376 | 351 | } |
| 377 | 352 | |
| 378 | 353 | INLINE void saturn_hst_bits_cleared(void) |
| 379 | 354 | { |
| 380 | saturn.carry=!(saturn.hst&READ_OP_ARG()); | |
| 355 | saturn.carry=!(saturn.hst&(READ_OP_ARG())); | |
| 356 | saturn_jump_after_test(); | |
| 381 | 357 | } |
| 382 | 358 | |
| 383 | 359 | /* p related */ |
| r2724 | r2725 | |
| 385 | 361 | { |
| 386 | 362 | int nr=READ_OP_ARG(); |
| 387 | 363 | int t=saturn.p; |
| 388 | saturn.p=S64_READ_NIBBLE(C,nr); | |
| 389 | S64_WRITE_NIBBLE(C,nr,t); | |
| 364 | saturn.p=saturn.reg[C][nr]; | |
| 365 | saturn.reg[C][nr]=t; | |
| 390 | 366 | } |
| 391 | 367 | |
| 392 | 368 | INLINE void saturn_p_to_c(void) |
| 393 | 369 | { |
| 394 | 370 | int nr=READ_OP_ARG(); |
| 395 | | |
| 371 | saturn.reg[ | |
| 396 | 372 | } |
| 397 | 373 | |
| 398 | 374 | INLINE void saturn_c_to_p(void) |
| 399 | 375 | { |
| 400 | 376 | int nr=READ_OP_ARG(); |
| 401 | saturn.p= | |
| 377 | saturn.p=saturn.reg[ | |
| 402 | 378 | } |
| 403 | 379 | |
| 404 | 380 | INLINE void saturn_dec_p(void) |
| 405 | 381 | { |
| 406 | 382 | saturn.carry=saturn.p==0; |
| 407 | saturn.p=saturn.p-1; | |
| 383 | saturn.p=(saturn.p-1)&0xf; | |
| 408 | 384 | } |
| 409 | 385 | |
| 410 | 386 | INLINE void saturn_inc_p(void) |
| 411 | 387 | { |
| 412 | saturn.p=saturn.p+1; | |
| 388 | saturn.p=(saturn.p+1)&0xf; | |
| 413 | 389 | saturn.carry=saturn.p==0; |
| 414 | 390 | } |
| 415 | 391 | |
| r2724 | r2725 | |
| 420 | 396 | |
| 421 | 397 | INLINE void saturn_p_equals(void) |
| 422 | 398 | { |
| 423 | int nr=READ_OP_ARG(); | |
| 424 | int adr; | |
| 425 | saturn.carry=saturn.p==nr; | |
| 426 | adr=READ_OP_DIS8(); | |
| 427 | if (saturn.carry) { | |
| 428 | if (adr==0) { | |
| 429 | saturn.pc=saturn_pop(); | |
| 430 | } else { | |
| 431 | saturn.pc=(saturn.pc+adr-2)&0xfffff; | |
| 432 | } | |
| 433 | change_pc(saturn.pc); | |
| 434 | } | |
| 399 | saturn.carry=saturn.p==(READ_OP_ARG()); | |
| 400 | saturn_jump_after_test(); | |
| 435 | 401 | } |
| 436 | 402 | |
| 437 | 403 | INLINE void saturn_p_not_equals(void) |
| 438 | 404 | { |
| 439 | int nr=READ_OP_ARG(); | |
| 440 | int adr; | |
| 441 | saturn.carry=saturn.p!=nr; | |
| 442 | adr=READ_OP_DIS8(); | |
| 443 | if (saturn.carry) { | |
| 444 | if (adr==0) { | |
| 445 | saturn.pc=saturn_pop(); | |
| 446 | } else { | |
| 447 | saturn.pc=(saturn.pc+adr-2)&0xfffff; | |
| 448 | } | |
| 449 | change_pc(saturn.pc); | |
| 450 | } | |
| 405 | saturn.carry=saturn.p!=(READ_OP_ARG()); | |
| 406 | saturn_jump_after_test(); | |
| 451 | 407 | } |
| 452 | 408 | |
| 453 | 409 | INLINE void saturn_ca_p_1(void) |
| 454 | 410 | { |
| 455 | int a=S64_READ_A(C)+1+saturn.p; | |
| 411 | int a=(S64_READ_A(C))+1+saturn.p; | |
| 456 | 412 | saturn.carry=a>=0x100000; |
| 457 | 413 | S64_WRITE_A(C,a&0xfffff); |
| 458 | 414 | } |
| r2724 | r2725 | |
| 461 | 417 | { |
| 462 | 418 | int count=READ_OP_ARG(); |
| 463 | 419 | int pos=saturn.p; |
| 420 | saturn_assert(reg>=0 && reg<9); | |
| 464 | 421 | for (; count>=0; count--, pos=(pos+1)&0xf ) { |
| 465 | | |
| 422 | satu | |
| 466 | 423 | } |
| 467 | 424 | } |
| 468 | 425 | |
| 469 | 426 | INLINE void saturn_jump(int adr, int jump) |
| 470 | 427 | { |
| 428 | saturn_assert(adr>=0 && adr<0x100000); | |
| 471 | 429 | if (jump) { |
| 472 | 430 | saturn.pc=adr; |
| 473 | 431 | saturn_ICount-=10; |
| r2724 | r2725 | |
| 477 | 435 | |
| 478 | 436 | INLINE void saturn_call(int adr) |
| 479 | 437 | { |
| 438 | saturn_assert(adr>=0 && adr<0x100000); | |
| 480 | 439 | saturn_push(saturn.pc); |
| 481 | 440 | saturn.pc=adr; |
| 482 | 441 | // saturn_ICount-=10; |
| r2724 | r2725 | |
| 510 | 469 | |
| 511 | 470 | INLINE void saturn_return_interrupt(void) |
| 512 | 471 | { |
| 472 | LOG(( "SATURN#%d at %05x: RTI\n", cpu_getactivecpu(), saturn.pc-2 )); | |
| 473 | saturn.in_irq=0; /* set to 1 when an IRQ is taken */ | |
| 513 | 474 | saturn.pc=saturn_pop(); |
| 514 | 475 | // saturn_ICount-=10; |
| 515 | 476 | change_pc(saturn.pc); |
| r2724 | r2725 | |
| 535 | 496 | |
| 536 | 497 | INLINE void saturn_indirect_jump(int reg) |
| 537 | 498 | { |
| 499 | saturn_assert(reg>=0 && reg<9); | |
| 538 | 500 | saturn.pc=READ_20(S64_READ_A(reg)); |
| 539 | 501 | change_pc(saturn.pc); |
| 540 | 502 | } |
| 541 | 503 | |
| 542 | 504 | INLINE void saturn_equals_zero(int reg, int begin, int count) |
| 543 | 505 | { |
| 544 | int i, t,adr; | |
| 506 | int i, t; | |
| 507 | saturn_assert(reg>=0 && reg<9); | |
| 508 | saturn_assert(begin>=0 && count>=0 && begin+count<=16); | |
| 509 | saturn.carry=1; | |
| 545 | 510 | for (i=0; i<count; i++) { |
| 546 | t=S64_READ_NIBBLE(reg, (begin+i)&0xf ); | |
| 547 | if (t!=0) break; | |
| 511 | t=saturn.reg[reg][begin+i]; | |
| 512 | if (t!=0) { saturn.carry=0; break; } | |
| 548 | 513 | saturn_ICount-=2; |
| 549 | 514 | } |
| 550 | saturn.carry=i==count; | |
| 551 | adr=READ_OP_DIS8(); | |
| 552 | if (saturn.carry) { | |
| 553 | if (adr==0) { | |
| 554 | saturn.pc=saturn_pop(); | |
| 555 | } else { | |
| 556 | saturn.pc=(saturn.pc+adr-2)&0xfffff; | |
| 557 | } | |
| 558 | change_pc(saturn.pc); | |
| 559 | } | |
| 515 | saturn_jump_after_test(); | |
| 560 | 516 | } |
| 561 | 517 | |
| 562 | 518 | INLINE void saturn_equals(int reg, int begin, int count, int right) |
| 563 | 519 | { |
| 564 | int i, t,t2,adr; | |
| 520 | int i, t,t2; | |
| 521 | saturn_assert(reg>=0 && reg<9); | |
| 522 | saturn_assert(right>=0 && right<9); | |
| 523 | saturn_assert(begin>=0 && count>=0 && begin+count<=16); | |
| 524 | saturn.carry=1; | |
| 565 | 525 | for (i=0; i<count; i++) { |
| 566 | t=S64_READ_NIBBLE(reg, (begin+i)&0xf ); | |
| 567 | t2=S64_READ_NIBBLE(right, (begin+i)&0xf ); | |
| 568 | if (t!=t2) break; | |
| 526 | t=saturn.reg[reg][begin+i]; | |
| 527 | t2=saturn.reg[right][begin+i]; | |
| 528 | if (t!=t2) { saturn.carry=0; break; } | |
| 569 | 529 | saturn_ICount-=2; |
| 570 | 530 | } |
| 571 | saturn.carry=i==count; | |
| 572 | adr=READ_OP_DIS8(); | |
| 573 | if (saturn.carry) { | |
| 574 | if (adr==0) { | |
| 575 | saturn.pc=saturn_pop(); | |
| 576 | } else { | |
| 577 | saturn.pc=(saturn.pc+adr-2)&0xfffff; | |
| 578 | } | |
| 579 | change_pc(saturn.pc); | |
| 580 | } | |
| 531 | saturn_jump_after_test(); | |
| 581 | 532 | } |
| 582 | 533 | |
| 583 | 534 | INLINE void saturn_not_equals_zero(int reg, int begin, int count) |
| 584 | 535 | { |
| 585 | int i, t,adr; | |
| 536 | int i, t; | |
| 537 | saturn_assert(reg>=0 && reg<9); | |
| 538 | saturn_assert(begin>=0 && count>=0 && begin+count<=16); | |
| 539 | saturn.carry=0; | |
| 586 | 540 | for (i=0; i<count; i++) { |
| 587 | t=S64_READ_NIBBLE(reg, (begin+i)&0xf ); | |
| 588 | if (t==0) break; | |
| 541 | t=saturn.reg[reg][begin+i]; | |
| 542 | if (t!=0) { saturn.carry=1; break; } | |
| 589 | 543 | saturn_ICount-=2; |
| 590 | 544 | } |
| 591 | saturn.carry=i==count; | |
| 592 | adr=READ_OP_DIS8(); | |
| 593 | if (saturn.carry) { | |
| 594 | if (adr==0) { | |
| 595 | saturn.pc=saturn_pop(); | |
| 596 | } else { | |
| 597 | saturn.pc=(saturn.pc+adr-2)&0xfffff; | |
| 598 | } | |
| 599 | change_pc(saturn.pc); | |
| 600 | } | |
| 545 | saturn_jump_after_test(); | |
| 601 | 546 | } |
| 602 | 547 | |
| 603 | 548 | INLINE void saturn_not_equals(int reg, int begin, int count, int right) |
| 604 | 549 | { |
| 605 | int i, t,t2,adr; | |
| 550 | int i, t,t2; | |
| 551 | saturn_assert(reg>=0 && reg<9); | |
| 552 | saturn_assert(right>=0 && right<9); | |
| 553 | saturn_assert(begin>=0 && count>=0 && begin+count<=16); | |
| 554 | saturn.carry=0; | |
| 606 | 555 | for (i=0; i<count; i++) { |
| 607 | t=S64_READ_NIBBLE(reg, (begin+i)&0xf ); | |
| 608 | t2=S64_READ_NIBBLE(right, (begin+i)&0xf ); | |
| 609 | if (t==t2) break; | |
| 556 | t=saturn.reg[reg][begin+i]; | |
| 557 | t2=saturn.reg[right][begin+i]; | |
| 558 | if (t!=t2) { saturn.carry=1; break; } | |
| 610 | 559 | saturn_ICount-=2; |
| 611 | 560 | } |
| 612 | saturn.carry=i==count; | |
| 613 | adr=READ_OP_DIS8(); | |
| 614 | if (saturn.carry) { | |
| 615 | if (adr==0) { | |
| 616 | saturn.pc=saturn_pop(); | |
| 617 | } else { | |
| 618 | saturn.pc=(saturn.pc+adr-2)&0xfffff; | |
| 619 | } | |
| 620 | change_pc(saturn.pc); | |
| 621 | } | |
| 561 | saturn_jump_after_test(); | |
| 622 | 562 | } |
| 623 | 563 | |
| 624 | 564 | INLINE void saturn_greater(int reg, int begin, int count, int right) |
| 625 | 565 | { |
| 626 | int i, t,t2,adr; | |
| 627 | for (i=count; i>=0; i--) { | |
| 628 | t=S64_READ_NIBBLE(reg, (begin+i)&0xf ); | |
| 629 | t2=S64_READ_NIBBLE(right, (begin+i)&0xf ); | |
| 630 | if (t<=t2) break; | |
| 566 | int i, t,t2; | |
| 567 | saturn_assert(reg>=0 && reg<9); | |
| 568 | saturn_assert(right>=0 && right<9); | |
| 569 | saturn_assert(begin>=0 && count>=0 && begin+count<=16); | |
| 570 | saturn.carry=0; | |
| 571 | for (i=count-1; i>=0; i--) { | |
| 572 | t=saturn.reg[reg][begin+i]; | |
| 573 | t2=saturn.reg[right][begin+i]; | |
| 574 | if (t>t2) { saturn.carry=1; break; } | |
| 575 | if (t<t2) break; | |
| 631 | 576 | saturn_ICount-=2; |
| 632 | 577 | } |
| 633 | saturn.carry=i<0; | |
| 634 | adr=READ_OP_DIS8(); | |
| 635 | if (saturn.carry) { | |
| 636 | if (adr==0) { | |
| 637 | saturn.pc=saturn_pop(); | |
| 638 | } else { | |
| 639 | saturn.pc=(saturn.pc+adr-2)&0xfffff; | |
| 640 | } | |
| 641 | change_pc(saturn.pc); | |
| 642 | } | |
| 578 | saturn_jump_after_test(); | |
| 643 | 579 | } |
| 644 | 580 | |
| 645 | 581 | INLINE void saturn_greater_equals(int reg, int begin, int count, int right) |
| 646 | 582 | { |
| 647 | int i, t,t2,adr; | |
| 648 | for (i=count; i>=0; i--) { | |
| 649 | t=S64_READ_NIBBLE(reg, (begin+i)&0xf ); | |
| 650 | t2=S64_READ_NIBBLE(right, (begin+i)&0xf ); | |
| 651 | if (t<t2) break; | |
| 583 | int i, t,t2; | |
| 584 | saturn_assert(reg>=0 && reg<9); | |
| 585 | saturn_assert(right>=0 && right<9); | |
| 586 | saturn_assert(begin>=0 && count>=0 && begin+count<=16); | |
| 587 | saturn.carry=1; | |
| 588 | for (i=count-1; i>=0; i--) { | |
| 589 | t=saturn.reg[reg][begin+i]; | |
| 590 | t2=saturn.reg[right][begin+i]; | |
| 591 | if (t<t2) { saturn.carry=0; break; } | |
| 592 | if (t>t2) break; | |
| 652 | 593 | saturn_ICount-=2; |
| 653 | 594 | } |
| 654 | saturn.carry=i<0; | |
| 655 | adr=READ_OP_DIS8(); | |
| 656 | if (saturn.carry) { | |
| 657 | if (adr==0) { | |
| 658 | saturn.pc=saturn_pop(); | |
| 659 | } else { | |
| 660 | saturn.pc=(saturn.pc+adr-2)&0xfffff; | |
| 661 | } | |
| 662 | change_pc(saturn.pc); | |
| 663 | } | |
| 595 | saturn_jump_after_test(); | |
| 664 | 596 | } |
| 665 | 597 | |
| 666 | 598 | INLINE void saturn_smaller_equals(int reg, int begin, int count, int right) |
| 667 | 599 | { |
| 668 | int i, t,t2,adr; | |
| 669 | for (i=count; i>=0; i--) { | |
| 670 | t=S64_READ_NIBBLE(reg, (begin+i)&0xf ); | |
| 671 | t2=S64_READ_NIBBLE(right, (begin+i)&0xf ); | |
| 672 | if (t>t2) break; | |
| 600 | int i, t,t2; | |
| 601 | saturn_assert(reg>=0 && reg<9); | |
| 602 | saturn_assert(right>=0 && right<9); | |
| 603 | saturn_assert(begin>=0 && count>=0 && begin+count<=16); | |
| 604 | saturn.carry=1; | |
| 605 | for (i=count-1; i>=0; i--) { | |
| 606 | t=saturn.reg[reg][begin+i]; | |
| 607 | t2=saturn.reg[right][begin+i]; | |
| 608 | if (t>t2) { saturn.carry=0; break; } | |
| 609 | if (t<t2) break; | |
| 673 | 610 | saturn_ICount-=2; |
| 674 | 611 | } |
| 675 | saturn.carry=i<0; | |
| 676 | adr=READ_OP_DIS8(); | |
| 677 | if (saturn.carry) { | |
| 678 | if (adr==0) { | |
| 679 | saturn.pc=saturn_pop(); | |
| 680 | } else { | |
| 681 | saturn.pc=(saturn.pc+adr-2)&0xfffff; | |
| 682 | } | |
| 683 | change_pc(saturn.pc); | |
| 684 | } | |
| 612 | saturn_jump_after_test(); | |
| 685 | 613 | } |
| 686 | 614 | |
| 687 | 615 | INLINE void saturn_smaller(int reg, int begin, int count, int right) |
| 688 | 616 | { |
| 689 | int i, t,t2,adr; | |
| 690 | for (i=count; i>=0; i--) { | |
| 691 | t=S64_READ_NIBBLE(reg, (begin+i)&0xf ); | |
| 692 | t2=S64_READ_NIBBLE(right, (begin+i)&0xf ); | |
| 693 | if (t>=t2) break; | |
| 617 | int i, t,t2; | |
| 618 | saturn_assert(reg>=0 && reg<9); | |
| 619 | saturn_assert(right>=0 && right<9); | |
| 620 | saturn_assert(begin>=0 && count>=0 && begin+count<=16); | |
| 621 | saturn.carry=0; | |
| 622 | for (i=count-1; i>=0; i--) { | |
| 623 | t=saturn.reg[reg][begin+i]; | |
| 624 | t2=saturn.reg[right][begin+i]; | |
| 625 | if (t<t2) { saturn.carry=1; break; } | |
| 626 | if (t>t2) break; | |
| 694 | 627 | saturn_ICount-=2; |
| 695 | 628 | } |
| 696 | saturn.carry=i<0; | |
| 697 | adr=READ_OP_DIS8(); | |
| 698 | if (saturn.carry) { | |
| 699 | if (adr==0) { | |
| 700 | saturn.pc=saturn_pop(); | |
| 701 | } else { | |
| 702 | saturn.pc=(saturn.pc+adr-2)&0xfffff; | |
| 703 | } | |
| 704 | change_pc(saturn.pc); | |
| 705 | } | |
| 629 | saturn_jump_after_test(); | |
| 706 | 630 | } |
| 707 | 631 | |
| 708 | 632 | INLINE void saturn_jump_bit_clear(int reg) |
| 709 | 633 | { |
| 710 | int adr; | |
| 711 | switch(READ_OP_ARG()) { | |
| 712 | case 0: saturn.carry=!(S64_BYTE( reg, 0)&1);break; | |
| 713 | case 1: saturn.carry=!(S64_BYTE( reg, 0)&2);break; | |
| 714 | case 2: saturn.carry=!(S64_BYTE( reg, 0)&4);break; | |
| 715 | case 3: saturn.carry=!(S64_BYTE( reg, 0)&8);break; | |
| 716 | case 4: saturn.carry=!(S64_BYTE( reg, 0)&0x10);break; | |
| 717 | case 5: saturn.carry=!(S64_BYTE( reg, 0)&0x20);break; | |
| 718 | case 6: saturn.carry=!(S64_BYTE( reg, 0)&0x40);break; | |
| 719 | case 7: saturn.carry=!(S64_BYTE( reg, 0)&0x80);break; | |
| 720 | case 8: saturn.carry=!(S64_BYTE( reg, 1)&1);break; | |
| 721 | case 9: saturn.carry=!(S64_BYTE( reg, 1)&2);break; | |
| 722 | case 0xa: saturn.carry=!(S64_BYTE( reg, 1)&4);break; | |
| 723 | case 0xb: saturn.carry=!(S64_BYTE( reg, 1)&8);break; | |
| 724 | case 0xc: saturn.carry=!(S64_BYTE( reg, 1)&0x10);break; | |
| 725 | case 0xd: saturn.carry=!(S64_BYTE( reg, 1)&0x20);break; | |
| 726 | case 0xe: saturn.carry=!(S64_BYTE( reg, 1)&0x40);break; | |
| 727 | case 0xf: saturn.carry=!(S64_BYTE( reg, 1)&0x80);break; | |
| 728 | } | |
| 729 | adr=READ_OP_DIS8(); | |
| 730 | if (saturn.carry) { | |
| 731 | if (adr==0) { | |
| 732 | saturn.pc=saturn_pop(); | |
| 733 | } else { | |
| 734 | saturn.pc=(saturn.pc+adr-2)&0xfffff; | |
| 735 | } | |
| 736 | change_pc(saturn.pc); | |
| 737 | } | |
| 634 | int op=READ_OP_ARG(); | |
| 635 | saturn_assert(reg>=0 && reg<9); | |
| 636 | saturn.carry=!((saturn.reg[reg][op>>2]>>(op&3))&1); | |
| 637 | saturn_jump_after_test(); | |
| 738 | 638 | } |
| 739 | 639 | |
| 740 | 640 | INLINE void saturn_jump_bit_set(int reg) |
| 741 | 641 | { |
| 742 | int adr; | |
| 743 | switch(READ_OP_ARG()) { | |
| 744 | case 0: saturn.carry=S64_BYTE( reg, 0)&1;break; | |
| 745 | case 1: saturn.carry=S64_BYTE( reg, 0)&2;break; | |
| 746 | case 2: saturn.carry=S64_BYTE( reg, 0)&4;break; | |
| 747 | case 3: saturn.carry=S64_BYTE( reg, 0)&8;break; | |
| 748 | case 4: saturn.carry=S64_BYTE( reg, 0)&0x10;break; | |
| 749 | case 5: saturn.carry=S64_BYTE( reg, 0)&0x20;break; | |
| 750 | case 6: saturn.carry=S64_BYTE( reg, 0)&0x40;break; | |
| 751 | case 7: saturn.carry=S64_BYTE( reg, 0)&0x80;break; | |
| 752 | case 8: saturn.carry=S64_BYTE( reg, 1)&1;break; | |
| 753 | case 9: saturn.carry=S64_BYTE( reg, 1)&2;break; | |
| 754 | case 0xa: saturn.carry=S64_BYTE( reg, 1)&4;break; | |
| 755 | case 0xb: saturn.carry=S64_BYTE( reg, 1)&8;break; | |
| 756 | case 0xc: saturn.carry=S64_BYTE( reg, 1)&0x10;break; | |
| 757 | case 0xd: saturn.carry=S64_BYTE( reg, 1)&0x20;break; | |
| 758 | case 0xe: saturn.carry=S64_BYTE( reg, 1)&0x40;break; | |
| 759 | case 0xf: saturn.carry=S64_BYTE( reg, 1)&0x80;break; | |
| 760 | } | |
| 761 | adr=READ_OP_DIS8(); | |
| 762 | if (saturn.carry) { | |
| 763 | if (adr==0) { | |
| 764 | saturn.pc=saturn_pop(); | |
| 765 | } else { | |
| 766 | saturn.pc=(saturn.pc+adr-2)&0xfffff; | |
| 767 | } | |
| 768 | change_pc(saturn.pc); | |
| 769 | } | |
| 642 | int op=READ_OP_ARG(); | |
| 643 | saturn_assert(reg>=0 && reg<9); | |
| 644 | saturn.carry=(saturn.reg[reg][op>>2]>>(op&3))&1; | |
| 645 | saturn_jump_after_test(); | |
| 770 | 646 | } |
| 771 | 647 | |
| 772 | 648 | INLINE void saturn_load_pc(int reg) |
| 773 | 649 | { |
| 650 | saturn_assert(reg>=0 && reg<9); | |
| 774 | 651 | saturn.pc=S64_READ_A(reg); |
| 775 | 652 | change_pc(saturn.pc); |
| 776 | 653 | } |
| 777 | 654 | |
| 778 | 655 | INLINE void saturn_store_pc(int reg) |
| 779 | 656 | { |
| 657 | saturn_assert(reg>=0 && reg<9); | |
| 780 | 658 | S64_WRITE_A(reg,saturn.pc); |
| 781 | 659 | } |
| 782 | 660 | |
| 783 | 661 | INLINE void saturn_exchange_pc(int reg) |
| 784 | 662 | { |
| 785 | 663 | int temp=saturn.pc; |
| 664 | saturn_assert(reg>=0 && reg<9); | |
| 786 | 665 | saturn.pc=S64_READ_A(reg); |
| 787 | 666 | change_pc(saturn.pc); |
| 788 | 667 | S64_WRITE_A(reg, temp); |
| r2724 | r2725 | |
| 793 | 672 | *************************************************************************************/ |
| 794 | 673 | INLINE void saturn_load_adr(int reg, int nibbles) |
| 795 | 674 | { |
| 675 | saturn_assert(reg>=0 && reg<2); | |
| 676 | saturn_assert(nibbles==2 || nibbles==4 || nibbles==5); | |
| 796 | 677 | switch (nibbles) { |
| 797 | 678 | case 5: |
| 798 | 679 | saturn.d[reg]=READ_OP_ARG20(); |
| r2724 | r2725 | |
| 809 | 690 | INLINE void saturn_add_adr(int reg) |
| 810 | 691 | { |
| 811 | 692 | int t=saturn.d[reg]+READ_OP_ARG()+1; |
| 693 | saturn_assert(reg>=0 && reg<2); | |
| 812 | 694 | saturn.d[reg]=t&0xfffff; |
| 813 | 695 | saturn.carry=t>=0x100000; |
| 814 | 696 | } |
| r2724 | r2725 | |
| 816 | 698 | INLINE void saturn_sub_adr(int reg) |
| 817 | 699 | { |
| 818 | 700 | int t=saturn.d[reg]-READ_OP_ARG()-1; |
| 701 | saturn_assert(reg>=0 && reg<2); | |
| 819 | 702 | saturn.d[reg]=t&0xfffff; |
| 820 | 703 | saturn.carry=t<0; |
| 821 | 704 | } |
| 822 | 705 | |
| 823 | 706 | INLINE void saturn_adr_to_reg(int adr, int reg) |
| 824 | 707 | { |
| 708 | saturn_assert(reg>=0 && reg<9); | |
| 709 | saturn_assert(adr>=0 && adr<2); | |
| 825 | 710 | S64_WRITE_A(reg,saturn.d[adr]); |
| 826 | 711 | } |
| 827 | 712 | |
| 828 | 713 | INLINE void saturn_reg_to_adr(int reg, int adr) |
| 829 | 714 | { |
| 715 | saturn_assert(reg>=0 && reg<9); | |
| 716 | saturn_assert(adr>=0 && adr<2); | |
| 830 | 717 | saturn.d[adr]=S64_READ_A(reg); |
| 831 | 718 | } |
| 832 | 719 | |
| 833 | 720 | INLINE void saturn_adr_to_reg_word(int adr, int reg) |
| 834 | 721 | { |
| 835 | S64_WRITE_WORD(reg,0,saturn.d[adr]&0xffff); | |
| 722 | saturn_assert(reg>=0 && reg<9); | |
| 723 | saturn_assert(adr>=0 && adr<2); | |
| 724 | S64_WRITE_WORD(reg,saturn.d[adr]&0xffff); | |
| 836 | 725 | } |
| 837 | 726 | |
| 838 | 727 | INLINE void saturn_reg_to_adr_word(int reg, int adr) |
| 839 | 728 | { |
| 840 | saturn.d[adr]=(saturn.d[adr]&0xf0000)|S64_READ_WORD(reg,0); | |
| 729 | saturn_assert(reg>=0 && reg<9); | |
| 730 | saturn_assert(adr>=0 && adr<2); | |
| 731 | saturn.d[adr]=(saturn.d[adr]&0xf0000)|S64_READ_WORD(reg); | |
| 841 | 732 | } |
| 842 | 733 | |
| 843 | 734 | INLINE void saturn_exchange_adr_reg(int adr, int reg) |
| 844 | 735 | { |
| 845 | 736 | int temp=saturn.d[adr]; |
| 737 | saturn_assert(reg>=0 && reg<9); | |
| 738 | saturn_assert(adr>=0 && adr<2); | |
| 846 | 739 | saturn.d[adr]=S64_READ_A(reg); |
| 847 | 740 | S64_WRITE_A(reg,temp); |
| 848 | 741 | } |
| r2724 | r2725 | |
| 850 | 743 | INLINE void saturn_exchange_adr_reg_word(int adr, int reg) |
| 851 | 744 | { |
| 852 | 745 | int temp=saturn.d[adr]&0xffff; |
| 853 | saturn.d[adr]=(saturn.d[adr]&0xf0000)|S64_READ_WORD(reg,0); | |
| 854 | S64_WRITE_WORD(reg,0,temp); | |
| 746 | saturn_assert(reg>=0 && reg<9); | |
| 747 | saturn_assert(adr>=0 && adr<2); | |
| 748 | saturn.d[adr]=(saturn.d[adr]&0xf0000)|S64_READ_WORD(reg); | |
| 749 | S64_WRITE_WORD(reg,temp); | |
| 855 | 750 | } |
| 856 | 751 | |
| 857 | 752 | INLINE void saturn_load_nibbles(int reg, int begin, int count, int adr) |
| 858 | 753 | { |
| 859 | 754 | int i; |
| 755 | saturn_assert(reg>=0 && reg<9); | |
| 756 | saturn_assert(adr>=0 && adr<2); | |
| 757 | saturn_assert(begin>=0 && count>=0 && begin+count<=16); | |
| 860 | 758 | for (i=0; i<count; i++) { |
| 861 | | |
| 759 | satu | |
| 862 | 760 | saturn_ICount-=2; |
| 863 | 761 | } |
| 864 | 762 | } |
| r2724 | r2725 | |
| 866 | 764 | INLINE void saturn_store_nibbles(int reg, int begin, int count, int adr) |
| 867 | 765 | { |
| 868 | 766 | int i; |
| 767 | saturn_assert(reg>=0 && reg<9); | |
| 768 | saturn_assert(adr>=0 && adr<2); | |
| 769 | saturn_assert(begin>=0 && count>=0 && begin+count<=16); | |
| 869 | 770 | for (i=0; i<count; i++) { |
| 870 | WRITE_NIBBLE(saturn.d[adr]+i, | |
| 771 | WRITE_NIBBLE((saturn.d[adr]+i)&0xfffff,satu | |
| 871 | 772 | saturn_ICount-=2; |
| 872 | 773 | } |
| 873 | 774 | } |
| 874 | 775 | |
| 875 | 776 | INLINE void saturn_clear_bit(int reg) |
| 876 | 777 | { |
| 877 | switch(READ_OP_ARG()) { | |
| 878 | case 0: S64_BYTE( reg, 0)&=~1;break; | |
| 879 | case 1: S64_BYTE( reg, 0)&=~2;break; | |
| 880 | case 2: S64_BYTE( reg, 0)&=~4;break; | |
| 881 | case 3: S64_BYTE( reg, 0)&=~8;break; | |
| 882 | case 4: S64_BYTE( reg, 0)&=~0x10;break; | |
| 883 | case 5: S64_BYTE( reg, 0)&=~0x20;break; | |
| 884 | case 6: S64_BYTE( reg, 0)&=~0x40;break; | |
| 885 | case 7: S64_BYTE( reg, 0)&=~0x80;break; | |
| 886 | case 8: S64_BYTE( reg, 1)&=~1;break; | |
| 887 | case 9: S64_BYTE( reg, 1)&=~2;break; | |
| 888 | case 0xa: S64_BYTE( reg, 1)&=~4;break; | |
| 889 | case 0xb: S64_BYTE( reg, 1)&=~8;break; | |
| 890 | case 0xc: S64_BYTE( reg, 1)&=~0x10;break; | |
| 891 | case 0xd: S64_BYTE( reg, 1)&=~0x20;break; | |
| 892 | case 0xe: S64_BYTE( reg, 1)&=~0x40;break; | |
| 893 | case 0xf: S64_BYTE( reg, 1)&=~0x80;break; | |
| 894 | } | |
| 778 | int arg=READ_OP_ARG(); | |
| 779 | saturn_assert(reg>=0 && reg<9); | |
| 780 | saturn.reg[reg][arg>>2]&=~(1<<(arg&3)); | |
| 895 | 781 | } |
| 896 | 782 | |
| 897 | 783 | INLINE void saturn_set_bit(int reg) |
| 898 | 784 | { |
| 899 | switch(READ_OP_ARG()) { | |
| 900 | case 0: S64_BYTE( reg, 0)|=1;break; | |
| 901 | case 1: S64_BYTE( reg, 0)|=2;break; | |
| 902 | case 2: S64_BYTE( reg, 0)|=4;break; | |
| 903 | case 3: S64_BYTE( reg, 0)|=8;break; | |
| 904 | case 4: S64_BYTE( reg, 0)|=0x10;break; | |
| 905 | case 5: S64_BYTE( reg, 0)|=0x20;break; | |
| 906 | case 6: S64_BYTE( reg, 0)|=0x40;break; | |
| 907 | case 7: S64_BYTE( reg, 0)|=0x80;break; | |
| 908 | case 8: S64_BYTE( reg, 1)|=1;break; | |
| 909 | case 9: S64_BYTE( reg, 1)|=2;break; | |
| 910 | case 0xa: S64_BYTE( reg, 1)|=4;break; | |
| 911 | case 0xb: S64_BYTE( reg, 1)|=8;break; | |
| 912 | case 0xc: S64_BYTE( reg, 1)|=0x10;break; | |
| 913 | case 0xd: S64_BYTE( reg, 1)|=0x20;break; | |
| 914 | case 0xe: S64_BYTE( reg, 1)|=0x40;break; | |
| 915 | case 0xf: S64_BYTE( reg, 1)|=0x80;break; | |
| 916 | } | |
| 785 | int arg=READ_OP_ARG(); | |
| 786 | saturn_assert(reg>=0 && reg<9); | |
| 787 | saturn.reg[reg][arg>>2]|=1<<(arg&3); | |
| 917 | 788 | } |
| 918 | 789 | |
| 919 | 790 | /**************************************************************************** |
| r2724 | r2725 | |
| 922 | 793 | INLINE void saturn_clear(int reg, int begin, int count) |
| 923 | 794 | { |
| 924 | 795 | int i; |
| 796 | saturn_assert(reg>=0 && reg<9); | |
| 797 | saturn_assert(begin>=0 && count>=0 && begin+count<=16); | |
| 925 | 798 | for (i=0; i<count; i++) { |
| 926 | | |
| 799 | satu | |
| 927 | 800 | saturn_ICount-=2; |
| 928 | 801 | } |
| 929 | 802 | } |
| r2724 | r2725 | |
| 935 | 808 | { |
| 936 | 809 | int i; |
| 937 | 810 | SaturnNib temp; |
| 811 | saturn_assert(left>=0 && left<9); | |
| 812 | saturn_assert(right>=0 && right<9); | |
| 813 | saturn_assert(begin>=0 && count>=0 && begin+count<=16); | |
| 938 | 814 | for (i=0; i<count; i++) { |
| 939 | temp=S64_READ_NIBBLE(left,(begin+i)&0xf); | |
| 940 | S64_WRITE_NIBBLE(left, (begin+i)&0xf, S64_READ_NIBBLE(right,(begin+i)&0xf)); | |
| 941 | S64_WRITE_NIBBLE(right, (begin+i)&0xf, temp); | |
| 815 | temp=saturn.reg[left][begin+i]; | |
| 816 | saturn.reg[left][begin+i]=saturn.reg[right][begin+i]; | |
| 817 | saturn.reg[right][begin+i]=temp; | |
| 942 | 818 | saturn_ICount-=2; |
| 943 | 819 | } |
| 944 | 820 | } |
| r2724 | r2725 | |
| 949 | 825 | INLINE void saturn_copy(int dest, int begin, int count, int src) |
| 950 | 826 | { |
| 951 | 827 | int i; |
| 828 | saturn_assert(dest>=0 && dest<9); | |
| 829 | saturn_assert(src>=0 && src<9); | |
| 830 | saturn_assert(begin>=0 && count>=0 && begin+count<=16); | |
| 952 | 831 | for (i=0; i<count; i++) { |
| 953 | | |
| 832 | saturn.reg[ | |
| 954 | 833 | saturn_ICount-=2; |
| 955 | 834 | } |
| 956 | 835 | } |
| r2724 | r2725 | |
| 960 | 839 | ****************************************************************************/ |
| 961 | 840 | INLINE void saturn_add(int reg, int begin, int count, int right) |
| 962 | 841 | { |
| 963 | int i, t=0; | |
| 842 | int i, t; | |
| 843 | int base=saturn.decimal?10:16; | |
| 844 | saturn_assert(reg>=0 && reg<9); | |
| 845 | saturn_assert(right>=0 && right<9); | |
| 846 | saturn_assert(begin>=0 && count>=0 && begin+count<=16); | |
| 847 | saturn.carry=0; | |
| 964 | 848 | for (i=0; i<count; i++) { |
| 965 | if (t>0x10) { | |
| 966 | t=S64_READ_NIBBLE(reg, (begin+i)&0xf)+1; | |
| 967 | } else { | |
| 968 | t=S64_READ_NIBBLE(reg, (begin+i)&0xf); | |
| 849 | t=saturn.reg[reg][begin+i]; | |
| 850 | t+=saturn.reg[right][begin+i]; | |
| 851 | t+=saturn.carry; | |
| 852 | if (t>=base) { | |
| 853 | saturn.carry=1; | |
| 854 | t-=base; | |
| 969 | 855 | } |
| 970 | t+=S64_READ_NIBBLE(right, (begin+i)&0xf ); | |
| 971 | S64_WRITE_NIBBLE(reg, (begin+i)&0xf , t&0x0f); | |
| 856 | else saturn.carry=0; | |
| 857 | saturn_assert(t>=0); saturn_assert(t<base); | |
| 858 | saturn.reg[reg][begin+i]=t&0xf; | |
| 972 | 859 | saturn_ICount-=2; |
| 973 | 860 | } |
| 974 | saturn.carry=t==0x10; | |
| 975 | 861 | } |
| 976 | 862 | |
| 977 | 863 | INLINE void saturn_add_const(int reg, int begin, int count, SaturnNib right) |
| 978 | 864 | { |
| 979 | int i, t=0; | |
| 865 | int i, t; | |
| 866 | int base=saturn.decimal?10:16; | |
| 867 | saturn_assert(reg>=0 && reg<9); | |
| 868 | saturn_assert(begin>=0 && count>=0 && begin+count<=16); | |
| 869 | saturn_assert(count>1 || !saturn.decimal); /* SATURN bug */ | |
| 980 | 870 | for (i=0; i<count; i++) { |
| 981 | t=S64_READ_NIBBLE(reg, (begin+i)&0xf); | |
| 982 | t+=right; | |
| 983 | right=(right>>4)+1; | |
| 984 | S64_WRITE_NIBBLE(reg, (begin+i)&0xf, t&0x0f); | |
| 871 | t=saturn.reg[reg][begin+i]; | |
| 872 | t+=(right&0xf); | |
| 873 | right>>=4; | |
| 874 | if (t>=base) { | |
| 875 | right++; | |
| 876 | t-=base; | |
| 877 | } | |
| 878 | saturn_assert(t>=0); saturn_assert(t<base); | |
| 879 | saturn.reg[reg][begin+i]=t&0xf; | |
| 985 | 880 | saturn_ICount-=2; |
| 986 | if (t | |
| 881 | if (!right | |
| 987 | 882 | } |
| 988 | saturn.carry=t> | |
| 883 | saturn.carry=right> | |
| 989 | 884 | } |
| 990 | 885 | |
| 991 | 886 | /**************************************************************************** |
| r2724 | r2725 | |
| 993 | 888 | ****************************************************************************/ |
| 994 | 889 | INLINE void saturn_sub(int reg, int begin, int count, int right) |
| 995 | 890 | { |
| 996 | int i, t=0; | |
| 891 | int i, t; | |
| 892 | int base=saturn.decimal?10:16; | |
| 893 | saturn_assert(reg>=0 && reg<9); | |
| 894 | saturn_assert(right>=0 && right<9); | |
| 895 | saturn_assert(begin>=0 && count>=0 && begin+count<=16); | |
| 896 | saturn.carry=0; | |
| 997 | 897 | for (i=0; i<count; i++) { |
| 998 | if (t>0x10) { | |
| 999 | t=S64_READ_NIBBLE(reg, (begin+i)&0xf)-1; | |
| 1000 | } else { | |
| 1001 | t=S64_READ_NIBBLE(reg, (begin+i)&0xf ); | |
| 898 | t=saturn.reg[reg][begin+i]; | |
| 899 | t-=saturn.reg[right][begin+i]; | |
| 900 | t-=saturn.carry; | |
| 901 | if (t<0) { | |
| 902 | saturn.carry=1; | |
| 903 | t+=base; | |
| 1002 | 904 | } |
| 1003 | t-=S64_READ_NIBBLE(right, (begin+i)&0xf ); | |
| 1004 | S64_WRITE_NIBBLE(reg, (begin+i)&0xf, t&0x0f); | |
| 905 | else saturn.carry=0; | |
| 906 | saturn_assert(t>=0); saturn_assert(t<base); | |
| 907 | saturn.reg[reg][begin+i]=t&0xf; | |
| 1005 | 908 | saturn_ICount-=2; |
| 1006 | 909 | } |
| 1007 | saturn.carry=t<0; | |
| 1008 | 910 | } |
| 1009 | 911 | |
| 1010 | 912 | INLINE void saturn_sub_const(int reg, int begin, int count, int right) |
| 1011 | 913 | { |
| 1012 | int i, t=0; | |
| 914 | int i, t; | |
| 915 | int base=saturn.decimal?10:16; | |
| 916 | saturn_assert(reg>=0 && reg<9); | |
| 917 | saturn_assert(begin>=0 && count>=0 && begin+count<=16); | |
| 918 | saturn_assert(count>1 || !saturn.decimal); /* SATURN bug */ | |
| 1013 | 919 | for (i=0; i<count; i++) { |
| 1014 | t=S64_READ_NIBBLE(reg, (begin+i)&0xf ); | |
| 1015 | t-=right; | |
| 1016 | right=(right>>4)+1; | |
| 1017 | S64_WRITE_NIBBLE(reg, (begin+i)&0xf, t&0x0f); | |
| 920 | t=saturn.reg[reg][begin+i]; | |
| 921 | t-=(right&0xf); | |
| 922 | right>>=4; | |
| 923 | if (t<0) { | |
| 924 | right++; | |
| 925 | t+=base; | |
| 926 | } | |
| 927 | saturn_assert(t>=0); saturn_assert(t<base); | |
| 928 | saturn.reg[reg][begin+i]=t&0xf; | |
| 1018 | 929 | saturn_ICount-=2; |
| 1019 | if (t | |
| 930 | if (!right | |
| 1020 | 931 | } |
| 1021 | saturn.carry=t | |
| 932 | saturn.carry=right>0; | |
| 1022 | 933 | } |
| 1023 | 934 | |
| 1024 | 935 | /**************************************************************************** |
| r2724 | r2725 | |
| 1026 | 937 | ****************************************************************************/ |
| 1027 | 938 | INLINE void saturn_sub2(int reg, int begin, int count, int right) |
| 1028 | 939 | { |
| 1029 | int i, t=0; | |
| 940 | int i, t; | |
| 941 | int base=saturn.decimal?10:16; | |
| 942 | saturn_assert(reg>=0 && reg<9); | |
| 943 | saturn_assert(right>=0 && right<9); | |
| 944 | saturn_assert(begin>=0 && count>=0 && begin+count<=16); | |
| 945 | saturn.carry=0; | |
| 1030 | 946 | for (i=0; i<count; i++) { |
| 1031 | t=S64_READ_NIBBLE(reg, (begin+i)&0xf ); | |
| 1032 | t=S64_READ_NIBBLE(right, i)-t; | |
| 1033 | S64_WRITE_NIBBLE(reg, (begin+i)&0xf, t&0x0f); | |
| 947 | t=saturn.reg[right][begin+i]; | |
| 948 | t-=saturn.reg[reg][begin+i]; | |
| 949 | t-=saturn.carry; | |
| 950 | if (t<0) { | |
| 951 | saturn.carry=1; | |
| 952 | t+=base; | |
| 953 | } | |
| 954 | else saturn.carry=0; | |
| 955 | saturn_assert(t>=0); saturn_assert(t<base); | |
| 956 | saturn.reg[reg][begin+i]=t&0xf; | |
| 1034 | 957 | saturn_ICount-=2; |
| 1035 | if (t>=0) break; | |
| 1036 | 958 | } |
| 1037 | saturn.carry=t<0; | |
| 1038 | 959 | } |
| 1039 | 960 | |
| 1040 | 961 | /**************************************************************************** |
| r2724 | r2725 | |
| 1043 | 964 | INLINE void saturn_increment(int reg, int begin, int count) |
| 1044 | 965 | { |
| 1045 | 966 | int i, t=0; |
| 967 | int base=saturn.decimal?10:16; | |
| 968 | saturn_assert(reg>=0 && reg<9); | |
| 969 | saturn_assert(begin>=0 && count>=0 && begin+count<=16); | |
| 1046 | 970 | for (i=0; i<count; i++) { |
| 1047 | t=S64_READ_NIBBLE(reg, (begin+i)&0xf ); | |
| 1048 | t++; | |
| 1049 | S64_WRITE_NIBBLE(reg, (begin+i)&0xf, t&0x0f); | |
| 1050 | 971 | saturn_ICount-=2; |
| 1051 | if (t!=0x10) break; | |
| 972 | t=saturn.reg[reg][begin+i]; | |
| 973 | t++; | |
| 974 | if (t>=base) saturn.reg[reg][begin+i]=t-base; | |
| 975 | else { saturn.reg[reg][begin+i]=t; break; } | |
| 1052 | 976 | } |
| 977 | saturn.carry=t>=base; | |
| 1053 | 978 | } |
| 1054 | 979 | |
| 1055 | 980 | /**************************************************************************** |
| r2724 | r2725 | |
| 1058 | 983 | INLINE void saturn_decrement(int reg, int begin, int count) |
| 1059 | 984 | { |
| 1060 | 985 | int i, t=0; |
| 986 | int base=saturn.decimal?10:16; | |
| 987 | saturn_assert(reg>=0 && reg<9); | |
| 988 | saturn_assert(begin>=0 && count>=0 && begin+count<=16); | |
| 1061 | 989 | for (i=0; i<count; i++) { |
| 1062 | t=S64_READ_NIBBLE(reg, (begin+i)&0xf ); | |
| 1063 | t=(t-1)&0xf; | |
| 1064 | S64_WRITE_NIBBLE(reg, (begin+i)&0xf, t); | |
| 1065 | 990 | saturn_ICount-=2; |
| 1066 | if (t!=0) break; | |
| 991 | t=saturn.reg[reg][begin+i]; | |
| 992 | t--; | |
| 993 | if (t<0) saturn.reg[reg][begin+i]=t+base; | |
| 994 | else { saturn.reg[reg][begin+i]=t; break; } | |
| 1067 | 995 | } |
| 1068 | saturn.carry=t | |
| 996 | saturn.carry=t< | |
| 1069 | 997 | } |
| 1070 | 998 | |
| 1071 | 999 | /**************************************************************************** |
| r2724 | r2725 | |
| 1074 | 1002 | INLINE void saturn_invert(int reg, int begin, int count) |
| 1075 | 1003 | { |
| 1076 | 1004 | int i; |
| 1077 | SaturnNib n; | |
| 1078 | saturn.carry=1; | |
| 1005 | int max=saturn.decimal?9:15; | |
| 1006 | saturn_assert(reg>=0 && reg<9); | |
| 1007 | saturn_assert(begin>=0 && count>=0 && begin+count<=16); | |
| 1008 | saturn.carry=0; | |
| 1079 | 1009 | for (i=0; i<count; i++) { |
| 1080 | S64_WRITE_NIBBLE(reg, (begin+i)&0xf, (n=S64_READ_NIBBLE(reg,(begin+i)&0xf)) ^ 0xf); | |
| 1081 | saturn.carry=saturn.carry && (n==0); | |
| 1010 | saturn.reg[reg][begin+i]=(max-saturn.reg[reg][begin+i])&0xf; | |
| 1082 | 1011 | saturn_ICount-=2; |
| 1083 | 1012 | } |
| 1084 | 1013 | } |
| r2724 | r2725 | |
| 1086 | 1015 | /**************************************************************************** |
| 1087 | 1016 | negate (2 complement) opers |
| 1088 | 1017 | ****************************************************************************/ |
| 1089 | INLINE void | |
| 1018 | INLINE void saturn_negate(int reg, int begin, int count) | |
| 1090 | 1019 | { |
| 1091 | int i; | |
| 1092 | SaturnNib n; | |
| 1093 | saturn.carry=1; | |
| 1020 | int i, n, c; | |
| 1021 | int max=saturn.decimal?9:15; | |
| 1022 | saturn_assert(reg>=0 && reg<9); | |
| 1023 | saturn_assert(begin>=0 && count>=0 && begin+count<=16); | |
| 1024 | c=1; | |
| 1025 | saturn.carry=0; | |
| 1094 | 1026 | for (i=0; i<count; i++) { |
| 1095 | n=S64_READ_NIBBLE(reg, (begin+i)&0xf ); | |
| 1096 | saturn.carry=saturn.carry && (n==0); | |
| 1097 | n=((n ^ 0xf)+1)&0xf; | |
| 1098 | S64_WRITE_NIBBLE(reg, (begin+i)&0xf, n); | |
| 1027 | n=saturn.reg[reg][begin+i]; | |
| 1028 | if (n) saturn.carry=1; | |
| 1029 | n=max+c-n; | |
| 1030 | if (n>max) n-=max+1; | |
| 1031 | else c=0; | |
| 1032 | saturn_assert(n>=0); saturn_assert(n<=max); | |
| 1033 | saturn.reg[reg][begin+i]=n&0xf; | |
| 1099 | 1034 | saturn_ICount-=2; |
| 1100 | 1035 | } |
| 1101 | 1036 | } |
| r2724 | r2725 | |
| 1106 | 1041 | INLINE void saturn_or(int dest, int begin, int count, int src) |
| 1107 | 1042 | { |
| 1108 | 1043 | int i; |
| 1044 | saturn_assert(dest>=0 && dest<9); | |
| 1045 | saturn_assert(src>=0 && src<9); | |
| 1046 | saturn_assert(begin>=0 && count>=0 && begin+count<=16); | |
| 1109 | 1047 | for (i=0; i<count; i++) { |
| 1110 | S64_WRITE_NIBBLE(dest, (begin+i)&0xf, | |
| 1111 | S64_READ_NIBBLE(dest,(begin+i)&0xf)|S64_READ_NIBBLE(src,(begin+i)&0xf)); | |
| 1048 | saturn.reg[dest][begin+i]|=saturn.reg[src][begin+i]; | |
| 1112 | 1049 | saturn_ICount-=2; |
| 1113 | 1050 | } |
| 1114 | 1051 | } |
| r2724 | r2725 | |
| 1119 | 1056 | INLINE void saturn_and(int dest, int begin, int count, int src) |
| 1120 | 1057 | { |
| 1121 | 1058 | int i; |
| 1059 | saturn_assert(dest>=0 && dest<9); | |
| 1060 | saturn_assert(src>=0 && src<9); | |
| 1061 | saturn_assert(begin>=0 && count>=0 && begin+count<=16); | |
| 1122 | 1062 | for (i=0; i<count; i++) { |
| 1123 | S64_WRITE_NIBBLE(dest, (begin+i)&0xf, | |
| 1124 | S64_READ_NIBBLE(dest,(begin+i)&0xf)&S64_READ_NIBBLE(src,(begin+i)&0xf)); | |
| 1063 | saturn.reg[dest][begin+i]&=saturn.reg[src][begin+i]; | |
| 1125 | 1064 | saturn_ICount-=2; |
| 1126 | 1065 | } |
| 1127 | 1066 | } |
| r2724 | r2725 | |
| 1132 | 1071 | INLINE void saturn_shift_nibble_left(int reg, int begin, int count) |
| 1133 | 1072 | { |
| 1134 | 1073 | int i; |
| 1135 | for (i=count; i>1; i--) { | |
| 1136 | S64_WRITE_NIBBLE(reg, (begin+i)&0xf, S64_READ_NIBBLE(reg,(begin+i-1)&0xf) ); | |
| 1074 | saturn_assert(reg>=0 && reg<9); | |
| 1075 | saturn_assert(begin>=0 && count>=0 && begin+count<=16); | |
| 1076 | if (saturn.reg[reg][begin+count-1]) saturn.hst|=SB; | |
| 1077 | for (i=count-1; i>=1; i--) { | |
| 1078 | saturn.reg[reg][begin+i]=saturn.reg[reg][begin+i-1]; | |
| 1137 | 1079 | saturn_ICount-=2; |
| 1138 | 1080 | } |
| 1139 | | |
| 1081 | satu | |
| 1140 | 1082 | saturn_ICount-=2; |
| 1141 | 1083 | } |
| 1142 | 1084 | |
| r2724 | r2725 | |
| 1146 | 1088 | INLINE void saturn_shift_nibble_right(int reg, int begin, int count) |
| 1147 | 1089 | { |
| 1148 | 1090 | int i; |
| 1091 | saturn_assert(reg>=0 && reg<9); | |
| 1092 | saturn_assert(begin>=0 && count>=0 && begin+count<=16); | |
| 1093 | if (saturn.reg[reg][begin]) saturn.hst|=SB; | |
| 1149 | 1094 | for (i=1; i<count; i++) { |
| 1150 | | |
| 1095 | satu | |
| 1151 | 1096 | saturn_ICount-=2; |
| 1152 | 1097 | } |
| 1153 | | |
| 1098 | satu | |
| 1154 | 1099 | saturn_ICount-=2; |
| 1155 | 1100 | } |
| 1156 | 1101 | |
| 1102 | ||
| 1157 | 1103 | /**************************************************************************** |
| 1158 | rotate nibble left opers | |
| 1104 | rotate nibbles left opers | |
| 1159 | 1105 | ****************************************************************************/ |
| 1160 | 1106 | INLINE void saturn_rotate_nibble_left_w(int reg) |
| 1161 | 1107 | { |
| 1162 | SaturnNib a=S64_READ_NIBBLE(reg, 15); | |
| 1163 | S64_WRITE_W(reg, S64_READ_W(reg)<<4); | |
| 1164 | S64_WRITE_NIBBLE(reg,0,a); | |
| 1165 | saturn_ICount-=32; | |
| 1108 | int i, x=saturn.reg[reg][15]; | |
| 1109 | saturn_assert(reg>=0 && reg<9); | |
| 1110 | for (i=15; i>=1; i--) { | |
| 1111 | saturn.reg[reg][i]=saturn.reg[reg][i-1]; | |
| 1112 | saturn_ICount-=2; | |
| 1113 | } | |
| 1114 | saturn.reg[reg][0]=x; | |
| 1115 | saturn_ICount-=2; | |
| 1166 | 1116 | } |
| 1167 | 1117 | |
| 1118 | /**************************************************************************** | |
| 1119 | rotate nibbles right opers | |
| 1120 | ****************************************************************************/ | |
| 1168 | 1121 | INLINE void saturn_rotate_nibble_right_w(int reg) |
| 1169 | 1122 | { |
| 1170 | SaturnNib a=S64_READ_NIBBLE(reg,0); | |
| 1171 | if (a) saturn.hst|=SB; | |
| 1172 | S64_WRITE_W(reg, S64_READ_W(reg)>>4); | |
| 1173 | S64_WRITE_NIBBLE(reg,15,a); | |
| 1174 | saturn_ICount-=32; | |
| 1123 | int i, x=saturn.reg[reg][0]; | |
| 1124 | saturn_assert(reg>=0 && reg<9); | |
| 1125 | for (i=1; i<16; i++) { | |
| 1126 | saturn.reg[reg][i-1]=saturn.reg[reg][i]; | |
| 1127 | saturn_ICount-=2; | |
| 1128 | } | |
| 1129 | saturn.reg[reg][15]=x; | |
| 1130 | if (x) saturn.hst|=SB; | |
| 1131 | saturn_ICount-=2; | |
| 1175 | 1132 | } |
| 1176 | 1133 | |
| 1134 | ||
| 1177 | 1135 | /**************************************************************************** |
| 1178 | 1136 | shift right opers |
| 1179 | 1137 | ****************************************************************************/ |
| 1180 | 1138 | INLINE void saturn_shift_right(int reg, int begin, int count) |
| 1181 | 1139 | { |
| 1182 | 1140 | int i, t, c=0; |
| 1183 | for (i=count; i>=count; i--) { | |
| 1184 | t=S64_READ_NIBBLE(reg, (begin+i)&0xf ); | |
| 1185 | if (c) t|=0x10; | |
| 1141 | saturn_assert(reg>=0 && reg<9); | |
| 1142 | saturn_assert(begin>=0 && count>=0 && begin+count<=16); | |
| 1143 | for (i=count-1; i>=0; i--) { | |
| 1144 | t=saturn.reg[reg][begin+i]; | |
| 1145 | t|=(c<<4); | |
| 1186 | 1146 | c=t&1; |
| 1187 | | |
| 1147 | satu | |
| 1188 | 1148 | saturn_ICount-=2; |
| 1189 | 1149 | } |
| 1190 | 1150 | if (c) saturn.hst|=SB; |
| 1191 | 1151 | saturn_ICount-=2; |
| 1192 | 1152 | } |
| 1193 | ||
| 1194 | ||
| 1195 | /**************************************************************************** | |
| 1196 | shift left opers, sets carry! | |
| 1197 | ****************************************************************************/ | |
| 1198 | INLINE void saturn_shift_left(int reg, int begin, int count) | |
| 1199 | { | |
| 1200 | SaturnNib t; | |
| 1201 | int i; | |
| 1202 | saturn.carry=0; | |
| 1203 | for (i=0; i<count; i++) { | |
| 1204 | t=S64_READ_NIBBLE(reg,(begin+i)&0xf); | |
| 1205 | S64_WRITE_NIBBLE(reg, (begin+i)&0xf, ((t<<1)&0xf)|saturn.carry); | |
| 1206 | saturn.carry=t&8?1:0; | |
| 1207 | saturn_ICount-=2; | |
| 1208 | } | |
| 1209 | } |
| r2724 | r2725 | |
|---|---|---|
| 6 | 6 | * |
| 7 | 7 | * Copyright Peter Trauner, all rights reserved. |
| 8 | 8 | * |
| 9 | * Modified by Antoine Mine' | |
| 10 | * | |
| 9 | 11 | * - This source code is released as freeware for non-commercial purposes. |
| 10 | 12 | * - You are free to use and redistribute this code in modified or |
| 11 | 13 | * unmodified form, provided you list me in the credits. |
| r2724 | r2725 | |
| 22 | 24 | #include "debugger.h" |
| 23 | 25 | |
| 24 | 26 | #include "saturn.h" |
| 25 | #include " | |
| 27 | #include "deprecat.h" /* for Machine */ | |
| 26 | 28 | |
| 27 | 29 | #define R0 0 |
| 28 | 30 | #define R1 1 |
| r2724 | r2725 | |
| 33 | 35 | #define B 6 |
| 34 | 36 | #define C 7 |
| 35 | 37 | #define D 8 |
| 38 | #define I 9 // invalid | |
| 36 | 39 | |
| 37 | typedef int SaturnAdr; // 20 bit | |
| 38 | typedef UINT8 SaturnNib; // 4 bit | |
| 39 | typedef short SaturnX; // 12 bit | |
| 40 | typedef INT64 SaturnM; // 48 bit | |
| 40 | typedef UINT32 SaturnAdr; // 20 bit, packed | |
| 41 | typedef UINT8 SaturnNib; // 4 bit | |
| 41 | 42 | |
| 42 | typedef union { | |
| 43 | UINT8 b[8]; | |
| 44 | UINT16 w[4]; | |
| 45 | UINT32 d[2]; | |
| 46 | UINT64 q; | |
| 47 | } Saturn64; | |
| 43 | // 64 bit, unpacked (one nibble per byte) | |
| 44 | typedef SaturnNib Saturn64[16]; | |
| 48 | 45 | |
| 49 | 46 | #define VERBOSE 0 |
| 50 | 47 | |
| r2724 | r2725 | |
| 52 | 49 | |
| 53 | 50 | |
| 54 | 51 | /**************************************************************************** |
| 55 | * The | |
| 52 | * The SATURN registers. | |
| 56 | 53 | ****************************************************************************/ |
| 57 | 54 | typedef struct |
| 58 | 55 | { |
| 59 | 56 | SATURN_CONFIG *config; |
| 60 | Saturn64 reg[9]; //r0,r1,r2,r3,r4,a,b,c,d; | |
| 61 | 57 | |
| 58 | Saturn64 reg[9]; //r0,r1,r2,r3,r4,a,b,c,d | |
| 59 | ||
| 62 | 60 | SaturnAdr d[2], pc, oldpc, rstk[8]; // 20 bit addresses |
| 63 | 61 | |
| 64 | int stackpointer; // this is only for debugger stepover support! | |
| 65 | ||
| 66 | 62 | SaturnNib p; // 4 bit pointer |
| 67 | 63 | |
| 68 | UINT16 in; | |
| 69 | int out; // 12 | |
| 70 | int carry, decimal; | |
| 64 | UINT16 out; // 12 bit (packed) | |
| 65 | UINT8 carry, decimal; | |
| 71 | 66 | UINT16 st; // status 16 bit |
| 72 | #define XM 1 | |
| 73 | #define SR 2 | |
| 74 | #define SB 4 | |
| 75 | #define MP 8 | |
| 76 | int hst; // hardware status 4 bit | |
| 77 | /* XM external Modules missing | |
| 78 | SR Service Request | |
| 79 | SB Sticky bit | |
| 80 | MP Module Pulled */ | |
| 81 | 67 | |
| 82 | int irq_state; | |
| 68 | SaturnNib hst; // hardware status 4 bit | |
| 69 | #define XM 1 // external Modules missing | |
| 70 | #define SB 2 // Sticky bit | |
| 71 | #define SR 4 // Service Request | |
| 72 | #define MP 8 // Module Pulled | |
| 83 | 73 | |
| 84 | UINT8 pending_irq; /* nonzero if an IRQ is pending */ | |
| 85 | UINT8 after_cli; /* pending IRQ and last insn cleared I */ | |
| 86 | 74 | UINT8 nmi_state; |
| 75 | UINT8 irq_state; | |
| 76 | UINT8 irq_enable; /* INTON / INTOFF */ | |
| 77 | UINT8 in_irq; /* already servicing IRQ */ | |
| 78 | UINT8 pending_irq; /* IRQ is pending */ | |
| 79 | UINT8 sleeping; /* low-consumption state */ | |
| 87 | 80 | int (*irq_callback)(int irqline); /* IRQ callback */ |
| 88 | 81 | } Saturn_Regs; |
| 89 | 82 | |
| r2724 | r2725 | |
| 94 | 87 | /*************************************************************** |
| 95 | 88 | * include the opcode macros, functions and tables |
| 96 | 89 | ***************************************************************/ |
| 90 | ||
| 97 | 91 | #include "satops.c" |
| 98 | 92 | #include "sattable.c" |
| 99 | 93 | |
| r2724 | r2725 | |
| 106 | 100 | static void saturn_init(int index, int clock, const void *config, int (*irqcallback)(int)) |
| 107 | 101 | { |
| 108 | 102 | saturn.config = (SATURN_CONFIG *) config; |
| 103 | saturn.irq_callback = irqcallback; | |
| 104 | ||
| 105 | state_save_register_item_array("saturn",index,saturn.reg[R0]); | |
| 106 | state_save_register_item_array("saturn",index,saturn.reg[R1]); | |
| 107 | state_save_register_item_array("saturn",index,saturn.reg[R2]); | |
| 108 | state_save_register_item_array("saturn",index,saturn.reg[R3]); | |
| 109 | state_save_register_item_array("saturn",index,saturn.reg[R4]); | |
| 110 | state_save_register_item_array("saturn",index,saturn.reg[A]); | |
| 111 | state_save_register_item_array("saturn",index,saturn.reg[B]); | |
| 112 | state_save_register_item_array("saturn",index,saturn.reg[C]); | |
| 113 | state_save_register_item_array("saturn",index,saturn.reg[D]); | |
| 114 | state_save_register_item_array("saturn",index,saturn.d); | |
| 115 | state_save_register_item("saturn",index,saturn.pc); | |
| 116 | state_save_register_item("saturn",index,saturn.oldpc); | |
| 117 | state_save_register_item_array("saturn",index,saturn.rstk); | |
| 118 | state_save_register_item("saturn",index,saturn.out); | |
| 119 | state_save_register_item("saturn",index,saturn.carry); | |
| 120 | state_save_register_item("saturn",index,saturn.st); | |
| 121 | state_save_register_item("saturn",index,saturn.hst); | |
| 122 | state_save_register_item("saturn",index,saturn.nmi_state); | |
| 123 | state_save_register_item("saturn",index,saturn.irq_state); | |
| 124 | state_save_register_item("saturn",index,saturn.irq_enable); | |
| 125 | state_save_register_item("saturn",index,saturn.in_irq); | |
| 126 | state_save_register_item("saturn",index,saturn.pending_irq); | |
| 127 | state_save_register_item("saturn",index,saturn.sleeping); | |
| 109 | 128 | } |
| 110 | 129 | |
| 111 | 130 | static void saturn_reset(void) |
| 112 | 131 | { |
| 113 | saturn.stackpointer=0; | |
| 114 | 132 | saturn.pc=0; |
| 133 | saturn.sleeping = 0; | |
| 134 | saturn.irq_enable = 0; | |
| 135 | saturn.in_irq = 0; | |
| 115 | 136 | change_pc(saturn.pc); |
| 116 | 137 | } |
| 117 | 138 | |
| r2724 | r2725 | |
| 134 | 155 | |
| 135 | 156 | INLINE void saturn_take_irq(void) |
| 136 | 157 | { |
| 137 | { | |
| 138 | saturn_ICount -= 7; | |
| 158 | saturn.in_irq = 1; /* reset by software, using RTI */ | |
| 159 | saturn.pending_irq = 0; | |
| 160 | saturn_ICount -= 7; | |
| 161 | saturn_push(saturn.pc); | |
| 162 | saturn.pc=IRQ_ADDRESS; | |
| 139 | 163 | |
| 140 | saturn_push(saturn.pc); | |
| 141 | saturn.pc=IRQ_ADDRESS; | |
| 164 | LOG(("Saturn#%d takes IRQ ($%04x)\n", cpu_getactivecpu(), saturn.pc)); | |
| 142 | 165 | |
| 143 | LOG(("Saturn#%d takes IRQ ($%04x)\n", cpu_getactivecpu(), saturn.pc)); | |
| 144 | /* call back the cpuintrf to let it clear the line */ | |
| 145 | if (saturn.irq_callback) (*saturn.irq_callback)(0); | |
| 146 | change_pc(saturn.pc); | |
| 147 | } | |
| 148 | saturn.pending_irq = 0; | |
| 166 | if (saturn.irq_callback) (*saturn.irq_callback)(SATURN_IRQ_LINE); | |
| 167 | change_pc(saturn.pc); | |
| 149 | 168 | } |
| 150 | 169 | |
| 151 | 170 | static int saturn_execute(int cycles) |
| r2724 | r2725 | |
| 160 | 179 | |
| 161 | 180 | CALL_DEBUGGER(saturn.pc); |
| 162 | 181 | |
| 163 | /* if an irq is pending, take it now */ | |
| 164 | if( saturn.pending_irq ) | |
| 165 | saturn_take_irq(); | |
| 166 | ||
| 167 | saturn_instruction(); | |
| 168 | ||
| 169 | /* check if the I flag was just reset (interrupts enabled) */ | |
| 170 | if( saturn.after_cli ) | |
| 182 | if ( saturn.sleeping ) | |
| 171 | 183 | { |
| 172 | LOG(("M6502#%d after_cli was >0", cpu_getactivecpu())); | |
| 173 | saturn.after_cli = 0; | |
| 174 | if (saturn.irq_state != CLEAR_LINE) | |
| 175 | { | |
| 176 | LOG((": irq line is asserted: set pending IRQ\n")); | |
| 177 | saturn.pending_irq = 1; | |
| 178 | } | |
| 179 | else | |
| 180 | { | |
| 181 | LOG((": irq line is clear\n")); | |
| 182 | } | |
| 184 | /* advance time when sleeping */ | |
| 185 | saturn_ICount -= 100; | |
| 183 | 186 | } |
| 184 | 187 | else |
| 185 | if( saturn.pending_irq ) | |
| 186 | saturn_take_irq(); | |
| 188 | { | |
| 189 | /* takes irq */ | |
| 190 | if ( saturn.pending_irq && (!saturn.in_irq) ) | |
| 191 | saturn_take_irq(); | |
| 187 | 192 | |
| 193 | /* execute one instruction */ | |
| 194 | saturn_instruction(); | |
| 195 | } | |
| 196 | ||
| 188 | 197 | } while (saturn_ICount > 0); |
| 189 | 198 | |
| 190 | 199 | return cycles - saturn_ICount; |
| 191 | 200 | } |
| 192 | 201 | |
| 193 | #ifdef UNUSED_FUNCTION | |
| 194 | void saturn_set_nmi_line(int state) | |
| 202 | ||
| 203 | static void saturn_set_nmi_line(int state) | |
| 195 | 204 | { |
| 196 | if (saturn.nmi_state | |
| 205 | if ( state == saturn.nmi_state | |
| 197 | 206 | saturn.nmi_state = state; |
| 198 | if( state != CLEAR_LINE ) | |
| 207 | if ( state != CLEAR_LINE ) | |
| 199 | 208 | { |
| 200 | LOG(( "M6502#%d set_nmi_line(ASSERT)\n", cpu_getactivecpu())); | |
| 201 | saturn_ICount -= 7; | |
| 202 | saturn_push(saturn.pc); | |
| 203 | saturn.pc=IRQ_ADDRESS; | |
| 204 | ||
| 205 | LOG(("M6502#%d takes NMI ($%04x)\n", cpu_getactivecpu(), PC)); | |
| 206 | change_pc(saturn.pc); | |
| 209 | LOG(( "SATURN#%d set_nmi_line(ASSERT)\n", cpu_getactivecpu())); | |
| 210 | saturn.pending_irq = 1; | |
| 207 | 211 | } |
| 208 | 212 | } |
| 209 | 213 | |
| 210 | void saturn_set_irq_line( | |
| 214 | static void saturn_set_irq_line( | |
| 211 | 215 | { |
| 216 | if ( state == saturn.irq_state ) return; | |
| 212 | 217 | saturn.irq_state = state; |
| 213 | if( state != CLEAR_LINE ) | |
| 218 | if ( state != CLEAR_LINE && saturn.irq_enable ) | |
| 214 | 219 | { |
| 215 | LOG(( " | |
| 220 | LOG(( "SATURN#%d set_irq_line(ASSERT)\n", cpu_getactivecpu())); | |
| 216 | 221 | saturn.pending_irq = 1; |
| 217 | 222 | } |
| 218 | 223 | } |
| 219 | 224 | |
| 220 | void saturn_set_ | |
| 225 | static void saturn_set_w | |
| 221 | 226 | { |
| 222 | saturn.irq_callback = callback; | |
| 227 | if (saturn.sleeping && state==1) | |
| 228 | { | |
| 229 | LOG(( "SATURN#%d set_wakeup_line(ASSERT)\n", cpu_getactivecpu())); | |
| 230 | if (saturn.irq_callback) (*saturn.irq_callback)(SATURN_WAKEUP_LINE); | |
| 231 | saturn.sleeping = 0; | |
| 232 | } | |
| 223 | 233 | } |
| 224 | #endif | |
| 225 | 234 | |
| 226 | #if 0 | |
| 227 | static void saturn_state_save(void *file) | |
| 228 | { | |
| 229 | int cpu = cpu_getactivecpu(); | |
| 230 | state_save_UINT16(file,"m6502",cpu,"PC",&m6502.pc.w.l,2); | |
| 231 | state_save_UINT16(file,"m6502",cpu,"SP",&m6502.sp.w.l,2); | |
| 232 | state_save_UINT8(file,"m6502",cpu,"P",&m6502.p,1); | |
| 233 | state_save_UINT8(file,"m6502",cpu,"A",&m6502.a,1); | |
| 234 | state_save_UINT8(file,"m6502",cpu,"X",&m6502.x,1); | |
| 235 | state_save_UINT8(file,"m6502",cpu,"Y",&m6502.y,1); | |
| 236 | state_save_UINT8(file,"m6502",cpu,"PENDING",&m6502.pending_irq,1); | |
| 237 | state_save_UINT8(file,"m6502",cpu,"AFTER_CLI",&m6502.after_cli,1); | |
| 238 | state_save_UINT8(file,"m6502",cpu,"NMI_STATE",&m6502.nmi_state,1); | |
| 239 | state_save_UINT8(file,"m6502",cpu,"IRQ_STATE",&m6502.irq_state,1); | |
| 240 | state_save_UINT8(file,"m6502",cpu,"SO_STATE",&m6502.so_state,1); | |
| 241 | } | |
| 242 | 235 | |
| 243 | static void saturn_state_load(void *file) | |
| 244 | { | |
| 245 | int cpu = cpu_getactivecpu(); | |
| 246 | state_load_UINT16(file,"m6502",cpu,"PC",&m6502.pc.w.l,2); | |
| 247 | state_load_UINT16(file,"m6502",cpu,"SP",&m6502.sp.w.l,2); | |
| 248 | state_load_UINT8(file,"m6502",cpu,"P",&m6502.p,1); | |
| 249 | state_load_UINT8(file,"m6502",cpu,"A",&m6502.a,1); | |
| 250 | state_load_UINT8(file,"m6502",cpu,"X",&m6502.x,1); | |
| 251 | state_load_UINT8(file,"m6502",cpu,"Y",&m6502.y,1); | |
| 252 | state_load_UINT8(file,"m6502",cpu,"PENDING",&m6502.pending_irq,1); | |
| 253 | state_load_UINT8(file,"m6502",cpu,"AFTER_CLI",&m6502.after_cli,1); | |
| 254 | state_load_UINT8(file,"m6502",cpu,"NMI_STATE",&m6502.nmi_state,1); | |
| 255 | state_load_UINT8(file,"m6502",cpu,"IRQ_STATE",&m6502.irq_state,1); | |
| 256 | state_load_UINT8(file,"m6502",cpu,"SO_STATE",&m6502.so_state,1); | |
| 257 | } | |
| 258 | #endif | |
| 259 | 236 | |
| 260 | 237 | /************************************************************************** |
| 261 | 238 | * Generic set_info |
| 262 | 239 | **************************************************************************/ |
| 263 | 240 | |
| 241 | static void IntReg64(Saturn64 r, INT64 d) | |
| 242 | { | |
| 243 | int i; | |
| 244 | for (i=0; i<16; i++) | |
| 245 | r[i] = (d >> (4*i)) & 0xf; | |
| 246 | } | |
| 247 | ||
| 248 | ||
| 264 | 249 | static void saturn_set_info(UINT32 state, cpuinfo *info) |
| 265 | 250 | { |
| 266 | 251 | switch (state) |
| 267 | 252 | { |
| 268 | 253 | /* --- the following bits of info are set as 64-bit signed integers --- */ |
| 269 | case CPUINFO_INT_INPUT_STATE + SATURN_NMI_STATE: saturn.nmi_state = info->i; break; | |
| 270 | case CPUINFO_INT_INPUT_STATE + SATURN_IRQ_STATE: saturn.irq_state = info->i; break; | |
| 254 | case CPUINFO_INT_INPUT_STATE + SATURN_NMI_LINE: saturn_set_nmi_line(info->i); break; | |
| 255 | case CPUINFO_INT_INPUT_STATE + SATURN_IRQ_LINE: saturn_set_irq_line(info->i); break; | |
| 256 | case CPUINFO_INT_INPUT_STATE + SATURN_WAKEUP_LINE: saturn_set_wakeup_line(info->i); break; | |
| 271 | 257 | |
| 272 | 258 | case CPUINFO_INT_PC: |
| 273 | 259 | case CPUINFO_INT_REGISTER + SATURN_PC: saturn.pc = info->i; change_pc(saturn.pc); break; |
| 274 | case CPUINFO_INT_SP: saturn.stackpointer = info->i; break; | |
| 275 | 260 | case CPUINFO_INT_REGISTER + SATURN_D0: saturn.d[0] = info->i; break; |
| 276 | 261 | case CPUINFO_INT_REGISTER + SATURN_D1: saturn.d[1] = info->i; break; |
| 277 | #if 0 | |
| 278 | case CPUINFO_INT_REGISTER + SATURN_A: saturn.reg[A] = info->i; break; | |
| 279 | case CPUINFO_INT_REGISTER + SATURN_B: saturn.reg[B] = info->i; break; | |
| 280 | case CPUINFO_INT_REGISTER + SATURN_C: saturn.reg[C] = info->i; break; | |
| 281 | case CPUINFO_INT_REGISTER + SATURN_D: saturn.reg[D] = info->i; break; | |
| 282 | case CPUINFO_INT_REGISTER + SATURN_R0: saturn.reg[R0] = info->i; break; | |
| 283 | case CPUINFO_INT_REGISTER + SATURN_R1: saturn.reg[R1] = info->i; break; | |
| 284 | case CPUINFO_INT_REGISTER + SATURN_R2: saturn.reg[R2] = info->i; break; | |
| 285 | case CPUINFO_INT_REGISTER + SATURN_R3: saturn.reg[R3] = info->i; break; | |
| 286 | case CPUINFO_INT_REGISTER + SATURN_R4: saturn.reg[R4] = info->i; break; | |
| 287 | #endif | |
| 262 | case CPUINFO_INT_REGISTER + SATURN_A: IntReg64(saturn.reg[A], info->i); break; | |
| 263 | case CPUINFO_INT_REGISTER + SATURN_B: IntReg64(saturn.reg[B], info->i); break; | |
| 264 | case CPUINFO_INT_REGISTER + SATURN_C: IntReg64(saturn.reg[C], info->i); break; | |
| 265 | case CPUINFO_INT_REGISTER + SATURN_D: IntReg64(saturn.reg[D], info->i); break; | |
| 266 | case CPUINFO_INT_REGISTER + SATURN_R0: IntReg64(saturn.reg[R0], info->i); break; | |
| 267 | case CPUINFO_INT_REGISTER + SATURN_R1: IntReg64(saturn.reg[R1], info->i); break; | |
| 268 | case CPUINFO_INT_REGISTER + SATURN_R2: IntReg64(saturn.reg[R2], info->i); break; | |
| 269 | case CPUINFO_INT_REGISTER + SATURN_R3: IntReg64(saturn.reg[R3], info->i); break; | |
| 270 | case CPUINFO_INT_REGISTER + SATURN_R4: IntReg64(saturn.reg[R4], info->i); break; | |
| 288 | 271 | case CPUINFO_INT_REGISTER + SATURN_P: saturn.p = info->i; break; |
| 289 | case CPUINFO_INT_REGISTER + SATURN_IN: saturn.in = info->i; break; | |
| 290 | 272 | case CPUINFO_INT_REGISTER + SATURN_OUT: saturn.out = info->i; break; |
| 291 | 273 | case CPUINFO_INT_REGISTER + SATURN_CARRY: saturn.carry = info->i; break; |
| 292 | 274 | case CPUINFO_INT_REGISTER + SATURN_ST: saturn.st = info->i; break; |
| r2724 | r2725 | |
| 299 | 281 | case CPUINFO_INT_REGISTER + SATURN_RSTK5: saturn.rstk[5] = info->i; break; |
| 300 | 282 | case CPUINFO_INT_REGISTER + SATURN_RSTK6: saturn.rstk[6] = info->i; break; |
| 301 | 283 | case CPUINFO_INT_REGISTER + SATURN_RSTK7: saturn.rstk[7] = info->i; break; |
| 284 | case CPUINFO_INT_REGISTER + SATURN_SLEEPING: saturn.sleeping = info->i; | |
| 302 | 285 | } |
| 303 | 286 | } |
| 304 | 287 | |
| r2724 | r2725 | |
| 306 | 289 | * Generic get_info |
| 307 | 290 | **************************************************************************/ |
| 308 | 291 | |
| 292 | #define Reg64Data(s) s[15],s[14],s[13],s[12],s[11],s[10],s[9],s[8],s[7],s[6],s[5],s[4],s[3],s[2],s[1],s[0] | |
| 293 | #define Reg64Format "%x %x%x%x%x%x%x%x %x%x%x %x%x%x%x%x" | |
| 294 | ||
| 295 | static INT64 Reg64Int(Saturn64 r) | |
| 296 | { | |
| 297 | INT64 x = 0; | |
| 298 | int i; | |
| 299 | for (i=0; i<16; i++) | |
| 300 | x |= (INT64) r[i] << (4*i); | |
| 301 | return x; | |
| 302 | } | |
| 303 | ||
| 309 | 304 | void saturn_get_info(UINT32 state, cpuinfo *info) |
| 310 | 305 | { |
| 311 | 306 | switch (state) |
| r2724 | r2725 | |
| 332 | 327 | case CPUINFO_INT_ADDRBUS_WIDTH + ADDRESS_SPACE_IO: info->i = 0; break; |
| 333 | 328 | case CPUINFO_INT_ADDRBUS_SHIFT + ADDRESS_SPACE_IO: info->i = 0; break; |
| 334 | 329 | |
| 335 | case CPUINFO_INT_INPUT_STATE + SATURN_NMI_STATE: info->i = saturn.nmi_state; break; | |
| 336 | case CPUINFO_INT_INPUT_STATE + SATURN_IRQ_STATE: info->i = saturn.irq_state; break; | |
| 330 | case CPUINFO_INT_INPUT_STATE + SATURN_NMI_LINE: info->i = saturn.nmi_state; break; | |
| 331 | case CPUINFO_INT_INPUT_STATE + SATURN_IRQ_LINE: info->i = saturn.irq_state; break; | |
| 337 | 332 | |
| 338 | 333 | case CPUINFO_INT_PREVIOUSPC: info->i = saturn.oldpc; break; |
| 339 | 334 | |
| 340 | 335 | case CPUINFO_INT_PC: |
| 341 | 336 | case CPUINFO_INT_REGISTER + SATURN_PC: info->i = saturn.pc; break; |
| 342 | case CPUINFO_INT_SP: info->i = saturn.stackpointer; break; | |
| 343 | 337 | case CPUINFO_INT_REGISTER + SATURN_D0: info->i = saturn.d[0]; break; |
| 344 | 338 | case CPUINFO_INT_REGISTER + SATURN_D1: info->i = saturn.d[1]; break; |
| 345 | #if 0 | |
| 346 | case CPUINFO_INT_REGISTER + SATURN_A: info->i = saturn.reg[A]; break; | |
| 347 | case CPUINFO_INT_REGISTER + SATURN_B: info->i = saturn.reg[B]; break; | |
| 348 | case CPUINFO_INT_REGISTER + SATURN_C: info->i = saturn.reg[C]; break; | |
| 349 | case CPUINFO_INT_REGISTER + SATURN_D: info->i = saturn.reg[D]; break; | |
| 350 | case CPUINFO_INT_REGISTER + SATURN_R0: info->i = saturn.reg[R0]; break; | |
| 351 | case CPUINFO_INT_REGISTER + SATURN_R1: info->i = saturn.reg[R1]; break; | |
| 352 | case CPUINFO_INT_REGISTER + SATURN_R2: info->i = saturn.reg[R2]; break; | |
| 353 | case CPUINFO_INT_REGISTER + SATURN_R3: info->i = saturn.reg[R3]; break; | |
| 354 | case CPUINFO_INT_REGISTER + SATURN_R4: info->i = saturn.reg[R4]; break; | |
| 355 | #endif | |
| 339 | ||
| 340 | case CPUINFO_INT_REGISTER + SATURN_A: info->i = Reg64Int(saturn.reg[A]); break; | |
| 341 | case CPUINFO_INT_REGISTER + SATURN_B: info->i = Reg64Int(saturn.reg[B]); break; | |
| 342 | case CPUINFO_INT_REGISTER + SATURN_C: info->i = Reg64Int(saturn.reg[C]); break; | |
| 343 | case CPUINFO_INT_REGISTER + SATURN_D: info->i = Reg64Int(saturn.reg[D]); break; | |
| 344 | case CPUINFO_INT_REGISTER + SATURN_R0: info->i = Reg64Int(saturn.reg[R0]); break; | |
| 345 | case CPUINFO_INT_REGISTER + SATURN_R1: info->i = Reg64Int(saturn.reg[R1]); break; | |
| 346 | case CPUINFO_INT_REGISTER + SATURN_R2: info->i = Reg64Int(saturn.reg[R2]); break; | |
| 347 | case CPUINFO_INT_REGISTER + SATURN_R3: info->i = Reg64Int(saturn.reg[R3]); break; | |
| 348 | case CPUINFO_INT_REGISTER + SATURN_R4: info->i = Reg64Int(saturn.reg[R4]); break; | |
| 349 | ||
| 356 | 350 | case CPUINFO_INT_REGISTER + SATURN_P: info->i = saturn.p; break; |
| 357 | case CPUINFO_INT_REGISTER + SATURN_IN: info->i = saturn.in; break; | |
| 358 | 351 | case CPUINFO_INT_REGISTER + SATURN_OUT: info->i = saturn.out; break; |
| 359 | 352 | case CPUINFO_INT_REGISTER + SATURN_CARRY: info->i = saturn.carry; break; |
| 360 | 353 | case CPUINFO_INT_REGISTER + SATURN_ST: info->i = saturn.st; break; |
| r2724 | r2725 | |
| 367 | 360 | case CPUINFO_INT_REGISTER + SATURN_RSTK5: info->i = saturn.rstk[5]; break; |
| 368 | 361 | case CPUINFO_INT_REGISTER + SATURN_RSTK6: info->i = saturn.rstk[6]; break; |
| 369 | 362 | case CPUINFO_INT_REGISTER + SATURN_RSTK7: info->i = saturn.rstk[7]; break; |
| 363 | case CPUINFO_INT_REGISTER + SATURN_SLEEPING: info->i = saturn.sleeping; | |
| 370 | 364 | |
| 371 | 365 | /* --- the following bits of info are returned as pointers to data or functions --- */ |
| 372 | 366 | case CPUINFO_PTR_SET_INFO: info->setinfo = saturn_set_info; break; |
| r2724 | r2725 | |
| 391 | 385 | case CPUINFO_STR_REGISTER + SATURN_PC: sprintf(info->s = cpuintrf_temp_str(), "PC: %.5x", saturn.pc);break; |
| 392 | 386 | case CPUINFO_STR_REGISTER + SATURN_D0: sprintf(info->s = cpuintrf_temp_str(), "D0: %.5x", saturn.d[0]);break; |
| 393 | 387 | case CPUINFO_STR_REGISTER + SATURN_D1: sprintf(info->s = cpuintrf_temp_str(), "D1: %.5x", saturn.d[1]);break; |
| 394 | case CPUINFO_STR_REGISTER + SATURN_A: sprintf(info->s = cpuintrf_temp_str(), "A: %.8x %.8x", saturn.reg[A].d[1], saturn.reg[A].d[0]);break; | |
| 395 | case CPUINFO_STR_REGISTER + SATURN_B: sprintf(info->s = cpuintrf_temp_str(), "B: %.8x %.8x", saturn.reg[B].d[1], saturn.reg[B].d[0]);break; | |
| 396 | case CPUINFO_STR_REGISTER + SATURN_C: sprintf(info->s = cpuintrf_temp_str(), "C: %.8x %.8x", saturn.reg[C].d[1], saturn.reg[C].d[0]);break; | |
| 397 | case CPUINFO_STR_REGISTER + SATURN_D: sprintf(info->s = cpuintrf_temp_str(), "D: %.8x %.8x", saturn.reg[D].d[1], saturn.reg[D].d[0]);break; | |
| 398 | case CPUINFO_STR_REGISTER + SATURN_R0: sprintf(info->s = cpuintrf_temp_str(), "R0:%.8x %.8x", saturn.reg[R0].d[1], saturn.reg[R0].d[0]);break; | |
| 399 | case CPUINFO_STR_REGISTER + SATURN_R1: sprintf(info->s = cpuintrf_temp_str(), "R1:%.8x %.8x", saturn.reg[R1].d[1], saturn.reg[R1].d[0]);break; | |
| 400 | case CPUINFO_STR_REGISTER + SATURN_R2: sprintf(info->s = cpuintrf_temp_str(), "R2:%.8x %.8x", saturn.reg[R2].d[1], saturn.reg[R2].d[0]);break; | |
| 401 | case CPUINFO_STR_REGISTER + SATURN_R3: sprintf(info->s = cpuintrf_temp_str(), "R3:%.8x %.8x", saturn.reg[R3].d[1], saturn.reg[R3].d[0]);break; | |
| 402 | case CPUINFO_STR_REGISTER + SATURN_R4: sprintf(info->s = cpuintrf_temp_str(), "R4:%.8x %.8x", saturn.reg[R4].d[1], saturn.reg[R4].d[0]);break; | |
| 388 | case CPUINFO_STR_REGISTER + SATURN_A: sprintf(info->s = cpuintrf_temp_str(), "A: " Reg64Format, Reg64Data(saturn.reg[A]));break; | |
| 389 | case CPUINFO_STR_REGISTER + SATURN_B: sprintf(info->s = cpuintrf_temp_str(), "B: " Reg64Format, Reg64Data(saturn.reg[B]));break; | |
| 390 | case CPUINFO_STR_REGISTER + SATURN_C: sprintf(info->s = cpuintrf_temp_str(), "C: " Reg64Format, Reg64Data(saturn.reg[C]));break; | |
| 391 | case CPUINFO_STR_REGISTER + SATURN_D: sprintf(info->s = cpuintrf_temp_str(), "D: " Reg64Format, Reg64Data(saturn.reg[D]));break; | |
| 392 | case CPUINFO_STR_REGISTER + SATURN_R0: sprintf(info->s = cpuintrf_temp_str(), "R0: " Reg64Format, Reg64Data(saturn.reg[R0]));break; | |
| 393 | case CPUINFO_STR_REGISTER + SATURN_R1: sprintf(info->s = cpuintrf_temp_str(), "R1: " Reg64Format, Reg64Data(saturn.reg[R1]));break; | |
| 394 | case CPUINFO_STR_REGISTER + SATURN_R2: sprintf(info->s = cpuintrf_temp_str(), "R2: " Reg64Format, Reg64Data(saturn.reg[R2]));break; | |
| 395 | case CPUINFO_STR_REGISTER + SATURN_R3: sprintf(info->s = cpuintrf_temp_str(), "R3: " Reg64Format, Reg64Data(saturn.reg[R3]));break; | |
| 396 | case CPUINFO_STR_REGISTER + SATURN_R4: sprintf(info->s = cpuintrf_temp_str(), "R4: " Reg64Format, Reg64Data(saturn.reg[R4]));break; | |
| 403 | 397 | case CPUINFO_STR_REGISTER + SATURN_P: sprintf(info->s = cpuintrf_temp_str(), "P:%x", saturn.p);break; |
| 404 | case CPUINFO_STR_REGISTER + SATURN_IN: sprintf(info->s = cpuintrf_temp_str(), "IN:%.4x", saturn.in);break; | |
| 405 | 398 | case CPUINFO_STR_REGISTER + SATURN_OUT: sprintf(info->s = cpuintrf_temp_str(), "OUT:%.3x", saturn.out);break; |
| 406 | 399 | case CPUINFO_STR_REGISTER + SATURN_CARRY: sprintf(info->s = cpuintrf_temp_str(), "Carry: %d", saturn.carry);break; |
| 407 | 400 | case CPUINFO_STR_REGISTER + SATURN_ST: sprintf(info->s = cpuintrf_temp_str(), "ST:%.4x", saturn.st);break; |
| r2724 | r2725 | |
| 414 | 407 | case CPUINFO_STR_REGISTER + SATURN_RSTK5: sprintf(info->s = cpuintrf_temp_str(), "RSTK5:%.5x", saturn.rstk[5]);break; |
| 415 | 408 | case CPUINFO_STR_REGISTER + SATURN_RSTK6: sprintf(info->s = cpuintrf_temp_str(), "RSTK6:%.5x", saturn.rstk[6]);break; |
| 416 | 409 | case CPUINFO_STR_REGISTER + SATURN_RSTK7: sprintf(info->s = cpuintrf_temp_str(), "RSTK7:%.5x", saturn.rstk[7]);break; |
| 417 | case CPUINFO_STR_REGISTER + SATURN_IRQ_STATE: sprintf(info->s = cpuintrf_temp_str(), "IRQ:%.4x", saturn.pending_irq);break; | |
| 418 | case CPUINFO_STR_FLAGS: sprintf(info->s = cpuintrf_temp_str(), "%c%c", saturn.decimal?'D':'.', saturn.carry ? 'C':'.'); break; | |
| 410 | case CPUINFO_STR_REGISTER + SATURN_IRQ_STATE: sprintf(info->s = cpuintrf_temp_str(), "IRQ:%c%c%c%i", saturn.in_irq?'S':'.', saturn.irq_enable?'e':'.', saturn.pending_irq?'p':'.', saturn.irq_state); break; | |
| 411 | case CPUINFO_STR_FLAGS: sprintf(info->s = cpuintrf_temp_str(), "%c%c", saturn.decimal?'D':'.', saturn.carry ? 'C':'.'); break; | |
| 412 | case CPUINFO_STR_REGISTER + SATURN_SLEEPING: sprintf(info->s = cpuintrf_temp_str(), "sleep:%c", saturn.sleeping?'S':'.'); break; | |
| 419 | 413 | } |
| 420 | 414 | } |
| r2724 | r2725 | |
|---|---|---|
| 43 | 43 | * |
| 44 | 44 | *************************************/ |
| 45 | 45 | |
| 46 | typedef void (*config_callback_func)(int config_type, xml_data_node *parentnode); | |
| 46 | typedef void (*config_callback_func)(running_machine *machine, int config_type, xml_data_node *parentnode); | |
| 47 | 47 | |
| 48 | 48 | |
| 49 | 49 | |
| r2724 | r2725 | |
| 54 | 54 | *************************************/ |
| 55 | 55 | |
| 56 | 56 | void config_init(running_machine *machine); |
| 57 | void config_register(const char *nodename, config_callback_func load, config_callback_func save); | |
| 57 | void config_register(running_machine *machine, const char *nodename, config_callback_func load, config_callback_func save); | |
| 58 | 58 | int config_load_settings(running_machine *machine); |
| 59 | 59 | void config_save_settings(running_machine *machine); |
| 60 | 60 |
| r2724 | r2725 | |
|---|---|---|
| 78 | 78 | static void ui_gfx_exit(running_machine *machine); |
| 79 | 79 | |
| 80 | 80 | /* palette handling */ |
| 81 | static void palette_handle_keys(ui_gfx_state *state); | |
| 82 | static void palette_handler(ui_gfx_state *state); | |
| 81 | static void palette_handle_keys(running_machine *machine, ui_gfx_state *state); | |
| 82 | static void palette_handler(running_machine *machine, ui_gfx_state *state); | |
| 83 | 83 | |
| 84 | 84 | /* graphics set handling */ |
| 85 | static void gfxset_handle_keys(ui_gfx_state *state, int xcells, int ycells); | |
| 85 | static void gfxset_handle_keys(running_machine *machine, ui_gfx_state *state, int xcells, int ycells); | |
| 86 | 86 | static void gfxset_draw_item(const gfx_element *gfx, int index, bitmap_t *bitmap, int dstx, int dsty, int color, int rotate); |
| 87 | 87 | static void gfxset_update_bitmap(ui_gfx_state *state, int xcells, int ycells, gfx_element *gfx); |
| 88 | static void gfxset_handler(ui_gfx_state *state); | |
| 88 | static void gfxset_handler(running_machine *machine, ui_gfx_state *state); | |
| 89 | 89 | |
| 90 | 90 | /* tilemap handling */ |
| 91 | static void tilemap_handle_keys(ui_gfx_state *state, int viswidth, int visheight); | |
| 91 | static void tilemap_handle_keys(running_machine *machine, ui_gfx_state *state, int viswidth, int visheight); | |
| 92 | 92 | static void tilemap_update_bitmap(ui_gfx_state *state, int width, int height); |
| 93 | static void tilemap_handler(ui_gfx_state *state); | |
| 93 | static void tilemap_handler(running_machine *machine, ui_gfx_state *state); | |
| 94 | 94 | |
| 95 | 95 | |
| 96 | 96 | |
| r2724 | r2725 | |
| 170 | 170 | /* if we have a palette, display it */ |
| 171 | 171 | if (machine->config->total_colors > 0) |
| 172 | 172 | { |
| 173 | palette_handler(state); | |
| 173 | palette_handler(machine, state); | |
| 174 | 174 | break; |
| 175 | 175 | } |
| 176 | 176 | |
| r2724 | r2725 | |
| 181 | 181 | /* if we have graphics sets, display them */ |
| 182 | 182 | if (machine->gfx[0] != NULL) |
| 183 | 183 | { |
| 184 | gfxset_handler(state); | |
| 184 | gfxset_handler(machine, state); | |
| 185 | 185 | break; |
| 186 | 186 | } |
| 187 | 187 | |
| r2724 | r2725 | |
| 192 | 192 | /* if we have tilemaps, display them */ |
| 193 | 193 | if (tilemap_count() > 0) |
| 194 | 194 | { |
| 195 | tilemap_handler(state); | |
| 195 | tilemap_handler(machine, state); | |
| 196 | 196 | break; |
| 197 | 197 | } |
| 198 | 198 | |
| r2724 | r2725 | |
| 201 | 201 | } |
| 202 | 202 | |
| 203 | 203 | /* handle keys */ |
| 204 | if (input_ui_pressed(IPT_UI_SELECT)) | |
| 204 | if (input_ui_pressed(machine, IPT_UI_SELECT)) | |
| 205 | 205 | { |
| 206 | 206 | state->mode = (state->mode + 1) % 3; |
| 207 | 207 | state->bitmap_dirty = TRUE; |
| 208 | 208 | } |
| 209 | 209 | |
| 210 | if (input_ui_pressed(IPT_UI_PAUSE)) | |
| 210 | if (input_ui_pressed(machine, IPT_UI_PAUSE)) | |
| 211 | 211 | mame_pause(machine, !mame_is_paused(machine)); |
| 212 | 212 | |
| 213 | if (input_ui_pressed(IPT_UI_CANCEL) || input_ui_pressed(IPT_UI_SHOW_GFX)) | |
| 213 | if (input_ui_pressed(machine, IPT_UI_CANCEL) || input_ui_pressed(machine, IPT_UI_SHOW_GFX)) | |
| 214 | 214 | goto cancel; |
| 215 | 215 | |
| 216 | 216 | return uistate; |
| r2724 | r2725 | |
| 233 | 233 | viewer |
| 234 | 234 | -------------------------------------------------*/ |
| 235 | 235 | |
| 236 | static void palette_handler(ui_gfx_state *state) | |
| 236 | static void palette_handler(running_machine *machine, ui_gfx_state *state) | |
| 237 | 237 | { |
| 238 | 238 | int total = state->palette.which ? colortable_palette_get_size(Machine->colortable) : Machine->config->total_colors; |
| 239 | 239 | const char *title = state->palette.which ? "COLORTABLE" : "PALETTE"; |
| r2724 | r2725 | |
| 344 | 344 | } |
| 345 | 345 | |
| 346 | 346 | /* handle keys */ |
| 347 | palette_handle_keys(state); | |
| 347 | palette_handle_keys(machine, state); | |
| 348 | 348 | } |
| 349 | 349 | |
| 350 | 350 | |
| r2724 | r2725 | |
| 353 | 353 | palette viewer |
| 354 | 354 | -------------------------------------------------*/ |
| 355 | 355 | |
| 356 | static void palette_handle_keys(ui_gfx_state *state) | |
| 356 | static void palette_handle_keys(running_machine *machine, ui_gfx_state *state) | |
| 357 | 357 | { |
| 358 | 358 | int rowcount, screencount; |
| 359 | 359 | int total; |
| 360 | 360 | |
| 361 | 361 | /* handle zoom (minus,plus) */ |
| 362 | if (input_ui_pressed(IPT_UI_ZOOM_OUT)) | |
| 362 | if (input_ui_pressed(machine, IPT_UI_ZOOM_OUT)) | |
| 363 | 363 | state->palette.count /= 2; |
| 364 | if (input_ui_pressed(IPT_UI_ZOOM_IN)) | |
| 364 | if (input_ui_pressed(machine, IPT_UI_ZOOM_IN)) | |
| 365 | 365 | state->palette.count *= 2; |
| 366 | 366 | |
| 367 | 367 | /* clamp within range */ |
| r2724 | r2725 | |
| 371 | 371 | state->palette.count = 64; |
| 372 | 372 | |
| 373 | 373 | /* handle colormap selection (open bracket,close bracket) */ |
| 374 | if (input_ui_pressed(IPT_UI_PREV_GROUP)) | |
| 374 | if (input_ui_pressed(machine, IPT_UI_PREV_GROUP)) | |
| 375 | 375 | state->palette.which--; |
| 376 | if (input_ui_pressed(IPT_UI_NEXT_GROUP)) | |
| 376 | if (input_ui_pressed(machine, IPT_UI_NEXT_GROUP)) | |
| 377 | 377 | state->palette.which++; |
| 378 | 378 | |
| 379 | 379 | /* clamp within range */ |
| r2724 | r2725 | |
| 390 | 390 | screencount = rowcount * rowcount; |
| 391 | 391 | |
| 392 | 392 | /* handle keyboard navigation */ |
| 393 | if (input_ui_pressed_repeat(IPT_UI_UP, 4)) | |
| 393 | if (input_ui_pressed_repeat(machine, IPT_UI_UP, 4)) | |
| 394 | 394 | state->palette.offset -= rowcount; |
| 395 | if (input_ui_pressed_repeat(IPT_UI_DOWN, 4)) | |
| 395 | if (input_ui_pressed_repeat(machine, IPT_UI_DOWN, 4)) | |
| 396 | 396 | state->palette.offset += rowcount; |
| 397 | if (input_ui_pressed_repeat(IPT_UI_PAGE_UP, 6)) | |
| 397 | if (input_ui_pressed_repeat(machine, IPT_UI_PAGE_UP, 6)) | |
| 398 | 398 | state->palette.offset -= screencount; |
| 399 | if (input_ui_pressed_repeat(IPT_UI_PAGE_DOWN, 6)) | |
| 399 | if (input_ui_pressed_repeat(machine, IPT_UI_PAGE_DOWN, 6)) | |
| 400 | 400 | state->palette.offset += screencount; |
| 401 | if (input_ui_pressed_repeat(IPT_UI_HOME, 4)) | |
| 401 | if (input_ui_pressed_repeat(machine, IPT_UI_HOME, 4)) | |
| 402 | 402 | state->palette.offset = 0; |
| 403 | if (input_ui_pressed_repeat(IPT_UI_END, 4)) | |
| 403 | if (input_ui_pressed_repeat(machine, IPT_UI_END, 4)) | |
| 404 | 404 | state->palette.offset = total; |
| 405 | 405 | |
| 406 | 406 | /* clamp within range */ |
| r2724 | r2725 | |
| 421 | 421 | viewer |
| 422 | 422 | -------------------------------------------------*/ |
| 423 | 423 | |
| 424 | static void gfxset_handler(ui_gfx_state *state) | |
| 424 | static void gfxset_handler(running_machine *machine, ui_gfx_state *state) | |
| 425 | 425 | { |
| 426 | 426 | render_font *ui_font = ui_get_font(); |
| 427 | 427 | int set = state->gfxset.set; |
| r2724 | r2725 | |
| 578 | 578 | ARGB_WHITE, state->texture, PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA)); |
| 579 | 579 | |
| 580 | 580 | /* handle keyboard navigation before drawing */ |
| 581 | gfxset_handle_keys(state, xcells, ycells); | |
| 581 | gfxset_handle_keys(machine, state, xcells, ycells); | |
| 582 | 582 | } |
| 583 | 583 | |
| 584 | 584 | |
| 585 | 585 | /*------------------------------------------------- |
| 586 | gfxset_handler - handle keys for the graphics | |
| 587 | viewer | |
| 586 | gfxset_handle_keys - handle keys for the | |
| 587 | graphics viewer | |
| 588 | 588 | -------------------------------------------------*/ |
| 589 | 589 | |
| 590 | static void gfxset_handle_keys(ui_gfx_state *state, int xcells, int ycells) | |
| 590 | static void gfxset_handle_keys(running_machine *machine, ui_gfx_state *state, int xcells, int ycells) | |
| 591 | 591 | { |
| 592 | 592 | ui_gfx_state oldstate = *state; |
| 593 | 593 | gfx_element *gfx; |
| 594 | 594 | int temp, set; |
| 595 | 595 | |
| 596 | 596 | /* handle gfxset selection (open bracket,close bracket) */ |
| 597 | if (input_ui_pressed(IPT_UI_PREV_GROUP)) | |
| 597 | if (input_ui_pressed(machine, IPT_UI_PREV_GROUP)) | |
| 598 | 598 | { |
| 599 | 599 | for (temp = state->gfxset.set - 1; temp >= 0; temp--) |
| 600 | 600 | if (Machine->gfx[temp] != NULL) |
| r2724 | r2725 | |
| 602 | 602 | if (temp >= 0) |
| 603 | 603 | state->gfxset.set = temp; |
| 604 | 604 | } |
| 605 | if (input_ui_pressed(IPT_UI_NEXT_GROUP)) | |
| 605 | if (input_ui_pressed(machine, IPT_UI_NEXT_GROUP)) | |
| 606 | 606 | { |
| 607 | 607 | for (temp = state->gfxset.set + 1; temp < MAX_GFX_ELEMENTS; temp++) |
| 608 | 608 | if (Machine->gfx[temp] != NULL) |
| r2724 | r2725 | |
| 616 | 616 | gfx = Machine->gfx[set]; |
| 617 | 617 | |
| 618 | 618 | /* handle cells per line (minus,plus) */ |
| 619 | if (input_ui_pressed(IPT_UI_ZOOM_OUT)) | |
| 619 | if (input_ui_pressed(machine, IPT_UI_ZOOM_OUT)) | |
| 620 | 620 | state->gfxset.count[set] = xcells - 1; |
| 621 | if (input_ui_pressed(IPT_UI_ZOOM_IN)) | |
| 621 | if (input_ui_pressed(machine, IPT_UI_ZOOM_IN)) | |
| 622 | 622 | state->gfxset.count[set] = xcells + 1; |
| 623 | 623 | |
| 624 | 624 | /* clamp within range */ |
| r2724 | r2725 | |
| 628 | 628 | state->gfxset.count[set] = 32; |
| 629 | 629 | |
| 630 | 630 | /* handle rotation (R) */ |
| 631 | if (input_ui_pressed(IPT_UI_ROTATE)) | |
| 631 | if (input_ui_pressed(machine, IPT_UI_ROTATE)) | |
| 632 | 632 | state->gfxset.rotate[set] = orientation_add(ROT90, state->gfxset.rotate[set]); |
| 633 | 633 | |
| 634 | 634 | /* handle navigation within the cells (up,down,pgup,pgdown) */ |
| 635 | if (input_ui_pressed_repeat(IPT_UI_UP, 4)) | |
| 635 | if (input_ui_pressed_repeat(machine, IPT_UI_UP, 4)) | |
| 636 | 636 | state->gfxset.offset[set] -= xcells; |
| 637 | if (input_ui_pressed_repeat(IPT_UI_DOWN, 4)) | |
| 637 | if (input_ui_pressed_repeat(machine, IPT_UI_DOWN, 4)) | |
| 638 | 638 | state->gfxset.offset[set] += xcells; |
| 639 | if (input_ui_pressed_repeat(IPT_UI_PAGE_UP, 6)) | |
| 639 | if (input_ui_pressed_repeat(machine, IPT_UI_PAGE_UP, 6)) | |
| 640 | 640 | state->gfxset.offset[set] -= xcells * ycells; |
| 641 | if (input_ui_pressed_repeat(IPT_UI_PAGE_DOWN, 6)) | |
| 641 | if (input_ui_pressed_repeat(machine, IPT_UI_PAGE_DOWN, 6)) | |
| 642 | 642 | state->gfxset.offset[set] += xcells * ycells; |
| 643 | if (input_ui_pressed_repeat(IPT_UI_HOME, 4)) | |
| 643 | if (input_ui_pressed_repeat(machine, IPT_UI_HOME, 4)) | |
| 644 | 644 | state->gfxset.offset[set] = 0; |
| 645 | if (input_ui_pressed_repeat(IPT_UI_END, 4)) | |
| 645 | if (input_ui_pressed_repeat(machine, IPT_UI_END, 4)) | |
| 646 | 646 | state->gfxset.offset[set] = gfx->total_elements; |
| 647 | 647 | |
| 648 | 648 | /* clamp within range */ |
| r2724 | r2725 | |
| 652 | 652 | state->gfxset.offset[set] = 0; |
| 653 | 653 | |
| 654 | 654 | /* handle color selection (left,right) */ |
| 655 | if (input_ui_pressed_repeat(IPT_UI_LEFT, 4)) | |
| 655 | if (input_ui_pressed_repeat(machine, IPT_UI_LEFT, 4)) | |
| 656 | 656 | state->gfxset.color[set] -= 1; |
| 657 | if (input_ui_pressed_repeat(IPT_UI_RIGHT, 4)) | |
| 657 | if (input_ui_pressed_repeat(machine, IPT_UI_RIGHT, 4)) | |
| 658 | 658 | state->gfxset.color[set] += 1; |
| 659 | 659 | |
| 660 | 660 | /* clamp within range */ |
| r2724 | r2725 | |
| 838 | 838 | viewer |
| 839 | 839 | -------------------------------------------------*/ |
| 840 | 840 | |
| 841 | static void tilemap_handler(ui_gfx_state *state) | |
| 841 | static void tilemap_handler(running_machine *machine, ui_gfx_state *state) | |
| 842 | 842 | { |
| 843 | 843 | render_font *ui_font = ui_get_font(); |
| 844 | 844 | float chwidth, chheight; |
| r2724 | r2725 | |
| 939 | 939 | PRIMFLAG_BLENDMODE(BLENDMODE_ALPHA) | PRIMFLAG_TEXORIENT(state->tilemap.rotate)); |
| 940 | 940 | |
| 941 | 941 | /* handle keyboard input */ |
| 942 | tilemap_handle_keys(state, mapboxwidth, mapboxheight); | |
| 942 | tilemap_handle_keys(machine, state, mapboxwidth, mapboxheight); | |
| 943 | 943 | } |
| 944 | 944 | |
| 945 | 945 | |
| r2724 | r2725 | |
| 948 | 948 | tilemap view |
| 949 | 949 | -------------------------------------------------*/ |
| 950 | 950 | |
| 951 | static void tilemap_handle_keys(ui_gfx_state *state, int viswidth, int visheight) | |
| 951 | static void tilemap_handle_keys(running_machine *machine, ui_gfx_state *state, int viswidth, int visheight) | |
| 952 | 952 | { |
| 953 | 953 | ui_gfx_state oldstate = *state; |
| 954 | 954 | UINT32 mapwidth, mapheight; |
| 955 | 955 | int step; |
| 956 | 956 | |
| 957 | 957 | /* handle tilemap selection (open bracket,close bracket) */ |
| 958 | if (input_ui_pressed(IPT_UI_PREV_GROUP)) | |
| 958 | if (input_ui_pressed(machine, IPT_UI_PREV_GROUP)) | |
| 959 | 959 | state->tilemap.which--; |
| 960 | if (input_ui_pressed(IPT_UI_NEXT_GROUP)) | |
| 960 | if (input_ui_pressed(machine, IPT_UI_NEXT_GROUP)) | |
| 961 | 961 | state->tilemap.which++; |
| 962 | 962 | |
| 963 | 963 | /* clamp within range */ |
| r2724 | r2725 | |
| 970 | 970 | tilemap_size_by_index(state->tilemap.which, &mapwidth, &mapheight); |
| 971 | 971 | |
| 972 | 972 | /* handle zoom (minus,plus) */ |
| 973 | if (input_ui_pressed(IPT_UI_ZOOM_OUT)) | |
| 973 | if (input_ui_pressed(machine, IPT_UI_ZOOM_OUT)) | |
| 974 | 974 | state->tilemap.zoom--; |
| 975 | if (input_ui_pressed(IPT_UI_ZOOM_IN)) | |
| 975 | if (input_ui_pressed(machine, IPT_UI_ZOOM_IN)) | |
| 976 | 976 | state->tilemap.zoom++; |
| 977 | 977 | |
| 978 | 978 | /* clamp within range */ |
| r2724 | r2725 | |
| 989 | 989 | } |
| 990 | 990 | |
| 991 | 991 | /* handle rotation (R) */ |
| 992 | if (input_ui_pressed(IPT_UI_ROTATE)) | |
| 992 | if (input_ui_pressed(machine, IPT_UI_ROTATE)) | |
| 993 | 993 | state->tilemap.rotate = orientation_add(ROT90, state->tilemap.rotate); |
| 994 | 994 | |
| 995 | 995 | /* handle navigation (up,down,left,right) */ |
| 996 | 996 | step = 8; |
| 997 | 997 | if (input_code_pressed(KEYCODE_LSHIFT)) step = 1; |
| 998 | 998 | if (input_code_pressed(KEYCODE_LCONTROL)) step = 64; |
| 999 | if (input_ui_pressed_repeat(IPT_UI_UP, 4)) | |
| 999 | if (input_ui_pressed_repeat(machine, IPT_UI_UP, 4)) | |
| 1000 | 1000 | state->tilemap.yoffs -= step; |
| 1001 | if (input_ui_pressed_repeat(IPT_UI_DOWN, 4)) | |
| 1001 | if (input_ui_pressed_repeat(machine, IPT_UI_DOWN, 4)) | |
| 1002 | 1002 | state->tilemap.yoffs += step; |
| 1003 | if (input_ui_pressed_repeat(IPT_UI_LEFT, 6)) | |
| 1003 | if (input_ui_pressed_repeat(machine, IPT_UI_LEFT, 6)) | |
| 1004 | 1004 | state->tilemap.xoffs -= step; |
| 1005 | if (input_ui_pressed_repeat(IPT_UI_RIGHT, 6)) | |
| 1005 | if (input_ui_pressed_repeat(machine, IPT_UI_RIGHT, 6)) | |
| 1006 | 1006 | state->tilemap.xoffs += step; |
| 1007 | 1007 | |
| 1008 | 1008 | /* clamp within range */ |
| r2724 | r2725 | |
|---|---|---|
| 108 | 108 | static void draw_mode23 (running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect); |
| 109 | 109 | static void draw_modebogus (running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect); |
| 110 | 110 | static void draw_sprites (running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect); |
| 111 | static void change_register (int reg, UINT8 data); | |
| 111 | static void change_register (running_machine *machine, int reg, UINT8 data); | |
| 112 | 112 | |
| 113 | 113 | static void (*const ModeHandlers[])(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect) = { |
| 114 | 114 | draw_mode0, draw_mode1, draw_mode2, draw_mode12, |
| r2724 | r2725 | |
| 138 | 138 | INT32 Addr; |
| 139 | 139 | int colour,pattern,nametbl,spriteattribute,spritepattern; |
| 140 | 140 | int colourmask,patternmask; |
| 141 | void (*INTCallback)(int); | |
| 141 | void (*INTCallback)(running_machine *, int); | |
| 142 | 142 | /* memory */ |
| 143 | 143 | UINT8 *vMem, *dBackMem; |
| 144 | 144 | bitmap_t *tmpbmp; |
| r2724 | r2725 | |
| 235 | 235 | } |
| 236 | 236 | |
| 237 | 237 | |
| 238 | void TMS9928A_post_load ( | |
| 238 | void TMS9928A_post_load (running_machine *machine) { | |
| 239 | 239 | int i; |
| 240 | 240 | |
| 241 | 241 | /* all registers need to be re-written, so tables are recalculated */ |
| 242 | 242 | for (i=0;i<8;i++) |
| 243 | change_register (i, tms.Regs[i]); | |
| 243 | change_register (machine, i, tms.Regs[i]); | |
| 244 | 244 | |
| 245 | 245 | /* make sure the interrupt request is set properly */ |
| 246 | if (tms.INTCallback) tms.INTCallback (tms.INT); | |
| 246 | if (tms.INTCallback) tms.INTCallback (machine, tms.INT); | |
| 247 | 247 | } |
| 248 | 248 | |
| 249 | 249 | |
| r2724 | r2725 | |
| 273 | 273 | tms.StatusReg = 0x1f; |
| 274 | 274 | if (tms.INT) { |
| 275 | 275 | tms.INT = 0; |
| 276 | if (tms.INTCallback) tms.INTCallback (tms.INT); | |
| 276 | if (tms.INTCallback) tms.INTCallback (machine, tms.INT); | |
| 277 | 277 | } |
| 278 | 278 | tms.latch = 0; |
| 279 | 279 | return b; |
| r2724 | r2725 | |
| 287 | 287 | /* register write */ |
| 288 | 288 | reg = data & 7; |
| 289 | 289 | /*if (tms.FirstByte != tms.Regs[reg])*/ /* Removed to fix ColecoVision MESS Driver*/ |
| 290 | change_register (reg, tms.FirstByte); | |
| 290 | change_register (machine, reg, tms.FirstByte); | |
| 291 | 291 | } else { |
| 292 | 292 | /* set read/write address */ |
| 293 | 293 | tms.Addr = ((UINT16)data << 8 | tms.FirstByte) & (tms.vramsize - 1); |
| r2724 | r2725 | |
| 303 | 303 | } |
| 304 | 304 | } |
| 305 | 305 | |
| 306 | static void change_register (int reg, UINT8 val) { | |
| 306 | static void change_register (running_machine *machine, int reg, UINT8 val) { | |
| 307 | 307 | static const UINT8 Mask[8] = |
| 308 | 308 | { 0x03, 0xfb, 0x0f, 0xff, 0x07, 0x7f, 0x07, 0xff }; |
| 309 | 309 | static const char *const modes[] = { |
| r2724 | r2725 | |
| 337 | 337 | b = (val & 0x20) && (tms.StatusReg & 0x80) ; |
| 338 | 338 | if (b != tms.INT) { |
| 339 | 339 | tms.INT = b; |
| 340 | if (tms.INTCallback) tms.INTCallback (tms.INT); | |
| 340 | if (tms.INTCallback) tms.INTCallback (machine, tms.INT); | |
| 341 | 341 | } |
| 342 | 342 | logerror("TMS9928A: %s\n", modes[TMS_MODE]); |
| 343 | 343 | break; |
| r2724 | r2725 | |
| 423 | 423 | return 0; |
| 424 | 424 | } |
| 425 | 425 | |
| 426 | int TMS9928A_interrupt | |
| 426 | int TMS9928A_interrupt | |
| 427 | 427 | int b; |
| 428 | 428 | |
| 429 | 429 | /* when skipping frames, calculate sprite collision */ |
| r2724 | r2725 | |
| 437 | 437 | b = (tms.Regs[1] & 0x20) != 0; |
| 438 | 438 | if (b != tms.INT) { |
| 439 | 439 | tms.INT = b; |
| 440 | if (tms.INTCallback) tms.INTCallback (tms.INT); | |
| 440 | if (tms.INTCallback) tms.INTCallback (machine, tms.INT); | |
| 441 | 441 | } |
| 442 | 442 | |
| 443 | 443 | return b; |
| r2724 | r2725 | |
|---|---|---|
| 40 | 40 | int vram_size; |
| 41 | 41 | /* interrupt */ |
| 42 | 42 | UINT8 INT; |
| 43 | void (*INTCallback)(int); | |
| 43 | void (*INTCallback)(running_machine *, int); | |
| 44 | 44 | int scanline; |
| 45 | 45 | /* blinking */ |
| 46 | 46 | int blink, blink_count; |
| r2724 | r2725 | |
| 483 | 483 | |
| 484 | 484 | ***************************************************************************/ |
| 485 | 485 | |
| 486 | void v9938_init (running_machine *machine, int which, const device_config *screen, bitmap_t *bitmap, int model, int vram_size, void (*callback)(int) ) | |
| 486 | void v9938_init (running_machine *machine, int which, const device_config *screen, bitmap_t *bitmap, int model, int vram_size, void (*callback)(running_machine *, int) ) | |
| 487 | 487 | { |
| 488 | 488 | vdp = &vdps[which]; |
| 489 | 489 | |
| r2724 | r2725 | |
| 610 | 610 | ** called; because of this Mr. Ghost, Xevious and SD Snatcher don't |
| 611 | 611 | ** run. As a patch it's called every scanline |
| 612 | 612 | */ |
| 613 | vdp->INTCallback (n); | |
| 613 | vdp->INTCallback (Machine, n); | |
| 614 | 614 | } |
| 615 | 615 | |
| 616 | 616 | void v9938_set_sprite_limit (int which, int i) |
| r2724 | r2725 | |
|---|---|---|
| 27 | 27 | tms9928a_model model; /* model: tms9929(a) runs at 50Hz instead of 60Hz */ |
| 28 | 28 | int vram; /* VRAM size in bytes (4k, 8k or 16k) */ |
| 29 | 29 | int borderx, bordery; /* number of border pixels to show in each direction */ |
| 30 | void (*int_callback)(int); /* callback which is called whenever the state | |
| 30 | void (*int_callback)(running_machine *, int); /* callback which is called whenever the state | |
| 31 | 31 | ** of the INT output of the TMS9918A changes (may be NULL)*/ |
| 32 | 32 | } TMS9928a_interface; |
| 33 | 33 | |
| r2724 | r2725 | |
| 64 | 64 | ** This next function must be called 50 (tms9929a) or 60 (tms99x8a) times per second, |
| 65 | 65 | ** to generate the necessary interrupts |
| 66 | 66 | */ |
| 67 | int TMS9928A_interrupt ( | |
| 67 | int TMS9928A_interrupt (running_machine *machine); | |
| 68 | 68 | |
| 69 | 69 | /* |
| 70 | 70 | ** The parameter is a function pointer. This function is called whenever |
| r2724 | r2725 | |
| 80 | 80 | /* |
| 81 | 81 | ** After loading a state, call this function |
| 82 | 82 | */ |
| 83 | void TMS9928A_post_load ( | |
| 83 | void TMS9928A_post_load (running_machine *machine); | |
| 84 | 84 | |
| 85 | 85 | /* |
| 86 | 86 | ** MachineDriver video declarations for the TMS9928A chip |
| r2724 | r2725 | |
|---|---|---|
| 199 | 199 | static void check_stalled_cpu(running_machine *machine, voodoo_state *v, attotime current_time); |
| 200 | 200 | static void flush_fifos(voodoo_state *v, attotime current_time); |
| 201 | 201 | static TIMER_CALLBACK( stall_cpu_callback ); |
| 202 | static void stall_cpu(voodoo_state *v, int state, attotime current_time); | |
| 202 | static void stall_cpu(running_machine *machine, voodoo_state *v, int state, attotime current_time); | |
| 203 | 203 | static TIMER_CALLBACK( vblank_callback ); |
| 204 | 204 | static INT32 register_w(voodoo_state *v, offs_t offset, UINT32 data); |
| 205 | 205 | static INT32 lfb_w(voodoo_state *v, offs_t offset, UINT32 data, UINT32 mem_mask, int forcefront); |
| 206 | 206 | static INT32 texture_w(voodoo_state *v, offs_t offset, UINT32 data); |
| 207 | static void voodoo_w(voodoo_state *v, offs_t offset, UINT32 data, UINT32 mem_mask); | |
| 207 | static void voodoo_w(running_machine *machine, voodoo_state *v, offs_t offset, UINT32 data, UINT32 mem_mask); | |
| 208 | 208 | static UINT32 voodoo_r(voodoo_state *v, offs_t offset); |
| 209 | 209 | static void banshee_w(voodoo_state *v, offs_t offset, UINT32 data, UINT32 mem_mask); |
| 210 | 210 | static UINT32 banshee_r(voodoo_state *v, offs_t offset, UINT32 mem_mask); |
| r2724 | r2725 | |
| 626 | 626 | } |
| 627 | 627 | |
| 628 | 628 | |
| 629 | void voodoo_set_vblank_callback(int which, void (*vblank)(int)) | |
| 629 | void voodoo_set_vblank_callback(int which, void (*vblank)(running_machine *, int)) | |
| 630 | 630 | { |
| 631 | 631 | voodoo[which]->fbi.vblank_client = vblank; |
| 632 | 632 | } |
| 633 | 633 | |
| 634 | 634 | |
| 635 | void voodoo_set_stall_callback(int which, void (*stall)(int)) | |
| 635 | void voodoo_set_stall_callback(int which, void (*stall)(running_machine *, int)) | |
| 636 | 636 | { |
| 637 | 637 | voodoo[which]->pci.stall_callback = stall; |
| 638 | 638 | } |
| r2724 | r2725 | |
| 647 | 647 | |
| 648 | 648 | WRITE32_HANDLER( voodoo_0_w ) |
| 649 | 649 | { |
| 650 | voodoo_w(voodoo[0], offset, data, mem_mask); | |
| 650 | voodoo_w(machine, voodoo[0], offset, data, mem_mask); | |
| 651 | 651 | } |
| 652 | 652 | |
| 653 | 653 | |
| 654 | 654 | WRITE32_HANDLER( voodoo_1_w ) |
| 655 | 655 | { |
| 656 | voodoo_w(voodoo[1], offset, data, mem_mask); | |
| 656 | voodoo_w(machine, voodoo[1], offset, data, mem_mask); | |
| 657 | 657 | } |
| 658 | 658 | |
| 659 | 659 | |
| r2724 | r2725 | |
| 1109 | 1109 | /* set internal state and call the client */ |
| 1110 | 1110 | v->fbi.vblank = FALSE; |
| 1111 | 1111 | if (v->fbi.vblank_client) |
| 1112 | (*v->fbi.vblank_client)(FALSE); | |
| 1112 | (*v->fbi.vblank_client)(machine, FALSE); | |
| 1113 | 1113 | |
| 1114 | 1114 | /* go to the end of the next frame */ |
| 1115 | 1115 | adjust_vblank_timer(v); |
| r2724 | r2725 | |
| 1149 | 1149 | /* set internal state and call the client */ |
| 1150 | 1150 | v->fbi.vblank = TRUE; |
| 1151 | 1151 | if (v->fbi.vblank_client) |
| 1152 | (*v->fbi.vblank_client)(TRUE); | |
| 1152 | (*v->fbi.vblank_client)(machine, TRUE); | |
| 1153 | 1153 | } |
| 1154 | 1154 | |
| 1155 | 1155 | |
| r2724 | r2725 | |
| 2194 | 2194 | |
| 2195 | 2195 | /* either call the callback, or trigger the trigger */ |
| 2196 | 2196 | if (v->pci.stall_callback) |
| 2197 | (*v->pci.stall_callback)(FALSE); | |
| 2197 | (*v->pci.stall_callback)(machine, FALSE); | |
| 2198 | 2198 | else |
| 2199 | 2199 | cpu_trigger(machine, v->trigger); |
| 2200 | 2200 | } |
| r2724 | r2725 | |
| 2207 | 2207 | } |
| 2208 | 2208 | |
| 2209 | 2209 | |
| 2210 | static void stall_cpu(voodoo_state *v, int state, attotime current_time) | |
| 2210 | static void stall_cpu(running_machine *machine, voodoo_state *v, int state, attotime current_time) | |
| 2211 | 2211 | { |
| 2212 | 2212 | /* sanity check */ |
| 2213 | 2213 | if (!v->pci.op_pending) fatalerror("FIFOs not empty, no op pending!"); |
| r2724 | r2725 | |
| 2218 | 2218 | |
| 2219 | 2219 | /* either call the callback, or spin the CPU */ |
| 2220 | 2220 | if (v->pci.stall_callback) |
| 2221 | (*v->pci.stall_callback)(TRUE); | |
| 2221 | (*v->pci.stall_callback)(machine, TRUE); | |
| 2222 | 2222 | else |
| 2223 | 2223 | cpu_spinuntil_trigger(v->trigger); |
| 2224 | 2224 | |
| r2724 | r2725 | |
| 3583 | 3583 | * |
| 3584 | 3584 | *************************************/ |
| 3585 | 3585 | |
| 3586 | static void voodoo_w(voodoo_state *v, offs_t offset, UINT32 data, UINT32 mem_mask) | |
| 3586 | static void voodoo_w(running_machine *machine, voodoo_state *v, offs_t offset, UINT32 data, UINT32 mem_mask) | |
| 3587 | 3587 | { |
| 3588 | 3588 | int stall = FALSE; |
| 3589 | 3589 | |
| r2724 | r2725 | |
| 3728 | 3728 | fifo_items(&v->fbi.fifo) >= 2 * 32 * FBIINIT0_MEMORY_FIFO_HWM(v->reg[fbiInit0].u)) |
| 3729 | 3729 | { |
| 3730 | 3730 | if (LOG_FIFO) logerror("VOODOO.%d.FIFO:voodoo_w hit memory FIFO HWM -- stalling\n", v->index); |
| 3731 | stall_cpu(v, STALLED_UNTIL_FIFO_LWM, timer_get_time()); | |
| 3731 | stall_cpu(machine, v, STALLED_UNTIL_FIFO_LWM, timer_get_time()); | |
| 3732 | 3732 | } |
| 3733 | 3733 | } |
| 3734 | 3734 | |
| r2724 | r2725 | |
| 3737 | 3737 | fifo_space(&v->pci.fifo) <= 2 * FBIINIT0_PCI_FIFO_LWM(v->reg[fbiInit0].u)) |
| 3738 | 3738 | { |
| 3739 | 3739 | if (LOG_FIFO) logerror("VOODOO.%d.FIFO:voodoo_w hit PCI FIFO free LWM -- stalling\n", v->index); |
| 3740 | stall_cpu(v, STALLED_UNTIL_FIFO_LWM, timer_get_time()); | |
| 3740 | stall_cpu(machine, v, STALLED_UNTIL_FIFO_LWM, timer_get_time()); | |
| 3741 | 3741 | } |
| 3742 | 3742 | |
| 3743 | 3743 | /* if we weren't ready, and this is a non-FIFO access, stall until the FIFOs are clear */ |
| 3744 | 3744 | if (stall) |
| 3745 | 3745 | { |
| 3746 | 3746 | if (LOG_FIFO_VERBOSE) logerror("VOODOO.%d.FIFO:voodoo_w wrote non-FIFO register -- stalling until clear\n", v->index); |
| 3747 | stall_cpu(v, STALLED_UNTIL_FIFO_EMPTY, timer_get_time()); | |
| 3747 | stall_cpu(machine, v, STALLED_UNTIL_FIFO_EMPTY, timer_get_time()); | |
| 3748 | 3748 | } |
| 3749 | 3749 | |
| 3750 | 3750 | profiler_mark(PROFILER_END); |
| r2724 | r2725 | |
|---|---|---|
| 14 | 14 | #define RENDER_LOW (1) |
| 15 | 15 | #define RENDER_AUTO (2) |
| 16 | 16 | |
| 17 | void v9938_init (running_machine *machine, int which, const device_config *screen, bitmap_t *bitmap, int model, int vram_size, void (*callback)(int) ); | |
| 17 | void v9938_init (running_machine *machine, int which, const device_config *screen, bitmap_t *bitmap, int model, int vram_size, void (*callback)(running_machine *, int) ); | |
| 18 | 18 | void v9938_reset (int which); |
| 19 | 19 | int v9938_interrupt (int which); |
| 20 | 20 | void v9938_set_sprite_limit (int which, int); |
| r2724 | r2725 | |
|---|---|---|
| 25 | 25 | int voodoo_get_type(int which); |
| 26 | 26 | int voodoo_is_stalled(int which); |
| 27 | 27 | void voodoo_set_init_enable(int which, UINT32 newval); |
| 28 | void voodoo_set_vblank_callback(int which, void (*vblank)(int)); | |
| 29 | void voodoo_set_stall_callback(int which, void (*stall)(int)); | |
| 28 | void voodoo_set_vblank_callback(int which, void (*vblank)(running_machine *, int)); | |
| 29 | void voodoo_set_stall_callback(int which, void (*stall)(running_machine *, int)); | |
| 30 | 30 | |
| 31 | 31 | READ32_HANDLER( voodoo_0_r ); |
| 32 | 32 | WRITE32_HANDLER( voodoo_0_w ); |
| r2724 | r2725 | |
|---|---|---|
| 1432 | 1432 | fifo_state fifo; /* PCI FIFO */ |
| 1433 | 1433 | UINT32 init_enable; /* initEnable value */ |
| 1434 | 1434 | UINT8 stall_state; /* state of the system if we're stalled */ |
| 1435 | void (*stall_callback)(int); /* callback for stalling/unstalling */ | |
| 1435 | void (*stall_callback)(running_machine *, int); /* callback for stalling/unstalling */ | |
| 1436 | 1436 | UINT8 op_pending; /* true if an operation is pending */ |
| 1437 | 1437 | attotime op_end_time; /* time when the pending operation ends */ |
| 1438 | 1438 | emu_timer *continue_timer; /* timer to use to continue processing */ |
| r2724 | r2725 | |
| 1555 | 1555 | UINT8 vblank_swap_pending; /* a swap is pending, waiting for a vblank */ |
| 1556 | 1556 | UINT8 vblank_swap; /* swap when we hit this count */ |
| 1557 | 1557 | UINT8 vblank_dont_swap; /* don't actually swap when we hit this point */ |
| 1558 | void (*vblank_client)(int); /* client callback */ | |
| 1558 | void (*vblank_client)(running_machine *, int); /* client callback */ | |
| 1559 | 1559 | |
| 1560 | 1560 | /* triangle setup info */ |
| 1561 | 1561 | UINT8 cheating_allowed; /* allow cheating? */ |
| r2724 | r2725 | |
|---|---|---|
| 36 | 36 | settings for a game |
| 37 | 37 | -------------------------------------------------*/ |
| 38 | 38 | |
| 39 | static void print_game_switches(FILE *out, const game_driver *game, const input_port_ | |
| 39 | static void print_game_switches(FILE *out, const game_driver *game, const input_port_config * | |
| 40 | 40 | { |
| 41 | /* iterate over input entries until we run out */ | |
| 42 | while (input->type != IPT_END) | |
| 43 | { | |
| 44 | /* once we hit a name entry, start outputting */ | |
| 45 | if (input->type == IPT_DIPSWITCH_NAME) | |
| 46 | { | |
| 47 | int def = input->default_value; | |
| 41 | const input_port_config *port; | |
| 42 | const input_field_config *field; | |
| 48 | 43 | |
| 49 | /* output the switch name information */ | |
| 50 | fprintf(out, "\t\t<dipswitch name=\"%s\">\n", xml_normalize_string(input->name)); | |
| 51 | ||
| 52 | /* loop over settings */ | |
| 53 | for (input++; input->type == IPT_DIPSWITCH_SETTING; input++) | |
| 44 | /* iterate looking for DIP switches */ | |
| 45 | for (port = portlist; port != NULL; port = port->next) | |
| 46 | for (field = port->fieldlist; field != NULL; field = field->next) | |
| 47 | if (field->type == IPT_DIPSWITCH) | |
| 54 | 48 | { |
| 55 | fprintf(out, "\t\t\t<dipvalue name=\"%s\"", xml_normalize_string(input->name)); | |
| 56 | if (def == input->default_value) | |
| 57 | fprintf(out, " default=\"yes\""); | |
| 58 | fprintf(out, "/>\n"); | |
| 59 | } | |
| 49 | const input_setting_config *setting; | |
| 60 | 50 | |
| 61 | /* terminate the switch entry */ | |
| 62 | fprintf(out, "\t\t</dipswitch>\n"); | |
| 63 | } | |
| 64 | else | |
| 65 | ++input; | |
| 66 | } | |
| 51 | /* output the switch name information */ | |
| 52 | fprintf(out, "\t\t<dipswitch name=\"%s\">\n", xml_normalize_string(input_field_name(field))); | |
| 53 | ||
| 54 | /* loop over settings */ | |
| 55 | for (setting = field->settinglist; setting != NULL; setting = setting->next) | |
| 56 | { | |
| 57 | fprintf(out, "\t\t\t<dipvalue name=\"%s\"", xml_normalize_string(setting->name)); | |
| 58 | if (setting->value == field->defvalue) | |
| 59 | fprintf(out, " default=\"yes\""); | |
| 60 | fprintf(out, "/>\n"); | |
| 61 | } | |
| 62 | ||
| 63 | /* terminate the switch entry */ | |
| 64 | fprintf(out, "\t\t</dipswitch>\n"); | |
| 65 | } | |
| 67 | 66 | } |
| 68 | 67 | |
| 69 | 68 | |
| r2724 | r2725 | |
| 72 | 71 | input |
| 73 | 72 | -------------------------------------------------*/ |
| 74 | 73 | |
| 75 | static void print_game_input(FILE *out, const game_driver *game, const input_port_ | |
| 74 | static void print_game_input(FILE *out, const game_driver *game, const input_port_config * | |
| 76 | 75 | { |
| 77 | 76 | /* fix me -- this needs to be cleaned up to match the core style */ |
| 78 | 77 | |
| r2724 | r2725 | |
| 97 | 96 | int keydelta; /* default analog keydelta */ |
| 98 | 97 | int reverse; /* default analog reverse setting */ |
| 99 | 98 | } control[ENDCONTROLTYPES]; |
| 99 | const input_port_config *port; | |
| 100 | const input_field_config *field; | |
| 100 | 101 | |
| 101 | 102 | for (i=0;i<ENDCONTROLTYPES;i++) |
| 102 | 103 | { |
| r2724 | r2725 | |
| 110 | 111 | control[i].reverse = 0; |
| 111 | 112 | } |
| 112 | 113 | |
| 113 | while (input->type != IPT_END) | |
| 114 | { | |
| 115 | if (nplayer < input->player+1) | |
| 116 | nplayer = input->player+1; | |
| 117 | ||
| 118 | switch (input->type) | |
| 114 | for (port = portlist; port != NULL; port = port->next) | |
| 115 | for (field = port->fieldlist; field != NULL; field = field->next) | |
| 119 | 116 | { |
| 120 | case IPT_JOYSTICK_LEFT: | |
| 121 | case IPT_JOYSTICK_RIGHT: | |
| 117 | if (nplayer < field->player+1) | |
| 118 | nplayer = field->player+1; | |
| 122 | 119 | |
| 123 | /* if control not defined, start it off as horizontal 2-way */ | |
| 124 | if (control[cjoy].Xway == NULL) | |
| 125 | control[cjoy].Xway = "joy2way"; | |
| 126 | else if (strcmp(control[cjoy].Xway,"joy2way") == 0) | |
| 127 | ; | |
| 128 | /* if already defined as vertical, make it 4 or 8 way */ | |
| 129 | else if (strcmp(control[cjoy].Xway,"vjoy2way") == 0) | |
| 130 | { | |
| 131 | if (input->way == 4) | |
| 132 | control[cjoy].Xway = "joy4way"; | |
| 133 | else | |
| 134 | control[cjoy].Xway = "joy8way"; | |
| 135 | } | |
| 136 | controlsyes = 1; | |
| 137 | break; | |
| 120 | switch (field->type) | |
| 121 | { | |
| 122 | case IPT_JOYSTICK_LEFT: | |
| 123 | case IPT_JOYSTICK_RIGHT: | |
| 138 | 124 | |
| 139 | case IPT_JOYSTICK_UP: | |
| 140 | case IPT_JOYSTICK_DOWN: | |
| 125 | /* if control not defined, start it off as horizontal 2-way */ | |
| 126 | if (control[cjoy].Xway == NULL) | |
| 127 | control[cjoy].Xway = "joy2way"; | |
| 128 | else if (strcmp(control[cjoy].Xway,"joy2way") == 0) | |
| 129 | ; | |
| 130 | /* if already defined as vertical, make it 4 or 8 way */ | |
| 131 | else if (strcmp(control[cjoy].Xway,"vjoy2way") == 0) | |
| 132 | { | |
| 133 | if (field->way == 4) | |
| 134 | control[cjoy].Xway = "joy4way"; | |
| 135 | else | |
| 136 | control[cjoy].Xway = "joy8way"; | |
| 137 | } | |
| 138 | controlsyes = 1; | |
| 139 | break; | |
| 141 | 140 | |
| 142 | /* if control not defined, start it off as vertical 2-way */ | |
| 143 | if (control[cjoy].Xway == NULL) | |
| 144 | control[cjoy].Xway = "vjoy2way"; | |
| 145 | else if (strcmp(control[cjoy].Xway,"vjoy2way") == 0) | |
| 146 | ; | |
| 147 | /* if already defined as horiz, make it 4 or 8way */ | |
| 148 | else if (strcmp(control[cjoy].Xway,"joy2way") == 0) | |
| 149 | { | |
| 150 | if (input->way == 4) | |
| 151 | control[cjoy].Xway = "joy4way"; | |
| 152 | else | |
| 153 | control[cjoy].Xway = "joy8way"; | |
| 154 | } | |
| 155 | controlsyes = 1; | |
| 156 | break; | |
| 141 | case IPT_JOYSTICK_UP: | |
| 142 | case IPT_JOYSTICK_DOWN: | |
| 157 | 143 | |
| 158 | case IPT_JOYSTICKRIGHT_UP: | |
| 159 | case IPT_JOYSTICKRIGHT_DOWN: | |
| 160 | case IPT_JOYSTICKLEFT_UP: | |
| 161 | case IPT_JOYSTICKLEFT_DOWN: | |
| 144 | /* if control not defined, start it off as vertical 2-way */ | |
| 145 | if (control[cjoy].Xway == NULL) | |
| 146 | control[cjoy].Xway = "vjoy2way"; | |
| 147 | else if (strcmp(control[cjoy].Xway,"vjoy2way") == 0) | |
| 148 | ; | |
| 149 | /* if already defined as horiz, make it 4 or 8way */ | |
| 150 | else if (strcmp(control[cjoy].Xway,"joy2way") == 0) | |
| 151 | { | |
| 152 | if (field->way == 4) | |
| 153 | control[cjoy].Xway = "joy4way"; | |
| 154 | else | |
| 155 | control[cjoy].Xway = "joy8way"; | |
| 156 | } | |
| 157 | controlsyes = 1; | |
| 158 | break; | |
| 162 | 159 | |
| 163 | /* if control not defined, start it off as vertical 2way */ | |
| 164 | if (control[cdoublejoy].Xway == NULL) | |
| 165 | control[cdoublejoy].Xway = "vdoublejoy2way"; | |
| 166 | else if (strcmp(control[cdoublejoy].Xway,"vdoublejoy2way") == 0) | |
| 167 | ; | |
| 168 | /* if already defined as horiz, make it 4 or 8 way */ | |
| 169 | else if (strcmp(control[cdoublejoy].Xway,"doublejoy2way") == 0) | |
| 170 | { | |
| 171 | if (input->way == 4) | |
| 172 | control[cdoublejoy].Xway = "doublejoy4way"; | |
| 173 | else | |
| 174 | control[cdoublejoy].Xway = "doublejoy8way"; | |
| 175 | } | |
| 176 | controlsyes = 1; | |
| 177 | break; | |
| 160 | case IPT_JOYSTICKRIGHT_UP: | |
| 161 | case IPT_JOYSTICKRIGHT_DOWN: | |
| 162 | case IPT_JOYSTICKLEFT_UP: | |
| 163 | case IPT_JOYSTICKLEFT_DOWN: | |
| 178 | 164 | |
| 179 | case IPT_JOYSTICKRIGHT_LEFT: | |
| 180 | case IPT_JOYSTICKRIGHT_RIGHT: | |
| 181 | case IPT_JOYSTICKLEFT_LEFT: | |
| 182 | case IPT_JOYSTICKLEFT_RIGHT: | |
| 165 | /* if control not defined, start it off as vertical 2way */ | |
| 166 | if (control[cdoublejoy].Xway == NULL) | |
| 167 | control[cdoublejoy].Xway = "vdoublejoy2way"; | |
| 168 | else if (strcmp(control[cdoublejoy].Xway,"vdoublejoy2way") == 0) | |
| 169 | ; | |
| 170 | /* if already defined as horiz, make it 4 or 8 way */ | |
| 171 | else if (strcmp(control[cdoublejoy].Xway,"doublejoy2way") == 0) | |
| 172 | { | |
| 173 | if (field->way == 4) | |
| 174 | control[cdoublejoy].Xway = "doublejoy4way"; | |
| 175 | else | |
| 176 | control[cdoublejoy].Xway = "doublejoy8way"; | |
| 177 | } | |
| 178 | controlsyes = 1; | |
| 179 | break; | |
| 183 | 180 | |
| 184 | /* if control not defined, start it off as horiz 2-way */ | |
| 185 | if (control[cdoublejoy].Xway == NULL) | |
| 186 | control[cdoublejoy].Xway = "doublejoy2way"; | |
| 187 | else if (strcmp(control[cdoublejoy].Xway,"doublejoy2way") == 0) | |
| 188 | ; | |
| 189 | /* if already defined as vertical, make it 4 or 8 way */ | |
| 190 | else if (strcmp(control[cdoublejoy].Xway,"vdoublejoy2way") == 0) | |
| 191 | { | |
| 192 | if (input->way == 4) | |
| 193 | control[cdoublejoy].Xway = "doublejoy4way"; | |
| 194 | else | |
| 195 | control[cdoublejoy].Xway = "doublejoy8way"; | |
| 196 | } | |
| 197 | controlsyes = 1; | |
| 198 | break; | |
| 181 | case IPT_JOYSTICKRIGHT_LEFT: | |
| 182 | case IPT_JOYSTICKRIGHT_RIGHT: | |
| 183 | case IPT_JOYSTICKLEFT_LEFT: | |
| 184 | case IPT_JOYSTICKLEFT_RIGHT: | |
| 199 | 185 | |
| 200 | /* mark as an analog input, and get analog stats after switch */ | |
| 201 | case IPT_PADDLE: | |
| 202 | analogcontrol = cpaddle; | |
| 203 | break; | |
| 204 | case IPT_DIAL: | |
| 205 | analogcontrol = cdial; | |
| 206 | break; | |
| 207 | case IPT_TRACKBALL_X: | |
| 208 | case IPT_TRACKBALL_Y: | |
| 209 | analogcontrol = ctrackball; | |
| 210 | break; | |
| 211 | case IPT_AD_STICK_X: | |
| 212 | case IPT_AD_STICK_Y: | |
| 213 | analogcontrol = cAD_stick; | |
| 214 | break; | |
| 215 | case IPT_LIGHTGUN_X: | |
| 216 | case IPT_LIGHTGUN_Y: | |
| 217 | analogcontrol = clightgun; | |
| 218 | break; | |
| 219 | case IPT_PEDAL: | |
| 220 | case IPT_PEDAL2: | |
| 221 | case IPT_PEDAL3: | |
| 222 | analogcontrol = cpedal; | |
| 223 | break; | |
| 186 | /* if control not defined, start it off as horiz 2-way */ | |
| 187 | if (control[cdoublejoy].Xway == NULL) | |
| 188 | control[cdoublejoy].Xway = "doublejoy2way"; | |
| 189 | else if (strcmp(control[cdoublejoy].Xway,"doublejoy2way") == 0) | |
| 190 | ; | |
| 191 | /* if already defined as vertical, make it 4 or 8 way */ | |
| 192 | else if (strcmp(control[cdoublejoy].Xway,"vdoublejoy2way") == 0) | |
| 193 | { | |
| 194 | if (field->way == 4) | |
| 195 | control[cdoublejoy].Xway = "doublejoy4way"; | |
| 196 | else | |
| 197 | control[cdoublejoy].Xway = "doublejoy8way"; | |
| 198 | } | |
| 199 | controlsyes = 1; | |
| 200 | break; | |
| 224 | 201 | |
| 225 | case IPT_BUTTON1: | |
| 226 | if (nbutton<1) nbutton = 1; | |
| 227 | break; | |
| 228 | case IPT_BUTTON2: | |
| 229 | if (nbutton<2) nbutton = 2; | |
| 230 | break; | |
| 231 | case IPT_BUTTON3: | |
| 232 | if (nbutton<3) nbutton = 3; | |
| 233 | break; | |
| 234 | case IPT_BUTTON4: | |
| 235 | if (nbutton<4) nbutton = 4; | |
| 236 | break; | |
| 237 | case IPT_BUTTON5: | |
| 238 | if (nbutton<5) nbutton = 5; | |
| 239 | break; | |
| 240 | case IPT_BUTTON6: | |
| 241 | if (nbutton<6) nbutton = 6; | |
| 242 | break; | |
| 243 | case IPT_BUTTON7: | |
| 244 | if (nbutton<7) nbutton = 7; | |
| 245 | break; | |
| 246 | case IPT_BUTTON8: | |
| 247 | if (nbutton<8) nbutton = 8; | |
| 248 | break; | |
| 249 | case IPT_BUTTON9: | |
| 250 | if (nbutton<9) nbutton = 9; | |
| 251 | break; | |
| 252 | case IPT_BUTTON10: | |
| 253 | if (nbutton<10) nbutton = 10; | |
| 254 | break; | |
| 202 | /* mark as an analog input, and get analog stats after switch */ | |
| 203 | case IPT_PADDLE: | |
| 204 | analogcontrol = cpaddle; | |
| 205 | break; | |
| 206 | case IPT_DIAL: | |
| 207 | analogcontrol = cdial; | |
| 208 | break; | |
| 209 | case IPT_TRACKBALL_X: | |
| 210 | case IPT_TRACKBALL_Y: | |
| 211 | analogcontrol = ctrackball; | |
| 212 | break; | |
| 213 | case IPT_AD_STICK_X: | |
| 214 | case IPT_AD_STICK_Y: | |
| 215 | analogcontrol = cAD_stick; | |
| 216 | break; | |
| 217 | case IPT_LIGHTGUN_X: | |
| 218 | case IPT_LIGHTGUN_Y: | |
| 219 | analogcontrol = clightgun; | |
| 220 | break; | |
| 221 | case IPT_PEDAL: | |
| 222 | case IPT_PEDAL2: | |
| 223 | case IPT_PEDAL3: | |
| 224 | analogcontrol = cpedal; | |
| 225 | break; | |
| 255 | 226 | |
| 256 | case IPT_COIN1: | |
| 257 | if (ncoin < 1) ncoin = 1; | |
| 258 | break; | |
| 259 | case IPT_COIN2: | |
| 260 | if (ncoin < 2) ncoin = 2; | |
| 261 | break; | |
| 262 | case IPT_COIN3: | |
| 263 | if (ncoin < 3) ncoin = 3; | |
| 264 | break; | |
| 265 | case IPT_COIN4: | |
| 266 | if (ncoin < 4) ncoin = 4; | |
| 267 | break; | |
| 268 | case IPT_COIN5: | |
| 269 | if (ncoin < 5) ncoin = 5; | |
| 270 | break; | |
| 271 | case IPT_COIN6: | |
| 272 | if (ncoin < 6) ncoin = 6; | |
| 273 | break; | |
| 274 | case IPT_COIN7: | |
| 275 | if (ncoin < 7) ncoin = 7; | |
| 276 | break; | |
| 277 | case IPT_COIN8: | |
| 278 | if (ncoin < 8) ncoin = 8; | |
| 279 | break; | |
| 280 | case IPT_SERVICE : | |
| 281 | service = "yes"; | |
| 282 | break; | |
| 283 | case IPT_TILT : | |
| 284 | tilt = "yes"; | |
| 285 | break; | |
| 286 | } | |
| 227 | case IPT_BUTTON1: | |
| 228 | case IPT_BUTTON2: | |
| 229 | case IPT_BUTTON3: | |
| 230 | case IPT_BUTTON4: | |
| 231 | case IPT_BUTTON5: | |
| 232 | case IPT_BUTTON6: | |
| 233 | case IPT_BUTTON7: | |
| 234 | case IPT_BUTTON8: | |
| 235 | case IPT_BUTTON9: | |
| 236 | case IPT_BUTTON10: | |
| 237 | case IPT_BUTTON11: | |
| 238 | case IPT_BUTTON12: | |
| 239 | case IPT_BUTTON13: | |
| 240 | case IPT_BUTTON14: | |
| 241 | case IPT_BUTTON15: | |
| 242 | case IPT_BUTTON16: | |
| 243 | nbutton = MAX(nbutton, field->type - IPT_BUTTON1 + 1); | |
| 244 | break; | |
| 287 | 245 | |
| 288 | /* get the analog stats */ | |
| 289 | if (analogcontrol) | |
| 290 | { | |
| 291 | controlsyes = 1; | |
| 292 | control[analogcontrol].analog = 1; | |
| 246 | case IPT_COIN1: | |
| 247 | case IPT_COIN2: | |
| 248 | case IPT_COIN3: | |
| 249 | case IPT_COIN4: | |
| 250 | case IPT_COIN5: | |
| 251 | case IPT_COIN6: | |
| 252 | case IPT_COIN7: | |
| 253 | case IPT_COIN8: | |
| 254 | ncoin = MAX(ncoin, field->type - IPT_COIN1 + 1); | |
| 293 | 255 | |
| 294 | if (input->analog.min) | |
| 295 | control[analogcontrol].min = input->analog.min; | |
| 296 | if (input->analog.max) | |
| 297 | control[analogcontrol].max = input->analog.max; | |
| 298 | if (input->analog.sensitivity) | |
| 299 | control[analogcontrol].sensitivity = input->analog.sensitivity; | |
| 300 | if (input->analog.delta) | |
| 301 | control[analogcontrol].keydelta = input->analog.delta; | |
| 302 | if (input->analog.reverse) | |
| 303 | control[analogcontrol].reverse = 1; | |
| 256 | case IPT_SERVICE : | |
| 257 | service = "yes"; | |
| 258 | break; | |
| 304 | 259 | |
| 305 | analogcontrol = 0; | |
| 306 | } | |
| 260 | case IPT_TILT : | |
| 261 | tilt = "yes"; | |
| 262 | break; | |
| 263 | } | |
| 307 | 264 | |
| 308 | ++input; | |
| 309 | } | |
| 265 | /* get the analog stats */ | |
| 266 | if (analogcontrol) | |
| 267 | { | |
| 268 | controlsyes = 1; | |
| 269 | control[analogcontrol].analog = 1; | |
| 310 | 270 | |
| 271 | if (field->min) | |
| 272 | control[analogcontrol].min = field->min; | |
| 273 | if (field->max) | |
| 274 | control[analogcontrol].max = field->max; | |
| 275 | if (field->sensitivity) | |
| 276 | control[analogcontrol].sensitivity = field->sensitivity; | |
| 277 | if (field->delta) | |
| 278 | control[analogcontrol].keydelta = field->delta; | |
| 279 | if (field->flags & ANALOG_FLAG_REVERSE) | |
| 280 | control[analogcontrol].reverse = 1; | |
| 281 | ||
| 282 | analogcontrol = 0; | |
| 283 | } | |
| 284 | } | |
| 285 | ||
| 311 | 286 | fprintf(out, "\t\t<input"); |
| 312 | 287 | fprintf(out, " players=\"%d\"", nplayer); |
| 313 | 288 | if (nbutton != 0) |
| r2724 | r2725 | |
| 856 | 831 | |
| 857 | 832 | static void print_game_info(FILE *out, const game_driver *game) |
| 858 | 833 | { |
| 859 | const input_port_ | |
| 834 | const input_port_config * | |
| 860 | 835 | const game_driver *clone_of; |
| 861 | 836 | machine_config *config; |
| 862 | 837 | const char *start; |
| r2724 | r2725 | |
| 866 | 841 | return; |
| 867 | 842 | |
| 868 | 843 | /* start tracking resources and allocate the machine and input configs */ |
| 869 | begin_resource_tracking(); | |
| 870 | 844 | config = machine_config_alloc(game->machine_config); |
| 871 | 845 | #ifdef MESS |
| 872 | 846 | /* temporary hook until MESS device transition is complete */ |
| 873 | 847 | mess_devices_setup(config, game); |
| 874 | 848 | #endif /* MESS */ |
| 875 | | |
| 849 | | |
| 876 | 850 | |
| 877 | 851 | /* print the header and the game name */ |
| 878 | 852 | fprintf(out, "\t<" XML_TOP); |
| r2724 | r2725 | |
| 922 | 896 | print_game_chips(out, game, config); |
| 923 | 897 | print_game_display(out, game, config); |
| 924 | 898 | print_game_sound(out, game, config); |
| 925 | print_game_input(out, game, input); | |
| 926 | print_game_switches(out, game, input); | |
| 899 | print_game_input(out, game, portconfig); | |
| 900 | print_game_switches(out, game, portconfig); | |
| 927 | 901 | print_game_driver(out, game, config); |
| 928 | 902 | #ifdef MESS |
| 929 | 903 | print_game_device(out, game, config); |
| r2724 | r2725 | |
| 933 | 907 | /* close the topmost tag */ |
| 934 | 908 | fprintf(out, "\t</" XML_TOP ">\n"); |
| 935 | 909 | |
| 936 | /* release resources */ | |
| 937 | end_resource_tracking(); | |
| 910 | input_port_config_free(portconfig); | |
| 938 | 911 | machine_config_free(config); |
| 939 | 912 | } |
| 940 | 913 |
| r2724 | r2725 | |
|---|---|---|
| 119 | 119 | { NULL, NULL, OPTION_HEADER, "CORE INPUT OPTIONS" }, |
| 120 | 120 | { "ctrlr", NULL, 0, "preconfigure for specified controller" }, |
| 121 | 121 | { "mouse", "0", OPTION_BOOLEAN, "enable mouse input" }, |
| 122 | { "joystick;joy", " | |
| 122 | { "joystick;joy", "1", OPTION_BOOLEAN, "enable joystick input" }, | |
| 123 | 123 | { "lightgun;gun", "0", OPTION_BOOLEAN, "enable lightgun input" }, |
| 124 | 124 | { "multikeyboard;multikey", "0", OPTION_BOOLEAN, "enable separate input from each keyboard device (if present)" }, |
| 125 | 125 | { "multimouse", "0", OPTION_BOOLEAN, "enable separate input from each mouse device (if present)" }, |
| r2724 | r2725 | |
|---|---|---|
| 39 | 39 | #define VISIBLE_GAMES_IN_LIST 15 |
| 40 | 40 | |
| 41 | 41 | #define MAX_PHYSICAL_DIPS 10 |
| 42 | #define MAX_INPUT_PORTS 32 | |
| 43 | #define MAX_BITS_PER_PORT 32 | |
| 42 | 44 | |
| 43 | 45 | /* DIP switch rendering parameters */ |
| 44 | 46 | #define DIP_SWITCH_HEIGHT 0.05f |
| r2724 | r2725 | |
| 84 | 86 | typedef struct _input_item_data input_item_data; |
| 85 | 87 | struct _input_item_data |
| 86 | 88 | { |
| 87 | input_seq * seq; /* pointer to the sequence we are operating on */ | |
| 88 | const input_seq *defseq; /* pointer to the sequence we are operating on */ | |
| 89 | const input_type_desc *typedesc; /* reference to type description for global inputs */ | |
| 90 | const input_field_config *field; /* reference to field for game inputs */ | |
| 91 | int seqtype; /* sequence type */ | |
| 92 | input_seq seq; /* copy of the live sequence */ | |
| 93 | const input_seq *defseq; /* pointer to the default sequence */ | |
| 89 | 94 | const char * name; |
| 90 | 95 | const char * seqname; |
| 91 | UINT16 sortorder; /* sorting information */ | |
| 92 | UINT8 type; /* type of port */ | |
| 93 | UINT8 invert; /* type of port */ | |
| 96 | UINT16 sortorder; /* sorting information */ | |
| 97 | UINT8 type; /* type of port */ | |
| 98 | UINT8 invert; /* type of port */ | |
| 94 | 99 | }; |
| 95 | 100 | |
| 96 | 101 | |
| r2724 | r2725 | |
| 152 | 157 | static void ui_menu_exit(running_machine *machine); |
| 153 | 158 | |
| 154 | 159 | /* menu handlers */ |
| 155 | static UINT32 menu_main(UINT32 state); | |
| 156 | static UINT32 menu_input_groups(UINT32 state); | |
| 157 | static UINT32 menu_input(UINT32 state); | |
| 158 | static UINT32 menu_switches(UINT32 state); | |
| 159 | static UINT32 menu_analog(UINT32 state); | |
| 160 | static UINT32 menu_main(running_machine *machine, UINT32 state); | |
| 161 | static UINT32 menu_input_groups(running_machine *machine, UINT32 state); | |
| 162 | static UINT32 menu_input(running_machine *machine, UINT32 state); | |
| 163 | static UINT32 menu_switches(running_machine *machine, UINT32 state); | |
| 164 | static UINT32 menu_analog(running_machine *machine, UINT32 state); | |
| 160 | 165 | #ifndef MESS |
| 161 | static UINT32 menu_bookkeeping(UINT32 state); | |
| 166 | static UINT32 menu_bookkeeping(running_machine *machine, UINT32 state); | |
| 162 | 167 | #endif |
| 163 | static UINT32 menu_game_info(UINT32 state); | |
| 164 | static UINT32 menu_cheat(UINT32 state); | |
| 165 | static UINT32 menu_memory_card(UINT32 state); | |
| 166 | static UINT32 menu_video(UINT32 state); | |
| 167 | static UINT32 menu_quit_game(UINT32 state); | |
| 168 | static UINT32 menu_select_game(UINT32 state); | |
| 168 | static UINT32 menu_game_info(running_machine *machine, UINT32 state); | |
| 169 | static UINT32 menu_cheat(running_machine *machine, UINT32 state); | |
| 170 | static UINT32 menu_memory_card(running_machine *machine, UINT32 state); | |
| 171 | static UINT32 menu_video(running_machine *machine, UINT32 state); | |
| 172 | static UINT32 menu_quit_game(running_machine *machine, UINT32 state); | |
| 173 | static UINT32 menu_select_game(running_machine *machine, UINT32 state); | |
| 169 | 174 | #ifdef MESS |
| 170 | static UINT32 menu_file_manager(UINT32 state); | |
| 175 | static UINT32 menu_file_manager(running_machine *machine, UINT32 state); | |
| 171 | 176 | #if HAS_WAVE |
| 172 | static UINT32 menu_tape_control(UINT32 state); | |
| 177 | static UINT32 menu_tape_control(running_machine *machine, UINT32 state); | |
| 173 | 178 | #endif /* HAS_WAVE */ |
| 174 | 179 | #endif /* MESS */ |
| 175 | 180 | |
| 176 | 181 | /* menu helpers */ |
| 177 | 182 | static void menu_render_triangle(bitmap_t *dest, const bitmap_t *source, const rectangle *sbounds, void *param); |
| 178 | 183 | |
| 179 | static int input_menu_get_items(input_item_data *itemlist, int group); | |
| 180 | static int input_menu_get_game_items(input_item_data *itemlist); | |
| 184 | static int input_menu_get_items(running_machine *machine, input_item_data *itemlist, int group); | |
| 185 | static int input_menu_get_game_items(running_machine *machine, input_item_data *itemlist); | |
| 181 | 186 | static void input_menu_toggle_none_default(input_seq *selected_seq, input_seq *original_seq, const input_seq *selected_defseq); |
| 182 | 187 | static int input_menu_compare_items(const void *i1, const void *i2); |
| 183 | static void switches_menu_add_item(ui_menu_item *item, const input_port_entry *in, int switch_entry, void *ref); | |
| 184 | static void switches_menu_select_previous(input_port_entry *in, int switch_entry); | |
| 185 | static void switches_menu_select_next(input_port_entry *in, int switch_entry); | |
| 186 | //static int switches_menu_compare_items(const void *i1, const void *i2); | |
| 187 | static void analog_menu_add_item(ui_menu_item *item, const input_port_entry *in, const char *append_string, int which_item); | |
| 188 | static void switches_menu_add_item(ui_menu_item *item, const input_field_config *field); | |
| 189 | static void switches_menu_select_previous(const input_field_config *field); | |
| 190 | static void switches_menu_select_next(const input_field_config *field); | |
| 191 | static void analog_menu_add_item(ui_menu_item *item, const input_field_config *field, const char *append_string, int which_item); | |
| 188 | 192 | |
| 189 | 193 | /* DIP switch helpers */ |
| 190 | static void dip_switch_build_model(input_ | |
| 194 | static void dip_switch_build_model(const input_fi | |
| 191 | 195 | static void dip_switch_draw_one(float dip_menu_x1, float dip_menu_y1, float dip_menu_x2, float dip_menu_y2, int model_index); |
| 192 | 196 | static void dip_switch_render(const menu_extra *extra, float x1, float y1, float x2, float y2); |
| 193 | 197 | |
| r2724 | r2725 | |
| 531 | 535 | bottom |
| 532 | 536 | -------------------------------------------------*/ |
| 533 | 537 | |
| 534 | void ui_menu_draw_text_box(const char *text) | |
| 538 | static void ui_menu_draw_text_box(const char *text) | |
| 535 | 539 | { |
| 536 | 540 | const char *priortext = "Return to Prior Menu"; |
| 537 | 541 | float line_height = ui_get_line_height(); |
| r2724 | r2725 | |
| 591 | 595 | keys for a menu |
| 592 | 596 | -------------------------------------------------*/ |
| 593 | 597 | |
| 594 | int ui_menu_generic_keys(UINT32 *selected, int num_items, int visible_items) | |
| 598 | int ui_menu_generic_keys(running_machine *machine, UINT32 *selected, int num_items, int visible_items) | |
| 595 | 599 | { |
| 596 | 600 | /* hitting cancel or selecting the last item returns to the previous menu */ |
| 597 | if (input_ui_pressed(IPT_UI_CANCEL) || (*selected == num_items - 1 && input_ui_pressed(IPT_UI_SELECT))) | |
| 601 | if (input_ui_pressed(machine, IPT_UI_CANCEL) || (*selected == num_items - 1 && input_ui_pressed(machine, IPT_UI_SELECT))) | |
| 598 | 602 | { |
| 599 | 603 | *selected = ui_menu_stack_pop(); |
| 600 | 604 | return 1; |
| 601 | 605 | } |
| 602 | 606 | |
| 603 | 607 | /* up backs up by one item */ |
| 604 | if (input_ui_pressed_repeat(IPT_UI_UP, 6)) | |
| 608 | if (input_ui_pressed_repeat(machine, IPT_UI_UP, 6)) | |
| 605 | 609 | *selected = (*selected + num_items - 1) % num_items; |
| 606 | 610 | |
| 607 | 611 | /* down advances by one item */ |
| 608 | if (input_ui_pressed_repeat(IPT_UI_DOWN, 6)) | |
| 612 | if (input_ui_pressed_repeat(machine, IPT_UI_DOWN, 6)) | |
| 609 | 613 | *selected = (*selected + 1) % num_items; |
| 610 | 614 | |
| 611 | 615 | /* page up backs up by visible_items */ |
| 612 | if (input_ui_pressed_repeat(IPT_UI_PAGE_UP, 6)) | |
| 616 | if (input_ui_pressed_repeat(machine, IPT_UI_PAGE_UP, 6)) | |
| 613 | 617 | { |
| 614 | 618 | if (*selected >= visible_items - 1) |
| 615 | 619 | *selected -= visible_items - 1; |
| r2724 | r2725 | |
| 618 | 622 | } |
| 619 | 623 | |
| 620 | 624 | /* page down advances by visible_items */ |
| 621 | if (input_ui_pressed_repeat(IPT_UI_PAGE_DOWN, 6)) | |
| 625 | if (input_ui_pressed_repeat(machine, IPT_UI_PAGE_DOWN, 6)) | |
| 622 | 626 | { |
| 623 | 627 | *selected += visible_items - 1; |
| 624 | 628 | if (*selected >= num_items) |
| r2724 | r2725 | |
| 626 | 630 | } |
| 627 | 631 | |
| 628 | 632 | /* home goes to the start */ |
| 629 | if (input_ui_pressed(IPT_UI_HOME)) | |
| 633 | if (input_ui_pressed(machine, IPT_UI_HOME)) | |
| 630 | 634 | *selected = 0; |
| 631 | 635 | |
| 632 | 636 | /* end goes to the last */ |
| 633 | if (input_ui_pressed(IPT_UI_END)) | |
| 637 | if (input_ui_pressed(machine, IPT_UI_END)) | |
| 634 | 638 | *selected = num_items - 1; |
| 635 | 639 | |
| 636 | 640 | /* pause enables/disables pause */ |
| 637 | if (input_ui_pressed(IPT_UI_PAUSE)) | |
| 641 | if (input_ui_pressed(machine, IPT_UI_PAUSE)) | |
| 638 | 642 | mame_pause(Machine, !mame_is_paused(Machine)); |
| 639 | 643 | |
| 640 | 644 | return 0; |
| r2724 | r2725 | |
| 694 | 698 | ui_menu_stack_push(menu_main, 0); |
| 695 | 699 | |
| 696 | 700 | /* update the menu state */ |
| 697 | newstate = (*menu_stack[menu_stack_index].handler)(menu_stack[menu_stack_index].state); | |
| 701 | newstate = (*menu_stack[menu_stack_index].handler)(machine, menu_stack[menu_stack_index].state); | |
| 698 | 702 | menu_stack[menu_stack_index].state = newstate; |
| 699 | 703 | |
| 700 | 704 | /* if the menus are to be hidden, return a cancel here */ |
| 701 | if ((input_ui_pressed(IPT_UI_CONFIGURE) && !ui_menu_is_force_game_select()) || menu_stack[menu_stack_index].handler == NULL) | |
| 705 | if ((input_ui_pressed(machine, IPT_UI_CONFIGURE) && !ui_menu_is_force_game_select()) || menu_stack[menu_stack_index].handler == NULL) | |
| 702 | 706 | return UI_HANDLER_CANCEL; |
| 703 | 707 | |
| 704 | 708 | return 0; |
| r2724 | r2725 | |
| 752 | 756 | menu_main - main UI menu |
| 753 | 757 | -------------------------------------------------*/ |
| 754 | 758 | |
| 755 | static UINT32 menu_main(UINT32 state) | |
| 759 | static UINT32 menu_main(running_machine *machine, UINT32 state) | |
| 756 | 760 | { |
| 757 | 761 | #define ADD_MENU(name, _handler, _param) \ |
| 758 | 762 | do { \ |
| r2724 | r2725 | |
| 762 | 766 | menu_items++; \ |
| 763 | 767 | } while (0) |
| 764 | 768 | |
| 769 | const input_port_config *port; | |
| 770 | const input_field_config *field; | |
| 765 | 771 | menu_state handler_list[20]; |
| 766 | 772 | ui_menu_item item_list[20]; |
| 767 | 773 | int has_categories = FALSE; |
| 768 | 774 | int has_configs = FALSE; |
| 769 | 775 | int has_analog = FALSE; |
| 770 | 776 | int has_dips = FALSE; |
| 771 | input_port_entry *in; | |
| 772 | 777 | int menu_items = 0; |
| 773 | 778 | int visible_items; |
| 774 | 779 | |
| 775 | 780 | /* scan the input port array to see what options we need to enable */ |
| 776 | for (in = Machine->input_ports; in->type != IPT_END; in++) | |
| 777 | if (input_port_active(in)) | |
| 781 | for (port = machine->portconfig; port != NULL; port = port->next) | |
| 782 | for (field = port->fieldlist; field != NULL; field = field->next) | |
| 778 | 783 | { |
| 779 | if (i | |
| 784 | if (field->type == IPT_DIPSWITCH | |
| 780 | 785 | has_dips = TRUE; |
| 781 | if (port_type_is_analog(in->type)) | |
| 782 | has_analog = TRUE; | |
| 783 | if (in->type == IPT_CONFIG_NAME) | |
| 786 | if (field->type == IPT_CONFIG) | |
| 784 | 787 | has_configs = TRUE; |
| 785 | if (i | |
| 788 | if (field->category > 0) | |
| 786 | 789 | has_categories = TRUE; |
| 790 | if (input_type_is_analog(field->type)) | |
| 791 | has_analog = TRUE; | |
| 787 | 792 | } |
| 788 | 793 | |
| 789 | 794 | /* reset the menu */ |
| r2724 | r2725 | |
| 795 | 800 | |
| 796 | 801 | /* add optional input-related menus */ |
| 797 | 802 | if (has_dips) |
| 798 | ADD_MENU("Dip Switches", menu_switches, | |
| 803 | ADD_MENU("Dip Switches", menu_switches, | |
| 799 | 804 | if (has_configs) |
| 800 | ADD_MENU("Driver Configuration", menu_switches, | |
| 805 | ADD_MENU("Driver Configuration", menu_switches, | |
| 801 | 806 | #ifdef MESS |
| 802 | 807 | if (has_categories) |
| 803 | ADD_MENU("Categories", menu_switches, | |
| 808 | ADD_MENU("Categories", menu_switches, | |
| 804 | 809 | #endif |
| 805 | 810 | if (has_analog) |
| 806 | 811 | ADD_MENU("Analog Controls", menu_analog, 0); |
| r2724 | r2725 | |
| 822 | 827 | |
| 823 | 828 | #if HAS_WAVE |
| 824 | 829 | /* add tape control menu */ |
| 825 | if (device_find_from_machine( | |
| 830 | if (device_find_from_machine(machine, IO_CASSETTE)) | |
| 826 | 831 | ADD_MENU("Tape Control", menu_tape_control, 1); |
| 827 | 832 | #endif /* HAS_WAVE */ |
| 828 | 833 | #endif /* MESS */ |
| r2724 | r2725 | |
| 835 | 840 | ADD_MENU("Cheat", menu_cheat, 1); |
| 836 | 841 | |
| 837 | 842 | /* add memory card menu */ |
| 838 | if ( | |
| 843 | if (machine->config->memcard_handler != NULL) | |
| 839 | 844 | ADD_MENU("Memory Card", menu_memory_card, 0); |
| 840 | 845 | |
| 841 | 846 | /* add reset and exit menus */ |
| r2724 | r2725 | |
| 846 | 851 | visible_items = ui_menu_draw(item_list, menu_items, state, NULL); |
| 847 | 852 | |
| 848 | 853 | /* handle the keys */ |
| 849 | if (ui_menu_generic_keys(&state, menu_items, visible_items)) | |
| 854 | if (ui_menu_generic_keys(machine, &state, menu_items, visible_items)) | |
| 850 | 855 | return state; |
| 851 | if (input_ui_pressed(IPT_UI_SELECT)) | |
| 856 | if (input_ui_pressed(machine, IPT_UI_SELECT)) | |
| 852 | 857 | return ui_menu_stack_push(handler_list[state].handler, handler_list[state].state); |
| 853 | 858 | |
| 854 | 859 | return state; |
| r2724 | r2725 | |
| 862 | 867 | groups |
| 863 | 868 | -------------------------------------------------*/ |
| 864 | 869 | |
| 865 | static UINT32 menu_input_groups(UINT32 state) | |
| 870 | static UINT32 menu_input_groups(running_machine *machine, UINT32 state) | |
| 866 | 871 | { |
| 867 | 872 | ui_menu_item item_list[IPG_TOTAL_GROUPS + 2]; |
| 868 | 873 | int menu_items = 0; |
| r2724 | r2725 | |
| 885 | 890 | visible_items = ui_menu_draw(item_list, menu_items, state, NULL); |
| 886 | 891 | |
| 887 | 892 | /* handle the keys */ |
| 888 | if (ui_menu_generic_keys(&state, menu_items, visible_items)) | |
| 893 | if (ui_menu_generic_keys(machine, &state, menu_items, visible_items)) | |
| 889 | 894 | return state; |
| 890 | if (input_ui_pressed(IPT_UI_SELECT)) | |
| 895 | if (input_ui_pressed(machine, IPT_UI_SELECT)) | |
| 891 | 896 | return ui_menu_stack_push(menu_input, state << 16); |
| 892 | 897 | |
| 893 | 898 | return state; |
| r2724 | r2725 | |
| 898 | 903 | menu_input - display a menu for inputs |
| 899 | 904 | -------------------------------------------------*/ |
| 900 | 905 | |
| 901 | static UINT32 menu_input(UINT32 state) | |
| 906 | static UINT32 menu_input(running_machine *machine, UINT32 state) | |
| 902 | 907 | { |
| 903 | 908 | ui_menu_item item_list[MAX_INPUT_PORTS * MAX_BITS_PER_PORT / 2]; |
| 904 | 909 | input_item_data item_data[MAX_INPUT_PORTS * MAX_BITS_PER_PORT / 2]; |
| r2724 | r2725 | |
| 907 | 912 | int record_next = (state >> 14) & 1; |
| 908 | 913 | int polling = (state >> 15) & 1; |
| 909 | 914 | int group = state >> 16; |
| 915 | int changed = FALSE; | |
| 910 | 916 | int visible_items; |
| 911 | 917 | int menu_items; |
| 912 | 918 | int item; |
| 913 | 919 | |
| 914 | 920 | /* get the list of items */ |
| 915 | 921 | menu_string_pool_offset = 0; |
| 916 | menu_items = input_menu_get_items(item_data, group); | |
| 917 | 922 | |
| 923 | /* an out of range group is special; it just means the game-specific inputs */ | |
| 924 | if (group > IPG_TOTAL_GROUPS) | |
| 925 | menu_items = input_menu_get_game_items(machine, item_data); | |
| 926 | else | |
| 927 | menu_items = input_menu_get_items(machine, item_data, group); | |
| 928 | ||
| 918 | 929 | /* build the menu */ |
| 919 | 930 | memset(item_list, 0, sizeof(item_list)); |
| 920 | 931 | for (item = 0; item < menu_items; item++) |
| r2724 | r2725 | |
| 954 | 965 | input_seq newseq; |
| 955 | 966 | |
| 956 | 967 | /* if UI_CANCEL is pressed, abort */ |
| 957 | if (input_ui_pressed(IPT_UI_CANCEL)) | |
| 968 | if (input_ui_pressed(machine, IPT_UI_CANCEL)) | |
| 958 | 969 | { |
| 959 | 970 | record_next = polling = FALSE; |
| 960 | input_menu_toggle_none_default(selected_item_data->seq, &starting_seq, selected_item_data->defseq); | |
| 971 | input_menu_toggle_none_default(&selected_item_data->seq, &starting_seq, selected_item_data->defseq); | |
| 972 | changed = TRUE; | |
| 961 | 973 | } |
| 962 | 974 | |
| 963 | 975 | /* poll again; if finished, update the sequence */ |
| r2724 | r2725 | |
| 965 | 977 | { |
| 966 | 978 | record_next = TRUE; |
| 967 | 979 | polling = FALSE; |
| 968 | *selected_item_data->seq = newseq; | |
| 980 | selected_item_data->seq = newseq; | |
| 981 | changed = TRUE; | |
| 969 | 982 | } |
| 970 | 983 | } |
| 971 | 984 | |
| r2724 | r2725 | |
| 975 | 988 | int prevsel = selected; |
| 976 | 989 | |
| 977 | 990 | /* handle generic menu keys */ |
| 978 | if (ui_menu_generic_keys(&selected, menu_items, visible_items)) | |
| 991 | if (ui_menu_generic_keys(machine, &selected, menu_items, visible_items)) | |
| 979 | 992 | return selected; |
| 980 | 993 | |
| 981 | 994 | /* if an item was selected, start polling on it */ |
| 982 | if (input_ui_pressed(IPT_UI_SELECT)) | |
| 995 | if (input_ui_pressed(machine, IPT_UI_SELECT)) | |
| 983 | 996 | { |
| 984 | input_seq_poll_start((selected_item_data->type == INPUT_TYPE_ANALOG) ? ITEM_CLASS_ABSOLUTE : ITEM_CLASS_SWITCH, record_next ? selected_item_data->seq : NULL); | |
| 985 | starting_seq = *selected_item_data->seq; | |
| 997 | input_seq_poll_start((selected_item_data->type == INPUT_TYPE_ANALOG) ? ITEM_CLASS_ABSOLUTE : ITEM_CLASS_SWITCH, record_next ? &selected_item_data->seq : NULL); | |
| 998 | starting_seq = selected_item_data->seq; | |
| 986 | 999 | polling = TRUE; |
| 987 | 1000 | } |
| 988 | 1001 | |
| 989 | 1002 | /* if the clear key was pressed, reset the selected item */ |
| 990 | if (input_ui_pressed(IPT_UI_CLEAR)) | |
| 1003 | if (input_ui_pressed(machine, IPT_UI_CLEAR)) | |
| 991 | 1004 | { |
| 992 | input_menu_toggle_none_default(selected_item_data->seq, selected_item_data->seq, selected_item_data->defseq); | |
| 1005 | input_menu_toggle_none_default(&selected_item_data->seq, &selected_item_data->seq, selected_item_data->defseq); | |
| 993 | 1006 | record_next = FALSE; |
| 1007 | changed = TRUE; | |
| 994 | 1008 | } |
| 995 | 1009 | |
| 996 | 1010 | /* if the selection changed, update and reset the "record first" flag */ |
| r2724 | r2725 | |
| 998 | 1012 | record_next = FALSE; |
| 999 | 1013 | } |
| 1000 | 1014 | |
| 1015 | /* if the sequence changed, update it */ | |
| 1016 | if (changed) | |
| 1017 | { | |
| 1018 | if (group > IPG_TOTAL_GROUPS) | |
| 1019 | { | |
| 1020 | input_field_user_settings settings; | |
| 1021 | ||
| 1022 | input_field_get_user_settings(selected_item_data->field, &settings); | |
| 1023 | settings.seq[selected_item_data->seqtype] = selected_item_data->seq; | |
| 1024 | input_field_set_user_settings(selected_item_data->field, &settings); | |
| 1025 | } | |
| 1026 | else | |
| 1027 | { | |
| 1028 | const input_type_desc *typedesc = selected_item_data->typedesc; | |
| 1029 | input_type_set_seq(machine, typedesc->type, typedesc->player, selected_item_data->seqtype, &selected_item_data->seq); | |
| 1030 | } | |
| 1031 | } | |
| 1032 | ||
| 1001 | 1033 | return selected | (record_next << 14) | (polling << 15) | (group << 16); |
| 1002 | 1034 | } |
| 1003 | 1035 | |
| r2724 | r2725 | |
| 1007 | 1039 | switches |
| 1008 | 1040 | -------------------------------------------------*/ |
| 1009 | 1041 | |
| 1010 | static UINT32 menu_switches(UINT32 state) | |
| 1042 | static UINT32 menu_switches(running_machine *machine, UINT32 state) | |
| 1011 | 1043 | { |
| 1012 | 1044 | ui_menu_item item_list[MAX_INPUT_PORTS * MAX_BITS_PER_PORT / 2]; |
| 1013 | int switch_entry = (state >> 24) & 0xff; | |
| 1014 | 1045 | int switch_name = (state >> 16) & 0xff; |
| 1015 | 1046 | UINT32 selected = state & 0xffff; |
| 1016 | input_port_entry *selected_in = NULL; | |
| 1017 | input_port_entry *in; | |
| 1047 | const input_port_config *port; | |
| 1048 | const input_field_config *field; | |
| 1049 | const input_field_config *selected_field = NULL; | |
| 1018 | 1050 | int menu_items = 0; |
| 1019 | 1051 | int changed = FALSE; |
| 1020 | 1052 | int visible_items; |
| r2724 | r2725 | |
| 1026 | 1058 | memset(dip_switch_model, 0, sizeof(dip_switch_model)); |
| 1027 | 1059 | |
| 1028 | 1060 | /* loop over input ports and set up the current values */ |
| 1029 | for (in = Machine->input_ports; in->type != IPT_END; in++) | |
| 1030 | if (in->type == switch_name && input_port_active(in) && input_port_condition(in)) | |
| 1031 | { | |
| 1032 | switches_menu_add_item(&item_list[menu_items], in, switch_entry, in); | |
| 1033 | if (in->type == IPT_DIPSWITCH_NAME) | |
| 1034 | dip_switch_build_model(in, menu_items == selected); | |
| 1035 | menu_items++; | |
| 1036 | } | |
| 1061 | for (port = machine->portconfig; port != NULL; port = port->next) | |
| 1062 | for (field = port->fieldlist; field != NULL; field = field->next) | |
| 1063 | if (field->type == switch_name && input_condition_true(machine, &field->condition)) | |
| 1064 | { | |
| 1065 | switches_menu_add_item(&item_list[menu_items], field); | |
| 1066 | if (field->type == IPT_DIPSWITCH) | |
| 1067 | dip_switch_build_model(field, menu_items == selected); | |
| 1068 | menu_items++; | |
| 1069 | } | |
| 1037 | 1070 | |
| 1038 | 1071 | /* sort the list */ |
| 1039 | // qsort(item_list, menu_items, sizeof(item_list[0]), switches_menu_compare_items); | |
| 1040 | selected_in = item_list[selected].ref; | |
| 1072 | selected_field = item_list[selected].ref; | |
| 1041 | 1073 | |
| 1042 | 1074 | /* add an item to return */ |
| 1043 | 1075 | item_list[menu_items++].text = "Return to Prior Menu"; |
| r2724 | r2725 | |
| 1052 | 1084 | visible_items = ui_menu_draw(item_list, menu_items, selected, (dip_switch_model[0].dip_name) ? &extra : NULL); |
| 1053 | 1085 | |
| 1054 | 1086 | /* handle generic menu keys */ |
| 1055 | if (ui_menu_generic_keys(&selected, menu_items, visible_items)) | |
| 1087 | if (ui_menu_generic_keys(machine, &selected, menu_items, visible_items)) | |
| 1056 | 1088 | return selected; |
| 1057 | 1089 | |
| 1058 | 1090 | /* handle left/right arrows */ |
| 1059 | if (input_ui_pressed(IPT_UI_LEFT) && (item_list[selected].flags & MENU_FLAG_LEFT_ARROW)) | |
| 1091 | if (input_ui_pressed(machine, IPT_UI_LEFT) && (item_list[selected].flags & MENU_FLAG_LEFT_ARROW)) | |
| 1060 | 1092 | { |
| 1061 | switches_menu_select_previous(selected_i | |
| 1093 | switches_menu_select_previous(selected_fi | |
| 1062 | 1094 | changed = TRUE; |
| 1063 | 1095 | } |
| 1064 | if (input_ui_pressed(IPT_UI_RIGHT) && (item_list[selected].flags & MENU_FLAG_RIGHT_ARROW)) | |
| 1096 | if (input_ui_pressed(machine, IPT_UI_RIGHT) && (item_list[selected].flags & MENU_FLAG_RIGHT_ARROW)) | |
| 1065 | 1097 | { |
| 1066 | switches_menu_select_next(selected_i | |
| 1098 | switches_menu_select_next(selected_fi | |
| 1067 | 1099 | changed = TRUE; |
| 1068 | 1100 | } |
| 1069 | 1101 | |
| r2724 | r2725 | |
| 1071 | 1103 | /* due to conditional DIPs changing things */ |
| 1072 | 1104 | if (changed) |
| 1073 | 1105 | { |
| 1074 | int newsel = 0; | |
| 1075 | input_port_update_defaults(); | |
| 1076 | for (in = Machine->input_ports; in->type != IPT_END; in++) | |
| 1077 | if (in->type == switch_name && input_port_active(in) && input_port_condition(in)) | |
| 1078 | { | |
| 1079 | if (selected_in == in) | |
| 1106 | int newselected = 0; | |
| 1107 | for (port = machine->portconfig; port != NULL; port = port->next) | |
| 1108 | for (field = port->fieldlist; field != NULL; field = field->next) | |
| 1109 | if (field->type == switch_name && input_condition_true(machine, &field->condition)) | |
| 1080 | 1110 | { |
| 1081 | selected = newsel; | |
| 1082 | break; | |
| 1111 | if (field == selected_field) | |
| 1112 | { | |
| 1113 | selected = newselected; | |
| 1114 | break; | |
| 1115 | } | |
| 1116 | newselected++; | |
| 1083 | 1117 | } |
| 1084 | newsel++; | |
| 1085 | } | |
| 1086 | 1118 | } |
| 1087 | 1119 | |
| 1088 | return selected | (switch_name << 16) | |
| 1120 | return selected | (switch_name << 16) | |
| 1089 | 1121 | } |
| 1090 | 1122 | |
| 1091 | 1123 | |
| r2724 | r2725 | |
| 1094 | 1126 | control settings |
| 1095 | 1127 | -------------------------------------------------*/ |
| 1096 | 1128 | |
| 1097 | static UINT32 menu_analog(UINT32 state) | |
| 1129 | static UINT32 menu_analog(running_machine *machine, UINT32 state) | |
| 1098 | 1130 | { |
| 1099 | 1131 | ui_menu_item item_list[MAX_INPUT_PORTS * 4 * ANALOG_ITEM_COUNT]; |
| 1100 | input_port_entry *selected_in = NULL; | |
| 1101 | input_port_entry *in; | |
| 1132 | const input_port_config *port; | |
| 1133 | const input_field_config *field; | |
| 1134 | const input_field_config *selected_field = NULL; | |
| 1102 | 1135 | int menu_items = 0; |
| 1103 | 1136 | int selected_item = 0; |
| 1104 | 1137 | int visible_items; |
| r2724 | r2725 | |
| 1110 | 1143 | menu_string_pool_offset = 0; |
| 1111 | 1144 | |
| 1112 | 1145 | /* loop over input ports and add the items */ |
| 1113 | for (in = Machine->input_ports; in->type != IPT_END; in++) | |
| 1114 | if (port_type_is_analog(in->type)) | |
| 1115 | { | |
| 1116 | use_autocenter = 0; | |
| 1117 | switch (in->type) | |
| 1146 | for (port = Machine->portconfig; port != NULL; port = port->next) | |
| 1147 | for (field = port->fieldlist; field != NULL; field = field->next) | |
| 1148 | if (input_type_is_analog(field->type)) | |
| 1118 | 1149 | { |
| 1119 | /* Autocenter Speed is only used for these devices */ | |
| 1120 | case IPT_POSITIONAL: | |
| 1121 | case IPT_POSITIONAL_V: | |
| 1122 | if (in->analog.wraps) break; | |
| 1150 | use_autocenter = FALSE; | |
| 1151 | switch (field->type) | |
| 1152 | { | |
| 1153 | /* Autocenter Speed is only used for these devices */ | |
| 1154 | case IPT_POSITIONAL: | |
| 1155 | case IPT_POSITIONAL_V: | |
| 1156 | if (field->flags & ANALOG_FLAG_WRAPS) | |
| 1157 | break; | |
| 1123 | 1158 | |
| 1124 | case IPT_PEDAL: | |
| 1125 | case IPT_PEDAL2: | |
| 1126 | case IPT_PEDAL3: | |
| 1127 | case IPT_PADDLE: | |
| 1128 | case IPT_PADDLE_V: | |
| 1129 | case IPT_AD_STICK_X: | |
| 1130 | case IPT_AD_STICK_Y: | |
| 1131 | case IPT_AD_STICK_Z: | |
| 1132 | use_autocenter = 1; | |
| 1133 | break; | |
| 1134 | } | |
| 1159 | case IPT_PEDAL: | |
| 1160 | case IPT_PEDAL2: | |
| 1161 | case IPT_PEDAL3: | |
| 1162 | case IPT_PADDLE: | |
| 1163 | case IPT_PADDLE_V: | |
| 1164 | case IPT_AD_STICK_X: | |
| 1165 | case IPT_AD_STICK_Y: | |
| 1166 | case IPT_AD_STICK_Z: | |
| 1167 | use_autocenter = TRUE; | |
| 1168 | break; | |
| 1169 | } | |
| 1135 | 1170 | |
| 1136 | /* track the selected item */ | |
| 1137 | if (state >= menu_items && state < menu_items + 3 + use_autocenter) | |
| 1138 | { | |
| 1139 | selected_in = in; | |
| 1140 | selected_item = state - menu_items; | |
| 1141 | // shift menu for missing Autocenter | |
| 1142 | if (selected_item && !use_autocenter) selected_item++; | |
| 1171 | /* track the selected item */ | |
| 1172 | if (state >= menu_items && state < menu_items + 3 + use_autocenter) | |
| 1173 | { | |
| 1174 | selected_field = field; | |
| 1175 | selected_item = state - menu_items; | |
| 1176 | // shift menu for missing Autocenter | |
| 1177 | if (selected_item && !use_autocenter) | |
| 1178 | selected_item++; | |
| 1179 | } | |
| 1180 | ||
| 1181 | /* add the needed items for each analog input */ | |
| 1182 | analog_menu_add_item(&item_list[menu_items++], field, "Digital Speed", ANALOG_ITEM_KEYSPEED); | |
| 1183 | if (use_autocenter) | |
| 1184 | analog_menu_add_item(&item_list[menu_items++], field, "Autocenter Speed", ANALOG_ITEM_CENTERSPEED); | |
| 1185 | analog_menu_add_item(&item_list[menu_items++], field, "Reverse", ANALOG_ITEM_REVERSE); | |
| 1186 | analog_menu_add_item(&item_list[menu_items++], field, "Sensitivity", ANALOG_ITEM_SENSITIVITY); | |
| 1143 | 1187 | } |
| 1144 | 1188 | |
| 1145 | /* add the needed items for each analog input */ | |
| 1146 | analog_menu_add_item(&item_list[menu_items++], in, "Digital Speed", ANALOG_ITEM_KEYSPEED); | |
| 1147 | if (use_autocenter) | |
| 1148 | analog_menu_add_item(&item_list[menu_items++], in, "Autocenter Speed", ANALOG_ITEM_CENTERSPEED); | |
| 1149 | analog_menu_add_item(&item_list[menu_items++], in, "Reverse", ANALOG_ITEM_REVERSE); | |
| 1150 | analog_menu_add_item(&item_list[menu_items++], in, "Sensitivity", ANALOG_ITEM_SENSITIVITY); | |
| 1151 | } | |
| 1152 | ||
| 1153 | 1189 | /* add an item to return */ |
| 1154 | 1190 | item_list[menu_items++].text = "Return to Prior Menu"; |
| 1155 | 1191 | |
| r2724 | r2725 | |
| 1157 | 1193 | visible_items = ui_menu_draw(item_list, menu_items, state, NULL); |
| 1158 | 1194 | |
| 1159 | 1195 | /* handle generic menu keys */ |
| 1160 | if (ui_menu_generic_keys(&state, menu_items, visible_items)) | |
| 1196 | if (ui_menu_generic_keys(machine, &state, menu_items, visible_items)) | |
| 1161 | 1197 | return state; |
| 1162 | 1198 | |
| 1163 | 1199 | /* handle left/right arrows */ |
| 1164 | if (input_ui_pressed_repeat(IPT_UI_LEFT,6) && (item_list[state].flags & MENU_FLAG_LEFT_ARROW)) | |
| 1200 | if (input_ui_pressed_repeat(machine, IPT_UI_LEFT,6) && (item_list[state].flags & MENU_FLAG_LEFT_ARROW)) | |
| 1165 | 1201 | delta = -1; |
| 1166 | if (input_ui_pressed_repeat(IPT_UI_RIGHT,6) && (item_list[state].flags & MENU_FLAG_RIGHT_ARROW)) | |
| 1202 | if (input_ui_pressed_repeat(machine, IPT_UI_RIGHT,6) && (item_list[state].flags & MENU_FLAG_RIGHT_ARROW)) | |
| 1167 | 1203 | delta = 1; |
| 1168 | 1204 | if (input_code_pressed(KEYCODE_LSHIFT)) |
| 1169 | 1205 | delta *= 10; |
| 1170 | 1206 | |
| 1171 | 1207 | /* adjust the appropriate value */ |
| 1172 | if (delta != 0 && selected_in) | |
| 1208 | if (delta != 0 && selected_field != NULL) | |
| 1209 | { | |
| 1210 | input_field_user_settings settings; | |
| 1211 | ||
| 1212 | input_field_get_user_settings(selected_field, &settings); | |
| 1173 | 1213 | switch (selected_item) |
| 1174 | 1214 | { |
| 1175 | case ANALOG_ITEM_KEYSPEED: selected_in->analog.delta += delta; break; | |
| 1176 | case ANALOG_ITEM_CENTERSPEED: selected_in->analog.centerdelta += delta; break; | |
| 1177 | case ANALOG_ITEM_REVERSE: selected_in->analog.reverse += delta; break; | |
| 1178 | case ANALOG_ITEM_SENSITIVITY: selected_in->analog.sensitivity += delta; break; | |
| 1215 | case ANALOG_ITEM_KEYSPEED: settings.delta += delta; break; | |
| 1216 | case ANALOG_ITEM_CENTERSPEED: settings.centerdelta += delta; break; | |
| 1217 | case ANALOG_ITEM_REVERSE: settings.reverse += delta; break; | |
| 1218 | case ANALOG_ITEM_SENSITIVITY: settings.sensitivity += delta; break; | |
| 1179 | 1219 | } |
| 1220 | input_field_set_user_settings(selected_field, &settings); | |
| 1221 | } | |
| 1180 | 1222 | |
| 1181 | 1223 | return state; |
| 1182 | 1224 | } |
| r2724 | r2725 | |
| 1188 | 1230 | -------------------------------------------------*/ |
| 1189 | 1231 | |
| 1190 | 1232 | #ifndef MESS |
| 1191 | static UINT32 menu_bookkeeping(UINT32 state) | |
| 1233 | static UINT32 menu_bookkeeping(running_machine *machine, UINT32 state) | |
| 1192 | 1234 | { |
| 1193 | 1235 | char buf[2048]; |
| 1194 | 1236 | char *bufptr = buf; |
| r2724 | r2725 | |
| 1230 | 1272 | ui_menu_draw_text_box(buf); |
| 1231 | 1273 | |
| 1232 | 1274 | /* handle the keys */ |
| 1233 | ui_menu_generic_keys(&selected, 1, 0); | |
| 1275 | ui_menu_generic_keys(machine, &selected, 1, 0); | |
| 1234 | 1276 | return selected; |
| 1235 | 1277 | } |
| 1236 | 1278 | #endif |
| r2724 | r2725 | |
| 1241 | 1283 | game information |
| 1242 | 1284 | -------------------------------------------------*/ |
| 1243 | 1285 | |
| 1244 | static UINT32 menu_game_info(UINT32 state) | |
| 1286 | static UINT32 menu_game_info(running_machine *machine, UINT32 state) | |
| 1245 | 1287 | { |
| 1246 | 1288 | char buf[2048]; |
| 1247 | 1289 | char *bufptr = buf; |
| 1248 | 1290 | UINT32 selected = 0; |
| 1249 | 1291 | |
| 1250 | 1292 | /* add the game info */ |
| 1251 | bufptr += sprintf_game_info( | |
| 1293 | bufptr += sprintf_game_info(machine, bufptr); | |
| 1252 | 1294 | |
| 1253 | 1295 | /* draw the text */ |
| 1254 | 1296 | ui_menu_draw_text_box(buf); |
| 1255 | 1297 | |
| 1256 | 1298 | /* handle the keys */ |
| 1257 | ui_menu_generic_keys(&selected, 1, 0); | |
| 1299 | ui_menu_generic_keys(machine, &selected, 1, 0); | |
| 1258 | 1300 | return selected; |
| 1259 | 1301 | } |
| 1260 | 1302 | |
| r2724 | r2725 | |
| 1263 | 1305 | menu_cheat - display a menu for cheat options |
| 1264 | 1306 | -------------------------------------------------*/ |
| 1265 | 1307 | |
| 1266 | static UINT32 menu_cheat(UINT32 state) | |
| 1308 | static UINT32 menu_cheat(running_machine *machine, UINT32 state) | |
| 1267 | 1309 | { |
| 1268 | int result = cheat_menu( | |
| 1310 | int result = cheat_menu(machine, state); | |
| 1269 | 1311 | if (result == 0) |
| 1270 | 1312 | return ui_menu_stack_pop(); |
| 1271 | 1313 | return result; |
| r2724 | r2725 | |
| 1277 | 1319 | card options |
| 1278 | 1320 | -------------------------------------------------*/ |
| 1279 | 1321 | |
| 1280 | static UINT32 menu_memory_card(UINT32 state) | |
| 1322 | static UINT32 menu_memory_card(running_machine *machine, UINT32 state) | |
| 1281 | 1323 | { |
| 1282 | 1324 | ui_menu_item item_list[5]; |
| 1283 | 1325 | int menu_items = 0; |
| r2724 | r2725 | |
| 1312 | 1354 | visible_items = ui_menu_draw(item_list, menu_items, selected, NULL); |
| 1313 | 1355 | |
| 1314 | 1356 | /* handle the keys */ |
| 1315 | if (ui_menu_generic_keys(&selected, menu_items, visible_items)) | |
| 1357 | if (ui_menu_generic_keys(machine, &selected, menu_items, visible_items)) | |
| 1316 | 1358 | return selected; |
| 1317 | if (selected == 0 && input_ui_pressed(IPT_UI_LEFT) && cardnum > 0) | |
| 1359 | if (selected == 0 && input_ui_pressed(machine, IPT_UI_LEFT) && cardnum > 0) | |
| 1318 | 1360 | cardnum--; |
| 1319 | if (selected == 0 && input_ui_pressed(IPT_UI_RIGHT) && cardnum < 1000) | |
| 1361 | if (selected == 0 && input_ui_pressed(machine, IPT_UI_RIGHT) && cardnum < 1000) | |
| 1320 | 1362 | cardnum++; |
| 1321 | 1363 | |
| 1322 | 1364 | /* handle actions */ |
| 1323 | if (input_ui_pressed(IPT_UI_SELECT)) | |
| 1365 | if (input_ui_pressed(machine, IPT_UI_SELECT)) | |
| 1324 | 1366 | { |
| 1325 | 1367 | /* handle load */ |
| 1326 | 1368 | if (selected == insertindex) |
| r2724 | r2725 | |
| 1338 | 1380 | /* handle eject */ |
| 1339 | 1381 | else if (selected == ejectindex) |
| 1340 | 1382 | { |
| 1341 | memcard_eject( | |
| 1383 | memcard_eject(machine); | |
| 1342 | 1384 | popmessage("Memory card ejected"); |
| 1343 | 1385 | } |
| 1344 | 1386 | |
| r2724 | r2725 | |
| 1360 | 1402 | menu_video - display a menu for video options |
| 1361 | 1403 | -------------------------------------------------*/ |
| 1362 | 1404 | |
| 1363 | static UINT32 menu_video(UINT32 state) | |
| 1405 | static UINT32 menu_video(running_machine *machine, UINT32 state) | |
| 1364 | 1406 | { |
| 1365 | 1407 | ui_menu_item item_list[100]; |
| 1366 | 1408 | render_target *targetlist[16]; |
| r2724 | r2725 | |
| 1391 | 1433 | |
| 1392 | 1434 | /* if we only ended up with one, auto-select it */ |
| 1393 | 1435 | if (menu_items == 1) |
| 1394 | return menu_video(0 << 16 | render_target_get_view(render_target_get_indexed(0))); | |
| 1436 | return menu_video(machine, 0 << 16 | render_target_get_view(render_target_get_indexed(0))); | |
| 1395 | 1437 | |
| 1396 | 1438 | /* add an item for moving the UI */ |
| 1397 | 1439 | item_list[menu_items++].text = "Move User Interface"; |
| r2724 | r2725 | |
| 1403 | 1445 | visible_items = ui_menu_draw(item_list, menu_items, selected, NULL); |
| 1404 | 1446 | |
| 1405 | 1447 | /* handle the keys */ |
| 1406 | if (ui_menu_generic_keys(&selected, menu_items, visible_items)) | |
| 1448 | if (ui_menu_generic_keys(machine, &selected, menu_items, visible_items)) | |
| 1407 | 1449 | return selected; |
| 1408 | 1450 | |
| 1409 | 1451 | /* handle actions */ |
| 1410 | if (input_ui_pressed(IPT_UI_SELECT)) | |
| 1452 | if (input_ui_pressed(machine, IPT_UI_SELECT)) | |
| 1411 | 1453 | { |
| 1412 | 1454 | if (selected == menu_items - 2) |
| 1413 | 1455 | { |
| r2724 | r2725 | |
| 1478 | 1520 | visible_items = ui_menu_draw(item_list, menu_items, selected, NULL); |
| 1479 | 1521 | |
| 1480 | 1522 | /* handle the keys */ |
| 1481 | if (ui_menu_generic_keys(&selected, menu_items, visible_items)) | |
| 1523 | if (ui_menu_generic_keys(machine, &selected, menu_items, visible_items)) | |
| 1482 | 1524 | return selected; |
| 1483 | 1525 | |
| 1484 | 1526 | /* handle actions */ |
| 1485 | if (input_ui_pressed(IPT_UI_SELECT)) | |
| 1527 | if (input_ui_pressed(machine, IPT_UI_SELECT)) | |
| 1486 | 1528 | { |
| 1487 | 1529 | /* rotate */ |
| 1488 | 1530 | if (selected == menu_items - 6) |
| r2724 | r2725 | |
| 1535 | 1577 | quitting the game |
| 1536 | 1578 | -------------------------------------------------*/ |
| 1537 | 1579 | |
| 1538 | static UINT32 menu_quit_game(UINT32 state) | |
| 1580 | static UINT32 menu_quit_game(running_machine *machine, UINT32 state) | |
| 1539 | 1581 | { |
| 1540 | 1582 | /* request a reset */ |
| 1541 | mame_schedule_exit( | |
| 1583 | mame_schedule_exit(machine); | |
| 1542 | 1584 | |
| 1543 | 1585 | /* reset the menu stack */ |
| 1544 | 1586 | ui_menu_stack_reset(); |
| r2724 | r2725 | |
| 1551 | 1593 | menu |
| 1552 | 1594 | -------------------------------------------------*/ |
| 1553 | 1595 | |
| 1554 | static UINT32 menu_select_game(UINT32 state) | |
| 1596 | static UINT32 menu_select_game(running_machine *machine, UINT32 state) | |
| 1555 | 1597 | { |
| 1556 | 1598 | ui_menu_item item_list[VISIBLE_GAMES_IN_LIST + 2]; |
| 1557 | 1599 | int error = (state >> 17) & 1; |
| r2724 | r2725 | |
| 1649 | 1691 | recompute |= select_game_handle_key(curkey, curkey - KEYCODE_0_PAD + '0'); |
| 1650 | 1692 | |
| 1651 | 1693 | /* escape pressed with non-empty text clears the text */ |
| 1652 | if (input_ui_pressed(IPT_UI_CANCEL)) | |
| 1694 | if (input_ui_pressed(machine, IPT_UI_CANCEL)) | |
| 1653 | 1695 | { |
| 1654 | 1696 | if (select_game_buffer[0] == 0) |
| 1655 | 1697 | return ui_menu_stack_pop(); |
| r2724 | r2725 | |
| 1665 | 1707 | selected = 0; |
| 1666 | 1708 | |
| 1667 | 1709 | /* ignore pause keys by swallowing them */ |
| 1668 | input_ui_pressed(IPT_UI_PAUSE); | |
| 1710 | input_ui_pressed(machine, IPT_UI_PAUSE); | |
| 1669 | 1711 | |
| 1670 | 1712 | /* handle the generic keys */ |
| 1671 | if (!recompute && ui_menu_generic_keys(&selected, menu_items, visible_items)) | |
| 1713 | if (!recompute && ui_menu_generic_keys(machine, &selected, menu_items, visible_items)) | |
| 1672 | 1714 | return selected; |
| 1673 | 1715 | |
| 1674 | 1716 | /* handle actions */ |
| 1675 | if (input_ui_pressed(IPT_UI_SELECT)) | |
| 1717 | if (input_ui_pressed(machine, IPT_UI_SELECT)) | |
| 1676 | 1718 | { |
| 1677 | 1719 | /* control config */ |
| 1678 | 1720 | if (ui_menu_is_force_game_select() && selected == menu_items - 2) |
| r2724 | r2725 | |
| 1694 | 1736 | /* if everything looks good, schedule the new driver */ |
| 1695 | 1737 | if (audit_result == CORRECT || audit_result == BEST_AVAILABLE) |
| 1696 | 1738 | { |
| 1697 | mame_schedule_new_driver( | |
| 1739 | mame_schedule_new_driver(machine, select_game_list[selected]); | |
| 1698 | 1740 | ui_menu_stack_reset(); |
| 1699 | 1741 | return 0; |
| 1700 | 1742 | } |
| r2724 | r2725 | |
| 1718 | 1760 | -------------------------------------------------*/ |
| 1719 | 1761 | |
| 1720 | 1762 | #ifdef MESS |
| 1721 | static UINT32 menu_file_manager(UINT32 state) | |
| 1763 | static UINT32 menu_file_manager(running_machine *machine, UINT32 state) | |
| 1722 | 1764 | { |
| 1723 | int result = filemanager(state); | |
| 1765 | int result = filemanager(machine, state); | |
| 1724 | 1766 | if (result == 0) |
| 1725 | 1767 | return ui_menu_stack_pop(); |
| 1726 | 1768 | return result; |
| r2724 | r2725 | |
| 1734 | 1776 | |
| 1735 | 1777 | #ifdef MESS |
| 1736 | 1778 | #if HAS_WAVE |
| 1737 | static UINT32 menu_tape_control(UINT32 state) | |
| 1779 | static UINT32 menu_tape_control(running_machine *machine, UINT32 state) | |
| 1738 | 1780 | { |
| 1739 | int result = tapecontrol(state); | |
| 1781 | int result = tapecontrol(machine, state); | |
| 1740 | 1782 | if (result == 0) |
| 1741 | 1783 | return ui_menu_stack_pop(); |
| 1742 | 1784 | return result; |
| r2724 | r2725 | |
| 1810 | 1852 | for a given group of inputs |
| 1811 | 1853 | -------------------------------------------------*/ |
| 1812 | 1854 | |
| 1813 | static int input_menu_get_items(input_item_data *itemlist, int group) | |
| 1855 | static int input_menu_get_items(running_machine *machine, input_item_data *itemlist, int group) | |
| 1814 | 1856 | { |
| 1815 | 1857 | input_item_data *item = itemlist; |
| 1816 | const input_port_default_entry *indef; | |
| 1817 | input_port_default_entry *in; | |
| 1858 | const input_type_desc *typedesc; | |
| 1818 | 1859 | astring *seqstring; |
| 1819 | 1860 | |
| 1820 | /* an out of range group is special; it just means the game-specific inputs */ | |
| 1821 | if (group > IPG_TOTAL_GROUPS) | |
| 1822 | return input_menu_get_game_items(itemlist); | |
| 1823 | ||
| 1824 | 1861 | /* iterate over the input ports and add menu items */ |
| 1825 | 1862 | seqstring = astring_alloc(); |
| 1826 | for ( | |
| 1863 | for ( | |
| 1827 | 1864 | |
| 1828 | 1865 | /* add if we match the group and we have a valid name */ |
| 1829 | if ( | |
| 1866 | if (typedesc->group == group && typedesc->name != NULL && typedesc->name[0] != 0) | |
| 1830 | 1867 | { |
| 1831 | 1868 | /* build an entry for the standard sequence */ |
| 1832 | item->seq = &in->defaultseq; | |
| 1833 | item->defseq = &indef->defaultseq; | |
| 1869 | item->typedesc = typedesc; | |
| 1870 | item->seqtype = SEQ_TYPE_STANDARD; | |
| 1871 | item->seq = *input_type_seq(machine, typedesc->type, typedesc->player, item->seqtype); | |
| 1872 | item->defseq = &typedesc->seq[item->seqtype]; | |
| 1834 | 1873 | item->sortorder = item - itemlist; |
| 1835 | item->type = port_type_is_analog(in->type) ? INPUT_TYPE_ANALOG : INPUT_TYPE_DIGITAL; | |
| 1836 | item->name = menu_string_pool_add(input_format[item->type], in->name); | |
| 1837 | item->seqname = menu_string_pool_add("%s", astring_c(input_seq_name(seqstring, item->seq))); | |
| 1838 | item->invert = input_seq_cmp(item->seq, item->defseq); | |
| 1874 | item->type = input_type_is_analog(typedesc->type) ? INPUT_TYPE_ANALOG : INPUT_TYPE_DIGITAL; | |
| 1875 | item->name = menu_string_pool_add(input_format[item->type], typedesc->name); | |
| 1876 | item->seqname = menu_string_pool_add("%s", astring_c(input_seq_name(seqstring, &item->seq))); | |
| 1877 | item->invert = input_seq_cmp(&item->seq, item->defseq); | |
| 1839 | 1878 | item++; |
| 1840 | 1879 | |
| 1841 | 1880 | /* if we're analog, add more entries */ |
| 1842 | 1881 | if (item[-1].type == INPUT_TYPE_ANALOG) |
| 1843 | 1882 | { |
| 1844 | 1883 | /* build an entry for the decrement sequence */ |
| 1845 | item->seq = &in->defaultdecseq; | |
| 1846 | item->defseq = &indef->defaultdecseq; | |
| 1884 | item->typedesc = typedesc; | |
| 1885 | item->seqtype = SEQ_TYPE_DECREMENT; | |
| 1886 | item->seq = *input_type_seq(machine, typedesc->type, typedesc->player, item->seqtype); | |
| 1887 | item->defseq = &typedesc->seq[item->seqtype]; | |
| 1847 | 1888 | item->sortorder = item - itemlist; |
| 1848 | 1889 | item->type = INPUT_TYPE_ANALOG_DEC; |
| 1849 | item->name = menu_string_pool_add(input_format[item->type], in->name); | |
| 1850 | item->seqname = menu_string_pool_add("%s", astring_c(input_seq_name(seqstring, item->seq))); | |
| 1851 | item->invert = input_seq_cmp(item->seq, item->defseq); | |
| 1890 | item->name = menu_string_pool_add(input_format[item->type], typedesc->name); | |
| 1891 | item->seqname = menu_string_pool_add("%s", astring_c(input_seq_name(seqstring, &item->seq))); | |
| 1892 | item->invert = input_seq_cmp(&item->seq, item->defseq); | |
| 1852 | 1893 | item++; |
| 1853 | 1894 | |
| 1854 | 1895 | /* build an entry for the increment sequence */ |
| 1855 | item->seq = &in->defaultincseq; | |
| 1856 | item->defseq = &indef->defaultincseq; | |
| 1896 | item->typedesc = typedesc; | |
| 1897 | item->seqtype = SEQ_TYPE_INCREMENT; | |
| 1898 | item->seq = *input_type_seq(machine, typedesc->type, typedesc->player, item->seqtype); | |
| 1899 | item->defseq = &typedesc->seq[item->seqtype]; | |
| 1857 | 1900 | item->sortorder = item - itemlist; |
| 1858 | 1901 | item->type = INPUT_TYPE_ANALOG_INC; |
| 1859 | item->name = menu_string_pool_add(input_format[item->type], in->name); | |
| 1860 | item->seqname = menu_string_pool_add("%s", astring_c(input_seq_name(seqstring, item->seq))); | |
| 1861 | item->invert = input_seq_cmp(item->seq, item->defseq); | |
| 1902 | item->name = menu_string_pool_add(input_format[item->type], typedesc->name); | |
| 1903 | item->seqname = menu_string_pool_add("%s", astring_c(input_seq_name(seqstring, &item->seq))); | |
| 1904 | item->invert = input_seq_cmp(&item->seq, item->defseq); | |
| 1862 | 1905 | item++; |
| 1863 | 1906 | } |
| 1864 | 1907 | } |
| r2724 | r2725 | |
| 1870 | 1913 | |
| 1871 | 1914 | |
| 1872 | 1915 | /*------------------------------------------------- |
| 1916 | get_field_default_seq - return a pointer | |
| 1917 | to the default sequence for the given field | |
| 1918 | -------------------------------------------------*/ | |
| 1919 | ||
| 1920 | static const input_seq *get_field_default_seq(const input_field_config *field, int seqtype) | |
| 1921 | { | |
| 1922 | if (input_seq_get_1(&field->seq[seqtype]) == SEQCODE_DEFAULT) | |
| 1923 | return input_type_seq(field->port->machine, field->type, field->player, seqtype); | |
| 1924 | else | |
| 1925 | return &field->seq[seqtype]; | |
| 1926 | } | |
| 1927 | ||
| 1928 | ||
| 1929 | /*------------------------------------------------- | |
| 1873 | 1930 | input_menu_get_game_items - build a list of |
| 1874 | 1931 | items for the game-specific inputs |
| 1875 | 1932 | -------------------------------------------------*/ |
| 1876 | 1933 | |
| 1877 | static int input_menu_get_game_items(input_item_data *itemlist) | |
| 1934 | static int input_menu_get_game_items(running_machine *machine, input_item_data *itemlist) | |
| 1878 | 1935 | { |
| 1879 | static const input_seq default_seq = SEQ_DEF_1(SEQCODE_DEFAULT); | |
| 1880 | 1936 | astring *seqstring = astring_alloc(); |
| 1881 | 1937 | input_item_data *item = itemlist; |
| 1882 | input_port_entry *in; | |
| 1938 | const input_port_config *port; | |
| 1939 | const input_field_config *field; | |
| 1883 | 1940 | |
| 1884 | 1941 | /* iterate over the input ports and add menu items */ |
| 1885 | for (in = Machine->input_ports; in->type != IPT_END; in++) | |
| 1886 | { | |
| 1887 | const char *name = input_port_name(in); | |
| 1942 | for (port = machine->portconfig; port != NULL; port = port->next) | |
| 1943 | for (field = port->fieldlist; field != NULL; field = field->next) | |
| 1944 | { | |
| 1945 | const char *name = input_field_name(field); | |
| 1888 | 1946 | |
| 1889 | /* add if we match the group and we have a valid name */ | |
| 1890 | if ((name != NULL) && (input_port_condition(in)) && | |
| 1947 | /* add if we match the group and we have a valid name */ | |
| 1948 | if (name != NULL && input_condition_true(machine, &field->condition) && | |
| 1891 | 1949 | #ifdef MESS |
| 1892 | (i | |
| 1950 | (field->category == 0 || input_category_active(machine, field->category)) && | |
| 1893 | 1951 | #endif /* MESS */ |
| 1894 | ((in->type == IPT_OTHER && in->name != IP_NAME_DEFAULT) || port_type_to_group(in->type, in->player) != IPG_INVALID)) | |
| 1895 | { | |
| 1896 | UINT16 sortorder; | |
| 1897 | const input_seq *curseq, *defseq; | |
| 1952 | ((field->type == IPT_OTHER && field->name != NULL) || input_type_group(machine, field->type, field->player) != IPG_INVALID)) | |
| 1953 | { | |
| 1954 | UINT16 sortorder; | |
| 1898 | 1955 | |
| 1899 | /* determine the sorting order */ | |
| 1900 | if (in->type >= IPT_START1 && in->type <= __ipt_analog_end) | |
| 1901 | sortorder = (in->type << 2) | (in->player << 12); | |
| 1902 | else | |
| 1903 | sortorder = in->type | 0xf000; | |
| 1956 | /* determine the sorting order */ | |
| 1957 | if (field->type >= IPT_START1 && field->type <= __ipt_analog_end) | |
| 1958 | sortorder = (field->type << 2) | (field->player << 12); | |
| 1959 | else | |
| 1960 | sortorder = field->type | 0xf000; | |
| 1904 | 1961 | |
| 1905 | /* fetch data for the standard sequence */ | |
| 1906 | curseq = input_port_seq(in, SEQ_TYPE_STANDARD); | |
| 1907 | defseq = input_port_default_seq(in->type, in->player, SEQ_TYPE_STANDARD); | |
| 1908 | ||
| 1909 | /* build an entry for the standard sequence */ | |
| 1910 | item->seq = &in->seq; | |
| 1911 | item->defseq = &default_seq; | |
| 1912 | item->sortorder = sortorder; | |
| 1913 | item->type = port_type_is_analog(in->type) ? INPUT_TYPE_ANALOG : INPUT_TYPE_DIGITAL; | |
| 1914 | item->name = menu_string_pool_add(input_format[item->type], name); | |
| 1915 | item->seqname = menu_string_pool_add("%s", astring_c(input_seq_name(seqstring, curseq))); | |
| 1916 | item->invert = input_seq_cmp(curseq, defseq); | |
| 1917 | item++; | |
| 1918 | ||
| 1919 | /* if we're analog, add more entries */ | |
| 1920 | if (item[-1].type == INPUT_TYPE_ANALOG) | |
| 1921 | { | |
| 1922 | /* fetch data for the decrement sequence */ | |
| 1923 | curseq = input_port_seq(in, SEQ_TYPE_DECREMENT); | |
| 1924 | defseq = input_port_default_seq(in->type, in->player, SEQ_TYPE_DECREMENT); | |
| 1925 | ||
| 1926 | /* build an entry for the decrement sequence */ | |
| 1927 | item->seq = &in->analog.decseq; | |
| 1928 | item->defseq = &default_seq; | |
| 1962 | /* build an entry for the standard sequence */ | |
| 1963 | item->field = field; | |
| 1964 | item->seqtype = SEQ_TYPE_STANDARD; | |
| 1965 | item->seq = *input_field_seq(field, item->seqtype); | |
| 1966 | item->defseq = get_field_default_seq(field, item->seqtype); | |
| 1929 | 1967 | item->sortorder = sortorder; |
| 1930 | item->type = INPUT_TYPE_ANALOG_ | |
| 1968 | item->type = input_type_is_analog(field->type) ? INPUT_TYPE_ANALOG : INPUT_TYPE_DIGITAL; | |
| 1931 | 1969 | item->name = menu_string_pool_add(input_format[item->type], name); |
| 1932 | item->seqname = menu_string_pool_add("%s", astring_c(input_seq_name(seqstring, curseq))); | |
| 1933 | item->invert = input_seq_cmp(curseq, defseq); | |
| 1970 | item->seqname = menu_string_pool_add("%s", astring_c(input_seq_name(seqstring, &item->seq))); | |
| 1971 | item->invert = input_seq_cmp(&item->seq, item->defseq); | |
| 1934 | 1972 | item++; |
| 1935 | 1973 | |
| 1936 | /* fetch data for the increment sequence */ | |
| 1937 | curseq = input_port_seq(in, SEQ_TYPE_INCREMENT); | |
| 1938 | defseq = input_port_default_seq(in->type, in->player, SEQ_TYPE_INCREMENT); | |
| 1974 | /* if we're analog, add more entries */ | |
| 1975 | if (item[-1].type == INPUT_TYPE_ANALOG) | |
| 1976 | { | |
| 1977 | /* build an entry for the decrement sequence */ | |
| 1978 | item->field = field; | |
| 1979 | item->seqtype = SEQ_TYPE_DECREMENT; | |
| 1980 | item->seq = *input_field_seq(field, item->seqtype); | |
| 1981 | item->defseq = get_field_default_seq(field, item->seqtype); | |
| 1982 | item->sortorder = sortorder; | |
| 1983 | item->type = INPUT_TYPE_ANALOG_DEC; | |
| 1984 | item->name = menu_string_pool_add(input_format[item->type], name); | |
| 1985 | item->seqname = menu_string_pool_add("%s", astring_c(input_seq_name(seqstring, &item->seq))); | |
| 1986 | item->invert = input_seq_cmp(&item->seq, item->defseq); | |
| 1987 | item++; | |
| 1939 | 1988 | |
| 1940 | /* build an entry for the increment sequence */ | |
| 1941 | item->seq = &in->analog.incseq; | |
| 1942 | item->defseq = &default_seq; | |
| 1943 | item->sortorder = sortorder; | |
| 1944 | item->type = INPUT_TYPE_ANALOG_INC; | |
| 1945 | item->name = menu_string_pool_add(input_format[item->type], name); | |
| 1946 | item->seqname = menu_string_pool_add("%s", astring_c(input_seq_name(seqstring, curseq))); | |
| 1947 | item->invert = input_seq_cmp(curseq, defseq); | |
| 1948 | item++; | |
| 1989 | /* build an entry for the increment sequence */ | |
| 1990 | item->field = field; | |
| 1991 | item->seqtype = SEQ_TYPE_INCREMENT; | |
| 1992 | item->seq = *input_field_seq(field, item->seqtype); | |
| 1993 | item->defseq = get_field_default_seq(field, item->seqtype); | |
| 1994 | item->sortorder = sortorder; | |
| 1995 | item->type = INPUT_TYPE_ANALOG_INC; | |
| 1996 | item->name = menu_string_pool_add(input_format[item->type], name); | |
| 1997 | item->seqname = menu_string_pool_add("%s", astring_c(input_seq_name(seqstring, &item->seq))); | |
| 1998 | item->invert = input_seq_cmp(&item->seq, item->defseq); | |
| 1999 | item++; | |
| 2000 | } | |
| 1949 | 2001 | } |
| 1950 | 2002 | } |
| 1951 | } | |
| 1952 | 2003 | |
| 1953 | 2004 | /* return the number of items */ |
| 1954 | 2005 | astring_free(seqstring); |
| r2724 | r2725 | |
| 2001 | 2052 | switches menu list |
| 2002 | 2053 | -------------------------------------------------*/ |
| 2003 | 2054 | |
| 2004 | static void switches_menu_add_item(ui_menu_item *item, const input_ | |
| 2055 | static void switches_menu_add_item(ui_menu_item *item, const input_f | |
| 2005 | 2056 | { |
| 2006 | const input_port_entry *tin; | |
| 2057 | const input_setting_config *setting; | |
| 2058 | input_field_user_settings settings; | |
| 2007 | 2059 | |
| 2008 | 2060 | /* set the text to the name and the subitem text to invalid */ |
| 2009 | item->text = input_port_name(in); | |
| 2061 | input_field_get_user_settings(field, &settings); | |
| 2062 | item->text = input_field_name(field); | |
| 2010 | 2063 | item->subtext = NULL; |
| 2011 | 2064 | |
| 2012 | 2065 | /* scan for the current selection in the list */ |
| 2013 | for (tin = in + 1; tin->type == switch_entry; tin++) | |
| 2014 | if (input_port_condition(tin)) | |
| 2066 | for (setting = field->settinglist; setting != NULL; setting = setting->next) | |
| 2067 | if (input_condition_true(field->port->machine, &setting->condition)) | |
| 2015 | 2068 | { |
| 2016 | 2069 | /* if this is a match, set the subtext */ |
| 2017 | if (in->default_value == tin->default_value) | |
| 2018 | item->subtext = input_port_name(tin); | |
| 2070 | if (setting->value == settings.value) | |
| 2071 | item->subtext = setting->name; | |
| 2019 | 2072 | |
| 2020 | 2073 | /* else if we haven't seen a match yet, show a left arrow */ |
| 2021 | else if ( | |
| 2074 | else if ( | |
| 2022 | 2075 | item->flags |= MENU_FLAG_LEFT_ARROW; |
| 2023 | 2076 | |
| 2024 | 2077 | /* else if we have seen a match, show a right arrow */ |
| r2724 | r2725 | |
| 2027 | 2080 | } |
| 2028 | 2081 | |
| 2029 | 2082 | /* if no matches, we're invalid */ |
| 2030 | if ( | |
| 2083 | if ( | |
| 2031 | 2084 | item->subtext = "INVALID"; |
| 2032 | 2085 | |
| 2033 | 2086 | /* stash our reference */ |
| 2034 | item->ref = | |
| 2087 | item->ref = (void *)field; | |
| 2035 | 2088 | } |
| 2036 | 2089 | |
| 2037 | 2090 | |
| r2724 | r2725 | |
| 2040 | 2093 | previous item in the switches list |
| 2041 | 2094 | -------------------------------------------------*/ |
| 2042 | 2095 | |
| 2043 | static void switches_menu_select_previous(input_ | |
| 2096 | static void switches_menu_select_previous(const input_fi | |
| 2044 | 2097 | { |
| 2045 | int last_value = in->default_value; | |
| 2046 | const input_port_entry *tin; | |
| 2098 | const input_setting_config *setting, *prevsetting; | |
| 2099 | input_field_user_settings settings; | |
| 2100 | int found_match = FALSE; | |
| 2047 | 2101 | |
| 2048 | /* scan for the current selection in the list */ | |
| 2049 | for (tin = in + 1; tin->type == switch_entry; tin++) | |
| 2050 | if (input_port_condition(tin)) | |
| 2102 | /* get the current configured settings */ | |
| 2103 | input_field_get_user_settings(field, &settings); | |
| 2104 | ||
| 2105 | /* scan the list of settings looking for a match on the current value */ | |
| 2106 | prevsetting = NULL; | |
| 2107 | for (setting = field->settinglist; setting != NULL; setting = setting->next) | |
| 2108 | { | |
| 2109 | if (setting->value == settings.value) | |
| 2051 | 2110 | { |
| 2052 | /* if this is a match, we're done */ | |
| 2053 | if (in->default_value == tin->default_value) | |
| 2054 | { | |
| 2055 | in->default_value = last_value; | |
| 2056 | return; | |
| 2057 | } | |
| 2111 | found_match = TRUE; | |
| 2112 | if (prevsetting != NULL) | |
| 2113 | break; | |
| 2114 | } | |
| 2115 | if (input_condition_true(field->port->machine, &setting->condition)) | |
| 2116 | prevsetting = setting; | |
| 2117 | } | |
| 2058 | 2118 | |
| 2059 | /* otherwise, keep track of last one found */ | |
| 2060 | else | |
| 2061 | last_value = tin->default_value; | |
| 2062 | } | |
| 2119 | /* if we didn't find a matching value, select the first */ | |
| 2120 | if (!found_match) | |
| 2121 | { | |
| 2122 | for (prevsetting = field->settinglist; prevsetting != NULL; prevsetting = prevsetting->next) | |
| 2123 | if (input_condition_true(field->port->machine, &prevsetting->condition)) | |
| 2124 | break; | |
| 2125 | } | |
| 2126 | ||
| 2127 | /* update the value to the previous one */ | |
| 2128 | if (prevsetting != NULL) | |
| 2129 | settings.value = prevsetting->value; | |
| 2130 | input_field_set_user_settings(field, &settings); | |
| 2063 | 2131 | } |
| 2064 | 2132 | |
| 2065 | 2133 | |
| r2724 | r2725 | |
| 2068 | 2136 | next item in the switches list |
| 2069 | 2137 | -------------------------------------------------*/ |
| 2070 | 2138 | |
| 2071 | static void switches_menu_select_next(input_ | |
| 2139 | static void switches_menu_select_next(const input_fi | |
| 2072 | 2140 | { |
| 2073 | const input_port_entry *tin; | |
| 2074 | int foundit = FALSE; | |
| 2141 | const input_setting_config *setting, *nextsetting; | |
| 2142 | input_field_user_settings settings; | |
| 2075 | 2143 | |
| 2076 | /* scan for the current selection in the list */ | |
| 2077 | for (tin = in + 1; tin->type == switch_entry; tin++) | |
| 2078 | if (input_port_condition(tin)) | |
| 2079 | { | |
| 2080 | /* if we found the current selection, we pick the next one */ | |
| 2081 | if (foundit) | |
| 2082 | { | |
| 2083 | in->default_value = tin->default_value; | |
| 2084 | return; | |
| 2085 | } | |
| 2144 | /* get the current configured settings */ | |
| 2145 | input_field_get_user_settings(field, &settings); | |
| 2086 | 2146 | |
| 2087 | /* if this is a match, note it */ | |
| 2088 | if (in->default_value == tin->default_value) | |
| 2089 | foundit = TRUE; | |
| 2090 | } | |
| 2091 | } | |
| 2147 | /* scan the list of settings looking for a match on the current value */ | |
| 2148 | nextsetting = NULL; | |
| 2149 | for (setting = field->settinglist; setting != NULL; setting = setting->next) | |
| 2150 | if (setting->value == settings.value) | |
| 2151 | break; | |
| 2092 | 2152 | |
| 2153 | /* if we found one, scan forward for the next valid one */ | |
| 2154 | if (setting != NULL) | |
| 2155 | for (nextsetting = setting->next; nextsetting != NULL; nextsetting = nextsetting->next) | |
| 2156 | if (input_condition_true(field->port->machine, &nextsetting->condition)) | |
| 2157 | break; | |
| 2093 | 2158 | |
| 2094 | /*------------------------------------------------- | |
| 2095 | switches_menu_compare_items - compare two | |
| 2096 | switches items for quicksort purposes | |
| 2097 | -------------------------------------------------*/ | |
| 2159 | /* if we hit the end, search from the beginning */ | |
| 2160 | if (nextsetting == NULL) | |
| 2161 | for (nextsetting = field->settinglist; nextsetting != NULL; nextsetting = nextsetting->next) | |
| 2162 | if (input_condition_true(field->port->machine, &nextsetting->condition)) | |
| 2163 | break; | |
| 2098 | 2164 | |
| 2099 | /* | |
| 2100 | static int switches_menu_compare_items(const void *i1, const void *i2) | |
| 2101 | { | |
| 2102 | const ui_menu_item *item1 = i1; | |
| 2103 | const ui_menu_item *item2 = i2; | |
| 2104 | const input_port_entry *data1 = item1->ref; | |
| 2105 | const input_port_entry *data2 = item2->ref; | |
| 2106 | return strcmp(input_port_name(data1), input_port_name(data2)); | |
| 2165 | /* update the value to the previous one */ | |
| 2166 | if (nextsetting != NULL) | |
| 2167 | settings.value = nextsetting->value; | |
| 2168 | input_field_set_user_settings(field, &settings); | |
| 2107 | 2169 | } |
| 2108 | */ | |
| 2109 | 2170 | |
| 2110 | 2171 | |
| 2111 | 2172 | /*------------------------------------------------- |
| r2724 | r2725 | |
| 2113 | 2174 | analog controls menu |
| 2114 | 2175 | -------------------------------------------------*/ |
| 2115 | 2176 | |
| 2116 | static void analog_menu_add_item(ui_menu_item *item, const input_ | |
| 2177 | static void analog_menu_add_item(ui_menu_item *item, const input_fi | |
| 2117 | 2178 | { |
| 2179 | input_field_user_settings settings; | |
| 2118 | 2180 | int value, minval, maxval; |
| 2119 | 2181 | |
| 2182 | input_field_get_user_settings(field, &settings); | |
| 2183 | ||
| 2120 | 2184 | /* set the item text using the formatting string provided */ |
| 2121 | item->text = menu_string_pool_add("%s %s", input_ | |
| 2185 | item->text = menu_string_pool_add("%s %s", input_field_name(field), append_string); | |
| 2122 | 2186 | |
| 2123 | 2187 | /* set the subitem text */ |
| 2124 | 2188 | switch (which_item) |
| 2125 | 2189 | { |
| 2126 | 2190 | default: |
| 2127 | 2191 | case ANALOG_ITEM_KEYSPEED: |
| 2128 | value = in | |
| 2192 | value = settin | |
| 2129 | 2193 | minval = 0; |
| 2130 | 2194 | maxval = 255; |
| 2131 | 2195 | item->subtext = menu_string_pool_add("%d", value); |
| 2132 | 2196 | break; |
| 2133 | 2197 | |
| 2134 | 2198 | case ANALOG_ITEM_CENTERSPEED: |
| 2135 | value = in | |
| 2199 | value = settin | |
| 2136 | 2200 | minval = 0; |
| 2137 | 2201 | maxval = 255; |
| 2138 | 2202 | item->subtext = menu_string_pool_add("%d", value); |
| 2139 | 2203 | break; |
| 2140 | 2204 | |
| 2141 | 2205 | case ANALOG_ITEM_REVERSE: |
| 2142 | value = in | |
| 2206 | value = settin | |
| 2143 | 2207 | minval = 0; |
| 2144 | 2208 | maxval = 1; |
| 2145 | 2209 | item->subtext = value ? "On" : "Off"; |
| 2146 | 2210 | break; |
| 2147 | 2211 | |
| 2148 | 2212 | case ANALOG_ITEM_SENSITIVITY: |
| 2149 | value = in | |
| 2213 | value = settin | |
| 2150 | 2214 | minval = 1; |
| 2151 | 2215 | maxval = 255; |
| 2152 | 2216 | item->subtext = menu_string_pool_add("%d%%", value); |
| r2724 | r2725 | |
| 2166 | 2230 | for DIP switches |
| 2167 | 2231 | -------------------------------------------------*/ |
| 2168 | 2232 | |
| 2169 | static void dip_switch_build_model(input_ | |
| 2233 | static void dip_switch_build_model(const input_fi | |
| 2170 | 2234 | { |
| 2171 | int dip_declaration_index = 0; | |
| 2172 | int value_mask_temp = entry->mask; | |
| 2235 | input_port_value value_mask_temp = field->mask; | |
| 2236 | const input_field_diplocation *diploc; | |
| 2237 | input_port_value toggle_switch_mask; | |
| 2238 | input_field_user_settings settings; | |
| 2173 | 2239 | int value_mask_bit = 0; |
| 2174 | int toggle_switch_mask; | |
| 2175 | int model_index = 0; | |
| 2240 | int model_index; | |
| 2176 | 2241 | int toggle_num; |
| 2177 | 2242 | |
| 2178 | if (entry->diploc[dip_declaration_index].swname == NULL) | |
| 2243 | diploc = field->diploclist; | |
| 2244 | if (diploc == NULL || diploc->swname == NULL) | |
| 2179 | 2245 | return; |
| 2180 | 2246 | |
| 2247 | input_field_get_user_settings(field, &settings); | |
| 2248 | ||
| 2181 | 2249 | /* get the entry in the model to work with */ |
| 2182 | do | |
| 2250 | for (model_index = 0; model_index < MAX_PHYSICAL_DIPS; model_index++) | |
| 2183 | 2251 | { |
| 2184 | 2252 | /* use this entry if it's not used */ |
| 2185 | 2253 | if (dip_switch_model[model_index].dip_name == NULL) |
| 2186 | 2254 | { |
| 2187 | dip_switch_model[model_index].dip_name = | |
| 2255 | dip_switch_model[model_index].dip_name = | |
| 2188 | 2256 | break; |
| 2189 | 2257 | } |
| 2190 | 2258 | |
| 2191 | 2259 | /* reuse this entry if the switch name matches */ |
| 2192 | if (!strcmp( | |
| 2260 | if (!strcmp( | |
| 2193 | 2261 | break; |
| 2194 | 2262 | |
| 2195 | 2263 | // todo: add a check here to see if we go over the max dips and throw an error. |
| 2196 | } | |
| 2264 | } | |
| 2197 | 2265 | |
| 2198 | 2266 | /* Create a mask depicting the number of toggles on the physical switch */ |
| 2199 | | |
| 2267 | for | |
| 2200 | 2268 | { |
| 2201 | 2269 | /* get the Nth DIP toggle number */ |
| 2202 | toggle_num = | |
| 2270 | toggle_num = | |
| 2203 | 2271 | |
| 2204 | 2272 | /* get the Nth mask bit - |
| 2205 | 2273 | * should probably put a check here to avoid bad driver definitions |
| r2724 | r2725 | |
| 2218 | 2286 | dip_switch_model[model_index].total_dip_mask |= toggle_switch_mask; |
| 2219 | 2287 | |
| 2220 | 2288 | /* if it's inverted, mark it as such */ |
| 2221 | if ( | |
| 2289 | if ( | |
| 2222 | 2290 | dip_switch_model[model_index].dip_invert_mask |= toggle_switch_mask; |
| 2223 | 2291 | |
| 2224 | 2292 | /* if isolated bit is on, set the toggle on */ |
| 2225 | if ((1 << value_mask_bit) & e | |
| 2293 | if ((1 << value_mask_bit) & se | |
| 2226 | 2294 | dip_switch_model[model_index].total_dip_settings |= toggle_switch_mask; |
| 2227 | 2295 | |
| 2228 | 2296 | /* indicate if the toggle is selected */ |
| 2229 | 2297 | if (item_is_selected) |
| 2230 | 2298 | dip_switch_model[model_index].selected_dip_feature_mask |= toggle_switch_mask; |
| 2231 | ||
| 2232 | ++dip_declaration_index; | |
| 2233 | 2299 | } |
| 2234 | 2300 | } |
| 2235 | 2301 |
| r2724 | r2725 | |
|---|---|---|
| 32 | 32 | TYPE DEFINITIONS |
| 33 | 33 | ***************************************************************************/ |
| 34 | 34 | |
| 35 | typedef UINT32 (*ui_menu_handler_func)(UINT32 state); | |
| 35 | typedef UINT32 (*ui_menu_handler_func)(running_machine *machine, UINT32 state); | |
| 36 | 36 | |
| 37 | 37 | typedef struct _ui_menu_item ui_menu_item; |
| 38 | 38 | struct _ui_menu_item |
| r2724 | r2725 | |
| 65 | 65 | /* draw a menu, returning the number of visible items */ |
| 66 | 66 | int ui_menu_draw(const ui_menu_item *items, int numitems, int selected, const menu_extra *extra); |
| 67 | 67 | |
| 68 | /* draw a text box */ | |
| 69 | void ui_menu_draw_text_box(const char *text); | |
| 70 | ||
| 71 | 68 | /* master handler */ |
| 72 | 69 | UINT32 ui_menu_ui_handler(running_machine *machine, UINT32 state); |
| 73 | 70 | |
| 74 | 71 | /* menu keyboard handling */ |
| 75 | int ui_menu_generic_keys(UINT32 *selected, int num_items, int visible_items); | |
| 72 | int ui_menu_generic_keys(running_machine *machine, UINT32 *selected, int num_items, int visible_items); | |
| 76 | 73 | |
| 77 | 74 | /* menu stack management */ |
| 78 | 75 | void ui_menu_stack_reset(void); |
| r2724 | r2725 | |
|---|---|---|
| 706 | 706 | /* loop over tokens until we hit the end */ |
| 707 | 707 | while (entrytype != ADDRMAP_TOKEN_END) |
| 708 | 708 | { |
| 709 | const char *tag; | |
| 710 | ||
| 711 | 709 | /* unpack the token from the first entry */ |
| 712 | 710 | TOKEN_GET_UINT32_UNPACK1(tokens, entrytype, 8); |
| 713 | 711 | switch (entrytype) |
| r2724 | r2725 | |
| 785 | 783 | break; |
| 786 | 784 | |
| 787 | 785 | case ADDRMAP_TOKEN_READ_PORT: |
| 788 | tag = TOKEN_GET_STRING(tokens); | |
| 789 | switch (map->databits) | |
| 790 | { | |
| 791 | case 8: entry->read.mhandler8 = port_tag_to_handler8(tag); break; | |
| 792 | case 16: entry->read.mhandler16 = port_tag_to_handler16(tag); break; | |
| 793 | case 32: entry->read.mhandler32 = port_tag_to_handler32(tag); break; | |
| 794 | case 64: entry->read.mhandler64 = port_tag_to_handler64(tag); break; | |
| 795 | } | |
| 796 | if (entry->read.generic == NULL) | |
| 797 | fatalerror("Non-existent port referenced: '%s'\n", tag); | |
| 786 | entry->read_porttag = TOKEN_GET_STRING(tokens); | |
| 798 | 787 | break; |
| 799 | 788 | |
| 800 | 789 | case ADDRMAP_TOKEN_REGION: |
| r2724 | r2725 | |
| 1556 | 1545 | while (last_entry != space->map->entrylist) |
| 1557 | 1546 | { |
| 1558 | 1547 | const address_map_entry *entry; |
| 1548 | read_handler rhandler; | |
| 1549 | write_handler whandler; | |
| 1559 | 1550 | |
| 1560 | 1551 | /* find the entry before the last one we processed */ |
| 1561 | 1552 | for (entry = space->map->entrylist; entry->next != last_entry; entry = entry->next) ; |
| 1562 | 1553 | last_entry = entry; |
| 1554 | rhandler = entry->read; | |
| 1555 | whandler = entry->write; | |
| 1563 | 1556 | |
| 1564 | if (entry->read.generic != NULL) | |
| 1557 | /* if we have a read port tag, look it up */ | |
| 1558 | if (entry->read_porttag != NULL) | |
| 1565 | 1559 | { |
| 1560 | switch (space->dbits) | |
| 1561 | { | |
| 1562 | case 8: rhandler.mhandler8 = input_port_read_handler8(machine->portconfig, entry->read_porttag); break; | |
| 1563 | case 16: rhandler.mhandler16 = input_port_read_handler16(machine->portconfig, entry->read_porttag); break; | |
| 1564 | case 32: rhandler.mhandler32 = input_port_read_handler32(machine->portconfig, entry->read_porttag); break; | |
| 1565 | case 64: rhandler.mhandler64 = input_port_read_handler64(machine->portconfig, entry->read_porttag); break; | |
| 1566 | } | |
| 1567 | if (rhandler.generic == NULL) | |
| 1568 | fatalerror("Non-existent port referenced: '%s'\n", entry->read_porttag); | |
| 1569 | } | |
| 1570 | ||
| 1571 | /* install the read handler if present */ | |
| 1572 | if (rhandler.generic != NULL) | |
| 1573 | { | |
| 1566 | 1574 | int bits = (entry->read_bits == 0) ? space->dbits : entry->read_bits; |
| 1567 | 1575 | void *object = machine; |
| 1568 | 1576 | if (entry->read_devtype != NULL) |
| r2724 | r2725 | |
| 1571 | 1579 | if (object == NULL) |
| 1572 | 1580 | fatalerror("Unidentified object in memory map: type=%s tag=%s\n", devtype_name(entry->read_devtype), entry->read_devtag); |
| 1573 | 1581 | } |
| 1574 | space_map_range_private(space, ROW_READ, bits, entry->read_mask, entry->addrstart, entry->addrend, entry->addrmask, entry->addrmirror, | |
| 1582 | space_map_range_private(space, ROW_READ, bits, entry->read_mask, entry->addrstart, entry->addrend, entry->addrmask, entry->addrmirror, | |
| 1575 | 1583 | } |
| 1576 | if (entry->write.generic != NULL) | |
| 1584 | ||
| 1585 | /* install the write handler if present */ | |
| 1586 | if (whandler.generic != NULL) | |
| 1577 | 1587 | { |
| 1578 | 1588 | int bits = (entry->write_bits == 0) ? space->dbits : entry->write_bits; |
| 1579 | 1589 | void *object = machine; |
| r2724 | r2725 | |
| 1583 | 1593 | if (object == NULL) |
| 1584 | 1594 | fatalerror("Unidentified object in memory map: type=%s tag=%s\n", devtype_name(entry->write_devtype), entry->write_devtag); |
| 1585 | 1595 | } |
| 1586 | space_map_range_private(space, ROW_WRITE, bits, entry->write_mask, entry->addrstart, entry->addrend, entry->addrmask, entry->addrmirror, | |
| 1596 | space_map_range_private(space, ROW_WRITE, bits, entry->write_mask, entry->addrstart, entry->addrend, entry->addrmask, entry->addrmirror, | |
| 1587 | 1597 | } |
| 1588 | 1598 | } |
| 1589 | 1599 | } |
| r2724 | r2725 | |
| 2443 | 2453 | if (entry->baseptr != NULL) |
| 2444 | 2454 | *entry->baseptr = entry->memory; |
| 2445 | 2455 | if (entry->baseptroffs_plus1 != 0) |
| 2446 | *(void **)((UINT8 *) | |
| 2456 | *(void **)((UINT8 *)machine->driver_data + entry->baseptroffs_plus1 - 1) = entry->memory; | |
| 2447 | 2457 | if (entry->sizeptr != NULL) |
| 2448 | 2458 | *entry->sizeptr = entry->byteend - entry->bytestart + 1; |
| 2449 | 2459 | if (entry->sizeptroffs_plus1 != 0) |
| 2450 | *(size_t *)((UINT8 *) | |
| 2460 | *(size_t *)((UINT8 *)machine->driver_data + entry->sizeptroffs_plus1 - 1) = entry->byteend - entry->bytestart + 1; | |
| 2451 | 2461 | } |
| 2452 | 2462 | } |
| 2453 | 2463 |
| r2724 | r2725 | |
|---|---|---|
| 212 | 212 | const char * read_name; /* read handler callback name */ |
| 213 | 213 | device_type read_devtype; /* read device type for device references */ |
| 214 | 214 | const char * read_devtag; /* read tag for the relevant device */ |
| 215 | const char * read_porttag; /* tag for input port reading */ | |
| 215 | 216 | write_handler write; /* write handler callback */ |
| 216 | 217 | UINT8 write_bits; /* bits for the write handler callback (0=default, 1=8, 2=16, 3=32) */ |
| 217 | 218 | UINT8 write_mask; /* mask bits indicating which subunits to process */ |
| r2724 | r2725 | |
|---|---|---|
| 1467 | 1467 | machine->sample_rate = options_get_int(mame_options(), OPTION_SAMPLERATE); |
| 1468 | 1468 | |
| 1469 | 1469 | /* input-related information */ |
| 1470 | machine->input_ports = NULL; | |
| 1471 | machine->record_file = NULL; | |
| 1472 | machine->playback_file = NULL; | |
| 1470 | machine->portconfig = NULL; | |
| 1473 | 1471 | |
| 1474 | 1472 | /* debugger-related information */ |
| 1475 | 1473 | #ifdef ENABLE_DEBUGGER |
| r2724 | r2725 | |
| 1598 | 1596 | #endif |
| 1599 | 1597 | |
| 1600 | 1598 | /* call the driver's _START callbacks */ |
| 1601 | if (machine->config->machine_start != NULL) (*machine->config->machine_start)(machine); | |
| 1602 | if (machine->config->sound_start != NULL) (*machine->config->sound_start)(machine); | |
| 1603 | if (machine->config->video_start != NULL) (*machine->config->video_start)(machine); | |
| 1599 | if (machine->config->machine_start != NULL) | |
| 1600 | (*machine->config->machine_start)(machine); | |
| 1601 | if (machine->config->sound_start != NULL) | |
| 1602 | (*machine->config->sound_start)(machine); | |
| 1603 | if (machine->config->video_start != NULL) | |
| 1604 | (*machine->config->video_start)(machine); | |
| 1604 | 1605 | |
| 1605 | 1606 | /* free memory regions allocated with REGIONFLAG_DISPOSE (typically gfx roms) */ |
| 1606 | 1607 | for (num = 0; num < MAX_MEMORY_REGIONS; num++) |
| r2724 | r2725 | |
| 1895 | 1896 | } |
| 1896 | 1897 | |
| 1897 | 1898 | |
| 1898 | ||
| 1899 | 1899 | /*------------------------------------------------- |
| 1900 | 1900 | fill_systime - fills out a mame_system_time |
| 1901 | 1901 | structure |
| r2724 | r2725 | |
| 1909 | 1909 | } |
| 1910 | 1910 | |
| 1911 | 1911 | |
| 1912 | ||
| 1913 | 1912 | /*------------------------------------------------- |
| 1914 | 1913 | mame_get_base_datetime - retrieve the time of |
| 1915 | 1914 | the host system; useful for RTC implementations |
| r2724 | r2725 | |
| 1922 | 1921 | } |
| 1923 | 1922 | |
| 1924 | 1923 | |
| 1925 | ||
| 1926 | 1924 | /*------------------------------------------------- |
| 1927 | 1925 | mame_get_current_datetime - retrieve the current |
| 1928 | 1926 | time (offsetted by the baes); useful for RTC |
| r2724 | r2725 | |
|---|---|---|
| 130 | 130 | TYPE DEFINITIONS |
| 131 | 131 | ***************************************************************************/ |
| 132 | 132 | |
| 133 | typedef struct _analog_port_info analog_port_info; | |
| 134 | struct _analog_port_info | |
| 133 | /* live analog field information */ | |
| 134 | typedef struct _analog_field_state analog_field_state; | |
| 135 | struct _analog_field_state | |
| 135 | 136 | { |
| 136 | analog_port_info * next; /* linked list */ | |
| 137 | input_port_entry * portentry; /* pointer to the input port entry referenced */ | |
| 138 | INT32 accum; /* accumulated value (including relative adjustments) */ | |
| 139 | INT32 previous; /* previous adjusted value */ | |
| 140 | INT32 previousanalog; /* previous analog value */ | |
| 141 | INT32 minimum; /* minimum adjusted value */ | |
| 142 | INT32 maximum; /* maximum adjusted value */ | |
| 143 | INT32 center; /* center adjusted value for autocentering */ | |
| 144 | INT32 reverse_val; /* value where we subtract from to reverse directions */ | |
| 145 | INT64 scalepos; /* scale factor to apply to positive adjusted values */ | |
| 146 | INT64 scaleneg; /* scale factor to apply to negative adjusted values */ | |
| 147 | INT64 keyscalepos; /* scale factor to apply to the key delta field when pos */ | |
| 148 | INT64 keyscaleneg; /* scale factor to apply to the key delta field when neg */ | |
| 149 | INT64 positionalscale; /* scale factor to divide a joystick into positions */ | |
| 150 | UINT8 shift; /* left shift to apply to the final result */ | |
| 151 | UINT8 bits; /* how many bits of resolution are expected? */ | |
| 152 | UINT8 absolute; /* is this an absolute or relative input? */ | |
| 153 | UINT8 wraps; /* does the control wrap around? */ | |
| 154 | UINT8 one_of_x; /* is this a 1 of X positional input? */ | |
| 155 | UINT8 autocenter; /* autocenter this input? */ | |
| 156 | UINT8 single_scale; /* scale joystick differently if default is between min/max */ | |
| 157 | UINT8 interpolate; /* should we do linear interpolation for mid-frame reads? */ | |
| 158 | UINT8 lastdigital; /* was the last modification caused by a digital form? */ | |
| 137 | analog_field_state * next; /* link to the next analog state for this port */ | |
| 138 | const input_field_config * field; /* pointer to the input field referenced */ | |
| 139 | ||
| 140 | /* adjusted values (right-justified and tweaked) */ | |
| 141 | UINT8 shift; /* shift to align final value in the port */ | |
| 142 | INT32 adjdefvalue; /* adjusted default value from the config */ | |
| 143 | INT32 adjmin; /* adjusted minimum value from the config */ | |
| 144 | INT32 adjmax; /* adjusted maximum value from the config */ | |
| 145 | ||
| 146 | /* live values of configurable parameters */ | |
| 147 | INT32 sensitivity; /* current live sensitivity (100=normal) */ | |
| 148 | UINT8 reverse; /* current live reverse flag */ | |
| 149 | INT32 delta; /* current live delta to apply each frame a digital inc/dec key is pressed */ | |
| 150 | INT32 centerdelta; /* current live delta to apply each frame no digital inputs are pressed */ | |
| 151 | ||
| 152 | /* live analog value tracking */ | |
| 153 | INT32 accum; /* accumulated value (including relative adjustments) */ | |
| 154 | INT32 previous; /* previous adjusted value */ | |
| 155 | INT32 previousanalog; /* previous analog value */ | |
| 156 | ||
| 157 | /* parameters for modifying live values */ | |
| 158 | INT32 minimum; /* minimum adjusted value */ | |
| 159 | INT32 maximum; /* maximum adjusted value */ | |
| 160 | INT32 center; /* center adjusted value for autocentering */ | |
| 161 | INT32 reverse_val; /* value where we subtract from to reverse directions */ | |
| 162 | ||
| 163 | /* scaling factors */ | |
| 164 | INT64 scalepos; /* scale factor to apply to positive adjusted values */ | |
| 165 | INT64 scaleneg; /* scale factor to apply to negative adjusted values */ | |
| 166 | INT64 keyscalepos; /* scale factor to apply to the key delta field when pos */ | |
| 167 | INT64 keyscaleneg; /* scale factor to apply to the key delta field when neg */ | |
| 168 | INT64 positionalscale; /* scale factor to divide a joystick into positions */ | |
| 169 | ||
| 170 | /* misc flags */ | |
| 171 | UINT8 absolute; /* is this an absolute or relative input? */ | |
| 172 | UINT8 wraps; /* does the control wrap around? */ | |
| 173 | UINT8 autocenter; /* autocenter this input? */ | |
| 174 | UINT8 single_scale; /* scale joystick differently if default is between min/max */ | |
| 175 | UINT8 interpolate; /* should we do linear interpolation for mid-frame reads? */ | |
| 176 | UINT8 lastdigital; /* was the last modification caused by a digital form? */ | |
| 159 | 177 | }; |
| 160 | 178 | |
| 161 | 179 | |
| 162 | typedef struct _custom_port_info custom_port_info; | |
| 163 | struct _custom_port_info | |
| 180 | /* shared digital joystick state */ | |
| 181 | typedef struct _digital_joystick_state digital_joystick_state; | |
| 182 | struct _digital_joystick_state | |
| 164 | 183 | { |
| 165 | custom_port_info * next; /* linked list */ | |
| 166 | input_port_entry * portentry; /* pointer to the input port entry referenced */ | |
| 167 | UINT8 shift; /* left shift to apply to the final result */ | |
| 184 | const input_field_config * field[4]; /* input field for up, down, left, right respectively */ | |
| 185 | UINT8 inuse; /* is this joystick used? */ | |
| 186 | UINT8 current; /* current value */ | |
| 187 | UINT8 current4way; /* current 4-way value */ | |
| 188 | UINT8 previous; /* previous value */ | |
| 168 | 189 | }; |
| 169 | 190 | |
| 170 | 191 | |
| 171 | typedef struct _changed_port_info changed_port_info; | |
| 172 | struct _changed_port_info | |
| 192 | /* live custom/changed field information */ | |
| 193 | typedef struct _callback_field_info callback_field_info; | |
| 194 | struct _callback_field_info | |
| 173 | 195 | { |
| 174 | changed_port_info * next; /* linked list */ | |
| 175 | input_port_entry * portentry; /* pointer to the input port entry referenced */ | |
| 176 | UINT8 shift; /* right shift to apply before calling callback */ | |
| 196 | callback_field_info * next; /* linked list of info for this port */ | |
| 197 | const input_field_config * field; /* pointer to the input field referenced */ | |
| 198 | UINT8 shift; /* shift to apply to the final result */ | |
| 177 | 199 | }; |
| 178 | 200 | |
| 179 | 201 | |
| 180 | typedef struct _input_bit_info input_bit_info; | |
| 181 | struct _input_bit_info | |
| 202 | /* internal live state of an input field */ | |
| 203 | struct _input_field_state | |
| 182 | 204 | { |
| 183 | input_port_entry * portentry; /* port entry for this input */ | |
| 184 | UINT8 impulse; /* counter for impulse controls */ | |
| 185 | UINT8 last; /* were we pressed last time? */ | |
| 205 | analog_field_state * analog; /* pointer to live analog data if this is an analog field */ | |
| 206 | digital_joystick_state * joystick; /* pointer to digital joystick information */ | |
| 207 | input_seq seq[SEQ_TYPE_TOTAL];/* currently configured input sequences */ | |
| 208 | input_port_value value; /* current value of this port */ | |
| 209 | UINT8 impulse; /* counter for impulse controls */ | |
| 210 | UINT8 last; /* were we pressed last time? */ | |
| 211 | UINT8 toggle; /* current toggle state */ | |
| 212 | UINT8 joydir; /* digital joystick direction index */ | |
| 186 | 213 | }; |
| 187 | 214 | |
| 188 | 215 | |
| 189 | typedef struct _input_port_info input_port_info; | |
| 190 | struct _input_port_info | |
| 216 | /* internal live state of an input port */ | |
| 217 | struct _input_port_state | |
| 191 | 218 | { |
| 192 | const char * tag; /* tag for this port */ | |
| 193 | UINT32 defvalue; /* default value of all the bits */ | |
| 194 | UINT32 digital; /* value from digital inputs */ | |
| 195 | UINT32 vblank; /* value of all IPT_VBLANK bits */ | |
| 196 | input_bit_info bit[MAX_BITS_PER_PORT]; /* info about each bit in the port */ | |
| 197 | analog_port_info * analoginfo; /* pointer to linked list of analog port info */ | |
| 198 | custom_port_info * custominfo; /* pointer to linked list of custom port info */ | |
| 199 | changed_port_info * changedinfo; /* pointer to linked list of changed port info */ | |
| 219 | analog_field_state * analoglist; /* pointer to list of analog port info */ | |
| 220 | callback_field_info * customlist; /* pointer to list of custom port info */ | |
| 221 | callback_field_info * changedlist; /* pointer to list of changed port info */ | |
| 222 | input_port_value defvalue; /* combined default value across the port */ | |
| 223 | input_port_value digital; /* current value from all digital inputs */ | |
| 224 | input_port_value vblank; /* value of all IPT_VBLANK bits */ | |
| 225 | input_port_value lastvalue; /* last value of the port, to detect changes */ | |
| 200 | 226 | }; |
| 201 | 227 | |
| 202 | 228 | |
| 203 | typedef struct _digital_joystick_info digital_joystick_info; | |
| 204 | struct _digital_joystick_info | |
| 229 | /* internal live state of an input type */ | |
| 230 | typedef struct _input_type_state input_type_state; | |
| 231 | struct _input_type_state | |
| 205 | 232 | { |
| 206 | input_port_entry * portentry[4]; /* port entry for up,down,left,right respectively */ | |
| 207 | UINT8 inuse; /* is this joystick used? */ | |
| 208 | UINT8 current; /* current value */ | |
| 209 | UINT8 current4way; /* current 4-way value */ | |
| 210 | UINT8 previous; /* previous value */ | |
| 233 | input_type_state * next; /* pointer to the next live state in the list */ | |
| 234 | input_type_desc typedesc; /* copy of the original description, modified by the OSD */ | |
| 235 | input_seq seq[SEQ_TYPE_TOTAL];/* currently configured sequences */ | |
| 211 | 236 | }; |
| 212 | 237 | |
| 213 | 238 | |
| 214 | struct _input_port_init_params | |
| 239 | /* private input port state */ | |
| 240 | struct _input_port_private | |
| 215 | 241 | { |
| 216 | input_port_entry * ports; /* base of the port array */ | |
| 217 | int max_ports; /* maximum number of ports we can support */ | |
| 218 | int current_port; /* current port index */ | |
| 242 | /* types */ | |
| 243 | input_type_state * typestatelist; /* list of live type states */ | |
| 244 | input_type_state * type_to_typestate[__ipt_max][MAX_PLAYERS]; /* map from type/player to type state */ | |
| 245 | ||
| 246 | /* specific special global input states */ | |
| 247 | digital_joystick_state joystick_info[MAX_PLAYERS][DIGITAL_JOYSTICKS_PER_PLAYER]; /* joystick states */ | |
| 248 | osd_ticks_t ui_memory[__ipt_max];/* keypress timing for UI */ | |
| 249 | ||
| 250 | /* frame time tracking */ | |
| 251 | attotime last_frame_time; /* time of the last frame callback */ | |
| 252 | attoseconds_t last_delta_nsec; /* nanoseconds that passed since the previous callback */ | |
| 253 | ||
| 254 | /* playback/record information */ | |
| 255 | mame_file * record_file; /* recording file (NULL if not recording) */ | |
| 256 | mame_file * playback_file; /* playback file (NULL if not recording) */ | |
| 257 | UINT64 playback_accumulated_speed;/* accumulated speed during playback */ | |
| 258 | UINT32 playback_accumulated_frames;/* accumulated frames during playback */ | |
| 219 | 259 | }; |
| 220 | 260 | |
| 221 | 261 | |
| r2724 | r2725 | |
| 224 | 264 | MACROS |
| 225 | 265 | ***************************************************************************/ |
| 226 | 266 | |
| 227 | #define IS_ANALOG(in) ((in)->type >= __ipt_analog_start && (in)->type <= __ipt_analog_end) | |
| 228 | #define IS_DIGITAL_JOYSTICK(in) ((in)->type >= __ipt_digital_joystick_start && (in)->type <= __ipt_digital_joystick_end) | |
| 229 | #define JOYSTICK_INFO_FOR_PORT(in) (&joystick_info[(in)->player][((in)->type - __ipt_digital_joystick_start) / 4]) | |
| 230 | #define JOYSTICK_DIR_FOR_PORT(in) (((in)->type - __ipt_digital_joystick_start) % 4) | |
| 231 | ||
| 232 | 267 | #define APPLY_SENSITIVITY(x,s) (((INT64)(x) * (s)) / 100) |
| 233 | 268 | #define APPLY_INVERSE_SENSITIVITY(x,s) (((INT64)(x) * 100) / (s)) |
| 234 | 269 | |
| r2724 | r2725 | |
| 242 | 277 | GLOBAL VARIABLES |
| 243 | 278 | ***************************************************************************/ |
| 244 | 279 | |
| 245 | /* current value of all the ports */ | |
| 246 | static input_port_info port_info[MAX_INPUT_PORTS]; | |
| 247 | ||
| 248 | /* additiona tracking information for special types of controls */ | |
| 249 | static digital_joystick_info joystick_info[MAX_PLAYERS][DIGITAL_JOYSTICKS_PER_PLAYER]; | |
| 250 | ||
| 251 | /* memory for UI keys */ | |
| 252 | static UINT8 ui_memory[__ipt_max]; | |
| 253 | ||
| 254 | 280 | /* XML attributes for the different types */ |
| 255 | 281 | static const char *const seqtypestrings[] = { "standard", "decrement", "increment" }; |
| 256 | 282 | |
| 257 | /* original input_ports without modifications */ | |
| 258 | static input_port_entry *input_ports_default; | |
| 259 | 283 | |
| 260 | /* for scaling analog ports */ | |
| 261 | static attotime last_update; | |
| 262 | static attoseconds_t last_delta; | |
| 263 | 284 | |
| 264 | /* playback information */ | |
| 265 | static UINT64 playback_accumulated_speed; | |
| 266 | static UINT32 playback_accumulated_frames; | |
| 267 | ||
| 268 | ||
| 269 | ||
| 270 | 285 | /*************************************************************************** |
| 271 | 286 | PORT HANDLER TABLES |
| 272 | 287 | ***************************************************************************/ |
| r2724 | r2725 | |
| 434 | 449 | |
| 435 | 450 | |
| 436 | 451 | /*************************************************************************** |
| 437 | | |
| 452 | B | |
| 438 | 453 | ***************************************************************************/ |
| 439 | 454 | |
| 440 | #define INPUT_PORT_DIGITAL_DEF(player_,group_,type_,name_,seq_) \ | |
| 441 | { IPT_##type_, group_, (player_ == 0) ? player_ : (player_) - 1, (player_ == 0) ? #type_ : ("P" #player_ "_" #type_), name_, seq_, SEQ_DEF_0, SEQ_DEF_0 }, | |
| 455 | #include "inpttype.h" | |
| 442 | 456 | |
| 443 | #define INPUT_PORT_ANALOG_DEF(player_,group_,type_,name_,seq_,decseq_,incseq_) \ | |
| 444 | { IPT_##type_, group_, (player_ == 0) ? player_ : (player_) - 1, (player_ == 0) ? #type_ : ("P" #player_ "_" #type_), name_, seq_, incseq_, decseq_ }, | |
| 445 | 457 | |
| 446 | #define INDEXED(a,b) INPUT_CODE_SET_DEVINDEX(a,b) | |
| 447 | 458 | |
| 448 | static const input_port_default_entry default_ports_builtin[] = | |
| 459 | /*************************************************************************** | |
| 460 | FUNCTION PROTOTYPES | |
| 461 | ***************************************************************************/ | |
| 462 | ||
| 463 | /* core system management */ | |
| 464 | static void input_port_exit(running_machine *machine); | |
| 465 | ||
| 466 | /* port reading */ | |
| 467 | static INT32 apply_analog_settings(INT32 current, analog_field_state *analog); | |
| 468 | ||
| 469 | /* initialization helpers */ | |
| 470 | static void init_port_types(running_machine *machine); | |
| 471 | static void init_port_state(running_machine *machine); | |
| 472 | static void init_autoselect_devices(const input_port_config *portlist, int type1, int type2, int type3, const char *option, const char *ananame); | |
| 473 | static callback_field_info *init_field_callback_info(const input_field_config *field); | |
| 474 | static analog_field_state *init_field_analog_state(const input_field_config *field); | |
| 475 | ||
| 476 | /* once-per-frame updates */ | |
| 477 | static void frame_update_callback(running_machine *machine); | |
| 478 | static void frame_update(running_machine *machine); | |
| 479 | static void frame_update_digital_joysticks(running_machine *machine); | |
| 480 | static void frame_update_analog_field(analog_field_state *analog); | |
| 481 | static int frame_get_digital_field_state(const input_field_config *field); | |
| 482 | ||
| 483 | /* port configuration helpers */ | |
| 484 | static input_port_config *port_config_detokenize(input_port_config *listhead, const input_port_token *ipt); | |
| 485 | static input_port_config *port_config_alloc(const input_port_config **listhead); | |
| 486 | static void port_config_free(const input_port_config **portptr); | |
| 487 | static input_port_config *port_config_find(const input_port_config *listhead, const char *tag); | |
| 488 | static input_field_config *field_config_alloc(input_port_config *port, int type, input_port_value defvalue, input_port_value maskbits); | |
| 489 | static void field_config_free(input_field_config **fieldptr); | |
| 490 | static input_setting_config *setting_config_alloc(input_field_config *field, input_port_value value, const char *name); | |
| 491 | static void setting_config_free(input_setting_config **settingptr); | |
| 492 | static const input_field_diplocation *diplocation_list_alloc(const input_field_config *field, const char *location); | |
| 493 | static void diplocation_free(input_field_diplocation **diplocptr); | |
| 494 | ||
| 495 | /* tokenization helpers */ | |
| 496 | static int token_to_input_field_type(running_machine *machine, const char *string, int *player); | |
| 497 | static const char *input_field_type_to_token(running_machine *machine, int type, int player); | |
| 498 | static int token_to_seq_type(const char *string); | |
| 499 | ||
| 500 | /* settings load */ | |
| 501 | static void load_config_callback(running_machine *machine, int config_type, xml_data_node *parentnode); | |
| 502 | static void load_remap_table(running_machine *machine, xml_data_node *parentnode); | |
| 503 | static int load_default_config(running_machine *machine, xml_data_node *portnode, int type, int player, const input_seq *newseq); | |
| 504 | static int load_game_config(running_machine *machine, xml_data_node *portnode, int type, int player, const input_seq *newseq); | |
| 505 | ||
| 506 | /* settings save */ | |
| 507 | static void save_config_callback(running_machine *machine, int config_type, xml_data_node *parentnode); | |
| 508 | static void save_sequence(xml_data_node *parentnode, int type, int porttype, const input_seq *seq); | |
| 509 | static int save_this_input_field_type(int type); | |
| 510 | static void save_default_inputs(running_machine *machine, xml_data_node *parentnode); | |
| 511 | static void save_game_inputs(running_machine *machine, xml_data_node *parentnode); | |
| 512 | ||
| 513 | /* input playback */ | |
| 514 | static time_t playback_init(running_machine *machine); | |
| 515 | static void playback_end(running_machine *machine, const char *message); | |
| 516 | static void playback_frame(running_machine *machine, attotime curtime); | |
| 517 | static void playback_port(const input_port_config *port); | |
| 518 | ||
| 519 | /* input recording */ | |
| 520 | static void record_init(running_machine *machine); | |
| 521 | static void record_end(running_machine *machine, const char *message); | |
| 522 | static void record_frame(running_machine *machine, attotime curtime); | |
| 523 | static void record_port(const input_port_config *port); | |
| 524 | ||
| 525 | ||
| 526 | ||
| 527 | /*************************************************************************** | |
| 528 | INLINE FUNCTIONS | |
| 529 | ***************************************************************************/ | |
| 530 | ||
| 531 | /*------------------------------------------------- | |
| 532 | apply_analog_min_max - clamp the given input | |
| 533 | value to the appropriate min/max for the | |
| 534 | analog control | |
| 535 | -------------------------------------------------*/ | |
| 536 | ||
| 537 | INLINE INT32 apply_analog_min_max(const analog_field_state *analog, INT32 value) | |
| 449 | 538 | { |
| 450 | INPUT_PORT_DIGITAL_DEF( 1, IPG_PLAYER1, JOYSTICK_UP, "P1 Up", SEQ_DEF_3(KEYCODE_UP, SEQCODE_OR, INDEXED(JOYCODE_Y_UP_SWITCH, 0)) ) | |
| 451 | INPUT_PORT_DIGITAL_DEF( 1, IPG_PLAYER1, JOYSTICK_DOWN, "P1 Down", SEQ_DEF_3(KEYCODE_DOWN, SEQCODE_OR, INDEXED(JOYCODE_Y_DOWN_SWITCH, 0)) ) | |
| 452 | INPUT_PORT_DIGITAL_DEF( 1, IPG_PLAYER1, JOYSTICK_LEFT, "P1 Left", SEQ_DEF_3(KEYCODE_LEFT, SEQCODE_OR, INDEXED(JOYCODE_X_LEFT_SWITCH, 0)) ) | |
| 453 | INPUT_PORT_DIGITAL_DEF( 1, IPG_PLAYER1, JOYSTICK_RIGHT, "P1 Right", SEQ_DEF_3(KEYCODE_RIGHT, SEQCODE_OR, INDEXED(JOYCODE_X_RIGHT_SWITCH, 0)) ) | |
| 454 | INPUT_PORT_DIGITAL_DEF( 1, IPG_PLAYER1, JOYSTICKRIGHT_UP, "P1 Right/Up", SEQ_DEF_3(KEYCODE_I, SEQCODE_OR, INDEXED(JOYCODE_BUTTON2, 0)) ) | |
| 455 | INPUT_PORT_DIGITAL_DEF( 1, IPG_PLAYER1, JOYSTICKRIGHT_DOWN, "P1 Right/Down", SEQ_DEF_3(KEYCODE_K, SEQCODE_OR, INDEXED(JOYCODE_BUTTON3, 0)) ) | |
| 456 | INPUT_PORT_DIGITAL_DEF( 1, IPG_PLAYER1, JOYSTICKRIGHT_LEFT, "P1 Right/Left", SEQ_DEF_3(KEYCODE_J, SEQCODE_OR, INDEXED(JOYCODE_BUTTON1, 0)) ) | |
| 457 | INPUT_PORT_DIGITAL_DEF( 1, IPG_PLAYER1, JOYSTICKRIGHT_RIGHT,"P1 Right/Right", SEQ_DEF_3(KEYCODE_L, SEQCODE_OR, INDEXED(JOYCODE_BUTTON4, 0)) ) | |
| 458 | INPUT_PORT_DIGITAL_DEF( 1, IPG_PLAYER1, JOYSTICKLEFT_UP, "P1 Left/Up", SEQ_DEF_3(KEYCODE_E, SEQCODE_OR, INDEXED(JOYCODE_Y_UP_SWITCH, 0)) ) | |
| 459 | INPUT_PORT_DIGITAL_DEF( 1, IPG_PLAYER1, JOYSTICKLEFT_DOWN, "P1 Left/Down", SEQ_DEF_3(KEYCODE_D, SEQCODE_OR, INDEXED(JOYCODE_Y_DOWN_SWITCH, 0)) ) | |
| 460 | INPUT_PORT_DIGITAL_DEF( 1, IPG_PLAYER1, JOYSTICKLEFT_LEFT, "P1 Left/Left", SEQ_DEF_3(KEYCODE_S, SEQCODE_OR, INDEXED(JOYCODE_X_LEFT_SWITCH, 0)) ) | |
| 461 | INPUT_PORT_DIGITAL_DEF( 1, IPG_PLAYER1, JOYSTICKLEFT_RIGHT, "P1 Left/Right", SEQ_DEF_3(KEYCODE_F, SEQCODE_OR, INDEXED(JOYCODE_X_RIGHT_SWITCH, 0)) ) | |
| 462 | INPUT_PORT_DIGITAL_DEF( 1, IPG_PLAYER1, BUTTON1, "P1 Button 1", SEQ_DEF_7(KEYCODE_LCONTROL, SEQCODE_OR, INDEXED(JOYCODE_BUTTON1, 0), SEQCODE_OR, INDEXED(MOUSECODE_BUTTON1, 0), SEQCODE_OR, INDEXED(GUNCODE_BUTTON1, 0)) ) | |
| 463 | INPUT_PORT_DIGITAL_DEF( 1, IPG_PLAYER1, BUTTON2, "P1 Button 2", SEQ_DEF_7(KEYCODE_LALT, SEQCODE_OR, INDEXED(JOYCODE_BUTTON2, 0), SEQCODE_OR, INDEXED(MOUSECODE_BUTTON3, 0), SEQCODE_OR, INDEXED(GUNCODE_BUTTON2, 0)) ) | |
| 464 | INPUT_PORT_DIGITAL_DEF( 1, IPG_PLAYER1, BUTTON3, "P1 Button 3", SEQ_DEF_5(KEYCODE_SPACE, SEQCODE_OR, INDEXED(JOYCODE_BUTTON3, 0), SEQCODE_OR, INDEXED(MOUSECODE_BUTTON2, 0)) ) | |
| 465 | INPUT_PORT_DIGITAL_DEF( 1, IPG_PLAYER1, BUTTON4, "P1 Button 4", SEQ_DEF_3(KEYCODE_LSHIFT, SEQCODE_OR, INDEXED(JOYCODE_BUTTON4, 0)) ) | |
| 466 | INPUT_PORT_DIGITAL_DEF( 1, IPG_PLAYER1, BUTTON5, "P1 Button 5", SEQ_DEF_3(KEYCODE_Z, SEQCODE_OR, INDEXED(JOYCODE_BUTTON5, 0)) ) | |
| 467 | INPUT_PORT_DIGITAL_DEF( 1, IPG_PLAYER1, BUTTON6, "P1 Button 6", SEQ_DEF_3(KEYCODE_X, SEQCODE_OR, INDEXED(JOYCODE_BUTTON6, 0)) ) | |
| 468 | INPUT_PORT_DIGITAL_DEF( 1, IPG_PLAYER1, BUTTON7, "P1 Button 7", SEQ_DEF_3(KEYCODE_C, SEQCODE_OR, INDEXED(JOYCODE_BUTTON7, 0)) ) | |
| 469 | INPUT_PORT_DIGITAL_DEF( 1, IPG_PLAYER1, BUTTON8, "P1 Button 8", SEQ_DEF_3(KEYCODE_V, SEQCODE_OR, INDEXED(JOYCODE_BUTTON8, 0)) ) | |
| 470 | INPUT_PORT_DIGITAL_DEF( 1, IPG_PLAYER1, BUTTON9, "P1 Button 9", SEQ_DEF_3(KEYCODE_B, SEQCODE_OR, INDEXED(JOYCODE_BUTTON9, 0)) ) | |
| 471 | INPUT_PORT_DIGITAL_DEF( 1, IPG_PLAYER1, BUTTON10, "P1 Button 10", SEQ_DEF_3(KEYCODE_N, SEQCODE_OR, INDEXED(JOYCODE_BUTTON10, 0)) ) | |
| 472 | INPUT_PORT_DIGITAL_DEF( 1, IPG_PLAYER1, BUTTON11, "P1 Button 11", SEQ_DEF_3(KEYCODE_M, SEQCODE_OR, INDEXED(JOYCODE_BUTTON11, 0)) ) | |
| 473 | INPUT_PORT_DIGITAL_DEF( 1, IPG_PLAYER1, BUTTON12, "P1 Button 12", SEQ_DEF_3(KEYCODE_COMMA, SEQCODE_OR, INDEXED(JOYCODE_BUTTON12, 0)) ) | |
| 474 | INPUT_PORT_DIGITAL_DEF( 1, IPG_PLAYER1, BUTTON13, "P1 Button 13", SEQ_DEF_3(KEYCODE_STOP, SEQCODE_OR, INDEXED(JOYCODE_BUTTON13, 0)) ) | |
| 475 | INPUT_PORT_DIGITAL_DEF( 1, IPG_PLAYER1, BUTTON14, "P1 Button 14", SEQ_DEF_3(KEYCODE_SLASH, SEQCODE_OR, INDEXED(JOYCODE_BUTTON14, 0)) ) | |
| 476 | INPUT_PORT_DIGITAL_DEF( 1, IPG_PLAYER1, BUTTON15, "P1 Button 15", SEQ_DEF_3(KEYCODE_RSHIFT, SEQCODE_OR, INDEXED(JOYCODE_BUTTON15, 0)) ) | |
| 477 | INPUT_PORT_DIGITAL_DEF( 1, IPG_PLAYER1, BUTTON16, "P1 Button 16", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON16, 0)) ) | |
| 478 | INPUT_PORT_DIGITAL_DEF( 1, IPG_PLAYER1, START, "P1 Start", SEQ_DEF_3(KEYCODE_1, SEQCODE_OR, INDEXED(JOYCODE_START, 0)) ) | |
| 479 | INPUT_PORT_DIGITAL_DEF( 1, IPG_PLAYER1, SELECT, "P1 Select", SEQ_DEF_3(KEYCODE_5, SEQCODE_OR, INDEXED(JOYCODE_SELECT, 0)) ) | |
| 480 | INPUT_PORT_DIGITAL_DEF( 1, IPG_PLAYER1, MAHJONG_A, "P1 Mahjong A", SEQ_DEF_1(KEYCODE_A) ) | |
| 481 | INPUT_PORT_DIGITAL_DEF( 1, IPG_PLAYER1, MAHJONG_B, "P1 Mahjong B", SEQ_DEF_1(KEYCODE_B) ) | |
| 482 | INPUT_PORT_DIGITAL_DEF( 1, IPG_PLAYER1, MAHJONG_C, "P1 Mahjong C", SEQ_DEF_1(KEYCODE_C) ) | |
| 483 | INPUT_PORT_DIGITAL_DEF( 1, IPG_PLAYER1, MAHJONG_D, "P1 Mahjong D", SEQ_DEF_1(KEYCODE_D) ) | |
| 484 | INPUT_PORT_DIGITAL_DEF( 1, IPG_PLAYER1, MAHJONG_E, "P1 Mahjong E", SEQ_DEF_1(KEYCODE_E) ) | |
| 485 | INPUT_PORT_DIGITAL_DEF( 1, IPG_PLAYER1, MAHJONG_F, "P1 Mahjong F", SEQ_DEF_1(KEYCODE_F) ) | |
| 486 | INPUT_PORT_DIGITAL_DEF( 1, IPG_PLAYER1, MAHJONG_G, "P1 Mahjong G", SEQ_DEF_1(KEYCODE_G) ) | |
| 487 | INPUT_PORT_DIGITAL_DEF( 1, IPG_PLAYER1, MAHJONG_H, "P1 Mahjong H", SEQ_DEF_1(KEYCODE_H) ) | |
| 488 | INPUT_PORT_DIGITAL_DEF( 1, IPG_PLAYER1, MAHJONG_I, "P1 Mahjong I", SEQ_DEF_1(KEYCODE_I) ) | |
| 489 | INPUT_PORT_DIGITAL_DEF( 1, IPG_PLAYER1, MAHJONG_J, "P1 Mahjong J", SEQ_DEF_1(KEYCODE_J) ) | |
| 490 | INPUT_PORT_DIGITAL_DEF( 1, IPG_PLAYER1, MAHJONG_K, "P1 Mahjong K", SEQ_DEF_1(KEYCODE_K) ) | |
| 491 | INPUT_PORT_DIGITAL_DEF( 1, IPG_PLAYER1, MAHJONG_L, "P1 Mahjong L", SEQ_DEF_1(KEYCODE_L) ) | |
| 492 | INPUT_PORT_DIGITAL_DEF( 1, IPG_PLAYER1, MAHJONG_M, "P1 Mahjong M", SEQ_DEF_1(KEYCODE_M) ) | |
| 493 | INPUT_PORT_DIGITAL_DEF( 1, IPG_PLAYER1, MAHJONG_N, "P1 Mahjong N", SEQ_DEF_1(KEYCODE_N) ) | |
| 494 | INPUT_PORT_DIGITAL_DEF( 1, IPG_PLAYER1, MAHJONG_O, "P1 Mahjong O", SEQ_DEF_1(KEYCODE_O) ) | |
| 495 | INPUT_PORT_DIGITAL_DEF( 1, IPG_PLAYER1, MAHJONG_P, "P1 Mahjong P", SEQ_DEF_1(KEYCODE_COLON) ) | |
| 496 | INPUT_PORT_DIGITAL_DEF( 1, IPG_PLAYER1, MAHJONG_Q, "P1 Mahjong Q", SEQ_DEF_1(KEYCODE_Q) ) | |
| 497 | INPUT_PORT_DIGITAL_DEF( 1, IPG_PLAYER1, MAHJONG_KAN, "P1 Mahjong Kan", SEQ_DEF_1(KEYCODE_LCONTROL) ) | |
| 498 | INPUT_PORT_DIGITAL_DEF( 1, IPG_PLAYER1, MAHJONG_PON, "P1 Mahjong Pon", SEQ_DEF_1(KEYCODE_LALT) ) | |
| 499 | INPUT_PORT_DIGITAL_DEF( 1, IPG_PLAYER1, MAHJONG_CHI, "P1 Mahjong Chi", SEQ_DEF_1(KEYCODE_SPACE) ) | |
| 500 | INPUT_PORT_DIGITAL_DEF( 1, IPG_PLAYER1, MAHJONG_REACH, "P1 Mahjong Reach", SEQ_DEF_1(KEYCODE_LSHIFT) ) | |
| 501 | INPUT_PORT_DIGITAL_DEF( 1, IPG_PLAYER1, MAHJONG_RON, "P1 Mahjong Ron", SEQ_DEF_1(KEYCODE_Z) ) | |
| 502 | INPUT_PORT_DIGITAL_DEF( 1, IPG_PLAYER1, MAHJONG_BET, "P1 Mahjong Bet", SEQ_DEF_1(KEYCODE_2) ) | |
| 503 | INPUT_PORT_DIGITAL_DEF( 1, IPG_PLAYER1, MAHJONG_LAST_CHANCE,"P1 Mahjong Last Chance",SEQ_DEF_1(KEYCODE_RALT) ) | |
| 504 | INPUT_PORT_DIGITAL_DEF( 1, IPG_PLAYER1, MAHJONG_SCORE, "P1 Mahjong Score", SEQ_DEF_1(KEYCODE_RCONTROL) ) | |
| 505 | INPUT_PORT_DIGITAL_DEF( 1, IPG_PLAYER1, MAHJONG_DOUBLE_UP, "P1 Mahjong Double Up", SEQ_DEF_1(KEYCODE_RSHIFT) ) | |
| 506 | INPUT_PORT_DIGITAL_DEF( 1, IPG_PLAYER1, MAHJONG_FLIP_FLOP, "P1 Mahjong Flip Flop", SEQ_DEF_1(KEYCODE_Y) ) | |
| 507 | INPUT_PORT_DIGITAL_DEF( 1, IPG_PLAYER1, MAHJONG_BIG, "P1 Mahjong Big", SEQ_DEF_1(KEYCODE_ENTER) ) | |
| 508 | INPUT_PORT_DIGITAL_DEF( 1, IPG_PLAYER1, MAHJONG_SMALL, "P1 Mahjong Small", SEQ_DEF_1(KEYCODE_BACKSPACE) ) | |
| 539 | /* take the analog minimum and maximum values and apply the inverse of the */ | |
| 540 | /* sensitivity so that we can clamp against them before applying sensitivity */ | |
| 541 | INT32 adjmin = APPLY_INVERSE_SENSITIVITY(analog->minimum, analog->sensitivity); | |
| 542 | INT32 adjmax = APPLY_INVERSE_SENSITIVITY(analog->maximum, analog->sensitivity); | |
| 509 | 543 | |
| 510 | INPUT_PORT_DIGITAL_DEF( 2, IPG_PLAYER2, JOYSTICK_UP, "P2 Up", SEQ_DEF_3(KEYCODE_R, SEQCODE_OR, INDEXED(JOYCODE_Y_UP_SWITCH, 1)) ) | |
| 511 | INPUT_PORT_DIGITAL_DEF( 2, IPG_PLAYER2, JOYSTICK_DOWN, "P2 Down", SEQ_DEF_3(KEYCODE_F, SEQCODE_OR, INDEXED(JOYCODE_Y_DOWN_SWITCH, 1)) ) | |
| 512 | INPUT_PORT_DIGITAL_DEF( 2, IPG_PLAYER2, JOYSTICK_LEFT, "P2 Left", SEQ_DEF_3(KEYCODE_D, SEQCODE_OR, INDEXED(JOYCODE_X_LEFT_SWITCH, 1)) ) | |
| 513 | INPUT_PORT_DIGITAL_DEF( 2, IPG_PLAYER2, JOYSTICK_RIGHT, "P2 Right", SEQ_DEF_3(KEYCODE_G, SEQCODE_OR, INDEXED(JOYCODE_X_RIGHT_SWITCH, 1)) ) | |
| 514 | INPUT_PORT_DIGITAL_DEF( 2, IPG_PLAYER2, JOYSTICKRIGHT_UP, "P2 Right/Up", SEQ_DEF_0 ) | |
| 515 | INPUT_PORT_DIGITAL_DEF( 2, IPG_PLAYER2, JOYSTICKRIGHT_DOWN, "P2 Right/Down", SEQ_DEF_0 ) | |
| 516 | INPUT_PORT_DIGITAL_DEF( 2, IPG_PLAYER2, JOYSTICKRIGHT_LEFT, "P2 Right/Left", SEQ_DEF_0 ) | |
| 517 | INPUT_PORT_DIGITAL_DEF( 2, IPG_PLAYER2, JOYSTICKRIGHT_RIGHT,"P2 Right/Right", SEQ_DEF_0 ) | |
| 518 | INPUT_PORT_DIGITAL_DEF( 2, IPG_PLAYER2, JOYSTICKLEFT_UP, "P2 Left/Up", SEQ_DEF_0 ) | |
| 519 | INPUT_PORT_DIGITAL_DEF( 2, IPG_PLAYER2, JOYSTICKLEFT_DOWN, "P2 Left/Down", SEQ_DEF_0 ) | |
| 520 | INPUT_PORT_DIGITAL_DEF( 2, IPG_PLAYER2, JOYSTICKLEFT_LEFT, "P2 Left/Left", SEQ_DEF_0 ) | |
| 521 | INPUT_PORT_DIGITAL_DEF( 2, IPG_PLAYER2, JOYSTICKLEFT_RIGHT, "P2 Left/Right", SEQ_DEF_0 ) | |
| 522 | INPUT_PORT_DIGITAL_DEF( 2, IPG_PLAYER2, BUTTON1, "P2 Button 1", SEQ_DEF_7(KEYCODE_A, SEQCODE_OR, INDEXED(JOYCODE_BUTTON1, 1), SEQCODE_OR, INDEXED(MOUSECODE_BUTTON1, 1), SEQCODE_OR, INDEXED(GUNCODE_BUTTON1, 1)) ) | |
| 523 | INPUT_PORT_DIGITAL_DEF( 2, IPG_PLAYER2, BUTTON2, "P2 Button 2", SEQ_DEF_7(KEYCODE_S, SEQCODE_OR, INDEXED(JOYCODE_BUTTON2, 1), SEQCODE_OR, INDEXED(MOUSECODE_BUTTON3, 1), SEQCODE_OR, INDEXED(GUNCODE_BUTTON2, 1)) ) | |
| 524 | INPUT_PORT_DIGITAL_DEF( 2, IPG_PLAYER2, BUTTON3, "P2 Button 3", SEQ_DEF_5(KEYCODE_Q, SEQCODE_OR, INDEXED(JOYCODE_BUTTON3, 1), SEQCODE_OR, INDEXED(MOUSECODE_BUTTON2, 1)) ) | |
| 525 | INPUT_PORT_DIGITAL_DEF( 2, IPG_PLAYER2, BUTTON4, "P2 Button 4", SEQ_DEF_3(KEYCODE_W, SEQCODE_OR, INDEXED(JOYCODE_BUTTON4, 1)) ) | |
| 526 | INPUT_PORT_DIGITAL_DEF( 2, IPG_PLAYER2, BUTTON5, "P2 Button 5", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON5, 1)) ) | |
| 527 | INPUT_PORT_DIGITAL_DEF( 2, IPG_PLAYER2, BUTTON6, "P2 Button 6", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON6, 1)) ) | |
| 528 | INPUT_PORT_DIGITAL_DEF( 2, IPG_PLAYER2, BUTTON7, "P2 Button 7", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON7, 1)) ) | |
| 529 | INPUT_PORT_DIGITAL_DEF( 2, IPG_PLAYER2, BUTTON8, "P2 Button 8", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON8, 1)) ) | |
| 530 | INPUT_PORT_DIGITAL_DEF( 2, IPG_PLAYER2, BUTTON9, "P2 Button 9", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON9, 1)) ) | |
| 531 | INPUT_PORT_DIGITAL_DEF( 2, IPG_PLAYER2, BUTTON10, "P2 Button 10", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON10, 1)) ) | |
| 532 | INPUT_PORT_DIGITAL_DEF( 2, IPG_PLAYER2, BUTTON11, "P2 Button 11", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON11, 1)) ) | |
| 533 | INPUT_PORT_DIGITAL_DEF( 2, IPG_PLAYER2, BUTTON12, "P2 Button 12", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON12, 1)) ) | |
| 534 | INPUT_PORT_DIGITAL_DEF( 2, IPG_PLAYER2, BUTTON13, "P2 Button 13", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON13, 1)) ) | |
| 535 | INPUT_PORT_DIGITAL_DEF( 2, IPG_PLAYER2, BUTTON14, "P2 Button 14", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON14, 1)) ) | |
| 536 | INPUT_PORT_DIGITAL_DEF( 2, IPG_PLAYER2, BUTTON15, "P2 Button 15", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON15, 1)) ) | |
| 537 | INPUT_PORT_DIGITAL_DEF( 2, IPG_PLAYER2, BUTTON16, "P2 Button 16", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON16, 1)) ) | |
| 538 | INPUT_PORT_DIGITAL_DEF( 2, IPG_PLAYER2, START, "P2 Start", SEQ_DEF_3(KEYCODE_2, SEQCODE_OR, INDEXED(JOYCODE_START, 1)) ) | |
| 539 | INPUT_PORT_DIGITAL_DEF( 2, IPG_PLAYER2, SELECT, "P2 Select", SEQ_DEF_3(KEYCODE_6, SEQCODE_OR, INDEXED(JOYCODE_SELECT, 1)) ) | |
| 540 | INPUT_PORT_DIGITAL_DEF( 2, IPG_PLAYER2, MAHJONG_A, "P2 Mahjong A", SEQ_DEF_0 ) | |
| 541 | INPUT_PORT_DIGITAL_DEF( 2, IPG_PLAYER2, MAHJONG_B, "P2 Mahjong B", SEQ_DEF_0 ) | |
| 542 | INPUT_PORT_DIGITAL_DEF( 2, IPG_PLAYER2, MAHJONG_C, "P2 Mahjong C", SEQ_DEF_0 ) | |
| 543 | INPUT_PORT_DIGITAL_DEF( 2, IPG_PLAYER2, MAHJONG_D, "P2 Mahjong D", SEQ_DEF_0 ) | |
| 544 | INPUT_PORT_DIGITAL_DEF( 2, IPG_PLAYER2, MAHJONG_E, "P2 Mahjong E", SEQ_DEF_0 ) | |
| 545 | INPUT_PORT_DIGITAL_DEF( 2, IPG_PLAYER2, MAHJONG_F, "P2 Mahjong F", SEQ_DEF_0 ) | |
| 546 | INPUT_PORT_DIGITAL_DEF( 2, IPG_PLAYER2, MAHJONG_G, "P2 Mahjong G", SEQ_DEF_0 ) | |
| 547 | INPUT_PORT_DIGITAL_DEF( 2, IPG_PLAYER2, MAHJONG_H, "P2 Mahjong H", SEQ_DEF_0 ) | |
| 548 | INPUT_PORT_DIGITAL_DEF( 2, IPG_PLAYER2, MAHJONG_I, "P2 Mahjong I", SEQ_DEF_0 ) | |
| 549 | INPUT_PORT_DIGITAL_DEF( 2, IPG_PLAYER2, MAHJONG_J, "P2 Mahjong J", SEQ_DEF_0 ) | |
| 550 | INPUT_PORT_DIGITAL_DEF( 2, IPG_PLAYER2, MAHJONG_K, "P2 Mahjong K", SEQ_DEF_0 ) | |
| 551 | INPUT_PORT_DIGITAL_DEF( 2, IPG_PLAYER2, MAHJONG_L, "P2 Mahjong L", SEQ_DEF_0 ) | |
| 552 | INPUT_PORT_DIGITAL_DEF( 2, IPG_PLAYER2, MAHJONG_M, "P2 Mahjong M", SEQ_DEF_0 ) | |
| 553 | INPUT_PORT_DIGITAL_DEF( 2, IPG_PLAYER2, MAHJONG_N, "P2 Mahjong N", SEQ_DEF_0 ) | |
| 554 | INPUT_PORT_DIGITAL_DEF( 2, IPG_PLAYER2, MAHJONG_O, "P2 Mahjong O", SEQ_DEF_0 ) | |
| 555 | INPUT_PORT_DIGITAL_DEF( 2, IPG_PLAYER2, MAHJONG_P, "P2 Mahjong P", SEQ_DEF_0 ) | |
| 556 | INPUT_PORT_DIGITAL_DEF( 2, IPG_PLAYER2, MAHJONG_Q, "P2 Mahjong Q", SEQ_DEF_0 ) | |
| 557 | INPUT_PORT_DIGITAL_DEF( 2, IPG_PLAYER2, MAHJONG_KAN, "P2 Mahjong Kan", SEQ_DEF_0 ) | |
| 558 | INPUT_PORT_DIGITAL_DEF( 2, IPG_PLAYER2, MAHJONG_PON, "P2 Mahjong Pon", SEQ_DEF_0 ) | |
| 559 | INPUT_PORT_DIGITAL_DEF( 2, IPG_PLAYER2, MAHJONG_CHI, "P2 Mahjong Chi", SEQ_DEF_0 ) | |
| 560 | INPUT_PORT_DIGITAL_DEF( 2, IPG_PLAYER2, MAHJONG_REACH, "P2 Mahjong Reach", SEQ_DEF_0 ) | |
| 561 | INPUT_PORT_DIGITAL_DEF( 2, IPG_PLAYER2, MAHJONG_RON, "P2 Mahjong Ron", SEQ_DEF_0 ) | |
| 562 | INPUT_PORT_DIGITAL_DEF( 2, IPG_PLAYER2, MAHJONG_BET, "P2 Mahjong Bet", SEQ_DEF_0 ) | |
| 563 | INPUT_PORT_DIGITAL_DEF( 2, IPG_PLAYER2, MAHJONG_LAST_CHANCE,"P2 Mahjong Last Chance",SEQ_DEF_0 ) | |
| 564 | INPUT_PORT_DIGITAL_DEF( 2, IPG_PLAYER2, MAHJONG_SCORE, "P2 Mahjong Score", SEQ_DEF_0 ) | |
| 565 | INPUT_PORT_DIGITAL_DEF( 2, IPG_PLAYER2, MAHJONG_DOUBLE_UP, "P2 Mahjong Double Up", SEQ_DEF_0 ) | |
| 566 | INPUT_PORT_DIGITAL_DEF( 2, IPG_PLAYER2, MAHJONG_FLIP_FLOP, "P2 Mahjong Flip Flop", SEQ_DEF_0 ) | |
| 567 | INPUT_PORT_DIGITAL_DEF( 2, IPG_PLAYER2, MAHJONG_BIG, "P2 Mahjong Big", SEQ_DEF_0 ) | |
| 568 | INPUT_PORT_DIGITAL_DEF( 2, IPG_PLAYER2, MAHJONG_SMALL, "P2 Mahjong Small", SEQ_DEF_0 ) | |
| 544 | /* for absolute devices, clamp to the bounds absolutely */ | |
| 545 | if (!analog->wraps) | |
| 546 | { | |
| 547 | if (value > adjmax) | |
| 548 | value = adjmax; | |
| 549 | else if (value < adjmin) | |
| 550 | value = adjmin; | |
| 551 | } | |
| 569 | 552 | |
| 570 | INPUT_PORT_DIGITAL_DEF( 3, IPG_PLAYER3, JOYSTICK_UP, "P3 Up", SEQ_DEF_3(KEYCODE_I, SEQCODE_OR, INDEXED(JOYCODE_Y_UP_SWITCH, 2)) ) | |
| 571 | INPUT_PORT_DIGITAL_DEF( 3, IPG_PLAYER3, JOYSTICK_DOWN, "P3 Down", SEQ_DEF_3(KEYCODE_K, SEQCODE_OR, INDEXED(JOYCODE_Y_DOWN_SWITCH, 2)) ) | |
| 572 | INPUT_PORT_DIGITAL_DEF( 3, IPG_PLAYER3, JOYSTICK_LEFT, "P3 Left", SEQ_DEF_3(KEYCODE_J, SEQCODE_OR, INDEXED(JOYCODE_X_LEFT_SWITCH, 2)) ) | |
| 573 | INPUT_PORT_DIGITAL_DEF( 3, IPG_PLAYER3, JOYSTICK_RIGHT, "P3 Right", SEQ_DEF_3(KEYCODE_L, SEQCODE_OR, INDEXED(JOYCODE_X_RIGHT_SWITCH, 2)) ) | |
| 574 | INPUT_PORT_DIGITAL_DEF( 3, IPG_PLAYER3, JOYSTICKRIGHT_UP, "P3 Right/Up", SEQ_DEF_0 ) | |
| 575 | INPUT_PORT_DIGITAL_DEF( 3, IPG_PLAYER3, JOYSTICKRIGHT_DOWN, "P3 Right/Down", SEQ_DEF_0 ) | |
| 576 | INPUT_PORT_DIGITAL_DEF( 3, IPG_PLAYER3, JOYSTICKRIGHT_LEFT, "P3 Right/Left", SEQ_DEF_0 ) | |
| 577 | INPUT_PORT_DIGITAL_DEF( 3, IPG_PLAYER3, JOYSTICKRIGHT_RIGHT,"P3 Right/Right", SEQ_DEF_0 ) | |
| 578 | INPUT_PORT_DIGITAL_DEF( 3, IPG_PLAYER3, JOYSTICKLEFT_UP, "P3 Left/Up", SEQ_DEF_0 ) | |
| 579 | INPUT_PORT_DIGITAL_DEF( 3, IPG_PLAYER3, JOYSTICKLEFT_DOWN, "P3 Left/Down", SEQ_DEF_0 ) | |
| 580 | INPUT_PORT_DIGITAL_DEF( 3, IPG_PLAYER3, JOYSTICKLEFT_LEFT, "P3 Left/Left", SEQ_DEF_0 ) | |
| 581 | INPUT_PORT_DIGITAL_DEF( 3, IPG_PLAYER3, JOYSTICKLEFT_RIGHT, "P3 Left/Right", SEQ_DEF_0 ) | |
| 582 | INPUT_PORT_DIGITAL_DEF( 3, IPG_PLAYER3, BUTTON1, "P3 Button 1", SEQ_DEF_5(KEYCODE_RCONTROL, SEQCODE_OR, INDEXED(JOYCODE_BUTTON1, 2), SEQCODE_OR, INDEXED(GUNCODE_BUTTON1, 2)) ) | |
| 583 | INPUT_PORT_DIGITAL_DEF( 3, IPG_PLAYER3, BUTTON2, "P3 Button 2", SEQ_DEF_5(KEYCODE_RSHIFT, SEQCODE_OR, INDEXED(JOYCODE_BUTTON2, 2), SEQCODE_OR, INDEXED(GUNCODE_BUTTON2, 2)) ) | |
| 584 | INPUT_PORT_DIGITAL_DEF( 3, IPG_PLAYER3, BUTTON3, "P3 Button 3", SEQ_DEF_3(KEYCODE_ENTER, SEQCODE_OR, INDEXED(JOYCODE_BUTTON3, 2)) ) | |
| 585 | INPUT_PORT_DIGITAL_DEF( 3, IPG_PLAYER3, BUTTON4, "P3 Button 4", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON4, 2)) ) | |
| 586 | INPUT_PORT_DIGITAL_DEF( 3, IPG_PLAYER3, BUTTON5, "P3 Button 5", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON5, 2)) ) | |
| 587 | INPUT_PORT_DIGITAL_DEF( 3, IPG_PLAYER3, BUTTON6, "P3 Button 6", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON6, 2)) ) | |
| 588 | INPUT_PORT_DIGITAL_DEF( 3, IPG_PLAYER3, BUTTON7, "P3 Button 7", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON7, 2)) ) | |
| 589 | INPUT_PORT_DIGITAL_DEF( 3, IPG_PLAYER3, BUTTON8, "P3 Button 8", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON8, 2)) ) | |
| 590 | INPUT_PORT_DIGITAL_DEF( 3, IPG_PLAYER3, BUTTON9, "P3 Button 9", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON9, 2)) ) | |
| 591 | INPUT_PORT_DIGITAL_DEF( 3, IPG_PLAYER3, BUTTON10, "P3 Button 10", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON10, 2)) ) | |
| 592 | INPUT_PORT_DIGITAL_DEF( 3, IPG_PLAYER3, BUTTON11, "P3 Button 11", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON11, 2)) ) | |
| 593 | INPUT_PORT_DIGITAL_DEF( 3, IPG_PLAYER3, BUTTON12, "P3 Button 12", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON12, 2)) ) | |
| 594 | INPUT_PORT_DIGITAL_DEF( 3, IPG_PLAYER3, BUTTON13, "P3 Button 13", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON13, 2)) ) | |
| 595 | INPUT_PORT_DIGITAL_DEF( 3, IPG_PLAYER3, BUTTON14, "P3 Button 14", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON14, 2)) ) | |
| 596 | INPUT_PORT_DIGITAL_DEF( 3, IPG_PLAYER3, BUTTON15, "P3 Button 15", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON15, 2)) ) | |
| 597 | INPUT_PORT_DIGITAL_DEF( 3, IPG_PLAYER3, BUTTON16, "P3 Button 16", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON16, 2)) ) | |
| 598 | INPUT_PORT_DIGITAL_DEF( 3, IPG_PLAYER3, START, "P3 Start", SEQ_DEF_3(KEYCODE_3, SEQCODE_OR, INDEXED(JOYCODE_START, 2)) ) | |
| 599 | INPUT_PORT_DIGITAL_DEF( 3, IPG_PLAYER3, SELECT, "P3 Select", SEQ_DEF_3(KEYCODE_7, SEQCODE_OR, INDEXED(JOYCODE_SELECT, 2)) ) | |
| 553 | /* for relative devices, wrap around when we go past the edge */ | |
| 554 | else | |
| 555 | { | |
| 556 | INT32 adj1 = APPLY_INVERSE_SENSITIVITY(512, analog->sensitivity); | |
| 557 | INT32 adjdif = adjmax - adjmin + adj1; | |
| 600 | 558 | |
| 601 | INPUT_PORT_DIGITAL_DEF( 4, IPG_PLAYER4, JOYSTICK_UP, "P4 Up", SEQ_DEF_3(KEYCODE_8_PAD, SEQCODE_OR, INDEXED(JOYCODE_Y_UP_SWITCH, 3)) ) | |
| 602 | INPUT_PORT_DIGITAL_DEF( 4, IPG_PLAYER4, JOYSTICK_DOWN, "P4 Down", SEQ_DEF_3(KEYCODE_2_PAD, SEQCODE_OR, INDEXED(JOYCODE_Y_DOWN_SWITCH, 3)) ) | |
| 603 | INPUT_PORT_DIGITAL_DEF( 4, IPG_PLAYER4, JOYSTICK_LEFT, "P4 Left", SEQ_DEF_3(KEYCODE_4_PAD, SEQCODE_OR, INDEXED(JOYCODE_X_LEFT_SWITCH, 3)) ) | |
| 604 | INPUT_PORT_DIGITAL_DEF( 4, IPG_PLAYER4, JOYSTICK_RIGHT, "P4 Right", SEQ_DEF_3(KEYCODE_6_PAD, SEQCODE_OR, INDEXED(JOYCODE_X_RIGHT_SWITCH, 3)) ) | |
| 605 | INPUT_PORT_DIGITAL_DEF( 4, IPG_PLAYER4, JOYSTICKRIGHT_UP, "P4 Right/Up", SEQ_DEF_0 ) | |
| 606 | INPUT_PORT_DIGITAL_DEF( 4, IPG_PLAYER4, JOYSTICKRIGHT_DOWN, "P4 Right/Down", SEQ_DEF_0 ) | |
| 607 | INPUT_PORT_DIGITAL_DEF( 4, IPG_PLAYER4, JOYSTICKRIGHT_LEFT, "P4 Right/Left", SEQ_DEF_0 ) | |
| 608 | INPUT_PORT_DIGITAL_DEF( 4, IPG_PLAYER4, JOYSTICKRIGHT_RIGHT,"P4 Right/Right", SEQ_DEF_0 ) | |
| 609 | INPUT_PORT_DIGITAL_DEF( 4, IPG_PLAYER4, JOYSTICKLEFT_UP, "P4 Left/Up", SEQ_DEF_0 ) | |
| 610 | INPUT_PORT_DIGITAL_DEF( 4, IPG_PLAYER4, JOYSTICKLEFT_DOWN, "P4 Left/Down", SEQ_DEF_0 ) | |
| 611 | INPUT_PORT_DIGITAL_DEF( 4, IPG_PLAYER4, JOYSTICKLEFT_LEFT, "P4 Left/Left", SEQ_DEF_0 ) | |
| 612 | INPUT_PORT_DIGITAL_DEF( 4, IPG_PLAYER4, JOYSTICKLEFT_RIGHT, "P4 Left/Right", SEQ_DEF_0 ) | |
| 613 | INPUT_PORT_DIGITAL_DEF( 4, IPG_PLAYER4, BUTTON1, "P4 Button 1", SEQ_DEF_3(KEYCODE_0_PAD, SEQCODE_OR, INDEXED(JOYCODE_BUTTON1, 3)) ) | |
| 614 | INPUT_PORT_DIGITAL_DEF( 4, IPG_PLAYER4, BUTTON2, "P4 Button 2", SEQ_DEF_3(KEYCODE_DEL_PAD, SEQCODE_OR, INDEXED(JOYCODE_BUTTON2, 3)) ) | |
| 615 | INPUT_PORT_DIGITAL_DEF( 4, IPG_PLAYER4, BUTTON3, "P4 Button 3", SEQ_DEF_3(KEYCODE_ENTER_PAD, SEQCODE_OR, INDEXED(JOYCODE_BUTTON3, 3)) ) | |
| 616 | INPUT_PORT_DIGITAL_DEF( 4, IPG_PLAYER4, BUTTON4, "P4 Button 4", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON4, 3)) ) | |
| 617 | INPUT_PORT_DIGITAL_DEF( 4, IPG_PLAYER4, BUTTON5, "P4 Button 5", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON5, 3)) ) | |
| 618 | INPUT_PORT_DIGITAL_DEF( 4, IPG_PLAYER4, BUTTON6, "P4 Button 6", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON6, 3)) ) | |
| 619 | INPUT_PORT_DIGITAL_DEF( 4, IPG_PLAYER4, BUTTON7, "P4 Button 7", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON7, 3)) ) | |
| 620 | INPUT_PORT_DIGITAL_DEF( 4, IPG_PLAYER4, BUTTON8, "P4 Button 8", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON8, 3)) ) | |
| 621 | INPUT_PORT_DIGITAL_DEF( 4, IPG_PLAYER4, BUTTON9, "P4 Button 9", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON9, 3)) ) | |
| 622 | INPUT_PORT_DIGITAL_DEF( 4, IPG_PLAYER4, BUTTON10, "P4 Button 10", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON10, 3)) ) | |
| 623 | INPUT_PORT_DIGITAL_DEF( 4, IPG_PLAYER4, BUTTON11, "P4 Button 11", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON11, 3)) ) | |
| 624 | INPUT_PORT_DIGITAL_DEF( 4, IPG_PLAYER4, BUTTON12, "P4 Button 12", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON12, 3)) ) | |
| 625 | INPUT_PORT_DIGITAL_DEF( 4, IPG_PLAYER4, BUTTON13, "P4 Button 13", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON13, 3)) ) | |
| 626 | INPUT_PORT_DIGITAL_DEF( 4, IPG_PLAYER4, BUTTON14, "P4 Button 14", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON14, 3)) ) | |
| 627 | INPUT_PORT_DIGITAL_DEF( 4, IPG_PLAYER4, BUTTON15, "P4 Button 15", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON15, 3)) ) | |
| 628 | INPUT_PORT_DIGITAL_DEF( 4, IPG_PLAYER4, BUTTON16, "P4 Button 16", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON16, 3)) ) | |
| 629 | INPUT_PORT_DIGITAL_DEF( 4, IPG_PLAYER4, START, "P4 Start", SEQ_DEF_3(KEYCODE_4, SEQCODE_OR, INDEXED(JOYCODE_START, 3)) ) | |
| 630 | INPUT_PORT_DIGITAL_DEF( 4, IPG_PLAYER4, SELECT, "P4 Select", SEQ_DEF_3(KEYCODE_8, SEQCODE_OR, INDEXED(JOYCODE_SELECT, 3)) ) | |
| 559 | if (analog->reverse) | |
| 560 | { | |
| 561 | while (value <= adjmin - adj1) | |
| 562 | value += adjdif; | |
| 563 | while (value > adjmax) | |
| 564 | value -= adjdif; | |
| 565 | } | |
| 566 | else | |
| 567 | { | |
| 568 | while (value >= adjmax + adj1) | |
| 569 | value -= adjdif; | |
| 570 | while (value < adjmin) | |
| 571 | value += adjdif; | |
| 572 | } | |
| 573 | } | |
| 631 | 574 | |
| 632 | INPUT_PORT_DIGITAL_DEF( 5, IPG_PLAYER5, JOYSTICK_UP, "P5 Up", SEQ_DEF_1(INDEXED(JOYCODE_Y_UP_SWITCH, 4)) ) | |
| 633 | INPUT_PORT_DIGITAL_DEF( 5, IPG_PLAYER5, JOYSTICK_DOWN, "P5 Down", SEQ_DEF_1(INDEXED(JOYCODE_Y_DOWN_SWITCH, 4)) ) | |
| 634 | INPUT_PORT_DIGITAL_DEF( 5, IPG_PLAYER5, JOYSTICK_LEFT, "P5 Left", SEQ_DEF_1(INDEXED(JOYCODE_X_LEFT_SWITCH, 4)) ) | |
| 635 | INPUT_PORT_DIGITAL_DEF( 5, IPG_PLAYER5, JOYSTICK_RIGHT, "P5 Right", SEQ_DEF_1(INDEXED(JOYCODE_X_RIGHT_SWITCH, 4)) ) | |
| 636 | INPUT_PORT_DIGITAL_DEF( 5, IPG_PLAYER5, JOYSTICKRIGHT_UP, "P5 Right/Up", SEQ_DEF_0 ) | |
| 637 | INPUT_PORT_DIGITAL_DEF( 5, IPG_PLAYER5, JOYSTICKRIGHT_DOWN, "P5 Right/Down", SEQ_DEF_0 ) | |
| 638 | INPUT_PORT_DIGITAL_DEF( 5, IPG_PLAYER5, JOYSTICKRIGHT_LEFT, "P5 Right/Left", SEQ_DEF_0 ) | |
| 639 | INPUT_PORT_DIGITAL_DEF( 5, IPG_PLAYER5, JOYSTICKRIGHT_RIGHT,"P5 Right/Right", SEQ_DEF_0 ) | |
| 640 | INPUT_PORT_DIGITAL_DEF( 5, IPG_PLAYER5, JOYSTICKLEFT_UP, "P5 Left/Up", SEQ_DEF_0 ) | |
| 641 | INPUT_PORT_DIGITAL_DEF( 5, IPG_PLAYER5, JOYSTICKLEFT_DOWN, "P5 Left/Down", SEQ_DEF_0 ) | |
| 642 | INPUT_PORT_DIGITAL_DEF( 5, IPG_PLAYER5, JOYSTICKLEFT_LEFT, "P5 Left/Left", SEQ_DEF_0 ) | |
| 643 | INPUT_PORT_DIGITAL_DEF( 5, IPG_PLAYER5, JOYSTICKLEFT_RIGHT, "P5 Left/Right", SEQ_DEF_0 ) | |
| 644 | INPUT_PORT_DIGITAL_DEF( 5, IPG_PLAYER5, BUTTON1, "P5 Button 1", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON1, 4)) ) | |
| 645 | INPUT_PORT_DIGITAL_DEF( 5, IPG_PLAYER5, BUTTON2, "P5 Button 2", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON2, 4)) ) | |
| 646 | INPUT_PORT_DIGITAL_DEF( 5, IPG_PLAYER5, BUTTON3, "P5 Button 3", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON3, 4)) ) | |
| 647 | INPUT_PORT_DIGITAL_DEF( 5, IPG_PLAYER5, BUTTON4, "P5 Button 4", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON4, 4)) ) | |
| 648 | INPUT_PORT_DIGITAL_DEF( 5, IPG_PLAYER5, BUTTON5, "P5 Button 5", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON5, 4)) ) | |
| 649 | INPUT_PORT_DIGITAL_DEF( 5, IPG_PLAYER5, BUTTON6, "P5 Button 6", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON6, 4)) ) | |
| 650 | INPUT_PORT_DIGITAL_DEF( 5, IPG_PLAYER5, BUTTON7, "P5 Button 7", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON7, 4)) ) | |
| 651 | INPUT_PORT_DIGITAL_DEF( 5, IPG_PLAYER5, BUTTON8, "P5 Button 8", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON8, 4)) ) | |
| 652 | INPUT_PORT_DIGITAL_DEF( 5, IPG_PLAYER5, BUTTON9, "P5 Button 9", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON9, 4)) ) | |
| 653 | INPUT_PORT_DIGITAL_DEF( 5, IPG_PLAYER5, BUTTON10, "P5 Button 10", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON10, 4)) ) | |
| 654 | INPUT_PORT_DIGITAL_DEF( 5, IPG_PLAYER5, BUTTON11, "P5 Button 11", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON11, 4)) ) | |
| 655 | INPUT_PORT_DIGITAL_DEF( 5, IPG_PLAYER5, BUTTON12, "P5 Button 12", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON12, 4)) ) | |
| 656 | INPUT_PORT_DIGITAL_DEF( 5, IPG_PLAYER5, BUTTON13, "P5 Button 13", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON13, 4)) ) | |
| 657 | INPUT_PORT_DIGITAL_DEF( 5, IPG_PLAYER5, BUTTON14, "P5 Button 14", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON14, 4)) ) | |
| 658 | INPUT_PORT_DIGITAL_DEF( 5, IPG_PLAYER5, BUTTON15, "P5 Button 15", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON15, 4)) ) | |
| 659 | INPUT_PORT_DIGITAL_DEF( 5, IPG_PLAYER5, BUTTON16, "P5 Button 16", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON16, 4)) ) | |
| 660 | INPUT_PORT_DIGITAL_DEF( 5, IPG_PLAYER5, START, "P5 Start", SEQ_DEF_0 ) | |
| 661 | INPUT_PORT_DIGITAL_DEF( 5, IPG_PLAYER5, SELECT, "P5 Select", SEQ_DEF_0 ) | |
| 575 | return value; | |
| 576 | } | |
| 662 | 577 | |
| 663 | INPUT_PORT_DIGITAL_DEF( 6, IPG_PLAYER6, JOYSTICK_UP, "P6 Up", SEQ_DEF_1(INDEXED(JOYCODE_Y_UP_SWITCH, 5)) ) | |
| 664 | INPUT_PORT_DIGITAL_DEF( 6, IPG_PLAYER6, JOYSTICK_DOWN, "P6 Down", SEQ_DEF_1(INDEXED(JOYCODE_Y_DOWN_SWITCH, 5)) ) | |
| 665 | INPUT_PORT_DIGITAL_DEF( 6, IPG_PLAYER6, JOYSTICK_LEFT, "P6 Left", SEQ_DEF_1(INDEXED(JOYCODE_X_LEFT_SWITCH, 5)) ) | |
| 666 | INPUT_PORT_DIGITAL_DEF( 6, IPG_PLAYER6, JOYSTICK_RIGHT, "P6 Right", SEQ_DEF_1(INDEXED(JOYCODE_X_RIGHT_SWITCH, 5)) ) | |
| 667 | INPUT_PORT_DIGITAL_DEF( 6, IPG_PLAYER6, JOYSTICKRIGHT_UP, "P6 Right/Up", SEQ_DEF_0 ) | |
| 668 | INPUT_PORT_DIGITAL_DEF( 6, IPG_PLAYER6, JOYSTICKRIGHT_DOWN, "P6 Right/Down", SEQ_DEF_0 ) | |
| 669 | INPUT_PORT_DIGITAL_DEF( 6, IPG_PLAYER6, JOYSTICKRIGHT_LEFT, "P6 Right/Left", SEQ_DEF_0 ) | |
| 670 | INPUT_PORT_DIGITAL_DEF( 6, IPG_PLAYER6, JOYSTICKRIGHT_RIGHT,"P6 Right/Right", SEQ_DEF_0 ) | |
| 671 | INPUT_PORT_DIGITAL_DEF( 6, IPG_PLAYER6, JOYSTICKLEFT_UP, "P6 Left/Up", SEQ_DEF_0 ) | |
| 672 | INPUT_PORT_DIGITAL_DEF( 6, IPG_PLAYER6, JOYSTICKLEFT_DOWN, "P6 Left/Down", SEQ_DEF_0 ) | |
| 673 | INPUT_PORT_DIGITAL_DEF( 6, IPG_PLAYER6, JOYSTICKLEFT_LEFT, "P6 Left/Left", SEQ_DEF_0 ) | |
| 674 | INPUT_PORT_DIGITAL_DEF( 6, IPG_PLAYER6, JOYSTICKLEFT_RIGHT, "P6 Left/Right", SEQ_DEF_0 ) | |
| 675 | INPUT_PORT_DIGITAL_DEF( 6, IPG_PLAYER6, BUTTON1, "P6 Button 1", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON1, 5)) ) | |
| 676 | INPUT_PORT_DIGITAL_DEF( 6, IPG_PLAYER6, BUTTON2, "P6 Button 2", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON2, 5)) ) | |
| 677 | INPUT_PORT_DIGITAL_DEF( 6, IPG_PLAYER6, BUTTON3, "P6 Button 3", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON3, 5)) ) | |
| 678 | INPUT_PORT_DIGITAL_DEF( 6, IPG_PLAYER6, BUTTON4, "P6 Button 4", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON4, 5)) ) | |
| 679 | INPUT_PORT_DIGITAL_DEF( 6, IPG_PLAYER6, BUTTON5, "P6 Button 5", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON5, 5)) ) | |
| 680 | INPUT_PORT_DIGITAL_DEF( 6, IPG_PLAYER6, BUTTON6, "P6 Button 6", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON6, 5)) ) | |
| 681 | INPUT_PORT_DIGITAL_DEF( 6, IPG_PLAYER6, BUTTON7, "P6 Button 7", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON7, 5)) ) | |
| 682 | INPUT_PORT_DIGITAL_DEF( 6, IPG_PLAYER6, BUTTON8, "P6 Button 8", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON8, 5)) ) | |
| 683 | INPUT_PORT_DIGITAL_DEF( 6, IPG_PLAYER6, BUTTON9, "P6 Button 9", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON9, 5)) ) | |
| 684 | INPUT_PORT_DIGITAL_DEF( 6, IPG_PLAYER6, BUTTON10, "P6 Button 10", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON10, 5)) ) | |
| 685 | INPUT_PORT_DIGITAL_DEF( 6, IPG_PLAYER6, BUTTON11, "P6 Button 11", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON11, 5)) ) | |
| 686 | INPUT_PORT_DIGITAL_DEF( 6, IPG_PLAYER6, BUTTON12, "P6 Button 12", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON12, 5)) ) | |
| 687 | INPUT_PORT_DIGITAL_DEF( 6, IPG_PLAYER6, BUTTON13, "P6 Button 13", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON13, 5)) ) | |
| 688 | INPUT_PORT_DIGITAL_DEF( 6, IPG_PLAYER6, BUTTON14, "P6 Button 14", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON14, 5)) ) | |
| 689 | INPUT_PORT_DIGITAL_DEF( 6, IPG_PLAYER6, BUTTON15, "P6 Button 15", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON15, 5)) ) | |
| 690 | INPUT_PORT_DIGITAL_DEF( 6, IPG_PLAYER6, BUTTON16, "P6 Button 16", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON16, 5)) ) | |
| 691 | INPUT_PORT_DIGITAL_DEF( 6, IPG_PLAYER6, START, "P6 Start", SEQ_DEF_0 ) | |
| 692 | INPUT_PORT_DIGITAL_DEF( 6, IPG_PLAYER6, SELECT, "P6 Select", SEQ_DEF_0 ) | |
| 693 | 578 | |
| 694 | INPUT_PORT_DIGITAL_DEF( 7, IPG_PLAYER7, JOYSTICK_UP, "P7 Up", SEQ_DEF_1(INDEXED(JOYCODE_Y_UP_SWITCH, 6)) ) | |
| 695 | INPUT_PORT_DIGITAL_DEF( 7, IPG_PLAYER7, JOYSTICK_DOWN, "P7 Down", SEQ_DEF_1(INDEXED(JOYCODE_Y_DOWN_SWITCH, 6)) ) | |
| 696 | INPUT_PORT_DIGITAL_DEF( 7, IPG_PLAYER7, JOYSTICK_LEFT, "P7 Left", SEQ_DEF_1(INDEXED(JOYCODE_X_LEFT_SWITCH, 6)) ) | |
| 697 | INPUT_PORT_DIGITAL_DEF( 7, IPG_PLAYER7, JOYSTICK_RIGHT, "P7 Right", SEQ_DEF_1(INDEXED(JOYCODE_X_RIGHT_SWITCH, 6)) ) | |
| 698 | INPUT_PORT_DIGITAL_DEF( 7, IPG_PLAYER7, JOYSTICKRIGHT_UP, "P7 Right/Up", SEQ_DEF_0 ) | |
| 699 | INPUT_PORT_DIGITAL_DEF( 7, IPG_PLAYER7, JOYSTICKRIGHT_DOWN, "P7 Right/Down", SEQ_DEF_0 ) | |
| 700 | INPUT_PORT_DIGITAL_DEF( 7, IPG_PLAYER7, JOYSTICKRIGHT_LEFT, "P7 Right/Left", SEQ_DEF_0 ) | |
| 701 | INPUT_PORT_DIGITAL_DEF( 7, IPG_PLAYER7, JOYSTICKRIGHT_RIGHT,"P7 Right/Right", SEQ_DEF_0 ) | |
| 702 | INPUT_PORT_DIGITAL_DEF( 7, IPG_PLAYER7, JOYSTICKLEFT_UP, "P7 Left/Up", SEQ_DEF_0 ) | |
| 703 | INPUT_PORT_DIGITAL_DEF( 7, IPG_PLAYER7, JOYSTICKLEFT_DOWN, "P7 Left/Down", SEQ_DEF_0 ) | |
| 704 | INPUT_PORT_DIGITAL_DEF( 7, IPG_PLAYER7, JOYSTICKLEFT_LEFT, "P7 Left/Left", SEQ_DEF_0 ) | |
| 705 | INPUT_PORT_DIGITAL_DEF( 7, IPG_PLAYER7, JOYSTICKLEFT_RIGHT, "P7 Left/Right", SEQ_DEF_0 ) | |
| 706 | INPUT_PORT_DIGITAL_DEF( 7, IPG_PLAYER7, BUTTON1, "P7 Button 1", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON1, 6)) ) | |
| 707 | INPUT_PORT_DIGITAL_DEF( 7, IPG_PLAYER7, BUTTON2, "P7 Button 2", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON2, 6)) ) | |
| 708 | INPUT_PORT_DIGITAL_DEF( 7, IPG_PLAYER7, BUTTON3, "P7 Button 3", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON3, 6)) ) | |
| 709 | INPUT_PORT_DIGITAL_DEF( 7, IPG_PLAYER7, BUTTON4, "P7 Button 4", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON4, 6)) ) | |
| 710 | INPUT_PORT_DIGITAL_DEF( 7, IPG_PLAYER7, BUTTON5, "P7 Button 5", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON5, 6)) ) | |
| 711 | INPUT_PORT_DIGITAL_DEF( 7, IPG_PLAYER7, BUTTON6, "P7 Button 6", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON6, 6)) ) | |
| 712 | INPUT_PORT_DIGITAL_DEF( 7, IPG_PLAYER7, BUTTON7, "P7 Button 7", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON7, 6)) ) | |
| 713 | INPUT_PORT_DIGITAL_DEF( 7, IPG_PLAYER7, BUTTON8, "P7 Button 8", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON8, 6)) ) | |
| 714 | INPUT_PORT_DIGITAL_DEF( 7, IPG_PLAYER7, BUTTON9, "P7 Button 9", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON9, 6)) ) | |
| 715 | INPUT_PORT_DIGITAL_DEF( 7, IPG_PLAYER7, BUTTON10, "P7 Button 10", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON10, 6)) ) | |
| 716 | INPUT_PORT_DIGITAL_DEF( 7, IPG_PLAYER7, BUTTON11, "P7 Button 11", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON11, 6)) ) | |
| 717 | INPUT_PORT_DIGITAL_DEF( 7, IPG_PLAYER7, BUTTON12, "P7 Button 12", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON12, 6)) ) | |
| 718 | INPUT_PORT_DIGITAL_DEF( 7, IPG_PLAYER7, BUTTON13, "P7 Button 13", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON13, 6)) ) | |
| 719 | INPUT_PORT_DIGITAL_DEF( 7, IPG_PLAYER7, BUTTON14, "P7 Button 14", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON14, 6)) ) | |
| 720 | INPUT_PORT_DIGITAL_DEF( 7, IPG_PLAYER7, BUTTON15, "P7 Button 15", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON15, 6)) ) | |
| 721 | INPUT_PORT_DIGITAL_DEF( 7, IPG_PLAYER7, BUTTON16, "P7 Button 16", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON16, 6)) ) | |
| 722 | INPUT_PORT_DIGITAL_DEF( 7, IPG_PLAYER7, START, "P7 Start", SEQ_DEF_0 ) | |
| 723 | INPUT_PORT_DIGITAL_DEF( 7, IPG_PLAYER7, SELECT, "P7 Select", SEQ_DEF_0 ) | |
| 579 | /*------------------------------------------------- | |
| 580 | get_port_index - return an index for the | |
| 581 | given port tag | |
| 582 | -------------------------------------------------*/ | |
| 724 | 583 | |
| 725 | INPUT_PORT_DIGITAL_DEF( 8, IPG_PLAYER8, JOYSTICK_UP, "P8 Up", SEQ_DEF_1(INDEXED(JOYCODE_Y_UP_SWITCH, 7)) ) | |
| 726 | INPUT_PORT_DIGITAL_DEF( 8, IPG_PLAYER8, JOYSTICK_DOWN, "P8 Down", SEQ_DEF_1(INDEXED(JOYCODE_Y_DOWN_SWITCH, 7)) ) | |
| 727 | INPUT_PORT_DIGITAL_DEF( 8, IPG_PLAYER8, JOYSTICK_LEFT, "P8 Left", SEQ_DEF_1(INDEXED(JOYCODE_X_LEFT_SWITCH, 7)) ) | |
| 728 | INPUT_PORT_DIGITAL_DEF( 8, IPG_PLAYER8, JOYSTICK_RIGHT, "P8 Right", SEQ_DEF_1(INDEXED(JOYCODE_X_RIGHT_SWITCH, 7)) ) | |
| 729 | INPUT_PORT_DIGITAL_DEF( 8, IPG_PLAYER8, JOYSTICKRIGHT_UP, "P8 Right/Up", SEQ_DEF_0 ) | |
| 730 | INPUT_PORT_DIGITAL_DEF( 8, IPG_PLAYER8, JOYSTICKRIGHT_DOWN, "P8 Right/Down", SEQ_DEF_0 ) | |
| 731 | INPUT_PORT_DIGITAL_DEF( 8, IPG_PLAYER8, JOYSTICKRIGHT_LEFT, "P8 Right/Left", SEQ_DEF_0 ) | |
| 732 | INPUT_PORT_DIGITAL_DEF( 8, IPG_PLAYER8, JOYSTICKRIGHT_RIGHT,"P8 Right/Right", SEQ_DEF_0 ) | |
| 733 | INPUT_PORT_DIGITAL_DEF( 8, IPG_PLAYER8, JOYSTICKLEFT_UP, "P8 Left/Up", SEQ_DEF_0 ) | |
| 734 | INPUT_PORT_DIGITAL_DEF( 8, IPG_PLAYER8, JOYSTICKLEFT_DOWN, "P8 Left/Down", SEQ_DEF_0 ) | |
| 735 | INPUT_PORT_DIGITAL_DEF( 8, IPG_PLAYER8, JOYSTICKLEFT_LEFT, "P8 Left/Left", SEQ_DEF_0 ) | |
| 736 | INPUT_PORT_DIGITAL_DEF( 8, IPG_PLAYER8, JOYSTICKLEFT_RIGHT, "P8 Left/Right", SEQ_DEF_0 ) | |
| 737 | INPUT_PORT_DIGITAL_DEF( 8, IPG_PLAYER8, BUTTON1, "P8 Button 1", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON1, 7)) ) | |
| 738 | INPUT_PORT_DIGITAL_DEF( 8, IPG_PLAYER8, BUTTON2, "P8 Button 2", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON2, 7)) ) | |
| 739 | INPUT_PORT_DIGITAL_DEF( 8, IPG_PLAYER8, BUTTON3, "P8 Button 3", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON3, 7)) ) | |
| 740 | INPUT_PORT_DIGITAL_DEF( 8, IPG_PLAYER8, BUTTON4, "P8 Button 4", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON4, 7)) ) | |
| 741 | INPUT_PORT_DIGITAL_DEF( 8, IPG_PLAYER8, BUTTON5, "P8 Button 5", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON5, 7)) ) | |
| 742 | INPUT_PORT_DIGITAL_DEF( 8, IPG_PLAYER8, BUTTON6, "P8 Button 6", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON6, 7)) ) | |
| 743 | INPUT_PORT_DIGITAL_DEF( 8, IPG_PLAYER8, BUTTON7, "P8 Button 7", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON7, 7)) ) | |
| 744 | INPUT_PORT_DIGITAL_DEF( 8, IPG_PLAYER8, BUTTON8, "P8 Button 8", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON8, 7)) ) | |
| 745 | INPUT_PORT_DIGITAL_DEF( 8, IPG_PLAYER8, BUTTON9, "P8 Button 9", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON9, 7)) ) | |
| 746 | INPUT_PORT_DIGITAL_DEF( 8, IPG_PLAYER8, BUTTON10, "P8 Button 10", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON10, 7)) ) | |
| 747 | INPUT_PORT_DIGITAL_DEF( 8, IPG_PLAYER8, BUTTON11, "P8 Button 11", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON11, 7)) ) | |
| 748 | INPUT_PORT_DIGITAL_DEF( 8, IPG_PLAYER8, BUTTON12, "P8 Button 12", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON12, 7)) ) | |
| 749 | INPUT_PORT_DIGITAL_DEF( 8, IPG_PLAYER8, BUTTON13, "P8 Button 13", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON13, 7)) ) | |
| 750 | INPUT_PORT_DIGITAL_DEF( 8, IPG_PLAYER8, BUTTON14, "P8 Button 14", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON14, 7)) ) | |
| 751 | INPUT_PORT_DIGITAL_DEF( 8, IPG_PLAYER8, BUTTON15, "P8 Button 15", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON15, 7)) ) | |
| 752 | INPUT_PORT_DIGITAL_DEF( 8, IPG_PLAYER8, BUTTON16, "P8 Button 16", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON16, 7)) ) | |
| 753 | INPUT_PORT_DIGITAL_DEF( 8, IPG_PLAYER8, START, "P8 Start", SEQ_DEF_0 ) | |
| 754 | INPUT_PORT_DIGITAL_DEF( 8, IPG_PLAYER8, SELECT, "P8 Select", SEQ_DEF_0 ) | |
| 584 | INLINE int get_port_index(const input_port_config *portlist, const char *tag) | |
| 585 | { | |
| 586 | const input_port_config *port; | |
| 587 | int index = 0; | |
| 755 | 588 | |
| 756 | INPUT_PORT_DIGITAL_DEF( 0, IPG_OTHER, START1, "1 Player Start", SEQ_DEF_3(KEYCODE_1, SEQCODE_OR, INDEXED(JOYCODE_START, 0)) ) | |
| 757 | INPUT_PORT_DIGITAL_DEF( 0, IPG_OTHER, START2, "2 Players Start", SEQ_DEF_3(KEYCODE_2, SEQCODE_OR, INDEXED(JOYCODE_START, 1)) ) | |
| 758 | INPUT_PORT_DIGITAL_DEF( 0, IPG_OTHER, START3, "3 Players Start", SEQ_DEF_3(KEYCODE_3, SEQCODE_OR, INDEXED(JOYCODE_START, 2)) ) | |
| 759 | INPUT_PORT_DIGITAL_DEF( 0, IPG_OTHER, START4, "4 Players Start", SEQ_DEF_3(KEYCODE_4, SEQCODE_OR, INDEXED(JOYCODE_START, 3)) ) | |
| 760 | INPUT_PORT_DIGITAL_DEF( 0, IPG_OTHER, START5, "5 Players Start", SEQ_DEF_0 ) | |
| 761 | INPUT_PORT_DIGITAL_DEF( 0, IPG_OTHER, START6, "6 Players Start", SEQ_DEF_0 ) | |
| 762 | INPUT_PORT_DIGITAL_DEF( 0, IPG_OTHER, START7, "7 Players Start", SEQ_DEF_0 ) | |
| 763 | INPUT_PORT_DIGITAL_DEF( 0, IPG_OTHER, START8, "8 Players Start", SEQ_DEF_0 ) | |
| 589 | for (port = portlist; port != NULL; port = port->next) | |
| 590 | { | |
| 591 | if (port->tag != NULL && strcmp(tag, port->tag) == 0) | |
| 592 | return index; | |
| 593 | index++; | |
| 594 | } | |
| 595 | return -1; | |
| 596 | } | |
| 764 | 597 | |
| 765 | INPUT_PORT_DIGITAL_DEF( 0, IPG_OTHER, COIN1, "Coin 1", SEQ_DEF_3(KEYCODE_5, SEQCODE_OR, INDEXED(JOYCODE_SELECT, 0)) ) | |
| 766 | INPUT_PORT_DIGITAL_DEF( 0, IPG_OTHER, COIN2, "Coin 2", SEQ_DEF_3(KEYCODE_6, SEQCODE_OR, INDEXED(JOYCODE_SELECT, 1)) ) | |
| 767 | INPUT_PORT_DIGITAL_DEF( 0, IPG_OTHER, COIN3, "Coin 3", SEQ_DEF_3(KEYCODE_7, SEQCODE_OR, INDEXED(JOYCODE_SELECT, 2)) ) | |
| 768 | INPUT_PORT_DIGITAL_DEF( 0, IPG_OTHER, COIN4, "Coin 4", SEQ_DEF_3(KEYCODE_8, SEQCODE_OR, INDEXED(JOYCODE_SELECT, 3)) ) | |
| 769 | INPUT_PORT_DIGITAL_DEF( 0, IPG_OTHER, COIN5, "Coin 5", SEQ_DEF_0 ) | |
| 770 | INPUT_PORT_DIGITAL_DEF( 0, IPG_OTHER, COIN6, "Coin 6", SEQ_DEF_0 ) | |
| 771 | INPUT_PORT_DIGITAL_DEF( 0, IPG_OTHER, COIN7, "Coin 7", SEQ_DEF_0 ) | |
| 772 | INPUT_PORT_DIGITAL_DEF( 0, IPG_OTHER, COIN8, "Coin 8", SEQ_DEF_0 ) | |
| 773 | INPUT_PORT_DIGITAL_DEF( 0, IPG_OTHER, BILL1, "Bill 1", SEQ_DEF_1(KEYCODE_BACKSPACE) ) | |
| 774 | 598 | |
| 775 | INPUT_PORT_DIGITAL_DEF( 0, IPG_OTHER, SERVICE1, "Service 1", SEQ_DEF_1(KEYCODE_9) ) | |
| 776 | INPUT_PORT_DIGITAL_DEF( 0, IPG_OTHER, SERVICE2, "Service 2", SEQ_DEF_1(KEYCODE_0) ) | |
| 777 | INPUT_PORT_DIGITAL_DEF( 0, IPG_OTHER, SERVICE3, "Service 3", SEQ_DEF_1(KEYCODE_MINUS) ) | |
| 778 | INPUT_PORT_DIGITAL_DEF( 0, IPG_OTHER, SERVICE4, "Service 4", SEQ_DEF_1(KEYCODE_EQUALS) ) | |
| 779 | 599 | |
| 780 | INPUT_PORT_DIGITAL_DEF( 0, IPG_OTHER, SERVICE, "Service", SEQ_DEF_1(KEYCODE_F2) ) | |
| 781 | INPUT_PORT_DIGITAL_DEF( 0, IPG_OTHER, TILT, "Tilt", SEQ_DEF_1(KEYCODE_T) ) | |
| 782 | INPUT_PORT_DIGITAL_DEF( 0, IPG_OTHER, INTERLOCK, "Door Interlock", SEQ_DEF_0 ) | |
| 783 | INPUT_PORT_DIGITAL_DEF( 0, IPG_OTHER, VOLUME_DOWN, "Volume Down", SEQ_DEF_1(KEYCODE_MINUS) ) | |
| 784 | INPUT_PORT_DIGITAL_DEF( 0, IPG_OTHER, VOLUME_UP, "Volume Up", SEQ_DEF_1(KEYCODE_EQUALS) ) | |
| 600 | /*************************************************************************** | |
| 601 | CORE SYSTEM MANAGEMENT | |
| 602 | ***************************************************************************/ | |
| 785 | 603 | |
| 786 | INPUT_PORT_ANALOG_DEF ( 1, IPG_PLAYER1, PEDAL, "P1 Pedal 1", SEQ_DEF_1(INDEXED(JOYCODE_Y_NEG_ABSOLUTE, 0)), SEQ_DEF_0, SEQ_DEF_3(KEYCODE_LCONTROL, SEQCODE_OR, INDEXED(JOYCODE_BUTTON1, 0)) ) | |
| 787 | INPUT_PORT_ANALOG_DEF ( 2, IPG_PLAYER2, PEDAL, "P2 Pedal 1", SEQ_DEF_1(INDEXED(JOYCODE_Y_NEG_ABSOLUTE, 1)), SEQ_DEF_0, SEQ_DEF_3(KEYCODE_A, SEQCODE_OR, INDEXED(JOYCODE_BUTTON1, 1)) ) | |
| 788 | INPUT_PORT_ANALOG_DEF ( 3, IPG_PLAYER3, PEDAL, "P3 Pedal 1", SEQ_DEF_1(INDEXED(JOYCODE_Y_NEG_ABSOLUTE, 2)), SEQ_DEF_0, SEQ_DEF_3(KEYCODE_RCONTROL, SEQCODE_OR, INDEXED(JOYCODE_BUTTON1, 2)) ) | |
| 789 | INPUT_PORT_ANALOG_DEF ( 4, IPG_PLAYER4, PEDAL, "P4 Pedal 1", SEQ_DEF_1(INDEXED(JOYCODE_Y_NEG_ABSOLUTE, 3)), SEQ_DEF_0, SEQ_DEF_3(KEYCODE_0_PAD, SEQCODE_OR, INDEXED(JOYCODE_BUTTON1, 3)) ) | |
| 790 | INPUT_PORT_ANALOG_DEF ( 5, IPG_PLAYER5, PEDAL, "P5 Pedal 1", SEQ_DEF_1(INDEXED(JOYCODE_Y_NEG_ABSOLUTE, 4)), SEQ_DEF_0, SEQ_DEF_1(INDEXED(JOYCODE_BUTTON1, 4)) ) | |
| 791 | INPUT_PORT_ANALOG_DEF ( 6, IPG_PLAYER6, PEDAL, "P6 Pedal 1", SEQ_DEF_1(INDEXED(JOYCODE_Y_NEG_ABSOLUTE, 5)), SEQ_DEF_0, SEQ_DEF_1(INDEXED(JOYCODE_BUTTON1, 5)) ) | |
| 792 | INPUT_PORT_ANALOG_DEF ( 7, IPG_PLAYER7, PEDAL, "P7 Pedal 1", SEQ_DEF_1(INDEXED(JOYCODE_Y_NEG_ABSOLUTE, 6)), SEQ_DEF_0, SEQ_DEF_1(INDEXED(JOYCODE_BUTTON1, 6)) ) | |
| 793 | INPUT_PORT_ANALOG_DEF ( 8, IPG_PLAYER8, PEDAL, "P8 Pedal 1", SEQ_DEF_1(INDEXED(JOYCODE_Y_NEG_ABSOLUTE, 7)), SEQ_DEF_0, SEQ_DEF_1(INDEXED(JOYCODE_BUTTON1, 7)) ) | |
| 604 | /*------------------------------------------------- | |
| 605 | input_port_init - initialize the input port | |
| 606 | system | |
| 607 | -------------------------------------------------*/ | |
| 794 | 608 | |
| 795 | INPUT_PORT_ANALOG_DEF ( 1, IPG_PLAYER1, PEDAL2, "P1 Pedal 2", SEQ_DEF_1(INDEXED(JOYCODE_Y_POS_ABSOLUTE, 0)), SEQ_DEF_0, SEQ_DEF_3(KEYCODE_LALT, SEQCODE_OR, INDEXED(JOYCODE_BUTTON2, 0)) ) | |
| 796 | INPUT_PORT_ANALOG_DEF ( 2, IPG_PLAYER2, PEDAL2, "P2 Pedal 2", SEQ_DEF_1(INDEXED(JOYCODE_Y_POS_ABSOLUTE, 1)), SEQ_DEF_0, SEQ_DEF_3(KEYCODE_S, SEQCODE_OR, INDEXED(JOYCODE_BUTTON2, 1)) ) | |
| 797 | INPUT_PORT_ANALOG_DEF ( 3, IPG_PLAYER3, PEDAL2, "P3 Pedal 2", SEQ_DEF_1(INDEXED(JOYCODE_Y_POS_ABSOLUTE, 2)), SEQ_DEF_0, SEQ_DEF_3(KEYCODE_RSHIFT, SEQCODE_OR, INDEXED(JOYCODE_BUTTON2, 2)) ) | |
| 798 | INPUT_PORT_ANALOG_DEF ( 4, IPG_PLAYER4, PEDAL2, "P4 Pedal 2", SEQ_DEF_1(INDEXED(JOYCODE_Y_POS_ABSOLUTE, 3)), SEQ_DEF_0, SEQ_DEF_3(KEYCODE_DEL_PAD, SEQCODE_OR, INDEXED(JOYCODE_BUTTON2, 3)) ) | |
| 799 | INPUT_PORT_ANALOG_DEF ( 5, IPG_PLAYER5, PEDAL2, "P5 Pedal 2", SEQ_DEF_1(INDEXED(JOYCODE_Y_POS_ABSOLUTE, 4)), SEQ_DEF_0, SEQ_DEF_1(INDEXED(JOYCODE_BUTTON2, 4)) ) | |
| 800 | INPUT_PORT_ANALOG_DEF ( 6, IPG_PLAYER6, PEDAL2, "P6 Pedal 2", SEQ_DEF_1(INDEXED(JOYCODE_Y_POS_ABSOLUTE, 5)), SEQ_DEF_0, SEQ_DEF_1(INDEXED(JOYCODE_BUTTON2, 5)) ) | |
| 801 | INPUT_PORT_ANALOG_DEF ( 7, IPG_PLAYER7, PEDAL2, "P7 Pedal 2", SEQ_DEF_1(INDEXED(JOYCODE_Y_POS_ABSOLUTE, 6)), SEQ_DEF_0, SEQ_DEF_1(INDEXED(JOYCODE_BUTTON2, 6)) ) | |
| 802 | INPUT_PORT_ANALOG_DEF ( 8, IPG_PLAYER8, PEDAL2, "P8 Pedal 2", SEQ_DEF_1(INDEXED(JOYCODE_Y_POS_ABSOLUTE, 7)), SEQ_DEF_0, SEQ_DEF_1(INDEXED(JOYCODE_BUTTON2, 7)) ) | |
| 609 | time_t input_port_init(running_machine *machine, const input_port_token *tokens) | |
| 610 | { | |
| 611 | input_port_private *portdata; | |
| 612 | time_t basetime; | |
| 803 | 613 | |
| 804 | INPUT_PORT_ANALOG_DEF ( 1, IPG_PLAYER1, PEDAL3, "P1 Pedal 3", SEQ_DEF_0, SEQ_DEF_0, SEQ_DEF_3(KEYCODE_SPACE, SEQCODE_OR, INDEXED(JOYCODE_BUTTON3, 0)) ) | |
| 805 | INPUT_PORT_ANALOG_DEF ( 2, IPG_PLAYER2, PEDAL3, "P2 Pedal 3", SEQ_DEF_0, SEQ_DEF_0, SEQ_DEF_3(KEYCODE_Q, SEQCODE_OR, INDEXED(JOYCODE_BUTTON3, 1)) ) | |
| 806 | INPUT_PORT_ANALOG_DEF ( 3, IPG_PLAYER3, PEDAL3, "P3 Pedal 3", SEQ_DEF_0, SEQ_DEF_0, SEQ_DEF_3(KEYCODE_ENTER, SEQCODE_OR, INDEXED(JOYCODE_BUTTON3, 2)) ) | |
| 807 | INPUT_PORT_ANALOG_DEF ( 4, IPG_PLAYER4, PEDAL3, "P4 Pedal 3", SEQ_DEF_0, SEQ_DEF_0, SEQ_DEF_3(KEYCODE_ENTER_PAD, SEQCODE_OR, INDEXED(JOYCODE_BUTTON3, 3)) ) | |
| 808 | INPUT_PORT_ANALOG_DEF ( 5, IPG_PLAYER5, PEDAL3, "P5 Pedal 3", SEQ_DEF_0, SEQ_DEF_0, SEQ_DEF_1(INDEXED(JOYCODE_BUTTON3, 4)) ) | |
| 809 | INPUT_PORT_ANALOG_DEF ( 6, IPG_PLAYER6, PEDAL3, "P6 Pedal 3", SEQ_DEF_0, SEQ_DEF_0, SEQ_DEF_1(INDEXED(JOYCODE_BUTTON3, 5)) ) | |
| 810 | INPUT_PORT_ANALOG_DEF ( 7, IPG_PLAYER7, PEDAL3, "P7 Pedal 3", SEQ_DEF_0, SEQ_DEF_0, SEQ_DEF_1(INDEXED(JOYCODE_BUTTON3, 6)) ) | |
| 811 | INPUT_PORT_ANALOG_DEF ( 8, IPG_PLAYER8, PEDAL3, "P8 Pedal 3", SEQ_DEF_0, SEQ_DEF_0, SEQ_DEF_1(INDEXED(JOYCODE_BUTTON3, 7)) ) | |
| 614 | /* allocate memory for our data structure */ | |
| 615 | machine->input_port_data = auto_malloc(sizeof(*machine->input_port_data)); | |
| 616 | memset(machine->input_port_data, 0, sizeof(*machine->input_port_data)); | |
| 617 | portdata = machine->input_port_data; | |
| 812 | 618 | |
| 813 | INPUT_PORT_ANALOG_DEF ( 1, IPG_PLAYER1, PADDLE, "Paddle", SEQ_DEF_3(INDEXED(MOUSECODE_X, 0), SEQCODE_OR, INDEXED(JOYCODE_X, 0)), SEQ_DEF_3(KEYCODE_LEFT, SEQCODE_OR, INDEXED(JOYCODE_X_LEFT_SWITCH, 0)), SEQ_DEF_3(KEYCODE_RIGHT, SEQCODE_OR, INDEXED(JOYCODE_X_RIGHT_SWITCH, 0)) ) | |
| 814 | INPUT_PORT_ANALOG_DEF ( 2, IPG_PLAYER2, PADDLE, "Paddle 2", SEQ_DEF_3(INDEXED(MOUSECODE_X, 1), SEQCODE_OR, INDEXED(JOYCODE_X, 1)), SEQ_DEF_3(KEYCODE_D, SEQCODE_OR, INDEXED(JOYCODE_X_LEFT_SWITCH, 1)), SEQ_DEF_3(KEYCODE_G, SEQCODE_OR, INDEXED(JOYCODE_X_RIGHT_SWITCH, 1)) ) | |
| 815 | INPUT_PORT_ANALOG_DEF ( 3, IPG_PLAYER3, PADDLE, "Paddle 3", SEQ_DEF_3(INDEXED(MOUSECODE_X, 2), SEQCODE_OR, INDEXED(JOYCODE_X, 2)), SEQ_DEF_3(KEYCODE_J, SEQCODE_OR, INDEXED(JOYCODE_X_LEFT_SWITCH, 2)), SEQ_DEF_3(KEYCODE_L, SEQCODE_OR, INDEXED(JOYCODE_X_RIGHT_SWITCH, 2)) ) | |
| 816 | INPUT_PORT_ANALOG_DEF ( 4, IPG_PLAYER4, PADDLE, "Paddle 4", SEQ_DEF_3(INDEXED(MOUSECODE_X, 3), SEQCODE_OR, INDEXED(JOYCODE_X, 3)), SEQ_DEF_1(INDEXED(JOYCODE_X_LEFT_SWITCH, 3)), SEQ_DEF_1(INDEXED(JOYCODE_X_RIGHT_SWITCH, 3)) ) | |
| 817 | INPUT_PORT_ANALOG_DEF ( 5, IPG_PLAYER5, PADDLE, "Paddle 5", SEQ_DEF_3(INDEXED(MOUSECODE_X, 4), SEQCODE_OR, INDEXED(JOYCODE_X, 4)), SEQ_DEF_1(INDEXED(JOYCODE_X_LEFT_SWITCH, 4)), SEQ_DEF_1(INDEXED(JOYCODE_X_RIGHT_SWITCH, 4)) ) | |
| 818 | INPUT_PORT_ANALOG_DEF ( 6, IPG_PLAYER6, PADDLE, "Paddle 6", SEQ_DEF_3(INDEXED(MOUSECODE_X, 5), SEQCODE_OR, INDEXED(JOYCODE_X, 5)), SEQ_DEF_1(INDEXED(JOYCODE_X_LEFT_SWITCH, 5)), SEQ_DEF_1(INDEXED(JOYCODE_X_RIGHT_SWITCH, 5)) ) | |
| 819 | INPUT_PORT_ANALOG_DEF ( 7, IPG_PLAYER7, PADDLE, "Paddle 7", SEQ_DEF_3(INDEXED(MOUSECODE_X, 6), SEQCODE_OR, INDEXED(JOYCODE_X, 6)), SEQ_DEF_1(INDEXED(JOYCODE_X_LEFT_SWITCH, 6)), SEQ_DEF_1(INDEXED(JOYCODE_X_RIGHT_SWITCH, 6)) ) | |
| 820 | INPUT_PORT_ANALOG_DEF ( 8, IPG_PLAYER8, PADDLE, "Paddle 8", SEQ_DEF_3(INDEXED(MOUSECODE_X, 7), SEQCODE_OR, INDEXED(JOYCODE_X, 7)), SEQ_DEF_1(INDEXED(JOYCODE_X_LEFT_SWITCH, 7)), SEQ_DEF_1(INDEXED(JOYCODE_X_RIGHT_SWITCH, 7)) ) | |
| 619 | /* add an exit callback and a frame callback */ | |
| 620 | add_exit_callback(machine, input_port_exit); | |
| 621 | add_frame_callback(machine, frame_update_callback); | |
| 821 | 622 | |
| 822 | INPUT_PORT_ANALOG_DEF ( 1, IPG_PLAYER1, PADDLE_V, "Paddle V", SEQ_DEF_3(INDEXED(MOUSECODE_Y, 0), SEQCODE_OR, INDEXED(JOYCODE_Y, 0)), SEQ_DEF_3(KEYCODE_UP, SEQCODE_OR, INDEXED(JOYCODE_Y_UP_SWITCH, 0)), SEQ_DEF_3(KEYCODE_DOWN, SEQCODE_OR, INDEXED(JOYCODE_Y_DOWN_SWITCH, 0)) ) | |
| 823 | INPUT_PORT_ANALOG_DEF ( 2, IPG_PLAYER2, PADDLE_V, "Paddle V 2", SEQ_DEF_3(INDEXED(MOUSECODE_Y, 1), SEQCODE_OR, INDEXED(JOYCODE_Y, 1)), SEQ_DEF_3(KEYCODE_R, SEQCODE_OR, INDEXED(JOYCODE_Y_UP_SWITCH, 1)), SEQ_DEF_3(KEYCODE_F, SEQCODE_OR, INDEXED(JOYCODE_Y_DOWN_SWITCH, 1)) ) | |
| 824 | INPUT_PORT_ANALOG_DEF ( 3, IPG_PLAYER3, PADDLE_V, "Paddle V 3", SEQ_DEF_3(INDEXED(MOUSECODE_Y, 2), SEQCODE_OR, INDEXED(JOYCODE_Y, 2)), SEQ_DEF_3(KEYCODE_I, SEQCODE_OR, INDEXED(JOYCODE_Y_UP_SWITCH, 2)), SEQ_DEF_3(KEYCODE_K, SEQCODE_OR, INDEXED(JOYCODE_Y_DOWN_SWITCH, 2)) ) | |
| 825 | INPUT_PORT_ANALOG_DEF ( 4, IPG_PLAYER4, PADDLE_V, "Paddle V 4", SEQ_DEF_3(INDEXED(MOUSECODE_Y, 3), SEQCODE_OR, INDEXED(JOYCODE_Y, 3)), SEQ_DEF_1(INDEXED(JOYCODE_Y_UP_SWITCH, 3)), SEQ_DEF_1(INDEXED(JOYCODE_Y_DOWN_SWITCH, 3)) ) | |
| 826 | INPUT_PORT_ANALOG_DEF ( 5, IPG_PLAYER5, PADDLE_V, "Paddle V 5", SEQ_DEF_3(INDEXED(MOUSECODE_Y, 4), SEQCODE_OR, INDEXED(JOYCODE_Y, 4)), SEQ_DEF_1(INDEXED(JOYCODE_Y_UP_SWITCH, 4)), SEQ_DEF_1(INDEXED(JOYCODE_Y_DOWN_SWITCH, 4)) ) | |
| 827 | INPUT_PORT_ANALOG_DEF ( 6, IPG_PLAYER6, PADDLE_V, "Paddle V 6", SEQ_DEF_3(INDEXED(MOUSECODE_Y, 5), SEQCODE_OR, INDEXED(JOYCODE_Y, 5)), SEQ_DEF_1(INDEXED(JOYCODE_Y_UP_SWITCH, 5)), SEQ_DEF_1(INDEXED(JOYCODE_Y_DOWN_SWITCH, 5)) ) | |
| 828 | INPUT_PORT_ANALOG_DEF ( 7, IPG_PLAYER7, PADDLE_V, "Paddle V 7", SEQ_DEF_3(INDEXED(MOUSECODE_Y, 6), SEQCODE_OR, INDEXED(JOYCODE_Y, 6)), SEQ_DEF_1(INDEXED(JOYCODE_Y_UP_SWITCH, 6)), SEQ_DEF_1(INDEXED(JOYCODE_Y_DOWN_SWITCH, 6)) ) | |
| 829 | INPUT_PORT_ANALOG_DEF ( 8, IPG_PLAYER8, PADDLE_V, "Paddle V 8", SEQ_DEF_3(INDEXED(MOUSECODE_Y, 7), SEQCODE_OR, INDEXED(JOYCODE_Y, 7)), SEQ_DEF_1(INDEXED(JOYCODE_Y_UP_SWITCH, 7)), SEQ_DEF_1(INDEXED(JOYCODE_Y_DOWN_SWITCH, 7)) ) | |
| 623 | /* initialize the default port info from the OSD */ | |
| 624 | init_port_types(machine); | |
| 830 | 625 | |
| 831 | INPUT_PORT_ANALOG_DEF ( 1, IPG_PLAYER1, POSITIONAL, "Positional", SEQ_DEF_3(INDEXED(MOUSECODE_X, 0), SEQCODE_OR, INDEXED(JOYCODE_X, 0)), SEQ_DEF_3(KEYCODE_LEFT, SEQCODE_OR, INDEXED(JOYCODE_X_LEFT_SWITCH, 0)), SEQ_DEF_3(KEYCODE_RIGHT, SEQCODE_OR, INDEXED(JOYCODE_X_RIGHT_SWITCH, 0)) ) | |
| 832 | INPUT_PORT_ANALOG_DEF ( 2, IPG_PLAYER2, POSITIONAL, "Positional 2", SEQ_DEF_3(INDEXED(MOUSECODE_X, 1), SEQCODE_OR, INDEXED(JOYCODE_X, 1)), SEQ_DEF_3(KEYCODE_D, SEQCODE_OR, INDEXED(JOYCODE_X_LEFT_SWITCH, 1)), SEQ_DEF_3(KEYCODE_G, SEQCODE_OR, INDEXED(JOYCODE_X_RIGHT_SWITCH, 1)) ) | |
| 833 | INPUT_PORT_ANALOG_DEF ( 3, IPG_PLAYER3, POSITIONAL, "Positional 3", SEQ_DEF_3(INDEXED(MOUSECODE_X, 2), SEQCODE_OR, INDEXED(JOYCODE_X, 2)), SEQ_DEF_3(KEYCODE_J, SEQCODE_OR, INDEXED(JOYCODE_X_LEFT_SWITCH, 2)), SEQ_DEF_3(KEYCODE_L, SEQCODE_OR, INDEXED(JOYCODE_X_RIGHT_SWITCH, 2)) ) | |
| 834 | INPUT_PORT_ANALOG_DEF ( 4, IPG_PLAYER4, POSITIONAL, "Positional 4", SEQ_DEF_3(INDEXED(MOUSECODE_X, 3), SEQCODE_OR, INDEXED(JOYCODE_X, 3)), SEQ_DEF_1(INDEXED(JOYCODE_X_LEFT_SWITCH, 3)), SEQ_DEF_1(INDEXED(JOYCODE_X_RIGHT_SWITCH, 3)) ) | |
| 835 | INPUT_PORT_ANALOG_DEF ( 5, IPG_PLAYER5, POSITIONAL, "Positional 5", SEQ_DEF_3(INDEXED(MOUSECODE_X, 4), SEQCODE_OR, INDEXED(JOYCODE_X, 4)), SEQ_DEF_1(INDEXED(JOYCODE_X_LEFT_SWITCH, 4)), SEQ_DEF_1(INDEXED(JOYCODE_X_RIGHT_SWITCH, 4)) ) | |
| 836 | INPUT_PORT_ANALOG_DEF ( 6, IPG_PLAYER6, POSITIONAL, "Positional 6", SEQ_DEF_3(INDEXED(MOUSECODE_X, 5), SEQCODE_OR, INDEXED(JOYCODE_X, 5)), SEQ_DEF_1(INDEXED(JOYCODE_X_LEFT_SWITCH, 5)), SEQ_DEF_1(INDEXED(JOYCODE_X_RIGHT_SWITCH, 5)) ) | |
| 837 | INPUT_PORT_ANALOG_DEF ( 7, IPG_PLAYER7, POSITIONAL, "Positional 7", SEQ_DEF_3(INDEXED(MOUSECODE_X, 6), SEQCODE_OR, INDEXED(JOYCODE_X, 6)), SEQ_DEF_1(INDEXED(JOYCODE_X_LEFT_SWITCH, 6)), SEQ_DEF_1(INDEXED(JOYCODE_X_RIGHT_SWITCH, 6)) ) | |
| 838 | INPUT_PORT_ANALOG_DEF ( 8, IPG_PLAYER8, POSITIONAL, "Positional 8", SEQ_DEF_3(INDEXED(MOUSECODE_X, 7), SEQCODE_OR, INDEXED(JOYCODE_X, 7)), SEQ_DEF_1(INDEXED(JOYCODE_X_LEFT_SWITCH, 7)), SEQ_DEF_1(INDEXED(JOYCODE_X_RIGHT_SWITCH, 7)) ) | |
| 626 | /* if we have a token list, proceed */ | |
| 627 | if (tokens != NULL) | |
| 628 | { | |
| 629 | machine->portconfig = input_port_config_alloc(tokens); | |
| 630 | init_port_state(machine); | |
| 631 | } | |
| 839 | 632 | |
| 840 | INPUT_PORT_ANALOG_DEF ( 1, IPG_PLAYER1, POSITIONAL_V, "Positional V", SEQ_DEF_3(INDEXED(MOUSECODE_Y, 0), SEQCODE_OR, INDEXED(JOYCODE_Y, 0)), SEQ_DEF_3(KEYCODE_UP, SEQCODE_OR, INDEXED(JOYCODE_Y_UP_SWITCH, 0)), SEQ_DEF_3(KEYCODE_DOWN, SEQCODE_OR, INDEXED(JOYCODE_Y_DOWN_SWITCH, 0)) ) | |
| 841 | INPUT_PORT_ANALOG_DEF ( 2, IPG_PLAYER2, POSITIONAL_V, "Positional V 2", SEQ_DEF_3(INDEXED(MOUSECODE_Y, 1), SEQCODE_OR, INDEXED(JOYCODE_Y, 1)), SEQ_DEF_3(KEYCODE_R, SEQCODE_OR, INDEXED(JOYCODE_Y_UP_SWITCH, 1)), SEQ_DEF_3(KEYCODE_F, SEQCODE_OR, INDEXED(JOYCODE_Y_DOWN_SWITCH, 1)) ) | |
| 842 | INPUT_PORT_ANALOG_DEF ( 3, IPG_PLAYER3, POSITIONAL_V, "Positional V 3", SEQ_DEF_3(INDEXED(MOUSECODE_Y, 2), SEQCODE_OR, INDEXED(JOYCODE_Y, 2)), SEQ_DEF_3(KEYCODE_I, SEQCODE_OR, INDEXED(JOYCODE_Y_UP_SWITCH, 2)), SEQ_DEF_3(KEYCODE_K, SEQCODE_OR, INDEXED(JOYCODE_Y_DOWN_SWITCH, 2)) ) | |
| 843 | INPUT_PORT_ANALOG_DEF ( 4, IPG_PLAYER4, POSITIONAL_V, "Positional V 4", SEQ_DEF_3(INDEXED(MOUSECODE_Y, 3), SEQCODE_OR, INDEXED(JOYCODE_Y, 3)), SEQ_DEF_1(INDEXED(JOYCODE_Y_UP_SWITCH, 3)), SEQ_DEF_1(INDEXED(JOYCODE_Y_DOWN_SWITCH, 3)) ) | |
| 844 | INPUT_PORT_ANALOG_DEF ( 5, IPG_PLAYER5, POSITIONAL_V, "Positional V 5", SEQ_DEF_3(INDEXED(MOUSECODE_Y, 4), SEQCODE_OR, INDEXED(JOYCODE_Y, 4)), SEQ_DEF_1(INDEXED(JOYCODE_Y_UP_SWITCH, 4)), SEQ_DEF_1(INDEXED(JOYCODE_Y_DOWN_SWITCH, 4)) ) | |
| 845 | INPUT_PORT_ANALOG_DEF ( 6, IPG_PLAYER6, POSITIONAL_V, "Positional V 6", SEQ_DEF_3(INDEXED(MOUSECODE_Y, 5), SEQCODE_OR, INDEXED(JOYCODE_Y, 5)), SEQ_DEF_1(INDEXED(JOYCODE_Y_UP_SWITCH, 5)), SEQ_DEF_1(INDEXED(JOYCODE_Y_DOWN_SWITCH, 5)) ) | |
| 846 | INPUT_PORT_ANALOG_DEF ( 7, IPG_PLAYER7, POSITIONAL_V, "Positional V 7", SEQ_DEF_3(INDEXED(MOUSECODE_Y, 6), SEQCODE_OR, INDEXED(JOYCODE_Y, 6)), SEQ_DEF_1(INDEXED(JOYCODE_Y_UP_SWITCH, 6)), SEQ_DEF_1(INDEXED(JOYCODE_Y_DOWN_SWITCH, 6)) ) | |
| 847 | INPUT_PORT_ANALOG_DEF ( 8, IPG_PLAYER8, POSITIONAL_V, "Positional V 8", SEQ_DEF_3(INDEXED(MOUSECODE_Y, 7), SEQCODE_OR, INDEXED(JOYCODE_Y, 7)), SEQ_DEF_1(INDEXED(JOYCODE_Y_UP_SWITCH, 7)), SEQ_DEF_1(INDEXED(JOYCODE_Y_DOWN_SWITCH, 7)) ) | |
| 633 | /* register callbacks for when we load configurations */ | |
| 634 | config_register(machine, "input", load_config_callback, save_config_callback); | |
| 848 | 635 | |
| 849 | INPUT_PORT_ANALOG_DEF ( 1, IPG_PLAYER1, DIAL, "Dial", SEQ_DEF_3(INDEXED(MOUSECODE_X, 0), SEQCODE_OR, INDEXED(JOYCODE_X, 0)), SEQ_DEF_3(KEYCODE_LEFT, SEQCODE_OR, INDEXED(JOYCODE_X_LEFT_SWITCH, 0)), SEQ_DEF_3(KEYCODE_RIGHT, SEQCODE_OR, INDEXED(JOYCODE_X_RIGHT_SWITCH, 0)) ) | |
| 850 | INPUT_PORT_ANALOG_DEF ( 2, IPG_PLAYER2, DIAL, "Dial 2", SEQ_DEF_3(INDEXED(MOUSECODE_X, 1), SEQCODE_OR, INDEXED(JOYCODE_X, 1)), SEQ_DEF_3(KEYCODE_D, SEQCODE_OR, INDEXED(JOYCODE_X_LEFT_SWITCH, 1)), SEQ_DEF_3(KEYCODE_G, SEQCODE_OR, INDEXED(JOYCODE_X_RIGHT_SWITCH, 1)) ) | |
| 851 | INPUT_PORT_ANALOG_DEF ( 3, IPG_PLAYER3, DIAL, "Dial 3", SEQ_DEF_3(INDEXED(MOUSECODE_X, 2), SEQCODE_OR, INDEXED(JOYCODE_X, 2)), SEQ_DEF_3(KEYCODE_J, SEQCODE_OR, INDEXED(JOYCODE_X_LEFT_SWITCH, 2)), SEQ_DEF_3(KEYCODE_L, SEQCODE_OR, INDEXED(JOYCODE_X_RIGHT_SWITCH, 2)) ) | |
| 852 | INPUT_PORT_ANALOG_DEF ( 4, IPG_PLAYER4, DIAL, "Dial 4", SEQ_DEF_3(INDEXED(MOUSECODE_X, 3), SEQCODE_OR, INDEXED(JOYCODE_X, 3)), SEQ_DEF_1(INDEXED(JOYCODE_X_LEFT_SWITCH, 3)), SEQ_DEF_1(INDEXED(JOYCODE_X_RIGHT_SWITCH, 3)) ) | |
| 853 | INPUT_PORT_ANALOG_DEF ( 5, IPG_PLAYER5, DIAL, "Dial 5", SEQ_DEF_3(INDEXED(MOUSECODE_X, 4), SEQCODE_OR, INDEXED(JOYCODE_X, 4)), SEQ_DEF_1(INDEXED(JOYCODE_X_LEFT_SWITCH, 4)), SEQ_DEF_1(INDEXED(JOYCODE_X_RIGHT_SWITCH, 4)) ) | |
| 854 | INPUT_PORT_ANALOG_DEF ( 6, IPG_PLAYER6, DIAL, "Dial 6", SEQ_DEF_3(INDEXED(MOUSECODE_X, 5), SEQCODE_OR, INDEXED(JOYCODE_X, 5)), SEQ_DEF_1(INDEXED(JOYCODE_X_LEFT_SWITCH, 5)), SEQ_DEF_1(INDEXED(JOYCODE_X_RIGHT_SWITCH, 5)) ) | |
| 855 | INPUT_PORT_ANALOG_DEF ( 7, IPG_PLAYER7, DIAL, "Dial 7", SEQ_DEF_3(INDEXED(MOUSECODE_X, 6), SEQCODE_OR, INDEXED(JOYCODE_X, 6)), SEQ_DEF_1(INDEXED(JOYCODE_X_LEFT_SWITCH, 6)), SEQ_DEF_1(INDEXED(JOYCODE_X_RIGHT_SWITCH, 6)) ) | |
| 856 | INPUT_PORT_ANALOG_DEF ( 8, IPG_PLAYER8, DIAL, "Dial 8", SEQ_DEF_3(INDEXED(MOUSECODE_X, 7), SEQCODE_OR, INDEXED(JOYCODE_X, 7)), SEQ_DEF_1(INDEXED(JOYCODE_X_LEFT_SWITCH, 7)), SEQ_DEF_1(INDEXED(JOYCODE_X_RIGHT_SWITCH, 7)) ) | |
| 636 | /* open playback and record files if specified */ | |
| 637 | basetime = playback_init(machine); | |
| 638 | record_init(machine); | |
| 857 | 639 | |
| 858 | INPUT_PORT_ANALOG_DEF ( 1, IPG_PLAYER1, DIAL_V, "Dial V", SEQ_DEF_3(INDEXED(MOUSECODE_Y, 0), SEQCODE_OR, INDEXED(JOYCODE_Y, 0)), SEQ_DEF_3(KEYCODE_UP, SEQCODE_OR, INDEXED(JOYCODE_Y_UP_SWITCH, 0)), SEQ_DEF_3(KEYCODE_DOWN, SEQCODE_OR, INDEXED(JOYCODE_Y_DOWN_SWITCH, 0)) ) | |
| 859 | INPUT_PORT_ANALOG_DEF ( 2, IPG_PLAYER2, DIAL_V, "Dial V 2", SEQ_DEF_3(INDEXED(MOUSECODE_Y, 1), SEQCODE_OR, INDEXED(JOYCODE_Y, 1)), SEQ_DEF_3(KEYCODE_R, SEQCODE_OR, INDEXED(JOYCODE_Y_UP_SWITCH, 1)), SEQ_DEF_3(KEYCODE_F, SEQCODE_OR, INDEXED(JOYCODE_Y_DOWN_SWITCH, 1)) ) | |
| 860 | INPUT_PORT_ANALOG_DEF ( 3, IPG_PLAYER3, DIAL_V, "Dial V 3", SEQ_DEF_3(INDEXED(MOUSECODE_Y, 2), SEQCODE_OR, INDEXED(JOYCODE_Y, 2)), SEQ_DEF_3(KEYCODE_I, SEQCODE_OR, INDEXED(JOYCODE_Y_UP_SWITCH, 2)), SEQ_DEF_3(KEYCODE_K, SEQCODE_OR, INDEXED(JOYCODE_Y_DOWN_SWITCH, 2)) ) | |
| 861 | INPUT_PORT_ANALOG_DEF ( 4, IPG_PLAYER4, DIAL_V, "Dial V 4", SEQ_DEF_3(INDEXED(MOUSECODE_Y, 3), SEQCODE_OR, INDEXED(JOYCODE_Y, 3)), SEQ_DEF_1(INDEXED(JOYCODE_Y_UP_SWITCH, 3)), SEQ_DEF_1(INDEXED(JOYCODE_Y_DOWN_SWITCH, 3)) ) | |
| 862 | INPUT_PORT_ANALOG_DEF ( 5, IPG_PLAYER5, DIAL_V, "Dial V 5", SEQ_DEF_3(INDEXED(MOUSECODE_Y, 4), SEQCODE_OR, INDEXED(JOYCODE_Y, 4)), SEQ_DEF_1(INDEXED(JOYCODE_Y_UP_SWITCH, 4)), SEQ_DEF_1(INDEXED(JOYCODE_Y_DOWN_SWITCH, 4)) ) | |
| 863 | INPUT_PORT_ANALOG_DEF ( 6, IPG_PLAYER6, DIAL_V, "Dial V 6", SEQ_DEF_3(INDEXED(MOUSECODE_Y, 5), SEQCODE_OR, INDEXED(JOYCODE_Y, 5)), SEQ_DEF_1(INDEXED(JOYCODE_Y_UP_SWITCH, 5)), SEQ_DEF_1(INDEXED(JOYCODE_Y_DOWN_SWITCH, 5)) ) | |
| 864 | INPUT_PORT_ANALOG_DEF ( 7, IPG_PLAYER7, DIAL_V, "Dial V 7", SEQ_DEF_3(INDEXED(MOUSECODE_Y, 6), SEQCODE_OR, INDEXED(JOYCODE_Y, 6)), SEQ_DEF_1(INDEXED(JOYCODE_Y_UP_SWITCH, 6)), SEQ_DEF_1(INDEXED(JOYCODE_Y_DOWN_SWITCH, 6)) ) | |
| 865 | INPUT_PORT_ANALOG_DEF ( 8, IPG_PLAYER8, DIAL_V, "Dial V 8", SEQ_DEF_3(INDEXED(MOUSECODE_Y, 7), SEQCODE_OR, INDEXED(JOYCODE_Y, 7)), SEQ_DEF_1(INDEXED(JOYCODE_Y_UP_SWITCH, 7)), SEQ_DEF_1(INDEXED(JOYCODE_Y_DOWN_SWITCH, 7)) ) | |
| 640 | return basetime; | |
| 641 | } | |
| 866 | 642 | |
| 867 | INPUT_PORT_ANALOG_DEF ( 1, IPG_PLAYER1, TRACKBALL_X, "Track X", SEQ_DEF_3(INDEXED(MOUSECODE_X, 0), SEQCODE_OR, INDEXED(JOYCODE_X, 0)), SEQ_DEF_3(KEYCODE_LEFT, SEQCODE_OR, INDEXED(JOYCODE_X_LEFT_SWITCH, 0)), SEQ_DEF_3(KEYCODE_RIGHT, SEQCODE_OR, INDEXED(JOYCODE_X_RIGHT_SWITCH, 0)) ) | |
| 868 | INPUT_PORT_ANALOG_DEF ( 2, IPG_PLAYER2, TRACKBALL_X, "Track X 2", SEQ_DEF_3(INDEXED(MOUSECODE_X, 1), SEQCODE_OR, INDEXED(JOYCODE_X, 1)), SEQ_DEF_3(KEYCODE_D, SEQCODE_OR, INDEXED(JOYCODE_X_LEFT_SWITCH, 1)), SEQ_DEF_3(KEYCODE_G, SEQCODE_OR, INDEXED(JOYCODE_X_RIGHT_SWITCH, 1)) ) | |
| 869 | INPUT_PORT_ANALOG_DEF ( 3, IPG_PLAYER3, TRACKBALL_X, "Track X 3", SEQ_DEF_3(INDEXED(MOUSECODE_X, 2), SEQCODE_OR, INDEXED(JOYCODE_X, 2)), SEQ_DEF_3(KEYCODE_J, SEQCODE_OR, INDEXED(JOYCODE_X_LEFT_SWITCH, 2)), SEQ_DEF_3(KEYCODE_L, SEQCODE_OR, INDEXED(JOYCODE_X_RIGHT_SWITCH, 2)) ) | |
| 870 | INPUT_PORT_ANALOG_DEF ( 4, IPG_PLAYER4, TRACKBALL_X, "Track X 4", SEQ_DEF_3(INDEXED(MOUSECODE_X, 3), SEQCODE_OR, INDEXED(JOYCODE_X, 3)), SEQ_DEF_1(INDEXED(JOYCODE_X_LEFT_SWITCH, 3)), SEQ_DEF_1(INDEXED(JOYCODE_X_RIGHT_SWITCH, 3)) ) | |
| 871 | INPUT_PORT_ANALOG_DEF ( 5, IPG_PLAYER5, TRACKBALL_X, "Track X 5", SEQ_DEF_3(INDEXED(MOUSECODE_X, 4), SEQCODE_OR, INDEXED(JOYCODE_X, 4)), SEQ_DEF_1(INDEXED(JOYCODE_X_LEFT_SWITCH, 4)), SEQ_DEF_1(INDEXED(JOYCODE_X_RIGHT_SWITCH, 4)) ) | |
| 872 | INPUT_PORT_ANALOG_DEF ( 6, IPG_PLAYER6, TRACKBALL_X, "Track X 6", SEQ_DEF_3(INDEXED(MOUSECODE_X, 5), SEQCODE_OR, INDEXED(JOYCODE_X, 5)), SEQ_DEF_1(INDEXED(JOYCODE_X_LEFT_SWITCH, 5)), SEQ_DEF_1(INDEXED(JOYCODE_X_RIGHT_SWITCH, 5)) ) | |
| 873 | INPUT_PORT_ANALOG_DEF ( 7, IPG_PLAYER7, TRACKBALL_X, "Track X 7", SEQ_DEF_3(INDEXED(MOUSECODE_X, 6), SEQCODE_OR, INDEXED(JOYCODE_X, 6)), SEQ_DEF_1(INDEXED(JOYCODE_X_LEFT_SWITCH, 6)), SEQ_DEF_1(INDEXED(JOYCODE_X_RIGHT_SWITCH, 6)) ) | |
| 874 | INPUT_PORT_ANALOG_DEF ( 8, IPG_PLAYER8, TRACKBALL_X, "Track X 8", SEQ_DEF_3(INDEXED(MOUSECODE_X, 7), SEQCODE_OR, INDEXED(JOYCODE_X, 7)), SEQ_DEF_1(INDEXED(JOYCODE_X_LEFT_SWITCH, 7)), SEQ_DEF_1(INDEXED(JOYCODE_X_RIGHT_SWITCH, 7)) ) | |
| 875 | 643 | |
| 876 | INPUT_PORT_ANALOG_DEF ( 1, IPG_PLAYER1, TRACKBALL_Y, "Track Y", SEQ_DEF_3(INDEXED(MOUSECODE_Y, 0), SEQCODE_OR, INDEXED(JOYCODE_Y, 0)), SEQ_DEF_3(KEYCODE_UP, SEQCODE_OR, INDEXED(JOYCODE_Y_UP_SWITCH, 0)), SEQ_DEF_3(KEYCODE_DOWN, SEQCODE_OR, INDEXED(JOYCODE_Y_DOWN_SWITCH, 0)) ) | |
| 877 | INPUT_PORT_ANALOG_DEF ( 2, IPG_PLAYER2, TRACKBALL_Y, "Track Y 2", SEQ_DEF_3(INDEXED(MOUSECODE_Y, 1), SEQCODE_OR, INDEXED(JOYCODE_Y, 1)), SEQ_DEF_3(KEYCODE_R, SEQCODE_OR, INDEXED(JOYCODE_Y_UP_SWITCH, 1)), SEQ_DEF_3(KEYCODE_F, SEQCODE_OR, INDEXED(JOYCODE_Y_DOWN_SWITCH, 1)) ) | |
| 878 | INPUT_PORT_ANALOG_DEF ( 3, IPG_PLAYER3, TRACKBALL_Y, "Track Y 3", SEQ_DEF_3(INDEXED(MOUSECODE_Y, 2), SEQCODE_OR, INDEXED(JOYCODE_Y, 2)), SEQ_DEF_3(KEYCODE_I, SEQCODE_OR, INDEXED(JOYCODE_Y_UP_SWITCH, 2)), SEQ_DEF_3(KEYCODE_K, SEQCODE_OR, INDEXED(JOYCODE_Y_DOWN_SWITCH, 2)) ) | |
| 879 | INPUT_PORT_ANALOG_DEF ( 4, IPG_PLAYER4, TRACKBALL_Y, "Track Y 4", SEQ_DEF_3(INDEXED(MOUSECODE_Y, 3), SEQCODE_OR, INDEXED(JOYCODE_Y, 3)), SEQ_DEF_1(INDEXED(JOYCODE_Y_UP_SWITCH, 3)), SEQ_DEF_1(INDEXED(JOYCODE_Y_DOWN_SWITCH, 3)) ) | |
| 880 | INPUT_PORT_ANALOG_DEF ( 5, IPG_PLAYER5, TRACKBALL_Y, "Track Y 5", SEQ_DEF_3(INDEXED(MOUSECODE_Y, 4), SEQCODE_OR, INDEXED(JOYCODE_Y, 4)), SEQ_DEF_1(INDEXED(JOYCODE_Y_UP_SWITCH, 4)), SEQ_DEF_1(INDEXED(JOYCODE_Y_DOWN_SWITCH, 4)) ) | |
| 881 | INPUT_PORT_ANALOG_DEF ( 6, IPG_PLAYER6, TRACKBALL_Y, "Track Y 6", SEQ_DEF_3(INDEXED(MOUSECODE_Y, 5), SEQCODE_OR, INDEXED(JOYCODE_Y, 5)), SEQ_DEF_1(INDEXED(JOYCODE_Y_UP_SWITCH, 5)), SEQ_DEF_1(INDEXED(JOYCODE_Y_DOWN_SWITCH, 5)) ) | |
| 882 | INPUT_PORT_ANALOG_DEF ( 7, IPG_PLAYER7, TRACKBALL_Y, "Track Y 7", SEQ_DEF_3(INDEXED(MOUSECODE_Y, 6), SEQCODE_OR, INDEXED(JOYCODE_Y, 6)), SEQ_DEF_1(INDEXED(JOYCODE_Y_UP_SWITCH, 6)), SEQ_DEF_1(INDEXED(JOYCODE_Y_DOWN_SWITCH, 6)) ) | |
| 883 | INPUT_PORT_ANALOG_DEF ( 8, IPG_PLAYER8, TRACKBALL_Y, "Track Y 8", SEQ_DEF_3(INDEXED(MOUSECODE_Y, 7), SEQCODE_OR, INDEXED(JOYCODE_Y, 7)), SEQ_DEF_1(INDEXED(JOYCODE_Y_UP_SWITCH, 7)), SEQ_DEF_1(INDEXED(JOYCODE_Y_DOWN_SWITCH, 7)) ) | |
| 644 | /*------------------------------------------------- | |
| 645 | input_port_exit - exit callback to ensure | |
| 646 | we clean up and close our files | |
| 647 | -------------------------------------------------*/ | |
| 884 | 648 | |
| 885 | INPUT_PORT_ANALOG_DEF ( 1, IPG_PLAYER1, AD_STICK_X, "AD Stick X", SEQ_DEF_3(INDEXED(JOYCODE_X, 0), SEQCODE_OR, INDEXED(MOUSECODE_X, 0)), SEQ_DEF_3(KEYCODE_LEFT, SEQCODE_OR, INDEXED(JOYCODE_X_LEFT_SWITCH, 0)), SEQ_DEF_3(KEYCODE_RIGHT, SEQCODE_OR, INDEXED(JOYCODE_X_RIGHT_SWITCH, 0)) ) | |
| 886 | INPUT_PORT_ANALOG_DEF ( 2, IPG_PLAYER2, AD_STICK_X, "AD Stick X 2", SEQ_DEF_3(INDEXED(JOYCODE_X, 1), SEQCODE_OR, INDEXED(MOUSECODE_X, 1)), SEQ_DEF_3(KEYCODE_D, SEQCODE_OR, INDEXED(JOYCODE_X_LEFT_SWITCH, 1)), SEQ_DEF_3(KEYCODE_G, SEQCODE_OR, INDEXED(JOYCODE_X_RIGHT_SWITCH, 1)) ) | |
| 887 | INPUT_PORT_ANALOG_DEF ( 3, IPG_PLAYER3, AD_STICK_X, "AD Stick X 3", SEQ_DEF_3(INDEXED(JOYCODE_X, 2), SEQCODE_OR, INDEXED(MOUSECODE_X, 2)), SEQ_DEF_3(KEYCODE_J, SEQCODE_OR, INDEXED(JOYCODE_X_LEFT_SWITCH, 2)), SEQ_DEF_3(KEYCODE_L, SEQCODE_OR, INDEXED(JOYCODE_X_RIGHT_SWITCH, 2)) ) | |
| 888 | INPUT_PORT_ANALOG_DEF ( 4, IPG_PLAYER4, AD_STICK_X, "AD Stick X 4", SEQ_DEF_3(INDEXED(JOYCODE_X, 3), SEQCODE_OR, INDEXED(MOUSECODE_X, 3)), SEQ_DEF_1(INDEXED(JOYCODE_X_LEFT_SWITCH, 3)), SEQ_DEF_1(INDEXED(JOYCODE_X_RIGHT_SWITCH, 3)) ) | |
| 889 | INPUT_PORT_ANALOG_DEF ( 5, IPG_PLAYER5, AD_STICK_X, "AD Stick X 5", SEQ_DEF_3(INDEXED(JOYCODE_X, 4), SEQCODE_OR, INDEXED(MOUSECODE_X, 4)), SEQ_DEF_1(INDEXED(JOYCODE_X_LEFT_SWITCH, 4)), SEQ_DEF_1(INDEXED(JOYCODE_X_RIGHT_SWITCH, 4)) ) | |
| 890 | INPUT_PORT_ANALOG_DEF ( 6, IPG_PLAYER6, AD_STICK_X, "AD Stick X 6", SEQ_DEF_3(INDEXED(JOYCODE_X, 5), SEQCODE_OR, INDEXED(MOUSECODE_X, 5)), SEQ_DEF_1(INDEXED(JOYCODE_X_LEFT_SWITCH, 5)), SEQ_DEF_1(INDEXED(JOYCODE_X_RIGHT_SWITCH, 5)) ) | |
| 891 | INPUT_PORT_ANALOG_DEF ( 7, IPG_PLAYER7, AD_STICK_X, "AD Stick X 7", SEQ_DEF_3(INDEXED(JOYCODE_X, 6), SEQCODE_OR, INDEXED(MOUSECODE_X, 6)), SEQ_DEF_1(INDEXED(JOYCODE_X_LEFT_SWITCH, 6)), SEQ_DEF_1(INDEXED(JOYCODE_X_RIGHT_SWITCH, 6)) ) | |
| 892 | INPUT_PORT_ANALOG_DEF ( 8, IPG_PLAYER8, AD_STICK_X, "AD Stick X 8", SEQ_DEF_3(INDEXED(JOYCODE_X, 7), SEQCODE_OR, INDEXED(MOUSECODE_X, 7)), SEQ_DEF_1(INDEXED(JOYCODE_X_LEFT_SWITCH, 7)), SEQ_DEF_1(INDEXED(JOYCODE_X_RIGHT_SWITCH, 7)) ) | |
| 649 | static void input_port_exit(running_machine *machine) | |
| 650 | { | |
| 651 | /* close any playback or recording files */ | |
| 652 | playback_end(machine, NULL); | |
| 653 | record_end(machine, NULL); | |
| 893 | 654 | |
| 894 | INPUT_PORT_ANALOG_DEF ( 1, IPG_PLAYER1, AD_STICK_Y, "AD Stick Y", SEQ_DEF_3(INDEXED(JOYCODE_Y, 0), SEQCODE_OR, INDEXED(MOUSECODE_Y, 0)), SEQ_DEF_3(KEYCODE_UP, SEQCODE_OR, INDEXED(JOYCODE_Y_UP_SWITCH, 0)), SEQ_DEF_3(KEYCODE_DOWN, SEQCODE_OR, INDEXED(JOYCODE_Y_DOWN_SWITCH, 0)) ) | |
| 895 | INPUT_PORT_ANALOG_DEF ( 2, IPG_PLAYER2, AD_STICK_Y, "AD Stick Y 2", SEQ_DEF_3(INDEXED(JOYCODE_Y, 1), SEQCODE_OR, INDEXED(MOUSECODE_Y, 1)), SEQ_DEF_3(KEYCODE_R, SEQCODE_OR, INDEXED(JOYCODE_Y_UP_SWITCH, 1)), SEQ_DEF_3(KEYCODE_F, SEQCODE_OR, INDEXED(JOYCODE_Y_DOWN_SWITCH, 1)) ) | |
| 896 | INPUT_PORT_ANALOG_DEF ( 3, IPG_PLAYER3, AD_STICK_Y, "AD Stick Y 3", SEQ_DEF_3(INDEXED(JOYCODE_Y, 2), SEQCODE_OR, INDEXED(MOUSECODE_Y, 2)), SEQ_DEF_3(KEYCODE_I, SEQCODE_OR, INDEXED(JOYCODE_Y_UP_SWITCH, 2)), SEQ_DEF_3(KEYCODE_K, SEQCODE_OR, INDEXED(JOYCODE_Y_DOWN_SWITCH, 2)) ) | |
| 897 | INPUT_PORT_ANALOG_DEF ( 4, IPG_PLAYER4, AD_STICK_Y, "AD Stick Y 4", SEQ_DEF_3(INDEXED(JOYCODE_Y, 3), SEQCODE_OR, INDEXED(MOUSECODE_Y, 3)), SEQ_DEF_1(INDEXED(JOYCODE_Y_UP_SWITCH, 3)), SEQ_DEF_1(INDEXED(JOYCODE_Y_DOWN_SWITCH, 3)) ) | |
| 898 | INPUT_PORT_ANALOG_DEF ( 5, IPG_PLAYER5, AD_STICK_Y, "AD Stick Y 5", SEQ_DEF_3(INDEXED(JOYCODE_Y, 4), SEQCODE_OR, INDEXED(MOUSECODE_Y, 4)), SEQ_DEF_1(INDEXED(JOYCODE_Y_UP_SWITCH, 4)), SEQ_DEF_1(INDEXED(JOYCODE_Y_DOWN_SWITCH, 4)) ) | |
| 899 | INPUT_PORT_ANALOG_DEF ( 6, IPG_PLAYER6, AD_STICK_Y, "AD Stick Y 6", SEQ_DEF_3(INDEXED(JOYCODE_Y, 5), SEQCODE_OR, INDEXED(MOUSECODE_Y, 5)), SEQ_DEF_1(INDEXED(JOYCODE_Y_UP_SWITCH, 5)), SEQ_DEF_1(INDEXED(JOYCODE_Y_DOWN_SWITCH, 5)) ) | |
| 900 | INPUT_PORT_ANALOG_DEF ( 7, IPG_PLAYER7, AD_STICK_Y, "AD Stick Y 7", SEQ_DEF_3(INDEXED(JOYCODE_Y, 6), SEQCODE_OR, INDEXED(MOUSECODE_Y, 6)), SEQ_DEF_1(INDEXED(JOYCODE_Y_UP_SWITCH, 6)), SEQ_DEF_1(INDEXED(JOYCODE_Y_DOWN_SWITCH, 6)) ) | |
| 901 | INPUT_PORT_ANALOG_DEF ( 8, IPG_PLAYER8, AD_STICK_Y, "AD Stick Y 8", SEQ_DEF_3(INDEXED(JOYCODE_Y, 7), SEQCODE_OR, INDEXED(MOUSECODE_Y, 7)), SEQ_DEF_1(INDEXED(JOYCODE_Y_UP_SWITCH, 7)), SEQ_DEF_1(INDEXED(JOYCODE_Y_DOWN_SWITCH, 7)) ) | |
| 655 | /* free our allocated config */ | |
| 656 | if (machine->portconfig != NULL) | |
| 657 | input_port_config_free(machine->portconfig); | |
| 658 | } | |
| 902 | 659 | |
| 903 | INPUT_PORT_ANALOG_DEF ( 1, IPG_PLAYER1, AD_STICK_Z, "AD Stick Z", SEQ_DEF_1(INDEXED(JOYCODE_Z, 0)), SEQ_DEF_0, SEQ_DEF_0 ) | |
| 904 | INPUT_PORT_ANALOG_DEF ( 2, IPG_PLAYER2, AD_STICK_Z, "AD Stick Z 2", SEQ_DEF_1(INDEXED(JOYCODE_Z, 1)), SEQ_DEF_0, SEQ_DEF_0 ) | |
| 905 | INPUT_PORT_ANALOG_DEF ( 3, IPG_PLAYER3, AD_STICK_Z, "AD Stick Z 3", SEQ_DEF_1(INDEXED(JOYCODE_Z, 2)), SEQ_DEF_0, SEQ_DEF_0 ) | |
| 906 | INPUT_PORT_ANALOG_DEF ( 4, IPG_PLAYER4, AD_STICK_Z, "AD Stick Z 4", SEQ_DEF_1(INDEXED(JOYCODE_Z, 3)), SEQ_DEF_0, SEQ_DEF_0 ) | |
| 907 | INPUT_PORT_ANALOG_DEF ( 5, IPG_PLAYER5, AD_STICK_Z, "AD Stick Z 5", SEQ_DEF_1(INDEXED(JOYCODE_Z, 4)), SEQ_DEF_0, SEQ_DEF_0 ) | |
| 908 | INPUT_PORT_ANALOG_DEF ( 6, IPG_PLAYER6, AD_STICK_Z, "AD Stick Z 6", SEQ_DEF_1(INDEXED(JOYCODE_Z, 5)), SEQ_DEF_0, SEQ_DEF_0 ) | |
| 909 | INPUT_PORT_ANALOG_DEF ( 7, IPG_PLAYER7, AD_STICK_Z, "AD Stick Z 7", SEQ_DEF_1(INDEXED(JOYCODE_Z, 6)), SEQ_DEF_0, SEQ_DEF_0 ) | |
| 910 | INPUT_PORT_ANALOG_DEF ( 8, IPG_PLAYER8, AD_STICK_Z, "AD Stick Z 8", SEQ_DEF_1(INDEXED(JOYCODE_Z, 7)), SEQ_DEF_0, SEQ_DEF_0 ) | |
| 911 | 660 | |
| 912 | INPUT_PORT_ANALOG_DEF ( 1, IPG_PLAYER1, LIGHTGUN_X, "Lightgun X", SEQ_DEF_5(INDEXED(GUNCODE_X, 0), SEQCODE_OR, INDEXED(MOUSECODE_X, 0), SEQCODE_OR, INDEXED(JOYCODE_X, 0)), SEQ_DEF_3(KEYCODE_LEFT, SEQCODE_OR, INDEXED(JOYCODE_X_LEFT_SWITCH, 0)), SEQ_DEF_3(KEYCODE_RIGHT, SEQCODE_OR, INDEXED(JOYCODE_X_RIGHT_SWITCH, 0)) ) | |
| 913 | INPUT_PORT_ANALOG_DEF ( 2, IPG_PLAYER2, LIGHTGUN_X, "Lightgun X 2", SEQ_DEF_5(INDEXED(GUNCODE_X, 1), SEQCODE_OR, INDEXED(MOUSECODE_X, 1), SEQCODE_OR, INDEXED(JOYCODE_X, 1)), SEQ_DEF_3(KEYCODE_D, SEQCODE_OR, INDEXED(JOYCODE_X_LEFT_SWITCH, 1)), SEQ_DEF_3(KEYCODE_G, SEQCODE_OR, INDEXED(JOYCODE_X_RIGHT_SWITCH, 1)) ) | |
| 914 | INPUT_PORT_ANALOG_DEF ( 3, IPG_PLAYER3, LIGHTGUN_X, "Lightgun X 3", SEQ_DEF_5(INDEXED(GUNCODE_X, 2), SEQCODE_OR, INDEXED(MOUSECODE_X, 2), SEQCODE_OR, INDEXED(JOYCODE_X, 2)), SEQ_DEF_3(KEYCODE_J, SEQCODE_OR, INDEXED(JOYCODE_X_LEFT_SWITCH, 2)), SEQ_DEF_3(KEYCODE_L, SEQCODE_OR, INDEXED(JOYCODE_X_RIGHT_SWITCH, 2)) ) | |
| 915 | INPUT_PORT_ANALOG_DEF ( 4, IPG_PLAYER4, LIGHTGUN_X, "Lightgun X 4", SEQ_DEF_5(INDEXED(GUNCODE_X, 3), SEQCODE_OR, INDEXED(MOUSECODE_X, 3), SEQCODE_OR, INDEXED(JOYCODE_X, 3)), SEQ_DEF_1(INDEXED(JOYCODE_X_LEFT_SWITCH, 3)), SEQ_DEF_1(INDEXED(JOYCODE_X_RIGHT_SWITCH, 3)) ) | |
| 916 | INPUT_PORT_ANALOG_DEF ( 5, IPG_PLAYER5, LIGHTGUN_X, "Lightgun X 5", SEQ_DEF_5(INDEXED(GUNCODE_X, 4), SEQCODE_OR, INDEXED(MOUSECODE_X, 4), SEQCODE_OR, INDEXED(JOYCODE_X, 4)), SEQ_DEF_1(INDEXED(JOYCODE_X_LEFT_SWITCH, 4)), SEQ_DEF_1(INDEXED(JOYCODE_X_RIGHT_SWITCH, 4)) ) | |
| 917 | INPUT_PORT_ANALOG_DEF ( 6, IPG_PLAYER6, LIGHTGUN_X, "Lightgun X 6", SEQ_DEF_5(INDEXED(GUNCODE_X, 5), SEQCODE_OR, INDEXED(MOUSECODE_X, 5), SEQCODE_OR, INDEXED(JOYCODE_X, 5)), SEQ_DEF_1(INDEXED(JOYCODE_X_LEFT_SWITCH, 5)), SEQ_DEF_1(INDEXED(JOYCODE_X_RIGHT_SWITCH, 5)) ) | |
| 918 | INPUT_PORT_ANALOG_DEF ( 7, IPG_PLAYER7, LIGHTGUN_X, "Lightgun X 7", SEQ_DEF_5(INDEXED(GUNCODE_X, 6), SEQCODE_OR, INDEXED(MOUSECODE_X, 6), SEQCODE_OR, INDEXED(JOYCODE_X, 6)), SEQ_DEF_1(INDEXED(JOYCODE_X_LEFT_SWITCH, 6)), SEQ_DEF_1(INDEXED(JOYCODE_X_RIGHT_SWITCH, 6)) ) | |
| 919 | INPUT_PORT_ANALOG_DEF ( 8, IPG_PLAYER8, LIGHTGUN_X, "Lightgun X 8", SEQ_DEF_5(INDEXED(GUNCODE_X, 7), SEQCODE_OR, INDEXED(MOUSECODE_X, 7), SEQCODE_OR, INDEXED(JOYCODE_X, 7)), SEQ_DEF_1(INDEXED(JOYCODE_X_LEFT_SWITCH, 7)), SEQ_DEF_1(INDEXED(JOYCODE_X_RIGHT_SWITCH, 7)) ) | |
| 920 | 661 | |
| 921 | INPUT_PORT_ANALOG_DEF ( 1, IPG_PLAYER1, LIGHTGUN_Y, "Lightgun Y", SEQ_DEF_5(INDEXED(GUNCODE_Y, 0), SEQCODE_OR, INDEXED(MOUSECODE_Y, 0), SEQCODE_OR, INDEXED(JOYCODE_Y, 0)), SEQ_DEF_3(KEYCODE_UP, SEQCODE_OR, INDEXED(JOYCODE_Y_UP_SWITCH, 0)), SEQ_DEF_3(KEYCODE_DOWN, SEQCODE_OR, INDEXED(JOYCODE_Y_DOWN_SWITCH, 0)) ) | |
| 922 | INPUT_PORT_ANALOG_DEF ( 2, IPG_PLAYER2, LIGHTGUN_Y, "Lightgun Y 2", SEQ_DEF_5(INDEXED(GUNCODE_Y, 1), SEQCODE_OR, INDEXED(MOUSECODE_Y, 1), SEQCODE_OR, INDEXED(JOYCODE_Y, 1)), SEQ_DEF_3(KEYCODE_R, SEQCODE_OR, INDEXED(JOYCODE_Y_UP_SWITCH, 1)), SEQ_DEF_3(KEYCODE_F, SEQCODE_OR, INDEXED(JOYCODE_Y_DOWN_SWITCH, 1)) ) | |
| 923 | INPUT_PORT_ANALOG_DEF ( 3, IPG_PLAYER3, LIGHTGUN_Y, "Lightgun Y 3", SEQ_DEF_5(INDEXED(GUNCODE_Y, 2), SEQCODE_OR, INDEXED(MOUSECODE_Y, 2), SEQCODE_OR, INDEXED(JOYCODE_Y, 2)), SEQ_DEF_3(KEYCODE_I, SEQCODE_OR, INDEXED(JOYCODE_Y_UP_SWITCH, 2)), SEQ_DEF_3(KEYCODE_K, SEQCODE_OR, INDEXED(JOYCODE_Y_DOWN_SWITCH, 2)) ) | |
| 924 | INPUT_PORT_ANALOG_DEF ( 4, IPG_PLAYER4, LIGHTGUN_Y, "Lightgun Y 4", SEQ_DEF_5(INDEXED(GUNCODE_Y, 3), SEQCODE_OR, INDEXED(MOUSECODE_Y, 3), SEQCODE_OR, INDEXED(JOYCODE_Y, 3)), SEQ_DEF_1(INDEXED(JOYCODE_Y_UP_SWITCH, 3)), SEQ_DEF_1(INDEXED(JOYCODE_Y_DOWN_SWITCH, 3)) ) | |
| 925 | INPUT_PORT_ANALOG_DEF ( 5, IPG_PLAYER5, LIGHTGUN_Y, "Lightgun Y 5", SEQ_DEF_5(INDEXED(GUNCODE_Y, 4), SEQCODE_OR, INDEXED(MOUSECODE_Y, 4), SEQCODE_OR, INDEXED(JOYCODE_Y, 4)), SEQ_DEF_1(INDEXED(JOYCODE_Y_UP_SWITCH, 4)), SEQ_DEF_1(INDEXED(JOYCODE_Y_DOWN_SWITCH, 4)) ) | |
| 926 | INPUT_PORT_ANALOG_DEF ( 6, IPG_PLAYER6, LIGHTGUN_Y, "Lightgun Y 6", SEQ_DEF_5(INDEXED(GUNCODE_Y, 5), SEQCODE_OR, INDEXED(MOUSECODE_Y, 5), SEQCODE_OR, INDEXED(JOYCODE_Y, 5)), SEQ_DEF_1(INDEXED(JOYCODE_Y_UP_SWITCH, 5)), SEQ_DEF_1(INDEXED(JOYCODE_Y_DOWN_SWITCH, 5)) ) | |
| 927 | INPUT_PORT_ANALOG_DEF ( 7, IPG_PLAYER7, LIGHTGUN_Y, "Lightgun Y 7", SEQ_DEF_5(INDEXED(GUNCODE_Y, 6), SEQCODE_OR, INDEXED(MOUSECODE_Y, 6), SEQCODE_OR, INDEXED(JOYCODE_Y, 6)), SEQ_DEF_1(INDEXED(JOYCODE_Y_UP_SWITCH, 6)), SEQ_DEF_1(INDEXED(JOYCODE_Y_DOWN_SWITCH, 6)) ) | |
| 928 | INPUT_PORT_ANALOG_DEF ( 8, IPG_PLAYER8, LIGHTGUN_Y, "Lightgun Y 8", SEQ_DEF_5(INDEXED(GUNCODE_Y, 7), SEQCODE_OR, INDEXED(MOUSECODE_Y, 7), SEQCODE_OR, INDEXED(JOYCODE_Y, 7)), SEQ_DEF_1(INDEXED(JOYCODE_Y_UP_SWITCH, 7)), SEQ_DEF_1(INDEXED(JOYCODE_Y_DOWN_SWITCH, 7)) ) | |
| 662 | /*************************************************************************** | |
| 663 | PORT CONFIGURATIONS | |
| 664 | ***************************************************************************/ | |
| 929 | 665 | |
| 930 | INPUT_PORT_ANALOG_DEF ( 1, IPG_PLAYER1, MOUSE_X, "Mouse X", SEQ_DEF_1(INDEXED(MOUSECODE_X, 0)), SEQ_DEF_3(KEYCODE_LEFT, SEQCODE_OR, INDEXED(JOYCODE_X_LEFT_SWITCH, 0)), SEQ_DEF_3(KEYCODE_RIGHT, SEQCODE_OR, INDEXED(JOYCODE_X_RIGHT_SWITCH, 0)) ) | |
| 931 | INPUT_PORT_ANALOG_DEF ( 2, IPG_PLAYER2, MOUSE_X, "Mouse X 2", SEQ_DEF_1(INDEXED(MOUSECODE_X, 1)), SEQ_DEF_3(KEYCODE_D, SEQCODE_OR, INDEXED(JOYCODE_X_LEFT_SWITCH, 1)), SEQ_DEF_3(KEYCODE_G, SEQCODE_OR, INDEXED(JOYCODE_X_RIGHT_SWITCH, 1)) ) | |
| 932 | INPUT_PORT_ANALOG_DEF ( 3, IPG_PLAYER3, MOUSE_X, "Mouse X 3", SEQ_DEF_1(INDEXED(MOUSECODE_X, 2)), SEQ_DEF_3(KEYCODE_J, SEQCODE_OR, INDEXED(JOYCODE_X_LEFT_SWITCH, 2)), SEQ_DEF_3(KEYCODE_L, SEQCODE_OR, INDEXED(JOYCODE_X_RIGHT_SWITCH, 2)) ) | |
| 933 | INPUT_PORT_ANALOG_DEF ( 4, IPG_PLAYER4, MOUSE_X, "Mouse X 4", SEQ_DEF_1(INDEXED(MOUSECODE_X, 3)), SEQ_DEF_1(INDEXED(JOYCODE_X_LEFT_SWITCH, 3)), SEQ_DEF_1(INDEXED(JOYCODE_X_RIGHT_SWITCH, 3)) ) | |
| 934 | INPUT_PORT_ANALOG_DEF ( 5, IPG_PLAYER5, MOUSE_X, "Mouse X 5", SEQ_DEF_1(INDEXED(MOUSECODE_X, 4)), SEQ_DEF_1(INDEXED(JOYCODE_X_LEFT_SWITCH, 4)), SEQ_DEF_1(INDEXED(JOYCODE_X_RIGHT_SWITCH, 4)) ) | |
| 935 | INPUT_PORT_ANALOG_DEF ( 6, IPG_PLAYER6, MOUSE_X, "Mouse X 6", SEQ_DEF_1(INDEXED(MOUSECODE_X, 5)), SEQ_DEF_1(INDEXED(JOYCODE_X_LEFT_SWITCH, 5)), SEQ_DEF_1(INDEXED(JOYCODE_X_RIGHT_SWITCH, 5)) ) | |
| 936 | INPUT_PORT_ANALOG_DEF ( 7, IPG_PLAYER7, MOUSE_X, "Mouse X 7", SEQ_DEF_1(INDEXED(MOUSECODE_X, 6)), SEQ_DEF_1(INDEXED(JOYCODE_X_LEFT_SWITCH, 6)), SEQ_DEF_1(INDEXED(JOYCODE_X_RIGHT_SWITCH, 6)) ) | |
| 937 | INPUT_PORT_ANALOG_DEF ( 8, IPG_PLAYER8, MOUSE_X, "Mouse X 8", SEQ_DEF_1(INDEXED(MOUSECODE_X, 7)), SEQ_DEF_1(INDEXED(JOYCODE_X_LEFT_SWITCH, 7)), SEQ_DEF_1(INDEXED(JOYCODE_X_RIGHT_SWITCH, 7)) ) | |
| 666 | /*------------------------------------------------- | |
| 667 | input_port_config_alloc - allocate a list of | |
| 668 | input ports from the given token list | |
| 669 | -------------------------------------------------*/ | |
| 938 | 670 | |
| 939 | INPUT_PORT_ANALOG_DEF ( 1, IPG_PLAYER1, MOUSE_Y, "Mouse Y", SEQ_DEF_1(INDEXED(MOUSECODE_Y, 0)), SEQ_DEF_3(KEYCODE_UP, SEQCODE_OR, INDEXED(JOYCODE_Y_UP_SWITCH, 0)), SEQ_DEF_3(KEYCODE_DOWN, SEQCODE_OR, INDEXED(JOYCODE_Y_DOWN_SWITCH, 0)) ) | |
| 940 | INPUT_PORT_ANALOG_DEF ( 2, IPG_PLAYER2, MOUSE_Y, "Mouse Y 2", SEQ_DEF_1(INDEXED(MOUSECODE_Y, 1)), SEQ_DEF_3(KEYCODE_R, SEQCODE_OR, INDEXED(JOYCODE_Y_UP_SWITCH, 1)), SEQ_DEF_3(KEYCODE_F, SEQCODE_OR, INDEXED(JOYCODE_Y_DOWN_SWITCH, 1)) ) | |
| 941 | INPUT_PORT_ANALOG_DEF ( 3, IPG_PLAYER3, MOUSE_Y, "Mouse Y 3", SEQ_DEF_1(INDEXED(MOUSECODE_Y, 2)), SEQ_DEF_3(KEYCODE_I, SEQCODE_OR, INDEXED(JOYCODE_Y_UP_SWITCH, 2)), SEQ_DEF_3(KEYCODE_K, SEQCODE_OR, INDEXED(JOYCODE_Y_DOWN_SWITCH, 2)) ) | |
| 942 | INPUT_PORT_ANALOG_DEF ( 4, IPG_PLAYER4, MOUSE_Y, "Mouse Y 4", SEQ_DEF_1(INDEXED(MOUSECODE_Y, 3)), SEQ_DEF_1(INDEXED(JOYCODE_Y_UP_SWITCH, 3)), SEQ_DEF_1(INDEXED(JOYCODE_Y_DOWN_SWITCH, 3)) ) | |
| 943 | INPUT_PORT_ANALOG_DEF ( 5, IPG_PLAYER5, MOUSE_Y, "Mouse Y 5", SEQ_DEF_1(INDEXED(MOUSECODE_Y, 4)), SEQ_DEF_1(INDEXED(JOYCODE_Y_UP_SWITCH, 4)), SEQ_DEF_1(INDEXED(JOYCODE_Y_DOWN_SWITCH, 4)) ) | |
| 944 | INPUT_PORT_ANALOG_DEF ( 6, IPG_PLAYER6, MOUSE_Y, "Mouse Y 6", SEQ_DEF_1(INDEXED(MOUSECODE_Y, 5)), SEQ_DEF_1(INDEXED(JOYCODE_Y_UP_SWITCH, 5)), SEQ_DEF_1(INDEXED(JOYCODE_Y_DOWN_SWITCH, 5)) ) | |
| 945 | INPUT_PORT_ANALOG_DEF ( 7, IPG_PLAYER7, MOUSE_Y, "Mouse Y 7", SEQ_DEF_1(INDEXED(MOUSECODE_Y, 6)), SEQ_DEF_1(INDEXED(JOYCODE_Y_UP_SWITCH, 6)), SEQ_DEF_1(INDEXED(JOYCODE_Y_DOWN_SWITCH, 6)) ) | |
| 946 | INPUT_PORT_ANALOG_DEF ( 8, IPG_PLAYER8, MOUSE_Y, "Mouse Y 8", SEQ_DEF_1(INDEXED(MOUSECODE_Y, 7)), SEQ_DEF_1(INDEXED(JOYCODE_Y_UP_SWITCH, 7)), SEQ_DEF_1(INDEXED(JOYCODE_Y_DOWN_SWITCH, 7)) ) | |
| 671 | const input_port_config *input_port_config_alloc(const input_port_token *tokens) | |
| 672 | { | |
| 673 | return port_config_detokenize(NULL, tokens); | |
| 674 | } | |
| 947 | 675 | |
| 948 | INPUT_PORT_DIGITAL_DEF( 0, IPG_OTHER, KEYBOARD, "Keyboard", SEQ_DEF_0 ) | |
| 949 | 676 | |
| 950 | INPUT_PORT_DIGITAL_DEF( 0, IPG_UI, UI_ON_SCREEN_DISPLAY,"On Screen Display", SEQ_DEF_1(KEYCODE_TILDE) ) | |
| 951 | INPUT_PORT_DIGITAL_DEF( 0, IPG_UI, UI_DEBUG_BREAK, "Break in Debugger", SEQ_DEF_1(KEYCODE_TILDE) ) | |
| 952 | INPUT_PORT_DIGITAL_DEF( 0, IPG_UI, UI_CONFIGURE, "Config Menu", SEQ_DEF_1(KEYCODE_TAB) ) | |
| 953 | INPUT_PORT_DIGITAL_DEF( 0, IPG_UI, UI_PAUSE, "Pause", SEQ_DEF_1(KEYCODE_P) ) | |
| 954 | INPUT_PORT_DIGITAL_DEF( 0, IPG_UI, UI_RESET_MACHINE, "Reset Game", SEQ_DEF_2(KEYCODE_F3, KEYCODE_LSHIFT) ) | |
| 955 | INPUT_PORT_DIGITAL_DEF( 0, IPG_UI, UI_SOFT_RESET, "Soft Reset", SEQ_DEF_3(KEYCODE_F3, SEQCODE_NOT, KEYCODE_LSHIFT) ) | |
| 956 | INPUT_PORT_DIGITAL_DEF( 0, IPG_UI, UI_SHOW_GFX, "Show Gfx", SEQ_DEF_1(KEYCODE_F4) ) | |
| 957 | INPUT_PORT_DIGITAL_DEF( 0, IPG_UI, UI_FRAMESKIP_DEC, "Frameskip Dec", SEQ_DEF_1(KEYCODE_F8) ) | |
| 958 | INPUT_PORT_DIGITAL_DEF( 0, IPG_UI, UI_FRAMESKIP_INC, "Frameskip Inc", SEQ_DEF_1(KEYCODE_F9) ) | |
| 959 | INPUT_PORT_DIGITAL_DEF( 0, IPG_UI, UI_THROTTLE, "Throttle", SEQ_DEF_1(KEYCODE_F10) ) | |
| 960 | INPUT_PORT_DIGITAL_DEF( 0, IPG_UI, UI_FAST_FORWARD, "Fast Forward", SEQ_DEF_1(KEYCODE_INSERT) ) | |
| 961 | INPUT_PORT_DIGITAL_DEF( 0, IPG_UI, UI_SHOW_FPS, "Show FPS", SEQ_DEF_5(KEYCODE_F11, SEQCODE_NOT, KEYCODE_LCONTROL, SEQCODE_NOT, KEYCODE_LSHIFT) ) | |
| 962 | INPUT_PORT_DIGITAL_DEF( 0, IPG_UI, UI_SNAPSHOT, "Save Snapshot", SEQ_DEF_3(KEYCODE_F12, SEQCODE_NOT, KEYCODE_LSHIFT) ) | |
| 963 | INPUT_PORT_DIGITAL_DEF( 0, IPG_UI, UI_RECORD_MOVIE, "Record Movie", SEQ_DEF_2(KEYCODE_F12, KEYCODE_LSHIFT) ) | |
| 964 | INPUT_PORT_DIGITAL_DEF( 0, IPG_UI, UI_TOGGLE_CHEAT, "Toggle Cheat", SEQ_DEF_1(KEYCODE_F6) ) | |
| 965 | INPUT_PORT_DIGITAL_DEF( 0, IPG_UI, UI_UP, "UI Up", SEQ_DEF_3(KEYCODE_UP, SEQCODE_OR, INDEXED(JOYCODE_Y_UP_SWITCH, 0)) ) | |
| 966 | INPUT_PORT_DIGITAL_DEF( 0, IPG_UI, UI_DOWN, "UI Down", SEQ_DEF_3(KEYCODE_DOWN, SEQCODE_OR, INDEXED(JOYCODE_Y_DOWN_SWITCH, 0)) ) | |
| 967 | INPUT_PORT_DIGITAL_DEF( 0, IPG_UI, UI_LEFT, "UI Left", SEQ_DEF_3(KEYCODE_LEFT, SEQCODE_OR, INDEXED(JOYCODE_X_LEFT_SWITCH, 0)) ) | |
| 968 | INPUT_PORT_DIGITAL_DEF( 0, IPG_UI, UI_RIGHT, "UI Right", SEQ_DEF_3(KEYCODE_RIGHT, SEQCODE_OR, INDEXED(JOYCODE_X_RIGHT_SWITCH, 0)) ) | |
| 969 | INPUT_PORT_DIGITAL_DEF( 0, IPG_UI, UI_HOME, "UI Home", SEQ_DEF_1(KEYCODE_HOME) ) | |
| 970 | INPUT_PORT_DIGITAL_DEF( 0, IPG_UI, UI_END, "UI End", SEQ_DEF_1(KEYCODE_END) ) | |
| 971 | INPUT_PORT_DIGITAL_DEF( 0, IPG_UI, UI_PAGE_UP, "UI Page Up", SEQ_DEF_1(KEYCODE_PGUP) ) | |
| 972 | INPUT_PORT_DIGITAL_DEF( 0, IPG_UI, UI_PAGE_DOWN, "UI Page Down", SEQ_DEF_1(KEYCODE_PGDN) ) | |
| 973 | INPUT_PORT_DIGITAL_DEF( 0, IPG_UI, UI_SELECT, "UI Select", SEQ_DEF_3(KEYCODE_ENTER, SEQCODE_OR, INDEXED(JOYCODE_BUTTON1, 0)) ) | |
| 974 | INPUT_PORT_DIGITAL_DEF( 0, IPG_UI, UI_CANCEL, "UI Cancel", SEQ_DEF_1(KEYCODE_ESC) ) | |
| 975 | INPUT_PORT_DIGITAL_DEF( 0, IPG_UI, UI_CLEAR, "UI Clear", SEQ_DEF_1(KEYCODE_DEL) ) | |
| 976 | INPUT_PORT_DIGITAL_DEF( 0, IPG_UI, UI_ZOOM_IN, "UI Zoom In", SEQ_DEF_1(KEYCODE_EQUALS) ) | |
| 977 | INPUT_PORT_DIGITAL_DEF( 0, IPG_UI, UI_ZOOM_OUT, "UI Zoom Out", SEQ_DEF_1(KEYCODE_MINUS) ) | |
| 978 | INPUT_PORT_DIGITAL_DEF( 0, IPG_UI, UI_PREV_GROUP, "UI Previous Group", SEQ_DEF_1(KEYCODE_OPENBRACE) ) | |
| 979 | INPUT_PORT_DIGITAL_DEF( 0, IPG_UI, UI_NEXT_GROUP, "UI Next Group", SEQ_DEF_1(KEYCODE_CLOSEBRACE) ) | |
| 980 | INPUT_PORT_DIGITAL_DEF( 0, IPG_UI, UI_ROTATE, "UI Rotate", SEQ_DEF_1(KEYCODE_R) ) | |
| 981 | INPUT_PORT_DIGITAL_DEF( 0, IPG_UI, UI_SHOW_PROFILER, "Show Profiler", SEQ_DEF_2(KEYCODE_F11, KEYCODE_LSHIFT) ) | |
| 982 | #ifdef MESS | |
| 983 | INPUT_PORT_DIGITAL_DEF( 0, IPG_UI, UI_TOGGLE_UI, "UI Toggle", SEQ_DEF_3(KEYCODE_SCRLOCK, SEQCODE_NOT, KEYCODE_LSHIFT) ) | |
| 984 | INPUT_PORT_DIGITAL_DEF( 0, IPG_UI, UI_PASTE, "UI Paste Text", SEQ_DEF_2(KEYCODE_SCRLOCK, KEYCODE_LSHIFT) ) | |
| 985 | #endif /* MESS */ | |
| 986 | INPUT_PORT_DIGITAL_DEF( 0, IPG_UI, UI_TOGGLE_DEBUG, "Toggle Debugger", SEQ_DEF_1(KEYCODE_F5) ) | |
| 987 | INPUT_PORT_DIGITAL_DEF( 0, IPG_UI, UI_SAVE_STATE, "Save State", SEQ_DEF_2(KEYCODE_F7, KEYCODE_LSHIFT) ) | |
| 988 | INPUT_PORT_DIGITAL_DEF( 0, IPG_UI, UI_LOAD_STATE, "Load State", SEQ_DEF_3(KEYCODE_F7, SEQCODE_NOT, KEYCODE_LSHIFT) ) | |
| 989 | INPUT_PORT_DIGITAL_DEF( 0, IPG_UI, UI_ADD_CHEAT, "Add Cheat", SEQ_DEF_1(KEYCODE_A) ) | |
| 990 | INPUT_PORT_DIGITAL_DEF( 0, IPG_UI, UI_DELETE_CHEAT, "Delete Cheat", SEQ_DEF_1(KEYCODE_D) ) | |
| 991 | INPUT_PORT_DIGITAL_DEF( 0, IPG_UI, UI_SAVE_CHEAT, "Save Cheat", SEQ_DEF_1(KEYCODE_S) ) | |
| 992 | INPUT_PORT_DIGITAL_DEF( 0, IPG_UI, UI_WATCH_VALUE, "Watch Value", SEQ_DEF_1(KEYCODE_W) ) | |
| 993 | INPUT_PORT_DIGITAL_DEF( 0, IPG_UI, UI_EDIT_CHEAT, "Edit Cheat", SEQ_DEF_1(KEYCODE_E) ) | |
| 994 | INPUT_PORT_DIGITAL_DEF( 0, IPG_UI, UI_RELOAD_CHEAT, "Reload Database", SEQ_DEF_1(KEYCODE_L) ) | |
| 995 | INPUT_PORT_DIGITAL_DEF( 0, IPG_UI, UI_TOGGLE_CROSSHAIR, "Toggle Crosshair", SEQ_DEF_1(KEYCODE_F1) ) | |
| 677 | /*------------------------------------------------- | |
| 678 | input_port_config_alloc - free memory | |
| 679 | allocated from input_port_alloc | |
| 680 | -------------------------------------------------*/ | |
| 996 | 681 | |
| 997 | INPUT_PORT_DIGITAL_DEF( 0, IPG_UI, OSD_1, NULL, SEQ_DEF_0 ) | |
| 998 | INPUT_PORT_DIGITAL_DEF( 0, IPG_UI, OSD_2, NULL, SEQ_DEF_0 ) | |
| 999 | INPUT_PORT_DIGITAL_DEF( 0, IPG_UI, OSD_3, NULL, SEQ_DEF_0 ) | |
| 1000 | INPUT_PORT_DIGITAL_DEF( 0, IPG_UI, OSD_4, NULL, SEQ_DEF_0 ) | |
| 1001 | INPUT_PORT_DIGITAL_DEF( 0, IPG_UI, OSD_5, NULL, SEQ_DEF_0 ) | |
| 1002 | INPUT_PORT_DIGITAL_DEF( 0, IPG_UI, OSD_6, NULL, SEQ_DEF_0 ) | |
| 1003 | INPUT_PORT_DIGITAL_DEF( 0, IPG_UI, OSD_7, NULL, SEQ_DEF_0 ) | |
| 1004 | INPUT_PORT_DIGITAL_DEF( 0, IPG_UI, OSD_8, NULL, SEQ_DEF_0 ) | |
| 1005 | INPUT_PORT_DIGITAL_DEF( 0, IPG_UI, OSD_9, NULL, SEQ_DEF_0 ) | |
| 1006 | INPUT_PORT_DIGITAL_DEF( 0, IPG_UI, OSD_10, NULL, SEQ_DEF_0 ) | |
| 1007 | INPUT_PORT_DIGITAL_DEF( 0, IPG_UI, OSD_11, NULL, SEQ_DEF_0 ) | |
| 1008 | INPUT_PORT_DIGITAL_DEF( 0, IPG_UI, OSD_12, NULL, SEQ_DEF_0 ) | |
| 1009 | INPUT_PORT_DIGITAL_DEF( 0, IPG_UI, OSD_13, NULL, SEQ_DEF_0 ) | |
| 1010 | INPUT_PORT_DIGITAL_DEF( 0, IPG_UI, OSD_14, NULL, SEQ_DEF_0 ) | |
| 1011 | INPUT_PORT_DIGITAL_DEF( 0, IPG_UI, OSD_15, NULL, SEQ_DEF_0 ) | |
| 1012 | INPUT_PORT_DIGITAL_DEF( 0, IPG_UI, OSD_16, NULL, SEQ_DEF_0 ) | |
| 1013 | INPUT_PORT_DIGITAL_DEF( 0, IPG_INVALID, UNKNOWN, NULL, SEQ_DEF_0 ) | |
| 1014 | INPUT_PORT_DIGITAL_DEF( 0, IPG_INVALID, SPECIAL, NULL, SEQ_DEF_0 ) | |
| 1015 | INPUT_PORT_DIGITAL_DEF( 0, IPG_INVALID, OTHER, NULL, SEQ_DEF_0 ) | |
| 1016 | INPUT_PORT_DIGITAL_DEF( 0, IPG_INVALID, DIPSWITCH_NAME, NULL, SEQ_DEF_0 ) | |
| 1017 | INPUT_PORT_DIGITAL_DEF( 0, IPG_INVALID, CONFIG_NAME, NULL, SEQ_DEF_0 ) | |
| 1018 | INPUT_PORT_DIGITAL_DEF( 0, IPG_INVALID, END, NULL, SEQ_DEF_0 ) | |
| 1019 | }; | |
| 682 | void input_port_config_free(const input_port_config *portlist) | |
| 683 | { | |
| 684 | /* iterate over all ports and free them */ | |
| 685 | while (portlist != NULL) | |
| 686 | port_config_free(&portlist); | |
| 687 | } | |
| 1020 | 688 | |
| 1021 | 689 | |
| 1022 | static input_port_default_entry default_ports[ARRAY_LENGTH(default_ports_builtin)]; | |
| 1023 | static input_port_default_entry default_ports_backup[ARRAY_LENGTH(default_ports_builtin)]; | |
| 1024 | static const int input_port_count = ARRAY_LENGTH(default_ports_builtin); | |
| 1025 | static int default_ports_lookup[__ipt_max][MAX_PLAYERS]; | |
| 690 | /*------------------------------------------------- | |
| 691 | input_port_by_tag - return a pointer to the | |
| 692 | port_config associated with the given port | |
| 693 | tag | |
| 694 | -------------------------------------------------*/ | |
| 1026 | 695 | |
| 696 | const input_port_config *input_port_by_tag(const input_port_config *portlist, const char *tag) | |
| 697 | { | |
| 698 | const input_port_config *port; | |
| 1027 | 699 | |
| 700 | /* loop over ports until we hit the index or run out */ | |
| 701 | for (port = portlist; port != NULL; port = port->next) | |
| 702 | if (port->tag != NULL && strcmp(port->tag, tag) == 0) | |
| 703 | return port; | |
| 1028 | 704 | |
| 705 | return NULL; | |
| 706 | } | |
| 707 | ||
| 708 | ||
| 709 | /*------------------------------------------------- | |
| 710 | input_port_by_index - return a pointer to the | |
| 711 | port_config associated with the given port | |
| 712 | index | |
| 713 | -------------------------------------------------*/ | |
| 714 | ||
| 715 | const input_port_config *input_port_by_index(const input_port_config *portlist, int index) | |
| 716 | { | |
| 717 | const input_port_config *port; | |
| 718 | ||
| 719 | /* loop over ports until we hit the index or run out */ | |
| 720 | for (port = portlist; port != NULL; port = port->next) | |
| 721 | if (index-- == 0) | |
| 722 | return port; | |
| 723 | ||
| 724 | return NULL; | |
| 725 | } | |
| 726 | ||
| 727 | ||
| 728 | ||
| 1029 | 729 | /*************************************************************************** |
| 1030 | | |
| 730 | A | |
| 1031 | 731 | ***************************************************************************/ |
| 1032 | 732 | |
| 1033 | static void input_port_exit(running_machine *machine); | |
| 1034 | static void input_port_frame(running_machine *machine); | |
| 1035 | static void input_port_frame_update(running_machine *machine); | |
| 1036 | static void input_port_load(int config_type, xml_data_node *parentnode); | |
| 1037 | static void input_port_save(int config_type, xml_data_node *parentnode); | |
| 1038 | static void update_digital_joysticks(running_machine *machine); | |
| 1039 | static void update_analog_port(int port); | |
| 1040 | static void autoselect_device(const input_port_entry *ipt, int type1, int type2, int type3, const char *option, const char *ananame); | |
| 733 | /*------------------------------------------------- | |
| 734 | input_field_name - return the field name for | |
| 735 | a given input field | |
| 736 | -------------------------------------------------*/ | |
| 1041 | 737 | |
| 1042 | /* playback and record */ | |
| 1043 | static time_t playback_init(running_machine *machine); | |
| 1044 | static void record_init(running_machine *machine); | |
| 1045 | static void playback_end(running_machine *machine, const char *message); | |
| 1046 | static void record_end(running_machine *machine, const char *message); | |
| 1047 | static void playback_frame(running_machine *machine, attotime curtime); | |
| 1048 | static void record_frame(running_machine *machine, attotime curtime); | |
| 1049 | static void playback_port(running_machine *machine, input_port_info *portinfo); | |
| 1050 | static void record_port(running_machine *machine, input_port_info *portinfo); | |
| 738 | const char *input_field_name(const input_field_config *field) | |
| 739 | { | |
| 740 | /* if we have a non-default name, use that */ | |
| 741 | if (field->name != NULL) | |
| 742 | return field->name; | |
| 1051 | 743 | |
| 744 | /* otherwise, return the name associated with the type */ | |
| 745 | return input_type_name(field->port->machine, field->type, field->player); | |
| 746 | } | |
| 1052 | 747 | |
| 1053 | 748 | |
| 749 | /*------------------------------------------------- | |
| 750 | input_field_seq - return the input sequence | |
| 751 | for the given input field | |
| 752 | -------------------------------------------------*/ | |
| 753 | ||
| 754 | const input_seq *input_field_seq(const input_field_config *field, input_seq_type seqtype) | |
| 755 | { | |
| 756 | static const input_seq ip_none = SEQ_DEF_0; | |
| 757 | const input_seq *portseq = &ip_none; | |
| 758 | ||
| 759 | /* if the field is disabled, return no key */ | |
| 760 | if (field->flags & FIELD_FLAG_UNUSED) | |
| 761 | return portseq; | |
| 762 | ||
| 763 | /* select either the live or config state depending on whether we have live state */ | |
| 764 | portseq = (field->state == NULL) ? &field->seq[seqtype] : &field->state->seq[seqtype]; | |
| 765 | ||
| 766 | /* if the portseq is the special default code, return the expanded default value */ | |
| 767 | if (input_seq_get_1(portseq) == SEQCODE_DEFAULT) | |
| 768 | return input_type_seq(field->port->machine, field->type, field->player, seqtype); | |
| 769 | ||
| 770 | /* otherwise, return the sequence as-is */ | |
| 771 | return portseq; | |
| 772 | } | |
| 773 | ||
| 774 | ||
| 775 | /*------------------------------------------------- | |
| 776 | input_field_get_user_settings - return the current | |
| 777 | settings for the given input field | |
| 778 | -------------------------------------------------*/ | |
| 779 | ||
| 780 | void input_field_get_user_settings(const input_field_config *field, input_field_user_settings *settings) | |
| 781 | { | |
| 782 | int seqtype; | |
| 783 | ||
| 784 | /* zap the entire structure */ | |
| 785 | memset(settings, 0, sizeof(*settings)); | |
| 786 | ||
| 787 | /* copy the basics */ | |
| 788 | for (seqtype = 0; seqtype < ARRAY_LENGTH(settings->seq); seqtype++) | |
| 789 | settings->seq[seqtype] = field->state->seq[seqtype]; | |
| 790 | ||
| 791 | /* if there's a list of settings or we're an adjuster, copy the current value */ | |
| 792 | if (field->settinglist != NULL || field->type == IPT_ADJUSTER) | |
| 793 | settings->value = field->state->value; | |
| 794 | ||
| 795 | /* if there's analog data, extract the analog settings */ | |
| 796 | if (field->state->analog != NULL) | |
| 797 | { | |
| 798 | settings->sensitivity = field->state->analog->sensitivity; | |
| 799 | settings->delta = field->state->analog->delta; | |
| 800 | settings->centerdelta = field->state->analog->centerdelta; | |
| 801 | settings->reverse = field->state->analog->reverse; | |
| 802 | } | |
| 803 | } | |
| 804 | ||
| 805 | ||
| 806 | /*------------------------------------------------- | |
| 807 | input_field_set_user_settings - modify the current | |
| 808 | settings for the given input field | |
| 809 | -------------------------------------------------*/ | |
| 810 | ||
| 811 | void input_field_set_user_settings(const input_field_config *field, const input_field_user_settings *settings) | |
| 812 | { | |
| 813 | static const input_seq default_seq = SEQ_DEF_1(SEQCODE_DEFAULT); | |
| 814 | int seqtype; | |
| 815 | ||
| 816 | /* copy the basics */ | |
| 817 | for (seqtype = 0; seqtype < ARRAY_LENGTH(settings->seq); seqtype++) | |
| 818 | { | |
| 819 | const input_seq *defseq = input_type_seq(field->port->machine, field->type, field->player, seqtype); | |
| 820 | if (input_seq_cmp(defseq, &settings->seq[seqtype]) == 0) | |
| 821 | field->state->seq[seqtype] = default_seq; | |
| 822 | else | |
| 823 | field->state->seq[seqtype] = settings->seq[seqtype]; | |
| 824 | } | |
| 825 | ||
| 826 | /* if there's a list of settings or we're an adjuster, copy the current value */ | |
| 827 | if (field->settinglist != NULL || field->type == IPT_ADJUSTER) | |
| 828 | field->state->value = settings->value; | |
| 829 | ||
| 830 | /* if there's analog data, extract the analog settings */ | |
| 831 | if (field->state->analog != NULL) | |
| 832 | { | |
| 833 | field->state->analog->sensitivity = settings->sensitivity; | |
| 834 | field->state->analog->delta = settings->delta; | |
| 835 | field->state->analog->centerdelta = settings->centerdelta; | |
| 836 | field->state->analog->reverse = settings->reverse; | |
| 837 | } | |
| 838 | } | |
| 839 | ||
| 840 | ||
| 841 | ||
| 1054 | 842 | /*************************************************************************** |
| 1055 | COR | |
| 843 | ACCESSORS FOR I | |
| 1056 | 844 | ***************************************************************************/ |
| 1057 | 845 | |
| 1058 | /************************************* | |
| 1059 | * | |
| 1060 | * Input port initialize | |
| 1061 | * | |
| 1062 | *************************************/ | |
| 846 | /*------------------------------------------------- | |
| 847 | input_type_is_analog - return TRUE if | |
| 848 | the given type represents an analog control | |
| 849 | -------------------------------------------------*/ | |
| 1063 | 850 | |
| 1064 | ||
| 851 | ||
| 1065 | 852 | { |
| 1066 | int ipnum, player; | |
| 1067 | time_t basetime; | |
| 853 | return (type >= __ipt_analog_start && type <= __ipt_analog_end); | |
| 854 | } | |
| 1068 | 855 | |
| 1069 | /* add an exit callback */ | |
| 1070 | add_exit_callback(machine, input_port_exit); | |
| 1071 | add_frame_callback(machine, input_port_frame); | |
| 1072 | 856 | |
| 1073 | /* reset the pointers */ | |
| 1074 | memset(&joystick_info, 0, sizeof(joystick_info)); | |
| 857 | /*------------------------------------------------- | |
| 858 | input_type_name - return the name | |
| 859 | for the given type/player | |
| 860 | -------------------------------------------------*/ | |
| 1075 | 861 | |
| 1076 | /* start with the raw defaults and ask the OSD to customize them in the backup array */ | |
| 1077 | memcpy(default_ports_backup, default_ports_builtin, sizeof(default_ports_backup)); | |
| 1078 | osd_customize_inputport_list(default_ports_backup); | |
| 862 | const char *input_type_name(running_machine *machine, int type, int player) | |
| 863 | { | |
| 864 | /* if we have a machine, use the live state and quick lookup */ | |
| 865 | if (machine != NULL) | |
| 866 | { | |
| 867 | input_port_private *portdata = machine->input_port_data; | |
| 868 | input_type_state *typestate = portdata->type_to_typestate[type][player]; | |
| 869 | if (typestate != NULL) | |
| 870 | return typestate->typedesc.name; | |
| 871 | } | |
| 1079 | 872 | |
| 1080 | /* propogate these changes forward to the final input list */ | |
| 1081 | memcpy(default_ports, default_ports_backup, sizeof(default_ports)); | |
| 873 | /* if no machine, fall back to brute force searching */ | |
| 874 | else | |
| 875 | { | |
| 876 | int typenum; | |
| 877 | for (typenum = 0; typenum < ARRAY_LENGTH(core_types); typenum++) | |
| 878 | if (core_types[typenum].type == type && core_types[typenum].player == player) | |
| 879 | return core_types[typenum].name; | |
| 880 | } | |
| 1082 | 881 | |
| 1083 | /* make a lookup table mapping type/player to the default port list entry */ | |
| 1084 | for (ipnum = 0; ipnum < __ipt_max; ipnum++) | |
| 1085 | for (player = 0; player < MAX_PLAYERS; player++) | |
| 1086 | default_ports_lookup[ipnum][player] = -1; | |
| 1087 | for (ipnum = 0; default_ports[ipnum].type != IPT_END; ipnum++) | |
| 1088 | default_ports_lookup[default_ports[ipnum].type][default_ports[ipnum].player] = ipnum; | |
| 882 | /* if we find nothing, return an invalid group */ | |
| 883 | return "???"; | |
| 884 | } | |
| 1089 | 885 | |
| 1090 | /* reset the port info */ | |
| 1091 | memset(port_info, 0, sizeof(port_info)); | |
| 1092 | 886 | |
| 1093 | /* if we have inputs, process them now */ | |
| 1094 | if (ipt != NULL) | |
| 887 | /*------------------------------------------------- | |
| 888 | input_type_group - return the group | |
| 889 | for the given type/player | |
| 890 | -------------------------------------------------*/ | |
| 891 | ||
| 892 | int input_type_group(running_machine *machine, int type, int player) | |
| 893 | { | |
| 894 | /* if we have a machine, use the live state and quick lookup */ | |
| 895 | if (machine != NULL) | |
| 1095 | 896 | { |
| 1096 | const char *joystick_map_default = options_get_string(mame_options(), OPTION_JOYSTICK_MAP); | |
| 1097 | input_port_entry *portentry; | |
| 1098 | int portnum; | |
| 897 | input_port_private *portdata = machine->input_port_data; | |
| 898 | input_type_state *typestate = portdata->type_to_typestate[type][player]; | |
| 899 | if (typestate != NULL) | |
| 900 | return typestate->typedesc.group; | |
| 901 | } | |
| 1099 | 902 | |
| 1100 | /* allocate input ports */ | |
| 1101 | machine->input_ports = input_port_allocate(ipt, NULL); | |
| 903 | /* if no machine, fall back to brute force searching */ | |
| 904 | else | |
| 905 | { | |
| 906 | int typenum; | |
| 907 | for (typenum = 0; typenum < ARRAY_LENGTH(core_types); typenum++) | |
| 908 | if (core_types[typenum].type == type && core_types[typenum].player == player) | |
| 909 | return core_types[typenum].group; | |
| 910 | } | |
| 1102 | 911 | |
| 1103 | /* allocate default input ports */ | |
| 1104 | input_ports_default = input_port_allocate(ipt, NULL); | |
| 912 | /* if we find nothing, return an invalid group */ | |
| 913 | return IPG_INVALID; | |
| 914 | } | |
| 1105 | 915 | |
| 1106 | /* handle autoselection of devices */ | |
| 1107 | autoselect_device(machine->input_ports, IPT_PADDLE, IPT_PADDLE_V, 0, OPTION_PADDLE_DEVICE, "paddle"); | |
| 1108 | autoselect_device(machine->input_ports, IPT_AD_STICK_X, IPT_AD_STICK_Y, IPT_AD_STICK_Z, OPTION_ADSTICK_DEVICE, "analog joystick"); | |
| 1109 | autoselect_device(machine->input_ports, IPT_LIGHTGUN_X, IPT_LIGHTGUN_Y, 0, OPTION_LIGHTGUN_DEVICE, "lightgun"); | |
| 1110 | autoselect_device(machine->input_ports, IPT_PEDAL, IPT_PEDAL2, IPT_PEDAL3, OPTION_PEDAL_DEVICE, "pedal"); | |
| 1111 | autoselect_device(machine->input_ports, IPT_DIAL, IPT_DIAL_V, 0, OPTION_DIAL_DEVICE, "dial"); | |
| 1112 | autoselect_device(machine->input_ports, IPT_TRACKBALL_X, IPT_TRACKBALL_Y, 0, OPTION_TRACKBALL_DEVICE, "trackball"); | |
| 1113 | autoselect_device(machine->input_ports, IPT_POSITIONAL, IPT_POSITIONAL_V, 0, OPTION_POSITIONAL_DEVICE, "positional"); | |
| 1114 | autoselect_device(machine->input_ports, IPT_MOUSE_X, IPT_MOUSE_Y, 0, OPTION_MOUSE_DEVICE, "mouse"); | |
| 1115 | 916 | |
| 1116 | /* look for 4-way joysticks and change the default map if we find any */ | |
| 1117 | if (joystick_map_default[0] == 0 || strcmp(joystick_map_default, "auto") == 0) | |
| 1118 | for (portentry = machine->input_ports; portentry->type != IPT_END; portentry++) | |
| 1119 | if (IS_DIGITAL_JOYSTICK(portentry) && portentry->way == 4) | |
| 1120 | { | |
| 1121 | input_device_set_joystick_map(-1, portentry->rotated ? joystick_map_4way_diagonal : joystick_map_4way_sticky); | |
| 1122 | break; | |
| 1123 | } | |
| 917 | /*------------------------------------------------- | |
| 918 | input_type_seq - return the input | |
| 919 | sequence for the given type/player | |
| 920 | -------------------------------------------------*/ | |
| 1124 | 921 | |
| 1125 | /* identify all the tagged ports up front so the memory system can access them */ | |
| 1126 | portnum = 0; | |
| 1127 | for (portentry = machine->input_ports; portentry->type != IPT_END; portentry++) | |
| 1128 | if (portentry->type == IPT_PORT) | |
| 1129 | port_info[portnum++].tag = portentry->start.tag; | |
| 922 | const input_seq *input_type_seq(running_machine *machine, int type, int player, input_seq_type seqtype) | |
| 923 | { | |
| 924 | static const input_seq ip_none = SEQ_DEF_0; | |
| 1130 | 925 | |
| 1131 | /* look up all the tags referenced in conditions */ | |
| 1132 | for (portentry = machine->input_ports; portentry->type != IPT_END; portentry++) | |
| 1133 | if (portentry->condition.tag) | |
| 1134 | { | |
| 1135 | int tag = port_tag_to_index(portentry->condition.tag); | |
| 1136 | if (tag == -1) | |
| 1137 | fatalerror("Conditional port references invalid tag '%s'", portentry->condition.tag); | |
| 1138 | portentry->condition.portnum = tag; | |
| 1139 | } | |
| 926 | /* if we have a machine, use the live state and quick lookup */ | |
| 927 | if (machine != NULL) | |
| 928 | { | |
| 929 | input_port_private *portdata = machine->input_port_data; | |
| 930 | input_type_state *typestate = portdata->type_to_typestate[type][player]; | |
| 931 | if (typestate != NULL) | |
| 932 | return &typestate->seq[seqtype]; | |
| 1140 | 933 | } |
| 1141 | 934 | |
| 1142 | /* register callbacks for when we load configurations */ | |
| 1143 | config_register("input", input_port_load, input_port_save); | |
| 935 | /* if no machine, fall back to brute force searching */ | |
| 936 | else | |
| 937 | { | |
| 938 | int typenum; | |
| 939 | for (typenum = 0; typenum < ARRAY_LENGTH(core_types); typenum++) | |
| 940 | if (core_types[typenum].type == type && core_types[typenum].player == player) | |
| 941 | return &core_types[typenum].seq[seqtype]; | |
| 942 | } | |
| 1144 | 943 | |
| 1145 | /* open playback and record files if specified */ | |
| 1146 | basetime = playback_init(machine); | |
| 1147 | record_init(machine); | |
| 944 | /* if we find nothing, return an empty sequence */ | |
| 945 | return &ip_none; | |
| 946 | } | |
| 1148 | 947 | |
| 1149 | return basetime; | |
| 948 | ||
| 949 | /*------------------------------------------------- | |
| 950 | input_type_set_seq - change the input | |
| 951 | sequence for the given type/player | |
| 952 | -------------------------------------------------*/ | |
| 953 | ||
| 954 | void input_type_set_seq(running_machine *machine, int type, int player, input_seq_type seqtype, const input_seq *newseq) | |
| 955 | { | |
| 956 | input_port_private *portdata = machine->input_port_data; | |
| 957 | input_type_state *typestate = portdata->type_to_typestate[type][player]; | |
| 958 | if (typestate != NULL) | |
| 959 | typestate->seq[seqtype] = *newseq; | |
| 1150 | 960 | } |
| 1151 | 961 | |
| 1152 | 962 | |
| 963 | /*------------------------------------------------- | |
| 964 | input_type_pressed - return TRUE if | |
| 965 | the sequence for the given input type/player | |
| 966 | is pressed | |
| 967 | -------------------------------------------------*/ | |
| 1153 | 968 | |
| 1154 | /************************************* | |
| 1155 | * | |
| 1156 | * Input port exit | |
| 1157 | * | |
| 1158 | *************************************/ | |
| 969 | int input_type_pressed(running_machine *machine, int type, int player) | |
| 970 | { | |
| 971 | return input_seq_pressed(input_type_seq(machine, type, player, SEQ_TYPE_STANDARD)); | |
| 972 | } | |
| 1159 | 973 | |
| 1160 | void input_port_exit(running_machine *machine) | |
| 974 | ||
| 975 | /*------------------------------------------------- | |
| 976 | input_type_list - return the list of types | |
| 977 | -------------------------------------------------*/ | |
| 978 | ||
| 979 | const input_type_desc *input_type_list(running_machine *machine) | |
| 1161 | 980 | { |
| 1162 | /* close any playback or recording files */ | |
| 1163 | playback_end(machine, NULL); | |
| 1164 | record_end(machine, NULL); | |
| 981 | input_port_private *portdata = machine->input_port_data; | |
| 982 | return &portdata->typestatelist->typedesc; | |
| 1165 | 983 | } |
| 1166 | 984 | |
| 1167 | 985 | |
| 1168 | 986 | |
| 1169 | /************************************* | |
| 1170 | * | |
| 1171 | * Input port initialization | |
| 1172 | * | |
| 1173 | *************************************/ | |
| 987 | /*************************************************************************** | |
| 988 | USER INTERFACE SEQUENCE READING | |
| 989 | ***************************************************************************/ | |
| 1174 | 990 | |
| 1175 | static void input_port_postload(void) | |
| 991 | /*------------------------------------------------- | |
| 992 | input_ui_pressed - return TRUE if a key down | |
| 993 | for the given user interface sequence is | |
| 994 | detected | |
| 995 | -------------------------------------------------*/ | |
| 996 | ||
| 997 | int input_ui_pressed(running_machine *machine, int code) | |
| 1176 | 998 | { |
| 1177 | input_port_entry *portentry; | |
| 1178 | int portnum, bitnum; | |
| 1179 | UINT32 mask; | |
| 999 | return input_ui_pressed_repeat(machine, code, 0); | |
| 1000 | } | |
| 1180 | 1001 | |
| 1181 | /* loop over the ports and identify all the analog inputs */ | |
| 1182 | portnum = -1; | |
| 1183 | bitnum = 0; | |
| 1184 | for (portentry = Machine->input_ports; portentry->type != IPT_END; portentry++) | |
| 1002 | ||
| 1003 | /*------------------------------------------------- | |
| 1004 | input_ui_pressed_r - return TRUE if a key down | |
| 1005 | for the given user interface sequence is | |
| 1006 | detected, or if autorepeat at the given speed | |
| 1007 | is triggered | |
| 1008 | -------------------------------------------------*/ | |
| 1009 | ||
| 1010 | int input_ui_pressed_repeat(running_machine *machine, int code, int speed) | |
| 1011 | { | |
| 1012 | input_port_private *portdata = machine->input_port_data; | |
| 1013 | int pressed; | |
| 1014 | ||
| 1015 | profiler_mark(PROFILER_INPUT); | |
| 1016 | ||
| 1017 | /* get the status of this key (assumed to be only in the defaults) */ | |
| 1018 | assert(code >= IPT_UI_CONFIGURE && code <= IPT_OSD_16); | |
| 1019 | pressed = input_seq_pressed(input_type_seq(machine, code, 0, SEQ_TYPE_STANDARD)); | |
| 1020 | ||
| 1021 | /* if down, handle it specially */ | |
| 1022 | if (pressed) | |
| 1185 | 1023 | { |
| 1186 | /* if this is IPT_PORT, increment the port number */ | |
| 1187 | if (portentry->type == IPT_PORT) | |
| 1024 | osd_ticks_t tps = osd_ticks_per_second(); | |
| 1025 | ||
| 1026 | /* if this is the first press, set a 3x delay and leave pressed = 1 */ | |
| 1027 | if (portdata->ui_memory[code] == 0) | |
| 1028 | portdata->ui_memory[code] = osd_ticks() + 3 * speed * tps / 60; | |
| 1029 | ||
| 1030 | /* if this is an autorepeat case, set a 1x delay and leave pressed = 1 */ | |
| 1031 | else if (speed > 0 && (osd_ticks() + tps - portdata->ui_memory[code]) >= tps) | |
| 1032 | portdata->ui_memory[code] += 1 * speed * tps / 60; | |
| 1033 | ||
| 1034 | /* otherwise, reset pressed = 0 */ | |
| 1035 | else | |
| 1036 | pressed = 0; | |
| 1037 | } | |
| 1038 | ||
| 1039 | /* if we're not pressed, reset the memory field */ | |
| 1040 | else | |
| 1041 | portdata->ui_memory[code] = 0; | |
| 1042 | ||
| 1043 | profiler_mark(PROFILER_END); | |
| 1044 | ||
| 1045 | return pressed; | |
| 1046 | } | |
| 1047 | ||
| 1048 | ||
| 1049 | ||
| 1050 | /*************************************************************************** | |
| 1051 | PORT READING | |
| 1052 | ***************************************************************************/ | |
| 1053 | ||
| 1054 | /*------------------------------------------------- | |
| 1055 | input_port_read_direct - return the value of | |
| 1056 | an input port | |
| 1057 | -------------------------------------------------*/ | |
| 1058 | ||
| 1059 | input_port_value input_port_read_direct(const input_port_config *port) | |
| 1060 | { | |
| 1061 | input_port_private *portdata = port->machine->input_port_data; | |
| 1062 | analog_field_state *analog; | |
| 1063 | callback_field_info *custom; | |
| 1064 | input_port_value result; | |
| 1065 | ||
| 1066 | /* start with the digital */ | |
| 1067 | result = port->state->digital; | |
| 1068 | ||
| 1069 | /* update custom values */ | |
| 1070 | for (custom = port->state->customlist; custom != NULL; custom = custom->next) | |
| 1071 | if (input_condition_true(port->machine, &custom->field->condition)) | |
| 1188 | 1072 | { |
| 1189 | portnum++; | |
| 1190 | bitnum = 0; | |
| 1073 | /* replace the bits with bits from the custom routine */ | |
| 1074 | input_port_value newbits = (*custom->field->custom)(custom->field, custom->field->custom_param); | |
| 1075 | result = (result & ~custom->field->mask) | ((newbits << custom->shift) & custom->field->mask); | |
| 1191 | 1076 | } |
| 1192 | 1077 | |
| 1193 | /* if this is not a DIP setting or config setting, add it to the list */ | |
| 1194 | else if (portentry->type != IPT_DIPSWITCH_SETTING && portentry->type != IPT_CONFIG_SETTING) | |
| 1195 | { | |
| 1196 | /* fatal error if we didn't hit an IPT_PORT */ | |
| 1197 | if (portnum < 0) | |
| 1198 | fatalerror("Error in InputPort definition: expecting PORT_START"); | |
| 1199 | 1078 | |
| 1200 | /* fatal error if too many bits */ | |
| 1201 | if (bitnum >= MAX_BITS_PER_PORT) | |
| 1202 | fatalerror("Error in InputPort definition: too many bits for a port (%d max)", MAX_BITS_PER_PORT); | |
| 1079 | /* update VBLANK bits */ | |
| 1080 | if (port->state->vblank != 0) | |
| 1081 | { | |
| 1082 | if (video_screen_get_vblank(port->machine->primary_screen)) | |
| 1083 | result |= port->state->vblank; | |
| 1084 | else | |
| 1085 | result &= ~port->state->vblank; | |
| 1086 | } | |
| 1203 | 1087 | |
| 1204 | /* fill in the bit info */ | |
| 1205 | port_info[portnum].bit[bitnum].portentry = portentry; | |
| 1206 | port_info[portnum].bit[bitnum].impulse = 0; | |
| 1207 | port_info[portnum].bit[bitnum++].last = 0; | |
| 1088 | /* apply active high/low state to digital, custom, and VBLANK inputs */ | |
| 1089 | result ^= port->state->defvalue; | |
| 1208 | 1090 | |
| 1209 | /* if this is a custom input, add it to the list */ | |
| 1210 | if (portentry->custom != NULL) | |
| 1091 | /* merge in analog portions */ | |
| 1092 | for (analog = port->state->analoglist; analog != NULL; analog = analog->next) | |
| 1093 | if (input_condition_true(port->machine, &analog->field->condition)) | |
| 1094 | { | |
| 1095 | /* start with the raw value */ | |
| 1096 | INT32 value = analog->accum; | |
| 1097 | ||
| 1098 | /* interpolate if appropriate and if time has passed since the last update */ | |
| 1099 | if (analog->interpolate && !(analog->field->flags & ANALOG_FLAG_RESET) && portdata->last_delta_nsec != 0) | |
| 1211 | 1100 | { |
| 1212 | custom_port_info *info; | |
| 1101 | attoseconds_t nsec_since_last = attotime_to_attoseconds(attotime_sub(timer_get_time(), portdata->last_frame_time)) / ATTOSECONDS_PER_NANOSECOND; | |
| 1102 | value = analog->previous + ((INT64)(analog->accum - analog->previous) * nsec_since_last / portdata->last_delta_nsec); | |
| 1103 | } | |
| 1213 | 1104 | |
| 1214 | /* allocate memory */ | |
| 1215 | info = auto_malloc(sizeof(*info)); | |
| 1216 | memset(info, 0, sizeof(*info)); | |
| 1105 | /* apply standard analog settings */ | |
| 1106 | value = apply_analog_settings(value, analog); | |
| 1217 | 1107 | |
| 1218 | /* fill in the data */ | |
| 1219 | info->portentry = portentry; | |
| 1220 | for (mask = portentry->mask; !(mask & 1); mask >>= 1) | |
| 1221 | info->shift++; | |
| 1108 | /* remap the value if needed */ | |
| 1109 | if (analog->field->remap_table != NULL) | |
| 1110 | value = analog->field->remap_table[value]; | |
| 1222 | 1111 | |
| 1223 | /* hook in the list */ | |
| 1224 | info->next = port_info[portnum].custominfo; | |
| 1225 | port_info[portnum].custominfo = info; | |
| 1226 | } | |
| 1112 | /* invert bits if needed */ | |
| 1113 | if (analog->field->flags & ANALOG_FLAG_INVERT) | |
| 1114 | value = ~value; | |
| 1227 | 1115 | |
| 1228 | /* if this is a changed input, add it to the list */ | |
| 1229 | else if (portentry->changed != NULL) | |
| 1230 | { | |
| 1231 | changed_port_info *info; | |
| 1116 | /* insert into the port */ | |
| 1117 | result = (result & ~analog->field->mask) | ((value << analog->shift) & analog->field->mask); | |
| 1118 | } | |
| 1232 | 1119 | |
| 1233 | /* allocate memory */ | |
| 1234 | info = auto_malloc(sizeof(*info)); | |
| 1235 | memset(info, 0, sizeof(*info)); | |
| 1120 | return result; | |
| 1121 | } | |
| 1236 | 1122 | |
| 1237 | /* fill in the data */ | |
| 1238 | info->portentry = portentry; | |
| 1239 | for (mask = portentry->mask; !(mask & 1); mask >>= 1) | |
| 1240 | info->shift++; | |
| 1241 | 1123 | |
| 1242 | /* hook in the list */ | |
| 1243 | info->next = port_info[portnum].changedinfo; | |
| 1244 | port_info[portnum].changedinfo = info; | |
| 1245 | } | |
| 1124 | /*------------------------------------------------- | |
| 1125 | input_port_read - return the value of | |
| 1126 | an input port specified by tag | |
| 1127 | -------------------------------------------------*/ | |
| 1246 | 1128 | |
| 1247 | /* if this is an analog port, create an info struct for it */ | |
| 1248 | else if (IS_ANALOG(portentry)) | |
| 1249 | { | |
| 1250 | analog_port_info *info; | |
| 1129 | input_port_value input_port_read(running_machine *machine, const char *tag) | |
| 1130 | { | |
| 1131 | const input_port_config *port = input_port_by_tag(machine->portconfig, tag); | |
| 1132 | if (port == NULL) | |
| 1133 | fatalerror("Unable to locate input port '%s'", tag); | |
| 1134 | return input_port_read_direct(port); | |
| 1135 | } | |
| 1251 | 1136 | |
| 1252 | /* allocate memory */ | |
| 1253 | info = auto_malloc(sizeof(*info)); | |
| 1254 | memset(info, 0, sizeof(*info)); | |
| 1255 | 1137 | |
| 1256 | /* fill in the data */ | |
| 1257 | info->portentry = portentry; | |
| 1258 | for (mask = portentry->mask; !(mask & 1); mask >>= 1) | |
| 1259 | info->shift++; | |
| 1260 | for ( ; mask & 1; mask >>= 1) | |
| 1261 | info->bits++; | |
| 1138 | /*------------------------------------------------- | |
| 1139 | input_port_read_indexed - return the value of | |
| 1140 | an input port specified by tag, or a default | |
| 1141 | value if the port does not exist | |
| 1142 | -------------------------------------------------*/ | |
| 1262 | 1143 | |
| 1263 | /* based on the port type determine if we need absolute or relative coordinates */ | |
| 1264 | info->minimum = INPUT_ABSOLUTE_MIN; | |
| 1265 | info->maximum = INPUT_ABSOLUTE_MAX; | |
| 1266 | info->interpolate = 1; | |
| 1144 | input_port_value input_port_read_safe(running_machine *machine, const char *tag, UINT32 defvalue) | |
| 1145 | { | |
| 1146 | const input_port_config *port = input_port_by_tag(machine->portconfig, tag); | |
| 1147 | return (port == NULL) ? defvalue : input_port_read_direct(port); | |
| 1148 | } | |
| 1267 | 1149 | |
| 1268 | /* adjust default, min, and max so they fall in the bitmask range */ | |
| 1269 | portentry->default_value = (portentry->default_value & portentry->mask) >> info->shift; | |
| 1270 | if (portentry->type != IPT_POSITIONAL && portentry->type != IPT_POSITIONAL_V) | |
| 1271 | { | |
| 1272 | portentry->analog.min = (portentry->analog.min & portentry->mask) >> info->shift; | |
| 1273 | portentry->analog.max = (portentry->analog.max & portentry->mask) >> info->shift; | |
| 1274 | } | |
| 1275 | 1150 | |
| 1276 | switch (portentry->type) | |
| 1277 | { | |
| 1278 | /* pedals start at and autocenter to the min range*/ | |
| 1279 | case IPT_PEDAL: | |
| 1280 | case IPT_PEDAL2: | |
| 1281 | case IPT_PEDAL3: | |
| 1282 | info->center = INPUT_ABSOLUTE_MIN; | |
| 1283 | /* force pedals to start at their scaled minimum */ | |
| 1284 | info->accum = APPLY_INVERSE_SENSITIVITY(info->center, portentry->analog.sensitivity); | |
| 1285 | /* fall through to complete setup */ | |
| 1151 | /*------------------------------------------------- | |
| 1152 | input_port_read_indexed - return the value of | |
| 1153 | an input port specified by index | |
| 1154 | -------------------------------------------------*/ | |
| 1286 | 1155 | |
| 1287 | /* pedals, paddles and analog joysticks are absolute and autocenter */ | |
| 1288 | case IPT_AD_STICK_X: | |
| 1289 | case IPT_AD_STICK_Y: | |
| 1290 | case IPT_AD_STICK_Z: | |
| 1291 | case IPT_PADDLE: | |
| 1292 | case IPT_PADDLE_V: | |
| 1293 | info->absolute = 1; | |
| 1294 | info->autocenter = 1; | |
| 1295 | break; | |
| 1156 | input_port_value input_port_read_indexed(running_machine *machine, int portnum) | |
| 1157 | { | |
| 1158 | const input_port_config *port = input_port_by_index(machine->portconfig, portnum); | |
| 1159 | return (port == NULL) ? 0 : input_port_read_direct(port); | |
| 1160 | } | |
| 1296 | 1161 | |
| 1297 | /* lightguns are absolute as well, but don't autocenter and don't interpolate their values */ | |
| 1298 | case IPT_LIGHTGUN_X: | |
| 1299 | case IPT_LIGHTGUN_Y: | |
| 1300 | info->absolute = 1; | |
| 1301 | info->interpolate = 0; | |
| 1302 | break; | |
| 1303 | 1162 | |
| 1304 | /* dials, mice and trackballs are relative devices */ | |
| 1305 | /* these have fixed "min" and "max" values based on how many bits are in the port */ | |
| 1306 | /* in addition, we set the wrap around min/max values to 512 * the min/max values */ | |
| 1307 | /* this takes into account the mapping that one mouse unit ~= 512 analog units */ | |
| 1308 | case IPT_DIAL: | |
| 1309 | case IPT_DIAL_V: | |
| 1310 | case IPT_MOUSE_X: | |
| 1311 | case IPT_MOUSE_Y: | |
| 1312 | case IPT_TRACKBALL_X: | |
| 1313 | case IPT_TRACKBALL_Y: | |
| 1314 | info->absolute = 0; | |
| 1315 | info->wraps = 1; | |
| 1316 | break; | |
| 1163 | /*------------------------------------------------- | |
| 1164 | input_port_read_crosshair - return the | |
| 1165 | extracted crosshair values for the given | |
| 1166 | player | |
| 1167 | -------------------------------------------------*/ | |
| 1317 | 1168 | |
| 1318 | /* positional devices are abolute, but can also wrap like relative devices */ | |
| 1319 | /* set each position to be 512 units */ | |
| 1320 | case IPT_POSITIONAL: | |
| 1321 | case IPT_POSITIONAL_V: | |
| 1322 | info->positionalscale = COMPUTE_SCALE(portentry->analog.max, INPUT_ABSOLUTE_MAX - INPUT_ABSOLUTE_MIN); | |
| 1323 | /* force to only use PORT_POSITIONS data */ | |
| 1324 | portentry->analog.min = 0; | |
| 1325 | portentry->analog.max--; | |
| 1326 | info->autocenter = !portentry->analog.wraps; | |
| 1327 | info->wraps = portentry->analog.wraps; | |
| 1328 | break; | |
| 1169 | int input_port_get_crosshair_position(running_machine *machine, int player, float *x, float *y) | |
| 1170 | { | |
| 1171 | const input_port_config *port; | |
| 1172 | const input_field_config *field; | |
| 1173 | int gotx = FALSE, goty = FALSE; | |
| 1329 | 1174 | |
| 1330 | default: | |
| 1331 | fatalerror("Unknown analog port type -- don't know if it is absolute or not"); | |
| 1332 | break; | |
| 1333 | } | |
| 1334 | ||
| 1335 | if (info->absolute) | |
| 1175 | /* read all the lightgun values */ | |
| 1176 | for (port = machine->portconfig; port != NULL; port = port->next) | |
| 1177 | for (field = port->fieldlist; field != NULL; field = field->next) | |
| 1178 | if (field->player == player && field->crossaxis != CROSSHAIR_AXIS_NONE) | |
| 1179 | if (input_condition_true(machine, &field->condition)) | |
| 1336 | 1180 | { |
| 1337 | /* if we are receiving data from the OSD input as absolute, | |
| 1338 | * and the emulated port type is absolute, | |
| 1339 | * and the default port value is between min/max, | |
| 1340 | * we need to scale differently for the +/- directions. | |
| 1341 | * All other absolute types use a 1:1 scale */ | |
| 1342 | info->single_scale = (portentry->default_value == portentry->analog.min) || (portentry->default_value == portentry->analog.max); | |
| 1181 | analog_field_state *analog = field->state->analog; | |
| 1182 | INT32 rawvalue = apply_analog_settings(analog->accum, analog) & (analog->field->mask >> analog->shift); | |
| 1183 | float value = (float)(rawvalue - field->state->analog->adjmin) / (float)(field->state->analog->adjmax - field->state->analog->adjmin); | |
| 1343 | 1184 | |
| 1344 | if (!info->single_scale) | |
| 1185 | /* apply the scale and offset */ | |
| 1186 | if (field->crossscale < 0) | |
| 1187 | value = -(1.0 - value) * field->crossscale; | |
| 1188 | else | |
| 1189 | value *= field->crossscale; | |
| 1190 | value += field->crossoffset; | |
| 1191 | ||
| 1192 | /* handle X axis */ | |
| 1193 | if (field->crossaxis == CROSSHAIR_AXIS_X) | |
| 1345 | 1194 | { |
| 1346 | /* axis moves in both directions from the default value */ | |
| 1347 | ||
| 1348 | /* unsigned */ | |
| 1349 | info->scalepos = COMPUTE_SCALE(portentry->analog.max - portentry->default_value, INPUT_ABSOLUTE_MAX - 0); | |
| 1350 | info->scaleneg = COMPUTE_SCALE(portentry->default_value - portentry->analog.min, 0 - INPUT_ABSOLUTE_MIN); | |
| 1351 | ||
| 1352 | if (portentry->analog.min > portentry->analog.max) | |
| 1195 | *x = value; | |
| 1196 | gotx = TRUE; | |
| 1197 | if (field->crossaltaxis != 0) | |
| 1353 | 1198 | { |
| 1354 | /* signed */ | |
| 1355 | info->scaleneg *= -1; | |
| 1199 | *y = field->crossaltaxis; | |
| 1200 | goty = TRUE; | |
| 1356 | 1201 | } |
| 1202 | } | |
| 1357 | 1203 | |
| 1358 | /* reverse from center */ | |
| 1359 | info->reverse_val = 0; | |
| 1360 | } | |
| 1204 | /* handle Y axis */ | |
| 1361 | 1205 | else |
| 1362 | 1206 | { |
| 1363 | /* single axis that increases from default */ | |
| 1364 | info->scalepos = COMPUTE_SCALE(portentry->analog.max - portentry->analog.min, INPUT_ABSOLUTE_MAX - INPUT_ABSOLUTE_MIN); | |
| 1207 | *y = value; | |
| 1208 | goty = TRUE; | |
| 1209 | if (field->crossaltaxis != 0) | |
| 1210 | { | |
| 1211 | *x = field->crossaltaxis; | |
| 1212 | gotx = TRUE; | |
| 1213 | } | |
| 1214 | } | |
| 1365 | 1215 | |
| 1366 | /* move from default */ | |
| 1367 | if (portentry->default_value == portentry->analog.max) | |
| 1368 | info->scalepos *= -1; | |
| 1369 | ||
| 1370 | /* make the scaling the same for easier coding when we need to scale */ | |
| 1371 | info->scaleneg = info->scalepos; | |
| 1372 | ||
| 1373 | /* reverse from max */ | |
| 1374 | info->reverse_val = info->maximum; | |
| 1375 | } | |
| 1216 | /* if we got both, stop */ | |
| 1217 | if (gotx && goty) | |
| 1218 | break; | |
| 1376 | 1219 | } |
| 1377 | 1220 | |
| 1378 | /* relative and positional controls all map directly with a 512x scale factor */ | |
| 1379 | else | |
| 1380 | { | |
| 1381 | /* The relative code is set up to allow specifing PORT_MINMAX and default values. */ | |
| 1382 | /* The validity checks are purposely set up to not allow you to use anything other */ | |
| 1383 | /* a default of 0 and PORT_MINMAX(0,mask). This is in case the need arises to use */ | |
| 1384 | /* this feature in the future. Keeping the code in does not hurt anything. */ | |
| 1385 | if (portentry->analog.min > portentry->analog.max) | |
| 1386 | /* adjust for signed */ | |
| 1387 | portentry->analog.min *= -1; | |
| 1221 | return (gotx && goty); | |
| 1222 | } | |
| 1388 | 1223 | |
| 1389 | info->minimum = (portentry->analog.min - portentry->default_value) * 512; | |
| 1390 | info->maximum = (portentry->analog.max - portentry->default_value) * 512; | |
| 1391 | 1224 | |
| 1392 | /* make the scaling the same for easier coding when we need to scale */ | |
| 1393 | info->scaleneg = info->scalepos = COMPUTE_SCALE(1, 512); | |
| 1225 | /*------------------------------------------------- | |
| 1226 | input_port_update_defaults - force an update | |
| 1227 | to the input port values based on current | |
| 1228 | conditions | |
| 1229 | -------------------------------------------------*/ | |
| 1394 | 1230 | |
| 1395 | if (portentry->analog.reset) | |
| 1396 | /* delta values reverse from center */ | |
| 1397 | info->reverse_val = 0; | |
| 1398 | else | |
| 1399 | { | |
| 1400 | /* positional controls reverse from their max range */ | |
| 1401 | info->reverse_val = info->maximum + info->minimum; | |
| 1231 | void input_port_update_defaults(running_machine *machine) | |
| 1232 | { | |
| 1233 | int loopnum; | |
| 1402 | 1234 | |
| 1403 | /* relative controls reverse from 1 past their max range */ | |
| 1404 | if (info->positionalscale == 0) | |
| 1405 | info->reverse_val += 512; | |
| 1406 | } | |
| 1407 | } | |
| 1235 | /* two passes to catch conditionals properly */ | |
| 1236 | for (loopnum = 0; loopnum < 2; loopnum++) | |
| 1237 | { | |
| 1238 | const input_port_config *port; | |
| 1408 | 1239 | |
| 1409 | /* compute scale for keypresses */ | |
| 1410 | info->keyscalepos = RECIP_SCALE(info->scalepos); | |
| 1411 | info->keyscaleneg = RECIP_SCALE(info->scaleneg); | |
| 1240 | /* loop over all input ports */ | |
| 1241 | for (port = machine->portconfig; port != NULL; port = port->next) | |
| 1242 | { | |
| 1243 | const input_field_config *field; | |
| 1412 | 1244 | |
| 1413 | /* hook in the list */ | |
| 1414 | info->next = port_info[portnum].analoginfo; | |
| 1415 | port_info[portnum].analoginfo = info; | |
| 1416 | } | |
| 1245 | /* only clear on the first pass */ | |
| 1246 | if (loopnum == 0) | |
| 1247 | port->state->defvalue = 0; | |
| 1417 | 1248 | |
| 1418 | /* if this is a digital joystick port, update info on it */ | |
| 1419 | else if (IS_DIGITAL_JOYSTICK(portentry)) | |
| 1420 | { | |
| 1421 | digital_joystick_info *info = JOYSTICK_INFO_FOR_PORT(portentry); | |
| 1422 | info->portentry[JOYSTICK_DIR_FOR_PORT(portentry)] = portentry; | |
| 1423 | info->inuse = 1; | |
| 1424 | } | |
| 1249 | /* first compute the default value for the entire port */ | |
| 1250 | for (field = port->fieldlist; field != NULL; field = field->next) | |
| 1251 | if (input_condition_true(machine, &field->condition)) | |
| 1252 | port->state->defvalue = (port->state->defvalue & ~field->mask) | (field->state->value & field->mask); | |
| 1425 | 1253 | } |
| 1426 | 1254 | } |
| 1255 | } | |
| 1427 | 1256 | |
| 1428 | /* run an initial update */ | |
| 1429 | input_port_frame_update(Machine); | |
| 1257 | ||
| 1258 | /*------------------------------------------------- | |
| 1259 | apply_analog_settings - return the value of | |
| 1260 | an input port | |
| 1261 | -------------------------------------------------*/ | |
| 1262 | ||
| 1263 | static INT32 apply_analog_settings(INT32 value, analog_field_state *analog) | |
| 1264 | { | |
| 1265 | /* apply the min/max and then the sensitivity */ | |
| 1266 | value = apply_analog_min_max(analog, value); | |
| 1267 | value = APPLY_SENSITIVITY(value, analog->sensitivity); | |
| 1268 | ||
| 1269 | /* apply reversal if needed */ | |
| 1270 | if (analog->reverse) | |
| 1271 | value = analog->reverse_val - value; | |
| 1272 | else if (analog->single_scale) | |
| 1273 | /* it's a pedal or the default value is equal to min/max */ | |
| 1274 | /* so we need to adjust the center to the minimum */ | |
| 1275 | value -= INPUT_ABSOLUTE_MIN; | |
| 1276 | ||
| 1277 | /* map differently for positive and negative values */ | |
| 1278 | if (value >= 0) | |
| 1279 | value = APPLY_SCALE(value, analog->scalepos); | |
| 1280 | else | |
| 1281 | value = APPLY_SCALE(value, analog->scaleneg); | |
| 1282 | value += analog->adjdefvalue; | |
| 1283 | ||
| 1284 | return value; | |
| 1430 | 1285 | } |
| 1431 | 1286 | |
| 1432 | 1287 | |
| 1433 | 1288 | |
| 1434 | /************************************* | |
| 1435 | * | |
| 1436 | * Identifies which port types are | |
| 1437 | * saved/loaded | |
| 1438 | * | |
| 1439 | *************************************/ | |
| 1289 | /*************************************************************************** | |
| 1290 | MISC HELPER FUNCTIONS | |
| 1291 | ***************************************************************************/ | |
| 1440 | 1292 | |
| 1441 | static int save_this_port_type(int type) | |
| 1293 | /*------------------------------------------------- | |
| 1294 | input_condition_true - return the TRUE | |
| 1295 | if the given condition attached is true | |
| 1296 | -------------------------------------------------*/ | |
| 1297 | ||
| 1298 | int input_condition_true(running_machine *machine, const input_condition *condition) | |
| 1442 | 1299 | { |
| 1443 | switch (type) | |
| 1300 | input_port_value condvalue; | |
| 1301 | ||
| 1302 | /* always condition is always true */ | |
| 1303 | if (condition->condition == PORTCOND_ALWAYS) | |
| 1304 | return TRUE; | |
| 1305 | ||
| 1306 | /* otherwise, read the referenced port */ | |
| 1307 | condvalue = input_port_read(machine, condition->tag); | |
| 1308 | ||
| 1309 | /* based on the condition encoded, determine truth */ | |
| 1310 | switch (condition->condition) | |
| 1444 | 1311 | { |
| 1445 | case IPT_UNUSED: | |
| 1446 | case IPT_END: | |
| 1447 | case IPT_PORT: | |
| 1448 | case IPT_DIPSWITCH_SETTING: | |
| 1449 | case IPT_CONFIG_SETTING: | |
| 1450 | case IPT_CATEGORY_SETTING: | |
| 1451 | case IPT_VBLANK: | |
| 1452 | case IPT_UNKNOWN: | |
| 1453 | return 0; | |
| 1312 | case PORTCOND_EQUALS: | |
| 1313 | return ((condvalue & condition->mask) == condition->value); | |
| 1314 | ||
| 1315 | case PORTCOND_NOTEQUALS: | |
| 1316 | return ((condvalue & condition->mask) != condition->value); | |
| 1454 | 1317 | } |
| 1455 | return | |
| 1318 | return TRUE; | |
| 1456 | 1319 | } |
| 1457 | 1320 | |
| 1458 | 1321 | |
| 1322 | /*------------------------------------------------- | |
| 1323 | input_port_string_from_token - convert an | |
| 1324 | input_port_token to a default string | |
| 1325 | -------------------------------------------------*/ | |
| 1459 | 1326 | |
| 1460 | /************************************* | |
| 1461 | * | |
| 1462 | * Input port configuration read | |
| 1463 | * | |
| 1464 | *************************************/ | |
| 1327 | const char *input_port_string_from_token(const input_port_token token) | |
| 1328 | { | |
| 1329 | int index; | |
| 1465 | 1330 | |
| 1466 | #ifdef UNUSED_FUNCTION | |
| 1467 | INLINE input_code get_default_code(int config_type, int type) | |
| 1331 | /* 0 is an invalid index */ | |
| 1332 | if (token.i == 0) | |
| 1333 | return NULL; | |
| 1334 | ||
| 1335 | /* if the index is greater than the count, assume it to be a pointer */ | |
| 1336 | if (token.i >= INPUT_STRING_COUNT) | |
| 1337 | return token.stringptr; | |
| 1338 | ||
| 1339 | /* otherwise, scan the list for a matching string and return it */ | |
| 1340 | for (index = 0; index < ARRAY_LENGTH(input_port_default_strings); index++) | |
| 1341 | if (input_port_default_strings[index].id == token.i) | |
| 1342 | return input_port_default_strings[index].string; | |
| 1343 | return "(Unknown Default)"; | |
| 1344 | } | |
| 1345 | ||
| 1346 | ||
| 1347 | ||
| 1348 | /*------------------------------------------------- | |
| 1349 | input_port_read_handler* - return a memory | |
| 1350 | handler corresponding to a given input port | |
| 1351 | tag | |
| 1352 | -------------------------------------------------*/ | |
| 1353 | ||
| 1354 | read8_machine_func input_port_read_handler8(const input_port_config *portlist, const char *tag) | |
| 1468 | 1355 | { |
| 1469 | switch (type) | |
| 1470 | { | |
| 1471 | case IPT_DIPSWITCH_NAME: | |
| 1472 | case IPT_CATEGORY_NAME: | |
| 1473 | return SEQCODE_END; | |
| 1356 | int portnum = get_port_index(portlist, tag); | |
| 1357 | return (portnum == -1) ? SMH_NOP : port_handler8[portnum]; | |
| 1358 | } | |
| 1474 | 1359 | |
| 1475 | default: | |
| 1476 | if (config_type != CONFIG_TYPE_GAME) | |
| 1477 | return SEQCODE_END; | |
| 1478 | else | |
| 1479 | return SEQCODE_DEFAULT; | |
| 1480 | } | |
| 1481 | return SEQCODE_END; | |
| 1360 | ||
| 1361 | read16_machine_func input_port_read_handler16(const input_port_config *portlist, const char *tag) | |
| 1362 | { | |
| 1363 | int portnum = get_port_index(portlist, tag); | |
| 1364 | return (portnum == -1) ? SMH_NOP : port_handler16[portnum]; | |
| 1482 | 1365 | } |
| 1483 | #endif | |
| 1484 | 1366 | |
| 1485 | 1367 | |
| 1486 | ||
| 1368 | read32_machine_func | |
| 1487 | 1369 | { |
| 1488 | int seqindex; | |
| 1370 | int portnum = get_port_index(portlist, tag); | |
| 1371 | return (portnum == -1) ? SMH_NOP : port_handler32[portnum]; | |
| 1372 | } | |
| 1489 | 1373 | |
| 1490 | for (seqindex = 0; seqindex < ARRAY_LENGTH(seqtypestrings); seqindex++) | |
| 1491 | if (!mame_stricmp(string, seqtypestrings[seqindex])) | |
| 1492 | return seqindex; | |
| 1493 | 1374 | |
| 1494 | return -1; | |
| 1375 | read64_machine_func input_port_read_handler64(const input_port_config *portlist, const char *tag) | |
| 1376 | { | |
| 1377 | return SMH_NOP; | |
| 1495 | 1378 | } |
| 1496 | 1379 | |
| 1497 | 1380 | |
| 1498 | static void apply_remaps(int count, const input_code *oldtable, const input_code *newtable) | |
| 1381 | ||
| 1382 | /*************************************************************************** | |
| 1383 | INITIALIZATION HELPERS | |
| 1384 | ***************************************************************************/ | |
| 1385 | ||
| 1386 | /*------------------------------------------------- | |
| 1387 | init_port_types - initialize the default | |
| 1388 | type list | |
| 1389 | -------------------------------------------------*/ | |
| 1390 | ||
| 1391 | static void init_port_types(running_machine *machine) | |
| 1499 | 1392 | { |
| 1500 | int remapnum; | |
| 1393 | input_port_private *portdata = machine->input_port_data; | |
| 1394 | input_type_state **stateptr; | |
| 1395 | input_type_state *curtype; | |
| 1396 | input_type_desc *lasttype = NULL; | |
| 1397 | int seqtype, typenum; | |
| 1501 | 1398 | |
| 1502 | /* loop over the remapping table, operating only if something was specified */ | |
| 1503 | for (remapnum = 0; remapnum < count; remapnum++) | |
| 1399 | /* convert the array into a list of type states that can be modified */ | |
| 1400 | portdata->typestatelist = NULL; | |
| 1401 | stateptr = &portdata->typestatelist; | |
| 1402 | for (typenum = 0; typenum < ARRAY_LENGTH(core_types); typenum++) | |
| 1504 | 1403 | { |
| 1505 | input_code oldcode = oldtable[remapnum]; | |
| 1506 | input_code newcode = newtable[remapnum]; | |
| 1507 | int portnum; | |
| 1404 | /* allocate memory for the state and link it to the end of the list */ | |
| 1405 | *stateptr = auto_malloc(sizeof(**stateptr)); | |
| 1406 | memset(*stateptr, 0, sizeof(**stateptr)); | |
| 1508 | 1407 | |
| 1509 | /* loop over all default ports, remapping the requested keys */ | |
| 1510 | for (portnum = 0; default_ports[portnum].type != IPT_END; portnum++) | |
| 1511 | { | |
| 1512 | input_port_default_entry *defport = &default_ports[portnum]; | |
| 1513 | int seqnum; | |
| 1408 | /* copy the type description and link the previous description to it */ | |
| 1409 | (*stateptr)->typedesc = core_types[typenum]; | |
| 1410 | if (lasttype != NULL) | |
| 1411 | lasttype->next = &(*stateptr)->typedesc; | |
| 1412 | lasttype = &(*stateptr)->typedesc; | |
| 1514 | 1413 | |
| 1515 | /* remap anything in the default sequences */ | |
| 1516 | for (seqnum = 0; seqnum < ARRAY_LENGTH(defport->defaultseq.code); seqnum++) | |
| 1517 | if (defport->defaultseq.code[seqnum] == oldcode) | |
| 1518 | defport->defaultseq.code[seqnum] = newcode; | |
| 1519 | for (seqnum = 0; seqnum < ARRAY_LENGTH(defport->defaultdecseq.code); seqnum++) | |
| 1520 | if (defport->defaultdecseq.code[seqnum] == oldcode) | |
| 1521 | defport->defaultdecseq.code[seqnum] = newcode; | |
| 1522 | for (seqnum = 0; seqnum < ARRAY_LENGTH(defport->defaultincseq.code); seqnum++) | |
| 1523 | if (defport->defaultincseq.code[seqnum] == oldcode) | |
| 1524 | defport->defaultincseq.code[seqnum] = newcode; | |
| 1525 | } | |
| 1414 | /* advance */ | |
| 1415 | stateptr = &(*stateptr)->next; | |
| 1526 | 1416 | } |
| 1417 | ||
| 1418 | /* ask the OSD to customize the list */ | |
| 1419 | osd_customize_input_type_list(&portdata->typestatelist->typedesc); | |
| 1420 | ||
| 1421 | /* now iterate over the OSD-modified types */ | |
| 1422 | for (curtype = portdata->typestatelist; curtype != NULL; curtype = curtype->next) | |
| 1423 | { | |
| 1424 | /* first copy all the OSD-updated sequences into our current state */ | |
| 1425 | for (seqtype = 0; seqtype < ARRAY_LENGTH(curtype->seq); seqtype++) | |
| 1426 | curtype->seq[seqtype] = curtype->typedesc.seq[seqtype]; | |
| 1427 | ||
| 1428 | /* also make a lookup table mapping type/player to the appropriate type list entry */ | |
| 1429 | portdata->type_to_typestate[curtype->typedesc.type][curtype->typedesc.player] = curtype; | |
| 1430 | } | |
| 1527 | 1431 | } |
| 1528 | 1432 | |
| 1529 | 1433 | |
| 1434 | /*------------------------------------------------- | |
| 1435 | init_port_state - initialize the live port | |
| 1436 | states based on the tokens | |
| 1437 | -------------------------------------------------*/ | |
| 1530 | 1438 | |
| 1531 | static i | |
| 1439 | static void | |
| 1532 | 1440 | { |
| 1533 | int portnum; | |
| 1441 | const char *joystick_map_default = options_get_string(mame_options(), OPTION_JOYSTICK_MAP); | |
| 1442 | input_port_private *portdata = machine->input_port_data; | |
| 1443 | const input_field_config *field; | |
| 1444 | const input_port_config *port; | |
| 1534 | 1445 | |
| 1535 | /* find a matching port in the list */ | |
| 1536 | for (portnum = 0; portnum < ARRAY_LENGTH(default_ports_backup); portnum++) | |
| 1446 | /* allocate live structures to mirror the configuration */ | |
| 1447 | for (port = machine->portconfig; port != NULL; port = port->next) | |
| 1537 | 1448 | { |
| 1538 | input_port_default_entry *updateport = &default_ports[portnum]; | |
| 1539 | if (updateport->type == type && updateport->player == player) | |
| 1449 | analog_field_state **analogstatetail; | |
| 1450 | callback_field_info **custominfotail; | |
| 1451 | callback_field_info **changedinfotail; | |
| 1452 | input_port_state *portstate; | |
| 1453 | ||
| 1454 | /* allocate a new input_port_info structure */ | |
| 1455 | portstate = auto_malloc(sizeof(*portstate)); | |
| 1456 | memset(portstate, 0, sizeof(*portstate)); | |
| 1457 | ((input_port_config *)port)->state = portstate; | |
| 1458 | ((input_port_config *)port)->machine = machine; | |
| 1459 | ||
| 1460 | /* start with tail pointers to all the data */ | |
| 1461 | analogstatetail = &portstate->analoglist; | |
| 1462 | custominfotail = &portstate->customlist; | |
| 1463 | changedinfotail = &portstate->changedlist; | |
| 1464 | ||
| 1465 | /* iterate over fields */ | |
| 1466 | for (field = port->fieldlist; field != NULL; field = field->next) | |
| 1540 | 1467 | { |
| 1541 | /* copy the sequence(s) that were specified */ | |
| 1542 | if (input_seq_get_1(&newseq[0]) != INPUT_CODE_INVALID) | |
| 1543 | updateport->defaultseq = newseq[0]; | |
| 1544 | if (input_seq_get_1(&newseq[1]) != INPUT_CODE_INVALID) | |
| 1545 | updateport->defaultdecseq = newseq[1]; | |
| 1546 | if (input_seq_get_1(&newseq[2]) != INPUT_CODE_INVALID) | |
| 1547 | updateport->defaultincseq = newseq[2]; | |
| 1548 | return 1; | |
| 1468 | input_field_state *fieldstate; | |
| 1469 | int seqtype; | |
| 1470 | ||
| 1471 | /* allocate a new input_field_info structure */ | |
| 1472 | fieldstate = auto_malloc(sizeof(*fieldstate)); | |
| 1473 | memset(fieldstate, 0, sizeof(*fieldstate)); | |
| 1474 | ((input_field_config *)field)->state = fieldstate; | |
| 1475 | ||
| 1476 | /* fill in the basic values */ | |
| 1477 | for (seqtype = 0; seqtype < ARRAY_LENGTH(fieldstate->seq); seqtype++) | |
| 1478 | fieldstate->seq[seqtype] = field->seq[seqtype]; | |
| 1479 | fieldstate->value = field->defvalue; | |
| 1480 | ||
| 1481 | /* if this is an analog field, allocate memory for the analog data */ | |
| 1482 | if (field->type >= __ipt_analog_start && field->type <= __ipt_analog_end) | |
| 1483 | { | |
| 1484 | *analogstatetail = fieldstate->analog = init_field_analog_state(field); | |
| 1485 | analogstatetail = &(*analogstatetail)->next; | |
| 1486 | } | |
| 1487 | ||
| 1488 | /* if this is a digital joystick field, make a note of it */ | |
| 1489 | if (field->type >= __ipt_digital_joystick_start && field->type <= __ipt_digital_joystick_end) | |
| 1490 | { | |
| 1491 | fieldstate->joystick = &portdata->joystick_info[field->player][(field->type - __ipt_digital_joystick_start) / 4]; | |
| 1492 | fieldstate->joydir = (field->type - __ipt_digital_joystick_start) % 4; | |
| 1493 | fieldstate->joystick->field[fieldstate->joydir] = field; | |
| 1494 | fieldstate->joystick->inuse = TRUE; | |
| 1495 | } | |
| 1496 | ||
| 1497 | /* if this entry has custom callback, allocate memory for the tracking structure */ | |
| 1498 | if (field->custom != NULL) | |
| 1499 | { | |
| 1500 | *custominfotail = init_field_callback_info(field); | |
| 1501 | custominfotail = &(*custominfotail)->next; | |
| 1502 | } | |
| 1503 | ||
| 1504 | /* if this entry has changed callback, allocate memory for the tracking structure */ | |
| 1505 | if (field->changed != NULL) | |
| 1506 | { | |
| 1507 | *changedinfotail = init_field_callback_info(field); | |
| 1508 | changedinfotail = &(*changedinfotail)->next; | |
| 1509 | } | |
| 1549 | 1510 | } |
| 1550 | 1511 | } |
| 1551 | return 0; | |
| 1512 | ||
| 1513 | /* handle autoselection of devices */ | |
| 1514 | init_autoselect_devices(machine->portconfig, IPT_PADDLE, IPT_PADDLE_V, 0, OPTION_PADDLE_DEVICE, "paddle"); | |
| 1515 | init_autoselect_devices(machine->portconfig, IPT_AD_STICK_X, IPT_AD_STICK_Y, IPT_AD_STICK_Z, OPTION_ADSTICK_DEVICE, "analog joystick"); | |
| 1516 | init_autoselect_devices(machine->portconfig, IPT_LIGHTGUN_X, IPT_LIGHTGUN_Y, 0, OPTION_LIGHTGUN_DEVICE, "lightgun"); | |
| 1517 | init_autoselect_devices(machine->portconfig, IPT_PEDAL, IPT_PEDAL2, IPT_PEDAL3, OPTION_PEDAL_DEVICE, "pedal"); | |
| 1518 | init_autoselect_devices(machine->portconfig, IPT_DIAL, IPT_DIAL_V, 0, OPTION_DIAL_DEVICE, "dial"); | |
| 1519 | init_autoselect_devices(machine->portconfig, IPT_TRACKBALL_X, IPT_TRACKBALL_Y, 0, OPTION_TRACKBALL_DEVICE, "trackball"); | |
| 1520 | init_autoselect_devices(machine->portconfig, IPT_POSITIONAL, IPT_POSITIONAL_V, 0, OPTION_POSITIONAL_DEVICE, "positional"); | |
| 1521 | init_autoselect_devices(machine->portconfig, IPT_MOUSE_X, IPT_MOUSE_Y, 0, OPTION_MOUSE_DEVICE, "mouse"); | |
| 1522 | ||
| 1523 | /* look for 4-way joysticks and change the default map if we find any */ | |
| 1524 | if (joystick_map_default[0] == 0 || strcmp(joystick_map_default, "auto") == 0) | |
| 1525 | for (port = machine->portconfig; port != NULL; port = port->next) | |
| 1526 | for (field = port->fieldlist; field != NULL; field = field->next) | |
| 1527 | if (field->state->joystick != NULL && field->way == 4) | |
| 1528 | { | |
| 1529 | input_device_set_joystick_map(-1, (field->flags & FIELD_FLAG_ROTATED) ? joystick_map_4way_diagonal : joystick_map_4way_sticky); | |
| 1530 | break; | |
| 1531 | } | |
| 1552 | 1532 | } |
| 1553 | 1533 | |
| 1554 | 1534 | |
| 1555 | static int apply_config_to_current(xml_data_node *portnode, int type, int player, input_seq *newseq) | |
| 1535 | /*------------------------------------------------- | |
| 1536 | init_autoselect_devices - autoselect a single | |
| 1537 | device based on the input port list passed | |
| 1538 | in and the corresponding option | |
| 1539 | -------------------------------------------------*/ | |
| 1540 | ||
| 1541 | static void init_autoselect_devices(const input_port_config *portlist, int type1, int type2, int type3, const char *option, const char *ananame) | |
| 1556 | 1542 | { |
| 1557 | input_port_entry *updateport; | |
| 1558 | int mask, defvalue, index; | |
| 1543 | const char *stemp = options_get_string(mame_options(), option); | |
| 1544 | input_device_class autoenable = DEVICE_CLASS_KEYBOARD; | |
| 1545 | const char *autostring = "keyboard"; | |
| 1546 | const input_field_config *field; | |
| 1547 | const input_port_config *port; | |
| 1559 | 1548 | |
| 1560 | /* read the mask, index, and defvalue attributes */ | |
| 1561 | index = xml_get_attribute_int(portnode, "index", 0); | |
| 1562 | mask = xml_get_attribute_int(portnode, "mask", 0); | |
| 1563 | defvalue = xml_get_attribute_int(portnode, "defvalue", 0); | |
| 1549 | /* if nothing specified, ignore the option */ | |
| 1550 | if (stemp[0] == 0) | |
| 1551 | return; | |
| 1564 | 1552 | |
| 1565 | /* find the indexed port; we scan the array to make sure we don't read past the end */ | |
| 1566 | for (updateport = input_ports_default; updateport->type != IPT_END; updateport++) | |
| 1567 | if (index-- == 0) | |
| 1568 | break; | |
| 1569 | ||
| 1570 | /* verify that it matches */ | |
| 1571 | if (updateport->type == type && updateport->player == player && | |
| 1572 | updateport->mask == mask && (updateport->default_value & mask) == (defvalue & mask)) | |
| 1553 | /* extract valid strings */ | |
| 1554 | if (strcmp(stemp, "mouse") == 0) | |
| 1573 | 1555 | { |
| 1574 | const char *revstring; | |
| 1556 | autoenable = DEVICE_CLASS_MOUSE; | |
| 1557 | autostring = "mouse"; | |
| 1558 | } | |
| 1559 | else if (strcmp(stemp, "joystick") == 0) | |
| 1560 | { | |
| 1561 | autoenable = DEVICE_CLASS_JOYSTICK; | |
| 1562 | autostring = "joystick"; | |
| 1563 | } | |
| 1564 | else if (strcmp(stemp, "lightgun") == 0) | |
| 1565 | { | |
| 1566 | autoenable = DEVICE_CLASS_LIGHTGUN; | |
| 1567 | autostring = "lightgun"; | |
| 1568 | } | |
| 1569 | else if (strcmp(stemp, "none") == 0) | |
| 1570 | { | |
| 1571 | /* nothing specified */ | |
| 1572 | return; | |
| 1573 | } | |
| 1574 | else if (strcmp(stemp, "keyboard") != 0) | |
| 1575 | mame_printf_error("Invalid %s value %s; reverting to keyboard\n", option, stemp); | |
| 1575 | 1576 | |
| 1576 | /* point to the real port */ | |
| 1577 | updateport = Machine->input_ports + (updateport - input_ports_default); | |
| 1577 | /* only scan the list if we haven't already enabled this class of control */ | |
| 1578 | if (!input_device_class_enabled(autoenable)) | |
| 1579 | for (port = portlist; port != NULL; port = port->next) | |
| 1580 | for (field = port->fieldlist; field != NULL; field = field->next) | |
| 1578 | 1581 | |
| 1579 | /* fill in the data from the attributes */ | |
| 1580 | if (!port_type_is_analog(updateport->type)) | |
| 1581 | updateport->default_value = xml_get_attribute_int(portnode, "value", updateport->default_value); | |
| 1582 | updateport->analog.delta = xml_get_attribute_int(portnode, "keydelta", updateport->analog.delta); | |
| 1583 | updateport->analog.centerdelta = xml_get_attribute_int(portnode, "centerdelta", updateport->analog.centerdelta); | |
| 1584 | updateport->analog.sensitivity = xml_get_attribute_int(portnode, "sensitivity", updateport->analog.sensitivity); | |
| 1585 | revstring = xml_get_attribute_string(portnode, "reverse", NULL); | |
| 1586 | if (revstring) | |
| 1587 | updateport->analog.reverse = (strcmp(revstring, "yes") == 0); | |
| 1582 | /* if this port type is in use, apply the autoselect criteria */ | |
| 1583 | if ((type1 != 0 && field->type == type1) || | |
| 1584 | (type2 != 0 && field->type == type2) || | |
| 1585 | (type3 != 0 && field->type == type3)) | |
| 1586 | { | |
| 1587 | mame_printf_verbose("Input: Autoenabling %s due to presence of a %s\n", autostring, ananame); | |
| 1588 | input_device_class_enable(autoenable, TRUE); | |
| 1589 | break; | |
| 1590 | } | |
| 1591 | } | |
| 1588 | 1592 | |
| 1589 | /* copy the sequence(s) that were specified */ | |
| 1590 | if (input_seq_get_1(&newseq[0]) != INPUT_CODE_INVALID) | |
| 1591 | updateport->seq = newseq[0]; | |
| 1592 | if (input_seq_get_1(&newseq[1]) != INPUT_CODE_INVALID) | |
| 1593 | updateport->analog.decseq = newseq[1]; | |
| 1594 | if (input_seq_get_1(&newseq[2]) != INPUT_CODE_INVALID) | |
| 1595 | updateport->analog.incseq = newseq[2]; | |
| 1596 | return 1; | |
| 1597 | } | |
| 1598 | return 0; | |
| 1593 | ||
| 1594 | /*------------------------------------------------- | |
| 1595 | init_field_callback_info - allocate and populate | |
| 1596 | information about a changed or custom | |
| 1597 | callback | |
| 1598 | -------------------------------------------------*/ | |
| 1599 | ||
| 1600 | static callback_field_info *init_field_callback_info(const input_field_config *field) | |
| 1601 | { | |
| 1602 | callback_field_info *info; | |
| 1603 | input_port_value mask; | |
| 1604 | ||
| 1605 | /* allocate memory */ | |
| 1606 | info = auto_malloc(sizeof(*info)); | |
| 1607 | memset(info, 0, sizeof(*info)); | |
| 1608 | ||
| 1609 | /* fill in the data */ | |
| 1610 | info->field = field; | |
| 1611 | for (mask = field->mask; !(mask & 1); mask >>= 1) | |
| 1612 | info->shift++; | |
| 1613 | ||
| 1614 | return info; | |
| 1599 | 1615 | } |
| 1600 | 1616 | |
| 1601 | 1617 | |
| 1602 | static void input_port_load(int config_type, xml_data_node *parentnode) | |
| 1618 | /*------------------------------------------------- | |
| 1619 | init_field_analog_state - allocate and populate | |
| 1620 | information about an analog port | |
| 1621 | -------------------------------------------------*/ | |
| 1622 | ||
| 1623 | static analog_field_state *init_field_analog_state(const input_field_config *field) | |
| 1603 | 1624 | { |
| 1604 | xml_data_node *portnode; | |
| 1605 | int seqnum; | |
| 1625 | analog_field_state *state; | |
| 1626 | input_port_value mask; | |
| 1606 | 1627 | |
| 1607 | /* in the completion phase, we finish the initialization with the final ports */ | |
| 1608 | if (config_type == CONFIG_TYPE_FINAL) | |
| 1609 | input_port_postload(); | |
| 1628 | /* allocate memory */ | |
| 1629 | state = auto_malloc(sizeof(*state)); | |
| 1630 | memset(state, 0, sizeof(*state)); | |
| 1610 | 1631 | |
| 1611 | /* early exit if no data to parse */ | |
| 1612 | if (!parentnode) | |
| 1613 | return; | |
| 1632 | /* compute the shift amount and number of bits */ | |
| 1633 | for (mask = field->mask; !(mask & 1); mask >>= 1) | |
| 1634 | state->shift++; | |
| 1614 | 1635 | |
| 1615 | /* iterate over all the remap nodes for controller configs only */ | |
| 1616 | if (config_type == CONFIG_TYPE_CONTROLLER) | |
| 1636 | /* initialize core data */ | |
| 1637 | state->field = field; | |
| 1638 | state->adjdefvalue = (field->defvalue & field->mask) >> state->shift; | |
| 1639 | state->adjmin = (field->min & field->mask) >> state->shift; | |
| 1640 | state->adjmax = (field->max & field->mask) >> state->shift; | |
| 1641 | state->sensitivity = field->sensitivity; | |
| 1642 | state->reverse = ((field->flags & ANALOG_FLAG_REVERSE) != 0); | |
| 1643 | state->delta = field->delta; | |
| 1644 | state->centerdelta = field->centerdelta; | |
| 1645 | state->minimum = INPUT_ABSOLUTE_MIN; | |
| 1646 | state->maximum = INPUT_ABSOLUTE_MAX; | |
| 1647 | ||
| 1648 | /* set basic parameters based on the configured type */ | |
| 1649 | switch (field->type) | |
| 1617 | 1650 | { |
| 1618 | input_code *oldtable, *newtable; | |
| 1619 | xml_data_node *remapnode; | |
| 1620 | int count; | |
| 1651 | /* pedals start at and autocenter to the min range */ | |
| 1652 | case IPT_PEDAL: | |
| 1653 | case IPT_PEDAL2: | |
| 1654 | case IPT_PEDAL3: | |
| 1655 | state->center = INPUT_ABSOLUTE_MIN; | |
| 1656 | state->accum = APPLY_INVERSE_SENSITIVITY(state->center, state->sensitivity); | |
| 1657 | state->absolute = TRUE; | |
| 1658 | state->autocenter = TRUE; | |
| 1659 | state->interpolate = TRUE; | |
| 1660 | break; | |
| 1621 | 1661 | |
| 1622 | /* count items first so we can allocate */ | |
| 1623 | count = 0; | |
| 1624 | for (remapnode = xml_get_sibling(parentnode->child, "remap"); remapnode; remapnode = xml_get_sibling(remapnode->next, "remap")) | |
| 1625 | count++; | |
| 1662 | /* paddles and analog joysticks are absolute and autocenter */ | |
| 1663 | case IPT_AD_STICK_X: | |
| 1664 | case IPT_AD_STICK_Y: | |
| 1665 | case IPT_AD_STICK_Z: | |
| 1666 | case IPT_PADDLE: | |
| 1667 | case IPT_PADDLE_V: | |
| 1668 | state->absolute = TRUE; | |
| 1669 | state->autocenter = TRUE; | |
| 1670 | state->interpolate = TRUE; | |
| 1671 | break; | |
| 1626 | 1672 | |
| 1627 | /* if we have some, deal with them */ | |
| 1628 | if (count > 0) | |
| 1673 | /* lightguns are absolute as well, but don't autocenter and don't interpolate their values */ | |
| 1674 | case IPT_LIGHTGUN_X: | |
| 1675 | case IPT_LIGHTGUN_Y: | |
| 1676 | state->absolute = TRUE; | |
| 1677 | state->autocenter = FALSE; | |
| 1678 | state->interpolate = FALSE; | |
| 1679 | break; | |
| 1680 | ||
| 1681 | /* dials, mice and trackballs are relative devices */ | |
| 1682 | /* these have fixed "min" and "max" values based on how many bits are in the port */ | |
| 1683 | /* in addition, we set the wrap around min/max values to 512 * the min/max values */ | |
| 1684 | /* this takes into account the mapping that one mouse unit ~= 512 analog units */ | |
| 1685 | case IPT_DIAL: | |
| 1686 | case IPT_DIAL_V: | |
| 1687 | case IPT_MOUSE_X: | |
| 1688 | case IPT_MOUSE_Y: | |
| 1689 | case IPT_TRACKBALL_X: | |
| 1690 | case IPT_TRACKBALL_Y: | |
| 1691 | state->absolute = FALSE; | |
| 1692 | state->wraps = TRUE; | |
| 1693 | state->interpolate = TRUE; | |
| 1694 | break; | |
| 1695 | ||
| 1696 | /* positional devices are abolute, but can also wrap like relative devices */ | |
| 1697 | /* set each position to be 512 units */ | |
| 1698 | case IPT_POSITIONAL: | |
| 1699 | case IPT_POSITIONAL_V: | |
| 1700 | state->positionalscale = COMPUTE_SCALE(state->adjmax, INPUT_ABSOLUTE_MAX - INPUT_ABSOLUTE_MIN); | |
| 1701 | state->adjmin = 0; | |
| 1702 | state->adjmax--; | |
| 1703 | state->wraps = ((field->flags & ANALOG_FLAG_WRAPS) != 0); | |
| 1704 | state->autocenter = !state->wraps; | |
| 1705 | break; | |
| 1706 | ||
| 1707 | default: | |
| 1708 | fatalerror("Unknown analog port type -- don't know if it is absolute or not"); | |
| 1709 | break; | |
| 1710 | } | |
| 1711 | ||
| 1712 | /* further processing for absolute controls */ | |
| 1713 | if (state->absolute) | |
| 1714 | { | |
| 1715 | /* if the default value is pegged at the min or max, use a single scale value for the whole axis */ | |
| 1716 | state->single_scale = (state->adjdefvalue == state->adjmin) || (state->adjdefvalue == state->adjmax); | |
| 1717 | ||
| 1718 | /* if not "single scale", compute separate scales for each side of the default */ | |
| 1719 | if (!state->single_scale) | |
| 1629 | 1720 | { |
| 1630 | /* allocate tables */ | |
| 1631 | oldtable = malloc_or_die(count * sizeof(*oldtable)); | |
| 1632 | newtable = malloc_or_die(count * sizeof(*newtable)); | |
| 1721 | /* unsigned */ | |
| 1722 | state->scalepos = COMPUTE_SCALE(state->adjmax - state->adjdefvalue, INPUT_ABSOLUTE_MAX - 0); | |
| 1723 | state->scaleneg = COMPUTE_SCALE(state->adjdefvalue - state->adjmin, 0 - INPUT_ABSOLUTE_MIN); | |
| 1633 | 1724 | |
| 1634 | /* build up the remap table */ | |
| 1635 | count = 0; | |
| 1636 | for (remapnode = xml_get_sibling(parentnode->child, "remap"); remapnode; remapnode = xml_get_sibling(remapnode->next, "remap")) | |
| 1637 | { | |
| 1638 | input_code origcode = input_code_from_token(xml_get_attribute_string(remapnode, "origcode", "")); | |
| 1639 | input_code newcode = input_code_from_token(xml_get_attribute_string(remapnode, "newcode", "")); | |
| 1640 | if (origcode != INPUT_CODE_INVALID && newcode != INPUT_CODE_INVALID) | |
| 1641 | { | |
| 1642 | oldtable[count] = origcode; | |
| 1643 | newtable[count] = newcode; | |
| 1644 | count++; | |
| 1645 | } | |
| 1646 | } | |
| 1725 | if (state->adjmin > state->adjmax) | |
| 1726 | state->scaleneg = -state->scaleneg; | |
| 1647 | 1727 | |
| 1648 | /* apply it then free the tables */ | |
| 1649 | apply_remaps(count, oldtable, newtable); | |
| 1650 | free(oldtable); | |
| 1651 | free(newtable); | |
| 1728 | /* reverse point is at center */ | |
| 1729 | state->reverse_val = 0; | |
| 1652 | 1730 | } |
| 1731 | else | |
| 1732 | { | |
| 1733 | /* single axis that increases from default */ | |
| 1734 | state->scalepos = COMPUTE_SCALE(state->adjmax - state->adjmin, INPUT_ABSOLUTE_MAX - INPUT_ABSOLUTE_MIN); | |
| 1735 | ||
| 1736 | /* move from default */ | |
| 1737 | if (state->adjdefvalue == state->adjmax) | |
| 1738 | state->scalepos = -state->scalepos; | |
| 1739 | ||
| 1740 | /* make the scaling the same for easier coding when we need to scale */ | |
| 1741 | state->scaleneg = state->scalepos; | |
| 1742 | ||
| 1743 | /* reverse point is at max */ | |
| 1744 | state->reverse_val = state->maximum; | |
| 1745 | } | |
| 1653 | 1746 | } |
| 1654 | 1747 | |
| 1655 | /* iterate over all the port nodes */ | |
| 1656 | for (portnode = xml_get_sibling(parentnode->child, "port"); portnode; portnode = xml_get_sibling(portnode->next, "port")) | |
| 1748 | /* relative and positional controls all map directly with a 512x scale factor */ | |
| 1749 | else | |
| 1657 | 1750 | { |
| 1658 | input_seq newseq[3], tempseq; | |
| 1659 | xml_data_node *seqnode; | |
| 1660 | int type, player; | |
| 1751 | /* The relative code is set up to allow specifing PORT_MINMAX and default values. */ | |
| 1752 | /* The validity checks are purposely set up to not allow you to use anything other */ | |
| 1753 | /* a default of 0 and PORT_MINMAX(0,mask). This is in case the need arises to use */ | |
| 1754 | /* this feature in the future. Keeping the code in does not hurt anything. */ | |
| 1755 | if (state->adjmin > state->adjmax) | |
| 1756 | /* adjust for signed */ | |
| 1757 | state->adjmin = -state->adjmin; | |
| 1661 | 1758 | |
| 1662 | /* get the basic port info from the attributes */ | |
| 1663 | type = token_to_port_type(xml_get_attribute_string(portnode, "type", ""), &player); | |
| 1759 | state->minimum = (state->adjmin - state->adjdefvalue) * 512; | |
| 1760 | state->maximum = (state->adjmax - state->adjdefvalue) * 512; | |
| 1664 | 1761 | |
| 1665 | /* initialize sequences to invalid defaults */ | |
| 1666 | for (seqnum = 0; seqnum < 3; seqnum++) | |
| 1667 | input_seq_set_1(&newseq[seqnum], INPUT_CODE_INVALID); | |
| 1762 | /* make the scaling the same for easier coding when we need to scale */ | |
| 1763 | state->scaleneg = state->scalepos = COMPUTE_SCALE(1, 512); | |
| 1668 | 1764 | |
| 1669 | /* loop over new sequences */ | |
| 1670 | for (seqnode = xml_get_sibling(portnode->child, "newseq"); seqnode; seqnode = xml_get_sibling(seqnode->next, "newseq")) | |
| 1765 | if (field->flags & ANALOG_FLAG_RESET) | |
| 1766 | /* delta values reverse from center */ | |
| 1767 | state->reverse_val = 0; | |
| 1768 | else | |
| 1671 | 1769 | { |
| 1672 | /* with a valid type, parse out the new sequence */ | |
| 1673 | seqnum = string_to_seq_index(xml_get_attribute_string(seqnode, "type", "")); | |
| 1674 | if (seqnum != -1) | |
| 1675 | if (seqnode->value != NULL) | |
| 1676 | { | |
| 1677 | if (strcmp(seqnode->value, "NONE") == 0) | |
| 1678 | input_seq_set_0(&newseq[seqnum]); | |
| 1679 | else if (input_seq_from_tokens(seqnode->value, &tempseq) != 0) | |
| 1680 | newseq[seqnum] = tempseq; | |
| 1681 | } | |
| 1770 | /* positional controls reverse from their max range */ | |
| 1771 | state->reverse_val = state->maximum + state->minimum; | |
| 1772 | ||
| 1773 | /* relative controls reverse from 1 past their max range */ | |
| 1774 | if (state->positionalscale == 0) | |
| 1775 | state->reverse_val += 512; | |
| 1682 | 1776 | } |
| 1683 | ||
| 1684 | /* if we're loading default ports, apply to the default_ports */ | |
| 1685 | if (config_type != CONFIG_TYPE_GAME) | |
| 1686 | apply_config_to_default(portnode, type, player, newseq); | |
| 1687 | else | |
| 1688 | apply_config_to_current(portnode, type, player, newseq); | |
| 1689 | 1777 | } |
| 1690 | 1778 | |
| 1691 | /* after applying the controller config, push that back into the backup, since that is */ | |
| 1692 | /* what we will diff against */ | |
| 1693 | if (config_type == CONFIG_TYPE_CONTROLLER) | |
| 1694 | memcpy(default_ports_backup, default_ports, sizeof(default_ports_backup)); | |
| 1779 | /* compute scale for keypresses */ | |
| 1780 | state->keyscalepos = RECIP_SCALE(state->scalepos); | |
| 1781 | state->keyscaleneg = RECIP_SCALE(state->scaleneg); | |
| 1782 | ||
| 1783 | return state; | |
| 1695 | 1784 | } |
| 1696 | 1785 | |
| 1697 | 1786 | |
| 1698 | 1787 | |
| 1699 | /************************************* | |
| 1700 | * | |
| 1701 | * Input port configuration write | |
| 1702 | * | |
| 1703 | *************************************/ | |
| 1788 | /*************************************************************************** | |
| 1789 | ONCE-PER-FRAME UPDATES | |
| 1790 | ***************************************************************************/ | |
| 1704 | 1791 | |
| 1705 | static void add_sequence(xml_data_node *parentnode, int type, int porttype, const input_seq *seq) | |
| 1792 | /*------------------------------------------------- | |
| 1793 | frame_update_callback - system-wide callback to | |
| 1794 | update the input ports once per frame, but | |
| 1795 | only if we are not paused | |
| 1796 | -------------------------------------------------*/ | |
| 1797 | ||
| 1798 | static void frame_update_callback(running_machine *machine) | |
| 1706 | 1799 | { |
| 1707 | astring *seqstring = astring_alloc(); | |
| 1708 | xml_data_node *seqnode; | |
| 1800 | /* if we're paused, don't do anything */ | |
| 1801 | if (mame_is_paused(machine)) | |
| 1802 | return; | |
| 1709 | 1803 | |
| 1710 | /* get the string for the sequence */ | |
| 1711 | if (input_seq_get_1(seq) == SEQCODE_END) | |
| 1712 | astring_cpyc(seqstring, "NONE"); | |
| 1713 | else | |
| 1714 | input_seq_to_tokens(seqstring, seq); | |
| 1715 | ||
| 1716 | /* add the new node */ | |
| 1717 | seqnode = xml_add_child(parentnode, "newseq", astring_c(seqstring)); | |
| 1718 | if (seqnode) | |
| 1719 | xml_set_attribute(seqnode, "type", seqtypestrings[type]); | |
| 1720 | astring_free(seqstring); | |
| 1804 | /* otherwise, use the common code */ | |
| 1805 | frame_update(machine); | |
| 1721 | 1806 | } |
| 1722 | 1807 | |
| 1723 | 1808 | |
| 1724 | static void save_default_inputs(xml_data_node *parentnode) | |
| 1809 | /*------------------------------------------------- | |
| 1810 | frame_update - core logic for per-frame input | |
| 1811 | port updating | |
| 1812 | -------------------------------------------------*/ | |
| 1813 | ||
| 1814 | static void frame_update(running_machine *machine) | |
| 1725 | 1815 | { |
| 1726 | int portnum; | |
| 1816 | input_port_private *portdata = machine->input_port_data; | |
| 1817 | int ui_visible = ui_is_menu_active() || ui_is_slider_active(); | |
| 1818 | attotime curtime = timer_get_time(); | |
| 1819 | const input_port_config *port; | |
| 1727 | 1820 | |
| 1728 | /* iterate over ports */ | |
| 1729 | for (portnum = 0; portnum < ARRAY_LENGTH(default_ports_backup); portnum++) | |
| 1821 | profiler_mark(PROFILER_INPUT); | |
| 1822 | ||
| 1823 | /* record/playback information about the current frame */ | |
| 1824 | playback_frame(machine, curtime); | |
| 1825 | record_frame(machine, curtime); | |
| 1826 | ||
| 1827 | /* track the duration of the previous frame */ | |
| 1828 | portdata->last_delta_nsec = attotime_to_attoseconds(attotime_sub(curtime, portdata->last_frame_time)) / ATTOSECONDS_PER_NANOSECOND; | |
| 1829 | portdata->last_frame_time = curtime; | |
| 1830 | ||
| 1831 | /* update the digital joysticks */ | |
| 1832 | frame_update_digital_joysticks(machine); | |
| 1833 | ||
| 1834 | /* compute default values for all the ports */ | |
| 1835 | input_port_update_defaults(machine); | |
| 1836 | ||
| 1837 | /* loop over all input ports */ | |
| 1838 | for (port = machine->portconfig; port != NULL; port = port->next) | |
| 1730 | 1839 | { |
| 1731 | input_port_default_entry *defport = &default_ports_backup[portnum]; | |
| 1732 | input_port_default_entry *curport = &default_ports[portnum]; | |
| 1840 | const input_field_config *field; | |
| 1841 | callback_field_info *changed; | |
| 1842 | input_port_value newvalue; | |
| 1733 | 1843 | |
| 1734 | /* only save if something has changed and this port is a type we save */ | |
| 1735 | if (save_this_port_type(defport->type) && | |
| 1736 | (input_seq_cmp(&defport->defaultseq, &curport->defaultseq) != 0 || | |
| 1737 | input_seq_cmp(&defport->defaultdecseq, &curport->defaultdecseq) != 0 || | |
| 1738 | input_seq_cmp(&defport->defaultincseq, &curport->defaultincseq) != 0)) | |
| 1844 | /* start with 0 values for the digital and VBLANK bits */ | |
| 1845 | port->state->digital = 0; | |
| 1846 | port->state->vblank = 0; | |
| 1847 | ||
| 1848 | /* now loop back and modify based on the inputs */ | |
| 1849 | for (field = port->fieldlist; field != NULL; field = field->next) | |
| 1850 | if (input_condition_true(port->machine, &field->condition)) | |
| 1851 | { | |
| 1852 | /* accumulate VBLANK bits */ | |
| 1853 | if (field->type == IPT_VBLANK) | |
| 1854 | port->state->vblank ^= field->mask; | |
| 1855 | ||
| 1856 | /* handle analog inputs */ | |
| 1857 | else if (field->state->analog != NULL) | |
| 1858 | frame_update_analog_field(field->state->analog); | |
| 1859 | ||
| 1860 | /* handle non-analog types, but only when the UI isn't visible */ | |
| 1861 | else if (!ui_visible && frame_get_digital_field_state(field)) | |
| 1862 | port->state->digital |= field->mask; | |
| 1863 | } | |
| 1864 | ||
| 1865 | #ifdef MESS | |
| 1866 | /* hook for MESS's natural keyboard support */ | |
| 1867 | mess_input_port_update_hook(machine, port); | |
| 1868 | #endif /* MESS */ | |
| 1869 | ||
| 1870 | /* call changed handlers */ | |
| 1871 | newvalue = input_port_read_direct(port); | |
| 1872 | for (changed = port->state->changedlist; changed; changed = changed->next) | |
| 1873 | if (input_condition_true(port->machine, &changed->field->condition)) | |
| 1874 | { | |
| 1875 | input_port_value oldbits = (port->state->lastvalue & changed->field->mask) >> changed->shift; | |
| 1876 | input_port_value newbits = (newvalue & changed->field->mask) >> changed->shift; | |
| 1877 | ||
| 1878 | /* if the bits have changed, call the handler */ | |
| 1879 | if (oldbits != newbits) | |
| 1880 | (*changed->field->changed)(changed->field, changed->field->changed_param, oldbits, newbits); | |
| 1881 | } | |
| 1882 | ||
| 1883 | /* remember the last value */ | |
| 1884 | port->state->lastvalue = newvalue; | |
| 1885 | } | |
| 1886 | ||
| 1887 | /* handle playback/record */ | |
| 1888 | for (port = machine->portconfig; port != NULL; port = port->next) | |
| 1889 | { | |
| 1890 | playback_port(port); | |
| 1891 | record_port(port); | |
| 1892 | } | |
| 1893 | ||
| 1894 | profiler_mark(PROFILER_END); | |
| 1895 | } | |
| 1896 | ||
| 1897 | ||
| 1898 | /*------------------------------------------------- | |
| 1899 | frame_update_digital_joysticks - update the | |
| 1900 | state of digital joysticks prior to | |
| 1901 | accumulating the results in a port | |
| 1902 | -------------------------------------------------*/ | |
| 1903 | ||
| 1904 | static void frame_update_digital_joysticks(running_machine *machine) | |
| 1905 | { | |
| 1906 | input_port_private *portdata = machine->input_port_data; | |
| 1907 | int player, joyindex; | |
| 1908 | ||
| 1909 | /* loop over all the joysticks */ | |
| 1910 | for (player = 0; player < MAX_PLAYERS; player++) | |
| 1911 | for (joyindex = 0; joyindex < DIGITAL_JOYSTICKS_PER_PLAYER; joyindex++) | |
| 1739 | 1912 | { |
| 1740 | /* add a new port node */ | |
| 1741 | xml_data_node *portnode = xml_add_child(parentnode, "port", NULL); | |
| 1742 | if (portnode) | |
| 1913 | digital_joystick_state *joystick = &portdata->joystick_info[player][joyindex]; | |
| 1914 | if (joystick->inuse) | |
| 1743 | 1915 | { |
| 1744 | /* add the port information and attributes */ | |
| 1745 | xml_set_attribute(portnode, "type", port_type_to_token(defport->type, defport->player)); | |
| 1916 | joystick->previous = joystick->current; | |
| 1917 | joystick->current = 0; | |
| 1746 | 1918 | |
| 1747 | /* add only the sequences that have changed from the defaults */ | |
| 1748 | if (input_seq_cmp(&defport->defaultseq, &curport->defaultseq) != 0) | |
| 1749 | add_sequence(portnode, 0, defport->type, &curport->defaultseq); | |
| 1750 | if (input_seq_cmp(&defport->defaultdecseq, &curport->defaultdecseq) != 0) | |
| 1751 | add_sequence(portnode, 1, defport->type, &curport->defaultdecseq); | |
| 1752 | if (input_seq_cmp(&defport->defaultincseq, &curport->defaultincseq) != 0) | |
| 1753 | add_sequence(portnode, 2, defport->type, &curport->defaultincseq); | |
| 1919 | /* read all the associated ports */ | |
| 1920 | if (joystick->field[JOYDIR_UP] != NULL && input_seq_pressed(input_field_seq(joystick->field[JOYDIR_UP], SEQ_TYPE_STANDARD))) | |
| 1921 | joystick->current |= JOYDIR_UP_BIT; | |
| 1922 | if (joystick->field[JOYDIR_DOWN] != NULL && input_seq_pressed(input_field_seq(joystick->field[JOYDIR_DOWN], SEQ_TYPE_STANDARD))) | |
| 1923 | joystick->current |= JOYDIR_DOWN_BIT; | |
| 1924 | if (joystick->field[JOYDIR_LEFT] != NULL && input_seq_pressed(input_field_seq(joystick->field[JOYDIR_LEFT], SEQ_TYPE_STANDARD))) | |
| 1925 | joystick->current |= JOYDIR_LEFT_BIT; | |
| 1926 | if (joystick->field[JOYDIR_RIGHT] != NULL && input_seq_pressed(input_field_seq(joystick->field[JOYDIR_RIGHT], SEQ_TYPE_STANDARD))) | |
| 1927 | joystick->current |= JOYDIR_RIGHT_BIT; | |
| 1928 | ||
| 1929 | /* lock out opposing directions (left + right or up + down) */ | |
| 1930 | if ((joystick->current & (JOYDIR_UP_BIT | JOYDIR_DOWN_BIT)) == (JOYDIR_UP_BIT | JOYDIR_DOWN_BIT)) | |
| 1931 | joystick->current &= ~(JOYDIR_UP_BIT | JOYDIR_DOWN_BIT); | |
| 1932 | if ((joystick->current & (JOYDIR_LEFT_BIT | JOYDIR_RIGHT_BIT)) == (JOYDIR_LEFT_BIT | JOYDIR_RIGHT_BIT)) | |
| 1933 | joystick->current &= ~(JOYDIR_LEFT_BIT | JOYDIR_RIGHT_BIT); | |
| 1934 | ||
| 1935 | /* only update 4-way case if joystick has moved */ | |
| 1936 | if (joystick->current != joystick->previous) | |
| 1937 | { | |
| 1938 | joystick->current4way = joystick->current; | |
| 1939 | ||
| 1940 | /* | |
| 1941 | If joystick is pointing at a diagonal, acknowledge that the player moved | |
| 1942 | the joystick by favoring a direction change. This minimizes frustration | |
| 1943 | when using a keyboard for input, and maximizes responsiveness. | |
| 1944 | ||
| 1945 | For example, if you are holding "left" then switch to "up" (where both left | |
| 1946 | and up are briefly pressed at the same time), we'll transition immediately | |
| 1947 | to "up." | |
| 1948 | ||
| 1949 | Zero any switches that didn't change from the previous to current state. | |
| 1950 | */ | |
| 1951 | if ((joystick->current4way & (JOYDIR_UP_BIT | JOYDIR_DOWN_BIT)) && | |
| 1952 | (joystick->current4way & (JOYDIR_LEFT_BIT | JOYDIR_RIGHT_BIT))) | |
| 1953 | { | |
| 1954 | joystick->current4way ^= joystick->current4way & joystick->previous; | |
| 1955 | } | |
| 1956 | ||
| 1957 | /* | |
| 1958 | If we are still pointing at a diagonal, we are in an indeterminant state. | |
| 1959 | ||
| 1960 | This could happen if the player moved the joystick from the idle position directly | |
| 1961 | to a diagonal, or from one diagonal directly to an extreme diagonal. | |
| 1962 | ||
| 1963 | The chances of this happening with a keyboard are slim, but we still need to | |
| 1964 | constrain this case. | |
| 1965 | ||
| 1966 | For now, just resolve randomly. | |
| 1967 | */ | |
| 1968 | if ((joystick->current4way & (JOYDIR_UP_BIT | JOYDIR_DOWN_BIT)) && | |
| 1969 | (joystick->current4way & (JOYDIR_LEFT_BIT | JOYDIR_RIGHT_BIT))) | |
| 1970 | { | |
| 1971 | if (mame_rand(machine) & 1) | |
| 1972 | joystick->current4way &= ~(JOYDIR_LEFT_BIT | JOYDIR_RIGHT_BIT); | |
| 1973 | else | |
| 1974 | joystick->current4way &= ~(JOYDIR_UP_BIT | JOYDIR_DOWN_BIT); | |
| 1975 | } | |
| 1976 | } | |
| 1754 | 1977 | } |
| 1755 | 1978 | } |
| 1756 | } | |
| 1757 | 1979 | } |
| 1758 | 1980 | |
| 1759 | 1981 | |
| 1760 | static void save_game_inputs(xml_data_node *parentnode) | |
| 1982 | /*------------------------------------------------- | |
| 1983 | frame_update_analog_field - update the | |
| 1984 | internals of a single analog field | |
| 1985 | -------------------------------------------------*/ | |
| 1986 | ||
| 1987 | static void frame_update_analog_field(analog_field_state *analog) | |
| 1761 | 1988 | { |
| 1762 | int portnum; | |
| 1989 | input_item_class itemclass; | |
| 1990 | int keypressed = FALSE; | |
| 1991 | INT64 keyscale; | |
| 1992 | INT32 rawvalue; | |
| 1993 | INT32 delta = 0; | |
| 1763 | 1994 | |
| 1764 | /* iterate over ports */ | |
| 1765 | for (portnum = 0; input_ports_default[portnum].type != IPT_END; portnum++) | |
| 1995 | /* clamp the previous value to the min/max range and remember it */ | |
| 1996 | analog->previous = analog->accum = apply_analog_min_max(analog, analog->accum); | |
| 1997 | ||
| 1998 | /* get the new raw analog value and its type */ | |
| 1999 | rawvalue = input_seq_axis_value(input_field_seq(analog->field, SEQ_TYPE_STANDARD), &itemclass); | |
| 2000 | ||
| 2001 | /* if we got an absolute input, it overrides everything else */ | |
| 2002 | if (itemclass == ITEM_CLASS_ABSOLUTE) | |
| 1766 | 2003 | { |
| 1767 | input_port_entry *defport = &input_ports_default[portnum]; | |
| 1768 | input_port_entry *curport = &Machine->input_ports[portnum]; | |
| 2004 | if (analog->previousanalog != rawvalue) | |
| 2005 | { | |
| 2006 | /* only update if analog value changed */ | |
| 2007 | analog->previousanalog = rawvalue; | |
| 1769 | 2008 | |
| 1770 | /* only save if something has changed and this port is a type we save */ | |
| 1771 | if (save_this_port_type(defport->type) && | |
| 1772 | ((!port_type_is_analog(defport->type) && (defport->default_value & defport->mask) != (curport->default_value & defport->mask)) || | |
| 1773 | defport->analog.delta != curport->analog.delta || | |
| 1774 | defport->analog.centerdelta != curport->analog.centerdelta || | |
| 1775 | defport->analog.sensitivity != curport->analog.sensitivity || | |
| 1776 | defport->analog.reverse != curport->analog.reverse || | |
| 1777 | input_seq_cmp(&defport->seq, &curport->seq) != 0 || | |
| 1778 | input_seq_cmp(&defport->analog.decseq, &curport->analog.decseq) != 0 || | |
| 1779 | input_seq_cmp(&defport->analog.incseq, &curport->analog.incseq) != 0)) | |
| 1780 | { | |
| 1781 | /* add a new port node */ | |
| 1782 | xml_data_node *portnode = xml_add_child(parentnode, "port", NULL); | |
| 1783 | if (portnode) | |
| 2009 | /* apply the inverse of the sensitivity to the raw value so that */ | |
| 2010 | /* it will still cover the full min->max range requested after */ | |
| 2011 | /* we apply the sensitivity adjustment */ | |
| 2012 | if (analog->absolute || (analog->field->flags & ANALOG_FLAG_RESET)) | |
| 1784 | 2013 | { |
| 1785 | /* add the port information and attributes */ | |
| 1786 | xml_set_attribute(portnode, "type", port_type_to_token(defport->type, defport->player)); | |
| 1787 | xml_set_attribute_int(portnode, "mask", defport->mask); | |
| 1788 | xml_set_attribute_int(portnode, "index", portnum); | |
| 1789 | xml_set_attribute_int(portnode, "defvalue", defport->default_value & defport->mask); | |
| 2014 | /* if port is absolute, then just return the absolute data supplied */ | |
| 2015 | analog->accum = APPLY_INVERSE_SENSITIVITY(rawvalue, analog->sensitivity); | |
| 2016 | } | |
| 2017 | else if (analog->positionalscale != 0) | |
| 2018 | { | |
| 2019 | /* if port is positional, we will take the full analog control and divide it */ | |
| 2020 | /* into positions, that way as the control is moved full scale, */ | |
| 2021 | /* it moves through all the positions */ | |
| 2022 | rawvalue = APPLY_SCALE(rawvalue - INPUT_ABSOLUTE_MIN, analog->positionalscale) * 512 + analog->minimum; | |
| 1790 | 2023 | |
| 1791 | /* if the value has changed, add it as well */ | |
| 1792 | if (!port_type_is_analog(defport->type) && defport->default_value != curport->default_value) | |
| 1793 | xml_set_attribute_int(portnode, "value", curport->default_value & defport->mask); | |
| 2024 | /* clamp the high value so it does not roll over */ | |
| 2025 | rawvalue = MIN(rawvalue, analog->maximum); | |
| 2026 | analog->accum = APPLY_INVERSE_SENSITIVITY(rawvalue, analog->sensitivity); | |
| 2027 | } | |
| 2028 | else | |
| 2029 | /* if port is relative, we use the value to simulate the speed of relative movement */ | |
| 2030 | /* sensitivity adjustment is allowed for this mode */ | |
| 2031 | analog->accum += rawvalue; | |
| 1794 | 2032 | |
| 1795 | /* add analog-specific attributes if they have changed */ | |
| 1796 | if (port_type_is_analog(defport->type)) | |
| 2033 | analog->lastdigital = 0; | |
| 2034 | /* do not bother with other control types if the analog data is changing */ | |
| 2035 | return; | |
| 2036 | } | |
| 2037 | else | |
| 2038 | { | |
| 2039 | /* we still have to update fake relative from joystick control */ | |
| 2040 | if (!analog->absolute && analog->positionalscale == 0) | |
| 2041 | analog->accum += rawvalue; | |
| 2042 | } | |
| 2043 | } | |
| 2044 | ||
| 2045 | /* if we got it from a relative device, use that as the starting delta */ | |
| 2046 | /* also note that the last input was not a digital one */ | |
| 2047 | if (itemclass == ITEM_CLASS_RELATIVE && rawvalue != 0) | |
| 2048 | { | |
| 2049 | delta = rawvalue; | |
| 2050 | analog->lastdigital = 0; | |
| 2051 | } | |
| 2052 | ||
| 2053 | keyscale = (analog->accum >= 0) ? analog->keyscalepos : analog->keyscaleneg; | |
| 2054 | ||
| 2055 | /* if the decrement code sequence is pressed, add the key delta to */ | |
| 2056 | /* the accumulated delta; also note that the last input was a digital one */ | |
| 2057 | if (input_seq_pressed(input_field_seq(analog->field, SEQ_TYPE_DECREMENT))) | |
| 2058 | { | |
| 2059 | keypressed = TRUE; | |
| 2060 | if (analog->field->delta != 0) | |
| 2061 | delta -= APPLY_SCALE(analog->field->delta, keyscale); | |
| 2062 | else if (analog->lastdigital != 1) | |
| 2063 | /* decrement only once when first pressed */ | |
| 2064 | delta -= APPLY_SCALE(1, keyscale); | |
| 2065 | analog->lastdigital = 1; | |
| 2066 | } | |
| 2067 | ||
| 2068 | /* same for the increment code sequence */ | |
| 2069 | if (input_seq_pressed(input_field_seq(analog->field, SEQ_TYPE_INCREMENT))) | |
| 2070 | { | |
| 2071 | keypressed = TRUE; | |
| 2072 | if (analog->field->delta) | |
| 2073 | delta += APPLY_SCALE(analog->field->delta, keyscale); | |
| 2074 | else if (analog->lastdigital != 2) | |
| 2075 | /* increment only once when first pressed */ | |
| 2076 | delta += APPLY_SCALE(1, keyscale); | |
| 2077 | analog->lastdigital = 2; | |
| 2078 | } | |
| 2079 | ||
| 2080 | /* if resetting is requested, clear the accumulated position to 0 before */ | |
| 2081 | /* applying the deltas so that we only return this frame's delta */ | |
| 2082 | /* note that centering only works for relative controls */ | |
| 2083 | /* no need to check if absolute here because it is checked by the validity tests */ | |
| 2084 | if (analog->field->flags & ANALOG_FLAG_RESET) | |
| 2085 | analog->accum = 0; | |
| 2086 | ||
| 2087 | /* apply the delta to the accumulated value */ | |
| 2088 | analog->accum += delta; | |
| 2089 | ||
| 2090 | /* if our last movement was due to a digital input, and if this control */ | |
| 2091 | /* type autocenters, and if neither the increment nor the decrement seq */ | |
| 2092 | /* was pressed, apply autocentering */ | |
| 2093 | if (analog->autocenter) | |
| 2094 | { | |
| 2095 | INT32 center = APPLY_INVERSE_SENSITIVITY(analog->center, analog->sensitivity); | |
| 2096 | if (analog->lastdigital != 0 && !keypressed) | |
| 2097 | { | |
| 2098 | /* autocenter from positive values */ | |
| 2099 | if (analog->accum >= center) | |
| 2100 | { | |
| 2101 | analog->accum -= APPLY_SCALE(analog->field->centerdelta, analog->keyscalepos); | |
| 2102 | if (analog->accum < center) | |
| 1797 | 2103 | { |
| 1798 | if (defport->analog.delta != curport->analog.delta) | |
| 1799 | xml_set_attribute_int(portnode, "keydelta", curport->analog.delta); | |
| 1800 | if (defport->analog.centerdelta != curport->analog.centerdelta) | |
| 1801 | xml_set_attribute_int(portnode, "centerdelta", curport->analog.centerdelta); | |
| 1802 | if (defport->analog.sensitivity != curport->analog.sensitivity) | |
| 1803 | xml_set_attribute_int(portnode, "sensitivity", curport->analog.sensitivity); | |
| 1804 | if (defport->analog.reverse != curport->analog.reverse) | |
| 1805 | xml_set_attribute(portnode, "reverse", curport->analog.reverse ? "yes" : "no"); | |
| 2104 | analog->accum = center; | |
| 2105 | analog->lastdigital = 0; | |
| 1806 | 2106 | } |
| 2107 | } | |
| 1807 | 2108 | |
| 1808 | /* add only the sequences that have changed from the defaults */ | |
| 1809 | if (input_seq_cmp(&defport->seq, &curport->seq) != 0) | |
| 1810 | add_sequence(portnode, 0, defport->type, &curport->seq); | |
| 1811 | if (input_seq_cmp(&defport->analog.decseq, &curport->analog.decseq) != 0) | |
| 1812 | add_sequence(portnode, 1, defport->type, &curport->analog.decseq); | |
| 1813 | if (input_seq_cmp(&defport->analog.incseq, &curport->analog.incseq) != 0) | |
| 1814 | add_sequence(portnode, 2, defport->type, &curport->analog.incseq); | |
| 2109 | /* autocenter from negative values */ | |
| 2110 | else | |
| 2111 | { | |
| 2112 | analog->accum += APPLY_SCALE(analog->field->centerdelta, analog->keyscaleneg); | |
| 2113 | if (analog->accum > center) | |
| 2114 | { | |
| 2115 | analog->accum = center; | |
| 2116 | analog->lastdigital = 0; | |
| 2117 | } | |
| 1815 | 2118 | } |
| 1816 | 2119 | } |
| 1817 | 2120 | } |
| 2121 | else if (!keypressed) | |
| 2122 | analog->lastdigital = 0; | |
| 1818 | 2123 | } |
| 1819 | 2124 | |
| 1820 | 2125 | |
| 1821 | static void input_port_save(int config_type, xml_data_node *parentnode) | |
| 2126 | /*------------------------------------------------- | |
| 2127 | frame_get_digital_field_state - get the state | |
| 2128 | of a digital field | |
| 2129 | -------------------------------------------------*/ | |
| 2130 | ||
| 2131 | static int frame_get_digital_field_state(const input_field_config *field) | |
| 1822 | 2132 | { |
| 1823 | if (parentnode) | |
| 2133 | int curstate = input_seq_pressed(input_field_seq(field, SEQ_TYPE_STANDARD)); | |
| 2134 | int changed = FALSE; | |
| 2135 | ||
| 2136 | /* if the state changed, look for switch down/switch up */ | |
| 2137 | if (curstate != field->state->last) | |
| 1824 | 2138 | { |
| 1825 | /* default ports save differently */ | |
| 1826 | if (config_type == CONFIG_TYPE_DEFAULT) | |
| 1827 | save_default_inputs(parentnode); | |
| 1828 | else | |
| 1829 | save_game_inputs(parentnode); | |
| 2139 | field->state->last = curstate; | |
| 2140 | changed = TRUE; | |
| 1830 | 2141 | } |
| 1831 | } | |
| 1832 | 2142 | |
| 2143 | #ifdef MESS | |
| 2144 | /* (MESS-specific) check for disabled keyboard */ | |
| 2145 | if (field->type == IPT_KEYBOARD && osd_keyboard_disabled()) | |
| 2146 | return FALSE; | |
| 2147 | #endif /* MESS */ | |
| 1833 | 2148 | |
| 2149 | /* skip locked-out coin inputs */ | |
| 2150 | if (field->type >= IPT_COIN1 && field->type <= IPT_COIN8 && coinlockedout[field->type - IPT_COIN1]) | |
| 2151 | { | |
| 2152 | ui_popup_time(3, "Coinlock disabled %s.", input_field_name(field)); | |
| 2153 | return FALSE; | |
| 2154 | } | |
| 1834 | 2155 | |
| 1835 | /************************************* | |
| 1836 | * | |
| 1837 | * Token to default string | |
| 1838 | * | |
| 1839 | *************************************/ | |
| 2156 | /* skip locked-out service inputs */ | |
| 2157 | if (field->type >= IPT_SERVICE1 && field->type <= IPT_SERVICE4 && servicecoinlockedout[field->type - IPT_SERVICE1]) | |
| 2158 | { | |
| 2159 | ui_popup_time(3, "Coinlock disabled %s.", input_field_name(field)); | |
| 2160 | return FALSE; | |
| 2161 | } | |
| 1840 | 2162 | |
| 1841 | const char *input_port_string_from_token(const input_port_token token) | |
| 1842 | { | |
| 1843 | int index; | |
| 2163 | /* if this is a switch-down event, handle impulse and toggle */ | |
| 2164 | if (changed && curstate) | |
| 2165 | { | |
| 2166 | /* impluse controls: reset the impulse counter */ | |
| 2167 | if (field->impulse != 0 && field->state->impulse == 0) | |
| 2168 | field->state->impulse = field->impulse; | |
| 1844 | 2169 | |
| 1845 | if (token.i == 0) | |
| 1846 | return NULL; | |
| 1847 | if (token.i >= INPUT_STRING_COUNT) | |
| 1848 | return token.stringptr; | |
| 1849 | for (index = 0; index < ARRAY_LENGTH(input_port_default_strings); index++) | |
| 1850 | if (input_port_default_strings[index].id == token.i) | |
| 1851 | return input_port_default_strings[index].string; | |
| 1852 | return "(Unknown Default)"; | |
| 2170 | /* toggle controls: flip the toggle state */ | |
| 2171 | if (field->flags & FIELD_FLAG_TOGGLE) | |
| 2172 | field->state->toggle = !field->state->toggle; | |
| 2173 | } | |
| 2174 | ||
| 2175 | /* update the current state with the impulse state */ | |
| 2176 | if (field->impulse != 0 && field->state->impulse != 0) | |
| 2177 | { | |
| 2178 | field->state->impulse--; | |
| 2179 | curstate = TRUE; | |
| 2180 | } | |
| 2181 | ||
| 2182 | /* update the current state with the toggle state */ | |
| 2183 | if (field->flags & FIELD_FLAG_TOGGLE) | |
| 2184 | curstate = field->state->toggle; | |
| 2185 | ||
| 2186 | /* additional logic to restrict digital joysticks */ | |
| 2187 | if (curstate && field->state->joystick != NULL && field->way != 16) | |
| 2188 | { | |
| 2189 | UINT8 mask = (field->way == 4) ? field->state->joystick->current4way : field->state->joystick->current; | |
| 2190 | if (!(mask & (1 << field->state->joydir))) | |
| 2191 | curstate = FALSE; | |
| 2192 | } | |
| 2193 | ||
| 2194 | return curstate; | |
| 1853 | 2195 | } |
| 1854 | 2196 | |
| 1855 | 2197 | |
| 1856 | 2198 | |
| 1857 | /************************************* | |
| 1858 | * | |
| 1859 | * Input port detokenizer | |
| 1860 | * | |
| 1861 | *************************************/ | |
| 2199 | /*************************************************************************** | |
| 2200 | PORT CONFIGURATION HELPERS | |
| 2201 | ***************************************************************************/ | |
| 1862 | 2202 | |
| 1863 | static void input_port_detokenize(input_port_init_params *param, const input_port_token *ipt) | |
| 2203 | /*------------------------------------------------- | |
| 2204 | port_config_detokenize - recursively | |
| 2205 | detokenize a series of input port tokens | |
| 2206 | -------------------------------------------------*/ | |
| 2207 | ||
| 2208 | static input_port_config *port_config_detokenize(input_port_config *listhead, const input_port_token *ipt) | |
| 1864 | 2209 | { |
| 1865 | 2210 | UINT32 entrytype = INPUT_TOKEN_INVALID; |
| 1866 | input_port_entry *portentry = NULL; | |
| 1867 | const char *modify_tag = NULL; | |
| 1868 | int seq_index[3] = {0}; | |
| 2211 | input_setting_config *cursetting = NULL; | |
| 2212 | input_field_config *curfield = NULL; | |
| 2213 | input_port_config *curport = NULL; | |
| 1869 | 2214 | |
| 1870 | 2215 | /* loop over tokens until we hit the end */ |
| 1871 | 2216 | while (entrytype != INPUT_TOKEN_END) |
| 1872 | 2217 | { |
| 1873 | 2218 | UINT32 mask, defval, type, val; |
| 1874 | 2219 | input_port_token temptoken; |
| 1875 | int hasdiploc, strindex; | |
| 1876 | #ifdef MESS | |
| 1877 | UINT16 category; | |
| 1878 | #endif /* MESS */ | |
| 2220 | input_condition condition; | |
| 2221 | int hasdiploc; | |
| 2222 | int index; | |
| 1879 | 2223 | |
| 1880 | 2224 | /* unpack the token from the first entry */ |
| 1881 | 2225 | TOKEN_GET_UINT32_UNPACK1(ipt, entrytype, 8); |
| r2724 | r2725 | |
| 1887 | 2231 | |
| 1888 | 2232 | /* including */ |
| 1889 | 2233 | case INPUT_TOKEN_INCLUDE: |
| 1890 | i | |
| 2234 | lis | |
| 1891 | 2235 | break; |
| 1892 | 2236 | |
| 1893 | 2237 | /* start of a new input port */ |
| 1894 | 2238 | case INPUT_TOKEN_START: |
| 1895 | 2239 | case INPUT_TOKEN_START_TAG: |
| 1896 | modify_tag = NULL; | |
| 1897 | portentry = input_port_initialize(param, IPT_PORT, NULL, 0, 0); | |
| 2240 | curport = port_config_alloc((const input_port_config **)&listhead); | |
| 1898 | 2241 | if (entrytype == INPUT_TOKEN_START_TAG) |
| 1899 | portentry->start.tag = TOKEN_GET_STRING(ipt); | |
| 2242 | curport->tag = TOKEN_GET_STRING(ipt); | |
| 2243 | curfield = NULL; | |
| 2244 | cursetting = NULL; | |
| 1900 | 2245 | break; |
| 1901 | 2246 | |
| 1902 | 2247 | /* modify an existing port */ |
| 1903 | 2248 | case INPUT_TOKEN_MODIFY: |
| 1904 | | |
| 2249 | curport = port_config_find(listhead, | |
| 1905 | 2250 | break; |
| 1906 | 2251 | |
| 1907 | /* input bit definition */ | |
| 1908 | case INPUT_TOKEN_BIT: | |
| 2252 | /* input field definition */ | |
| 2253 | case INPUT_TOKEN_FIELD: | |
| 2254 | if (curport == NULL) | |
| 2255 | fatalerror("INPUT_TOKEN_FIELD encountered with no active port"); | |
| 2256 | ||
| 1909 | 2257 | TOKEN_UNGET_UINT32(ipt); |
| 1910 | 2258 | TOKEN_GET_UINT32_UNPACK2(ipt, entrytype, 8, type, 24); |
| 1911 | 2259 | TOKEN_GET_UINT64_UNPACK2(ipt, mask, 32, defval, 32); |
| 1912 | portentry = input_port_initialize(param, type, modify_tag, mask, defval); | |
| 1913 | seq_index[0] = seq_index[1] = seq_index[2] = 0; | |
| 2260 | ||
| 2261 | curfield = field_config_alloc(curport, type, defval, mask); | |
| 2262 | cursetting = NULL; | |
| 1914 | 2263 | break; |
| 1915 | 2264 | |
| 1916 | case INPUT_TOKEN_SPECIAL_ONOFF: | |
| 2265 | /* field or setting condition */ | |
| 2266 | case INPUT_TOKEN_CONDITION: | |
| 2267 | if (curfield == NULL && cursetting == NULL) | |
| 2268 | fatalerror("INPUT_TOKEN_CONDITION encountered with no active field or setting"); | |
| 2269 | ||
| 1917 | 2270 | TOKEN_UNGET_UINT32(ipt); |
| 1918 | TOKEN_GET_UINT32_UNPACK3(ipt, entrytype, 8, hasdiploc, 1, strindex, 23); | |
| 1919 | TOKEN_GET_UINT64_UNPACK2(ipt, mask, 32, defval, 32); | |
| 2271 | TOKEN_GET_UINT32_UNPACK2(ipt, entrytype, 8, condition.condition, 24); | |
| 2272 | TOKEN_GET_UINT64_UNPACK2(ipt, condition.mask, 32, condition.value, 32); | |
| 2273 | condition.tag = TOKEN_GET_STRING(ipt); | |
| 1920 | 2274 | |
| 1921 | portentry = input_port_initialize(param, IPT_DIPSWITCH_NAME, modify_tag, mask, mask & defval); | |
| 1922 | temptoken.i = strindex; | |
| 1923 | portentry->name = input_port_string_from_token(temptoken); | |
| 1924 | if (strindex == INPUT_STRING_Service_Mode) | |
| 1925 | { | |
| 1926 | portentry->toggle = TRUE; | |
| 1927 | portentry->seq.code[0] = KEYCODE_F2; | |
| 1928 | } | |
| 1929 | if (hasdiploc) | |
| 1930 | input_port_parse_diplocation(portentry, TOKEN_GET_STRING(ipt)); | |
| 2275 | if (cursetting != NULL) | |
| 2276 | cursetting->condition = condition; | |
| 2277 | else | |
| 2278 | curfield->condition = condition; | |
| 2279 | break; | |
| 1931 | 2280 | |
| 1932 | portentry = input_port_initialize(param, IPT_DIPSWITCH_SETTING, modify_tag, 0, mask & defval); | |
| 1933 | temptoken.i = INPUT_STRING_Off; | |
| 1934 | portentry->name = input_port_string_from_token(temptoken); | |
| 1935 | ||
| 1936 | portentry = input_port_initialize(param, IPT_DIPSWITCH_SETTING, modify_tag, 0, mask & ~defval); | |
| 1937 | temptoken.i = INPUT_STRING_On; | |
| 1938 | portentry->name = input_port_string_from_token(temptoken); | |
| 2281 | /* field player select */ | |
| 2282 | case INPUT_TOKEN_PLAYER1: | |
| 2283 | case INPUT_TOKEN_PLAYER2: | |
| 2284 | case INPUT_TOKEN_PLAYER3: | |
| 2285 | case INPUT_TOKEN_PLAYER4: | |
| 2286 | case INPUT_TOKEN_PLAYER5: | |
| 2287 | case INPUT_TOKEN_PLAYER6: | |
| 2288 | case INPUT_TOKEN_PLAYER7: | |
| 2289 | case INPUT_TOKEN_PLAYER8: | |
| 2290 | if (curfield == NULL) | |
| 2291 | fatalerror("INPUT_TOKEN_PLAYERn encountered with no active field"); | |
| 2292 | curfield->player = entrytype - INPUT_TOKEN_PLAYER1; | |
| 1939 | 2293 | break; |
| 1940 | 2294 | |
| 1941 | /* append a code */ | |
| 1942 | case INPUT_TOKEN_CODE: | |
| 2295 | /* field category */ | |
| 2296 | case INPUT_TOKEN_CATEGORY: | |
| 2297 | if (curfield == NULL) | |
| 2298 | fatalerror("INPUT_TOKEN_CATEGORY encountered with no active field"); | |
| 1943 | 2299 | TOKEN_UNGET_UINT32(ipt); |
| 1944 | TOKEN_GET_UINT64_UNPACK2(ipt, entrytype, 8, val, 32); | |
| 1945 | if (seq_index[0] > 0) | |
| 1946 | portentry->seq.code[seq_index[0]++] = SEQCODE_OR; | |
| 1947 | portentry->seq.code[seq_index[0]++] = val; | |
| 2300 | TOKEN_GET_UINT32_UNPACK2(ipt, entrytype, 8, curfield->category, 24); | |
| 1948 | 2301 | break; |
| 1949 | 2302 | |
| 1950 | case INPUT_TOKEN_CODE_DEC: | |
| 2303 | /* field flags */ | |
| 2304 | case INPUT_TOKEN_UNUSED: | |
| 2305 | if (curfield == NULL) | |
| 2306 | fatalerror("INPUT_TOKEN_UNUSED encountered with no active field"); | |
| 2307 | curfield->flags |= FIELD_FLAG_UNUSED; | |
| 2308 | break; | |
| 2309 | ||
| 2310 | case INPUT_TOKEN_COCKTAIL: | |
| 2311 | if (curfield == NULL) | |
| 2312 | fatalerror("INPUT_TOKEN_COCKTAIL encountered with no active field"); | |
| 2313 | curfield->flags |= FIELD_FLAG_COCKTAIL; | |
| 2314 | curfield->player = 1; | |
| 2315 | break; | |
| 2316 | ||
| 2317 | case INPUT_TOKEN_ROTATED: | |
| 2318 | if (curfield == NULL) | |
| 2319 | fatalerror("INPUT_TOKEN_ROTATED encountered with no active field"); | |
| 2320 | curfield->flags |= FIELD_FLAG_ROTATED; | |
| 2321 | break; | |
| 2322 | ||
| 2323 | case INPUT_TOKEN_TOGGLE: | |
| 2324 | if (curfield == NULL) | |
| 2325 | fatalerror("INPUT_TOKEN_TOGGLE encountered with no active field"); | |
| 2326 | curfield->flags |= FIELD_FLAG_TOGGLE; | |
| 2327 | break; | |
| 2328 | ||
| 2329 | /* field impulse */ | |
| 2330 | case INPUT_TOKEN_IMPULSE: | |
| 2331 | if (curfield == NULL) | |
| 2332 | fatalerror("INPUT_TOKEN_IMPULSE encountered with no active field"); | |
| 1951 | 2333 | TOKEN_UNGET_UINT32(ipt); |
| 1952 | TOKEN_GET_UINT64_UNPACK2(ipt, entrytype, 8, val, 32); | |
| 1953 | if (seq_index[1] > 0) | |
| 1954 | portentry->analog.decseq.code[seq_index[1]++] = SEQCODE_OR; | |
| 1955 | portentry->analog.decseq.code[seq_index[1]++] = val; | |
| 2334 | TOKEN_GET_UINT32_UNPACK2(ipt, entrytype, 8, curfield->impulse, 24); | |
| 1956 | 2335 | break; |
| 1957 | 2336 | |
| 1958 | case INPUT_TOKEN_CODE_INC: | |
| 2337 | /* field name */ | |
| 2338 | case INPUT_TOKEN_NAME: | |
| 2339 | if (curfield == NULL) | |
| 2340 | fatalerror("INPUT_TOKEN_NAME encountered with no active field"); | |
| 2341 | curfield->name = input_port_string_from_token(*ipt++); | |
| 2342 | break; | |
| 2343 | ||
| 2344 | /* field code sequence */ | |
| 2345 | case INPUT_TOKEN_CODE: | |
| 2346 | if (curfield == NULL) | |
| 2347 | fatalerror("INPUT_TOKEN_CODE encountered with no active field"); | |
| 2348 | ||
| 1959 | 2349 | TOKEN_UNGET_UINT32(ipt); |
| 1960 | 2350 | TOKEN_GET_UINT64_UNPACK2(ipt, entrytype, 8, val, 32); |
| 1961 | if (seq_index[2] > 0) | |
| 1962 | portentry->analog.incseq.code[seq_index[2]++] = SEQCODE_OR; | |
| 1963 | portentry->analog.incseq.code[seq_index[2]++] = val; | |
| 2351 | ||
| 2352 | input_seq_append_or(&curfield->seq[SEQ_TYPE_STANDARD], val); | |
| 1964 | 2353 | break; |
| 1965 | 2354 | |
| 2355 | /* field custom callback */ | |
| 2356 | case INPUT_TOKEN_CUSTOM: | |
| 2357 | if (curfield == NULL) | |
| 2358 | fatalerror("INPUT_TOKEN_CUSTOM encountered with no active field"); | |
| 2359 | curfield->custom = TOKEN_GET_PTR(ipt, customptr); | |
| 2360 | curfield->custom_param = (void *)TOKEN_GET_PTR(ipt, voidptr); | |
| 2361 | break; | |
| 2362 | ||
| 2363 | /* field changed callback */ | |
| 2364 | case INPUT_TOKEN_CHANGED: | |
| 2365 | if (curfield == NULL) | |
| 2366 | fatalerror("INPUT_TOKEN_CHANGED encountered with no active field"); | |
| 2367 | curfield->changed = TOKEN_GET_PTR(ipt, changedptr); | |
| 2368 | curfield->changed_param = (void *)TOKEN_GET_PTR(ipt, voidptr); | |
| 2369 | break; | |
| 2370 | ||
| 2371 | /* DIP switch location */ | |
| 2372 | case INPUT_TOKEN_DIPLOCATION: | |
| 2373 | if (curfield == NULL) | |
| 2374 | fatalerror("INPUT_TOKEN_DIPLOCATION encountered with no active field"); | |
| 2375 | curfield->diploclist = diplocation_list_alloc(curfield, TOKEN_GET_STRING(ipt)); | |
| 2376 | break; | |
| 2377 | ||
| 1966 | 2378 | /* joystick flags */ |
| 1967 | 2379 | case INPUT_TOKEN_2WAY: |
| 1968 | 2380 | case INPUT_TOKEN_4WAY: |
| 1969 | 2381 | case INPUT_TOKEN_8WAY: |
| 1970 | 2382 | case INPUT_TOKEN_16WAY: |
| 1971 | portentry->way = 2 << (entrytype - INPUT_TOKEN_2WAY); | |
| 2383 | if (curfield == NULL) | |
| 2384 | fatalerror("INPUT_TOKEN_nWAY encountered with no active field"); | |
| 2385 | curfield->way = 2 << (entrytype - INPUT_TOKEN_2WAY); | |
| 1972 | 2386 | break; |
| 1973 | 2387 | |
| 1974 | case INPUT_TOKEN_ROTATED: | |
| 1975 | portentry->rotated = TRUE; | |
| 1976 | break; | |
| 2388 | /* (MESS) natural keyboard support */ | |
| 2389 | case INPUT_TOKEN_CHAR: | |
| 2390 | if (curfield == NULL) | |
| 2391 | fatalerror("INPUT_TOKEN_CHAR encountered with no active field"); | |
| 1977 | 2392 | |
| 1978 | /* general flags */ | |
| 1979 | case INPUT_TOKEN_NAME: | |
| 1980 | portentry->name = input_port_string_from_token(*ipt++); | |
| 2393 | TOKEN_UNGET_UINT32(ipt); | |
| 2394 | TOKEN_GET_UINT64_UNPACK2(ipt, entrytype, 8, val, 32); | |
| 2395 | ||
| 2396 | for (index = 0; index < ARRAY_LENGTH(curfield->chars); index++) | |
| 2397 | if (curfield->chars[index] == 0) | |
| 2398 | { | |
| 2399 | curfield->chars[index] = (unicode_char)val; | |
| 2400 | break; | |
| 2401 | } | |
| 1981 | 2402 | break; |
| 1982 | 2403 | |
| 1983 | case INPUT_TOKEN_PLAYER1: | |
| 1984 | case INPUT_TOKEN_PLAYER2: | |
| 1985 | case INPUT_TOKEN_PLAYER3: | |
| 1986 | case INPUT_TOKEN_PLAYER4: | |
| 1987 | case INPUT_TOKEN_PLAYER5: | |
| 1988 | case INPUT_TOKEN_PLAYER6: | |
| 1989 | case INPUT_TOKEN_PLAYER7: | |
| 1990 | case INPUT_TOKEN_PLAYER8: | |
| 1991 | portentry->player = entrytype - INPUT_TOKEN_PLAYER1; | |
| 2404 | /* analog minimum/maximum */ | |
| 2405 | case INPUT_TOKEN_MINMAX: | |
| 2406 | if (curfield == NULL) | |
| 2407 | fatalerror("INPUT_TOKEN_MINMAX encountered with no active field"); | |
| 2408 | TOKEN_GET_UINT64_UNPACK2(ipt, curfield->min, 32, curfield->max, 32); | |
| 1992 | 2409 | break; |
| 1993 | 2410 | |
| 1994 | case INPUT_TOKEN_COCKTAIL: | |
| 1995 | portentry->cocktail = TRUE; | |
| 1996 | portentry->player = 1; | |
| 2411 | /* analog sensitivity */ | |
| 2412 | case INPUT_TOKEN_SENSITIVITY: | |
| 2413 | if (curfield == NULL) | |
| 2414 | fatalerror("INPUT_TOKEN_SENSITIVITY encountered with no active field"); | |
| 2415 | TOKEN_UNGET_UINT32(ipt); | |
| 2416 | TOKEN_GET_UINT32_UNPACK2(ipt, entrytype, 8, curfield->sensitivity, 24); | |
| 1997 | 2417 | break; |
| 1998 | 2418 | |
| 1999 | case INPUT_TOKEN_TOGGLE: | |
| 2000 | portentry->toggle = TRUE; | |
| 2419 | /* analog keyboard delta */ | |
| 2420 | case INPUT_TOKEN_KEYDELTA: | |
| 2421 | if (curfield == NULL) | |
| 2422 | fatalerror("INPUT_TOKEN_KEYDELTA encountered with no active field"); | |
| 2423 | TOKEN_UNGET_UINT32(ipt); | |
| 2424 | TOKEN_GET_UINT32_UNPACK2(ipt, entrytype, 8, curfield->delta, -24); | |
| 2425 | curfield->centerdelta = curfield->delta; | |
| 2001 | 2426 | break; |
| 2002 | 2427 | |
| 2003 | case INPUT_TOKEN_IMPULSE: | |
| 2428 | /* analog autocenter delta */ | |
| 2429 | case INPUT_TOKEN_CENTERDELTA: | |
| 2430 | if (curfield == NULL) | |
| 2431 | fatalerror("INPUT_TOKEN_CENTERDELTA encountered with no active field"); | |
| 2004 | 2432 | TOKEN_UNGET_UINT32(ipt); |
| 2005 | TOKEN_GET_UINT32_UNPACK2(ipt, entrytype, 8, | |
| 2433 | TOKEN_GET_UINT32_UNPACK2(ipt, entrytype, 8, curfield->centerd | |
| 2006 | 2434 | break; |
| 2007 | 2435 | |
| 2436 | /* analog reverse flags */ | |
| 2008 | 2437 | case INPUT_TOKEN_REVERSE: |
| 2009 | portentry->analog.reverse = TRUE; | |
| 2438 | if (curfield == NULL) | |
| 2439 | fatalerror("INPUT_TOKEN_REVERSE encountered with no active field"); | |
| 2440 | curfield->flags |= ANALOG_FLAG_REVERSE; | |
| 2010 | 2441 | break; |
| 2011 | 2442 | |
| 2012 | 2443 | case INPUT_TOKEN_RESET: |
| 2013 | portentry->analog.reset = TRUE; | |
| 2444 | if (curfield == NULL) | |
| 2445 | fatalerror("INPUT_TOKEN_RESET encountered with no active field"); | |
| 2446 | curfield->flags |= ANALOG_FLAG_RESET; | |
| 2014 | 2447 | break; |
| 2015 | 2448 | |
| 2016 | case INPUT_TOKEN_UNUSED: | |
| 2017 | portentry->unused = TRUE; | |
| 2449 | case INPUT_TOKEN_WRAPS: | |
| 2450 | if (curfield == NULL) | |
| 2451 | fatalerror("INPUT_TOKEN_WRAPS encountered with no active field"); | |
| 2452 | curfield->flags |= ANALOG_FLAG_WRAPS; | |
| 2018 | 2453 | break; |
| 2019 | 2454 | |
| 2020 | /* analog settings */ | |
| 2021 | case INPUT_TOKEN_MINMAX: | |
| 2022 | TOKEN_GET_UINT64_UNPACK2(ipt, portentry->analog.min, 32, portentry->analog.max, 32); | |
| 2455 | case INPUT_TOKEN_INVERT: | |
| 2456 | if (curfield == NULL) | |
| 2457 | fatalerror("INPUT_TOKEN_INVERT encountered with no active field"); | |
| 2458 | curfield->flags |= ANALOG_FLAG_INVERT; | |
| 2023 | 2459 | break; |
| 2024 | 2460 | |
| 2025 | case INPUT_TOKEN_SENSITIVITY: | |
| 2461 | /* analog crosshair parameters */ | |
| 2462 | case INPUT_TOKEN_CROSSHAIR: | |
| 2463 | if (curfield == NULL) | |
| 2464 | fatalerror("INPUT_TOKEN_CROSSHAIR encountered with no active field"); | |
| 2465 | ||
| 2026 | 2466 | TOKEN_UNGET_UINT32(ipt); |
| 2027 | TOKEN_GET_UINT32_UNPACK2(ipt, entrytype, 8, portentry->analog.sensitivity, 24); | |
| 2467 | TOKEN_GET_UINT32_UNPACK3(ipt, entrytype, 8, curfield->crossaxis, 4, curfield->crossaltaxis, -20); | |
| 2468 | TOKEN_GET_UINT64_UNPACK2(ipt, curfield->crossscale, -32, curfield->crossoffset, -32); | |
| 2469 | ||
| 2470 | curfield->crossaltaxis *= 1.0f / 65536.0f; | |
| 2471 | curfield->crossscale *= 1.0f / 65536.0f; | |
| 2472 | curfield->crossoffset *= 1.0f / 65536.0f; | |
| 2028 | 2473 | break; |
| 2029 | 2474 | |
| 2030 | case INPUT_TOKEN_KEYDELTA: | |
| 2475 | /* analog decrement sequence */ | |
| 2476 | case INPUT_TOKEN_CODE_DEC: | |
| 2477 | if (curfield == NULL) | |
| 2478 | fatalerror("INPUT_TOKEN_CODE_DEC encountered with no active field"); | |
| 2479 | index = entrytype - INPUT_TOKEN_CODE; | |
| 2480 | ||
| 2031 | 2481 | TOKEN_UNGET_UINT32(ipt); |
| 2032 | TOKEN_GET_UINT32_UNPACK2(ipt, entrytype, 8, portentry->analog.delta, -24); | |
| 2033 | portentry->analog.centerdelta = portentry->analog.delta; | |
| 2482 | TOKEN_GET_UINT64_UNPACK2(ipt, entrytype, 8, val, 32); | |
| 2483 | ||
| 2484 | input_seq_append_or(&curfield->seq[SEQ_TYPE_DECREMENT], val); | |
| 2034 | 2485 | break; |
| 2035 | 2486 | |
| 2036 | case INPUT_TOKEN_CENTERDELTA: | |
| 2487 | /* analog increment sequence */ | |
| 2488 | case INPUT_TOKEN_CODE_INC: | |
| 2489 | if (curfield == NULL) | |
| 2490 | fatalerror("INPUT_TOKEN_CODE_INC encountered with no active field"); | |
| 2491 | index = entrytype - INPUT_TOKEN_CODE; | |
| 2492 | ||
| 2037 | 2493 | TOKEN_UNGET_UINT32(ipt); |
| 2038 | TOKEN_GET_UINT32_UNPACK2(ipt, entrytype, 8, portentry->analog.centerdelta, -24); | |
| 2039 | break; | |
| 2494 | TOKEN_GET_UINT64_UNPACK2(ipt, entrytype, 8, val, 32); | |
| 2040 | 2495 | |
| 2041 | case INPUT_TOKEN_CROSSHAIR: | |
| 2042 | TOKEN_UNGET_UINT32(ipt); | |
| 2043 | TOKEN_GET_UINT32_UNPACK3(ipt, entrytype, 8, portentry->analog.crossaxis, 4, portentry->analog.crossaltaxis, -20); | |
| 2044 | TOKEN_GET_UINT64_UNPACK2(ipt, portentry->analog.crossscale, -32, portentry->analog.crossoffset, -32); | |
| 2045 | portentry->analog.crossaltaxis *= 1.0f / 65536.0f; | |
| 2046 | portentry->analog.crossscale *= 1.0f / 65536.0f; | |
| 2047 | portentry->analog.crossoffset *= 1.0f / 65536.0f; | |
| 2496 | input_seq_append_or(&curfield->seq[SEQ_TYPE_INCREMENT], val); | |
| 2048 | 2497 | break; |
| 2049 | 2498 | |
| 2499 | /* analog wraps flag */ | |
| 2500 | ||
| 2050 | 2501 | case INPUT_TOKEN_FULL_TURN_COUNT: |
| 2502 | if (curfield == NULL) | |
| 2503 | fatalerror("INPUT_TOKEN_FULL_TURN_COUNT encountered with no active field"); | |
| 2051 | 2504 | TOKEN_UNGET_UINT32(ipt); |
| 2052 | TOKEN_GET_UINT32_UNPACK2(ipt, entrytype, 8, | |
| 2505 | TOKEN_GET_UINT32_UNPACK2(ipt, entrytype, 8, curfield | |
| 2053 | 2506 | break; |
| 2054 | 2507 | |
| 2055 | 2508 | case INPUT_TOKEN_POSITIONS: |
| 2509 | if (curfield == NULL) | |
| 2510 | fatalerror("INPUT_TOKEN_POSITIONS encountered with no active field"); | |
| 2056 | 2511 | TOKEN_UNGET_UINT32(ipt); |
| 2057 | TOKEN_GET_UINT32_UNPACK2(ipt, entrytype, 8, | |
| 2512 | TOKEN_GET_UINT32_UNPACK2(ipt, entrytype, 8, curfield | |
| 2058 | 2513 | break; |
| 2059 | 2514 | |
| 2060 | case INPUT_TOKEN_WRAPS: | |
| 2061 | portentry->analog.wraps = TRUE; | |
| 2062 | break; | |
| 2063 | ||
| 2064 | 2515 | case INPUT_TOKEN_REMAP_TABLE: |
| 2065 | portentry->analog.remap_table = TOKEN_GET_PTR(ipt, ui32ptr); | |
| 2516 | if (curfield == NULL) | |
| 2517 | fatalerror("INPUT_TOKEN_REMAP_TABLE encountered with no active field"); | |
| 2518 | curfield->remap_table = TOKEN_GET_PTR(ipt, ui32ptr); | |
| 2066 | 2519 | break; |
| 2067 | 2520 | |
| 2068 | case INPUT_TOKEN_INVERT: | |
| 2069 | portentry->analog.invert = TRUE; | |
| 2070 | break; | |
| 2521 | /* DIP switch definition */ | |
| 2522 | case INPUT_TOKEN_DIPNAME: | |
| 2523 | if (curport == NULL) | |
| 2524 | fatalerror("INPUT_TOKEN_DIPNAME encountered with no active port"); | |
| 2071 | 2525 | |
| 2072 | /* custom callbacks */ | |
| 2073 | case INPUT_TOKEN_CUSTOM: | |
| 2074 | portentry->custom = TOKEN_GET_PTR(ipt, customptr); | |
| 2075 | portentry->custom_param = (void *)TOKEN_GET_PTR(ipt, voidptr); | |
| 2076 | break; | |
| 2526 | TOKEN_GET_UINT64_UNPACK2(ipt, mask, 32, defval, 32); | |
| 2077 | 2527 | |
| 2078 | /* changed callbacks */ | |
| 2079 | case INPUT_TOKEN_CHANGED: | |
| 2080 | portentry->changed = TOKEN_GET_PTR(ipt, changedptr); | |
| 2081 | portentry->changed_param = (void *)TOKEN_GET_PTR(ipt, voidptr); | |
| 2082 | break; | |
| 2528 | curfield = field_config_alloc(curport, IPT_DIPSWITCH, defval, mask); | |
| 2529 | cursetting = NULL; | |
| 2083 | 2530 | |
| 2084 | /* dip switch definition */ | |
| 2085 | case INPUT_TOKEN_DIPNAME: | |
| 2086 | TOKEN_GET_UINT64_UNPACK2(ipt, mask, 32, defval, 32); | |
| 2087 | portentry = input_port_initialize(param, IPT_DIPSWITCH_NAME, modify_tag, mask, defval); | |
| 2088 | seq_index[0] = seq_index[1] = seq_index[2] = 0; | |
| 2089 | portentry->name = input_port_string_from_token(*ipt++); | |
| 2531 | curfield->name = input_port_string_from_token(*ipt++); | |
| 2090 | 2532 | break; |
| 2091 | 2533 | |
| 2534 | /* DIP switch setting */ | |
| 2092 | 2535 | case INPUT_TOKEN_DIPSETTING: |
| 2536 | if (curfield == NULL) | |
| 2537 | fatalerror("INPUT_TOKEN_DIPSETTING encountered with no active field"); | |
| 2538 | ||
| 2093 | 2539 | TOKEN_UNGET_UINT32(ipt); |
| 2094 | 2540 | TOKEN_GET_UINT64_UNPACK2(ipt, entrytype, 8, defval, 32); |
| 2095 | portentry = input_port_initialize(param, IPT_DIPSWITCH_SETTING, modify_tag, 0, defval); | |
| 2096 | seq_index[0] = seq_index[1] = seq_index[2] = 0; | |
| 2097 | portentry->name = input_port_string_from_token(*ipt++); | |
| 2098 | break; | |
| 2099 | 2541 | |
| 2100 | /* physical location */ | |
| 2101 | case INPUT_TOKEN_DIPLOCATION: | |
| 2102 | input_port_parse_diplocation(portentry, TOKEN_GET_STRING(ipt)); | |
| 2542 | cursetting = setting_config_alloc(curfield, defval & curfield->mask, input_port_string_from_token(*ipt++)); | |
| 2103 | 2543 | break; |
| 2104 | 2544 | |
| 2105 | /* conditionals for dip switch settings */ | |
| 2106 | case INPUT_TOKEN_CONDITION: | |
| 2545 | /* special DIP switch with on/off values */ | |
| 2546 | case INPUT_TOKEN_SPECIAL_ONOFF: | |
| 2547 | if (curport == NULL) | |
| 2548 | fatalerror("INPUT_TOKEN_SPECIAL_ONOFF encountered with no active port"); | |
| 2549 | ||
| 2107 | 2550 | TOKEN_UNGET_UINT32(ipt); |
| 2108 | TOKEN_GET_UINT32_UNPACK2(ipt, entrytype, 8, portentry->condition.condition, 24); | |
| 2109 | TOKEN_GET_UINT64_UNPACK2(ipt, portentry->condition.mask, 32, portentry->condition.value, 32); | |
| 2110 | portentry->condition.tag = TOKEN_GET_STRING(ipt); | |
| 2111 | break; | |
| 2551 | TOKEN_GET_UINT32_UNPACK3(ipt, entrytype, 8, hasdiploc, 1, temptoken.i, 23); | |
| 2552 | TOKEN_GET_UINT64_UNPACK2(ipt, mask, 32, defval, 32); | |
| 2112 | 2553 | |
| 2113 | /* analog adjuster definition */ | |
| 2114 | case INPUT_TOKEN_ADJUSTER: | |
| 2115 | TOKEN_UNGET_UINT32(ipt); | |
| 2116 | TOKEN_GET_UINT64_UNPACK2(ipt, entrytype, 8, defval, 32); | |
| 2117 | portentry = input_port_initialize(param, IPT_ADJUSTER, modify_tag, 0xff, defval | (defval << 8)); | |
| 2118 | seq_index[0] = seq_index[1] = seq_index[2] = 0; | |
| 2119 | portentry->name = TOKEN_GET_STRING(ipt); | |
| 2554 | curfield = field_config_alloc(curport, IPT_DIPSWITCH, defval, mask); | |
| 2555 | cursetting = NULL; | |
| 2556 | ||
| 2557 | curfield->name = input_port_string_from_token(temptoken); | |
| 2558 | if (temptoken.i == INPUT_STRING_Service_Mode) | |
| 2559 | { | |
| 2560 | curfield->flags |= FIELD_FLAG_TOGGLE; | |
| 2561 | curfield->seq[SEQ_TYPE_STANDARD].code[0] = KEYCODE_F2; | |
| 2562 | } | |
| 2563 | if (hasdiploc) | |
| 2564 | curfield->diploclist = diplocation_list_alloc(curfield, TOKEN_GET_STRING(ipt)); | |
| 2565 | ||
| 2566 | temptoken.i = INPUT_STRING_Off; | |
| 2567 | cursetting = setting_config_alloc(curfield, defval & mask, input_port_string_from_token(temptoken)); | |
| 2568 | ||
| 2569 | temptoken.i = INPUT_STRING_On; | |
| 2570 | cursetting = setting_config_alloc(curfield, ~defval & mask, input_port_string_from_token(temptoken)); | |
| 2120 | 2571 | break; |
| 2121 | 2572 | |
| 2122 | 2573 | /* configuration definition */ |
| 2123 | 2574 | case INPUT_TOKEN_CONFNAME: |
| 2575 | if (curport == NULL) | |
| 2576 | fatalerror("INPUT_TOKEN_CONFNAME encountered with no active port"); | |
| 2577 | ||
| 2124 | 2578 | TOKEN_GET_UINT64_UNPACK2(ipt, mask, 32, defval, 32); |
| 2125 | portentry = input_port_initialize(param, IPT_CONFIG_NAME, modify_tag, mask, defval); | |
| 2126 | seq_index[0] = seq_index[1] = seq_index[2] = 0; | |
| 2127 | portentry->name = input_port_string_from_token(*ipt++); | |
| 2579 | ||
| 2580 | curfield = field_config_alloc(curport, IPT_CONFIG, defval, mask); | |
| 2581 | cursetting = NULL; | |
| 2582 | ||
| 2583 | curfield->name = input_port_string_from_token(*ipt++); | |
| 2128 | 2584 | break; |
| 2129 | 2585 | |
| 2586 | /* configuration setting */ | |
| 2130 | 2587 | case INPUT_TOKEN_CONFSETTING: |
| 2588 | if (curfield == NULL) | |
| 2589 | fatalerror("INPUT_TOKEN_CONFSETTING encountered with no active field"); | |
| 2590 | ||
| 2131 | 2591 | TOKEN_UNGET_UINT32(ipt); |
| 2132 | 2592 | TOKEN_GET_UINT64_UNPACK2(ipt, entrytype, 8, defval, 32); |
| 2133 | portentry = input_port_initialize(param, IPT_CONFIG_SETTING, modify_tag, 0, defval); | |
| 2134 | seq_index[0] = seq_index[1] = seq_index[2] = 0; | |
| 2135 | portentry->name = input_port_string_from_token(*ipt++); | |
| 2136 | break; | |
| 2137 | 2593 | |
| 2138 | #ifdef MESS | |
| 2139 | case INPUT_TOKEN_CHAR: | |
| 2140 | TOKEN_UNGET_UINT32(ipt); | |
| 2141 | TOKEN_GET_UINT64_UNPACK2(ipt, entrytype, 8, val, 32); | |
| 2142 | { | |
| 2143 | int ch; | |
| 2144 | for (ch = 0; portentry->keyboard.chars[ch] != 0; ch++) | |
| 2145 | ; | |
| 2146 | portentry->keyboard.chars[ch] = (unicode_char) val; | |
| 2147 | } | |
| 2594 | cursetting = setting_config_alloc(curfield, defval & curfield->mask, input_port_string_from_token(*ipt++)); | |
| 2148 | 2595 | break; |
| 2149 | 2596 | |
| 2150 | /* category definition */ | |
| 2151 | case INPUT_TOKEN_CATEGORY: | |
| 2152 | TOKEN_UNGET_UINT32(ipt); | |
| 2153 | TOKEN_GET_UINT32_UNPACK2(ipt, entrytype, 8, portentry->category, 24); | |
| 2154 | break; | |
| 2597 | /* configuration definition */ | |
| 2598 | case INPUT_TOKEN_CATEGORY_NAME: | |
| 2599 | if (curport == NULL) | |
| 2600 | fatalerror("INPUT_TOKEN_CATEGORY_NAME encountered with no active port"); | |
| 2155 | 2601 | |
| 2156 | case INPUT_TOKEN_CATEGORY_NAME: | |
| 2157 | 2602 | TOKEN_GET_UINT64_UNPACK2(ipt, mask, 32, defval, 32); |
| 2158 | portentry = input_port_initialize(param, IPT_CATEGORY_NAME, modify_tag, mask, defval); | |
| 2159 | seq_index[0] = seq_index[1] = seq_index[2] = 0; | |
| 2160 | portentry->name = input_port_string_from_token(*ipt++); | |
| 2603 | ||
| 2604 | curfield = field_config_alloc(curport, IPT_CATEGORY, defval, mask); | |
| 2605 | cursetting = NULL; | |
| 2606 | ||
| 2607 | curfield->name = input_port_string_from_token(*ipt++); | |
| 2161 | 2608 | break; |
| 2162 | 2609 | |
| 2610 | /* configuration setting */ | |
| 2163 | 2611 | case INPUT_TOKEN_CATEGORY_SETTING: |
| 2612 | if (curfield == NULL) | |
| 2613 | fatalerror("INPUT_TOKEN_CATEGORY_SETTING encountered with no active field"); | |
| 2614 | ||
| 2164 | 2615 | TOKEN_UNGET_UINT32(ipt); |
| 2165 | TOKEN_GET_UINT64_UNPACK3(ipt, entrytype, 8, defval, 32, category, 16); | |
| 2166 | portentry = input_port_initialize(param, IPT_CATEGORY_SETTING, modify_tag, 0, defval); | |
| 2167 | seq_index[0] = seq_index[1] = seq_index[2] = 0; | |
| 2168 | portentry->name = input_port_string_from_token(*ipt++); | |
| 2169 | portentry->category = category; | |
| 2616 | TOKEN_GET_UINT64_UNPACK2(ipt, entrytype, 8, defval, 32); | |
| 2617 | ||
| 2618 | cursetting = setting_config_alloc(curfield, defval & curfield->mask, input_port_string_from_token(*ipt++)); | |
| 2170 | 2619 | break; |
| 2171 | #endif /* MESS */ | |
| 2172 | 2620 | |
| 2621 | /* analog adjuster definition */ | |
| 2622 | case INPUT_TOKEN_ADJUSTER: | |
| 2623 | if (curport == NULL) | |
| 2624 | fatalerror("INPUT_TOKEN_ADJUSTER encountered with no active port"); | |
| 2625 | ||
| 2626 | TOKEN_UNGET_UINT32(ipt); | |
| 2627 | TOKEN_GET_UINT64_UNPACK2(ipt, entrytype, 8, defval, 32); | |
| 2628 | ||
| 2629 | curfield = field_config_alloc(curport, IPT_ADJUSTER, defval, 0xff); | |
| 2630 | cursetting = NULL; | |
| 2631 | ||
| 2632 | curfield->name = TOKEN_GET_STRING(ipt); | |
| 2633 | break; | |
| 2634 | ||
| 2173 | 2635 | default: |
| 2174 | 2636 | fatalerror("Invalid token %d in input ports\n", entrytype); |
| 2175 | 2637 | break; |
| 2176 | 2638 | } |
| 2177 | 2639 | } |
| 2640 | ||
| 2641 | return listhead; | |
| 2178 | 2642 | } |
| 2179 | 2643 | |
| 2180 | 2644 | |
| 2645 | /*------------------------------------------------- | |
| 2646 | port_config_alloc - allocate a new input | |
| 2647 | port config and append to the end of the | |
| 2648 | given list | |
| 2649 | -------------------------------------------------*/ | |
| 2181 | 2650 | |
| 2182 | /************************************* | |
| 2183 | * | |
| 2184 | * Input port construction | |
| 2185 | * | |
| 2186 | *************************************/ | |
| 2651 | static input_port_config *port_config_alloc(const input_port_config **listhead) | |
| 2652 | { | |
| 2653 | const input_port_config * const *tailptr; | |
| 2654 | input_port_config *config; | |
| 2187 | 2655 | |
| 2188 | input_port_entry *input_port_initialize(input_port_init_params *iip, UINT32 type, const char *tag, UINT32 mask, UINT32 defval) | |
| 2656 | /* allocate memory */ | |
| 2657 | config = malloc_or_die(sizeof(*config)); | |
| 2658 | memset(config, 0, sizeof(*config)); | |
| 2659 | ||
| 2660 | /* add it to the tail */ | |
| 2661 | for (tailptr = listhead; *tailptr != NULL; tailptr = &(*tailptr)->next) ; | |
| 2662 | *(input_port_config **)tailptr = config; | |
| 2663 | ||
| 2664 | return config; | |
| 2665 | } | |
| 2666 | ||
| 2667 | ||
| 2668 | /*------------------------------------------------- | |
| 2669 | port_config_free - free an allocated input | |
| 2670 | port configuration | |
| 2671 | -------------------------------------------------*/ | |
| 2672 | ||
| 2673 | static void port_config_free(const input_port_config **portptr) | |
| 2189 | 2674 | { |
| 2190 | /* this function is used within an INPUT_PORT callback to set up a single port */ | |
| 2191 | input_port_entry *portentry; | |
| 2192 | input_code code; | |
| 2675 | input_port_config *port = (input_port_config *)*portptr; | |
| 2193 | 2676 | |
| 2194 | /* are we modifying an existing port? */ | |
| 2195 | if (tag != NULL) | |
| 2196 | { | |
| 2197 | int portnum, deleting; | |
| 2677 | /* free any field configs first */ | |
| 2678 | while (port->fieldlist != NULL) | |
| 2679 | field_config_free((input_field_config **)&port->fieldlist); | |
| 2198 | 2680 | |
| 2199 | /* find the matching port */ | |
| 2200 | for (portnum = 0; portnum < iip->current_port; portnum++) | |
| 2201 | if (iip->ports[portnum].type == IPT_PORT && iip->ports[portnum].start.tag != NULL && !strcmp(iip->ports[portnum].start.tag, tag)) | |
| 2202 | break; | |
| 2203 | if (portnum >= iip->current_port) | |
| 2204 | fatalerror("Could not find port to modify: '%s'", tag); | |
| 2681 | /* remove ourself from the list */ | |
| 2682 | *portptr = port->next; | |
| 2205 | 2683 | |
| 2206 | /* nuke any matching masks */ | |
| 2207 | for (portnum++, deleting = 0; portnum < iip->current_port && iip->ports[portnum].type != IPT_PORT; portnum++) | |
| 2684 | /* free ourself */ | |
| 2685 | free(port); | |
| 2686 | } | |
| 2687 | ||
| 2688 | ||
| 2689 | /*------------------------------------------------- | |
| 2690 | port_config_find - locate an existing port | |
| 2691 | configuration by tag | |
| 2692 | -------------------------------------------------*/ | |
| 2693 | ||
| 2694 | static input_port_config *port_config_find(const input_port_config *listhead, const char *tag) | |
| 2695 | { | |
| 2696 | const input_port_config *scanport; | |
| 2697 | ||
| 2698 | /* scan for a matching tag and return the matching port */ | |
| 2699 | for (scanport = listhead; scanport != NULL; scanport = scanport->next) | |
| 2700 | if (scanport->tag != NULL && strcmp(scanport->tag, tag) == 0) | |
| 2701 | return (input_port_config *)scanport; | |
| 2702 | ||
| 2703 | /* failure is fatal */ | |
| 2704 | fatalerror("port_config_find failed to find a matching port '%s'", tag); | |
| 2705 | } | |
| 2706 | ||
| 2707 | ||
| 2708 | /*------------------------------------------------- | |
| 2709 | field_config_alloc - allocate a new input | |
| 2710 | port field config, replacing any intersecting | |
| 2711 | fields already present and inserting at the | |
| 2712 | correct sorted location | |
| 2713 | -------------------------------------------------*/ | |
| 2714 | ||
| 2715 | static input_field_config *field_config_alloc(input_port_config *port, int type, input_port_value defvalue, input_port_value maskbits) | |
| 2716 | { | |
| 2717 | const input_field_config * const *scanfieldptr; | |
| 2718 | const input_field_config * const *scanfieldnextptr; | |
| 2719 | input_field_config *config; | |
| 2720 | input_port_value lowbit; | |
| 2721 | int seqtype; | |
| 2722 | ||
| 2723 | /* first modify/nuke any entries that intersect our maskbits */ | |
| 2724 | for (scanfieldptr = &port->fieldlist; *scanfieldptr != NULL; scanfieldptr = scanfieldnextptr) | |
| 2725 | { | |
| 2726 | scanfieldnextptr = &(*scanfieldptr)->next; | |
| 2727 | if (((*scanfieldptr)->mask & maskbits) != 0) | |
| 2208 | 2728 | { |
| 2209 | deleting = (iip->ports[portnum].mask & mask) || (deleting && iip->ports[portnum].mask == 0); | |
| 2210 | if (deleting) | |
| 2729 | /* reduce the mask of the field we found */ | |
| 2730 | config = (input_field_config *)*scanfieldptr; | |
| 2731 | config->mask &= ~maskbits; | |
| 2732 | ||
| 2733 | /* if the new entry fully overrides the previous one, we nuke */ | |
| 2734 | if (config->mask == 0) | |
| 2211 | 2735 | { |
| 2212 | iip->current_port--; | |
| 2213 | memmove(&iip->ports[portnum], &iip->ports[portnum + 1], (iip->current_port - portnum) * sizeof(iip->ports[0])); | |
| 2214 | portnum--; | |
| 2736 | field_config_free((input_field_config **)scanfieldptr); | |
| 2737 | scanfieldnextptr = scanfieldptr; | |
| 2215 | 2738 | } |
| 2216 | 2739 | } |
| 2217 | ||
| 2218 | /* allocate space for a new port at the end of this entry */ | |
| 2219 | if (iip->current_port >= iip->max_ports) | |
| 2220 | fatalerror("Too many input ports"); | |
| 2221 | if (portnum < iip->current_port) | |
| 2222 | { | |
| 2223 | memmove(&iip->ports[portnum + 1], &iip->ports[portnum], (iip->current_port - portnum) * sizeof(iip->ports[0])); | |
| 2224 | iip->current_port++; | |
| 2225 | portentry = &iip->ports[portnum]; | |
| 2226 | } | |
| 2227 | else | |
| 2228 | portentry = &iip->ports[iip->current_port++]; | |
| 2229 | 2740 | } |
| 2230 | 2741 | |
| 2231 | /* otherwise, just allocate a new one from the end */ | |
| 2232 | else | |
| 2233 | { | |
| 2234 | if (iip->current_port >= iip->max_ports) | |
| 2235 | fatalerror("Too many input ports"); | |
| 2236 | portentry = &iip->ports[iip->current_port++]; | |
| 2237 | } | |
| 2742 | /* make a mask of just the low bit */ | |
| 2743 | lowbit = (maskbits ^ (maskbits - 1)) & maskbits; | |
| 2238 | 2744 | |
| 2239 | /* set up defaults */ | |
| 2240 | memset(portentry, 0, sizeof(*portentry)); | |
| 2241 | portentry->name = IP_NAME_DEFAULT; | |
| 2242 | portentry->type = type; | |
| 2243 | portentry->mask = mask; | |
| 2244 | portentry->default_value = defval; | |
| 2745 | /* scan forward to find where to insert ourselves */ | |
| 2746 | for (scanfieldptr = (const input_field_config * const *)&port->fieldlist; *scanfieldptr != NULL; scanfieldptr = &(*scanfieldptr)->next) | |
| 2747 | if ((*scanfieldptr)->mask > lowbit) | |
| 2748 | break; | |
| 2245 | 2749 | |
| 2246 | /* default min to 0 and max to the mask value */ | |
| 2247 | /* they can be overwritten by PORT_MINMAX */ | |
| 2248 | if (port_type_is_analog(portentry->type) && !portentry->analog.min && !portentry->analog.max) | |
| 2249 | portentry->analog.max = portentry->mask; | |
| 2750 | /* allocate memory */ | |
| 2751 | config = malloc_or_die(sizeof(*config)); | |
| 2752 | memset(config, 0, sizeof(*config)); | |
| 2250 | 2753 | |
| 2251 | /* sets up default port codes */ | |
| 2252 | switch (portentry->type) | |
| 2253 | { | |
| 2254 | case IPT_DIPSWITCH_NAME: | |
| 2255 | case IPT_DIPSWITCH_SETTING: | |
| 2256 | case IPT_CONFIG_NAME: | |
| 2257 | case IPT_CONFIG_SETTING: | |
| 2258 | code = SEQCODE_END; | |
| 2259 | break; | |
| 2754 | /* fill in the basic field values */ | |
| 2755 | config->port = port; | |
| 2756 | config->type = type; | |
| 2757 | config->mask = maskbits; | |
| 2758 | config->defvalue = defvalue & maskbits; | |
| 2759 | config->max = maskbits; | |
| 2760 | for (seqtype = 0; seqtype < ARRAY_LENGTH(config->seq); seqtype++) | |
| 2761 | input_seq_set_1(&config->seq[seqtype], SEQCODE_DEFAULT); | |
| 2260 | 2762 | |
| 2261 | default: | |
| 2262 | code = SEQCODE_DEFAULT; | |
| 2263 | break; | |
| 2264 | } | |
| 2763 | /* insert it into the list */ | |
| 2764 | config->next = *scanfieldptr; | |
| 2765 | *(input_field_config **)scanfieldptr = config; | |
| 2265 | 2766 | |
| 2266 | /* set the default codes */ | |
| 2267 | input_seq_set_1(&portentry->seq, code); | |
| 2268 | input_seq_set_1(&portentry->analog.incseq, code); | |
| 2269 | input_seq_set_1(&portentry->analog.decseq, code); | |
| 2270 | return portentry; | |
| 2767 | return config; | |
| 2271 | 2768 | } |
| 2272 | 2769 | |
| 2273 | 2770 | |
| 2274 | input_port_entry *input_port_allocate(const input_port_token *ipt, input_port_entry *memory) | |
| 2771 | /*------------------------------------------------- | |
| 2772 | field_config_free - free an allocated input | |
| 2773 | field configuration | |
| 2774 | -------------------------------------------------*/ | |
| 2775 | ||
| 2776 | static void field_config_free(input_field_config **fieldptr) | |
| 2275 | 2777 | { |
| 2276 | input_ | |
| 2778 | input_f | |
| 2277 | 2779 | |
| 2278 | /* set up the port parameter structure */ | |
| 2279 | iip.max_ports = MAX_INPUT_PORTS * MAX_BITS_PER_PORT; | |
| 2280 | iip.current_port = 0; | |
| 2780 | /* free any settings and DIP locations first */ | |
| 2781 | while (field->settinglist != NULL) | |
| 2782 | setting_config_free((input_setting_config **)&field->settinglist); | |
| 2783 | while (field->diploclist != NULL) | |
| 2784 | diplocation_free((input_field_diplocation **)&field->diploclist); | |
| 2281 | 2785 | |
| 2282 | /* allocate memory for the input ports */ | |
| 2283 | if (memory == NULL) | |
| 2284 | iip.ports = (input_port_entry *)auto_malloc(iip.max_ports * sizeof(*iip.ports)); | |
| 2285 | else | |
| 2286 | iip.ports = memory; | |
| 2287 | memset(iip.ports, 0, iip.max_ports * sizeof(*iip.ports)); | |
| 2786 | /* remove ourself from the list */ | |
| 2787 | *fieldptr = (input_field_config *)field->next; | |
| 2288 | 2788 | |
| 2289 | /* construct the ports */ | |
| 2290 | input_port_detokenize(&iip, ipt); | |
| 2789 | /* free ourself */ | |
| 2790 | free(field); | |
| 2791 | } | |
| 2291 | 2792 | |
| 2292 | /* append final IPT_END */ | |
| 2293 | input_port_initialize(&iip, IPT_END, NULL, 0, 0); | |
| 2294 | 2793 | |
| 2295 | #ifdef MESS | |
| 2296 | /* process MESS specific extensions to the port */ | |
| 2297 | inputx_handle_mess_extensions(iip.ports); | |
| 2298 | #endif | |
| 2794 | /*------------------------------------------------- | |
| 2795 | setting_config_alloc - allocate a new input | |
| 2796 | port setting and append it to the end of the | |
| 2797 | list | |
| 2798 | -------------------------------------------------*/ | |
| 2299 | 2799 | |
| 2300 | return iip.ports; | |
| 2800 | static input_setting_config *setting_config_alloc(input_field_config *field, input_port_value value, const char *name) | |
| 2801 | { | |
| 2802 | const input_setting_config * const *tailptr; | |
| 2803 | input_setting_config *config; | |
| 2804 | ||
| 2805 | /* allocate memory */ | |
| 2806 | config = malloc_or_die(sizeof(*config)); | |
| 2807 | memset(config, 0, sizeof(*config)); | |
| 2808 | ||
| 2809 | /* fill in the basic setting values */ | |
| 2810 | config->field = field; | |
| 2811 | config->value = value; | |
| 2812 | config->name = name; | |
| 2813 | ||
| 2814 | /* add it to the tail */ | |
| 2815 | for (tailptr = &field->settinglist; *tailptr != NULL; tailptr = &(*tailptr)->next) ; | |
| 2816 | *(input_setting_config **)tailptr = config; | |
| 2817 | ||
| 2818 | return config; | |
| 2301 | 2819 | } |
| 2302 | 2820 | |
| 2303 | 2821 | |
| 2304 | void input_port_parse_diplocation(input_port_entry *in, const char *location) | |
| 2822 | /*------------------------------------------------- | |
| 2823 | setting_config_free - free an allocated input | |
| 2824 | setting configuration | |
| 2825 | -------------------------------------------------*/ | |
| 2826 | ||
| 2827 | static void setting_config_free(input_setting_config **settingptr) | |
| 2305 | 2828 | { |
| 2306 | char *curname = NULL, tempbuf[100]; | |
| 2307 | const char *entry; | |
| 2308 | int index, val, bits; | |
| 2309 | UINT32 temp; | |
| 2829 | input_setting_config *setting = (input_setting_config *)*settingptr; | |
| 2310 | 2830 | |
| 2831 | /* remove ourself from the list */ | |
| 2832 | *settingptr = (input_setting_config *)setting->next; | |
| 2833 | ||
| 2834 | /* free ourself */ | |
| 2835 | free(setting); | |
| 2836 | } | |
| 2837 | ||
| 2838 | ||
| 2839 | /*------------------------------------------------- | |
| 2840 | diplocation_expand - expand a string-based | |
| 2841 | DIP location into a linked list of | |
| 2842 | descriptions | |
| 2843 | -------------------------------------------------*/ | |
| 2844 | ||
| 2845 | static const input_field_diplocation *diplocation_list_alloc(const input_field_config *field, const char *location) | |
| 2846 | { | |
| 2847 | input_field_diplocation *head = NULL; | |
| 2848 | input_field_diplocation **tailptr = &head; | |
| 2849 | const char *curentry = location; | |
| 2850 | char *lastname = NULL; | |
| 2851 | char tempbuf[100]; | |
| 2852 | input_port_value temp; | |
| 2853 | int entries = 0; | |
| 2854 | int val, bits; | |
| 2855 | ||
| 2311 | 2856 | /* if nothing present, bail */ |
| 2312 | if (!location) | |
| 2313 | return; | |
| 2314 | memset(in->diploc, 0, sizeof(in->diploc)); | |
| 2857 | if (location == NULL) | |
| 2858 | return NULL; | |
| 2315 | 2859 | |
| 2316 | 2860 | /* parse the string */ |
| 2317 | | |
| 2861 | wh | |
| 2318 | 2862 | { |
| 2319 | 2863 | const char *comma, *colon, *number; |
| 2320 | 2864 | |
| 2865 | /* allocate a new entry */ | |
| 2866 | *tailptr = malloc_or_die(sizeof(**tailptr)); | |
| 2867 | memset(*tailptr, 0, sizeof(**tailptr)); | |
| 2868 | entries++; | |
| 2869 | ||
| 2321 | 2870 | /* find the end of this entry */ |
| 2322 | comma = strchr(entry, ','); | |
| 2871 | comma = strchr(curentry, ','); | |
| 2323 | 2872 | if (comma == NULL) |
| 2324 | comma = entry + strlen(entry); | |
| 2873 | comma = curentry + strlen(curentry); | |
| 2325 | 2874 | |
| 2326 | 2875 | /* extract it to tempbuf */ |
| 2327 | strncpy(tempbuf, entry, comma - entry); | |
| 2328 | tempbuf[comma - entry] = 0; | |
| 2876 | strncpy(tempbuf, curentry, comma - curentry); | |
| 2877 | tempbuf[comma - curentry] = 0; | |
| 2329 | 2878 | |
| 2330 | 2879 | /* first extract the switch name if present */ |
| 2331 | 2880 | number = tempbuf; |
| 2332 | 2881 | colon = strchr(tempbuf, ':'); |
| 2882 | ||
| 2883 | /* allocate and copy the name if it is present */ | |
| 2333 | 2884 | if (colon != NULL) |
| 2334 | 2885 | { |
| 2335 | curname = auto_malloc(colon - tempbuf + 1); | |
| 2336 | strncpy(curname, tempbuf, colon - tempbuf); | |
| 2337 | curname[colon - tempbuf] = 0; | |
| 2886 | (*tailptr)->swname = lastname = malloc_or_die(colon - tempbuf + 1); | |
| 2887 | strncpy(lastname, tempbuf, colon - tempbuf); | |
| 2888 | lastname[colon - tempbuf] = 0; | |
| 2338 | 2889 | number = colon + 1; |
| 2339 | 2890 | } |
| 2340 | 2891 | |
| 2341 | /* if we don't have a name by now, we're screwed */ | |
| 2342 | if (curname == NULL) | |
| 2343 | fatalerror("Switch location '%s' missing switch name!", location); | |
| 2892 | /* otherwise, just copy the last name */ | |
| 2893 | else | |
| 2894 | { | |
| 2895 | char *namecopy; | |
| 2896 | if (lastname == NULL) | |
| 2897 | fatalerror("Switch location '%s' missing switch name!", location); | |
| 2898 | (*tailptr)->swname = namecopy = malloc_or_die(strlen(lastname) + 1); | |
| 2899 | strcpy(namecopy, lastname); | |
| 2900 | } | |
| 2344 | 2901 | |
| 2345 | 2902 | /* if the number is preceded by a '!' it's active high */ |
| 2903 | (*tailptr)->invert = FALSE; | |
| 2346 | 2904 | if (*number == '!') |
| 2347 | 2905 | { |
| 2348 | i | |
| 2906 | (*tailptr)-> | |
| 2349 | 2907 | number++; |
| 2350 | 2908 | } |
| 2351 | else | |
| 2352 | in->diploc[index].invert = 0; | |
| 2353 | 2909 | |
| 2354 | 2910 | /* now scan the switch number */ |
| 2355 | 2911 | if (sscanf(number, "%d", &val) != 1) |
| 2356 | 2912 | fatalerror("Switch location '%s' has invalid format!", location); |
| 2913 | (*tailptr)->swnum = val; | |
| 2357 | 2914 | |
| 2358 | /* fill the entry and bump the index */ | |
| 2359 | in->diploc[index].swname = curname; | |
| 2360 | in->diploc[index].swnum = val; | |
| 2361 | ||
| 2362 | 2915 | /* advance to the next item */ |
| 2363 | entry = comma; | |
| 2364 | if (*entry) | |
| 2365 | entry++; | |
| 2916 | curentry = comma; | |
| 2917 | if (*curentry != 0) | |
| 2918 | curentry++; | |
| 2919 | tailptr = &(*tailptr)->next; | |
| 2366 | 2920 | } |
| 2367 | 2921 | |
| 2368 | 2922 | /* then verify the number of bits in the mask matches */ |
| 2369 | for (bits = 0, temp = i | |
| 2923 | for (bits = 0, temp = field->mask; temp != 0 && bits < 32; bits++) | |
| 2370 | 2924 | temp &= temp - 1; |
| 2371 | if (bits != index) | |
| 2372 | fatalerror("Switch location '%s' does not describe enough bits for mask %X\n", location, in->mask); | |
| 2925 | if (bits != entries) | |
| 2926 | fatalerror("Switch location '%s' does not describe enough bits for mask %X\n", location, field->mask); | |
| 2927 | return head; | |
| 2373 | 2928 | } |
| 2374 | 2929 | |
| 2375 | 2930 | |
| 2931 | /*------------------------------------------------- | |
| 2932 | diplocation_free - free an allocated dip | |
| 2933 | location | |
| 2934 | -------------------------------------------------*/ | |
| 2376 | 2935 | |
| 2377 | /************************************* | |
| 2378 | * | |
| 2379 | * List access | |
| 2380 | * | |
| 2381 | *************************************/ | |
| 2382 | ||
| 2383 | input_port_default_entry *get_input_port_list(void) | |
| 2936 | static void diplocation_free(input_field_diplocation **diplocptr) | |
| 2384 | 2937 | { |
| 2385 | return default_ports; | |
| 2386 | } | |
| 2938 | input_field_diplocation *diploc = (input_field_diplocation *)*diplocptr; | |
| 2387 | 2939 | |
| 2940 | /* free the name */ | |
| 2941 | if (diploc->swname != NULL) | |
| 2942 | free((void *)diploc->swname); | |
| 2388 | 2943 | |
| 2389 | const input_port_default_entry *get_input_port_list_defaults(void) | |
| 2390 | { | |
| 2391 | return default_ports_backup; | |
| 2944 | /* remove ourself from the list */ | |
| 2945 | *diplocptr = (input_field_diplocation *)diploc->next; | |
| 2946 | ||
| 2947 | /* free ourself */ | |
| 2948 | free(diploc); | |
| 2392 | 2949 | } |
| 2393 | 2950 | |
| 2394 | 2951 | |
| 2395 | 2952 | |
| 2396 | /************************************* | |
| 2397 | * | |
| 2398 | * Input port tokens | |
| 2399 | * | |
| 2400 | *************************************/ | |
| 2953 | /*************************************************************************** | |
| 2954 | TOKENIZATION HELPERS | |
| 2955 | ***************************************************************************/ | |
| 2401 | 2956 | |
| 2402 | const char *port_type_to_token(int type, int player) | |
| 2403 | { | |
| 2404 | static char tempbuf[32]; | |
| 2405 | int defindex; | |
| 2957 | /*------------------------------------------------- | |
| 2958 | token_to_input_field_type - convert a string | |
| 2959 | token to an input field type and player | |
| 2960 | -------------------------------------------------*/ | |
| 2406 | 2961 | |
| 2407 | /* look up the port and return the token */ | |
| 2408 | defindex = default_ports_lookup[type][player]; | |
| 2409 | if (defindex != -1) | |
| 2410 | return default_ports[defindex].token; | |
| 2411 | ||
| 2412 | /* if that fails, carry on */ | |
| 2413 | sprintf(tempbuf, "TYPE_OTHER(%d,%d)", type, player); | |
| 2414 | return tempbuf; | |
| 2415 | } | |
| 2416 | ||
| 2417 | ||
| 2418 | int token_to_port_type(const char *string, int *player) | |
| 2962 | static int token_to_input_field_type(running_machine *machine, const char *string, int *player) | |
| 2419 | 2963 | { |
| 2964 | input_port_private *portdata = machine->input_port_data; | |
| 2965 | const input_type_desc *typedesc; | |
| 2420 | 2966 | int ipnum; |
| 2421 | 2967 | |
| 2422 | 2968 | /* check for our failsafe case first */ |
| r2724 | r2725 | |
| 2424 | 2970 | return ipnum; |
| 2425 | 2971 | |
| 2426 | 2972 | /* find the token in the list */ |
| 2427 | for (ipnum = 0; ipnum < input_port_count; ipnum++) | |
| 2428 | if (default_ports[ipnum].token != NULL && !strcmp(default_ports[ipnum].token, string)) | |
| 2973 | for (typedesc = &portdata->typestatelist->typedesc; typedesc != NULL; typedesc = typedesc->next) | |
| 2974 | if (typedesc->token != NULL && !strcmp(typedesc->token, string)) | |
| 2429 | 2975 | { |
| 2430 | *player = default_ports[ipnum].player; | |
| 2431 | return default_ports[ipnum].type; | |
| 2976 | *player = typedesc->player; | |
| 2977 | return typedesc->type; | |
| 2432 | 2978 | } |
| 2433 | 2979 | |
| 2434 | 2980 | /* if we fail, return IPT_UNKNOWN */ |
| r2724 | r2725 | |
| 2437 | 2983 | } |
| 2438 | 2984 | |
| 2439 | 2985 | |
| 2986 | /*------------------------------------------------- | |
| 2987 | input_field_type_to_token - convert an input | |
| 2988 | field type and player to a string token | |
| 2989 | -------------------------------------------------*/ | |
| 2440 | 2990 | |
| 2441 | /************************************* | |
| 2442 | * | |
| 2443 | * Input port getters | |
| 2444 | * | |
| 2445 | *************************************/ | |
| 2446 | ||
| 2447 | int input_port_active(const input_port_entry *portentry) | |
| 2991 | static const char *input_field_type_to_token(running_machine *machine, int type, int player) | |
| 2448 | 2992 | { |
| 2449 | return (input_port_name(portentry) != NULL && !portentry->unused); | |
| 2450 | } | |
| 2993 | input_port_private *portdata = machine->input_port_data; | |
| 2994 | input_type_state *typestate; | |
| 2995 | static char tempbuf[32]; | |
| 2451 | 2996 | |
| 2997 | /* look up the port and return the token */ | |
| 2998 | typestate = portdata->type_to_typestate[type][player]; | |
| 2999 | if (typestate != NULL) | |
| 3000 | return typestate->typedesc.token; | |
| 2452 | 3001 | |
| 2453 | int port_type_is_analog(int type) | |
| 2454 | { | |
| 2455 | return (type >= __ipt_analog_start && type <= __ipt_analog_end); | |
| 3002 | /* if that fails, carry on */ | |
| 3003 | sprintf(tempbuf, "TYPE_OTHER(%d,%d)", type, player); | |
| 3004 | return tempbuf; | |
| 2456 | 3005 | } |
| 2457 | 3006 | |
| 2458 | 3007 | |
| 2459 | int port_type_is_analog_absolute(int type) | |
| 2460 | { | |
| 2461 | return (type >= __ipt_analog_absolute_start && type <= __ipt_analog_absolute_end); | |
| 2462 | } | |
| 3008 | /*------------------------------------------------- | |
| 3009 | token_to_seq_type - convert a string to | |
| 3010 | a sequence type | |
| 3011 | -------------------------------------------------*/ | |
| 2463 | 3012 | |
| 2464 | ||
| 2465 | int port_type_in_use(int type) | |
| 3013 | static int token_to_seq_type(const char *string) | |
| 2466 | 3014 | { |
| 2467 | input_port_entry *portentry; | |
| 2468 | for (portentry = Machine->input_ports; portentry->type != IPT_END; portentry++) | |
| 2469 | if (portentry->type == type) | |
| 2470 | return 1; | |
| 2471 | return 0; | |
| 2472 | } | |
| 3015 | int seqindex; | |
| 2473 | 3016 | |
| 3017 | /* look up the string in the table of possible sequence types and return the index */ | |
| 3018 | for (seqindex = 0; seqindex < ARRAY_LENGTH(seqtypestrings); seqindex++) | |
| 3019 | if (!mame_stricmp(string, seqtypestrings[seqindex])) | |
| 3020 | return seqindex; | |
| 2474 | 3021 | |
| 2475 | int port_type_to_group(int type, int player) | |
| 2476 | { | |
| 2477 | int defindex = default_ports_lookup[type][player]; | |
| 2478 | if (defindex != -1) | |
| 2479 | return default_ports[defindex].group; | |
| 2480 | return IPG_INVALID; | |
| 2481 | } | |
| 2482 | ||
| 2483 | ||
| 2484 | int port_tag_to_index(const char *tag) | |
| 2485 | { | |
| 2486 | int portnum; | |
| 2487 | ||
| 2488 | /* find the matching tag */ | |
| 2489 | for (portnum = 0; portnum < MAX_INPUT_PORTS; portnum++) | |
| 2490 | if (port_info[portnum].tag != NULL && !strcmp(port_info[portnum].tag, tag)) | |
| 2491 | return portnum; | |
| 2492 | 3022 | return -1; |
| 2493 | 3023 | } |
| 2494 | 3024 | |
| 2495 | 3025 | |
| 2496 | read8_machine_func port_tag_to_handler8(const char *tag) | |
| 2497 | { | |
| 2498 | int portnum = port_tag_to_index(tag); | |
| 2499 | return (portnum == -1) ? SMH_NOP : port_handler8[portnum]; | |
| 2500 | } | |
| 2501 | 3026 | |
| 3027 | /*************************************************************************** | |
| 3028 | SETTINGS LOAD | |
| 3029 | ***************************************************************************/ | |
| 2502 | 3030 | |
| 2503 | read16_machine_func port_tag_to_handler16(const char *tag) | |
| 2504 | { | |
| 2505 | int portnum = port_tag_to_index(tag); | |
| 2506 | return (portnum == -1) ? SMH_NOP : port_handler16[portnum]; | |
| 2507 | } | |
| 3031 | /*------------------------------------------------- | |
| 3032 | load_config_callback - callback to extract | |
| 3033 | configuration data from the XML nodes | |
| 3034 | -------------------------------------------------*/ | |
| 2508 | 3035 | |
| 2509 | ||
| 2510 | read32_machine_func port_tag_to_handler32(const char *tag) | |
| 3036 | static void load_config_callback(running_machine *machine, int config_type, xml_data_node *parentnode) | |
| 2511 | 3037 | { |
| 2512 | int portnum = port_tag_to_index(tag); | |
| 2513 | return (portnum == -1) ? SMH_NOP : port_handler32[portnum]; | |
| 2514 | } | |
| 3038 | input_port_private *portdata = machine->input_port_data; | |
| 3039 | xml_data_node *portnode; | |
| 3040 | int seqtype; | |
| 2515 | 3041 | |
| 3042 | /* in the completion phase, we finish the initialization with the final ports */ | |
| 3043 | if (config_type == CONFIG_TYPE_FINAL) | |
| 3044 | frame_update(machine); | |
| 2516 | 3045 | |
| 2517 | read64_machine_func port_tag_to_handler64(const char *tag) | |
| 2518 | { | |
| 2519 | return SMH_NOP; | |
| 2520 | } | |
| 3046 | /* early exit if no data to parse */ | |
| 3047 | if (parentnode == NULL) | |
| 3048 | return; | |
| 2521 | 3049 | |
| 3050 | /* iterate over all the remap nodes for controller configs only */ | |
| 3051 | if (config_type == CONFIG_TYPE_CONTROLLER) | |
| 3052 | load_remap_table(machine, parentnode); | |
| 2522 | 3053 | |
| 2523 | const char *input_port_name(const input_port_entry *portentry) | |
| 2524 | { | |
| 2525 | int defindex; | |
| 2526 | ||
| 2527 | /* if we have a non-default name, use that */ | |
| 2528 | if (portentry->name != IP_NAME_DEFAULT) | |
| 2529 | return portentry->name; | |
| 2530 | ||
| 2531 | /* if the port exists, return the default name */ | |
| 2532 | defindex = default_ports_lookup[portentry->type][portentry->player]; | |
| 2533 | if (defindex != -1) | |
| 2534 | return default_ports[defindex].name; | |
| 2535 | ||
| 2536 | /* should never get here */ | |
| 2537 | return NULL; | |
| 2538 | } | |
| 2539 | ||
| 2540 | ||
| 2541 | const input_seq *input_port_seq(input_port_entry *portentry, input_seq_type seqtype) | |
| 2542 | { | |
| 2543 | static const input_seq ip_none = SEQ_DEF_0; | |
| 2544 | input_seq *portseq; | |
| 2545 | ||
| 2546 | /* if port is disabled, return no key */ | |
| 2547 | if (portentry->unused) | |
| 2548 | return &ip_none; | |
| 2549 | ||
| 2550 | /* handle the various seq types */ | |
| 2551 | switch (seqtype) | |
| 3054 | /* iterate over all the port nodes */ | |
| 3055 | for (portnode = xml_get_sibling(parentnode->child, "port"); portnode; portnode = xml_get_sibling(portnode->next, "port")) | |
| 2552 | 3056 | { |
| 2553 | case SEQ_TYPE_STANDARD: | |
| 2554 | portseq = &portentry->seq; | |
| 2555 | break; | |
| 3057 | input_seq newseq[SEQ_TYPE_TOTAL], tempseq; | |
| 3058 | xml_data_node *seqnode; | |
| 3059 | int type, player; | |
| 2556 | 3060 | |
| 2557 | case SEQ_TYPE_INCREMENT: | |
| 2558 | if (!IS_ANALOG(portentry)) | |
| 2559 | return &ip_none; | |
| 2560 | portseq = &portentry->analog.incseq; | |
| 2561 | break; | |
| 3061 | /* get the basic port info from the attributes */ | |
| 3062 | type = token_to_input_field_type(machine, xml_get_attribute_string(portnode, "type", ""), &player); | |
| 2562 | 3063 | |
| 2563 | case SEQ_TYPE_DECREMENT: | |
| 2564 | if (!IS_ANALOG(portentry)) | |
| 2565 | return &ip_none; | |
| 2566 | portseq = &portentry->analog.decseq; | |
| 2567 | break; | |
| 3064 | /* initialize sequences to invalid defaults */ | |
| 3065 | for (seqtype = 0; seqtype < ARRAY_LENGTH(newseq); seqtype++) | |
| 3066 | input_seq_set_1(&newseq[seqtype], INPUT_CODE_INVALID); | |
| 2568 | 3067 | |
| 2569 | default: | |
| 2570 | return &ip_none; | |
| 2571 | } | |
| 2572 | ||
| 2573 | /* does this override the default? if so, return it directly */ | |
| 2574 | if (input_seq_get_1(portseq) != SEQCODE_DEFAULT) | |
| 2575 | return portseq; | |
| 2576 | ||
| 2577 | /* otherwise find the default setting */ | |
| 2578 | return input_port_default_seq(portentry->type, portentry->player, seqtype); | |
| 2579 | } | |
| 2580 | ||
| 2581 | ||
| 2582 | const input_seq *input_port_default_seq(int type, int player, input_seq_type seqtype) | |
| 2583 | { | |
| 2584 | static const input_seq ip_none = SEQ_DEF_0; | |
| 2585 | ||
| 2586 | /* find the default setting */ | |
| 2587 | int defindex = default_ports_lookup[type][player]; | |
| 2588 | if (defindex != -1) | |
| 2589 | { | |
| 2590 | switch (seqtype) | |
| 3068 | /* loop over new sequences */ | |
| 3069 | for (seqnode = xml_get_sibling(portnode->child, "newseq"); seqnode; seqnode = xml_get_sibling(seqnode->next, "newseq")) | |
| 2591 | 3070 | { |
| 2592 | case SEQ_TYPE_STANDARD: | |
| 2593 | return &default_ports[defindex].defaultseq; | |
| 2594 | case SEQ_TYPE_INCREMENT: | |
| 2595 | return &default_ports[defindex].defaultincseq; | |
| 2596 | case SEQ_TYPE_DECREMENT: | |
| 2597 | return &default_ports[defindex].defaultdecseq; | |
| 3071 | /* with a valid type, parse out the new sequence */ | |
| 3072 | seqtype = token_to_seq_type(xml_get_attribute_string(seqnode, "type", "")); | |
| 3073 | if (seqtype != -1 && seqnode->value != NULL) | |
| 3074 | { | |
| 3075 | if (strcmp(seqnode->value, "NONE") == 0) | |
| 3076 | input_seq_set_0(&newseq[seqtype]); | |
| 3077 | else if (input_seq_from_tokens(seqnode->value, &tempseq) != 0) | |
| 3078 | newseq[seqtype] = tempseq; | |
| 3079 | } | |
| 2598 | 3080 | } |
| 3081 | ||
| 3082 | /* if we're loading default ports, apply to the defaults */ | |
| 3083 | if (config_type != CONFIG_TYPE_GAME) | |
| 3084 | load_default_config(machine, portnode, type, player, newseq); | |
| 3085 | else | |
| 3086 | load_game_config(machine, portnode, type, player, newseq); | |
| 2599 | 3087 | } |
| 2600 | return &ip_none; | |
| 2601 | } | |
| 2602 | 3088 | |
| 3089 | /* after applying the controller config, push that back into the backup, since that is */ | |
| 3090 | /* what we will diff against */ | |
| 3091 | if (config_type == CONFIG_TYPE_CONTROLLER) | |
| 3092 | { | |
| 3093 | input_type_state *typestate; | |
| 3094 | int seqtype; | |
| 2603 | 3095 | |
| 2604 | int input_port_condition(const input_port_entry *in) | |
| 2605 | { | |
| 2606 | switch (in->condition.condition) | |
| 2607 | { | |
| 2608 | case PORTCOND_EQUALS: | |
| 2609 | return ((input_port_read_indexed(Machine, in->condition.portnum) & in->condition.mask) == in->condition.value); | |
| 2610 | case PORTCOND_NOTEQUALS: | |
| 2611 | return ((input_port_read_indexed(Machine, in->condition.portnum) & in->condition.mask) != in->condition.value); | |
| 3096 | for (typestate = portdata->typestatelist; typestate != NULL; typestate = typestate->next) | |
| 3097 | for (seqtype = 0; seqtype < ARRAY_LENGTH(typestate->typedesc.seq); seqtype++) | |
| 3098 | typestate->typedesc.seq[seqtype] = typestate->seq[seqtype]; | |
| 2612 | 3099 | } |
| 2613 | return 1; | |
| 2614 | 3100 | } |
| 2615 | 3101 | |
| 2616 | 3102 | |
| 3103 | /*------------------------------------------------- | |
| 3104 | load_remap_table - extract and apply the | |
| 3105 | global remapping table | |
| 3106 | -------------------------------------------------*/ | |
| 2617 | 3107 | |
| 2618 | /************************************* | |
| 2619 | * | |
| 2620 | * Key sequence handlers | |
| 2621 | * | |
| 2622 | *************************************/ | |
| 2623 | ||
| 2624 | int input_port_type_pressed(int type, int player) | |
| 3108 | static void load_remap_table(running_machine *machine, xml_data_node *parentnode) | |
| 2625 | 3109 | { |
| 2626 | int defindex = default_ports_lookup[type][player]; | |
| 2627 | if (defindex != -1) | |
| 2628 | return input_seq_pressed(&default_ports[defindex].defaultseq); | |
| 3110 | input_port_private *portdata = machine->input_port_data; | |
| 3111 | input_code *oldtable, *newtable; | |
| 3112 | xml_data_node *remapnode; | |
| 3113 | int count; | |
| 2629 | 3114 | |
| 2630 | return 0; | |
| 2631 | } | |
| 3115 | /* count items first so we can allocate */ | |
| 3116 | count = 0; | |
| 3117 | for (remapnode = xml_get_sibling(parentnode->child, "remap"); remapnode != NULL; remapnode = xml_get_sibling(remapnode->next, "remap")) | |
| 3118 | count++; | |
| 2632 | 3119 | |
| 2633 | ||
| 2634 | int input_ui_pressed(int code) | |
| 2635 | { | |
| 2636 | int pressed; | |
| 2637 | ||
| 2638 | profiler_mark(PROFILER_INPUT); | |
| 2639 | ||
| 2640 | /* get the status of this key (assumed to be only in the defaults) */ | |
| 2641 | pressed = input_seq_pressed(input_port_default_seq(code, 0, SEQ_TYPE_STANDARD)); | |
| 2642 | ||
| 2643 | /* if pressed, handle it specially */ | |
| 2644 | if (pressed) | |
| 3120 | /* if we have some, deal with them */ | |
| 3121 | if (count > 0) | |
| 2645 | 3122 | { |
| 2646 | /* if this is the first press, leave pressed = 1 */ | |
| 2647 | if (ui_memory[code] == 0) | |
| 2648 | ui_memory[code] = 1; | |
| 3123 | int remapnum; | |
| 2649 | 3124 | |
| 2650 | /* otherwise, reset pressed = 0 */ | |
| 2651 | else | |
| 2652 | pressed = 0; | |
| 2653 | } | |
| 3125 | /* allocate tables */ | |
| 3126 | oldtable = malloc_or_die(count * sizeof(*oldtable)); | |
| 3127 | newtable = malloc_or_die(count * sizeof(*newtable)); | |
| 2654 | 3128 | |
| 2655 | /* if we're not pressed, reset the memory field */ | |
| 2656 | else | |
| 2657 | ui_memory[code] = 0; | |
| 2658 | ||
| 2659 | profiler_mark(PROFILER_END); | |
| 2660 | ||
| 2661 | return pressed; | |
| 2662 | } | |
| 2663 | ||
| 2664 | ||
| 2665 | int input_ui_pressed_repeat(int code, int speed) | |
| 2666 | { | |
| 2667 | static osd_ticks_t lastdown; | |
| 2668 | static osd_ticks_t keydelay; | |
| 2669 | int pressed; | |
| 2670 | ||
| 2671 | profiler_mark(PROFILER_INPUT); | |
| 2672 | ||
| 2673 | /* get the status of this key (assumed to be only in the defaults) */ | |
| 2674 | pressed = input_seq_pressed(input_port_default_seq(code, 0, SEQ_TYPE_STANDARD)); | |
| 2675 | ||
| 2676 | /* if so, handle it specially */ | |
| 2677 | if (pressed) | |
| 2678 | { | |
| 2679 | /* if this is the first press, set a 3x delay and leave pressed = 1 */ | |
| 2680 | if (ui_memory[code] == 0) | |
| 3129 | /* build up the remap table */ | |
| 3130 | count = 0; | |
| 3131 | for (remapnode = xml_get_sibling(parentnode->child, "remap"); remapnode != NULL; remapnode = xml_get_sibling(remapnode->next, "remap")) | |
| 2681 | 3132 | { |
| 2682 | ui_memory[code] = 1; | |
| 2683 | lastdown = osd_ticks(); | |
| 2684 | keydelay = 3 * speed * osd_ticks_per_second() / 60; | |
| 3133 | input_code origcode = input_code_from_token(xml_get_attribute_string(remapnode, "origcode", "")); | |
| 3134 | input_code newcode = input_code_from_token(xml_get_attribute_string(remapnode, "newcode", "")); | |
| 3135 | if (origcode != INPUT_CODE_INVALID && newcode != INPUT_CODE_INVALID) | |
| 3136 | { | |
| 3137 | oldtable[count] = origcode; | |
| 3138 | newtable[count] = newcode; | |
| 3139 | count++; | |
| 3140 | } | |
| 2685 | 3141 | } |
| 2686 | 3142 | |
| 2687 | /* if this is an autorepeat case, set a 1x delay and leave pressed = 1 */ | |
| 2688 | else if (osd_ticks() - lastdown >= keydelay) | |
| 3143 | /* loop over the remapping table, operating only if something was specified */ | |
| 3144 | for (remapnum = 0; remapnum < count; remapnum++) | |
| 2689 | 3145 | { |
| 2690 | lastdown += keydelay; | |
| 2691 | keydelay = 1 * speed * osd_ticks_per_second() / 60; | |
| 3146 | input_code oldcode = oldtable[remapnum]; | |
| 3147 | input_code newcode = newtable[remapnum]; | |
| 3148 | input_type_state *typestate; | |
| 3149 | ||
| 3150 | /* loop over all default ports, remapping the requested keys */ | |
| 3151 | for (typestate = portdata->typestatelist; typestate != NULL; typestate = typestate->next) | |
| 3152 | { | |
| 3153 | int seqtype, codenum; | |
| 3154 | ||
| 3155 | /* remap anything in the default sequences */ | |
| 3156 | for (seqtype = 0; seqtype < ARRAY_LENGTH(typestate->seq); seqtype++) | |
| 3157 | for (codenum = 0; codenum < ARRAY_LENGTH(typestate->seq[0].code); codenum++) | |
| 3158 | if (typestate->seq[seqtype].code[codenum] == oldcode) | |
| 3159 | typestate->seq[seqtype].code[codenum] = newcode; | |
| 3160 | } | |
| 2692 | 3161 | } |
| 2693 | 3162 | |
| 2694 | /* otherwise, reset pressed = 0 */ | |
| 2695 | else | |
| 2696 | pressed = 0; | |
| 3163 | /* release the tables */ | |
| 3164 | free(oldtable); | |
| 3165 | free(newtable); | |
| 2697 | 3166 | } |
| 2698 | ||
| 2699 | /* if we're not pressed, reset the memory field */ | |
| 2700 | else | |
| 2701 | ui_memory[code] = 0; | |
| 2702 | ||
| 2703 | profiler_mark(PROFILER_END); | |
| 2704 | ||
| 2705 | return pressed; | |
| 2706 | 3167 | } |
| 2707 | 3168 | |
| 2708 | 3169 | |
| 3170 | /*------------------------------------------------- | |
| 3171 | load_default_config - apply configuration | |
| 3172 | data to the default mappings | |
| 3173 | -------------------------------------------------*/ | |
| 2709 | 3174 | |
| 2710 | /************************************* | |
| 2711 | * | |
| 2712 | * Update default ports | |
| 2713 | * | |
| 2714 | *************************************/ | |
| 2715 | ||
| 2716 | void input_port_update_defaults(void) | |
| 3175 | static int load_default_config(running_machine *machine, xml_data_node *portnode, int type, int player, const input_seq *newseq) | |
| 2717 | 3176 | { |
| 2718 | int loopnum, portnum; | |
| 3177 | input_port_private *portdata = machine->input_port_data; | |
| 3178 | input_type_state *typestate; | |
| 3179 | int seqtype; | |
| 2719 | 3180 | |
| 2720 | /* two passes to catch conditionals properly */ | |
| 2721 | for (loopnum = 0; loopnum < 2; loopnum++) | |
| 2722 | ||
| 2723 | /* loop over all input ports */ | |
| 2724 | for (portnum = 0; portnum < MAX_INPUT_PORTS; portnum++) | |
| 3181 | /* find a matching port in the list */ | |
| 3182 | for (typestate = portdata->typestatelist; typestate != NULL; typestate = typestate->next) | |
| 3183 | if (typestate->typedesc.type == type && typestate->typedesc.player == player) | |
| 2725 | 3184 | { |
| 2726 | input_port_info *portinfo = &port_info[portnum]; | |
| 2727 | input_bit_info *info; | |
| 2728 | int bitnum; | |
| 3185 | for (seqtype = 0; seqtype < ARRAY_LENGTH(typestate->seq); seqtype++) | |
| 3186 | if (input_seq_get_1(&newseq[seqtype]) != INPUT_CODE_INVALID) | |
| 3187 | typestate->seq[seqtype] = newseq[seqtype]; | |
| 3188 | return TRUE; | |
| 3189 | } | |
| 2729 | 3190 | |
| 2730 | /* only clear on the first pass */ | |
| 2731 | if (loopnum == 0) | |
| 2732 | portinfo->defvalue = 0; | |
| 2733 | ||
| 2734 | /* first compute the default value for the entire port */ | |
| 2735 | for (bitnum = 0, info = &portinfo->bit[0]; bitnum < MAX_BITS_PER_PORT && info->portentry; bitnum++, info++) | |
| 2736 | if (input_port_condition(info->portentry)) | |
| 2737 | portinfo->defvalue = (portinfo->defvalue & ~info->portentry->mask) | (info->portentry->default_value & info->portentry->mask); | |
| 2738 | } | |
| 3191 | return FALSE; | |
| 2739 | 3192 | } |
| 2740 | 3193 | |
| 2741 | 3194 | |
| 3195 | /*------------------------------------------------- | |
| 3196 | load_game_config - apply configuration | |
| 3197 | data to the current set of input ports | |
| 3198 | -------------------------------------------------*/ | |
| 2742 | 3199 | |
| 2743 | /************************************* | |
| 2744 | * | |
| 2745 | * VBLANK start routine | |
| 2746 | * | |
| 2747 | *************************************/ | |
| 2748 | ||
| 2749 | static void input_port_frame(running_machine *machine) | |
| 3200 | static int load_game_config(running_machine *machine, xml_data_node *portnode, int type, int player, const input_seq *newseq) | |
| 2750 | 3201 | { |
| 2751 | /* if we're paused, don't do anything */ | |
| 2752 | if (mame_is_paused(machine)) | |
| 2753 | return; | |
| 3202 | input_port_value mask, defvalue; | |
| 3203 | const input_field_config *field; | |
| 3204 | const input_port_config *port; | |
| 3205 | const char *tag; | |
| 2754 | 3206 | |
| 2755 | /* otherwise, use the common code */ | |
| 2756 | input_port_frame_update(machine); | |
| 2757 | } | |
| 3207 | /* read the mask, index, and defvalue attributes */ | |
| 3208 | tag = xml_get_attribute_string(portnode, "port", NULL); | |
| 3209 | mask = xml_get_attribute_int(portnode, "mask", 0); | |
| 3210 | defvalue = xml_get_attribute_int(portnode, "defvalue", 0); | |
| 2758 | 3211 | |
| 3212 | /* find the port we want; if no tag, search them all */ | |
| 3213 | for (port = machine->portconfig; port != NULL; port = port->next) | |
| 3214 | if (tag == NULL || (port->tag != NULL && strcmp(port->tag, tag) == 0)) | |
| 3215 | for (field = port->fieldlist; field != NULL; field = field->next) | |
| 2759 | 3216 | |
| 2760 | static void input_port_frame_update(running_machine *machine) | |
| 2761 | { | |
| 2762 | int ui_visible = ui_is_menu_active() || ui_is_slider_active(); | |
| 2763 | attotime curtime = timer_get_time(); | |
| 2764 | int portnum, bitnum; | |
| 2765 | ||
| 2766 | profiler_mark(PROFILER_INPUT); | |
| 2767 | ||
| 2768 | /* record/playback information about the current frame */ | |
| 2769 | playback_frame(machine, curtime); | |
| 2770 | record_frame(machine, curtime); | |
| 2771 | ||
| 2772 | /* track the duration of the previous frame */ | |
| 2773 | last_delta = attotime_to_attoseconds(attotime_sub(curtime, last_update)) / ATTOSECONDS_PER_SECOND_SQRT; | |
| 2774 | last_update = curtime; | |
| 2775 | ||
| 2776 | /* update all analog ports if the UI isn't visible */ | |
| 2777 | if (!ui_visible) | |
| 2778 | for (portnum = 0; portnum < MAX_INPUT_PORTS; portnum++) | |
| 2779 | update_analog_port(portnum); | |
| 2780 | ||
| 2781 | /* update the digital joysticks first */ | |
| 2782 | update_digital_joysticks(machine); | |
| 2783 | ||
| 2784 | /* compute default values for all the ports */ | |
| 2785 | input_port_update_defaults(); | |
| 2786 | ||
| 2787 | /* loop over all input ports */ | |
| 2788 | for (portnum = 0; portnum < MAX_INPUT_PORTS; portnum++) | |
| 2789 | { | |
| 2790 | input_port_info *portinfo = &port_info[portnum]; | |
| 2791 | input_bit_info *info; | |
| 2792 | changed_port_info *changed; | |
| 2793 | ||
| 2794 | /* compute the VBLANK mask */ | |
| 2795 | portinfo->vblank = 0; | |
| 2796 | for (bitnum = 0, info = &portinfo->bit[0]; bitnum < MAX_BITS_PER_PORT && info->portentry; bitnum++, info++) | |
| 2797 | if (input_port_condition(info->portentry) && info->portentry->type == IPT_VBLANK) | |
| 2798 | portinfo->vblank ^= info->portentry->mask; | |
| 2799 | ||
| 2800 | /* now loop back and modify based on the inputs */ | |
| 2801 | portinfo->digital = 0; | |
| 2802 | for (bitnum = 0, info = &portinfo->bit[0]; bitnum < MAX_BITS_PER_PORT && info->portentry; bitnum++, info++) | |
| 2803 | if (input_port_condition(info->portentry)) | |
| 2804 | { | |
| 2805 | input_port_entry *portentry = info->portentry; | |
| 2806 | ||
| 2807 | /* handle non-analog types, but only when the UI isn't visible */ | |
| 2808 | if (portentry->type != IPT_VBLANK && !IS_ANALOG(portentry) && !ui_visible) | |
| 3217 | /* find the matching mask and defvalue */ | |
| 3218 | if (field->type == type && field->player == player && | |
| 3219 | field->mask == mask && (field->defvalue & mask) == (defvalue & mask)) | |
| 2809 | 3220 | { |
| 2810 | /* if the sequence for this port is currently pressed.... */ | |
| 2811 | if (input_seq_pressed(input_port_seq(portentry, SEQ_TYPE_STANDARD))) | |
| 2812 | { | |
| 2813 | #ifdef MESS | |
| 2814 | /* (MESS-specific) check for disabled keyboard */ | |
| 2815 | if (portentry->type == IPT_KEYBOARD && osd_keyboard_disabled()) | |
| 2816 | continue; | |
| 2817 | #endif /* MESS */ | |
| 2818 | /* skip locked-out coin inputs */ | |
| 2819 | if (portentry->type >= IPT_COIN1 && portentry->type <= IPT_COIN8 && coinlockedout[portentry->type - IPT_COIN1]) | |
| 2820 | { | |
| 2821 | ui_popup_time(3, "Coinlock disabled %s.", input_port_name(portentry)); | |
| 2822 | continue; | |
| 2823 | } | |
| 2824 | if (portentry->type >= IPT_SERVICE1 && portentry->type <= IPT_SERVICE4 && servicecoinlockedout[portentry->type - IPT_SERVICE1]) | |
| 2825 | { | |
| 2826 | ui_popup_time(3, "Coinlock disabled %s.", input_port_name(portentry)); | |
| 2827 | continue; | |
| 2828 | } | |
| 2829 | /* if this is a downward press and we're an impulse control, reset the count */ | |
| 2830 | if (portentry->impulse) | |
| 2831 | { | |
| 2832 | if (info->last == 0) | |
| 2833 | info->impulse = portentry->impulse; | |
| 2834 | } | |
| 3221 | const char *revstring; | |
| 3222 | int seqtype; | |
| 2835 | 3223 | |
| 2836 | /* if this is a downward press and we're a toggle control, toggle the value */ | |
| 2837 | else if (portentry->toggle) | |
| 2838 | { | |
| 2839 | if (info->last == 0) | |
| 2840 | { | |
| 2841 | portentry->default_value ^= portentry->mask; | |
| 2842 | portinfo->digital ^= portentry->mask; | |
| 2843 | } | |
| 2844 | } | |
| 3224 | /* if a sequence was specified, copy it in */ | |
| 3225 | for (seqtype = 0; seqtype < ARRAY_LENGTH(field->state->seq); seqtype++) | |
| 3226 | if (input_seq_get_1(&newseq[seqtype]) != INPUT_CODE_INVALID) | |
| 3227 | field->state->seq[seqtype] = newseq[seqtype]; | |
| 2845 | 3228 | |
| 2846 | /* if this is a digital joystick type, apply either standard or 4-way rules */ | |
| 2847 | else if (IS_DIGITAL_JOYSTICK(portentry)) | |
| 2848 | { | |
| 2849 | digital_joystick_info *joyinfo = JOYSTICK_INFO_FOR_PORT(portentry); | |
| 2850 | UINT8 mask; | |
| 2851 | switch( portentry->way ) | |
| 2852 | { | |
| 2853 | case 4: | |
| 2854 | mask = joyinfo->current4way; | |
| 2855 | break; | |
| 2856 | case 16: | |
| 2857 | mask = 0xff; | |
| 2858 | break; | |
| 2859 | default: | |
| 2860 | mask = joyinfo->current; | |
| 2861 | break; | |
| 2862 | } | |
| 2863 | if ((mask >> JOYSTICK_DIR_FOR_PORT(portentry)) & 1) | |
| 2864 | portinfo->digital ^= portentry->mask; | |
| 2865 | } | |
| 3229 | /* for non-analog fields, fetch the value */ | |
| 3230 | if (field->state->analog == NULL) | |
| 3231 | field->state->value = xml_get_attribute_int(portnode, "value", field->defvalue); | |
| 2866 | 3232 | |
| 2867 | /* otherwise, just set it raw */ | |
| 2868 | else | |
| 2869 | portinfo->digital ^= portentry->mask; | |
| 2870 | ||
| 2871 | /* track the last value */ | |
| 2872 | info->last = 1; | |
| 2873 | } | |
| 3233 | /* for analog fields, fetch configurable analog attributes */ | |
| 2874 | 3234 | else |
| 2875 | info->last = 0; | |
| 3235 | { | |
| 3236 | /* get base attributes */ | |
| 3237 | field->state->analog->delta = xml_get_attribute_int(portnode, "keydelta", field->delta); | |
| 3238 | field->state->analog->centerdelta = xml_get_attribute_int(portnode, "centerdelta", field->centerdelta); | |
| 3239 | field->state->analog->sensitivity = xml_get_attribute_int(portnode, "sensitivity", field->sensitivity); | |
| 2876 | 3240 | |
| 2877 | /* handle the impulse countdown */ | |
| 2878 | if (portentry->impulse && info->impulse > 0) | |
| 2879 | { | |
| 2880 | info->impulse--; | |
| 2881 | info->last = 1; | |
| 2882 | portinfo->digital ^= portentry->mask; | |
| 3241 | /* fetch yes/no for reverse setting */ | |
| 3242 | revstring = xml_get_attribute_string(portnode, "reverse", NULL); | |
| 3243 | if (revstring != NULL) | |
| 3244 | field->state->analog->reverse = (strcmp(revstring, "yes") == 0); | |
| 2883 | 3245 | } |
| 3246 | return TRUE; | |
| 2884 | 3247 | } |
| 2885 | 3248 | |
| 2886 | /* note that analog ports are handled instantaneously at port read time */ | |
| 2887 | } | |
| 3249 | return FALSE; | |
| 3250 | } | |
| 2888 | 3251 | |
| 2889 | #ifdef MESS | |
| 2890 | /* hook for MESS's natural keyboard support */ | |
| 2891 | mess_input_port_update_hook(machine, portnum, &portinfo->digital); | |
| 2892 | #endif /* MESS */ | |
| 2893 | 3252 | |
| 2894 | /* call changed handlers */ | |
| 2895 | for (changed = portinfo->changedinfo; changed; changed = changed->next) | |
| 2896 | if (input_port_condition(changed->portentry)) | |
| 2897 | { | |
| 2898 | input_port_entry *portentry = changed->portentry; | |
| 2899 | 3253 | |
| 2900 | UINT32 new_unmasked_value = input_port_read_indexed(machine, portnum); | |
| 2901 | UINT32 newval = (new_unmasked_value & portentry->mask) >> changed->shift; | |
| 2902 | UINT32 oldval = (portentry->changed_last_value & portentry->mask) >> changed->shift; | |
| 3254 | /*************************************************************************** | |
| 3255 | SETTINGS SAVE | |
| 3256 | ***************************************************************************/ | |
| 2903 | 3257 | |
| 2904 | if (newval != oldval) | |
| 2905 | (*portentry->changed)(machine, portentry->changed_param, oldval, newval); | |
| 3258 | /*------------------------------------------------- | |
| 3259 | save_config_callback - config callback for | |
| 3260 | saving input port configuration | |
| 3261 | -------------------------------------------------*/ | |
| 2906 | 3262 | |
| 2907 | portentry->changed_last_value = new_unmasked_value; | |
| 2908 | } | |
| 2909 | } | |
| 3263 | static void save_config_callback(running_machine *machine, int config_type, xml_data_node *parentnode) | |
| 3264 | { | |
| 3265 | /* if no parentnode, ignore */ | |
| 3266 | if (parentnode == NULL) | |
| 3267 | return; | |
| 2910 | 3268 | |
| 2911 | /* handle playback/record */ | |
| 2912 | for (portnum = 0; portnum < MAX_INPUT_PORTS; portnum++) | |
| 2913 | { | |
| 2914 | playback_port(machine, &port_info[portnum]); | |
| 2915 | record_port(machine, &port_info[portnum]); | |
| 2916 | } | |
| 2917 | ||
| 2918 | profiler_mark(PROFILER_END); | |
| 3269 | /* default ports save differently */ | |
| 3270 | if (config_type == CONFIG_TYPE_DEFAULT) | |
| 3271 | save_default_inputs(machine, parentnode); | |
| 3272 | else | |
| 3273 | save_game_inputs(machine, parentnode); | |
| 2919 | 3274 | } |
| 2920 | 3275 | |
| 2921 | 3276 | |
| 3277 | /*------------------------------------------------- | |
| 3278 | save_sequence - add a node for an input | |
| 3279 | sequence | |
| 3280 | -------------------------------------------------*/ | |
| 2922 | 3281 | |
| 2923 | /************************************* | |
| 2924 | * | |
| 2925 | * Digital joystick updating | |
| 2926 | * | |
| 2927 | *************************************/ | |
| 2928 | ||
| 2929 | static void update_digital_joysticks(running_machine *machine) | |
| 3282 | static void save_sequence(xml_data_node *parentnode, int type, int porttype, const input_seq *seq) | |
| 2930 | 3283 | { |
| 2931 | int player, joyindex; | |
| 3284 | astring *seqstring = astring_alloc(); | |
| 3285 | xml_data_node *seqnode; | |
| 2932 | 3286 | |
| 2933 | /* loop over all the joysticks */ | |
| 2934 | for (player = 0; player < MAX_PLAYERS; player++) | |
| 2935 | for (joyindex = 0; joyindex < DIGITAL_JOYSTICKS_PER_PLAYER; joyindex++) | |
| 2936 | { | |
| 2937 | digital_joystick_info *info = &joystick_info[player][joyindex]; | |
| 2938 | if (info->inuse) | |
| 2939 | { | |
| 2940 | info->previous = info->current; | |
| 2941 | info->current = 0; | |
| 3287 | /* get the string for the sequence */ | |
| 3288 | if (input_seq_get_1(seq) == SEQCODE_END) | |
| 3289 | astring_cpyc(seqstring, "NONE"); | |
| 3290 | else | |
| 3291 | input_seq_to_tokens(seqstring, seq); | |
| 2942 | 3292 | |
| 2943 | /* read all the associated ports */ | |
| 2944 | if (info->portentry[JOYDIR_UP] != NULL && input_seq_pressed(input_port_seq(info->portentry[JOYDIR_UP], SEQ_TYPE_STANDARD))) | |
| 2945 | info->current |= JOYDIR_UP_BIT; | |
| 2946 | if (info->portentry[JOYDIR_DOWN] != NULL && input_seq_pressed(input_port_seq(info->portentry[JOYDIR_DOWN], SEQ_TYPE_STANDARD))) | |
| 2947 | info->current |= JOYDIR_DOWN_BIT; | |
| 2948 | if (info->portentry[JOYDIR_LEFT] != NULL && input_seq_pressed(input_port_seq(info->portentry[JOYDIR_LEFT], SEQ_TYPE_STANDARD))) | |
| 2949 | info->current |= JOYDIR_LEFT_BIT; | |
| 2950 | if (info->portentry[JOYDIR_RIGHT] != NULL && input_seq_pressed(input_port_seq(info->portentry[JOYDIR_RIGHT], SEQ_TYPE_STANDARD))) | |
| 2951 | info->current |= JOYDIR_RIGHT_BIT; | |
| 2952 | ||
| 2953 | /* lock out opposing directions (left + right or up + down) */ | |
| 2954 | if ((info->current & (JOYDIR_UP_BIT | JOYDIR_DOWN_BIT)) == (JOYDIR_UP_BIT | JOYDIR_DOWN_BIT)) | |
| 2955 | info->current &= ~(JOYDIR_UP_BIT | JOYDIR_DOWN_BIT); | |
| 2956 | if ((info->current & (JOYDIR_LEFT_BIT | JOYDIR_RIGHT_BIT)) == (JOYDIR_LEFT_BIT | JOYDIR_RIGHT_BIT)) | |
| 2957 | info->current &= ~(JOYDIR_LEFT_BIT | JOYDIR_RIGHT_BIT); | |
| 2958 | ||
| 2959 | /* only update 4-way case if joystick has moved */ | |
| 2960 | if (info->current != info->previous) | |
| 2961 | { | |
| 2962 | info->current4way = info->current; | |
| 2963 | ||
| 2964 | /* | |
| 2965 | If joystick is pointing at a diagonal, acknowledge that the player moved | |
| 2966 | the joystick by favoring a direction change. This minimizes frustration | |
| 2967 | when using a keyboard for input, and maximizes responsiveness. | |
| 2968 | ||
| 2969 | For example, if you are holding "left" then switch to "up" (where both left | |
| 2970 | and up are briefly pressed at the same time), we'll transition immediately | |
| 2971 | to "up." | |
| 2972 | ||
| 2973 | Zero any switches that didn't change from the previous to current state. | |
| 2974 | */ | |
| 2975 | if ((info->current4way & (JOYDIR_UP_BIT | JOYDIR_DOWN_BIT)) && | |
| 2976 | (info->current4way & (JOYDIR_LEFT_BIT | JOYDIR_RIGHT_BIT))) | |
| 2977 | { | |
| 2978 | info->current4way ^= info->current4way & info->previous; | |
| 2979 | } | |
| 2980 | ||
| 2981 | /* | |
| 2982 | If we are still pointing at a diagonal, we are in an indeterminant state. | |
| 2983 | ||
| 2984 | This could happen if the player moved the joystick from the idle position directly | |
| 2985 | to a diagonal, or from one diagonal directly to an extreme diagonal. | |
| 2986 | ||
| 2987 | The chances of this happening with a keyboard are slim, but we still need to | |
| 2988 | constrain this case. | |
| 2989 | ||
| 2990 | For now, just resolve randomly. | |
| 2991 | */ | |
| 2992 | if ((info->current4way & (JOYDIR_UP_BIT | JOYDIR_DOWN_BIT)) && | |
| 2993 | (info->current4way & (JOYDIR_LEFT_BIT | JOYDIR_RIGHT_BIT))) | |
| 2994 | { | |
| 2995 | if (mame_rand(machine) & 1) | |
| 2996 | info->current4way &= ~(JOYDIR_LEFT_BIT | JOYDIR_RIGHT_BIT); | |
| 2997 | else | |
| 2998 | info->current4way &= ~(JOYDIR_UP_BIT | JOYDIR_DOWN_BIT); | |
| 2999 | } | |
| 3000 | } | |
| 3001 | } | |
| 3002 | } | |
| 3293 | /* add the new node */ | |
| 3294 | seqnode = xml_add_child(parentnode, "newseq", astring_c(seqstring)); | |
| 3295 | if (seqnode != NULL) | |
| 3296 | xml_set_attribute(seqnode, "type", seqtypestrings[type]); | |
| 3297 | astring_free(seqstring); | |
| 3003 | 3298 | } |
| 3004 | 3299 | |
| 3005 | 3300 | |
| 3301 | /*------------------------------------------------- | |
| 3302 | save_this_input_field_type - determine if the given | |
| 3303 | port type is worth saving | |
| 3304 | -------------------------------------------------*/ | |
| 3006 | 3305 | |
| 3007 | /************************************* | |
| 3008 | * | |
| 3009 | * Analog minimum/maximum clamping | |
| 3010 | * | |
| 3011 | *************************************/ | |
| 3012 | ||
| 3013 | INLINE INT32 apply_analog_min_max(const analog_port_info *info, INT32 value) | |
| 3306 | static int save_this_input_field_type(int type) | |
| 3014 | 3307 | { |
| 3015 | const input_port_entry *portentry = info->portentry; | |
| 3016 | INT32 adjmax, adjmin, adj1, adjdif; | |
| 3017 | ||
| 3018 | /* take the analog minimum and maximum values and apply the inverse of the */ | |
| 3019 | /* sensitivity so that we can clamp against them before applying sensitivity */ | |
| 3020 | adjmin = APPLY_INVERSE_SENSITIVITY(info->minimum, portentry->analog.sensitivity); | |
| 3021 | adjmax = APPLY_INVERSE_SENSITIVITY(info->maximum, portentry->analog.sensitivity); | |
| 3022 | adj1 = APPLY_INVERSE_SENSITIVITY(512, portentry->analog.sensitivity); | |
| 3023 | ||
| 3024 | /* for absolute devices, clamp to the bounds absolutely */ | |
| 3025 | if (!info->wraps) | |
| 3308 | switch (type) | |
| 3026 | 3309 | { |
| 3027 | if (value > adjmax) | |
| 3028 | value = adjmax; | |
| 3029 | else if (value < adjmin) | |
| 3030 | value = adjmin; | |
| 3310 | case IPT_UNUSED: | |
| 3311 | case IPT_END: | |
| 3312 | case IPT_PORT: | |
| 3313 | case IPT_VBLANK: | |
| 3314 | case IPT_UNKNOWN: | |
| 3315 | return FALSE; | |
| 3031 | 3316 | } |
| 3032 | ||
| 3033 | /* for relative devices, wrap around when we go past the edge */ | |
| 3034 | else | |
| 3035 | { | |
| 3036 | adjdif = adjmax - adjmin + adj1; | |
| 3037 | if (portentry->analog.reverse) | |
| 3038 | { | |
| 3039 | while (value <= adjmin - adj1) | |
| 3040 | value += adjdif; | |
| 3041 | while (value > adjmax) | |
| 3042 | value -= adjdif; | |
| 3043 | } | |
| 3044 | else | |
| 3045 | { | |
| 3046 | while (value >= adjmax + adj1) | |
| 3047 | value -= adjdif; | |
| 3048 | while (value < adjmin) | |
| 3049 | value += adjdif; | |
| 3050 | } | |
| 3051 | } | |
| 3052 | ||
| 3053 | return value; | |
| 3317 | return TRUE; | |
| 3054 | 3318 | } |
| 3055 | 3319 | |
| 3056 | 3320 | |
| 3321 | /*------------------------------------------------- | |
| 3322 | save_default_inputs - add nodes for any default | |
| 3323 | mappings that have changed | |
| 3324 | -------------------------------------------------*/ | |
| 3057 | 3325 | |
| 3058 | /************************************* | |
| 3059 | * | |
| 3060 | * Analog port updating | |
| 3061 | * | |
| 3062 | *************************************/ | |
| 3063 | ||
| 3064 | static void update_analog_port(int portnum) | |
| 3326 | static void save_default_inputs(running_machine *machine, xml_data_node *parentnode) | |
| 3065 | 3327 | { |
| 3066 | analog_port_info *info; | |
| 3328 | input_port_private *portdata = machine->input_port_data; | |
| 3329 | input_type_state *typestate; | |
| 3067 | 3330 | |
| 3068 | /* loop over all analog ports in this port number */ | |
| 3069 | for (info = port_info[portnum].analoginfo; info != NULL; info = info->next) | |
| 3331 | /* iterate over ports */ | |
| 3332 | for (typestate = portdata->typestatelist; typestate != NULL; typestate = typestate->next) | |
| 3070 | 3333 | { |
| 3071 | input_port_entry *portentry = info->portentry; | |
| 3072 | INT32 rawvalue; | |
| 3073 | INT32 delta = 0; | |
| 3074 | INT64 keyscale; | |
| 3075 | int keypressed = FALSE; | |
| 3076 | input_item_class itemclass; | |
| 3334 | /* only save if this port is a type we save */ | |
| 3335 | if (save_this_input_field_type(typestate->typedesc.type)) | |
| 3336 | { | |
| 3337 | int seqtype; | |
| 3077 | 3338 | |
| 3078 | /* clamp the previous value to the min/max range and remember it */ | |
| 3079 | info->previous = info->accum = apply_analog_min_max(info, info->accum); | |
| 3339 | /* see if any of the sequences have changed */ | |
| 3340 | for (seqtype = 0; seqtype < ARRAY_LENGTH(typestate->seq); seqtype++) | |
| 3341 | if (input_seq_cmp(&typestate->seq[seqtype], &typestate->typedesc.seq[seqtype]) != 0) | |
| 3342 | break; | |
| 3080 | 3343 | |
| 3081 | /* get the new raw analog value and its type */ | |
| 3082 | rawvalue = input_seq_axis_value(input_port_seq(portentry, SEQ_TYPE_STANDARD), &itemclass); | |
| 3083 | ||
| 3084 | /* if we got an absolute input, it overrides everything else */ | |
| 3085 | if (itemclass == ITEM_CLASS_ABSOLUTE) | |
| 3086 | { | |
| 3087 | if (info->previousanalog != rawvalue) | |
| 3344 | /* if so, we need to add a node */ | |
| 3345 | if (seqtype < ARRAY_LENGTH(typestate->seq)) | |
| 3088 | 3346 | { |
| 3089 | /* only update if analog value changed */ | |
| 3090 | info->previousanalog = rawvalue; | |
| 3091 | ||
| 3092 | /* apply the inverse of the sensitivity to the raw value so that */ | |
| 3093 | /* it will still cover the full min->max range requested after */ | |
| 3094 | /* we apply the sensitivity adjustment */ | |
| 3095 | if (info->absolute || portentry->analog.reset) | |
| 3347 | /* add a new port node */ | |
| 3348 | xml_data_node *portnode = xml_add_child(parentnode, "port", NULL); | |
| 3349 | if (portnode != NULL) | |
| 3096 | 3350 | { |
| 3097 | /* if port is absolute, then just return the absolute data supplied */ | |
| 3098 | info->accum = APPLY_INVERSE_SENSITIVITY(rawvalue, portentry->analog.sensitivity); | |
| 3099 | } | |
| 3100 | else if (info->positionalscale != 0) | |
| 3101 | { | |
| 3102 | /* if port is positional, we will take the full analog control and divide it */ | |
| 3103 | /* into positions, that way as the control is moved full scale, */ | |
| 3104 | /* it moves through all the positions */ | |
| 3105 | rawvalue = APPLY_SCALE(rawvalue - INPUT_ABSOLUTE_MIN, info->positionalscale) * 512 + info->minimum; | |
| 3351 | /* add the port information and attributes */ | |
| 3352 | xml_set_attribute(portnode, "type", input_field_type_to_token(machine, typestate->typedesc.type, typestate->typedesc.player)); | |
| 3106 | 3353 | |
| 3107 | /* clamp the high value so it does not roll over */ | |
| 3108 | rawvalue = MIN(rawvalue, info->maximum); | |
| 3109 | info->accum = APPLY_INVERSE_SENSITIVITY(rawvalue, portentry->analog.sensitivity); | |
| 3354 | /* add only the sequences that have changed from the defaults */ | |
| 3355 | for (seqtype = 0; seqtype < ARRAY_LENGTH(typestate->seq); seqtype++) | |
| 3356 | if (input_seq_cmp(&typestate->seq[seqtype], &typestate->typedesc.seq[seqtype]) != 0) | |
| 3357 | save_sequence(portnode, seqtype, typestate->typedesc.type, &typestate->seq[seqtype]); | |
| 3110 | 3358 | } |
| 3111 | else | |
| 3112 | /* if port is relative, we use the value to simulate the speed of relative movement */ | |
| 3113 | /* sensitivity adjustment is allowed for this mode */ | |
| 3114 | info->accum += rawvalue; | |
| 3115 | ||
| 3116 | info->lastdigital = FALSE; | |
| 3117 | /* do not bother with other control types if the analog data is changing */ | |
| 3118 | continue; | |
| 3119 | 3359 | } |
| 3120 | else | |
| 3121 | { | |
| 3122 | /* we still have to update fake relative from joystick control */ | |
| 3123 | if (!info->absolute && info->positionalscale == 0) | |
| 3124 | info->accum += rawvalue; | |
| 3125 | } | |
| 3126 | 3360 | } |
| 3361 | } | |
| 3362 | } | |
| 3127 | 3363 | |
| 3128 | /* if we got it from a relative device, use that as the starting delta */ | |
| 3129 | /* also note that the last input was not a digital one */ | |
| 3130 | if (itemclass == ITEM_CLASS_RELATIVE && rawvalue != 0) | |
| 3131 | { | |
| 3132 | delta = rawvalue; | |
| 3133 | info->lastdigital = 0; | |
| 3134 | } | |
| 3135 | 3364 | |
| 3136 | keyscale = (info->accum >= 0) ? info->keyscalepos : info->keyscaleneg; | |
| 3365 | /*------------------------------------------------- | |
| 3366 | save_game_inputs - add nodes for any game | |
| 3367 | mappings that have changed | |
| 3368 | -------------------------------------------------*/ | |
| 3137 | 3369 | |
| 3138 | /* if the decrement code sequence is pressed, add the key delta to */ | |
| 3139 | /* the accumulated delta; also note that the last input was a digital one */ | |
| 3140 | if (input_seq_pressed(input_port_seq(info->portentry, SEQ_TYPE_DECREMENT))) | |
| 3141 | { | |
| 3142 | keypressed = TRUE; | |
| 3143 | if (portentry->analog.delta) | |
| 3144 | delta -= APPLY_SCALE(portentry->analog.delta, keyscale); | |
| 3145 | else if (info->lastdigital != 1) | |
| 3146 | /* decrement only once when first pressed */ | |
| 3147 | delta -= APPLY_SCALE(1, keyscale); | |
| 3148 | info->lastdigital = 1; | |
| 3149 | } | |
| 3370 | static void save_game_inputs(running_machine *machine, xml_data_node *parentnode) | |
| 3371 | { | |
| 3372 | const input_field_config *field; | |
| 3373 | const input_port_config *port; | |
| 3150 | 3374 | |
| 3151 | /* same for the increment code sequence */ | |
| 3152 | if (input_seq_pressed(input_port_seq(info->portentry, SEQ_TYPE_INCREMENT))) | |
| 3153 | { | |
| 3154 | keypressed = TRUE; | |
| 3155 | if (portentry->analog.delta) | |
| 3156 | delta += APPLY_SCALE(portentry->analog.delta, keyscale); | |
| 3157 | else if (info->lastdigital != 2) | |
| 3158 | /* increment only once when first pressed */ | |
| 3159 | delta += APPLY_SCALE(1, keyscale); | |
| 3160 | info->lastdigital = 2; | |
| 3161 | } | |
| 3375 | /* iterate over ports */ | |
| 3376 | for (port = machine->portconfig; port != NULL; port = port->next) | |
| 3377 | for (field = port->fieldlist; field != NULL; field = field->next) | |
| 3378 | if (save_this_input_field_type(field->type)) | |
| 3379 | { | |
| 3380 | int changed = FALSE; | |
| 3381 | int seqtype; | |
| 3162 | 3382 | |
| 3163 | /* if resetting is requested, clear the accumulated position to 0 before */ | |
| 3164 | /* applying the deltas so that we only return this frame's delta */ | |
| 3165 | /* note that centering only works for relative controls */ | |
| 3166 | /* no need to check if absolute here because it is checked by the validity tests */ | |
| 3167 | if (portentry->analog.reset) | |
| 3168 | info->accum = 0; | |
| 3383 | /* determine if we changed */ | |
| 3384 | for (seqtype = 0; seqtype < ARRAY_LENGTH(field->state->seq); seqtype++) | |
| 3385 | changed |= (input_seq_cmp(&field->state->seq[seqtype], &field->seq[seqtype]) != 0); | |
| 3169 | 3386 | |
| 3170 | /* apply the delta to the accumulated value */ | |
| 3171 | info->accum += delta; | |
| 3387 | /* non-analog changes */ | |
| 3388 | if (field->state->analog == NULL) | |
| 3389 | changed |= ((field->state->value & field->mask) != (field->defvalue & field->mask)); | |
| 3172 | 3390 | |
| 3173 | /* if our last movement was due to a digital input, and if this control */ | |
| 3174 | /* type autocenters, and if neither the increment nor the decrement seq */ | |
| 3175 | /* was pressed, apply autocentering */ | |
| 3176 | if (info->autocenter) | |
| 3177 | { | |
| 3178 | INT32 center = APPLY_INVERSE_SENSITIVITY(info->center, portentry->analog.sensitivity); | |
| 3179 | if (info->lastdigital && !keypressed) | |
| 3180 | { | |
| 3181 | /* autocenter from positive values */ | |
| 3182 | if (info->accum >= center) | |
| 3391 | /* analog changes */ | |
| 3392 | else | |
| 3183 | 3393 | { |
| 3184 | info->accum -= APPLY_SCALE(portentry->analog.centerdelta, info->keyscalepos); | |
| 3185 | if (info->accum < center) | |
| 3186 | { | |
| 3187 | info->accum = center; | |
| 3188 | info->lastdigital = 0; | |
| 3189 | } | |
| 3394 | changed |= (field->state->analog->delta != field->delta); | |
| 3395 | changed |= (field->state->analog->centerdelta != field->centerdelta); | |
| 3396 | changed |= (field->state->analog->sensitivity != field->sensitivity); | |
| 3397 | changed |= (field->state->analog->reverse != ((field->flags & ANALOG_FLAG_REVERSE) != 0)); | |
| 3190 | 3398 | } |
| 3191 | 3399 | |
| 3192 | /* autocenter from negative values */ | |
| 3193 | else | |
| 3400 | /* if we did change, add a new node */ | |
| 3401 | if (changed) | |
| 3194 | 3402 | { |
| 3195 | info->accum += APPLY_SCALE(portentry->analog.centerdelta, info->keyscaleneg); | |
| 3196 | if (info->accum > center) | |
| 3403 | /* add a new port node */ | |
| 3404 | xml_data_node *portnode = xml_add_child(parentnode, "port", NULL); | |
| 3405 | if (portnode != NULL) | |
| 3197 | 3406 | { |
| 3198 | info->accum = center; | |
| 3199 | info->lastdigital = 0; | |
| 3407 | /* add the identifying information and attributes */ | |
| 3408 | xml_set_attribute(portnode, "tag", port->tag); | |
| 3409 | xml_set_attribute(portnode, "type", input_field_type_to_token(machine, field->type, field->player)); | |
| 3410 | xml_set_attribute_int(portnode, "mask", field->mask); | |
| 3411 | xml_set_attribute_int(portnode, "defvalue", field->defvalue & field->mask); | |
| 3412 | ||
| 3413 | /* add sequences if changed */ | |
| 3414 | for (seqtype = 0; seqtype < ARRAY_LENGTH(field->state->seq); seqtype++) | |
| 3415 | if (input_seq_cmp(&field->state->seq[seqtype], &field->seq[seqtype]) != 0) | |
| 3416 | save_sequence(portnode, seqtype, field->type, &field->state->seq[seqtype]); | |
| 3417 | ||
| 3418 | /* write out non-analog changes */ | |
| 3419 | if (field->state->analog == NULL) | |
| 3420 | { | |
| 3421 | if ((field->state->value & field->mask) != (field->defvalue & field->mask)) | |
| 3422 | xml_set_attribute_int(portnode, "value", field->state->value & field->mask); | |
| 3423 | } | |
| 3424 | ||
| 3425 | /* write out analog changes */ | |
| 3426 | else | |
| 3427 | { | |
| 3428 | if (field->state->analog->delta != field->delta) | |
| 3429 | xml_set_attribute_int(portnode, "keydelta", field->state->analog->delta); | |
| 3430 | if (field->state->analog->centerdelta != field->centerdelta) | |
| 3431 | xml_set_attribute_int(portnode, "centerdelta", field->state->analog->centerdelta); | |
| 3432 | if (field->state->analog->sensitivity != field->sensitivity) | |
| 3433 | xml_set_attribute_int(portnode, "sensitivity", field->state->analog->sensitivity); | |
| 3434 | if (field->state->analog->reverse != ((field->flags & ANALOG_FLAG_REVERSE) != 0)) | |
| 3435 | xml_set_attribute(portnode, "reverse", field->state->analog->reverse ? "yes" : "no"); | |
| 3436 | } | |
| 3200 | 3437 | } |
| 3201 | 3438 | } |
| 3202 | 3439 | } |
| 3203 | } | |
| 3204 | else if (!keypressed) | |
| 3205 | info->lastdigital = 0; | |
| 3206 | } | |
| 3207 | 3440 | } |
| 3208 | 3441 | |
| 3209 | 3442 | |
| 3210 | 3443 | |
| 3211 | /************************************* | |
| 3212 | * | |
| 3213 | * Apply analogue port settings | |
| 3214 | * | |
| 3215 | *************************************/ | |
| 3444 | /*************************************************************************** | |
| 3445 | INPUT PLAYBACK | |
| 3446 | ***************************************************************************/ | |
| 3216 | 3447 | |
| 3217 | INT32 apply_analogue_settings(INT32 current, analog_port_info *info) | |
| 3448 | /*------------------------------------------------- | |
| 3449 | playback_read_uint8 - read an 8-bit value | |
| 3450 | from the playback file | |
| 3451 | -------------------------------------------------*/ | |
| 3452 | ||
| 3453 | static UINT8 playback_read_uint8(running_machine *machine) | |
| 3218 | 3454 | { |
| 3219 | INT32 value; | |
| 3220 | input_port_entry *portentry = info->portentry; | |
| 3455 | input_port_private *portdata = machine->input_port_data; | |
| 3456 | UINT8 result; | |
| 3221 | 3457 | |
| 3222 | /* apply the min/max and then the sensitivity */ | |
| 3223 | current = apply_analog_min_max(info, current); | |
| 3224 | current = APPLY_SENSITIVITY(current, portentry->analog.sensitivity); | |
| 3458 | /* protect against NULL handles if previous reads fail */ | |
| 3459 | if (portdata->playback_file == NULL) | |
| 3460 | return 0; | |
| 3225 | 3461 | |
| 3226 | /* apply reversal if needed */ | |
| 3227 | if (portentry->analog.reverse) | |
| 3228 | current = info->reverse_val - current; | |
| 3229 | else if (info->single_scale) | |
| 3230 | /* it's a pedal or the default value is equal to min/max */ | |
| 3231 | /* so we need to adjust the center to the minimum */ | |
| 3232 | current -= INPUT_ABSOLUTE_MIN; | |
| 3462 | /* read the value; if we fail, end playback */ | |
| 3463 | if (mame_fread(portdata->playback_file, &result, sizeof(result)) != sizeof(result)) | |
| 3464 | { | |
| 3465 | playback_end(machine, "End of file"); | |
| 3466 | return 0; | |
| 3467 | } | |
| 3233 | 3468 | |
| 3234 | /* map differently for positive and negative values */ | |
| 3235 | if (current >= 0) | |
| 3236 | value = APPLY_SCALE(current, info->scalepos); | |
| 3237 | else | |
| 3238 | value = APPLY_SCALE(current, info->scaleneg); | |
| 3239 | value += portentry->default_value; | |
| 3240 | ||
| 3241 | return value; | |
| 3469 | /* return the appropriate value */ | |
| 3470 | return result; | |
| 3242 | 3471 | } |
| 3243 | 3472 | |
| 3244 | 3473 | |
| 3474 | /*------------------------------------------------- | |
| 3475 | playback_read_uint32 - read a 32-bit value | |
| 3476 | from the playback file | |
| 3477 | -------------------------------------------------*/ | |
| 3245 | 3478 | |
| 3246 | /************************************* | |
| 3247 | * | |
| 3248 | * Analog port interpolation | |
| 3249 | * | |
| 3250 | *************************************/ | |
| 3251 | ||
| 3252 | static UINT32 merge_interpolated_analog_data(int portnum, UINT32 digital) | |
| 3479 | static UINT32 playback_read_uint32(running_machine *machine) | |
| 3253 | 3480 | { |
| 3254 | analog_port_info *info; | |
| 3255 | UINT32 result = digital; | |
| 3481 | input_port_private *portdata = machine->input_port_data; | |
| 3482 | UINT32 result; | |
| 3256 | 3483 | |
| 3257 | profiler_mark(PROFILER_INPUT); | |
| 3484 | /* protect against NULL handles if previous reads fail */ | |
| 3485 | if (portdata->playback_file == NULL) | |
| 3486 | return 0; | |
| 3258 | 3487 | |
| 3259 | /* loop over all analog ports in this port number */ | |
| 3260 | for (info = port_info[portnum].analoginfo; info != NULL; info = info->next) | |
| 3488 | /* read the value; if we fail, end playback */ | |
| 3489 | if (mame_fread(portdata->playback_file, &result, sizeof(result)) != sizeof(result)) | |
| 3261 | 3490 | { |
| 3262 | input_port_entry *portentry = info->portentry; | |
| 3491 | playback_end(machine, "End of file"); | |
| 3492 | return 0; | |
| 3493 | } | |
| 3263 | 3494 | |
| 3264 | if (input_port_condition(portentry)) | |
| 3265 | { | |
| 3266 | INT32 current; | |
| 3267 | INT32 value; | |
| 3495 | /* return the appropriate value */ | |
| 3496 | return LITTLE_ENDIANIZE_INT32(result); | |
| 3497 | } | |
| 3268 | 3498 | |
| 3269 | /* interpolate or not */ | |
| 3270 | if (info->interpolate && !portentry->analog.reset && last_delta != 0) | |
| 3271 | { | |
| 3272 | attoseconds_t time_since_last = attotime_to_attoseconds(attotime_sub(timer_get_time(), last_update)) / ATTOSECONDS_PER_SECOND_SQRT; | |
| 3273 | current = info->previous + ((INT64)(info->accum - info->previous) * time_since_last / last_delta); | |
| 3274 | } | |
| 3275 | else | |
| 3276 | current = info->accum; | |
| 3277 | 3499 | |
| 3278 | value = apply_analogue_settings(current, info); | |
| 3500 | /*------------------------------------------------- | |
| 3501 | playback_read_uint64 - read a 64-bit value | |
| 3502 | from the playback file | |
| 3503 | -------------------------------------------------*/ | |
| 3279 | 3504 | |
| 3280 | /* remap the value if needed */ | |
| 3281 | if (portentry->analog.remap_table) | |
| 3282 | value = info->portentry->analog.remap_table[value]; | |
| 3505 | static UINT64 playback_read_uint64(running_machine *machine) | |
| 3506 | { | |
| 3507 | input_port_private *portdata = machine->input_port_data; | |
| 3508 | UINT64 result; | |
| 3283 | 3509 | |
| 3284 | /* invert bits if needed */ | |
| 3285 | if (portentry->analog.invert) | |
| 3286 | value = ~value; | |
| 3510 | /* protect against NULL handles if previous reads fail */ | |
| 3511 | if (portdata->playback_file == NULL) | |
| 3512 | return 0; | |
| 3287 | 3513 | |
| 3288 | /* insert into the port */ | |
| 3289 | result = (result & ~portentry->mask) | ((value << info->shift) & portentry->mask); | |
| 3290 | } | |
| 3514 | /* read the value; if we fail, end playback */ | |
| 3515 | if (mame_fread(portdata->playback_file, &result, sizeof(result)) != sizeof(result)) | |
| 3516 | { | |
| 3517 | playback_end(machine, "End of file"); | |
| 3518 | return 0; | |
| 3291 | 3519 | } |
| 3292 | 3520 | |
| 3293 | profiler_mark(PROFILER_END); | |
| 3294 | return result; | |
| 3521 | /* return the appropriate value */ | |
| 3522 | return LITTLE_ENDIANIZE_INT64(result); | |
| 3295 | 3523 | } |
| 3296 | 3524 | |
| 3297 | 3525 | |
| 3526 | /*------------------------------------------------- | |
| 3527 | playback_init - initialize INP playback | |
| 3528 | -------------------------------------------------*/ | |
| 3298 | 3529 | |
| 3299 | /************************************* | |
| 3300 | * | |
| 3301 | * Input port reading | |
| 3302 | * | |
| 3303 | *************************************/ | |
| 3304 | ||
| 3305 | UINT32 input_port_read_indexed(running_machine *machine, int portnum) | |
| 3530 | static time_t playback_init(running_machine *machine) | |
| 3306 | 3531 | { |
| 3307 | input_port_info *portinfo = &port_info[portnum]; | |
| 3308 | custom_port_info *custom; | |
| 3309 | UINT32 result; | |
| 3532 | const char *filename = options_get_string(mame_options(), OPTION_PLAYBACK); | |
| 3533 | input_port_private *portdata = machine->input_port_data; | |
| 3534 | UINT8 header[INP_HEADER_SIZE]; | |
| 3535 | file_error filerr; | |
| 3536 | time_t basetime; | |
| 3310 | 3537 | |
| 3311 | /* start with the digital */ | |
| 3312 | result = portinfo->defvalue ^ portinfo->digital; | |
| 3538 | /* if no file, nothing to do */ | |
| 3539 | if (filename[0] == 0) | |
| 3540 | return 0; | |
| 3313 | 3541 | |
| 3314 | /* merge in analog portions */ | |
| 3315 | result = merge_interpolated_analog_data(portnum, result); | |
| 3542 | /* open the playback file */ | |
| 3543 | filerr = mame_fopen(SEARCHPATH_INPUTLOG, filename, OPEN_FLAG_READ, &portdata->playback_file); | |
| 3544 | assert_always(filerr == FILERR_NONE, "Failed to open file for playback"); | |
| 3316 | 3545 | |
| 3317 | /* update custom values */ | |
| 3318 | for (custom = portinfo->custominfo; custom; custom = custom->next) | |
| 3319 | if (input_port_condition(custom->portentry)) | |
| 3320 | { | |
| 3321 | /* replace the bits with bits from the custom routine */ | |
| 3322 | input_port_entry *portentry = custom->portentry; | |
| 3323 | result &= ~portentry->mask; | |
| 3324 | result |= ((*portentry->custom)(machine, portentry->custom_param) << custom->shift) & portentry->mask; | |
| 3325 | } | |
| 3546 | /* read the header and verify that it is a modern version; if not, print an error */ | |
| 3547 | if (mame_fread(portdata->playback_file, header, sizeof(header)) != sizeof(header)) | |
| 3548 | fatalerror("Input file is corrupt or invalid (missing header)"); | |
| 3549 | if (memcmp(header, "MAMEINP\0", 8) != 0) | |
| 3550 | fatalerror("Input file invalid or in an older, unsupported format"); | |
| 3551 | if (header[0x10] != INP_HEADER_MAJVERSION) | |
| 3552 | fatalerror("Input file format version mismatch"); | |
| 3326 | 3553 | |
| 3327 | /* handle VBLANK bits */ | |
| 3328 | if (portinfo->vblank) | |
| 3329 | { | |
| 3330 | /* reset the VBLANK bits to their default value, regardless of inputs */ | |
| 3331 | result = (result & ~portinfo->vblank) | (portinfo->defvalue & portinfo->vblank); | |
| 3554 | /* output info to console */ | |
| 3555 | mame_printf_info("Input file: %s\n", filename); | |
| 3556 | mame_printf_info("INP version %d.%d\n", header[0x10], header[0x11]); | |
| 3557 | basetime = header[0x08] | (header[0x09] << 8) | (header[0x0a] << 16) | (header[0x0b] << 24) | | |
| 3558 | ((UINT64)header[0x0c] << 32) | ((UINT64)header[0x0d] << 40) | ((UINT64)header[0x0e] << 48) | ((UINT64)header[0x0f] << 56); | |
| 3559 | mame_printf_info("Created %s", ctime(&basetime)); | |
| 3560 | mame_printf_info("Recorded using %s\n", header + 0x20); | |
| 3332 | 3561 | |
| 3333 | /* toggle VBLANK if we're in a VBLANK state */ | |
| 3334 | if (video_screen_get_vblank(machine->primary_screen)) | |
| 3335 | result ^= portinfo->vblank; | |
| 3336 | } | |
| 3337 | return result; | |
| 3562 | /* verify the header against the current game */ | |
| 3563 | if (memcmp(machine->gamedrv->name, header + 0x14, strlen(machine->gamedrv->name) + 1) != 0) | |
| 3564 | fatalerror("Input file is for " GAMENOUN " '%s', not for current " GAMENOUN " '%s'\n", header + 0x14, machine->gamedrv->name); | |
| 3565 | ||
| 3566 | return basetime; | |
| 3338 | 3567 | } |
| 3339 | 3568 | |
| 3340 | 3569 | |
| 3341 | UINT32 input_port_read(running_machine *machine, const char *tag) | |
| 3570 | /*------------------------------------------------- | |
| 3571 | playback_end - end INP playback | |
| 3572 | -------------------------------------------------*/ | |
| 3573 | ||
| 3574 | static void playback_end(running_machine *machine, const char *message) | |
| 3342 | 3575 | { |
| 3343 | int portnum = port_tag_to_index(tag); | |
| 3344 | if (portnum != -1) | |
| 3345 | return input_port_read_indexed(machine, portnum); | |
| 3576 | input_port_private *portdata = machine->input_port_data; | |
| 3346 | 3577 | |
| 3347 | /* otherwise fail horribly */ | |
| 3348 | fatalerror("Unable to locate input port '%s'", tag); | |
| 3349 | return -1; | |
| 3350 | } | |
| 3578 | /* only applies if we have a live file */ | |
| 3579 | if (portdata->playback_file != NULL) | |
| 3580 | { | |
| 3581 | /* close the file */ | |
| 3582 | mame_fclose(portdata->playback_file); | |
| 3583 | portdata->playback_file = NULL; | |
| 3351 | 3584 | |
| 3585 | /* pop a message */ | |
| 3586 | if (message != NULL) | |
| 3587 | popmessage("Playback Ended\nReason: %s", message); | |
| 3352 | 3588 | |
| 3353 | UINT32 input_port_read_safe(running_machine *machine, const char *tag, UINT32 defvalue) | |
| 3354 | { | |
| 3355 | int portnum = port_tag_to_index(tag); | |
| 3356 | if (portnum != -1) | |
| 3357 | return input_port_read_indexed(machine, portnum); | |
| 3358 | return defvalue; | |
| 3589 | /* display speed stats */ | |
| 3590 | portdata->playback_accumulated_speed /= portdata->playback_accumulated_frames; | |
| 3591 | mame_printf_info("Total playback frames: %d\n", (UINT32)portdata->playback_accumulated_frames); | |
| 3592 | mame_printf_info("Average recorded speed: %d%%\n", (UINT32)((portdata->playback_accumulated_speed * 200 + 1) >> 21)); | |
| 3593 | } | |
| 3359 | 3594 | } |
| 3360 | 3595 | |
| 3361 | 3596 | |
| 3597 | /*------------------------------------------------- | |
| 3598 | playback_frame - start of frame callback for | |
| 3599 | playback | |
| 3600 | -------------------------------------------------*/ | |
| 3362 | 3601 | |
| 3363 | /************************************* | |
| 3364 | * | |
| 3365 | * Return position of crosshair axis | |
| 3366 | * | |
| 3367 | *************************************/ | |
| 3368 | ||
| 3369 | UINT32 get_crosshair_pos(int port_num, UINT8 player, UINT8 axis) | |
| 3602 | static void playback_frame(running_machine *machine, attotime curtime) | |
| 3370 | 3603 | { |
| 3371 | input_port_info *portinfo = &port_info[port_num]; | |
| 3372 | analog_port_info *info; | |
| 3373 | input_port_entry *portentry; | |
| 3374 | UINT32 result = 0; | |
| 3604 | input_port_private *portdata = machine->input_port_data; | |
| 3375 | 3605 | |
| 3376 | for (info = portinfo->analoginfo; info; info = info->next) | |
| 3606 | /* if playing back, fetch the information and verify */ | |
| 3607 | if (portdata->playback_file != NULL) | |
| 3377 | 3608 | { |
| 3378 | portentry = info->portentry; | |
| 3379 | if (portentry->player == player && portentry->analog.crossaxis == axis && input_port_condition(portentry)) | |
| 3380 | { | |
| 3381 | result = apply_analogue_settings(info->accum, info) & (portentry->mask >> info->shift); | |
| 3382 | break; | |
| 3383 | } | |
| 3609 | attotime readtime; | |
| 3610 | ||
| 3611 | /* first the absolute time */ | |
| 3612 | readtime.seconds = playback_read_uint32(machine); | |
| 3613 | readtime.attoseconds = playback_read_uint64(machine); | |
| 3614 | if (attotime_compare(readtime, curtime) != 0) | |
| 3615 | playback_end(machine, "Out of sync"); | |
| 3616 | ||
| 3617 | /* then the speed */ | |
| 3618 | portdata->playback_accumulated_speed += playback_read_uint32(machine); | |
| 3619 | portdata->playback_accumulated_frames++; | |
| 3384 | 3620 | } |
| 3385 | ||
| 3386 | return result; | |
| 3387 | 3621 | } |
| 3388 | 3622 | |
| 3389 | 3623 | |
| 3390 | 3624 | /*------------------------------------------------- |
| 3391 | autoselect_device - autoselect a single | |
| 3392 | device based on the input port list passed | |
| 3393 | in and the corresponding option | |
| 3625 | playback_port - per-port callback for playback | |
| 3394 | 3626 | -------------------------------------------------*/ |
| 3395 | 3627 | |
| 3396 | static void | |
| 3628 | static void p | |
| 3397 | 3629 | { |
| 3398 | const char *stemp = options_get_string(mame_options(), option); | |
| 3399 | input_device_class autoenable = DEVICE_CLASS_KEYBOARD; | |
| 3400 | const char *autostring = "keyboard"; | |
| 3630 | input_port_private *portdata = port->machine->input_port_data; | |
| 3401 | 3631 | |
| 3402 | /* if nothing specified, ignore the option */ | |
| 3403 | if (stemp[0] == 0) | |
| 3404 | return; | |
| 3405 | ||
| 3406 | /* extract valid strings */ | |
| 3407 | if (strcmp(stemp, "mouse") == 0) | |
| 3632 | /* if playing back, fetch information about this port */ | |
| 3633 | if (portdata->playback_file != NULL) | |
| 3408 | 3634 | { |
| 3409 | autoenable = DEVICE_CLASS_MOUSE; | |
| 3410 | autostring = "mouse"; | |
| 3411 | } | |
| 3412 | else if (strcmp(stemp, "joystick") == 0) | |
| 3413 | { | |
| 3414 | autoenable = DEVICE_CLASS_JOYSTICK; | |
| 3415 | autostring = "joystick"; | |
| 3416 | } | |
| 3417 | else if (strcmp(stemp, "lightgun") == 0) | |
| 3418 | { | |
| 3419 | autoenable = DEVICE_CLASS_LIGHTGUN; | |
| 3420 | autostring = "lightgun"; | |
| 3421 | } | |
| 3422 | else if (strcmp(stemp, "none") == 0) | |
| 3423 | { | |
| 3424 | /* nothing specified */ | |
| 3425 | return; | |
| 3426 | } | |
| 3427 | else if (strcmp(stemp, "keyboard") != 0) | |
| 3428 | mame_printf_error("Invalid %s value %s; reverting to keyboard\n", option, stemp); | |
| 3635 | analog_field_state *analog; | |
| 3429 | 3636 | |
| 3430 | /* only scan the list if we haven't already enabled this class of control */ | |
| 3431 | if (!input_device_class_enabled(autoenable)) | |
| 3432 | for ( ; ipt->type != IPT_END; ipt++) | |
| 3637 | /* read the digital value */ | |
| 3638 | port->state->digital = playback_read_uint32(port->machine); | |
| 3433 | 3639 | |
| 3434 | /* if this port type is in use, apply the autoselect criteria */ | |
| 3435 | if ((type1 != 0 && ipt->type == type1) || | |
| 3436 | (type2 != 0 && ipt->type == type2) || | |
| 3437 | (type3 != 0 && ipt->type == type3)) | |
| 3438 | { | |
| 3439 | mame_printf_verbose("Input: Autoenabling %s due to presence of a %s\n", autostring, ananame); | |
| 3440 | input_device_class_enable(autoenable, TRUE); | |
| 3441 | break; | |
| 3442 | } | |
| 3640 | /* loop over analog ports and save their data */ | |
| 3641 | for (analog = port->state->analoglist; analog != NULL; analog = analog->next) | |
| 3642 | { | |
| 3643 | /* read current and previous values */ | |
| 3644 | analog->accum = playback_read_uint32(port->machine); | |
| 3645 | analog->previous = playback_read_uint32(port->machine); | |
| 3646 | ||
| 3647 | /* read configuration information */ | |
| 3648 | analog->sensitivity = playback_read_uint32(port->machine); | |
| 3649 | analog->reverse = playback_read_uint8(port->machine); | |
| 3650 | } | |
| 3651 | } | |
| 3443 | 3652 | } |
| 3444 | 3653 | |
| 3445 | 3654 | |
| 3446 | 3655 | |
| 3447 | 3656 | /*************************************************************************** |
| 3448 | P | |
| 3657 | INPUT | |
| 3449 | 3658 | ***************************************************************************/ |
| 3450 | 3659 | |
| 3451 | 3660 | /*------------------------------------------------- |
| 3452 | playback_read_uint8 - read an 8-bit value | |
| 3453 | from the playback file | |
| 3454 | -------------------------------------------------*/ | |
| 3455 | ||
| 3456 | static UINT8 playback_read_uint8(running_machine *machine) | |
| 3457 | { | |
| 3458 | UINT8 result; | |
| 3459 | ||
| 3460 | /* protect against NULL handles if previous reads fail */ | |
| 3461 | if (machine->playback_file == NULL) | |
| 3462 | return 0; | |
| 3463 | ||
| 3464 | /* read the value; if we fail, end playback */ | |
| 3465 | if (mame_fread(machine->playback_file, &result, sizeof(result)) != sizeof(result)) | |
| 3466 | { | |
| 3467 | playback_end(machine, "End of file"); | |
| 3468 | return 0; | |
| 3469 | } | |
| 3470 | ||
| 3471 | /* return the appropriate value */ | |
| 3472 | return result; | |
| 3473 | } | |
| 3474 | ||
| 3475 | ||
| 3476 | /*------------------------------------------------- | |
| 3477 | 3661 | record_write_uint8 - write an 8-bit value |
| 3478 | 3662 | to the record file |
| 3479 | 3663 | -------------------------------------------------*/ |
| 3480 | 3664 | |
| 3481 | 3665 | static void record_write_uint8(running_machine *machine, UINT8 data) |
| 3482 | 3666 | { |
| 3667 | input_port_private *portdata = machine->input_port_data; | |
| 3483 | 3668 | UINT8 result = data; |
| 3484 | 3669 | |
| 3485 | 3670 | /* protect against NULL handles if previous reads fail */ |
| 3486 | if ( | |
| 3671 | if (portdata | |
| 3487 | 3672 | return; |
| 3488 | 3673 | |
| 3489 | 3674 | /* read the value; if we fail, end playback */ |
| 3490 | if (mame_fwrite( | |
| 3675 | if (mame_fwrite(portdata | |
| 3491 | 3676 | record_end(machine, "Out of space"); |
| 3492 | 3677 | } |
| 3493 | 3678 | |
| 3494 | 3679 | |
| 3495 | 3680 | /*------------------------------------------------- |
| 3496 | playback_read_uint32 - read a 32-bit value | |
| 3497 | from the playback file | |
| 3498 | -------------------------------------------------*/ | |
| 3499 | ||
| 3500 | static UINT32 playback_read_uint32(running_machine *machine) | |
| 3501 | { | |
| 3502 | UINT32 result; | |
| 3503 | ||
| 3504 | /* protect against NULL handles if previous reads fail */ | |
| 3505 | if (machine->playback_file == NULL) | |
| 3506 | return 0; | |
| 3507 | ||
| 3508 | /* read the value; if we fail, end playback */ | |
| 3509 | if (mame_fread(machine->playback_file, &result, sizeof(result)) != sizeof(result)) | |
| 3510 | { | |
| 3511 | playback_end(machine, "End of file"); | |
| 3512 | return 0; | |
| 3513 | } | |
| 3514 | ||
| 3515 | /* return the appropriate value */ | |
| 3516 | return LITTLE_ENDIANIZE_INT32(result); | |
| 3517 | } | |
| 3518 | ||
| 3519 | ||
| 3520 | /*------------------------------------------------- | |
| 3521 | 3681 | record_write_uint32 - write a 32-bit value |
| 3522 | 3682 | to the record file |
| 3523 | 3683 | -------------------------------------------------*/ |
| 3524 | 3684 | |
| 3525 | 3685 | static void record_write_uint32(running_machine *machine, UINT32 data) |
| 3526 | 3686 | { |
| 3687 | input_port_private *portdata = machine->input_port_data; | |
| 3527 | 3688 | UINT32 result = LITTLE_ENDIANIZE_INT32(data); |
| 3528 | 3689 | |
| 3529 | 3690 | /* protect against NULL handles if previous reads fail */ |
| 3530 | if ( | |
| 3691 | if (portdata | |
| 3531 | 3692 | return; |
| 3532 | 3693 | |
| 3533 | 3694 | /* read the value; if we fail, end playback */ |
| 3534 | if (mame_fwrite( | |
| 3695 | if (mame_fwrite(portdata | |
| 3535 | 3696 | record_end(machine, "Out of space"); |
| 3536 | 3697 | } |
| 3537 | 3698 | |
| 3538 | 3699 | |
| 3539 | 3700 | /*------------------------------------------------- |
| 3540 | playback_read_uint64 - read a 64-bit value | |
| 3541 | from the playback file | |
| 3542 | -------------------------------------------------*/ | |
| 3543 | ||
| 3544 | static UINT64 playback_read_uint64(running_machine *machine) | |
| 3545 | { | |
| 3546 | UINT64 result; | |
| 3547 | ||
| 3548 | /* protect against NULL handles if previous reads fail */ | |
| 3549 | if (machine->playback_file == NULL) | |
| 3550 | return 0; | |
| 3551 | ||
| 3552 | /* read the value; if we fail, end playback */ | |
| 3553 | if (mame_fread(machine->playback_file, &result, sizeof(result)) != sizeof(result)) | |
| 3554 | { | |
| 3555 | playback_end(machine, "End of file"); | |
| 3556 | return 0; | |
| 3557 | } | |
| 3558 | ||
| 3559 | /* return the appropriate value */ | |
| 3560 | return LITTLE_ENDIANIZE_INT64(result); | |
| 3561 | } | |
| 3562 | ||
| 3563 | ||
| 3564 | /*------------------------------------------------- | |
| 3565 | 3701 | record_write_uint64 - write a 64-bit value |
| 3566 | 3702 | to the record file |
| 3567 | 3703 | -------------------------------------------------*/ |
| 3568 | 3704 | |
| 3569 | 3705 | static void record_write_uint64(running_machine *machine, UINT64 data) |
| 3570 | 3706 | { |
| 3707 | input_port_private *portdata = machine->input_port_data; | |
| 3571 | 3708 | UINT64 result = LITTLE_ENDIANIZE_INT64(data); |
| 3572 | 3709 | |
| 3573 | 3710 | /* protect against NULL handles if previous reads fail */ |
| 3574 | if ( | |
| 3711 | if (portdata | |
| 3575 | 3712 | return; |
| 3576 | 3713 | |
| 3577 | 3714 | /* read the value; if we fail, end playback */ |
| 3578 | if (mame_fwrite( | |
| 3715 | if (mame_fwrite(portdata | |
| 3579 | 3716 | record_end(machine, "Out of space"); |
| 3580 | 3717 | } |
| 3581 | 3718 | |
| 3582 | 3719 | |
| 3583 | 3720 | /*------------------------------------------------- |
| 3584 | playback_init - initialize INP playback | |
| 3585 | -------------------------------------------------*/ | |
| 3586 | ||
| 3587 | static time_t playback_init(running_machine *machine) | |
| 3588 | { | |
| 3589 | const char *filename = options_get_string(mame_options(), OPTION_PLAYBACK); | |
| 3590 | UINT8 header[INP_HEADER_SIZE]; | |
| 3591 | file_error filerr; | |
| 3592 | time_t basetime; | |
| 3593 | ||
| 3594 | /* if no file, nothing to do */ | |
| 3595 | if (filename[0] == 0) | |
| 3596 | return 0; | |
| 3597 | ||
| 3598 | /* open the playback file */ | |
| 3599 | filerr = mame_fopen(SEARCHPATH_INPUTLOG, filename, OPEN_FLAG_READ, &machine->playback_file); | |
| 3600 | assert_always(filerr == FILERR_NONE, "Failed to open file for playback"); | |
| 3601 | ||
| 3602 | /* read the header and verify that it is a modern version; if not, print an error */ | |
| 3603 | if (mame_fread(machine->playback_file, header, sizeof(header)) != sizeof(header)) | |
| 3604 | fatalerror("Input file is corrupt or invalid (missing header)"); | |
| 3605 | if (memcmp(header, "MAMEINP\0", 8) != 0) | |
| 3606 | fatalerror("Input file invalid or in an older, unsupported format"); | |
| 3607 | if (header[0x10] != INP_HEADER_MAJVERSION) | |
| 3608 | fatalerror("Input file format version mismatch"); | |
| 3609 | ||
| 3610 | /* output info to console */ | |
| 3611 | mame_printf_info("Input file: %s\n", filename); | |
| 3612 | mame_printf_info("INP version %d.%d\n", header[0x10], header[0x11]); | |
| 3613 | basetime = header[0x08] | (header[0x09] << 8) | (header[0x0a] << 16) | (header[0x0b] << 24) | | |
| 3614 | ((UINT64)header[0x0c] << 32) | ((UINT64)header[0x0d] << 40) | ((UINT64)header[0x0e] << 48) | ((UINT64)header[0x0f] << 56); | |
| 3615 | mame_printf_info("Created %s", ctime(&basetime)); | |
| 3616 | mame_printf_info("Recorded using %s\n", header + 0x20); | |
| 3617 | ||
| 3618 | /* verify the header against the current game */ | |
| 3619 | if (memcmp(machine->gamedrv->name, header + 0x14, strlen(machine->gamedrv->name) + 1) != 0) | |
| 3620 | fatalerror("Input file is for " GAMENOUN " '%s', not for current " GAMENOUN " '%s'\n", header + 0x14, machine->gamedrv->name); | |
| 3621 | ||
| 3622 | return basetime; | |
| 3623 | } | |
| 3624 | ||
| 3625 | ||
| 3626 | /*------------------------------------------------- | |
| 3627 | 3721 | record_init - initialize INP recording |
| 3628 | 3722 | -------------------------------------------------*/ |
| 3629 | 3723 | |
| 3630 | 3724 | static void record_init(running_machine *machine) |
| 3631 | 3725 | { |
| 3632 | 3726 | const char *filename = options_get_string(mame_options(), OPTION_RECORD); |
| 3727 | input_port_private *portdata = machine->input_port_data; | |
| 3633 | 3728 | UINT8 header[INP_HEADER_SIZE]; |
| 3634 | 3729 | mame_system_time systime; |
| 3635 | 3730 | file_error filerr; |
| r2724 | r2725 | |
| 3639 | 3734 | return; |
| 3640 | 3735 | |
| 3641 | 3736 | /* open the record file */ |
| 3642 | filerr = mame_fopen(SEARCHPATH_INPUTLOG, filename, OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS, & | |
| 3737 | filerr = mame_fopen(SEARCHPATH_INPUTLOG, filename, OPEN_FLAG_WRITE | OPEN_FLAG_CREATE | OPEN_FLAG_CREATE_PATHS, &portdata | |
| 3643 | 3738 | assert_always(filerr == FILERR_NONE, "Failed to open file for recording"); |
| 3644 | 3739 | |
| 3645 | 3740 | /* get the base time */ |
| r2724 | r2725 | |
| 3662 | 3757 | sprintf((char *)header + 0x20, APPNAME " %s", build_version); |
| 3663 | 3758 | |
| 3664 | 3759 | /* write it */ |
| 3665 | mame_fwrite( | |
| 3760 | mame_fwrite(portdata | |
| 3666 | 3761 | } |
| 3667 | 3762 | |
| 3668 | 3763 | |
| 3669 | 3764 | /*------------------------------------------------- |
| 3670 | playback_end - end INP playback | |
| 3671 | -------------------------------------------------*/ | |
| 3672 | ||
| 3673 | static void playback_end(running_machine *machine, const char *message) | |
| 3674 | { | |
| 3675 | /* only applies if we have a live file */ | |
| 3676 | if (machine->playback_file != NULL) | |
| 3677 | { | |
| 3678 | /* close the file */ | |
| 3679 | mame_fclose(machine->playback_file); | |
| 3680 | machine->playback_file = NULL; | |
| 3681 | ||
| 3682 | /* pop a message */ | |
| 3683 | if (message != NULL) | |
| 3684 | popmessage("Playback Ended\nReason: %s", message); | |
| 3685 | ||
| 3686 | /* display speed stats */ | |
| 3687 | playback_accumulated_speed /= playback_accumulated_frames; | |
| 3688 | mame_printf_info("Total playback frames: %d\n", (UINT32)playback_accumulated_frames); | |
| 3689 | mame_printf_info("Average recorded speed: %d%%\n", (UINT32)((playback_accumulated_speed * 200 + 1) >> 21)); | |
| 3690 | } | |
| 3691 | } | |
| 3692 | ||
| 3693 | ||
| 3694 | /*------------------------------------------------- | |
| 3695 | 3765 | record_end - end INP recording |
| 3696 | 3766 | -------------------------------------------------*/ |
| 3697 | 3767 | |
| 3698 | 3768 | static void record_end(running_machine *machine, const char *message) |
| 3699 | 3769 | { |
| 3770 | input_port_private *portdata = machine->input_port_data; | |
| 3771 | ||
| 3700 | 3772 | /* only applies if we have a live file */ |
| 3701 | if ( | |
| 3773 | if (portdata | |
| 3702 | 3774 | { |
| 3703 | 3775 | /* close the file */ |
| 3704 | mame_fclose(machine->record_file); | |
| 3705 | machine->record_file = NULL; | |
| 3776 | mame_fclose(portdata->record_file); | |
| 3777 | portdata->record_file = NULL; | |
| 3706 | 3778 | |
| 3707 | 3779 | /* pop a message */ |
| 3708 | 3780 | if (message != NULL) |
| r2724 | r2725 | |
| 3712 | 3784 | |
| 3713 | 3785 | |
| 3714 | 3786 | /*------------------------------------------------- |
| 3715 | playback_frame - start of frame callback for | |
| 3716 | playback | |
| 3717 | -------------------------------------------------*/ | |
| 3718 | ||
| 3719 | static void playback_frame(running_machine *machine, attotime curtime) | |
| 3720 | { | |
| 3721 | /* if playing back, fetch the information and verify */ | |
| 3722 | if (machine->playback_file != NULL) | |
| 3723 | { | |
| 3724 | attotime readtime; | |
| 3725 | ||
| 3726 | /* first the absolute time */ | |
| 3727 | readtime.seconds = playback_read_uint32(machine); | |
| 3728 | readtime.attoseconds = playback_read_uint64(machine); | |
| 3729 | if (attotime_compare(readtime, curtime) != 0) | |
| 3730 | playback_end(machine, "Out of sync"); | |
| 3731 | ||
| 3732 | /* then the speed */ | |
| 3733 | playback_accumulated_speed += playback_read_uint32(machine); | |
| 3734 | playback_accumulated_frames++; | |
| 3735 | } | |
| 3736 | } | |
| 3737 | ||
| 3738 | ||
| 3739 | /*------------------------------------------------- | |
| 3740 | 3787 | record_frame - start of frame callback for |
| 3741 | 3788 | recording |
| 3742 | 3789 | -------------------------------------------------*/ |
| 3743 | 3790 | |
| 3744 | 3791 | static void record_frame(running_machine *machine, attotime curtime) |
| 3745 | 3792 | { |
| 3793 | input_port_private *portdata = machine->input_port_data; | |
| 3794 | ||
| 3746 | 3795 | /* if recording, record information about the current frame */ |
| 3747 | if ( | |
| 3796 | if (portdata | |
| 3748 | 3797 | { |
| 3749 | 3798 | /* first the absolute time */ |
| 3750 | 3799 | record_write_uint32(machine, curtime.seconds); |
| r2724 | r2725 | |
| 3757 | 3806 | |
| 3758 | 3807 | |
| 3759 | 3808 | /*------------------------------------------------- |
| 3760 | | |
| 3809 | re | |
| 3761 | 3810 | -------------------------------------------------*/ |
| 3762 | 3811 | |
| 3763 | static void | |
| 3812 | static void re | |
| 3764 | 3813 | { |
| 3765 | /* if playing back, fetch information about this port */ | |
| 3766 | if (machine->playback_file != NULL) | |
| 3767 | { | |
| 3768 | analog_port_info *analog; | |
| 3814 | input_port_private *portdata = port->machine->input_port_data; | |
| 3769 | 3815 | |
| 3770 | /* read the digital value */ | |
| 3771 | portinfo->digital = playback_read_uint32(machine); | |
| 3772 | ||
| 3773 | /* loop over analog ports and save their data */ | |
| 3774 | for (analog = portinfo->analoginfo; analog != NULL; analog = analog->next) | |
| 3775 | { | |
| 3776 | /* read current and previous values */ | |
| 3777 | analog->accum = playback_read_uint32(machine); | |
| 3778 | analog->previous = playback_read_uint32(machine); | |
| 3779 | ||
| 3780 | /* read configuration information */ | |
| 3781 | analog->portentry->analog.sensitivity = playback_read_uint32(machine); | |
| 3782 | analog->portentry->analog.reverse = playback_read_uint8(machine); | |
| 3783 | } | |
| 3784 | } | |
| 3785 | } | |
| 3786 | ||
| 3787 | ||
| 3788 | /*------------------------------------------------- | |
| 3789 | record_port - per-port callback for record | |
| 3790 | -------------------------------------------------*/ | |
| 3791 | ||
| 3792 | static void record_port(running_machine *machine, input_port_info *portinfo) | |
| 3793 | { | |
| 3794 | 3816 | /* if recording, store information about this port */ |
| 3795 | if ( | |
| 3817 | if (portdata | |
| 3796 | 3818 | { |
| 3797 | analog_ | |
| 3819 | analog_ | |
| 3798 | 3820 | |
| 3799 | 3821 | /* store the digital value */ |
| 3800 | record_write_uint32(machine, port | |
| 3822 | record_write_uint32(port->machine, port->state->digital); | |
| 3801 | 3823 | |
| 3802 | 3824 | /* loop over analog ports and save their data */ |
| 3803 | for (analog = port | |
| 3825 | for (analog = port | |
| 3804 | 3826 | { |
| 3805 | 3827 | /* store current and previous values */ |
| 3806 | record_write_uint32(machine, analog->accum); | |
| 3807 | record_write_uint32(machine, analog->previous); | |
| 3828 | record_write_uint32(port->machine, analog->accum); | |
| 3829 | record_write_uint32(port->machine, analog->previous); | |
| 3808 | 3830 | |
| 3809 | 3831 | /* store configuration information */ |
| 3810 | record_write_uint32(machine, analog->portentry->analog.sensitivity); | |
| 3811 | record_write_uint8(machine, analog->portentry->analog.reverse); | |
| 3832 | record_write_uint32(port->machine, analog->sensitivity); | |
| 3833 | record_write_uint8(port->machine, analog->reverse); | |
| 3812 | 3834 | } |
| 3813 | 3835 | } |
| 3814 | 3836 | } |
| r0 | r2725 | |
|---|---|---|
| 1 | /*************************************************************************** | |
| 2 | ||
| 3 | inpttype.h | |
| 4 | ||
| 5 | Array of core-defined input types and default mappings. | |
| 6 | ||
| 7 | Copyright Nicola Salmoria and the MAME Team. | |
| 8 | Visit http://mamedev.org for licensing and usage restrictions. | |
| 9 | ||
| 10 | ***************************************************************************/ | |
| 11 | ||
| 12 | ||
| 13 | /*************************************************************************** | |
| 14 | BUILT-IN CORE MAPPINGS | |
| 15 | ***************************************************************************/ | |
| 16 | ||
| 17 | #define INPUT_PORT_DIGITAL_TYPE(_player,_group,_type,_name,_seq) \ | |
| 18 | { NULL, IPT_##_type, IPG_##_group, (_player == 0) ? _player : (_player) - 1, (_player == 0) ? #_type : ("P" #_player "_" #_type), _name, { _seq, SEQ_DEF_0, SEQ_DEF_0 } }, | |
| 19 | ||
| 20 | #define INPUT_PORT_ANALOG_TYPE(_player,_group,_type,_name,_seq,_decseq,_incseq) \ | |
| 21 | { NULL, IPT_##_type, IPG_##_group, (_player == 0) ? _player : (_player) - 1, (_player == 0) ? #_type : ("P" #_player "_" #_type), _name, { _seq, _incseq, _decseq } }, | |
| 22 | ||
| 23 | #define INDEXED(a,b) INPUT_CODE_SET_DEVINDEX(a,b) | |
| 24 | ||
| 25 | static const input_type_desc core_types[] = | |
| 26 | { | |
| 27 | INPUT_PORT_DIGITAL_TYPE( 1, PLAYER1, JOYSTICK_UP, "P1 Up", SEQ_DEF_3(KEYCODE_UP, SEQCODE_OR, INDEXED(JOYCODE_Y_UP_SWITCH, 0)) ) | |
| 28 | INPUT_PORT_DIGITAL_TYPE( 1, PLAYER1, JOYSTICK_DOWN, "P1 Down", SEQ_DEF_3(KEYCODE_DOWN, SEQCODE_OR, INDEXED(JOYCODE_Y_DOWN_SWITCH, 0)) ) | |
| 29 | INPUT_PORT_DIGITAL_TYPE( 1, PLAYER1, JOYSTICK_LEFT, "P1 Left", SEQ_DEF_3(KEYCODE_LEFT, SEQCODE_OR, INDEXED(JOYCODE_X_LEFT_SWITCH, 0)) ) | |
| 30 | INPUT_PORT_DIGITAL_TYPE( 1, PLAYER1, JOYSTICK_RIGHT, "P1 Right", SEQ_DEF_3(KEYCODE_RIGHT, SEQCODE_OR, INDEXED(JOYCODE_X_RIGHT_SWITCH, 0)) ) | |
| 31 | INPUT_PORT_DIGITAL_TYPE( 1, PLAYER1, JOYSTICKRIGHT_UP, "P1 Right/Up", SEQ_DEF_3(KEYCODE_I, SEQCODE_OR, INDEXED(JOYCODE_BUTTON2, 0)) ) | |
| 32 | INPUT_PORT_DIGITAL_TYPE( 1, PLAYER1, JOYSTICKRIGHT_DOWN, "P1 Right/Down", SEQ_DEF_3(KEYCODE_K, SEQCODE_OR, INDEXED(JOYCODE_BUTTON3, 0)) ) | |
| 33 | INPUT_PORT_DIGITAL_TYPE( 1, PLAYER1, JOYSTICKRIGHT_LEFT, "P1 Right/Left", SEQ_DEF_3(KEYCODE_J, SEQCODE_OR, INDEXED(JOYCODE_BUTTON1, 0)) ) | |
| 34 | INPUT_PORT_DIGITAL_TYPE( 1, PLAYER1, JOYSTICKRIGHT_RIGHT, "P1 Right/Right", SEQ_DEF_3(KEYCODE_L, SEQCODE_OR, INDEXED(JOYCODE_BUTTON4, 0)) ) | |
| 35 | INPUT_PORT_DIGITAL_TYPE( 1, PLAYER1, JOYSTICKLEFT_UP, "P1 Left/Up", SEQ_DEF_3(KEYCODE_E, SEQCODE_OR, INDEXED(JOYCODE_Y_UP_SWITCH, 0)) ) | |
| 36 | INPUT_PORT_DIGITAL_TYPE( 1, PLAYER1, JOYSTICKLEFT_DOWN, "P1 Left/Down", SEQ_DEF_3(KEYCODE_D, SEQCODE_OR, INDEXED(JOYCODE_Y_DOWN_SWITCH, 0)) ) | |
| 37 | INPUT_PORT_DIGITAL_TYPE( 1, PLAYER1, JOYSTICKLEFT_LEFT, "P1 Left/Left", SEQ_DEF_3(KEYCODE_S, SEQCODE_OR, INDEXED(JOYCODE_X_LEFT_SWITCH, 0)) ) | |
| 38 | INPUT_PORT_DIGITAL_TYPE( 1, PLAYER1, JOYSTICKLEFT_RIGHT, "P1 Left/Right", SEQ_DEF_3(KEYCODE_F, SEQCODE_OR, INDEXED(JOYCODE_X_RIGHT_SWITCH, 0)) ) | |
| 39 | INPUT_PORT_DIGITAL_TYPE( 1, PLAYER1, BUTTON1, "P1 Button 1", SEQ_DEF_7(KEYCODE_LCONTROL, SEQCODE_OR, INDEXED(JOYCODE_BUTTON1, 0), SEQCODE_OR, INDEXED(MOUSECODE_BUTTON1, 0), SEQCODE_OR, INDEXED(GUNCODE_BUTTON1, 0)) ) | |
| 40 | INPUT_PORT_DIGITAL_TYPE( 1, PLAYER1, BUTTON2, "P1 Button 2", SEQ_DEF_7(KEYCODE_LALT, SEQCODE_OR, INDEXED(JOYCODE_BUTTON2, 0), SEQCODE_OR, INDEXED(MOUSECODE_BUTTON3, 0), SEQCODE_OR, INDEXED(GUNCODE_BUTTON2, 0)) ) | |
| 41 | INPUT_PORT_DIGITAL_TYPE( 1, PLAYER1, BUTTON3, "P1 Button 3", SEQ_DEF_5(KEYCODE_SPACE, SEQCODE_OR, INDEXED(JOYCODE_BUTTON3, 0), SEQCODE_OR, INDEXED(MOUSECODE_BUTTON2, 0)) ) | |
| 42 | INPUT_PORT_DIGITAL_TYPE( 1, PLAYER1, BUTTON4, "P1 Button 4", SEQ_DEF_3(KEYCODE_LSHIFT, SEQCODE_OR, INDEXED(JOYCODE_BUTTON4, 0)) ) | |
| 43 | INPUT_PORT_DIGITAL_TYPE( 1, PLAYER1, BUTTON5, "P1 Button 5", SEQ_DEF_3(KEYCODE_Z, SEQCODE_OR, INDEXED(JOYCODE_BUTTON5, 0)) ) | |
| 44 | INPUT_PORT_DIGITAL_TYPE( 1, PLAYER1, BUTTON6, "P1 Button 6", SEQ_DEF_3(KEYCODE_X, SEQCODE_OR, INDEXED(JOYCODE_BUTTON6, 0)) ) | |
| 45 | INPUT_PORT_DIGITAL_TYPE( 1, PLAYER1, BUTTON7, "P1 Button 7", SEQ_DEF_3(KEYCODE_C, SEQCODE_OR, INDEXED(JOYCODE_BUTTON7, 0)) ) | |
| 46 | INPUT_PORT_DIGITAL_TYPE( 1, PLAYER1, BUTTON8, "P1 Button 8", SEQ_DEF_3(KEYCODE_V, SEQCODE_OR, INDEXED(JOYCODE_BUTTON8, 0)) ) | |
| 47 | INPUT_PORT_DIGITAL_TYPE( 1, PLAYER1, BUTTON9, "P1 Button 9", SEQ_DEF_3(KEYCODE_B, SEQCODE_OR, INDEXED(JOYCODE_BUTTON9, 0)) ) | |
| 48 | INPUT_PORT_DIGITAL_TYPE( 1, PLAYER1, BUTTON10, "P1 Button 10", SEQ_DEF_3(KEYCODE_N, SEQCODE_OR, INDEXED(JOYCODE_BUTTON10, 0)) ) | |
| 49 | INPUT_PORT_DIGITAL_TYPE( 1, PLAYER1, BUTTON11, "P1 Button 11", SEQ_DEF_3(KEYCODE_M, SEQCODE_OR, INDEXED(JOYCODE_BUTTON11, 0)) ) | |
| 50 | INPUT_PORT_DIGITAL_TYPE( 1, PLAYER1, BUTTON12, "P1 Button 12", SEQ_DEF_3(KEYCODE_COMMA, SEQCODE_OR, INDEXED(JOYCODE_BUTTON12, 0)) ) | |
| 51 | INPUT_PORT_DIGITAL_TYPE( 1, PLAYER1, BUTTON13, "P1 Button 13", SEQ_DEF_3(KEYCODE_STOP, SEQCODE_OR, INDEXED(JOYCODE_BUTTON13, 0)) ) | |
| 52 | INPUT_PORT_DIGITAL_TYPE( 1, PLAYER1, BUTTON14, "P1 Button 14", SEQ_DEF_3(KEYCODE_SLASH, SEQCODE_OR, INDEXED(JOYCODE_BUTTON14, 0)) ) | |
| 53 | INPUT_PORT_DIGITAL_TYPE( 1, PLAYER1, BUTTON15, "P1 Button 15", SEQ_DEF_3(KEYCODE_RSHIFT, SEQCODE_OR, INDEXED(JOYCODE_BUTTON15, 0)) ) | |
| 54 | INPUT_PORT_DIGITAL_TYPE( 1, PLAYER1, BUTTON16, "P1 Button 16", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON16, 0)) ) | |
| 55 | INPUT_PORT_DIGITAL_TYPE( 1, PLAYER1, START, "P1 Start", SEQ_DEF_3(KEYCODE_1, SEQCODE_OR, INDEXED(JOYCODE_START, 0)) ) | |
| 56 | INPUT_PORT_DIGITAL_TYPE( 1, PLAYER1, SELECT, "P1 Select", SEQ_DEF_3(KEYCODE_5, SEQCODE_OR, INDEXED(JOYCODE_SELECT, 0)) ) | |
| 57 | INPUT_PORT_DIGITAL_TYPE( 1, PLAYER1, MAHJONG_A, "P1 Mahjong A", SEQ_DEF_1(KEYCODE_A) ) | |
| 58 | INPUT_PORT_DIGITAL_TYPE( 1, PLAYER1, MAHJONG_B, "P1 Mahjong B", SEQ_DEF_1(KEYCODE_B) ) | |
| 59 | INPUT_PORT_DIGITAL_TYPE( 1, PLAYER1, MAHJONG_C, "P1 Mahjong C", SEQ_DEF_1(KEYCODE_C) ) | |
| 60 | INPUT_PORT_DIGITAL_TYPE( 1, PLAYER1, MAHJONG_D, "P1 Mahjong D", SEQ_DEF_1(KEYCODE_D) ) | |
| 61 | INPUT_PORT_DIGITAL_TYPE( 1, PLAYER1, MAHJONG_E, "P1 Mahjong E", SEQ_DEF_1(KEYCODE_E) ) | |
| 62 | INPUT_PORT_DIGITAL_TYPE( 1, PLAYER1, MAHJONG_F, "P1 Mahjong F", SEQ_DEF_1(KEYCODE_F) ) | |
| 63 | INPUT_PORT_DIGITAL_TYPE( 1, PLAYER1, MAHJONG_G, "P1 Mahjong G", SEQ_DEF_1(KEYCODE_G) ) | |
| 64 | INPUT_PORT_DIGITAL_TYPE( 1, PLAYER1, MAHJONG_H, "P1 Mahjong H", SEQ_DEF_1(KEYCODE_H) ) | |
| 65 | INPUT_PORT_DIGITAL_TYPE( 1, PLAYER1, MAHJONG_I, "P1 Mahjong I", SEQ_DEF_1(KEYCODE_I) ) | |
| 66 | INPUT_PORT_DIGITAL_TYPE( 1, PLAYER1, MAHJONG_J, "P1 Mahjong J", SEQ_DEF_1(KEYCODE_J) ) | |
| 67 | INPUT_PORT_DIGITAL_TYPE( 1, PLAYER1, MAHJONG_K, "P1 Mahjong K", SEQ_DEF_1(KEYCODE_K) ) | |
| 68 | INPUT_PORT_DIGITAL_TYPE( 1, PLAYER1, MAHJONG_L, "P1 Mahjong L", SEQ_DEF_1(KEYCODE_L) ) | |
| 69 | INPUT_PORT_DIGITAL_TYPE( 1, PLAYER1, MAHJONG_M, "P1 Mahjong M", SEQ_DEF_1(KEYCODE_M) ) | |
| 70 | INPUT_PORT_DIGITAL_TYPE( 1, PLAYER1, MAHJONG_N, "P1 Mahjong N", SEQ_DEF_1(KEYCODE_N) ) | |
| 71 | INPUT_PORT_DIGITAL_TYPE( 1, PLAYER1, MAHJONG_O, "P1 Mahjong O", SEQ_DEF_1(KEYCODE_O) ) | |
| 72 | INPUT_PORT_DIGITAL_TYPE( 1, PLAYER1, MAHJONG_P, "P1 Mahjong P", SEQ_DEF_1(KEYCODE_COLON) ) | |
| 73 | INPUT_PORT_DIGITAL_TYPE( 1, PLAYER1, MAHJONG_Q, "P1 Mahjong Q", SEQ_DEF_1(KEYCODE_Q) ) | |
| 74 | INPUT_PORT_DIGITAL_TYPE( 1, PLAYER1, MAHJONG_KAN, "P1 Mahjong Kan", SEQ_DEF_1(KEYCODE_LCONTROL) ) | |
| 75 | INPUT_PORT_DIGITAL_TYPE( 1, PLAYER1, MAHJONG_PON, "P1 Mahjong Pon", SEQ_DEF_1(KEYCODE_LALT) ) | |
| 76 | INPUT_PORT_DIGITAL_TYPE( 1, PLAYER1, MAHJONG_CHI, "P1 Mahjong Chi", SEQ_DEF_1(KEYCODE_SPACE) ) | |
| 77 | INPUT_PORT_DIGITAL_TYPE( 1, PLAYER1, MAHJONG_REACH, "P1 Mahjong Reach", SEQ_DEF_1(KEYCODE_LSHIFT) ) | |
| 78 | INPUT_PORT_DIGITAL_TYPE( 1, PLAYER1, MAHJONG_RON, "P1 Mahjong Ron", SEQ_DEF_1(KEYCODE_Z) ) | |
| 79 | INPUT_PORT_DIGITAL_TYPE( 1, PLAYER1, MAHJONG_BET, "P1 Mahjong Bet", SEQ_DEF_1(KEYCODE_2) ) | |
| 80 | INPUT_PORT_DIGITAL_TYPE( 1, PLAYER1, MAHJONG_LAST_CHANCE, "P1 Mahjong Last Chance", SEQ_DEF_1(KEYCODE_RALT) ) | |
| 81 | INPUT_PORT_DIGITAL_TYPE( 1, PLAYER1, MAHJONG_SCORE, "P1 Mahjong Score", SEQ_DEF_1(KEYCODE_RCONTROL) ) | |
| 82 | INPUT_PORT_DIGITAL_TYPE( 1, PLAYER1, MAHJONG_DOUBLE_UP, "P1 Mahjong Double Up", SEQ_DEF_1(KEYCODE_RSHIFT) ) | |
| 83 | INPUT_PORT_DIGITAL_TYPE( 1, PLAYER1, MAHJONG_FLIP_FLOP, "P1 Mahjong Flip Flop", SEQ_DEF_1(KEYCODE_Y) ) | |
| 84 | INPUT_PORT_DIGITAL_TYPE( 1, PLAYER1, MAHJONG_BIG, "P1 Mahjong Big", SEQ_DEF_1(KEYCODE_ENTER) ) | |
| 85 | INPUT_PORT_DIGITAL_TYPE( 1, PLAYER1, MAHJONG_SMALL, "P1 Mahjong Small", SEQ_DEF_1(KEYCODE_BACKSPACE) ) | |
| 86 | ||
| 87 | INPUT_PORT_DIGITAL_TYPE( 2, PLAYER2, JOYSTICK_UP, "P2 Up", SEQ_DEF_3(KEYCODE_R, SEQCODE_OR, INDEXED(JOYCODE_Y_UP_SWITCH, 1)) ) | |
| 88 | INPUT_PORT_DIGITAL_TYPE( 2, PLAYER2, JOYSTICK_DOWN, "P2 Down", SEQ_DEF_3(KEYCODE_F, SEQCODE_OR, INDEXED(JOYCODE_Y_DOWN_SWITCH, 1)) ) | |
| 89 | INPUT_PORT_DIGITAL_TYPE( 2, PLAYER2, JOYSTICK_LEFT, "P2 Left", SEQ_DEF_3(KEYCODE_D, SEQCODE_OR, INDEXED(JOYCODE_X_LEFT_SWITCH, 1)) ) | |
| 90 | INPUT_PORT_DIGITAL_TYPE( 2, PLAYER2, JOYSTICK_RIGHT, "P2 Right", SEQ_DEF_3(KEYCODE_G, SEQCODE_OR, INDEXED(JOYCODE_X_RIGHT_SWITCH, 1)) ) | |
| 91 | INPUT_PORT_DIGITAL_TYPE( 2, PLAYER2, JOYSTICKRIGHT_UP, "P2 Right/Up", SEQ_DEF_0 ) | |
| 92 | INPUT_PORT_DIGITAL_TYPE( 2, PLAYER2, JOYSTICKRIGHT_DOWN, "P2 Right/Down", SEQ_DEF_0 ) | |
| 93 | INPUT_PORT_DIGITAL_TYPE( 2, PLAYER2, JOYSTICKRIGHT_LEFT, "P2 Right/Left", SEQ_DEF_0 ) | |
| 94 | INPUT_PORT_DIGITAL_TYPE( 2, PLAYER2, JOYSTICKRIGHT_RIGHT, "P2 Right/Right", SEQ_DEF_0 ) | |
| 95 | INPUT_PORT_DIGITAL_TYPE( 2, PLAYER2, JOYSTICKLEFT_UP, "P2 Left/Up", SEQ_DEF_0 ) | |
| 96 | INPUT_PORT_DIGITAL_TYPE( 2, PLAYER2, JOYSTICKLEFT_DOWN, "P2 Left/Down", SEQ_DEF_0 ) | |
| 97 | INPUT_PORT_DIGITAL_TYPE( 2, PLAYER2, JOYSTICKLEFT_LEFT, "P2 Left/Left", SEQ_DEF_0 ) | |
| 98 | INPUT_PORT_DIGITAL_TYPE( 2, PLAYER2, JOYSTICKLEFT_RIGHT, "P2 Left/Right", SEQ_DEF_0 ) | |
| 99 | INPUT_PORT_DIGITAL_TYPE( 2, PLAYER2, BUTTON1, "P2 Button 1", SEQ_DEF_7(KEYCODE_A, SEQCODE_OR, INDEXED(JOYCODE_BUTTON1, 1), SEQCODE_OR, INDEXED(MOUSECODE_BUTTON1, 1), SEQCODE_OR, INDEXED(GUNCODE_BUTTON1, 1)) ) | |
| 100 | INPUT_PORT_DIGITAL_TYPE( 2, PLAYER2, BUTTON2, "P2 Button 2", SEQ_DEF_7(KEYCODE_S, SEQCODE_OR, INDEXED(JOYCODE_BUTTON2, 1), SEQCODE_OR, INDEXED(MOUSECODE_BUTTON3, 1), SEQCODE_OR, INDEXED(GUNCODE_BUTTON2, 1)) ) | |
| 101 | INPUT_PORT_DIGITAL_TYPE( 2, PLAYER2, BUTTON3, "P2 Button 3", SEQ_DEF_5(KEYCODE_Q, SEQCODE_OR, INDEXED(JOYCODE_BUTTON3, 1), SEQCODE_OR, INDEXED(MOUSECODE_BUTTON2, 1)) ) | |
| 102 | INPUT_PORT_DIGITAL_TYPE( 2, PLAYER2, BUTTON4, "P2 Button 4", SEQ_DEF_3(KEYCODE_W, SEQCODE_OR, INDEXED(JOYCODE_BUTTON4, 1)) ) | |
| 103 | INPUT_PORT_DIGITAL_TYPE( 2, PLAYER2, BUTTON5, "P2 Button 5", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON5, 1)) ) | |
| 104 | INPUT_PORT_DIGITAL_TYPE( 2, PLAYER2, BUTTON6, "P2 Button 6", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON6, 1)) ) | |
| 105 | INPUT_PORT_DIGITAL_TYPE( 2, PLAYER2, BUTTON7, "P2 Button 7", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON7, 1)) ) | |
| 106 | INPUT_PORT_DIGITAL_TYPE( 2, PLAYER2, BUTTON8, "P2 Button 8", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON8, 1)) ) | |
| 107 | INPUT_PORT_DIGITAL_TYPE( 2, PLAYER2, BUTTON9, "P2 Button 9", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON9, 1)) ) | |
| 108 | INPUT_PORT_DIGITAL_TYPE( 2, PLAYER2, BUTTON10, "P2 Button 10", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON10, 1)) ) | |
| 109 | INPUT_PORT_DIGITAL_TYPE( 2, PLAYER2, BUTTON11, "P2 Button 11", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON11, 1)) ) | |
| 110 | INPUT_PORT_DIGITAL_TYPE( 2, PLAYER2, BUTTON12, "P2 Button 12", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON12, 1)) ) | |
| 111 | INPUT_PORT_DIGITAL_TYPE( 2, PLAYER2, BUTTON13, "P2 Button 13", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON13, 1)) ) | |
| 112 | INPUT_PORT_DIGITAL_TYPE( 2, PLAYER2, BUTTON14, "P2 Button 14", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON14, 1)) ) | |
| 113 | INPUT_PORT_DIGITAL_TYPE( 2, PLAYER2, BUTTON15, "P2 Button 15", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON15, 1)) ) | |
| 114 | INPUT_PORT_DIGITAL_TYPE( 2, PLAYER2, BUTTON16, "P2 Button 16", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON16, 1)) ) | |
| 115 | INPUT_PORT_DIGITAL_TYPE( 2, PLAYER2, START, "P2 Start", SEQ_DEF_3(KEYCODE_2, SEQCODE_OR, INDEXED(JOYCODE_START, 1)) ) | |
| 116 | INPUT_PORT_DIGITAL_TYPE( 2, PLAYER2, SELECT, "P2 Select", SEQ_DEF_3(KEYCODE_6, SEQCODE_OR, INDEXED(JOYCODE_SELECT, 1)) ) | |
| 117 | INPUT_PORT_DIGITAL_TYPE( 2, PLAYER2, MAHJONG_A, "P2 Mahjong A", SEQ_DEF_0 ) | |
| 118 | INPUT_PORT_DIGITAL_TYPE( 2, PLAYER2, MAHJONG_B, "P2 Mahjong B", SEQ_DEF_0 ) | |
| 119 | INPUT_PORT_DIGITAL_TYPE( 2, PLAYER2, MAHJONG_C, "P2 Mahjong C", SEQ_DEF_0 ) | |
| 120 | INPUT_PORT_DIGITAL_TYPE( 2, PLAYER2, MAHJONG_D, "P2 Mahjong D", SEQ_DEF_0 ) | |
| 121 | INPUT_PORT_DIGITAL_TYPE( 2, PLAYER2, MAHJONG_E, "P2 Mahjong E", SEQ_DEF_0 ) | |
| 122 | INPUT_PORT_DIGITAL_TYPE( 2, PLAYER2, MAHJONG_F, "P2 Mahjong F", SEQ_DEF_0 ) | |
| 123 | INPUT_PORT_DIGITAL_TYPE( 2, PLAYER2, MAHJONG_G, "P2 Mahjong G", SEQ_DEF_0 ) | |
| 124 | INPUT_PORT_DIGITAL_TYPE( 2, PLAYER2, MAHJONG_H, "P2 Mahjong H", SEQ_DEF_0 ) | |
| 125 | INPUT_PORT_DIGITAL_TYPE( 2, PLAYER2, MAHJONG_I, "P2 Mahjong I", SEQ_DEF_0 ) | |
| 126 | INPUT_PORT_DIGITAL_TYPE( 2, PLAYER2, MAHJONG_J, "P2 Mahjong J", SEQ_DEF_0 ) | |
| 127 | INPUT_PORT_DIGITAL_TYPE( 2, PLAYER2, MAHJONG_K, "P2 Mahjong K", SEQ_DEF_0 ) | |
| 128 | INPUT_PORT_DIGITAL_TYPE( 2, PLAYER2, MAHJONG_L, "P2 Mahjong L", SEQ_DEF_0 ) | |
| 129 | INPUT_PORT_DIGITAL_TYPE( 2, PLAYER2, MAHJONG_M, "P2 Mahjong M", SEQ_DEF_0 ) | |
| 130 | INPUT_PORT_DIGITAL_TYPE( 2, PLAYER2, MAHJONG_N, "P2 Mahjong N", SEQ_DEF_0 ) | |
| 131 | INPUT_PORT_DIGITAL_TYPE( 2, PLAYER2, MAHJONG_O, "P2 Mahjong O", SEQ_DEF_0 ) | |
| 132 | INPUT_PORT_DIGITAL_TYPE( 2, PLAYER2, MAHJONG_P, "P2 Mahjong P", SEQ_DEF_0 ) | |
| 133 | INPUT_PORT_DIGITAL_TYPE( 2, PLAYER2, MAHJONG_Q, "P2 Mahjong Q", SEQ_DEF_0 ) | |
| 134 | INPUT_PORT_DIGITAL_TYPE( 2, PLAYER2, MAHJONG_KAN, "P2 Mahjong Kan", SEQ_DEF_0 ) | |
| 135 | INPUT_PORT_DIGITAL_TYPE( 2, PLAYER2, MAHJONG_PON, "P2 Mahjong Pon", SEQ_DEF_0 ) | |
| 136 | INPUT_PORT_DIGITAL_TYPE( 2, PLAYER2, MAHJONG_CHI, "P2 Mahjong Chi", SEQ_DEF_0 ) | |
| 137 | INPUT_PORT_DIGITAL_TYPE( 2, PLAYER2, MAHJONG_REACH, "P2 Mahjong Reach", SEQ_DEF_0 ) | |
| 138 | INPUT_PORT_DIGITAL_TYPE( 2, PLAYER2, MAHJONG_RON, "P2 Mahjong Ron", SEQ_DEF_0 ) | |
| 139 | INPUT_PORT_DIGITAL_TYPE( 2, PLAYER2, MAHJONG_BET, "P2 Mahjong Bet", SEQ_DEF_0 ) | |
| 140 | INPUT_PORT_DIGITAL_TYPE( 2, PLAYER2, MAHJONG_LAST_CHANCE, "P2 Mahjong Last Chance", SEQ_DEF_0 ) | |
| 141 | INPUT_PORT_DIGITAL_TYPE( 2, PLAYER2, MAHJONG_SCORE, "P2 Mahjong Score", SEQ_DEF_0 ) | |
| 142 | INPUT_PORT_DIGITAL_TYPE( 2, PLAYER2, MAHJONG_DOUBLE_UP, "P2 Mahjong Double Up", SEQ_DEF_0 ) | |
| 143 | INPUT_PORT_DIGITAL_TYPE( 2, PLAYER2, MAHJONG_FLIP_FLOP, "P2 Mahjong Flip Flop", SEQ_DEF_0 ) | |
| 144 | INPUT_PORT_DIGITAL_TYPE( 2, PLAYER2, MAHJONG_BIG, "P2 Mahjong Big", SEQ_DEF_0 ) | |
| 145 | INPUT_PORT_DIGITAL_TYPE( 2, PLAYER2, MAHJONG_SMALL, "P2 Mahjong Small", SEQ_DEF_0 ) | |
| 146 | ||
| 147 | INPUT_PORT_DIGITAL_TYPE( 3, PLAYER3, JOYSTICK_UP, "P3 Up", SEQ_DEF_3(KEYCODE_I, SEQCODE_OR, INDEXED(JOYCODE_Y_UP_SWITCH, 2)) ) | |
| 148 | INPUT_PORT_DIGITAL_TYPE( 3, PLAYER3, JOYSTICK_DOWN, "P3 Down", SEQ_DEF_3(KEYCODE_K, SEQCODE_OR, INDEXED(JOYCODE_Y_DOWN_SWITCH, 2)) ) | |
| 149 | INPUT_PORT_DIGITAL_TYPE( 3, PLAYER3, JOYSTICK_LEFT, "P3 Left", SEQ_DEF_3(KEYCODE_J, SEQCODE_OR, INDEXED(JOYCODE_X_LEFT_SWITCH, 2)) ) | |
| 150 | INPUT_PORT_DIGITAL_TYPE( 3, PLAYER3, JOYSTICK_RIGHT, "P3 Right", SEQ_DEF_3(KEYCODE_L, SEQCODE_OR, INDEXED(JOYCODE_X_RIGHT_SWITCH, 2)) ) | |
| 151 | INPUT_PORT_DIGITAL_TYPE( 3, PLAYER3, JOYSTICKRIGHT_UP, "P3 Right/Up", SEQ_DEF_0 ) | |
| 152 | INPUT_PORT_DIGITAL_TYPE( 3, PLAYER3, JOYSTICKRIGHT_DOWN, "P3 Right/Down", SEQ_DEF_0 ) | |
| 153 | INPUT_PORT_DIGITAL_TYPE( 3, PLAYER3, JOYSTICKRIGHT_LEFT, "P3 Right/Left", SEQ_DEF_0 ) | |
| 154 | INPUT_PORT_DIGITAL_TYPE( 3, PLAYER3, JOYSTICKRIGHT_RIGHT, "P3 Right/Right", SEQ_DEF_0 ) | |
| 155 | INPUT_PORT_DIGITAL_TYPE( 3, PLAYER3, JOYSTICKLEFT_UP, "P3 Left/Up", SEQ_DEF_0 ) | |
| 156 | INPUT_PORT_DIGITAL_TYPE( 3, PLAYER3, JOYSTICKLEFT_DOWN, "P3 Left/Down", SEQ_DEF_0 ) | |
| 157 | INPUT_PORT_DIGITAL_TYPE( 3, PLAYER3, JOYSTICKLEFT_LEFT, "P3 Left/Left", SEQ_DEF_0 ) | |
| 158 | INPUT_PORT_DIGITAL_TYPE( 3, PLAYER3, JOYSTICKLEFT_RIGHT, "P3 Left/Right", SEQ_DEF_0 ) | |
| 159 | INPUT_PORT_DIGITAL_TYPE( 3, PLAYER3, BUTTON1, "P3 Button 1", SEQ_DEF_5(KEYCODE_RCONTROL, SEQCODE_OR, INDEXED(JOYCODE_BUTTON1, 2), SEQCODE_OR, INDEXED(GUNCODE_BUTTON1, 2)) ) | |
| 160 | INPUT_PORT_DIGITAL_TYPE( 3, PLAYER3, BUTTON2, "P3 Button 2", SEQ_DEF_5(KEYCODE_RSHIFT, SEQCODE_OR, INDEXED(JOYCODE_BUTTON2, 2), SEQCODE_OR, INDEXED(GUNCODE_BUTTON2, 2)) ) | |
| 161 | INPUT_PORT_DIGITAL_TYPE( 3, PLAYER3, BUTTON3, "P3 Button 3", SEQ_DEF_3(KEYCODE_ENTER, SEQCODE_OR, INDEXED(JOYCODE_BUTTON3, 2)) ) | |
| 162 | INPUT_PORT_DIGITAL_TYPE( 3, PLAYER3, BUTTON4, "P3 Button 4", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON4, 2)) ) | |
| 163 | INPUT_PORT_DIGITAL_TYPE( 3, PLAYER3, BUTTON5, "P3 Button 5", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON5, 2)) ) | |
| 164 | INPUT_PORT_DIGITAL_TYPE( 3, PLAYER3, BUTTON6, "P3 Button 6", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON6, 2)) ) | |
| 165 | INPUT_PORT_DIGITAL_TYPE( 3, PLAYER3, BUTTON7, "P3 Button 7", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON7, 2)) ) | |
| 166 | INPUT_PORT_DIGITAL_TYPE( 3, PLAYER3, BUTTON8, "P3 Button 8", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON8, 2)) ) | |
| 167 | INPUT_PORT_DIGITAL_TYPE( 3, PLAYER3, BUTTON9, "P3 Button 9", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON9, 2)) ) | |
| 168 | INPUT_PORT_DIGITAL_TYPE( 3, PLAYER3, BUTTON10, "P3 Button 10", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON10, 2)) ) | |
| 169 | INPUT_PORT_DIGITAL_TYPE( 3, PLAYER3, BUTTON11, "P3 Button 11", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON11, 2)) ) | |
| 170 | INPUT_PORT_DIGITAL_TYPE( 3, PLAYER3, BUTTON12, "P3 Button 12", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON12, 2)) ) | |
| 171 | INPUT_PORT_DIGITAL_TYPE( 3, PLAYER3, BUTTON13, "P3 Button 13", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON13, 2)) ) | |
| 172 | INPUT_PORT_DIGITAL_TYPE( 3, PLAYER3, BUTTON14, "P3 Button 14", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON14, 2)) ) | |
| 173 | INPUT_PORT_DIGITAL_TYPE( 3, PLAYER3, BUTTON15, "P3 Button 15", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON15, 2)) ) | |
| 174 | INPUT_PORT_DIGITAL_TYPE( 3, PLAYER3, BUTTON16, "P3 Button 16", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON16, 2)) ) | |
| 175 | INPUT_PORT_DIGITAL_TYPE( 3, PLAYER3, START, "P3 Start", SEQ_DEF_3(KEYCODE_3, SEQCODE_OR, INDEXED(JOYCODE_START, 2)) ) | |
| 176 | INPUT_PORT_DIGITAL_TYPE( 3, PLAYER3, SELECT, "P3 Select", SEQ_DEF_3(KEYCODE_7, SEQCODE_OR, INDEXED(JOYCODE_SELECT, 2)) ) | |
| 177 | ||
| 178 | INPUT_PORT_DIGITAL_TYPE( 4, PLAYER4, JOYSTICK_UP, "P4 Up", SEQ_DEF_3(KEYCODE_8_PAD, SEQCODE_OR, INDEXED(JOYCODE_Y_UP_SWITCH, 3)) ) | |
| 179 | INPUT_PORT_DIGITAL_TYPE( 4, PLAYER4, JOYSTICK_DOWN, "P4 Down", SEQ_DEF_3(KEYCODE_2_PAD, SEQCODE_OR, INDEXED(JOYCODE_Y_DOWN_SWITCH, 3)) ) | |
| 180 | INPUT_PORT_DIGITAL_TYPE( 4, PLAYER4, JOYSTICK_LEFT, "P4 Left", SEQ_DEF_3(KEYCODE_4_PAD, SEQCODE_OR, INDEXED(JOYCODE_X_LEFT_SWITCH, 3)) ) | |
| 181 | INPUT_PORT_DIGITAL_TYPE( 4, PLAYER4, JOYSTICK_RIGHT, "P4 Right", SEQ_DEF_3(KEYCODE_6_PAD, SEQCODE_OR, INDEXED(JOYCODE_X_RIGHT_SWITCH, 3)) ) | |
| 182 | INPUT_PORT_DIGITAL_TYPE( 4, PLAYER4, JOYSTICKRIGHT_UP, "P4 Right/Up", SEQ_DEF_0 ) | |
| 183 | INPUT_PORT_DIGITAL_TYPE( 4, PLAYER4, JOYSTICKRIGHT_DOWN, "P4 Right/Down", SEQ_DEF_0 ) | |
| 184 | INPUT_PORT_DIGITAL_TYPE( 4, PLAYER4, JOYSTICKRIGHT_LEFT, "P4 Right/Left", SEQ_DEF_0 ) | |
| 185 | INPUT_PORT_DIGITAL_TYPE( 4, PLAYER4, JOYSTICKRIGHT_RIGHT, "P4 Right/Right", SEQ_DEF_0 ) | |
| 186 | INPUT_PORT_DIGITAL_TYPE( 4, PLAYER4, JOYSTICKLEFT_UP, "P4 Left/Up", SEQ_DEF_0 ) | |
| 187 | INPUT_PORT_DIGITAL_TYPE( 4, PLAYER4, JOYSTICKLEFT_DOWN, "P4 Left/Down", SEQ_DEF_0 ) | |
| 188 | INPUT_PORT_DIGITAL_TYPE( 4, PLAYER4, JOYSTICKLEFT_LEFT, "P4 Left/Left", SEQ_DEF_0 ) | |
| 189 | INPUT_PORT_DIGITAL_TYPE( 4, PLAYER4, JOYSTICKLEFT_RIGHT, "P4 Left/Right", SEQ_DEF_0 ) | |
| 190 | INPUT_PORT_DIGITAL_TYPE( 4, PLAYER4, BUTTON1, "P4 Button 1", SEQ_DEF_3(KEYCODE_0_PAD, SEQCODE_OR, INDEXED(JOYCODE_BUTTON1, 3)) ) | |
| 191 | INPUT_PORT_DIGITAL_TYPE( 4, PLAYER4, BUTTON2, "P4 Button 2", SEQ_DEF_3(KEYCODE_DEL_PAD, SEQCODE_OR, INDEXED(JOYCODE_BUTTON2, 3)) ) | |
| 192 | INPUT_PORT_DIGITAL_TYPE( 4, PLAYER4, BUTTON3, "P4 Button 3", SEQ_DEF_3(KEYCODE_ENTER_PAD, SEQCODE_OR, INDEXED(JOYCODE_BUTTON3, 3)) ) | |
| 193 | INPUT_PORT_DIGITAL_TYPE( 4, PLAYER4, BUTTON4, "P4 Button 4", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON4, 3)) ) | |
| 194 | INPUT_PORT_DIGITAL_TYPE( 4, PLAYER4, BUTTON5, "P4 Button 5", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON5, 3)) ) | |
| 195 | INPUT_PORT_DIGITAL_TYPE( 4, PLAYER4, BUTTON6, "P4 Button 6", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON6, 3)) ) | |
| 196 | INPUT_PORT_DIGITAL_TYPE( 4, PLAYER4, BUTTON7, "P4 Button 7", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON7, 3)) ) | |
| 197 | INPUT_PORT_DIGITAL_TYPE( 4, PLAYER4, BUTTON8, "P4 Button 8", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON8, 3)) ) | |
| 198 | INPUT_PORT_DIGITAL_TYPE( 4, PLAYER4, BUTTON9, "P4 Button 9", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON9, 3)) ) | |
| 199 | INPUT_PORT_DIGITAL_TYPE( 4, PLAYER4, BUTTON10, "P4 Button 10", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON10, 3)) ) | |
| 200 | INPUT_PORT_DIGITAL_TYPE( 4, PLAYER4, BUTTON11, "P4 Button 11", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON11, 3)) ) | |
| 201 | INPUT_PORT_DIGITAL_TYPE( 4, PLAYER4, BUTTON12, "P4 Button 12", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON12, 3)) ) | |
| 202 | INPUT_PORT_DIGITAL_TYPE( 4, PLAYER4, BUTTON13, "P4 Button 13", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON13, 3)) ) | |
| 203 | INPUT_PORT_DIGITAL_TYPE( 4, PLAYER4, BUTTON14, "P4 Button 14", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON14, 3)) ) | |
| 204 | INPUT_PORT_DIGITAL_TYPE( 4, PLAYER4, BUTTON15, "P4 Button 15", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON15, 3)) ) | |
| 205 | INPUT_PORT_DIGITAL_TYPE( 4, PLAYER4, BUTTON16, "P4 Button 16", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON16, 3)) ) | |
| 206 | INPUT_PORT_DIGITAL_TYPE( 4, PLAYER4, START, "P4 Start", SEQ_DEF_3(KEYCODE_4, SEQCODE_OR, INDEXED(JOYCODE_START, 3)) ) | |
| 207 | INPUT_PORT_DIGITAL_TYPE( 4, PLAYER4, SELECT, "P4 Select", SEQ_DEF_3(KEYCODE_8, SEQCODE_OR, INDEXED(JOYCODE_SELECT, 3)) ) | |
| 208 | ||
| 209 | INPUT_PORT_DIGITAL_TYPE( 5, PLAYER5, JOYSTICK_UP, "P5 Up", SEQ_DEF_1(INDEXED(JOYCODE_Y_UP_SWITCH, 4)) ) | |
| 210 | INPUT_PORT_DIGITAL_TYPE( 5, PLAYER5, JOYSTICK_DOWN, "P5 Down", SEQ_DEF_1(INDEXED(JOYCODE_Y_DOWN_SWITCH, 4)) ) | |
| 211 | INPUT_PORT_DIGITAL_TYPE( 5, PLAYER5, JOYSTICK_LEFT, "P5 Left", SEQ_DEF_1(INDEXED(JOYCODE_X_LEFT_SWITCH, 4)) ) | |
| 212 | INPUT_PORT_DIGITAL_TYPE( 5, PLAYER5, JOYSTICK_RIGHT, "P5 Right", SEQ_DEF_1(INDEXED(JOYCODE_X_RIGHT_SWITCH, 4)) ) | |
| 213 | INPUT_PORT_DIGITAL_TYPE( 5, PLAYER5, JOYSTICKRIGHT_UP, "P5 Right/Up", SEQ_DEF_0 ) | |
| 214 | INPUT_PORT_DIGITAL_TYPE( 5, PLAYER5, JOYSTICKRIGHT_DOWN, "P5 Right/Down", SEQ_DEF_0 ) | |
| 215 | INPUT_PORT_DIGITAL_TYPE( 5, PLAYER5, JOYSTICKRIGHT_LEFT, "P5 Right/Left", SEQ_DEF_0 ) | |
| 216 | INPUT_PORT_DIGITAL_TYPE( 5, PLAYER5, JOYSTICKRIGHT_RIGHT, "P5 Right/Right", SEQ_DEF_0 ) | |
| 217 | INPUT_PORT_DIGITAL_TYPE( 5, PLAYER5, JOYSTICKLEFT_UP, "P5 Left/Up", SEQ_DEF_0 ) | |
| 218 | INPUT_PORT_DIGITAL_TYPE( 5, PLAYER5, JOYSTICKLEFT_DOWN, "P5 Left/Down", SEQ_DEF_0 ) | |
| 219 | INPUT_PORT_DIGITAL_TYPE( 5, PLAYER5, JOYSTICKLEFT_LEFT, "P5 Left/Left", SEQ_DEF_0 ) | |
| 220 | INPUT_PORT_DIGITAL_TYPE( 5, PLAYER5, JOYSTICKLEFT_RIGHT, "P5 Left/Right", SEQ_DEF_0 ) | |
| 221 | INPUT_PORT_DIGITAL_TYPE( 5, PLAYER5, BUTTON1, "P5 Button 1", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON1, 4)) ) | |
| 222 | INPUT_PORT_DIGITAL_TYPE( 5, PLAYER5, BUTTON2, "P5 Button 2", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON2, 4)) ) | |
| 223 | INPUT_PORT_DIGITAL_TYPE( 5, PLAYER5, BUTTON3, "P5 Button 3", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON3, 4)) ) | |
| 224 | INPUT_PORT_DIGITAL_TYPE( 5, PLAYER5, BUTTON4, "P5 Button 4", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON4, 4)) ) | |
| 225 | INPUT_PORT_DIGITAL_TYPE( 5, PLAYER5, BUTTON5, "P5 Button 5", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON5, 4)) ) | |
| 226 | INPUT_PORT_DIGITAL_TYPE( 5, PLAYER5, BUTTON6, "P5 Button 6", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON6, 4)) ) | |
| 227 | INPUT_PORT_DIGITAL_TYPE( 5, PLAYER5, BUTTON7, "P5 Button 7", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON7, 4)) ) | |
| 228 | INPUT_PORT_DIGITAL_TYPE( 5, PLAYER5, BUTTON8, "P5 Button 8", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON8, 4)) ) | |
| 229 | INPUT_PORT_DIGITAL_TYPE( 5, PLAYER5, BUTTON9, "P5 Button 9", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON9, 4)) ) | |
| 230 | INPUT_PORT_DIGITAL_TYPE( 5, PLAYER5, BUTTON10, "P5 Button 10", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON10, 4)) ) | |
| 231 | INPUT_PORT_DIGITAL_TYPE( 5, PLAYER5, BUTTON11, "P5 Button 11", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON11, 4)) ) | |
| 232 | INPUT_PORT_DIGITAL_TYPE( 5, PLAYER5, BUTTON12, "P5 Button 12", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON12, 4)) ) | |
| 233 | INPUT_PORT_DIGITAL_TYPE( 5, PLAYER5, BUTTON13, "P5 Button 13", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON13, 4)) ) | |
| 234 | INPUT_PORT_DIGITAL_TYPE( 5, PLAYER5, BUTTON14, "P5 Button 14", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON14, 4)) ) | |
| 235 | INPUT_PORT_DIGITAL_TYPE( 5, PLAYER5, BUTTON15, "P5 Button 15", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON15, 4)) ) | |
| 236 | INPUT_PORT_DIGITAL_TYPE( 5, PLAYER5, BUTTON16, "P5 Button 16", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON16, 4)) ) | |
| 237 | INPUT_PORT_DIGITAL_TYPE( 5, PLAYER5, START, "P5 Start", SEQ_DEF_0 ) | |
| 238 | INPUT_PORT_DIGITAL_TYPE( 5, PLAYER5, SELECT, "P5 Select", SEQ_DEF_0 ) | |
| 239 | ||
| 240 | INPUT_PORT_DIGITAL_TYPE( 6, PLAYER6, JOYSTICK_UP, "P6 Up", SEQ_DEF_1(INDEXED(JOYCODE_Y_UP_SWITCH, 5)) ) | |
| 241 | INPUT_PORT_DIGITAL_TYPE( 6, PLAYER6, JOYSTICK_DOWN, "P6 Down", SEQ_DEF_1(INDEXED(JOYCODE_Y_DOWN_SWITCH, 5)) ) | |
| 242 | INPUT_PORT_DIGITAL_TYPE( 6, PLAYER6, JOYSTICK_LEFT, "P6 Left", SEQ_DEF_1(INDEXED(JOYCODE_X_LEFT_SWITCH, 5)) ) | |
| 243 | INPUT_PORT_DIGITAL_TYPE( 6, PLAYER6, JOYSTICK_RIGHT, "P6 Right", SEQ_DEF_1(INDEXED(JOYCODE_X_RIGHT_SWITCH, 5)) ) | |
| 244 | INPUT_PORT_DIGITAL_TYPE( 6, PLAYER6, JOYSTICKRIGHT_UP, "P6 Right/Up", SEQ_DEF_0 ) | |
| 245 | INPUT_PORT_DIGITAL_TYPE( 6, PLAYER6, JOYSTICKRIGHT_DOWN, "P6 Right/Down", SEQ_DEF_0 ) | |
| 246 | INPUT_PORT_DIGITAL_TYPE( 6, PLAYER6, JOYSTICKRIGHT_LEFT, "P6 Right/Left", SEQ_DEF_0 ) | |
| 247 | INPUT_PORT_DIGITAL_TYPE( 6, PLAYER6, JOYSTICKRIGHT_RIGHT, "P6 Right/Right", SEQ_DEF_0 ) | |
| 248 | INPUT_PORT_DIGITAL_TYPE( 6, PLAYER6, JOYSTICKLEFT_UP, "P6 Left/Up", SEQ_DEF_0 ) | |
| 249 | INPUT_PORT_DIGITAL_TYPE( 6, PLAYER6, JOYSTICKLEFT_DOWN, "P6 Left/Down", SEQ_DEF_0 ) | |
| 250 | INPUT_PORT_DIGITAL_TYPE( 6, PLAYER6, JOYSTICKLEFT_LEFT, "P6 Left/Left", SEQ_DEF_0 ) | |
| 251 | INPUT_PORT_DIGITAL_TYPE( 6, PLAYER6, JOYSTICKLEFT_RIGHT, "P6 Left/Right", SEQ_DEF_0 ) | |
| 252 | INPUT_PORT_DIGITAL_TYPE( 6, PLAYER6, BUTTON1, "P6 Button 1", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON1, 5)) ) | |
| 253 | INPUT_PORT_DIGITAL_TYPE( 6, PLAYER6, BUTTON2, "P6 Button 2", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON2, 5)) ) | |
| 254 | INPUT_PORT_DIGITAL_TYPE( 6, PLAYER6, BUTTON3, "P6 Button 3", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON3, 5)) ) | |
| 255 | INPUT_PORT_DIGITAL_TYPE( 6, PLAYER6, BUTTON4, "P6 Button 4", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON4, 5)) ) | |
| 256 | INPUT_PORT_DIGITAL_TYPE( 6, PLAYER6, BUTTON5, "P6 Button 5", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON5, 5)) ) | |
| 257 | INPUT_PORT_DIGITAL_TYPE( 6, PLAYER6, BUTTON6, "P6 Button 6", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON6, 5)) ) | |
| 258 | INPUT_PORT_DIGITAL_TYPE( 6, PLAYER6, BUTTON7, "P6 Button 7", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON7, 5)) ) | |
| 259 | INPUT_PORT_DIGITAL_TYPE( 6, PLAYER6, BUTTON8, "P6 Button 8", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON8, 5)) ) | |
| 260 | INPUT_PORT_DIGITAL_TYPE( 6, PLAYER6, BUTTON9, "P6 Button 9", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON9, 5)) ) | |
| 261 | INPUT_PORT_DIGITAL_TYPE( 6, PLAYER6, BUTTON10, "P6 Button 10", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON10, 5)) ) | |
| 262 | INPUT_PORT_DIGITAL_TYPE( 6, PLAYER6, BUTTON11, "P6 Button 11", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON11, 5)) ) | |
| 263 | INPUT_PORT_DIGITAL_TYPE( 6, PLAYER6, BUTTON12, "P6 Button 12", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON12, 5)) ) | |
| 264 | INPUT_PORT_DIGITAL_TYPE( 6, PLAYER6, BUTTON13, "P6 Button 13", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON13, 5)) ) | |
| 265 | INPUT_PORT_DIGITAL_TYPE( 6, PLAYER6, BUTTON14, "P6 Button 14", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON14, 5)) ) | |
| 266 | INPUT_PORT_DIGITAL_TYPE( 6, PLAYER6, BUTTON15, "P6 Button 15", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON15, 5)) ) | |
| 267 | INPUT_PORT_DIGITAL_TYPE( 6, PLAYER6, BUTTON16, "P6 Button 16", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON16, 5)) ) | |
| 268 | INPUT_PORT_DIGITAL_TYPE( 6, PLAYER6, START, "P6 Start", SEQ_DEF_0 ) | |
| 269 | INPUT_PORT_DIGITAL_TYPE( 6, PLAYER6, SELECT, "P6 Select", SEQ_DEF_0 ) | |
| 270 | ||
| 271 | INPUT_PORT_DIGITAL_TYPE( 7, PLAYER7, JOYSTICK_UP, "P7 Up", SEQ_DEF_1(INDEXED(JOYCODE_Y_UP_SWITCH, 6)) ) | |
| 272 | INPUT_PORT_DIGITAL_TYPE( 7, PLAYER7, JOYSTICK_DOWN, "P7 Down", SEQ_DEF_1(INDEXED(JOYCODE_Y_DOWN_SWITCH, 6)) ) | |
| 273 | INPUT_PORT_DIGITAL_TYPE( 7, PLAYER7, JOYSTICK_LEFT, "P7 Left", SEQ_DEF_1(INDEXED(JOYCODE_X_LEFT_SWITCH, 6)) ) | |
| 274 | INPUT_PORT_DIGITAL_TYPE( 7, PLAYER7, JOYSTICK_RIGHT, "P7 Right", SEQ_DEF_1(INDEXED(JOYCODE_X_RIGHT_SWITCH, 6)) ) | |
| 275 | INPUT_PORT_DIGITAL_TYPE( 7, PLAYER7, JOYSTICKRIGHT_UP, "P7 Right/Up", SEQ_DEF_0 ) | |
| 276 | INPUT_PORT_DIGITAL_TYPE( 7, PLAYER7, JOYSTICKRIGHT_DOWN, "P7 Right/Down", SEQ_DEF_0 ) | |
| 277 | INPUT_PORT_DIGITAL_TYPE( 7, PLAYER7, JOYSTICKRIGHT_LEFT, "P7 Right/Left", SEQ_DEF_0 ) | |
| 278 | INPUT_PORT_DIGITAL_TYPE( 7, PLAYER7, JOYSTICKRIGHT_RIGHT, "P7 Right/Right", SEQ_DEF_0 ) | |
| 279 | INPUT_PORT_DIGITAL_TYPE( 7, PLAYER7, JOYSTICKLEFT_UP, "P7 Left/Up", SEQ_DEF_0 ) | |
| 280 | INPUT_PORT_DIGITAL_TYPE( 7, PLAYER7, JOYSTICKLEFT_DOWN, "P7 Left/Down", SEQ_DEF_0 ) | |
| 281 | INPUT_PORT_DIGITAL_TYPE( 7, PLAYER7, JOYSTICKLEFT_LEFT, "P7 Left/Left", SEQ_DEF_0 ) | |
| 282 | INPUT_PORT_DIGITAL_TYPE( 7, PLAYER7, JOYSTICKLEFT_RIGHT, "P7 Left/Right", SEQ_DEF_0 ) | |
| 283 | INPUT_PORT_DIGITAL_TYPE( 7, PLAYER7, BUTTON1, "P7 Button 1", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON1, 6)) ) | |
| 284 | INPUT_PORT_DIGITAL_TYPE( 7, PLAYER7, BUTTON2, "P7 Button 2", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON2, 6)) ) | |
| 285 | INPUT_PORT_DIGITAL_TYPE( 7, PLAYER7, BUTTON3, "P7 Button 3", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON3, 6)) ) | |
| 286 | INPUT_PORT_DIGITAL_TYPE( 7, PLAYER7, BUTTON4, "P7 Button 4", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON4, 6)) ) | |
| 287 | INPUT_PORT_DIGITAL_TYPE( 7, PLAYER7, BUTTON5, "P7 Button 5", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON5, 6)) ) | |
| 288 | INPUT_PORT_DIGITAL_TYPE( 7, PLAYER7, BUTTON6, "P7 Button 6", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON6, 6)) ) | |
| 289 | INPUT_PORT_DIGITAL_TYPE( 7, PLAYER7, BUTTON7, "P7 Button 7", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON7, 6)) ) | |
| 290 | INPUT_PORT_DIGITAL_TYPE( 7, PLAYER7, BUTTON8, "P7 Button 8", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON8, 6)) ) | |
| 291 | INPUT_PORT_DIGITAL_TYPE( 7, PLAYER7, BUTTON9, "P7 Button 9", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON9, 6)) ) | |
| 292 | INPUT_PORT_DIGITAL_TYPE( 7, PLAYER7, BUTTON10, "P7 Button 10", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON10, 6)) ) | |
| 293 | INPUT_PORT_DIGITAL_TYPE( 7, PLAYER7, BUTTON11, "P7 Button 11", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON11, 6)) ) | |
| 294 | INPUT_PORT_DIGITAL_TYPE( 7, PLAYER7, BUTTON12, "P7 Button 12", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON12, 6)) ) | |
| 295 | INPUT_PORT_DIGITAL_TYPE( 7, PLAYER7, BUTTON13, "P7 Button 13", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON13, 6)) ) | |
| 296 | INPUT_PORT_DIGITAL_TYPE( 7, PLAYER7, BUTTON14, "P7 Button 14", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON14, 6)) ) | |
| 297 | INPUT_PORT_DIGITAL_TYPE( 7, PLAYER7, BUTTON15, "P7 Button 15", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON15, 6)) ) | |
| 298 | INPUT_PORT_DIGITAL_TYPE( 7, PLAYER7, BUTTON16, "P7 Button 16", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON16, 6)) ) | |
| 299 | INPUT_PORT_DIGITAL_TYPE( 7, PLAYER7, START, "P7 Start", SEQ_DEF_0 ) | |
| 300 | INPUT_PORT_DIGITAL_TYPE( 7, PLAYER7, SELECT, "P7 Select", SEQ_DEF_0 ) | |
| 301 | ||
| 302 | INPUT_PORT_DIGITAL_TYPE( 8, PLAYER8, JOYSTICK_UP, "P8 Up", SEQ_DEF_1(INDEXED(JOYCODE_Y_UP_SWITCH, 7)) ) | |
| 303 | INPUT_PORT_DIGITAL_TYPE( 8, PLAYER8, JOYSTICK_DOWN, "P8 Down", SEQ_DEF_1(INDEXED(JOYCODE_Y_DOWN_SWITCH, 7)) ) | |
| 304 | INPUT_PORT_DIGITAL_TYPE( 8, PLAYER8, JOYSTICK_LEFT, "P8 Left", SEQ_DEF_1(INDEXED(JOYCODE_X_LEFT_SWITCH, 7)) ) | |
| 305 | INPUT_PORT_DIGITAL_TYPE( 8, PLAYER8, JOYSTICK_RIGHT, "P8 Right", SEQ_DEF_1(INDEXED(JOYCODE_X_RIGHT_SWITCH, 7)) ) | |
| 306 | INPUT_PORT_DIGITAL_TYPE( 8, PLAYER8, JOYSTICKRIGHT_UP, "P8 Right/Up", SEQ_DEF_0 ) | |
| 307 | INPUT_PORT_DIGITAL_TYPE( 8, PLAYER8, JOYSTICKRIGHT_DOWN, "P8 Right/Down", SEQ_DEF_0 ) | |
| 308 | INPUT_PORT_DIGITAL_TYPE( 8, PLAYER8, JOYSTICKRIGHT_LEFT, "P8 Right/Left", SEQ_DEF_0 ) | |
| 309 | INPUT_PORT_DIGITAL_TYPE( 8, PLAYER8, JOYSTICKRIGHT_RIGHT, "P8 Right/Right", SEQ_DEF_0 ) | |
| 310 | INPUT_PORT_DIGITAL_TYPE( 8, PLAYER8, JOYSTICKLEFT_UP, "P8 Left/Up", SEQ_DEF_0 ) | |
| 311 | INPUT_PORT_DIGITAL_TYPE( 8, PLAYER8, JOYSTICKLEFT_DOWN, "P8 Left/Down", SEQ_DEF_0 ) | |
| 312 | INPUT_PORT_DIGITAL_TYPE( 8, PLAYER8, JOYSTICKLEFT_LEFT, "P8 Left/Left", SEQ_DEF_0 ) | |
| 313 | INPUT_PORT_DIGITAL_TYPE( 8, PLAYER8, JOYSTICKLEFT_RIGHT, "P8 Left/Right", SEQ_DEF_0 ) | |
| 314 | INPUT_PORT_DIGITAL_TYPE( 8, PLAYER8, BUTTON1, "P8 Button 1", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON1, 7)) ) | |
| 315 | INPUT_PORT_DIGITAL_TYPE( 8, PLAYER8, BUTTON2, "P8 Button 2", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON2, 7)) ) | |
| 316 | INPUT_PORT_DIGITAL_TYPE( 8, PLAYER8, BUTTON3, "P8 Button 3", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON3, 7)) ) | |
| 317 | INPUT_PORT_DIGITAL_TYPE( 8, PLAYER8, BUTTON4, "P8 Button 4", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON4, 7)) ) | |
| 318 | INPUT_PORT_DIGITAL_TYPE( 8, PLAYER8, BUTTON5, "P8 Button 5", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON5, 7)) ) | |
| 319 | INPUT_PORT_DIGITAL_TYPE( 8, PLAYER8, BUTTON6, "P8 Button 6", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON6, 7)) ) | |
| 320 | INPUT_PORT_DIGITAL_TYPE( 8, PLAYER8, BUTTON7, "P8 Button 7", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON7, 7)) ) | |
| 321 | INPUT_PORT_DIGITAL_TYPE( 8, PLAYER8, BUTTON8, "P8 Button 8", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON8, 7)) ) | |
| 322 | INPUT_PORT_DIGITAL_TYPE( 8, PLAYER8, BUTTON9, "P8 Button 9", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON9, 7)) ) | |
| 323 | INPUT_PORT_DIGITAL_TYPE( 8, PLAYER8, BUTTON10, "P8 Button 10", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON10, 7)) ) | |
| 324 | INPUT_PORT_DIGITAL_TYPE( 8, PLAYER8, BUTTON11, "P8 Button 11", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON11, 7)) ) | |
| 325 | INPUT_PORT_DIGITAL_TYPE( 8, PLAYER8, BUTTON12, "P8 Button 12", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON12, 7)) ) | |
| 326 | INPUT_PORT_DIGITAL_TYPE( 8, PLAYER8, BUTTON13, "P8 Button 13", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON13, 7)) ) | |
| 327 | INPUT_PORT_DIGITAL_TYPE( 8, PLAYER8, BUTTON14, "P8 Button 14", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON14, 7)) ) | |
| 328 | INPUT_PORT_DIGITAL_TYPE( 8, PLAYER8, BUTTON15, "P8 Button 15", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON15, 7)) ) | |
| 329 | INPUT_PORT_DIGITAL_TYPE( 8, PLAYER8, BUTTON16, "P8 Button 16", SEQ_DEF_1(INDEXED(JOYCODE_BUTTON16, 7)) ) | |
| 330 | INPUT_PORT_DIGITAL_TYPE( 8, PLAYER8, START, "P8 Start", SEQ_DEF_0 ) | |
| 331 | INPUT_PORT_DIGITAL_TYPE( 8, PLAYER8, SELECT, "P8 Select", SEQ_DEF_0 ) | |
| 332 | ||
| 333 | INPUT_PORT_DIGITAL_TYPE( 0, OTHER, START1, "1 Player Start", SEQ_DEF_3(KEYCODE_1, SEQCODE_OR, INDEXED(JOYCODE_START, 0)) ) | |
| 334 | INPUT_PORT_DIGITAL_TYPE( 0, OTHER, START2, "2 Players Start", SEQ_DEF_3(KEYCODE_2, SEQCODE_OR, INDEXED(JOYCODE_START, 1)) ) | |
| 335 | INPUT_PORT_DIGITAL_TYPE( 0, OTHER, START3, "3 Players Start", SEQ_DEF_3(KEYCODE_3, SEQCODE_OR, INDEXED(JOYCODE_START, 2)) ) | |
| 336 | INPUT_PORT_DIGITAL_TYPE( 0, OTHER, START4, "4 Players Start", SEQ_DEF_3(KEYCODE_4, SEQCODE_OR, INDEXED(JOYCODE_START, 3)) ) | |
| 337 | INPUT_PORT_DIGITAL_TYPE( 0, OTHER, START5, "5 Players Start", SEQ_DEF_0 ) | |
| 338 | INPUT_PORT_DIGITAL_TYPE( 0, OTHER, START6, "6 Players Start", SEQ_DEF_0 ) | |
| 339 | INPUT_PORT_DIGITAL_TYPE( 0, OTHER, START7, "7 Players Start", SEQ_DEF_0 ) | |
| 340 | INPUT_PORT_DIGITAL_TYPE( 0, OTHER, START8, "8 Players Start", SEQ_DEF_0 ) | |
| 341 | ||
| 342 | INPUT_PORT_DIGITAL_TYPE( 0, OTHER, COIN1, "Coin 1", SEQ_DEF_3(KEYCODE_5, SEQCODE_OR, INDEXED(JOYCODE_SELECT, 0)) ) | |
| 343 | INPUT_PORT_DIGITAL_TYPE( 0, OTHER, COIN2, "Coin 2", SEQ_DEF_3(KEYCODE_6, SEQCODE_OR, INDEXED(JOYCODE_SELECT, 1)) ) | |
| 344 | INPUT_PORT_DIGITAL_TYPE( 0, OTHER, COIN3, "Coin 3", SEQ_DEF_3(KEYCODE_7, SEQCODE_OR, INDEXED(JOYCODE_SELECT, 2)) ) | |
| 345 | INPUT_PORT_DIGITAL_TYPE( 0, OTHER, COIN4, "Coin 4", SEQ_DEF_3(KEYCODE_8, SEQCODE_OR, INDEXED(JOYCODE_SELECT, 3)) ) | |
| 346 | INPUT_PORT_DIGITAL_TYPE( 0, OTHER, COIN5, "Coin 5", SEQ_DEF_0 ) | |
| 347 | INPUT_PORT_DIGITAL_TYPE( 0, OTHER, COIN6, "Coin 6", SEQ_DEF_0 ) | |
| 348 | INPUT_PORT_DIGITAL_TYPE( 0, OTHER, COIN7, "Coin 7", SEQ_DEF_0 ) | |
| 349 | INPUT_PORT_DIGITAL_TYPE( 0, OTHER, COIN8, "Coin 8", SEQ_DEF_0 ) | |
| 350 | INPUT_PORT_DIGITAL_TYPE( 0, OTHER, BILL1, "Bill 1", SEQ_DEF_1(KEYCODE_BACKSPACE) ) | |
| 351 | ||
| 352 | INPUT_PORT_DIGITAL_TYPE( 0, OTHER, SERVICE1, "Service 1", SEQ_DEF_1(KEYCODE_9) ) | |
| 353 | INPUT_PORT_DIGITAL_TYPE( 0, OTHER, SERVICE2, "Service 2", SEQ_DEF_1(KEYCODE_0) ) | |
| 354 | INPUT_PORT_DIGITAL_TYPE( 0, OTHER, SERVICE3, "Service 3", SEQ_DEF_1(KEYCODE_MINUS) ) | |
| 355 | INPUT_PORT_DIGITAL_TYPE( 0, OTHER, SERVICE4, "Service 4", SEQ_DEF_1(KEYCODE_EQUALS) ) | |
| 356 | ||
| 357 | INPUT_PORT_DIGITAL_TYPE( 0, OTHER, SERVICE, "Service", SEQ_DEF_1(KEYCODE_F2) ) | |
| 358 | INPUT_PORT_DIGITAL_TYPE( 0, OTHER, TILT, "Tilt", SEQ_DEF_1(KEYCODE_T) ) | |
| 359 | INPUT_PORT_DIGITAL_TYPE( 0, OTHER, INTERLOCK, "Door Interlock", SEQ_DEF_0 ) | |
| 360 | INPUT_PORT_DIGITAL_TYPE( 0, OTHER, VOLUME_DOWN, "Volume Down", SEQ_DEF_1(KEYCODE_MINUS) ) | |
| 361 | INPUT_PORT_DIGITAL_TYPE( 0, OTHER, VOLUME_UP, "Volume Up", SEQ_DEF_1(KEYCODE_EQUALS) ) | |
| 362 | ||
| 363 | INPUT_PORT_ANALOG_TYPE( 1, PLAYER1, PEDAL, "P1 Pedal 1", SEQ_DEF_1(INDEXED(JOYCODE_Y_NEG_ABSOLUTE, 0)), SEQ_DEF_0, SEQ_DEF_3(KEYCODE_LCONTROL, SEQCODE_OR, INDEXED(JOYCODE_BUTTON1, 0)) ) | |
| 364 | INPUT_PORT_ANALOG_TYPE( 2, PLAYER2, PEDAL, "P2 Pedal 1", SEQ_DEF_1(INDEXED(JOYCODE_Y_NEG_ABSOLUTE, 1)), SEQ_DEF_0, SEQ_DEF_3(KEYCODE_A, SEQCODE_OR, INDEXED(JOYCODE_BUTTON1, 1)) ) | |
| 365 | INPUT_PORT_ANALOG_TYPE( 3, PLAYER3, PEDAL, "P3 Pedal 1", SEQ_DEF_1(INDEXED(JOYCODE_Y_NEG_ABSOLUTE, 2)), SEQ_DEF_0, SEQ_DEF_3(KEYCODE_RCONTROL, SEQCODE_OR, INDEXED(JOYCODE_BUTTON1, 2)) ) | |
| 366 | INPUT_PORT_ANALOG_TYPE( 4, PLAYER4, PEDAL, "P4 Pedal 1", SEQ_DEF_1(INDEXED(JOYCODE_Y_NEG_ABSOLUTE, 3)), SEQ_DEF_0, SEQ_DEF_3(KEYCODE_0_PAD, SEQCODE_OR, INDEXED(JOYCODE_BUTTON1, 3)) ) | |
| 367 | INPUT_PORT_ANALOG_TYPE( 5, PLAYER5, PEDAL, "P5 Pedal 1", SEQ_DEF_1(INDEXED(JOYCODE_Y_NEG_ABSOLUTE, 4)), SEQ_DEF_0, SEQ_DEF_1(INDEXED(JOYCODE_BUTTON1, 4)) ) | |
| 368 | INPUT_PORT_ANALOG_TYPE( 6, PLAYER6, PEDAL, "P6 Pedal 1", SEQ_DEF_1(INDEXED(JOYCODE_Y_NEG_ABSOLUTE, 5)), SEQ_DEF_0, SEQ_DEF_1(INDEXED(JOYCODE_BUTTON1, 5)) ) | |
| 369 | INPUT_PORT_ANALOG_TYPE( 7, PLAYER7, PEDAL, "P7 Pedal 1", SEQ_DEF_1(INDEXED(JOYCODE_Y_NEG_ABSOLUTE, 6)), SEQ_DEF_0, SEQ_DEF_1(INDEXED(JOYCODE_BUTTON1, 6)) ) | |
| 370 | INPUT_PORT_ANALOG_TYPE( 8, PLAYER8, PEDAL, "P8 Pedal 1", SEQ_DEF_1(INDEXED(JOYCODE_Y_NEG_ABSOLUTE, 7)), SEQ_DEF_0, SEQ_DEF_1(INDEXED(JOYCODE_BUTTON1, 7)) ) | |
| 371 | ||
| 372 | INPUT_PORT_ANALOG_TYPE( 1, PLAYER1, PEDAL2, "P1 Pedal 2", SEQ_DEF_1(INDEXED(JOYCODE_Y_POS_ABSOLUTE, 0)), SEQ_DEF_0, SEQ_DEF_3(KEYCODE_LALT, SEQCODE_OR, INDEXED(JOYCODE_BUTTON2, 0)) ) | |
| 373 | INPUT_PORT_ANALOG_TYPE( 2, PLAYER2, PEDAL2, "P2 Pedal 2", SEQ_DEF_1(INDEXED(JOYCODE_Y_POS_ABSOLUTE, 1)), SEQ_DEF_0, SEQ_DEF_3(KEYCODE_S, SEQCODE_OR, INDEXED(JOYCODE_BUTTON2, 1)) ) | |
| 374 | INPUT_PORT_ANALOG_TYPE( 3, PLAYER3, PEDAL2, "P3 Pedal 2", SEQ_DEF_1(INDEXED(JOYCODE_Y_POS_ABSOLUTE, 2)), SEQ_DEF_0, SEQ_DEF_3(KEYCODE_RSHIFT, SEQCODE_OR, INDEXED(JOYCODE_BUTTON2, 2)) ) | |
| 375 | INPUT_PORT_ANALOG_TYPE( 4, PLAYER4, PEDAL2, "P4 Pedal 2", SEQ_DEF_1(INDEXED(JOYCODE_Y_POS_ABSOLUTE, 3)), SEQ_DEF_0, SEQ_DEF_3(KEYCODE_DEL_PAD, SEQCODE_OR, INDEXED(JOYCODE_BUTTON2, 3)) ) | |
| 376 | INPUT_PORT_ANALOG_TYPE( 5, PLAYER5, PEDAL2, "P5 Pedal 2", SEQ_DEF_1(INDEXED(JOYCODE_Y_POS_ABSOLUTE, 4)), SEQ_DEF_0, SEQ_DEF_1(INDEXED(JOYCODE_BUTTON2, 4)) ) | |
| 377 | INPUT_PORT_ANALOG_TYPE( 6, PLAYER6, PEDAL2, "P6 Pedal 2", SEQ_DEF_1(INDEXED(JOYCODE_Y_POS_ABSOLUTE, 5)), SEQ_DEF_0, SEQ_DEF_1(INDEXED(JOYCODE_BUTTON2, 5)) ) | |
| 378 | INPUT_PORT_ANALOG_TYPE( 7, PLAYER7, PEDAL2, "P7 Pedal 2", SEQ_DEF_1(INDEXED(JOYCODE_Y_POS_ABSOLUTE, 6)), SEQ_DEF_0, SEQ_DEF_1(INDEXED(JOYCODE_BUTTON2, 6)) ) | |
| 379 | INPUT_PORT_ANALOG_TYPE( 8, PLAYER8, PEDAL2, "P8 Pedal 2", SEQ_DEF_1(INDEXED(JOYCODE_Y_POS_ABSOLUTE, 7)), SEQ_DEF_0, SEQ_DEF_1(INDEXED(JOYCODE_BUTTON2, 7)) ) | |
| 380 | ||
| 381 | INPUT_PORT_ANALOG_TYPE( 1, PLAYER1, PEDAL3, "P1 Pedal 3", SEQ_DEF_0, SEQ_DEF_0, SEQ_DEF_3(KEYCODE_SPACE, SEQCODE_OR, INDEXED(JOYCODE_BUTTON3, 0)) ) | |
| 382 | INPUT_PORT_ANALOG_TYPE( 2, PLAYER2, PEDAL3, "P2 Pedal 3", SEQ_DEF_0, SEQ_DEF_0, SEQ_DEF_3(KEYCODE_Q, SEQCODE_OR, INDEXED(JOYCODE_BUTTON3, 1)) ) | |
| 383 | INPUT_PORT_ANALOG_TYPE( 3, PLAYER3, PEDAL3, "P3 Pedal 3", SEQ_DEF_0, SEQ_DEF_0, SEQ_DEF_3(KEYCODE_ENTER, SEQCODE_OR, INDEXED(JOYCODE_BUTTON3, 2)) ) | |
| 384 | INPUT_PORT_ANALOG_TYPE( 4, PLAYER4, PEDAL3, "P4 Pedal 3", SEQ_DEF_0, SEQ_DEF_0, SEQ_DEF_3(KEYCODE_ENTER_PAD, SEQCODE_OR, INDEXED(JOYCODE_BUTTON3, 3)) ) | |
| 385 | INPUT_PORT_ANALOG_TYPE( 5, PLAYER5, PEDAL3, "P5 Pedal 3", SEQ_DEF_0, SEQ_DEF_0, SEQ_DEF_1(INDEXED(JOYCODE_BUTTON3, 4)) ) | |
| 386 | INPUT_PORT_ANALOG_TYPE( 6, PLAYER6, PEDAL3, "P6 Pedal 3", SEQ_DEF_0, SEQ_DEF_0, SEQ_DEF_1(INDEXED(JOYCODE_BUTTON3, 5)) ) | |
| 387 | INPUT_PORT_ANALOG_TYPE( 7, PLAYER7, PEDAL3, "P7 Pedal 3", SEQ_DEF_0, SEQ_DEF_0, SEQ_DEF_1(INDEXED(JOYCODE_BUTTON3, 6)) ) | |
| 388 | INPUT_PORT_ANALOG_TYPE( 8, PLAYER8, PEDAL3, "P8 Pedal 3", SEQ_DEF_0, SEQ_DEF_0, SEQ_DEF_1(INDEXED(JOYCODE_BUTTON3, 7)) ) | |
| 389 | ||
| 390 | INPUT_PORT_ANALOG_TYPE( 1, PLAYER1, PADDLE, "Paddle", SEQ_DEF_3(INDEXED(MOUSECODE_X, 0), SEQCODE_OR, INDEXED(JOYCODE_X, 0)), SEQ_DEF_3(KEYCODE_LEFT, SEQCODE_OR, INDEXED(JOYCODE_X_LEFT_SWITCH, 0)), SEQ_DEF_3(KEYCODE_RIGHT, SEQCODE_OR, INDEXED(JOYCODE_X_RIGHT_SWITCH, 0)) ) | |
| 391 | INPUT_PORT_ANALOG_TYPE( 2, PLAYER2, PADDLE, "Paddle 2", SEQ_DEF_3(INDEXED(MOUSECODE_X, 1), SEQCODE_OR, INDEXED(JOYCODE_X, 1)), SEQ_DEF_3(KEYCODE_D, SEQCODE_OR, INDEXED(JOYCODE_X_LEFT_SWITCH, 1)), SEQ_DEF_3(KEYCODE_G, SEQCODE_OR, INDEXED(JOYCODE_X_RIGHT_SWITCH, 1)) ) | |
| 392 | INPUT_PORT_ANALOG_TYPE( 3, PLAYER3, PADDLE, "Paddle 3", SEQ_DEF_3(INDEXED(MOUSECODE_X, 2), SEQCODE_OR, INDEXED(JOYCODE_X, 2)), SEQ_DEF_3(KEYCODE_J, SEQCODE_OR, INDEXED(JOYCODE_X_LEFT_SWITCH, 2)), SEQ_DEF_3(KEYCODE_L, SEQCODE_OR, INDEXED(JOYCODE_X_RIGHT_SWITCH, 2)) ) | |
| 393 | INPUT_PORT_ANALOG_TYPE( 4, PLAYER4, PADDLE, "Paddle 4", SEQ_DEF_3(INDEXED(MOUSECODE_X, 3), SEQCODE_OR, INDEXED(JOYCODE_X, 3)), SEQ_DEF_1(INDEXED(JOYCODE_X_LEFT_SWITCH, 3)), SEQ_DEF_1(INDEXED(JOYCODE_X_RIGHT_SWITCH, 3)) ) | |
| 394 | INPUT_PORT_ANALOG_TYPE( 5, PLAYER5, PADDLE, "Paddle 5", SEQ_DEF_3(INDEXED(MOUSECODE_X, 4), SEQCODE_OR, INDEXED(JOYCODE_X, 4)), SEQ_DEF_1(INDEXED(JOYCODE_X_LEFT_SWITCH, 4)), SEQ_DEF_1(INDEXED(JOYCODE_X_RIGHT_SWITCH, 4)) ) | |
| 395 | INPUT_PORT_ANALOG_TYPE( 6, PLAYER6, PADDLE, "Paddle 6", SEQ_DEF_3(INDEXED(MOUSECODE_X, 5), SEQCODE_OR, INDEXED(JOYCODE_X, 5)), SEQ_DEF_1(INDEXED(JOYCODE_X_LEFT_SWITCH, 5)), SEQ_DEF_1(INDEXED(JOYCODE_X_RIGHT_SWITCH, 5)) ) | |
| 396 | INPUT_PORT_ANALOG_TYPE( 7, PLAYER7, PADDLE, "Paddle 7", SEQ_DEF_3(INDEXED(MOUSECODE_X, 6), SEQCODE_OR, INDEXED(JOYCODE_X, 6)), SEQ_DEF_1(INDEXED(JOYCODE_X_LEFT_SWITCH, 6)), SEQ_DEF_1(INDEXED(JOYCODE_X_RIGHT_SWITCH, 6)) ) | |
| 397 | INPUT_PORT_ANALOG_TYPE( 8, PLAYER8, PADDLE, "Paddle 8", SEQ_DEF_3(INDEXED(MOUSECODE_X, 7), SEQCODE_OR, INDEXED(JOYCODE_X, 7)), SEQ_DEF_1(INDEXED(JOYCODE_X_LEFT_SWITCH, 7)), SEQ_DEF_1(INDEXED(JOYCODE_X_RIGHT_SWITCH, 7)) ) | |
| 398 | ||
| 399 | INPUT_PORT_ANALOG_TYPE( 1, PLAYER1, PADDLE_V, "Paddle V", SEQ_DEF_3(INDEXED(MOUSECODE_Y, 0), SEQCODE_OR, INDEXED(JOYCODE_Y, 0)), SEQ_DEF_3(KEYCODE_UP, SEQCODE_OR, INDEXED(JOYCODE_Y_UP_SWITCH, 0)), SEQ_DEF_3(KEYCODE_DOWN, SEQCODE_OR, INDEXED(JOYCODE_Y_DOWN_SWITCH, 0)) ) | |
| 400 | INPUT_PORT_ANALOG_TYPE( 2, PLAYER2, PADDLE_V, "Paddle V 2", SEQ_DEF_3(INDEXED(MOUSECODE_Y, 1), SEQCODE_OR, INDEXED(JOYCODE_Y, 1)), SEQ_DEF_3(KEYCODE_R, SEQCODE_OR, INDEXED(JOYCODE_Y_UP_SWITCH, 1)), SEQ_DEF_3(KEYCODE_F, SEQCODE_OR, INDEXED(JOYCODE_Y_DOWN_SWITCH, 1)) ) | |
| 401 | INPUT_PORT_ANALOG_TYPE( 3, PLAYER3, PADDLE_V, "Paddle V 3", SEQ_DEF_3(INDEXED(MOUSECODE_Y, 2), SEQCODE_OR, INDEXED(JOYCODE_Y, 2)), SEQ_DEF_3(KEYCODE_I, SEQCODE_OR, INDEXED(JOYCODE_Y_UP_SWITCH, 2)), SEQ_DEF_3(KEYCODE_K, SEQCODE_OR, INDEXED(JOYCODE_Y_DOWN_SWITCH, 2)) ) | |
| 402 | INPUT_PORT_ANALOG_TYPE( 4, PLAYER4, PADDLE_V, "Paddle V 4", SEQ_DEF_3(INDEXED(MOUSECODE_Y, 3), SEQCODE_OR, INDEXED(JOYCODE_Y, 3)), SEQ_DEF_1(INDEXED(JOYCODE_Y_UP_SWITCH, 3)), SEQ_DEF_1(INDEXED(JOYCODE_Y_DOWN_SWITCH, 3)) ) | |
| 403 | INPUT_PORT_ANALOG_TYPE( 5, PLAYER5, PADDLE_V, "Paddle V 5", SEQ_DEF_3(INDEXED(MOUSECODE_Y, 4), SEQCODE_OR, INDEXED(JOYCODE_Y, 4)), SEQ_DEF_1(INDEXED(JOYCODE_Y_UP_SWITCH, 4)), SEQ_DEF_1(INDEXED(JOYCODE_Y_DOWN_SWITCH, 4)) ) | |
| 404 | INPUT_PORT_ANALOG_TYPE( 6, PLAYER6, PADDLE_V, "Paddle V 6", SEQ_DEF_3(INDEXED(MOUSECODE_Y, 5), SEQCODE_OR, INDEXED(JOYCODE_Y, 5)), SEQ_DEF_1(INDEXED(JOYCODE_Y_UP_SWITCH, 5)), SEQ_DEF_1(INDEXED(JOYCODE_Y_DOWN_SWITCH, 5)) ) | |
| 405 | INPUT_PORT_ANALOG_TYPE( 7, PLAYER7, PADDLE_V, "Paddle V 7", SEQ_DEF_3(INDEXED(MOUSECODE_Y, 6), SEQCODE_OR, INDEXED(JOYCODE_Y, 6)), SEQ_DEF_1(INDEXED(JOYCODE_Y_UP_SWITCH, 6)), SEQ_DEF_1(INDEXED(JOYCODE_Y_DOWN_SWITCH, 6)) ) | |
| 406 | INPUT_PORT_ANALOG_TYPE( 8, PLAYER8, PADDLE_V, "Paddle V 8", SEQ_DEF_3(INDEXED(MOUSECODE_Y, 7), SEQCODE_OR, INDEXED(JOYCODE_Y, 7)), SEQ_DEF_1(INDEXED(JOYCODE_Y_UP_SWITCH, 7)), SEQ_DEF_1(INDEXED(JOYCODE_Y_DOWN_SWITCH, 7)) ) | |
| 407 | ||
| 408 | INPUT_PORT_ANALOG_TYPE( 1, PLAYER1, POSITIONAL, "Positional", SEQ_DEF_3(INDEXED(MOUSECODE_X, 0), SEQCODE_OR, INDEXED(JOYCODE_X, 0)), SEQ_DEF_3(KEYCODE_LEFT, SEQCODE_OR, INDEXED(JOYCODE_X_LEFT_SWITCH, 0)), SEQ_DEF_3(KEYCODE_RIGHT, SEQCODE_OR, INDEXED(JOYCODE_X_RIGHT_SWITCH, 0)) ) | |
| 409 | INPUT_PORT_ANALOG_TYPE( 2, PLAYER2, POSITIONAL, "Positional 2", SEQ_DEF_3(INDEXED(MOUSECODE_X, 1), SEQCODE_OR, INDEXED(JOYCODE_X, 1)), SEQ_DEF_3(KEYCODE_D, SEQCODE_OR, INDEXED(JOYCODE_X_LEFT_SWITCH, 1)), SEQ_DEF_3(KEYCODE_G, SEQCODE_OR, INDEXED(JOYCODE_X_RIGHT_SWITCH, 1)) ) | |
| 410 | INPUT_PORT_ANALOG_TYPE( 3, PLAYER3, POSITIONAL, "Positional 3", SEQ_DEF_3(INDEXED(MOUSECODE_X, 2), SEQCODE_OR, INDEXED(JOYCODE_X, 2)), SEQ_DEF_3(KEYCODE_J, SEQCODE_OR, INDEXED(JOYCODE_X_LEFT_SWITCH, 2)), SEQ_DEF_3(KEYCODE_L, SEQCODE_OR, INDEXED(JOYCODE_X_RIGHT_SWITCH, 2)) ) | |
| 411 | INPUT_PORT_ANALOG_TYPE( 4, PLAYER4, POSITIONAL, "Positional 4", SEQ_DEF_3(INDEXED(MOUSECODE_X, 3), SEQCODE_OR, INDEXED(JOYCODE_X, 3)), SEQ_DEF_1(INDEXED(JOYCODE_X_LEFT_SWITCH, 3)), SEQ_DEF_1(INDEXED(JOYCODE_X_RIGHT_SWITCH, 3)) ) | |
| 412 | INPUT_PORT_ANALOG_TYPE( 5, PLAYER5, POSITIONAL, "Positional 5", SEQ_DEF_3(INDEXED(MOUSECODE_X, 4), SEQCODE_OR, INDEXED(JOYCODE_X, 4)), SEQ_DEF_1(INDEXED(JOYCODE_X_LEFT_SWITCH, 4)), SEQ_DEF_1(INDEXED(JOYCODE_X_RIGHT_SWITCH, 4)) ) | |
| 413 | INPUT_PORT_ANALOG_TYPE( 6, PLAYER6, POSITIONAL, "Positional 6", SEQ_DEF_3(INDEXED(MOUSECODE_X, 5), SEQCODE_OR, INDEXED(JOYCODE_X, 5)), SEQ_DEF_1(INDEXED(JOYCODE_X_LEFT_SWITCH, 5)), SEQ_DEF_1(INDEXED(JOYCODE_X_RIGHT_SWITCH, 5)) ) | |
| 414 | INPUT_PORT_ANALOG_TYPE( 7, PLAYER7, POSITIONAL, "Positional 7", SEQ_DEF_3(INDEXED(MOUSECODE_X, 6), SEQCODE_OR, INDEXED(JOYCODE_X, 6)), SEQ_DEF_1(INDEXED(JOYCODE_X_LEFT_SWITCH, 6)), SEQ_DEF_1(INDEXED(JOYCODE_X_RIGHT_SWITCH, 6)) ) | |
| 415 | INPUT_PORT_ANALOG_TYPE( 8, PLAYER8, POSITIONAL, "Positional 8", SEQ_DEF_3(INDEXED(MOUSECODE_X, 7), SEQCODE_OR, INDEXED(JOYCODE_X, 7)), SEQ_DEF_1(INDEXED(JOYCODE_X_LEFT_SWITCH, 7)), SEQ_DEF_1(INDEXED(JOYCODE_X_RIGHT_SWITCH, 7)) ) | |
| 416 | ||
| 417 | INPUT_PORT_ANALOG_TYPE( 1, PLAYER1, POSITIONAL_V, "Positional V", SEQ_DEF_3(INDEXED(MOUSECODE_Y, 0), SEQCODE_OR, INDEXED(JOYCODE_Y, 0)), SEQ_DEF_3(KEYCODE_UP, SEQCODE_OR, INDEXED(JOYCODE_Y_UP_SWITCH, 0)), SEQ_DEF_3(KEYCODE_DOWN, SEQCODE_OR, INDEXED(JOYCODE_Y_DOWN_SWITCH, 0)) ) | |
| 418 | INPUT_PORT_ANALOG_TYPE( 2, PLAYER2, POSITIONAL_V, "Positional V 2", SEQ_DEF_3(INDEXED(MOUSECODE_Y, 1), SEQCODE_OR, INDEXED(JOYCODE_Y, 1)), SEQ_DEF_3(KEYCODE_R, SEQCODE_OR, INDEXED(JOYCODE_Y_UP_SWITCH, 1)), SEQ_DEF_3(KEYCODE_F, SEQCODE_OR, INDEXED(JOYCODE_Y_DOWN_SWITCH, 1)) ) | |
| 419 | INPUT_PORT_ANALOG_TYPE( 3, PLAYER3, POSITIONAL_V, "Positional V 3", SEQ_DEF_3(INDEXED(MOUSECODE_Y, 2), SEQCODE_OR, INDEXED(JOYCODE_Y, 2)), SEQ_DEF_3(KEYCODE_I, SEQCODE_OR, INDEXED(JOYCODE_Y_UP_SWITCH, 2)), SEQ_DEF_3(KEYCODE_K, SEQCODE_OR, INDEXED(JOYCODE_Y_DOWN_SWITCH, 2)) ) | |
| 420 | INPUT_PORT_ANALOG_TYPE( 4, PLAYER4, POSITIONAL_V, "Positional V 4", SEQ_DEF_3(INDEXED(MOUSECODE_Y, 3), SEQCODE_OR, INDEXED(JOYCODE_Y, 3)), SEQ_DEF_1(INDEXED(JOYCODE_Y_UP_SWITCH, 3)), SEQ_DEF_1(INDEXED(JOYCODE_Y_DOWN_SWITCH, 3)) ) | |
| 421 | INPUT_PORT_ANALOG_TYPE( 5, PLAYER5, POSITIONAL_V, "Positional V 5", SEQ_DEF_3(INDEXED(MOUSECODE_Y, 4), SEQCODE_OR, INDEXED(JOYCODE_Y, 4)), SEQ_DEF_1(INDEXED(JOYCODE_Y_UP_SWITCH, 4)), SEQ_DEF_1(INDEXED(JOYCODE_Y_DOWN_SWITCH, 4)) ) | |
| 422 | INPUT_PORT_ANALOG_TYPE( 6, PLAYER6, POSITIONAL_V, "Positional V 6", SEQ_DEF_3(INDEXED(MOUSECODE_Y, 5), SEQCODE_OR, INDEXED(JOYCODE_Y, 5)), SEQ_DEF_1(INDEXED(JOYCODE_Y_UP_SWITCH, 5)), SEQ_DEF_1(INDEXED(JOYCODE_Y_DOWN_SWITCH, 5)) ) | |
| 423 | INPUT_PORT_ANALOG_TYPE( 7, PLAYER7, POSITIONAL_V, "Positional V 7", SEQ_DEF_3(INDEXED(MOUSECODE_Y, 6), SEQCODE_OR, INDEXED(JOYCODE_Y, 6)), SEQ_DEF_1(INDEXED(JOYCODE_Y_UP_SWITCH, 6)), SEQ_DEF_1(INDEXED(JOYCODE_Y_DOWN_SWITCH, 6)) ) | |
| 424 | INPUT_PORT_ANALOG_TYPE( 8, PLAYER8, POSITIONAL_V, "Positional V 8", SEQ_DEF_3(INDEXED(MOUSECODE_Y, 7), SEQCODE_OR, INDEXED(JOYCODE_Y, 7)), SEQ_DEF_1(INDEXED(JOYCODE_Y_UP_SWITCH, 7)), SEQ_DEF_1(INDEXED(JOYCODE_Y_DOWN_SWITCH, 7)) ) | |
| 425 | ||
| 426 | INPUT_PORT_ANALOG_TYPE( 1, PLAYER1, DIAL, "Dial", SEQ_DEF_3(INDEXED(MOUSECODE_X, 0), SEQCODE_OR, INDEXED(JOYCODE_X, 0)), SEQ_DEF_3(KEYCODE_LEFT, SEQCODE_OR, INDEXED(JOYCODE_X_LEFT_SWITCH, 0)), SEQ_DEF_3(KEYCODE_RIGHT, SEQCODE_OR, INDEXED(JOYCODE_X_RIGHT_SWITCH, 0)) ) | |
| 427 | INPUT_PORT_ANALOG_TYPE( 2, PLAYER2, DIAL, "Dial 2", SEQ_DEF_3(INDEXED(MOUSECODE_X, 1), SEQCODE_OR, INDEXED(JOYCODE_X, 1)), SEQ_DEF_3(KEYCODE_D, SEQCODE_OR, INDEXED(JOYCODE_X_LEFT_SWITCH, 1)), SEQ_DEF_3(KEYCODE_G, SEQCODE_OR, INDEXED(JOYCODE_X_RIGHT_SWITCH, 1)) ) | |
| 428 | INPUT_PORT_ANALOG_TYPE( 3, PLAYER3, DIAL, "Dial 3", SEQ_DEF_3(INDEXED(MOUSECODE_X, 2), SEQCODE_OR, INDEXED(JOYCODE_X, 2)), SEQ_DEF_3(KEYCODE_J, SEQCODE_OR, INDEXED(JOYCODE_X_LEFT_SWITCH, 2)), SEQ_DEF_3(KEYCODE_L, SEQCODE_OR, INDEXED(JOYCODE_X_RIGHT_SWITCH, 2)) ) | |
| 429 | INPUT_PORT_ANALOG_TYPE( 4, PLAYER4, DIAL, "Dial 4", SEQ_DEF_3(INDEXED(MOUSECODE_X, 3), SEQCODE_OR, INDEXED(JOYCODE_X, 3)), SEQ_DEF_1(INDEXED(JOYCODE_X_LEFT_SWITCH, 3)), SEQ_DEF_1(INDEXED(JOYCODE_X_RIGHT_SWITCH, 3)) ) | |
| 430 | INPUT_PORT_ANALOG_TYPE( 5, PLAYER5, DIAL, "Dial 5", SEQ_DEF_3(INDEXED(MOUSECODE_X, 4), SEQCODE_OR, INDEXED(JOYCODE_X, 4)), SEQ_DEF_1(INDEXED(JOYCODE_X_LEFT_SWITCH, 4)), SEQ_DEF_1(INDEXED(JOYCODE_X_RIGHT_SWITCH, 4)) ) | |
| 431 | INPUT_PORT_ANALOG_TYPE( 6, PLAYER6, DIAL, "Dial 6", SEQ_DEF_3(INDEXED(MOUSECODE_X, 5), SEQCODE_OR, INDEXED(JOYCODE_X, 5)), SEQ_DEF_1(INDEXED(JOYCODE_X_LEFT_SWITCH, 5)), SEQ_DEF_1(INDEXED(JOYCODE_X_RIGHT_SWITCH, 5)) ) | |
| 432 | INPUT_PORT_ANALOG_TYPE( 7, PLAYER7, DIAL, "Dial 7", SEQ_DEF_3(INDEXED(MOUSECODE_X, 6), SEQCODE_OR, INDEXED(JOYCODE_X, 6)), SEQ_DEF_1(INDEXED(JOYCODE_X_LEFT_SWITCH, 6)), SEQ_DEF_1(INDEXED(JOYCODE_X_RIGHT_SWITCH, 6)) ) | |
| 433 | INPUT_PORT_ANALOG_TYPE( 8, PLAYER8, DIAL, "Dial 8", SEQ_DEF_3(INDEXED(MOUSECODE_X, 7), SEQCODE_OR, INDEXED(JOYCODE_X, 7)), SEQ_DEF_1(INDEXED(JOYCODE_X_LEFT_SWITCH, 7)), SEQ_DEF_1(INDEXED(JOYCODE_X_RIGHT_SWITCH, 7)) ) | |
| 434 | ||
| 435 | INPUT_PORT_ANALOG_TYPE( 1, PLAYER1, DIAL_V, "Dial V", SEQ_DEF_3(INDEXED(MOUSECODE_Y, 0), SEQCODE_OR, INDEXED(JOYCODE_Y, 0)), SEQ_DEF_3(KEYCODE_UP, SEQCODE_OR, INDEXED(JOYCODE_Y_UP_SWITCH, 0)), SEQ_DEF_3(KEYCODE_DOWN, SEQCODE_OR, INDEXED(JOYCODE_Y_DOWN_SWITCH, 0)) ) | |
| 436 | INPUT_PORT_ANALOG_TYPE( 2, PLAYER2, DIAL_V, "Dial V 2", SEQ_DEF_3(INDEXED(MOUSECODE_Y, 1), SEQCODE_OR, INDEXED(JOYCODE_Y, 1)), SEQ_DEF_3(KEYCODE_R, SEQCODE_OR, INDEXED(JOYCODE_Y_UP_SWITCH, 1)), SEQ_DEF_3(KEYCODE_F, SEQCODE_OR, INDEXED(JOYCODE_Y_DOWN_SWITCH, 1)) ) | |
| 437 | INPUT_PORT_ANALOG_TYPE( 3, PLAYER3, DIAL_V, "Dial V 3", SEQ_DEF_3(INDEXED(MOUSECODE_Y, 2), SEQCODE_OR, INDEXED(JOYCODE_Y, 2)), SEQ_DEF_3(KEYCODE_I, SEQCODE_OR, INDEXED(JOYCODE_Y_UP_SWITCH, 2)), SEQ_DEF_3(KEYCODE_K, SEQCODE_OR, INDEXED(JOYCODE_Y_DOWN_SWITCH, 2)) ) | |
| 438 | INPUT_PORT_ANALOG_TYPE( 4, PLAYER4, DIAL_V, "Dial V 4", SEQ_DEF_3(INDEXED(MOUSECODE_Y, 3), SEQCODE_OR, INDEXED(JOYCODE_Y, 3)), SEQ_DEF_1(INDEXED(JOYCODE_Y_UP_SWITCH, 3)), SEQ_DEF_1(INDEXED(JOYCODE_Y_DOWN_SWITCH, 3)) ) | |
| 439 | INPUT_PORT_ANALOG_TYPE( 5, PLAYER5, DIAL_V, "Dial V 5", SEQ_DEF_3(INDEXED(MOUSECODE_Y, 4), SEQCODE_OR, INDEXED(JOYCODE_Y, 4)), SEQ_DEF_1(INDEXED(JOYCODE_Y_UP_SWITCH, 4)), SEQ_DEF_1(INDEXED(JOYCODE_Y_DOWN_SWITCH, 4)) ) | |
| 440 | INPUT_PORT_ANALOG_TYPE( 6, PLAYER6, DIAL_V, "Dial V 6", SEQ_DEF_3(INDEXED(MOUSECODE_Y, 5), SEQCODE_OR, INDEXED(JOYCODE_Y, 5)), SEQ_DEF_1(INDEXED(JOYCODE_Y_UP_SWITCH, 5)), SEQ_DEF_1(INDEXED(JOYCODE_Y_DOWN_SWITCH, 5)) ) | |
| 441 | INPUT_PORT_ANALOG_TYPE( 7, PLAYER7, DIAL_V, "Dial V 7", SEQ_DEF_3(INDEXED(MOUSECODE_Y, 6), SEQCODE_OR, INDEXED(JOYCODE_Y, 6)), SEQ_DEF_1(INDEXED(JOYCODE_Y_UP_SWITCH, 6)), SEQ_DEF_1(INDEXED(JOYCODE_Y_DOWN_SWITCH, 6)) ) | |
| 442 | INPUT_PORT_ANALOG_TYPE( 8, PLAYER8, DIAL_V, "Dial V 8", SEQ_DEF_3(INDEXED(MOUSECODE_Y, 7), SEQCODE_OR, INDEXED(JOYCODE_Y, 7)), SEQ_DEF_1(INDEXED(JOYCODE_Y_UP_SWITCH, 7)), SEQ_DEF_1(INDEXED(JOYCODE_Y_DOWN_SWITCH, 7)) ) | |
| 443 | ||
| 444 | INPUT_PORT_ANALOG_TYPE( 1, PLAYER1, TRACKBALL_X, "Track X", SEQ_DEF_3(INDEXED(MOUSECODE_X, 0), SEQCODE_OR, INDEXED(JOYCODE_X, 0)), SEQ_DEF_3(KEYCODE_LEFT, SEQCODE_OR, INDEXED(JOYCODE_X_LEFT_SWITCH, 0)), SEQ_DEF_3(KEYCODE_RIGHT, SEQCODE_OR, INDEXED(JOYCODE_X_RIGHT_SWITCH, 0)) ) | |
| 445 | INPUT_PORT_ANALOG_TYPE( 2, PLAYER2, TRACKBALL_X, "Track X 2", SEQ_DEF_3(INDEXED(MOUSECODE_X, 1), SEQCODE_OR, INDEXED(JOYCODE_X, 1)), SEQ_DEF_3(KEYCODE_D, SEQCODE_OR, INDEXED(JOYCODE_X_LEFT_SWITCH, 1)), SEQ_DEF_3(KEYCODE_G, SEQCODE_OR, INDEXED(JOYCODE_X_RIGHT_SWITCH, 1)) ) | |
| 446 | INPUT_PORT_ANALOG_TYPE( 3, PLAYER3, TRACKBALL_X, "Track X 3", SEQ_DEF_3(INDEXED(MOUSECODE_X, 2), SEQCODE_OR, INDEXED(JOYCODE_X, 2)), SEQ_DEF_3(KEYCODE_J, SEQCODE_OR, INDEXED(JOYCODE_X_LEFT_SWITCH, 2)), SEQ_DEF_3(KEYCODE_L, SEQCODE_OR, INDEXED(JOYCODE_X_RIGHT_SWITCH, 2)) ) | |
| 447 | INPUT_PORT_ANALOG_TYPE( 4, PLAYER4, TRACKBALL_X, "Track X 4", SEQ_DEF_3(INDEXED(MOUSECODE_X, 3), SEQCODE_OR, INDEXED(JOYCODE_X, 3)), SEQ_DEF_1(INDEXED(JOYCODE_X_LEFT_SWITCH, 3)), SEQ_DEF_1(INDEXED(JOYCODE_X_RIGHT_SWITCH, 3)) ) | |
| 448 | INPUT_PORT_ANALOG_TYPE( 5, PLAYER5, TRACKBALL_X, "Track X 5", SEQ_DEF_3(INDEXED(MOUSECODE_X, 4), SEQCODE_OR, INDEXED(JOYCODE_X, 4)), SEQ_DEF_1(INDEXED(JOYCODE_X_LEFT_SWITCH, 4)), SEQ_DEF_1(INDEXED(JOYCODE_X_RIGHT_SWITCH, 4)) ) | |
| 449 | INPUT_PORT_ANALOG_TYPE( 6, PLAYER6, TRACKBALL_X, "Track X 6", SEQ_DEF_3(INDEXED(MOUSECODE_X, 5), SEQCODE_OR, INDEXED(JOYCODE_X, 5)), SEQ_DEF_1(INDEXED(JOYCODE_X_LEFT_SWITCH, 5)), SEQ_DEF_1(INDEXED(JOYCODE_X_RIGHT_SWITCH, 5)) ) | |
| 450 | INPUT_PORT_ANALOG_TYPE( 7, PLAYER7, TRACKBALL_X, "Track X 7", SEQ_DEF_3(INDEXED(MOUSECODE_X, 6), SEQCODE_OR, INDEXED(JOYCODE_X, 6)), SEQ_DEF_1(INDEXED(JOYCODE_X_LEFT_SWITCH, 6)), SEQ_DEF_1(INDEXED(JOYCODE_X_RIGHT_SWITCH, 6)) ) | |
| 451 | INPUT_PORT_ANALOG_TYPE( 8, PLAYER8, TRACKBALL_X, "Track X 8", SEQ_DEF_3(INDEXED(MOUSECODE_X, 7), SEQCODE_OR, INDEXED(JOYCODE_X, 7)), SEQ_DEF_1(INDEXED(JOYCODE_X_LEFT_SWITCH, 7)), SEQ_DEF_1(INDEXED(JOYCODE_X_RIGHT_SWITCH, 7)) ) | |
| 452 | ||
| 453 | INPUT_PORT_ANALOG_TYPE( 1, PLAYER1, TRACKBALL_Y, "Track Y", SEQ_DEF_3(INDEXED(MOUSECODE_Y, 0), SEQCODE_OR, INDEXED(JOYCODE_Y, 0)), SEQ_DEF_3(KEYCODE_UP, SEQCODE_OR, INDEXED(JOYCODE_Y_UP_SWITCH, 0)), SEQ_DEF_3(KEYCODE_DOWN, SEQCODE_OR, INDEXED(JOYCODE_Y_DOWN_SWITCH, 0)) ) | |
| 454 | INPUT_PORT_ANALOG_TYPE( 2, PLAYER2, TRACKBALL_Y, "Track Y 2", SEQ_DEF_3(INDEXED(MOUSECODE_Y, 1), SEQCODE_OR, INDEXED(JOYCODE_Y, 1)), SEQ_DEF_3(KEYCODE_R, SEQCODE_OR, INDEXED(JOYCODE_Y_UP_SWITCH, 1)), SEQ_DEF_3(KEYCODE_F, SEQCODE_OR, INDEXED(JOYCODE_Y_DOWN_SWITCH, 1)) ) | |
| 455 | INPUT_PORT_ANALOG_TYPE( 3, PLAYER3, TRACKBALL_Y, "Track Y 3", SEQ_DEF_3(INDEXED(MOUSECODE_Y, 2), SEQCODE_OR, INDEXED(JOYCODE_Y, 2)), SEQ_DEF_3(KEYCODE_I, SEQCODE_OR, INDEXED(JOYCODE_Y_UP_SWITCH, 2)), SEQ_DEF_3(KEYCODE_K, SEQCODE_OR, INDEXED(JOYCODE_Y_DOWN_SWITCH, 2)) ) | |
| 456 | INPUT_PORT_ANALOG_TYPE( 4, PLAYER4, TRACKBALL_Y, "Track Y 4", SEQ_DEF_3(INDEXED(MOUSECODE_Y, 3), SEQCODE_OR, INDEXED(JOYCODE_Y, 3)), SEQ_DEF_1(INDEXED(JOYCODE_Y_UP_SWITCH, 3)), SEQ_DEF_1(INDEXED(JOYCODE_Y_DOWN_SWITCH, 3)) ) | |
| 457 | INPUT_PORT_ANALOG_TYPE( 5, PLAYER5, TRACKBALL_Y, "Track Y 5", SEQ_DEF_3(INDEXED(MOUSECODE_Y, 4), SEQCODE_OR, INDEXED(JOYCODE_Y, 4)), SEQ_DEF_1(INDEXED(JOYCODE_Y_UP_SWITCH, 4)), SEQ_DEF_1(INDEXED(JOYCODE_Y_DOWN_SWITCH, 4)) ) | |
| 458 | INPUT_PORT_ANALOG_TYPE( 6, PLAYER6, TRACKBALL_Y, "Track Y 6", SEQ_DEF_3(INDEXED(MOUSECODE_Y, 5), SEQCODE_OR, INDEXED(JOYCODE_Y, 5)), SEQ_DEF_1(INDEXED(JOYCODE_Y_UP_SWITCH, 5)), SEQ_DEF_1(INDEXED(JOYCODE_Y_DOWN_SWITCH, 5)) ) | |
| 459 | INPUT_PORT_ANALOG_TYPE( 7, PLAYER7, TRACKBALL_Y, "Track Y 7", SEQ_DEF_3(INDEXED(MOUSECODE_Y, 6), SEQCODE_OR, INDEXED(JOYCODE_Y, 6)), SEQ_DEF_1(INDEXED(JOYCODE_Y_UP_SWITCH, 6)), SEQ_DEF_1(INDEXED(JOYCODE_Y_DOWN_SWITCH, 6)) ) | |
| 460 | INPUT_PORT_ANALOG_TYPE( 8, PLAYER8, TRACKBALL_Y, "Track Y 8", SEQ_DEF_3(INDEXED(MOUSECODE_Y, 7), SEQCODE_OR, INDEXED(JOYCODE_Y, 7)), SEQ_DEF_1(INDEXED(JOYCODE_Y_UP_SWITCH, 7)), SEQ_DEF_1(INDEXED(JOYCODE_Y_DOWN_SWITCH, 7)) ) | |
| 461 | ||
| 462 | INPUT_PORT_ANALOG_TYPE( 1, PLAYER1, AD_STICK_X, "AD Stick X", SEQ_DEF_3(INDEXED(JOYCODE_X, 0), SEQCODE_OR, INDEXED(MOUSECODE_X, 0)), SEQ_DEF_3(KEYCODE_LEFT, SEQCODE_OR, INDEXED(JOYCODE_X_LEFT_SWITCH, 0)), SEQ_DEF_3(KEYCODE_RIGHT, SEQCODE_OR, INDEXED(JOYCODE_X_RIGHT_SWITCH, 0)) ) | |
| 463 | INPUT_PORT_ANALOG_TYPE( 2, PLAYER2, AD_STICK_X, "AD Stick X 2", SEQ_DEF_3(INDEXED(JOYCODE_X, 1), SEQCODE_OR, INDEXED(MOUSECODE_X, 1)), SEQ_DEF_3(KEYCODE_D, SEQCODE_OR, INDEXED(JOYCODE_X_LEFT_SWITCH, 1)), SEQ_DEF_3(KEYCODE_G, SEQCODE_OR, INDEXED(JOYCODE_X_RIGHT_SWITCH, 1)) ) | |
| 464 | INPUT_PORT_ANALOG_TYPE( 3, PLAYER3, AD_STICK_X, "AD Stick X 3", SEQ_DEF_3(INDEXED(JOYCODE_X, 2), SEQCODE_OR, INDEXED(MOUSECODE_X, 2)), SEQ_DEF_3(KEYCODE_J, SEQCODE_OR, INDEXED(JOYCODE_X_LEFT_SWITCH, 2)), SEQ_DEF_3(KEYCODE_L, SEQCODE_OR, INDEXED(JOYCODE_X_RIGHT_SWITCH, 2)) ) | |
| 465 | INPUT_PORT_ANALOG_TYPE( 4, PLAYER4, AD_STICK_X, "AD Stick X 4", SEQ_DEF_3(INDEXED(JOYCODE_X, 3), SEQCODE_OR, INDEXED(MOUSECODE_X, 3)), SEQ_DEF_1(INDEXED(JOYCODE_X_LEFT_SWITCH, 3)), SEQ_DEF_1(INDEXED(JOYCODE_X_RIGHT_SWITCH, 3)) ) | |
| 466 | INPUT_PORT_ANALOG_TYPE( 5, PLAYER5, AD_STICK_X, "AD Stick X 5", SEQ_DEF_3(INDEXED(JOYCODE_X, 4), SEQCODE_OR, INDEXED(MOUSECODE_X, 4)), SEQ_DEF_1(INDEXED(JOYCODE_X_LEFT_SWITCH, 4)), SEQ_DEF_1(INDEXED(JOYCODE_X_RIGHT_SWITCH, 4)) ) | |
| 467 | INPUT_PORT_ANALOG_TYPE( 6, PLAYER6, AD_STICK_X, "AD Stick X 6", SEQ_DEF_3(INDEXED(JOYCODE_X, 5), SEQCODE_OR, INDEXED(MOUSECODE_X, 5)), SEQ_DEF_1(INDEXED(JOYCODE_X_LEFT_SWITCH, 5)), SEQ_DEF_1(INDEXED(JOYCODE_X_RIGHT_SWITCH, 5)) ) | |
| 468 | INPUT_PORT_ANALOG_TYPE( 7, PLAYER7, AD_STICK_X, "AD Stick X 7", SEQ_DEF_3(INDEXED(JOYCODE_X, 6), SEQCODE_OR, INDEXED(MOUSECODE_X, 6)), SEQ_DEF_1(INDEXED(JOYCODE_X_LEFT_SWITCH, 6)), SEQ_DEF_1(INDEXED(JOYCODE_X_RIGHT_SWITCH, 6)) ) | |
| 469 | INPUT_PORT_ANALOG_TYPE( 8, PLAYER8, AD_STICK_X, "AD Stick X 8", SEQ_DEF_3(INDEXED(JOYCODE_X, 7), SEQCODE_OR, INDEXED(MOUSECODE_X, 7)), SEQ_DEF_1(INDEXED(JOYCODE_X_LEFT_SWITCH, 7)), SEQ_DEF_1(INDEXED(JOYCODE_X_RIGHT_SWITCH, 7)) ) | |
| 470 | ||
| 471 | INPUT_PORT_ANALOG_TYPE( 1, PLAYER1, AD_STICK_Y, "AD Stick Y", SEQ_DEF_3(INDEXED(JOYCODE_Y, 0), SEQCODE_OR, INDEXED(MOUSECODE_Y, 0)), SEQ_DEF_3(KEYCODE_UP, SEQCODE_OR, INDEXED(JOYCODE_Y_UP_SWITCH, 0)), SEQ_DEF_3(KEYCODE_DOWN, SEQCODE_OR, INDEXED(JOYCODE_Y_DOWN_SWITCH, 0)) ) | |
| 472 | INPUT_PORT_ANALOG_TYPE( 2, PLAYER2, AD_STICK_Y, "AD Stick Y 2", SEQ_DEF_3(INDEXED(JOYCODE_Y, 1), SEQCODE_OR, INDEXED(MOUSECODE_Y, 1)), SEQ_DEF_3(KEYCODE_R, SEQCODE_OR, INDEXED(JOYCODE_Y_UP_SWITCH, 1)), SEQ_DEF_3(KEYCODE_F, SEQCODE_OR, INDEXED(JOYCODE_Y_DOWN_SWITCH, 1)) ) | |
| 473 | INPUT_PORT_ANALOG_TYPE( 3, PLAYER3, AD_STICK_Y, "AD Stick Y 3", SEQ_DEF_3(INDEXED(JOYCODE_Y, 2), SEQCODE_OR, INDEXED(MOUSECODE_Y, 2)), SEQ_DEF_3(KEYCODE_I, SEQCODE_OR, INDEXED(JOYCODE_Y_UP_SWITCH, 2)), SEQ_DEF_3(KEYCODE_K, SEQCODE_OR, INDEXED(JOYCODE_Y_DOWN_SWITCH, 2)) ) | |
| 474 | INPUT_PORT_ANALOG_TYPE( 4, PLAYER4, AD_STICK_Y, "AD Stick Y 4", SEQ_DEF_3(INDEXED(JOYCODE_Y, 3), SEQCODE_OR, INDEXED(MOUSECODE_Y, 3)), SEQ_DEF_1(INDEXED(JOYCODE_Y_UP_SWITCH, 3)), SEQ_DEF_1(INDEXED(JOYCODE_Y_DOWN_SWITCH, 3)) ) | |
| 475 | INPUT_PORT_ANALOG_TYPE( 5, PLAYER5, AD_STICK_Y, "AD Stick Y 5", SEQ_DEF_3(INDEXED(JOYCODE_Y, 4), SEQCODE_OR, INDEXED(MOUSECODE_Y, 4)), SEQ_DEF_1(INDEXED(JOYCODE_Y_UP_SWITCH, 4)), SEQ_DEF_1(INDEXED(JOYCODE_Y_DOWN_SWITCH, 4)) ) | |
| 476 | INPUT_PORT_ANALOG_TYPE( 6, PLAYER6, AD_STICK_Y, "AD Stick Y 6", SEQ_DEF_3(INDEXED(JOYCODE_Y, 5), SEQCODE_OR, INDEXED(MOUSECODE_Y, 5)), SEQ_DEF_1(INDEXED(JOYCODE_Y_UP_SWITCH, 5)), SEQ_DEF_1(INDEXED(JOYCODE_Y_DOWN_SWITCH, 5)) ) | |
| 477 | INPUT_PORT_ANALOG_TYPE( 7, PLAYER7, AD_STICK_Y, "AD Stick Y 7", SEQ_DEF_3(INDEXED(JOYCODE_Y, 6), SEQCODE_OR, INDEXED(MOUSECODE_Y, 6)), SEQ_DEF_1(INDEXED(JOYCODE_Y_UP_SWITCH, 6)), SEQ_DEF_1(INDEXED(JOYCODE_Y_DOWN_SWITCH, 6)) ) | |
| 478 | INPUT_PORT_ANALOG_TYPE( 8, PLAYER8, AD_STICK_Y, "AD Stick Y 8", SEQ_DEF_3(INDEXED(JOYCODE_Y, 7), SEQCODE_OR, INDEXED(MOUSECODE_Y, 7)), SEQ_DEF_1(INDEXED(JOYCODE_Y_UP_SWITCH, 7)), SEQ_DEF_1(INDEXED(JOYCODE_Y_DOWN_SWITCH, 7)) ) | |
| 479 | ||
| 480 | INPUT_PORT_ANALOG_TYPE( 1, PLAYER1, AD_STICK_Z, "AD Stick Z", SEQ_DEF_1(INDEXED(JOYCODE_Z, 0)), SEQ_DEF_0, SEQ_DEF_0 ) | |
| 481 | INPUT_PORT_ANALOG_TYPE( 2, PLAYER2, AD_STICK_Z, "AD Stick Z 2", SEQ_DEF_1(INDEXED(JOYCODE_Z, 1)), SEQ_DEF_0, SEQ_DEF_0 ) | |
| 482 | INPUT_PORT_ANALOG_TYPE( 3, PLAYER3, AD_STICK_Z, "AD Stick Z 3", SEQ_DEF_1(INDEXED(JOYCODE_Z, 2)), SEQ_DEF_0, SEQ_DEF_0 ) | |
| 483 | INPUT_PORT_ANALOG_TYPE( 4, PLAYER4, AD_STICK_Z, "AD Stick Z 4", SEQ_DEF_1(INDEXED(JOYCODE_Z, 3)), SEQ_DEF_0, SEQ_DEF_0 ) | |
| 484 | INPUT_PORT_ANALOG_TYPE( 5, PLAYER5, AD_STICK_Z, "AD Stick Z 5", SEQ_DEF_1(INDEXED(JOYCODE_Z, 4)), SEQ_DEF_0, SEQ_DEF_0 ) | |
| 485 | INPUT_PORT_ANALOG_TYPE( 6, PLAYER6, AD_STICK_Z, "AD Stick Z 6", SEQ_DEF_1(INDEXED(JOYCODE_Z, 5)), SEQ_DEF_0, SEQ_DEF_0 ) | |
| 486 | INPUT_PORT_ANALOG_TYPE( 7, PLAYER7, AD_STICK_Z, "AD Stick Z 7", SEQ_DEF_1(INDEXED(JOYCODE_Z, 6)), SEQ_DEF_0, SEQ_DEF_0 ) | |
| 487 | INPUT_PORT_ANALOG_TYPE( 8, PLAYER8, AD_STICK_Z, "AD Stick Z 8", SEQ_DEF_1(INDEXED(JOYCODE_Z, 7)), SEQ_DEF_0, SEQ_DEF_0 ) | |
| 488 | ||
| 489 | INPUT_PORT_ANALOG_TYPE( 1, PLAYER1, LIGHTGUN_X, "Lightgun X", SEQ_DEF_5(INDEXED(GUNCODE_X, 0), SEQCODE_OR, INDEXED(MOUSECODE_X, 0), SEQCODE_OR, INDEXED(JOYCODE_X, 0)), SEQ_DEF_3(KEYCODE_LEFT, SEQCODE_OR, INDEXED(JOYCODE_X_LEFT_SWITCH, 0)), SEQ_DEF_3(KEYCODE_RIGHT, SEQCODE_OR, INDEXED(JOYCODE_X_RIGHT_SWITCH, 0)) ) | |
| 490 | INPUT_PORT_ANALOG_TYPE( 2, PLAYER2, LIGHTGUN_X, "Lightgun X 2", SEQ_DEF_5(INDEXED(GUNCODE_X, 1), SEQCODE_OR, INDEXED(MOUSECODE_X, 1), SEQCODE_OR, INDEXED(JOYCODE_X, 1)), SEQ_DEF_3(KEYCODE_D, SEQCODE_OR, INDEXED(JOYCODE_X_LEFT_SWITCH, 1)), SEQ_DEF_3(KEYCODE_G, SEQCODE_OR, INDEXED(JOYCODE_X_RIGHT_SWITCH, 1)) ) | |
| 491 | INPUT_PORT_ANALOG_TYPE( 3, PLAYER3, LIGHTGUN_X, "Lightgun X 3", SEQ_DEF_5(INDEXED(GUNCODE_X, 2), SEQCODE_OR, INDEXED(MOUSECODE_X, 2), SEQCODE_OR, INDEXED(JOYCODE_X, 2)), SEQ_DEF_3(KEYCODE_J, SEQCODE_OR, INDEXED(JOYCODE_X_LEFT_SWITCH, 2)), SEQ_DEF_3(KEYCODE_L, SEQCODE_OR, INDEXED(JOYCODE_X_RIGHT_SWITCH, 2)) ) | |
| 492 | INPUT_PORT_ANALOG_TYPE( 4, PLAYER4, LIGHTGUN_X, "Lightgun X 4", SEQ_DEF_5(INDEXED(GUNCODE_X, 3), SEQCODE_OR, INDEXED(MOUSECODE_X, 3), SEQCODE_OR, INDEXED(JOYCODE_X, 3)), SEQ_DEF_1(INDEXED(JOYCODE_X_LEFT_SWITCH, 3)), SEQ_DEF_1(INDEXED(JOYCODE_X_RIGHT_SWITCH, 3)) ) | |
| 493 | INPUT_PORT_ANALOG_TYPE( 5, PLAYER5, LIGHTGUN_X, "Lightgun X 5", SEQ_DEF_5(INDEXED(GUNCODE_X, 4), SEQCODE_OR, INDEXED(MOUSECODE_X, 4), SEQCODE_OR, INDEXED(JOYCODE_X, 4)), SEQ_DEF_1(INDEXED(JOYCODE_X_LEFT_SWITCH, 4)), SEQ_DEF_1(INDEXED(JOYCODE_X_RIGHT_SWITCH, 4)) ) | |
| 494 | INPUT_PORT_ANALOG_TYPE( 6, PLAYER6, LIGHTGUN_X, "Lightgun X 6", SEQ_DEF_5(INDEXED(GUNCODE_X, 5), SEQCODE_OR, INDEXED(MOUSECODE_X, 5), SEQCODE_OR, INDEXED(JOYCODE_X, 5)), SEQ_DEF_1(INDEXED(JOYCODE_X_LEFT_SWITCH, 5)), SEQ_DEF_1(INDEXED(JOYCODE_X_RIGHT_SWITCH, 5)) ) | |
| 495 | INPUT_PORT_ANALOG_TYPE( 7, PLAYER7, LIGHTGUN_X, "Lightgun X 7", SEQ_DEF_5(INDEXED(GUNCODE_X, 6), SEQCODE_OR, INDEXED(MOUSECODE_X, 6), SEQCODE_OR, INDEXED(JOYCODE_X, 6)), SEQ_DEF_1(INDEXED(JOYCODE_X_LEFT_SWITCH, 6)), SEQ_DEF_1(INDEXED(JOYCODE_X_RIGHT_SWITCH, 6)) ) | |
| 496 | INPUT_PORT_ANALOG_TYPE( 8, PLAYER8, LIGHTGUN_X, "Lightgun X 8", SEQ_DEF_5(INDEXED(GUNCODE_X, 7), SEQCODE_OR, INDEXED(MOUSECODE_X, 7), SEQCODE_OR, INDEXED(JOYCODE_X, 7)), SEQ_DEF_1(INDEXED(JOYCODE_X_LEFT_SWITCH, 7)), SEQ_DEF_1(INDEXED(JOYCODE_X_RIGHT_SWITCH, 7)) ) | |
| 497 | ||
| 498 | INPUT_PORT_ANALOG_TYPE( 1, PLAYER1, LIGHTGUN_Y, "Lightgun Y", SEQ_DEF_5(INDEXED(GUNCODE_Y, 0), SEQCODE_OR, INDEXED(MOUSECODE_Y, 0), SEQCODE_OR, INDEXED(JOYCODE_Y, 0)), SEQ_DEF_3(KEYCODE_UP, SEQCODE_OR, INDEXED(JOYCODE_Y_UP_SWITCH, 0)), SEQ_DEF_3(KEYCODE_DOWN, SEQCODE_OR, INDEXED(JOYCODE_Y_DOWN_SWITCH, 0)) ) | |
| 499 | INPUT_PORT_ANALOG_TYPE( 2, PLAYER2, LIGHTGUN_Y, "Lightgun Y 2", SEQ_DEF_5(INDEXED(GUNCODE_Y, 1), SEQCODE_OR, INDEXED(MOUSECODE_Y, 1), SEQCODE_OR, INDEXED(JOYCODE_Y, 1)), SEQ_DEF_3(KEYCODE_R, SEQCODE_OR, INDEXED(JOYCODE_Y_UP_SWITCH, 1)), SEQ_DEF_3(KEYCODE_F, SEQCODE_OR, INDEXED(JOYCODE_Y_DOWN_SWITCH, 1)) ) | |
| 500 | INPUT_PORT_ANALOG_TYPE( 3, PLAYER3, LIGHTGUN_Y, "Lightgun Y 3", SEQ_DEF_5(INDEXED(GUNCODE_Y, 2), SEQCODE_OR, INDEXED(MOUSECODE_Y, 2), SEQCODE_OR, INDEXED(JOYCODE_Y, 2)), SEQ_DEF_3(KEYCODE_I, SEQCODE_OR, INDEXED(JOYCODE_Y_UP_SWITCH, 2)), SEQ_DEF_3(KEYCODE_K, SEQCODE_OR, INDEXED(JOYCODE_Y_DOWN_SWITCH, 2)) ) | |
| 501 | INPUT_PORT_ANALOG_TYPE( 4, PLAYER4, LIGHTGUN_Y, "Lightgun Y 4", SEQ_DEF_5(INDEXED(GUNCODE_Y, 3), SEQCODE_OR, INDEXED(MOUSECODE_Y, 3), SEQCODE_OR, INDEXED(JOYCODE_Y, 3)), SEQ_DEF_1(INDEXED(JOYCODE_Y_UP_SWITCH, 3)), SEQ_DEF_1(INDEXED(JOYCODE_Y_DOWN_SWITCH, 3)) ) | |
| 502 | INPUT_PORT_ANALOG_TYPE( 5, PLAYER5, LIGHTGUN_Y, "Lightgun Y 5", SEQ_DEF_5(INDEXED(GUNCODE_Y, 4), SEQCODE_OR, INDEXED(MOUSECODE_Y, 4), SEQCODE_OR, INDEXED(JOYCODE_Y, 4)), SEQ_DEF_1(INDEXED(JOYCODE_Y_UP_SWITCH, 4)), SEQ_DEF_1(INDEXED(JOYCODE_Y_DOWN_SWITCH, 4)) ) | |
| 503 | INPUT_PORT_ANALOG_TYPE( 6, PLAYER6, LIGHTGUN_Y, "Lightgun Y 6", SEQ_DEF_5(INDEXED(GUNCODE_Y, 5), SEQCODE_OR, INDEXED(MOUSECODE_Y, 5), SEQCODE_OR, INDEXED(JOYCODE_Y, 5)), SEQ_DEF_1(INDEXED(JOYCODE_Y_UP_SWITCH, 5)), SEQ_DEF_1(INDEXED(JOYCODE_Y_DOWN_SWITCH, 5)) ) | |
| 504 | INPUT_PORT_ANALOG_TYPE( 7, PLAYER7, LIGHTGUN_Y, "Lightgun Y 7", SEQ_DEF_5(INDEXED(GUNCODE_Y, 6), SEQCODE_OR, INDEXED(MOUSECODE_Y, 6), SEQCODE_OR, INDEXED(JOYCODE_Y, 6)), SEQ_DEF_1(INDEXED(JOYCODE_Y_UP_SWITCH, 6)), SEQ_DEF_1(INDEXED(JOYCODE_Y_DOWN_SWITCH, 6)) ) | |
| 505 | INPUT_PORT_ANALOG_TYPE( 8, PLAYER8, LIGHTGUN_Y, "Lightgun Y 8", SEQ_DEF_5(INDEXED(GUNCODE_Y, 7), SEQCODE_OR, INDEXED(MOUSECODE_Y, 7), SEQCODE_OR, INDEXED(JOYCODE_Y, 7)), SEQ_DEF_1(INDEXED(JOYCODE_Y_UP_SWITCH, 7)), SEQ_DEF_1(INDEXED(JOYCODE_Y_DOWN_SWITCH, 7)) ) | |
| 506 | ||
| 507 | INPUT_PORT_ANALOG_TYPE( 1, PLAYER1, MOUSE_X, "Mouse X", SEQ_DEF_1(INDEXED(MOUSECODE_X, 0)), SEQ_DEF_3(KEYCODE_LEFT, SEQCODE_OR, INDEXED(JOYCODE_X_LEFT_SWITCH, 0)), SEQ_DEF_3(KEYCODE_RIGHT, SEQCODE_OR, INDEXED(JOYCODE_X_RIGHT_SWITCH, 0)) ) | |
| 508 | INPUT_PORT_ANALOG_TYPE( 2, PLAYER2, MOUSE_X, "Mouse X 2", SEQ_DEF_1(INDEXED(MOUSECODE_X, 1)), SEQ_DEF_3(KEYCODE_D, SEQCODE_OR, INDEXED(JOYCODE_X_LEFT_SWITCH, 1)), SEQ_DEF_3(KEYCODE_G, SEQCODE_OR, INDEXED(JOYCODE_X_RIGHT_SWITCH, 1)) ) | |
| 509 | INPUT_PORT_ANALOG_TYPE( 3, PLAYER3, MOUSE_X, "Mouse X 3", SEQ_DEF_1(INDEXED(MOUSECODE_X, 2)), SEQ_DEF_3(KEYCODE_J, SEQCODE_OR, INDEXED(JOYCODE_X_LEFT_SWITCH, 2)), SEQ_DEF_3(KEYCODE_L, SEQCODE_OR, INDEXED(JOYCODE_X_RIGHT_SWITCH, 2)) ) | |
| 510 | INPUT_PORT_ANALOG_TYPE( 4, PLAYER4, MOUSE_X, "Mouse X 4", SEQ_DEF_1(INDEXED(MOUSECODE_X, 3)), SEQ_DEF_1(INDEXED(JOYCODE_X_LEFT_SWITCH, 3)), SEQ_DEF_1(INDEXED(JOYCODE_X_RIGHT_SWITCH, 3)) ) | |
| 511 | INPUT_PORT_ANALOG_TYPE( 5, PLAYER5, MOUSE_X, "Mouse X 5", SEQ_DEF_1(INDEXED(MOUSECODE_X, 4)), SEQ_DEF_1(INDEXED(JOYCODE_X_LEFT_SWITCH, 4)), SEQ_DEF_1(INDEXED(JOYCODE_X_RIGHT_SWITCH, 4)) ) | |
| 512 | INPUT_PORT_ANALOG_TYPE( 6, PLAYER6, MOUSE_X, "Mouse X 6", SEQ_DEF_1(INDEXED(MOUSECODE_X, 5)), SEQ_DEF_1(INDEXED(JOYCODE_X_LEFT_SWITCH, 5)), SEQ_DEF_1(INDEXED(JOYCODE_X_RIGHT_SWITCH, 5)) ) | |
| 513 | INPUT_PORT_ANALOG_TYPE( 7, PLAYER7, MOUSE_X, "Mouse X 7", SEQ_DEF_1(INDEXED(MOUSECODE_X, 6)), SEQ_DEF_1(INDEXED(JOYCODE_X_LEFT_SWITCH, 6)), SEQ_DEF_1(INDEXED(JOYCODE_X_RIGHT_SWITCH, 6)) ) | |
| 514 | INPUT_PORT_ANALOG_TYPE( 8, PLAYER8, MOUSE_X, "Mouse X 8", SEQ_DEF_1(INDEXED(MOUSECODE_X, 7)), SEQ_DEF_1(INDEXED(JOYCODE_X_LEFT_SWITCH, 7)), SEQ_DEF_1(INDEXED(JOYCODE_X_RIGHT_SWITCH, 7)) ) | |
| 515 | ||
| 516 | INPUT_PORT_ANALOG_TYPE( 1, PLAYER1, MOUSE_Y, "Mouse Y", SEQ_DEF_1(INDEXED(MOUSECODE_Y, 0)), SEQ_DEF_3(KEYCODE_UP, SEQCODE_OR, INDEXED(JOYCODE_Y_UP_SWITCH, 0)), SEQ_DEF_3(KEYCODE_DOWN, SEQCODE_OR, INDEXED(JOYCODE_Y_DOWN_SWITCH, 0)) ) | |
| 517 | INPUT_PORT_ANALOG_TYPE( 2, PLAYER2, MOUSE_Y, "Mouse Y 2", SEQ_DEF_1(INDEXED(MOUSECODE_Y, 1)), SEQ_DEF_3(KEYCODE_R, SEQCODE_OR, INDEXED(JOYCODE_Y_UP_SWITCH, 1)), SEQ_DEF_3(KEYCODE_F, SEQCODE_OR, INDEXED(JOYCODE_Y_DOWN_SWITCH, 1)) ) | |
| 518 | INPUT_PORT_ANALOG_TYPE( 3, PLAYER3, MOUSE_Y, "Mouse Y 3", SEQ_DEF_1(INDEXED(MOUSECODE_Y, 2)), SEQ_DEF_3(KEYCODE_I, SEQCODE_OR, INDEXED(JOYCODE_Y_UP_SWITCH, 2)), SEQ_DEF_3(KEYCODE_K, SEQCODE_OR, INDEXED(JOYCODE_Y_DOWN_SWITCH, 2)) ) | |
| 519 | INPUT_PORT_ANALOG_TYPE( 4, PLAYER4, MOUSE_Y, "Mouse Y 4", SEQ_DEF_1(INDEXED(MOUSECODE_Y, 3)), SEQ_DEF_1(INDEXED(JOYCODE_Y_UP_SWITCH, 3)), SEQ_DEF_1(INDEXED(JOYCODE_Y_DOWN_SWITCH, 3)) ) | |
| 520 | INPUT_PORT_ANALOG_TYPE( 5, PLAYER5, MOUSE_Y, "Mouse Y 5", SEQ_DEF_1(INDEXED(MOUSECODE_Y, 4)), SEQ_DEF_1(INDEXED(JOYCODE_Y_UP_SWITCH, 4)), SEQ_DEF_1(INDEXED(JOYCODE_Y_DOWN_SWITCH, 4)) ) | |
| 521 | INPUT_PORT_ANALOG_TYPE( 6, PLAYER6, MOUSE_Y, "Mouse Y 6", SEQ_DEF_1(INDEXED(MOUSECODE_Y, 5)), SEQ_DEF_1(INDEXED(JOYCODE_Y_UP_SWITCH, 5)), SEQ_DEF_1(INDEXED(JOYCODE_Y_DOWN_SWITCH, 5)) ) | |
| 522 | INPUT_PORT_ANALOG_TYPE( 7, PLAYER7, MOUSE_Y, "Mouse Y 7", SEQ_DEF_1(INDEXED(MOUSECODE_Y, 6)), SEQ_DEF_1(INDEXED(JOYCODE_Y_UP_SWITCH, 6)), SEQ_DEF_1(INDEXED(JOYCODE_Y_DOWN_SWITCH, 6)) ) | |
| 523 | INPUT_PORT_ANALOG_TYPE( 8, PLAYER8, MOUSE_Y, "Mouse Y 8", SEQ_DEF_1(INDEXED(MOUSECODE_Y, 7)), SEQ_DEF_1(INDEXED(JOYCODE_Y_UP_SWITCH, 7)), SEQ_DEF_1(INDEXED(JOYCODE_Y_DOWN_SWITCH, 7)) ) | |
| 524 | ||
| 525 | INPUT_PORT_DIGITAL_TYPE( 0, OTHER, KEYBOARD, "Keyboard", SEQ_DEF_0 ) | |
| 526 | ||
| 527 | INPUT_PORT_DIGITAL_TYPE( 0, UI, UI_ON_SCREEN_DISPLAY,"On Screen Display", SEQ_DEF_1(KEYCODE_TILDE) ) | |
| 528 | INPUT_PORT_DIGITAL_TYPE( 0, UI, UI_DEBUG_BREAK, "Break in Debugger", SEQ_DEF_1(KEYCODE_TILDE) ) | |
| 529 | INPUT_PORT_DIGITAL_TYPE( 0, UI, UI_CONFIGURE, "Config Menu", SEQ_DEF_1(KEYCODE_TAB) ) | |
| 530 | INPUT_PORT_DIGITAL_TYPE( 0, UI, UI_PAUSE, "Pause", SEQ_DEF_1(KEYCODE_P) ) | |
| 531 | INPUT_PORT_DIGITAL_TYPE( 0, UI, UI_RESET_MACHINE, "Reset Game", SEQ_DEF_2(KEYCODE_F3, KEYCODE_LSHIFT) ) | |
| 532 | INPUT_PORT_DIGITAL_TYPE( 0, UI, UI_SOFT_RESET, "Soft Reset", SEQ_DEF_3(KEYCODE_F3, SEQCODE_NOT, KEYCODE_LSHIFT) ) | |
| 533 | INPUT_PORT_DIGITAL_TYPE( 0, UI, UI_SHOW_GFX, "Show Gfx", SEQ_DEF_1(KEYCODE_F4) ) | |
| 534 | INPUT_PORT_DIGITAL_TYPE( 0, UI, UI_FRAMESKIP_DEC, "Frameskip Dec", SEQ_DEF_1(KEYCODE_F8) ) | |
| 535 | INPUT_PORT_DIGITAL_TYPE( 0, UI, UI_FRAMESKIP_INC, "Frameskip Inc", SEQ_DEF_1(KEYCODE_F9) ) | |
| 536 | INPUT_PORT_DIGITAL_TYPE( 0, UI, UI_THROTTLE, "Throttle", SEQ_DEF_1(KEYCODE_F10) ) | |
| 537 | INPUT_PORT_DIGITAL_TYPE( 0, UI, UI_FAST_FORWARD, "Fast Forward", SEQ_DEF_1(KEYCODE_INSERT) ) | |
| 538 | INPUT_PORT_DIGITAL_TYPE( 0, UI, UI_SHOW_FPS, "Show FPS", SEQ_DEF_5(KEYCODE_F11, SEQCODE_NOT, KEYCODE_LCONTROL, SEQCODE_NOT, KEYCODE_LSHIFT) ) | |
| 539 | INPUT_PORT_DIGITAL_TYPE( 0, UI, UI_SNAPSHOT, "Save Snapshot", SEQ_DEF_3(KEYCODE_F12, SEQCODE_NOT, KEYCODE_LSHIFT) ) | |
| 540 | INPUT_PORT_DIGITAL_TYPE( 0, UI, UI_RECORD_MOVIE, "Record Movie", SEQ_DEF_2(KEYCODE_F12, KEYCODE_LSHIFT) ) | |
| 541 | INPUT_PORT_DIGITAL_TYPE( 0, UI, UI_TOGGLE_CHEAT, "Toggle Cheat", SEQ_DEF_1(KEYCODE_F6) ) | |
| 542 | INPUT_PORT_DIGITAL_TYPE( 0, UI, UI_UP, "UI Up", SEQ_DEF_3(KEYCODE_UP, SEQCODE_OR, INDEXED(JOYCODE_Y_UP_SWITCH, 0)) ) | |
| 543 | INPUT_PORT_DIGITAL_TYPE( 0, UI, UI_DOWN, "UI Down", SEQ_DEF_3(KEYCODE_DOWN, SEQCODE_OR, INDEXED(JOYCODE_Y_DOWN_SWITCH, 0)) ) | |
| 544 | INPUT_PORT_DIGITAL_TYPE( 0, UI, UI_LEFT, "UI Left", SEQ_DEF_3(KEYCODE_LEFT, SEQCODE_OR, INDEXED(JOYCODE_X_LEFT_SWITCH, 0)) ) | |
| 545 | INPUT_PORT_DIGITAL_TYPE( 0, UI, UI_RIGHT, "UI Right", SEQ_DEF_3(KEYCODE_RIGHT, SEQCODE_OR, INDEXED(JOYCODE_X_RIGHT_SWITCH, 0)) ) | |
| 546 | INPUT_PORT_DIGITAL_TYPE( 0, UI, UI_HOME, "UI Home", SEQ_DEF_1(KEYCODE_HOME) ) | |
| 547 | INPUT_PORT_DIGITAL_TYPE( 0, UI, UI_END, "UI End", SEQ_DEF_1(KEYCODE_END) ) | |
| 548 | INPUT_PORT_DIGITAL_TYPE( 0, UI, UI_PAGE_UP, "UI Page Up", SEQ_DEF_1(KEYCODE_PGUP) ) | |
| 549 | INPUT_PORT_DIGITAL_TYPE( 0, UI, UI_PAGE_DOWN, "UI Page Down", SEQ_DEF_1(KEYCODE_PGDN) ) | |
| 550 | INPUT_PORT_DIGITAL_TYPE( 0, UI, UI_SELECT, "UI Select", SEQ_DEF_3(KEYCODE_ENTER, SEQCODE_OR, INDEXED(JOYCODE_BUTTON1, 0)) ) | |
| 551 | INPUT_PORT_DIGITAL_TYPE( 0, UI, UI_CANCEL, "UI Cancel", SEQ_DEF_1(KEYCODE_ESC) ) | |
| 552 | INPUT_PORT_DIGITAL_TYPE( 0, UI, UI_CLEAR, "UI Clear", SEQ_DEF_1(KEYCODE_DEL) ) | |
| 553 | INPUT_PORT_DIGITAL_TYPE( 0, UI, UI_ZOOM_IN, "UI Zoom In", SEQ_DEF_1(KEYCODE_EQUALS) ) | |
| 554 | INPUT_PORT_DIGITAL_TYPE( 0, UI, UI_ZOOM_OUT, "UI Zoom Out", SEQ_DEF_1(KEYCODE_MINUS) ) | |
| 555 | INPUT_PORT_DIGITAL_TYPE( 0, UI, UI_PREV_GROUP, "UI Previous Group", SEQ_DEF_1(KEYCODE_OPENBRACE) ) | |
| 556 | INPUT_PORT_DIGITAL_TYPE( 0, UI, UI_NEXT_GROUP, "UI Next Group", SEQ_DEF_1(KEYCODE_CLOSEBRACE) ) | |
| 557 | INPUT_PORT_DIGITAL_TYPE( 0, UI, UI_ROTATE, "UI Rotate", SEQ_DEF_1(KEYCODE_R) ) | |
| 558 | INPUT_PORT_DIGITAL_TYPE( 0, UI, UI_SHOW_PROFILER, "Show Profiler", SEQ_DEF_2(KEYCODE_F11, KEYCODE_LSHIFT) ) | |
| 559 | #ifdef MESS | |
| 560 | INPUT_PORT_DIGITAL_TYPE( 0, UI, UI_TOGGLE_UI, "UI Toggle", SEQ_DEF_3(KEYCODE_SCRLOCK, SEQCODE_NOT, KEYCODE_LSHIFT) ) | |
| 561 | INPUT_PORT_DIGITAL_TYPE( 0, UI, UI_PASTE, "UI Paste Text", SEQ_DEF_2(KEYCODE_SCRLOCK, KEYCODE_LSHIFT) ) | |
| 562 | #endif /* MESS */ | |
| 563 | INPUT_PORT_DIGITAL_TYPE( 0, UI, UI_TOGGLE_DEBUG, "Toggle Debugger", SEQ_DEF_1(KEYCODE_F5) ) | |
| 564 | INPUT_PORT_DIGITAL_TYPE( 0, UI, UI_SAVE_STATE, "Save State", SEQ_DEF_2(KEYCODE_F7, KEYCODE_LSHIFT) ) | |
| 565 | INPUT_PORT_DIGITAL_TYPE( 0, UI, UI_LOAD_STATE, "Load State", SEQ_DEF_3(KEYCODE_F7, SEQCODE_NOT, KEYCODE_LSHIFT) ) | |
| 566 | INPUT_PORT_DIGITAL_TYPE( 0, UI, UI_ADD_CHEAT, "Add Cheat", SEQ_DEF_1(KEYCODE_A) ) | |
| 567 | INPUT_PORT_DIGITAL_TYPE( 0, UI, UI_DELETE_CHEAT, "Delete Cheat", SEQ_DEF_1(KEYCODE_D) ) | |
| 568 | INPUT_PORT_DIGITAL_TYPE( 0, UI, UI_SAVE_CHEAT, "Save Cheat", SEQ_DEF_1(KEYCODE_S) ) | |
| 569 | INPUT_PORT_DIGITAL_TYPE( 0, UI, UI_WATCH_VALUE, "Watch Value", SEQ_DEF_1(KEYCODE_W) ) | |
| 570 | INPUT_PORT_DIGITAL_TYPE( 0, UI, UI_EDIT_CHEAT, "Edit Cheat", SEQ_DEF_1(KEYCODE_E) ) | |
| 571 | INPUT_PORT_DIGITAL_TYPE( 0, UI, UI_RELOAD_CHEAT, "Reload Database", SEQ_DEF_1(KEYCODE_L) ) | |
| 572 | INPUT_PORT_DIGITAL_TYPE( 0, UI, UI_TOGGLE_CROSSHAIR, "Toggle Crosshair", SEQ_DEF_1(KEYCODE_F1) ) | |
| 573 | ||
| 574 | INPUT_PORT_DIGITAL_TYPE( 0, UI, OSD_1, NULL, SEQ_DEF_0 ) | |
| 575 | INPUT_PORT_DIGITAL_TYPE( 0, UI, OSD_2, NULL, SEQ_DEF_0 ) | |
| 576 | INPUT_PORT_DIGITAL_TYPE( 0, UI, OSD_3, NULL, SEQ_DEF_0 ) | |
| 577 | INPUT_PORT_DIGITAL_TYPE( 0, UI, OSD_4, NULL, SEQ_DEF_0 ) | |
| 578 | INPUT_PORT_DIGITAL_TYPE( 0, UI, OSD_5, NULL, SEQ_DEF_0 ) | |
| 579 | INPUT_PORT_DIGITAL_TYPE( 0, UI, OSD_6, NULL, SEQ_DEF_0 ) | |
| 580 | INPUT_PORT_DIGITAL_TYPE( 0, UI, OSD_7, NULL, SEQ_DEF_0 ) | |
| 581 | INPUT_PORT_DIGITAL_TYPE( 0, UI, OSD_8, NULL, SEQ_DEF_0 ) | |
| 582 | INPUT_PORT_DIGITAL_TYPE( 0, UI, OSD_9, NULL, SEQ_DEF_0 ) | |
| 583 | INPUT_PORT_DIGITAL_TYPE( 0, UI, OSD_10, NULL, SEQ_DEF_0 ) | |
| 584 | INPUT_PORT_DIGITAL_TYPE( 0, UI, OSD_11, NULL, SEQ_DEF_0 ) | |
| 585 | INPUT_PORT_DIGITAL_TYPE( 0, UI, OSD_12, NULL, SEQ_DEF_0 ) | |
| 586 | INPUT_PORT_DIGITAL_TYPE( 0, UI, OSD_13, NULL, SEQ_DEF_0 ) | |
| 587 | INPUT_PORT_DIGITAL_TYPE( 0, UI, OSD_14, NULL, SEQ_DEF_0 ) | |
| 588 | INPUT_PORT_DIGITAL_TYPE( 0, UI, OSD_15, NULL, SEQ_DEF_0 ) | |
| 589 | INPUT_PORT_DIGITAL_TYPE( 0, UI, OSD_16, NULL, SEQ_DEF_0 ) | |
| 590 | INPUT_PORT_DIGITAL_TYPE( 0, INVALID, UNKNOWN, NULL, SEQ_DEF_0 ) | |
| 591 | INPUT_PORT_DIGITAL_TYPE( 0, INVALID, UNUSED, NULL, SEQ_DEF_0 ) | |
| 592 | INPUT_PORT_DIGITAL_TYPE( 0, INVALID, SPECIAL, NULL, SEQ_DEF_0 ) | |
| 593 | INPUT_PORT_DIGITAL_TYPE( 0, INVALID, OTHER, NULL, SEQ_DEF_0 ) | |
| 594 | INPUT_PORT_DIGITAL_TYPE( 0, INVALID, ADJUSTER, NULL, SEQ_DEF_0 ) | |
| 595 | INPUT_PORT_DIGITAL_TYPE( 0, INVALID, DIPSWITCH, NULL, SEQ_DEF_0 ) | |
| 596 | INPUT_PORT_DIGITAL_TYPE( 0, INVALID, CONFIG, NULL, SEQ_DEF_0 ) | |
| 597 | INPUT_PORT_DIGITAL_TYPE( 0, INVALID, CATEGORY, NULL, SEQ_DEF_0 ) | |
| 598 | }; |
| r2724 | r2725 | |
|---|---|---|
| 74 | 74 | { |
| 75 | 75 | int active; |
| 76 | 76 | cia_type_t type; |
| 77 | void (*irq_func)(int state); | |
| 77 | void (*irq_func)(running_machine *machine, int state); | |
| 78 | 78 | int clock; |
| 79 | 79 | |
| 80 | 80 | cia_port port[2]; |
| r2724 | r2725 | |
| 298 | 298 | { |
| 299 | 299 | cia->irq = new_irq; |
| 300 | 300 | if (cia->irq_func) |
| 301 | cia->irq_func(cia->irq); | |
| 301 | cia->irq_func(Machine, cia->irq); | |
| 302 | 302 | } |
| 303 | 303 | } |
| 304 | 304 |
| r2724 | r2725 | |
|---|---|---|
| 1 | 1 | /* LSI Logic LSI53C810A PCI to SCSI I/O Processor */ |
| 2 | 2 | |
| 3 | 3 | #include "driver.h" |
| 4 | #include "deprecat.h" | |
| 4 | 5 | #include "53c810.h" |
| 5 | 6 | |
| 6 | 7 | #define DMA_MAX_ICOUNT 512 /* Maximum number of DMA Scripts opcodes to run */ |
| r2724 | r2725 | |
| 41 | 42 | int halted; |
| 42 | 43 | int carry; |
| 43 | 44 | UINT32 (* fetch)(UINT32 dsp); |
| 44 | void (* irq_callback)( | |
| 45 | void (* irq_callback)(running_machine *machine); | |
| 45 | 46 | void (* dma_callback)(UINT32, UINT32, int, int); |
| 46 | 47 | } lsi810; |
| 47 | 48 | |
| r2724 | r2725 | |
| 94 | 95 | lsi810.dstat |= 0x4; /* SIR (SCRIPTS Interrupt Instruction Received) */ |
| 95 | 96 | |
| 96 | 97 | if(intf->irq_callback != NULL) { |
| 97 | intf->irq_callback(); | |
| 98 | intf->irq_callback(Machine); | |
| 98 | 99 | } |
| 99 | 100 | lsi810.dma_icount = 0; |
| 100 | 101 | lsi810.halted = 1; |
| r2724 | r2725 | |
| 518 | 519 | return 0; |
| 519 | 520 | } |
| 520 | 521 | |
| 521 | void lsi53c810_reg_w(int reg, UINT8 value) | |
| 522 | void lsi53c810_reg_w(running_machine *machine, int reg, UINT8 value) | |
| 522 | 523 | { |
| 523 | 524 | logerror("53c810: %02x to reg %d:0x%x (PC=%x)\n", value, reg, reg, activecpu_get_pc()); |
| 524 | 525 | switch(reg) |
| r2724 | r2725 | |
| 614 | 615 | lsi810.istat |= 0x3; /* DMA interrupt pending */ |
| 615 | 616 | lsi810.dstat |= 0x8; /* SSI (Single Step Interrupt) */ |
| 616 | 617 | if(intf->irq_callback != NULL) { |
| 617 | intf->irq_callback(); | |
| 618 | intf->irq_callback(machine); | |
| 618 | 619 | } |
| 619 | 620 | } |
| 620 | 621 | else if(lsi810.dcntl & 0x04 && !lsi810.halted) /* manual start DMA */ |
| r2724 | r2725 | |
|---|---|---|
| 20 | 20 | struct _cia6526_interface |
| 21 | 21 | { |
| 22 | 22 | cia_type_t type; |
| 23 | void (*irq_func)(int state); | |
| 23 | void (*irq_func)(running_machine *machine, int state); | |
| 24 | 24 | int clock; |
| 25 | 25 | int tod_clock; |
| 26 | 26 |
| r2724 | r2725 | |
|---|---|---|
| 6 | 6 | struct LSI53C810interface |
| 7 | 7 | { |
| 8 | 8 | const SCSIConfigTable *scsidevs; /* SCSI devices */ |
| 9 | void (*irq_callback)( | |
| 9 | void (*irq_callback)(running_machine *machine); | |
| 10 | 10 | void (*dma_callback)(UINT32, UINT32, int, int); /* DMA callback */ |
| 11 | 11 | UINT32 (*fetch)(UINT32 dsp); |
| 12 | 12 | }; |
| r2724 | r2725 | |
| 20 | 20 | extern void *lsi53c810_get_device(int id); |
| 21 | 21 | |
| 22 | 22 | UINT8 lsi53c810_reg_r(int reg); |
| 23 | void lsi53c810_reg_w(int reg, UINT8 value); | |
| 23 | void lsi53c810_reg_w(running_machine *machine, int reg, UINT8 value); | |
| 24 | 24 | |
| 25 | 25 | unsigned lsi53c810_dasm(char *buf, UINT32 pc); |
| 26 | 26 |
| r2724 | r2725 | |
|---|---|---|
| 195 | 195 | pias[i].in_ca2 = TRUE; |
| 196 | 196 | |
| 197 | 197 | /* clear the IRQs */ |
| 198 | if (intf->irq_a_func) (*intf->irq_a_func)(FALSE); | |
| 199 | if (intf->irq_b_func) (*intf->irq_b_func)(FALSE); | |
| 198 | if (intf->irq_a_func) (*intf->irq_a_func)(Machine, FALSE); | |
| 199 | if (intf->irq_b_func) (*intf->irq_b_func)(Machine, FALSE); | |
| 200 | 200 | } |
| 201 | 201 | } |
| 202 | 202 | |
| r2724 | r2725 | |
| 219 | 219 | { |
| 220 | 220 | p->irq_a_state = new_state; |
| 221 | 221 | |
| 222 | if (p->intf->irq_a_func) (p->intf->irq_a_func)(p->irq_a_state); | |
| 222 | if (p->intf->irq_a_func) (p->intf->irq_a_func)(Machine, p->irq_a_state); | |
| 223 | 223 | } |
| 224 | 224 | |
| 225 | 225 | /* then do IRQ B */ |
| r2724 | r2725 | |
| 229 | 229 | { |
| 230 | 230 | p->irq_b_state = new_state; |
| 231 | 231 | |
| 232 | if (p->intf->irq_b_func) (p->intf->irq_b_func)(p->irq_b_state); | |
| 232 | if (p->intf->irq_b_func) (p->intf->irq_b_func)(Machine, p->irq_b_state); | |
| 233 | 233 | } |
| 234 | 234 | } |
| 235 | 235 |
| r2724 | r2725 | |
|---|---|---|
| 85 | 85 | // callbacks |
| 86 | 86 | UINT8 (*input_port_read)(void); |
| 87 | 87 | void (*tx_callback)(int channel, UINT8 data); |
| 88 | void (*irq_handler)( | |
| 88 | void (*irq_handler)(running_machine *machine, int vector); | |
| 89 | 89 | |
| 90 | 90 | DUART_68681_CHANNEL channel[2]; |
| 91 | 91 | } DUART_68681; |
| 92 | 92 | |
| 93 | 93 | static DUART_68681 duart_68681; |
| 94 | 94 | |
| 95 | static void duart_68681_update_interrupts( | |
| 95 | static void duart_68681_update_interrupts( running_machine *machine ) | |
| 96 | 96 | { |
| 97 | 97 | if ( (duart_68681.ISR & duart_68681.IMR) != 0 ) |
| 98 | 98 | { |
| 99 | 99 | if ( duart_68681.irq_handler ) |
| 100 | 100 | { |
| 101 | duart_68681.irq_handler( duart_68681.IVR ); | |
| 101 | duart_68681.irq_handler( machine, duart_68681.IVR ); | |
| 102 | 102 | } |
| 103 | 103 | } |
| 104 | 104 | }; |
| r2724 | r2725 | |
| 192 | 192 | } |
| 193 | 193 | }; |
| 194 | 194 | |
| 195 | static UINT8 duart_68681_read_rx_fifo( int ch ) | |
| 195 | static UINT8 duart_68681_read_rx_fifo( running_machine *machine, int ch ) | |
| 196 | 196 | { |
| 197 | 197 | UINT8 r; |
| 198 | 198 | |
| r2724 | r2725 | |
| 234 | 234 | duart_68681.ISR &= ~INT_RXRDY_FFULLB; |
| 235 | 235 | } |
| 236 | 236 | } |
| 237 | duart_68681_update_interrupts(); | |
| 237 | duart_68681_update_interrupts(machine); | |
| 238 | 238 | return r; |
| 239 | 239 | }; |
| 240 | 240 | |
| r2724 | r2725 | |
| 253 | 253 | else |
| 254 | 254 | duart_68681.ISR |= INT_TXRDYB; |
| 255 | 255 | |
| 256 | duart_68681_update_interrupts(); | |
| 256 | duart_68681_update_interrupts(machine); | |
| 257 | 257 | timer_adjust_oneshot(duart_68681.channel[ch].tx_timer, attotime_never, ch); |
| 258 | 258 | }; |
| 259 | 259 | |
| 260 | static void duart_68681_write_TX(int ch, UINT8 data) | |
| 260 | static void duart_68681_write_TX(running_machine *machine, int ch, UINT8 data) | |
| 261 | 261 | { |
| 262 | 262 | attotime period; |
| 263 | 263 | |
| r2724 | r2725 | |
| 271 | 271 | else |
| 272 | 272 | duart_68681.ISR &= ~INT_TXRDYB; |
| 273 | 273 | |
| 274 | duart_68681_update_interrupts(); | |
| 274 | duart_68681_update_interrupts(machine); | |
| 275 | 275 | |
| 276 | 276 | period = ATTOTIME_IN_HZ(duart_68681.channel[ch].baud_rate / 10 ); |
| 277 | 277 | timer_adjust_oneshot(duart_68681.channel[ch].tx_timer, period, ch); |
| r2724 | r2725 | |
| 288 | 288 | r = duart_68681.channel[0].SR; |
| 289 | 289 | break; |
| 290 | 290 | case 0x03: /* Rx Holding Register A */ |
| 291 | r = duart_68681_read_rx_fifo(0); | |
| 291 | r = duart_68681_read_rx_fifo(machine, 0); | |
| 292 | 292 | break; |
| 293 | 293 | case 0x04: /* IPCR */ |
| 294 | 294 | { |
| r2724 | r2725 | |
| 301 | 301 | r = (((duart_68681.IP_last_state ^ IP) & 0x0f) << 4) | (IP & 0x0f); |
| 302 | 302 | duart_68681.IP_last_state = IP; |
| 303 | 303 | duart_68681.ISR &= ~INT_INPUT_PORT_CHANGE; |
| 304 | duart_68681_update_interrupts(); | |
| 304 | duart_68681_update_interrupts(machine); | |
| 305 | 305 | } |
| 306 | 306 | break; |
| 307 | 307 | case 0x09: /* SRB */ |
| 308 | 308 | r = duart_68681.channel[1].SR; |
| 309 | 309 | break; |
| 310 | 310 | case 0x0b: /* RHRB */ |
| 311 | r = duart_68681_read_rx_fifo(1); | |
| 311 | r = duart_68681_read_rx_fifo(machine, 1); | |
| 312 | 312 | break; |
| 313 | 313 | default: |
| 314 | 314 | logerror( "Reading unhandled 68681 reg %x\n", offset ); |
| r2724 | r2725 | |
| 332 | 332 | duart_68681_write_CR(0, data); |
| 333 | 333 | break; |
| 334 | 334 | case 0x03: /* THRA */ |
| 335 | duart_68681_write_TX(0, data); | |
| 335 | duart_68681_write_TX(machine, 0, data); | |
| 336 | 336 | break; |
| 337 | 337 | case 0x04: /* ACR */ |
| 338 | 338 | duart_68681.ACR = data; |
| r2724 | r2725 | |
| 356 | 356 | duart_68681_write_CR(1, data); |
| 357 | 357 | break; |
| 358 | 358 | case 0x0b: /* THRB */ |
| 359 | duart_68681_write_TX(1, data); | |
| 359 | duart_68681_write_TX(machine, 1, data); | |
| 360 | 360 | break; |
| 361 | 361 | case 0x0c: /* IVR */ |
| 362 | 362 | duart_68681.IVR = data; |
| r2724 | r2725 | |
| 376 | 376 | } |
| 377 | 377 | } |
| 378 | 378 | |
| 379 | void duart_68681_rx_data( int ch, UINT8 data ) | |
| 379 | void duart_68681_rx_data( running_machine *machine, int ch, UINT8 data ) | |
| 380 | 380 | { |
| 381 | 381 | if ( duart_68681.channel[ch].rx_enabled ) |
| 382 | 382 | { |
| r2724 | r2725 | |
| 405 | 405 | duart_68681.ISR |= (ch == 0) ? INT_RXRDY_FFULLA : INT_RXRDY_FFULLB; |
| 406 | 406 | } |
| 407 | 407 | } |
| 408 | duart_68681_update_interrupts(); | |
| 408 | duart_68681_update_interrupts(machine); | |
| 409 | 409 | } |
| 410 | 410 | }; |
| 411 | 411 | |
| 412 | void duart_68681_init(int frequency, void (*irq_handler)( | |
| 412 | void duart_68681_init(int frequency, void (*irq_handler)(running_machine *machine, int vector), void (*tx_callback)(int channel, UINT8 data)) | |
| 413 | 413 | { |
| 414 | 414 | memset(&duart_68681, 0, sizeof(duart_68681)); |
| 415 | 415 |
| r2724 | r2725 | |
|---|---|---|
| 58 | 58 | { |
| 59 | 59 | r6532[which].timer_irq = 1; |
| 60 | 60 | if (r6532[which].intf->irq_func) |
| 61 | (*r6532[which].intf->irq_func)(ASSERT_LINE); | |
| 61 | (*r6532[which].intf->irq_func)(machine, ASSERT_LINE); | |
| 62 | 62 | else |
| 63 | 63 | logerror("6532RIOT chip #%d: Interrupt is asserted but there is no callback function. PC: %08X\n", which, safe_activecpu_get_pc()); |
| 64 | 64 | } |
| r2724 | r2725 | |
| 73 | 73 | if (r6532[which].pa7_enable) |
| 74 | 74 | { |
| 75 | 75 | if (r6532[which].intf->irq_func) |
| 76 | (*r6532[which].intf->irq_func)(ASSERT_LINE); | |
| 76 | (*r6532[which].intf->irq_func)(Machine, ASSERT_LINE); | |
| 77 | 77 | else |
| 78 | 78 | logerror("6532RIOT chip #%d: Interrupt is asserted but there is no callback function. PC: %08X\n", which, safe_activecpu_get_pc()); |
| 79 | 79 | } |
| r2724 | r2725 | |
| 166 | 166 | if (timer_cycles_left != -1) |
| 167 | 167 | { |
| 168 | 168 | if (r6532[which].intf->irq_func && r6532[which].timer_irq) |
| 169 | (*r6532[which].intf->irq_func)(CLEAR_LINE); | |
| 169 | (*r6532[which].intf->irq_func)(Machine, CLEAR_LINE); | |
| 170 | 170 | else |
| 171 | 171 | logerror("6532RIOT chip #%d: Interrupt is cleared but there is no callback function. PC: %08X\n", which, safe_activecpu_get_pc()); |
| 172 | 172 | |
| r2724 | r2725 | |
| 204 | 204 | if ( timer_cycles_left < -1 ) |
| 205 | 205 | { |
| 206 | 206 | if ( r6532[which].intf->irq_func) |
| 207 | (*r6532[which].intf->irq_func)(CLEAR_LINE); | |
| 207 | (*r6532[which].intf->irq_func)(Machine, CLEAR_LINE); | |
| 208 | 208 | else |
| 209 | 209 | logerror("6532RIOT chip #%d: Interrupt is cleared but there is no callback function. PC: %08X\n", which, safe_activecpu_get_pc()); |
| 210 | 210 | |
| r2724 | r2725 | |
| 219 | 219 | r6532[which].pa7_flag = 0; |
| 220 | 220 | |
| 221 | 221 | if (r6532[which].intf->irq_func && timer_cycles_left != -1) |
| 222 | (*r6532[which].intf->irq_func)(CLEAR_LINE); | |
| 222 | (*r6532[which].intf->irq_func)(Machine, CLEAR_LINE); | |
| 223 | 223 | else |
| 224 | 224 | logerror("6532RIOT chip #%d: Interrupt is cleared but there is no callback function. PC: %08X\n", which, safe_activecpu_get_pc()); |
| 225 | 225 | } |
| r2724 | r2725 | |
| 300 | 300 | r6532[which].timer_irq = 0; |
| 301 | 301 | |
| 302 | 302 | if (r6532[which].intf->irq_func) |
| 303 | (*r6532[which].intf->irq_func)(CLEAR_LINE); | |
| 303 | (*r6532[which].intf->irq_func)(Machine, CLEAR_LINE); | |
| 304 | 304 | else |
| 305 | 305 | logerror("6532RIOT chip #%d: Interrupt is cleared but there is no callback function. PC: %08X\n", which, safe_activecpu_get_pc()); |
| 306 | 306 | } |
| r2724 | r2725 | |
|---|---|---|
| 185 | 185 | { |
| 186 | 186 | v->ifr |= INT_ANY; |
| 187 | 187 | if (v->intf->irq_func) |
| 188 | (*v->intf->irq_func)(ASSERT_LINE); | |
| 188 | (*v->intf->irq_func)(Machine, ASSERT_LINE); | |
| 189 | 189 | else |
| 190 | 190 | logerror("6522VIA chip %d: Interrupt is asserted but there is no callback function. PC: %08X\n", which, safe_activecpu_get_pc()); |
| 191 | 191 | } |
| r2724 | r2725 | |
| 206 | 206 | else |
| 207 | 207 | { |
| 208 | 208 | if (v->intf->irq_func) |
| 209 | (*v->intf->irq_func)(CLEAR_LINE); | |
| 209 | (*v->intf->irq_func)(Machine, CLEAR_LINE); | |
| 210 | 210 | // else |
| 211 | 211 | // logerror("6522VIA chip %d: Interrupt is cleared but there is no callback function. PC: %08X\n", which, safe_activecpu_get_pc()); |
| 212 | 212 | } |
| r2724 | r2725 | |
| 821 | 821 | { |
| 822 | 822 | v->ifr &= ~INT_ANY; |
| 823 | 823 | if (v->intf->irq_func) |
| 824 | (*v->intf->irq_func)(CLEAR_LINE); | |
| 824 | (*v->intf->irq_func)(Machine, CLEAR_LINE); | |
| 825 | 825 | // else |
| 826 | 826 | // logerror("6522VIA chip %d: Interrupt is cleared but there is no callback function. PC: %08X\n", which, safe_activecpu_get_pc()); |
| 827 | 827 | } |
| r2724 | r2725 | |
| 832 | 832 | { |
| 833 | 833 | v->ifr |= INT_ANY; |
| 834 | 834 | if (v->intf->irq_func) |
| 835 | (*v->intf->irq_func)(ASSERT_LINE); | |
| 835 | (*v->intf->irq_func)(Machine, ASSERT_LINE); | |
| 836 | 836 | else |
| 837 | 837 | logerror("6522VIA chip %d: Interrupt is asserted but there is no callback function. PC: %08X\n", which, safe_activecpu_get_pc()); |
| 838 | 838 | } |
| r2724 | r2725 | |
|---|---|---|
| 40 | 40 | write8_machine_func out_b_func; |
| 41 | 41 | write8_machine_func out_ca2_func; |
| 42 | 42 | write8_machine_func out_cb2_func; |
| 43 | void (*irq_a_func)(int state); | |
| 44 | void (*irq_b_func)(int state); | |
| 43 | void (*irq_a_func)(running_machine *machine, int state); | |
| 44 | void (*irq_b_func)(running_machine *machine, int state); | |
| 45 | 45 | }; |
| 46 | 46 | |
| 47 | 47 |
| r2724 | r2725 | |
|---|---|---|
| 235 | 235 | } |
| 236 | 236 | } |
| 237 | 237 | |
| 238 | static void wd33c93_complete_immediate( int status ) | |
| 238 | static void wd33c93_complete_immediate( running_machine *machine, int status ) | |
| 239 | 239 | { |
| 240 | 240 | /* reset our timer */ |
| 241 | 241 | timer_reset( scsi_data.cmd_timer, attotime_never ); |
| r2724 | r2725 | |
| 264 | 264 | /* if we have a callback, call it */ |
| 265 | 265 | if (intf && intf->irq_callback) |
| 266 | 266 | { |
| 267 | intf->irq_callback(1); | |
| 267 | intf->irq_callback(machine, 1); | |
| 268 | 268 | } |
| 269 | 269 | } |
| 270 | 270 | |
| 271 | 271 | static TIMER_CALLBACK(wd33c93_complete_cb) |
| 272 | 272 | { |
| 273 | wd33c93_complete_immediate( param ); | |
| 273 | wd33c93_complete_immediate( machine, param ); | |
| 274 | 274 | } |
| 275 | 275 | |
| 276 | 276 | static TIMER_CALLBACK(wd33c93_service_request) |
| 277 | 277 | { |
| 278 | 278 | /* issue a message out request */ |
| 279 | wd33c93_complete_immediate(CSR_SRV_REQ | scsi_data.busphase); | |
| 279 | wd33c93_complete_immediate(machine, CSR_SRV_REQ | scsi_data.busphase); | |
| 280 | 280 | } |
| 281 | 281 | |
| 282 | 282 | static TIMER_CALLBACK(wd33c93_deassert_cip) |
| r2724 | r2725 | |
| 635 | 635 | } |
| 636 | 636 | |
| 637 | 637 | /* complete the command */ |
| 638 | wd33c93_complete_immediate(CSR_XFER_DONE | scsi_data.busphase); | |
| 638 | wd33c93_complete_immediate(machine, CSR_XFER_DONE | scsi_data.busphase); | |
| 639 | 639 | } |
| 640 | 640 | } |
| 641 | 641 | else |
| r2724 | r2725 | |
| 682 | 682 | |
| 683 | 683 | if (intf && intf->irq_callback) |
| 684 | 684 | { |
| 685 | intf->irq_callback(0); | |
| 685 | intf->irq_callback(machine, 0); | |
| 686 | 686 | } |
| 687 | 687 | |
| 688 | 688 | LOG(( "WD33C93: PC=%08x - Status read (%02x)\n", safe_activecpu_get_pc(), scsi_data.regs[WD_SCSI_STATUS] )); |
| r2724 | r2725 | |
|---|---|---|
| 1 | 1 | #ifndef _68681_H |
| 2 | 2 | #define _68681_H |
| 3 | 3 | |
| 4 | void duart_68681_init(int frequency, void (*irq_handler)(UINT8 vector), void (*tx_callback)(int channel, UINT8 data)); | |
| 5 | void duart_68681_rx_data( int ch, UINT8 data ); | |
| 4 | void duart_68681_init(int frequency, void (*irq_handler)(running_machine *machine, int vector), void (*tx_callback)(int channel, UINT8 data)); | |
| 5 | void duart_68681_rx_data( running_machine *machine, int ch, UINT8 data ); | |
| 6 | 6 | |
| 7 | 7 | READ16_HANDLER(duart_68681_r); |
| 8 | 8 | WRITE16_HANDLER(duart_68681_w); |
| r2724 | r2725 | |
|---|---|---|
| 15 | 15 | read8_machine_func in_b_func; |
| 16 | 16 | write8_machine_func out_a_func; |
| 17 | 17 | write8_machine_func out_b_func; |
| 18 | void (*irq_func)(int state); | |
| 18 | void (*irq_func)(running_machine *machine, int state); | |
| 19 | 19 | }; |
| 20 | 20 | |
| 21 | 21 | void r6532_set_clock(int which, int clock); |
| r2724 | r2725 | |
|---|---|---|
| 48 | 48 | write8_machine_func out_cb1_func; |
| 49 | 49 | write8_machine_func out_ca2_func; |
| 50 | 50 | write8_machine_func out_cb2_func; |
| 51 | void (*irq_func)(int state); | |
| 51 | void (*irq_func)(running_machine *machine, int state); | |
| 52 | 52 | }; |
| 53 | 53 | |
| 54 | 54 | void via_set_clock(int which,int clck); |
| r2724 | r2725 | |
|---|---|---|
| 11 | 11 | struct WD33C93interface |
| 12 | 12 | { |
| 13 | 13 | const SCSIConfigTable *scsidevs; /* SCSI devices */ |
| 14 | void (*irq_callback)(int state); | |
| 14 | void (*irq_callback)(running_machine *machine, int state); /* irq callback */ | |
| 15 | 15 | }; |
| 16 | 16 | |
| 17 | 17 | extern void wd33c93_init( const struct WD33C93interface *interface ); |
| r2724 | r2725 | |
|---|---|---|
| 261 | 261 | currptr->status_reg &= ~0x80; |
| 262 | 262 | |
| 263 | 263 | if (currptr->intf->irq_func) |
| 264 | (currptr->intf->irq_func)(currptr->IRQ); | |
| 264 | (currptr->intf->irq_func)(Machine, currptr->IRQ); | |
| 265 | 265 | } |
| 266 | 266 | } |
| 267 | 267 |
| r2724 | r2725 | |
|---|---|---|
| 20 | 20 | |
| 21 | 21 | write8_machine_func out_func[3]; // function to call when output[idx] changes |
| 22 | 22 | |
| 23 | void (*irq_func)(int state); // function called if IRQ line changes | |
| 23 | void (*irq_func)(running_machine *machine, int state); // function called if IRQ line changes | |
| 24 | 24 | }; |
| 25 | 25 | |
| 26 | 26 | void ptm6840_config( int which, const ptm6840_interface *intf); |
| r2724 | r2725 | |
|---|---|---|
| 87 | 87 | { |
| 88 | 88 | scsi_regs[REG_IRQSTATE] = 8; // indicate success |
| 89 | 89 | scsi_regs[REG_STATUS] |= 0x80; // indicate IRQ |
| 90 | intf->irq_callback(); | |
| 90 | intf->irq_callback(machine); | |
| 91 | 91 | } |
| 92 | 92 | |
| 93 | 93 | WRITE32_HANDLER( am53cf96_w ) |
| r2724 | r2725 | |
|---|---|---|
| 11 | 11 | struct AM53CF96interface |
| 12 | 12 | { |
| 13 | 13 | const SCSIConfigTable *scsidevs; /* SCSI devices */ |
| 14 | void (*irq_callback)( | |
| 14 | void (*irq_callback)(running_machine *machine); /* irq callback */ | |
| 15 | 15 | }; |
| 16 | 16 | |
| 17 | 17 | extern void am53cf96_init( const struct AM53CF96interface *interface ); |
| r2724 | r2725 | |
|---|---|---|
| 54 | 54 | { |
| 55 | 55 | PC16552D_CHANNEL ch[2]; |
| 56 | 56 | int frequency; |
| 57 | void (* irq_handler)(int channel, int value); | |
| 57 | void (* irq_handler)(running_machine *machine, int channel, int value); | |
| 58 | 58 | void (* tx_callback)(int channel, int count, UINT8* data); |
| 59 | 59 | } PC16552D_REGS; |
| 60 | 60 | |
| r2724 | r2725 | |
| 67 | 67 | static const int rx_trigger_level[4] = { 1, 4, 8, 14 }; |
| 68 | 68 | |
| 69 | 69 | |
| 70 | static void check_interrupts(int chip, int channel) | |
| 70 | static void check_interrupts(running_machine *machine, int chip, int channel) | |
| 71 | 71 | { |
| 72 | 72 | PC16552D_CHANNEL *ch = &duart[chip].ch[channel]; |
| 73 | 73 | |
| r2724 | r2725 | |
| 80 | 80 | { |
| 81 | 81 | if (duart[chip].irq_handler != NULL) |
| 82 | 82 | { |
| 83 | duart[chip].irq_handler(channel, 0); | |
| 83 | duart[chip].irq_handler(machine, channel, 0); | |
| 84 | 84 | } |
| 85 | 85 | } |
| 86 | 86 | } |
| 87 | 87 | } |
| 88 | 88 | |
| 89 | static void duart_push_rx_fifo(int chip, int channel, UINT8 data) | |
| 89 | static void duart_push_rx_fifo(running_machine *machine, int chip, int channel, UINT8 data) | |
| 90 | 90 | { |
| 91 | 91 | PC16552D_CHANNEL *ch = &duart[chip].ch[channel]; |
| 92 | 92 | |
| r2724 | r2725 | |
| 107 | 107 | { |
| 108 | 108 | ch->pending_interrupt |= IRQ_RX_DATA_AVAILABLE; // INT ID: received data available |
| 109 | 109 | |
| 110 | check_interrupts(chip, channel); | |
| 110 | check_interrupts(machine, chip, channel); | |
| 111 | 111 | } |
| 112 | 112 | } |
| 113 | 113 | |
| 114 | static UINT8 duart_pop_rx_fifo(int chip, int channel) | |
| 114 | static UINT8 duart_pop_rx_fifo(running_machine *machine, int chip, int channel) | |
| 115 | 115 | { |
| 116 | 116 | UINT8 r; |
| 117 | 117 | PC16552D_CHANNEL *ch = &duart[chip].ch[channel]; |
| r2724 | r2725 | |
| 133 | 133 | { |
| 134 | 134 | ch->pending_interrupt &= ~IRQ_RX_DATA_AVAILABLE; |
| 135 | 135 | |
| 136 | check_interrupts(chip, channel); | |
| 136 | check_interrupts(machine, chip, channel); | |
| 137 | 137 | } |
| 138 | 138 | |
| 139 | 139 | return r; |
| r2724 | r2725 | |
| 154 | 154 | |
| 155 | 155 | // set transmitter empty interrupt |
| 156 | 156 | ch->pending_interrupt |= IRQ_TX_HOLDING_REG_EMPTY; |
| 157 | check_interrupts(chip, channel); | |
| 157 | check_interrupts(machine, chip, channel); | |
| 158 | 158 | |
| 159 | 159 | timer_adjust_oneshot(duart[chip].ch[channel].tx_fifo_timer, attotime_never, (chip * 2) + channel); |
| 160 | 160 | } |
| r2724 | r2725 | |
| 180 | 180 | #endif |
| 181 | 181 | |
| 182 | 182 | |
| 183 | static UINT8 duart_r(int chip, int reg) | |
| 183 | static UINT8 duart_r(running_machine *machine, int chip, int reg) | |
| 184 | 184 | { |
| 185 | 185 | int channel = (reg >> 3) & 1; |
| 186 | 186 | PC16552D_CHANNEL *ch = &duart[chip].ch[channel]; |
| r2724 | r2725 | |
| 202 | 202 | // Receiver Buffer |
| 203 | 203 | ch->pending_interrupt &= ~IRQ_RX_DATA_AVAILABLE; |
| 204 | 204 | |
| 205 | check_interrupts(chip, channel); | |
| 205 | check_interrupts(machine, chip, channel); | |
| 206 | 206 | |
| 207 | return duart_pop_rx_fifo(chip, channel); | |
| 207 | return duart_pop_rx_fifo(machine, chip, channel); | |
| 208 | 208 | } |
| 209 | 209 | } |
| 210 | 210 | case 1: |
| r2724 | r2725 | |
| 288 | 288 | return ch->reg[reg]; |
| 289 | 289 | } |
| 290 | 290 | |
| 291 | static void duart_w(int chip, int reg, UINT8 data) | |
| 291 | static void duart_w(running_machine *machine, int chip, int reg, UINT8 data) | |
| 292 | 292 | { |
| 293 | 293 | int channel = (reg >> 3) & 1; |
| 294 | 294 | PC16552D_CHANNEL *ch = &duart[chip].ch[channel]; |
| r2724 | r2725 | |
| 314 | 314 | duart_push_tx_fifo(chip, channel, data); |
| 315 | 315 | |
| 316 | 316 | ch->pending_interrupt &= ~IRQ_TX_HOLDING_REG_EMPTY; |
| 317 | check_interrupts(chip, channel); | |
| 317 | check_interrupts(machine, chip, channel); | |
| 318 | 318 | |
| 319 | 319 | return; |
| 320 | 320 | } |
| r2724 | r2725 | |
| 335 | 335 | // Interrupt enable |
| 336 | 336 | ch->reg[REG_INT_ENABLE] = data; |
| 337 | 337 | |
| 338 | check_interrupts(chip, channel); | |
| 338 | check_interrupts(machine, chip, channel); | |
| 339 | 339 | return; |
| 340 | 340 | } |
| 341 | 341 | } |
| r2724 | r2725 | |
| 371 | 371 | // cause transmitter empty IRQ |
| 372 | 372 | ch->pending_interrupt |= IRQ_TX_HOLDING_REG_EMPTY; |
| 373 | 373 | |
| 374 | check_interrupts(chip, channel); | |
| 374 | check_interrupts(machine, chip, channel); | |
| 375 | 375 | } |
| 376 | 376 | */ |
| 377 | 377 | } |
| r2724 | r2725 | |
| 384 | 384 | |
| 385 | 385 | /*****************************************************************************/ |
| 386 | 386 | |
| 387 | void pc16552d_init(int chip, int frequency, void (* irq_handler)(int channel, int value), void (* tx_callback)(int channel, int count, UINT8* data)) | |
| 387 | void pc16552d_init(int chip, int frequency, void (* irq_handler)(running_machine *machine, int channel, int value), void (* tx_callback)(int channel, int count, UINT8* data)) | |
| 388 | 388 | { |
| 389 | 389 | memset(&duart[chip], 0, sizeof(PC16552D_REGS)); |
| 390 | 390 | |
| r2724 | r2725 | |
| 404 | 404 | timer_adjust_oneshot(duart[chip].ch[1].tx_fifo_timer, attotime_never, (chip * 2) + 1); |
| 405 | 405 | } |
| 406 | 406 | |
| 407 | void pc16552d_rx_data(int chip, int channel, UINT8 data) | |
| 407 | void pc16552d_rx_data(running_machine *machine, int chip, int channel, UINT8 data) | |
| 408 | 408 | { |
| 409 | 409 | if (duart[chip].ch[channel].reg[REG_FIFO_CTRL] & 0x01) // RCVR & XMIT FIFO enable |
| 410 | 410 | { |
| 411 | duart_push_rx_fifo(chip, channel, data); | |
| 411 | duart_push_rx_fifo(machine, chip, channel, data); | |
| 412 | 412 | } |
| 413 | 413 | } |
| 414 | 414 | |
| r2724 | r2725 | |
| 417 | 417 | |
| 418 | 418 | READ8_HANDLER(pc16552d_0_r) |
| 419 | 419 | { |
| 420 | return duart_r(0, offset); | |
| 420 | return duart_r(machine, 0, offset); | |
| 421 | 421 | } |
| 422 | 422 | |
| 423 | 423 | WRITE8_HANDLER(pc16552d_0_w) |
| 424 | 424 | { |
| 425 | duart_w(0, offset, data); | |
| 425 | duart_w(machine, 0, offset, data); | |
| 426 | 426 | } |
| 427 | 427 | |
| 428 | 428 | READ8_HANDLER(pc16552d_1_r) |
| 429 | 429 | { |
| 430 | return duart_r(1, offset); | |
| 430 | return duart_r(machine, 1, offset); | |
| 431 | 431 | } |
| 432 | 432 | |
| 433 | 433 | WRITE8_HANDLER(pc16552d_1_w) |
| 434 | 434 | { |
| 435 | duart_w(1, offset, data); | |
| 435 | duart_w(machine, 1, offset, data); | |
| 436 | 436 | } |
| r2724 | r2725 | |
|---|---|---|
| 46 | 46 | FUNCTION PROTOTYPES |
| 47 | 47 | ***************************************************************************/ |
| 48 | 48 | |
| 49 | static void counters_load(int config_type, xml_data_node *parentnode); | |
| 50 | static void counters_save(int config_type, xml_data_node *parentnode); | |
| 49 | static void counters_load(running_machine *machine, int config_type, xml_data_node *parentnode); | |
| 50 | static void counters_save(running_machine *machine, int config_type, xml_data_node *parentnode); | |
| 51 | 51 | static void interrupt_reset(running_machine *machine); |
| 52 | 52 | |
| 53 | 53 | |
| r2724 | r2725 | |
| 93 | 93 | state_save_register_item_array("cpu", 0, interrupt_enable); |
| 94 | 94 | |
| 95 | 95 | /* register for configuration */ |
| 96 | config_register("counters", counters_load, counters_save); | |
| 96 | config_register(machine, "counters", counters_load, counters_save); | |
| 97 | 97 | |
| 98 | 98 | /* for memory cards, request save state and an exit callback */ |
| 99 | 99 | if (machine->config->memcard_handler != NULL) |
| r2724 | r2725 | |
| 114 | 114 | and tickets |
| 115 | 115 | -------------------------------------------------*/ |
| 116 | 116 | |
| 117 | static void counters_load(int config_type, xml_data_node *parentnode) | |
| 117 | static void counters_load(running_machine *machine, int config_type, xml_data_node *parentnode) | |
| 118 | 118 | { |
| 119 | 119 | xml_data_node *coinnode, *ticketnode; |
| 120 | 120 | |
| r2724 | r2725 | |
| 153 | 153 | and tickets |
| 154 | 154 | -------------------------------------------------*/ |
| 155 | 155 | |
| 156 | static void counters_save(int config_type, xml_data_node *parentnode) | |
| 156 | static void counters_save(running_machine *machine, int config_type, xml_data_node *parentnode) | |
| 157 | 157 | { |
| 158 | 158 | int i; |
| 159 | 159 |
| r2724 | r2725 | |
|---|---|---|
| 1 | 1 | #ifndef PC16552D_H |
| 2 | 2 | #define PC16552D_H |
| 3 | 3 | |
| 4 | void pc16552d_init(int chip, int frequency, void (* irq_handler)(int channel, int value), void (* tx_callback)(int channel, int count, UINT8* data)); | |
| 5 | void pc16552d_rx_data(int chip, int channel, UINT8 data); | |
| 4 | void pc16552d_init(int chip, int frequency, void (* irq_handler)(running_machine *machine, int channel, int value), void (* tx_callback)(int channel, int count, UINT8* data)); | |
| 5 | void pc16552d_rx_data(running_machine *machine, int chip, int channel, UINT8 data); | |
| 6 | 6 | |
| 7 | 7 | READ8_HANDLER(pc16552d_0_r); |
| 8 | 8 | WRITE8_HANDLER(pc16552d_0_w); |
| r2724 | r2725 | |
|---|---|---|
| 114 | 114 | |
| 115 | 115 | struct smc91c94_data |
| 116 | 116 | { |
| 117 | void (*irq_handler)(int state); | |
| 117 | void (*irq_handler)(running_machine *machine, int state); | |
| 118 | 118 | |
| 119 | 119 | /* raw register data and masks */ |
| 120 | 120 | UINT16 reg[64]; |
| r2724 | r2725 | |
| 154 | 154 | * |
| 155 | 155 | *************************************/ |
| 156 | 156 | |
| 157 | static void update_ethernet_irq( | |
| 157 | static void update_ethernet_irq(running_machine *machine); | |
| 158 | 158 | |
| 159 | 159 | |
| 160 | 160 | |
| r2724 | r2725 | |
| 177 | 177 | * |
| 178 | 178 | *************************************/ |
| 179 | 179 | |
| 180 | void smc91c94_reset( | |
| 180 | void smc91c94_reset(running_machine *machine) | |
| 181 | 181 | { |
| 182 | void (*saved_handler)(int) = ethernet.irq_handler; | |
| 182 | void (*saved_handler)(running_machine *machine, int) = ethernet.irq_handler; | |
| 183 | 183 | memset(ðernet, 0, sizeof(ethernet)); |
| 184 | 184 | ethernet.irq_handler = saved_handler; |
| 185 | 185 | |
| r2724 | r2725 | |
| 215 | 215 | ethernet.reg[EREG_REVISION] = 0x3340; ethernet.regmask[EREG_REVISION] = 0x0000; |
| 216 | 216 | ethernet.reg[EREG_ERCV] = 0x331f; ethernet.regmask[EREG_ERCV] = 0x009f; |
| 217 | 217 | |
| 218 | update_ethernet_irq(); | |
| 218 | update_ethernet_irq(machine); | |
| 219 | 219 | } |
| 220 | 220 | |
| 221 | 221 | |
| r2724 | r2725 | |
| 226 | 226 | * |
| 227 | 227 | *************************************/ |
| 228 | 228 | |
| 229 | static void update_ethernet_irq( | |
| 229 | static void update_ethernet_irq(running_machine *machine) | |
| 230 | 230 | { |
| 231 | 231 | UINT8 mask = ethernet.reg[EREG_INTERRUPT] >> 8; |
| 232 | 232 | UINT8 state = ethernet.reg[EREG_INTERRUPT] & 0xff; |
| r2724 | r2725 | |
| 234 | 234 | /* update the IRQ state */ |
| 235 | 235 | ethernet.irq_state = ((mask & state) != 0); |
| 236 | 236 | if (ethernet.irq_handler) |
| 237 | (*ethernet.irq_handler)(ethernet.irq_state ? ASSERT_LINE : CLEAR_LINE); | |
| 237 | (*ethernet.irq_handler)(machine, ethernet.irq_state ? ASSERT_LINE : CLEAR_LINE); | |
| 238 | 238 | } |
| 239 | 239 | |
| 240 | 240 | |
| r2724 | r2725 | |
| 260 | 260 | * |
| 261 | 261 | *************************************/ |
| 262 | 262 | |
| 263 | static void finish_enqueue(int param) | |
| 263 | static void finish_enqueue(running_machine *machine, int param) | |
| 264 | 264 | { |
| 265 | 265 | int is_broadcast = (ethernet.tx[4] == 0xff && ethernet.tx[5] == 0xff && ethernet.tx[6] == 0xff && |
| 266 | 266 | ethernet.tx[7] == 0xff && ethernet.tx[8] == 0xff && ethernet.tx[9] == 0xff); |
| r2724 | r2725 | |
| 320 | 320 | ethernet.reg[EREG_INTERRUPT] |= EINT_RCV; |
| 321 | 321 | ethernet.reg[EREG_FIFO_PORTS] &= ~0x8000; |
| 322 | 322 | } |
| 323 | update_ethernet_irq(); | |
| 323 | update_ethernet_irq(machine); | |
| 324 | 324 | } |
| 325 | 325 | |
| 326 | 326 | |
| r2724 | r2725 | |
| 331 | 331 | * |
| 332 | 332 | *************************************/ |
| 333 | 333 | |
| 334 | static void process_command(UINT16 data) | |
| 334 | static void process_command(running_machine *machine, UINT16 data) | |
| 335 | 335 | { |
| 336 | 336 | switch ((data >> 5) & 7) |
| 337 | 337 | { |
| r2724 | r2725 | |
| 346 | 346 | ethernet.reg[EREG_PNR_ARR] &= ~0xff00; |
| 347 | 347 | ethernet.reg[EREG_PNR_ARR] |= ethernet.alloc_count++ << 8; |
| 348 | 348 | ethernet.reg[EREG_INTERRUPT] |= 0x0008; |
| 349 | update_ethernet_irq(); | |
| 349 | update_ethernet_irq(machine); | |
| 350 | 350 | break; |
| 351 | 351 | |
| 352 | 352 | case ECMD_RESET_MMU: |
| r2724 | r2725 | |
| 373 | 373 | } |
| 374 | 374 | else |
| 375 | 375 | ethernet.reg[EREG_FIFO_PORTS] |= 0x8000; |
| 376 | update_ethernet_irq(); | |
| 376 | update_ethernet_irq(machine); | |
| 377 | 377 | ethernet.recd++; |
| 378 | 378 | update_stats(); |
| 379 | 379 | break; |
| r2724 | r2725 | |
| 386 | 386 | case ECMD_ENQUEUE_PACKET: |
| 387 | 387 | if (LOG_ETHERNET) |
| 388 | 388 | logerror(" ENQUEUE TX PACKET\n"); |
| 389 | finish_enqueue(0); | |
| 389 | finish_enqueue(machine, 0); | |
| 390 | 390 | break; |
| 391 | 391 | |
| 392 | 392 | case ECMD_RESET_FIFOS: |
| r2724 | r2725 | |
| 421 | 421 | if (ACCESSING_BITS_8_15) |
| 422 | 422 | { |
| 423 | 423 | ethernet.reg[EREG_INTERRUPT] &= ~0x0008; |
| 424 | update_ethernet_irq(); | |
| 424 | update_ethernet_irq(machine); | |
| 425 | 425 | } |
| 426 | 426 | break; |
| 427 | 427 | |
| r2724 | r2725 | |
| 490 | 490 | case EREG_RCR: /* receive control register */ |
| 491 | 491 | if (LOG_ETHERNET) |
| 492 | 492 | { |
| 493 | if (data & 0x8000) smc91c94_reset(); | |
| 493 | if (data & 0x8000) smc91c94_reset(machine); | |
| 494 | 494 | if (data & 0x8000) logerror(" SOFT RST\n"); |
| 495 | 495 | if (data & 0x4000) logerror(" FILT_CAR\n"); |
| 496 | 496 | if (data & 0x0200) logerror(" STRIP CRC\n"); |
| r2724 | r2725 | |
| 540 | 540 | break; |
| 541 | 541 | |
| 542 | 542 | case EREG_MMU_COMMAND: /* command register */ |
| 543 | process_command(data); | |
| 543 | process_command(machine, data); | |
| 544 | 544 | break; |
| 545 | 545 | |
| 546 | 546 | case EREG_DATA_0: /* data register */ |
| r2724 | r2725 | |
| 558 | 558 | |
| 559 | 559 | case EREG_INTERRUPT: |
| 560 | 560 | ethernet.reg[EREG_INTERRUPT] &= ~(data & 0x56); |
| 561 | update_ethernet_irq(); | |
| 561 | update_ethernet_irq(machine); | |
| 562 | 562 | break; |
| 563 | 563 | } |
| 564 | 564 | } |
| r2724 | r2725 | |
|---|---|---|
| 11 | 11 | |
| 12 | 12 | struct smc91c9x_interface |
| 13 | 13 | { |
| 14 | void (*irq_handler)(int state); | |
| 14 | void (*irq_handler)(running_machine *machine, int state); | |
| 15 | 15 | }; |
| 16 | 16 | |
| 17 | 17 | void smc91c94_init(const struct smc91c9x_interface *config); |
| 18 | void smc91c94_reset( | |
| 18 | void smc91c94_reset(running_machine *machine); | |
| 19 | 19 | READ16_HANDLER( smc91c94_r ); |
| 20 | 20 | WRITE16_HANDLER( smc91c94_w ); |
| 21 | 21 |
| r2724 | r2725 | |
|---|---|---|
| 56 | 56 | struct _z80pio |
| 57 | 57 | { |
| 58 | 58 | UINT8 vector[2]; /* interrupt vector */ |
| 59 | void (*intr)(int which); /* interrupt callbacks */ | |
| 59 | void (*intr)(running_machine *, int which); /* interrupt callbacks */ | |
| 60 | 60 | void (*rdyr[2])(int data); /* RDY active callback */ |
| 61 | 61 | read8_machine_func port_read[2]; /* port read callbacks */ |
| 62 | 62 | write8_machine_func port_write[2]; /* port write callbacks */ |
| r2724 | r2725 | |
| 103 | 103 | |
| 104 | 104 | /* if we have a callback, update it with the current state */ |
| 105 | 105 | if (pio->intr) |
| 106 | (*pio->intr)((z80pio_irq_state(which) & Z80_DAISY_INT) ? ASSERT_LINE : CLEAR_LINE); | |
| 106 | (*pio->intr)(Machine, (z80pio_irq_state(which) & Z80_DAISY_INT) ? ASSERT_LINE : CLEAR_LINE); | |
| 107 | 107 | } |
| 108 | 108 | |
| 109 | 109 |
| r2724 | r2725 | |
|---|---|---|
| 180 | 180 | sio_channel chan[2]; /* 2 channels */ |
| 181 | 181 | UINT8 int_state[8]; /* interrupt states */ |
| 182 | 182 | |
| 183 | void (*irq_cb)(int state); | |
| 183 | void (*irq_cb)(running_machine *machine, int state); | |
| 184 | 184 | write8_machine_func dtr_changed_cb; |
| 185 | 185 | write8_machine_func rts_changed_cb; |
| 186 | 186 | write8_machine_func break_changed_cb; |
| r2724 | r2725 | |
| 265 | 265 | { |
| 266 | 266 | /* if we have a callback, update it with the current state */ |
| 267 | 267 | if (sio->irq_cb != NULL) |
| 268 | (*sio->irq_cb)((z80sio_irq_state(sio - sios) & Z80_DAISY_INT) ? ASSERT_LINE : CLEAR_LINE); | |
| 268 | (*sio->irq_cb)(Machine, (z80sio_irq_state(sio - sios) & Z80_DAISY_INT) ? ASSERT_LINE : CLEAR_LINE); | |
| 269 | 269 | } |
| 270 | 270 | |
| 271 | 271 |
| r2724 | r2725 | |
|---|---|---|
| 21 | 21 | |
| 22 | 22 | struct _z80pio_interface |
| 23 | 23 | { |
| 24 | void (*intr)(int which); /* callback when change interrupt status */ | |
| 24 | void (*intr)(running_machine *machine, int which); /* callback when change interrupt status */ | |
| 25 | 25 | read8_machine_func portAread; /* port A read callback */ |
| 26 | 26 | read8_machine_func portBread; /* port B read callback */ |
| 27 | 27 | write8_machine_func portAwrite; /* port A write callback */ |
| r2724 | r2725 | |
|---|---|---|
| 23 | 23 | struct _z80sio_interface |
| 24 | 24 | { |
| 25 | 25 | int baseclock; |
| 26 | void (*irq_cb)(int state); | |
| 26 | void (*irq_cb)(running_machine *machine, int state); | |
| 27 | 27 | write8_machine_func dtr_changed_cb; |
| 28 | 28 | write8_machine_func rts_changed_cb; |
| 29 | 29 | write8_machine_func break_changed_cb; |
| r2724 | r2725 | |
|---|---|---|
| 9 | 9 | ***************************************************************************/ |
| 10 | 10 | |
| 11 | 11 | #include "driver.h" |
| 12 | #include "deprecat.h" | |
| 13 | 12 | #include "machine/tmp68301.h" |
| 14 | 13 | |
| 15 | 14 | UINT16 *tmp68301_regs; |
| r2724 | r2725 | |
| 120 | 119 | } |
| 121 | 120 | |
| 122 | 121 | /* Update the IRQ state based on all possible causes */ |
| 123 | static void update_irq_state( | |
| 122 | static void update_irq_state(running_machine *machine) | |
| 124 | 123 | { |
| 125 | 124 | int i; |
| 126 | 125 | |
| r2724 | r2725 | |
| 146 | 145 | |
| 147 | 146 | tmp68301_IE[i] = 0; // Interrupts are edge triggerred |
| 148 | 147 | |
| 149 | cpunum_set_input_line( | |
| 148 | cpunum_set_input_line(machine, 0,level,HOLD_LINE); | |
| 150 | 149 | } |
| 151 | 150 | } |
| 152 | 151 | } |
| r2724 | r2725 | |
| 174 | 173 | } |
| 175 | 174 | } |
| 176 | 175 | |
| 177 | void tmp68301_external_interrupt_0() { tmp68301_IE[0] = 1; update_irq_state(); } | |
| 178 | void tmp68301_external_interrupt_1() { tmp68301_IE[1] = 1; update_irq_state(); } | |
| 179 | void tmp68301_external_interrupt_2() { tmp68301_IE[2] = 1; update_irq_state(); } | |
| 176 | void tmp68301_external_interrupt_0(running_machine *machine) { tmp68301_IE[0] = 1; update_irq_state(machine); } | |
| 177 | void tmp68301_external_interrupt_1(running_machine *machine) { tmp68301_IE[1] = 1; update_irq_state(machine); } | |
| 178 | void tmp68301_external_interrupt_2(running_machine *machine) { tmp68301_IE[2] = 1; update_irq_state(machine); } | |
| 180 | 179 |
| r2724 | r2725 | |
|---|---|---|
| 9 | 9 | WRITE16_HANDLER( tmp68301_regs_w ); |
| 10 | 10 | |
| 11 | 11 | // Interrupts |
| 12 | void tmp68301_external_interrupt_0(void); | |
| 13 | void tmp68301_external_interrupt_1(void); | |
| 14 | void tmp68301_external_interrupt_2(void); | |
| 12 | void tmp68301_external_interrupt_0(running_machine *machine); | |
| 13 | void tmp68301_external_interrupt_1(running_machine *machine); | |
| 14 | void tmp68301_external_interrupt_2(running_machine *machine); | |
| 15 | 15 | |
| 16 | 16 | #endif |
| r2724 | r2725 | |
|---|---|---|
| 80 | 80 | UINT32 clock; /* system clock */ |
| 81 | 81 | attotime period16; /* 16/system clock */ |
| 82 | 82 | attotime period256; /* 256/system clock */ |
| 83 | void (*intr)(int which); /* interrupt callback */ | |
| 83 | void (*intr)(running_machine *machine, int which); /* interrupt callback */ | |
| 84 | 84 | write8_machine_func zc[4]; /* zero crossing callbacks */ |
| 85 | 85 | UINT8 notimer; /* no timer masks */ |
| 86 | 86 | UINT16 mode[4]; /* current mode */ |
| r2724 | r2725 | |
| 111 | 111 | |
| 112 | 112 | /* if we have a callback, update it with the current state */ |
| 113 | 113 | if (ctc->intr) |
| 114 | (*ctc->intr)((z80ctc_irq_state(which) & Z80_DAISY_INT) ? ASSERT_LINE : CLEAR_LINE); | |
| 114 | (*ctc->intr)(Machine, (z80ctc_irq_state(which) & Z80_DAISY_INT) ? ASSERT_LINE : CLEAR_LINE); | |
| 115 | 115 | } |
| 116 | 116 | |
| 117 | 117 |
| r2724 | r2725 | |
|---|---|---|
| 28 | 28 | { |
| 29 | 29 | int baseclock; /* timer clock */ |
| 30 | 30 | int notimer; /* timer disablers */ |
| 31 | void (*intr)(int which); /* callback when change interrupt status */ | |
| 31 | void (*intr)(running_machine *machine, int which); /* callback when change interrupt status */ | |
| 32 | 32 | write8_machine_func zc0; /* ZC/TO0 callback */ |
| 33 | 33 | write8_machine_func zc1; /* ZC/TO1 callback */ |
| 34 | 34 | write8_machine_func zc2; /* ZC/TO2 callback */ |
| r2724 | r2725 | |
|---|---|---|
| 17 | 17 | #include "crsshair.h" |
| 18 | 18 | #include "restrack.h" |
| 19 | 19 | #include "options.h" |
| 20 | #include "inptport.h" | |
| 20 | 21 | #include <stdarg.h> |
| 21 | 22 | |
| 22 | 23 | #ifdef MESS |
| r2724 | r2725 | |
| 166 | 167 | typedef struct _palette_private palette_private; |
| 167 | 168 | typedef struct _streams_private streams_private; |
| 168 | 169 | typedef struct _devices_private devices_private; |
| 170 | typedef struct _input_port_private input_port_private; | |
| 169 | 171 | |
| 170 | 172 | |
| 171 | 173 | /* description of the currently-running machine */ |
| 172 | 174 | /* typedef struct _running_machine running_machine; -- in mamecore.h */ |
| 173 | 175 | struct _running_machine |
| 174 | 176 | { |
| 177 | /* configuration data */ | |
| 178 | const machine_config * config; /* points to the constructed machine_config */ | |
| 179 | const input_port_config *portconfig; /* points to a list of input port configurations */ | |
| 180 | ||
| 175 | 181 | /* game-related information */ |
| 176 | 182 | const game_driver * gamedrv; /* points to the definition of the game machine */ |
| 177 | const machine_config * config; /* points to the constructed machine_config */ | |
| 178 | 183 | const char * basename; /* basename used for game-related paths */ |
| 179 | 184 | |
| 180 | 185 | /* video-related information */ |
| r2724 | r2725 | |
| 190 | 195 | /* audio-related information */ |
| 191 | 196 | int sample_rate; /* the digital audio sample rate */ |
| 192 | 197 | |
| 193 | /* input-related information */ | |
| 194 | input_port_entry * input_ports; /* the input ports definition from the driver is copied here and modified */ | |
| 195 | mame_file * record_file; /* recording file (NULL if not recording) */ | |
| 196 | mame_file * playback_file; /* playback file (NULL if not recording) */ | |
| 197 | ||
| 198 | 198 | /* debugger-related information */ |
| 199 | 199 | int debug_mode; /* was debug mode enabled? */ |
| 200 | 200 | |
| r2724 | r2725 | |
| 203 | 203 | palette_private * palette_data; /* internal data from palette.c */ |
| 204 | 204 | streams_private * streams_data; /* internal data from streams.c */ |
| 205 | 205 | devices_private * devices_data; /* internal data from devices.c */ |
| 206 | input_port_private * input_port_data; /* internal data from inptport.c */ | |
| 206 | 207 | #ifdef MESS |
| 207 | 208 | images_private * images_data; /* internal data from image.c */ |
| 208 | 209 | #endif /* MESS */ |
| r2724 | r2725 | |
|---|---|---|
| 19 | 19 | #include "memory.h" |
| 20 | 20 | #include "inputseq.h" |
| 21 | 21 | #include "tokenize.h" |
| 22 | ||
| 23 | #ifdef MESS | |
| 24 | 22 | #include "unicode.h" |
| 25 | #endif | |
| 26 | 23 | |
| 27 | 24 | |
| 28 | 25 | |
| r2724 | r2725 | |
| 30 | 27 | CONSTANTS |
| 31 | 28 | ***************************************************************************/ |
| 32 | 29 | |
| 33 | #define MAX_INPUT_PORTS 32 | |
| 34 | 30 | #define MAX_PLAYERS 8 |
| 35 | #define MAX_BITS_PER_PORT 32 | |
| 36 | 31 | |
| 37 | 32 | #define IP_ACTIVE_HIGH 0x00000000 |
| 38 | 33 | #define IP_ACTIVE_LOW 0xffffffff |
| 39 | 34 | |
| 40 | #define INPUT_PORT_PAIR_ENTRIES (sizeof(FPTR) / sizeof(UINT32)) | |
| 41 | #define INPUT_PORT_PAIR_TOKENS (2 * sizeof(UINT32) / sizeof(FPTR)) | |
| 42 | 35 | |
| 36 | /* flags for input_field_configs */ | |
| 37 | #define FIELD_FLAG_UNUSED 0x01 /* set if this field is unused but relevant to other games on the same hw */ | |
| 38 | #define FIELD_FLAG_COCKTAIL 0x02 /* set if this field is relevant only for cocktail cabinets */ | |
| 39 | #define FIELD_FLAG_TOGGLE 0x04 /* set if this field should behave as a toggle */ | |
| 40 | #define FIELD_FLAG_ROTATED 0x08 /* set if this field represents a rotated control */ | |
| 41 | #define ANALOG_FLAG_REVERSE 0x10 /* analog only: reverse the sense of the axis */ | |
| 42 | #define ANALOG_FLAG_RESET 0x20 /* analog only: always preload in->default for relative axes, returning only deltas */ | |
| 43 | #define ANALOG_FLAG_WRAPS 0x40 /* analog only: positional count wraps around */ | |
| 44 | #define ANALOG_FLAG_INVERT 0x80 /* analog only: bitwise invert bits */ | |
| 43 | 45 | |
| 46 | ||
| 47 | /* INP file information */ | |
| 44 | 48 | #define INP_HEADER_SIZE 64 |
| 45 | 49 | #define INP_HEADER_MAJVERSION 2 |
| 46 | 50 | #define INP_HEADER_MINVERSION 0 |
| 47 | 51 | |
| 48 | 52 | |
| 49 | /* macro for a custom callback functions (PORT_CUSTOM) */ | |
| 50 | #define CUSTOM_INPUT(name) UINT32 name(running_machine *machine, void *param) | |
| 51 | ||
| 52 | /* macro for port changed callback functions (PORT_CHANGED) */ | |
| 53 | #define INPUT_CHANGED(name) void name(running_machine *machine, void *param, UINT32 oldval, UINT32 newval) | |
| 54 | ||
| 55 | ||
| 56 | 53 | /* sequence types for input_port_seq() call */ |
| 57 | 54 | enum _input_seq_type |
| 58 | 55 | { |
| 59 | 56 | SEQ_TYPE_STANDARD = 0, |
| 60 | SEQ_TYPE_INCREMENT = 1, | |
| 61 | SEQ_TYPE_DECREMENT = 2 | |
| 57 | SEQ_TYPE_INCREMENT, | |
| 58 | SEQ_TYPE_DECREMENT, | |
| 59 | SEQ_TYPE_TOTAL | |
| 62 | 60 | }; |
| 63 | 61 | typedef enum _input_seq_type input_seq_type; |
| 64 | 62 | |
| r2724 | r2725 | |
| 108 | 106 | IPT_END, |
| 109 | 107 | IPT_UNKNOWN, |
| 110 | 108 | IPT_PORT, |
| 111 | IPT_DIPSWITCH_NAME, | |
| 112 | IPT_DIPSWITCH_SETTING, | |
| 109 | IPT_DIPSWITCH, | |
| 113 | 110 | IPT_VBLANK, |
| 114 | IPT_CONFIG_NAME, /* MESS only */ | |
| 115 | IPT_CONFIG_SETTING, /* MESS only */ | |
| 116 | IPT_CATEGORY_NAME, /* MESS only */ | |
| 117 | IPT_CATEGORY_SETTING, /* MESS only */ | |
| 111 | IPT_CONFIG, | |
| 112 | IPT_CATEGORY, /* MESS only */ | |
| 118 | 113 | |
| 119 | 114 | /* start buttons */ |
| 120 | 115 | IPT_START1, |
| r2724 | r2725 | |
| 249 | 244 | IPT_ADJUSTER, |
| 250 | 245 | |
| 251 | 246 | /* the following are special codes for user interface handling - not to be used by drivers! */ |
| 247 | #define __ipt_ui_start IPT_UI_CONFIGURE | |
| 252 | 248 | IPT_UI_CONFIGURE, |
| 253 | 249 | IPT_UI_ON_SCREEN_DISPLAY, |
| 254 | 250 | IPT_UI_DEBUG_BREAK, |
| r2724 | r2725 | |
| 311 | 307 | IPT_OSD_14, |
| 312 | 308 | IPT_OSD_15, |
| 313 | 309 | IPT_OSD_16, |
| 310 | #define __ipt_ui_end IPT_OSD_16 | |
| 314 | 311 | |
| 315 | 312 | /* other meaning not mapped to standard defaults */ |
| 316 | 313 | IPT_OTHER, |
| r2724 | r2725 | |
| 331 | 328 | INPUT_TOKEN_START, |
| 332 | 329 | INPUT_TOKEN_START_TAG, |
| 333 | 330 | INPUT_TOKEN_MODIFY, |
| 334 | INPUT_TOKEN_ | |
| 331 | INPUT_TOKEN_FIELD, | |
| 335 | 332 | INPUT_TOKEN_SPECIAL_ONOFF, |
| 336 | 333 | INPUT_TOKEN_CODE, |
| 337 | 334 | INPUT_TOKEN_CODE_DEC, |
| r2724 | r2725 | |
| 375 | 372 | INPUT_TOKEN_ADJUSTER, |
| 376 | 373 | INPUT_TOKEN_CONFNAME, |
| 377 | 374 | INPUT_TOKEN_CONFSETTING, |
| 378 | #ifdef MESS | |
| 379 | 375 | INPUT_TOKEN_CHAR, |
| 380 | 376 | INPUT_TOKEN_CATEGORY, |
| 381 | 377 | INPUT_TOKEN_CATEGORY_NAME, |
| 382 | INPUT_TOKEN_CATEGORY_SETTING, | |
| 383 | #endif /* MESS */ | |
| 378 | INPUT_TOKEN_CATEGORY_SETTING | |
| 384 | 379 | }; |
| 385 | 380 | |
| 386 | 381 | |
| r2724 | r2725 | |
| 505 | 500 | TYPE DEFINITIONS |
| 506 | 501 | ***************************************************************************/ |
| 507 | 502 | |
| 508 | /* this is an opaque type */ | |
| 509 | typedef struct _input_port_init_params input_port_init_params; | |
| 503 | /* input ports support up to 32 bits each */ | |
| 504 | typedef UINT32 input_port_value; | |
| 510 | 505 | |
| 511 | 506 | |
| 512 | /* a custom input port callback function */ | |
| 513 | typedef UINT32 (*input_port_custom_func)(running_machine *machine, void *param); | |
| 514 | typedef void (*input_port_changed_func)(running_machine *machine, void *param, UINT32 oldval, UINT32 newval); | |
| 507 | /* opaque types pointing to live state */ | |
| 508 | typedef struct _input_port_state input_port_state; | |
| 509 | typedef struct _input_field_state input_field_state; | |
| 515 | 510 | |
| 516 | 511 | |
| 512 | /* forward declarations */ | |
| 513 | typedef struct _input_port_config input_port_config; | |
| 514 | typedef struct _input_field_config input_field_config; | |
| 515 | ||
| 516 | ||
| 517 | /* custom input port callback function */ | |
| 518 | typedef UINT32 (*input_field_custom_func)(const input_field_config *field, void *param); | |
| 519 | ||
| 520 | /* input port changed callback function */ | |
| 521 | typedef void (*input_field_changed_func)(const input_field_config *field, void *param, UINT32 oldval, UINT32 newval); | |
| 522 | ||
| 523 | ||
| 517 | 524 | /* this type is used to encode input port definitions */ |
| 518 | 525 | typedef union _input_port_token input_port_token; |
| 519 | 526 | union _input_port_token |
| 520 | 527 | { |
| 521 | 528 | TOKEN_COMMON_FIELDS |
| 522 | const input_port_token *tokenptr; | |
| 523 | input_port_custom_func customptr; | |
| 524 | input_port_changed_func changedptr; | |
| 529 | const input_port_token * tokenptr; | |
| 530 | input_field_custom_func customptr; | |
| 531 | input_field_changed_func changedptr; | |
| 525 | 532 | }; |
| 526 | 533 | |
| 527 | 534 | |
| 528 | /* In mamecore.h: typedef struct _input_port_default_entry input_port_default_entry; */ | |
| 529 | struct _input_port_default_entry | |
| 535 | /* encapsulates a condition on a port field or setting */ | |
| 536 | typedef struct _input_condition input_condition; | |
| 537 | struct _input_condition | |
| 530 | 538 | { |
| 531 | UINT32 type; /* type of port; see enum above */ | |
| 532 | UINT8 group; /* which group the port belongs to */ | |
| 533 | UINT8 player; /* player number (0 is player 1) */ | |
| 534 | const char *token; /* token used to store settings */ | |
| 535 | const char *name; /* user-friendly name */ | |
| 536 | input_seq defaultseq; /* default input sequence */ | |
| 537 | input_seq defaultincseq; /* default input sequence to increment (analog ports only) */ | |
| 538 | input_seq defaultdecseq; /* default input sequence to decrement (analog ports only) */ | |
| 539 | const char * tag; /* tag of port whose condition is to be tested */ | |
| 540 | input_port_value mask; /* mask to apply to the port */ | |
| 541 | input_port_value value; /* value to compare against */ | |
| 542 | UINT8 condition; /* condition to use */ | |
| 539 | 543 | }; |
| 540 | 544 | |
| 541 | 545 | |
| 542 | /* In mamecore.h: typedef struct _input_port_entry input_port_entry; */ | |
| 543 | struct _input_port_entry | |
| 546 | /* a single setting for a configuration or DIP switch */ | |
| 547 | typedef struct _input_setting_config input_setting_config; | |
| 548 | struct _input_setting_config | |
| 544 | 549 | { |
| 545 | UINT32 mask; /* bits affected */ | |
| 546 | UINT32 default_value; /* default value for the bits affected */ | |
| 547 | /* you can also use one of the IP_ACTIVE defines above */ | |
| 548 | UINT32 type; /* see enum above */ | |
| 549 | UINT8 unused; /* The bit is not used by this game, but is used */ | |
| 550 | /* by other games running on the same hardware. */ | |
| 551 | /* This is different from IPT_UNUSED, which marks */ | |
| 552 | /* bits not connected to anything. */ | |
| 553 | UINT8 cocktail; /* the bit is used in cocktail mode only */ | |
| 554 | UINT8 player; /* the player associated with this port; note that */ | |
| 555 | /* player 1 is '0' */ | |
| 556 | UINT8 toggle; /* When this is set, the key acts as a toggle - press */ | |
| 557 | /* it once and it goes on, press it again and it goes off. */ | |
| 558 | /* useful e.g. for some Test Mode dip switches. */ | |
| 559 | UINT8 impulse; /* When this is set, when the key corresponding to */ | |
| 560 | /* the input bit is pressed it will be reported as */ | |
| 561 | /* pressed for a certain number of video frames and */ | |
| 562 | /* then released, regardless of the real status of */ | |
| 563 | /* the key. This is useful e.g. for some coin inputs. */ | |
| 564 | /* The number of frames the signal should stay active */ | |
| 565 | /* is specified in the "arg" field. */ | |
| 566 | UINT8 way; /* Joystick modes of operation. 8WAY is the default, */ | |
| 567 | /* it prevents left/right or up/down to be pressed at */ | |
| 568 | /* the same time. 4WAY prevents diagonal directions. */ | |
| 569 | /* 2WAY should be used for joysticks wich move only */ | |
| 570 | /* on one axis (e.g. Battle Zone) */ | |
| 571 | UINT8 rotated; /* Indicates the control is rotated 45 degrees. This */ | |
| 572 | /* is used as a hint for joystick mapping. */ | |
| 573 | UINT16 category; /* (MESS-specific) category */ | |
| 574 | const char *name; /* user-friendly name to display */ | |
| 575 | input_seq seq; /* input sequence affecting the input bits */ | |
| 576 | input_port_custom_func custom;/* custom callback routine */ | |
| 577 | void * custom_param; /* parameter for custom callback routine */ | |
| 578 | input_port_changed_func changed;/* changed callback routine */ | |
| 579 | void * changed_param; /* parameter for changed callback routine */ | |
| 580 | UINT32 changed_last_value; /* the last value for changed detection purposes */ | |
| 550 | const input_setting_config *next; /* pointer to next setting in sequence */ | |
| 551 | const input_field_config * field; /* pointer back to the field that owns us */ | |
| 552 | input_port_value value; /* value of the bits in this setting */ | |
| 553 | input_condition condition; /* condition under which this setting is valid */ | |
| 554 | const char * name; /* user-friendly name to display */ | |
| 555 | }; | |
| 581 | 556 | |
| 582 | /* valid if type is between __ipt_analog_start and __ipt_analog_end */ | |
| 583 | struct | |
| 584 | { | |
| 585 | INT32 min; /* minimum value for absolute axes */ | |
| 586 | INT32 max; /* maximum value for absolute axes */ | |
| 587 | INT32 sensitivity; /* sensitivity (100=normal) */ | |
| 588 | INT32 delta; /* delta to apply each frame a digital inc/dec key is pressed */ | |
| 589 | INT32 centerdelta; /* delta to apply each frame no digital inputs are pressed */ | |
| 590 | UINT8 reverse; /* reverse the sense of the analog axis */ | |
| 591 | UINT8 reset; /* always preload in->default for relative axes, returning only deltas */ | |
| 592 | UINT8 crossaxis; /* crosshair axis */ | |
| 593 | float crossscale; /* crosshair scale */ | |
| 594 | float crossoffset; /* crosshair offset */ | |
| 595 | float crossaltaxis; /* crosshair alternate axis value */ | |
| 596 | input_seq incseq; /* increment sequence */ | |
| 597 | input_seq decseq; /* decrement sequence */ | |
| 598 | UINT8 wraps; /* positional count wraps around */ | |
| 599 | UINT8 invert; /* bitwise invert bits */ | |
| 600 | UINT16 full_turn_count; /* number of optical counts for 1 full turn of the original control */ | |
| 601 | const UINT32 *remap_table; /* pointer to an array that remaps the port value */ | |
| 602 | } analog; | |
| 603 | 557 | |
| 604 | /* valid if type is IPT_PORT */ | |
| 605 | struct | |
| 606 | { | |
| 607 | const char *tag; /* used to tag PORT_START declarations */ | |
| 608 | } start; | |
| 558 | /* a mapping from a bit to a physical DIP switch description */ | |
| 559 | typedef struct _input_field_diplocation input_field_diplocation; | |
| 560 | struct _input_field_diplocation | |
| 561 | { | |
| 562 | input_field_diplocation * next; /* pointer to the next bit */ | |
| 563 | const char * swname; /* name of the physical DIP switch */ | |
| 564 | UINT8 swnum; /* physical switch number */ | |
| 565 | UINT8 invert; /* is this an active-high DIP? */ | |
| 566 | }; | |
| 609 | 567 | |
| 610 | /* valid for most types */ | |
| 611 | struct | |
| 612 | { | |
| 613 | const char *tag; /* port tag to use for condition */ | |
| 614 | UINT8 portnum; /* port number for condition */ | |
| 615 | UINT8 condition; /* condition to use */ | |
| 616 | UINT32 mask; /* mask to apply to the port */ | |
| 617 | UINT32 value; /* value to compare against */ | |
| 618 | } condition; | |
| 619 | 568 | |
| 620 | /* valid for IPT_DIPNAME */ | |
| 621 | struct | |
| 622 | { | |
| 623 | const char *swname; /* name of the physical DIP switch */ | |
| 624 | UINT8 swnum; /* physical switch number */ | |
| 625 | UINT8 invert; /* is this an active-high DIP? */ | |
| 626 | } diploc[8]; | |
| 569 | /* a single bitfield within an input port */ | |
| 570 | struct _input_field_config | |
| 571 | { | |
| 572 | /* generally-applicable data */ | |
| 573 | const input_field_config * next; /* pointer to next field in sequence */ | |
| 574 | const input_port_config * port; /* pointer back to the port that owns us */ | |
| 575 | input_port_value mask; /* mask of bits belonging to the field */ | |
| 576 | input_port_value defvalue; /* default value of these bits */ | |
| 577 | input_condition condition; /* condition under which this field is relevant */ | |
| 578 | UINT32 type; /* IPT_* type for this port */ | |
| 579 | UINT8 player; /* player number (0-based) */ | |
| 580 | UINT16 category; /* (MESS-specific) category */ | |
| 581 | UINT32 flags; /* combination of FIELD_FLAG_* and ANALOG_FLAG_* above */ | |
| 582 | UINT8 impulse; /* number of frames before reverting to defvalue */ | |
| 583 | const char * name; /* user-friendly name to display */ | |
| 584 | input_seq seq[SEQ_TYPE_TOTAL];/* sequences of all types */ | |
| 585 | input_field_custom_func custom; /* custom callback routine */ | |
| 586 | void * custom_param; /* parameter for custom callback routine */ | |
| 587 | input_field_changed_func changed; /* changed callback routine */ | |
| 588 | void * changed_param; /* parameter for changed callback routine */ | |
| 627 | 589 | |
| 628 | /* valid if type is IPT_KEYBOARD */ | |
| 629 | #ifdef MESS | |
| 630 | struct | |
| 631 | { | |
| 632 | unicode_char chars[3]; /* (MESS-specific) unicode key data */ | |
| 633 | } keyboard; | |
| 634 | #endif /* MESS */ | |
| 590 | /* data relevant to analog control types */ | |
| 591 | INT32 min; /* minimum value for absolute axes */ | |
| 592 | INT32 max; /* maximum value for absolute axes */ | |
| 593 | INT32 sensitivity; /* sensitivity (100=normal) */ | |
| 594 | INT32 delta; /* delta to apply each frame a digital inc/dec key is pressed */ | |
| 595 | INT32 centerdelta; /* delta to apply each frame no digital inputs are pressed */ | |
| 596 | UINT8 crossaxis; /* crosshair axis */ | |
| 597 | float crossscale; /* crosshair scale */ | |
| 598 | float crossoffset; /* crosshair offset */ | |
| 599 | float crossaltaxis; /* crosshair alternate axis value */ | |
| 600 | UINT16 full_turn_count;/* number of optical counts for 1 full turn of the original control */ | |
| 601 | const input_port_value * remap_table; /* pointer to an array that remaps the port value */ | |
| 602 | ||
| 603 | /* data relevant to other specific types */ | |
| 604 | const input_setting_config *settinglist; /* list of input_setting_configs */ | |
| 605 | const input_field_diplocation *diploclist; /* list of locations for various bits */ | |
| 606 | UINT8 way; /* digital joystick 2/4/8-way descriptions */ | |
| 607 | unicode_char chars[3]; /* (MESS-specific) unicode key data */ | |
| 608 | ||
| 609 | /* this field is only valid if the device is live */ | |
| 610 | input_field_state * state; /* live state of field (NULL if not live) */ | |
| 635 | 611 | }; |
| 636 | 612 | |
| 637 | 613 | |
| 614 | /* user-controllable settings for a field */ | |
| 615 | typedef struct _input_field_user_settings input_field_user_settings; | |
| 616 | struct _input_field_user_settings | |
| 617 | { | |
| 618 | input_port_value value; /* for DIP switches */ | |
| 619 | input_seq seq[SEQ_TYPE_TOTAL];/* sequences of all types */ | |
| 620 | INT32 sensitivity; /* for analog controls */ | |
| 621 | INT32 delta; /* for analog controls */ | |
| 622 | INT32 centerdelta; /* for analog controls */ | |
| 623 | UINT8 reverse; /* for analog controls */ | |
| 624 | }; | |
| 625 | ||
| 626 | ||
| 627 | /* a single input port configuration */ | |
| 628 | struct _input_port_config | |
| 629 | { | |
| 630 | const input_port_config * next; /* pointer to next port */ | |
| 631 | const char * tag; /* pointer to this port's tag */ | |
| 632 | const input_field_config * fieldlist; /* list of input_field_configs */ | |
| 633 | ||
| 634 | /* these two fields are only valid if the port is live */ | |
| 635 | input_port_state * state; /* live state of port (NULL if not live) */ | |
| 636 | running_machine * machine; /* machine if port is live */ | |
| 637 | }; | |
| 638 | ||
| 639 | ||
| 640 | /* describes a fundamental input type, including default input sequences */ | |
| 641 | typedef struct _input_type_desc input_type_desc; | |
| 642 | struct _input_type_desc | |
| 643 | { | |
| 644 | input_type_desc * next; /* next description in the list */ | |
| 645 | UINT32 type; /* IPT_* for this entry */ | |
| 646 | UINT8 group; /* which group the port belongs to */ | |
| 647 | UINT8 player; /* player number (0 is player 1) */ | |
| 648 | const char * token; /* token used to store settings */ | |
| 649 | const char * name; /* user-friendly name */ | |
| 650 | input_seq seq[SEQ_TYPE_TOTAL];/* default input sequence */ | |
| 651 | }; | |
| 652 | ||
| 653 | ||
| 654 | /* heaeder at the front of INP files */ | |
| 638 | 655 | typedef struct _inp_header inp_header; |
| 639 | 656 | struct _inp_header |
| 640 | 657 | { |
| 641 | char header[8]; /* +00: 8 byte header - must be "MAMEINP\0" */ | |
| 642 | UINT64 basetime; /* +08: base time of recording */ | |
| 643 | UINT8 majversion; /* +10: major INP version */ | |
| 644 | UINT8 minversion; /* +11: minor INP version */ | |
| 645 | UINT8 reserved[2]; /* +12: must be zero */ | |
| 646 | char gamename[12]; /* +14: game name string, NULL-terminated */ | |
| 647 | char version[32]; /* +20: system version string, NULL-terminated */ | |
| 658 | char header[8]; /* +00: 8 byte header - must be "MAMEINP\0" */ | |
| 659 | UINT64 basetime; /* +08: base time of recording */ | |
| 660 | UINT8 majversion; /* +10: major INP version */ | |
| 661 | UINT8 minversion; /* +11: minor INP version */ | |
| 662 | UINT8 reserved[2]; /* +12: must be zero */ | |
| 663 | char gamename[12]; /* +14: game name string, NULL-terminated */ | |
| 664 | char version[32]; /* +20: system version string, NULL-terminated */ | |
| 648 | 665 | }; |
| 649 | 666 | |
| 650 | 667 | |
| 651 | 668 | |
| 652 | 669 | /*************************************************************************** |
| 670 | MACROS | |
| 671 | ***************************************************************************/ | |
| 672 | ||
| 673 | /* macro for a custom callback functions (PORT_CUSTOM) */ | |
| 674 | #define CUSTOM_INPUT(name) UINT32 name(const input_field_config *field, void *param) | |
| 675 | ||
| 676 | /* macro for port changed callback functions (PORT_CHANGED) */ | |
| 677 | #define INPUT_CHANGED(name) void name(const input_field_config *field, void *param, UINT32 oldval, UINT32 newval) | |
| 678 | ||
| 679 | /* macro for wrapping a default string */ | |
| 680 | #define DEF_STR(str_num) ((const char *)INPUT_STRING_##str_num) | |
| 681 | ||
| 682 | ||
| 683 | ||
| 684 | /*************************************************************************** | |
| 653 | 685 | MACROS FOR BUILDING INPUT PORTS |
| 654 | 686 | ***************************************************************************/ |
| 655 | 687 | |
| 656 | #define IP_NAME_DEFAULT NULL | |
| 657 | ||
| 658 | 688 | /* start of table */ |
| 659 | 689 | #define INPUT_PORTS_START(_name) \ |
| 660 | 690 | const input_port_token ipt_##_name[] = { |
| r2724 | r2725 | |
| 688 | 718 | |
| 689 | 719 | /* input bit definition */ |
| 690 | 720 | #define PORT_BIT(_mask, _default, _type) \ |
| 691 | TOKEN_UINT32_PACK2(INPUT_TOKEN_ | |
| 721 | TOKEN_UINT32_PACK2(INPUT_TOKEN_FIELD, 8, _type, 24), \ | |
| 692 | 722 | TOKEN_UINT64_PACK2(_mask, 32, _default, 32), |
| 693 | 723 | |
| 694 | 724 | #define PORT_SPECIAL_ONOFF(_mask, _default, _strindex) \ |
| r2724 | r2725 | |
| 845 | 875 | TOKEN_UINT64_PACK2(INPUT_TOKEN_CONFSETTING, 8, _default, 32), \ |
| 846 | 876 | TOKEN_STRING(_name), |
| 847 | 877 | |
| 848 | #ifdef MESS | |
| 849 | 878 | /* keyboard chars */ |
| 850 | 879 | #define PORT_CHAR(_ch) \ |
| 851 | 880 | TOKEN_UINT64_PACK2(INPUT_TOKEN_CHAR, 8, _ch, 32), \ |
| r2724 | r2725 | |
| 862 | 891 | #define PORT_CATEGORY_ITEM(_default, _name, _category) \ |
| 863 | 892 | TOKEN_UINT64_PACK3(INPUT_TOKEN_CATEGORY_SETTING, 8, _default, 32, _category, 16), \ |
| 864 | 893 | TOKEN_STRING(_name), |
| 865 | #endif /* MESS */ | |
| 866 | 894 | |
| 867 | 895 | |
| 868 | 896 | |
| r2724 | r2725 | |
| 894 | 922 | |
| 895 | 923 | |
| 896 | 924 | /*************************************************************************** |
| 897 | | |
| 925 | FUNCTION | |
| 898 | 926 | ***************************************************************************/ |
| 899 | 927 | |
| 900 | #define DEF_STR(str_num) ((const char *)INPUT_STRING_##str_num) | |
| 901 | 928 | |
| 929 | /* ----- core system management ----- */ | |
| 902 | 930 | |
| 903 | /*************************************************************************** | |
| 904 | FUNCTION PROTOTYPES | |
| 905 | ***************************************************************************/ | |
| 931 | /* initialize the input ports, processing the given token list */ | |
| 932 | time_t input_port_init(running_machine *machine, const input_port_token *tokens); | |
| 906 | 933 | |
| 907 | time_t input_port_init(running_machine *machine, const input_port_token *ipt); | |
| 908 | const char *input_port_string_from_token(const input_port_token token); | |
| 909 | 934 | |
| 910 | input_port_entry *input_port_initialize(input_port_init_params *params, UINT32 type, const char *tag, UINT32 mask, UINT32 defval); | |
| 911 | input_port_entry *input_port_allocate(const input_port_token *ipt, input_port_entry *memory); | |
| 912 | void input_port_parse_diplocation(input_port_entry *in, const char *location); | |
| 913 | 935 | |
| 914 | input_port_default_entry *get_input_port_list(void); | |
| 915 | const input_port_default_entry *get_input_port_list_defaults(void); | |
| 936 | /* ----- port configurations ----- */ | |
| 916 | 937 | |
| 917 | int input_port_active(const input_port_entry *in); | |
| 918 | int port_type_is_analog(int type); | |
| 919 | int port_type_is_analog_absolute(int type); | |
| 920 | int port_type_in_use(int type); | |
| 921 | int port_type_to_group(int type, int player); | |
| 922 | int port_tag_to_index(const char *tag); | |
| 923 | read8_machine_func port_tag_to_handler8(const char *tag); | |
| 924 | read16_machine_func port_tag_to_handler16(const char *tag); | |
| 925 | read32_machine_func port_tag_to_handler32(const char *tag); | |
| 926 | read64_machine_func port_tag_to_handler64(const char *tag); | |
| 927 | const char *input_port_name(const input_port_entry *in); | |
| 928 | const input_seq *input_port_seq(input_port_entry *in, input_seq_type seqtype); | |
| 929 | const input_seq *input_port_default_seq(int type, int player, input_seq_type seqtype); | |
| 930 | int input_port_condition(const input_port_entry *in); | |
| 938 | /* allocate a list of input ports from the given token list */ | |
| 939 | const input_port_config *input_port_config_alloc(const input_port_token *tokens); | |
| 931 | 940 | |
| 932 | const char *port_type_to_token(int type, int player); | |
| 933 | int token_to_port_type(const char *string, int *player); | |
| 941 | /* free memory allocated from input_port_alloc */ | |
| 942 | void input_port_config_free(const input_port_config *portlist); | |
| 934 | 943 | |
| 935 | int input_port_type_pressed(int type, int player); | |
| 936 | int input_ui_pressed(int code); | |
| 937 | int input_ui_pressed_repeat(int code, int speed); | |
| 944 | /* return the config that matches the given tag */ | |
| 945 | const input_port_config *input_port_by_tag(const input_port_config *portlist, const char *tag); | |
| 938 | 946 | |
| 939 | void input_port_update_defaults(void); | |
| 947 | /* return the config that matches the given tag */ | |
| 948 | const input_port_config *input_port_by_index(const input_port_config *portlist, int index); | |
| 940 | 949 | |
| 941 | UINT32 get_crosshair_pos(int port_num, UINT8 player, UINT8 axis); | |
| 942 | 950 | |
| 943 | UINT32 input_port_read_indexed(running_machine *machine, int port); | |
| 944 | UINT32 input_port_read(running_machine *machine, const char *tag); | |
| 945 | UINT32 input_port_read_safe(running_machine *machine, const char *tag, UINT32 defvalue); | |
| 946 | 951 | |
| 952 | /* ----- accessors for input types ----- */ | |
| 953 | ||
| 954 | /* return TRUE if the given type represents an analog control */ | |
| 955 | int input_type_is_analog(int type); | |
| 956 | ||
| 957 | /* return the name for the given type/player */ | |
| 958 | const char *input_type_name(running_machine *machine, int type, int player); | |
| 959 | ||
| 960 | /* return the group for the given type/player */ | |
| 961 | int input_type_group(running_machine *machine, int type, int player); | |
| 962 | ||
| 963 | /* return the global input mapping sequence for the given type/player */ | |
| 964 | const input_seq *input_type_seq(running_machine *machine, int type, int player, input_seq_type seqtype); | |
| 965 | ||
| 966 | /* change the global input sequence for the given type/player */ | |
| 967 | void input_type_set_seq(running_machine *machine, int type, int player, input_seq_type seqtype, const input_seq *newseq); | |
| 968 | ||
| 969 | /* return TRUE if the sequence for the given input type/player is pressed */ | |
| 970 | int input_type_pressed(running_machine *machine, int type, int player); | |
| 971 | ||
| 972 | /* return the list of default mappings */ | |
| 973 | const input_type_desc *input_type_list(running_machine *machine); | |
| 974 | ||
| 975 | ||
| 976 | ||
| 977 | /* ----- accessors for input fields ----- */ | |
| 978 | ||
| 979 | /* return the expanded string name of the field */ | |
| 980 | const char *input_field_name(const input_field_config *field); | |
| 981 | ||
| 982 | /* return the input sequence for the given input field */ | |
| 983 | const input_seq *input_field_seq(const input_field_config *field, input_seq_type seqtype); | |
| 984 | ||
| 985 | /* return the current settings for the given input field */ | |
| 986 | void input_field_get_user_settings(const input_field_config *field, input_field_user_settings *settings); | |
| 987 | ||
| 988 | /* modify the current settings for the given input field */ | |
| 989 | void input_field_set_user_settings(const input_field_config *field, const input_field_user_settings *settings); | |
| 990 | ||
| 991 | ||
| 992 | ||
| 993 | /* ----- user interface sequence reading ----- */ | |
| 994 | ||
| 995 | /* return TRUE if a key down for the given user interface sequence is detected */ | |
| 996 | int input_ui_pressed(running_machine *machine, int code); | |
| 997 | ||
| 998 | /* return TRUE if a key down for the given user interface sequence is detected, or if | |
| 999 | autorepeat at the given speed is triggered */ | |
| 1000 | int input_ui_pressed_repeat(running_machine *machine, int code, int speed); | |
| 1001 | ||
| 1002 | ||
| 1003 | ||
| 1004 | /* ----- port reading ----- */ | |
| 1005 | ||
| 1006 | /* return the value of an input port */ | |
| 1007 | input_port_value input_port_read_direct(const input_port_config *port); | |
| 1008 | ||
| 1009 | /* return the value of an input port specified by tag */ | |
| 1010 | input_port_value input_port_read(running_machine *machine, const char *tag); | |
| 1011 | ||
| 1012 | /* return the value of an input port specified by tag, or a default value if the port does not exist */ | |
| 1013 | input_port_value input_port_read_safe(running_machine *machine, const char *tag, input_port_value defvalue); | |
| 1014 | ||
| 1015 | /* return the value of an input port specified by index */ | |
| 1016 | input_port_value input_port_read_indexed(running_machine *machine, int portnum); | |
| 1017 | ||
| 1018 | /* return the extracted crosshair values for the given player */ | |
| 1019 | int input_port_get_crosshair_position(running_machine *machine, int player, float *x, float *y); | |
| 1020 | ||
| 1021 | /* force an update to the input port values based on current conditions */ | |
| 1022 | void input_port_update_defaults(running_machine *machine); | |
| 1023 | ||
| 1024 | ||
| 1025 | ||
| 1026 | /* ----- misc helper functions ----- */ | |
| 1027 | ||
| 1028 | /* return the TRUE if the given condition attached is true */ | |
| 1029 | int input_condition_true(running_machine *machine, const input_condition *condition); | |
| 1030 | ||
| 1031 | /* convert an input_port_token to a default string */ | |
| 1032 | const char *input_port_string_from_token(const input_port_token token); | |
| 1033 | ||
| 1034 | /* return a memory handler corresponding to a given input port tag */ | |
| 1035 | read8_machine_func input_port_read_handler8(const input_port_config *portlist, const char *tag); | |
| 1036 | read16_machine_func input_port_read_handler16(const input_port_config *portlist, const char *tag); | |
| 1037 | read32_machine_func input_port_read_handler32(const input_port_config *portlist, const char *tag); | |
| 1038 | read64_machine_func input_port_read_handler64(const input_port_config *portlist, const char *tag); | |
| 1039 | ||
| 1040 | ||
| 947 | 1041 | #endif /* __INPTPORT_H__ */ |
| r2724 | r2725 | |
|---|---|---|
| 66 | 66 | typedef struct _rom_load_data rom_load_data; |
| 67 | 67 | typedef struct _osd_create_params osd_create_params; |
| 68 | 68 | typedef struct _gfx_element gfx_element; |
| 69 | typedef struct _input_port_entry input_port_entry; | |
| 70 | typedef struct _input_port_default_entry input_port_default_entry; | |
| 71 | 69 | typedef struct _mame_file mame_file; |
| 72 | 70 | |
| 73 | 71 |
| r2724 | r2725 | |
|---|---|---|
| 4 | 4 | |
| 5 | 5 | struct YMF262interface |
| 6 | 6 | { |
| 7 | void (*handler)(int irq); | |
| 7 | void (*handler)(running_machine *machine, int irq); | |
| 8 | 8 | }; |
| 9 | 9 | |
| 10 | 10 |
| r2724 | r2725 | |
|---|---|---|
| 7 | 7 | Additional tweaking by Aaron Giles |
| 8 | 8 | Various fixes by Lord Nightmare |
| 9 | 9 | Additional enhancements by Couriersud |
| 10 | Sub-interpolation-cycle parameter updating added by Lord Nightmare | |
| 10 | 11 | |
| 11 | 12 | Todo: |
| 12 | 13 | - implement CS |
| r2724 | r2725 | |
| 417 | 418 | { |
| 418 | 419 | struct tms5110 *tms = chip; |
| 419 | 420 | int buf_count=0; |
| 420 | int i, interp_period; | |
| 421 | int i, interp_period, bitout; | |
| 421 | 422 | INT16 Y11, cliptemp; |
| 422 | 423 | |
| 423 | 424 | /* if we're not speaking, fill with nothingness */ |
| r2724 | r2725 | |
| 542 | 543 | tms->target_k[i] = tms->new_k[i]; |
| 543 | 544 | } |
| 544 | 545 | } |
| 545 | else | |
| 546 | else | |
| 546 | 547 | { |
| 547 | /* interpolate (update) values based on step values */ | |
| 548 | /*logerror("\n");*/ | |
| 549 | ||
| 550 | 548 | interp_period = tms->sample_count / 25; |
| 551 | tms->current_energy += (tms->target_energy - tms->current_energy) / tms->coeff->interp_coeff[interp_period]; | |
| 552 | tms->current_pitch += (tms->target_pitch - tms->current_pitch) / tms->coeff->interp_coeff[interp_period]; | |
| 553 | ||
| 554 | /*logerror("*** Energy = %d\n",current_energy);*/ | |
| 555 | ||
| 556 | for (i = 0; i < tms->coeff->num_k; i++) | |
| 549 | switch(tms->interp_count) | |
| 557 | 550 | { |
| 558 | tms->current_k[i] += (tms->target_k[i] - tms->current_k[i]) / tms->coeff->interp_coeff[interp_period]; | |
| 551 | /* PC=X X cycle, rendering change (change for next cycle which chip is actually doing) */ | |
| 552 | case 0: /* PC=0, A cycle, nothing happens (calc energy) */ | |
| 553 | break; | |
| 554 | case 1: /* PC=0, B cycle, nothing happens (update energy) */ | |
| 555 | break; | |
| 556 | case 2: /* PC=1, A cycle, update energy (calc pitch) */ | |
| 557 | tms->current_energy += ((tms->target_energy - tms->current_energy) >> tms->coeff->interp_coeff[interp_period]); | |
| 558 | break; | |
| 559 | case 3: /* PC=1, B cycle, nothing happens (update pitch) */ | |
| 560 | break; | |
| 561 | case 4: /* PC=2, A cycle, update pitch (calc K1) */ | |
| 562 | tms->current_pitch += ((tms->target_pitch - tms->current_pitch) >> tms->coeff->interp_coeff[interp_period]); | |
| 563 | break; | |
| 564 | case 5: /* PC=2, B cycle, nothing happens (update K1) */ | |
| 565 | break; | |
| 566 | case 6: /* PC=3, A cycle, update K1 (calc K2) */ | |
| 567 | tms->current_k[0] += ((tms->target_k[0] - tms->current_k[0]) >> tms->coeff->interp_coeff[interp_period]); | |
| 568 | break; | |
| 569 | case 7: /* PC=3, B cycle, nothing happens (update K2) */ | |
| 570 | break; | |
| 571 | case 8: /* PC=4, A cycle, update K2 (calc K3) */ | |
| 572 | tms->current_k[1] += ((tms->target_k[1] - tms->current_k[1]) >> tms->coeff->interp_coeff[interp_period]); | |
| 573 | break; | |
| 574 | case 9: /* PC=4, B cycle, nothing happens (update K3) */ | |
| 575 | break; | |
| 576 | case 10: /* PC=5, A cycle, update K3 (calc K4) */ | |
| 577 | tms->current_k[2] += ((tms->target_k[2] - tms->current_k[2]) >> tms->coeff->interp_coeff[interp_period]); | |
| 578 | break; | |
| 579 | case 11: /* PC=5, B cycle, nothing happens (update K4) */ | |
| 580 | break; | |
| 581 | case 12: /* PC=6, A cycle, update K4 (calc K5) */ | |
| 582 | tms->current_k[3] += ((tms->target_k[3] - tms->current_k[3]) >> tms->coeff->interp_coeff[interp_period]); | |
| 583 | break; | |
| 584 | case 13: /* PC=6, B cycle, nothing happens (update K5) */ | |
| 585 | break; | |
| 586 | case 14: /* PC=7, A cycle, update K5 (calc K6) */ | |
| 587 | tms->current_k[4] += ((tms->target_k[4] - tms->current_k[4]) >> tms->coeff->interp_coeff[interp_period]); | |
| 588 | break; | |
| 589 | case 15: /* PC=7, B cycle, nothing happens (update K6) */ | |
| 590 | break; | |
| 591 | case 16: /* PC=8, A cycle, update K6 (calc K7) */ | |
| 592 | tms->current_k[5] += ((tms->target_k[5] - tms->current_k[5]) >> tms->coeff->interp_coeff[interp_period]); | |
| 593 | break; | |
| 594 | case 17: /* PC=8, B cycle, nothing happens (update K7) */ | |
| 595 | break; | |
| 596 | case 18: /* PC=9, A cycle, update K7 (calc K8) */ | |
| 597 | tms->current_k[6] += ((tms->target_k[6] - tms->current_k[6]) >> tms->coeff->interp_coeff[interp_period]); | |
| 598 | break; | |
| 599 | case 19: /* PC=9, B cycle, nothing happens (update K8) */ | |
| 600 | break; | |
| 601 | case 20: /* PC=10, A cycle, update K8 (calc K9) */ | |
| 602 | tms->current_k[7] += ((tms->target_k[7] - tms->current_k[7]) >> tms->coeff->interp_coeff[interp_period]); | |
| 603 | break; | |
| 604 | case 21: /* PC=10, B cycle, nothing happens (update K9) */ | |
| 605 | break; | |
| 606 | case 22: /* PC=11, A cycle, update K9 (calc K10) */ | |
| 607 | tms->current_k[8] += ((tms->target_k[8] - tms->current_k[8]) >> tms->coeff->interp_coeff[interp_period]); | |
| 608 | break; | |
| 609 | case 23: /* PC=11, B cycle, nothing happens (update K10) */ | |
| 610 | break; | |
| 611 | case 24: /* PC=12, A cycle, update K10 (do nothing) */ | |
| 612 | tms->current_k[9] += ((tms->target_k[9] - tms->current_k[9]) >> tms->coeff->interp_coeff[interp_period]); | |
| 613 | break; | |
| 559 | 614 | } |
| 560 | 615 | } |
| 561 | 616 | |
| 562 | 617 | |
| 618 | /* calculate the output */ | |
| 563 | 619 | |
| 564 | ||
| 565 | ||
| 566 | /* calculate the output */ | |
| 567 | ||
| 568 | 620 | if (tms->current_energy == 0) |
| 569 | 621 | { |
| 570 | 622 | /* generate silent samples here */ |
| r2724 | r2725 | |
| 572 | 624 | } |
| 573 | 625 | else if (tms->old_pitch == 0) |
| 574 | 626 | { |
| 575 | int bitout, randbit; | |
| 576 | ||
| 577 | 627 | /* generate unvoiced samples here */ |
| 578 | 628 | if (tms->RNG&1) |
| 579 | r | |
| 629 | curren | |
| 580 | 630 | else |
| 581 | r | |
| 631 | curren | |
| 582 | 632 | |
| 583 | bitout = ((tms->RNG>>12)&1) ^ | |
| 584 | ((tms->RNG>>10)&1) ^ | |
| 585 | ((tms->RNG>> 9)&1) ^ | |
| 586 | ((tms->RNG>> 0)&1); | |
| 587 | tms->RNG >>= 1; | |
| 588 | tms->RNG |= (bitout<<12); | |
| 589 | ||
| 590 | current_val = randbit; | |
| 591 | 633 | } |
| 592 | 634 | else |
| 593 | 635 | { |
| r2724 | r2725 | |
| 608 | 650 | current_val = tms->coeff->chirptable[tms->pitch_count]; |
| 609 | 651 | } |
| 610 | 652 | |
| 653 | /* Update LFSR *20* times every sample, like patent shows */ | |
| 654 | for (i=0; i<20; i++) | |
| 655 | { | |
| 656 | bitout = ((tms->RNG>>12)&1) ^ | |
| 657 | ((tms->RNG>>10)&1) ^ | |
| 658 | ((tms->RNG>> 9)&1) ^ | |
| 659 | ((tms->RNG>> 0)&1); | |
| 660 | tms->RNG >>= 1; | |
| 661 | tms->RNG |= (bitout<<12); | |
| 662 | } | |
| 611 | 663 | |
| 612 | 664 | /* Lattice filter here */ |
| 613 | 665 |
| r2724 | r2725 | |
|---|---|---|
| 31 | 31 | static void IRQHandler(void *param,int irq) |
| 32 | 32 | { |
| 33 | 33 | struct ym2612_info *info = param; |
| 34 | if(info->intf->handler) info->intf->handler(irq); | |
| 34 | if(info->intf->handler) info->intf->handler(Machine, irq); | |
| 35 | 35 | } |
| 36 | 36 | |
| 37 | 37 | /* Timer overflow callback from timer.c */ |
| r2724 | r2725 | |
|---|---|---|
| 3 | 3 | |
| 4 | 4 | struct YM2612interface |
| 5 | 5 | { |
| 6 | void (*handler)(int irq); | |
| 6 | void (*handler)(running_machine *machine, int irq); | |
| 7 | 7 | }; |
| 8 | 8 | |
| 9 | 9 | |
| r2724 | r2725 | |
| 33 | 33 | |
| 34 | 34 | struct YM3438interface |
| 35 | 35 | { |
| 36 | void (*handler)(int irq); | |
| 36 | void (*handler)(running_machine *machine, int irq); | |
| 37 | 37 | }; |
| 38 | 38 | |
| 39 | 39 |
| r2724 | r2725 | |
|---|---|---|
| 430 | 430 | { |
| 431 | 431 | struct k054539_info *info = ptr; |
| 432 | 432 | if(info->regs[0x22f] & 0x20) |
| 433 | info->intf->irq | |
| 433 | info->intf->irq | |
| 434 | 434 | } |
| 435 | 435 | |
| 436 | 436 | static void K054539_init_chip(struct k054539_info *info, int clock, int sndindex) |
| r2724 | r2725 | |
|---|---|---|
| 22 | 22 | |
| 23 | 23 | struct dss_adjustment_context |
| 24 | 24 | { |
| 25 | | |
| 25 | const input_port_config *port; | |
| 26 | 26 | INT32 lastpval; |
| 27 | 27 | INT32 pmin; |
| 28 | 28 | double pscale; |
| r2724 | r2725 | |
| 122 | 122 | if (DSS_ADJUSTMENT__ENABLE) |
| 123 | 123 | { |
| 124 | 124 | struct dss_adjustment_context *context = node->context; |
| 125 | INT32 rawportval = input_port_read_ | |
| 125 | INT32 rawportval = input_port_read_ | |
| 126 | 126 | |
| 127 | 127 | /* only recompute if the value changed from last time */ |
| 128 | 128 | if (rawportval != context->lastpval) |
| r2724 | r2725 | |
| 150 | 150 | |
| 151 | 151 | if (node->custom) |
| 152 | 152 | { |
| 153 | context->port = port_tag_to_index(node->custom); | |
| 154 | if (context->port == -1) | |
| 153 | context->port = input_port_by_tag(Machine->portconfig, node->custom); | |
| 154 | if (context->port == NULL) | |
| 155 | 155 | fatalerror("DISCRETE_ADJUSTMENT_TAG - NODE_%d has invalid tag", node->node-NODE_00); |
| 156 | 156 | } |
| 157 | 157 | else |
| 158 | context->port = DSS_ADJUSTMENT__PORT; | |
| 158 | context->port = input_port_by_index(Machine->portconfig, DSS_ADJUSTMENT__PORT); | |
| 159 | 159 | |
| 160 | 160 | context->lastpval = 0x7fffffff; |
| 161 | 161 | context->pmin = DSS_ADJUSTMENT__PMIN; |
| r2724 | r2725 | |
|---|---|---|
| 9 | 9 | struct K054539interface { |
| 10 | 10 | int region; /* memory regions of sample ROM(s) */ |
| 11 | 11 | void (*apan)(double, double); /* Callback for analog output mixing levels (0..1 for each channel) */ |
| 12 | void (*irq)( | |
| 12 | void (*irq)(running_machine *); | |
| 13 | 13 | }; |
| 14 | 14 | |
| 15 | 15 |
| r2724 | r2725 | |
|---|---|---|
| 116 | 116 | int val; |
| 117 | 117 | int new_signal; |
| 118 | 118 | /* callback user handler and latch next data */ |
| 119 | if(voice->intf->vclk_callback) (*voice->intf->vclk_callback)(voice->index); | |
| 119 | if(voice->intf->vclk_callback) (*voice->intf->vclk_callback)(machine, voice->index); | |
| 120 | 120 | |
| 121 | 121 | /* reset check at last hieddge of VCLK */ |
| 122 | 122 | if(voice->reset) |
| r2724 | r2725 | |
|---|---|---|
| 16 | 16 | |
| 17 | 17 | struct MSM5205interface |
| 18 | 18 | { |
| 19 | void (*vclk_callback)(int); /* VCLK callback */ | |
| 19 | void (*vclk_callback)(running_machine *, int); /* VCLK callback */ | |
| 20 | 20 | int select; /* prescaler / bit width selector */ |
| 21 | 21 | }; |
| 22 | 22 |
| r2724 | r2725 | |
|---|---|---|
| 38 | 38 | static void IRQHandler_3812(void *param,int irq) |
| 39 | 39 | { |
| 40 | 40 | struct ym3812_info *info = param; |
| 41 | if (info->intf->handler) (info->intf->handler)(irq ? ASSERT_LINE : CLEAR_LINE); | |
| 41 | if (info->intf->handler) (info->intf->handler)(Machine, irq ? ASSERT_LINE : CLEAR_LINE); | |
| 42 | 42 | } |
| 43 | 43 | static TIMER_CALLBACK( timer_callback_3812_0 ) |
| 44 | 44 | { |
| r2724 | r2725 | |
| 207 | 207 | static void IRQHandler_3526(void *param,int irq) |
| 208 | 208 | { |
| 209 | 209 | struct ym3526_info *info = param; |
| 210 | if (info->intf->handler) (info->intf->handler)(irq ? ASSERT_LINE : CLEAR_LINE); | |
| 210 | if (info->intf->handler) (info->intf->handler)(Machine, irq ? ASSERT_LINE : CLEAR_LINE); | |
| 211 | 211 | } |
| 212 | 212 | /* Timer overflow callback from timer.c */ |
| 213 | 213 | static TIMER_CALLBACK( timer_callback_3526_0 ) |
| r2724 | r2725 | |
| 374 | 374 | static void IRQHandler_8950(void *param,int irq) |
| 375 | 375 | { |
| 376 | 376 | struct y8950_info *info = param; |
| 377 | if (info->intf->handler) (info->intf->handler)(irq ? ASSERT_LINE : CLEAR_LINE); | |
| 377 | if (info->intf->handler) (info->intf->handler)(Machine, irq ? ASSERT_LINE : CLEAR_LINE); | |
| 378 | 378 | } |
| 379 | 379 | static TIMER_CALLBACK( timer_callback_8950_0 ) |
| 380 | 380 | { |
| r2724 | r2725 | |
|---|---|---|
| 4 | 4 | |
| 5 | 5 | struct YM3812interface |
| 6 | 6 | { |
| 7 | void (*handler)(int linestate); | |
| 7 | void (*handler)(running_machine *machine, int linestate); | |
| 8 | 8 | }; |
| 9 | 9 | |
| 10 | 10 | #define YM3526interface YM3812interface |
| 11 | 11 | |
| 12 | 12 | struct Y8950interface |
| 13 | 13 | { |
| 14 | void (*handler)(int linestate); | |
| 14 | void (*handler)(running_machine *machine, int linestate); | |
| 15 | 15 | |
| 16 | 16 | int rom_region; /* delta-T ADPCM ROM/RAM region */ |
| 17 | 17 |
| r2724 | r2725 | |
|---|---|---|
| 89 | 89 | UINT8 irq_enable; /* current IRQ enable */ |
| 90 | 90 | UINT8 keyon_enable; /* key on enable */ |
| 91 | 91 | double master_clock; /* master clock frequency */ |
| 92 | void (*irq_callback)(int); /* IRQ callback */ | |
| 92 | void (*irq_callback)(running_machine *, int); /* IRQ callback */ | |
| 93 | 93 | struct YMZ280BVoice voice[8]; /* the 8 voices */ |
| 94 | 94 | UINT32 rom_readback_addr; /* where the CPU can read the ROM */ |
| 95 | 95 | read8_machine_func ext_ram_read; /* external RAM read handler */ |
| r2724 | r2725 | |
| 145 | 145 | { |
| 146 | 146 | chip->irq_state = 1; |
| 147 | 147 | if (chip->irq_callback) |
| 148 | (*chip->irq_callback)(1); | |
| 148 | (*chip->irq_callback)(Machine, 1); | |
| 149 | 149 | else logerror("YMZ280B: IRQ generated, but no callback specified!"); |
| 150 | 150 | } |
| 151 | 151 | else if (!irq_bits && chip->irq_state) |
| 152 | 152 | { |
| 153 | 153 | chip->irq_state = 0; |
| 154 | 154 | if (chip->irq_callback) |
| 155 | (*chip->irq_callback)(0); | |
| 155 | (*chip->irq_callback)(Machine, 0); | |
| 156 | 156 | else logerror("YMZ280B: IRQ generated, but no callback specified!"); |
| 157 | 157 | } |
| 158 | 158 | } |
| r2724 | r2725 | |
|---|---|---|
| 11 | 11 | struct YMZ280Binterface |
| 12 | 12 | { |
| 13 | 13 | int region; /* memory region where the sample ROM lives */ |
| 14 | void (*irq_callback)(int state); /* irq callback */ | |
| 14 | void (*irq_callback)(running_machine *machine, int state); /* irq callback */ | |
| 15 | 15 | read8_machine_func ext_read; /* external RAM read */ |
| 16 | 16 | write8_machine_func ext_write; /* external RAM write */ |
| 17 | 17 | }; |
| r2724 | r2725 | |
|---|---|---|
| 26 | 26 | * |
| 27 | 27 | * Instead, { 8, 8, 8, 4, 4, 4, 2, 1 } |
| 28 | 28 | * will calculate those coefficients and this has been used below. |
| 29 | * LN: | |
| 30 | * The real chip uses shifters and not true division to achieve those factors, | |
| 31 | * so they have been replaced by the shifting coefficients: | |
| 32 | * { 3, 3, 3, 2, 2, 2, 1, 0 } | |
| 29 | 33 | */ |
| 30 | 34 | |
| 31 | 35 | static const struct tms5100_coeffs pat4209836_coeff = |
| r2724 | r2725 | |
| 85 | 89 | 1, 0, 0, 0, 0, 0, 0, 0, |
| 86 | 90 | 0, 0, 0 }, |
| 87 | 91 | /* interpolation coefficients */ |
| 88 | { | |
| 92 | { 3, 3, 3, 2, 2, | |
| 89 | 93 | }; |
| 90 | 94 | |
| 91 | 95 | /* |
| r2724 | r2725 | |
| 161 | 165 | 0,0,0 |
| 162 | 166 | }, |
| 163 | 167 | /* interpolation coefficients */ |
| 164 | { | |
| 168 | { 3, 3, 3, 2, 2, | |
| 165 | 169 | }; |
| 166 | 170 | |
| 167 | 171 | |
| r2724 | r2725 | |
| 228 | 232 | 1, 0, 0, 0, 0, 0, 0, 0, |
| 229 | 233 | 0, 0, 0 }, |
| 230 | 234 | /* interpolation coefficients */ |
| 231 | { | |
| 235 | { 3, 3, 3, 2, 2, | |
| 232 | 236 | }; |
| 233 | 237 | |
| 234 | 238 |
| r2724 | r2725 | |
|---|---|---|
| 175 | 175 | unsigned char *AICARAM; |
| 176 | 176 | UINT32 AICARAM_LENGTH, RAM_MASK, RAM_MASK16; |
| 177 | 177 | char Master; |
| 178 | void (*IntARMCB)(int irq); | |
| 178 | void (*IntARMCB)(running_machine *machine, int irq); | |
| 179 | 179 | sound_stream * stream; |
| 180 | 180 | |
| 181 | 181 | INT32 *buffertmpl, *buffertmpr; |
| r2724 | r2725 | |
| 233 | 233 | { |
| 234 | 234 | #if 0 |
| 235 | 235 | UINT32 reset = AICA->udata.data[0xa4/2]; |
| 236 | running_machine *machine = Machine; | |
| 237 | ||
| 236 | 238 | if (reset & 0x40) |
| 237 | AICA->IntARMCB(-AICA->IrqTimA); | |
| 239 | AICA->IntARMCB(machine, -AICA->IrqTimA); | |
| 238 | 240 | if (reset & 0x180) |
| 239 | AICA->IntARMCB(-AICA->IrqTimBC); | |
| 241 | AICA->IntARMCB(machine, -AICA->IrqTimBC); | |
| 240 | 242 | #endif |
| 241 | 243 | } |
| 242 | 244 | |
| r2724 | r2725 | |
| 244 | 246 | { |
| 245 | 247 | UINT32 pend=AICA->udata.data[0xa0/2]; |
| 246 | 248 | UINT32 en=AICA->udata.data[0x9c/2]; |
| 249 | running_machine *machine = Machine; | |
| 250 | ||
| 247 | 251 | if(AICA->MidiW!=AICA->MidiR) |
| 248 | 252 | { |
| 249 | 253 | AICA->IRQL = AICA->IrqMidi; |
| 250 | AICA->IntARMCB(1); | |
| 254 | AICA->IntARMCB(machine, 1); | |
| 251 | 255 | return; |
| 252 | 256 | } |
| 253 | 257 | if(!pend) |
| r2724 | r2725 | |
| 256 | 260 | if(en&0x40) |
| 257 | 261 | { |
| 258 | 262 | AICA->IRQL = AICA->IrqTimA; |
| 259 | AICA->IntARMCB(1); | |
| 263 | AICA->IntARMCB(machine, 1); | |
| 260 | 264 | return; |
| 261 | 265 | } |
| 262 | 266 | if(pend&0x80) |
| 263 | 267 | if(en&0x80) |
| 264 | 268 | { |
| 265 | 269 | AICA->IRQL = AICA->IrqTimBC; |
| 266 | AICA->IntARMCB(1); | |
| 270 | AICA->IntARMCB(machine, 1); | |
| 267 | 271 | return; |
| 268 | 272 | } |
| 269 | 273 | if(pend&0x100) |
| 270 | 274 | if(en&0x100) |
| 271 | 275 | { |
| 272 | 276 | AICA->IRQL = AICA->IrqTimBC; |
| 273 | AICA->IntARMCB(1); | |
| 277 | AICA->IntARMCB(machine, 1); | |
| 274 | 278 | return; |
| 275 | 279 | } |
| 276 | 280 | } |
| r2724 | r2725 | |
| 856 | 860 | unsigned short v=AICA->udata.data[0x8/2]; |
| 857 | 861 | v&=0xff00; |
| 858 | 862 | v|=AICA->MidiStack[AICA->MidiR]; |
| 859 | AICA->IntARMCB(0); // cancel the IRQ | |
| 863 | AICA->IntARMCB(Machine, 0); // cancel the IRQ | |
| 860 | 864 | if(AICA->MidiR!=AICA->MidiW) |
| 861 | 865 | { |
| 862 | 866 | ++AICA->MidiR; |
| r2724 | r2725 | |
| 922 | 926 | |
| 923 | 927 | if (val) |
| 924 | 928 | { |
| 925 | AICA->IntARMCB(0); | |
| 929 | AICA->IntARMCB(Machine, 0); | |
| 926 | 930 | } |
| 927 | 931 | } |
| 928 | 932 | } |
| r2724 | r2725 | |
|---|---|---|
| 12 | 12 | { |
| 13 | 13 | int region; /* region of 2M/8M RAM */ |
| 14 | 14 | int roffset; /* offset in the region */ |
| 15 | void (*irq_callback)(int state); /* irq callback */ | |
| 15 | void (*irq_callback)(running_machine *machine, int state); /* irq callback */ | |
| 16 | 16 | }; |
| 17 | 17 | |
| 18 | 18 | void AICA_set_ram_base(int which, void *base, int size); |
| r2724 | r2725 | |
|---|---|---|
| 110 | 110 | const UINT8 *rom; |
| 111 | 111 | read8_machine_func ext_mem_read; |
| 112 | 112 | write8_machine_func ext_mem_write; |
| 113 | void (*irq_callback)(int); | |
| 113 | void (*irq_callback)(running_machine *, int); | |
| 114 | 114 | |
| 115 | 115 | int index; |
| 116 | 116 | UINT32 clock; |
| r2724 | r2725 | |
| 1356 | 1356 | if (chip->enable & 4) |
| 1357 | 1357 | { |
| 1358 | 1358 | chip->irqstate |= 1; |
| 1359 | if (chip->irq_callback) chip->irq_callback(1); | |
| 1359 | if (chip->irq_callback) chip->irq_callback(machine, 1); | |
| 1360 | 1360 | } |
| 1361 | 1361 | } |
| 1362 | 1362 | |
| r2724 | r2725 | |
| 1369 | 1369 | if (chip->enable & 8) |
| 1370 | 1370 | { |
| 1371 | 1371 | chip->irqstate |= 2; |
| 1372 | if (chip->irq_callback) chip->irq_callback(1); | |
| 1372 | if (chip->irq_callback) chip->irq_callback(machine, 1); | |
| 1373 | 1373 | } |
| 1374 | 1374 | } |
| 1375 | 1375 | |
| r2724 | r2725 | |
| 1396 | 1396 | int slotnum; |
| 1397 | 1397 | YMF271Group *group; |
| 1398 | 1398 | attotime period; |
| 1399 | running_machine *machine = Machine; | |
| 1399 | 1400 | |
| 1400 | 1401 | slotnum = fm_tab[chip->timerreg & 0xf]; |
| 1401 | 1402 | group = &chip->groups[slotnum]; |
| r2724 | r2725 | |
| 1453 | 1454 | chip->irqstate &= ~1; |
| 1454 | 1455 | chip->status &= ~1; |
| 1455 | 1456 | |
| 1456 | if (chip->irq_callback) chip->irq_callback(0); | |
| 1457 | if (chip->irq_callback) chip->irq_callback(machine, 0); | |
| 1457 | 1458 | |
| 1458 | 1459 | //period = (double)(256.0 - chip->timerAVal ) * ( 384.0 * 4.0 / (double)CLOCK); |
| 1459 | 1460 | period = attotime_mul(ATTOTIME_IN_HZ(chip->clock), 384 * (1024 - chip->timerAVal)); |
| r2724 | r2725 | |
| 1465 | 1466 | chip->irqstate &= ~2; |
| 1466 | 1467 | chip->status &= ~2; |
| 1467 | 1468 | |
| 1468 | if (chip->irq_callback) chip->irq_callback(0); | |
| 1469 | if (chip->irq_callback) chip->irq_callback(machine, 0); | |
| 1469 | 1470 | |
| 1470 | 1471 | period = attotime_mul(ATTOTIME_IN_HZ(chip->clock), 384 * 16 * (256 - chip->timerBVal)); |
| 1471 | 1472 | |
| r2724 | r2725 | |
| 1726 | 1727 | state_save_register_item("ymf271", chip->index, chip->ext_read); |
| 1727 | 1728 | } |
| 1728 | 1729 | |
| 1729 | static void ymf271_init(YMF271Chip *chip, UINT8 *rom, void (*cb)(int), read8_machine_func ext_read, write8_machine_func ext_write) | |
| 1730 | static void ymf271_init(YMF271Chip *chip, UINT8 *rom, void (*cb)(running_machine *,int), read8_machine_func ext_read, write8_machine_func ext_write) | |
| 1730 | 1731 | { |
| 1731 | 1732 | chip->timA = timer_alloc(ymf271_timer_a_tick, chip); |
| 1732 | 1733 | chip->timB = timer_alloc(ymf271_timer_b_tick, chip); |
| r2724 | r2725 | |
|---|---|---|
| 185 | 185 | read8_machine_func allpot_r; |
| 186 | 186 | read8_machine_func serin_r; |
| 187 | 187 | write8_machine_func serout_w; |
| 188 | void (*interrupt_cb)(int mask); | |
| 188 | void (*interrupt_cb)(running_machine *machine, int mask); | |
| 189 | 189 | UINT8 AUDF[4]; /* AUDFx (D200, D202, D204, D206) */ |
| 190 | 190 | UINT8 AUDC[4]; /* AUDCx (D201, D203, D205, D207) */ |
| 191 | 191 | UINT8 POTx[8]; /* POTx (R/D200-D207) */ |
| r2724 | r2725 | |
| 698 | 698 | p->IRQST |= timers; |
| 699 | 699 | /* call back an application supplied function to handle the interrupt */ |
| 700 | 700 | if( p->interrupt_cb ) |
| 701 | (*p->interrupt_cb)(timers); | |
| 701 | (*p->interrupt_cb)(machine, timers); | |
| 702 | 702 | } |
| 703 | 703 | } |
| 704 | 704 | |
| r2724 | r2725 | |
| 761 | 761 | p->IRQST |= IRQ_SERIN; |
| 762 | 762 | /* call back an application supplied function to handle the interrupt */ |
| 763 | 763 | if( p->interrupt_cb ) |
| 764 | (*p->interrupt_cb)(IRQ_SERIN); | |
| 764 | (*p->interrupt_cb)(machine, IRQ_SERIN); | |
| 765 | 765 | } |
| 766 | 766 | } |
| 767 | 767 | |
| r2724 | r2725 | |
| 772 | 772 | { |
| 773 | 773 | p->IRQST |= IRQ_SEROR; |
| 774 | 774 | if( p->interrupt_cb ) |
| 775 | (*p->interrupt_cb)(IRQ_SEROR); | |
| 775 | (*p->interrupt_cb)(machine, IRQ_SEROR); | |
| 776 | 776 | } |
| 777 | 777 | } |
| 778 | 778 | |
| r2724 | r2725 | |
| 783 | 783 | { |
| 784 | 784 | p->IRQST |= IRQ_SEROC; |
| 785 | 785 | if( p->interrupt_cb ) |
| 786 | (*p->interrupt_cb)(IRQ_SEROC); | |
| 786 | (*p->interrupt_cb)(machine, IRQ_SEROC); | |
| 787 | 787 | } |
| 788 | 788 | } |
| 789 | 789 | |
| r2724 | r2725 | |
| 1436 | 1436 | /* set break IRQ status and call back the interrupt handler */ |
| 1437 | 1437 | p->IRQST |= IRQ_BREAK; |
| 1438 | 1438 | if( p->interrupt_cb ) |
| 1439 | (*p->interrupt_cb)(IRQ_BREAK); | |
| 1439 | (*p->interrupt_cb)(Machine, IRQ_BREAK); | |
| 1440 | 1440 | } |
| 1441 | 1441 | } |
| 1442 | 1442 | |
| r2724 | r2725 | |
| 1480 | 1480 | p->SKSTAT |= SK_KBERR; |
| 1481 | 1481 | p->IRQST |= IRQ_KEYBD; |
| 1482 | 1482 | if( p->interrupt_cb ) |
| 1483 | (*p->interrupt_cb)(IRQ_KEYBD); | |
| 1483 | (*p->interrupt_cb)(Machine, IRQ_KEYBD); | |
| 1484 | 1484 | } |
| 1485 | 1485 | } |
| 1486 | 1486 | else |
| r2724 | r2725 | |
|---|---|---|
| 6 | 6 | int region; /* memory region of sample ROMs */ |
| 7 | 7 | read8_machine_func ext_read; /* external memory read */ |
| 8 | 8 | write8_machine_func ext_write; /* external memory write */ |
| 9 | void (*irq_callback)(int state); /* irq callback */ | |
| 9 | void (*irq_callback)(running_machine *machine, int state); /* irq callback */ | |
| 10 | 10 | }; |
| 11 | 11 | |
| 12 | 12 | READ8_HANDLER( YMF271_0_r ); |
| r2724 | r2725 | |
|---|---|---|
| 71 | 71 | read8_machine_func allpot_r; |
| 72 | 72 | read8_machine_func serin_r; |
| 73 | 73 | write8_machine_func serout_w; |
| 74 | void (*interrupt_cb)(int mask); | |
| 74 | void (*interrupt_cb)(running_machine *machine, int mask); | |
| 75 | 75 | }; |
| 76 | 76 | |
| 77 | 77 |
| r2724 | r2725 | |
|---|---|---|
| 165 | 165 | |
| 166 | 166 | UINT32 noise_tab[32]; /* 17bit Noise Generator periods */ |
| 167 | 167 | |
| 168 | void (*irqhandler)(int irq); /* IRQ function handler */ | |
| 168 | void (*irqhandler)(running_machine *machine, int irq); /* IRQ function handler */ | |
| 169 | 169 | write8_machine_func porthandler; /* port write function handler */ |
| 170 | 170 | |
| 171 | 171 | unsigned int clock; /* chip clock in Hz (passed from 2151intf.c) */ |
| r2724 | r2725 | |
| 791 | 791 | |
| 792 | 792 | chip->irqlinestate |= 1; |
| 793 | 793 | |
| 794 | if (oldstate == 0 && chip->irqhandler) (*chip->irqhandler)(1); | |
| 794 | if (oldstate == 0 && chip->irqhandler) (*chip->irqhandler)(machine, 1); | |
| 795 | 795 | } |
| 796 | 796 | |
| 797 | 797 | static TIMER_CALLBACK( irqBon_callback ) |
| r2724 | r2725 | |
| 801 | 801 | |
| 802 | 802 | chip->irqlinestate |= 2; |
| 803 | 803 | |
| 804 | if (oldstate == 0 && chip->irqhandler) (*chip->irqhandler)(1); | |
| 804 | if (oldstate == 0 && chip->irqhandler) (*chip->irqhandler)(machine, 1); | |
| 805 | 805 | } |
| 806 | 806 | |
| 807 | 807 | static TIMER_CALLBACK( irqAoff_callback ) |
| r2724 | r2725 | |
| 811 | 811 | |
| 812 | 812 | chip->irqlinestate &= ~1; |
| 813 | 813 | |
| 814 | if (oldstate == 1 && chip->irqhandler) (*chip->irqhandler)(0); | |
| 814 | if (oldstate == 1 && chip->irqhandler) (*chip->irqhandler)(machine, 0); | |
| 815 | 815 | } |
| 816 | 816 | |
| 817 | 817 | static TIMER_CALLBACK( irqBoff_callback ) |
| r2724 | r2725 | |
| 821 | 821 | |
| 822 | 822 | chip->irqlinestate &= ~2; |
| 823 | 823 | |
| 824 | if (oldstate == 2 && chip->irqhandler) (*chip->irqhandler)(0); | |
| 824 | if (oldstate == 2 && chip->irqhandler) (*chip->irqhandler)(machine, 0); | |
| 825 | 825 | } |
| 826 | 826 | |
| 827 | 827 | static TIMER_CALLBACK( timer_callback_a ) |
| r2724 | r2725 | |
| 1112 | 1112 | #else |
| 1113 | 1113 | int oldstate = chip->status & 3; |
| 1114 | 1114 | chip->status &= ~1; |
| 1115 | if ((oldstate==1) && (chip->irqhandler)) (*chip->irqhandler)(0); | |
| 1115 | if ((oldstate==1) && (chip->irqhandler)) (*chip->irqhandler)(machine, 0); | |
| 1116 | 1116 | #endif |
| 1117 | 1117 | } |
| 1118 | 1118 | |
| r2724 | r2725 | |
| 1124 | 1124 | #else |
| 1125 | 1125 | int oldstate = chip->status & 3; |
| 1126 | 1126 | chip->status &= ~2; |
| 1127 | if ((oldstate==2) && (chip->irqhandler)) (*chip->irqhandler)(0); | |
| 1127 | if ((oldstate==2) && (chip->irqhandler)) (*chip->irqhandler)(machine, 0); | |
| 1128 | 1128 | #endif |
| 1129 | 1129 | } |
| 1130 | 1130 | |
| r2724 | r2725 | |
| 2403 | 2403 | { |
| 2404 | 2404 | int oldstate = PSG->status & 3; |
| 2405 | 2405 | PSG->status |= 2; |
| 2406 | if ((!oldstate) && (PSG->irqhandler)) (*PSG->irqhandler)(1); | |
| 2406 | if ((!oldstate) && (PSG->irqhandler)) (*PSG->irqhandler)(machine, 1); | |
| 2407 | 2407 | } |
| 2408 | 2408 | } |
| 2409 | 2409 | } |
| r2724 | r2725 | |
| 2481 | 2481 | { |
| 2482 | 2482 | int oldstate = PSG->status & 3; |
| 2483 | 2483 | PSG->status |= 1; |
| 2484 | if ((!oldstate) && (PSG->irqhandler)) (*PSG->irqhandler)(1); | |
| 2484 | if ((!oldstate) && (PSG->irqhandler)) (*PSG->irqhandler)(machine, 1); | |
| 2485 | 2485 | } |
| 2486 | 2486 | if (PSG->irq_enable & 0x80) |
| 2487 | 2487 | PSG->csm_req = 2; /* request KEY ON / KEY OFF sequence */ |
| r2724 | r2725 | |
| 2492 | 2492 | } |
| 2493 | 2493 | } |
| 2494 | 2494 | |
| 2495 | void YM2151SetIrqHandler(void *chip, void(*handler)(int irq)) | |
| 2495 | void YM2151SetIrqHandler(void *chip, void(*handler)(running_machine *machine, int irq)) | |
| 2496 | 2496 | { |
| 2497 | 2497 | YM2151 *PSG = chip; |
| 2498 | 2498 | PSG->irqhandler = handler; |
| r2724 | r2725 | |
|---|---|---|
| 76 | 76 | int YM2151ReadStatus(void *chip); |
| 77 | 77 | |
| 78 | 78 | /* set interrupt handler on YM2151 chip number 'n'*/ |
| 79 | void YM2151SetIrqHandler(void *chip, void (*handler)(int irq)); | |
| 79 | void YM2151SetIrqHandler(void *chip, void (*handler)(running_machine *machine, int irq)); | |
| 80 | 80 | |
| 81 | 81 | /* set port write handler on YM2151 chip number 'n'*/ |
| 82 | 82 | void YM2151SetPortWriteHandler(void *chip, write8_machine_func handler); |
| r2724 | r2725 | |
|---|---|---|
| 194 | 194 | unsigned char *SCSPRAM; |
| 195 | 195 | UINT32 SCSPRAM_LENGTH; |
| 196 | 196 | char Master; |
| 197 | void (*Int68kCB)(int irq); | |
| 197 | void (*Int68kCB)(running_machine *machine, int irq); | |
| 198 | 198 | sound_stream * stream; |
| 199 | 199 | |
| 200 | 200 | INT32 *buffertmpl,*buffertmpr; |
| r2724 | r2725 | |
| 226 | 226 | struct _SCSPDSP DSP; |
| 227 | 227 | }; |
| 228 | 228 | |
| 229 | static void dma_scsp(struct _SCSP *SCSP); /*SCSP DMA transfer function*/ | |
| 229 | static void dma_scsp(running_machine *machine, struct _SCSP *SCSP); /*SCSP DMA transfer function*/ | |
| 230 | 230 | #define scsp_dgate scsp_regs[0x16/2] & 0x4000 |
| 231 | 231 | #define scsp_ddir scsp_regs[0x16/2] & 0x2000 |
| 232 | 232 | #define scsp_dexe scsp_regs[0x16/2] & 0x1000 |
| r2724 | r2725 | |
| 259 | 259 | { |
| 260 | 260 | UINT32 pend=SCSP->udata.data[0x20/2]; |
| 261 | 261 | UINT32 en=SCSP->udata.data[0x1e/2]; |
| 262 | running_machine *machine = Machine; | |
| 263 | ||
| 262 | 264 | if(SCSP->MidiW!=SCSP->MidiR) |
| 263 | 265 | { |
| 264 | 266 | SCSP->udata.data[0x20/2] |= 8; |
| r2724 | r2725 | |
| 269 | 271 | if(pend&0x40) |
| 270 | 272 | if(en&0x40) |
| 271 | 273 | { |
| 272 | SCSP->Int68kCB(SCSP->IrqTimA); | |
| 274 | SCSP->Int68kCB(machine, SCSP->IrqTimA); | |
| 273 | 275 | return; |
| 274 | 276 | } |
| 275 | 277 | if(pend&0x80) |
| 276 | 278 | if(en&0x80) |
| 277 | 279 | { |
| 278 | SCSP->Int68kCB(SCSP->IrqTimBC); | |
| 280 | SCSP->Int68kCB(machine, SCSP->IrqTimBC); | |
| 279 | 281 | return; |
| 280 | 282 | } |
| 281 | 283 | if(pend&0x100) |
| 282 | 284 | if(en&0x100) |
| 283 | 285 | { |
| 284 | SCSP->Int68kCB(SCSP->IrqTimBC); | |
| 286 | SCSP->Int68kCB(machine, SCSP->IrqTimBC); | |
| 285 | 287 | return; |
| 286 | 288 | } |
| 287 | 289 | if(pend&8) |
| 288 | 290 | if (en&8) |
| 289 | 291 | { |
| 290 | SCSP->Int68kCB(SCSP->IrqMidi); | |
| 292 | SCSP->Int68kCB(machine, SCSP->IrqMidi); | |
| 291 | 293 | SCSP->udata.data[0x20/2] &= ~8; |
| 292 | 294 | return; |
| 293 | 295 | } |
| 294 | 296 | |
| 295 | SCSP->Int68kCB(0); | |
| 297 | SCSP->Int68kCB(machine, 0); | |
| 296 | 298 | } |
| 297 | 299 | |
| 298 | 300 | static void ResetInterrupts(struct _SCSP *SCSP) |
| 299 | 301 | { |
| 300 | 302 | UINT32 reset = SCSP->udata.data[0x22/2]; |
| 303 | running_machine *machine = Machine; | |
| 301 | 304 | |
| 302 | 305 | if (reset & 0x40) |
| 303 | 306 | { |
| 304 | SCSP->Int68kCB(-SCSP->IrqTimA); | |
| 307 | SCSP->Int68kCB(machine, -SCSP->IrqTimA); | |
| 305 | 308 | } |
| 306 | 309 | if (reset & 0x180) |
| 307 | 310 | { |
| 308 | SCSP->Int68kCB(-SCSP->IrqTimBC); | |
| 311 | SCSP->Int68kCB(machine, -SCSP->IrqTimBC); | |
| 309 | 312 | } |
| 310 | 313 | if (reset & 0x8) |
| 311 | 314 | { |
| 312 | SCSP->Int68kCB(-SCSP->IrqMidi); | |
| 315 | SCSP->Int68kCB(machine, -SCSP->IrqMidi); | |
| 313 | 316 | } |
| 314 | 317 | |
| 315 | 318 | CheckPendingIRQ(SCSP); |
| r2724 | r2725 | |
| 833 | 836 | unsigned short v=SCSP->udata.data[0x5/2]; |
| 834 | 837 | v&=0xff00; |
| 835 | 838 | v|=SCSP->MidiStack[SCSP->MidiR]; |
| 836 | SCSP[0].Int68kCB(-SCSP->IrqMidi); // cancel the IRQ | |
| 839 | SCSP[0].Int68kCB(Machine, -SCSP->IrqMidi); // cancel the IRQ | |
| 837 | 840 | if(SCSP->MidiR!=SCSP->MidiW) |
| 838 | 841 | { |
| 839 | 842 | ++SCSP->MidiR; |
| r2724 | r2725 | |
| 1147 | 1150 | } |
| 1148 | 1151 | } |
| 1149 | 1152 | |
| 1150 | static void dma_scsp(struct _SCSP *SCSP) | |
| 1153 | static void dma_scsp(running_machine *machine, struct _SCSP *SCSP) | |
| 1151 | 1154 | { |
| 1152 | 1155 | static UINT16 tmp_dma[3], *scsp_regs; |
| 1153 | 1156 | |
| r2724 | r2725 | |
| 1195 | 1198 | |
| 1196 | 1199 | /*Job done,request a dma end irq*/ |
| 1197 | 1200 | if(scsp_regs[0x1e/2] & 0x10) |
| 1198 | cpunum_set_input_line( | |
| 1201 | cpunum_set_input_line(machine, 2,dma_transfer_end,HOLD_LINE); | |
| 1199 | 1202 | } |
| 1200 | 1203 | |
| 1201 | 1204 | #ifdef UNUSED_FUNCTION |
| r2724 | r2725 | |
| 1302 | 1305 | SCSP->scsp_dtlg = scsp_regs[0x416/2] & 0x0ffe; |
| 1303 | 1306 | if(scsp_dexe) |
| 1304 | 1307 | { |
| 1305 | dma_scsp(SCSP); | |
| 1308 | dma_scsp(machine, SCSP); | |
| 1306 | 1309 | scsp_regs[0x416/2]^=0x1000;//disable starting bit |
| 1307 | 1310 | } |
| 1308 | 1311 | break; |
| r2724 | r2725 | |
|---|---|---|
| 66 | 66 | static void IRQHandler(void *param,int irq) |
| 67 | 67 | { |
| 68 | 68 | struct ym2610_info *info = param; |
| 69 | if(info->intf->handler) info->intf->handler(irq); | |
| 69 | if(info->intf->handler) info->intf->handler(Machine, irq); | |
| 70 | 70 | } |
| 71 | 71 | |
| 72 | 72 | /* Timer overflow callback from timer.c */ |
| r2724 | r2725 | |
|---|---|---|
| 10 | 10 | { |
| 11 | 11 | int region; /* region of 512k RAM */ |
| 12 | 12 | int roffset; /* offset in the region */ |
| 13 | void (*irq_callback)(int state); /* irq callback */ | |
| 13 | void (*irq_callback)(running_machine *machine, int state); /* irq callback */ | |
| 14 | 14 | }; |
| 15 | 15 | |
| 16 | 16 | void SCSP_set_ram_base(int which, void *base); |
| r2724 | r2725 | |
|---|---|---|
| 5 | 5 | |
| 6 | 6 | struct YM2610interface |
| 7 | 7 | { |
| 8 | void ( *handler )( int irq ); /* IRQ handler for the YM2610 */ | |
| 8 | void ( *handler )( running_machine *machine, int irq ); /* IRQ handler for the YM2610 */ | |
| 9 | 9 | int pcmromb; /* Delta-T rom region */ |
| 10 | 10 | int pcmroma; /* ADPCM rom region */ |
| 11 | 11 | }; |
| r2724 | r2725 | |
|---|---|---|
| 7 | 7 | |
| 8 | 8 | #include <math.h> |
| 9 | 9 | #include "sndintrf.h" |
| 10 | #include "deprecat.h" | |
| 10 | 11 | #include "streams.h" |
| 11 | 12 | #include "cpuintrf.h" |
| 12 | 13 | #include "ics2115.h" |
| r2724 | r2725 | |
| 91 | 92 | if(irq != chip->irq_on) { |
| 92 | 93 | chip->irq_on = irq; |
| 93 | 94 | if(chip->intf->irq_cb) |
| 94 | chip->intf->irq_cb(irq ? ASSERT_LINE : CLEAR_LINE); | |
| 95 | chip->intf->irq_cb(Machine, irq ? ASSERT_LINE : CLEAR_LINE); | |
| 95 | 96 | } |
| 96 | 97 | } |
| 97 | 98 |
| r2724 | r2725 | |
|---|---|---|
| 3 | 3 | |
| 4 | 4 | struct ics2115_interface { |
| 5 | 5 | int region; |
| 6 | void (*irq_cb)(int); | |
| 6 | void (*irq_cb)(running_machine *, int); | |
| 7 | 7 | }; |
| 8 | 8 | |
| 9 | 9 | READ8_HANDLER( ics2115_r ); |
| r2724 | r2725 | |
|---|---|---|
| 66 | 66 | static void IRQHandler(void *param,int irq) |
| 67 | 67 | { |
| 68 | 68 | struct ym2608_info *info = param; |
| 69 | if(info->intf->handler) info->intf->handler(irq); | |
| 69 | if(info->intf->handler) info->intf->handler(Machine, irq); | |
| 70 | 70 | } |
| 71 | 71 | |
| 72 | 72 | /* Timer overflow callback from timer.c */ |
| r2724 | r2725 | |
|---|---|---|
| 7 | 7 | struct YM2608interface |
| 8 | 8 | { |
| 9 | 9 | const struct AY8910interface ay8910_intf; |
| 10 | void ( *handler )( int irq ); /* IRQ handler for the YM2608 */ | |
| 10 | void ( *handler )( running_machine *machine, int irq ); /* IRQ handler for the YM2608 */ | |
| 11 | 11 | int pcmrom; /* Delta-T memory region ram/rom */ |
| 12 | 12 | }; |
| 13 | 13 |
| r2724 | r2725 | |
|---|---|---|
| 9 | 9 | #include <math.h> |
| 10 | 10 | |
| 11 | 11 | #include "sndintrf.h" |
| 12 | #include "deprecat.h" | |
| 12 | 13 | #include "streams.h" |
| 13 | 14 | #include "cpuintrf.h" |
| 14 | 15 | #include "es5506.h" |
| r2724 | r2725 | |
| 104 | 105 | UINT32 write_latch; /* currently accumulated data for write */ |
| 105 | 106 | UINT32 read_latch; /* currently accumulated data for read */ |
| 106 | 107 | UINT32 master_clock; /* master clock frequency */ |
| 107 | void (*irq_callback)(int); /* IRQ callback */ | |
| 108 | void (*irq_callback)(running_machine *, int); /* IRQ callback */ | |
| 108 | 109 | UINT16 (*port_read)(void); /* input port read */ |
| 109 | 110 | |
| 110 | 111 | UINT8 current_page; /* current register page */ |
| r2724 | r2725 | |
| 149 | 150 | { |
| 150 | 151 | /* ES5505/6 irq line has been set high - inform the host */ |
| 151 | 152 | if (chip->irq_callback) |
| 152 | (*chip->irq_callback)(1); /* IRQB set high */ | |
| 153 | (*chip->irq_callback)(Machine, 1); /* IRQB set high */ | |
| 153 | 154 | } |
| 154 | 155 | |
| 155 | 156 | static void update_internal_irq_state(struct ES5506Chip *chip) |
| r2724 | r2725 | |
| 166 | 167 | chip->irqv=0x80; |
| 167 | 168 | |
| 168 | 169 | if (chip->irq_callback) |
| 169 | (*chip->irq_callback)(0); /* IRQB set low */ | |
| 170 | (*chip->irq_callback)(Machine, 0); /* IRQB set low */ | |
| 170 | 171 | } |
| 171 | 172 | |
| 172 | 173 | /********************************************************************************************** |
| r2724 | r2725 | |
|---|---|---|
| 12 | 12 | { |
| 13 | 13 | int region0; /* memory region where the sample ROM lives */ |
| 14 | 14 | int region1; /* memory region where the sample ROM lives */ |
| 15 | void (*irq_callback)(int state); /* irq callback */ | |
| 15 | void (*irq_callback)(running_machine *machine, int state); /* irq callback */ | |
| 16 | 16 | UINT16 (*read_port)(void); /* input port read */ |
| 17 | 17 | }; |
| 18 | 18 | |
| r2724 | r2725 | |
| 33 | 33 | int region1; /* memory region where the sample ROM lives */ |
| 34 | 34 | int region2; /* memory region where the sample ROM lives */ |
| 35 | 35 | int region3; /* memory region where the sample ROM lives */ |
| 36 | void (*irq_callback)(int state); /* irq callback */ | |
| 36 | void (*irq_callback)(running_machine *machine, int state); /* irq callback */ | |
| 37 | 37 | UINT16 (*read_port)(void); /* input port read */ |
| 38 | 38 | }; |
| 39 | 39 |
| r2724 | r2725 | |
|---|---|---|
| 118 | 118 | int irq_line; |
| 119 | 119 | |
| 120 | 120 | UINT8 port_A, port_B, port_C; |
| 121 | void (*irq_callback)(int); | |
| 121 | void (*irq_callback)(running_machine *, int); | |
| 122 | 122 | |
| 123 | 123 | const UINT8 *rom; |
| 124 | 124 | int clock; |
| r2724 | r2725 | |
| 336 | 336 | } |
| 337 | 337 | } |
| 338 | 338 | |
| 339 | static void ymf278b_irq_check(YMF278BChip *chip) | |
| 339 | static void ymf278b_irq_check(running_machine *machine, YMF278BChip *chip) | |
| 340 | 340 | { |
| 341 | 341 | int prev_line = chip->irq_line; |
| 342 | 342 | chip->irq_line = chip->current_irq ? ASSERT_LINE : CLEAR_LINE; |
| 343 | 343 | if(chip->irq_line != prev_line && chip->irq_callback) |
| 344 | chip->irq_callback(chip->irq_line); | |
| 344 | chip->irq_callback(machine, chip->irq_line); | |
| 345 | 345 | } |
| 346 | 346 | |
| 347 | 347 | static TIMER_CALLBACK( ymf278b_timer_a_tick ) |
| r2724 | r2725 | |
| 350 | 350 | if(!(chip->enable & 0x40)) |
| 351 | 351 | { |
| 352 | 352 | chip->current_irq |= 0x40; |
| 353 | ymf278b_irq_check(chip); | |
| 353 | ymf278b_irq_check(machine, chip); | |
| 354 | 354 | } |
| 355 | 355 | } |
| 356 | 356 | |
| r2724 | r2725 | |
| 360 | 360 | if(!(chip->enable & 0x20)) |
| 361 | 361 | { |
| 362 | 362 | chip->current_irq |= 0x20; |
| 363 | ymf278b_irq_check(chip); | |
| 363 | ymf278b_irq_check(machine, chip); | |
| 364 | 364 | } |
| 365 | 365 | } |
| 366 | 366 | |
| r2724 | r2725 | |
| 394 | 394 | timer_adjust_oneshot(chip->timer_b, attotime_never, 0); |
| 395 | 395 | } |
| 396 | 396 | |
| 397 | static void ymf278b_A_w(YMF278BChip *chip, UINT8 reg, UINT8 data) | |
| 397 | static void ymf278b_A_w(running_machine *machine, YMF278BChip *chip, UINT8 reg, UINT8 data) | |
| 398 | 398 | { |
| 399 | 399 | switch(reg) |
| 400 | 400 | { |
| r2724 | r2725 | |
| 419 | 419 | if((old_enable ^ data) & 2) |
| 420 | 420 | ymf278b_timer_b_reset(chip); |
| 421 | 421 | } |
| 422 | ymf278b_irq_check(chip); | |
| 422 | ymf278b_irq_check(machine, chip); | |
| 423 | 423 | break; |
| 424 | 424 | default: |
| 425 | 425 | logerror("YMF278B: Port A write %02x, %02x\n", reg, data); |
| r2724 | r2725 | |
| 624 | 624 | chip->port_A = data; |
| 625 | 625 | } |
| 626 | 626 | |
| 627 | static void ymf278b_data_port_A_w(int num, UINT8 data) | |
| 627 | static void ymf278b_data_port_A_w(running_machine *machine, int num, UINT8 data) | |
| 628 | 628 | { |
| 629 | 629 | YMF278BChip *chip = sndti_token(SOUND_YMF278B, num); |
| 630 | ymf278b_A_w(chip, chip->port_A, data); | |
| 630 | ymf278b_A_w(machine, chip, chip->port_A, data); | |
| 631 | 631 | } |
| 632 | 632 | |
| 633 | 633 | static void ymf278b_control_port_B_w(int num, UINT8 data) |
| r2724 | r2725 | |
| 654 | 654 | ymf278b_C_w(chip, chip->port_C, data); |
| 655 | 655 | } |
| 656 | 656 | |
| 657 | static void ymf278b_init(YMF278BChip *chip, UINT8 *rom, void (*cb)(int), int clock) | |
| 657 | static void ymf278b_init(YMF278BChip *chip, UINT8 *rom, void (*cb)(running_machine *, int), int clock) | |
| 658 | 658 | { |
| 659 | 659 | chip->rom = rom; |
| 660 | 660 | chip->irq_callback = cb; |
| r2724 | r2725 | |
| 720 | 720 | |
| 721 | 721 | WRITE8_HANDLER( YMF278B_data_port_0_A_w ) |
| 722 | 722 | { |
| 723 | ymf278b_data_port_A_w(0, data); | |
| 723 | ymf278b_data_port_A_w(machine, 0, data); | |
| 724 | 724 | } |
| 725 | 725 | |
| 726 | 726 | WRITE8_HANDLER( YMF278B_control_port_0_B_w ) |
| r2724 | r2725 | |
| 761 | 761 | |
| 762 | 762 | WRITE8_HANDLER( YMF278B_data_port_1_A_w ) |
| 763 | 763 | { |
| 764 | ymf278b_data_port_A_w(1, data); | |
| 764 | ymf278b_data_port_A_w(machine, 1, data); | |
| 765 | 765 | } |
| 766 | 766 | |
| 767 | 767 | WRITE8_HANDLER( YMF278B_control_port_1_B_w ) |
| r2724 | r2725 | |
|---|---|---|
| 5 | 5 | |
| 6 | 6 | struct YMF278B_interface { |
| 7 | 7 | int region; /* memory region of sample ROMs */ |
| 8 | void (*irq_callback)(int state); /* irq callback */ | |
| 8 | void (*irq_callback)(running_machine *machine, int state); /* irq callback */ | |
| 9 | 9 | }; |
| 10 | 10 | |
| 11 | 11 | READ8_HANDLER( YMF278B_status_port_0_r ); |
| r2724 | r2725 | |
|---|---|---|
| 10 | 10 | |
| 11 | 11 | #include <stdarg.h> |
| 12 | 12 | #include "sndintrf.h" |
| 13 | #include "deprecat.h" | |
| 13 | 14 | #include "streams.h" |
| 14 | 15 | #include "cpuintrf.h" |
| 15 | 16 | #include "psx.h" |
| r2724 | r2725 | |
| 154 | 155 | ( chip->m_n_irqaddress * 4 ) >= chip->m_p_n_blockaddress[ n_channel ] && |
| 155 | 156 | ( chip->m_n_irqaddress * 4 ) <= chip->m_p_n_blockaddress[ n_channel ] + 7 ) |
| 156 | 157 | { |
| 157 | chip->intf->irq_set( 0x0200 ); | |
| 158 | chip->intf->irq_set( Machine, 0x0200 ); | |
| 158 | 159 | } |
| 159 | 160 | |
| 160 | 161 | n_shift = ( chip->m_p_n_spuram[ chip->m_p_n_blockaddress[ n_channel ] ] >> 0 ) & 0x0f; |
| r2724 | r2725 | |
|---|---|---|
| 7 | 7 | |
| 8 | 8 | struct TMS5220interface |
| 9 | 9 | { |
| 10 | void (*irq)(int state); /* IRQ callback function */ | |
| 10 | void (*irq)(running_machine *machine, int state); /* IRQ callback function */ | |
| 11 | 11 | |
| 12 | 12 | int (*read)(int count); /* speech ROM read callback */ |
| 13 | 13 | void (*load_address)(int data); /* speech ROM load address callback */ |
| r2724 | r2725 | |
|---|---|---|
| 3 | 3 | |
| 4 | 4 | struct YM2151interface |
| 5 | 5 | { |
| 6 | void (*irqhandler)(int irq); | |
| 6 | void (*irqhandler)(running_machine *machine, int irq); | |
| 7 | 7 | write8_machine_func portwritehandler; |
| 8 | 8 | }; |
| 9 | 9 |
| r2724 | r2725 | |
|---|---|---|
| 18 | 18 | struct PSXSPUinterface |
| 19 | 19 | { |
| 20 | 20 | UINT32 **p_psxram; |
| 21 | void (*irq_set)(UINT32); | |
| 21 | void (*irq_set)(running_machine *,UINT32); | |
| 22 | 22 | void (*spu_install_read_handler)(int,spu_handler); |
| 23 | 23 | void (*spu_install_write_handler)(int,spu_handler); |
| 24 | 24 | }; |
| r2724 | r2725 | |
|---|---|---|
| 52 | 52 | static void IRQHandler(void *param,int irq) |
| 53 | 53 | { |
| 54 | 54 | struct ym2203_info *info = param; |
| 55 | if(info->intf->handler) info->intf->handler(irq); | |
| 55 | if(info->intf->handler) info->intf->handler(Machine, irq); | |
| 56 | 56 | } |
| 57 | 57 | |
| 58 | 58 | /* Timer overflow callback from timer.c */ |
| r2724 | r2725 | |
|---|---|---|
| 6 | 6 | struct YM2203interface |
| 7 | 7 | { |
| 8 | 8 | const struct AY8910interface ay8910_intf; |
| 9 | void (*handler)(int irq); | |
| 9 | void (*handler)(running_machine *machine, int irq); | |
| 10 | 10 | }; |
| 11 | 11 | |
| 12 | 12 |
| r2724 | r2725 | |
|---|---|---|
| 10 | 10 | Chirp/excitation table fixes by Lord Nightmare |
| 11 | 11 | Various fixes by Lord Nightmare |
| 12 | 12 | Modularization by Lord Nightmare |
| 13 | Sub-interpolation-cycle parameter updating added by Lord Nightmare | |
| 13 | 14 | |
| 14 | 15 | Much information regarding these lpc encoding comes from US patent 4,209,844 |
| 15 | 16 | US patent 4,331,836 describes the complete 51xx chip |
| r2724 | r2725 | |
| 19 | 20 | ***********************************************************************************************/ |
| 20 | 21 | |
| 21 | 22 | #include "sndintrf.h" |
| 23 | #include "deprecat.h" | |
| 22 | 24 | #include "tms5220.h" |
| 23 | 25 | |
| 24 | 26 | |
| r2724 | r2725 | |
| 69 | 71 | UINT8 buffer_empty; /* FIFO is empty*/ |
| 70 | 72 | UINT8 irq_pin; /* state of the IRQ pin (output) */ |
| 71 | 73 | |
| 72 | void (*irq_func)(int state); /* called when the state of the IRQ pin changes */ | |
| 74 | void (*irq_func)(running_machine *machine, int state); /* called when the state of the IRQ pin changes */ | |
| 73 | 75 | |
| 74 | 76 | |
| 75 | 77 | /* these contain data describing the current and previous voice frames */ |
| r2724 | r2725 | |
| 93 | 95 | |
| 94 | 96 | UINT16 previous_energy; /* needed for lattice filter to match patent */ |
| 95 | 97 | |
| 96 | UINT8 interp_count; /* number of interp periods (0-7) */ | |
| 97 | UINT8 sample_count; /* sample number within interp (0-24) */ | |
| 98 | UINT16 pitch_count; | |
| 98 | UINT8 interp_count; /* number of samples within each sub-interpolation period, ranges from 0-24 */ | |
| 99 | UINT8 sample_count; /* number of samples within the ENTIRE interpolation period, ranges from 0-199 */ | |
| 100 | UINT16 pitch_count; /* pitch counter; provides chirp rom address */ | |
| 99 | 101 | |
| 100 | 102 | INT32 u[11]; |
| 101 | 103 | INT32 x[10]; |
| r2724 | r2725 | |
| 233 | 235 | /* initialize the chip state */ |
| 234 | 236 | /* Note that we do not actually clear IRQ on start-up : IRQ is even raised if tms->buffer_empty or tms->buffer_low are 0 */ |
| 235 | 237 | tms->tms5220_speaking = tms->speak_external = tms->talk_status = tms->first_frame = tms->last_frame = tms->irq_pin = 0; |
| 236 | if (tms->irq_func) tms->irq_func(0); | |
| 238 | if (tms->irq_func) tms->irq_func(Machine, 0); | |
| 237 | 239 | tms->buffer_empty = tms->buffer_low = 1; |
| 238 | 240 | |
| 239 | 241 | tms->RDB_flag = FALSE; |
| r2724 | r2725 | |
| 266 | 268 | |
| 267 | 269 | ***********************************************************************************************/ |
| 268 | 270 | |
| 269 | void tms5220_set_irq(void *chip, void (*func)(int)) | |
| 271 | void tms5220_set_irq(void *chip, void (*func)(running_machine *, int)) | |
| 270 | 272 | { |
| 271 | 273 | struct tms5220 *tms = chip; |
| 272 | 274 | tms->irq_func = func; |
| r2724 | r2725 | |
| 595 | 597 | } |
| 596 | 598 | } |
| 597 | 599 | } |
| 598 | else | |
| 600 | else | |
| 599 | 601 | { |
| 600 | /* Update values based on step values */ | |
| 601 | /*mame_printf_debug("\n");*/ | |
| 602 | ||
| 603 | 602 | interp_period = tms->sample_count / 25; |
| 604 | tms->current_energy += ((tms->target_energy - tms->current_energy) >> interp_coeff[interp_period]); | |
| 605 | if (tms->old_pitch != 0) | |
| 606 | tms->current_pitch += ((tms->target_pitch - tms->current_pitch) >> interp_coeff[interp_period]); | |
| 607 | ||
| 608 | /*mame_printf_debug("*** Energy = %d\n",tms->current_energy);*/ | |
| 609 | ||
| 610 | for (i = 0; i < 10; i++) | |
| 611 | { | |
| 612 | tms->current_k[i] += ((tms->target_k[i] - tms->current_k[i]) >> interp_coeff[interp_period]); | |
| 613 | } | |
| 603 | switch(tms->interp_count) | |
| 604 | { | |
| 605 | /* PC=X X cycle, rendering change (change for next cycle which chip is actually doing) */ | |
| 606 | case 0: /* PC=0, A cycle, nothing happens (calc energy) */ | |
| 607 | break; | |
| 608 | case 1: /* PC=0, B cycle, nothing happens (update energy) */ | |
| 609 | break; | |
| 610 | case 2: /* PC=1, A cycle, update energy (calc pitch) */ | |
| 611 | tms->current_energy += ((tms->target_energy - tms->current_energy) >> interp_coeff[interp_period]); | |
| 612 | break; | |
| 613 | case 3: /* PC=1, B cycle, nothing happens (update pitch) */ | |
| 614 | break; | |
| 615 | case 4: /* PC=2, A cycle, update pitch (calc K1) */ | |
| 616 | if (tms->old_pitch != 0) | |
| 617 | tms->current_pitch += ((tms->target_pitch - tms->current_pitch) >> interp_coeff[interp_period]); | |
| 618 | break; | |
| 619 | case 5: /* PC=2, B cycle, nothing happens (update K1) */ | |
| 620 | break; | |
| 621 | case 6: /* PC=3, A cycle, update K1 (calc K2) */ | |
| 622 | tms->current_k[0] += ((tms->target_k[0] - tms->current_k[0]) >> interp_coeff[interp_period]); | |
| 623 | break; | |
| 624 | case 7: /* PC=3, B cycle, nothing happens (update K2) */ | |
| 625 | break; | |
| 626 | case 8: /* PC=4, A cycle, update K2 (calc K3) */ | |
| 627 | tms->current_k[1] += ((tms->target_k[1] - tms->current_k[1]) >> interp_coeff[interp_period]); | |
| 628 | break; | |
| 629 | case 9: /* PC=4, B cycle, nothing happens (update K3) */ | |
| 630 | break; | |
| 631 | case 10: /* PC=5, A cycle, update K3 (calc K4) */ | |
| 632 | tms->current_k[2] += ((tms->target_k[2] - tms->current_k[2]) >> interp_coeff[interp_period]); | |
| 633 | break; | |
| 634 | case 11: /* PC=5, B cycle, nothing happens (update K4) */ | |
| 635 | break; | |
| 636 | case 12: /* PC=6, A cycle, update K4 (calc K5) */ | |
| 637 | tms->current_k[3] += ((tms->target_k[3] - tms->current_k[3]) >> interp_coeff[interp_period]); | |
| 638 | break; | |
| 639 | case 13: /* PC=6, B cycle, nothing happens (update K5) */ | |
| 640 | break; | |
| 641 | case 14: /* PC=7, A cycle, update K5 (calc K6) */ | |
| 642 | tms->current_k[4] += ((tms->target_k[4] - tms->current_k[4]) >> interp_coeff[interp_period]); | |
| 643 | break; | |
| 644 | case 15: /* PC=7, B cycle, nothing happens (update K6) */ | |
| 645 | break; | |
| 646 | case 16: /* PC=8, A cycle, update K6 (calc K7) */ | |
| 647 | tms->current_k[5] += ((tms->target_k[5] - tms->current_k[5]) >> interp_coeff[interp_period]); | |
| 648 | break; | |
| 649 | case 17: /* PC=8, B cycle, nothing happens (update K7) */ | |
| 650 | break; | |
| 651 | case 18: /* PC=9, A cycle, update K7 (calc K8) */ | |
| 652 | tms->current_k[6] += ((tms->target_k[6] - tms->current_k[6]) >> interp_coeff[interp_period]); | |
| 653 | break; | |
| 654 | case 19: /* PC=9, B cycle, nothing happens (update K8) */ | |
| 655 | break; | |
| 656 | case 20: /* PC=10, A cycle, update K8 (calc K9) */ | |
| 657 | tms->current_k[7] += ((tms->target_k[7] - tms->current_k[7]) >> interp_coeff[interp_period]); | |
| 658 | break; | |
| 659 | case 21: /* PC=10, B cycle, nothing happens (update K9) */ | |
| 660 | break; | |
| 661 | case 22: /* PC=11, A cycle, update K9 (calc K10) */ | |
| 662 | tms->current_k[8] += ((tms->target_k[8] - tms->current_k[8]) >> interp_coeff[interp_period]); | |
| 663 | break; | |
| 664 | case 23: /* PC=11, B cycle, nothing happens (update K10) */ | |
| 665 | break; | |
| 666 | case 24: /* PC=12, A cycle, update K10 (do nothing) */ | |
| 667 | tms->current_k[9] += ((tms->target_k[9] - tms->current_k[9]) >> interp_coeff[interp_period]); | |
| 668 | break; | |
| 669 | } | |
| 614 | 670 | } |
| 615 | 671 | |
| 616 | 672 | if (tms->old_energy == 0) |
| 617 | 673 | { |
| 618 | 674 | /* generate silent samples here */ |
| 619 | tms->excitation_data = 0x00; /* I'm not sure if this is actually RIGHT, the current_energy may be forced to zero when we've just passed a zero energy frame. However, this does work too. May be removed later. */ | |
| 675 | tms->excitation_data = 0x00; /* This is NOT correct, the current_energy is forced to zero when we just passed a zero energy frame because thats what the tables hold for that value. | |
| 676 | However, this code does no harm. Will be removed later. */ | |
| 620 | 677 | } |
| 621 | 678 | else if (tms->old_pitch == 0) |
| 622 | 679 | { |
| r2724 | r2725 | |
| 642 | 699 | tms->excitation_data = chirptable[tms->pitch_count]; |
| 643 | 700 | } |
| 644 | 701 | |
| 645 | /* Update LFSR every clock, like patent shows */ | |
| 646 | bitout = ((tms->RNG >> 12) & 1) ^ | |
| 647 | ((tms->RNG >> 10) & 1) ^ | |
| 648 | ((tms->RNG >> 9) & 1) ^ | |
| 649 | ((tms->RNG >> 0) & 1); | |
| 650 | tms->RNG >>= 1; | |
| 651 | tms->RNG |= bitout << 12; | |
| 702 | /* Update LFSR *20* times every sample, like patent shows */ | |
| 703 | for (i=0; i<20; i++) | |
| 704 | { | |
| 705 | bitout = ((tms->RNG >> 12) & 1) ^ | |
| 706 | ((tms->RNG >> 10) & 1) ^ | |
| 707 | ((tms->RNG >> 9) & 1) ^ | |
| 708 | ((tms->RNG >> 0) & 1); | |
| 709 | tms->RNG >>= 1; | |
| 710 | tms->RNG |= bitout << 12; | |
| 711 | } | |
| 652 | 712 | |
| 653 | 713 | buffer[buf_count] = clip_and_wrap(lattice_filter(tms)); /* execute lattice filter and clipping/wrapping */ |
| 654 | 714 | |
| r2724 | r2725 | |
| 1112 | 1172 | static void set_interrupt_state(struct tms5220 *tms, int state) |
| 1113 | 1173 | { |
| 1114 | 1174 | if (tms->irq_func && state != tms->irq_pin) |
| 1115 | tms->irq_func(state); | |
| 1175 | tms->irq_func(Machine, state); | |
| 1116 | 1176 | tms->irq_pin = state; |
| 1117 | 1177 | } |
| r2724 | r2725 | |
|---|---|---|
| 5 | 5 | void tms5220_destroy(void *chip); |
| 6 | 6 | |
| 7 | 7 | void tms5220_reset_chip(void *chip); |
| 8 | void tms5220_set_irq(void *chip, void (*func)(int)); | |
| 8 | void tms5220_set_irq(void *chip, void (*func)(running_machine *, int)); | |
| 9 | 9 | |
| 10 | 10 | void tms5220_data_write(void *chip, int data); |
| 11 | 11 | int tms5220_status_read(void *chip); |
| r2724 | r2725 | |
|---|---|---|
| 36 | 36 | #include <math.h> |
| 37 | 37 | #include "sndintrf.h" |
| 38 | 38 | #include "cpuintrf.h" |
| 39 | #include "deprecat.h" | |
| 39 | 40 | #include "es5503.h" |
| 40 | 41 | #include "streams.h" |
| 41 | 42 | #include "state.h" |
| r2724 | r2725 | |
| 67 | 68 | int index; |
| 68 | 69 | sound_stream * stream; |
| 69 | 70 | |
| 70 | void (*irq_callback)(int); // IRQ callback | |
| 71 | void (*irq_callback)(running_machine *machine, int); // IRQ callback | |
| 71 | 72 | |
| 72 | 73 | read8_machine_func adc_read; // callback for the 5503's built-in analog to digital converter |
| 73 | 74 | |
| r2724 | r2725 | |
| 127 | 128 | |
| 128 | 129 | if (chip->irq_callback) |
| 129 | 130 | { |
| 130 | chip->irq_callback(1); | |
| 131 | chip->irq_callback(Machine, 1); | |
| 131 | 132 | } |
| 132 | 133 | } |
| 133 | 134 | } |
| r2724 | r2725 | |
| 347 | 348 | |
| 348 | 349 | if (chip->irq_callback) |
| 349 | 350 | { |
| 350 | chip->irq_callback(0); | |
| 351 | chip->irq_callback(machine, 0); | |
| 351 | 352 | } |
| 352 | 353 | break; |
| 353 | 354 | } |
| r2724 | r2725 | |
| 360 | 361 | { |
| 361 | 362 | if (chip->irq_callback) |
| 362 | 363 | { |
| 363 | chip->irq_callback(1); | |
| 364 | chip->irq_callback(machine, 1); | |
| 364 | 365 | } |
| 365 | 366 | break; |
| 366 | 367 | } |
| r2724 | r2725 | |
|---|---|---|
| 3 | 3 | |
| 4 | 4 | struct ES5503interface |
| 5 | 5 | { |
| 6 | void (*irq_callback)(int state); | |
| 6 | void (*irq_callback)(running_machine *machine, int state); | |
| 7 | 7 | read8_machine_func adc_read; |
| 8 | 8 | UINT8 *wave_memory; |
| 9 | 9 | }; |
| r2724 | r2725 | |
|---|---|---|
| 6 | 6 | |
| 7 | 7 | ***************************************************************************/ |
| 8 | 8 | #include "sndintrf.h" |
| 9 | #include "deprecat.h" | |
| 9 | 10 | #include "streams.h" |
| 10 | 11 | #include "262intf.h" |
| 11 | 12 | #include "ymf262.h" |
| r2724 | r2725 | |
| 25 | 26 | static void IRQHandler_262(void *param,int irq) |
| 26 | 27 | { |
| 27 | 28 | struct ymf262_info *info = param; |
| 28 | if (info->intf->handler) (info->intf->handler)(irq); | |
| 29 | if (info->intf->handler) (info->intf->handler)(Machine, irq); | |
| 29 | 30 | } |
| 30 | 31 | |
| 31 | 32 | static TIMER_CALLBACK( timer_callback_262_0 ) |
| r2724 | r2725 | |
|---|---|---|
| 174 | 174 | return 0; |
| 175 | 175 | } |
| 176 | 176 | |
| 177 | ||
| 178 | /*------------------------------------------------- | |
| 179 | input_seq_append_or - append a code to a | |
| 180 | sequence; if the sequence is non-empty, insert | |
| 181 | an OR before the new code | |
| 182 | -------------------------------------------------*/ | |
| 183 | ||
| 184 | INLINE void input_seq_append_or(input_seq *seq, input_code code) | |
| 185 | { | |
| 186 | int codenum; | |
| 187 | if (seq->code[0] == SEQCODE_END || seq->code[0] == SEQCODE_DEFAULT) | |
| 188 | { | |
| 189 | seq->code[0] = code; | |
| 190 | seq->code[1] = SEQCODE_END; | |
| 191 | } | |
| 192 | else | |
| 193 | { | |
| 194 | for (codenum = 0; codenum < ARRAY_LENGTH(seq->code) - 2; codenum++) | |
| 195 | if (seq->code[codenum] == SEQCODE_END) | |
| 196 | { | |
| 197 | seq->code[codenum++] = SEQCODE_OR; | |
| 198 | seq->code[codenum++] = code; | |
| 199 | seq->code[codenum++] = SEQCODE_END; | |
| 200 | } | |
| 201 | } | |
| 202 | } | |
| 203 | ||
| 204 | ||
| 177 | 205 | #endif /* __INPUTSEQ_H__ */ |
| r2724 | r2725 | |
|---|---|---|
| 72 | 72 | INT32 defval; /* default value */ |
| 73 | 73 | INT32 maxval; /* maximum value */ |
| 74 | 74 | INT32 incval; /* increment value */ |
| 75 | INT32 (*update)(running_machine *machine, INT32 newval, char *buffer, int arg); /* callback */ | |
| 76 | int arg; /* argument */ | |
| 75 | INT32 (*update)(running_machine *machine, INT32 newval, char *buffer, void *arg); /* callback */ | |
| 76 | void * arg; /* argument */ | |
| 77 | 77 | }; |
| 78 | 78 | |
| 79 | 79 | |
| r2724 | r2725 | |
| 139 | 139 | static void slider_init(running_machine *machine); |
| 140 | 140 | static void slider_display(const char *text, int minval, int maxval, int defval, int curval); |
| 141 | 141 | static void slider_draw_bar(float leftx, float topy, float width, float height, float percentage, float default_percentage); |
| 142 | static INT32 slider_volume(running_machine *machine, INT32 newval, char *buffer, int arg); | |
| 143 | static INT32 slider_mixervol(running_machine *machine, INT32 newval, char *buffer, int arg); | |
| 144 | static INT32 slider_adjuster(running_machine *machine, INT32 newval, char *buffer, int arg); | |
| 145 | static INT32 slider_overclock(running_machine *machine, INT32 newval, char *buffer, int arg); | |
| 146 | static INT32 slider_refresh(running_machine *machine, INT32 newval, char *buffer, int arg); | |
| 147 | static INT32 slider_brightness(running_machine *machine, INT32 newval, char *buffer, int arg); | |
| 148 | static INT32 slider_contrast(running_machine *machine, INT32 newval, char *buffer, int arg); | |
| 149 | static INT32 slider_gamma(running_machine *machine, INT32 newval, char *buffer, int arg); | |
| 150 | static INT32 slider_xscale(running_machine *machine, INT32 newval, char *buffer, int arg); | |
| 151 | static INT32 slider_yscale(running_machine *machine, INT32 newval, char *buffer, int arg); | |
| 152 | static INT32 slider_xoffset(running_machine *machine, INT32 newval, char *buffer, int arg); | |
| 153 | static INT32 slider_yoffset(running_machine *machine, INT32 newval, char *buffer, int arg); | |
| 154 | static INT32 slider_flicker(running_machine *machine, INT32 newval, char *buffer, int arg); | |
| 155 | static INT32 slider_beam(running_machine *machine, INT32 newval, char *buffer, int arg); | |
| 142 | static INT32 slider_volume(running_machine *machine, INT32 newval, char *buffer, void *arg); | |
| 143 | static INT32 slider_mixervol(running_machine *machine, INT32 newval, char *buffer, void *arg); | |
| 144 | static INT32 slider_adjuster(running_machine *machine, INT32 newval, char *buffer, void *arg); | |
| 145 | static INT32 slider_overclock(running_machine *machine, INT32 newval, char *buffer, void *arg); | |
| 146 | static INT32 slider_refresh(running_machine *machine, INT32 newval, char *buffer, void *arg); | |
| 147 | static INT32 slider_brightness(running_machine *machine, INT32 newval, char *buffer, void *arg); | |
| 148 | static INT32 slider_contrast(running_machine *machine, INT32 newval, char *buffer, void *arg); | |
| 149 | static INT32 slider_gamma(running_machine *machine, INT32 newval, char *buffer, void *arg); | |
| 150 | static INT32 slider_xscale(running_machine *machine, INT32 newval, char *buffer, void *arg); | |
| 151 | static INT32 slider_yscale(running_machine *machine, INT32 newval, char *buffer, void *arg); | |
| 152 | static INT32 slider_xoffset(running_machine *machine, INT32 newval, char *buffer, void *arg); | |
| 153 | static INT32 slider_yoffset(running_machine *machine, INT32 newval, char *buffer, void *arg); | |
| 154 | static INT32 slider_flicker(running_machine *machine, INT32 newval, char *buffer, void *arg); | |
| 155 | static INT32 slider_beam(running_machine *machine, INT32 newval, char *buffer, void *arg); | |
| 156 | 156 | static char *slider_get_screen_desc(const device_config *screen); |
| 157 | 157 | #ifdef MAME_DEBUG |
| 158 | static INT32 slider_crossscale(running_machine *machine, INT32 newval, char *buffer, int arg); | |
| 159 | static INT32 slider_crossoffset(running_machine *machine, INT32 newval, char *buffer, int arg); | |
| 158 | static INT32 slider_crossscale(running_machine *machine, INT32 newval, char *buffer, void *arg); | |
| 159 | static INT32 slider_crossoffset(running_machine *machine, INT32 newval, char *buffer, void *arg); | |
| 160 | 160 | #endif |
| 161 | 161 | |
| 162 | 162 | |
| r2724 | r2725 | |
| 182 | 182 | -------------------------------------------------*/ |
| 183 | 183 | |
| 184 | 184 | INLINE void slider_config(slider_state *state, INT32 minval, INT32 defval, INT32 maxval, INT32 incval, |
| 185 | INT32 (*update)(running_machine *, INT32, char *, i | |
| 185 | INT32 (*update)(running_machine *, INT32, char *, void *), void | |
| 186 | 186 | { |
| 187 | 187 | state->minval = minval; |
| 188 | 188 | state->defval = defval; |
| r2724 | r2725 | |
| 1173 | 1173 | ui_draw_text_box(messagebox_text, JUSTIFY_LEFT, 0.5f, 0.5f, messagebox_backcolor); |
| 1174 | 1174 | |
| 1175 | 1175 | /* an 'O' or left joystick kicks us to the next state */ |
| 1176 | if (state == 0 && (input_code_pressed_once(KEYCODE_O) || input_ui_pressed(IPT_UI_LEFT))) | |
| 1176 | if (state == 0 && (input_code_pressed_once(KEYCODE_O) || input_ui_pressed(machine, IPT_UI_LEFT))) | |
| 1177 | 1177 | state++; |
| 1178 | 1178 | |
| 1179 | 1179 | /* a 'K' or right joystick exits the state */ |
| 1180 | else if (state == 1 && (input_code_pressed_once(KEYCODE_K) || input_ui_pressed(IPT_UI_RIGHT))) | |
| 1180 | else if (state == 1 && (input_code_pressed_once(KEYCODE_K) || input_ui_pressed(machine, IPT_UI_RIGHT))) | |
| 1181 | 1181 | state = UI_HANDLER_CANCEL; |
| 1182 | 1182 | |
| 1183 | 1183 | /* if the user cancels, exit out completely */ |
| 1184 | else if (input_ui_pressed(IPT_UI_CANCEL)) | |
| 1184 | else if (input_ui_pressed(machine, IPT_UI_CANCEL)) | |
| 1185 | 1185 | { |
| 1186 | 1186 | mame_schedule_exit(machine); |
| 1187 | 1187 | state = UI_HANDLER_CANCEL; |
| r2724 | r2725 | |
| 1203 | 1203 | ui_draw_text_box(messagebox_text, JUSTIFY_LEFT, 0.5f, 0.5f, messagebox_backcolor); |
| 1204 | 1204 | |
| 1205 | 1205 | /* if the user cancels, exit out completely */ |
| 1206 | if (input_ui_pressed(IPT_UI_CANCEL)) | |
| 1206 | if (input_ui_pressed(machine, IPT_UI_CANCEL)) | |
| 1207 | 1207 | { |
| 1208 | 1208 | mame_schedule_exit(machine); |
| 1209 | 1209 | state = UI_HANDLER_CANCEL; |
| r2724 | r2725 | |
| 1262 | 1262 | #endif /* MESS */ |
| 1263 | 1263 | |
| 1264 | 1264 | /* if the user pressed ESC, stop the emulation */ |
| 1265 | if (input_ui_pressed(IPT_UI_CANCEL)) | |
| 1265 | if (input_ui_pressed(machine, IPT_UI_CANCEL)) | |
| 1266 | 1266 | mame_schedule_exit(machine); |
| 1267 | 1267 | |
| 1268 | 1268 | /* turn on menus if requested */ |
| 1269 | if (input_ui_pressed(IPT_UI_CONFIGURE)) | |
| 1269 | if (input_ui_pressed(machine, IPT_UI_CONFIGURE)) | |
| 1270 | 1270 | return ui_set_handler(ui_menu_ui_handler, 0); |
| 1271 | 1271 | |
| 1272 | 1272 | /* if the on-screen display isn't up and the user has toggled it, turn it on */ |
| 1273 | if (!machine->debug_mode && input_ui_pressed(IPT_UI_ON_SCREEN_DISPLAY)) | |
| 1273 | if (!machine->debug_mode && input_ui_pressed(machine, IPT_UI_ON_SCREEN_DISPLAY)) | |
| 1274 | 1274 | return ui_set_handler(handler_slider, 0); |
| 1275 | 1275 | |
| 1276 | 1276 | /* handle a reset request */ |
| 1277 | if (input_ui_pressed(IPT_UI_RESET_MACHINE)) | |
| 1277 | if (input_ui_pressed(machine, IPT_UI_RESET_MACHINE)) | |
| 1278 | 1278 | mame_schedule_hard_reset(machine); |
| 1279 | if (input_ui_pressed(IPT_UI_SOFT_RESET)) | |
| 1279 | if (input_ui_pressed(machine, IPT_UI_SOFT_RESET)) | |
| 1280 | 1280 | mame_schedule_soft_reset(machine); |
| 1281 | 1281 | |
| 1282 | 1282 | /* handle a request to display graphics/palette */ |
| 1283 | if (input_ui_pressed(IPT_UI_SHOW_GFX)) | |
| 1283 | if (input_ui_pressed(machine, IPT_UI_SHOW_GFX)) | |
| 1284 | 1284 | { |
| 1285 | 1285 | if (!is_paused) |
| 1286 | 1286 | mame_pause(machine, TRUE); |
| r2724 | r2725 | |
| 1288 | 1288 | } |
| 1289 | 1289 | |
| 1290 | 1290 | /* handle a save state request */ |
| 1291 | if (input_ui_pressed(IPT_UI_SAVE_STATE)) | |
| 1291 | if (input_ui_pressed(machine, IPT_UI_SAVE_STATE)) | |
| 1292 | 1292 | { |
| 1293 | 1293 | mame_pause(machine, TRUE); |
| 1294 | 1294 | return ui_set_handler(handler_load_save, LOADSAVE_SAVE); |
| 1295 | 1295 | } |
| 1296 | 1296 | |
| 1297 | 1297 | /* handle a load state request */ |
| 1298 | if (input_ui_pressed(IPT_UI_LOAD_STATE)) | |
| 1298 | if (input_ui_pressed(machine, IPT_UI_LOAD_STATE)) | |
| 1299 | 1299 | { |
| 1300 | 1300 | mame_pause(machine, TRUE); |
| 1301 | 1301 | return ui_set_handler(handler_load_save, LOADSAVE_LOAD); |
| 1302 | 1302 | } |
| 1303 | 1303 | |
| 1304 | 1304 | /* handle a save snapshot request */ |
| 1305 | if (input_ui_pressed(IPT_UI_SNAPSHOT)) | |
| 1305 | if (input_ui_pressed(machine, IPT_UI_SNAPSHOT)) | |
| 1306 | 1306 | video_save_active_screen_snapshots(machine); |
| 1307 | 1307 | |
| 1308 | 1308 | /* toggle pause */ |
| 1309 | if (input_ui_pressed(IPT_UI_PAUSE)) | |
| 1309 | if (input_ui_pressed(machine, IPT_UI_PAUSE)) | |
| 1310 | 1310 | { |
| 1311 | 1311 | /* with a shift key, it is single step */ |
| 1312 | 1312 | if (is_paused && (input_code_pressed(KEYCODE_LSHIFT) || input_code_pressed(KEYCODE_RSHIFT))) |
| r2724 | r2725 | |
| 1319 | 1319 | } |
| 1320 | 1320 | |
| 1321 | 1321 | /* toggle movie recording */ |
| 1322 | if (input_ui_pressed(IPT_UI_RECORD_MOVIE)) | |
| 1322 | if (input_ui_pressed(machine, IPT_UI_RECORD_MOVIE)) | |
| 1323 | 1323 | { |
| 1324 | 1324 | if (!video_mng_is_movie_active(machine->primary_screen)) |
| 1325 | 1325 | { |
| r2724 | r2725 | |
| 1334 | 1334 | } |
| 1335 | 1335 | |
| 1336 | 1336 | /* toggle profiler display */ |
| 1337 | if (input_ui_pressed(IPT_UI_SHOW_PROFILER)) | |
| 1337 | if (input_ui_pressed(machine, IPT_UI_SHOW_PROFILER)) | |
| 1338 | 1338 | ui_set_show_profiler(!ui_get_show_profiler()); |
| 1339 | 1339 | |
| 1340 | 1340 | /* toggle FPS display */ |
| 1341 | if (input_ui_pressed(IPT_UI_SHOW_FPS)) | |
| 1341 | if (input_ui_pressed(machine, IPT_UI_SHOW_FPS)) | |
| 1342 | 1342 | ui_set_show_fps(!ui_get_show_fps()); |
| 1343 | 1343 | |
| 1344 | 1344 | /* toggle crosshair display */ |
| 1345 | if (input_ui_pressed(IPT_UI_TOGGLE_CROSSHAIR)) | |
| 1345 | if (input_ui_pressed(machine, IPT_UI_TOGGLE_CROSSHAIR)) | |
| 1346 | 1346 | crosshair_toggle(machine); |
| 1347 | 1347 | |
| 1348 | 1348 | /* increment frameskip? */ |
| 1349 | if (input_ui_pressed(IPT_UI_FRAMESKIP_INC)) | |
| 1349 | if (input_ui_pressed(machine, IPT_UI_FRAMESKIP_INC)) | |
| 1350 | 1350 | { |
| 1351 | 1351 | /* get the current value and increment it */ |
| 1352 | 1352 | int newframeskip = video_get_frameskip() + 1; |
| r2724 | r2725 | |
| 1359 | 1359 | } |
| 1360 | 1360 | |
| 1361 | 1361 | /* decrement frameskip? */ |
| 1362 | if (input_ui_pressed(IPT_UI_FRAMESKIP_DEC)) | |
| 1362 | if (input_ui_pressed(machine, IPT_UI_FRAMESKIP_DEC)) | |
| 1363 | 1363 | { |
| 1364 | 1364 | /* get the current value and decrement it */ |
| 1365 | 1365 | int newframeskip = video_get_frameskip() - 1; |
| r2724 | r2725 | |
| 1372 | 1372 | } |
| 1373 | 1373 | |
| 1374 | 1374 | /* toggle throttle? */ |
| 1375 | if (input_ui_pressed(IPT_UI_THROTTLE)) | |
| 1375 | if (input_ui_pressed(machine, IPT_UI_THROTTLE)) | |
| 1376 | 1376 | video_set_throttle(!video_get_throttle()); |
| 1377 | 1377 | |
| 1378 | 1378 | /* check for fast forward */ |
| 1379 | if (input_ | |
| 1379 | if (input_ | |
| 1380 | 1380 | { |
| 1381 | 1381 | video_set_fastforward(TRUE); |
| 1382 | 1382 | ui_show_fps_temp(0.5); |
| r2724 | r2725 | |
| 1386 | 1386 | |
| 1387 | 1387 | #ifdef MESS |
| 1388 | 1388 | /* paste? */ |
| 1389 | if (input_ui_pressed(IPT_UI_PASTE)) | |
| 1389 | if (input_ui_pressed(machine, IPT_UI_PASTE)) | |
| 1390 | 1390 | ui_paste(machine); |
| 1391 | 1391 | #endif /* MESS */ |
| 1392 | 1392 | |
| r2724 | r2725 | |
| 1406 | 1406 | char textbuf[256]; |
| 1407 | 1407 | |
| 1408 | 1408 | /* left/right control the increment */ |
| 1409 | if (input_ui_pressed_repeat(IPT_UI_LEFT,6)) | |
| 1409 | if (input_ui_pressed_repeat(machine, IPT_UI_LEFT,6)) | |
| 1410 | 1410 | increment = -cur->incval; |
| 1411 | if (input_ui_pressed_repeat(IPT_UI_RIGHT,6)) | |
| 1411 | if (input_ui_pressed_repeat(machine, IPT_UI_RIGHT,6)) | |
| 1412 | 1412 | increment = cur->incval; |
| 1413 | 1413 | |
| 1414 | 1414 | /* alt goes to 1, shift goes 10x smaller, control goes 10x larger */ |
| r2724 | r2725 | |
| 1426 | 1426 | newval = (*cur->update)(machine, 0, NULL, cur->arg) + increment; |
| 1427 | 1427 | |
| 1428 | 1428 | /* select resets to the default value */ |
| 1429 | if (input_ui_pressed(IPT_UI_SELECT)) | |
| 1429 | if (input_ui_pressed(machine, IPT_UI_SELECT)) | |
| 1430 | 1430 | newval = cur->defval; |
| 1431 | 1431 | |
| 1432 | 1432 | /* clamp within bounds */ |
| r2724 | r2725 | |
| 1442 | 1442 | slider_display(textbuf, cur->minval, cur->maxval, cur->defval, newval); |
| 1443 | 1443 | |
| 1444 | 1444 | /* up/down select which slider to control */ |
| 1445 | if (input_ui_pressed_repeat(IPT_UI_DOWN,6)) | |
| 1445 | if (input_ui_pressed_repeat(machine, IPT_UI_DOWN,6)) | |
| 1446 | 1446 | slider_current = (slider_current + 1) % slider_count; |
| 1447 | if (input_ui_pressed_repeat(IPT_UI_UP,6)) | |
| 1447 | if (input_ui_pressed_repeat(machine, IPT_UI_UP,6)) | |
| 1448 | 1448 | slider_current = (slider_current + slider_count - 1) % slider_count; |
| 1449 | 1449 | |
| 1450 | 1450 | /* the slider toggle or ESC will cancel out of our display */ |
| 1451 | if (input_ui_pressed(IPT_UI_ON_SCREEN_DISPLAY) || input_ui_pressed(IPT_UI_CANCEL)) | |
| 1451 | if (input_ui_pressed(machine, IPT_UI_ON_SCREEN_DISPLAY) || input_ui_pressed(machine, IPT_UI_CANCEL)) | |
| 1452 | 1452 | return UI_HANDLER_CANCEL; |
| 1453 | 1453 | |
| 1454 | 1454 | /* the menu key will take us directly to the menu */ |
| 1455 | if (input_ui_pressed(IPT_UI_CONFIGURE)) | |
| 1455 | if (input_ui_pressed(machine, IPT_UI_CONFIGURE)) | |
| 1456 | 1456 | return ui_set_handler(ui_menu_ui_handler, 0); |
| 1457 | 1457 | |
| 1458 | 1458 | return 0; |
| r2724 | r2725 | |
| 1481 | 1481 | ui_draw_message_window("Select position to load from"); |
| 1482 | 1482 | |
| 1483 | 1483 | /* check for cancel key */ |
| 1484 | if (input_ui_pressed(IPT_UI_CANCEL)) | |
| 1484 | if (input_ui_pressed(machine, IPT_UI_CANCEL)) | |
| 1485 | 1485 | { |
| 1486 | 1486 | /* display a popup indicating things were cancelled */ |
| 1487 | 1487 | if (state == LOADSAVE_SAVE) |
| r2724 | r2725 | |
| 1541 | 1541 | static void slider_init(running_machine *machine) |
| 1542 | 1542 | { |
| 1543 | 1543 | int numscreens = video_screen_count(machine->config); |
| 1544 | const input_port_config *port; | |
| 1545 | const input_field_config *field; | |
| 1544 | 1546 | const device_config *device; |
| 1545 | 1547 | int numitems, item; |
| 1546 | input_port_entry *in; | |
| 1547 | 1548 | |
| 1548 | 1549 | slider_count = 0; |
| 1549 | 1550 | |
| 1550 | 1551 | /* add overall volume */ |
| 1551 | slider_config(&slider_list[slider_count++], -32, 0, 0, 1, slider_volume, | |
| 1552 | slider_config(&slider_list[slider_count++], -32, 0, 0, 1, slider_volume, NULL); | |
| 1552 | 1553 | |
| 1553 | 1554 | /* add per-channel volume */ |
| 1554 | 1555 | numitems = sound_get_user_gain_count(); |
| r2724 | r2725 | |
| 1560 | 1561 | if (defval > 1000) |
| 1561 | 1562 | maxval = 2 * defval; |
| 1562 | 1563 | |
| 1563 | slider_config(&slider_list[slider_count++], 0, defval, maxval, 20, slider_mixervol, item); | |
| 1564 | slider_config(&slider_list[slider_count++], 0, defval, maxval, 20, slider_mixervol, (void *)(FPTR)item); | |
| 1564 | 1565 | } |
| 1565 | 1566 | |
| 1566 | 1567 | /* add analog adjusters */ |
| 1567 | for (in = machine->input_ports; in && in->type != IPT_END; in++) | |
| 1568 | if ((in->type & 0xff) == IPT_ADJUSTER) | |
| 1569 | slider_config(&slider_list[slider_count++], 0, in->default_value >> 8, 100, 1, slider_adjuster, in - machine->input_ports); | |
| 1568 | for (port = machine->portconfig; port != NULL; port = port->next) | |
| 1569 | for (field = port->fieldlist; field != NULL; field = field->next) | |
| 1570 | if (field->type == IPT_ADJUSTER) | |
| 1571 | { | |
| 1572 | void *param = (void *)field; | |
| 1573 | slider_config(&slider_list[slider_count++], 0, field->defvalue, 100, 1, slider_adjuster, param); | |
| 1574 | } | |
| 1570 | 1575 | |
| 1571 | 1576 | if (options_get_bool(mame_options(), OPTION_CHEAT)) |
| 1572 | 1577 | { |
| 1573 | 1578 | /* add CPU overclocking */ |
| 1574 | 1579 | numitems = cpu_gettotalcpu(); |
| 1575 | 1580 | for (item = 0; item < numitems; item++) |
| 1576 | slider_config(&slider_list[slider_count++], 10, 1000, 2000, 1, slider_overclock, item); | |
| 1581 | slider_config(&slider_list[slider_count++], 10, 1000, 2000, 1, slider_overclock, (void *)(FPTR)item); | |
| 1577 | 1582 | |
| 1578 | 1583 | /* add refresh rate tweaker */ |
| 1579 | slider_config(&slider_list[slider_count++], -10000, 0, 10000, 1000, slider_refresh, | |
| 1584 | slider_config(&slider_list[slider_count++], -10000, 0, 10000, 1000, slider_refresh, NULL); | |
| 1580 | 1585 | } |
| 1581 | 1586 | |
| 1582 | 1587 | for (item = 0; item < numscreens; item++) |
| 1583 | 1588 | { |
| 1584 | const screen_config *scrconfig = device_list_find_by_index(machine->config->devicelist, VIDEO_SCREEN, item)->inline_config; | |
| 1589 | const device_config *screen = device_list_find_by_index(machine->config->devicelist, VIDEO_SCREEN, item); | |
| 1590 | const screen_config *scrconfig = screen->inline_config; | |
| 1585 | 1591 | int defxscale = floor(scrconfig->xscale * 1000.0f + 0.5f); |
| 1586 | 1592 | int defyscale = floor(scrconfig->yscale * 1000.0f + 0.5f); |
| 1587 | 1593 | int defxoffset = floor(scrconfig->xoffset * 1000.0f + 0.5f); |
| 1588 | 1594 | int defyoffset = floor(scrconfig->yoffset * 1000.0f + 0.5f); |
| 1595 | void *param = (void *)screen; | |
| 1589 | 1596 | |
| 1590 | 1597 | /* add standard brightness/contrast/gamma controls per-screen */ |
| 1591 | slider_config(&slider_list[slider_count++], 100, 1000, 2000, 10, slider_brightness, item); | |
| 1592 | slider_config(&slider_list[slider_count++], 100, 1000, 2000, 50, slider_contrast, item); | |
| 1593 | slider_config(&slider_list[slider_count++], 100, 1000, 3000, 50, slider_gamma, item); | |
| 1598 | slider_config(&slider_list[slider_count++], 100, 1000, 2000, 10, slider_brightness, param); | |
| 1599 | slider_config(&slider_list[slider_count++], 100, 1000, 2000, 50, slider_contrast, param); | |
| 1600 | slider_config(&slider_list[slider_count++], 100, 1000, 3000, 50, slider_gamma, param); | |
| 1594 | 1601 | |
| 1595 | 1602 | /* add scale and offset controls per-screen */ |
| 1596 | slider_config(&slider_list[slider_count++], 500, (defxscale == 0) ? 1000 : defxscale, 1500, 2, slider_xscale, item); | |
| 1597 | slider_config(&slider_list[slider_count++], -500, defxoffset, 500, 2, slider_xoffset, item); | |
| 1598 | slider_config(&slider_list[slider_count++], 500, (defyscale == 0) ? 1000 : defyscale, 1500, 2, slider_yscale, item); | |
| 1599 | slider_config(&slider_list[slider_count++], -500, defyoffset, 500, 2, slider_yoffset, item); | |
| 1603 | slider_config(&slider_list[slider_count++], 500, (defxscale == 0) ? 1000 : defxscale, 1500, 2, slider_xscale, param); | |
| 1604 | slider_config(&slider_list[slider_count++], -500, defxoffset, 500, 2, slider_xoffset, param); | |
| 1605 | slider_config(&slider_list[slider_count++], 500, (defyscale == 0) ? 1000 : defyscale, 1500, 2, slider_yscale, param); | |
| 1606 | slider_config(&slider_list[slider_count++], -500, defyoffset, 500, 2, slider_yoffset, param); | |
| 1600 | 1607 | } |
| 1601 | 1608 | |
| 1602 | 1609 | for (device = video_screen_first(machine->config); device != NULL; device = video_screen_next(device)) |
| r2724 | r2725 | |
| 1605 | 1612 | if (scrconfig->type == SCREEN_TYPE_VECTOR) |
| 1606 | 1613 | { |
| 1607 | 1614 | /* add flicker control */ |
| 1608 | slider_config(&slider_list[slider_count++], 0, 0, 1000, 10, slider_flicker, 0); | |
| 1609 | slider_config(&slider_list[slider_count++], 10, 100, 1000, 10, slider_beam, 0); | |
| 1615 | slider_config(&slider_list[slider_count++], 0, 0, 1000, 10, slider_flicker, NULL); | |
| 1616 | slider_config(&slider_list[slider_count++], 10, 100, 1000, 10, slider_beam, NULL); | |
| 1610 | 1617 | break; |
| 1611 | 1618 | } |
| 1612 | 1619 | } |
| 1613 | 1620 | |
| 1614 | 1621 | #ifdef MAME_DEBUG |
| 1615 | 1622 | /* add crosshair adjusters */ |
| 1616 | for (in = machine->input_ports; in && in->type != IPT_END; in++) | |
| 1617 | if (in->analog.crossaxis != CROSSHAIR_AXIS_NONE && in->player == 0) | |
| 1618 | { | |
| 1619 | slider_config(&slider_list[slider_count++], -3000, 1000, 3000, 100, slider_crossscale, in->analog.crossaxis); | |
| 1620 | slider_config(&slider_list[slider_count++], -3000, 0, 3000, 100, slider_crossoffset, in->analog.crossaxis); | |
| 1621 | } | |
| 1623 | for (port = machine->portconfig; port != NULL; port = port->next) | |
| 1624 | for (field = port->fieldlist; field != NULL; field = field->next) | |
| 1625 | if (field->crossaxis != CROSSHAIR_AXIS_NONE && field->player == 0) | |
| 1626 | { | |
| 1627 | void *param = (void *)field; | |
| 1628 | slider_config(&slider_list[slider_count++], -3000, 1000, 3000, 100, slider_crossscale, param); | |
| 1629 | slider_config(&slider_list[slider_count++], -3000, 0, 3000, 100, slider_crossoffset, param); | |
| 1630 | } | |
| 1622 | 1631 | #endif |
| 1623 | 1632 | } |
| 1624 | 1633 | |
| r2724 | r2725 | |
| 1693 | 1702 | slider_volume - global volume slider callback |
| 1694 | 1703 | -------------------------------------------------*/ |
| 1695 | 1704 | |
| 1696 | static INT32 slider_volume(running_machine *machine, INT32 newval, char *buffer, i | |
| 1705 | static INT32 slider_volume(running_machine *machine, INT32 newval, char *buffer, void | |
| 1697 | 1706 | { |
| 1698 | 1707 | if (buffer != NULL) |
| 1699 | 1708 | { |
| r2724 | r2725 | |
| 1709 | 1718 | slider callback |
| 1710 | 1719 | -------------------------------------------------*/ |
| 1711 | 1720 | |
| 1712 | static INT32 slider_mixervol(running_machine *machine, INT32 newval, char *buffer, i | |
| 1721 | static INT32 slider_mixervol(running_machine *machine, INT32 newval, char *buffer, void | |
| 1713 | 1722 | { |
| 1723 | int which = (FPTR)arg; | |
| 1714 | 1724 | if (buffer != NULL) |
| 1715 | 1725 | { |
| 1716 | sound_set_user_gain(arg, (float)newval * 0.001f); | |
| 1717 | sprintf(buffer, "%s Volume %4.2f", sound_get_user_gain_name(arg), sound_get_user_gain(arg)); | |
| 1726 | sound_set_user_gain(which, (float)newval * 0.001f); | |
| 1727 | sprintf(buffer, "%s Volume %4.2f", sound_get_user_gain_name(which), sound_get_user_gain(which)); | |
| 1718 | 1728 | } |
| 1719 | return floor(sound_get_user_gain( | |
| 1729 | return floor(sound_get_user_gain(which) * 1000.0f + 0.5f); | |
| 1720 | 1730 | } |
| 1721 | 1731 | |
| 1722 | 1732 | |
| r2724 | r2725 | |
| 1725 | 1735 | callback |
| 1726 | 1736 | -------------------------------------------------*/ |
| 1727 | 1737 | |
| 1728 | static INT32 slider_adjuster(running_machine *machine, INT32 newval, char *buffer, i | |
| 1738 | static INT32 slider_adjuster(running_machine *machine, INT32 newval, char *buffer, void | |
| 1729 | 1739 | { |
| 1730 | input_port_entry *in = &machine->input_ports[arg]; | |
| 1740 | const input_field_config *field = arg; | |
| 1741 | input_field_user_settings settings; | |
| 1742 | ||
| 1743 | input_field_get_user_settings(field, &settings); | |
| 1731 | 1744 | if (buffer != NULL) |
| 1732 | 1745 | { |
| 1733 | in->default_value = (in->default_value & ~0xff) | (newval & 0xff); | |
| 1734 | sprintf(buffer, "%s %d%%", in->name, in->default_value & 0xff); | |
| 1746 | settings.value = newval; | |
| 1747 | input_field_set_user_settings(field, &settings); | |
| 1748 | sprintf(buffer, "%s %d%%", field->name, settings.value); | |
| 1735 | 1749 | } |
| 1736 | return | |
| 1750 | return s | |
| 1737 | 1751 | } |
| 1738 | 1752 | |
| 1739 | 1753 | |
| r2724 | r2725 | |
| 1742 | 1756 | callback |
| 1743 | 1757 | -------------------------------------------------*/ |
| 1744 | 1758 | |
| 1745 | static INT32 slider_overclock(running_machine *machine, INT32 newval, char *buffer, i | |
| 1759 | static INT32 slider_overclock(running_machine *machine, INT32 newval, char *buffer, void | |
| 1746 | 1760 | { |
| 1761 | int which = (FPTR)arg; | |
| 1747 | 1762 | if (buffer != NULL) |
| 1748 | 1763 | { |
| 1749 | cpunum_set_clockscale(machine, arg, (float)newval * 0.001f); | |
| 1750 | sprintf(buffer, "Overclock CPU %d %3.0f%%", arg, floor(cpunum_get_clockscale(arg) * 100.0f + 0.5f)); | |
| 1764 | cpunum_set_clockscale(machine, which, (float)newval * 0.001f); | |
| 1765 | sprintf(buffer, "Overclock CPU %d %3.0f%%", which, floor(cpunum_get_clockscale(which) * 100.0f + 0.5f)); | |
| 1751 | 1766 | } |
| 1752 | return floor(cpunum_get_clockscale( | |
| 1767 | return floor(cpunum_get_clockscale(which) * 1000.0f + 0.5f); | |
| 1753 | 1768 | } |
| 1754 | 1769 | |
| 1755 | 1770 | |
| r2724 | r2725 | |
| 1757 | 1772 | slider_refresh - refresh rate slider callback |
| 1758 | 1773 | -------------------------------------------------*/ |
| 1759 | 1774 | |
| 1760 | static INT32 slider_refresh(running_machine *machine, INT32 newval, char *buffer, i | |
| 1775 | static INT32 slider_refresh(running_machine *machine, INT32 newval, char *buffer, void | |
| 1761 | 1776 | { |
| 1762 | const screen_config *scrconfig = device_list_find_by_index(machine->config->devicelist, VIDEO_SCREEN, arg)->inline_config; | |
| 1777 | const device_config *screen = arg; | |
| 1778 | const screen_config *scrconfig = screen->inline_config; | |
| 1763 | 1779 | double defrefresh = ATTOSECONDS_TO_HZ(scrconfig->refresh); |
| 1764 | 1780 | double refresh; |
| 1765 | 1781 | |
| 1766 | 1782 | if (buffer != NULL) |
| 1767 | 1783 | { |
| 1768 | const device_config *screen = device_list_find_by_index(machine->config->devicelist, VIDEO_SCREEN, arg); | |
| 1769 | 1784 | int width = video_screen_get_width(screen); |
| 1770 | 1785 | int height = video_screen_get_height(screen); |
| 1771 | 1786 | const rectangle *visarea = video_screen_get_visible_area(screen); |
| r2724 | r2725 | |
| 1783 | 1798 | callback |
| 1784 | 1799 | -------------------------------------------------*/ |
| 1785 | 1800 | |
| 1786 | static INT32 slider_brightness(running_machine *machine, INT32 newval, char *buffer, i | |
| 1801 | static INT32 slider_brightness(running_machine *machine, INT32 newval, char *buffer, void | |
| 1787 | 1802 | { |
| 1788 | const device_config *screen = | |
| 1803 | const device_config *screen = | |
| 1789 | 1804 | render_container *container = render_container_get_screen(screen); |
| 1790 | 1805 | if (buffer != NULL) |
| 1791 | 1806 | { |
| r2724 | r2725 | |
| 1801 | 1816 | callback |
| 1802 | 1817 | -------------------------------------------------*/ |
| 1803 | 1818 | |
| 1804 | static INT32 slider_contrast(running_machine *machine, INT32 newval, char *buffer, i | |
| 1819 | static INT32 slider_contrast(running_machine *machine, INT32 newval, char *buffer, void | |
| 1805 | 1820 | { |
| 1806 | const device_config *screen = | |
| 1821 | const device_config *screen = | |
| 1807 | 1822 | render_container *container = render_container_get_screen(screen); |
| 1808 | 1823 | if (buffer != NULL) |
| 1809 | 1824 | { |
| r2724 | r2725 | |
| 1818 | 1833 | slider_gamma - screen gamma slider callback |
| 1819 | 1834 | -------------------------------------------------*/ |
| 1820 | 1835 | |
| 1821 | static INT32 slider_gamma(running_machine *machine, INT32 newval, char *buffer, i | |
| 1836 | static INT32 slider_gamma(running_machine *machine, INT32 newval, char *buffer, void | |
| 1822 | 1837 | { |
| 1823 | const device_config *screen = | |
| 1838 | const device_config *screen = | |
| 1824 | 1839 | render_container *container = render_container_get_screen(screen); |
| 1825 | 1840 | if (buffer != NULL) |
| 1826 | 1841 | { |
| r2724 | r2725 | |
| 1836 | 1851 | callback |
| 1837 | 1852 | -------------------------------------------------*/ |
| 1838 | 1853 | |
| 1839 | static INT32 slider_xscale(running_machine *machine, INT32 newval, char *buffer, i | |
| 1854 | static INT32 slider_xscale(running_machine *machine, INT32 newval, char *buffer, void | |
| 1840 | 1855 | { |
| 1841 | const device_config *screen = | |
| 1856 | const device_config *screen = | |
| 1842 | 1857 | render_container *container = render_container_get_screen(screen); |
| 1843 | 1858 | if (buffer != NULL) |
| 1844 | 1859 | { |
| r2724 | r2725 | |
| 1854 | 1869 | callback |
| 1855 | 1870 | -------------------------------------------------*/ |
| 1856 | 1871 | |
| 1857 | static INT32 slider_yscale(running_machine *machine, INT32 newval, char *buffer, i | |
| 1872 | static INT32 slider_yscale(running_machine *machine, INT32 newval, char *buffer, void | |
| 1858 | 1873 | { |
| 1859 | const device_config *screen = | |
| 1874 | const device_config *screen = | |
| 1860 | 1875 | render_container *container = render_container_get_screen(screen); |
| 1861 | 1876 | if (buffer != NULL) |
| 1862 | 1877 | { |
| r2724 | r2725 | |
| 1872 | 1887 | slider callback |
| 1873 | 1888 | -------------------------------------------------*/ |
| 1874 | 1889 | |
| 1875 | static INT32 slider_xoffset(running_machine *machine, INT32 newval, char *buffer, i | |
| 1890 | static INT32 slider_xoffset(running_machine *machine, INT32 newval, char *buffer, void | |
| 1876 | 1891 | { |
| 1877 | const device_config *screen = | |
| 1892 | const device_config *screen = | |
| 1878 | 1893 | render_container *container = render_container_get_screen(screen); |
| 1879 | 1894 | if (buffer != NULL) |
| 1880 | 1895 | { |
| r2724 | r2725 | |
| 1890 | 1905 | slider callback |
| 1891 | 1906 | -------------------------------------------------*/ |
| 1892 | 1907 | |
| 1893 | static INT32 slider_yoffset(running_machine *machine, INT32 newval, char *buffer, i | |
| 1908 | static INT32 slider_yoffset(running_machine *machine, INT32 newval, char *buffer, void | |
| 1894 | 1909 | { |
| 1895 | const device_config *screen = | |
| 1910 | const device_config *screen = | |
| 1896 | 1911 | render_container *container = render_container_get_screen(screen); |
| 1897 | 1912 | if (buffer != NULL) |
| 1898 | 1913 | { |
| r2724 | r2725 | |
| 1908 | 1923 | callback |
| 1909 | 1924 | -------------------------------------------------*/ |
| 1910 | 1925 | |
| 1911 | static INT32 slider_flicker(running_machine *machine, INT32 newval, char *buffer, i | |
| 1926 | static INT32 slider_flicker(running_machine *machine, INT32 newval, char *buffer, void | |
| 1912 | 1927 | { |
| 1913 | 1928 | if (buffer != NULL) |
| 1914 | 1929 | { |
| r2724 | r2725 | |
| 1924 | 1939 | callback |
| 1925 | 1940 | -------------------------------------------------*/ |
| 1926 | 1941 | |
| 1927 | static INT32 slider_beam(running_machine *machine, INT32 newval, char *buffer, i | |
| 1942 | static INT32 slider_beam(running_machine *machine, INT32 newval, char *buffer, void | |
| 1928 | 1943 | { |
| 1929 | 1944 | if (buffer != NULL) |
| 1930 | 1945 | { |
| r2724 | r2725 | |
| 1960 | 1975 | -------------------------------------------------*/ |
| 1961 | 1976 | |
| 1962 | 1977 | #ifdef MAME_DEBUG |
| 1963 | static INT32 slider_crossscale(running_machine *machine, INT32 newval, char *buffer, i | |
| 1978 | static INT32 slider_crossscale(running_machine *machine, INT32 newval, char *buffer, void | |
| 1964 | 1979 | { |
| 1965 | input_ | |
| 1980 | input_fi | |
| 1966 | 1981 | |
| 1967 | 1982 | if (buffer != NULL) |
| 1968 | 1983 | { |
| 1969 | for (in = machine->input_ports; in && in->type != IPT_END; in++) | |
| 1970 | if (in->analog.crossaxis == arg) | |
| 1971 | { | |
| 1972 | in->analog.crossscale = (float)newval * 0.001f; | |
| 1973 | break; | |
| 1974 | } | |
| 1975 | sprintf(buffer, "%s %s %1.3f", "Crosshair Scale", (in->analog.crossaxis == CROSSHAIR_AXIS_X) ? "X" : "Y", (float)newval * 0.001f); | |
| 1984 | field->crossscale = (float)newval * 0.001f; | |
| 1985 | sprintf(buffer, "%s %s %1.3f", "Crosshair Scale", (field->crossaxis == CROSSHAIR_AXIS_X) ? "X" : "Y", (float)newval * 0.001f); | |
| 1976 | 1986 | } |
| 1977 | for (in = machine->input_ports; in && in->type != IPT_END; in++) | |
| 1978 | if (in->analog.crossaxis == arg) | |
| 1979 | return floor(in->analog.crossscale * 1000.0f + 0.5f); | |
| 1980 | return 0; | |
| 1987 | return floor(field->crossscale * 1000.0f + 0.5f); | |
| 1981 | 1988 | } |
| 1982 | 1989 | #endif |
| 1983 | 1990 | |
| r2724 | r2725 | |
| 1988 | 1995 | -------------------------------------------------*/ |
| 1989 | 1996 | |
| 1990 | 1997 | #ifdef MAME_DEBUG |
| 1991 | static INT32 slider_crossoffset(running_machine *machine, INT32 newval, char *buffer, i | |
| 1998 | static INT32 slider_crossoffset(running_machine *machine, INT32 newval, char *buffer, void | |
| 1992 | 1999 | { |
| 1993 | input_ | |
| 2000 | input_fi | |
| 1994 | 2001 | |
| 1995 | 2002 | if (buffer != NULL) |
| 1996 | 2003 | { |
| 1997 | for (in = machine->input_ports; in && in->type != IPT_END; in++) | |
| 1998 | if (in->analog.crossaxis == arg) | |
| 1999 | { | |
| 2000 | in->analog.crossoffset = (float)newval * 0.001f; | |
| 2001 | break; | |
| 2002 | } | |
| 2003 | sprintf(buffer, "%s %s %1.3f", "Crosshair Offset", (in->analog.crossaxis == CROSSHAIR_AXIS_X) ? "X" : "Y", (float)newval * 0.001f); | |
| 2004 | field->crossoffset = (float)newval * 0.001f; | |
| 2005 | sprintf(buffer, "%s %s %1.3f", "Crosshair Offset", (field->crossaxis == CROSSHAIR_AXIS_X) ? "X" : "Y", (float)newval * 0.001f); | |
| 2004 | 2006 | } |
| 2005 | for (in = machine->input_ports; in && in->type != IPT_END; in++) | |
| 2006 | if (in->analog.crossaxis == arg) | |
| 2007 | return floor(in->analog.crossoffset * 1000.0f + 0.5f); | |
| 2008 | return 0; | |
| 2007 | return field->crossoffset; | |
| 2009 | 2008 | } |
| 2010 | 2009 | #endif |
| r2724 | r2725 | |
|---|---|---|
| 182 | 182 | |
| 183 | 183 | void crosshair_init(running_machine *machine) |
| 184 | 184 | { |
| 185 | input_port_entry *ipt; | |
| 185 | const input_port_config *port; | |
| 186 | const input_field_config *field; | |
| 186 | 187 | |
| 187 | 188 | /* request a callback upon exiting */ |
| 188 | 189 | add_exit_callback(machine, crosshair_exit); |
| r2724 | r2725 | |
| 191 | 192 | memset(&global, 0, sizeof(global)); |
| 192 | 193 | |
| 193 | 194 | /* determine who needs crosshairs */ |
| 194 | for (ipt = machine->input_ports; ipt->type != IPT_END; ipt++) | |
| 195 | if (ipt->analog.crossaxis != CROSSHAIR_AXIS_NONE) | |
| 196 | { | |
| 197 | int player = ipt->player; | |
| 195 | for (port = machine->portconfig; port != NULL; port = port->next) | |
| 196 | for (field = port->fieldlist; field != NULL; field = field->next) | |
| 197 | if (field->crossaxis != CROSSHAIR_AXIS_NONE) | |
| 198 | { | |
| 199 | int player = field->player; | |
| 198 | 200 | |
| 199 | assert(player < MAX_PLAYERS); | |
| 201 | assert(player < MAX_PLAYERS); | |
| 200 | 202 | |
| 201 | /* mark as used and visible */ | |
| 202 | global.used[player] = TRUE; | |
| 203 | global.visible[player] = TRUE; | |
| 203 | /* mark as used and visible */ | |
| 204 | global.used[player] = TRUE; | |
| 205 | global.visible[player] = TRUE; | |
| 204 | 206 | |
| 205 | /* for now, use the main screen */ | |
| 206 | global.screen[player] = machine->primary_screen; | |
| 207 | /* for now, use the main screen */ | |
| 208 | global.screen[player] = machine->primary_screen; | |
| 207 | 209 | |
| 208 | create_bitmap(player); | |
| 209 | } | |
| 210 | create_bitmap(player); | |
| 211 | } | |
| 210 | 212 | |
| 211 | 213 | /* register the animation callback */ |
| 212 | 214 | if (machine->primary_screen != NULL) |
| r2724 | r2725 | |
| 272 | 274 | |
| 273 | 275 | static void animate(const device_config *device, int vblank_state) |
| 274 | 276 | { |
| 275 | input_port_entry *ipt; | |
| 276 | int portnum = -1; | |
| 277 | int player; | |
| 277 | 278 | |
| 278 | 279 | /* increment animation counter */ |
| 279 | 280 | global.animation_counter += 0x04; |
| r2724 | r2725 | |
| 285 | 286 | global.fade = 0xa0 + (0x60 * (~global.animation_counter & 0x7f) / 0x80); |
| 286 | 287 | |
| 287 | 288 | /* read all the lightgun values */ |
| 288 | for (ipt = device->machine->input_ports; ipt->type != IPT_END; ipt++) | |
| 289 | { | |
| 290 | /* keep track of the port number */ | |
| 291 | if (ipt->type == IPT_PORT) | |
| 292 | portnum++; | |
| 293 | ||
| 294 | /* compute the values */ | |
| 295 | if (ipt->analog.crossaxis != CROSSHAIR_AXIS_NONE) | |
| 296 | { | |
| 297 | float value = (float)(get_crosshair_pos(portnum, ipt->player, ipt->analog.crossaxis) - ipt->analog.min) / (float)(ipt->analog.max - ipt->analog.min); | |
| 298 | if (ipt->analog.crossscale < 0) | |
| 299 | value = -(1.0 - value) * ipt->analog.crossscale; | |
| 300 | else | |
| 301 | value *= ipt->analog.crossscale; | |
| 302 | value += ipt->analog.crossoffset; | |
| 303 | ||
| 304 | /* switch off the axis */ | |
| 305 | switch (ipt->analog.crossaxis) | |
| 306 | { | |
| 307 | case CROSSHAIR_AXIS_X: | |
| 308 | global.x[ipt->player] = value; | |
| 309 | if (ipt->analog.crossaltaxis != 0) | |
| 310 | global.y[ipt->player] = ipt->analog.crossaltaxis; | |
| 311 | break; | |
| 312 | ||
| 313 | case CROSSHAIR_AXIS_Y: | |
| 314 | global.y[ipt->player] = value; | |
| 315 | if (ipt->analog.crossaltaxis != 0) | |
| 316 | global.x[ipt->player] = ipt->analog.crossaltaxis; | |
| 317 | break; | |
| 318 | } | |
| 319 | } | |
| 320 | } | |
| 289 | for (player = 0; player < MAX_PLAYERS; player++) | |
| 290 | if (global.used[player]) | |
| 291 | input_port_get_crosshair_position(device->machine, player, &global.x[player], &global.y[player]); | |
| 321 | 292 | } |
| 322 | 293 | |
| 323 | 294 |
| r2724 | r2725 | |
|---|---|---|
| 114 | 114 | static void sound_reset(running_machine *machine); |
| 115 | 115 | static void sound_exit(running_machine *machine); |
| 116 | 116 | static void sound_pause(running_machine *machine, int pause); |
| 117 | static void sound_load(int config_type, xml_data_node *parentnode); | |
| 118 | static void sound_save(int config_type, xml_data_node *parentnode); | |
| 117 | static void sound_load(running_machine *machine, int config_type, xml_data_node *parentnode); | |
| 118 | static void sound_save(running_machine *machine, int config_type, xml_data_node *parentnode); | |
| 119 | 119 | static TIMER_CALLBACK( sound_update ); |
| 120 | 120 | static void start_sound_chips(void); |
| 121 | 121 | static void route_sound(void); |
| 122 | 122 | static void mixer_update(void *param, stream_sample_t **inputs, stream_sample_t **buffer, int length); |
| 123 | static STATE_POSTLOAD( mixer_postload ); | |
| 123 | 124 | |
| 124 | 125 | |
| 125 | 126 | |
| r2724 | r2725 | |
| 223 | 224 | sound_set_attenuation(options_get_int(mame_options(), OPTION_VOLUME)); |
| 224 | 225 | |
| 225 | 226 | /* register callbacks */ |
| 226 | config_register("mixer", sound_load, sound_save); | |
| 227 | config_register(machine, "mixer", sound_load, sound_save); | |
| 227 | 228 | add_pause_callback(machine, sound_pause); |
| 228 | 229 | add_reset_callback(machine, sound_reset); |
| 229 | 230 | add_exit_callback(machine, sound_exit); |
| r2724 | r2725 | |
| 397 | 398 | if (info->inputs != 0) |
| 398 | 399 | { |
| 399 | 400 | info->mixer_stream = stream_create(info->inputs, 1, Machine->sample_rate, info, mixer_update); |
| 401 | state_save_register_postload(Machine, mixer_postload, info->mixer_stream); | |
| 400 | 402 | info->input = auto_malloc(info->inputs * sizeof(*info->input)); |
| 401 | 403 | info->inputs = 0; |
| 402 | 404 | } |
| r2724 | r2725 | |
| 577 | 579 | configuration file |
| 578 | 580 | -------------------------------------------------*/ |
| 579 | 581 | |
| 580 | static void sound_load(int config_type, xml_data_node *parentnode) | |
| 582 | static void sound_load(running_machine *machine, int config_type, xml_data_node *parentnode) | |
| 581 | 583 | { |
| 582 | 584 | xml_data_node *channelnode; |
| 583 | 585 | int mixernum; |
| r2724 | r2725 | |
| 610 | 612 | file |
| 611 | 613 | -------------------------------------------------*/ |
| 612 | 614 | |
| 613 | static void sound_save(int config_type, xml_data_node *parentnode) | |
| 615 | static void sound_save(running_machine *machine, int config_type, xml_data_node *parentnode) | |
| 614 | 616 | { |
| 615 | 617 | int mixernum; |
| 616 | 618 | |
| r2724 | r2725 | |
| 791 | 793 | } |
| 792 | 794 | |
| 793 | 795 | |
| 796 | /*------------------------------------------------- | |
| 797 | mixer_postload - postload function to reset | |
| 798 | the mixer stream to the proper sample rate | |
| 799 | -------------------------------------------------*/ | |
| 794 | 800 | |
| 801 | static STATE_POSTLOAD( mixer_postload ) | |
| 802 | { | |
| 803 | sound_stream *stream = param; | |
| 804 | stream_set_sample_rate(stream, machine->sample_rate); | |
| 805 | } | |
| 806 | ||
| 807 | ||
| 808 | ||
| 795 | 809 | /*************************************************************************** |
| 796 | 810 | SPEAKER OUTPUT DEVICE INTERFACE |
| 797 | 811 | ***************************************************************************/ |
| r2724 | r2725 | |
|---|---|---|
| 252 | 252 | |
| 253 | 253 | /* core system */ |
| 254 | 254 | static void render_exit(running_machine *machine); |
| 255 | static void render_load(int config_type, xml_data_node *parentnode); | |
| 256 | static void render_save(int config_type, xml_data_node *parentnode); | |
| 255 | static void render_load(running_machine *machine, int config_type, xml_data_node *parentnode); | |
| 256 | static void render_save(running_machine *machine, int config_type, xml_data_node *parentnode); | |
| 257 | 257 | |
| 258 | 258 | /* render targets */ |
| 259 | 259 | static void release_render_list(render_primitive_list *list); |
| r2724 | r2725 | |
| 537 | 537 | *current_container_ptr = NULL; |
| 538 | 538 | |
| 539 | 539 | /* register callbacks */ |
| 540 | config_register("video", render_load, render_save); | |
| 540 | config_register(machine, "video", render_load, render_save); | |
| 541 | 541 | } |
| 542 | 542 | |
| 543 | 543 | |
| r2724 | r2725 | |
| 615 | 615 | configuration file |
| 616 | 616 | -------------------------------------------------*/ |
| 617 | 617 | |
| 618 | static void render_load(int config_type, xml_data_node *parentnode) | |
| 618 | static void render_load(running_machine *machine, int config_type, xml_data_node *parentnode) | |
| 619 | 619 | { |
| 620 | 620 | xml_data_node *targetnode; |
| 621 | 621 | xml_data_node *screennode; |
| r2724 | r2725 | |
| 733 | 733 | file |
| 734 | 734 | -------------------------------------------------*/ |
| 735 | 735 | |
| 736 | static void render_save(int config_type, xml_data_node *parentnode) | |
| 736 | static void render_save(running_machine *machine, int config_type, xml_data_node *parentnode) | |
| 737 | 737 | { |
| 738 | 738 | render_target *target; |
| 739 | 739 | render_container *container; |
| r2724 | r2725 | |
|---|---|---|
| 751 | 751 | static int ControlKeyPressed(void); |
| 752 | 752 | static int AltKeyPressed(void); |
| 753 | 753 | |
| 754 | static int UIPressedRepeatThrottle(int code, int baseSpeed); | |
| 754 | static int UIPressedRepeatThrottle(running_machine *machine, int code, int baseSpeed); | |
| 755 | 755 | |
| 756 | 756 | /********** DIRECT KEY INPUT **********/ |
| 757 | 757 | static int ReadHexInput(void); |
| 758 | 758 | |
| 759 | 759 | static char * DoDynamicEditTextField(char * buf); |
| 760 | 760 | static void DoStaticEditTextField(char * buf, int size); |
| 761 | static UINT32 DoEditHexField(UINT32 data); | |
| 761 | static UINT32 DoEditHexField(running_machine *machine, UINT32 data); | |
| 762 | 762 | static UINT32 DoEditHexFieldSigned(UINT32 data, UINT32 mask); |
| 763 | 763 | static INT32 DoEditDecField(INT32 data, INT32 min, INT32 max); |
| 764 | 764 | |
| r2724 | r2725 | |
| 777 | 777 | static char * CreateStringCopy(char * buf); |
| 778 | 778 | |
| 779 | 779 | /********** ADDITIONAL MENU FOR CHEAT **********/ |
| 780 | static INT32 UserSelectValueMenu(int selection, CheatEntry * entry); | |
| 780 | static INT32 UserSelectValueMenu(running_machine *machine, int selection, CheatEntry * entry); | |
| 781 | 781 | |
| 782 | 782 | /********** CHEAT MENU **********/ |
| 783 | 783 | static int EnableDisableCheatMenu(running_machine *machine, int selection, int firstTime); |
| r2724 | r2725 | |
| 788 | 788 | static int DoSearchMenuClassic(running_machine *machine, int selection); // classic mode |
| 789 | 789 | static int DoSearchMenu(running_machine *machine, int selection); // advanced mode |
| 790 | 790 | static int SelectSearchRegions(running_machine *machine, int selection, SearchInfo * search); |
| 791 | static int ViewSearchResults(int selection, int firstTime); | |
| 791 | static int ViewSearchResults(running_machine *machine, int selection, int firstTime); | |
| 792 | 792 | |
| 793 | 793 | static int ChooseWatch(running_machine *machine, int selection); |
| 794 | 794 | static int EditWatch(running_machine *machine, WatchInfo * entry, int selection); |
| r2724 | r2725 | |
| 1187 | 1187 | UIPressedRepoeatThrottle - key repeat handling |
| 1188 | 1188 | -------------------------------------------------*/ |
| 1189 | 1189 | |
| 1190 | static int UIPressedRepeatThrottle(int code, int baseSpeed) | |
| 1190 | static int UIPressedRepeatThrottle(running_machine *machine, int code, int baseSpeed) | |
| 1191 | 1191 | { |
| 1192 | 1192 | static int lastCode = -1; |
| 1193 | 1193 | static int lastSpeed = -1; |
| r2724 | r2725 | |
| 1196 | 1196 | |
| 1197 | 1197 | const int kDelayRampTimer = 10; |
| 1198 | 1198 | |
| 1199 | if(input_ | |
| 1199 | if(input_ | |
| 1200 | 1200 | { |
| 1201 | 1201 | if(lastCode != code) // different key pressed |
| 1202 | 1202 | { |
| r2724 | r2725 | |
| 1227 | 1227 | lastCode = -1; |
| 1228 | 1228 | } |
| 1229 | 1229 | |
| 1230 | return input_ui_pressed_repeat(code, lastSpeed); | |
| 1230 | return input_ui_pressed_repeat(machine, code, lastSpeed); | |
| 1231 | 1231 | } |
| 1232 | 1232 | |
| 1233 | 1233 | /*--------------------------------- |
| r2724 | r2725 | |
| 1350 | 1350 | DoEditHexField - edit hex field with direct key input (unsigned) |
| 1351 | 1351 | ------------------------------------------------------------------*/ |
| 1352 | 1352 | |
| 1353 | static UINT32 DoEditHexField(UINT32 data) | |
| 1353 | static UINT32 DoEditHexField(running_machine *machine, UINT32 data) | |
| 1354 | 1354 | { |
| 1355 | 1355 | INT8 key; |
| 1356 | 1356 | |
| r2724 | r2725 | |
| 1363 | 1363 | } |
| 1364 | 1364 | else |
| 1365 | 1365 | { |
| 1366 | if(input_ui_pressed(IPT_UI_CLEAR)) | |
| 1366 | if(input_ui_pressed(machine, IPT_UI_CLEAR)) | |
| 1367 | 1367 | { |
| 1368 | 1368 | data = 0; |
| 1369 | 1369 | |
| r2724 | r2725 | |
| 1713 | 1713 | ui_menu_draw(menu_item, total, sel, NULL); |
| 1714 | 1714 | |
| 1715 | 1715 | /********** KEY HANDLING **********/ |
| 1716 | if(UIPressedRepeatThrottle(IPT_UI_DOWN, kVerticalKeyRepeatRate)) | |
| 1716 | if(UIPressedRepeatThrottle(machine, IPT_UI_DOWN, kVerticalKeyRepeatRate)) | |
| 1717 | 1717 | { |
| 1718 | 1718 | if(sel < (total - 1)) |
| 1719 | 1719 | sel++; |
| r2724 | r2725 | |
| 1721 | 1721 | sel = 0; |
| 1722 | 1722 | } |
| 1723 | 1723 | |
| 1724 | if(UIPressedRepeatThrottle(IPT_UI_UP, kVerticalKeyRepeatRate)) | |
| 1724 | if(UIPressedRepeatThrottle(machine, IPT_UI_UP, kVerticalKeyRepeatRate)) | |
| 1725 | 1725 | { |
| 1726 | 1726 | if(sel > 0) |
| 1727 | 1727 | sel--; |
| r2724 | r2725 | |
| 1729 | 1729 | sel = total - 1; |
| 1730 | 1730 | } |
| 1731 | 1731 | |
| 1732 | if(input_ui_pressed(IPT_UI_SELECT)) | |
| 1732 | if(input_ui_pressed(machine, IPT_UI_SELECT)) | |
| 1733 | 1733 | { |
| 1734 | 1734 | switch(sel) |
| 1735 | 1735 | { |
| r2724 | r2725 | |
| 1750 | 1750 | } |
| 1751 | 1751 | } |
| 1752 | 1752 | |
| 1753 | if(input_ui_pressed(IPT_UI_RELOAD_CHEAT)) | |
| 1753 | if(input_ui_pressed(machine, IPT_UI_RELOAD_CHEAT)) | |
| 1754 | 1754 | ReloadCheatDatabase(machine); |
| 1755 | 1755 | |
| 1756 | if(input_ui_pressed(IPT_UI_CANCEL)) | |
| 1756 | if(input_ui_pressed(machine, IPT_UI_CANCEL)) | |
| 1757 | 1757 | { |
| 1758 | 1758 | if(sel == kMenu_Return) |
| 1759 | 1759 | lastPstn = 0; // if cursor is now on the return item, adjust cursor keeper |
| r2724 | r2725 | |
| 1973 | 1973 | UserSelectValueMenu - management for value-selection menu |
| 1974 | 1974 | ------------------------------------------------------------*/ |
| 1975 | 1975 | |
| 1976 | static INT32 UserSelectValueMenu(int selection, CheatEntry * entry) | |
| 1976 | static INT32 UserSelectValueMenu(running_machine *machine, int selection, CheatEntry * entry) | |
| 1977 | 1977 | { |
| 1978 | 1978 | char buf[2048]; |
| 1979 | 1979 | int sel; |
| r2724 | r2725 | |
| 2040 | 2040 | ui_draw_message_window(buf); |
| 2041 | 2041 | |
| 2042 | 2042 | /********** KEY HANDLING **********/ |
| 2043 | if(UIPressedRepeatThrottle(IPT_UI_LEFT, kHorizontalFastKeyRepeatRate)) | |
| 2043 | if(UIPressedRepeatThrottle(machine, IPT_UI_LEFT, kHorizontalFastKeyRepeatRate)) | |
| 2044 | 2044 | delta = -1; |
| 2045 | 2045 | |
| 2046 | if(UIPressedRepeatThrottle(IPT_UI_RIGHT, kHorizontalFastKeyRepeatRate)) | |
| 2046 | if(UIPressedRepeatThrottle(machine, IPT_UI_RIGHT, kHorizontalFastKeyRepeatRate)) | |
| 2047 | 2047 | delta = 1; |
| 2048 | 2048 | |
| 2049 | if(input_ui_pressed(IPT_UI_SELECT)) | |
| 2049 | if(input_ui_pressed(machine, IPT_UI_SELECT)) | |
| 2050 | 2050 | { |
| 2051 | 2051 | /* ### redundant?? probably can be removed ### */ |
| 2052 | 2052 | if(!firstTime) |
| r2724 | r2725 | |
| 2093 | 2093 | sel = -1; |
| 2094 | 2094 | } |
| 2095 | 2095 | |
| 2096 | if(input_ui_pressed(IPT_UI_CANCEL)) | |
| 2096 | if(input_ui_pressed(machine, IPT_UI_CANCEL)) | |
| 2097 | 2097 | { |
| 2098 | 2098 | firstTime = 1; |
| 2099 | 2099 | sel = -1; |
| r2724 | r2725 | |
| 2161 | 2161 | CommentMenu - management comment for code menu |
| 2162 | 2162 | -------------------------------------------------*/ |
| 2163 | 2163 | |
| 2164 | static INT32 CommentMenu(int selection, CheatEntry * entry) | |
| 2164 | static INT32 CommentMenu(running_machine *machine, int selection, CheatEntry * entry) | |
| 2165 | 2165 | { |
| 2166 | 2166 | char buf[2048]; |
| 2167 | 2167 | int sel; |
| r2724 | r2725 | |
| 2184 | 2184 | ui_draw_message_window(buf); |
| 2185 | 2185 | |
| 2186 | 2186 | /********** KEY HANDLING **********/ |
| 2187 | if(input_ui_pressed(IPT_UI_SELECT) || input_ui_pressed(IPT_UI_CANCEL)) | |
| 2187 | if(input_ui_pressed(machine, IPT_UI_SELECT) || input_ui_pressed(machine, IPT_UI_CANCEL)) | |
| 2188 | 2188 | sel = -1; |
| 2189 | 2189 | |
| 2190 | 2190 | return sel + 1; |
| r2724 | r2725 | |
| 2221 | 2221 | switch(submenu_id) |
| 2222 | 2222 | { |
| 2223 | 2223 | case 1: |
| 2224 | submenu_choice = CommentMenu(submenu_choice, &cheatList[sel]); | |
| 2224 | submenu_choice = CommentMenu(machine, submenu_choice, &cheatList[sel]); | |
| 2225 | 2225 | break; |
| 2226 | 2226 | |
| 2227 | 2227 | case 2: |
| 2228 | submenu_choice = UserSelectValueMenu(submenu_choice, &cheatList[sel]); | |
| 2228 | submenu_choice = UserSelectValueMenu(machine, submenu_choice, &cheatList[sel]); | |
| 2229 | 2229 | break; |
| 2230 | 2230 | |
| 2231 | 2231 | case 3: |
| r2724 | r2725 | |
| 2343 | 2343 | old_style_menu(menu_item, menu_subitem, flagBuf, sel, 0); |
| 2344 | 2344 | |
| 2345 | 2345 | /********** KEY HANDLING **********/ |
| 2346 | if(UIPressedRepeatThrottle(IPT_UI_DOWN, kVerticalKeyRepeatRate)) | |
| 2346 | if(UIPressedRepeatThrottle(machine, IPT_UI_DOWN, kVerticalKeyRepeatRate)) | |
| 2347 | 2347 | { |
| 2348 | 2348 | sel++; |
| 2349 | 2349 | |
| r2724 | r2725 | |
| 2358 | 2358 | } |
| 2359 | 2359 | } |
| 2360 | 2360 | |
| 2361 | if(UIPressedRepeatThrottle(IPT_UI_UP, kVerticalKeyRepeatRate)) | |
| 2361 | if(UIPressedRepeatThrottle(machine, IPT_UI_UP, kVerticalKeyRepeatRate)) | |
| 2362 | 2362 | { |
| 2363 | 2363 | sel--; |
| 2364 | 2364 | |
| r2724 | r2725 | |
| 2380 | 2380 | } |
| 2381 | 2381 | } |
| 2382 | 2382 | |
| 2383 | if(UIPressedRepeatThrottle(IPT_UI_PAGE_UP, kVerticalKeyRepeatRate)) | |
| 2383 | if(UIPressedRepeatThrottle(machine, IPT_UI_PAGE_UP, kVerticalKeyRepeatRate)) | |
| 2384 | 2384 | { |
| 2385 | 2385 | sel -= fullMenuPageHeight; |
| 2386 | 2386 | |
| r2724 | r2725 | |
| 2388 | 2388 | sel = 0; |
| 2389 | 2389 | } |
| 2390 | 2390 | |
| 2391 | if(UIPressedRepeatThrottle(IPT_UI_PAGE_DOWN, kVerticalKeyRepeatRate)) | |
| 2391 | if(UIPressedRepeatThrottle(machine, IPT_UI_PAGE_DOWN, kVerticalKeyRepeatRate)) | |
| 2392 | 2392 | { |
| 2393 | 2393 | sel += fullMenuPageHeight; |
| 2394 | 2394 | |
| r2724 | r2725 | |
| 2401 | 2401 | else |
| 2402 | 2402 | entry = NULL; |
| 2403 | 2403 | |
| 2404 | if(UIPressedRepeatThrottle(IPT_UI_LEFT, kHorizontalSlowKeyRepeatRate)) | |
| 2404 | if(UIPressedRepeatThrottle(machine, IPT_UI_LEFT, kHorizontalSlowKeyRepeatRate)) | |
| 2405 | 2405 | { |
| 2406 | 2406 | if((sel < (total - 1)) && entry) |
| 2407 | 2407 | { |
| r2724 | r2725 | |
| 2460 | 2460 | } |
| 2461 | 2461 | } |
| 2462 | 2462 | |
| 2463 | if(UIPressedRepeatThrottle(IPT_UI_RIGHT, kHorizontalSlowKeyRepeatRate)) | |
| 2463 | if(UIPressedRepeatThrottle(machine, IPT_UI_RIGHT, kHorizontalSlowKeyRepeatRate)) | |
| 2464 | 2464 | { |
| 2465 | 2465 | if((sel < (total - 1)) && entry) |
| 2466 | 2466 | { |
| r2724 | r2725 | |
| 2524 | 2524 | } |
| 2525 | 2525 | } |
| 2526 | 2526 | |
| 2527 | if(input_ui_pressed(IPT_UI_SELECT)) | |
| 2527 | if(input_ui_pressed(machine, IPT_UI_SELECT)) | |
| 2528 | 2528 | { |
| 2529 | 2529 | if(sel == (total - 1)) |
| 2530 | 2530 | { |
| r2724 | r2725 | |
| 2574 | 2574 | } |
| 2575 | 2575 | } |
| 2576 | 2576 | |
| 2577 | if(input_ui_pressed(IPT_UI_WATCH_VALUE)) | |
| 2577 | if(input_ui_pressed(machine, IPT_UI_WATCH_VALUE)) | |
| 2578 | 2578 | WatchCheatEntry(entry, 0); |
| 2579 | 2579 | |
| 2580 | 2580 | if(ShiftKeyPressed()) |
| 2581 | 2581 | { |
| 2582 | if(input_ui_pressed(IPT_UI_SAVE_CHEAT)) // shift + save = save all codes | |
| 2582 | if(input_ui_pressed(machine, IPT_UI_SAVE_CHEAT)) // shift + save = save all codes | |
| 2583 | 2583 | { |
| 2584 | 2584 | for(i = 0; i < cheatListLength; i++) |
| 2585 | 2585 | SaveCheat(machine, &cheatList[i], 0, 0); |
| r2724 | r2725 | |
| 2587 | 2587 | ui_popup_time(1, "%d cheats saved", cheatListLength); |
| 2588 | 2588 | } |
| 2589 | 2589 | |
| 2590 | if(input_ui_pressed(IPT_UI_ADD_CHEAT)) // shift + add = add new emypty code | |
| 2590 | if(input_ui_pressed(machine, IPT_UI_ADD_CHEAT)) // shift + add = add new emypty code | |
| 2591 | 2591 | AddCheatBefore(sel); |
| 2592 | 2592 | |
| 2593 | if(input_ui_pressed(IPT_UI_DELETE_CHEAT)) // shift + delete = delete selected code | |
| 2593 | if(input_ui_pressed(machine, IPT_UI_DELETE_CHEAT)) // shift + delete = delete selected code | |
| 2594 | 2594 | DeleteCheatAt(sel); |
| 2595 | 2595 | } |
| 2596 | 2596 | else |
| 2597 | 2597 | { |
| 2598 | 2598 | if(ControlKeyPressed()) |
| 2599 | 2599 | { |
| 2600 | if(input_ui_pressed(IPT_UI_SAVE_CHEAT)) // ctrl + save = save activation key | |
| 2600 | if(input_ui_pressed(machine, IPT_UI_SAVE_CHEAT)) // ctrl + save = save activation key | |
| 2601 | 2601 | { |
| 2602 | 2602 | if((entry->flags & kCheatFlag_HasActivationKey1) || (entry->flags & kCheatFlag_HasActivationKey2)) |
| 2603 | 2603 | { |
| r2724 | r2725 | |
| 2611 | 2611 | } |
| 2612 | 2612 | else |
| 2613 | 2613 | { |
| 2614 | if(input_ui_pressed(IPT_UI_SAVE_CHEAT)) | |
| 2614 | if(input_ui_pressed(machine, IPT_UI_SAVE_CHEAT)) | |
| 2615 | 2615 | SaveCheat(machine, entry, 0, 0); // save current entry |
| 2616 | 2616 | } |
| 2617 | 2617 | } |
| 2618 | 2618 | |
| 2619 | if(input_ui_pressed(IPT_UI_EDIT_CHEAT) && entry) // edit selected code | |
| 2619 | if(input_ui_pressed(machine, IPT_UI_EDIT_CHEAT) && entry) // edit selected code | |
| 2620 | 2620 | { |
| 2621 | 2621 | submenu_id = 3; |
| 2622 | 2622 | submenu_choice = 1; |
| 2623 | 2623 | } |
| 2624 | 2624 | |
| 2625 | if(input_ui_pressed(IPT_UI_RELOAD_CHEAT)) | |
| 2625 | if(input_ui_pressed(machine, IPT_UI_RELOAD_CHEAT)) | |
| 2626 | 2626 | ReloadCheatDatabase(machine); |
| 2627 | 2627 | |
| 2628 | if(UIPressedRepeatThrottle(IPT_UI_ZOOM_IN, kVerticalKeyRepeatRate)) | |
| 2628 | if(UIPressedRepeatThrottle(machine, IPT_UI_ZOOM_IN, kVerticalKeyRepeatRate)) | |
| 2629 | 2629 | /* ----- quick menu switch : enable/disable -> add/edit ----- */ |
| 2630 | 2630 | sel = -3; |
| 2631 | 2631 | |
| 2632 | if(UIPressedRepeatThrottle(IPT_UI_ZOOM_OUT, kVerticalKeyRepeatRate)) | |
| 2632 | if(UIPressedRepeatThrottle(machine, IPT_UI_ZOOM_OUT, kVerticalKeyRepeatRate)) | |
| 2633 | 2633 | /* ----- quick menu switch : enable/disable -> watchpoint list ----- */ |
| 2634 | 2634 | sel = -5; |
| 2635 | 2635 | |
| 2636 | if(input_ui_pressed(IPT_UI_CANCEL)) | |
| 2636 | if(input_ui_pressed(machine, IPT_UI_CANCEL)) | |
| 2637 | 2637 | sel = -1; |
| 2638 | 2638 | |
| 2639 | 2639 | return sel + 1; |
| r2724 | r2725 | |
| 2699 | 2699 | old_style_menu(menu_item, NULL, NULL, sel, 0); |
| 2700 | 2700 | |
| 2701 | 2701 | /********** KEY HANDLING **********/ |
| 2702 | if(UIPressedRepeatThrottle(IPT_UI_DOWN, kVerticalKeyRepeatRate)) | |
| 2702 | if(UIPressedRepeatThrottle(machine, IPT_UI_DOWN, kVerticalKeyRepeatRate)) | |
| 2703 | 2703 | { |
| 2704 | 2704 | sel++; |
| 2705 | 2705 | |
| r2724 | r2725 | |
| 2707 | 2707 | sel = 0; |
| 2708 | 2708 | } |
| 2709 | 2709 | |
| 2710 | if(UIPressedRepeatThrottle(IPT_UI_UP, kVerticalKeyRepeatRate)) | |
| 2710 | if(UIPressedRepeatThrottle(machine, IPT_UI_UP, kVerticalKeyRepeatRate)) | |
| 2711 | 2711 | { |
| 2712 | 2712 | sel--; |
| 2713 | 2713 | |
| r2724 | r2725 | |
| 2715 | 2715 | sel = total - 1; |
| 2716 | 2716 | } |
| 2717 | 2717 | |
| 2718 | if(UIPressedRepeatThrottle(IPT_UI_PAGE_UP, kVerticalKeyRepeatRate)) | |
| 2718 | if(UIPressedRepeatThrottle(machine, IPT_UI_PAGE_UP, kVerticalKeyRepeatRate)) | |
| 2719 | 2719 | { |
| 2720 | 2720 | sel -= fullMenuPageHeight; |
| 2721 | 2721 | |
| r2724 | r2725 | |
| 2723 | 2723 | sel = 0; |
| 2724 | 2724 | } |
| 2725 | 2725 | |
| 2726 | if(UIPressedRepeatThrottle(IPT_UI_PAGE_DOWN, kVerticalKeyRepeatRate)) | |
| 2726 | if(UIPressedRepeatThrottle(machine, IPT_UI_PAGE_DOWN, kVerticalKeyRepeatRate)) | |
| 2727 | 2727 | { |
| 2728 | 2728 | sel += fullMenuPageHeight; |
| 2729 | 2729 | |
| r2724 | r2725 | |
| 2736 | 2736 | else |
| 2737 | 2737 | entry = NULL; |
| 2738 | 2738 | |
| 2739 | if(input_ui_pressed(IPT_UI_SAVE_CHEAT)) | |
| 2739 | if(input_ui_pressed(machine, IPT_UI_SAVE_CHEAT)) | |
| 2740 | 2740 | { |
| 2741 | 2741 | if(ShiftKeyPressed()) |
| 2742 | 2742 | { |
| r2724 | r2725 | |
| 2763 | 2763 | } |
| 2764 | 2764 | } |
| 2765 | 2765 | |
| 2766 | if(input_ui_pressed(IPT_UI_ADD_CHEAT)) | |
| 2766 | if(input_ui_pressed(machine, IPT_UI_ADD_CHEAT)) | |
| 2767 | 2767 | AddCheatBefore(sel); // insert empty code |
| 2768 | 2768 | |
| 2769 | if(input_ui_pressed(IPT_UI_DELETE_CHEAT)) | |
| 2769 | if(input_ui_pressed(machine, IPT_UI_DELETE_CHEAT)) | |
| 2770 | 2770 | DeleteCheatAt(sel); // delete selected code |
| 2771 | 2771 | |
| 2772 | if(input_ui_pressed(IPT_UI_WATCH_VALUE)) | |
| 2772 | if(input_ui_pressed(machine, IPT_UI_WATCH_VALUE)) | |
| 2773 | 2773 | WatchCheatEntry(entry, 0); // watch selected code |
| 2774 | 2774 | |
| 2775 | if(input_ui_pressed(IPT_UI_EDIT_CHEAT)) // edit selected code | |
| 2775 | if(input_ui_pressed(machine, IPT_UI_EDIT_CHEAT)) // edit selected code | |
| 2776 | 2776 | { |
| 2777 | 2777 | /* ----- if selected item is not return, go to edit menu ----- */ |
| 2778 | 2778 | if(sel < (total - 1)) |
| r2724 | r2725 | |
| 2782 | 2782 | } |
| 2783 | 2783 | } |
| 2784 | 2784 | |
| 2785 | if(input_ui_pressed(IPT_UI_SELECT)) | |
| 2785 | if(input_ui_pressed(machine, IPT_UI_SELECT)) | |
| 2786 | 2786 | { |
| 2787 | 2787 | /* ----- if selected item is return, return previous menu ----- */ |
| 2788 | 2788 | if(sel >= (total - 1)) |
| r2724 | r2725 | |
| 2798 | 2798 | } |
| 2799 | 2799 | } |
| 2800 | 2800 | |
| 2801 | if(input_ui_pressed(IPT_UI_RELOAD_CHEAT)) | |
| 2801 | if(input_ui_pressed(machine, IPT_UI_RELOAD_CHEAT)) | |
| 2802 | 2802 | ReloadCheatDatabase(machine); |
| 2803 | 2803 | |
| 2804 | if(UIPressedRepeatThrottle(IPT_UI_ZOOM_IN, kVerticalKeyRepeatRate)) | |
| 2804 | if(UIPressedRepeatThrottle(machine, IPT_UI_ZOOM_IN, kVerticalKeyRepeatRate)) | |
| 2805 | 2805 | /* ----- quick menu switch : add/edit -> search ----- */ |
| 2806 | 2806 | sel = -4; |
| 2807 | 2807 | |
| 2808 | if(UIPressedRepeatThrottle(IPT_UI_ZOOM_OUT, kVerticalKeyRepeatRate)) | |
| 2808 | if(UIPressedRepeatThrottle(machine, IPT_UI_ZOOM_OUT, kVerticalKeyRepeatRate)) | |
| 2809 | 2809 | /* ----- quick menu switch : add/edit -> enable/disable ----- */ |
| 2810 | 2810 | sel = -2; |
| 2811 | 2811 | |
| 2812 | if(input_ui_pressed(IPT_UI_CANCEL)) | |
| 2812 | if(input_ui_pressed(machine, IPT_UI_CANCEL)) | |
| 2813 | 2813 | sel = -1; |
| 2814 | 2814 | |
| 2815 | 2815 | return sel + 1; |
| r2724 | r2725 | |
| 3706 | 3706 | if(ShiftKeyPressed()) |
| 3707 | 3707 | increment <<= 16; |
| 3708 | 3708 | |
| 3709 | if(UIPressedRepeatThrottle(IPT_UI_LEFT, kHorizontalSlowKeyRepeatRate)) | |
| 3709 | if(UIPressedRepeatThrottle(machine, IPT_UI_LEFT, kHorizontalSlowKeyRepeatRate)) | |
| 3710 | 3710 | { |
| 3711 | 3711 | editActive = 0; |
| 3712 | 3712 | dirty = 1; |
| r2724 | r2725 | |
| 4026 | 4026 | } |
| 4027 | 4027 | } |
| 4028 | 4028 | |
| 4029 | if(UIPressedRepeatThrottle(IPT_UI_RIGHT, kHorizontalSlowKeyRepeatRate)) | |
| 4029 | if(UIPressedRepeatThrottle(machine, IPT_UI_RIGHT, kHorizontalSlowKeyRepeatRate)) | |
| 4030 | 4030 | { |
| 4031 | 4031 | editActive = 0; |
| 4032 | 4032 | dirty = 1; |
| r2724 | r2725 | |
| 4345 | 4345 | } |
| 4346 | 4346 | } |
| 4347 | 4347 | |
| 4348 | if(UIPressedRepeatThrottle(IPT_UI_DOWN, kVerticalKeyRepeatRate)) | |
| 4348 | if(UIPressedRepeatThrottle(machine, IPT_UI_DOWN, kVerticalKeyRepeatRate)) | |
| 4349 | 4349 | { |
| 4350 | 4350 | sel++; |
| 4351 | 4351 | |
| r2724 | r2725 | |
| 4355 | 4355 | editActive = 0; |
| 4356 | 4356 | } |
| 4357 | 4357 | |
| 4358 | if(UIPressedRepeatThrottle(IPT_UI_UP, kVerticalKeyRepeatRate)) | |
| 4358 | if(UIPressedRepeatThrottle(machine, IPT_UI_UP, kVerticalKeyRepeatRate)) | |
| 4359 | 4359 | { |
| 4360 | 4360 | sel--; |
| 4361 | 4361 | |
| r2724 | r2725 | |
| 4365 | 4365 | editActive = 0; |
| 4366 | 4366 | } |
| 4367 | 4367 | |
| 4368 | if(UIPressedRepeatThrottle(IPT_UI_PAGE_UP, kVerticalKeyRepeatRate)) | |
| 4368 | if(UIPressedRepeatThrottle(machine, IPT_UI_PAGE_UP, kVerticalKeyRepeatRate)) | |
| 4369 | 4369 | { |
| 4370 | 4370 | sel -= fullMenuPageHeight; |
| 4371 | 4371 | |
| r2724 | r2725 | |
| 4375 | 4375 | editActive = 0; |
| 4376 | 4376 | } |
| 4377 | 4377 | |
| 4378 | if(UIPressedRepeatThrottle(IPT_UI_PAGE_DOWN, kVerticalKeyRepeatRate)) | |
| 4378 | if(UIPressedRepeatThrottle(machine, IPT_UI_PAGE_DOWN, kVerticalKeyRepeatRate)) | |
| 4379 | 4379 | { |
| 4380 | 4380 | sel += fullMenuPageHeight; |
| 4381 | 4381 | |
| r2724 | r2725 | |
| 4385 | 4385 | editActive = 0; |
| 4386 | 4386 | } |
| 4387 | 4387 | |
| 4388 | if(input_ui_pressed(IPT_UI_SELECT)) | |
| 4388 | if(input_ui_pressed(machine, IPT_UI_SELECT)) | |
| 4389 | 4389 | { |
| 4390 | 4390 | if(editActive) |
| 4391 | 4391 | { |
| r2724 | r2725 | |
| 4447 | 4447 | case kType_ActivationKey1: |
| 4448 | 4448 | case kType_ActivationKey2: |
| 4449 | 4449 | { |
| 4450 | if(input_ui_pressed(IPT_UI_CANCEL)) | |
| 4450 | if(input_ui_pressed(machine, IPT_UI_CANCEL)) | |
| 4451 | 4451 | { |
| 4452 | 4452 | if(info->fieldType == kType_ActivationKey1) |
| 4453 | 4453 | { |
| r2724 | r2725 | |
| 4483 | 4483 | } |
| 4484 | 4484 | else |
| 4485 | 4485 | { |
| 4486 | if((code != INPUT_CODE_INVALID) && !input_ui_pressed(IPT_UI_SELECT)) | |
| 4486 | if((code != INPUT_CODE_INVALID) && !input_ui_pressed(machine, IPT_UI_SELECT)) | |
| 4487 | 4487 | { |
| 4488 | 4488 | if(info->fieldType == kType_ActivationKey1) |
| 4489 | 4489 | { |
| r2724 | r2725 | |
| 4508 | 4508 | UINT32 temp = (action->originalDataField >> 0) & 0xFF; |
| 4509 | 4509 | |
| 4510 | 4510 | temp++; |
| 4511 | temp = DoEditHexField(temp) & 0xFF; | |
| 4511 | temp = DoEditHexField(machine, temp) & 0xFF; | |
| 4512 | 4512 | temp--; |
| 4513 | 4513 | |
| 4514 | 4514 | action->originalDataField = (action->originalDataField & 0xFFFFFF00) | ((temp << 0) & 0x000000FF); |
| r2724 | r2725 | |
| 4520 | 4520 | { |
| 4521 | 4521 | UINT32 temp = (action->originalDataField >> 8) & 0xFF; |
| 4522 | 4522 | |
| 4523 | temp = DoEditHexField(temp) & 0xFF; | |
| 4523 | temp = DoEditHexField(machine, temp) & 0xFF; | |
| 4524 | 4524 | |
| 4525 | 4525 | action->originalDataField = (action->originalDataField & 0xFFFF00FF) | ((temp << 8) & 0x0000FF00); |
| 4526 | 4526 | action->data = action->originalDataField; |
| r2724 | r2725 | |
| 4531 | 4531 | { |
| 4532 | 4532 | UINT32 temp = (action->originalDataField >> 16) & 0xFF; |
| 4533 | 4533 | |
| 4534 | temp = DoEditHexField(temp) & 0xFF; | |
| 4534 | temp = DoEditHexField(machine, temp) & 0xFF; | |
| 4535 | 4535 | |
| 4536 | 4536 | action->originalDataField = (action->originalDataField & 0xFF00FFFF) | ((temp << 16) & 0x00FF0000); |
| 4537 | 4537 | action->data = action->originalDataField; |
| r2724 | r2725 | |
| 4550 | 4550 | break; |
| 4551 | 4551 | |
| 4552 | 4552 | case kType_WriteMask: |
| 4553 | action->extendData = DoEditHexField(action->extendData); | |
| 4553 | action->extendData = DoEditHexField(machine, action->extendData); | |
| 4554 | 4554 | action->extendData &= info->extraData; |
| 4555 | 4555 | break; |
| 4556 | 4556 | |
| 4557 | 4557 | case kType_AddMaximum: |
| 4558 | 4558 | case kType_SubtractMinimum: |
| 4559 | 4559 | case kType_WriteMatch: |
| 4560 | action->extendData = DoEditHexField(action->extendData); | |
| 4560 | action->extendData = DoEditHexField(machine, action->extendData); | |
| 4561 | 4561 | break; |
| 4562 | 4562 | |
| 4563 | 4563 | case kType_RangeMinimum: |
| r2724 | r2725 | |
| 4567 | 4567 | if(!TEST_FIELD(action->type, BytesUsed)) |
| 4568 | 4568 | { |
| 4569 | 4569 | temp = (action->extendData >> 8) & 0xFF; |
| 4570 | temp = DoEditHexField(temp) & 0xFF; | |
| 4570 | temp = DoEditHexField(machine, temp) & 0xFF; | |
| 4571 | 4571 | |
| 4572 | 4572 | action->extendData = (action->extendData & 0xFF) | ((temp << 8) & 0xFF00); |
| 4573 | 4573 | } |
| 4574 | 4574 | else |
| 4575 | 4575 | { |
| 4576 | 4576 | temp = (action->extendData >> 16) & 0xFFFF; |
| 4577 | temp = DoEditHexField(temp) & 0xFFFF; | |
| 4577 | temp = DoEditHexField(machine, temp) & 0xFFFF; | |
| 4578 | 4578 | |
| 4579 | 4579 | action->extendData = (action->extendData & 0x0000FFFF) | ((temp << 16) & 0xFFFF0000); |
| 4580 | 4580 | } |
| r2724 | r2725 | |
| 4588 | 4588 | if(!TEST_FIELD(action->type, BytesUsed)) |
| 4589 | 4589 | { |
| 4590 | 4590 | temp = action->extendData & 0xFF; |
| 4591 | temp = DoEditHexField(temp) & 0xFF; | |
| 4591 | temp = DoEditHexField(machine, temp) & 0xFF; | |
| 4592 | 4592 | |
| 4593 | 4593 | action->extendData = (action->extendData & 0xFF00) | (temp & 0x00FF); |
| 4594 | 4594 | } |
| 4595 | 4595 | else |
| 4596 | 4596 | { |
| 4597 | 4597 | temp = action->extendData & 0xFFFF; |
| 4598 | temp = DoEditHexField(temp) & 0xFFFF; | |
| 4598 | temp = DoEditHexField(machine, temp) & 0xFFFF; | |
| 4599 | 4599 | |
| 4600 | 4600 | action->extendData = (action->extendData & 0xFFFF0000) | (temp & 0x0000FFFF); |
| 4601 | 4601 | } |
| r2724 | r2725 | |
| 4603 | 4603 | break; |
| 4604 | 4604 | |
| 4605 | 4605 | case kType_Data: |
| 4606 | action->originalDataField = DoEditHexField(action->originalDataField); | |
| 4606 | action->originalDataField = DoEditHexField(machine, action->originalDataField); | |
| 4607 | 4607 | action->originalDataField &= info->extraData; |
| 4608 | 4608 | action->data = action->originalDataField; |
| 4609 | 4609 | break; |
| 4610 | 4610 | |
| 4611 | 4611 | case kType_Address: |
| 4612 | action->address = DoEditHexField(action->address); | |
| 4612 | action->address = DoEditHexField(machine, action->address); | |
| 4613 | 4613 | action->address &= info->extraData; |
| 4614 | 4614 | break; |
| 4615 | 4615 | } |
| 4616 | 4616 | |
| 4617 | if(input_ui_pressed(IPT_UI_CANCEL)) | |
| 4617 | if(input_ui_pressed(machine, IPT_UI_CANCEL)) | |
| 4618 | 4618 | editActive = 0; |
| 4619 | 4619 | } |
| 4620 | 4620 | else |
| 4621 | 4621 | { |
| 4622 | if(input_ui_pressed(IPT_UI_SAVE_CHEAT)) | |
| 4622 | if(input_ui_pressed(machine, IPT_UI_SAVE_CHEAT)) | |
| 4623 | 4623 | { |
| 4624 | 4624 | if(ControlKeyPressed()) |
| 4625 | 4625 | if((entry->flags & kCheatFlag_HasActivationKey1) || (entry->flags & kCheatFlag_HasActivationKey2)) |
| r2724 | r2725 | |
| 4634 | 4634 | SaveCheat(machine, entry, 0, 0); // save current entry |
| 4635 | 4635 | } |
| 4636 | 4636 | |
| 4637 | if(input_ui_pressed(IPT_UI_WATCH_VALUE)) | |
| 4637 | if(input_ui_pressed(machine, IPT_UI_WATCH_VALUE)) | |
| 4638 | 4638 | WatchCheatEntry(entry, 0); |
| 4639 | 4639 | |
| 4640 | if(input_ui_pressed(IPT_UI_ADD_CHEAT)) | |
| 4640 | if(input_ui_pressed(machine, IPT_UI_ADD_CHEAT)) | |
| 4641 | 4641 | AddActionBefore(entry, info->subcheat); |
| 4642 | 4642 | |
| 4643 | if(input_ui_pressed(IPT_UI_DELETE_CHEAT)) | |
| 4643 | if(input_ui_pressed(machine, IPT_UI_DELETE_CHEAT)) | |
| 4644 | 4644 | { |
| 4645 | 4645 | if(!info->subcheat) |
| 4646 | 4646 | { |
| r2724 | r2725 | |
| 4654 | 4654 | } |
| 4655 | 4655 | } |
| 4656 | 4656 | |
| 4657 | if(input_ui_pressed(IPT_UI_CANCEL)) | |
| 4657 | if(input_ui_pressed(machine, IPT_UI_CANCEL)) | |
| 4658 | 4658 | { |
| 4659 | 4659 | sel = -1; |
| 4660 | 4660 | editActive = 0; |
| r2724 | r2725 | |
| 4745 | 4745 | break; |
| 4746 | 4746 | |
| 4747 | 4747 | case kMenu_ViewResult: |
| 4748 | submenuChoice = ViewSearchResults(submenuChoice, firstEntry); | |
| 4748 | submenuChoice = ViewSearchResults(machine, submenuChoice, firstEntry); | |
| 4749 | 4749 | break; |
| 4750 | 4750 | } |
| 4751 | 4751 | |
| r2724 | r2725 | |
| 4870 | 4870 | old_style_menu(menuItem, menuSubItem, flagBuf, sel, 0); |
| 4871 | 4871 | |
| 4872 | 4872 | /********** KEY HANDLING **********/ |
| 4873 | if(UIPressedRepeatThrottle(IPT_UI_UP, kVerticalKeyRepeatRate)) | |
| 4873 | if(UIPressedRepeatThrottle(machine, IPT_UI_UP, kVerticalKeyRepeatRate)) | |
| 4874 | 4874 | { |
| 4875 | 4875 | if(editActive) |
| 4876 | 4876 | { |
| r2724 | r2725 | |
| 4904 | 4904 | } |
| 4905 | 4905 | } |
| 4906 | 4906 | |
| 4907 | if(UIPressedRepeatThrottle(IPT_UI_DOWN, kVerticalKeyRepeatRate)) | |
| 4907 | if(UIPressedRepeatThrottle(machine, IPT_UI_DOWN, kVerticalKeyRepeatRate)) | |
| 4908 | 4908 | { |
| 4909 | 4909 | if(editActive) |
| 4910 | 4910 | { |
| r2724 | r2725 | |
| 4938 | 4938 | } |
| 4939 | 4939 | } |
| 4940 | 4940 | |
| 4941 | if(UIPressedRepeatThrottle(IPT_UI_PAGE_UP, kVerticalKeyRepeatRate)) | |
| 4941 | if(UIPressedRepeatThrottle(machine, IPT_UI_PAGE_UP, kVerticalKeyRepeatRate)) | |
| 4942 | 4942 | { |
| 4943 | 4943 | sel -= fullMenuPageHeight; |
| 4944 | 4944 | |
| r2724 | r2725 | |
| 4946 | 4946 | sel = 0; |
| 4947 | 4947 | } |
| 4948 | 4948 | |
| 4949 | if(UIPressedRepeatThrottle(IPT_UI_PAGE_DOWN, kVerticalKeyRepeatRate)) | |
| 4949 | if(UIPressedRepeatThrottle(machine, IPT_UI_PAGE_DOWN, kVerticalKeyRepeatRate)) | |
| 4950 | 4950 | { |
| 4951 | 4951 | sel += fullMenuPageHeight; |
| 4952 | 4952 | |
| r2724 | r2725 | |
| 4954 | 4954 | sel = total - 1; |
| 4955 | 4955 | } |
| 4956 | 4956 | |
| 4957 | if(UIPressedRepeatThrottle(IPT_UI_LEFT, kHorizontalFastKeyRepeatRate)) | |
| 4957 | if(UIPressedRepeatThrottle(machine, IPT_UI_LEFT, kHorizontalFastKeyRepeatRate)) | |
| 4958 | 4958 | { |
| 4959 | 4959 | if(editActive) |
| 4960 | 4960 | { |
| r2724 | r2725 | |
| 4998 | 4998 | } |
| 4999 | 4999 | } |
| 5000 | 5000 | |
| 5001 | if(UIPressedRepeatThrottle(IPT_UI_RIGHT, kHorizontalFastKeyRepeatRate)) | |
| 5001 | if(UIPressedRepeatThrottle(machine, IPT_UI_RIGHT, kHorizontalFastKeyRepeatRate)) | |
| 5002 | 5002 | { |
| 5003 | 5003 | if(editActive) |
| 5004 | 5004 | { |
| r2724 | r2725 | |
| 5043 | 5043 | } |
| 5044 | 5044 | } |
| 5045 | 5045 | |
| 5046 | if(input_ui_pressed(IPT_UI_SELECT)) | |
| 5046 | if(input_ui_pressed(machine, IPT_UI_SELECT)) | |
| 5047 | 5047 | { |
| 5048 | 5048 | if(editActive) |
| 5049 | 5049 | { |
| r2724 | r2725 | |
| 5160 | 5160 | } |
| 5161 | 5161 | } |
| 5162 | 5162 | |
| 5163 | if(UIPressedRepeatThrottle(IPT_UI_ZOOM_IN, kVerticalKeyRepeatRate)) | |
| 5163 | if(UIPressedRepeatThrottle(machine, IPT_UI_ZOOM_IN, kVerticalKeyRepeatRate)) | |
| 5164 | 5164 | /* ----- quick menu switch : search -> watchpoint list ----- */ |
| 5165 | 5165 | sel = -5; |
| 5166 | 5166 | |
| 5167 | if(UIPressedRepeatThrottle(IPT_UI_ZOOM_OUT, kVerticalKeyRepeatRate)) | |
| 5167 | if(UIPressedRepeatThrottle(machine, IPT_UI_ZOOM_OUT, kVerticalKeyRepeatRate)) | |
| 5168 | 5168 | /* ----- quick menu switch : search -> add/edit ----- */ |
| 5169 | 5169 | sel = -3; |
| 5170 | 5170 | |
| 5171 | 5171 | /* ----- edit mode ON/OFF ----- */ |
| 5172 | if(input_ui_pressed(IPT_UI_EDIT_CHEAT)) | |
| 5172 | if(input_ui_pressed(machine, IPT_UI_EDIT_CHEAT)) | |
| 5173 | 5173 | { |
| 5174 | 5174 | if(editActive) |
| 5175 | 5175 | editActive = 0; |
| r2724 | r2725 | |
| 5181 | 5181 | } |
| 5182 | 5182 | |
| 5183 | 5183 | /* ----- memory save ----- */ |
| 5184 | if(input_ui_pressed(IPT_UI_CLEAR)) | |
| 5184 | if(input_ui_pressed(machine, IPT_UI_CLEAR)) | |
| 5185 | 5185 | { |
| 5186 | 5186 | doneSaveMemory = 0; |
| 5187 | 5187 | |
| 5188 | 5188 | doSearch = 1; |
| 5189 | 5189 | } |
| 5190 | 5190 | |
| 5191 | if(input_ui_pressed(IPT_UI_CANCEL)) | |
| 5191 | if(input_ui_pressed(machine, IPT_UI_CANCEL)) | |
| 5192 | 5192 | { |
| 5193 | 5193 | if(editActive) |
| 5194 | 5194 | editActive = 0; |
| r2724 | r2725 | |
| 5237 | 5237 | { |
| 5238 | 5238 | if(searchItem == kItem_Value) |
| 5239 | 5239 | { |
| 5240 | search->oldOptions.value = DoEditHexField(search->oldOptions.value); | |
| 5240 | search->oldOptions.value = DoEditHexField(machine, search->oldOptions.value); | |
| 5241 | 5241 | |
| 5242 | 5242 | search->oldOptions.value &= kSearchByteMaskTable[search->bytes]; |
| 5243 | 5243 | } |
| r2724 | r2725 | |
| 5245 | 5245 | { |
| 5246 | 5246 | if(searchItem == kItem_Timer) |
| 5247 | 5247 | { |
| 5248 | search->oldOptions.delta = DoEditHexField(search->oldOptions.delta); | |
| 5248 | search->oldOptions.delta = DoEditHexField(machine, search->oldOptions.delta); | |
| 5249 | 5249 | |
| 5250 | 5250 | search->oldOptions.delta &= kSearchByteMaskTable[search->bytes]; |
| 5251 | 5251 | } |
| r2724 | r2725 | |
| 5366 | 5366 | break; |
| 5367 | 5367 | |
| 5368 | 5368 | case kMenu_ViewResult: |
| 5369 | submenuChoice = ViewSearchResults(submenuChoice, firstEntry); | |
| 5369 | submenuChoice = ViewSearchResults(machine, submenuChoice, firstEntry); | |
| 5370 | 5370 | break; |
| 5371 | 5371 | } |
| 5372 | 5372 | |
| r2724 | r2725 | |
| 5481 | 5481 | if(AltKeyPressed()) |
| 5482 | 5482 | increment <<= 4; |
| 5483 | 5483 | |
| 5484 | if(UIPressedRepeatThrottle(IPT_UI_DOWN, kVerticalKeyRepeatRate)) | |
| 5484 | if(UIPressedRepeatThrottle(machine, IPT_UI_DOWN, kVerticalKeyRepeatRate)) | |
| 5485 | 5485 | { |
| 5486 | 5486 | sel++; |
| 5487 | 5487 | |
| r2724 | r2725 | |
| 5493 | 5493 | sel = 0; |
| 5494 | 5494 | } |
| 5495 | 5495 | |
| 5496 | if(UIPressedRepeatThrottle(IPT_UI_UP, kVerticalKeyRepeatRate)) | |
| 5496 | if(UIPressedRepeatThrottle(machine, IPT_UI_UP, kVerticalKeyRepeatRate)) | |
| 5497 | 5497 | { |
| 5498 | 5498 | sel--; |
| 5499 | 5499 | |
| r2724 | r2725 | |
| 5505 | 5505 | sel = total - 1; |
| 5506 | 5506 | } |
| 5507 | 5507 | |
| 5508 | if(UIPressedRepeatThrottle(IPT_UI_PAGE_UP, kVerticalKeyRepeatRate)) | |
| 5508 | if(UIPressedRepeatThrottle(machine, IPT_UI_PAGE_UP, kVerticalKeyRepeatRate)) | |
| 5509 | 5509 | { |
| 5510 | 5510 | sel -= fullMenuPageHeight; |
| 5511 | 5511 | |
| r2724 | r2725 | |
| 5513 | 5513 | sel = 0; |
| 5514 | 5514 | } |
| 5515 | 5515 | |
| 5516 | if(UIPressedRepeatThrottle(IPT_UI_PAGE_DOWN, kVerticalKeyRepeatRate)) | |
| 5516 | if(UIPressedRepeatThrottle(machine, IPT_UI_PAGE_DOWN, kVerticalKeyRepeatRate)) | |
| 5517 | 5517 | { |
| 5518 | 5518 | sel += fullMenuPageHeight; |
| 5519 | 5519 | |
| r2724 | r2725 | |
| 5521 | 5521 | sel = total - 1; |
| 5522 | 5522 | } |
| 5523 | 5523 | |
| 5524 | if(UIPressedRepeatThrottle(IPT_UI_LEFT, kHorizontalFastKeyRepeatRate)) | |
| 5524 | if(UIPressedRepeatThrottle(machine, IPT_UI_LEFT, kHorizontalFastKeyRepeatRate)) | |
| 5525 | 5525 | { |
| 5526 | 5526 | switch(sel) |
| 5527 | 5527 | { |
| r2724 | r2725 | |
| 5575 | 5575 | } |
| 5576 | 5576 | } |
| 5577 | 5577 | |
| 5578 | if(UIPressedRepeatThrottle(IPT_UI_RIGHT, kHorizontalFastKeyRepeatRate)) | |
| 5578 | if(UIPressedRepeatThrottle(machine, IPT_UI_RIGHT, kHorizontalFastKeyRepeatRate)) | |
| 5579 | 5579 | { |
| 5580 | 5580 | switch(sel) |
| 5581 | 5581 | { |
| r2724 | r2725 | |
| 5629 | 5629 | } |
| 5630 | 5630 | } |
| 5631 | 5631 | |
| 5632 | if(input_ui_pressed(IPT_UI_SELECT)) | |
| 5632 | if(input_ui_pressed(machine, IPT_UI_SELECT)) | |
| 5633 | 5633 | { |
| 5634 | 5634 | switch(sel) |
| 5635 | 5635 | { |
| r2724 | r2725 | |
| 5714 | 5714 | } |
| 5715 | 5715 | } |
| 5716 | 5716 | |
| 5717 | if(UIPressedRepeatThrottle(IPT_UI_ZOOM_IN, kVerticalKeyRepeatRate)) | |
| 5717 | if(UIPressedRepeatThrottle(machine, IPT_UI_ZOOM_IN, kVerticalKeyRepeatRate)) | |
| 5718 | 5718 | /* ----- quick menu switch : search -> watchpoint list ----- */ |
| 5719 | 5719 | sel = -5; |
| 5720 | 5720 | |
| 5721 | if(UIPressedRepeatThrottle(IPT_UI_ZOOM_OUT, kVerticalKeyRepeatRate)) | |
| 5721 | if(UIPressedRepeatThrottle(machine, IPT_UI_ZOOM_OUT, kVerticalKeyRepeatRate)) | |
| 5722 | 5722 | /* ----- quick menu switch : search -> add/edit ----- */ |
| 5723 | 5723 | sel = -3; |
| 5724 | 5724 | |
| 5725 | 5725 | |
| 5726 | if(input_ui_pressed(IPT_UI_CANCEL)) | |
| 5726 | if(input_ui_pressed(machine, IPT_UI_CANCEL)) | |
| 5727 | 5727 | { |
| 5728 | 5728 | /* ----- if cursor is now on the return item, adjust cursor keeper ----- */ |
| 5729 | 5729 | if(sel == kMenu_Return) |
| r2724 | r2725 | |
| 5766 | 5766 | /* ----- edit a value if direct key input ----- */ |
| 5767 | 5767 | if((sel == kMenu_ValueEqual) || (sel == kMenu_ValueNearTo)) |
| 5768 | 5768 | { |
| 5769 | search->oldOptions.value = DoEditHexField(search->oldOptions.value); | |
| 5769 | search->oldOptions.value = DoEditHexField(machine, search->oldOptions.value); | |
| 5770 | 5770 | |
| 5771 | 5771 | search->oldOptions.value &= kSearchByteMaskTable[search->bytes]; |
| 5772 | 5772 | } |
| r2724 | r2725 | |
| 5774 | 5774 | { |
| 5775 | 5775 | if(sel == kMenu_Time) |
| 5776 | 5776 | { |
| 5777 | search->oldOptions.delta = DoEditHexField(search->oldOptions.delta); | |
| 5777 | search->oldOptions.delta = DoEditHexField(machine, search->oldOptions.delta); | |
| 5778 | 5778 | |
| 5779 | 5779 | search->oldOptions.delta &= kSearchByteMaskTable[search->bytes]; |
| 5780 | 5780 | } |
| r2724 | r2725 | |
| 5884 | 5884 | break; |
| 5885 | 5885 | |
| 5886 | 5886 | case kMenu_ViewResult: |
| 5887 | submenuChoice = ViewSearchResults(submenuChoice, firstEntry); | |
| 5887 | submenuChoice = ViewSearchResults(machine, submenuChoice, firstEntry); | |
| 5888 | 5888 | break; |
| 5889 | 5889 | } |
| 5890 | 5890 | |
| r2724 | r2725 | |
| 6006 | 6006 | if(ShiftKeyPressed()) |
| 6007 | 6007 | increment <<= 16; |
| 6008 | 6008 | |
| 6009 | if(UIPressedRepeatThrottle(IPT_UI_DOWN, kVerticalKeyRepeatRate)) | |
| 6009 | if(UIPressedRepeatThrottle(machine, IPT_UI_DOWN, kVerticalKeyRepeatRate)) | |
| 6010 | 6010 | { |
| 6011 | 6011 | sel++; |
| 6012 | 6012 | |
| r2724 | r2725 | |
| 6018 | 6018 | sel = 0; |
| 6019 | 6019 | } |
| 6020 | 6020 | |
| 6021 | if(UIPressedRepeatThrottle(IPT_UI_UP, kVerticalKeyRepeatRate)) | |
| 6021 | if(UIPressedRepeatThrottle(machine, IPT_UI_UP, kVerticalKeyRepeatRate)) | |
| 6022 | 6022 | { |
| 6023 | 6023 | sel--; |
| 6024 | 6024 | |
| r2724 | r2725 | |
| 6030 | 6030 | sel = total - 1; |
| 6031 | 6031 | } |
| 6032 | 6032 | |
| 6033 | if(UIPressedRepeatThrottle(IPT_UI_PAGE_UP, kVerticalKeyRepeatRate)) | |
| 6033 | if(UIPressedRepeatThrottle(machine, IPT_UI_PAGE_UP, kVerticalKeyRepeatRate)) | |
| 6034 | 6034 | { |
| 6035 | 6035 | sel -= fullMenuPageHeight; |
| 6036 | 6036 | |
| r2724 | r2725 | |
| 6038 | 6038 | sel = 0; |
| 6039 | 6039 | } |
| 6040 | 6040 | |
| 6041 | if(UIPressedRepeatThrottle(IPT_UI_PAGE_DOWN, kVerticalKeyRepeatRate)) | |
| 6041 | if(UIPressedRepeatThrottle(machine, IPT_UI_PAGE_DOWN, kVerticalKeyRepeatRate)) | |
| 6042 | 6042 | { |
| 6043 | 6043 | sel += fullMenuPageHeight; |
| 6044 | 6044 | |
| r2724 | r2725 | |
| 6046 | 6046 | sel = total - 1; |
| 6047 | 6047 | } |
| 6048 | 6048 | |
| 6049 | if(UIPressedRepeatThrottle(IPT_UI_LEFT, kHorizontalFastKeyRepeatRate)) | |
| 6049 | if(UIPressedRepeatThrottle(machine, IPT_UI_LEFT, kHorizontalFastKeyRepeatRate)) | |
| 6050 | 6050 | { |
| 6051 | 6051 | switch(sel) |
| 6052 | 6052 | { |
| r2724 | r2725 | |
| 6106 | 6106 | } |
| 6107 | 6107 | } |
| 6108 | 6108 | |
| 6109 | if(UIPressedRepeatThrottle(IPT_UI_RIGHT, kHorizontalFastKeyRepeatRate)) | |
| 6109 | if(UIPressedRepeatThrottle(machine, IPT_UI_RIGHT, kHorizontalFastKeyRepeatRate)) | |
| 6110 | 6110 | { |
| 6111 | 6111 | switch(sel) |
| 6112 | 6112 | { |
| r2724 | r2725 | |
| 6166 | 6166 | } |
| 6167 | 6167 | } |
| 6168 | 6168 | |
| 6169 | if(input_ui_pressed(IPT_UI_SELECT)) | |
| 6169 | if(input_ui_pressed(machine, IPT_UI_SELECT)) | |
| 6170 | 6170 | { |
| 6171 | 6171 | if(editActive) |
| 6172 | 6172 | editActive = 0; |
| r2724 | r2725 | |
| 6256 | 6256 | switch(sel) |
| 6257 | 6257 | { |
| 6258 | 6258 | case kMenu_Value: |
| 6259 | search->value = DoEditHexField(search->value); | |
| 6259 | search->value = DoEditHexField(machine, search->value); | |
| 6260 | 6260 | |
| 6261 | 6261 | search->value &= kSearchByteMaskTable[search->bytes]; |
| 6262 | 6262 | break; |
| r2724 | r2725 | |
| 6267 | 6267 | } |
| 6268 | 6268 | } |
| 6269 | 6269 | |
| 6270 | if(input_ui_pressed(IPT_UI_CANCEL)) | |
| 6270 | if(input_ui_pressed(machine, IPT_UI_CANCEL)) | |
| 6271 | 6271 | sel = -1; |
| 6272 | 6272 | |
| 6273 | 6273 | /* ----- keep current cursor position ----- */ |
| r2724 | r2725 | |
| 6342 | 6342 | old_style_menu(menuItem, menuSubItem, NULL, sel, 0); |
| 6343 | 6343 | |
| 6344 | 6344 | /********** KEY HANDLING **********/ |
| 6345 | if(UIPressedRepeatThrottle(IPT_UI_DOWN, kVerticalKeyRepeatRate)) | |
| 6345 | if(UIPressedRepeatThrottle(machine, IPT_UI_DOWN, kVerticalKeyRepeatRate)) | |
| 6346 | 6346 | { |
| 6347 | 6347 | sel++; |
| 6348 | 6348 | |
| r2724 | r2725 | |
| 6350 | 6350 | sel = 0; |
| 6351 | 6351 | } |
| 6352 | 6352 | |
| 6353 | if(UIPressedRepeatThrottle(IPT_UI_UP, kVerticalKeyRepeatRate)) | |
| 6353 | if(UIPressedRepeatThrottle(machine, IPT_UI_UP, kVerticalKeyRepeatRate)) | |
| 6354 | 6354 | { |
| 6355 | 6355 | sel--; |
| 6356 | 6356 | |
| r2724 | r2725 | |
| 6358 | 6358 | sel = total - 1; |
| 6359 | 6359 | } |
| 6360 | 6360 | |
| 6361 | if(UIPressedRepeatThrottle(IPT_UI_PAGE_UP, kVerticalKeyRepeatRate)) | |
| 6361 | if(UIPressedRepeatThrottle(machine, IPT_UI_PAGE_UP, kVerticalKeyRepeatRate)) | |
| 6362 | 6362 | { |
| 6363 | 6363 | sel -= fullMenuPageHeight; |
| 6364 | 6364 | |
| r2724 | r2725 | |
| 6366 | 6366 | sel = 0; |
| 6367 | 6367 | } |
| 6368 | 6368 | |
| 6369 | if(UIPressedRepeatThrottle(IPT_UI_PAGE_DOWN, kVerticalKeyRepeatRate)) | |
| 6369 | if(UIPressedRepeatThrottle(machine, IPT_UI_PAGE_DOWN, kVerticalKeyRepeatRate)) | |
| 6370 | 6370 | { |
| 6371 | 6371 | sel += fullMenuPageHeight; |
| 6372 | 6372 | |
| r2724 | r2725 | |
| 6374 | 6374 | sel = total - 1; |
| 6375 | 6375 | } |
| 6376 | 6376 | |
| 6377 | if(UIPressedRepeatThrottle(IPT_UI_LEFT, kHorizontalSlowKeyRepeatRate)) | |
| 6377 | if(UIPressedRepeatThrottle(machine, IPT_UI_LEFT, kHorizontalSlowKeyRepeatRate)) | |
| 6378 | 6378 | { |
| 6379 | 6379 | if(sel < search->regionListLength) |
| 6380 | 6380 | { |
| r2724 | r2725 | |
| 6395 | 6395 | } |
| 6396 | 6396 | } |
| 6397 | 6397 | |
| 6398 | if(UIPressedRepeatThrottle(IPT_UI_RIGHT, kHorizontalSlowKeyRepeatRate)) | |
| 6398 | if(UIPressedRepeatThrottle(machine, IPT_UI_RIGHT, kHorizontalSlowKeyRepeatRate)) | |
| 6399 | 6399 | { |
| 6400 | 6400 | if(sel < search->regionListLength) |
| 6401 | 6401 | { |
| r2724 | r2725 | |
| 6416 | 6416 | } |
| 6417 | 6417 | } |
| 6418 | 6418 | |
| 6419 | if(input_ui_pressed(IPT_UI_DELETE_CHEAT)) | |
| 6419 | if(input_ui_pressed(machine, IPT_UI_DELETE_CHEAT)) | |
| 6420 | 6420 | { |
| 6421 | 6421 | if(ShiftKeyPressed()) // shift + delete = invalid region |
| 6422 | 6422 | { |
| r2724 | r2725 | |
| 6429 | 6429 | } |
| 6430 | 6430 | } |
| 6431 | 6431 | |
| 6432 | if(input_ui_pressed(IPT_UI_SELECT)) | |
| 6432 | if(input_ui_pressed(machine, IPT_UI_SELECT)) | |
| 6433 | 6433 | { |
| 6434 | 6434 | if(sel >= total - 1) |
| 6435 | 6435 | sel = -1; |
| 6436 | 6436 | } |
| 6437 | 6437 | |
| 6438 | if(input_ui_pressed(IPT_UI_CANCEL)) | |
| 6438 | if(input_ui_pressed(machine, IPT_UI_CANCEL)) | |
| 6439 | 6439 | sel = -1; |
| 6440 | 6440 | |
| 6441 | 6441 | return sel + 1; |
| r2724 | r2725 | |
| 6445 | 6445 | ViewSearchResults - management for search result menu |
| 6446 | 6446 | --------------------------------------------------------*/ |
| 6447 | 6447 | |
| 6448 | static int ViewSearchResults(int selection, int firstTime) | |
| 6448 | static int ViewSearchResults(running_machine *machine, int selection, int firstTime) | |
| 6449 | 6449 | { |
| 6450 | 6450 | enum |
| 6451 | 6451 | { |
| r2724 | r2725 | |
| 6612 | 6612 | old_style_menu(menu_item, NULL, NULL, sel, 0); |
| 6613 | 6613 | |
| 6614 | 6614 | /********** KEY HANDLING **********/ |
| 6615 | if(UIPressedRepeatThrottle(IPT_UI_DOWN, kVerticalKeyRepeatRate)) | |
| 6615 | if(UIPressedRepeatThrottle(machine, IPT_UI_DOWN, kVerticalKeyRepeatRate)) | |
| 6616 | 6616 | { |
| 6617 | 6617 | sel++; |
| 6618 | 6618 | |
| r2724 | r2725 | |
| 6620 | 6620 | sel = kMenu_FirstResult; |
| 6621 | 6621 | } |
| 6622 | 6622 | |
| 6623 | if(UIPressedRepeatThrottle(IPT_UI_UP, kVerticalKeyRepeatRate)) | |
| 6623 | if(UIPressedRepeatThrottle(machine, IPT_UI_UP, kVerticalKeyRepeatRate)) | |
| 6624 | 6624 | { |
| 6625 | 6625 | sel--; |
| 6626 | 6626 | |
| r2724 | r2725 | |
| 6628 | 6628 | sel = total - 1; |
| 6629 | 6629 | } |
| 6630 | 6630 | |
| 6631 | if(UIPressedRepeatThrottle(IPT_UI_RIGHT, kHorizontalFastKeyRepeatRate)) | |
| 6631 | if(UIPressedRepeatThrottle(machine, IPT_UI_RIGHT, kHorizontalFastKeyRepeatRate)) | |
| 6632 | 6632 | { |
| 6633 | 6633 | if(ShiftKeyPressed()) |
| 6634 | 6634 | search->currentResultsPage = numPages - 1; // shift + right = go to last PAGE |
| r2724 | r2725 | |
| 6648 | 6648 | sel = kMenu_FirstResult; |
| 6649 | 6649 | } |
| 6650 | 6650 | |
| 6651 | if(UIPressedRepeatThrottle(IPT_UI_LEFT, kHorizontalFastKeyRepeatRate)) | |
| 6651 | if(UIPressedRepeatThrottle(machine, IPT_UI_LEFT, kHorizontalFastKeyRepeatRate)) | |
| 6652 | 6652 | { |
| 6653 | 6653 | if(ShiftKeyPressed()) |
| 6654 | 6654 | search->currentResultsPage = 0; // shift + left = go to first PAGE |
| r2724 | r2725 | |
| 6668 | 6668 | sel = kMenu_FirstResult; |
| 6669 | 6669 | } |
| 6670 | 6670 | |
| 6671 | if(UIPressedRepeatThrottle(IPT_UI_PAGE_UP, kHorizontalFastKeyRepeatRate)) | |
| 6671 | if(UIPressedRepeatThrottle(machine, IPT_UI_PAGE_UP, kHorizontalFastKeyRepeatRate)) | |
| 6672 | 6672 | { |
| 6673 | 6673 | sel -=fullMenuPageHeight; |
| 6674 | 6674 | |
| r2724 | r2725 | |
| 6676 | 6676 | sel = kMenu_FirstResult; |
| 6677 | 6677 | } |
| 6678 | 6678 | |
| 6679 | if(UIPressedRepeatThrottle(IPT_UI_PAGE_DOWN, kHorizontalFastKeyRepeatRate)) | |
| 6679 | if(UIPressedRepeatThrottle(machine, IPT_UI_PAGE_DOWN, kHorizontalFastKeyRepeatRate)) | |
| 6680 | 6680 | { |
| 6681 | 6681 | sel +=fullMenuPageHeight; |
| 6682 | 6682 | |
| r2724 | r2725 | |
| 6690 | 6690 | if(input_code_pressed_once(KEYCODE_HOME)) |
| 6691 | 6691 | search->currentResultsPage = 0; // go to first PAGE |
| 6692 | 6692 | |
| 6693 | if(UIPressedRepeatThrottle(IPT_UI_PREV_GROUP, kVerticalKeyRepeatRate)) | |
| 6693 | if(UIPressedRepeatThrottle(machine, IPT_UI_PREV_GROUP, kVerticalKeyRepeatRate)) | |
| 6694 | 6694 | { |
| 6695 | 6695 | search->currentRegionIdx--; // go to previous REGION |
| 6696 | 6696 | |
| r2724 | r2725 | |
| 6700 | 6700 | sel = kMenu_FirstResult; |
| 6701 | 6701 | } |
| 6702 | 6702 | |
| 6703 | if(UIPressedRepeatThrottle(IPT_UI_NEXT_GROUP, kVerticalKeyRepeatRate)) | |
| 6703 | if(UIPressedRepeatThrottle(machine, IPT_UI_NEXT_GROUP, kVerticalKeyRepeatRate)) | |
| 6704 | 6704 | { |
| 6705 | 6705 | search->currentRegionIdx++; // go to next REGION |
| 6706 | 6706 | |
| r2724 | r2725 | |
| 6780 | 6780 | |
| 6781 | 6781 | if(selectedAddressGood) |
| 6782 | 6782 | { |
| 6783 | if(input_ui_pressed(IPT_UI_WATCH_VALUE)) | |
| 6783 | if(input_ui_pressed(machine, IPT_UI_WATCH_VALUE)) | |
| 6784 | 6784 | AddWatchFromResult(search, region, selectedAddress); // watch selected result |
| 6785 | 6785 | |
| 6786 | if(input_ui_pressed(IPT_UI_ADD_CHEAT)) | |
| 6786 | if(input_ui_pressed(machine, IPT_UI_ADD_CHEAT)) | |
| 6787 | 6787 | AddCheatFromResult(search, region, selectedAddress); // add selected result as new code to cheat list |
| 6788 | 6788 | |
| 6789 | if(input_ui_pressed(IPT_UI_DELETE_CHEAT)) | |
| 6789 | if(input_ui_pressed(machine, IPT_UI_DELETE_CHEAT)) | |
| 6790 | 6790 | { |
| 6791 | 6791 | InvalidateRegionOffset(search, region, selectedOffset); // delete selected result |
| 6792 | 6792 | search->numResults--; |
| r2724 | r2725 | |
| 6794 | 6794 | } |
| 6795 | 6795 | } |
| 6796 | 6796 | |
| 6797 | if(input_ui_pressed(IPT_UI_DELETE_CHEAT)) | |
| 6797 | if(input_ui_pressed(machine, IPT_UI_DELETE_CHEAT)) | |
| 6798 | 6798 | { |
| 6799 | 6799 | if(ShiftKeyPressed()) |
| 6800 | 6800 | { |
| r2724 | r2725 | |
| 6807 | 6807 | } |
| 6808 | 6808 | } |
| 6809 | 6809 | |
| 6810 | if((input_ui_pressed(IPT_UI_SELECT) && (sel == total - 1)) || input_ui_pressed(IPT_UI_CANCEL)) | |
| 6810 | if((input_ui_pressed(machine, IPT_UI_SELECT) && (sel == total - 1)) || input_ui_pressed(machine, IPT_UI_CANCEL)) | |
| 6811 | 6811 | sel = -1; |
| 6812 | 6812 | |
| 6813 | 6813 | return sel + 1; |
| r2724 | r2725 | |
| 6882 | 6882 | watch = NULL; |
| 6883 | 6883 | |
| 6884 | 6884 | /********** KEY HANDLING **********/ |
| 6885 | if(UIPressedRepeatThrottle(IPT_UI_DOWN, kVerticalKeyRepeatRate)) | |
| 6885 | if(UIPressedRepeatThrottle(machine, IPT_UI_DOWN, kVerticalKeyRepeatRate)) | |
| 6886 | 6886 | { |
| 6887 | 6887 | sel++; |
| 6888 | 6888 | |
| r2724 | r2725 | |
| 6890 | 6890 | sel = 0; |
| 6891 | 6891 | } |
| 6892 | 6892 | |
| 6893 | if(UIPressedRepeatThrottle(IPT_UI_UP, kVerticalKeyRepeatRate)) | |
| 6893 | if(UIPressedRepeatThrottle(machine, IPT_UI_UP, kVerticalKeyRepeatRate)) | |
| 6894 | 6894 | { |
| 6895 | 6895 | sel--; |
| 6896 | 6896 | |
| r2724 | r2725 | |
| 6898 | 6898 | sel = total - 1; |
| 6899 | 6899 | } |
| 6900 | 6900 | |
| 6901 | if(UIPressedRepeatThrottle(IPT_UI_PAGE_UP, kVerticalKeyRepeatRate)) | |
| 6901 | if(UIPressedRepeatThrottle(machine, IPT_UI_PAGE_UP, kVerticalKeyRepeatRate)) | |
| 6902 | 6902 | { |
| 6903 | 6903 | sel -= fullMenuPageHeight; |
| 6904 | 6904 | |
| r2724 | r2725 | |
| 6906 | 6906 | sel = 0; |
| 6907 | 6907 | } |
| 6908 | 6908 | |
| 6909 | if(UIPressedRepeatThrottle(IPT_UI_PAGE_DOWN, kVerticalKeyRepeatRate)) | |
| 6909 | if(UIPressedRepeatThrottle(machine, IPT_UI_PAGE_DOWN, kVerticalKeyRepeatRate)) | |
| 6910 | 6910 | { |
| 6911 | 6911 | sel += fullMenuPageHeight; |
| 6912 | 6912 | |
| r2724 | r2725 | |
| 6916 | 6916 | |
| 6917 | 6917 | if(ShiftKeyPressed()) |
| 6918 | 6918 | { |
| 6919 | if(input_ui_pressed(IPT_UI_ADD_CHEAT)) // shift + add = add new watchpoint | |
| 6919 | if(input_ui_pressed(machine, IPT_UI_ADD_CHEAT)) // shift + add = add new watchpoint | |
| 6920 | 6920 | AddWatchBefore(sel); |
| 6921 | 6921 | |
| 6922 | if(input_ui_pressed(IPT_UI_DELETE_CHEAT)) // shift + delete = delete selected watchpoint | |
| 6922 | if(input_ui_pressed(machine, IPT_UI_DELETE_CHEAT)) // shift + delete = delete selected watchpoint | |
| 6923 | 6923 | DeleteWatchAt(sel); |
| 6924 | 6924 | } |
| 6925 | 6925 | else |
| 6926 | 6926 | { |
| 6927 | if(input_ui_pressed(IPT_UI_SAVE_CHEAT)) // save = save selected watchpoint as watchpoint code | |
| 6927 | if(input_ui_pressed(machine, IPT_UI_SAVE_CHEAT)) // save = save selected watchpoint as watchpoint code | |
| 6928 | 6928 | { |
| 6929 | 6929 | if(watch) |
| 6930 | 6930 | { |
| r2724 | r2725 | |
| 6938 | 6938 | } |
| 6939 | 6939 | } |
| 6940 | 6940 | |
| 6941 | if(input_ui_pressed(IPT_UI_ADD_CHEAT)) | |
| 6941 | if(input_ui_pressed(machine, IPT_UI_ADD_CHEAT)) | |
| 6942 | 6942 | { |
| 6943 | 6943 | if(watch) |
| 6944 | 6944 | { |
| r2724 | r2725 | |
| 6954 | 6954 | } |
| 6955 | 6955 | } |
| 6956 | 6956 | |
| 6957 | if(input_ui_pressed(IPT_UI_DELETE_CHEAT)) | |
| 6957 | if(input_ui_pressed(machine, IPT_UI_DELETE_CHEAT)) | |
| 6958 | 6958 | { |
| 6959 | 6959 | if(ControlKeyPressed()) |
| 6960 | 6960 | { |
| r2724 | r2725 | |
| 6969 | 6969 | } |
| 6970 | 6970 | } |
| 6971 | 6971 | |
| 6972 | if(input_ui_pressed(IPT_UI_EDIT_CHEAT)) // edit = edit selected watchpoint | |
| 6972 | if(input_ui_pressed(machine, IPT_UI_EDIT_CHEAT)) // edit = edit selected watchpoint | |
| 6973 | 6973 | { |
| 6974 | 6974 | if(sel < (total - 1)) |
| 6975 | 6975 | { |
| r2724 | r2725 | |
| 6978 | 6978 | } |
| 6979 | 6979 | } |
| 6980 | 6980 | |
| 6981 | if(input_ui_pressed(IPT_UI_SELECT)) | |
| 6981 | if(input_ui_pressed(machine, IPT_UI_SELECT)) | |
| 6982 | 6982 | { |
| 6983 | 6983 | if(sel == (total - 1)) // return previous menu |
| 6984 | 6984 | { |
| r2724 | r2725 | |
| 6995 | 6995 | } |
| 6996 | 6996 | } |
| 6997 | 6997 | |
| 6998 | if(input_ui_pressed(IPT_UI_CLEAR)) | |
| 6998 | if(input_ui_pressed(machine, IPT_UI_CLEAR)) | |
| 6999 | 6999 | { |
| 7000 | 7000 | /* ----- reset all watchpoints ----- */ |
| 7001 | 7001 | for(i = 0; i < watchListLength; i++) |
| r2724 | r2725 | |
| 7019 | 7019 | } |
| 7020 | 7020 | } |
| 7021 | 7021 | |
| 7022 | if(UIPressedRepeatThrottle(IPT_UI_ZOOM_IN, kVerticalKeyRepeatRate)) | |
| 7022 | if(UIPressedRepeatThrottle(machine, IPT_UI_ZOOM_IN, kVerticalKeyRepeatRate)) | |
| 7023 | 7023 | /* ----- quick menu switch : watchpoint list -> enable/disable ----- */ |
| 7024 | 7024 | sel = -2; |
| 7025 | 7025 | |
| 7026 | if(UIPressedRepeatThrottle(IPT_UI_ZOOM_OUT, kVerticalKeyRepeatRate)) | |
| 7026 | if(UIPressedRepeatThrottle(machine, IPT_UI_ZOOM_OUT, kVerticalKeyRepeatRate)) | |
| 7027 | 7027 | /* ----- quick menu switch : watchpoint list -> search ----- */ |
| 7028 | 7028 | sel = -4; |
| 7029 | 7029 | |
| 7030 | if(input_ui_pressed(IPT_UI_CANCEL)) | |
| 7030 | if(input_ui_pressed(machine, IPT_UI_CANCEL)) | |
| 7031 | 7031 | sel = -1; |
| 7032 | 7032 | |
| 7033 | 7033 | return sel + 1; |
| r2724 | r2725 | |
| 7195 | 7195 | if(ShiftKeyPressed()) |
| 7196 | 7196 | increment <<= 16; |
| 7197 | 7197 | |
| 7198 | if(UIPressedRepeatThrottle(IPT_UI_LEFT, kHorizontalSlowKeyRepeatRate)) | |
| 7198 | if(UIPressedRepeatThrottle(machine, IPT_UI_LEFT, kHorizontalSlowKeyRepeatRate)) | |
| 7199 | 7199 | { |
| 7200 | 7200 | editActive = 0; |
| 7201 | 7201 | |
| r2724 | r2725 | |
| 7296 | 7296 | } |
| 7297 | 7297 | } |
| 7298 | 7298 | |
| 7299 | if(UIPressedRepeatThrottle(IPT_UI_RIGHT, kHorizontalSlowKeyRepeatRate)) | |
| 7299 | if(UIPressedRepeatThrottle(machine, IPT_UI_RIGHT, kHorizontalSlowKeyRepeatRate)) | |
| 7300 | 7300 | { |
| 7301 | 7301 | editActive = 0; |
| 7302 | 7302 | |
| r2724 | r2725 | |
| 7389 | 7389 | } |
| 7390 | 7390 | } |
| 7391 | 7391 | |
| 7392 | if(UIPressedRepeatThrottle(IPT_UI_DOWN, kVerticalKeyRepeatRate)) | |
| 7392 | if(UIPressedRepeatThrottle(machine, IPT_UI_DOWN, kVerticalKeyRepeatRate)) | |
| 7393 | 7393 | { |
| 7394 | 7394 | sel++; |
| 7395 | 7395 | |
| r2724 | r2725 | |
| 7399 | 7399 | editActive = 0; |
| 7400 | 7400 | } |
| 7401 | 7401 | |
| 7402 | if(UIPressedRepeatThrottle(IPT_UI_UP, kVerticalKeyRepeatRate)) | |
| 7402 | if(UIPressedRepeatThrottle(machine, IPT_UI_UP, kVerticalKeyRepeatRate)) | |
| 7403 | 7403 | { |
| 7404 | 7404 | sel--; |
| 7405 | 7405 | |
| r2724 | r2725 | |
| 7409 | 7409 | editActive = 0; |
| 7410 | 7410 | } |
| 7411 | 7411 | |
| 7412 | if(UIPressedRepeatThrottle(IPT_UI_PAGE_UP, kVerticalKeyRepeatRate)) | |
| 7412 | if(UIPressedRepeatThrottle(machine, IPT_UI_PAGE_UP, kVerticalKeyRepeatRate)) | |
| 7413 | 7413 | { |
| 7414 | 7414 | sel -= fullMenuPageHeight; |
| 7415 | 7415 | |
| r2724 | r2725 | |
| 7419 | 7419 | editActive = 0; |
| 7420 | 7420 | } |
| 7421 | 7421 | |
| 7422 | if(UIPressedRepeatThrottle(IPT_UI_PAGE_DOWN, kVerticalKeyRepeatRate)) | |
| 7422 | if(UIPressedRepeatThrottle(machine, IPT_UI_PAGE_DOWN, kVerticalKeyRepeatRate)) | |
| 7423 | 7423 | { |
| 7424 | 7424 | sel += fullMenuPageHeight; |
| 7425 | 7425 | |
| r2724 | r2725 | |
| 7429 | 7429 | editActive = 0; |
| 7430 | 7430 | } |
| 7431 | 7431 | |
| 7432 | if(input_ui_pressed(IPT_UI_SELECT)) | |
| 7432 | if(input_ui_pressed(machine, IPT_UI_SELECT)) | |
| 7433 | 7433 | { |
| 7434 | 7434 | if(editActive) |
| 7435 | 7435 | editActive = 0; |
| r2724 | r2725 | |
| 7463 | 7463 | { |
| 7464 | 7464 | case kMenu_Address: |
| 7465 | 7465 | entry->address = DoShift(entry->address, entry->addressShift); |
| 7466 | entry->address = DoEditHexField(entry->address); | |
| 7466 | entry->address = DoEditHexField(machine, entry->address); | |
| 7467 | 7467 | entry->address = DoShift(entry->address, -entry->addressShift); |
| 7468 | 7468 | entry->address &= cpuInfoList[entry->cpu].addressMask; |
| 7469 | 7469 | break; |
| r2724 | r2725 | |
| 7502 | 7502 | break; |
| 7503 | 7503 | |
| 7504 | 7504 | case kMenu_XOR: |
| 7505 | entry->xor = DoEditHexField(entry->xor); | |
| 7505 | entry->xor = DoEditHexField(machine, entry->xor); | |
| 7506 | 7506 | entry->xor &= kSearchByteMaskTable[kWatchSizeConversionTable[entry->elementBytes]]; |
| 7507 | 7507 | break; |
| 7508 | 7508 | } |
| 7509 | 7509 | |
| 7510 | if(input_ui_pressed(IPT_UI_CANCEL)) | |
| 7510 | if(input_ui_pressed(machine, IPT_UI_CANCEL)) | |
| 7511 | 7511 | editActive = 0; |
| 7512 | 7512 | } |
| 7513 | 7513 | else |
| 7514 | 7514 | { |
| 7515 | if(input_ui_pressed(IPT_UI_ADD_CHEAT)) | |
| 7515 | if(input_ui_pressed(machine, IPT_UI_ADD_CHEAT)) | |
| 7516 | 7516 | AddCheatFromWatch(entry); |
| 7517 | 7517 | |
| 7518 | if(input_ui_pressed(IPT_UI_DELETE_CHEAT)) | |
| 7518 | if(input_ui_pressed(machine, IPT_UI_DELETE_CHEAT)) | |
| 7519 | 7519 | entry->numElements = 0; |
| 7520 | 7520 | |
| 7521 | if(input_ui_pressed(IPT_UI_SAVE_CHEAT)) | |
| 7521 | if(input_ui_pressed(machine, IPT_UI_SAVE_CHEAT)) | |
| 7522 | 7522 | { |
| 7523 | 7523 | CheatEntry tempEntry; |
| 7524 | 7524 | |
| r2724 | r2725 | |
| 7530 | 7530 | } |
| 7531 | 7531 | } |
| 7532 | 7532 | |
| 7533 | if(input_ui_pressed(IPT_UI_CANCEL)) | |
| 7533 | if(input_ui_pressed(machine, IPT_UI_CANCEL)) | |
| 7534 | 7534 | sel = -1; |
| 7535 | 7535 | |
| 7536 | 7536 | return sel + 1; |
| r2724 | r2725 | |
| 7630 | 7630 | old_style_menu(menuItem, menuSubItem, NULL, sel, 0); |
| 7631 | 7631 | |
| 7632 | 7632 | /********** KEY HANDLING **********/ |
| 7633 | if(UIPressedRepeatThrottle(IPT_UI_RIGHT, kHorizontalSlowKeyRepeatRate)) | |
| 7633 | if(UIPressedRepeatThrottle(machine, IPT_UI_RIGHT, kHorizontalSlowKeyRepeatRate)) | |
| 7634 | 7634 | { |
| 7635 | 7635 | switch(sel) |
| 7636 | 7636 | { |
| r2724 | r2725 | |
| 7667 | 7667 | } |
| 7668 | 7668 | } |
| 7669 | 7669 | |
| 7670 | if(UIPressedRepeatThrottle(IPT_UI_LEFT, kHorizontalSlowKeyRepeatRate)) | |
| 7670 | if(UIPressedRepeatThrottle(machine, IPT_UI_LEFT, kHorizontalSlowKeyRepeatRate)) | |
| 7671 | 7671 | { |
| 7672 | 7672 | switch(sel) |
| 7673 | 7673 | { |
| r2724 | r2725 | |
| 7704 | 7704 | } |
| 7705 | 7705 | } |
| 7706 | 7706 | |
| 7707 | if(UIPressedRepeatThrottle(IPT_UI_DOWN, kVerticalKeyRepeatRate)) | |
| 7707 | if(UIPressedRepeatThrottle(machine, IPT_UI_DOWN, kVerticalKeyRepeatRate)) | |
| 7708 | 7708 | { |
| 7709 | 7709 | if(sel < (kMenu_Max - 1)) |
| 7710 | 7710 | sel++; |
| r2724 | r2725 | |
| 7712 | 7712 | sel = 0; |
| 7713 | 7713 | } |
| 7714 | 7714 | |
| 7715 | if(UIPressedRepeatThrottle(IPT_UI_UP, kVerticalKeyRepeatRate)) | |
| 7715 | if(UIPressedRepeatThrottle(machine, IPT_UI_UP, kVerticalKeyRepeatRate)) | |
| 7716 | 7716 | { |
| 7717 | 7717 | if(sel > 0) |
| 7718 | 7718 | sel--; |
| r2724 | r2725 | |
| 7720 | 7720 | sel = kMenu_Max - 1; |
| 7721 | 7721 | } |
| 7722 | 7722 | |
| 7723 | if(input_ui_pressed(IPT_UI_SELECT)) | |
| 7723 | if(input_ui_pressed(machine, IPT_UI_SELECT)) | |
| 7724 | 7724 | { |
| 7725 | 7725 | switch(sel) |
| 7726 | 7726 | { |
| r2724 | r2725 | |
| 7735 | 7735 | } |
| 7736 | 7736 | } |
| 7737 | 7737 | |
| 7738 | if(input_ui_pressed(IPT_UI_SAVE_CHEAT)) | |
| 7738 | if(input_ui_pressed(machine, IPT_UI_SAVE_CHEAT)) | |
| 7739 | 7739 | { |
| 7740 | 7740 | SaveCheat(machine, NULL, 0, 2); |
| 7741 | 7741 | |
| 7742 | 7742 | ui_popup_time(1, "command code saved"); |
| 7743 | 7743 | } |
| 7744 | 7744 | |
| 7745 | if(input_ui_pressed(IPT_UI_RELOAD_CHEAT)) | |
| 7745 | if(input_ui_pressed(machine, IPT_UI_RELOAD_CHEAT)) | |
| 7746 | 7746 | ReloadCheatDatabase(machine); |
| 7747 | 7747 | |
| 7748 | if(input_ui_pressed(IPT_UI_CANCEL)) | |
| 7748 | if(input_ui_pressed(machine, IPT_UI_CANCEL)) | |
| 7749 | 7749 | sel = -1; |
| 7750 | 7750 | |
| 7751 | 7751 | return sel + 1; |
| r2724 | r2725 | |
| 7808 | 7808 | old_style_menu(menuItem, NULL, NULL, sel, 0); |
| 7809 | 7809 | |
| 7810 | 7810 | /********** KEY HANDLING **********/ |
| 7811 | if(UIPressedRepeatThrottle(IPT_UI_DOWN, kVerticalKeyRepeatRate)) | |
| 7811 | if(UIPressedRepeatThrottle(machine, IPT_UI_DOWN, kVerticalKeyRepeatRate)) | |
| 7812 | 7812 | { |
| 7813 | 7813 | sel++; |
| 7814 | 7814 | |
| r2724 | r2725 | |
| 7816 | 7816 | sel = 0; |
| 7817 | 7817 | } |
| 7818 | 7818 | |
| 7819 | if(UIPressedRepeatThrottle(IPT_UI_UP, kVerticalKeyRepeatRate)) | |
| 7819 | if(UIPressedRepeatThrottle(machine, IPT_UI_UP, kVerticalKeyRepeatRate)) | |
| 7820 | 7820 | { |
| 7821 | 7821 | sel--; |
| 7822 | 7822 | |
| r2724 | r2725 | |
| 7824 | 7824 | sel = total - 1; |
| 7825 | 7825 | } |
| 7826 | 7826 | |
| 7827 | if(UIPressedRepeatThrottle(IPT_UI_PAGE_UP, kVerticalKeyRepeatRate)) | |
| 7827 | if(UIPressedRepeatThrottle(machine, IPT_UI_PAGE_UP, kVerticalKeyRepeatRate)) | |
| 7828 | 7828 | { |
| 7829 | 7829 | sel -= fullMenuPageHeight; |
| 7830 | 7830 | |
| r2724 | r2725 | |
| 7832 | 7832 | sel = 0; |
| 7833 | 7833 | } |
| 7834 | 7834 | |
| 7835 | if(UIPressedRepeatThrottle(IPT_UI_PAGE_DOWN, kVerticalKeyRepeatRate)) | |
| 7835 | if(UIPressedRepeatThrottle(machine, IPT_UI_PAGE_DOWN, kVerticalKeyRepeatRate)) | |
| 7836 | 7836 | { |
| 7837 | 7837 | sel += fullMenuPageHeight; |
| 7838 | 7838 | |
| r2724 | r2725 | |
| 7840 | 7840 | sel = total - 1; |
| 7841 | 7841 | } |
| 7842 | 7842 | |
| 7843 | if(input_ui_pressed(IPT_UI_ADD_CHEAT)) | |
| 7843 | if(input_ui_pressed(machine, IPT_UI_ADD_CHEAT)) | |
| 7844 | 7844 | { |
| 7845 | 7845 | AddSearchBefore(sel); |
| 7846 | 7846 | |
| r2724 | r2725 | |
| 7848 | 7848 | AllocateSearchRegions(&searchList[sel]); |
| 7849 | 7849 | } |
| 7850 | 7850 | |
| 7851 | if(input_ui_pressed(IPT_UI_DELETE_CHEAT)) | |
| 7851 | if(input_ui_pressed(machine, IPT_UI_DELETE_CHEAT)) | |
| 7852 | 7852 | { |
| 7853 | 7853 | if(searchListLength > 1) |
| 7854 | 7854 | DeleteSearchAt(sel); |
| 7855 | 7855 | } |
| 7856 | 7856 | |
| 7857 | if(input_ui_pressed(IPT_UI_EDIT_CHEAT)) | |
| 7857 | if(input_ui_pressed(machine, IPT_UI_EDIT_CHEAT)) | |
| 7858 | 7858 | { |
| 7859 | 7859 | if(sel < total - 1) |
| 7860 | 7860 | currentSearchIdx = sel; |
| 7861 | 7861 | } |
| 7862 | 7862 | |
| 7863 | if(input_ui_pressed(IPT_UI_SELECT)) | |
| 7863 | if(input_ui_pressed(machine, IPT_UI_SELECT)) | |
| 7864 | 7864 | { |
| 7865 | 7865 | if(sel >= total - 1) |
| 7866 | 7866 | sel = -1; |
| r2724 | r2725 | |
| 7868 | 7868 | currentSearchIdx = sel; |
| 7869 | 7869 | } |
| 7870 | 7870 | |
| 7871 | if(input_ui_pressed(IPT_UI_CANCEL)) | |
| 7871 | if(input_ui_pressed(machine, IPT_UI_CANCEL)) | |
| 7872 | 7872 | sel = -1; |
| 7873 | 7873 | |
| 7874 | 7874 | return sel + 1; |
| r2724 | r2725 | |
| 7882 | 7882 | { |
| 7883 | 7883 | int i; |
| 7884 | 7884 | |
| 7885 | if(input_ui_pressed(IPT_UI_TOGGLE_CHEAT)) | |
| 7885 | if(input_ui_pressed(machine, IPT_UI_TOGGLE_CHEAT)) | |
| 7886 | 7886 | { |
| 7887 | 7887 | if(ShiftKeyPressed()) |
| 7888 | 7888 | { |
| r2724 | r2725 | |
|---|---|---|
| 947 | 947 | |
| 948 | 948 | |
| 949 | 949 | /*------------------------------------------------- |
| 950 | display_valid_coin_order - display the | |
| 951 | correct coin order | |
| 950 | get_defstr_index - return the index of the | |
| 951 | string assuming it is one of the default | |
| 952 | strings | |
| 952 | 953 | -------------------------------------------------*/ |
| 953 | 954 | |
| 954 | static | |
| 955 | static | |
| 955 | 956 | { |
| 956 | const game_driver *driver = drivers[drivnum]; | |
| 957 | const input_port_entry *inp; | |
| 958 | int coin_list[1024]; | |
| 959 | int coin_len = 0; | |
| 960 | int i, j; | |
| 957 | UINT32 crc = quark_string_crc(name); | |
| 961 | 958 | quark_entry *entry; |
| 959 | int strindex = 0; | |
| 962 | 960 | |
| 963 | for (inp = memory; inp->type != IPT_END; inp++) | |
| 964 | { | |
| 965 | int strindex = 0; | |
| 966 | UINT32 crc; | |
| 967 | ||
| 968 | if ( !inp->name || inp->name == IP_NAME_DEFAULT ) | |
| 969 | continue; | |
| 970 | ||
| 971 | /* hash the string and look it up in the string table */ | |
| 972 | crc = quark_string_crc(inp->name); | |
| 973 | for (entry = quark_table_get_first(defstr_table, crc); entry; entry = entry->next) | |
| 974 | if (entry->crc == crc && !strcmp(inp->name, input_port_string_from_index(entry - defstr_table->entry))) | |
| 975 | { | |
| 976 | strindex = entry - defstr_table->entry; | |
| 977 | break; | |
| 978 | } | |
| 979 | ||
| 980 | /* if its a coin entry, add it to our list, avoiding repetitions */ | |
| 981 | if ( strindex >= INPUT_STRING_9C_1C && strindex <= INPUT_STRING_1C_9C ) | |
| 961 | /* scan the quark table of input port strings */ | |
| 962 | for (entry = quark_table_get_first(defstr_table, crc); entry != NULL; entry = entry->next) | |
| 963 | if (entry->crc == crc && strcmp(name, input_port_string_from_index(entry - defstr_table->entry)) == 0) | |
| 982 | 964 | { |
| 983 | j = 1; | |
| 984 | ||
| 985 | for( i = 0; i < coin_len; i++ ) | |
| 986 | { | |
| 987 | if ( coin_list[i] == strindex ) | |
| 988 | { | |
| 989 | j = 0; | |
| 990 | break; | |
| 991 | } | |
| 992 | } | |
| 993 | ||
| 994 | if ( j ) | |
| 995 | coin_list[coin_len++] = strindex; | |
| 965 | strindex = entry - defstr_table->entry; | |
| 966 | break; | |
| 996 | 967 | } |
| 968 | ||
| 969 | /* check for strings that should be DEF_STR */ | |
| 970 | if (strindex != 0 && name != input_port_string_from_index(strindex) && error != NULL) | |
| 971 | { | |
| 972 | mame_printf_error("%s: %s must use DEF_STR( %s )\n", driver->source_file, driver->name, name); | |
| 973 | *error = TRUE; | |
| 997 | 974 | } |
| 998 | 975 | |
| 999 | /* now display the proper coin entry list */ | |
| 1000 | mame_printf_error( "%s: %s proper coin sort order should be:\n", driver->source_file, driver->name ); | |
| 1001 | for (i = INPUT_STRING_9C_1C; i <= INPUT_STRING_1C_9C; i++) | |
| 1002 | for (j = 0; j < coin_len; j++) | |
| 1003 | /* if it's on our list, display it */ | |
| 1004 | if (coin_list[j] == i) | |
| 1005 | mame_printf_error("%s\n", input_port_string_from_index(i)); | |
| 976 | return strindex; | |
| 1006 | 977 | } |
| 1007 | 978 | |
| 1008 | 979 | |
| 1009 | 980 | /*------------------------------------------------- |
| 1010 | validate_inputs - validate input configuration | |
| 981 | validate_analog_input_field - validate an | |
| 982 | analog input field | |
| 1011 | 983 | -------------------------------------------------*/ |
| 1012 | 984 | |
| 1013 | static i | |
| 985 | static void | |
| 1014 | 986 | { |
| 1015 | const char *demo_sounds = input_port_string_from_index(INPUT_STRING_Demo_Sounds); | |
| 1016 | const char *flipscreen = input_port_string_from_index(INPUT_STRING_Flip_Screen); | |
| 1017 | const input_port_entry *inp, *last_dipname_entry = NULL; | |
| 1018 | const game_driver *driver = drivers[drivnum]; | |
| 1019 | const char *tag[MAX_INPUT_PORTS] = { 0 }; | |
| 1020 | int portnum = 0; | |
| 1021 | int empty_string_found = FALSE; | |
| 1022 | int last_strindex = 0; | |
| 1023 | quark_entry *entry; | |
| 1024 | int error = FALSE; | |
| 1025 | int coin_error = FALSE; | |
| 1026 | UINT32 crc; | |
| 987 | INT32 analog_max = field->max; | |
| 988 | INT32 analog_min = field->min; | |
| 989 | int shift; | |
| 1027 | 990 | |
| 1028 | /* skip if no ports */ | |
| 1029 | if (!driver->ipt) | |
| 1030 | return FALSE; | |
| 991 | if (field->type == IPT_POSITIONAL || field->type == IPT_POSITIONAL_V) | |
| 992 | { | |
| 993 | for (shift = 0; (shift <= 31) && (~field->mask & (1 << shift)); shift++) ; | |
| 994 | /* convert the positional max value to be in the bitmask for testing */ | |
| 995 | analog_max = (analog_max - 1) << shift; | |
| 1031 | 996 | |
| 1032 | /* skip if we already validated these ports */ | |
| 1033 | crc = (FPTR)driver->ipt; | |
| 1034 | for (entry = quark_table_get_first(inputs_table, crc); entry; entry = entry->next) | |
| 1035 | if (entry->crc == crc && driver->ipt == drivers[entry - inputs_table->entry]->ipt) | |
| 1036 | return FALSE; | |
| 997 | /* positional port size must fit in bits used */ | |
| 998 | if (((field->mask >> shift) + 1) < field->max) | |
| 999 | { | |
| 1000 | mame_printf_error("%s: %s has an analog port with a positional port size bigger then the mask size\n", driver->source_file, driver->name); | |
| 1001 | *error = TRUE; | |
| 1002 | } | |
| 1003 | } | |
| 1004 | else | |
| 1005 | { | |
| 1006 | /* only positional controls use PORT_WRAPS */ | |
| 1007 | if (field->flags & ANALOG_FLAG_WRAPS) | |
| 1008 | { | |
| 1009 | mame_printf_error("%s: %s only positional analog ports use PORT_WRAPS\n", driver->source_file, driver->name); | |
| 1010 | *error = TRUE; | |
| 1011 | } | |
| 1012 | } | |
| 1037 | 1013 | |
| 1038 | /* otherwise, add ourself to the list */ | |
| 1039 | quark_add(inputs_table, drivnum, crc); | |
| 1014 | /* analog ports must have a valid sensitivity */ | |
| 1015 | if (field->sensitivity == 0) | |
| 1016 | { | |
| 1017 | mame_printf_error("%s: %s has an analog port with zero sensitivity\n", driver->source_file, driver->name); | |
| 1018 | *error = TRUE; | |
| 1019 | } | |
| 1040 | 1020 | |
| 1041 | /* allocate the input ports */ | |
| 1042 | *memory = input_port_allocate(driver->ipt, *memory); | |
| 1021 | /* check that the default falls in the bitmask range */ | |
| 1022 | if (field->defvalue & ~field->mask) | |
| 1023 | { | |
| 1024 | mame_printf_error("%s: %s has an analog port with a default value out of the bitmask range\n", driver->source_file, driver->name); | |
| 1025 | *error = TRUE; | |
| 1026 | } | |
| 1043 | 1027 | |
| 1044 | /* iterate over the results */ | |
| 1045 | for (inp = *memory; inp->type != IPT_END; inp++) | |
| 1028 | /* tests for absolute devices */ | |
| 1029 | if (field->type >= __ipt_analog_absolute_start && field->type <= __ipt_analog_absolute_end) | |
| 1046 | 1030 | { |
| 1047 | | |
| 1031 | INT32 | |
| 1048 | 1032 | |
| 1049 | /* check for duplicate tags */ | |
| 1050 | if (inp->type == IPT_PORT) | |
| 1033 | /* adjust for signed values */ | |
| 1034 | if (analog_min > analog_max) | |
| 1051 | 1035 | { |
| 1052 | if (inp->start.tag != NULL && portnum < ARRAY_LENGTH(tag)) | |
| 1053 | { | |
| 1054 | int scanport; | |
| 1036 | analog_min = -analog_min; | |
| 1037 | if (default_value > analog_max) | |
| 1038 | default_value = -default_value; | |
| 1039 | } | |
| 1055 | 1040 | |
| 1056 | for (scanport = 0; scanport < portnum - 1; scanport++) | |
| 1057 | if (strcmp(inp->start.tag, tag[scanport]) == 0) | |
| 1058 | { | |
| 1059 | mame_printf_error("%s: %s has a duplicate input port tag \"%s\"\n", driver->source_file, driver->name, inp->start.tag); | |
| 1060 | error = TRUE; | |
| 1061 | } | |
| 1062 | tag[portnum++] = inp->start.tag; | |
| 1063 | } | |
| 1064 | continue; | |
| 1041 | /* check that the default falls in the MINMAX range */ | |
| 1042 | if (default_value < analog_min || default_value > analog_max) | |
| 1043 | { | |
| 1044 | mame_printf_error("%s: %s has an analog port with a default value out PORT_MINMAX range\n", driver->source_file, driver->name); | |
| 1045 | *error = TRUE; | |
| 1065 | 1046 | } |
| 1066 | 1047 | |
| 1067 | if (port_type_is_analog(inp->type)) | |
| 1048 | /* check that the MINMAX falls in the bitmask range */ | |
| 1049 | /* we use the unadjusted min for testing */ | |
| 1050 | if (field->min & ~field->mask || analog_max & ~field->mask) | |
| 1068 | 1051 | { |
| 1069 | INT32 analog_max = inp->analog.max; | |
| 1070 | INT32 analog_min = inp->analog.min; | |
| 1071 | int shift; | |
| 1052 | mame_printf_error("%s: %s has an analog port with a PORT_MINMAX value out of the bitmask range\n", driver->source_file, driver->name); | |
| 1053 | *error = TRUE; | |
| 1054 | } | |
| 1072 | 1055 | |
| 1073 | if (inp->type == IPT_POSITIONAL || inp->type == IPT_POSITIONAL_V) | |
| 1074 | { | |
| 1075 | for (shift = 0; (shift <= 31) && (~inp->mask & (1 << shift)); shift++); | |
| 1076 | /* convert the positional max value to be in the bitmask for testing */ | |
| 1077 | analog_max = (analog_max - 1) << shift; | |
| 1056 | /* absolute analog ports do not use PORT_RESET */ | |
| 1057 | if (field->flags & ANALOG_FLAG_RESET) | |
| 1058 | { | |
| 1059 | mame_printf_error("%s: %s - absolute analog ports do not use PORT_RESET\n", driver->source_file, driver->name); | |
| 1060 | *error = TRUE; | |
| 1061 | } | |
| 1062 | } | |
| 1078 | 1063 | |
| 1079 | /* positional port size must fit in bits used */ | |
| 1080 | if (((inp->mask >> shift) + 1) < inp->analog.max) | |
| 1081 | { | |
| 1082 | mame_printf_error("%s: %s has an analog port with a positional port size bigger then the mask size\n", driver->source_file, driver->name); | |
| 1083 | error = TRUE; | |
| 1084 | } | |
| 1085 | } | |
| 1086 | else | |
| 1064 | /* tests for relative devices */ | |
| 1065 | else | |
| 1066 | { | |
| 1067 | /* tests for non IPT_POSITIONAL relative devices */ | |
| 1068 | if (field->type != IPT_POSITIONAL && field->type != IPT_POSITIONAL_V) | |
| 1069 | { | |
| 1070 | /* relative devices do not use PORT_MINMAX */ | |
| 1071 | if (field->min != 0 || field->max != field->mask) | |
| 1087 | 1072 | { |
| 1088 | /* only positional controls use PORT_WRAPS */ | |
| 1089 | if (inp->analog.wraps) | |
| 1090 | { | |
| 1091 | mame_printf_error("%s: %s only positional analog ports use PORT_WRAPS\n", driver->source_file, driver->name); | |
| 1092 | error = TRUE; | |
| 1093 | } | |
| 1073 | mame_printf_error("%s: %s - relative ports do not use PORT_MINMAX\n", driver->source_file, driver->name); | |
| 1074 | *error = TRUE; | |
| 1094 | 1075 | } |
| 1095 | 1076 | |
| 1096 | ||
| 1097 | /* analog ports must have a valid sensitivity */ | |
| 1098 | if (inp->analog.sensitivity == 0) | |
| 1077 | /* relative devices do not use a default value */ | |
| 1078 | /* the counter is at 0 on power up */ | |
| 1079 | if (field->defvalue != 0) | |
| 1099 | 1080 | { |
| 1100 | mame_printf_error("%s: %s has an analog port with zero sensitivity\n", driver->source_file, driver->name); | |
| 1101 | error = TRUE; | |
| 1081 | mame_printf_error("%s: %s - relative ports do not use a default value other then 0\n", driver->source_file, driver->name); | |
| 1082 | *error = TRUE; | |
| 1102 | 1083 | } |
| 1084 | } | |
| 1085 | } | |
| 1086 | } | |
| 1103 | 1087 | |
| 1104 | /* check that the default falls in the bitmask range */ | |
| 1105 | if (inp->default_value & ~inp->mask) | |
| 1106 | { | |
| 1107 | mame_printf_error("%s: %s has an analog port with a default value out of the bitmask range\n", driver->source_file, driver->name); | |
| 1108 | error = TRUE; | |
| 1109 | } | |
| 1110 | 1088 | |
| 1111 | /* tests for absolute devices */ | |
| 1112 | if (port_type_is_analog_absolute(inp->type)) | |
| 1113 | { | |
| 1114 | INT32 default_value = inp->default_value; | |
| 1089 | /*------------------------------------------------- | |
| 1090 | validate_dip_settings - validate a DIP switch | |
| 1091 | setting | |
| 1092 | -------------------------------------------------*/ | |
| 1115 | 1093 | |
| 1116 | /* adjust for signed values */ | |
| 1117 | if (analog_min > analog_max) | |
| 1118 | { | |
| 1119 | analog_min = -analog_min; | |
| 1120 | if (default_value > analog_max) | |
| 1121 | default_value = -default_value; | |
| 1122 | } | |
| 1094 | static void validate_dip_settings(const input_field_config *field, const game_driver *driver, int *error) | |
| 1095 | { | |
| 1096 | const char *demo_sounds = input_port_string_from_index(INPUT_STRING_Demo_Sounds); | |
| 1097 | const char *flipscreen = input_port_string_from_index(INPUT_STRING_Flip_Screen); | |
| 1098 | UINT8 coin_list[INPUT_STRING_1C_9C + 1 - INPUT_STRING_9C_1C] = { 0 }; | |
| 1099 | const input_setting_config *setting; | |
| 1100 | int coin_error = FALSE; | |
| 1123 | 1101 | |
| 1124 | /* check that the default falls in the MINMAX range */ | |
| 1125 | if (default_value < analog_min || default_value > analog_max) | |
| 1126 | { | |
| 1127 | mame_printf_error("%s: %s has an analog port with a default value out PORT_MINMAX range\n", driver->source_file, driver->name); | |
| 1128 | error = TRUE; | |
| 1129 | } | |
| 1102 | /* iterate through the settings */ | |
| 1103 | for (setting = field->settinglist; setting != NULL; setting = setting->next) | |
| 1104 | { | |
| 1105 | int strindex = get_defstr_index(setting->name, driver, error); | |
| 1130 | 1106 | |
| 1131 | /* check that the MINMAX falls in the bitmask range */ | |
| 1132 | /* we use the unadjusted min for testing */ | |
| 1133 | if (inp->analog.min & ~inp->mask || analog_max & ~inp->mask) | |
| 1134 | { | |
| 1135 | mame_printf_error("%s: %s has an analog port with a PORT_MINMAX value out of the bitmask range\n", driver->source_file, driver->name); | |
| 1136 | error = TRUE; | |
| 1137 | } | |
| 1107 | /* note any coinage strings */ | |
| 1108 | if (strindex >= INPUT_STRING_9C_1C && strindex <= INPUT_STRING_1C_9C) | |
| 1109 | coin_list[strindex - INPUT_STRING_9C_1C] = 1; | |
| 1138 | 1110 | |
| 1139 | /* absolute analog ports do not use PORT_RESET */ | |
| 1140 | if (inp->analog.reset) | |
| 1141 | { | |
| 1142 | mame_printf_error("%s: %s - absolute analog ports do not use PORT_RESET\n", driver->source_file, driver->name); | |
| 1143 | error = TRUE; | |
| 1144 | } | |
| 1145 | } | |
| 1146 | else | |
| 1147 | /* tests for relative devices */ | |
| 1148 | { | |
| 1149 | /* tests for non IPT_POSITIONAL relative devices */ | |
| 1150 | if (inp->type != IPT_POSITIONAL && inp->type != IPT_POSITIONAL_V) | |
| 1151 | { | |
| 1152 | /* relative devices do not use PORT_MINMAX */ | |
| 1153 | if (inp->analog.min || inp->analog.max != inp->mask) | |
| 1154 | { | |
| 1155 | mame_printf_error("%s: %s - relative ports do not use PORT_MINMAX\n", driver->source_file, driver->name); | |
| 1156 | error = TRUE; | |
| 1157 | } | |
| 1158 | ||
| 1159 | /* relative devices do not use a default value */ | |
| 1160 | /* the counter is at 0 on power up */ | |
| 1161 | if (inp->default_value) | |
| 1162 | { | |
| 1163 | mame_printf_error("%s: %s - relative ports do not use a default value other then 0\n", driver->source_file, driver->name); | |
| 1164 | error = TRUE; | |
| 1165 | } | |
| 1166 | } | |
| 1167 | } | |
| 1168 | } | |
| 1169 | ||
| 1170 | /* clear the DIP switch tracking when we hit the first non-DIP entry */ | |
| 1171 | if (last_dipname_entry != NULL && inp->type != IPT_DIPSWITCH_SETTING) | |
| 1172 | last_dipname_entry = NULL; | |
| 1173 | ||
| 1174 | /* look for invalid (0) types which should be mapped to IPT_OTHER */ | |
| 1175 | if (inp->type == IPT_INVALID) | |
| 1111 | /* make sure demo sounds default to on */ | |
| 1112 | if (field->name == demo_sounds && strindex == INPUT_STRING_On && field->defvalue != setting->value) | |
| 1176 | 1113 | { |
| 1177 | mame_printf_error("%s: %s has an input port with an invalid type (0); use IPT_OTHER instead\n", driver->source_file, driver->name); | |
| 1178 | error = TRUE; | |
| 1114 | mame_printf_error("%s: %s Demo Sounds must default to On\n", driver->source_file, driver->name); | |
| 1115 | *error = TRUE; | |
| 1179 | 1116 | } |
| 1180 | 1117 | |
| 1181 | /* if this entry doesn't have a name, we don't care about the rest of this stuff */ | |
| 1182 | if (inp->name == NULL || inp->name == IP_NAME_DEFAULT) | |
| 1118 | /* check for bad demo sounds options */ | |
| 1119 | if (field->name == demo_sounds && (strindex == INPUT_STRING_Yes || strindex == INPUT_STRING_No)) | |
| 1183 | 1120 | { |
| 1184 | /* not allowed for dipswitches */ | |
| 1185 | if (inp->type == IPT_DIPSWITCH_NAME || inp->type == IPT_DIPSWITCH_SETTING) | |
| 1186 | { | |
| 1187 | mame_printf_error("%s: %s has a DIP switch name or setting with no name\n", driver->source_file, driver->name); | |
| 1188 | error = TRUE; | |
| 1189 | } | |
| 1190 | last_strindex = 0; | |
| 1191 | continue; | |
| 1121 | mame_printf_error("%s: %s has wrong Demo Sounds option %s (must be Off/On)\n", driver->source_file, driver->name, setting->name); | |
| 1122 | *error = TRUE; | |
| 1192 | 1123 | } |
| 1193 | 1124 | |
| 1194 | /* check for empty string */ | |
| 1195 | if (inp->name[0] == 0 && !empty_string_found) | |
| 1125 | /* check for bad flip screen options */ | |
| 1126 | if (field->name == flipscreen && (strindex == INPUT_STRING_Yes || strindex == INPUT_STRING_No)) | |
| 1196 | 1127 | { |
| 1197 | mame_printf_error("%s: %s has an input with an empty string\n", driver->source_file, driver->name); | |
| 1198 | error = TRUE; | |
| 1199 | empty_string_found = TRUE; | |
| 1128 | mame_printf_error("%s: %s has wrong Flip Screen option %s (must be Off/On)\n", driver->source_file, driver->name, setting->name); | |
| 1129 | *error = TRUE; | |
| 1200 | 1130 | } |
| 1201 | 1131 | |
| 1202 | /* check for trailing spaces */ | |
| 1203 | if (inp->name[0] != 0 && inp->name[strlen(inp->name) - 1] == ' ') | |
| 1132 | /* if we have a neighbor, compare ourselves to him */ | |
| 1133 | if (setting->next != NULL) | |
| 1204 | 1134 | { |
| 1205 | mame_printf_error("%s: %s input '%s' has trailing spaces\n", driver->source_file, driver->name, inp->name); | |
| 1206 | error = TRUE; | |
| 1207 | } | |
| 1135 | int next_strindex = get_defstr_index(setting->next->name, driver, error); | |
| 1208 | 1136 | |
| 1209 | /* check for invalid UTF-8 */ | |
| 1210 | if (!utf8_is_valid_string(inp->name)) | |
| 1211 | { | |
| 1212 | mame_printf_error("%s: %s input '%s' has invalid characters\n", driver->source_file, driver->name, inp->name); | |
| 1213 | error = TRUE; | |
| 1214 | } | |
| 1215 | ||
| 1216 | /* hash the string and look it up in the string table */ | |
| 1217 | crc = quark_string_crc(inp->name); | |
| 1218 | for (entry = quark_table_get_first(defstr_table, crc); entry; entry = entry->next) | |
| 1219 | if (entry->crc == crc && !strcmp(inp->name, input_port_string_from_index(entry - defstr_table->entry))) | |
| 1220 | { | |
| 1221 | strindex = entry - defstr_table->entry; | |
| 1222 | break; | |
| 1223 | } | |
| 1224 | ||
| 1225 | /* check for strings that should be DEF_STR */ | |
| 1226 | if (strindex != 0 && inp->name != input_port_string_from_index(strindex)) | |
| 1227 | { | |
| 1228 | mame_printf_error("%s: %s must use DEF_STR( %s )\n", driver->source_file, driver->name, inp->name); | |
| 1229 | error = TRUE; | |
| 1230 | } | |
| 1231 | ||
| 1232 | /* track the last dipswitch we encountered */ | |
| 1233 | if (inp->type == IPT_DIPSWITCH_NAME) | |
| 1234 | last_dipname_entry = inp; | |
| 1235 | ||
| 1236 | /* check for dipswitch ordering against the last entry */ | |
| 1237 | if (inp[0].type == IPT_DIPSWITCH_SETTING && inp[-1].type == IPT_DIPSWITCH_SETTING && last_strindex != 0 && strindex != 0) | |
| 1238 | { | |
| 1239 | 1137 | /* check for inverted off/on dispswitch order */ |
| 1240 | if ( | |
| 1138 | if ( | |
| 1241 | 1139 | { |
| 1242 | 1140 | mame_printf_error("%s: %s has inverted Off/On dipswitch order\n", driver->source_file, driver->name); |
| 1243 | error = TRUE; | |
| 1141 | *error = TRUE; | |
| 1244 | 1142 | } |
| 1245 | 1143 | |
| 1246 | 1144 | /* check for inverted yes/no dispswitch order */ |
| 1247 | else if ( | |
| 1145 | else if ( | |
| 1248 | 1146 | { |
| 1249 | 1147 | mame_printf_error("%s: %s has inverted No/Yes dipswitch order\n", driver->source_file, driver->name); |
| 1250 | error = TRUE; | |
| 1148 | *error = TRUE; | |
| 1251 | 1149 | } |
| 1252 | 1150 | |
| 1253 | 1151 | /* check for inverted upright/cocktail dispswitch order */ |
| 1254 | else if ( | |
| 1152 | else if ( | |
| 1255 | 1153 | { |
| 1256 | 1154 | mame_printf_error("%s: %s has inverted Upright/Cocktail dipswitch order\n", driver->source_file, driver->name); |
| 1257 | error = TRUE; | |
| 1155 | *error = TRUE; | |
| 1258 | 1156 | } |
| 1259 | 1157 | |
| 1260 | 1158 | /* check for proper coin ordering */ |
| 1261 | else if (last_strindex >= INPUT_STRING_9C_1C && last_strindex <= INPUT_STRING_1C_9C && strindex >= INPUT_STRING_9C_1C && strindex <= INPUT_STRING_1C_9C && | |
| 1262 | last_strindex >= strindex && !memcmp(&inp[-1].condition, &inp[0].condition, sizeof(inp[-1].condition))) | |
| 1159 | else if (strindex >= INPUT_STRING_9C_1C && strindex <= INPUT_STRING_1C_9C && next_strindex >= INPUT_STRING_9C_1C && next_strindex <= INPUT_STRING_1C_9C && | |
| 1160 | strindex >= next_strindex && memcmp(&setting->condition, &setting->next->condition, sizeof(setting->condition)) == 0) | |
| 1263 | 1161 | { |
| 1264 | mame_printf_error("%s: %s has unsorted coinage %s > %s\n", driver->source_file, driver->name, inp[-1].name, inp[0].name); | |
| 1265 | error = TRUE; | |
| 1266 | coin_error = TRUE; | |
| 1162 | mame_printf_error("%s: %s has unsorted coinage %s > %s\n", driver->source_file, driver->name, setting->name, setting->next->name); | |
| 1163 | coin_error = *error = TRUE; | |
| 1267 | 1164 | } |
| 1268 | 1165 | } |
| 1166 | } | |
| 1269 | 1167 | |
| 1270 | /* check for invalid DIP switch entries */ | |
| 1271 | if (last_dipname_entry && inp->type == IPT_DIPSWITCH_SETTING) | |
| 1168 | /* if we have a coin error, demonstrate the correct way */ | |
| 1169 | if (coin_error) | |
| 1170 | { | |
| 1171 | int entry; | |
| 1172 | ||
| 1173 | mame_printf_error("%s: %s proper coin sort order should be:\n", driver->source_file, driver->name); | |
| 1174 | for (entry = 0; entry < ARRAY_LENGTH(coin_list); entry++) | |
| 1175 | if (coin_list[entry]) | |
| 1176 | mame_printf_error("%s\n", input_port_string_from_index(INPUT_STRING_9C_1C + entry)); | |
| 1177 | } | |
| 1178 | } | |
| 1179 | ||
| 1180 | ||
| 1181 | /*------------------------------------------------- | |
| 1182 | validate_inputs - validate input configuration | |
| 1183 | -------------------------------------------------*/ | |
| 1184 | ||
| 1185 | static int validate_inputs(int drivnum, const machine_config *config) | |
| 1186 | { | |
| 1187 | const input_port_config *portlist; | |
| 1188 | const input_port_config *scanport; | |
| 1189 | const input_port_config *port; | |
| 1190 | const input_field_config *field; | |
| 1191 | const game_driver *driver = drivers[drivnum]; | |
| 1192 | int empty_string_found = FALSE; | |
| 1193 | quark_entry *entry; | |
| 1194 | int error = FALSE; | |
| 1195 | UINT32 crc; | |
| 1196 | ||
| 1197 | /* skip if no ports */ | |
| 1198 | if (driver->ipt == NULL) | |
| 1199 | return FALSE; | |
| 1200 | ||
| 1201 | /* skip if we already validated these ports */ | |
| 1202 | crc = (FPTR)driver->ipt; | |
| 1203 | for (entry = quark_table_get_first(inputs_table, crc); entry != NULL; entry = entry->next) | |
| 1204 | if (entry->crc == crc && driver->ipt == drivers[entry - inputs_table->entry]->ipt) | |
| 1205 | return FALSE; | |
| 1206 | ||
| 1207 | /* otherwise, add ourself to the list */ | |
| 1208 | quark_add(inputs_table, drivnum, crc); | |
| 1209 | ||
| 1210 | /* allocate the input ports */ | |
| 1211 | portlist = input_port_config_alloc(driver->ipt); | |
| 1212 | ||
| 1213 | /* check for duplicate tags */ | |
| 1214 | for (port = portlist; port != NULL; port = port->next) | |
| 1215 | if (port->tag != NULL) | |
| 1216 | for (scanport = port->next; scanport != NULL; scanport = scanport->next) | |
| 1217 | if (scanport->tag != NULL && strcmp(port->tag, scanport->tag) == 0) | |
| 1218 | { | |
| 1219 | mame_printf_error("%s: %s has a duplicate input port tag \"%s\"\n", driver->source_file, driver->name, port->tag); | |
| 1220 | error = TRUE; | |
| 1221 | } | |
| 1222 | ||
| 1223 | /* iterate over the results */ | |
| 1224 | for (port = portlist; port != NULL; port = port->next) | |
| 1225 | for (field = port->fieldlist; field != NULL; field = field->next) | |
| 1272 | 1226 | { |
| 1273 | /* make sure demo sounds default to on */ | |
| 1274 | if (last_dipname_entry->name == demo_sounds && strindex == INPUT_STRING_On && | |
| 1275 | last_dipname_entry->default_value != inp->default_value) | |
| 1227 | int strindex = 0; | |
| 1228 | ||
| 1229 | /* verify analog inputs */ | |
| 1230 | if (input_type_is_analog(field->type)) | |
| 1231 | validate_analog_input_field(field, driver, &error); | |
| 1232 | ||
| 1233 | /* verify dip switches */ | |
| 1234 | if (field->type == IPT_DIPSWITCH) | |
| 1276 | 1235 | { |
| 1277 | mame_printf_error("%s: %s Demo Sounds must default to On\n", driver->source_file, driver->name); | |
| 1278 | error = TRUE; | |
| 1236 | /* dip switch fields must have a name */ | |
| 1237 | if (field->name == NULL) | |
| 1238 | { | |
| 1239 | mame_printf_error("%s: %s has a DIP switch name or setting with no name\n", driver->source_file, driver->name); | |
| 1240 | error = TRUE; | |
| 1241 | } | |
| 1242 | ||
| 1243 | /* verify the settings list */ | |
| 1244 | validate_dip_settings(field, driver, &error); | |
| 1279 | 1245 | } |
| 1280 | 1246 | |
| 1281 | /* check for bad flip screen options */ | |
| 1282 | if (last_dipname_entry->name == flipscreen && (strindex == INPUT_STRING_Yes || strindex == INPUT_STRING_No)) | |
| 1247 | /* look for invalid (0) types which should be mapped to IPT_OTHER */ | |
| 1248 | if (field->type == IPT_INVALID) | |
| 1283 | 1249 | { |
| 1284 | mame_printf_error("%s: %s has | |
| 1250 | mame_printf_error("%s: %s has a | |
| 1285 | 1251 | error = TRUE; |
| 1286 | 1252 | } |
| 1287 | 1253 | |
| 1288 | /* check for bad demo sounds options */ | |
| 1289 | if (last_dipname_entry->name == demo_sounds && (strindex == INPUT_STRING_Yes || strindex == INPUT_STRING_No)) | |
| 1254 | /* verify names */ | |
| 1255 | if (field->name != NULL) | |
| 1290 | 1256 | { |
| 1291 | mame_printf_error("%s: %s has wrong Demo Sounds option %s (must be Off/On)\n", driver->source_file, driver->name, inp->name); | |
| 1292 | error = TRUE; | |
| 1257 | /* check for empty string */ | |
| 1258 | if (field->name[0] == 0 && !empty_string_found) | |
| 1259 | { | |
| 1260 | mame_printf_error("%s: %s has an input with an empty string\n", driver->source_file, driver->name); | |
| 1261 | empty_string_found = error = TRUE; | |
| 1262 | } | |
| 1263 | ||
| 1264 | /* check for trailing spaces */ | |
| 1265 | if (field->name[0] != 0 && field->name[strlen(field->name) - 1] == ' ') | |
| 1266 | { | |
| 1267 | mame_printf_error("%s: %s input '%s' has trailing spaces\n", driver->source_file, driver->name, field->name); | |
| 1268 | error = TRUE; | |
| 1269 | } | |
| 1270 | ||
| 1271 | /* check for invalid UTF-8 */ | |
| 1272 | if (!utf8_is_valid_string(field->name)) | |
| 1273 | { | |
| 1274 | mame_printf_error("%s: %s input '%s' has invalid characters\n", driver->source_file, driver->name, field->name); | |
| 1275 | error = TRUE; | |
| 1276 | } | |
| 1277 | ||
| 1278 | /* look up the string and print an error if default strings are not used */ | |
| 1279 | strindex = get_defstr_index(field->name, driver, &error); | |
| 1293 | 1280 | } |
| 1294 | 1281 | } |
| 1295 | 1282 | |
| 1296 | /* remember the last string index */ | |
| 1297 | last_strindex = strindex; | |
| 1298 | } | |
| 1283 | #ifdef MESS | |
| 1284 | if (mess_validate_input_ports(drivnum, config, portlist)) | |
| 1285 | error = TRUE; | |
| 1286 | #endif /* MESS */ | |
| 1299 | 1287 | |
| 1300 | if ( coin_error ) | |
| 1301 | display_valid_coin_order(drivnum, *memory); | |
| 1302 | ||
| 1288 | /* free the config */ | |
| 1289 | input_port_config_free(portlist); | |
| 1303 | 1290 | return error; |
| 1304 | 1291 | } |
| 1305 | 1292 | |
| r2724 | r2725 | |
| 1393 | 1380 | osd_ticks_t mess_checks = 0; |
| 1394 | 1381 | #endif |
| 1395 | 1382 | |
| 1396 | input_port_entry *inputports = NULL; | |
| 1397 | 1383 | int drivnum; |
| 1398 | 1384 | int error = FALSE; |
| 1399 | 1385 | UINT16 lsbtest; |
| r2724 | r2725 | |
| 1487 | 1473 | |
| 1488 | 1474 | /* validate input ports */ |
| 1489 | 1475 | input_checks -= osd_profiling_ticks(); |
| 1490 | error = validate_inputs(drivnum, config | |
| 1476 | error = validate_inputs(drivnum, config | |
| 1491 | 1477 | input_checks += osd_profiling_ticks(); |
| 1492 | 1478 | |
| 1493 | 1479 | /* validate sounds and speakers */ |
| r2724 | r2725 | |
|---|---|---|
| 5 | 5 | ****************************************************************************/ |
| 6 | 6 | |
| 7 | 7 | #include "mame.h" |
| 8 | #include "deprecat.h" | |
| 9 | 8 | #include "configms.h" |
| 10 | 9 | #include "config.h" |
| 11 | 10 | #include "xmlfile.h" |
| r2724 | r2725 | |
| 20 | 19 | configuration items |
| 21 | 20 | -------------------------------------------------*/ |
| 22 | 21 | |
| 23 | static void device_dirs_load(int config_type, xml_data_node *parentnode) | |
| 22 | static void device_dirs_load(running_machine *machine, int config_type, xml_data_node *parentnode) | |
| 24 | 23 | { |
| 25 | 24 | xml_data_node *node; |
| 26 | 25 | const device_config *dev; |
| r2724 | r2725 | |
| 38 | 37 | |
| 39 | 38 | if ((dev_instance != NULL) && (dev_instance[0] != '\0')) |
| 40 | 39 | { |
| 41 | for (dev = image_device_first( | |
| 40 | for (dev = image_device_first(machine->config); (image == NULL) && (dev != NULL); dev = image_device_next(dev)) | |
| 42 | 41 | { |
| 43 | info = image_device_getinfo( | |
| 42 | info = image_device_getinfo(machine->config, dev); | |
| 44 | 43 | if (!strcmp(dev_instance, info.instance_name)) |
| 45 | 44 | image = dev; |
| 46 | 45 | } |
| r2724 | r2725 | |
| 63 | 62 | directories to the configuration file |
| 64 | 63 | -------------------------------------------------*/ |
| 65 | 64 | |
| 66 | static void device_dirs_save(int config_type, xml_data_node *parentnode) | |
| 65 | static void device_dirs_save(running_machine *machine, int config_type, xml_data_node *parentnode) | |
| 67 | 66 | { |
| 68 | 67 | xml_data_node *node; |
| 69 | 68 | image_device_info info; |
| r2724 | r2725 | |
| 73 | 72 | /* only care about game-specific data */ |
| 74 | 73 | if (config_type == CONFIG_TYPE_GAME) |
| 75 | 74 | { |
| 76 | for (image = image_device_first( | |
| 75 | for (image = image_device_first(machine->config); image != NULL; image = image_device_next(image)) | |
| 77 | 76 | { |
| 78 | info = image_device_getinfo( | |
| 77 | info = image_device_getinfo(machine->config, image); | |
| 79 | 78 | dev_instance = info.instance_name; |
| 80 | 79 | |
| 81 | 80 | node = xml_add_child(parentnode, "device", NULL); |
| r2724 | r2725 | |
| 97 | 96 | |
| 98 | 97 | void mess_config_init(running_machine *machine) |
| 99 | 98 | { |
| 100 | config_register("device_directories", device_dirs_load, device_dirs_save); | |
| 99 | config_register(machine, "device_directories", device_dirs_load, device_dirs_save); | |
| 101 | 100 | } |
| r2724 | r2725 | |
|---|---|---|
| 7 | 7 | *********************************************************************/ |
| 8 | 8 | |
| 9 | 9 | #include "mame.h" |
| 10 | #include "deprecat.h" | |
| 11 | 10 | #include "mslegacy.h" |
| 12 | 11 | #include "uimenu.h" |
| 13 | 12 | #include "uimess.h" |
| r2724 | r2725 | |
| 31 | 30 | /* traditional MESS interface */ |
| 32 | 31 | if (machine->gamedrv->flags & GAME_COMPUTER) |
| 33 | 32 | { |
| 34 | if( input_ui_pressed(IPT_UI_TOGGLE_UI) ) | |
| 33 | if( input_ui_pressed(machine, IPT_UI_TOGGLE_UI) ) | |
| 35 | 34 | { |
| 36 | 35 | if( !ui_toggle_key ) |
| 37 | 36 | { |
| r2724 | r2725 | |
| 161 | 160 | |
| 162 | 161 | |
| 163 | 162 | |
| 164 | UINT32 ui_menu_image_info(UINT32 state) | |
| 163 | UINT32 ui_menu_image_info(running_machine *machine, UINT32 state) | |
| 165 | 164 | { |
| 166 | 165 | char buf[2048]; |
| 167 | 166 | char *bufptr = buf; |
| 168 | 167 | UINT32 selected = 0; |
| 169 | 168 | |
| 170 | 169 | /* add the game info */ |
| 171 | bufptr += ui_sprintf_image_info( | |
| 170 | bufptr += ui_sprintf_image_info(machine, bufptr); | |
| 172 | 171 | |
| 173 | 172 | /* make it look like a menu */ |
| 174 | 173 | bufptr += sprintf(bufptr, "\n\t%s %s %s", ui_getstring(UI_lefthilight), ui_getstring(UI_returntomain), ui_getstring(UI_righthilight)); |
| r2724 | r2725 | |
| 177 | 176 | ui_draw_message_window(buf); |
| 178 | 177 | |
| 179 | 178 | /* handle the keys */ |
| 180 | ui_menu_generic_keys(&selected, 1, 0); | |
| 179 | ui_menu_generic_keys(machine, &selected, 1, 0); | |
| 181 | 180 | return selected; |
| 182 | 181 | } |
| 183 | 182 |
| r2724 | r2725 | |
|---|---|---|
| 18 | 18 | |
| 19 | 19 | /* image info screen */ |
| 20 | 20 | int ui_sprintf_image_info(running_machine *machine, char *buf); |
| 21 | UINT32 ui_menu_image_info(UINT32 state); | |
| 21 | UINT32 ui_menu_image_info(running_machine *machine, UINT32 state); | |
| 22 | 22 | |
| 23 | 23 | /* file manager */ |
| 24 | int filemanager(int selected); | |
| 24 | int filemanager(running_machine *machine, int selected); | |
| 25 | 25 | |
| 26 | 26 | /* tape control */ |
| 27 | int tapecontrol(int selected); | |
| 27 | int tapecontrol(running_machine *machine, int selected); | |
| 28 | 28 | |
| 29 | 29 | /* paste */ |
| 30 | 30 | void ui_paste(running_machine *machine); |
| r2724 | r2725 | |
|---|---|---|
| 55 | 55 | /***************************************************************************/ |
| 56 | 56 | |
| 57 | 57 | #if HAS_WAVE |
| 58 | int tapecontrol(int selected); | |
| 58 | int tapecontrol(running_machine *machine, int selected); | |
| 59 | 59 | void tapecontrol_gettime(char *timepos, size_t timepos_size, const device_config *img, int *curpos, int *endpos); |
| 60 | 60 | #endif |
| 61 | 61 |
| r2724 | r2725 | |
|---|---|---|
| 12 | 12 | #include "uimenu.h" |
| 13 | 13 | #include "mslegacy.h" |
| 14 | 14 | #include "devices/cassette.h" |
| 15 | #include "deprecat.h" | |
| 16 | 15 | |
| 17 | 16 | |
| 18 | 17 | |
| r2724 | r2725 | |
| 38 | 37 | *endpos = t1; |
| 39 | 38 | } |
| 40 | 39 | |
| 41 | int tapecontrol(int selected) | |
| 40 | int tapecontrol(running_machine *machine, int selected) | |
| 42 | 41 | { |
| 43 | running_machine *machine = Machine; | |
| 44 | 42 | static int id = 0; |
| 45 | 43 | char timepos[32]; |
| 46 | 44 | ui_menu_item menu_item[40]; |
| r2724 | r2725 | |
| 66 | 64 | strcat(name, ui_getstring(UI_righthilight)); |
| 67 | 65 | ui_draw_message_window(name); |
| 68 | 66 | |
| 69 | if (input_ui_pressed(IPT_UI_SELECT) || input_ui_pressed(IPT_UI_CANCEL)) | |
| 67 | if (input_ui_pressed(machine, IPT_UI_SELECT) || input_ui_pressed(machine, IPT_UI_CANCEL)) | |
| 70 | 68 | sel = -1; |
| 71 | if (input_ui_pressed(IPT_UI_CONFIGURE)) | |
| 69 | if (input_ui_pressed(machine, IPT_UI_CONFIGURE)) | |
| 72 | 70 | sel = -2; |
| 73 | 71 | |
| 74 | 72 | return sel + 1; |
| r2724 | r2725 | |
| 139 | 137 | |
| 140 | 138 | ui_menu_draw(menu_item, total, sel, NULL); |
| 141 | 139 | |
| 142 | if (input_ui_pressed_repeat(IPT_UI_DOWN,8)) | |
| 140 | if (input_ui_pressed_repeat(machine, IPT_UI_DOWN,8)) | |
| 143 | 141 | { |
| 144 | 142 | if (sel < total - 1) sel++; |
| 145 | 143 | else sel = 0; |
| 146 | 144 | } |
| 147 | 145 | |
| 148 | if (input_ui_pressed_repeat(IPT_UI_UP,8)) | |
| 146 | if (input_ui_pressed_repeat(machine, IPT_UI_UP,8)) | |
| 149 | 147 | { |
| 150 | 148 | if (sel > 0) sel--; |
| 151 | 149 | else sel = total - 1; |
| 152 | 150 | } |
| 153 | 151 | |
| 154 | 152 | |
| 155 | if (input_ui_pressed(IPT_UI_LEFT)) | |
| 153 | if (input_ui_pressed(machine, IPT_UI_LEFT)) | |
| 156 | 154 | { |
| 157 | 155 | switch (sel) |
| 158 | 156 | { |
| r2724 | r2725 | |
| 163 | 161 | } |
| 164 | 162 | } |
| 165 | 163 | |
| 166 | if (input_ui_pressed(IPT_UI_RIGHT)) | |
| 164 | if (input_ui_pressed(machine, IPT_UI_RIGHT)) | |
| 167 | 165 | { |
| 168 | 166 | switch (sel) |
| 169 | 167 | { |
| r2724 | r2725 | |
| 174 | 172 | } |
| 175 | 173 | } |
| 176 | 174 | |
| 177 | if (input_ui_pressed(IPT_UI_SELECT)) | |
| 175 | if (input_ui_pressed(machine, IPT_UI_SELECT)) | |
| 178 | 176 | { |
| 179 | 177 | if (sel == total - 1) |
| 180 | 178 | sel = -1; |
| r2724 | r2725 | |
| 210 | 208 | } |
| 211 | 209 | } |
| 212 | 210 | |
| 213 | if (input_ui_pressed(IPT_UI_CANCEL)) | |
| 211 | if (input_ui_pressed(machine, IPT_UI_CANCEL)) | |
| 214 | 212 | sel = -1; |
| 215 | 213 | |
| 216 | if (input_ui_pressed(IPT_UI_CONFIGURE)) | |
| 214 | if (input_ui_pressed(machine, IPT_UI_CONFIGURE)) | |
| 217 | 215 | sel = -2; |
| 218 | 216 | |
| 219 | 217 | return sel + 1; |
| r2724 | r2725 | |
|---|---|---|
| 487 | 487 | |
| 488 | 488 | |
| 489 | 489 | |
| 490 | static void find_switch(running_machine *machine, const char *switch_name, const char *switch_setting, | |
| 491 | int switch_type, int switch_setting_type, | |
| 492 | input_port_entry **in_switch, input_port_entry **in_switch_setting) | |
| 490 | static const input_setting_config *find_switch(running_machine *machine, const char *switch_name, | |
| 491 | const char *switch_setting, int switch_type, int *found_field) | |
| 493 | 492 | { |
| 494 | input_port_entry *in; | |
| 493 | int found = FALSE; | |
| 494 | const input_port_config *port; | |
| 495 | const input_field_config *field = NULL; | |
| 496 | const input_setting_config *setting = NULL; | |
| 495 | 497 | |
| 496 | *in_switch = NULL; | |
| 497 | *in_switch_setting = NULL; | |
| 498 | ||
| 499 | 498 | /* find switch with the name */ |
| 500 | in = machine->input_ports; | |
| 501 | while(in->type != IPT_END) | |
| 499 | found = FALSE; | |
| 500 | for (port = machine->portconfig; !found && (port != NULL); port = port->next) | |
| 502 | 501 | { |
| 503 | if (in->type == switch_type && input_port_active(in) | |
| 504 | && input_port_name(in) && !mame_stricmp(input_port_name(in), switch_name)) | |
| 505 | break; | |
| 506 | in++; | |
| 502 | for (field = port->fieldlist; !found && (field != NULL); field = field->next) | |
| 503 | { | |
| 504 | if (field->type == switch_type && input_field_name(field) && !mame_stricmp(input_field_name(field), switch_name)) | |
| 505 | found = TRUE; | |
| 506 | } | |
| 507 | 507 | } |
| 508 | if (in->type == IPT_END) | |
| 509 | return; | |
| 510 | *in_switch = in; | |
| 511 | 508 | |
| 512 | /* find the setting */ | |
| 513 | in++; | |
| 514 | while(in->type == switch_setting_type) | |
| 509 | /* did we find the field? */ | |
| 510 | if (field != NULL) | |
| 515 | 511 | { |
| 516 | if (input_port_active(in) && input_port_name(in) && !mame_stricmp(input_port_name(in), switch_setting)) | |
| 517 | break; | |
| 518 | in++; | |
| 512 | /* we did find the field - now find the setting */ | |
| 513 | for (setting = field->settinglist; setting != NULL; setting = setting->next) | |
| 514 | { | |
| 515 | if (setting->name != NULL && !mame_stricmp(setting->name, switch_setting)) | |
| 516 | break; | |
| 517 | } | |
| 519 | 518 | } |
| 520 | if (in->type != switch_setting_type) | |
| 521 | return; | |
| 522 | *in_switch_setting = in; | |
| 519 | ||
| 520 | /* return whether the field was found at all, if we're asked that */ | |
| 521 | if (found_field != NULL) | |
| 522 | *found_field = (field != NULL); | |
| 523 | ||
| 524 | return setting; | |
| 523 | 525 | } |
| 524 | 526 | |
| 525 | 527 | |
| r2724 | r2725 | |
| 638 | 640 | |
| 639 | 641 | static void command_switch(running_machine *machine) |
| 640 | 642 | { |
| 641 | input_port_entry *switch_name; | |
| 642 | input_port_entry *switch_setting; | |
| 643 | int found_field; | |
| 644 | const input_setting_config *setting; | |
| 643 | 645 | |
| 644 | 646 | /* special hack until we support video targets natively */ |
| 645 | 647 | if (!strcmp(current_command->u.switch_args.name, "Video type")) |
| r2724 | r2725 | |
| 662 | 664 | } |
| 663 | 665 | } |
| 664 | 666 | |
| 665 | find_switch(machine, current_command->u.switch_args.name, current_command->u.switch_args.value, | |
| 666 | IPT_DIPSWITCH_NAME, IPT_DIPSWITCH_SETTING, &switch_name, &switch_setting); | |
| 667 | /* first try dip switches */ | |
| 668 | setting = find_switch(machine, current_command->u.switch_args.name, | |
| 669 | current_command->u.switch_args.value, IPT_DIPSWITCH, &found_field); | |
| 667 | 670 | |
| 668 | if ( | |
| 671 | if ( | |
| 669 | 672 | { |
| 670 | find_switch(machine, current_command->u.switch_args.name, current_command->u.switch_args.value, | |
| 671 | IPT_CONFIG_NAME, IPT_CONFIG_SETTING, &switch_name, &switch_setting); | |
| 673 | /* failing that, try configs */ | |
| 674 | setting = find_switch(machine, current_command->u.switch_args.name, | |
| 675 | current_command->u.switch_args.value, IPT_CONFIG, &found_field); | |
| 672 | 676 | } |
| 673 | 677 | |
| 674 | if ( | |
| 678 | if ( | |
| 675 | 679 | { |
| 680 | /* now failing that, really fail - lets report a good message */ | |
| 681 | if (found_field) | |
| 682 | { | |
| 683 | report_message(MSG_FAILURE, "Cannot find setting '%s' on switch '%s'", | |
| 684 | current_command->u.switch_args.value, current_command->u.switch_args.name); | |
| 685 | } | |
| 686 | else | |
| 687 | { | |
| 688 | report_message(MSG_FAILURE, "Cannot find switch named '%s'", current_command->u.switch_args.name); | |
| 689 | } | |
| 676 | 690 | state = STATE_ABORTED; |
| 677 | report_message(MSG_FAILURE, "Cannot find switch named '%s'", current_command->u.switch_args.name); | |
| 678 | 691 | return; |
| 679 | 692 | } |
| 680 | 693 | |
| 681 | if (!switch_setting) | |
| 682 | { | |
| 683 | state = STATE_ABORTED; | |
| 684 | report_message(MSG_FAILURE, "Cannot find setting '%s' on switch '%s'", | |
| 685 | current_command->u.switch_args.value, current_command->u.switch_args.name); | |
| 686 | return; | |
| 687 | } | |
| 688 | ||
| 689 | switch_name->default_value = switch_setting->default_value; | |
| 694 | /* success! */ | |
| 695 | /* FIXME */ | |
| 696 | /* switch_name->default_value = setting->value; */ | |
| 690 | 697 | } |
| 691 | 698 | |
| 692 | 699 |
| r2724 | r2725 | |
|---|---|---|
| 14 | 14 | { |
| 15 | 15 | } |
| 16 | 16 | |
| 17 | void osd_customize_input | |
| 17 | void osd_customize_input_ | |
| 18 | 18 | { |
| 19 | 19 | } |
| 20 | 20 |
| r2724 | r2725 | |
|---|---|---|
| 2524 | 2524 | { |
| 2525 | 2525 | /* append a path */ |
| 2526 | 2526 | if ((strlen(path1) > 0) && (path1[strlen(path1) - 1] != path_separator)) |
| 2527 | snprintf(buffer, buffer_len, "%s%c%s | |
| 2527 | snprintf(buffer, buffer_len, "%s%c%s | |
| 2528 | 2528 | else |
| 2529 | snprintf(buffer, buffer_len, "%s%s | |
| 2529 | snprintf(buffer, buffer_len, "%s%s | |
| 2530 | 2530 | } |
| 2531 | 2531 | return buffer; |
| 2532 | 2532 | } |
| r2724 | r2725 | |
|---|---|---|
| 33 | 33 | |
| 34 | 34 | NVRAM_HANDLER( apple2gs ); |
| 35 | 35 | |
| 36 | void apple2gs_doc_irq(int state); | |
| 36 | void apple2gs_doc_irq(running_machine *machine, int state); | |
| 37 | 37 | |
| 38 | 38 | |
| 39 | 39 | /*----------- defined in video/apple2gs.c -----------*/ |
| r2724 | r2725 | |
|---|---|---|
| 69 | 69 | extern HP48_HARDWARE hp48_hardware; |
| 70 | 70 | |
| 71 | 71 | extern UINT8 *hp48_ram, *hp48_card1, *hp48_card2; |
| 72 | void hp48_mem_reset(void); | |
| 73 | void hp48_mem_config(int v); | |
| 74 | void hp48_mem_unconfig(int v); | |
| 75 | int hp48_mem_id(void); | |
| 76 | void hp48_crc(int adr, int data); | |
| 77 | int hp48_in(void); | |
| 78 | void hp48_out(int v); | |
| 72 | void hp48_mem_reset(running_machine *machine); | |
| 73 | void hp48_mem_config(running_machine *machine, int v); | |
| 74 | void hp48_mem_unconfig(running_machine *machine, int v); | |
| 75 | int hp48_mem_id(running_machine *machine); | |
| 76 | void hp48_crc(running_machine *machine, int adr, int data); | |
| 77 | int hp48_in(running_machine *machine); | |
| 78 | void hp48_out(running_machine *machine, int v); | |
| 79 | 79 | |
| 80 | 80 | DRIVER_INIT( hp48s ); |
| 81 | 81 | DRIVER_INIT( hp48g ); |
| r2724 | r2725 | |
|---|---|---|
| 62 | 62 | DEVICE_IMAGE_LOAD( msx_cart ); |
| 63 | 63 | DEVICE_IMAGE_UNLOAD( msx_cart ); |
| 64 | 64 | |
| 65 | void msx_vdp_interrupt | |
| 65 | void msx_vdp_interrupt | |
| 66 | 66 | |
| 67 | 67 | /* I/O functions */ |
| 68 | 68 | WRITE8_HANDLER ( msx_printer_w ); |
| r2724 | r2725 | |
|---|---|---|
| 24 | 24 | void vectrex_configuration(running_machine *machine); |
| 25 | 25 | READ8_HANDLER (v_via_pa_r); |
| 26 | 26 | READ8_HANDLER(v_via_pb_r ); |
| 27 | void v_via_irq (int level); | |
| 27 | void v_via_irq (running_machine *machine, int level); | |
| 28 | 28 | WRITE8_HANDLER ( vectrex_psg_port_w ); |
| 29 | 29 | |
| 30 | 30 | DRIVER_INIT( vectrex ); |
| r2724 | r2725 | |
|---|---|---|
| 15 | 15 | |
| 16 | 16 | WRITE8_HANDLER(pc8801_write_interrupt_level); |
| 17 | 17 | WRITE8_HANDLER(pc8801_write_interrupt_mask); |
| 18 | READ8_HANDLER(pc88sr_inport_30); | |
| 19 | READ8_HANDLER(pc88sr_inport_31); | |
| 20 | READ8_HANDLER(pc88sr_inport_32); | |
| 18 | READ8_HANDLER(pc88sr_inport_30); | |
| 19 | READ8_HANDLER(pc88sr_inport_31); | |
| 20 | READ8_HANDLER(pc88sr_inport_32); | |
| 21 | 21 | WRITE8_HANDLER(pc88sr_outport_30); |
| 22 | 22 | WRITE8_HANDLER(pc88sr_outport_31); |
| 23 | 23 | WRITE8_HANDLER(pc88sr_outport_32); |
| 24 | 24 | WRITE8_HANDLER(pc88sr_outport_40); |
| 25 | READ8_HANDLER(pc88sr_inport_40); | |
| 26 | READ8_HANDLER(pc8801_inport_70); | |
| 25 | READ8_HANDLER(pc88sr_inport_40); | |
| 26 | READ8_HANDLER(pc8801_inport_70); | |
| 27 | 27 | WRITE8_HANDLER(pc8801_outport_70); |
| 28 | 28 | WRITE8_HANDLER(pc8801_outport_78); |
| 29 | ||
| 29 | ||
| 30 | 30 | WRITE8_HANDLER(pc88sr_outport_71); |
| 31 | 31 | |
| 32 | 32 | extern INTERRUPT_GEN( pc8801_interrupt ); |
| r2724 | r2725 | |
| 36 | 36 | void pc8801_update_bank(void); |
| 37 | 37 | extern unsigned char *pc8801_mainRAM; |
| 38 | 38 | extern int pc88sr_is_highspeed; |
| 39 | READ8_HANDLER(pc8801fd_nec765_tc); | |
| 40 | void pc88sr_sound_interupt(int irq); | |
| 39 | READ8_HANDLER(pc8801fd_nec765_tc); | |
| 40 | void pc88sr_sound_interupt(running_machine *machine, int irq); | |
| 41 | 41 | WRITE8_HANDLER(pc8801_write_kanji1); |
| 42 | ||
| 42 | ||
| 43 | 43 | WRITE8_HANDLER(pc8801_write_kanji2); |
| 44 | ||
| 44 | ||
| 45 | 45 | WRITE8_HANDLER(pc8801_calender); |
| 46 | ||
| 46 | ||
| 47 | 47 | WRITE8_HANDLER(pc8801_write_extmem); |
| 48 | 48 | |
| 49 | 49 |
| r2724 | r2725 | |
|---|---|---|
| 27 | 27 | DEVICE_IMAGE_UNLOAD( svi318_cart ); |
| 28 | 28 | |
| 29 | 29 | INTERRUPT_GEN( svi318_interrupt ); |
| 30 | void svi318_vdp_interrupt(int i); | |
| 30 | void svi318_vdp_interrupt(running_machine *machine, int i); | |
| 31 | 31 | |
| 32 | 32 | WRITE8_HANDLER( svi318_writemem1 ); |
| 33 | 33 | WRITE8_HANDLER( svi318_writemem2 ); |
| r2724 | r2725 | |
|---|---|---|
| 154 | 154 | INPUT_PORTS_END |
| 155 | 155 | |
| 156 | 156 | /* Dipswitch for font selection */ |
| 157 | #define CGA_FONT (input_port_read_ | |
| 157 | #define CGA_FONT (input_port_read_ | |
| 158 | 158 | |
| 159 | 159 | /* Dipswitch for monitor selection */ |
| 160 | #define CGA_MONITOR (input_port_read_ | |
| 160 | #define CGA_MONITOR (input_port_read_ | |
| 161 | 161 | #define CGA_MONITOR_RGB 0x00 /* Colour RGB */ |
| 162 | 162 | #define CGA_MONITOR_MONO 0x04 /* Greyscale RGB */ |
| 163 | 163 | #define CGA_MONITOR_COMPOSITE 0x08 /* Colour composite */ |
| r2724 | r2725 | |
| 166 | 166 | |
| 167 | 167 | |
| 168 | 168 | /* Dipswitch for chipset selection */ |
| 169 | #define CGA_CHIPSET (input_port_read_ | |
| 169 | #define CGA_CHIPSET (input_port_read_ | |
| 170 | 170 | #define CGA_CHIPSET_IBM 0x00 /* Original IBM CGA */ |
| 171 | 171 | #define CGA_CHIPSET_PC1512 0x20 /* PC1512 CGA subset */ |
| 172 | 172 | #define CGA_CHIPSET_PC200 0x40 /* PC200 in CGA mode */ |
| r2724 | r2725 | |
| 242 | 242 | |
| 243 | 243 | UINT8 *chr_gen; |
| 244 | 244 | |
| 245 | int | |
| 245 | const input_port_config *config_input_port; | |
| 246 | 246 | |
| 247 | 247 | mc6845_update_row_func update_row; |
| 248 | 248 | UINT8 palette_lut_2bpp[4]; |
| r2724 | r2725 | |
| 454 | 454 | state_save_register_item("pccga", 0, cga.status); |
| 455 | 455 | state_save_register_item("pccga", 0, cga.plantronics); |
| 456 | 456 | |
| 457 | cga.config_input_port = port_tag | |
| 457 | cga.config_input_port = input_port_by_tag(Machin | |
| 458 | 458 | |
| 459 | 459 | return 0; |
| 460 | 460 | } |
| r2724 | r2725 | |
| 513 | 513 | |
| 514 | 514 | static VIDEO_UPDATE( mc6845_cga ) |
| 515 | 515 | { |
| 516 | running_machine *machine = screen->machine; | |
| 517 | 516 | device_config *devconf = (device_config *) device_list_find_by_tag(screen->machine->config->devicelist, MC6845, CGA_MC6845_NAME); |
| 518 | 517 | mc6845_update( devconf, bitmap, cliprect); |
| 519 | 518 | |
| r2724 | r2725 | |
| 1165 | 1164 | */ |
| 1166 | 1165 | static void pc_cga_plantronics_w(int data) |
| 1167 | 1166 | { |
| 1168 | running_machine *machine = Machine; | |
| 1169 | ||
| 1170 | 1167 | CGA_LOG(1,"CGA_plantronics_w",("$%02x\n", data)); |
| 1171 | 1168 | |
| 1172 | 1169 | if (CGA_CHIPSET != CGA_CHIPSET_ATI) return; |
| r2724 | r2725 | |
| 1640 | 1637 | |
| 1641 | 1638 | static VIDEO_UPDATE( mc6845_pc1512 ) |
| 1642 | 1639 | { |
| 1643 | running_machine *machine = screen->machine; | |
| 1644 | 1640 | device_config *devconf = (device_config *) device_list_find_by_tag(screen->machine->config->devicelist, MC6845, CGA_MC6845_NAME); |
| 1645 | 1641 | mc6845_update( devconf, bitmap, cliprect); |
| 1646 | 1642 |
| r2724 | r2725 | |
|---|---|---|
| 27 | 27 | #define NUM_SIMUL_KEYS (UCHAR_SHIFT_END - UCHAR_SHIFT_BEGIN + 1) |
| 28 | 28 | #define LOG_INPUTX 0 |
| 29 | 29 | #define SPACE_COUNT 3 |
| 30 | #define INVALID_CHAR '?' | |
| 31 | #define IP_NAME_DEFAULT NULL | |
| 30 | 32 | |
| 31 | 33 | |
| 32 | 34 | |
| r2724 | r2725 | |
| 34 | 36 | TYPE DEFINITIONS |
| 35 | 37 | ***************************************************************************/ |
| 36 | 38 | |
| 39 | typedef const input_port_config *input_port_config_c; | |
| 40 | typedef const input_field_config *input_field_config_c; | |
| 41 | ||
| 42 | ||
| 37 | 43 | typedef struct _mess_input_code mess_input_code; |
| 38 | 44 | struct _mess_input_code |
| 39 | 45 | { |
| 40 | 46 | unicode_char ch; |
| 41 | UINT32 port[NUM_SIMUL_KEYS]; | |
| 42 | const input_port_entry *ipt[NUM_SIMUL_KEYS]; | |
| 47 | input_port_config_c port[NUM_SIMUL_KEYS]; | |
| 48 | input_field_config_c ipt[NUM_SIMUL_KEYS]; | |
| 43 | 49 | }; |
| 44 | 50 | |
| 45 | 51 | typedef struct _key_buffer key_buffer; |
| r2724 | r2725 | |
| 361 | 367 | |
| 362 | 368 | |
| 363 | 369 | |
| 364 | #define INVALID_CHAR '?' | |
| 365 | 370 | |
| 366 | 371 | /*************************************************************************** |
| 372 | MISCELLANEOUS | |
| 373 | ***************************************************************************/ | |
| 367 | 374 | |
| 368 | Char info lookup | |
| 375 | /*------------------------------------------------- | |
| 376 | find_charinfo - looks up information about a | |
| 377 | particular character | |
| 378 | -------------------------------------------------*/ | |
| 369 | 379 | |
| 370 | ***************************************************************************/ | |
| 371 | ||
| 372 | 380 | static const char_info *find_charinfo(unicode_char target_char) |
| 373 | 381 | { |
| 374 | 382 | int low = 0; |
| r2724 | r2725 | |
| 394 | 402 | |
| 395 | 403 | |
| 396 | 404 | /*************************************************************************** |
| 397 | ||
| 398 | Code assembling | |
| 399 | ||
| 405 | CODE ASSEMBLING | |
| 400 | 406 | ***************************************************************************/ |
| 401 | 407 | |
| 402 | 408 | /*------------------------------------------------- |
| r2724 | r2725 | |
| 448 | 454 | |
| 449 | 455 | |
| 450 | 456 | |
| 451 | static unicode_char get_keyboard_code(const input_port_entry *ipt, int i) | |
| 457 | /*------------------------------------------------- | |
| 458 | get_keyboard_code - accesses a particular | |
| 459 | keyboard code | |
| 460 | -------------------------------------------------*/ | |
| 461 | ||
| 462 | static unicode_char get_keyboard_code(const input_field_config *field, int i) | |
| 452 | 463 | { |
| 453 | unicode_char ch = i | |
| 464 | unicode_char ch = fi | |
| 454 | 465 | |
| 455 | 466 | /* special hack to allow for PORT_CODE('\xA3') */ |
| 456 | 467 | if ((ch >= 0xFFFFFF80) && (ch <= 0xFFFFFFFF)) |
| r2724 | r2725 | |
| 460 | 471 | |
| 461 | 472 | |
| 462 | 473 | |
| 463 | static int scan_keys(const input_port_entry *input_ports, mess_input_code *codes, UINT32 *ports, const input_port_entry **shift_ports, int keys, int shift) | |
| 474 | /*------------------------------------------------- | |
| 475 | scan_keys - scans through input ports and | |
| 476 | sets up natural keyboard input mapping | |
| 477 | -------------------------------------------------*/ | |
| 478 | ||
| 479 | static int scan_keys(const input_port_config *portconfig, mess_input_code *codes, input_port_config_c *ports, input_field_config_c *shift_ports, int keys, int shift) | |
| 464 | 480 | { |
| 465 | 481 | int code_count = 0; |
| 466 | const input_port_entry *ipt; | |
| 467 | const input_port_entry *ipt_key = NULL; | |
| 468 | UINT32 port = (UINT32) -1; | |
| 482 | const input_port_config *port; | |
| 483 | const input_field_config *field; | |
| 469 | 484 | unicode_char code; |
| 470 | 485 | |
| 471 | 486 | assert(keys < NUM_SIMUL_KEYS); |
| 472 | 487 | |
| 473 | ipt = input_ports; | |
| 474 | while(ipt->type != IPT_END) | |
| 488 | for (port = portconfig; port != NULL; port = port->next) | |
| 475 | 489 | { |
| 476 | | |
| 490 | for | |
| 477 | 491 | { |
| 478 | case IPT_KEYBOARD: | |
| 479 | ipt_key = ipt; | |
| 480 | ||
| 481 | code = get_keyboard_code(ipt, shift); | |
| 492 | if (field->type == IPT_KEYBOARD) | |
| 493 | { | |
| 494 | code = get_keyboard_code(field, shift); | |
| 482 | 495 | if (code != 0) |
| 483 | 496 | { |
| 484 | 497 | /* is this a shifter key? */ |
| 485 | 498 | if ((code >= UCHAR_SHIFT_BEGIN) && (code <= UCHAR_SHIFT_END)) |
| 486 | 499 | { |
| 487 | ports[keys] = port; | |
| 488 | shift_ports[keys] = ipt_key; | |
| 489 | code_count += scan_keys(input_ports, | |
| 500 | shift_ports[keys] = field; | |
| 501 | code_count += scan_keys(portconfig, | |
| 490 | 502 | codes ? &codes[code_count] : NULL, |
| 491 | 503 | ports, |
| 492 | 504 | shift_ports, |
| r2724 | r2725 | |
| 503 | 515 | memcpy((void *) codes[code_count].ipt, shift_ports, sizeof(shift_ports[0]) * keys); |
| 504 | 516 | codes[code_count].ch = code; |
| 505 | 517 | codes[code_count].port[keys] = port; |
| 506 | codes[code_count].ipt[keys] = i | |
| 518 | codes[code_count].ipt[keys] = fi | |
| 507 | 519 | } |
| 508 | 520 | |
| 509 | 521 | /* increment the count */ |
| 510 | 522 | code_count++; |
| 511 | 523 | |
| 512 | 524 | if (LOG_INPUTX) |
| 513 | logerror("inputx: code=%i (%s) port=% | |
| 525 | logerror("inputx: code=%i (%s) port=%p field->name='%s'\n", (int) code, code_point_string(code), port, field->name); | |
| 514 | 526 | } |
| 515 | 527 | } |
| 516 | break; | |
| 517 | ||
| 518 | case IPT_PORT: | |
| 519 | port++; | |
| 520 | /* fall through */ | |
| 521 | ||
| 522 | default: | |
| 523 | ipt_key = NULL; | |
| 524 | break; | |
| 528 | } | |
| 525 | 529 | } |
| 526 | ipt++; | |
| 527 | 530 | } |
| 528 | 531 | return code_count; |
| 529 | 532 | } |
| r2724 | r2725 | |
| 536 | 539 | chars |
| 537 | 540 | -------------------------------------------------*/ |
| 538 | 541 | |
| 539 | static mess_input_code *build_codes(const input_port_ | |
| 542 | static mess_input_code *build_codes(const input_port_config * | |
| 540 | 543 | { |
| 541 | 544 | mess_input_code *codes = NULL; |
| 542 | UINT32 ports[NUM_SIMUL_KEYS]; | |
| 543 | const input_port_entry *ipts[NUM_SIMUL_KEYS]; | |
| 545 | const input_port_config *ports[NUM_SIMUL_KEYS]; | |
| 546 | const input_field_config *ipts[NUM_SIMUL_KEYS]; | |
| 544 | 547 | int code_count; |
| 545 | 548 | |
| 546 | 549 | /* first count the number of codes */ |
| 547 | code_count = scan_keys( | |
| 550 | code_count = scan_keys( | |
| 548 | 551 | if (code_count > 0) |
| 549 | 552 | { |
| 550 | 553 | /* allocate the codes */ |
| r2724 | r2725 | |
| 552 | 555 | memset(codes, 0, sizeof(*codes) * (code_count + 1)); |
| 553 | 556 | |
| 554 | 557 | /* and populate them */ |
| 555 | scan_keys( | |
| 558 | scan_keys( | |
| 556 | 559 | } |
| 557 | 560 | return codes; |
| 558 | 561 | } |
| r2724 | r2725 | |
| 560 | 563 | |
| 561 | 564 | |
| 562 | 565 | /*************************************************************************** |
| 566 | VALIDITY CHECKS | |
| 567 | ***************************************************************************/ | |
| 563 | 568 | |
| 564 | Validity checks | |
| 569 | /*------------------------------------------------- | |
| 570 | mess_validate_input_ports - validates the | |
| 571 | natural keyboard setup of a set of input ports | |
| 572 | -------------------------------------------------*/ | |
| 565 | 573 | |
| 566 | ***************************************************************************/ | |
| 574 | int mess_validate_input_ports(int drivnum, const machine_config *config, const input_port_config *portlist) | |
| 575 | { | |
| 576 | int error = FALSE; | |
| 567 | 577 | |
| 568 | int inputx_validitycheck(const game_driver *gamedrv, input_port_entry **memory) | |
| 578 | if (drivers[drivnum]->flags & GAME_COMPUTER) | |
| 579 | { | |
| 580 | /* unused hook */ | |
| 581 | } | |
| 582 | ||
| 583 | return error; | |
| 584 | } | |
| 585 | ||
| 586 | ||
| 587 | ||
| 588 | /*------------------------------------------------- | |
| 589 | mess_validate_natural_keyboard_statics - | |
| 590 | validates natural keyboard static data | |
| 591 | -------------------------------------------------*/ | |
| 592 | ||
| 593 | int mess_validate_natural_keyboard_statics(void) | |
| 569 | 594 | { |
| 570 | mess_input_code *codes; | |
| 571 | const input_port_entry *input_ports; | |
| 572 | const input_port_entry *ipt; | |
| 573 | int port_count, i, j; | |
| 574 | int error = 0; | |
| 595 | int i; | |
| 596 | int error = FALSE; | |
| 575 | 597 | unicode_char last_char = 0; |
| 576 | 598 | const char_info *ci; |
| 577 | 599 | |
| 578 | if (gamedrv) | |
| 600 | /* check to make sure that charinfo is in order */ | |
| 601 | for (i = 0; i < sizeof(charinfo) / sizeof(charinfo[0]); i++) | |
| 579 | 602 | { |
| 580 | if ( | |
| 603 | if ( | |
| 581 | 604 | { |
| 582 | /* allocate the input ports */ | |
| 583 | *memory = input_port_allocate(gamedrv->ipt, *memory); | |
| 584 | input_ports = *memory; | |
| 585 | ||
| 586 | codes = build_codes(input_ports); | |
| 587 | if (codes) | |
| 588 | { | |
| 589 | /* count the total amount of ports */ | |
| 590 | port_count = 0; | |
| 591 | for (ipt = input_ports; ipt->type != IPT_END; ipt++) | |
| 592 | { | |
| 593 | if (ipt->type == IPT_PORT) | |
| 594 | port_count++; | |
| 595 | } | |
| 596 | ||
| 597 | for (i = 0; codes[i].ch; i++) | |
| 598 | { | |
| 599 | for (j = 0; j < NUM_SIMUL_KEYS; j++) | |
| 600 | { | |
| 601 | if (codes[i].port[j] >= port_count) | |
| 602 | { | |
| 603 | mame_printf_error("%s: invalid inputx translation for code %i port %i\n", gamedrv->name, i, j); | |
| 604 | error = 1; | |
| 605 | } | |
| 606 | } | |
| 607 | } | |
| 608 | } | |
| 605 | mame_printf_error("inputx: charinfo is out of order; 0x%08x should be higher than 0x%08x\n", charinfo[i].ch, last_char); | |
| 606 | error = TRUE; | |
| 609 | 607 | } |
| 608 | last_char = charinfo[i].ch; | |
| 610 | 609 | } |
| 611 | else | |
| 610 | ||
| 611 | /* check to make sure that I can look up everything on alternate_charmap */ | |
| 612 | for (i = 0; i < sizeof(charinfo) / sizeof(charinfo[0]); i++) | |
| 612 | 613 | { |
| 613 | /* check to make sure that charinfo is in order */ | |
| 614 | for (i = 0; i < sizeof(charinfo) / sizeof(charinfo[0]); i++) | |
| 614 | ci = find_charinfo(charinfo[i].ch); | |
| 615 | if (ci != &charinfo[i]) | |
| 615 | 616 | { |
| 616 | if (last_char >= charinfo[i].ch) | |
| 617 | { | |
| 618 | mame_printf_error("inputx: charinfo is out of order; 0x%08x should be higher than 0x%08x\n", charinfo[i].ch, last_char); | |
| 619 | error = 1; | |
| 620 | } | |
| 621 | last_char = charinfo[i].ch; | |
| 617 | mame_printf_error("inputx: expected find_charinfo(0x%08x) to work properly\n", charinfo[i].ch); | |
| 618 | error = TRUE; | |
| 622 | 619 | } |
| 623 | ||
| 624 | /* check to make sure that I can look up everything on alternate_charmap */ | |
| 625 | for (i = 0; i < sizeof(charinfo) / sizeof(charinfo[0]); i++) | |
| 626 | { | |
| 627 | ci = find_charinfo(charinfo[i].ch); | |
| 628 | if (ci != &charinfo[i]) | |
| 629 | { | |
| 630 | mame_printf_error("inputx: expected find_charinfo(0x%08x) to work properly\n", charinfo[i].ch); | |
| 631 | error = 1; | |
| 632 | } | |
| 633 | } | |
| 634 | 620 | } |
| 635 | 621 | return error; |
| 636 | 622 | } |
| r2724 | r2725 | |
| 699 | 685 | /* posting keys directly only makes sense for a computer */ |
| 700 | 686 | if (machine->gamedrv->flags & GAME_COMPUTER) |
| 701 | 687 | { |
| 702 | codes = build_codes(machine-> | |
| 688 | codes = build_codes(machine-> | |
| 703 | 689 | setup_keybuffer(machine); |
| 704 | 690 | } |
| 705 | 691 | } |
| r2724 | r2725 | |
| 882 | 868 | if (LOG_INPUTX) |
| 883 | 869 | { |
| 884 | 870 | code = find_code(ch); |
| 885 | logerror("inputx_postn(): code=%i (%s) port=% | |
| 871 | logerror("inputx_postn(): code=%i (%s) port=%p field->name='%s'\n", (int) ch, code_point_string(ch), code ? code->port[0] : NULL, (code && code->ipt[0]) ? code->ipt[0]->name : "<null>"); | |
| 886 | 872 | } |
| 887 | 873 | |
| 888 | 874 | if (can_post_key_directly(ch)) |
| r2724 | r2725 | |
| 962 | 948 | called from core to allow for natural keyboard |
| 963 | 949 | -------------------------------------------------*/ |
| 964 | 950 | |
| 965 | void mess_input_port_update_hook(running_machine *machine, | |
| 951 | void mess_input_port_update_hook(running_machine *machine, const input_port_conf | |
| 966 | 952 | { |
| 967 | 953 | const key_buffer *keybuf; |
| 968 | 954 | const mess_input_code *code; |
| r2724 | r2725 | |
| 986 | 972 | { |
| 987 | 973 | for (i = 0; i < ARRAY_LENGTH(code->ipt) && (code->ipt[i] != NULL); i++) |
| 988 | 974 | { |
| 989 | if (code->port[i] == port | |
| 975 | if (code->port[i] == port | |
| 990 | 976 | { |
| 991 | 977 | value = code->ipt[i]->mask; |
| 992 | *digital |= value; | |
| 978 | /* 24-May-2008 - FIXME */ | |
| 979 | /* *digital |= value; */ | |
| 993 | 980 | } |
| 994 | 981 | } |
| 995 | 982 | } |
| r2724 | r2725 | |
| 999 | 986 | |
| 1000 | 987 | |
| 1001 | 988 | |
| 1002 | void inputx_handle_mess_extensions(input_ | |
| 989 | void inputx_handle_mess_extensions(input_fi | |
| 1003 | 990 | { |
| 1004 | 991 | char buf[256]; |
| 1005 | 992 | int i, pos; |
| r2724 | r2725 | |
| 1014 | 1001 | buf[0] = '\0'; |
| 1015 | 1002 | pos = 0; |
| 1016 | 1003 | |
| 1017 | for (i = 0; i < ARRAY_LENGTH(ipt-> | |
| 1004 | for (i = 0; i < ARRAY_LENGTH(ipt-> | |
| 1018 | 1005 | { |
| 1019 | 1006 | ch = get_keyboard_code(ipt, i); |
| 1020 | 1007 | pos += snprintf(&buf[pos], ARRAY_LENGTH(buf) - pos, "%-*s ", MAX(SPACE_COUNT - 1, 0), inputx_key_name(ch)); |
| r2724 | r2725 | |
| 1355 | 1342 | This stuff is here more out of convienience than anything else |
| 1356 | 1343 | ***************************************************************************/ |
| 1357 | 1344 | |
| 1358 | int input_classify_port(const input_ | |
| 1345 | int input_classify_port(const input_fi | |
| 1359 | 1346 | { |
| 1360 | 1347 | int result; |
| 1361 | 1348 | |
| 1362 | if (port->unused) | |
| 1363 | return INPUT_CLASS_INTERNAL; | |
| 1364 | if (port->category && (port->type != IPT_CATEGORY_SETTING)) | |
| 1349 | if (field->category && (field->type != IPT_CATEGORY)) | |
| 1365 | 1350 | return INPUT_CLASS_CATEGORIZED; |
| 1366 | 1351 | |
| 1367 | switch(port->type) { | |
| 1368 | case IPT_JOYSTICK_UP: | |
| 1369 | case IPT_JOYSTICK_DOWN: | |
| 1370 | case IPT_JOYSTICK_LEFT: | |
| 1371 | case IPT_JOYSTICK_RIGHT: | |
| 1372 | case IPT_JOYSTICKLEFT_UP: | |
| 1373 | case IPT_JOYSTICKLEFT_DOWN: | |
| 1374 | case IPT_JOYSTICKLEFT_LEFT: | |
| 1375 | case IPT_JOYSTICKLEFT_RIGHT: | |
| 1376 | case IPT_JOYSTICKRIGHT_UP: | |
| 1377 | case IPT_JOYSTICKRIGHT_DOWN: | |
| 1378 | case IPT_JOYSTICKRIGHT_LEFT: | |
| 1379 | case IPT_JOYSTICKRIGHT_RIGHT: | |
| 1380 | case IPT_BUTTON1: | |
| 1381 | case IPT_BUTTON2: | |
| 1382 | case IPT_BUTTON3: | |
| 1383 | case IPT_BUTTON4: | |
| 1384 | case IPT_BUTTON5: | |
| 1385 | case IPT_BUTTON6: | |
| 1386 | case IPT_BUTTON7: | |
| 1387 | case IPT_BUTTON8: | |
| 1388 | case IPT_BUTTON9: | |
| 1389 | case IPT_BUTTON10: | |
| 1390 | case IPT_AD_STICK_X: | |
| 1391 | case IPT_AD_STICK_Y: | |
| 1392 | case IPT_AD_STICK_Z: | |
| 1393 | case IPT_TRACKBALL_X: | |
| 1394 | case IPT_TRACKBALL_Y: | |
| 1395 | case IPT_LIGHTGUN_X: | |
| 1396 | case IPT_LIGHTGUN_Y: | |
| 1397 | case IPT_MOUSE_X: | |
| 1398 | case IPT_MOUSE_Y: | |
| 1399 | case IPT_START: | |
| 1400 | case IPT_SELECT: | |
| 1401 | result = INPUT_CLASS_CONTROLLER; | |
| 1402 | break; | |
| 1352 | switch(field->type) | |
| 1353 | { | |
| 1354 | case IPT_JOYSTICK_UP: | |
| 1355 | case IPT_JOYSTICK_DOWN: | |
| 1356 | case IPT_JOYSTICK_LEFT: | |
| 1357 | case IPT_JOYSTICK_RIGHT: | |
| 1358 | case IPT_JOYSTICKLEFT_UP: | |
| 1359 | case IPT_JOYSTICKLEFT_DOWN: | |
| 1360 | case IPT_JOYSTICKLEFT_LEFT: | |
| 1361 | case IPT_JOYSTICKLEFT_RIGHT: | |
| 1362 | case IPT_JOYSTICKRIGHT_UP: | |
| 1363 | case IPT_JOYSTICKRIGHT_DOWN: | |
| 1364 | case IPT_JOYSTICKRIGHT_LEFT: | |
| 1365 | case IPT_JOYSTICKRIGHT_RIGHT: | |
| 1366 | case IPT_BUTTON1: | |
| 1367 | case IPT_BUTTON2: | |
| 1368 | case IPT_BUTTON3: | |
| 1369 | case IPT_BUTTON4: | |
| 1370 | case IPT_BUTTON5: | |
| 1371 | case IPT_BUTTON6: | |
| 1372 | case IPT_BUTTON7: | |
| 1373 | case IPT_BUTTON8: | |
| 1374 | case IPT_BUTTON9: | |
| 1375 | case IPT_BUTTON10: | |
| 1376 | case IPT_AD_STICK_X: | |
| 1377 | case IPT_AD_STICK_Y: | |
| 1378 | case IPT_AD_STICK_Z: | |
| 1379 | case IPT_TRACKBALL_X: | |
| 1380 | case IPT_TRACKBALL_Y: | |
| 1381 | case IPT_LIGHTGUN_X: | |
| 1382 | case IPT_LIGHTGUN_Y: | |
| 1383 | case IPT_MOUSE_X: | |
| 1384 | case IPT_MOUSE_Y: | |
| 1385 | case IPT_START: | |
| 1386 | case IPT_SELECT: | |
| 1387 | result = INPUT_CLASS_CONTROLLER; | |
| 1388 | break; | |
| 1403 | 1389 | |
| 1404 | case IPT_KEYBOARD: | |
| 1405 | result = INPUT_CLASS_KEYBOARD; | |
| 1406 | break; | |
| 1390 | case IPT_KEYBOARD: | |
| 1391 | result = INPUT_CLASS_KEYBOARD; | |
| 1392 | break; | |
| 1407 | 1393 | |
| 1408 | case IPT_CONFIG_NAME: | |
| 1409 | result = INPUT_CLASS_CONFIG; | |
| 1410 | break; | |
| 1394 | case IPT_CONFIG: | |
| 1395 | result = INPUT_CLASS_CONFIG; | |
| 1396 | break; | |
| 1411 | 1397 | |
| 1412 | case IPT_DIPSWITCH_NAME: | |
| 1413 | result = INPUT_CLASS_DIPSWITCH; | |
| 1414 | break; | |
| 1398 | case IPT_DIPSWITCH: | |
| 1399 | result = INPUT_CLASS_DIPSWITCH; | |
| 1400 | break; | |
| 1415 | 1401 | |
| 1416 | case 0: | |
| 1417 | if (port->name && (port->name != (const char *) -1)) | |
| 1418 | result = INPUT_CLASS_MISC; | |
| 1419 | else | |
| 1402 | case 0: | |
| 1403 | if (field->name && (field->name != (const char *) -1)) | |
| 1404 | result = INPUT_CLASS_MISC; | |
| 1405 | else | |
| 1406 | result = INPUT_CLASS_INTERNAL; | |
| 1407 | break; | |
| 1408 | ||
| 1409 | default: | |
| 1420 | 1410 | result = INPUT_CLASS_INTERNAL; |
| 1421 | break; | |
| 1422 | ||
| 1423 | default: | |
| 1424 | result = INPUT_CLASS_INTERNAL; | |
| 1425 | break; | |
| 1411 | break; | |
| 1426 | 1412 | } |
| 1427 | 1413 | return result; |
| 1428 | 1414 | } |
| 1429 | 1415 | |
| 1430 | 1416 | |
| 1431 | 1417 | |
| 1432 | int input_player_number(const input_ | |
| 1418 | int input_player_number(const input_fi | |
| 1433 | 1419 | { |
| 1434 | 1420 | return port->player; |
| 1435 | 1421 | } |
| 1436 | 1422 | |
| 1437 | 1423 | |
| 1438 | 1424 | |
| 1425 | /*------------------------------------------------- | |
| 1426 | input_has_input_class - checks to see if a | |
| 1427 | particular input class is present | |
| 1428 | -------------------------------------------------*/ | |
| 1429 | ||
| 1439 | 1430 | int input_has_input_class(running_machine *machine, int inputclass) |
| 1440 | 1431 | { |
| 1441 | input_port_entry *in; | |
| 1442 | for (in = machine->input_ports; in->type != IPT_END; in++) | |
| 1432 | const input_port_config *port; | |
| 1433 | const input_field_config *field; | |
| 1434 | ||
| 1435 | for (port = machine->portconfig; port != NULL; port = port->next) | |
| 1443 | 1436 | { |
| 1444 | if (input_classify_port(in) == inputclass) | |
| 1445 | return TRUE; | |
| 1437 | for (field = port->fieldlist; field != NULL; field = field->next) | |
| 1438 | { | |
| 1439 | if (input_classify_port(field) == inputclass) | |
| 1440 | return TRUE; | |
| 1441 | } | |
| 1446 | 1442 | } |
| 1447 | 1443 | return FALSE; |
| 1448 | 1444 | } |
| 1449 | 1445 | |
| 1450 | 1446 | |
| 1451 | 1447 | |
| 1448 | /*------------------------------------------------- | |
| 1449 | input_count_players - counts the number of | |
| 1450 | active players | |
| 1451 | -------------------------------------------------*/ | |
| 1452 | ||
| 1452 | 1453 | int input_count_players(running_machine *machine) |
| 1453 | 1454 | { |
| 1454 | const input_port_entry *in; | |
| 1455 | const input_port_config *port; | |
| 1456 | const input_field_config *field; | |
| 1455 | 1457 | int joystick_count; |
| 1456 | 1458 | |
| 1457 | 1459 | joystick_count = 0; |
| 1458 | for ( | |
| 1460 | for (port = machine-> | |
| 1459 | 1461 | { |
| 1460 | | |
| 1462 | | |
| 1461 | 1463 | { |
| 1462 | if (joystick_count <= in->player + 1) | |
| 1463 | joystick_count = in->player + 1; | |
| 1464 | if (input_classify_port(field) == INPUT_CLASS_CONTROLLER) | |
| 1465 | { | |
| 1466 | if (joystick_count <= field->player + 1) | |
| 1467 | joystick_count = field->player + 1; | |
| 1468 | } | |
| 1464 | 1469 | } |
| 1465 | 1470 | } |
| 1466 | 1471 | return joystick_count; |
| r2724 | r2725 | |
| 1468 | 1473 | |
| 1469 | 1474 | |
| 1470 | 1475 | |
| 1476 | /*------------------------------------------------- | |
| 1477 | input_category_active - checks to see if a | |
| 1478 | specific category is active | |
| 1479 | -------------------------------------------------*/ | |
| 1480 | ||
| 1471 | 1481 | int input_category_active(running_machine *machine, int category) |
| 1472 | 1482 | { |
| 1473 | const input_port_entry *in; | |
| 1474 | const input_port_entry *in_base = NULL; | |
| 1483 | int found; | |
| 1484 | const input_port_config *port; | |
| 1485 | const input_field_config *field = NULL; | |
| 1486 | const input_setting_config *setting; | |
| 1475 | 1487 | |
| 1476 | 1488 | assert(category >= 1); |
| 1477 | 1489 | |
| 1478 | for (in = machine->input_ports; in->type != IPT_END; in++) | |
| 1490 | found = FALSE; | |
| 1491 | for (port = machine->portconfig; !found && (port != NULL); port = port->next) | |
| 1479 | 1492 | { |
| 1480 | switch(in->type) { | |
| 1481 | case IPT_CATEGORY_NAME: | |
| 1482 | in_base = in; | |
| 1483 | break; | |
| 1493 | for (field = port->fieldlist; !found && (field != NULL); field = field->next) | |
| 1494 | found = (field->type == IPT_CATEGORY) && (field->category == category); | |
| 1495 | } | |
| 1484 | 1496 | |
| 1485 | case IPT_CATEGORY_SETTING: | |
| 1486 | if ((in->category == category) && (in_base->default_value == in->default_value)) | |
| 1497 | if (field != NULL) | |
| 1498 | { | |
| 1499 | for (setting = field->settinglist; setting != NULL; setting = setting->next) | |
| 1500 | { | |
| 1501 | if (setting->value == field->defvalue) | |
| 1487 | 1502 | return TRUE; |
| 1488 | break; | |
| 1489 | 1503 | } |
| 1490 | 1504 | } |
| 1491 | 1505 | return FALSE; |
| r2724 | r2725 | |
|---|---|---|
| 51 | 51 | |
| 52 | 52 | /* these are called by the core; they should not be called from FEs */ |
| 53 | 53 | void inputx_init(running_machine *machine); |
| 54 | void mess_input_port_update_hook(running_machine *machine, int portnum, UINT32 *digital); | |
| 55 | void inputx_handle_mess_extensions(input_port_entry *ipt); | |
| 54 | void mess_input_port_update_hook(running_machine *machine, const input_port_config *port); | |
| 55 | /*void inputx_handle_mess_extensions(input_port_entry *ipt);*/ | |
| 56 | 56 | |
| 57 | 57 | /* called by drivers to setup natural keyboard support */ |
| 58 | 58 | void inputx_setup_natural_keyboard( |
| r2724 | r2725 | |
| 60 | 60 | int (*accept_char)(unicode_char ch), |
| 61 | 61 | int (*charqueue_empty)(void)); |
| 62 | 62 | |
| 63 | /* run the validity checks */ | |
| 64 | int inputx_validitycheck(const game_driver *gamedrv, input_port_entry **memory); | |
| 63 | /* validity checks */ | |
| 64 | int mess_validate_input_ports(int drivnum, const machine_config *config, const input_port_config *portlist); | |
| 65 | int mess_validate_natural_keyboard_statics(void); | |
| 65 | 66 | |
| 66 | 67 | /* these can be called from FEs */ |
| 67 | 68 | int inputx_can_post(running_machine *machine); |
| r2724 | r2725 | |
| 90 | 91 | void inputx_postn_coded_rate(running_machine *machine, const char *text, size_t text_len, attotime rate); |
| 91 | 92 | |
| 92 | 93 | /* miscellaneous functions */ |
| 93 | int input_classify_port(const input_ | |
| 94 | int input_classify_port(const input_fi | |
| 94 | 95 | int input_has_input_class(running_machine *machine, int inputclass); |
| 95 | int input_player_number(const input_ | |
| 96 | int input_player_number(const input_fi | |
| 96 | 97 | int input_count_players(running_machine *machine); |
| 97 | 98 | int input_category_active(running_machine *machine, int category); |
| 98 | 99 |
| r2724 | r2725 | |
|---|---|---|
| 7 | 7 | *********************************************************************/ |
| 8 | 8 | |
| 9 | 9 | #include "driver.h" |
| 10 | #include "deprecat.h" | |
| 11 | 10 | #include "utils.h" |
| 12 | 11 | #include "image.h" |
| 13 | 12 | #include "ui.h" |
| r2724 | r2725 | |
| 449 | 448 | /* and mask to get bits */ |
| 450 | 449 | #define SEL_BITS_MASK (~SEL_MASK) |
| 451 | 450 | |
| 452 | static int fileselect(int selected, const char *default_selection, const char *working_directory) | |
| 451 | static int fileselect(running_machine *machine, int selected, const char *default_selection, const char *working_directory) | |
| 453 | 452 | { |
| 454 | 453 | int sel, total, arrowize; |
| 455 | 454 | int visible; |
| 456 | running_machine *machine = Machine; | |
| 457 | 455 | |
| 458 | 456 | sel = selected - 1; |
| 459 | 457 | |
| r2724 | r2725 | |
| 536 | 534 | /* Maybe the following code up to IPT_UI_PAUSE can be replaced with a call to ui_menu_generic_keys() */ |
| 537 | 535 | |
| 538 | 536 | /* up backs up by one item */ |
| 539 | if (input_ui_pressed_repeat(IPT_UI_UP, 6)) | |
| 537 | if (input_ui_pressed_repeat(machine, IPT_UI_UP, 6)) | |
| 540 | 538 | sel = (sel + total - 1) % total; |
| 541 | 539 | |
| 542 | 540 | /* down advances by one item */ |
| 543 | if (input_ui_pressed_repeat(IPT_UI_DOWN, 6)) | |
| 541 | if (input_ui_pressed_repeat(machine, IPT_UI_DOWN, 6)) | |
| 544 | 542 | sel = (sel + 1) % total; |
| 545 | 543 | |
| 546 | 544 | /* page up backs up by visible_items */ |
| 547 | if (input_ui_pressed_repeat(IPT_UI_PAGE_UP, 6)) | |
| 545 | if (input_ui_pressed_repeat(machine, IPT_UI_PAGE_UP, 6)) | |
| 548 | 546 | { |
| 549 | 547 | if (sel >= visible - 1) |
| 550 | 548 | sel -= visible - 1; |
| r2724 | r2725 | |
| 553 | 551 | } |
| 554 | 552 | |
| 555 | 553 | /* page down advances by visible_items */ |
| 556 | if (input_ui_pressed_repeat(IPT_UI_PAGE_DOWN, 6)) | |
| 554 | if (input_ui_pressed_repeat(machine, IPT_UI_PAGE_DOWN, 6)) | |
| 557 | 555 | { |
| 558 | 556 | sel += visible - 1; |
| 559 | 557 | if (sel >= total) |
| r2724 | r2725 | |
| 561 | 559 | } |
| 562 | 560 | |
| 563 | 561 | /* home goes to the start */ |
| 564 | if (input_ui_pressed(IPT_UI_HOME)) | |
| 562 | if (input_ui_pressed(machine, IPT_UI_HOME)) | |
| 565 | 563 | sel = 0; |
| 566 | 564 | |
| 567 | 565 | /* end goes to the last */ |
| 568 | if (input_ui_pressed(IPT_UI_END)) | |
| 566 | if (input_ui_pressed(machine, IPT_UI_END)) | |
| 569 | 567 | sel = total - 1; |
| 570 | 568 | |
| 571 | 569 | /* pause enables/disables pause */ |
| 572 | if (input_ui_pressed(IPT_UI_PAUSE)) | |
| 570 | if (input_ui_pressed(machine, IPT_UI_PAUSE)) | |
| 573 | 571 | mame_pause(machine, !mame_is_paused(machine)); |
| 574 | 572 | |
| 575 | if (input_ui_pressed(IPT_UI_SELECT)) | |
| 573 | if (input_ui_pressed(machine, IPT_UI_SELECT)) | |
| 576 | 574 | { |
| 577 | 575 | if (sel < SEL_MASK) |
| 578 | 576 | { |
| r2724 | r2725 | |
| 643 | 641 | } |
| 644 | 642 | } |
| 645 | 643 | |
| 646 | if (input_ui_pressed(IPT_UI_CANCEL)) | |
| 644 | if (input_ui_pressed(machine, IPT_UI_CANCEL)) | |
| 647 | 645 | sel = -1; |
| 648 | 646 | |
| 649 | if (input_ui_pressed(IPT_UI_CONFIGURE)) | |
| 647 | if (input_ui_pressed(machine, IPT_UI_CONFIGURE)) | |
| 650 | 648 | sel = -2; |
| 651 | 649 | } |
| 652 | 650 | else |
| r2724 | r2725 | |
| 665 | 663 | return sel + 1; |
| 666 | 664 | } |
| 667 | 665 | |
| 668 | int filemanager(int selected) | |
| 666 | int filemanager(running_machine *machine, int selected) | |
| 669 | 667 | { |
| 670 | running_machine *machine = Machine; | |
| 671 | 668 | static int previous_sel; |
| 672 | 669 | const char *name; |
| 673 | 670 | ui_menu_item menu_items[40]; |
| r2724 | r2725 | |
| 699 | 696 | if (sel & (2 << SEL_BITS)) |
| 700 | 697 | { |
| 701 | 698 | image = devices[previous_sel & SEL_MASK]; |
| 702 | sel = fileselect(selected & ~(2 << SEL_BITS), image_filename(image), image_working_directory(image)); | |
| 699 | sel = fileselect(machine, selected & ~(2 << SEL_BITS), image_filename(image), image_working_directory(image)); | |
| 703 | 700 | if (sel != 0 && sel != -1 && sel!=-2) |
| 704 | 701 | return sel | (2 << SEL_BITS); |
| 705 | 702 | |
| r2724 | r2725 | |
| 757 | 754 | |
| 758 | 755 | visible = ui_menu_draw(menu_items, total, sel, NULL); |
| 759 | 756 | |
| 760 | if (input_ui_pressed(IPT_UI_SELECT)) | |
| 757 | if (input_ui_pressed(machine, IPT_UI_SELECT)) | |
| 761 | 758 | { |
| 762 | 759 | int os_sel; |
| 763 | 760 | |
| r2724 | r2725 | |
| 807 | 804 | sel |= 1 << SEL_BITS; /* we'll ask for a key */ |
| 808 | 805 | } |
| 809 | 806 | } |
| 810 | else if (input_ui_pressed(IPT_UI_CANCEL)) | |
| 807 | else if (input_ui_pressed(machine, IPT_UI_CANCEL)) | |
| 811 | 808 | { |
| 812 | 809 | sel = -1; |
| 813 | 810 | } |
| 814 | 811 | else |
| 815 | 812 | { |
| 816 | ui_menu_generic_keys(&sel, total, visible); | |
| 813 | ui_menu_generic_keys(machine, &sel, total, visible); | |
| 817 | 814 | } |
| 818 | 815 | |
| 819 | if (input_ui_pressed(IPT_UI_CONFIGURE)) | |
| 816 | if (input_ui_pressed(machine, IPT_UI_CONFIGURE)) | |
| 820 | 817 | sel = -2; |
| 821 | 818 | |
| 822 | 819 | return sel + 1; |
| r2724 | r2725 | |
|---|---|---|
| 286 | 286 | int error = 0; |
| 287 | 287 | iodevice_t devtype; |
| 288 | 288 | const char *name; |
| 289 | input_port_entry *inputports = NULL; | |
| 290 | 289 | |
| 291 | 290 | /* make sure that all of the UI_* strings are set for all devices */ |
| 292 | 291 | for (devtype = 0; devtype < IO_COUNT; devtype++) |
| r2724 | r2725 | |
| 310 | 309 | |
| 311 | 310 | /* check system config */ |
| 312 | 311 | ram_option_count(drivers[i]); |
| 313 | ||
| 314 | /* make sure that our input system likes this driver */ | |
| 315 | error = inputx_validitycheck(drivers[i], &inputports) || error; | |
| 316 | 312 | } |
| 317 | 313 | |
| 318 | 314 | /* call other validity checks */ |
| 319 | error = | |
| 315 | error = mess | |
| 320 | 316 | error = device_valididtychecks() || error; |
| 321 | 317 | |
| 322 | 318 | return error; |
| r2724 | r2725 | |
|---|---|---|
| 1264 | 1264 | // input_port_mutable_seq |
| 1265 | 1265 | //============================================================ |
| 1266 | 1266 | |
| 1267 | static input_seq *input_port_mutable_seq(input_ | |
| 1267 | static input_seq *input_port_mutable_seq(input_fi | |
| 1268 | 1268 | { |
| 1269 | 1269 | input_seq *portseq; |
| 1270 | 1270 | |
| 1271 | // if port is disabled, return no key | |
| 1272 | if (port->unused) | |
| 1271 | // if field is disabled, return no key | |
| 1272 | if (field->flags & FIELD_FLAG_UNUSED) | |
| 1273 | 1273 | return NULL; |
| 1274 | 1274 | |
| 1275 | 1275 | // handle the various seq types |
| 1276 | switch (seqtype) | |
| 1277 | { | |
| 1278 | case SEQ_TYPE_STANDARD: | |
| 1279 | portseq = &port->seq; | |
| 1280 | break; | |
| 1276 | portseq = &field->seq[seqtype]; | |
| 1281 | 1277 | |
| 1282 | case SEQ_TYPE_INCREMENT: | |
| 1283 | portseq = &port->analog.incseq; | |
| 1284 | break; | |
| 1285 | ||
| 1286 | case SEQ_TYPE_DECREMENT: | |
| 1287 | portseq = &port->analog.decseq; | |
| 1288 | break; | |
| 1289 | ||
| 1290 | default: | |
| 1291 | return NULL; | |
| 1292 | } | |
| 1293 | ||
| 1294 | 1278 | // does this override the default? if not, find the default setting |
| 1295 | 1279 | if (input_seq_get_1(portseq) == SEQCODE_DEFAULT) |
| 1296 | 1280 | { |
| 1297 | 1281 | const input_seq *default_portseq; |
| 1298 | default_portseq = input_ | |
| 1282 | default_portseq = input_ | |
| 1299 | 1283 | *portseq = *default_portseq; |
| 1300 | 1284 | } |
| 1301 | 1285 | return portseq; |
| r2724 | r2725 | |
| 1306 | 1290 | //============================================================ |
| 1307 | 1291 | |
| 1308 | 1292 | static int dialog_add_single_seqselect(struct _dialog_box *di, short x, short y, |
| 1309 | short cx, short cy, input_ | |
| 1293 | short cx, short cy, input_fi | |
| 1310 | 1294 | { |
| 1311 | 1295 | seqselect_info *stuff; |
| 1312 | 1296 | input_seq *code; |
| 1313 | 1297 | |
| 1314 | code = input_port_mutable_seq( | |
| 1298 | code = input_port_mutable_seq(field, seq); | |
| 1315 | 1299 | |
| 1316 | 1300 | if (dialog_write_item(di, WS_CHILD | WS_VISIBLE | SS_ENDELLIPSIS | ES_CENTER | SS_SUNKEN, |
| 1317 | 1301 | x, y, cx, cy, NULL, DLGITEM_EDIT, NULL)) |
| r2724 | r2725 | |
| 1336 | 1320 | // win_dialog_add_seqselect |
| 1337 | 1321 | //============================================================ |
| 1338 | 1322 | |
| 1339 | int win_dialog_add_portselect(dialog_box *dialog, input_ | |
| 1323 | int win_dialog_add_portselect(dialog_box *dialog, input_fi | |
| 1340 | 1324 | { |
| 1341 | 1325 | dialog_box *di = dialog; |
| 1342 | 1326 | short x; |
| r2724 | r2725 | |
| 1353 | 1337 | int is_analog[3]; |
| 1354 | 1338 | int len; |
| 1355 | 1339 | |
| 1356 | port_name = input_ | |
| 1340 | port_name = input_field_name(field); | |
| 1357 | 1341 | assert(port_name); |
| 1358 | 1342 | |
| 1359 | if ( | |
| 1343 | if (field->t | |
| 1360 | 1344 | { |
| 1361 | 1345 | seq_types[seq_count] = SEQ_TYPE_STANDARD; |
| 1362 | 1346 | port_suffix[seq_count] = " Analog"; |
| r2724 | r2725 | |
| 1405 | 1389 | x += dialog->layout->label_width + DIM_HORIZONTAL_SPACING; |
| 1406 | 1390 | |
| 1407 | 1391 | if (dialog_add_single_seqselect(di, x, y, DIM_EDIT_WIDTH, DIM_NORMAL_ROW_HEIGHT, |
| 1408 | | |
| 1392 | field, is_analog[seq], seq_types[seq])) | |
| 1409 | 1393 | return 1; |
| 1410 | 1394 | y += DIM_VERTICAL_SPACING + DIM_NORMAL_ROW_HEIGHT; |
| 1411 | 1395 | x += DIM_EDIT_WIDTH + DIM_HORIZONTAL_SPACING; |
| r2724 | r2725 | |
| 1427 | 1411 | height /= pixels_to_ydlgunits; |
| 1428 | 1412 | |
| 1429 | 1413 | if (dialog_add_single_seqselect(di, x, y, width, height, |
| 1430 | | |
| 1414 | field, is_analog[seq], seq_types[seq])) | |
| 1431 | 1415 | return 1; |
| 1432 | 1416 | } |
| 1433 | 1417 | } |
| r2724 | r2725 | |
|---|---|---|
| 126 | 126 | static void customize_input(running_machine *machine, HWND wnd, const char *title, artwork_cust_type cust_type, int player, int inputclass, const char *section) |
| 127 | 127 | { |
| 128 | 128 | dialog_box *dlg; |
| 129 | input_port_entry *in; | |
| 129 | const input_port_config *port; | |
| 130 | const input_field_config *field; | |
| 130 | 131 | png_info png; |
| 131 | 132 | struct inputform_customization customizations[128]; |
| 132 | 133 | RECT *pr; |
| r2724 | r2725 | |
| 134 | 135 | |
| 135 | 136 | struct |
| 136 | 137 | { |
| 137 | input_ | |
| 138 | input_fi | |
| 138 | 139 | const RECT *pr; |
| 139 | 140 | } portslots[256]; |
| 140 | 141 | |
| r2724 | r2725 | |
| 157 | 158 | win_dialog_add_separator(dlg); |
| 158 | 159 | } |
| 159 | 160 | |
| 160 | in = machine->input_ports; | |
| 161 | while(in->type != IPT_END) | |
| 161 | for (port = machine->portconfig; port != NULL; port = port->next) | |
| 162 | 162 | { |
| 163 | this_inputclass = input_classify_port(in); | |
| 164 | if (input_port_name(in) && (this_inputclass == inputclass)) | |
| 163 | for (field = port->fieldlist; field != NULL; field = field->next) | |
| 165 | 164 | { |
| 166 | /* most of the time, the player parameter is the player number | |
| 167 | * but in the case of INPUT_CLASS_CATEGORIZED, it is the | |
| 168 | * category */ | |
| 169 | if (inputclass == INPUT_CLASS_CATEGORIZED) | |
| 170 | this_player = in->category; | |
| 171 | else | |
| 172 | this_player = input_player_number(in); | |
| 165 | this_inputclass = input_classify_port(field); | |
| 166 | if (input_field_name(field) && (this_inputclass == inputclass)) | |
| 167 | { | |
| 168 | /* most of the time, the player parameter is the player number | |
| 169 | * but in the case of INPUT_CLASS_CATEGORIZED, it is the | |
| 170 | * category */ | |
| 171 | if (inputclass == INPUT_CLASS_CATEGORIZED) | |
| 172 | this_player = field->category; | |
| 173 | else | |
| 174 | this_player = input_player_number(field); | |
| 173 | 175 | |
| 174 | if (this_player == player) | |
| 175 | { | |
| 176 | /* check to see if the custom artwork for this configure dialog | |
| 177 | * says anything about this input */ | |
| 178 | pr = NULL; | |
| 179 | for (i = 0; customizations[i].ipt != IPT_END; i++) | |
| 176 | if (this_player == player) | |
| 180 | 177 | { |
| 181 | if (in->type == customizations[i].ipt) | |
| 178 | /* check to see if the custom artwork for this configure dialog | |
| 179 | * says anything about this input */ | |
| 180 | pr = NULL; | |
| 181 | for (i = 0; customizations[i].ipt != IPT_END; i++) | |
| 182 | 182 | { |
| 183 | pr = (RECT *) alloca(sizeof(*pr)); | |
| 184 | pr->left = customizations[i].x; | |
| 185 | pr->top = customizations[i].y; | |
| 186 | pr->right = pr->left + customizations[i].width; | |
| 187 | pr->bottom = pr->top + customizations[i].height; | |
| 188 | break; | |
| 183 | if (field->type == customizations[i].ipt) | |
| 184 | { | |
| 185 | pr = (RECT *) alloca(sizeof(*pr)); | |
| 186 | pr->left = customizations[i].x; | |
| 187 | pr->top = customizations[i].y; | |
| 188 | pr->right = pr->left + customizations[i].width; | |
| 189 | pr->bottom = pr->top + customizations[i].height; | |
| 190 | break; | |
| 191 | } | |
| 189 | 192 | } |
| 190 | } | |
| 191 | 193 | |
| 192 | /* store this InputPort/RECT combo in our list. we do not | |
| 193 | * necessarily want to add it yet because we the INI might | |
| 194 | * want to reorder the tab order */ | |
| 195 | if (customizations[i].ipt == IPT_END) | |
| 196 | i = portslot_count++; | |
| 197 | if (i < (sizeof(portslots) / sizeof(portslots[0]))) | |
| 198 | { | |
| 199 | portslots[i].in = in; | |
| 200 | portslots[i].pr = pr; | |
| 194 | /* store this InputPort/RECT combo in our list. we do not | |
| 195 | * necessarily want to add it yet because we the INI might | |
| 196 | * want to reorder the tab order */ | |
| 197 | if (customizations[i].ipt == IPT_END) | |
| 198 | i = portslot_count++; | |
| 199 | if (i < (sizeof(portslots) / sizeof(portslots[0]))) | |
| 200 | { | |
| 201 | portslots[i].field = (input_field_config *) field; | |
| 202 | portslots[i].pr = pr; | |
| 203 | } | |
| 201 | 204 | } |
| 202 | 205 | } |
| 203 | 206 | } |
| 204 | in++; | |
| 205 | 207 | } |
| 206 | 208 | |
| 207 | 209 | /* finally add the portselects to the dialog */ |
| r2724 | r2725 | |
| 209 | 211 | portslot_count = sizeof(portslots) / sizeof(portslots[0]); |
| 210 | 212 | for (i = 0; i < portslot_count; i++) |
| 211 | 213 | { |
| 212 | if (portslots[i].i | |
| 214 | if (portslots[i].field) | |
| 213 | 215 | { |
| 214 | if (win_dialog_add_portselect(dlg, portslots[i].i | |
| 216 | if (win_dialog_add_portselect(dlg, portslots[i].field, portslots[i].pr)) | |
| 215 | 217 | goto done; |
| 216 | 218 | } |
| 217 | 219 | } |
| r2724 | r2725 | |
| 281 | 283 | |
| 282 | 284 | static void storeval_inputport(void *param, int val) |
| 283 | 285 | { |
| 284 | input_port_entry *in = (input_port_entry *) param; | |
| 285 | in->default_value = (UINT16) val; | |
| 286 | input_field_config *field = (input_field_config *) param; | |
| 287 | field->defvalue = (UINT16) val; | |
| 286 | 288 | } |
| 287 | 289 | |
| 288 | 290 | |
| r2724 | r2725 | |
| 291 | 293 | // customize_switches |
| 292 | 294 | //============================================================ |
| 293 | 295 | |
| 294 | static void customize_switches(running_machine *machine, HWND wnd, int title_string_num, UINT32 ipt_name | |
| 296 | static void customize_switches(running_machine *machine, HWND wnd, int title_string_num, UINT32 ipt_name | |
| 295 | 297 | { |
| 296 | 298 | dialog_box *dlg; |
| 297 | input_port_entry *in; | |
| 299 | const input_port_config *port; | |
| 300 | const input_field_config *field; | |
| 301 | const input_setting_config *setting; | |
| 298 | 302 | const char *switch_name = NULL; |
| 299 | 303 | UINT32 type; |
| 300 | 304 | |
| r2724 | r2725 | |
| 302 | 306 | if (!dlg) |
| 303 | 307 | goto done; |
| 304 | 308 | |
| 305 | for ( | |
| 309 | for (port = machine-> | |
| 306 | 310 | { |
| 307 | type = in->type; | |
| 311 | for (field = port->fieldlist; field != NULL; field = field->next) | |
| 312 | { | |
| 313 | type = field->type; | |
| 308 | 314 | |
| 309 | if (type == ipt_name) | |
| 310 | { | |
| 311 | if (input_port_active(in)) | |
| 315 | if (type == ipt_name) | |
| 312 | 316 | { |
| 313 | switch_name = input_port_name(in); | |
| 314 | if (win_dialog_add_combobox(dlg, switch_name, in->default_value, storeval_inputport, in)) | |
| 317 | switch_name = input_field_name(field); | |
| 318 | if (win_dialog_add_combobox(dlg, switch_name, field->defvalue, storeval_inputport, (input_field_config *) field)) | |
| 315 | 319 | goto done; |
| 320 | ||
| 321 | for (setting = field->settinglist; setting != NULL; setting = setting->next) | |
| 322 | { | |
| 323 | if (win_dialog_add_combobox_item(dlg, setting->name, setting->value)) | |
| 324 | goto done; | |
| 325 | } | |
| 316 | 326 | } |
| 317 | else | |
| 318 | { | |
| 319 | switch_name = NULL; | |
| 320 | } | |
| 321 | 327 | } |
| 322 | else if (type == ipt_setting) | |
| 323 | { | |
| 324 | if (switch_name) | |
| 325 | { | |
| 326 | if (win_dialog_add_combobox_item(dlg, input_port_name(in), in->default_value)) | |
| 327 | goto done; | |
| 328 | } | |
| 329 | } | |
| 330 | 328 | } |
| 331 | 329 | |
| 332 | 330 | if (win_dialog_add_standard_buttons(dlg)) |
| r2724 | r2725 | |
| 347 | 345 | |
| 348 | 346 | static void customize_dipswitches(running_machine *machine, HWND wnd) |
| 349 | 347 | { |
| 350 | customize_switches(machine, wnd, UI_dipswitches, IPT_DIPSWITCH | |
| 348 | customize_switches(machine, wnd, UI_dipswitches, IPT_DIPSWITCH | |
| 351 | 349 | } |
| 352 | 350 | |
| 353 | 351 | |
| r2724 | r2725 | |
| 358 | 356 | |
| 359 | 357 | static void customize_configuration(running_machine *machine, HWND wnd) |
| 360 | 358 | { |
| 361 | customize_switches(machine, wnd, UI_configuration, IPT_CONFIG | |
| 359 | customize_switches(machine, wnd, UI_configuration, IPT_CONFIG | |
| 362 | 360 | } |
| 363 | 361 | |
| 364 | 362 | |
| r2724 | r2725 | |
| 367 | 365 | // customize_analogcontrols |
| 368 | 366 | //============================================================ |
| 369 | 367 | |
| 368 | enum | |
| 369 | { | |
| 370 | ANALOG_ITEM_KEYSPEED, | |
| 371 | ANALOG_ITEM_CENTERSPEED, | |
| 372 | ANALOG_ITEM_REVERSE, | |
| 373 | ANALOG_ITEM_SENSITIVITY | |
| 374 | }; | |
| 375 | ||
| 376 | ||
| 377 | ||
| 378 | static void store_analogitem(void *param, int val, int selected_item) | |
| 379 | { | |
| 380 | const input_field_config *field = (const input_field_config *) param; | |
| 381 | input_field_user_settings settings; | |
| 382 | ||
| 383 | input_field_get_user_settings(field, &settings); | |
| 384 | ||
| 385 | switch(selected_item) | |
| 386 | { | |
| 387 | case ANALOG_ITEM_KEYSPEED: settings.delta = val; break; | |
| 388 | case ANALOG_ITEM_CENTERSPEED: settings.centerdelta = val; break; | |
| 389 | case ANALOG_ITEM_REVERSE: settings.reverse = val; break; | |
| 390 | case ANALOG_ITEM_SENSITIVITY: settings.sensitivity = val; break; | |
| 391 | } | |
| 392 | input_field_set_user_settings(field, &settings); | |
| 393 | } | |
| 394 | ||
| 395 | ||
| 396 | ||
| 370 | 397 | static void store_delta(void *param, int val) |
| 371 | 398 | { |
| 372 | | |
| 399 | s | |
| 373 | 400 | } |
| 374 | 401 | |
| 375 | 402 | |
| 376 | 403 | |
| 377 | 404 | static void store_centerdelta(void *param, int val) |
| 378 | 405 | { |
| 379 | | |
| 406 | s | |
| 380 | 407 | } |
| 381 | 408 | |
| 382 | 409 | |
| 383 | 410 | |
| 384 | 411 | static void store_reverse(void *param, int val) |
| 385 | 412 | { |
| 386 | | |
| 413 | s | |
| 387 | 414 | } |
| 388 | 415 | |
| 389 | 416 | |
| 390 | 417 | |
| 391 | 418 | static void store_sensitivity(void *param, int val) |
| 392 | 419 | { |
| 393 | | |
| 420 | s | |
| 394 | 421 | } |
| 395 | 422 | |
| 396 | 423 | |
| 397 | 424 | |
| 425 | static int port_type_is_analog(int type) | |
| 426 | { | |
| 427 | return (type >= __ipt_analog_start && type <= __ipt_analog_end); | |
| 428 | } | |
| 429 | ||
| 430 | ||
| 431 | ||
| 398 | 432 | static void customize_analogcontrols(running_machine *machine, HWND wnd) |
| 399 | 433 | { |
| 400 | 434 | dialog_box *dlg; |
| 401 | input_port_entry *in; | |
| 435 | const input_port_config *port; | |
| 436 | const input_field_config *field; | |
| 437 | input_field_user_settings settings; | |
| 402 | 438 | const char *name; |
| 403 | 439 | char buf[255]; |
| 404 | 440 | static const struct dialog_layout layout = { 120, 52 }; |
| r2724 | r2725 | |
| 407 | 443 | if (!dlg) |
| 408 | 444 | goto done; |
| 409 | 445 | |
| 410 | in = machine->input_ports; | |
| 411 | ||
| 412 | while (in->type != IPT_END) | |
| 446 | for (port = machine->portconfig; port != NULL; port = port->next) | |
| 413 | 447 | { |
| 414 | | |
| 448 | | |
| 415 | 449 | { |
| 416 | name = input_port_name(in); | |
| 450 | if (port_type_is_analog(field->type)) | |
| 451 | { | |
| 452 | input_field_get_user_settings(field, &settings); | |
| 453 | name = input_field_name(field); | |
| 417 | 454 | |
| 418 | _snprintf(buf, sizeof(buf) / sizeof(buf[0]), | |
| 419 | "%s %s", name, ui_getstring(UI_keyjoyspeed)); | |
| 420 | if (win_dialog_add_adjuster(dlg, buf, in->analog.delta, 1, 255, FALSE, store_delta, in)) | |
| 421 | goto done; | |
| 455 | _snprintf(buf, sizeof(buf) / sizeof(buf[0]), | |
| 456 | "%s %s", name, ui_getstring(UI_keyjoyspeed)); | |
| 457 | if (win_dialog_add_adjuster(dlg, buf, settings.delta, 1, 255, FALSE, store_delta, (input_field_config *) field)) | |
| 458 | goto done; | |
| 422 | 459 | |
| 423 | _snprintf(buf, sizeof(buf) / sizeof(buf[0]), | |
| 424 | "%s %s", name, ui_getstring(UI_centerspeed)); | |
| 425 | if (win_dialog_add_adjuster(dlg, buf, in->analog.centerdelta, 1, 255, FALSE, store_centerdelta, in)) | |
| 426 | goto done; | |
| 460 | _snprintf(buf, sizeof(buf) / sizeof(buf[0]), | |
| 461 | "%s %s", name, ui_getstring(UI_centerspeed)); | |
| 462 | if (win_dialog_add_adjuster(dlg, buf, settings.centerdelta, 1, 255, FALSE, store_centerdelta, (input_field_config *) field)) | |
| 463 | goto done; | |
| 427 | 464 | |
| 428 | _snprintf(buf, sizeof(buf) / sizeof(buf[0]), | |
| 429 | "%s %s", name, ui_getstring(UI_reverse)); | |
| 430 | if (win_dialog_add_combobox(dlg, buf, in->analog.reverse ? 1 : 0, store_reverse, in)) | |
| 431 | goto done; | |
| 432 | if (win_dialog_add_combobox_item(dlg, ui_getstring(UI_off), 0)) | |
| 433 | goto done; | |
| 434 | if (win_dialog_add_combobox_item(dlg, ui_getstring(UI_on), 1)) | |
| 435 | goto done; | |
| 465 | _snprintf(buf, sizeof(buf) / sizeof(buf[0]), | |
| 466 | "%s %s", name, ui_getstring(UI_reverse)); | |
| 467 | if (win_dialog_add_combobox(dlg, buf, settings.reverse ? 1 : 0, store_reverse, (input_field_config *) field)) | |
| 468 | goto done; | |
| 469 | if (win_dialog_add_combobox_item(dlg, ui_getstring(UI_off), 0)) | |
| 470 | goto done; | |
| 471 | if (win_dialog_add_combobox_item(dlg, ui_getstring(UI_on), 1)) | |
| 472 | goto done; | |
| 436 | 473 | |
| 437 | _snprintf(buf, sizeof(buf) / sizeof(buf[0]), | |
| 438 | "%s %s", name, ui_getstring(UI_sensitivity)); | |
| 439 | if (win_dialog_add_adjuster(dlg, buf, in->analog.sensitivity, 1, 255, TRUE, store_sensitivity, in)) | |
| 440 | goto done; | |
| 474 | _snprintf(buf, sizeof(buf) / sizeof(buf[0]), | |
| 475 | "%s %s", name, ui_getstring(UI_sensitivity)); | |
| 476 | if (win_dialog_add_adjuster(dlg, buf, settings.sensitivity, 1, 255, TRUE, store_sensitivity, (input_field_config *) field)) | |
| 477 | goto done; | |
| 478 | } | |
| 441 | 479 | } |
| 442 | in++; | |
| 443 | 480 | } |
| 444 | 481 | |
| 445 | 482 | if (win_dialog_add_standard_buttons(dlg)) |
| r2724 | r2725 | |
| 1088 | 1125 | HMENU joystick_menu; |
| 1089 | 1126 | int i, j; |
| 1090 | 1127 | HMENU submenu = NULL; |
| 1091 | const input_port_entry *in; | |
| 1092 | const input_port_entry *in_setting; | |
| 1128 | const input_port_config *port; | |
| 1129 | const input_field_config *field; | |
| 1130 | const input_setting_config *setting; | |
| 1093 | 1131 | char buf[256]; |
| 1094 | 1132 | int child_count = 0; |
| 1095 | 1133 | |
| 1096 | in = machine->input_ports; | |
| 1097 | 1134 | use_input_categories = 0; |
| 1098 | | |
| 1135 | for (port = machi | |
| 1099 | 1136 | { |
| 1100 | | |
| 1137 | | |
| 1101 | 1138 | { |
| 1102 | use_input_categories = 1; | |
| 1103 | break; | |
| 1139 | if (field->type == IPT_CATEGORY) | |
| 1140 | { | |
| 1141 | use_input_categories = 1; | |
| 1142 | break; | |
| 1143 | } | |
| 1104 | 1144 | } |
| 1105 | in++; | |
| 1106 | 1145 | } |
| 1107 | 1146 | |
| 1108 | 1147 | joystick_menu = find_sub_menu(menu_bar, "&Options\0&Joysticks\0", TRUE); |
| r2724 | r2725 | |
| 1112 | 1151 | if (use_input_categories) |
| 1113 | 1152 | { |
| 1114 | 1153 | // using input categories |
| 1115 | for (i = 0; machine->input_ports[i].type != IPT_END; i++) | |
| 1154 | i = 0; | |
| 1155 | for (port = machine->portconfig; port != NULL; port = port->next) | |
| 1116 | 1156 | { |
| 1117 | in = &machine->input_ports[i]; | |
| 1118 | if ((in->type) == IPT_CATEGORY_NAME) | |
| 1157 | for (field = port->fieldlist; field != NULL; field = field->next) | |
| 1119 | 1158 | { |
| 1120 | submenu = CreateMenu(); | |
| 1121 | if (!submenu) | |
| 1122 | return; | |
| 1159 | if (field->type == IPT_CATEGORY) | |
| 1160 | { | |
| 1161 | submenu = CreateMenu(); | |
| 1162 | if (!submenu) | |
| 1163 | return; | |
| 1123 | 1164 | |
| 1124 | // append all of the category settings | |
| 1125 | for (j = i + 1; (machine->input_ports[j].type) == IPT_CATEGORY_SETTING; j++) | |
| 1126 | { | |
| 1127 | in_setting = &machine->input_ports[j]; | |
| 1128 | append_menu_utf8(submenu, MF_STRING, ID_INPUT_0 + j, in_setting->name); | |
| 1165 | // append all of the category settings | |
| 1166 | j = 0; | |
| 1167 | for (setting = field->settinglist; setting != NULL; setting = setting->next) | |
| 1168 | { | |
| 1169 | append_menu_utf8(submenu, MF_STRING, ID_INPUT_0 + j++, setting->name); | |
| 1170 | } | |
| 1171 | ||
| 1172 | // tack on the final items and the menu item | |
| 1173 | AppendMenu(submenu, MF_SEPARATOR, 0, NULL); | |
| 1174 | AppendMenu(submenu, MF_STRING, ID_INPUT_0 + i, TEXT("&Configure...")); | |
| 1175 | append_menu_utf8(joystick_menu, MF_STRING | MF_POPUP, (UINT_PTR) submenu, field->name); | |
| 1176 | child_count++; | |
| 1129 | 1177 | } |
| 1130 | ||
| 1131 | // tack on the final items and the menu item | |
| 1132 | AppendMenu(submenu, MF_SEPARATOR, 0, NULL); | |
| 1133 | AppendMenu(submenu, MF_STRING, ID_INPUT_0 + i, TEXT("&Configure...")); | |
| 1134 | append_menu_utf8(joystick_menu, MF_STRING | MF_POPUP, (UINT_PTR) submenu, in->name); | |
| 1135 | child_count++; | |
| 1178 | i++; | |
| 1136 | 1179 | } |
| 1137 | 1180 | } |
| 1138 | 1181 | } |
| r2724 | r2725 | |
| 1210 | 1253 | UINT flags_for_writing; |
| 1211 | 1254 | const device_config *img; |
| 1212 | 1255 | int has_config, has_dipswitch, has_keyboard, has_analog, has_misc; |
| 1213 | const input_port_entry *in; | |
| 1214 | UINT16 in_cat_value = 0; | |
| 1256 | const input_port_config *port; | |
| 1257 | const input_field_config *field; | |
| 1258 | const input_setting_config *setting; | |
| 1215 | 1259 | int frameskip; |
| 1216 | 1260 | int orientation; |
| 1217 | 1261 | int speed; |
| r2724 | r2725 | |
| 1242 | 1286 | has_misc = input_has_input_class(machine, INPUT_CLASS_MISC); |
| 1243 | 1287 | |
| 1244 | 1288 | has_analog = 0; |
| 1245 | for ( | |
| 1289 | for (port = machine-> | |
| 1246 | 1290 | { |
| 1247 | | |
| 1291 | | |
| 1248 | 1292 | { |
| 1249 | has_analog = 1; | |
| 1250 | break; | |
| 1293 | if (port_type_is_analog(field->type)) | |
| 1294 | { | |
| 1295 | has_analog = 1; | |
| 1296 | break; | |
| 1297 | } | |
| 1251 | 1298 | } |
| 1252 | 1299 | } |
| 1253 | 1300 | |
| r2724 | r2725 | |
| 1294 | 1341 | // if we are using categorized input, we need to properly checkmark the categories |
| 1295 | 1342 | if (use_input_categories) |
| 1296 | 1343 | { |
| 1297 | for ( | |
| 1344 | for (port = | |
| 1298 | 1345 | { |
| 1299 | in = &machine->input_ports[i]; | |
| 1300 | switch(in->type) { | |
| 1301 | case IPT_CATEGORY_NAME: | |
| 1302 | in_cat_value = in->default_value; | |
| 1303 | break; | |
| 1304 | ||
| 1305 | case IPT_CATEGORY_SETTING: | |
| 1306 | set_command_state(menu_bar, ID_INPUT_0 + i, (in->default_value == in_cat_value) ? MFS_CHECKED : MFS_ENABLED); | |
| 1307 | break; | |
| 1346 | for (field = port->fieldlist; field != NULL; field = field->next) | |
| 1347 | { | |
| 1348 | if (field->type == IPT_CATEGORY) | |
| 1349 | { | |
| 1350 | i = 0; | |
| 1351 | for (setting = field->settinglist; setting != NULL; setting = setting->next) | |
| 1352 | set_command_state(menu_bar, ID_INPUT_0 + i++, (setting->value == field->defvalue) ? MFS_CHECKED : MFS_ENABLED); | |
| 1353 | } | |
| 1308 | 1354 | } |
| 1309 | 1355 | } |
| 1310 | 1356 | } |
| r2724 | r2725 | |
| 1637 | 1683 | int dev_command, i; |
| 1638 | 1684 | const device_config *img; |
| 1639 | 1685 | int port_count; |
| 1640 | UINT16 setting, category; | |
| 1641 | input_port_entry *in; | |
| 1686 | UINT16 category; | |
| 1642 | 1687 | const char *section; |
| 1688 | const input_port_config *port; | |
| 1689 | const input_field_config *field; | |
| 1690 | const input_setting_config *setting; | |
| 1643 | 1691 | LONG_PTR ptr = GetWindowLongPtr(wnd, GWLP_USERDATA); |
| 1644 | 1692 | win_window_info *window = (win_window_info *)ptr; |
| 1645 | 1693 | |
| r2724 | r2725 | |
| 1805 | 1853 | // quickly come up with a port count, so we can upper bound commands |
| 1806 | 1854 | // near ID_INPUT_0 |
| 1807 | 1855 | port_count = 0; |
| 1808 | while(machine->input_ports[port_count].type != IPT_END) | |
| 1809 | port_count++; | |
| 1856 | field = NULL; | |
| 1857 | for (port = machine->portconfig; port != NULL; port = port->next) | |
| 1858 | { | |
| 1859 | for (field = port->fieldlist; field != NULL; field = field->next) | |
| 1860 | port_count++; | |
| 1861 | } | |
| 1810 | 1862 | |
| 1811 | 1863 | if ((command >= ID_FRAMESKIP_0) && (command < ID_FRAMESKIP_0 + frameskip_level_count())) |
| 1812 | 1864 | { |
| r2724 | r2725 | |
| 1832 | 1884 | else if ((command >= ID_INPUT_0) && (command < ID_INPUT_0 + port_count)) |
| 1833 | 1885 | { |
| 1834 | 1886 | // customize categorized input |
| 1835 | in = &machine->input_ports[command - ID_INPUT_0]; | |
| 1836 | switch(in->type) { | |
| 1837 | case IPT_CATEGORY_NAME: | |
| 1838 | // customize the input type | |
| 1839 | category = 0; | |
| 1840 | section = NULL; | |
| 1841 | for (i = 1; (in[i].type) == IPT_CATEGORY_SETTING; i++) | |
| 1842 | { | |
| 1843 | if (in[i].default_value == in[0].default_value) | |
| 1887 | i = command - ID_INPUT_0; | |
| 1888 | for (port = machine->portconfig; (i > 0) && (port != NULL); port = port->next) | |
| 1889 | { | |
| 1890 | for (field = port->fieldlist; (i > 0) && (field != NULL); field = field->next) | |
| 1891 | ; | |
| 1892 | } | |
| 1893 | ||
| 1894 | switch(field->type) | |
| 1895 | { | |
| 1896 | case IPT_CATEGORY: | |
| 1897 | // customize the input type | |
| 1898 | category = 0; | |
| 1899 | section = NULL; | |
| 1900 | for (setting = field->settinglist; setting != NULL; setting = setting->next) | |
| 1844 | 1901 | { |
| 1845 | category = in[i].category; | |
| 1846 | section = in[i].name; | |
| 1902 | if (field->defvalue == setting->value) | |
| 1903 | { | |
| 1904 | //category = in[i].category; | |
| 1905 | //section = in[i].name; | |
| 1906 | } | |
| 1847 | 1907 | } |
| 1848 | } | |
| 1849 | customize_categorizedinput(machine, wnd, section, category); | |
| 1850 | break; | |
| 1908 | customize_categorizedinput(machine, wnd, section, category); | |
| 1909 | break; | |
| 1851 | 1910 | |
| 1852 | case IPT_CATEGORY_SETTING: | |
| 1853 | // change the input type for this category | |
| 1854 | setting = in->default_value; | |
| 1855 | while((in->type) != IPT_CATEGORY_NAME) | |
| 1856 | in--; | |
| 1857 | in->default_value = setting; | |
| 1858 | break; | |
| 1911 | // case IPT_CATEGORY_SETTING: | |
| 1912 | // // change the input type for this category | |
| 1913 | // setting = in->default_value; | |
| 1914 | // while((in->type) != IPT_CATEGORY_NAME) | |
| 1915 | // in--; | |
| 1916 | // in->default_value = setting; | |
| 1917 | // break; | |
| 1859 | 1918 | |
| 1860 | default: | |
| 1861 | // should never happen | |
| 1862 | handled = 0; | |
| 1863 | break; | |
| 1919 | default: | |
| 1920 | // should never happen | |
| 1921 | handled = 0; | |
| 1922 | break; | |
| 1864 | 1923 | } |
| 1865 | 1924 | } |
| 1866 | 1925 | else |
| r2724 | r2725 | |
|---|---|---|
| 57 | 57 | int min_value, int max_value, |
| 58 | 58 | dialog_itemstoreval storeval, void *storeval_param); |
| 59 | 59 | |
| 60 | int win_dialog_add_portselect(dialog_box *dialog, input_ | |
| 60 | int win_dialog_add_portselect(dialog_box *dialog, input_fi | |
| 61 | 61 | |
| 62 | 62 | int win_dialog_add_standard_buttons(dialog_box *dialog); |
| 63 | 63 | int win_dialog_add_image(dialog_box *dialog, const png_info *png); |
| r2724 | r2725 | |
|---|---|---|
| 14 | 14 | |
| 15 | 15 | BOOL DriverUsesMouse(int driver_index) |
| 16 | 16 | { |
| 17 | // NPW 23-May-2008 - Temporarily disabling | |
| 18 | BOOL retval = FALSE; | |
| 19 | #if 0 | |
| 17 | 20 | const input_port_entry *input_ports; |
| 18 | BOOL retval = FALSE; | |
| 19 | 21 | |
| 20 | 22 | if (drivers[driver_index]->ipt) |
| 21 | 23 | { |
| r2724 | r2725 | |
| 34 | 36 | |
| 35 | 37 | end_resource_tracking(); |
| 36 | 38 | } |
| 37 | ||
| 39 | #endif | |
| 38 | 40 | return retval; |
| 39 | 41 | } |
| 40 | 42 |
| r2724 | r2725 | |
|---|---|---|
| 105 | 105 | static READ8_HANDLER(d_pia0_pb_r); |
| 106 | 106 | static WRITE8_HANDLER(d_pia0_pb_w); |
| 107 | 107 | static WRITE8_HANDLER(d_pia0_cb2_w); |
| 108 | static void d_pia0_irq_a(int state); | |
| 109 | static void d_pia0_irq_b(int state); | |
| 108 | static void d_pia0_irq_a(running_machine *machine, int state); | |
| 109 | static void d_pia0_irq_b(running_machine *machine, int state); | |
| 110 | 110 | static READ8_HANDLER(d_pia1_pa_r); |
| 111 | 111 | static WRITE8_HANDLER(d_pia1_pa_w); |
| 112 | 112 | static READ8_HANDLER(d_pia1_pb_r); |
| 113 | 113 | static WRITE8_HANDLER(d_pia1_pb_w); |
| 114 | static void d_pia1_irq_a(int state); | |
| 115 | static void d_pia1_irq_b(int state); | |
| 114 | static void d_pia1_irq_a(running_machine *machine, int state); | |
| 115 | static void d_pia1_irq_b(running_machine *machine, int state); | |
| 116 | 116 | static READ8_HANDLER(d_pia2_pa_r); |
| 117 | 117 | static WRITE8_HANDLER(d_pia2_pa_w); |
| 118 | 118 | static READ8_HANDLER(d_pia2_pb_r); |
| 119 | 119 | static WRITE8_HANDLER(d_pia2_pb_w); |
| 120 | static void d_pia2_irq_a(int state); | |
| 121 | static void d_pia2_irq_b(int state); | |
| 120 | static void d_pia2_irq_a(running_machine *machine, int state); | |
| 121 | static void d_pia2_irq_b(running_machine *machine, int state); | |
| 122 | 122 | |
| 123 | 123 | static void cpu0_recalc_irq(running_machine *machine, int state); |
| 124 | 124 | static void cpu0_recalc_firq(running_machine *machine, int state); |
| r2724 | r2725 | |
| 647 | 647 | } |
| 648 | 648 | |
| 649 | 649 | |
| 650 | static void d_pia0_irq_a(int state) | |
| 650 | static void d_pia0_irq_a(running_machine *machine, int state) | |
| 651 | 651 | { |
| 652 | cpu0_recalc_irq( | |
| 652 | cpu0_recalc_irq(machine, state); | |
| 653 | 653 | } |
| 654 | 654 | |
| 655 | static void d_pia0_irq_b(int state) | |
| 655 | static void d_pia0_irq_b(running_machine *machine, int state) | |
| 656 | 656 | { |
| 657 | cpu0_recalc_firq( | |
| 657 | cpu0_recalc_firq(machine, state); | |
| 658 | 658 | } |
| 659 | 659 | |
| 660 | 660 | /* PIA #1 at $FC24-$FC27 I63 |
| r2724 | r2725 | |
| 739 | 739 | } |
| 740 | 740 | } |
| 741 | 741 | |
| 742 | static void d_pia1_irq_a(int state) | |
| 742 | static void d_pia1_irq_a(running_machine *machine, int state) | |
| 743 | 743 | { |
| 744 | cpu0_recalc_irq( | |
| 744 | cpu0_recalc_irq(machine, state); | |
| 745 | 745 | } |
| 746 | 746 | |
| 747 | static void d_pia1_irq_b(int state) | |
| 747 | static void d_pia1_irq_b(running_machine *machine, int state) | |
| 748 | 748 | { |
| 749 | cpu0_recalc_irq( | |
| 749 | cpu0_recalc_irq(machine, state); | |
| 750 | 750 | } |
| 751 | 751 | |
| 752 | 752 | /* PIA #2 at FCC0-FCC3 I28 |
| r2724 | r2725 | |
| 842 | 842 | vid_set_gctrl(data); |
| 843 | 843 | } |
| 844 | 844 | |
| 845 | static void d_pia2_irq_a(int state) | |
| 845 | static void d_pia2_irq_a(running_machine *machine, int state) | |
| 846 | 846 | { |
| 847 | 847 | logerror("PIA2 IRQ1 state=%02X\n",state); |
| 848 | cpu0_recalc_irq( | |
| 848 | cpu0_recalc_irq(machine, state); | |
| 849 | 849 | } |
| 850 | 850 | |
| 851 | static void d_pia2_irq_b(int state) | |
| 851 | static void d_pia2_irq_b(running_machine *machine, int state) | |
| 852 | 852 | { |
| 853 | 853 | logerror("PIA2 IRQ2 state=%02X\n",state); |
| 854 | cpu0_recalc_irq( | |
| 854 | cpu0_recalc_irq(machine, state); | |
| 855 | 855 | } |
| 856 | 856 | |
| 857 | 857 | /************************************ Recalculate CPU inturrupts ****************************/ |
| r2724 | r2725 | |
|---|---|---|
| 173 | 173 | |
| 174 | 174 | /* priority on the bus |
| 175 | 175 | hdw, ram, ce2, ce1, nce3, rom */ |
| 176 | void hp48_mem_reset( | |
| 176 | void hp48_mem_reset(running_machine *machine) | |
| 177 | 177 | { |
| 178 | 178 | int i; |
| 179 | 179 | hp48s.state=0; |
| r2724 | r2725 | |
| 184 | 184 | hp48_config(); |
| 185 | 185 | } |
| 186 | 186 | |
| 187 | void hp48_mem_config(int v) | |
| 187 | void hp48_mem_config(running_machine *machine, int v) | |
| 188 | 188 | { |
| 189 | 189 | logerror("hp48_mem_config called\n"); |
| 190 | 190 | if (hp48s.mem[HDW].adr==-1) { |
| r2724 | r2725 | |
| 228 | 228 | } |
| 229 | 229 | } |
| 230 | 230 | |
| 231 | void hp48_mem_unconfig(int v) | |
| 231 | void hp48_mem_unconfig(running_machine *machine, int v) | |
| 232 | 232 | { |
| 233 | 233 | int i; |
| 234 | 234 | for (i=0; i+1< sizeof(hp48s.mem)/sizeof(hp48s.mem[0]); i++) { |
| r2724 | r2725 | |
| 250 | 250 | #define CE2_ID_ADR 0xf8 |
| 251 | 251 | #define NCE3_ID_SIZE 1 |
| 252 | 252 | #define NCE3_ID_ADR 0xf2 |
| 253 | int hp48_mem_id( | |
| 253 | int hp48_mem_id(running_machine *machine) | |
| 254 | 254 | { |
| 255 | 255 | if (hp48s.mem[HDW].adr==-1) { |
| 256 | 256 | return (hp48s.mem[HDW].adr&~0x3f)|HDW_ID_ADR; |
| r2724 | r2725 | |
| 272 | 272 | {0} |
| 273 | 273 | }; |
| 274 | 274 | |
| 275 | void hp48_crc(int adr, int data) | |
| 275 | void hp48_crc(running_machine *machine, int adr, int data) | |
| 276 | 276 | { |
| 277 | 277 | if ((hp48s.mem[HDW].adr==-1) |
| 278 | 278 | ||(adr<(hp48s.mem[HDW].adr&~0x3f)) |
| r2724 | r2725 | |
| 424 | 424 | } |
| 425 | 425 | } |
| 426 | 426 | |
| 427 | void hp48_out(int v) | |
| 427 | void hp48_out(running_machine *machine, int v) | |
| 428 | 428 | { |
| 429 | 429 | out=v; |
| 430 | 430 | } |
| 431 | 431 | |
| 432 | int hp48_in( | |
| 432 | int hp48_in(running_machine *machine) | |
| 433 | 433 | { |
| 434 | 434 | int data=0; |
| 435 | 435 | #if 1 |
| r2724 | r2725 | |
| 556 | 556 | |
| 557 | 557 | MACHINE_RESET( hp48 ) |
| 558 | 558 | { |
| 559 | hp48_mem_reset(); | |
| 559 | hp48_mem_reset(machine); | |
| 560 | 560 | } |
| r2724 | r2725 | |
|---|---|---|
| 485 | 485 | static WRITE8_HANDLER(apple3_via_1_out_a) { apple3_via_out(machine, &via_1_a, data); } |
| 486 | 486 | static WRITE8_HANDLER(apple3_via_1_out_b) { apple3_via_out(machine, &via_1_b, data); } |
| 487 | 487 | |
| 488 | static void apple2_via_1_irq_func(int state) | |
| 488 | static void apple2_via_1_irq_func(running_machine *machine, int state) | |
| 489 | 489 | { |
| 490 | 490 | if (!via_1_irq && state) |
| 491 | cpunum_set_input_line( | |
| 491 | cpunum_set_input_line(machine, 0, M6502_IRQ_LINE, PULSE_LINE); | |
| 492 | 492 | via_1_irq = state; |
| 493 | 493 | } |
| 494 | 494 |
| r2724 | r2725 | |
|---|---|---|
| 188 | 188 | cbm_ieee_data_w(0, data); |
| 189 | 189 | } |
| 190 | 190 | |
| 191 | static void cbmb_tpi6525_0_irq2_level( int level ) { | |
| 192 | tpi6525_0_irq2_level( Machine, level ); | |
| 191 | static void cbmb_tpi6525_0_irq2_level( running_machine *machine, int level ) | |
| 192 | { | |
| 193 | tpi6525_0_irq2_level( machine, level ); | |
| 193 | 194 | } |
| 194 | 195 | |
| 195 | 196 | static const cia6526_interface cbmb_cia = |
| r2724 | r2725 | |
|---|---|---|
| 30 | 30 | static UINT8 fdc_head = 0; |
| 31 | 31 | static UINT8 fdc_den = 0; |
| 32 | 32 | static UINT8 fdc_status = 0; |
| 33 | static void pio_interrupt(int state); | |
| 33 | static void pio_interrupt(running_machine *machine, int state); | |
| 34 | 34 | static void mbee_fdc_callback(running_machine *machine, wd17xx_state_t event, void *param); |
| 35 | 35 | |
| 36 | 36 | UINT8 *mbee_workram; |
| r2724 | r2725 | |
| 46 | 46 | 0 /* portB ready active callback (do not support yet)*/ |
| 47 | 47 | }; |
| 48 | 48 | |
| 49 | static void pio_interrupt(int state) | |
| 49 | static void pio_interrupt(running_machine *machine, int state) | |
| 50 | 50 | { |
| 51 | cpunum_set_input_line( | |
| 51 | cpunum_set_input_line(machine, 0, 0, state ? ASSERT_LINE : CLEAR_LINE); | |
| 52 | 52 | } |
| 53 | 53 | |
| 54 | 54 | /* |
| r2724 | r2725 | |
|---|---|---|
| 130 | 130 | static WRITE8_HANDLER ( d_pia0_cb2_w); |
| 131 | 131 | static WRITE8_HANDLER ( d_pia1_ca2_w); |
| 132 | 132 | static WRITE8_HANDLER ( d_pia0_ca2_w); |
| 133 | static void d_pia0_irq_a(int state); | |
| 134 | static void d_pia0_irq_b(int state); | |
| 135 | static void d_pia1_firq_a(int state); | |
| 136 | static void d_pia1_firq_b(int state); | |
| 133 | static void d_pia0_irq_a(running_machine *machine, int state); | |
| 134 | static void d_pia0_irq_b(running_machine *machine, int state); | |
| 135 | static void d_pia1_firq_a(running_machine *machine, int state); | |
| 136 | static void d_pia1_firq_b(running_machine *machine, int state); | |
| 137 | 137 | static void d_sam_set_pageonemode(int val); |
| 138 | 138 | static void d_sam_set_mpurate(int val); |
| 139 | 139 | static void d_sam_set_memorysize(int val); |
| r2724 | r2725 | |
| 154 | 154 | static UINT8 coco3_interupt_line; |
| 155 | 155 | static UINT8 gime_firq, gime_irq; |
| 156 | 156 | |
| 157 | static void coco3_pia0_irq_a(int state); | |
| 158 | static void coco3_pia0_irq_b(int state); | |
| 159 | static void coco3_pia1_firq_a(int state); | |
| 160 | static void coco3_pia1_firq_b(int state); | |
| 157 | static void coco3_pia0_irq_a(running_machine *machine, int state); | |
| 158 | static void coco3_pia0_irq_b(running_machine *machine, int state); | |
| 159 | static void coco3_pia1_firq_a(running_machine *machine, int state); | |
| 160 | static void coco3_pia1_firq_b(running_machine *machine, int state); | |
| 161 | 161 | static void coco3_sam_set_maptype(int val); |
| 162 | 162 | static const UINT8 *coco3_sam_get_rambase(void); |
| 163 | 163 | |
| r2724 | r2725 | |
| 172 | 172 | |
| 173 | 173 | /* Dragon Alpha specific */ |
| 174 | 174 | static WRITE8_HANDLER ( dgnalpha_pia2_pa_w ); |
| 175 | static void d_pia2_firq_a(int state); | |
| 176 | static void d_pia2_firq_b(int state); | |
| 175 | static void d_pia2_firq_a(running_machine *machine, int state); | |
| 176 | static void d_pia2_firq_b(running_machine *machine, int state); | |
| 177 | 177 | static int dgnalpha_just_reset; /* Reset flag used to ignore first NMI after reset */ |
| 178 | 178 | |
| 179 | 179 | /* Dragon Plus specific */ |
| r2724 | r2725 | |
| 813 | 813 | d_recalc_firq(machine); |
| 814 | 814 | } |
| 815 | 815 | |
| 816 | static void d_pia0_irq_a(int state) | |
| 816 | static void d_pia0_irq_a(running_machine *machine, int state) | |
| 817 | 817 | { |
| 818 | d_recalc_irq( | |
| 818 | d_recalc_irq(machine); | |
| 819 | 819 | } |
| 820 | 820 | |
| 821 | static void d_pia0_irq_b(int state) | |
| 821 | static void d_pia0_irq_b(running_machine *machine, int state) | |
| 822 | 822 | { |
| 823 | d_recalc_irq( | |
| 823 | d_recalc_irq(machine); | |
| 824 | 824 | } |
| 825 | 825 | |
| 826 | static void d_pia1_firq_a(int state) | |
| 826 | static void d_pia1_firq_a(running_machine *machine, int state) | |
| 827 | 827 | { |
| 828 | d_recalc_firq( | |
| 828 | d_recalc_firq(machine); | |
| 829 | 829 | } |
| 830 | 830 | |
| 831 | static void d_pia1_firq_b(int state) | |
| 831 | static void d_pia1_firq_b(running_machine *machine, int state) | |
| 832 | 832 | { |
| 833 | d_recalc_firq( | |
| 833 | d_recalc_firq(machine); | |
| 834 | 834 | } |
| 835 | 835 | |
| 836 | 836 | /* Dragon Alpha second PIA IRQ lines also cause FIRQ */ |
| 837 | static void d_pia2_firq_a(int state) | |
| 837 | static void d_pia2_firq_a(running_machine *machine, int state) | |
| 838 | 838 | { |
| 839 | d_recalc_firq( | |
| 839 | d_recalc_firq(machine); | |
| 840 | 840 | } |
| 841 | 841 | |
| 842 | static void d_pia2_firq_b(int state) | |
| 842 | static void d_pia2_firq_b(running_machine *machine, int state) | |
| 843 | 843 | { |
| 844 | d_recalc_firq( | |
| 844 | d_recalc_firq(machine); | |
| 845 | 845 | } |
| 846 | 846 | |
| 847 | static void coco3_pia0_irq_a(int state) | |
| 847 | static void coco3_pia0_irq_a(running_machine *machine, int state) | |
| 848 | 848 | { |
| 849 | coco3_recalc_irq( | |
| 849 | coco3_recalc_irq(machine); | |
| 850 | 850 | } |
| 851 | 851 | |
| 852 | static void coco3_pia0_irq_b(int state) | |
| 852 | static void coco3_pia0_irq_b(running_machine *machine, int state) | |
| 853 | 853 | { |
| 854 | coco3_recalc_irq( | |
| 854 | coco3_recalc_irq(machine); | |
| 855 | 855 | } |
| 856 | 856 | |
| 857 | static void coco3_pia1_firq_a(int state) | |
| 857 | static void coco3_pia1_firq_a(running_machine *machine, int state) | |
| 858 | 858 | { |
| 859 | coco3_recalc_firq( | |
| 859 | coco3_recalc_firq(machine); | |
| 860 | 860 | } |
| 861 | 861 | |
| 862 | static void coco3_pia1_firq_b(int state) | |
| 862 | static void coco3_pia1_firq_b(running_machine *machine, int state) | |
| 863 | 863 | { |
| 864 | coco3_recalc_firq( | |
| 864 | coco3_recalc_firq(machine); | |
| 865 | 865 | } |
| 866 | 866 | |
| 867 | 867 | static void coco3_raise_interrupt(running_machine *machine, UINT8 mask, int state) |
| r2724 | r2725 | |
| 1412 | 1412 | |
| 1413 | 1413 | /* three functions that update the keyboard in varying ways */ |
| 1414 | 1414 | static WRITE8_HANDLER ( d_pia0_pb_w ) { (*update_keyboard)(machine); } |
| 1415 | INPUT_CHANGED(coco_keyboard_changed) { (*update_keyboard)(machine); } | |
| 1415 | INPUT_CHANGED(coco_keyboard_changed) { (*update_keyboard)(field->port->machine); } | |
| 1416 | 1416 | static TIMER_CALLBACK(coco_update_keyboard_timerproc) { (*update_keyboard)(machine); } |
| 1417 | 1417 | |
| 1418 | 1418 | static WRITE8_HANDLER ( d_pia0_pa_w ) |
| r2724 | r2725 | |
| 3081 | 3081 | |
| 3082 | 3082 | INPUT_CHANGED( coco_joystick_mode_changed ) |
| 3083 | 3083 | { |
| 3084 | update_lightgun(machine); | |
| 3084 | update_lightgun(field->port->machine); | |
| 3085 | 3085 | } |
| 3086 | 3086 | |
| 3087 | 3087 | static TIMER_CALLBACK( update_lightgun_timer_callback ) |
| r2724 | r2725 | |
|---|---|---|
| 37 | 37 | ******************************************************************************/ |
| 38 | 38 | |
| 39 | 39 | |
| 40 | static void aim65_via_irq_func(int state) | |
| 40 | static void aim65_via_irq_func(running_machine *machine, int state) | |
| 41 | 41 | { |
| 42 | cpunum_set_input_line( | |
| 42 | cpunum_set_input_line(machine, 0, M6502_IRQ_LINE, state ? HOLD_LINE : CLEAR_LINE); | |
| 43 | 43 | } |
| 44 | 44 | |
| 45 | 45 | /* STEP/RUN |
| r2724 | r2725 | |
| 155 | 155 | } |
| 156 | 156 | |
| 157 | 157 | |
| 158 | static void aim65_riot_irq(int state) | |
| 158 | static void aim65_riot_irq(running_machine *machine, int state) | |
| 159 | 159 | { |
| 160 | cpunum_set_input_line( | |
| 160 | cpunum_set_input_line(machine, 0, M6502_IRQ_LINE, state ? HOLD_LINE : CLEAR_LINE); | |
| 161 | 161 | } |
| 162 | 162 | |
| 163 | 163 |
| r2724 | r2725 | |
|---|---|---|
| 399 | 399 | * also ca1 (books says cb2) |
| 400 | 400 | * irq to m6502 irq connected (or with second via irq) |
| 401 | 401 | */ |
| 402 | static void vc1541_via0_irq (int level) | |
| 402 | static void vc1541_via0_irq (running_machine *machine, int level) | |
| 403 | 403 | { |
| 404 | 404 | vc1541->via0irq = level; |
| 405 | 405 | DBG_LOG(2, "vc1541 via0 irq",("level %d %d\n",vc1541->via0irq,vc1541->via1irq)); |
| 406 | cpunum_set_input_line ( | |
| 406 | cpunum_set_input_line (machine, vc1541->cpunumber, | |
| 407 | 407 | M6502_IRQ_LINE, vc1541->via1irq || vc1541->via0irq); |
| 408 | 408 | } |
| 409 | 409 | |
| 410 | static | |
| 410 | static | |
| 411 | 411 | { |
| 412 | 412 | static int old=-1; |
| 413 | 413 | int value = 0x7a; |
| r2724 | r2725 | |
| 498 | 498 | * |
| 499 | 499 | * irq to m6502 irq connected |
| 500 | 500 | */ |
| 501 | static void vc1541_via1_irq (int level) | |
| 501 | static void vc1541_via1_irq (running_machine *machine, int level) | |
| 502 | 502 | { |
| 503 | 503 | vc1541->via1irq = level; |
| 504 | 504 | DBG_LOG(2, "vc1541 via1 irq",("level %d %d\n",vc1541->via0irq,vc1541->via1irq)); |
| 505 | cpunum_set_input_line ( | |
| 505 | cpunum_set_input_line (machine, vc1541->cpunumber, | |
| 506 | 506 | M6502_IRQ_LINE, vc1541->via1irq || vc1541->via0irq); |
| 507 | 507 | } |
| 508 | 508 | |
| 509 | static | |
| 509 | static | |
| 510 | 510 | { |
| 511 | 511 | int data=vc1541->head.data[vc1541->d64.pos]; |
| 512 | 512 | DBG_LOG(2, "vc1541 drive",("port a read %.2x\n", data)); |
| r2724 | r2725 | |
|---|---|---|
| 114 | 114 | |
| 115 | 115 | |
| 116 | 116 | |
| 117 | static void thom_irq_0 ( int state ) | |
| 117 | static void thom_irq_0 ( running_machine *machine, int state ) | |
| 118 | 118 | { |
| 119 | thom_set_irq ( | |
| 119 | thom_set_irq ( machine, 0, state ); | |
| 120 | 120 | } |
| 121 | 121 | |
| 122 | static void thom_irq_1 ( int state ) | |
| 122 | static void thom_irq_1 ( running_machine *machine, int state ) | |
| 123 | 123 | { |
| 124 | thom_set_irq ( | |
| 124 | thom_set_irq ( machine, 1, state ); | |
| 125 | 125 | } |
| 126 | 126 | |
| 127 | static void thom_irq_3 ( int state ) | |
| 127 | static void thom_irq_3 ( running_machine *machine, int state ) | |
| 128 | 128 | { |
| 129 | thom_set_irq ( | |
| 129 | thom_set_irq ( machine, 3, state ); | |
| 130 | 130 | } |
| 131 | 131 | |
| 132 | static void thom_firq_1 ( int state ) | |
| 132 | static void thom_firq_1 ( running_machine *machine, int state ) | |
| 133 | 133 | { |
| 134 | thom_set_firq ( | |
| 134 | thom_set_firq ( machine, 1, state ); | |
| 135 | 135 | } |
| 136 | 136 | |
| 137 | static void thom_firq_2 ( int state ) | |
| 137 | static void thom_firq_2 ( running_machine *machine, int state ) | |
| 138 | 138 | { |
| 139 | thom_set_firq ( | |
| 139 | thom_set_firq ( machine, 2, state ); | |
| 140 | 140 | } |
| 141 | 141 | |
| 142 | 142 | #ifdef CHARDEV |
| 143 | static void thom_irq_4 ( int state ) | |
| 143 | static void thom_irq_4 ( running_machine *machine, int state ) | |
| 144 | 144 | { |
| 145 | thom_set_irq ( | |
| 145 | thom_set_irq ( machine, 4, state ); | |
| 146 | 146 | } |
| 147 | 147 | #endif |
| 148 | 148 | |
| r2724 | r2725 | |
| 2354 | 2354 | if ( (to9_kbd_intr & 3) == 1 && (to9_kbd_status & ACIA_6850_TDRE) ) |
| 2355 | 2355 | to9_kbd_status |= ACIA_6850_irq; /* ready to transmit interrupt */ |
| 2356 | 2356 | |
| 2357 | thom_irq_3( to9_kbd_status & ACIA_6850_irq ); | |
| 2357 | thom_irq_3( Machine, to9_kbd_status & ACIA_6850_irq ); | |
| 2358 | 2358 | } |
| 2359 | 2359 | |
| 2360 | 2360 | |
| r2724 | r2725 | |
| 3505 | 3505 | case 1: /* ram register / lightpen register 2 */ |
| 3506 | 3506 | if ( to7_lightpen ) |
| 3507 | 3507 | { |
| 3508 | thom_firq_2( 0 ); | |
| 3508 | thom_firq_2( machine, 0 ); | |
| 3509 | 3509 | to8_lightpen_intr = 0; |
| 3510 | 3510 | res = count & 0xff; |
| 3511 | 3511 | } |
| r2724 | r2725 | |
| 3763 | 3763 | if ( ! to7_lightpen ) |
| 3764 | 3764 | return; |
| 3765 | 3765 | |
| 3766 | thom_firq_2( 1 ); | |
| 3766 | thom_firq_2( Machine, 1 ); | |
| 3767 | 3767 | to7_lightpen_step = step; |
| 3768 | 3768 | to8_lightpen_intr = 1; |
| 3769 | 3769 | } |
| r2724 | r2725 | |
| 4388 | 4388 | case 1: /* ram register / lightpen register 2 */ |
| 4389 | 4389 | if ( to7_lightpen ) |
| 4390 | 4390 | { |
| 4391 | thom_firq_2( 0 ); | |
| 4391 | thom_firq_2( machine, 0 ); | |
| 4392 | 4392 | to8_lightpen_intr = 0; |
| 4393 | 4393 | res = count & 0xff; |
| 4394 | 4394 | } |
| r2724 | r2725 | |
|---|---|---|
| 19 | 19 | **********************************************************************/ |
| 20 | 20 | |
| 21 | 21 | #include "driver.h" |
| 22 | #include "deprecat.h" | |
| 22 | 23 | #include "mc6846.h" |
| 23 | 24 | |
| 24 | 25 | #define VERBOSE 0 |
| r2724 | r2725 | |
| 94 | 95 | |
| 95 | 96 | |
| 96 | 97 | |
| 97 | INLINE void mc6846_update_irq( | |
| 98 | INLINE void mc6846_update_irq( running_machine *machine ) | |
| 98 | 99 | { |
| 99 | 100 | static int old_cif; |
| 100 | 101 | int cif = 0; |
| r2724 | r2725 | |
| 114 | 115 | { |
| 115 | 116 | mc6846.csr |= 0x80; |
| 116 | 117 | if ( mc6846.iface->irq_func ) |
| 117 | mc6846.iface->irq_func( 1 ); | |
| 118 | mc6846.iface->irq_func( machine, 1 ); | |
| 118 | 119 | } |
| 119 | 120 | else |
| 120 | 121 | { |
| 121 | 122 | mc6846.csr &= ~0x80; |
| 122 | 123 | if ( mc6846.iface->irq_func ) |
| 123 | mc6846.iface->irq_func( 0 ); | |
| 124 | mc6846.iface->irq_func( machine, 0 ); | |
| 124 | 125 | } |
| 125 | 126 | } |
| 126 | 127 | |
| r2724 | r2725 | |
| 179 | 180 | |
| 180 | 181 | mc6846.csr &= ~1; |
| 181 | 182 | mc6846_update_cto(machine); |
| 182 | mc6846_update_irq(); | |
| 183 | mc6846_update_irq(machine); | |
| 183 | 184 | } |
| 184 | 185 | |
| 185 | 186 | |
| r2724 | r2725 | |
| 224 | 225 | |
| 225 | 226 | mc6846.csr |= 1; |
| 226 | 227 | mc6846_update_cto(machine); |
| 227 | mc6846_update_irq(); | |
| 228 | mc6846_update_irq(machine); | |
| 228 | 229 | } |
| 229 | 230 | |
| 230 | 231 | |
| r2724 | r2725 | |
| 275 | 276 | mc6846.csr &= ~2; |
| 276 | 277 | if ( mc6846.csr2_to_be_cleared ) |
| 277 | 278 | mc6846.csr &= ~4; |
| 278 | mc6846_update_irq(); | |
| 279 | mc6846_update_irq(machine); | |
| 279 | 280 | mc6846.csr1_to_be_cleared = 0; |
| 280 | 281 | mc6846.csr2_to_be_cleared = 0; |
| 281 | 282 | } |
| r2724 | r2725 | |
| 290 | 291 | if ( mc6846.csr0_to_be_cleared ) |
| 291 | 292 | { |
| 292 | 293 | mc6846.csr &= ~1; |
| 293 | mc6846_update_irq(); | |
| 294 | mc6846_update_irq(machine); | |
| 294 | 295 | } |
| 295 | 296 | mc6846.csr0_to_be_cleared = 0; |
| 296 | 297 | return mc6846_counter() >> 8; |
| r2724 | r2725 | |
| 300 | 301 | if ( mc6846.csr0_to_be_cleared ) |
| 301 | 302 | { |
| 302 | 303 | mc6846.csr &= ~1; |
| 303 | mc6846_update_irq(); | |
| 304 | mc6846_update_irq(machine); | |
| 304 | 305 | } |
| 305 | 306 | mc6846.csr0_to_be_cleared = 0; |
| 306 | 307 | return mc6846_counter() & 0xff; |
| r2724 | r2725 | |
| 345 | 346 | mc6846.pdr = 0; |
| 346 | 347 | mc6846.ddr = 0; |
| 347 | 348 | mc6846.csr &= ~6; |
| 348 | mc6846_update_irq(); | |
| 349 | mc6846_update_irq(machine); | |
| 349 | 350 | } |
| 350 | 351 | if ( data & 4 ) |
| 351 | 352 | logerror( "$%04x mc6846 CP1 latching not implemented\n", activecpu_get_previouspc() ); |
| r2724 | r2725 | |
| 391 | 392 | } |
| 392 | 393 | mc6846.csr1_to_be_cleared = 0; |
| 393 | 394 | mc6846.csr2_to_be_cleared = 0; |
| 394 | mc6846_update_irq(); | |
| 395 | mc6846_update_irq(machine); | |
| 395 | 396 | } |
| 396 | 397 | break; |
| 397 | 398 | |
| r2724 | r2725 | |
| 427 | 428 | if ( ! mc6846.timer_started ) |
| 428 | 429 | mc6846_timer_launch(machine); |
| 429 | 430 | } |
| 430 | mc6846_update_irq(); | |
| 431 | mc6846_update_irq(machine); | |
| 431 | 432 | } |
| 432 | 433 | break; |
| 433 | 434 | |
| r2724 | r2725 | |
| 443 | 444 | /* timer initialization */ |
| 444 | 445 | mc6846.preset = mc6846.latch; |
| 445 | 446 | mc6846.csr &= ~1; |
| 446 | mc6846_update_irq(); | |
| 447 | mc6846_update_irq(machine); | |
| 447 | 448 | mc6846.cto = 0; |
| 448 | 449 | mc6846_update_cto(machine); |
| 449 | 450 | /* launch only if started */ |
| r2724 | r2725 | |
| 473 | 474 | if (( data && (mc6846.pcr & 2)) || (!data && !(mc6846.pcr & 2))) |
| 474 | 475 | { |
| 475 | 476 | mc6846.csr |= 2; |
| 476 | mc6846_update_irq(); | |
| 477 | mc6846_update_irq(Machine); | |
| 477 | 478 | } |
| 478 | 479 | } |
| 479 | 480 | |
| r2724 | r2725 | |
| 489 | 490 | if (( data && (mc6846.pcr & 0x10)) || (!data && !(mc6846.pcr & 0x10))) |
| 490 | 491 | { |
| 491 | 492 | mc6846.csr |= 4; |
| 492 | mc6846_update_irq(); | |
| 493 | mc6846_update_irq(Machine); | |
| 493 | 494 | } |
| 494 | 495 | } |
| 495 | 496 | } |
| r2724 | r2725 | |
|---|---|---|
| 27 | 27 | write8_machine_func out_cto_func; /* 1-bit output */ |
| 28 | 28 | |
| 29 | 29 | /* timer interrupt */ |
| 30 | void ( * irq_func ) ( int state ); | |
| 30 | void ( * irq_func ) ( running_machine *machine, int state ); | |
| 31 | 31 | |
| 32 | 32 | /* CPU identifier (defines the clock rate) */ |
| 33 | 33 | int cpunum; |
| r2724 | r2725 | |
|---|---|---|
| 278 | 278 | Helper Functions |
| 279 | 279 | ***************************************************************************/ |
| 280 | 280 | |
| 281 | INLINE int a2_has_keypad( | |
| 281 | INLINE int a2_has_keypad(running_machine *machine) | |
| 282 | 282 | { |
| 283 | return port_tag | |
| 283 | return input_port_by_tag(machin | |
| 284 | 284 | } |
| 285 | 285 | |
| 286 | INLINE int a2_has_reset_dip( | |
| 286 | INLINE int a2_has_reset_dip(running_machine *machine) | |
| 287 | 287 | { |
| 288 | return port_tag | |
| 288 | return input_port_by_tag(machin | |
| 289 | 289 | } |
| 290 | 290 | |
| 291 | INLINE int a2_has_repeat( | |
| 291 | INLINE int a2_has_repeat(running_machine *machine) | |
| 292 | 292 | { |
| 293 | return port_tag | |
| 293 | return input_port_by_tag(machin | |
| 294 | 294 | } |
| 295 | 295 | |
| 296 | INLINE int a2_has_capslock( | |
| 296 | INLINE int a2_has_capslock(running_machine *machine) | |
| 297 | 297 | { |
| 298 | return !a2_has_repeat(); /* BUG: Doesn't work with Ace */ | |
| 298 | return !a2_has_repeat(machine); /* BUG: Doesn't work with Ace */ | |
| 299 | 299 | } |
| 300 | 300 | |
| 301 | 301 | INLINE int a2_no_ctrl_reset(running_machine *machine) |
| 302 | 302 | { |
| 303 | return ((a2_has_repeat() && !a2_has_reset_dip()) || | |
| 304 | (a2_has_reset_dip() && !input_port_read(machine, "reset_dip"))); | |
| 303 | return ((a2_has_repeat(machine) && !a2_has_reset_dip(machine)) || | |
| 304 | (a2_has_reset_dip(machine) && !input_port_read(machine, "reset_dip"))); | |
| 305 | 305 | } |
| 306 | 306 | |
| 307 | 307 | |
| r2724 | r2725 | |
| 361 | 361 | /* check for these special cases because they affect the emulated key codes */ |
| 362 | 362 | |
| 363 | 363 | /* only repeat keys on a 2/2+ if special REPT key is pressed */ |
| 364 | if (a2_has_repeat()) | |
| 364 | if (a2_has_repeat(machine)) | |
| 365 | 365 | time_until_repeat = input_port_read(machine, "keyb_repeat") & 0x01 ? 0 : ~0; |
| 366 | 366 | |
| 367 | 367 | /* check caps lock and set LED here */ |
| r2724 | r2725 | |
| 440 | 440 | } |
| 441 | 441 | |
| 442 | 442 | /* run through real keys and see what's being pressed */ |
| 443 | num_ports = a2_has_keypad() ? 9 : 7; | |
| 443 | num_ports = a2_has_keypad(machine) ? 9 : 7; | |
| 444 | 444 | |
| 445 | 445 | keymodreg &= ~A2_KEYMOD_KEYPAD; |
| 446 | 446 | |
| r2724 | r2725 | |
| 449 | 449 | data = input_port_read_indexed(machine, AY3600_KEYS_BASEPORT + port); |
| 450 | 450 | for (bit = 0; bit < 8; bit++) |
| 451 | 451 | { |
| 452 | if (a2_has_capslock()) { | |
| 452 | if (a2_has_capslock(machine)) { | |
| 453 | 453 | curkey = ay3600_key_remap_2e[caps_lock][port*8+bit][switchkey]; |
| 454 | 454 | curkey_unmodified = ay3600_key_remap_2e[caps_lock][port*8+bit][0]; |
| 455 | 455 | } else { |
| r2724 | r2725 | |
|---|---|---|
| 107 | 107 | cbm_ieee_eoi_w(0, data); |
| 108 | 108 | } |
| 109 | 109 | |
| 110 | static void pet_irq (int level) | |
| 110 | static void pet_irq (running_machine *machine, int level) | |
| 111 | 111 | { |
| 112 | 112 | static int old_level = 0; |
| 113 | 113 | |
| r2724 | r2725 | |
| 115 | 115 | { |
| 116 | 116 | DBG_LOG (3, "mos6502", ("irq %s\n", level ? "start" : "end")); |
| 117 | 117 | if (superpet) |
| 118 | cpunum_set_input_line(Machine, 1, M6809_IRQ_LINE, level); | |
| 119 | cpunum_set_input_line(Machine, 0, M6502_IRQ_LINE, level); | |
| 118 | cpunum_set_input_line(machine, 1, M6809_IRQ_LINE, level); | |
| 119 | cpunum_set_input_line(machine, 0, M6502_IRQ_LINE, level); | |
| 120 | 120 | old_level = level; |
| 121 | 121 | } |
| 122 | 122 | } |
| r2724 | r2725 | |
|---|---|---|
| 406 | 406 | } |
| 407 | 407 | |
| 408 | 408 | |
| 409 | static void oric_via_irq_func(int state) | |
| 409 | static void oric_via_irq_func(running_machine *machine, int state) | |
| 410 | 410 | { |
| 411 | 411 | oric_irqs &= ~(1<<0); |
| 412 | 412 | |
| r2724 | r2725 | |
| 420 | 420 | oric_irqs |=(1<<0); |
| 421 | 421 | } |
| 422 | 422 | |
| 423 | oric_refresh_ints( | |
| 423 | oric_refresh_ints(machine); | |
| 424 | 424 | } |
| 425 | 425 | |
| 426 | 426 | |
| r2724 | r2725 | |
| 1437 | 1437 | } |
| 1438 | 1438 | |
| 1439 | 1439 | |
| 1440 | static void telestrat_via2_irq_func(int state) | |
| 1440 | static void telestrat_via2_irq_func(running_machine *machine, int state) | |
| 1441 | 1441 | { |
| 1442 | 1442 | oric_irqs &=~(1<<2); |
| 1443 | 1443 | |
| r2724 | r2725 | |
| 1448 | 1448 | oric_irqs |=(1<<2); |
| 1449 | 1449 | } |
| 1450 | 1450 | |
| 1451 | oric_refresh_ints( | |
| 1451 | oric_refresh_ints(machine); | |
| 1452 | 1452 | } |
| 1453 | 1453 | static const struct via6522_interface telestrat_via2_interface= |
| 1454 | 1454 | { |
| r2724 | r2725 | |
|---|---|---|
| 91 | 91 | /* if the buffer was empty and we have new data, start a timer to send the keystrokes */ |
| 92 | 92 | if ( key_buf_was_empty && ( key_buf_pos != key_cur_pos ) ) |
| 93 | 93 | { |
| 94 | timer_adjust_oneshot(kbd_timer, attotime_div(video_screen_get_frame_period(machine->primary_screen),4), 0); | |
| 94 | timer_adjust_oneshot(kbd_timer, attotime_div(video_screen_get_frame_period(field->port->machine->primary_screen),4), 0); | |
| 95 | 95 | } |
| 96 | 96 | } |
| 97 | 97 | } |
| r2724 | r2725 | |
|---|---|---|
| 215 | 215 | LOG(("microtan_via_0_out_cb2 %d\n", data)); |
| 216 | 216 | } |
| 217 | 217 | |
| 218 | static void via_0_irq(int state) | |
| 218 | static void via_0_irq(running_machine *machine, int state) | |
| 219 | 219 | { |
| 220 | 220 | LOG(("microtan_via_0_irq %d\n", state)); |
| 221 | 221 | via_0_irq_line = state; |
| 222 | microtan_set_irq_line( | |
| 222 | microtan_set_irq_line(machine); | |
| 223 | 223 | } |
| 224 | 224 | |
| 225 | 225 | /************************************************************** |
| r2724 | r2725 | |
| 287 | 287 | LOG(("microtan_via_1_out_cb2 %d\n", data)); |
| 288 | 288 | } |
| 289 | 289 | |
| 290 | static void via_1_irq(int state) | |
| 290 | static void via_1_irq(running_machine *machine, int state) | |
| 291 | 291 | { |
| 292 | 292 | LOG(("microtan_via_1_irq %d\n", state)); |
| 293 | 293 | via_1_irq_line = state; |
| 294 | microtan_set_irq_line( | |
| 294 | microtan_set_irq_line(machine); | |
| 295 | 295 | } |
| 296 | 296 | |
| 297 | 297 | /************************************************************** |
| r2724 | r2725 | |
|---|---|---|
| 101 | 101 | */ |
| 102 | 102 | |
| 103 | 103 | #include "driver.h" |
| 104 | #include "deprecat.h" | |
| 104 | 105 | #include "99_peb.h" |
| 105 | 106 | |
| 106 | 107 | /* TRUE if we are using the snug sgcpu 99/4p 16-bit extensions */ |
| r2724 | r2725 | |
| 162 | 163 | static int tmp_buffer; |
| 163 | 164 | |
| 164 | 165 | /* inta/intb handlers */ |
| 165 | static void (*inta_callback)(int state); | |
| 166 | static void (*intb_callback)(int state); | |
| 166 | static void (*inta_callback)(running_machine *machine, int state); | |
| 167 | static void (*intb_callback)(running_machine *machine, int state); | |
| 167 | 168 | |
| 168 | 169 | |
| 169 | 170 | /* |
| r2724 | r2725 | |
| 187 | 188 | in_intb_callback: callback called when the state of INTB changes (may be |
| 188 | 189 | NULL) |
| 189 | 190 | */ |
| 190 | void ti99_peb_reset(int in_has_16bit_peb, void (*in_inta_callback)(int state), void (*in_intb_callback)(int state)) | |
| 191 | void ti99_peb_reset(int in_has_16bit_peb, void (*in_inta_callback)(running_machine *machine, int state), void (*in_intb_callback)(running_machine *machine, int state)) | |
| 191 | 192 | { |
| 192 | 193 | has_16bit_peb = in_has_16bit_peb; |
| 193 | 194 | inta_callback = in_inta_callback; |
| r2724 | r2725 | |
| 286 | 287 | { |
| 287 | 288 | ila |= 1 << bit; |
| 288 | 289 | if (inta_callback) |
| 289 | (*inta_callback)(1); | |
| 290 | (*inta_callback)(Machine, 1); | |
| 290 | 291 | } |
| 291 | 292 | else |
| 292 | 293 | { |
| 293 | 294 | ila &= ~(1 << bit); |
| 294 | 295 | if ((! ila) && inta_callback) |
| 295 | (*inta_callback)(0); | |
| 296 | (*inta_callback)(Machine, 0); | |
| 296 | 297 | } |
| 297 | 298 | } |
| 298 | 299 | |
| r2724 | r2725 | |
| 311 | 312 | { |
| 312 | 313 | ilb |= 1 << bit; |
| 313 | 314 | if (intb_callback) |
| 314 | (*intb_callback)(1); | |
| 315 | (*intb_callback)(Machine, 1); | |
| 315 | 316 | } |
| 316 | 317 | else |
| 317 | 318 | { |
| 318 | 319 | ilb &= ~(1 << bit); |
| 319 | 320 | if ((! ilb) && intb_callback) |
| 320 | (*intb_callback)(0); | |
| 321 | (*intb_callback)(Machine, 0); | |
| 321 | 322 | } |
| 322 | 323 | } |
| 323 | 324 |
| r2724 | r2725 | |
|---|---|---|
| 236 | 236 | } |
| 237 | 237 | } |
| 238 | 238 | |
| 239 | static void ieee_pia_irq_a_func(int state) { | |
| 239 | static void ieee_pia_irq_a_func(running_machine *machine, int state) { | |
| 240 | 240 | osborne1.pia_0_irq_state = state; |
| 241 | osborne1_update_irq_state( | |
| 241 | osborne1_update_irq_state(machine); | |
| 242 | 242 | } |
| 243 | 243 | |
| 244 | 244 | static const pia6821_interface osborne1_ieee_pia_config = { |
| r2724 | r2725 | |
| 277 | 277 | //logerror("Video pia port b write: %02X\n", data ); |
| 278 | 278 | } |
| 279 | 279 | |
| 280 | static void video_pia_irq_a_func(int state) { | |
| 280 | static void video_pia_irq_a_func(running_machine *machine, int state) { | |
| 281 | 281 | osborne1.pia_1_irq_state = state; |
| 282 | osborne1_update_irq_state( | |
| 282 | osborne1_update_irq_state(machine); | |
| 283 | 283 | } |
| 284 | 284 | |
| 285 | 285 | static const pia6821_interface osborne1_video_pia_config = { |
| r2724 | r2725 | |
|---|---|---|
| 54 | 54 | }; |
| 55 | 55 | |
| 56 | 56 | void ti99_peb_init(void); |
| 57 | void ti99_peb_reset(int in_has_16bit_peb, void (*in_inta_callback)(int state), void (*in_intb_callback)(int state)); | |
| 57 | void ti99_peb_reset(int in_has_16bit_peb, void (*in_inta_callback)(running_machine *machine, int state), void (*in_intb_callback)(running_machine *machine, int state)); | |
| 58 | 58 | |
| 59 | 59 | void ti99_peb_set_card_handlers(int cru_base, const ti99_peb_card_handlers_t *handler); |
| 60 | 60 | void ti99_peb_set_16bit_card_handlers(int cru_base, const ti99_peb_16bit_card_handlers_t *handler); |
| r2724 | r2725 | |
|---|---|---|
| 586 | 586 | |
| 587 | 587 | INPUT_CHANGED( comx35_reset ) |
| 588 | 588 | { |
| 589 | if (BIT(input_port_read(machine, "RESET"), 0) && BIT(input_port_read(machine, "D6"), 7)) | |
| 589 | if (BIT(input_port_read(field->port->machine, "RESET"), 0) && BIT(input_port_read(field->port->machine, "D6"), 7)) | |
| 590 | 590 | { |
| 591 | running_machine *machine = field->port->machine; | |
| 591 | 592 | MACHINE_RESET_CALL(comx35); |
| 592 | 593 | } |
| 593 | 594 | } |
| r2724 | r2725 | |
|---|---|---|
| 563 | 563 | |
| 564 | 564 | /* Init functions */ |
| 565 | 565 | |
| 566 | void svi318_vdp_interrupt(int i) | |
| 566 | void svi318_vdp_interrupt(running_machine *machine, int i) | |
| 567 | 567 | { |
| 568 | cpunum_set_input_line( | |
| 568 | cpunum_set_input_line(machine, 0, 0, (i ? HOLD_LINE : CLEAR_LINE)); | |
| 569 | 569 | } |
| 570 | 570 | |
| 571 | 571 | DRIVER_INIT( svi318 ) |
| r2724 | r2725 | |
| 669 | 669 | |
| 670 | 670 | set = input_port_read(machine, "CONFIG"); |
| 671 | 671 | TMS9928A_set_spriteslimit (set & 0x20); |
| 672 | TMS9928A_interrupt(); | |
| 672 | TMS9928A_interrupt(machine); | |
| 673 | 673 | } |
| 674 | 674 | |
| 675 | 675 | /* Memory */ |
| r2724 | r2725 | |
|---|---|---|
| 336 | 336 | } |
| 337 | 337 | } |
| 338 | 338 | |
| 339 | void apple2gs_doc_irq(int state) | |
| 339 | void apple2gs_doc_irq(running_machine *machine, int state) | |
| 340 | 340 | { |
| 341 | 341 | if (state) |
| 342 | 342 | { |
| 343 | apple2gs_add_irq( | |
| 343 | apple2gs_add_irq(machine, IRQ_DOC); | |
| 344 | 344 | } |
| 345 | 345 | else |
| 346 | 346 | { |
| 347 | apple2gs_remove_irq( | |
| 347 | apple2gs_remove_irq(machine, IRQ_DOC); | |
| 348 | 348 | } |
| 349 | 349 | } |
| 350 | 350 |
| r2724 | r2725 | |
|---|---|---|
| 75 | 75 | static WRITE8_HANDLER(mac_via_out_a); |
| 76 | 76 | static WRITE8_HANDLER(mac_via_out_b); |
| 77 | 77 | static WRITE8_HANDLER(mac_via_out_cb2); |
| 78 | static void mac_via_irq(int state); | |
| 78 | static void mac_via_irq(running_machine *machine, int state); | |
| 79 | 79 | static offs_t mac_dasm_override(char *buffer, offs_t pc, const UINT8 *oprom, const UINT8 *opram); |
| 80 | 80 | |
| 81 | 81 | static const struct via6522_interface mac_via6522_intf = |
| r2724 | r2725 | |
| 1253 | 1253 | mac_adb_newaction((data & 0x30) >> 4); |
| 1254 | 1254 | } |
| 1255 | 1255 | |
| 1256 | static void mac_via_irq(int state) | |
| 1256 | static void mac_via_irq(running_machine *machine, int state) | |
| 1257 | 1257 | { |
| 1258 | 1258 | /* interrupt the 68k (level 1) */ |
| 1259 | 1259 | //cpunum_set_input_line(machine, 0, 1, state); |
| 1260 | set_via_interrupt( | |
| 1260 | set_via_interrupt(machine, state); | |
| 1261 | 1261 | } |
| 1262 | 1262 | |
| 1263 | 1263 | READ16_HANDLER ( mac_via_r ) |
| r2724 | r2725 | |
|---|---|---|
| 47 | 47 | static READ8_HANDLER(via_in_b); |
| 48 | 48 | static WRITE8_HANDLER(via_out_b); |
| 49 | 49 | static WRITE8_HANDLER(via_out_cb2); |
| 50 | static void via_irq_func(int state); | |
| 50 | static void via_irq_func(running_machine *machine, int state); | |
| 51 | 51 | |
| 52 | 52 | |
| 53 | 53 | static const struct via6522_interface concept_via6522_intf = |
| r2724 | r2725 | |
| 274 | 274 | /* |
| 275 | 275 | VIA irq -> 68k level 5 |
| 276 | 276 | */ |
| 277 | static void via_irq_func(int state) | |
| 277 | static void via_irq_func(running_machine *machine, int state) | |
| 278 | 278 | { |
| 279 | concept_set_interrupt( | |
| 279 | concept_set_interrupt(machine, TIMINT_level, state); | |
| 280 | 280 | } |
| 281 | 281 | |
| 282 | 282 | READ16_HANDLER(concept_io_r) |
| r2724 | r2725 | |
|---|---|---|
| 277 | 277 | } |
| 278 | 278 | } |
| 279 | 279 | |
| 280 | void msx_vdp_interrupt(int i) | |
| 280 | void msx_vdp_interrupt(running_machine *machine, int i) | |
| 281 | 281 | { |
| 282 | cpunum_set_input_line ( | |
| 282 | cpunum_set_input_line (machine, 0, 0, (i ? HOLD_LINE : CLEAR_LINE)); | |
| 283 | 283 | } |
| 284 | 284 | |
| 285 | 285 | static void msx_ch_reset_core (void) |
| r2724 | r2725 | |
| 421 | 421 | } |
| 422 | 422 | |
| 423 | 423 | TMS9928A_set_spriteslimit (input_port_read(machine, "DSW") & 0x20); |
| 424 | TMS9928A_interrupt(); | |
| 424 | TMS9928A_interrupt(machine); | |
| 425 | 425 | } |
| 426 | 426 | |
| 427 | 427 | /* |
| r2724 | r2725 | |
|---|---|---|
| 211 | 211 | |
| 212 | 212 | *********************************************************************/ |
| 213 | 213 | |
| 214 | void v_via_irq (int level) | |
| 214 | void v_via_irq (running_machine *machine, int level) | |
| 215 | 215 | { |
| 216 | cpunum_set_input_line( | |
| 216 | cpunum_set_input_line(machine, 0, M6809_IRQ_LINE, level); | |
| 217 | 217 | } |
| 218 | 218 | |
| 219 | 219 | READ8_HANDLER( v_via_pb_r ) |
| r2724 | r2725 | |
|---|---|---|
| 19 | 19 | UINT8 data = 0; |
| 20 | 20 | int delta; |
| 21 | 21 | attotime new_time = timer_get_time(); |
| 22 | int joystick_port = port_tag | |
| 22 | const input_port_config *joystick_port = input_port_by_tag(machin | |
| 23 | 23 | |
| 24 | if (joystick_port | |
| 24 | if (joystick_port != NULL) | |
| 25 | 25 | { |
| 26 | data = input_port_read_ | |
| 26 | data = input_port_read_ | |
| 27 | 27 | |
| 28 | 28 | /* timer overflow? */ |
| 29 | 29 | if (attotime_compare(attotime_sub(new_time, JOY_time), ATTOTIME_IN_MSEC(10)) > 0) |
| r2724 | r2725 | |
| 33 | 33 | else |
| 34 | 34 | { |
| 35 | 35 | delta = attotime_mul(attotime_sub(new_time, JOY_time), 256 * 1000).seconds; |
| 36 | if (input_port_read_indexed(machine, joystick_port + 1) < delta) data &= ~0x01; | |
| 37 | if (input_port_read_indexed(machine, joystick_port + 2) < delta) data &= ~0x02; | |
| 38 | if (input_port_read_indexed(machine, joystick_port + 3) < delta) data &= ~0x04; | |
| 39 | if (input_port_read_indexed(machine, joystick_port + 4) < delta) data &= ~0x08; | |
| 36 | if (input_port_read(machine, "pc_joy_1") < delta) data &= ~0x01; | |
| 37 | if (input_port_read(machine, "pc_joy_2") < delta) data &= ~0x02; | |
| 38 | if (input_port_read(machine, "pc_joy_3") < delta) data &= ~0x04; | |
| 39 | if (input_port_read(machine, "pc_joy_4") < delta) data &= ~0x08; | |
| 40 | 40 | } |
| 41 | 41 | } |
| 42 | 42 | return data; |
| r2724 | r2725 | |
| 79 | 79 | PORT_BIT( 0x0040, 0x0000, IPT_BUTTON1) PORT_NAME("Joystick 2 Button 1") PORT_CODE(JOYCODE_BUTTON1) PORT_PLAYER(2) |
| 80 | 80 | PORT_BIT( 0x0080, 0x0000, IPT_BUTTON2) PORT_NAME("Joystick 2 Button 2") PORT_CODE(JOYCODE_BUTTON2) PORT_PLAYER(2) |
| 81 | 81 | |
| 82 | PORT_START | |
| 82 | PORT_START_TAG("pc_joy_1") | |
| 83 | 83 | PORT_BIT(0xff,0x80,IPT_AD_STICK_X) PORT_SENSITIVITY(100) PORT_KEYDELTA(1) PORT_MINMAX(1,0xff) PORT_CODE_DEC(KEYCODE_LEFT) PORT_CODE_INC(KEYCODE_RIGHT) PORT_CODE_DEC(JOYCODE_X_LEFT_SWITCH) PORT_CODE_INC(JOYCODE_X_RIGHT_SWITCH) PORT_REVERSE |
| 84 | 84 | |
| 85 | PORT_START | |
| 85 | PORT_START_TAG("pc_joy_2") | |
| 86 | 86 | PORT_BIT(0xff,0x80,IPT_AD_STICK_Y) PORT_SENSITIVITY(100) PORT_KEYDELTA(1) PORT_MINMAX(1,0xff) PORT_CODE_DEC(KEYCODE_UP) PORT_CODE_INC(KEYCODE_DOWN) PORT_CODE_DEC(JOYCODE_Y_UP_SWITCH) PORT_CODE_INC(JOYCODE_Y_DOWN_SWITCH) PORT_REVERSE |
| 87 | 87 | |
| 88 | PORT_START | |
| 88 | PORT_START_TAG("pc_joy_3") | |
| 89 | 89 | PORT_BIT(0xff,0x80,IPT_AD_STICK_X) PORT_SENSITIVITY(100) PORT_KEYDELTA(1) PORT_MINMAX(1,0xff) PORT_CODE_DEC(JOYCODE_X_LEFT_SWITCH) PORT_CODE_INC(JOYCODE_X_RIGHT_SWITCH) PORT_PLAYER(2) PORT_REVERSE |
| 90 | 90 | |
| 91 | PORT_START | |
| 91 | PORT_START_TAG("pc_joy_4") | |
| 92 | 92 | PORT_BIT(0xff,0x80,IPT_AD_STICK_Y) PORT_SENSITIVITY(100) PORT_KEYDELTA(1) PORT_MINMAX(1,0xff) PORT_CODE_DEC(JOYCODE_Y_UP_SWITCH) PORT_CODE_INC(JOYCODE_Y_DOWN_SWITCH) PORT_PLAYER(2) PORT_REVERSE |
| 93 | 93 | INPUT_PORTS_END |
| 94 | 94 |
| r2724 | r2725 | |
|---|---|---|
| 131 | 131 | static WRITE8_HANDLER(COPS_via_out_b); |
| 132 | 132 | static WRITE8_HANDLER(COPS_via_out_ca2); |
| 133 | 133 | static WRITE8_HANDLER(COPS_via_out_cb2); |
| 134 | static void COPS_via_irq_func(int val); | |
| 134 | static void COPS_via_irq_func(running_machine *machine, int val); | |
| 135 | 135 | static READ8_HANDLER(parallel_via_in_b); |
| 136 | 136 | |
| 137 | 137 | static int KBIR; /* COPS VIA interrupt pending */ |
| r2724 | r2725 | |
| 842 | 842 | speaker_level_w(0, data); |
| 843 | 843 | } |
| 844 | 844 | |
| 845 | static void COPS_via_irq_func(int val) | |
| 845 | static void COPS_via_irq_func(running_machine *machine, int val) | |
| 846 | 846 | { |
| 847 | 847 | if (KBIR != val) |
| 848 | 848 | { |
| 849 | 849 | KBIR = val; |
| 850 | lisa_field_interrupts( | |
| 850 | lisa_field_interrupts(machine); | |
| 851 | 851 | } |
| 852 | 852 | } |
| 853 | 853 |
| r2724 | r2725 | |
|---|---|---|
| 171 | 171 | ******************************************************************************/ |
| 172 | 172 | |
| 173 | 173 | |
| 174 | static void sym1_irq(int level) | |
| 174 | static void sym1_irq(running_machine *machine, int level) | |
| 175 | 175 | { |
| 176 | cpunum_set_input_line( | |
| 176 | cpunum_set_input_line(machine, 0, M6502_IRQ_LINE, level); | |
| 177 | 177 | } |
| 178 | 178 | |
| 179 | 179 |
| r2724 | r2725 | |
|---|---|---|
| 24 | 24 | |
| 25 | 25 | |
| 26 | 26 | /* prototypes */ |
| 27 | static void inta_callback(int state); | |
| 28 | static void intb_callback(int state); | |
| 27 | static void inta_callback(running_machine *machine, int state); | |
| 28 | static void intb_callback(running_machine *machine, int state); | |
| 29 | 29 | |
| 30 | 30 | static void read_key_if_possible(void); |
| 31 | 31 | static void poll_keyboard(void); |
| r2724 | r2725 | |
| 254 | 254 | KeyReset = 1; |
| 255 | 255 | |
| 256 | 256 | /* read config */ |
| 257 | has_speech = (input_port_read_indexed(machine, input_port_config) >> config_speech_bit) & config_speech_mask; | |
| 258 | fdc_kind = (input_port_read_indexed(machine, input_port_config) >> config_fdc_bit) & config_fdc_mask; | |
| 259 | has_ide = (input_port_read_indexed(machine, input_port_config) >> config_ide_bit) & config_ide_mask; | |
| 260 | has_rs232 = (input_port_read_indexed(machine, input_port_config) >> config_rs232_bit) & config_rs232_mask; | |
| 261 | has_usb_sm = (input_port_read_indexed(machine, input_port_config) >> config_usbsm_bit) & config_usbsm_mask; | |
| 257 | has_speech = (input_port_read_indexed(machine, INPUT_PORT_CONFIG) >> config_speech_bit) & config_speech_mask; | |
| 258 | fdc_kind = (input_port_read_indexed(machine, INPUT_PORT_CONFIG) >> config_fdc_bit) & config_fdc_mask; | |
| 259 | has_ide = (input_port_read_indexed(machine, INPUT_PORT_CONFIG) >> config_ide_bit) & config_ide_mask; | |
| 260 | has_rs232 = (input_port_read_indexed(machine, INPUT_PORT_CONFIG) >> config_rs232_bit) & config_rs232_mask; | |
| 261 | has_usb_sm = (input_port_read_indexed(machine, INPUT_PORT_CONFIG) >> config_usbsm_bit) & config_usbsm_mask; | |
| 262 | 262 | |
| 263 | 263 | /* set up optional expansion hardware */ |
| 264 | 264 | ti99_peb_reset(0, inta_callback, intb_callback); |
| r2724 | r2725 | |
| 342 | 342 | /* |
| 343 | 343 | inta is connected to both tms9901 IRQ1 line and to tms9995 INT4/EC line. |
| 344 | 344 | */ |
| 345 | static void inta_callback(int state) | |
| 345 | static void inta_callback(running_machine *machine, int state) | |
| 346 | 346 | { |
| 347 | 347 | tms9901_set_single_int(0, 1, state); |
| 348 | cpunum_set_input_line( | |
| 348 | cpunum_set_input_line(machine, 0, 1, state ? ASSERT_LINE : CLEAR_LINE); | |
| 349 | 349 | } |
| 350 | 350 | |
| 351 | 351 | /* |
| 352 | 352 | intb is connected to tms9901 IRQ12 line. |
| 353 | 353 | */ |
| 354 | static void intb_callback(int state) | |
| 354 | static void intb_callback(running_machine *machine, int state) | |
| 355 | 355 | { |
| 356 | 356 | tms9901_set_single_int(0, 12, state); |
| 357 | 357 | } |
| r2724 | r2725 | |
|---|---|---|
| 842 | 842 | FM_IRQ_save=0; |
| 843 | 843 | } |
| 844 | 844 | |
| 845 | void pc88sr_sound_interupt(int irq) | |
| 845 | void pc88sr_sound_interupt(running_machine *machine, int irq) | |
| 846 | 846 | { |
| 847 | FM_IRQ_save=irq; | |
| 848 | if(FM_IRQ_save && enable_FM_IRQ) pc8801_raise_interrupt(Machine, FM_IRQ_LEVEL); | |
| 847 | FM_IRQ_save=irq; | |
| 848 | if(FM_IRQ_save && enable_FM_IRQ) pc8801_raise_interrupt(machine, FM_IRQ_LEVEL); | |
| 849 | 849 | } |
| 850 | 850 | |
| 851 | 851 | /* |
| r2724 | r2725 | |
|---|---|---|
| 40 | 40 | /* I am not sure if this is correct, the atom appears to have a 2.4Khz timer used for reading tapes?? */ |
| 41 | 41 | static int timer_state = 0; |
| 42 | 42 | |
| 43 | static void atom_via_irq_func(int state) | |
| 43 | static void atom_via_irq_func(running_machine *machine, int state) | |
| 44 | 44 | { |
| 45 | 45 | if (state) |
| 46 | 46 | { |
| 47 | cpunum_set_input_line( | |
| 47 | cpunum_set_input_line(machine, 0, 0, HOLD_LINE); | |
| 48 | 48 | } |
| 49 | 49 | else |
| 50 | 50 | { |
| 51 | cpunum_set_input_line( | |
| 51 | cpunum_set_input_line(machine, 0, 0, CLEAR_LINE); | |
| 52 | 52 | } |
| 53 | 53 | } |
| 54 | 54 |
| r2724 | r2725 | |
|---|---|---|
| 57 | 57 | pa2 till pa6, port b, cb1, cb2 userport |
| 58 | 58 | irq connected to m6502 nmi |
| 59 | 59 | */ |
| 60 | static void vc20_via0_irq (int level) | |
| 60 | static void vc20_via0_irq (running_machine *machine, int level) | |
| 61 | 61 | { |
| 62 | cpunum_set_input_line( | |
| 62 | cpunum_set_input_line(machine, 0, INPUT_LINE_NMI, level); | |
| 63 | 63 | } |
| 64 | 64 | |
| 65 | static | |
| 65 | static | |
| 66 | 66 | { |
| 67 | 67 | return ! ( input_port_read(machine, TAG_KEYBOARD_EXTRA ) & 0x02 ); |
| 68 | 68 | } |
| 69 | 69 | |
| 70 | static | |
| 70 | static | |
| 71 | 71 | { |
| 72 | 72 | DBG_LOG (1, "tape", ("motor read %d\n", via0_ca2)); |
| 73 | 73 | return via0_ca2; |
| r2724 | r2725 | |
| 121 | 121 | * cb2 inverted serial data out |
| 122 | 122 | * irq connected to m6502 irq |
| 123 | 123 | */ |
| 124 | static void vc20_via1_irq (int level) | |
| 124 | static void vc20_via1_irq (running_machine *machine, int level) | |
| 125 | 125 | { |
| 126 | cpunum_set_input_line( | |
| 126 | cpunum_set_input_line(machine, 0, M6502_IRQ_LINE, level); | |
| 127 | 127 | } |
| 128 | 128 | |
| 129 | static | |
| 129 | static | |
| 130 | 130 | { |
| 131 | 131 | int value = 0xff; |
| 132 | 132 |
| r2724 | r2725 | |
|---|---|---|
| 908 | 908 | { |
| 909 | 909 | int reg = offset*8; |
| 910 | 910 | if (!(mem_mask & U64(0xff00000000000000))) { |
| 911 | lsi53c810_reg_w(reg+0, data >> 56); | |
| 911 | lsi53c810_reg_w(machine, reg+0, data >> 56); | |
| 912 | 912 | } |
| 913 | 913 | if (!(mem_mask & U64(0x00ff000000000000))) { |
| 914 | lsi53c810_reg_w(reg+1, data >> 48); | |
| 914 | lsi53c810_reg_w(machine, reg+1, data >> 48); | |
| 915 | 915 | } |
| 916 | 916 | if (!(mem_mask & U64(0x0000ff0000000000))) { |
| 917 | lsi53c810_reg_w(reg+2, data >> 40); | |
| 917 | lsi53c810_reg_w(machine, reg+2, data >> 40); | |
| 918 | 918 | } |
| 919 | 919 | if (!(mem_mask & U64(0x000000ff00000000))) { |
| 920 | lsi53c810_reg_w(reg+3, data >> 32); | |
| 920 | lsi53c810_reg_w(machine, reg+3, data >> 32); | |
| 921 | 921 | } |
| 922 | 922 | if (!(mem_mask & U64(0x00000000ff000000))) { |
| 923 | lsi53c810_reg_w(reg+4, data >> 24); | |
| 923 | lsi53c810_reg_w(machine, reg+4, data >> 24); | |
| 924 | 924 | } |
| 925 | 925 | if (!(mem_mask & U64(0x0000000000ff0000))) { |
| 926 | lsi53c810_reg_w(reg+5, data >> 16); | |
| 926 | lsi53c810_reg_w(machine, reg+5, data >> 16); | |
| 927 | 927 | } |
| 928 | 928 | if (!(mem_mask & U64(0x000000000000ff00))) { |
| 929 | lsi53c810_reg_w(reg+6, data >> 8); | |
| 929 | lsi53c810_reg_w(machine, reg+6, data >> 8); | |
| 930 | 930 | } |
| 931 | 931 | if (!(mem_mask & U64(0x00000000000000ff))) { |
| 932 | lsi53c810_reg_w(reg+7, data >> 0); | |
| 932 | lsi53c810_reg_w(machine, reg+7, data >> 0); | |
| 933 | 933 | } |
| 934 | 934 | } |
| 935 | 935 | |
| r2724 | r2725 | |
| 947 | 947 | } |
| 948 | 948 | |
| 949 | 949 | |
| 950 | static void scsi53c810_irq_callback( | |
| 950 | static void scsi53c810_irq_callback(running_machine *machine) | |
| 951 | 951 | { |
| 952 | bebox_set_irq_bit(Machine, 21, 1); | |
| 953 | bebox_set_irq_bit(Machine, 21, 0); | |
| 952 | bebox_set_irq_bit(machine, 21, 1); | |
| 953 | bebox_set_irq_bit(machine, 21, 0); | |
| 954 | 954 | } |
| 955 | 955 | |
| 956 | 956 |
| r2724 | r2725 | |
|---|---|---|
| 49 | 49 | * |
| 50 | 50 | *************************************/ |
| 51 | 51 | |
| 52 | static void mtx_tms9929a_interrupt(int data) | |
| 52 | static void mtx_tms9929a_interrupt(running_machine *machine, int data) | |
| 53 | 53 | { |
| 54 | running_machine *machine = Machine; | |
| 55 | 54 | z80ctc_0_trg0_w(machine, 0, data ? 0 : 1); |
| 56 | 55 | } |
| 57 | 56 | |
| r2724 | r2725 | |
| 65 | 64 | |
| 66 | 65 | INTERRUPT_GEN( mtx_interrupt ) |
| 67 | 66 | { |
| 68 | TMS9928A_interrupt(); | |
| 67 | TMS9928A_interrupt(machine); | |
| 69 | 68 | } |
| 70 | 69 | |
| 71 | 70 | |
| r2724 | r2725 | |
| 210 | 209 | * |
| 211 | 210 | *************************************/ |
| 212 | 211 | |
| 213 | static void mtx_ctc_interrupt(int state) | |
| 212 | static void mtx_ctc_interrupt(running_machine *machine, int state) | |
| 214 | 213 | { |
| 215 | 214 | // logerror("mtx_ctc_interrupt: %02x\n", state); |
| 216 | cpunum_set_input_line( | |
| 215 | cpunum_set_input_line(machine, 0, 0, state); | |
| 217 | 216 | } |
| 218 | 217 | |
| 219 | 218 | READ8_HANDLER( mtx_ctc_r ) |
| r2724 | r2725 | |
|---|---|---|
| 322 | 322 | cia_issue_index(0); |
| 323 | 323 | } |
| 324 | 324 | |
| 325 | static void c64_cia0_interrupt (int level) | |
| 325 | static void c64_cia0_interrupt (running_machine *machine, int level) | |
| 326 | 326 | { |
| 327 | c64_irq ( | |
| 327 | c64_irq (machine, level || vicirq); | |
| 328 | 328 | } |
| 329 | 329 | |
| 330 | 330 | void c64_vic_interrupt (int level) |
| r2724 | r2725 | |
| 386 | 386 | } |
| 387 | 387 | } |
| 388 | 388 | |
| 389 | static void c64_cia1_interrupt (int level) | |
| 389 | static void c64_cia1_interrupt (running_machine *machine, int level) | |
| 390 | 390 | { |
| 391 | c64_nmi( | |
| 391 | c64_nmi(machine); | |
| 392 | 392 | } |
| 393 | 393 | |
| 394 | 394 | const cia6526_interface c64_cia0 = |
| r2724 | r2725 | |
|---|---|---|
| 75 | 75 | } pce_cd; |
| 76 | 76 | |
| 77 | 77 | /* MSM5205 ADPCM decoder definition */ |
| 78 | static void pce_cd_msm5205_int( int data ); | |
| 78 | static void pce_cd_msm5205_int( running_machine *machine, int data ); | |
| 79 | 79 | const struct MSM5205interface pce_cd_msm5205_interface = { |
| 80 | 80 | pce_cd_msm5205_int, /* interrupt function */ |
| 81 | 81 | MSM5205_S48_4B /* 1/48 prescaler, 4bit data */ |
| r2724 | r2725 | |
| 296 | 296 | the MSM5205. Currently we can only use static clocks for the |
| 297 | 297 | MSM5205. |
| 298 | 298 | */ |
| 299 | static void pce_cd_msm5205_int( int chip ) { | |
| 299 | static void pce_cd_msm5205_int( running_machine *machine, int chip ) { | |
| 300 | 300 | pce_cd.adpcm_clock_count = ( pce_cd.adpcm_clock_count + 1 ) % pce_cd.adpcm_clock_divider; |
| 301 | 301 | if ( ! pce_cd.adpcm_clock_count ) { |
| 302 | 302 | /* Supply new ADPCM data */ |
| r2724 | r2725 | |
|---|---|---|
| 76 | 76 | static READ16_HANDLER ( ti99_rspeech_r ); |
| 77 | 77 | static WRITE16_HANDLER ( ti99_wspeech_w ); |
| 78 | 78 | |
| 79 | static void tms9901_set_int1(int state); | |
| 79 | static void tms9901_set_int1(running_machine *machine, int state); | |
| 80 | 80 | static void tms9901_interrupt_callback(int intreq, int ic); |
| 81 | 81 | static int ti99_R9901_0(int offset); |
| 82 | 82 | static int ti99_R9901_1(int offset); |
| r2724 | r2725 | |
| 792 | 792 | else if (ti99_model == model_99_4p) |
| 793 | 793 | xRAM_kind = xRAM_kind_99_4p_1Mb; /* hack */ |
| 794 | 794 | else |
| 795 | xRAM_kind = (input_port_read_indexed(machine, | |
| 795 | xRAM_kind = (input_port_read_indexed(machine, INPUT_PORT_CONFIG) >> config_xRAM_bit) & config_xRAM_mask; | |
| 796 | 796 | if (ti99_model == model_99_8) |
| 797 | 797 | has_speech = TRUE; |
| 798 | 798 | else |
| 799 | has_speech = (input_port_read_indexed(machine, input_port_config) >> config_speech_bit) & config_speech_mask; | |
| 800 | fdc_kind = (input_port_read_indexed(machine, input_port_config) >> config_fdc_bit) & config_fdc_mask; | |
| 801 | has_ide = (input_port_read_indexed(machine, input_port_config) >> config_ide_bit) & config_ide_mask; | |
| 802 | has_rs232 = (input_port_read_indexed(machine, input_port_config) >> config_rs232_bit) & config_rs232_mask; | |
| 803 | has_handset = (ti99_model == model_99_4) && ((input_port_read_indexed(machine, input_port_config) >> config_handsets_bit) & config_handsets_mask); | |
| 804 | has_hsgpl = (ti99_model == model_99_4p) || ((input_port_read_indexed(machine, input_port_config) >> config_hsgpl_bit) & config_hsgpl_mask); | |
| 805 | has_usb_sm = (input_port_read_indexed(machine, input_port_config) >> config_usbsm_bit) & config_usbsm_mask; | |
| 799 | has_speech = (input_port_read_indexed(machine, INPUT_PORT_CONFIG) >> config_speech_bit) & config_speech_mask; | |
| 800 | fdc_kind = (input_port_read_indexed(machine, INPUT_PORT_CONFIG) >> config_fdc_bit) & config_fdc_mask; | |
| 801 | has_ide = (input_port_read_indexed(machine, INPUT_PORT_CONFIG) >> config_ide_bit) & config_ide_mask; | |
| 802 | has_rs232 = (input_port_read_indexed(machine, INPUT_PORT_CONFIG) >> config_rs232_bit) & config_rs232_mask; | |
| 803 | has_handset = (ti99_model == model_99_4) && ((input_port_read_indexed(machine, INPUT_PORT_CONFIG) >> config_handsets_bit) & config_handsets_mask); | |
| 804 | has_hsgpl = (ti99_model == model_99_4p) || ((input_port_read_indexed(machine, INPUT_PORT_CONFIG) >> config_hsgpl_bit) & config_hsgpl_mask); | |
| 805 | has_usb_sm = (input_port_read_indexed(machine, INPUT_PORT_CONFIG) >> config_usbsm_bit) & config_usbsm_mask; | |
| 806 | 806 | |
| 807 | 807 | /* set up optional expansion hardware */ |
| 808 | 808 | ti99_peb_reset(ti99_model == model_99_4p, tms9901_set_int1, NULL); |
| r2724 | r2725 | |
| 944 | 944 | */ |
| 945 | 945 | INTERRUPT_GEN( ti99_vblank_interrupt ) |
| 946 | 946 | { |
| 947 | TMS9928A_interrupt(); | |
| 947 | TMS9928A_interrupt(machine); | |
| 948 | 948 | if (has_handset) |
| 949 | 949 | ti99_handset_task(); |
| 950 | has_mecmouse = (input_port_read_indexed(machine, | |
| 950 | has_mecmouse = (input_port_read_indexed(machine, INPUT_PORT_CONFIG) >> config_mecmouse_bit) & config_mecmouse_mask; | |
| 951 | 951 | if (has_mecmouse) |
| 952 | 952 | mecmouse_poll(); |
| 953 | 953 | } |
| r2724 | r2725 | |
| 959 | 959 | if (++line_count == 262) |
| 960 | 960 | { |
| 961 | 961 | line_count = 0; |
| 962 | has_mecmouse = (input_port_read_indexed(machine, | |
| 962 | has_mecmouse = (input_port_read_indexed(machine, INPUT_PORT_CONFIG) >> config_mecmouse_bit) & config_mecmouse_mask; | |
| 963 | 963 | if (has_mecmouse) |
| 964 | 964 | mecmouse_poll(); |
| 965 | 965 | } |
| r2724 | r2725 | |
| 2181 | 2181 | /* |
| 2182 | 2182 | set the state of int1 (called by the peb core) |
| 2183 | 2183 | */ |
| 2184 | static void tms9901_set_int1(int state) | |
| 2184 | static void tms9901_set_int1(running_machine *machine, int state) | |
| 2185 | 2185 | { |
| 2186 | 2186 | tms9901_set_single_int(0, 1, state); |
| 2187 | 2187 | } |
| r2724 | r2725 | |
| 2189 | 2189 | /* |
| 2190 | 2190 | set the state of int2 (called by the tms9928 core) |
| 2191 | 2191 | */ |
| 2192 | void tms9901_set_int2(int state) | |
| 2192 | void tms9901_set_int2(running_machine *machine, int state) | |
| 2193 | 2193 | { |
| 2194 | 2194 | tms9901_set_single_int(0, 2, state); |
| 2195 | 2195 | } |
| r2724 | r2725 | |
|---|---|---|
| 108 | 108 | /* defines for input ports */ |
| 109 | 109 | enum |
| 110 | 110 | { |
| 111 | | |
| 111 | INPUT_PORT_CONFIG = 0, | |
| 112 | 112 | input_port_mousex, /* optional mouse */ |
| 113 | 113 | input_port_mousey, /* optional mouse */ |
| 114 | 114 | input_port_mouse_buttons, /* optional mouse */ |
| r2724 | r2725 | |
| 194 | 194 | READ16_HANDLER ( ti99_4p_rgpl_r ); |
| 195 | 195 | WRITE16_HANDLER ( ti99_4p_wgpl_w ); |
| 196 | 196 | |
| 197 | extern void tms9901_set_int2(int state); | |
| 197 | extern void tms9901_set_int2(running_machine *machine, int state); | |
| 198 | 198 | |
| 199 | ||
| 199 | ||
| 200 | 200 | WRITE8_HANDLER ( ti99_8_w ); |
| r2724 | r2725 | |
|---|---|---|
| 1163 | 1163 | |
| 1164 | 1164 | |
| 1165 | 1165 | |
| 1166 | static void bbc_via_system_irq(int level) | |
| 1166 | static void bbc_via_system_irq(running_machine *machine, int level) | |
| 1167 | 1167 | { |
| 1168 | 1168 | // logerror("SYSTEM via irq %d %d %d\n",via_system_irq,via_user_irq,level); |
| 1169 | 1169 | via_system_irq=level; |
| 1170 | bbc_setirq( | |
| 1170 | bbc_setirq(machine); | |
| 1171 | 1171 | } |
| 1172 | 1172 | |
| 1173 | 1173 | |
| r2724 | r2725 | |
| 1253 | 1253 | via_1_ca1_w(machine, 0,data); |
| 1254 | 1254 | } |
| 1255 | 1255 | |
| 1256 | static void bbc_via_user_irq(int level) | |
| 1256 | static void bbc_via_user_irq(running_machine *machine, int level) | |
| 1257 | 1257 | { |
| 1258 | 1258 | via_user_irq=level; |
| 1259 | bbc_setirq( | |
| 1259 | bbc_setirq(machine); | |
| 1260 | 1260 | } |
| 1261 | 1261 | |
| 1262 | 1262 |
| r2724 | r2725 | |
|---|---|---|
| 1725 | 1725 | } |
| 1726 | 1726 | |
| 1727 | 1727 | |
| 1728 | static void kc85_pio_interrupt(int state) | |
| 1728 | static void kc85_pio_interrupt(running_machine *machine, int state) | |
| 1729 | 1729 | { |
| 1730 | cpunum_set_input_line( | |
| 1730 | cpunum_set_input_line(machine, 0, 0, state); | |
| 1731 | 1731 | } |
| 1732 | 1732 | |
| 1733 | static void kc85_ctc_interrupt(int state) | |
| 1733 | static void kc85_ctc_interrupt(running_machine *machine, int state) | |
| 1734 | 1734 | { |
| 1735 | cpunum_set_input_line( | |
| 1735 | cpunum_set_input_line(machine, 0, 1, state); | |
| 1736 | 1736 | } |
| 1737 | 1737 | |
| 1738 | 1738 | /* callback for ardy output from PIO */ |
| r2724 | r2725 | |
|---|---|---|
| 300 | 300 | PORT_BIT(0x8000, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Return") PORT_CODE(KEYCODE_ENTER) |
| 301 | 301 | |
| 302 | 302 | PORT_START /* 10: pseudo-input port with config */ |
| 303 | PORT_ | |
| 303 | PORT_DIPNAME( 0x0003, 0x0002, | |
| 304 | 304 | PORT_DIPSETTING( 0x0000, "4kw" ) |
| 305 | 305 | PORT_DIPSETTING( 0x0001, "32kw") |
| 306 | 306 | PORT_DIPSETTING( 0x0002, "64kw") |
| 307 | PORT_ | |
| 307 | PORT_DIPNAME( 0x0004, 0x0000, | |
| 308 | 308 | PORT_DIPSETTING( 0x0000, DEF_STR( Off ) ) |
| 309 | 309 | PORT_DIPSETTING( 0x0004, DEF_STR( On ) ) |
| 310 | PORT_ | |
| 310 | PORT_DIPNAME( 0x0008, 0x0000, | |
| 311 | 311 | PORT_DIPSETTING( 0x0000, DEF_STR( Off ) ) |
| 312 | 312 | PORT_DIPSETTING( 0x0008, DEF_STR( On ) ) |
| 313 | PORT_ | |
| 313 | PORT_DIPNAME( 0x0010, 0x0000, | |
| 314 | 314 | PORT_DIPSETTING( 0x0000, DEF_STR( Off ) ) |
| 315 | 315 | PORT_DIPSETTING( 0x0010, DEF_STR( On ) ) |
| 316 | 316 | PORT_DIPNAME( 0x0020, 0x0000, "Type 32 light pen") PORT_CODE(KEYCODE_ENTER_PAD) |
| r2724 | r2725 | |
|---|---|---|
| 423 | 423 | |
| 424 | 424 | static INTERRUPT_GEN( adam_interrupt ) |
| 425 | 425 | { |
| 426 | TMS9928A_interrupt(); | |
| 426 | TMS9928A_interrupt(machine); | |
| 427 | 427 | exploreKeyboard(); |
| 428 | 428 | } |
| 429 | 429 | |
| 430 | static void adam_vdp_interrupt (int state) | |
| 430 | static void adam_vdp_interrupt (running_machine *machine, int state) | |
| 431 | 431 | { |
| 432 | 432 | static int last_state = 0; |
| 433 | 433 | |
| 434 | 434 | /* only if it goes up */ |
| 435 | 435 | if (state && !last_state) |
| 436 | 436 | { |
| 437 | cpunum_set_input_line( | |
| 437 | cpunum_set_input_line(machine, 0, INPUT_LINE_NMI, PULSE_LINE); | |
| 438 | 438 | } |
| 439 | 439 | last_state = state; |
| 440 | 440 | } |
| r2724 | r2725 | |
|---|---|---|
| 298 | 298 | /*********************************************************************************************/ |
| 299 | 299 | |
| 300 | 300 | |
| 301 | static void sord_m5_ctc_interrupt(int state) | |
| 301 | static void sord_m5_ctc_interrupt(running_machine *machine, int state) | |
| 302 | 302 | { |
| 303 | 303 | //logerror("interrupting ctc %02x\r\n ",state); |
| 304 | cpunum_set_input_line( | |
| 304 | cpunum_set_input_line(machine, 0, 0, state); | |
| 305 | 305 | } |
| 306 | 306 | |
| 307 | 307 | static z80ctc_interface sord_m5_ctc_intf = |
| r2724 | r2725 | |
| 451 | 451 | }, |
| 452 | 452 | }; |
| 453 | 453 | |
| 454 | static void sordm5_video_interrupt_callback(int state) | |
| 454 | static void sordm5_video_interrupt_callback(running_machine *machine, int state) | |
| 455 | 455 | { |
| 456 | 456 | if (state) |
| 457 | 457 | { |
| 458 | z80ctc_0_trg3_w(Machine, 0, 1); | |
| 459 | z80ctc_0_trg3_w(Machine, 0, 0); | |
| 458 | z80ctc_0_trg3_w(machine, 0, 1); | |
| 459 | z80ctc_0_trg3_w(machine, 0, 0); | |
| 460 | 460 | } |
| 461 | 461 | } |
| 462 | 462 | |
| r2724 | r2725 | |
| 622 | 622 | |
| 623 | 623 | static INTERRUPT_GEN( sord_interrupt ) |
| 624 | 624 | { |
| 625 | if (TMS9928A_interrupt()) | |
| 625 | if (TMS9928A_interrupt(machine)) | |
| 626 | 626 | cpunum_set_input_line(machine, 0, 0, HOLD_LINE); |
| 627 | 627 | } |
| 628 | 628 |
| r2724 | r2725 | |
|---|---|---|
| 198 | 198 | |
| 199 | 199 | /* 1 port for config */ |
| 200 | 200 | PORT_START /* config */ |
| 201 | PORT_ | |
| 201 | PORT_DIPNAME( config_fdc_mask << config_fdc_bit, /*fdc_kind_hfdc << config_fdc_bit*/0, | |
| 202 | 202 | PORT_DIPSETTING( fdc_kind_none << config_fdc_bit, DEF_STR( None ) ) |
| 203 | 203 | PORT_DIPSETTING( fdc_kind_TI << config_fdc_bit, "Texas Instruments SD" ) |
| 204 | 204 | #if HAS_99CCFDC |
| r2724 | r2725 | |
| 206 | 206 | #endif |
| 207 | 207 | PORT_DIPSETTING( fdc_kind_BwG << config_fdc_bit, "SNUG's BwG" ) |
| 208 | 208 | PORT_DIPSETTING( fdc_kind_hfdc << config_fdc_bit, "Myarc's HFDC" ) |
| 209 | PORT_ | |
| 209 | PORT_DIPNAME( config_ide_mask << config_ide_bit, /*1 << config_ide_bit*/0, | |
| 210 | 210 | PORT_DIPSETTING( 0x0000, DEF_STR( Off ) ) |
| 211 | 211 | PORT_DIPSETTING( 1 << config_ide_bit, DEF_STR( On ) ) |
| 212 | PORT_ | |
| 212 | PORT_DIPNAME( config_rs232_mask << config_rs232_bit, /*1 << config_rs232_bit*/0, | |
| 213 | 213 | PORT_DIPSETTING( 0x0000, DEF_STR( Off ) ) |
| 214 | 214 | PORT_DIPSETTING( 1 << config_rs232_bit, DEF_STR( On ) ) |
| 215 | PORT_ | |
| 215 | PORT_DIPNAME( config_hsgpl_mask << config_hsgpl_bit, 0/*1 << config_hsgpl_bit*/, | |
| 216 | 216 | PORT_DIPSETTING( 0x0000, DEF_STR( Off ) ) |
| 217 | 217 | PORT_DIPSETTING( 1 << config_hsgpl_bit, DEF_STR( On ) ) |
| 218 | PORT_ | |
| 218 | PORT_DIPNAME( config_mecmouse_mask << config_mecmouse_bit, 0, | |
| 219 | 219 | PORT_DIPSETTING( 0x0000, DEF_STR( Off ) ) |
| 220 | 220 | PORT_DIPSETTING( 1 << config_mecmouse_bit, DEF_STR( On ) ) |
| 221 | PORT_ | |
| 221 | PORT_DIPNAME( config_usbsm_mask << config_usbsm_bit, 1 << config_usbsm_bit, | |
| 222 | 222 | PORT_DIPSETTING( 0x0000, DEF_STR( Off ) ) |
| 223 | 223 | PORT_DIPSETTING( 1 << config_usbsm_bit, DEF_STR( On ) ) |
| 224 | 224 |
| r2724 | r2725 | |
|---|---|---|
| 108 | 108 | PORT_BIT (0x80, 0x00, IPT_UNUSED ) |
| 109 | 109 | PORT_BIT(0x40, 0x40, IPT_KEYBOARD) PORT_NAME("sw1: ST (F7)") PORT_CODE(KEYCODE_F7) |
| 110 | 110 | PORT_BIT(0x20, 0x20, IPT_KEYBOARD) PORT_NAME("sw2: RS (F3)") PORT_CODE(KEYCODE_F3) |
| 111 | PORT_ | |
| 111 | PORT_DIPNAME(0x10, 0x10, | |
| 112 | 112 | PORT_DIPSETTING( 0x00, "single step") |
| 113 | 113 | PORT_DIPSETTING( 0x10, "run") |
| 114 | 114 | PORT_BIT (0x08, 0x00, IPT_UNUSED ) |
| r2724 | r2725 | |
|---|---|---|
| 121 | 121 | AICA_set_ram_base(0, dc_sound_ram, 2*1024*1024); |
| 122 | 122 | } |
| 123 | 123 | |
| 124 | static void aica_irq(int irq) | |
| 124 | static void aica_irq(running_machine *machine, int irq) | |
| 125 | 125 | { |
| 126 | cpunum_set_input_line( | |
| 126 | cpunum_set_input_line(machine, 1, ARM7_FIRQ_LINE, irq ? ASSERT_LINE : CLEAR_LINE); | |
| 127 | 127 | } |
| 128 | 128 | |
| 129 | 129 | static const struct AICAinterface aica_interface = |
| r2724 | r2725 | |
|---|---|---|
| 72 | 72 | PORT_DIPNAME( 0x20, 0x00, "Extension E000-EFFF") |
| 73 | 73 | PORT_DIPSETTING( 0x00, DEF_STR( Off ) ) |
| 74 | 74 | PORT_DIPSETTING( 0x20, DEF_STR( On ) ) |
| 75 | PORT_ | |
| 75 | PORT_DIPNAME( 0x10, 0x10, | |
| 76 | 76 | PORT_DIPSETTING( 0x10, "TV set" ) |
| 77 | 77 | PORT_DIPSETTING( 0x00, "RGB monitor" ) |
| 78 | PORT_ | |
| 78 | PORT_DIPNAME( 0x08, 0x08, | |
| 79 | 79 | PORT_DIPSETTING( 0x00, DEF_STR( Off ) ) |
| 80 | 80 | PORT_DIPSETTING( 0x08, DEF_STR( On ) ) |
| 81 | 81 | PORT_BIT(0x07, 0x07, IPT_UNUSED) |
| r2724 | r2725 | |
|---|---|---|
| 1440 | 1440 | } |
| 1441 | 1441 | } |
| 1442 | 1442 | |
| 1443 | static void x68k_fm_irq(int irq) | |
| 1443 | static void x68k_fm_irq(running_machine *machine, int irq) | |
| 1444 | 1444 | { |
| 1445 | 1445 | if(irq == CLEAR_LINE) |
| 1446 | 1446 | { |
| r2724 | r2725 | |
|---|---|---|
| 367 | 367 | |
| 368 | 368 | /* Z80 PIO Interface */ |
| 369 | 369 | |
| 370 | static void mpf1_pio_interrupt( int state ) | |
| 370 | static void mpf1_pio_interrupt( running_machine *machine, int state ) | |
| 371 | 371 | { |
| 372 | 372 | logerror("pio irq state: %02x\n",state); |
| 373 | 373 | } |
| r2724 | r2725 | |
|---|---|---|
| 341 | 341 | |
| 342 | 342 | /**************************** PIO ******************************************************************************/ |
| 343 | 343 | |
| 344 | static void pio_interrupt(int state) | |
| 344 | static void pio_interrupt(running_machine *machine, int state) | |
| 345 | 345 | { |
| 346 | cpunum_set_input_line( | |
| 346 | cpunum_set_input_line( machine, 0, 0, state ? ASSERT_LINE : CLEAR_LINE ); | |
| 347 | 347 | } |
| 348 | 348 | |
| 349 | 349 | static const z80pio_interface pio_intf = |
| r2724 | r2725 | |
|---|---|---|
| 252 | 252 | static INPUT_PORTS_START(geneve) |
| 253 | 253 | |
| 254 | 254 | PORT_START /* config */ |
| 255 | PORT_ | |
| 255 | PORT_DIPNAME( config_speech_mask << config_speech_bit, 1 << config_speech_bit, | |
| 256 | 256 | PORT_DIPSETTING( 0x0000, DEF_STR( Off ) ) |
| 257 | 257 | PORT_DIPSETTING( 1 << config_speech_bit, DEF_STR( On ) ) |
| 258 | PORT_ | |
| 258 | PORT_DIPNAME( config_fdc_mask << config_fdc_bit, fdc_kind_hfdc << config_fdc_bit, | |
| 259 | 259 | PORT_DIPSETTING( fdc_kind_none << config_fdc_bit, DEF_STR( None ) ) |
| 260 | 260 | PORT_DIPSETTING( fdc_kind_TI << config_fdc_bit, "Texas Instruments SD" ) |
| 261 | 261 | #if HAS_99CCFDC |
| r2724 | r2725 | |
| 263 | 263 | #endif |
| 264 | 264 | PORT_DIPSETTING( fdc_kind_BwG << config_fdc_bit, "SNUG's BwG" ) |
| 265 | 265 | PORT_DIPSETTING( fdc_kind_hfdc << config_fdc_bit, "Myarc's HFDC" ) |
| 266 | PORT_ | |
| 266 | PORT_DIPNAME( config_ide_mask << config_ide_bit, /*1 << config_ide_bit*/0, | |
| 267 | 267 | PORT_DIPSETTING( 0x0000, DEF_STR( Off ) ) |
| 268 | 268 | PORT_DIPSETTING( 1 << config_ide_bit, DEF_STR( On ) ) |
| 269 | PORT_ | |
| 269 | PORT_DIPNAME( config_rs232_mask << config_rs232_bit, 1 << config_rs232_bit, | |
| 270 | 270 | PORT_DIPSETTING( 0x0000, DEF_STR( Off ) ) |
| 271 | 271 | PORT_DIPSETTING( 1 << config_rs232_bit, DEF_STR( On ) ) |
| 272 | PORT_ | |
| 272 | PORT_DIPNAME( config_usbsm_mask << config_usbsm_bit, 1 << config_usbsm_bit, | |
| 273 | 273 | PORT_DIPSETTING( 0x0000, DEF_STR( Off ) ) |
| 274 | 274 | PORT_DIPSETTING( 1 << config_usbsm_bit, DEF_STR( On ) ) |
| 275 | 275 |
| r2724 | r2725 | |
|---|---|---|
| 313 | 313 | |
| 314 | 314 | static INTERRUPT_GEN( sg1000_int ) |
| 315 | 315 | { |
| 316 | TMS9928A_interrupt(); | |
| 316 | TMS9928A_interrupt(machine); | |
| 317 | 317 | } |
| 318 | 318 | |
| 319 | static void sg1000_vdp_interrupt(int state) | |
| 319 | static void sg1000_vdp_interrupt(running_machine *machine, int state) | |
| 320 | 320 | { |
| 321 | cpunum_set_input_line_and_vector( | |
| 321 | cpunum_set_input_line_and_vector(machine, 0, INPUT_LINE_IRQ0, state, 0x38); | |
| 322 | 322 | } |
| 323 | 323 | |
| 324 | 324 | static const TMS9928a_interface tms9928a_interface = |
| r2724 | r2725 | |
|---|---|---|
| 1271 | 1271 | |
| 1272 | 1272 | static UINT8 dma_buffer[4096]; |
| 1273 | 1273 | |
| 1274 | static void scsi_irq(int state) | |
| 1274 | static void scsi_irq(running_machine *machine, int state) | |
| 1275 | 1275 | { |
| 1276 | running_machine *machine = Machine; | |
| 1277 | ||
| 1278 | 1276 | if (state) |
| 1279 | 1277 | { |
| 1280 | 1278 | if (wd33c93_get_dma_count()) |
| r2724 | r2725 | |
|---|---|---|
| 1138 | 1138 | static WRITE8_HANDLER( switch_B_w ) { |
| 1139 | 1139 | } |
| 1140 | 1140 | |
| 1141 | static void irq_callback(int state) { | |
| 1141 | static void irq_callback(running_machine *machine, int state) { | |
| 1142 | 1142 | } |
| 1143 | 1143 | |
| 1144 | 1144 | static const struct riot6532_interface r6532_interface = |
| r2724 | r2725 | |
| 1431 | 1431 | } |
| 1432 | 1432 | |
| 1433 | 1433 | static void set_category_value( running_machine *machine, const char* cat, const char *cat_selection ) { |
| 1434 | /* NPW 22-May-2008 - FIXME */ | |
| 1435 | #if 0 | |
| 1434 | 1436 | input_port_entry *cat_in = NULL; |
| 1435 | 1437 | input_port_entry *in; |
| 1436 | 1438 | |
| r2724 | r2725 | |
| 1443 | 1445 | return; |
| 1444 | 1446 | } |
| 1445 | 1447 | } |
| 1448 | #endif | |
| 1446 | 1449 | } |
| 1447 | 1450 | |
| 1448 | 1451 | static void set_controller( running_machine *machine, const char *controller, unsigned int selection ) { |
| r2724 | r2725 | |
|---|---|---|
| 402 | 402 | |
| 403 | 403 | #if defined(ADLIB) |
| 404 | 404 | /* irq line not connected to pc on adlib cards (and compatibles) */ |
| 405 | static void irqhandler(int linestate) {} | |
| 405 | static void irqhandler(running_machine *machine, int linestate) {} | |
| 406 | 406 | |
| 407 | 407 | static const struct YM3812interface ym3812_interface = |
| 408 | 408 | { |
| r2724 | r2725 | |
|---|---|---|
| 177 | 177 | |
| 178 | 178 | static INTERRUPT_GEN( coleco_interrupt ) |
| 179 | 179 | { |
| 180 | TMS9928A_interrupt(); | |
| 180 | TMS9928A_interrupt(machine); | |
| 181 | 181 | } |
| 182 | 182 | |
| 183 | static void coleco_vdp_interrupt (int state) | |
| 183 | static void coleco_vdp_interrupt (running_machine *machine, int state) | |
| 184 | 184 | { |
| 185 | 185 | static int last_state = 0; |
| 186 | 186 | |
| 187 | 187 | // only if it goes up |
| 188 | if (state && !last_state) cpunum_set_input_line( | |
| 188 | if (state && !last_state) cpunum_set_input_line(machine, 0, INPUT_LINE_NMI, PULSE_LINE); | |
| 189 | 189 | last_state = state; |
| 190 | 190 | } |
| 191 | 191 |
| r2724 | r2725 | |
|---|---|---|
| 170 | 170 | |
| 171 | 171 | if (newval) |
| 172 | 172 | { |
| 173 | cpunum_set_input_line(machine, 0, UPD7810_INTF1, state); | |
| 173 | cpunum_set_input_line(field->port->machine, 0, UPD7810_INTF1, state); | |
| 174 | 174 | state = (state == ASSERT_LINE) ? CLEAR_LINE : ASSERT_LINE; |
| 175 | 175 | } |
| 176 | 176 | } |
| r2724 | r2725 | |
|---|---|---|
| 148 | 148 | cpunum_set_input_line(machine, 0, 0, apf_ints ? HOLD_LINE : CLEAR_LINE); |
| 149 | 149 | } |
| 150 | 150 | |
| 151 | static void apf_m1000_irq_a_func(int state) | |
| 151 | static void apf_m1000_irq_a_func(running_machine *machine, int state) | |
| 152 | 152 | { |
| 153 | 153 | if (state) |
| 154 | 154 | { |
| r2724 | r2725 | |
| 159 | 159 | apf_ints&=~1; |
| 160 | 160 | } |
| 161 | 161 | |
| 162 | apf_update_ints( | |
| 162 | apf_update_ints(machine); | |
| 163 | 163 | } |
| 164 | 164 | |
| 165 | 165 | |
| 166 | static void apf_m1000_irq_b_func(int state) | |
| 166 | static void apf_m1000_irq_b_func(running_machine *machine, int state) | |
| 167 | 167 | { |
| 168 | 168 | //logerror("pia 0 irq b %d\n",state); |
| 169 | 169 | |
| r2724 | r2725 | |
| 176 | 176 | apf_ints&=~2; |
| 177 | 177 | } |
| 178 | 178 | |
| 179 | apf_update_ints( | |
| 179 | apf_update_ints(machine); | |
| 180 | 180 | |
| 181 | 181 | } |
| 182 | 182 | |
| r2724 | r2725 | |
| 274 | 274 | { |
| 275 | 275 | } |
| 276 | 276 | |
| 277 | static void apf_imagination_irq_a_func(int state) | |
| 277 | static void apf_imagination_irq_a_func(running_machine *machine, int state) | |
| 278 | 278 | { |
| 279 | 279 | if (state) |
| 280 | 280 | { |
| r2724 | r2725 | |
| 285 | 285 | apf_ints&=~4; |
| 286 | 286 | } |
| 287 | 287 | |
| 288 | apf_update_ints( | |
| 288 | apf_update_ints(machine); | |
| 289 | 289 | |
| 290 | 290 | } |
| 291 | 291 | |
| 292 | static void apf_imagination_irq_b_func(int state) | |
| 292 | static void apf_imagination_irq_b_func(running_machine *machine, int state) | |
| 293 | 293 | { |
| 294 | 294 | if (state) |
| 295 | 295 | { |
| r2724 | r2725 | |
| 300 | 300 | apf_ints&=~8; |
| 301 | 301 | } |
| 302 | 302 | |
| 303 | apf_update_ints( | |
| 303 | apf_update_ints(machine); | |
| 304 | 304 | |
| 305 | 305 | } |
| 306 | 306 |
| r2724 | r2725 | |
|---|---|---|
| 2249 | 2249 | static const struct sh2_config sh2_conf_master = { 0 }; |
| 2250 | 2250 | static const struct sh2_config sh2_conf_slave = { 1 }; |
| 2251 | 2251 | |
| 2252 | static void scsp_irq(int irq) | |
| 2252 | static void scsp_irq(running_machine *machine, int irq) | |
| 2253 | 2253 | { |
| 2254 | 2254 | // don't bother the 68k if it's off |
| 2255 | 2255 | if (!en_68k) |
| r2724 | r2725 | |
| 2260 | 2260 | if (irq > 0) |
| 2261 | 2261 | { |
| 2262 | 2262 | scsp_last_line = irq; |
| 2263 | cpunum_set_input_line( | |
| 2263 | cpunum_set_input_line(machine, 2, irq, ASSERT_LINE); | |
| 2264 | 2264 | } |
| 2265 | 2265 | else if (irq < 0) |
| 2266 | 2266 | { |
| 2267 | cpunum_set_input_line( | |
| 2267 | cpunum_set_input_line(machine, 2, -irq, CLEAR_LINE); | |
| 2268 | 2268 | } |
| 2269 | 2269 | else |
| 2270 | 2270 | { |
| 2271 | cpunum_set_input_line( | |
| 2271 | cpunum_set_input_line(machine, 2, scsp_last_line, CLEAR_LINE); | |
| 2272 | 2272 | } |
| 2273 | 2273 | } |
| 2274 | 2274 |
| r2724 | r2725 | |
|---|---|---|
| 197 | 197 | |
| 198 | 198 | static INTERRUPT_GEN( crvision_int ) |
| 199 | 199 | { |
| 200 | TMS9928A_interrupt(); | |
| 200 | TMS9928A_interrupt(machine); | |
| 201 | 201 | } |
| 202 | 202 | |
| 203 | static void crvision_vdp_interrupt(int state) | |
| 203 | static void crvision_vdp_interrupt(running_machine *machine, int state) | |
| 204 | 204 | { |
| 205 | cpunum_set_input_line( | |
| 205 | cpunum_set_input_line(machine, 0, INPUT_LINE_IRQ0, state); | |
| 206 | 206 | } |
| 207 | 207 | |
| 208 | 208 | static const TMS9928a_interface tms9918_intf = |
| r2724 | r2725 | |
|---|---|---|
| 402 | 402 | |
| 403 | 403 | |
| 404 | 404 | /* interrupt state callback for ctc */ |
| 405 | static void einstein_ctc_interrupt(int state) | |
| 405 | static void einstein_ctc_interrupt(running_machine *machine, int state) | |
| 406 | 406 | { |
| 407 | 407 | logerror("ctc irq state: %02x\n",state); |
| 408 | cpunum_set_input_line( | |
| 408 | cpunum_set_input_line(machine, 0, 1, state); | |
| 409 | 409 | } |
| 410 | 410 | |
| 411 | static void einstein_pio_interrupt(int state) | |
| 411 | static void einstein_pio_interrupt(running_machine *machine, int state) | |
| 412 | 412 | { |
| 413 | 413 | logerror("pio irq state: %02x\n",state); |
| 414 | cpunum_set_input_line( | |
| 414 | cpunum_set_input_line(machine, 0, 3, state); | |
| 415 | 415 | } |
| 416 | 416 | |
| 417 | 417 | static WRITE8_HANDLER(einstein_serial_transmit_clock) |
| r2724 | r2725 | |
|---|---|---|
| 180 | 180 | int n_port = param; |
| 181 | 181 | if( m_pad[ n_port ].n_state != PAD_STATE_IDLE ) |
| 182 | 182 | { |
| 183 | psx_sio_input( 0, PSX_SIO_IN_DSR, m_pad[ n_port ].b_ack * PSX_SIO_IN_DSR ); | |
| 183 | psx_sio_input( machine, 0, PSX_SIO_IN_DSR, m_pad[ n_port ].b_ack * PSX_SIO_IN_DSR ); | |
| 184 | 184 | if( !m_pad[ n_port ].b_ack ) |
| 185 | 185 | { |
| 186 | 186 | m_pad[ n_port ].b_ack = 1; |
| r2724 | r2725 | |
| 217 | 217 | case PAD_STATE_READ: |
| 218 | 218 | if( m_pad[ n_port ].b_lastclock && !b_clock ) |
| 219 | 219 | { |
| 220 | psx_sio_input( 0, PSX_SIO_IN_DATA, ( m_pad[ n_port ].n_shiftout & 1 ) * PSX_SIO_IN_DATA ); | |
| 220 | psx_sio_input( machine, 0, PSX_SIO_IN_DATA, ( m_pad[ n_port ].n_shiftout & 1 ) * PSX_SIO_IN_DATA ); | |
| 221 | 221 | m_pad[ n_port ].n_shiftout >>= 1; |
| 222 | 222 | } |
| 223 | 223 | if( !m_pad[ n_port ].b_lastclock && b_clock ) |
| r2724 | r2725 | |
| 634 | 634 | if (psx_cdcmd) |
| 635 | 635 | psx_cdcmd(); |
| 636 | 636 | |
| 637 | psx_irq_set(0x0004); | |
| 637 | psx_irq_set(machine, 0x0004); | |
| 638 | 638 | } |
| 639 | 639 | else if( mem_mask == 0xff00ffff ) |
| 640 | 640 | { |
| r2724 | r2725 | |
|---|---|---|
| 135 | 135 | static INTERRUPT_GEN( tutor_vblank_interrupt ) |
| 136 | 136 | { |
| 137 | 137 | /* No vblank interrupt? */ |
| 138 | TMS9928A_interrupt(); | |
| 138 | TMS9928A_interrupt(machine); | |
| 139 | 139 | } |
| 140 | 140 | |
| 141 | 141 | static const device_config *printer_fp(void) |
| r2724 | r2725 | |
|---|---|---|
| 95 | 95 | |
| 96 | 96 | /* 1 port for config */ |
| 97 | 97 | PORT_START /* config */ |
| 98 | PORT_ | |
| 98 | PORT_DIPNAME( config_speech_mask << config_speech_bit, 1 << config_speech_bit, | |
| 99 | 99 | PORT_DIPSETTING( 0x0000, DEF_STR( Off ) ) |
| 100 | 100 | PORT_DIPSETTING( 1 << config_speech_bit, DEF_STR( On ) ) |
| 101 | PORT_ | |
| 101 | PORT_DIPNAME( config_fdc_mask << config_fdc_bit, fdc_kind_hfdc << config_fdc_bit, | |
| 102 | 102 | PORT_DIPSETTING( fdc_kind_none << config_fdc_bit, DEF_STR( None ) ) |
| 103 | 103 | PORT_DIPSETTING( fdc_kind_TI << config_fdc_bit, "Texas Instruments SD" ) |
| 104 | 104 | #if HAS_99CCFDC |
| r2724 | r2725 | |
| 106 | 106 | #endif |
| 107 | 107 | PORT_DIPSETTING( fdc_kind_BwG << config_fdc_bit, "SNUG's BwG" ) |
| 108 | 108 | PORT_DIPSETTING( fdc_kind_hfdc << config_fdc_bit, "Myarc's HFDC" ) |
| 109 | /*PORT_ | |
| 109 | /*PORT_DIPNAME( config_ide_mask << config_ide_bit, 1 << config_ide_bit, IPT_DIPSWITCH_NAME) PORT_NAME("Nouspickel's IDE card") | |
| 110 | 110 | PORT_DIPSETTING( 0x0000, DEF_STR( Off ) ) |
| 111 | 111 | PORT_DIPSETTING( 1 << config_ide_bit, DEF_STR( On ) )*/ |
| 112 | PORT_ | |
| 112 | PORT_DIPNAME( config_rs232_mask << config_rs232_bit, /*1 << config_rs232_bit*/0, | |
| 113 | 113 | PORT_DIPSETTING( 0x0000, DEF_STR( Off ) ) |
| 114 | 114 | PORT_DIPSETTING( 1 << config_rs232_bit, DEF_STR( On ) ) |
| 115 | PORT_ | |
| 115 | PORT_DIPNAME( config_mecmouse_mask << config_mecmouse_bit, 0, | |
| 116 | 116 | PORT_DIPSETTING( 0x0000, DEF_STR( Off ) ) |
| 117 | 117 | PORT_DIPSETTING( 1 << config_mecmouse_bit, DEF_STR( On ) ) |
| 118 | PORT_ | |
| 118 | PORT_DIPNAME( config_usbsm_mask << config_usbsm_bit, 1 << config_usbsm_bit, | |
| 119 | 119 | PORT_DIPSETTING( 0x0000, DEF_STR( Off ) ) |
| 120 | 120 | PORT_DIPSETTING( 1 << config_usbsm_bit, DEF_STR( On ) ) |
| 121 | 121 |
| r2724 | r2725 | |
|---|---|---|
| 1156 | 1156 | |
| 1157 | 1157 | #if defined(ADLIB) |
| 1158 | 1158 | /* irq line not connected to pc on adlib cards (and compatibles) */ |
| 1159 | static void pc_irqhandler(int linestate) {} | |
| 1159 | static void pc_irqhandler(running_machine *machine, int linestate) {} | |
| 1160 | 1160 | |
| 1161 | 1161 | static const struct YM3812interface ym3812_interface = |
| 1162 | 1162 | { |
| r2724 | r2725 | |
|---|---|---|
| 105 | 105 | |
| 106 | 106 | /* 1 port for config */ |
| 107 | 107 | PORT_START /* config */ |
| 108 | PORT_ | |
| 108 | PORT_DIPNAME( config_xRAM_mask << config_xRAM_bit, xRAM_kind_TI << config_xRAM_bit, | |
| 109 | 109 | PORT_DIPSETTING( xRAM_kind_none << config_xRAM_bit, DEF_STR( None ) ) |
| 110 | 110 | PORT_DIPSETTING( xRAM_kind_TI << config_xRAM_bit, "Texas Instruments 32kb") |
| 111 | 111 | PORT_DIPSETTING( xRAM_kind_super_AMS << config_xRAM_bit, "Super AMS 1Mb") |
| r2724 | r2725 | |
| 113 | 113 | PORT_DIPSETTING( xRAM_kind_foundation_512k << config_xRAM_bit, "Foundation 512kb") |
| 114 | 114 | PORT_DIPSETTING( xRAM_kind_myarc_128k << config_xRAM_bit, "Myarc look-alike 128kb") |
| 115 | 115 | PORT_DIPSETTING( xRAM_kind_myarc_512k << config_xRAM_bit, "Myarc look-alike 512kb") |
| 116 | PORT_ | |
| 116 | PORT_DIPNAME( config_speech_mask << config_speech_bit, 1 << config_speech_bit, | |
| 117 | 117 | PORT_DIPSETTING( 0x0000, DEF_STR( Off ) ) |
| 118 | 118 | PORT_DIPSETTING( 1 << config_speech_bit, DEF_STR( On ) ) |
| 119 | PORT_ | |
| 119 | PORT_DIPNAME( config_fdc_mask << config_fdc_bit, fdc_kind_hfdc << config_fdc_bit, | |
| 120 | 120 | PORT_DIPSETTING( fdc_kind_none << config_fdc_bit, DEF_STR( None ) ) |
| 121 | 121 | PORT_DIPSETTING( fdc_kind_TI << config_fdc_bit, "Texas Instruments SD" ) |
| 122 | 122 | #if HAS_99CCFDC |
| r2724 | r2725 | |
| 124 | 124 | #endif |
| 125 | 125 | PORT_DIPSETTING( fdc_kind_BwG << config_fdc_bit, "SNUG's BwG" ) |
| 126 | 126 | PORT_DIPSETTING( fdc_kind_hfdc << config_fdc_bit, "Myarc's HFDC" ) |
| 127 | PORT_ | |
| 127 | PORT_DIPNAME( config_ide_mask << config_ide_bit, 1 << config_ide_bit, | |
| 128 | 128 | PORT_DIPSETTING( 0x0000, DEF_STR( Off ) ) |
| 129 | 129 | PORT_DIPSETTING( 1 << config_ide_bit, DEF_STR( On ) ) |
| 130 | PORT_ | |
| 130 | PORT_DIPNAME( config_rs232_mask << config_rs232_bit, 1 << config_rs232_bit, | |
| 131 | 131 | PORT_DIPSETTING( 0x0000, DEF_STR( Off ) ) |
| 132 | 132 | PORT_DIPSETTING( 1 << config_rs232_bit, DEF_STR( On ) ) |
| 133 | PORT_ | |
| 133 | PORT_DIPNAME( config_hsgpl_mask << config_hsgpl_bit, 0/*1 << config_hsgpl_bit*/, | |
| 134 | 134 | PORT_DIPSETTING( 0x0000, DEF_STR( Off ) ) |
| 135 | 135 | PORT_DIPSETTING( 1 << config_hsgpl_bit, DEF_STR( On ) ) |
| 136 | PORT_ | |
| 136 | PORT_DIPNAME( config_mecmouse_mask << config_mecmouse_bit, 0, | |
| 137 | 137 | PORT_DIPSETTING( 0x0000, DEF_STR( Off ) ) |
| 138 | 138 | PORT_DIPSETTING( 1 << config_mecmouse_bit, DEF_STR( On ) ) |
| 139 | PORT_ | |
| 139 | PORT_DIPNAME( config_usbsm_mask << config_usbsm_bit, 1 << config_usbsm_bit, | |
| 140 | 140 | PORT_DIPSETTING( 0x0000, DEF_STR( Off ) ) |
| 141 | 141 | PORT_DIPSETTING( 1 << config_usbsm_bit, DEF_STR( On ) ) |
| 142 | 142 | |
| r2724 | r2725 | |
| 245 | 245 | |
| 246 | 246 | /* 1 port for config */ |
| 247 | 247 | PORT_START /* config */ |
| 248 | PORT_ | |
| 248 | PORT_DIPNAME( config_xRAM_mask << config_xRAM_bit, xRAM_kind_TI << config_xRAM_bit, | |
| 249 | 249 | PORT_DIPSETTING( xRAM_kind_none << config_xRAM_bit, DEF_STR( None ) ) |
| 250 | 250 | PORT_DIPSETTING( xRAM_kind_TI << config_xRAM_bit, "Texas Instruments 32kb") |
| 251 | 251 | PORT_DIPSETTING( xRAM_kind_super_AMS << config_xRAM_bit, "Super AMS 1Mb") |
| r2724 | r2725 | |
| 253 | 253 | PORT_DIPSETTING( xRAM_kind_foundation_512k << config_xRAM_bit, "Foundation 512kb") |
| 254 | 254 | PORT_DIPSETTING( xRAM_kind_myarc_128k << config_xRAM_bit, "Myarc look-alike 128kb") |
| 255 | 255 | PORT_DIPSETTING( xRAM_kind_myarc_512k << config_xRAM_bit, "Myarc look-alike 512kb") |
| 256 | PORT_ | |
| 256 | PORT_DIPNAME( config_speech_mask << config_speech_bit, 1 << config_speech_bit, | |
| 257 | 257 | PORT_DIPSETTING( 0x0000, DEF_STR( Off ) ) |
| 258 | 258 | PORT_DIPSETTING( 1 << config_speech_bit, DEF_STR( On ) ) |
| 259 | PORT_ | |
| 259 | PORT_DIPNAME( config_fdc_mask << config_fdc_bit, fdc_kind_hfdc << config_fdc_bit, | |
| 260 | 260 | PORT_DIPSETTING( fdc_kind_none << config_fdc_bit, DEF_STR( None ) ) |
| 261 | 261 | PORT_DIPSETTING( fdc_kind_TI << config_fdc_bit, "Texas Instruments SD" ) |
| 262 | 262 | #if HAS_99CCFDC |
| r2724 | r2725 | |
| 264 | 264 | #endif |
| 265 | 265 | PORT_DIPSETTING( fdc_kind_BwG << config_fdc_bit, "SNUG's BwG" ) |
| 266 | 266 | PORT_DIPSETTING( fdc_kind_hfdc << config_fdc_bit, "Myarc's HFDC" ) |
| 267 | PORT_ | |
| 267 | PORT_DIPNAME( config_ide_mask << config_ide_bit, /*1 << config_ide_bit*/0, | |
| 268 | 268 | PORT_DIPSETTING( 0x0000, DEF_STR( Off ) ) |
| 269 | 269 | PORT_DIPSETTING( 1 << config_ide_bit, DEF_STR( On ) ) |
| 270 | PORT_ | |
| 270 | PORT_DIPNAME( config_rs232_mask << config_rs232_bit, 1 << config_rs232_bit, | |
| 271 | 271 | PORT_DIPSETTING( 0x0000, DEF_STR( Off ) ) |
| 272 | 272 | PORT_DIPSETTING( 1 << config_rs232_bit, DEF_STR( On ) ) |
| 273 | PORT_ | |
| 273 | PORT_DIPNAME( config_handsets_mask << config_handsets_bit, /*1 << config_handsets_bit*/0, | |
| 274 | 274 | PORT_DIPSETTING( 0x0000, DEF_STR( Off ) ) |
| 275 | 275 | PORT_DIPSETTING( 1 << config_handsets_bit, DEF_STR( On ) ) |
| 276 | PORT_ | |
| 276 | PORT_DIPNAME( config_hsgpl_mask << config_hsgpl_bit, 0/*1 << config_hsgpl_bit*/, | |
| 277 | 277 | PORT_DIPSETTING( 0x0000, DEF_STR( Off ) ) |
| 278 | 278 | PORT_DIPSETTING( 1 << config_hsgpl_bit, DEF_STR( On ) ) |
| 279 | PORT_ | |
| 279 | PORT_DIPNAME( config_mecmouse_mask << config_mecmouse_bit, 0, | |
| 280 | 280 | PORT_DIPSETTING( 0x0000, DEF_STR( Off ) ) |
| 281 | 281 | PORT_DIPSETTING( 1 << config_mecmouse_bit, DEF_STR( On ) ) |
| 282 | PORT_ | |
| 282 | PORT_DIPNAME( config_usbsm_mask << config_usbsm_bit, 1 << config_usbsm_bit, | |
| 283 | 283 | PORT_DIPSETTING( 0x0000, DEF_STR( Off ) ) |
| 284 | 284 | PORT_DIPSETTING( 1 << config_usbsm_bit, DEF_STR( On ) ) |
| 285 | 285 |
| r2724 | r2725 | |
|---|---|---|
| 559 | 559 | nRTC_Temp = 0; |
| 560 | 560 | } |
| 561 | 561 | |
| 562 | static void scsi_irq(int state) | |
| 562 | static void scsi_irq(running_machine *machine, int state) | |
| 563 | 563 | { |
| 564 | 564 | } |
| 565 | 565 |
| r2724 | r2725 | |
|---|---|---|
| 28 | 28 | AM_RANGE(0x81, 0x81) AM_READWRITE(TMS9928A_register_r, TMS9928A_register_w) |
| 29 | 29 | ADDRESS_MAP_END |
| 30 | 30 | |
| 31 | static void tms_interrupt(int dummy) | |
| 31 | static void tms_interrupt(running_machine *machine, int dummy) | |
| 32 | 32 | { |
| 33 | cpunum_set_input_line( | |
| 33 | cpunum_set_input_line(machine, 0, 0, HOLD_LINE); | |
| 34 | 34 | } |
| 35 | 35 | |
| 36 | 36 | static INTERRUPT_GEN( bbcbc_interrupt ) |
| 37 | 37 | { |
| 38 | TMS9928A_interrupt(); | |
| 38 | TMS9928A_interrupt(machine); | |
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | static INPUT_PORTS_START( bbcbc ) |
| r2724 | r2725 | |
|---|---|---|
| 81 | 81 | |
| 82 | 82 | Source Changes: |
| 83 | 83 | ---------------- |
| 84 | - The core is based on MAME 0.125u | |
| 84 | - The core is based on MAME 0.125u2. This incorporates all features of the | |
| 85 | 85 | update to this core. [MAME team] |
| 86 | 86 | |
| 87 | 87 | - Fixed performance problems with -triplebuffer. (bug #1539) [Justin Kerk] |
| Previous | 15994 Revisions | Next |