Previous 15994 Revisions Next

r7501 Friday 5th March, 2010 at 12:28:32 UTC by Nathan Woods
Updating to MAME 0.136u4 core, some files don't compile...
[ROOT]makefile
[docs]messnew.txt
[src/emu]drawgfx.c emualloc.c emualloc.h mame.c mconfig.c mconfig.h memory.h validity.c
[src/emu/cpu]drcbex86.c
[src/emu/cpu/h83002]h8_16.c h8_8.c h8ops.h h8priv.h
[src/emu/debug]express.c
[src/emu/debugint]debugint.c
[src/emu/machine]pic8259.h z80dma.c z80pio.c z80pio.h
[src/emu/sound]disc_mth.c es5506.c k051649.c mos6560.c sn76496.c sound.mak
[src/lib]lib.mak
[src/lib/softfloat]README.txt* mamesf.h* milieu.h* softfloat-macros* softfloat-specialize* softfloat.c* softfloat.h*
[src/mame]mame.mak mamedriv.c
[src/mame/audio]micro3d.c senjyo.c
[src/mame/drivers]1945kiii.c 2mindril.c 39in1.c 8080bw.c ace.c adp.c aeroboto.c aladbl.c albazc.c albazg.c arkanoid.c astinvad.c astrocorp.c asuka.c atarig1.c attckufo.c backfire.c beaminv.c big10.c bigfghtr.c bladestl.c boogwing.c boxer.c calorie.c cball.c cbuster.c chanbara.c chinsan.c chsuper.c circus.c cischeat.c clayshoo.c cninja.c cntsteer.c cps2.c cultures.c dacholer.c dassault.c dblewing.c ddayjlc.c ddealer.c deco156.c deniam.c destroyr.c dietgo.c discoboy.c diverboy.c dominob.c dorachan.c dotrikun.c dreamwld.c drtomy.c dunhuang.c dwarfd.c dynadice.c dynax.c egghunt.c embargo.c enigma2.c exerion.c f-32.c f1gp.c flyball.c funkyjet.c funworld.c galaga.c galaxi.c galaxian.c galdrvr.c go2000.c goldstar.c good.c gstream.c hotblock.c imolagp.c jangou.c jantotsu.c jollyjgr.c jongkyo.c kingdrby.c koikoi.c laserbas.c lastfght.c liberate.c lkage.c lockon.c looping.c lsasquad.c luckgrln.c m14.c m63.c m79amb.c macrossp.c macs.c madmotor.c marinedt.c markham.c matmania.c maygay1b.c mayumi.c mazerbla.c mcatadv.c mcr.c mediagx.c megadriv.c megatech.c megazone.c meijinsn.c meritm.c mermaid.c metlclsh.c metro.c mexico86.c mgolf.c mikie.c minivadr.c mirage.c mjsister.c model3.c mogura.c mole.c momoko.c mosaic.c mouser.c mrdo.c mrflea.c mrjong.c mugsmash.c munchmo.c mwarr.c namcond1.c namcops2.c namcos12.c namcos21.c namcos23.c naomi.c nemesis.c neodrvr.c news.c nightgal.c nitedrvr.c nmg5.c nycaptor.c nyny.c ohmygod.c ojankohs.c olibochu.c oneshot.c onetwo.c orbit.c othello.c othldrby.c othunder.c pachifev.c pktgaldx.c poo.c* pushman.c rgum.c* rohga.c safarir.c sbowling.c segas16b.c segas32.c senjyo.c sfbonus.c shougi.c simpl156.c skeetsht.c skyarmy.c skyfox.c sliver.c spaceg.c speglsht.c spoker.c spool99.c srmp5.c srmp6.c ssingles.c sstrangr.c sub.c suna8.c supbtime.c supdrapo.c superdq.c supertnk.c suprgolf.c system1.c tail2nos.c taito_b.c tmaster.c toaplan1.c toaplan2.c toratora.c tumbleb.c tumblep.c twincobr.c vamphalf.c vaportra.c vicdual.c wardner.c wc90.c zaxxon.c
[src/mame/includes]1942.h 1943.h 20pacgal.h 4enraya.h 88games.h actfancr.h aeroboto.h aerofgt.h airbustr.h ajax.h aliens.h alpha68k.h ambush.h amspdwy.h angelkds.h appoooh.h aquarium.h arabian.h arkanoid.h armedf.h ashnojoe.h asterix.h astrof.h asuka.h atarifb.h atarig1.h atarig42.h atarigt.h atarigx2.h atarisy1.h atarisy2.h avalnche.h badlands.h balsente.h bankp.h batman.h battlane.h battlex.h battlnts.h beathead.h bigevglf.h bigstrkb.h bionicc.h bishi.h bladestl.h blktiger.h blmbycar.h blockade.h blockhl.h blockout.h blstroid.h blueprnt.h bogeyman.h bombjack.h boogwing.h* bottom9.h brkthru.h bsktball.h btime.h bublbobl.h buggychl.h bwing.h cabal.h canyon.h capbowl.h carjmbre.h cave.h cbasebal.h cbuster.h* ccastles.h chaknpop.h champbas.h changela.h cheekyms.h chqflag.h cidelsa.h circus.h circusc.h citycon.h cloud9.h cninja.h combatsc.h commando.h compgolf.h contra.h cop01.h copsnrob.h cosmic.h cps1.h crgolf.h crimfght.h crospang.h crshrace.h cvs.h cyberbal.h darius.h dassault.h* dbz.h dcheese.h dday.h ddragon.h ddragon3.h ddribble.h dec8.h deniam.h dietgo.h* djboy.h dkong.h docastle.h dogfgt.h dragrace.h drgnmst.h dribling.h drmicro.h epos.h eprom.h equites.h esd16.h espial.h exedexes.h exerion.h exprraid.h f1gp.h fantland.h fastlane.h fcombat.h fgoal.h finalizr.h firetrap.h fitfight.h flkatck.h flstory.h foodf.h freekick.h fromanc2.h fromance.h funkybee.h funkyjet.h* funybubl.h fuukifg2.h fuukifg3.h gaelco.h gaiden.h galivan.h galspnbl.h gameplan.h gauntlet.h gberet.h gbusters.h gcpinbal.h gijoe.h ginganin.h glass.h gng.h goal92.h goindol.h goldstar.h gotcha.h gotya.h gradius3.h grchamp.h gumbo.h gundealr.h gunsmoke.h gyruss.h hanaawas.h harddriv.h hcastle.h higemaru.h himesiki.h hitme.h hnayayoi.h holeland.h homedata.h homerun.h hyprduel.h ikki.h inufuku.h iremz80.h ironhors.h jack.h jackal.h jailbrek.h jedi.h kangaroo.h karnov.h kchamp.h kickgoal.h kingobox.h klax.h kncljoe.h kopunch.h ksayakyu.h kyugo.h labyrunr.h ladybug.h ladyfrog.h laserbat.h lasso.h lastduel.h lazercmd.h lemmings.h lethal.h liberate.h lkage.h lockon.h lsasquad.h lwings.h m10.h macrossp.h* madmotor.h* mainevt.h malzak.h mappy.h mario.h markham.h* matmania.h mcatadv.h megadriv.h megazone.h* mermaid.h* metalmx.h metlclsh.h* mexico86.h micro3d.h mikie.h* mitchell.h mjkjidai.h momoko.h* moo.h mosaic.h* mouser.h* mrdo.h* mrflea.h* mrjong.h* mugsmash.h munchmo.h* mw8080bw.h mystston.h n8080.h naomi.h nemesis.h neogeo.h news.h ninjaw.h nitedrvr.h nycaptor.h offtwall.h ohmygod.h* ojankohs.h* oneshot.h opwolf.h orbit.h othldrby.h* othunder.h overdriv.h pandoras.h parodius.h pass.h pgm.h pktgaldx.h* popper.h psikyo.h psikyo4.h psikyosh.h qix.h rainbow.h rampart.h rastan.h relief.h rockrage.h rohga.h* rollerg.h rungun.h sbugger.h sderby.h segas16.h sf.h shadfrce.h shootout.h shuuz.h sidearms.h sidepckt.h silkroad.h simpl156.h* simpsons.h skullxbo.h skyfox.h* slapshot.h sonson.h spbactn.h spy.h srmp2.h sslam.h stactics.h stlforce.h supbtime.h* suprslam.h surpratk.h system16.h tail2nos.h taito_b.h taito_f2.h taito_h.h taito_l.h taito_o.h taito_z.h taitoair.h taitojc.h thunderj.h thunderx.h timeplt.h tmnt.h tnzs.h toaplipt.h* toobin.h topspeed.h toypop.h trackfld.h tumbleb.h tumblep.h* tunhunt.h turbo.h ultraman.h vaportra.h* vastar.h vendetta.h vindictr.h volfied.h warriorb.h welltris.h wgp.h wwfsstar.h xexex.h xmen.h xybots.h xyonix.h yunsun16.h yunsung8.h zaxxon.h zerozone.h
[src/mame/machine]cps2crpt.c daikaiju.c decocass.h lkage.c lsasquad.c maniach.c mcr.c mexico86.c namco50.c namco51.c namco53.c naomi.c naomibd.c nitedrvr.c nycaptor.c slapstic.c snes.c
[src/mame/video]arkanoid.c avgdvg.c boogwing.c cbuster.c cninja.c dassault.c deco16ic.c deco16ic.h* deco32.c dietgo.c funkyjet.c funworld.c hng64.c liberate.c lkage.c lockon.c lsasquad.c macrossp.c madmotor.c markham.c matmania.c mcatadv.c megazone.c mermaid.c metlclsh.c mexico86.c mikie.c momoko.c mosaic.c mouser.c mrdo.c mrflea.c mrjong.c mugsmash.c munchmo.c nemesis.c news.c nitedrvr.c nycaptor.c ohmygod.c ojankohs.c oneshot.c orbit.c othldrby.c pktgaldx.c rohga.c simpl156.c skyfox.c snes.c st0016.c supbtime.c tumbleb.c tumblep.c vaportra.c
[src/mess]mess.mak
[src/osd/sdl]gl_shader_mgr.c input.c main.c output.c sdlmisc_os2.c sdlsync_tc.c strconv.h video.c video.h
[src/osd/windows]input.c winmisc.c wintime.c
[src/tools]unidasm.c

src/mame/audio/micro3d.c
r7500r7501
214214{
215215   assert(device != NULL);
216216   assert(device->token != NULL);
217   assert(device->type == SOUND_MICRO3D);
217   assert(device->type == SOUND);
218   assert(sound_get_type(device) == SOUND_MICRO3D);
218219
219220   return (noise_state *)device->token;
220221}
src/mame/audio/senjyo.c
r7500r7501
1010static INT16 *_single;
1111static int single_rate = 0;
1212static int single_volume = 0;
13UINT8 senjyo_sound_cmd;
1314
14
1515const z80_daisy_chain senjyo_daisy_chain[] =
1616{
1717   { "z80ctc" },
r7500r7501
2222
2323/* z80 pio */
2424
25const z80pio_interface senjyo_pio_intf =
25READ8_DEVICE_HANDLER( pio_pa_r )
2626{
27   return senjyo_sound_cmd;
28}
29
30Z80PIO_INTERFACE( senjyo_pio_intf )
31{
2732   DEVCB_CPU_INPUT_LINE("sub", INPUT_LINE_IRQ0),
33   DEVCB_HANDLER(pio_pa_r),
2834   DEVCB_NULL,
2935   DEVCB_NULL,
3036   DEVCB_NULL,
3137   DEVCB_NULL,
32   DEVCB_NULL,
3338   DEVCB_NULL
3439};
3540
src/mame/machine/nycaptor.c
r7500r7501
1010#include "emu.h"
1111#include "includes/nycaptor.h"
1212
13static UINT8 from_main,from_mcu;
14static int mcu_sent = 0,main_sent = 0;
15
16
17static UINT8 portA_in,portA_out,ddrA;
18
19READ8_HANDLER( nycaptor_68705_portA_r )
13READ8_HANDLER( nycaptor_68705_port_a_r )
2014{
21
22   return (portA_out & ddrA) | (portA_in & ~ddrA);
15   nycaptor_state *state = (nycaptor_state *)space->machine->driver_data;
16   return (state->port_a_out & state->ddr_a) | (state->port_a_in & ~state->ddr_a);
2317}
2418
25WRITE8_HANDLER( nycaptor_68705_portA_w )
19WRITE8_HANDLER( nycaptor_68705_port_a_w )
2620{
27
28   portA_out = data;
21   nycaptor_state *state = (nycaptor_state *)space->machine->driver_data;
22   state->port_a_out = data;
2923}
3024
31WRITE8_HANDLER( nycaptor_68705_ddrA_w )
25WRITE8_HANDLER( nycaptor_68705_ddr_a_w )
3226{
33   ddrA = data;
27   nycaptor_state *state = (nycaptor_state *)space->machine->driver_data;
28   state->ddr_a = data;
3429}
3530
3631/*
r7500r7501
4237 *  2   W  when 0->1, copies port A to the latch for the main CPU
4338 */
4439
45static UINT8 portB_in,portB_out,ddrB;
46
47READ8_HANDLER( nycaptor_68705_portB_r )
40READ8_HANDLER( nycaptor_68705_port_b_r )
4841{
49   return (portB_out & ddrB) | (portB_in & ~ddrB);
42   nycaptor_state *state = (nycaptor_state *)space->machine->driver_data;
43   return (state->port_b_out & state->ddr_b) | (state->port_b_in & ~state->ddr_b);
5044}
5145
52WRITE8_HANDLER( nycaptor_68705_portB_w )
46WRITE8_HANDLER( nycaptor_68705_port_b_w )
5347{
48   nycaptor_state *state = (nycaptor_state *)space->machine->driver_data;
5449
55
56   if ((ddrB & 0x02) && (~data & 0x02) && (portB_out & 0x02))
50   if (BIT(state->ddr_b, 1) && BIT(~data, 1) && BIT(state->port_b_out, 1))
5751   {
58      portA_in = from_main;
59      if (main_sent) cputag_set_input_line(space->machine, "mcu", 0, CLEAR_LINE);
60      main_sent = 0;
52      state->port_a_in = state->from_main;
6153
54      if (state->main_sent)
55         cpu_set_input_line(state->mcu, 0, CLEAR_LINE);
56      state->main_sent = 0;
57
6258   }
63   if ((ddrB & 0x04) && (data & 0x04) && (~portB_out & 0x04))
59
60   if (BIT(state->ddr_b, 2) && BIT(data, 2) && BIT(~state->port_b_out, 2))
6461   {
65
66      from_mcu = portA_out;
67      mcu_sent = 1;
62      state->from_mcu = state->port_a_out;
63      state->mcu_sent = 1;
6864   }
6965
70   portB_out = data;
66   state->port_b_out = data;
7167}
7268
73WRITE8_HANDLER( nycaptor_68705_ddrB_w )
69WRITE8_HANDLER( nycaptor_68705_ddr_b_w )
7470{
75   ddrB = data;
71   nycaptor_state *state = (nycaptor_state *)space->machine->driver_data;
72   state->ddr_b = data;
7673}
7774
7875
79static UINT8 portC_in,portC_out,ddrC;
80
81READ8_HANDLER( nycaptor_68705_portC_r )
76READ8_HANDLER( nycaptor_68705_port_c_r )
8277{
83   portC_in = 0;
84   if (main_sent) portC_in |= 0x01;
85   if (!mcu_sent) portC_in |= 0x02;
78   nycaptor_state *state = (nycaptor_state *)space->machine->driver_data;
79   state->port_c_in = 0;
8680
87   return (portC_out & ddrC) | (portC_in & ~ddrC);
81   if (state->main_sent)
82      state->port_c_in |= 0x01;
83   if (!state->mcu_sent)
84      state->port_c_in |= 0x02;
85
86   return (state->port_c_out & state->ddr_c) | (state->port_c_in & ~state->ddr_c);
8887}
8988
90WRITE8_HANDLER( nycaptor_68705_portC_w )
89WRITE8_HANDLER( nycaptor_68705_port_c_w )
9190{
92
93   portC_out = data;
91   nycaptor_state *state = (nycaptor_state *)space->machine->driver_data;
92   state->port_c_out = data;
9493}
9594
96WRITE8_HANDLER( nycaptor_68705_ddrC_w )
95WRITE8_HANDLER( nycaptor_68705_ddr_c_w )
9796{
98   ddrC = data;
97   nycaptor_state *state = (nycaptor_state *)space->machine->driver_data;
98   state->ddr_c = data;
9999}
100100
101101WRITE8_HANDLER( nycaptor_mcu_w )
102102{
103   nycaptor_state *state = (nycaptor_state *)space->machine->driver_data;
103104
104   from_main = data;
105   main_sent = 1;
106   cputag_set_input_line(space->machine, "mcu", 0, ASSERT_LINE);
105   state->from_main = data;
106   state->main_sent = 1;
107   cpu_set_input_line(state->mcu, 0, ASSERT_LINE);
107108}
108109
109110READ8_HANDLER( nycaptor_mcu_r )
110111{
112   nycaptor_state *state = (nycaptor_state *)space->machine->driver_data;
111113
112   mcu_sent = 0;
113   return from_mcu;
114   state->mcu_sent = 0;
115   return state->from_mcu;
114116}
115117
116118READ8_HANDLER( nycaptor_mcu_status_r1 )
117119{
120   nycaptor_state *state = (nycaptor_state *)space->machine->driver_data;
121
118122   /* bit 1 = when 1, mcu has sent data to the main cpu */
119
120   return mcu_sent?2:0;
123   return state->mcu_sent ? 2 : 0;
121124}
122125
123126READ8_HANDLER( nycaptor_mcu_status_r2 )
124127{
128   nycaptor_state *state = (nycaptor_state *)space->machine->driver_data;
129
125130   /* bit 0 = when 1, mcu is ready to receive data from main cpu */
126  return main_sent?0:1;
127
131   return state->main_sent ? 0 : 1;
128132}
src/mame/machine/naomi.c
r7500r7501
2222   return naomi_ram64[0x2ad238/8];
2323}
2424
25static UINT8 asciihex_to_dec(UINT8 in)
26{
27   if (in>=0x30 && in<=0x39)
28   {
29      return in - 0x30;
30   }
31   else
32   if (in>=0x41 && in<=0x46)
33   {
34      return in - 0x37;
35   }
36   /*
37    else
38    if (in>=0x61 && in<=0x66)
39    {
40        return in - 0x57;
41    }
42    */
43   else
44   {
45      fatalerror("unexpected value in asciihex_to_dec");
46   }
47
48
49}
50
51// development helper function
52static void create_pic_from_retdat(running_machine* machine)
53{
54   {
55      UINT8* hexregion = memory_region(machine,"pichex");
56      UINT8* retregion = memory_region(machine,"picreturn");
57      UINT8* newregion = memory_region(machine,"pic");
58      int outcount = 0;
59
60      if (hexregion && retregion && newregion)
61      {
62         int hexoffs = 0;
63         int line;
64
65         hexoffs += 0x11; // skip first line  // :020000040000FA
66
67         for (line=0;line<0x200;line++)
68         {
69            int offs2;
70
71            hexoffs+= 0x1; // skip :
72            hexoffs+= 0x8; // skip line #  (:20xxxxxx incrementing in 0x2000)
73
74            for (offs2=0;offs2<0x20;offs2++)
75            {
76               UINT8 ascii1 = hexregion[hexoffs+0];
77               UINT8 ascii2 = hexregion[hexoffs+1];
78               UINT8 dec1 = asciihex_to_dec(ascii1);
79               UINT8 dec2 = asciihex_to_dec(ascii2);
80               UINT8 val = dec1 << 4 | dec2;
81
82               //printf("%02x%02x", ascii1, ascii2);
83
84               printf("%02x", val);
85
86               newregion[outcount] = val;
87
88               hexoffs+=2;
89               outcount++;
90            }
91
92            hexoffs+=0x4; // skip running checksum + newline
93
94            printf("\n");
95
96
97         }
98
99         {
100            int i;
101            printf("string 1 (key1)\n");
102            for (i=0;i<7;i++)
103            {
104               printf("%02x %02x\n", newregion[0x780+i*2], retregion[0x31+i]);
105
106               newregion[0x780+i*2] = retregion[0x31+i]; // patch with extracted data
107            }
108
109            printf("string 2 (key2)\n");
110            for (i=0;i<7;i++)
111            {
112               printf("%02x %02x\n", newregion[0x7a0+i*2], retregion[0x29+i]);
113
114               newregion[0x7a0+i*2] = retregion[0x29+i]; // patch with extracted data
115            }
116
117            printf("string 3 (filename)\n");
118            for (i=0;i<7;i++)
119            {
120               printf("%02x %02x\n", newregion[0x7c0+i*2], retregion[0x21+i]);
121
122               newregion[0x7c0+i*2] = retregion[0x21+i]; // patch with extracted data
123            }
124
125            printf("string 4 (filename?)\n");
126            for (i=0;i<7;i++)
127            {
128               printf("%02x %02x\n", newregion[0x7e0+i*2], retregion[0x19+i]);
129
130               newregion[0x7e0+i*2] = retregion[0x19+i]; // patch with extracted data
131            }
132         }
133
134
135         {
136            FILE *fp;
137            char filename[256];
138            sprintf(filename,"picbin_%s", machine->gamedrv->name);
139            fp=fopen(filename, "w+b");
140            if (fp)
141            {
142               fwrite(newregion, outcount, 1, fp);
143               fclose(fp);
144            }
145
146            printf("wrote %04x bytes\n", outcount);
147         }
148
149         // hex dumps end with
150         //:10400000000000000000000000000000000082002E
151         //:00000001FF
152
153
154      }
155   }
156}
157
25158DRIVER_INIT(naomi)
26159{
27160   memory_install_read64_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0xc2ad238, 0xc2ad23f, 0, 0, naomi_bios_idle_skip_r); // rev e bios
28161   jvsboard_type = JVSBD_DEFAULT;
29162   actel_id = 0xffff;
163
164   create_pic_from_retdat(machine);
30165}
31166
167DRIVER_INIT(naomi2)
168{
169   jvsboard_type = JVSBD_DEFAULT;
170   actel_id = 0xffff;
171
172   create_pic_from_retdat(machine);
173}
174
32175DRIVER_INIT(naomi_mp)
33176{
34177   memory_install_read64_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0xc2ad238, 0xc2ad23f, 0, 0, naomi_bios_idle_skip_r); // rev e bios
35178   jvsboard_type = JVSBD_MAHJONG;
36179   actel_id = 0xffff;
180
181   create_pic_from_retdat(machine);
37182}
38183
39184static READ64_HANDLER( naomigd_ggxxsla_idle_skip_r )
r7500r7501
102247
103248DRIVER_INIT( vf4evoct )
104249{
105//  DRIVER_INIT_CALL(naomi2);
250   DRIVER_INIT_CALL(naomi2);
106251   actel_id = 0; //FIXME: correct value
107252}
src/mame/machine/decocass.h
r7500r7501
1515
1616
1717
18typedef struct _decocass_state decocass_state;
19struct _decocass_state
18class decocass_state
2019{
20public:
21   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, decocass_state(machine)); }
22
23   decocass_state(running_machine &machine) { }
24
2125   /* memory pointers */
2226   UINT8 *   rambase;
2327   UINT8 *   charram;
src/mame/machine/daikaiju.c
r7500r7501
110110#define MCU_CONTROLS1 0x36
111111#define MCU_MESSAGE   0x40
112112#define MCU_CONTROLS2 0x44
113#define MCU_ID            0x60
113#define MCU_ID        0x60
114114
115115#define MCU_ADDRESS1_LENGTH  2
116116#define MCU_ADDRESS2_LENGTH  2
117117#define MCU_CONTROLS1_LENGTH 2
118118#define MCU_MESSAGE_LENGTH   3
119119#define MCU_CONTROLS2_LENGTH 3
120#define MCU_ID_LENGTH            0
120#define MCU_ID_LENGTH        0
121121
122#define SET_COMMAND(n)   daikaiju_command=data; \
123         daikaiju_length=n;\
124         daikaiju_cnt=0;\
125         daikaiju_cntr=0;
122#define SET_COMMAND(n)   state->daikaiju_command = data; \
123         state->daikaiju_length = n;\
124         state->daikaiju_cnt = 0;\
125         state->daikaiju_cntr = 0;
126126
127127
128static int daikaiju_xor, daikaiju_command, daikaiju_length, daikaiju_prev, daikaiju_cnt, daikaiju_cntr;
129
130static int daikaiju_buffer[256];
131
132128static const int xortable[]=
133129{
134130 0xF5, 0xD5, 0x6A, 0x26, 0x00, 0x29, 0x29, 0x29, 0x29, 0x29, 0x29, 0x16, 0x00, 0xCB, 0x23, 0x19,
135131 0x11, 0x00, 0xC0, 0x19, 0xD1, 0xF1, 0xC9, -1
136132};
137133
138MACHINE_RESET(daikaiju)
139{
140   daikaiju_xor=-1;
141   daikaiju_command=0;
142   daikaiju_length=0;
143}
144
145134WRITE8_HANDLER( daikaiju_mcu_w )
146135{
147  if(daikaiju_xor <0)
136   lsasquad_state *state = (lsasquad_state *)space->machine->driver_data;
137
138   if (state->daikaiju_xor < 0)
148139   {
149140      //reset
150      daikaiju_xor=0;
151      data^=0xc3;
141      state->daikaiju_xor = 0;
142      data ^= 0xc3;
152143   }
153144   else
154145   {
155      data^=xortable[daikaiju_xor];
146      data ^= xortable[state->daikaiju_xor];
156147      //check for end of table
157      if(xortable[++daikaiju_xor]<0)
148      if (xortable[++state->daikaiju_xor] < 0)
158149      {
159         daikaiju_xor=0;
150         state->daikaiju_xor = 0;
160151      }
161152   }
162   daikaiju_prev=data;
153   state->daikaiju_prev = data;
163154
164   if(daikaiju_length == 0) //new command
155   if (state->daikaiju_length == 0) //new command
165156   {
166157      switch(data)
167158      {
r7500r7501
172163         case MCU_CONTROLS1: SET_COMMAND(MCU_CONTROLS1_LENGTH); break;
173164         case MCU_MESSAGE:   SET_COMMAND(MCU_MESSAGE_LENGTH); break;
174165         case MCU_CONTROLS2: SET_COMMAND(MCU_CONTROLS2_LENGTH); break;
175         case MCU_ID:            SET_COMMAND(MCU_ID_LENGTH); break;
166         case MCU_ID:         SET_COMMAND(MCU_ID_LENGTH); break;
176167         default:
177            daikaiju_command=data;
168            state->daikaiju_command = data;
178169            logerror("Unknown MCU command W %x %x \n",data,cpu_get_pc(space->cpu));
179170      }
180171   }
181172   else
182173   {
183      --daikaiju_length;
184      daikaiju_buffer[daikaiju_cnt++]=data;
174      --state->daikaiju_length;
175      state->daikaiju_buffer[state->daikaiju_cnt++] = data;
185176   }
186177}
187178
188179READ8_HANDLER( daikaiju_mcu_r )
189180{
190   switch(daikaiju_command)
181   lsasquad_state *state = (lsasquad_state *)space->machine->driver_data;
182
183   switch (state->daikaiju_command)
191184   {
192185      case MCU_ID:
193186         return ID_DAIKAIJU;
r7500r7501
195188      case MCU_CONTROLS1:
196189      {
197190         int n;
198         switch( (daikaiju_buffer[0]&0xf)^0xf)
191         switch ((state->daikaiju_buffer[0] & 0xf) ^ 0xf)
199192         {
200            case 0x00:   n = (daikaiju_buffer[1]&(~8))&0xf; break;
193            case 0x00:   n = (state->daikaiju_buffer[1] & (~8)) & 0xf; break;
201194            case 0x08:   n = 0 | 8; break;
202195            case 0x0a:   n = 1 | 8; break;
203196            case 0x02:   n = 2 | 8; break;
r7500r7501
210203            default:      n = 0; break;
211204         }
212205
213         if( !(daikaiju_buffer[0]&0x10) ) //button 1 pressed
206         if (!(state->daikaiju_buffer[0] & 0x10)) //button 1 pressed
214207         {
215            if(daikaiju_buffer[1]&0x10) //previous status
208            if (state->daikaiju_buffer[1] & 0x10) //previous status
216209            {
217               n|=0x40;   // button 0->1
210               n |= 0x40;   // button 0->1
218211            }
219212            else
220213            {
221               n|=0; //button 1->1
214               n |= 0; //button 1->1
222215            }
223216         }
224217         else
225218         {
226            if(daikaiju_buffer[1]&0x10) //previous status
219            if (state->daikaiju_buffer[1] & 0x10) //previous status
227220            {
228               n|=0x40+0x10;   // button 0->0
221               n |= 0x40 + 0x10;   // button 0->0
229222            }
230223            else
231224            {
232               n|=0x10; //button 1->0
225               n |= 0x10; //button 1->0
233226            }
234227         }
235228
236         if( !(daikaiju_buffer[0]&0x20) ) //button 2 pressed
229         if (!(state->daikaiju_buffer[0] & 0x20)) //button 2 pressed
237230         {
238            if(daikaiju_buffer[1]&0x20) //previous status
231            if (state->daikaiju_buffer[1] & 0x20) //previous status
239232            {
240               n|=0x80;   // button 0->1
233               n |= 0x80;   // button 0->1
241234            }
242235            else
243236            {
244               n|=0; //button 1->1
237               n |= 0; //button 1->1
245238            }
246239         }
247240         else
248241         {
249            if(daikaiju_buffer[1]&0x20) //previous status
242            if (state->daikaiju_buffer[1] & 0x20) //previous status
250243            {
251               n|=0x80+0x20;   // button 0->0
244               n |= 0x80 + 0x20;   // button 0->0
252245            }
253246            else
254247            {
255               n|=0x20; //button 1->0
248               n |= 0x20; //button 1->0
256249            }
257250         }
258251         return n;
r7500r7501
260253
261254      case MCU_ADDRESS1:
262255      {
263         int address=daikaiju_buffer[1]*2+64*daikaiju_buffer[0];
256         int address = state->daikaiju_buffer[1] * 2 + 64 * state->daikaiju_buffer[0];
264257
265         address&=0x0fff; // ?
266         address+=0xd000;
258         address &= 0x0fff; // ?
259         address += 0xd000;
267260
268         if(daikaiju_cntr==0)
261         if (state->daikaiju_cntr == 0)
269262         {
270            daikaiju_cntr++;
271            return address&0xff;
263            state->daikaiju_cntr++;
264            return address & 0xff;
272265         }
273266         else
274267         {
275            return address>>8;
268            return address >> 8;
276269         }
277270      }
278271
279272      case MCU_ADDRESS2:
280273      {
281         int address=daikaiju_buffer[1]*2+64*daikaiju_buffer[0];
274         int address = state->daikaiju_buffer[1] * 2 + 64 * state->daikaiju_buffer[0];
282275
283         address&=0x1fff; // ?
284         address+=0xc000;
276         address &= 0x1fff; // ?
277         address += 0xc000;
285278
286         if(daikaiju_cntr==0)
279         if (state->daikaiju_cntr == 0)
287280         {
288            daikaiju_cntr++;
289            return address&0xff;
281            state->daikaiju_cntr++;
282            return address & 0xff;
290283         }
291284         else
292285         {
293            return address>>8;
286            return address >> 8;
294287         }
295288      }
296289
297290      case MCU_MESSAGE:
298         return daikaiju_buffer[1];
291         return state->daikaiju_buffer[1];
299292
300293      case MCU_CONTROLS2:
301294      {
302295         int n;
303         int dest=(daikaiju_buffer[0]&0x7)<<1;
304         int prev=(daikaiju_buffer[1]&0xf);
296         int dest = (state->daikaiju_buffer[0] & 0x7) << 1;
297         int prev = (state->daikaiju_buffer[1] & 0xf);
305298
306         if(daikaiju_buffer[2]==2)
299         if (state->daikaiju_buffer[2] == 2)
307300         {
308            prev&=0xfe;
301            prev &= 0xfe;
309302         }
310         if(prev!=dest)
303
304         if (prev != dest)
311305         {
312            int diff=(dest-prev);
306            int diff = (dest - prev);
313307
314            if((diff>8 )|| (diff<0 && diff >-8))
308            if ((diff > 8)|| (diff < 0 && diff > -8))
315309            {
316               n=(prev-daikaiju_buffer[2])&0xf;
310               n = (prev - state->daikaiju_buffer[2]) & 0xf;
317311            }
318312            else
319313            {
320               n=(prev+daikaiju_buffer[2])&0xf;
314               n = (prev + state->daikaiju_buffer[2]) & 0xf;
321315            }
322316         }
323317         else
324318         {
325            n=prev;
319            n = prev;
326320         }
327         prev&=0xf;
328         if(prev!=n)
321         prev &= 0xf;
322
323         if (prev != n)
329324         {
330            n|=0x10;
325            n |= 0x10;
331326         }
332327         return n;
333328      }
334329   }
335   logerror("Unknown MCU R %x %x %x %x\n",cpu_get_pc(space->cpu), daikaiju_command, daikaiju_length, daikaiju_prev);
330   logerror("Unknown MCU R %x %x %x %x\n", cpu_get_pc(space->cpu), state->daikaiju_command, state->daikaiju_length, state->daikaiju_prev);
336331   return 0xff;
337332}
338333
339334READ8_HANDLER( daikaiju_mcu_status_r )
340335{
336   lsasquad_state *state = (lsasquad_state *)space->machine->driver_data;
341337   int res = input_port_read(space->machine, "MCU?");
342338
343   res^=mame_rand(space->machine)&3;
344   res |=((lsasquad_sound_pending & 0x02)^2)<<3; //inverted flag
345   lsasquad_sound_pending &= ~0x02;
339   res ^= mame_rand(space->machine) & 3;
340   res |= ((state->sound_pending & 0x02) ^ 2) << 3; //inverted flag
341   state->sound_pending &= ~0x02;
346342   return res;
347343}
348
src/mame/machine/namco53.c
r7500r7501
188188   devcb_resolve_read8(&state->in[2], &config->in[2], device);
189189   devcb_resolve_read8(&state->in[3], &config->in[3], device);
190190   devcb_resolve_write8(&state->p, &config->p, device);
191
192   state_save_register_device_item(device, 0, state->portO);
191193}
192194
193195
src/mame/machine/mexico86.c
r7500r7501
22#include "deprecat.h"
33#include "includes/mexico86.h"
44
5
6UINT8 *mexico86_protection_ram;
7
8
9static int kikikai_mcu_running, kikikai_mcu_initialised;
10
11
125/*
136$f008 - write
147bit 7 = ? (unused?)
r7500r7501
2215*/
2316WRITE8_HANDLER( mexico86_f008_w )
2417{
25   cputag_set_input_line(space->machine, "audiocpu", INPUT_LINE_RESET, (data & 4) ? CLEAR_LINE : ASSERT_LINE);
26   if (devtag_get_device(space->machine, "mcu") != NULL)
18   mexico86_state *state = (mexico86_state *)space->machine->driver_data;
19
20   cpu_set_input_line(state->audiocpu, INPUT_LINE_RESET, (data & 4) ? CLEAR_LINE : ASSERT_LINE);
21
22   if (state->mcu != NULL)
2723   {
2824      // mexico 86, knight boy
29      cputag_set_input_line(space->machine, "mcu", INPUT_LINE_RESET, (data & 2) ? CLEAR_LINE : ASSERT_LINE);
25      cpu_set_input_line(state->mcu, INPUT_LINE_RESET, (data & 2) ? CLEAR_LINE : ASSERT_LINE);
3026   }
3127   else
3228   {
3329      // simulation for KiKi KaiKai
34      kikikai_mcu_running = data & 2;
35      if (!kikikai_mcu_running)
36         kikikai_mcu_initialised = 0;
30      state->mcu_running = data & 2;
31
32      if (!state->mcu_running)
33         state->mcu_initialised = 0;
3734   }
3835}
3936
r7500r7501
4744
4845***************************************************************************/
4946
50static void mcu_simulate(running_machine *machine)
47static void mcu_simulate( running_machine *machine )
5148{
52   if (!kikikai_mcu_initialised)
49   mexico86_state *state = (mexico86_state *)machine->driver_data;
50
51   if (!state->mcu_initialised)
5352   {
54      if (mexico86_protection_ram[0x01] == 0x00)
53      if (state->protection_ram[0x01] == 0x00)
5554      {
56logerror("initialising MCU\n");
57         mexico86_protection_ram[0x04] = 0xfc;   // coin inputs
58         mexico86_protection_ram[0x02] = 0xff;   // player 1
59         mexico86_protection_ram[0x03] = 0xff;   // player 2
60         mexico86_protection_ram[0x1b] = 0xff;   // active player
61         mexico86_protection_ram[0x06] = 0xff;   // must be FF otherwise PS4 ERROR
62         mexico86_protection_ram[0x07] = 0x03;   // must be 03 otherwise PS4 ERROR
63         mexico86_protection_ram[0x00] = 0x00;
64         kikikai_mcu_initialised = 1;
55         logerror("initialising MCU\n");
56         state->protection_ram[0x04] = 0xfc;   // coin inputs
57         state->protection_ram[0x02] = 0xff;   // player 1
58         state->protection_ram[0x03] = 0xff;   // player 2
59         state->protection_ram[0x1b] = 0xff;   // active player
60         state->protection_ram[0x06] = 0xff;   // must be FF otherwise PS4 ERROR
61         state->protection_ram[0x07] = 0x03;   // must be 03 otherwise PS4 ERROR
62         state->protection_ram[0x00] = 0x00;
63         state->mcu_initialised = 1;
6564      }
6665   }
6766
68   if (kikikai_mcu_initialised)
67   if (state->mcu_initialised)
6968   {
7069      int i;
71      static int coin_last;
7270      int coin_curr;
7371
74
7572      coin_curr = ~input_port_read(machine, "IN0") & 1;
76      if (coin_curr && !coin_last && mexico86_protection_ram[0x01] < 9)
73      if (coin_curr && !state->coin_last && state->protection_ram[0x01] < 9)
7774      {
78         mexico86_protection_ram[0x01]++;   // increase credits counter
79         mexico86_protection_ram[0x0a] = 0x01;   // set flag (coin inserted sound is not played otherwise)
75         state->protection_ram[0x01]++;   // increase credits counter
76         state->protection_ram[0x0a] = 0x01;   // set flag (coin inserted sound is not played otherwise)
8077      }
81      coin_last = coin_curr;
78      state->coin_last = coin_curr;
8279
83      mexico86_protection_ram[0x04] = 0x3c;   // coin inputs
80      state->protection_ram[0x04] = 0x3c;   // coin inputs
8481
85      mexico86_protection_ram[0x02] = BITSWAP8(input_port_read(machine, "IN1"), 7,6,5,4,2,3,1,0);   // player 1
86      mexico86_protection_ram[0x03] = BITSWAP8(input_port_read(machine, "IN2"), 7,6,5,4,2,3,1,0);   // player 2
82      state->protection_ram[0x02] = BITSWAP8(input_port_read(machine, "IN1"), 7,6,5,4,2,3,1,0);   // player 1
83      state->protection_ram[0x03] = BITSWAP8(input_port_read(machine, "IN2"), 7,6,5,4,2,3,1,0);   // player 2
8784
88      if (mexico86_protection_ram[0x19] == 0xaa)   // player 2 active
89         mexico86_protection_ram[0x1b] = mexico86_protection_ram[0x03];
85      if (state->protection_ram[0x19] == 0xaa)   // player 2 active
86         state->protection_ram[0x1b] = state->protection_ram[0x03];
9087      else
91         mexico86_protection_ram[0x1b] = mexico86_protection_ram[0x02];
88         state->protection_ram[0x1b] = state->protection_ram[0x02];
9289
9390
9491      for (i = 0; i < 0x10; i += 2)
95         mexico86_protection_ram[i + 0xb1] = mexico86_protection_ram[i + 0xb0];
92         state->protection_ram[i + 0xb1] = state->protection_ram[i + 0xb0];
9693
9794      for (i = 0; i < 0x0a; i++)
98         mexico86_protection_ram[i + 0xc0] = mexico86_protection_ram[i + 0x90] + 1;
95         state->protection_ram[i + 0xc0] = state->protection_ram[i + 0x90] + 1;
9996
100      if (mexico86_protection_ram[0xd1] == 0xff)
97      if (state->protection_ram[0xd1] == 0xff)
10198      {
102         if (mexico86_protection_ram[0xd0] > 0 && mexico86_protection_ram[0xd0] < 4)
99         if (state->protection_ram[0xd0] > 0 && state->protection_ram[0xd0] < 4)
103100         {
104            mexico86_protection_ram[0xd2] = 0x81;
105            mexico86_protection_ram[0xd0] = 0xff;
101            state->protection_ram[0xd2] = 0x81;
102            state->protection_ram[0xd0] = 0xff;
106103         }
107104      }
108105
109
110      if (mexico86_protection_ram[0xe0] > 0 && mexico86_protection_ram[0xe0] < 4)
106      if (state->protection_ram[0xe0] > 0 && state->protection_ram[0xe0] < 4)
111107      {
112108         static const UINT8 answers[3][16] =
113109         {
r7500r7501
115111            { 0x00,0x04,0x08,0x0C,0x10,0x14,0x18,0x1C,0x20,0x31,0x2B,0x35,0x00,0x00,0x00,0x00 },
116112            { 0x00,0x0C,0x0D,0x0E,0x0F,0x10,0x11,0x12,0x03,0x0A,0x0B,0x14,0x00,0x00,0x00,0x00 },
117113         };
118         int table = mexico86_protection_ram[0xe0] - 1;
114         int table = state->protection_ram[0xe0] - 1;
119115
120116         for (i = 1; i < 0x10; i++)
121            mexico86_protection_ram[0xe0 + i] = answers[table][i];
122         mexico86_protection_ram[0xe0] = 0xff;
117            state->protection_ram[0xe0 + i] = answers[table][i];
118         state->protection_ram[0xe0] = 0xff;
123119      }
124120
125      if (mexico86_protection_ram[0xf0] > 0 && mexico86_protection_ram[0xf0] < 4)
121      if (state->protection_ram[0xf0] > 0 && state->protection_ram[0xf0] < 4)
126122      {
127         mexico86_protection_ram[0xf1] = 0xb3;
128         mexico86_protection_ram[0xf0] = 0xff;
123         state->protection_ram[0xf1] = 0xb3;
124         state->protection_ram[0xf0] = 0xff;
129125      }
130126
131127
r7500r7501
133129      // this should be equivalent to the obfuscated kiki_clogic() below
134130      {
135131         static const UINT8 db[16]={0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x00,0x10,0x18,0x00,0x00,0x00,0x00};
136         UINT16 sy = mexico86_protection_ram[0xa0] + ((0x18)>>1);
137         UINT16 sx = mexico86_protection_ram[0xa1] + ((0x18)>>1);
132         UINT16 sy = state->protection_ram[0xa0] + ((0x18) >> 1);
133         UINT16 sx = state->protection_ram[0xa1] + ((0x18) >> 1);
138134
139135         for (i = 0; i < 0x38; i += 8)
140136         {
141            UINT8 hw = db[mexico86_protection_ram[0x20 + i] & 0xf];
137            UINT8 hw = db[state->protection_ram[0x20 + i] & 0xf];
142138
143139            if (hw)
144140            {
145               UINT16 xdiff = sx - ((UINT16)mexico86_protection_ram[0x20 + i+6] << 8 | mexico86_protection_ram[0x20 + i+7]);
141               UINT16 xdiff = sx - ((UINT16)state->protection_ram[0x20 + i + 6] << 8 | state->protection_ram[0x20 + i + 7]);
146142               if (xdiff < hw)
147143               {
148                  UINT16 ydiff = sy - ((UINT16)mexico86_protection_ram[0x20 + i+4] << 8 | mexico86_protection_ram[0x20 + i+5]);
144                  UINT16 ydiff = sy - ((UINT16)state->protection_ram[0x20 + i + 4] << 8 | state->protection_ram[0x20 + i + 5]);
149145                  if (ydiff < hw)
150                     mexico86_protection_ram[0xa2] = 1; // we have a collision
146                     state->protection_ram[0xa2] = 1; // we have a collision
151147               }
152148            }
153149         }
r7500r7501
158154
159155INTERRUPT_GEN( kikikai_interrupt )
160156{
161   if (kikikai_mcu_running)
157   mexico86_state *state = (mexico86_state *)device->machine->driver_data;
158
159   if (state->mcu_running)
162160      mcu_simulate(device->machine);
163161
164   cpu_set_input_line_vector(device,0,mexico86_protection_ram[0]);
165   cpu_set_input_line(device,0,HOLD_LINE);
162   cpu_set_input_line_vector(device, 0, state->protection_ram[0]);
163   cpu_set_input_line(device, 0, HOLD_LINE);
166164}
167165
168166
r7500r7501
179177#define DCWIDTH 0
180178#define DCHEIGHT 0
181179
182static void kiki_clogic(int address, int latch)
180static void kiki_clogic(running_machine *machine, int address, int latch)
183181{
182   mexico86_state *state = (mexico86_state *)machine->driver_data;
184183   static const UINT8 db[16]={0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x00,0x10,0x18,0x00,0x00,0x00,0x00};
185184   static UINT8 queue[64];
186185   static int qfront = 0, state = 0;
r7500r7501
208207            diff1 = sy - (short)(queue[(qptr+4)&0x3f]<<8|queue[(qptr+5)&0x3f]) + DCHEIGHT;
209208            diff2 = diff1 - (hw + DCHEIGHT);
210209            if ((diff1^diff2)<0)
211               mexico86_protection_ram[KIKI_CL_OUT] = 1; // we have a collision
210               state->protection_ram[KIKI_CL_OUT] = 1; // we have a collision
212211         }
213212      }
214213   }
r7500r7501
229228{
230229   /* I don't know how to handle the interrupt line so I just toggle it every time. */
231230   if (cpu_getiloops(device) & 1)
232      cpu_set_input_line(device,0,CLEAR_LINE);
231      cpu_set_input_line(device, 0, CLEAR_LINE);
233232   else
234      cpu_set_input_line(device,0,ASSERT_LINE);
233      cpu_set_input_line(device, 0, ASSERT_LINE);
235234}
236235
237236
237READ8_HANDLER( mexico86_68705_port_a_r )
238{
239   mexico86_state *state = (mexico86_state *)space->machine->driver_data;
238240
239static UINT8 portA_in,portA_out,ddrA;
241   //logerror("%04x: 68705 port A read %02x\n", cpu_get_pc(space->cpu), state->port_a_in);
242   return (state->port_a_out & state->ddr_a) | (state->port_a_in & ~state->ddr_a);
243}
240244
241READ8_HANDLER( mexico86_68705_portA_r )
245WRITE8_HANDLER( mexico86_68705_port_a_w )
242246{
243//logerror("%04x: 68705 port A read %02x\n",cpu_get_pc(space->cpu),portA_in);
244   return (portA_out & ddrA) | (portA_in & ~ddrA);
245}
247   mexico86_state *state = (mexico86_state *)space->machine->driver_data;
246248
247WRITE8_HANDLER( mexico86_68705_portA_w )
248{
249//logerror("%04x: 68705 port A write %02x\n",cpu_get_pc(space->cpu),data);
250   portA_out = data;
249   //logerror("%04x: 68705 port A write %02x\n", cpu_get_pc(space->cpu), data);
250   state->port_a_out = data;
251251}
252252
253WRITE8_HANDLER( mexico86_68705_ddrA_w )
253WRITE8_HANDLER( mexico86_68705_ddr_a_w )
254254{
255   ddrA = data;
255   mexico86_state *state = (mexico86_state *)space->machine->driver_data;
256   state->ddr_a = data;
256257}
257258
258259
r7500r7501
273274 *  7   W  not used?
274275 */
275276
276static UINT8 portB_in,portB_out,ddrB;
277
278READ8_HANDLER( mexico86_68705_portB_r )
277READ8_HANDLER( mexico86_68705_port_b_r )
279278{
280   return (portB_out & ddrB) | (portB_in & ~ddrB);
279   mexico86_state *state = (mexico86_state *)space->machine->driver_data;
280   return (state->port_b_out & state->ddr_b) | (state->port_b_in & ~state->ddr_b);
281281}
282282
283static int address,latch;
284
285WRITE8_HANDLER( mexico86_68705_portB_w )
283WRITE8_HANDLER( mexico86_68705_port_b_w )
286284{
287//logerror("%04x: 68705 port B write %02x\n",cpu_get_pc(space->cpu),data);
285   mexico86_state *state = (mexico86_state *)space->machine->driver_data;
286   //logerror("%04x: 68705 port B write %02x\n", cpu_get_pc(space->cpu), data);
288287
289   if ((ddrB & 0x01) && (~data & 0x01) && (portB_out & 0x01))
288   if (BIT(state->ddr_b, 0) && BIT(~data, 0) && BIT(state->port_b_out, 0))
290289   {
291      portA_in = latch;
290      state->port_a_in = state->latch;
292291   }
293   if ((ddrB & 0x02) && (data & 0x02) && (~portB_out & 0x02)) /* positive edge trigger */
292
293   if (BIT(state->ddr_b, 1) && BIT(data, 1) && BIT(~state->port_b_out, 1)) /* positive edge trigger */
294294   {
295      address = portA_out;
296//if (address >= 0x80) logerror("%04x: 68705 address %02x\n",cpu_get_pc(space->cpu),portA_out);
295      state->address = state->port_a_out;
296      //if (state->address >= 0x80) logerror("%04x: 68705 address %02x\n", cpu_get_pc(space->cpu), state->port_a_out);
297297   }
298   if ((ddrB & 0x08) && (~data & 0x08) && (portB_out & 0x08))
298
299   if (BIT(state->ddr_b, 3) && BIT(~data, 3) && BIT(state->port_b_out, 3))
299300   {
300301      if (data & 0x10)    /* read */
301302      {
302303         if (data & 0x04)
303304         {
304//logerror("%04x: 68705 read %02x from address %04x\n",cpu_get_pc(space->cpu),shared[0x800+address],address);
305            latch = mexico86_protection_ram[address];
305            //logerror("%04x: 68705 read %02x from address %04x\n", cpu_get_pc(space->cpu), state->protection_ram[state->address], state->address);
306            state->latch = state->protection_ram[state->address];
306307         }
307308         else
308309         {
309//logerror("%04x: 68705 read input port %04x\n",cpu_get_pc(space->cpu),address);
310            latch = input_port_read(space->machine, (address & 1) ? "IN2" : "IN1");
310            //logerror("%04x: 68705 read input port %04x\n", cpu_get_pc(space->cpu), state->address);
311            state->latch = input_port_read(space->machine, (state->address & 1) ? "IN2" : "IN1");
311312         }
312313      }
313314      else    /* write */
314315      {
315//logerror("%04x: 68705 write %02x to address %04x\n",cpu_get_pc(space->cpu),portA_out,address);
316            mexico86_protection_ram[address] = portA_out;
316            //logerror("%04x: 68705 write %02x to address %04x\n",cpu_get_pc(space->cpu), port_a_out, state->address);
317            state->protection_ram[state->address] = state->port_a_out;
317318      }
318319   }
319   if ((ddrB & 0x20) && (data & 0x20) && (~portB_out & 0x20))
320
321   if (BIT(state->ddr_b, 5) && BIT(data, 5) && BIT(~state->port_b_out, 5))
320322   {
321      cpu_set_input_line_vector(devtag_get_device(space->machine, "maincpu"), 0, mexico86_protection_ram[0]);
322      cputag_set_input_line(space->machine, "maincpu", 0, HOLD_LINE); //AT: HOLD_LINE works better in Z80 interrupt mode 1.
323      cpu_set_input_line_vector(state->maincpu, 0, state->protection_ram[0]);
324      cpu_set_input_line(state->maincpu, 0, HOLD_LINE);        //AT: HOLD_LINE works better in Z80 interrupt mode 1.
323325   }
324   if ((ddrB & 0x40) && (~data & 0x40) && (portB_out & 0x40))
326
327   if (BIT(state->ddr_b, 6) && BIT(~data, 6) && BIT(state->port_b_out, 6))
325328   {
326logerror("%04x: 68705 unknown port B bit %02x\n",cpu_get_pc(space->cpu),data);
329      logerror("%04x: 68705 unknown port B bit %02x\n", cpu_get_pc(space->cpu), data);
327330   }
328   if ((ddrB & 0x80) && (~data & 0x80) && (portB_out & 0x80))
331
332   if (BIT(state->ddr_b, 7) && BIT(~data, 7) && BIT(state->port_b_out, 7))
329333   {
330logerror("%04x: 68705 unknown port B bit %02x\n",cpu_get_pc(space->cpu),data);
334      logerror("%04x: 68705 unknown port B bit %02x\n", cpu_get_pc(space->cpu), data);
331335   }
332336
333   portB_out = data;
337   state->port_b_out = data;
334338}
335339
336WRITE8_HANDLER( mexico86_68705_ddrB_w )
340WRITE8_HANDLER( mexico86_68705_ddr_b_w )
337341{
338   ddrB = data;
342   mexico86_state *state = (mexico86_state *)space->machine->driver_data;
343   state->ddr_b = data;
339344}
src/mame/machine/snes.c
r7500r7501
295295   timer_adjust_oneshot(snes_scanline_timer, video_screen_get_time_until_pos(machine->primary_screen, nextscan, 0), 0);
296296}
297297
298/* FIXME: multiplication should take 8 CPU cycles & division 16 CPU cycles, but
299using these timers breaks e.g. Chrono Trigger intro and Super Tennis gameplay.
298/* FIXME: multiplication should take 8 CPU cycles & division 16 CPU cycles, but
299using these timers breaks e.g. Chrono Trigger intro and Super Tennis gameplay.
300300On the other hand, timers are needed for the translation of Breath of Fire 2
301301to work. More weirdness: we might need to leave 8 CPU cycles for division at
302302first, since using 16 produces bugs (see e.g. Triforce pieces in Zelda 3 intro) */
r7500r7501
13291329         break;
13301330      case WRMPYB:   /* Multiplier B */
13311331         snes_ram[WRMPYB] = data;
1332//         timer_adjust_oneshot(snes_mult_timer, cputag_clocks_to_attotime(space->machine, "maincpu", 8), 0);
1332//          timer_adjust_oneshot(snes_mult_timer, cputag_clocks_to_attotime(space->machine, "maincpu", 8), 0);
13331333         {
13341334            UINT32 c = snes_ram[WRMPYA] * snes_ram[WRMPYB];
13351335            snes_ram[RDMPYL] = c & 0xff;
r7500r7501
13411341         break;
13421342      case WRDVDD:   /* Divisor */
13431343         snes_ram[WRDVDD] = data;
1344//         timer_adjust_oneshot(snes_div_timer, cputag_clocks_to_attotime(space->machine, "maincpu", 16), 0);
1344//          timer_adjust_oneshot(snes_div_timer, cputag_clocks_to_attotime(space->machine, "maincpu", 16), 0);
13451345         {
13461346            UINT16 value, dividend, remainder;
13471347            dividend = remainder = 0;
src/mame/machine/lkage.c
r7500r7501
1111#include "includes/lkage.h"
1212
1313
14static UINT8 from_main,from_mcu;
15static int mcu_sent = 0,main_sent = 0;
16
17
1814/***************************************************************************
1915
2016 Legend of Kage 68705 protection interface
r7500r7501
2420
2521***************************************************************************/
2622
27static UINT8 portA_in,portA_out,ddrA;
23READ8_HANDLER( lkage_68705_port_a_r )
24{
25   lkage_state *state = (lkage_state *)space->machine->driver_data;
2826
29READ8_HANDLER( lkage_68705_portA_r )
30{
31//logerror("%04x: 68705 port A read %02x\n",cpu_get_pc(space->cpu),portA_in);
32   return (portA_out & ddrA) | (portA_in & ~ddrA);
27   //logerror("%04x: 68705 port A read %02x\n", cpu_get_pc(space->cpu), state->port_a_in);
28   return (state->port_a_out & state->ddr_a) | (state->port_a_in & ~state->ddr_a);
3329}
3430
35WRITE8_HANDLER( lkage_68705_portA_w )
31WRITE8_HANDLER( lkage_68705_port_a_w )
3632{
37//logerror("%04x: 68705 port A write %02x\n",cpu_get_pc(space->cpu),data);
38   portA_out = data;
33   lkage_state *state = (lkage_state *)space->machine->driver_data;
34
35   //logerror("%04x: 68705 port A write %02x\n", cpu_get_pc(space->cpu), data);
36   state->port_a_out = data;
3937}
4038
41WRITE8_HANDLER( lkage_68705_ddrA_w )
39WRITE8_HANDLER( lkage_68705_ddr_a_w )
4240{
43   ddrA = data;
41   lkage_state *state = (lkage_state *)space->machine->driver_data;
42   state->ddr_a = data;
4443}
4544
4645
r7500r7501
5453 *  2   W  when 0->1, copies port A to the latch for the main CPU
5554 */
5655
57static UINT8 portB_in,portB_out,ddrB;
58
59READ8_HANDLER( lkage_68705_portB_r )
56READ8_HANDLER( lkage_68705_port_b_r )
6057{
61   return (portB_out & ddrB) | (portB_in & ~ddrB);
58   lkage_state *state = (lkage_state *)space->machine->driver_data;
59   return (state->port_b_out & state->ddr_b) | (state->port_b_in & ~state->ddr_b);
6260}
6361
64WRITE8_HANDLER( lkage_68705_portB_w )
62WRITE8_HANDLER( lkage_68705_port_b_w )
6563{
66//logerror("%04x: 68705 port B write %02x\n",cpu_get_pc(space->cpu),data);
64   lkage_state *state = (lkage_state *)space->machine->driver_data;
6765
68   if ((ddrB & 0x02) && (~data & 0x02) && (portB_out & 0x02))
66   //logerror("%04x: 68705 port B write %02x\n", cpu_get_pc(space->cpu), data);
67
68   if ((state->ddr_b & 0x02) && (~data & 0x02) && (state->port_b_out & 0x02))
6969   {
70      portA_in = from_main;
71      if (main_sent) cputag_set_input_line(space->machine, "mcu", 0, CLEAR_LINE);
72      main_sent = 0;
73logerror("read command %02x from main cpu\n",portA_in);
70      state->port_a_in = state->from_main;
71      if (state->main_sent)
72         cpu_set_input_line(state->mcu, 0, CLEAR_LINE);
73
74      state->main_sent = 0;
75      logerror("read command %02x from main cpu\n", state->port_a_in);
7476   }
75   if ((ddrB & 0x04) && (data & 0x04) && (~portB_out & 0x04))
77
78   if ((state->ddr_b & 0x04) && (data & 0x04) && (~state->port_b_out & 0x04))
7679   {
77logerror("send command %02x to main cpu\n",portA_out);
78      from_mcu = portA_out;
79      mcu_sent = 1;
80      logerror("send command %02x to main cpu\n", state->port_a_out);
81      state->from_mcu = state->port_a_out;
82      state->mcu_sent = 1;
8083   }
8184
82   portB_out = data;
85   state->port_b_out = data;
8386}
8487
85WRITE8_HANDLER( lkage_68705_ddrB_w )
88WRITE8_HANDLER( lkage_68705_ddr_b_w )
8689{
87   ddrB = data;
90   lkage_state *state = (lkage_state *)space->machine->driver_data;
91   state->ddr_b = data;
8892}
8993
9094
91static UINT8 portC_in,portC_out,ddrC;
9295
93READ8_HANDLER( lkage_68705_portC_r )
96READ8_HANDLER( lkage_68705_port_c_r )
9497{
95   portC_in = 0;
96   if (main_sent) portC_in |= 0x01;
97   if (!mcu_sent) portC_in |= 0x02;
98//logerror("%04x: 68705 port C read %02x\n",cpu_get_pc(space->cpu),portC_in);
99   return (portC_out & ddrC) | (portC_in & ~ddrC);
98   lkage_state *state = (lkage_state *)space->machine->driver_data;
99
100   state->port_c_in = 0;
101   if (state->main_sent)
102      state->port_c_in |= 0x01;
103   if (!state->mcu_sent)
104      state->port_c_in |= 0x02;
105
106   //logerror("%04x: 68705 port C read %02x\n", cpu_get_pc(space->cpu), state->port_c_in);
107   return (state->port_c_out & state->ddr_c) | (state->port_c_in & ~state->ddr_c);
100108}
101109
102WRITE8_HANDLER( lkage_68705_portC_w )
110WRITE8_HANDLER( lkage_68705_port_c_w )
103111{
104logerror("%04x: 68705 port C write %02x\n",cpu_get_pc(space->cpu),data);
105   portC_out = data;
112   lkage_state *state = (lkage_state *)space->machine->driver_data;
113
114   logerror("%04x: 68705 port C write %02x\n", cpu_get_pc(space->cpu), data);
115   state->port_c_out = data;
106116}
107117
108WRITE8_HANDLER( lkage_68705_ddrC_w )
118WRITE8_HANDLER( lkage_68705_ddr_c_w )
109119{
110   ddrC = data;
120   lkage_state *state = (lkage_state *)space->machine->driver_data;
121   state->ddr_c = data;
111122}
112123
113124
114125WRITE8_HANDLER( lkage_mcu_w )
115126{
116logerror("%04x: mcu_w %02x\n",cpu_get_pc(space->cpu),data);
117   from_main = data;
118   main_sent = 1;
119   cputag_set_input_line(space->machine, "mcu", 0, ASSERT_LINE);
127   lkage_state *state = (lkage_state *)space->machine->driver_data;
128
129   logerror("%04x: mcu_w %02x\n", cpu_get_pc(space->cpu), data);
130   state->from_main = data;
131   state->main_sent = 1;
132   cpu_set_input_line(state->mcu, 0, ASSERT_LINE);
120133}
121134
122135READ8_HANDLER( lkage_mcu_r )
123136{
124logerror("%04x: mcu_r %02x\n",cpu_get_pc(space->cpu),from_mcu);
125   mcu_sent = 0;
126   return from_mcu;
137   lkage_state *state = (lkage_state *)space->machine->driver_data;
138
139   logerror("%04x: mcu_r %02x\n", cpu_get_pc(space->cpu), state->from_mcu);
140   state->mcu_sent = 0;
141   return state->from_mcu;
127142}
128143
129144READ8_HANDLER( lkage_mcu_status_r )
130145{
146   lkage_state *state = (lkage_state *)space->machine->driver_data;
131147   int res = 0;
132148
133149   /* bit 0 = when 1, mcu is ready to receive data from main cpu */
134150   /* bit 1 = when 1, mcu has sent data to the main cpu */
135//logerror("%04x: mcu_status_r\n",cpu_get_pc(space->cpu));
136   if (!main_sent) res |= 0x01;
137   if (mcu_sent) res |= 0x02;
151   //logerror("%04x: mcu_status_r\n", cpu_get_pc(space->cpu));
152   if (!state->main_sent)
153      res |= 0x01;
154   if (state->mcu_sent)
155      res |= 0x02;
138156
139157   return res;
140158}
src/mame/machine/namco50.c
r7500r7501
286286   /* find our CPU */
287287   state->cpu = device->subdevice("mcu");
288288   assert(state->cpu != NULL);
289
290   state_save_register_device_item(device, 0, state->latched_cmd);
291   state_save_register_device_item(device, 0, state->latched_rw);
292   state_save_register_device_item(device, 0, state->portO);
289293}
290294
291295
src/mame/machine/naomibd.c
r7500r7501
196196{
197197   const char *name;
198198   int reverse_bytes;
199   int live_key;
199200   UINT32   transtbl[MAX_PROT_REGIONS*3];
200201};
201202
r7500r7501
219220
220221   const UINT32         *prot_translate;
221222   int            prot_reverse_bytes;
223
224   // live decrypt vars
225   UINT32            dc_gamekey, dc_seqkey, dc_seed;
226   UINT8            dc_cart_ram[128*1024];   // internal cartridge RAM
227   INT32            dc_m3_ptr, dc_m2_ptr, dc_readback;
228
222229   #if NAOMIBD_PRINTF_PROTECTION
223230   int            prot_pio_count;
224231   #endif
r7500r7501
229236// if key is not -1, it's used for the match instead of the address written.
230237static const naomibd_config_table naomibd_translate_tbl[] =
231238{
232   { "doa2", 0, { -1, 0x500, 0, -1, 0x20504, 0x20000, -1, 0x40508, 0x40000, -1, 0x6050c, 0x60000, -1, 0x80510, 0x80000,
239   // games where on-the-fly decryption works (many of these are fully playable in MAME, just slow)
240   { "18wheelr", 0, 0x7cf54, { 0x1502, 0, 0, 0xffffffff, 0xffffffff, 0xffffffff } },
241   { "alpilota", 0, 0x70e41, { 0, 0, 0, 0xffffffff, 0xffffffff, 0xffffffff } },
242   { "alpiltdx", 0, 0x70e41, { 0, 0, 0, 0xffffffff, 0xffffffff, 0xffffffff } },
243   { "capsnk", 0, 0, { 0, 0, 0, 0xffffffff, 0xffffffff, 0xffffffff } },
244   { "capsnka", 0, 0, { 0, 0, 0, 0xffffffff, 0xffffffff, 0xffffffff } },
245   { "crzytaxi", 0, 0xd2f45, { 0, 0, 0, 0xffffffff, 0xffffffff, 0xffffffff } },
246   { "csmash", 1, 0x03347, { 0, 0, 0, 0xffffffff, 0xffffffff, 0xffffffff } },
247   { "csmasho", 1, 0x03347, { 0, 0, 0, 0xffffffff, 0xffffffff, 0xffffffff } },
248   { "cspike", 0, 0xe2010, { 0, 0, 0, 0xffffffff, 0xffffffff, 0xffffffff } },
249   { "deathcox", 0, 0xb64d0, { 0, 0, 0, 0xffffffff, 0xffffffff, 0xffffffff } },
250   { "dybb99", 0, 0x48a01, { 0, 0, 0, 0xffffffff, 0xffffffff, 0xffffffff } },
251   { "f355twin", 0, 0x6efd4, { 0, 0, 0, 0xffffffff, 0xffffffff, 0xffffffff } },
252   { "f355twn2", 0, 0x666c6, { 0, 0, 0, 0xffffffff, 0xffffffff, 0xffffffff } },
253   { "ggram2", 0, 0x74a61, { 0, 0, 0, 0xffffffff, 0xffffffff, 0xffffffff } },
254   { "gwing2",  0, 0xb25d0, { 0, 0, 0, 0xffffffff, 0xffffffff, 0xffffffff } },
255   { "hmgeo",   0, 0x38510, { 0, 0, 0, 0xffffffff, 0xffffffff, 0xffffffff } },
256   { "jambo",    0, 0xfab95, { 0, 0, 0, 0xffffffff, 0xffffffff, 0xffffffff } },
257   { "otrigger", 0, 0xfea94, { 0, 0, 0, 0xffffffff, 0xffffffff, 0xffffffff } },
258   { "pjustic", 0, 0x725d0, { 0, 0, 0, 0xffffffff, 0xffffffff, 0xffffffff } },
259   { "pstone", 0, 0xe69c1, { 0, 0, 0, 0xffffffff, 0xffffffff, 0xffffffff } },
260   { "pstone2", 0, 0xb8dc0, { 0, 0, 0, 0xffffffff, 0xffffffff, 0xffffffff } },
261   { "samba", 0, 0xa8b5d, { 0, 0, 0, 0xffffffff, 0xffffffff, 0xffffffff } },
262   { "slasho", 0, 0xa66ca, { 0, 0, 0, 0xffffffff, 0xffffffff, 0xffffffff } },
263   { "smlg99", 0, 0x48a01, { 0, 0, 0, 0xffffffff, 0xffffffff, 0xffffffff } },
264   { "spawn", 0, 0x78d01, { 0, 0, 0, 0xffffffff, 0xffffffff, 0xffffffff } },
265   { "suchie3", 0, 0x368e1, { 0, 0, 0, 0xffffffff, 0xffffffff, 0xffffffff } },
266   { "toyfight", 0, 0x2ca85, { 0, 0, 0, 0xffffffff, 0xffffffff, 0xffffffff } },
267   { "vtennis", 0, 0x3eb15, { 0, 0, 0, 0xffffffff, 0xffffffff, 0xffffffff } },
268   { "wwfroyal",0, 0x627c3, { 0, 0, 0, 0xffffffff, 0xffffffff, 0xffffffff } },
269   { "zombrvn", 0, 0x12b41, { 0, 0, 0, 0xffffffff, 0xffffffff, 0xffffffff } },
270
271   // games where the encryption is stacked with the ASIC's compression
272   { "doa2", 0, -1, { -1, 0x500, 0, -1, 0x20504, 0x20000, -1, 0x40508, 0x40000, -1, 0x6050c, 0x60000, -1, 0x80510, 0x80000,   // 0x8ad01, has compression
233273          -1, 0xa0514, 0xa0000, -1, 0xc0518, 0xc0000, -1, 0xe051c, 0xe0000, -1, 0x100520,0x100000, -1, 0x118a3a, 0x120000,
234274          -1, 0x12c0d8, 0x140000, -1, 0x147e22, 0x160000, -1, 0x1645ce, 0x180000, -1, 0x17c6b2, 0x1a0000,
235275          -1, 0x19902e, 0x1c0000, -1, 0x1b562a, 0x1e0000, -1, 0xffffffff, 0xffffffff } },
236   { "doa2m", 0, { -1, 0x500, 0, -1, 0x20504, 0x20000, -1, 0x40508, 0x40000, -1, 0x6050c, 0x60000, -1, 0x80510, 0x80000,
276   { "doa2m", 0, -1, { -1, 0x500, 0, -1, 0x20504, 0x20000, -1, 0x40508, 0x40000, -1, 0x6050c, 0x60000, -1, 0x80510, 0x80000,
237277          -1, 0xa0514, 0xa0000, -1, 0xc0518, 0xc0000, -1, 0xe051c, 0xe0000, -1, 0x100520,0x100000, -1, 0x11a5b4, 0x120000,
238278          -1, 0x12e7c4, 0x140000, -1, 0x1471f6, 0x160000, -1, 0x1640c4, 0x180000, -1, 0x1806ca, 0x1a0000,
239279          -1, 0x199df4, 0x1c0000, -1, 0x1b5d0a, 0x1e0000, 0xffffffff, 0xffffffff } },
240   { "csmash", 1, { -1, 0x2000000, 0xbb614, 0xffffffff, 0xffffffff, 0xffffffff } },
241   { "csmasho", 1, { -1, 0x2000000, 0xbb5b4, 0xffffffff, 0xffffffff, 0xffffffff } },
242   { "capsnk", 0, { 0x8c2a, 0, 0, 0x3d3e, 0, 0x10000, 0x65b7, 0, 0x20000, 0x5896, 0, 0x30000, 0x16d2, 0, 0x40000,
243         0x9147, 0, 0x50000, 0x7ac, 0, 0x60000, 0xee67, 0, 0x70000, 0xeb63, 0, 0x80000, 0x2a04, 0, 0x90000,
244         0x3e41, 0, 0xa0000, 0xb7af, 0, 0xb0000, 0x9651, 0, 0xc0000, 0xd208, 0, 0xd0000, 0x4769, 0, 0xe0000,
245         0xad8c, 0, 0xf0000, 0x923d, 0, 0x100000, 0x4a65, 0, 0x110000, 0x9958, 0, 0x120000, 0x8216, 0, 0x130000,
246         0xaa91, 0, 0x140000, 0xd007, 0, 0x150000, 0xead, 0, 0x160000, 0x492, 0, 0x170000,
247         0xffffffff, 0xffffffff, 0xffffffff } },
248   { "capsnka", 0, { 0x8c2a, 0, 0, 0x3d3e, 0, 0x10000, 0x65b7, 0, 0x20000, 0x5896, 0, 0x30000, 0x16d2, 0, 0x40000,
249         0x9147, 0, 0x50000, 0x7ac, 0, 0x60000, 0xee67, 0, 0x70000, 0xeb63, 0, 0x80000, 0x2a04, 0, 0x90000,
250         0x3e41, 0, 0xa0000, 0xb7af, 0, 0xb0000, 0x9651, 0, 0xc0000, 0xd208, 0, 0xd0000, 0x4769, 0, 0xe0000,
251         0xad8c, 0, 0xf0000, 0x923d, 0, 0x100000, 0x4a65, 0, 0x110000, 0x9958, 0, 0x120000, 0x8216, 0, 0x130000,
252         0xaa91, 0, 0x140000, 0xd007, 0, 0x150000, 0xead, 0, 0x160000, 0x492, 0, 0x170000,
253         0xffffffff, 0xffffffff, 0xffffffff } },
254   { "pjustic", 0, { 0x923d, 0, 0, 0x3e41, 0, 0x10000, 0xb7af, 0, 0x20000,
255           0x9651, 0, 0x30000, 0xad8c, 0, 0x40000, 0xffffffff, 0xffffffff, 0xffffffff } },
256   { "hmgeo",   0, { 0x6cc8, 0, 0x000000, 0x7b92, 0, 0x010000, 0x69bc, 0, 0x020000,
257           0x6d16, 0, 0x030000, 0x6134, 0, 0x040000, 0x1340, 0, 0x050000,
258           0x7716, 0, 0x060000, 0x2e1a, 0, 0x070000, 0x3030, 0, 0x080000,
259           0x0870, 0, 0x090000, 0x2856, 0, 0x0a0000, 0x4224, 0, 0x0b0000,
260           0x6df0, 0, 0x0c0000, 0x0dd8, 0, 0x0d0000, 0x576c, 0, 0x0e0000,
261           0x0534, 0, 0x0f0000, 0x0904, 0, 0x100000, 0x2f14, 0, 0x110000,
262           0x1792, 0, 0x120000, 0x6866, 0, 0x130000, 0x06fa, 0, 0x140000,
263           0x2842, 0, 0x150000, 0x7cc8, 0, 0x160000, 0xffffffff, 0xffffffff, 0xffffffff } },
264   { "wwfroyal",0, { 0xaaaa, 0, 0, 0xffffffff, 0xffffffff, 0xffffffff } },
265   { "gwing2",  0, { -1, 0x85ddc0, 0, 0xd567, 0, 0x10000, 0xe329, 0, 0x30000, 0xc112, 0, 0x50000,
266           0xabcd, 0, 0x70000, 0xef01, 0, 0x90000, 0x1234, 0, 0xb0000, 0x5678, 0, 0xd0000,
267           0x5555, 0, 0xf0000, 0x6666, 0, 0x110000, 0xa901, 0, 0x130000, 0xa802, 0, 0x150000,
268           0x3232, 0, 0x170000, 0x8989, 0, 0x190000, 0x6655, 0, 0x1a0000,
269           0x3944, 0, 0x1c0000, 0x655a, 0, 0x1d0000, 0xf513, 0, 0x1e0000,
270           0xb957, 0, 0, 0x37ca, 0, 0, 0xffffffff, 0xffffffff, 0xffffffff } },
271   { "pstone2", 0, { -2, 0x14db3f4,  0x000000, -2, 0xfbd0179d, 0x010000, -2, 0x9827117, 0x020000, -2, 0x69358f, 0x030000,
272           -2, 0x193954e, 0x040000, -2, 0xba50eb, 0x050000, -2, 0x9f1523, 0x060000, -2, 0xcb7b03, 0x070000,
273           -2, 0x8f712b, 0x080000, -2, 0x120f246, 0x090000, -2, 0xacc9fc, 0x0a0000, -2, 0x4eb319, 0x0b0000,
274           -2, 0x19d0c41, 0x0c0000, -2, 0x1077853, 0x0d0000, -2, 0x100019d, 0x0e0000, -2, 0xfd91596b, 0x0f0000,
275           -2, 0x63bae7, 0x100000, -2, 0x3e3685, 0x110000, -2, 0x6d08a9, 0x120000, -2, 0xfff85c5d, 0x130000,
276           -2, 0x5263bf, 0x140000, -2, 0x396180, 0x150000, -2, 0x73af6c, 0x160000, -2, 0xfffa8a76, 0x170000,
277           -2, 0xc2d9e0, 0x180000, -2, 0x33be72, 0x190000,
278           0xffffffff, 0xffffffff, 0xffffffff } },
279   { "toyfight", 0,{ 0x0615, 0, 0x8f058, 0x1999, 0, 0x8ec58, 0x7510, 0, 0x8f458, 0x5736, 0, 0x8e858,
280                0xffffffff, 0xffffffff, 0xffffffff } },
281   { "ggx",      0,{ -1, 0x200000, 0x100000, -1, 0x210004, 0x110000, -1, 0x220008, 0x120000, -1, 0x228000, 0x130000,
280   { "ggx",      0, -1, { -1, 0x200000, 0x100000, -1, 0x210004, 0x110000, -1, 0x220008, 0x120000, -1, 0x228000, 0x130000,   // 0x76110, uses compression
282281                0x3af9, 0, 0x000000, 0x2288, 0, 0x010000, 0xe5e6, 0, 0x020000, 0xebb0, 0, 0x030000,
283282           0x0228, 0, 0x040000, 0x872c, 0, 0x050000, 0xbba0, 0, 0x060000, 0x772f, 0, 0x070000,
284283           0x2924, 0, 0x080000, 0x3222, 0, 0x090000, 0x7954, 0, 0x0a0000, 0x5acd, 0, 0x0b0000,
285284           0xdd19, 0, 0x0c0000, 0x2428, 0, 0x0d0000, 0x3329, 0, 0x0e0000, 0x2142, 0, 0x0f0000,
286285                0xffffffff, 0xffffffff, 0xffffffff } },
287   { "crzytaxi", 0,{ 0x0219, 0, 0, 0xffffffff, 0xffffffff, 0xffffffff } },
288   { "jambo",    0,{ 0x0223, 0, 0, 0xffffffff, 0xffffffff, 0xffffffff } },
289   { "18wheelr", 0,{ 0x1502, 0, 0, 0xffffffff, 0xffffffff, 0xffffffff } },
290   { "sgtetris", 0,{ 0x1234, 0, 0, 0xffffffff, 0xffffffff, 0xffffffff } },
286   { "sgtetris", 0, -1, { 0x1234, 0, 0, 0xffffffff, 0xffffffff, 0xffffffff } },   // 0x8ae51, uses compression
287//  { "virnbao", 0, 0x68b58, { 0, 0, 0, 0xffffffff, 0xffffffff, 0xffffffff } },     // note: "virnba" set doesn't have protection
288//  { "vs2_2k", 0, 0x88b08, { 0, 0, 0, 0xffffffff, 0xffffffff, 0xffffffff } },
291289};
292290
291// forward declaration for decrypt function
292static void stream_decrypt(UINT32 game_key, UINT32 sequence_key, UINT16 seed, UINT8* ciphertext, UINT8* plaintext, int length);
293static UINT16 block_decrypt(UINT32 game_key, UINT16 sequence_key, UINT16 counter, UINT16 data);
294
293295/***************************************************************************
294296    INLINE FUNCTIONS
295297***************************************************************************/
r7500r7501
377379static void soft_reset(naomibd_state *v)
378380{
379381   v->prot_sum = 0;
382
383   v->dc_m3_ptr = 0;
384   v->dc_seqkey = 0;
380385}
381386
382387
r7500r7501
406411
407412      if (v->rom_offset_flags & NAOMIBD_FLAG_SPECIAL_MODE)
408413      {
409         if (v->rom_offset == 0x1fffe)
414         // can we live-decrypt this game?
415         if (v->dc_gamekey != -1)
410416         {
411            UINT8 *prot = (UINT8 *)v->protdata;
412            UINT32 byte_offset = v->prot_offset*2;
417            ret = (UINT64)(v->dc_cart_ram[v->dc_readback+1] | (v->dc_cart_ram[v->dc_readback]<<8));
418            v->dc_readback += 2;
419         }
420         else
421         {
422            if (v->rom_offset == 0x1fffe)
423            {
424               UINT8 *prot = (UINT8 *)v->protdata;
425               UINT32 byte_offset = v->prot_offset*2;
413426
414            // this is a good time to clear the prot_sum
415            v->prot_sum = 0;
427               // this is a good time to clear the prot_sum
428               v->prot_sum = 0;
416429
417            if (v->prot_translate == NULL)
418            {
430               if (v->prot_translate == NULL)
431               {
432                  #if NAOMIBD_PRINTF_PROTECTION
433                  v->prot_pio_count += 2;
434                  printf("naomibd: reading protection data, but none was supplied (now %x bytes)\n", v->prot_pio_count);
435                  #endif
436                  return 0;
437               }
438
419439               #if NAOMIBD_PRINTF_PROTECTION
420440               v->prot_pio_count += 2;
421               printf("naomibd: reading protection data, but none was supplied (now %x bytes)\n", v->prot_pio_count);
441               printf("naomibd: PIO read count %x\n", v->prot_pio_count);
422442               #endif
423               return 0;
424            }
425443
426            #if NAOMIBD_PRINTF_PROTECTION
427            v->prot_pio_count += 2;
428            printf("naomibd: PIO read count %x\n", v->prot_pio_count);
429            #endif
444               if (v->prot_reverse_bytes)
445               {
446                  ret = (UINT64)(prot[byte_offset+1] | (prot[byte_offset]<<8));
447               }
448               else
449               {
450                  ret = (UINT64)(prot[byte_offset] | (prot[byte_offset+1]<<8));
451               }
430452
431            if (v->prot_reverse_bytes)
432            {
433               ret = (UINT64)(prot[byte_offset+1] | (prot[byte_offset]<<8));
453               v->prot_offset++;
434454            }
455            #if NAOMIBD_PRINTF_PROTECTION
435456            else
436457            {
437               ret = (UINT64)(prot[byte_offset] | (prot[byte_offset+1]<<8));
458               printf("Bad protection offset read %x\n", v->rom_offset);
438459            }
439
440            v->prot_offset++;
460            #endif
441461         }
442         #if NAOMIBD_PRINTF_PROTECTION
443         else
444         {
445            printf("Bad protection offset read %x\n", v->rom_offset);
446         }
447         #endif
448462      }
449463      else
450464      {
r7500r7501
461475   else if ((offset == 2) && ACCESSING_BITS_32_63)
462476   {
463477      //  Actel FPGA ID, used on some games for a "special" ROM test.
478      //
479      //  without this (by returning 0xffff) some games will do a rom test where
480      //  the IC numbers tested do not relate to the actual ROMs on the cart,
481      //  and a fake 'IC1' will be tested, which returns mirrored data from the
482      //  other roms in order to pass if enabled on the real hardware.
483      //  (certain bios / board combinations will also cause this, so it is
484      //   important that we mirror the data in the rom loading using ROM_COPY)
464485
486      //return (UINT64)0xffff << 32;
465487      return (UINT64)actel_id << 32;
466488   }
467489   else if ((offset == 7) && ACCESSING_BITS_32_47)
r7500r7501
513535WRITE64_DEVICE_HANDLER( naomibd_w )
514536{
515537   naomibd_state *v = get_safe_token(device);
516   INT32 i;
517538
518539   // AW board
519540   if (v->type == AW_ROM_BOARD)
r7500r7501
657678                  v->prot_pio_count = 0;
658679                  #endif
659680
660                  // translate address if necessary
661                  if (v->prot_translate != NULL)
681                  // if dc_gamekey isn't -1, we can live-decrypt this one
682                  if (v->dc_gamekey != -1)
662683                  {
663                     i = 0;
664                     while (v->prot_translate[i+1] != 0xffffffff)
684                     UINT8 temp_ram[128*1024];
685                     UINT8 *ROM = (UINT8 *)v->memory;
686
687                     v->dc_seed = 0;
688                     v->dc_readback = 0;
689                     v->dc_seqkey = v->prot_key;
690
691                     #if NAOMIBD_PRINTF_PROTECTION
692                     printf("M2/M3 decrypt: gamekey %x seqkey %x seed %x length %x\n", v->dc_gamekey, v->dc_seqkey, v->dc_seed, v->dc_m3_ptr);
693                     #endif
694
695                     // M2: just decrypt up to the size limit since we don't know the size in advance
696                     if (v->prot_offset != 0x2000000/2)
665697                     {
666                        // should we match by key, address, or sum?
667                        if (v->prot_translate[i] == -2)   // match sum
698                        // decrypt to temp buffer
699                        stream_decrypt(v->dc_gamekey, v->dc_seqkey, v->prot_offset&0xffff, &ROM[v->prot_offset*2], temp_ram, 128*1024);
700                     }
701                     else
702                     {
703                        // decrypt cart ram to temp buffer
704                        stream_decrypt(v->dc_gamekey, v->dc_seqkey, v->dc_seed, v->dc_cart_ram, temp_ram, v->dc_m3_ptr);
705                     }
706
707                     #if NAOMIBD_PRINTF_PROTECTION
708                     printf("result: %02x %02x %02x %02x %02x %02x %02x %02x\n",
709                        temp_ram[0], temp_ram[1], temp_ram[2], temp_ram[3],
710                        temp_ram[4], temp_ram[5], temp_ram[6], temp_ram[7]);
711                     #endif
712
713                     // copy results to cart ram for readback
714                     memcpy(v->dc_cart_ram, temp_ram, 128*1024);
715
716                     v->dc_m3_ptr = 0;
717                     v->prot_sum = 0;
718                  }
719                  else
720                  {
721                     // translate address if necessary
722                     if (v->prot_translate != NULL)
723                     {
724                        int i = 0;
725                        while (v->prot_translate[i+1] != 0xffffffff)
668726                        {
669                           if (v->prot_translate[i+1] == v->prot_sum)
727                           // should we match by key, address, or sum?
728                           if (v->prot_translate[i] == -2)   // match sum
670729                           {
671                              #if NAOMIBD_PRINTF_PROTECTION
672                              printf("Protection: got sum %x, translated to %x\n", v->prot_sum, v->prot_translate[i+2]);
673                              #endif
674                              v->prot_offset = v->prot_translate[i+2]/2;
675                              break;
730                              if (v->prot_translate[i+1] == v->prot_sum)
731                              {
732                                 #if NAOMIBD_PRINTF_PROTECTION
733                                 printf("Protection: got sum %x, translated to %x\n", v->prot_sum, v->prot_translate[i+2]);
734                                 #endif
735                                 v->prot_offset = v->prot_translate[i+2]/2;
736                                 break;
737                              }
738                              else
739                              {
740                                 i+= 3;
741                              }
676742                           }
677                           else
743                           else if (v->prot_translate[i] == -1)   // match address
678744                           {
679                              i+= 3;
745                              if (v->prot_translate[i+1] == (v->prot_offset*2))
746                              {
747                                 #if NAOMIBD_PRINTF_PROTECTION
748                                 printf("Protection: got offset %x, translated to %x\n", v->prot_offset, v->prot_translate[i+2]);
749                                 #endif
750                                 v->prot_offset = v->prot_translate[i+2]/2;
751                                 break;
752                              }
753                              else
754                              {
755                                 i += 3;
756                              }
680757                           }
681                        }
682                        else if (v->prot_translate[i] == -1)   // match address
683                        {
684                           if (v->prot_translate[i+1] == (v->prot_offset*2))
758                           else   // match key
685759                           {
686                              #if NAOMIBD_PRINTF_PROTECTION
687                              printf("Protection: got offset %x, translated to %x\n", v->prot_offset, v->prot_translate[i+2]);
688                              #endif
689                              v->prot_offset = v->prot_translate[i+2]/2;
690                              break;
760                              if (v->prot_translate[i] == v->prot_key)
761                              {
762                                 #if NAOMIBD_PRINTF_PROTECTION
763                                 printf("Protection: got key %x, translated to %x\n", v->prot_key, v->prot_translate[i+2]);
764                                 #endif
765                                 v->prot_offset = v->prot_translate[i+2]/2;
766                                 break;
767                              }
768                              else
769                              {
770                                 i+= 3;
771                              }
691772                           }
692                           else
693                           {
694                              i += 3;
695                           }
696773                        }
697                        else   // match key
698                        {
699                           if (v->prot_translate[i] == v->prot_key)
700                           {
701                              #if NAOMIBD_PRINTF_PROTECTION
702                              printf("Protection: got key %x, translated to %x\n", v->prot_key, v->prot_translate[i+2]);
703                              #endif
704                              v->prot_offset = v->prot_translate[i+2]/2;
705                              break;
706                           }
707                           else
708                           {
709                              i+= 3;
710                           }
711                        }
712774                     }
775                     #if NAOMIBD_PRINTF_PROTECTION
776                     else
777                     {
778                        printf("naomibd: protection not handled for this game\n");
779                     }
780                     #endif
713781                  }
714                  #if NAOMIBD_PRINTF_PROTECTION
715                  else
716                  {
717                     printf("naomibd: protection not handled for this game\n");
718                  }
719                  #endif
720782                  break;
721783
722784               case 0x2000000:
723785               case 0x2020000:
724786                  #if NAOMIBD_PRINTF_PROTECTION
725                  printf("Protection write %04x to upload\n", (UINT32)(data&0xffff));
787                  printf("Protection write %04x to upload @ %x\n", (UINT32)(data&0xffff), v->dc_m3_ptr);
726788                  #endif
727789                  v->prot_sum += (INT16)(data&0xffff);
790
791                  v->dc_cart_ram[v->dc_m3_ptr] = (data&0xff);
792                  v->dc_cart_ram[v->dc_m3_ptr+1] = (data>>8)&0xff;
793                  v->dc_m3_ptr += 2;
728794                  break;
729795
730796               default:
r7500r7501
813879   int pos,len,a;
814880   char name[128];
815881   UINT64 key;
882   UINT8* realpic; // todo, add to device
816883
817884   memset(name,'\0',128);
818   memcpy(name, v->picdata+33, 7);
819   memcpy(name+7, v->picdata+25, 7);
885
886   realpic = memory_region(machine,"pic");
887
888   if (realpic)
889   {
890      //printf("Real PIC binary found\n");
891      int i;
892      for (i=0;i<7;i++)
893      {
894         name[i] = realpic[0x7c0+i*2];
895      }
896      for (i=0;i<7;i++)
897      {
898         name[i+7] = realpic[0x7e0+i*2];
899      }
900   }
901   else
902   {
903      // use extracted pic data
904      logerror("This PIC key hasn't been converted to a proper PIC binary yet!\n");
905      memcpy(name, v->picdata+33, 7);
906      memcpy(name+7, v->picdata+25, 7);
907   }
908
820909   gdromfile = cdrom_open(v->gdromchd);
821910   // primary volume descriptor
822911   // read frame 0xb06e (frame=sector+150)
r7500r7501
838927   // find data of file
839928   start = 0;
840929   size = 0;
841   printf("Looking for file %s\n", name);
930   logerror("Looking for file %s\n", name);
842931   for (pos = 0;pos < 2048;pos += buffer[pos])
843932   {
844933      a=0;
r7500r7501
875964               (buffer[pos+12] << 16) |
876965               (buffer[pos+13] << 24));
877966
878         printf("start %08x size %08x\n", start,size);
967         logerror("start %08x size %08x\n", start,size);
879968         break;
880969      }
881970      if (buffer[pos] == 0)
r7500r7501
897986      start = 0;
898987      size = 0;
899988
900      printf("Looking for file %s\n", name);
989      logerror("Looking for file %s\n", name);
901990      for (pos = 0;pos < 2048;pos += buffer[pos])
902991      {
903992         a = 0;
r7500r7501
9341023                  (buffer[pos+12] << 16) |
9351024                  (buffer[pos+13] << 24));
9361025
937            printf("start %08x size %08x\n", start,size);
1026            logerror("start %08x size %08x\n", start,size);
9381027            break;
9391028         }
9401029         if (buffer[pos] == 0)
r7500r7501
9551044      }
9561045   }
9571046   // get des key
958   key =(((UINT64)v->picdata[0x31] << 56) |
959        ((UINT64)v->picdata[0x32] << 48) |
960        ((UINT64)v->picdata[0x33] << 40) |
961        ((UINT64)v->picdata[0x34] << 32) |
962        ((UINT64)v->picdata[0x35] << 24) |
963        ((UINT64)v->picdata[0x36] << 16) |
964        ((UINT64)v->picdata[0x37] << 8)  |
965        ((UINT64)v->picdata[0x29] << 0));
1047   realpic = memory_region(machine,"pic");
9661048
967   printf("key is %08x%08x\n", (UINT32)((key & 0xffffffff00000000ULL)>>32), (UINT32)(key & 0x00000000ffffffffULL));
1049   if (realpic)
1050   {
1051      int i;
1052      key = 0;
1053      for (i=0;i<7;i++)
1054      {
1055         key |= (UINT64)realpic[0x780+i*2] << (56 - i*8);
1056      }
9681057
1058      key |= (UINT64)realpic[0x7a0];
1059   }
1060   else
1061   {
1062      key =(((UINT64)v->picdata[0x31] << 56) |
1063           ((UINT64)v->picdata[0x32] << 48) |
1064           ((UINT64)v->picdata[0x33] << 40) |
1065           ((UINT64)v->picdata[0x34] << 32) |
1066           ((UINT64)v->picdata[0x35] << 24) |
1067           ((UINT64)v->picdata[0x36] << 16) |
1068           ((UINT64)v->picdata[0x37] << 8)  |
1069           ((UINT64)v->picdata[0x29] << 0));
1070   }
1071
1072   logerror("key is %08x%08x\n", (UINT32)((key & 0xffffffff00000000ULL)>>32), (UINT32)(key & 0x00000000ffffffffULL));
1073
9691074   // decrypt loaded data
9701075   naomi_game_decrypt(machine, key, v->memory, size);
9711076   cdrom_close(gdromfile);
9721077}
9731078
1079/***************************************************************************
1080    DECRYPTION EMULATION
9741081
1082By convention, we label the three known cart protection methods this way (using Deunan Knute's wording):
1083M1: DMA read of protected ROM area
1084M2: special read of ROM area which supplies decryption key first
1085M3: normal read followed by write to cart's decryption buffer (up to 64kB), followed by M2 but from buffer area
9751086
1087M1's working is still unclear (more on this later), so we will be speaking of M2 & M3 most of the time.
1088
1089The encryption is done by a stream cipher operating in counter mode, which use a 16-bits internal block cipher.
1090
1091There are 2 "control bits" at the start of the decrypted stream which control the mode of operation: bit #1 set to 1 means
1092that the decrypted stream needs to be decompressed after being decrypted. More on this later.
1093
1094The next 16-bits are part of the header (they don't belong to the plaintext), but his meaning is unclear. It has been
1095conjectured that it could stablish when to "reset" the process and start processing a new stream (based on some tests
1096on WWFROYAL, in which the decryption's output doesn't seem to be valid for more than some dozens of words), but some
1097more testing would be needed for clarifying that.
1098
1099After those 18 heading bits, we find the proper plaintext. It must be noted that, due to the initial 2 special bits,
1100the 16-bits words of the plaintext are shifted 2 bits respect to the word-boundaries of the output stream of the
1101internal block-cipher. So, at a given step, the internal block cipher will output 16-bits, 14 of which will go to a
1102given plaintext word, and the remaining 2 to the next plaintext word.
1103
1104The underlying block cipher consists of two 4-round Feistel Networks (FN): the first one takes the counter (16 bits),
1105the game-key (20 bits) and the sequence-key (16 bits) and output a middle result (16 bits) which will act as another key
1106for the second one. The second FN will take the encrypted word (16 bits), the game-key, the sequence-key and the result
1107from the first FN and will output the decrypted word (16 bits).
1108
1109Each round of the Feistel Networks use four substitution sboxes, each having 6 inputs and 2 outputs. The input can be the
1110XOR of at most two "sources bits", being source bits the bits from the previous round and the bits from the different keys.
1111
1112The underlying block cipher has the same structure than the one used by the CPS-2 (Capcom Play System 2) and,
1113indeed, some of the used sboxes are exactly the same and appear in the same FN/round in both systems (this is not evident,
1114as you need to apply a bitswapping and some XORs to the input & output of the sboxes to get the same values due). However,
1115the key scheduling used by this implementation is much weaker than the CPS-2's one. Many s-boxes inputs are XORed with any
1116key bit and, indeed, the cart-specific key is just 20-bits long.
1117
1118Due to the small key-length, no sophisticated attacks are needed to recover the keys; a brute-force attack knowing just
1119one or two (encrypted word-decrypted word) pairs suffice.
1120
1121The only difference in the decryption process between M2 and M3 is the initialization of the counter. In M3, the counter is
1122always set to 0 at the beginning of the decryption while, in M2, the bits #1-#16 of the ciphertext's address are used
1123to initialize the counter.
1124
1125Due to the nature of the cipher, there are some degrees of freedom when choosing the s-boxes and keys values; by example,
1126you could apply a fixed bitswapping and XOR to the keys and the decryption would remain the same as long as you change
1127accordingly the s-boxes' definitions. So the order of the bits in the keys is arbitrary, and the s-boxes values have been
1128chosen so as to make the key for CAPSNK equal to 0.
1129
1130It can be observed that some sboxes have incomplete tables (a 255 value indicate an unknown value). In most of the cases,
1131they are apparently unused by the cipher (due to the weak key scheduling mentioned above). As of february/2010, the only
1132s-box which have a incomplete table which could be begin used is the 4th s-box of the 1st round of the 2nd FN. It's
1133incomplete because we haven't located any game using that part of the s-box till now, but definitively it could be being
1134used by some still-not-analyzed carts.
1135
1136When bit #1 of the heading control bits is set to 1, an additional decompression step seems to be carried out. As of
1137february/2010, Deunan Knute has put some work on analyzing the decompression algorithm, but probably much more work will
1138be needed to completely reverse engineer it. Interested devs with quick access to hardware tests are welcomed to join
1139the task.
1140
1141Guilty Gear X & Sega Tetris are examples of games using the decompression ingame.
1142
1143Due to technical details, it's more difficult to get custom decryption data from M1 carts, which hinders some types of
1144analysis. The only M1 cart which have received attention until now have been AH! MY GODDESS. The available data clearly
1145doesn't have the same structure than M2&M3 carts using only the decryption step. However, due to that some hardware tests
1146show cycled structures similar to the ones returned by M2&M3 carts using the decompression algo, it's conjectured that M1
1147carts will be using the same decompression algorithm seen in M2&M3 ones.
1148
1149****************************************************************************************/
1150
1151struct sbox
1152{
1153    UINT8 table[64];
1154    int inputs[6];      // positions of the inputs bits, -1 means no input except from key
1155    int outputs[2];     // positions of the output bits
1156};
1157
1158
1159static const struct sbox fn1_sboxes[4][4] =
1160{
1161    {   // 1st round
1162        {
1163            {
1164                0,3,2,2,1,3,1,2,3,2,1,2,1,2,3,1,3,2,2,0,2,1,3,0,0,3,2,3,2,1,2,0,
1165                // unused
1166                255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
1167            },
1168            {3,4,5,7,-1,-1},
1169            {0,4}
1170        },
1171
1172        {
1173            {
1174                2,2,2,0,3,3,0,1,2,2,3,2,3,0,2,2,1,1,0,3,3,2,0,2,0,1,0,1,2,3,1,1,
1175                0,1,3,3,1,3,3,1,2,3,2,0,0,0,2,2,0,3,1,3,0,3,2,2,0,3,0,3,1,1,0,2,
1176            },
1177            {0,1,2,5,6,7},
1178            {1,6}
1179        },
1180
1181        {
1182            {
1183                0,1,3,0,3,1,1,1,1,2,3,1,3,0,2,3,3,2,0,2,1,1,2,1,1,3,1,0,0,2,0,1,
1184                1,3,1,0,0,3,2,3,2,0,3,3,0,0,0,0,1,2,3,3,2,0,3,2,1,0,0,0,2,2,3,3,
1185            },
1186            {0,2,5,6,7,-1},
1187            {2,3}
1188        },
1189
1190        {
1191            {
1192                3,2,1,2,1,2,3,2,0,3,2,2,3,1,3,3,0,2,3,0,3,3,2,1,1,1,2,0,2,2,0,1,
1193                1,3,3,0,0,3,0,3,0,2,1,3,2,1,0,0,0,1,1,2,0,1,0,0,0,1,3,3,2,0,3,3,
1194            },
1195            {1,2,3,4,6,7},
1196            {5,7}
1197        },
1198    },
1199    {   // 2nd round
1200        {
1201            {
1202                3,3,1,2,0,0,2,2,2,1,2,1,3,1,1,3,3,0,0,3,0,3,3,2,1,1,3,2,3,2,1,3,
1203                2,3,0,1,3,2,0,1,2,1,3,1,2,2,3,3,3,1,2,2,0,3,1,2,2,1,3,0,3,0,1,3,
1204            },
1205            {0,1,3,4,5,7},
1206            {0,4}
1207        },
1208
1209        {
1210            {
1211                2,0,1,0,0,3,2,0,3,3,1,2,1,3,0,2,0,2,0,0,0,2,3,1,3,1,1,2,3,0,3,0,
1212                // unused
1213                255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
1214            },
1215            {0,1,3,4,6,-1},
1216            {1,5}
1217        },
1218
1219        {
1220            {
1221                2,2,2,3,1,1,0,1,0,1,2,2,3,3,0,2,0,3,2,3,3,0,2,1,0,3,1,0,0,2,3,2,
1222                3,2,0,3,2,0,1,0,3,3,1,1,2,2,2,0,2,1,3,1,1,1,1,2,2,2,3,0,1,3,0,0,
1223            },
1224            {1,2,5,6,7,-1},
1225            {2,7}
1226        },
1227
1228        {
1229            {
1230                0,1,3,3,3,1,3,3,1,0,2,0,2,0,0,3,1,2,1,3,1,2,3,2,2,0,1,3,0,3,3,3,
1231                0,0,0,2,1,1,2,3,2,2,3,1,1,2,0,2,0,2,1,3,1,1,3,3,1,1,3,0,2,3,0,0,
1232            },
1233            {2,3,4,5,6,7},
1234            {3,6}
1235        },
1236    },
1237    {   // 3rd round
1238        {
1239            {
1240                0,0,1,0,1,0,0,3,2,0,0,3,0,1,0,2,0,3,0,0,2,0,3,2,2,1,3,2,2,1,1,2,
1241                0,0,0,3,0,1,1,0,0,2,1,0,3,1,2,2,2,0,3,1,3,0,1,2,2,1,1,1,0,2,3,1,
1242            },
1243            {1,2,3,4,5,7},
1244            {0,5}
1245        },
1246
1247        {
1248            {
1249                1,2,1,0,3,1,1,2,0,0,2,3,2,3,1,3,2,0,3,2,2,3,1,1,1,1,0,3,2,0,0,1,
1250                1,0,0,1,3,1,2,3,0,0,2,3,3,0,1,0,0,2,3,0,1,2,0,1,3,3,3,1,2,0,2,1,
1251            },
1252            {0,2,4,5,6,7},
1253            {1,6}
1254        },
1255
1256        {
1257            {
1258                0,3,0,2,1,2,0,0,1,1,0,0,3,1,1,0,0,3,0,0,2,3,3,2,3,1,2,0,0,2,3,0,
1259                // unused
1260                255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
1261            },
1262            {0,2,4,6,7,-1},
1263            {2,3}
1264        },
1265
1266        {
1267            {
1268                0,0,1,0,0,1,0,2,3,3,0,3,3,2,3,0,2,2,2,0,3,2,0,3,1,0,0,3,3,0,0,0,
1269                2,2,1,0,2,0,3,2,0,0,3,1,3,3,0,0,2,1,1,2,1,0,1,1,0,3,1,2,0,2,0,3,
1270            },
1271            {0,1,2,3,6,-1},
1272            {4,7}
1273        },
1274    },
1275    {   // 4th round
1276        {
1277            {
1278                0,3,3,3,3,3,2,0,0,1,2,0,2,2,2,2,1,1,0,2,2,1,3,2,3,2,0,1,2,3,2,1,
1279                3,2,2,3,1,0,1,0,0,2,0,1,2,1,2,3,1,2,1,1,2,2,1,0,1,3,2,3,2,0,3,1,
1280            },
1281            {0,1,3,4,5,6},
1282            {0,5}
1283        },
1284
1285        {
1286            {
1287                0,3,0,0,2,0,3,1,1,1,2,2,2,1,3,1,2,2,1,3,2,2,3,3,0,3,1,0,3,2,0,1,
1288                3,0,2,0,1,0,2,1,3,3,1,2,2,0,2,3,3,2,3,0,1,1,3,3,0,2,1,3,0,2,2,3,
1289            },
1290            {0,1,2,3,5,7},
1291            {1,7}
1292        },
1293
1294        {
1295            {
1296                0,1,2,3,3,3,3,1,2,0,2,3,2,1,0,1,2,2,1,2,0,3,2,0,1,1,0,1,3,1,3,1,
1297                3,1,0,0,1,0,0,0,0,1,2,2,1,1,3,3,1,2,3,3,3,2,3,0,2,2,1,3,3,0,2,0,
1298            },
1299            {2,3,4,5,6,7},
1300            {2,3}
1301        },
1302
1303        {
1304            {
1305                0,2,1,1,3,2,0,3,1,0,1,0,3,2,1,1,2,2,0,3,1,0,1,2,2,2,3,3,0,0,0,0,
1306                1,2,1,0,2,1,2,2,2,3,2,3,0,1,3,0,0,1,3,0,0,1,1,0,1,0,0,0,0,2,0,1,
1307            },
1308            {0,1,2,4,6,7},
1309            {4,6}
1310        },
1311    },
1312};
1313
1314
1315static const struct sbox fn2_sboxes[4][4] =
1316{
1317    {   // 1st round
1318        {
1319            {
1320                3,3,0,1,0,1,0,0,0,3,0,0,1,3,1,2,0,3,3,3,2,1,0,1,1,1,2,2,2,3,2,2,
1321                2,1,3,3,1,3,1,1,0,0,1,2,0,2,2,1,1,2,3,1,2,1,3,1,2,2,0,1,3,0,2,2,
1322            },
1323            {1,3,4,5,6,7},
1324            {0,7}
1325        },
1326
1327        {
1328            {
1329                0,2,3,2,1,1,0,0,2,1,0,3,3,0,0,0,3,2,0,2,1,1,2,1,0,0,3,1,2,2,3,1,
1330                3,1,3,0,0,0,1,3,1,0,0,3,2,2,3,1,1,3,0,0,2,1,3,3,1,3,1,2,3,1,2,1,
1331            },
1332            {0,3,5,6,-1,-1},
1333            {1,2}
1334        },
1335
1336        {
1337            {
1338                0,2,2,1,0,1,2,1,2,0,1,2,3,3,0,1,3,1,1,2,1,2,1,3,3,2,3,3,2,1,0,1,
1339                // unused
1340                255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
1341            },
1342            {0,2,3,4,7,-1},
1343            {3,4}
1344        },
1345
1346        {
1347            {
1348                2,3,1,3,2,0,1,2,0,0,3,3,3,3,3,1,2,0,2,1,2,3,0,2,0,1,0,3,0,2,1,0,
1349                2,3,0,1,3,0,3,2,3,1,2,0,3,1,1,2,
1350                // potentially used, but we haven't located any game using it
1351                255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
1352            },
1353            {1,2,5,6,-1,-1},
1354            {5,6}
1355        },
1356    },
1357    {   // 2nd round
1358        {
1359            {
1360                2,3,1,3,1,0,3,3,3,2,3,3,2,0,0,3,2,3,0,3,1,1,2,3,1,1,2,2,0,1,0,0,
1361                2,1,0,1,2,0,1,2,0,3,1,1,2,3,1,2,0,2,0,1,3,0,1,0,2,2,3,0,3,2,3,0,
1362            },
1363            {0,1,4,5,6,7},
1364            {0,7}
1365        },
1366
1367        {
1368            {
1369                0,2,2,0,2,2,0,3,2,3,2,1,3,2,3,3,1,1,0,0,3,0,2,1,1,3,3,2,3,2,0,1,
1370                1,2,3,0,1,0,3,0,3,1,0,2,1,2,0,3,2,3,1,2,2,0,3,2,3,0,0,1,2,3,3,3,
1371            },
1372            {0,2,3,6,7,-1},
1373            {1,5}
1374        },
1375
1376        {
1377            {
1378                1,2,3,2,0,3,2,3,0,1,1,0,0,2,2,3,2,0,0,3,0,2,3,3,2,2,1,0,2,1,0,3,
1379                1,0,2,0,1,1,0,1,0,0,1,0,3,0,3,3,2,2,0,2,1,1,1,0,3,0,1,3,2,3,2,1,
1380            },
1381            {2,3,4,6,7,-1},
1382            {2,3}
1383        },
1384
1385        {
1386            {
1387                2,3,1,3,1,1,2,3,3,1,1,0,1,0,2,3,2,1,0,0,2,2,0,1,0,2,2,2,0,2,1,0,
1388                3,1,2,3,1,3,0,2,1,0,1,0,0,1,2,2,3,2,3,1,3,2,1,1,2,0,2,1,3,3,1,0,
1389            },
1390            {1,2,3,4,5,6},
1391            {4,6}
1392        },
1393    },
1394    {   // 3rd round
1395        {
1396            {
1397                0,3,0,1,0,2,3,3,1,0,1,3,2,2,1,1,3,3,3,0,2,0,2,0,0,0,2,3,1,1,0,0,
1398                3,3,0,3,3,0,0,2,1,1,1,0,2,2,2,0,3,0,3,1,2,2,0,3,0,0,3,2,0,3,2,1,
1399            },
1400            {1,4,5,6,7,-1},
1401            {0,5}
1402        },
1403
1404        {
1405            {
1406                0,3,0,1,3,0,3,1,3,2,2,2,3,0,3,2,2,1,2,2,0,3,2,2,0,0,2,1,1,3,2,3,
1407                2,3,3,1,2,0,1,2,2,1,0,0,0,0,2,3,1,2,0,3,1,3,1,2,3,2,1,0,3,0,0,2,
1408            },
1409            {0,2,3,4,6,7},
1410            {1,7}
1411        },
1412
1413        {
1414            {
1415                2,2,3,2,0,3,2,3,1,1,2,0,2,3,1,3,0,0,0,3,2,0,1,0,1,3,2,3,3,3,1,0,
1416                // unused
1417                255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,
1418            },
1419            {1,2,4,7,-1,-1},
1420            {2,4}
1421        },
1422
1423        {
1424            {
1425                0,2,3,1,3,1,1,0,0,1,3,0,2,1,3,3,2,0,2,1,1,2,3,3,0,0,0,2,0,2,3,0,
1426                3,3,3,3,2,3,3,2,3,0,1,0,2,3,3,2,0,1,3,1,0,1,2,3,3,0,2,0,3,0,3,3,
1427            },
1428            {0,1,2,3,5,7},
1429            {3,6}
1430        },
1431    },
1432    {   // 4th round
1433        {
1434            {
1435                0,1,1,0,0,1,0,2,3,3,0,1,2,3,0,2,1,0,3,3,2,0,3,0,0,2,1,0,1,0,1,3,
1436                0,3,3,1,2,0,3,0,1,3,2,0,3,3,1,3,0,2,3,3,2,1,1,2,2,1,2,1,2,0,1,1,
1437            },
1438            {0,1,2,4,7,-1},
1439            {0,5}
1440        },
1441
1442        {
1443            {
1444                2,0,0,2,3,0,2,3,3,1,1,1,2,1,1,0,0,2,1,0,0,3,1,0,0,3,3,0,1,0,1,2,
1445                0,2,0,2,0,1,2,3,2,1,1,0,3,3,3,3,3,3,1,0,3,0,0,2,0,3,2,0,2,2,0,1,
1446            },
1447            {0,1,3,5,6,-1},
1448            {1,3}
1449        },
1450
1451        {
1452            {
1453                0,1,1,2,1,3,1,1,0,0,3,1,1,1,2,0,3,2,0,1,1,2,3,3,3,0,3,0,0,2,0,3,
1454                3,2,0,0,3,2,3,1,2,3,0,3,2,0,1,2,2,2,0,2,0,1,2,2,3,1,2,2,1,1,1,1,
1455            },
1456            {0,2,3,4,5,7},
1457            {2,7}
1458        },
1459
1460        {
1461            {
1462                0,1,2,0,3,3,0,3,2,1,3,3,0,3,1,1,3,2,3,2,3,0,0,0,3,0,2,2,3,2,2,3,
1463                2,2,3,1,2,3,1,2,0,3,0,2,3,1,0,0,3,2,1,2,1,2,1,3,1,0,2,3,3,1,3,2,
1464            },
1465            {2,3,4,5,6,7},
1466            {4,6}
1467        },
1468    },
1469};
1470
1471static const int fn1_game_key_scheduling[30][2] =
1472{
1473    {1,29},  {1,71},  {1,81},  {2,4},   {2,54},  {3,8},   {4,56},  {4,73},
1474    {5,11},  {6,51},  {7,92},  {8,89},  {9,9},   {9,10},  {9,39},  {9,41},
1475    {9,58},  {9,59},  {9,86},  {10,90}, {11,6},  {12,64}, {13,49}, {14,44},
1476    {15,40}, {16,69}, {17,15}, {18,23}, {18,43}, {19,82},
1477};
1478
1479static const int fn2_game_key_scheduling[27][2] =
1480{
1481    {0,0},   {1,3},   {1,35},  {2,11},  {3,20},  {4,22},  {5,23},  {6,29},
1482    {7,38},  {8,39},  {9,47},  {9,55},  {9,86},  {9,87},  {9,90},  {10,50},
1483    {10,53}, {11,57}, {12,59}, {13,61}, {13,64}, {14,63}, {15,67}, {16,72},
1484    {17,83}, {18,88}, {19,94},
1485};
1486
1487static const int fn1_sequence_key_scheduling[20][2] =
1488{
1489    {0,52},  {1,34},  {2,17},  {3,36}, {4,84},  {4,88},  {5,57},  {6,48},
1490    {6,68},  {7,76},  {8,83},  {9,30}, {10,22}, {10,41}, {11,38}, {12,55},
1491    {13,74}, {14,19}, {14,80}, {15,26}
1492};
1493
1494static const int fn2_sequence_key_scheduling[16] = {77,34,8,42,36,27,69,66,13,9,79,31,49,7,24,64};
1495
1496static const int fn2_middle_result_scheduling[16] = {1,10,44,68,74,78,81,95,2,4,30,40,41,51,53,58};
1497
1498static int feistel_function(int input, const struct sbox* sboxes, UINT32 subkeys)
1499{
1500    int k,m;
1501    int aux;
1502    int result=0;
1503
1504    for (m=0; m<4; ++m)  // 4 sboxes
1505    {
1506        for (k=0, aux=0; k<6; ++k)
1507        {
1508            if (sboxes[m].inputs[k]!=-1)
1509            {
1510                aux |= (BIT(input, sboxes[m].inputs[k])<<k);
1511            }
1512        }
1513
1514        aux = sboxes[m].table[(aux^subkeys)&0x3f];
1515
1516        for (k=0; k<2; ++k)
1517        {
1518            result |= (BIT(aux,k)<<sboxes[m].outputs[k]);
1519        }
1520
1521        subkeys >>=6;
1522    }
1523
1524    return result;
1525}
1526
1527/**************************
1528This implementation is an "educational" version. It must be noted that it can be speed-optimized in a number of ways.
1529The most evident one is to factor out the parts of the key-scheduling that must only be done once (like the game-key &
1530sequence-key parts) as noted in the comments inlined in the function. More sophisticated speed-ups can be gained by
1531noticing that the weak key-scheduling would allow to create some pregenerated look-up tables for doing most of the work
1532of the function. Even so, it would still be pretty slow, so caching techniques could be a wiser option here.
1533**************************/
1534
1535static UINT16 block_decrypt(UINT32 game_key, UINT16 sequence_key, UINT16 counter, UINT16 data)
1536{
1537    int j;
1538    int aux,aux2;
1539    int A,B;
1540    int middle_result;
1541    UINT32 fn1_subkeys[4];
1542    UINT32 fn2_subkeys[4];
1543
1544    /* Game-key scheduling; this could be done just once per game at initialization time */
1545    memset(fn1_subkeys,0,sizeof(UINT32)*4);
1546    memset(fn2_subkeys,0,sizeof(UINT32)*4);
1547
1548    for (j=0; j<30; ++j)
1549    {
1550        if (BIT(game_key, fn1_game_key_scheduling[j][0])!=0)
1551        {
1552            aux = fn1_game_key_scheduling[j][1]%24;
1553            aux2 = fn1_game_key_scheduling[j][1]/24;
1554            fn1_subkeys[aux2] ^= (1<<aux);
1555        }
1556    }
1557
1558    for (j=0; j<27; ++j)
1559    {
1560        if (BIT(game_key, fn2_game_key_scheduling[j][0])!=0)
1561        {
1562            aux = fn2_game_key_scheduling[j][1]%24;
1563            aux2 = fn2_game_key_scheduling[j][1]/24;
1564            fn2_subkeys[aux2] ^= (1<<aux);
1565        }
1566    }
1567    /********************************************************/
1568
1569    /* Sequence-key scheduling; this could be done just once per decryption run */
1570    for (j=0; j<20; ++j)
1571    {
1572        if (BIT(sequence_key,fn1_sequence_key_scheduling[j][0])!=0)
1573        {
1574            aux = fn1_sequence_key_scheduling[j][1]%24;
1575            aux2 = fn1_sequence_key_scheduling[j][1]/24;
1576            fn1_subkeys[aux2] ^= (1<<aux);
1577        }
1578    }
1579
1580    for (j=0; j<16; ++j)
1581    {
1582        if (BIT(sequence_key,j)!=0)
1583        {
1584            aux = fn2_sequence_key_scheduling[j]%24;
1585            aux2 = fn2_sequence_key_scheduling[j]/24;
1586            fn2_subkeys[aux2] ^= (1<<aux);
1587        }
1588    }
1589
1590    // subkeys bits 10 & 41
1591    fn2_subkeys[0] ^= (BIT(sequence_key,2)<<10);
1592    fn2_subkeys[1] ^= (BIT(sequence_key,4)<<17);
1593    /**************************************************************/
1594
1595    // First Feistel Network
1596
1597    aux = BITSWAP16(counter,5,12,14,13,9,3,6,4,    8,1,15,11,0,7,10,2);
1598
1599    // 1st round
1600    B = aux >> 8;
1601    A = (aux & 0xff) ^ feistel_function(B,fn1_sboxes[0],fn1_subkeys[0]);
1602
1603    // 2nd round
1604    B = B ^ feistel_function(A,fn1_sboxes[1],fn1_subkeys[1]);
1605
1606    // 3rd round
1607    A = A ^ feistel_function(B,fn1_sboxes[2],fn1_subkeys[2]);
1608
1609    // 4th round
1610    B = B ^ feistel_function(A,fn1_sboxes[3],fn1_subkeys[3]);
1611
1612    middle_result = (B<<8)|A;
1613
1614
1615    /* Middle-result-key sheduling */
1616    for (j=0; j<16; ++j)
1617    {
1618        if (BIT(middle_result,j)!=0)
1619        {
1620            aux = fn2_middle_result_scheduling[j]%24;
1621            aux2 = fn2_middle_result_scheduling[j]/24;
1622            fn2_subkeys[aux2] ^= (1<<aux);
1623        }
1624    }
1625    /*********************/
1626
1627    // Second Feistel Network
1628
1629    aux = BITSWAP16(data,14,3,8,12,13,7,15,4,    6,2,9,5,11,0,1,10);
1630
1631    // 1st round
1632    B = aux >> 8;
1633    A = (aux & 0xff) ^ feistel_function(B,fn2_sboxes[0],fn2_subkeys[0]);
1634
1635    // 2nd round
1636    B = B ^ feistel_function(A,fn2_sboxes[1],fn2_subkeys[1]);
1637
1638    // 3rd round
1639    A = A ^ feistel_function(B,fn2_sboxes[2],fn2_subkeys[2]);
1640
1641    // 4th round
1642    B = B ^ feistel_function(A,fn2_sboxes[3],fn2_subkeys[3]);
1643
1644    aux = (B<<8)|A;
1645
1646    aux = BITSWAP16(aux,15,7,6,14,13,12,5,4,    3,2,11,10,9,1,0,8);
1647
1648    return aux;
1649}
1650
1651static void stream_decrypt(UINT32 game_key, UINT32 sequence_key, UINT16 seed, UINT8* ciphertext, UINT8* plaintext, int length)
1652{
1653    UINT16 counter = seed;
1654    UINT16 last_word;
1655    UINT16 plain_word;
1656    UINT16 aux_word;
1657    int control_bits;
1658    UINT16 heading_word;
1659
1660    last_word = block_decrypt(game_key, sequence_key, counter, *ciphertext<<8 | *(ciphertext+1));
1661    control_bits = last_word&3;
1662    ++counter; ciphertext+=2;
1663
1664    aux_word = block_decrypt(game_key, sequence_key, counter, *ciphertext<<8 | *(ciphertext+1));
1665    heading_word = (last_word&~3) | (aux_word&3);
1666    last_word = aux_word;
1667    ++counter; ciphertext+=2;
1668
1669    if (BIT(control_bits,1)==0)  // no decompression, just decryption
1670    {
1671        for (; length>0; length-=2, ++counter, ciphertext+=2)
1672        {
1673            aux_word = block_decrypt(game_key, sequence_key, counter, *ciphertext<<8 | *(ciphertext+1));
1674            plain_word = (last_word&~3) | (aux_word&3);
1675            last_word = aux_word;
1676
1677            *(plaintext++) = plain_word>>8;
1678            *(plaintext++) = plain_word&0xff;
1679        }
1680    }
1681    else  // decryption plus decompression
1682    {
1683       fatalerror("NAOMI ASIC compression unsupported\n");
1684        return;  // not implemented, decompression has not been fully reverse engineered as of february/2010
1685    }
1686}
1687
9761688/***************************************************************************
9771689    DEVICE INTERFACE
9781690***************************************************************************/
r7500r7501
10101722      {
10111723         v->prot_translate = &naomibd_translate_tbl[i].transtbl[0];
10121724         v->prot_reverse_bytes = naomibd_translate_tbl[i].reverse_bytes;
1725         v->dc_gamekey = naomibd_translate_tbl[i].live_key;
10131726         break;
10141727      }
10151728   }
src/mame/machine/mcr.c
r7500r7501
253253};
254254
255255
256const z80pio_interface nflfoot_pio_intf =
256Z80PIO_INTERFACE( nflfoot_pio_intf )
257257{
258258   DEVCB_CPU_INPUT_LINE("ipu", INPUT_LINE_IRQ0),  /* interrupt handler */
259259   DEVCB_NULL,
src/mame/machine/maniach.c
r7500r7501
1111#include "includes/matmania.h"
1212
1313
14static UINT8 from_main,from_mcu;
15static int mcu_sent = 0,main_sent = 0;
16
17
1814/***************************************************************************
1915
2016 Mania Challenge 68705 protection interface
r7500r7501
2319
2420***************************************************************************/
2521
26static UINT8 portA_in,portA_out,ddrA;
22READ8_HANDLER( maniach_68705_port_a_r )
23{
24   matmania_state *state = (matmania_state *)space->machine->driver_data;
2725
28READ8_HANDLER( maniach_68705_portA_r )
29{
30//logerror("%04x: 68705 port A read %02x\n",cpu_get_pc(space->cpu),portA_in);
31   return (portA_out & ddrA) | (portA_in & ~ddrA);
26   //logerror("%04x: 68705 port A read %02x\n", cpu_get_pc(space->cpu), state->port_a_in);
27   return (state->port_a_out & state->ddr_a) | (state->port_a_in & ~state->ddr_a);
3228}
3329
34WRITE8_HANDLER( maniach_68705_portA_w )
30WRITE8_HANDLER( maniach_68705_port_a_w )
3531{
36//logerror("%04x: 68705 port A write %02x\n",cpu_get_pc(space->cpu),data);
37   portA_out = data;
32   matmania_state *state = (matmania_state *)space->machine->driver_data;
33
34   //logerror("%04x: 68705 port A write %02x\n", cpu_get_pc(space->cpu), data);
35   state->port_a_out = data;
3836}
3937
40WRITE8_HANDLER( maniach_68705_ddrA_w )
38WRITE8_HANDLER( maniach_68705_ddr_a_w )
4139{
42   ddrA = data;
40   matmania_state *state = (matmania_state *)space->machine->driver_data;
41   state->ddr_a = data;
4342}
4443
4544
r7500r7501
5352 *  2   W  when 0->1, copies port A to the latch for the main CPU
5453 */
5554
56static UINT8 portB_in,portB_out,ddrB;
57
58READ8_HANDLER( maniach_68705_portB_r )
55READ8_HANDLER( maniach_68705_port_b_r )
5956{
60   return (portB_out & ddrB) | (portB_in & ~ddrB);
57   matmania_state *state = (matmania_state *)space->machine->driver_data;
58   return (state->port_b_out & state->ddr_b) | (state->port_b_in & ~state->ddr_b);
6159}
6260
63WRITE8_HANDLER( maniach_68705_portB_w )
61WRITE8_HANDLER( maniach_68705_port_b_w )
6462{
65//logerror("%04x: 68705 port B write %02x\n",cpu_get_pc(space->cpu),data);
63   matmania_state *state = (matmania_state *)space->machine->driver_data;
6664
67   if ((ddrB & 0x02) && (~data & 0x02) && (portB_out & 0x02))
65   //logerror("%04x: 68705 port B write %02x\n", cpu_get_pc(space->cpu), data);
66
67   if (BIT(state->ddr_b, 1) && BIT(~data, 1) && BIT(state->port_b_out, 1))
6868   {
69      portA_in = from_main;
70      main_sent = 0;
71//logerror("read command %02x from main cpu\n",portA_in);
69      state->port_a_in = state->from_main;
70      state->main_sent = 0;
71      //logerror("read command %02x from main cpu\n", state->port_a_in);
7272   }
73   if ((ddrB & 0x04) && (data & 0x04) && (~portB_out & 0x04))
73   if (BIT(state->ddr_b, 2) && BIT(data, 2) && BIT(~state->port_b_out, 2))
7474   {
75//logerror("send command %02x to main cpu\n",portA_out);
76      from_mcu = portA_out;
77      mcu_sent = 1;
75      //logerror("send command %02x to main cpu\n", state->port_a_out);
76      state->from_mcu = state->port_a_out;
77      state->mcu_sent = 1;
7878   }
7979
80   portB_out = data;
80   state->port_b_out = data;
8181}
8282
83WRITE8_HANDLER( maniach_68705_ddrB_w )
83WRITE8_HANDLER( maniach_68705_ddr_b_w )
8484{
85   ddrB = data;
85   matmania_state *state = (matmania_state *)space->machine->driver_data;
86   state->ddr_b = data;
8687}
8788
8889
89static UINT8 portC_in,portC_out,ddrC;
90READ8_HANDLER( maniach_68705_port_c_r )
91{
92   matmania_state *state = (matmania_state *)space->machine->driver_data;
9093
91READ8_HANDLER( maniach_68705_portC_r )
92{
93   portC_in = 0;
94   if (main_sent) portC_in |= 0x01;
95   if (!mcu_sent) portC_in |= 0x02;
96//logerror("%04x: 68705 port C read %02x\n",cpu_get_pc(space->cpu),portC_in);
97   return (portC_out & ddrC) | (portC_in & ~ddrC);
94   state->port_c_in = 0;
95
96   if (state->main_sent)
97      state->port_c_in |= 0x01;
98
99   if (!state->mcu_sent)
100      state->port_c_in |= 0x02;
101
102   //logerror("%04x: 68705 port C read %02x\n",state->cpu_get_pc(space->cpu), state->port_c_in);
103
104   return (state->port_c_out & state->ddr_c) | (state->port_c_in & ~state->ddr_c);
98105}
99106
100WRITE8_HANDLER( maniach_68705_portC_w )
107WRITE8_HANDLER( maniach_68705_port_c_w )
101108{
102//logerror("%04x: 68705 port C write %02x\n",cpu_get_pc(space->cpu),data);
103   portC_out = data;
109   matmania_state *state = (matmania_state *)space->machine->driver_data;
110
111   //logerror("%04x: 68705 port C write %02x\n", cpu_get_pc(space->cpu), data);
112   state->port_c_out = data;
104113}
105114
106WRITE8_HANDLER( maniach_68705_ddrC_w )
115WRITE8_HANDLER( maniach_68705_ddr_c_w )
107116{
108   ddrC = data;
117   matmania_state *state = (matmania_state *)space->machine->driver_data;
118   state->ddr_c = data;
109119}
110120
111121
112122WRITE8_HANDLER( maniach_mcu_w )
113123{
114//logerror("%04x: 3040_w %02x\n",cpu_get_pc(space->cpu),data);
115   from_main = data;
116   main_sent = 1;
124   matmania_state *state = (matmania_state *)space->machine->driver_data;
125
126   //logerror("%04x: 3040_w %02x\n", cpu_get_pc(space->cpu), data);
127   state->from_main = data;
128   state->main_sent = 1;
117129}
118130
119131READ8_HANDLER( maniach_mcu_r )
120132{
121//logerror("%04x: 3040_r %02x\n",cpu_get_pc(space->cpu),from_mcu);
122   mcu_sent = 0;
123   return from_mcu;
133   matmania_state *state = (matmania_state *)space->machine->driver_data;
134
135   //logerror("%04x: 3040_r %02x\n", cpu_get_pc(space->cpu), state->from_mcu);
136   state->mcu_sent = 0;
137   return state->from_mcu;
124138}
125139
126140READ8_HANDLER( maniach_mcu_status_r )
127141{
142   matmania_state *state = (matmania_state *)space->machine->driver_data;
128143   int res = 0;
129144
130145   /* bit 0 = when 0, mcu has sent data to the main cpu */
131146   /* bit 1 = when 1, mcu is ready to receive data from main cpu */
132//logerror("%04x: 3041_r\n",cpu_get_pc(space->cpu));
133   if (!mcu_sent) res |= 0x01;
134   if (!main_sent) res |= 0x02;
147   //logerror("%04x: 3041_r\n", cpu_get_pc(space->cpu));
148   if (!state->mcu_sent)
149      res |= 0x01;
150   if (!state->main_sent)
151      res |= 0x02;
135152
136153   return res;
137154}
src/mame/machine/lsasquad.c
r7500r7501
22#include "cpu/z80/z80.h"
33#include "includes/lsasquad.h"
44
5
6/* coin inputs are inverted in storming */
7int lsasquad_invertcoin;
8
9
105/***************************************************************************
116
127 main <-> sound CPU communication
138
149***************************************************************************/
1510
16static int sound_nmi_enable,pending_nmi,sound_cmd,sound_result;
17int lsasquad_sound_pending;
18
1911static TIMER_CALLBACK( nmi_callback )
2012{
21   if (sound_nmi_enable) cputag_set_input_line(machine, "audiocpu", INPUT_LINE_NMI, PULSE_LINE);
22   else pending_nmi = 1;
13   lsasquad_state *state = (lsasquad_state *)machine->driver_data;
14
15   if (state->sound_nmi_enable)
16      cpu_set_input_line(state->audiocpu, INPUT_LINE_NMI, PULSE_LINE);
17   else
18      state->pending_nmi = 1;
2319}
2420
2521WRITE8_HANDLER( lsasquad_sh_nmi_disable_w )
2622{
27   sound_nmi_enable = 0;
23   lsasquad_state *state = (lsasquad_state *)space->machine->driver_data;
24   state->sound_nmi_enable = 0;
2825}
2926
3027WRITE8_HANDLER( lsasquad_sh_nmi_enable_w )
3128{
32   sound_nmi_enable = 1;
33   if (pending_nmi)
29   lsasquad_state *state = (lsasquad_state *)space->machine->driver_data;
30
31   state->sound_nmi_enable = 1;
32   if (state->pending_nmi)
3433   {
35      cputag_set_input_line(space->machine, "audiocpu", INPUT_LINE_NMI, PULSE_LINE);
36      pending_nmi = 0;
34      cpu_set_input_line(state->audiocpu, INPUT_LINE_NMI, PULSE_LINE);
35      state->pending_nmi = 0;
3736   }
3837}
3938
4039WRITE8_HANDLER( lsasquad_sound_command_w )
4140{
42   lsasquad_sound_pending |= 0x01;
43   sound_cmd = data;
44//logerror("%04x: sound cmd %02x\n",cpu_get_pc(space->cpu),data);
45   timer_call_after_resynch(space->machine, NULL, data,nmi_callback);
41   lsasquad_state *state = (lsasquad_state *)space->machine->driver_data;
42   state->sound_pending |= 0x01;
43   state->sound_cmd = data;
44
45   //logerror("%04x: sound cmd %02x\n", cpu_get_pc(space->cpu), data);
46   timer_call_after_resynch(space->machine, NULL, data, nmi_callback);
4647}
4748
4849READ8_HANDLER( lsasquad_sh_sound_command_r )
4950{
50   lsasquad_sound_pending &= ~0x01;
51//logerror("%04x: read sound cmd %02x\n",cpu_get_pc(space->cpu),sound_cmd);
52   return sound_cmd;
51   lsasquad_state *state = (lsasquad_state *)space->machine->driver_data;
52   state->sound_pending &= ~0x01;
53   //logerror("%04x: read sound cmd %02x\n", cpu_get_pc(space->cpu), state->sound_cmd);
54   return state->sound_cmd;
5355}
5456
5557WRITE8_HANDLER( lsasquad_sh_result_w )
5658{
57   lsasquad_sound_pending |= 0x02;
58//logerror("%04x: sound res %02x\n",cpu_get_pc(space->cpu),data);
59   sound_result = data;
59   lsasquad_state *state = (lsasquad_state *)space->machine->driver_data;
60   state->sound_pending |= 0x02;
61   //logerror("%04x: sound res %02x\n", cpu_get_pc(space->cpu), data);
62   state->sound_result = data;
6063}
6164
6265READ8_HANDLER( lsasquad_sound_result_r )
6366{
64   lsasquad_sound_pending &= ~0x02;
65//logerror("%04x: read sound res %02x\n",cpu_get_pc(space->cpu),sound_result);
66   return sound_result;
67   lsasquad_state *state = (lsasquad_state *)space->machine->driver_data;
68   state->sound_pending &= ~0x02;
69   //logerror("%04x: read sound res %02x\n", cpu_get_pc(space->cpu), state->sound_result);
70   return state->sound_result;
6771}
6872
6973READ8_HANDLER( lsasquad_sound_status_r )
7074{
75   lsasquad_state *state = (lsasquad_state *)space->machine->driver_data;
76
7177   /* bit 0: message pending for sound cpu */
7278   /* bit 1: message pending for main cpu */
73   return lsasquad_sound_pending;
79   return state->sound_pending;
7480}
7581
7682
7783READ8_HANDLER( daikaiju_sh_sound_command_r )
7884{
79   lsasquad_sound_pending &= ~0x01;
80   lsasquad_sound_pending |= 0x02;
81//logerror("%04x: read sound cmd %02x\n",cpu_get_pc(space->cpu),sound_cmd);
82   return sound_cmd;
85   lsasquad_state *state = (lsasquad_state *)space->machine->driver_data;
86   state->sound_pending &= ~0x01;
87   state->sound_pending |= 0x02;
88   //logerror("%04x: read sound cmd %02x\n", cpu_get_pc(space->cpu), state->sound_cmd);
89   return state->sound_cmd;
8390}
8491
8592READ8_HANDLER( daikaiju_sound_status_r )
8693{
94   lsasquad_state *state = (lsasquad_state *)space->machine->driver_data;
95
8796   /* bit 0: message pending for sound cpu */
8897   /* bit 1: message pending for main cpu */
89   return lsasquad_sound_pending^3;
98   return state->sound_pending ^ 3;
9099}
91100
92101
r7500r7501
98107
99108***************************************************************************/
100109
101static UINT8 from_main,from_mcu;
102static int mcu_sent = 0,main_sent = 0;
110READ8_HANDLER( lsasquad_68705_port_a_r )
111{
112   lsasquad_state *state = (lsasquad_state *)space->machine->driver_data;
103113
104static UINT8 portA_in,portA_out,ddrA;
114   //logerror("%04x: 68705 port A read %02x\n", cpu_get_pc(space->cpu), state->port_a_in);
115   return (state->port_a_out & state->ddr_a) | (state->port_a_in & ~state->ddr_a);
116}
105117
106READ8_HANDLER( lsasquad_68705_portA_r )
118WRITE8_HANDLER( lsasquad_68705_port_a_w )
107119{
108//logerror("%04x: 68705 port A read %02x\n",cpu_get_pc(space->cpu),portA_in);
109   return (portA_out & ddrA) | (portA_in & ~ddrA);
110}
120   lsasquad_state *state = (lsasquad_state *)space->machine->driver_data;
111121
112WRITE8_HANDLER( lsasquad_68705_portA_w )
113{
114//logerror("%04x: 68705 port A write %02x\n",cpu_get_pc(space->cpu),data);
115   portA_out = data;
122   //logerror("%04x: 68705 port A write %02x\n", cpu_get_pc(space->cpu), data);
123   state->port_a_out = data;
116124}
117125
118WRITE8_HANDLER( lsasquad_68705_ddrA_w )
126WRITE8_HANDLER( lsasquad_68705_ddr_a_w )
119127{
120   ddrA = data;
128   lsasquad_state *state = (lsasquad_state *)space->machine->driver_data;
129   state->ddr_a = data;
121130}
122131
123132
r7500r7501
131140 *  2   W  when 0->1, copies port A to the latch for the main CPU
132141 */
133142
134static UINT8 portB_in,portB_out,ddrB;
135
136READ8_HANDLER( lsasquad_68705_portB_r )
143READ8_HANDLER( lsasquad_68705_port_b_r )
137144{
138   return (portB_out & ddrB) | (portB_in & ~ddrB);
145   lsasquad_state *state = (lsasquad_state *)space->machine->driver_data;
146   return (state->port_b_out & state->ddr_b) | (state->port_b_in & ~state->ddr_b);
139147}
140148
141WRITE8_HANDLER( lsasquad_68705_portB_w )
149WRITE8_HANDLER( lsasquad_68705_port_b_w )
142150{
143//logerror("%04x: 68705 port B write %02x\n",cpu_get_pc(space->cpu),data);
151   lsasquad_state *state = (lsasquad_state *)space->machine->driver_data;
144152
145   if ((ddrB & 0x02) && (~data & 0x02) && (portB_out & 0x02))
153   //logerror("%04x: 68705 port B write %02x\n", cpu_get_pc(space->cpu), data);
154
155   if ((state->ddr_b & 0x02) && (~data & 0x02) && (state->port_b_out & 0x02))
146156   {
147      portA_in = from_main;
148      if (main_sent) cputag_set_input_line(space->machine, "mcu", 0, CLEAR_LINE);
149      main_sent = 0;
150//logerror("read command %02x from main cpu\n",portA_in);
157      state->port_a_in = state->from_main;
158      if (state->main_sent)
159         cpu_set_input_line(state->mcu, 0, CLEAR_LINE);
160      state->main_sent = 0;
161      //logerror("read command %02x from main cpu\n", state->port_a_in);
151162   }
152   if ((ddrB & 0x04) && (data & 0x04) && (~portB_out & 0x04))
163
164   if ((state->ddr_b & 0x04) && (data & 0x04) && (~state->port_b_out & 0x04))
153165   {
154//logerror("send command %02x to main cpu\n",portA_out);
155      from_mcu = portA_out;
156      mcu_sent = 1;
166      //logerror("send command %02x to main cpu\n", state->port_a_out);
167      state->from_mcu = state->port_a_out;
168      state->mcu_sent = 1;
157169   }
158170
159   portB_out = data;
171   state->port_b_out = data;
160172}
161173
162WRITE8_HANDLER( lsasquad_68705_ddrB_w )
174WRITE8_HANDLER( lsasquad_68705_ddr_b_w )
163175{
164   ddrB = data;
176   lsasquad_state *state = (lsasquad_state *)space->machine->driver_data;
177   state->ddr_b = data;
165178}
166179
167180WRITE8_HANDLER( lsasquad_mcu_w )
168181{
169//logerror("%04x: mcu_w %02x\n",cpu_get_pc(space->cpu),data);
170   from_main = data;
171   main_sent = 1;
172   cputag_set_input_line(space->machine, "mcu", 0, ASSERT_LINE);
182   lsasquad_state *state = (lsasquad_state *)space->machine->driver_data;
183
184   //logerror("%04x: mcu_w %02x\n", cpu_get_pc(space->cpu), data);
185   state->from_main = data;
186   state->main_sent = 1;
187   cpu_set_input_line(state->mcu, 0, ASSERT_LINE);
173188}
174189
175190READ8_HANDLER( lsasquad_mcu_r )
176191{
177//logerror("%04x: mcu_r %02x\n",cpu_get_pc(space->cpu),from_mcu);
178   mcu_sent = 0;
179   return from_mcu;
192   lsasquad_state *state = (lsasquad_state *)space->machine->driver_data;
193
194   //logerror("%04x: mcu_r %02x\n", cpu_get_pc(space->cpu), state->from_mcu);
195   state->mcu_sent = 0;
196   return state->from_mcu;
180197}
181198
182199READ8_HANDLER( lsasquad_mcu_status_r )
183200{
201   lsasquad_state *state = (lsasquad_state *)space->machine->driver_data;
184202   int res = input_port_read(space->machine, "MCU?");
185203
186204   /* bit 0 = when 1, mcu is ready to receive data from main cpu */
187205   /* bit 1 = when 0, mcu has sent data to the main cpu */
188//logerror("%04x: mcu_status_r\n",cpu_get_pc(space->cpu));
189   if (!main_sent) res |= 0x01;
190   if (!mcu_sent) res |= 0x02;
206   //logerror("%04x: mcu_status_r\n",cpu_get_pc(space->cpu));
207   if (!state->main_sent)
208      res |= 0x01;
209   if (!state->mcu_sent)
210      res |= 0x02;
191211
192   return res ^ lsasquad_invertcoin;
212   return res ^ state->invertcoin;
193213}
src/mame/machine/cps2crpt.c
r7500r7501
787787   { "xmcotaj",  { 0x46027315,0xaf8bcd9e }, 0x100000 },   // 0C80 1972 0301  cmpi.l  #$19720301,D0
788788   { "xmcotaj1", { 0x46027315,0xaf8bcd9e }, 0x100000 },   // 0C80 1972 0301  cmpi.l  #$19720301,D0
789789   { "xmcotaj2", { 0x46027315,0xaf8bcd9e }, 0x100000 },   // 0C80 1972 0301  cmpi.l  #$19720301,D0
790   { "xmcotaj3", { 0x46027315,0xaf8bcd9e }, 0x100000 },   // 0C80 1972 0301  cmpi.l  #$19720301,D0
790791   { "xmcotajr", { 0x46027315,0xaf8bcd9e }, 0x100000 },   // 0C80 1972 0301  cmpi.l  #$19720301,D0
791792   { "xmcotaa",  { 0x0795a4e2,0xdb3f861c }, 0x100000 },   // 0C80 1972 0301  cmpi.l  #$19720301,D0
792793   { "armwar",   { 0x9e9d4c0b,0x8a39081f }, 0x100000 },   // 3039 0080 4020  move.w  $00804020,D0
src/mame/machine/namco51.c
r7500r7501
396396   /* resolve our write callbacks */
397397   devcb_resolve_write8(&state->out[0], &config->out[0], device);
398398   devcb_resolve_write8(&state->out[1], &config->out[1], device);
399
399#if 0
400   INT32 lastcoins,lastbuttons;
401   INT32 credits;
402   INT32 coins[2];
403   INT32 coins_per_cred[2];
404   INT32 creds_per_coin[2];
405   INT32 in_count;
406   INT32 mode,coincred_mode,remap_joy;
407#endif
400408   state_save_register_device_item(device, 0, state->lastcoins);
401409   state_save_register_device_item(device, 0, state->lastbuttons);
402410   state_save_register_device_item(device, 0, state->credits);
r7500r7501
404412   state_save_register_device_item_array(device, 0, state->coins_per_cred);
405413   state_save_register_device_item_array(device, 0, state->creds_per_coin);
406414   state_save_register_device_item(device, 0, state->in_count);
415   state_save_register_device_item(device, 0, state->mode);
416   state_save_register_device_item(device, 0, state->coincred_mode);
417   state_save_register_device_item(device, 0, state->remap_joy);
407418}
408419
409420
src/mame/machine/slapstic.c
r7500r7501
615615};
616616
617617
618/* slapstic 137412-114: Unknown (Europe) (unconfirmed) */
618/* slapstic 137412-114: Pit Fighter (rev 9) (confirmed) */
619619static const struct slapstic_data slapstic114 =
620620{
621621   /* basic banking */
src/mame/machine/nitedrvr.c
r7500r7501
88#include "includes/nitedrvr.h"
99#include "sound/discrete.h"
1010
11static UINT8 nitedrvr_gear;
12static UINT8 nitedrvr_track;
13static INT32 nitedrvr_steering_buf;
14static INT32 nitedrvr_steering_val;
15static UINT8 nitedrvr_crash_en;
16static UINT8 nitedrvr_crash_data;
17static UINT8 nitedrvr_crash_data_en;   // IC D8
18static UINT8 ac_line;
19static INT32 last_steering_val;
20
2111/***************************************************************************
2212Steering
2313
r7500r7501
2717because D6 and D7 are apparently checked at different times, and a
2818change in-between can affect the direction you move.
2919***************************************************************************/
30static int nitedrvr_steering(running_machine *machine)
20
21static int nitedrvr_steering( running_machine *machine )
3122{
32   int this_val;
33   int delta;
23   nitedrvr_state *state = (nitedrvr_state *)machine->driver_data;
24   int this_val = input_port_read(machine, "STEER");
25   int delta = this_val - state->last_steering_val;
3426
35   this_val = input_port_read(machine, "STEER");
27   state->last_steering_val = this_val;
3628
37   delta=this_val-last_steering_val;
38   last_steering_val=this_val;
39   if (delta>128) delta-=256;
40   else if (delta<-128) delta+=256;
29   if (delta > 128)
30      delta -= 256;
31   else if (delta < -128)
32      delta += 256;
33
4134   /* Divide by four to make our steering less sensitive */
42   nitedrvr_steering_buf+=(delta/4);
35   state->steering_buf += (delta / 4);
4336
44   if (nitedrvr_steering_buf>0)
37   if (state->steering_buf > 0)
4538   {
46      nitedrvr_steering_buf--;
47      nitedrvr_steering_val=0xC0;
39      state->steering_buf--;
40      state->steering_val = 0xc0;
4841   }
49   else if (nitedrvr_steering_buf<0)
42   else if (state->steering_buf < 0)
5043   {
51      nitedrvr_steering_buf++;
52      nitedrvr_steering_val=0x80;
44      state->steering_buf++;
45      state->steering_val = 0x80;
5346   }
5447   else
5548   {
56      nitedrvr_steering_val=0x00;
49      state->steering_val = 0x00;
5750   }
5851
59   return nitedrvr_steering_val;
52   return state->steering_val;
6053}
6154
6255/***************************************************************************
6356nitedrvr_steering_reset
6457***************************************************************************/
58
6559READ8_HANDLER( nitedrvr_steering_reset_r )
6660{
67   nitedrvr_steering_val = 0;
61   nitedrvr_state *state = (nitedrvr_state *)space->machine->driver_data;
62   state->steering_val = 0;
6863   return 0;
6964}
7065
7166WRITE8_HANDLER( nitedrvr_steering_reset_w )
7267{
73   nitedrvr_steering_val = 0;
68   nitedrvr_state *state = (nitedrvr_state *)space->machine->driver_data;
69   state->steering_val = 0;
7470}
7571
7672
r7500r7501
104100
105101READ8_HANDLER( nitedrvr_in0_r )
106102{
107   int gear;
103   nitedrvr_state *state = (nitedrvr_state *)space->machine->driver_data;
104   int gear = input_port_read(space->machine, "GEARS");
108105
109   gear = input_port_read(space->machine, "GEARS");
110   if (gear & 0x10)            nitedrvr_gear=1;
111   else if (gear & 0x20)         nitedrvr_gear=2;
112   else if (gear & 0x40)         nitedrvr_gear=3;
113   else if (gear & 0x80)         nitedrvr_gear=4;
106   if (gear & 0x10)            state->gear = 1;
107   else if (gear & 0x20)         state->gear = 2;
108   else if (gear & 0x40)         state->gear = 3;
109   else if (gear & 0x80)         state->gear = 4;
114110
115111   switch (offset & 0x03)
116112   {
r7500r7501
119115      case 0x01:                  /* No remapping necessary */
120116         return input_port_read(space->machine, "DSW1");
121117      case 0x02:                  /* Remap our gear shift */
122         if (nitedrvr_gear==1)      return 0xE0;
123         else if (nitedrvr_gear==2)   return 0xD0;
124         else if (nitedrvr_gear==3)   return 0xB0;
125         else                  return 0x70;
118         if (state->gear == 1)
119            return 0xe0;
120         else if (state->gear == 2)
121            return 0xd0;
122         else if (state->gear == 3)
123            return 0xb0;
124         else
125            return 0x70;
126126      case 0x03:                  /* Remap our steering */
127127         return (input_port_read(space->machine, "DSW2") | nitedrvr_steering(space->machine));
128128      default:
129         return 0xFF;
129         return 0xff;
130130   }
131131}
132132
r7500r7501
164164
165165READ8_HANDLER( nitedrvr_in1_r )
166166{
167   int port;
167   nitedrvr_state *state = (nitedrvr_state *)space->machine->driver_data;
168   int port = input_port_read(space->machine, "IN0");
168169
169   ac_line=(ac_line+1) % 3;
170   state->ac_line = (state->ac_line + 1) % 3;
170171
171   port = input_port_read(space->machine, "IN0");
172   if (port & 0x10)            nitedrvr_track=0;
173   else if (port & 0x20)         nitedrvr_track=1;
174   else if (port & 0x40)         nitedrvr_track=2;
172   if (port & 0x10)            state->track = 0;
173   else if (port & 0x20)         state->track = 1;
174   else if (port & 0x40)         state->track = 2;
175175
176176   switch (offset & 0x07)
177177   {
r7500r7501
184184      case 0x03:
185185         return ((port & 0x08) << 4);
186186      case 0x04:
187         if (nitedrvr_track == 1) return 0x80; else return 0x00;
187         if (state->track == 1) return 0x80; else return 0x00;
188188      case 0x05:
189         if (nitedrvr_track == 0) return 0x80; else return 0x00;
189         if (state->track == 0) return 0x80; else return 0x00;
190190      case 0x06:
191191         /* TODO: fix alternating signal? */
192         if (ac_line==0) return 0x80; else return 0x00;
192         if (state->ac_line==0) return 0x80; else return 0x00;
193193      case 0x07:
194194         return 0x00;
195195      default:
196         return 0xFF;
196         return 0xff;
197197   }
198198}
199199
r7500r7501
209209D4 = SKID1
210210D5 = SKID2
211211***************************************************************************/
212
212213WRITE8_HANDLER( nitedrvr_out0_w )
213214{
214   running_device *discrete = devtag_get_device(space->machine, "discrete");
215   discrete_sound_w(discrete, NITEDRVR_MOTOR_DATA, data & 0x0f);   // Motor freq data
216   discrete_sound_w(discrete, NITEDRVR_SKID1_EN, data & 0x10);   // Skid1 enable
217   discrete_sound_w(discrete, NITEDRVR_SKID2_EN, data & 0x20);   // Skid2 enable
215   nitedrvr_state *state = (nitedrvr_state *)space->machine->driver_data;
216
217   discrete_sound_w(state->discrete, NITEDRVR_MOTOR_DATA, data & 0x0f);   // Motor freq data
218   discrete_sound_w(state->discrete, NITEDRVR_SKID1_EN, data & 0x10);   // Skid1 enable
219   discrete_sound_w(state->discrete, NITEDRVR_SKID2_EN, data & 0x20);   // Skid2 enable
218220}
219221
220222/***************************************************************************
r7500r7501
227229D4 = LED START
228230D5 = Spare (Not used)
229231***************************************************************************/
232
230233WRITE8_HANDLER( nitedrvr_out1_w )
231234{
232   running_device *discrete = devtag_get_device(space->machine, "discrete");
235   nitedrvr_state *state = (nitedrvr_state *)space->machine->driver_data;
233236
234   set_led_status(space->machine, 0,data & 0x10);
237   set_led_status(space->machine, 0, data & 0x10);
235238
236   nitedrvr_crash_en = data & 0x01;
237   discrete_sound_w(discrete, NITEDRVR_CRASH_EN, nitedrvr_crash_en);   // Crash enable
238   discrete_sound_w(discrete, NITEDRVR_ATTRACT_EN, data & 0x02);      // Attract enable (sound disable)
239   state->crash_en = data & 0x01;
239240
240   if (!nitedrvr_crash_en)
241   discrete_sound_w(state->discrete, NITEDRVR_CRASH_EN, state->crash_en);   // Crash enable
242   discrete_sound_w(state->discrete, NITEDRVR_ATTRACT_EN, data & 0x02);      // Attract enable (sound disable)
243
244   if (!state->crash_en)
241245   {
242246      /* Crash reset, set counter high and enable output */
243      nitedrvr_crash_data_en = 1;
244      nitedrvr_crash_data = 0x0f;
247      state->crash_data_en = 1;
248      state->crash_data = 0x0f;
245249      /* Invert video */
246      palette_set_color(space->machine,1,MAKE_RGB(0x00,0x00,0x00)); /* BLACK */
247      palette_set_color(space->machine,0,MAKE_RGB(0xff,0xff,0xff)); /* WHITE */
250      palette_set_color(space->machine, 1, MAKE_RGB(0x00,0x00,0x00)); /* BLACK */
251      palette_set_color(space->machine, 0, MAKE_RGB(0xff,0xff,0xff)); /* WHITE */
248252   }
249   discrete_sound_w(discrete, NITEDRVR_BANG_DATA, nitedrvr_crash_data_en ? nitedrvr_crash_data : 0);   // Crash Volume
253   discrete_sound_w(state->discrete, NITEDRVR_BANG_DATA, state->crash_data_en ? state->crash_data : 0);   // Crash Volume
250254}
251255
252256
253257TIMER_DEVICE_CALLBACK( nitedrvr_crash_toggle_callback )
254258{
255   if (nitedrvr_crash_en && nitedrvr_crash_data_en)
259   nitedrvr_state *state = (nitedrvr_state *)timer->machine->driver_data;
260
261   if (state->crash_en && state->crash_data_en)
256262   {
257      running_device *discrete = devtag_get_device(timer->machine, "discrete");
263      state->crash_data--;
264      discrete_sound_w(state->discrete, NITEDRVR_BANG_DATA, state->crash_data);   // Crash Volume
265      if (!state->crash_data)
266         state->crash_data_en = 0;   // Done counting?
258267
259      nitedrvr_crash_data--;
260      discrete_sound_w(discrete, NITEDRVR_BANG_DATA, nitedrvr_crash_data);   // Crash Volume
261      if (!nitedrvr_crash_data) nitedrvr_crash_data_en = 0;   // Done counting?
262      if (nitedrvr_crash_data & 0x01)
268      if (state->crash_data & 0x01)
263269      {
264270         /* Invert video */
265         palette_set_color(timer->machine,1,MAKE_RGB(0x00,0x00,0x00)); /* BLACK */
266         palette_set_color(timer->machine,0,MAKE_RGB(0xff,0xff,0xff)); /* WHITE */
271         palette_set_color(timer->machine, 1, MAKE_RGB(0x00,0x00,0x00)); /* BLACK */
272         palette_set_color(timer->machine, 0, MAKE_RGB(0xff,0xff,0xff)); /* WHITE */
267273      }
268274      else
269275      {
270276         /* Normal video */
271         palette_set_color(timer->machine,0,MAKE_RGB(0x00,0x00,0x00)); /* BLACK */
272         palette_set_color(timer->machine,1,MAKE_RGB(0xff,0xff,0xff)); /* WHITE */
277         palette_set_color(timer->machine, 0, MAKE_RGB(0x00,0x00,0x00)); /* BLACK */
278         palette_set_color(timer->machine, 1, MAKE_RGB(0xff,0xff,0xff)); /* WHITE */
273279      }
274280   }
275281}
276282
277283MACHINE_START( nitedrvr )
278284{
279   state_save_register_global(machine, nitedrvr_gear);
280   state_save_register_global(machine, nitedrvr_track);
281   state_save_register_global(machine, nitedrvr_steering_buf);
282   state_save_register_global(machine, nitedrvr_steering_val);
283   state_save_register_global(machine, nitedrvr_crash_en);
284   state_save_register_global(machine, nitedrvr_crash_data);
285   state_save_register_global(machine, nitedrvr_crash_data_en);
286   state_save_register_global(machine, ac_line);
287   state_save_register_global(machine, last_steering_val);
285   nitedrvr_state *state = (nitedrvr_state *)machine->driver_data;
286
287   state->maincpu = devtag_get_device(machine, "maincpu");
288   state->discrete = devtag_get_device(machine, "discrete");
289
290   state_save_register_global(machine, state->gear);
291   state_save_register_global(machine, state->track);
292   state_save_register_global(machine, state->steering_buf);
293   state_save_register_global(machine, state->steering_val);
294   state_save_register_global(machine, state->crash_en);
295   state_save_register_global(machine, state->crash_data);
296   state_save_register_global(machine, state->crash_data_en);
297   state_save_register_global(machine, state->ac_line);
298   state_save_register_global(machine, state->last_steering_val);
288299}
289300
290301MACHINE_RESET( nitedrvr )
291302{
292   nitedrvr_gear = 1;
293   nitedrvr_track = 0;
294   nitedrvr_steering_buf = 0;
295   nitedrvr_steering_val = 0;
296   nitedrvr_crash_en = 0;
297   nitedrvr_crash_data = 0x0f;
298   nitedrvr_crash_data_en = 0;
299   ac_line = 0;
300   last_steering_val = 0;
303   nitedrvr_state *state = (nitedrvr_state *)machine->driver_data;
304
305   state->gear = 1;
306   state->track = 0;
307   state->steering_buf = 0;
308   state->steering_val = 0;
309   state->crash_en = 0;
310   state->crash_data = 0x0f;
311   state->crash_data_en = 0;
312   state->ac_line = 0;
313   state->last_steering_val = 0;
301314}
src/mame/mamedriv.c
r7500r7501
191191   DRIVER( mooncrstu )   /* (c) 1980 Nichibutsu USA */
192192   DRIVER( mooncrsto )   /* (c) 1980 Nichibutsu */
193193   DRIVER( mooncrstg )   /* (c) 1980 Gremlin */
194   DRIVER( mooncrstuk )/* (c) 1980 Nichibutsu UK */
194195   DRIVER( smooncrs )   /* Gremlin */
195196   DRIVER( mooncmw )   /* bootleg */
196197   DRIVER( mooncrsb )   /* bootleg */
r7500r7501
342343   DRIVER( scorpion )   /* (c) 1982 Zaccaria */
343344   DRIVER( scorpiona )   /* (c) 1982 Zaccaria */
344345   DRIVER( scorpionb )   /* (c) 1982 Zaccaria */
346   DRIVER( aracnis )   /* bootleg */
345347   DRIVER( ad2083 )   /* (c) 1983 Midcoin */
346348   DRIVER( turpins )   /* (c) 1981 bootleg */
347349
r7500r7501
928930   DRIVER( motoxgo )   /* (c) 1997 */
929931   DRIVER( timecrs2 )   /* (c) 1997 */
930932   DRIVER( timecrs2b )   /* (c) 1997 */
933   DRIVER( timecrs2c )   /* (c) 1997 */
931934   DRIVER( panicprk )   /* (c) 1998 */
932935   DRIVER( 500gp )      /* (c) 1999 */
933936   DRIVER( finfurl2 )   /* (c) 1999 */
r7500r7501
12941297   DRIVER( indianbt )   /* (c) 1980 Taito */
12951298   DRIVER( steelwkr )   /* (c) 1980 Taito */
12961299   DRIVER( m79amb )   /* (c) 1977 RamTek */
1297   DRIVER( alieninv )   /* bootleg */
1300   DRIVER( alieninv )   /* Margamatics */
1301   DRIVER( alieninvp2 )   /* bootleg */
12981302   DRIVER( tst_invd )   /* Test ROM */
12991303   DRIVER( sitv )      /* (c) 1979 Taito */
13001304   DRIVER( sicv )      /* (c) 1979 Taito */
r7500r7501
18211825   DRIVER( arktayt2 )   /* bootleg */
18221826   DRIVER( arkatour )   /* ??? (c) 1987 Taito America Corporation + Romstar license (US) */
18231827   DRIVER( tetrsark )   /* ??? (c) D.R.Korea */
1828   DRIVER( hexa )      /* D. R. Korea */
18241829   DRIVER( sqix )      /* B03 1987 */
18251830   DRIVER( sqixr1 )   /* B03 1987 */
18261831   DRIVER( sqixu )      /* B03 1987 */
r7500r7501
23182323   DRIVER( batridj )   /* (c) 1998 Raizing/8ing */
23192324   DRIVER( batridk )   /* (c) 1998 Raizing/8ing */
23202325   DRIVER( batridja )   /* (c) 1998 Raizing/8ing */
2326   DRIVER( batridta )   /* (c) 1998 Raizing/8ing */
23212327   DRIVER( bkraidu )   /* (c) 1999 8ing */
23222328   DRIVER( bkraiduj )   /* (c) 1999 8ing */
23232329   DRIVER( bkraidj )   /* (c) 1999 8ing */
r7500r7501
27712777   DRIVER( xmcota )   /* 05/01/1995 (c) 1994 (Euro) */
27722778   DRIVER( xmcotau )   /* 05/01/1995 (c) 1994 (US) */
27732779   DRIVER( xmcotah )   /* 31/03/1995 (c) 1994 (Hispanic) */
2774   DRIVER( xmcotaj )   /* 22/12/1994 (c) 1994 (Japan) */
2775   DRIVER( xmcotaj1 )   /* 19/12/1994 (c) 1994 (Japan) */
2776   DRIVER( xmcotaj2 )   /* 17/12/1994 (c) 1994 (Japan) */
2780   DRIVER( xmcotaj )   /* 05/01/1995 (c) 1994 (Japan) */
2781   DRIVER( xmcotaj1 )   /* 22/12/1994 (c) 1994 (Japan) */
2782   DRIVER( xmcotaj2 )   /* 19/12/1994 (c) 1994 (Japan) */
2783   DRIVER( xmcotaj3 )   /* 17/12/1994 (c) 1994 (Japan) */
27772784   DRIVER( xmcotaa )   /* 17/12/1994 (c) 1994 (Asia) */
27782785   DRIVER( xmcotajr )   /* 08/12/1994 (c) 1994 (Japan Rent) */
27792786   DRIVER( nwarr )      /* 16/03/1995 (c) 1995 (Euro) */
r7500r7501
31623169   DRIVER( ehrgeizj )   /* 1998.05 Ehrgeiz (EG1, Japan) */
31633170   DRIVER( sws98 )      /* 1998.06 Super World Stadium '98 (SS81/VER.A, Japan) */
31643171   DRIVER( soulclbr )   /* 1998.?? Soul Calibur (SOC14/VER.C) */
3172   DRIVER( soulclbrb )   /* 1998.?? Soul Calibur (SOC14/VER.B) */
31653173   DRIVER( soulclbrj )   /* 1998.07 Soul Calibur (SOC11/VER.C, Japan) */
3166   DRIVER( soulclbrb )   /* 1998.?? Soul Calibur (SOC13/VER.B) */
3174   DRIVER( soulclbrb2 )   /* 1998.?? Soul Calibur (SOC13/VER.B) */
31673175   DRIVER( soulclbrjb )/* 1998.?? Soul Calibur (SOC11/VER.B, Japan) */
31683176   DRIVER( soulclbrja )/* 1998.?? Soul Calibur (SOC11/VER.A2, Japan) */
31693177                  /* 1998.07 Techno Drive */
r7500r7501
35453553   DRIVER( depthcho )   /*   ?   [1977 Gremlin?] */
35463554   DRIVER( subhunt )   /*   ?   [1977 Taito] */
35473555   DRIVER( safari )   /* 57-66 [1977 Gremlin?] */
3556   DRIVER( safaria )   /* bootleg? */
35483557   DRIVER( frogs )      /* 112-119 [1978 Gremlin?] */
35493558   DRIVER( sspaceat )   /* 155-162 (c) */
35503559   DRIVER( sspaceat2 )   /* 155-162 (c) 1979 Sega */
r7500r7501
42674276
42684277   /* Step 2.1 */
42694278   DRIVER( daytona2 )   /* 1998.06 Daytona USA 2 */
4270                  /* 1998.09 Ocean Hunter */
4279   DRIVER( oceanhun )   /* 1998.09 Ocean Hunter */
42714280   DRIVER( spikeout )   /* 1998.09 Spikeout */
42724281   DRIVER( dirtdvls )   /* 1998.10 Dirt Devils */
42734282   DRIVER( dirtdvlsa )
42744283   DRIVER( swtrilgy )   /* 1998.11 Star Wars Trilogy Arcade */
42754284   DRIVER( swtrilgya )
42764285                  /* 1998.11 Magical Torokko Adventure (Japan) */
4277                  /* 1998.12 L.A. Machine Guns */
4286   DRIVER( lamachin )   /* 1998.12 L.A. Machine Guns */
42784287   DRIVER( dayto2pe )   /* 1998.12 Daytone USA 2 Power Edition */
42794288                  /* 1998.12 Virtua Striker 2 ver.99 */
42804289   DRIVER( spikeofe )   /* 1999.01 Spikeout Final Edition */
r7500r7501
45494558   DRIVER( chocomk )   /* 2002.06 Musapey no Choco Marker */
45504559                  /* 2002.07 Mazan */
45514560                  /* 2002.09 Yonin Uchi Mahjong MJ */
4552                  /* 2002.12 Azumanga Daiou Puzzle Bobble */
4561   DRIVER( azumanga )   /* 2002.12 Azumanga Daiou Puzzle Bobble */
45534562   DRIVER( moeru )      /* 2002.12 Moeru Casinyo */
45544563   DRIVER( quizqgd )   /* 2003.01 Quiz Keitai Q mode */
45554564                  /* 2003.03 Yonin Uchi Mahjong MJ Network Taisen ver. */
r7500r7501
53355344   DRIVER( battlnts )   /* GX777 (c) 1987 */
53365345   DRIVER( battlntsj )   /* GX777 (c) 1987 (Japan) */
53375346   DRIVER( bladestl )   /* GX797 (c) 1987 */
5347   DRIVER( bladestll )   /* GX797 (c) 1987 */
53385348   DRIVER( bladestle )   /* GX797 (c) 1987 */
53395349   DRIVER( hcastle )   /* GX768 (c) 1988 */
53405350   DRIVER( hcastleo )   /* GX768 (c) 1988 */
r7500r7501
57185728   DRIVER( circusse )   /* bootleg */
57195729   DRIVER( robotbwl )   /* no copyright notice */
57205730   DRIVER( crash )      /* Exidy [1979?] */
5731   DRIVER( smash )      /* bootleg */
57215732   DRIVER( ripcord )   /* Exidy [1977?] */
57225733   DRIVER( starfire )   /* Exidy [1979?] */
57235734   DRIVER( starfirea )   /* Exidy [1979?] */
r7500r7501
61556166   DRIVER( hydrap )   /* (proto)          (c) 1990 */
61566167   DRIVER( hydrap2 )   /* (proto)          (c) 1990 */
61576168   DRIVER( pitfight )   /* 136081           (c) 1990 */
6169   DRIVER( pitfight7 )   /* 136081           (c) 1990 */
61586170   DRIVER( pitfight6 )   /* 136081           (c) 1990 */
61596171   DRIVER( pitfight5 )   /* 136081           (c) 1990 */
61606172   DRIVER( pitfight4 )   /* 136081           (c) 1990 */
r7500r7501
69987010
69997011   /* Midway Touchmaster / Galaxy Games */
70007012   DRIVER( tm )      /* (c) 1996 Midway Games */
7013   DRIVER( tmdo )      /* (c) 1996 Midway Games */
70017014   DRIVER( tm2k )      /* (c) 1996 Midway Games */
70027015   DRIVER( tm3k )      /* (c) 1997 Midway Games */
70037016   DRIVER( tm3ka )      /* (c) 1997 Midway Games */
70047017   DRIVER( tm4k )      /* (c) 1998 Midway Games */
7018   DRIVER( tm4ka )      /* (c) 1998 Midway Games */
70057019   DRIVER( tm5k )      /* (c) 1998 Midway Games */
70067020   DRIVER( tm5kca )   /* (c) 1998 Midway Games */
70077021   DRIVER( tm5ka )      /* (c) 1998 Midway Games */
r7500r7501
70647078   DRIVER( thepit )   /* (c) 1982 Taito */
70657079   DRIVER( thepitc )   /* (c) 1982 Centuri */
70667080   DRIVER( thepitb )   /* bootleg */
7081   DRIVER( thepitm )   /* bootleg */
70677082   DRIVER( dockman )   /* (c) 1982 Taito Corp. */
70687083   DRIVER( portman )   /* (c) 1982 Nova Games Ltd. */
70697084   DRIVER( funnymou )   /* (c) 1982 Chuo Co. Ltd */
r7500r7501
78967911   DRIVER( pushman )   /* (c) 1990 Comad */
78977912   DRIVER( pushmana )   /* (c) 1990 Comad */
78987913   DRIVER( pushmans )   /* (c) 1990 Comad + American Sammy license */
7914   DRIVER( pushmant )   /* (c) 1990 Comad + Top Tronic license */
78997915   DRIVER( bballs )   /* (c) 1991 Comad */
79007916   DRIVER( zerozone )   /* (c) 1993 Comad */
79017917   DRIVER( lvgirl94 )   /* (c) 1994 Comad */
r7500r7501
81238139   DRIVER( janptr96 )   /* 1996 Dynax */
81248140   DRIVER( sprtmtch )   /* "31" (c) 1989 Dynax + Fabtek license */
81258141   DRIVER( maya )      /* (c) 1994 Promat */
8142   DRIVER( mayaa )      /* (c) 1994 Promat */
81268143   DRIVER( inca )      /* (c) 199? ???? */
81278144   DRIVER( blktouch )   /* (c) Yang Gi Co Ltd. */
81288145   DRIVER( mcnpshnt )   /* "33" Mahjong Campus Hunting 1990 Dynax */
r7500r7501
86578674   DRIVER( monzagp )   /* (c) 1981 Olympia */
86588675   DRIVER( dday )      /* (c) 1982 Olympia */
86598676   DRIVER( ddayc )      /* (c) 1982 Olympia + Centuri license */
8660   DRIVER( hexa )      /* D. R. Korea */
86618677   DRIVER( stactics )   /* [1981 Sega] */
86628678   DRIVER( exterm )   /* (c) 1989 Premier Technology - a Gottlieb game */
86638679   DRIVER( kingofb )   /* (c) 1985 Woodplace Inc. */
r7500r7501
92709286   DRIVER( leader )   /* Bootleg? */
92719287   DRIVER( livequiz )   /* (c) 1999 Andamiro */
92729288   DRIVER( cowrace )   /* (c) 20?? hack */
9289   DRIVER( kingdrbb )  /* (c) 199? hack */
92739290   DRIVER( discoboy )   /* (c) 1993 Soft Art Co. */
92749291   DRIVER( pangofun )   /* (c) 1995 InfoCube */
92759292   DRIVER( 2mindril )   /* (c) 1993 Taito */
r7500r7501
94269443   DRIVER( cmv801 )   /* (c) 198? Corsica */
94279444   DRIVER( cmv4 )      /* (c) 1992 Dyna Electronics */
94289445   DRIVER( cmv4a )      /* (c) 1992 Dyna Electronics */
9446   DRIVER( cmwm )      /* (c) 199? Dyna Electronics */
9447   DRIVER( cmfun )      /* (c) 1995 Dyna Electronics */
94299448   DRIVER( cmaster )   /* (c) 1991 Dyna Electronics */
94309449   DRIVER( cmasterb )   /* (c) 1991 Dyna Electronics */
94319450   DRIVER( cmasterc )   /* (c) 1991 Dyna Electronics */
r7500r7501
94779496
94789497   /* Eagle */
94799498   DRIVER( janshi )
9499   DRIVER( pinkiri8 )
94809500
94819501   /* Wing */
94829502   DRIVER( slotcarn )   /* (c) 1985 Wing Co. Ltd */
r7500r7501
96739693   DRIVER( fb6sev2 )   /* (c) 200? Amcoe */
96749694   DRIVER( version4 )   /* (c) 200? Amcoe - Version 4 ? */
96759695   DRIVER( bugfever )   /* (c) 200? Amcoe - Bug Fever */
9696   DRIVER( bugfevero )   /* (c) 200? Amcoe */
96769697   DRIVER( bugfeverd )   /* (c) 200? Amcoe */
96779698   DRIVER( bugfeverv )   /* (c) 200? Amcoe */
9678   DRIVER( bugfeverv2 )/* (c) 200? Amcoe */
9699   DRIVER( bugfeverv2 )   /* (c) 200? Amcoe */
96799700   DRIVER( dvisland )   /* (c) 200? Amcoe - Devil's Island */
96809701   DRIVER( funriver )   /* (c) 200? Amcoe - Fun River */
96819702   DRIVER( funriverv )   /* (c) 200? Amcoe */
r7500r7501
97449765
97459766   DRIVER( chsuper3 )   /* unknown */
97469767   DRIVER( chsuper2 )   /* unknown */
9768   DRIVER( chmpnum )   /* unknown */
97479769   DRIVER( 3super8 )   /* unknown */
97489770   DRIVER( buster )   /* (c) 1987 Marian Electronics Ltd. */
97499771   DRIVER( spielbud )   /* (c) 1985 ADP */
r7500r7501
1000410026   DRIVER( am_mg24 )   /* (c) Amatic 2000 */
1000510027   DRIVER( am_mg3 )   /* (c) Amatic 2000 */
1000610028
10007   DRIVER( pinkiri8 )
1000810029   DRIVER( neptunp2 )
10030   DRIVER( rgum )
1000910031
10032   /* Diatec */
10033   DRIVER( unclepoo )
10034
1001010035#endif   /* DRIVER_RECURSIVE */
src/mame/includes/nitedrvr.h
r7500r7501
1515#define NITEDRVR_ATTRACT_EN   NODE_06
1616
1717
18class nitedrvr_state
19{
20public:
21   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, nitedrvr_state(machine)); }
22
23   nitedrvr_state(running_machine &machine) { }
24
25   /* memory pointers */
26   UINT8 *    hvc;
27   UINT8 *    videoram;
28
29   /* video-related */
30   tilemap_t  *bg_tilemap;
31
32   /* input */
33   UINT8 gear;
34   UINT8 track;
35   INT32 steering_buf;
36   INT32 steering_val;
37   UINT8 crash_en;
38   UINT8 crash_data;
39   UINT8 crash_data_en;   // IC D8
40   UINT8 ac_line;
41   INT32 last_steering_val;
42
43   /* devices */
44   running_device *maincpu;
45   running_device *discrete;
46};
47
48
1849/*----------- defined in machine/nitedrvr.c -----------*/
1950
2051READ8_HANDLER( nitedrvr_in0_r );
r7500r7501
3768
3869/*----------- defined in video/nitedrvr.c -----------*/
3970
40extern UINT8 *nitedrvr_hvc;
41
4271WRITE8_HANDLER( nitedrvr_hvc_w );
4372WRITE8_HANDLER( nitedrvr_videoram_w );
4473
src/mame/includes/m10.h
r7500r7501
2727#define IREMM15_VBSTART         (240)
2828#define IREMM15_VBEND         (16)
2929
30typedef struct _m10_state m10_state;
31struct _m10_state
30class m10_state
3231{
32public:
33   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, m10_state(machine)); }
34
35   m10_state(running_machine &machine) { }
36
3337   /* memory pointers */
3438   UINT8 *             chargen;
3539   UINT8 *             memory;
src/mame/includes/sbugger.h
r7500r7501
1typedef struct _sbugger_state sbugger_state;
2struct _sbugger_state
1class sbugger_state
32{
3public:
4   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, sbugger_state(machine)); }
5
6   sbugger_state(running_machine &machine) { }
7
48   UINT8 *videoram;
59   UINT8 *videoram_attr;
610
src/mame/includes/nycaptor.h
r7500r7501
1/*----------- defined in drivers/nycaptor.c -----------*/
21
3extern UINT8 *nycaptor_sharedram;
4extern int nyc_gametype;
2class nycaptor_state
3{
4public:
5   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, nycaptor_state(machine)); }
56
7   nycaptor_state(running_machine &machine) { }
68
9   /* memory pointers */
10   UINT8 *      sharedram;
11   UINT8 *      scrlram;
12   UINT8 *      videoram;
13   UINT8 *      spriteram;
14   size_t       videoram_size;
15
16   /* video-related */
17   tilemap_t *bg_tilemap;
18   int char_bank, palette_bank, gfxctrl;
19
20   /* mcu */
21   UINT8 from_main, from_mcu;
22   int mcu_sent, main_sent;
23   UINT8 port_a_in, port_a_out, ddr_a;
24   UINT8 port_b_in, port_b_out, ddr_b;
25   UINT8 port_c_in, port_c_out, ddr_c;
26
27   /* misc */
28   int generic_control_reg;
29   int sound_nmi_enable, pending_nmi;
30   UINT8 snd_data;
31   int vol_ctrl[16];
32   int  gametype;
33
34   /* devices */
35   running_device *maincpu;
36   running_device *audiocpu;
37   running_device *subcpu;
38   running_device *mcu;
39};
40
41
742/*----------- defined in machine/nycaptor.c -----------*/
843
944READ8_HANDLER( nycaptor_mcu_r );
1045READ8_HANDLER( nycaptor_mcu_status_r1 );
1146READ8_HANDLER( nycaptor_mcu_status_r2 );
12READ8_HANDLER( nycaptor_68705_portC_r );
13READ8_HANDLER( nycaptor_68705_portB_r );
14READ8_HANDLER( nycaptor_68705_portA_r );
47READ8_HANDLER( nycaptor_68705_port_c_r );
48READ8_HANDLER( nycaptor_68705_port_b_r );
49READ8_HANDLER( nycaptor_68705_port_a_r );
1550
1651WRITE8_HANDLER( nycaptor_mcu_w );
17WRITE8_HANDLER( nycaptor_68705_portA_w );
18WRITE8_HANDLER( nycaptor_68705_portB_w );
19WRITE8_HANDLER( nycaptor_68705_portC_w );
20WRITE8_HANDLER( nycaptor_68705_ddrA_w );
21WRITE8_HANDLER( nycaptor_68705_ddrB_w );
22WRITE8_HANDLER( nycaptor_68705_ddrC_w );
52WRITE8_HANDLER( nycaptor_68705_port_a_w );
53WRITE8_HANDLER( nycaptor_68705_port_b_w );
54WRITE8_HANDLER( nycaptor_68705_port_c_w );
55WRITE8_HANDLER( nycaptor_68705_ddr_a_w );
56WRITE8_HANDLER( nycaptor_68705_ddr_b_w );
57WRITE8_HANDLER( nycaptor_68705_ddr_c_w );
2358
2459
2560/*----------- defined in video/nycaptor.c -----------*/
2661
27extern UINT8 *nycaptor_scrlram;
28
29VIDEO_START( nycaptor );
30VIDEO_UPDATE( nycaptor );
31
32
3362READ8_HANDLER( nycaptor_videoram_r );
3463READ8_HANDLER( nycaptor_spriteram_r );
3564READ8_HANDLER( nycaptor_palette_r );
r7500r7501
4170WRITE8_HANDLER( nycaptor_palette_w );
4271WRITE8_HANDLER( nycaptor_gfxctrl_w );
4372WRITE8_HANDLER( nycaptor_scrlram_w );
73
74VIDEO_START( nycaptor );
75VIDEO_UPDATE( nycaptor );
src/mame/includes/rainbow.h
r7500r7501
44
55*************************************************************************/
66
7typedef struct _rainbow_state rainbow_state;
8struct _rainbow_state
7class rainbow_state
98{
9public:
10   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, rainbow_state(machine)); }
11
12   rainbow_state(running_machine &machine) { }
13
1014   /* memory pointers */
1115   UINT16 *    spriteram;
1216//  UINT16 *    paletteram;    // currently this uses generic palette handling
src/mame/includes/mitchell.h
r7500r7501
44
55*************************************************************************/
66
7typedef struct _mitchell_state mitchell_state;
8struct _mitchell_state
7class mitchell_state
98{
9public:
10   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, mitchell_state(machine)); }
11
12   mitchell_state(running_machine &machine) { }
13
1014   /* memory pointers */
1115   UINT8 *    videoram;
1216   UINT8 *    colorram;
src/mame/includes/galspnbl.h
r7500r7501
55
66*************************************************************************/
77
8typedef struct _galspnbl_state galspnbl_state;
9struct _galspnbl_state
8class galspnbl_state
109{
10public:
11   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, galspnbl_state(machine)); }
12
13   galspnbl_state(running_machine &machine) { }
14
1115   /* memory pointers */
1216   UINT16 *    videoram;
1317   UINT16 *    bgvideoram;
src/mame/includes/blktiger.h
r7500r7501
44
55***************************************************************************/
66
7typedef struct _blktiger_state blktiger_state;
8struct _blktiger_state
7class blktiger_state
98{
9public:
10   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, blktiger_state(machine)); }
11
12   blktiger_state(running_machine &machine) { }
13
1014   /* memory pointers */
1115   UINT8 * txvideoram;
1216//  UINT8 * spriteram;  // currently this uses generic buffer_spriteram_w
src/mame/includes/tunhunt.h
r7500r7501
1typedef struct _tunhunt_state tunhunt_state;
2struct _tunhunt_state
1class tunhunt_state
32{
3public:
4   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, tunhunt_state(machine)); }
5
6   tunhunt_state(running_machine &machine) { }
7
48   UINT8 control;
59   UINT8 *workram;
610   UINT8 *spriteram;
src/mame/includes/rungun.h
r7500r7501
44
55*************************************************************************/
66
7typedef struct _rungun_state rungun_state;
8struct _rungun_state
7class rungun_state
98{
9public:
10   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, rungun_state(machine)); }
11
12   rungun_state(running_machine &machine) { }
13
1014   /* memory pointers */
1115   UINT16 *    _936_videoram;
1216//  UINT16 *    paletteram;    // currently this uses generic palette handling
src/mame/includes/madmotor.h
r0r7501
1/*************************************************************************
2
3    Mad Motor
4
5*************************************************************************/
6
7class madmotor_state
8{
9public:
10   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, madmotor_state(machine)); }
11
12   madmotor_state(running_machine &machine) { }
13
14   /* memory pointers */
15   UINT16 *        pf1_rowscroll;
16   UINT16 *        pf1_data;
17   UINT16 *        pf2_data;
18   UINT16 *        pf3_data;
19   UINT16 *        pf1_control;
20   UINT16 *        pf2_control;
21   UINT16 *        pf3_control;
22   UINT16 *        spriteram;
23//  UINT16 *        paletteram;     // this currently uses generic palette handlers
24   size_t          spriteram_size;
25
26   /* video-related */
27   tilemap_t       *pf1_tilemap, *pf2_tilemap, *pf3_tilemap, *pf3a_tilemap;
28   int             flipscreen;
29
30   /* devices */
31   running_device *maincpu;
32   running_device *audiocpu;
33};
34
35
36/*----------- defined in video/madmotor.c -----------*/
37
38WRITE16_HANDLER( madmotor_pf1_data_w );
39WRITE16_HANDLER( madmotor_pf2_data_w );
40WRITE16_HANDLER( madmotor_pf3_data_w );
41
42VIDEO_START( madmotor );
43VIDEO_UPDATE( madmotor );
src/mame/includes/eprom.h
r7500r7501
66
77#include "machine/atarigen.h"
88
9typedef struct _eprom_state eprom_state;
10struct _eprom_state
9class eprom_state
1110{
11public:
12   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, eprom_state(machine)); }
13
14   eprom_state(running_machine &machine) { }
15
1216   atarigen_state   atarigen;
1317   int          screen_intensity;
1418   int          video_disable;
src/mame/includes/skyfox.h
r0r7501
1/*************************************************************************
2
3    Skyfox
4
5*************************************************************************/
6
7class skyfox_state
8{
9public:
10   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, skyfox_state(machine)); }
11
12   skyfox_state(running_machine &machine) { }
13
14   /* memory pointers */
15   UINT8 *    spriteram;
16   size_t     spriteram_size;
17
18   /* video-related */
19   UINT8      vreg[8];
20   int        bg_pos, bg_ctrl;
21
22   /* misc */
23   int        palette_selected;
24
25   /* devices */
26   running_device *maincpu;
27};
28
29/*----------- defined in video/skyfox.c -----------*/
30
31WRITE8_HANDLER( skyfox_vregs_w );
32
33PALETTE_INIT( skyfox );
34
35VIDEO_UPDATE( skyfox );
36
src/mame/includes/bublbobl.h
r7500r7501
11
2typedef struct _bublbobl_state bublbobl_state;
3struct _bublbobl_state
2class bublbobl_state
43{
4public:
5   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, bublbobl_state(machine)); }
6
7   bublbobl_state(running_machine &machine) { }
8
59   /* memory pointers */
610   UINT8 *  mcu_sharedram;
711   UINT8 *  videoram;
src/mame/includes/aerofgt.h
r7500r7501
11
2typedef struct _aerofgt_state aerofgt_state;
3struct _aerofgt_state
2class aerofgt_state
43{
4public:
5   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, aerofgt_state(machine)); }
6
7   aerofgt_state(running_machine &machine) { }
8
59   /* memory pointers */
610   UINT16 *  bg1videoram;
711   UINT16 *  bg2videoram;
src/mame/includes/fgoal.h
r7500r7501
11
22
3typedef struct _fgoal_state fgoal_state;
4struct _fgoal_state
3class fgoal_state
54{
5public:
6   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, fgoal_state(machine)); }
7
8   fgoal_state(running_machine &machine) { }
9
610   /* memory pointers */
711   UINT8 *    video_ram;
812
src/mame/includes/docastle.h
r7500r7501
11
22
3typedef struct _docastle_state docastle_state;
4struct _docastle_state
3class docastle_state
54{
5public:
6   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, docastle_state(machine)); }
7
8   docastle_state(running_machine &machine) { }
9
610   /* memory pointers */
711   UINT8 *  videoram;
812   UINT8 *  colorram;
src/mame/includes/mystston.h
r7500r7501
1010#define   MYSTSTON_MASTER_CLOCK   (XTAL_12MHz)
1111
1212
13typedef struct _mystston_state mystston_state;
14struct _mystston_state
13class mystston_state
1514{
15public:
16   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, mystston_state(machine)); }
17
18   mystston_state(running_machine &machine) { }
19
1620   /* machine state */
1721   UINT8 *ay8910_data;
1822   UINT8 *ay8910_select;
src/mame/includes/hitme.h
r7500r7501
1212#define HITME_ENABLE_VAL         NODE_03
1313#define HITME_OUT1               NODE_04
1414
15typedef struct _hitme_state hitme_state;
16struct _hitme_state
15class hitme_state
1716{
17public:
18   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, hitme_state(machine)); }
19
20   hitme_state(running_machine &machine) { }
21
1822   /* memory pointers */
1923   UINT8 *  videoram;
2024
src/mame/includes/rampart.h
r7500r7501
77#include "machine/atarigen.h"
88
99/* shared with arcadecl hardware */
10typedef struct _rampart_state rampart_state;
11struct _rampart_state
10class rampart_state
1211{
12public:
13   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, rampart_state(machine)); }
14
15   rampart_state(running_machine &machine) { }
16
1317   atarigen_state   atarigen;
1418   UINT16 *      bitmap;
1519   UINT8         has_mo;
src/mame/includes/sonson.h
r7500r7501
44
55*************************************************************************/
66
7typedef struct _sonson_state sonson_state;
8struct _sonson_state
7class sonson_state
98{
9public:
10   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, sonson_state(machine)); }
11
12   sonson_state(running_machine &machine) { }
13
1014   /* memory pointers */
1115   UINT8 *    videoram;
1216   UINT8 *    colorram;
src/mame/includes/sslam.h
r7500r7501
1typedef struct _sslam_state sslam_state;
2struct _sslam_state
1class sslam_state
32{
3public:
4   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, sslam_state(machine)); }
5
6   sslam_state(running_machine &machine) { }
7
48   emu_timer *music_timer;
59
610   int sound;
src/mame/includes/simpl156.h
r0r7501
1/*************************************************************************
2
3    Simple 156 based board
4
5*************************************************************************/
6
7class simpl156_state
8{
9public:
10   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, simpl156_state(machine)); }
11
12   simpl156_state(running_machine &machine) { }
13
14   /* memory pointers */
15   UINT16 *  pf1_rowscroll;
16   UINT16 *  pf2_rowscroll;
17   UINT32 *  mainram;
18   UINT32 *  systemram;
19
20   /* devices */
21   running_device *maincpu;
22   running_device *deco16ic;
23   running_device *eeprom;
24   running_device *okimusic;
25};
26
27
28
29/*----------- defined in video/simpl156.c -----------*/
30
31VIDEO_START( simpl156 );
32VIDEO_UPDATE( simpl156 );
src/mame/includes/hcastle.h
r7500r7501
44
55*************************************************************************/
66
7typedef struct _hcastle_state hcastle_state;
8struct _hcastle_state
7class hcastle_state
98{
9public:
10   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, hcastle_state(machine)); }
11
12   hcastle_state(running_machine &machine) { }
13
1014   /* memory pointers */
1115   UINT8 *    pf1_videoram;
1216   UINT8 *    pf2_videoram;
src/mame/includes/copsnrob.h
r7500r7501
44
55*************************************************************************/
66
7typedef struct _copsnrob_state copsnrob_state;
8struct _copsnrob_state
7class copsnrob_state
98{
9public:
10   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, copsnrob_state(machine)); }
11
12   copsnrob_state(running_machine &machine) { }
13
1014   /* memory pointers */
1115   UINT8 *        videoram;
1216   UINT8 *        trucky;
src/mame/includes/battlnts.h
r7500r7501
44
55*************************************************************************/
66
7typedef struct _battlnts_state battlnts_state;
8struct _battlnts_state
7class battlnts_state
98{
9public:
10   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, battlnts_state(machine)); }
11
12   battlnts_state(running_machine &machine) { }
13
1014   /* memory pointers */
1115//  UINT8 *      paletteram;    // this currently uses generic palette handling
1216
src/mame/includes/arabian.h
r7500r7501
66
77***************************************************************************/
88
9typedef struct _arabian_state arabian_state;
10struct _arabian_state
9class arabian_state
1110{
11public:
12   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, arabian_state(machine)); }
13
14   arabian_state(running_machine &machine) { }
15
1216   /* memory pointers */
1317   UINT8 *  blitter;
1418   UINT8 *  custom_cpu_ram;
src/mame/includes/taito_o.h
r7500r7501
44
55*************************************************************************/
66
7typedef struct _taitoo_state taitoo_state;
8struct _taitoo_state
7class taitoo_state
98{
9public:
10   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, taitoo_state(machine)); }
11
12   taitoo_state(running_machine &machine) { }
13
1014   /* memory pointers */
1115//  UINT16 *    paletteram;    // currently this uses generic palette handling
1216
src/mame/includes/labyrunr.h
r7500r7501
44
55*************************************************************************/
66
7typedef struct _labyrunr_state labyrunr_state;
8struct _labyrunr_state
7class labyrunr_state
98{
9public:
10   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, labyrunr_state(machine)); }
11
12   labyrunr_state(running_machine &machine) { }
13
1014   /* memory pointers */
1115   UINT8 *    videoram1;
1216   UINT8 *    videoram2;
src/mame/includes/ccastles.h
r7500r7501
44
55*************************************************************************/
66
7typedef struct _ccastles_state ccastles_state;
8struct _ccastles_state
7class ccastles_state
98{
9public:
10   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, ccastles_state(machine)); }
11
12   ccastles_state(running_machine &machine) { }
13
1014   /* memory pointers */
1115   UINT8 *  videoram;
1216   UINT8 *  spriteram;
src/mame/includes/ddragon3.h
r7500r7501
55*************************************************************************/
66
77
8typedef struct _ddragon3_state ddragon3_state;
9struct _ddragon3_state
8class ddragon3_state
109{
10public:
11   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, ddragon3_state(machine)); }
12
13   ddragon3_state(running_machine &machine) { }
14
1115   /* memory pointers */
1216   UINT16 *        bg_videoram;
1317   UINT16 *        fg_videoram;
src/mame/includes/dragrace.h
r7500r7501
2222#define DRAGRACE_ATTRACT_EN     NODE_09
2323
2424
25typedef struct _dragrace_state dragrace_state;
26struct _dragrace_state
25class dragrace_state
2726{
27public:
28   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, dragrace_state(machine)); }
29
30   dragrace_state(running_machine &machine) { }
31
2832   /* memory pointers */
2933   UINT8 *  playfield_ram;
3034   UINT8 *  position_ram;
src/mame/includes/orbit.h
r7500r7501
77#include "sound/discrete.h"
88
99/* Discrete Sound Input Nodes */
10#define ORBIT_NOTE_FREQ      NODE_01
11#define ORBIT_ANOTE1_AMP   NODE_02
12#define ORBIT_ANOTE2_AMP   NODE_03
13#define ORBIT_NOISE1_AMP   NODE_04
14#define ORBIT_NOISE2_AMP   NODE_05
15#define ORBIT_WARNING_EN   NODE_06
16#define ORBIT_NOISE_EN      NODE_07
10#define ORBIT_NOTE_FREQ       NODE_01
11#define ORBIT_ANOTE1_AMP      NODE_02
12#define ORBIT_ANOTE2_AMP      NODE_03
13#define ORBIT_NOISE1_AMP      NODE_04
14#define ORBIT_NOISE2_AMP      NODE_05
15#define ORBIT_WARNING_EN      NODE_06
16#define ORBIT_NOISE_EN        NODE_07
1717
18class orbit_state
19{
20public:
21   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, orbit_state(machine)); }
1822
23   orbit_state(running_machine &machine) { }
24
25   /* memory pointers */
26   UINT8 *    playfield_ram;
27   UINT8 *    sprite_ram;
28
29   /* video-related */
30   tilemap_t  *bg_tilemap;
31   int        flip_screen;
32
33   /* misc */
34   UINT8      misc_flags;
35
36   /* devices */
37   running_device *maincpu;
38   running_device *discrete;
39};
40
41
1942/*----------- defined in audio/orbit.c -----------*/
2043
2144WRITE8_DEVICE_HANDLER( orbit_note_w );
r7500r7501
3053VIDEO_START( orbit );
3154VIDEO_UPDATE( orbit );
3255
33extern UINT8* orbit_playfield_ram;
34extern UINT8* orbit_sprite_ram;
35
3656extern WRITE8_HANDLER( orbit_playfield_w );
src/mame/includes/ambush.h
r7500r7501
44
55*************************************************************************/
66
7typedef struct _ambush_state ambush_state;
8struct _ambush_state
7class ambush_state
98{
9public:
10   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, ambush_state(machine)); }
11
12   ambush_state(running_machine &machine) { }
13
1014   /* memory pointers */
1115   UINT8 *    videoram;
1216   UINT8 *    spriteram;
src/mame/includes/drmicro.h
r7500r7501
55*************************************************************************/
66
77
8typedef struct _drmicro_state drmicro_state;
9struct _drmicro_state
8class drmicro_state
109{
10public:
11   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, drmicro_state(machine)); }
12
13   drmicro_state(running_machine &machine) { }
14
1115   /* memory pointers */
1216   UINT8 *        videoram;
1317
src/mame/includes/exedexes.h
r7500r7501
55*************************************************************************/
66
77
8typedef struct _exedexes_state exedexes_state;
9struct _exedexes_state
8class exedexes_state
109{
10public:
11   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, exedexes_state(machine)); }
12
13   exedexes_state(running_machine &machine) { }
14
1115   /* memory pointers */
1216   UINT8 *        videoram;
1317   UINT8 *        colorram;
src/mame/includes/jedi.h
r7500r7501
1414#define JEDI_TMS5220_CLOCK      (JEDI_AUDIO_CPU_OSC / 2 / 9) /* div by 9 is via a binary counter that counts from 7 to 16 */
1515
1616
17typedef struct _jedi_state jedi_state;
18struct _jedi_state
17class jedi_state
1918{
19public:
20   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, jedi_state(machine)); }
21
22   jedi_state(running_machine &machine) { }
23
2024   /* machine state */
2125   UINT8  a2d_select;
2226   UINT8  nvram_enabled;
src/mame/includes/flkatck.h
r7500r7501
44
55*************************************************************************/
66
7typedef struct _flkatck_state flkatck_state;
8struct _flkatck_state
7class flkatck_state
98{
9public:
10   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, flkatck_state(machine)); }
11
12   flkatck_state(running_machine &machine) { }
13
1014   /* memory pointers */
1115   UINT8 *    k007121_ram;
1216//  UINT8 *    paletteram;  // this currently uses generic palette handling
src/mame/includes/shootout.h
r7500r7501
1typedef struct _shootout_state shootout_state;
2struct _shootout_state
1class shootout_state
32{
3public:
4   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, shootout_state(machine)); }
5
6   shootout_state(running_machine &machine) { }
7
48   tilemap_t *background;
59   tilemap_t *foreground;
610   UINT8 *spriteram;
src/mame/includes/contra.h
r7500r7501
44
55*************************************************************************/
66
7typedef struct _contra_state contra_state;
8struct _contra_state
7class contra_state
98{
9public:
10   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, contra_state(machine)); }
11
12   contra_state(running_machine &machine) { }
13
1014   /* memory pointers */
1115   UINT8 *        spriteram;
1216   UINT8 *        spriteram_2;
src/mame/includes/volfied.h
r7500r7501
44
55*************************************************************************/
66
7typedef struct _volfied_state volfied_state;
8struct _volfied_state
7class volfied_state
98{
9public:
10   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, volfied_state(machine)); }
11
12   volfied_state(running_machine &machine) { }
13
1014   /* memory pointers */
1115   UINT16 *    video_ram;
1216   UINT8  *    cchip_ram;
src/mame/includes/dribling.h
r7500r7501
66
77
88
9typedef struct _dribling_state dribling_state;
10struct _dribling_state
9class dribling_state
1110{
11public:
12   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, dribling_state(machine)); }
13
14   dribling_state(running_machine &machine) { }
15
1216   /* memory pointers */
1317   UINT8 *  videoram;
1418   UINT8 *  colorram;
src/mame/includes/balsente.h
r7500r7501
2525#define POLY17_ADD   0x18000
2626
2727
28typedef struct _balsente_state balsente_state;
29struct _balsente_state
28class balsente_state
3029{
30public:
31   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, balsente_state(machine)); }
32
33   balsente_state(running_machine &machine) { }
34
3135   /* global data */
3236   UINT8 shooter;
3337   UINT8 shooter_x;
src/mame/includes/megadriv.h
r7500r7501
1515INPUT_PORTS_EXTERN( aladbl );
1616INPUT_PORTS_EXTERN( megadri6 );
1717INPUT_PORTS_EXTERN( ssf2ghw );
18INPUT_PORTS_EXTERN( mk3ghw );
1819INPUT_PORTS_EXTERN( megdsvp );
1920
2021MACHINE_DRIVER_EXTERN( megadriv_timers );
src/mame/includes/mexico86.h
r7500r7501
1
2class mexico86_state
3{
4public:
5   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, mexico86_state(machine)); }
6
7   mexico86_state(running_machine &machine) { }
8
9   /* memory pointers */
10   UINT8 *     protection_ram;
11   UINT8 *     videoram;
12   UINT8 *     objectram;
13   size_t      objectram_size;
14
15   /* video-related */
16   int      charbank;
17
18   /* mcu */
19   /* mexico86 68705 protection */
20   UINT8    port_a_in, port_a_out, ddr_a;
21   UINT8    port_b_in, port_b_out, ddr_b;
22   int      address, latch;
23   /* kikikai mcu simulation */
24   int      mcu_running, mcu_initialised;
25   int      coin_last;
26
27   /* devices */
28   running_device *maincpu;
29   running_device *audiocpu;
30   running_device *subcpu;
31   running_device *mcu;
32};
33
34
135/*----------- defined in machine/mexico86.c -----------*/
236
3extern UINT8 *mexico86_protection_ram;
4
537WRITE8_HANDLER( mexico86_f008_w );
638INTERRUPT_GEN( kikikai_interrupt );
739INTERRUPT_GEN( mexico86_m68705_interrupt );
8READ8_HANDLER( mexico86_68705_portA_r );
9WRITE8_HANDLER( mexico86_68705_portA_w );
10WRITE8_HANDLER( mexico86_68705_ddrA_w );
11READ8_HANDLER( mexico86_68705_portB_r );
12WRITE8_HANDLER( mexico86_68705_portB_w );
13WRITE8_HANDLER( mexico86_68705_ddrB_w );
40READ8_HANDLER( mexico86_68705_port_a_r );
41WRITE8_HANDLER( mexico86_68705_port_a_w );
42WRITE8_HANDLER( mexico86_68705_ddr_a_w );
43READ8_HANDLER( mexico86_68705_port_b_r );
44WRITE8_HANDLER( mexico86_68705_port_b_w );
45WRITE8_HANDLER( mexico86_68705_ddr_b_w );
1446
1547
1648/*----------- defined in video/mexico86.c -----------*/
1749
18extern UINT8 *mexico86_videoram,*mexico86_objectram;
19extern size_t mexico86_objectram_size;
50WRITE8_HANDLER( mexico86_bankswitch_w );
2051
21WRITE8_HANDLER( mexico86_bankswitch_w );
2252VIDEO_UPDATE( mexico86 );
2353VIDEO_UPDATE( kikikai );
src/mame/includes/chaknpop.h
r7500r7501
33#define MCU_INITIAL_SEED   0x81
44
55
6typedef struct _chaknpop_state chaknpop_state;
7struct _chaknpop_state
6class chaknpop_state
87{
8public:
9   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, chaknpop_state(machine)); }
10
11   chaknpop_state(running_machine &machine) { }
12
913   /* memory pointers */
1014   UINT8 *  mcu_ram;
1115   UINT8 *  tx_ram;
src/mame/includes/fitfight.h
r7500r7501
11
2typedef struct _fitfight_state fitfight_state;
3struct _fitfight_state
2class fitfight_state
43{
4public:
5   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, fitfight_state(machine)); }
6
7   fitfight_state(running_machine &machine) { }
8
59   /* memory pointers */
610   UINT16 *  fof_100000;
711   UINT16 *  fof_600000;
src/mame/includes/ashnojoe.h
r7500r7501
44
55*************************************************************************/
66
7typedef struct _ashnojoe_state ashnojoe_state;
8struct _ashnojoe_state
7class ashnojoe_state
98{
9public:
10   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, ashnojoe_state(machine)); }
11
12   ashnojoe_state(running_machine &machine) { }
13
1014   /* memory pointers */
1115   UINT16 *    tileram;
1216   UINT16 *    tileram_1;
src/mame/includes/ddribble.h
r7500r7501
44
55***************************************************************************/
66
7typedef struct _ddribble_state ddribble_state;
8struct _ddribble_state
7class ddribble_state
98{
9public:
10   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, ddribble_state(machine)); }
11
12   ddribble_state(running_machine &machine) { }
13
1014   /* memory pointers */
1115   UINT8 *     sharedram;
1216   UINT8 *     snd_sharedram;
src/mame/includes/mouser.h
r0r7501
1/*************************************************************************
2
3    Mouser
4
5*************************************************************************/
6
7class mouser_state
8{
9public:
10   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, mouser_state(machine)); }
11
12   mouser_state(running_machine &machine) { }
13
14   /* memory pointers */
15   UINT8 *    videoram;
16   UINT8 *    colorram;
17   UINT8 *    spriteram;
18   size_t     spriteram_size;
19
20   /* misc */
21   UINT8      sound_byte;
22   UINT8      nmi_enable;
23
24   /* devices */
25   running_device *maincpu;
26   running_device *audiocpu;
27};
28
29/*----------- defined in video/mouser.c -----------*/
30
31WRITE8_HANDLER( mouser_flip_screen_x_w );
32WRITE8_HANDLER( mouser_flip_screen_y_w );
33
34PALETTE_INIT( mouser );
35VIDEO_UPDATE( mouser );
src/mame/includes/malzak.h
r7500r7501
55*************************************************************************/
66
77
8typedef struct _malzak_state malzak_state;
9struct _malzak_state
8class malzak_state
109{
10public:
11   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, malzak_state(machine)); }
12
13   malzak_state(running_machine &machine) { }
14
1115   /* misc */
1216//  int playfield_x[256];
1317//  int playfield_y[256];
src/mame/includes/grchamp.h
r7500r7501
66
77#include "sound/discrete.h"
88
9typedef struct _grchamp_state grchamp_state;
10struct _grchamp_state
9class grchamp_state
1110{
11public:
12   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, grchamp_state(machine)); }
13
14   grchamp_state(running_machine &machine) { }
15
1216   UINT8      cpu0_out[16];
1317   UINT8      cpu1_out[16];
1418
src/mame/includes/lkage.h
r7500r7501
1
2class lkage_state
3{
4public:
5   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, lkage_state(machine)); }
6
7   lkage_state(running_machine &machine) { }
8
9   UINT8 *      scroll;
10   UINT8 *      vreg;
11   UINT8 *      videoram;
12   UINT8 *      spriteram;
13//  UINT8 *    paletteram;    // currently this uses generic palette handling
14
15   /* video-related */
16   tilemap_t *bg_tilemap, *fg_tilemap, *tx_tilemap;
17   UINT8 bg_tile_bank, fg_tile_bank;
18
19   /* misc */
20   int sound_nmi_enable, pending_nmi;
21
22   /* mcu */
23   UINT8 from_main, from_mcu;
24   int mcu_sent, main_sent;
25   UINT8 port_a_in, port_a_out, ddr_a;
26   UINT8 port_b_in, port_b_out, ddr_b;
27   UINT8 port_c_in, port_c_out, ddr_c;
28
29   /* lkageb fake mcu */
30   UINT8 mcu_val;
31   int mcu_ready;   /* cpu data/mcu ready status */
32
33   /* devices */
34   running_device *maincpu;
35   running_device *audiocpu;
36   running_device *mcu;
37};
38
139/*----------- defined in machine/lkage.c -----------*/
240
3READ8_HANDLER( lkage_68705_portA_r );
4WRITE8_HANDLER( lkage_68705_portA_w );
5READ8_HANDLER( lkage_68705_portB_r );
6WRITE8_HANDLER( lkage_68705_portB_w );
7READ8_HANDLER( lkage_68705_portC_r );
8WRITE8_HANDLER( lkage_68705_portC_w );
9WRITE8_HANDLER( lkage_68705_ddrA_w );
10WRITE8_HANDLER( lkage_68705_ddrB_w );
11WRITE8_HANDLER( lkage_68705_ddrC_w );
41READ8_HANDLER( lkage_68705_port_a_r );
42WRITE8_HANDLER( lkage_68705_port_a_w );
43READ8_HANDLER( lkage_68705_port_b_r );
44WRITE8_HANDLER( lkage_68705_port_b_w );
45READ8_HANDLER( lkage_68705_port_c_r );
46WRITE8_HANDLER( lkage_68705_port_c_w );
47WRITE8_HANDLER( lkage_68705_ddr_a_w );
48WRITE8_HANDLER( lkage_68705_ddr_b_w );
49WRITE8_HANDLER( lkage_68705_ddr_c_w );
1250WRITE8_HANDLER( lkage_mcu_w );
1351READ8_HANDLER( lkage_mcu_r );
1452READ8_HANDLER( lkage_mcu_status_r );
r7500r7501
1654
1755/*----------- defined in video/lkage.c -----------*/
1856
19extern UINT8 *lkage_scroll, *lkage_vreg;
2057WRITE8_HANDLER( lkage_videoram_w );
2158VIDEO_START( lkage );
2259VIDEO_UPDATE( lkage );
src/mame/includes/zaxxon.h
r7500r7501
44
55***************************************************************************/
66
7typedef struct _zaxxon_state zaxxon_state;
8struct _zaxxon_state
7class zaxxon_state
98{
9public:
10   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, zaxxon_state(machine)); }
11
12   zaxxon_state(running_machine &machine) { }
13
1014   UINT8 *colorram;
1115   UINT8 *videoram;
1216   UINT8 *spriteram;
src/mame/includes/gaiden.h
r7500r7501
44
55***************************************************************************/
66
7typedef struct _gaiden_state gaiden_state;
8struct _gaiden_state
7class gaiden_state
98{
9public:
10   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, gaiden_state(machine)); }
11
12   gaiden_state(running_machine &machine) { }
13
1014   /* memory pointers */
1115   UINT16 *    videoram;
1216   UINT16 *    videoram2;
src/mame/includes/trackfld.h
r7500r7501
88#include "sound/msm5205.h"
99
1010
11typedef struct _trackfld_state trackfld_state;
12struct _trackfld_state
11class trackfld_state
1312{
13public:
14   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, trackfld_state(machine)); }
15
16   trackfld_state(running_machine &machine) { }
17
1418   /* memory pointers */
1519   UINT8 *  videoram;   // trackfld, hyperspt, yiear, sbasketb
1620   UINT8 *  colorram;   // trackfld, hyperspt, sbasketb
src/mame/includes/astrof.h
r7500r7501
44
55****************************************************************************/
66
7typedef struct _astrof_state astrof_state;
8struct _astrof_state
7class astrof_state
98{
9public:
10   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, astrof_state(machine)); }
11
12   astrof_state(running_machine &machine) { }
13
1014   /* video-related */
1115   UINT8 *    videoram;
1216   size_t     videoram_size;
src/mame/includes/karnov.h
r7500r7501
44
55*************************************************************************/
66
7typedef struct _karnov_state karnov_state;
8struct _karnov_state
7class karnov_state
98{
9public:
10   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, karnov_state(machine)); }
11
12   karnov_state(running_machine &machine) { }
13
1014   /* memory pointers */
1115   UINT16 *    videoram;
1216   UINT16 *    ram;
src/mame/includes/lwings.h
r7500r7501
11
2typedef struct _lwings_state lwings_state;
3struct _lwings_state
2class lwings_state
43{
4public:
5   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, lwings_state(machine)); }
6
7   lwings_state(running_machine &machine) { }
8
59   /* memory pointers */
610   UINT8 *  fgvideoram;
711   UINT8 *  bg1videoram;
src/mame/includes/kopunch.h
r7500r7501
44
55*************************************************************************/
66
7typedef struct _kopunch_state kopunch_state;
8struct _kopunch_state
7class kopunch_state
98{
9public:
10   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, kopunch_state(machine)); }
11
12   kopunch_state(running_machine &machine) { }
13
1014   /* memory pointers */
1115   UINT8 *    videoram;
1216   UINT8 *    videoram2;
src/mame/includes/news.h
r7500r7501
1
2class news_state
3{
4public:
5   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, news_state(machine)); }
6
7   news_state(running_machine &machine) { }
8
9   /* memory pointers */
10   UINT8 *  bgram;
11   UINT8 *  fgram;
12//  UINT8 *  paletteram;    // currently this uses generic palette handling
13
14   /* video-related */
15   tilemap_t *fg_tilemap, *bg_tilemap;
16   int      bgpic;
17};
18
19
120/*----------- defined in video/news.c -----------*/
221
3extern UINT8 *news_fgram;
4extern UINT8 *news_bgram;
5
622WRITE8_HANDLER( news_fgram_w );
723WRITE8_HANDLER( news_bgram_w );
824WRITE8_HANDLER( news_bgpic_w );
25
926VIDEO_START( news );
1027VIDEO_UPDATE( news );
src/mame/includes/finalizr.h
r7500r7501
44
55***************************************************************************/
66
7typedef struct _finalizr_state finalizr_state;
8struct _finalizr_state
7class finalizr_state
98{
9public:
10   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, finalizr_state(machine)); }
11
12   finalizr_state(running_machine &machine) { }
13
1014   /* memory pointers */
1115   UINT8 *       videoram;
1216   UINT8 *       colorram;
src/mame/includes/shuuz.h
r7500r7501
66
77#include "machine/atarigen.h"
88
9typedef struct _shuuz_state shuuz_state;
10struct _shuuz_state
9class shuuz_state
1110{
11public:
12   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, shuuz_state(machine)); }
13
14   shuuz_state(running_machine &machine) { }
15
1216   atarigen_state   atarigen;
1317};
1418
src/mame/includes/foodf.h
r7500r7501
66
77#include "machine/atarigen.h"
88
9typedef struct _foodf_state foodf_state;
10struct _foodf_state
9class foodf_state
1110{
11public:
12   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, foodf_state(machine)); }
13
14   foodf_state(running_machine &machine) { }
15
1216   atarigen_state   atarigen;
1317
1418   double         rweights[3];
src/mame/includes/armedf.h
r7500r7501
22
33
44
5typedef struct _armedf_state armedf_state;
6struct _armedf_state
5class armedf_state
76{
7public:
8   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, armedf_state(machine)); }
9
10   armedf_state(running_machine &machine) { }
11
812   /* memory pointers */
913   UINT16 *  text_videoram;
1014   UINT16 *  bg_videoram;
src/mame/includes/bsktball.h
r7500r7501
1313#define BSKTBALL_BOUNCE_EN      NODE_04
1414
1515
16typedef struct _bsktball_state bsktball_state;
17struct _bsktball_state
16class bsktball_state
1817{
18public:
19   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, bsktball_state(machine)); }
20
21   bsktball_state(running_machine &machine) { }
22
1923   /* memory pointers */
2024   UINT8 *  videoram;
2125   UINT8 *  motion;
src/mame/includes/dkong.h
r7500r7501
6969#define DK3_PALETTE_LENGTH      (256+256+8+1) /*  (256) */
7070#define RS_PALETTE_LENGTH      (256+256+8+1)
7171
72typedef struct _dkong_state dkong_state;
73struct _dkong_state
72class dkong_state
7473{
74public:
75   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, dkong_state(machine)); }
76
77   dkong_state(running_machine &machine) { }
78
7579   /* memory pointers */
7680   UINT8 *           video_ram;
7781   UINT8 *           sprite_ram;
src/mame/includes/appoooh.h
r7500r7501
11
22
3typedef struct _appoooh_state appoooh_state;
4struct _appoooh_state
3class appoooh_state
54{
5public:
6   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, appoooh_state(machine)); }
7
8   appoooh_state(running_machine &machine) { }
9
610   /* memory pointers */
711   UINT8 *  bg_videoram;
812   UINT8 *  bg_colorram;
src/mame/includes/aliens.h
r7500r7501
44
55*************************************************************************/
66
7typedef struct _aliens_state aliens_state;
8struct _aliens_state
7class aliens_state
98{
9public:
10   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, aliens_state(machine)); }
11
12   aliens_state(running_machine &machine) { }
13
1014   /* memory pointers */
1115   UINT8 *    ram;
1216//  UINT8 *    paletteram;    // currently this uses generic palette handling
src/mame/includes/metlclsh.h
r0r7501
1/*************************************************************************
2
3    Metal Clash
4
5*************************************************************************/
6
7class metlclsh_state
8{
9public:
10   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, metlclsh_state(machine)); }
11
12   metlclsh_state(running_machine &machine) { }
13
14   /* memory pointers */
15   UINT8 *        bgram;
16   UINT8 *        fgram;
17   UINT8 *        scrollx;
18   UINT8 *        otherram;
19//      UINT8 *        paletteram;    // currently this uses generic palette handling
20//      UINT8 *        paletteram2;    // currently this uses generic palette handling
21   UINT8 *        spriteram;
22   size_t         spriteram_size;
23
24   /* video-related */
25   tilemap_t      *bg_tilemap,*fg_tilemap;
26   UINT8          write_mask, gfxbank;
27
28   /* devices */
29   running_device *maincpu;
30   running_device *subcpu;
31};
32
33
34/*----------- defined in video/metlclsh.c -----------*/
35
36WRITE8_HANDLER( metlclsh_bgram_w );
37WRITE8_HANDLER( metlclsh_fgram_w );
38WRITE8_HANDLER( metlclsh_gfxbank_w );
39WRITE8_HANDLER( metlclsh_rambank_w );
40
41VIDEO_START( metlclsh );
42VIDEO_UPDATE( metlclsh );
src/mame/includes/88games.h
r7500r7501
44
55*************************************************************************/
66
7typedef struct __88games_state _88games_state;
8struct __88games_state
7class _88games_state
98{
9public:
10   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, _88games_state(machine)); }
11
12   _88games_state(running_machine &machine) { }
13
1014   /* memory pointers */
1115   UINT8 *      ram;
1216   UINT8 *      banked_rom;
src/mame/includes/goldstar.h
r7500r7501
1typedef struct _goldstar_state goldstar_state;
2struct _goldstar_state
1class goldstar_state
32{
3public:
4   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, goldstar_state(machine)); }
5
6   goldstar_state(running_machine &machine) { }
7
48   int dataoffset;
59
610   UINT8 *nvram;
src/mame/includes/dbz.h
r7500r7501
44
55*************************************************************************/
66
7typedef struct _dbz_state dbz_state;
8struct _dbz_state
7class dbz_state
98{
9public:
10   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, dbz_state(machine)); }
11
12   dbz_state(running_machine &machine) { }
13
1014   /* memory pointers */
1115   UINT16 *      bg1_videoram;
1216   UINT16 *      bg2_videoram;
src/mame/includes/gauntlet.h
r7500r7501
66
77#include "machine/atarigen.h"
88
9typedef struct _gauntlet_state gauntlet_state;
10struct _gauntlet_state
9class gauntlet_state
1110{
11public:
12   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, gauntlet_state(machine)); }
13
14   gauntlet_state(running_machine &machine) { }
15
1216   atarigen_state   atarigen;
1317   UINT16         sound_reset_val;
1418   UINT8         vindctr2_screen_refresh;
src/mame/includes/20pacgal.h
r7500r7501
77***************************************************************************/
88
99
10typedef struct __20pacgal_state _20pacgal_state;
11struct __20pacgal_state
10class _20pacgal_state
1211{
12public:
13   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, _20pacgal_state(machine)); }
14
15   _20pacgal_state(running_machine &machine) { }
16
1317   /* memory pointers */
1418   UINT8 *char_gfx_ram;
1519   UINT8 *sprite_gfx_ram;
src/mame/includes/spbactn.h
r7500r7501
1typedef struct _spbactn_state spbactn_state;
2struct _spbactn_state
1class spbactn_state
32{
3public:
4   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, spbactn_state(machine)); }
5
6   spbactn_state(running_machine &machine) { }
7
48   UINT16 *bgvideoram;
59   UINT16 *fgvideoram;
610   UINT16 *spvideoram;
src/mame/includes/system16.h
r7500r7501
11
22// later, this might be merged with segas1x_state in segas16.h
33
4typedef struct _segas1x_bootleg_state segas1x_bootleg_state;
5struct _segas1x_bootleg_state
4class segas1x_bootleg_state
65{
6public:
7   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, segas1x_bootleg_state(machine)); }
8
9   segas1x_bootleg_state(running_machine &machine) { }
10
711   UINT16 *    bg0_tileram;
812   UINT16 *    bg1_tileram;
913   UINT16 *    textram;
src/mame/includes/deniam.h
r7500r7501
55*************************************************************************/
66
77
8typedef struct _deniam_state deniam_state;
9struct _deniam_state
8class deniam_state
109{
10public:
11   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, deniam_state(machine)); }
12
13   deniam_state(running_machine &machine) { }
14
1115   /* memory pointers */
1216   UINT16 *       videoram;
1317   UINT16 *       textram;
src/mame/includes/simpsons.h
r7500r7501
11
2typedef struct _simpsons_state simpsons_state;
3struct _simpsons_state
2class simpsons_state
43{
4public:
5   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, simpsons_state(machine)); }
6
7   simpsons_state(running_machine &machine) { }
8
59   /* memory pointers */
610   UINT8 *    ram;
711   UINT8 *    xtraram;
src/mame/includes/wwfsstar.h
r7500r7501
1typedef struct _wwfsstar_state wwfsstar_state;
2struct _wwfsstar_state
1class wwfsstar_state
32{
3public:
4   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, wwfsstar_state(machine)); }
5
6   wwfsstar_state(running_machine &machine) { }
7
48   int vblank;
59   int scrollx;
610   int scrolly;
src/mame/includes/actfancr.h
r7500r7501
44
55*************************************************************************/
66
7typedef struct _actfancr_state actfancr_state;
8struct _actfancr_state
7class actfancr_state
98{
9public:
10   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, actfancr_state(machine)); }
11
12   actfancr_state(running_machine &machine) { }
13
1014   /* memory pointers */
1115   UINT8 *        pf1_data;
1216   UINT8 *        pf2_data;
src/mame/includes/taito_b.h
r7500r7501
11
2typedef struct _taitob_state taitob_state;
3struct _taitob_state
2class taitob_state
43{
4public:
5   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, taitob_state(machine)); }
6
7   taitob_state(running_machine &machine) { }
8
59   /* memory pointers */
610   UINT16 *      spriteram;
711   UINT16 *      pixelram;
src/mame/includes/jackal.h
r7500r7501
44
55
66
7typedef struct _jackal_state jackal_state;
8struct _jackal_state
7class jackal_state
98{
9public:
10   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, jackal_state(machine)); }
11
12   jackal_state(running_machine &machine) { }
13
1014   /* memory pointers */
1115   UINT8 *  videoctrl;
1216   UINT8 *  scrollram;
src/mame/includes/mw8080bw.h
r7500r7501
3030#define MW8080BW_HPIXCOUNT                (MW8080BW_HBSTART + 4)
3131
3232
33typedef struct _mw8080bw_state mw8080bw_state;
34struct _mw8080bw_state
33class mw8080bw_state
3534{
35public:
36   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, mw8080bw_state(machine)); }
37
38   mw8080bw_state(running_machine &machine) { }
39
3640   /* memory pointers */
3741   UINT8 *     main_ram;
3842   UINT8 *     colorram;
src/mame/includes/vaportra.h
r0r7501
1/*************************************************************************
2
3    Vapour Trail
4
5*************************************************************************/
6
7class vaportra_state
8{
9public:
10   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, vaportra_state(machine)); }
11
12   vaportra_state(running_machine &machine) { }
13
14   /* memory pointers */
15   UINT16 *  pf1_rowscroll;
16   UINT16 *  pf2_rowscroll;
17   UINT16 *  pf3_rowscroll;
18   UINT16 *  pf4_rowscroll;
19
20   /* misc */
21   UINT16    priority[2];
22
23   /* devices */
24   running_device *maincpu;
25   running_device *audiocpu;
26   running_device *deco16ic;
27};
28
29
30
31/*----------- defined in video/vaportra.c -----------*/
32
33WRITE16_HANDLER( vaportra_priority_w );
34WRITE16_HANDLER( vaportra_palette_24bit_rg_w );
35WRITE16_HANDLER( vaportra_palette_24bit_b_w );
36
37VIDEO_UPDATE( vaportra );
src/mame/includes/btime.h
r7500r7501
11
2typedef struct _btime_state btime_state;
3struct _btime_state
2class btime_state
43{
4public:
5   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, btime_state(machine)); }
6
7   btime_state(running_machine &machine) { }
8
59   /* memory pointers */
610   UINT8 *  videoram;
711   UINT8 *  colorram;
src/mame/includes/cps1.h
r7500r7501
5757};
5858
5959
60typedef struct _cps_state cps_state;
61struct _cps_state
60class cps_state
6261{
62public:
63   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, cps_state(machine)); }
64
65   cps_state(running_machine &machine) { }
66
6367   /* memory pointers */
6468   // cps1
6569   UINT16 *     gfxram;
src/mame/includes/yunsun16.h
r7500r7501
44
55*************************************************************************/
66
7typedef struct _yunsun16_state yunsun16_state;
8struct _yunsun16_state
7class yunsun16_state
98{
9public:
10   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, yunsun16_state(machine)); }
11
12   yunsun16_state(running_machine &machine) { }
13
1014   /* memory pointers */
1115   UINT16 *    vram_0;
1216   UINT16 *    vram_1;
src/mame/includes/stactics.h
r7500r7501
77****************************************************************************/
88
99
10typedef struct _stactics_state stactics_state;
11struct _stactics_state
10class stactics_state
1211{
12public:
13   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, stactics_state(machine)); }
14
15   stactics_state(running_machine &machine) { }
16
1317   /* machine state */
1418   int    vert_pos;
1519   int    horiz_pos;
src/mame/includes/mermaid.h
r0r7501
1/*************************************************************************
2
3    Mermaid
4
5*************************************************************************/
6
7class mermaid_state
8{
9public:
10   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, mermaid_state(machine)); }
11
12   mermaid_state(running_machine &machine) { }
13
14   /* memory pointers */
15   UINT8 *    videoram;
16   UINT8 *    colorram;
17   UINT8 *    videoram2;
18   UINT8 *    spriteram;
19   UINT8 *    bg_scrollram;
20   UINT8 *    fg_scrollram;
21   UINT8 *    ay8910_enable;
22   size_t     spriteram_size;
23
24   /* video-related */
25   tilemap_t *bg_tilemap, *fg_tilemap;
26   bitmap_t* helper;
27   bitmap_t* helper2;
28   int coll_bit0, coll_bit1, coll_bit2, coll_bit3, coll_bit6;
29   int rougien_gfxbank1, rougien_gfxbank2;
30
31   /* devices */
32   running_device *maincpu;
33   running_device *ay1;
34   running_device *ay2;
35};
36
37
38
39/*----------- defined in video/mermaid.c -----------*/
40
41WRITE8_HANDLER( mermaid_videoram2_w );
42WRITE8_HANDLER( mermaid_videoram_w );
43WRITE8_HANDLER( mermaid_colorram_w );
44WRITE8_HANDLER( mermaid_flip_screen_x_w );
45WRITE8_HANDLER( mermaid_flip_screen_y_w );
46WRITE8_HANDLER( mermaid_bg_scroll_w );
47WRITE8_HANDLER( mermaid_fg_scroll_w );
48WRITE8_HANDLER( rougien_gfxbankswitch1_w );
49WRITE8_HANDLER( rougien_gfxbankswitch2_w );
50READ8_HANDLER( mermaid_collision_r );
51
52PALETTE_INIT( mermaid );
53VIDEO_START( mermaid );
54VIDEO_UPDATE( mermaid );
55VIDEO_EOF( mermaid );
src/mame/includes/avalnche.h
r7500r7501
77#include "sound/discrete.h"
88
99
10typedef struct _avalnche_state avalnche_state;
11struct _avalnche_state
10class avalnche_state
1211{
12public:
13   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, avalnche_state(machine)); }
14
15   avalnche_state(running_machine &machine) { }
16
1317   /* video-related */
1418   UINT8 *  videoram;
1519   size_t   videoram_size;
src/mame/includes/kickgoal.h
r7500r7501
44
55*************************************************************************/
66
7typedef struct _kickgoal_state kickgoal_state;
8struct _kickgoal_state
7class kickgoal_state
98{
9public:
10   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, kickgoal_state(machine)); }
11
12   kickgoal_state(running_machine &machine) { }
13
1014   /* memory pointers */
1115   UINT16 *    fgram;
1216   UINT16 *    bgram;
src/mame/includes/othldrby.h
r0r7501
1/*************************************************************************
2
3    Othello Derby
4
5*************************************************************************/
6
7#define OTHLDRBY_VREG_SIZE   18
8
9class othldrby_state
10{
11public:
12   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, othldrby_state(machine)); }
13
14   othldrby_state(running_machine &machine) { }
15
16   /* memory pointers */
17   UINT16 *     vram;
18   UINT16 *     buf_spriteram;
19   UINT16 *     buf_spriteram2;
20
21   /* video-related */
22   tilemap_t    *bg_tilemap[3];
23   UINT16       vreg[OTHLDRBY_VREG_SIZE];
24   UINT32       vram_addr, vreg_addr;
25
26   /* misc */
27   int          toggle;
28};
29
30
31/*----------- defined in video/othldrby.c -----------*/
32
33WRITE16_HANDLER( othldrby_videoram_addr_w );
34READ16_HANDLER( othldrby_videoram_r );
35WRITE16_HANDLER( othldrby_videoram_w );
36WRITE16_HANDLER( othldrby_vreg_addr_w );
37WRITE16_HANDLER( othldrby_vreg_w );
38
39VIDEO_START( othldrby );
40VIDEO_EOF( othldrby );
41VIDEO_UPDATE( othldrby );
src/mame/includes/hyprduel.h
r7500r7501
22#define FIRST_VISIBLE_LINE 0
33#define LAST_VISIBLE_LINE 223
44
5typedef struct _hyprduel_state hyprduel_state;
6struct _hyprduel_state
5class hyprduel_state
76{
7public:
8   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, hyprduel_state(machine)); }
9
10   hyprduel_state(running_machine &machine) { }
11
812   /* memory pointers */
913   UINT16 *  videoregs;
1014   UINT16 *  screenctrl;
src/mame/includes/flstory.h
r7500r7501
11
2typedef struct _flstory_state flstory_state;
3struct _flstory_state
2class flstory_state
43{
4public:
5   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, flstory_state(machine)); }
6
7   flstory_state(running_machine &machine) { }
8
59   /* memory pointers */
610   UINT8 *  videoram;
711   UINT8 *  workram;
src/mame/includes/suprslam.h
r7500r7501
44
55*************************************************************************/
66
7typedef struct _suprslam_state suprslam_state;
8struct _suprslam_state
7class suprslam_state
98{
9public:
10   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, suprslam_state(machine)); }
11
12   suprslam_state(running_machine &machine) { }
13
1014   /* memory pointers */
1115   UINT16 *    screen_videoram;
1216   UINT16 *    bg_videoram;
src/mame/includes/cosmic.h
r7500r7501
88#define Z80_MASTER_CLOCK         XTAL_10_816MHz
99
1010
11typedef struct _cosmic_state cosmic_state;
12struct _cosmic_state
11class cosmic_state
1312{
13public:
14   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, cosmic_state(machine)); }
15
16   cosmic_state(running_machine &machine) { }
17
1418   /* memory pointers */
1519   UINT8 *        videoram;
1620   UINT8 *        spriteram;
src/mame/includes/kyugo.h
r7500r7501
44
55***************************************************************************/
66
7typedef struct _kyugo_state kyugo_state;
8struct _kyugo_state
7class kyugo_state
98{
9public:
10   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, kyugo_state(machine)); }
11
12   kyugo_state(running_machine &machine) { }
13
1014   /* memory pointers */
1115   UINT8 *     fgvideoram;
1216   UINT8 *     bgvideoram;
src/mame/includes/lazercmd.h
r7500r7501
1717#define MARKER_HORZ_ADJ -1
1818#define MARKER_VERT_ADJ -10
1919
20typedef struct _lazercmd_state lazercmd_state;
21struct _lazercmd_state
20class lazercmd_state
2221{
22public:
23   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, lazercmd_state(machine)); }
24
25   lazercmd_state(running_machine &machine) { }
26
2327   /* memory pointers */
2428   UINT8 *  videoram;
2529   size_t   videoram_size;
src/mame/includes/4enraya.h
r7500r7501
44
55*************************************************************************/
66
7typedef struct __4enraya_state _4enraya_state;
8struct __4enraya_state
7class _4enraya_state
98{
9public:
10   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, _4enraya_state(machine)); }
11
12   _4enraya_state(running_machine &machine) { }
13
1014   /* memory pointers */
1115   UINT8 *    videoram;
1216   size_t     videoram_size;
src/mame/includes/blockade.h
r7500r7501
11#include "sound/discrete.h"
22#include "sound/samples.h"
33
4typedef struct _blockade_state blockade_state;
5struct _blockade_state
4class blockade_state
65{
6public:
7   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, blockade_state(machine)); }
8
9   blockade_state(running_machine &machine) { }
10
711   UINT8 *  videoram;
812
913   /* video-related */
src/mame/includes/compgolf.h
r7500r7501
44
55*************************************************************************/
66
7typedef struct _compgolf_state compgolf_state;
8struct _compgolf_state
7class compgolf_state
98{
9public:
10   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, compgolf_state(machine)); }
11
12   compgolf_state(running_machine &machine) { }
13
1014   /* memory pointers */
1115   UINT8 *        videoram;
1216   UINT8 *        bg_ram;
src/mame/includes/lemmings.h
r7500r7501
11
2typedef struct _lemmings_state lemmings_state;
3struct _lemmings_state
2class lemmings_state
43{
4public:
5   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, lemmings_state(machine)); }
6
7   lemmings_state(running_machine &machine) { }
8
59   /* memory pointers */
610   UINT16 *  pixel_0_data;
711   UINT16 *  pixel_1_data;
src/mame/includes/zerozone.h
r7500r7501
44
55*************************************************************************/
66
7typedef struct _zerozone_state zerozone_state;
8struct _zerozone_state
7class zerozone_state
98{
9public:
10   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, zerozone_state(machine)); }
11
12   zerozone_state(running_machine &machine) { }
13
1014   /* memory pointers */
1115   UINT16 *    videoram;
1216//  UINT16 *    paletteram; // currently this uses generic palette handling
src/mame/includes/espial.h
r7500r7501
44
55***************************************************************************/
66
7typedef struct _espial_state espial_state;
8struct _espial_state
7class espial_state
98{
9public:
10   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, espial_state(machine)); }
11
12   espial_state(running_machine &machine) { }
13
1014   UINT8 *   videoram;   // espial, zodiack, marineb
1115   UINT8 *   colorram;   // espial, marineb
1216   UINT8 *   attributeram;   // espial, zodiack
src/mame/includes/hnayayoi.h
r7500r7501
44
55*************************************************************************/
66
7typedef struct _hnayayoi_state hnayayoi_state;
8struct _hnayayoi_state
7class hnayayoi_state
98{
9public:
10   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, hnayayoi_state(machine)); }
11
12   hnayayoi_state(running_machine &machine) { }
13
1014   /* video-related */
1115   UINT8      *pixmap[8];
1216   int        palbank;
src/mame/includes/tmnt.h
r7500r7501
11
2typedef struct _tmnt_state tmnt_state;
3struct _tmnt_state
2class tmnt_state
43{
4public:
5   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, tmnt_state(machine)); }
6
7   tmnt_state(running_machine &machine) { }
8
59   /* memory pointers */
610   INT16 *    sampledata;
711   UINT16 *   tmnt2_1c0800;
src/mame/includes/taitojc.h
r7500r7501
11#include "video/poly.h"
22
3typedef struct _taitojc_state taitojc_state;
4struct _taitojc_state
3class taitojc_state
54{
5public:
6   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, taitojc_state(machine)); }
7
8   taitojc_state(running_machine &machine) { }
9
610   int texture_x;
711   int texture_y;
812
src/mame/includes/bionicc.h
r7500r7501
44
55***************************************************************************/
66
7typedef struct _bionicc_state bionicc_state;
8struct _bionicc_state
7class bionicc_state
98{
9public:
10   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, bionicc_state(machine)); }
11
12   bionicc_state(running_machine &machine) { }
13
1014   /* memory pointers */
1115   UINT16 *  bgvideoram;
1216   UINT16 *  fgvideoram;
src/mame/includes/citycon.h
r7500r7501
44
55*************************************************************************/
66
7typedef struct _citycon_state citycon_state;
8struct _citycon_state
7class citycon_state
98{
9public:
10   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, citycon_state(machine)); }
11
12   citycon_state(running_machine &machine) { }
13
1014   /* memory pointers */
1115   UINT8 *        videoram;
1216   UINT8 *        linecolor;
src/mame/includes/spy.h
r7500r7501
44
55*************************************************************************/
66
7typedef struct _spy_state spy_state;
8struct _spy_state
7class spy_state
98{
9public:
10   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, spy_state(machine)); }
11
12   spy_state(running_machine &machine) { }
13
1014   /* memory pointers */
1115   UINT8 *    ram;
1216   UINT8 *    pmcram;
src/mame/includes/psikyo.h
r7500r7501
44
55*************************************************************************/
66
7typedef struct _psikyo_state psikyo_state;
8struct _psikyo_state
7class psikyo_state
98{
9public:
10   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, psikyo_state(machine)); }
11
12   psikyo_state(running_machine &machine) { }
13
1014   /* memory pointers */
1115   UINT32 *       vram_0;
1216   UINT32 *       vram_1;
src/mame/includes/esd16.h
r7500r7501
44
55***************************************************************************/
66
7typedef struct _esd16_state esd16_state;
8struct _esd16_state
7class esd16_state
98{
9public:
10   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, esd16_state(machine)); }
11
12   esd16_state(running_machine &machine) { }
13
1014   /* memory pointers */
1115   UINT16 *       vram_0;
1216   UINT16 *       vram_1;
src/mame/includes/pgm.h
r7500r7501
11
2typedef struct _pgm_state pgm_state;
3struct _pgm_state
2class pgm_state
43{
4public:
5   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, pgm_state(machine)); }
6
7   pgm_state(running_machine &machine) { }
8
59   /* memory pointers */
610//  UINT16 *      mainram;  // currently this is also used by nvram handler
711   UINT16 *      bg_videoram;
src/mame/includes/gameplan.h
r7500r7501
2121#define LEPRECHAUN_MAIN_CPU_CLOCK        (LEPRECHAUN_MAIN_MASTER_CLOCK / 4)
2222
2323
24typedef struct _gameplan_state gameplan_state;
25struct _gameplan_state
24class gameplan_state
2625{
26public:
27   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, gameplan_state(machine)); }
28
29   gameplan_state(running_machine &machine) { }
30
2731   /* machine state */
2832   UINT8   current_port;
2933   UINT8   *trvquest_question;
src/mame/includes/darius.h
r7500r7501
77#define DARIUS_VOL_MAX    (3*2 + 2)
88#define DARIUS_PAN_MAX    (2 + 2 + 1)   /* FM 2port + PSG 2port + DA 1port */
99
10typedef struct _darius_state darius_state;
11struct _darius_state
10class darius_state
1211{
12public:
13   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, darius_state(machine)); }
14
15   darius_state(running_machine &machine) { }
16
1317   /* memory pointers */
1418   UINT16 *    spriteram;
1519   UINT16 *    fg_ram;
src/mame/includes/capbowl.h
r7500r7501
44
55*************************************************************************/
66
7typedef struct _capbowl_state capbowl_state;
8struct _capbowl_state
7class capbowl_state
98{
9public:
10   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, capbowl_state(machine)); }
11
12   capbowl_state(running_machine &machine) { }
13
1014   /* memory pointers */
1115   UINT8 *  rowaddress;
1216//  UINT8 *  nvram; // currently this uses generic_nvram
src/mame/includes/ikki.h
r7500r7501
44
55*************************************************************************/
66
7typedef struct _ikki_state ikki_state;
8struct _ikki_state
7class ikki_state
98{
9public:
10   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, ikki_state(machine)); }
11
12   ikki_state(running_machine &machine) { }
13
1014   /* memory pointers */
1115   UINT8 *    videoram;
1216   UINT8 *    spriteram;
src/mame/includes/cbasebal.h
r7500r7501
44
55*************************************************************************/
66
7typedef struct _cbasebal_state cbasebal_state;
8struct _cbasebal_state
7class cbasebal_state
98{
9public:
10   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, cbasebal_state(machine)); }
11
12   cbasebal_state(running_machine &machine) { }
13
1014   /* memory pointers */
1115   UINT8 *    spriteram;
1216//  UINT8 *    paletteram;    // currently this uses generic palette handling
src/mame/includes/beathead.h
r7500r7501
66
77#include "machine/atarigen.h"
88
9typedef struct _beathead_state beathead_state;
10struct _beathead_state
9class beathead_state
1110{
11public:
12   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, beathead_state(machine)); }
13
14   beathead_state(running_machine &machine) { }
15
1216   atarigen_state   atarigen;
1317
1418   UINT32 *      vram_bulk_latch;
src/mame/includes/funkyjet.h
r0r7501
1/*************************************************************************
2
3    Funky Jet
4
5*************************************************************************/
6
7class funkyjet_state
8{
9public:
10   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, funkyjet_state(machine)); }
11
12   funkyjet_state(running_machine &machine) { }
13
14   /* memory pointers */
15   UINT16 *  pf1_rowscroll;
16   UINT16 *  pf2_rowscroll;
17   UINT16 *  spriteram;
18//  UINT16 *  paletteram;    // currently this uses generic palette handling (in deco16ic.c)
19   size_t    spriteram_size;
20
21   /* devices */
22   running_device *maincpu;
23   running_device *audiocpu;
24   running_device *deco16ic;
25};
26
27
28
29/*----------- defined in video/funkyjet.c -----------*/
30
31VIDEO_UPDATE( funkyjet );
src/mame/includes/qix.h
r7500r7501
1717#define QIX_CHARACTER_CLOCK      (20000000/2/16)
1818
1919
20typedef struct _qix_state qix_state;
21struct _qix_state
20class qix_state
2221{
22public:
23   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, qix_state(machine)); }
24
25   qix_state(running_machine &machine) { }
26
2327   /* machine state */
2428   UINT8 *_68705_port_out;
2529   UINT8 *_68705_ddr;
src/mame/includes/ksayakyu.h
r7500r7501
44
55*************************************************************************/
66
7typedef struct _ksayakyu_state ksayakyu_state;
8struct _ksayakyu_state
7class ksayakyu_state
98{
9public:
10   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, ksayakyu_state(machine)); }
11
12   ksayakyu_state(running_machine &machine) { }
13
1014   /* memory pointers */
1115   UINT8 *    videoram;
1216   UINT8 *    spriteram;
src/mame/includes/xexex.h
r7500r7501
44
55*************************************************************************/
66
7typedef struct _xexex_state xexex_state;
8struct _xexex_state
7class xexex_state
98{
9public:
10   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, xexex_state(machine)); }
11
12   xexex_state(running_machine &machine) { }
13
1014   /* memory pointers */
1115   UINT16 *    workram;
1216   UINT16 *    spriteram;
src/mame/includes/himesiki.h
r7500r7501
44
55*************************************************************************/
66
7typedef struct _himesiki_state himesiki_state;
8struct _himesiki_state
7class himesiki_state
98{
9public:
10   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, himesiki_state(machine)); }
11
12   himesiki_state(running_machine &machine) { }
13
1014   /* memory pointers */
1115   UINT8 *    bg_ram;
1216   UINT8 *    spriteram;
src/mame/includes/skullxbo.h
r7500r7501
66
77#include "machine/atarigen.h"
88
9typedef struct _skullxbo_state skullxbo_state;
10struct _skullxbo_state
9class skullxbo_state
1110{
11public:
12   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, skullxbo_state(machine)); }
13
14   skullxbo_state(running_machine &machine) { }
15
1216   atarigen_state   atarigen;
1317};
1418
src/mame/includes/battlex.h
r7500r7501
44
55***************************************************************************/
66
7typedef struct _battlex_state battlex_state;
8struct _battlex_state
7class battlex_state
98{
9public:
10   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, battlex_state(machine)); }
11
12   battlex_state(running_machine &machine) { }
13
1014   /* memory pointers */
1115   UINT8 * videoram;
1216   UINT8 * spriteram;
src/mame/includes/ironhors.h
r7500r7501
44
55*************************************************************************/
66
7typedef struct _ironhors_state ironhors_state;
8struct _ironhors_state
7class ironhors_state
98{
9public:
10   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, ironhors_state(machine)); }
11
12   ironhors_state(running_machine &machine) { }
13
1014   /* memory pointers */
1115   UINT8 *    videoram;
1216   UINT8 *    colorram;
src/mame/includes/mrflea.h
r0r7501
1/*************************************************************************
2
3    Mr. Flea
4
5*************************************************************************/
6
7class mrflea_state
8{
9public:
10   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, mrflea_state(machine)); }
11
12   mrflea_state(running_machine &machine) { }
13
14   /* memory pointers */
15   UINT8 *    videoram;
16   UINT8 *    spriteram;
17//  UINT8 *    paletteram;    // currently this uses generic palette handling
18
19   /* video-related */
20   int     gfx_bank;
21
22   /* misc */
23   int io;
24   int main;
25   int status;
26   int select1;
27
28   /* devices */
29   running_device *maincpu;
30   running_device *subcpu;
31};
32
33
34/*----------- defined in video/mrflea.c -----------*/
35
36WRITE8_HANDLER( mrflea_gfx_bank_w );
37WRITE8_HANDLER( mrflea_videoram_w );
38WRITE8_HANDLER( mrflea_spriteram_w );
39
40VIDEO_UPDATE( mrflea );
src/mame/includes/epos.h
r7500r7501
44
55**************************************************************************/
66
7typedef struct _epos_state epos_state;
8struct _epos_state
7class epos_state
98{
9public:
10   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, epos_state(machine)); }
11
12   epos_state(running_machine &machine) { }
13
1014   /* memory pointers */
1115   UINT8 *  videoram;
1216   size_t   videoram_size;
src/mame/includes/glass.h
r7500r7501
44
55*************************************************************************/
66
7typedef struct _glass_state glass_state;
8struct _glass_state
7class glass_state
98{
9public:
10   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, glass_state(machine)); }
11
12   glass_state(running_machine &machine) { }
13
1014   /* memory pointers */
1115   UINT16 *    videoram;
1216   UINT16 *    vregs;
src/mame/includes/mcatadv.h
r7500r7501
1/*----------- defined in drivers/mcatadv.c -----------*/
21
3extern UINT16 *mcatadv_videoram1, *mcatadv_videoram2;
4extern UINT16 *mcatadv_scroll, *mcatadv_scroll2;
5extern UINT16 *mcatadv_vidregs;
2class mcatadv_state
3{
4public:
5   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, mcatadv_state(machine)); }
66
7   mcatadv_state(running_machine &machine) { }
78
9   /* memory pointers */
10   UINT16 *     videoram1;
11   UINT16 *     videoram2;
12   UINT16 *     scroll1;
13   UINT16 *     scroll2;
14   UINT16 *     spriteram;
15   UINT16 *     spriteram_old;
16   UINT16 *     vidregs;
17   UINT16 *     vidregs_old;
18//  UINT16 *     paletteram;    // this currently uses generic palette handlers
19   size_t       spriteram_size;
20
21   /* video-related */
22   tilemap_t    *tilemap1,  *tilemap2;
23   int palette_bank1, palette_bank2;
24
25   /* devices */
26   running_device *maincpu;
27   running_device *soundcpu;
28};
29
830/*----------- defined in video/mcatadv.c -----------*/
931
1032VIDEO_UPDATE( mcatadv );
src/mame/includes/mjkjidai.h
r7500r7501
1typedef struct _mjkjidai_state mjkjidai_state;
2struct _mjkjidai_state
1class mjkjidai_state
32{
3public:
4   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, mjkjidai_state(machine)); }
5
6   mjkjidai_state(running_machine &machine) { }
7
48   UINT8 *videoram;
59   UINT8 *spriteram1;
610   UINT8 *spriteram2;
src/mame/includes/jailbrek.h
r7500r7501
77#define MASTER_CLOCK        XTAL_18_432MHz
88#define VOICE_CLOCK         XTAL_3_579545MHz
99
10typedef struct _jailbrek_state jailbrek_state;
11struct _jailbrek_state
10class jailbrek_state
1211{
12public:
13   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, jailbrek_state(machine)); }
14
15   jailbrek_state(running_machine &machine) { }
16
1317   /* memory pointers */
1418   UINT8 *      videoram;
1519   UINT8 *      colorram;
src/mame/includes/gaelco.h
r7500r7501
44
55***************************************************************************/
66
7typedef struct _gaelco_state gaelco_state;
8struct _gaelco_state
7class gaelco_state
98{
9public:
10   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, gaelco_state(machine)); }
11
12   gaelco_state(running_machine &machine) { }
13
1014   /* memory pointers */
1115   UINT16 *     videoram;
1216   UINT16 *     spriteram;
src/mame/includes/bankp.h
r7500r7501
99#define BANKP_CPU_CLOCK (BANKP_MASTER_CLOCK/6)
1010#define BANKP_SN76496_CLOCK (BANKP_MASTER_CLOCK/6)
1111
12typedef struct _bankp_state bankp_state;
13struct _bankp_state
12class bankp_state
1413{
14public:
15   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, bankp_state(machine)); }
16
17   bankp_state(running_machine &machine) { }
18
1519   /* memory pointers */
1620   UINT8 * videoram;
1721   UINT8 * colorram;
src/mame/includes/munchmo.h
r0r7501
1/*************************************************************************
2
3    Munch Mobile
4
5*************************************************************************/
6
7class munchmo_state
8{
9public:
10   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, munchmo_state(machine)); }
11
12   munchmo_state(running_machine &machine) { }
13
14   /* memory pointers */
15   UINT8 *      vreg;
16   UINT8 *      status_vram;
17   UINT8 *      sprite_xpos;
18   UINT8 *      sprite_attr;
19   UINT8 *      sprite_tile;
20   UINT8 *      videoram;
21
22   /* video-related */
23   bitmap_t     *tmpbitmap;
24   int          palette_bank;
25   int          flipscreen;
26
27   /* misc */
28   int          nmi_enable;
29   int          which;
30
31   /* devices */
32   running_device *maincpu;
33   running_device *audiocpu;
34};
35
36
37/*----------- defined in video/munchmo.c -----------*/
38
39WRITE8_HANDLER( mnchmobl_palette_bank_w );
40WRITE8_HANDLER( mnchmobl_flipscreen_w );
41
42PALETTE_INIT( mnchmobl );
43VIDEO_START( mnchmobl );
44VIDEO_UPDATE( mnchmobl );
src/mame/includes/funkybee.h
r7500r7501
11
22
3typedef struct _funkybee_state funkybee_state;
4struct _funkybee_state
3class funkybee_state
54{
5public:
6   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, funkybee_state(machine)); }
7
8   funkybee_state(running_machine &machine) { }
9
610   /* memory pointers */
711   UINT8 *    videoram;
812   UINT8 *    colorram;
src/mame/includes/lastduel.h
r7500r7501
44
55*************************************************************************/
66
7typedef struct _lastduel_state lastduel_state;
8struct _lastduel_state
7class lastduel_state
98{
9public:
10   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, lastduel_state(machine)); }
11
12   lastduel_state(running_machine &machine) { }
13
1014   /* memory pointers */
1115   UINT16 *    vram;
1216   UINT16 *    scroll1;
src/mame/includes/alpha68k.h
r7500r7501
44
55*************************************************************************/
66
7typedef struct _alpha68k_state alpha68k_state;
8struct _alpha68k_state
7class alpha68k_state
98{
9public:
10   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, alpha68k_state(machine)); }
11
12   alpha68k_state(running_machine &machine) { }
13
1014   /* memory pointers */
1115   UINT16 *    videoram;
1216   UINT16 *    spriteram;
src/mame/includes/drgnmst.h
r7500r7501
11
2typedef struct _drgnmst_state drgnmst_state;
3struct _drgnmst_state
2class drgnmst_state
43{
4public:
5   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, drgnmst_state(machine)); }
6
7   drgnmst_state(running_machine &machine) { }
8
59   /* memory pointers */
610   UINT16 *    vidregs;
711   UINT16 *    fg_videoram;
src/mame/includes/freekick.h
r7500r7501
11
22
3typedef struct _freekick_state freekick_state;
4struct _freekick_state
3class freekick_state
54{
5public:
6   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, freekick_state(machine)); }
7
8   freekick_state(running_machine &machine) { }
9
610   /* memory pointers */
711   UINT8 *    videoram;
812   UINT8 *    spriteram;
src/mame/includes/xybots.h
r7500r7501
66
77#include "machine/atarigen.h"
88
9typedef struct _xybots_state xybots_state;
10struct _xybots_state
9class xybots_state
1110{
11public:
12   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, xybots_state(machine)); }
13
14   xybots_state(running_machine &machine) { }
15
1216   atarigen_state   atarigen;
1317
1418   UINT16         h256;
src/mame/includes/atarisy1.h
r7500r7501
66
77#include "machine/atarigen.h"
88
9typedef struct _atarisy1_state atarisy1_state;
10struct _atarisy1_state
9class atarisy1_state
1110{
11public:
12   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, atarisy1_state(machine)); }
13
14   atarisy1_state(running_machine &machine) { }
15
1216   atarigen_state   atarigen;
1317
1418   UINT16 *      bankselect;
src/mame/includes/wgp.h
r7500r7501
44
55*************************************************************************/
66
7typedef struct _wgp_state wgp_state;
8struct _wgp_state
7class wgp_state
98{
9public:
10   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, wgp_state(machine)); }
11
12   wgp_state(running_machine &machine) { }
13
1014   /* memory pointers */
1115   UINT16 *    spritemap;
1216   UINT16 *    spriteram;
src/mame/includes/welltris.h
r7500r7501
1typedef struct _welltris_state welltris_state;
2struct _welltris_state
1class welltris_state
32{
3public:
4   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, welltris_state(machine)); }
5
6   welltris_state(running_machine &machine) { }
7
48   int pending_command;
59
610   UINT16 *spriteram;
src/mame/includes/gumbo.h
r7500r7501
44
55*************************************************************************/
66
7typedef struct _gumbo_state gumbo_state;
8struct _gumbo_state
7class gumbo_state
98{
9public:
10   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, gumbo_state(machine)); }
11
12   gumbo_state(running_machine &machine) { }
13
1014   /* memory pointers */
1115   UINT16 *    bg_videoram;
1216   UINT16 *    fg_videoram;
src/mame/includes/taitoair.h
r7500r7501
1717};
1818
1919
20typedef struct _taitoair_state taitoair_state;
21struct _taitoair_state
20class taitoair_state
2221{
22public:
23   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, taitoair_state(machine)); }
24
25   taitoair_state(running_machine &machine) { }
26
2327   /* memory pointers */
2428   UINT16 *      m68000_mainram;
2529   UINT16 *      line_ram;
src/mame/includes/atarig42.h
r7500r7501
66
77#include "machine/atarigen.h"
88
9typedef struct _atarig42_state atarig42_state;
10struct _atarig42_state
9class atarig42_state
1110{
11public:
12   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, atarig42_state(machine)); }
13
14   atarig42_state(running_machine &machine) { }
15
1216   atarigen_state   atarigen;
1317   UINT16         playfield_base;
1418   UINT16         motion_object_base;
src/mame/includes/vindictr.h
r7500r7501
66
77#include "machine/atarigen.h"
88
9typedef struct _vindictr_state vindictr_state;
10struct _vindictr_state
9class vindictr_state
1110{
11public:
12   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, vindictr_state(machine)); }
13
14   vindictr_state(running_machine &machine) { }
15
1216   atarigen_state   atarigen;
1317
1418   UINT8         playfield_tile_bank;
src/mame/includes/cop01.h
r7500r7501
44
55*************************************************************************/
66
7typedef struct _cop01_state cop01_state;
8struct _cop01_state
7class cop01_state
98{
9public:
10   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, cop01_state(machine)); }
11
12   cop01_state(running_machine &machine) { }
13
1014   /* memory pointers */
1115   UINT8 *        bgvideoram;
1216   UINT8 *        fgvideoram;
src/mame/includes/hanaawas.h
r7500r7501
44
55*************************************************************************/
66
7typedef struct _hanaawas_state hanaawas_state;
8struct _hanaawas_state
7class hanaawas_state
98{
9public:
10   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, hanaawas_state(machine)); }
11
12   hanaawas_state(running_machine &machine) { }
13
1014   /* memory pointers */
1115   UINT8 *    videoram;
1216   UINT8 *    colorram;
src/mame/includes/aquarium.h
r7500r7501
11
22
33
4typedef struct _aquarium_state aquarium_state;
5struct _aquarium_state
4class aquarium_state
65{
6public:
7   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, aquarium_state(machine)); }
8
9   aquarium_state(running_machine &machine) { }
10
711   /* memory pointers */
812   UINT16 *  scroll;
913   UINT16 *  txt_videoram;
src/mame/includes/angelkds.h
r7500r7501
44
55*************************************************************************/
66
7typedef struct _angelkds_state angelkds_state;
8struct _angelkds_state
7class angelkds_state
98{
9public:
10   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, angelkds_state(machine)); }
11
12   angelkds_state(running_machine &machine) { }
13
1014   /* memory pointers */
1115   UINT8 *    paletteram;
1216   UINT8 *    spriteram;
src/mame/includes/circusc.h
r7500r7501
44
55*************************************************************************/
66
7typedef struct _circusc_state circusc_state;
8struct _circusc_state
7class circusc_state
98{
9public:
10   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, circusc_state(machine)); }
11
12   circusc_state(running_machine &machine) { }
13
1014   /* memory pointers */
1115   UINT8 *        videoram;
1216   UINT8 *        colorram;
src/mame/includes/mikie.h
r0r7501
1/*************************************************************************
2
3    Mikie
4
5*************************************************************************/
6
7class mikie_state
8{
9public:
10   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, mikie_state(machine)); }
11
12   mikie_state(running_machine &machine) { }
13
14   /* memory pointers */
15   UINT8 *    videoram;
16   UINT8 *    colorram;
17   UINT8 *    spriteram;
18   size_t     spriteram_size;
19
20   /* video-related */
21   tilemap_t  *bg_tilemap;
22   int        palettebank;
23
24   /* misc */
25   int        last_irq;
26
27   /* devices */
28   running_device *maincpu;
29   running_device *audiocpu;
30};
31
32
33/*----------- defined in video/mikie.c -----------*/
34
35WRITE8_HANDLER( mikie_videoram_w );
36WRITE8_HANDLER( mikie_colorram_w );
37WRITE8_HANDLER( mikie_palettebank_w );
38WRITE8_HANDLER( mikie_flipscreen_w );
39
40PALETTE_INIT( mikie );
41VIDEO_START( mikie );
42VIDEO_UPDATE( mikie );
src/mame/includes/opwolf.h
r7500r7501
44
55*************************************************************************/
66
7typedef struct _opwolf_state opwolf_state;
8struct _opwolf_state
7class opwolf_state
98{
9public:
10   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, opwolf_state(machine)); }
11
12   opwolf_state(running_machine &machine) { }
13
1014   /* memory pointers */
1115   UINT8 *      cchip_ram;
1216
src/mame/includes/surpratk.h
r7500r7501
44
55*************************************************************************/
66
7typedef struct _surpratk_state surpratk_state;
8struct _surpratk_state
7class surpratk_state
98{
9public:
10   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, surpratk_state(machine)); }
11
12   surpratk_state(running_machine &machine) { }
13
1014   /* memory pointers */
1115   UINT8 *    ram;
1216//  UINT8 *    paletteram;    // currently this uses generic palette handling
src/mame/includes/shadfrce.h
r7500r7501
1typedef struct _shadfrce_state shadfrce_state;
2struct _shadfrce_state
1class shadfrce_state
32{
3public:
4   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, shadfrce_state(machine)); }
5
6   shadfrce_state(running_machine &machine) { }
7
48   tilemap_t *fgtilemap;
59   tilemap_t *bg0tilemap;
610   tilemap_t *bg1tilemap;
src/mame/includes/bigevglf.h
r7500r7501
11
2typedef struct _bigevglf_state bigevglf_state;
3struct _bigevglf_state
2class bigevglf_state
43{
4public:
5   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, bigevglf_state(machine)); }
6
7   bigevglf_state(running_machine &machine) { }
8
59   /* memory pointers */
610   UINT8 *  paletteram;
711   UINT8 *  spriteram1;
src/mame/includes/inufuku.h
r7500r7501
11
2typedef struct _inufuku_state inufuku_state;
3struct _inufuku_state
2class inufuku_state
43{
4public:
5   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, inufuku_state(machine)); }
6
7   inufuku_state(running_machine &machine) { }
8
59   /* memory pointers */
610   UINT16 *  bg_videoram;
711   UINT16 *  bg_rasterram;
src/mame/includes/commando.h
r7500r7501
44
55*************************************************************************/
66
7typedef struct _commando_state commando_state;
8struct _commando_state
7class commando_state
98{
9public:
10   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, commando_state(machine)); }
11
12   commando_state(running_machine &machine) { }
13
1014   /* memory pointers */
1115   UINT8 *  videoram;
1216   UINT8 *  colorram;
src/mame/includes/atarisy2.h
r7500r7501
66
77#include "machine/atarigen.h"
88
9typedef struct _atarisy2_state atarisy2_state;
10struct _atarisy2_state
9class atarisy2_state
1110{
11public:
12   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, atarisy2_state(machine)); }
13
14   atarisy2_state(running_machine &machine) { }
15
1216   atarigen_state   atarigen;
1317
1418   UINT16 *      slapstic_base;
src/mame/includes/yunsung8.h
r7500r7501
44
55*************************************************************************/
66
7typedef struct _yunsung8_state yunsung8_state;
8struct _yunsung8_state
7class yunsung8_state
98{
9public:
10   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, yunsung8_state(machine)); }
11
12   yunsung8_state(running_machine &machine) { }
13
1014   /* memory pointers */
1115   UINT8 *     videoram;
1216
src/mame/includes/cbuster.h
r0r7501
1/*************************************************************************
2
3    Crude Buster
4
5*************************************************************************/
6
7class cbuster_state
8{
9public:
10   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, cbuster_state(machine)); }
11
12   cbuster_state(running_machine &machine) { }
13
14   /* memory pointers */
15   UINT16 *  pf1_rowscroll;
16   UINT16 *  pf2_rowscroll;
17   UINT16 *  pf3_rowscroll;
18   UINT16 *  pf4_rowscroll;
19   UINT16 *  ram;
20
21   /* misc */
22   UINT16    prot;
23   int       pri;
24
25   /* devices */
26   running_device *maincpu;
27   running_device *audiocpu;
28   running_device *deco16ic;
29};
30
31
32
33/*----------- defined in video/cbuster.c -----------*/
34
35WRITE16_HANDLER( twocrude_palette_24bit_rg_w );
36WRITE16_HANDLER( twocrude_palette_24bit_b_w );
37
38VIDEO_UPDATE( twocrude );
src/mame/includes/gng.h
r7500r7501
44
55*************************************************************************/
66
7typedef struct _gng_state gng_state;
8struct _gng_state
7class gng_state
98{
9public:
10   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, gng_state(machine)); }
11
12   gng_state(running_machine &machine) { }
13
1014   /* memory pointers */
1115   UINT8 *    bgvideoram;
1216   UINT8 *    fgvideoram;
src/mame/includes/ojankohs.h
r0r7501
1/*************************************************************************
2
3    Ojanko High School & other Video System mahjong series
4
5*************************************************************************/
6
7class ojankohs_state
8{
9public:
10   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, ojankohs_state(machine)); }
11
12   ojankohs_state(running_machine &machine) { }
13
14   /* memory pointers */
15   UINT8 *   videoram;
16   UINT8 *   colorram;
17   UINT8 *   paletteram;
18
19   /* video-related */
20   tilemap_t  *tilemap;
21   bitmap_t   *tmpbitmap;
22   int       gfxreg;
23   int       flipscreen, flipscreen_old;
24   int       scrollx, scrolly;
25   int       screen_refresh;
26
27   /* misc */
28   int       portselect;
29   int       adpcm_reset;
30   int       adpcm_data;
31   int       vclk_left;
32
33   /* devices */
34   running_device *maincpu;
35   running_device *msm;
36};
37
38
39/*----------- defined in video/ojankohs.c -----------*/
40
41WRITE8_HANDLER( ojankohs_palette_w );
42WRITE8_HANDLER( ccasino_palette_w );
43WRITE8_HANDLER( ojankohs_videoram_w );
44WRITE8_HANDLER( ojankohs_colorram_w );
45WRITE8_HANDLER( ojankohs_gfxreg_w );
46WRITE8_HANDLER( ojankohs_flipscreen_w );
47WRITE8_HANDLER( ojankoc_palette_w );
48WRITE8_HANDLER( ojankoc_videoram_w );
49
50PALETTE_INIT( ojankoy );
51
52VIDEO_START( ojankohs );
53VIDEO_START( ojankoy );
54VIDEO_START( ojankoc );
55
56VIDEO_UPDATE( ojankohs );
57VIDEO_UPDATE( ojankoc );
58
59void ojankoc_flipscreen(const address_space *space, int data);
60
src/mame/includes/n8080.h
r7500r7501
11
2typedef struct _n8080_state n8080_state;
3struct _n8080_state
2class n8080_state
43{
4public:
5   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, n8080_state(machine)); }
6
7   n8080_state(running_machine &machine) { }
8
59   /* memory pointers */
610   UINT8 * videoram;
711   UINT8 * colorram;   // for helifire
src/mame/includes/kncljoe.h
r7500r7501
44
55*************************************************************************/
66
7typedef struct _kncljoe_state kncljoe_state;
8struct _kncljoe_state
7class kncljoe_state
98{
9public:
10   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, kncljoe_state(machine)); }
11
12   kncljoe_state(running_machine &machine) { }
13
1014   /* memory pointers */
1115   UINT8 *    videoram;
1216   UINT8 *    spriteram;
src/mame/includes/holeland.h
r7500r7501
44
55*************************************************************************/
66
7typedef struct _holeland_state holeland_state;
8struct _holeland_state
7class holeland_state
98{
9public:
10   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, holeland_state(machine)); }
11
12   holeland_state(running_machine &machine) { }
13
1014   /* memory pointers */
1115   UINT8 *    videoram;
1216   UINT8 *    colorram;
src/mame/includes/liberate.h
r7500r7501
1typedef struct _liberate_state liberate_state;
2struct _liberate_state
1class liberate_state
32{
3public:
4   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, liberate_state(machine)); }
5
6   liberate_state(running_machine &machine) { }
7
8   UINT8 *videoram;
9   UINT8 *colorram;
10   UINT8 *paletteram;
11   UINT8 *spriteram;
12   UINT8 *scratchram;
13   UINT8 *charram;   /* prosoccr */
14   UINT8 *bg_vram; /* prosport */
15
16   UINT8 io_ram[16];
17
418   int bank;
519   int latch;
620   UINT8 gfx_rom_readback;
721   int background_color;
822   int background_disable;
9   tilemap_t *background_tilemap;
23
24   tilemap_t *back_tilemap;
1025   tilemap_t *fix_tilemap;
11   UINT8 io_ram[16];
12   UINT8 *videoram;
13   UINT8 *colorram;
14   UINT8 *scratchram;
15   UINT8 *charram;   /* prosoccr */
16   UINT8 *bg_vram; /* prosport */
26
27   running_device *maincpu;
28   running_device *audiocpu;
1729};
1830
1931
src/mame/includes/gunsmoke.h
r7500r7501
44
55*************************************************************************/
66
7typedef struct _gunsmoke_state gunsmoke_state;
8struct _gunsmoke_state
7class gunsmoke_state
98{
9public:
10   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, gunsmoke_state(machine)); }
11
12   gunsmoke_state(running_machine &machine) { }
13
1014   /* memory pointers */
1115   UINT8 *    videoram;
1216   UINT8 *    colorram;
src/mame/includes/cvs.h
r7500r7501
1616   int x, y, code;
1717};
1818
19typedef struct _cvs_state cvs_state;
20struct _cvs_state
19class cvs_state
2120{
21public:
22   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, cvs_state(machine)); }
23
24   cvs_state(running_machine &machine) { }
25
2226   /* memory pointers */
2327   UINT8 *    video_ram;
2428   UINT8 *    bullet_ram;
src/mame/includes/turbo.h
r7500r7501
1111#define TURBO_X_SCALE      2
1212
1313
14typedef struct _i8279_state i8279_state;
15struct _i8279_state
14struct i8279_state
1615{
1716   UINT8      command;
1817   UINT8      mode;
r7500r7501
2322};
2423
2524
26typedef struct _turbo_state turbo_state;
27struct _turbo_state
25class turbo_state
2826{
27public:
28   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, turbo_state(machine)); }
29
30   turbo_state(running_machine &machine) { }
31
2932   /* memory pointers */
3033   UINT8 *      videoram;
3134   UINT8 *      spriteram;
src/mame/includes/laserbat.h
r7500r7501
44
55*************************************************************************/
66
7typedef struct _laserbat_state laserbat_state;
8struct _laserbat_state
7class laserbat_state
98{
9public:
10   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, laserbat_state(machine)); }
11
12   laserbat_state(running_machine &machine) { }
13
1014   /* video-related */
1115   tilemap_t    *bg_tilemap;
1216   UINT8      *videoram;
src/mame/includes/tnzs.h
r7500r7501
1515   MCU_TNZS
1616};
1717
18typedef struct _tnzs_state tnzs_state;
19struct _tnzs_state
18class tnzs_state
2019{
20public:
21   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, tnzs_state(machine)); }
22
23   tnzs_state(running_machine &machine) { }
24
2125   /* memory pointers */
2226   UINT8 *  objram;
2327   UINT8 *  vdcram;
src/mame/includes/rohga.h
r0r7501
1/*************************************************************************
2
3    Data East 'Rohga' era hardware
4
5*************************************************************************/
6
7class rohga_state
8{
9public:
10   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, rohga_state(machine)); }
11
12   rohga_state(running_machine &machine) { }
13
14   /* memory pointers */
15   UINT16 *  pf1_rowscroll;
16   UINT16 *  pf2_rowscroll;
17   UINT16 *  pf3_rowscroll;
18   UINT16 *  pf4_rowscroll;
19   UINT16 *  spriteram;
20
21   /* devices */
22   running_device *maincpu;
23   running_device *audiocpu;
24   running_device *deco16ic;
25   running_device *oki1;
26   running_device *oki2;
27};
28
29
30
31/*----------- defined in video/rohga.c -----------*/
32
33WRITE16_HANDLER( rohga_buffer_spriteram16_w );
34
35VIDEO_START( rohga );
36
37VIDEO_UPDATE( rohga );
38VIDEO_UPDATE( schmeisr );
39VIDEO_UPDATE( wizdfire );
40VIDEO_UPDATE( nitrobal );
src/mame/includes/higemaru.h
r7500r7501
44
55*************************************************************************/
66
7typedef struct _higemaru_state higemaru_state;
8struct _higemaru_state
7class higemaru_state
98{
9public:
10   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, higemaru_state(machine)); }
11
12   higemaru_state(running_machine &machine) { }
13
1014   /* memory pointers */
1115   UINT8 *    videoram;
1216   UINT8 *    colorram;
src/mame/includes/batman.h
r7500r7501
66
77#include "machine/atarigen.h"
88
9typedef struct _batman_state batman_state;
10struct _batman_state
9class batman_state
1110{
11public:
12   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, batman_state(machine)); }
13
14   batman_state(running_machine &machine) { }
15
1216   atarigen_state   atarigen;
1317
1418   UINT16         latch_data;
src/mame/includes/naomi.h
r7500r7501
2121
2222extern DRIVER_INIT( naomi );
2323extern DRIVER_INIT( naomi_mp );
24extern DRIVER_INIT( naomi2 );
2425
2526extern DRIVER_INIT( ggxxsla );
2627extern DRIVER_INIT( ggxxrl );
src/mame/includes/nemesis.h
r7500r7501
1/*----------- defined in drivers/nemesis.c -----------*/
1class nemesis_state
2{
3public:
4   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, nemesis_state(machine)); }
25
3extern int nemesis_irq_on;
4extern int nemesis_irq2_on;
5extern UINT16 hcrash_selected_ip;
6   nemesis_state(running_machine &machine) { }
67
8   /* memory pointers */
9   UINT16 *  videoram1;
10   UINT16 *  videoram2;
11   UINT16 *  colorram1;
12   UINT16 *  colorram2;
13   UINT16 *  charram;
14   UINT16 *  spriteram;
15   UINT16 *  paletteram;
16   UINT16 *  xscroll1;
17   UINT16 *  xscroll2;
18   UINT16 *  yscroll1;
19   UINT16 *  yscroll2;
20   UINT8 *   gx400_shared_ram;
21
22   size_t    charram_size;
23   size_t    spriteram_size;
24
25   /* video-related */
26   tilemap_t *background, *foreground;
27   int       spriteram_words;
28   int       tilemap_flip;
29   int       flipscreen;
30   UINT8     irq_port_last;
31   UINT8     blank_tile[8*8];
32
33   /* misc */
34   int       irq_on;
35   int       irq1_on;
36   int       irq2_on;
37   int       irq4_on;
38   UINT16    selected_ip; /* Copied from WEC Le Mans 24 driver, explicity needed for Hyper Crash */
39   int       gx400_irq1_cnt;
40   UINT8     frame_counter;
41
42   /* devices */
43   running_device *maincpu;
44   running_device *audiocpu;
45   running_device *vlm;
46};
47
48
749/*----------- defined in video/nemesis.c -----------*/
850
9extern UINT16 *nemesis_videoram1;
10extern UINT16 *nemesis_videoram2;
11extern UINT16 *nemesis_colorram1;
12extern UINT16 *nemesis_colorram2;
13extern UINT16 *nemesis_characterram;
14extern size_t nemesis_characterram_size;
15extern UINT16 *nemesis_xscroll1, *nemesis_xscroll2;
16extern UINT16 *nemesis_yscroll1, *nemesis_yscroll2;
51WRITE16_HANDLER( nemesis_gfx_flipx_word_w );
52WRITE16_HANDLER( nemesis_gfx_flipy_word_w );
53WRITE16_HANDLER( salamand_control_port_word_w );
54WRITE16_HANDLER( salamander_palette_word_w );
55WRITE16_HANDLER( nemesis_palette_word_w );
1756
1857WRITE16_HANDLER( nemesis_videoram1_word_w );
1958WRITE16_HANDLER( nemesis_videoram2_word_w );
2059WRITE16_HANDLER( nemesis_colorram1_word_w );
2160WRITE16_HANDLER( nemesis_colorram2_word_w );
22WRITE16_HANDLER( nemesis_characterram_word_w );
61WRITE16_HANDLER( nemesis_charram_word_w );
62
2363VIDEO_START( nemesis );
2464VIDEO_UPDATE( nemesis );
25
26WRITE16_HANDLER( nemesis_gfx_flipx_word_w );
27WRITE16_HANDLER( nemesis_gfx_flipy_word_w );
28WRITE16_HANDLER( salamand_control_port_word_w );
29WRITE16_HANDLER( salamander_palette_word_w );
30WRITE16_HANDLER( nemesis_palette_word_w );
src/mame/includes/cheekyms.h
r7500r7501
55*************************************************************************/
66
77
8typedef struct _cheekyms_state cheekyms_state;
9struct _cheekyms_state
8class cheekyms_state
109{
10public:
11   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, cheekyms_state(machine)); }
12
13   cheekyms_state(running_machine &machine) { }
14
1115   /* memory pointers */
1216   UINT8 *        videoram;
1317   UINT8 *        spriteram;
src/mame/includes/warriorb.h
r7500r7501
44
55*************************************************************************/
66
7typedef struct _warriorb_state warriorb_state;
8struct _warriorb_state
7class warriorb_state
98{
9public:
10   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, warriorb_state(machine)); }
11
12   warriorb_state(running_machine &machine) { }
13
1014   /* memory pointers */
1115   UINT16 *   spriteram;
1216   size_t     spriteram_size;
src/mame/includes/goal92.h
r7500r7501
44
55*************************************************************************/
66
7typedef struct _goal92_state goal92_state;
8struct _goal92_state
7class goal92_state
98{
9public:
10   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, goal92_state(machine)); }
11
12   goal92_state(running_machine &machine) { }
13
1014   /* memory pointers */
1115   UINT16 *    bg_data;
1216   UINT16 *    fg_data;
src/mame/includes/bishi.h
r7500r7501
77#define CPU_CLOCK       (XTAL_24MHz / 2)      /* 68000 clock */
88#define SOUND_CLOCK     XTAL_16_9344MHz      /* YMZ280 clock */
99
10typedef struct _bishi_state bishi_state;
11struct _bishi_state
10class bishi_state
1211{
12public:
13   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, bishi_state(machine)); }
14
15   bishi_state(running_machine &machine) { }
16
1317   /* memory pointers */
1418   UINT8 *    ram;
1519//  UINT8 *    paletteram;    // currently this uses generic palette handling
src/mame/includes/1942.h
r7500r7501
44
55***************************************************************************/
66
7typedef struct __1942_state _1942_state;
8struct __1942_state
7class _1942_state
98{
9public:
10   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, _1942_state(machine)); }
11
12   _1942_state(running_machine &machine) { }
13
1014   /* memory pointers */
1115   UINT8 * fg_videoram;
1216   UINT8 * bg_videoram;
src/mame/includes/fromanc2.h
r7500r7501
11
2typedef struct _fromanc2_state fromanc2_state;
3struct _fromanc2_state
2class fromanc2_state
43{
4public:
5   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, fromanc2_state(machine)); }
6
7   fromanc2_state(running_machine &machine) { }
8
59   /* memory pointers */
610   UINT16   *paletteram[2];
711   UINT16   *videoram[2][4];
src/mame/includes/bombjack.h
r7500r7501
44
55*************************************************************************/
66
7typedef struct _bombjack_state bombjack_state;
8struct _bombjack_state
7class bombjack_state
98{
9public:
10   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, bombjack_state(machine)); }
11
12   bombjack_state(running_machine &machine) { }
13
1014   /* memory pointers */
1115   UINT8 *    videoram;
1216   UINT8 *    colorram;
src/mame/includes/blockhl.h
r7500r7501
44
55*************************************************************************/
66
7typedef struct _blockhl_state blockhl_state;
8struct _blockhl_state
7class blockhl_state
98{
9public:
10   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, blockhl_state(machine)); }
11
12   blockhl_state(running_machine &machine) { }
13
1014   /* memory pointers */
1115   UINT8 *    ram;
1216//  UINT8 *    paletteram;    // currently this uses generic palette handling
src/mame/includes/gcpinbal.h
r7500r7501
11
2typedef struct _gcpinbal_state gcpinbal_state;
3struct _gcpinbal_state
2class gcpinbal_state
43{
4public:
5   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, gcpinbal_state(machine)); }
6
7   gcpinbal_state(running_machine &machine) { }
8
59   /* memory pointers */
610   UINT16 *    tilemapram;
711   UINT16 *    ioc_ram;
src/mame/includes/carjmbre.h
r7500r7501
44
55***************************************************************************/
66
7typedef struct _carjmbre_state carjmbre_state;
8struct _carjmbre_state
7class carjmbre_state
98{
9public:
10   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, carjmbre_state(machine)); }
11
12   carjmbre_state(running_machine &machine) { }
13
1014   /* memory pointers */
1115   UINT8 * videoram;
1216   UINT8 * spriteram;
src/mame/includes/bottom9.h
r7500r7501
44
55*************************************************************************/
66
7typedef struct _bottom9_state bottom9_state;
8struct _bottom9_state
7class bottom9_state
98{
9public:
10   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, bottom9_state(machine)); }
11
12   bottom9_state(running_machine &machine) { }
13
1014   /* memory pointers */
1115//  UINT8 *    paletteram;    // currently this uses generic palette handling
1216
src/mame/includes/gundealr.h
r7500r7501
44
55*************************************************************************/
66
7typedef struct _gundealr_state gundealr_state;
8struct _gundealr_state
7class gundealr_state
98{
9public:
10   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, gundealr_state(machine)); }
11
12   gundealr_state(running_machine &machine) { }
13
1014   /* memory pointers */
1115   UINT8 *    bg_videoram;
1216   UINT8 *    fg_videoram;
src/mame/includes/mrdo.h
r0r7501
1/*************************************************************************
2
3    Mr. Do
4
5*************************************************************************/
6
7class mrdo_state
8{
9public:
10   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, mrdo_state(machine)); }
11
12   mrdo_state(running_machine &machine) { }
13
14   /* memory pointers */
15   UINT8 *    bgvideoram;
16   UINT8 *    fgvideoram;
17   UINT8 *    spriteram;
18   size_t     spriteram_size;
19
20   /* video-related */
21   tilemap_t *bg_tilemap, *fg_tilemap;
22   int       flipscreen;
23};
24
25
26/*----------- defined in video/mrdo.c -----------*/
27
28WRITE8_HANDLER( mrdo_bgvideoram_w );
29WRITE8_HANDLER( mrdo_fgvideoram_w );
30WRITE8_HANDLER( mrdo_scrollx_w );
31WRITE8_HANDLER( mrdo_scrolly_w );
32WRITE8_HANDLER( mrdo_flipscreen_w );
33
34PALETTE_INIT( mrdo );
35VIDEO_START( mrdo );
36VIDEO_UPDATE( mrdo );
src/mame/includes/mainevt.h
r7500r7501
44
55*************************************************************************/
66
7typedef struct _mainevt_state mainevt_state;
8struct _mainevt_state
7class mainevt_state
98{
9public:
10   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, mainevt_state(machine)); }
11
12   mainevt_state(running_machine &machine) { }
13
1014   /* memory pointers */
1115//  UINT8 *    paletteram;    // currently this uses generic palette handling
1216
src/mame/includes/megazone.h
r0r7501
1/*************************************************************************
2
3    Megazone
4
5*************************************************************************/
6
7class megazone_state
8{
9public:
10   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, megazone_state(machine)); }
11
12   megazone_state(running_machine &machine) { }
13
14   /* memory pointers */
15   UINT8 *       scrollx;
16   UINT8 *       scrolly;
17   UINT8 *       videoram;
18   UINT8 *       colorram;
19   UINT8 *       videoram2;
20   UINT8 *       colorram2;
21   UINT8 *       spriteram;
22   size_t        spriteram_size;
23   size_t        videoram_size;
24   size_t        videoram2_size;
25
26   /* video-related */
27   bitmap_t      *tmpbitmap;
28   int           flipscreen;
29
30   /* misc */
31   int           i8039_status;
32
33   /* devices */
34   running_device *maincpu;
35   running_device *audiocpu;
36   running_device *daccpu;
37};
38
39
40
41/*----------- defined in video/megazone.c -----------*/
42
43WRITE8_HANDLER( megazone_flipscreen_w );
44
45PALETTE_INIT( megazone );
46VIDEO_START( megazone );
47VIDEO_UPDATE( megazone );
src/mame/includes/pass.h
r7500r7501
1typedef struct _pass_state pass_state;
2struct _pass_state
1class pass_state
32{
3public:
4   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, pass_state(machine)); }
5
6   pass_state(running_machine &machine) { }
7
48   tilemap_t *bg_tilemap;
59   tilemap_t *fg_tilemap;
610
src/mame/includes/lasso.h
r7500r7501
44
55***************************************************************************/
66
7typedef struct _lasso_state lasso_state;
8struct _lasso_state
7class lasso_state
98{
9public:
10   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, lasso_state(machine)); }
11
12   lasso_state(running_machine &machine) { }
13
1014   /* memory pointers */
1115   UINT8 *  videoram;
1216   UINT8 *  colorram;
src/mame/includes/taito_h.h
r7500r7501
44
55*************************************************************************/
66
7typedef struct _taitoh_state taitoh_state;
8struct _taitoh_state
7class taitoh_state
98{
9public:
10   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, taitoh_state(machine)); }
11
12   taitoh_state(running_machine &machine) { }
13
1014   /* memory pointers */
1115   UINT16 *    m68000_mainram;
1216//  UINT16 *    paletteram;    // currently this uses generic palette handling
src/mame/includes/othunder.h
r7500r7501
1515};
1616
1717
18typedef struct _othunder_state othunder_state;
19struct _othunder_state
18class othunder_state
2019{
20public:
21   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, othunder_state(machine)); }
22
23   othunder_state(running_machine &machine) { }
24
2125   /* memory pointers */
2226   UINT16 *   spriteram;
2327   size_t     spriteram_size;
src/mame/includes/ginganin.h
r7500r7501
44
55*************************************************************************/
66
7typedef struct _ginganin_state ginganin_state;
8struct _ginganin_state
7class ginganin_state
98{
9public:
10   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, ginganin_state(machine)); }
11
12   ginganin_state(running_machine &machine) { }
13
1014   /* memory pointers */
1115   UINT16 *    fgram;
1216   UINT16 *    txtram;
src/mame/includes/tail2nos.h
r7500r7501
44
55*************************************************************************/
66
7typedef struct _tail2nos_state tail2nos_state;
8struct _tail2nos_state
7class tail2nos_state
98{
9public:
10   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, tail2nos_state(machine)); }
11
12   tail2nos_state(running_machine &machine) { }
13
1014   /* memory pointers */
1115   UINT16 *    bgvideoram;
1216   UINT16 *    spriteram;
src/mame/includes/mrjong.h
r0r7501
1/*************************************************************************
2
3    Mr. Jong
4
5*************************************************************************/
6
7class mrjong_state
8{
9public:
10   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, mrjong_state(machine)); }
11
12   mrjong_state(running_machine &machine) { }
13
14   /* memory pointers */
15   UINT8 *    videoram;
16   UINT8 *    colorram;
17
18   /* video-related */
19   tilemap_t *bg_tilemap;
20};
21
22
23/*----------- defined in video/mrjong.c -----------*/
24
25WRITE8_HANDLER( mrjong_videoram_w );
26WRITE8_HANDLER( mrjong_colorram_w );
27WRITE8_HANDLER( mrjong_flipscreen_w );
28
29PALETTE_INIT( mrjong );
30VIDEO_START( mrjong );
31VIDEO_UPDATE( mrjong );
src/mame/includes/slapshot.h
r7500r7501
1414   int primask;
1515};
1616
17typedef struct _slapshot_state slapshot_state;
18struct _slapshot_state
17class slapshot_state
1918{
19public:
20   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, slapshot_state(machine)); }
21
22   slapshot_state(running_machine &machine) { }
23
2024   /* memory pointers */
2125   UINT16 *    color_ram;
2226   UINT16 *    spriteram;
src/mame/includes/xyonix.h
r7500r7501
1typedef struct _xyonix_state xyonix_state;
2struct _xyonix_state
1class xyonix_state
32{
3public:
4   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, xyonix_state(machine)); }
5
6   xyonix_state(running_machine &machine) { }
7
48   UINT8 *vidram;
59   tilemap_t *tilemap;
610
src/mame/includes/1943.h
r7500r7501
44
55***************************************************************************/
66
7typedef struct __1943_state _1943_state;
8struct __1943_state
7class _1943_state
98{
9public:
10   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, _1943_state(machine)); }
11
12   _1943_state(running_machine &machine) { }
13
1014   /* memory pointers */
1115   UINT8 * videoram;
1216   UINT8 * colorram;
src/mame/includes/cninja.h
r7500r7501
1/*************************************************************************
2
3    Caveman Ninja (and other DECO 16bit titles)
4
5*************************************************************************/
6
7class cninja_state
8{
9public:
10   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, cninja_state(machine)); }
11
12   cninja_state(running_machine &machine) { }
13
14   /* memory pointers */
15   UINT16 *   ram;
16   UINT16 *   pf1_rowscroll;
17   UINT16 *   pf2_rowscroll;
18   UINT16 *   pf3_rowscroll;
19   UINT16 *   pf4_rowscroll;
20
21   /* misc */
22   int        scanline, irq_mask;
23
24   /* devices */
25   running_device *maincpu;
26   running_device *audiocpu;
27   running_device *deco16ic;
28   running_device *raster_irq_timer;
29   running_device *oki2;
30};
31
132/*----------- defined in video/cninja.c -----------*/
233
3VIDEO_START( cninja );
4VIDEO_START( edrandy );
5VIDEO_START( robocop2 );
634VIDEO_START( stoneage );
7VIDEO_START( mutantf );
35
836VIDEO_UPDATE( cninja );
937VIDEO_UPDATE( cninjabl );
1038VIDEO_UPDATE( edrandy );
1139VIDEO_UPDATE( robocop2 );
1240VIDEO_UPDATE( mutantf );
13VIDEO_EOF( cninja );
src/mame/includes/psikyo4.h
r7500r7501
77#define MASTER_CLOCK 57272700   // main oscillator frequency
88
99
10typedef struct _psikyo4_state psikyo4_state;
11struct _psikyo4_state
10class psikyo4_state
1211{
12public:
13   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, psikyo4_state(machine)); }
14
15   psikyo4_state(running_machine &machine) { }
16
1317   /* memory pointers */
1418   UINT32 *       vidregs;
1519   UINT32 *       paletteram;
src/mame/includes/popper.h
r7500r7501
44
55***************************************************************************/
66
7typedef struct _popper_state popper_state;
8struct _popper_state
7class popper_state
98{
9public:
10   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, popper_state(machine)); }
11
12   popper_state(running_machine &machine) { }
13
1014   /* memory pointers */
1115   UINT8 * videoram;
1216   UINT8 * ol_videoram;
src/mame/includes/djboy.h
r7500r7501
66
77#define PROT_OUTPUT_BUFFER_SIZE 8
88
9typedef struct _djboy_state djboy_state;
10struct _djboy_state
9class djboy_state
1110{
11public:
12   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, djboy_state(machine)); }
13
14   djboy_state(running_machine &machine) { }
15
1216   /* memory pointers */
1317   UINT8 *    videoram;
1418   UINT8 *    paletteram;
src/mame/includes/ladyfrog.h
r7500r7501
44
55*************************************************************************/
66
7typedef struct _ladyfrog_state ladyfrog_state;
8struct _ladyfrog_state
7class ladyfrog_state
98{
9public:
10   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, ladyfrog_state(machine)); }
11
12   ladyfrog_state(running_machine &machine) { }
13
1014   /* memory pointers */
1115   UINT8 *    videoram;
1216   UINT8 *    spriteram;
src/mame/includes/sidearms.h
r7500r7501
1typedef struct _sidearms_state sidearms_state;
2struct _sidearms_state
1class sidearms_state
32{
3public:
4   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, sidearms_state(machine)); }
5
6   sidearms_state(running_machine &machine) { }
7
48   int gameid;
59
610   UINT8 *videoram;
src/mame/includes/jack.h
r7500r7501
44
55*************************************************************************/
66
7typedef struct _jack_state jack_state;
8struct _jack_state
7class jack_state
98{
9public:
10   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, jack_state(machine)); }
11
12   jack_state(running_machine &machine) { }
13
1014   /* memory pointers */
1115   UINT8 *    videoram;
1216   UINT8 *    colorram;
src/mame/includes/tumblep.h
r0r7501
1/*************************************************************************
2
3    Tumble Pop
4
5*************************************************************************/
6
7class tumblep_state
8{
9public:
10   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, tumblep_state(machine)); }
11
12   tumblep_state(running_machine &machine) { }
13
14   /* memory pointers */
15   UINT16 *  pf1_rowscroll;
16   UINT16 *  pf2_rowscroll;
17   UINT16 *  spriteram;
18//  UINT16 *  paletteram;    // currently this uses generic palette handling (in deco16ic.c)
19   size_t    spriteram_size;
20
21   /* devices */
22   running_device *maincpu;
23   running_device *audiocpu;
24   running_device *deco16ic;
25};
26
27
28
29/*----------- defined in video/tumblep.c -----------*/
30
31VIDEO_UPDATE( tumblep );
src/mame/includes/dogfgt.h
r7500r7501
33#define BITMAPRAM_SIZE      0x6000
44
55
6typedef struct _dogfgt_state dogfgt_state;
7struct _dogfgt_state
6class dogfgt_state
87{
8public:
9   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, dogfgt_state(machine)); }
10
11   dogfgt_state(running_machine &machine) { }
12
913   /* memory pointers */
1014   UINT8 *    bgvideoram;
1115   UINT8 *    spriteram;
src/mame/includes/dietgo.h
r0r7501
1/*************************************************************************
2
3    Diet Go Go
4
5*************************************************************************/
6
7class dietgo_state
8{
9public:
10   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, dietgo_state(machine)); }
11
12   dietgo_state(running_machine &machine) { }
13
14   /* memory pointers */
15   UINT16 *  pf1_rowscroll;
16   UINT16 *  pf2_rowscroll;
17   UINT16 *  spriteram;
18//  UINT16 *  paletteram;    // currently this uses generic palette handling (in deco16ic.c)
19   size_t    spriteram_size;
20
21   /* devices */
22   running_device *maincpu;
23   running_device *audiocpu;
24   running_device *deco16ic;
25};
26
27
28
29/*----------- defined in video/dietgo.c -----------*/
30
31VIDEO_UPDATE( dietgo );
src/mame/includes/kingobox.h
r7500r7501
44
55*************************************************************************/
66
7typedef struct _kingofb_state kingofb_state;
8struct _kingofb_state
7class kingofb_state
98{
9public:
10   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, kingofb_state(machine)); }
11
12   kingofb_state(running_machine &machine) { }
13
1014   /* memory pointers */
1115   UINT8 *    videoram;
1216   UINT8 *    videoram2;
src/mame/includes/galivan.h
r7500r7501
44
55***************************************************************************/
66
7typedef struct _galivan_state galivan_state;
8struct _galivan_state
7class galivan_state
98{
9public:
10   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, galivan_state(machine)); }
11
12   galivan_state(running_machine &machine) { }
13
1014   /* memory pointers */
1115   UINT8 *     videoram;
1216   UINT8 *     colorram;
src/mame/includes/blockout.h
r7500r7501
44
55***************************************************************************/
66
7typedef struct _blockout_state blockout_state;
8struct _blockout_state
7class blockout_state
98{
9public:
10   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, blockout_state(machine)); }
11
12   blockout_state(running_machine &machine) { }
13
1014   /* memory pointers */
1115   UINT16 * videoram;
1216   UINT16 * frontvideoram;
src/mame/includes/canyon.h
r7500r7501
1717
1818
1919
20typedef struct _canyon_state canyon_state;
21struct _canyon_state
20class canyon_state
2221{
22public:
23   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, canyon_state(machine)); }
24
25   canyon_state(running_machine &machine) { }
26
2327   /* memory pointers */
2428   UINT8 *  videoram;
2529
src/mame/includes/f1gp.h
r7500r7501
11
2typedef struct _f1gp_state f1gp_state;
3struct _f1gp_state
2class f1gp_state
43{
4public:
5   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, f1gp_state(machine)); }
6
7   f1gp_state(running_machine &machine) { }
8
59   /* memory pointers */
610   UINT16 *  sharedram;
711   UINT16 *  spr1vram;
src/mame/includes/dassault.h
r0r7501
1/*************************************************************************
2
3    Desert Assault
4
5*************************************************************************/
6
7class dassault_state
8{
9public:
10   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, dassault_state(machine)); }
11
12   dassault_state(running_machine &machine) { }
13
14   /* memory pointers */
15   UINT16 *  pf2_rowscroll;
16   UINT16 *  pf4_rowscroll;
17   UINT16 *  ram;
18   UINT16 *  ram2;
19   UINT16 *  shared_ram;
20
21   /* devices */
22   running_device *maincpu;
23   running_device *audiocpu;
24   running_device *subcpu;
25   running_device *deco16ic;
26   running_device *oki2;
27};
28
29
30
31/*----------- defined in video/dassault.c -----------*/
32
33VIDEO_UPDATE( dassault );
src/mame/includes/blstroid.h
r7500r7501
66
77#include "machine/atarigen.h"
88
9typedef struct _blstroid_state blstroid_state;
10struct _blstroid_state
9class blstroid_state
1110{
11public:
12   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, blstroid_state(machine)); }
13
14   blstroid_state(running_machine &machine) { }
15
1216   atarigen_state   atarigen;
1317
1418   UINT16 *      priorityram;
src/mame/includes/gotya.h
r7500r7501
11
2typedef struct _gotya_state gotya_state;
3struct _gotya_state
2class gotya_state
43{
4public:
5   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, gotya_state(machine)); }
6
7   gotya_state(running_machine &machine) { }
8
59   /* memory pointers */
610   UINT8 *  videoram;
711   UINT8 *  videoram2;
src/mame/includes/supbtime.h
r0r7501
1/*************************************************************************
2
3    Super Burger Time & China Town
4
5*************************************************************************/
6
7class supbtime_state
8{
9public:
10   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, supbtime_state(machine)); }
11
12   supbtime_state(running_machine &machine) { }
13
14   /* memory pointers */
15   UINT16 *  pf1_rowscroll;
16   UINT16 *  pf2_rowscroll;
17   UINT16 *  spriteram;
18//  UINT16 *  paletteram;    // currently this uses generic palette handling (in deco16ic.c)
19   size_t    spriteram_size;
20
21   /* video-related */
22
23   /* devices */
24   running_device *maincpu;
25   running_device *audiocpu;
26   running_device *deco16ic;
27};
28
29
30
31/*----------- defined in video/supbtime.c -----------*/
32
33VIDEO_UPDATE( supbtime );
src/mame/includes/blmbycar.h
r7500r7501
44
55***************************************************************************/
66
7typedef struct _blmbycar_state blmbycar_state;
8struct _blmbycar_state
7class blmbycar_state
98{
9public:
10   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, blmbycar_state(machine)); }
11
12   blmbycar_state(running_machine &machine) { }
13
1014   /* memory pointers */
1115   UINT16 *    vram_0;
1216   UINT16 *    scroll_0;
src/mame/includes/gbusters.h
r7500r7501
44
55*************************************************************************/
66
7typedef struct _gbusters_state gbusters_state;
8struct _gbusters_state
7class gbusters_state
98{
9public:
10   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, gbusters_state(machine)); }
11
12   gbusters_state(running_machine &machine) { }
13
1014   /* memory pointers */
1115   UINT8 *    ram;
1216//  UINT8 *    paletteram;    // currently this uses generic palette handling
src/mame/includes/bogeyman.h
r7500r7501
44
55*************************************************************************/
66
7typedef struct _bogeyman_state bogeyman_state;
8struct _bogeyman_state
7class bogeyman_state
98{
9public:
10   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, bogeyman_state(machine)); }
11
12   bogeyman_state(running_machine &machine) { }
13
1014   /* memory pointers */
1115   UINT8 *    videoram;
1216   UINT8 *    videoram2;
src/mame/includes/harddriv.h
r7500r7501
77#include "cpu/tms34010/tms34010.h"
88#include "machine/atarigen.h"
99
10typedef struct _harddriv_state harddriv_state;
11struct _harddriv_state
10class harddriv_state
1211{
12public:
13   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, harddriv_state(machine)); }
14
15   harddriv_state(running_machine &machine) { }
16
1317   atarigen_state         atarigen;
1418
1519   running_device *   maincpu;
src/mame/includes/srmp2.h
r7500r7501
1typedef struct _srmp2_state srmp2_state;
2struct _srmp2_state
1class srmp2_state
32{
3public:
4   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, srmp2_state(machine)); }
5
6   srmp2_state(running_machine &machine) { }
7
48   int color_bank;
59   int gfx_bank;
610
src/mame/includes/ohmygod.h
r0r7501
1/*************************************************************************
2
3    Oh My God!
4
5*************************************************************************/
6
7class ohmygod_state
8{
9public:
10   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, ohmygod_state(machine)); }
11
12   ohmygod_state(running_machine &machine) { }
13
14
15   /* memory pointers */
16   UINT16 *    videoram;
17   UINT16 *    spriteram;
18   size_t      spriteram_size;
19
20   /* video-related */
21   tilemap_t    *bg_tilemap;
22   int spritebank;
23   UINT16 scrollx, scrolly;
24
25   /* misc */
26   int adpcm_bank_shift;
27   int sndbank;
28};
29
30
31/*----------- defined in video/ohmygod.c -----------*/
32
33WRITE16_HANDLER( ohmygod_videoram_w );
34WRITE16_HANDLER( ohmygod_spritebank_w );
35WRITE16_HANDLER( ohmygod_scrollx_w );
36WRITE16_HANDLER( ohmygod_scrolly_w );
37
38VIDEO_START( ohmygod );
39VIDEO_UPDATE( ohmygod );
src/mame/includes/aeroboto.h
r7500r7501
44
55***************************************************************************/
66
7typedef struct _aeroboto_state aeroboto_state;
8struct _aeroboto_state
7class aeroboto_state
98{
9public:
10   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, aeroboto_state(machine)); }
11
12   aeroboto_state(running_machine &machine) { }
13
1014   /* memory pointers */
1115   UINT8 * mainram;
1216   UINT8 * spriteram;
src/mame/includes/firetrap.h
r7500r7501
44
55***************************************************************************/
66
7typedef struct _firetrap_state firetrap_state;
8struct _firetrap_state
7class firetrap_state
98{
9public:
10   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, firetrap_state(machine)); }
11
12   firetrap_state(running_machine &machine) { }
13
1014   /* memory pointers */
1115   UINT8 *       bg1videoram;
1216   UINT8 *       bg2videoram;
src/mame/includes/crgolf.h
r7500r7501
77#define MASTER_CLOCK      18432000
88
99
10typedef struct _crgolf_state crgolf_state;
11struct _crgolf_state
10class crgolf_state
1211{
12public:
13   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, crgolf_state(machine)); }
14
15   crgolf_state(running_machine &machine) { }
16
1317   /* memory pointers */
1418   UINT8 *  videoram_a;
1519   UINT8 *  videoram_b;
src/mame/includes/oneshot.h
r7500r7501
1/*----------- defined in drivers/oneshot.c -----------*/
21
3extern UINT16 *oneshot_sprites;
4extern UINT16 *oneshot_bg_videoram;
5extern UINT16 *oneshot_mid_videoram;
6extern UINT16 *oneshot_fg_videoram;
7extern UINT16 *oneshot_scroll;
2class oneshot_state
3{
4public:
5   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, oneshot_state(machine)); }
86
9extern int gun_x_p1,gun_y_p1,gun_x_p2,gun_y_p2;
10extern int gun_x_shift;
7   oneshot_state(running_machine &machine) { }
118
9   /* memory pointers */
10   UINT16 *        sprites;
11   UINT16 *        bg_videoram;
12   UINT16 *        mid_videoram;
13   UINT16 *        fg_videoram;
14   UINT16 *        scroll;
1215
16   /* video-related */
17   tilemap_t  *bg_tilemap, *mid_tilemap, *fg_tilemap;
18
19   /* misc */
20   int gun_x_p1, gun_y_p1, gun_x_p2, gun_y_p2;
21   int gun_x_shift;
22   int p1_wobble, p2_wobble;
23
24   /* devices */
25   running_device *maincpu;
26   running_device *audiocpu;
27};
28
1329/*----------- defined in video/oneshot.c -----------*/
1430
1531WRITE16_HANDLER( oneshot_bg_videoram_w );
1632WRITE16_HANDLER( oneshot_mid_videoram_w );
1733WRITE16_HANDLER( oneshot_fg_videoram_w );
34
1835VIDEO_START( oneshot );
1936VIDEO_UPDATE( oneshot );
2037VIDEO_UPDATE( maddonna );
src/mame/includes/stlforce.h
r7500r7501
1typedef struct _stlforce_state stlforce_state;
2struct _stlforce_state
1class stlforce_state
32{
3public:
4   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, stlforce_state(machine)); }
5
6   stlforce_state(running_machine &machine) { }
7
48   tilemap_t *bg_tilemap;
59   tilemap_t *mlow_tilemap;
610   tilemap_t *mhigh_tilemap;
src/mame/includes/topspeed.h
r7500r7501
44
55*************************************************************************/
66
7typedef struct _topspeed_state topspeed_state;
8struct _topspeed_state
7class topspeed_state
98{
9public:
10   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, topspeed_state(machine)); }
11
12   topspeed_state(running_machine &machine) { }
13
1014   /* memory pointers */
1115   UINT16 *   spritemap;
1216   UINT16 *   raster_ctrl;
src/mame/includes/amspdwy.h
r7500r7501
44
55*************************************************************************/
66
7typedef struct _amspdwy_state amspdwy_state;
8struct _amspdwy_state
7class amspdwy_state
98{
9public:
10   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, amspdwy_state(machine)); }
11
12   amspdwy_state(running_machine &machine) { }
13
1014   /* memory pointers */
1115   UINT8 *    videoram;
1216   UINT8 *    spriteram;
src/mame/includes/fantland.h
r7500r7501
11
22
3typedef struct _fantland_state fantland_state;
4struct _fantland_state
3class fantland_state
54{
5public:
6   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, fantland_state(machine)); }
7
8   fantland_state(running_machine &machine) { }
9
610   /* memory pointers */
711//  UINT8 *    spriteram;   // currently directly used in a 16bit map...
812//  UINT8 *    spriteram_2; // currently directly used in a 16bit map...
src/mame/includes/atarig1.h
r7500r7501
66
77#include "machine/atarigen.h"
88
9typedef struct _atarig1_state atarig1_state;
10struct _atarig1_state
9class atarig1_state
1110{
11public:
12   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, atarig1_state(machine)); }
13
14   atarig1_state(running_machine &machine) { }
15
1216   atarigen_state   atarigen;
1317   UINT8         is_pitfight;
1418
src/mame/includes/bladestl.h
r7500r7501
44
55*************************************************************************/
66
7typedef struct _bladestl_state bladestl_state;
8struct _bladestl_state
7class bladestl_state
98{
9public:
10   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, bladestl_state(machine)); }
11
12   bladestl_state(running_machine &machine) { }
13
1014   /* memory pointers */
1115   UINT8 *    paletteram;
1216
src/mame/includes/toobin.h
r7500r7501
66
77#include "machine/atarigen.h"
88
9typedef struct _toobin_state toobin_state;
10struct _toobin_state
9class toobin_state
1110{
11public:
12   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, toobin_state(machine)); }
13
14   toobin_state(running_machine &machine) { }
15
1216   atarigen_state   atarigen;
1317
1418   UINT16 *      interrupt_scan;
src/mame/includes/overdriv.h
r7500r7501
44
55*************************************************************************/
66
7typedef struct _overdriv_state overdriv_state;
8struct _overdriv_state
7class overdriv_state
98{
9public:
10   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, overdriv_state(machine)); }
11
12   overdriv_state(running_machine &machine) { }
13
1014   /* memory pointers */
1115//  UINT16 *   paletteram;    // currently this uses generic palette handling
1216
src/mame/includes/thunderx.h
r7500r7501
44
55*************************************************************************/
66
7typedef struct _thunderx_state thunderx_state;
8struct _thunderx_state
7class thunderx_state
98{
9public:
10   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, thunderx_state(machine)); }
11
12   thunderx_state(running_machine &machine) { }
13
1014   /* memory pointers */
1115   UINT8 *    ram;
1216   UINT8 *    pmcram;
src/mame/includes/xmen.h
r7500r7501
11
2typedef struct _xmen_state xmen_state;
3struct _xmen_state
2class xmen_state
43{
4public:
5   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, xmen_state(machine)); }
6
7   xmen_state(running_machine &machine) { }
8
59   /* memory pointers */
610//  UINT16 *   paletteram;    // currently this uses generic palette handling
711
src/mame/includes/mario.h
r7500r7501
3030
3131#define MARIO_PALETTE_LENGTH   (256)
3232
33typedef struct _mario_state mario_state;
34struct _mario_state
33class mario_state
3534{
35public:
36   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, mario_state(machine)); }
37
38   mario_state(running_machine &machine) { }
39
3640   /* memory pointers */
3741
3842   /* machine states */
src/mame/includes/atarifb.h
r7500r7501
1515#define ATARIFB_HIT_EN         NODE_05
1616
1717
18typedef struct _atarifb_state atarifb_state;
19struct _atarifb_state
18class atarifb_state
2019{
20public:
21   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, atarifb_state(machine)); }
22
23   atarifb_state(running_machine &machine) { }
24
2125   /* video-related */
2226   UINT8 *  alphap1_videoram;
2327   UINT8 *  alphap2_videoram;
src/mame/includes/silkroad.h
r7500r7501
1typedef struct _silkroad_state silkroad_state;
2struct _silkroad_state
1class silkroad_state
32{
3public:
4   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, silkroad_state(machine)); }
5
6   silkroad_state(running_machine &machine) { }
7
48   UINT32 *vidram;
59   UINT32 *vidram2;
610   UINT32 *vidram3;
src/mame/includes/lethal.h
r7500r7501
44
55*************************************************************************/
66
7typedef struct _lethal_state lethal_state;
8struct _lethal_state
7class lethal_state
98{
9public:
10   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, lethal_state(machine)); }
11
12   lethal_state(running_machine &machine) { }
13
1014   /* memory pointers */
1115//  UINT8 *    paletteram;    // currently this uses generic palette handling
1216
src/mame/includes/exprraid.h
r7500r7501
55*************************************************************************/
66
77
8typedef struct _exprraid_state exprraid_state;
9struct _exprraid_state
8class exprraid_state
109{
10public:
11   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, exprraid_state(machine)); }
12
13   exprraid_state(running_machine &machine) { }
14
1115   /* memory pointers */
1216   UINT8 *        main_ram;
1317   UINT8 *        videoram;
src/mame/includes/toypop.h
r7500r7501
1typedef struct _toypop_state toypop_state;
2struct _toypop_state
1class toypop_state
32{
3public:
4   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, toypop_state(machine)); }
5
6   toypop_state(running_machine &machine) { }
7
48   UINT8 *videoram;
59   UINT8 *spriteram;
610   UINT16 *bg_image;
src/mame/includes/tumbleb.h
r7500r7501
1/*----------- defined in drivers/tumbleb.c -----------*/
21
3extern UINT16* jumppop_control;
4extern UINT16* suprtrio_control;
2class tumbleb_state
3{
4public:
5   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, tumbleb_state(machine)); }
56
7   tumbleb_state(running_machine &machine) { }
68
9   /* memory pointers */
10   UINT16 *    pf1_data;
11   UINT16 *    pf2_data;
12   UINT16 *    mainram;
13   UINT16 *    spriteram;
14   UINT16 *    control;
15   size_t      spriteram_size;
16//  UINT16 *    paletteram;    // currently this uses generic palette handling
17
18   /* misc */
19   int         music_command;
20   int         music_bank;
21   int         music_is_playing;
22
23   /* video-related */
24   tilemap_t   *pf1_tilemap,*pf1_alt_tilemap,*pf2_tilemap,*pf2_alt_tilemap;
25   UINT16      control_0[8];
26   int         flipscreen;
27   UINT16      tilebank;
28   int         sprite_xoffset;
29   int         sprite_yoffset;
30
31   /* devices */
32   running_device *maincpu;
33   running_device *audiocpu;
34   running_device *oki;
35};
36
737/*----------- defined in video/tumbleb.c -----------*/
838
9extern UINT16 *tumblepb_pf1_data,*tumblepb_pf2_data;
39WRITE16_HANDLER( tumblepb_pf1_data_w );
40WRITE16_HANDLER( tumblepb_pf2_data_w );
41WRITE16_HANDLER( fncywld_pf1_data_w );
42WRITE16_HANDLER( fncywld_pf2_data_w );
43WRITE16_HANDLER( tumblepb_control_0_w );
44WRITE16_HANDLER( pangpang_pf1_data_w );
45WRITE16_HANDLER( pangpang_pf2_data_w );
1046
47WRITE16_HANDLER( bcstory_tilebank_w );
48WRITE16_HANDLER( suprtrio_tilebank_w );
49WRITE16_HANDLER( chokchok_tilebank_w );
50WRITE16_HANDLER( wlstar_tilebank_w );
51
1152VIDEO_START( tumblepb );
1253VIDEO_START( fncywld );
1354VIDEO_START( jumppop );
1455VIDEO_START( sdfight );
56VIDEO_START( suprtrio );
57VIDEO_START( pangpang );
58
1559VIDEO_UPDATE( tumblepb );
1660VIDEO_UPDATE( jumpkids );
1761VIDEO_UPDATE( fncywld );
r7500r7501
2064VIDEO_UPDATE( semicom_altoffsets );
2165VIDEO_UPDATE( bcstory );
2266VIDEO_UPDATE(semibase );
23VIDEO_START( suprtrio );
2467VIDEO_UPDATE( suprtrio );
25VIDEO_START( pangpang );
2668VIDEO_UPDATE( pangpang );
2769VIDEO_UPDATE( sdfight );
28
29WRITE16_HANDLER( tumblepb_pf1_data_w );
30WRITE16_HANDLER( tumblepb_pf2_data_w );
31WRITE16_HANDLER( fncywld_pf1_data_w );
32WRITE16_HANDLER( fncywld_pf2_data_w );
33WRITE16_HANDLER( tumblepb_control_0_w );
34WRITE16_HANDLER( pangpang_pf1_data_w );
35WRITE16_HANDLER( pangpang_pf2_data_w );
36
37WRITE16_HANDLER( bcstory_tilebank_w );
38WRITE16_HANDLER( suprtrio_tilebank_w );
39WRITE16_HANDLER( chokchok_tilebank_w );
40WRITE16_HANDLER( wlstar_tilebank_w );
src/mame/includes/micro3d.h
r7500r7501
1111#define VGB_MONITOR_DISPLAY         0
1212#define DRMATH_MONITOR_DISPLAY      1
1313
14typedef struct _micro3d_state micro3d_state;
15struct _micro3d_state
14class micro3d_state
1615{
16public:
17   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, micro3d_state(machine)); }
18
19   micro3d_state(running_machine &machine) { }
20
1721   struct
1822   {
1923      union
src/mame/includes/momoko.h
r0r7501
1/*************************************************************************
2
3    Momoko 120%
4
5*************************************************************************/
6
7class momoko_state
8{
9public:
10   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, momoko_state(machine)); }
11
12   momoko_state(running_machine &machine) { }
13
14   /* memory pointers */
15   UINT8 *        bg_scrollx;
16   UINT8 *        bg_scrolly;
17   UINT8 *        videoram;
18   UINT8 *        spriteram;
19//  UINT8 *        paletteram;    // currently this uses generic palette handling
20   size_t         spriteram_size;
21   size_t         videoram_size;
22
23   /* video-related */
24   UINT8          fg_scrollx;
25   UINT8          fg_scrolly;
26   UINT8          fg_select;
27   UINT8          text_scrolly;
28   UINT8          text_mode;
29   UINT8          bg_select;
30   UINT8          bg_priority;
31   UINT8          bg_mask;
32   UINT8          fg_mask;
33   UINT8          flipscreen;
34};
35
36
37/*----------- defined in video/momoko.c -----------*/
38
39WRITE8_HANDLER( momoko_fg_scrollx_w );
40WRITE8_HANDLER( momoko_fg_scrolly_w );
41WRITE8_HANDLER( momoko_text_scrolly_w );
42WRITE8_HANDLER( momoko_text_mode_w );
43WRITE8_HANDLER( momoko_bg_scrollx_w );
44WRITE8_HANDLER( momoko_bg_scrolly_w );
45WRITE8_HANDLER( momoko_flipscreen_w );
46WRITE8_HANDLER( momoko_fg_select_w);
47WRITE8_HANDLER( momoko_bg_select_w);
48WRITE8_HANDLER( momoko_bg_priority_w);
49
50VIDEO_UPDATE( momoko );
src/mame/includes/kchamp.h
r7500r7501
44
55*************************************************************************/
66
7typedef struct _kchamp_state kchamp_state;
8struct _kchamp_state
7class kchamp_state
98{
9public:
10   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, kchamp_state(machine)); }
11
12   kchamp_state(running_machine &machine) { }
13
1014   /* memory pointers */
1115   UINT8 *    videoram;
1216   UINT8 *    colorram;
src/mame/includes/taito_z.h
r7500r7501
44
55*************************************************************************/
66
7typedef struct _taitoz_state taitoz_state;
8struct _taitoz_state
7class taitoz_state
98{
9public:
10   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, taitoz_state(machine)); }
11
12   taitoz_state(running_machine &machine) { }
13
1014   /* memory pointers */
1115   UINT16 *    spriteram;
1216//  UINT16 *    paletteram;    // currently this uses generic palette handling
src/mame/includes/markham.h
r0r7501
1/*************************************************************************
2
3    Markham
4
5*************************************************************************/
6
7class markham_state
8{
9public:
10   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, markham_state(machine)); }
11
12   markham_state(running_machine &machine) { }
13
14   /* memory pointers */
15   UINT8 *    videoram;
16   UINT8 *    spriteram;
17   UINT8 *    xscroll;
18   size_t     spriteram_size;
19
20   /* video-related */
21   tilemap_t  *bg_tilemap;
22};
23
24
25/*----------- defined in video/markham.c -----------*/
26
27WRITE8_HANDLER( markham_videoram_w );
28WRITE8_HANDLER( markham_flipscreen_w );
29
30PALETTE_INIT( markham );
31VIDEO_START( markham );
32VIDEO_UPDATE( markham );
src/mame/includes/dday.h
r7500r7501
55*************************************************************************/
66
77
8typedef struct _dday_state dday_state;
9struct _dday_state
8class dday_state
109{
10public:
11   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, dday_state(machine)); }
12
13   dday_state(running_machine &machine) { }
14
1115   /* memory pointers */
1216   UINT8 *        bgvideoram;
1317   UINT8 *        fgvideoram;
src/mame/includes/cyberbal.h
r7500r7501
66
77#include "machine/atarigen.h"
88
9typedef struct _cyberbal_state cyberbal_state;
10struct _cyberbal_state
9class cyberbal_state
1110{
11public:
12   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, cyberbal_state(machine)); }
13
14   cyberbal_state(running_machine &machine) { }
15
1216   atarigen_state   atarigen;
1317
1418   UINT16 *      paletteram_0;
src/mame/includes/lockon.h
r7500r7501
55*************************************************************************/
66
77/* Calculated from CRT controller writes */
8#define PIXEL_CLOCK         (XTAL_21MHz / 3)
9#define FRAMEBUFFER_CLOCK   XTAL_10MHz
10#define HBSTART            320
11#define HBEND            0
12#define HTOTAL            448
13#define VBSTART            240
14#define VBEND            0
15#define VTOTAL            280
8#define PIXEL_CLOCK            (XTAL_21MHz / 3)
9#define FRAMEBUFFER_CLOCK      XTAL_10MHz
10#define HBSTART                320
11#define HBEND                  0
12#define HTOTAL                 448
13#define VBSTART                240
14#define VBEND                  0
15#define VTOTAL                 280
1616
17/*----------- defined in drivers/lockon.c -----------*/
18extern UINT8  lockon_ctrl_reg;
19extern UINT32 lockon_main_inten;
2017
18class lockon_state
19{
20public:
21   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, lockon_state(machine)); }
22
23   lockon_state(running_machine &machine) { }
24
25   /* memory pointers */
26   UINT16   *char_ram;
27   UINT16   *hud_ram;
28   UINT16   *scene_ram;
29   UINT16   *ground_ram;
30   UINT16   *object_ram;
31
32   size_t   hudram_size;
33   size_t   objectram_size;
34   size_t   groundram_size;
35
36   /* video-related */
37   tilemap_t   *tilemap;
38   UINT8         ground_ctrl;
39   UINT16      scroll_h;
40   UINT16      scroll_v;
41   bitmap_t    *front_buffer;
42   bitmap_t    *back_buffer;
43   emu_timer   *bufend_timer;
44   emu_timer   *cursor_timer;
45
46   /* Rotation Control */
47   UINT16      xsal;
48   UINT16      x0ll;
49   UINT16      dx0ll;
50   UINT16      dxll;
51   UINT16      ysal;
52   UINT16      y0ll;
53   UINT16      dy0ll;
54   UINT16      dyll;
55
56   /* Object palette RAM control */
57   UINT32      iden;
58   UINT8   *     obj_pal_ram;
59   UINT32      obj_pal_latch;
60   UINT32      obj_pal_addr;
61
62   /* misc */
63   UINT8       ctrl_reg;
64   UINT32      main_inten;
65
66   /* devices */
67   running_device *maincpu;
68   running_device *audiocpu;
69   running_device *ground;
70   running_device *object;
71   running_device *f2203_1l;
72   running_device *f2203_2l;
73   running_device *f2203_3l;
74   running_device *f2203_1r;
75   running_device *f2203_2r;
76   running_device *f2203_3r;
77};
78
79
2180/*----------- defined in video/lockon.c -----------*/
81
2282PALETTE_INIT( lockon );
2383VIDEO_START( lockon );
2484VIDEO_UPDATE( lockon );
r7500r7501
3595WRITE16_HANDLER( lockon_tza112_w );
3696READ16_HANDLER( lockon_obj_4000_r );
3797WRITE16_HANDLER( lockon_obj_4000_w );
38
39extern UINT16 *lockon_char_ram;
40extern UINT16 *lockon_scene_ram;
41extern UINT16 *lockon_object_ram;
42extern UINT16 *lockon_hud_ram;
43extern UINT16 *lockon_ground_ram;
44
45extern size_t lockon_hudram_size;
46extern size_t lockon_objectram_size;
47extern size_t lockon_groundram_size;
src/mame/includes/mappy.h
r7500r7501
1typedef struct _mappy_state mappy_state;
2struct _mappy_state
1class mappy_state
32{
3public:
4   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, mappy_state(machine)); }
5
6   mappy_state(running_machine &machine) { }
7
48   UINT8 *videoram;
59   UINT8 *spriteram;
610   tilemap_t *bg_tilemap;
src/mame/includes/rastan.h
r7500r7501
44
55*************************************************************************/
66
7typedef struct _rastan_state rastan_state;
8struct _rastan_state
7class rastan_state
98{
9public:
10   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, rastan_state(machine)); }
11
12   rastan_state(running_machine &machine) { }
13
1014   /* memory pointers */
1115//  UINT16 *    paletteram; // this currently uses generic palette handlers
1216
src/mame/includes/toaplipt.h
r0r7501
1/*******************************************************************************
2
3    Input port macros used by many games in multiple Toaplan drivers
4    (similar to Taito but bits are ACTIVE_HIGH instead of ACTIVE_LOW)
5
6*******************************************************************************/
7
8
9/**************************** Machine Dip Switches ****************************/
10
11/* with location */
12#define TOAPLAN_DSWA_BITS_2_TO_3_LOC(DIPBANK) \
13   PORT_SERVICE_DIPLOC( 0x04, IP_ACTIVE_HIGH, #DIPBANK":3" ) \
14   PORT_DIPNAME( 0x08, 0x00, DEF_STR( Demo_Sounds ) ) PORT_DIPLOCATION(#DIPBANK":4") \
15   PORT_DIPSETTING(    0x08, DEF_STR( Off ) ) \
16   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
17
18#define TOAPLAN_DSWA_BITS_1_TO_3_LOC(DIPBANK) \
19   PORT_DIPNAME( 0x02, 0x00, DEF_STR( Flip_Screen ) ) PORT_DIPLOCATION(#DIPBANK":2") \
20   PORT_DIPSETTING(    0x00, DEF_STR( Off ) ) \
21   PORT_DIPSETTING(    0x02, DEF_STR( On ) ) \
22   TOAPLAN_DSWA_BITS_2_TO_3_LOC(DIPBANK)
23
24#define TOAPLAN_MACHINE_COCKTAIL_LOC(DIPBANK) \
25   PORT_DIPNAME( 0x01, 0x01, DEF_STR( Cabinet ) ) PORT_DIPLOCATION(#DIPBANK":1") \
26   PORT_DIPSETTING(    0x01, DEF_STR( Upright ) ) \
27   PORT_DIPSETTING(    0x00, DEF_STR( Cocktail ) ) \
28   TOAPLAN_DSWA_BITS_1_TO_3_LOC(DIPBANK)
29
30#define TOAPLAN_MACHINE_NO_COCKTAIL_LOC(DIPBANK) \
31   PORT_DIPUNUSED_DIPLOC( 0x01, IP_ACTIVE_HIGH, #DIPBANK":1" ) \
32   TOAPLAN_DSWA_BITS_1_TO_3_LOC(DIPBANK)
33
34
35/* without location */
36#define TOAPLAN_DSWA_BITS_2_TO_3 \
37   PORT_SERVICE( 0x04, IP_ACTIVE_HIGH ) \
38   PORT_DIPNAME( 0x08, 0x00, DEF_STR( Demo_Sounds ) ) \
39   PORT_DIPSETTING(    0x08, DEF_STR( Off ) ) \
40   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
41
42#define TOAPLAN_DSWA_BITS_1_TO_3 \
43   PORT_DIPNAME( 0x02, 0x00, DEF_STR( Flip_Screen ) ) \
44   PORT_DIPSETTING(    0x00, DEF_STR( Off ) ) \
45   PORT_DIPSETTING(    0x02, DEF_STR( On ) ) \
46   TOAPLAN_DSWA_BITS_2_TO_3
47
48#define TOAPLAN_MACHINE_COCKTAIL \
49   PORT_DIPNAME( 0x01, 0x01, DEF_STR( Cabinet ) ) \
50   PORT_DIPSETTING(    0x01, DEF_STR( Upright ) ) \
51   PORT_DIPSETTING(    0x00, DEF_STR( Cocktail ) ) \
52   TOAPLAN_DSWA_BITS_1_TO_3
53
54#define TOAPLAN_MACHINE_NO_COCKTAIL \
55   PORT_DIPUNUSED( 0x01, IP_ACTIVE_HIGH ) \
56   TOAPLAN_DSWA_BITS_1_TO_3
57
58
59/**************************** Coinage Dip Swicthes ****************************/
60
61/* with location */
62#define TOAPLAN_COINAGE_JAPAN_OLD_COIN_A_LOC(DIPBANK) \
63   PORT_DIPNAME( 0x30, 0x00, DEF_STR( Coin_A ) ) PORT_DIPLOCATION(#DIPBANK":5,6") \
64   PORT_DIPSETTING(    0x20, DEF_STR( 2C_1C ) ) \
65   PORT_DIPSETTING(    0x00, DEF_STR( 1C_1C ) ) \
66   PORT_DIPSETTING(    0x30, DEF_STR( 2C_3C ) ) \
67   PORT_DIPSETTING(    0x10, DEF_STR( 1C_2C ) )
68
69#define TOAPLAN_COINAGE_JAPAN_OLD_COIN_B_LOC(DIPBANK) \
70   PORT_DIPNAME( 0xc0, 0x00, DEF_STR( Coin_B ) ) PORT_DIPLOCATION(#DIPBANK":7,8") \
71   PORT_DIPSETTING(    0x80, DEF_STR( 2C_1C ) ) \
72   PORT_DIPSETTING(    0x00, DEF_STR( 1C_1C ) ) \
73   PORT_DIPSETTING(    0xc0, DEF_STR( 2C_3C ) ) \
74   PORT_DIPSETTING(    0x40, DEF_STR( 1C_2C ) )
75
76#define TOAPLAN_COINAGE_JAPAN_NEW_COIN_A_LOC(DIPBANK) \
77   PORT_DIPNAME( 0x30, 0x00, DEF_STR( Coin_A ) ) PORT_DIPLOCATION(#DIPBANK":5,6") \
78   PORT_DIPSETTING(    0x30, DEF_STR( 3C_1C ) ) \
79   PORT_DIPSETTING(    0x20, DEF_STR( 2C_1C ) ) \
80   PORT_DIPSETTING(    0x00, DEF_STR( 1C_1C ) ) \
81   PORT_DIPSETTING(    0x10, DEF_STR( 1C_2C ) )
82
83#define TOAPLAN_COINAGE_JAPAN_NEW_COIN_B_LOC(DIPBANK) \
84   PORT_DIPNAME( 0xc0, 0x00, DEF_STR( Coin_B ) ) PORT_DIPLOCATION(#DIPBANK":7,8") \
85   PORT_DIPSETTING(    0xc0, DEF_STR( 3C_1C ) ) \
86   PORT_DIPSETTING(    0x80, DEF_STR( 2C_1C ) ) \
87   PORT_DIPSETTING(    0x00, DEF_STR( 1C_1C ) ) \
88   PORT_DIPSETTING(    0x40, DEF_STR( 1C_2C ) )
89
90#define TOAPLAN_COINAGE_WORLD_COIN_A_LOC(DIPBANK) \
91   PORT_DIPNAME( 0x30, 0x00, DEF_STR( Coin_A ) ) PORT_DIPLOCATION(#DIPBANK":5,6") \
92   PORT_DIPSETTING(    0x30, DEF_STR( 4C_1C ) ) \
93   PORT_DIPSETTING(    0x20, DEF_STR( 3C_1C ) ) \
94   PORT_DIPSETTING(    0x10, DEF_STR( 2C_1C ) ) \
95   PORT_DIPSETTING(    0x00, DEF_STR( 1C_1C ) )
96
97#define TOAPLAN_COINAGE_WORLD_COIN_B_LOC(DIPBANK) \
98   PORT_DIPNAME( 0xc0, 0x00, DEF_STR( Coin_B ) ) PORT_DIPLOCATION(#DIPBANK":7,8") \
99   PORT_DIPSETTING(    0x00, DEF_STR( 1C_2C ) ) \
100   PORT_DIPSETTING(    0x40, DEF_STR( 1C_3C ) ) \
101   PORT_DIPSETTING(    0x80, DEF_STR( 1C_4C ) ) \
102   PORT_DIPSETTING(    0xc0, DEF_STR( 1C_6C ) )
103
104#define TOAPLAN_COINAGE_US_COIN_START_LOC(DIPBANK) \
105   PORT_DIPNAME( 0x30, 0x00, DEF_STR( Coinage ) ) PORT_DIPLOCATION(#DIPBANK":5,6") \
106   PORT_DIPSETTING(    0x30, DEF_STR( 4C_1C ) ) \
107   PORT_DIPSETTING(    0x20, DEF_STR( 3C_1C ) ) \
108   PORT_DIPSETTING(    0x10, DEF_STR( 2C_1C ) ) \
109   PORT_DIPSETTING(    0x00, DEF_STR( 1C_1C ) )
110
111#define TOAPLAN_COINAGE_US_COIN_CONT_LOC(DIPBANK) \
112   PORT_DIPNAME( 0xc0, 0x00, "Price to Continue" ) PORT_DIPLOCATION(#DIPBANK":7,8") \
113   PORT_DIPSETTING(    0xc0, DEF_STR( 3C_1C ) ) \
114   PORT_DIPSETTING(    0x80, DEF_STR( 2C_1C ) ) \
115   PORT_DIPSETTING(    0x40, DEF_STR( 1C_1C ) ) \
116   PORT_DIPSETTING(    0x00, "Same as Start" )
117
118#define TOAPLAN_COINAGE_JAPAN_OLD_LOC(DIPBANK) \
119   TOAPLAN_COINAGE_JAPAN_OLD_COIN_A_LOC(DIPBANK) \
120   TOAPLAN_COINAGE_JAPAN_OLD_COIN_B_LOC(DIPBANK)
121
122#define TOAPLAN_COINAGE_JAPAN_NEW_LOC(DIPBANK) \
123   TOAPLAN_COINAGE_JAPAN_NEW_COIN_A_LOC(DIPBANK) \
124   TOAPLAN_COINAGE_JAPAN_NEW_COIN_B_LOC(DIPBANK)
125
126#define TOAPLAN_COINAGE_WORLD_LOC(DIPBANK) \
127   TOAPLAN_COINAGE_WORLD_COIN_A_LOC(DIPBANK) \
128   TOAPLAN_COINAGE_WORLD_COIN_B_LOC(DIPBANK)
129
130#define TOAPLAN_COINAGE_US_LOC(DIPBANK) \
131   TOAPLAN_COINAGE_US_COIN_START_LOC(DIPBANK) \
132   TOAPLAN_COINAGE_US_COIN_CONT_LOC(DIPBANK)
133
134#define TOAPLAN_COINAGE_DUAL_LOC(DIP, MASK, WORLD, DIPBANK) \
135   PORT_DIPNAME( 0x30, 0x30, DEF_STR( Coin_A ) ) PORT_DIPLOCATION(#DIPBANK":5,6") \
136   PORT_DIPSETTING(    0x00, DEF_STR( 4C_1C ) ) PORT_CONDITION(#DIP,MASK,PORTCOND_EQUALS,WORLD) \
137   PORT_DIPSETTING(    0x10, DEF_STR( 3C_1C ) ) PORT_CONDITION(#DIP,MASK,PORTCOND_EQUALS,WORLD) \
138   PORT_DIPSETTING(    0x10, DEF_STR( 2C_1C ) ) PORT_CONDITION(#DIP,MASK,PORTCOND_NOTEQUALS,WORLD) \
139   PORT_DIPSETTING(    0x20, DEF_STR( 2C_1C ) ) PORT_CONDITION(#DIP,MASK,PORTCOND_EQUALS,WORLD) \
140   PORT_DIPSETTING(    0x30, DEF_STR( 1C_1C ) ) PORT_CONDITION(#DIP,MASK,PORTCOND_NOTEQUALS,WORLD) \
141   PORT_DIPSETTING(    0x30, DEF_STR( 1C_1C ) ) PORT_CONDITION(#DIP,MASK,PORTCOND_EQUALS,WORLD) \
142   PORT_DIPSETTING(    0x00, DEF_STR( 2C_3C ) ) PORT_CONDITION(#DIP,MASK,PORTCOND_NOTEQUALS,WORLD) \
143   PORT_DIPSETTING(    0x20, DEF_STR( 1C_2C ) ) PORT_CONDITION(#DIP,MASK,PORTCOND_NOTEQUALS,WORLD) \
144   PORT_DIPNAME( 0xc0, 0xc0, DEF_STR( Coin_B ) ) PORT_DIPLOCATION(#DIPBANK":7,8") \
145   PORT_DIPSETTING(    0x40, DEF_STR( 2C_1C ) ) PORT_CONDITION(#DIP,MASK,PORTCOND_NOTEQUALS,WORLD) \
146   PORT_DIPSETTING(    0xc0, DEF_STR( 1C_1C ) ) PORT_CONDITION(#DIP,MASK,PORTCOND_NOTEQUALS,WORLD) \
147   PORT_DIPSETTING(    0x00, DEF_STR( 2C_3C ) ) PORT_CONDITION(#DIP,MASK,PORTCOND_NOTEQUALS,WORLD) \
148   PORT_DIPSETTING(    0x80, DEF_STR( 1C_2C ) ) PORT_CONDITION(#DIP,MASK,PORTCOND_NOTEQUALS,WORLD) \
149   PORT_DIPSETTING(    0xc0, DEF_STR( 1C_2C ) ) PORT_CONDITION(#DIP,MASK,PORTCOND_EQUALS,WORLD) \
150   PORT_DIPSETTING(    0x80, DEF_STR( 1C_3C ) ) PORT_CONDITION(#DIP,MASK,PORTCOND_EQUALS,WORLD) \
151   PORT_DIPSETTING(    0x40, DEF_STR( 1C_4C ) ) PORT_CONDITION(#DIP,MASK,PORTCOND_EQUALS,WORLD) \
152   PORT_DIPSETTING(    0x00, DEF_STR( 1C_6C ) ) PORT_CONDITION(#DIP,MASK,PORTCOND_EQUALS,WORLD)
153
154/* without location */
155#define TOAPLAN_COINAGE_JAPAN_OLD_COIN_A \
156   PORT_DIPNAME( 0x30, 0x00, DEF_STR( Coin_A ) ) \
157   PORT_DIPSETTING(    0x20, DEF_STR( 2C_1C ) ) \
158   PORT_DIPSETTING(    0x00, DEF_STR( 1C_1C ) ) \
159   PORT_DIPSETTING(    0x30, DEF_STR( 2C_3C ) ) \
160   PORT_DIPSETTING(    0x10, DEF_STR( 1C_2C ) )
161
162#define TOAPLAN_COINAGE_JAPAN_OLD_COIN_B \
163   PORT_DIPNAME( 0xc0, 0x00, DEF_STR( Coin_B ) ) \
164   PORT_DIPSETTING(    0x80, DEF_STR( 2C_1C ) ) \
165   PORT_DIPSETTING(    0x00, DEF_STR( 1C_1C ) ) \
166   PORT_DIPSETTING(    0xc0, DEF_STR( 2C_3C ) ) \
167   PORT_DIPSETTING(    0x40, DEF_STR( 1C_2C ) )
168
169#define TOAPLAN_COINAGE_JAPAN_NEW_COIN_A \
170   PORT_DIPNAME( 0x30, 0x00, DEF_STR( Coin_A ) ) \
171   PORT_DIPSETTING(    0x30, DEF_STR( 3C_1C ) ) \
172   PORT_DIPSETTING(    0x20, DEF_STR( 2C_1C ) ) \
173   PORT_DIPSETTING(    0x00, DEF_STR( 1C_1C ) ) \
174   PORT_DIPSETTING(    0x10, DEF_STR( 1C_2C ) )
175
176#define TOAPLAN_COINAGE_JAPAN_NEW_COIN_B \
177   PORT_DIPNAME( 0xc0, 0x00, DEF_STR( Coin_B ) ) \
178   PORT_DIPSETTING(    0xc0, DEF_STR( 3C_1C ) ) \
179   PORT_DIPSETTING(    0x80, DEF_STR( 2C_1C ) ) \
180   PORT_DIPSETTING(    0x00, DEF_STR( 1C_1C ) ) \
181   PORT_DIPSETTING(    0x40, DEF_STR( 1C_2C ) )
182
183#define TOAPLAN_COINAGE_WORLD_COIN_A \
184   PORT_DIPNAME( 0x30, 0x00, DEF_STR( Coin_A ) ) \
185   PORT_DIPSETTING(    0x30, DEF_STR( 4C_1C ) ) \
186   PORT_DIPSETTING(    0x20, DEF_STR( 3C_1C ) ) \
187   PORT_DIPSETTING(    0x10, DEF_STR( 2C_1C ) ) \
188   PORT_DIPSETTING(    0x00, DEF_STR( 1C_1C ) )
189
190#define TOAPLAN_COINAGE_WORLD_COIN_B \
191   PORT_DIPNAME( 0xc0, 0x00, DEF_STR( Coin_B ) ) \
192   PORT_DIPSETTING(    0x00, DEF_STR( 1C_2C ) ) \
193   PORT_DIPSETTING(    0x40, DEF_STR( 1C_3C ) ) \
194   PORT_DIPSETTING(    0x80, DEF_STR( 1C_4C ) ) \
195   PORT_DIPSETTING(    0xc0, DEF_STR( 1C_6C ) )
196
197#define TOAPLAN_COINAGE_US_COIN_START \
198   PORT_DIPNAME( 0x30, 0x00, DEF_STR( Coinage ) ) \
199   PORT_DIPSETTING(    0x30, DEF_STR( 4C_1C ) ) \
200   PORT_DIPSETTING(    0x20, DEF_STR( 3C_1C ) ) \
201   PORT_DIPSETTING(    0x10, DEF_STR( 2C_1C ) ) \
202   PORT_DIPSETTING(    0x00, DEF_STR( 1C_1C ) )
203
204#define TOAPLAN_COINAGE_US_COIN_CONT \
205   PORT_DIPNAME( 0xc0, 0x00, DEF_STR( Continue_Price ) ) \
206   PORT_DIPSETTING(    0xc0, DEF_STR( 3C_1C ) ) \
207   PORT_DIPSETTING(    0x80, DEF_STR( 2C_1C ) ) \
208   PORT_DIPSETTING(    0x40, DEF_STR( 1C_1C ) ) \
209   PORT_DIPSETTING(    0x00, "Same as Start" )
210
211#define TOAPLAN_COINAGE_JAPAN_OLD \
212   TOAPLAN_COINAGE_JAPAN_OLD_COIN_A \
213   TOAPLAN_COINAGE_JAPAN_OLD_COIN_B
214
215#define TOAPLAN_COINAGE_JAPAN_NEW \
216   TOAPLAN_COINAGE_JAPAN_NEW_COIN_A \
217   TOAPLAN_COINAGE_JAPAN_NEW_COIN_B
218
219#define TOAPLAN_COINAGE_WORLD \
220   TOAPLAN_COINAGE_WORLD_COIN_A \
221   TOAPLAN_COINAGE_WORLD_COIN_B
222
223#define TOAPLAN_COINAGE_US \
224   TOAPLAN_COINAGE_US_COIN_START \
225   TOAPLAN_COINAGE_US_COIN_CONT
226
227#define TOAPLAN_COINAGE_DUAL(DIP, MASK, WORLD) \
228   PORT_DIPNAME( 0x30, 0x00, DEF_STR( Coin_A ) ) \
229   PORT_DIPSETTING(    0x30, DEF_STR( 4C_1C ) ) PORT_CONDITION(#DIP,MASK,PORTCOND_EQUALS,WORLD) \
230   PORT_DIPSETTING(    0x20, DEF_STR( 3C_1C ) ) PORT_CONDITION(#DIP,MASK,PORTCOND_EQUALS,WORLD) \
231   PORT_DIPSETTING(    0x20, DEF_STR( 2C_1C ) ) PORT_CONDITION(#DIP,MASK,PORTCOND_NOTEQUALS,WORLD) \
232   PORT_DIPSETTING(    0x10, DEF_STR( 2C_1C ) ) PORT_CONDITION(#DIP,MASK,PORTCOND_EQUALS,WORLD) \
233   PORT_DIPSETTING(    0x00, DEF_STR( 1C_1C ) ) PORT_CONDITION(#DIP,MASK,PORTCOND_NOTEQUALS,WORLD) \
234   PORT_DIPSETTING(    0x00, DEF_STR( 1C_1C ) ) PORT_CONDITION(#DIP,MASK,PORTCOND_EQUALS,WORLD) \
235   PORT_DIPSETTING(    0x30, DEF_STR( 2C_3C ) ) PORT_CONDITION(#DIP,MASK,PORTCOND_NOTEQUALS,WORLD) \
236   PORT_DIPSETTING(    0x10, DEF_STR( 1C_2C ) ) PORT_CONDITION(#DIP,MASK,PORTCOND_NOTEQUALS,WORLD) \
237   PORT_DIPNAME( 0xc0, 0x00, DEF_STR( Coin_B ) ) \
238   PORT_DIPSETTING(    0x80, DEF_STR( 2C_1C ) ) PORT_CONDITION(#DIP,MASK,PORTCOND_NOTEQUALS,WORLD) \
239   PORT_DIPSETTING(    0x00, DEF_STR( 1C_1C ) ) PORT_CONDITION(#DIP,MASK,PORTCOND_NOTEQUALS,WORLD) \
240   PORT_DIPSETTING(    0xc0, DEF_STR( 2C_3C ) ) PORT_CONDITION(#DIP,MASK,PORTCOND_NOTEQUALS,WORLD) \
241   PORT_DIPSETTING(    0x40, DEF_STR( 1C_2C ) ) PORT_CONDITION(#DIP,MASK,PORTCOND_NOTEQUALS,WORLD) \
242   PORT_DIPSETTING(    0x00, DEF_STR( 1C_2C ) ) PORT_CONDITION(#DIP,MASK,PORTCOND_EQUALS,WORLD) \
243   PORT_DIPSETTING(    0x40, DEF_STR( 1C_3C ) ) PORT_CONDITION(#DIP,MASK,PORTCOND_EQUALS,WORLD) \
244   PORT_DIPSETTING(    0x80, DEF_STR( 1C_4C ) ) PORT_CONDITION(#DIP,MASK,PORTCOND_EQUALS,WORLD) \
245   PORT_DIPSETTING(    0xc0, DEF_STR( 1C_6C ) ) PORT_CONDITION(#DIP,MASK,PORTCOND_EQUALS,WORLD)
246
247
248/************************** Difficulty Dip Switches ***************************/
249
250/* with location */
251#define TOAPLAN_DIFFICULTY_LOC(DIPBANK) \
252   PORT_DIPNAME( 0x03, 0x00, DEF_STR( Difficulty ) ) PORT_DIPLOCATION(#DIPBANK":1,2") \
253   PORT_DIPSETTING(    0x01, DEF_STR( Easy ) ) \
254   PORT_DIPSETTING(    0x00, DEF_STR( Medium ) ) \
255   PORT_DIPSETTING(    0x02, DEF_STR( Hard ) ) \
256   PORT_DIPSETTING(    0x03, DEF_STR( Hardest ) )
257
258/* without location */
259#define TOAPLAN_DIFFICULTY \
260   PORT_DIPNAME( 0x03, 0x00, DEF_STR( Difficulty ) ) \
261   PORT_DIPSETTING(    0x01, DEF_STR( Easy ) ) \
262   PORT_DIPSETTING(    0x00, DEF_STR( Medium ) ) \
263   PORT_DIPSETTING(    0x02, DEF_STR( Hard ) ) \
264   PORT_DIPSETTING(    0x03, DEF_STR( Hardest ) )
265
266
267/************************** Joysticks and buttons *****************************/
268
269/* generic (might be moved elsewhere) */
270#define INPUT_GENERIC_JOY_LOW_NIBBLE(PL, STATE, WAY, B01, B02, B04, B08) \
271   PORT_BIT( 0x01, STATE, IPT_JOYSTICK_##B01 ) WAY PORT_PLAYER(PL) \
272   PORT_BIT( 0x02, STATE, IPT_JOYSTICK_##B02 ) WAY PORT_PLAYER(PL) \
273   PORT_BIT( 0x04, STATE, IPT_JOYSTICK_##B04 ) WAY PORT_PLAYER(PL) \
274   PORT_BIT( 0x08, STATE, IPT_JOYSTICK_##B08 ) WAY PORT_PLAYER(PL)
275
276
277/* Toaplan generic (more might be needed) */
278#define TOAPLAN_GENERIC_JOY_MONO_UDLR(PL) \
279   INPUT_GENERIC_JOY_LOW_NIBBLE(PL, IP_ACTIVE_HIGH, PORT_8WAY, UP, DOWN, LEFT, RIGHT)
280
281
282#define TOAPLAN_GENERIC_BUTTONS_HIGH_NIBBLE(PL, STATE, BUTTON_A, BUTTON_B) \
283   PORT_BIT( 0x10, STATE, IPT_##BUTTON_A ) PORT_PLAYER(PL) \
284   PORT_BIT( 0x20, STATE, IPT_##BUTTON_B ) PORT_PLAYER(PL) \
285   /* DO NOT fill bit 6 as it may be defined as START button ! */
286
287#define TOAPLAN_GENERIC_1_BUTTON(PL) \
288   TOAPLAN_GENERIC_BUTTONS_HIGH_NIBBLE(PL, IP_ACTIVE_HIGH, BUTTON1, UNKNOWN) \
289   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_UNKNOWN )
290
291#define TOAPLAN_GENERIC_2_BUTTONS(PL) \
292   TOAPLAN_GENERIC_BUTTONS_HIGH_NIBBLE(PL, IP_ACTIVE_HIGH, BUTTON1, BUTTON2) \
293   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_UNKNOWN )
294
295#define TOAPLAN_GENERIC_3_BUTTONS(PL) \
296   TOAPLAN_GENERIC_BUTTONS_HIGH_NIBBLE(PL, IP_ACTIVE_HIGH, BUTTON1, BUTTON2) \
297   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_BUTTON3 ) PORT_PLAYER(PL) \
298   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_UNKNOWN )
299
300#define TOAPLAN_GENERIC_1_BUTTON_START(PL) \
301   TOAPLAN_GENERIC_BUTTONS_HIGH_NIBBLE(PL, IP_ACTIVE_HIGH, BUTTON1, UNKNOWN) \
302   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_START##PL ) \
303   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_UNKNOWN )
304
305#define TOAPLAN_GENERIC_2_BUTTONS_START(PL) \
306   TOAPLAN_GENERIC_BUTTONS_HIGH_NIBBLE(PL, IP_ACTIVE_HIGH, BUTTON1, BUTTON2) \
307   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_START##PL ) \
308   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_UNKNOWN )
309
310
311/* Toaplan games (more might be needed) */
312#define TOAPLAN_JOY_UDLR_1_BUTTON(PL) \
313   TOAPLAN_GENERIC_JOY_MONO_UDLR(PL) \
314   TOAPLAN_GENERIC_1_BUTTON(PL)
315
316#define TOAPLAN_JOY_UDLR_2_BUTTONS(PL) \
317   TOAPLAN_GENERIC_JOY_MONO_UDLR(PL) \
318   TOAPLAN_GENERIC_2_BUTTONS(PL)
319
320#define TOAPLAN_JOY_UDLR_3_BUTTONS(PL) \
321   TOAPLAN_GENERIC_JOY_MONO_UDLR(PL) \
322   TOAPLAN_GENERIC_3_BUTTONS(PL)
323
324
325#define TOAPLAN_JOY_UDLR_1_BUTTON_START(PL) \
326   TOAPLAN_GENERIC_JOY_MONO_UDLR(PL) \
327   TOAPLAN_GENERIC_1_BUTTON_START(PL)
328
329#define TOAPLAN_JOY_UDLR_2_BUTTONS_START(PL) \
330   TOAPLAN_GENERIC_JOY_MONO_UDLR(PL) \
331   TOAPLAN_GENERIC_2_BUTTONS_START(PL)
332
333
334/******************************* Test switch **********************************/
335
336/* Set to 0 if you want to see the "TEST" switch as a standard input
337   Set to 1 if you want to see the "TEST" switch as a fake Dip Switch */
338
339#define SHOW_TEST_AS_DIP   1
340
341#if SHOW_TEST_AS_DIP
342#define TOAPLAN_TEST_SWITCH(MASK, STATE) \
343   PORT_DIPNAME( MASK, MASK & STATE, "Test Switch" ) PORT_CODE(KEYCODE_F1) PORT_TOGGLE \
344   PORT_DIPSETTING(    MASK & STATE, DEF_STR( Off ) ) \
345   PORT_DIPSETTING(    MASK & ~STATE, DEF_STR( On ) )
346#else
347#define TOAPLAN_TEST_SWITCH(MASK, STATE) \
348   PORT_BIT( MASK, MASK & STATE, IPT_SPECIAL ) PORT_NAME("Test Switch") PORT_CODE(KEYCODE_F1)
349#endif
350
src/mame/includes/gijoe.h
r7500r7501
44
55*************************************************************************/
66
7typedef struct _gijoe_state gijoe_state;
8struct _gijoe_state
7class gijoe_state
98{
9public:
10   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, gijoe_state(machine)); }
11
12   gijoe_state(running_machine &machine) { }
13
1014   /* memory pointers */
1115   UINT16 *    workram;
1216   UINT16 *    spriteram;
src/mame/includes/metalmx.h
r7500r7501
1typedef struct _metalmx_state metalmx_state;
2struct _metalmx_state
1class metalmx_state
32{
3public:
4   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, metalmx_state(machine)); }
5
6   metalmx_state(running_machine &machine) { }
7
48   running_device *maincpu;
59   running_device *gsp;
610   running_device *adsp;
src/mame/includes/badlands.h
r7500r7501
66
77#include "machine/atarigen.h"
88
9typedef struct _badlands_state badlands_state;
10struct _badlands_state
9class badlands_state
1110{
11public:
12   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, badlands_state(machine)); }
13
14   badlands_state(running_machine &machine) { }
15
1216   atarigen_state   atarigen;
1317
1418   UINT8         pedal_value[2];
src/mame/includes/psikyosh.h
r7500r7501
1616#define SPRITE_PRI(n) (((state->vidregs[2] << (4*n)) & 0xf0000000 ) >> 28)
1717
1818
19typedef struct _psikyosh_state psikyosh_state;
20struct _psikyosh_state
19class psikyosh_state
2120{
21public:
22   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, psikyosh_state(machine)); }
23
24   psikyosh_state(running_machine &machine) { }
25
2226   /* memory pointers */
2327   UINT32 *       bgram;
2428   UINT32 *       zoomram;
src/mame/includes/boogwing.h
r0r7501
1/*************************************************************************
2
3    Boogie Wings
4
5*************************************************************************/
6
7class boogwing_state
8{
9public:
10   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, boogwing_state(machine)); }
11
12   boogwing_state(running_machine &machine) { }
13
14   /* memory pointers */
15   UINT16 *  pf1_rowscroll;
16   UINT16 *  pf2_rowscroll;
17   UINT16 *  pf3_rowscroll;
18   UINT16 *  pf4_rowscroll;
19
20   /* devices */
21   running_device *maincpu;
22   running_device *audiocpu;
23   running_device *deco16ic;
24   running_device *oki1;
25   running_device *oki2;
26};
27
28
29/*----------- defined in video/boogwing.c -----------*/
30
31VIDEO_UPDATE( boogwing );
32
src/mame/includes/offtwall.h
r7500r7501
66
77#include "machine/atarigen.h"
88
9typedef struct _offtwall_state offtwall_state;
10struct _offtwall_state
9class offtwall_state
1110{
11public:
12   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, offtwall_state(machine)); }
13
14   offtwall_state(running_machine &machine) { }
15
1216   atarigen_state   atarigen;
1317};
1418
src/mame/includes/equites.h
r7500r7501
22#define POPDRUMKIT 0
33
44
5typedef struct _equites_state equites_state;
6struct _equites_state
5class equites_state
76{
7public:
8   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, equites_state(machine)); }
9
10   equites_state(running_machine &machine) { }
11
812   /* memory pointers */
913   UINT16 *  bg_videoram;
1014   UINT8  *  fg_videoram;   // 8bits
src/mame/includes/gradius3.h
r7500r7501
44
55*************************************************************************/
66
7typedef struct _gradius3_state gradius3_state;
8struct _gradius3_state
7class gradius3_state
98{
9public:
10   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, gradius3_state(machine)); }
11
12   gradius3_state(running_machine &machine) { }
13
1014   /* memory pointers */
1115   UINT16 *    gfxram;
1216//  UINT16 *    paletteram;    // currently this uses generic palette handling
src/mame/includes/fromance.h
r7500r7501
77
88***************************************************************************/
99
10typedef struct _fromance_state fromance_state;
11struct _fromance_state
10class fromance_state
1211{
12public:
13   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, fromance_state(machine)); }
14
15   fromance_state(running_machine &machine) { }
16
1317   /* memory pointers (used by pipedrm) */
1418   UINT8 *  videoram;
1519   UINT8 *  spriteram;
src/mame/includes/klax.h
r7500r7501
66
77#include "machine/atarigen.h"
88
9typedef struct _klax_state klax_state;
10struct _klax_state
9class klax_state
1110{
11public:
12   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, klax_state(machine)); }
13
14   klax_state(running_machine &machine) { }
15
1216   atarigen_state         atarigen;
1317};
1418
src/mame/includes/neogeo.h
r7500r7501
2828
2929
3030
31typedef struct _neogeo_state neogeo_state;
32struct _neogeo_state
31class neogeo_state
3332{
33public:
34   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, neogeo_state(machine)); }
35
36   neogeo_state(running_machine &machine) { }
37
3438   /* memory pointers */
3539//  UINT8      *memcard_data;   // this currently uses generic handlers
3640//  UINT16     *save_ram;       // this currently uses generic handlers
src/mame/includes/thunderj.h
r7500r7501
66
77#include "machine/atarigen.h"
88
9typedef struct _thunderj_state thunderj_state;
10struct _thunderj_state
9class thunderj_state
1110{
11public:
12   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, thunderj_state(machine)); }
13
14   thunderj_state(running_machine &machine) { }
15
1216   atarigen_state   atarigen;
1317   UINT8         alpha_tile_bank;
1418};
src/mame/includes/ultraman.h
r7500r7501
44
55*************************************************************************/
66
7typedef struct _ultraman_state ultraman_state;
8struct _ultraman_state
7class ultraman_state
98{
9public:
10   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, ultraman_state(machine)); }
11
12   ultraman_state(running_machine &machine) { }
13
1014   /* memory pointers */
1115//  UINT16 *   paletteram;    // currently this uses generic palette handling
1216
src/mame/includes/parodius.h
r7500r7501
44
55*************************************************************************/
66
7typedef struct _parodius_state parodius_state;
8struct _parodius_state
7class parodius_state
98{
9public:
10   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, parodius_state(machine)); }
11
12   parodius_state(running_machine &machine) { }
13
1014   /* memory pointers */
1115   UINT8 *    ram;
1216//  UINT8 *    paletteram;    // currently this uses generic palette handling
src/mame/includes/ladybug.h
r7500r7501
66
77*************************************************************************/
88
9typedef struct _ladybug_state ladybug_state;
10struct _ladybug_state
9class ladybug_state
1110{
11public:
12   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, ladybug_state(machine)); }
13
14   ladybug_state(running_machine &machine) { }
15
1216   /* memory pointers */
1317   UINT8 *    videoram;
1418   UINT8 *    colorram;
src/mame/includes/blueprnt.h
r7500r7501
44
55***************************************************************************/
66
7typedef struct _blueprnt_state blueprnt_state;
8struct _blueprnt_state
7class blueprnt_state
98{
9public:
10   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, blueprnt_state(machine)); }
11
12   blueprnt_state(running_machine &machine) { }
13
1014   /* memory pointers */
1115   UINT8 * videoram;
1216   UINT8 * colorram;
src/mame/includes/combatsc.h
r7500r7501
44
55*************************************************************************/
66
7typedef struct _combatsc_state combatsc_state;
8struct _combatsc_state
7class combatsc_state
98{
9public:
10   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, combatsc_state(machine)); }
11
12   combatsc_state(running_machine &machine) { }
13
1014   /* memory pointers */
1115   UINT8 *    videoram;
1216   UINT8 *    scrollram;
src/mame/includes/rockrage.h
r7500r7501
44
55*************************************************************************/
66
7typedef struct _rockrage_state rockrage_state;
8struct _rockrage_state
7class rockrage_state
98{
9public:
10   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, rockrage_state(machine)); }
11
12   rockrage_state(running_machine &machine) { }
13
1014   /* memory pointers */
1115   UINT8 *    paletteram;
1216
src/mame/includes/buggychl.h
r7500r7501
33    40love.c, bking.c and msisaac.c
44*/
55
6typedef struct _buggychl_state buggychl_state;
7struct _buggychl_state
6class buggychl_state
87{
8public:
9   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, buggychl_state(machine)); }
10
11   buggychl_state(running_machine &machine) { }
12
913   /* memory pointers */
1014   UINT8 *     videoram;   // buggychl, 40love, msisaac
1115   UINT8 *     videoram2;   // msisaac
src/mame/includes/gotcha.h
r7500r7501
44
55*************************************************************************/
66
7typedef struct _gotcha_state gotcha_state;
8struct _gotcha_state
7class gotcha_state
98{
9public:
10   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, gotcha_state(machine)); }
11
12   gotcha_state(running_machine &machine) { }
13
1014   /* memory pointers */
1115   UINT16 *    fgvideoram;
1216   UINT16 *    bgvideoram;
src/mame/includes/bigstrkb.h
r7500r7501
1typedef struct _bigstrkb_state bigstrkb_state;
2struct _bigstrkb_state
1class bigstrkb_state
32{
3public:
4   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, bigstrkb_state(machine)); }
5
6   bigstrkb_state(running_machine &machine) { }
7
48   tilemap_t *tilemap;
59   tilemap_t *tilemap2;
610   tilemap_t *tilemap3;
src/mame/includes/pandoras.h
r7500r7501
44
55*************************************************************************/
66
7typedef struct _pandoras_state pandoras_state;
8struct _pandoras_state
7class pandoras_state
98{
9public:
10   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, pandoras_state(machine)); }
11
12   pandoras_state(running_machine &machine) { }
13
1014   /* memory pointers */
1115   UINT8 *    videoram;
1216   UINT8 *    colorram;
src/mame/includes/taito_f2.h
r7500r7501
88   int primask;
99};
1010
11typedef struct _taitof2_state taitof2_state;
12struct _taitof2_state
11class taitof2_state
1312{
13public:
14   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, taitof2_state(machine)); }
15
16   taitof2_state(running_machine &machine) { }
17
1418   /* memory pointers */
1519   UINT16 *        sprite_extension;
1620   UINT16 *        spriteram;
src/mame/includes/gberet.h
r7500r7501
44
55***************************************************************************/
66
7typedef struct _gberet_state gberet_state;
8struct _gberet_state
7class gberet_state
98{
9public:
10   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, gberet_state(machine)); }
11
12   gberet_state(running_machine &machine) { }
13
1014   /* memory pointers */
1115   UINT8 *     videoram;
1216   UINT8 *     colorram;
src/mame/includes/segas16.h
r7500r7501
11
2typedef struct _segas1x_state segas1x_state;
3struct _segas1x_state
2class segas1x_state
43{
4public:
5   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, segas1x_state(machine)); }
6
7   segas1x_state(running_machine &machine) { }
8
59   /* memory pointers */
610//  UINT16 *  workram;  // this is used in the nvram handler, hence it cannot be added here
711//  UINT16 *  paletteram;   // this is used in the segaic16 mapper, hence it cannot be added here (yet)
src/mame/includes/ddragon.h
r7500r7501
55*************************************************************************/
66
77
8typedef struct _ddragon_state ddragon_state;
9struct _ddragon_state
8class ddragon_state
109{
10public:
11   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, ddragon_state(machine)); }
12
13   ddragon_state(running_machine &machine) { }
14
1115   /* memory pointers */
1216   UINT8 *        rambase;
1317   UINT8 *        bgvideoram;
src/mame/includes/asterix.h
r7500r7501
44
55*************************************************************************/
66
7typedef struct _asterix_state asterix_state;
8struct _asterix_state
7class asterix_state
98{
9public:
10   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, asterix_state(machine)); }
11
12   asterix_state(running_machine &machine) { }
13
1014   /* memory pointers */
1115//  UINT16 *    paletteram;    // currently this uses generic palette handling
1216
src/mame/includes/homedata.h
r7500r7501
11
2typedef struct _homedata_state homedata_state;
3struct _homedata_state
2class homedata_state
43{
4public:
5   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, homedata_state(machine)); }
6
7   homedata_state(running_machine &machine) { }
8
59   /* memory pointers */
610   UINT8 *  vreg;
711   UINT8 *  videoram;
src/mame/includes/mugsmash.h
r7500r7501
1typedef struct _mugsmash_state mugsmash_state;
2struct _mugsmash_state
1
2class mugsmash_state
33{
4public:
5   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, mugsmash_state(machine)); }
6
7   mugsmash_state(running_machine &machine) { }
8
49   UINT16 *videoram1;
510   UINT16 *videoram2;
611   UINT16 *spriteram;
712   UINT16 *regs1;
813   UINT16 *regs2;
14
915   tilemap_t *tilemap1;
1016   tilemap_t *tilemap2;
17
18   running_device *maincpu;
19   running_device *audiocpu;
1120};
1221
1322
src/mame/includes/macrossp.h
r0r7501
1/*************************************************************************
2
3    Macross Plus
4
5*************************************************************************/
6
7class macrossp_state
8{
9public:
10   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, macrossp_state(machine)); }
11
12   macrossp_state(running_machine &machine) { }
13
14   /* memory pointers */
15   UINT32 *         mainram;
16   UINT32 *         scra_videoram;
17   UINT32 *         scra_videoregs;
18   UINT32 *         scrb_videoram;
19   UINT32 *         scrb_videoregs;
20   UINT32 *         scrc_videoram;
21   UINT32 *         scrc_videoregs;
22   UINT32 *         text_videoram;
23   UINT32 *         text_videoregs;
24   UINT32 *         spriteram;
25   UINT32 *         spriteram_old;
26   UINT32 *         spriteram_old2;
27   UINT32 *         paletteram;
28   size_t           spriteram_size;
29
30   /* video-related */
31   tilemap_t  *scra_tilemap, *scrb_tilemap, *scrc_tilemap, *text_tilemap;
32
33   /* misc */
34   int              sndpending;
35   int              snd_toggle;
36   INT32            fade_effect, old_fade;
37
38   /* devices */
39   running_device *maincpu;
40   running_device *audiocpu;
41};
42
43/*----------- defined in video/macrossp.c -----------*/
44
45WRITE32_HANDLER( macrossp_scra_videoram_w );
46WRITE32_HANDLER( macrossp_scrb_videoram_w );
47WRITE32_HANDLER( macrossp_scrc_videoram_w );
48WRITE32_HANDLER( macrossp_text_videoram_w );
49
50VIDEO_START(macrossp);
51VIDEO_UPDATE(macrossp);
52VIDEO_EOF(macrossp);
src/mame/includes/moo.h
r7500r7501
44
55*************************************************************************/
66
7typedef struct _moo_state moo_state;
8struct _moo_state
7class moo_state
98{
9public:
10   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, moo_state(machine)); }
11
12   moo_state(running_machine &machine) { }
13
1014   /* memory pointers */
1115   UINT16 *    workram;
1216   UINT16 *    spriteram;
src/mame/includes/goindol.h
r7500r7501
44
55*************************************************************************/
66
7typedef struct _goindol_state goindol_state;
8struct _goindol_state
7class goindol_state
98{
9public:
10   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, goindol_state(machine)); }
11
12   goindol_state(running_machine &machine) { }
13
1014   /* memory pointers */
1115   UINT8 *    bg_videoram;
1216   UINT8 *    fg_videoram;
src/mame/includes/taito_l.h
r7500r7501
11
22#define TAITOL_SPRITERAM_SIZE 0x400
33
4typedef struct _taitol_state taitol_state;
5struct _taitol_state
4class taitol_state
65{
6public:
7   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, taitol_state(machine)); }
8
9   taitol_state(running_machine &machine) { }
10
711   /* memory pointers */
812   UINT8 *       rambanks;
913   UINT8 *       palette_ram;
src/mame/includes/gyruss.h
r7500r7501
44
55*************************************************************************/
66
7typedef struct _gyruss_state gyruss_state;
8struct _gyruss_state
7class gyruss_state
98{
9public:
10   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, gyruss_state(machine)); }
11
12   gyruss_state(running_machine &machine) { }
13
1014   /* memory pointers */
1115   UINT8 *    videoram;
1216   UINT8 *    colorram;
src/mame/includes/fastlane.h
r7500r7501
44
55*************************************************************************/
66
7typedef struct _fastlane_state fastlane_state;
8struct _fastlane_state
7class fastlane_state
98{
9public:
10   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, fastlane_state(machine)); }
11
12   fastlane_state(running_machine &machine) { }
13
1014   /* memory pointers */
1115   UINT8 *    videoram1;
1216   UINT8 *    videoram2;
src/mame/includes/iremz80.h
r7500r7501
66
77/* These share sound hardware (in audio/irem.h) and hence driver data */
88
9typedef struct _irem_z80_state irem_z80_state;
10struct _irem_z80_state
9class irem_z80_state
1110{
11public:
12   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, irem_z80_state(machine)); }
13
14   irem_z80_state(running_machine &machine) { }
15
1216   /* memory pointers */
1317   UINT8 *              videoram;   // m52, m57, m58
1418   UINT8 *              spriteram;   // m52, m57, m58, m62
src/mame/includes/kangaroo.h
r7500r7501
66
77***************************************************************************/
88
9typedef struct _kangaroo_state kangaroo_state;
10struct _kangaroo_state
9class kangaroo_state
1110{
11public:
12   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, kangaroo_state(machine)); }
13
14   kangaroo_state(running_machine &machine) { }
15
1216   /* memory pointers */
1317   UINT8 *      video_control;
1418
src/mame/includes/cabal.h
r7500r7501
1typedef struct _cabal_state cabal_state;
2struct _cabal_state
1class cabal_state
32{
3public:
4   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, cabal_state(machine)); }
5
6   cabal_state(running_machine &machine) { }
7
48   UINT16 *spriteram;
59   UINT16 *colorram;
610   UINT16 *videoram;
src/mame/includes/cidelsa.h
r7500r7501
2424#define DRACO_PAGERAM_MASK      0x7ff
2525#define CIDELSA_CHARRAM_MASK   0x7ff
2626
27typedef struct _cidelsa_state cidelsa_state;
27class cidelsa_state
28{
29public:
30   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, cidelsa_state(machine)); }
2831
29struct _cidelsa_state
30{
32   cidelsa_state(running_machine &machine) { }
33
3134   /* cpu state */
3235   cdp1802_control_mode cdp1802_mode;
3336
src/mame/includes/vendetta.h
r7500r7501
44
55*************************************************************************/
66
7typedef struct _vendetta_state vendetta_state;
8struct _vendetta_state
7class vendetta_state
98{
9public:
10   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, vendetta_state(machine)); }
11
12   vendetta_state(running_machine &machine) { }
13
1014   /* memory pointers */
1115   UINT8 *    ram;
1216//  UINT8 *    paletteram;    // currently this uses generic palette handling
src/mame/includes/fcombat.h
r7500r7501
2222#define VISIBLE_Y_MAX         (30*8)
2323
2424
25typedef struct _fcombat_state fcombat_state;
26struct _fcombat_state
25class fcombat_state
2726{
27public:
28   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, fcombat_state(machine)); }
29
30   fcombat_state(running_machine &machine) { }
31
2832   /* memory pointers */
2933   UINT8 *    videoram;
3034   UINT8 *    spriteram;
src/mame/includes/pktgaldx.h
r0r7501
1/*************************************************************************
2
3    Pocket Gal Deluxe
4
5*************************************************************************/
6
7class pktgaldx_state
8{
9public:
10   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, pktgaldx_state(machine)); }
11
12   pktgaldx_state(running_machine &machine) { }
13
14   /* memory pointers */
15   UINT16 *  pf1_rowscroll;
16   UINT16 *  pf2_rowscroll;
17   UINT16 *  spriteram;
18//  UINT16 *  paletteram;    // currently this uses generic palette handling (in deco16ic.c)
19   size_t    spriteram_size;
20
21   UINT16*   pktgaldb_fgram;
22   UINT16*   pktgaldb_sprites;
23
24   /* devices */
25   running_device *maincpu;
26   running_device *deco16ic;
27};
28
29
30
31/*----------- defined in video/pktgaldx.c -----------*/
32
33VIDEO_UPDATE( pktgaldx );
34VIDEO_UPDATE( pktgaldb );
src/mame/includes/timeplt.h
r7500r7501
1919
2020#define JUNGLER_MAX_STARS 1000
2121
22typedef struct _timeplt_state timeplt_state;
23struct _timeplt_state
22class timeplt_state
2423{
24public:
25   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, timeplt_state(machine)); }
26
27   timeplt_state(running_machine &machine) { }
28
2529   /* memory pointers */
2630   UINT8 *  videoram;   // timeplt, tutankham, junofrst, rocnrope, pooyan, rallyx
2731   UINT8 *  colorram;   // timeplt, rocnrope, pooyan
src/mame/includes/atarigx2.h
r7500r7501
66
77#include "machine/atarigen.h"
88
9typedef struct _atarigx2_state atarigx2_state;
10struct _atarigx2_state
9class atarigx2_state
1110{
11public:
12   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, atarigx2_state(machine)); }
13
14   atarigx2_state(running_machine &machine) { }
15
1216   atarigen_state   atarigen;
1317   UINT16         playfield_base;
1418   UINT16         motion_object_base;
src/mame/includes/fuukifg2.h
r7500r7501
11
22
3typedef struct _fuuki16_state fuuki16_state;
4struct _fuuki16_state
3class fuuki16_state
54{
5public:
6   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, fuuki16_state(machine)); }
7
8   fuuki16_state(running_machine &machine) { }
9
610   /* memory pointers */
711   UINT16 *    vram_0;
812   UINT16 *    vram_1;
src/mame/includes/circus.h
r7500r7501
66#define GAME_IS_RIPCORD      (state->game_id == 4)
77
88
9typedef struct _circus_state circus_state;
10struct _circus_state
9class circus_state
1110{
11public:
12   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, circus_state(machine)); }
13
14   circus_state(running_machine &machine) { }
15
1216   /* memory pointers */
1317   UINT8 *  videoram;
1418
src/mame/includes/sderby.h
r7500r7501
1typedef struct _sderby_state sderby_state;
2struct _sderby_state
1class sderby_state
32{
3public:
4   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, sderby_state(machine)); }
5
6   sderby_state(running_machine &machine) { }
7
48   UINT16 *spriteram;
59   size_t spriteram_size;
610
src/mame/includes/vastar.h
r7500r7501
1typedef struct _vastar_state vastar_state;
2struct _vastar_state
1class vastar_state
32{
3public:
4   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, vastar_state(machine)); }
5
6   vastar_state(running_machine &machine) { }
7
48   UINT8 *spriteram1;
59   UINT8 *spriteram2;
610   UINT8 *spriteram3;
src/mame/includes/relief.h
r7500r7501
66
77#include "machine/atarigen.h"
88
9typedef struct _relief_state relief_state;
10struct _relief_state
9class relief_state
1110{
11public:
12   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, relief_state(machine)); }
13
14   relief_state(running_machine &machine) { }
15
1216   atarigen_state   atarigen;
1317
1418   UINT8         ym2413_volume;
src/mame/includes/homerun.h
r7500r7501
44
55*************************************************************************/
66
7typedef struct _homerun_state homerun_state;
8struct _homerun_state
7class homerun_state
98{
9public:
10   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, homerun_state(machine)); }
11
12   homerun_state(running_machine &machine) { }
13
1014   /* memory pointers */
1115   UINT8 *    videoram;
1216   UINT8 *    spriteram;
src/mame/includes/champbas.h
r7500r7501
88#define CPUTAG_MCU "mcu"
99
1010
11typedef struct _champbas_state champbas_state;
12struct _champbas_state
11class champbas_state
1312{
13public:
14   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, champbas_state(machine)); }
15
16   champbas_state(running_machine &machine) { }
17
1418   /* memory pointers */
1519   UINT8 *        bg_videoram;
1620   UINT8 *        spriteram;
src/mame/includes/ninjaw.h
r7500r7501
44
55*************************************************************************/
66
7typedef struct _ninjaw_state ninjaw_state;
8struct _ninjaw_state
7class ninjaw_state
98{
9public:
10   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, ninjaw_state(machine)); }
11
12   ninjaw_state(running_machine &machine) { }
13
1014   /* memory pointers */
1115   UINT16 *   spriteram;
1216   size_t     spriteram_size;
src/mame/includes/matmania.h
r7500r7501
1
2class matmania_state
3{
4public:
5   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, matmania_state(machine)); }
6
7   matmania_state(running_machine &machine) { }
8
9   /* memory pointers */
10   UINT8 *         videoram;
11   UINT8 *         videoram2;
12   UINT8 *         videoram3;
13   UINT8 *         colorram;
14   UINT8 *         colorram2;
15   UINT8 *         colorram3;
16   UINT8 *         scroll;
17   UINT8 *         pageselect;
18   UINT8 *         spriteram;
19   UINT8 *         paletteram;
20   size_t          videoram_size;
21   size_t          videoram2_size;
22   size_t          videoram3_size;
23   size_t          spriteram_size;
24
25   /* video-related */
26   bitmap_t        *tmpbitmap;
27   bitmap_t        *tmpbitmap2;
28
29   /* mcu */
30   /* maniach 68705 protection */
31   UINT8           port_a_in, port_a_out, ddr_a;
32   UINT8           port_b_in, port_b_out, ddr_b;
33   UINT8           port_c_in, port_c_out, ddr_c;
34   UINT8           from_main, from_mcu;
35   int             mcu_sent, main_sent;
36
37   /* devices */
38   running_device *maincpu;
39   running_device *audiocpu;
40   running_device *mcu;
41};
42
143/*----------- defined in machine/maniach.c -----------*/
244
3READ8_HANDLER( maniach_68705_portA_r );
4WRITE8_HANDLER( maniach_68705_portA_w );
5READ8_HANDLER( maniach_68705_portB_r );
6WRITE8_HANDLER( maniach_68705_portB_w );
7READ8_HANDLER( maniach_68705_portC_r );
8WRITE8_HANDLER( maniach_68705_portC_w );
9WRITE8_HANDLER( maniach_68705_ddrA_w );
10WRITE8_HANDLER( maniach_68705_ddrB_w );
11WRITE8_HANDLER( maniach_68705_ddrC_w );
45READ8_HANDLER( maniach_68705_port_a_r );
46WRITE8_HANDLER( maniach_68705_port_a_w );
47READ8_HANDLER( maniach_68705_port_b_r );
48WRITE8_HANDLER( maniach_68705_port_b_w );
49READ8_HANDLER( maniach_68705_port_c_r );
50WRITE8_HANDLER( maniach_68705_port_c_w );
51WRITE8_HANDLER( maniach_68705_ddr_a_w );
52WRITE8_HANDLER( maniach_68705_ddr_b_w );
53WRITE8_HANDLER( maniach_68705_ddr_c_w );
1254WRITE8_HANDLER( maniach_mcu_w );
1355READ8_HANDLER( maniach_mcu_r );
1456READ8_HANDLER( maniach_mcu_status_r );
r7500r7501
1658
1759/*----------- defined in video/matmania.c -----------*/
1860
19extern UINT8 *matmania_videoram,*matmania_colorram;
20extern size_t matmania_videoram_size;
21extern UINT8 *matmania_videoram2,*matmania_colorram2;
22extern size_t matmania_videoram2_size;
23extern UINT8 *matmania_videoram3,*matmania_colorram3;
24extern size_t matmania_videoram3_size;
25extern UINT8 *matmania_scroll;
26extern UINT8 *matmania_pageselect;
27
2861WRITE8_HANDLER( matmania_paletteram_w );
2962PALETTE_INIT( matmania );
3063VIDEO_UPDATE( maniach );
src/mame/includes/arkanoid.h
r7500r7501
1010   PADDLE2
1111};
1212
13typedef struct _arkanoid_state arkanoid_state;
14struct _arkanoid_state
13class arkanoid_state
1514{
15public:
16   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, arkanoid_state(machine)); }
17
18   arkanoid_state(running_machine &machine) { }
19
1620   /* memory pointers */
1721   UINT8 *  videoram;
1822   UINT8 *  spriteram;
1923   size_t   spriteram_size;
24   size_t   videoram_size;
2025
2126   /* video-related */
2227   tilemap_t  *bg_tilemap;
r7500r7501
4449
4550extern WRITE8_HANDLER( arkanoid_d008_w );
4651extern WRITE8_HANDLER( tetrsark_d008_w );
52extern WRITE8_HANDLER( hexa_d008_w );
4753
4854extern VIDEO_START( arkanoid );
4955extern VIDEO_UPDATE( arkanoid );
56extern VIDEO_UPDATE( hexa );
5057
5158
5259/*----------- defined in machine/arkanoid.c -----------*/
src/mame/includes/crshrace.h
r7500r7501
11
2typedef struct _crshrace_state crshrace_state;
3struct _crshrace_state
2class crshrace_state
43{
4public:
5   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, crshrace_state(machine)); }
6
7   crshrace_state(running_machine &machine) { }
8
59   /* memory pointers */
610   UINT16 *  videoram1;
711   UINT16 *  videoram2;
src/mame/includes/airbustr.h
r7500r7501
44
55*************************************************************************/
66
7typedef struct _airbustr_state airbustr_state;
8struct _airbustr_state
7class airbustr_state
98{
9public:
10   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, airbustr_state(machine)); }
11
12   airbustr_state(running_machine &machine) { }
13
1014   /* memory pointers */
1115   UINT8 *    videoram;
1216   UINT8 *    videoram2;
src/mame/includes/dcheese.h
r7500r7501
55**************************************************************************/
66
77
8typedef struct _dcheese_state dcheese_state;
9struct _dcheese_state
8class dcheese_state
109{
10public:
11   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, dcheese_state(machine)); }
12
13   dcheese_state(running_machine &machine) { }
14
1115   /* video-related */
1216   UINT16   blitter_color[2];
1317   UINT16   blitter_xparam[16];
src/mame/includes/chqflag.h
r7500r7501
44
55*************************************************************************/
66
7typedef struct _chqflag_state chqflag_state;
8struct _chqflag_state
7class chqflag_state
98{
9public:
10   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, chqflag_state(machine)); }
11
12   chqflag_state(running_machine &machine) { }
13
1014   /* memory pointers */
1115   UINT8 *    ram;
1216//  UINT8 *    paletteram;    // currently this uses generic palette handling
src/mame/includes/bwing.h
r7500r7501
77#define BW_DEBUG 0
88#define MAX_SOUNDS 16
99
10typedef struct _bwing_state bwing_state;
11struct _bwing_state
10class bwing_state
1211{
12public:
13   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, bwing_state(machine)); }
14
15   bwing_state(running_machine &machine) { }
16
1317   /* memory pointers */
1418   UINT8 *    videoram;
1519   UINT8 *    spriteram;
src/mame/includes/sf.h
r7500r7501
44
55*************************************************************************/
66
7typedef struct _sf_state sf_state;
8struct _sf_state
7class sf_state
98{
9public:
10   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, sf_state(machine)); }
11
12   sf_state(running_machine &machine) { }
13
1014   /* memory pointers */
1115   UINT16 *    videoram;
1216   UINT16 *    objectram;
src/mame/includes/lsasquad.h
r7500r7501
1
2class lsasquad_state
3{
4public:
5   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, lsasquad_state(machine)); }
6
7   lsasquad_state(running_machine &machine) { }
8
9   /* memory pointers */
10   UINT8 *      scrollram;
11   UINT8 *      videoram;
12   UINT8 *      spriteram;
13   size_t       spriteram_size;
14   size_t       videoram_size;
15
16   /* misc */
17   int invertcoin;
18   int sound_pending;
19   int sound_nmi_enable, pending_nmi, sound_cmd, sound_result;
20
21   /* daikaiju */
22   int daikaiju_xor, daikaiju_command, daikaiju_length, daikaiju_prev, daikaiju_cnt, daikaiju_cntr;
23   int daikaiju_buffer[256];
24
25   /* mcu */
26   UINT8 from_main, from_mcu;
27   int mcu_sent, main_sent;
28   UINT8 port_a_in, port_a_out, ddr_a;
29   UINT8 port_b_in, port_b_out, ddr_b;
30
31   /* devices */
32   running_device *maincpu;
33   running_device *audiocpu;
34   running_device *mcu;
35};
36
37
138/*----------- defined in machine/daikaiju.c -----------*/
239
340READ8_HANDLER( daikaiju_mcu_r);
r7500r7501
441WRITE8_HANDLER( daikaiju_mcu_w);
542READ8_HANDLER( daikaiju_mcu_status_r);
643
7MACHINE_RESET(daikaiju);
8
9
1044/*----------- defined in machine/lsasquad.c -----------*/
1145
12extern int lsasquad_invertcoin;
13extern int lsasquad_sound_pending;
14
1546WRITE8_HANDLER( lsasquad_sh_nmi_disable_w );
1647WRITE8_HANDLER( lsasquad_sh_nmi_enable_w );
1748WRITE8_HANDLER( lsasquad_sound_command_w );
r7500r7501
2051READ8_HANDLER( lsasquad_sound_result_r );
2152READ8_HANDLER( lsasquad_sound_status_r );
2253
23READ8_HANDLER( lsasquad_68705_portA_r );
24WRITE8_HANDLER( lsasquad_68705_portA_w );
25WRITE8_HANDLER( lsasquad_68705_ddrA_w );
26READ8_HANDLER( lsasquad_68705_portB_r );
27WRITE8_HANDLER( lsasquad_68705_portB_w );
28WRITE8_HANDLER( lsasquad_68705_ddrB_w );
54READ8_HANDLER( lsasquad_68705_port_a_r );
55WRITE8_HANDLER( lsasquad_68705_port_a_w );
56WRITE8_HANDLER( lsasquad_68705_ddr_a_w );
57READ8_HANDLER( lsasquad_68705_port_b_r );
58WRITE8_HANDLER( lsasquad_68705_port_b_w );
59WRITE8_HANDLER( lsasquad_68705_ddr_b_w );
2960WRITE8_HANDLER( lsasquad_mcu_w );
3061READ8_HANDLER( lsasquad_mcu_r );
3162READ8_HANDLER( lsasquad_mcu_status_r );
r7500r7501
3667
3768/*----------- defined in video/lsasquad.c -----------*/
3869
39extern UINT8 *lsasquad_scrollram;
40
4170VIDEO_UPDATE( lsasquad );
4271VIDEO_UPDATE( daikaiju );
src/mame/includes/cave.h
r7500r7501
2121#define MAX_PRIORITY        4
2222#define MAX_SPRITE_NUM      0x400
2323
24typedef struct _cave_state cave_state;
25struct _cave_state
24class cave_state
2625{
26public:
27   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, cave_state(machine)); }
28
29   cave_state(running_machine &machine) { }
30
2731   /* memory pointers */
2832   UINT16 *     videoregs;
2933   UINT16 *     vram_0;
src/mame/includes/brkthru.h
r7500r7501
44
55***************************************************************************/
66
7typedef struct _brkthru_state brkthru_state;
8struct _brkthru_state
7class brkthru_state
98{
9public:
10   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, brkthru_state(machine)); }
11
12   brkthru_state(running_machine &machine) { }
13
1014   /* memory pointers */
1115   UINT8 * videoram;
1216   UINT8 * spriteram;
src/mame/includes/fuukifg3.h
r7500r7501
99/* NOTE: YMF278B_STD_CLOCK is defined in /src/emu/sound/ymf278b.h */
1010
1111
12typedef struct _fuuki32_state fuuki32_state;
13struct _fuuki32_state
12class fuuki32_state
1413{
14public:
15   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, fuuki32_state(machine)); }
16
17   fuuki32_state(running_machine &machine) { }
18
1519   /* memory pointers */
1620   UINT32 *    vram_0;
1721   UINT32 *    vram_1;
src/mame/includes/dec8.h
r7500r7501
11
2typedef struct _dec8_state dec8_state;
3struct _dec8_state
2class dec8_state
43{
4public:
5   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, dec8_state(machine)); }
6
7   dec8_state(running_machine &machine) { }
8
59   /* memory pointers */
610   UINT8 *  videoram;
711   UINT8 *  pf0_data;
src/mame/includes/battlane.h
r7500r7501
44
55***************************************************************************/
66
7typedef struct _battlane_state battlane_state;
8struct _battlane_state
7class battlane_state
98{
9public:
10   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, battlane_state(machine)); }
11
12   battlane_state(running_machine &machine) { }
13
1014   /* memory pointers */
1115   UINT8 *     tileram;
1216   UINT8 *     spriteram;
src/mame/includes/atarigt.h
r7500r7501
1111#define TRAM_ENTRIES      0x4000
1212#define MRAM_ENTRIES      0x8000
1313
14typedef struct _atarigt_state atarigt_state;
15struct _atarigt_state
14class atarigt_state
1615{
16public:
17   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, atarigt_state(machine)); }
18
19   atarigt_state(running_machine &machine) { }
20
1721   atarigen_state   atarigen;
1822   UINT8         is_primrage;
1923   UINT16 *      colorram;
src/mame/includes/cloud9.h
r7500r7501
44
55*************************************************************************/
66
7typedef struct _cloud9_state cloud9_state;
8struct _cloud9_state
7class cloud9_state
98{
9public:
10   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, cloud9_state(machine)); }
11
12   cloud9_state(running_machine &machine) { }
13
1014   /* memory pointers */
1115   UINT8 *     videoram;
1216   UINT8 *     spriteram;
src/mame/includes/changela.h
r7500r7501
11
22
3typedef struct _changela_state changela_state;
4struct _changela_state
3class changela_state
54{
5public:
6   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, changela_state(machine)); }
7
8   changela_state(running_machine &machine) { }
9
610   /* memory pointers */
711   UINT8 *  videoram;
812   UINT8 *  colorram;
src/mame/includes/crimfght.h
r7500r7501
44
55*************************************************************************/
66
7typedef struct _crimfght_state crimfght_state;
8struct _crimfght_state
7class crimfght_state
98{
9public:
10   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, crimfght_state(machine)); }
11
12   crimfght_state(running_machine &machine) { }
13
1014   /* memory pointers */
1115//  UINT8 *    paletteram;    // currently this uses generic palette handling
1216
src/mame/includes/asuka.h
r7500r7501
44
55*************************************************************************/
66
7typedef struct _asuka_state asuka_state;
8struct _asuka_state
7class asuka_state
98{
9public:
10   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, asuka_state(machine)); }
11
12   asuka_state(running_machine &machine) { }
13
1014   /* memory pointers */
1115//  UINT16 *    paletteram; // this currently uses generic palette handlers
1216
src/mame/includes/sidepckt.h
r7500r7501
1typedef struct _sidepckt_state sidepckt_state;
2struct _sidepckt_state
1class sidepckt_state
32{
3public:
4   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, sidepckt_state(machine)); }
5
6   sidepckt_state(running_machine &machine) { }
7
48   tilemap_t *bg_tilemap;
59   UINT8 *colorram;
610   UINT8 *videoram;
src/mame/includes/rollerg.h
r7500r7501
44
55*************************************************************************/
66
7typedef struct _rollerg_state rollerg_state;
8struct _rollerg_state
7class rollerg_state
98{
9public:
10   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, rollerg_state(machine)); }
11
12   rollerg_state(running_machine &machine) { }
13
1014   /* memory pointers */
1115//  UINT8 *    paletteram;    // currently this uses generic palette handling
1216
src/mame/includes/exerion.h
r7500r7501
1818#define EXERION_VBSTART           (240)
1919
2020
21typedef struct _exerion_state exerion_state;
22struct _exerion_state
21class exerion_state
2322{
23public:
24   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, exerion_state(machine)); }
25
26   exerion_state(running_machine &machine) { }
27
2428   /* memory pointers */
2529   UINT8 *  main_ram;
2630   UINT8 *  videoram;
src/mame/includes/mosaic.h
r0r7501
1/*************************************************************************
2
3    Mosaic
4
5*************************************************************************/
6
7class mosaic_state
8{
9public:
10   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, mosaic_state(machine)); }
11
12   mosaic_state(running_machine &machine) { }
13
14   /* memory pointers */
15   UINT8 *        fgvideoram;
16   UINT8 *        bgvideoram;
17//      UINT8 *        paletteram;    // currently this uses generic palette handling
18
19   /* video-related */
20   tilemap_t      *bg_tilemap,*fg_tilemap;
21
22   /* misc */
23   int            prot_val;
24};
25
26
27/*----------- defined in video/mosaic.c -----------*/
28
29WRITE8_HANDLER( mosaic_fgvideoram_w );
30WRITE8_HANDLER( mosaic_bgvideoram_w );
31
32VIDEO_START( mosaic );
33VIDEO_UPDATE( mosaic );
src/mame/includes/crospang.h
r7500r7501
44
55*************************************************************************/
66
7typedef struct _crospang_state crospang_state;
8struct _crospang_state
7class crospang_state
98{
9public:
10   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, crospang_state(machine)); }
11
12   crospang_state(running_machine &machine) { }
13
1014   /* memory pointers */
1115   UINT16 *  bg_videoram;
1216   UINT16 *  fg_videoram;
src/mame/includes/ajax.h
r7500r7501
11
2typedef struct _ajax_state ajax_state;
3struct _ajax_state
2class ajax_state
43{
4public:
5   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, ajax_state(machine)); }
6
7   ajax_state(running_machine &machine) { }
8
59   /* memory pointers */
610//  UINT8 *    paletteram;    // currently this uses generic palette handling
711
src/mame/includes/funybubl.h
r7500r7501
11
22
3typedef struct _funybubl_state funybubl_state;
4struct _funybubl_state
3class funybubl_state
54{
5public:
6   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, funybubl_state(machine)); }
7
8   funybubl_state(running_machine &machine) { }
9
610   /* memory pointers */
711   UINT8 *    banked_vram;
812   UINT8 *    paletteram;
src/mame/mame.mak
r7500r7501
221221SOUNDS += CDP1863
222222SOUNDS += CDP1864
223223SOUNDS += ZSG2
224SOUNDS += MOS656X
224225
225226#-------------------------------------------------
226227# this is the list of driver libraries that
r7500r7501
10941095   $(DRIVERS)/chinsan.o \
10951096   $(DRIVERS)/drmicro.o $(VIDEO)/drmicro.o \
10961097   $(DRIVERS)/jantotsu.o \
1097   $(DRIVERS)/mayumi.o $(VIDEO)/mayumi.o \
1098   $(DRIVERS)/mayumi.o \
10981099   $(DRIVERS)/mermaid.o $(VIDEO)/mermaid.o \
10991100   $(DRIVERS)/mjkjidai.o $(VIDEO)/mjkjidai.o \
11001101
r7500r7501
12551256
12561257$(MAMEOBJ)/taito.a: \
12571258   $(DRIVERS)/40love.o $(VIDEO)/40love.o \
1258   $(DRIVERS)/arkanoid.o $(MACHINE)/arkanoid.o $(VIDEO)/arkanoid.o \
1259   $(DRIVERS)/arkanoid.o $(MACHINE)/arkanoid.o $(VIDEO)/arkanoid.o\
12591260   $(DRIVERS)/ashnojoe.o $(VIDEO)/ashnojoe.o \
12601261   $(DRIVERS)/asuka.o $(MACHINE)/bonzeadv.o $(VIDEO)/asuka.o \
12611262   $(DRIVERS)/bigevglf.o $(MACHINE)/bigevglf.o $(VIDEO)/bigevglf.o \
r7500r7501
13931394   $(DRIVERS)/timelimt.o $(VIDEO)/timelimt.o \
13941395
13951396$(MAMEOBJ)/toaplan.a: \
1396   $(DRIVERS)/mjsister.o $(VIDEO)/mjsister.o \
1397   $(DRIVERS)/mjsister.o \
13971398   $(DRIVERS)/slapfght.o $(MACHINE)/slapfght.o $(VIDEO)/slapfght.o \
13981399   $(DRIVERS)/snowbros.o $(VIDEO)/kan_pand.o $(VIDEO)/kan_panb.o \
13991400   $(DRIVERS)/toaplan1.o $(MACHINE)/toaplan1.o $(VIDEO)/toaplan1.o \
r7500r7501
14851486   $(DRIVERS)/amspdwy.o $(VIDEO)/amspdwy.o \
14861487   $(DRIVERS)/artmagic.o $(VIDEO)/artmagic.o \
14871488   $(DRIVERS)/astrocorp.o \
1488   $(DRIVERS)/attckufo.o $(AUDIO)/attckufo.o $(VIDEO)/attckufo.o \
1489   $(DRIVERS)/attckufo.o \
14891490   $(DRIVERS)/aztarac.o $(AUDIO)/aztarac.o $(VIDEO)/aztarac.o \
14901491   $(DRIVERS)/beaminv.o \
14911492   $(DRIVERS)/big10.o \
r7500r7501
15031504   $(DRIVERS)/coinmvga.o \
15041505   $(DRIVERS)/comebaby.o \
15051506   $(DRIVERS)/coolpool.o \
1506   $(DRIVERS)/cowrace.o \
15071507   $(DRIVERS)/crystal.o $(DRIVERS)/psattack.o $(VIDEO)/vrender0.o \
15081508   $(DRIVERS)/cubeqst.o \
15091509   $(DRIVERS)/cybertnk.o \
r7500r7501
15361536   $(DRIVERS)/gstream.o \
15371537   $(DRIVERS)/gumbo.o $(VIDEO)/gumbo.o \
15381538   $(DRIVERS)/gunpey.o \
1539   $(DRIVERS)/hexa.o $(VIDEO)/hexa.o \
15401539   $(DRIVERS)/highvdeo.o \
15411540   $(DRIVERS)/himesiki.o $(VIDEO)/himesiki.o \
15421541   $(DRIVERS)/hitpoker.o \
r7500r7501
15761575   $(DRIVERS)/mirage.o \
15771576   $(DRIVERS)/mirax.o \
15781577   $(DRIVERS)/mirderby.o \
1579   $(DRIVERS)/mole.o $(VIDEO)/mole.o \
1578   $(DRIVERS)/mole.o \
15801579   $(DRIVERS)/mosaic.o $(VIDEO)/mosaic.o \
15811580   $(DRIVERS)/mrjong.o $(VIDEO)/mrjong.o \
15821581   $(DRIVERS)/multfish.o \
r7500r7501
16061605   $(DRIVERS)/pntnpuzl.o \
16071606   $(DRIVERS)/policetr.o $(VIDEO)/policetr.o \
16081607   $(DRIVERS)/polyplay.o $(AUDIO)/polyplay.o $(VIDEO)/polyplay.o \
1608   $(DRIVERS)/poo.o \
16091609   $(DRIVERS)/quakeat.o \
16101610   $(DRIVERS)/queen.o \
16111611   $(DRIVERS)/quizo.o \
r7500r7501
16131613   $(DRIVERS)/rbmk.o \
16141614   $(DRIVERS)/rcorsair.o \
16151615   $(DRIVERS)/re900.o \
1616   $(DRIVERS)/rgum.o \
16161617   $(DRIVERS)/roul.o \
16171618   $(DRIVERS)/sfbonus.o \
16181619   $(DRIVERS)/shangkid.o $(VIDEO)/shangkid.o \
src/mame/video/nycaptor.c
r7500r7501
1111#define NYCAPTOR_DEBUG   0
1212
1313#if NYCAPTOR_DEBUG
14static  int nycaptor_mask=0;
14static  int nycaptor_mask = 0;
1515#endif
1616
17static tilemap_t *bg_tilemap;
18static int char_bank,palette_bank,gfxctrl;
1917
20UINT8 *nycaptor_scrlram;
21
22static UINT8 *nycaptor_spriteram;
23
2418/*
2519 298 (e298) - spot (0-3) , 299 (e299) - lives
2620 spot number isn't set to 0 in main menu ; lives - yes
2721 sprites in main menu req priority 'type' 0
2822*/
29static int nycaptor_spot(void)
23static int nycaptor_spot( running_machine *machine )
3024{
31   if(nyc_gametype==0 || nyc_gametype==2)
32      return nycaptor_sharedram[0x299]?nycaptor_sharedram[0x298]:0;
25   nycaptor_state *state = (nycaptor_state *)machine->driver_data;
26
27   if (state->gametype == 0 || state->gametype == 2)
28      return state->sharedram[0x299] ? state->sharedram[0x298] : 0;
3329   else
3430      return 0;
3531}
3632
3733WRITE8_HANDLER(nycaptor_spriteram_w)
3834{
39   nycaptor_spriteram[offset]=data;
35   nycaptor_state *state = (nycaptor_state *)space->machine->driver_data;
36   state->spriteram[offset] = data;
4037}
4138
4239READ8_HANDLER(nycaptor_spriteram_r)
4340{
44   return nycaptor_spriteram[offset];
41   nycaptor_state *state = (nycaptor_state *)space->machine->driver_data;
42   return state->spriteram[offset];
4543}
4644
4745static TILE_GET_INFO( get_tile_info )
4846{
49   int pal;
50   tileinfo->category = (machine->generic.videoram.u8[tile_index*2 + 1] & 0x30)>>4;
51   pal=machine->generic.videoram.u8[tile_index*2+1]&0x0f;
52  tileinfo->group=0;
53  if((!nycaptor_spot())&&(pal==6))tileinfo->group=1;
54   if(((nycaptor_spot()==3)&&(pal==8))||((nycaptor_spot()==1)&&(pal==0xc)))tileinfo->group=2;
55   if((nycaptor_spot()==1)&&(tileinfo->category==2))tileinfo->group=3;
47   nycaptor_state *state = (nycaptor_state *)machine->driver_data;
48   int pal = state->videoram[tile_index * 2 + 1] & 0x0f;
49   tileinfo->category = (state->videoram[tile_index * 2 + 1] & 0x30) >> 4;
50
51   tileinfo->group = 0;
52
53   if ((!nycaptor_spot(machine)) && (pal == 6))
54      tileinfo->group = 1;
55
56   if (((nycaptor_spot(machine) == 3) && (pal == 8)) || ((nycaptor_spot(machine) == 1) && (pal == 0xc)))
57      tileinfo->group = 2;
58
59   if ((nycaptor_spot(machine) == 1) && (tileinfo->category == 2))
60      tileinfo->group = 3;
61
5662#if NYCAPTOR_DEBUG
57  if(nycaptor_mask&(1<<tileinfo->category))
58  {
59    if(nycaptor_spot())pal=0xe;else pal=4;
60  }
63   if (nycaptor_mask & (1 << tileinfo->category))
64   {
65      if (nycaptor_spot(machine))
66         pal = 0xe;
67      else
68         pal = 4;
69   }
6170#endif
6271
6372   SET_TILE_INFO(
6473         0,
65         machine->generic.videoram.u8[tile_index*2] + ((machine->generic.videoram.u8[tile_index*2+1] & 0xc0) << 2) +0x400 * char_bank,
66         pal,0
74         state->videoram[tile_index * 2] + ((state->videoram[tile_index * 2 + 1] & 0xc0) << 2) + 0x400 * state->char_bank,
75         pal, 0
6776         );
6877}
6978
7079
7180VIDEO_START( nycaptor )
7281{
73  nycaptor_spriteram = auto_alloc_array(machine, UINT8, 160);
74  bg_tilemap = tilemap_create( machine, get_tile_info,tilemap_scan_rows,8,8,32,32 );
82   nycaptor_state *state = (nycaptor_state *)machine->driver_data;
7583
76  tilemap_set_transmask(bg_tilemap,0,0xf800,0x7ff); //split 0
77  tilemap_set_transmask(bg_tilemap,1,0xfe00,0x01ff);//split 1
78  tilemap_set_transmask(bg_tilemap,2,0xfffc,0x0003);//split 2
79  tilemap_set_transmask(bg_tilemap,3,0xfff0,0x000f);//split 3
84   state->spriteram = auto_alloc_array(machine, UINT8, 160);
85   state->bg_tilemap = tilemap_create(machine, get_tile_info, tilemap_scan_rows, 8, 8, 32, 32 );
8086
87   tilemap_set_transmask(state->bg_tilemap, 0, 0xf800, 0x7ff); //split 0
88   tilemap_set_transmask(state->bg_tilemap, 1, 0xfe00, 0x01ff);//split 1
89   tilemap_set_transmask(state->bg_tilemap, 2, 0xfffc, 0x0003);//split 2
90   tilemap_set_transmask(state->bg_tilemap, 3, 0xfff0, 0x000f);//split 3
91
8192   machine->generic.paletteram.u8 = auto_alloc_array(machine, UINT8, 0x200);
8293   machine->generic.paletteram2.u8 = auto_alloc_array(machine, UINT8, 0x200);
83   tilemap_set_scroll_cols(bg_tilemap,32);
94   tilemap_set_scroll_cols(state->bg_tilemap, 32);
95
96   state_save_register_global_pointer(machine, state->spriteram, 160);
97   state_save_register_global_pointer(machine, machine->generic.paletteram.u8, 0x200);
98   state_save_register_global_pointer(machine, machine->generic.paletteram2.u8, 0x200);
8499}
85100
86101WRITE8_HANDLER( nycaptor_videoram_w )
87102{
88   space->machine->generic.videoram.u8[offset] = data;
89   tilemap_mark_tile_dirty(bg_tilemap,offset>>1);
103   nycaptor_state *state = (nycaptor_state *)space->machine->driver_data;
104   state->videoram[offset] = data;
105   tilemap_mark_tile_dirty(state->bg_tilemap, offset >> 1);
90106}
91107
92108READ8_HANDLER( nycaptor_videoram_r )
93109{
94   return space->machine->generic.videoram.u8[offset];
110   nycaptor_state *state = (nycaptor_state *)space->machine->driver_data;
111   return state->videoram[offset];
95112}
96113
97114WRITE8_HANDLER( nycaptor_palette_w )
98115{
99   if(nyc_gametype==2) //colt
116   nycaptor_state *state = (nycaptor_state *)space->machine->driver_data;
117
118   if (state->gametype == 2) //colt
100119      return;
101120
102121   if (offset & 0x100)
103      paletteram_xxxxBBBBGGGGRRRR_split2_w(space, (offset & 0xff) + (palette_bank << 8),data);
122      paletteram_xxxxBBBBGGGGRRRR_split2_w(space, (offset & 0xff) + (state->palette_bank << 8), data);
104123   else
105      paletteram_xxxxBBBBGGGGRRRR_split1_w(space, (offset & 0xff) + (palette_bank << 8),data);
124      paletteram_xxxxBBBBGGGGRRRR_split1_w(space, (offset & 0xff) + (state->palette_bank << 8), data);
106125}
107126
108127READ8_HANDLER( nycaptor_palette_r )
109128{
129   nycaptor_state *state = (nycaptor_state *)space->machine->driver_data;
130
110131   if (offset & 0x100)
111      return space->machine->generic.paletteram2.u8[ (offset & 0xff) + (palette_bank << 8) ];
132      return space->machine->generic.paletteram2.u8[(offset & 0xff) + (state->palette_bank << 8)];
112133   else
113      return space->machine->generic.paletteram.u8 [ (offset & 0xff) + (palette_bank << 8) ];
134      return space->machine->generic.paletteram.u8 [(offset & 0xff) + (state->palette_bank << 8)];
114135}
115136
116137WRITE8_HANDLER( nycaptor_gfxctrl_w )
117138{
118   if (gfxctrl == data)
139   nycaptor_state *state = (nycaptor_state *)space->machine->driver_data;
140
141   if (state->gfxctrl == data)
119142      return;
120   gfxctrl = data;
121143
122   if(char_bank != ((data & 0x18) >> 3))
144   state->gfxctrl = data;
145
146   if (state->char_bank != ((data & 0x18) >> 3))
123147   {
124      char_bank=((data & 0x18) >> 3);
125      tilemap_mark_all_tiles_dirty( bg_tilemap );
148      state->char_bank = ((data & 0x18) >> 3);
149      tilemap_mark_all_tiles_dirty(state->bg_tilemap);
126150   }
127   palette_bank = (data & 0x20) >> 5;
128151
152   state->palette_bank = BIT(data, 5);
153
129154}
130155
131156READ8_HANDLER( nycaptor_gfxctrl_r )
132157{
133      return   gfxctrl;
158   nycaptor_state *state = (nycaptor_state *)space->machine->driver_data;
159   return state->gfxctrl;
134160}
135161
136162READ8_HANDLER( nycaptor_scrlram_r )
137163{
138   return nycaptor_scrlram[offset];
164   nycaptor_state *state = (nycaptor_state *)space->machine->driver_data;
165   return state->scrlram[offset];
139166}
140167
141168WRITE8_HANDLER( nycaptor_scrlram_w )
142169{
143   nycaptor_scrlram[offset] = data;
144   tilemap_set_scrolly(bg_tilemap, offset, data );
170   nycaptor_state *state = (nycaptor_state *)space->machine->driver_data;
171   state->scrlram[offset] = data;
172   tilemap_set_scrolly(state->bg_tilemap, offset, data);
145173}
146174
147static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect,int pri)
175static void draw_sprites( running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, int pri )
148176{
177   nycaptor_state *state = (nycaptor_state *)machine->driver_data;
149178   int i;
150   for (i=0;i<0x20;i++)
179
180   for (i = 0; i < 0x20; i++)
151181   {
152      int pr = nycaptor_spriteram[0x9f-i];
182      int pr = state->spriteram[0x9f - i];
153183      int offs = (pr & 0x1f) * 4;
154      int code,sx,sy,flipx,flipy,pal,priori;
184      int code, sx, sy, flipx, flipy, pal, priori;
155185
156      code = nycaptor_spriteram[offs+2] + ((nycaptor_spriteram[offs+1] & 0x10) << 4);//1 bit wolny = 0x20
157      pal=nycaptor_spriteram[offs+1] & 0x0f;
158      sx = nycaptor_spriteram[offs+3];
159      sy = 240-nycaptor_spriteram[offs+0];
160      priori=(pr&0xe0)>>5;
161      if(priori==pri)
186      code = state->spriteram[offs + 2] + ((state->spriteram[offs + 1] & 0x10) << 4);//1 bit wolny = 0x20
187      pal  = state->spriteram[offs + 1] & 0x0f;
188      sx   = state->spriteram[offs + 3];
189      sy   = 240 - state->spriteram[offs + 0];
190      priori = (pr & 0xe0) >> 5;
191
192      if (priori == pri)
162193      {
163194#if NYCAPTOR_DEBUG
164         if(nycaptor_mask&(1<<(pri+4)))pal=0xd;
195         if (nycaptor_mask & (1 << (pri + 4))) pal = 0xd;
165196#endif
166         flipx = ((nycaptor_spriteram[offs+1]&0x40)>>6);
167         flipy = ((nycaptor_spriteram[offs+1]&0x80)>>7);
197         flipx = BIT(state->spriteram[offs + 1], 6);
198         flipy = BIT(state->spriteram[offs + 1], 7);
168199
169         drawgfx_transpen(bitmap,cliprect,machine->gfx[1],
200         drawgfx_transpen(bitmap, cliprect, machine->gfx[1],
170201               code,
171202               pal,
172203               flipx,flipy,
173204               sx,sy,15);
174205
175         if(nycaptor_spriteram[offs+3]>240)
206         if (state->spriteram[offs + 3] > 240)
176207         {
177            sx = (nycaptor_spriteram[offs+3]-256);
178            drawgfx_transpen(bitmap,cliprect,machine->gfx[1],
179                    code,
180                    pal,
181                    flipx,flipy,
182                     sx,sy,15);
208            sx = (state->spriteram[offs + 3] - 256);
209            drawgfx_transpen(bitmap, cliprect, machine->gfx[1],
210               code,
211               pal,
212               flipx,flipy,
213               sx,sy,15);
183214         }
184215      }
185216   }
r7500r7501
198229   x - no bg/sprite pri.
199230*/
200231
201#define mKEY_MASK(x,y) if (input_code_pressed_once(machine, x)){nycaptor_mask|=y;tilemap_mark_all_tiles_dirty( bg_tilemap );}
232#define mKEY_MASK(x,y) if (input_code_pressed_once(machine, x)) { nycaptor_mask |= y; tilemap_mark_all_tiles_dirty(state->bg_tilemap);}
202233
203static void nycaptor_setmask(running_machine *machine)
234static void nycaptor_setmask( running_machine *machine )
204235{
205  mKEY_MASK(KEYCODE_Q,1); /* bg */
206  mKEY_MASK(KEYCODE_W,2);
207  mKEY_MASK(KEYCODE_E,4);
208  mKEY_MASK(KEYCODE_R,8);
236   nycaptor_state *state = (nycaptor_state *)machine->driver_data;
209237
210  mKEY_MASK(KEYCODE_A,0x10); /* sprites */
211  mKEY_MASK(KEYCODE_S,0x20);
212  mKEY_MASK(KEYCODE_D,0x40);
213  mKEY_MASK(KEYCODE_F,0x80);
214  mKEY_MASK(KEYCODE_G,0x100);
215  mKEY_MASK(KEYCODE_H,0x200);
216  mKEY_MASK(KEYCODE_J,0x400);
217  mKEY_MASK(KEYCODE_K,0x800);
238   mKEY_MASK(KEYCODE_Q, 1); /* bg */
239   mKEY_MASK(KEYCODE_W, 2);
240   mKEY_MASK(KEYCODE_E, 4);
241   mKEY_MASK(KEYCODE_R, 8);
218242
219  if (input_code_pressed_once(machine, KEYCODE_Z)){nycaptor_mask=0;tilemap_mark_all_tiles_dirty( bg_tilemap );} /* disable */
220  if (input_code_pressed_once(machine, KEYCODE_X)){nycaptor_mask|=0x1000;tilemap_mark_all_tiles_dirty( bg_tilemap );} /* no layers */
243   mKEY_MASK(KEYCODE_A, 0x10); /* sprites */
244   mKEY_MASK(KEYCODE_S, 0x20);
245   mKEY_MASK(KEYCODE_D, 0x40);
246   mKEY_MASK(KEYCODE_F, 0x80);
247   mKEY_MASK(KEYCODE_G, 0x100);
248   mKEY_MASK(KEYCODE_H, 0x200);
249   mKEY_MASK(KEYCODE_J, 0x400);
250   mKEY_MASK(KEYCODE_K, 0x800);
251
252   if (input_code_pressed_once(machine, KEYCODE_Z)){nycaptor_mask = 0; tilemap_mark_all_tiles_dirty(state->bg_tilemap);} /* disable */
253   if (input_code_pressed_once(machine, KEYCODE_X)){nycaptor_mask |= 0x1000; tilemap_mark_all_tiles_dirty(state->bg_tilemap);} /* no layers */
221254}
222255#endif
223256
224257VIDEO_UPDATE( nycaptor )
225258{
259   nycaptor_state *state = (nycaptor_state *)screen->machine->driver_data;
260
226261#if NYCAPTOR_DEBUG
227  nycaptor_setmask(screen->machine);
228  if(nycaptor_mask&0x1000)
229  {
230       tilemap_draw(bitmap,cliprect,bg_tilemap,TILEMAP_DRAW_LAYER1|3,0);
231       tilemap_draw(bitmap,cliprect,bg_tilemap,TILEMAP_DRAW_LAYER0|3,0);
232       tilemap_draw(bitmap,cliprect,bg_tilemap,TILEMAP_DRAW_LAYER1|2,0);
233       tilemap_draw(bitmap,cliprect,bg_tilemap,TILEMAP_DRAW_LAYER0|2,0);
234       tilemap_draw(bitmap,cliprect,bg_tilemap,TILEMAP_DRAW_LAYER1|1,0);
235       tilemap_draw(bitmap,cliprect,bg_tilemap,TILEMAP_DRAW_LAYER0|1,0);
236       tilemap_draw(bitmap,cliprect,bg_tilemap,TILEMAP_DRAW_LAYER1|0,0);
237       tilemap_draw(bitmap,cliprect,bg_tilemap,TILEMAP_DRAW_LAYER0|0,0);
238       draw_sprites(screen->machine, bitmap,cliprect,0);
239       draw_sprites(screen->machine, bitmap,cliprect,1);
240       draw_sprites(screen->machine, bitmap,cliprect,2);
241       draw_sprites(screen->machine, bitmap,cliprect,3);
242       draw_sprites(screen->machine, bitmap,cliprect,4);
243       draw_sprites(screen->machine, bitmap,cliprect,5);
244       draw_sprites(screen->machine, bitmap,cliprect,6);
245       draw_sprites(screen->machine, bitmap,cliprect,7);
246  }
247 else
248#endif
249 switch (nycaptor_spot()&3)
250 {
251  case 0:
252   tilemap_draw(bitmap,cliprect,bg_tilemap,TILEMAP_DRAW_LAYER1|3,0);
253    draw_sprites(screen->machine, bitmap,cliprect,6);
254    tilemap_draw(bitmap,cliprect,bg_tilemap,TILEMAP_DRAW_LAYER0|3,0);
255    tilemap_draw(bitmap,cliprect,bg_tilemap,TILEMAP_DRAW_LAYER1|2,0);
256     tilemap_draw(bitmap,cliprect,bg_tilemap,TILEMAP_DRAW_LAYER0|2,0);
257   tilemap_draw(bitmap,cliprect,bg_tilemap,TILEMAP_DRAW_LAYER1|1,0);
258    draw_sprites(screen->machine, bitmap,cliprect,3);
259    tilemap_draw(bitmap,cliprect,bg_tilemap,TILEMAP_DRAW_LAYER0|1,0);
260    draw_sprites(screen->machine, bitmap,cliprect,0);
261    draw_sprites(screen->machine, bitmap,cliprect,2);
262    tilemap_draw(bitmap,cliprect,bg_tilemap,TILEMAP_DRAW_LAYER1|0,0);
263    draw_sprites(screen->machine, bitmap,cliprect,1);
264    tilemap_draw(bitmap,cliprect,bg_tilemap,TILEMAP_DRAW_LAYER0|0,0);
265  break;
262   nycaptor_setmask(screen->machine);
263   if (nycaptor_mask & 0x1000)
264   {
265      tilemap_draw(bitmap, cliprect, state->bg_tilemap, TILEMAP_DRAW_LAYER1 | 3, 0);
266      tilemap_draw(bitmap, cliprect, state->bg_tilemap, TILEMAP_DRAW_LAYER0 | 3, 0);
267      tilemap_draw(bitmap, cliprect, state->bg_tilemap, TILEMAP_DRAW_LAYER1 | 2, 0);
268      tilemap_draw(bitmap, cliprect, state->bg_tilemap, TILEMAP_DRAW_LAYER0 | 2, 0);
269      tilemap_draw(bitmap, cliprect, state->bg_tilemap, TILEMAP_DRAW_LAYER1 | 1, 0);
270      tilemap_draw(bitmap, cliprect, state->bg_tilemap, TILEMAP_DRAW_LAYER0 | 1, 0);
271      tilemap_draw(bitmap, cliprect, state->bg_tilemap, TILEMAP_DRAW_LAYER1 | 0, 0);
272      tilemap_draw(bitmap, cliprect, state->bg_tilemap, TILEMAP_DRAW_LAYER0 | 0, 0);
273      draw_sprites(screen->machine, bitmap, cliprect, 0);
274      draw_sprites(screen->machine, bitmap, cliprect, 1);
275      draw_sprites(screen->machine, bitmap, cliprect, 2);
276      draw_sprites(screen->machine, bitmap, cliprect, 3);
277      draw_sprites(screen->machine, bitmap, cliprect, 4);
278      draw_sprites(screen->machine, bitmap, cliprect, 5);
279      draw_sprites(screen->machine, bitmap, cliprect, 6);
280      draw_sprites(screen->machine, bitmap, cliprect, 7);
281   }
282   else
283   #endif
284   switch (nycaptor_spot(screen->machine) & 3)
285   {
286   case 0:
287      tilemap_draw(bitmap, cliprect, state->bg_tilemap, TILEMAP_DRAW_LAYER1 | 3, 0);
288      draw_sprites(screen->machine, bitmap, cliprect, 6);
289      tilemap_draw(bitmap, cliprect, state->bg_tilemap, TILEMAP_DRAW_LAYER0 | 3, 0);
290      tilemap_draw(bitmap, cliprect, state->bg_tilemap, TILEMAP_DRAW_LAYER1 | 2, 0);
291      tilemap_draw(bitmap, cliprect, state->bg_tilemap, TILEMAP_DRAW_LAYER0 | 2, 0);
292      tilemap_draw(bitmap, cliprect, state->bg_tilemap, TILEMAP_DRAW_LAYER1 | 1, 0);
293      draw_sprites(screen->machine, bitmap, cliprect, 3);
294      tilemap_draw(bitmap, cliprect, state->bg_tilemap, TILEMAP_DRAW_LAYER0 | 1, 0);
295      draw_sprites(screen->machine, bitmap, cliprect, 0);
296      draw_sprites(screen->machine, bitmap, cliprect, 2);
297      tilemap_draw(bitmap, cliprect, state->bg_tilemap, TILEMAP_DRAW_LAYER1 | 0, 0);
298      draw_sprites(screen->machine, bitmap, cliprect, 1);
299      tilemap_draw(bitmap, cliprect, state->bg_tilemap, TILEMAP_DRAW_LAYER0 | 0, 0);
300      break;
266301
267  case 1:
268    tilemap_draw(bitmap,cliprect,bg_tilemap,TILEMAP_DRAW_LAYER1|3,0);
269    draw_sprites(screen->machine, bitmap,cliprect,3);
270    tilemap_draw(bitmap,cliprect,bg_tilemap,TILEMAP_DRAW_LAYER0|3,0);
271    draw_sprites(screen->machine, bitmap,cliprect,2);
272    tilemap_draw(bitmap,cliprect,bg_tilemap,TILEMAP_DRAW_LAYER1|2,0);
273    tilemap_draw(bitmap,cliprect,bg_tilemap,TILEMAP_DRAW_LAYER1|1,0);
274    draw_sprites(screen->machine, bitmap,cliprect,1);
275    tilemap_draw(bitmap,cliprect,bg_tilemap,TILEMAP_DRAW_LAYER0|1,0);
276    tilemap_draw(bitmap,cliprect,bg_tilemap,TILEMAP_DRAW_LAYER0|2,0);
277    draw_sprites(screen->machine, bitmap,cliprect,0);
278    tilemap_draw(bitmap,cliprect,bg_tilemap,TILEMAP_DRAW_LAYER1|0,0);
279    tilemap_draw(bitmap,cliprect,bg_tilemap,TILEMAP_DRAW_LAYER0|0,0);
280  break;
302   case 1:
303      tilemap_draw(bitmap, cliprect, state->bg_tilemap, TILEMAP_DRAW_LAYER1 | 3, 0);
304      draw_sprites(screen->machine, bitmap, cliprect, 3);
305      tilemap_draw(bitmap, cliprect, state->bg_tilemap, TILEMAP_DRAW_LAYER0 | 3, 0);
306      draw_sprites(screen->machine, bitmap, cliprect, 2);
307      tilemap_draw(bitmap, cliprect, state->bg_tilemap, TILEMAP_DRAW_LAYER1 | 2, 0);
308      tilemap_draw(bitmap, cliprect, state->bg_tilemap, TILEMAP_DRAW_LAYER1 | 1, 0);
309      draw_sprites(screen->machine, bitmap, cliprect, 1);
310      tilemap_draw(bitmap, cliprect, state->bg_tilemap, TILEMAP_DRAW_LAYER0 | 1, 0);
311      tilemap_draw(bitmap, cliprect, state->bg_tilemap, TILEMAP_DRAW_LAYER0 | 2, 0);
312      draw_sprites(screen->machine, bitmap, cliprect, 0);
313      tilemap_draw(bitmap, cliprect, state->bg_tilemap, TILEMAP_DRAW_LAYER1 | 0, 0);
314      tilemap_draw(bitmap, cliprect, state->bg_tilemap, TILEMAP_DRAW_LAYER0 | 0, 0);
315      break;
281316
282  case 2:
283   tilemap_draw(bitmap,cliprect,bg_tilemap,TILEMAP_DRAW_LAYER1|3,0);
284    tilemap_draw(bitmap,cliprect,bg_tilemap,TILEMAP_DRAW_LAYER0|3,0);
285    tilemap_draw(bitmap,cliprect,bg_tilemap,TILEMAP_DRAW_LAYER1|1,0);
286    draw_sprites(screen->machine, bitmap,cliprect,1);
287    tilemap_draw(bitmap,cliprect,bg_tilemap,TILEMAP_DRAW_LAYER0|1,0);
288    tilemap_draw(bitmap,cliprect,bg_tilemap,TILEMAP_DRAW_LAYER1|2,0);
289    tilemap_draw(bitmap,cliprect,bg_tilemap,TILEMAP_DRAW_LAYER0|2,0);
290    draw_sprites(screen->machine, bitmap,cliprect,0);
291    tilemap_draw(bitmap,cliprect,bg_tilemap,TILEMAP_DRAW_LAYER1|0,0);
292    tilemap_draw(bitmap,cliprect,bg_tilemap,TILEMAP_DRAW_LAYER0|0,0);
293  break;
317   case 2:
318      tilemap_draw(bitmap, cliprect, state->bg_tilemap, TILEMAP_DRAW_LAYER1 | 3, 0);
319      tilemap_draw(bitmap, cliprect, state->bg_tilemap, TILEMAP_DRAW_LAYER0 | 3, 0);
320      tilemap_draw(bitmap, cliprect, state->bg_tilemap, TILEMAP_DRAW_LAYER1 | 1, 0);
321      draw_sprites(screen->machine, bitmap, cliprect, 1);
322      tilemap_draw(bitmap, cliprect, state->bg_tilemap, TILEMAP_DRAW_LAYER0 | 1, 0);
323      tilemap_draw(bitmap, cliprect, state->bg_tilemap, TILEMAP_DRAW_LAYER1 | 2, 0);
324      tilemap_draw(bitmap, cliprect, state->bg_tilemap, TILEMAP_DRAW_LAYER0 | 2, 0);
325      draw_sprites(screen->machine, bitmap, cliprect, 0);
326      tilemap_draw(bitmap, cliprect, state->bg_tilemap, TILEMAP_DRAW_LAYER1 | 0, 0);
327      tilemap_draw(bitmap, cliprect, state->bg_tilemap, TILEMAP_DRAW_LAYER0 | 0, 0);
328      break;
294329
295  case 3:
296    tilemap_draw(bitmap,cliprect,bg_tilemap,TILEMAP_DRAW_LAYER1|1,0);
297    draw_sprites(screen->machine, bitmap,cliprect,1);
298    tilemap_draw(bitmap,cliprect,bg_tilemap,TILEMAP_DRAW_LAYER0|1,0);
299    draw_sprites(screen->machine, bitmap,cliprect,0);
300    tilemap_draw(bitmap,cliprect,bg_tilemap,TILEMAP_DRAW_LAYER1|0,0);
301    tilemap_draw(bitmap,cliprect,bg_tilemap,TILEMAP_DRAW_LAYER0|0,0);
302  break;
303 }
330   case 3:
331      tilemap_draw(bitmap, cliprect, state->bg_tilemap, TILEMAP_DRAW_LAYER1 | 1, 0);
332      draw_sprites(screen->machine, bitmap, cliprect, 1);
333      tilemap_draw(bitmap, cliprect, state->bg_tilemap, TILEMAP_DRAW_LAYER0 | 1, 0);
334      draw_sprites(screen->machine, bitmap, cliprect, 0);
335      tilemap_draw(bitmap, cliprect, state->bg_tilemap, TILEMAP_DRAW_LAYER1 | 0, 0);
336      tilemap_draw(bitmap, cliprect, state->bg_tilemap, TILEMAP_DRAW_LAYER0 | 0, 0);
337      break;
338   }
339
304340   return 0;
305341}
306342
src/mame/video/madmotor.c
r7500r7501
77***************************************************************************/
88
99#include "emu.h"
10#include "includes/madmotor.h"
1011
11UINT16 *madmotor_pf1_rowscroll;
12UINT16 *madmotor_pf1_data,*madmotor_pf2_data,*madmotor_pf3_data;
1312
14UINT16 *madmotor_pf1_control;
15UINT16 *madmotor_pf2_control;
16UINT16 *madmotor_pf3_control;
17
18static int flipscreen;
19static tilemap_t *madmotor_pf1_tilemap,*madmotor_pf2_tilemap,*madmotor_pf3_tilemap,*madmotor_pf3a_tilemap;
20
21
22
23
2413/* 512 by 512 playfield, 8 by 8 tiles */
2514static TILEMAP_MAPPER( pf1_scan )
2615{
r7500r7501
3019
3120static TILE_GET_INFO( get_pf1_tile_info )
3221{
33   int tile,color;
22   madmotor_state *state = (madmotor_state *)machine->driver_data;
23   int tile = state->pf1_data[tile_index];
24   int color = tile >> 12;
3425
35   tile=madmotor_pf1_data[tile_index];
36   color=tile >> 12;
37   tile=tile&0xfff;
26   tile = tile & 0xfff;
3827
3928   SET_TILE_INFO(
4029         0,
r7500r7501
5241
5342static TILE_GET_INFO( get_pf2_tile_info )
5443{
55   int tile,color;
44   madmotor_state *state = (madmotor_state *)machine->driver_data;
45   int tile = state->pf2_data[tile_index];
46   int color = tile >> 12;
5647
57   tile=madmotor_pf2_data[tile_index];
58   color=tile >> 12;
59   tile=tile&0xfff;
48   tile = tile & 0xfff;
6049
6150   SET_TILE_INFO(
6251         1,
r7500r7501
7463
7564static TILE_GET_INFO( get_pf3_tile_info )
7665{
77   int tile,color;
66   madmotor_state *state = (madmotor_state *)machine->driver_data;
67   int tile = state->pf3_data[tile_index];
68   int color = tile >> 12;
7869
79   tile=madmotor_pf3_data[tile_index];
80   color=tile >> 12;
81   tile=tile&0xfff;
70   tile = tile & 0xfff;
8271
8372   SET_TILE_INFO(
8473         2,
r7500r7501
9685
9786static TILE_GET_INFO( get_pf3a_tile_info )
9887{
99   int tile,color;
88   madmotor_state *state = (madmotor_state *)machine->driver_data;
89   int tile = state->pf3_data[tile_index];
90   int color = tile >> 12;
10091
101   tile=madmotor_pf3_data[tile_index];
102   color=tile >> 12;
103   tile=tile&0xfff;
92   tile = tile & 0xfff;
10493
10594   SET_TILE_INFO(
10695         2,
r7500r7501
113102
114103VIDEO_START( madmotor )
115104{
116   madmotor_pf1_tilemap = tilemap_create(machine, get_pf1_tile_info, pf1_scan,  8, 8, 64,64);
117   madmotor_pf2_tilemap = tilemap_create(machine, get_pf2_tile_info, pf2_scan, 16,16, 32,32);
118   madmotor_pf3_tilemap = tilemap_create(machine, get_pf3_tile_info, pf3_scan,      16,16, 32,64);
119   madmotor_pf3a_tilemap= tilemap_create(machine, get_pf3a_tile_info,pf3a_scan,     16,16,128,16);
105   madmotor_state *state = (madmotor_state *)machine->driver_data;
120106
121   tilemap_set_transparent_pen(madmotor_pf1_tilemap,0);
122   tilemap_set_transparent_pen(madmotor_pf2_tilemap,0);
123   tilemap_set_scroll_rows(madmotor_pf1_tilemap,512);
107   state->pf1_tilemap = tilemap_create(machine, get_pf1_tile_info,  pf1_scan,   8,  8,  64, 64);
108   state->pf2_tilemap = tilemap_create(machine, get_pf2_tile_info,  pf2_scan,  16, 16,  32, 32);
109   state->pf3_tilemap = tilemap_create(machine, get_pf3_tile_info,  pf3_scan,  16, 16,  32, 64);
110   state->pf3a_tilemap= tilemap_create(machine, get_pf3a_tile_info, pf3a_scan, 16, 16, 128, 16);
111
112   tilemap_set_transparent_pen(state->pf1_tilemap, 0);
113   tilemap_set_transparent_pen(state->pf2_tilemap, 0);
114   tilemap_set_scroll_rows(state->pf1_tilemap, 512);
124115}
125116
126117/******************************************************************************/
127118
128119WRITE16_HANDLER( madmotor_pf1_data_w )
129120{
130   COMBINE_DATA(&madmotor_pf1_data[offset]);
131   tilemap_mark_tile_dirty(madmotor_pf1_tilemap,offset);
121   madmotor_state *state = (madmotor_state *)space->machine->driver_data;
122
123   COMBINE_DATA(&state->pf1_data[offset]);
124   tilemap_mark_tile_dirty(state->pf1_tilemap, offset);
132125}
133126
134127WRITE16_HANDLER( madmotor_pf2_data_w )
135128{
136   COMBINE_DATA(&madmotor_pf2_data[offset]);
137   tilemap_mark_tile_dirty(madmotor_pf2_tilemap,offset);
129   madmotor_state *state = (madmotor_state *)space->machine->driver_data;
130
131   COMBINE_DATA(&state->pf2_data[offset]);
132   tilemap_mark_tile_dirty(state->pf2_tilemap, offset);
138133}
139134
140135WRITE16_HANDLER( madmotor_pf3_data_w )
141136{
142   COMBINE_DATA(&madmotor_pf3_data[offset]);
137   madmotor_state *state = (madmotor_state *)space->machine->driver_data;
143138
139   COMBINE_DATA(&state->pf3_data[offset]);
140
144141   /* Mark the dirty position on the 512 x 1024 version */
145   tilemap_mark_tile_dirty(madmotor_pf3_tilemap,offset);
142   tilemap_mark_tile_dirty(state->pf3_tilemap, offset);
146143
147144   /* Mark the dirty position on the 2048 x 256 version */
148   tilemap_mark_tile_dirty(madmotor_pf3a_tilemap,offset);
145   tilemap_mark_tile_dirty(state->pf3a_tilemap, offset);
149146}
150147
151148/******************************************************************************/
152149
153static void draw_sprites(running_machine *machine, bitmap_t *bitmap,const rectangle *cliprect,int pri_mask,int pri_val)
150static void draw_sprites( running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, int pri_mask, int pri_val )
154151{
155   UINT16 *spriteram16 = machine->generic.spriteram.u16;
152   madmotor_state *state = (madmotor_state *)machine->driver_data;
153   UINT16 *spriteram = state->spriteram;
156154   int offs;
157155
158156   offs = 0;
159   while (offs < machine->generic.spriteram_size/2)
157   while (offs < state->spriteram_size / 2)
160158   {
161      int sx,sy,code,color,w,h,flipx,flipy,incy,flash,mult,x,y;
159      int sx, sy, code, color, w, h, flipx, flipy, incy, flash, mult, x, y;
162160
163      sy = spriteram16[offs];
164      sx = spriteram16[offs+2];
161      sy = spriteram[offs];
162      sx = spriteram[offs + 2];
165163      color = sx >> 12;
166164
167      flash=sx&0x800;
165      flash = sx & 0x800;
168166
169167      flipx = sy & 0x2000;
170168      flipy = sy & 0x4000;
r7500r7501
172170      w = (1 << ((sy & 0x0600) >>  9));   /* 1x, 2x, 4x, 8x width */
173171      /* multi width used only on the title screen? */
174172
175      code = spriteram16[offs+1] & 0x1fff;
173      code = spriteram[offs + 1] & 0x1fff;
176174
177175      sx = sx & 0x01ff;
178176      sy = sy & 0x01ff;
r7500r7501
190188         incy = 1;
191189      }
192190
193      if (flipscreen) {
194         sy=240-sy;
195         sx=240-sx;
196         if (flipx) flipx=0; else flipx=1;
197         if (flipy) flipy=0; else flipy=1;
198         mult=16;
191      if (state->flipscreen)
192      {
193         sy = 240 - sy;
194         sx = 240 - sx;
195         if (flipx) flipx = 0; else flipx = 1;
196         if (flipy) flipy = 0; else flipy = 1;
197         mult = 16;
199198      }
200      else mult=-16;
199      else
200         mult = -16;
201201
202      for (x = 0;x < w;x++)
202      for (x = 0; x < w; x++)
203203      {
204         for (y = 0;y < h;y++)
204         for (y = 0; y < h; y++)
205205         {
206206            if ((color & pri_mask) == pri_val &&
207207                     (!flash || (video_screen_get_frame_number(machine->primary_screen) & 1)))
r7500r7501
213213         }
214214
215215         offs += 4;
216         if (offs >= machine->generic.spriteram_size/2 ||
217               spriteram16[offs] & 0x8000)   // seems the expected behaviour on the title screen
216         if (offs >= state->spriteram_size / 2 || spriteram[offs] & 0x8000)   // seems the expected behaviour on the title screen
218217             break;
219218      }
220219   }
r7500r7501
225224
226225VIDEO_UPDATE( madmotor )
227226{
227   madmotor_state *state = (madmotor_state *)screen->machine->driver_data;
228228   int offs;
229229
230230   /* Update flipscreen */
231   if (madmotor_pf1_control[0]&0x80)
232      flipscreen=1;
231   if (state->pf1_control[0] & 0x80)
232      state->flipscreen = 1;
233233   else
234      flipscreen=0;
235   tilemap_set_flip_all(screen->machine,flipscreen ? (TILEMAP_FLIPY | TILEMAP_FLIPX) : 0);
234      state->flipscreen = 0;
236235
236   tilemap_set_flip_all(screen->machine, state->flipscreen ? (TILEMAP_FLIPY | TILEMAP_FLIPX) : 0);
237
237238   /* Setup scroll registers */
238   for (offs = 0;offs < 512;offs++)
239      tilemap_set_scrollx( madmotor_pf1_tilemap,offs, madmotor_pf1_control[0x08] + madmotor_pf1_rowscroll[0x200+offs] );
240   tilemap_set_scrolly( madmotor_pf1_tilemap,0, madmotor_pf1_control[0x09] );
241   tilemap_set_scrollx( madmotor_pf2_tilemap,0, madmotor_pf2_control[0x08] );
242   tilemap_set_scrolly( madmotor_pf2_tilemap,0, madmotor_pf2_control[0x09] );
243   tilemap_set_scrollx( madmotor_pf3_tilemap,0, madmotor_pf3_control[0x08] );
244   tilemap_set_scrolly( madmotor_pf3_tilemap,0, madmotor_pf3_control[0x09] );
245   tilemap_set_scrollx( madmotor_pf3a_tilemap,0, madmotor_pf3_control[0x08] );
246   tilemap_set_scrolly( madmotor_pf3a_tilemap,0, madmotor_pf3_control[0x09] );
239   for (offs = 0; offs < 512; offs++)
240      tilemap_set_scrollx(state->pf1_tilemap, offs, state->pf1_control[0x08] + state->pf1_rowscroll[0x200 + offs]);
247241
242   tilemap_set_scrolly(state->pf1_tilemap,  0, state->pf1_control[0x09]);
243   tilemap_set_scrollx(state->pf2_tilemap,  0, state->pf2_control[0x08]);
244   tilemap_set_scrolly(state->pf2_tilemap,  0, state->pf2_control[0x09]);
245   tilemap_set_scrollx(state->pf3_tilemap,  0, state->pf3_control[0x08]);
246   tilemap_set_scrolly(state->pf3_tilemap,  0, state->pf3_control[0x09]);
247   tilemap_set_scrollx(state->pf3a_tilemap, 0, state->pf3_control[0x08]);
248   tilemap_set_scrolly(state->pf3a_tilemap, 0, state->pf3_control[0x09]);
249
248250   /* Draw playfields & sprites */
249   if (madmotor_pf3_control[0x03]==2)
250      tilemap_draw(bitmap,cliprect,madmotor_pf3_tilemap,0,0);
251   if (state->pf3_control[0x03] == 2)
252      tilemap_draw(bitmap, cliprect, state->pf3_tilemap, 0, 0);
251253   else
252      tilemap_draw(bitmap,cliprect,madmotor_pf3a_tilemap,0,0);
253   tilemap_draw(bitmap,cliprect,madmotor_pf2_tilemap,0,0);
254   draw_sprites(screen->machine,bitmap,cliprect,0x00,0x00);
255   tilemap_draw(bitmap,cliprect,madmotor_pf1_tilemap,0,0);
254      tilemap_draw(bitmap, cliprect, state->pf3a_tilemap, 0, 0);
255
256   tilemap_draw(bitmap, cliprect, state->pf2_tilemap, 0, 0);
257   draw_sprites(screen->machine, bitmap, cliprect, 0x00, 0x00);
258   tilemap_draw(bitmap, cliprect, state->pf1_tilemap, 0, 0);
256259   return 0;
257260}
src/mame/video/skyfox.c
r7500r7501
3434
3535
3636***************************************************************************/
37
3738#include "emu.h"
39#include "includes/skyfox.h"
3840
39/* Variables only used here: */
4041
41static UINT8 vreg[8];
42
43
44/* Variables that driver has access to: */
45
46int skyfox_bg_pos, skyfox_bg_ctrl;
47
48
49
5042/***************************************************************************
5143
5244                            Memory Handlers
r7500r7501
5648#ifdef UNUSED_FUNCTION
5749READ8_HANDLER( skyfox_vregs_r )   // for debug
5850{
59   return vreg[offset];
51   skyfox_state *state = (skyfox_state *)space->machine->driver_data;
52   return state->vreg[offset];
6053}
6154#endif
6255
6356WRITE8_HANDLER( skyfox_vregs_w )
6457{
65   vreg[offset] = data;
58   skyfox_state *state = (skyfox_state *)space->machine->driver_data;
6659
60   state->vreg[offset] = data;
61
6762   switch (offset)
6863   {
69      case 0:   skyfox_bg_ctrl = data;   break;
70      case 1:   soundlatch_w(space,0,data);   break;
64      case 0:   state->bg_ctrl = data;   break;
65      case 1:   soundlatch_w(space, 0, data);   break;
7166      case 2:   break;
7267      case 3:   break;
7368      case 4:   break;
r7500r7501
9893{
9994   int i;
10095
101   for (i = 0;i < 256;i++)
96   for (i = 0; i < 256; i++)
10297   {
103      int bit0,bit1,bit2,bit3,r,g,b;
98      int bit0, bit1, bit2, bit3, r, g, b;
10499
105100      /* red component */
106101      bit0 = (color_prom[i] >> 0) & 0x01;
r7500r7501
121116      bit3 = (color_prom[i + 2*256] >> 3) & 0x01;
122117      b = 0x0e * bit0 + 0x1f * bit1 + 0x43 * bit2 + 0x8f * bit3;
123118
124      palette_set_color(machine,i,MAKE_RGB(r,g,b));
119      palette_set_color(machine, i, MAKE_RGB(r, g, b));
125120   }
126121
127122   /* Grey scale for the background??? */
128123   for (i = 0; i < 256; i++)
129124   {
130      palette_set_color(machine,i+256,MAKE_RGB(i,i,i));
125      palette_set_color(machine,i + 256, MAKE_RGB(i, i, i));
131126   }
132127}
133128
r7500r7501
164159
165160***************************************************************************/
166161
167static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect)
162static void draw_sprites( running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect )
168163{
169   UINT8 *spriteram = machine->generic.spriteram.u8;
164   skyfox_state *state = (skyfox_state *)machine->driver_data;
170165   int offs;
171166
172167   int width = video_screen_get_width(machine->primary_screen);
173168   int height = video_screen_get_height(machine->primary_screen);
174169
175170   /* The 32x32 tiles in the 80-ff range are bankswitched */
176   int shift   =   (skyfox_bg_ctrl & 0x80) ? (4-1) : 4;
171   int shift =(state->bg_ctrl & 0x80) ? (4 - 1) : 4;
177172
178   for (offs = 0; offs < machine->generic.spriteram_size; offs += 4)
173   for (offs = 0; offs < state->spriteram_size; offs += 4)
179174   {
180175      int xstart, ystart, xend, yend;
181176      int xinc, yinc, dx, dy;
182177      int low_code, high_code, n;
183178
184      int y      =      spriteram[offs+0];
185      int x      =      spriteram[offs+1];
186      int code   =      spriteram[offs+2] + spriteram[offs+3] * 256;
187      int flipx   =      code & 0x2;
188      int flipy   =      code & 0x4;
179      int y = state->spriteram[offs + 0];
180      int x = state->spriteram[offs + 1];
181      int code = state->spriteram[offs + 2] + state->spriteram[offs + 3] * 256;
182      int flipx = code & 0x2;
183      int flipy = code & 0x4;
189184
190185      x = x * 2 + (code & 1);   // add the least significant bit
191186
192      high_code = ((code >> 4) & 0x7f0) +
193               ((code & 0x8000) >> shift);
187      high_code = ((code >> 4) & 0x7f0) + ((code & 0x8000) >> shift);
194188
195189      switch( code & 0x88 )
196190      {
197         case 0x88:   n = 4;   low_code = 0;                              break;
198         case 0x08:   n = 2;   low_code = ((code&0x20)?8:0) + ((code&0x10)?2:0);   break;
199         default:   n = 1;   low_code = (code >> 4) & 0xf;
191         case 0x88:   n = 4; low_code = 0;                              break;
192         case 0x08:   n = 2; low_code = ((code & 0x20) ? 8 : 0) + ((code & 0x10) ? 2 : 0);   break;
193         default:   n = 1; low_code = (code >> 4) & 0xf;
200194      }
201195
202196#define DRAW_SPRITE(DX,DY,CODE) \
r7500r7501
207201            flipx,flipy, \
208202            x + (DX),y + (DY), 0xff); \
209203
210      if (skyfox_bg_ctrl & 1)   // flipscreen
204      if (state->bg_ctrl & 1)   // flipscreen
211205      {
212         x = width  - x - (n-1)*8;
213         y = height - y - (n-1)*8;
206         x = width  - x - (n - 1) * 8;
207         y = height - y - (n - 1) * 8;
214208         flipx = !flipx;
215209         flipy = !flipy;
216210      }
217211
218      if (flipx)   { xstart = n-1;  xend = -1;  xinc = -1; }
219      else      { xstart = 0;    xend = n;   xinc = +1; }
212      if (flipx)   { xstart = n - 1;  xend = -1;  xinc = -1; }
213      else      { xstart = 0;      xend = n;   xinc = +1; }
220214
221      if (flipy)   { ystart = n-1;  yend = -1;  yinc = -1; }
222      else      { ystart = 0;    yend = n;   yinc = +1; }
215      if (flipy)   { ystart = n - 1;  yend = -1;  yinc = -1; }
216      else      { ystart = 0;      yend = n;   yinc = +1; }
223217
224218
225219      code = low_code + high_code;
r7500r7501
227221      for (dy = ystart; dy != yend; dy += yinc)
228222      {
229223         for (dx = xstart; dx != xend; dx += xinc)
230            DRAW_SPRITE( dx*8, dy*8, code++);
224            DRAW_SPRITE(dx * 8, dy * 8, code++);
231225
232         if (n==2)   code+=2;
226         if (n == 2)   code += 2;
233227      }
234228   }
235229}
r7500r7501
246240
247241static void draw_background(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect)
248242{
249   UINT8 *RAM   =   memory_region(machine, "gfx2");
250   int x,y,i;
243   skyfox_state *state = (skyfox_state *)machine->driver_data;
244   UINT8 *RAM = memory_region(machine, "gfx2");
245   int x, y, i;
251246
252247   /* The foreground stars (sprites) move at twice this speed when
253248       the bg scroll rate [e.g. (skyfox_bg_reg >> 1) & 7] is 4 */
254   int pos = (skyfox_bg_pos >> 4) & (512*2-1);
249   int pos = (state->bg_pos >> 4) & (512 * 2 - 1);
255250
256251   for (i = 0 ; i < 0x1000; i++)
257252   {
258      int pen,offs,j;
253      int pen, offs, j;
259254
260      offs   =   (i*2+((skyfox_bg_ctrl>>4)&0x3)*0x2000) % 0x8000;
255      offs   = (i * 2 + ((state->bg_ctrl >> 4) & 0x3) * 0x2000) % 0x8000;
261256
262      pen      =   RAM[offs];
263      x      =   RAM[offs+1]*2 + (i&1) + pos + ((i & 8)?512:0);
264      y      =   ((i/8)/2)*8 + (i%8);
257      pen = RAM[offs];
258      x = RAM[offs + 1] * 2 + (i & 1) + pos + ((i & 8) ? 512 : 0);
259      y = ((i / 8) / 2) * 8 + (i % 8);
265260
266      if (skyfox_bg_ctrl & 1)   // flipscreen
261      if (state->bg_ctrl & 1)   // flipscreen
267262      {
268         x = 512 * 2 - (x%(512*2));
269         y = 256     - (y%256);
263         x = 512 * 2 - (x % (512 * 2));
264         y = 256     - (y % 256);
270265      }
271266
272      for (j = 0 ; j <= ((pen&0x80)?0:3); j++)
267      for (j = 0 ; j <= ((pen & 0x80) ? 0 : 3); j++)
273268         *BITMAP_ADDR16(bitmap,
274                     ( ((j/2)&1) + y ) % 256,
275                     ( (j&1)     + x ) % 512) = 256+(pen&0x7f);
269                     (((j / 2) & 1) + y) % 256,
270                     ((j & 1)     + x) % 512) = 256 + (pen & 0x7f);
276271   }
277272}
278273
r7500r7501
288283
289284VIDEO_UPDATE( skyfox )
290285{
291   bitmap_fill(bitmap,cliprect,255);   // the bg is black
286   bitmap_fill(bitmap, cliprect, 255);   // the bg is black
292287   draw_background(screen->machine, bitmap, cliprect);
293288   draw_sprites(screen->machine, bitmap, cliprect);
294289   return 0;
src/mame/video/simpl156.c
r7500r7501
33*/
44
55#include "emu.h"
6#include "includes/deco16ic.h"
6#include "includes/simpl156.h"
7#include "video/deco16ic.h"
78
89/*
910
r7500r7501
3536
3637/* spriteram is really 16-bit.. this can be changed to use 16-bit ram like the tilemaps
3738 its the same sprite chip Data East used on many, many 16-bit era titles */
38static void draw_sprites(running_machine *machine, bitmap_t *bitmap,const rectangle *cliprect)
39static void draw_sprites( running_machine *machine, bitmap_t *bitmap,const rectangle *cliprect )
3940{
40   UINT32 *spriteram32 = machine->generic.spriteram.u32;
41   UINT32 *spriteram = machine->generic.spriteram.u32;
4142   int offs;
4243
4344   //FIXME: flip_screen_x should not be written!
4445   flip_screen_set_no_update(machine, 1);
4546
46   for (offs = (0x1400/4)-4;offs >= 0;offs -= 4) // 0x1400 for charlien
47   for (offs = (0x1400 / 4) - 4; offs >= 0; offs -= 4) // 0x1400 for charlien
4748   {
48      int x,y,sprite,colour,multi,fx,fy,inc,flash,mult, pri;
49      int x, y, sprite, colour, multi, fx, fy, inc, flash, mult, pri;
4950
50      sprite = spriteram32[offs+1]&0xffff;
51      sprite = spriteram[offs + 1] & 0xffff;
5152
52      y = spriteram32[offs]&0xffff;
53      flash=y&0x1000;
54      if (flash && (video_screen_get_frame_number(machine->primary_screen) & 1)) continue;
53      y = spriteram[offs] & 0xffff;
54      flash = y & 0x1000;
55      if (flash && (video_screen_get_frame_number(machine->primary_screen) & 1))
56         continue;
5557
56      x = spriteram32[offs+2]&0xffff;
57      colour = (x >>9) & 0x1f;
58      x = spriteram[offs + 2] & 0xffff;
59      colour = (x >> 9) & 0x1f;
5860
59      pri = (x&0xc000); // 2 bits or 1?
61      pri = (x & 0xc000); // 2 bits or 1?
6062
61      switch (pri&0xc000) {
62      case 0x0000: pri=0; break;
63      case 0x4000: pri=0xf0; break;
64      case 0x8000: pri=0xf0|0xcc; break;
65      case 0xc000: pri=0xf0|0xcc; break; /*  or 0xf0|0xcc|0xaa ? */
63      switch (pri & 0xc000)
64      {
65      case 0x0000: pri = 0; break;
66      case 0x4000: pri = 0xf0; break;
67      case 0x8000: pri = 0xf0 | 0xcc; break;
68      case 0xc000: pri = 0xf0 | 0xcc; break; /*  or 0xf0|0xcc|0xaa ? */
6669      }
6770
6871      fx = y & 0x2000;
r7500r7501
7477      if (x >= 320) x -= 512;
7578      if (y >= 256) y -= 512;
7679      y = 240 - y;
77        x = 304 - x;
80      x = 304 - x;
7881
79      if (x>320) continue;
82      if (x > 320)
83         continue;
8084
8185      sprite &= ~multi;
8286      if (fy)
r7500r7501
8993
9094      if (flip_screen_get(machine))
9195      {
92         y=240-y;
93         x=304-x;
94         if (fx) fx=0; else fx=1;
95         if (fy) fy=0; else fy=1;
96         mult=16;
96         y = 240 - y;
97         x = 304 - x;
98         if (fx) fx = 0; else fx = 1;
99         if (fy) fy = 0; else fy = 1;
100         mult = 16;
97101      }
98      else mult=-16;
102      else
103         mult = -16;
99104
100105      while (multi >= 0)
101106      {
r7500r7501
112117}
113118
114119
115VIDEO_UPDATE( simpl156 )
120VIDEO_START( simpl156 )
116121{
117   bitmap_fill(screen->machine->priority_bitmap,NULL,0);
122   simpl156_state *state = (simpl156_state *)machine->driver_data;
118123
119   deco16_pf12_update(deco16_pf1_rowscroll,deco16_pf2_rowscroll);
124   /* allocate the ram as 16-bit (we do it here because the CPU is 32-bit) */
125   state->pf1_rowscroll = auto_alloc_array(machine, UINT16, 0x800/2);
126   state->pf2_rowscroll = auto_alloc_array(machine, UINT16, 0x800/2);
127   machine->generic.paletteram.u16 =  auto_alloc_array(machine, UINT16, 0x1000/2);
120128
121   bitmap_fill(bitmap,cliprect,256);
122
123   deco16_tilemap_2_draw(screen,bitmap,cliprect,0,2);
124   deco16_tilemap_1_draw(screen,bitmap,cliprect,0,4);
125
126   draw_sprites(screen->machine, bitmap,cliprect);
127   return 0;
129   /* and register the allocated ram so that save states still work */
130   state_save_register_global_pointer(machine, state->pf1_rowscroll, 0x800/2);
131   state_save_register_global_pointer(machine, state->pf2_rowscroll, 0x800/2);
132   state_save_register_global_pointer(machine, machine->generic.paletteram.u16, 0x1000/2);
128133}
129134
130static int simpl156_bank_callback(const int bank)
135VIDEO_UPDATE( simpl156 )
131136{
132   return ((bank>>4)&0x7) * 0x1000;
133}
137   simpl156_state *state = (simpl156_state *)screen->machine->driver_data;
134138
139   bitmap_fill(screen->machine->priority_bitmap, NULL, 0);
135140
136VIDEO_START( simpl156 )
137{
138   /* allocate the ram as 16-bit (we do it here because the CPU is 32-bit) */
139   deco16_pf1_data = auto_alloc_array(machine, UINT16, 0x2000/2);
140   deco16_pf2_data = auto_alloc_array(machine, UINT16, 0x2000/2);
141   deco16_pf1_rowscroll = auto_alloc_array(machine, UINT16, 0x800/2);
142   deco16_pf2_rowscroll = auto_alloc_array(machine, UINT16, 0x800/2);
143   deco16_pf12_control = auto_alloc_array(machine, UINT16, 0x10/2);
144   machine->generic.paletteram.u16 =  auto_alloc_array(machine, UINT16, 0x1000/2);
141   deco16ic_pf12_update(state->deco16ic, state->pf1_rowscroll, state->pf2_rowscroll);
145142
146   /* and register the allocated ram so that save states still work */
147   state_save_register_global_pointer(machine, deco16_pf1_data, 0x2000/2);
148   state_save_register_global_pointer(machine, deco16_pf2_data, 0x2000/2);
149   state_save_register_global_pointer(machine, deco16_pf1_rowscroll, 0x800/2);
150   state_save_register_global_pointer(machine, deco16_pf2_rowscroll, 0x800/2);
151   state_save_register_global_pointer(machine, deco16_pf12_control, 0x10/2);
152   state_save_register_global_pointer(machine, machine->generic.paletteram.u16, 0x1000/2);
143   bitmap_fill(bitmap, cliprect, 256);
153144
154   deco16_1_video_init(machine);
145   deco16ic_tilemap_2_draw(state->deco16ic, bitmap, cliprect, 0, 2);
146   deco16ic_tilemap_1_draw(state->deco16ic, bitmap, cliprect, 0, 4);
155147
156   deco16_set_tilemap_bank_callback(0, simpl156_bank_callback);
157   deco16_set_tilemap_bank_callback(1, simpl156_bank_callback);
148   draw_sprites(screen->machine, bitmap, cliprect);
149   return 0;
158150}
src/mame/video/orbit.c
r7500r7501
77#include "emu.h"
88#include "includes/orbit.h"
99
10UINT8* orbit_playfield_ram;
11UINT8* orbit_sprite_ram;
12
13static tilemap_t* bg_tilemap;
14
15static int orbit_flip_screen;
16
17
1810WRITE8_HANDLER( orbit_playfield_w )
1911{
20   orbit_playfield_ram[offset] = data;
21   tilemap_mark_tile_dirty(bg_tilemap, offset);
12   orbit_state *state = (orbit_state *)space->machine->driver_data;
13   state->playfield_ram[offset] = data;
14   tilemap_mark_tile_dirty(state->bg_tilemap, offset);
2215}
2316
2417
2518static TILE_GET_INFO( get_tile_info )
2619{
27   UINT8 code = orbit_playfield_ram[tile_index];
28
20   orbit_state *state = (orbit_state *)machine->driver_data;
21   UINT8 code = state->playfield_ram[tile_index];
2922   int flags = 0;
3023
31   if (code & 0x40)
24   if (BIT(code, 6))
3225      flags |= TILE_FLIPX;
33   if (orbit_flip_screen)
26   if (state->flip_screen)
3427      flags |= TILE_FLIPY;
3528
3629   SET_TILE_INFO(3, code & 0x3f, 0, flags);
r7500r7501
3932
4033VIDEO_START( orbit )
4134{
42   bg_tilemap = tilemap_create(machine, get_tile_info, tilemap_scan_rows, 16, 16, 32, 30);
35   orbit_state *state = (orbit_state *)machine->driver_data;
36   state->bg_tilemap = tilemap_create(machine, get_tile_info, tilemap_scan_rows, 16, 16, 32, 30);
4337}
4438
4539
46static void draw_sprites(running_machine *machine, bitmap_t* bitmap, const rectangle* cliprect)
40static void draw_sprites( running_machine *machine, bitmap_t* bitmap, const rectangle* cliprect )
4741{
48   const UINT8* p = orbit_sprite_ram;
42   orbit_state *state = (orbit_state *)machine->driver_data;
43   const UINT8* p = state->sprite_ram;
4944
5045   int i;
5146
r7500r7501
6055         ((flag & 0xc0) == 0x80) ? 1 :
6156         ((flag & 0xc0) == 0xc0) ? 2 : 0;
6257
63      int flip_x = code & 0x40;
64      int flip_y = code & 0x80;
58      int flip_x = BIT(code, 6);
59      int flip_y = BIT(code, 7);
6560
6661      int zoom_x = 0x10000;
6762      int zoom_y = 0x10000;
r7500r7501
8681
8782VIDEO_UPDATE( orbit )
8883{
89   orbit_flip_screen = input_port_read(screen->machine, "DSW2") & 8;
84   orbit_state *state = (orbit_state *)screen->machine->driver_data;
9085
91   tilemap_draw(bitmap, cliprect, bg_tilemap, 0, 0);
86   state->flip_screen = input_port_read(screen->machine, "DSW2") & 8;
9287
88   tilemap_draw(bitmap, cliprect, state->bg_tilemap, 0, 0);
89
9390   draw_sprites(screen->machine, bitmap, cliprect);
9491   return 0;
9592}
src/mame/video/mexico86.c
r7500r7501
11#include "emu.h"
22#include "includes/mexico86.h"
33
4UINT8 *mexico86_videoram,*mexico86_objectram;
5size_t mexico86_objectram_size;
6static int charbank;
74
8
9
105WRITE8_HANDLER( mexico86_bankswitch_w )
116{
12   UINT8 *RAM = memory_region(space->machine, "maincpu");
7   mexico86_state *state = (mexico86_state *)space->machine->driver_data;
138
149   if ((data & 7) > 5)
15      popmessage( "Switching to invalid bank!" );
10      popmessage("Switching to invalid bank!");
1611
17   memory_set_bankptr(space->machine, "bank1", &RAM[0x10000 + 0x4000 * (data & 0x07)]);
12   memory_set_bank(space->machine, "bank1", data & 0x07);
1813
19   charbank = (data & 0x20) >> 5;
14   state->charbank = BIT(data, 5);
2015}
2116
2217
2318
2419VIDEO_UPDATE( mexico86 )
2520{
21   mexico86_state *state = (mexico86_state *)screen->machine->driver_data;
2622   int offs;
27   int sx,sy,xc,yc;
28   int gfx_num,gfx_attr,gfx_offs;
23   int sx, sy, xc, yc;
24   int gfx_num, gfx_attr, gfx_offs;
2925
3026
3127   /* Bubble Bobble doesn't have a real video RAM. All graphics (characters */
3228   /* and sprites) are stored in the same memory region, and information on */
3329   /* the background character columns is stored inthe area dd00-dd3f */
30   bitmap_fill(bitmap, cliprect, 255);
3431
35   bitmap_fill(bitmap,cliprect,255);
32   sx = 0;
3633
37   sx = 0;
38/* the score display seems to be outside of the main objectram. */
39   for (offs = 0;offs < mexico86_objectram_size+0x200;offs += 4)
34   /* the score display seems to be outside of the main objectram. */
35   for (offs = 0; offs < state->objectram_size + 0x200; offs += 4)
4036   {
4137      int height;
4238
43if (offs >= mexico86_objectram_size && offs < mexico86_objectram_size+0x180) continue;
44if (offs >= mexico86_objectram_size+0x1c0) continue;
39      if (offs >= state->objectram_size && offs < state->objectram_size + 0x180)
40         continue;
4541
42      if (offs >= state->objectram_size + 0x1c0)
43         continue;
44
4645      /* skip empty sprites */
4746      /* this is dword aligned so the UINT32 * cast shouldn't give problems */
4847      /* on any architecture */
49      if (*(UINT32 *)(&mexico86_objectram[offs]) == 0)
48      if (*(UINT32 *)(&state->objectram[offs]) == 0)
5049         continue;
5150
52      gfx_num = mexico86_objectram[offs + 1];
53      gfx_attr = mexico86_objectram[offs + 3];
51      gfx_num = state->objectram[offs + 1];
52      gfx_attr = state->objectram[offs + 3];
5453
55      if ((gfx_num & 0x80) == 0)  /* 16x16 sprites */
54      if (!BIT(gfx_num, 7))  /* 16x16 sprites */
5655      {
5756         gfx_offs = ((gfx_num & 0x1f) * 0x80) + ((gfx_num & 0x60) >> 1) + 12;
5857         height = 2;
r7500r7501
6766         sx += 16;
6867      else
6968      {
70         sx = mexico86_objectram[offs + 2];
71//          if (gfx_attr & 0x40) sx -= 256;
69         sx = state->objectram[offs + 2];
70         //if (gfx_attr & 0x40) sx -= 256;
7271      }
73      sy = 256 - height*8 - (mexico86_objectram[offs + 0]);
72      sy = 256 - height * 8 - (state->objectram[offs + 0]);
7473
75      for (xc = 0;xc < 2;xc++)
74      for (xc = 0; xc < 2; xc++)
7675      {
77         for (yc = 0;yc < height;yc++)
76         for (yc = 0; yc < height; yc++)
7877         {
79            int goffs,code,color,flipx,flipy,x,y;
78            int goffs, code, color, flipx, flipy, x, y;
8079
8180            goffs = gfx_offs + xc * 0x40 + yc * 0x02;
82            code = mexico86_videoram[goffs] + ((mexico86_videoram[goffs + 1] & 0x07) << 8)
83                  + ((mexico86_videoram[goffs + 1] & 0x80) << 4) + (charbank << 12);
84            color = ((mexico86_videoram[goffs + 1] & 0x38) >> 3) + ((gfx_attr & 0x02) << 2);
85            flipx = mexico86_videoram[goffs + 1] & 0x40;
81            code = state->videoram[goffs] + ((state->videoram[goffs + 1] & 0x07) << 8)
82                  + ((state->videoram[goffs + 1] & 0x80) << 4) + (state->charbank << 12);
83            color = ((state->videoram[goffs + 1] & 0x38) >> 3) + ((gfx_attr & 0x02) << 2);
84            flipx = state->videoram[goffs + 1] & 0x40;
8685            flipy = 0;
87//              x = sx + xc * 8;
86
87            //x = sx + xc * 8;
8888            x = (sx + xc * 8) & 0xff;
8989            y = (sy + yc * 8) & 0xff;
9090
r7500r7501
101101
102102VIDEO_UPDATE( kikikai )
103103{
104   mexico86_state *state = (mexico86_state *)screen->machine->driver_data;
104105   int offs;
105   int sx,sy,yc;
106   int gfx_num,gfx_attr,gfx_offs;
106   int sx, sy, yc;
107   int gfx_num, gfx_attr, gfx_offs;
107108   int height;
108   int goffs,code,color,y;
109   int goffs, code, color, y;
109110   int tx, ty;
110111
111112   bitmap_fill(bitmap, cliprect, get_black_pen(screen->machine));
112113   sx = 0;
113   for (offs=0; offs<mexico86_objectram_size; offs+=4)
114   for (offs = 0; offs < state->objectram_size; offs += 4)
114115   {
115      if (*(UINT32*)(mexico86_objectram + offs) == 0) continue;
116      if (*(UINT32*)(state->objectram + offs) == 0)
117         continue;
116118
117      ty = mexico86_objectram[offs];
118      gfx_num = mexico86_objectram[offs + 1];
119      tx = mexico86_objectram[offs + 2];
120      gfx_attr = mexico86_objectram[offs + 3];
119      ty = state->objectram[offs];
120      gfx_num = state->objectram[offs + 1];
121      tx = state->objectram[offs + 2];
122      gfx_attr = state->objectram[offs + 3];
121123
122124      if (gfx_num & 0x80)
123125      {
r7500r7501
133135         height = 2;
134136         sx = tx;
135137      }
138
136139      sy = 256 - (height << 3) - ty;
137140
138141      height <<= 1;
139      for (yc=0; yc<height; yc+=2)
142      for (yc = 0; yc < height; yc += 2)
140143      {
141144         y = (sy + (yc << 2)) & 0xff;
142145         goffs = gfx_offs + yc;
143         code = mexico86_videoram[goffs] + ((mexico86_videoram[goffs + 1] & 0x1f) << 8);
144         color = (mexico86_videoram[goffs + 1] & 0xe0) >> 5;
146         code = state->videoram[goffs] + ((state->videoram[goffs + 1] & 0x1f) << 8);
147         color = (state->videoram[goffs + 1] & 0xe0) >> 5;
145148         goffs += 0x40;
146149
147150         drawgfx_transpen(bitmap,cliprect,screen->machine->gfx[0],
r7500r7501
150153               0,0,
151154               sx&0xff,y,15);
152155
153         code = mexico86_videoram[goffs] + ((mexico86_videoram[goffs + 1] & 0x1f) << 8);
154         color = (mexico86_videoram[goffs + 1] & 0xe0) >> 5;
156         code = state->videoram[goffs] + ((state->videoram[goffs + 1] & 0x1f) << 8);
157         color = (state->videoram[goffs + 1] & 0xe0) >> 5;
155158
156159         drawgfx_transpen(bitmap,cliprect,screen->machine->gfx[0],
157160               code,
src/mame/video/mouser.c
r7500r7501
1414*******************************************************************************/
1515
1616#include "emu.h"
17#include "includes/mouser.h"
1718
18UINT8 *mouser_videoram;
19UINT8 *mouser_colorram;
20
2119PALETTE_INIT( mouser )
2220{
2321   int i;
2422
25   for (i = 0;i < machine->config->total_colors;i++)
23   for (i = 0; i < machine->config->total_colors; i++)
2624   {
27      int bit0,bit1,bit2,r,g,b;
25      int bit0, bit1, bit2, r, g, b;
2826
2927      /* red component */
30      bit0 = BIT(*color_prom,0);
31      bit1 = BIT(*color_prom,1);
32      bit2 = BIT(*color_prom,2);
28      bit0 = BIT(*color_prom, 0);
29      bit1 = BIT(*color_prom, 1);
30      bit2 = BIT(*color_prom, 2);
3331      r = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2;
3432      /* green component */
35      bit0 = BIT(*color_prom,3);
36      bit1 = BIT(*color_prom,4);
37      bit2 = BIT(*color_prom,5);
33      bit0 = BIT(*color_prom, 3);
34      bit1 = BIT(*color_prom, 4);
35      bit2 = BIT(*color_prom, 5);
3836      g = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2;
3937      /* blue component */
40      bit0 = BIT(*color_prom,6);
41      bit1 = BIT(*color_prom,7);
38      bit0 = BIT(*color_prom, 6);
39      bit1 = BIT(*color_prom, 7);
4240      b = 0x4f * bit0 + 0xa8 * bit1;
4341
4442      palette_set_color(machine,i,MAKE_RGB(r,g,b));
r7500r7501
5856
5957VIDEO_UPDATE( mouser )
6058{
61   UINT8 *spriteram = screen->machine->generic.spriteram.u8;
59   mouser_state *state = (mouser_state *)screen->machine->driver_data;
60   UINT8 *spriteram = state->spriteram;
6261   int offs;
63   int sx,sy;
64   int flipx,flipy;
62   int sx, sy;
63   int flipx, flipy;
6564
6665   /* for every character in the Video RAM  */
6766   for (offs = 0x3ff; offs >= 0; offs--)
r7500r7501
8988      /* Ideally we would merge these on a pixel-by-pixel basis, but it's ok to do this char-by-char, */
9089      /* Since it's only for the MOUSER logo and it looks fine */
9190      /* Note: this is _not_ dependant on flipping */
92      color_offs = offs%32 + ((256 + 8*(offs/32) - spriteram[offs%32])%256)/8*32;
91      color_offs = offs % 32 + ((256 + 8 * (offs / 32) - spriteram[offs % 32] )% 256) / 8 * 32;
9392
9493      drawgfx_opaque(bitmap,cliprect,screen->machine->gfx[0],
95            mouser_videoram[offs] | (mouser_colorram[color_offs]>>5)*256 | ((mouser_colorram[color_offs]>>4)&1)*512,
96            mouser_colorram[color_offs]%16,
94            state->videoram[offs] | (state->colorram[color_offs] >> 5) * 256 | ((state->colorram[color_offs] >> 4) & 1) * 512,
95            state->colorram[color_offs]%16,
9796            flip_screen_x_get(screen->machine),flip_screen_y_get(screen->machine),
9897            8*sx,scrolled_y_position);
9998   }
r7500r7501
103102   /* This is the first set of 7 sprites */
104103   for(offs = 0x0084; offs < 0x00A0; offs += 4)
105104   {
106      sx = spriteram[offs+3];
107      sy = 0xef-spriteram[offs+2];
105      sx = spriteram[offs + 3];
106      sy = 0xef - spriteram[offs + 2];
108107
109      flipx = (spriteram[offs]&0x40)>>6;
110      flipy = (spriteram[offs]&0x80)>>7;
108      flipx = BIT(spriteram[offs], 6);
109      flipy = BIT(spriteram[offs], 7);
111110
112111      if (flip_screen_x_get(screen->machine))
113112      {
r7500r7501
121120         sy = 238 - sy;
122121      }
123122
124      if ((spriteram[offs+1]&0x10)>>4)
123      if (BIT(spriteram[offs + 1], 4))
125124         drawgfx_transpen(bitmap,cliprect,screen->machine->gfx[1+((spriteram[offs+1]&0x20)>>5)],
126125               spriteram[offs]&0x3f,
127126               spriteram[offs+1]%16,
r7500r7501
130129   }
131130
132131   /* This is the second set of 8 sprites */
133   for(offs = 0x00C4; offs < 0x00E4; offs += 4)
132   for(offs = 0x00C4; offs < 0x00e4; offs += 4)
134133   {
135      sx = spriteram[offs+3];
136      sy = 0xef-spriteram[offs+2];
134      sx = spriteram[offs + 3];
135      sy = 0xef - spriteram[offs + 2];
137136
138      flipx = (spriteram[offs]&0x40)>>6;
139      flipy = (spriteram[offs]&0x80)>>7;
137      flipx = BIT(spriteram[offs], 6);
138      flipy = BIT(spriteram[offs], 7);
140139
141140      if (flip_screen_x_get(screen->machine))
142141      {
r7500r7501
150149         sy = 238 - sy;
151150      }
152151
153      if ((spriteram[offs+1]&0x10)>>4)
152      if (BIT(spriteram[offs + 1], 4))
154153         drawgfx_transpen(bitmap,cliprect,screen->machine->gfx[1+((spriteram[offs+1]&0x20)>>5)],
155154               spriteram[offs]&0x3f,
156155               spriteram[offs+1]%16,
src/mame/video/deco32.c
r7500r7501
11#include "emu.h"
2#include "includes/deco16ic.h"
32#include "includes/deco32.h"
43
54UINT32 *deco32_pf1_data,*deco32_pf2_data,*deco32_pf3_data,*deco32_pf4_data;
r7500r7501
2322int deco32_raster_display_position;
2423UINT16 *deco32_raster_display_list;
2524
25/******************************************************************************
26
27 This sprite_priority_bitmap handling is the same as in deco16ic.c
28
29******************************************************************************/
30
31static bitmap_t *sprite_priority_bitmap;
32
33static void deco16_clear_sprite_priority_bitmap(void)
34{
35   if (sprite_priority_bitmap)
36      bitmap_fill(sprite_priority_bitmap,NULL,0);
37}
38
39/* A special pdrawgfx z-buffered sprite renderer that is needed to properly draw multiple sprite sources with alpha */
40static void deco16_pdrawgfx(
41      bitmap_t *dest,const rectangle *clip,const gfx_element *gfx,
42      UINT32 code,UINT32 color,int flipx,int flipy,int sx,int sy,
43      int transparent_color,UINT32 pri_mask,UINT32 sprite_mask,UINT8 write_pri,UINT8 alpha)
44{
45   int ox,oy,cx,cy;
46   int x_index,y_index,x,y;
47   bitmap_t *priority_bitmap = gfx->machine->priority_bitmap;
48   const pen_t *pal = &gfx->machine->pens[gfx->color_base + gfx->color_granularity * (color % gfx->total_colors)];
49   const UINT8 *code_base = gfx_element_get_data(gfx, code % gfx->total_elements);
50
51   /* check bounds */
52   ox = sx;
53   oy = sy;
54
55   if (sx>319 || sy>247 || sx<-15 || sy<-7)
56      return;
57
58   if (sy<0) sy=0;
59   if (sx<0) sx=0;
60   if (sx>319) cx=319;
61   else cx=ox+16;
62
63   cy=(sy-oy);
64
65   if (flipy) y_index=15-cy; else y_index=cy;
66
67   for( y=0; y<16-cy; y++ )
68   {
69      const UINT8 *source = code_base + (y_index * gfx->line_modulo);
70      UINT32 *destb = BITMAP_ADDR32(dest, sy, 0);
71      UINT8 *pri = BITMAP_ADDR8(priority_bitmap, sy, 0);
72      UINT8 *spri = BITMAP_ADDR8(sprite_priority_bitmap, sy, 0);
73
74      if (sy >= 0 && sy < 248)
75      {
76         if (flipx) { source+=15-(sx-ox); x_index=-1; } else { x_index=1; source+=(sx-ox); }
77
78         for (x=sx; x<cx; x++)
79         {
80            int c = *source;
81            if( c != transparent_color && x >= 0 && x < 320 )
82            {
83               if (pri_mask>pri[x] && sprite_mask>spri[x]) {
84                  if (alpha != 0xff)
85                     destb[x] = alpha_blend_r32(destb[x], pal[c], alpha);
86                  else
87                     destb[x] = pal[c];
88                  if (write_pri)
89                     pri[x] |= pri_mask;
90               }
91               spri[x]|=sprite_mask;
92            }
93            source+=x_index;
94         }
95      }
96
97      sy++;
98      if (sy>247)
99         return;
100      if (flipy) y_index--; else y_index++;
101   }
102}
103
26104/******************************************************************************/
27105
28106WRITE32_HANDLER( deco32_pf1_data_w )
r7500r7501
9921070   pf1a_tilemap =0;
9931071   dirty_palette = auto_alloc_array(machine, UINT8, 4096);
9941072
995   deco_allocate_sprite_bitmap(machine);
1073   /* Allow sprite bitmap */
1074   int width = video_screen_get_width(machine->primary_screen);
1075   int height = video_screen_get_height(machine->primary_screen);
1076   sprite_priority_bitmap = auto_bitmap_alloc(machine, width, height, BITMAP_FORMAT_INDEXED16 );
9961077
9971078   tilemap_set_transparent_pen(pf1_tilemap,0);
9981079   tilemap_set_transparent_pen(pf2_tilemap,0);
src/mame/video/lkage.c
r7500r7501
1#include "emu.h"
2#include "includes/lkage.h"
1/***************************************************************************
32
4static tilemap_t *bg_tilemap, *fg_tilemap, *tx_tilemap;
5static UINT8 bg_tile_bank, fg_tile_bank;
6UINT8 *lkage_scroll, *lkage_vreg;
3    video/lkage.c
74
8/*
5
96    lkage_scroll[0x00]: text layer horizontal scroll
107    lkage_scroll[0x01]: text layer vertical scroll
118    lkage_scroll[0x02]: foreground layer horizontal scroll
r7500r7501
3532        04 1e f3 : attract#2    110
3633        04 1e f3 : attract#3    110
3734        00 4e f3 : attract#4    110
38*/
3935
36
37***************************************************************************/
38
39#include "emu.h"
40#include "includes/lkage.h"
41
42
4043WRITE8_HANDLER( lkage_videoram_w )
4144{
42   space->machine->generic.videoram.u8[offset] = data;
45   lkage_state *state = (lkage_state *)space->machine->driver_data;
4346
44   switch( offset/0x400 )
47   state->videoram[offset] = data;
48
49   switch (offset / 0x400)
4550   {
4651   case 0:
47      tilemap_mark_tile_dirty(tx_tilemap,offset & 0x3ff);
52      tilemap_mark_tile_dirty(state->tx_tilemap, offset & 0x3ff);
4853      break;
4954
5055   case 1:
51      tilemap_mark_tile_dirty(fg_tilemap,offset & 0x3ff);
56      tilemap_mark_tile_dirty(state->fg_tilemap, offset & 0x3ff);
5257      break;
5358
5459   case 2:
55      tilemap_mark_tile_dirty(bg_tilemap,offset & 0x3ff);
60      tilemap_mark_tile_dirty(state->bg_tilemap, offset & 0x3ff);
5661      break;
5762
5863   default:
5964      break;
6065   }
61} /* lkage_videoram_w */
66}
6267
6368static TILE_GET_INFO( get_bg_tile_info )
6469{
65   int code = machine->generic.videoram.u8[tile_index + 0x800] + 256 * (bg_tile_bank?5:1);
70   lkage_state *state = (lkage_state *)machine->driver_data;
71   int code = state->videoram[tile_index + 0x800] + 256 * (state->bg_tile_bank ? 5 : 1);
6672   SET_TILE_INFO( 0/*gfx*/, code, 0/*color*/, 0/*flags*/ );
6773}
6874
6975static TILE_GET_INFO( get_fg_tile_info )
7076{
71   int code = machine->generic.videoram.u8[tile_index + 0x400] + 256 * (fg_tile_bank?1:0);
77   lkage_state *state = (lkage_state *)machine->driver_data;
78   int code = state->videoram[tile_index + 0x400] + 256 * (state->fg_tile_bank ? 1 : 0);
7279   SET_TILE_INFO( 0/*gfx*/, code, 0/*color*/, 0/*flags*/);
7380}
7481
7582static TILE_GET_INFO( get_tx_tile_info )
7683{
77   int code = machine->generic.videoram.u8[tile_index];
84   lkage_state *state = (lkage_state *)machine->driver_data;
85   int code = state->videoram[tile_index];
7886   SET_TILE_INFO( 0/*gfx*/, code, 0/*color*/, 0/*flags*/);
7987}
8088
8189VIDEO_START( lkage )
8290{
83   bg_tile_bank = fg_tile_bank = 0;
91   lkage_state *state = (lkage_state *)machine->driver_data;
8492
85   bg_tilemap = tilemap_create(machine, get_bg_tile_info,tilemap_scan_rows,     8,8,32,32);
86   fg_tilemap = tilemap_create(machine, get_fg_tile_info,tilemap_scan_rows,8,8,32,32);
87   tx_tilemap = tilemap_create(machine, get_tx_tile_info,tilemap_scan_rows,8,8,32,32);
93   state->bg_tilemap = tilemap_create(machine, get_bg_tile_info, tilemap_scan_rows, 8, 8, 32, 32);
94   state->fg_tilemap = tilemap_create(machine, get_fg_tile_info, tilemap_scan_rows, 8, 8, 32, 32);
95   state->tx_tilemap = tilemap_create(machine, get_tx_tile_info, tilemap_scan_rows, 8, 8, 32, 32);
8896
89   tilemap_set_transparent_pen(fg_tilemap,0);
90   tilemap_set_transparent_pen(tx_tilemap,0);
97   tilemap_set_transparent_pen(state->fg_tilemap, 0);
98   tilemap_set_transparent_pen(state->tx_tilemap, 0);
9199
92   tilemap_set_scrolldx(bg_tilemap,-5,-5+24);
93   tilemap_set_scrolldx(fg_tilemap,-3,-3+24);
94   tilemap_set_scrolldx(tx_tilemap,-1,-1+24);
95} /* VIDEO_START( lkage ) */
100   tilemap_set_scrolldx(state->bg_tilemap, -5, -5 + 24);
101   tilemap_set_scrolldx(state->fg_tilemap, -3, -3 + 24);
102   tilemap_set_scrolldx(state->tx_tilemap, -1, -1 + 24);
103}
96104
97105
98static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect )
106static void draw_sprites( running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect )
99107{
100   const UINT8 *source = machine->generic.spriteram.u8;
101   const UINT8 *finish = source+0x60;
102   while( source<finish )
108   lkage_state *state = (lkage_state *)machine->driver_data;
109   const UINT8 *source = state->spriteram;
110   const UINT8 *finish = source + 0x60;
111
112   while (source < finish)
103113   {
104114      int attributes = source[2];
105115      /* 0x01: horizontal flip
r7500r7501
110120         * 0x80: priority
111121         */
112122      int priority_mask = 0;
113      int color = (attributes>>4)&7;
114      int flipx = attributes&0x01;
115      int flipy = attributes&0x02;
116      int height = (attributes&0x08) ? 2 : 1;
117      int sx = source[0]-15;
118      int sy = 256-16*height-source[1];
123      int color = (attributes >> 4) & 7;
124      int flipx = attributes & 0x01;
125      int flipy = attributes & 0x02;
126      int height = (attributes & 0x08) ? 2 : 1;
127      int sx = source[0] - 15;
128      int sy = 256 - 16 * height - source[1];
119129      int sprite_number = source[3] + ((attributes & 0x04) << 6);
120130      int y;
121131
122      if( attributes&0x80 )
132      if (attributes & 0x80)
123133      {
124         priority_mask = (0xf0|0xcc );
134         priority_mask = (0xf0 | 0xcc);
125135      }
126136      else
127137      {
128         priority_mask = (0xf0);
138         priority_mask = 0xf0;
129139      }
130140
131141      if (flip_screen_x_get(machine))
r7500r7501
133143         sx = 239 - sx - 24;
134144         flipx = !flipx;
135145      }
136      if( flip_screen_y_get(machine) )
146      if (flip_screen_y_get(machine))
137147      {
138         sy = 254 - 16*height - sy;
148         sy = 254 - 16 * height - sy;
139149         flipy = !flipy;
140150      }
141151      if (height == 2 && !flipy)
r7500r7501
143153         sprite_number ^= 1;
144154      }
145155
146      for (y = 0;y < height;y++)
156      for (y = 0; y < height; y++)
147157      {
148158         pdrawgfx_transpen(
149159            bitmap,
r7500r7501
157167            machine->priority_bitmap,
158168            priority_mask,0 );
159169      }
160      source+=4;
170      source += 4;
161171   }
162} /* draw_sprites */
172}
163173
164174VIDEO_UPDATE( lkage )
165175{
176   lkage_state *state = (lkage_state *)screen->machine->driver_data;
166177   int bank;
167178
168   flip_screen_x_set(screen->machine, ~lkage_vreg[2] & 0x01);
169   flip_screen_y_set(screen->machine, ~lkage_vreg[2] & 0x02);
179   flip_screen_x_set(screen->machine, ~state->vreg[2] & 0x01);
180   flip_screen_y_set(screen->machine, ~state->vreg[2] & 0x02);
170181
171   bank = lkage_vreg[1]&0x08;
172   if( bg_tile_bank != bank )
182   bank = state->vreg[1] & 0x08;
183   if (state->bg_tile_bank != bank)
173184   {
174      bg_tile_bank = bank;
175      tilemap_mark_all_tiles_dirty( bg_tilemap );
185      state->bg_tile_bank = bank;
186      tilemap_mark_all_tiles_dirty(state->bg_tilemap);
176187   }
177188
178   bank = lkage_vreg[0]&0x04;
179   if( fg_tile_bank != bank )
189   bank = state->vreg[0]&0x04;
190   if (state->fg_tile_bank != bank)
180191   {
181      fg_tile_bank = bank;
182      tilemap_mark_all_tiles_dirty( fg_tilemap );
192      state->fg_tile_bank = bank;
193      tilemap_mark_all_tiles_dirty(state->fg_tilemap);
183194   }
184195
185   tilemap_set_palette_offset( bg_tilemap, 0x300 + (lkage_vreg[1]&0xf0) );
186   tilemap_set_palette_offset( fg_tilemap, 0x200 + (lkage_vreg[1]&0xf0) );
187   tilemap_set_palette_offset( tx_tilemap, 0x110 );
196   tilemap_set_palette_offset(state->bg_tilemap, 0x300 + (state->vreg[1] & 0xf0));
197   tilemap_set_palette_offset(state->fg_tilemap, 0x200 + (state->vreg[1] & 0xf0));
198   tilemap_set_palette_offset(state->tx_tilemap, 0x110);
188199
189   tilemap_set_scrollx(tx_tilemap,0,lkage_scroll[0]);
190   tilemap_set_scrolly(tx_tilemap,0,lkage_scroll[1]);
200   tilemap_set_scrollx(state->tx_tilemap, 0, state->scroll[0]);
201   tilemap_set_scrolly(state->tx_tilemap, 0, state->scroll[1]);
191202
192   tilemap_set_scrollx(fg_tilemap,0,lkage_scroll[2]);
193   tilemap_set_scrolly(fg_tilemap,0,lkage_scroll[3]);
203   tilemap_set_scrollx(state->fg_tilemap, 0, state->scroll[2]);
204   tilemap_set_scrolly(state->fg_tilemap, 0, state->scroll[3]);
194205
195   tilemap_set_scrollx(bg_tilemap,0,lkage_scroll[4]);
196   tilemap_set_scrolly(bg_tilemap,0,lkage_scroll[5]);
206   tilemap_set_scrollx(state->bg_tilemap, 0, state->scroll[4]);
207   tilemap_set_scrolly(state->bg_tilemap, 0, state->scroll[5]);
197208
198209   bitmap_fill(screen->machine->priority_bitmap, cliprect, 0);
199   if ((lkage_vreg[2] & 0xf0) == 0xf0)
210   if ((state->vreg[2] & 0xf0) == 0xf0)
200211   {
201      tilemap_draw( bitmap,cliprect,bg_tilemap,0,1 );
202      tilemap_draw( bitmap,cliprect,fg_tilemap,0,(lkage_vreg[1]&2)?2:4 );
203      tilemap_draw( bitmap,cliprect,tx_tilemap,0,4 );
212      tilemap_draw(bitmap, cliprect, state->bg_tilemap, 0, 1);
213      tilemap_draw(bitmap, cliprect, state->fg_tilemap, 0, (state->vreg[1] & 2) ? 2 : 4);
214      tilemap_draw(bitmap, cliprect, state->tx_tilemap, 0, 4);
204215   }
205216   else
206217   {
207      tilemap_draw( bitmap,cliprect,tx_tilemap,TILEMAP_DRAW_OPAQUE,0);
218      tilemap_draw(bitmap, cliprect, state->tx_tilemap, TILEMAP_DRAW_OPAQUE, 0);
208219   }
209   draw_sprites(screen->machine, bitmap,cliprect );
220   draw_sprites(screen->machine, bitmap, cliprect);
210221   return 0;
211222}
src/mame/video/news.c
r7500r7501
22#include "includes/news.h"
33
44
5UINT8 *news_fgram;
6UINT8 *news_bgram;
7
8static int bgpic;
9static tilemap_t *fg_tilemap, *bg_tilemap;
10
11
12
135/***************************************************************************
146
157  Callbacks for the TileMap code
r7500r7501
1810
1911static TILE_GET_INFO( get_fg_tile_info )
2012{
21   int code = (news_fgram[tile_index*2] << 8) | news_fgram[tile_index*2+1];
13   news_state *state = (news_state *)machine->driver_data;
14   int code = (state->fgram[tile_index * 2] << 8) | state->fgram[tile_index * 2 + 1];
2215   SET_TILE_INFO(
2316         0,
2417         code & 0x0fff,
r7500r7501
2821
2922static TILE_GET_INFO( get_bg_tile_info )
3023{
31   int code = (news_bgram[tile_index*2] << 8) | news_bgram[tile_index*2+1];
24   news_state *state = (news_state *)machine->driver_data;
25   int code = (state->bgram[tile_index * 2] << 8) | state->bgram[tile_index * 2 + 1];
3226   int color = (code & 0xf000) >> 12;
3327
3428   code &= 0x0fff;
35   if ((code & 0x0e00) == 0x0e00) code = (code & 0x1ff) | (bgpic << 9);
29   if ((code & 0x0e00) == 0x0e00)
30      code = (code & 0x1ff) | (state->bgpic << 9);
3631
3732   SET_TILE_INFO(
3833         0,
r7500r7501
5146
5247VIDEO_START( news )
5348{
49   news_state *state = (news_state *)machine->driver_data;
5450
55   fg_tilemap = tilemap_create(machine, get_fg_tile_info,tilemap_scan_rows,8,8,32, 32);
56   tilemap_set_transparent_pen(fg_tilemap,0);
51   state->fg_tilemap = tilemap_create(machine, get_fg_tile_info, tilemap_scan_rows, 8, 8, 32, 32);
52   tilemap_set_transparent_pen(state->fg_tilemap, 0);
5753
58   bg_tilemap = tilemap_create(machine, get_bg_tile_info,tilemap_scan_rows,8,8,32, 32);
54   state->bg_tilemap = tilemap_create(machine, get_bg_tile_info, tilemap_scan_rows, 8, 8, 32, 32);
5955}
6056
6157
r7500r7501
6864
6965WRITE8_HANDLER( news_fgram_w )
7066{
71   news_fgram[offset] = data;
72   tilemap_mark_tile_dirty(fg_tilemap,offset/2);
67   news_state *state = (news_state *)space->machine->driver_data;
68
69   state->fgram[offset] = data;
70   tilemap_mark_tile_dirty(state->fg_tilemap, offset / 2);
7371}
7472
7573WRITE8_HANDLER( news_bgram_w )
7674{
77   news_bgram[offset] = data;
78   tilemap_mark_tile_dirty(bg_tilemap,offset/2);
75   news_state *state = (news_state *)space->machine->driver_data;
76
77   state->bgram[offset] = data;
78   tilemap_mark_tile_dirty(state->bg_tilemap, offset / 2);
7979}
8080
8181WRITE8_HANDLER( news_bgpic_w )
8282{
83   if (bgpic != data)
83   news_state *state = (news_state *)space->machine->driver_data;
84
85   if (state->bgpic != data)
8486   {
85      bgpic = data;
86      tilemap_mark_all_tiles_dirty(bg_tilemap);
87      state->bgpic = data;
88      tilemap_mark_all_tiles_dirty(state->bg_tilemap);
8789   }
8890}
8991
r7500r7501
9799
98100VIDEO_UPDATE( news )
99101{
100   tilemap_draw(bitmap,cliprect,bg_tilemap,0,0);
101   tilemap_draw(bitmap,cliprect,fg_tilemap,0,0);
102   news_state *state = (news_state *)screen->machine->driver_data;
103   tilemap_draw(bitmap, cliprect, state->bg_tilemap, 0, 0);
104   tilemap_draw(bitmap, cliprect, state->fg_tilemap, 0, 0);
102105   return 0;
103106}
src/mame/video/metlclsh.c
r7500r7501
1919***************************************************************************/
2020
2121#include "emu.h"
22#include "includes/metlclsh.h"
2223
23/* Local variables: */
2424
25static tilemap_t *bg_tilemap,*fg_tilemap;
26
27static UINT8 metlclsh_write_mask, *metlclsh_otherram;
28
29/* Variables that driver has access to: */
30
31UINT8 *metlclsh_bgram, *metlclsh_fgram, *metlclsh_scrollx;
32
33/* Functions that driver has access to: */
34
3525WRITE8_HANDLER( metlclsh_rambank_w )
3626{
27   metlclsh_state *state = (metlclsh_state *)space->machine->driver_data;
28
3729   if (data & 1)
3830   {
39      metlclsh_write_mask = 0;
40      memory_set_bankptr(space->machine, "bank1", metlclsh_bgram);
31      state->write_mask = 0;
32      memory_set_bankptr(space->machine, "bank1", state->bgram);
4133   }
4234   else
4335   {
44      metlclsh_write_mask = 1 << (data >> 1);
45      memory_set_bankptr(space->machine, "bank1", metlclsh_otherram);
36      state->write_mask = 1 << (data >> 1);
37      memory_set_bankptr(space->machine, "bank1", state->otherram);
4638   }
4739}
4840
49static UINT8 metlclsh_gfxbank;
5041WRITE8_HANDLER( metlclsh_gfxbank_w )
5142{
52   if (!(data & 4) && (metlclsh_gfxbank != data))
43   metlclsh_state *state = (metlclsh_state *)space->machine->driver_data;
44
45   if (!(data & 4) && (state->gfxbank != data))
5346   {
54      tilemap_mark_all_tiles_dirty(bg_tilemap);
55      metlclsh_gfxbank = data & 3;
47      tilemap_mark_all_tiles_dirty(state->bg_tilemap);
48      state->gfxbank = data & 3;
5649   }
5750}
5851
r7500r7501
8073
8174static TILE_GET_INFO( get_bg_tile_info )
8275{
83   SET_TILE_INFO(1, metlclsh_bgram[tile_index] + (metlclsh_gfxbank << 7),0,0);
76   metlclsh_state *state = (metlclsh_state *)machine->driver_data;
77   SET_TILE_INFO(1, state->bgram[tile_index] + (state->gfxbank << 7), 0, 0);
8478}
8579
8680WRITE8_HANDLER( metlclsh_bgram_w )
8781{
82   metlclsh_state *state = (metlclsh_state *)space->machine->driver_data;
83
8884   /*  This ram is banked: it's either the tilemap (e401 = 1)
8985        or bit n of another area (e401 = n << 1)? (that I don't understand) */
90   if (metlclsh_write_mask)
86   if (state->write_mask)
9187   {
9288      /* unknown area - the following is almost surely wrong */
9389// 405b (e401 = e c a 8 6 4 2 0) writes d400++
r7500r7501
9591// 4085 (e401 = e a 6 2) writes d000++
9692// 405b (e401 = e a 6 2) writes d000++
9793
98//      metlclsh_otherram[offset] |= (data & metlclsh_write_mask);
99      metlclsh_otherram[offset] = (metlclsh_otherram[offset] & ~metlclsh_write_mask) | (data & metlclsh_write_mask);
94//      state->otherram[offset] |= (data & state->write_mask);
95      state->otherram[offset] = (state->otherram[offset] & ~state->write_mask) | (data & state->write_mask);
10096   }
10197   else
10298   {
10399      /* tilemap */
104      metlclsh_bgram[offset] = data;
105      tilemap_mark_tile_dirty(bg_tilemap,offset & 0x1ff);
100      state->bgram[offset] = data;
101      tilemap_mark_tile_dirty(state->bg_tilemap,offset & 0x1ff);
106102   }
107103}
108104
r7500r7501
121117
122118static TILE_GET_INFO( get_fg_tile_info )
123119{
124   UINT8 code = metlclsh_fgram[tile_index + 0x000];
125   UINT8 attr = metlclsh_fgram[tile_index + 0x400];
120   metlclsh_state *state = (metlclsh_state *)machine->driver_data;
121   UINT8 code = state->fgram[tile_index + 0x000];
122   UINT8 attr = state->fgram[tile_index + 0x400];
126123   SET_TILE_INFO(2, code + ((attr & 0x03) << 8), (attr >> 5) & 3, 0);
127124   tileinfo->category = ((attr & 0x80) ? 1 : 2);
128125}
129126
130127WRITE8_HANDLER( metlclsh_fgram_w )
131128{
132   metlclsh_fgram[offset] = data;
133   tilemap_mark_tile_dirty(fg_tilemap,offset & 0x3ff);
129   metlclsh_state *state = (metlclsh_state *)space->machine->driver_data;
130   state->fgram[offset] = data;
131   tilemap_mark_tile_dirty(state->fg_tilemap, offset & 0x3ff);
134132}
135133
136134
r7500r7501
142140
143141VIDEO_START( metlclsh )
144142{
145   metlclsh_otherram = auto_alloc_array(machine, UINT8, 0x800);   // banked ram
143   metlclsh_state *state = (metlclsh_state *)machine->driver_data;
146144
147   bg_tilemap = tilemap_create(machine, get_bg_tile_info,metlclsh_bgtilemap_scan,16,16,32,16);
148   fg_tilemap = tilemap_create(machine, get_fg_tile_info,tilemap_scan_rows,8,8,32,32);
145   state->otherram = auto_alloc_array(machine, UINT8, 0x800);   // banked ram
149146
150   tilemap_set_transparent_pen( bg_tilemap, 0 );
151   tilemap_set_transparent_pen( fg_tilemap, 0 );
147   state->bg_tilemap = tilemap_create(machine, get_bg_tile_info, metlclsh_bgtilemap_scan, 16, 16, 32, 16);
148   state->fg_tilemap = tilemap_create(machine, get_fg_tile_info, tilemap_scan_rows, 8, 8, 32, 32);
149
150   tilemap_set_transparent_pen(state->bg_tilemap, 0);
151   tilemap_set_transparent_pen(state->fg_tilemap, 0);
152
153   state_save_register_global_pointer(machine, state->otherram, 0x800);
152154}
153155
154156
r7500r7501
172174
173175***************************************************************************/
174176
175static void draw_sprites(running_machine *machine, bitmap_t *bitmap,const rectangle *cliprect)
177static void draw_sprites( running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect )
176178{
177   UINT8 *spriteram = machine->generic.spriteram.u8;
179   metlclsh_state *state = (metlclsh_state *)machine->driver_data;
180   UINT8 *spriteram = state->spriteram;
178181   gfx_element *gfx = machine->gfx[0];
179182   int offs;
180183
181   for (offs = 0;offs < machine->generic.spriteram_size; offs += 4)
184   for (offs = 0; offs < state->spriteram_size; offs += 4)
182185   {
183      int attr,code,color,sx,sy,flipx,flipy,wrapy,sizey;
186      int attr, code, color, sx, sy, flipx, flipy, wrapy, sizey;
184187
185      attr   =   spriteram[offs];
186      if (!(attr & 0x01))   continue;   // enable
188      attr = spriteram[offs];
189      if (!(attr & 0x01))
190         continue;   // enable
187191
188      flipy   =   (attr & 0x02);
189      flipx   =   (attr & 0x04);
190      color   =   (attr & 0x08) >> 3;
191      sizey   =   (attr & 0x10);   // double height
192      code   =   ((attr & 0x60) << 3) + spriteram[offs+1];
192      flipy = (attr & 0x02);
193      flipx = (attr & 0x04);
194      color = (attr & 0x08) >> 3;
195      sizey = (attr & 0x10);   // double height
196      code = ((attr & 0x60) << 3) + spriteram[offs + 1];
193197
194      sx   =   240 - spriteram[offs+3];
195      if (sx < -7) sx += 256;
196      sy   =   240 - spriteram[offs+2];
198      sx = 240 - spriteram[offs + 3];
199      if (sx < -7)
200         sx += 256;
197201
202      sy = 240 - spriteram[offs + 2];
203
198204      if (flip_screen_get(machine))
199205      {
200206         sx = 240 - sx;   flipx = !flipx;
201         sy = 240 - sy;   flipy = !flipy;      if (sizey)   sy+=16;
207         sy = 240 - sy;   flipy = !flipy;      if (sizey)   sy += 16;
202208         if (sy > 240)   sy -= 256;
203209      }
204210
205211      /* Draw twice, at sy and sy + 256 (wrap around) */
206      for ( wrapy = 0; wrapy <= 256; wrapy += 256 )
212      for (wrapy = 0; wrapy <= 256; wrapy += 256)
207213      {
208214         if (sizey)
209215         {
r7500r7501
238244
239245VIDEO_UPDATE( metlclsh )
240246{
241   bitmap_fill(bitmap,cliprect,0x10);
247   metlclsh_state *state = (metlclsh_state *)screen->machine->driver_data;
242248
243   tilemap_draw(bitmap,cliprect,fg_tilemap,1,0);   // low priority tiles of foreground
244   if (metlclsh_scrollx[0] & 0x08)               // background (if enabled)
249   bitmap_fill(bitmap, cliprect, 0x10);
250
251   tilemap_draw(bitmap, cliprect, state->fg_tilemap, 1, 0);   // low priority tiles of foreground
252
253   if (state->scrollx[0] & 0x08)               // background (if enabled)
245254   {
246255      /* The background seems to be always flipped along x */
247      tilemap_set_flip(bg_tilemap, (flip_screen_get(screen->machine) ? (TILEMAP_FLIPX|TILEMAP_FLIPY) : 0) ^ TILEMAP_FLIPX);
248      tilemap_set_scrollx(bg_tilemap, 0,metlclsh_scrollx[1] + ((metlclsh_scrollx[0]&0x02)<<7) );
249      tilemap_draw(bitmap,cliprect,bg_tilemap,0,0);
256      tilemap_set_flip(state->bg_tilemap, (flip_screen_get(screen->machine) ? (TILEMAP_FLIPX | TILEMAP_FLIPY) : 0) ^ TILEMAP_FLIPX);
257      tilemap_set_scrollx(state->bg_tilemap, 0, state->scrollx[1] + ((state->scrollx[0] & 0x02) << 7) );
258      tilemap_draw(bitmap, cliprect, state->bg_tilemap, 0, 0);
250259   }
251   draw_sprites(screen->machine,bitmap,cliprect);         // sprites
252   tilemap_draw(bitmap,cliprect,fg_tilemap,2,0);   // high priority tiles of foreground
260   draw_sprites(screen->machine, bitmap, cliprect);         // sprites
261   tilemap_draw(bitmap, cliprect, state->fg_tilemap, 2, 0);   // high priority tiles of foreground
253262
254//  popmessage("%02X",metlclsh_scrollx[0]);
263//  popmessage("%02X", state->scrollx[0]);
255264   return 0;
256265}
257266
src/mame/video/vaportra.c
r7500r7501
1010***************************************************************************/
1111
1212#include "emu.h"
13#include "includes/deco16ic.h"
13#include "video/deco16ic.h"
14#include "includes/vaportra.h"
1415
15static UINT16 vaportra_priority[2];
16
1716/******************************************************************************/
1817
19static int vaportra_bank_callback(const int bank)
20{
21   return ((bank>>4)&0x7) * 0x1000;
22}
23
24
25VIDEO_START( vaportra )
26{
27   deco16_2_video_init(machine, 0);
28
29   deco16_pf1_rowscroll = 0;
30   deco16_pf2_rowscroll = 0;
31   deco16_pf3_rowscroll = 0;
32   deco16_pf4_rowscroll = 0;
33
34   deco16_set_tilemap_bank_callback(0, vaportra_bank_callback);
35   deco16_set_tilemap_bank_callback(1, vaportra_bank_callback);
36   deco16_set_tilemap_bank_callback(2, vaportra_bank_callback);
37   deco16_set_tilemap_bank_callback(3, vaportra_bank_callback);
38
39   deco16_pf1_colour_bank=0x00;
40   deco16_pf2_colour_bank=0x20;
41   deco16_pf4_colour_bank=0x40;
42   deco16_pf3_colour_bank=0x30;
43}
44
45/******************************************************************************/
46
47
4818WRITE16_HANDLER( vaportra_priority_w )
4919{
50   COMBINE_DATA(&vaportra_priority[offset]);
20   vaportra_state *state = (vaportra_state *)space->machine->driver_data;
21   COMBINE_DATA(&state->priority[offset]);
5122}
5223
5324/******************************************************************************/
5425
55static void update_24bitcol(running_machine *machine, int offset)
26static void update_24bitcol( running_machine *machine, int offset )
5627{
57   UINT8 r,g,b;
28   UINT8 r, g, b;
5829
5930   r = (machine->generic.paletteram.u16[offset] >> 0) & 0xff;
6031   g = (machine->generic.paletteram.u16[offset] >> 8) & 0xff;
6132   b = (machine->generic.paletteram2.u16[offset] >> 0) & 0xff;
6233
63   palette_set_color(machine,offset,MAKE_RGB(r,g,b));
34   palette_set_color(machine, offset, MAKE_RGB(r,g,b));
6435}
6536
6637WRITE16_HANDLER( vaportra_palette_24bit_rg_w )
r7500r7501
7748
7849/******************************************************************************/
7950
80static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, int pri)
51static void draw_sprites( running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, int pri )
8152{
82   UINT16 *buffered_spriteram16 = machine->generic.buffered_spriteram.u16;
83   int offs,priority_value;
53   vaportra_state *state = (vaportra_state *)machine->driver_data;
54   UINT16 *buffered_spriteram = machine->generic.buffered_spriteram.u16;
55   int offs;
56   int priority_value = state->priority[1];
8457
85   priority_value=vaportra_priority[1];
86
87   for (offs = 0;offs < 0x400;offs += 4)
58   for (offs = 0; offs < 0x400; offs += 4)
8859   {
89      int x,y,sprite,colour,multi,fx,fy,inc,flash,mult;
60      int x, y, sprite, colour, multi, fx, fy, inc, flash, mult;
9061
91      y = buffered_spriteram16[offs];
92      if ((y&0x8000) == 0) continue;
62      y = buffered_spriteram[offs];
63      if ((y & 0x8000) == 0)
64         continue;
9365
94      sprite = buffered_spriteram16[offs+1] & 0x1fff;
95      x = buffered_spriteram16[offs+2];
96      colour = (x >> 12) &0xf;
97      if (pri && (colour>=priority_value)) continue;
98      if (!pri && !(colour>=priority_value)) continue;
66      sprite = buffered_spriteram[offs + 1] & 0x1fff;
67      x = buffered_spriteram[offs + 2];
68      colour = (x >> 12) & 0xf;
69      if (pri && (colour >= priority_value))
70         continue;
71      if (!pri && !(colour >= priority_value))
72         continue;
9973
100      flash=x&0x800;
101      if (flash && (video_screen_get_frame_number(machine->primary_screen) & 1)) continue;
74      flash = x & 0x800;
75      if (flash && (video_screen_get_frame_number(machine->primary_screen) & 1))
76         continue;
10277
10378      fx = y & 0x2000;
10479      fy = y & 0x4000;
r7500r7501
11186      x = 240 - x;
11287      y = 240 - y;
11388
114      if (x>256) continue; /* Speedup */
89      if (x > 256)
90         continue; /* Speedup */
11591
11692      sprite &= ~multi;
11793      if (fy)
r7500r7501
124100
125101      if (flip_screen_get(machine))
126102      {
127         y=240-y;
128         x=240-x;
129         if (fx) fx=0; else fx=1;
130         if (fy) fy=0; else fy=1;
131         mult=16;
103         y = 240 - y;
104         x = 240 - x;
105         if (fx) fx = 0; else fx = 1;
106         if (fy) fy = 0; else fy = 1;
107         mult = 16;
132108      }
133      else mult=-16;
109      else mult = -16;
134110
135111      while (multi >= 0)
136112      {
r7500r7501
148124
149125VIDEO_UPDATE( vaportra )
150126{
151   int pri=vaportra_priority[0] & 0x03;
127   vaportra_state *state = (vaportra_state *)screen->machine->driver_data;
128   UINT16 flip = deco16ic_pf12_control_r(state->deco16ic, 0, 0xffff);
129   int pri = state->priority[0] & 0x03;
152130
153   flip_screen_set(screen->machine,  !(deco16_pf12_control[0]&0x80) );
131   flip_screen_set(screen->machine, !BIT(flip, 7));
132   deco16ic_pf12_update(state->deco16ic, 0, 0);
133   deco16ic_pf34_update(state->deco16ic, 0, 0);
154134
155   deco16_pf12_update(deco16_pf1_rowscroll,deco16_pf2_rowscroll);
156   deco16_pf34_update(deco16_pf3_rowscroll,deco16_pf4_rowscroll);
157
158135   /* Draw playfields */
159   if (pri==0) {
160      deco16_tilemap_4_draw(screen,bitmap,cliprect,TILEMAP_DRAW_OPAQUE,0);
161      deco16_tilemap_3_draw(screen,bitmap,cliprect,0,0);
162      draw_sprites(screen->machine, bitmap,cliprect,0);
163      deco16_tilemap_2_draw(screen,bitmap,cliprect,0,0);
136   if (pri == 0)
137   {
138      deco16ic_tilemap_4_draw(state->deco16ic, bitmap, cliprect, TILEMAP_DRAW_OPAQUE, 0);
139      deco16ic_tilemap_3_draw(state->deco16ic, bitmap, cliprect, 0, 0);
140      draw_sprites(screen->machine, bitmap, cliprect, 0);
141      deco16ic_tilemap_2_draw(state->deco16ic, bitmap, cliprect, 0, 0);
164142   }
165   else if (pri==1) {
166      deco16_tilemap_3_draw(screen,bitmap,cliprect,TILEMAP_DRAW_OPAQUE,0);
167      deco16_tilemap_4_draw(screen,bitmap,cliprect,0,0);
168      draw_sprites(screen->machine, bitmap,cliprect,0);
169      deco16_tilemap_2_draw(screen,bitmap,cliprect,0,0);
143   else if (pri == 1)
144   {
145      deco16ic_tilemap_3_draw(state->deco16ic, bitmap, cliprect, TILEMAP_DRAW_OPAQUE, 0);
146      deco16ic_tilemap_4_draw(state->deco16ic, bitmap, cliprect, 0, 0);
147      draw_sprites(screen->machine, bitmap, cliprect, 0);
148      deco16ic_tilemap_2_draw(state->deco16ic, bitmap, cliprect, 0, 0);
170149   }
171   else if (pri==2) {
172      deco16_tilemap_4_draw(screen,bitmap,cliprect,TILEMAP_DRAW_OPAQUE,0);
173      deco16_tilemap_2_draw(screen,bitmap,cliprect,0,0);
174      draw_sprites(screen->machine, bitmap,cliprect,0);
175      deco16_tilemap_3_draw(screen,bitmap,cliprect,0,0);
150   else if (pri == 2)
151   {
152      deco16ic_tilemap_4_draw(state->deco16ic, bitmap, cliprect, TILEMAP_DRAW_OPAQUE, 0);
153      deco16ic_tilemap_2_draw(state->deco16ic, bitmap, cliprect, 0, 0);
154      draw_sprites(screen->machine, bitmap, cliprect, 0);
155      deco16ic_tilemap_3_draw(state->deco16ic, bitmap, cliprect, 0, 0);
176156   }
177   else {
178      deco16_tilemap_3_draw(screen,bitmap,cliprect,TILEMAP_DRAW_OPAQUE,0);
179      deco16_tilemap_2_draw(screen,bitmap,cliprect,0,0);
180      draw_sprites(screen->machine, bitmap,cliprect,0);
181      deco16_tilemap_4_draw(screen,bitmap,cliprect,0,0);
157   else
158   {
159      deco16ic_tilemap_3_draw(state->deco16ic, bitmap, cliprect, TILEMAP_DRAW_OPAQUE, 0);
160      deco16ic_tilemap_2_draw(state->deco16ic, bitmap, cliprect, 0, 0);
161      draw_sprites(screen->machine, bitmap, cliprect, 0);
162      deco16ic_tilemap_4_draw(state->deco16ic, bitmap, cliprect, 0, 0);
182163   }
183164
184   draw_sprites(screen->machine,bitmap,cliprect,1);
185   deco16_tilemap_1_draw(screen,bitmap,cliprect,0,0);
165   draw_sprites(screen->machine, bitmap, cliprect, 1);
166   deco16ic_tilemap_1_draw(state->deco16ic, bitmap, cliprect, 0, 0);
186167   return 0;
187168}
src/mame/video/mermaid.c
r7500r7501
11#include "emu.h"
2#include "includes/mermaid.h"
23
3static tilemap_t *bg_tilemap, *fg_tilemap;
44
5UINT8* mermaid_videoram;
6UINT8* mermaid_colorram;
7UINT8* mermaid_videoram2;
8UINT8* mermaid_bg_scrollram;
9UINT8* mermaid_fg_scrollram;
10
11static bitmap_t* helper;
12static bitmap_t* helper2;
13static int coll_bit0,coll_bit1,coll_bit2,coll_bit3,coll_bit6;
14
15static int rougien_gfxbank1, rougien_gfxbank2;
16
175static const rectangle spritevisiblearea =
186{
19   0*8, 26*8-1,
20   2*8, 30*8-1
7   0 * 8, 26 * 8 - 1,
8   2 * 8, 30 * 8 - 1
219};
2210
2311static const rectangle flip_spritevisiblearea =
2412{
25   6*8, 31*8-1,
26   2*8, 30*8-1
13   6 * 8, 31 * 8 - 1,
14   2 * 8, 30 * 8 - 1
2715};
2816
2917PALETTE_INIT( mermaid )
r7500r7501
5846
5947WRITE8_HANDLER( mermaid_videoram2_w )
6048{
61   mermaid_videoram2[offset] = data;
62   tilemap_mark_tile_dirty(bg_tilemap, offset);
49   mermaid_state *state = (mermaid_state *)space->machine->driver_data;
50   state->videoram2[offset] = data;
51   tilemap_mark_tile_dirty(state->bg_tilemap, offset);
6352}
6453
6554WRITE8_HANDLER( mermaid_videoram_w )
6655{
67   mermaid_videoram[offset] = data;
68   tilemap_mark_tile_dirty(fg_tilemap, offset);
56   mermaid_state *state = (mermaid_state *)space->machine->driver_data;
57   state->videoram[offset] = data;
58   tilemap_mark_tile_dirty(state->fg_tilemap, offset);
6959}
7060
7161WRITE8_HANDLER( mermaid_colorram_w )
7262{
73   mermaid_colorram[offset] = data;
74   tilemap_mark_tile_dirty(fg_tilemap, offset);
63   mermaid_state *state = (mermaid_state *)space->machine->driver_data;
64   state->colorram[offset] = data;
65   tilemap_mark_tile_dirty(state->fg_tilemap, offset);
7566}
7667
7768WRITE8_HANDLER( mermaid_flip_screen_x_w )
r7500r7501
8677
8778WRITE8_HANDLER( mermaid_bg_scroll_w )
8879{
89   mermaid_bg_scrollram[offset] = data;
90   tilemap_set_scrolly(bg_tilemap, offset, data);
80   mermaid_state *state = (mermaid_state *)space->machine->driver_data;
81   state->bg_scrollram[offset] = data;
82   tilemap_set_scrolly(state->bg_tilemap, offset, data);
9183}
9284
9385WRITE8_HANDLER( mermaid_fg_scroll_w )
9486{
95   mermaid_fg_scrollram[offset] = data;
96   tilemap_set_scrolly(fg_tilemap, offset, data);
87   mermaid_state *state = (mermaid_state *)space->machine->driver_data;
88   state->fg_scrollram[offset] = data;
89   tilemap_set_scrolly(state->fg_tilemap, offset, data);
9790}
9891
9992WRITE8_HANDLER( rougien_gfxbankswitch1_w )
10093{
101   rougien_gfxbank1 = data & 0x01;
94   mermaid_state *state = (mermaid_state *)space->machine->driver_data;
95   state->rougien_gfxbank1 = data & 0x01;
10296}
10397
10498WRITE8_HANDLER( rougien_gfxbankswitch2_w )
10599{
106   rougien_gfxbank2 = data & 0x01;
100   mermaid_state *state = (mermaid_state *)space->machine->driver_data;
101   state->rougien_gfxbank2 = data & 0x01;
107102}
108103
109104READ8_HANDLER( mermaid_collision_r )
r7500r7501
123118        Bit 7
124119    */
125120
121   mermaid_state *state = (mermaid_state *)space->machine->driver_data;
126122   int collision = 0xff;
127123
128   if(coll_bit0) collision &= 0xfe;
129   if(coll_bit1) collision &= 0xfd;
130   if(coll_bit2) collision &= 0xfb;
131   if(coll_bit3) collision &= 0xf7;
132   if(coll_bit6) collision &= 0xbf;
124   if (state->coll_bit0) collision &= 0xfe;
125   if (state->coll_bit1) collision &= 0xfd;
126   if (state->coll_bit2) collision &= 0xfb;
127   if (state->coll_bit3) collision &= 0xf7;
128   if (state->coll_bit6) collision &= 0xbf;
133129
134130   return collision;
135131}
136132
137133static TILE_GET_INFO( get_bg_tile_info )
138134{
139   int code = mermaid_videoram2[tile_index];
135   mermaid_state *state = (mermaid_state *)machine->driver_data;
136   int code = state->videoram2[tile_index];
140137   int sx = tile_index % 32;
141138   int color = (sx >= 26) ? 0 : 1;
142139
r7500r7501
145142
146143static TILE_GET_INFO( get_fg_tile_info )
147144{
148   int attr = mermaid_colorram[tile_index];
149   int code = mermaid_videoram[tile_index] + ((attr & 0x30) << 4);
145   mermaid_state *state = (mermaid_state *)machine->driver_data;
146   int attr = state->colorram[tile_index];
147   int code = state->videoram[tile_index] + ((attr & 0x30) << 4);
150148   int color = attr & 0x0f;
151149   int flags = TILE_FLIPYX((attr & 0xc0) >> 6);
152150
153   code |= rougien_gfxbank1 * 0x2800;
154   code |= rougien_gfxbank2 * 0x2400;
151   code |= state->rougien_gfxbank1 * 0x2800;
152   code |= state->rougien_gfxbank2 * 0x2400;
155153
156154   SET_TILE_INFO(0, code, color, flags);
157155}
158156
159157VIDEO_START( mermaid )
160158{
161   bg_tilemap = tilemap_create(machine, get_bg_tile_info, tilemap_scan_rows, 8, 8, 32, 32);
162   tilemap_set_scroll_cols(bg_tilemap, 32);
159   mermaid_state *state = (mermaid_state *)machine->driver_data;
163160
164   fg_tilemap = tilemap_create(machine, get_fg_tile_info, tilemap_scan_rows, 8, 8, 32, 32);
165   tilemap_set_scroll_cols(fg_tilemap, 32);
166   tilemap_set_transparent_pen(fg_tilemap, 0);
161   state->bg_tilemap = tilemap_create(machine, get_bg_tile_info, tilemap_scan_rows, 8, 8, 32, 32);
162   tilemap_set_scroll_cols(state->bg_tilemap, 32);
167163
168   helper = video_screen_auto_bitmap_alloc(machine->primary_screen);
169   helper2 = video_screen_auto_bitmap_alloc(machine->primary_screen);
164   state->fg_tilemap = tilemap_create(machine, get_fg_tile_info, tilemap_scan_rows, 8, 8, 32, 32);
165   tilemap_set_scroll_cols(state->fg_tilemap, 32);
166   tilemap_set_transparent_pen(state->fg_tilemap, 0);
167
168   state->helper = video_screen_auto_bitmap_alloc(machine->primary_screen);
169   state->helper2 = video_screen_auto_bitmap_alloc(machine->primary_screen);
170170}
171171
172static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect)
172static void draw_sprites( running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect )
173173{
174   UINT8 *spriteram = machine->generic.spriteram.u8;
174   mermaid_state *state = (mermaid_state *)machine->driver_data;
175   UINT8 *spriteram = state->spriteram;
175176   int offs;
176177
177   for (offs = machine->generic.spriteram_size - 4; offs >= 0; offs -= 4)
178   for (offs = state->spriteram_size - 4; offs >= 0; offs -= 4)
178179   {
179180      int attr = spriteram[offs + 2];
180181      int bank = (attr & 0x30) >> 4;
r7500r7501
187188
188189      if (sx >= 0xf0) sx -= 256;
189190
190      code |= rougien_gfxbank1 * 0x2800;
191      code |= rougien_gfxbank2 * 0x2400;
191      code |= state->rougien_gfxbank1 * 0x2800;
192      code |= state->rougien_gfxbank2 * 0x2400;
192193
193194      if (flip_screen_x_get(machine))
194195      {
r7500r7501
209210
210211VIDEO_UPDATE( mermaid )
211212{
212   tilemap_draw(bitmap, cliprect, bg_tilemap, 0, 0);
213   tilemap_draw(bitmap, cliprect, fg_tilemap, 0, 0);
213   mermaid_state *state = (mermaid_state *)screen->machine->driver_data;
214
215   tilemap_draw(bitmap, cliprect, state->bg_tilemap, 0, 0);
216   tilemap_draw(bitmap, cliprect, state->fg_tilemap, 0, 0);
214217   draw_sprites(screen->machine, bitmap, cliprect);
215218   return 0;
216219}
217220
218static UINT8 collision_check(colortable_t *colortable, rectangle* rect)
221static UINT8 collision_check( running_machine *machine, rectangle* rect )
219222{
223   mermaid_state *state = (mermaid_state *)machine->driver_data;
220224   UINT8 data = 0;
221225
222226   int x;
r7500r7501
225229   for (y = rect->min_y; y <= rect->max_y; y++)
226230      for (x = rect->min_x; x <= rect->max_x; x++)
227231      {
228         UINT16 a = colortable_entry_get_value(colortable, *BITMAP_ADDR16(helper, y, x));
229         UINT16 b = colortable_entry_get_value(colortable, *BITMAP_ADDR16(helper2, y, x));
232         UINT16 a = colortable_entry_get_value(machine->colortable, *BITMAP_ADDR16(state->helper, y, x));
233         UINT16 b = colortable_entry_get_value(machine->colortable, *BITMAP_ADDR16(state->helper2, y, x));
230234
231235         if (b != 0)
232236            if ((a != 0) & (a != 0x40))
r7500r7501
238242
239243VIDEO_EOF( mermaid )
240244{
245   mermaid_state *state = (mermaid_state *)machine->driver_data;
241246   const rectangle *visarea = video_screen_get_visible_area(machine->primary_screen);
242   UINT8 *spriteram = machine->generic.spriteram.u8;
247   UINT8 *spriteram = state->spriteram;
243248
244   int offs,offs2;
249   int offs, offs2;
245250
246   coll_bit1 = 0;
247   coll_bit2 = 0;
248   coll_bit3 = 0;
249   coll_bit6 = 0;
250   coll_bit0 = 0;
251   state->coll_bit1 = 0;
252   state->coll_bit2 = 0;
253   state->coll_bit3 = 0;
254   state->coll_bit6 = 0;
255   state->coll_bit0 = 0;
251256
252257   // check for bit 0 (sprite-sprite), 1 (sprite-foreground), 2 (sprite-background)
253258
254   for (offs = machine->generic.spriteram_size - 4; offs >= 0; offs -= 4)
259   for (offs = state->spriteram_size - 4; offs >= 0; offs -= 4)
255260   {
256261      int attr = spriteram[offs + 2];
257262      int bank = (attr & 0x30) >> 4;
r7500r7501
266271
267272      if (coll != 1) continue;
268273
269      code |= rougien_gfxbank1 * 0x2800;
270      code |= rougien_gfxbank2 * 0x2400;
274      code |= state->rougien_gfxbank1 * 0x2800;
275      code |= state->rougien_gfxbank2 * 0x2400;
271276
272277      if (flip_screen_x_get(machine))
273278      {
r7500r7501
297302
298303      // check collision sprite - background
299304
300      bitmap_fill(helper,&rect,0);
301      bitmap_fill(helper2,&rect,0);
305      bitmap_fill(state->helper, &rect, 0);
306      bitmap_fill(state->helper2, &rect, 0);
302307
303      tilemap_draw(helper, &rect, bg_tilemap, 0, 0);
308      tilemap_draw(state->helper, &rect, state->bg_tilemap, 0, 0);
304309
305      drawgfx_transpen(helper2, &rect,machine->gfx[1], code, 0, flipx, flipy, sx, sy, 0);
310      drawgfx_transpen(state->helper2, &rect, machine->gfx[1], code, 0, flipx, flipy, sx, sy, 0);
306311
307      coll_bit2 |= collision_check(machine->colortable, &rect);
312      state->coll_bit2 |= collision_check(machine, &rect);
308313
309314      // check collision sprite - foreground
310315
311      bitmap_fill(helper,&rect,0);
312      bitmap_fill(helper2,&rect,0);
316      bitmap_fill(state->helper, &rect, 0);
317      bitmap_fill(state->helper2, &rect, 0);
313318
314      tilemap_draw(helper, &rect, fg_tilemap, 0, 0);
319      tilemap_draw(state->helper, &rect, state->fg_tilemap, 0, 0);
315320
316      drawgfx_transpen(helper2, &rect,machine->gfx[1], code, 0, flipx, flipy, sx, sy, 0);
321      drawgfx_transpen(state->helper2, &rect, machine->gfx[1], code, 0, flipx, flipy, sx, sy, 0);
317322
318      coll_bit1 |= collision_check(machine->colortable, &rect);
323      state->coll_bit1 |= collision_check(machine, &rect);
319324
320325      // check collision sprite - sprite
321326
322      bitmap_fill(helper,&rect,0);
323      bitmap_fill(helper2,&rect,0);
327      bitmap_fill(state->helper, &rect, 0);
328      bitmap_fill(state->helper2, &rect, 0);
324329
325      for (offs2 = machine->generic.spriteram_size - 4; offs2 >= 0; offs2 -= 4)
330      for (offs2 = state->spriteram_size - 4; offs2 >= 0; offs2 -= 4)
326331         if (offs != offs2)
327332         {
328333            int attr2 = spriteram[offs2 + 2];
r7500r7501
336341
337342            if (coll2 != 0) continue;
338343
339            code2 |= rougien_gfxbank1 * 0x2800;
340            code2 |= rougien_gfxbank2 * 0x2400;
344            code2 |= state->rougien_gfxbank1 * 0x2800;
345            code2 |= state->rougien_gfxbank2 * 0x2400;
341346
342347            if (flip_screen_x_get(machine))
343348            {
r7500r7501
351356               sy2 = 240 - sy2;
352357            }
353358
354            drawgfx_transpen(helper, &rect,machine->gfx[1], code2, 0, flipx2, flipy2, sx2, sy2, 0);
359            drawgfx_transpen(state->helper, &rect, machine->gfx[1], code2, 0, flipx2, flipy2, sx2, sy2, 0);
355360         }
356361
357      drawgfx_transpen(helper2, &rect,machine->gfx[1], code, 0, flipx, flipy, sx, sy, 0);
362      drawgfx_transpen(state->helper2, &rect, machine->gfx[1], code, 0, flipx, flipy, sx, sy, 0);
358363
359      coll_bit0 |= collision_check(machine->colortable, &rect);
364      state->coll_bit0 |= collision_check(machine, &rect);
360365   }
361366
362367   // check for bit 3 (sprite-sprite)
363368
364   for (offs = machine->generic.spriteram_size - 4; offs >= 0; offs -= 4)
369   for (offs = state->spriteram_size - 4; offs >= 0; offs -= 4)
365370   {
366371      int attr = spriteram[offs + 2];
367372      int bank = (attr & 0x30) >> 4;
r7500r7501
376381
377382      if (coll != 2) continue;
378383
379      code |= rougien_gfxbank1 * 0x2800;
380      code |= rougien_gfxbank2 * 0x2400;
384      code |= state->rougien_gfxbank1 * 0x2800;
385      code |= state->rougien_gfxbank2 * 0x2400;
381386
382387      if (flip_screen_x_get(machine))
383388      {
r7500r7501
407412
408413      // check collision sprite - sprite
409414
410      bitmap_fill(helper,&rect,0);
411      bitmap_fill(helper2,&rect,0);
415      bitmap_fill(state->helper, &rect, 0);
416      bitmap_fill(state->helper2, &rect, 0);
412417
413      for (offs2 = machine->generic.spriteram_size - 4; offs2 >= 0; offs2 -= 4)
418      for (offs2 = state->spriteram_size - 4; offs2 >= 0; offs2 -= 4)
414419         if (offs != offs2)
415420         {
416421            int attr2 = spriteram[offs2 + 2];
r7500r7501
424429
425430            if (coll2 != 0) continue;
426431
427            code2 |= rougien_gfxbank1 * 0x2800;
428            code2 |= rougien_gfxbank2 * 0x2400;
432            code2 |= state->rougien_gfxbank1 * 0x2800;
433            code2 |= state->rougien_gfxbank2 * 0x2400;
429434
430435            if (flip_screen_x_get(machine))
431436            {
r7500r7501
439444               sy2 = 240 - sy2;
440445            }
441446
442            drawgfx_transpen(helper, &rect,machine->gfx[1], code2, 0, flipx2, flipy2, sx2, sy2, 0);
447            drawgfx_transpen(state->helper, &rect, machine->gfx[1], code2, 0, flipx2, flipy2, sx2, sy2, 0);
443448         }
444449
445      drawgfx_transpen(helper2, &rect,machine->gfx[1], code, 0, flipx, flipy, sx, sy, 0);
450      drawgfx_transpen(state->helper2, &rect, machine->gfx[1], code, 0, flipx, flipy, sx, sy, 0);
446451
447      coll_bit3 |= collision_check(machine->colortable, &rect);
452      state->coll_bit3 |= collision_check(machine, &rect);
448453   }
449454
450455   // check for bit 6
451456
452   for (offs = machine->generic.spriteram_size - 4; offs >= 0; offs -= 4)
457   for (offs = state->spriteram_size - 4; offs >= 0; offs -= 4)
453458   {
454459      int attr = spriteram[offs + 2];
455460      int bank = (attr & 0x30) >> 4;
r7500r7501
464469
465470      if (coll != 1) continue;
466471
467      code |= rougien_gfxbank1 * 0x2800;
468      code |= rougien_gfxbank2 * 0x2400;
472      code |= state->rougien_gfxbank1 * 0x2800;
473      code |= state->rougien_gfxbank2 * 0x2400;
469474
470475      if (flip_screen_x_get(machine))
471476      {
r7500r7501
495500
496501      // check collision sprite - sprite
497502
498      bitmap_fill(helper,&rect,0);
499      bitmap_fill(helper2,&rect,0);
503      bitmap_fill(state->helper, &rect, 0);
504      bitmap_fill(state->helper2, &rect, 0);
500505
501      for (offs2 = machine->generic.spriteram_size - 4; offs2 >= 0; offs2 -= 4)
506      for (offs2 = state->spriteram_size - 4; offs2 >= 0; offs2 -= 4)
502507         if (offs != offs2)
503508         {
504509            int attr2 = spriteram[offs2 + 2];
r7500r7501
512517
513518            if (coll2 != 2) continue;
514519
515            code2 |= rougien_gfxbank1 * 0x2800;
516            code2 |= rougien_gfxbank2 * 0x2400;
520            code2 |= state->rougien_gfxbank1 * 0x2800;
521            code2 |= state->rougien_gfxbank2 * 0x2400;
517522
518523            if (flip_screen_x_get(machine))
519524            {
r7500r7501
527532               sy2 = 240 - sy2;
528533            }
529534
530            drawgfx_transpen(helper, &rect,machine->gfx[1], code2, 0, flipx2, flipy2, sx2, sy2, 0);
535            drawgfx_transpen(state->helper, &rect, machine->gfx[1], code2, 0, flipx2, flipy2, sx2, sy2, 0);
531536         }
532537
533      drawgfx_transpen(helper2, &rect,machine->gfx[1], code, 0, flipx, flipy, sx, sy, 0);
538      drawgfx_transpen(state->helper2, &rect, machine->gfx[1], code, 0, flipx, flipy, sx, sy, 0);
534539
535      coll_bit6 |= collision_check(machine->colortable, &rect);
540      state->coll_bit6 |= collision_check(machine, &rect);
536541   }
537542
538543}
src/mame/video/othldrby.c
r7500r7501
11#include "emu.h"
2#include "includes/othldrby.h"
23
34
5#define VIDEORAM_SIZE      0x1c00
6#define SPRITERAM_START    0x1800
7#define SPRITERAM_SIZE     (VIDEORAM_SIZE - SPRITERAM_START)
48
5#define VIDEORAM_SIZE 0x1c00
6#define SPRITERAM_START 0x1800
7#define SPRITERAM_SIZE (VIDEORAM_SIZE-SPRITERAM_START)
89
9static UINT16 *vram,*buf_spriteram,*buf_spriteram2;
10
11#define VREG_SIZE 18
12static UINT16 vreg[VREG_SIZE];
13
14static tilemap_t *bg_tilemap[3];
15
16
1710/***************************************************************************
1811
1912  Callbacks for the TileMap code
2013
2114***************************************************************************/
2215
23INLINE void get_tile_info(running_machine *machine,tile_data *tileinfo,int tile_index,int plane)
16INLINE void get_tile_info( running_machine *machine, tile_data *tileinfo, int tile_index, int plane )
2417{
18   othldrby_state *state = (othldrby_state *)machine->driver_data;
2519   UINT16 attr;
2620
27   tile_index = 2*tile_index + 0x800*plane;
28   attr = vram[tile_index];
21   tile_index = 2 * tile_index + 0x800 * plane;
22   attr = state->vram[tile_index];
2923   SET_TILE_INFO(
3024         1,
31         vram[tile_index+1],
25         state->vram[tile_index + 1],
3226         attr & 0x7f,
3327         0);
3428   tileinfo->category = (attr & 0x0600) >> 9;
r7500r7501
3630
3731static TILE_GET_INFO( get_tile_info0 )
3832{
39   get_tile_info(machine,tileinfo,tile_index,0);
33   get_tile_info(machine, tileinfo, tile_index, 0);
4034}
4135
4236static TILE_GET_INFO( get_tile_info1 )
4337{
44   get_tile_info(machine,tileinfo,tile_index,1);
38   get_tile_info(machine, tileinfo, tile_index, 1);
4539}
4640
4741static TILE_GET_INFO( get_tile_info2 )
4842{
49   get_tile_info(machine,tileinfo,tile_index,2);
43   get_tile_info(machine, tileinfo, tile_index, 2);
5044}
5145
5246
r7500r7501
5953
6054VIDEO_START( othldrby )
6155{
62   bg_tilemap[0] = tilemap_create(machine, get_tile_info0,tilemap_scan_rows,16,16,32,32);
63   bg_tilemap[1] = tilemap_create(machine, get_tile_info1,tilemap_scan_rows,16,16,32,32);
64   bg_tilemap[2] = tilemap_create(machine, get_tile_info2,tilemap_scan_rows,16,16,32,32);
56   othldrby_state *state = (othldrby_state *)machine->driver_data;
6557
66   vram = auto_alloc_array(machine, UINT16, VIDEORAM_SIZE);
67   buf_spriteram = auto_alloc_array(machine, UINT16, 2*SPRITERAM_SIZE);
58   state->bg_tilemap[0] = tilemap_create(machine, get_tile_info0, tilemap_scan_rows, 16, 16, 32, 32);
59   state->bg_tilemap[1] = tilemap_create(machine, get_tile_info1, tilemap_scan_rows, 16, 16, 32, 32);
60   state->bg_tilemap[2] = tilemap_create(machine, get_tile_info2, tilemap_scan_rows, 16, 16, 32, 32);
6861
69   buf_spriteram2 = buf_spriteram + SPRITERAM_SIZE;
62   state->vram = auto_alloc_array(machine, UINT16, VIDEORAM_SIZE);
63   state->buf_spriteram = auto_alloc_array(machine, UINT16, 2 * SPRITERAM_SIZE);
64   state->buf_spriteram2 = state->buf_spriteram + SPRITERAM_SIZE;
7065
71   tilemap_set_transparent_pen(bg_tilemap[0],0);
72   tilemap_set_transparent_pen(bg_tilemap[1],0);
73   tilemap_set_transparent_pen(bg_tilemap[2],0);
66   tilemap_set_transparent_pen(state->bg_tilemap[0], 0);
67   tilemap_set_transparent_pen(state->bg_tilemap[1], 0);
68   tilemap_set_transparent_pen(state->bg_tilemap[2], 0);
69
70   state_save_register_global_pointer(machine, state->vram, VIDEORAM_SIZE);
71   state_save_register_global_pointer(machine, state->buf_spriteram, 2 * SPRITERAM_SIZE);
7472}
7573
7674
r7500r7501
8179
8280***************************************************************************/
8381
84static UINT32 vram_addr,vreg_addr;
85
8682WRITE16_HANDLER( othldrby_videoram_addr_w )
8783{
88   vram_addr = data;
84   othldrby_state *state = (othldrby_state *)space->machine->driver_data;
85   state->vram_addr = data;
8986}
9087
9188READ16_HANDLER( othldrby_videoram_r )
9289{
93   if (vram_addr < VIDEORAM_SIZE)
94      return vram[vram_addr++];
90   othldrby_state *state = (othldrby_state *)space->machine->driver_data;
91
92   if (state->vram_addr < VIDEORAM_SIZE)
93      return state->vram[state->vram_addr++];
9594   else
9695   {
97      popmessage("GFXRAM OUT OF BOUNDS %04x",vram_addr);
96      popmessage("GFXRAM OUT OF BOUNDS %04x", state->vram_addr);
9897      return 0;
9998   }
10099}
101100
102101WRITE16_HANDLER( othldrby_videoram_w )
103102{
104   if (vram_addr < VIDEORAM_SIZE)
103   othldrby_state *state = (othldrby_state *)space->machine->driver_data;
104
105   if (state->vram_addr < VIDEORAM_SIZE)
105106   {
106      if (vram_addr < SPRITERAM_START)
107         tilemap_mark_tile_dirty(bg_tilemap[vram_addr/0x800],(vram_addr&0x7ff)/2);
108      vram[vram_addr++] = data;
107      if (state->vram_addr < SPRITERAM_START)
108         tilemap_mark_tile_dirty(state->bg_tilemap[state->vram_addr / 0x800], (state->vram_addr & 0x7ff) / 2);
109      state->vram[state->vram_addr++] = data;
109110   }
110111   else
111      popmessage("GFXRAM OUT OF BOUNDS %04x",vram_addr);
112      popmessage("GFXRAM OUT OF BOUNDS %04x", state->vram_addr);
112113}
113114
114115WRITE16_HANDLER( othldrby_vreg_addr_w )
115116{
116   vreg_addr = data & 0x7f;   /* bit 7 is set when screen is flipped */
117   othldrby_state *state = (othldrby_state *)space->machine->driver_data;
118   state->vreg_addr = data & 0x7f;   /* bit 7 is set when screen is flipped */
117119}
118120
119121WRITE16_HANDLER( othldrby_vreg_w )
120122{
121   if (vreg_addr < VREG_SIZE)
122      vreg[vreg_addr++] = data;
123   othldrby_state *state = (othldrby_state *)space->machine->driver_data;
124
125   if (state->vreg_addr < OTHLDRBY_VREG_SIZE)
126      state->vreg[state->vreg_addr++] = data;
123127   else
124      popmessage("%06x: VREG OUT OF BOUNDS %04x",cpu_get_pc(space->cpu),vreg_addr);
128      popmessage("%06x: VREG OUT OF BOUNDS %04x", cpu_get_pc(space->cpu), state->vreg_addr);
125129}
126130
127131
r7500r7501
132136
133137***************************************************************************/
134138
135static void draw_sprites(running_machine *machine, bitmap_t *bitmap,const rectangle *cliprect,int priority)
139static void draw_sprites( running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, int priority )
136140{
141   othldrby_state *state = (othldrby_state *)machine->driver_data;
137142   int offs;
138143
139   for (offs = 0;offs < SPRITERAM_SIZE;offs += 4)
144   for (offs = 0; offs < SPRITERAM_SIZE; offs += 4)
140145   {
141      int x,y,color,code,sx,sy,flipx,flipy,sizex,sizey,pri;
146      int x, y, color, code, sx, sy, flipx, flipy, sizex, sizey, pri;
142147
148      pri = (state->buf_spriteram[offs] & 0x0600) >> 9;
149      if (pri != priority)
150         continue;
143151
144      pri = (buf_spriteram[offs] & 0x0600) >> 9;
145      if (pri != priority) continue;
146
147      flipx = buf_spriteram[offs] & 0x1000;
152      flipx = state->buf_spriteram[offs] & 0x1000;
148153      flipy = 0;
149      color = (buf_spriteram[offs] & 0x01fc) >> 2;
150      code = buf_spriteram[offs+1] | ((buf_spriteram[offs] & 0x0003) << 16);
151      sx = (buf_spriteram[offs+2] >> 7);
152      sy = (buf_spriteram[offs+3] >> 7);
153      sizex = (buf_spriteram[offs+2] & 0x000f) + 1;
154      sizey = (buf_spriteram[offs+3] & 0x000f) + 1;
154      color = (state->buf_spriteram[offs] & 0x01fc) >> 2;
155      code = state->buf_spriteram[offs + 1] | ((state->buf_spriteram[offs] & 0x0003) << 16);
156      sx = (state->buf_spriteram[offs + 2] >> 7);
157      sy = (state->buf_spriteram[offs + 3] >> 7);
158      sizex = (state->buf_spriteram[offs + 2] & 0x000f) + 1;
159      sizey = (state->buf_spriteram[offs + 3] & 0x000f) + 1;
155160
156161      if (flip_screen_get(machine))
157162      {
r7500r7501
161166         sy = 16 - sy;
162167      }
163168
164      for (y = 0;y < sizey;y++)
169      for (y = 0; y < sizey; y++)
165170      {
166         for (x = 0;x < sizex;x++)
171         for (x = 0; x < sizex; x++)
167172         {
168173            drawgfx_transpen(bitmap,cliprect,machine->gfx[0],
169174                  code + x + sizex * y,
170175                  color,
171176                  flipx,flipy,
172                  (sx + (flipx ? (-8*(x+1)+1) : 8*x) - vreg[6]+44) & 0x1ff,(sy + (flipy ? (-8*(y+1)+1) : 8*y) - vreg[7]-9) & 0x1ff,0);
177                  (sx + (flipx ? (-8*(x+1)+1) : 8*x) - state->vreg[6]+44) & 0x1ff,(sy + (flipy ? (-8*(y+1)+1) : 8*y) - state->vreg[7]-9) & 0x1ff,0);
173178         }
174179      }
175180   }
r7500r7501
177182
178183VIDEO_UPDATE( othldrby )
179184{
185   othldrby_state *state = (othldrby_state *)screen->machine->driver_data;
180186   int layer;
181187
188   flip_screen_set(screen->machine, state->vreg[0x0f] & 0x80);
182189
183   flip_screen_set(screen->machine, vreg[0x0f] & 0x80);
184
185   for (layer = 0;layer < 3;layer++)
190   for (layer = 0; layer < 3; layer++)
186191   {
187192      if (flip_screen_get(screen->machine))
188193      {
189         tilemap_set_scrollx(bg_tilemap[layer],0,vreg[2*layer]+59);
190         tilemap_set_scrolly(bg_tilemap[layer],0,vreg[2*layer+1]+248);
194         tilemap_set_scrollx(state->bg_tilemap[layer], 0, state->vreg[2 * layer] + 59);
195         tilemap_set_scrolly(state->bg_tilemap[layer], 0, state->vreg[2 * layer + 1] + 248);
191196      }
192197      else
193198      {
194         tilemap_set_scrollx(bg_tilemap[layer],0,vreg[2*layer]-58);
195         tilemap_set_scrolly(bg_tilemap[layer],0,vreg[2*layer+1]+9);
199         tilemap_set_scrollx(state->bg_tilemap[layer], 0, state->vreg[2 * layer] - 58);
200         tilemap_set_scrolly(state->bg_tilemap[layer], 0, state->vreg[2 * layer+1] + 9);
196201      }
197202   }
198203
199   bitmap_fill(screen->machine->priority_bitmap,cliprect,0);
204   bitmap_fill(screen->machine->priority_bitmap, cliprect, 0);
200205
201   bitmap_fill(bitmap,cliprect,0);
206   bitmap_fill(bitmap, cliprect, 0);
202207
203   for (layer = 0;layer < 3;layer++)
204      tilemap_draw(bitmap,cliprect,bg_tilemap[layer],0,0);
205   draw_sprites(screen->machine,bitmap,cliprect,0);
206   for (layer = 0;layer < 3;layer++)
207      tilemap_draw(bitmap,cliprect,bg_tilemap[layer],1,0);
208   draw_sprites(screen->machine,bitmap,cliprect,1);
209   for (layer = 0;layer < 3;layer++)
210      tilemap_draw(bitmap,cliprect,bg_tilemap[layer],2,0);
211   draw_sprites(screen->machine,bitmap,cliprect,2);
212   for (layer = 0;layer < 3;layer++)
213      tilemap_draw(bitmap,cliprect,bg_tilemap[layer],3,0);
214   draw_sprites(screen->machine,bitmap,cliprect,3);
208   for (layer = 0; layer < 3; layer++)
209      tilemap_draw(bitmap, cliprect, state->bg_tilemap[layer], 0, 0);
210   draw_sprites(screen->machine, bitmap, cliprect, 0);
211
212   for (layer = 0; layer < 3; layer++)
213      tilemap_draw(bitmap, cliprect, state->bg_tilemap[layer], 1, 0);
214   draw_sprites(screen->machine, bitmap, cliprect, 1);
215
216   for (layer = 0; layer < 3; layer++)
217      tilemap_draw(bitmap, cliprect, state->bg_tilemap[layer], 2, 0);
218   draw_sprites(screen->machine, bitmap, cliprect, 2);
219
220   for (layer = 0; layer < 3; layer++)
221      tilemap_draw(bitmap, cliprect, state->bg_tilemap[layer], 3, 0);
222   draw_sprites(screen->machine, bitmap, cliprect, 3);
223
215224   return 0;
216225}
217226
218227VIDEO_EOF( othldrby )
219228{
229   othldrby_state *state = (othldrby_state *)machine->driver_data;
230
220231   /* sprites need to be delayed two frames */
221    memcpy(buf_spriteram,buf_spriteram2,SPRITERAM_SIZE*sizeof(buf_spriteram[0]));
222    memcpy(buf_spriteram2,&vram[SPRITERAM_START],SPRITERAM_SIZE*sizeof(buf_spriteram[0]));
232   memcpy(state->buf_spriteram, state->buf_spriteram2, SPRITERAM_SIZE * sizeof(state->buf_spriteram[0]));
233   memcpy(state->buf_spriteram2, &state->vram[SPRITERAM_START], SPRITERAM_SIZE * sizeof(state->buf_spriteram[0]));
223234}
src/mame/video/st0016.c
r7500r7501
1313
1414UINT32 st0016_game;
1515
16extern UINT8 macs_cart_slot;
17
1618static INT32 st0016_spr_bank,st0016_spr2_bank,st0016_pal_bank,st0016_char_bank;
1719static int spr_dx,spr_dy;
1820
r7500r7501
191193      UINT32 length=((st0016_vregs[0xa6]|(st0016_vregs[0xa7]<<8)|((st0016_vregs[0xa8]&0x1f)<<16))+1)<<1;
192194      UINT32 srclen = (memory_region_length(space->machine, "maincpu")-0x10000);
193195      UINT8 *mem = memory_region(space->machine, "maincpu");
196
197      srcadr += macs_cart_slot*0x400000;
198
194199      while(length>0)
195200      {
196201         if( srcadr < srclen && (dstadr < ST0016_MAX_CHAR_BANK*ST0016_CHAR_BANK_SIZE))
r7500r7501
654659   }
655660   else
656661   {
657      if(ISMACS1)
658      {
659         if(!(input_port_read(screen->machine, "SYS1")&1))   //fake coins - MACS2 system
660         {
661            macs_ram2[0]++;
662         }
663      }
664
665662      bitmap_fill(bitmap,cliprect,UNUSED_PEN);
666663      draw_bgmap(screen->machine, bitmap,cliprect,0);
667664      draw_sprites(screen->machine, bitmap,cliprect);
src/mame/video/funkyjet.c
r7500r7501
55***************************************************************************/
66
77#include "emu.h"
8#include "includes/deco16ic.h"
8#include "includes/funkyjet.h"
9#include "video/deco16ic.h"
910
1011/******************************************************************************/
1112
12VIDEO_START( funkyjet )
13static void draw_sprites( running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect )
1314{
14   deco16_1_video_init(machine);
15}
16
17static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect)
18{
19   UINT16 *spriteram16 = machine->generic.spriteram.u16;
15   funkyjet_state *state = (funkyjet_state *)machine->driver_data;
16   UINT16 *spriteram = state->spriteram;
2017   int offs;
2118
22   for (offs = 0;offs < 0x400;offs += 4)
19   for (offs = 0; offs < 0x400; offs += 4)
2320   {
24      int x,y,sprite,colour,multi,fx,fy,inc,flash,mult;
21      int x, y,sprite, colour, multi, fx, fy, inc, flash, mult;
2522
26      sprite = spriteram16[offs+1] & 0x3fff;
23      sprite = spriteram[offs + 1] & 0x3fff;
2724
28      y = spriteram16[offs];
29      flash=y&0x1000;
30      if (flash && (video_screen_get_frame_number(machine->primary_screen) & 1)) continue;
25      y = spriteram[offs];
26      flash = y & 0x1000;
27      if (flash && (video_screen_get_frame_number(machine->primary_screen) & 1))
28         continue;
3129
32      x = spriteram16[offs+2];
33      colour = (x >>9) & 0x1f;
30      x = spriteram[offs + 2];
31      colour = (x >> 9) & 0x1f;
3432
3533      fx = y & 0x2000;
3634      fy = y & 0x4000;
r7500r7501
4139      if (x >= 320) x -= 512;
4240      if (y >= 256) y -= 512;
4341      y = 240 - y;
44        x = 304 - x;
42      x = 304 - x;
4543
46      if (x>320) continue;
44      if (x > 320)
45         continue;
4746
4847      sprite &= ~multi;
4948      if (fy)
r7500r7501
5655
5756      if (flip_screen_get(machine))
5857      {
59         y=240-y;
60         x=304-x;
61         if (fx) fx=0; else fx=1;
62         if (fy) fy=0; else fy=1;
63         mult=16;
58         y = 240 - y;
59         x = 304 - x;
60         if (fx) fx = 0; else fx = 1;
61         if (fy) fy = 0; else fy = 1;
62         mult = 16;
6463      }
65      else mult=-16;
64      else
65         mult = -16;
6666
6767      while (multi >= 0)
6868      {
r7500r7501
7979
8080VIDEO_UPDATE( funkyjet )
8181{
82   flip_screen_set(screen->machine,  deco16_pf12_control[0]&0x80 );
83   deco16_pf12_update(deco16_pf1_rowscroll,deco16_pf2_rowscroll);
82   funkyjet_state *state = (funkyjet_state *)screen->machine->driver_data;
83   UINT16 flip = deco16ic_pf12_control_r(state->deco16ic, 0, 0xffff);
8484
85   bitmap_fill(bitmap,cliprect,768);
86   deco16_tilemap_2_draw(screen,bitmap,cliprect,TILEMAP_DRAW_OPAQUE,0);
87   deco16_tilemap_1_draw(screen,bitmap,cliprect,0,0);
88   draw_sprites(screen->machine,bitmap,cliprect);
85   flip_screen_set(screen->machine, BIT(flip, 7));
86   deco16ic_pf12_update(state->deco16ic, state->pf1_rowscroll, state->pf2_rowscroll);
87
88   bitmap_fill(bitmap, cliprect, 768);
89   deco16ic_tilemap_2_draw(state->deco16ic, bitmap, cliprect, TILEMAP_DRAW_OPAQUE, 0);
90   deco16ic_tilemap_1_draw(state->deco16ic, bitmap, cliprect, 0, 0);
91   draw_sprites(screen->machine, bitmap, cliprect);
8992   return 0;
9093}
src/mame/video/mrflea.c
r7500r7501
66******************************************************************/
77
88#include "emu.h"
9#include "includes/mrflea.h"
910
10static int mrflea_gfx_bank;
11WRITE8_HANDLER( mrflea_gfx_bank_w )
12{
13   mrflea_state *state = (mrflea_state *)space->machine->driver_data;
14   state->gfx_bank = data;
1115
12WRITE8_HANDLER( mrflea_gfx_bank_w ){
13   mrflea_gfx_bank = data;
14   if( data & ~0x14 ){
15      logerror( "unknown gfx bank: 0x%02x\n", data );
16   }
16   if (data & ~0x14)
17      logerror("unknown gfx bank: 0x%02x\n", data);
1718}
1819
19WRITE8_HANDLER( mrflea_videoram_w ){
20   int bank = offset/0x400;
20WRITE8_HANDLER( mrflea_videoram_w )
21{
22   mrflea_state *state = (mrflea_state *)space->machine->driver_data;
23   int bank = offset / 0x400;
24
2125   offset &= 0x3ff;
22   space->machine->generic.videoram.u8[offset] = data;
23   space->machine->generic.videoram.u8[offset+0x400] = bank;
24   /*  the address range that tile data is written to sets one bit of
25    **  the bank select.  The remaining bits are from a video register.
26    */
26   state->videoram[offset] = data;
27   state->videoram[offset + 0x400] = bank;
28   /* the address range that tile data is written to sets one bit of
29      the bank select.  The remaining bits are from a video register. */
2730}
2831
29WRITE8_HANDLER( mrflea_spriteram_w ){
30   if( offset&2 ){ /* tile_number */
31      space->machine->generic.spriteram.u8[offset|1] = offset&1;
32WRITE8_HANDLER( mrflea_spriteram_w )
33{
34   mrflea_state *state = (mrflea_state *)space->machine->driver_data;
35
36   if (offset & 2)
37   {
38      /* tile_number */
39      state->spriteram[offset | 1] = offset & 1;
3240      offset &= ~1;
3341   }
34   space->machine->generic.spriteram.u8[offset] = data;
42
43   state->spriteram[offset] = data;
3544}
3645
37static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect)
46static void draw_sprites( running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect )
3847{
48   mrflea_state *state = (mrflea_state *)machine->driver_data;
3949   const gfx_element *gfx = machine->gfx[0];
40   const UINT8 *source = machine->generic.spriteram.u8;
41   const UINT8 *finish = source+0x100;
50   const UINT8 *source = state->spriteram;
51   const UINT8 *finish = source + 0x100;
4252   rectangle clip = *video_screen_get_visible_area(machine->primary_screen);
53
4354   clip.max_x -= 24;
4455   clip.min_x += 16;
45   while( source<finish ){
46      int xpos = source[1]-3;
47      int ypos = source[0]-16+3;
48      int tile_number = source[2]+source[3]*0x100;
4956
57   while (source < finish)
58   {
59      int xpos = source[1] - 3;
60      int ypos = source[0] - 16 + 3;
61      int tile_number = source[2] + source[3] * 0x100;
62
5063      drawgfx_transpen( bitmap, &clip,gfx,
5164         tile_number,
5265         0, /* color */
r7500r7501
5770         0, /* color */
5871         0,0, /* no flip */
5972         xpos,256+ypos,0 );
60      source+=4;
73      source += 4;
6174   }
6275}
6376
64static void draw_background(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect)
77static void draw_background( running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect )
6578{
66   const UINT8 *source = machine->generic.videoram.u8;
79   mrflea_state *state = (mrflea_state *)machine->driver_data;
80   const UINT8 *source = state->videoram;
6781   const gfx_element *gfx = machine->gfx[1];
68   int sx,sy;
82   int sx, sy;
6983   int base = 0;
70   if( mrflea_gfx_bank&0x04 ) base |= 0x400;
71   if( mrflea_gfx_bank&0x10 ) base |= 0x200;
72   for( sy=0; sy<256; sy+=8 ){
73      for( sx=0; sx<256; sx+=8 ){
74         int tile_number = base+source[0]+source[0x400]*0x100;
84
85   if (BIT(state->gfx_bank, 2))
86      base |= 0x400;
87
88   if (BIT(state->gfx_bank, 4))
89      base |= 0x200;
90
91   for (sy = 0; sy < 256; sy += 8)
92   {
93      for (sx = 0; sx < 256; sx += 8)
94      {
95         int tile_number = base + source[0] + source[0x400] * 0x100;
7596         source++;
7697         drawgfx_opaque( bitmap, cliprect,
7798            gfx,
r7500r7501
83104   }
84105}
85106
86VIDEO_START( mrflea ){
87}
88
89107VIDEO_UPDATE( mrflea )
90108{
91109   draw_background(screen->machine, bitmap, cliprect);
src/mame/video/snes.c
r7500r7501
108108   { (96*32),  (96*32)+32,  (96*32)+64,  (96*32)+96,  (96*32)+128,  (96*32)+160,  (96*32)+192,  (96*32)+224 },
109109   { (112*32), (112*32)+32, (112*32)+64, (112*32)+96, (112*32)+128, (112*32)+160, (112*32)+192, (112*32)+224 }
110110};
111/* Scroll tables                             32x32      64x32              32x64              64x64 */
112static const UINT16 table_hscroll[4][4] = { {0,0,0,0}, {0,0x800,0,0x800}, {0,0,0,0}, {0,0x800,0,0x800} };
113static const UINT16 table_vscroll[4][4] = { {0,0,0,0}, {0,0,0,0}, {0,0x800,0,0x800}, {0,0x1000,0,0x1000} };
111114
112115struct SCANLINE
113116{
114   int enable, clip;
115
116   UINT16 buffer[(SNES_SCR_WIDTH * 2)];
117   UINT8  priority[(SNES_SCR_WIDTH * 2)];
118   UINT8  layer[(SNES_SCR_WIDTH * 2)];
119   UINT8  blend_exception[(SNES_SCR_WIDTH * 2)];
117   UINT16 buffer[(SNES_SCR_WIDTH * 2) + 16];
118   UINT8  priority[(SNES_SCR_WIDTH * 2) + 16];
119   UINT8  layer[(SNES_SCR_WIDTH * 2) + 16];
120   UINT8  blend_exception[(SNES_SCR_WIDTH * 2) + 16];
120121};
121122
122123static struct SCANLINE scanlines[2];
r7500r7501
135136 * Routine for additive/subtractive blending
136137 * between the main and sub screens.
137138 *****************************************/
138
139INLINE void snes_draw_blend( UINT16 offset, UINT16 *colour, UINT8 clip, UINT8 black_pen_clip )
139INLINE void snes_draw_blend(UINT16 offset, UINT16 *colour, UINT8 factor, UINT8 clip, UINT8 black_pen_clip )
140140{
141141   if ((black_pen_clip == SNES_CLIP_ALL2) ||
142      (black_pen_clip == SNES_CLIP_IN && snes_ppu.clipmasks[SNES_COLOR][offset]) ||
143      (black_pen_clip == SNES_CLIP_OUT && !snes_ppu.clipmasks[SNES_COLOR][offset]))
142      (black_pen_clip == SNES_CLIP_IN && snes_ppu.clipmasks[SNES_COLOR][offset / factor]) ||
143      (black_pen_clip == SNES_CLIP_OUT && !snes_ppu.clipmasks[SNES_COLOR][offset / factor]))
144144      *colour = 0; //clip to black before color math
145145
146146   if (clip == SNES_CLIP_ALL2) // blending mode 3 == always OFF
r7500r7501
150150   if (!debug_options.transparency_disabled)
151151#endif /* SNES_LAYER_DEBUG */
152152   if ((clip == SNES_CLIP_ALL) ||
153      (clip == SNES_CLIP_IN  && !snes_ppu.clipmasks[SNES_COLOR][offset]) ||
154      (clip == SNES_CLIP_OUT && snes_ppu.clipmasks[SNES_COLOR][offset]))
153      (clip == SNES_CLIP_IN  && !snes_ppu.clipmasks[SNES_COLOR][offset / factor]) ||
154      (clip == SNES_CLIP_OUT && snes_ppu.clipmasks[SNES_COLOR][offset / factor]))
155155   {
156156      UINT16 r, g, b;
157157      int clip_max = 0;   // if add then clip to 0x1f, if sub then clip to 0
r7500r7501
225225   }
226226}
227227
228INLINE void snes_draw_blend_lores(UINT16 offset, UINT16 *colour, UINT8 clip, UINT8 black_pen_clip )
229{
230   snes_draw_blend(offset, colour, 1, clip, black_pen_clip);
231}
232
233INLINE void snes_draw_blend_hires(UINT16 offset, UINT16 *colour, UINT8 clip, UINT8 black_pen_clip )
234{
235   snes_draw_blend(offset, colour, 2, clip, black_pen_clip);
236}
237
228238/*****************************************
229239 * snes_draw_tile()
230240 *
231241 * Draw tiles with variable bit planes
232242 *****************************************/
233
234INLINE void snes_draw_tile( UINT8 planes, UINT8 layer, UINT16 tileaddr, INT16 x, UINT8 priority, UINT8 flip, UINT16 pal, UINT8 direct_colors, UINT8 hires )
243INLINE void snes_draw_tile(UINT8 screen, UINT8 planes, UINT8 layer, UINT16 tileaddr, INT16 x, UINT8 priority, UINT8 flip, UINT16 pal, UINT8 direct_colors )
235244{
236   UINT8 mask, plane[8];
245   UINT8 mask, plane[8], window_enabled = 0;
237246   UINT16 c;
238247   INT16 ii, jj;
239248
r7500r7501
266275         mask >>= 1;
267276      }
268277
269
270      if (!hires)
271      {
272         if (scanlines[SNES_MAINSCREEN].enable)
273         {
274
275278#ifdef SNES_LAYER_DEBUG
276            if (!debug_options.windows_disabled)
279      if (!debug_options.windows_disabled)
277280#endif /* SNES_LAYER_DEBUG */
278            /* Clip to windows */
279            if (scanlines[SNES_MAINSCREEN].clip)
280               colour &= snes_ppu.clipmasks[layer][ii];
281      /* Clip to windows */
282      window_enabled = (screen == SNES_MAINSCREEN) ? snes_ppu.layer[layer].main_window_enabled : snes_ppu.layer[layer].sub_window_enabled;
283      if (window_enabled)
284         colour &= snes_ppu.clipmasks[layer][ii];
281285
282            /* Only draw if we have a colour (0 == transparent) */
283            if (colour)
284            {
285               if ((scanlines[SNES_MAINSCREEN].priority[ii] <= priority) && (ii >= 0))
286               {
287                  if (direct_colors)
288                  {
289                     /* format is  0 | BBb00 | GGGg0 | RRRr0, HW confirms that the data is zero padded. */
290                     c = ((colour & 0x07) << 2) | ((colour & 0x38) << 4) | ((colour & 0xc0) << 7);
291                     c |= ((pal & 0x04) >> 1) | ((pal & 0x08) << 3) | ((pal & 0x10) << 8);
292                  }
293                  else
294                     c = snes_cgram[pal + colour];
295
296                  if (snes_ppu.layer[SNES_MAINSCREEN].mosaic_enabled) // handle horizontal mosaic
297                  {
298                     int x_mos;
299
300                     //TODO: 512 modes has the h values doubled.
301                     for (x_mos = 0; x_mos < (snes_ppu.mosaic_size + 1) ; x_mos++)
302                     {
303                        scanlines[SNES_MAINSCREEN].buffer[ii + x_mos] = c;
304                        scanlines[SNES_MAINSCREEN].priority[ii + x_mos] = priority;
305                        scanlines[SNES_MAINSCREEN].layer[ii + x_mos] = layer;
306                     }
307
308                     ii += x_mos - 1;
309                  }
310                  else
311                  {
312                     scanlines[SNES_MAINSCREEN].buffer[ii] = c;
313                     scanlines[SNES_MAINSCREEN].priority[ii] = priority;
314                     scanlines[SNES_MAINSCREEN].layer[ii] = layer;
315                  }
316               }
317            }
318         }
319
320         if (scanlines[SNES_SUBSCREEN].enable)
286      /* Only draw if we have a colour (0 == transparent) */
287      if (colour)
288      {
289         if ((scanlines[screen].priority[ii] <= priority) && (ii >= 0))
321290         {
322#ifdef SNES_LAYER_DEBUG
323            if (!debug_options.windows_disabled)
324#endif /* SNES_LAYER_DEBUG */
325            /* Clip to windows */
326            if (scanlines[SNES_SUBSCREEN].clip)
327               colour &= snes_ppu.clipmasks[layer][ii];
328
329            /* Only draw if we have a colour (0 == transparent) */
330            if (colour)
291            if (direct_colors)
331292            {
332               if ((scanlines[SNES_SUBSCREEN].priority[ii] <= priority) && (ii >= 0))
333               {
334                  if (direct_colors)
335                  {
336                     /* format is  0 | BBb00 | GGGg0 | RRRr0, HW confirms that the data is zero padded. */
337                     c = ((colour & 0x07) << 2) | ((colour & 0x38) << 4) | ((colour & 0xc0) << 7);
338                     c |= ((pal & 0x04) >> 1) | ((pal & 0x08) << 3) | ((pal & 0x10) << 8);
339                  }
340                  else
341                     c = snes_cgram[pal + colour];
342
343                  if (snes_ppu.layer[SNES_SUBSCREEN].mosaic_enabled) // handle horizontal mosaic
344                  {
345                     int x_mos;
346
347                     //TODO: 512 modes has the h values doubled.
348                     for (x_mos = 0; x_mos < (snes_ppu.mosaic_size + 1) ; x_mos++)
349                     {
350                        scanlines[SNES_SUBSCREEN].buffer[ii + x_mos] = c;
351                        scanlines[SNES_SUBSCREEN].priority[ii + x_mos] = priority;
352                        scanlines[SNES_SUBSCREEN].layer[ii + x_mos] = layer;
353                     }
354
355                     ii += x_mos - 1;
356                  }
357                  else
358                  {
359                     scanlines[SNES_SUBSCREEN].buffer[ii] = c;
360                     scanlines[SNES_SUBSCREEN].priority[ii] = priority;
361                     scanlines[SNES_SUBSCREEN].layer[ii] = layer;
362                  }
363               }
293               /* format is  0 | BBb00 | GGGg0 | RRRr0, HW confirms that the data is zero padded. */
294               c = ((colour & 0x07) << 2) | ((colour & 0x38) << 4) | ((colour & 0xc0) << 7);
295               c |= ((pal & 0x04) >> 1) | ((pal & 0x08) << 3) | ((pal & 0x10) << 8);
364296            }
365         }
366      }
297            else
298               c = snes_cgram[pal + colour];
367299
368      else /* hires */
369      {
370#ifdef SNES_LAYER_DEBUG
371         if (!debug_options.windows_disabled)
372#endif /* SNES_LAYER_DEBUG */
373         /* Clip to windows */
374         if (scanlines[SNES_MAINSCREEN].clip)
375            colour &= snes_ppu.clipmasks[layer][ii >> hires];
376
377         /* Only draw if we have a colour (0 == transparent) */
378         if (colour)
379         {
380            if ((scanlines[SNES_MAINSCREEN].priority[ii >> hires] <= priority) && (ii >= 0))
300            if (snes_ppu.layer[layer].mosaic_enabled) // handle horizontal mosaic
381301            {
382               if (direct_colors)
383               {
384                  /* format is  0 | BBb00 | GGGg0 | RRRr0, HW confirms that the data is zero padded. */
385                  c = ((colour & 0x07) << 2) | ((colour & 0x38) << 4) | ((colour & 0xc0) << 7);
386                  c |= ((pal & 0x04) >> 1) | ((pal & 0x08) << 3) | ((pal & 0x10) << 8);
387               }
388               else
389                  c = snes_cgram[pal + colour];
302               int x_mos;
390303
391               if (snes_ppu.layer[layer].mosaic_enabled) // handle horizontal mosaic
304               //TODO: 512 modes has the h values doubled.
305               for (x_mos = 0; x_mos < (snes_ppu.mosaic_size + 1) ; x_mos++)
392306               {
393                  int x_mos;
394
395                  //TODO: 512 modes has the h values doubled.
396                  for (x_mos = 0; x_mos < (snes_ppu.mosaic_size + 1) ; x_mos++)
397                  {
398                     if ((ii & 1) && scanlines[SNES_MAINSCREEN].enable)
399                     {
400                        scanlines[SNES_MAINSCREEN].buffer[(ii + x_mos) >> 1] = c;
401                        scanlines[SNES_MAINSCREEN].priority[(ii + x_mos) >> 1] = priority;
402                        scanlines[SNES_MAINSCREEN].layer[(ii + x_mos) >> 1] = layer;
403                     }
404                     else if (scanlines[SNES_SUBSCREEN].enable)
405                     {
406                        scanlines[SNES_SUBSCREEN].buffer[(ii + x_mos) >> 1] = c;
407                        scanlines[SNES_SUBSCREEN].priority[(ii + x_mos) >> 1] = priority;
408                        scanlines[SNES_SUBSCREEN].layer[(ii + x_mos) >> 1] = layer;
409                     }
410                  }
411                  ii += x_mos - 1;
307                  scanlines[screen].buffer[ii + x_mos] = c;
308                  scanlines[screen].priority[ii + x_mos] = priority;
309                  scanlines[screen].layer[ii + x_mos] = layer;
412310               }
413               else
414               {
415                  if ((ii & 1) && scanlines[SNES_MAINSCREEN].enable)
416                  {
417                     scanlines[SNES_MAINSCREEN].buffer[ii >> 1] = c;
418                     scanlines[SNES_MAINSCREEN].priority[ii >> 1] = priority;
419                     scanlines[SNES_MAINSCREEN].layer[ii >> 1] = layer;
420                  }
421                  else if (scanlines[SNES_SUBSCREEN].enable)
422                  {
423                     scanlines[SNES_SUBSCREEN].buffer[ii >> 1] = c;
424                     scanlines[SNES_SUBSCREEN].priority[ii >> 1] = priority;
425                     scanlines[SNES_SUBSCREEN].layer[ii >> 1] = layer;
426                  }
427               }
311               ii += x_mos - 1;
428312            }
313            else
314            {
315               scanlines[screen].buffer[ii] = c;
316               scanlines[screen].priority[ii] = priority;
317               scanlines[screen].layer[ii] = layer;
318            }
429319         }
430320      }
431321   }
r7500r7501
436326 *
437327 * Draw 2 tiles with variable bit planes
438328 *****************************************/
439
440INLINE void snes_draw_tile_x2( UINT8 planes, UINT8 layer, UINT16 tileaddr, INT16 x, UINT8 priority, UINT8 flip, UINT16 pal, UINT8 direct_colors, UINT8 hires )
329INLINE void snes_draw_tile_x2(UINT8 screen, UINT8 planes, UINT8 layer, UINT16 tileaddr, INT16 x, UINT8 priority, UINT8 flip, UINT16 pal, UINT8 direct_colors )
441330{
442331   if (flip)
443332   {
444      snes_draw_tile(planes, layer, tileaddr + (8 * planes), x, priority, flip, pal, direct_colors, hires);
445      snes_draw_tile(planes, layer, tileaddr, x + 8, priority, flip, pal, direct_colors, hires);
333      snes_draw_tile(screen, planes, layer, tileaddr + (8 * planes), x, priority, flip, pal, direct_colors);
334      snes_draw_tile(screen, planes, layer, tileaddr, x + 8, priority, flip, pal, direct_colors);
446335   }
447336   else
448337   {
449      snes_draw_tile(planes, layer, tileaddr, x, priority, flip, pal, direct_colors, hires);
450      snes_draw_tile(planes, layer, tileaddr + (8 * planes), x + 8, priority, flip, pal, direct_colors, hires);
338      snes_draw_tile(screen, planes, layer, tileaddr, x, priority, flip, pal, direct_colors);
339      snes_draw_tile(screen, planes, layer, tileaddr + (8 * planes), x + 8, priority, flip, pal, direct_colors);
451340   }
452341}
453342
r7500r7501
458347 * The same as snes_draw_tile_4() except
459348 * that it takes a blend parameter.
460349 *****************************************/
461
462INLINE void snes_draw_tile_object( UINT16 tileaddr, INT16 x, UINT8 priority, UINT8 flip, UINT16 pal, UINT8 blend )
350INLINE void snes_draw_tile_object(UINT8 screen, UINT16 tileaddr, INT16 x, UINT8 priority, UINT8 flip, UINT16 pal, UINT8 blend, UINT8 wide )
463351{
464   UINT8 mask, plane[4];
352   UINT8 mask, plane[4], window_enabled = 0;
465353   UINT16 c;
466354   INT16 ii;
355   UINT8 x_shift = wide ? 1 : 0;
356   UINT8 size = wide ? 16 : 8;
357   UINT8 step = wide ? 1 : 0;
467358
468359   plane[0] = snes_vram[tileaddr];
469360   plane[1] = snes_vram[tileaddr + 1];
r7500r7501
475366   else
476367      mask = 0x80;
477368
478   for (ii = x; ii < (x + 8); ii++)
369   x <<= x_shift;
370   for (ii = x; ii < (x + size); ii += 1 + step)
479371   {
480372      UINT8 colour;
481373      if (flip)
r7500r7501
491383         mask >>= 1;
492384      }
493385
494      if (scanlines[SNES_MAINSCREEN].enable)
495      {
496
497386#ifdef SNES_LAYER_DEBUG
498         if (!debug_options.windows_disabled)
387      if (!debug_options.windows_disabled)
499388#endif /* SNES_LAYER_DEBUG */
500         /* Clip to windows */
501         if (scanlines[SNES_MAINSCREEN].clip)
502            colour &= snes_ppu.clipmasks[SNES_OAM][ii];
389      /* Clip to windows */
390      window_enabled = (screen == SNES_MAINSCREEN) ? snes_ppu.layer[SNES_OAM].main_window_enabled : snes_ppu.layer[SNES_OAM].sub_window_enabled;
391      if (window_enabled)
392         colour &= snes_ppu.clipmasks[SNES_OAM][ii];
503393
504         /* Only draw if we have a colour (0 == transparent) */
505         if (colour)
506         {
507            if ((scanlines[SNES_MAINSCREEN].priority[ii] <= priority) && (ii >= 0))
508            {
509               c = snes_cgram[pal + colour];
510
511               scanlines[SNES_MAINSCREEN].buffer[ii] = c;
512               scanlines[SNES_MAINSCREEN].priority[ii] = priority;
513               scanlines[SNES_MAINSCREEN].layer[ii] = SNES_OAM;
514               scanlines[SNES_MAINSCREEN].blend_exception[ii] = blend;
515            }
516         }
517      }
518
519      if (scanlines[SNES_SUBSCREEN].enable)
394      /* Only draw if we have a colour (0 == transparent) */
395      if (colour)
520396      {
521
522#ifdef SNES_LAYER_DEBUG
523         if (!debug_options.windows_disabled)
524#endif /* SNES_LAYER_DEBUG */
525         /* Clip to windows */
526         if (scanlines[SNES_SUBSCREEN].clip)
527            colour &= snes_ppu.clipmasks[SNES_OAM][ii];
528
529         /* Only draw if we have a colour (0 == transparent) */
530         if (colour)
397         if ((scanlines[screen].priority[ii] <= priority) && (ii >= 0))
531398         {
532            if ((scanlines[SNES_SUBSCREEN].priority[ii] <= priority) && (ii >= 0))
533            {
534               c = snes_cgram[pal + colour];
399            c = snes_cgram[pal + colour];
535400
536               scanlines[SNES_SUBSCREEN].buffer[ii] = c;
537               scanlines[SNES_SUBSCREEN].priority[ii] = priority;
538               scanlines[SNES_SUBSCREEN].layer[ii] = SNES_OAM;
539               scanlines[SNES_SUBSCREEN].blend_exception[ii] = blend;
401            scanlines[screen].buffer[ii] = c;
402            scanlines[screen].priority[ii] = priority;
403            scanlines[screen].layer[ii] = SNES_OAM;
404            scanlines[screen].blend_exception[ii] = blend;
405            if (wide)
406            {
407               scanlines[screen].buffer[ii + 1] = c;
408               scanlines[screen].priority[ii + 1] = priority;
409               scanlines[screen].layer[ii + 1] = SNES_OAM;
410               scanlines[screen].blend_exception[ii + 1] = blend;
540411            }
541412         }
542413      }
r7500r7501
548419 *
549420 * Update an entire line of tiles.
550421 *********************************************/
551
552INLINE UINT32 snes_get_tmap( UINT8 layer, UINT8 tile_size, UINT32 base, UINT32 x, UINT32 y )
422INLINE void snes_update_line( UINT8 screen, UINT8 color_depth, UINT8 hires, UINT8 priority_a, UINT8 priority_b, UINT8 layer, UINT16 curline, UINT8 offset_per_tile, UINT8 direct_colors )
553423{
554   UINT32 res = base;
555   x  >>= (3 + tile_size);
556   y  >>= (3 + tile_size);
557
558   res += (snes_ppu.layer[layer].tilemap_size & 2) ? ((y & 0x20) << ((snes_ppu.layer[layer].tilemap_size & 1) ? 7 : 6)) : 0;
559   /* Scroll vertically */
560   res += (y & 0x1f) << 6;
561   /* Offset horizontally */
562   res += (snes_ppu.layer[layer].tilemap_size & 1) ? ((x & 0x20) << 6) : 0;
563   /* Scroll horizontally */
564   res += (x & 0x1f) << 1;
565
566   return res;
567}
568
569INLINE void snes_update_line( UINT8 color_depth, UINT8 hires, UINT8 priority_a, UINT8 priority_b, UINT8 layer, UINT16 curline, UINT8 offset_per_tile, UINT8 direct_colors )
570{
571   UINT32 tmap, tile, xoff, yoff;
572   UINT16 ii = 0, vflip, hflip, pal;
424   UINT32 tmap, tile;
425   UINT16 ii, vflip, hflip, pal;
573426   INT8 tile_line;
574427   UINT8 priority;
575428   /* scrolling */
576   UINT32 charaddr;
429   UINT32 basevmap, charaddr;
577430   UINT16 vscroll, hscroll;
578   UINT16 opt_bit = (layer == SNES_BG1) ? 13 : (layer == SNES_BG2) ? 14 : 0;
431//  UINT16 offset_per_tile_valid;
432//  UINT8 offset_per_tile_mode;
579433   UINT8 vshift, hshift, tile_size;
580434   /* variables depending on color_depth */
581435   UINT8 color_shift = 0;
582436   UINT8 color_planes = 2;
583437   UINT8 tile_divider = 1;
438   UINT8 wrap_around_x; //helper for wrap-around
584439
585440#ifdef SNES_LAYER_DEBUG
586441   if (debug_options.bg_disabled[layer])
587442      return;
588#endif /* SNES_LAYER_DEBUG */
589443
590   scanlines[SNES_MAINSCREEN].enable = snes_ppu.main_bg_enabled[layer];
591   scanlines[SNES_SUBSCREEN].enable = snes_ppu.sub_bg_enabled[layer];
592   scanlines[SNES_MAINSCREEN].clip = snes_ppu.layer[layer].main_window_enabled;
593   scanlines[SNES_SUBSCREEN].clip = snes_ppu.layer[layer].sub_window_enabled;
594
595   if (!scanlines[SNES_MAINSCREEN].enable && !scanlines[SNES_SUBSCREEN].enable)
444   if (debug_options.mode_disabled[snes_ppu.mode])
596445      return;
446#endif /* SNES_LAYER_DEBUG */
597447
598448   /* Handle Mosaic effects */
599449   if (snes_ppu.layer[layer].mosaic_enabled)
r7500r7501
611461   vscroll = ((snes_ppu.layer[layer].voffs & 0x3ff) + curline) >> (3 + tile_size);
612462   vshift = ((snes_ppu.layer[layer].voffs & 0x3ff) + curline) & ((8 << tile_size) - 1);
613463
614   xoff = snes_ppu.layer[layer].hoffs;
615   yoff = snes_ppu.layer[layer].voffs;
616
617464   /* figure out which line to draw */
618465   if (vshift > ((8 << tile_size) - 1))   /* scrolled into the next tile */
619466   {
r7500r7501
627474   tmap = snes_ppu.layer[layer].tilemap << 9;
628475   charaddr = snes_ppu.layer[layer].charmap << 13;
629476
477   /* Offset vertically */
478   tmap += (snes_ppu.layer[layer].tilemap_size & 2) ? ((vscroll & 0x20) << ((snes_ppu.layer[layer].tilemap_size & 1) ? 7 : 6)) : 0;
479   /* Scroll vertically */
480   tmap += (vscroll & 0x1f) << 6;
481   /* Remember this position */
482   basevmap = tmap;
483   /* Offset horizontally */
484   tmap += (snes_ppu.layer[layer].tilemap_size & 1) ? ((hscroll & 0x20) << 6) : 0;
485   /* Scroll horizontally */
486   tmap += (hscroll & 0x1f) << 1;
487
630488   /* set a couple of variables depending on color_dept */
631489   switch (color_depth)
632490   {
r7500r7501
647505         break;
648506   }
649507
650   while (ii < 256)
508   wrap_around_x = 1;
509
510   for (ii = 0; ii < (66*(hires+1) >> tile_size); ii += 2)
651511   {
512      /* Have we scrolled into the next map? */
513      if (wrap_around_x && ((ii >> 1) >= 32 - (hscroll & 0x1f)))
514      {
515         tmap = basevmap + table_hscroll[snes_ppu.layer[layer].tilemap_size & 3][((hscroll >> 5) + 1) & 3];
516         tmap -= ii;
517         wrap_around_x = 0;   /* Make sure we don't do this again */
518      }
519      //if (tmap > 0x10000)
520      //  tmap %= 0x10000;
521
652522      /*
653523        Tilemap format
654524          vhopppcc cccccccc
r7500r7501
658528          ppp  = Tile palette. The number of entries in the palette depends on the Mode and the BG.
659529          cccccccccc = Tile number.
660530        */
661
662      // determine the horizontal position (Bishojo Janshi Suchi Pai & Desert Figther have tile_size & hires == 1)
663      UINT32 xpos = xoff + (ii << (tile_size * hires));
664      UINT32 ypos = yoff + curline;
665
666      if (offset_per_tile != SNES_OPT_NONE)
667      {
668         int opt_x = ii + (xoff & 7);
669         UINT32 haddr = 0, vaddr = 0;
670         UINT16 hval = 0, vval = 0;
671
672            if (opt_x >= 8)
673         {
674            switch (offset_per_tile)
675            {
676            case SNES_OPT_MODE2:
677            case SNES_OPT_MODE6:
678               haddr = snes_get_tmap(SNES_BG3, snes_ppu.layer[SNES_BG3].tile_size, snes_ppu.layer[SNES_BG3].tilemap << 9, (opt_x - 8) + ((snes_ppu.layer[SNES_BG3].hoffs & 0x3ff) & ~7), (snes_ppu.layer[SNES_BG3].voffs & 0x3ff));
679               vaddr = snes_get_tmap(SNES_BG3, snes_ppu.layer[SNES_BG3].tile_size, snes_ppu.layer[SNES_BG3].tilemap << 9, (opt_x - 8) + ((snes_ppu.layer[SNES_BG3].hoffs & 0x3ff) & ~7), (snes_ppu.layer[SNES_BG3].voffs & 0x3ff) + 8);
680               hval = snes_vram[haddr] | (snes_vram[haddr + 1] << 8);
681               vval = snes_vram[vaddr] | (snes_vram[vaddr + 1] << 8);
682               if (BIT(hval, opt_bit))
683                  xpos = opt_x + (hval & ~7);
684               if (BIT(vval, opt_bit))
685                  ypos = curline + vval;
686               break;
687            case SNES_OPT_MODE4:
688               haddr = snes_get_tmap(SNES_BG3, snes_ppu.layer[SNES_BG3].tile_size, snes_ppu.layer[SNES_BG3].tilemap << 9, (opt_x - 8) + ((snes_ppu.layer[SNES_BG3].hoffs & 0x3ff) & ~7), (snes_ppu.layer[SNES_BG3].voffs & 0x3ff));
689               hval = snes_vram[haddr] | (snes_vram[haddr + 1] << 8);
690               if (BIT(hval, opt_bit))
691               {
692                  if (!BIT(hval, 15))
693                     xpos = opt_x + (hval & ~7);
694                  else
695                     ypos = curline + hval;
696               }
697               break;
698            }
699
700         }
701      }
702
703      UINT32 addr = snes_get_tmap(layer, tile_size, tmap, xpos, ypos);
704      UINT16 tilemap = snes_vram[addr] | (snes_vram[addr + 1] << 8);
531      UINT16 tilemap = snes_vram[tmap + ii] | (snes_vram[tmap + ii + 1] << 8);
705532      vflip = BIT(tilemap, 15);
706533      hflip = BIT(tilemap, 14);
707534      priority = BIT(tilemap, 13) ? priority_b : priority_a;
r7500r7501
741568      tile_line <<= 1;
742569
743570      /* below, only color_planes depends on color_depth */
744      if (hires)   /* Hi-Res: 2bpp & 4bpp */
571      if (tile_size)
745572      {
746         snes_draw_tile_x2(color_planes, layer, charaddr + (tile  * 8 * color_planes) + tile_line, ii * 2, priority, hflip, pal, direct_colors, hires);
747         ii += 8;
573         snes_draw_tile_x2(screen, color_planes, layer, charaddr + (tile  * 8 * color_planes) + tile_line, ((ii >> 1) * (8 << tile_size)) - hshift, priority, hflip, pal, direct_colors);
748574      }
749575      else   /* tile_size = 0 */
750576      {
751         if (tile_size)
752         {
753            snes_draw_tile_x2(color_planes, layer, charaddr + (tile  * 8 * color_planes) + tile_line, ii, priority, hflip, pal, direct_colors, hires);
754            ii += 16;
755         }
577         if (hires)   /* Hi-Res: 2bpp & 4bpp */
578            snes_draw_tile_x2(screen, color_planes, layer, charaddr + (tile  * 8 * color_planes) + tile_line, ((ii >> 1) * (8 << (tile_size + 1))) - (hshift << 1), priority, hflip, pal, direct_colors);
756579         else   /* No Hi-Res: 2bpp, 4bpp & 8bpp */
757         {
758            snes_draw_tile(color_planes, layer, charaddr + (tile  * 8 * color_planes) + tile_line, ii, priority, hflip, pal, direct_colors, hires);
759            ii += 8;
760         }
580            snes_draw_tile(screen, color_planes, layer, charaddr + (tile  * 8 * color_planes) + tile_line, ((ii >> 1) * (8 << tile_size)) - hshift, priority, hflip, pal, direct_colors);
761581      }
762582   }
763583}
r7500r7501
768588 *
769589 * Update an entire line of mode7 tiles.
770590 *********************************************/
771
772591#define MODE7_CLIP(x) (((x) & 0x2000) ? ((x) | ~0x03ff) : ((x) & 0x03ff))
773592
774static void snes_update_line_mode7( UINT8 priority_a, UINT8 priority_b, UINT8 layer, UINT16 curline )
593static void snes_update_line_mode7(UINT8 screen, UINT8 priority_a, UINT8 priority_b, UINT8 layer, UINT16 curline )
775594{
776595   UINT32 tiled;
777596   INT16 ma, mb, mc, md;
778597   INT32 xc, yc, tx, ty, sx, sy, hs, vs, xpos, xdir, x0, y0;
779598   UINT8 priority = priority_a;
780   UINT8 colour = 0;
599   UINT8 colour = 0, window_enabled = 0;
781600   UINT16 *mosaic_x, *mosaic_y;
782601
783602#ifdef SNES_LAYER_DEBUG
784603   if (debug_options.bg_disabled[layer])
785604      return;
786#endif /* SNES_LAYER_DEBUG */
787605
788   scanlines[SNES_MAINSCREEN].enable = snes_ppu.main_bg_enabled[layer];
789   scanlines[SNES_SUBSCREEN].enable = snes_ppu.sub_bg_enabled[layer];
790   scanlines[SNES_MAINSCREEN].clip = snes_ppu.layer[layer].main_window_enabled;
791   scanlines[SNES_SUBSCREEN].clip = snes_ppu.layer[layer].sub_window_enabled;
792
793   if (!scanlines[SNES_MAINSCREEN].enable && !scanlines[SNES_SUBSCREEN].enable)
606   if (debug_options.mode_disabled[snes_ppu.mode])
794607      return;
608#endif /* SNES_LAYER_DEBUG */
795609
796610   ma = snes_ppu.mode7.matrix_a;
797611   mb = snes_ppu.mode7.matrix_b;
r7500r7501
887701         colour &= 0x7f;
888702      }
889703
890      if (scanlines[SNES_MAINSCREEN].enable)
891      {
892         if (scanlines[SNES_MAINSCREEN].clip)
893            colour &= snes_ppu.clipmasks[layer][xpos];
704      window_enabled = (screen == SNES_MAINSCREEN) ? snes_ppu.layer[layer].main_window_enabled : snes_ppu.layer[layer].sub_window_enabled;
705      if (window_enabled)
706         colour &= snes_ppu.clipmasks[layer][xpos];
894707
895         /* Draw pixel if appropriate */
896         if (scanlines[SNES_MAINSCREEN].priority[xpos] <= priority && colour > 0)
897         {
898            UINT16 clr;
899            /* Direct select, but only outside EXTBG! */
900            if (snes_ppu.direct_color && layer == 0)
901            {
902               /* 0 | BB000 | GGG00 | RRR00, HW confirms that the data is zero padded. */
903               clr = ((colour & 0x07) << 2) | ((colour & 0x38) << 4) | ((colour & 0xc0) << 7);
904            }
905            else
906               clr = snes_cgram[colour];
907
908            scanlines[SNES_MAINSCREEN].buffer[xpos] = clr;
909            scanlines[SNES_MAINSCREEN].priority[xpos] = priority;
910            scanlines[SNES_MAINSCREEN].layer[xpos] = layer;
911         }
912      }
913
914      if (scanlines[SNES_SUBSCREEN].enable)
708      /* Draw pixel if appropriate */
709      if (scanlines[screen].priority[xpos] <= priority && colour > 0)
915710      {
916         if (scanlines[SNES_SUBSCREEN].clip)
917            colour &= snes_ppu.clipmasks[layer][xpos];
918
919         /* Draw pixel if appropriate */
920         if (scanlines[SNES_SUBSCREEN].priority[xpos] <= priority && colour > 0)
711         UINT16 clr;
712         /* Direct select, but only outside EXTBG! */
713         if (snes_ppu.direct_color && layer == 0)
921714         {
922            UINT16 clr;
923            /* Direct select, but only outside EXTBG! */
924            if (snes_ppu.direct_color && layer == 0)
925            {
926               /* 0 | BB000 | GGG00 | RRR00, HW confirms that the data is zero padded. */
927               clr = ((colour & 0x07) << 2) | ((colour & 0x38) << 4) | ((colour & 0xc0) << 7);
928            }
929            else
930               clr = snes_cgram[colour];
931
932            scanlines[SNES_SUBSCREEN].buffer[xpos] = clr;
933            scanlines[SNES_SUBSCREEN].priority[xpos] = priority;
934            scanlines[SNES_SUBSCREEN].layer[xpos] = layer;
715            /* 0 | BB000 | GGG00 | RRR00, HW confirms that the data is zero padded. */
716            clr = ((colour & 0x07) << 2) | ((colour & 0x38) << 4) | ((colour & 0xc0) << 7);
935717         }
718         else
719            clr = snes_cgram[colour];
720
721         scanlines[screen].buffer[xpos] = clr;
722         scanlines[screen].priority[xpos] = priority;
723         scanlines[screen].layer[xpos] = layer;
936724      }
937725   }
938726}
r7500r7501
943731 * Update an entire line of sprites.
944732 * FIXME: We need to support high priority bit
945733 *********************************************/
946
947static void snes_update_objects( UINT8 priority_tbl, UINT16 curline )
734static void snes_update_objects( UINT8 screen, UINT8 priority_tbl, UINT16 curline )
948735{
949736   INT8 xs, ys;
950   UINT8 line;
737   UINT8 line, widemode = 0;
951738   UINT16 oam_extra, extra;
952739   INT16 oam;
953740   UINT8 range_over = 0, time_over = 0;
r7500r7501
970757   };
971758
972759#ifdef SNES_LAYER_DEBUG
973   if (debug_options.bg_disabled[SNES_OAM])
760   if (debug_options.bg_disabled[4])
974761      return;
975762#endif /* SNES_LAYER_DEBUG */
976763
977   scanlines[SNES_MAINSCREEN].enable = snes_ppu.main_bg_enabled[SNES_OAM];
978   scanlines[SNES_SUBSCREEN].enable = snes_ppu.sub_bg_enabled[SNES_OAM];
979   scanlines[SNES_MAINSCREEN].clip = snes_ppu.layer[SNES_OAM].main_window_enabled;
980   scanlines[SNES_SUBSCREEN].clip = snes_ppu.layer[SNES_OAM].sub_window_enabled;
764   if (snes_ppu.mode == 5 || snes_ppu.mode == 6)
765      widemode = 1;
981766
982   if (!scanlines[SNES_MAINSCREEN].enable && !scanlines[SNES_SUBSCREEN].enable)
983      return;
984
985767   curline /= snes_ppu.interlace;
986768   curline *= snes_ppu.obj_interlace;
987769
r7500r7501
1007789      extra <<= 1;
1008790      x |= ((extra & 0x80) << 1);
1009791      extra <<= 1;
1010      y *= snes_ppu.obj_interlace;
792      y*=snes_ppu.obj_interlace;
1011793
1012794      /* Adjust if past maximum position */
1013795      if (y >= snes_ppu.beam.last_visible_line*snes_ppu.interlace)
r7500r7501
1040822            {
1041823               if ((x + (count << 3) < SNES_SCR_WIDTH + 8))
1042824               {
1043                  snes_draw_tile_object(charaddr + name_sel + tile + table_obj_offset[ys][xs] + line, x + (count++ << 3), priority, hflip, pal, blend);
825                  if (widemode)
826                     snes_draw_tile_object(screen, charaddr + name_sel + tile + table_obj_offset[ys][xs] + line, x + (count++ << 3), priority, hflip, pal, blend, 1);
827                  else
828                     snes_draw_tile_object(screen, charaddr + name_sel + tile + table_obj_offset[ys][xs] + line, x + (count++ << 3), priority, hflip, pal, blend, 0);
1044829               }
1045830               time_over++;   /* Increase time_over. Should we stop drawing if exceeded 34 tiles? */
1046831            }
r7500r7501
1051836            {
1052837               if ((x + (xs << 3) < SNES_SCR_WIDTH + 8))
1053838               {
1054                  snes_draw_tile_object(charaddr + name_sel + tile + table_obj_offset[ys][xs] + line, x + (xs << 3), priority, hflip, pal, blend);
839                  if (widemode)
840                     snes_draw_tile_object(screen, charaddr + name_sel + tile + table_obj_offset[ys][xs] + line, x + (xs << 3), priority, hflip, pal, blend, 1);
841                  else
842                     snes_draw_tile_object(screen, charaddr + name_sel + tile + table_obj_offset[ys][xs] + line, x + (xs << 3), priority, hflip, pal, blend, 0);
1055843               }
1056844               time_over++;   /* Increase time_over. Should we stop drawing if exceeded 34 tiles? */
1057845            }
r7500r7501
1082870 *
1083871 * Update Mode X line.
1084872 *********************************************/
1085
1086static void snes_update_mode_0( UINT16 curline )
873static void snes_update_mode_0( UINT8 screen, UINT16 curline )
1087874{
1088#ifdef SNES_LAYER_DEBUG
1089   if (debug_options.mode_disabled[0])
1090      return;
1091#endif /* SNES_LAYER_DEBUG */
875   UINT8 *bg_enabled;
876   bg_enabled = (screen == SNES_MAINSCREEN) ? snes_ppu.main_bg_enabled : snes_ppu.sub_bg_enabled;
1092877
1093   snes_update_line(SNES_COLOR_DEPTH_2BPP, 0, 0, 3, SNES_BG4, curline, SNES_OPT_NONE, 0);
1094   snes_update_line(SNES_COLOR_DEPTH_2BPP, 0, 1, 4, SNES_BG3, curline, SNES_OPT_NONE, 0);
1095   snes_update_line(SNES_COLOR_DEPTH_2BPP, 0, 6, 9, SNES_BG2, curline, SNES_OPT_NONE, 0);
1096   snes_update_line(SNES_COLOR_DEPTH_2BPP, 0, 7, 10, SNES_BG1, curline, SNES_OPT_NONE, 0);
1097   snes_update_objects(0, curline);
878   if (bg_enabled[4]) snes_update_objects(screen, 0, curline);
879   if (bg_enabled[0]) snes_update_line(screen, SNES_COLOR_DEPTH_2BPP, 0, 7, 10, SNES_BG1, curline, 0, 0);
880   if (bg_enabled[1]) snes_update_line(screen, SNES_COLOR_DEPTH_2BPP, 0, 6, 9, SNES_BG2, curline, 0, 0);
881   if (bg_enabled[2]) snes_update_line(screen, SNES_COLOR_DEPTH_2BPP, 0, 1, 4, SNES_BG3, curline, 0, 0);
882   if (bg_enabled[3]) snes_update_line(screen, SNES_COLOR_DEPTH_2BPP, 0, 0, 3, SNES_BG4, curline, 0, 0);
1098883}
1099884
1100static void snes_update_mode_1( UINT16 curline )
885static void snes_update_mode_1( UINT8 screen, UINT16 curline )
1101886{
1102#ifdef SNES_LAYER_DEBUG
1103   if (debug_options.mode_disabled[1])
1104      return;
1105#endif /* SNES_LAYER_DEBUG */
887   UINT8 *bg_enabled;
888   bg_enabled = (screen == SNES_MAINSCREEN) ? snes_ppu.main_bg_enabled : snes_ppu.sub_bg_enabled;
1106889
1107890   if (!snes_ppu.bg3_priority_bit)
1108891   {
1109      snes_update_line(SNES_COLOR_DEPTH_2BPP, 0, 0, 2, SNES_BG3, curline, SNES_OPT_NONE, 0);
1110      snes_update_line(SNES_COLOR_DEPTH_4BPP, 0, 4, 7, SNES_BG2, curline, SNES_OPT_NONE, 0);
1111      snes_update_line(SNES_COLOR_DEPTH_4BPP, 0, 5, 8, SNES_BG1, curline, SNES_OPT_NONE, 0);
1112      snes_update_objects(1, curline);
892      if (bg_enabled[4]) snes_update_objects(screen, 1, curline);
893      if (bg_enabled[0]) snes_update_line(screen, SNES_COLOR_DEPTH_4BPP, 0, 5, 8, SNES_BG1, curline, 0, 0);
894      if (bg_enabled[1]) snes_update_line(screen, SNES_COLOR_DEPTH_4BPP, 0, 4, 7, SNES_BG2, curline, 0, 0);
895      if (bg_enabled[2]) snes_update_line(screen, SNES_COLOR_DEPTH_2BPP, 0, 0, 2, SNES_BG3, curline, 0, 0);
1113896   }
1114897   else
1115898   {
1116      snes_update_line(SNES_COLOR_DEPTH_2BPP, 0, 0, 9, SNES_BG3, curline, SNES_OPT_NONE, 0);
1117      snes_update_line(SNES_COLOR_DEPTH_4BPP, 0, 3, 6, SNES_BG2, curline, SNES_OPT_NONE, 0);
1118      snes_update_line(SNES_COLOR_DEPTH_4BPP, 0, 4, 7, SNES_BG1, curline, SNES_OPT_NONE, 0);
1119      snes_update_objects(9, curline);
899      if (bg_enabled[4]) snes_update_objects(screen, 9, curline);
900      if (bg_enabled[0]) snes_update_line(screen, SNES_COLOR_DEPTH_4BPP, 0, 4, 7, SNES_BG1, curline, 0, 0);
901      if (bg_enabled[1]) snes_update_line(screen, SNES_COLOR_DEPTH_4BPP, 0, 3, 6, SNES_BG2, curline, 0, 0);
902      if (bg_enabled[2]) snes_update_line(screen, SNES_COLOR_DEPTH_2BPP, 0, 0, 9, SNES_BG3, curline, 0, 0);
1120903   }
1121904}
1122905
1123static void snes_update_mode_2( UINT16 curline )
906static void snes_update_mode_2( UINT8 screen, UINT16 curline )
1124907{
1125#ifdef SNES_LAYER_DEBUG
1126   if (debug_options.mode_disabled[2])
1127      return;
1128#endif /* SNES_LAYER_DEBUG */
908   UINT8 *bg_enabled;
909   bg_enabled = (screen == SNES_MAINSCREEN) ? snes_ppu.main_bg_enabled : snes_ppu.sub_bg_enabled;
1129910
1130   snes_update_line(SNES_COLOR_DEPTH_4BPP, 0, 0, 4, SNES_BG2, curline, SNES_OPT_MODE2, 0);
1131   snes_update_line(SNES_COLOR_DEPTH_4BPP, 0, 2, 6, SNES_BG1, curline, SNES_OPT_MODE2, 0);
1132   snes_update_objects(2, curline);
911   if (bg_enabled[4]) snes_update_objects(screen, 2, curline);
912   if (bg_enabled[0]) snes_update_line(screen, SNES_COLOR_DEPTH_4BPP, 0, 2, 6, SNES_BG1, curline, 1, 0);
913   if (bg_enabled[1]) snes_update_line(screen, SNES_COLOR_DEPTH_4BPP, 0, 0, 4, SNES_BG2, curline, 1, 0);
1133914}
1134915
1135static void snes_update_mode_3( UINT16 curline )
916static void snes_update_mode_3( UINT8 screen, UINT16 curline )
1136917{
1137#ifdef SNES_LAYER_DEBUG
1138   if (debug_options.mode_disabled[3])
1139      return;
1140#endif /* SNES_LAYER_DEBUG */
918   UINT8 *bg_enabled;
919   bg_enabled = (screen == SNES_MAINSCREEN) ? snes_ppu.main_bg_enabled : snes_ppu.sub_bg_enabled;
1141920
1142   snes_update_line(SNES_COLOR_DEPTH_4BPP, 0, 0, 4, SNES_BG2, curline, SNES_OPT_NONE, 0);
1143   snes_update_line(SNES_COLOR_DEPTH_8BPP, 0, 2, 6, SNES_BG1, curline, SNES_OPT_NONE, snes_ppu.direct_color);
1144   snes_update_objects(3, curline);
921   if (bg_enabled[4]) snes_update_objects(screen, 3, curline);
922   if (bg_enabled[0]) snes_update_line(screen, SNES_COLOR_DEPTH_8BPP, 0, 2, 6, SNES_BG1, curline, 0, snes_ppu.direct_color);
923   if (bg_enabled[1]) snes_update_line(screen, SNES_COLOR_DEPTH_4BPP, 0, 0, 4, SNES_BG2, curline, 0, 0);
1145924}
1146925
1147static void snes_update_mode_4( UINT16 curline )
926static void snes_update_mode_4( UINT8 screen, UINT16 curline )
1148927{
1149#ifdef SNES_LAYER_DEBUG
1150   if (debug_options.mode_disabled[4])
1151      return;
1152#endif /* SNES_LAYER_DEBUG */
928   UINT8 *bg_enabled;
929   bg_enabled = (screen == SNES_MAINSCREEN) ? snes_ppu.main_bg_enabled : snes_ppu.sub_bg_enabled;
1153930
1154   snes_update_line(SNES_COLOR_DEPTH_2BPP, 0, 0, 4, SNES_BG2, curline, SNES_OPT_MODE4, 0);
1155   snes_update_line(SNES_COLOR_DEPTH_8BPP, 0, 2, 6, SNES_BG1, curline, SNES_OPT_MODE4, snes_ppu.direct_color);
1156   snes_update_objects(4, curline);
931   if (bg_enabled[4]) snes_update_objects(screen, 4, curline);
932   if (bg_enabled[0]) snes_update_line(screen, SNES_COLOR_DEPTH_8BPP, 0, 2, 6, SNES_BG1, curline, 0, snes_ppu.direct_color);
933   if (bg_enabled[1]) snes_update_line(screen, SNES_COLOR_DEPTH_2BPP, 0, 0, 4, SNES_BG2, curline, 0, 0);
1157934}
1158935
1159static void snes_update_mode_5( UINT16 curline )
936static void snes_update_mode_5( UINT8 screen, UINT16 curline )
1160937{
1161#ifdef SNES_LAYER_DEBUG
1162   if (debug_options.mode_disabled[5])
1163      return;
1164#endif /* SNES_LAYER_DEBUG */
938   UINT8 *bg_enabled;
939   bg_enabled = (screen == SNES_MAINSCREEN) ? snes_ppu.main_bg_enabled : snes_ppu.sub_bg_enabled;
1165940
1166   snes_update_line(SNES_COLOR_DEPTH_4BPP, 1, 2, 6, SNES_BG1, curline, SNES_OPT_NONE, 0);
1167   snes_update_line(SNES_COLOR_DEPTH_2BPP, 1, 0, 4, SNES_BG2, curline, SNES_OPT_NONE, 0);
1168   snes_update_objects(5, curline);
941   if (bg_enabled[4]) snes_update_objects(screen, 5, curline);
942   if (bg_enabled[0]) snes_update_line(screen, SNES_COLOR_DEPTH_4BPP, 1, 2, 6, SNES_BG1, curline, 0, 0);
943   if (bg_enabled[1]) snes_update_line(screen, SNES_COLOR_DEPTH_2BPP, 1, 0, 4, SNES_BG2, curline, 0, 0);
1169944}
1170945
1171static void snes_update_mode_6( UINT16 curline )
946static void snes_update_mode_6( UINT8 screen, UINT16 curline )
1172947{
1173#ifdef SNES_LAYER_DEBUG
1174   if (debug_options.mode_disabled[6])
1175      return;
1176#endif /* SNES_LAYER_DEBUG */
948   UINT8 *bg_enabled;
949   bg_enabled = (screen == SNES_MAINSCREEN) ? snes_ppu.main_bg_enabled : snes_ppu.sub_bg_enabled;
1177950
1178   snes_update_line(SNES_COLOR_DEPTH_4BPP, 1, 1, 4, SNES_BG1, curline, SNES_OPT_MODE6, 0);
1179   snes_update_objects(6, curline);
951   if (bg_enabled[4]) snes_update_objects(screen, 6, curline);
952   if (bg_enabled[0]) snes_update_line(screen, SNES_COLOR_DEPTH_4BPP, 1, 1, 4, SNES_BG1, curline, 1, 0);
1180953}
1181954
1182static void snes_update_mode_7( UINT16 curline )
955static void snes_update_mode_7( UINT8 screen, UINT16 curline )
1183956{
1184#ifdef SNES_LAYER_DEBUG
1185   if (debug_options.mode_disabled[7])
1186      return;
1187#endif /* SNES_LAYER_DEBUG */
957   UINT8 *bg_enabled;
958   bg_enabled = (screen == SNES_MAINSCREEN) ? snes_ppu.main_bg_enabled : snes_ppu.sub_bg_enabled;
1188959
1189960   if (!snes_ppu.mode7.extbg)
1190961   {
1191      snes_update_line_mode7(1, 1, SNES_BG1, curline);
1192      snes_update_objects(7, curline);
962      if (bg_enabled[4]) snes_update_objects(screen, 7, curline);
963      if (bg_enabled[0]) snes_update_line_mode7(screen, 1, 1, SNES_BG1, curline);
1193964   }
1194965   else
1195966   {
1196      snes_update_line_mode7(0, 4, SNES_BG2, curline);
1197      snes_update_line_mode7(2, 2, SNES_BG1, curline);
1198      snes_update_objects(8, curline);
967      if (bg_enabled[4]) snes_update_objects(screen, 8, curline);
968      if (bg_enabled[0]) snes_update_line_mode7(screen, 2, 2, SNES_BG1, curline);
969      if (bg_enabled[1]) snes_update_line_mode7(screen, 0, 4, SNES_BG2, curline);
1199970   }
1200971}
1201972
1202973/*********************************************
1203 * snes_draw_screens()
974 * snes_draw_screen()
1204975 *
1205976 * Draw the whole screen (Mode 0 -> 7).
1206977 *********************************************/
1207
1208static void snes_draw_screens( UINT16 curline )
978static void snes_draw_screen( UINT8 screen, UINT16 curline )
1209979{
1210980   switch (snes_ppu.mode)
1211981   {
1212      case 0: snes_update_mode_0(curline); break;      /* Mode 0 */
1213      case 1: snes_update_mode_1(curline); break;      /* Mode 1 */
1214      case 2: snes_update_mode_2(curline); break;      /* Mode 2 - Supports offset per tile */
1215      case 3: snes_update_mode_3(curline); break;      /* Mode 3 - Supports direct colour */
1216      case 4: snes_update_mode_4(curline); break;      /* Mode 4 - Supports offset per tile and direct colour */
1217      case 5: snes_update_mode_5(curline); break;      /* Mode 5 - Supports hires */
1218      case 6: snes_update_mode_6(curline); break;      /* Mode 6 - Supports offset per tile and hires */
1219      case 7: snes_update_mode_7(curline); break;      /* Mode 7 - Supports direct colour */
982      case 0: snes_update_mode_0(screen, curline); break;      /* Mode 0 */
983      case 1: snes_update_mode_1(screen, curline); break;      /* Mode 1 */
984      case 2: snes_update_mode_2(screen, curline); break;      /* Mode 2 - Supports offset per tile */
985      case 3: snes_update_mode_3(screen, curline); break;      /* Mode 3 - Supports direct colour */
986      case 4: snes_update_mode_4(screen, curline); break;      /* Mode 4 - Supports offset per tile and direct colour */
987      case 5: snes_update_mode_5(screen, curline); break;      /* Mode 5 - Supports hires */
988      case 6: snes_update_mode_6(screen, curline); break;      /* Mode 6 - Supports offset per tile and hires */
989      case 7: snes_update_mode_7(screen, curline); break;      /* Mode 7 - Supports direct colour */
1220990   }
1221991}
1222992
r7500r7501
12321002 * XOR:  ...###..###...     ###...##...###
12331003 * XNOR: ###...##...###     ...###..###...
12341004 *********************************************/
1235
1236static void snes_update_windowmasks( void )
1005static void snes_update_windowmasks(void)
12371006{
12381007   UINT16 ii, jj;
12391008   INT8 w1, w2;
r7500r7501
13041073 *
13051074 * Update the offsets with the latest changes.
13061075 *********************************************/
1307
1308static void snes_update_offsets( void )
1076static void snes_update_offsets(void)
13091077{
13101078   int ii;
13111079   for (ii = 0; ii < 4; ii++)
r7500r7501
13191087 *
13201088 * Redraw the current line.
13211089 *********************************************/
1322
13231090static void snes_refresh_scanline( running_machine *machine, bitmap_t *bitmap, UINT16 curline )
13241091{
13251092   UINT16 ii;
r7500r7501
13661133         scanlines[SNES_MAINSCREEN].buffer[ii] = snes_cgram[0];
13671134      }
13681135
1369      /* Draw screens */
1370      snes_draw_screens(curline);
1136      /* Draw SNES_SUBSCREEN */
1137      snes_draw_screen(SNES_SUBSCREEN, curline);
13711138
1139      /* Draw SNES_MAINSCREEN */
1140      snes_draw_screen(SNES_MAINSCREEN, curline);
1141
13721142#ifdef SNES_LAYER_DEBUG
13731143      if (snes_dbg_video(machine, bitmap, curline))
13741144      {
r7500r7501
13861156      /* Phew! Draw the line to screen */
13871157      fade = snes_ppu.screen_brightness;
13881158
1389      for (x = 0; x < SNES_SCR_WIDTH * 2; x++)
1159      for (x = 0; x < SNES_SCR_WIDTH * 2; x += 2)
13901160      {
1391         int r, g, b, hires;
1392         UINT16 temp_col;
1393         hires = (snes_ppu.mode != 5 && snes_ppu.mode != 6) ? 0 : 1;
1394         c = scanline->buffer[x];
1395         temp_col = scanline->buffer[x];
1161         if (snes_ppu.mode != 5 && snes_ppu.mode != 6)
1162         {
1163            int r, g, b;
1164            c = scanline->buffer[x];
13961165
1397         /* perform color math if the layer wants it (except if it's an object > 192) */
1398         if (!scanlines[SNES_MAINSCREEN].blend_exception[x] && snes_ppu.layer[scanlines[SNES_MAINSCREEN].layer[x]].color_math)
1399            snes_draw_blend(x, &c, snes_ppu.sub_color_mask, snes_ppu.main_color_mask);
1166            /* perform color math if the layer wants it (except if it's an object > 192) */
1167            if (!scanlines[SNES_MAINSCREEN].blend_exception[x] && snes_ppu.layer[scanlines[SNES_MAINSCREEN].layer[x]].color_math)
1168               snes_draw_blend_lores(x, &c, snes_ppu.sub_color_mask, snes_ppu.main_color_mask);
14001169
1401         r = ((c & 0x1f) * fade) >> 4;
1402         g = (((c & 0x3e0) >> 5) * fade) >> 4;
1403         b = (((c & 0x7c00) >> 10) * fade) >> 4;
1170            r = ((c & 0x1f) * fade) >> 4;
1171            g = (((c & 0x3e0) >> 5) * fade) >> 4;
1172            b = (((c & 0x7c00) >> 10) * fade) >> 4;
14041173
1405         *BITMAP_ADDR32(bitmap, curline, x * 2 + 0) = MAKE_RGB(pal5bit(r), pal5bit(g), pal5bit(b));
1406
1407         if (!hires)
1174            *BITMAP_ADDR32(bitmap, curline, x * 2 + 0) = MAKE_RGB(pal5bit(r), pal5bit(g), pal5bit(b));
14081175            *BITMAP_ADDR32(bitmap, curline, x * 2 + 1) = MAKE_RGB(pal5bit(r), pal5bit(g), pal5bit(b));
1176
1177            c = scanline->buffer[x + 1];
1178
1179            /* perform color math if the layer wants it (except if it's an object > 192) */
1180            if (!scanlines[SNES_MAINSCREEN].blend_exception[x + 1] && snes_ppu.layer[scanlines[SNES_MAINSCREEN].layer[x + 1]].color_math)
1181               snes_draw_blend_lores(x + 1, &c, snes_ppu.sub_color_mask, snes_ppu.main_color_mask);
1182
1183            r = ((c & 0x1f) * fade) >> 4;
1184            g = (((c & 0x3e0) >> 5) * fade) >> 4;
1185            b = (((c & 0x7c00) >> 10) * fade) >> 4;
1186
1187            *BITMAP_ADDR32(bitmap, curline, (x + 1) * 2 + 0) = MAKE_RGB(pal5bit(r), pal5bit(g), pal5bit(b));
1188            *BITMAP_ADDR32(bitmap, curline, (x + 1) * 2 + 1) = MAKE_RGB(pal5bit(r), pal5bit(g), pal5bit(b));
1189
1190         }
14091191         else
14101192         {
1193            int r, g, b;
1194            UINT16 temp_col;
1195            c = scanline->buffer[x];
1196            temp_col = scanline->buffer[x];
1197
1198            /* perform color math if the layer wants it (except if it's an object > 192) */
1199            if (!scanlines[SNES_MAINSCREEN].blend_exception[x] && snes_ppu.layer[scanlines[SNES_MAINSCREEN].layer[x]].color_math)
1200               snes_draw_blend_hires(x, &c, snes_ppu.sub_color_mask, snes_ppu.main_color_mask);
1201
1202            r = ((c & 0x1f) * fade) >> 4;
1203            g = (((c & 0x3e0) >> 5) * fade) >> 4;
1204            b = (((c & 0x7c00) >> 10) * fade) >> 4;
1205
1206            *BITMAP_ADDR32(bitmap, curline, x) = MAKE_RGB(pal5bit(r), pal5bit(g), pal5bit(b));
1207
14111208            c = scanlines[SNES_SUBSCREEN].buffer[x];
14121209            scanlines[SNES_SUBSCREEN].buffer[x] = temp_col;
14131210
1414            if (!scanlines[SNES_SUBSCREEN].blend_exception[x] && snes_ppu.layer[scanlines[SNES_MAINSCREEN].layer[x]].color_math)
1415               snes_draw_blend(x, &c, snes_ppu.sub_color_mask, snes_ppu.main_color_mask);
1211            /* perform color math only if it's been done on the previous pixel */
1212            if (!scanlines[SNES_MAINSCREEN].blend_exception[x] && snes_ppu.layer[scanlines[SNES_MAINSCREEN].layer[x]].color_math)
1213               snes_draw_blend_hires(x, &c, snes_ppu.sub_color_mask, snes_ppu.main_color_mask);
14161214
14171215            r = ((c & 0x1f) * fade) >> 4;
14181216            g = (((c & 0x3e0) >> 5) * fade) >> 4;
14191217            b = (((c & 0x7c00) >> 10) * fade) >> 4;
14201218
1421            *BITMAP_ADDR32(bitmap, curline, x * 2 + 1) = MAKE_RGB(pal5bit(r), pal5bit(g), pal5bit(b));
1219            *BITMAP_ADDR32(bitmap, curline, x + 1) = MAKE_RGB(pal5bit(r), pal5bit(g), pal5bit(b));
14221220         }
14231221      }
14241222   }
src/mame/video/mcatadv.c
r7500r7501
1414#include "profiler.h"
1515#include "includes/mcatadv.h"
1616
17static tilemap_t *mcatadv_tilemap1,  *mcatadv_tilemap2;
18static UINT16 *spriteram_old, *vidregs_old;
19static int palette_bank1, palette_bank2;
20
21
2217static TILE_GET_INFO( get_mcatadv_tile_info1 )
2318{
24   int tileno, colour, pri;
19   mcatadv_state *state = (mcatadv_state *)machine->driver_data;
20   int tileno = state->videoram1[tile_index * 2 + 1];
21   int colour = (state->videoram1[tile_index * 2] & 0x3f00) >> 8;
22   int pri = (state->videoram1[tile_index * 2] & 0xc000) >> 14;
2523
26   tileno = mcatadv_videoram1[tile_index*2+1];
27   colour = (mcatadv_videoram1[tile_index*2] & 0x3f00)>>8;
28   pri = (mcatadv_videoram1[tile_index*2] & 0xc000)>>14;
29
30   SET_TILE_INFO(0,tileno,colour + palette_bank1*0x40,0);
24   SET_TILE_INFO(0,tileno,colour + state->palette_bank1 * 0x40, 0);
3125   tileinfo->category = pri;
3226}
3327
3428WRITE16_HANDLER( mcatadv_videoram1_w )
3529{
36   COMBINE_DATA(&mcatadv_videoram1[offset]);
37   tilemap_mark_tile_dirty(mcatadv_tilemap1,offset/2);
30   mcatadv_state *state = (mcatadv_state *)space->machine->driver_data;
31
32   COMBINE_DATA(&state->videoram1[offset]);
33   tilemap_mark_tile_dirty(state->tilemap1, offset / 2);
3834}
3935
4036static TILE_GET_INFO( get_mcatadv_tile_info2 )
4137{
42   int tileno, colour, pri;
38   mcatadv_state *state = (mcatadv_state *)machine->driver_data;
39   int tileno = state->videoram2[tile_index * 2 + 1];
40   int colour = (state->videoram2[tile_index * 2] & 0x3f00) >> 8;
41   int pri = (state->videoram2[tile_index * 2] & 0xc000) >> 14;
4342
44   tileno = mcatadv_videoram2[tile_index*2+1];
45   colour = (mcatadv_videoram2[tile_index*2] & 0x3f00)>>8;
46   pri = (mcatadv_videoram2[tile_index*2] & 0xc000)>>14;
47
48   SET_TILE_INFO(1,tileno,colour + palette_bank2*0x40,0);
43   SET_TILE_INFO(1, tileno, colour + state->palette_bank2 * 0x40, 0);
4944   tileinfo->category = pri;
5045}
5146
5247WRITE16_HANDLER( mcatadv_videoram2_w )
5348{
54   COMBINE_DATA(&mcatadv_videoram2[offset]);
55   tilemap_mark_tile_dirty(mcatadv_tilemap2,offset/2);
49   mcatadv_state *state = (mcatadv_state *)space->machine->driver_data;
50
51   COMBINE_DATA(&state->videoram2[offset]);
52   tilemap_mark_tile_dirty(state->tilemap2, offset / 2);
5653}
5754
5855
5956static void draw_sprites( running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect )
6057{
61   UINT16 *source = spriteram_old;
62   UINT16 *finish = source + (machine->generic.spriteram_size/2)/2;
63   int global_x = mcatadv_vidregs[0]-0x184;
64   int global_y = mcatadv_vidregs[1]-0x1f1;
58   mcatadv_state *state = (mcatadv_state *)machine->driver_data;
59   UINT16 *source = state->spriteram_old;
60   UINT16 *finish = source + (state->spriteram_size / 2) / 2;
61   int global_x = state->vidregs[0] - 0x184;
62   int global_y = state->vidregs[1] - 0x1f1;
6563
6664   UINT16 *destline;
6765   UINT8 *priline;
68   UINT8 *sprdata = memory_region ( machine, "gfx1" );
66   UINT8 *sprdata = memory_region(machine, "gfx1");
6967
7068   int xstart, xend, xinc;
7169   int ystart, yend, yinc;
7270
73   if( vidregs_old[2] == 0x0001 ) /* Double Buffered */
71   if (state->vidregs_old[2] == 0x0001) /* Double Buffered */
7472   {
75      source += (machine->generic.spriteram_size/2)/2;
76      finish += (machine->generic.spriteram_size/2)/2;
73      source += (state->spriteram_size / 2) / 2;
74      finish += (state->spriteram_size / 2) / 2;
7775   }
78   else if( vidregs_old[2] ) /* I suppose it's possible that there is 4 banks, haven't seen it used though */
76   else if (state->vidregs_old[2]) /* I suppose it's possible that there is 4 banks, haven't seen it used though */
7977   {
8078      logerror("Spritebank != 0/1\n");
8179   }
8280
83   while ( source<finish )
81   while (source < finish)
8482   {
85      int pen = (source[0]&0x3f00)>>8;
86      int tileno = source[1]&0xffff;
87      int pri = (source[0]&0xc000)>>14;
88      int x = source[2]&0x3ff;
89      int y = source[3]&0x3ff;
83      int pen = (source[0] & 0x3f00) >> 8;
84      int tileno = source[1] & 0xffff;
85      int pri = (source[0] & 0xc000) >> 14;
86      int x = source[2] & 0x3ff;
87      int y = source[3] & 0x3ff;
9088      int flipy = source[0] & 0x0040;
9189      int flipx = source[0] & 0x0080;
9290
93      int height = ((source[3]&0xf000)>>12)*16;
94      int width = ((source[2]&0xf000)>>12)*16;
91      int height = ((source[3] & 0xf000) >> 12) * 16;
92      int width = ((source[2] & 0xf000) >> 12) * 16;
9593      int offset = tileno * 256;
9694
9795      int drawxpos, drawypos;
98      int xcnt,ycnt;
96      int xcnt, ycnt;
9997      int pix;
10098
10199      if (x & 0x200) x-=0x400;
102100      if (y & 0x200) y-=0x400;
103101
104102#if 0 // For Flipscreen/Cocktail
105      if(mcatadv_vidregs[0]&0x8000)
103      if(state->vidregs[0] & 0x8000)
106104      {
107105         flipx = !flipx;
108106      }
109      if(mcatadv_vidregs[1]&0x8000)
107      if(state->vidregs[1] & 0x8000)
110108      {
111109         flipy = !flipy;
112110      }
r7500r7501
119117         if(!flipy) { ystart = 0;        yend = height; yinc = 1; }
120118         else       { ystart = height-1; yend = -1;     yinc = -1; }
121119
122         for (ycnt = ystart; ycnt != yend; ycnt += yinc) {
123            drawypos = y+ycnt-global_y;
120         for (ycnt = ystart; ycnt != yend; ycnt += yinc)
121         {
122            drawypos = y + ycnt - global_y;
124123
125            if ((drawypos >= cliprect->min_y) && (drawypos <= cliprect->max_y)) {
124            if ((drawypos >= cliprect->min_y) && (drawypos <= cliprect->max_y))
125            {
126126               destline = BITMAP_ADDR16(bitmap, drawypos, 0);
127127               priline = BITMAP_ADDR8(machine->priority_bitmap, drawypos, 0);
128128
129               for (xcnt = xstart; xcnt != xend; xcnt += xinc) {
130                  drawxpos = x+xcnt-global_x;
129               for (xcnt = xstart; xcnt != xend; xcnt += xinc)
130               {
131                  drawxpos = x + xcnt - global_x;
131132
132                  if((priline[drawxpos] < pri)) {
133                     if (offset >= 0x500000*2) offset = 0;
134                     pix = sprdata[offset/2];
133                  if((priline[drawxpos] < pri))
134                  {
135                     if (offset >= 0x500000 * 2)
136                        offset = 0;
137                     pix = sprdata[offset / 2];
135138
136                     if (offset & 1)  pix = pix >> 4;
139                     if (offset & 1)
140                        pix = pix >> 4;
137141                     pix &= 0x0f;
138142
139143                     if ((drawxpos >= cliprect->min_x) && (drawxpos <= cliprect->max_x) && pix)
r7500r7501
142146                  offset++;
143147               }
144148            }
145            else  {
149            else
150            {
146151               offset += width;
147152            }
148153         }
149154      }
150      source+=4;
155      source += 4;
151156   }
152157}
153158
154static void mcatadv_draw_tilemap_part(UINT16* current_scroll, UINT16* current_videoram1, int i, tilemap_t* current_tilemap, bitmap_t *bitmap, const rectangle *cliprect)
159static void mcatadv_draw_tilemap_part( UINT16* current_scroll, UINT16* current_videoram1, int i, tilemap_t* current_tilemap, bitmap_t *bitmap, const rectangle *cliprect )
155160{
156161   int flip;
157162   UINT32 drawline;
r7500r7501
160165   clip.min_x = cliprect->min_x;
161166   clip.max_x = cliprect->max_x;
162167
163   for(drawline = cliprect->min_y; drawline <= cliprect->max_y;drawline++)
168   for (drawline = cliprect->min_y; drawline <= cliprect->max_y; drawline++)
164169   {
165170      int scrollx, scrolly;
166171
167172      clip.min_y = drawline;
168173      clip.max_y = drawline;
169174
170      scrollx = (current_scroll[0]&0x1ff)-0x194;
171      scrolly = (current_scroll[1]&0x1ff)-0x1df;
175      scrollx = (current_scroll[0] & 0x1ff) - 0x194;
176      scrolly = (current_scroll[1] & 0x1ff) - 0x1df;
172177
173      if ((current_scroll[1]&0x4000)==0x4000)
178      if ((current_scroll[1] & 0x4000) == 0x4000)
174179      {
175         int rowselect;
176         rowselect = current_videoram1[0x1000/2 + (((drawline+scrolly)&0x1ff) * 2) + 1];
180         int rowselect = current_videoram1[0x1000 / 2 + (((drawline + scrolly) & 0x1ff) * 2) + 1];
177181         scrolly = rowselect - drawline;
178182      }
179183
180      if ((current_scroll[0]&0x4000)==0x4000)
184      if ((current_scroll[0] & 0x4000) == 0x4000)
181185      {
182         int rowscroll;
183         rowscroll = current_videoram1[0x1000/2 + (((drawline+scrolly)&0x1ff) * 2) + 0];
186         int rowscroll = current_videoram1[0x1000 / 2 + (((drawline + scrolly) & 0x1ff) * 2) + 0];
184187         scrollx += rowscroll;
185188      }
186189
187190      /* Global Flip */
188      if(!(current_scroll[0]&0x8000)) scrollx -= 0x19;
189      if(!(current_scroll[1]&0x8000)) scrolly -= 0x141;
190      flip = ((current_scroll[0]&0x8000)?0:TILEMAP_FLIPX) | ((current_scroll[1]&0x8000)?0:TILEMAP_FLIPY);
191      if (!(current_scroll[0] & 0x8000)) scrollx -= 0x19;
192      if (!(current_scroll[1] & 0x8000)) scrolly -= 0x141;
193      flip = ((current_scroll[0] & 0x8000) ? 0 : TILEMAP_FLIPX) | ((current_scroll[1] & 0x8000) ? 0 : TILEMAP_FLIPY);
191194
192195      tilemap_set_scrollx(current_tilemap, 0, scrollx);
193196      tilemap_set_scrolly(current_tilemap, 0, scrolly);
r7500r7501
199202
200203VIDEO_UPDATE( mcatadv )
201204{
205   mcatadv_state *state = (mcatadv_state *)screen->machine->driver_data;
202206   int i;
203207
204208   bitmap_fill(bitmap, cliprect, get_black_pen(screen->machine));
205209   bitmap_fill(screen->machine->priority_bitmap, cliprect, 0);
206210
207   if(mcatadv_scroll[2] != palette_bank1) {
208      palette_bank1 = mcatadv_scroll[2];
209      tilemap_mark_all_tiles_dirty(mcatadv_tilemap1);
211   if (state->scroll1[2] != state->palette_bank1)
212   {
213      state->palette_bank1 = state->scroll1[2];
214      tilemap_mark_all_tiles_dirty(state->tilemap1);
210215   }
211216
212   if(mcatadv_scroll2[2] != palette_bank2) {
213      palette_bank2 = mcatadv_scroll2[2];
214      tilemap_mark_all_tiles_dirty(mcatadv_tilemap2);
217   if (state->scroll2[2] != state->palette_bank2)
218   {
219      state->palette_bank2 = state->scroll2[2];
220      tilemap_mark_all_tiles_dirty(state->tilemap2);
215221   }
216222
217223/*
218224    popmessage("%02x %02x %02x %02x",
219        (mcatadv_scroll[0]&0x4000)>>8,
220        (mcatadv_scroll[1]&0x4000)>>8,
221        (mcatadv_scroll2[0]&0x4000)>>8,
222        (mcatadv_scroll2[1]&0x4000)>>8);
225        (mcatadv_scroll1[0]  & 0x4000) >> 8,
226        (mcatadv_scroll1[1]  & 0x4000) >> 8,
227        (mcatadv_scroll2[0] & 0x4000) >> 8,
228        (mcatadv_scroll2[1] & 0x4000) >> 8);
223229*/
224230
225   for (i=0; i<=3; i++)
231   for (i = 0; i <= 3; i++)
226232   {
227233   #ifdef MAME_DEBUG
228234         if (!input_code_pressed(screen->machine, KEYCODE_Q))
229235   #endif
230         mcatadv_draw_tilemap_part(mcatadv_scroll,  mcatadv_videoram1, i, mcatadv_tilemap1, bitmap, cliprect);
236         mcatadv_draw_tilemap_part(state->scroll1,  state->videoram1, i, state->tilemap1, bitmap, cliprect);
231237
232238   #ifdef MAME_DEBUG
233239         if (!input_code_pressed(screen->machine, KEYCODE_W))
234240   #endif
235            mcatadv_draw_tilemap_part(mcatadv_scroll2, mcatadv_videoram2, i, mcatadv_tilemap2, bitmap, cliprect);
241            mcatadv_draw_tilemap_part(state->scroll2, state->videoram2, i, state->tilemap2, bitmap, cliprect);
236242   }
237243
238244   profiler_mark_start(PROFILER_USER1);
r7500r7501
246252
247253VIDEO_START( mcatadv )
248254{
249   mcatadv_tilemap1 = tilemap_create(machine, get_mcatadv_tile_info1,tilemap_scan_rows, 16, 16,32,32);
250   tilemap_set_transparent_pen(mcatadv_tilemap1,0);
255   mcatadv_state *state = (mcatadv_state *)machine->driver_data;
256   state->tilemap1 = tilemap_create(machine, get_mcatadv_tile_info1, tilemap_scan_rows, 16, 16, 32, 32);
257   tilemap_set_transparent_pen(state->tilemap1, 0);
251258
252   mcatadv_tilemap2 = tilemap_create(machine, get_mcatadv_tile_info2,tilemap_scan_rows, 16, 16,32,32);
253   tilemap_set_transparent_pen(mcatadv_tilemap2,0);
259   state->tilemap2 = tilemap_create(machine, get_mcatadv_tile_info2, tilemap_scan_rows, 16, 16, 32, 32);
260   tilemap_set_transparent_pen(state->tilemap2, 0);
254261
255   spriteram_old = auto_alloc_array_clear(machine, UINT16, machine->generic.spriteram_size/2);
256   vidregs_old = auto_alloc_array(machine, UINT16, (0xf+1)/2);
262   state->spriteram_old = auto_alloc_array_clear(machine, UINT16, state->spriteram_size / 2);
263   state->vidregs_old = auto_alloc_array(machine, UINT16, (0x0f + 1) / 2);
257264
258   palette_bank1 = 0;
259   palette_bank2 = 0;
265   state->palette_bank1 = 0;
266   state->palette_bank2 = 0;
267
268   state_save_register_global_pointer(machine, state->spriteram_old, state->spriteram_size / 2);
269   state_save_register_global_pointer(machine, state->vidregs_old, (0x0f + 1) / 2);
260270}
261271
262272VIDEO_EOF( mcatadv )
263273{
264   memcpy(spriteram_old,machine->generic.spriteram.u16,machine->generic.spriteram_size);
265   memcpy(vidregs_old,mcatadv_vidregs,0xf);
274   mcatadv_state *state = (mcatadv_state *)machine->driver_data;
275   memcpy(state->spriteram_old, state->spriteram, state->spriteram_size);
276   memcpy(state->vidregs_old, state->vidregs, 0xf);
266277}
src/mame/video/munchmo.c
r7500r7501
11#include "emu.h"
2#include "includes/munchmo.h"
23
34
4UINT8 *mnchmobl_vreg;
5UINT8 *mnchmobl_status_vram;
6UINT8 *mnchmobl_sprite_xpos;
7UINT8 *mnchmobl_sprite_attr;
8UINT8 *mnchmobl_sprite_tile;
9
10static int mnchmobl_palette_bank;
11static int flipscreen;
12
135PALETTE_INIT( mnchmobl )
146{
157   int i;
168
17   for (i = 0;i < machine->config->total_colors;i++)
9   for (i = 0; i < machine->config->total_colors; i++)
1810   {
19      int bit0,bit1,bit2,r,g,b;
11      int bit0, bit1, bit2, r, g, b;
2012
2113      /* red component */
22      bit0 = (color_prom[i] >> 0) & 0x01;
23      bit1 = (color_prom[i] >> 1) & 0x01;
24      bit2 = (color_prom[i] >> 2) & 0x01;
14      bit0 = BIT(color_prom[i], 0);
15      bit1 = BIT(color_prom[i], 1);
16      bit2 = BIT(color_prom[i], 2);
2517      r = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2;
2618      /* green component */
27      bit0 = (color_prom[i] >> 3) & 0x01;
28      bit1 = (color_prom[i] >> 4) & 0x01;
29      bit2 = (color_prom[i] >> 5) & 0x01;
19      bit0 = BIT(color_prom[i], 3);
20      bit1 = BIT(color_prom[i], 4);
21      bit2 = BIT(color_prom[i], 5);
3022      g = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2;
3123      /* blue component */
32      bit0 = (color_prom[i] >> 6) & 0x01;
33      bit1 = (color_prom[i] >> 7) & 0x01;
24      bit0 = BIT(color_prom[i], 6);
25      bit1 = BIT(color_prom[i], 7);
3426      b = 0x4f * bit0 + 0xa8 * bit1;
3527
36      palette_set_color(machine,i,MAKE_RGB(r,g,b));
28      palette_set_color(machine, i, MAKE_RGB(r, g, b));
3729   }
3830}
3931
4032WRITE8_HANDLER( mnchmobl_palette_bank_w )
4133{
42   mnchmobl_palette_bank = data&0x3;
34   munchmo_state *state = (munchmo_state *)space->machine->driver_data;
35   state->palette_bank = data & 0x3;
4336}
4437
4538WRITE8_HANDLER( mnchmobl_flipscreen_w )
4639{
47   flipscreen = data;
40   munchmo_state *state = (munchmo_state *)space->machine->driver_data;
41   state->flipscreen = data;
4842}
4943
5044
5145VIDEO_START( mnchmobl )
5246{
53   machine->generic.tmpbitmap = auto_bitmap_alloc(machine,512,512,video_screen_get_format(machine->primary_screen));
47   munchmo_state *state = (munchmo_state *)machine->driver_data;
48   state->tmpbitmap = auto_bitmap_alloc(machine, 512, 512, video_screen_get_format(machine->primary_screen));
5449}
5550
56static void draw_status(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect)
51static void draw_status( running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect )
5752{
53   munchmo_state *state = (munchmo_state *)machine->driver_data;
5854   const gfx_element *gfx = machine->gfx[0];
5955   int row;
6056
61   for( row=0; row<4; row++ )
57   for (row = 0; row < 4; row++)
6258   {
63      int sy,sx = (row&1)*8;
64      const UINT8 *source = mnchmobl_status_vram + (~row&1)*32;
65      if( row<=1 )
59      int sy, sx = (row & 1) * 8;
60      const UINT8 *source = state->status_vram + (~row & 1) * 32;
61      if (row <= 1)
6662      {
67         source+=2*32;
68         sx+=256+32+16;
63         source += 2 * 32;
64         sx += 256 + 32 + 16;
6965      }
70      for( sy=0; sy<256; sy+=8 )
66
67      for (sy = 0; sy < 256; sy += 8)
7168      {
7269         drawgfx_opaque( bitmap, cliprect,
7370            gfx,
r7500r7501
7976   }
8077}
8178
82static void draw_background(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect)
79static void draw_background( running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect )
8380{
8481/*
8582    ROM B1.2C contains 256 tilemaps defining 4x4 configurations of
8683    the tiles in ROM B2.2B
8784*/
85   munchmo_state *state = (munchmo_state *)machine->driver_data;
8886   UINT8 *rom = memory_region(machine, "gfx2");
8987   const gfx_element *gfx = machine->gfx[1];
9088   int offs;
9189
92   for( offs=0; offs<0x100; offs++ )
90   for (offs = 0; offs < 0x100; offs++)
9391   {
94      int sy = (offs%16)*32;
95      int sx = (offs/16)*32;
96      int tile_number = machine->generic.videoram.u8[offs];
97      int row,col;
92      int sy = (offs % 16) * 32;
93      int sx = (offs / 16) * 32;
94      int tile_number = state->videoram[offs];
95      int row, col;
9896
99      for( row=0; row<4; row++ )
97      for (row = 0; row < 4; row++)
10098      {
101         for( col=0; col<4; col++ )
99         for (col = 0; col < 4; col++)
102100         {
103            drawgfx_opaque( machine->generic.tmpbitmap,0, gfx,
104               rom[col+tile_number*4+row*0x400],
105               mnchmobl_palette_bank,
101            drawgfx_opaque(state->tmpbitmap, 0, gfx,
102               rom[col + tile_number * 4 + row * 0x400],
103               state->palette_bank,
106104               0,0, /* flip */
107               sx+col*8, sy+row*8 );
105               sx + col * 8, sy + row * 8 );
108106         }
109107      }
110108   }
111109
112110   {
113      int scrollx = -(mnchmobl_vreg[6]*2+(mnchmobl_vreg[7]>>7))-64-128-16;
111      int scrollx = -(state->vreg[6] *2 + (state->vreg[7] >> 7)) - 64 - 128 - 16;
114112      int scrolly = 0;
115113
116      copyscrollbitmap(bitmap,machine->generic.tmpbitmap, 1,&scrollx,1,&scrolly, cliprect);
114      copyscrollbitmap(bitmap, state->tmpbitmap, 1, &scrollx, 1, &scrolly, cliprect);
117115   }
118116}
119117
120static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect)
118static void draw_sprites( running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect )
121119{
122   int scroll = mnchmobl_vreg[6];
123   int flags = mnchmobl_vreg[7];                     /*   XB?????? */
120   munchmo_state *state = (munchmo_state *)machine->driver_data;
121   int scroll = state->vreg[6];
122   int flags = state->vreg[7];                     /*   XB?????? */
124123   int xadjust = - 128 - 16 - ((flags & 0x80) ? 1 : 0);
125124   int bank = (flags & 0x40) ? 1 : 0;
126125   const gfx_element *gfx = machine->gfx[2 + bank];
127   int color_base = mnchmobl_palette_bank * 4 + 3;
126   int color_base = state->palette_bank * 4 + 3;
128127   int i, j;
129   int firstsprite = mnchmobl_vreg[4] & 0x3f;
130   for( i = firstsprite; i < firstsprite + 0x40; i++ )
128   int firstsprite = state->vreg[4] & 0x3f;
129   for (i = firstsprite; i < firstsprite + 0x40; i++)
131130   {
132      for( j = 0; j < 8; j++ )
131      for (j = 0; j < 8; j++)
133132      {
134         int offs = (j << 6) | ( i & 0x3f );
135         int tile_number = mnchmobl_sprite_tile[offs];      /*   ETTTTTTT */
136         int attributes = mnchmobl_sprite_attr[offs];      /*   XYYYYYCC */
137         int sx = mnchmobl_sprite_xpos[offs];         /*   XXXXXXX? */
133         int offs = (j << 6) | (i & 0x3f);
134         int tile_number = state->sprite_tile[offs];      /*   ETTTTTTT */
135         int attributes = state->sprite_attr[offs];      /*   XYYYYYCC */
136         int sx = state->sprite_xpos[offs];            /*   XXXXXXX? */
138137         int sy = (offs >> 6) << 5;               /* Y YY------ */
139138         sy += (attributes >> 2) & 0x1f;
140139         if( attributes & 0x80 )
src/mame/video/mikie.c
r7500r7501
88
99#include "emu.h"
1010#include "video/resnet.h"
11#include "includes/mikie.h"
1112
12static int palettebank;
13
14UINT8 *mikie_videoram;
15UINT8 *mikie_colorram;
16static tilemap_t *bg_tilemap;
17
1813/***************************************************************************
1914
2015  Convert the color PROMs into a more useable format.
r7500r7501
3025  bit 0 -- 2.2kohm resistor  -- RED/GREEN/BLUE
3126
3227***************************************************************************/
28
3329PALETTE_INIT( mikie )
3430{
3531   static const int resistances[4] = { 2200, 1000, 470, 220 };
r7500r7501
7874   /* color_prom now points to the beginning of the lookup table,*/
7975   color_prom += 0x300;
8076
81   /* characters use colors 0x10-0x1f of each 0x20 color bank,
82       while sprites use colors 0-0x0f */
77   /* characters use colors 0x10-0x1f of each 0x20 color bank, while sprites use colors 0-0x0f */
8378   for (i = 0; i < 0x200; i++)
8479   {
8580      int j;
r7500r7501
9489
9590WRITE8_HANDLER( mikie_videoram_w )
9691{
97   mikie_videoram[offset] = data;
98   tilemap_mark_tile_dirty(bg_tilemap, offset);
92   mikie_state *state = (mikie_state *)space->machine->driver_data;
93
94   state->videoram[offset] = data;
95   tilemap_mark_tile_dirty(state->bg_tilemap, offset);
9996}
10097
10198WRITE8_HANDLER( mikie_colorram_w )
10299{
103   mikie_colorram[offset] = data;
104   tilemap_mark_tile_dirty(bg_tilemap, offset);
100   mikie_state *state = (mikie_state *)space->machine->driver_data;
101
102   state->colorram[offset] = data;
103   tilemap_mark_tile_dirty(state->bg_tilemap, offset);
105104}
106105
107106WRITE8_HANDLER( mikie_palettebank_w )
108107{
109   if (palettebank != (data & 0x07))
108   mikie_state *state = (mikie_state *)space->machine->driver_data;
109
110   if (state->palettebank != (data & 0x07))
110111   {
111      palettebank = data & 0x07;
112      state->palettebank = data & 0x07;
112113      tilemap_mark_all_tiles_dirty_all(space->machine);
113114   }
114115}
r7500r7501
124125
125126static TILE_GET_INFO( get_bg_tile_info )
126127{
127   int code = mikie_videoram[tile_index] + ((mikie_colorram[tile_index] & 0x20) << 3);
128   int color = (mikie_colorram[tile_index] & 0x0f) + 16 * palettebank;
129   int flags = ((mikie_colorram[tile_index] & 0x40) ? TILE_FLIPX : 0) | ((mikie_colorram[tile_index] & 0x80) ? TILE_FLIPY : 0);
130   if (mikie_colorram[tile_index] & 0x10)
128   mikie_state *state = (mikie_state *)machine->driver_data;
129   int code = state->videoram[tile_index] + ((state->colorram[tile_index] & 0x20) << 3);
130   int color = (state->colorram[tile_index] & 0x0f) + 16 * state->palettebank;
131   int flags = ((state->colorram[tile_index] & 0x40) ? TILE_FLIPX : 0) | ((state->colorram[tile_index] & 0x80) ? TILE_FLIPY : 0);
132   if (state->colorram[tile_index] & 0x10)
131133      tileinfo->category = 1;
132134   else
133135      tileinfo->category = 0;
136
134137   SET_TILE_INFO(0, code, color, flags);
135138
136139
r7500r7501
138141
139142VIDEO_START( mikie )
140143{
141   bg_tilemap = tilemap_create(machine, get_bg_tile_info, tilemap_scan_rows,
142       8, 8, 32, 32);
144   mikie_state *state = (mikie_state *)machine->driver_data;
145   state->bg_tilemap = tilemap_create(machine, get_bg_tile_info, tilemap_scan_rows, 8, 8, 32, 32);
143146}
144147
145148static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect)
146149{
147   UINT8 *spriteram = machine->generic.spriteram.u8;
150   mikie_state *state = (mikie_state *)machine->driver_data;
151   UINT8 *spriteram = state->spriteram;
148152   int offs;
149153
150   for (offs = 0;offs < machine->generic.spriteram_size;offs += 4)
154   for (offs = 0; offs < state->spriteram_size; offs += 4)
151155   {
152      int gfxbank = (spriteram[offs+2] & 0x40) ? 2 : 1;
156      int gfxbank = (spriteram[offs + 2] & 0x40) ? 2 : 1;
153157      int code = (spriteram[offs + 2] & 0x3f) + ((spriteram[offs + 2] & 0x80) >> 1) + ((spriteram[offs] & 0x40) << 1);
154      int color = (spriteram[offs] & 0x0f) + 16 * palettebank;
158      int color = (spriteram[offs] & 0x0f) + 16 * state->palettebank;
155159      int sx = spriteram[offs + 3];
156160      int sy = 244 - spriteram[offs + 1];
157161      int flipx = ~spriteram[offs] & 0x10;
r7500r7501
173177
174178VIDEO_UPDATE( mikie )
175179{
176   tilemap_draw(bitmap, cliprect, bg_tilemap, TILEMAP_DRAW_CATEGORY(0), 0);
180   mikie_state *state = (mikie_state *)screen->machine->driver_data;
181   tilemap_draw(bitmap, cliprect, state->bg_tilemap, TILEMAP_DRAW_CATEGORY(0), 0);
177182   draw_sprites(screen->machine, bitmap, cliprect);
178   tilemap_draw(bitmap, cliprect, bg_tilemap, TILEMAP_DRAW_CATEGORY(1), 0);
183   tilemap_draw(bitmap, cliprect, state->bg_tilemap, TILEMAP_DRAW_CATEGORY(1), 0);
179184   return 0;
180185}
src/mame/video/cbuster.c
r7500r7501
55***************************************************************************/
66
77#include "emu.h"
8#include "includes/deco16ic.h"
8#include "includes/cbuster.h"
9#include "video/deco16ic.h"
910
10static int twocrude_pri;
11
1211/******************************************************************************/
1312
14static int bank_callback(const int bank)
13static void update_24bitcol( running_machine *machine, int offset )
1514{
16   return ((bank>>4)&0x7) * 0x1000;
17}
15   UINT8 r, g, b; /* The highest palette value seems to be 0x8e */
1816
19VIDEO_START( twocrude )
20{
21   deco16_2_video_init(machine, 0);
17   r = (UINT8)((float)((machine->generic.paletteram.u16[offset]  >> 0) & 0xff) * 1.75);
18   g = (UINT8)((float)((machine->generic.paletteram.u16[offset]  >> 8) & 0xff) * 1.75);
19   b = (UINT8)((float)((machine->generic.paletteram2.u16[offset] >> 0) & 0xff) * 1.75);
2220
23   deco16_set_tilemap_bank_callback(0, bank_callback);
24   deco16_set_tilemap_bank_callback(1, bank_callback);
25   deco16_set_tilemap_bank_callback(2, bank_callback);
26   deco16_set_tilemap_bank_callback(3, bank_callback);
27
28   deco16_pf1_colour_bank=0x00;
29   deco16_pf2_colour_bank=0x20;
30   deco16_pf4_colour_bank=0x40;
31   deco16_pf3_colour_bank=0x30;
21   palette_set_color(machine, offset, MAKE_RGB(r, g, b));
3222}
3323
34/******************************************************************************/
35
36static void update_24bitcol(running_machine *machine, int offset)
37{
38   UINT8 r,g,b; /* The highest palette value seems to be 0x8e */
39
40   r = (UINT8)((float)((machine->generic.paletteram.u16[offset] >> 0) & 0xff)*1.75);
41   g = (UINT8)((float)((machine->generic.paletteram.u16[offset] >> 8) & 0xff)*1.75);
42   b = (UINT8)((float)((machine->generic.paletteram2.u16[offset] >> 0) & 0xff)*1.75);
43
44   palette_set_color(machine,offset,MAKE_RGB(r,g,b));
45}
46
4724WRITE16_HANDLER( twocrude_palette_24bit_rg_w )
4825{
4926   COMBINE_DATA(&space->machine->generic.paletteram.u16[offset]);
r7500r7501
5633   update_24bitcol(space->machine, offset);
5734}
5835
59/******************************************************************************/
6036
61void twocrude_pri_w(int pri)
62{
63   twocrude_pri=pri;
64}
65
6637/******************************************************************************/
6738
68static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, int pri)
39static void draw_sprites( running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, int pri )
6940{
70   UINT16 *buffered_spriteram16 = machine->generic.buffered_spriteram.u16;
41   UINT16 *buffered_spriteram = machine->generic.buffered_spriteram.u16;
7142   int offs;
7243
73   for (offs = 0;offs < 0x400;offs += 4)
44   for (offs = 0; offs < 0x400; offs += 4)
7445   {
75      int x,y,sprite,colour,multi,fx,fy,inc,flash,mult;
46      int x, y, sprite, colour, multi, fx, fy, inc, flash, mult;
7647
77      sprite = buffered_spriteram16[offs+1] & 0x7fff;
78      if (!sprite) continue;
48      sprite = buffered_spriteram[offs + 1] & 0x7fff;
49      if (!sprite)
50         continue;
7951
80      y = buffered_spriteram16[offs];
81      x = buffered_spriteram16[offs+2];
52      y = buffered_spriteram[offs];
53      x = buffered_spriteram[offs + 2];
8254
83      if ((y&0x8000) && pri==1) continue;
84      if (!(y&0x8000) && pri==0) continue;
55      if ((y & 0x8000) && pri == 1)
56         continue;
57      if (!(y & 0x8000) && pri == 0)
58         continue;
8559
86      colour = (x >> 9) &0xf;
87      if (x&0x2000) colour+=64;
60      colour = (x >> 9) & 0xf;
61      if (x & 0x2000)
62         colour += 64;
8863
89      flash=y&0x1000;
90      if (flash && (video_screen_get_frame_number(machine->primary_screen) & 1)) continue;
64      flash = y & 0x1000;
65      if (flash && (video_screen_get_frame_number(machine->primary_screen) & 1))
66         continue;
9167
9268      fx = y & 0x2000;
9369      fy = y & 0x4000;
r7500r7501
10076      x = 240 - x;
10177      y = 240 - y;
10278
103      if (x>256) continue; /* Speedup */
79      if (x > 256)
80         continue; /* Speedup */
10481
10582      sprite &= ~multi;
10683      if (fy)
r7500r7501
11188         inc = 1;
11289      }
11390
114      if (flip_screen_get(machine)) {
115         y=240-y;
116         x=240-x;
117         if (fx) fx=0; else fx=1;
118         if (fy) fy=0; else fy=1;
119         mult=16;
91      if (flip_screen_get(machine))
92      {
93         y = 240 - y;
94         x = 240 - x;
95         if (fx) fx = 0; else fx = 1;
96         if (fy) fy = 0; else fy = 1;
97         mult = 16;
12098      }
121      else mult=-16;
99      else mult = -16;
122100
123101      while (multi >= 0)
124102      {
r7500r7501
137115
138116VIDEO_UPDATE( twocrude )
139117{
140   flip_screen_set(screen->machine,  !(deco16_pf12_control[0]&0x80) );
118   cbuster_state *state = (cbuster_state *)screen->machine->driver_data;
119   UINT16 flip = deco16ic_pf12_control_r(state->deco16ic, 0, 0xffff);
141120
142   deco16_pf12_update(deco16_pf1_rowscroll,deco16_pf2_rowscroll);
143   deco16_pf34_update(deco16_pf3_rowscroll,deco16_pf4_rowscroll);
121   flip_screen_set(screen->machine, !BIT(flip, 7));
144122
123   deco16ic_pf12_update(state->deco16ic, state->pf1_rowscroll, state->pf2_rowscroll);
124   deco16ic_pf34_update(state->deco16ic, state->pf3_rowscroll, state->pf4_rowscroll);
125
145126   /* Draw playfields & sprites */
146   deco16_tilemap_4_draw(screen,bitmap,cliprect,TILEMAP_DRAW_OPAQUE,0);
147   draw_sprites(screen->machine,bitmap,cliprect,0);
127   deco16ic_tilemap_4_draw(state->deco16ic, bitmap, cliprect, TILEMAP_DRAW_OPAQUE, 0);
128   draw_sprites(screen->machine, bitmap, cliprect, 0);
148129
149   if (twocrude_pri) {
150      deco16_tilemap_2_draw(screen,bitmap,cliprect,0,0);
151      deco16_tilemap_3_draw(screen,bitmap,cliprect,0,0);
130   if (state->pri)
131   {
132      deco16ic_tilemap_2_draw(state->deco16ic, bitmap, cliprect, 0, 0);
133      deco16ic_tilemap_3_draw(state->deco16ic, bitmap, cliprect, 0, 0);
152134   }
153   else {
154      deco16_tilemap_3_draw(screen,bitmap,cliprect,0,0);
155      deco16_tilemap_2_draw(screen,bitmap,cliprect,0,0);
135   else
136   {
137      deco16ic_tilemap_3_draw(state->deco16ic, bitmap, cliprect, 0, 0);
138      deco16ic_tilemap_2_draw(state->deco16ic, bitmap, cliprect, 0, 0);
156139   }
157140
158   draw_sprites(screen->machine,bitmap,cliprect,1);
159   deco16_tilemap_1_draw(screen,bitmap,cliprect,0,0);
141   draw_sprites(screen->machine, bitmap, cliprect, 1);
142   deco16ic_tilemap_1_draw(state->deco16ic, bitmap, cliprect, 0, 0);
160143   return 0;
161144}
src/mame/video/ojankohs.c
r7500r7501
99
1010#include "emu.h"
1111#include "cpu/z80/z80.h"
12#include "includes/ojankohs.h"
1213
13
14static UINT8 *ojankohs_videoram;
15static UINT8 *ojankohs_colorram;
16static UINT8 *ojankohs_paletteram;
17static int ojankohs_gfxreg;
18static int ojankohs_flipscreen;
19static int ojankohs_scrollx, ojankohs_scrolly;
20static tilemap_t *ojankohs_tilemap;
21static int ojankoc_screen_refresh;
22static bitmap_t *ojankoc_tmpbitmap;
23
24WRITE8_HANDLER( ojankoc_videoram_w );
25
26
2714/******************************************************************************
2815
2916    Palette system
r7500r7501
3522   int i;
3623   int bit0, bit1, bit2, bit3, bit4, r, g, b;
3724
38   for (i = 0; i < machine->config->total_colors; i++) {
39      bit0 = (color_prom[0] >> 2) & 0x01;
40      bit1 = (color_prom[0] >> 3) & 0x01;
41      bit2 = (color_prom[0] >> 4) & 0x01;
42      bit3 = (color_prom[0] >> 5) & 0x01;
43      bit4 = (color_prom[0] >> 6) & 0x01;
25   for (i = 0; i < machine->config->total_colors; i++)
26   {
27      bit0 = BIT(color_prom[0], 2);
28      bit1 = BIT(color_prom[0], 3);
29      bit2 = BIT(color_prom[0], 4);
30      bit3 = BIT(color_prom[0], 5);
31      bit4 = BIT(color_prom[0], 6);
4432      r = 0x08 * bit0 + 0x11 * bit1 + 0x21 * bit2 + 0x43 * bit3 + 0x82 * bit4;
45      bit0 = (color_prom[machine->config->total_colors] >> 5) & 0x01;
46      bit1 = (color_prom[machine->config->total_colors] >> 6) & 0x01;
47      bit2 = (color_prom[machine->config->total_colors] >> 7) & 0x01;
48      bit3 = (color_prom[0] >> 0) & 0x01;
49      bit4 = (color_prom[0] >> 1) & 0x01;
33      bit0 = BIT(color_prom[machine->config->total_colors], 5);
34      bit1 = BIT(color_prom[machine->config->total_colors], 6);
35      bit2 = BIT(color_prom[machine->config->total_colors], 7);
36      bit3 = BIT(color_prom[0], 0);
37      bit4 = BIT(color_prom[0], 1);
5038      g = 0x08 * bit0 + 0x11 * bit1 + 0x21 * bit2 + 0x43 * bit3 + 0x82 * bit4;
51      bit0 = (color_prom[machine->config->total_colors] >> 0) & 0x01;
52      bit1 = (color_prom[machine->config->total_colors] >> 1) & 0x01;
53      bit2 = (color_prom[machine->config->total_colors] >> 2) & 0x01;
54      bit3 = (color_prom[machine->config->total_colors] >> 3) & 0x01;
55      bit4 = (color_prom[machine->config->total_colors] >> 4) & 0x01;
39      bit0 = BIT(color_prom[machine->config->total_colors], 0);
40      bit1 = BIT(color_prom[machine->config->total_colors], 1);
41      bit2 = BIT(color_prom[machine->config->total_colors], 2);
42      bit3 = BIT(color_prom[machine->config->total_colors], 3);
43      bit4 = BIT(color_prom[machine->config->total_colors], 4);
5644      b = 0x08 * bit0 + 0x11 * bit1 + 0x21 * bit2 + 0x43 * bit3 + 0x82 * bit4;
5745
5846      palette_set_color(machine, i, MAKE_RGB(r, g, b));
r7500r7501
6250
6351WRITE8_HANDLER( ojankohs_palette_w )
6452{
53   ojankohs_state *state = (ojankohs_state *)space->machine->driver_data;
6554   int r, g, b;
6655
67   ojankohs_paletteram[offset] = data;
56   state->paletteram[offset] = data;
6857
6958   offset &= 0x7fe;
7059
71   r = (ojankohs_paletteram[offset + 0] & 0x7c) >> 2;
72   g = ((ojankohs_paletteram[offset + 0] & 0x03) << 3) |
73         ((ojankohs_paletteram[offset + 1] & 0xe0) >> 5);
74   b = (ojankohs_paletteram[offset + 1] & 0x1f) >> 0;
60   r = (state->paletteram[offset + 0] & 0x7c) >> 2;
61   g = ((state->paletteram[offset + 0] & 0x03) << 3) | ((state->paletteram[offset + 1] & 0xe0) >> 5);
62   b = (state->paletteram[offset + 1] & 0x1f) >> 0;
7563
76   palette_set_color_rgb(space->machine,offset >> 1, pal5bit(r), pal5bit(g), pal5bit(b));
64   palette_set_color_rgb(space->machine, offset >> 1, pal5bit(r), pal5bit(g), pal5bit(b));
7765}
7866
7967WRITE8_HANDLER( ccasino_palette_w )
8068{
69   ojankohs_state *state = (ojankohs_state *)space->machine->driver_data;
8170   int r, g, b;
8271
8372   /* get top 8 bits of the I/O port address */
8473   offset = (offset << 8) | (cpu_get_reg(space->cpu, Z80_BC) >> 8);
8574
86   ojankohs_paletteram[offset] = data;
75   state->paletteram[offset] = data;
8776
8877   offset &= 0x7fe;
8978
90   r = (ojankohs_paletteram[offset + 0] & 0x7c) >> 2;
91   g = ((ojankohs_paletteram[offset + 0] & 0x03) << 3) |
92         ((ojankohs_paletteram[offset + 1] & 0xe0) >> 5);
93   b = (ojankohs_paletteram[offset + 1] & 0x1f) >> 0;
79   r = (state->paletteram[offset + 0] & 0x7c) >> 2;
80   g = ((state->paletteram[offset + 0] & 0x03) << 3) | ((state->paletteram[offset + 1] & 0xe0) >> 5);
81   b = (state->paletteram[offset + 1] & 0x1f) >> 0;
9482
95   palette_set_color_rgb(space->machine,offset >> 1, pal5bit(r), pal5bit(g), pal5bit(b));
83   palette_set_color_rgb(space->machine, offset >> 1, pal5bit(r), pal5bit(g), pal5bit(b));
9684}
9785
9886WRITE8_HANDLER( ojankoc_palette_w )
9987{
88   ojankohs_state *state = (ojankohs_state *)space->machine->driver_data;
10089   int r, g, b, color;
10190
102   if (ojankohs_paletteram[offset] == data) return;
91   if (state->paletteram[offset] == data)
92      return;
10393
104   ojankohs_paletteram[offset] = data;
105   ojankoc_screen_refresh = 1;
94   state->paletteram[offset] = data;
95   state->screen_refresh = 1;
10696
107   color = (ojankohs_paletteram[offset & 0x1e] << 8) | ojankohs_paletteram[offset | 0x01];
97   color = (state->paletteram[offset & 0x1e] << 8) | state->paletteram[offset | 0x01];
10898
10999   r = (color >> 10) & 0x1f;
110100   g = (color >>  5) & 0x1f;
111101   b = (color >>  0) & 0x1f;
112102
113   palette_set_color_rgb(space->machine,offset >> 1, pal5bit(r), pal5bit(g), pal5bit(b));
103   palette_set_color_rgb(space->machine, offset >> 1, pal5bit(r), pal5bit(g), pal5bit(b));
114104}
115105
116106
r7500r7501
122112
123113WRITE8_HANDLER( ojankohs_videoram_w )
124114{
125   ojankohs_videoram[offset] = data;
126   tilemap_mark_tile_dirty(ojankohs_tilemap, offset);
115   ojankohs_state *state = (ojankohs_state *)space->machine->driver_data;
116   state->videoram[offset] = data;
117   tilemap_mark_tile_dirty(state->tilemap, offset);
127118}
128119
129120WRITE8_HANDLER( ojankohs_colorram_w )
130121{
131   ojankohs_colorram[offset] = data;
132   tilemap_mark_tile_dirty(ojankohs_tilemap, offset);
122   ojankohs_state *state = (ojankohs_state *)space->machine->driver_data;
123   state->colorram[offset] = data;
124   tilemap_mark_tile_dirty(state->tilemap, offset);
133125}
134126
135127WRITE8_HANDLER( ojankohs_gfxreg_w )
136128{
137   if (ojankohs_gfxreg != data) {
138      ojankohs_gfxreg = data;
139      tilemap_mark_all_tiles_dirty(ojankohs_tilemap);
129   ojankohs_state *state = (ojankohs_state *)space->machine->driver_data;
130
131   if (state->gfxreg != data)
132   {
133      state->gfxreg = data;
134      tilemap_mark_all_tiles_dirty(state->tilemap);
140135   }
141136}
142137
143138WRITE8_HANDLER( ojankohs_flipscreen_w )
144139{
145   if (ojankohs_flipscreen != (data & 0x01)) {
140   ojankohs_state *state = (ojankohs_state *)space->machine->driver_data;
146141
147      ojankohs_flipscreen = data & 0x01;
142   if (state->flipscreen != BIT(data, 0))
143   {
148144
149      tilemap_set_flip_all(space->machine, ojankohs_flipscreen ? (TILEMAP_FLIPX | TILEMAP_FLIPY) : 0);
145      state->flipscreen = BIT(data, 0);
150146
151      if (ojankohs_flipscreen) {
152         ojankohs_scrollx = -0xe0;
153         ojankohs_scrolly = -0x20;
147      tilemap_set_flip_all(space->machine, state->flipscreen ? (TILEMAP_FLIPX | TILEMAP_FLIPY) : 0);
148
149      if (state->flipscreen)
150      {
151         state->scrollx = -0xe0;
152         state->scrolly = -0x20;
154153      }
155      else {
156         ojankohs_scrollx = 0;
157         ojankohs_scrolly = 0;
154      else
155      {
156         state->scrollx = 0;
157         state->scrolly = 0;
158158      }
159159   }
160160}
161161
162162static TILE_GET_INFO( ojankohs_get_tile_info )
163163{
164   int tile, color;
164   ojankohs_state *state = (ojankohs_state *)machine->driver_data;
165   int tile = state->videoram[tile_index] | ((state->colorram[tile_index] & 0x0f) << 8);
166   int color = (state->colorram[tile_index] & 0xe0) >> 5;
165167
166   tile = ojankohs_videoram[tile_index] | ((ojankohs_colorram[tile_index] & 0x0f) << 8);
167   color = (ojankohs_colorram[tile_index] & 0xe0) >> 5;
168
169   if (ojankohs_colorram[tile_index] & 0x10) {
170      tile |= (ojankohs_gfxreg & 0x07) << 12;
171      color |= (ojankohs_gfxreg & 0xe0) >> 2;
168   if (state->colorram[tile_index] & 0x10)
169   {
170      tile |= (state->gfxreg & 0x07) << 12;
171      color |= (state->gfxreg & 0xe0) >> 2;
172172   }
173173
174174   SET_TILE_INFO(0, tile, color, 0);
r7500r7501
176176
177177static TILE_GET_INFO( ojankoy_get_tile_info )
178178{
179   int tile, color, flipx, flipy;
179   ojankohs_state *state = (ojankohs_state *)machine->driver_data;
180   int tile = state->videoram[tile_index] | (state->videoram[tile_index + 0x1000] << 8);
181   int color = state->colorram[tile_index] & 0x3f;
182   int flipx = ((state->colorram[tile_index] & 0x40) >> 6) ? TILEMAP_FLIPX : 0;
183   int flipy = ((state->colorram[tile_index] & 0x80) >> 7) ? TILEMAP_FLIPY : 0;
180184
181   tile = ojankohs_videoram[tile_index] | (ojankohs_videoram[tile_index + 0x1000] << 8);
182   color = ojankohs_colorram[tile_index] & 0x3f;
183   flipx = ((ojankohs_colorram[tile_index] & 0x40) >> 6) ? TILEMAP_FLIPX : 0;
184   flipy = ((ojankohs_colorram[tile_index] & 0x80) >> 7) ? TILEMAP_FLIPY : 0;
185
186185   SET_TILE_INFO(0, tile, color, (flipx | flipy));
187186}
188187
r7500r7501
193192
194193******************************************************************************/
195194
196void ojankoc_flipscreen(const address_space *space, int data)
195void ojankoc_flipscreen( const address_space *space, int data )
197196{
198   static int ojankoc_flipscreen_old = 0;
197   ojankohs_state *state = (ojankohs_state *)space->machine->driver_data;
199198   int x, y;
200199   UINT8 color1, color2;
201200
202   ojankohs_flipscreen = (data & 0x80) >> 7;
201   state->flipscreen = BIT(data, 7);
203202
204   if (ojankohs_flipscreen == ojankoc_flipscreen_old) return;
203   if (state->flipscreen == state->flipscreen_old)
204      return;
205205
206   for (y = 0; y < 0x40; y++) {
207      for (x = 0; x < 0x100; x++) {
208         color1 = ojankohs_videoram[0x0000 + ((y * 256) + x)];
209         color2 = ojankohs_videoram[0x3fff - ((y * 256) + x)];
206   for (y = 0; y < 0x40; y++)
207   {
208      for (x = 0; x < 0x100; x++)
209      {
210         color1 = state->videoram[0x0000 + ((y * 256) + x)];
211         color2 = state->videoram[0x3fff - ((y * 256) + x)];
210212         ojankoc_videoram_w(space, 0x0000 + ((y * 256) + x), color2);
211213         ojankoc_videoram_w(space, 0x3fff - ((y * 256) + x), color1);
212214
213         color1 = ojankohs_videoram[0x4000 + ((y * 256) + x)];
214         color2 = ojankohs_videoram[0x7fff - ((y * 256) + x)];
215         color1 = state->videoram[0x4000 + ((y * 256) + x)];
216         color2 = state->videoram[0x7fff - ((y * 256) + x)];
215217         ojankoc_videoram_w(space, 0x4000 + ((y * 256) + x), color2);
216218         ojankoc_videoram_w(space, 0x7fff - ((y * 256) + x), color1);
217219      }
218220   }
219221
220   ojankoc_flipscreen_old = ojankohs_flipscreen;
222   state->flipscreen_old = state->flipscreen;
221223}
222224
223225WRITE8_HANDLER( ojankoc_videoram_w )
224226{
227   ojankohs_state *state = (ojankohs_state *)space->machine->driver_data;
225228   int i;
226229   UINT8 x, y, xx, px, py ;
227230   UINT8 color, color1, color2;
228231
229   ojankohs_videoram[offset] = data;
232   state->videoram[offset] = data;
230233
231   color1 = ojankohs_videoram[offset & 0x3fff];
232   color2 = ojankohs_videoram[offset | 0x4000];
234   color1 = state->videoram[offset & 0x3fff];
235   color2 = state->videoram[offset | 0x4000];
233236
234237   y = offset >> 6;
235238   x = (offset & 0x3f) << 2;
236239   xx = 0;
237240
238   if (ojankohs_flipscreen) {
241   if (state->flipscreen)
242   {
239243      x = 0xfc - x;
240244      y = 0xff - y;
241245      xx = 3;
242246   }
243247
244   for (i = 0; i < 4; i++) {
248   for (i = 0; i < 4; i++)
249   {
245250      color = ((color1 & 0x01) >> 0) | ((color1 & 0x10) >> 3) | ((color2 & 0x01) << 2) | ((color2 & 0x10) >> 1);
246251
247252      px = x + (i ^ xx);
248253      py = y;
249254
250      *BITMAP_ADDR16(ojankoc_tmpbitmap, py, px) = color;
255      *BITMAP_ADDR16(state->tmpbitmap, py, px) = color;
251256
252257      color1 >>= 1;
253258      color2 >>= 1;
r7500r7501
263268
264269VIDEO_START( ojankohs )
265270{
266   ojankohs_tilemap = tilemap_create(machine, ojankohs_get_tile_info, tilemap_scan_rows,  8, 4, 64, 64);
267   ojankohs_videoram = auto_alloc_array(machine, UINT8, 0x2000);
268   ojankohs_colorram = auto_alloc_array(machine, UINT8, 0x1000);
269   ojankohs_paletteram = auto_alloc_array(machine, UINT8, 0x800);
271   ojankohs_state *state = (ojankohs_state *)machine->driver_data;
272
273   state->tilemap = tilemap_create(machine, ojankohs_get_tile_info, tilemap_scan_rows,  8, 4, 64, 64);
274   state->videoram = auto_alloc_array(machine, UINT8, 0x2000);
275   state->colorram = auto_alloc_array(machine, UINT8, 0x1000);
276   state->paletteram = auto_alloc_array(machine, UINT8, 0x800);
277
278   state_save_register_global_pointer(machine, state->videoram, 0x2000);
279   state_save_register_global_pointer(machine, state->colorram, 0x1000);
280   state_save_register_global_pointer(machine, state->paletteram, 0x800);
270281}
271282
272283VIDEO_START( ojankoy )
273284{
274   ojankohs_tilemap = tilemap_create(machine, ojankoy_get_tile_info, tilemap_scan_rows,  8, 4, 64, 64);
275   ojankohs_videoram = auto_alloc_array(machine, UINT8, 0x2000);
276   ojankohs_colorram = auto_alloc_array(machine, UINT8, 0x1000);
277   ojankohs_paletteram = auto_alloc_array(machine, UINT8, 0x800);
285   ojankohs_state *state = (ojankohs_state *)machine->driver_data;
286
287   state->tilemap = tilemap_create(machine, ojankoy_get_tile_info, tilemap_scan_rows,  8, 4, 64, 64);
288   state->videoram = auto_alloc_array(machine, UINT8, 0x2000);
289   state->colorram = auto_alloc_array(machine, UINT8, 0x1000);
290   state->paletteram = auto_alloc_array(machine, UINT8, 0x800);
291
292   state_save_register_global_pointer(machine, state->videoram, 0x2000);
293   state_save_register_global_pointer(machine, state->colorram, 0x1000);
294   state_save_register_global_pointer(machine, state->paletteram, 0x800);
278295}
279296
280297VIDEO_START( ojankoc )
281298{
282   ojankoc_tmpbitmap = video_screen_auto_bitmap_alloc(machine->primary_screen);
283   ojankohs_videoram = auto_alloc_array(machine, UINT8, 0x8000);
284   ojankohs_paletteram = auto_alloc_array(machine, UINT8, 0x20);
299   ojankohs_state *state = (ojankohs_state *)machine->driver_data;
300
301   state->tmpbitmap = video_screen_auto_bitmap_alloc(machine->primary_screen);
302   state->videoram = auto_alloc_array(machine, UINT8, 0x8000);
303   state->paletteram = auto_alloc_array(machine, UINT8, 0x20);
304
305   state_save_register_global_pointer(machine, state->videoram, 0x8000);
306   state_save_register_global_pointer(machine, state->paletteram, 0x20);
307   state_save_register_global_bitmap(machine, state->tmpbitmap);
285308}
286309
287310
r7500r7501
293316
294317VIDEO_UPDATE( ojankohs )
295318{
296   tilemap_set_scrollx(ojankohs_tilemap, 0, ojankohs_scrollx);
297   tilemap_set_scrolly(ojankohs_tilemap, 0, ojankohs_scrolly);
319   ojankohs_state *state = (ojankohs_state *)screen->machine->driver_data;
298320
299   tilemap_draw(bitmap, cliprect, ojankohs_tilemap, 0, 0);
321   tilemap_set_scrollx(state->tilemap, 0, state->scrollx);
322   tilemap_set_scrolly(state->tilemap, 0, state->scrolly);
323
324   tilemap_draw(bitmap, cliprect, state->tilemap, 0, 0);
300325   return 0;
301326}
302327
303328VIDEO_UPDATE( ojankoc )
304329{
330   ojankohs_state *state = (ojankohs_state *)screen->machine->driver_data;
305331   int offs;
306332
307   if (ojankoc_screen_refresh)
333   if (state->screen_refresh)
308334   {
309335      const address_space *space = cputag_get_address_space(screen->machine, "maincpu", ADDRESS_SPACE_PROGRAM);
310336
311337      /* redraw bitmap */
312      for (offs = 0; offs < 0x8000; offs++) {
313         ojankoc_videoram_w(space, offs, ojankohs_videoram[offs]);
338      for (offs = 0; offs < 0x8000; offs++)
339      {
340         ojankoc_videoram_w(space, offs, state->videoram[offs]);
314341      }
315      ojankoc_screen_refresh = 0;
342      state->screen_refresh = 0;
316343   }
317344
318   copybitmap(bitmap, ojankoc_tmpbitmap, 0, 0, 0, 0, cliprect);
345   copybitmap(bitmap, state->tmpbitmap, 0, 0, 0, 0, cliprect);
319346   return 0;
320347}
src/mame/video/liberate.c
r7500r7501
6060   }
6161
6262   tile = RAM[tile_index];
63   if (tile > 0x7f) bank = 3; else bank = 2;
63   if (tile > 0x7f)
64      bank = 3;
65   else
66      bank = 2;
6467   SET_TILE_INFO(bank, tile & 0x7f, state->background_color, 0);
6568}
6669
r7500r7501
104107   liberate_state *state = (liberate_state *)space->machine->driver_data;
105108   state->io_ram[offset] = data;
106109   if (offset > 1 && offset < 6)
107      tilemap_mark_all_tiles_dirty(state->background_tilemap);
110      tilemap_mark_all_tiles_dirty(state->back_tilemap);
108111
109112   switch (offset)
110113   {
r7500r7501
112115         if (((data >> 4) & 3) != state->background_color)
113116         {
114117            state->background_color = (data >> 4) & 3;
115            tilemap_mark_all_tiles_dirty(state->background_tilemap);
118            tilemap_mark_all_tiles_dirty(state->back_tilemap);
116119         }
117120         state->background_disable = data & 0x4;
118         flip_screen_set(space->machine, data & 0x1);
121         flip_screen_set(space->machine, data & 0x01);
119122         break;
120123      case 7: /* Background palette resistors? */
121124         /* Todo */
122125         break;
123126      case 8: /* Irq ack */
124         cputag_set_input_line(space->machine, "maincpu", DECO16_IRQ_LINE, CLEAR_LINE);
127         cpu_set_input_line(state->maincpu, DECO16_IRQ_LINE, CLEAR_LINE);
125128         break;
126129      case 9: /* Sound */
127130         soundlatch_w(space, 0, data);
128         cputag_set_input_line(space->machine, "audiocpu", M6502_IRQ_LINE, HOLD_LINE);
131         cpu_set_input_line(state->audiocpu, M6502_IRQ_LINE, HOLD_LINE);
129132         break;
130133   }
131134}
r7500r7501
135138   liberate_state *state = (liberate_state *)space->machine->driver_data;
136139   state->io_ram[offset] = data;
137140   if (offset > 1 && offset < 6)
138      tilemap_mark_all_tiles_dirty(state->background_tilemap);
141      tilemap_mark_all_tiles_dirty(state->back_tilemap);
139142
140//  popmessage("%02x %02x",state->io_ram[6],state->io_ram[7]);
143   //  popmessage("%02x %02x",state->io_ram[6],state->io_ram[7]);
141144
142145   switch (offset)
143146   {
r7500r7501
150153         /* x--- ---- used on the attract mode */
151154         break;
152155      case 8: /* Irq ack */
153         cputag_set_input_line(space->machine, "maincpu", DECO16_IRQ_LINE, CLEAR_LINE);
156         cpu_set_input_line(state->maincpu, DECO16_IRQ_LINE, CLEAR_LINE);
154157         break;
155158      case 9: /* Sound */
156159         soundlatch_w(space, 0, data);
157         cputag_set_input_line(space->machine, "audiocpu", M6502_IRQ_LINE, HOLD_LINE);
160         cpu_set_input_line(state->audiocpu, M6502_IRQ_LINE, HOLD_LINE);
158161         break;
159162   }
160163}
r7500r7501
170173      case 0:
171174         //background_disable = ~data & 0x80;
172175         flip_screen_set(space->machine, data & 0x80);
173         tilemap_mark_all_tiles_dirty(state->background_tilemap);
176         tilemap_mark_all_tiles_dirty(state->back_tilemap);
174177         break;
175178      case 2: /* Sound */
176179         soundlatch_w(space, 0, data);
177         cputag_set_input_line(space->machine, "audiocpu", M6502_IRQ_LINE, HOLD_LINE);
180         cpu_set_input_line(state->audiocpu, M6502_IRQ_LINE, HOLD_LINE);
178181         break;
179182      case 4: /* Irq ack */
180         cputag_set_input_line(space->machine, "maincpu", DECO16_IRQ_LINE, CLEAR_LINE);
183         cpu_set_input_line(state->maincpu, DECO16_IRQ_LINE, CLEAR_LINE);
181184         break;
182185   }
183186}
r7500r7501
200203{
201204   liberate_state *state = (liberate_state *)space->machine->driver_data;
202205   state->bg_vram[offset] = data;
203   tilemap_mark_tile_dirty(state->background_tilemap, offset);
206   tilemap_mark_tile_dirty(state->back_tilemap, offset);
204207}
205208
206209/***************************************************************************/
r7500r7501
208211VIDEO_START( prosoccr )
209212{
210213   liberate_state *state = (liberate_state *)machine->driver_data;
211   state->background_tilemap = tilemap_create(machine, get_back_tile_info,back_scan,16,16,32,32);
212   state->fix_tilemap = tilemap_create(machine, get_fix_tile_info,fix_scan,8,8,32,32);
214   state->back_tilemap = tilemap_create(machine, get_back_tile_info, back_scan, 16, 16, 32, 32);
215   state->fix_tilemap = tilemap_create(machine, get_fix_tile_info, fix_scan, 8, 8, 32, 32);
213216
214   tilemap_set_transparent_pen(state->fix_tilemap,0);
217   tilemap_set_transparent_pen(state->fix_tilemap, 0);
215218
216   state->charram = auto_alloc_array(machine, UINT8, 0x1800*2);
219   state->charram = auto_alloc_array(machine, UINT8, 0x1800 * 2);
217220}
218221
219222VIDEO_START( boomrang )
220223{
221224   liberate_state *state = (liberate_state *)machine->driver_data;
222   state->background_tilemap = tilemap_create(machine, get_back_tile_info,back_scan,16,16,32,32);
223   state->fix_tilemap = tilemap_create(machine, get_fix_tile_info,fix_scan,8,8,32,32);
225   state->back_tilemap = tilemap_create(machine, get_back_tile_info, back_scan, 16, 16, 32, 32);
226   state->fix_tilemap = tilemap_create(machine, get_fix_tile_info, fix_scan, 8, 8, 32, 32);
224227
225   tilemap_set_transmask(state->background_tilemap,0,0x0001,0x007e); /* Bottom 1 pen/Top 7 pens */
226   tilemap_set_transparent_pen(state->fix_tilemap,0);
228   tilemap_set_transmask(state->back_tilemap, 0, 0x0001, 0x007e); /* Bottom 1 pen/Top 7 pens */
229   tilemap_set_transparent_pen(state->fix_tilemap, 0);
227230}
228231
229232VIDEO_START( liberate )
230233{
231234   liberate_state *state = (liberate_state *)machine->driver_data;
232   state->background_tilemap = tilemap_create(machine, get_back_tile_info,back_scan,16,16,32,32);
233   state->fix_tilemap = tilemap_create(machine, get_fix_tile_info,fix_scan,8,8,32,32);
235   state->back_tilemap = tilemap_create(machine, get_back_tile_info, back_scan, 16, 16, 32, 32);
236   state->fix_tilemap = tilemap_create(machine, get_fix_tile_info, fix_scan, 8, 8, 32, 32);
234237
235   tilemap_set_transparent_pen(state->fix_tilemap,0);
238   tilemap_set_transparent_pen(state->fix_tilemap, 0);
236239}
237240
238241VIDEO_START( prosport )
239242{
240243   liberate_state *state = (liberate_state *)machine->driver_data;
241   state->background_tilemap = tilemap_create(machine, prosport_get_back_tile_info,back_scan,16,16,32,32);
242   state->fix_tilemap = tilemap_create(machine, get_fix_tile_info,fix_scan,8,8,32,32);
244   state->back_tilemap = tilemap_create(machine, prosport_get_back_tile_info, back_scan, 16, 16, 32, 32);
245   state->fix_tilemap = tilemap_create(machine, get_fix_tile_info, fix_scan, 8, 8, 32, 32);
243246
244   tilemap_set_transparent_pen(state->fix_tilemap,0);
247   tilemap_set_transparent_pen(state->fix_tilemap, 0);
245248}
246249
247250/***************************************************************************/
248251
249252WRITE8_HANDLER( prosport_paletteram_w )
250253{
251   space->machine->generic.paletteram.u8[offset] = data;
254   liberate_state *state = (liberate_state *)space->machine->driver_data;
255   state->paletteram[offset] = data;
252256
253257   /* RGB output is inverted */
254258   palette_set_color_rgb(space->machine, offset, pal3bit(~data >> 0), pal3bit(~data >> 3), pal2bit(~data >> 6));
r7500r7501
256260
257261PALETTE_INIT( liberate )
258262{
259   int i,bit0,bit1,bit2,g,r,b;
263   int i, bit0, bit1, bit2, g, r, b;
260264
261265   for (i = 0;i < 32;i++)
262266   {
r7500r7501
286290
287291/***************************************************************************/
288292
289static void liberate_draw_sprites(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect)
293static void liberate_draw_sprites( running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect )
290294{
291   UINT8 *spriteram = machine->generic.spriteram.u8;
295   liberate_state *state = (liberate_state *)machine->driver_data;
296   UINT8 *spriteram = state->spriteram;
292297   int offs;
293298
294299   /* Sprites */
295   for (offs = 0x000;offs < 0x800;offs += 4)
300   for (offs = 0x000; offs < 0x800; offs += 4)
296301   {
297      int multi,fx,fy,sx,sy,sy2,code,color;
302      int multi, fx, fy, sx, sy, sy2, code, color;
298303
299304      /*
300305            Byte 0: 0x01 - ?
r7500r7501
309314            Byte 3: 0xff - X position
310315        */
311316
312      code = spriteram[offs+1] + ((spriteram[offs+0] & 0x60) << 3);
313      sx = 240 - spriteram[offs+3];
314      sy = 240 - spriteram[offs+2];
315      color = ((spriteram[offs+1] & 0x08) >> 3); // ?
317      code = spriteram[offs + 1] + ((spriteram[offs + 0] & 0x60) << 3);
318      sx = 240 - spriteram[offs + 3];
319      sy = 240 - spriteram[offs + 2];
320      color = ((spriteram[offs + 1] & 0x08) >> 3); // ?
316321
317      fx = spriteram[offs+0] & 0x04;
318      fy = spriteram[offs+0] & 0x02;
319      multi = spriteram[offs+0] & 0x10;
322      fx = spriteram[offs + 0] & 0x04;
323      fy = spriteram[offs + 0] & 0x02;
324      multi = spriteram[offs + 0] & 0x10;
320325
321      if (multi && fy==0) sy-=16;
326      if (multi && fy == 0)
327         sy -= 16;
322328
323329      if (flip_screen_get(machine))
324330      {
325         sy=240-sy;
326         sx=240-sx;
331         sy = 240 - sy;
332         sx = 240 - sx;
327333         if (fy)
328            sy2=sy+16;
334            sy2 = sy + 16;
329335         else
330            sy2=sy-16;
331         if (fx) fx=0; else fx=1;
332         if (fy) fy=0; else fy=1;
336            sy2 = sy - 16;
337         if (fx) fx = 0; else fx = 1;
338         if (fy) fy = 0; else fy = 1;
333339      }
334340      else
335341      {
336342         if (fy)
337            sy2=sy-16;
343            sy2 = sy - 16;
338344         else
339            sy2=sy+16;
345            sy2 = sy + 16;
340346      }
341347
342348      drawgfx_transpen(bitmap,cliprect,machine->gfx[1],
r7500r7501
353359   }
354360}
355361
356static void prosport_draw_sprites(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect)
362static void prosport_draw_sprites( running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect )
357363{
358364   liberate_state *state = (liberate_state *)machine->driver_data;
359   int offs,multi,fx,fy,sx,sy,sy2,code,code2,color,gfx_region;
360   UINT8 *spriteram = machine->generic.spriteram.u8;
365   int offs, multi, fx, fy, sx, sy, sy2, code, code2, color, gfx_region;
366   UINT8 *spriteram = state->spriteram;
361367
362   for (offs = 0x000;offs < 0x800;offs += 4)
368   for (offs = 0x000; offs < 0x800; offs += 4)
363369   {
364      if ((spriteram[offs+0]&1)!=1) continue;
370      if ((spriteram[offs + 0] & 1) != 1)
371         continue;
365372
366      code = spriteram[offs+1] + ((spriteram[offs+0]&0x3)<<8);
367      code2=code+1;
373      code = spriteram[offs + 1] + ((spriteram[offs + 0] & 0x3) << 8);
374      code2 = code + 1;
368375
369      if(state->io_ram[0]&0x40) //dynamic ram-based gfxs for Pro Golf
370         gfx_region = 3+4;
376      if(state->io_ram[0] & 0x40) //dynamic ram-based gfxs for Pro Golf
377         gfx_region = 3 + 4;
371378      else
372         gfx_region = ((state->io_ram[0]&0x30)>>4)+4;
379         gfx_region = ((state->io_ram[0] & 0x30) >> 4) + 4;
373380
374381
375      multi = spriteram[offs+0] & 0x10;
382      multi = spriteram[offs + 0] & 0x10;
376383
377      sy=spriteram[offs+2];
378      if (multi) sy+=16;
379      sx = (240 - spriteram[offs+3]);
380//      sy = (240-spriteram[offs+2]);//-16;
381      sy = 240-sy;
384      sy = spriteram[offs + 2];
385      if (multi)
386         sy += 16;
387      sx = (240 - spriteram[offs + 3]);
388//      sy = (240 - spriteram[offs + 2]);//-16;
389      sy = 240 - sy;
382390
383      color = 1;//(state->io_ram[4] & 2)+1;//(spriteram[offs+0]&0x4)>>2;
391      color = 1;//(state->io_ram[4] & 2) + 1;//(spriteram[offs + 0] & 0x4) >> 2;
384392
385      fy = spriteram[offs+0] & 0x02;
386      fx = spriteram[offs+0] & 0x04;
387      multi = 0;// spriteram[offs+0] & 0x10;
393      fy = spriteram[offs + 0] & 0x02;
394      fx = spriteram[offs + 0] & 0x04;
395      multi = 0;// spriteram[offs + 0] & 0x10;
388396
389//      if (multi) sy-=16;
390      if ((fy && multi) || (fx && multi)) { code2=code; code++; }
397//      if (multi) sy -= 16;
398      if ((fy && multi) || (fx && multi)) { code2 = code; code++; }
391399
392400      if (flip_screen_get(machine))
393401      {
394         sy=240-sy;
395         sx=240-sx;
396         if (fx) fx=0; else fx=1;
397         if (fy) fy=0; else fy=1;
398         sy2=sy-16;
402         sy = 240 - sy;
403         sx = 240 - sx;
404         if (fx) fx = 0; else fx = 1;
405         if (fy) fy = 0; else fy = 1;
406         sy2 = sy - 16;
399407      }
400408      else
401409      {
402         sy2=sy+16;
410         sy2 = sy + 16;
403411      }
404412
405413      drawgfx_transpen(bitmap,cliprect,machine->gfx[gfx_region],
r7500r7501
416424   }
417425}
418426
419static void boomrang_draw_sprites(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, int pri)
427static void boomrang_draw_sprites( running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, int pri )
420428{
421   UINT8 *spriteram = machine->generic.spriteram.u8;
422   int offs,multi,fx,fy,sx,sy,sy2,code,code2,color;
429   liberate_state *state = (liberate_state *)machine->driver_data;
430   UINT8 *spriteram = state->spriteram;
431   int offs, multi, fx, fy, sx, sy, sy2, code, code2, color;
423432
424   for (offs = 0x000;offs < 0x800;offs += 4)
433   for (offs = 0x000; offs < 0x800; offs += 4)
425434   {
426      if ((spriteram[offs+0]&1)!=1) continue;
427      if ((spriteram[offs+0]&0x8)!=pri) continue;
435      if ((spriteram[offs + 0] & 1) != 1)
436         continue;
437      if ((spriteram[offs + 0] & 0x8) != pri)
438         continue;
428439
429      code = spriteram[offs+1] + ((spriteram[offs+0]&0xe0)<<3);
430      code2=code+1;
440      code = spriteram[offs + 1] + ((spriteram[offs + 0] & 0xe0) << 3);
441      code2 = code + 1;
431442
432      multi = spriteram[offs+0] & 0x10;
443      multi = spriteram[offs + 0] & 0x10;
433444
434      sy=spriteram[offs+2];
435      if (multi) sy+=16;
436      sx = (240 - spriteram[offs+3]);
437//      sy = (240-spriteram[offs+2]);//-16;
438      sy = 240-sy;
445      sy=spriteram[offs + 2];
446      if (multi)
447         sy += 16;
448      sx = (240 - spriteram[offs + 3]);
449//      sy = (240-spriteram[offs + 2]);//-16;
450      sy = 240 - sy;
439451
440      color = (spriteram[offs+0]&0x4)>>2;
452      color = (spriteram[offs + 0] & 0x4) >> 2;
441453
442454      fx = 0;
443      fy = spriteram[offs+0] & 0x02;
444      multi = spriteram[offs+0] & 0x10;
455      fy = spriteram[offs + 0] & 0x02;
456      multi = spriteram[offs + 0] & 0x10;
445457
446//      if (multi) sy-=16;
447      if (fy && multi) { code2=code; code++; }
458//      if (multi) sy -= 16;
459      if (fy && multi) { code2 = code; code++; }
448460
449461      if (flip_screen_get(machine))
450462      {
451         sy=240-sy;
452         sx=240-sx;
453         if (fx) fx=0; else fx=1;
454         if (fy) fy=0; else fy=1;
455         sy2=sy-16;
463         sy = 240 - sy;
464         sx = 240 - sx;
465         if (fx) fx = 0; else fx = 1;
466         if (fy) fy = 0; else fy = 1;
467         sy2 = sy - 16;
456468      }
457469      else
458470      {
459         sy2=sy+16;
471         sy2 = sy + 16;
460472      }
461473
462474      drawgfx_transpen(bitmap,cliprect,machine->gfx[1],
r7500r7501
473485   }
474486}
475487
476static void prosoccr_draw_sprites(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect)
488static void prosoccr_draw_sprites( running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect )
477489{
478   UINT8 *spriteram = machine->generic.spriteram.u8;
479   int offs,code,fx,fy,sx,sy;
490   liberate_state *state = (liberate_state *)machine->driver_data;
491   UINT8 *spriteram = state->spriteram;
492   int offs, code, fx, fy, sx, sy;
480493
481   for (offs = 0x000;offs < 0x400;offs += 4)
494   for (offs = 0x000; offs < 0x400; offs += 4)
482495   {
483      if ((spriteram[offs+0]&1)!=1) continue;
496      if ((spriteram[offs + 0] & 1) != 1)
497         continue;
484498
485      code = spriteram[offs+1];
486      sy = 240 - spriteram[offs+2];
487      sx = 240 - spriteram[offs+3];
488      fx = spriteram[offs+0] & 4;
489      fy = spriteram[offs+0] & 2;
499      code = spriteram[offs + 1];
500      sy = 240 - spriteram[offs + 2];
501      sx = 240 - spriteram[offs + 3];
502      fx = spriteram[offs + 0] & 4;
503      fy = spriteram[offs + 0] & 2;
490504
491505      drawgfx_transpen(bitmap,cliprect,machine->gfx[1],
492506            code,
r7500r7501
501515VIDEO_UPDATE( prosoccr )
502516{
503517   liberate_state *state = (liberate_state *)screen->machine->driver_data;
504   tilemap_set_scrolly(state->background_tilemap,0, state->io_ram[1]);
505   tilemap_set_scrollx(state->background_tilemap,0,-state->io_ram[0]);
518   tilemap_set_scrolly(state->back_tilemap, 0,  state->io_ram[1]);
519   tilemap_set_scrollx(state->back_tilemap, 0, -state->io_ram[0]);
506520
507521   if (state->background_disable)
508      bitmap_fill(bitmap,cliprect,32);
522      bitmap_fill(bitmap, cliprect, 32);
509523   else
510      tilemap_draw(bitmap,cliprect,state->background_tilemap,0,0);
524      tilemap_draw(bitmap, cliprect, state->back_tilemap, 0, 0);
511525
512   tilemap_draw(bitmap,cliprect,state->fix_tilemap,0,0);
513   prosoccr_draw_sprites(screen->machine,bitmap,cliprect);
526   tilemap_draw(bitmap, cliprect, state->fix_tilemap, 0, 0);
527   prosoccr_draw_sprites(screen->machine, bitmap, cliprect);
514528
515529   return 0;
516530}
r7500r7501
520534   liberate_state *state = (liberate_state *)screen->machine->driver_data;
521535   UINT8 *videoram = state->videoram;
522536   UINT8 *colorram = state->colorram;
523   int mx,my,tile,offs,gfx_region;
524   int scrollx,scrolly;
537   int mx, my, tile, offs, gfx_region;
538   int scrollx, scrolly;
525539
526   bitmap_fill(bitmap,cliprect,0);
540   bitmap_fill(bitmap, cliprect, 0);
527541
528542   offs = 0;
529543   /* TODO: what's bits 0 and 2 for? Internal scrolling state? */
530   scrolly = ((state->io_ram[0] & 0x8)<<5);
531   scrollx = ((state->io_ram[0] & 0x2)<<7) | (state->io_ram[1]);
544   scrolly = ((state->io_ram[0] & 0x8) << 5);
545   scrollx = ((state->io_ram[0] & 0x2) << 7) | (state->io_ram[1]);
532546
533   tilemap_set_scrolly(state->background_tilemap,0,scrolly);
534   tilemap_set_scrollx(state->background_tilemap,0,-scrollx);
547   tilemap_set_scrolly(state->back_tilemap, 0, scrolly);
548   tilemap_set_scrollx(state->back_tilemap, 0, -scrollx);
535549
536   tilemap_draw(bitmap,cliprect,state->background_tilemap,0,0);
550   tilemap_draw(bitmap, cliprect, state->back_tilemap, 0, 0);
537551
538552//  popmessage("%d %02x %02x %02x %02x %02x %02x %02x %02x",scrollx,deco16_io_ram[0],deco16_io_ram[1],deco16_io_ram[2],deco16_io_ram[3]
539553//  ,deco16_io_ram[4],deco16_io_ram[5],deco16_io_ram[6],deco16_io_ram[7]);
540554
541   for (offs = 0;offs < 0x400;offs++)
555   for (offs = 0; offs < 0x400; offs++)
542556   {
543      tile=videoram[offs]+((colorram[offs]&0x3)<<8);
557      tile = videoram[offs] + ((colorram[offs] & 0x3) << 8);
544558
545      if(state->io_ram[0]&0x40) //dynamic ram-based gfxs for Pro Golf
559      if(state->io_ram[0] & 0x40) //dynamic ram-based gfxs for Pro Golf
546560         gfx_region = 3;
547561      else
548         gfx_region = ((state->io_ram[0]&0x30)>>4);
562         gfx_region = ((state->io_ram[0] & 0x30) >> 4);
549563
550564      my = (offs) % 32;
551565      mx = (offs) / 32;
552566
553      drawgfx_transpen(bitmap,cliprect,screen->machine->gfx[gfx_region],
554            tile,1,0,0,248-8*mx,8*my,0);
567      drawgfx_transpen(bitmap, cliprect,screen->machine->gfx[gfx_region],
568            tile, 1, 0, 0, 248 - 8 * mx, 8 * my, 0);
555569   }
556570
557   prosport_draw_sprites(screen->machine,bitmap,cliprect);
571   prosport_draw_sprites(screen->machine, bitmap, cliprect);
558572
559573   return 0;
560574}
r7500r7501
562576VIDEO_UPDATE( boomrang )
563577{
564578   liberate_state *state = (liberate_state *)screen->machine->driver_data;
565   tilemap_set_scrolly(state->background_tilemap,0, state->io_ram[1]);
566   tilemap_set_scrollx(state->background_tilemap,0,-state->io_ram[0]);
579   tilemap_set_scrolly(state->back_tilemap, 0,  state->io_ram[1]);
580   tilemap_set_scrollx(state->back_tilemap, 0, -state->io_ram[0]);
567581
568582   if (state->background_disable)
569      bitmap_fill(bitmap,cliprect,32);
583      bitmap_fill(bitmap, cliprect, 32);
570584   else
571      tilemap_draw(bitmap,cliprect,state->background_tilemap,TILEMAP_DRAW_LAYER1,0);
585      tilemap_draw(bitmap, cliprect, state->back_tilemap, TILEMAP_DRAW_LAYER1, 0);
572586
573587   boomrang_draw_sprites(screen->machine,bitmap,cliprect,8);
574588   if (!state->background_disable)
575      tilemap_draw(bitmap,cliprect,state->background_tilemap,TILEMAP_DRAW_LAYER0,0);
576   boomrang_draw_sprites(screen->machine,bitmap,cliprect,0);
577   tilemap_draw(bitmap,cliprect,state->fix_tilemap,0,0);
589      tilemap_draw(bitmap, cliprect, state->back_tilemap, TILEMAP_DRAW_LAYER0, 0);
590
591   boomrang_draw_sprites(screen->machine, bitmap, cliprect, 0);
592   tilemap_draw(bitmap, cliprect, state->fix_tilemap, 0, 0);
578593   return 0;
579594}
580595
581596VIDEO_UPDATE( liberate )
582597{
583598   liberate_state *state = (liberate_state *)screen->machine->driver_data;
584   tilemap_set_scrolly(state->background_tilemap,0, state->io_ram[1]);
585   tilemap_set_scrollx(state->background_tilemap,0,-state->io_ram[0]);
599   tilemap_set_scrolly(state->back_tilemap, 0,  state->io_ram[1]);
600   tilemap_set_scrollx(state->back_tilemap, 0, -state->io_ram[0]);
586601
587602   if (state->background_disable)
588      bitmap_fill(bitmap,cliprect,32);
603      bitmap_fill(bitmap, cliprect, 32);
589604   else
590      tilemap_draw(bitmap,cliprect,state->background_tilemap,0,0);
605      tilemap_draw(bitmap, cliprect, state->back_tilemap, 0, 0);
591606
592   liberate_draw_sprites(screen->machine,bitmap,cliprect);
593   tilemap_draw(bitmap,cliprect,state->fix_tilemap,0,0);
607   liberate_draw_sprites(screen->machine, bitmap, cliprect);
608   tilemap_draw(bitmap, cliprect, state->fix_tilemap, 0, 0);
594609   return 0;
595610}
src/mame/video/rohga.c
r7500r7501
55***************************************************************************/
66
77#include "emu.h"
8#include "includes/deco16ic.h"
8#include "includes/rohga.h"
9#include "video/deco16ic.h"
910
10static UINT16 * rohga_spriteram;
1111
12/******************************************************************************/
13
1412WRITE16_HANDLER( rohga_buffer_spriteram16_w )
1513{
1614   // Spriteram seems to be triple buffered (no sprite lag on real pcb, but there
1715   // is on driver with only double buffering)
18   memcpy(rohga_spriteram, space->machine->generic.buffered_spriteram.u16, 0x800);
16   rohga_state *state = (rohga_state *)space->machine->driver_data;
17   memcpy(state->spriteram, space->machine->generic.buffered_spriteram.u16, 0x800);
1918   memcpy(space->machine->generic.buffered_spriteram.u16, space->machine->generic.spriteram.u16, 0x800);
2019}
2120
22static int wizdfire_bank_callback(const int bank)
23{
24   return ((bank>>4)&0x3)<<12;
25}
26
2721VIDEO_START( rohga )
2822{
29   rohga_spriteram = auto_alloc_array(machine, UINT16, 0x800/2);
30
31   deco16_2_video_init(machine, 0);
32
33   deco16_set_tilemap_bank_callback(0,wizdfire_bank_callback);
34   deco16_set_tilemap_bank_callback(1,wizdfire_bank_callback);
35   deco16_set_tilemap_bank_callback(2,wizdfire_bank_callback);
36   deco16_set_tilemap_bank_callback(3,wizdfire_bank_callback);
23   rohga_state *state = (rohga_state *)machine->driver_data;
24   state->spriteram = auto_alloc_array(machine, UINT16, 0x800/2);
25   state_save_register_global_pointer(machine, state->spriteram, 0x800/2);
3726}
3827
39VIDEO_START( wizdfire )
40{
41   deco16_2_video_init(machine, 0);
42
43   deco16_set_tilemap_bank_callback(0,wizdfire_bank_callback);
44   deco16_set_tilemap_bank_callback(1,wizdfire_bank_callback);
45   deco16_set_tilemap_bank_callback(2,wizdfire_bank_callback);
46   deco16_set_tilemap_bank_callback(3,wizdfire_bank_callback);
47
48   deco16_pf1_rowscroll=deco16_pf2_rowscroll=0;
49}
50
51VIDEO_START( nitrobal )
52{
53   deco16_2_video_init_half_width(machine);
54
55   deco16_set_tilemap_bank_callback(0,wizdfire_bank_callback);
56   deco16_set_tilemap_bank_callback(1,wizdfire_bank_callback);
57   deco16_set_tilemap_bank_callback(2,wizdfire_bank_callback);
58   deco16_set_tilemap_bank_callback(3,wizdfire_bank_callback);
59
60   deco16_set_tilemap_colour_base(2,0);
61   deco16_set_tilemap_colour_mask(2,0);
62   deco16_set_tilemap_colour_base(3,0);
63   deco16_set_tilemap_colour_mask(3,0);
64}
65
6628/******************************************************************************/
6729
68static void rohga_draw_sprites(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, const UINT16 *spriteptr, int is_schmeisr)
30static void rohga_draw_sprites( running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, const UINT16 *spriteptr, int is_schmeisr )
6931{
7032   int offs;
7133
72   for (offs = 0x400-4;offs >= 0;offs -= 4)
34   for (offs = 0x400 - 4; offs >= 0; offs -= 4)
7335   {
74      int x,y,sprite,colour,multi,fx,fy,inc,flash,mult,pri=0;
75      sprite = spriteptr[offs+1];
76      if (!sprite) continue;
36      int x, y, sprite, colour, multi, fx, fy, inc, flash, mult, pri = 0;
37      sprite = spriteptr[offs + 1];
38      if (!sprite)
39         continue;
7740
78      x = spriteptr[offs+2];
41      x = spriteptr[offs + 2];
7942
8043      /* Sprite/playfield priority */
81      switch (x&0x6000) {
82      case 0x0000: pri=0; break;
83      case 0x4000: pri=0xf0; break;
84      case 0x6000: pri=0xf0|0xcc; break;
85      case 0x2000: pri=0;//0xf0|0xcc; break; /* Perhaps 0xf0|0xcc|0xaa (Sprite under bottom layer) */
44      switch (x & 0x6000)
45      {
46      case 0x0000: pri = 0; break;
47      case 0x4000: pri = 0xf0; break;
48      case 0x6000: pri = 0xf0 | 0xcc; break;
49      case 0x2000: pri = 0;//0xf0|0xcc; break; /* Perhaps 0xf0|0xcc|0xaa (Sprite under bottom layer) */
8650      }
8751
8852      y = spriteptr[offs];
89      flash=y&0x1000;
90      if (flash && (video_screen_get_frame_number(machine->primary_screen) & 1)) continue;
53      flash = y & 0x1000;
54      if (flash && (video_screen_get_frame_number(machine->primary_screen) & 1))
55         continue;
9156
9257      // Sprite colour is different between Rohga (6bpp) and Schmeisr (4bpp plus wire mods on pcb)
9358      if (is_schmeisr)
9459      {
95         colour = ((x >> 9) &0xf)<<2;
96         if (x&0x8000)
60         colour = ((x >> 9) & 0xf) << 2;
61         if (x & 0x8000)
9762            colour++;
9863      }
9964      else
10065      {
101         colour = (x >> 9) &0xf;
66         colour = (x >> 9) & 0xf;
10267      }
10368
10469      fx = y & 0x2000;
r7500r7501
11984         inc = 1;
12085      }
12186
122      if (flip_screen_get(machine)) {
123         x=304-x;
124         y=240-y;
125         if (fx) fx=0; else fx=1;
126         if (fy) fy=0; else fy=1;
127         mult=-16;
87      if (flip_screen_get(machine))
88      {
89         x = 304 - x;
90         y = 240 - y;
91         if (fx) fx = 0; else fx = 1;
92         if (fy) fy = 0; else fy = 1;
93         mult = -16;
12894      }
129      else mult=+16;
95      else
96         mult = +16;
13097
13198      while (multi >= 0)
13299      {
r7500r7501
142109   }
143110}
144111
145static void wizdfire_draw_sprites(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, UINT16 *spriteptr, int mode, int bank)
112static void wizdfire_draw_sprites( running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, UINT16 *spriteptr, int mode, int bank )
146113{
147114   int offs;
148115
149   for (offs = 0;offs < 0x400;offs += 4)
116   for (offs = 0; offs < 0x400; offs += 4)
150117   {
151      int x,y,sprite,colour,multi,fx,fy,inc,flash,mult;
152      int alpha=0xff;
118      int x, y, sprite, colour, multi, fx, fy, inc, flash, mult;
119      int alpha = 0xff;
153120
154      sprite = spriteptr[offs+1];
155      if (!sprite) continue;
121      sprite = spriteptr[offs + 1];
122      if (!sprite)
123         continue;
156124
157      x = spriteptr[offs+2];
125      x = spriteptr[offs + 2];
158126
159127      /*
160128        Sprite/playfield priority - we can't use pdrawgfx because we need alpha'd sprites overlaid
r7500r7501
163131        Hence, we rely on the hardware sorting everything correctly and not relying on any orthoganality
164132        effects (it doesn't seem to), and instead draw seperate passes for each sprite priority.  :(
165133        */
166      switch (mode) {
134      switch (mode)
135      {
167136      case 4:
168         if ((x&0xc000)!=0xc000)
137         if ((x & 0xc000) != 0xc000)
169138            continue;
170139         break;
171140      case 3:
172         if ((x&0xc000)!=0x8000)
141         if ((x & 0xc000) != 0x8000)
173142            continue;
174143         break;
175144      case 2:
176         if ((x&0x8000)!=0x8000)
145         if ((x & 0x8000) != 0x8000)
177146            continue;
178147         break;
179148      case 1:
180149      case 0:
181150      default:
182         if ((x&0x8000)!=0)
151         if ((x & 0x8000) != 0)
183152            continue;
184153         break;
185154      }
186155
187156      y = spriteptr[offs];
188      flash=y&0x1000;
189      if (flash && (video_screen_get_frame_number(machine->primary_screen) & 1)) continue;
190      colour = (x >> 9) &0x1f;
157      flash = y & 0x1000;
158      if (flash && (video_screen_get_frame_number(machine->primary_screen) & 1))
159         continue;
160      colour = (x >> 9) & 0x1f;
191161
192      if (bank==4 && colour&0x10) {
193         alpha=0x80;
194         colour&=0xf;
162      if (bank == 4 && colour & 0x10)
163      {
164         alpha = 0x80;
165         colour &= 0xf;
195166      }
196167
197168      fx = y & 0x2000;
r7500r7501
212183         inc = 1;
213184      }
214185
215      if (flip_screen_get(machine)) {
216         x=304-x;
217         y=240-y;
218         if (fx) fx=0; else fx=1;
219         if (fy) fy=0; else fy=1;
220         mult=-16;
186      if (flip_screen_get(machine))
187      {
188         x = 304 - x;
189         y = 240 - y;
190         if (fx) fx = 0; else fx = 1;
191         if (fy) fy = 0; else fy = 1;
192         mult = -16;
221193      }
222194      else
223         mult=+16;
195         mult = +16;
224196
225      if (fx) fx=0; else fx=1;
226      if (fy) fy=0; else fy=1;
197      if (fx) fx = 0; else fx = 1;
198      if (fy) fy = 0; else fy = 1;
227199
228200      while (multi >= 0)
229201      {
r7500r7501
239211   }
240212}
241213
242static void nitrobal_draw_sprites(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, const UINT16 *spriteptr, int gfxbank)
214static void nitrobal_draw_sprites( running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, const UINT16 *spriteptr, int gfxbank )
243215{
244   int offs,end,inc;
216   rohga_state *state = (rohga_state *)machine->driver_data;
217   int offs, end, inc;
218   UINT16 priority = deco16ic_priority_r(state->deco16ic, 0, 0xffff);
245219
246220   /*
247221        Alternate format from most 16 bit games - same as Captain America and Mutant Fighter
r7500r7501
272246            0xffff: Sprite value
273247    */
274248
275   offs=0x3fc;
276   end=-4;
277   inc=-4;
249   offs = 0x3fc;
250   end = -4;
251   inc = -4;
278252
279   while (offs!=end)
253   while (offs != end)
280254   {
281      int x,y,sprite,colour,fx,fy,w,h,sx,sy,x_mult,y_mult,tilemap_pri,sprite_pri;
282      int alpha=0xff;
255      int x, y, sprite, colour, fx, fy, w, h, sx, sy, x_mult, y_mult, tilemap_pri, sprite_pri;
256      int alpha = 0xff;
283257
284      sprite = spriteptr[offs+3];
285      if (!sprite) {
286         offs+=inc;
258      sprite = spriteptr[offs + 3];
259      if (!sprite)
260      {
261         offs += inc;
287262         continue;
288263      }
289264
290      sx = spriteptr[offs+1];
265      sx = spriteptr[offs + 1];
291266
292      h = (spriteptr[offs+2]&0xf000)>>12;
293      w = (spriteptr[offs+2]&0x0f00)>> 8;
267      h = (spriteptr[offs + 2] & 0xf000) >> 12;
268      w = (spriteptr[offs + 2] & 0x0f00) >>  8;
294269
295270      sy = spriteptr[offs];
296      if ((sy&0x2000) && (video_screen_get_frame_number(machine->primary_screen) & 1)) {
297         offs+=inc;
271      if ((sy & 0x2000) && (video_screen_get_frame_number(machine->primary_screen) & 1))
272      {
273         offs += inc;
298274         continue;
299275      }
300276
301      colour = (spriteptr[offs+2] >>0) & 0x1f;
277      colour = (spriteptr[offs + 2] >> 0) & 0x1f;
302278
303279      // PRIORITIES - TODO
304      if (gfxbank==3) {
280      if (gfxbank == 3)
281      {
305282         /* Sprite chip 1 */
306         switch (spriteptr[offs+2]&0xe0) {
307//          case 0xc0: colour=rand()%0xff; tilemap_pri=256; break; //todo
308         case 0xc0: tilemap_pri=8; break; //? under other sprites
309         case 0x80: tilemap_pri=32; break; //? under other sprites
310         case 0x20: tilemap_pri=32; break; /* Over pf2 and under other sprite chip */
311         case 0x40: tilemap_pri=8; break; /* Under pf2 and under other sprite chip */
312         case 0xa0: tilemap_pri=32; break;
283         switch (spriteptr[offs + 2] & 0xe0)
284         {
285//          case 0xc0: colour = rand()%0xff; tilemap_pri = 256; break; //todo
286         case 0xc0: tilemap_pri = 8; break; //? under other sprites
287         case 0x80: tilemap_pri = 32; break; //? under other sprites
288         case 0x20: tilemap_pri = 32; break; /* Over pf2 and under other sprite chip */
289         case 0x40: tilemap_pri = 8; break; /* Under pf2 and under other sprite chip */
290         case 0xa0: tilemap_pri = 32; break;
313291         case 0:
314            tilemap_pri=128; break;
292            tilemap_pri = 128; break;
315293         default:
316            tilemap_pri=128;
294            tilemap_pri = 128;
317295            break;
318296         }
319297
r7500r7501
364342
365343  */
366344
367         sprite_pri=1;
368      } else {
345         sprite_pri = 1;
346      }
347      else
348      {
369349         /* Sprite chip 2 (with alpha blending) */
370350
371351         /* Sprite above playfield 2, but still below other sprite chip */
372//          if (spriteptr[offs+2]&0x80)
373            tilemap_pri=64;
352//          if (spriteptr[offs + 2] & 0x80)
353            tilemap_pri = 64;
374354//          else
375//              tilemap_pri=8;
355//              tilemap_pri = 8;
376356
377         if (deco16_priority)
378            tilemap_pri=8;
357         if (priority)
358            tilemap_pri = 8;
379359         else
380            tilemap_pri=64;
360            tilemap_pri = 64;
381361
382         sprite_pri=2;
362         sprite_pri = 2;
383363      }
384364
385      if (gfxbank==4 && colour&0x10) {
386         alpha=0x80;
387         colour&=0xf;
365      if (gfxbank == 4 && colour & 0x10)
366      {
367         alpha = 0x80;
368         colour &= 0xf;
388369      }
389370
390      fx = (spriteptr[offs+0]&0x4000);
391      fy = (spriteptr[offs+0]&0x8000);
371      fx = (spriteptr[offs + 0] & 0x4000);
372      fy = (spriteptr[offs + 0] & 0x8000);
392373
393      if (!flip_screen_get(machine)) { /* Inverted from Mutant Fighter! */
394         if (fx) fx=0; else fx=1;
395         if (fy) fy=0; else fy=1;
374      if (!flip_screen_get(machine))
375      { /* Inverted from Mutant Fighter! */
376         if (fx) fx = 0; else fx = 1;
377         if (fy) fy = 0; else fy = 1;
396378
397379         sx = sx & 0x01ff;
398380         sy = sy & 0x01ff;
399         if (sx>0x180) sx=-(0x200 - sx);
400         if (sy>0x180) sy=-(0x200 - sy);
381         if (sx > 0x180) sx = -(0x200 - sx);
382         if (sy > 0x180) sy = -(0x200 - sy);
401383
402         if (fx) { x_mult=-16; sx+=16*w; } else { x_mult=16; sx-=16; }
403         if (fy) { y_mult=-16; sy+=16*h; } else { y_mult=16; sy-=16; }
404      } else {
384         if (fx) { x_mult = -16; sx += 16 * w; } else { x_mult = 16; sx -= 16; }
385         if (fy) { y_mult = -16; sy += 16 * h; } else { y_mult = 16; sy -= 16; }
386      }
387      else
388      {
405389         sx = sx & 0x01ff;
406390         sy = sy & 0x01ff;
407         if (sx&0x100) sx=-(0x100 - (sx&0xff));
408         if (sy&0x100) sy=-(0x100 - (sy&0xff));
391         if (sx & 0x100) sx = -(0x100 - (sx & 0xff));
392         if (sy & 0x100) sy = -(0x100 - (sy & 0xff));
409393         sx = 304 - sx;
410394         sy = 240 - sy;
411395         if (sx >= 432) sx -= 512;
412396         if (sy >= 384) sy -= 512;
413         if (fx) { x_mult=-16; sx+=16; } else { x_mult=16; sx-=16*w; }
414         if (fy) { y_mult=-16; sy+=16; } else { y_mult=16; sy-=16*h; }
397         if (fx) { x_mult = -16; sx += 16; } else { x_mult = 16; sx -= 16 * w; }
398         if (fy) { y_mult = -16; sy += 16; } else { y_mult = 16; sy -= 16 * h; }
415399      }
416400
417      for (x=0; x<w; x++) {
418         for (y=0; y<h; y++) {
419            deco16_pdrawgfx(
401      for (x = 0; x < w; x++)
402      {
403         for (y = 0; y < h; y++)
404         {
405            deco16ic_pdrawgfx(
406                  state->deco16ic,
420407                  bitmap,cliprect,machine->gfx[gfxbank],
421408                  sprite + y + h * x,
422409                  colour,
r7500r7501
426413         }
427414      }
428415
429      offs+=inc;
416      offs += inc;
430417   }
431418}
432419
433420/******************************************************************************/
434421
435static void update_rohga(running_device *screen, bitmap_t *bitmap, const rectangle *cliprect, int is_schmeisr)
422static void update_rohga( running_device *screen, bitmap_t *bitmap, const rectangle *cliprect, int is_schmeisr )
436423{
424   rohga_state *state = (rohga_state *)screen->machine->driver_data;
425   UINT16 flip = deco16ic_pf12_control_r(state->deco16ic, 0, 0xffff);
426   UINT16 priority = deco16ic_priority_r(state->deco16ic, 0, 0xffff);
427
437428   /* Update playfields */
438   flip_screen_set(screen->machine,  deco16_pf12_control[0]&0x80 );
439   deco16_pf12_update(deco16_pf1_rowscroll,deco16_pf2_rowscroll);
440   deco16_pf34_update(deco16_pf3_rowscroll,deco16_pf4_rowscroll);
429   flip_screen_set(screen->machine, BIT(flip, 7));
430   deco16ic_pf12_update(state->deco16ic, state->pf1_rowscroll, state->pf2_rowscroll);
431   deco16ic_pf34_update(state->deco16ic, state->pf3_rowscroll, state->pf4_rowscroll);
441432
442433   /* Draw playfields */
443   bitmap_fill(screen->machine->priority_bitmap,cliprect,0);
444   bitmap_fill(bitmap,cliprect,screen->machine->pens[768]);
434   bitmap_fill(screen->machine->priority_bitmap, cliprect, 0);
435   bitmap_fill(bitmap, cliprect, screen->machine->pens[768]);
445436
446   switch (deco16_priority&3)
437   switch (priority & 3)
447438   {
448439   case 0:
449      if (deco16_priority&4)
440      if (priority & 4)
450441      {
451442         // Draw as 1 8BPP layer
452         deco16_tilemap_34_combine_draw(screen,bitmap,cliprect,TILEMAP_DRAW_OPAQUE,3);
443         deco16ic_tilemap_34_combine_draw(state->deco16ic, bitmap, cliprect, TILEMAP_DRAW_OPAQUE, 3);
453444      }
454445      else
455446      {
456447         // Draw as 2 4BPP layers
457         deco16_tilemap_4_draw(screen,bitmap,cliprect,TILEMAP_DRAW_OPAQUE,1);
458         deco16_tilemap_3_draw(screen,bitmap,cliprect,0,2);
448         deco16ic_tilemap_4_draw(state->deco16ic, bitmap, cliprect, TILEMAP_DRAW_OPAQUE, 1);
449         deco16ic_tilemap_3_draw(state->deco16ic, bitmap, cliprect, 0, 2);
459450      }
460      deco16_tilemap_2_draw(screen,bitmap,cliprect,0,4);
451      deco16ic_tilemap_2_draw(state->deco16ic, bitmap, cliprect, 0, 4);
461452      break;
462453   case 1:
463      deco16_tilemap_4_draw(screen,bitmap,cliprect,TILEMAP_DRAW_OPAQUE,1);
464      deco16_tilemap_2_draw(screen,bitmap,cliprect,0,2);
465      deco16_tilemap_3_draw(screen,bitmap,cliprect,0,4);
454      deco16ic_tilemap_4_draw(state->deco16ic, bitmap, cliprect, TILEMAP_DRAW_OPAQUE, 1);
455      deco16ic_tilemap_2_draw(state->deco16ic, bitmap, cliprect, 0, 2);
456      deco16ic_tilemap_3_draw(state->deco16ic, bitmap, cliprect, 0, 4);
466457      break;
467458   case 2:
468      deco16_tilemap_2_draw(screen,bitmap,cliprect,TILEMAP_DRAW_OPAQUE,1);
469      deco16_tilemap_4_draw(screen,bitmap,cliprect,0,2);
470      deco16_tilemap_3_draw(screen,bitmap,cliprect,0,4);
459      deco16ic_tilemap_2_draw(state->deco16ic, bitmap, cliprect, TILEMAP_DRAW_OPAQUE, 1);
460      deco16ic_tilemap_4_draw(state->deco16ic, bitmap, cliprect, 0, 2);
461      deco16ic_tilemap_3_draw(state->deco16ic, bitmap, cliprect, 0, 4);
471462      break;
472463   }
473464
474   rohga_draw_sprites(screen->machine,bitmap,cliprect,rohga_spriteram,is_schmeisr);
475   deco16_tilemap_1_draw(screen,bitmap,cliprect,0,0);
465   rohga_draw_sprites(screen->machine, bitmap, cliprect, state->spriteram, is_schmeisr);
466   deco16ic_tilemap_1_draw(state->deco16ic, bitmap, cliprect, 0, 0);
476467}
477468
478469VIDEO_UPDATE( rohga )
r7500r7501
491482
492483VIDEO_UPDATE( wizdfire )
493484{
485   rohga_state *state = (rohga_state *)screen->machine->driver_data;
486   UINT16 flip = deco16ic_pf12_control_r(state->deco16ic, 0, 0xffff);
487   UINT16 priority = deco16ic_priority_r(state->deco16ic, 0, 0xffff);
488
494489   /* Update playfields */
495   flip_screen_set(screen->machine,  deco16_pf12_control[0]&0x80 );
496   deco16_pf12_update(deco16_pf1_rowscroll,deco16_pf2_rowscroll);
497   deco16_pf34_update(deco16_pf3_rowscroll,deco16_pf4_rowscroll);
490   flip_screen_set(screen->machine, BIT(flip, 7));
491   deco16ic_pf12_update(state->deco16ic, 0, 0);
492   deco16ic_pf34_update(state->deco16ic, state->pf3_rowscroll, state->pf4_rowscroll);
498493
499494   /* Draw playfields - Palette of 2nd playfield chip visible if playfields turned off */
500   bitmap_fill(bitmap,cliprect,screen->machine->pens[512]);
495   bitmap_fill(bitmap, cliprect, screen->machine->pens[512]);
501496
502   deco16_tilemap_4_draw(screen,bitmap,cliprect,TILEMAP_DRAW_OPAQUE,0);
503   wizdfire_draw_sprites(screen->machine,bitmap,cliprect,screen->machine->generic.buffered_spriteram.u16,4,3);
504   deco16_tilemap_2_draw(screen,bitmap,cliprect,0,0);
505   wizdfire_draw_sprites(screen->machine,bitmap,cliprect,screen->machine->generic.buffered_spriteram.u16,3,3);
497   deco16ic_tilemap_4_draw(state->deco16ic, bitmap, cliprect, TILEMAP_DRAW_OPAQUE, 0);
498   wizdfire_draw_sprites(screen->machine, bitmap, cliprect, screen->machine->generic.buffered_spriteram.u16, 4, 3);
499   deco16ic_tilemap_2_draw(state->deco16ic, bitmap, cliprect, 0, 0);
500   wizdfire_draw_sprites(screen->machine, bitmap, cliprect, screen->machine->generic.buffered_spriteram.u16, 3, 3);
506501
507   if ((deco16_priority&0x1f)==0x1f) /* Wizdfire has bit 0x40 always set, Dark Seal 2 doesn't?! */
508      deco16_tilemap_3_draw(screen,bitmap,cliprect,TILEMAP_DRAW_ALPHA(0x80),0);
502   if ((priority & 0x1f) == 0x1f) /* Wizdfire has bit 0x40 always set, Dark Seal 2 doesn't?! */
503      deco16ic_tilemap_3_draw(state->deco16ic, bitmap, cliprect, TILEMAP_DRAW_ALPHA(0x80), 0);
509504   else
510      deco16_tilemap_3_draw(screen,bitmap,cliprect,0,0);
505      deco16ic_tilemap_3_draw(state->deco16ic, bitmap, cliprect, 0, 0);
511506
512507   /* See notes in wizdfire_draw_sprites about this */
513   wizdfire_draw_sprites(screen->machine,bitmap,cliprect,screen->machine->generic.buffered_spriteram.u16,0,3);
514   wizdfire_draw_sprites(screen->machine,bitmap,cliprect,screen->machine->generic.buffered_spriteram2.u16,2,4);
515   wizdfire_draw_sprites(screen->machine,bitmap,cliprect,screen->machine->generic.buffered_spriteram2.u16,1,4);
508   wizdfire_draw_sprites(screen->machine, bitmap, cliprect, screen->machine->generic.buffered_spriteram.u16,  0, 3);
509   wizdfire_draw_sprites(screen->machine, bitmap, cliprect, screen->machine->generic.buffered_spriteram2.u16, 2, 4);
510   wizdfire_draw_sprites(screen->machine, bitmap, cliprect, screen->machine->generic.buffered_spriteram2.u16, 1, 4);
516511
517   deco16_tilemap_1_draw(screen,bitmap,cliprect,0,0);
512   deco16ic_tilemap_1_draw(state->deco16ic, bitmap, cliprect, 0, 0);
518513   return 0;
519514}
520515
521516VIDEO_UPDATE( nitrobal )
522517{
518   rohga_state *state = (rohga_state *)screen->machine->driver_data;
519   UINT16 flip = deco16ic_pf12_control_r(state->deco16ic, 0, 0xffff);
520
523521   /* Update playfields */
524   flip_screen_set(screen->machine,  deco16_pf12_control[0]&0x80 );
525   deco16_pf12_update(deco16_pf1_rowscroll,deco16_pf2_rowscroll);
526   deco16_pf34_update(deco16_pf3_rowscroll,deco16_pf4_rowscroll);
522   flip_screen_set(screen->machine, BIT(flip, 7));
523   deco16ic_pf12_update(state->deco16ic, state->pf1_rowscroll, state->pf2_rowscroll);
524   deco16ic_pf34_update(state->deco16ic, state->pf3_rowscroll, state->pf4_rowscroll);
527525
528526   /* Draw playfields - Palette of 2nd playfield chip visible if playfields turned off */
529   bitmap_fill(bitmap,cliprect,screen->machine->pens[512]);
530   bitmap_fill(screen->machine->priority_bitmap,NULL,0);
531   deco16_clear_sprite_priority_bitmap();
527   bitmap_fill(bitmap, cliprect, screen->machine->pens[512]);
528   bitmap_fill(screen->machine->priority_bitmap, NULL, 0);
529   deco16ic_clear_sprite_priority_bitmap(state->deco16ic);
532530
533531   /* pf3 and pf4 are combined into a single 8bpp bitmap */
534   deco16_tilemap_34_combine_draw(screen,bitmap,cliprect,TILEMAP_DRAW_OPAQUE,0);
532   deco16ic_tilemap_34_combine_draw(state->deco16ic, bitmap, cliprect, TILEMAP_DRAW_OPAQUE, 0);
535533
536   deco16_tilemap_2_draw(screen,bitmap,cliprect,0,16);
537   nitrobal_draw_sprites(screen->machine,bitmap,cliprect,screen->machine->generic.buffered_spriteram.u16,3);
538   nitrobal_draw_sprites(screen->machine,bitmap,cliprect,screen->machine->generic.buffered_spriteram2.u16,4);
534   deco16ic_tilemap_2_draw(state->deco16ic, bitmap, cliprect, 0, 16);
535   nitrobal_draw_sprites(screen->machine, bitmap, cliprect, screen->machine->generic.buffered_spriteram.u16, 3);
536   nitrobal_draw_sprites(screen->machine, bitmap, cliprect, screen->machine->generic.buffered_spriteram2.u16, 4);
539537
540   deco16_tilemap_1_draw(screen,bitmap,cliprect,0,0);
538   deco16ic_tilemap_1_draw(state->deco16ic, bitmap, cliprect, 0, 0);
541539   return 0;
542540}
src/mame/video/nemesis.c
r7500r7501
88#include "includes/nemesis.h"
99
1010
11UINT16 *nemesis_videoram1;
12UINT16 *nemesis_videoram2;
13UINT16 *nemesis_colorram1;
14UINT16 *nemesis_colorram2;
15UINT16 *nemesis_characterram;
16size_t nemesis_characterram_size;
17UINT16 *nemesis_xscroll1, *nemesis_xscroll2;
18UINT16 *nemesis_yscroll1, *nemesis_yscroll2;
19
20static int spriteram_words;
21static int tilemap_flip;
22static int flipscreen;
23static UINT8 irq_port_last;
24
25static tilemap_t *background, *foreground;
26
2711static const struct
2812{
2913   UINT8 width;
r7500r7501
3620   {  8,  8, 0 }, { 16,  8, 6 }, {  8, 16, 3 }, { 16, 16, 1 }
3721};
3822
39static UINT8 blank_tile[8*8];
4023
41
4224static TILE_GET_INFO( get_bg_tile_info )
4325{
44   int code,color,flags,mask,layer;
26   nemesis_state *state = (nemesis_state *)machine->driver_data;
27   int code, color, flags, mask, layer;
4528
46   code = nemesis_videoram2[tile_index];
47   color = nemesis_colorram2[tile_index];
29   code = state->videoram2[tile_index];
30   color = state->colorram2[tile_index];
4831   flags = 0;
4932
50   if (color & 0x80) flags |= TILE_FLIPX;
51   if (code & 0x0800) flags |= TILE_FLIPY;
33   if (color & 0x80)
34      flags |= TILE_FLIPX;
35
36   if (code & 0x0800)
37      flags |= TILE_FLIPY;
38
5239   if ((~code & 0x2000) || ((code & 0xc000) == 0x4000))
5340       flags |= TILE_FORCE_LAYER0;      /* no transparency */
54   if (code & 0xf800) {
41
42   if (code & 0xf800)
43   {
5544      SET_TILE_INFO( 0, code & 0x7ff, color & 0x7f, flags );
56   } else {
45   }
46   else
47   {
5748      SET_TILE_INFO( 0, 0, 0x00, 0 );
58      tileinfo->pen_data = blank_tile;
49      tileinfo->pen_data = state->blank_tile;
5950   }
6051
6152   mask = (code & 0x1000) >> 12;
r7500r7501
6859
6960static TILE_GET_INFO( get_fg_tile_info )
7061{
71   int code,color,flags,mask,layer;
62   nemesis_state *state = (nemesis_state *)machine->driver_data;
63   int code, color, flags, mask, layer;
7264
73   code = nemesis_videoram1[tile_index];
74   color = nemesis_colorram1[tile_index];
65   code = state->videoram1[tile_index];
66   color = state->colorram1[tile_index];
7567   flags = 0;
7668
77   if (color & 0x80) flags |= TILE_FLIPX;
78   if (code & 0x0800) flags |= TILE_FLIPY;
69   if (color & 0x80)
70      flags |= TILE_FLIPX;
71
72   if (code & 0x0800)
73      flags |= TILE_FLIPY;
74
7975   if ((~code & 0x2000) || ((code & 0xc000) == 0x4000))
8076       flags |= TILE_FORCE_LAYER0;      /* no transparency */
81   if (code & 0xf800) {
77
78   if (code & 0xf800)
79   {
8280      SET_TILE_INFO( 0, code & 0x7ff, color & 0x7f, flags );
83   } else {
81   }
82   else
83   {
8484      SET_TILE_INFO( 0, 0, 0x00, 0 );
85      tileinfo->pen_data = blank_tile;
85      tileinfo->pen_data = state->blank_tile;
8686   }
8787
8888   mask = (code & 0x1000) >> 12;
r7500r7501
9696
9797WRITE16_HANDLER( nemesis_gfx_flipx_word_w )
9898{
99   nemesis_state *state = (nemesis_state *)space->machine->driver_data;
100
99101   if (ACCESSING_BITS_0_7)
100102   {
101      flipscreen = data & 0x01;
103      state->flipscreen = data & 0x01;
102104
103105      if (data & 0x01)
104         tilemap_flip |= TILEMAP_FLIPX;
106         state->tilemap_flip |= TILEMAP_FLIPX;
105107      else
106         tilemap_flip &= ~TILEMAP_FLIPX;
108         state->tilemap_flip &= ~TILEMAP_FLIPX;
107109
108      tilemap_set_flip_all(space->machine, tilemap_flip);
110      tilemap_set_flip_all(space->machine, state->tilemap_flip);
109111   }
110112
111113   if (ACCESSING_BITS_8_15)
112114   {
113115      if (data & 0x0100)
114         cputag_set_input_line_and_vector(space->machine, "audiocpu", 0, HOLD_LINE, 0xff);
116         cpu_set_input_line_and_vector(state->audiocpu, 0, HOLD_LINE, 0xff);
115117   }
116118}
117119
118120WRITE16_HANDLER( nemesis_gfx_flipy_word_w )
119121{
122   nemesis_state *state = (nemesis_state *)space->machine->driver_data;
123
120124   if (ACCESSING_BITS_0_7)
121125   {
122126      if (data & 0x01)
123         tilemap_flip |= TILEMAP_FLIPY;
127         state->tilemap_flip |= TILEMAP_FLIPY;
124128      else
125         tilemap_flip &= ~TILEMAP_FLIPY;
129         state->tilemap_flip &= ~TILEMAP_FLIPY;
126130
127      tilemap_set_flip_all(space->machine, tilemap_flip);
131      tilemap_set_flip_all(space->machine, state->tilemap_flip);
128132   }
129133}
130134
131135
132136WRITE16_HANDLER( salamand_control_port_word_w )
133137{
138   nemesis_state *state = (nemesis_state *)space->machine->driver_data;
139
134140   if (ACCESSING_BITS_0_7)
135141   {
136      UINT8 accessing_bits = data ^ irq_port_last;
142      UINT8 accessing_bits = data ^ state->irq_port_last;
137143
138      nemesis_irq_on = data & 0x01;
139      nemesis_irq2_on = data & 0x02;
140      flipscreen = data & 0x04;
144      state->irq_on = data & 0x01;
145      state->irq2_on = data & 0x02;
146      state->flipscreen = data & 0x04;
141147
142148      if (data & 0x04)
143         tilemap_flip |= TILEMAP_FLIPX;
149         state->tilemap_flip |= TILEMAP_FLIPX;
144150      else
145         tilemap_flip &= ~TILEMAP_FLIPX;
151         state->tilemap_flip &= ~TILEMAP_FLIPX;
146152
147153      if (data & 0x08)
148         tilemap_flip |= TILEMAP_FLIPY;
154         state->tilemap_flip |= TILEMAP_FLIPY;
149155      else
150         tilemap_flip &= ~TILEMAP_FLIPY;
156         state->tilemap_flip &= ~TILEMAP_FLIPY;
151157
152158      if (accessing_bits & 0x0c)
153         tilemap_set_flip_all(space->machine, tilemap_flip);
159         tilemap_set_flip_all(space->machine, state->tilemap_flip);
154160
155      irq_port_last = data;
161      state->irq_port_last = data;
156162   }
157163
158164   if (ACCESSING_BITS_8_15)
r7500r7501
161167      coin_lockout_w(space->machine, 1, data & 0x0400);
162168
163169      if (data & 0x0800)
164         cputag_set_input_line(space->machine, "audiocpu", 0, HOLD_LINE);
170         cpu_set_input_line(state->audiocpu, 0, HOLD_LINE);
165171
166      hcrash_selected_ip = (~data & 0x1000) >> 12;      /* citybomb steering & accel */
172      state->selected_ip = (~data & 0x1000) >> 12;      /* citybomb steering & accel */
167173   }
168174}
169175
170176
171177WRITE16_HANDLER( nemesis_palette_word_w )
172178{
173   int r,g,b,bit1,bit2,bit3,bit4,bit5;
179   nemesis_state *state = (nemesis_state *)space->machine->driver_data;
180   int r, g, b, bit1, bit2, bit3, bit4, bit5;
174181
175   COMBINE_DATA(space->machine->generic.paletteram.u16 + offset);
176   data = space->machine->generic.paletteram.u16[offset];
182   COMBINE_DATA(state->paletteram + offset);
183   data = state->paletteram[offset];
177184
178185   /* Mish, 30/11/99 - Schematics show the resistor values are:
179186        300 Ohms
r7500r7501
187194
188195   #define MULTIPLIER 8 * bit1 + 17 * bit2 + 33 * bit3 + 67 * bit4 + 130 * bit5
189196
190   bit1=(data >>  0)&1;
191   bit2=(data >>  1)&1;
192   bit3=(data >>  2)&1;
193   bit4=(data >>  3)&1;
194   bit5=(data >>  4)&1;
197   bit1 = BIT(data, 0);
198   bit2 = BIT(data, 1);
199   bit3 = BIT(data, 2);
200   bit4 = BIT(data, 3);
201   bit5 = BIT(data, 4);
195202   r = MULTIPLIER;
196   r = pow (r/255.0, 2)*255;
197   bit1=(data >>  5)&1;
198   bit2=(data >>  6)&1;
199   bit3=(data >>  7)&1;
200   bit4=(data >>  8)&1;
201   bit5=(data >>  9)&1;
203   r = pow(r/255.0, 2)*255;
204   bit1 = BIT(data, 5);
205   bit2 = BIT(data, 6);
206   bit3 = BIT(data, 7);
207   bit4 = BIT(data, 8);
208   bit5 = BIT(data, 9);
202209   g = MULTIPLIER;
203   g = pow (g/255.0, 2)*255;
204   bit1=(data >>  10)&1;
205   bit2=(data >>  11)&1;
206   bit3=(data >>  12)&1;
207   bit4=(data >>  13)&1;
208   bit5=(data >>  14)&1;
210   g = pow(g/255.0, 2)*255;
211   bit1 = BIT(data, 10);
212   bit2 = BIT(data, 11);
213   bit3 = BIT(data, 12);
214   bit4 = BIT(data, 13);
215   bit5 = BIT(data, 14);
209216   b = MULTIPLIER;
210   b = pow (b/255.0, 2)*255;
217   b = pow(b/255.0, 2)*255;
211218
212   palette_set_color(space->machine,offset,MAKE_RGB(r,g,b));
219   palette_set_color(space->machine, offset, MAKE_RGB(r, g, b));
213220}
214221
215222WRITE16_HANDLER( salamander_palette_word_w )
216223{
217   COMBINE_DATA(space->machine->generic.paletteram.u16 + offset);
224   nemesis_state *state = (nemesis_state *)space->machine->driver_data;
225
226   COMBINE_DATA(state->paletteram + offset);
218227   offset &= ~1;
219228
220   data = ((space->machine->generic.paletteram.u16[offset] << 8) & 0xff00) | (space->machine->generic.paletteram.u16[offset+1] & 0xff);
221   palette_set_color_rgb(space->machine,offset / 2,pal5bit(data >> 0),pal5bit(data >> 5),pal5bit(data >> 10));
229   data = ((state->paletteram[offset] << 8) & 0xff00) | (state->paletteram[offset + 1] & 0xff);
230   palette_set_color_rgb(space->machine, offset / 2, pal5bit(data >> 0), pal5bit(data >> 5), pal5bit(data >> 10));
222231}
223232
224233
225234WRITE16_HANDLER( nemesis_videoram1_word_w )
226235{
227   COMBINE_DATA(nemesis_videoram1 + offset);
228   tilemap_mark_tile_dirty( foreground, offset );
236   nemesis_state *state = (nemesis_state *)space->machine->driver_data;
237
238   COMBINE_DATA(state->videoram1 + offset);
239   tilemap_mark_tile_dirty(state->foreground, offset);
229240}
230241
231242WRITE16_HANDLER( nemesis_videoram2_word_w )
232243{
233   COMBINE_DATA(nemesis_videoram2 + offset);
234   tilemap_mark_tile_dirty( background, offset );
244   nemesis_state *state = (nemesis_state *)space->machine->driver_data;
245
246   COMBINE_DATA(state->videoram2 + offset);
247   tilemap_mark_tile_dirty(state->background, offset);
235248}
236249
237250WRITE16_HANDLER( nemesis_colorram1_word_w )
238251{
239   COMBINE_DATA(nemesis_colorram1 + offset);
240   tilemap_mark_tile_dirty( foreground, offset );
252   nemesis_state *state = (nemesis_state *)space->machine->driver_data;
253
254   COMBINE_DATA(state->colorram1 + offset);
255   tilemap_mark_tile_dirty(state->foreground, offset);
241256}
242257
243258WRITE16_HANDLER( nemesis_colorram2_word_w )
244259{
245   COMBINE_DATA(nemesis_colorram2 + offset);
246   tilemap_mark_tile_dirty( background, offset );
260   nemesis_state *state = (nemesis_state *)space->machine->driver_data;
261
262   COMBINE_DATA(state->colorram2 + offset);
263   tilemap_mark_tile_dirty(state->background, offset);
247264}
248265
249266
250267/* we have to straighten out the 16-bit word into bytes for gfxdecode() to work */
251WRITE16_HANDLER( nemesis_characterram_word_w )
268WRITE16_HANDLER( nemesis_charram_word_w )
252269{
253   UINT16 oldword = nemesis_characterram[offset];
254   COMBINE_DATA(nemesis_characterram + offset);
255   data = nemesis_characterram[offset];
270   nemesis_state *state = (nemesis_state *)space->machine->driver_data;
271   UINT16 oldword = state->charram[offset];
256272
273   COMBINE_DATA(state->charram + offset);
274   data = state->charram[offset];
275
257276   if (oldword != data)
258277   {
259278      int i;
260      for (i=0; i<8; i++)
279      for (i = 0; i < 8; i++)
261280      {
262281         int w = sprite_data[i].width;
263282         int h = sprite_data[i].height;
r7500r7501
269288
270289static STATE_POSTLOAD( nemesis_postload )
271290{
272   int i,offs;
291   nemesis_state *state = (nemesis_state *)machine->driver_data;
292   int i, offs;
273293
274   for (offs=0; offs<nemesis_characterram_size; offs++)
294   for (offs = 0; offs < state->charram_size; offs++)
275295   {
276      for (i=0; i<8; i++)
296      for (i = 0; i < 8; i++)
277297      {
278298         int w = sprite_data[i].width;
279299         int h = sprite_data[i].height;
280300         gfx_element_mark_dirty(machine->gfx[sprite_data[i].char_type], offs * 4 / (w * h));
281301      }
282302   }
283   tilemap_mark_all_tiles_dirty(background);
284   tilemap_mark_all_tiles_dirty(foreground);
303   tilemap_mark_all_tiles_dirty(state->background);
304   tilemap_mark_all_tiles_dirty(state->foreground);
285305}
286306
287307
288308/* claim a palette dirty array */
289309VIDEO_START( nemesis )
290310{
291   spriteram_words = machine->generic.spriteram_size / 2;
311   nemesis_state *state = (nemesis_state *)machine->driver_data;
292312
293   background = tilemap_create(machine,
294      get_bg_tile_info, tilemap_scan_rows,  8,8, 64,32 );
313   state->spriteram_words = state->spriteram_size / 2;
295314
296   foreground = tilemap_create(machine,
297      get_fg_tile_info, tilemap_scan_rows,  8,8, 64,32 );
315   state->background = tilemap_create(machine, get_bg_tile_info, tilemap_scan_rows,  8, 8, 64, 32);
316   state->foreground = tilemap_create(machine, get_fg_tile_info, tilemap_scan_rows,  8, 8, 64, 32);
298317
299   tilemap_set_transparent_pen( background, 0 );
300   tilemap_set_transparent_pen( foreground, 0 );
301   tilemap_set_scroll_rows( background, 256 );
302   tilemap_set_scroll_rows( foreground, 256 );
318   tilemap_set_transparent_pen(state->background, 0);
319   tilemap_set_transparent_pen(state->foreground, 0);
320   tilemap_set_scroll_rows(state->background, 256);
321   tilemap_set_scroll_rows(state->foreground, 256);
303322
304   memset(nemesis_characterram, 0, nemesis_characterram_size);
323   memset(state->charram, 0, state->charram_size);
324   memset(state->blank_tile, 0, ARRAY_LENGTH(state->blank_tile));
305325
306   gfx_element_set_source(machine->gfx[0], (UINT8 *)nemesis_characterram);
307   gfx_element_set_source(machine->gfx[1], (UINT8 *)nemesis_characterram);
308   gfx_element_set_source(machine->gfx[2], (UINT8 *)nemesis_characterram);
309   gfx_element_set_source(machine->gfx[3], (UINT8 *)nemesis_characterram);
310   gfx_element_set_source(machine->gfx[4], (UINT8 *)nemesis_characterram);
311   gfx_element_set_source(machine->gfx[5], (UINT8 *)nemesis_characterram);
312   gfx_element_set_source(machine->gfx[6], (UINT8 *)nemesis_characterram);
313   gfx_element_set_source(machine->gfx[7], (UINT8 *)nemesis_characterram);
326   gfx_element_set_source(machine->gfx[0], (UINT8 *)state->charram);
327   gfx_element_set_source(machine->gfx[1], (UINT8 *)state->charram);
328   gfx_element_set_source(machine->gfx[2], (UINT8 *)state->charram);
329   gfx_element_set_source(machine->gfx[3], (UINT8 *)state->charram);
330   gfx_element_set_source(machine->gfx[4], (UINT8 *)state->charram);
331   gfx_element_set_source(machine->gfx[5], (UINT8 *)state->charram);
332   gfx_element_set_source(machine->gfx[6], (UINT8 *)state->charram);
333   gfx_element_set_source(machine->gfx[7], (UINT8 *)state->charram);
314334
315   flipscreen = 0;
316   tilemap_flip = 0;
317   irq_port_last = 0;
318
319335   /* Set up save state */
320   state_save_register_global(machine, spriteram_words);
321   state_save_register_global(machine, tilemap_flip);
322   state_save_register_global(machine, flipscreen);
323   state_save_register_global(machine, irq_port_last);
324336   state_save_register_postload(machine, nemesis_postload, NULL);
325337}
326338
327339
328static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect)
340static void draw_sprites( running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect )
329341{
330342   /*
331343     *  16 bytes per sprite, in memory from 56000-56fff
r7500r7501
342354     *  byte    E : not used.
343355     */
344356
345   UINT16 *spriteram16 = machine->generic.spriteram.u16;
357   nemesis_state *state = (nemesis_state *)machine->driver_data;
358   UINT16 *spriteram = state->spriteram;
346359   int adress;   /* start of sprite in spriteram */
347360   int sx;   /* sprite X-pos */
348361   int sy;   /* sprite Y-pos */
r7500r7501
356369   int w,h;
357370   int idx;
358371
359   for (priority=256-1; priority>=0; priority--)
372   for (priority = 256 - 1; priority >= 0; priority--)
360373   {
361      for (adress = spriteram_words-8; adress >= 0; adress -= 8)
374      for (adress = state->spriteram_words - 8; adress >= 0; adress -= 8)
362375      {
363         if((spriteram16[adress] & 0xff)!=priority) continue;
376         if((spriteram[adress] & 0xff) != priority)
377            continue;
364378
365         zoom = spriteram16[adress+2] & 0xff;
366         if (!(spriteram16[adress+2] & 0xff00) && ((spriteram16[adress+3] & 0xff00) != 0xff00))
367            code = spriteram16[adress+3] + ((spriteram16[adress+4] & 0xc0) << 2);
379         zoom = spriteram[adress + 2] & 0xff;
380         if (!(spriteram[adress + 2] & 0xff00) && ((spriteram[adress + 3] & 0xff00) != 0xff00))
381            code = spriteram[adress + 3] + ((spriteram[adress + 4] & 0xc0) << 2);
368382         else
369            code = (spriteram16[adress+3] & 0xff) + ((spriteram16[adress+4] & 0xc0) << 2);
383            code = (spriteram[adress + 3] & 0xff) + ((spriteram[adress + 4] & 0xc0) << 2);
370384
371         if (zoom != 0xFF || code!=0)
385         if (zoom != 0xff || code != 0)
372386         {
373            size = spriteram16[adress+1];
387            size = spriteram[adress + 1];
374388            zoom += (size & 0xc0) << 2;
375389
376            sx = spriteram16[adress+5] & 0xff;
377            sy = spriteram16[adress+6] & 0xff;
378            if (spriteram16[adress+4] & 0x01)
390            sx = spriteram[adress + 5] & 0xff;
391            sy = spriteram[adress + 6] & 0xff;
392            if (spriteram[adress + 4] & 0x01)
379393               sx-=0x100;   /* fixes left side clip */
380            color = (spriteram16[adress+4] & 0x1e) >> 1;
381            flipx = spriteram16[adress+1] & 0x01;
382            flipy = spriteram16[adress+4] & 0x20;
383394
395            color = (spriteram[adress + 4] & 0x1e) >> 1;
396            flipx = spriteram[adress + 1] & 0x01;
397            flipy = spriteram[adress + 4] & 0x20;
398
384399            idx = (size >> 3) & 7;
385400            w = sprite_data[idx].width;
386401            h = sprite_data[idx].height;
387402            code = code * 8 * 16 / (w * h);
388403            char_type = sprite_data[idx].char_type;
389404
390            if( zoom )
405            if (zoom)
391406            {
392               zoom = ((1<<16) * 0x80 / zoom) + 0x02ab;
393               if (flipscreen)
407               zoom = ((1 << 16) * 0x80 / zoom) + 0x02ab;
408               if (state->flipscreen)
394409               {
395410                  sx = 256 - ((zoom * w) >> 16) - sx;
396411                  sy = 256 - ((zoom * h) >> 16) - sy;
397412                  flipx = !flipx;
398413                  flipy = !flipy;
399414               }
415
400416               pdrawgfxzoom_transpen(bitmap,cliprect,machine->gfx[char_type],
401417                  code,
402418                  color,
r7500r7501
405421                  zoom,zoom,
406422                  machine->priority_bitmap,0xffcc,0 );
407423            }
408         } /* if sprite */
409      } /* for loop */
410   } /* priority */
424         }
425      }
426   }
411427}
412428
413429/******************************************************************************/
414430
415431VIDEO_UPDATE( nemesis )
416432{
433   nemesis_state *state = (nemesis_state *)screen->machine->driver_data;
417434   int offs;
418435   rectangle clip;
419436
420   bitmap_fill(screen->machine->priority_bitmap,cliprect,0);
421   bitmap_fill(bitmap,cliprect,0);
437   bitmap_fill(screen->machine->priority_bitmap, cliprect, 0);
438   bitmap_fill(bitmap, cliprect, 0);
422439
423440   clip.min_x = 0;
424441   clip.max_x = 255;
425442
426   tilemap_set_scroll_cols( background, 64 );
427   tilemap_set_scroll_cols( foreground, 64 );
428   tilemap_set_scroll_rows( background, 1 );
429   tilemap_set_scroll_rows( foreground, 1 );
443   tilemap_set_scroll_cols(state->background, 64);
444   tilemap_set_scroll_cols(state->foreground, 64);
445   tilemap_set_scroll_rows(state->background, 1);
446   tilemap_set_scroll_rows(state->foreground, 1);
430447
431448   for (offs = 0; offs < 64; offs++)
432449   {
433450      int offset_x = offs;
434451
435      if (flipscreen)
452      if (state->flipscreen)
436453         offset_x = (offs + 0x20) & 0x3f;
437454
438      tilemap_set_scrolly( background, offs, nemesis_yscroll2[offset_x] );
439      tilemap_set_scrolly( foreground, offs, nemesis_yscroll1[offset_x] );
455      tilemap_set_scrolly(state->background, offs, state->yscroll2[offset_x]);
456      tilemap_set_scrolly(state->foreground, offs, state->yscroll1[offset_x]);
440457   }
441458
442459   for (offs = cliprect->min_y; offs <= cliprect->max_y; offs++)
r7500r7501
447464      clip.min_y = offs;
448465      clip.max_y = offs;
449466
450      if (flipscreen)
467      if (state->flipscreen)
451468         offset_y = 255 - offs;
452469
453      tilemap_set_scrollx( background, 0, (nemesis_xscroll2[offset_y] & 0xff) + ((nemesis_xscroll2[0x100 + offset_y] & 0x01) << 8) - (flipscreen ? 0x107 : 0) );
454      tilemap_set_scrollx( foreground, 0, (nemesis_xscroll1[offset_y] & 0xff) + ((nemesis_xscroll1[0x100 + offset_y] & 0x01) << 8) - (flipscreen ? 0x107 : 0) );
470      tilemap_set_scrollx(state->background, 0, (state->xscroll2[offset_y] & 0xff) + ((state->xscroll2[0x100 + offset_y] & 0x01) << 8) - (state->flipscreen ? 0x107 : 0));
471      tilemap_set_scrollx(state->foreground, 0, (state->xscroll1[offset_y] & 0xff) + ((state->xscroll1[0x100 + offset_y] & 0x01) << 8) - (state->flipscreen ? 0x107 : 0));
455472
456      for (i=0; i<4; i+=2)
473      for (i = 0; i < 4; i += 2)
457474      {
458         tilemap_draw(bitmap, &clip, background, TILEMAP_DRAW_CATEGORY(i+0), 1);
459         tilemap_draw(bitmap, &clip, background, TILEMAP_DRAW_CATEGORY(i+1), 2);
460         tilemap_draw(bitmap, &clip, foreground, TILEMAP_DRAW_CATEGORY(i+0), 1);
461         tilemap_draw(bitmap, &clip, foreground, TILEMAP_DRAW_CATEGORY(i+1), 2);
475         tilemap_draw(bitmap, &clip, state->background, TILEMAP_DRAW_CATEGORY(i + 0), 1);
476         tilemap_draw(bitmap, &clip, state->background, TILEMAP_DRAW_CATEGORY(i + 1), 2);
477         tilemap_draw(bitmap, &clip, state->foreground, TILEMAP_DRAW_CATEGORY(i + 0), 1);
478         tilemap_draw(bitmap, &clip, state->foreground, TILEMAP_DRAW_CATEGORY(i + 1), 2);
462479      }
463480   }
464481
src/mame/video/deco16ic.c
r7500r7501
137137
138138    Column and rowscroll can both be applied at once.
139139
140
141    2010-02: Converted to be a device.
142    TODO:
143      - properly support PCBs with two ICs (i.e. no pf3/pf4 because they actually belong to a 2nd chip)
144      - move here emulation of the sprite chips (currently replicated in each driver)?
145
140146***************************************************************************/
141147
142148#include "emu.h"
143#include "includes/deco16ic.h"
149#include "video/deco16ic.h"
144150#include "ui.h"
145151
146UINT16 *deco16_pf1_data,*deco16_pf2_data;
147UINT16 *deco16_pf3_data,*deco16_pf4_data;
148UINT16 *deco16_pf1_rowscroll,*deco16_pf2_rowscroll;
149UINT16 *deco16_pf3_rowscroll,*deco16_pf4_rowscroll;
152#if 0
153void deco16ic_set_vram( const device_config *device, UINT8 *ram_bank )
154{
155   deco16ic_state *deco16ic = get_safe_token(device);
150156
151static const UINT16 *pf1_rowscroll_ptr, *pf2_rowscroll_ptr;
152static const UINT16 *pf3_rowscroll_ptr, *pf4_rowscroll_ptr;
157   deco16ic->vram = ram_bank;
158}
153159
154UINT16 *deco16_pf12_control,*deco16_pf34_control;
155UINT16 deco16_priority;
160UINT8 *deco16icvdp_get_vram( const device_config *device )
161{
162   deco16ic_state *deco16ic = get_safe_token(device);
156163
157UINT16 *deco16_raster_display_list;
158int deco16_raster_display_position;
164   return deco16ic->vram;
165}
166#endif
159167
160static int use_custom_pf1, use_custom_pf2, use_custom_pf3, use_custom_pf4;
161168
162static tilemap_t *pf1_tilemap_16x16,*pf2_tilemap_16x16,*pf3_tilemap_16x16,*pf4_tilemap_16x16;
163static tilemap_t *pf1_tilemap_8x8,*pf2_tilemap_8x8;
169typedef struct _deco16ic_state deco16ic_state;
170struct _deco16ic_state
171{
172   running_device *screen;
164173
165static bitmap_t *sprite_priority_bitmap;
174   UINT16 *pf1_data, *pf2_data;
175   UINT16 *pf3_data, *pf4_data;
176   UINT16 *pf12_control, *pf34_control;
177   UINT16 *raster_display_list;
178   UINT8 *dirty_palette;
166179
167static UINT8 *dirty_palette;
168static int deco16_pf1_bank,deco16_pf2_bank,deco16_pf3_bank,deco16_pf4_bank;
169static int deco16_pf12_16x16_gfx_bank,deco16_pf34_16x16_gfx_bank,deco16_pf12_8x8_gfx_bank;
170static int deco16_pf1_colourmask,deco16_pf2_colourmask,deco16_pf3_colourmask,deco16_pf4_colourmask;
171int deco16_pf1_colour_bank,deco16_pf2_colour_bank,deco16_pf3_colour_bank,deco16_pf4_colour_bank;
172static int deco16_pf1_trans_mask,deco16_pf2_trans_mask,deco16_pf3_trans_mask,deco16_pf4_trans_mask;
173static int (*deco16_bank_callback_1)(const int bank);
174static int (*deco16_bank_callback_2)(const int bank);
175static int (*deco16_bank_callback_3)(const int bank);
176static int (*deco16_bank_callback_4)(const int bank);
177static void custom_tilemap_draw(running_machine *machine,
178   bitmap_t *bitmap,tilemap_t *tilemap0_8x8,tilemap_t *tilemap0_16x16,
179   tilemap_t *tilemap1_8x8,tilemap_t *tilemap1_16x16, const UINT16 *rowscroll_ptr,const UINT16 scrollx,
180   const UINT16 scrolly,const UINT16 control0, const UINT16 control1,int combine_mask,int combine_shift,int trans_mask,int flags,UINT32 priority);
181static int pf12_last_small, pf12_last_big, pf34_last_big;
180   const UINT16 *pf1_rowscroll_ptr, *pf2_rowscroll_ptr;
181   const UINT16 *pf3_rowscroll_ptr, *pf4_rowscroll_ptr;
182182
183   tilemap_t *pf1_tilemap_16x16, *pf2_tilemap_16x16, *pf3_tilemap_16x16, *pf4_tilemap_16x16 ;
184   tilemap_t *pf1_tilemap_8x8, *pf2_tilemap_8x8;
185   bitmap_t *sprite_priority_bitmap;
183186
184/******************************************************************************/
187   deco16_bank_cb  bank_cb[4];
185188
189   UINT16 priority;
190
191   int raster_display_position;
192
193   int use_custom_pf1, use_custom_pf2, use_custom_pf3, use_custom_pf4;
194
195   int pf1_bank, pf2_bank, pf3_bank, pf4_bank;
196   int pf12_16x16_gfx_bank, pf34_16x16_gfx_bank, pf12_8x8_gfx_bank;
197   int pf1_colourmask, pf2_colourmask, pf3_colourmask, pf4_colourmask;
198   int pf1_colour_bank, pf2_colour_bank, pf3_colour_bank, pf4_colour_bank;
199   int pf1_trans_mask, pf2_trans_mask, pf3_trans_mask, pf4_trans_mask;
200
201   int pf12_last_small, pf12_last_big, pf34_last_big;
202};
203
204/*****************************************************************************
205    INLINE FUNCTIONS
206*****************************************************************************/
207
208INLINE deco16ic_state *get_safe_token( running_device *device )
209{
210   assert(device != NULL);
211   assert(device->token != NULL);
212   assert(device->type == DECO16IC);
213
214   return (deco16ic_state *)device->token;
215}
216
217INLINE const deco16ic_interface *get_interface( running_device *device )
218{
219   assert(device != NULL);
220   assert((device->type == DECO16IC));
221   return (const deco16ic_interface *) device->baseconfig().static_config;
222}
223
224/*****************************************************************************
225    DEVICE HANDLERS
226*****************************************************************************/
227
186228/* Later games have double buffered paletteram - the real palette ram is
187229only updated on a DMA call */
188230
189WRITE16_HANDLER( deco16_nonbuffered_palette_w )
231WRITE16_DEVICE_HANDLER( deco16ic_nonbuffered_palette_w )
190232{
191233   int r,g,b;
192234
193   COMBINE_DATA(&space->machine->generic.paletteram.u16[offset]);
235   COMBINE_DATA(&device->machine->generic.paletteram.u16[offset]);
194236   if (offset&1) offset--;
195237
196   b = (space->machine->generic.paletteram.u16[offset] >> 0) & 0xff;
197   g = (space->machine->generic.paletteram.u16[offset+1] >> 8) & 0xff;
198   r = (space->machine->generic.paletteram.u16[offset+1] >> 0) & 0xff;
238   b = (device->machine->generic.paletteram.u16[offset] >> 0) & 0xff;
239   g = (device->machine->generic.paletteram.u16[offset + 1] >> 8) & 0xff;
240   r = (device->machine->generic.paletteram.u16[offset + 1] >> 0) & 0xff;
199241
200   palette_set_color(space->machine,offset/2,MAKE_RGB(r,g,b));
242   palette_set_color(device->machine, offset / 2, MAKE_RGB(r,g,b));
201243}
202244
203WRITE16_HANDLER( deco16_buffered_palette_w )
245WRITE16_DEVICE_HANDLER( deco16ic_buffered_palette_w )
204246{
205   COMBINE_DATA(&space->machine->generic.paletteram.u16[offset]);
206   dirty_palette[offset/2]=1;
247   deco16ic_state *deco16ic = get_safe_token(device);
248
249   COMBINE_DATA(&device->machine->generic.paletteram.u16[offset]);
250
251   deco16ic->dirty_palette[offset / 2] = 1;
207252}
208253
209WRITE16_HANDLER( deco16_palette_dma_w )
254WRITE16_DEVICE_HANDLER( deco16ic_palette_dma_w )
210255{
211   const int m=space->machine->config->total_colors;
212   int r,g,b,i;
256   deco16ic_state *deco16ic = get_safe_token(device);
257   const int m = device->machine->config->total_colors;
258   int r, g, b, i;
213259
214   for (i=0; i<m; i++) {
215      if (dirty_palette[i]) {
216         dirty_palette[i]=0;
260   for (i = 0; i < m; i++)
261   {
262      if (deco16ic->dirty_palette[i])
263      {
264         deco16ic->dirty_palette[i] = 0;
217265
218         b = (space->machine->generic.paletteram.u16[i*2] >> 0) & 0xff;
219         g = (space->machine->generic.paletteram.u16[i*2+1] >> 8) & 0xff;
220         r = (space->machine->generic.paletteram.u16[i*2+1] >> 0) & 0xff;
266         b = (device->machine->generic.paletteram.u16[i * 2] >> 0) & 0xff;
267         g = (device->machine->generic.paletteram.u16[i * 2 + 1] >> 8) & 0xff;
268         r = (device->machine->generic.paletteram.u16[i * 2 + 1] >> 0) & 0xff;
221269
222         palette_set_color(space->machine,i,MAKE_RGB(r,g,b));
270         palette_set_color(device->machine, i, MAKE_RGB(r,g,b));
223271      }
224272   }
225273}
r7500r7501
227275/*****************************************************************************************/
228276
229277/* */
230READ16_HANDLER( deco16_71_r )
278READ16_DEVICE_HANDLER( deco16ic_71_r )
231279{
232280   return 0xffff;
233281}
234282
235WRITE16_HANDLER( deco16_priority_w )
283WRITE16_DEVICE_HANDLER( deco16ic_priority_w )
236284{
237   deco16_priority=data;
285   deco16ic_state *deco16ic = get_safe_token(device);
286   deco16ic->priority = data;
238287}
239288
289READ16_DEVICE_HANDLER( deco16ic_priority_r )
290{
291   deco16ic_state *deco16ic = get_safe_token(device);
292   return deco16ic->priority;
293}
294
295
240296/*****************************************************************************************/
241297
242298static TILEMAP_MAPPER( deco16_scan_rows )
r7500r7501
245301   return (col & 0x1f) + ((row & 0x1f) << 5) + ((col & 0x20) << 5) + ((row & 0x20) << 6);
246302}
247303
248static TILE_GET_INFO( get_pf4_tile_info )
304static TILE_GET_INFO_DEVICE( get_pf4_tile_info )
249305{
250   UINT16 tile=deco16_pf4_data[tile_index];
251   UINT8 colour=(tile>>12)&0xf;
252   UINT8 flags=0;
306   deco16ic_state *deco16ic = get_safe_token(device);
307   UINT16 tile = deco16ic->pf4_data[tile_index];
308   UINT8 colour = (tile >> 12) & 0xf;
309   UINT8 flags = 0;
253310
254   if (tile&0x8000) {
255      if ((deco16_pf34_control[6]>>8)&0x01) {
256         flags|=TILE_FLIPX;
257         colour&=0x7;
311   if (tile & 0x8000)
312   {
313      if ((deco16ic->pf34_control[6] >> 8) & 0x01)
314      {
315         flags |= TILE_FLIPX;
316         colour &= 0x7;
258317      }
259      if ((deco16_pf34_control[6]>>8)&0x02) {
318      if ((deco16ic->pf34_control[6] >> 8) & 0x02)
319      {
260320         flags|=TILE_FLIPY;
261         colour&=0x7;
321         colour &= 0x7;
262322      }
263323   }
264324
265   SET_TILE_INFO(
266         deco16_pf34_16x16_gfx_bank,
267         (tile&0xfff)|deco16_pf4_bank,
268         (colour&deco16_pf4_colourmask)+deco16_pf4_colour_bank,
325   SET_TILE_INFO_DEVICE(
326         deco16ic->pf34_16x16_gfx_bank,
327         (tile & 0xfff) | deco16ic->pf4_bank,
328         (colour & deco16ic->pf4_colourmask) + deco16ic->pf4_colour_bank,
269329         flags);
270330}
271331
272static TILE_GET_INFO( get_pf3_tile_info )
332static TILE_GET_INFO_DEVICE( get_pf3_tile_info )
273333{
274   UINT16 tile=deco16_pf3_data[tile_index];
275   UINT8 colour=(tile>>12)&0xf;
276   UINT8 flags=0;
334   deco16ic_state *deco16ic = get_safe_token(device);
335   UINT16 tile = deco16ic->pf3_data[tile_index];
336   UINT8 colour = (tile >> 12) & 0xf;
337   UINT8 flags = 0;
277338
278   if (tile&0x8000) {
279      if ((deco16_pf34_control[6]>>0)&0x01) {
280         flags|=TILE_FLIPX;
281         colour&=0x7;
339   if (tile & 0x8000)
340   {
341      if ((deco16ic->pf34_control[6] >> 0) & 0x01)
342      {
343         flags |= TILE_FLIPX;
344         colour &= 0x7;
282345      }
283      if ((deco16_pf34_control[6]>>0)&0x02) {
284         flags|=TILE_FLIPY;
285         colour&=0x7;
346      if ((deco16ic->pf34_control[6] >> 0) & 0x02)
347      {
348         flags |= TILE_FLIPY;
349         colour &= 0x7;
286350      }
287351   }
288352
289   SET_TILE_INFO(
290         deco16_pf34_16x16_gfx_bank,
291         (tile&0xfff)|deco16_pf3_bank,
292         (colour&deco16_pf3_colourmask)+deco16_pf3_colour_bank,
353   SET_TILE_INFO_DEVICE(
354         deco16ic->pf34_16x16_gfx_bank,
355         (tile & 0xfff) | deco16ic->pf3_bank,
356         (colour & deco16ic->pf3_colourmask) + deco16ic->pf3_colour_bank,
293357         flags);
294358}
295359
296static TILE_GET_INFO( get_pf2_tile_info )
360static TILE_GET_INFO_DEVICE( get_pf2_tile_info )
297361{
298   UINT16 tile=deco16_pf2_data[tile_index];
299   UINT8 colour=(tile>>12)&0xf;
300   UINT8 flags=0;
362   deco16ic_state *deco16ic = get_safe_token(device);
363   UINT16 tile = deco16ic->pf2_data[tile_index];
364   UINT8 colour = (tile >> 12) & 0xf;
365   UINT8 flags = 0;
301366
302   if (tile&0x8000) {
303      if ((deco16_pf12_control[6]>>8)&0x01) {
304         flags|=TILE_FLIPX;
305         colour&=0x7;
367   if (tile & 0x8000)
368   {
369      if ((deco16ic->pf12_control[6] >> 8) & 0x01)
370      {
371         flags |= TILE_FLIPX;
372         colour &= 0x7;
306373      }
307      if ((deco16_pf12_control[6]>>8)&0x02) {
308         flags|=TILE_FLIPY;
309         colour&=0x7;
374      if ((deco16ic->pf12_control[6] >> 8) & 0x02)
375      {
376         flags |= TILE_FLIPY;
377         colour &= 0x7;
310378      }
311379   }
312380
313   SET_TILE_INFO(
314         deco16_pf12_16x16_gfx_bank,
315         (tile&0xfff)|deco16_pf2_bank,
316         (colour&deco16_pf2_colourmask)+deco16_pf2_colour_bank,
381   SET_TILE_INFO_DEVICE(
382         deco16ic->pf12_16x16_gfx_bank,
383         (tile & 0xfff) | deco16ic->pf2_bank,
384         (colour & deco16ic->pf2_colourmask) + deco16ic->pf2_colour_bank,
317385         flags);
318386}
319387
320static TILE_GET_INFO( get_pf1_tile_info )
388static TILE_GET_INFO_DEVICE( get_pf1_tile_info )
321389{
322   UINT16 tile=deco16_pf1_data[tile_index];
323   UINT8 colour=(tile>>12)&0xf;
324   UINT8 flags=0;
390   deco16ic_state *deco16ic = get_safe_token(device);
391   UINT16 tile = deco16ic->pf1_data[tile_index];
392   UINT8 colour = (tile >> 12) & 0xf;
393   UINT8 flags = 0;
325394
326   if (tile&0x8000) {
327      if ((deco16_pf12_control[6]>>0)&0x01) {
328         flags|=TILE_FLIPX;
329         colour&=0x7;
395   if (tile & 0x8000)
396   {
397      if ((deco16ic->pf12_control[6] >> 0) & 0x01)
398      {
399         flags |= TILE_FLIPX;
400         colour &= 0x7;
330401      }
331      if ((deco16_pf12_control[6]>>0)&0x02) {
332         flags|=TILE_FLIPY;
333         colour&=0x7;
402      if ((deco16ic->pf12_control[6] >> 0) & 0x02)
403      {
404         flags |= TILE_FLIPY;
405         colour &= 0x7;
334406      }
335407   }
336408
337   SET_TILE_INFO(
338         deco16_pf12_16x16_gfx_bank,
339         (tile&0xfff)|deco16_pf1_bank,
340         (colour&deco16_pf1_colourmask)+deco16_pf1_colour_bank,
409   SET_TILE_INFO_DEVICE(
410         deco16ic->pf12_16x16_gfx_bank,
411         (tile & 0xfff) | deco16ic->pf1_bank,
412         (colour & deco16ic->pf1_colourmask) + deco16ic->pf1_colour_bank,
341413         flags);
342414}
343415
344static TILE_GET_INFO( get_pf2_tile_info_b )
416static TILE_GET_INFO_DEVICE( get_pf2_tile_info_b )
345417{
346   UINT16 tile=deco16_pf2_data[tile_index];
347   UINT8 colour=(tile>>12)&0xf;
348   UINT8 flags=0;
418   deco16ic_state *deco16ic = get_safe_token(device);
419   UINT16 tile = deco16ic->pf2_data[tile_index];
420   UINT8 colour = (tile >> 12) & 0xf;
421   UINT8 flags = 0;
349422
350   if (tile&0x8000) {
351      if ((deco16_pf12_control[6]>>8)&0x01) {
352         flags|=TILE_FLIPX;
353         colour&=0x7;
423   if (tile & 0x8000)
424   {
425      if ((deco16ic->pf12_control[6] >> 8) & 0x01)
426      {
427         flags |= TILE_FLIPX;
428         colour &= 0x7;
354429      }
355      if ((deco16_pf12_control[6]>>8)&0x02) {
356         flags|=TILE_FLIPY;
357         colour&=0x7;
430      if ((deco16ic->pf12_control[6] >> 8) & 0x02)
431      {
432         flags |= TILE_FLIPY;
433         colour &= 0x7;
358434      }
359435   }
360436
361   SET_TILE_INFO(
362         deco16_pf12_8x8_gfx_bank,
363         (tile&0xfff)|deco16_pf2_bank,
364         (colour&deco16_pf2_colourmask)+deco16_pf2_colour_bank,
437   SET_TILE_INFO_DEVICE(
438         deco16ic->pf12_8x8_gfx_bank,
439         (tile & 0xfff) | deco16ic->pf2_bank,
440         (colour & deco16ic->pf2_colourmask) + deco16ic->pf2_colour_bank,
365441         flags);
366442}
367443
368static TILE_GET_INFO( get_pf1_tile_info_b )
444static TILE_GET_INFO_DEVICE( get_pf1_tile_info_b )
369445{
370   UINT16 tile=deco16_pf1_data[tile_index];
371   UINT8 colour=(tile>>12)&0xf;
372   UINT8 flags=0;
446   deco16ic_state *deco16ic = get_safe_token(device);
447   UINT16 tile = deco16ic->pf1_data[tile_index];
448   UINT8 colour = (tile >> 12) & 0xf;
449   UINT8 flags = 0;
373450
374   if (tile&0x8000) {
375      if ((deco16_pf12_control[6]>>0)&0x01) {
376         flags|=TILE_FLIPX;
377         colour&=0x7;
451   if (tile & 0x8000)
452   {
453      if ((deco16ic->pf12_control[6] >> 0) & 0x01)
454      {
455         flags |= TILE_FLIPX;
456         colour &= 0x7;
378457      }
379      if ((deco16_pf12_control[6]>>0)&0x02) {
380         flags|=TILE_FLIPY;
381         colour&=0x7;
458      if ((deco16ic->pf12_control[6] >> 0) & 0x02)
459      {
460         flags |= TILE_FLIPY;
461         colour &= 0x7;
382462      }
383463   }
384464
385   SET_TILE_INFO(
386         deco16_pf12_8x8_gfx_bank,
387         (tile&0xfff)|deco16_pf1_bank,
388         (colour&deco16_pf1_colourmask)+deco16_pf1_colour_bank,
465   SET_TILE_INFO_DEVICE(
466         deco16ic->pf12_8x8_gfx_bank,
467         (tile & 0xfff) | deco16ic->pf1_bank,
468         (colour & deco16ic->pf1_colourmask) + deco16ic->pf1_colour_bank,
389469         flags);
390470}
391471
392/******************************************************************************/
472/*****************************************************************************************/
393473
394/* Each game can have banking set up differently depending on how the roms are
395connected, and what rom slots are used */
474/*
475    Consider this the 'reference rasterizer' for the 56/74/141 tilemap chips - it implements
476    simultaneous row & column scroll which the Mame tilemap core cannot do.  It also
477    implements combining the 4BPP output of two tilemaps into 8BPP output.  This function
478    is automatically called when the tilemap is in a state the cannot be properly rendered
479    by the Mame core.
480*/
396481
397void deco16_set_tilemap_bank_callback(int tmap, int (*callback)(const int bank))
482static void custom_tilemap_draw(
483   running_device *device,
484   bitmap_t *bitmap,
485   tilemap_t *tilemap0_8x8,
486   tilemap_t *tilemap0_16x16,
487   tilemap_t *tilemap1_8x8,
488   tilemap_t *tilemap1_16x16,
489   const UINT16 *rowscroll_ptr,
490   const UINT16 scrollx,
491   const UINT16 scrolly,
492   const UINT16 control0,
493   const UINT16 control1,
494   int combine_mask,
495   int combine_shift,
496   int trans_mask,
497   int flags,
498   UINT32 priority)
398499{
399   switch (tmap) {
400   case 0: deco16_bank_callback_1=callback; break;
401   case 1: deco16_bank_callback_2=callback; break;
402   case 2: deco16_bank_callback_3=callback; break;
403   case 3: deco16_bank_callback_4=callback; break;
500   running_machine *machine = device->machine;
501   tilemap_t *tilemap0 = BIT(control1, 7) ? tilemap0_8x8 : tilemap0_16x16;
502   tilemap_t *tilemap1 = BIT(control1, 7) ? tilemap1_8x8 : tilemap1_16x16;
503   const bitmap_t *src_bitmap0 = tilemap0 ? tilemap_get_pixmap(tilemap0) : NULL;
504   const bitmap_t *src_bitmap1 = tilemap1 ? tilemap_get_pixmap(tilemap1) : NULL;
505   int width_mask, height_mask, x, y, p;
506   int column_offset, src_x = 0, src_y = 0;
507   int row_type = 1 << ((control0 >> 3) & 0xf);
508   int col_type = 8 << (control0 & 7);
509
510   if (!src_bitmap0)
511      return;
512
513   // Playfield disable
514   if (!BIT(control0, 7))
515      return;
516
517   width_mask = src_bitmap0->width - 1;
518   height_mask = src_bitmap0->height - 1;
519   src_y = scrolly + 8;
520
521   for (y = 8; y < 248; y++)
522   {
523      if (rowscroll_ptr && BIT(control1, 6))
524         src_x = scrollx + rowscroll_ptr[src_y / row_type];
525      else
526         src_x = scrollx;
527
528      src_x &= width_mask;
529
530      if (bitmap->bpp == 16)
531      {
532         for (x = 0; x < 320; x++)
533         {
534            if (rowscroll_ptr && BIT(control1, 5))
535               column_offset = rowscroll_ptr[0x200 + ((src_x & 0x1ff) / col_type)];
536            else
537               column_offset = 0;
538
539            p = *BITMAP_ADDR16(src_bitmap0, (src_y + column_offset) & height_mask, src_x);
540
541            if (src_bitmap1)
542               p |= (*BITMAP_ADDR16(src_bitmap1, (src_y + column_offset) & height_mask, src_x) & combine_mask) << combine_shift;
543
544            src_x = (src_x + 1) & width_mask;
545
546            if ((flags & TILEMAP_DRAW_OPAQUE) || (p & trans_mask))
547            {
548               *BITMAP_ADDR16(bitmap, y, x) = machine->pens[p];
549               if (machine->priority_bitmap)
550               {
551                  UINT8 *pri = BITMAP_ADDR8(machine->priority_bitmap, y, 0);
552                  pri[x] |= priority;
553               }
554            }
555         }
556      }
557      else
558      {
559         /* boogwing */
560         for (x = 0; x < 320; x++)
561         {
562            if (rowscroll_ptr && BIT(control1, 5))
563               column_offset = rowscroll_ptr[0x200 + ((src_x & 0x1ff) / col_type)];
564            else
565               column_offset = 0;
566
567            p = *BITMAP_ADDR16(src_bitmap0, (src_y + column_offset) & height_mask, src_x);
568
569            if (src_bitmap1)
570               p |= (*BITMAP_ADDR16(src_bitmap1, (src_y + column_offset) & height_mask, src_x) & combine_mask) << combine_shift;
571
572            src_x = (src_x + 1) & width_mask;
573
574            if ((flags & TILEMAP_DRAW_OPAQUE) || (p & trans_mask))
575            {
576               *BITMAP_ADDR32(bitmap, y, x) = machine->pens[p];
577               if (machine->priority_bitmap)
578               {
579                  UINT8 *pri = BITMAP_ADDR8(machine->priority_bitmap, y, 0);
580                  pri[x] |= priority;
581               }
582            }
583         }
584      }
585      src_y = (src_y + 1) & height_mask;
404586   }
405587}
406588
407/* Each game can have colours set up differently depending on how the playfield
408generator is connected to paletteram */
589/******************************************************************************/
409590
410void deco16_set_tilemap_colour_base(int tmap, int base)
591/* robocop 2 can switch between 2 tilemaps at 4bpp, or 1 at 8bpp */
592void deco16ic_set_tilemap_colour_mask( running_device *device, int tmap, int mask )
411593{
412   switch (tmap) {
413   case 0: deco16_pf1_colour_bank=base; break;
414   case 1: deco16_pf2_colour_bank=base; break;
415   case 2: deco16_pf3_colour_bank=base; break;
416   case 3: deco16_pf4_colour_bank=base; break;
594   deco16ic_state *deco16ic = get_safe_token(device);
595
596   switch (tmap)
597   {
598   case 0: deco16ic->pf1_colourmask = mask; break;
599   case 1: deco16ic->pf2_colourmask = mask; break;
600   case 2: deco16ic->pf3_colourmask = mask; break;
601   case 3: deco16ic->pf4_colourmask = mask; break;
417602   }
418603}
419604
420void deco16_set_tilemap_colour_mask(int tmap, int mask)
605void deco16ic_pf34_set_gfxbank( running_device *device, int small, int big )
421606{
422   switch (tmap) {
423   case 0: deco16_pf1_colourmask=mask; break;
424   case 1: deco16_pf2_colourmask=mask; break;
425   case 2: deco16_pf3_colourmask=mask; break;
426   case 3: deco16_pf4_colourmask=mask; break;
607   deco16ic_state *deco16ic = get_safe_token(device);
608
609   if (deco16ic->pf34_last_big != big)
610   {
611      if (deco16ic->pf3_tilemap_16x16)
612         tilemap_mark_all_tiles_dirty(deco16ic->pf3_tilemap_16x16);
613      if (deco16ic->pf4_tilemap_16x16)
614         tilemap_mark_all_tiles_dirty(deco16ic->pf4_tilemap_16x16);
615
616      deco16ic->pf34_last_big = big;
427617   }
618   deco16ic->pf34_16x16_gfx_bank = big;
428619}
429620
430void deco16_set_tilemap_transparency_mask(int tmap, int mask)
621/* stoneage has broken scroll registers */
622void deco16ic_set_scrolldx( running_device *device, int tmap, int size, int dx, int dx_if_flipped )
431623{
432   switch (tmap) {
433   case 0: deco16_pf1_trans_mask=mask; break;
434   case 1: deco16_pf2_trans_mask=mask; break;
435   case 2: deco16_pf3_trans_mask=mask; break;
436   case 3: deco16_pf4_trans_mask=mask; break;
624   deco16ic_state *deco16ic = get_safe_token(device);
625
626   switch (tmap)
627   {
628   case 0:
629      if (!size)
630         tilemap_set_scrolldx(deco16ic->pf1_tilemap_16x16, dx, dx_if_flipped);
631      else
632         tilemap_set_scrolldx(deco16ic->pf1_tilemap_8x8, dx, dx_if_flipped);
633      break;
634   case 1:
635      if (!size)
636         tilemap_set_scrolldx(deco16ic->pf2_tilemap_16x16, dx, dx_if_flipped);
637      else
638         tilemap_set_scrolldx(deco16ic->pf2_tilemap_8x8, dx, dx_if_flipped);
639      break;
640   case 2:
641      if (!size)
642         tilemap_set_scrolldx(deco16ic->pf3_tilemap_16x16, dx, dx_if_flipped);
643      break;
644   case 3:
645      if (!size)
646         tilemap_set_scrolldx(deco16ic->pf4_tilemap_16x16, dx, dx_if_flipped);
647      break;
437648   }
438649}
439650
440void deco16_pf12_set_gfxbank(int small, int big)
651/******************************************************************************/
652
653WRITE16_DEVICE_HANDLER( deco16ic_pf1_data_w )
441654{
442   if (pf12_last_small!=small) {
443      if (pf1_tilemap_8x8)
444         tilemap_mark_all_tiles_dirty(pf1_tilemap_8x8);
445      if (pf2_tilemap_8x8)
446         tilemap_mark_all_tiles_dirty(pf2_tilemap_8x8);
447      pf12_last_small=small;
448   }
449   deco16_pf12_8x8_gfx_bank=small;
655   deco16ic_state *deco16ic = get_safe_token(device);
450656
451   if (pf12_last_big!=big) {
452      if (pf1_tilemap_16x16)
453         tilemap_mark_all_tiles_dirty(pf1_tilemap_16x16);
454      if (pf2_tilemap_16x16)
455         tilemap_mark_all_tiles_dirty(pf2_tilemap_16x16);
456      pf12_last_big=big;
457   }
458   deco16_pf12_16x16_gfx_bank=big;
657   COMBINE_DATA(&deco16ic->pf1_data[offset]);
459658
659   tilemap_mark_tile_dirty(deco16ic->pf1_tilemap_8x8, offset);
660   if (offset < 0x800)
661      tilemap_mark_tile_dirty(deco16ic->pf1_tilemap_16x16, offset);
460662}
461663
462void deco16_pf34_set_gfxbank(int small, int big)
664WRITE16_DEVICE_HANDLER( deco16ic_pf2_data_w )
463665{
464   if (pf34_last_big!=big) {
465      if (pf3_tilemap_16x16)
466         tilemap_mark_all_tiles_dirty(pf3_tilemap_16x16);
467      if (pf4_tilemap_16x16)
468         tilemap_mark_all_tiles_dirty(pf4_tilemap_16x16);
469      pf34_last_big=big;
470   }
471   deco16_pf34_16x16_gfx_bank=big;
666   deco16ic_state *deco16ic = get_safe_token(device);
667
668   COMBINE_DATA(&deco16ic->pf2_data[offset]);
669
670   tilemap_mark_tile_dirty(deco16ic->pf2_tilemap_8x8, offset);
671   if (offset < 0x800)
672      tilemap_mark_tile_dirty(deco16ic->pf2_tilemap_16x16, offset);
472673}
473674
474tilemap_t *deco16_get_tilemap(int pf, int size)
675WRITE16_DEVICE_HANDLER( deco16ic_pf3_data_w )
475676{
476   switch (pf) {
477   case 0: if (size) return pf1_tilemap_8x8; return pf1_tilemap_16x16;
478   case 1: if (size) return pf2_tilemap_8x8; return pf2_tilemap_16x16;
479   case 2: if (size) return 0; return pf3_tilemap_16x16;
480   case 3: if (size) return 0; return pf4_tilemap_16x16;
481   }
482   return 0;
677   deco16ic_state *deco16ic = get_safe_token(device);
678
679   COMBINE_DATA(&deco16ic->pf3_data[offset]);
680   tilemap_mark_tile_dirty(deco16ic->pf3_tilemap_16x16, offset);
483681}
484682
485/******************************************************************************/
683WRITE16_DEVICE_HANDLER( deco16ic_pf4_data_w )
684{
685   deco16ic_state *deco16ic = get_safe_token(device);
486686
487WRITE16_HANDLER( deco16_pf1_data_w )
687   COMBINE_DATA(&deco16ic->pf4_data[offset]);
688   tilemap_mark_tile_dirty(deco16ic->pf4_tilemap_16x16, offset);
689}
690
691READ16_DEVICE_HANDLER( deco16ic_pf1_data_r )
488692{
489   COMBINE_DATA(&deco16_pf1_data[offset]);
490   tilemap_mark_tile_dirty(pf1_tilemap_8x8,offset);
491   if (offset<0x800)
492      tilemap_mark_tile_dirty(pf1_tilemap_16x16,offset);
693   deco16ic_state *deco16ic = get_safe_token(device);
694   return deco16ic->pf1_data[offset];
493695}
494696
495WRITE16_HANDLER( deco16_pf2_data_w )
697READ16_DEVICE_HANDLER( deco16ic_pf2_data_r )
496698{
497   COMBINE_DATA(&deco16_pf2_data[offset]);
498   tilemap_mark_tile_dirty(pf2_tilemap_8x8,offset);
499   if (offset<0x800)
500      tilemap_mark_tile_dirty(pf2_tilemap_16x16,offset);
699   deco16ic_state *deco16ic = get_safe_token(device);
700   return deco16ic->pf2_data[offset];
501701}
502702
503WRITE16_HANDLER( deco16_pf3_data_w )
703READ16_DEVICE_HANDLER( deco16ic_pf3_data_r )
504704{
505   COMBINE_DATA(&deco16_pf3_data[offset]);
506   tilemap_mark_tile_dirty(pf3_tilemap_16x16,offset);
705   deco16ic_state *deco16ic = get_safe_token(device);
706   return deco16ic->pf3_data[offset];
507707}
508708
509WRITE16_HANDLER( deco16_pf4_data_w )
709READ16_DEVICE_HANDLER( deco16ic_pf4_data_r )
510710{
511   COMBINE_DATA(&deco16_pf4_data[offset]);
512   tilemap_mark_tile_dirty(pf4_tilemap_16x16,offset);
711   deco16ic_state *deco16ic = get_safe_token(device);
712   return deco16ic->pf4_data[offset];
513713}
514714
515/*****************************************************************************************/
516715
517static void deco16_video_init(running_machine *machine, int pf12_only, int split, int full_width)
716WRITE16_DEVICE_HANDLER( deco16ic_pf12_control_w )
518717{
519   int width = video_screen_get_width(machine->primary_screen);
520   int height = video_screen_get_height(machine->primary_screen);
521   sprite_priority_bitmap = auto_bitmap_alloc(machine, width, height, BITMAP_FORMAT_INDEXED8 );
718   deco16ic_state *deco16ic = get_safe_token(device);
719   COMBINE_DATA(&deco16ic->pf12_control[offset]);
720}
522721
523   pf1_tilemap_16x16 =   tilemap_create(machine, get_pf1_tile_info,   deco16_scan_rows, 16,16,64,32);
524   pf1_tilemap_8x8 =   tilemap_create(machine, get_pf1_tile_info_b, tilemap_scan_rows,8,8,64,32);
722WRITE16_DEVICE_HANDLER( deco16ic_pf34_control_w )
723{
724   deco16ic_state *deco16ic = get_safe_token(device);
725   COMBINE_DATA(&deco16ic->pf34_control[offset]);
726}
525727
526   if (split)
527      pf2_tilemap_16x16 =   tilemap_create(machine, get_pf2_tile_info,   deco16_scan_rows, 16,16,full_width ? 64 : 32,32);
528   else
529      pf2_tilemap_16x16 =   tilemap_create(machine, get_pf2_tile_info,   deco16_scan_rows, 16,16,full_width ? 64 : 32,32);
530   pf2_tilemap_8x8 =   tilemap_create(machine, get_pf2_tile_info_b, tilemap_scan_rows,8,8,full_width ? 64 : 32,32);
728READ16_DEVICE_HANDLER( deco16ic_pf12_control_r )
729{
730   deco16ic_state *deco16ic = get_safe_token(device);
731   return deco16ic->pf12_control[offset];
732}
531733
532   dirty_palette = auto_alloc_array(machine, UINT8, 4096);
533   deco16_raster_display_list=auto_alloc_array(machine, UINT16, 20 * 256 / 2);
734READ16_DEVICE_HANDLER( deco16ic_pf34_control_r )
735{
736   deco16ic_state *deco16ic = get_safe_token(device);
737   return deco16ic->pf34_control[offset];
738}
534739
535   if (!pf12_only)
536   {
537      pf4_tilemap_16x16 =   tilemap_create(machine, get_pf4_tile_info,   deco16_scan_rows, 16,16,full_width ? 64 : 32,32);
538      pf3_tilemap_16x16 =   tilemap_create(machine, get_pf3_tile_info,   deco16_scan_rows, 16,16,full_width ? 64 : 32,32);
539   }
540   else
541   {
542      pf3_tilemap_16x16=0;
543      pf4_tilemap_16x16=0;
544   }
545740
546   tilemap_set_transparent_pen(pf1_tilemap_8x8,0);
547   tilemap_set_transparent_pen(pf2_tilemap_8x8,0);
548   tilemap_set_transparent_pen(pf1_tilemap_16x16,0);
549   tilemap_set_transparent_pen(pf2_tilemap_16x16,0);
550   if (split) /* Caveman Ninja only */
551      tilemap_set_transmask(pf2_tilemap_16x16,0,0x00ff,0xff01);
741READ32_DEVICE_HANDLER ( deco16ic_pf12_control_dword_r )
742{
743   return deco16ic_pf12_control_r(device, offset, 0xffff)^0xffff0000;
744}
552745
553   if (!pf12_only)
554   {
555      tilemap_set_transparent_pen(pf3_tilemap_16x16,0);
556      tilemap_set_transparent_pen(pf4_tilemap_16x16,0);
557   }
746WRITE32_DEVICE_HANDLER( deco16ic_pf12_control_dword_w )
747{
748   deco16ic_pf12_control_w(device, offset, data & 0xffff, mem_mask & 0xffff);
749}
558750
751READ32_DEVICE_HANDLER ( deco16ic_pf34_control_dword_r )
752{
753   return deco16ic_pf34_control_r(device, offset, 0xffff)^0xffff0000;
754}
559755
560   deco16_bank_callback_1=0;
561   deco16_bank_callback_2=0;
562   deco16_bank_callback_3=0;
563   deco16_bank_callback_4=0;
756WRITE32_DEVICE_HANDLER( deco16ic_pf34_control_dword_w )
757{
758   deco16ic_pf34_control_w(device, offset, data & 0xffff, mem_mask & 0xffff);
759}
564760
565   deco16_pf1_trans_mask=0xf;
566   deco16_pf2_trans_mask=0xf;
567   deco16_pf3_trans_mask=0xf;
568   deco16_pf4_trans_mask=0xf;
569761
570   deco16_pf1_colourmask=deco16_pf2_colourmask=0xf;
571   deco16_pf3_colourmask=deco16_pf4_colourmask=0xf;
572   deco16_pf1_bank=deco16_pf2_bank=deco16_pf3_bank=deco16_pf4_bank=0;
573   deco16_pf4_colour_bank=deco16_pf2_colour_bank=16;
574   deco16_pf3_colour_bank=deco16_pf1_colour_bank=0;
762READ32_DEVICE_HANDLER( deco16ic_pf1_data_dword_r )
763{
764   return deco16ic_pf1_data_r(device, offset, 0xffff)^0xffff0000;
765}
575766
576   deco16_pf12_8x8_gfx_bank=0;
577   deco16_pf12_16x16_gfx_bank=1;
578   deco16_pf34_16x16_gfx_bank=2;
767WRITE32_DEVICE_HANDLER( deco16ic_pf1_data_dword_w )
768{
769   deco16ic_pf1_data_w(device, offset, data & 0xffff, mem_mask & 0xffff);
770}
579771
580   deco16_raster_display_position=0;
772READ32_DEVICE_HANDLER( deco16ic_pf2_data_dword_r )
773{
774   return deco16ic_pf2_data_r(device, offset, 0xffff)^0xffff0000;
775}
581776
582   pf12_last_small = pf12_last_big = pf34_last_big = -1;
777WRITE32_DEVICE_HANDLER( deco16ic_pf2_data_dword_w )
778{
779   deco16ic_pf2_data_w(device, offset, data & 0xffff, mem_mask & 0xffff);
583780}
584781
585void deco16_1_video_init(running_machine *machine)  /* 1 times playfield generator chip */
782READ32_DEVICE_HANDLER( deco16ic_pf3_data_dword_r )
586783{
587   deco16_video_init(machine, 1, 0, 1);
784   return deco16ic_pf3_data_r(device, offset, 0xffff)^0xffff0000;
588785}
589786
590void deco16_2_video_init(running_machine *machine, int split) /* 2 times playfield generator chips */
787WRITE32_DEVICE_HANDLER( deco16ic_pf3_data_dword_w )
591788{
592   deco16_video_init(machine, 0, split, 1);
789   deco16ic_pf3_data_w(device, offset, data & 0xffff, mem_mask & 0xffff);
593790}
594791
595void deco16_2_video_init_half_width(running_machine *machine) /* 2 times playfield generator chips */
792READ32_DEVICE_HANDLER( deco16ic_pf4_data_dword_r )
596793{
597   deco16_video_init(machine, 0, 0, 0);
794   return deco16ic_pf4_data_r(device, offset, 0xffff)^0xffff0000;
598795}
599796
797WRITE32_DEVICE_HANDLER( deco16ic_pf4_data_dword_w )
798{
799   deco16ic_pf4_data_w(device, offset, data & 0xffff, mem_mask & 0xffff);
800}
801
802
803
804#if 0
600805void deco_allocate_sprite_bitmap(running_machine *machine)
601806{
602807   /* Allow sprite bitmap to be used by Deco32 games as well */
r7500r7501
605810   sprite_priority_bitmap = auto_bitmap_alloc(machine, width, height, BITMAP_FORMAT_INDEXED16 );
606811}
607812
813#endif
814
608815/*****************************************************************************************/
609816
610817static int deco16_pf_update(
r7500r7501
616823   const UINT16 control0,
617824   const UINT16 control1)
618825{
619   int rows, cols, offs, use_custom=0;
826   int rows, cols, offs, use_custom = 0;
620827
621828   /* Toggle between 8x8 and 16x16 modes (and master enable bit) */
622   if (control1&0x80) {
623      if (!tilemap_8x8) popmessage("Deco16: Playfield switched into 8x8 mode but no tilemap defined");
829   if (BIT(control1, 7))
830   {
831      if (!tilemap_8x8)
832         popmessage("Deco16: Playfield switched into 8x8 mode but no tilemap defined");
624833
625      if (tilemap_8x8) tilemap_set_enable(tilemap_8x8,control0&0x80);
626      if (tilemap_16x16) tilemap_set_enable(tilemap_16x16,0);
627   } else {
628      if (!tilemap_16x16) popmessage("Deco16: Playfield switched into 16x16 mode but no tilemap defined");
834      if (tilemap_8x8)
835         tilemap_set_enable(tilemap_8x8, BIT(control0, 7));
629836
630      if (tilemap_8x8) tilemap_set_enable(tilemap_8x8,0);
631      if (tilemap_16x16) tilemap_set_enable(tilemap_16x16,control0&0x80);
837      if (tilemap_16x16)
838         tilemap_set_enable(tilemap_16x16, 0);
839
632840   }
841   else
842   {
843      if (!tilemap_16x16)
844         popmessage("Deco16: Playfield switched into 16x16 mode but no tilemap defined");
633845
846      if (tilemap_8x8)
847         tilemap_set_enable(tilemap_8x8, 0);
848
849      if (tilemap_16x16)
850         tilemap_set_enable(tilemap_16x16, BIT(control0, 7));
851   }
852
634853   /* Rowscroll enable */
635   if (rowscroll_ptr && (control1&0x60)==0x40) {
854   if (rowscroll_ptr && (control1 & 0x60) == 0x40)
855   {
636856
637857      /* Several different rowscroll styles */
638      switch ((control0>>3)&0xf) {
639         case 0: rows=512; break;/* Every line of 512 height bitmap */
640         case 1: rows=256; break;
641         case 2: rows=128; break;
642         case 3: rows=64; break;
643         case 4: rows=32; break;
644         case 5: rows=16; break;
645         case 6: rows=8; break;
646         case 7: rows=4; break;
647         case 8: rows=2; break;
648         default: rows=1; break;
858      switch ((control0 >> 3) & 0xf)
859      {
860         case 0:    rows = 512;    break;/* Every line of 512 height bitmap */
861         case 1:    rows = 256;    break;
862         case 2:    rows = 128;    break;
863         case 3:    rows = 64;      break;
864         case 4:    rows = 32;      break;
865         case 5:    rows = 16;      break;
866         case 6:    rows = 8;      break;
867         case 7:    rows = 4;      break;
868         case 8:    rows = 2;      break;
869         default:   rows = 1;      break;
649870      }
650871
651      if (tilemap_16x16) {
652         tilemap_set_scroll_cols(tilemap_16x16,1);
653         tilemap_set_scroll_rows(tilemap_16x16,rows);
654         tilemap_set_scrolly(tilemap_16x16,0,scrolly);
872      if (tilemap_16x16)
873      {
874         tilemap_set_scroll_cols(tilemap_16x16, 1);
875         tilemap_set_scroll_rows(tilemap_16x16, rows);
876         tilemap_set_scrolly(tilemap_16x16, 0, scrolly);
655877
656         for (offs = 0;offs < rows;offs++)
657            tilemap_set_scrollx( tilemap_16x16, offs, scrollx + rowscroll_ptr[offs] );
878         for (offs = 0; offs < rows; offs++)
879            tilemap_set_scrollx(tilemap_16x16, offs, scrollx + rowscroll_ptr[offs]);
658880      }
659881
660      if (tilemap_8x8) {
661         tilemap_set_scroll_cols(tilemap_8x8,1);
662         tilemap_set_scroll_rows(tilemap_8x8,rows/2);
663         tilemap_set_scrolly(tilemap_8x8,0,scrolly);
882      if (tilemap_8x8)
883      {
884         tilemap_set_scroll_cols(tilemap_8x8, 1);
885         tilemap_set_scroll_rows(tilemap_8x8, rows / 2);
886         tilemap_set_scrolly(tilemap_8x8, 0, scrolly);
664887
665         for (offs = 0;offs < rows/2;offs++)
666            tilemap_set_scrollx( tilemap_8x8, offs, scrollx + rowscroll_ptr[offs] );
888         for (offs = 0; offs < rows / 2; offs++)
889            tilemap_set_scrollx(tilemap_8x8, offs, scrollx + rowscroll_ptr[offs]);
667890      }
668891   }
669   else if (rowscroll_ptr && (control1&0x60)==0x20) { /* Column scroll */
892   else if (rowscroll_ptr && (control1 & 0x60) == 0x20)  /* Column scroll */
893   {
670894
671895      /* Column scroll ranges from 8 pixel columns to 512 pixel columns */
672      int mask=(0x40 >> (control0&7))-1;
673      if (mask==-1) mask=0;
674      cols=(8<<(control0&7))&0x3ff;
675      if (!cols) cols=1024;
676      cols=1024 / cols;
896      int mask = (0x40 >> (control0 & 7)) - 1;
897      if (mask == -1)
898         mask = 0;
677899
678      if (tilemap_16x16) {
679         tilemap_set_scroll_cols(tilemap_16x16,cols);
680         tilemap_set_scroll_rows(tilemap_16x16,1);
681         tilemap_set_scrollx(tilemap_16x16,0,scrollx );
900      cols = (8 << (control0 & 7)) & 0x3ff;
901      if (!cols)
902         cols = 1024;
682903
683         for (offs=0 ; offs < cols;offs++)
684            tilemap_set_scrolly( tilemap_16x16, offs, scrolly + rowscroll_ptr[(offs&mask)+0x200] );
904      cols = 1024 / cols;
905
906      if (tilemap_16x16)
907      {
908         tilemap_set_scroll_cols(tilemap_16x16, cols);
909         tilemap_set_scroll_rows(tilemap_16x16, 1);
910         tilemap_set_scrollx(tilemap_16x16, 0, scrollx);
911
912         for (offs = 0; offs < cols; offs++)
913            tilemap_set_scrolly(tilemap_16x16, offs, scrolly + rowscroll_ptr[(offs & mask) + 0x200]);
685914      }
686915
687      if (tilemap_8x8) {
916      if (tilemap_8x8)
917      {
688918         cols = cols / 2; /* Adjust because 8x8 tilemap is half the width of 16x16 */
689919
690         tilemap_set_scroll_cols(tilemap_8x8,cols);
691         tilemap_set_scroll_rows(tilemap_8x8,1);
692         tilemap_set_scrollx(tilemap_8x8,0,scrollx );
920         tilemap_set_scroll_cols(tilemap_8x8, cols);
921         tilemap_set_scroll_rows(tilemap_8x8, 1);
922         tilemap_set_scrollx(tilemap_8x8, 0, scrollx);
693923
694         for (offs=0 ; offs < cols;offs++)
695            tilemap_set_scrolly( tilemap_8x8,offs, scrolly + rowscroll_ptr[(offs&mask)+0x200] );
924         for (offs = 0; offs < cols; offs++)
925            tilemap_set_scrolly(tilemap_8x8, offs, scrolly + rowscroll_ptr[(offs & mask) + 0x200]);
696926      }
697927   }
698   else if (control1&0x60) {
928   else if (control1 & 0x60)
929   {
699930      /* Simultaneous row & column scroll requested - use custom renderer */
700      use_custom=1;
931      use_custom = 1;
701932
702      if (tilemap_16x16) {
703         tilemap_set_scroll_rows(tilemap_16x16,1);
704         tilemap_set_scroll_cols(tilemap_16x16,1);
705         tilemap_set_scrollx( tilemap_16x16,0, scrollx );
706         tilemap_set_scrolly( tilemap_16x16,0, scrolly );
933      if (tilemap_16x16)
934      {
935         tilemap_set_scroll_rows(tilemap_16x16, 1);
936         tilemap_set_scroll_cols(tilemap_16x16, 1);
937         tilemap_set_scrollx(tilemap_16x16, 0, scrollx);
938         tilemap_set_scrolly(tilemap_16x16, 0, scrolly);
707939      }
708940
709      if (tilemap_8x8) {
710         tilemap_set_scroll_rows(tilemap_8x8,1);
711         tilemap_set_scroll_cols(tilemap_8x8,1);
712         tilemap_set_scrollx( tilemap_8x8,0, scrollx );
713         tilemap_set_scrolly( tilemap_8x8,0, scrolly );
941      if (tilemap_8x8)
942      {
943         tilemap_set_scroll_rows(tilemap_8x8, 1);
944         tilemap_set_scroll_cols(tilemap_8x8, 1);
945         tilemap_set_scrollx(tilemap_8x8, 0, scrollx);
946         tilemap_set_scrolly(tilemap_8x8, 0, scrolly);
714947
715948      }
716949
717   } else {
718      if (tilemap_16x16) {
719         tilemap_set_scroll_rows(tilemap_16x16,1);
720         tilemap_set_scroll_cols(tilemap_16x16,1);
721         tilemap_set_scrollx( tilemap_16x16,0, scrollx );
722         tilemap_set_scrolly( tilemap_16x16,0, scrolly );
950   }
951   else
952   {
953      if (tilemap_16x16)
954      {
955         tilemap_set_scroll_rows(tilemap_16x16, 1);
956         tilemap_set_scroll_cols(tilemap_16x16, 1);
957         tilemap_set_scrollx(tilemap_16x16, 0, scrollx);
958         tilemap_set_scrolly(tilemap_16x16, 0, scrolly);
723959      }
724960
725      if (tilemap_8x8) {
726         tilemap_set_scroll_rows(tilemap_8x8,1);
727         tilemap_set_scroll_cols(tilemap_8x8,1);
728         tilemap_set_scrollx( tilemap_8x8,0, scrollx );
729         tilemap_set_scrolly( tilemap_8x8,0, scrolly );
961      if (tilemap_8x8)
962      {
963         tilemap_set_scroll_rows(tilemap_8x8, 1);
964         tilemap_set_scroll_cols(tilemap_8x8, 1);
965         tilemap_set_scrollx(tilemap_8x8, 0, scrollx);
966         tilemap_set_scrolly(tilemap_8x8, 0, scrolly);
730967      }
731968   }
732969
733970   return use_custom;
734971}
735972
736void deco16_pf12_update(const UINT16 *rowscroll_1_ptr, const UINT16 *rowscroll_2_ptr)
973void deco16ic_pf12_update( running_device *device, const UINT16 *rowscroll_1_ptr, const UINT16 *rowscroll_2_ptr )
737974{
975   deco16ic_state *deco16ic = get_safe_token(device);
738976   int bank1, bank2;
739977
740978   /* Update scrolling and tilemap enable */
741   pf1_rowscroll_ptr=rowscroll_1_ptr;
742   pf2_rowscroll_ptr=rowscroll_2_ptr;
743   use_custom_pf2=deco16_pf_update(pf2_tilemap_8x8,pf2_tilemap_16x16,rowscroll_2_ptr,deco16_pf12_control[3], deco16_pf12_control[4], deco16_pf12_control[5]>>8, deco16_pf12_control[6]>>8);
744   use_custom_pf1=deco16_pf_update(pf1_tilemap_8x8,pf1_tilemap_16x16,rowscroll_1_ptr,deco16_pf12_control[1], deco16_pf12_control[2], deco16_pf12_control[5]&0xff, deco16_pf12_control[6]&0xff);
979   deco16ic->pf1_rowscroll_ptr = rowscroll_1_ptr;
980   deco16ic->pf2_rowscroll_ptr = rowscroll_2_ptr;
981   deco16ic->use_custom_pf2 = deco16_pf_update(deco16ic->pf2_tilemap_8x8, deco16ic->pf2_tilemap_16x16, rowscroll_2_ptr, deco16ic->pf12_control[3], deco16ic->pf12_control[4], deco16ic->pf12_control[5] >> 8, deco16ic->pf12_control[6] >> 8);
982   deco16ic->use_custom_pf1 = deco16_pf_update(deco16ic->pf1_tilemap_8x8, deco16ic->pf1_tilemap_16x16, rowscroll_1_ptr, deco16ic->pf12_control[1], deco16ic->pf12_control[2], deco16ic->pf12_control[5] & 0xff, deco16ic->pf12_control[6] & 0xff);
745983
746984   /* Update banking and global flip state */
747   if (deco16_bank_callback_1) {
748      bank1=deco16_bank_callback_1(deco16_pf12_control[7]&0xff);
749      if (bank1!=deco16_pf1_bank) {
750         if (pf1_tilemap_8x8) tilemap_mark_all_tiles_dirty(pf1_tilemap_8x8);
751         if (pf1_tilemap_16x16) tilemap_mark_all_tiles_dirty(pf1_tilemap_16x16);
985   if (deco16ic->bank_cb[0])
986   {
987      bank1 = deco16ic->bank_cb[0](deco16ic->pf12_control[7] & 0xff);
988
989      if (bank1 != deco16ic->pf1_bank)
990      {
991         if (deco16ic->pf1_tilemap_8x8)
992            tilemap_mark_all_tiles_dirty(deco16ic->pf1_tilemap_8x8);
993         if (deco16ic->pf1_tilemap_16x16)
994            tilemap_mark_all_tiles_dirty(deco16ic->pf1_tilemap_16x16);
995
996         deco16ic->pf1_bank = bank1;
752997      }
753
754      deco16_pf1_bank=bank1;
755998   }
756999
757   if (deco16_bank_callback_2) {
758      bank2=deco16_bank_callback_2(deco16_pf12_control[7]>>8);
759      if (bank2!=deco16_pf2_bank) {
760         if (pf2_tilemap_8x8) tilemap_mark_all_tiles_dirty(pf2_tilemap_8x8);
761         if (pf2_tilemap_16x16) tilemap_mark_all_tiles_dirty(pf2_tilemap_16x16);
1000   if (deco16ic->bank_cb[1])
1001   {
1002      bank2 = deco16ic->bank_cb[1](deco16ic->pf12_control[7] >> 8);
1003
1004      if (bank2 != deco16ic->pf2_bank)
1005      {
1006         if (deco16ic->pf2_tilemap_8x8)
1007            tilemap_mark_all_tiles_dirty(deco16ic->pf2_tilemap_8x8);
1008         if (deco16ic->pf2_tilemap_16x16)
1009            tilemap_mark_all_tiles_dirty(deco16ic->pf2_tilemap_16x16);
1010
1011         deco16ic->pf2_bank = bank2;
7621012      }
763
764      deco16_pf2_bank=bank2;
7651013   }
7661014}
7671015
768void deco16_pf34_update(const UINT16 *rowscroll_1_ptr, const UINT16 *rowscroll_2_ptr)
1016void deco16ic_pf34_update( running_device *device, const UINT16 *rowscroll_1_ptr, const UINT16 *rowscroll_2_ptr )
7691017{
1018   deco16ic_state *deco16ic = get_safe_token(device);
7701019   int bank1, bank2;
7711020
7721021   /* Update scrolling and tilemap enable */
773   pf3_rowscroll_ptr=rowscroll_1_ptr;
774   pf4_rowscroll_ptr=rowscroll_2_ptr;
775   use_custom_pf4=deco16_pf_update(0,pf4_tilemap_16x16,rowscroll_2_ptr,deco16_pf34_control[3], deco16_pf34_control[4], deco16_pf34_control[5]>>8, deco16_pf34_control[6]>>8);
776   use_custom_pf3=deco16_pf_update(0,pf3_tilemap_16x16,rowscroll_1_ptr,deco16_pf34_control[1], deco16_pf34_control[2], deco16_pf34_control[5]&0xff, deco16_pf34_control[6]&0xff);
1022   deco16ic->pf3_rowscroll_ptr = rowscroll_1_ptr;
1023   deco16ic->pf4_rowscroll_ptr = rowscroll_2_ptr;
1024   deco16ic->use_custom_pf4 = deco16_pf_update(0, deco16ic->pf4_tilemap_16x16, rowscroll_2_ptr, deco16ic->pf34_control[3], deco16ic->pf34_control[4], deco16ic->pf34_control[5] >> 8, deco16ic->pf34_control[6] >> 8);
1025   deco16ic->use_custom_pf3 = deco16_pf_update(0, deco16ic->pf3_tilemap_16x16, rowscroll_1_ptr, deco16ic->pf34_control[1], deco16ic->pf34_control[2], deco16ic->pf34_control[5] & 0xff, deco16ic->pf34_control[6] & 0xff);
7771026
1027   /* Update banking and global flip state */
1028   if (deco16ic->bank_cb[2])
1029   {
1030      bank1 = deco16ic->bank_cb[2](deco16ic->pf34_control[7] & 0xff);
1031      if (bank1 != deco16ic->pf3_bank)
1032      {
1033         if (deco16ic->pf3_tilemap_16x16)
1034            tilemap_mark_all_tiles_dirty(deco16ic->pf3_tilemap_16x16);
7781035
779   /* Update banking and global flip state */
780   if (deco16_bank_callback_3) {
781      bank1=deco16_bank_callback_3(deco16_pf34_control[7]&0xff);
782      if (bank1!=deco16_pf3_bank) {
783         //if (pf3_tilemap_8x8) tilemap_mark_all_tiles_dirty(pf3_tilemap_8x8);
784         if (pf3_tilemap_16x16) tilemap_mark_all_tiles_dirty(pf3_tilemap_16x16);
1036         deco16ic->pf3_bank = bank1;
7851037      }
786
787      deco16_pf3_bank=bank1;
7881038   }
7891039
790   if (deco16_bank_callback_4) {
791      bank2=deco16_bank_callback_4(deco16_pf34_control[7]>>8);
792      if (bank2!=deco16_pf4_bank) {
793         //if (pf4_tilemap_8x8) tilemap_mark_all_tiles_dirty(pf4_tilemap_8x8);
794         if (pf4_tilemap_16x16) tilemap_mark_all_tiles_dirty(pf4_tilemap_16x16);
1040   if (deco16ic->bank_cb[3])
1041   {
1042      bank2 = deco16ic->bank_cb[3](deco16ic->pf34_control[7] >> 8);
1043      if (bank2 != deco16ic->pf4_bank)
1044      {
1045         if (deco16ic->pf4_tilemap_16x16)
1046            tilemap_mark_all_tiles_dirty(deco16ic->pf4_tilemap_16x16);
1047
1048         deco16ic->pf4_bank = bank2;
7951049      }
796
797      deco16_pf4_bank=bank2;
7981050   }
7991051}
8001052
8011053/*****************************************************************************************/
8021054
803void deco16_print_debug_info(running_machine *machine, bitmap_t *bitmap)
1055void deco16ic_print_debug_info(running_device *device, bitmap_t *bitmap)
8041056{
1057   deco16ic_state *deco16ic = get_safe_token(device);
8051058   char buf[64*5];
8061059
807   if (input_code_pressed(machine, KEYCODE_O))
1060   if (input_code_pressed(device->machine, KEYCODE_O))
8081061      return;
8091062
810   if (deco16_pf12_control) {
811      sprintf(buf,"%04X %04X %04X %04X\n",deco16_pf12_control[0],deco16_pf12_control[1],deco16_pf12_control[2],deco16_pf12_control[3]);
812      sprintf(&buf[strlen(buf)],"%04X %04X %04X %04X\n",deco16_pf12_control[4],deco16_pf12_control[5],deco16_pf12_control[6],deco16_pf12_control[7]);
1063   if (deco16ic->pf12_control)
1064   {
1065      sprintf(buf,"%04X %04X %04X %04X\n", deco16ic->pf12_control[0], deco16ic->pf12_control[1], deco16ic->pf12_control[2], deco16ic->pf12_control[3]);
1066      sprintf(&buf[strlen(buf)],"%04X %04X %04X %04X\n", deco16ic->pf12_control[4], deco16ic->pf12_control[5], deco16ic->pf12_control[6], deco16ic->pf12_control[7]);
8131067   }
8141068   else
8151069      sprintf(buf, "\n\n");
8161070
817   if (deco16_pf34_control) {
818      sprintf(&buf[strlen(buf)],"%04X %04X %04X %04X\n",deco16_pf34_control[0],deco16_pf34_control[1],deco16_pf34_control[2],deco16_pf34_control[3]);
819      sprintf(&buf[strlen(buf)],"%04X %04X %04X %04X\n",deco16_pf34_control[4],deco16_pf34_control[5],deco16_pf34_control[6],deco16_pf34_control[7]);
1071   if (deco16ic->pf34_control)
1072   {
1073      sprintf(&buf[strlen(buf)],"%04X %04X %04X %04X\n", deco16ic->pf34_control[0], deco16ic->pf34_control[1], deco16ic->pf34_control[2], deco16ic->pf34_control[3]);
1074      sprintf(&buf[strlen(buf)],"%04X %04X %04X %04X\n", deco16ic->pf34_control[4], deco16ic->pf34_control[5], deco16ic->pf34_control[6], deco16ic->pf34_control[7]);
8201075   }
8211076   else
8221077      sprintf(&buf[strlen(buf)], "\n\n");
8231078
824   sprintf(&buf[strlen(buf)],"%04X",deco16_priority);
1079   sprintf(&buf[strlen(buf)],"%04X", deco16ic->priority);
8251080
826   ui_draw_text(render_container_get_ui(), buf,60,40);
1081   ui_draw_text(render_container_get_ui(), buf, 60, 40);
8271082}
8281083
8291084/*****************************************************************************************/
8301085
831void deco16_clear_sprite_priority_bitmap(void)
1086void deco16ic_clear_sprite_priority_bitmap( running_device *device )
8321087{
833   if (sprite_priority_bitmap)
834      bitmap_fill(sprite_priority_bitmap,NULL,0);
1088   deco16ic_state *deco16ic = get_safe_token(device);
1089
1090   if (deco16ic->sprite_priority_bitmap)
1091      bitmap_fill(deco16ic->sprite_priority_bitmap, NULL, 0);
8351092}
8361093
8371094/* A special pdrawgfx z-buffered sprite renderer that is needed to properly draw multiple sprite sources with alpha */
838void deco16_pdrawgfx(
839      bitmap_t *dest,const rectangle *clip,const gfx_element *gfx,
840      UINT32 code,UINT32 color,int flipx,int flipy,int sx,int sy,
841      int transparent_color,UINT32 pri_mask,UINT32 sprite_mask,UINT8 write_pri,UINT8 alpha)
1095void deco16ic_pdrawgfx(
1096      running_device *device,
1097      bitmap_t *dest, const rectangle *clip, const gfx_element *gfx,
1098      UINT32 code, UINT32 color, int flipx, int flipy, int sx, int sy,
1099      int transparent_color, UINT32 pri_mask, UINT32 sprite_mask, UINT8 write_pri, UINT8 alpha)
8421100{
843   int ox,oy,cx,cy;
844   int x_index,y_index,x,y;
1101   deco16ic_state *deco16ic = get_safe_token(device);
1102   int ox, oy, cx, cy;
1103   int x_index, y_index, x, y;
8451104   bitmap_t *priority_bitmap = gfx->machine->priority_bitmap;
8461105   const pen_t *pal = &gfx->machine->pens[gfx->color_base + gfx->color_granularity * (color % gfx->total_colors)];
8471106   const UINT8 *code_base = gfx_element_get_data(gfx, code % gfx->total_elements);
r7500r7501
8501109   ox = sx;
8511110   oy = sy;
8521111
853   if (sx>319 || sy>247 || sx<-15 || sy<-7)
1112   if (sx > 319 || sy > 247 || sx < -15 || sy < -7)
8541113      return;
8551114
856   if (sy<0) sy=0;
857   if (sx<0) sx=0;
858   if (sx>319) cx=319;
859   else cx=ox+16;
1115   if (sy < 0) sy = 0;
1116   if (sx < 0) sx = 0;
8601117
861   cy=(sy-oy);
1118   if (sx > 319) cx = 319;
1119   else cx = ox + 16;
8621120
863   if (flipy) y_index=15-cy; else y_index=cy;
1121   cy = (sy - oy);
8641122
865   for( y=0; y<16-cy; y++ )
1123   if (flipy) y_index = 15 - cy; else y_index = cy;
1124
1125   for (y = 0; y < 16 - cy; y++)
8661126   {
8671127      const UINT8 *source = code_base + (y_index * gfx->line_modulo);
8681128      UINT32 *destb = BITMAP_ADDR32(dest, sy, 0);
8691129      UINT8 *pri = BITMAP_ADDR8(priority_bitmap, sy, 0);
870      UINT8 *spri = BITMAP_ADDR8(sprite_priority_bitmap, sy, 0);
1130      UINT8 *spri = BITMAP_ADDR8(deco16ic->sprite_priority_bitmap, sy, 0);
8711131
8721132      if (sy >= 0 && sy < 248)
8731133      {
874         if (flipx) { source+=15-(sx-ox); x_index=-1; } else { x_index=1; source+=(sx-ox); }
1134         if (flipx) { source += 15 - (sx - ox); x_index = -1; }
1135         else       { source += (sx - ox); x_index = 1; }
8751136
876         for (x=sx; x<cx; x++)
1137         for (x = sx; x < cx; x++)
8771138         {
8781139            int c = *source;
879            if( c != transparent_color && x >= 0 && x < 320 )
1140            if (c != transparent_color && x >= 0 && x < 320)
8801141            {
881               if (pri_mask>pri[x] && sprite_mask>spri[x]) {
1142               if (pri_mask>pri[x] && sprite_mask>spri[x])
1143               {
8821144                  if (alpha != 0xff)
8831145                     destb[x] = alpha_blend_r32(destb[x], pal[c], alpha);
8841146                  else
r7500r7501
8861148                  if (write_pri)
8871149                     pri[x] |= pri_mask;
8881150               }
889               spri[x]|=sprite_mask;
1151               spri[x] |= sprite_mask;
8901152            }
891            source+=x_index;
1153            source += x_index;
8921154         }
8931155      }
8941156
8951157      sy++;
896      if (sy>247)
1158      if (sy > 247)
8971159         return;
8981160      if (flipy) y_index--; else y_index++;
8991161   }
r7500r7501
9011163
9021164/*****************************************************************************************/
9031165
904void deco16_tilemap_1_draw(running_device *screen, bitmap_t *bitmap, const rectangle *cliprect, int flags, UINT32 priority)
1166void deco16ic_tilemap_1_draw( running_device *device, bitmap_t *bitmap, const rectangle *cliprect, int flags, UINT32 priority )
9051167{
906   if (use_custom_pf1)
1168   deco16ic_state *deco16ic = get_safe_token(device);
1169
1170   if (deco16ic->use_custom_pf1)
9071171   {
908      custom_tilemap_draw(screen->machine, bitmap,pf1_tilemap_8x8,pf1_tilemap_16x16,0,0,pf1_rowscroll_ptr,deco16_pf12_control[1], deco16_pf12_control[2], deco16_pf12_control[5]&0xff, deco16_pf12_control[6]&0xff, 0, 0, deco16_pf1_trans_mask, flags, priority);
1172      custom_tilemap_draw(device, bitmap, deco16ic->pf1_tilemap_8x8, deco16ic->pf1_tilemap_16x16, 0, 0, deco16ic->pf1_rowscroll_ptr, deco16ic->pf12_control[1], deco16ic->pf12_control[2], deco16ic->pf12_control[5] & 0xff, deco16ic->pf12_control[6] & 0xff, 0, 0, deco16ic->pf1_trans_mask, flags, priority);
9091173   }
9101174   else
9111175   {
912      if (pf1_tilemap_8x8) tilemap_draw(bitmap,cliprect,pf1_tilemap_8x8,flags,priority);
913      if (pf1_tilemap_16x16) tilemap_draw(bitmap,cliprect,pf1_tilemap_16x16,flags,priority);
1176      if (deco16ic->pf1_tilemap_8x8)
1177         tilemap_draw(bitmap, cliprect, deco16ic->pf1_tilemap_8x8, flags, priority);
1178      if (deco16ic->pf1_tilemap_16x16)
1179         tilemap_draw(bitmap, cliprect, deco16ic->pf1_tilemap_16x16, flags, priority);
9141180   }
9151181}
9161182
917void deco16_tilemap_2_draw(running_device *screen, bitmap_t *bitmap, const rectangle *cliprect, int flags, UINT32 priority)
1183void deco16ic_tilemap_2_draw(running_device *device, bitmap_t *bitmap, const rectangle *cliprect, int flags, UINT32 priority)
9181184{
919   if (use_custom_pf2)
1185   deco16ic_state *deco16ic = get_safe_token(device);
1186
1187   if (deco16ic->use_custom_pf2)
9201188   {
921      custom_tilemap_draw(screen->machine, bitmap,pf2_tilemap_8x8,pf2_tilemap_16x16,0,0,pf2_rowscroll_ptr,deco16_pf12_control[3], deco16_pf12_control[4], deco16_pf12_control[5]>>8, deco16_pf12_control[6]>>8, 0, 0, deco16_pf2_trans_mask, flags, priority);
1189      custom_tilemap_draw(device, bitmap, deco16ic->pf2_tilemap_8x8, deco16ic->pf2_tilemap_16x16, 0, 0, deco16ic->pf2_rowscroll_ptr, deco16ic->pf12_control[3], deco16ic->pf12_control[4], deco16ic->pf12_control[5] >> 8, deco16ic->pf12_control[6] >> 8, 0, 0, deco16ic->pf2_trans_mask, flags, priority);
9221190   }
9231191   else
9241192   {
925      if (pf2_tilemap_8x8) tilemap_draw(bitmap,cliprect,pf2_tilemap_8x8,flags,priority);
926      if (pf2_tilemap_16x16) tilemap_draw(bitmap,cliprect,pf2_tilemap_16x16,flags,priority);
1193      if (deco16ic->pf2_tilemap_8x8)
1194         tilemap_draw(bitmap, cliprect, deco16ic->pf2_tilemap_8x8, flags, priority);
1195      if (deco16ic->pf2_tilemap_16x16)
1196         tilemap_draw(bitmap, cliprect, deco16ic->pf2_tilemap_16x16, flags, priority);
9271197   }
9281198}
9291199
930void deco16_tilemap_3_draw(running_device *screen, bitmap_t *bitmap, const rectangle *cliprect, int flags, UINT32 priority)
1200void deco16ic_tilemap_3_draw(running_device *device, bitmap_t *bitmap, const rectangle *cliprect, int flags, UINT32 priority)
9311201{
932   if (use_custom_pf3) custom_tilemap_draw(screen->machine, bitmap,0,pf3_tilemap_16x16,0,0,pf3_rowscroll_ptr,deco16_pf34_control[1], deco16_pf34_control[2], deco16_pf34_control[5]&0xff, deco16_pf34_control[6]&0xff, 0, 0, deco16_pf3_trans_mask, flags, priority);
933   else if (pf3_tilemap_16x16) tilemap_draw(bitmap,cliprect,pf3_tilemap_16x16,flags,priority);
1202   deco16ic_state *deco16ic = get_safe_token(device);
1203
1204   if (deco16ic->use_custom_pf3)
1205      custom_tilemap_draw(device, bitmap, 0, deco16ic->pf3_tilemap_16x16, 0, 0, deco16ic->pf3_rowscroll_ptr, deco16ic->pf34_control[1], deco16ic->pf34_control[2], deco16ic->pf34_control[5] & 0xff, deco16ic->pf34_control[6] & 0xff, 0, 0, deco16ic->pf3_trans_mask, flags, priority);
1206   else if (deco16ic->pf3_tilemap_16x16)
1207      tilemap_draw(bitmap, cliprect, deco16ic->pf3_tilemap_16x16, flags, priority);
9341208}
9351209
936void deco16_tilemap_4_draw(running_device *screen, bitmap_t *bitmap, const rectangle *cliprect, int flags, UINT32 priority)
1210void deco16ic_tilemap_4_draw(running_device *device, bitmap_t *bitmap, const rectangle *cliprect, int flags, UINT32 priority)
9371211{
938   if (use_custom_pf4) custom_tilemap_draw(screen->machine, bitmap,0,pf4_tilemap_16x16,0,0,pf4_rowscroll_ptr,deco16_pf34_control[3], deco16_pf34_control[4], deco16_pf34_control[5]>>8, deco16_pf34_control[6]>>8, 0, 0, deco16_pf4_trans_mask, flags, priority);
939   else if (pf4_tilemap_16x16) tilemap_draw(bitmap,cliprect,pf4_tilemap_16x16,flags,priority);
1212   deco16ic_state *deco16ic = get_safe_token(device);
1213
1214   if (deco16ic->use_custom_pf4)
1215      custom_tilemap_draw(device, bitmap, 0, deco16ic->pf4_tilemap_16x16, 0, 0, deco16ic->pf4_rowscroll_ptr, deco16ic->pf34_control[3], deco16ic->pf34_control[4], deco16ic->pf34_control[5] >> 8, deco16ic->pf34_control[6] >> 8, 0, 0, deco16ic->pf4_trans_mask, flags, priority);
1216   else if (deco16ic->pf4_tilemap_16x16)
1217      tilemap_draw(bitmap, cliprect, deco16ic->pf4_tilemap_16x16, flags, priority);
9401218}
9411219
9421220/*****************************************************************************************/
9431221
9441222// Combines the output of two 4BPP tilemaps into an 8BPP tilemap
945void deco16_tilemap_34_combine_draw(running_device *screen, bitmap_t *bitmap, const rectangle *cliprect, int flags, UINT32 priority)
1223void deco16ic_tilemap_34_combine_draw(running_device *device, bitmap_t *bitmap, const rectangle *cliprect, int flags, UINT32 priority)
9461224{
947   custom_tilemap_draw(screen->machine, bitmap,0,pf3_tilemap_16x16,0,pf4_tilemap_16x16,pf3_rowscroll_ptr,deco16_pf34_control[1], deco16_pf34_control[2], deco16_pf34_control[5]&0xff, deco16_pf34_control[6]&0xff, 0xf, 4, 0xff, flags, priority);
1225   deco16ic_state *deco16ic = get_safe_token(device);
1226   custom_tilemap_draw(device, bitmap, 0, deco16ic->pf3_tilemap_16x16, 0, deco16ic->pf4_tilemap_16x16, deco16ic->pf3_rowscroll_ptr, deco16ic->pf34_control[1], deco16ic->pf34_control[2], deco16ic->pf34_control[5] & 0xff, deco16ic->pf34_control[6] & 0xff, 0xf, 4, 0xff, flags, priority);
9481227}
9491228
950/*****************************************************************************************/
9511229
952/*
953    Consider this the 'reference rasterizer' for the 56/74/141 tilemap chips - it implements
954    simultaneous row & column scroll which the Mame tilemap core cannot do.  It also
955    implements combining the 4BPP output of two tilemaps into 8BPP output.  This function
956    is automatically called when the tilemap is in a state the cannot be properly rendered
957    by the Mame core.
958*/
1230/*****************************************************************************
1231    DEVICE INTERFACE
1232*****************************************************************************/
9591233
960static void custom_tilemap_draw(
961   running_machine *machine,
962   bitmap_t *bitmap,
963   tilemap_t *tilemap0_8x8,
964   tilemap_t *tilemap0_16x16,
965   tilemap_t *tilemap1_8x8,
966   tilemap_t *tilemap1_16x16,
967   const UINT16 *rowscroll_ptr,
968   const UINT16 scrollx,
969   const UINT16 scrolly,
970   const UINT16 control0,
971   const UINT16 control1,
972   int combine_mask,
973   int combine_shift,
974   int trans_mask,
975   int flags,
976   UINT32 priority)
1234static DEVICE_START( deco16ic )
9771235{
978   tilemap_t *tilemap0 = (control1&0x80) ? tilemap0_8x8 : tilemap0_16x16;
979   tilemap_t *tilemap1 = (control1&0x80) ? tilemap1_8x8 : tilemap1_16x16;
980   const bitmap_t *src_bitmap0 = tilemap0 ? tilemap_get_pixmap(tilemap0) : NULL;
981   const bitmap_t *src_bitmap1 = tilemap1 ? tilemap_get_pixmap(tilemap1) : NULL;
982   int width_mask, height_mask, x, y, p;
983   int column_offset, src_x=0, src_y=0;
984   int   row_type=1 << ((control0>>3)&0xf);
985   int col_type=8 << (control0&7);
1236   deco16ic_state *deco16ic = get_safe_token(device);
1237   const deco16ic_interface *intf = get_interface(device);
1238   int width, height;
9861239
987   if (!src_bitmap0)
988      return;
1240   deco16ic->screen = devtag_get_device(device->machine, intf->screen);
1241   width = video_screen_get_width(deco16ic->screen);
1242   height = video_screen_get_height(deco16ic->screen);
9891243
990   // Playfield disable
991   if (!(control0&0x80))
992      return;
1244   deco16ic->sprite_priority_bitmap = auto_bitmap_alloc(device->machine, width, height, BITMAP_FORMAT_INDEXED8);
9931245
994   width_mask=src_bitmap0->width - 1;
995   height_mask=src_bitmap0->height - 1;
996   src_y=scrolly + 8;
1246   deco16ic->bank_cb[0] = intf->bank_cb0;
1247   deco16ic->bank_cb[1] = intf->bank_cb1;
1248   deco16ic->bank_cb[2] = intf->bank_cb2;
1249   deco16ic->bank_cb[3] = intf->bank_cb3;
9971250
998   for (y=8; y<248; y++) {
999      if (rowscroll_ptr && (control1&0x40))
1000         src_x=scrollx + rowscroll_ptr[src_y / row_type];
1001      else
1002         src_x=scrollx;
1251   deco16ic->pf1_trans_mask = intf->trans_mask1;
1252   deco16ic->pf2_trans_mask = intf->trans_mask2;
1253   deco16ic->pf3_trans_mask = intf->trans_mask3;
1254   deco16ic->pf4_trans_mask = intf->trans_mask4;
10031255
1004      src_x &= width_mask;
1256   deco16ic->pf1_colour_bank = intf->col_base1;
1257   deco16ic->pf2_colour_bank = intf->col_base2;
1258   deco16ic->pf3_colour_bank = intf->col_base3;
1259   deco16ic->pf4_colour_bank = intf->col_base4;
10051260
1006      if (bitmap->bpp == 16)
1007      {
1008         for (x=0; x<320; x++) {
1009            if (rowscroll_ptr && (control1&0x20))
1010               column_offset=rowscroll_ptr[0x200 + ((src_x&0x1ff) / col_type)];
1011            else
1012               column_offset=0;
1261   deco16ic->pf1_colourmask = intf->col_mask1;
1262   deco16ic->pf2_colourmask = intf->col_mask2;
1263   deco16ic->pf3_colourmask = intf->col_mask3;
1264   deco16ic->pf4_colourmask = intf->col_mask4;
10131265
1014            p=*BITMAP_ADDR16(src_bitmap0, (src_y + column_offset)&height_mask, src_x);
1015            if (src_bitmap1)
1016               p|=(*BITMAP_ADDR16(src_bitmap1, (src_y + column_offset)&height_mask, src_x)&combine_mask)<<combine_shift;
1266   deco16ic->pf1_tilemap_16x16 =   tilemap_create_device(device, get_pf1_tile_info, deco16_scan_rows, 16, 16, 64, 32);
1267   deco16ic->pf1_tilemap_8x8 = tilemap_create_device(device, get_pf1_tile_info_b, tilemap_scan_rows, 8, 8, 64, 32);
10171268
1018            src_x=(src_x+1)&width_mask;
1019            if ((flags&TILEMAP_DRAW_OPAQUE) || (p&trans_mask))
1020            {
1021               *BITMAP_ADDR16(bitmap, y, x) = machine->pens[p];
1022               if (machine->priority_bitmap)
1023               {
1024                  UINT8 *pri = BITMAP_ADDR8(machine->priority_bitmap, y, 0);
1025                  pri[x]|=priority;
1026               }
1027            }
1028         }
1029      }
1030      else
1031      {
1032         /* boogwing */
1033         for (x=0; x<320; x++) {
1034            if (rowscroll_ptr && (control1&0x20))
1035               column_offset=rowscroll_ptr[0x200 + ((src_x&0x1ff) / col_type)];
1036            else
1037               column_offset=0;
1269   if (intf->split)
1270      deco16ic->pf2_tilemap_16x16 =   tilemap_create_device(device, get_pf2_tile_info, deco16_scan_rows, 16, 16, intf->full_width ? 64 : 32, 32);
1271   else
1272      deco16ic->pf2_tilemap_16x16 =   tilemap_create_device(device, get_pf2_tile_info, deco16_scan_rows, 16, 16, intf->full_width ? 64 : 32, 32);
10381273
1039            p=*BITMAP_ADDR16(src_bitmap0, (src_y + column_offset)&height_mask, src_x);
1040            if (src_bitmap1)
1041               p|=(*BITMAP_ADDR16(src_bitmap1, (src_y + column_offset)&height_mask, src_x)&combine_mask)<<combine_shift;
1274   deco16ic->pf2_tilemap_8x8 = tilemap_create_device(device, get_pf2_tile_info_b, tilemap_scan_rows, 8, 8, intf->full_width ? 64 : 32, 32);
10421275
1043            src_x=(src_x+1)&width_mask;
1044            if ((flags&TILEMAP_DRAW_OPAQUE) || (p&trans_mask))
1045            {
1046               *BITMAP_ADDR32(bitmap, y, x) = machine->pens[p];
1047               if (machine->priority_bitmap)
1048               {
1049                  UINT8 *pri = BITMAP_ADDR8(machine->priority_bitmap, y, 0);
1050                  pri[x]|=priority;
1051               }
1052            }
1053         }
1054      }
1055      src_y=(src_y+1)&height_mask;
1276   if (!intf->pf12_only)
1277   {
1278      deco16ic->pf4_tilemap_16x16 =   tilemap_create_device(device, get_pf4_tile_info, deco16_scan_rows, 16, 16, intf->full_width ? 64 : 32, 32);
1279      deco16ic->pf3_tilemap_16x16 =   tilemap_create_device(device, get_pf3_tile_info, deco16_scan_rows, 16, 16, intf->full_width ? 64 : 32, 32);
10561280   }
1281   else
1282   {
1283      deco16ic->pf3_tilemap_16x16 = 0;
1284      deco16ic->pf4_tilemap_16x16 = 0;
1285   }
1286
1287   tilemap_set_transparent_pen(deco16ic->pf1_tilemap_8x8, 0);
1288   tilemap_set_transparent_pen(deco16ic->pf2_tilemap_8x8, 0);
1289   tilemap_set_transparent_pen(deco16ic->pf1_tilemap_16x16, 0);
1290   tilemap_set_transparent_pen(deco16ic->pf2_tilemap_16x16, 0);
1291
1292   if (intf->split) /* Caveman Ninja only */
1293      tilemap_set_transmask(deco16ic->pf2_tilemap_16x16, 0, 0x00ff, 0xff01);
1294
1295   if (!intf->pf12_only)
1296   {
1297      tilemap_set_transparent_pen(deco16ic->pf3_tilemap_16x16, 0);
1298      tilemap_set_transparent_pen(deco16ic->pf4_tilemap_16x16, 0);
1299   }
1300
1301
1302   deco16ic->dirty_palette = auto_alloc_array_clear(device->machine, UINT8, 4096);
1303   deco16ic->raster_display_list = auto_alloc_array_clear(device->machine, UINT16, 20 * 256 / 2);
1304
1305   deco16ic->pf1_data = auto_alloc_array_clear(device->machine, UINT16, 0x2000 / 2);
1306   deco16ic->pf2_data = auto_alloc_array_clear(device->machine, UINT16, 0x2000 / 2);
1307   deco16ic->pf3_data = auto_alloc_array_clear(device->machine, UINT16, 0x2000 / 2);
1308   deco16ic->pf4_data = auto_alloc_array_clear(device->machine, UINT16, 0x2000 / 2);
1309   deco16ic->pf12_control = auto_alloc_array_clear(device->machine, UINT16, 0x10 / 2);
1310   deco16ic->pf34_control = auto_alloc_array_clear(device->machine, UINT16, 0x10 / 2);
1311
1312   state_save_register_device_item(device, 0, deco16ic->priority);
1313   state_save_register_device_item(device, 0, deco16ic->raster_display_position);
1314   state_save_register_device_item(device, 0, deco16ic->use_custom_pf1);
1315   state_save_register_device_item(device, 0, deco16ic->use_custom_pf2);
1316   state_save_register_device_item(device, 0, deco16ic->use_custom_pf3);
1317   state_save_register_device_item(device, 0, deco16ic->use_custom_pf4);
1318   state_save_register_device_item(device, 0, deco16ic->pf1_bank);
1319   state_save_register_device_item(device, 0, deco16ic->pf2_bank);
1320   state_save_register_device_item(device, 0, deco16ic->pf3_bank);
1321   state_save_register_device_item(device, 0, deco16ic->pf4_bank);
1322   state_save_register_device_item(device, 0, deco16ic->pf12_8x8_gfx_bank);
1323   state_save_register_device_item(device, 0, deco16ic->pf12_16x16_gfx_bank);
1324   state_save_register_device_item(device, 0, deco16ic->pf34_16x16_gfx_bank);
1325   state_save_register_device_item(device, 0, deco16ic->pf12_last_small);
1326   state_save_register_device_item(device, 0, deco16ic->pf12_last_big);
1327   state_save_register_device_item(device, 0, deco16ic->pf34_last_big);
1328
1329   state_save_register_device_item_pointer(device, 0, deco16ic->dirty_palette, 4096);
1330   state_save_register_device_item_pointer(device, 0, deco16ic->raster_display_list, 20 * 256 / 2);
1331   state_save_register_device_item_pointer(device, 0, deco16ic->pf1_data, 0x2000 / 2);
1332   state_save_register_device_item_pointer(device, 0, deco16ic->pf2_data, 0x2000 / 2);
1333   state_save_register_device_item_pointer(device, 0, deco16ic->pf3_data, 0x2000 / 2);
1334   state_save_register_device_item_pointer(device, 0, deco16ic->pf4_data, 0x2000 / 2);
1335   state_save_register_device_item_pointer(device, 0, deco16ic->pf12_control, 0x10 / 2);
1336   state_save_register_device_item_pointer(device, 0, deco16ic->pf34_control, 0x10 / 2);
10571337}
1338
1339static DEVICE_RESET( deco16ic )
1340{
1341   deco16ic_state *deco16ic = get_safe_token(device);
1342
1343   deco16ic->pf1_bank = deco16ic->pf2_bank = deco16ic->pf3_bank = deco16ic->pf4_bank = 0;
1344
1345   deco16ic->pf12_8x8_gfx_bank = 0;
1346   deco16ic->pf12_16x16_gfx_bank = 1;
1347   deco16ic->pf34_16x16_gfx_bank = 2;
1348
1349   deco16ic->raster_display_position = 0;
1350
1351   deco16ic->pf12_last_small = deco16ic->pf12_last_big = deco16ic->pf34_last_big = -1;
1352
1353   deco16ic->priority = 0;
1354   deco16ic->use_custom_pf1 = deco16ic->use_custom_pf2 = deco16ic->use_custom_pf3 = deco16ic->use_custom_pf4 = 0;
1355
1356   deco16ic->pf1_rowscroll_ptr = 0;
1357   deco16ic->pf2_rowscroll_ptr = 0;
1358   deco16ic->pf3_rowscroll_ptr = 0;
1359   deco16ic->pf4_rowscroll_ptr = 0;
1360}
1361
1362
1363DEVICE_GET_INFO( deco16ic )
1364{
1365   switch (state)
1366   {
1367      /* --- the following bits of info are returned as 64-bit signed integers --- */
1368      case DEVINFO_INT_TOKEN_BYTES:         info->i = sizeof(deco16ic_state);               break;
1369      case DEVINFO_INT_CLASS:               info->i = DEVICE_CLASS_VIDEO;               break;
1370
1371      /* --- the following bits of info are returned as pointers to data or functions --- */
1372      case DEVINFO_FCT_START:               info->start = DEVICE_START_NAME(deco16ic);      break;
1373      case DEVINFO_FCT_STOP:               /* Nothing */                           break;
1374      case DEVINFO_FCT_RESET:               info->reset = DEVICE_RESET_NAME(deco16ic);      break;
1375
1376      /* --- the following bits of info are returned as NULL-terminated strings --- */
1377      case DEVINFO_STR_NAME:               strcpy(info->s, "Data East IC 55 / 56 / 74 / 141");            break;
1378      case DEVINFO_STR_FAMILY:            strcpy(info->s, "Data East Video IC");               break;
1379      case DEVINFO_STR_VERSION:            strcpy(info->s, "1.0");                     break;
1380      case DEVINFO_STR_SOURCE_FILE:         strcpy(info->s, __FILE__);                  break;
1381      case DEVINFO_STR_CREDITS:            strcpy(info->s, "Copyright MAME Team");         break;
1382   }
1383}
src/mame/video/deco16ic.h
r0r7501
1/*************************************************************************
2
3    deco16ic.h
4
5    Implementation of various Data East custom 16bit video ICs
6
7**************************************************************************/
8
9#include "devcb.h"
10
11
12/***************************************************************************
13    TYPE DEFINITIONS
14***************************************************************************/
15
16typedef int (*deco16_bank_cb)( const int bank );
17
18
19typedef struct _deco16ic_interface deco16ic_interface;
20struct _deco16ic_interface
21{
22   const char         *screen;
23   int                pf12_only;
24   int                split;
25   int                full_width;
26
27   int                trans_mask1, trans_mask2, trans_mask3, trans_mask4;
28   int                col_base1, col_base2, col_base3, col_base4;
29   int                col_mask1, col_mask2, col_mask3, col_mask4;
30   deco16_bank_cb     bank_cb0, bank_cb1, bank_cb2, bank_cb3;
31};
32
33/***************************************************************************
34    FUNCTION PROTOTYPES
35***************************************************************************/
36
37DEVICE_GET_INFO( deco16ic );
38
39
40/***************************************************************************
41    DEVICE CONFIGURATION MACROS
42***************************************************************************/
43
44#define DECO16IC DEVICE_GET_INFO_NAME( deco16ic )
45
46#define MDRV_DECO16IC_ADD(_tag, _interface) \
47   MDRV_DEVICE_ADD(_tag, DECO16IC, 0) \
48   MDRV_DEVICE_CONFIG(_interface)
49
50/***************************************************************************
51    DEVICE I/O FUNCTIONS
52***************************************************************************/
53
54WRITE16_DEVICE_HANDLER( deco16ic_pf1_data_w );
55WRITE16_DEVICE_HANDLER( deco16ic_pf2_data_w );
56WRITE16_DEVICE_HANDLER( deco16ic_pf3_data_w );
57WRITE16_DEVICE_HANDLER( deco16ic_pf4_data_w );
58
59READ16_DEVICE_HANDLER( deco16ic_pf1_data_r );
60READ16_DEVICE_HANDLER( deco16ic_pf2_data_r );
61READ16_DEVICE_HANDLER( deco16ic_pf3_data_r );
62READ16_DEVICE_HANDLER( deco16ic_pf4_data_r );
63
64WRITE16_DEVICE_HANDLER( deco16ic_pf12_control_w );
65WRITE16_DEVICE_HANDLER( deco16ic_pf34_control_w );
66
67READ16_DEVICE_HANDLER( deco16ic_pf12_control_r );
68READ16_DEVICE_HANDLER( deco16ic_pf34_control_r );
69
70
71WRITE32_DEVICE_HANDLER( deco16ic_pf1_data_dword_w );
72WRITE32_DEVICE_HANDLER( deco16ic_pf2_data_dword_w );
73WRITE32_DEVICE_HANDLER( deco16ic_pf3_data_dword_w );
74WRITE32_DEVICE_HANDLER( deco16ic_pf4_data_dword_w );
75
76READ32_DEVICE_HANDLER( deco16ic_pf1_data_dword_r );
77READ32_DEVICE_HANDLER( deco16ic_pf2_data_dword_r );
78READ32_DEVICE_HANDLER( deco16ic_pf3_data_dword_r );
79READ32_DEVICE_HANDLER( deco16ic_pf4_data_dword_r );
80
81WRITE32_DEVICE_HANDLER( deco16ic_pf12_control_dword_w );
82WRITE32_DEVICE_HANDLER( deco16ic_pf34_control_dword_w );
83
84READ32_DEVICE_HANDLER( deco16ic_pf12_control_dword_r );
85READ32_DEVICE_HANDLER( deco16ic_pf34_control_dword_r );
86
87
88WRITE16_DEVICE_HANDLER( deco16ic_nonbuffered_palette_w );
89WRITE16_DEVICE_HANDLER( deco16ic_buffered_palette_w );
90WRITE16_DEVICE_HANDLER( deco16ic_palette_dma_w );
91
92WRITE16_DEVICE_HANDLER( deco16ic_priority_w );
93READ16_DEVICE_HANDLER( deco16ic_priority_r );
94
95READ16_DEVICE_HANDLER( deco16ic_71_r );
96
97void deco16ic_print_debug_info(running_device *device, bitmap_t *bitmap);
98
99void deco16ic_pf12_update(running_device *device, const UINT16 *rowscroll_1_ptr, const UINT16 *rowscroll_2_ptr);
100void deco16ic_pf34_update(running_device *device, const UINT16 *rowscroll_1_ptr, const UINT16 *rowscroll_2_ptr);
101
102void deco16ic_tilemap_1_draw(running_device *device, bitmap_t *bitmap, const rectangle *cliprect, int flags, UINT32 priority);
103void deco16ic_tilemap_2_draw(running_device *device, bitmap_t *bitmap, const rectangle *cliprect, int flags, UINT32 priority);
104void deco16ic_tilemap_3_draw(running_device *device, bitmap_t *bitmap, const rectangle *cliprect, int flags, UINT32 priority);
105void deco16ic_tilemap_4_draw(running_device *device, bitmap_t *bitmap, const rectangle *cliprect, int flags, UINT32 priority);
106
107/* used by boogwing, nitrobal */
108void deco16ic_tilemap_34_combine_draw(running_device *device, bitmap_t *bitmap, const rectangle *cliprect, int flags, UINT32 priority);
109
110
111/* used by boogwing, dassault, nitrobal */
112void deco16ic_clear_sprite_priority_bitmap(running_device *device);
113void deco16ic_pdrawgfx(
114      running_device *device,
115      bitmap_t *dest,const rectangle *clip,const gfx_element *gfx,
116      UINT32 code,UINT32 color,int flipx,int flipy,int sx,int sy,
117      int transparent_color,UINT32 pri_mask,UINT32 sprite_mask,UINT8 write_pri,UINT8 alpha);
118
119/* used by robocop2 */
120void deco16ic_set_tilemap_colour_mask(running_device *device, int tmap, int mask);
121void deco16ic_pf34_set_gfxbank(running_device *device, int small, int big);
122
123/* used by stoneage */
124void deco16ic_set_scrolldx(running_device *device, int tmap, int size, int dx, int dx_if_flipped);
src/mame/video/mrdo.c
r7500r7501
77***************************************************************************/
88
99#include "emu.h"
10#include "includes/mrdo.h"
1011
1112
12UINT8 *mrdo_bgvideoram,*mrdo_fgvideoram;
13static tilemap_t *bg_tilemap,*fg_tilemap;
14static int flipscreen;
15
16
17
1813/***************************************************************************
1914
2015  Convert the color PROMs into a more useable format.
r7500r7501
4641  200 ohm pulldown on all three components
4742
4843***************************************************************************/
44
4945PALETTE_INIT( mrdo )
5046{
5147   int i;
r7500r7501
138134
139135static TILE_GET_INFO( get_bg_tile_info )
140136{
141   UINT8 attr = mrdo_bgvideoram[tile_index];
137   mrdo_state *state = (mrdo_state *)machine->driver_data;
138   UINT8 attr = state->bgvideoram[tile_index];
142139   SET_TILE_INFO(
143140         1,
144         mrdo_bgvideoram[tile_index+0x400] + ((attr & 0x80) << 1),
141         state->bgvideoram[tile_index + 0x400] + ((attr & 0x80) << 1),
145142         attr & 0x3f,
146143         (attr & 0x40) ? TILE_FORCE_LAYER0 : 0);
147144}
148145
149146static TILE_GET_INFO( get_fg_tile_info )
150147{
151   UINT8 attr = mrdo_fgvideoram[tile_index];
148   mrdo_state *state = (mrdo_state *)machine->driver_data;
149   UINT8 attr = state->fgvideoram[tile_index];
152150   SET_TILE_INFO(
153151         0,
154         mrdo_fgvideoram[tile_index+0x400] + ((attr & 0x80) << 1),
152         state->fgvideoram[tile_index+0x400] + ((attr & 0x80) << 1),
155153         attr & 0x3f,
156154         (attr & 0x40) ? TILE_FORCE_LAYER0 : 0);
157155}
r7500r7501
166164
167165VIDEO_START( mrdo )
168166{
169   bg_tilemap = tilemap_create(machine, get_bg_tile_info,tilemap_scan_rows,8,8,32,32);
170   fg_tilemap = tilemap_create(machine, get_fg_tile_info,tilemap_scan_rows,8,8,32,32);
167   mrdo_state *state = (mrdo_state *)machine->driver_data;
171168
172   tilemap_set_transparent_pen(bg_tilemap,0);
173   tilemap_set_transparent_pen(fg_tilemap,0);
169   state->bg_tilemap = tilemap_create(machine, get_bg_tile_info,tilemap_scan_rows,8,8,32,32);
170   state->fg_tilemap = tilemap_create(machine, get_fg_tile_info,tilemap_scan_rows,8,8,32,32);
174171
175   tilemap_set_scrolldx(bg_tilemap, 0, 56);
176   tilemap_set_scrolldx(fg_tilemap, 0, 56);
177   tilemap_set_scrolldy(bg_tilemap, 0, 6);
178   tilemap_set_scrolldy(fg_tilemap, 0, 6);
172   tilemap_set_transparent_pen(state->bg_tilemap,0);
173   tilemap_set_transparent_pen(state->fg_tilemap,0);
179174
180    state_save_register_global(machine, flipscreen);
175   tilemap_set_scrolldx(state->bg_tilemap, 0, 56);
176   tilemap_set_scrolldx(state->fg_tilemap, 0, 56);
177   tilemap_set_scrolldy(state->bg_tilemap, 0, 6);
178   tilemap_set_scrolldy(state->fg_tilemap, 0, 6);
179
180   state->flipscreen = 0;
181
182   state_save_register_global(machine, state->flipscreen);
181183}
182184
183185
r7500r7501
190192
191193WRITE8_HANDLER( mrdo_bgvideoram_w )
192194{
193   mrdo_bgvideoram[offset] = data;
194   tilemap_mark_tile_dirty(bg_tilemap,offset & 0x3ff);
195   mrdo_state *state = (mrdo_state *)space->machine->driver_data;
196   state->bgvideoram[offset] = data;
197   tilemap_mark_tile_dirty(state->bg_tilemap, offset & 0x3ff);
195198}
196199
197200WRITE8_HANDLER( mrdo_fgvideoram_w )
198201{
199   mrdo_fgvideoram[offset] = data;
200   tilemap_mark_tile_dirty(fg_tilemap,offset & 0x3ff);
202   mrdo_state *state = (mrdo_state *)space->machine->driver_data;
203   state->fgvideoram[offset] = data;
204   tilemap_mark_tile_dirty(state->fg_tilemap, offset & 0x3ff);
201205}
202206
203207
204208WRITE8_HANDLER( mrdo_scrollx_w )
205209{
206   tilemap_set_scrollx(bg_tilemap,0,data);
210   mrdo_state *state = (mrdo_state *)space->machine->driver_data;
211   tilemap_set_scrollx(state->bg_tilemap, 0, data);
207212}
208213
209214WRITE8_HANDLER( mrdo_scrolly_w )
210215{
216   mrdo_state *state = (mrdo_state *)space->machine->driver_data;
217
211218   /* This is NOT affected by flipscreen (so stop it happening) */
212
213   if (flipscreen) tilemap_set_scrolly(bg_tilemap,0,((256-data) & 0xff));
214   else tilemap_set_scrolly(bg_tilemap,0,data);
219   if (state->flipscreen)
220      tilemap_set_scrolly(state->bg_tilemap, 0,((256 - data) & 0xff));
221   else
222      tilemap_set_scrolly(state->bg_tilemap, 0, data);
215223}
216224
217225
218226WRITE8_HANDLER( mrdo_flipscreen_w )
219227{
228   mrdo_state *state = (mrdo_state *)space->machine->driver_data;
229
220230   /* bits 1-3 control the playfield priority, but they are not used by */
221231   /* Mr. Do! so we don't emulate them */
222232
223   flipscreen = data & 0x01;
224   tilemap_set_flip_all(space->machine,flipscreen ? (TILEMAP_FLIPY | TILEMAP_FLIPX) : 0);
233   state->flipscreen = data & 0x01;
234   tilemap_set_flip_all(space->machine, state->flipscreen ? (TILEMAP_FLIPY | TILEMAP_FLIPX) : 0);
225235}
226236
227237
r7500r7501
232242
233243***************************************************************************/
234244
235static void draw_sprites(running_machine *machine, bitmap_t *bitmap,const rectangle *cliprect)
245static void draw_sprites( running_machine *machine, bitmap_t *bitmap,const rectangle *cliprect )
236246{
237   UINT8 *spriteram = machine->generic.spriteram.u8;
247   mrdo_state *state = (mrdo_state *)machine->driver_data;
248   UINT8 *spriteram = state->spriteram;
238249   int offs;
239250
240
241   for (offs = machine->generic.spriteram_size - 4;offs >= 0;offs -= 4)
251   for (offs = state->spriteram_size - 4; offs >= 0; offs -= 4)
242252   {
243253      if (spriteram[offs + 1] != 0)
244254      {
245         drawgfx_transpen(bitmap,cliprect,machine->gfx[2],
246               spriteram[offs],spriteram[offs + 2] & 0x0f,
247               spriteram[offs + 2] & 0x10,spriteram[offs + 2] & 0x20,
248               spriteram[offs + 3],256 - spriteram[offs + 1],0);
255         drawgfx_transpen(bitmap, cliprect, machine->gfx[2],
256               spriteram[offs], spriteram[offs + 2] & 0x0f,
257               spriteram[offs + 2] & 0x10, spriteram[offs + 2] & 0x20,
258               spriteram[offs + 3], 256 - spriteram[offs + 1], 0);
249259      }
250260   }
251261}
252262
253263VIDEO_UPDATE( mrdo )
254264{
255   bitmap_fill(bitmap,cliprect,0);
256   tilemap_draw(bitmap,cliprect,bg_tilemap,0,0);
257   tilemap_draw(bitmap,cliprect,fg_tilemap,0,0);
258   draw_sprites(screen->machine,bitmap,cliprect);
265   mrdo_state *state = (mrdo_state *)screen->machine->driver_data;
266
267   bitmap_fill(bitmap, cliprect,0);
268   tilemap_draw(bitmap, cliprect, state->bg_tilemap, 0, 0);
269   tilemap_draw(bitmap, cliprect, state->fg_tilemap, 0, 0);
270   draw_sprites(screen->machine, bitmap, cliprect);
259271   return 0;
260272}
src/mame/video/megazone.c
r7500r7501
88
99#include "emu.h"
1010#include "video/resnet.h"
11#include "includes/megazone.h"
1112
12UINT8 *megazone_scrollx;
13UINT8 *megazone_scrolly;
14static int flipscreen;
15
16UINT8 *megazone_videoram;
17UINT8 *megazone_colorram;
18UINT8 *megazone_videoram2;
19UINT8 *megazone_colorram2;
20size_t megazone_videoram_size;
21size_t megazone_videoram2_size;
22
2313/***************************************************************************
2414Based on driver from MAME 0.55
2515Changes by Martin M. (pfloyd@gmx.net) 14.10.2001:
r7500r7501
4535  bit 0 -- 1  kohm resistor  -- RED
4636
4737***************************************************************************/
38
4839PALETTE_INIT( megazone )
4940{
5041   static const int resistances_rg[3] = { 1000, 470, 220 };
r7500r7501
6859      int r, g, b;
6960
7061      /* red component */
71      bit0 = (color_prom[i] >> 0) & 0x01;
72      bit1 = (color_prom[i] >> 1) & 0x01;
73      bit2 = (color_prom[i] >> 2) & 0x01;
62      bit0 = BIT(color_prom[i], 0);
63      bit1 = BIT(color_prom[i], 1);
64      bit2 = BIT(color_prom[i], 2);
7465      r = combine_3_weights(rweights, bit0, bit1, bit2);
7566
7667      /* green component */
77      bit0 = (color_prom[i] >> 3) & 0x01;
78      bit1 = (color_prom[i] >> 4) & 0x01;
79      bit2 = (color_prom[i] >> 5) & 0x01;
68      bit0 = BIT(color_prom[i], 3);
69      bit1 = BIT(color_prom[i], 4);
70      bit2 = BIT(color_prom[i], 5);
8071      g = combine_3_weights(gweights, bit0, bit1, bit2);
8172
8273      /* blue component */
83      bit0 = (color_prom[i] >> 6) & 0x01;
84      bit1 = (color_prom[i] >> 7) & 0x01;
74      bit0 = BIT(color_prom[i], 6);
75      bit1 = BIT(color_prom[i], 7);
8576      b = combine_2_weights(bweights, bit0, bit1);
8677
8778      colortable_palette_set_color(machine->colortable, i, MAKE_RGB(r, g, b));
r7500r7501
10798
10899WRITE8_HANDLER( megazone_flipscreen_w )
109100{
110   flipscreen = data & 1;
101   megazone_state *state = (megazone_state *)space->machine->driver_data;
102   state->flipscreen = data & 1;
111103}
112104
113105VIDEO_START( megazone )
114106{
115   machine->generic.tmpbitmap = auto_bitmap_alloc(machine,256,256,video_screen_get_format(machine->primary_screen));
107   megazone_state *state = (megazone_state *)machine->driver_data;
108   state->tmpbitmap = auto_bitmap_alloc(machine, 256, 256, video_screen_get_format(machine->primary_screen));
109
110   state_save_register_global_bitmap(machine, state->tmpbitmap);
116111}
117112
118113
119114VIDEO_UPDATE( megazone )
120115{
116   megazone_state *state = (megazone_state *)screen->machine->driver_data;
121117   int offs;
122   int x,y;
118   int x, y;
123119
124120   /* for every character in the Video RAM */
125   for (offs = megazone_videoram_size - 1;offs >= 0;offs--)
121   for (offs = state->videoram_size - 1; offs >= 0; offs--)
126122   {
127      int sx,sy,flipx,flipy;
123      int sx, sy, flipx, flipy;
128124
129125      sx = offs % 32;
130126      sy = offs / 32;
131      flipx = megazone_colorram[offs] & (1<<6);
132      flipy = megazone_colorram[offs] & (1<<5);
133      if (flipscreen)
127      flipx = state->colorram[offs] & (1 << 6);
128      flipy = state->colorram[offs] & (1 << 5);
129
130      if (state->flipscreen)
134131      {
135132         sx = 31 - sx;
136133         sy = 31 - sy;
r7500r7501
138135         flipy = !flipy;
139136      }
140137
141      drawgfx_opaque(screen->machine->generic.tmpbitmap,0,screen->machine->gfx[1],
142            ((int)megazone_videoram[offs]) + ((megazone_colorram[offs] & (1<<7) ? 256 : 0) ),
143            (megazone_colorram[offs] & 0x0f) + 0x10,
138      drawgfx_opaque(state->tmpbitmap, 0, screen->machine->gfx[1],
139            ((int)state->videoram[offs]) + ((state->colorram[offs] & (1 << 7) ? 256 : 0) ),
140            (state->colorram[offs] & 0x0f) + 0x10,
144141            flipx,flipy,
145142            8*sx,8*sy);
146143   }
r7500r7501
150147      int scrollx;
151148      int scrolly;
152149
153      if (flipscreen)
150      if (state->flipscreen)
154151      {
155         scrollx = *megazone_scrolly;
156         scrolly = *megazone_scrollx;
152         scrollx = *state->scrolly;
153         scrolly = *state->scrollx;
157154      }
158155      else
159156      {
160         scrollx = -*megazone_scrolly+4*8; // leave space for credit&score overlay
161         scrolly = -*megazone_scrollx;
157         scrollx = - *state->scrolly + 4 * 8; // leave space for credit&score overlay
158         scrolly = - *state->scrollx;
162159      }
163160
164161
165      copyscrollbitmap(bitmap,screen->machine->generic.tmpbitmap,1,&scrollx,1,&scrolly,cliprect);
162      copyscrollbitmap(bitmap, state->tmpbitmap, 1, &scrollx, 1, &scrolly, cliprect);
166163   }
167164
168165
169166   /* Draw the sprites. */
170167   {
171      UINT8 *spriteram = screen->machine->generic.spriteram.u8;
172      for (offs = screen->machine->generic.spriteram_size-4; offs >= 0;offs -= 4)
168      UINT8 *spriteram = state->spriteram;
169      for (offs = state->spriteram_size - 4; offs >= 0; offs -= 4)
173170      {
174171         int sx = spriteram[offs + 3];
175         int sy = 255-((spriteram[offs + 1]+16)&0xff);
172         int sy = 255 - ((spriteram[offs + 1] + 16) & 0xff);
176173         int color =  spriteram[offs + 0] & 0x0f;
177174         int flipx = ~spriteram[offs + 0] & 0x40;
178175         int flipy =  spriteram[offs + 0] & 0x80;
179176
180         if (flipscreen)
177         if (state->flipscreen)
181178         {
182179            sx = sx - 11;
183180            sy = sy + 2;
r7500r7501
196193
197194   for (y = 0; y < 32;y++)
198195   {
199      offs = y*32;
196      offs = y * 32;
200197      for (x = 0; x < 6; x++)
201198      {
202         int sx,sy,flipx,flipy;
199         int sx, sy, flipx, flipy;
203200
204201         sx = x;
205202         sy = y;
206203
207         flipx = megazone_colorram2[offs] & (1<<6);
208         flipy = megazone_colorram2[offs] & (1<<5);
204         flipx = state->colorram2[offs] & (1 << 6);
205         flipy = state->colorram2[offs] & (1 << 5);
209206
210         if (flipscreen)
207         if (state->flipscreen)
211208         {
212209            sx = 35 - sx;
213210            sy = 31 - sy;
r7500r7501
218215
219216
220217
221         drawgfx_opaque(bitmap,cliprect,screen->machine->gfx[1],
222               ((int)megazone_videoram2[offs]) + ((megazone_colorram2[offs] & (1<<7) ? 256 : 0) ),
223               (megazone_colorram2[offs] & 0x0f) + 0x10,
218         drawgfx_opaque(bitmap, cliprect, screen->machine->gfx[1],
219               ((int)state->videoram2[offs]) + ((state->colorram2[offs] & (1 << 7) ? 256 : 0) ),
220               (state->colorram2[offs] & 0x0f) + 0x10,
224221               flipx,flipy,
225222               8*sx,8*sy);
226223         offs++;
src/mame/video/mrjong.c
r7500r7501
77***************************************************************************/
88
99#include "emu.h"
10#include "includes/mrjong.h"
1011
11UINT8 *mrjong_videoram;
12UINT8 *mrjong_colorram;
13static tilemap_t *bg_tilemap;
1412
1513/***************************************************************************
1614
1715  Convert the color PROMs. (from video/pengo.c)
1816
1917***************************************************************************/
18
2019PALETTE_INIT( mrjong )
2120{
2221   int i;
r7500r7501
3130      int r, g, b;
3231
3332      /* red component */
34      bit0 = (color_prom[i] >> 0) & 0x01;
35      bit1 = (color_prom[i] >> 1) & 0x01;
36      bit2 = (color_prom[i] >> 2) & 0x01;
33      bit0 = BIT(color_prom[i], 0);
34      bit1 = BIT(color_prom[i], 1);
35      bit2 = BIT(color_prom[i], 2);
3736      r = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2;
3837
3938      /* green component */
40      bit0 = (color_prom[i] >> 3) & 0x01;
41      bit1 = (color_prom[i] >> 4) & 0x01;
42      bit2 = (color_prom[i] >> 5) & 0x01;
39      bit0 = BIT(color_prom[i], 3);
40      bit1 = BIT(color_prom[i], 4);
41      bit2 = BIT(color_prom[i], 5);
4342      g = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2;
4443
4544      /* blue component */
4645      bit0 = 0;
47      bit1 = (color_prom[i] >> 6) & 0x01;
48      bit2 = (color_prom[i] >> 7) & 0x01;
46      bit1 = BIT(color_prom[i], 6);
47      bit2 = BIT(color_prom[i], 7);
4948      b = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2;
5049
5150      colortable_palette_set_color(machine->colortable, i, MAKE_RGB(r, g, b));
r7500r7501
6867  Display control parameter.
6968
7069***************************************************************************/
70
7171WRITE8_HANDLER( mrjong_videoram_w )
7272{
73   mrjong_videoram[offset] = data;
74   tilemap_mark_tile_dirty(bg_tilemap, offset);
73   mrjong_state *state = (mrjong_state *)space->machine->driver_data;
74   state->videoram[offset] = data;
75   tilemap_mark_tile_dirty(state->bg_tilemap, offset);
7576}
7677
7778WRITE8_HANDLER( mrjong_colorram_w )
7879{
79   mrjong_colorram[offset] = data;
80   tilemap_mark_tile_dirty(bg_tilemap, offset);
80   mrjong_state *state = (mrjong_state *)space->machine->driver_data;
81   state->colorram[offset] = data;
82   tilemap_mark_tile_dirty(state->bg_tilemap, offset);
8183}
8284
8385WRITE8_HANDLER( mrjong_flipscreen_w )
8486{
85   if (flip_screen_get(space->machine) != (data & 0x01))
87   if (flip_screen_get(space->machine) != BIT(data, 2))
8688   {
87      flip_screen_set(space->machine, data & 0x01);
89      flip_screen_set(space->machine, BIT(data, 2));
8890      tilemap_mark_all_tiles_dirty_all(space->machine);
8991   }
9092}
9193
9294static TILE_GET_INFO( get_bg_tile_info )
9395{
94   int code = mrjong_videoram[tile_index] | ((mrjong_colorram[tile_index] & 0x20) << 3);
95   int color = mrjong_colorram[tile_index] & 0x1f;
96   int flags = ((mrjong_colorram[tile_index] & 0x40) ? TILE_FLIPX : 0) | ((mrjong_colorram[tile_index] & 0x80) ? TILE_FLIPY : 0);
96   mrjong_state *state = (mrjong_state *)machine->driver_data;
97   int code = state->videoram[tile_index] | ((state->colorram[tile_index] & 0x20) << 3);
98   int color = state->colorram[tile_index] & 0x1f;
99   int flags = ((state->colorram[tile_index] & 0x40) ? TILE_FLIPX : 0) | ((state->colorram[tile_index] & 0x80) ? TILE_FLIPY : 0);
97100
98101   SET_TILE_INFO(0, code, color, flags);
99102}
100103
101104VIDEO_START( mrjong )
102105{
103   bg_tilemap = tilemap_create(machine, get_bg_tile_info, tilemap_scan_rows_flip_xy, 8, 8, 32, 32);
106   mrjong_state *state = (mrjong_state *)machine->driver_data;
107   state->bg_tilemap = tilemap_create(machine, get_bg_tile_info, tilemap_scan_rows_flip_xy, 8, 8, 32, 32);
104108}
105109
106110/*
107111Note: First 0x40 entries in the videoram are actually spriteram
108112*/
109static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect)
113static void draw_sprites( running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect )
110114{
115   mrjong_state *state = (mrjong_state *)machine->driver_data;
111116   int offs;
112117
113118   for (offs = (0x40 - 4); offs >= 0; offs -= 4)
r7500r7501
117122      int sx, sy;
118123      int flipx, flipy;
119124
120      sprt = (((mrjong_videoram[offs + 1] >> 2) & 0x3f) | ((mrjong_videoram[offs + 3] & 0x20) << 1));
121      flipx = (mrjong_videoram[offs + 1] & 0x01) >> 0;
122      flipy = (mrjong_videoram[offs + 1] & 0x02) >> 1;
123      color = (mrjong_videoram[offs + 3] & 0x1f);
125      sprt = (((state->videoram[offs + 1] >> 2) & 0x3f) | ((state->videoram[offs + 3] & 0x20) << 1));
126      flipx = (state->videoram[offs + 1] & 0x01) >> 0;
127      flipy = (state->videoram[offs + 1] & 0x02) >> 1;
128      color = (state->videoram[offs + 3] & 0x1f);
124129
125      sx = 224 - mrjong_videoram[offs + 2];
126      sy = mrjong_videoram[offs + 0];
130      sx = 224 - state->videoram[offs + 2];
131      sy = state->videoram[offs + 0];
127132      if (flip_screen_get(machine))
128133      {
129134         sx = 208 - sx;
r7500r7501
142147
143148VIDEO_UPDATE( mrjong )
144149{
145   tilemap_draw(bitmap, cliprect, bg_tilemap, 0, 0);
150   mrjong_state *state = (mrjong_state *)screen->machine->driver_data;
151   tilemap_draw(bitmap, cliprect, state->bg_tilemap, 0, 0);
146152   draw_sprites(screen->machine, bitmap, cliprect);
147153   return 0;
148154}
src/mame/video/cninja.c
r7500r7501
55****************************************************************************/
66
77#include "emu.h"
8#include "includes/deco16ic.h"
8#include "video/deco16ic.h"
99#include "includes/cninja.h"
1010
1111/******************************************************************************/
1212
13static int cninja_bank_callback(const int bank)
14{
15   if ((bank>>4)&0xf) return 0x0000; /* Only 2 banks */
16   return 0x1000;
17}
18
19static int edrandy_bank_callback(const int bank)
20{
21   if ((bank>>4)&0xf) return 0x0000; /* Only 2 banks */
22   return 0x1000;
23}
24
25static int robocop2_bank_callback(const int bank)
26{
27   return (bank&0x30)<<8;
28}
29
30static int mutantf_1_bank_callback(const int bank)
31{
32   return ((bank>>4)&0x3)<<12;
33}
34
35static int mutantf_2_bank_callback(const int bank)
36{
37   return ((bank>>5)&0x1)<<14;
38}
39
40/******************************************************************************/
41
42VIDEO_START( cninja )
43{
44   deco16_2_video_init(machine, 1);
45
46   deco16_set_tilemap_bank_callback(2,cninja_bank_callback);
47   deco16_set_tilemap_bank_callback(3,cninja_bank_callback);
48   deco16_set_tilemap_colour_base(3,48);
49}
50
5113VIDEO_START( stoneage )
5214{
53   deco16_2_video_init(machine, 1);
15   cninja_state *state = (cninja_state *)machine->driver_data;
5416
55   deco16_set_tilemap_bank_callback(2,edrandy_bank_callback);
56   deco16_set_tilemap_bank_callback(3,edrandy_bank_callback);
57   deco16_set_tilemap_colour_base(3,48);
58
5917   /* The bootleg has broken scroll registers */
60   tilemap_set_scrolldx(deco16_get_tilemap(3,0),-10,-10);
61   tilemap_set_scrolldx(deco16_get_tilemap(1,0),-10,-10);
62   tilemap_set_scrolldx(deco16_get_tilemap(0,1),2,2);
18   deco16ic_set_scrolldx(state->deco16ic, 3, 0, -10, -10);   /* pf4 16x16 tilemap */
19   deco16ic_set_scrolldx(state->deco16ic, 1, 0, -10, -10);   /* pf2 16x16 tilemap */
20   deco16ic_set_scrolldx(state->deco16ic, 0, 1, 2, 2);   /* pf1 8x8 tilemap */
6321}
6422
65VIDEO_START( edrandy )
66{
67   deco16_2_video_init(machine, 0);
68
69   deco16_set_tilemap_bank_callback(2,edrandy_bank_callback);
70   deco16_set_tilemap_bank_callback(3,edrandy_bank_callback);
71   deco16_set_tilemap_colour_base(3,48);
72}
73
74VIDEO_START( robocop2 )
75{
76   deco16_2_video_init(machine, 0);
77
78   deco16_set_tilemap_bank_callback(1,robocop2_bank_callback);
79   deco16_set_tilemap_bank_callback(2,robocop2_bank_callback);
80   deco16_set_tilemap_bank_callback(3,robocop2_bank_callback);
81   deco16_set_tilemap_colour_base(3,48);
82}
83
84VIDEO_START( mutantf )
85{
86   deco16_2_video_init(machine, 0);
87
88   deco16_set_tilemap_bank_callback(0,mutantf_1_bank_callback);
89   deco16_set_tilemap_bank_callback(1,mutantf_2_bank_callback);
90   deco16_set_tilemap_bank_callback(2,mutantf_1_bank_callback);
91   deco16_set_tilemap_bank_callback(3,mutantf_1_bank_callback);
92
93   deco16_set_tilemap_colour_base(1,0x30);
94   deco16_set_tilemap_colour_base(2,0x20);
95   deco16_set_tilemap_colour_base(3,0x40);
96}
97
9823/******************************************************************************/
9924
100/******************************************************************************/
101
102static void cninja_draw_sprites(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect)
25static void cninja_draw_sprites( running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect )
10326{
104   UINT16 *buffered_spriteram16 = machine->generic.buffered_spriteram.u16;
27   UINT16 *buffered_spriteram = machine->generic.buffered_spriteram.u16;
10528   int offs;
10629
107   for (offs = 0x400-4;offs >=0 ;offs -= 4)
30   for (offs = 0x400 - 4; offs >=0 ; offs -= 4)
10831   {
109      int x,y,sprite,colour,multi,fx,fy,inc,flash,mult,pri=0;
32      int x, y, sprite, colour, multi, fx, fy, inc, flash, mult, pri = 0;
11033
111      sprite = buffered_spriteram16[offs+1];
112      if (!sprite) continue;
34      sprite = buffered_spriteram[offs + 1];
35      if (!sprite)
36         continue;
11337
114      x = buffered_spriteram16[offs+2];
38      x = buffered_spriteram[offs + 2];
11539
11640      /* Sprite/playfield priority */
117      switch (x&0xc000) {
118      case 0x0000: pri=0; break;
119      case 0x4000: pri=0xf0; break;
120      case 0x8000: pri=0xf0|0xcc; break;
121      case 0xc000: pri=0xf0|0xcc; break; /* Perhaps 0xf0|0xcc|0xaa (Sprite under bottom layer) */
41      switch (x & 0xc000)
42      {
43      case 0x0000: pri = 0; break;
44      case 0x4000: pri = 0xf0; break;
45      case 0x8000: pri = 0xf0 | 0xcc; break;
46      case 0xc000: pri = 0xf0 | 0xcc; break; /* Perhaps 0xf0|0xcc|0xaa (Sprite under bottom layer) */
12247      }
12348
124      y = buffered_spriteram16[offs];
125      flash=y&0x1000;
126      if (flash && (video_screen_get_frame_number(machine->primary_screen) & 1)) continue;
127      colour = (x >> 9) &0x1f;
49      y = buffered_spriteram[offs];
50      flash = y & 0x1000;
51      if (flash && (video_screen_get_frame_number(machine->primary_screen) & 1))
52         continue;
12853
54      colour = (x >> 9) & 0x1f;
55
12956      fx = y & 0x2000;
13057      fy = y & 0x4000;
13158      multi = (1 << ((y & 0x0600) >> 9)) - 1;   /* 1x, 2x, 4x, 8x height */
r7500r7501
14673         inc = 1;
14774      }
14875
149      if (flip_screen_get(machine)) {
150         y=240-y;
151         x=240-x;
152         if (fx) fx=0; else fx=1;
153         if (fy) fy=0; else fy=1;
154         mult=16;
76      if (flip_screen_get(machine))
77      {
78         y = 240 - y;
79         x = 240 - x;
80         if (fx) fx = 0; else fx = 1;
81         if (fy) fy = 0; else fy = 1;
82         mult = 16;
15583      }
156      else mult=-16;
84      else
85         mult = -16;
15786
15887      while (multi >= 0)
15988      {
r7500r7501
17099}
171100
172101/* The bootleg sprites are in a different format! */
173static void cninjabl_draw_sprites(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect)
102static void cninjabl_draw_sprites( running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect )
174103{
175   UINT16 *buffered_spriteram16 = machine->generic.buffered_spriteram.u16;
104   UINT16 *buffered_spriteram = machine->generic.buffered_spriteram.u16;
176105   int offs;
177106   int endoffs;
178107
179108   // bootleg seems to use 0x180 as an end of list marker
180109   // find it first, so we can use normal list processing
181   endoffs = 0x400-4;
182   for (offs = 0;offs <0x400-4 ;offs += 4)
110   endoffs = 0x400 - 4;
111   for (offs = 0; offs < 0x400 - 4 ; offs += 4)
183112   {
184      int y;
113      int y = buffered_spriteram[offs + 1];
185114
186      y = buffered_spriteram16[offs+1];
187
188      if (y==0x180)
115      if (y == 0x180)
189116      {
190117         endoffs = offs;
191         offs = 0x400-4;
118         offs = 0x400 - 4;
192119      }
193120   }
194121
195   for (offs = endoffs;offs >=0 ;offs -= 4)
122   for (offs = endoffs; offs >=0 ; offs -= 4)
196123   {
197      int x,y,sprite,colour,multi,fx,fy,inc,flash,mult,pri=0;
124      int x, y, sprite, colour, multi, fx, fy, inc, flash, mult, pri = 0;
198125
199      sprite = buffered_spriteram16[offs+0]; // changed on bootleg!
200      y = buffered_spriteram16[offs+1]; // changed on bootleg!
126      sprite = buffered_spriteram[offs + 0]; // changed on bootleg!
127      y = buffered_spriteram[offs + 1]; // changed on bootleg!
201128
202      if (!sprite) continue;
129      if (!sprite)
130         continue;
203131
204      x = buffered_spriteram16[offs+2];
132      x = buffered_spriteram[offs + 2];
205133
206134      /* Sprite/playfield priority */
207      switch (x&0xc000) {
208      case 0x0000: pri=0; break;
209      case 0x4000: pri=0xf0; break;
210      case 0x8000: pri=0xf0|0xcc; break;
211      case 0xc000: pri=0xf0|0xcc; break; /* Perhaps 0xf0|0xcc|0xaa (Sprite under bottom layer) */
135      switch (x & 0xc000)
136      {
137      case 0x0000: pri = 0; break;
138      case 0x4000: pri = 0xf0; break;
139      case 0x8000: pri = 0xf0 | 0xcc; break;
140      case 0xc000: pri = 0xf0 | 0xcc; break; /* Perhaps 0xf0|0xcc|0xaa (Sprite under bottom layer) */
212141      }
213142
143      flash = y & 0x1000;
144      if (flash && (video_screen_get_frame_number(machine->primary_screen) & 1))
145         continue;
214146
147      colour = (x >> 9) & 0x1f;
215148
216      flash=y&0x1000;
217      if (flash && (video_screen_get_frame_number(machine->primary_screen) & 1)) continue;
218
219      colour = (x >> 9) &0x1f;
220
221
222149      fx = y & 0x2000;
223150      fy = y & 0x4000;
224151
225152      multi = (1 << ((y & 0x0600) >> 9)) - 1;   /* 1x, 2x, 4x, 8x height */
226153
227      y -= multi*16; // changed on bootleg!
154      y -= multi * 16; // changed on bootleg!
228155      y += 4;
229156
230157      x = x & 0x01ff;
r7500r7501
243170         inc = 1;
244171      }
245172
246      if (flip_screen_get(machine)) {
247         y=240-y;
248         x=240-x;
249         if (fx) fx=0; else fx=1;
250         if (fy) fy=0; else fy=1;
251         mult=16;
173      if (flip_screen_get(machine))
174      {
175         y = 240 - y;
176         x = 240 - x;
177         if (fx) fx = 0; else fx = 1;
178         if (fy) fy = 0; else fy = 1;
179         mult = 16;
252180      }
253      else mult=-16;
181      else
182         mult = -16;
254183
255184      while (multi >= 0)
256185      {
r7500r7501
267196}
268197
269198
270static void robocop2_draw_sprites(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect)
199static void robocop2_draw_sprites( running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect )
271200{
272   UINT16 *buffered_spriteram16 = machine->generic.buffered_spriteram.u16;
201   UINT16 *buffered_spriteram = machine->generic.buffered_spriteram.u16;
273202   int offs;
274203
275   for (offs = 0x400-4;offs >=0 ;offs -= 4)
204   for (offs = 0x400 - 4; offs >=0 ; offs -= 4)
276205   {
277      int x,y,sprite,colour,multi,fx,fy,inc,flash,mult,pri=0;
278      sprite = buffered_spriteram16[offs+1];
279      if (!sprite) continue;
206      int x, y, sprite, colour, multi, fx, fy, inc, flash, mult, pri = 0;
207      sprite = buffered_spriteram[offs + 1];
208      if (!sprite)
209         continue;
280210
281      x = buffered_spriteram16[offs+2];
211      x = buffered_spriteram[offs + 2];
282212
283213      /* Sprite/playfield priority */
284      switch (x&0xc000) {
285      case 0x0000: pri=0; break;
286      case 0x4000: pri=0xf0; break;
287      case 0x8000: pri=0xf0|0xcc; break;
288      case 0xc000: pri=0xf0|0xcc; break; /* Perhaps 0xf0|0xcc|0xaa (Sprite under bottom layer) */
214      switch (x & 0xc000)
215      {
216      case 0x0000: pri = 0; break;
217      case 0x4000: pri = 0xf0; break;
218      case 0x8000: pri = 0xf0 | 0xcc; break;
219      case 0xc000: pri = 0xf0 | 0xcc; break; /* Perhaps 0xf0|0xcc|0xaa (Sprite under bottom layer) */
289220      }
290221
291      y = buffered_spriteram16[offs];
292      flash=y&0x1000;
293      if (flash && (video_screen_get_frame_number(machine->primary_screen) & 1)) continue;
294      colour = (x >> 9) &0x1f;
222      y = buffered_spriteram[offs];
223      flash = y & 0x1000;
224      if (flash && (video_screen_get_frame_number(machine->primary_screen) & 1))
225         continue;
226      colour = (x >> 9) & 0x1f;
295227
296228      fx = y & 0x2000;
297229      fy = y & 0x4000;
r7500r7501
313245         inc = 1;
314246      }
315247
316      if (flip_screen_get(machine)) {
317         y=240-y;
318         x=304-x;
319         if (fx) fx=0; else fx=1;
320         if (fy) fy=0; else fy=1;
321         mult=16;
248      if (flip_screen_get(machine))
249      {
250         y = 240 - y;
251         x = 304 - x;
252         if (fx) fx = 0; else fx = 1;
253         if (fy) fy = 0; else fy = 1;
254         mult = 16;
322255      }
323      else mult=-16;
256      else
257         mult = -16;
324258
325259      while (multi >= 0)
326260      {
r7500r7501
336270   }
337271}
338272
339static void mutantf_draw_sprites(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, const UINT16 *spriteptr, int gfxbank)
273static void mutantf_draw_sprites( running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, const UINT16 *spriteptr, int gfxbank )
340274{
341   int offs,end,inc;
275   int offs, end, inc;
342276
343277   /*
344278        Alternate format from most 16 bit games - same as Captain America
r7500r7501
361295
362296   /* This may look strange, but the alpha-blended sprite chip definitely draws end to
363297        front, ie, reversed from normal pdrawgfx style. */
364   if (gfxbank==4) {
365      offs=0;
366      end=0x400;
367      inc=4;
368   } else {
369      offs=0x3fc;
370      end=-4;
371      inc=-4;
298   if (gfxbank == 4)
299   {
300      offs = 0;
301      end = 0x400;
302      inc = 4;
372303   }
304   else
305   {
306      offs = 0x3fc;
307      end = -4;
308      inc = -4;
309   }
373310
374   while (offs!=end)
311   while (offs != end)
375312   {
376      int x,y,sprite,colour,fx,fy,w,h,sx,sy,x_mult,y_mult;
377      int alpha=0xff;
313      int x, y, sprite, colour, fx, fy, w, h, sx, sy, x_mult, y_mult;
314      int alpha = 0xff;
378315
379      sprite = spriteptr[offs+3];
380      if (!sprite) {
381         offs+=inc;
316      sprite = spriteptr[offs + 3];
317      if (!sprite)
318      {
319         offs += inc;
382320         continue;
383321      }
384322
385      sx = spriteptr[offs+1];
323      sx = spriteptr[offs + 1];
386324
387      h = (spriteptr[offs+2]&0xf000)>>12;
388      w = (spriteptr[offs+2]&0x0f00)>> 8;
325      h = (spriteptr[offs + 2] & 0xf000) >> 12;
326      w = (spriteptr[offs + 2] & 0x0f00) >>  8;
389327
390328      sy = spriteptr[offs];
391      if ((sy&0x2000) && (video_screen_get_frame_number(machine->primary_screen) & 1)) {
392         offs+=inc;
329      if ((sy & 0x2000) && (video_screen_get_frame_number(machine->primary_screen) & 1))
330      {
331         offs += inc;
393332         continue;
394333      }
395334
396      colour = (spriteptr[offs+2] >>0) & 0x1f;
335      colour = (spriteptr[offs + 2] >> 0) & 0x1f;
397336
398      if (gfxbank==4) { /* Seems to be always alpha'd */
399         alpha=0x80;
400         colour&=0xf;
337      if (gfxbank == 4)
338      { /* Seems to be always alpha'd */
339         alpha = 0x80;
340         colour &= 0xf;
401341      }
402342
403      fx = (spriteptr[offs+0]&0x4000);
404      fy = (spriteptr[offs+0]&0x8000);
343      fx = (spriteptr[offs + 0] & 0x4000);
344      fy = (spriteptr[offs + 0] & 0x8000);
405345
406      if (flip_screen_get(machine)) {
407         if (fx) fx=0; else fx=1;
408         if (fy) fy=0; else fy=1;
346      if (flip_screen_get(machine))
347      {
348         if (fx) fx = 0; else fx = 1;
349         if (fy) fy = 0; else fy = 1;
409350
410351         sx = sx & 0x01ff;
411352         sy = sy & 0x01ff;
412         if (sx>0x180) sx=-(0x200 - sx);
413         if (sy>0x180) sy=-(0x200 - sy);
353         if (sx > 0x180) sx = -(0x200 - sx);
354         if (sy > 0x180) sy = -(0x200 - sy);
414355
415         if (fx) { x_mult=-16; sx+=16*w; } else { x_mult=16; sx-=16; }
416         if (fy) { y_mult=-16; sy+=16*h; } else { y_mult=16; sy-=16; }
417      } else {
356         if (fx) { x_mult = -16; sx += 16 * w; } else { x_mult = 16; sx -= 16; }
357         if (fy) { y_mult = -16; sy += 16 * h; } else { y_mult = 16; sy -= 16; }
358      }
359      else
360      {
418361         sx = sx & 0x01ff;
419362         sy = sy & 0x01ff;
420         if (sx&0x100) sx=-(0x100 - (sx&0xff));
421         if (sy&0x100) sy=-(0x100 - (sy&0xff));
363         if (sx & 0x100) sx = -(0x100 - (sx & 0xff));
364         if (sy & 0x100) sy = -(0x100 - (sy & 0xff));
422365         sx = 304 - sx;
423366         sy = 240 - sy;
424367         if (sx >= 432) sx -= 512;
425368         if (sy >= 384) sy -= 512;
426         if (fx) { x_mult=-16; sx+=16; } else { x_mult=16; sx-=16*w; }
427         if (fy) { y_mult=-16; sy+=16; } else { y_mult=16; sy-=16*h; }
369         if (fx) { x_mult = -16; sx += 16; } else { x_mult = 16; sx -= 16*w; }
370         if (fy) { y_mult = -16; sy += 16; } else { y_mult = 16; sy -= 16*h; }
428371      }
429372
430      for (x=0; x<w; x++) {
431         for (y=0; y<h; y++) {
373      for (x = 0; x < w; x++)
374      {
375         for (y = 0; y < h; y++)
376         {
432377            pdrawgfx_alpha(bitmap,cliprect,machine->gfx[gfxbank],
433378                  sprite + y + h * x,
434379                  colour,
r7500r7501
438383                  0,alpha);
439384         }
440385      }
441
442      offs+=inc;
386      offs += inc;
443387   }
444388}
445389
r7500r7501
447391
448392VIDEO_UPDATE( cninja )
449393{
450   flip_screen_set(screen->machine,  deco16_pf12_control[0]&0x80 );
451   deco16_pf12_update(deco16_pf1_rowscroll,deco16_pf2_rowscroll);
452   deco16_pf34_update(deco16_pf3_rowscroll,deco16_pf4_rowscroll);
394   cninja_state *state = (cninja_state *)screen->machine->driver_data;
395   UINT16 flip = deco16ic_pf12_control_r(state->deco16ic, 0, 0xffff);
453396
397   flip_screen_set(screen->machine, BIT(flip, 7));
398   deco16ic_pf12_update(state->deco16ic, state->pf1_rowscroll, state->pf2_rowscroll);
399   deco16ic_pf34_update(state->deco16ic, state->pf3_rowscroll, state->pf4_rowscroll);
400
454401   /* Draw playfields */
455   bitmap_fill(screen->machine->priority_bitmap,cliprect,0);
456   bitmap_fill(bitmap,cliprect,512);
457   deco16_tilemap_4_draw(screen,bitmap,cliprect,TILEMAP_DRAW_OPAQUE,1);
458   deco16_tilemap_3_draw(screen,bitmap,cliprect,0,2);
459   deco16_tilemap_2_draw(screen,bitmap,cliprect,TILEMAP_DRAW_LAYER1,2);
460   deco16_tilemap_2_draw(screen,bitmap,cliprect,TILEMAP_DRAW_LAYER0,4);
461   cninja_draw_sprites(screen->machine,bitmap,cliprect);
462   deco16_tilemap_1_draw(screen,bitmap,cliprect,0,0);
402   bitmap_fill(screen->machine->priority_bitmap, cliprect, 0);
403   bitmap_fill(bitmap, cliprect, 512);
404   deco16ic_tilemap_4_draw(state->deco16ic, bitmap, cliprect, TILEMAP_DRAW_OPAQUE, 1);
405   deco16ic_tilemap_3_draw(state->deco16ic, bitmap, cliprect, 0, 2);
406   deco16ic_tilemap_2_draw(state->deco16ic, bitmap, cliprect, TILEMAP_DRAW_LAYER1, 2);
407   deco16ic_tilemap_2_draw(state->deco16ic, bitmap, cliprect, TILEMAP_DRAW_LAYER0, 4);
408   cninja_draw_sprites(screen->machine, bitmap, cliprect);
409   deco16ic_tilemap_1_draw(state->deco16ic, bitmap, cliprect, 0, 0);
463410   return 0;
464411}
465412
466413VIDEO_UPDATE( cninjabl )
467414{
468   flip_screen_set(screen->machine,  deco16_pf12_control[0]&0x80 );
469   deco16_pf12_update(deco16_pf1_rowscroll,deco16_pf2_rowscroll);
470   deco16_pf34_update(deco16_pf3_rowscroll,deco16_pf4_rowscroll);
415   cninja_state *state = (cninja_state *)screen->machine->driver_data;
416   UINT16 flip = deco16ic_pf12_control_r(state->deco16ic, 0, 0xffff);
471417
418   flip_screen_set(screen->machine, BIT(flip, 7));
419   deco16ic_pf12_update(state->deco16ic, state->pf1_rowscroll, state->pf2_rowscroll);
420   deco16ic_pf34_update(state->deco16ic, state->pf3_rowscroll, state->pf4_rowscroll);
421
472422   /* Draw playfields */
473   bitmap_fill(screen->machine->priority_bitmap,cliprect,0);
474   bitmap_fill(bitmap,cliprect,512);
475   deco16_tilemap_4_draw(screen,bitmap,cliprect,TILEMAP_DRAW_OPAQUE,1);
476   deco16_tilemap_3_draw(screen,bitmap,cliprect,0,2);
477   deco16_tilemap_2_draw(screen,bitmap,cliprect,TILEMAP_DRAW_LAYER1,2);
478   deco16_tilemap_2_draw(screen,bitmap,cliprect,TILEMAP_DRAW_LAYER0,4);
479   cninjabl_draw_sprites(screen->machine,bitmap,cliprect);
480   deco16_tilemap_1_draw(screen,bitmap,cliprect,0,0);
423   bitmap_fill(screen->machine->priority_bitmap, cliprect, 0);
424   bitmap_fill(bitmap, cliprect, 512);
425   deco16ic_tilemap_4_draw(state->deco16ic, bitmap, cliprect, TILEMAP_DRAW_OPAQUE, 1);
426   deco16ic_tilemap_3_draw(state->deco16ic, bitmap, cliprect, 0, 2);
427   deco16ic_tilemap_2_draw(state->deco16ic, bitmap, cliprect, TILEMAP_DRAW_LAYER1, 2);
428   deco16ic_tilemap_2_draw(state->deco16ic, bitmap, cliprect, TILEMAP_DRAW_LAYER0, 4);
429   cninjabl_draw_sprites(screen->machine, bitmap, cliprect);
430   deco16ic_tilemap_1_draw(state->deco16ic, bitmap, cliprect, 0, 0);
481431   return 0;
482432}
483433
484434VIDEO_UPDATE( edrandy )
485435{
486   flip_screen_set(screen->machine,  deco16_pf12_control[0]&0x80 );
487   deco16_pf12_update(deco16_pf1_rowscroll,deco16_pf2_rowscroll);
488   deco16_pf34_update(deco16_pf3_rowscroll,deco16_pf4_rowscroll);
436   cninja_state *state = (cninja_state *)screen->machine->driver_data;
437   UINT16 flip = deco16ic_pf12_control_r(state->deco16ic, 0, 0xffff);
489438
490   bitmap_fill(screen->machine->priority_bitmap,cliprect,0);
491   bitmap_fill(bitmap,cliprect,0);
492   deco16_tilemap_4_draw(screen,bitmap,cliprect,TILEMAP_DRAW_OPAQUE,1);
493   deco16_tilemap_3_draw(screen,bitmap,cliprect,0,2);
494   deco16_tilemap_2_draw(screen,bitmap,cliprect,0,4);
495   cninja_draw_sprites(screen->machine,bitmap,cliprect);
496   deco16_tilemap_1_draw(screen,bitmap,cliprect,0,0);
439   flip_screen_set(screen->machine, BIT(flip, 7));
440   deco16ic_pf12_update(state->deco16ic, state->pf1_rowscroll, state->pf2_rowscroll);
441   deco16ic_pf34_update(state->deco16ic, state->pf3_rowscroll, state->pf4_rowscroll);
442
443   bitmap_fill(screen->machine->priority_bitmap, cliprect, 0);
444   bitmap_fill(bitmap, cliprect, 0);
445   deco16ic_tilemap_4_draw(state->deco16ic, bitmap, cliprect, TILEMAP_DRAW_OPAQUE, 1);
446   deco16ic_tilemap_3_draw(state->deco16ic, bitmap, cliprect, 0, 2);
447   deco16ic_tilemap_2_draw(state->deco16ic, bitmap, cliprect, 0, 4);
448   cninja_draw_sprites(screen->machine, bitmap, cliprect);
449   deco16ic_tilemap_1_draw(state->deco16ic, bitmap, cliprect, 0, 0);
497450   return 0;
498451}
499452
500453VIDEO_UPDATE( robocop2 )
501454{
455   cninja_state *state = (cninja_state *)screen->machine->driver_data;
456   UINT16 flip = deco16ic_pf12_control_r(state->deco16ic, 0, 0xffff);
457   UINT16 priority = deco16ic_priority_r(state->deco16ic, 0, 0xffff);
458
502459   /* One of the tilemap chips can switch between 2 tilemaps at 4bpp, or 1 at 8bpp */
503   if (deco16_priority&4) {
504      deco16_set_tilemap_colour_mask(2,0);
505      deco16_set_tilemap_colour_mask(3,0);
506      deco16_pf34_set_gfxbank(0,4);
507   } else {
508      deco16_set_tilemap_colour_mask(2,0xf);
509      deco16_set_tilemap_colour_mask(3,0xf);
510      deco16_pf34_set_gfxbank(0,2);
460   if (priority & 4)
461   {
462      deco16ic_set_tilemap_colour_mask(state->deco16ic, 2, 0);
463      deco16ic_set_tilemap_colour_mask(state->deco16ic, 3, 0);
464      deco16ic_pf34_set_gfxbank(state->deco16ic, 0, 4);
511465   }
466   else
467   {
468      deco16ic_set_tilemap_colour_mask(state->deco16ic, 2, 0xf);
469      deco16ic_set_tilemap_colour_mask(state->deco16ic, 3, 0xf);
470      deco16ic_pf34_set_gfxbank(state->deco16ic, 0, 2);
471   }
512472
513473   /* Update playfields */
514   flip_screen_set(screen->machine,  deco16_pf12_control[0]&0x80 );
515   deco16_pf12_update(deco16_pf1_rowscroll,deco16_pf2_rowscroll);
516   deco16_pf34_update(deco16_pf3_rowscroll,deco16_pf4_rowscroll);
474   flip_screen_set(screen->machine, BIT(flip, 7));
475   deco16ic_pf12_update(state->deco16ic, state->pf1_rowscroll, state->pf2_rowscroll);
476   deco16ic_pf34_update(state->deco16ic, state->pf3_rowscroll, state->pf4_rowscroll);
517477
518478   /* Draw playfields */
519   bitmap_fill(screen->machine->priority_bitmap,cliprect,0);
520   bitmap_fill(bitmap,cliprect,0x200);
521   if ((deco16_priority&4)==0)
522      deco16_tilemap_4_draw(screen,bitmap,cliprect,TILEMAP_DRAW_OPAQUE,1);
479   bitmap_fill(screen->machine->priority_bitmap, cliprect, 0);
480   bitmap_fill(bitmap, cliprect, 0x200);
523481
482   if ((priority & 4) == 0)
483      deco16ic_tilemap_4_draw(state->deco16ic, bitmap, cliprect, TILEMAP_DRAW_OPAQUE, 1);
484
524485   /* Switchable priority */
525   switch (deco16_priority&0x8) {
486   switch (priority & 0x8)
487   {
526488      case 8:
527         deco16_tilemap_2_draw(screen,bitmap,cliprect,0,2);
528         deco16_tilemap_3_draw(screen,bitmap,cliprect,0,4);
489         deco16ic_tilemap_2_draw(state->deco16ic, bitmap, cliprect, 0, 2);
490         deco16ic_tilemap_3_draw(state->deco16ic, bitmap, cliprect, 0, 4);
529491         break;
530492      default:
531493      case 0:
532         deco16_tilemap_3_draw(screen,bitmap,cliprect,0,2);
533         deco16_tilemap_2_draw(screen,bitmap,cliprect,0,4);
494         deco16ic_tilemap_3_draw(state->deco16ic, bitmap, cliprect, 0, 2);
495         deco16ic_tilemap_2_draw(state->deco16ic, bitmap, cliprect, 0, 4);
534496         break;
535497   }
536498
537   robocop2_draw_sprites(screen->machine,bitmap,cliprect);
538   deco16_tilemap_1_draw(screen,bitmap,cliprect,0,0);
499   robocop2_draw_sprites(screen->machine, bitmap, cliprect);
500   deco16ic_tilemap_1_draw(state->deco16ic, bitmap, cliprect, 0, 0);
539501   return 0;
540502}
541503
542504VIDEO_UPDATE( mutantf )
543505{
544   flip_screen_set(screen->machine,  deco16_pf12_control[0]&0x80 );
545   deco16_pf12_update(deco16_pf1_rowscroll,deco16_pf2_rowscroll);
546   deco16_pf34_update(deco16_pf3_rowscroll,deco16_pf4_rowscroll);
506   cninja_state *state = (cninja_state *)screen->machine->driver_data;
507   UINT16 flip = deco16ic_pf12_control_r(state->deco16ic, 0, 0xffff);
508   UINT16 priority = deco16ic_priority_r(state->deco16ic, 0, 0xffff);
547509
510   flip_screen_set(screen->machine, BIT(flip, 7));
511   deco16ic_pf12_update(state->deco16ic, state->pf1_rowscroll, state->pf2_rowscroll);
512   deco16ic_pf34_update(state->deco16ic, state->pf3_rowscroll, state->pf4_rowscroll);
513
548514   /* Draw playfields */
549   bitmap_fill(bitmap,cliprect,0x400); /* Confirmed */
515   bitmap_fill(bitmap, cliprect, 0x400); /* Confirmed */
550516
551517   /* There is no priority prom on this board, but there is a
552518    priority control word, the only values used in game appear
r7500r7501
559525    The other bits may control alpha blend on the 2nd sprite chip, or
560526    layer order.
561527    */
562   deco16_tilemap_4_draw(screen,bitmap,cliprect,TILEMAP_DRAW_OPAQUE,0);
563   deco16_tilemap_2_draw(screen,bitmap,cliprect,0,0);
564   deco16_tilemap_3_draw(screen,bitmap,cliprect,0,0);
528   deco16ic_tilemap_4_draw(state->deco16ic, bitmap, cliprect, TILEMAP_DRAW_OPAQUE, 0);
529   deco16ic_tilemap_2_draw(state->deco16ic, bitmap, cliprect, 0, 0);
530   deco16ic_tilemap_3_draw(state->deco16ic, bitmap, cliprect, 0, 0);
565531
566532   /* We need to abuse the priority bitmap a little by clearing it before
567533        drawing each sprite layer.  This is because there is no priority
r7500r7501
569535        priority between sprites in each layer.  Ie, if we didn't do this,
570536        then when two alpha blended shadows overlapped then they would be 25%
571537        transparent against the background, rather than 50% */
572   if (deco16_priority&1) {
573      bitmap_fill(screen->machine->priority_bitmap,cliprect,0);
574      mutantf_draw_sprites(screen->machine,bitmap,cliprect,screen->machine->generic.buffered_spriteram.u16,3);
575      bitmap_fill(screen->machine->priority_bitmap,cliprect,0);
576      mutantf_draw_sprites(screen->machine,bitmap,cliprect,screen->machine->generic.buffered_spriteram2.u16,4);
577   } else {
578      bitmap_fill(screen->machine->priority_bitmap,cliprect,0);
579      mutantf_draw_sprites(screen->machine,bitmap,cliprect,screen->machine->generic.buffered_spriteram2.u16,4);
580      bitmap_fill(screen->machine->priority_bitmap,cliprect,0);
581      mutantf_draw_sprites(screen->machine,bitmap,cliprect,screen->machine->generic.buffered_spriteram.u16,3);
538   if (priority & 1)
539   {
540      bitmap_fill(screen->machine->priority_bitmap, cliprect, 0);
541      mutantf_draw_sprites(screen->machine, bitmap, cliprect, screen->machine->generic.buffered_spriteram.u16, 3);
542      bitmap_fill(screen->machine->priority_bitmap, cliprect, 0);
543      mutantf_draw_sprites(screen->machine, bitmap, cliprect, screen->machine->generic.buffered_spriteram2.u16, 4);
582544   }
583   deco16_tilemap_1_draw(screen,bitmap,cliprect,0,0);
545   else
546   {
547      bitmap_fill(screen->machine->priority_bitmap, cliprect, 0);
548      mutantf_draw_sprites(screen->machine, bitmap, cliprect, screen->machine->generic.buffered_spriteram2.u16, 4);
549      bitmap_fill(screen->machine->priority_bitmap, cliprect, 0);
550      mutantf_draw_sprites(screen->machine, bitmap, cliprect, screen->machine->generic.buffered_spriteram.u16, 3);
551   }
552   deco16ic_tilemap_1_draw(state->deco16ic, bitmap, cliprect, 0, 0);
584553   return 0;
585554}
src/mame/video/tumblep.c
r7500r7501
1414***************************************************************************/
1515
1616#include "emu.h"
17#include "includes/deco16ic.h"
17#include "video/deco16ic.h"
18#include "includes/tumblep.h"
1819
19static void draw_sprites(running_machine *machine, bitmap_t *bitmap,const rectangle *cliprect)
20static void draw_sprites( running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect )
2021{
21   UINT16 *spriteram16 = machine->generic.spriteram.u16;
22   tumblep_state *state = (tumblep_state *)machine->driver_data;
23   UINT16 *spriteram = state->spriteram;
2224   int offs;
2325
24   for (offs = 0;offs < 0x400;offs += 4)
26   for (offs = 0; offs < 0x400; offs += 4)
2527   {
26      int x,y,sprite,colour,multi,fx,fy,inc,flash,mult;
28      int x, y, sprite, colour, multi, fx, fy, inc, flash, mult;
2729
28      sprite = spriteram16[offs+1];
29      if (!sprite) continue;
30      sprite = spriteram[offs + 1];
31      if (!sprite)
32         continue;
3033
31      y = spriteram16[offs];
32      flash=y&0x1000;
33      if (flash && (video_screen_get_frame_number(machine->primary_screen) & 1)) continue;
34      y = spriteram[offs];
35      flash = y & 0x1000;
36      if (flash && (video_screen_get_frame_number(machine->primary_screen) & 1))
37         continue;
3438
35      x = spriteram16[offs+2];
36      colour = (x >>9) & 0x1f;
39      x = spriteram[offs + 2];
40      colour = (x >> 9) & 0x1f;
3741
3842      fx = y & 0x2000;
3943      fy = y & 0x4000;
r7500r7501
4448      if (x >= 320) x -= 512;
4549      if (y >= 256) y -= 512;
4650      y = 240 - y;
47        x = 304 - x;
51      x = 304 - x;
4852
49      if (x>320) continue;
53      if (x > 320) continue;
5054
5155      sprite &= ~multi;
5256      if (fy)
r7500r7501
5963
6064      if (flip_screen_get(machine))
6165      {
62         y=240-y;
63         x=304-x;
64         if (fx) fx=0; else fx=1;
65         if (fy) fy=0; else fy=1;
66         mult=16;
66         y = 240 - y;
67         x = 304 - x;
68         if (fx) fx = 0; else fx = 1;
69         if (fy) fy = 0; else fy = 1;
70         mult = 16;
6771      }
68      else mult=-16;
72      else mult = -16;
6973
7074      while (multi >= 0)
7175      {
r7500r7501
8084   }
8185}
8286
83VIDEO_START(tumblep)
87VIDEO_UPDATE( tumblep )
8488{
85   deco16_1_video_init(machine);
86}
89   tumblep_state *state = (tumblep_state *)screen->machine->driver_data;
90   UINT16 flip = deco16ic_pf12_control_r(state->deco16ic, 0, 0xffff);
8791
88VIDEO_UPDATE(tumblep)
89{
90   flip_screen_set(screen->machine,  deco16_pf12_control[0]&0x80 );
91   deco16_pf12_update(deco16_pf1_rowscroll,deco16_pf2_rowscroll);
92   flip_screen_set(screen->machine, BIT(flip, 7));
93   deco16ic_pf12_update(state->deco16ic, state->pf1_rowscroll, state->pf2_rowscroll);
9294
93   bitmap_fill(bitmap,cliprect,256); /* not verified */
95   bitmap_fill(bitmap, cliprect, 256); /* not verified */
9496
95   deco16_tilemap_2_draw(screen,bitmap,cliprect,TILEMAP_DRAW_OPAQUE,0);
96   deco16_tilemap_1_draw(screen,bitmap,cliprect,0,0);
97   deco16ic_tilemap_2_draw(state->deco16ic, bitmap, cliprect, TILEMAP_DRAW_OPAQUE, 0);
98   deco16ic_tilemap_1_draw(state->deco16ic, bitmap, cliprect, 0, 0);
9799
98   draw_sprites(screen->machine,bitmap,cliprect);
100   draw_sprites(screen->machine, bitmap, cliprect);
99101   return 0;
100102}
src/mame/video/dietgo.c
r7500r7501
11#include "emu.h"
2#include "includes/deco16ic.h"
2#include "video/deco16ic.h"
3#include "includes/dietgo.h"
34
4static void draw_sprites(running_machine* machine, bitmap_t *bitmap,const rectangle *cliprect)
5
6static void draw_sprites( running_machine* machine, bitmap_t *bitmap, const rectangle *cliprect )
57{
6   UINT16 *spriteram16 = machine->generic.spriteram.u16;
8   dietgo_state *state = (dietgo_state *)machine->driver_data;
9   UINT16 *spriteram = state->spriteram;
710   int offs;
811
9   for (offs = 0;offs < 0x400;offs += 4)
12   for (offs = 0; offs < 0x400; offs += 4)
1013   {
11      int x,y,sprite,colour,multi,fx,fy,inc,flash,mult;
14      int x, y, sprite, colour, multi, fx, fy, inc, flash, mult;
1215
13      sprite = spriteram16[offs+1];
14      if (!sprite) continue;
16      sprite = spriteram[offs + 1];
17      if (!sprite)
18         continue;
1519
16      y = spriteram16[offs];
17      flash=y&0x1000;
18      if (flash && (video_screen_get_frame_number(machine->primary_screen) & 1)) continue;
20      y = spriteram[offs];
21      flash = y & 0x1000;
22      if (flash && (video_screen_get_frame_number(machine->primary_screen) & 1))
23         continue;
1924
20      x = spriteram16[offs+2];
21      colour = (x >>9) & 0x1f;
25      x = spriteram[offs + 2];
26      colour = (x >> 9) & 0x1f;
2227
2328      fx = y & 0x2000;
2429      fy = y & 0x4000;
r7500r7501
2934      if (x >= 320) x -= 512;
3035      if (y >= 256) y -= 512;
3136      y = 240 - y;
32        x = 304 - x;
37      x = 304 - x;
3338
34      if (x>320) continue;
39      if (x > 320)
40         continue;
3541
3642      sprite &= ~multi;
3743      if (fy)
r7500r7501
4450
4551      if (flip_screen_get(machine))
4652      {
47         y=240-y;
48         x=304-x;
49         if (fx) fx=0; else fx=1;
50         if (fy) fy=0; else fy=1;
51         mult=16;
53         y = 240 - y;
54         x = 304 - x;
55         if (fx) fx = 0; else fx = 1;
56         if (fy) fy = 0; else fy = 1;
57         mult = 16;
5258      }
53      else mult=-16;
59      else mult = -16;
5460
5561      while (multi >= 0)
5662      {
r7500r7501
6571   }
6672}
6773
68static int dietgo_bank_callback(const int bank)
69{
70   return ((bank>>4)&0x7) * 0x1000;
71}
7274
73VIDEO_START(dietgo)
75VIDEO_UPDATE( dietgo )
7476{
75   deco16_1_video_init(machine);
77   dietgo_state *state = (dietgo_state *)screen->machine->driver_data;
78   UINT16 flip = deco16ic_pf12_control_r(state->deco16ic, 0, 0xffff);
7679
77   deco16_set_tilemap_bank_callback(0, dietgo_bank_callback);
78   deco16_set_tilemap_bank_callback(1, dietgo_bank_callback);
79}
80   flip_screen_set(screen->machine, BIT(flip, 7));
81   deco16ic_pf12_update(state->deco16ic, state->pf1_rowscroll, state->pf2_rowscroll);
8082
81VIDEO_UPDATE(dietgo)
82{
83   flip_screen_set(screen->machine,  deco16_pf12_control[0]&0x80 );
84   deco16_pf12_update(deco16_pf1_rowscroll,deco16_pf2_rowscroll);
83   bitmap_fill(bitmap, cliprect, 256); /* not verified */
8584
86   bitmap_fill(bitmap,cliprect,256); /* not verified */
85   deco16ic_tilemap_2_draw(state->deco16ic, bitmap, cliprect, TILEMAP_DRAW_OPAQUE, 0);
86   deco16ic_tilemap_1_draw(state->deco16ic, bitmap, cliprect, 0, 0);
8787
88   deco16_tilemap_2_draw(screen,bitmap,cliprect,TILEMAP_DRAW_OPAQUE,0);
89   deco16_tilemap_1_draw(screen,bitmap,cliprect,0,0);
90
91   draw_sprites(screen->machine,bitmap,cliprect);
88   draw_sprites(screen->machine, bitmap, cliprect);
9289   return 0;
9390}
src/mame/video/avgdvg.c
r7500r7501
173173
174174static void vg_flush (running_machine *machine)
175175{
176   int i;
176   int i = 0;
177177
178   while (vectbuf[i].status == VGCLIP)
179      i++;
180   vector_add_point(machine, vectbuf[i].x, vectbuf[i].y, vectbuf[i].color, 0);
181
178182   for (i = 0; i < nvect; i++)
179183   {
180184      if (vectbuf[i].status == VGVECTOR)
r7500r7501
11311135   vg->sp = 0;
11321136}
11331137
1138static void tempest_vggo(vgdata *vg)
1139{
1140   vg->pc = 0;
1141   vg->sp = 0;
1142   /*
1143     * Tempest and Quantum trigger VGGO from time to time even though
1144     * the VG runs in an endless loop for these games (see
1145     * avg_common_strobe2). If we don't discard all vectors in the
1146     * current buffer at this point, the screen starts flickering.
1147     */
1148   nvect = 0;
1149}
1150
11341151static void dvg_vggo(vgdata *vg)
11351152{
11361153   vg->dvy = 0;
r7500r7501
12211238 *
12221239 ************************************/
12231240
1224#ifdef UNUSED_FUNCTION
1225int avgdvg_done(void)
1226{
1227   return vg->sync_halt;
1228}
1229#endif
1230
12311241CUSTOM_INPUT( avgdvg_done_r )
12321242{
12331243   return vg->sync_halt ? 0x01 : 0x00;
r7500r7501
12351245
12361246WRITE8_HANDLER( avgdvg_go_w )
12371247{
1248   vgc->vggo(vg);
1249
12381250   if (vg->sync_halt && (nvect > 10))
12391251   {
12401252      /*
r7500r7501
12461258   }
12471259   vg_flush(space->machine);
12481260
1249   vgc->vggo(vg);
12501261   vg_set_halt(0);
12511262   timer_adjust_oneshot(vg_run_timer, attotime_zero, 0);
12521263}
r7500r7501
13721383   },
13731384   avg_state_addr,
13741385   avg_data,
1375   avg_vggo,
1386   tempest_vggo,
13761387   avg_vgrst
13771388};
13781389
r7500r7501
14081419   },
14091420   avg_state_addr,
14101421   quantum_data,
1411   avg_vggo,
1422   tempest_vggo,
14121423   avg_vgrst
14131424};
14141425
src/mame/video/dassault.c
r7500r7501
55****************************************************************************/
66
77#include "emu.h"
8#include "includes/deco16ic.h"
8#include "video/deco16ic.h"
9#include "includes/dassault.h"
910
1011/******************************************************************************/
1112
12static void draw_sprites(running_machine* machine, bitmap_t *bitmap, const rectangle *cliprect, int pf_priority)
13static void draw_sprites( running_machine* machine, bitmap_t *bitmap, const rectangle *cliprect, int pf_priority )
1314{
14   UINT16 *buffered_spriteram16 = machine->generic.buffered_spriteram.u16;
15   int x,y,sprite,colour,multi,fx,fy,inc,flash,mult;
15   dassault_state *state = (dassault_state *)machine->driver_data;
16   UINT16 *buffered_spriteram = machine->generic.buffered_spriteram.u16;
17   int x, y, sprite, colour, multi, fx, fy, inc, flash, mult;
1618   int offs, bank, gfxbank;
1719   const UINT16 *spritebase;
1820
1921   /* Have to loop over the two sprite sources */
20   for (bank=0; bank<2; bank++)
22   for (bank = 0; bank < 2; bank++)
2123   {
22      for (offs = 0x800-4;offs >= 0; offs -= 4)
24      for (offs = 0x800 - 4; offs >= 0; offs -= 4)
2325      {
24         int alpha=0xff, pmask=0;
26         int alpha = 0xff, pmask = 0;
2527
2628         /* Draw the main spritebank after the other one */
27         if (bank==0)
29         if (bank == 0)
2830         {
29            spritebase=buffered_spriteram16;
30            gfxbank=3;
31            spritebase = buffered_spriteram;
32            gfxbank = 3;
3133         }
3234         else
3335         {
34            spritebase=machine->generic.buffered_spriteram2.u16;
35            gfxbank=4;
36            spritebase = machine->generic.buffered_spriteram2.u16;
37            gfxbank = 4;
3638         }
3739
38         sprite = spritebase[offs+1] & 0x7fff;
39         if (!sprite) continue;
40         sprite = spritebase[offs + 1] & 0x7fff;
41         if (!sprite)
42            continue;
4043
41         x = spritebase[offs+2];
44         x = spritebase[offs + 2];
4245
4346         /* Alpha on chip 2 only */
44         if (bank==1 && x&0xc000)
45            alpha=0x80;
47         if (bank == 1 && x & 0xc000)
48            alpha = 0x80;
4649
4750         y = spritebase[offs];
48         flash=y&0x1000;
49         if (flash && (video_screen_get_frame_number(machine->primary_screen) & 1)) continue;
50         colour = (x >> 9) &0x1f;
51         if (y&0x8000) colour+=32;
51         flash = y & 0x1000;
52         if (flash && (video_screen_get_frame_number(machine->primary_screen) & 1))
53            continue;
54         colour = (x >> 9) & 0x1f;
55         if (y & 0x8000)
56            colour += 32;
5257
5358         fx = y & 0x2000;
5459         fy = y & 0x4000;
r7500r7501
6166         x = 304 - x;
6267         y = 240 - y;
6368
64         if (x>320) continue; /* Speedup */
69         if (x > 320)
70            continue; /* Speedup */
6571
6672         sprite &= ~multi;
6773         if (fy)
r7500r7501
7278            inc = 1;
7379         }
7480
75         if (flip_screen_get(machine)) {
76            y=240-y;
77            x=304-x;
78            if (fx) fx=0; else fx=1;
79            if (fy) fy=0; else fy=1;
80            mult=16;
81         if (flip_screen_get(machine))
82         {
83            y = 240 - y;
84            x = 304 - x;
85            if (fx) fx = 0; else fx = 1;
86            if (fy) fy = 0; else fy = 1;
87            mult = 16;
8188         }
82         else mult=-16;
89         else mult = -16;
8390
8491         /* Priority */
85         switch (pf_priority&3) {
92         switch (pf_priority & 3)
93         {
8694         case 0:
87            if (bank==0) {
88               switch (spritebase[offs+2]&0xc000) {
89               case 0xc000: pmask=1; break;
90               case 0x8000: pmask=8; break;
91               case 0x4000: pmask=32; break;
92               case 0x0000: pmask=128; break;
95            if (bank == 0)
96            {
97               switch (spritebase[offs+2]&0xc000)
98               {
99               case 0xc000: pmask = 1; break;
100               case 0x8000: pmask = 8; break;
101               case 0x4000: pmask = 32; break;
102               case 0x0000: pmask = 128; break;
93103               }
94            } else {
95               if (spritebase[offs+2]&0x8000) pmask=64; /* Check */
96               else pmask=64;
97104            }
105            else
106            {
107               if (spritebase[offs + 2] & 0x8000)
108                  pmask = 64; /* Check */
109               else
110                  pmask = 64;
111            }
98112            break;
99113
100114         case 1:
101            if (bank==0) {
102               switch (spritebase[offs+2]&0xc000) {
103               case 0xc000: pmask=1; break;
104               case 0x8000: pmask=8; break;
105               case 0x4000: pmask=32; break;
106               case 0x0000: pmask=128; break;
115            if (bank == 0)
116            {
117               switch (spritebase[offs + 2] & 0xc000)
118               {
119               case 0xc000: pmask = 1; break;
120               case 0x8000: pmask = 8; break;
121               case 0x4000: pmask = 32; break;
122               case 0x0000: pmask = 128; break;
107123               }
108            } else {
109               if (spritebase[offs+2]&0x8000) pmask=16; /* Check */
110               else pmask=16;
111124            }
125            else
126            {
127               if (spritebase[offs + 2] & 0x8000)
128                  pmask = 16; /* Check */
129               else
130                  pmask = 16;
131            }
112132            break;
113133
114134         case 2: /* Unused */
115135         case 3:
116            if (bank==0) {
117               switch (spritebase[offs+2]&0xc000) {
118               case 0xc000: pmask=1; break;
119               case 0x8000: pmask=8; break;
120               case 0x4000: pmask=32; break;
121               case 0x0000: pmask=128; break;
136            if (bank == 0)
137            {
138               switch (spritebase[offs + 2] & 0xc000)
139               {
140               case 0xc000: pmask = 1; break;
141               case 0x8000: pmask = 8; break;
142               case 0x4000: pmask = 32; break;
143               case 0x0000: pmask = 128; break;
122144               }
123            } else {
124               if (spritebase[offs+2]&0x8000) pmask=64; /* Check */
125               else pmask=64;
126145            }
146            else
147            {
148               if (spritebase[offs + 2] & 0x8000)
149                  pmask = 64; /* Check */
150               else
151                  pmask = 64;
152            }
127153            break;
128154         }
129155
130156         while (multi >= 0)
131157         {
132            deco16_pdrawgfx(
158            deco16ic_pdrawgfx(
159                  state->deco16ic,
133160                  bitmap,cliprect,machine->gfx[gfxbank],
134161                  sprite - multi * inc,
135162                  colour,
136                  fx,fy,
137                  x,y + mult * multi,
138                  0,pmask,1<<bank, 1, alpha);
163                  fx, fy,
164                  x, y + mult * multi,
165                  0, pmask, 1 << bank, 1, alpha);
139166
140167            multi--;
141168         }
r7500r7501
145172
146173/******************************************************************************/
147174
148static int dassault_bank_callback(const int bank)
175VIDEO_UPDATE( dassault )
149176{
150   return ((bank>>4)&0xf)<<12;
151}
177   dassault_state *state = (dassault_state *)screen->machine->driver_data;
178   UINT16 flip = deco16ic_pf12_control_r(state->deco16ic, 0, 0xffff);
179   UINT16 priority = deco16ic_priority_r(state->deco16ic, 0, 0xffff);
152180
153VIDEO_START( dassault )
154{
155   deco16_2_video_init(machine, 0);
156
157   deco16_set_tilemap_bank_callback(0,dassault_bank_callback);
158   deco16_set_tilemap_bank_callback(1,dassault_bank_callback);
159   deco16_set_tilemap_bank_callback(2,dassault_bank_callback);
160   deco16_set_tilemap_bank_callback(3,dassault_bank_callback);
161}
162
163/******************************************************************************/
164
165VIDEO_UPDATE( dassault )
166{
167181   /* Update tilemaps */
168   flip_screen_set(screen->machine,  deco16_pf12_control[0]&0x80 );
169   deco16_pf12_update(deco16_pf1_rowscroll,deco16_pf2_rowscroll);
170   deco16_pf34_update(deco16_pf3_rowscroll,deco16_pf4_rowscroll);
182   flip_screen_set(screen->machine, BIT(flip, 7));
183   deco16ic_pf12_update(state->deco16ic, 0, state->pf2_rowscroll);
184   deco16ic_pf34_update(state->deco16ic, 0, state->pf4_rowscroll);
171185
172186   /* Draw playfields/update priority bitmap */
173   deco16_clear_sprite_priority_bitmap();
174   bitmap_fill(screen->machine->priority_bitmap,cliprect,0);
175   bitmap_fill(bitmap,cliprect,screen->machine->pens[3072]);
176   deco16_tilemap_4_draw(screen,bitmap,cliprect,TILEMAP_DRAW_OPAQUE,0);
187   deco16ic_clear_sprite_priority_bitmap(state->deco16ic);
188   bitmap_fill(screen->machine->priority_bitmap, cliprect, 0);
189   bitmap_fill(bitmap, cliprect, screen->machine->pens[3072]);
190   deco16ic_tilemap_4_draw(state->deco16ic, bitmap, cliprect, TILEMAP_DRAW_OPAQUE, 0);
177191
178192   /* The middle playfields can be swapped priority-wise */
179   if ((deco16_priority&3)==0) {
180      deco16_tilemap_2_draw(screen,bitmap,cliprect,0,2);
181      deco16_tilemap_3_draw(screen,bitmap,cliprect,0,16);
182   } else if ((deco16_priority&3)==1) {
183      deco16_tilemap_3_draw(screen,bitmap,cliprect,0,2);
184      deco16_tilemap_2_draw(screen,bitmap,cliprect,0,64);
185   } else if ((deco16_priority&3)==3) {
186      deco16_tilemap_3_draw(screen,bitmap,cliprect,0,2);
187      deco16_tilemap_2_draw(screen,bitmap,cliprect,0,16);
188   } else {
193   if ((priority & 3) == 0)
194   {
195      deco16ic_tilemap_2_draw(state->deco16ic, bitmap, cliprect, 0, 2);
196      deco16ic_tilemap_3_draw(state->deco16ic, bitmap, cliprect, 0, 16);
197   }
198   else if ((priority & 3) == 1)
199   {
200      deco16ic_tilemap_3_draw(state->deco16ic, bitmap, cliprect, 0, 2);
201      deco16ic_tilemap_2_draw(state->deco16ic, bitmap, cliprect, 0, 64);
202   }
203   else if ((priority & 3) == 3)
204   {
205      deco16ic_tilemap_3_draw(state->deco16ic, bitmap, cliprect, 0, 2);
206      deco16ic_tilemap_2_draw(state->deco16ic, bitmap, cliprect, 0, 16);
207   }
208   else
209   {
189210      /* Unused */
190211   }
191212
192213   /* Draw sprites - two sprite generators, with selectable priority */
193   draw_sprites(screen->machine,bitmap,cliprect,deco16_priority);
194   deco16_tilemap_1_draw(screen,bitmap,cliprect,0,0);
214   draw_sprites(screen->machine, bitmap, cliprect, priority);
215   deco16ic_tilemap_1_draw(state->deco16ic, bitmap, cliprect, 0, 0);
195216   return 0;
196217}
src/mame/video/supbtime.c
r7500r7501
1313***************************************************************************/
1414
1515#include "emu.h"
16#include "includes/deco16ic.h"
16#include "video/deco16ic.h"
17#include "includes/supbtime.h"
1718
1819/******************************************************************************/
1920
20static void draw_sprites(running_machine *machine, bitmap_t *bitmap,const rectangle *cliprect)
21static void draw_sprites( running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect )
2122{
22   UINT16 *spriteram16 = machine->generic.spriteram.u16;
23   supbtime_state *state = (supbtime_state *)machine->driver_data;
24   UINT16 *spriteram = state->spriteram;
2325   int offs;
2426
25   for (offs = 0;offs < 0x400;offs += 4)
27   for (offs = 0; offs < 0x400; offs += 4)
2628   {
27      int x,y,sprite,colour,multi,fx,fy,inc,flash,mult;
29      int x, y, sprite, colour, multi, fx, fy, inc, flash, mult;
2830
29      sprite = spriteram16[offs+1] & 0x3fff;
30      if (!sprite) continue;
31      sprite = spriteram[offs + 1] & 0x3fff;
32      if (!sprite)
33         continue;
3134
32      y = spriteram16[offs];
33      flash=y&0x1000;
34      if (flash && (video_screen_get_frame_number(machine->primary_screen) & 1)) continue;
35      y = spriteram[offs];
36      flash = y & 0x1000;
37      if (flash && (video_screen_get_frame_number(machine->primary_screen) & 1))
38         continue;
3539
36      x = spriteram16[offs+2];
37      colour = (x >>9) & 0x1f;
40      x = spriteram[offs + 2];
41      colour = (x >> 9) & 0x1f;
3842
3943      fx = y & 0x2000;
4044      fy = y & 0x4000;
r7500r7501
4549      if (x >= 320) x -= 512;
4650      if (y >= 256) y -= 512;
4751      y = 240 - y;
48        x = 304 - x;
52      x = 304 - x;
4953
50      if (x>320) continue;
54      if (x > 320)
55         continue;
5156
5257      sprite &= ~multi;
5358      if (fy)
r7500r7501
6065
6166      if (flip_screen_get(machine))
6267      {
63         y=240-y;
64         x=304-x;
65         if (fx) fx=0; else fx=1;
66         if (fy) fy=0; else fy=1;
67         mult=16;
68         y = 240 - y;
69         x = 304 - x;
70         if (fx) fx = 0; else fx = 1;
71         if (fy) fy = 0; else fy = 1;
72         mult = 16;
6873      }
69      else mult=-16;
74      else mult = -16;
7075
7176      while (multi >= 0)
7277      {
r7500r7501
8388
8489/******************************************************************************/
8590
86VIDEO_START(supbtime)
87{
88   deco16_1_video_init(machine);
89}
90
9191VIDEO_UPDATE(supbtime)
9292{
93   flip_screen_set(screen->machine,  deco16_pf12_control[0]&0x80 );
94   deco16_pf12_update(deco16_pf1_rowscroll,deco16_pf2_rowscroll);
93   supbtime_state *state = (supbtime_state *)screen->machine->driver_data;
94   UINT16 flip = deco16ic_pf12_control_r(state->deco16ic, 0, 0xffff);
9595
96   bitmap_fill(bitmap,cliprect,768);
96   flip_screen_set(screen->machine, BIT(flip, 7));
97   deco16ic_pf12_update(state->deco16ic, state->pf1_rowscroll, state->pf2_rowscroll);
9798
98   deco16_tilemap_2_draw(screen,bitmap,cliprect,0,0);
99   draw_sprites(screen->machine, bitmap,cliprect);
100   deco16_tilemap_1_draw(screen,bitmap,cliprect,0,0);
99   bitmap_fill(bitmap, cliprect, 768);
100
101   deco16ic_tilemap_2_draw(state->deco16ic, bitmap, cliprect, 0, 0);
102   draw_sprites(screen->machine, bitmap, cliprect);
103   deco16ic_tilemap_1_draw(state->deco16ic, bitmap, cliprect, 0, 0);
101104   return 0;
102105}
103
src/mame/video/ohmygod.c
r7500r7501
11#include "emu.h"
2#include "includes/ohmygod.h"
23
3
4UINT16 *ohmygod_videoram;
5
6static int spritebank;
7static tilemap_t *bg_tilemap;
8
9
10
114/***************************************************************************
125
136  Callbacks for the TileMap code
r7500r7501
169
1710static TILE_GET_INFO( get_tile_info )
1811{
19   UINT16 code = ohmygod_videoram[2*tile_index+1];
20   UINT16 attr = ohmygod_videoram[2*tile_index];
12   ohmygod_state *state = (ohmygod_state *)machine->driver_data;
13   UINT16 code = state->videoram[2 * tile_index + 1];
14   UINT16 attr = state->videoram[2 * tile_index];
2115   SET_TILE_INFO(
2216         0,
2317         code,
r7500r7501
3529
3630VIDEO_START( ohmygod )
3731{
38   bg_tilemap = tilemap_create(machine, get_tile_info,tilemap_scan_rows,8,8,64,64);
32   ohmygod_state *state = (ohmygod_state *)machine->driver_data;
33   state->bg_tilemap = tilemap_create(machine, get_tile_info, tilemap_scan_rows, 8, 8, 64, 64);
3934}
4035
4136
r7500r7501
4843
4944WRITE16_HANDLER( ohmygod_videoram_w )
5045{
51   COMBINE_DATA(&ohmygod_videoram[offset]);
52   tilemap_mark_tile_dirty(bg_tilemap,offset/2);
46   ohmygod_state *state = (ohmygod_state *)space->machine->driver_data;
47   COMBINE_DATA(&state->videoram[offset]);
48   tilemap_mark_tile_dirty(state->bg_tilemap, offset / 2);
5349}
5450
5551WRITE16_HANDLER( ohmygod_spritebank_w )
5652{
53   ohmygod_state *state = (ohmygod_state *)space->machine->driver_data;
5754   if (ACCESSING_BITS_8_15)
58      spritebank = data & 0x8000;
55      state->spritebank = data & 0x8000;
5956}
6057
6158WRITE16_HANDLER( ohmygod_scrollx_w )
6259{
63   static UINT16 scroll;
64   COMBINE_DATA(&scroll);
65   tilemap_set_scrollx(bg_tilemap,0,scroll - 0x81ec);
60   ohmygod_state *state = (ohmygod_state *)space->machine->driver_data;
61   COMBINE_DATA(&state->scrollx);
62   tilemap_set_scrollx(state->bg_tilemap, 0, state->scrollx - 0x81ec);
6663}
6764
6865WRITE16_HANDLER( ohmygod_scrolly_w )
6966{
70   static UINT16 scroll;
71   COMBINE_DATA(&scroll);
72   tilemap_set_scrolly(bg_tilemap,0,scroll - 0x81ef);
67   ohmygod_state *state = (ohmygod_state *)space->machine->driver_data;
68   COMBINE_DATA(&state->scrolly);
69   tilemap_set_scrolly(state->bg_tilemap, 0, state->scrolly - 0x81ef);
7370}
7471
7572
r7500r7501
7976
8077***************************************************************************/
8178
82static void draw_sprites(running_machine *machine, bitmap_t *bitmap,const rectangle *cliprect)
79static void draw_sprites( running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect )
8380{
84   UINT16 *spriteram16 = machine->generic.spriteram.u16;
81   ohmygod_state *state = (ohmygod_state *)machine->driver_data;
82   UINT16 *spriteram = state->spriteram;
8583   int offs;
8684
87   for (offs = 0;offs < machine->generic.spriteram_size/4;offs += 4)
85   for (offs = 0; offs < state->spriteram_size / 4; offs += 4)
8886   {
89      int sx,sy,code,color,flipx;
87      int sx, sy, code, color, flipx;
9088      UINT16 *sr;
9189
92      sr = spritebank ? (spriteram16+machine->generic.spriteram_size/4) : spriteram16;
90      sr = state->spritebank ? (spriteram + state->spriteram_size / 4) : spriteram;
9391
94      code = sr[offs+3] & 0x0fff;
95      color = sr[offs+2] & 0x000f;
96      sx = sr[offs+0] - 29;
97      sy = sr[offs+1];
98      if (sy >= 32768) sy -= 65536;
99      flipx = sr[offs+3] & 0x8000;
92      code = sr[offs + 3] & 0x0fff;
93      color = sr[offs + 2] & 0x000f;
94      sx = sr[offs + 0] - 29;
95      sy = sr[offs + 1];
96      if (sy >= 32768)
97         sy -= 65536;
98      flipx = sr[offs + 3] & 0x8000;
10099
101100      drawgfx_transpen(bitmap,cliprect,machine->gfx[1],
102101            code,
r7500r7501
108107
109108VIDEO_UPDATE( ohmygod )
110109{
111   tilemap_draw(bitmap,cliprect,bg_tilemap,0,0);
112   draw_sprites(screen->machine,bitmap,cliprect);
110   ohmygod_state *state = (ohmygod_state *)screen->machine->driver_data;
111
112   tilemap_draw(bitmap, cliprect, state->bg_tilemap, 0, 0);
113   draw_sprites(screen->machine, bitmap, cliprect);
113114   return 0;
114115}
src/mame/video/oneshot.c
r7500r7501
33#include "emu.h"
44#include "includes/oneshot.h"
55
6static tilemap_t *oneshot_bg_tilemap;
7static tilemap_t *oneshot_mid_tilemap;
8static tilemap_t *oneshot_fg_tilemap;
96
107/* bg tilemap */
118static TILE_GET_INFO( get_oneshot_bg_tile_info )
129{
13   int tileno;
10   oneshot_state *state = (oneshot_state *)machine->driver_data;
11   int tileno = state->bg_videoram[tile_index * 2 + 1];
1412
15   tileno = oneshot_bg_videoram[tile_index*2+1];
16
17   SET_TILE_INFO(0,tileno,0,0);
13   SET_TILE_INFO(0, tileno, 0, 0);
1814}
1915
2016WRITE16_HANDLER( oneshot_bg_videoram_w )
2117{
22   COMBINE_DATA(&oneshot_bg_videoram[offset]);
23   tilemap_mark_tile_dirty(oneshot_bg_tilemap,offset/2);
18   oneshot_state *state = (oneshot_state *)space->machine->driver_data;
19   COMBINE_DATA(&state->bg_videoram[offset]);
20   tilemap_mark_tile_dirty(state->bg_tilemap, offset / 2);
2421}
2522
2623/* mid tilemap */
2724static TILE_GET_INFO( get_oneshot_mid_tile_info )
2825{
29   int tileno;
26   oneshot_state *state = (oneshot_state *)machine->driver_data;
27   int tileno = state->mid_videoram[tile_index * 2 + 1];
3028
31   tileno = oneshot_mid_videoram[tile_index*2+1];
32
33   SET_TILE_INFO(0,tileno,2,0);
29   SET_TILE_INFO(0, tileno, 2, 0);
3430}
3531
3632WRITE16_HANDLER( oneshot_mid_videoram_w )
3733{
38   COMBINE_DATA(&oneshot_mid_videoram[offset]);
39   tilemap_mark_tile_dirty(oneshot_mid_tilemap,offset/2);
34   oneshot_state *state = (oneshot_state *)space->machine->driver_data;
35   COMBINE_DATA(&state->mid_videoram[offset]);
36   tilemap_mark_tile_dirty(state->mid_tilemap, offset / 2);
4037}
4138
4239
4340/* fg tilemap */
4441static TILE_GET_INFO( get_oneshot_fg_tile_info )
4542{
46   int tileno;
43   oneshot_state *state = (oneshot_state *)machine->driver_data;
44   int tileno = state->fg_videoram[tile_index * 2 + 1];
4745
48   tileno = oneshot_fg_videoram[tile_index*2+1];
49
50   SET_TILE_INFO(0,tileno,3,0);
46   SET_TILE_INFO(0, tileno, 3, 0);
5147}
5248
5349WRITE16_HANDLER( oneshot_fg_videoram_w )
5450{
55   COMBINE_DATA(&oneshot_fg_videoram[offset]);
56   tilemap_mark_tile_dirty(oneshot_fg_tilemap,offset/2);
51   oneshot_state *state = (oneshot_state *)space->machine->driver_data;
52   COMBINE_DATA(&state->fg_videoram[offset]);
53   tilemap_mark_tile_dirty(state->fg_tilemap, offset / 2);
5754}
5855
5956VIDEO_START( oneshot )
6057{
61   oneshot_bg_tilemap = tilemap_create(machine, get_oneshot_bg_tile_info,tilemap_scan_rows, 16, 16,32,32);
62   oneshot_mid_tilemap = tilemap_create(machine, get_oneshot_mid_tile_info,tilemap_scan_rows, 16, 16,32,32);
63   oneshot_fg_tilemap = tilemap_create(machine, get_oneshot_fg_tile_info,tilemap_scan_rows, 16, 16,32,32);
58   oneshot_state *state = (oneshot_state *)machine->driver_data;
6459
65   tilemap_set_transparent_pen(oneshot_bg_tilemap,0);
66   tilemap_set_transparent_pen(oneshot_mid_tilemap,0);
67   tilemap_set_transparent_pen(oneshot_fg_tilemap,0);
60   state->bg_tilemap =  tilemap_create(machine, get_oneshot_bg_tile_info,  tilemap_scan_rows, 16, 16, 32, 32);
61   state->mid_tilemap = tilemap_create(machine, get_oneshot_mid_tile_info, tilemap_scan_rows, 16, 16, 32, 32);
62   state->fg_tilemap =  tilemap_create(machine, get_oneshot_fg_tile_info,  tilemap_scan_rows, 16, 16, 32, 32);
63
64   tilemap_set_transparent_pen(state->bg_tilemap,  0);
65   tilemap_set_transparent_pen(state->mid_tilemap, 0);
66   tilemap_set_transparent_pen(state->fg_tilemap,  0);
6867}
6968
7069static void draw_crosshairs( running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect )
7170{
72    int xpos,ypos;
73    /* get gun raw coordonates (player 1) */
74    gun_x_p1 = (input_port_read(machine, "LIGHT0_X") & 0xff) * 320 / 256;
75    gun_y_p1 = (input_port_read(machine, "LIGHT0_Y") & 0xff) * 240 / 256;
71   oneshot_state *state = (oneshot_state *)machine->driver_data;
72   int xpos,ypos;
7673
77    /* compute the coordonates for drawing (from routine at 0x009ab0) */
78    xpos = gun_x_p1;
79    ypos = gun_y_p1;
74   /* get gun raw coordinates (player 1) */
75   state->gun_x_p1 = (input_port_read(machine, "LIGHT0_X") & 0xff) * 320 / 256;
76   state->gun_y_p1 = (input_port_read(machine, "LIGHT0_Y") & 0xff) * 240 / 256;
8077
81    gun_x_p1+=gun_x_shift;
78   /* compute the coordinates for drawing (from routine at 0x009ab0) */
79   xpos = state->gun_x_p1;
80   ypos = state->gun_y_p1;
8281
83    gun_y_p1 -= 0x0a;
84    if (gun_y_p1 < 0)
85        gun_y_p1=0;
82   state->gun_x_p1 += state->gun_x_shift;
8683
84   state->gun_y_p1 -= 0x0a;
85   if (state->gun_y_p1 < 0)
86      state->gun_y_p1 = 0;
8787
88    /* get gun raw coordonates (player 2) */
89    gun_x_p2 = (input_port_read(machine, "LIGHT1_X") & 0xff) * 320 / 256;
90    gun_y_p2 = (input_port_read(machine, "LIGHT1_Y") & 0xff) * 240 / 256;
91    /* compute the coordonates for drawing (from routine at 0x009b6e) */
92    xpos = gun_x_p2;
93    ypos = gun_y_p2;
9488
95    gun_x_p2 += gun_x_shift-0x0a;
96    if (gun_x_p2 < 0)
97        gun_x_p2=0;
89   /* get gun raw coordinates (player 2) */
90   state->gun_x_p2 = (input_port_read(machine, "LIGHT1_X") & 0xff) * 320 / 256;
91   state->gun_y_p2 = (input_port_read(machine, "LIGHT1_Y") & 0xff) * 240 / 256;
92
93   /* compute the coordinates for drawing (from routine at 0x009b6e) */
94   xpos = state->gun_x_p2;
95   ypos = state->gun_y_p2;
96
97   state->gun_x_p2 += state->gun_x_shift - 0x0a;
98   if (state->gun_x_p2 < 0)
99      state->gun_x_p2 = 0;
98100}
99101
100static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect)
102static void draw_sprites( running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect )
101103{
102   const UINT16 *source = oneshot_sprites;
103   const UINT16 *finish = source+(0x1000/2);
104   oneshot_state *state = (oneshot_state *)machine->driver_data;
105   const UINT16 *source = state->sprites;
106   const UINT16 *finish = source + (0x1000 / 2);
104107   const gfx_element *gfx = machine->gfx[1];
105108
106   int xpos,ypos;
109   int xpos, ypos;
107110
108   while( source<finish )
111   while (source < finish)
109112   {
110      int blockx,blocky;
113      int blockx, blocky;
111114      int num = source[1] & 0xffff;
112      int xsize = (source[2] & 0x000f)+1;
113      int ysize = (source[3] & 0x000f)+1;
115      int xsize = (source[2] & 0x000f) + 1;
116      int ysize = (source[3] & 0x000f) + 1;
114117
115118      ypos = source[3] & 0xff80;
116119      xpos = source[2] & 0xff80;
r7500r7501
119122      xpos = xpos >> 7;
120123
121124
122      if (source[0] == 0x0001) break;
125      if (source[0] == 0x0001)
126         break;
123127
124128      xpos -= 8;
125129      ypos -= 6;
126130
127
128      for (blockx = 0; blockx<xsize;blockx++) {
129         for (blocky = 0; blocky<ysize;blocky++) {
130
131
131      for (blockx = 0; blockx < xsize; blockx++)
132      {
133         for (blocky = 0; blocky < ysize; blocky++)
134         {
132135            drawgfx_transpen(
133136                  bitmap,
134137                  cliprect,
135138                  gfx,
136                  num+(blocky*xsize)+blockx,
139                  num + (blocky * xsize) + blockx,
137140                  1,
138141                  0,0,
139                  xpos+blockx*8,ypos+blocky*8,0
140                  );
142                  xpos + blockx * 8, ypos + blocky * 8, 0);
141143
142144            drawgfx_transpen(
143145                  bitmap,
144146                  cliprect,
145147                  gfx,
146                  num+(blocky*xsize)+blockx,
148                  num + (blocky * xsize) + blockx,
147149                  1,
148150                  0,0,
149                  xpos+blockx*8-0x200,ypos+blocky*8,0
150                  );
151                  xpos + blockx * 8 - 0x200, ypos + blocky * 8, 0);
151152         }
152153      }
153154      source += 0x4;
r7500r7501
157158
158159VIDEO_UPDATE( oneshot )
159160{
161   oneshot_state *state = (oneshot_state *)screen->machine->driver_data;
162
160163   bitmap_fill(bitmap, cliprect, get_black_pen(screen->machine));
161164
162   tilemap_set_scrollx(oneshot_mid_tilemap,0, oneshot_scroll[0]-0x1f5);
163   tilemap_set_scrolly(oneshot_mid_tilemap,0, oneshot_scroll[1]);
165   tilemap_set_scrollx(state->mid_tilemap, 0, state->scroll[0] - 0x1f5);
166   tilemap_set_scrolly(state->mid_tilemap, 0, state->scroll[1]);
164167
165   tilemap_draw(bitmap,cliprect,oneshot_bg_tilemap,0,0);
166   tilemap_draw(bitmap,cliprect,oneshot_mid_tilemap,0,0);
167   draw_sprites(screen->machine,bitmap,cliprect);
168   tilemap_draw(bitmap,cliprect,oneshot_fg_tilemap,0,0);
169   draw_crosshairs(screen->machine,bitmap,cliprect);
168   tilemap_draw(bitmap, cliprect, state->bg_tilemap, 0, 0);
169   tilemap_draw(bitmap, cliprect, state->mid_tilemap, 0, 0);
170   draw_sprites(screen->machine, bitmap, cliprect);
171   tilemap_draw(bitmap, cliprect, state->fg_tilemap, 0, 0);
172   draw_crosshairs(screen->machine, bitmap, cliprect);
170173   return 0;
171174}
172175
173176VIDEO_UPDATE( maddonna )
174177{
178   oneshot_state *state = (oneshot_state *)screen->machine->driver_data;
179
175180   bitmap_fill(bitmap, cliprect, get_black_pen(screen->machine));
176181
177   tilemap_set_scrolly(oneshot_mid_tilemap,0, oneshot_scroll[1]); // other registers aren't used so we don't know which layers they relate to
182   tilemap_set_scrolly(state->mid_tilemap, 0, state->scroll[1]); // other registers aren't used so we don't know which layers they relate to
178183
179   tilemap_draw(bitmap,cliprect,oneshot_mid_tilemap,0,0);
180   tilemap_draw(bitmap,cliprect,oneshot_fg_tilemap,0,0);
181   tilemap_draw(bitmap,cliprect,oneshot_bg_tilemap,0,0);
182   draw_sprites(screen->machine,bitmap,cliprect);
183//  draw_crosshairs(screen->machine,bitmap,cliprect); // not a gun game
184   tilemap_draw(bitmap, cliprect, state->mid_tilemap, 0, 0);
185   tilemap_draw(bitmap, cliprect, state->fg_tilemap, 0, 0);
186   tilemap_draw(bitmap, cliprect, state->bg_tilemap, 0, 0);
187   draw_sprites(screen->machine, bitmap, cliprect);
184188
185//  popmessage ("%04x %04x %04x %04x %04x %04x %04x %04x", oneshot_scroll[0],oneshot_scroll[1],oneshot_scroll[2],oneshot_scroll[3],oneshot_scroll[4],oneshot_scroll[5],oneshot_scroll[6],oneshot_scroll[7]);
189//  popmessage ("%04x %04x %04x %04x %04x %04x %04x %04x", state->scroll[0], state->scroll[1], state->scroll[2], state->scroll[3], state->scroll[4], state->scroll[5], state->scroll[6], state->scroll[7]);
186190   return 0;
187191}
src/mame/video/funworld.c
r7500r7501
11/**********************************************************************************
22
33
4    FUNWORLD / TAB.
4  FUNWORLD / TAB.
5  Video Hardware.
56
6  Video Hardware.
7  Written by Roberto Fresca.
78
8    Written by Roberto Fresca.
99
10  Games running on this hardware:
1011
11    Games running on this hardware:
12  * Jolly Card (austrian),                            TAB-Austria,        1985.
13  * Jolly Card (3x3 deal),                            TAB-Austria,        1985.
14  * Jolly Card Professional 2.0,                      Spale-Soft,         2000.
15  * Jolly Card (Evona Electronic),                    Evona Electronic    1998.
16  * Jolly Card (croatian, set 1),                     TAB-Austria,        1985.
17  * Jolly Card (croatian, set 2),                     Soft Design,        1993.
18  * Jolly Card (italian, blue TAB board, encrypted),  bootleg,            199?.
19  * Jolly Card (italian, encrypted bootleg),          bootleg,            1990.
20  * Super Joly 2000 - 3x,                             M.P.                1985.
21  * Jolly Card (austrian, Funworld, bootleg),         Inter Games,        1986.
22  * Big Deal (hungarian, set 1),                      Funworld,           1986.
23  * Big Deal (hungarian, set 2),                      Funworld,           1986.
24  * Jolly Card (austrian, Funworld),                  Funworld,           1986.
25  * Cuore 1 (italian),                                C.M.C.,             1996.
26  * Elephant Family (italian, new),                   C.M.C.,             1997.
27  * Elephant Family (italian, old),                   C.M.C.,             1996.
28  * Pool 10 (italian, set 1),                         C.M.C.,             1996.
29  * Pool 10 (italian, set 2),                         C.M.C.,             1996.
30  * Pool 10 (italian, set 3),                         C.M.C.,             1996.
31  * Pool 10 (italian, set 4),                         C.M.C.,             1997.
32  * Tortuga Family (italian),                         C.M.C.,             1997.
33  * Pot Game (italian),                               C.M.C.,             1996.
34  * Bottle 10 (italian, set 1),                       C.M.C.,             1996.
35  * Bottle 10 (italian, set 2),                       C.M.C.,             1996.
36  * Royal Card (austrian, set 1),                     TAB-Austria,        1991.
37  * Royal Card (austrian, set 2),                     TAB-Austria,        1991.
38  * Royal Card (slovak, encrypted),                   Evona Electronic,   1991.
39  * Royal Card Professional 2.0,                      Digital Dreams,     1993.
40  * Lucky Lady (3x3 deal),                            TAB-Austria,        1991.
41  * Lucky Lady (4x1 aces),                            TAB-Austria,        1991.
42  * Magic Card II (bulgarian),                        Impera,             1996.
43  * Magic Card II (green TAB or Impera board),        Impera,             1996.
44  * Magic Card II (blue TAB board, encrypted),        Impera,             1996.
45  * Royal Vegas Joker Card (slow deal),               Funworld,           1993.
46  * Royal Vegas Joker Card (fast deal),               Soft Design,        1993.
47  * Royal Vegas Joker Card (fast deal, english gfx),  Soft Design,        1993.
48  * Jolly Joker (98bet, set 1).                       Impera,             198?.
49  * Jolly Joker (98bet, set 2).                       Impera,             198?.
50  * Jolly Joker (40bet, croatian hack),               Impera,             198?.
51  * Joker Card (Ver.A267BC, encrypted),               Vesely Svet,        1993.
52  * Mongolfier New (italian),                         bootleg,            199?.
53  * Soccer New (italian),                             bootleg,            199?.
54  * Saloon (french, encrypted),                       unknown,            199?.
1255
13    * Jolly Card (austrian),                            TAB-Austria,        1985.
14    * Jolly Card (3x3 deal),                            TAB-Austria,        1985.
15    * Jolly Card Professional 2.0,                      Spale-Soft,         2000.
16    * Jolly Card (Evona Electronic),                    Evona Electronic    1998.
17    * Jolly Card (croatian, set 1),                     TAB-Austria,        1985.
18    * Jolly Card (croatian, set 2),                     Soft Design,        1993.
19    * Jolly Card (italian, blue TAB board, encrypted),  bootleg,            199?.
20    * Jolly Card (italian, encrypted bootleg),          bootleg,            1990.
21    * Super Joly 2000 - 3x,                             M.P.                1985.
22    * Jolly Card (austrian, Funworld, bootleg),         Inter Games,        1986.
23    * Big Deal (hungarian, set 1),                      Funworld,           1986.
24    * Big Deal (hungarian, set 2),                      Funworld,           1986.
25    * Jolly Card (austrian, Funworld),                  Funworld,           1986.
26    * Cuore 1 (italian),                                C.M.C.,             1996.
27    * Elephant Family (italian, new),                   C.M.C.,             1997.
28    * Elephant Family (italian, old),                   C.M.C.,             1996.
29    * Pool 10 (italian, set 1),                         C.M.C.,             1996.
30    * Pool 10 (italian, set 2),                         C.M.C.,             1996.
31    * Pool 10 (italian, set 3),                         C.M.C.,             1996.
32    * Pool 10 (italian, set 4),                         C.M.C.,             1997.
33    * Tortuga Family (italian),                         C.M.C.,             1997.
34    * Pot Game (italian),                               C.M.C.,             1996.
35    * Bottle 10 (italian, set 1),                       C.M.C.,             1996.
36    * Bottle 10 (italian, set 2),                       C.M.C.,             1996.
37    * Royal Card (austrian, set 1),                     TAB-Austria,        1991.
38    * Royal Card (austrian, set 2),                     TAB-Austria,        1991.
39    * Royal Card (slovak, encrypted),                   Evona Electronic,   1991.
40    * Royal Card Professional 2.0,                      Digital Dreams,     1993.
41    * Lucky Lady (3x3 deal),                            TAB-Austria,        1991.
42    * Lucky Lady (4x1 aces),                            TAB-Austria,        1991.
43    * Magic Card II (bulgarian),                        Impera,             1996.
44    * Magic Card II (green TAB or Impera board),        Impera,             1996.
45    * Magic Card II (blue TAB board, encrypted),        Impera,             1996.
46    * Royal Vegas Joker Card (slow deal),               Funworld,           1993.
47    * Royal Vegas Joker Card (fast deal),               Soft Design,        1993.
48    * Royal Vegas Joker Card (fast deal, english gfx),  Soft Design,        1993.
49    * Jolly Joker,                                      Impera,             198?.
50    * Jolly Joker (50bet),                              Impera,             198?.
51    * Joker Card (Ver.A267BC, encrypted),               Vesely Svet,        1993.
52    * Mongolfier New (italian),                         bootleg,            199?.
53    * Soccer New (italian),                             bootleg,            199?.
54    * Saloon (french, encrypted),                       unknown,            199?.
5556
56
5757***********************************************************************************/
5858
5959
src/mame/video/tumbleb.c
r7500r7501
1717#include "emu.h"
1818#include "includes/tumbleb.h"
1919
20
21static UINT16 tumblepb_control_0[8];
22UINT16 *tumblepb_pf1_data,*tumblepb_pf2_data;
23static tilemap_t *pf1_tilemap,*pf1_alt_tilemap,*pf2_tilemap,*pf2_alt_tilemap;
24static int flipscreen;
25static UINT16 bcstory_tilebank;
26static int sprite_xoffset;
27static int sprite_yoffset;
28
29
3020/******************************************************************************/
3121
32static void tumblepb_draw_sprites(running_machine *machine, bitmap_t *bitmap,const rectangle *cliprect)
22static void tumblepb_draw_sprites( running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect )
3323{
34   UINT16 *spriteram16 = machine->generic.spriteram.u16;
24   tumbleb_state *state = (tumbleb_state *)machine->driver_data;
25   UINT16 *spriteram = state->spriteram;
3526   int offs;
3627
37   for (offs = 0;offs < 0x400;offs += 4)
28   for (offs = 0; offs < 0x400; offs += 4)
3829   {
39      int x,y,sprite,colour,multi,fx,fy,inc,flash,mult;
30      int x, y, sprite, colour, multi, fx, fy, inc, flash, mult;
4031
41      sprite = spriteram16[offs+1] & 0x3fff;
42      if (!sprite) continue;
32      sprite = spriteram[offs + 1] & 0x3fff;
33      if (!sprite)
34         continue;
4335
44      y = spriteram16[offs];
45      flash=y&0x1000;
46      if (flash && (video_screen_get_frame_number(machine->primary_screen) & 1)) continue;
36      y = spriteram[offs];
37      flash = y & 0x1000;
38      if (flash && (video_screen_get_frame_number(machine->primary_screen) & 1))
39         continue;
4740
48      x = spriteram16[offs+2];
49      colour = (x >>9) & 0xf;
41      x = spriteram[offs + 2];
42      colour = (x >> 9) & 0xf;
5043
5144      fx = y & 0x2000;
5245      fy = y & 0x4000;
r7500r7501
5750      if (x >= 320) x -= 512;
5851      if (y >= 256) y -= 512;
5952      y = 240 - y;
60        x = 304 - x;
53      x = 304 - x;
6154
6255      sprite &= ~multi;
6356      if (fy)
r7500r7501
6861         inc = 1;
6962      }
7063
71      if (flipscreen)
64      if (state->flipscreen)
7265      {
73         y=240-y;
74         x=304-x;
75         if (fx) fx=0; else fx=1;
76         if (fy) fy=0; else fy=1;
77         mult=16;
66         y = 240 - y;
67         x = 304 - x;
68         if (fx) fx = 0; else fx = 1;
69         if (fy) fy = 0; else fy = 1;
70         mult = 16;
7871      }
79      else mult=-16;
72      else
73         mult = -16;
8074
8175      while (multi >= 0)
8276      {
r7500r7501
8478               sprite - multi * inc,
8579               colour,
8680               fx,fy,
87               sprite_xoffset + x,sprite_yoffset + y + mult * multi,0);
81               state->sprite_xoffset + x, state->sprite_yoffset + y + mult * multi, 0);
8882
8983         multi--;
9084      }
9185   }
9286}
9387
94static void jumpkids_draw_sprites(running_machine *machine, bitmap_t *bitmap,const rectangle *cliprect)
88static void jumpkids_draw_sprites( running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect )
9589{
96   UINT16 *spriteram16 = machine->generic.spriteram.u16;
90   tumbleb_state *state = (tumbleb_state *)machine->driver_data;
91   UINT16 *spriteram = state->spriteram;
9792   int offs;
9893
99   for (offs = 0;offs < machine->generic.spriteram_size/2;offs += 4)
94   for (offs = 0; offs < state->spriteram_size / 2; offs += 4)
10095   {
101      int x,y,sprite,colour,multi,fx,fy,inc,flash,mult;
96      int x, y, sprite, colour, multi, fx, fy, inc, flash, mult;
10297
103      sprite = spriteram16[offs+1] & 0x7fff;
104      if (!sprite) continue;
98      sprite = spriteram[offs + 1] & 0x7fff;
99      if (!sprite)
100         continue;
105101
106      y = spriteram16[offs];
107      flash=y&0x1000;
108      if (flash && (video_screen_get_frame_number(machine->primary_screen) & 1)) continue;
102      y = spriteram[offs];
103      flash = y & 0x1000;
104      if (flash && (video_screen_get_frame_number(machine->primary_screen) & 1))
105         continue;
109106
110      x = spriteram16[offs+2];
111      colour = (x >>9) & 0xf;
107      x = spriteram[offs+2];
108      colour = (x >> 9) & 0xf;
112109
113110      fx = y & 0x2000;
114111      fy = y & 0x4000;
r7500r7501
119116      if (x >= 320) x -= 512;
120117      if (y >= 256) y -= 512;
121118      y = 240 - y;
122        x = 304 - x;
119      x = 304 - x;
123120
124   //  sprite &= ~multi; /* Todo:  I bet TumblePop bootleg doesn't do this either */
121      //  sprite &= ~multi; /* Todo:  I bet TumblePop bootleg doesn't do this either */
125122      if (fy)
126123         inc = -1;
127124      else
r7500r7501
130127         inc = 1;
131128      }
132129
133      if (flipscreen)
130      if (state->flipscreen)
134131      {
135         y=240-y;
136         x=304-x;
137         if (fx) fx=0; else fx=1;
138         if (fy) fy=0; else fy=1;
139         mult=16;
132         y = 240 - y;
133         x = 304 - x;
134         if (fx) fx = 0; else fx = 1;
135         if (fy) fy = 0; else fy = 1;
136         mult = 16;
140137      }
141      else mult=-16;
138      else
139         mult = -16;
142140
143141      while (multi >= 0)
144142      {
r7500r7501
147145               sprite - multi * inc,
148146               colour,
149147               fx,fy,
150               sprite_xoffset+x,sprite_yoffset + y + mult * multi,0);
148               state->sprite_xoffset + x, state->sprite_yoffset + y + mult * multi, 0);
151149
152150         multi--;
153151      }
154152   }
155153}
156154
157static void fncywld_draw_sprites(running_machine *machine, bitmap_t *bitmap,const rectangle *cliprect)
155static void fncywld_draw_sprites( running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect )
158156{
159   UINT16 *spriteram16 = machine->generic.spriteram.u16;
157   tumbleb_state *state = (tumbleb_state *)machine->driver_data;
158   UINT16 *spriteram = state->spriteram;
160159   int offs;
161160
162   for (offs = 0;offs < 0x400;offs += 4)
161   for (offs = 0; offs < 0x400; offs += 4)
163162   {
164      int x,y,sprite,colour,multi,fx,fy,inc,flash,mult;
163      int x, y, sprite, colour, multi, fx, fy, inc, flash, mult;
165164
166      sprite = spriteram16[offs+1] & 0x3fff;
167      if (!sprite) continue;
165      sprite = spriteram[offs + 1] & 0x3fff;
166      if (!sprite)
167         continue;
168168
169      y = spriteram16[offs];
170      flash=y&0x1000;
171      if (flash && (video_screen_get_frame_number(machine->primary_screen) & 1)) continue;
169      y = spriteram[offs];
170      flash = y & 0x1000;
171      if (flash && (video_screen_get_frame_number(machine->primary_screen) & 1))
172         continue;
172173
173      x = spriteram16[offs+2];
174      colour = (x >>9) & 0x3f;
174      x = spriteram[offs + 2];
175      colour = (x >> 9) & 0x3f;
175176
176177      fx = y & 0x2000;
177178      fy = y & 0x4000;
r7500r7501
182183      if (x >= 320) x -= 512;
183184      if (y >= 256) y -= 512;
184185      y = 240 - y;
185        x = 304 - x;
186      x = 304 - x;
186187
187   //  sprite &= ~multi; /* Todo:  I bet TumblePop bootleg doesn't do this either */
188      //  sprite &= ~multi; /* Todo:  I bet TumblePop bootleg doesn't do this either */
188189      if (fy)
189190         inc = -1;
190191      else
r7500r7501
193194         inc = 1;
194195      }
195196
196      if (flipscreen)
197      if (state->flipscreen)
197198      {
198         y=240-y;
199         x=304-x;
200         if (fx) fx=0; else fx=1;
201         if (fy) fy=0; else fy=1;
202         mult=16;
199         y = 240 - y;
200         x = 304 - x;
201         if (fx) fx = 0; else fx = 1;
202         if (fy) fy = 0; else fy = 1;
203         mult = 16;
203204      }
204      else mult=-16;
205      else mult = -16;
205206
206207      while (multi >= 0)
207208      {
r7500r7501
209210               sprite - multi * inc,
210211               colour,
211212               fx,fy,
212               sprite_xoffset+x,sprite_yoffset+ y + mult * multi,15);
213               state->sprite_xoffset + x, state->sprite_yoffset + y + mult * multi, 15);
213214
214215         multi--;
215216      }
r7500r7501
220221
221222WRITE16_HANDLER( bcstory_tilebank_w )
222223{
223   bcstory_tilebank = data;
224   tilemap_mark_all_tiles_dirty(pf1_tilemap);
225   tilemap_mark_all_tiles_dirty(pf1_alt_tilemap);
226   tilemap_mark_all_tiles_dirty(pf2_tilemap);
224   tumbleb_state *state = (tumbleb_state *)space->machine->driver_data;
225
226   state->tilebank = data;
227   tilemap_mark_all_tiles_dirty(state->pf1_tilemap);
228   tilemap_mark_all_tiles_dirty(state->pf1_alt_tilemap);
229   tilemap_mark_all_tiles_dirty(state->pf2_tilemap);
227230}
228231
229232WRITE16_HANDLER( chokchok_tilebank_w )
230233{
231   bcstory_tilebank = data<<1;
232   tilemap_mark_all_tiles_dirty(pf1_tilemap);
233   tilemap_mark_all_tiles_dirty(pf1_alt_tilemap);
234   tilemap_mark_all_tiles_dirty(pf2_tilemap);
234   tumbleb_state *state = (tumbleb_state *)space->machine->driver_data;
235
236   state->tilebank = data << 1;
237   tilemap_mark_all_tiles_dirty(state->pf1_tilemap);
238   tilemap_mark_all_tiles_dirty(state->pf1_alt_tilemap);
239   tilemap_mark_all_tiles_dirty(state->pf2_tilemap);
235240}
236241
237242WRITE16_HANDLER( wlstar_tilebank_w )
238243{
244   tumbleb_state *state = (tumbleb_state *)space->machine->driver_data;
245
239246   /* it just writes 0000 or ffff */
240   bcstory_tilebank = data&0x4000;
241   tilemap_mark_all_tiles_dirty(pf1_tilemap);
242   tilemap_mark_all_tiles_dirty(pf1_alt_tilemap);
243   tilemap_mark_all_tiles_dirty(pf2_tilemap);
247   state->tilebank = data & 0x4000;
248   tilemap_mark_all_tiles_dirty(state->pf1_tilemap);
249   tilemap_mark_all_tiles_dirty(state->pf1_alt_tilemap);
250   tilemap_mark_all_tiles_dirty(state->pf2_tilemap);
244251}
245252
246253
247254WRITE16_HANDLER( suprtrio_tilebank_w )
248255{
249   bcstory_tilebank = data<<14; // shift it here, makes using bcstory_tilebank easier
250   tilemap_mark_all_tiles_dirty(pf1_tilemap);
251   tilemap_mark_all_tiles_dirty(pf1_alt_tilemap);
252   tilemap_mark_all_tiles_dirty(pf2_tilemap);
256   tumbleb_state *state = (tumbleb_state *)space->machine->driver_data;
257
258   state->tilebank = data << 14; // shift it here, makes using bcstory_tilebank easier
259   tilemap_mark_all_tiles_dirty(state->pf1_tilemap);
260   tilemap_mark_all_tiles_dirty(state->pf1_alt_tilemap);
261   tilemap_mark_all_tiles_dirty(state->pf2_tilemap);
253262}
254263
255264
256
257
258
259265WRITE16_HANDLER( tumblepb_pf1_data_w )
260266{
261   COMBINE_DATA(&tumblepb_pf1_data[offset]);
262   tilemap_mark_tile_dirty(pf1_tilemap,offset);
263   tilemap_mark_tile_dirty(pf1_alt_tilemap,offset);
267   tumbleb_state *state = (tumbleb_state *)space->machine->driver_data;
268
269   COMBINE_DATA(&state->pf1_data[offset]);
270   tilemap_mark_tile_dirty(state->pf1_tilemap, offset);
271   tilemap_mark_tile_dirty(state->pf1_alt_tilemap, offset);
264272}
265273
266274WRITE16_HANDLER( tumblepb_pf2_data_w )
267275{
268   COMBINE_DATA(&tumblepb_pf2_data[offset]);
269   tilemap_mark_tile_dirty(pf2_tilemap,offset);
276   tumbleb_state *state = (tumbleb_state *)space->machine->driver_data;
270277
271   if (pf2_alt_tilemap)
272      tilemap_mark_tile_dirty(pf2_alt_tilemap,offset);
278   COMBINE_DATA(&state->pf2_data[offset]);
279   tilemap_mark_tile_dirty(state->pf2_tilemap, offset);
280
281   if (state->pf2_alt_tilemap)
282      tilemap_mark_tile_dirty(state->pf2_alt_tilemap, offset);
273283}
274284
275285WRITE16_HANDLER( fncywld_pf1_data_w )
276286{
277   COMBINE_DATA(&tumblepb_pf1_data[offset]);
278   tilemap_mark_tile_dirty(pf1_tilemap,offset/2);
279   tilemap_mark_tile_dirty(pf1_alt_tilemap,offset/2);
287   tumbleb_state *state = (tumbleb_state *)space->machine->driver_data;
288
289   COMBINE_DATA(&state->pf1_data[offset]);
290   tilemap_mark_tile_dirty(state->pf1_tilemap, offset / 2);
291   tilemap_mark_tile_dirty(state->pf1_alt_tilemap, offset / 2);
280292}
281293
282294WRITE16_HANDLER( fncywld_pf2_data_w )
283295{
284   COMBINE_DATA(&tumblepb_pf2_data[offset]);
285   tilemap_mark_tile_dirty(pf2_tilemap,offset/2);
296   tumbleb_state *state = (tumbleb_state *)space->machine->driver_data;
297
298   COMBINE_DATA(&state->pf2_data[offset]);
299   tilemap_mark_tile_dirty(state->pf2_tilemap, offset / 2);
286300}
287301
288302WRITE16_HANDLER( tumblepb_control_0_w )
289303{
290   COMBINE_DATA(&tumblepb_control_0[offset]);
304   tumbleb_state *state = (tumbleb_state *)space->machine->driver_data;
305   COMBINE_DATA(&state->control_0[offset]);
291306}
292307
308
309WRITE16_HANDLER( pangpang_pf1_data_w )
310{
311   tumbleb_state *state = (tumbleb_state *)space->machine->driver_data;
312
313   COMBINE_DATA(&state->pf1_data[offset]);
314   tilemap_mark_tile_dirty(state->pf1_tilemap, offset / 2);
315   tilemap_mark_tile_dirty(state->pf1_alt_tilemap, offset / 2);
316}
317
318WRITE16_HANDLER( pangpang_pf2_data_w )
319{
320   tumbleb_state *state = (tumbleb_state *)space->machine->driver_data;
321
322   COMBINE_DATA(&state->pf2_data[offset]);
323   tilemap_mark_tile_dirty(state->pf2_tilemap, offset / 2);
324
325   if (state->pf2_alt_tilemap)
326      tilemap_mark_tile_dirty(state->pf2_alt_tilemap, offset / 2);
327}
328
293329/******************************************************************************/
294330
295331static TILEMAP_MAPPER( tumblep_scan )
r7500r7501
298334   return (col & 0x1f) + ((row & 0x1f) << 5) + ((col & 0x60) << 5);
299335}
300336
301INLINE void get_bg_tile_info(running_machine *machine,tile_data *tileinfo,int tile_index,int gfx_bank,UINT16 *gfx_base)
337INLINE void get_bg_tile_info( running_machine *machine, tile_data *tileinfo, int tile_index, int gfx_bank, UINT16 *gfx_base)
302338{
339   tumbleb_state *state = (tumbleb_state *)machine->driver_data;
303340   int data = gfx_base[tile_index];
304341
305342   SET_TILE_INFO(
306343         gfx_bank,
307         (data & 0x0fff)|(bcstory_tilebank>>2),
344         (data & 0x0fff) | (state->tilebank >> 2),
308345         data >> 12,
309346         0);
310347}
311348
312static TILE_GET_INFO( get_bg1_tile_info ) { get_bg_tile_info(machine,tileinfo,tile_index,2,tumblepb_pf1_data); }
313static TILE_GET_INFO( get_bg2_tile_info ) { get_bg_tile_info(machine,tileinfo,tile_index,1,tumblepb_pf2_data); }
349static TILE_GET_INFO( get_bg1_tile_info ) { tumbleb_state *state = (tumbleb_state *)machine->driver_data;   get_bg_tile_info(machine, tileinfo, tile_index, 2, state->pf1_data); }
350static TILE_GET_INFO( get_bg2_tile_info ) { tumbleb_state *state = (tumbleb_state *)machine->driver_data;   get_bg_tile_info(machine, tileinfo, tile_index, 1, state->pf2_data); }
314351
315352static TILE_GET_INFO( get_fg_tile_info )
316353{
317   int data = tumblepb_pf1_data[tile_index];
354   tumbleb_state *state = (tumbleb_state *)machine->driver_data;
355   int data = state->pf1_data[tile_index];
318356
319357   SET_TILE_INFO(
320358         0,
321         (data & 0x0fff)|bcstory_tilebank,
359         (data & 0x0fff) | state->tilebank,
322360         data >> 12,
323361         0);
324362}
325363
326INLINE void get_fncywld_bg_tile_info(running_machine *machine,tile_data *tileinfo,int tile_index,int gfx_bank,UINT16 *gfx_base)
364INLINE void get_fncywld_bg_tile_info( running_machine *machine, tile_data *tileinfo, int tile_index, int gfx_bank, UINT16 *gfx_base)
327365{
328   int data = gfx_base[tile_index*2];
329   int attr = gfx_base[tile_index*2+1];
366   int data = gfx_base[tile_index * 2];
367   int attr = gfx_base[tile_index * 2 + 1];
330368
331369   SET_TILE_INFO(
332370         gfx_bank,
r7500r7501
335373         0);
336374}
337375
338static TILE_GET_INFO( get_fncywld_bg1_tile_info ) { get_fncywld_bg_tile_info(machine,tileinfo,tile_index,2,tumblepb_pf1_data); }
339static TILE_GET_INFO( get_fncywld_bg2_tile_info ) { get_fncywld_bg_tile_info(machine,tileinfo,tile_index,1,tumblepb_pf2_data); }
376static TILE_GET_INFO( get_fncywld_bg1_tile_info ) { tumbleb_state *state = (tumbleb_state *)machine->driver_data;   get_fncywld_bg_tile_info(machine, tileinfo, tile_index, 2, state->pf1_data); }
377static TILE_GET_INFO( get_fncywld_bg2_tile_info ) { tumbleb_state *state = (tumbleb_state *)machine->driver_data;   get_fncywld_bg_tile_info(machine, tileinfo, tile_index, 1, state->pf2_data); }
340378
341379static TILE_GET_INFO( get_fncywld_fg_tile_info )
342380{
343   int data = tumblepb_pf1_data[tile_index*2];
344   int attr = tumblepb_pf1_data[tile_index*2+1];
381   tumbleb_state *state = (tumbleb_state *)machine->driver_data;
382   int data = state->pf1_data[tile_index * 2];
383   int attr = state->pf1_data[tile_index * 2 + 1];
345384
346385   SET_TILE_INFO(
347386         0,
r7500r7501
354393/* jump pop */
355394static TILE_GET_INFO( get_jumppop_bg1_tile_info )
356395{
357   int data = tumblepb_pf1_data[tile_index];
396   tumbleb_state *state = (tumbleb_state *)machine->driver_data;
397   int data = state->pf1_data[tile_index];
358398
359399   SET_TILE_INFO(
360400         2,
r7500r7501
365405
366406static TILE_GET_INFO( get_jumppop_bg2_tile_info )
367407{
368   int data = tumblepb_pf2_data[tile_index];
408   tumbleb_state *state = (tumbleb_state *)machine->driver_data;
409   int data = state->pf2_data[tile_index];
369410
370411   SET_TILE_INFO(
371412         1,
r7500r7501
376417
377418static TILE_GET_INFO( get_jumppop_bg2_alt_tile_info )
378419{
379   int data = tumblepb_pf2_data[tile_index];
420   tumbleb_state *state = (tumbleb_state *)machine->driver_data;
421   int data = state->pf2_data[tile_index];
380422
381423   SET_TILE_INFO(
382424         0,
r7500r7501
388430
389431static TILE_GET_INFO( get_jumppop_fg_tile_info )
390432{
391   int data = tumblepb_pf1_data[tile_index];
433   tumbleb_state *state = (tumbleb_state *)machine->driver_data;
434   int data = state->pf1_data[tile_index];
392435
393436   SET_TILE_INFO(
394437         0,
r7500r7501
397440         0);
398441}
399442
400
401WRITE16_HANDLER( pangpang_pf1_data_w )
443INLINE void pangpang_get_bg_tile_info( running_machine *machine, tile_data *tileinfo, int tile_index, int gfx_bank, UINT16 *gfx_base )
402444{
403   COMBINE_DATA(&tumblepb_pf1_data[offset]);
404   tilemap_mark_tile_dirty(pf1_tilemap,offset/2);
405   tilemap_mark_tile_dirty(pf1_alt_tilemap,offset/2);
406}
445   int data = gfx_base[tile_index * 2 + 1];
446   int attr = gfx_base[tile_index * 2];
407447
408WRITE16_HANDLER( pangpang_pf2_data_w )
409{
410   COMBINE_DATA(&tumblepb_pf2_data[offset]);
411   tilemap_mark_tile_dirty(pf2_tilemap,offset/2);
412
413   if (pf2_alt_tilemap)
414      tilemap_mark_tile_dirty(pf2_alt_tilemap,offset/2);
415}
416
417
418
419INLINE void pangpang_get_bg_tile_info(running_machine *machine, tile_data *tileinfo, int tile_index,int gfx_bank,UINT16 *gfx_base)
420{
421   int data = gfx_base[tile_index*2+1];
422   int attr = gfx_base[tile_index*2];
423
424448   SET_TILE_INFO(
425449         gfx_bank,
426450         data & 0x1fff,
r7500r7501
428452         0);
429453}
430454
431INLINE void pangpang_get_bg2x_tile_info(running_machine *machine, tile_data *tileinfo, int tile_index,int gfx_bank,UINT16 *gfx_base)
455INLINE void pangpang_get_bg2x_tile_info( running_machine *machine, tile_data *tileinfo, int tile_index, int gfx_bank, UINT16 *gfx_base )
432456{
433   int data = gfx_base[tile_index*2+1];
434   int attr = gfx_base[tile_index*2];
457   int data = gfx_base[tile_index * 2 + 1];
458   int attr = gfx_base[tile_index * 2];
435459
436460   SET_TILE_INFO(
437461         gfx_bank,
438         (data & 0xfff)+0x1000,
462         (data & 0xfff) + 0x1000,
439463         (attr >>12) & 0xf,
440464         0);
441465}
442466
443467
444static TILE_GET_INFO( pangpang_get_bg1_tile_info ) { pangpang_get_bg_tile_info(machine,tileinfo,tile_index,2,tumblepb_pf1_data); }
445static TILE_GET_INFO( pangpang_get_bg2_tile_info ) { pangpang_get_bg2x_tile_info(machine,tileinfo,tile_index,1,tumblepb_pf2_data); }
468static TILE_GET_INFO( pangpang_get_bg1_tile_info ) { tumbleb_state *state = (tumbleb_state *)machine->driver_data;   pangpang_get_bg_tile_info(machine, tileinfo, tile_index, 2, state->pf1_data); }
469static TILE_GET_INFO( pangpang_get_bg2_tile_info ) { tumbleb_state *state = (tumbleb_state *)machine->driver_data;   pangpang_get_bg2x_tile_info(machine, tileinfo, tile_index, 1, state->pf2_data); }
446470
447471static TILE_GET_INFO( pangpang_get_fg_tile_info )
448472{
449   int data = tumblepb_pf1_data[tile_index*2+1];
450   int attr = tumblepb_pf1_data[tile_index*2];
473   tumbleb_state *state = (tumbleb_state *)machine->driver_data;
474   int data = state->pf1_data[tile_index * 2 + 1];
475   int attr = state->pf1_data[tile_index * 2];
451476
452477   SET_TILE_INFO(
453478         0,
r7500r7501
457482}
458483
459484
485static STATE_POSTLOAD( tumbleb_tilemap_redraw )
486{
487   tumbleb_state *state = (tumbleb_state *)machine->driver_data;
488
489   tilemap_mark_all_tiles_dirty(state->pf1_tilemap);
490   tilemap_mark_all_tiles_dirty(state->pf1_alt_tilemap);
491   tilemap_mark_all_tiles_dirty(state->pf2_tilemap);
492   if (state->pf2_alt_tilemap)
493      tilemap_mark_all_tiles_dirty(state->pf2_alt_tilemap);
494}
495
460496VIDEO_START( pangpang )
461497{
462   pf1_tilemap =     tilemap_create(machine, pangpang_get_fg_tile_info, tilemap_scan_rows, 8, 8,64,32);
463   pf1_alt_tilemap = tilemap_create(machine, pangpang_get_bg1_tile_info,tumblep_scan,16,16,64,32);
464   pf2_tilemap =     tilemap_create(machine, pangpang_get_bg2_tile_info,tumblep_scan,     16,16,64,32);
498   tumbleb_state *state = (tumbleb_state *)machine->driver_data;
465499
466   tilemap_set_transparent_pen(pf1_tilemap,0);
467   tilemap_set_transparent_pen(pf1_alt_tilemap,0);
468   bcstory_tilebank = 0;
500   state->pf1_tilemap =     tilemap_create(machine, pangpang_get_fg_tile_info,  tilemap_scan_rows, 8,  8, 64, 32);
501   state->pf1_alt_tilemap = tilemap_create(machine, pangpang_get_bg1_tile_info, tumblep_scan,     16, 16, 64, 32);
502   state->pf2_tilemap =     tilemap_create(machine, pangpang_get_bg2_tile_info, tumblep_scan,     16, 16, 64, 32);
469503
470   sprite_xoffset = -1;
471   sprite_yoffset = 0;
504   tilemap_set_transparent_pen(state->pf1_tilemap, 0);
505   tilemap_set_transparent_pen(state->pf1_alt_tilemap, 0);
506
507   state->sprite_xoffset = -1;
508   state->sprite_yoffset = 0;
509
510   state_save_register_postload(machine, tumbleb_tilemap_redraw, NULL);
472511}
473512
474513
475514VIDEO_START( tumblepb )
476515{
477   pf1_tilemap =     tilemap_create(machine, get_fg_tile_info, tilemap_scan_rows, 8, 8,64,32);
478   pf1_alt_tilemap = tilemap_create(machine, get_bg1_tile_info,tumblep_scan,16,16,64,32);
479   pf2_tilemap =     tilemap_create(machine, get_bg2_tile_info,tumblep_scan,     16,16,64,32);
516   tumbleb_state *state = (tumbleb_state *)machine->driver_data;
480517
481   tilemap_set_transparent_pen(pf1_tilemap,0);
482   tilemap_set_transparent_pen(pf1_alt_tilemap,0);
483   bcstory_tilebank = 0;
518   state->pf1_tilemap =     tilemap_create(machine, get_fg_tile_info,  tilemap_scan_rows, 8,  8, 64, 32);
519   state->pf1_alt_tilemap = tilemap_create(machine, get_bg1_tile_info, tumblep_scan,     16, 16, 64, 32);
520   state->pf2_tilemap =     tilemap_create(machine, get_bg2_tile_info, tumblep_scan,     16, 16, 64, 32);
484521
485   sprite_xoffset = -1;
486   sprite_yoffset = 0;
522   tilemap_set_transparent_pen(state->pf1_tilemap, 0);
523   tilemap_set_transparent_pen(state->pf1_alt_tilemap, 0);
524
525   state->sprite_xoffset = -1;
526   state->sprite_yoffset = 0;
527
528   state_save_register_postload(machine, tumbleb_tilemap_redraw, NULL);
487529}
488530
489531VIDEO_START( sdfight )
490532{
491   pf1_tilemap =     tilemap_create(machine, get_fg_tile_info, tilemap_scan_rows, 8, 8,64,64); // 64*64 to prevent bad tilemap wrapping? - check real behavior
492   pf1_alt_tilemap = tilemap_create(machine, get_bg1_tile_info,tumblep_scan,16,16,64,32);
493   pf2_tilemap =     tilemap_create(machine, get_bg2_tile_info,tumblep_scan,     16,16,64,32);
533   tumbleb_state *state = (tumbleb_state *)machine->driver_data;
494534
495   tilemap_set_transparent_pen(pf1_tilemap,0);
496   tilemap_set_transparent_pen(pf1_alt_tilemap,0);
497   bcstory_tilebank = 0;
535   state->pf1_tilemap =     tilemap_create(machine, get_fg_tile_info,  tilemap_scan_rows, 8,  8, 64, 64); // 64*64 to prevent bad tilemap wrapping? - check real behavior
536   state->pf1_alt_tilemap = tilemap_create(machine, get_bg1_tile_info, tumblep_scan,     16, 16, 64, 32);
537   state->pf2_tilemap =     tilemap_create(machine, get_bg2_tile_info, tumblep_scan,     16, 16, 64, 32);
498538
539   tilemap_set_transparent_pen(state->pf1_tilemap, 0);
540   tilemap_set_transparent_pen(state->pf1_alt_tilemap, 0);
541
499542   /* aligned to monitor test */
500   sprite_xoffset = 0;
501   sprite_yoffset = 1;
543   state->sprite_xoffset = 0;
544   state->sprite_yoffset = 1;
545
546   state_save_register_postload(machine, tumbleb_tilemap_redraw, NULL);
502547}
503548
504549VIDEO_START( fncywld )
505550{
506   pf1_tilemap =     tilemap_create(machine, get_fncywld_fg_tile_info, tilemap_scan_rows, 8, 8,64,32);
507   pf1_alt_tilemap = tilemap_create(machine, get_fncywld_bg1_tile_info,tumblep_scan,16,16,64,32);
508   pf2_tilemap =     tilemap_create(machine, get_fncywld_bg2_tile_info,tumblep_scan,     16,16,64,32);
551   tumbleb_state *state = (tumbleb_state *)machine->driver_data;
509552
510   tilemap_set_transparent_pen(pf1_tilemap,15);
511   tilemap_set_transparent_pen(pf1_alt_tilemap,15);
512   bcstory_tilebank = 0;
553   state->pf1_tilemap =     tilemap_create(machine, get_fncywld_fg_tile_info,  tilemap_scan_rows, 8,  8, 64, 32);
554   state->pf1_alt_tilemap = tilemap_create(machine, get_fncywld_bg1_tile_info, tumblep_scan,     16, 16, 64, 32);
555   state->pf2_tilemap =     tilemap_create(machine, get_fncywld_bg2_tile_info, tumblep_scan,     16, 16, 64, 32);
513556
514   sprite_xoffset = -1;
515   sprite_yoffset = 0;
557   tilemap_set_transparent_pen(state->pf1_tilemap, 15);
558   tilemap_set_transparent_pen(state->pf1_alt_tilemap, 15);
559
560   state->sprite_xoffset = -1;
561   state->sprite_yoffset = 0;
562
563   state_save_register_postload(machine, tumbleb_tilemap_redraw, NULL);
516564}
517565
518566VIDEO_START( jumppop )
519567{
520   pf1_tilemap =     tilemap_create(machine, get_jumppop_fg_tile_info, tilemap_scan_rows, 8, 8,128,64);
521   pf1_alt_tilemap = tilemap_create(machine, get_jumppop_bg1_tile_info,tilemap_scan_rows,16,16,64,64);
522   pf2_tilemap =     tilemap_create(machine, get_jumppop_bg2_tile_info,tilemap_scan_rows,     16,16,64,64);
523   pf2_alt_tilemap =     tilemap_create(machine, get_jumppop_bg2_alt_tile_info,tilemap_scan_rows,     8,8,128,64);
568   tumbleb_state *state = (tumbleb_state *)machine->driver_data;
524569
525   tilemap_set_transparent_pen(pf1_tilemap,0);
526   tilemap_set_transparent_pen(pf1_alt_tilemap,0);
570   state->pf1_tilemap =     tilemap_create(machine, get_jumppop_fg_tile_info,      tilemap_scan_rows,     8,  8, 128, 64);
571   state->pf1_alt_tilemap = tilemap_create(machine, get_jumppop_bg1_tile_info,     tilemap_scan_rows,    16, 16,  64, 64);
572   state->pf2_tilemap =     tilemap_create(machine, get_jumppop_bg2_tile_info,     tilemap_scan_rows,    16, 16,  64, 64);
573   state->pf2_alt_tilemap = tilemap_create(machine, get_jumppop_bg2_alt_tile_info, tilemap_scan_rows,     8,  8, 128, 64);
527574
528   tilemap_set_flip(pf1_tilemap, TILEMAP_FLIPX);
529   tilemap_set_flip(pf1_alt_tilemap, TILEMAP_FLIPX);
530   tilemap_set_flip(pf2_tilemap, TILEMAP_FLIPX);
531   tilemap_set_flip(pf2_alt_tilemap, TILEMAP_FLIPX);
532   bcstory_tilebank = 0;
575   tilemap_set_transparent_pen(state->pf1_tilemap, 0);
576   tilemap_set_transparent_pen(state->pf1_alt_tilemap, 0);
533577
534   sprite_xoffset = -1;
535   sprite_yoffset = 0;
578   tilemap_set_flip(state->pf1_tilemap, TILEMAP_FLIPX);
579   tilemap_set_flip(state->pf1_alt_tilemap, TILEMAP_FLIPX);
580   tilemap_set_flip(state->pf2_tilemap, TILEMAP_FLIPX);
581   tilemap_set_flip(state->pf2_alt_tilemap, TILEMAP_FLIPX);
582
583   state->sprite_xoffset = -1;
584   state->sprite_yoffset = 0;
585
586   state_save_register_postload(machine, tumbleb_tilemap_redraw, NULL);
536587}
537588
538589
590VIDEO_START( suprtrio )
591{
592   tumbleb_state *state = (tumbleb_state *)machine->driver_data;
593
594   state->pf1_tilemap =     tilemap_create(machine, get_fg_tile_info,  tilemap_scan_rows, 8,  8, 64, 32);
595   state->pf1_alt_tilemap = tilemap_create(machine, get_bg1_tile_info, tumblep_scan,     16, 16, 64, 32);
596   state->pf2_tilemap =     tilemap_create(machine, get_bg2_tile_info, tumblep_scan,     16, 16, 64, 32);
597
598   tilemap_set_transparent_pen(state->pf1_alt_tilemap, 0);
599
600   state_save_register_postload(machine, tumbleb_tilemap_redraw, NULL);
601}
602
539603/******************************************************************************/
540604
541605
542606VIDEO_UPDATE( tumblepb )
543607{
544   int offs,offs2;
608   tumbleb_state *state = (tumbleb_state *)screen->machine->driver_data;
609   int offs, offs2;
545610
546   flipscreen=tumblepb_control_0[0]&0x80;
547   tilemap_set_flip_all(screen->machine,flipscreen ? (TILEMAP_FLIPY | TILEMAP_FLIPX) : 0);
548   if (flipscreen) offs=1; else offs=-1;
549   if (flipscreen) offs2=-3; else offs2=-5;
611   state->flipscreen = state->control_0[0] & 0x80;
612   tilemap_set_flip_all(screen->machine, state->flipscreen ? (TILEMAP_FLIPY | TILEMAP_FLIPX) : 0);
550613
551   tilemap_set_scrollx( pf1_tilemap,0, tumblepb_control_0[1]+offs2 );
552   tilemap_set_scrolly( pf1_tilemap,0, tumblepb_control_0[2] );
553   tilemap_set_scrollx( pf1_alt_tilemap,0, tumblepb_control_0[1]+offs2 );
554   tilemap_set_scrolly( pf1_alt_tilemap,0, tumblepb_control_0[2] );
555   tilemap_set_scrollx( pf2_tilemap,0, tumblepb_control_0[3]+offs );
556   tilemap_set_scrolly( pf2_tilemap,0, tumblepb_control_0[4] );
614   if (state->flipscreen)
615      offs = 1;
616   else
617      offs = -1;
557618
558   tilemap_draw(bitmap,cliprect,pf2_tilemap,0,0);
559   if (tumblepb_control_0[6]&0x80)
560      tilemap_draw(bitmap,cliprect,pf1_tilemap,0,0);
619   if (state->flipscreen)
620      offs2 = -3;
561621   else
562      tilemap_draw(bitmap,cliprect,pf1_alt_tilemap,0,0);
563   tumblepb_draw_sprites(screen->machine,bitmap,cliprect);
622      offs2 = -5;
623
624   tilemap_set_scrollx(state->pf1_tilemap,     0, state->control_0[1] + offs2);
625   tilemap_set_scrolly(state->pf1_tilemap,     0, state->control_0[2]);
626   tilemap_set_scrollx(state->pf1_alt_tilemap, 0, state->control_0[1] + offs2);
627   tilemap_set_scrolly(state->pf1_alt_tilemap, 0, state->control_0[2]);
628   tilemap_set_scrollx(state->pf2_tilemap,     0, state->control_0[3] + offs);
629   tilemap_set_scrolly(state->pf2_tilemap,     0, state->control_0[4]);
630
631   tilemap_draw(bitmap, cliprect, state->pf2_tilemap, 0, 0);
632
633   if (state->control_0[6] & 0x80)
634      tilemap_draw(bitmap, cliprect, state->pf1_tilemap, 0, 0);
635   else
636      tilemap_draw(bitmap, cliprect, state->pf1_alt_tilemap, 0, 0);
637
638   tumblepb_draw_sprites(screen->machine, bitmap, cliprect);
564639   return 0;
565640}
566641
567642VIDEO_UPDATE( jumpkids )
568643{
569   int offs,offs2;
644   tumbleb_state *state = (tumbleb_state *)screen->machine->driver_data;
645   int offs, offs2;
570646
571   flipscreen=tumblepb_control_0[0]&0x80;
572   tilemap_set_flip_all(screen->machine,flipscreen ? (TILEMAP_FLIPY | TILEMAP_FLIPX) : 0);
573   if (flipscreen) offs=1; else offs=-1;
574   if (flipscreen) offs2=-3; else offs2=-5;
647   state->flipscreen = state->control_0[0] & 0x80;
648   tilemap_set_flip_all(screen->machine, state->flipscreen ? (TILEMAP_FLIPY | TILEMAP_FLIPX) : 0);
575649
576   tilemap_set_scrollx( pf1_tilemap,0, tumblepb_control_0[1]+offs2 );
577   tilemap_set_scrolly( pf1_tilemap,0, tumblepb_control_0[2] );
578   tilemap_set_scrollx( pf1_alt_tilemap,0, tumblepb_control_0[1]+offs2 );
579   tilemap_set_scrolly( pf1_alt_tilemap,0, tumblepb_control_0[2] );
580   tilemap_set_scrollx( pf2_tilemap,0, tumblepb_control_0[3]+offs );
581   tilemap_set_scrolly( pf2_tilemap,0, tumblepb_control_0[4] );
650   if (state->flipscreen)
651      offs = 1;
652   else
653      offs = -1;
582654
583   tilemap_draw(bitmap,cliprect,pf2_tilemap,0,0);
584   if (tumblepb_control_0[6]&0x80)
585      tilemap_draw(bitmap,cliprect,pf1_tilemap,0,0);
655   if (state->flipscreen)
656      offs2 = -3;
586657   else
587      tilemap_draw(bitmap,cliprect,pf1_alt_tilemap,0,0);
588   jumpkids_draw_sprites(screen->machine,bitmap,cliprect);
658      offs2 = -5;
659
660   tilemap_set_scrollx(state->pf1_tilemap,     0, state->control_0[1] + offs2);
661   tilemap_set_scrolly(state->pf1_tilemap,     0, state->control_0[2]);
662   tilemap_set_scrollx(state->pf1_alt_tilemap, 0, state->control_0[1] + offs2);
663   tilemap_set_scrolly(state->pf1_alt_tilemap, 0, state->control_0[2]);
664   tilemap_set_scrollx(state->pf2_tilemap,     0, state->control_0[3] + offs);
665   tilemap_set_scrolly(state->pf2_tilemap,     0, state->control_0[4]);
666
667   tilemap_draw(bitmap, cliprect, state->pf2_tilemap, 0, 0);
668
669   if (state->control_0[6] & 0x80)
670      tilemap_draw(bitmap, cliprect, state->pf1_tilemap, 0, 0);
671   else
672      tilemap_draw(bitmap, cliprect, state->pf1_alt_tilemap, 0, 0);
673
674   jumpkids_draw_sprites(screen->machine, bitmap, cliprect);
589675   return 0;
590676}
591677
592678VIDEO_UPDATE( semicom )
593679{
594   int offs,offs2;
680   tumbleb_state *state = (tumbleb_state *)screen->machine->driver_data;
681   int offs, offs2;
595682
596   flipscreen=tumblepb_control_0[0]&0x80;
597   tilemap_set_flip_all(screen->machine,flipscreen ? (TILEMAP_FLIPY | TILEMAP_FLIPX) : 0);
598   if (flipscreen) offs=1; else offs=-1;   /* fixed */
599   if (flipscreen) offs2=-3; else offs2=-5;   /* fixed */
683   state->flipscreen = state->control_0[0] & 0x80;
684   tilemap_set_flip_all(screen->machine, state->flipscreen ? (TILEMAP_FLIPY | TILEMAP_FLIPX) : 0);
600685
601   tilemap_set_scrollx( pf1_tilemap,0, tumblepb_control_0[1]+offs2 );
602   tilemap_set_scrolly( pf1_tilemap,0, tumblepb_control_0[2] );
603   tilemap_set_scrollx( pf1_alt_tilemap,0, tumblepb_control_0[1]+offs2 );
604   tilemap_set_scrolly( pf1_alt_tilemap,0, tumblepb_control_0[2] );
605   tilemap_set_scrollx( pf2_tilemap,0, tumblepb_control_0[3]+offs );
606   tilemap_set_scrolly( pf2_tilemap,0, tumblepb_control_0[4] );
686   if (state->flipscreen)
687      offs = 1;
688   else
689      offs = -1;
607690
608   tilemap_draw(bitmap,cliprect,pf2_tilemap,0,0);
609   if (tumblepb_control_0[6]&0x80)
610      tilemap_draw(bitmap,cliprect,pf1_tilemap,0,0);
691   if (state->flipscreen)
692      offs2 = -3;
611693   else
612      tilemap_draw(bitmap,cliprect,pf1_alt_tilemap,0,0);
613   jumpkids_draw_sprites(screen->machine,bitmap,cliprect);
694      offs2 = -5;
695
696   tilemap_set_scrollx(state->pf1_tilemap,     0, state->control_0[1] + offs2);
697   tilemap_set_scrolly(state->pf1_tilemap,     0, state->control_0[2]);
698   tilemap_set_scrollx(state->pf1_alt_tilemap, 0, state->control_0[1] + offs2);
699   tilemap_set_scrolly(state->pf1_alt_tilemap, 0, state->control_0[2]);
700   tilemap_set_scrollx(state->pf2_tilemap,     0, state->control_0[3] + offs);
701   tilemap_set_scrolly(state->pf2_tilemap,     0, state->control_0[4]);
702
703   tilemap_draw(bitmap, cliprect, state->pf2_tilemap, 0, 0);
704
705   if (state->control_0[6] & 0x80)
706      tilemap_draw(bitmap, cliprect, state->pf1_tilemap, 0, 0);
707   else
708      tilemap_draw(bitmap, cliprect, state->pf1_alt_tilemap, 0, 0);
709
710   jumpkids_draw_sprites(screen->machine, bitmap, cliprect);
614711   return 0;
615712}
616713
617714VIDEO_UPDATE( semicom_altoffsets )
618715{
619   int offsx,offsy,offsx2;
716   tumbleb_state *state = (tumbleb_state *)screen->machine->driver_data;
717   int offsx, offsy, offsx2;
620718
621   flipscreen=tumblepb_control_0[0]&0x80;
719   state->flipscreen = state->control_0[0] & 0x80;
622720
623721   offsx = -1;
624722   offsy = 2;
625723   offsx2 = -5;
626724
627   tilemap_set_scrollx( pf1_tilemap,0, tumblepb_control_0[1]+offsx2 );
628   tilemap_set_scrolly( pf1_tilemap,0, tumblepb_control_0[2] );
629   tilemap_set_scrollx( pf1_alt_tilemap,0, tumblepb_control_0[1]+offsx2 );
630   tilemap_set_scrolly( pf1_alt_tilemap,0, tumblepb_control_0[2] );
631   tilemap_set_scrollx( pf2_tilemap,0, tumblepb_control_0[3]+offsx );
632   tilemap_set_scrolly( pf2_tilemap,0, tumblepb_control_0[4]+offsy );
725   tilemap_set_scrollx(state->pf1_tilemap,     0, state->control_0[1] + offsx2);
726   tilemap_set_scrolly(state->pf1_tilemap,     0, state->control_0[2]);
727   tilemap_set_scrollx(state->pf1_alt_tilemap, 0, state->control_0[1] + offsx2);
728   tilemap_set_scrolly(state->pf1_alt_tilemap, 0, state->control_0[2]);
729   tilemap_set_scrollx(state->pf2_tilemap,     0, state->control_0[3] + offsx);
730   tilemap_set_scrolly(state->pf2_tilemap,     0, state->control_0[4] + offsy);
633731
634   tilemap_draw(bitmap,cliprect,pf2_tilemap,0,0);
635   if (tumblepb_control_0[6]&0x80)
636      tilemap_draw(bitmap,cliprect,pf1_tilemap,0,0);
732   tilemap_draw(bitmap, cliprect, state->pf2_tilemap, 0, 0);
733
734   if (state->control_0[6] & 0x80)
735      tilemap_draw(bitmap, cliprect, state->pf1_tilemap, 0, 0);
637736   else
638      tilemap_draw(bitmap,cliprect,pf1_alt_tilemap,0,0);
639   jumpkids_draw_sprites(screen->machine,bitmap,cliprect);
737      tilemap_draw(bitmap, cliprect, state->pf1_alt_tilemap, 0, 0);
738
739   jumpkids_draw_sprites(screen->machine, bitmap, cliprect);
640740   return 0;
641741}
642742
643743VIDEO_UPDATE( bcstory )
644744{
645   int offs,offs2;
745   tumbleb_state *state = (tumbleb_state *)screen->machine->driver_data;
746   int offs, offs2;
646747
647   flipscreen=tumblepb_control_0[0]&0x80;
648   tilemap_set_flip_all(screen->machine,flipscreen ? (TILEMAP_FLIPY | TILEMAP_FLIPX) : 0);
649   if (flipscreen) offs=1; else offs=8;   /* not sure of this */
650   if (flipscreen) offs2=-3; else offs2=8;   /* not sure of this */
748   state->flipscreen = state->control_0[0] & 0x80;
749   tilemap_set_flip_all(screen->machine, state->flipscreen ? (TILEMAP_FLIPY | TILEMAP_FLIPX) : 0);
651750
652   tilemap_set_scrollx( pf1_tilemap,0, tumblepb_control_0[1]+offs2 );
653   tilemap_set_scrolly( pf1_tilemap,0, tumblepb_control_0[2] );
654   tilemap_set_scrollx( pf1_alt_tilemap,0, tumblepb_control_0[1]+offs2 );
655   tilemap_set_scrolly( pf1_alt_tilemap,0, tumblepb_control_0[2] );
656   tilemap_set_scrollx( pf2_tilemap,0, tumblepb_control_0[3]+offs );
657   tilemap_set_scrolly( pf2_tilemap,0, tumblepb_control_0[4] );
751   /* not sure of this */
752   if (state->flipscreen)
753      offs = 1;
754   else
755      offs = 8;
658756
659   tilemap_draw(bitmap,cliprect,pf2_tilemap,0,0);
660   if (tumblepb_control_0[6]&0x80)
661      tilemap_draw(bitmap,cliprect,pf1_tilemap,0,0);
757   /* not sure of this */
758   if (state->flipscreen)
759      offs2 = -3;
662760   else
663      tilemap_draw(bitmap,cliprect,pf1_alt_tilemap,0,0);
664   jumpkids_draw_sprites(screen->machine,bitmap,cliprect);
761      offs2 = 8;
762
763   tilemap_set_scrollx(state->pf1_tilemap,     0, state->control_0[1] + offs2);
764   tilemap_set_scrolly(state->pf1_tilemap,     0, state->control_0[2]);
765   tilemap_set_scrollx(state->pf1_alt_tilemap, 0, state->control_0[1] + offs2);
766   tilemap_set_scrolly(state->pf1_alt_tilemap, 0, state->control_0[2]);
767   tilemap_set_scrollx(state->pf2_tilemap,     0, state->control_0[3] + offs);
768   tilemap_set_scrolly(state->pf2_tilemap,     0, state->control_0[4]);
769
770   tilemap_draw(bitmap, cliprect, state->pf2_tilemap, 0, 0);
771
772   if (state->control_0[6] & 0x80)
773      tilemap_draw(bitmap, cliprect, state->pf1_tilemap, 0, 0);
774   else
775      tilemap_draw(bitmap, cliprect, state->pf1_alt_tilemap, 0, 0);
776
777   jumpkids_draw_sprites(screen->machine, bitmap, cliprect);
665778   return 0;
666779}
667780
668781VIDEO_UPDATE( semibase )
669782{
670   int offs,offs2;
783   tumbleb_state *state = (tumbleb_state *)screen->machine->driver_data;
784   int offs, offs2;
671785
672   flipscreen=tumblepb_control_0[0]&0x80;
673   tilemap_set_flip_all(screen->machine,flipscreen ? (TILEMAP_FLIPY | TILEMAP_FLIPX) : 0);
674   offs=-1;
675   offs2=-2;
786   state->flipscreen = state->control_0[0] & 0x80;
787   tilemap_set_flip_all(screen->machine, state->flipscreen ? (TILEMAP_FLIPY | TILEMAP_FLIPX) : 0);
788   offs = -1;
789   offs2 = -2;
676790
677791   /* sprites need an offset too */
792   tilemap_set_scrollx(state->pf1_tilemap,     0, state->control_0[1] + offs2);
793   tilemap_set_scrolly(state->pf1_tilemap,     0, state->control_0[2]);
794   tilemap_set_scrollx(state->pf1_alt_tilemap, 0, state->control_0[1] + offs2);
795   tilemap_set_scrolly(state->pf1_alt_tilemap, 0, state->control_0[2]);
796   tilemap_set_scrollx(state->pf2_tilemap,     0, state->control_0[3] + offs);
797   tilemap_set_scrolly(state->pf2_tilemap,     0, state->control_0[4]);
678798
679   tilemap_set_scrollx( pf1_tilemap,0, tumblepb_control_0[1]+offs2 );
680   tilemap_set_scrolly( pf1_tilemap,0, tumblepb_control_0[2] );
681   tilemap_set_scrollx( pf1_alt_tilemap,0, tumblepb_control_0[1]+offs2 );
682   tilemap_set_scrolly( pf1_alt_tilemap,0, tumblepb_control_0[2] );
683   tilemap_set_scrollx( pf2_tilemap,0, tumblepb_control_0[3]+offs );
684   tilemap_set_scrolly( pf2_tilemap,0, tumblepb_control_0[4] );
799   tilemap_draw(bitmap, cliprect, state->pf2_tilemap, 0, 0);
685800
686   tilemap_draw(bitmap,cliprect,pf2_tilemap,0,0);
687   if (tumblepb_control_0[6]&0x80)
688      tilemap_draw(bitmap,cliprect,pf1_tilemap,0,0);
801   if (state->control_0[6] & 0x80)
802      tilemap_draw(bitmap, cliprect, state->pf1_tilemap, 0, 0);
689803   else
690      tilemap_draw(bitmap,cliprect,pf1_alt_tilemap,0,0);
691   jumpkids_draw_sprites(screen->machine,bitmap,cliprect);
804      tilemap_draw(bitmap, cliprect, state->pf1_alt_tilemap, 0, 0);
805
806   jumpkids_draw_sprites(screen->machine, bitmap, cliprect);
692807   return 0;
693808}
694809
695810VIDEO_UPDATE( sdfight )
696811{
697   int offs,offs2;
812   tumbleb_state *state = (tumbleb_state *)screen->machine->driver_data;
813   int offs, offs2;
698814
699   flipscreen=tumblepb_control_0[0]&0x80;
700   tilemap_set_flip_all(screen->machine,flipscreen ? (TILEMAP_FLIPY | TILEMAP_FLIPX) : 0);
701   offs=-1;
702   offs2=-5; // foreground scroll..
815   state->flipscreen = state->control_0[0] & 0x80;
816   tilemap_set_flip_all(screen->machine, state->flipscreen ? (TILEMAP_FLIPY | TILEMAP_FLIPX) : 0);
817   offs = -1;
818   offs2 = -5; // foreground scroll..
703819
704820   /* sprites need an offset too */
821   tilemap_set_scrollx(state->pf1_tilemap,     0, state->control_0[1] + offs2);
822   tilemap_set_scrolly(state->pf1_tilemap,     0, state->control_0[2] - 16); // needed for the ground ...
823   tilemap_set_scrollx(state->pf1_alt_tilemap, 0, state->control_0[1] + offs2);
824   tilemap_set_scrolly(state->pf1_alt_tilemap, 0, state->control_0[2] - 16);
825   tilemap_set_scrollx(state->pf2_tilemap,     0, state->control_0[3] + offs);
826   tilemap_set_scrolly(state->pf2_tilemap,     0, state->control_0[4]);
705827
706   tilemap_set_scrollx( pf1_tilemap,0, tumblepb_control_0[1]+offs2 );
707   tilemap_set_scrolly( pf1_tilemap,0, tumblepb_control_0[2]-16 ); // needed for the ground ...
708   tilemap_set_scrollx( pf1_alt_tilemap,0, tumblepb_control_0[1]+offs2 );
709   tilemap_set_scrolly( pf1_alt_tilemap,0, tumblepb_control_0[2]-16 );
710   tilemap_set_scrollx( pf2_tilemap,0, tumblepb_control_0[3]+offs );
711   tilemap_set_scrolly( pf2_tilemap,0, tumblepb_control_0[4] );
828   tilemap_draw(bitmap, cliprect, state->pf2_tilemap, 0, 0);
829   if (state->control_0[6] & 0x80)
830      tilemap_draw(bitmap, cliprect, state->pf1_tilemap, 0, 0);
831   else
832      tilemap_draw(bitmap, cliprect, state->pf1_alt_tilemap, 0, 0);
712833
713   tilemap_draw(bitmap,cliprect,pf2_tilemap,0,0);
714   if (tumblepb_control_0[6]&0x80)
715      tilemap_draw(bitmap,cliprect,pf1_tilemap,0,0);
716   else
717      tilemap_draw(bitmap,cliprect,pf1_alt_tilemap,0,0);
718   jumpkids_draw_sprites(screen->machine,bitmap,cliprect);
834   jumpkids_draw_sprites(screen->machine, bitmap, cliprect);
719835   return 0;
720836}
721837
r7500r7501
723839
724840VIDEO_UPDATE( fncywld )
725841{
726   int offs,offs2;
842   tumbleb_state *state = (tumbleb_state *)screen->machine->driver_data;
843   int offs, offs2;
727844
728   flipscreen=tumblepb_control_0[0]&0x80;
729   tilemap_set_flip_all(screen->machine,flipscreen ? (TILEMAP_FLIPY | TILEMAP_FLIPX) : 0);
730   if (flipscreen) offs=1; else offs=-1;
731   if (flipscreen) offs2=-3; else offs2=-5;
845   state->flipscreen = state->control_0[0] & 0x80;
846   tilemap_set_flip_all(screen->machine, state->flipscreen ? (TILEMAP_FLIPY | TILEMAP_FLIPX) : 0);
732847
733   tilemap_set_scrollx( pf1_tilemap,0, tumblepb_control_0[1]+offs2 );
734   tilemap_set_scrolly( pf1_tilemap,0, tumblepb_control_0[2] );
735   tilemap_set_scrollx( pf1_alt_tilemap,0, tumblepb_control_0[1]+offs2 );
736   tilemap_set_scrolly( pf1_alt_tilemap,0, tumblepb_control_0[2] );
737   tilemap_set_scrollx( pf2_tilemap,0, tumblepb_control_0[3]+offs );
738   tilemap_set_scrolly( pf2_tilemap,0, tumblepb_control_0[4] );
848   if (state->flipscreen)
849      offs = 1;
850   else
851      offs = -1;
739852
740   tilemap_draw(bitmap,cliprect,pf2_tilemap,0,0);
741   if (tumblepb_control_0[6]&0x80)
742      tilemap_draw(bitmap,cliprect,pf1_tilemap,0,0);
853   if (state->flipscreen)
854      offs2 = -3;
743855   else
744      tilemap_draw(bitmap,cliprect,pf1_alt_tilemap,0,0);
745   fncywld_draw_sprites(screen->machine,bitmap,cliprect);
856      offs2 = -5;
857
858   tilemap_set_scrollx(state->pf1_tilemap,     0, state->control_0[1] + offs2);
859   tilemap_set_scrolly(state->pf1_tilemap,     0, state->control_0[2]);
860   tilemap_set_scrollx(state->pf1_alt_tilemap, 0, state->control_0[1] + offs2);
861   tilemap_set_scrolly(state->pf1_alt_tilemap, 0, state->control_0[2]);
862   tilemap_set_scrollx(state->pf2_tilemap,     0, state->control_0[3] + offs);
863   tilemap_set_scrolly(state->pf2_tilemap,     0, state->control_0[4]);
864
865   tilemap_draw(bitmap, cliprect, state->pf2_tilemap, 0, 0);
866
867   if (state->control_0[6] & 0x80)
868      tilemap_draw(bitmap, cliprect, state->pf1_tilemap, 0, 0);
869   else
870      tilemap_draw(bitmap, cliprect, state->pf1_alt_tilemap, 0, 0);
871
872   fncywld_draw_sprites(screen->machine, bitmap, cliprect);
746873   return 0;
747874}
748875
749876
750877VIDEO_UPDATE( jumppop )
751878{
752//  bitmap_fill(bitmap, cliprect, get_black_pen(screen->machine));
879   tumbleb_state *state = (tumbleb_state *)screen->machine->driver_data;
753880
754   tilemap_set_scrollx( pf1_tilemap,0, jumppop_control[2]-0x3a0 );
755   tilemap_set_scrolly( pf1_tilemap,0, jumppop_control[3] );
756   tilemap_set_scrollx( pf1_alt_tilemap,0, jumppop_control[2]-0x3a0 );
757   tilemap_set_scrolly( pf1_alt_tilemap,0, jumppop_control[3] );
758   tilemap_set_scrollx( pf2_tilemap,0, jumppop_control[0]-0x3a2  );
759   tilemap_set_scrolly( pf2_tilemap,0, jumppop_control[1] );
760   tilemap_set_scrollx( pf2_alt_tilemap,0, jumppop_control[0]-0x3a2 );
761   tilemap_set_scrolly( pf2_alt_tilemap,0, jumppop_control[1] );
881   //  bitmap_fill(bitmap, cliprect, get_black_pen(screen->machine));
762882
763   if (jumppop_control[7]&1)
764      tilemap_draw(bitmap,cliprect,pf2_tilemap,0,0);
883   tilemap_set_scrollx(state->pf1_tilemap, 0, state->control[2] - 0x3a0);
884   tilemap_set_scrolly(state->pf1_tilemap, 0, state->control[3]);
885   tilemap_set_scrollx(state->pf1_alt_tilemap, 0, state->control[2] - 0x3a0);
886   tilemap_set_scrolly(state->pf1_alt_tilemap, 0, state->control[3]);
887   tilemap_set_scrollx(state->pf2_tilemap, 0, state->control[0] - 0x3a2);
888   tilemap_set_scrolly(state->pf2_tilemap, 0, state->control[1]);
889   tilemap_set_scrollx(state->pf2_alt_tilemap, 0, state->control[0] - 0x3a2);
890   tilemap_set_scrolly(state->pf2_alt_tilemap, 0, state->control[1]);
891
892   if (state->control[7] & 1)
893      tilemap_draw(bitmap, cliprect, state->pf2_tilemap, 0, 0);
765894   else
766      tilemap_draw(bitmap,cliprect,pf2_alt_tilemap,0,0);
895      tilemap_draw(bitmap, cliprect, state->pf2_alt_tilemap, 0, 0);
767896
768   if (jumppop_control[7]&2)
769      tilemap_draw(bitmap,cliprect,pf1_alt_tilemap,0,0);
897   if (state->control[7] & 2)
898      tilemap_draw(bitmap, cliprect, state->pf1_alt_tilemap, 0, 0);
770899   else
771      tilemap_draw(bitmap,cliprect,pf1_tilemap,0,0);
900      tilemap_draw(bitmap, cliprect, state->pf1_tilemap, 0, 0);
772901
773//popmessage("%04x %04x %04x %04x %04x %04x %04x %04x", jumppop_control[0],jumppop_control[1],jumppop_control[2],jumppop_control[3],jumppop_control[4],jumppop_control[5],jumppop_control[6],jumppop_control[7]);
902//popmessage("%04x %04x %04x %04x %04x %04x %04x %04x", state->control[0],state->control[1],state->control[2],state->control[3],state->control[4],state->control[5],state->control[6],state->control[7]);
774903
775   jumpkids_draw_sprites(screen->machine,bitmap,cliprect);
904   jumpkids_draw_sprites(screen->machine, bitmap, cliprect);
776905   return 0;
777906}
778907
779908
780909VIDEO_UPDATE( suprtrio )
781910{
782   tilemap_set_scrollx( pf1_alt_tilemap,0, -suprtrio_control[1]-6 );
783   tilemap_set_scrolly( pf1_alt_tilemap,0, -suprtrio_control[2] );
784   tilemap_set_scrollx( pf2_tilemap,0, -suprtrio_control[3]-2 );
785   tilemap_set_scrolly( pf2_tilemap,0, -suprtrio_control[4] );
911   tumbleb_state *state = (tumbleb_state *)screen->machine->driver_data;
786912
787   tilemap_draw(bitmap,cliprect,pf2_tilemap,0,0);
788   tilemap_draw(bitmap,cliprect,pf1_alt_tilemap,0,0);
913   tilemap_set_scrollx(state->pf1_alt_tilemap, 0, -state->control[1] - 6);
914   tilemap_set_scrolly(state->pf1_alt_tilemap, 0, -state->control[2]);
915   tilemap_set_scrollx(state->pf2_tilemap, 0, -state->control[3] - 2);
916   tilemap_set_scrolly(state->pf2_tilemap, 0, -state->control[4]);
789917
790   jumpkids_draw_sprites(screen->machine,bitmap,cliprect);
918   tilemap_draw(bitmap, cliprect, state->pf2_tilemap, 0, 0);
919   tilemap_draw(bitmap, cliprect, state->pf1_alt_tilemap, 0, 0);
920
921   jumpkids_draw_sprites(screen->machine, bitmap, cliprect);
791922#if 0
792923popmessage("%04x %04x %04x %04x %04x %04x %04x %04x",
793 suprtrio_control[0],
794 suprtrio_control[1],
795 suprtrio_control[2],
796 suprtrio_control[3],
797 suprtrio_control[4],
798 suprtrio_control[5],
799 suprtrio_control[6],
800 suprtrio_control[7]);
924 state->control[0],
925 state->control[1],
926 state->control[2],
927 state->control[3],
928 state->control[4],
929 state->control[5],
930 state->control[6],
931 state->control[7]);
801932#endif
802933
803934   return 0;
r7500r7501
805936
806937VIDEO_UPDATE( pangpang )
807938{
808   int offs,offs2;
939   tumbleb_state *state = (tumbleb_state *)screen->machine->driver_data;
940   int offs, offs2;
809941
810   flipscreen=tumblepb_control_0[0]&0x80;
811   tilemap_set_flip_all(screen->machine,flipscreen ? (TILEMAP_FLIPY | TILEMAP_FLIPX) : 0);
812   if (flipscreen) offs=1; else offs=-1;
813   if (flipscreen) offs2=-3; else offs2=-5;
942   state->flipscreen = state->control_0[0] & 0x80;
943   tilemap_set_flip_all(screen->machine, state->flipscreen ? (TILEMAP_FLIPY | TILEMAP_FLIPX) : 0);
814944
815   tilemap_set_scrollx( pf1_tilemap,0, tumblepb_control_0[1]+offs2 );
816   tilemap_set_scrolly( pf1_tilemap,0, tumblepb_control_0[2] );
817   tilemap_set_scrollx( pf1_alt_tilemap,0, tumblepb_control_0[1]+offs2 );
818   tilemap_set_scrolly( pf1_alt_tilemap,0, tumblepb_control_0[2] );
819   tilemap_set_scrollx( pf2_tilemap,0, tumblepb_control_0[3]+offs );
820   tilemap_set_scrolly( pf2_tilemap,0, tumblepb_control_0[4] );
945   if (state->flipscreen)
946      offs = 1;
947   else
948      offs = -1;
821949
822   tilemap_draw(bitmap,cliprect,pf2_tilemap,0,0);
823   if (tumblepb_control_0[6]&0x80)
824      tilemap_draw(bitmap,cliprect,pf1_tilemap,0,0);
950   if (state->flipscreen)
951      offs2 = -3;
825952   else
826      tilemap_draw(bitmap,cliprect,pf1_alt_tilemap,0,0);
827   jumpkids_draw_sprites(screen->machine,bitmap,cliprect);
828   return 0;
829}
953      offs2 = -5;
830954
831VIDEO_START( suprtrio )
832{
833   pf1_tilemap =     tilemap_create(machine, get_fg_tile_info, tilemap_scan_rows, 8, 8,64,32);
834   pf1_alt_tilemap = tilemap_create(machine, get_bg1_tile_info,tumblep_scan,16,16,64,32);
835   pf2_tilemap =     tilemap_create(machine, get_bg2_tile_info,tumblep_scan,     16,16,64,32);
955   tilemap_set_scrollx(state->pf1_tilemap,     0, state->control_0[1] + offs2);
956   tilemap_set_scrolly(state->pf1_tilemap,     0, state->control_0[2]);
957   tilemap_set_scrollx(state->pf1_alt_tilemap, 0, state->control_0[1] + offs2);
958   tilemap_set_scrolly(state->pf1_alt_tilemap, 0, state->control_0[2]);
959   tilemap_set_scrollx(state->pf2_tilemap,     0, state->control_0[3] + offs);
960   tilemap_set_scrolly(state->pf2_tilemap,     0, state->control_0[4]);
836961
837   tilemap_set_transparent_pen(pf1_alt_tilemap,0);
838   bcstory_tilebank = 0;
839}
962   tilemap_draw(bitmap, cliprect, state->pf2_tilemap, 0, 0);
840963
964   if (state->control_0[6] & 0x80)
965      tilemap_draw(bitmap, cliprect, state->pf1_tilemap, 0, 0);
966   else
967      tilemap_draw(bitmap, cliprect, state->pf1_alt_tilemap, 0, 0);
841968
969   jumpkids_draw_sprites(screen->machine, bitmap, cliprect);
970   return 0;
971}
src/mame/video/momoko.c
r7500r7501
11/*******************************************************************************
22
3Momoko 120% (c) 1986 Jaleco
3    Momoko 120% (c) 1986 Jaleco
44
5Video hardware driver by Uki
5    Video hardware driver by Uki
66
77    02/Mar/2001 -
88
99*******************************************************************************/
1010
1111#include "emu.h"
12#include "includes/momoko.h"
1213
13UINT8 *momoko_bg_scrollx;
14UINT8 *momoko_bg_scrolly;
15static UINT8 momoko_fg_scrollx;
16static UINT8 momoko_fg_scrolly;
17static UINT8 momoko_fg_select;
18static UINT8 momoko_text_scrolly;
19static UINT8 momoko_text_mode;
20static UINT8 momoko_bg_select;
21static UINT8 momoko_bg_priority;
22static UINT8 momoko_bg_mask;
23static UINT8 momoko_fg_mask;
24static UINT8 momoko_flipscreen;
2514
26/****************************************************************************/
27
2815WRITE8_HANDLER ( momoko_fg_scrollx_w )
2916{
30   momoko_fg_scrollx = data;
17   momoko_state *state = (momoko_state *)space->machine->driver_data;
18   state->fg_scrollx = data;
3119}
20
3221WRITE8_HANDLER ( momoko_fg_scrolly_w )
3322{
34   momoko_fg_scrolly = data;
23   momoko_state *state = (momoko_state *)space->machine->driver_data;
24   state->fg_scrolly = data;
3525}
26
3627WRITE8_HANDLER ( momoko_fg_select_w )
3728{
38   momoko_fg_select = data & 0x0f;
39   momoko_fg_mask = data & 0x10;
29   momoko_state *state = (momoko_state *)space->machine->driver_data;
30   state->fg_select = data & 0x0f;
31   state->fg_mask = data & 0x10;
4032}
33
4134WRITE8_HANDLER ( momoko_text_scrolly_w )
4235{
43   momoko_text_scrolly = data;
36   momoko_state *state = (momoko_state *)space->machine->driver_data;
37   state->text_scrolly = data;
4438}
39
4540WRITE8_HANDLER ( momoko_text_mode_w )
4641{
47   momoko_text_mode = data;
42   momoko_state *state = (momoko_state *)space->machine->driver_data;
43   state->text_mode = data;
4844}
45
4946WRITE8_HANDLER ( momoko_bg_scrollx_w )
5047{
51   momoko_bg_scrollx[ offset ] = data;
48   momoko_state *state = (momoko_state *)space->machine->driver_data;
49   state->bg_scrollx[offset] = data;
5250}
51
5352WRITE8_HANDLER ( momoko_bg_scrolly_w )
5453{
55   momoko_bg_scrolly[ offset ] = data;
54   momoko_state *state = (momoko_state *)space->machine->driver_data;
55   state->bg_scrolly[offset] = data;
5656}
57
5758WRITE8_HANDLER( momoko_bg_select_w )
5859{
59   momoko_bg_select = data & 0x0f;
60   momoko_bg_mask = data & 0x10;
60   momoko_state *state = (momoko_state *)space->machine->driver_data;
61   state->bg_select = data & 0x0f;
62   state->bg_mask = data & 0x10;
6163}
64
6265WRITE8_HANDLER( momoko_bg_priority_w )
6366{
64   momoko_bg_priority = data & 0x01;
67   momoko_state *state = (momoko_state *)space->machine->driver_data;
68   state->bg_priority = data & 0x01;
6569}
70
6671WRITE8_HANDLER( momoko_flipscreen_w )
6772{
68   momoko_flipscreen = data & 0x01;
73   momoko_state *state = (momoko_state *)space->machine->driver_data;
74   state->flipscreen = data & 0x01;
6975}
76
7077/****************************************************************************/
7178
72static void momoko_draw_bg_pri(running_machine *machine, bitmap_t *bitmap, int chr, int col, int flipx, int flipy, int x,int y, int pri)
79static void momoko_draw_bg_pri( running_machine *machine, bitmap_t *bitmap, int chr, int col, int flipx, int flipy, int x, int y, int pri )
7380{
74   int xx,sx,sy,px,py,dot;
81   int xx, sx, sy, px, py, dot;
7582   UINT32 gfxadr;
7683   UINT8 d0, d1;
77   UINT8 *BG_GFX = memory_region( machine, "gfx2" );
78   for (sy=0; sy<8; sy++)
84   UINT8 *BG_GFX = memory_region(machine, "gfx2");
85
86   for (sy = 0; sy < 8; sy++)
7987   {
80      gfxadr = chr*16 + sy*2;
81      for (xx=0; xx<2; xx++)
88      gfxadr = chr * 16 + sy * 2;
89      for (xx = 0; xx < 2; xx++)
8290      {
83         d0 = BG_GFX[gfxadr + xx*4096];
84         d1 = BG_GFX[gfxadr + xx*4096+1];
85         for (sx=0; sx<4; sx++)
91         d0 = BG_GFX[gfxadr + xx * 4096];
92         d1 = BG_GFX[gfxadr + xx * 4096 + 1];
93
94         for (sx = 0; sx < 4; sx++)
8695         {
8796            dot = (d0 & 0x08) | ((d0 & 0x80) >>5) | ((d1 & 0x08) >>2) | ((d1 & 0x80) >>7);
88            if (flipx==0) px=sx+xx*4 + x;
89               else  px=7-sx-xx*4 + x;
90            if (flipy==0) py=sy + y;
91               else  py=7-sy + y;
97            if (flipx == 0) px = sx + xx * 4 + x;
98               else      px = 7 - sx - xx * 4 + x;
99            if (flipy == 0) py = sy + y;
100               else      py = 7 - sy + y;
92101
93            if (dot>=pri)
94               *BITMAP_ADDR16(bitmap, py, px) = col*16+dot+256;
102            if (dot >= pri)
103               *BITMAP_ADDR16(bitmap, py, px) = col * 16 + dot + 256;
104
95105            d0 = d0 << 1;
96106            d1 = d1 << 1;
97107         }
r7500r7501
103113
104114VIDEO_UPDATE( momoko )
105115{
116   momoko_state *state = (momoko_state *)screen->machine->driver_data;
106117   int x, y, dx, dy, rx, ry, radr, chr, sy, fx, fy, px, py, offs, col, pri, flip ;
107   UINT8 *spriteram = screen->machine->generic.spriteram.u8;
118   UINT8 *spriteram = state->spriteram;
108119
109   UINT8 *BG_MAP     = memory_region( screen->machine, "user1" );
110   UINT8 *BG_COL_MAP = memory_region( screen->machine, "user2" );
111   UINT8 *FG_MAP     = memory_region( screen->machine, "user3" );
112   UINT8 *TEXT_COLOR = memory_region( screen->machine, "proms" );
120   UINT8 *BG_MAP     = memory_region(screen->machine, "user1");
121   UINT8 *BG_COL_MAP = memory_region(screen->machine, "user2");
122   UINT8 *FG_MAP     = memory_region(screen->machine, "user3");
123   UINT8 *TEXT_COLOR = memory_region(screen->machine, "proms");
113124
114125
115   flip = momoko_flipscreen ^ (input_port_read(screen->machine, "FAKE") & 0x01);
126   flip = state->flipscreen ^ (input_port_read(screen->machine, "FAKE") & 0x01);
116127
117/* draw BG layer */
128   /* draw BG layer */
129   dx = (7 - state->bg_scrollx[0]) & 7;
130   dy = (7 - state->bg_scrolly[0]) & 7;
131   rx = (state->bg_scrollx[0] + state->bg_scrollx[1] * 256) >> 3;
132   ry = (state->bg_scrolly[0] + state->bg_scrolly[1] * 256) >> 3;
118133
119   dx = ( 7 - momoko_bg_scrollx[0] ) & 7 ;
120   dy = ( 7 - momoko_bg_scrolly[0] ) & 7 ;
121   rx = (momoko_bg_scrollx[0] + momoko_bg_scrollx[1]*256) >> 3 ;
122   ry = (momoko_bg_scrolly[0] + momoko_bg_scrolly[1]*256) >> 3 ;
123
124   if (momoko_bg_mask == 0)
134   if (state->bg_mask == 0)
125135   {
126      for (y=0; y<29; y++)
136      for (y = 0; y < 29; y++)
127137      {
128         for (x=0; x<32; x++)
138         for (x = 0; x < 32; x++)
129139         {
130            radr = ( (ry + y +2 ) & 0x3ff ) * 128 + ( (rx + x) & 0x7f ) ;
131            chr = BG_MAP[ radr ] ;
132            col = BG_COL_MAP[ chr+momoko_bg_select*512+momoko_bg_priority*256] & 0x0f;
133            chr = chr + momoko_bg_select * 512;
140            radr = ((ry + y + 2) & 0x3ff) * 128 + ((rx + x) & 0x7f);
141            chr = BG_MAP[radr];
142            col = BG_COL_MAP[chr + state->bg_select * 512 + state->bg_priority * 256] & 0x0f;
143            chr = chr + state->bg_select * 512;
134144
135            if (flip==0)
145            if (flip == 0)
136146            {
137               px = 8*x+dx-6;
138               py = 8*y+dy+9;
147               px = 8 * x + dx - 6;
148               py = 8 * y + dy + 9;
139149            }
140150            else
141151            {
142               px = 248-(8*x+dx-8);
143               py = 248-(8*y+dy+9);
152               px = 248 - (8 * x + dx - 8);
153               py = 248 - (8 * y + dy + 9);
144154            }
145155
146156            drawgfx_opaque(bitmap,cliprect,screen->machine->gfx[1],
r7500r7501
155165   bitmap_fill(bitmap, cliprect, 256);
156166
157167
158/* draw sprites (momoko) */
159
160   for (offs=0; offs<9*4; offs +=4)
168   /* draw sprites (momoko) */
169   for (offs = 0; offs < 9 * 4; offs +=4)
161170   {
162      chr = spriteram[offs+1] | ((spriteram[offs+2]&0x60)<<3);
171      chr = spriteram[offs + 1] | ((spriteram[offs + 2] & 0x60) << 3);
163172      chr = ((chr & 0x380) << 1) | (chr & 0x7f);
164      col = spriteram[offs+2] & 0x07;
165      fx = ((spriteram[offs+2] & 0x10) >> 4) ^ flip;
166      fy = ((spriteram[offs+2] & 0x08) >> 3) ^ flip; /* ??? */
167      x = spriteram[offs+3];
168      y = spriteram[offs+0];
169      if (flip==0)
173      col = spriteram[offs + 2] & 0x07;
174      fx = ((spriteram[offs + 2] & 0x10) >> 4) ^ flip;
175      fy = ((spriteram[offs + 2] & 0x08) >> 3) ^ flip; /* ??? */
176      x = spriteram[offs + 3];
177      y = spriteram[offs + 0];
178
179      if (flip == 0)
170180      {
171181         px = x;
172         py = 239-y;
182         py = 239 - y;
173183      }
174184      else
175185      {
176         px = 248-x;
177         py = y+1;
186         px = 248 - x;
187         py = y + 1;
178188      }
179189
180190      drawgfx_transpen(bitmap,cliprect,screen->machine->gfx[3],
r7500r7501
185195   }
186196
187197
188/* draw BG layer */
189
190   if (momoko_bg_mask ==0)
198   /* draw BG layer */
199   if (state->bg_mask ==0)
191200   {
192      for (y=0; y<29; y++)
201      for (y = 0; y < 29; y++)
193202      {
194         for (x=0; x<32; x++)
203         for (x = 0; x < 32; x++)
195204         {
196            radr = ( (ry + y +2 ) & 0x3ff ) * 128 + ( (rx + x) & 0x7f ) ;
197            chr = BG_MAP[ radr ] ;
198            col = BG_COL_MAP[ chr+momoko_bg_select*512+momoko_bg_priority*256 ];
205            radr = ((ry + y + 2) & 0x3ff) * 128 + ((rx + x) & 0x7f) ;
206            chr = BG_MAP[radr] ;
207            col = BG_COL_MAP[chr + state->bg_select * 512 + state->bg_priority * 256];
199208            pri = (col & 0x10) >> 1;
200209
201            if (flip==0)
210            if (flip == 0)
202211            {
203               px = 8*x+dx-6;
204               py = 8*y+dy+9;
205            }
212               px = 8 * x + dx - 6;
213               py = 8 * y + dy + 9;
214             }
206215            else
207216            {
208               px = 248-(8*x+dx-8);
209               py = 248-(8*y+dy+9);
217               px = 248 - (8 * x + dx - 8);
218               py = 248 - (8 * y + dy + 9);
210219            }
211220            if (pri != 0)
212221            {
213222               col = col & 0x0f;
214               chr = chr + momoko_bg_select * 512;
215               momoko_draw_bg_pri(screen->machine,bitmap,chr,col,flip,flip,px,py,pri);
223               chr = chr + state->bg_select * 512;
224               momoko_draw_bg_pri(screen->machine, bitmap, chr, col, flip, flip, px, py, pri);
216225            }
217226         }
218227      }
219228   }
220229
221230
222/* draw sprites (others) */
223
224   for (offs=9*4; offs<screen->machine->generic.spriteram_size; offs +=4)
231   /* draw sprites (others) */
232   for (offs = 9 * 4; offs < state->spriteram_size; offs += 4)
225233   {
226      chr = spriteram[offs+1] | ((spriteram[offs+2]&0x60)<<3);
234      chr = spriteram[offs + 1] | ((spriteram[offs + 2] & 0x60) << 3);
227235      chr = ((chr & 0x380) << 1) | (chr & 0x7f);
228      col = spriteram[offs+2] & 0x07;
229      fx = ((spriteram[offs+2] & 0x10) >> 4) ^ flip;
230      fy = ((spriteram[offs+2] & 0x08) >> 3) ^ flip; /* ??? */
231      x = spriteram[offs+3];
232      y = spriteram[offs+0];
233      if (flip==0)
236      col = spriteram[offs + 2] & 0x07;
237      fx = ((spriteram[offs + 2] & 0x10) >> 4) ^ flip;
238      fy = ((spriteram[offs + 2] & 0x08) >> 3) ^ flip; /* ??? */
239      x = spriteram[offs + 3];
240      y = spriteram[offs + 0];
241
242      if (flip == 0)
234243      {
235244         px = x;
236         py = 239-y;
245         py = 239 - y;
237246      }
238247      else
239248      {
240         px = 248-x;
241         py = y+1;
249         px = 248 - x;
250         py = y + 1;
242251      }
243252      drawgfx_transpen(bitmap,cliprect,screen->machine->gfx[3],
244253         chr,
r7500r7501
248257   }
249258
250259
251/* draw text layer */
252
253   for (y=16; y<240; y++)
260   /* draw text layer */
261   for (y = 16; y < 240; y++)
254262   {
255      for (x=0; x<32; x++)
263      for (x = 0; x < 32; x++)
256264      {
257265         sy = y;
258         if (momoko_text_mode == 0)
259            col = TEXT_COLOR[ (sy >> 3) + 0x100 ] & 0x0f;
266         if (state->text_mode == 0)
267            col = TEXT_COLOR[(sy >> 3) + 0x100] & 0x0f;
260268         else
261269         {
262            if (TEXT_COLOR[ y ] < 0x08)
263               sy += momoko_text_scrolly;
264            col = (TEXT_COLOR[ y ] & 0x07) + 0x10;
270            if (TEXT_COLOR[y] < 0x08)
271               sy += state->text_scrolly;
272            col = (TEXT_COLOR[y] & 0x07) + 0x10;
265273         }
266         dy=sy & 7;
267         if (flip==0)
274         dy = sy & 7;
275         if (flip == 0)
268276         {
269            px = x*8;
277            px = x * 8;
270278            py = y;
271279         }
272280         else
273281         {
274            px = 248-x*8;
275            py = 255-y;
282            px = 248 - x * 8;
283            py = 255 - y;
276284         }
277285         drawgfx_transpen(bitmap,cliprect,screen->machine->gfx[0],
278            screen->machine->generic.videoram.u8[(sy>>3)*32+x]*8+dy,
286            state->videoram[(sy >> 3) * 32 + x] * 8 + dy,
279287            col,
280288            flip,0,
281289            px,py,0);
r7500r7501
283291   }
284292
285293
286/* draw FG layer */
287
288   if (momoko_fg_mask==0)
294   /* draw FG layer */
295   if (state->fg_mask == 0)
289296   {
290      dx = ( 7 - momoko_fg_scrollx ) & 7 ;
291      dy = ( 7 - momoko_fg_scrolly ) & 7 ;
292      rx = momoko_fg_scrollx >> 3 ;
293      ry = momoko_fg_scrolly >> 3 ;
297      dx = (7 - state->fg_scrollx) & 7;
298      dy = (7 - state->fg_scrolly) & 7;
299      rx = state->fg_scrollx >> 3;
300      ry = state->fg_scrolly >> 3;
294301
295      for (y=0; y<29; y++)
302      for (y = 0; y < 29; y++)
296303      {
297         for (x=0; x<32; x++)
304         for (x = 0; x < 32; x++)
298305         {
299            radr = ((ry + y +34) & 0x3f) *0x20 + ((rx + x) & 0x1f) + (momoko_fg_select & 3) *0x800;
300            chr = FG_MAP[ radr ] ;
301            if (flip==0)
306            radr = ((ry + y + 34) & 0x3f) * 0x20 + ((rx + x) & 0x1f) + (state->fg_select & 3) * 0x800;
307            chr = FG_MAP[radr] ;
308            if (flip == 0)
302309            {
303               px = 8*x+dx-6;
304               py = 8*y+dy+9;
310               px = 8 * x + dx - 6;
311               py = 8 * y + dy + 9;
305312            }
306313            else
307314            {
308               px = 248-(8*x+dx-8);
309               py = 248-(8*y+dy+9);
315               px = 248 - (8 * x + dx - 8);
316               py = 248 - (8 * y + dy + 9);
310317            }
311318            drawgfx_transpen(bitmap,cliprect,screen->machine->gfx[2],
312319               chr,
src/mame/video/markham.c
r7500r7501
11/******************************************************************************
22
3Markham (c) 1983 Sun Electronics
3    Markham (c) 1983 Sun Electronics
44
5Video hardware driver by Uki
5    Video hardware driver by Uki
66
77    17/Jun/2001 -
88
99******************************************************************************/
1010
1111#include "emu.h"
12#include "includes/markham.h"
1213
13
14UINT8 *markham_xscroll;
15
16static tilemap_t *bg_tilemap;
17
1814PALETTE_INIT( markham )
1915{
2016   int i;
r7500r7501
4541
4642WRITE8_HANDLER( markham_videoram_w )
4743{
48   space->machine->generic.videoram.u8[offset] = data;
49   tilemap_mark_tile_dirty(bg_tilemap, offset / 2);
44   markham_state *state = (markham_state *)space->machine->driver_data;
45   state->videoram[offset] = data;
46   tilemap_mark_tile_dirty(state->bg_tilemap, offset / 2);
5047}
5148
5249WRITE8_HANDLER( markham_flipscreen_w )
r7500r7501
6057
6158static TILE_GET_INFO( get_bg_tile_info )
6259{
63   int attr = machine->generic.videoram.u8[tile_index * 2];
64   int code = machine->generic.videoram.u8[(tile_index * 2) + 1] + ((attr & 0x60) << 3);
60   markham_state *state = (markham_state *)machine->driver_data;
61   int attr = state->videoram[tile_index * 2];
62   int code = state->videoram[(tile_index * 2) + 1] + ((attr & 0x60) << 3);
6563   int color = (attr & 0x1f) | ((attr & 0x80) >> 2);
6664
6765   SET_TILE_INFO(0, code, color, 0);
r7500r7501
6967
7068VIDEO_START( markham )
7169{
72   bg_tilemap = tilemap_create(machine, get_bg_tile_info, tilemap_scan_cols,
73       8, 8, 32, 32);
70   markham_state *state = (markham_state *)machine->driver_data;
71   state->bg_tilemap = tilemap_create(machine, get_bg_tile_info, tilemap_scan_cols, 8, 8, 32, 32);
7472
75   tilemap_set_scroll_rows(bg_tilemap, 32);
73   tilemap_set_scroll_rows(state->bg_tilemap, 32);
7674}
7775
78static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect)
76static void draw_sprites( running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect )
7977{
80   UINT8 *spriteram = machine->generic.spriteram.u8;
78   markham_state *state = (markham_state *)machine->driver_data;
79   UINT8 *spriteram = state->spriteram;
8180   int offs;
8281
83   for (offs=0x60; offs<0x100; offs +=4)
82   for (offs = 0x60; offs < 0x100; offs += 4)
8483   {
85      int chr = spriteram[offs+1];
86      int col = spriteram[offs+2];
84      int chr = spriteram[offs + 1];
85      int col = spriteram[offs + 2];
8786
8887      int fx = flip_screen_get(machine);
8988      int fy = flip_screen_get(machine);
9089
91      int x = spriteram[offs+3];
92      int y = spriteram[offs+0];
93      int px,py;
90      int x = spriteram[offs + 3];
91      int y = spriteram[offs + 0];
92      int px, py;
9493      col &= 0x3f ;
9594
96      if (flip_screen_get(machine)==0)
95      if (flip_screen_get(machine) == 0)
9796      {
98         px = x-2;
99         py = 240-y;
97         px = x - 2;
98         py = 240 - y;
10099      }
101100      else
102101      {
103         px = 240-x;
102         px = 240 - x;
104103         py = y;
105104      }
106105
107106      px = px & 0xff;
108107
109      if (px>248)
110         px = px-256;
108      if (px > 248)
109         px = px - 256;
111110
112111      drawgfx_transmask(bitmap,cliprect,machine->gfx[1],
113112         chr,
r7500r7501
120119
121120VIDEO_UPDATE( markham )
122121{
122   markham_state *state = (markham_state *)screen->machine->driver_data;
123123   int i;
124124
125125   for (i = 0; i < 32; i++)
126126   {
127      if ((i > 3) && (i<16))
128         tilemap_set_scrollx(bg_tilemap, i, markham_xscroll[0]);
127      if ((i > 3) && (i < 16))
128         tilemap_set_scrollx(state->bg_tilemap, i, state->xscroll[0]);
129129      if (i >= 16)
130         tilemap_set_scrollx(bg_tilemap, i, markham_xscroll[1]);
130         tilemap_set_scrollx(state->bg_tilemap, i, state->xscroll[1]);
131131   }
132132
133   tilemap_draw(bitmap, cliprect, bg_tilemap, 0, 0);
133   tilemap_draw(bitmap, cliprect, state->bg_tilemap, 0, 0);
134134   draw_sprites(screen->machine, bitmap, cliprect);
135135   return 0;
136136}
src/mame/video/lockon.c
r7500r7501
1717
1818/*************************************
1919 *
20 *  Globals
21 *
22 *************************************/
23
24UINT16   *lockon_char_ram;
25UINT16   *lockon_hud_ram;
26UINT16   *lockon_scene_ram;
27UINT16   *lockon_ground_ram;
28UINT16   *lockon_object_ram;
29
30size_t   lockon_hudram_size;
31size_t   lockon_objectram_size;
32size_t   lockon_groundram_size;
33
34
35/*************************************
36 *
37 *  Statics
38 *
39 *************************************/
40
41static tilemap_t *lockon_tilemap;
42static UINT8   ground_ctrl;
43static UINT16   scroll_h;
44static UINT16   scroll_v;
45
46static bitmap_t   *front_buffer;
47static bitmap_t   *back_buffer;
48static emu_timer   *bufend_timer;
49static emu_timer   *cursor_timer;
50
51/* Rotation Control */
52static UINT16   xsal;
53static UINT16   x0ll;
54static UINT16   dx0ll;
55static UINT16   dxll;
56static UINT16   ysal;
57static UINT16   y0ll;
58static UINT16   dy0ll;
59static UINT16   dyll;
60
61/* Object palette RAM control */
62static UINT32   iden;
63static UINT8   *obj_pal_ram;
64static UINT32   obj_pal_latch;
65static UINT32   obj_pal_addr;
66
67
68/*************************************
69 *
7020 *  HD46505S-2 CRT Controller
7121 *
7222 *************************************/
r7500r7501
11464
11565static TIMER_CALLBACK( cursor_callback )
11666{
117   if (lockon_main_inten)
118      cputag_set_input_line_and_vector(machine, "maincpu", 0, HOLD_LINE, 0xff);
67   lockon_state *state = (lockon_state *)machine->driver_data;
11968
120   timer_adjust_oneshot(cursor_timer, video_screen_get_time_until_pos(machine->primary_screen, CURSOR_YPOS, CURSOR_XPOS), 0);
69   if (state->main_inten)
70      cpu_set_input_line_and_vector(state->maincpu, 0, HOLD_LINE, 0xff);
71
72   timer_adjust_oneshot(state->cursor_timer, video_screen_get_time_until_pos(machine->primary_screen, CURSOR_YPOS, CURSOR_XPOS), 0);
12173}
12274
12375/*************************************
r7500r7501
158110
159111      if (p2 & 0x80)
160112      {
161         r = compute_res_net( (p2 >> 2) & 0x1f, 0, &lockon_net_info );
162         g = compute_res_net( ((p1 >> 5) & 0x7) | (p2 & 3) << 3, 1, &lockon_net_info );
163         b = compute_res_net( (p1 & 0x1f), 2, &lockon_net_info );
113         r = compute_res_net((p2 >> 2) & 0x1f, 0, &lockon_net_info);
114         g = compute_res_net(((p1 >> 5) & 0x7) | (p2 & 3) << 3, 1, &lockon_net_info);
115         b = compute_res_net((p1 & 0x1f), 2, &lockon_net_info);
164116      }
165117      else
166118      {
167         r = compute_res_net( (p2 >> 2) & 0x1f, 0, &lockon_pd_net_info );
168         g = compute_res_net( ((p1 >> 5) & 0x7) | (p2 & 3) << 3, 1, &lockon_pd_net_info );
169         b = compute_res_net( (p1 & 0x1f), 2, &lockon_pd_net_info );
119         r = compute_res_net((p2 >> 2) & 0x1f, 0, &lockon_pd_net_info);
120         g = compute_res_net(((p1 >> 5) & 0x7) | (p2 & 3) << 3, 1, &lockon_pd_net_info);
121         b = compute_res_net((p1 & 0x1f), 2, &lockon_pd_net_info);
170122      }
171123
172124      palette_set_color(machine, i, MAKE_RGB(r, g, b));
r7500r7501
182134
183135WRITE16_HANDLER( lockon_char_w )
184136{
185   lockon_char_ram[offset] = data;
186   tilemap_mark_tile_dirty(lockon_tilemap, offset);
137   lockon_state *state = (lockon_state *)space->machine->driver_data;
138   state->char_ram[offset] = data;
139   tilemap_mark_tile_dirty(state->tilemap, offset);
187140}
188141
189142static TILE_GET_INFO( get_lockon_tile_info )
190143{
191   UINT32 tileno = lockon_char_ram[tile_index] & 0x03ff;
192   UINT32 col = (lockon_char_ram[tile_index] >> 10) & 0x3f;
144   lockon_state *state = (lockon_state *)machine->driver_data;
145   UINT32 tileno = state->char_ram[tile_index] & 0x03ff;
146   UINT32 col = (state->char_ram[tile_index] >> 10) & 0x3f;
193147
194148   col = (col & 0x1f) + (col & 0x20 ? 64 : 0);
195149   SET_TILE_INFO(0, tileno, col, 0);
r7500r7501
204158
205159WRITE16_HANDLER( lockon_scene_h_scr_w )
206160{
207   scroll_h = data & 0x1ff;
161   lockon_state *state = (lockon_state *)space->machine->driver_data;
162   state->scroll_h = data & 0x1ff;
208163}
209164
210165WRITE16_HANDLER( lockon_scene_v_scr_w )
211166{
212   scroll_v = data & 0x81ff;
167   lockon_state *state = (lockon_state *)space->machine->driver_data;
168   state->scroll_v = data & 0x81ff;
213169}
214170
215static void scene_draw(running_machine *machine)
171static void scene_draw( running_machine *machine )
216172{
173   lockon_state *state = (lockon_state *)machine->driver_data;
217174   UINT32 y;
218175
219176   /* 3bpp characters */
r7500r7501
224181
225182   for (y = 0; y < FRAMEBUFFER_MAX_Y; ++y)
226183   {
227      UINT32   x;
228      UINT32   d0 = 0, d1 = 0, d2 = 0;
229      UINT32   colour = 0;
230      UINT32   y_offs;
231      UINT32   x_offs;
232      UINT32   y_gran;
233      UINT16   *bmpaddr;
234      UINT32   ram_mask = 0x7ff;
184      UINT32 x;
185      UINT32 d0 = 0, d1 = 0, d2 = 0;
186      UINT32 colour = 0;
187      UINT32 y_offs;
188      UINT32 x_offs;
189      UINT32 y_gran;
190      UINT16 *bmpaddr;
191      UINT32 ram_mask = 0x7ff;
235192
236      y_offs = (y + scroll_v) & 0x1ff;
193      y_offs = (y + state->scroll_v) & 0x1ff;
237194
238195      /* Clamp - stops tilemap wrapping when screen is rotated */
239      if (BIT(scroll_v, 15) && y_offs & 0x100)
196      if (BIT(state->scroll_v, 15) && y_offs & 0x100)
240197         ram_mask = 0x7;
241198
242      x_offs = (scroll_h - 8) & 0x1ff;
199      x_offs = (state->scroll_h - 8) & 0x1ff;
243200      y_gran = y_offs & 7;
244201
245202      if (x_offs & 7)
246203      {
247204         UINT32 tileidx;
248205         UINT16 addr = ((y_offs & ~7) << 3) + ((x_offs >> 3) & 0x3f);
249         UINT16 ram_val = lockon_scene_ram[addr & ram_mask];
206         UINT16 ram_val = state->scene_ram[addr & ram_mask];
250207
251208         colour = (clut[ram_val & 0x7fff] & 0x3f) << 3;
252209         tileidx = ((ram_val & 0x0fff) << 3) + y_gran;
r7500r7501
256213         d2 = *(gfx3 + tileidx);
257214      }
258215
259      bmpaddr = BITMAP_ADDR16(back_buffer, y, 0);
216      bmpaddr = BITMAP_ADDR16(state->back_buffer, y, 0);
260217
261218      for (x = 0; x < FRAMEBUFFER_MAX_X; ++x)
262219      {
r7500r7501
267224         {
268225            UINT32 tileidx;
269226            UINT16 addr = ((y_offs & ~7) << 3) + ((x_offs >> 3) & 0x3f);
270            UINT16 ram_val = lockon_scene_ram[addr & ram_mask];
227            UINT16 ram_val = state->scene_ram[addr & ram_mask];
271228
272229            colour = (clut[ram_val & 0x7fff] & 0x3f) << 3;
273230            tileidx = ((ram_val & 0x0fff) << 3) + y_gran;
r7500r7501
324281
325282WRITE16_HANDLER( lockon_ground_ctrl_w )
326283{
327   ground_ctrl = data & 0xff;
284   lockon_state *state = (lockon_state *)space->machine->driver_data;
285   state->ground_ctrl = data & 0xff;
328286}
329287
330288static TIMER_CALLBACK( bufend_callback )
331289{
332   cputag_set_input_line_and_vector(machine, "ground", 0, HOLD_LINE, 0xff);
333   cputag_set_input_line(machine, "object", NEC_INPUT_LINE_POLL, ASSERT_LINE);
290   lockon_state *state = (lockon_state *)machine->driver_data;
291   cpu_set_input_line_and_vector(state->ground, 0, HOLD_LINE, 0xff);
292   cpu_set_input_line(state->object, NEC_INPUT_LINE_POLL, ASSERT_LINE);
334293}
335294
336295/* Get data for a each 8x8x3 ground tile */
r7500r7501
347306   rom_data3 = gfx_rom[gfx_addr + 0x20000];                                             \
348307}
349308
350static void ground_draw(running_machine *machine)
309static void ground_draw( running_machine *machine )
351310{
311   lockon_state *state = (lockon_state *)machine->driver_data;
312
352313   /* ROM pointers */
353314   const UINT8 *const gfx_rom  = memory_region(machine, "gfx4");
354   const UINT8 *const lut_rom  = gfx_rom + 0x30000 + ((ground_ctrl >> 2) & 0x3 ? 0x10000 : 0);
315   const UINT8 *const lut_rom  = gfx_rom + 0x30000 + ((state->ground_ctrl >> 2) & 0x3 ? 0x10000 : 0);
355316   const UINT8 *const clut_rom = gfx_rom + 0x50000;
356317
357   UINT32 lut_a15_14   = (ground_ctrl & 0x3) << 14;
358   UINT32 clut_a14_12   = (ground_ctrl & 0x70) << 8;
359   UINT32 gfx_a15      = (ground_ctrl & 0x40) << 9;
318   UINT32 lut_a15_14   = (state->ground_ctrl & 0x3) << 14;
319   UINT32 clut_a14_12 = (state->ground_ctrl & 0x70) << 8;
320   UINT32 gfx_a15 = (state->ground_ctrl & 0x40) << 9;
360321   UINT32 offs = 3;
361322   UINT32 y;
362323
363324   /* TODO: Clean up and emulate CS of GFX ROMs? */
364325   for (y = 0; y < FRAMEBUFFER_MAX_Y; ++y)
365326   {
366      UINT16   *bmpaddr = BITMAP_ADDR16(back_buffer, y, 0);
367      UINT8   ls163;
368      UINT32   clut_addr;
369      UINT32   gfx_addr;
370      UINT8   rom_data1 = 0;
371      UINT8   rom_data2 = 0;
372      UINT8   rom_data3 = 0;
373      UINT32   pal = 0;
374      UINT32   x;
327      UINT16 *bmpaddr = BITMAP_ADDR16(state->back_buffer, y, 0);
328      UINT8 ls163;
329      UINT32 clut_addr;
330      UINT32 gfx_addr;
331      UINT8 rom_data1 = 0;
332      UINT8 rom_data2 = 0;
333      UINT8 rom_data3 = 0;
334      UINT32 pal = 0;
335      UINT32 x;
375336
376337      /* Draw this line? */
377      if (!(lockon_ground_ram[offs] & 0x8000))
338      if (!(state->ground_ram[offs] & 0x8000))
378339      {
379         UINT32   gfx_a2_0  =  lockon_ground_ram[offs] & 0x0007;
380         UINT32   gfx_a6_5  = (lockon_ground_ram[offs] & 0x0018) << 2;
381         UINT32   clut_a4_3 = (lockon_ground_ram[offs] & 0x0018) >> 1;
382         UINT8   tz2213_x  = lockon_ground_ram[offs + 1] & 0xff;
383         UINT8   tz2213_dx = lockon_ground_ram[offs + 2] & 0xff;
340         UINT32 gfx_a2_0  =  state->ground_ram[offs] & 0x0007;
341         UINT32 gfx_a6_5  = (state->ground_ram[offs] & 0x0018) << 2;
342         UINT32 clut_a4_3 = (state->ground_ram[offs] & 0x0018) >> 1;
343         UINT8   tz2213_x  = state->ground_ram[offs + 1] & 0xff;
344         UINT8   tz2213_dx = state->ground_ram[offs + 2] & 0xff;
384345
385         UINT32   lut_address = lut_a15_14 + ((lockon_ground_ram[offs] & 0x7fe0) >> 1);
386         UINT32   cy         = lockon_ground_ram[offs + 2] & 0x0100;
387         UINT32   color;
388         UINT32   gpbal2_0_prev;
346         UINT32 lut_address = lut_a15_14 + ((state->ground_ram[offs] & 0x7fe0) >> 1);
347         UINT32 cy = state->ground_ram[offs + 2] & 0x0100;
348         UINT32 color;
349         UINT32 gpbal2_0_prev;
389350
390         ls163 = lockon_ground_ram[offs + 1] >> 8;
351         ls163 = state->ground_ram[offs + 1] >> 8;
391352
392353         gpbal2_0_prev = ((ls163 & 3) << 1) | BIT(tz2213_x, 7);
393354
r7500r7501
425386      offs += 3;
426387
427388      /* End of list marker */
428      if (lockon_ground_ram[offs + 2] & 0x8000)
389      if (state->ground_ram[offs + 2] & 0x8000)
429390      {
430         timer_adjust_oneshot(bufend_timer, attotime_mul(ATTOTIME_IN_HZ(FRAMEBUFFER_CLOCK), FRAMEBUFFER_MAX_X * y), 0);
391         timer_adjust_oneshot(state->bufend_timer, attotime_mul(ATTOTIME_IN_HZ(FRAMEBUFFER_CLOCK), FRAMEBUFFER_MAX_X * y), 0);
431392      }
432393   }
433394}
r7500r7501
464425   if (px < FRAMEBUFFER_MAX_X)                      \
465426   if (COLOR != 0xf)                                    \
466427   {                                                    \
467      UINT8 clr = obj_pal_ram[(pal << 4) + COLOR];     \
428      UINT8 clr = state->obj_pal_ram[(pal << 4) + COLOR];     \
468429      UINT16 *pix = (line + px);                   \
469430      if (!(clr == 0xff && ((*pix & 0xe00) == 0xa00))) \
470431         *pix = 0x400 + clr;          \
r7500r7501
472433   px = (px + 1) & 0x7ff;                               \
473434} while(0)
474435
475static void objects_draw(running_machine *machine)
436static void objects_draw( running_machine *machine )
476437{
477438   UINT32 offs;
439   lockon_state *state = (lockon_state *)machine->driver_data;
478440
479441   const UINT8  *const romlut = memory_region(machine, "user1");
480442   const UINT16 *const chklut = (UINT16*)memory_region(machine, "user2");
481443   const UINT8  *const gfxrom = memory_region(machine, "gfx5");
482444   const UINT8  *const sproms = memory_region(machine, "proms") + 0x800;
483445
484   for (offs = 0; offs < lockon_objectram_size; offs += 4)
446   for (offs = 0; offs < state->objectram_size; offs += 4)
485447   {
486448      UINT32 y;
487449      UINT32 xpos;
r7500r7501
497459      UINT32 opsta15_8;
498460
499461      /* Retrieve the object attributes */
500      ypos   = lockon_object_ram[offs] & 0x03ff;
501      xpos   = lockon_object_ram[offs + 3] & 0x07ff;
502      ysize   = (lockon_object_ram[offs] >> 10) & 0x3;
503      xsize   = (lockon_object_ram[offs] >> 12) & 0x3;
504      yflip   = BIT(lockon_object_ram[offs], 14);
505      xflip   = BIT(lockon_object_ram[offs], 15);
506      scale   = lockon_object_ram[offs + 1] & 0xff;
507      pal      = (lockon_object_ram[offs + 1] >> 8) & 0x7f;
508      opsta   = lockon_object_ram[offs + 2];
462      ypos   = state->object_ram[offs] & 0x03ff;
463      xpos   = state->object_ram[offs + 3] & 0x07ff;
464      ysize   = (state->object_ram[offs] >> 10) & 0x3;
465      xsize   = (state->object_ram[offs] >> 12) & 0x3;
466      yflip   = BIT(state->object_ram[offs], 14);
467      xflip   = BIT(state->object_ram[offs], 15);
468      scale   = state->object_ram[offs + 1] & 0xff;
469      pal = (state->object_ram[offs + 1] >> 8) & 0x7f;
470      opsta   = state->object_ram[offs + 2];
509471
510      if (iden)
472      if (state->iden)
511473      {
512         obj_pal_ram[(pal << 4) + obj_pal_addr] = obj_pal_latch;
474         state->obj_pal_ram[(pal << 4) + state->obj_pal_addr] = state->obj_pal_latch;
513475         break;
514476      }
515477
r7500r7501
523485
524486      for (y = 0; y < FRAMEBUFFER_MAX_Y; y++)
525487      {
526         UINT32   cy = (y + ypos) & 0x3ff;
527         UINT32   optab;
528         UINT32   lutaddr;
529         UINT32   tile;
488         UINT32 cy = (y + ypos) & 0x3ff;
489         UINT32 optab;
490         UINT32 lutaddr;
491         UINT32 tile;
530492         UINT8   cnt;
531         UINT32   yidx;
532         UINT16   *line = BITMAP_ADDR16(back_buffer, y, 0);
533         UINT32   px = xpos;
493         UINT32 yidx;
494         UINT16 *line = BITMAP_ADDR16(state->back_buffer, y, 0);
495         UINT32 px = xpos;
534496
535497         /* Outside the limits? */
536498         if (cy & 0x300)
r7500r7501
560522         /* Draw! */
561523         for (tile = 0; tile < (1 << xsize); ++tile)
562524         {
563            UINT16   sc;
564            UINT16   scl;
565            UINT32   x;
566            UINT32   tileaddr;
567            UINT16   td0, td1, td2, td3;
568            UINT32   j;
569            UINT32   bank;
525            UINT16 sc;
526            UINT16 scl;
527            UINT32 x;
528            UINT32 tileaddr;
529            UINT16 td0, td1, td2, td3;
530            UINT32 j;
531            UINT32 bank;
570532
571533            scl = scale & 0x7f;
572534            tileaddr = (chklut[opsta15_8 + cnt] & 0x7fff);
r7500r7501
610572
611573                     DRAW_OBJ_PIXEL(col);
612574
613                     if ( BIT(sc, x) )
575                     if (BIT(sc, x))
614576                        DRAW_OBJ_PIXEL(col);
615577                  }
616578               }
r7500r7501
621583                     UINT8 col;
622584                     UINT8 pix = x;
623585
624                     if ( BIT(sc, x) )
586                     if (BIT(sc, x))
625587                     {
626588                        if (!xflip)
627589                           pix ^= 0x7;
r7500r7501
640602      }
641603
642604      /* Check for the end of list marker */
643      if (lockon_object_ram[offs + 1] & 0x8000)
605      if (state->object_ram[offs + 1] & 0x8000)
644606         return;
645607   }
646608}
r7500r7501
648610/* The mechanism used by the object CPU to update the object ASICs palette RAM */
649611WRITE16_HANDLER( lockon_tza112_w )
650612{
651   if (iden)
613   lockon_state *state = (lockon_state *)space->machine->driver_data;
614
615   if (state->iden)
652616   {
653      obj_pal_latch = data & 0xff;
654      obj_pal_addr = offset & 0xf;
617      state->obj_pal_latch = data & 0xff;
618      state->obj_pal_addr = offset & 0xf;
655619      objects_draw(space->machine);
656620   }
657621}
658622
659623READ16_HANDLER( lockon_obj_4000_r )
660624{
661   cputag_set_input_line(space->machine, "object", NEC_INPUT_LINE_POLL, CLEAR_LINE);
625   lockon_state *state = (lockon_state *)space->machine->driver_data;
626
627   cpu_set_input_line(state->object, NEC_INPUT_LINE_POLL, CLEAR_LINE);
662628   return 0xffff;
663629}
664630
665631WRITE16_HANDLER( lockon_obj_4000_w )
666632{
667   iden = data & 1;
633   lockon_state *state = (lockon_state *)space->machine->driver_data;
634   state->iden = data & 1;
668635}
669636
670637
r7500r7501
701668/* Rotation control register */
702669WRITE16_HANDLER( lockon_rotate_w )
703670{
671   lockon_state *state = (lockon_state *)space->machine->driver_data;
672
704673   switch (offset & 7)
705674   {
706      case 0: xsal  = data & 0x1ff;   break;
707      case 1: x0ll  = data & 0xff;   break;
708      case 2: dx0ll = data & 0x1ff;   break;
709      case 3: dxll  = data & 0x1ff;   break;
675      case 0: state->xsal  = data & 0x1ff;   break;
676      case 1: state->x0ll  = data & 0xff;   break;
677      case 2: state->dx0ll = data & 0x1ff;   break;
678      case 3: state->dxll  = data & 0x1ff;   break;
710679
711      case 4: ysal  = data & 0x1ff;   break;
712      case 5: y0ll  = data & 0xff;   break;
713      case 6: dy0ll =   data & 0x1ff;   break;
714      case 7: dyll  = data & 0x3ff;   break;
680      case 4: state->ysal  = data & 0x1ff;   break;
681      case 5: state->y0ll  = data & 0xff;   break;
682      case 6: state->dy0ll =   data & 0x1ff;   break;
683      case 7: state->dyll  = data & 0x3ff;   break;
715684   }
716685}
717686
r7500r7501
729698   if (carry) --CNT;                    \
730699} while(0)
731700
732static void rotate_draw(bitmap_t *bitmap, const rectangle *cliprect)
701static void rotate_draw( running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect )
733702{
703   lockon_state *state = (lockon_state *)machine->driver_data;
734704   UINT32 y;
735705
736706   /* Counters */
737   UINT32 cxy = xsal & 0xff;
738   UINT32 cyy = ysal & 0x1ff;
707   UINT32 cxy = state->xsal & 0xff;
708   UINT32 cyy = state->ysal & 0x1ff;
739709
740710   /* Accumulator values and deltas */
741   UINT8 axy  = x0ll & 0xff;
742   UINT8 daxy = dx0ll & 0xff;
743   UINT8 ayy  = y0ll & 0xff;
744   UINT8 dayy = dy0ll & 0xff;
745   UINT8 dayx = dyll & 0xff;
746   UINT8 daxx = dxll & 0xff;
711   UINT8 axy  = state->x0ll & 0xff;
712   UINT8 daxy = state->dx0ll & 0xff;
713   UINT8 ayy  = state->y0ll & 0xff;
714   UINT8 dayy = state->dy0ll & 0xff;
715   UINT8 dayx = state->dyll & 0xff;
716   UINT8 daxx = state->dxll & 0xff;
747717
748   UINT32 xy_up = BIT(xsal, 8);
749   UINT32 yx_up = BIT(dyll, 9);
750   UINT32 axx_en  = !BIT(dxll, 8);
751   UINT32 ayx_en  = !BIT(dyll, 8);
752   UINT32 axy_en  = !BIT(dx0ll, 8);
753   UINT32 ayy_en  = !BIT(dy0ll, 8);
718   UINT32 xy_up = BIT(state->xsal, 8);
719   UINT32 yx_up = BIT(state->dyll, 9);
720   UINT32 axx_en  = !BIT(state->dxll, 8);
721   UINT32 ayx_en  = !BIT(state->dyll, 8);
722   UINT32 axy_en  = !BIT(state->dx0ll, 8);
723   UINT32 ayy_en  = !BIT(state->dy0ll, 8);
754724
755725   for (y = 0; y <= cliprect->max_y; ++y)
756726   {
r7500r7501
769739         cx &= 0x1ff;
770740         cy &= 0x1ff;
771741
772         *dst++ = *BITMAP_ADDR16(front_buffer, cy, cx);
742         *dst++ = *BITMAP_ADDR16(state->front_buffer, cy, cx);
773743
774744         if (axx_en)
775745            INCREMENT(axx, cx);
r7500r7501
833803
834804*******************************************************************************************/
835805
836static void hud_draw(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect)
806static void hud_draw( running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect )
837807{
808   lockon_state *state = (lockon_state *)machine->driver_data;
838809   UINT8   *tile_rom = memory_region(machine, "gfx3");
839   UINT32   offs;
810   UINT32 offs;
840811
841   for (offs = 0x0; offs <= lockon_hudram_size; offs += 2)
812   for (offs = 0x0; offs <= state->hudram_size; offs += 2)
842813   {
843      UINT32   y;
844      UINT32   y_pos;
845      UINT32   x_pos;
846      UINT32   y_size;
847      UINT32   x_size;
848      UINT32   layout;
849      UINT16   colour;
850      UINT32   code;
851      UINT32   rom_a12_7;
814      UINT32 y;
815      UINT32 y_pos;
816      UINT32 x_pos;
817      UINT32 y_size;
818      UINT32 x_size;
819      UINT32 layout;
820      UINT16 colour;
821      UINT32 code;
822      UINT32 rom_a12_7;
852823
853824      /* End of sprite list marker */
854      if (lockon_hud_ram[offs + 1] & 0x8000)
825      if (state->hud_ram[offs + 1] & 0x8000)
855826         break;
856827
857      y_pos   = lockon_hud_ram[offs] & 0x1ff;
858      x_pos   = lockon_hud_ram[offs + 1] & 0x1ff;
859      x_size   = (lockon_hud_ram[offs + 1] >> 12) & 7;
860      code   = (lockon_hud_ram[offs] >> 9) & 0x7f;
861      colour   = 0x200 + ((lockon_hud_ram[offs + 1] >> 9) & 7);
862      layout   = (code >> 5) & 3;
828      y_pos   = state->hud_ram[offs] & 0x1ff;
829      x_pos   = state->hud_ram[offs + 1] & 0x1ff;
830      x_size = (state->hud_ram[offs + 1] >> 12) & 7;
831      code   = (state->hud_ram[offs] >> 9) & 0x7f;
832      colour = 0x200 + ((state->hud_ram[offs + 1] >> 9) & 7);
833      layout = (code >> 5) & 3;
863834
864835      rom_a12_7 = (code & 0xfe) << 6;
865836
r7500r7501
888859
889860         for (xt = 0; xt <= x_size; ++xt)
890861         {
891            UINT32   rom_a6_3;
892            UINT32   px;
862            UINT32 rom_a6_3;
863            UINT32 px;
893864            UINT8   gfx_strip;
894865
895866            if (layout == 3)
r7500r7501
934905
935906VIDEO_START( lockon )
936907{
937   lockon_tilemap = tilemap_create(machine, get_lockon_tile_info, tilemap_scan_rows, 8, 8, 64, 32);
938   tilemap_set_transparent_pen(lockon_tilemap, 0);
908   lockon_state *state = (lockon_state *)machine->driver_data;
939909
910   state->tilemap = tilemap_create(machine, get_lockon_tile_info, tilemap_scan_rows, 8, 8, 64, 32);
911   tilemap_set_transparent_pen(state->tilemap, 0);
912
940913   /* Allocate the two frame buffers for rotation */
941   back_buffer = auto_bitmap_alloc(machine, 512, 512, BITMAP_FORMAT_INDEXED16);
942   front_buffer = auto_bitmap_alloc(machine, 512, 512, BITMAP_FORMAT_INDEXED16);
914   state->back_buffer = auto_bitmap_alloc(machine, 512, 512, BITMAP_FORMAT_INDEXED16);
915   state->front_buffer = auto_bitmap_alloc(machine, 512, 512, BITMAP_FORMAT_INDEXED16);
943916
944917   /* 2kB of object ASIC palette RAM */
945   obj_pal_ram = auto_alloc_array(machine, UINT8, 2048);
918   state->obj_pal_ram = auto_alloc_array(machine, UINT8, 2048);
946919
947920   /* Timer for ground display list callback */
948   bufend_timer = timer_alloc(machine, bufend_callback, NULL);
921   state->bufend_timer = timer_alloc(machine, bufend_callback, NULL);
949922
950923   /* Timer for the CRTC cursor pulse */
951   cursor_timer = timer_alloc(machine, cursor_callback, NULL);
952   timer_adjust_oneshot(cursor_timer, video_screen_get_time_until_pos(machine->primary_screen, CURSOR_YPOS, CURSOR_XPOS), 0);
924   state->cursor_timer = timer_alloc(machine, cursor_callback, NULL);
925   timer_adjust_oneshot(state->cursor_timer, video_screen_get_time_until_pos(machine->primary_screen, CURSOR_YPOS, CURSOR_XPOS), 0);
926
927   state_save_register_global_bitmap(machine, state->back_buffer);
928   state_save_register_global_bitmap(machine, state->front_buffer);
929   state_save_register_global_pointer(machine, state->obj_pal_ram, 2048);
953930}
954931
955932VIDEO_UPDATE( lockon )
956933{
934   lockon_state *state = (lockon_state *)screen->machine->driver_data;
935
957936   /* If screen output is disabled, fill with black */
958   if ( !BIT(lockon_ctrl_reg, 7) )
937   if (!BIT(state->ctrl_reg, 7))
959938   {
960939      bitmap_fill(bitmap, cliprect, get_black_pen(screen->machine));
961940      return 0;
962941   }
963942
964943   /* Scan out the frame buffer in rotated order */
965   rotate_draw(bitmap, cliprect);
944   rotate_draw(screen->machine, bitmap, cliprect);
966945
967946   /* Draw the character tilemap */
968   tilemap_draw(bitmap, cliprect, lockon_tilemap, 0, 0);
947   tilemap_draw(bitmap, cliprect, state->tilemap, 0, 0);
969948
970949   /* Draw the HUD */
971950   hud_draw(screen->machine, bitmap, cliprect);
r7500r7501
975954
976955VIDEO_EOF( lockon )
977956{
957   lockon_state *state = (lockon_state *)machine->driver_data;
958
978959   /* Swap the frame buffers */
979   bitmap_t *tmp = front_buffer;
980   front_buffer = back_buffer;
981   back_buffer = tmp;
960   bitmap_t *tmp = state->front_buffer;
961   state->front_buffer = state->back_buffer;
962   state->back_buffer = tmp;
982963
983964   /* Draw the frame buffer layers */
984965   scene_draw(machine);
985966   ground_draw(machine);
986967   objects_draw(machine);
987
988968}
src/mame/video/boogwing.c
r7500r7501
11#include "emu.h"
2#include "includes/deco16ic.h"
2#include "includes/boogwing.h"
3#include "video/deco16ic.h"
34
4static void draw_sprites(running_machine *machine, bitmap_t *bitmap,const rectangle *cliprect, UINT16* spriteram_base, int gfx_region)
5static void draw_sprites( running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, UINT16* spriteram_base, int gfx_region )
56{
7   boogwing_state *state = (boogwing_state *)machine->driver_data;
68   int offs;
7   int flipscreen=!flip_screen_get(machine);
9   int flipscreen = !flip_screen_get(machine);
10   UINT16 priority = deco16ic_priority_r(state->deco16ic, 0, 0xffff);
811
9   for (offs = 0x400-4;offs >= 0;offs -= 4)
12   for (offs = 0x400 - 4; offs >= 0; offs -= 4)
1013   {
11      int x,y,sprite,colour,multi,fx,fy,inc,flash,mult,pri=0,spri=0;
14      int x, y, sprite, colour, multi, fx, fy, inc, flash, mult, pri = 0, spri = 0;
1215      int alpha = 0xff;
1316
14      sprite = spriteram_base[offs+1];
15      if (!sprite) continue;
17      sprite = spriteram_base[offs + 1];
18      if (!sprite)
19         continue;
1620
1721      y = spriteram_base[offs];
18      flash=y&0x1000;
19      if (flash && (video_screen_get_frame_number(machine->primary_screen) & 1)) continue;
22      flash = y & 0x1000;
23      if (flash && (video_screen_get_frame_number(machine->primary_screen) & 1))
24         continue;
2025
21      x = spriteram_base[offs+2];
22      colour = (x >>9) & 0x1f;
26      x = spriteram_base[offs + 2];
27      colour = (x >> 9) & 0x1f;
2328
2429      fx = y & 0x2000;
2530      fy = y & 0x4000;
2631      multi = (1 << ((y & 0x0600) >> 9)) - 1;   /* 1x, 2x, 4x, 8x height */
2732
2833      // Todo:  This should be verified from the prom
29      if (gfx_region==4)
34      if (gfx_region == 4)
3035      {
3136         // Sprite 2 priority vs sprite 1
32         if ((spriteram_base[offs+2]&0xc000)==0xc000)
33            spri=4;
34         else if ((spriteram_base[offs+2]&0xc000))
35            spri=16;
37         if ((spriteram_base[offs + 2] & 0xc000) == 0xc000)
38            spri = 4;
39         else if ((spriteram_base[offs + 2] & 0xc000))
40            spri = 16;
3641         else
37            spri=64;
42            spri = 64;
3843
3944         // Transparency
40         if (spriteram_base[offs+2]&0x2000)
45         if (spriteram_base[offs + 2] & 0x2000)
4146            alpha = 0x80;
4247
43         if (deco16_priority==0x2)
48         if (priority == 0x2)
4449         {
4550            // Additional sprite alpha in this mode
46            if (spriteram_base[offs+2]&0x8000)
51            if (spriteram_base[offs + 2] & 0x8000)
4752               alpha = 0x80;
4853
4954            // Sprite vs playfield
50            if ((spriteram_base[offs+2]&0xc000)==0xc000)
51               pri=4;
52            else if ((spriteram_base[offs+2]&0xc000)==0x8000)
53               pri=16;
55            if ((spriteram_base[offs + 2] & 0xc000) == 0xc000)
56               pri = 4;
57            else if ((spriteram_base[offs + 2] & 0xc000) == 0x8000)
58               pri = 16;
5459            else
55               pri=64;
60               pri = 64;
5661         }
5762         else
5863         {
59            if ((spriteram_base[offs+2]&0x8000)==0x8000)
60               pri=16;
64            if ((spriteram_base[offs + 2] & 0x8000) == 0x8000)
65               pri = 16;
6166            else
62               pri=64;
67               pri = 64;
6368         }
6469      }
6570      else
6671      {
6772         // Sprite 1 priority vs sprite 2
68         if (spriteram_base[offs+2]&0x8000)      // todo - check only in pri mode 2??
69            spri=8;
73         if (spriteram_base[offs + 2] & 0x8000)      // todo - check only in pri mode 2??
74            spri = 8;
7075         else
71            spri=32;
76            spri = 32;
7277
7378         // Sprite vs playfield
74         if (deco16_priority==0x1)
79         if (priority == 0x1)
7580         {
76            if ((spriteram_base[offs+2]&0xc000))
77               pri=16;
81            if ((spriteram_base[offs + 2] & 0xc000))
82               pri = 16;
7883            else
79               pri=64;
84               pri = 64;
8085         }
8186         else
8287         {
83            if ((spriteram_base[offs+2]&0xc000)==0xc000)
84               pri=4;
85            else if ((spriteram_base[offs+2]&0xc000)==0x8000)
86               pri=16;
88            if ((spriteram_base[offs + 2] & 0xc000) == 0xc000)
89               pri = 4;
90            else if ((spriteram_base[offs + 2] & 0xc000) == 0x8000)
91               pri = 16;
8792            else
88               pri=64;
93               pri = 64;
8994         }
9095      }
9196
r7500r7501
9499      if (x >= 320) x -= 512;
95100      if (y >= 256) y -= 512;
96101      y = 240 - y;
97        x = 304 - x;
102      x = 304 - x;
98103
99104      sprite &= ~multi;
100105      if (fy)
r7500r7501
107112
108113      if (flipscreen)
109114      {
110         y=240-y;
111         x=304-x;
112         if (fx) fx=0; else fx=1;
113         if (fy) fy=0; else fy=1;
114         mult=16;
115         y = 240 - y;
116         x = 304 - x;
117         if (fx) fx = 0; else fx = 1;
118         if (fy) fy = 0; else fy = 1;
119         mult = 16;
115120      }
116      else mult=-16;
121      else
122         mult = -16;
117123
118124      while (multi >= 0)
119125      {
120         deco16_pdrawgfx(
126         deco16ic_pdrawgfx(
127               state->deco16ic,
121128               bitmap, cliprect, machine->gfx[gfx_region],
122129               sprite - multi * inc,
123130               colour,
r7500r7501
130137   }
131138}
132139
133static int boogwing_bank_callback(const int bank)
140VIDEO_UPDATE( boogwing )
134141{
135   return ((bank>>4) & 0x7) * 0x1000;
136}
142   boogwing_state *state = (boogwing_state *)screen->machine->driver_data;
143   UINT16 flip = deco16ic_pf12_control_r(state->deco16ic, 0, 0xffff);
144   UINT16 priority = deco16ic_priority_r(state->deco16ic, 0, 0xffff);
137145
138static int boogwing_bank_callback2(const int bank)
139{
140   int offset=((bank>>4) & 0x7) * 0x1000;
141   if ((bank&0xf)==0xa)
142      offset+=0x800; // strange - transporter level
143   return offset;
144}
146   flip_screen_set(screen->machine, BIT(flip, 7));
147   deco16ic_pf12_update(state->deco16ic, state->pf1_rowscroll, state->pf2_rowscroll);
148   deco16ic_pf34_update(state->deco16ic, state->pf3_rowscroll, state->pf4_rowscroll);
145149
146VIDEO_START(boogwing)
147{
148   deco16_2_video_init(machine, 0);
149
150   deco16_set_tilemap_bank_callback(1,boogwing_bank_callback);
151   deco16_set_tilemap_bank_callback(2,boogwing_bank_callback2);
152   deco16_set_tilemap_bank_callback(3,boogwing_bank_callback2);
153   deco16_set_tilemap_colour_base(1,0);
154   deco16_set_tilemap_transparency_mask(1, 0x1f); // 5bpp graphics
155}
156
157VIDEO_UPDATE(boogwing)
158{
159   flip_screen_set(screen->machine,  deco16_pf12_control[0]&0x80 );
160   deco16_pf12_update(deco16_pf1_rowscroll,deco16_pf2_rowscroll);
161   deco16_pf34_update(deco16_pf3_rowscroll,deco16_pf4_rowscroll);
162
163150   /* Draw playfields */
164   deco16_clear_sprite_priority_bitmap();
165   bitmap_fill(bitmap,cliprect,screen->machine->pens[0x400]); /* pen not confirmed */
166   bitmap_fill(screen->machine->priority_bitmap,NULL,0);
151   deco16ic_clear_sprite_priority_bitmap(state->deco16ic);
152   bitmap_fill(bitmap, cliprect, screen->machine->pens[0x400]); /* pen not confirmed */
153   bitmap_fill(screen->machine->priority_bitmap, NULL, 0);
167154
168155   // bit&0x8 is definitely some kind of palette effect
169156   // bit&0x4 combines playfields
170   if ((deco16_priority&0x7)==0x5)
157   if ((priority & 0x7) == 0x5)
171158   {
172      deco16_tilemap_2_draw(screen,bitmap,cliprect,TILEMAP_DRAW_OPAQUE,0);
173      deco16_tilemap_34_combine_draw(screen,bitmap,cliprect,0,32);
159      deco16ic_tilemap_2_draw(state->deco16ic, bitmap, cliprect, TILEMAP_DRAW_OPAQUE, 0);
160      deco16ic_tilemap_34_combine_draw(state->deco16ic, bitmap, cliprect, 0, 32);
174161   }
175   else if ((deco16_priority&0x7)==0x1 || (deco16_priority&0x7)==0x2)
162   else if ((priority & 0x7) == 0x1 || (priority & 0x7) == 0x2)
176163   {
177      deco16_tilemap_4_draw(screen,bitmap,cliprect,TILEMAP_DRAW_OPAQUE,0);
178      deco16_tilemap_2_draw(screen,bitmap,cliprect,0,8);
179      deco16_tilemap_3_draw(screen,bitmap,cliprect,0,32);
164      deco16ic_tilemap_4_draw(state->deco16ic, bitmap, cliprect, TILEMAP_DRAW_OPAQUE, 0);
165      deco16ic_tilemap_2_draw(state->deco16ic, bitmap, cliprect, 0, 8);
166      deco16ic_tilemap_3_draw(state->deco16ic, bitmap, cliprect, 0, 32);
180167   }
181   else if ((deco16_priority&0x7)==0x3)
168   else if ((priority & 0x7) == 0x3)
182169   {
183      deco16_tilemap_4_draw(screen,bitmap,cliprect,TILEMAP_DRAW_OPAQUE,0);
184      deco16_tilemap_2_draw(screen,bitmap,cliprect,0,8);
170      deco16ic_tilemap_4_draw(state->deco16ic, bitmap, cliprect, TILEMAP_DRAW_OPAQUE, 0);
171      deco16ic_tilemap_2_draw(state->deco16ic, bitmap, cliprect, 0, 8);
185172
186173      // This mode uses playfield 3 to shadow sprites & playfield 2 (instead of
187174      // regular alpha-blending, the destination is inverted).  Not yet implemented.
188//      deco16_tilemap_3_draw(screen,bitmap,cliprect,TILEMAP_DRAW_ALPHA(0x80),32);
175      // deco16ic_tilemap_3_draw(state->deco16ic, bitmap, cliprect, TILEMAP_DRAW_ALPHA(0x80), 32);
189176   }
190177   else
191178   {
192      deco16_tilemap_4_draw(screen,bitmap,cliprect,TILEMAP_DRAW_OPAQUE,0);
193      deco16_tilemap_3_draw(screen,bitmap,cliprect,0,8);
194      deco16_tilemap_2_draw(screen,bitmap,cliprect,0,32);
179      deco16ic_tilemap_4_draw(state->deco16ic, bitmap, cliprect, TILEMAP_DRAW_OPAQUE, 0);
180      deco16ic_tilemap_3_draw(state->deco16ic, bitmap, cliprect, 0, 8);
181      deco16ic_tilemap_2_draw(state->deco16ic, bitmap, cliprect, 0, 32);
195182   }
196183
197184   draw_sprites(screen->machine, bitmap, cliprect, screen->machine->generic.buffered_spriteram.u16, 3);
198185   draw_sprites(screen->machine, bitmap, cliprect, screen->machine->generic.buffered_spriteram2.u16, 4);
199186
200   deco16_tilemap_1_draw(screen,bitmap,cliprect,0,0);
187   deco16ic_tilemap_1_draw(state->deco16ic, bitmap, cliprect, 0, 0);
201188   return 0;
202189}
src/mame/video/mugsmash.c
r7500r7501
2727
2828   mugsmash_state *state = (mugsmash_state *)machine->driver_data;
2929   const UINT16 *source = state->spriteram;
30   const UINT16 *finish = source+0x2000;
30   const UINT16 *finish = source + 0x2000;
3131   const gfx_element *gfx = machine->gfx[0];
3232
33   while( source<finish )
33   while (source < finish)
3434   {
3535      int xpos = source[0] & 0x00ff;
3636      int ypos = source[4] & 0x00ff;
3737      int num = (source[3] & 0x00ff) | ((source[2] & 0x00ff) << 8);
3838      int attr = source[1];
39      int flipx = (attr & 0x0080)>>7;
39      int flipx = (attr & 0x0080) >> 7;
4040      int colour = (attr & 0x000f);
4141
4242      xpos += ((attr & 0x0020) >> 5) * 0x100;
r7500r7501
7171    */
7272
7373   mugsmash_state *state = (mugsmash_state *)machine->driver_data;
74   int tileno,colour,fx;
74   int tileno, colour, fx;
7575
76   tileno = state->videoram1[tile_index *2 +1];
77   colour = state->videoram1[tile_index *2] & 0x000f;
78   fx = (state->videoram1[tile_index *2] & 0xc0) >>6;
76   tileno = state->videoram1[tile_index * 2 + 1];
77   colour = state->videoram1[tile_index * 2] & 0x000f;
78   fx = (state->videoram1[tile_index * 2] & 0xc0) >> 6;
7979
80   SET_TILE_INFO(1,tileno,colour,TILE_FLIPYX(fx));
80   SET_TILE_INFO(1, tileno, colour, TILE_FLIPYX(fx));
8181}
8282
8383WRITE16_HANDLER( mugsmash_videoram1_w )
r7500r7501
8585   mugsmash_state *state = (mugsmash_state *)space->machine->driver_data;
8686
8787   state->videoram1[offset] = data;
88   tilemap_mark_tile_dirty(state->tilemap1,offset/2);
88   tilemap_mark_tile_dirty(state->tilemap1, offset / 2);
8989}
9090
9191static TILE_GET_INFO( get_mugsmash_tile_info2 )
r7500r7501
100100    */
101101
102102   mugsmash_state *state = (mugsmash_state *)machine->driver_data;
103   int tileno,colour,fx;
103   int tileno, colour, fx;
104104
105   tileno = state->videoram2[tile_index *2 +1];
106   colour = state->videoram2[tile_index *2] & 0x000f;
107   fx = (state->videoram2[tile_index *2] & 0xc0) >>6;
105   tileno = state->videoram2[tile_index * 2 + 1];
106   colour = state->videoram2[tile_index * 2] & 0x000f;
107   fx = (state->videoram2[tile_index * 2] & 0xc0) >> 6;
108108
109   SET_TILE_INFO(1,tileno,16+colour,TILE_FLIPYX(fx));
109   SET_TILE_INFO(1, tileno, 16 + colour, TILE_FLIPYX(fx));
110110}
111111
112112WRITE16_HANDLER( mugsmash_videoram2_w )
r7500r7501
114114   mugsmash_state *state = (mugsmash_state *)space->machine->driver_data;
115115
116116   state->videoram2[offset] = data;
117   tilemap_mark_tile_dirty(state->tilemap2,offset/2);
117   tilemap_mark_tile_dirty(state->tilemap2, offset / 2);
118118}
119119
120120WRITE16_HANDLER (mugsmash_reg_w)
r7500r7501
127127   switch (offset)
128128   {
129129   case 0:
130      tilemap_set_scrollx(state->tilemap2,0, state->regs1[2]+7);
130      tilemap_set_scrollx(state->tilemap2, 0, state->regs1[2] + 7);
131131      break;
132132   case 1:
133      tilemap_set_scrolly(state->tilemap2,0, state->regs1[3]+4);
133      tilemap_set_scrolly(state->tilemap2, 0, state->regs1[3] + 4);
134134      break;
135135   case 2:
136      tilemap_set_scrollx(state->tilemap1,0, state->regs1[0]+3);
136      tilemap_set_scrollx(state->tilemap1, 0, state->regs1[0] + 3);
137137      break;
138138   case 3:
139      tilemap_set_scrolly(state->tilemap1,0, state->regs1[1]+4);
139      tilemap_set_scrolly(state->tilemap1, 0, state->regs1[1] + 4);
140140      break;
141141   }
142142}
r7500r7501
145145{
146146   mugsmash_state *state = (mugsmash_state *)machine->driver_data;
147147
148   state->tilemap1 = tilemap_create(machine, get_mugsmash_tile_info1,tilemap_scan_rows, 16, 16,32,32);
149   tilemap_set_transparent_pen(state->tilemap1,0);
148   state->tilemap1 = tilemap_create(machine, get_mugsmash_tile_info1, tilemap_scan_rows, 16, 16, 32, 32);
149   tilemap_set_transparent_pen(state->tilemap1, 0);
150150
151   state->tilemap2 = tilemap_create(machine, get_mugsmash_tile_info2,tilemap_scan_rows, 16, 16,32,32);
151   state->tilemap2 = tilemap_create(machine, get_mugsmash_tile_info2, tilemap_scan_rows, 16, 16, 32, 32);
152152}
153153
154154VIDEO_UPDATE( mugsmash )
155155{
156156   mugsmash_state *state = (mugsmash_state *)screen->machine->driver_data;
157157
158   tilemap_draw(bitmap,cliprect,state->tilemap2,0,0);
159   tilemap_draw(bitmap,cliprect,state->tilemap1,0,0);
160   draw_sprites(screen->machine,bitmap,cliprect);
158   tilemap_draw(bitmap, cliprect, state->tilemap2, 0, 0);
159   tilemap_draw(bitmap, cliprect, state->tilemap1, 0, 0);
160   draw_sprites(screen->machine, bitmap, cliprect);
161161   return 0;
162162}
src/mame/video/hng64.c
r7500r7501
16571657static float modelViewMatrix[16];
16581658static float cameraMatrix[16];
16591659
1660static float lightStrength;
1661static float lightVector[3];
1662
16601663struct polyVert
16611664{
16621665   float worldCoords[4];   // World space coordinates (X Y Z 1.0)
r7500r7501
16771680   float faceNormal[4];      // Normal of the face overall - for calculating visibility and flat-shading...
16781681   int visible;            // Polygon visibility in scene
16791682
1680   INT8 texIndex;            // Which texture to draw from (0x00-0x0f)
1681   INT8 texType;            // How to index into the texture
1683   UINT8 texIndex;            // Which texture to draw from (0x00-0x0f)
1684   UINT8 texType;            // How to index into the texture
1685   UINT8 texPageSmall;         // Does this polygon use 'small' texture pages?
1686   UINT8 texPageHorizOffset;   // If it does use small texture pages, how far is this page horizontally offset?
1687   UINT8 texPageVertOffset;    // If it does use small texture pages, how far is this page vertically offset?
1688
16821689   UINT32 palOffset;         // The base offset where this object's palette starts.
16831690   UINT32 palPageSize;         // The size of the palette page that is being pointed to.
16841691
r7500r7501
16881695static void setIdentity(float *matrix);
16891696static void matmul4(float *product, const float *a, const float *b);
16901697static void vecmatmul4(float *product, const float *a, const float *b);
1691//static float vecDotProduct( const float *a, const float *b);
1692//static void normalize(float* x);
1698static float vecDotProduct(const float *a, const float *b);
1699static void normalize(float* x);
16931700
16941701static void performFrustumClip(struct polygon *p);
16951702static void drawShaded(running_machine *machine, struct polygon *p);
r7500r7501
17771784   cameraMatrix[15] = 1.0f;
17781785}
17791786
1787// Operation 0010
1788// Lighting information
1789static void setLighting(const UINT16* packet)
1790{
1791   /*//////////////
1792    // PACKET FORMAT
1793    // [0]  - 0010 ... ID
1794    // [1]  - ???? ... ? Always zero
1795    // [2]  - ???? ... ? Always zero
1796    // [3]  - xxxx ... X light vector direction
1797    // [4]  - xxxx ... Y light vector direction
1798    // [5]  - xxxx ... Z light vector direction
1799    // [6]  - ???? ... ? Seems to be another light vector ?
1800    // [7]  - ???? ... ? Seems to be another light vector ?
1801    // [8]  - ???? ... ? Seems to be another light vector ?
1802    // [9]  - xxxx ... Strength according to sams64_2 [0000,01ff]
1803    // [10] - ???? ... ? Used in fatfurwa
1804    // [11] - ???? ... ? Used in fatfurwa
1805    // [12] - ???? ... ? Used in fatfurwa
1806    // [13] - ???? ... ? Used in fatfurwa
1807    // [14] - ???? ... ? Used in fatfurwa
1808    // [15] - ???? ... ? Used in fatfurwa
1809    ////////////*/
1810   if (packet[1] != 0x0000) printf("ZOMG!  packet[1] in setLighting function is non-zero!\n");
1811   if (packet[2] != 0x0000) printf("ZOMG!  packet[2] in setLighting function is non-zero!\n");
1812
1813    lightVector[0] = uToF(packet[3]);
1814    lightVector[1] = uToF(packet[4]);
1815    lightVector[2] = uToF(packet[5]);
1816    lightStrength = uToF(packet[9]);
1817}
1818
17801819// Operation 0011
17811820// Palette / Model flags?
17821821static void set3dFlags(const UINT16* packet)
r7500r7501
18131852    // [1]  - ???? ... ? Contains a value in buriki's 'how to play' - probably a projection window/offset.
18141853    // [2]  - ???? ... ? Contains a value in buriki's 'how to play' - probably a projection window/offset.
18151854    // [3]  - ???? ... ? Contains a value
1816    // [4]  - ???? ... ? Contains a value in buriki
1817    // [5]  - ???? ... ? Contains a value
1818    // [6]  - xxxx ... camera projection near
1819    // [7]  - xxxx ... camera projection far
1820    // [8]  - ???? ... ? Contains a value
1821    // [9]  - ???? ... ? Contains a value
1822    // [10] - xxxx ... camera projection right
1823    // [11] - xxxx ... camera projection left
1824    // [12] - xxxx ... camera projection top
1825    // [13] - xxxx ... camera projection bottom
1855    // [4]  - xxxx ... Camera projection near scale
1856    // [5]  - xxxx ... Camera projection near height(?)
1857    // [6]  - xxxx ... Camera projection near width(?)
1858    // [7]  - xxxx ... Camera projection far scale
1859    // [8]  - xxxx ... Camera projection far height(?)
1860    // [9]  - xxxx ... Camera projection far width(?)
1861    // [10] - xxxx ... Camera projection right
1862    // [11] - xxxx ... Camera projection left
1863    // [12] - xxxx ... Camera projection top
1864    // [13] - xxxx ... Camera projection bottom
18261865    // [14] - ???? ... ? Gets data during buriki door-run
18271866    // [15] - ???? ... ? Gets data during buriki door-run
18281867    ////////////*/
r7500r7501
18341873   right   = uToF(packet[10]);
18351874   top     = uToF(packet[12]);
18361875   bottom  = uToF(packet[13]);
1837   near_   = uToF(packet[6]);
1838   far_    = uToF(packet[7]);
1876   near_   = uToF(packet[6]) + (uToF(packet[6]) * uToF(packet[4]));
1877   far_    = uToF(packet[9]) + (uToF(packet[9]) * uToF(packet[7]));
1878   // (note are likely not 100% correct - I'm not using one of the parameters)
18391879
18401880   projectionMatrix[0]  = (2.0f*near_)/(right-left);
18411881   projectionMatrix[1]  = 0.0f;
r7500r7501
18651905   /*//////////////
18661906    // PACKET FORMAT
18671907    // [0]  - 0100 ... ID
1868    // [1]  - xxxx ... Flags
1908    // [1]  - ?--- ... Flags [?000 = ???
1909    //                        0?00 = ???
1910    //                        00?0 = ???
1911    //                        000? = ???]
1912    // [1]  - -?-- ... Flags [?000 = ???
1913    //                        0?00 = ???
1914    //                        00?0 = ???
1915    //                        000x = Dynamic palette bit]
1916    // [1]  - --?- ... Flags [?000 = ???
1917    //                        0?00 = ???
1918    //                        00?0 = ???
1919    //                        000? = ???]
1920    // [1]  - ---? ... Flags [x000 = Apply lighting bit
1921    //                        0?00 = ???
1922    //                        00?0 = ???
1923    //                        000? = ???]
18691924    // [2]  - xxxx ... offset into ROM
18701925    // [3]  - xxxx ... offset into ROM
18711926    // [4]  - xxxx ... Transformation matrix
r7500r7501
19542009   UINT32  threeDOffset = (((UINT32)packet[2]) << 16) | ((UINT32)packet[3]);
19552010   UINT16* threeDPointer = &threeDRoms[threeDOffset * 3];
19562011
1957   if (threeDOffset >= 0x0c00000 && hng64_mcu_type == SHOOT_MCU)
2012   if (threeDOffset >= memory_region_length(machine, "verts"))
19582013   {
19592014      printf("Strange geometry packet: (ignoring)\n");
19602015      printPacket(packet, 1);
r7500r7501
20222077         ////////////////////////////////////////////
20232078         // GATHER A SINGLE TRIANGLE'S INFORMATION //
20242079         ////////////////////////////////////////////
2025         /*/////////////////////////
2026            // SINGLE POLY CHUNK FORMAT
2027            // [0] ??-- - ???? unused ????
2028            // [0] --xx - Chunk type
2029            // [1] ?--- - Flags [x000 = ???
2030                                 0x00 = ???
2031                                 00x0 = ???
2032                                 000x = low-res texture flag]
2033            // [1] -x-- - Explicit palette index.
2034            // [1] --?- - Unknown
2035            // [1] ---x - Texture index
2036            // [2] ???? - Used in fatfurwa 'hng64' & everywhere in roadedge
2037            /////////////////////////*/
2080         // SINGLE POLY CHUNK FORMAT
2081         // [0] ??-- - ???
2082         // [0] --xx - Chunk type
2083         //
2084         // [1] ?--- - Flags [?000 = ???
2085         //                   0?00 = ???
2086         //                   00?0 = ???
2087         //                   000x = low-res texture flag]
2088         // [1] -x-- - Explicit 0x80 palette index.
2089         // [1] --x- - Explicit 0x08 palette index.
2090         // [1] ---x - Texture page (1024x1024 bytes)
2091         //
2092         // [2] x--- - Texture Flags [x000 = Uses 4x4 sub-texture pages?
2093         //                           0?00 = ??? - differen sub-page size?  SNK logo in RoadEdge.  Always on in bbust2.
2094         //                           00xx = Horizontal sub-texture page index]
2095         // [2] -?-- - ??? - barely visible (thus far) in roadedge
2096         // [2] --x- - Texture Flags [?000 = ???
2097         //                           0xx0 = Vertical sub-texture page index.
2098         //                           000? = ???]
2099         // [2] ---? - ???
2100         //////////////////////////
20382101         UINT8 chunkType = chunkOffset[0] & 0x00ff;
20392102
20402103         // Debug - ajg
r7500r7501
20572120         if (chunkOffset[1] & 0x1000) polys[*numPolys].texType = 0x1;
20582121         else                   polys[*numPolys].texType = 0x0;
20592122
2123         polys[*numPolys].texPageSmall       = (chunkOffset[2] & 0x8000) >> 15;   // Just a guess.
2124         polys[*numPolys].texPageHorizOffset = (chunkOffset[2] & 0x3000) >> 12;
2125         polys[*numPolys].texPageVertOffset  = (chunkOffset[2] & 0x0060) >> 5;
2126
20602127         polys[*numPolys].texIndex = chunkOffset[1] & 0x000f;
20612128
20622129
r7500r7501
20692136                      So instead we're looking for a bit that is on for XRally & Buriki, but noone else. */
20702137         if (hng64_3dregs[0x00/4] & 0x2000)
20712138         {
2072            polys[*numPolys].palOffset += 0x800;
2139            if (strcmp(machine->basename, "roadedge"))
2140               polys[*numPolys].palOffset += 0x800;
20732141         }
20742142
20752143         //UINT16 explicitPaletteValue0 = ((chunkOffset[?] & 0x????) >> ?) * 0x800;
r7500r7501
22862354         }
22872355         matmul4(modelViewMatrix, modelViewMatrix, objectMatrix);
22882356
2357         // LIGHTING
2358         if (packet[1] & 0x0008 && lightStrength > 0.0f)
2359         {
2360            for (int v = 0; v < 3; v++)
2361            {
2362               float transformedNormal[4];
2363               vecmatmul4(transformedNormal, objectMatrix, polys[*numPolys].vert[v].normal);
2364               normalize(transformedNormal);
2365               normalize(lightVector);
2366
2367               float intensity = vecDotProduct(transformedNormal, lightVector) * -1.0f;
2368               intensity = (intensity <= 0.0f) ? (0.0f) : (intensity);
2369               intensity *= lightStrength * 128.0f * 0.5f;     // HACK.  This 0.5 is completely arbitrary.
2370               intensity *= 255.0f;
2371               if (intensity >= 255.0f) intensity = 255.0f;
2372
2373               polys[*numPolys].vert[v].light[0] = intensity;
2374               polys[*numPolys].vert[v].light[1] = intensity;
2375               polys[*numPolys].vert[v].light[2] = intensity;
2376            }
2377         }
2378         else
2379         {
2380            // Just clear out the light values
2381            for (int v = 0; v < 3; v++)
2382            {
2383               polys[*numPolys].vert[v].light[0] = 0;
2384               polys[*numPolys].vert[v].light[1] = 0;
2385               polys[*numPolys].vert[v].light[2] = 0;
2386            }
2387         }
2388
2389
22892390         // BACKFACE CULL //
22902391         // EMPIRICAL EVIDENCE SEEMS TO SHOW THE HNG64 HARDWARE DOES NOT BACKFACE CULL //
22912392         /*
r7500r7501
23062407                polys[*numPolys].visible = 0;
23072408            */
23082409
2410
23092411         // BEHIND-THE-CAMERA CULL //
23102412         vecmatmul4(cullRay, modelViewMatrix, polys[*numPolys].vert[0].worldCoords);
23112413         if (cullRay[2] > 0.0f)            // Camera is pointing down -Z
r7500r7501
23772479      setCameraTransformation(packet);
23782480      break;
23792481
2380   case 0x0010:   // Unknown
2381      // Called very interestingly per-frame in every game.  Floats for sure.  Light-related?
2482   case 0x0010:   // Lighting information.
2483      //if (packet[9]) printPacket(packet, 1);
2484      setLighting(packet);
23822485      break;
23832486
23842487   case 0x0011:   // Palette / Model flags?
r7500r7501
24982601/////////////////////
24992602
25002603/* 4x4 matrix multiplication */
2501static void matmul4( float *product, const float *a, const float *b )
2604static void matmul4(float *product, const float *a, const float *b )
25022605{
25032606   int i;
25042607   for (i = 0; i < 4; i++)
r7500r7501
25162619}
25172620
25182621/* vector by 4x4 matrix multiply */
2519static void vecmatmul4( float *product, const float *a, const float *b)
2622static void vecmatmul4(float *product, const float *a, const float *b)
25202623{
25212624   const float bi0 = b[0];
25222625   const float bi1 = b[1];
r7500r7501
25292632   product[3] = bi0 * a[3] + bi1 * a[7] + bi2 * a[11] + bi3 * a[15];
25302633}
25312634
2532#ifdef UNUSED_FUNCTION
2533static float vecDotProduct( const float *a, const float *b)
2635static float vecDotProduct(const float *a, const float *b)
25342636{
25352637   return ((a[0]*b[0]) + (a[1]*b[1]) + (a[2]*b[2]));
25362638}
2537#endif
25382639
25392640static void setIdentity(float *matrix)
25402641{
r7500r7501
25622663*/
25632664}
25642665
2565#ifdef UNUSED_FUNCTION
25662666static void normalize(float* x)
25672667{
25682668   double l2 = (x[0]*x[0]) + (x[1]*x[1]) + (x[2]*x[2]);
2569   double l=sqrt(l2);
2669   double l = sqrt(l2);
25702670
25712671   x[0] = (float)(x[0] / l);
25722672   x[1] = (float)(x[1] / l);
25732673   x[2] = (float)(x[2] / l);
25742674}
2575#endif
25762675
25772676
25782677
r7500r7501
28262925// polygon rendering //
28272926///////////////////////
28282927
2928struct polygonRasterOptions
2929{
2930   UINT8 texType;
2931   UINT8 texIndex;
2932   UINT8 texPageSmall;
2933   UINT8 texPageHorizOffset;
2934   UINT8 texPageVertOffset;
2935   int palOffset;
2936   int palPageSize;
2937   int debugColor;
2938};
2939
28292940/*********************************************************************/
28302941/**   FillSmoothTexPCHorizontalLine                                 **/
28312942/**     Input: Color Buffer (framebuffer), depth buffer, width and  **/
r7500r7501
28362947/**     Output: none                                                **/
28372948/*********************************************************************/
28382949INLINE void FillSmoothTexPCHorizontalLine(running_machine *machine,
2839                                int textureType, int palOffset, int palPageSize,
2840                                int texIndex, int debugColor,
2950                                const polygonRasterOptions& prOptions,
28412951                                int x_start, int x_end, int y, float z_start, float z_delta,
28422952                                float w_start, float w_delta, float r_start, float r_delta,
28432953                                float g_start, float g_delta, float b_start, float b_delta,
r7500r7501
28492959   UINT8 paletteEntry = 0;
28502960   float t_coord, s_coord;
28512961   const UINT8 *gfx = memory_region(machine, "textures");
2852   const UINT8 *textureOffset = &gfx[texIndex * 1024 * 1024];
2962   const UINT8 *textureOffset = &gfx[prOptions.texIndex * 1024 * 1024];
28532963
28542964   for (; x_start <= x_end; x_start++)
28552965   {
r7500r7501
28592969         t_coord = t_start / w_start;
28602970         s_coord = s_start / w_start;
28612971
2862         if ((debugColor & 0xff000000) == 0x01000000)
2972         if ((prOptions.debugColor & 0xff000000) == 0x01000000)
28632973         {
28642974            // UV COLOR MODE
28652975            *cb = MAKE_ARGB(255, (UINT8)(s_coord*255.0f), (UINT8)(t_coord*255.0f), (UINT8)(0));
28662976            *db = z_start;
28672977         }
2868         else if ((debugColor & 0xff000000) == 0x02000000)
2978         else if ((prOptions.debugColor & 0xff000000) == 0x02000000)
28692979         {
28702980            // Lit
28712981            *cb = MAKE_ARGB(255, (UINT8)(r_start/w_start), (UINT8)(g_start/w_start), (UINT8)(b_start/w_start));
28722982            *db = z_start;
28732983         }
2874         else if ((debugColor & 0xff000000) == 0xff000000)
2984         else if ((prOptions.debugColor & 0xff000000) == 0xff000000)
28752985         {
28762986            // DEBUG COLOR MODE
2877            *cb = debugColor;
2987            *cb = prOptions.debugColor;
28782988            *db = z_start;
28792989         }
28802990         else
28812991         {
2882            // TEXTURED
2883            if (textureType == 0x0)
2884               paletteEntry = textureOffset[(((int)(s_coord*1024.0f))*1024 + (int)(t_coord*1024.0f))];
2885            else if (textureType == 0x1)
2886               paletteEntry = textureOffset[(((int)(s_coord*512.0f))*1024 + (int)(t_coord*512.0f))];
2992            float textureS = 0.0f;
2993            float textureT = 0.0f;
28872994
2995            // Standard & Half-Res textures
2996            if (prOptions.texType == 0x0)
2997            {
2998               textureS = s_coord * 1024.0f;
2999               textureT = t_coord * 1024.0f;
3000            }
3001            else if (prOptions.texType == 0x1)
3002            {
3003               textureS = s_coord * 512.0f;
3004               textureT = t_coord * 512.0f;
3005            }
3006
3007            // Small-Page textures
3008            if (prOptions.texPageSmall)
3009            {
3010               textureT = fmod(textureT, 256.0f);
3011               textureS = fmod(textureS, 256.0f);
3012
3013               textureT += (256.0f * prOptions.texPageHorizOffset);
3014               textureS += (256.0f * prOptions.texPageVertOffset);
3015            }
3016            paletteEntry = textureOffset[((int)textureS)*1024 + (int)textureT];
3017
28883018            // Naieve Alpha Implementation (?) - don't draw if you're at texture index 0...
28893019            if (paletteEntry != 0)
28903020            {
2891               paletteEntry %= palPageSize;
3021               // The color out of the texture
3022               paletteEntry %= prOptions.palPageSize;
3023               UINT32 color = machine->pens[prOptions.palOffset + paletteEntry];
28923024
2893               // Greyscale texture test.
2894               // *cb = MAKE_ARGB(255, (UINT8)paletteEntry, (UINT8)paletteEntry, (UINT8)paletteEntry);
2895               *cb = machine->pens[palOffset + paletteEntry];
3025               // Application of the lighting
3026               UINT32 red   = RGB_RED(color)   + (UINT8)(r_start/w_start);
3027               UINT32 green = RGB_GREEN(color) + (UINT8)(g_start/w_start);
3028               UINT32 blue  = RGB_BLUE(color)  + (UINT8)(b_start/w_start);
3029
3030               // Clamp and finalize
3031               if (red >= 255) red = 255;
3032               if (green >= 255) green = 255;
3033               if (blue >= 255) blue = 255;
3034               color = MAKE_ARGB(255, (UINT8)red, (UINT8)green, (UINT8)blue);
3035
3036               *cb = color;
28963037               *db = z_start;
28973038            }
28983039         }
r7500r7501
29433084                                 float A[4], float B[4], float C[4],
29443085                                 float Ca[3], float Cb[3], float Cc[3], // PER-VERTEX RGB COLORS
29453086                                 float Ta[2], float Tb[2], float Tc[2], // PER-VERTEX (S,T) TEX-COORDS
2946                                 int textureType, int palOffset, int palPageSize,
2947                                 int texIndex, int debugColor)
3087                                 const polygonRasterOptions& prOptions)
29483088{
29493089   // Get our order of points by increasing y-coord
29503090   float *p_min = ((A[1] <= B[1]) && (A[1] <= C[1])) ? A : ((B[1] <= A[1]) && (B[1] <= C[1])) ? B : C;
r7500r7501
30413181   t_max = (p_max == A) ? ta : (p_max == B) ? tb : tc;
30423182
30433183   // Find out control points for y, this divides the triangle into upper and lower
3044   y_min  = (((int)p_min[1]) + 0.5 >= p_min[1]) ? p_min[1] : ((int)p_min[1]) + 1;
3045   y_max  = (((int)p_max[1]) + 0.5 <  p_max[1]) ? p_max[1] : ((int)p_max[1]) - 1;
3046   y_mid  = (((int)p_mid[1]) + 0.5 >= p_mid[1]) ? p_mid[1] : ((int)p_mid[1]) + 1;
3184   y_min  = (((int)p_min[1]) + 0.5 >= p_min[1]) ? (int)p_min[1] : ((int)p_min[1]) + 1;
3185   y_max  = (((int)p_max[1]) + 0.5 <  p_max[1]) ? (int)p_max[1] : ((int)p_max[1]) - 1;
3186   y_mid  = (((int)p_mid[1]) + 0.5 >= p_mid[1]) ? (int)p_mid[1] : ((int)p_mid[1]) + 1;
30473187
30483188   // Compute the slopes of each line, and color this is used to determine the interpolation
30493189   x1_slope = (p_max[0] - p_min[0]) / (p_max[1] - p_min[1]);
r7500r7501
30953235      // Compute the integer starting and ending points and the appropriate z by
30963236      // interpolating.  Remember the pixels are in the middle of the grid, i.e. (0.5,0.5,0.5)
30973237      if (x1_interp < x2_interp) {
3098         x_start    = ((((int)x1_interp) + 0.5) >= x1_interp) ? x1_interp : ((int)x1_interp) + 1;
3099         x_end      = ((((int)x2_interp) + 0.5) <  x2_interp) ? x2_interp : ((int)x2_interp) - 1;
3238         x_start    = ((((int)x1_interp) + 0.5) >= x1_interp) ? (int)x1_interp : ((int)x1_interp) + 1;
3239         x_end      = ((((int)x2_interp) + 0.5) <  x2_interp) ? (int)x2_interp : ((int)x2_interp) - 1;
31003240         z_delta_x  = (z2_interp - z1_interp) / (x2_interp - x1_interp);
31013241         w_delta_x  = (w2_interp - w1_interp) / (x2_interp - x1_interp);
31023242         r_delta_x  = (r2_interp - r1_interp) / (x2_interp - x1_interp);
r7500r7501
31143254         t_interp_x = t1_interp + (t2_interp - t1_interp) * t;
31153255
31163256      } else {
3117         x_start    = ((((int)x2_interp) + 0.5) >= x2_interp) ? x2_interp : ((int)x2_interp) + 1;
3118         x_end      = ((((int)x1_interp) + 0.5) <  x1_interp) ? x1_interp : ((int)x1_interp) - 1;
3257         x_start    = ((((int)x2_interp) + 0.5) >= x2_interp) ? (int)x2_interp : ((int)x2_interp) + 1;
3258         x_end      = ((((int)x1_interp) + 0.5) <  x1_interp) ? (int)x1_interp : ((int)x1_interp) - 1;
31193259         z_delta_x  = (z1_interp - z2_interp) / (x1_interp - x2_interp);
31203260         w_delta_x  = (w1_interp - w2_interp) / (x1_interp - x2_interp);
31213261         r_delta_x  = (r1_interp - r2_interp) / (x1_interp - x2_interp);
r7500r7501
31353275
31363276      // Pass the horizontal line to the filler, this could be put in the routine
31373277      // then interpolate for the next values of x and z
3138      FillSmoothTexPCHorizontalLine(machine, textureType, palOffset, palPageSize, texIndex, debugColor,
3278      FillSmoothTexPCHorizontalLine(machine, prOptions,
31393279         x_start, x_end, y_min, z_interp_x, z_delta_x, w_interp_x, w_delta_x,
31403280         r_interp_x, r_delta_x, g_interp_x, g_delta_x, b_interp_x, b_delta_x,
31413281         s_interp_x, s_delta_x, t_interp_x, t_delta_x);
r7500r7501
31753315   for (; y_mid <= y_max; y_mid++) {
31763316
31773317      if (x1_interp < x2_interp) {
3178         x_start    = ((((int)x1_interp) + 0.5) >= x1_interp) ? x1_interp : ((int)x1_interp) + 1;
3179         x_end      = ((((int)x2_interp) + 0.5) <  x2_interp) ? x2_interp : ((int)x2_interp) - 1;
3318         x_start    = ((((int)x1_interp) + 0.5) >= x1_interp) ? (int)x1_interp : ((int)x1_interp) + 1;
3319         x_end      = ((((int)x2_interp) + 0.5) <  x2_interp) ? (int)x2_interp : ((int)x2_interp) - 1;
31803320         z_delta_x  = (z2_interp - z1_interp) / (x2_interp - x1_interp);
31813321         w_delta_x  = (w2_interp - w1_interp) / (x2_interp - x1_interp);
31823322         r_delta_x  = (r2_interp - r1_interp) / (x2_interp - x1_interp);
r7500r7501
31943334         t_interp_x = t1_interp + (t2_interp - t1_interp) * t;
31953335
31963336      } else {
3197         x_start    = ((((int)x2_interp) + 0.5) >= x2_interp) ? x2_interp : ((int)x2_interp) + 1;
3198         x_end      = ((((int)x1_interp) + 0.5) <  x1_interp) ? x1_interp : ((int)x1_interp) - 1;
3337         x_start    = ((((int)x2_interp) + 0.5) >= x2_interp) ? (int)x2_interp : ((int)x2_interp) + 1;
3338         x_end      = ((((int)x1_interp) + 0.5) <  x1_interp) ? (int)x1_interp : ((int)x1_interp) - 1;
31993339         z_delta_x  = (z1_interp - z2_interp) / (x1_interp - x2_interp);
32003340         w_delta_x  = (w1_interp - w2_interp) / (x1_interp - x2_interp);
32013341         r_delta_x  = (r1_interp - r2_interp) / (x1_interp - x2_interp);
r7500r7501
32153355
32163356      // Pass the horizontal line to the filler, this could be put in the routine
32173357      // then interpolate for the next values of x and z
3218      FillSmoothTexPCHorizontalLine(machine, textureType, palOffset, palPageSize, texIndex, debugColor,
3358      FillSmoothTexPCHorizontalLine(machine, prOptions,
32193359         x_start, x_end, y_mid, z_interp_x, z_delta_x, w_interp_x, w_delta_x,
32203360         r_interp_x, r_delta_x, g_interp_x, g_delta_x, b_interp_x, b_delta_x,
32213361         s_interp_x, s_delta_x, t_interp_x, t_delta_x);
r7500r7501
32453385      p->vert[j].texCoords[1]  = p->vert[j].texCoords[1] * p->vert[j].clipCoords[3];
32463386   }
32473387
3388   // Set up the struct that will pass the polygon's options around.
3389   polygonRasterOptions prOptions;
3390   prOptions.texType = p->texType;
3391   prOptions.texIndex = p->texIndex;
3392   prOptions.palOffset = p->palOffset;
3393   prOptions.palPageSize = p->palPageSize;
3394   prOptions.debugColor = p->debugColor;
3395   prOptions.texPageSmall = p->texPageSmall;
3396   prOptions.texPageHorizOffset = p->texPageHorizOffset;
3397   prOptions.texPageVertOffset = p->texPageVertOffset;
3398
32483399   for (j = 1; j < p->n-1; j++)
32493400   {
32503401      RasterizeTriangle_SMOOTH_TEX_PC(machine,
32513402                              p->vert[0].clipCoords, p->vert[j].clipCoords, p->vert[j+1].clipCoords,
32523403                              p->vert[0].light,      p->vert[j].light,      p->vert[j+1].light,
32533404                              p->vert[0].texCoords,  p->vert[j].texCoords,  p->vert[j+1].texCoords,
3254                              p->texType, p->palOffset, p->palPageSize,
3255                              p->texIndex, p->debugColor);
3405                              prOptions);
32563406   }
32573407}
32583408
src/mame/video/macrossp.c
r7500r7501
1/* Macross Plus - video
2  see DRIVER file for notes */
1/* video/macrossp.c */
32
43#include "emu.h"
4#include "includes/macrossp.h"
55
66
7UINT32 *macrossp_scra_videoram, *macrossp_scra_videoregs;
8UINT32 *macrossp_scrb_videoram, *macrossp_scrb_videoregs;
9UINT32 *macrossp_scrc_videoram, *macrossp_scrc_videoregs;
10UINT32 *macrossp_text_videoram, *macrossp_text_videoregs;
11UINT32 *macrossp_spriteram;
12
13static UINT32 *spriteram_old,*spriteram_old2;
14
15static tilemap_t  *macrossp_scra_tilemap, *macrossp_scrb_tilemap,*macrossp_scrc_tilemap, *macrossp_text_tilemap;
16
17
187/*** SCR A LAYER ***/
198
209WRITE32_HANDLER( macrossp_scra_videoram_w )
2110{
22   COMBINE_DATA(&macrossp_scra_videoram[offset]);
11   macrossp_state *state = (macrossp_state *)space->machine->driver_data;
2312
24   tilemap_mark_tile_dirty(macrossp_scra_tilemap,offset);
13   COMBINE_DATA(&state->scra_videoram[offset]);
14
15   tilemap_mark_tile_dirty(state->scra_tilemap, offset);
2516}
2617
2718
2819static TILE_GET_INFO( get_macrossp_scra_tile_info )
2920{
30   UINT32 attr,tileno,color;
21   macrossp_state *state = (macrossp_state *)machine->driver_data;
22   UINT32 attr, tileno, color;
3123
32   attr = macrossp_scra_videoram[tile_index];
24   attr = state->scra_videoram[tile_index];
3325   tileno = attr & 0x0000ffff;
3426
35   switch (macrossp_scra_videoregs[0] & 0x00000c00)
27   switch (state->scra_videoregs[0] & 0x00000c00)
3628   {
3729      case 0x00000800:
3830         color = (attr & 0x000e0000) >> 15;
r7500r7501
4739         break;
4840   }
4941
50   SET_TILE_INFO(1,tileno,color,TILE_FLIPYX((attr & 0xc0000000) >> 30));
42   SET_TILE_INFO(1, tileno, color, TILE_FLIPYX((attr & 0xc0000000) >> 30));
5143}
5244
5345/*** SCR B LAYER ***/
5446
5547WRITE32_HANDLER( macrossp_scrb_videoram_w )
5648{
57   COMBINE_DATA(&macrossp_scrb_videoram[offset]);
49   macrossp_state *state = (macrossp_state *)space->machine->driver_data;
5850
59   tilemap_mark_tile_dirty(macrossp_scrb_tilemap,offset);
51   COMBINE_DATA(&state->scrb_videoram[offset]);
52
53   tilemap_mark_tile_dirty(state->scrb_tilemap, offset);
6054}
6155
6256
6357static TILE_GET_INFO( get_macrossp_scrb_tile_info )
6458{
65   UINT32 attr,tileno,color;
59   macrossp_state *state = (macrossp_state *)machine->driver_data;
60   UINT32 attr, tileno, color;
6661
67   attr = macrossp_scrb_videoram[tile_index];
62   attr = state->scrb_videoram[tile_index];
6863   tileno = attr & 0x0000ffff;
6964
70   switch (macrossp_scrb_videoregs[0] & 0x00000c00)
65   switch (state->scrb_videoregs[0] & 0x00000c00)
7166   {
7267      case 0x00000800:
7368         color = (attr & 0x000e0000) >> 15;
r7500r7501
8277         break;
8378   }
8479
85   SET_TILE_INFO(2,tileno,color,TILE_FLIPYX((attr & 0xc0000000) >> 30));
80   SET_TILE_INFO(2, tileno, color, TILE_FLIPYX((attr & 0xc0000000) >> 30));
8681}
8782
8883/*** SCR C LAYER ***/
8984
9085WRITE32_HANDLER( macrossp_scrc_videoram_w )
9186{
92   COMBINE_DATA(&macrossp_scrc_videoram[offset]);
87   macrossp_state *state = (macrossp_state *)space->machine->driver_data;
9388
94   tilemap_mark_tile_dirty(macrossp_scrc_tilemap,offset);
89   COMBINE_DATA(&state->scrc_videoram[offset]);
90
91   tilemap_mark_tile_dirty(state->scrc_tilemap, offset);
9592}
9693
9794
9895static TILE_GET_INFO( get_macrossp_scrc_tile_info )
9996{
100   UINT32 attr,tileno,color;
97   macrossp_state *state = (macrossp_state *)machine->driver_data;
98   UINT32 attr, tileno, color;
10199
102   attr = macrossp_scrc_videoram[tile_index];
100   attr = state->scrc_videoram[tile_index];
103101   tileno = attr & 0x0000ffff;
104102
105   switch (macrossp_scrc_videoregs[0] & 0x00000c00)
103   switch (state->scrc_videoregs[0] & 0x00000c00)
106104   {
107105      case 0x00000800:
108106         color = (attr & 0x000e0000) >> 15;
r7500r7501
117115         break;
118116   }
119117
120   SET_TILE_INFO(3,tileno,color,TILE_FLIPYX((attr & 0xc0000000) >> 30));
118   SET_TILE_INFO(3, tileno, color, TILE_FLIPYX((attr & 0xc0000000) >> 30));
121119}
122120
123121/*** TEXT LAYER ***/
124122
125123WRITE32_HANDLER( macrossp_text_videoram_w )
126124{
127   COMBINE_DATA(&macrossp_text_videoram[offset]);
125   macrossp_state *state = (macrossp_state *)space->machine->driver_data;
128126
129   tilemap_mark_tile_dirty(macrossp_text_tilemap,offset);
127   COMBINE_DATA(&state->text_videoram[offset]);
128
129   tilemap_mark_tile_dirty(state->text_tilemap, offset);
130130}
131131
132132
133133static TILE_GET_INFO( get_macrossp_text_tile_info )
134134{
135   macrossp_state *state = (macrossp_state *)machine->driver_data;
135136   UINT32 tileno, colour;
136137
137   tileno = macrossp_text_videoram[tile_index] & 0x0000ffff;
138   colour = (macrossp_text_videoram[tile_index] & 0x00fe0000) >> 17;
138   tileno = state->text_videoram[tile_index] & 0x0000ffff;
139   colour = (state->text_videoram[tile_index] & 0x00fe0000) >> 17;
139140
140   SET_TILE_INFO(4,tileno,colour,0);
141   SET_TILE_INFO(4, tileno, colour, 0);
141142}
142143
143144
144145
145146/*** VIDEO START / UPDATE ***/
146147
147VIDEO_START(macrossp)
148VIDEO_START( macrossp )
148149{
149   spriteram_old = auto_alloc_array_clear(machine, UINT32, machine->generic.spriteram_size/4);
150   spriteram_old2 = auto_alloc_array_clear(machine, UINT32, machine->generic.spriteram_size/4);
150   macrossp_state *state = (macrossp_state *)machine->driver_data;
151151
152   macrossp_text_tilemap = tilemap_create(machine, get_macrossp_text_tile_info,tilemap_scan_rows,16,16,64,64);
153   macrossp_scra_tilemap = tilemap_create(machine, get_macrossp_scra_tile_info,tilemap_scan_rows,16,16,64,64);
154   macrossp_scrb_tilemap = tilemap_create(machine, get_macrossp_scrb_tile_info,tilemap_scan_rows,16,16,64,64);
155   macrossp_scrc_tilemap = tilemap_create(machine, get_macrossp_scrc_tile_info,tilemap_scan_rows,16,16,64,64);
152   state->spriteram_old = auto_alloc_array_clear(machine, UINT32, state->spriteram_size / 4);
153   state->spriteram_old2 = auto_alloc_array_clear(machine, UINT32, state->spriteram_size / 4);
156154
157   tilemap_set_transparent_pen(macrossp_text_tilemap,0);
158   tilemap_set_transparent_pen(macrossp_scra_tilemap,0);
159   tilemap_set_transparent_pen(macrossp_scrb_tilemap,0);
160   tilemap_set_transparent_pen(macrossp_scrc_tilemap,0);
155   state->text_tilemap = tilemap_create(machine, get_macrossp_text_tile_info, tilemap_scan_rows, 16, 16, 64, 64);
156   state->scra_tilemap = tilemap_create(machine, get_macrossp_scra_tile_info, tilemap_scan_rows, 16, 16, 64, 64);
157   state->scrb_tilemap = tilemap_create(machine, get_macrossp_scrb_tile_info, tilemap_scan_rows, 16, 16, 64, 64);
158   state->scrc_tilemap = tilemap_create(machine, get_macrossp_scrc_tile_info, tilemap_scan_rows, 16, 16, 64, 64);
161159
162   machine->gfx[0]->color_granularity=64;
163   machine->gfx[1]->color_granularity=64;
164   machine->gfx[2]->color_granularity=64;
165   machine->gfx[3]->color_granularity=64;
160   tilemap_set_transparent_pen(state->text_tilemap, 0);
161   tilemap_set_transparent_pen(state->scra_tilemap, 0);
162   tilemap_set_transparent_pen(state->scrb_tilemap, 0);
163   tilemap_set_transparent_pen(state->scrc_tilemap, 0);
164
165   machine->gfx[0]->color_granularity = 64;
166   machine->gfx[1]->color_granularity = 64;
167   machine->gfx[2]->color_granularity = 64;
168   machine->gfx[3]->color_granularity = 64;
169
170   state_save_register_global_pointer(machine, state->spriteram_old, state->spriteram_size / 4);
171   state_save_register_global_pointer(machine, state->spriteram_old2, state->spriteram_size / 4);
166172}
167173
168174
169175
170176static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, int priority )
171177{
178   macrossp_state *state = (macrossp_state *)machine->driver_data;
172179   const gfx_element *gfx = machine->gfx[0];
173//  UINT32 *source = macrossp_spriteram;
174   UINT32 *source = spriteram_old2; /* buffers by two frames */
175   UINT32 *finish = source + machine->generic.spriteram_size/4;
180   //  UINT32 *source = state->spriteram;
181   UINT32 *source = state->spriteram_old2; /* buffers by two frames */
182   UINT32 *finish = source + state->spriteram_size / 4;
176183
177
178   while( source<finish )
184   while (source < finish)
179185   {
180186
181187      /*
r7500r7501
208214
209215      int loopno = 0;
210216
211      int xcnt,ycnt;
212      int xoffset,yoffset;
217      int xcnt, ycnt;
218      int xoffset, yoffset;
213219
214220      int pri = (source[2] & 0x0c000000) >> 26;
215221
r7500r7501
234240         if (xpos > 0x1ff) xpos -=0x400;
235241         if (ypos > 0x1ff) ypos -=0x400;
236242
237         if (!flipx) {
238            if (!flipy) { /* noxflip, noyflip */
243         if (!flipx)
244         {
245            if (!flipy)
246            {
247               /* noxflip, noyflip */
239248               yoffset = 0; /* I'm doing this so rounding errors are cumulative, still looks a touch crappy when multiple sprites used together */
240               for (ycnt = 0; ycnt <= high; ycnt++) {
249               for (ycnt = 0; ycnt <= high; ycnt++)
250               {
241251                  xoffset = 0;
242                  for (xcnt = 0; xcnt <= wide; xcnt++) {
252                  for (xcnt = 0; xcnt <= wide; xcnt++)
253                  {
243254                     drawgfxzoom_alpha(bitmap,cliprect,gfx,tileno+loopno,col,flipx,flipy,xpos+xoffset,ypos+yoffset,xzoom*0x100,yzoom*0x100,0,alpha);
244255
245256                     xoffset += ((xzoom*16 + (1<<7)) >> 8);
r7500r7501
247258                  }
248259                  yoffset += ((yzoom*16 + (1<<7)) >> 8);
249260               }
250            }else{ /* noxflip, flipy */
251               yoffset = ((high*yzoom*16) >> 8);
252               for (ycnt = high; ycnt >= 0; ycnt--) {
261            }
262            else
263            {
264               /* noxflip, flipy */
265               yoffset = ((high * yzoom * 16) >> 8);
266               for (ycnt = high; ycnt >= 0; ycnt--)
267               {
253268                  xoffset = 0;
254                  for (xcnt = 0; xcnt <= wide; xcnt++) {
269                  for (xcnt = 0; xcnt <= wide; xcnt++)
270                  {
255271                     drawgfxzoom_alpha(bitmap,cliprect,gfx,tileno+loopno,col,flipx,flipy,xpos+xoffset,ypos+yoffset,xzoom*0x100,yzoom*0x100,0,alpha);
256272
257                     xoffset += ((xzoom*16 + (1<<7)) >> 8);
273                     xoffset += ((xzoom * 16 + (1 << 7)) >> 8);
258274                     loopno++;
259275                  }
260                  yoffset -= ((yzoom*16 + (1<<7)) >> 8);
276                  yoffset -= ((yzoom * 16 + (1 << 7)) >> 8);
261277               }
262278            }
263         }else{
264            if (!flipy) { /* xflip, noyflip */
279         }
280         else
281         {
282            if (!flipy)
283            {
284               /* xflip, noyflip */
265285               yoffset = 0;
266               for (ycnt = 0; ycnt <= high; ycnt++) {
286               for (ycnt = 0; ycnt <= high; ycnt++)
287               {
267288                  xoffset = ((wide*xzoom*16) >> 8);
268                  for (xcnt = wide; xcnt >= 0; xcnt--) {
289                  for (xcnt = wide; xcnt >= 0; xcnt--)
290                  {
269291                     drawgfxzoom_alpha(bitmap,cliprect,gfx,tileno+loopno,col,flipx,flipy,xpos+xoffset,ypos+yoffset,xzoom*0x100,yzoom*0x100,0,alpha);
270292
271                     xoffset -= ((xzoom*16 + (1<<7)) >> 8);
293                     xoffset -= ((xzoom * 16 + (1 << 7)) >> 8);
272294                     loopno++;
273295                  }
274                  yoffset += ((yzoom*16 + (1<<7)) >> 8);
296                  yoffset += ((yzoom * 16 + (1 << 7)) >> 8);
275297               }
276            }else{ /* xflip, yflip */
277               yoffset = ((high*yzoom*16) >> 8);
278               for (ycnt = high; ycnt >= 0; ycnt--) {
279                  xoffset = ((wide*xzoom*16) >> 8);
280                  for (xcnt = wide; xcnt >=0 ; xcnt--) {
298            }
299            else
300            {
301               /* xflip, yflip */
302               yoffset = ((high * yzoom * 16) >> 8);
303               for (ycnt = high; ycnt >= 0; ycnt--)
304               {
305                  xoffset = ((wide * xzoom * 16) >> 8);
306                  for (xcnt = wide; xcnt >=0 ; xcnt--)
307                  {
281308                     drawgfxzoom_alpha(bitmap,cliprect,gfx,tileno+loopno,col,flipx,flipy,xpos+xoffset,ypos+yoffset,xzoom*0x100,yzoom*0x100,0,alpha);
282309
283                     xoffset -= ((xzoom*16 + (1<<7)) >> 8);
310                     xoffset -= ((xzoom * 16 + (1 << 7)) >> 8);
284311                     loopno++;
285312                  }
286                  yoffset -= ((yzoom*16 + (1<<7)) >> 8);
313                  yoffset -= ((yzoom * 16 + (1 << 7)) >> 8);
287314               }
288315            }
289316         }
r7500r7501
293320}
294321
295322
296static void draw_layer(bitmap_t *bitmap, const rectangle *cliprect, int layer)
323static void draw_layer( running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, int layer )
297324{
325   macrossp_state *state = (macrossp_state *)machine->driver_data;
298326   tilemap_t *tm;
299327   UINT32 *vr;
300328
r7500r7501
302330   {
303331      case 0:
304332      default:
305         tm = macrossp_scra_tilemap;
306         vr = macrossp_scra_videoregs;
333         tm = state->scra_tilemap;
334         vr = state->scra_videoregs;
307335         break;
308336
309337      case 1:
310         tm = macrossp_scrb_tilemap;
311         vr = macrossp_scrb_videoregs;
338         tm = state->scrb_tilemap;
339         vr = state->scrb_videoregs;
312340         break;
313341
314342      case 2:
315         tm = macrossp_scrc_tilemap;
316         vr = macrossp_scrc_videoregs;
343         tm = state->scrc_tilemap;
344         vr = state->scrc_videoregs;
317345         break;
318346   }
319347
320348   if ((vr[2] & 0xf0000000) == 0xe0000000)   /* zoom enable (guess, surely wrong) */
321349   {
322      int startx,starty,inc;
350      int startx, starty, inc;
323351
324352      startx = (vr[1] & 0x0000ffff) << 16;
325353      starty = (vr[1] & 0xffff0000) >> 0;
r7500r7501
339367   {
340368      tilemap_set_scrollx( tm, 0, ((vr[0] & 0x000003ff) >> 0 ) );
341369      tilemap_set_scrolly( tm, 0, ((vr[0] & 0x03ff0000) >> 16) );
342      tilemap_draw(bitmap,cliprect,tm,0,0);
370      tilemap_draw(bitmap, cliprect, tm, 0, 0);
343371   }
344372}
345373
r7500r7501
359387   SWAP(1,2)
360388}
361389
362VIDEO_UPDATE(macrossp)
390VIDEO_UPDATE( macrossp )
363391{
392   macrossp_state *state = (macrossp_state *)screen->machine->driver_data;
364393   int layers[3],layerpri[3];
365394
395   bitmap_fill(bitmap, cliprect, get_black_pen(screen->machine));
366396
367   bitmap_fill(bitmap,cliprect,get_black_pen(screen->machine));
368
369397   layers[0] = 0;
370   layerpri[0] = (macrossp_scra_videoregs[0] & 0x0000c000) >> 14;
398   layerpri[0] = (state->scra_videoregs[0] & 0x0000c000) >> 14;
371399   layers[1] = 1;
372   layerpri[1] = (macrossp_scrb_videoregs[0] & 0x0000c000) >> 14;
400   layerpri[1] = (state->scrb_videoregs[0] & 0x0000c000) >> 14;
373401   layers[2] = 2;
374   layerpri[2] = (macrossp_scrc_videoregs[0] & 0x0000c000) >> 14;
402   layerpri[2] = (state->scrc_videoregs[0] & 0x0000c000) >> 14;
375403
376404   sortlayers(layers, layerpri);
377405
378   draw_layer(bitmap,cliprect,layers[0]);
379   draw_sprites(screen->machine,bitmap,cliprect,0);
380   draw_layer(bitmap,cliprect,layers[1]);
381   draw_sprites(screen->machine,bitmap,cliprect,1);
382   draw_layer(bitmap,cliprect,layers[2]);
383   draw_sprites(screen->machine,bitmap,cliprect,2);
384   draw_sprites(screen->machine,bitmap,cliprect,3);
385   tilemap_draw(bitmap,cliprect,macrossp_text_tilemap,0,0);
406   draw_layer(screen->machine, bitmap, cliprect, layers[0]);
407   draw_sprites(screen->machine, bitmap, cliprect, 0);
408   draw_layer(screen->machine, bitmap, cliprect, layers[1]);
409   draw_sprites(screen->machine, bitmap, cliprect, 1);
410   draw_layer(screen->machine, bitmap, cliprect, layers[2]);
411   draw_sprites(screen->machine, bitmap, cliprect, 2);
412   draw_sprites(screen->machine, bitmap, cliprect, 3);
413   tilemap_draw(bitmap, cliprect, state->text_tilemap, 0, 0);
386414
387415#if 0
388416popmessage   ("scra - %08x %08x %08x\nscrb - %08x %08x %08x\nscrc - %08x %08x %08x",
389macrossp_scra_videoregs[0]&0xffff33ff, // yyyyxxxx
390macrossp_scra_videoregs[1], // ??? more scrolling?
391macrossp_scra_videoregs[2], // 08 - 0b
417state->scra_videoregs[0]&0xffff33ff, // yyyyxxxx
418state->scra_videoregs[1], // ??? more scrolling?
419state->scra_videoregs[2], // 08 - 0b
392420
393macrossp_scrb_videoregs[0]&0xffff33ff, // 00 - 03
394macrossp_scrb_videoregs[1], // 04 - 07
395macrossp_scrb_videoregs[2], // 08 - 0b
421state->scrb_videoregs[0]&0xffff33ff, // 00 - 03
422state->scrb_videoregs[1], // 04 - 07
423state->scrb_videoregs[2], // 08 - 0b
396424
397macrossp_scrc_videoregs[0]&0xffff33ff, // 00 - 03
398macrossp_scrc_videoregs[1], // 04 - 07
399macrossp_scrc_videoregs[2]);// 08 - 0b
425state->scrc_videoregs[0]&0xffff33ff, // 00 - 03
426state->scrc_videoregs[1], // 04 - 07
427state->scrc_videoregs[2]);// 08 - 0b
400428#endif
401429   return 0;
402430}
403431
404432VIDEO_EOF( macrossp )
405433{
434   macrossp_state *state = (macrossp_state *)machine->driver_data;
435
406436   /* looks like sprites are *two* frames ahead, like nmk16 */
407   memcpy(spriteram_old2,spriteram_old,machine->generic.spriteram_size);
408   memcpy(spriteram_old,macrossp_spriteram,machine->generic.spriteram_size);
437   memcpy(state->spriteram_old2, state->spriteram_old, state->spriteram_size);
438   memcpy(state->spriteram_old, state->spriteram, state->spriteram_size);
409439}
src/mame/video/pktgaldx.c
r7500r7501
11#include "emu.h"
2#include "includes/deco16ic.h"
2#include "video/deco16ic.h"
3#include "includes/pktgaldx.h"
34
4UINT16* pcktgaldb_fgram;
5UINT16* pcktgaldb_sprites;
6
7
8static void draw_sprites(running_machine *machine, bitmap_t *bitmap,const rectangle *cliprect)
5static void draw_sprites( running_machine *machine, bitmap_t *bitmap,const rectangle *cliprect )
96{
10   UINT16 *spriteram16 = machine->generic.spriteram.u16;
7   pktgaldx_state *state = (pktgaldx_state *)machine->driver_data;
8   UINT16 *spriteram = state->spriteram;
119   int offs;
12   int flipscreen=!flip_screen_get(machine);
10   int flipscreen = !flip_screen_get(machine);
1311
14   for (offs = 0;offs < 0x400;offs += 4)
12   for (offs = 0; offs < 0x400; offs += 4)
1513   {
16      int x,y,sprite,colour,multi,fx,fy,inc,flash,mult;
14      int x, y, sprite, colour, multi, fx, fy, inc, flash, mult;
1715
18      sprite = spriteram16[offs+1];
19      if (!sprite) continue;
16      sprite = spriteram[offs+1];
17      if (!sprite)
18         continue;
2019
21      y = spriteram16[offs];
22      flash=y&0x1000;
23      if (flash && (video_screen_get_frame_number(machine->primary_screen) & 1)) continue;
20      y = spriteram[offs];
21      flash = y & 0x1000;
22      if (flash && (video_screen_get_frame_number(machine->primary_screen) & 1))
23         continue;
2424
25      x = spriteram16[offs+2];
26      colour = (x >>9) & 0x1f;
25      x = spriteram[offs + 2];
26      colour = (x >> 9) & 0x1f;
2727
2828      fx = y & 0x2000;
2929      fy = y & 0x4000;
r7500r7501
3434      if (x >= 320) x -= 512;
3535      if (y >= 256) y -= 512;
3636      y = 240 - y;
37        x = 304 - x;
37      x = 304 - x;
3838
39      if (x>320) continue;
39      if (x > 320)
40         continue;
4041
4142      sprite &= ~multi;
4243      if (fy)
r7500r7501
4950
5051      if (flipscreen)
5152      {
52         y=240-y;
53         x=304-x;
54         if (fx) fx=0; else fx=1;
55         if (fy) fy=0; else fy=1;
56         mult=16;
53         y = 240 - y;
54         x = 304 - x;
55         if (fx) fx = 0; else fx = 1;
56         if (fy) fy = 0; else fy = 1;
57         mult = 16;
5758      }
58      else mult=-16;
59      else mult = -16;
5960
6061      while (multi >= 0)
6162      {
r7500r7501
7071   }
7172}
7273
73static int pktgaldx_bank_callback(const int bank)
74{
75   return ((bank>>4) & 0x7) * 0x1000;
76}
77
7874/* Video on the orginal */
79VIDEO_START(pktgaldx)
80{
81   deco16_1_video_init(machine);
8275
83   deco16_set_tilemap_bank_callback(1,pktgaldx_bank_callback);
84}
85
86VIDEO_UPDATE(pktgaldx)
76VIDEO_UPDATE( pktgaldx )
8777{
88   flip_screen_set(screen->machine,  deco16_pf12_control[0]&0x80 );
89   deco16_pf12_update(deco16_pf1_rowscroll,deco16_pf2_rowscroll);
78   pktgaldx_state *state = (pktgaldx_state *)screen->machine->driver_data;
79   UINT16 flip = deco16ic_pf12_control_r(state->deco16ic, 0, 0xffff);
9080
91   bitmap_fill(bitmap,cliprect,0); /* not Confirmed */
92   bitmap_fill(screen->machine->priority_bitmap,NULL,0);
81   flip_screen_set(screen->machine, BIT(flip, 7));
82   deco16ic_pf12_update(state->deco16ic, state->pf1_rowscroll, state->pf2_rowscroll);
9383
94   deco16_tilemap_2_draw(screen,bitmap,cliprect,0,0);
95   draw_sprites(screen->machine,bitmap,cliprect);
96   deco16_tilemap_1_draw(screen,bitmap,cliprect,0,0);
84   bitmap_fill(bitmap, cliprect, 0); /* not Confirmed */
85   bitmap_fill(screen->machine->priority_bitmap, NULL, 0);
86
87   deco16ic_tilemap_2_draw(state->deco16ic, bitmap, cliprect, 0, 0);
88   draw_sprites(screen->machine, bitmap, cliprect);
89   deco16ic_tilemap_1_draw(state->deco16ic, bitmap, cliprect, 0, 0);
9790   return 0;
9891}
9992
10093/* Video for the bootleg */
101VIDEO_START(pktgaldb)
102{
103}
10494
105VIDEO_UPDATE(pktgaldb)
95VIDEO_UPDATE( pktgaldb )
10696{
107   int x,y;
108   int offset=0;
97   pktgaldx_state *state = (pktgaldx_state *)screen->machine->driver_data;
98   int x, y;
99   int offset = 0;
109100   int tileno;
110101   int colour;
111102
112103   bitmap_fill(bitmap, cliprect, get_black_pen(screen->machine));
113104
114105   /* the bootleg seems to treat the tilemaps as sprites */
115   for (offset = 0;offset<0x1600/2;offset+=8)
106   for (offset = 0; offset < 0x1600 / 2; offset += 8)
116107   {
117      tileno =  pcktgaldb_sprites[offset+3] | (pcktgaldb_sprites[offset+2]<<16);
118      colour =  pcktgaldb_sprites[offset+1]>>1;
119      x = pcktgaldb_sprites[offset+0];
120      y = pcktgaldb_sprites[offset+4];
108      tileno = state->pktgaldb_sprites[offset + 3] | (state->pktgaldb_sprites[offset + 2] << 16);
109      colour = state->pktgaldb_sprites[offset + 1] >> 1;
110      x = state->pktgaldb_sprites[offset + 0];
111      y = state->pktgaldb_sprites[offset + 4];
121112
122      x-=0xc2;
123      y&=0x1ff;
124      y-=8;
113      x -= 0xc2;
114      y &= 0x1ff;
115      y -= 8;
125116
126      drawgfx_transpen(bitmap,cliprect,screen->machine->gfx[0],tileno^0x1000,colour,0,0,x,y,0);
117      drawgfx_transpen(bitmap, cliprect, screen->machine->gfx[0], tileno ^ 0x1000, colour, 0, 0, x, y, 0);
127118   }
128119
129   for (offset = 0x1600/2;offset<0x2000/2;offset+=8)
120   for (offset = 0x1600/2; offset < 0x2000 / 2; offset += 8)
130121   {
131      tileno =  pcktgaldb_sprites[offset+3] | (pcktgaldb_sprites[offset+2]<<16);
132      colour =  pcktgaldb_sprites[offset+1]>>1;
133      x = pcktgaldb_sprites[offset+0]&0x1ff;
134      y = pcktgaldb_sprites[offset+4]&0x0ff;
122      tileno = state->pktgaldb_sprites[offset + 3] | (state->pktgaldb_sprites[offset + 2] << 16);
123      colour = state->pktgaldb_sprites[offset + 1] >> 1;
124      x = state->pktgaldb_sprites[offset + 0] & 0x1ff;
125      y = state->pktgaldb_sprites[offset + 4] & 0x0ff;
135126
136      x-=0xc2;
137      y&=0x1ff;
138      y-=8;
127      x -= 0xc2;
128      y &= 0x1ff;
129      y -= 8;
139130
140      drawgfx_transpen(bitmap,cliprect,screen->machine->gfx[0],tileno^0x4000,colour,0,0,x,y,0);
131      drawgfx_transpen(bitmap, cliprect, screen->machine->gfx[0], tileno ^ 0x4000, colour, 0, 0, x, y, 0);
141132   }
142133
143   for (offset = 0x2000/2;offset<0x4000/2;offset+=8)
134   for (offset = 0x2000/2; offset < 0x4000 / 2; offset += 8)
144135   {
145      tileno =  pcktgaldb_sprites[offset+3] | (pcktgaldb_sprites[offset+2]<<16);
146      colour =  pcktgaldb_sprites[offset+1]>>1;
147      x = pcktgaldb_sprites[offset+0]&0x1ff;
148      y = pcktgaldb_sprites[offset+4]&0x0ff;
136      tileno = state->pktgaldb_sprites[offset + 3] | (state->pktgaldb_sprites[offset + 2] << 16);
137      colour = state->pktgaldb_sprites[offset + 1] >> 1;
138      x = state->pktgaldb_sprites[offset + 0] & 0x1ff;
139      y = state->pktgaldb_sprites[offset + 4] & 0x0ff;
149140
150      x-=0xc2;
151      y&=0x1ff;
152      y-=8;
141      x -= 0xc2;
142      y &= 0x1ff;
143      y -= 8;
153144
154      drawgfx_transpen(bitmap,cliprect,screen->machine->gfx[0],tileno^0x3000,colour,0,0,x,y,0);
145      drawgfx_transpen(bitmap, cliprect, screen->machine->gfx[0], tileno ^ 0x3000, colour, 0, 0, x, y, 0);
155146   }
156147
157148   return 0;
src/mame/video/matmania.c
r7500r7501
1616#include "includes/matmania.h"
1717
1818
19
20UINT8 *matmania_videoram,*matmania_colorram;
21size_t matmania_videoram_size;
22UINT8 *matmania_videoram2,*matmania_colorram2;
23size_t matmania_videoram2_size;
24UINT8 *matmania_videoram3,*matmania_colorram3;
25size_t matmania_videoram3_size;
26UINT8 *matmania_scroll;
27static bitmap_t *tmpbitmap;
28static bitmap_t *tmpbitmap2;
29
30UINT8 *matmania_pageselect;
31
3219/***************************************************************************
3320
3421  Convert the color PROMs into a more useable format.
r7500r7501
5845{
5946   int i;
6047
61   for (i = 0;i < 64;i++)
48   for (i = 0; i < 64; i++)
6249   {
63      int bit0,bit1,bit2,bit3,r,g,b;
50      int bit0, bit1, bit2, bit3, r, g, b;
6451
65
66      bit0 = (color_prom[0] >> 0) & 0x01;
67      bit1 = (color_prom[0] >> 1) & 0x01;
68      bit2 = (color_prom[0] >> 2) & 0x01;
69      bit3 = (color_prom[0] >> 3) & 0x01;
52      bit0 = BIT(color_prom[0], 0);
53      bit1 = BIT(color_prom[0], 1);
54      bit2 = BIT(color_prom[0], 2);
55      bit3 = BIT(color_prom[0], 3);
7056      r = 0x0e * bit0 + 0x1f * bit1 + 0x43 * bit2 + 0x8f * bit3;
71      bit0 = (color_prom[0] >> 4) & 0x01;
72      bit1 = (color_prom[0] >> 5) & 0x01;
73      bit2 = (color_prom[0] >> 6) & 0x01;
74      bit3 = (color_prom[0] >> 7) & 0x01;
57      bit0 = BIT(color_prom[0], 4);
58      bit1 = BIT(color_prom[0], 5);
59      bit2 = BIT(color_prom[0], 6);
60      bit3 = BIT(color_prom[0], 7);
7561      g = 0x0e * bit0 + 0x1f * bit1 + 0x43 * bit2 + 0x8f * bit3;
76      bit0 = (color_prom[64] >> 0) & 0x01;
77      bit1 = (color_prom[64] >> 1) & 0x01;
78      bit2 = (color_prom[64] >> 2) & 0x01;
79      bit3 = (color_prom[64] >> 3) & 0x01;
62      bit0 = BIT(color_prom[64], 0);
63      bit1 = BIT(color_prom[64], 1);
64      bit2 = BIT(color_prom[64], 2);
65      bit3 = BIT(color_prom[64], 3);
8066      b = 0x0e * bit0 + 0x1f * bit1 + 0x43 * bit2 + 0x8f * bit3;
8167
8268      palette_set_color(machine,i,MAKE_RGB(r,g,b));
r7500r7501
8874
8975WRITE8_HANDLER( matmania_paletteram_w )
9076{
91   int bit0,bit1,bit2,bit3,val;
92   int r,g,b;
77   matmania_state *state = (matmania_state *)space->machine->driver_data;
78   int bit0, bit1, bit2, bit3, val;
79   int r, g, b;
9380   int offs2;
9481
95
96   space->machine->generic.paletteram.u8[offset] = data;
82   state->paletteram[offset] = data;
9783   offs2 = offset & 0x0f;
9884
99   val = space->machine->generic.paletteram.u8[offs2];
100   bit0 = (val >> 0) & 0x01;
101   bit1 = (val >> 1) & 0x01;
102   bit2 = (val >> 2) & 0x01;
103   bit3 = (val >> 3) & 0x01;
85   val = state->paletteram[offs2];
86   bit0 = BIT(val, 0);
87   bit1 = BIT(val, 1);
88   bit2 = BIT(val, 2);
89   bit3 = BIT(val, 3);
10490   r = 0x0e * bit0 + 0x1f * bit1 + 0x43 * bit2 + 0x8f * bit3;
10591
106   val = space->machine->generic.paletteram.u8[offs2 | 0x10];
107   bit0 = (val >> 0) & 0x01;
108   bit1 = (val >> 1) & 0x01;
109   bit2 = (val >> 2) & 0x01;
110   bit3 = (val >> 3) & 0x01;
92   val = state->paletteram[offs2 | 0x10];
93   bit0 = BIT(val, 0);
94   bit1 = BIT(val, 1);
95   bit2 = BIT(val, 2);
96   bit3 = BIT(val, 3);
11197   g = 0x0e * bit0 + 0x1f * bit1 + 0x43 * bit2 + 0x8f * bit3;
11298
113   val = space->machine->generic.paletteram.u8[offs2 | 0x20];
114   bit0 = (val >> 0) & 0x01;
115   bit1 = (val >> 1) & 0x01;
116   bit2 = (val >> 2) & 0x01;
117   bit3 = (val >> 3) & 0x01;
99   val = state->paletteram[offs2 | 0x20];
100   bit0 = BIT(val, 0);
101   bit1 = BIT(val, 1);
102   bit2 = BIT(val, 2);
103   bit3 = BIT(val, 3);
118104   b = 0x0e * bit0 + 0x1f * bit1 + 0x43 * bit2 + 0x8f * bit3;
119105
120106   palette_set_color(space->machine,offs2 + 64,MAKE_RGB(r,g,b));
r7500r7501
126112  Start the video hardware emulation.
127113
128114***************************************************************************/
115
129116VIDEO_START( matmania )
130117{
118   matmania_state *state = (matmania_state *)machine->driver_data;
131119   int width = video_screen_get_width(machine->primary_screen);
132120   int height = video_screen_get_height(machine->primary_screen);
133121   bitmap_format format = video_screen_get_format(machine->primary_screen);
134122
135123   /* Mat Mania has a virtual screen twice as large as the visible screen */
136   tmpbitmap  = auto_bitmap_alloc(machine, width, 2*height, format);
137   tmpbitmap2 = auto_bitmap_alloc(machine, width, 2*height, format);
124   state->tmpbitmap  = auto_bitmap_alloc(machine, width, 2 * height, format);
125   state->tmpbitmap2 = auto_bitmap_alloc(machine, width, 2 * height, format);
138126}
139127
140128
141129
142130VIDEO_UPDATE( matmania )
143131{
144   UINT8 *spriteram = screen->machine->generic.spriteram.u8;
132   matmania_state *state = (matmania_state *)screen->machine->driver_data;
133   UINT8 *spriteram = state->spriteram;
145134   int offs;
146135
147136
148137   /* Update the tiles in the left tile ram bank */
149   for (offs = matmania_videoram_size - 1;offs >= 0;offs--)
138   for (offs = state->videoram_size - 1; offs >= 0; offs--)
150139   {
151      int sx,sy;
140      int sx = 15 - offs / 32;
141      int sy = offs % 32;
152142
153
154      sx = 15 - offs / 32;
155      sy = offs % 32;
156
157      drawgfx_opaque(tmpbitmap,0,screen->machine->gfx[1],
158            matmania_videoram[offs] + ((matmania_colorram[offs] & 0x08) << 5),
159            (matmania_colorram[offs] & 0x30) >> 4,
143      drawgfx_opaque(state->tmpbitmap, 0, screen->machine->gfx[1],
144            state->videoram[offs] + ((state->colorram[offs] & 0x08) << 5),
145            (state->colorram[offs] & 0x30) >> 4,
160146            0,sy >= 16,   /* flip horizontally tiles on the right half of the bitmap */
161            16*sx,16*sy);
147            16 * sx, 16 * sy);
162148   }
163149
164150   /* Update the tiles in the right tile ram bank */
165   for (offs = matmania_videoram3_size - 1;offs >= 0;offs--)
151   for (offs = state->videoram3_size - 1; offs >= 0; offs--)
166152   {
167         int sx,sy;
153      int sx = 15 - offs / 32;
154      int sy = offs % 32;
168155
169
170      sx = 15 - offs / 32;
171      sy = offs % 32;
172
173      drawgfx_opaque(tmpbitmap2,0,screen->machine->gfx[1],
174            matmania_videoram3[offs] + ((matmania_colorram3[offs] & 0x08) << 5),
175            (matmania_colorram3[offs] & 0x30) >> 4,
156      drawgfx_opaque(state->tmpbitmap2, 0, screen->machine->gfx[1],
157            state->videoram3[offs] + ((state->colorram3[offs] & 0x08) << 5),
158            (state->colorram3[offs] & 0x30) >> 4,
176159            0,sy >= 16,   /* flip horizontally tiles on the right half of the bitmap */
177160            16*sx,16*sy);
178161   }
179162
180
181163   /* copy the temporary bitmap to the screen */
182164   {
183      int scrolly;
184
185
186      scrolly = -*matmania_scroll;
187      if (matmania_pageselect[0]&0x01) // maniach sets 0x20 sometimes, which must have a different meaning
188         copyscrollbitmap(bitmap,tmpbitmap2,0,0,1,&scrolly,cliprect);
165      int scrolly = -*state->scroll;
166      if (state->pageselect[0] & 0x01) // maniach sets 0x20 sometimes, which must have a different meaning
167         copyscrollbitmap(bitmap, state->tmpbitmap2, 0, 0, 1, &scrolly, cliprect);
189168      else
190         copyscrollbitmap(bitmap,tmpbitmap,0,0,1,&scrolly,cliprect);
169         copyscrollbitmap(bitmap, state->tmpbitmap, 0, 0, 1, &scrolly, cliprect);
191170   }
192171
193172
194173   /* Draw the sprites */
195   for (offs = 0;offs < screen->machine->generic.spriteram_size;offs += 4)
174   for (offs = 0; offs < state->spriteram_size; offs += 4)
196175   {
197176      if (spriteram[offs] & 0x01)
198177      {
199         drawgfx_transpen(bitmap,cliprect,screen->machine->gfx[2],
200               spriteram[offs+1] + ((spriteram[offs] & 0xf0) << 4),
178         drawgfx_transpen(bitmap, cliprect, screen->machine->gfx[2],
179               spriteram[offs + 1] + ((spriteram[offs] & 0xf0) << 4),
201180               (spriteram[offs] & 0x08) >> 3,
202               spriteram[offs] & 0x04,spriteram[offs] & 0x02,
203               239 - spriteram[offs+3],(240 - spriteram[offs+2]) & 0xff,0);
181               spriteram[offs] & 0x04, spriteram[offs] & 0x02,
182               239 - spriteram[offs + 3],(240 - spriteram[offs + 2]) & 0xff,0);
204183      }
205184   }
206185
207186
208187   /* draw the frontmost playfield. They are characters, but draw them as sprites */
209   for (offs = matmania_videoram2_size - 1;offs >= 0;offs--)
188   for (offs = state->videoram2_size - 1; offs >= 0; offs--)
210189   {
211      int sx,sy;
190      int sx = 31 - offs / 32;
191      int sy = offs % 32;
212192
213
214      sx = 31 - offs / 32;
215      sy = offs % 32;
216
217193      drawgfx_transpen(bitmap,cliprect,screen->machine->gfx[0],
218            matmania_videoram2[offs] + 256 * (matmania_colorram2[offs] & 0x07),
219            (matmania_colorram2[offs] & 0x30) >> 4,
194            state->videoram2[offs] + 256 * (state->colorram2[offs] & 0x07),
195            (state->colorram2[offs] & 0x30) >> 4,
220196            0,0,
221197            8*sx,8*sy,0);
222198   }
r7500r7501
225201
226202VIDEO_UPDATE( maniach )
227203{
228   UINT8 *spriteram = screen->machine->generic.spriteram.u8;
204   matmania_state *state = (matmania_state *)screen->machine->driver_data;
205   UINT8 *spriteram = state->spriteram;
229206   int offs;
230207
231208
232209   /* Update the tiles in the left tile ram bank */
233   for (offs = matmania_videoram_size - 1;offs >= 0;offs--)
210   for (offs = state->videoram_size - 1; offs >= 0; offs--)
234211   {
235      int sx,sy;
212      int sx = 15 - offs / 32;
213      int sy = offs % 32;
236214
237
238      sx = 15 - offs / 32;
239      sy = offs % 32;
240
241      drawgfx_opaque(tmpbitmap,0,screen->machine->gfx[1],
242            matmania_videoram[offs] + ((matmania_colorram[offs] & 0x03) << 8),
243            (matmania_colorram[offs] & 0x30) >> 4,
215      drawgfx_opaque(state->tmpbitmap, 0, screen->machine->gfx[1],
216            state->videoram[offs] + ((state->colorram[offs] & 0x03) << 8),
217            (state->colorram[offs] & 0x30) >> 4,
244218            0,sy >= 16,   /* flip horizontally tiles on the right half of the bitmap */
245219            16*sx,16*sy);
246220   }
247221
248222   /* Update the tiles in the right tile ram bank */
249   for (offs = matmania_videoram3_size - 1;offs >= 0;offs--)
223   for (offs = state->videoram3_size - 1; offs >= 0; offs--)
250224   {
251      int sx,sy;
225      int sx = 15 - offs / 32;
226      int sy = offs % 32;
252227
253
254      sx = 15 - offs / 32;
255      sy = offs % 32;
256
257      drawgfx_opaque(tmpbitmap2,0,screen->machine->gfx[1],
258            matmania_videoram3[offs] + ((matmania_colorram3[offs] & 0x03) << 8),
259            (matmania_colorram3[offs] & 0x30) >> 4,
228      drawgfx_opaque(state->tmpbitmap2, 0, screen->machine->gfx[1],
229            state->videoram3[offs] + ((state->colorram3[offs] & 0x03) << 8),
230            (state->colorram3[offs] & 0x30) >> 4,
260231            0,sy >= 16,   /* flip horizontally tiles on the right half of the bitmap */
261232            16*sx,16*sy);
262233   }
r7500r7501
264235
265236   /* copy the temporary bitmap to the screen */
266237   {
267      int scrolly;
238      int scrolly = -*state->scroll;
268239
269
270      scrolly = -*matmania_scroll;
271
272      if (matmania_pageselect[0]&0x01) // this sets 0x20 sometimes, which must have a different meaning
273         copyscrollbitmap(bitmap,tmpbitmap2,0,0,1,&scrolly,cliprect);
240      if (state->pageselect[0] & 0x01) // this sets 0x20 sometimes, which must have a different meaning
241         copyscrollbitmap(bitmap, state->tmpbitmap2, 0, 0, 1, &scrolly, cliprect);
274242      else
275         copyscrollbitmap(bitmap,tmpbitmap,0,0,1,&scrolly,cliprect);
243         copyscrollbitmap(bitmap, state->tmpbitmap, 0, 0, 1, &scrolly, cliprect);
276244   }
277245
278246
279247   /* Draw the sprites */
280   for (offs = 0;offs < screen->machine->generic.spriteram_size;offs += 4)
248   for (offs = 0; offs < state->spriteram_size; offs += 4)
281249   {
282250      if (spriteram[offs] & 0x01)
283251      {
r7500r7501
291259
292260
293261   /* draw the frontmost playfield. They are characters, but draw them as sprites */
294   for (offs = matmania_videoram2_size - 1;offs >= 0;offs--)
262   for (offs = state->videoram2_size - 1; offs >= 0; offs--)
295263   {
296      int sx,sy;
264      int sx = 31 - offs / 32;
265      int sy = offs % 32;
297266
298
299      sx = 31 - offs / 32;
300      sy = offs % 32;
301
302267      drawgfx_transpen(bitmap,cliprect,screen->machine->gfx[0],
303            matmania_videoram2[offs] + 256 * (matmania_colorram2[offs] & 0x07),
304            (matmania_colorram2[offs] & 0x30) >> 4,
268            state->videoram2[offs] + 256 * (state->colorram2[offs] & 0x07),
269            (state->colorram2[offs] & 0x30) >> 4,
305270            0,0,
306271            8*sx,8*sy,0);
307272   }
src/mame/video/arkanoid.c
r7500r7501
120120}
121121
122122
123WRITE8_HANDLER( hexa_d008_w )
124{
125   arkanoid_state *state = (arkanoid_state *)space->machine->driver_data;
126
127   /* bit 0 = flipx (or y?) */
128   if (flip_screen_x_get(space->machine) != (data & 0x01))
129   {
130      flip_screen_x_set(space->machine, data & 0x01);
131      tilemap_mark_all_tiles_dirty(state->bg_tilemap);
132   }
133
134   /* bit 1 = flipy (or x?) */
135   if (flip_screen_y_get(space->machine) != (data & 0x02))
136   {
137      flip_screen_y_set(space->machine, data & 0x02);
138      tilemap_mark_all_tiles_dirty(state->bg_tilemap);
139   }
140
141   /* bit 2 - 3 unknown */
142
143   /* bit 4 could be the ROM bank selector for 8000-bfff (not sure) */
144   memory_set_bank(space->machine, "bank1", ((data & 0x10) >> 4));
145
146   /* bit 5 = gfx bank */
147   if (state->gfxbank != ((data & 0x20) >> 5))
148   {
149      state->gfxbank = (data & 0x20) >> 5;
150      tilemap_mark_all_tiles_dirty(state->bg_tilemap);
151   }
152
153   /* bit 6 - 7 unknown */
154}
155
123156static TILE_GET_INFO( get_bg_tile_info )
124157{
125158   arkanoid_state *state = (arkanoid_state *)machine->driver_data;
r7500r7501
177210   draw_sprites(screen->machine, bitmap, cliprect);
178211   return 0;
179212}
213
214VIDEO_UPDATE( hexa )
215{
216   arkanoid_state *state = (arkanoid_state *)screen->machine->driver_data;
217
218   tilemap_draw(bitmap, cliprect, state->bg_tilemap, 0, 0);
219   return 0;
220}
src/mame/video/lsasquad.c
r7500r7501
11#include "emu.h"
22#include "includes/lsasquad.h"
33
4UINT8 *lsasquad_scrollram;
5
6
7
8static void draw_layer(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, UINT8 *scrollram)
4static void draw_layer( running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, UINT8 *scrollram )
95{
10   int offs,scrollx,scrolly;
6   lsasquad_state *state = (lsasquad_state *)machine->driver_data;
7   int offs, scrollx, scrolly;
118
12
139   scrollx = scrollram[3];
1410   scrolly = -scrollram[0];
1511
16   for (offs = 0;offs < 0x080;offs += 4)
12   for (offs = 0; offs < 0x080; offs += 4)
1713   {
18      int base,y,sx,sy,code,color;
14      int base, y, sx, sy, code, color;
1915
20      base = 64 * scrollram[offs+1];
21      sx = 8*(offs/4) + scrollx;
22      if (flip_screen_get(machine)) sx = 248 - sx;
16      base = 64 * scrollram[offs + 1];
17      sx = 8 * (offs / 4) + scrollx;
18      if (flip_screen_get(machine))
19         sx = 248 - sx;
20
2321      sx &= 0xff;
2422
25      for (y = 0;y < 32;y++)
23      for (y = 0; y < 32; y++)
2624      {
2725         int attr;
2826
29         sy = 8*y + scrolly;
30         if (flip_screen_get(machine)) sy = 248 - sy;
27         sy = 8 * y + scrolly;
28         if (flip_screen_get(machine))
29            sy = 248 - sy;
3130         sy &= 0xff;
3231
33         attr = machine->generic.videoram.u8[base + 2*y + 1];
34         code = machine->generic.videoram.u8[base + 2*y] + ((attr & 0x0f) << 8);
32         attr = state->videoram[base + 2 * y + 1];
33         code = state->videoram[base + 2 * y] + ((attr & 0x0f) << 8);
3534         color = attr >> 4;
3635
3736         drawgfx_transpen(bitmap,cliprect,machine->gfx[0],
r7500r7501
4948   }
5049}
5150
52static int draw_layer_daikaiju(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, int offs, int  * previd, int type)
51static int draw_layer_daikaiju( running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, int offs, int  * previd, int type )
5352{
54   int id,scrollx,scrolly,initoffs, globalscrollx;
55   int stepx=0;
56   initoffs=offs;
53   lsasquad_state *state = (lsasquad_state *)machine->driver_data;
54   int id, scrollx, scrolly, initoffs, globalscrollx;
55   int stepx = 0;
5756
58   globalscrollx=0;
57   initoffs = offs;
58   globalscrollx = 0;
5959
60   id=lsasquad_scrollram[offs+2];
60   id = state->scrollram[offs + 2];
6161
62   for(;offs < 0x400; offs+=4)
62   for( ; offs < 0x400; offs += 4)
6363   {
64      int base,y,sx,sy,code,color;
64      int base, y, sx, sy, code, color;
6565
6666       //id change
67      if(id!=lsasquad_scrollram[offs+2])
67      if (id != state->scrollram[offs + 2])
6868      {
6969         *previd = id;
7070         return offs;
7171      }
7272      else
7373      {
74         id=lsasquad_scrollram[offs+2];
74         id = state->scrollram[offs + 2];
7575      }
7676
7777      //skip empty (??) column, potential probs with 1st column in scrollram (scroll 0, tile 0, id 0)
78      if( (lsasquad_scrollram[offs+0]|lsasquad_scrollram[offs+1]|lsasquad_scrollram[offs+2]|lsasquad_scrollram[offs+3])==0)
78      if ((state->scrollram[offs + 0] | state->scrollram[offs + 1] | state->scrollram[offs + 2] | state->scrollram[offs + 3]) == 0)
7979         continue;
8080
8181      //local scroll x/y
82      scrolly = -lsasquad_scrollram[offs+0];
83      scrollx =  lsasquad_scrollram[offs+3];
82      scrolly = -state->scrollram[offs + 0];
83      scrollx =  state->scrollram[offs + 3];
8484
8585      //check for global x scroll used in bg layer in game (starts at offset 0 in scrollram
8686      // and game name/logo on title screen (starts in the middle of scrollram, but with different
8787      // (NOT unique )id than prev coulmn(s)
8888
89      if( *previd!=1 )
89      if (*previd != 1)
9090      {
91         if(offs!=initoffs)
91         if (offs != initoffs)
9292         {
93            scrollx+=globalscrollx;
93            scrollx += globalscrollx;
9494         }
9595         else
9696         {
9797            //global scroll init
98            globalscrollx=scrollx;
98            globalscrollx = scrollx;
9999         }
100100      }
101101
102      base = 64 * lsasquad_scrollram[offs+1];
103      sx = scrollx+stepx;
102      base = 64 * state->scrollram[offs + 1];
103      sx = scrollx + stepx;
104104
105      if (flip_screen_get(machine)) sx = 248 - sx;
105      if (flip_screen_get(machine))
106         sx = 248 - sx;
106107      sx &= 0xff;
107108
108      for (y = 0;y < 32;y++)
109      for (y = 0; y < 32; y++)
109110      {
110111         int attr;
111112
112         sy = 8*y + scrolly;
113         if (flip_screen_get(machine)) sy = 248 - sy;
113         sy = 8 * y + scrolly;
114         if (flip_screen_get(machine))
115            sy = 248 - sy;
114116         sy &= 0xff;
115117
116         attr = machine->generic.videoram.u8[base + 2*y + 1];
117         code = machine->generic.videoram.u8[base + 2*y] + ((attr & 0x0f) << 8);
118         attr = state->videoram[base + 2 * y + 1];
119         code = state->videoram[base + 2 * y] + ((attr & 0x0f) << 8);
118120         color = attr >> 4;
119121
120
121         if((type==0 && color!=0x0d) || (type !=0 && color==0x0d))
122         if ((type == 0 && color != 0x0d) || (type != 0 && color == 0x0d))
122123         {
123124            drawgfx_transpen(bitmap,cliprect,machine->gfx[0],
124125               code,
r7500r7501
137138   return offs;
138139}
139140
140static void drawbg(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, int type)
141static void drawbg( running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, int type )
141142{
142   int i=0;
143   int id=-1;
143   lsasquad_state *state = (lsasquad_state *)machine->driver_data;
144   int i = 0;
145   int id = -1;
144146
145   while(i<0x400)
147   while (i < 0x400)
146148   {
147      if(!(lsasquad_scrollram[i+2]&1))
149      if (!(state->scrollram[i + 2] & 1))
148150      {
149         i=draw_layer_daikaiju(machine, bitmap, cliprect, i, &id,type);
151         i = draw_layer_daikaiju(machine, bitmap, cliprect, i, &id, type);
150152      }
151153      else
152154      {
153         id=lsasquad_scrollram[i+2];
154         i+=4;
155         id = state->scrollram[i + 2];
156         i += 4;
155157      }
156158   }
157159}
158160
159static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect)
161static void draw_sprites( running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect )
160162{
161   UINT8 *spriteram = machine->generic.spriteram.u8;
163   lsasquad_state *state = (lsasquad_state *)machine->driver_data;
164   UINT8 *spriteram = state->spriteram;
162165   int offs;
163166
164   for (offs = machine->generic.spriteram_size-4;offs >= 0;offs -= 4)
167   for (offs = state->spriteram_size - 4; offs >= 0; offs -= 4)
165168   {
166      int sx,sy,attr,code,color,flipx,flipy;
169      int sx, sy, attr, code, color, flipx, flipy;
167170
168      sx = spriteram[offs+3];
171      sx = spriteram[offs + 3];
169172      sy = 240 - spriteram[offs];
170      attr = spriteram[offs+1];
171      code = spriteram[offs+2] + ((attr & 0x30) << 4);
173      attr = spriteram[offs + 1];
174      code = spriteram[offs + 2] + ((attr & 0x30) << 4);
172175      color = attr & 0x0f;
173176      flipx = attr & 0x40;
174177      flipy = attr & 0x80;
r7500r7501
197200
198201VIDEO_UPDATE( lsasquad )
199202{
200   bitmap_fill(bitmap,cliprect,511);
203   lsasquad_state *state = (lsasquad_state *)screen->machine->driver_data;
204   bitmap_fill(bitmap, cliprect, 511);
201205
202   draw_layer(screen->machine,bitmap,cliprect,lsasquad_scrollram + 0x000);
203   draw_layer(screen->machine,bitmap,cliprect,lsasquad_scrollram + 0x080);
204   draw_sprites(screen->machine,bitmap,cliprect);
205   draw_layer(screen->machine,bitmap,cliprect,lsasquad_scrollram + 0x100);
206   draw_layer(screen->machine, bitmap, cliprect, state->scrollram + 0x000);
207   draw_layer(screen->machine, bitmap, cliprect, state->scrollram + 0x080);
208   draw_sprites(screen->machine, bitmap, cliprect);
209   draw_layer(screen->machine, bitmap, cliprect, state->scrollram + 0x100);
206210   return 0;
207211}
208212
209213
210214VIDEO_UPDATE( daikaiju )
211215{
212   bitmap_fill(bitmap,cliprect,511);
213   drawbg(screen->machine,bitmap,cliprect,0); // bottom
214   draw_sprites(screen->machine,bitmap,cliprect);
215   drawbg(screen->machine,bitmap,cliprect,1);   // top = pallete $d ?
216   bitmap_fill(bitmap, cliprect, 511);
217   drawbg(screen->machine, bitmap, cliprect, 0); // bottom
218   draw_sprites(screen->machine, bitmap, cliprect);
219   drawbg(screen->machine, bitmap, cliprect, 1);   // top = pallete $d ?
216220   return 0;
217221}
src/mame/video/mosaic.c
r7500r7501
77***************************************************************************/
88
99#include "emu.h"
10#include "includes/mosaic.h"
1011
11
12UINT8 *mosaic_fgvideoram;
13UINT8 *mosaic_bgvideoram;
14
15static tilemap_t *bg_tilemap,*fg_tilemap;
16
17
18
1912/***************************************************************************
2013
2114  Callbacks for the TileMap code
r7500r7501
2417
2518static TILE_GET_INFO( get_fg_tile_info )
2619{
20   mosaic_state *state = (mosaic_state *)machine->driver_data;
2721   tile_index *= 2;
2822   SET_TILE_INFO(
2923         0,
30         mosaic_fgvideoram[tile_index] + (mosaic_fgvideoram[tile_index+1] << 8),
24         state->fgvideoram[tile_index] + (state->fgvideoram[tile_index+1] << 8),
3125         0,
3226         0);
3327}
3428
3529static TILE_GET_INFO( get_bg_tile_info )
3630{
31   mosaic_state *state = (mosaic_state *)machine->driver_data;
3732   tile_index *= 2;
3833   SET_TILE_INFO(
3934         1,
40         mosaic_bgvideoram[tile_index] + (mosaic_bgvideoram[tile_index+1] << 8),
35         state->bgvideoram[tile_index] + (state->bgvideoram[tile_index+1] << 8),
4136         0,
4237         0);
4338}
r7500r7501
5247
5348VIDEO_START( mosaic )
5449{
55   fg_tilemap = tilemap_create(machine, get_fg_tile_info,tilemap_scan_rows,8,8,64,32);
56   bg_tilemap = tilemap_create(machine, get_bg_tile_info,tilemap_scan_rows,     8,8,64,32);
50   mosaic_state *state = (mosaic_state *)machine->driver_data;
5751
58   tilemap_set_transparent_pen(fg_tilemap,0xff);
52   state->fg_tilemap = tilemap_create(machine, get_fg_tile_info, tilemap_scan_rows, 8, 8, 64, 32);
53   state->bg_tilemap = tilemap_create(machine, get_bg_tile_info, tilemap_scan_rows, 8, 8, 64, 32);
54
55   tilemap_set_transparent_pen(state->fg_tilemap, 0xff);
5956}
6057
6158
r7500r7501
6764
6865WRITE8_HANDLER( mosaic_fgvideoram_w )
6966{
70   mosaic_fgvideoram[offset] = data;
71   tilemap_mark_tile_dirty(fg_tilemap,offset/2);
67   mosaic_state *state = (mosaic_state *)space->machine->driver_data;
68
69   state->fgvideoram[offset] = data;
70   tilemap_mark_tile_dirty(state->fg_tilemap, offset / 2);
7271}
7372
7473WRITE8_HANDLER( mosaic_bgvideoram_w )
7574{
76   mosaic_bgvideoram[offset] = data;
77   tilemap_mark_tile_dirty(bg_tilemap,offset/2);
75   mosaic_state *state = (mosaic_state *)space->machine->driver_data;
76
77   state->bgvideoram[offset] = data;
78   tilemap_mark_tile_dirty(state->bg_tilemap, offset / 2);
7879}
7980
8081
8182
8283VIDEO_UPDATE( mosaic )
8384{
84   tilemap_draw(bitmap,cliprect,bg_tilemap,0,0);
85   tilemap_draw(bitmap,cliprect,fg_tilemap,0,0);
85   mosaic_state *state = (mosaic_state *)screen->machine->driver_data;
86
87   tilemap_draw(bitmap, cliprect, state->bg_tilemap, 0, 0);
88   tilemap_draw(bitmap, cliprect, state->fg_tilemap, 0, 0);
8689   return 0;
8790}
src/mame/video/nitedrvr.c
r7500r7501
77#include "emu.h"
88#include "includes/nitedrvr.h"
99
10UINT8 *nitedrvr_hvc;
11
12static tilemap_t *bg_tilemap;
13
1410WRITE8_HANDLER( nitedrvr_videoram_w )
1511{
16   space->machine->generic.videoram.u8[offset] = data;
17   tilemap_mark_tile_dirty(bg_tilemap, offset);
12   nitedrvr_state *state = (nitedrvr_state *)space->machine->driver_data;
13
14   state->videoram[offset] = data;
15   tilemap_mark_tile_dirty(state->bg_tilemap, offset);
1816}
1917
2018WRITE8_HANDLER( nitedrvr_hvc_w )
2119{
22   nitedrvr_hvc[offset & 0x3f] = data;
20   nitedrvr_state *state = (nitedrvr_state *)space->machine->driver_data;
2321
22   state->hvc[offset & 0x3f] = data;
23
2424   if ((offset & 0x30) == 0x30)
2525      watchdog_reset_w(space, 0, 0);
2626}
2727
2828static TILE_GET_INFO( get_bg_tile_info )
2929{
30   int code = machine->generic.videoram.u8[tile_index] & 0x3f;
30   nitedrvr_state *state = (nitedrvr_state *)machine->driver_data;
31   int code = state->videoram[tile_index] & 0x3f;
3132
3233   SET_TILE_INFO(0, code, 0, 0);
3334}
r7500r7501
3637
3738VIDEO_START( nitedrvr )
3839{
39   bg_tilemap = tilemap_create(machine, get_bg_tile_info, tilemap_scan_rows, 8, 8, 32, 32);
40   nitedrvr_state *state = (nitedrvr_state *)machine->driver_data;
41   state->bg_tilemap = tilemap_create(machine, get_bg_tile_info, tilemap_scan_rows, 8, 8, 32, 32);
4042}
4143
42static void draw_box(bitmap_t *bitmap, int bx, int by, int ex, int ey )
44static void draw_box( bitmap_t *bitmap, int bx, int by, int ex, int ey )
4345{
4446   int x, y;
4547
r7500r7501
5355   return;
5456}
5557
56static void draw_roadway(bitmap_t *bitmap)
58static void draw_roadway( running_machine *machine, bitmap_t *bitmap )
5759{
60   nitedrvr_state *state = (nitedrvr_state *)machine->driver_data;
5861   int roadway;
5962
6063   for (roadway = 0; roadway < 16; roadway++)
6164   {
6265      int bx, by, ex, ey;
6366
64      bx = nitedrvr_hvc[roadway];
65      by = nitedrvr_hvc[roadway + 16];
66      ex = bx + ((nitedrvr_hvc[roadway + 32] & 0xf0) >> 4);
67      ey = by + (16 - (nitedrvr_hvc[roadway + 32] & 0x0f));
67      bx = state->hvc[roadway];
68      by = state->hvc[roadway + 16];
69      ex = bx + ((state->hvc[roadway + 32] & 0xf0) >> 4);
70      ey = by + (16 - (state->hvc[roadway + 32] & 0x0f));
6871
6972      draw_box(bitmap, bx, by, ex, ey);
7073   }
r7500r7501
7275
7376VIDEO_UPDATE( nitedrvr )
7477{
75   tilemap_draw(bitmap, cliprect, bg_tilemap, 0, 0);
76   draw_roadway(bitmap);
78   nitedrvr_state *state = (nitedrvr_state *)screen->machine->driver_data;
79
80   tilemap_draw(bitmap, cliprect, state->bg_tilemap, 0, 0);
81   draw_roadway(screen->machine, bitmap);
7782   return 0;
7883}
src/mame/drivers/nycaptor.c
r7500r7501
153153#include "sound/msm5232.h"
154154#include "includes/nycaptor.h"
155155
156UINT8 *nycaptor_sharedram;
157static int generic_control_reg = 0;
158static int sound_nmi_enable=0,pending_nmi=0;
159int nyc_gametype=0;
160156
161157static WRITE8_HANDLER( sub_cpu_halt_w )
162158{
163   cputag_set_input_line(space->machine, "sub", INPUT_LINE_HALT, (data) ? ASSERT_LINE : CLEAR_LINE);
159   nycaptor_state *state = (nycaptor_state *)space->machine->driver_data;
160   cpu_set_input_line(state->subcpu, INPUT_LINE_HALT, (data) ? ASSERT_LINE : CLEAR_LINE);
164161}
165162
166static UINT8 snd_data;
167
168163static READ8_HANDLER( from_snd_r )
169164{
170   return snd_data;
165   nycaptor_state *state = (nycaptor_state *)space->machine->driver_data;
166   return state->snd_data;
171167}
172168
173169static WRITE8_HANDLER( to_main_w )
174170{
175   snd_data = data;
171   nycaptor_state *state = (nycaptor_state *)space->machine->driver_data;
172   state->snd_data = data;
176173}
177174
178175
179176static READ8_HANDLER(nycaptor_sharedram_r)
180177{
181   return nycaptor_sharedram[offset];
178   nycaptor_state *state = (nycaptor_state *)space->machine->driver_data;
179   return state->sharedram[offset];
182180}
183181
184182static WRITE8_HANDLER(nycaptor_sharedram_w)
185183{
186   nycaptor_sharedram[offset]=data;
184   nycaptor_state *state = (nycaptor_state *)space->machine->driver_data;
185   state->sharedram[offset] = data;
187186}
188187
189
190188static READ8_HANDLER( nycaptor_b_r )
191189{
192190   return 1;
r7500r7501
194192
195193static READ8_HANDLER( nycaptor_by_r )
196194{
197   int port=input_port_read(space->machine, "LIGHTY");
198   if(nyc_gametype == 1)
195   nycaptor_state *state = (nycaptor_state *)space->machine->driver_data;
196   int port = input_port_read(space->machine, "LIGHTY");
197
198   if (state->gametype == 1)
199199      port = 255 - port;
200
200201   return port - 8;
201202}
202203
r7500r7501
208209
209210static WRITE8_HANDLER( sound_cpu_reset_w )
210211{
211   cputag_set_input_line(space->machine, "audiocpu", INPUT_LINE_RESET, (data&1 )? ASSERT_LINE : CLEAR_LINE);
212   nycaptor_state *state = (nycaptor_state *)space->machine->driver_data;
213   cpu_set_input_line(state->audiocpu, INPUT_LINE_RESET, (data&1 )? ASSERT_LINE : CLEAR_LINE);
212214}
213215
214static int vol_ctrl[16];
215216
216217static MACHINE_RESET( ta7630 )
217218{
219   nycaptor_state *state = (nycaptor_state *)machine->driver_data;
218220   int i;
219
220221   double db         = 0.0;
221222   double db_step      = 0.50;   /* 0.50 dB step (at least, maybe more) */
222223   double db_step_inc   = 0.275;
223   for (i=0; i<16; i++)
224
225   for (i = 0; i < 16; i++)
224226   {
225227      double max = 100.0 / pow(10.0, db/20.0 );
226      vol_ctrl[ 15-i ] = max;
227      /*logerror("vol_ctrl[%x] = %i (%f dB)\n",15-i,vol_ctrl[ 15-i ],db);*/
228      state->vol_ctrl[15 - i] = max;
229      /*logerror("vol_ctrl[%x] = %i (%f dB)\n", 15 - i, state->vol_ctrl[15 - i], db);*/
228230      db += db_step;
229231      db_step += db_step_inc;
230232   }
r7500r7501
232234
233235static TIMER_CALLBACK( nmi_callback )
234236{
235   if (sound_nmi_enable) cputag_set_input_line(machine, "audiocpu", INPUT_LINE_NMI, PULSE_LINE);
236   else pending_nmi = 1;
237   nycaptor_state *state = (nycaptor_state *)machine->driver_data;
238   if (state->sound_nmi_enable)
239      cpu_set_input_line(state->audiocpu, INPUT_LINE_NMI, PULSE_LINE);
240   else
241      state->pending_nmi = 1;
237242}
238243
239244static WRITE8_HANDLER( sound_command_w )
240245{
241   soundlatch_w(space,0,data);
242   timer_call_after_resynch(space->machine, NULL, data,nmi_callback);
246   soundlatch_w(space, 0, data);
247   timer_call_after_resynch(space->machine, NULL, data, nmi_callback);
243248}
244249
245250static WRITE8_HANDLER( nmi_disable_w )
246251{
247   sound_nmi_enable = 0;
252   nycaptor_state *state = (nycaptor_state *)space->machine->driver_data;
253   state->sound_nmi_enable = 0;
248254}
249255
250256static WRITE8_HANDLER( nmi_enable_w )
251257{
252   sound_nmi_enable = 1;
253   if (pending_nmi)
258   nycaptor_state *state = (nycaptor_state *)space->machine->driver_data;
259   state->sound_nmi_enable = 1;
260
261   if (state->pending_nmi)
254262   {
255      cputag_set_input_line(space->machine, "audiocpu", INPUT_LINE_NMI, PULSE_LINE);
256      pending_nmi = 0;
263      cpu_set_input_line(state->audiocpu, INPUT_LINE_NMI, PULSE_LINE);
264      state->pending_nmi = 0;
257265   }
258266}
259267
r7500r7501
280288
281289static READ8_HANDLER ( nycaptor_generic_control_r )
282290{
283   return generic_control_reg;
291   nycaptor_state *state = (nycaptor_state *)space->machine->driver_data;
292   return state->generic_control_reg;
284293}
285294
286295static WRITE8_HANDLER( nycaptor_generic_control_w )
287296{
288   generic_control_reg = data;
297   nycaptor_state *state = (nycaptor_state *)space->machine->driver_data;
298   state->generic_control_reg = data;
289299   memory_set_bankptr(space->machine, "bank1", memory_region(space->machine, "maincpu") + 0x10000 + ((data&0x08)>>3)*0x4000 );
290300}
291301
292302static ADDRESS_MAP_START( nycaptor_master_map, ADDRESS_SPACE_PROGRAM, 8 )
293303   AM_RANGE(0x0000, 0x7fff) AM_ROM
294304   AM_RANGE(0x8000, 0xbfff) AM_ROMBANK("bank1")
295   AM_RANGE(0xc000, 0xc7ff) AM_READ(nycaptor_videoram_r) AM_WRITE(nycaptor_videoram_w) AM_BASE_GENERIC(videoram) AM_SIZE_GENERIC(videoram)
296   AM_RANGE(0xd000, 0xd000) AM_READ(nycaptor_mcu_r) AM_WRITE(nycaptor_mcu_w)
305   AM_RANGE(0xc000, 0xc7ff) AM_READWRITE(nycaptor_videoram_r, nycaptor_videoram_w) AM_BASE_SIZE_MEMBER(nycaptor_state, videoram, videoram_size)
306   AM_RANGE(0xd000, 0xd000) AM_READWRITE(nycaptor_mcu_r, nycaptor_mcu_w)
297307   AM_RANGE(0xd001, 0xd001) AM_WRITE(sub_cpu_halt_w)
298   AM_RANGE(0xd002, 0xd002) AM_READ(nycaptor_generic_control_r) AM_WRITE(nycaptor_generic_control_w)   /* bit 3 - memory bank at 0x8000-0xbfff */
299   AM_RANGE(0xd400, 0xd400) AM_READ(from_snd_r) AM_WRITE(sound_command_w)
308   AM_RANGE(0xd002, 0xd002) AM_READWRITE(nycaptor_generic_control_r, nycaptor_generic_control_w)   /* bit 3 - memory bank at 0x8000-0xbfff */
309   AM_RANGE(0xd400, 0xd400) AM_READWRITE(from_snd_r, sound_command_w)
300310   AM_RANGE(0xd401, 0xd401) AM_READNOP
301311   AM_RANGE(0xd403, 0xd403) AM_WRITE(sound_cpu_reset_w)
302312   AM_RANGE(0xd800, 0xd800) AM_READ_PORT("DSW0")
r7500r7501
307317   AM_RANGE(0xd805, 0xd805) AM_READ(nycaptor_mcu_status_r1)
308318   AM_RANGE(0xd806, 0xd806) AM_READNOP /* unknown ?sound? */
309319   AM_RANGE(0xd807, 0xd807) AM_READ(nycaptor_mcu_status_r2)
310   AM_RANGE(0xdc00, 0xdc9f) AM_READ(nycaptor_spriteram_r) AM_WRITE(nycaptor_spriteram_w)
311   AM_RANGE(0xdca0, 0xdcbf) AM_READ(nycaptor_scrlram_r) AM_WRITE(nycaptor_scrlram_w) AM_BASE(&nycaptor_scrlram)
320   AM_RANGE(0xdc00, 0xdc9f) AM_READWRITE(nycaptor_spriteram_r, nycaptor_spriteram_w)
321   AM_RANGE(0xdca0, 0xdcbf) AM_READWRITE(nycaptor_scrlram_r, nycaptor_scrlram_w) AM_BASE_MEMBER(nycaptor_state, scrlram)
312322   AM_RANGE(0xdce1, 0xdce1) AM_WRITENOP
313   AM_RANGE(0xdd00, 0xdeff) AM_READ(nycaptor_palette_r) AM_WRITE(nycaptor_palette_w)
314   AM_RANGE(0xdf03, 0xdf03) AM_READ(nycaptor_gfxctrl_r) AM_WRITE(nycaptor_gfxctrl_w)
315   AM_RANGE(0xe000, 0xffff) AM_READ(nycaptor_sharedram_r)  AM_WRITE(nycaptor_sharedram_w) AM_BASE(&nycaptor_sharedram)
323   AM_RANGE(0xdd00, 0xdeff) AM_READWRITE(nycaptor_palette_r, nycaptor_palette_w)
324   AM_RANGE(0xdf03, 0xdf03) AM_READWRITE(nycaptor_gfxctrl_r, nycaptor_gfxctrl_w)
325   AM_RANGE(0xe000, 0xffff) AM_READWRITE(nycaptor_sharedram_r, nycaptor_sharedram_w) AM_BASE_MEMBER(nycaptor_state, sharedram)
316326ADDRESS_MAP_END
317327
318328static ADDRESS_MAP_START( nycaptor_slave_map, ADDRESS_SPACE_PROGRAM, 8 )
319329   AM_RANGE(0x0000, 0x7fff) AM_ROM
320   AM_RANGE(0xc000, 0xc7ff) AM_READ(nycaptor_videoram_r) AM_WRITE(nycaptor_videoram_w) AM_BASE_GENERIC(videoram) AM_SIZE_GENERIC(videoram)
330   AM_RANGE(0xc000, 0xc7ff) AM_READWRITE(nycaptor_videoram_r, nycaptor_videoram_w) AM_BASE_SIZE_MEMBER(nycaptor_state, videoram, videoram_size)
321331   AM_RANGE(0xd800, 0xd800) AM_READ_PORT("DSW0")
322332   AM_RANGE(0xd801, 0xd801) AM_READ_PORT("DSW1")
323333   AM_RANGE(0xd802, 0xd802) AM_READ_PORT("DSW2")
324334   AM_RANGE(0xd803, 0xd803) AM_READ_PORT("IN0")
325335   AM_RANGE(0xd804, 0xd804) AM_READ_PORT("IN1")
326   AM_RANGE(0xdc00, 0xdc9f) AM_READ(nycaptor_spriteram_r) AM_WRITE(nycaptor_spriteram_w)
327   AM_RANGE(0xdca0, 0xdcbf) AM_WRITE(nycaptor_scrlram_w) AM_BASE(&nycaptor_scrlram)
336   AM_RANGE(0xdc00, 0xdc9f) AM_READWRITE(nycaptor_spriteram_r, nycaptor_spriteram_w)
337   AM_RANGE(0xdca0, 0xdcbf) AM_WRITE(nycaptor_scrlram_w) AM_BASE_MEMBER(nycaptor_state, scrlram)
328338
329   AM_RANGE(0xdd00, 0xdeff) AM_READ(nycaptor_palette_r) AM_WRITE(nycaptor_palette_w)
339   AM_RANGE(0xdd00, 0xdeff) AM_READWRITE(nycaptor_palette_r, nycaptor_palette_w)
330340   AM_RANGE(0xdf00, 0xdf00) AM_READ(nycaptor_bx_r)
331341   AM_RANGE(0xdf01, 0xdf01) AM_READ(nycaptor_by_r)
332342   AM_RANGE(0xdf02, 0xdf02) AM_READ(nycaptor_b_r)
333343   AM_RANGE(0xdf03, 0xdf03) AM_READ(nycaptor_gfxctrl_r) AM_WRITENOP/* ? gfx control ? */
334   AM_RANGE(0xe000, 0xffff) AM_READ(nycaptor_sharedram_r) AM_WRITE(nycaptor_sharedram_w)
344   AM_RANGE(0xe000, 0xffff) AM_READWRITE(nycaptor_sharedram_r, nycaptor_sharedram_w)
335345ADDRESS_MAP_END
336346
337347static ADDRESS_MAP_START( nycaptor_sound_map, ADDRESS_SPACE_PROGRAM, 8 )
r7500r7501
343353   AM_RANGE(0xca00, 0xca00) AM_WRITENOP
344354   AM_RANGE(0xcb00, 0xcb00) AM_WRITENOP
345355   AM_RANGE(0xcc00, 0xcc00) AM_WRITENOP
346   AM_RANGE(0xd000, 0xd000) AM_READ(soundlatch_r) AM_WRITE(to_main_w)
356   AM_RANGE(0xd000, 0xd000) AM_READWRITE(soundlatch_r, to_main_w)
347357   AM_RANGE(0xd200, 0xd200) AM_READNOP AM_WRITE(nmi_enable_w)
348358   AM_RANGE(0xd400, 0xd400) AM_WRITE(nmi_disable_w)
349359   AM_RANGE(0xd600, 0xd600) AM_WRITENOP
r7500r7501
352362
353363static ADDRESS_MAP_START( nycaptor_m68705_map, ADDRESS_SPACE_PROGRAM, 8 )
354364   ADDRESS_MAP_GLOBAL_MASK(0x7ff)
355   AM_RANGE(0x0000, 0x0000) AM_READWRITE(nycaptor_68705_portA_r,nycaptor_68705_portA_w)
356   AM_RANGE(0x0001, 0x0001) AM_READWRITE(nycaptor_68705_portB_r,nycaptor_68705_portB_w)
357   AM_RANGE(0x0002, 0x0002) AM_READWRITE(nycaptor_68705_portC_r,nycaptor_68705_portC_w)
358   AM_RANGE(0x0004, 0x0004) AM_WRITE(nycaptor_68705_ddrA_w)
359   AM_RANGE(0x0005, 0x0005) AM_WRITE(nycaptor_68705_ddrB_w)
360   AM_RANGE(0x0006, 0x0006) AM_WRITE(nycaptor_68705_ddrC_w)
365   AM_RANGE(0x0000, 0x0000) AM_READWRITE(nycaptor_68705_port_a_r, nycaptor_68705_port_a_w)
366   AM_RANGE(0x0001, 0x0001) AM_READWRITE(nycaptor_68705_port_b_r, nycaptor_68705_port_b_w)
367   AM_RANGE(0x0002, 0x0002) AM_READWRITE(nycaptor_68705_port_c_r, nycaptor_68705_port_c_w)
368   AM_RANGE(0x0004, 0x0004) AM_WRITE(nycaptor_68705_ddr_a_w)
369   AM_RANGE(0x0005, 0x0005) AM_WRITE(nycaptor_68705_ddr_b_w)
370   AM_RANGE(0x0006, 0x0006) AM_WRITE(nycaptor_68705_ddr_c_w)
361371   AM_RANGE(0x0010, 0x007f) AM_RAM
362372   AM_RANGE(0x0080, 0x07ff) AM_ROM
363373ADDRESS_MAP_END
r7500r7501
368378
369379static READ8_HANDLER(cyclshtg_mcu_status_r)
370380{
371  return 0xff;
381   return 0xff;
372382}
373383
374384static READ8_HANDLER(cyclshtg_mcu_r)
375385{
376  return 7;
386   return 7;
377387}
378388
379389static WRITE8_HANDLER(cyclshtg_mcu_w)
r7500r7501
383393
384394static READ8_HANDLER(cyclshtg_mcu_status_r1)
385395{
386  return mame_rand(space->machine);
396   return mame_rand(space->machine);
387397}
388398
389399static WRITE8_HANDLER( cyclshtg_generic_control_w )
390400{
391   int bank=(data>>2)&3;
392   generic_control_reg = data;
401   nycaptor_state *state = (nycaptor_state *)space->machine->driver_data;
402   int bank = (data >> 2) & 3;
403
404   state->generic_control_reg = data;
393405   memory_set_bankptr(space->machine, "bank1", memory_region(space->machine, "maincpu") + 0x10000 + bank*0x4000 );
394406}
395407
r7500r7501
397409static ADDRESS_MAP_START( cyclshtg_master_map, ADDRESS_SPACE_PROGRAM, 8 )
398410   AM_RANGE(0x0000, 0x7fff) AM_ROM
399411   AM_RANGE(0x8000, 0xbfff) AM_ROMBANK("bank1")
400   AM_RANGE(0xc000, 0xcfff) AM_READ(nycaptor_videoram_r) AM_WRITE(nycaptor_videoram_w) AM_BASE_GENERIC(videoram) AM_SIZE_GENERIC(videoram)
401   AM_RANGE(0xd000, 0xd000) AM_READ(cyclshtg_mcu_r) AM_WRITE(cyclshtg_mcu_w)
412   AM_RANGE(0xc000, 0xcfff) AM_READWRITE(nycaptor_videoram_r, nycaptor_videoram_w) AM_BASE_SIZE_MEMBER(nycaptor_state, videoram, videoram_size)
413   AM_RANGE(0xd000, 0xd000) AM_READWRITE(cyclshtg_mcu_r, cyclshtg_mcu_w)
402414   AM_RANGE(0xd001, 0xd001) AM_WRITE(sub_cpu_halt_w)
403   AM_RANGE(0xd002, 0xd002) AM_READ(nycaptor_generic_control_r) AM_WRITE(cyclshtg_generic_control_w)
404   AM_RANGE(0xd400, 0xd400) AM_READ(from_snd_r) AM_WRITE(sound_command_w)
415   AM_RANGE(0xd002, 0xd002) AM_READWRITE(nycaptor_generic_control_r, cyclshtg_generic_control_w)
416   AM_RANGE(0xd400, 0xd400) AM_READWRITE(from_snd_r, sound_command_w)
405417   AM_RANGE(0xd403, 0xd403) AM_WRITE(sound_cpu_reset_w)
406418   AM_RANGE(0xd800, 0xd800) AM_READ_PORT("DSW0")
407419   AM_RANGE(0xd801, 0xd801) AM_READ_PORT("DSW1")
r7500r7501
411423   AM_RANGE(0xd805, 0xd805) AM_READ(cyclshtg_mcu_status_r)
412424   AM_RANGE(0xd806, 0xd806) AM_READNOP
413425   AM_RANGE(0xd807, 0xd807) AM_READ(cyclshtg_mcu_status_r)
414   AM_RANGE(0xdc00, 0xdc9f) AM_READ(nycaptor_spriteram_r) AM_WRITE(nycaptor_spriteram_w)
415   AM_RANGE(0xdca0, 0xdcbf) AM_READ(nycaptor_scrlram_r) AM_WRITE(nycaptor_scrlram_w) AM_BASE(&nycaptor_scrlram)
426   AM_RANGE(0xdc00, 0xdc9f) AM_READWRITE(nycaptor_spriteram_r, nycaptor_spriteram_w)
427   AM_RANGE(0xdca0, 0xdcbf) AM_READWRITE(nycaptor_scrlram_r, nycaptor_scrlram_w) AM_BASE_MEMBER(nycaptor_state, scrlram)
416428   AM_RANGE(0xdce1, 0xdce1) AM_WRITENOP
417   AM_RANGE(0xdd00, 0xdeff) AM_READ(nycaptor_palette_r) AM_WRITE(nycaptor_palette_w)
418   AM_RANGE(0xdf03, 0xdf03) AM_READ(nycaptor_gfxctrl_r) AM_WRITE(nycaptor_gfxctrl_w)
419   AM_RANGE(0xe000, 0xffff) AM_READ(nycaptor_sharedram_r) AM_WRITE(nycaptor_sharedram_w) AM_BASE(&nycaptor_sharedram)
429   AM_RANGE(0xdd00, 0xdeff) AM_READWRITE(nycaptor_palette_r, nycaptor_palette_w)
430   AM_RANGE(0xdf03, 0xdf03) AM_READWRITE(nycaptor_gfxctrl_r, nycaptor_gfxctrl_w)
431   AM_RANGE(0xe000, 0xffff) AM_READWRITE(nycaptor_sharedram_r, nycaptor_sharedram_w) AM_BASE_MEMBER(nycaptor_state, sharedram)
420432ADDRESS_MAP_END
421433
422434static ADDRESS_MAP_START( cyclshtg_slave_map, ADDRESS_SPACE_PROGRAM, 8 )
423435   AM_RANGE(0x0000, 0xbfff) AM_ROM
424   AM_RANGE(0xc000, 0xcfff) AM_READ(nycaptor_videoram_r) AM_WRITE(nycaptor_videoram_w) AM_BASE_GENERIC(videoram) AM_SIZE_GENERIC(videoram)
436   AM_RANGE(0xc000, 0xcfff) AM_READWRITE(nycaptor_videoram_r, nycaptor_videoram_w) AM_BASE_SIZE_MEMBER(nycaptor_state, videoram, videoram_size)
425437   AM_RANGE(0xd800, 0xd800) AM_READ_PORT("DSW0")
426438   AM_RANGE(0xd801, 0xd801) AM_READ_PORT("DSW1")
427439   AM_RANGE(0xd802, 0xd802) AM_READ_PORT("DSW2")
428440   AM_RANGE(0xd803, 0xd803) AM_READ_PORT("IN0")
429441   AM_RANGE(0xd804, 0xd804) AM_READ_PORT("IN1")
430   AM_RANGE(0xdc00, 0xdc9f) AM_READ(nycaptor_spriteram_r) AM_WRITE(nycaptor_spriteram_w)
431   AM_RANGE(0xdca0, 0xdcbf) AM_WRITE(nycaptor_scrlram_w) AM_BASE(&nycaptor_scrlram)
432   AM_RANGE(0xdd00, 0xdeff) AM_READ(nycaptor_palette_r) AM_WRITE(nycaptor_palette_w)
442   AM_RANGE(0xdc00, 0xdc9f) AM_READWRITE(nycaptor_spriteram_r, nycaptor_spriteram_w)
443   AM_RANGE(0xdca0, 0xdcbf) AM_WRITE(nycaptor_scrlram_w) AM_BASE_MEMBER(nycaptor_state, scrlram)
444   AM_RANGE(0xdd00, 0xdeff) AM_READWRITE(nycaptor_palette_r, nycaptor_palette_w)
433445   AM_RANGE(0xdf00, 0xdf00) AM_READ(nycaptor_bx_r)
434446   AM_RANGE(0xdf01, 0xdf01) AM_READ(nycaptor_by_r)
435447   AM_RANGE(0xdf02, 0xdf02) AM_READ(nycaptor_b_r)
436448   AM_RANGE(0xdf03, 0xdf03) AM_READ(nycaptor_gfxctrl_r)
437449   AM_RANGE(0xdf03, 0xdf03) AM_WRITENOP
438   AM_RANGE(0xe000, 0xffff) AM_READ(nycaptor_sharedram_r) AM_WRITE(nycaptor_sharedram_w)
450   AM_RANGE(0xe000, 0xffff) AM_READWRITE(nycaptor_sharedram_r, nycaptor_sharedram_w)
439451ADDRESS_MAP_END
440452
441static READ8_HANDLER(unk_r)
453static READ8_HANDLER( unk_r )
442454{
443  return mame_rand(space->machine);
455   return mame_rand(space->machine);
444456}
445457
446458static ADDRESS_MAP_START( bronx_master_map, ADDRESS_SPACE_PROGRAM, 8 )
447459   AM_RANGE(0x0000, 0x7fff) AM_ROM
448460   AM_RANGE(0x8000, 0xbfff) AM_ROMBANK("bank1")
449   AM_RANGE(0xc000, 0xcfff) AM_READ(nycaptor_videoram_r) AM_WRITE(nycaptor_videoram_w) AM_BASE_GENERIC(videoram) AM_SIZE_GENERIC(videoram)
461   AM_RANGE(0xc000, 0xcfff) AM_READWRITE(nycaptor_videoram_r, nycaptor_videoram_w) AM_BASE_SIZE_MEMBER(nycaptor_state, videoram, videoram_size)
450462   AM_RANGE(0xd000, 0xd000) AM_READ(cyclshtg_mcu_r) AM_WRITENOP
451463   AM_RANGE(0xd001, 0xd001) AM_WRITE(sub_cpu_halt_w)
452   AM_RANGE(0xd002, 0xd002) AM_READ(nycaptor_generic_control_r) AM_WRITE(cyclshtg_generic_control_w)
453   AM_RANGE(0xd400, 0xd400) AM_READ(from_snd_r) AM_WRITE(sound_command_w)
464   AM_RANGE(0xd002, 0xd002) AM_READWRITE(nycaptor_generic_control_r, cyclshtg_generic_control_w)
465   AM_RANGE(0xd400, 0xd400) AM_READWRITE(from_snd_r, sound_command_w)
454466   AM_RANGE(0xd401, 0xd401) AM_READ(unk_r)
455467   AM_RANGE(0xd403, 0xd403) AM_WRITE(sound_cpu_reset_w)
456468   AM_RANGE(0xd800, 0xd800) AM_READ_PORT("DSW0")
r7500r7501
461473   AM_RANGE(0xd805, 0xd805) AM_READ(cyclshtg_mcu_status_r)
462474   AM_RANGE(0xd806, 0xd806) AM_READNOP
463475   AM_RANGE(0xd807, 0xd807) AM_READ(cyclshtg_mcu_status_r)
464   AM_RANGE(0xdc00, 0xdc9f) AM_READ(nycaptor_spriteram_r) AM_WRITE(nycaptor_spriteram_w)
465   AM_RANGE(0xdca0, 0xdcbf) AM_READ(nycaptor_scrlram_r) AM_WRITE(nycaptor_scrlram_w) AM_BASE(&nycaptor_scrlram)
466   AM_RANGE(0xdd00, 0xdeff) AM_READ(nycaptor_palette_r) AM_WRITE(nycaptor_palette_w)
467   AM_RANGE(0xdf03, 0xdf03) AM_READ(nycaptor_gfxctrl_r) AM_WRITE(nycaptor_gfxctrl_w)
468   AM_RANGE(0xe000, 0xffff) AM_READ(nycaptor_sharedram_r) AM_WRITE(nycaptor_sharedram_w) AM_BASE(&nycaptor_sharedram)
476   AM_RANGE(0xdc00, 0xdc9f) AM_READWRITE(nycaptor_spriteram_r, nycaptor_spriteram_w)
477   AM_RANGE(0xdca0, 0xdcbf) AM_READWRITE(nycaptor_scrlram_r, nycaptor_scrlram_w) AM_BASE_MEMBER(nycaptor_state, scrlram)
478   AM_RANGE(0xdd00, 0xdeff) AM_READWRITE(nycaptor_palette_r, nycaptor_palette_w)
479   AM_RANGE(0xdf03, 0xdf03) AM_READWRITE(nycaptor_gfxctrl_r, nycaptor_gfxctrl_w)
480   AM_RANGE(0xe000, 0xffff) AM_READWRITE(nycaptor_sharedram_r, nycaptor_sharedram_w) AM_BASE_MEMBER(nycaptor_state, sharedram)
469481ADDRESS_MAP_END
470482
471483static ADDRESS_MAP_START( bronx_slave_map, ADDRESS_SPACE_PROGRAM, 8 )
472484   AM_RANGE(0x0000, 0x7fff) AM_ROM
473   AM_RANGE(0xc000, 0xcfff) AM_READ(nycaptor_videoram_r) AM_WRITE(nycaptor_videoram_w) AM_BASE_GENERIC(videoram) AM_SIZE_GENERIC(videoram)
485   AM_RANGE(0xc000, 0xcfff) AM_READWRITE(nycaptor_videoram_r, nycaptor_videoram_w) AM_BASE_SIZE_MEMBER(nycaptor_state, videoram, videoram_size)
474486   AM_RANGE(0xd800, 0xd800) AM_READ_PORT("DSW0")
475487   AM_RANGE(0xd801, 0xd801) AM_READ_PORT("DSW1")
476488   AM_RANGE(0xd802, 0xd802) AM_READ_PORT("DSW2")
r7500r7501
478490   AM_RANGE(0xd804, 0xd804) AM_READ_PORT("IN1")
479491   AM_RANGE(0xd805, 0xd805) AM_READ(cyclshtg_mcu_status_r1)
480492   AM_RANGE(0xd807, 0xd807) AM_READ(cyclshtg_mcu_status_r)
481   AM_RANGE(0xdc00, 0xdc9f) AM_READ(nycaptor_spriteram_r) AM_WRITE(nycaptor_spriteram_w)
482   AM_RANGE(0xdca0, 0xdcbf) AM_WRITE(nycaptor_scrlram_w) AM_BASE(&nycaptor_scrlram)
483   AM_RANGE(0xdd00, 0xdeff) AM_READ(nycaptor_palette_r) AM_WRITE(nycaptor_palette_w)
493   AM_RANGE(0xdc00, 0xdc9f) AM_READWRITE(nycaptor_spriteram_r, nycaptor_spriteram_w)
494   AM_RANGE(0xdca0, 0xdcbf) AM_WRITE(nycaptor_scrlram_w) AM_BASE_MEMBER(nycaptor_state, scrlram)
495   AM_RANGE(0xdd00, 0xdeff) AM_READWRITE(nycaptor_palette_r, nycaptor_palette_w)
484496   AM_RANGE(0xdf00, 0xdf00) AM_READ(nycaptor_bx_r)
485497   AM_RANGE(0xdf01, 0xdf01) AM_READ(nycaptor_by_r)
486498   AM_RANGE(0xdf02, 0xdf02) AM_READ(nycaptor_b_r)
487   AM_RANGE(0xdf03, 0xdf03) AM_READ(nycaptor_gfxctrl_r) AM_WRITE(nycaptor_gfxctrl_w)
488   AM_RANGE(0xe000, 0xffff) AM_READ(nycaptor_sharedram_r) AM_WRITE(nycaptor_sharedram_w)
499   AM_RANGE(0xdf03, 0xdf03) AM_READWRITE(nycaptor_gfxctrl_r, nycaptor_gfxctrl_w)
500   AM_RANGE(0xe000, 0xffff) AM_READWRITE(nycaptor_sharedram_r, nycaptor_sharedram_w)
489501ADDRESS_MAP_END
490502
491503static ADDRESS_MAP_START( bronx_slave_io_map, ADDRESS_SPACE_IO, 8 )
r7500r7501
683695
684696
685697
698static MACHINE_START( nycaptor )
699{
700   nycaptor_state *state = (nycaptor_state *)machine->driver_data;
701
702   state->maincpu = devtag_get_device(machine, "maincpu");
703   state->audiocpu = devtag_get_device(machine, "audiocpu");
704   state->subcpu = devtag_get_device(machine, "sub");
705   state->mcu = devtag_get_device(machine, "mcu");
706
707   state_save_register_global(machine, state->generic_control_reg);
708   state_save_register_global(machine, state->sound_nmi_enable);
709   state_save_register_global(machine, state->pending_nmi);
710   state_save_register_global(machine, state->snd_data);
711   state_save_register_global_array(machine, state->vol_ctrl);
712
713   state_save_register_global(machine, state->char_bank);
714   state_save_register_global(machine, state->palette_bank);
715   state_save_register_global(machine, state->gfxctrl);
716
717   state_save_register_global(machine, state->port_a_in);
718   state_save_register_global(machine, state->port_a_out);
719   state_save_register_global(machine, state->ddr_a);
720   state_save_register_global(machine, state->port_b_in);
721   state_save_register_global(machine, state->port_b_out);
722   state_save_register_global(machine, state->ddr_b);
723   state_save_register_global(machine, state->port_c_in);
724   state_save_register_global(machine, state->port_c_out);
725   state_save_register_global(machine, state->ddr_c);
726   state_save_register_global(machine, state->mcu_sent);
727   state_save_register_global(machine, state->main_sent);
728   state_save_register_global(machine, state->from_main);
729   state_save_register_global(machine, state->from_mcu);
730}
731
732static MACHINE_RESET( nycaptor )
733{
734   nycaptor_state *state = (nycaptor_state *)machine->driver_data;
735
736   MACHINE_RESET_CALL(ta7630);
737
738   state->generic_control_reg = 0;
739   state->sound_nmi_enable = 0;
740   state->pending_nmi = 0;
741   state->snd_data = 0;
742
743   state->char_bank = 0;
744   state->palette_bank = 0;
745   state->gfxctrl = 0;
746
747   state->port_a_in = 0;
748   state->port_a_out = 0;
749   state->ddr_a = 0;
750   state->port_b_in = 0;
751   state->port_b_out = 0;
752   state->ddr_b = 0;
753   state->port_c_in = 0;
754   state->port_c_out = 0;
755   state->ddr_c = 0;
756   state->mcu_sent = 0;
757   state->main_sent = 0;
758   state->from_main = 0;
759   state->from_mcu = 0;
760
761   memset(state->vol_ctrl, 0, ARRAY_LENGTH(state->vol_ctrl));
762}
763
686764static MACHINE_DRIVER_START( nycaptor )
765
766   /* driver data */
767   MDRV_DRIVER_DATA(nycaptor_state)
768
687769   /* basic machine hardware */
688770   MDRV_CPU_ADD("maincpu", Z80,8000000/2)      /* ??? */
689771   MDRV_CPU_PROGRAM_MAP(nycaptor_master_map)
r7500r7501
702784
703785   MDRV_QUANTUM_TIME(HZ(6000))   /* 100 CPU slices per frame - an high value to ensure proper synchronization of the CPUs */
704786
705   MDRV_MACHINE_RESET(ta7630)
787   MDRV_MACHINE_START(nycaptor)
788   MDRV_MACHINE_RESET(nycaptor)
706789
707790   /* video hardware */
708791   MDRV_SCREEN_ADD("screen", RASTER)
r7500r7501
745828MACHINE_DRIVER_END
746829
747830static MACHINE_DRIVER_START( cyclshtg )
831
832   /* driver data */
833   MDRV_DRIVER_DATA(nycaptor_state)
834
748835   MDRV_CPU_ADD("maincpu", Z80,8000000/2)
749836   MDRV_CPU_PROGRAM_MAP(cyclshtg_master_map)
750837   MDRV_CPU_VBLANK_INT("screen", irq0_line_hold)
r7500r7501
763850#endif
764851
765852   MDRV_QUANTUM_TIME(HZ(60))
766   MDRV_MACHINE_RESET(ta7630)
853   MDRV_MACHINE_START(nycaptor)
854   MDRV_MACHINE_RESET(nycaptor)
767855
768856   MDRV_SCREEN_ADD("screen", RASTER)
769857   MDRV_SCREEN_REFRESH_RATE(60)
r7500r7501
805893
806894
807895static MACHINE_DRIVER_START( bronx )
896
897   /* driver data */
898   MDRV_DRIVER_DATA(nycaptor_state)
899
808900   MDRV_CPU_ADD("maincpu", Z80,8000000/2)
809901   MDRV_CPU_PROGRAM_MAP(bronx_master_map)
810902   MDRV_CPU_VBLANK_INT("screen", irq0_line_hold)
r7500r7501
819911   MDRV_CPU_PERIODIC_INT(irq0_line_hold,2*60)
820912
821913   MDRV_QUANTUM_TIME(HZ(120))
822   MDRV_MACHINE_RESET(ta7630)
914   MDRV_MACHINE_START(nycaptor)
915   MDRV_MACHINE_RESET(nycaptor)
823916
824917   MDRV_SCREEN_ADD("screen", RASTER)
825918   MDRV_SCREEN_REFRESH_RATE(60)
r7500r7501
11891282   ROM_LOAD( "a50_14",   0x1c000, 0x4000, CRC(24b2f1bf) SHA1(4757aec2e4b99ce33d993ce1e19ee46a4eb76e86) )
11901283ROM_END
11911284
1192static DRIVER_INIT(bronx)
1285static DRIVER_INIT( bronx )
11931286{
1287   nycaptor_state *state = (nycaptor_state *)machine->driver_data;
11941288   int i;
11951289   UINT8 *rom = memory_region(machine, "maincpu");
1196   for(i=0;i<0x20000;i++)
1197      rom[i]=BITSWAP8(rom[i],0,1,2,3,4,5,6,7);
1198   nyc_gametype=1;
1290
1291   for (i = 0; i < 0x20000; i++)
1292      rom[i] = BITSWAP8(rom[i], 0, 1, 2, 3, 4, 5, 6, 7);
1293
1294   state->gametype = 1;
11991295}
12001296
1201static DRIVER_INIT(colt)
1297static DRIVER_INIT( colt )
12021298{
1299   nycaptor_state *state = (nycaptor_state *)machine->driver_data;
12031300   int i;
12041301   UINT8 *rom = memory_region(machine, "maincpu");
1205   for(i=0;i<0x20000;i++)
1206      rom[i]=BITSWAP8(rom[i],0,1,2,3,4,5,6,7);
1207   nyc_gametype=2;
1302
1303   for (i = 0; i < 0x20000; i++)
1304      rom[i] = BITSWAP8(rom[i], 0, 1, 2, 3, 4, 5, 6, 7);
1305
1306   state->gametype = 2;
12081307}
12091308
1210static DRIVER_INIT(nycaptor)
1309static DRIVER_INIT( nycaptor )
12111310{
1212   nyc_gametype=0;
1311   nycaptor_state *state = (nycaptor_state *)machine->driver_data;
1312   state->gametype = 0;
12131313}
12141314
1215static DRIVER_INIT(cyclshtg)
1315static DRIVER_INIT( cyclshtg )
12161316{
1217   nyc_gametype=1;
1317   nycaptor_state *state = (nycaptor_state *)machine->driver_data;
1318   state->gametype = 1;
12181319}
12191320
1220GAME( 1985, nycaptor, 0,       nycaptor,  nycaptor, nycaptor, ROT0,  "Taito", "N.Y. Captor", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
1221GAME( 1986, cyclshtg, 0,       cyclshtg,  cyclshtg, cyclshtg, ROT90, "Taito", "Cycle Shooting", GAME_NOT_WORKING)
1321GAME( 1985, nycaptor, 0,        nycaptor, nycaptor, nycaptor, ROT0,  "Taito",   "N.Y. Captor", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND | GAME_SUPPORTS_SAVE )
1322GAME( 1986, cyclshtg, 0,        cyclshtg, cyclshtg, cyclshtg, ROT90, "Taito",   "Cycle Shooting", GAME_NOT_WORKING | GAME_SUPPORTS_SAVE )
12221323/* bootlegs */
1223GAME( 1986, bronx, cyclshtg,       bronx,  cyclshtg, bronx, ROT90, "bootleg", "Bronx",GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND)
1224GAME( 1986, colt , nycaptor,       bronx,  nycaptor, colt, ROT0, "bootleg", "Colt",GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND|GAME_WRONG_COLORS)
1324GAME( 1986, bronx,    cyclshtg, bronx,    cyclshtg, bronx,    ROT90, "bootleg", "Bronx", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND | GAME_SUPPORTS_SAVE )
1325GAME( 1986, colt ,    nycaptor, bronx,    nycaptor, colt,     ROT0,  "bootleg", "Colt", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND | GAME_WRONG_COLORS | GAME_SUPPORTS_SAVE )
src/mame/drivers/mgolf.c
r7500r7501
77#include "emu.h"
88#include "cpu/m6502/m6502.h"
99
10static UINT8* mgolf_video_ram;
10class mgolf_state
11{
12public:
13   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, mgolf_state(machine)); }
1114
12static attotime time_pushed;
13static attotime time_released;
15   mgolf_state(running_machine &machine) { }
1416
15static UINT8 prev = 0;
16static UINT8 mask = 0;
17   /* memory pointers */
18   UINT8*   video_ram;
1719
18static tilemap_t* bg_tilemap;
20   /* video-related */
21   tilemap_t* bg_tilemap;
1922
23   /* misc */
24   UINT8 prev;
25   UINT8 mask;
26   attotime time_pushed;
27   attotime time_released;
2028
29   /* devices */
30   running_device *maincpu;
31};
32
33
2134static TILE_GET_INFO( get_tile_info )
2235{
23   UINT8 code = mgolf_video_ram[tile_index];
36   mgolf_state *state = (mgolf_state *)machine->driver_data;
37   UINT8 code = state->video_ram[tile_index];
2438
2539   SET_TILE_INFO(0, code, code >> 7, 0);
2640}
r7500r7501
2842
2943static WRITE8_HANDLER( mgolf_vram_w )
3044{
31   mgolf_video_ram[offset] = data;
32   tilemap_mark_tile_dirty(bg_tilemap, offset);
45   mgolf_state *state = (mgolf_state *)space->machine->driver_data;
46   state->video_ram[offset] = data;
47   tilemap_mark_tile_dirty(state->bg_tilemap, offset);
3348}
3449
3550
3651static VIDEO_START( mgolf )
3752{
38   bg_tilemap = tilemap_create(machine, get_tile_info, tilemap_scan_rows, 8, 8, 32, 32);
53   mgolf_state *state = (mgolf_state *)machine->driver_data;
54   state->bg_tilemap = tilemap_create(machine, get_tile_info, tilemap_scan_rows, 8, 8, 32, 32);
3955}
4056
4157
4258static VIDEO_UPDATE( mgolf )
4359{
60   mgolf_state *state = (mgolf_state *)screen->machine->driver_data;
4461   int i;
4562
4663   /* draw playfield */
64   tilemap_draw(bitmap, cliprect, state->bg_tilemap, 0, 0);
4765
48   tilemap_draw(bitmap, cliprect, bg_tilemap, 0, 0);
49
5066   /* draw sprites */
51
5267   for (i = 0; i < 2; i++)
5368   {
5469      drawgfx_transpen(bitmap, cliprect, screen->machine->gfx[1],
55         mgolf_video_ram[0x399 + 4 * i],
70         state->video_ram[0x399 + 4 * i],
5671         i,
5772         0, 0,
58         mgolf_video_ram[0x390 + 2 * i] - 7,
59         mgolf_video_ram[0x398 + 4 * i] - 16, 0);
73         state->video_ram[0x390 + 2 * i] - 7,
74         state->video_ram[0x398 + 4 * i] - 16, 0);
6075
6176      drawgfx_transpen(bitmap, cliprect, screen->machine->gfx[1],
62         mgolf_video_ram[0x39b + 4 * i],
77         state->video_ram[0x39b + 4 * i],
6378         i,
6479         0, 0,
65         mgolf_video_ram[0x390 + 2 * i] - 15,
66         mgolf_video_ram[0x39a + 4 * i] - 16, 0);
80         state->video_ram[0x390 + 2 * i] - 15,
81         state->video_ram[0x39a + 4 * i] - 16, 0);
6782   }
6883   return 0;
6984}
7085
7186
72static void update_plunger(running_machine *machine)
87static void update_plunger( running_machine *machine )
7388{
89   mgolf_state *state = (mgolf_state *)machine->driver_data;
7490   UINT8 val = input_port_read(machine, "BUTTON");
7591
76   if (prev != val)
92   if (state->prev != val)
7793   {
7894      if (val == 0)
7995      {
80         time_released = timer_get_time(machine);
96         state->time_released = timer_get_time(machine);
8197
82         if (!mask)
83            cputag_set_input_line(machine, "maincpu", INPUT_LINE_NMI, PULSE_LINE);
98         if (!state->mask)
99            cpu_set_input_line(state->maincpu, INPUT_LINE_NMI, PULSE_LINE);
84100      }
85101      else
86         time_pushed = timer_get_time(machine);
102         state->time_pushed = timer_get_time(machine);
87103
88      prev = val;
104      state->prev = val;
89105   }
90106}
91107
92108
93109static TIMER_CALLBACK( interrupt_callback )
94110{
111   mgolf_state *state = (mgolf_state *)machine->driver_data;
95112   int scanline = param;
96113
97114   update_plunger(machine);
98115
99   generic_pulse_irq_line(devtag_get_device(machine, "maincpu"), 0);
116   generic_pulse_irq_line(state->maincpu, 0);
100117
101118   scanline = scanline + 32;
102119
r7500r7501
109126
110127static double calc_plunger_pos(running_machine *machine)
111128{
112   return (attotime_to_double(timer_get_time(machine)) - attotime_to_double(time_released)) * (attotime_to_double(time_released) - attotime_to_double(time_pushed) + 0.2);
129   mgolf_state *state = (mgolf_state *)machine->driver_data;
130   return (attotime_to_double(timer_get_time(machine)) - attotime_to_double(state->time_released)) * (attotime_to_double(state->time_released) - attotime_to_double(state->time_pushed) + 0.2);
113131}
114132
115133
116static MACHINE_RESET( mgolf )
117{
118   timer_set(machine, video_screen_get_time_until_pos(machine->primary_screen, 16, 0), NULL, 16, interrupt_callback);
119}
120
121
122static PALETTE_INIT( mgolf )
123{
124   palette_set_color(machine, 0, MAKE_RGB(0x80, 0x80, 0x80));
125   palette_set_color(machine, 1, MAKE_RGB(0x00, 0x00, 0x00));
126   palette_set_color(machine, 2, MAKE_RGB(0x80, 0x80, 0x80));
127   palette_set_color(machine, 3, MAKE_RGB(0xff, 0xff, 0xff));
128}
129
130
131134static READ8_HANDLER( mgolf_wram_r )
132135{
133   return mgolf_video_ram[0x380 + offset];
136   mgolf_state *state = (mgolf_state *)space->machine->driver_data;
137   return state->video_ram[0x380 + offset];
134138}
135139
136140
r7500r7501
172176
173177static WRITE8_HANDLER( mgolf_wram_w )
174178{
175   mgolf_video_ram[0x380 + offset] = data;
179   mgolf_state *state = (mgolf_state *)space->machine->driver_data;
180   state->video_ram[0x380 + offset] = data;
176181}
177182
178183
r7500r7501
201206   AM_RANGE(0x006d, 0x006d) AM_WRITENOP
202207   AM_RANGE(0x0080, 0x00ff) AM_WRITE(mgolf_wram_w)
203208   AM_RANGE(0x0180, 0x01ff) AM_WRITE(mgolf_wram_w)
204   AM_RANGE(0x0800, 0x0bff) AM_WRITE(mgolf_vram_w) AM_BASE(&mgolf_video_ram)
209   AM_RANGE(0x0800, 0x0bff) AM_WRITE(mgolf_vram_w) AM_BASE_MEMBER(mgolf_state, video_ram)
205210
206211   AM_RANGE(0x2000, 0x3fff) AM_ROM
207212ADDRESS_MAP_END
r7500r7501
209214
210215static INPUT_PORTS_START( mgolf )
211216
212   PORT_START("40")   /* 40 */
217   PORT_START("40")
213218   PORT_DIPNAME( 0x30, 0x00, DEF_STR( Language ) )
214219   PORT_DIPSETTING(   0x00, DEF_STR( English ) )
215220   PORT_DIPSETTING(   0x10, DEF_STR( French ) )
r7500r7501
221226   PORT_DIPSETTING(   0x80, "35" )
222227   PORT_DIPSETTING(   0xc0, "40" )
223228
224   PORT_START("41")   /* 41 */
229   PORT_START("41")
225230   PORT_BIT ( 0x01, IP_ACTIVE_HIGH, IPT_SPECIAL ) /* DIAL A */
226231   PORT_BIT ( 0x02, IP_ACTIVE_HIGH, IPT_SPECIAL ) /* DIAL B */
227232   PORT_BIT ( 0x04, IP_ACTIVE_HIGH, IPT_UNUSED )
228233   PORT_BIT ( 0x08, IP_ACTIVE_HIGH, IPT_VBLANK )
229234
230   PORT_START("60")   /* 60 */
235   PORT_START("60")
231236   PORT_SERVICE( 0x10, IP_ACTIVE_LOW )
232237   PORT_BIT ( 0x20, IP_ACTIVE_LOW, IPT_TILT )
233238   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_COIN1 ) PORT_IMPULSE(1)
234239   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_COIN2 ) PORT_IMPULSE(1)
235240
236   PORT_START("61")   /* 61 */
241   PORT_START("61")
237242   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_NAME("Course Select") PORT_CODE(KEYCODE_SPACE)
238243   PORT_BIT ( 0x20, IP_ACTIVE_LOW, IPT_SPECIAL ) /* PLUNGER 1 */
239244   PORT_BIT ( 0x40, IP_ACTIVE_LOW, IPT_SPECIAL ) /* PLUNGER 2 */
r7500r7501
248253INPUT_PORTS_END
249254
250255
256static PALETTE_INIT( mgolf )
257{
258   palette_set_color(machine, 0, MAKE_RGB(0x80, 0x80, 0x80));
259   palette_set_color(machine, 1, MAKE_RGB(0x00, 0x00, 0x00));
260   palette_set_color(machine, 2, MAKE_RGB(0x80, 0x80, 0x80));
261   palette_set_color(machine, 3, MAKE_RGB(0xff, 0xff, 0xff));
262}
263
251264static const gfx_layout tile_layout =
252265{
253266   8, 8,
r7500r7501
287300GFXDECODE_END
288301
289302
303static MACHINE_START( mgolf )
304{
305   mgolf_state *state = (mgolf_state *)machine->driver_data;
306
307   state->maincpu = devtag_get_device(machine, "maincpu");
308
309   state_save_register_global(machine, state->prev);
310   state_save_register_global(machine, state->mask);
311}
312
313static MACHINE_RESET( mgolf )
314{
315   mgolf_state *state = (mgolf_state *)machine->driver_data;
316   timer_set(machine, video_screen_get_time_until_pos(machine->primary_screen, 16, 0), NULL, 16, interrupt_callback);
317
318   state->mask = 0;
319   state->prev = 0;
320}
321
322
290323static MACHINE_DRIVER_START( mgolf )
291324
325   /* driver data */
326   MDRV_DRIVER_DATA(mgolf_state)
327
292328   /* basic machine hardware */
293329   MDRV_CPU_ADD("maincpu", M6502, 12096000 / 16) /* ? */
294330   MDRV_CPU_PROGRAM_MAP(cpu_map)
295331
332   MDRV_MACHINE_START(mgolf)
296333   MDRV_MACHINE_RESET(mgolf)
297334
298335   /* video hardware */
src/mame/drivers/skyfox.c
r7500r7501
1919#include "emu.h"
2020#include "cpu/z80/z80.h"
2121#include "sound/2203intf.h"
22#include "includes/skyfox.h"
2223
23/* Variables defined in video: */
2424
25extern int skyfox_bg_pos, skyfox_bg_ctrl;
26
27
28/* Functions defined in video: */
29
30WRITE8_HANDLER( skyfox_vregs_w );
31
32PALETTE_INIT( skyfox );
33
34VIDEO_UPDATE( skyfox );
35
36
3725/***************************************************************************
3826
3927
r7500r7501
5038static ADDRESS_MAP_START( skyfox_map, ADDRESS_SPACE_PROGRAM, 8 )
5139   AM_RANGE(0x0000, 0xbfff) AM_ROM                     // ROM
5240   AM_RANGE(0xc000, 0xcfff) AM_RAM                     // RAM
53   AM_RANGE(0xd000, 0xd3ff) AM_RAM AM_BASE_SIZE_GENERIC(spriteram)   // Sprites
41   AM_RANGE(0xd000, 0xd3ff) AM_RAM AM_BASE_SIZE_MEMBER(skyfox_state, spriteram, spriteram_size)   // Sprites
5442   AM_RANGE(0xd400, 0xdfff) AM_RAM                     // RAM?
5543   AM_RANGE(0xe000, 0xe000) AM_READ_PORT("INPUTS")         // Input Ports
5644   AM_RANGE(0xe001, 0xe001) AM_READ_PORT("DSW0")         //
r7500r7501
9684
9785static INPUT_CHANGED( coin_inserted )
9886{
99   cputag_set_input_line(field->port->machine, "maincpu", INPUT_LINE_NMI, newval ? CLEAR_LINE : ASSERT_LINE);
87   skyfox_state *state = (skyfox_state *)field->port->machine->driver_data;
88   cpu_set_input_line(state->maincpu, INPUT_LINE_NMI, newval ? CLEAR_LINE : ASSERT_LINE);
10089}
10190
10291static INPUT_PORTS_START( skyfox )
r7500r7501
225214
226215static INTERRUPT_GEN( skyfox_interrupt )
227216{
217   skyfox_state *state = (skyfox_state *)device->machine->driver_data;
218
228219   /* Scroll the bg */
229   skyfox_bg_pos += (skyfox_bg_ctrl >> 1) & 0x7;   // maybe..
220   state->bg_pos += (state->bg_ctrl >> 1) & 0x7;   // maybe..
230221}
231222
223static MACHINE_START( skyfox )
224{
225   skyfox_state *state = (skyfox_state *)machine->driver_data;
226
227   state->maincpu = devtag_get_device(machine, "maincpu");
228
229   state_save_register_global(machine, state->bg_pos);
230   state_save_register_global(machine, state->bg_ctrl);
231}
232
233static MACHINE_RESET( skyfox )
234{
235   skyfox_state *state = (skyfox_state *)machine->driver_data;
236
237   state->bg_pos = 0;
238   state->bg_ctrl = 0;
239}
240
232241static MACHINE_DRIVER_START( skyfox )
233242
243   /* driver data */
244   MDRV_DRIVER_DATA(skyfox_state)
245
234246   /* basic machine hardware */
235247   MDRV_CPU_ADD("maincpu", Z80, 4000000)
236248   MDRV_CPU_PROGRAM_MAP(skyfox_map)
r7500r7501
239251   MDRV_CPU_ADD("audiocpu", Z80, 1748000)
240252   MDRV_CPU_PROGRAM_MAP(skyfox_sound_map)
241253
254   MDRV_MACHINE_START(skyfox)
255   MDRV_MACHINE_RESET(skyfox)
256
242257   /* video hardware */
243258   MDRV_SCREEN_ADD("screen", RASTER)
244259   MDRV_SCREEN_REFRESH_RATE(60)
r7500r7501
394409{
395410   UINT8 *RAM = memory_region(machine, "gfx1");
396411   UINT8 *end = RAM + memory_region_length(machine, "gfx1");
397   UINT8 buf[32*32];
412   UINT8 buf[32 * 32];
398413
399414   while (RAM < end)
400415   {
401416      int i;
402      for (i=0;i<(32*32);i++)
403         buf[i] = RAM[(i%8) + ((i/8)%8)*32 + ((i/64)%4)*8 + (i/256)*256];
417      for (i = 0; i < (32 * 32); i++)
418         buf[i] = RAM[(i % 8) + ((i / 8) % 8) * 32 + ((i / 64) % 4) * 8 + (i / 256) * 256];
404419
405      memcpy(RAM,buf,32*32);
406      RAM += 32*32;
420      memcpy(RAM, buf, 32 * 32);
421      RAM += 32 * 32;
407422   }
408423}
409424
410425
411426
412GAME( 1987, skyfox,   0,      skyfox, skyfox, skyfox, ROT90, "Jaleco (Nichibutsu USA license)", "Sky Fox" , 0 )
413GAME( 1987, exerizrb, skyfox, skyfox, skyfox, skyfox, ROT90, "bootleg", "Exerizer (Japan) (bootleg)", 0 )
427GAME( 1987, skyfox,   0,      skyfox, skyfox, skyfox, ROT90, "Jaleco (Nichibutsu USA license)", "Sky Fox" , GAME_SUPPORTS_SAVE )
428GAME( 1987, exerizrb, skyfox, skyfox, skyfox, skyfox, ROT90, "bootleg", "Exerizer (Japan) (bootleg)", GAME_SUPPORTS_SAVE )
src/mame/drivers/cntsteer.c
r7500r7501
2929#include "sound/dac.h"
3030
3131
32typedef struct _cntsteer_state cntsteer_state;
33struct _cntsteer_state
32class cntsteer_state
3433{
34public:
35   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, cntsteer_state(machine)); }
36
37   cntsteer_state(running_machine &machine) { }
38
3539   /* memory pointers */
3640   UINT8 *  videoram;
3741   UINT8 *  videoram2;
src/mame/drivers/skeetsht.c
r7500r7501
1717 *
1818 *************************************/
1919
20typedef struct _skeetsht_state skeetsht_state;
21struct _skeetsht_state
20class skeetsht_state
2221{
22public:
23   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, skeetsht_state(machine)); }
24
25   skeetsht_state(running_machine &machine) { }
26
2327   UINT16 *tms_vram;
2428   UINT8 porta_latch;
2529   UINT8 ay_sel;
src/mame/drivers/dblewing.c
r7500r7501
2121#include "cpu/z80/z80.h"
2222#include "cpu/m68000/m68000.h"
2323#include "includes/decocrpt.h"
24#include "includes/deco16ic.h"
2524#include "sound/2151intf.h"
2625#include "sound/okim6295.h"
26#include "video/deco16ic.h"
2727
28class dblewing_state
29{
30public:
31   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, dblewing_state(machine)); }
32
33   dblewing_state(running_machine &machine) { }
34
35   /* memory pointers */
36   UINT16 *  pf1_rowscroll;
37   UINT16 *  pf2_rowscroll;
38   UINT16 *  spriteram;
39   size_t    spriteram_size;
40
41   /* protection */
42   UINT16 _008_data;
43   UINT16 _104_data;
44   UINT16 _406_data;
45   UINT16 _608_data;
46   UINT16 _70c_data;
47   UINT16 _78a_data;
48   UINT16 _088_data;
49   UINT16 _58c_data;
50   UINT16 _408_data;
51   UINT16 _40e_data;
52   UINT16 _080_data;
53   UINT16 _788_data;
54   UINT16 _38e_data;
55   UINT16 _580_data;
56   UINT16 _60a_data;
57   UINT16 _200_data;
58   UINT16 _28c_data;
59   UINT16 _18a_data;
60   UINT16 _280_data;
61   UINT16 _384_data;
62
63   UINT16 boss_move, boss_shoot_type, boss_3_data, boss_4_data, boss_5_data ,boss_5sx_data, boss_6_data;
64
65   /* misc */
66   UINT8 sound_irq;
67
68   /* devices */
69   running_device *maincpu;
70   running_device *audiocpu;
71   running_device *deco16ic;
72};
73
2874/*
2975
3076offs +0
r7500r7501
55101*/
56102
57103
58
59static void draw_sprites(running_machine *machine, bitmap_t *bitmap,const rectangle *cliprect)
104static void draw_sprites( running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect )
60105{
61   UINT16 *spriteram16 = machine->generic.spriteram.u16;
106   dblewing_state *state = (dblewing_state *)machine->driver_data;
107   UINT16 *spriteram = state->spriteram;
62108   int offs;
63109
64   for (offs = 0x400-4;offs >= 0;offs -= 4)
110   for (offs = 0x400 - 4; offs >= 0; offs -= 4)
65111   {
66      int x,y,sprite,colour,multi,mult2,fx,fy,inc,flash,mult,xsize,pri;
112      int x, y, sprite, colour, multi, mult2, fx, fy, inc, flash, mult, xsize, pri;
67113
68      sprite = spriteram16[offs+1];
114      sprite = spriteram[offs + 1];
69115
70      y = spriteram16[offs];
71      flash=y&0x1000;
72      xsize = y&0x0800;
73      if (flash && (video_screen_get_frame_number(machine->primary_screen) & 1)) continue;
116      y = spriteram[offs];
117      flash = y & 0x1000;
118      xsize = y & 0x0800;
119      if (flash && (video_screen_get_frame_number(machine->primary_screen) & 1))
120         continue;
74121
75      x = spriteram16[offs+2];
76      colour = (x >>9) & 0x1f;
122      x = spriteram[offs + 2];
123      colour = (x >> 9) & 0x1f;
77124
78      pri = (x&0xc000); // 2 bits or 1?
125      pri = (x & 0xc000); // 2 bits or 1?
79126
80      switch (pri&0xc000) {
81      case 0x0000: pri=0; break;
82      case 0x4000: pri=0xf0; break;
83      case 0x8000: pri=0xf0|0xcc; break;
84      case 0xc000: pri=0xf0|0xcc; break; /*  or 0xf0|0xcc|0xaa ? */
127      switch (pri & 0xc000)
128      {
129      case 0x0000: pri = 0; break;
130      case 0x4000: pri = 0xf0; break;
131      case 0x8000: pri = 0xf0 | 0xcc; break;
132      case 0xc000: pri = 0xf0 | 0xcc; break; /*  or 0xf0|0xcc|0xaa ? */
85133      }
86134
87135      fx = y & 0x2000;
r7500r7501
93141      if (x >= 320) x -= 512;
94142      if (y >= 256) y -= 512;
95143      y = 240 - y;
96        x = 304 - x;
144      x = 304 - x;
97145
98      if (x>320) continue;
146      if (x > 320)
147         continue;
99148
100149      sprite &= ~multi;
101150      if (fy)
r7500r7501
108157
109158      if (flip_screen_get(machine))
110159      {
111         y=240-y;
112         x=304-x;
113         if (fx) fx=0; else fx=1;
114         if (fy) fy=0; else fy=1;
115         mult=16;
160         y = 240 - y;
161         x = 304 - x;
162         if (fx) fx = 0; else fx = 1;
163         if (fy) fy = 0; else fy = 1;
164         mult = 16;
116165      }
117      else mult=-16;
166      else
167         mult = -16;
118168
119      mult2 = multi+1;
169      mult2 = multi + 1;
120170
121171      while (multi >= 0)
122172      {
r7500r7501
141191   }
142192}
143193
144static int dblewing_bank_callback(const int bank)
194static VIDEO_UPDATE(dblewing)
145195{
146   return ((bank>>4) & 0x7) * 0x1000;
147}
196   dblewing_state *state = (dblewing_state *)screen->machine->driver_data;
197   UINT16 flip = deco16ic_pf12_control_r(state->deco16ic, 0, 0xffff);
148198
149static VIDEO_START(dblewing)
150{
151   deco16_1_video_init(machine);
199   flip_screen_set(screen->machine, BIT(flip, 7));
200   deco16ic_pf12_update(state->deco16ic, state->pf1_rowscroll, state->pf2_rowscroll);
152201
153   deco16_set_tilemap_bank_callback(0,dblewing_bank_callback);
154   deco16_set_tilemap_bank_callback(1,dblewing_bank_callback);
155}
202   bitmap_fill(bitmap, cliprect, 0); /* not Confirmed */
203   bitmap_fill(screen->machine->priority_bitmap, NULL, 0);
156204
157static VIDEO_UPDATE(dblewing)
158{
159   flip_screen_set(screen->machine,  deco16_pf12_control[0]&0x80 );
160   deco16_pf12_update(deco16_pf1_rowscroll,deco16_pf2_rowscroll);
161
162   bitmap_fill(bitmap,cliprect,0); /* not Confirmed */
163   bitmap_fill(screen->machine->priority_bitmap,NULL,0);
164
165   deco16_tilemap_2_draw(screen,bitmap,cliprect,0,2);
166   deco16_tilemap_1_draw(screen,bitmap,cliprect,0,4);
167   draw_sprites(screen->machine,bitmap,cliprect);
205   deco16ic_tilemap_2_draw(state->deco16ic, bitmap, cliprect, 0, 2);
206   deco16ic_tilemap_1_draw(state->deco16ic, bitmap, cliprect, 0, 4);
207   draw_sprites(screen->machine, bitmap, cliprect);
168208   return 0;
169209}
170210
r7500r7501
178218 we need to log the PC of each read/write and check to
179219 see if the code makes any of them move obvious
180220*/
181static UINT16 dblwings_008_data;
182static UINT16 dblwings_104_data;
183static UINT16 dblwings_406_data;
184static UINT16 dblwings_608_data;
185static UINT16 dblwings_70c_data;
186static UINT16 dblwings_78a_data;
187static UINT16 dblwings_088_data;
188static UINT16 dblwings_58c_data;
189static UINT16 dblwings_408_data;
190static UINT16 dblwings_40e_data;
191static UINT16 dblwings_080_data;
192static UINT16 dblwings_788_data;
193static UINT16 dblwings_38e_data;
194static UINT16 dblwings_580_data;
195static UINT16 dblwings_60a_data;
196static UINT16 dblwings_200_data;
197static UINT16 dblwings_28c_data;
198static UINT16 dblwings_18a_data;
199static UINT16 dblwings_280_data;
200static UINT16 dblwings_384_data;
221static READ16_HANDLER ( dblewing_prot_r )
222{
223   dblewing_state *state = (dblewing_state *)space->machine->driver_data;
201224
202static UINT16 boss_move,boss_shoot_type,boss_3_data,boss_4_data,boss_5_data,boss_5sx_data,boss_6_data;
203
204static UINT8 dblewing_sound_irq;
205
206static READ16_HANDLER ( dlbewing_prot_r )
207{
208   switch(offset*2)
225   switch (offset * 2)
209226   {
210      case 0x16a: return boss_move;          // boss 1 movement
211      case 0x6d6: return boss_move;          // boss 1 2nd pilot
212      case 0x748: return boss_move;          // boss 1 3rd pilot
227      case 0x16a: return state->boss_move;          // boss 1 movement
228      case 0x6d6: return state->boss_move;          // boss 1 2nd pilot
229      case 0x748: return state->boss_move;          // boss 1 3rd pilot
213230
214231      case 0x566: return 0x0009;           // boss BGM,might be a variable one (read->write to the sound latch)
215      case 0x1ea: return boss_shoot_type;    // boss 1 shoot type
216      case 0x596: return boss_3_data;         // boss 3 appearing
217      case 0x692:   return boss_4_data;
218      case 0x6b0: return boss_5_data;
219      case 0x51e: return boss_5sx_data;
220      case 0x784: return boss_6_data;
232      case 0x1ea: return state->boss_shoot_type;    // boss 1 shoot type
233      case 0x596: return state->boss_3_data;         // boss 3 appearing
234      case 0x692:   return state->boss_4_data;
235      case 0x6b0: return state->boss_5_data;
236      case 0x51e: return state->boss_5sx_data;
237      case 0x784: return state->boss_6_data;
221238
222239      case 0x330: return 0; // controls bonuses such as shoot type,bombs etc.
223      case 0x1d4: return dblwings_70c_data;  //controls restart points
240      case 0x1d4: return state->_70c_data;  //controls restart points
224241
225      case 0x0ac: return (input_port_read(space->machine, "DSW") & 0x40)<<4;//flip screen
226      case 0x4b0: return dblwings_608_data;//coinage
242      case 0x0ac: return (input_port_read(space->machine, "DSW") & 0x40) << 4;//flip screen
243      case 0x4b0: return state->_608_data;//coinage
227244      case 0x068:
228245      {
229         switch(input_port_read(space->machine, "DSW") & 0x0300) //I don't know how to relationate this...
246         switch (input_port_read(space->machine, "DSW") & 0x0300) //I don't know how to relationate this...
230247         {
231248            case 0x0000: return 0x000;//0
232249            case 0x0100: return 0x060;//3
r7500r7501
234251            case 0x0300: return 0x160;//b
235252         }
236253      }
237      case 0x094: return dblwings_104_data;// p1 inputs select screen  OK
238      case 0x24c: return dblwings_008_data;//read DSW (mirror for coinage/territory)
254      case 0x094: return state->_104_data;// p1 inputs select screen  OK
255      case 0x24c: return state->_008_data;//read DSW (mirror for coinage/territory)
239256      case 0x298: return input_port_read(space->machine, "SYSTEM");//vblank
240257      case 0x476: return input_port_read(space->machine, "SYSTEM");//mirror for coins
241258      case 0x506: return input_port_read(space->machine, "DSW");
242      case 0x5d8: return dblwings_406_data;
259      case 0x5d8: return state->_406_data;
243260      case 0x2b4: return input_port_read(space->machine, "P1_P2");
244261      case 0x1a8: return (input_port_read(space->machine, "DSW") & 0x4000) >> 12;//allow continue
245      case 0x3ec: return dblwings_70c_data; //score entry
246      case 0x246: return dblwings_580_data; // these three controls "perfect bonus" I suppose...
247      case 0x52e: return dblwings_580_data;
248      case 0x532: return dblwings_580_data;
262      case 0x3ec: return state->_70c_data; //score entry
263      case 0x246: return state->_580_data; // these three controls "perfect bonus" I suppose...
264      case 0x52e: return state->_580_data;
265      case 0x532: return state->_580_data;
249266   }
250267
251//  printf("dblewing prot r %08x, %04x, %04x\n",cpu_get_pc(space->cpu), offset*2, mem_mask);
268//  printf("dblewing prot r %08x, %04x, %04x\n", cpu_get_pc(space->cpu), offset * 2, mem_mask);
252269
253   if ((offset*2)==0x0f8) return 0; // dblwings_080_data;
254   if ((offset*2)==0x104) return 0;
255   if ((offset*2)==0x10e) return 0;
256   if ((offset*2)==0x206) return 0; // dblwings_70c_data;
257   if ((offset*2)==0x25c) return 0;
258   if ((offset*2)==0x284) return 0; // 3rd player 2nd boss
259   if ((offset*2)==0x432) return 0; // boss on water level?
260   if ((offset*2)==0x54a) return 0; // 3rd player 2nd boss
261   if ((offset*2)==0x786) return 0;
270   if ((offset*2) == 0x0f8) return 0; // state->_080_data;
271   if ((offset*2) == 0x104) return 0;
272   if ((offset*2) == 0x10e) return 0;
273   if ((offset*2) == 0x206) return 0; // state->_70c_data;
274   if ((offset*2) == 0x25c) return 0;
275   if ((offset*2) == 0x284) return 0; // 3rd player 2nd boss
276   if ((offset*2) == 0x432) return 0; // boss on water level?
277   if ((offset*2) == 0x54a) return 0; // 3rd player 2nd boss
278   if ((offset*2) == 0x786) return 0;
262279
263   mame_printf_debug("dblewing prot r %08x, %04x, %04x\n",cpu_get_pc(space->cpu), offset*2, mem_mask);
280   mame_printf_debug("dblewing prot r %08x, %04x, %04x\n", cpu_get_pc(space->cpu), offset * 2, mem_mask);
264281
265282   return 0;//mame_rand(space->machine);
266283}
267284
268285static WRITE16_HANDLER( dblewing_prot_w )
269286{
270//  if(offset*2 != 0x380)
271//  printf("dblewing prot w %08x, %04x, %04x %04x\n",cpu_get_pc(space->cpu), offset*2, mem_mask,data);
287   dblewing_state *state = (dblewing_state *)space->machine->driver_data;
272288
273   switch(offset*2)
289//  if (offset * 2 != 0x380)
290//  printf("dblewing prot w %08x, %04x, %04x %04x\n", cpu_get_pc(space->cpu), offset * 2, mem_mask, data);
291
292   switch (offset * 2)
274293   {
275294      case 0x088:
276         dblwings_088_data = data;
277         if(dblwings_088_data == 0)          { boss_4_data = 0;    }
278         else if(dblwings_088_data & 0x8000) { boss_4_data = 0x50; }
279         else                                { boss_4_data = 0x40; }
295         state->_088_data = data;
296         if(state->_088_data == 0)          { state->boss_4_data = 0;    }
297         else if(state->_088_data & 0x8000) { state->boss_4_data = 0x50; }
298         else                                { state->boss_4_data = 0x40; }
280299
281300         return;
282301
283302      case 0x104:
284         dblwings_104_data = data;
303         state->_104_data = data;
285304         return; // p1 inputs select screen  OK
286305
287306      case 0x18a:
288         dblwings_18a_data = data;
289         switch(dblwings_18a_data)
307         state->_18a_data = data;
308         switch (state->_18a_data)
290309         {
291            case 0x6b94: boss_5_data = 0x10; break; //initialize
292            case 0x7c68: boss_5_data = 0x60; break; //go up
293            case 0xfb1d: boss_5_data = 0x50; break;
294            case 0x977c: boss_5_data = 0x50; break;
295            case 0x8a49: boss_5_data = 0x60; break;
310            case 0x6b94: state->boss_5_data = 0x10; break; //initialize
311            case 0x7c68: state->boss_5_data = 0x60; break; //go up
312            case 0xfb1d: state->boss_5_data = 0x50; break;
313            case 0x977c: state->boss_5_data = 0x50; break;
314            case 0x8a49: state->boss_5_data = 0x60; break;
296315         }
297316         return;
298317      case 0x200:
299         dblwings_200_data = data;
300         switch(dblwings_200_data)
318         state->_200_data = data;
319         switch (state->_200_data)
301320         {
302            case 0x5a19: boss_move = 1; break;
303            case 0x3b28: boss_move = 2; break;
304            case 0x1d4d: boss_move = 1; break;
321            case 0x5a19: state->boss_move = 1; break;
322            case 0x3b28: state->boss_move = 2; break;
323            case 0x1d4d: state->boss_move = 1; break;
305324         }
306         //popmessage("%04x",dblwings_200_data);
325         //popmessage("%04x",state->_200_data);
307326         return;
308327      case 0x280:
309         dblwings_280_data = data;
310         switch(dblwings_280_data)
328         state->_280_data = data;
329         switch (state->_280_data)
311330         {
312            case 0x6b94: boss_5sx_data = 0x10; break;
313            case 0x7519: boss_5sx_data = 0x60; break;
314            case 0xfc68: boss_5sx_data = 0x50; break;
315            case 0x02dd: boss_5sx_data = 0x50; break;
316            case 0x613c: boss_5sx_data = 0x50; break;
331            case 0x6b94: state->boss_5sx_data = 0x10; break;
332            case 0x7519: state->boss_5sx_data = 0x60; break;
333            case 0xfc68: state->boss_5sx_data = 0x50; break;
334            case 0x02dd: state->boss_5sx_data = 0x50; break;
335            case 0x613c: state->boss_5sx_data = 0x50; break;
317336         }
318         //printf("%04x\n",dblwings_280_data);
337         //printf("%04x\n",state->_280_data);
319338         return;
320339      case 0x380: // sound write
321340         soundlatch_w(space, 0, data & 0xff);
322         dblewing_sound_irq |= 0x02;
323         cputag_set_input_line(space->machine, "audiocpu", 0, (dblewing_sound_irq != 0) ? ASSERT_LINE : CLEAR_LINE);
341         state->sound_irq |= 0x02;
342         cpu_set_input_line(state->audiocpu, 0, (state->sound_irq != 0) ? ASSERT_LINE : CLEAR_LINE);
324343         return;
325344      case 0x384:
326         dblwings_384_data = data;
327         switch(dblwings_384_data)
345         state->_384_data = data;
346         switch(state->_384_data)
328347         {
329            case 0xaa41: boss_6_data = 1; break;
330            case 0x5a97: boss_6_data = 2; break;
331            case 0xbac5: boss_6_data = 3; break;
332            case 0x0afb: boss_6_data = 4; break;
333            case 0x6a99: boss_6_data = 5; break;
334            case 0xda8f: boss_6_data = 6; break;
348            case 0xaa41: state->boss_6_data = 1; break;
349            case 0x5a97: state->boss_6_data = 2; break;
350            case 0xbac5: state->boss_6_data = 3; break;
351            case 0x0afb: state->boss_6_data = 4; break;
352            case 0x6a99: state->boss_6_data = 5; break;
353            case 0xda8f: state->boss_6_data = 6; break;
335354         }
336355         return;
337356      case 0x38e:
338         dblwings_38e_data = data;
339         switch(dblwings_38e_data)
357         state->_38e_data = data;
358         switch(state->_38e_data)
340359         {
341            case 0x6c13: boss_shoot_type = 3; break;
342            case 0xc311: boss_shoot_type = 0; break;
343            case 0x1593: boss_shoot_type = 1; break;
344            case 0xf9db: boss_shoot_type = 2; break;
345            case 0xf742: boss_shoot_type = 3; break;
360            case 0x6c13: state->boss_shoot_type = 3; break;
361            case 0xc311: state->boss_shoot_type = 0; break;
362            case 0x1593: state->boss_shoot_type = 1; break;
363            case 0xf9db: state->boss_shoot_type = 2; break;
364            case 0xf742: state->boss_shoot_type = 3; break;
346365
347            case 0xeff5: boss_move = 1; break;
348            case 0xd2f1: boss_move = 2; break;
349            //default:   printf("%04x\n",dblwings_38e_data); break;
350            //case 0xe65a: boss_shoot_type = 0; break;
366            case 0xeff5: state->boss_move = 1; break;
367            case 0xd2f1: state->boss_move = 2; break;
368            //default:   printf("%04x\n",state->_38e_data); break;
369            //case 0xe65a: state->boss_shoot_type = 0; break;
351370         }
352371         return;
353372      case 0x58c: // 3rd player 1st level
354         dblwings_58c_data = data;
355         if(dblwings_58c_data == 0)     { boss_move = 5; }
356         else                           { boss_move = 2; }
373         state->_58c_data = data;
374         if(state->_58c_data == 0)     { state->boss_move = 5; }
375         else                           { state->boss_move = 2; }
357376
358377         return;
359378      case 0x60a:
360         dblwings_60a_data = data;
361         if(dblwings_60a_data & 0x8000) { boss_3_data = 2; }
362         else                           { boss_3_data = 9; }
379         state->_60a_data = data;
380         if(state->_60a_data & 0x8000) { state->boss_3_data = 2; }
381         else                           { state->boss_3_data = 9; }
363382
364383         return;
365384      case 0x580:
366         dblwings_580_data = data;
385         state->_580_data = data;
367386         return;
368387      case 0x406:
369         dblwings_406_data = data;
388         state->_406_data = data;
370389         return;  // p2 inputs select screen  OK
371390   }
372391
373//  printf("dblewing prot w %08x, %04x, %04x %04x\n",cpu_get_pc(space->cpu), offset*2, mem_mask,data);
392//  printf("dblewing prot w %08x, %04x, %04x %04x\n", cpu_get_pc(space->cpu), offset * 2, mem_mask, data);
374393
375   if ((offset*2)==0x008) { dblwings_008_data = data; return; }
376   if ((offset*2)==0x080) { dblwings_080_data = data; return; } // p3 3rd boss?
377   if ((offset*2)==0x28c) { dblwings_28c_data = data; return; }
378   if ((offset*2)==0x408) { dblwings_408_data = data; return; } // 3rd player 1st level?
379   if ((offset*2)==0x40e) { dblwings_40e_data = data; return; } // 3rd player 2nd level?
380   if ((offset*2)==0x608) { dblwings_608_data = data; return; }
381   if ((offset*2)==0x70c) { dblwings_70c_data = data; return; }
382   if ((offset*2)==0x78a) { dblwings_78a_data = data; return; }
383   if ((offset*2)==0x788) { dblwings_788_data = data; return; }
394   if ((offset * 2) == 0x008) { state->_008_data = data; return; }
395   if ((offset * 2) == 0x080) { state->_080_data = data; return; } // p3 3rd boss?
396   if ((offset * 2) == 0x28c) { state->_28c_data = data; return; }
397   if ((offset * 2) == 0x408) { state->_408_data = data; return; } // 3rd player 1st level?
398   if ((offset * 2) == 0x40e) { state->_40e_data = data; return; } // 3rd player 2nd level?
399   if ((offset * 2) == 0x608) { state->_608_data = data; return; }
400   if ((offset * 2) == 0x70c) { state->_70c_data = data; return; }
401   if ((offset * 2) == 0x78a) { state->_78a_data = data; return; }
402   if ((offset * 2) == 0x788) { state->_788_data = data; return; }
384403}
385404
386405static ADDRESS_MAP_START( dblewing_map, ADDRESS_SPACE_PROGRAM, 16 )
387406   AM_RANGE(0x000000, 0x07ffff) AM_ROM
388407
389   AM_RANGE(0x100000, 0x100fff) AM_RAM_WRITE(deco16_pf1_data_w) AM_BASE(&deco16_pf1_data)
390   AM_RANGE(0x102000, 0x102fff) AM_RAM_WRITE(deco16_pf2_data_w) AM_BASE(&deco16_pf2_data)
391   AM_RANGE(0x104000, 0x104fff) AM_RAM AM_BASE(&deco16_pf1_rowscroll)
392   AM_RANGE(0x106000, 0x106fff) AM_RAM AM_BASE(&deco16_pf2_rowscroll)
408   AM_RANGE(0x100000, 0x100fff) AM_DEVREADWRITE("deco_custom", deco16ic_pf1_data_r, deco16ic_pf1_data_w)
409   AM_RANGE(0x102000, 0x102fff) AM_DEVREADWRITE("deco_custom", deco16ic_pf2_data_r, deco16ic_pf2_data_w)
410   AM_RANGE(0x104000, 0x104fff) AM_RAM AM_BASE_MEMBER(dblewing_state, pf1_rowscroll)
411   AM_RANGE(0x106000, 0x106fff) AM_RAM AM_BASE_MEMBER(dblewing_state, pf2_rowscroll)
393412
394413   /* protection */
395414//  AM_RANGE(0x280104, 0x280105) AM_WRITENOP              // ??
396415//  AM_RANGE(0x2800ac, 0x2800ad) AM_READ_PORT("DSW")            // dips
397416//  AM_RANGE(0x280298, 0x280299) AM_READ_PORT("SYSTEM")         // vbl
398417//  AM_RANGE(0x280506, 0x280507) AM_READ_PORT("UNK")
399//  AM_RANGE(0x2802B4, 0x2802B5) AM_READ_PORT("P1_P2")          // inverted?
418//  AM_RANGE(0x2802b4, 0x2802b5) AM_READ_PORT("P1_P2")          // inverted?
400419//  AM_RANGE(0x280330, 0x280331) AM_READNOP               // sound?
401420//  AM_RANGE(0x280380, 0x280381) AM_WRITENOP              // sound
402421
403   AM_RANGE(0x280000, 0x2807ff) AM_READWRITE(dlbewing_prot_r,dblewing_prot_w)
422   AM_RANGE(0x280000, 0x2807ff) AM_READWRITE(dblewing_prot_r, dblewing_prot_w)
404423
405424
406425   AM_RANGE(0x284000, 0x284001) AM_RAM
407426   AM_RANGE(0x288000, 0x288001) AM_RAM
408   AM_RANGE(0x28C000, 0x28C00f) AM_RAM AM_BASE(&deco16_pf12_control)
409   AM_RANGE(0x300000, 0x3007ff) AM_RAM AM_BASE_SIZE_GENERIC(spriteram)
427   AM_RANGE(0x28c000, 0x28c00f) AM_RAM_DEVWRITE("deco_custom", deco16ic_pf12_control_w)
428   AM_RANGE(0x300000, 0x3007ff) AM_RAM AM_BASE_SIZE_MEMBER(dblewing_state, spriteram, spriteram_size)
410429   AM_RANGE(0x320000, 0x3207ff) AM_RAM_WRITE(paletteram16_xxxxBBBBGGGGRRRR_word_w) AM_BASE_GENERIC(paletteram)
411430   AM_RANGE(0xff0000, 0xff3fff) AM_MIRROR(0xc000) AM_RAM
412431ADDRESS_MAP_END
413432
414433static READ8_HANDLER(irq_latch_r)
415434{
435   dblewing_state *state = (dblewing_state *)space->machine->driver_data;
436
416437   /* bit 1 of dblewing_sound_irq specifies IRQ command writes */
417   dblewing_sound_irq &= ~0x02;
418   cputag_set_input_line(space->machine, "audiocpu", 0, (dblewing_sound_irq != 0) ? ASSERT_LINE : CLEAR_LINE);
419   return dblewing_sound_irq;
438   state->sound_irq &= ~0x02;
439   cpu_set_input_line(state->audiocpu, 0, (state->sound_irq != 0) ? ASSERT_LINE : CLEAR_LINE);
440   return state->sound_irq;
420441}
421442
422443static ADDRESS_MAP_START( sound_map, ADDRESS_SPACE_PROGRAM, 8 )
r7500r7501
601622   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
602623INPUT_PORTS_END
603624
604static void sound_irq(running_device *device, int state)
625static void sound_irq( running_device *device, int state )
605626{
627   dblewing_state *driver_state = (dblewing_state *)device->machine->driver_data;
628
606629   /* bit 0 of dblewing_sound_irq specifies IRQ from sound chip */
607630   if (state)
608      dblewing_sound_irq |= 0x01;
631      driver_state->sound_irq |= 0x01;
609632   else
610      dblewing_sound_irq &= ~0x01;
611   cputag_set_input_line(device->machine, "audiocpu", 0, (dblewing_sound_irq != 0) ? ASSERT_LINE : CLEAR_LINE);
633      driver_state->sound_irq &= ~0x01;
634   cpu_set_input_line(driver_state->audiocpu, 0, (driver_state->sound_irq != 0) ? ASSERT_LINE : CLEAR_LINE);
612635}
613636
614637static const ym2151_interface ym2151_config =
r7500r7501
616639   sound_irq
617640};
618641
642static int dblewing_bank_callback( const int bank )
643{
644   return ((bank >> 4) & 0x7) * 0x1000;
645}
646
647static const deco16ic_interface dblewing_deco16ic_intf =
648{
649   "screen",
650   1, 0, 1,
651   0x0f, 0x0f, 0x0f, 0x0f,   /* trans masks (default values) */
652   0, 16, 0, 16, /* color base (default values) */
653   0x0f, 0x0f, 0x0f, 0x0f,   /* color masks (default values) */
654   dblewing_bank_callback,
655   dblewing_bank_callback,
656   NULL,
657   NULL
658};
659
660static MACHINE_START( dblewing )
661{
662   dblewing_state *state = (dblewing_state *)machine->driver_data;
663
664   state->maincpu = devtag_get_device(machine, "maincpu");
665   state->audiocpu = devtag_get_device(machine, "audiocpu");
666   state->deco16ic = devtag_get_device(machine, "deco_custom");
667
668   state_save_register_global(machine, state->_008_data);
669   state_save_register_global(machine, state->_104_data);
670   state_save_register_global(machine, state->_406_data);
671   state_save_register_global(machine, state->_608_data);
672   state_save_register_global(machine, state->_70c_data);
673   state_save_register_global(machine, state->_78a_data);
674   state_save_register_global(machine, state->_088_data);
675   state_save_register_global(machine, state->_58c_data);
676   state_save_register_global(machine, state->_408_data);
677   state_save_register_global(machine, state->_40e_data);
678   state_save_register_global(machine, state->_080_data);
679   state_save_register_global(machine, state->_788_data);
680   state_save_register_global(machine, state->_38e_data);
681   state_save_register_global(machine, state->_580_data);
682   state_save_register_global(machine, state->_60a_data);
683   state_save_register_global(machine, state->_200_data);
684   state_save_register_global(machine, state->_28c_data);
685   state_save_register_global(machine, state->_18a_data);
686   state_save_register_global(machine, state->_280_data);
687   state_save_register_global(machine, state->_384_data);
688
689   state_save_register_global(machine, state->boss_move);
690   state_save_register_global(machine, state->boss_shoot_type);
691   state_save_register_global(machine, state->boss_3_data);
692   state_save_register_global(machine, state->boss_4_data);
693   state_save_register_global(machine, state->boss_5_data);
694   state_save_register_global(machine, state->boss_5sx_data);
695   state_save_register_global(machine, state->boss_6_data);
696   state_save_register_global(machine, state->sound_irq);
697}
698
699static MACHINE_RESET( dblewing )
700{
701   dblewing_state *state = (dblewing_state *)machine->driver_data;
702
703   state->_008_data = 0;
704   state->_104_data = 0;
705   state->_406_data = 0;
706   state->_608_data = 0;
707   state->_70c_data = 0;
708   state->_78a_data = 0;
709   state->_088_data = 0;
710   state->_58c_data = 0;
711   state->_408_data = 0;
712   state->_40e_data = 0;
713   state->_080_data = 0;
714   state->_788_data = 0;
715   state->_38e_data = 0;
716   state->_580_data = 0;
717   state->_60a_data = 0;
718   state->_200_data = 0;
719   state->_28c_data = 0;
720   state->_18a_data = 0;
721   state->_280_data = 0;
722   state->_384_data = 0;
723
724   state->boss_move = 0;
725   state->boss_shoot_type = 0;
726   state->boss_3_data = 0;
727   state->boss_4_data = 0;
728   state->boss_5_data = 0;
729   state->boss_5sx_data = 0;
730   state->boss_6_data = 0;
731   state->sound_irq = 0;
732}
733
619734static MACHINE_DRIVER_START( dblewing )
735
736   /* driver data */
737   MDRV_DRIVER_DATA(dblewing_state)
738
620739   /* basic machine hardware */
621740   MDRV_CPU_ADD("maincpu", M68000, 14000000)   /* DE102 */
622741   MDRV_CPU_PROGRAM_MAP(dblewing_map)
r7500r7501
628747
629748   MDRV_QUANTUM_TIME(HZ(6000))
630749
750   MDRV_MACHINE_START(dblewing)
751   MDRV_MACHINE_RESET(dblewing)
752
631753   /* video hardware */
632754   MDRV_SCREEN_ADD("screen", RASTER)
633755   MDRV_SCREEN_REFRESH_RATE(58)
r7500r7501
639761   MDRV_PALETTE_LENGTH(4096)
640762   MDRV_GFXDECODE(dblewing)
641763
642   MDRV_VIDEO_START(dblewing)
643764   MDRV_VIDEO_UPDATE(dblewing)
644765
766   MDRV_DECO16IC_ADD("deco_custom", dblewing_deco16ic_intf)
767
645768   /* sound hardware */
646769   MDRV_SPEAKER_STANDARD_MONO("mono")
647770
r7500r7501
732855}
733856
734857
735GAME( 1993, dblewing, 0,        dblewing, dblewing,  dblewing,  ROT90,"Mitchell", "Double Wings", GAME_UNEMULATED_PROTECTION | GAME_IMPERFECT_SOUND | GAME_NOT_WORKING )
858GAME( 1993, dblewing, 0,     dblewing, dblewing,  dblewing,  ROT90, "Mitchell", "Double Wings", GAME_UNEMULATED_PROTECTION | GAME_IMPERFECT_SOUND | GAME_NOT_WORKING | GAME_SUPPORTS_SAVE )
src/mame/drivers/shougi.c
r7500r7501
8787#include "sound/ay8910.h"
8888#include "video/resnet.h"
8989
90typedef struct _shougi_state shougi_state;
91struct _shougi_state
90class shougi_state
9291{
92public:
93   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, shougi_state(machine)); }
94
95   shougi_state(running_machine &machine) { }
96
9397   UINT8 *videoram;
9498   int nmi_enabled;
9599   //UINT8 *cpu_sharedram;
src/mame/drivers/discoboy.c
r7500r7501
4343
4444
4545
46typedef struct _discoboy_state discoboy_state;
47struct _discoboy_state
46class discoboy_state
4847{
48public:
49   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, discoboy_state(machine)); }
50
51   discoboy_state(running_machine &machine) { }
52
4953   /* memory pointers */
5054   UINT8 *  ram_1;
5155   UINT8 *  ram_2;
src/mame/drivers/mediagx.c
r7500r7501
10041004
10051005static const struct pic8259_interface mediagx_pic8259_2_config =
10061006{
1007   DEVCB_DEVICE_LINE("pic8259_1", pic8259_ir2_w)
1007   DEVCB_DEVICE_LINE("pic8259_master", pic8259_ir2_w)
10081008};
10091009
10101010
src/mame/drivers/orbit.c
r7500r7501
2525
2626#define MASTER_CLOCK      XTAL_12_096MHz
2727
28
29static UINT8 orbit_misc_flags;
30
31
32
3328/*************************************
3429 *
3530 *  Interrupts and timing
r7500r7501
3833
3934static TIMER_DEVICE_CALLBACK( nmi_32v )
4035{
36   orbit_state *state = (orbit_state *)timer->machine->driver_data;
4137   int scanline = param;
42   int nmistate = (scanline & 32) && (orbit_misc_flags & 4);
43   cputag_set_input_line(timer->machine, "maincpu", INPUT_LINE_NMI, nmistate ? ASSERT_LINE : CLEAR_LINE);
38   int nmistate = (scanline & 32) && (state->misc_flags & 4);
39   cpu_set_input_line(state->maincpu, INPUT_LINE_NMI, nmistate ? ASSERT_LINE : CLEAR_LINE);
4440}
4541
4642
4743static TIMER_CALLBACK( irq_off )
4844{
49   cputag_set_input_line(machine, "maincpu", 0, CLEAR_LINE);
45   orbit_state *state = (orbit_state *)machine->driver_data;
46   cpu_set_input_line(state->maincpu, 0, CLEAR_LINE);
5047}
5148
5249
r7500r7501
6663
6764static void update_misc_flags(running_machine *machine, UINT8 val)
6865{
69   running_device *discrete = devtag_get_device(machine, "discrete");
66   orbit_state *state = (orbit_state *)machine->driver_data;
7067
71   orbit_misc_flags = val;
68   state->misc_flags = val;
7269
7370   /* BIT0 => UNUSED       */
7471   /* BIT1 => LOCKOUT      */
r7500r7501
7976   /* BIT6 => HYPER LED    */
8077   /* BIT7 => WARNING SND  */
8178
82   discrete_sound_w(discrete, ORBIT_WARNING_EN, orbit_misc_flags & 0x80);
79   discrete_sound_w(state->discrete, ORBIT_WARNING_EN, BIT(state->misc_flags, 7));
8380
84   set_led_status(machine, 0, orbit_misc_flags & 0x08);
85   set_led_status(machine, 1, orbit_misc_flags & 0x40);
81   set_led_status(machine, 0, BIT(state->misc_flags, 3));
82   set_led_status(machine, 1, BIT(state->misc_flags, 6));
8683
87   coin_lockout_w(machine, 0, !(orbit_misc_flags & 0x02));
88   coin_lockout_w(machine, 1, !(orbit_misc_flags & 0x02));
84   coin_lockout_w(machine, 0, !BIT(state->misc_flags, 1));
85   coin_lockout_w(machine, 1, !BIT(state->misc_flags, 1));
8986}
9087
9188
9289static WRITE8_HANDLER( orbit_misc_w )
9390{
91   orbit_state *state = (orbit_state *)space->machine->driver_data;
9492   UINT8 bit = offset >> 1;
9593
9694   if (offset & 1)
97      update_misc_flags(space->machine, orbit_misc_flags | (1 << bit));
95      update_misc_flags(space->machine, state->misc_flags | (1 << bit));
9896   else
99      update_misc_flags(space->machine, orbit_misc_flags & ~(1 << bit));
97      update_misc_flags(space->machine, state->misc_flags & ~(1 << bit));
10098}
10199
102100
103101
104102/*************************************
105103 *
106 *  Machine setup
107 *
108 *************************************/
109
110static MACHINE_RESET( orbit )
111{
112   update_misc_flags(machine, 0);
113}
114
115
116
117/*************************************
118 *
119104 *  Address maps
120105 *
121106 *************************************/
r7500r7501
128113   AM_RANGE(0x1800, 0x1800) AM_MIRROR(0x07ff) AM_READ_PORT("DSW1")
129114   AM_RANGE(0x2000, 0x2000) AM_MIRROR(0x07ff) AM_READ_PORT("DSW2")
130115   AM_RANGE(0x2800, 0x2800) AM_MIRROR(0x07ff) AM_READ_PORT("BUTTONS")
131   AM_RANGE(0x3000, 0x33bf) AM_MIRROR(0x0400) AM_RAM_WRITE(orbit_playfield_w) AM_BASE(&orbit_playfield_ram)
132   AM_RANGE(0x33c0, 0x33ff) AM_MIRROR(0x0400) AM_RAM AM_BASE(&orbit_sprite_ram)
116   AM_RANGE(0x3000, 0x33bf) AM_MIRROR(0x0400) AM_RAM_WRITE(orbit_playfield_w) AM_BASE_MEMBER(orbit_state, playfield_ram)
117   AM_RANGE(0x33c0, 0x33ff) AM_MIRROR(0x0400) AM_RAM AM_BASE_MEMBER(orbit_state, sprite_ram)
133118   AM_RANGE(0x3800, 0x3800) AM_MIRROR(0x00ff) AM_DEVWRITE("discrete", orbit_note_w)
134119   AM_RANGE(0x3900, 0x3900) AM_MIRROR(0x00ff) AM_DEVWRITE("discrete", orbit_noise_amp_w)
135120   AM_RANGE(0x3a00, 0x3a00) AM_MIRROR(0x00ff) AM_DEVWRITE("discrete", orbit_note_amp_w)
r7500r7501
283268
284269/*************************************
285270 *
271 *  Machine setup
272 *
273 *************************************/
274
275static MACHINE_START( orbit )
276{
277   orbit_state *state = (orbit_state *)machine->driver_data;
278
279   state->maincpu = devtag_get_device(machine, "maincpu");
280   state->discrete = devtag_get_device(machine, "discrete");
281
282   state_save_register_global(machine, state->misc_flags);
283   state_save_register_global(machine, state->flip_screen);
284}
285
286static MACHINE_RESET( orbit )
287{
288   orbit_state *state = (orbit_state *)machine->driver_data;
289
290   update_misc_flags(machine, 0);
291   state->flip_screen = 0;
292}
293
294
295/*************************************
296 *
286297 *  Machine drivers
287298 *
288299 *************************************/
289300
290301static MACHINE_DRIVER_START( orbit )
291302
303   /* driver data */
304   MDRV_DRIVER_DATA(orbit_state)
305
292306   /* basic machine hardware */
293307   MDRV_CPU_ADD("maincpu", M6800, MASTER_CLOCK / 16)
294308   MDRV_CPU_PROGRAM_MAP(orbit_map)
r7500r7501
296310
297311   MDRV_TIMER_ADD_SCANLINE("32v", nmi_32v, "screen", 0, 32)
298312
313   MDRV_MACHINE_START(orbit)
299314   MDRV_MACHINE_RESET(orbit)
300315
301316   /* video hardware */
r7500r7501
362377 *
363378 *************************************/
364379
365GAME( 1978, orbit, 0, orbit, orbit, 0, 0, "Atari", "Orbit", 0 )
380GAME( 1978, orbit, 0, orbit, orbit, 0, 0, "Atari", "Orbit", GAME_SUPPORTS_SAVE )
src/mame/drivers/mwarr.c
r7500r7501
4242#include "cpu/m68000/m68000.h"
4343#include "sound/okim6295.h"
4444
45#define MASTER_CLOCK   XTAL_12MHz
46#define SOUND_CLOCK      XTAL_45MHz
45#define MASTER_CLOCK     XTAL_12MHz
46#define SOUND_CLOCK      XTAL_45MHz
4747
48static tilemap_t *bg_tilemap, *mlow_tilemap, *mhigh_tilemap, *tx_tilemap;
49static UINT16 *bg_videoram, *mlow_videoram, *mhigh_videoram, *tx_videoram, *sprites_buffer;
50static UINT16 *bg_scrollram, *mlow_scrollram, *mhigh_scrollram, *vidattrram;
51static UINT16 *mwarr_ram;
5248
49class mwarr_state
50{
51public:
52   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, mwarr_state(machine)); }
53
54   mwarr_state(running_machine &machine) { }
55
56   /* memory pointers */
57   UINT16 *bg_videoram, *mlow_videoram, *mhigh_videoram, *tx_videoram, *sprites_buffer;
58   UINT16 *bg_scrollram, *mlow_scrollram, *mhigh_scrollram, *vidattrram;
59   UINT16 *spriteram;
60//  UINT16 *paletteram;    // currently this uses generic palette handling
61   UINT16 *mwarr_ram;
62
63   /* video-related */
64   tilemap_t *bg_tilemap, *mlow_tilemap, *mhigh_tilemap, *tx_tilemap;
65
66   /* misc */
67   int which;
68};
69
70
71/*************************************
72 *
73 *  Memory handlers
74 *
75 *************************************/
76
5377static WRITE16_HANDLER( bg_videoram_w )
5478{
55   COMBINE_DATA(&bg_videoram[offset]);
56   tilemap_mark_tile_dirty(bg_tilemap,offset);
79   mwarr_state *state = (mwarr_state *)space->machine->driver_data;
80
81   COMBINE_DATA(&state->bg_videoram[offset]);
82   tilemap_mark_tile_dirty(state->bg_tilemap,offset);
5783}
5884
5985static WRITE16_HANDLER( mlow_videoram_w )
6086{
61   COMBINE_DATA(&mlow_videoram[offset]);
62   tilemap_mark_tile_dirty(mlow_tilemap,offset);
87   mwarr_state *state = (mwarr_state *)space->machine->driver_data;
88
89   COMBINE_DATA(&state->mlow_videoram[offset]);
90   tilemap_mark_tile_dirty(state->mlow_tilemap,offset);
6391}
6492
6593static WRITE16_HANDLER( mhigh_videoram_w )
6694{
67   COMBINE_DATA(&mhigh_videoram[offset]);
68   tilemap_mark_tile_dirty(mhigh_tilemap,offset);
95   mwarr_state *state = (mwarr_state *)space->machine->driver_data;
96
97   COMBINE_DATA(&state->mhigh_videoram[offset]);
98   tilemap_mark_tile_dirty(state->mhigh_tilemap,offset);
6999}
70100
71101static WRITE16_HANDLER( tx_videoram_w )
72102{
73   COMBINE_DATA(&tx_videoram[offset]);
74   tilemap_mark_tile_dirty(tx_tilemap,offset);
103   mwarr_state *state = (mwarr_state *)space->machine->driver_data;
104
105   COMBINE_DATA(&state->tx_videoram[offset]);
106   tilemap_mark_tile_dirty(state->tx_tilemap,offset);
75107}
76108
77109static WRITE16_DEVICE_HANDLER( oki1_bank_w )
r7500r7501
81113
82114static WRITE16_HANDLER( sprites_commands_w )
83115{
84   static int which = 0;
116   mwarr_state *state = (mwarr_state *)space->machine->driver_data;
85117
86   if( which )
118   if (state->which)
87119   {
88120      int i;
89121
90      switch(data)
122      switch (data)
91123      {
92124      case 0:
93125         /* clear sprites on screen */
94         for( i = 0; i < 0x800; i++)
126         for (i = 0; i < 0x800; i++)
95127         {
96            sprites_buffer[i] = 0;
128            state->sprites_buffer[i] = 0;
97129         }
98         which = 0;
130         state->which = 0;
99131         break;
100132
101133      default:
102134         logerror("used unknown sprites command %02X\n",data);
103135      case 0xf:
104136         /* refresh sprites on screen */
105         for( i = 0; i < 0x800; i++)
137         for (i = 0; i < 0x800; i++)
106138         {
107            sprites_buffer[i] = space->machine->generic.spriteram.u16[i];
139            state->sprites_buffer[i] = state->spriteram[i];
108140         }
109141         break;
110142
r7500r7501
114146      }
115147   }
116148
117   which ^= 1;
149   state->which ^= 1;
118150}
119151
120152static WRITE16_HANDLER( mwarr_brightness_w )
121153{
154   mwarr_state *state = (mwarr_state *)space->machine->driver_data;
122155   int i;
123156   double brightness;
124157
125   COMBINE_DATA(&mwarr_ram[0x14/2]);
158   COMBINE_DATA(&state->mwarr_ram[0x14 / 2]);
126159
127160   brightness = (double)(data & 0xff);
128   for (i=0;i<0x800;i++)
161   for (i = 0; i < 0x800; i++)
129162   {
130163      palette_set_pen_contrast(space->machine, i, brightness/255);
131164   }
132165}
133166
134167
168/*************************************
169 *
170 *  Address maps
171 *
172 *************************************/
173
135174static ADDRESS_MAP_START( mwarr_map, ADDRESS_SPACE_PROGRAM, 16 )
136175   AM_RANGE(0x000000, 0x0fffff) AM_ROM
137   AM_RANGE(0x100000, 0x1007ff) AM_RAM_WRITE(bg_videoram_w) AM_BASE(&bg_videoram)
138   AM_RANGE(0x100800, 0x100fff) AM_RAM_WRITE(mlow_videoram_w) AM_BASE(&mlow_videoram)
139   AM_RANGE(0x101000, 0x1017ff) AM_RAM_WRITE(mhigh_videoram_w) AM_BASE(&mhigh_videoram)
140   AM_RANGE(0x101800, 0x1027ff) AM_RAM_WRITE(tx_videoram_w) AM_BASE(&tx_videoram)
141   AM_RANGE(0x103000, 0x1033ff) AM_RAM AM_BASE(&bg_scrollram)
142   AM_RANGE(0x103400, 0x1037ff) AM_RAM AM_BASE(&mlow_scrollram)
143   AM_RANGE(0x103800, 0x103bff) AM_RAM AM_BASE(&mhigh_scrollram)
144   AM_RANGE(0x103c00, 0x103fff) AM_RAM AM_BASE(&vidattrram)
176   AM_RANGE(0x100000, 0x1007ff) AM_RAM_WRITE(bg_videoram_w) AM_BASE_MEMBER(mwarr_state, bg_videoram)
177   AM_RANGE(0x100800, 0x100fff) AM_RAM_WRITE(mlow_videoram_w) AM_BASE_MEMBER(mwarr_state, mlow_videoram)
178   AM_RANGE(0x101000, 0x1017ff) AM_RAM_WRITE(mhigh_videoram_w) AM_BASE_MEMBER(mwarr_state, mhigh_videoram)
179   AM_RANGE(0x101800, 0x1027ff) AM_RAM_WRITE(tx_videoram_w) AM_BASE_MEMBER(mwarr_state, tx_videoram)
180   AM_RANGE(0x103000, 0x1033ff) AM_RAM AM_BASE_MEMBER(mwarr_state, bg_scrollram)
181   AM_RANGE(0x103400, 0x1037ff) AM_RAM AM_BASE_MEMBER(mwarr_state, mlow_scrollram)
182   AM_RANGE(0x103800, 0x103bff) AM_RAM AM_BASE_MEMBER(mwarr_state, mhigh_scrollram)
183   AM_RANGE(0x103c00, 0x103fff) AM_RAM AM_BASE_MEMBER(mwarr_state, vidattrram)
145184   AM_RANGE(0x104000, 0x104fff) AM_RAM_WRITE(paletteram16_xBBBBBGGGGGRRRRR_word_w) AM_BASE_GENERIC(paletteram)
146   AM_RANGE(0x108000, 0x108fff) AM_RAM AM_BASE_GENERIC(spriteram)
185   AM_RANGE(0x108000, 0x108fff) AM_RAM AM_BASE_MEMBER(mwarr_state, spriteram)
147186   AM_RANGE(0x110000, 0x110001) AM_READ_PORT("P1_P2")
148187   AM_RANGE(0x110002, 0x110003) AM_READ_PORT("SYSTEM")
149188   AM_RANGE(0x110004, 0x110005) AM_READ_PORT("DSW")
150189   AM_RANGE(0x110010, 0x110011) AM_DEVWRITE("oki2", oki1_bank_w)
151190   AM_RANGE(0x110014, 0x110015) AM_WRITE(mwarr_brightness_w)
152191   AM_RANGE(0x110016, 0x110017) AM_WRITE(sprites_commands_w)
153   AM_RANGE(0x110000, 0x11ffff) AM_RAM AM_BASE(&mwarr_ram)
192   AM_RANGE(0x110000, 0x11ffff) AM_RAM AM_BASE_MEMBER(mwarr_state, mwarr_ram)
154193   AM_RANGE(0x180000, 0x180001) AM_DEVREADWRITE8("oki1", okim6295_r, okim6295_w, 0x00ff)
155194   AM_RANGE(0x190000, 0x190001) AM_DEVREADWRITE8("oki2", okim6295_r, okim6295_w, 0x00ff)
156195ADDRESS_MAP_END
157196
197
198/*************************************
199 *
200 *  Input ports
201 *
202 *************************************/
203
158204static INPUT_PORTS_START( mwarr )
159205   PORT_START("P1_P2")
160206   PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_8WAY PORT_PLAYER(1)
r7500r7501
229275   PORT_SERVICE_NO_TOGGLE( 0x8000, IP_ACTIVE_LOW )
230276INPUT_PORTS_END
231277
278/*************************************
279 *
280 *  Graphics definitions
281 *
282 *************************************/
283
232284static const gfx_layout mwarr_tile8_layout =
233285{
234286   8,8,
r7500r7501
271323   GFXDECODE_ENTRY( "gfx5", 0, mwarr_tile16_layout,    0,  8 )
272324GFXDECODE_END
273325
326/*************************************
327 *
328 *  Video emulation
329 *
330 *************************************/
331
274332static TILE_GET_INFO( get_bg_tile_info )
275333{
276   int tileno,colour;
334   mwarr_state *state = (mwarr_state *)machine->driver_data;
335   int tileno = state->bg_videoram[tile_index] & 0x1fff;
336   int colour = (state->bg_videoram[tile_index] & 0xe000) >> 13;
277337
278   tileno = bg_videoram[tile_index] & 0x1fff;
279   colour = (bg_videoram[tile_index] & 0xe000) >> 13;
280
281   SET_TILE_INFO(4,tileno,colour,0);
338   SET_TILE_INFO(4, tileno, colour, 0);
282339}
283340
284341static TILE_GET_INFO( get_mlow_tile_info )
285342{
286   int tileno,colour;
343   mwarr_state *state = (mwarr_state *)machine->driver_data;
344   int tileno = state->mlow_videoram[tile_index] & 0x1fff;
345   int colour = (state->mlow_videoram[tile_index] & 0xe000) >> 13;
287346
288   tileno = mlow_videoram[tile_index] & 0x1fff;
289   colour = (mlow_videoram[tile_index] & 0xe000) >> 13;
290
291   SET_TILE_INFO(3,tileno,colour,0);
347   SET_TILE_INFO(3, tileno, colour, 0);
292348}
293349
294350static TILE_GET_INFO( get_mhigh_tile_info )
295351{
296   int tileno,colour;
352   mwarr_state *state = (mwarr_state *)machine->driver_data;
353   int tileno = state->mhigh_videoram[tile_index] & 0x1fff;
354   int colour = (state->mhigh_videoram[tile_index] & 0xe000) >> 13;
297355
298   tileno = mhigh_videoram[tile_index] & 0x1fff;
299   colour = (mhigh_videoram[tile_index] & 0xe000) >> 13;
300
301   SET_TILE_INFO(2,tileno,colour,0);
356   SET_TILE_INFO(2, tileno, colour, 0);
302357}
303358
304359static TILE_GET_INFO( get_tx_tile_info )
305360{
306   int tileno,colour;
361   mwarr_state *state = (mwarr_state *)machine->driver_data;
362   int tileno = state->tx_videoram[tile_index] & 0x1fff;
363   int colour = (state->tx_videoram[tile_index] & 0xe000) >> 13;
307364
308   tileno = tx_videoram[tile_index] & 0x1fff;
309   colour = (tx_videoram[tile_index] & 0xe000) >> 13;
310
311   SET_TILE_INFO(1,tileno,colour,0);
365   SET_TILE_INFO(1, tileno, colour, 0);
312366}
313367
314368static VIDEO_START( mwarr )
315369{
316   bg_tilemap    = tilemap_create(machine, get_bg_tile_info,   tilemap_scan_cols, 16, 16,64,16);
317   mlow_tilemap  = tilemap_create(machine, get_mlow_tile_info, tilemap_scan_cols, 16, 16,64,16);
318   mhigh_tilemap = tilemap_create(machine, get_mhigh_tile_info,tilemap_scan_cols, 16, 16,64,16);
319   tx_tilemap    = tilemap_create(machine, get_tx_tile_info,   tilemap_scan_rows,  8,  8,64,32);
370   mwarr_state *state = (mwarr_state *)machine->driver_data;
320371
321   sprites_buffer = auto_alloc_array(machine, UINT16, 0x800);
372   state->bg_tilemap    = tilemap_create(machine, get_bg_tile_info,    tilemap_scan_cols, 16, 16, 64, 16);
373   state->mlow_tilemap  = tilemap_create(machine, get_mlow_tile_info,  tilemap_scan_cols, 16, 16, 64, 16);
374   state->mhigh_tilemap = tilemap_create(machine, get_mhigh_tile_info, tilemap_scan_cols, 16, 16, 64, 16);
375   state->tx_tilemap    = tilemap_create(machine, get_tx_tile_info,    tilemap_scan_rows,  8,  8, 64, 32);
322376
323   tilemap_set_transparent_pen(mlow_tilemap,0);
324   tilemap_set_transparent_pen(mhigh_tilemap,0);
325   tilemap_set_transparent_pen(tx_tilemap,0);
377   state->sprites_buffer = auto_alloc_array(machine, UINT16, 0x800);
326378
327   tilemap_set_scroll_rows(bg_tilemap, 256);
328   tilemap_set_scroll_rows(mlow_tilemap, 256);
329   tilemap_set_scroll_rows(mhigh_tilemap, 256);
379   tilemap_set_transparent_pen(state->mlow_tilemap, 0);
380   tilemap_set_transparent_pen(state->mhigh_tilemap, 0);
381   tilemap_set_transparent_pen(state->tx_tilemap, 0);
382
383   tilemap_set_scroll_rows(state->bg_tilemap, 256);
384   tilemap_set_scroll_rows(state->mlow_tilemap, 256);
385   tilemap_set_scroll_rows(state->mhigh_tilemap, 256);
386
387   state_save_register_global_pointer(machine, state->sprites_buffer, 0x800);
330388}
331389
332static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect )
390static void draw_sprites( running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect )
333391{
334   const UINT16 *source = sprites_buffer+0x800-4;
335   const UINT16 *finish = sprites_buffer;
392   mwarr_state *state = (mwarr_state *)machine->driver_data;
393   const UINT16 *source = state->sprites_buffer + 0x800 - 4;
394   const UINT16 *finish = state->sprites_buffer;
336395   const gfx_element *gfx = machine->gfx[0];
337396   int x, y, color, flipx, dy, pri, pri_mask, i;
338397
339   while( source>=finish )
398   while (source >= finish)
340399   {
341400      /* draw sprite */
342      if( source[0] & 0x0800 )
401      if (source[0] & 0x0800)
343402      {
344403         y = 512 - (source[0] & 0x01ff);
345404         x = (source[3] & 0x3ff) - 9;
r7500r7501
347406         color = source[1] & 0x000f;
348407         flipx = source[1] & 0x0200;
349408
350         dy = (source[0] & 0xf000)>>12;
409         dy = (source[0] & 0xf000) >> 12;
351410
352         pri       =   ((source[1] & 0x3c00)>>10);   // Priority (1 = Low)
353         pri_mask =   ~((1 << (pri+1)) - 1);      // Above the first "pri" levels
411         pri = ((source[1] & 0x3c00) >> 10);   // Priority (1 = Low)
412         pri_mask = ~((1 << (pri + 1)) - 1);      // Above the first "pri" levels
354413
355         for(i=0;i<=dy;i++)
414         for (i = 0; i <= dy; i++)
356415         {
357416            pdrawgfx_transpen( bitmap,
358417                    cliprect,
r7500r7501
401460
402461static VIDEO_UPDATE( mwarr )
403462{
463   mwarr_state *state = (mwarr_state *)screen->machine->driver_data;
404464   int i;
405465
406   bitmap_fill(screen->machine->priority_bitmap,cliprect,0);
466   bitmap_fill(screen->machine->priority_bitmap, cliprect, 0);
407467
408   if(vidattrram[6] & 1)
468   if (BIT(state->vidattrram[6], 0))
409469   {
410      for(i=0;i<256;i++)
411         tilemap_set_scrollx(bg_tilemap, i, bg_scrollram[i]+20);
470      for (i = 0; i < 256; i++)
471         tilemap_set_scrollx(state->bg_tilemap, i, state->bg_scrollram[i] + 20);
412472   }
413473   else
414474   {
415      for(i=0;i<256;i++)
416         tilemap_set_scrollx(bg_tilemap, i, bg_scrollram[0]+19);
475      for (i = 0; i < 256; i++)
476         tilemap_set_scrollx(state->bg_tilemap, i, state->bg_scrollram[0] + 19);
417477   }
418478
419   if(vidattrram[6] & 4)
479   if (BIT(state->vidattrram[6], 2))
420480   {
421      for(i=0;i<256;i++)
422         tilemap_set_scrollx(mlow_tilemap, i, mlow_scrollram[i]+19);
481      for (i = 0; i < 256; i++)
482         tilemap_set_scrollx(state->mlow_tilemap, i, state->mlow_scrollram[i] + 19);
423483   }
424484   else
425485   {
426      for(i=0;i<256;i++)
427         tilemap_set_scrollx(mlow_tilemap, i, mlow_scrollram[0]+19);
486      for (i = 0; i < 256; i++)
487         tilemap_set_scrollx(state->mlow_tilemap, i, state->mlow_scrollram[0] + 19);
428488   }
429489
430   if(vidattrram[6] & 0x10)
490   if (BIT(state->vidattrram[6], 4))
431491   {
432      for(i=0;i<256;i++)
433         tilemap_set_scrollx(mhigh_tilemap, i, mhigh_scrollram[i]+19);
492      for (i = 0; i < 256; i++)
493         tilemap_set_scrollx(state->mhigh_tilemap, i, state->mhigh_scrollram[i] + 19);
434494   }
435495   else
436496   {
437      for(i=0;i<256;i++)
438         tilemap_set_scrollx(mhigh_tilemap, i, mhigh_scrollram[0]+19);
497      for (i = 0; i < 256; i++)
498         tilemap_set_scrollx(state->mhigh_tilemap, i, state->mhigh_scrollram[0] + 19);
439499   }
440500
441   tilemap_set_scrolly(bg_tilemap,    0, vidattrram[1]+1);
442   tilemap_set_scrolly(mlow_tilemap,  0, vidattrram[2]+1);
443   tilemap_set_scrolly(mhigh_tilemap, 0, vidattrram[3]+1);
501   tilemap_set_scrolly(state->bg_tilemap,    0, state->vidattrram[1] + 1);
502   tilemap_set_scrolly(state->mlow_tilemap,  0, state->vidattrram[2] + 1);
503   tilemap_set_scrolly(state->mhigh_tilemap, 0, state->vidattrram[3] + 1);
444504
445   tilemap_set_scrollx(tx_tilemap, 0, vidattrram[0]+16);
446   tilemap_set_scrolly(tx_tilemap, 0, vidattrram[4]+1);
505   tilemap_set_scrollx(state->tx_tilemap, 0, state->vidattrram[0] + 16);
506   tilemap_set_scrolly(state->tx_tilemap, 0, state->vidattrram[4] + 1);
447507
448   tilemap_draw(bitmap,cliprect,bg_tilemap,   0,0x01);
449   tilemap_draw(bitmap,cliprect,mlow_tilemap, 0,0x02);
450   tilemap_draw(bitmap,cliprect,mhigh_tilemap,0,0x04);
451   tilemap_draw(bitmap,cliprect,tx_tilemap,   0,0x10);
452   draw_sprites(screen->machine, bitmap,cliprect);
508   tilemap_draw(bitmap, cliprect, state->bg_tilemap,    0, 0x01);
509   tilemap_draw(bitmap, cliprect, state->mlow_tilemap,  0, 0x02);
510   tilemap_draw(bitmap, cliprect, state->mhigh_tilemap, 0, 0x04);
511   tilemap_draw(bitmap, cliprect, state->tx_tilemap,    0, 0x10);
512   draw_sprites(screen->machine, bitmap, cliprect);
453513   return 0;
454514}
455515
516/*************************************
517 *
518 *  Machine driver
519 *
520 *************************************/
521
522static MACHINE_START( mwarr )
523{
524   mwarr_state *state = (mwarr_state *)machine->driver_data;
525
526   state_save_register_global(machine, state->which);
527}
528
529static MACHINE_RESET( mwarr )
530{
531   mwarr_state *state = (mwarr_state *)machine->driver_data;
532
533   state->which = 0;
534}
535
456536static MACHINE_DRIVER_START( mwarr )
537
538   /* driver data */
539   MDRV_DRIVER_DATA(mwarr_state)
540
541   /* basic machine hardware */
457542   MDRV_CPU_ADD("maincpu", M68000, MASTER_CLOCK)
458543   MDRV_CPU_PROGRAM_MAP(mwarr_map)
459544   MDRV_CPU_VBLANK_INT("screen", irq4_line_hold)
460545
461   MDRV_GFXDECODE(mwarr)
546   MDRV_MACHINE_START(mwarr)
547   MDRV_MACHINE_RESET(mwarr)
462548
463
549   /* video hardware */
464550   MDRV_SCREEN_ADD("screen", RASTER)
465551   MDRV_SCREEN_REFRESH_RATE(54)
466552   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(2500) /* not accurate */)
r7500r7501
468554   MDRV_SCREEN_SIZE(64*8, 32*8)
469555   MDRV_SCREEN_VISIBLE_AREA(8+1, 48*8-1-8-1, 0, 30*8-1)
470556
557   MDRV_GFXDECODE(mwarr)
471558   MDRV_PALETTE_LENGTH(0x800)
472559
473560   MDRV_VIDEO_START(mwarr)
474561   MDRV_VIDEO_UPDATE(mwarr)
475562
563   /* sound hardware */
476564   MDRV_SPEAKER_STANDARD_MONO("mono")
477565
478566   MDRV_SOUND_ADD("oki1", OKIM6295, SOUND_CLOCK/48 )
r7500r7501
485573MACHINE_DRIVER_END
486574
487575
576/*************************************
577 *
578 *  ROM definition(s)
579 *
580 *************************************/
581
488582ROM_START( mwarr )
489583   ROM_REGION( 0x100000, "maincpu", 0 ) /* 68000 Code */
490584   ROM_LOAD16_BYTE( "prg_ev", 0x00000, 0x80000, CRC(d1d5e0a6) SHA1(f47955459d41c904b96de000b32cae156ee3bcba) )
r7500r7501
545639   ROM_COPY( "user1", 0x060000, 0x0e0000, 0x020000)
546640ROM_END
547641
548GAME( 199?, mwarr, 0, mwarr, mwarr, 0, ROT0,  "Elettronica Video-Games S.R.L.", "Mighty Warriors", 0 )
642/*************************************
643 *
644 *  Game driver(s)
645 *
646 *************************************/
647
648GAME( 199?, mwarr, 0, mwarr, mwarr, 0, ROT0,  "Elettronica Video-Games S.R.L.", "Mighty Warriors", GAME_SUPPORTS_SAVE )
src/mame/drivers/cultures.c
r7500r7501
1414
1515#define MCLK 16000000
1616
17typedef struct _cultures_state cultures_state;
18struct _cultures_state
17class cultures_state
1918{
19public:
20   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, cultures_state(machine)); }
21
22   cultures_state(running_machine &machine) { }
23
2024   /* memory pointers */
2125   UINT8 *   bg0_videoram;
2226   UINT8 *   paletteram;
src/mame/drivers/superdq.c
r7500r7501
2727#include "machine/laserdsc.h"
2828#include "video/resnet.h"
2929
30typedef struct _superdq_state superdq_state;
31struct _superdq_state
30class superdq_state
3231{
32public:
33   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, superdq_state(machine)); }
34
35   superdq_state(running_machine &machine) { }
36
3337   running_device *laserdisc;
3438   UINT8 ld_in_latch;
3539   UINT8 ld_out_latch;
src/mame/drivers/zaxxon.c
r7500r7501
779779   PORT_INCLUDE(zaxxon)
780780
781781   PORT_MODIFY("SW00")
782   PORT_BIT( 0xff, 0x00, IPT_SPECIAL) PORT_CUSTOM(razmataz_dial_r, (void *)0)
783
784   PORT_START("DIAL0")
782785   PORT_BIT( 0xff, 0x00, IPT_DIAL ) PORT_SENSITIVITY(30) PORT_KEYDELTA(15) PORT_CODE_DEC(KEYCODE_Z) PORT_CODE_INC(KEYCODE_X) PORT_RESET
783786
784787   PORT_MODIFY("SW01")
src/mame/drivers/news.c
r7500r7501
2121
2222static ADDRESS_MAP_START( news_map, ADDRESS_SPACE_PROGRAM, 8 )
2323   AM_RANGE(0x0000, 0x7fff) AM_ROM    /* 4000-7fff is written to during startup, probably leftover code */
24   AM_RANGE(0x8000, 0x87ff) AM_RAM_WRITE(news_fgram_w) AM_BASE(&news_fgram)
25   AM_RANGE(0x8800, 0x8fff) AM_RAM_WRITE(news_bgram_w) AM_BASE(&news_bgram)
24   AM_RANGE(0x8000, 0x87ff) AM_RAM_WRITE(news_fgram_w) AM_BASE_MEMBER(news_state, fgram)
25   AM_RANGE(0x8800, 0x8fff) AM_RAM_WRITE(news_bgram_w) AM_BASE_MEMBER(news_state, bgram)
2626   AM_RANGE(0x9000, 0x91ff) AM_RAM_WRITE(paletteram_xxxxRRRRGGGGBBBB_be_w) AM_BASE_GENERIC(paletteram)
2727   AM_RANGE(0xc000, 0xc000) AM_READ_PORT("DSW")
2828   AM_RANGE(0xc001, 0xc001) AM_READ_PORT("INPUTS")
r7500r7501
113113
114114
115115
116static MACHINE_START( news )
117{
118   news_state *state = (news_state *)machine->driver_data;
119
120   state_save_register_global(machine, state->bgpic);
121}
122
123static MACHINE_RESET( news )
124{
125   news_state *state = (news_state *)machine->driver_data;
126
127   state->bgpic = 0;
128}
129
116130static MACHINE_DRIVER_START( news )
131
132   /* driver data */
133   MDRV_DRIVER_DATA(news_state)
134
117135   /* basic machine hardware */
118136   MDRV_CPU_ADD("maincpu", Z80,8000000)       /* ? MHz */
119137   MDRV_CPU_PROGRAM_MAP(news_map)
120138   MDRV_CPU_VBLANK_INT("screen", irq0_line_hold)
121139
140   MDRV_MACHINE_START(news)
141   MDRV_MACHINE_RESET(news)
142
122143   /* video hardware */
123144   MDRV_SCREEN_ADD("screen", RASTER)
124145   MDRV_SCREEN_REFRESH_RATE(60)
r7500r7501
167188   ROM_LOAD( "virus.1", 0x00000, 0x40000, CRC(41f5935a) SHA1(1566d243f165019660cd4dd69df9f049e0130f15) )
168189ROM_END
169190
170GAME( 1993, news,  0,    news, news,  0, ROT0, "Poby / Virus", "News (set 1)", 0 )
171GAME( 1993, newsa, news, news, newsa, 0, ROT0, "Poby",         "News (set 2)", 0 )
191GAME( 1993, news,  0,    news, news,  0, ROT0, "Poby / Virus", "News (set 1)", GAME_SUPPORTS_SAVE )
192GAME( 1993, newsa, news, news, newsa, 0, ROT0, "Poby",         "News (set 2)", GAME_SUPPORTS_SAVE )
src/mame/drivers/wc90.c
r7500r7501
309309static MACHINE_DRIVER_START( wc90 )
310310
311311   /* basic machine hardware */
312   MDRV_CPU_ADD("maincpu", Z80, 6000000)   /* 6.0 MHz ??? */
312   MDRV_CPU_ADD("maincpu", Z80, XTAL_8MHz)      /* verified on pcb */
313313   MDRV_CPU_PROGRAM_MAP(wc90_map_1)
314314   MDRV_CPU_VBLANK_INT("screen", irq0_line_hold)
315315
316   MDRV_CPU_ADD("sub", Z80, 6000000)   /* 6.0 MHz ??? */
316   MDRV_CPU_ADD("sub", Z80, XTAL_8MHz)      /* verified on pcb */
317317   MDRV_CPU_PROGRAM_MAP(wc90_map_2)
318318   MDRV_CPU_VBLANK_INT("screen", irq0_line_hold)
319319
320   MDRV_CPU_ADD("audiocpu", Z80, 4000000)   /* 4 MHz ???? */
320   MDRV_CPU_ADD("audiocpu", Z80, XTAL_8MHz/2)   /* verified on pcb */
321321   MDRV_CPU_PROGRAM_MAP(sound_map)
322322   /* NMIs are triggered by the main CPU */
323323
324324   /* video hardware */
325325   MDRV_SCREEN_ADD("screen", RASTER)
326   MDRV_SCREEN_REFRESH_RATE(60)
326   MDRV_SCREEN_REFRESH_RATE(59.17)         /* verified on pcb */
327327   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(0))
328328   MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16)
329329   MDRV_SCREEN_SIZE(32*8, 32*8)
r7500r7501
338338   /* sound hardware */
339339   MDRV_SPEAKER_STANDARD_MONO("mono")
340340
341   MDRV_SOUND_ADD("ymsnd", YM2608, 8000000)
341   MDRV_SOUND_ADD("ymsnd", YM2608, XTAL_8MHz)   /* verified on pcb */
342342   MDRV_SOUND_CONFIG(ym2608_config)
343343   MDRV_SOUND_ROUTE(0, "mono", 0.50)
344344   MDRV_SOUND_ROUTE(1, "mono", 1.0)
src/mame/drivers/namcops2.c
r7500r7501
115115
116116ROM_START( kinniku )
117117   ROM_REGION(0x200000, "bios", 0)
118   SYSTEM246_BIOS
118   SYSTEM256_BIOS
119119
120120   ROM_REGION(0x840000, "key", ROMREGION_ERASE00)
121121        ROM_LOAD( "kn1vera.ic002", 0x000000, 0x800000, CRC(17aac6c3) SHA1(dddf37e88385f01bba27496d03f053fdc33882e2) )
r7500r7501
133133        ROM_LOAD( "npy1verb_spr.ic002", 0x800000, 0x040000, CRC(6a3374f0) SHA1(0c0845edc0ac0e9871e65caade8b4157614b81eb) )
134134
135135   DISK_REGION("dvd")
136   DISK_IMAGE_READONLY( "npy1cd0b", 0, SHA1(514adcd2d4205873b3d144a05c033822344798e3) )
136137ROM_END
137138
138139ROM_START( soulclb2 )
r7500r7501
155156        ROM_LOAD( "sc21vera_spr.ic002", 0x800000, 0x040000, CRC(f5502fdf) SHA1(064196982d855bd41bafe97db5ff5694b933016a) )
156157
157158   DISK_REGION("dvd")
159   DISK_IMAGE_READONLY( "sc210d", 0, SHA1(9a7b1ea836adc9d78481928a3067530e0f8d74a6) )
158160ROM_END
159161
160162ROM_START( soulclb3 )
r7500r7501
166168        ROM_LOAD( "sc31001-na-a_spr.ic002", 0x800000, 0x040000, CRC(18c6f56d) SHA1(13bc6a3688985c0cd9900b063824a4af691a1b31) )
167169
168170   DISK_REGION("dvd")
171   DISK_IMAGE_READONLY( "sc31na0b", 0, SHA1(b46ee35083f8fcc091ce562951c55fbdbb929e4b) )
169172ROM_END
170173
171174ROM_START( sukuinuf )
r7500r7501
177180        ROM_LOAD( "in2vera_spr.ic002", 0x800000, 0x040000, CRC(c43fed95) SHA1(b6001dc8ff34198400a7bf3e41e5ab73823685b0) )
178181
179182   DISK_REGION("dvd")
183   DISK_IMAGE_READONLY( "in2vera", 0, SHA1(4e2d95798a2bcc6f93bc82c364379a3936d68986) )
180184ROM_END
181185
182186ROM_START( taiko9 )
183187   ROM_REGION(0x200000, "bios", 0)
184   SYSTEM246_BIOS
188   SYSTEM256_BIOS
185189
186190   ROM_REGION(0x840000, "key", ROMREGION_ERASE00)
187191        ROM_LOAD( "tk91001-na-a.ic002", 0x000000, 0x800000, CRC(db4efc9a) SHA1(a24f10c726f5bc7313559a515d5c4c34cd129c97) )
r7500r7501
221225        ROM_LOAD( "tef1vera.spr", 0x800000, 0x040000, CRC(64e12053) SHA1(04383cf928b4fd82290d7cccc7b23104fbf2c2f2) )
222226
223227   DISK_REGION("dvd")
228   DISK_IMAGE_READONLY( "tef1dvd0", 0, SHA1(f39aa37156245f622a6e19e8a0e081418e247b36) )
224229ROM_END
225230
226231ROM_START( tekken51 )
r7500r7501
232237        ROM_LOAD( "te51verb_spr.ic002", 0x800000, 0x040000, CRC(683bad0d) SHA1(ef10accbdc82143c31d29e2b8b812a209b341b1b) )
233238
234239   DISK_REGION("dvd")
240   DISK_IMAGE_READONLY( "te510b", 0, SHA1(2a0ac3723725572c1810b0ef4bcfa7aa114062f8) )
235241ROM_END
236242
237243ROM_START( zgundm )
r7500r7501
269275GAME(2004, sukuinuf,   sys246, system246, system246, 0, ROT0, "Namco", "Quiz and Variety Suku Suku Inufuku 2 (IN2 Ver. A)", GAME_NO_SOUND|GAME_NOT_WORKING)
270276GAME(2004, zgundmdx,   sys246, system246, system246, 0, ROT0, "Capcom/Banpresto", "Mobile Suit Z-Gundam: A.E.U.G. vs Titans DX (ZDX1 Ver. A)", GAME_NO_SOUND|GAME_NOT_WORKING)
271277GAME(2005, soulclb3,   sys246, system246, system246, 0, ROT0, "Namco", "Soul Calibur III (SC31001-NA-A)", GAME_NO_SOUND|GAME_NOT_WORKING)
272GAME(2006, kinniku,    sys246, system246, system246, 0, ROT0, "Namco", "Kinnikuman Muscle Grand Prix (KN1 Ver. A)", GAME_NO_SOUND|GAME_NOT_WORKING)
273GAME(2006, taiko9,     sys246, system246, system246, 0, ROT0, "Namco", "Taiko No Tatsujin 9 (TK91001-NA-A)", GAME_NO_SOUND|GAME_NOT_WORKING)
274278
275279GAME(2004, sys256,          0, system256, system246, 0, ROT0, "Namco", "System 256 BIOS", GAME_NO_SOUND|GAME_NOT_WORKING|GAME_IS_BIOS_ROOT)
276280GAME(2005, tekken51,   sys256, system256, system246, 0, ROT0, "Namco", "Tekken 5.1 (TE51 Ver. B)", GAME_NO_SOUND|GAME_NOT_WORKING)
281GAME(2006, kinniku,    sys256, system256, system246, 0, ROT0, "Namco", "Kinnikuman Muscle Grand Prix (KN1 Ver. A)", GAME_NO_SOUND|GAME_NOT_WORKING)
282GAME(2006, taiko9,     sys256, system256, system246, 0, ROT0, "Namco", "Taiko No Tatsujin 9 (TK91001-NA-A)", GAME_NO_SOUND|GAME_NOT_WORKING)
277283
src/mame/drivers/deniam.c
r7500r7501
7171      okim6295_set_bank_base(device, (data & 0x01) ? 0x40000 : 0x00000);
7272}
7373
74static WRITE16_HANDLER( deniam_irq_ack_w )
75{
76   cputag_set_input_line(space->machine, "maincpu", 4, CLEAR_LINE);
77}
7478
7579static ADDRESS_MAP_START( deniam16b_map, ADDRESS_SPACE_PROGRAM, 16 )
7680   AM_RANGE(0x000000, 0x0fffff) AM_ROM
r7500r7501
8084   AM_RANGE(0x840000, 0x840fff) AM_WRITE(deniam_palette_w) AM_BASE_MEMBER(deniam_state, paletteram)
8185   AM_RANGE(0xc40000, 0xc40001) AM_WRITE(sound_command_w)
8286   AM_RANGE(0xc40002, 0xc40003) AM_READWRITE(deniam_coinctrl_r, deniam_coinctrl_w)
87   AM_RANGE(0xc40004, 0xc40005) AM_WRITE(deniam_irq_ack_w)
8388   AM_RANGE(0xc44000, 0xc44001) AM_READ_PORT("SYSTEM")
8489   AM_RANGE(0xc44002, 0xc44003) AM_READ_PORT("P1")
85   AM_RANGE(0xc44004, 0xc44005) AM_READ_PORT("P2") AM_WRITENOP /* irq ack? */
90   AM_RANGE(0xc44004, 0xc44005) AM_READ_PORT("P2") AM_WRITENOP
8691   AM_RANGE(0xc44006, 0xc44007) AM_READNOP   /* unused? */
8792   AM_RANGE(0xc4400a, 0xc4400b) AM_READ_PORT("DSW")
8893   AM_RANGE(0xff0000, 0xffffff) AM_RAM
r7500r7501
110115   AM_RANGE(0x840000, 0x840fff) AM_WRITE(deniam_palette_w) AM_BASE_MEMBER(deniam_state, paletteram)
111116   AM_RANGE(0xc40000, 0xc40001) AM_DEVREADWRITE8("oki", okim6295_r, okim6295_w, 0x00ff)
112117   AM_RANGE(0xc40002, 0xc40003) AM_READWRITE(deniam_coinctrl_r, deniam_coinctrl_w)
118   AM_RANGE(0xc40004, 0xc40005) AM_WRITE(deniam_irq_ack_w)
113119   AM_RANGE(0xc44000, 0xc44001) AM_READ_PORT("SYSTEM")
114120   AM_RANGE(0xc44002, 0xc44003) AM_READ_PORT("P1")
115   AM_RANGE(0xc44004, 0xc44005) AM_READ_PORT("P2") AM_WRITENOP /* irq ack? */
121   AM_RANGE(0xc44004, 0xc44005) AM_READ_PORT("P2") AM_WRITENOP
116122   AM_RANGE(0xc44006, 0xc44007) AM_READNOP   AM_DEVWRITE("oki", deniam16c_oki_rom_bank_w) /* read unused? */
117123   AM_RANGE(0xc40008, 0xc4000b) AM_DEVWRITE8("ymsnd", ym3812_w, 0xff00)
118124   AM_RANGE(0xc4400a, 0xc4400b) AM_READ_PORT("DSW") /* probably YM3812 input port */
r7500r7501
267273   /* basic machine hardware */
268274   MDRV_CPU_ADD("maincpu", M68000,XTAL_25MHz/2)   /* 12.5Mhz verified */
269275   MDRV_CPU_PROGRAM_MAP(deniam16b_map)
270   MDRV_CPU_VBLANK_INT("screen", irq4_line_hold)
276   MDRV_CPU_VBLANK_INT("screen", irq4_line_assert)
271277
272278   MDRV_CPU_ADD("audiocpu", Z80,XTAL_25MHz/4)   /* 6.25Mhz verified */
273279   MDRV_CPU_PROGRAM_MAP(sound_map)
r7500r7501
311317   /* basic machine hardware */
312318   MDRV_CPU_ADD("maincpu", M68000,XTAL_25MHz/2)   /* 12.5Mhz verified */
313319   MDRV_CPU_PROGRAM_MAP(deniam16c_map)
314   MDRV_CPU_VBLANK_INT("screen", irq4_line_hold)
320   MDRV_CPU_VBLANK_INT("screen", irq4_line_assert)
315321
316322   MDRV_MACHINE_START(deniam)
317323   MDRV_MACHINE_RESET(deniam)
src/mame/drivers/big10.c
r7500r7501
7171
7272static void big10_vdp_interrupt(running_machine *machine, int i)
7373{
74   cputag_set_input_line (machine, "maincpu", 0, (i ? HOLD_LINE : CLEAR_LINE));
74   cputag_set_input_line (machine, "maincpu", 0, (i ? ASSERT_LINE : CLEAR_LINE));
7575}
7676
7777static INTERRUPT_GEN( big10_interrupt )
src/mame/drivers/aladbl.c
r7500r7501
154154   ROM_CONTINUE(            0x300000, 0x040000)
155155ROM_END
156156
157static INPUT_PORTS_START(mk3ghw)
158   PORT_INCLUDE( md_common )
159
160   PORT_MODIFY("PAD1")      /* Joypad 1 (3 button + start) NOT READ DIRECTLY */
161   PORT_BIT( 0x0010, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(1) // a
162   PORT_BIT( 0x0020, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(1) // b
163   PORT_BIT( 0x0040, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_PLAYER(1) // c
164   PORT_BIT( 0x0080, IP_ACTIVE_LOW, IPT_START1 ) // start
165
166   PORT_MODIFY("PAD2")      /* Joypad 2 (3 button + start) NOT READ DIRECTLY - not used */
167   PORT_BIT( 0x00ff, IP_ACTIVE_LOW, IPT_UNUSED )
168
169   PORT_START("IN0")
170   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_COIN1 ) PORT_IMPULSE(1)
171   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_COIN2 ) PORT_IMPULSE(1)
172   PORT_DIPNAME( 0x04, 0x04, DEF_STR( Coinage ) )
173   PORT_DIPSETTING(    0x00, DEF_STR( 3C_1C ) )
174   PORT_DIPSETTING(    0x04, DEF_STR( 1C_2C ) )
175   PORT_BIT( 0xf8, 0x00, IPT_UNUSED )
176
177   PORT_START("IN1")
178   PORT_DIPUNKNOWN( 0x01, 0x00 )
179   PORT_DIPUNKNOWN( 0x02, 0x00 )
180   PORT_DIPUNKNOWN( 0x04, 0x00 )
181   PORT_DIPUNKNOWN( 0x08, 0x00 )
182   PORT_DIPUNKNOWN( 0x10, 0x00 )
183   PORT_DIPUNKNOWN( 0x20, 0x00 )
184   PORT_DIPNAME( 0x40, 0x40, DEF_STR( Demo_Sounds ) )
185   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
186   PORT_DIPSETTING(    0x40, DEF_STR( On ) )
187   PORT_DIPUNKNOWN( 0x80, 0x00 )
188INPUT_PORTS_END
189
190157// this should be correct, the areas of the rom that differ to the original
191158// after this decode look like intentional changes
192159static DRIVER_INIT( mk3ghw )
r7500r7501
233200   ROM[7] = 0x02;
234201   ROM[6] = 0x10;
235202
236   memory_install_read_port(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x770070, 0x770071, 0, 0, "IN0");
237   memory_install_read_port(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x770072, 0x770073, 0, 0, "IN1");
203   memory_install_read_port(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x770070, 0x770071, 0, 0, "DSWA");
204   memory_install_read_port(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x770072, 0x770073, 0, 0, "DSWB");
238205}
239206
240207
src/mame/drivers/taito_b.c
r7500r7501
520520   AM_RANGE(0x200000, 0x201fff) AM_RAM_WRITE(paletteram16_RRRRGGGGBBBBxxxx_word_w) AM_BASE_GENERIC(paletteram)
521521   TC0180VCU_MEMRW( 0x400000 )
522522   AM_RANGE(0x600000, 0x600001) AM_DEVREADWRITE8("tc0220ioc", tc0220ioc_portreg_r, tc0220ioc_portreg_w, 0xff00)
523   AM_RANGE(0x600002, 0x600003) AM_DEVREADWRITE8("tc0220ioc", tc0220ioc_r, tc0220ioc_w, 0xff00)
523   AM_RANGE(0x600002, 0x600003) AM_DEVREADWRITE8("tc0220ioc", tc0220ioc_port_r, tc0220ioc_port_w, 0xff00)
524524   AM_RANGE(0x800000, 0x803fff) AM_RAM   /* Main RAM */
525525   AM_RANGE(0xa00000, 0xa00001) AM_READNOP AM_DEVWRITE8("tc0140syt", tc0140syt_port_w, 0xff00)
526526   AM_RANGE(0xa00002, 0xa00003) AM_DEVREADWRITE8("tc0140syt", tc0140syt_comm_r, tc0140syt_comm_w, 0xff00)
r7500r7501
641641   TC0180VCU_MEMRW( 0x400000 )
642642   AM_RANGE(0x600000, 0x601fff) AM_RAM_WRITE(paletteram16_RRRRGGGGBBBBxxxx_word_w) AM_BASE_GENERIC(paletteram)
643643   AM_RANGE(0x800000, 0x800001) AM_DEVREADWRITE8("tc0220ioc", tc0220ioc_portreg_r, tc0220ioc_portreg_w, 0xff00)
644   AM_RANGE(0x800002, 0x800003) AM_DEVREADWRITE8("tc0220ioc", tc0220ioc_r, tc0220ioc_w, 0xff00)
644   AM_RANGE(0x800002, 0x800003) AM_DEVREADWRITE8("tc0220ioc", tc0220ioc_port_r, tc0220ioc_port_w, 0xff00)
645645   AM_RANGE(0xa00000, 0xa00001) AM_READNOP AM_DEVWRITE8("tc0140syt", tc0140syt_port_w, 0xff00)
646646   AM_RANGE(0xa00002, 0xa00003) AM_DEVREADWRITE8("tc0140syt", tc0140syt_comm_r, tc0140syt_comm_w, 0xff00)
647647ADDRESS_MAP_END
src/mame/drivers/vaportra.c
r7500r7501
1414#include "sound/2203intf.h"
1515#include "sound/2151intf.h"
1616#include "sound/okim6295.h"
17#include "includes/deco16ic.h"
17#include "video/deco16ic.h"
18#include "includes/vaportra.h"
1819
19VIDEO_START( vaportra );
20VIDEO_UPDATE( vaportra );
21
22WRITE16_HANDLER( vaportra_priority_w );
23WRITE16_HANDLER( vaportra_palette_24bit_rg_w );
24WRITE16_HANDLER( vaportra_palette_24bit_b_w );
25
2620/******************************************************************************/
2721
2822static WRITE16_HANDLER( vaportra_sound_w )
2923{
24   vaportra_state *state = (vaportra_state *)space->machine->driver_data;
25
3026   /* Force synchronisation between CPUs with fake timer */
3127   timer_call_after_resynch(space->machine, NULL, 0, NULL);
32   soundlatch_w(space,0,data & 0xff);
33   cputag_set_input_line(space->machine, "audiocpu", 0, ASSERT_LINE);
28   soundlatch_w(space, 0, data & 0xff);
29   cpu_set_input_line(state->audiocpu, 0, ASSERT_LINE);
3430}
3531
3632static READ16_HANDLER( vaportra_control_r )
3733{
38   switch (offset<<1)
34   switch (offset << 1)
3935   {
4036      case 4:
4137         return input_port_read(space->machine, "DSW");
r7500r7501
5652   AM_RANGE(0x100000, 0x100003) AM_WRITE(vaportra_priority_w)
5753   AM_RANGE(0x100006, 0x100007) AM_WRITE(vaportra_sound_w)
5854   AM_RANGE(0x100000, 0x10000f) AM_READ(vaportra_control_r)
59   AM_RANGE(0x200000, 0x201fff) AM_RAM_WRITE(deco16_pf3_data_w) AM_BASE(&deco16_pf3_data)
60   AM_RANGE(0x202000, 0x203fff) AM_RAM_WRITE(deco16_pf4_data_w) AM_BASE(&deco16_pf4_data)
61   AM_RANGE(0x240000, 0x24000f) AM_WRITEONLY AM_BASE(&deco16_pf34_control)
62   AM_RANGE(0x280000, 0x281fff) AM_RAM_WRITE(deco16_pf1_data_w) AM_BASE(&deco16_pf1_data)
63   AM_RANGE(0x282000, 0x283fff) AM_RAM_WRITE(deco16_pf2_data_w) AM_BASE(&deco16_pf2_data)
64   AM_RANGE(0x2c0000, 0x2c000f) AM_WRITEONLY AM_BASE(&deco16_pf12_control)
55   AM_RANGE(0x200000, 0x201fff) AM_DEVREADWRITE("deco_custom", deco16ic_pf3_data_r, deco16ic_pf3_data_w)
56   AM_RANGE(0x202000, 0x203fff) AM_DEVREADWRITE("deco_custom", deco16ic_pf4_data_r, deco16ic_pf4_data_w)
57   AM_RANGE(0x240000, 0x24000f) AM_DEVWRITE("deco_custom", deco16ic_pf34_control_w)
58   AM_RANGE(0x280000, 0x281fff) AM_DEVREADWRITE("deco_custom", deco16ic_pf1_data_r, deco16ic_pf1_data_w)
59   AM_RANGE(0x282000, 0x283fff) AM_DEVREADWRITE("deco_custom", deco16ic_pf2_data_r, deco16ic_pf2_data_w)
60   AM_RANGE(0x2c0000, 0x2c000f) AM_DEVWRITE("deco_custom", deco16ic_pf12_control_w)
6561   AM_RANGE(0x300000, 0x3009ff) AM_RAM_WRITE(vaportra_palette_24bit_rg_w) AM_BASE_GENERIC(paletteram)
6662   AM_RANGE(0x304000, 0x3049ff) AM_RAM_WRITE(vaportra_palette_24bit_b_w) AM_BASE_GENERIC(paletteram2)
6763   AM_RANGE(0x308000, 0x308001) AM_NOP
r7500r7501
7571
7672static READ8_HANDLER( vaportra_soundlatch_r )
7773{
78   cputag_set_input_line(space->machine, "audiocpu", 0, CLEAR_LINE);
74   vaportra_state *state = (vaportra_state *)space->machine->driver_data;
75   cpu_set_input_line(state->audiocpu, 0, CLEAR_LINE);
7976   return soundlatch_r(space, offset);
8077}
8178
r7500r7501
193190   32*16
194191};
195192
196
197
198193static GFXDECODE_START( vaportra )
199194   GFXDECODE_ENTRY( "gfx1", 0x000000, charlayout,    0x000, 0x500 )   /* Characters 8x8 */
200195   GFXDECODE_ENTRY( "gfx1", 0x000000, tilelayout,    0x000, 0x500 )   /* Tiles 16x16 */
r7500r7501
204199
205200/******************************************************************************/
206201
207static void sound_irq(running_device *device, int state)
202static void sound_irq( running_device *device, int state )
208203{
209   cputag_set_input_line(device->machine, "audiocpu", 1, state); /* IRQ 2 */
204   vaportra_state *driver_state = (vaportra_state *)device->machine->driver_data;
205   cpu_set_input_line(driver_state->audiocpu, 1, state); /* IRQ 2 */
210206}
211207
212208static const ym2151_interface ym2151_config =
r7500r7501
215211};
216212
217213
214static int vaportra_bank_callback( const int bank )
215{
216   return ((bank >> 4) & 0x7) * 0x1000;
217}
218218
219static const deco16ic_interface vaportra_deco16ic_intf =
220{
221   "screen",
222   0, 0, 1,
223   0x0f, 0x0f, 0x0f, 0x0f,   /* trans masks (default values) */
224   0x00, 0x20, 0x30, 0x40, /* color base */
225   0x0f, 0x0f, 0x0f, 0x0f,   /* color masks (default values) */
226   vaportra_bank_callback,
227   vaportra_bank_callback,
228   vaportra_bank_callback,
229   vaportra_bank_callback
230};
231
232
233static MACHINE_START( vaportra )
234{
235   vaportra_state *state = (vaportra_state *)machine->driver_data;
236
237   state->maincpu = devtag_get_device(machine, "maincpu");
238   state->audiocpu = devtag_get_device(machine, "audiocpu");
239   state->deco16ic = devtag_get_device(machine, "deco_custom");
240
241   state_save_register_global_array(machine, state->priority);
242}
243
244static MACHINE_RESET( vaportra )
245{
246   vaportra_state *state = (vaportra_state *)machine->driver_data;
247
248   state->priority[0] = 0;
249   state->priority[1] = 0;
250}
251
219252static MACHINE_DRIVER_START( vaportra )
220253
254   /* driver data */
255   MDRV_DRIVER_DATA(vaportra_state)
256
221257   /* basic machine hardware */
222258   MDRV_CPU_ADD("maincpu", M68000,12000000) /* Custom chip 59 */
223259   MDRV_CPU_PROGRAM_MAP(main_map)
r7500r7501
226262   MDRV_CPU_ADD("audiocpu", H6280, 32220000/4) /* Custom chip 45; Audio section crystal is 32.220 MHz */
227263   MDRV_CPU_PROGRAM_MAP(sound_map)
228264
265   MDRV_MACHINE_START(vaportra)
266   MDRV_MACHINE_RESET(vaportra)
267
229268   /* video hardware */
230269   MDRV_VIDEO_ATTRIBUTES(VIDEO_BUFFERS_SPRITERAM)
231270
r7500r7501
238277   MDRV_GFXDECODE(vaportra)
239278   MDRV_PALETTE_LENGTH(1280)
240279
241   MDRV_VIDEO_START(vaportra)
242280   MDRV_VIDEO_UPDATE(vaportra)
243281
282   MDRV_DECO16IC_ADD("deco_custom", vaportra_deco16ic_intf)
283
244284   /* sound hardware */
245285   MDRV_SPEAKER_STANDARD_MONO("mono")
246286
r7500r7501
766806   UINT8 *RAM = memory_region(machine, "maincpu");
767807   int i;
768808
769   for (i=0x00000; i<0x80000; i++)
770      RAM[i]=(RAM[i] & 0x7e) | ((RAM[i] & 0x01) << 7) | ((RAM[i] & 0x80) >> 7);
809   for (i = 0x00000; i < 0x80000; i++)
810      RAM[i] = (RAM[i] & 0x7e) | ((RAM[i] & 0x01) << 7) | ((RAM[i] & 0x80) >> 7);
771811}
772812
773813/******************************************************************************/
774814
775GAME( 1989, vaportra, 0,        vaportra, vaportra, vaportra, ROT270, "Data East Corporation", "Vapor Trail - Hyper Offence Formation (World revision 1)", 0 )
776GAME( 1989, vaportrau,vaportra, vaportra, vaportra, vaportra, ROT270, "Data East USA", "Vapor Trail - Hyper Offence Formation (US)", 0 )
777GAME( 1989, kuhga,    vaportra, vaportra, vaportra, vaportra, ROT270, "Data East Corporation", "Kuhga - Operation Code 'Vapor Trail' (Japan revision 3)", 0 )
815GAME( 1989, vaportra, 0,        vaportra, vaportra, vaportra, ROT270, "Data East Corporation", "Vapor Trail - Hyper Offence Formation (World revision 1)", GAME_SUPPORTS_SAVE )
816GAME( 1989, vaportrau,vaportra, vaportra, vaportra, vaportra, ROT270, "Data East USA", "Vapor Trail - Hyper Offence Formation (US)", GAME_SUPPORTS_SAVE )
817GAME( 1989, kuhga,    vaportra, vaportra, vaportra, vaportra, ROT270, "Data East Corporation", "Kuhga - Operation Code 'Vapor Trail' (Japan revision 3)", GAME_SUPPORTS_SAVE )
src/mame/drivers/suna8.c
r7500r7501
14681468static MACHINE_DRIVER_START( hardhead )
14691469
14701470   /* basic machine hardware */
1471   MDRV_CPU_ADD("maincpu", Z80, SUNA8_MASTER_CLOCK / 4)         /* ? */
1471   MDRV_CPU_ADD("maincpu", Z80, SUNA8_MASTER_CLOCK / 4)   /* verified on pcb */
14721472   MDRV_CPU_PROGRAM_MAP(hardhead_map)
14731473   MDRV_CPU_IO_MAP(hardhead_io_map)
1474   MDRV_CPU_VBLANK_INT("screen", irq0_line_hold)   /* No NMI */
1474   MDRV_CPU_VBLANK_INT("screen", irq0_line_hold)      /* No NMI */
14751475
1476   MDRV_CPU_ADD("audiocpu", Z80, SUNA8_MASTER_CLOCK / 4)               /* ? */
1476   MDRV_CPU_ADD("audiocpu", Z80, SUNA8_MASTER_CLOCK / 8)   /* verified on pcb */
14771477   MDRV_CPU_PROGRAM_MAP(hardhead_sound_map)
14781478   MDRV_CPU_IO_MAP(hardhead_sound_io_map)
1479   MDRV_CPU_VBLANK_INT_HACK(irq0_line_hold,4)   /* No NMI */
1479   MDRV_CPU_VBLANK_INT_HACK(irq0_line_hold,4)      /* No NMI */
14801480
14811481   /* video hardware */
14821482   MDRV_SCREEN_ADD("screen", RASTER)
1483   MDRV_SCREEN_REFRESH_RATE(60)
1483   MDRV_SCREEN_REFRESH_RATE(59.10)  /* verified on pcb */
14841484   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(0))
14851485   MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16)
14861486   MDRV_SCREEN_SIZE(256, 256)
r7500r7501
14951495   /* sound hardware */
14961496   MDRV_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker")
14971497
1498   MDRV_SOUND_ADD("ymsnd", YM3812, SUNA8_MASTER_CLOCK / 8)
1498   MDRV_SOUND_ADD("ymsnd", YM3812, SUNA8_MASTER_CLOCK / 8)      /* verified on pcb */
14991499   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 1.0)
15001500   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 1.0)
15011501
1502   MDRV_SOUND_ADD("aysnd", AY8910, SUNA8_MASTER_CLOCK / 16)
1502   MDRV_SOUND_ADD("aysnd", AY8910, SUNA8_MASTER_CLOCK / 16)   /* verified on pcb */
15031503   MDRV_SOUND_CONFIG(hardhead_ay8910_interface)
15041504   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 0.30)
15051505   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 0.30)
src/mame/drivers/chanbara.c
r7500r7501
5151#include "sound/2203intf.h"
5252
5353
54typedef struct _chanbara_state chanbara_state;
55struct _chanbara_state
54class chanbara_state
5655{
56public:
57   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, chanbara_state(machine)); }
58
59   chanbara_state(running_machine &machine) { }
60
5761   /* memory pointers */
5862   UINT8 *  videoram;
5963   UINT8 *  videoram2;
src/mame/drivers/m14.c
r7500r7501
5454#include "cpu/i8085/i8085.h"
5555
5656
57typedef struct _m14_state m14_state;
58struct _m14_state
57class m14_state
5958{
59public:
60   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, m14_state(machine)); }
61
62   m14_state(running_machine &machine) { }
63
6064   /* video-related */
6165   tilemap_t  *m14_tilemap;
6266   UINT8 *  video_ram;
src/mame/drivers/jantotsu.c
r7500r7501
9999#include "sound/sn76496.h"
100100#include "sound/msm5205.h"
101101
102typedef struct _jantotsu_state jantotsu_state;
103struct _jantotsu_state
102class jantotsu_state
104103{
104public:
105   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, jantotsu_state(machine)); }
106
107   jantotsu_state(running_machine &machine) { }
108
105109   /* video-related */
106110   UINT8    *bitmap;
107111   UINT8    vram_bank, col_bank;
src/mame/drivers/chsuper.c
r7500r7501
3333      {
3434         int tile = ((vram[count+1]<<8) | vram[count]) & 0xffff;
3535
36         tile ^=chsuper_tilexor;
37         //int colour = tile>>12;
36         //tile ^=chsuper_tilexor;
3837
3938         drawgfx_opaque(bitmap,cliprect,gfx,tile,0,0,0,x*4,y*8);
4039         count+=2;
r7500r7501
187186};
188187
189188static GFXDECODE_START( chsuper )
190   GFXDECODE_ENTRY( "gfx1", 0x00000, charlayout,   0, 16 )
189   GFXDECODE_ENTRY( "gfx1", 0x00000, charlayout,   0, 1 )
191190GFXDECODE_END
192191
193192static MACHINE_DRIVER_START( chsuper )
r7500r7501
253252   ROM_COPY( "maincpu", 0x10000, 0x00000, 0x70000 )
254253ROM_END
255254
255ROM_START( chmpnum )
256   ROM_REGION( 0x80000, "maincpu", 0 ) // code + samples
257   ROM_LOAD( "3.ic11", 0x00000, 0x80000, CRC(46aa2ce7) SHA1(036d67a26c890c4dc26599bfcd2c67f12e30fb52) )
258
259   ROM_REGION( 0x010000, "vram", ROMREGION_ERASE00 )
260
261   ROM_REGION( 0x100000, "gfx1", 0 )
262   ROM_LOAD( "1.ic18", 0x00000, 0x80000, CRC(8e202eaa) SHA1(156b498873111e5890c00d447201ba4bcbe6e633) )
263   ROM_LOAD( "2.ic19", 0x80000, 0x80000, CRC(dc0790b0) SHA1(4550f85e609338635a3987f7832517ed1d6388d4) )
264
265   ROM_REGION( 0x80000, "adpcm", 0 )
266   ROM_COPY( "maincpu", 0x10000, 0x00000, 0x70000 )
267ROM_END
268
256269static DRIVER_INIT( chsuper2 )
257270{
271   UINT8 *buffer;
272   UINT8 *rom = memory_region(machine,"gfx1");
273   int i;
274
258275   chsuper_tilexor = 0x7f00;
276
277   buffer = auto_alloc_array(machine, UINT8, 0x100000);
278
279   for (i=0;i<0x100000;i++)
280   {
281      int j;
282
283      j = i ^ (chsuper_tilexor << 5);
284
285      buffer[j] = rom[i];
286   }
287
288   memcpy(rom,buffer,0x100000);
289
290   chsuper_tilexor = 0x0000;
259291}
260292
261293static DRIVER_INIT( chsuper3 )
262294{
295   UINT8 *buffer;
296   UINT8 *rom = memory_region(machine,"gfx1");
297   int i;
298
263299   chsuper_tilexor = 0x0e00;
300
301   buffer = auto_alloc_array(machine, UINT8, 0x100000);
302
303   for (i=0;i<0x100000;i++)
304   {
305      int j;
306
307      j = i ^ (chsuper_tilexor << 5);
308
309      buffer[j] = rom[i];
310   }
311
312   memcpy(rom,buffer,0x100000);
313
314   chsuper_tilexor = 0x0000;
264315}
265316
317static DRIVER_INIT( chmpnum )
318{
319   UINT8 *buffer;
320   UINT8 *rom = memory_region(machine,"gfx1");
321   int i;
266322
267GAME( 1999, chsuper3, 0,        chsuper, chsuper,  chsuper3, ROT0, "<unknown>",    "Champion Super 3 (V0.35)", GAME_NO_SOUND ) //24/02/99
268GAME( 1999, chsuper2, chsuper3, chsuper, chsuper,  chsuper2, ROT0, "<unknown>",    "Champion Super 2 (V0.13)", GAME_NO_SOUND ) //26/01/99
323   chsuper_tilexor = 0x1800;
324
325   buffer = auto_alloc_array(machine, UINT8, 0x100000);
326
327   for (i=0;i<0x100000;i++)
328   {
329      int j;
330
331      j = i ^ (chsuper_tilexor << 5);
332
333      j = BITSWAP24(j,23,22,21,20,19,18,17,13, 15,14,16,12, 11,10,9,8, 7,6,5,4, 3,2,1,0);
334      j = BITSWAP24(j,23,22,21,20,19,18,17,14, 15,16,13,12, 11,10,9,8, 7,6,5,4, 3,2,1,0);
335      j = BITSWAP24(j,23,22,21,20,19,18,17,15, 16,14,13,12, 11,10,9,8, 7,6,5,4, 3,2,1,0);
336
337      buffer[j] = rom[i];
338   }
339
340   memcpy(rom,buffer,0x100000);
341
342   chsuper_tilexor = 0x0000;
343}
344
345
346GAME( 1999, chsuper3, 0,        chsuper, chsuper,  chsuper3, ROT0, "<unknown>",    "Champion Super 3 (V0.35)", GAME_IMPERFECT_SOUND ) //24/02/99
347GAME( 1999, chsuper2, chsuper3, chsuper, chsuper,  chsuper2, ROT0, "<unknown>",    "Champion Super 2 (V0.13)", GAME_IMPERFECT_SOUND ) //26/01/99
348GAME( 1999, chmpnum,  chsuper3, chsuper, chsuper,  chmpnum,  ROT0, "<unknown>",    "Champion Number (V0.74)",  GAME_IMPERFECT_SOUND ) //10/11/99
src/mame/drivers/mermaid.c
r7500r7501
116116#include "emu.h"
117117#include "cpu/z80/z80.h"
118118#include "sound/ay8910.h"
119#include "includes/mermaid.h"
119120
120extern UINT8* mermaid_videoram;
121extern UINT8* mermaid_colorram;
122extern UINT8* mermaid_videoram2;
123extern UINT8* mermaid_bg_scrollram;
124extern UINT8* mermaid_fg_scrollram;
125
126WRITE8_HANDLER( mermaid_videoram2_w );
127WRITE8_HANDLER( mermaid_videoram_w );
128WRITE8_HANDLER( mermaid_colorram_w );
129WRITE8_HANDLER( mermaid_flip_screen_x_w );
130WRITE8_HANDLER( mermaid_flip_screen_y_w );
131WRITE8_HANDLER( mermaid_bg_scroll_w );
132WRITE8_HANDLER( mermaid_fg_scroll_w );
133WRITE8_HANDLER( rougien_gfxbankswitch1_w );
134WRITE8_HANDLER( rougien_gfxbankswitch2_w );
135READ8_HANDLER( mermaid_collision_r );
136
137PALETTE_INIT( mermaid );
138VIDEO_START( mermaid );
139VIDEO_UPDATE( mermaid );
140VIDEO_EOF( mermaid );
141
142
143121/* Read/Write Handlers */
144122
145static UINT8 *mermaid_ay8910_enable;
146
147123static WRITE8_HANDLER( mermaid_ay8910_write_port_w )
148124{
149   if (mermaid_ay8910_enable[0]) ay8910_data_w(devtag_get_device(space->machine, "ay1"), offset, data);
150   if (mermaid_ay8910_enable[1]) ay8910_data_w(devtag_get_device(space->machine, "ay2"), offset, data);
125   mermaid_state *state = (mermaid_state *)space->machine->driver_data;
126   if (state->ay8910_enable[0]) ay8910_data_w(state->ay1, offset, data);
127   if (state->ay8910_enable[1]) ay8910_data_w(state->ay2, offset, data);
151128}
152129
153130static WRITE8_HANDLER( mermaid_ay8910_control_port_w )
154131{
155   if (mermaid_ay8910_enable[0]) ay8910_address_w(devtag_get_device(space->machine, "ay1"), offset, data);
156   if (mermaid_ay8910_enable[1]) ay8910_address_w(devtag_get_device(space->machine, "ay2"), offset, data);
132   mermaid_state *state = (mermaid_state *)space->machine->driver_data;
133   if (state->ay8910_enable[0]) ay8910_address_w(state->ay1, offset, data);
134   if (state->ay8910_enable[1]) ay8910_address_w(state->ay2, offset, data);
157135}
158136
159137
r7500r7501
162140static ADDRESS_MAP_START( mermaid_map, ADDRESS_SPACE_PROGRAM, 8 )
163141   AM_RANGE(0x0000, 0x9fff) AM_ROM
164142   AM_RANGE(0xc000, 0xc7ff) AM_RAM
165   AM_RANGE(0xc800, 0xcbff) AM_RAM_WRITE(mermaid_videoram2_w) AM_BASE(&mermaid_videoram2)
166   AM_RANGE(0xd000, 0xd3ff) AM_RAM_WRITE(mermaid_videoram_w) AM_BASE(&mermaid_videoram)
167   AM_RANGE(0xd800, 0xd81f) AM_RAM_WRITE(mermaid_bg_scroll_w) AM_BASE(&mermaid_bg_scrollram)
168   AM_RANGE(0xd840, 0xd85f) AM_RAM_WRITE(mermaid_fg_scroll_w) AM_BASE(&mermaid_fg_scrollram)
169   AM_RANGE(0xd880, 0xd8bf) AM_RAM AM_BASE_SIZE_GENERIC(spriteram)
170   AM_RANGE(0xdc00, 0xdfff) AM_RAM_WRITE(mermaid_colorram_w) AM_BASE(&mermaid_colorram)
143   AM_RANGE(0xc800, 0xcbff) AM_RAM_WRITE(mermaid_videoram2_w) AM_BASE_MEMBER(mermaid_state, videoram2)
144   AM_RANGE(0xd000, 0xd3ff) AM_RAM_WRITE(mermaid_videoram_w) AM_BASE_MEMBER(mermaid_state, videoram)
145   AM_RANGE(0xd800, 0xd81f) AM_RAM_WRITE(mermaid_bg_scroll_w) AM_BASE_MEMBER(mermaid_state, bg_scrollram)
146   AM_RANGE(0xd840, 0xd85f) AM_RAM_WRITE(mermaid_fg_scroll_w) AM_BASE_MEMBER(mermaid_state, fg_scrollram)
147   AM_RANGE(0xd880, 0xd8bf) AM_RAM AM_BASE_SIZE_MEMBER(mermaid_state, spriteram, spriteram_size)
148   AM_RANGE(0xdc00, 0xdfff) AM_RAM_WRITE(mermaid_colorram_w) AM_BASE_MEMBER(mermaid_state, colorram)
171149   AM_RANGE(0xe000, 0xe000) AM_READ_PORT("DSW")
172   AM_RANGE(0xe000, 0xe001) AM_RAM AM_BASE(&mermaid_ay8910_enable)
150   AM_RANGE(0xe000, 0xe001) AM_RAM AM_BASE_MEMBER(mermaid_state, ay8910_enable)
173151   AM_RANGE(0xe002, 0xe002) AM_WRITENOP   // ???
174152   AM_RANGE(0xe003, 0xe003) AM_WRITENOP   // ???
175153   AM_RANGE(0xe004, 0xe004) AM_WRITENOP   // ???
r7500r7501
348326
349327/* Machine Driver */
350328
329static MACHINE_START( mermaid )
330{
331   mermaid_state *state = (mermaid_state *)machine->driver_data;
332
333   state->maincpu = devtag_get_device(machine, "maincpu");
334   state->ay1 = devtag_get_device(machine, "ay1");
335   state->ay2 = devtag_get_device(machine, "ay2");
336
337   state_save_register_global(machine, state->coll_bit0);
338   state_save_register_global(machine, state->coll_bit1);
339   state_save_register_global(machine, state->coll_bit2);
340   state_save_register_global(machine, state->coll_bit3);
341   state_save_register_global(machine, state->coll_bit6);
342   state_save_register_global(machine, state->rougien_gfxbank1);
343   state_save_register_global(machine, state->rougien_gfxbank2);
344}
345
346static MACHINE_RESET( mermaid )
347{
348   mermaid_state *state = (mermaid_state *)machine->driver_data;
349
350   state->coll_bit0 = 0;
351   state->coll_bit1 = 0;
352   state->coll_bit2 = 0;
353   state->coll_bit3 = 0;
354   state->coll_bit6 = 0;
355   state->rougien_gfxbank1 = 0;
356   state->rougien_gfxbank2 = 0;
357}
358
351359static MACHINE_DRIVER_START( mermaid )
352   // basic machine hardware
360
361   /* driver data */
362   MDRV_DRIVER_DATA(mermaid_state)
363
364   /* basic machine hardware */
353365   MDRV_CPU_ADD("maincpu", Z80, 4000000)   // ???
354366   MDRV_CPU_PROGRAM_MAP(mermaid_map)
355367   MDRV_CPU_VBLANK_INT("screen", nmi_line_pulse)
356368
357   // video hardware
369   MDRV_MACHINE_START(mermaid)
370   MDRV_MACHINE_RESET(mermaid)
358371
372   /* video hardware */
359373   MDRV_SCREEN_ADD("screen", RASTER)
360374   MDRV_SCREEN_REFRESH_RATE(60)
361375   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(2500) /* not accurate */)
r7500r7501
371385   MDRV_VIDEO_UPDATE(mermaid)
372386   MDRV_VIDEO_EOF(mermaid)
373387
374   // sound hardware
388   /* sound hardware */
375389   MDRV_SPEAKER_STANDARD_MONO("mono")
376390
377391   MDRV_SOUND_ADD("ay1", AY8910, 1500000)
r7500r7501
486500
487501/* Game Drivers */
488502
489GAME( 1982, mermaid,  0,        mermaid,  mermaid,  0, ROT0, "[Sanritsu] Rock-Ola", "Mermaid", 0 )
490GAME( 1982, yachtmn,  mermaid,  mermaid,  yachtmn,  0, ROT0, "[Sanritsu] Esco", "Yachtsman", 0 )
491GAME( 1982, rougien,  0,        mermaid,  rougien,  0, ROT0, "Sanritsu", "Rougien", 0 )
503GAME( 1982, mermaid,  0,        mermaid,  mermaid,  0, ROT0, "[Sanritsu] Rock-Ola", "Mermaid", GAME_SUPPORTS_SAVE )
504GAME( 1982, yachtmn,  mermaid,  mermaid,  yachtmn,  0, ROT0, "[Sanritsu] Esco", "Yachtsman", GAME_SUPPORTS_SAVE )
505GAME( 1982, rougien,  0,        mermaid,  rougien,  0, ROT0, "Sanritsu", "Rougien", GAME_SUPPORTS_SAVE )
src/mame/drivers/othello.c
r7500r7501
3737
3838#include "emu.h"
3939#include "cpu/z80/z80.h"
40#include "cpu/mcs48/mcs48.h"
41#include "machine/i8243.h"
42#include "sound/dac.h"
4043#include "sound/ay8910.h"
4144#include "video/mc6845.h"
42#include "machine/i8243.h"
43#include "cpu/mcs48/mcs48.h"
44#include "sound/dac.h"
4545
46static int   ay_select=0;
47static int   ack_data=0;
4846
49static UINT8 n7751_command;
50//static UINT32 n7751_rom_address;
47#define   TILE_WIDTH 6
5148
52static int tile_bank=0;
5349
54static int sound_addr;
55static int n7751_busy;
50class othello_state
51{
52public:
53   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, othello_state(machine)); }
5654
57#define   TILE_WIDTH 6
55   othello_state(running_machine &machine) { }
5856
57   /* memory pointers */
58   UINT8 *  videoram;
59
60   /* video-related */
61   int    tile_bank;
62
63   /* misc */
64   int   ay_select;
65   int   ack_data;
66   UINT8 n7751_command;
67//  UINT32 n7751_rom_address;
68   int sound_addr;
69   int n7751_busy;
70
71   /* devices */
72   running_device *maincpu;
73   running_device *mc6845;
74   running_device *n7751;
75   running_device *ay1;
76   running_device *ay2;
77};
78
79
5980static MC6845_UPDATE_ROW( update_row )
6081{
61   int cx,x;
82   othello_state *state = (othello_state *)device->machine->driver_data;
83   int cx, x;
6284   UINT32 data_address;
6385   UINT32 tmp;
6486
6587   const UINT8 *gfx = memory_region(device->machine, "gfx");
6688
67   for(cx=0;cx<x_count;++cx)
89   for(cx = 0; cx < x_count; ++cx)
6890   {
69      data_address=((device->machine->generic.videoram.u8[ma+cx]+tile_bank)<<4)|ra;
70      tmp=gfx[data_address]|(gfx[data_address+0x2000]<<8)|(gfx[data_address+0x4000]<<16);
91      data_address = ((state->videoram[ma + cx] + state->tile_bank) << 4) | ra;
92      tmp = gfx[data_address] | (gfx[data_address + 0x2000] << 8) | (gfx[data_address + 0x4000] << 16);
7193
72      for(x=0;x<TILE_WIDTH;++x)
94      for(x = 0; x < TILE_WIDTH; ++x)
7395      {
74         *BITMAP_ADDR16(bitmap, y, (cx*TILE_WIDTH+x)^1) = tmp&0x0f;
75         tmp>>=4;
96         *BITMAP_ADDR16(bitmap, y, (cx * TILE_WIDTH + x) ^ 1) = tmp & 0x0f;
97         tmp >>= 4;
7698      }
7799   }
78100}
r7500r7501
80102static PALETTE_INIT( othello )
81103{
82104   int i;
83   for (i = 0;i < machine->config->total_colors;i++)
84    {
85        palette_set_color(machine,i,MAKE_RGB(0xff,0x00,0xff));
86    }
105   for (i = 0; i < machine->config->total_colors; i++)
106   {
107      palette_set_color(machine, i, MAKE_RGB(0xff, 0x00, 0xff));
108   }
87109
88    /* only colors  2,3,7,9,c,d,f are used */
89    palette_set_color(machine,0x02,MAKE_RGB(0x00,0xff,0x00));
90    palette_set_color(machine,0x03,MAKE_RGB(0xff,0x7f,0x00));
91    palette_set_color(machine,0x07,MAKE_RGB(0x00,0x00,0x00));
92    palette_set_color(machine,0x09,MAKE_RGB(0xff,0x00,0x00));
93    palette_set_color(machine,0x0c,MAKE_RGB(0x00,0x00,0xff));
94    palette_set_color(machine,0x0d,MAKE_RGB(0x7f,0x7f,0x00));
95    palette_set_color(machine,0x0f,MAKE_RGB(0xff,0xff,0xff));
110   /* only colors  2,3,7,9,c,d,f are used */
111   palette_set_color(machine, 0x02, MAKE_RGB(0x00, 0xff, 0x00));
112   palette_set_color(machine, 0x03, MAKE_RGB(0xff, 0x7f, 0x00));
113   palette_set_color(machine, 0x07, MAKE_RGB(0x00, 0x00, 0x00));
114   palette_set_color(machine, 0x09, MAKE_RGB(0xff, 0x00, 0x00));
115   palette_set_color(machine, 0x0c, MAKE_RGB(0x00, 0x00, 0xff));
116   palette_set_color(machine, 0x0d, MAKE_RGB(0x7f, 0x7f, 0x00));
117   palette_set_color(machine, 0x0f, MAKE_RGB(0xff, 0xff, 0xff));
96118}
97119
98120static VIDEO_UPDATE( othello )
99121{
100   running_device *mc6845 = devtag_get_device(screen->machine, "crtc");
101   mc6845_update(mc6845, bitmap, cliprect);
122   othello_state *state = (othello_state *)screen->machine->driver_data;
123
124   mc6845_update(state->mc6845, bitmap, cliprect);
102125   return 0;
103126}
104127
105128static ADDRESS_MAP_START( main_map, ADDRESS_SPACE_PROGRAM, 8 )
106129   AM_RANGE(0x0000, 0x1fff) AM_ROM
107130   AM_RANGE(0x8000, 0x97ff) AM_NOP /* not populated */
108   AM_RANGE(0x9800, 0x9fff) AM_RAM AM_BASE_GENERIC(videoram)
131   AM_RANGE(0x9800, 0x9fff) AM_RAM AM_BASE_MEMBER(othello_state, videoram)
109132   AM_RANGE(0xf000, 0xffff) AM_RAM
110133ADDRESS_MAP_END
111134
r7500r7501
115138   return mame_rand(space->machine);
116139}
117140
118static WRITE8_HANDLER(unk_8a_w)
141static WRITE8_HANDLER( unk_8a_w )
119142{
120143   /*
121    n7751_command = (data & 0x07);
122    cputag_set_input_line(space->machine, "n7751", 0, ((data & 0x08) == 0) ? ASSERT_LINE : CLEAR_LINE);
123    //cputag_set_input_line(device->machine, "n7751", 0, (data & 0x02) ? CLEAR_LINE : ASSERT_LINE);
144    othello_state *state = (othello_state *)space->machine->driver_data;
145
146    state->n7751_command = (data & 0x07);
147    cpu_set_input_line(state->n7751, 0, ((data & 0x08) == 0) ? ASSERT_LINE : CLEAR_LINE);
148    //cpu_set_input_line(state->n7751, 0, (data & 0x02) ? CLEAR_LINE : ASSERT_LINE);
124149    cpuexec_boost_interleave(space->machine, attotime_zero, ATTOTIME_IN_USEC(100));
125150    */
126151
127   logerror("8a -> %x\n",data);
152   logerror("8a -> %x\n", data);
128153}
129154
130static WRITE8_HANDLER(unk_8c_w)
155static WRITE8_HANDLER( unk_8c_w )
131156{
132   logerror("8c -> %x\n",data);
157   logerror("8c -> %x\n", data);
133158}
134159
135160static READ8_HANDLER( unk_8c_r )
r7500r7501
137162   return mame_rand(space->machine);
138163}
139164
140static READ8_HANDLER(sound_ack_r)
165static READ8_HANDLER( sound_ack_r )
141166{
142   return ack_data;
167   othello_state *state = (othello_state *)space->machine->driver_data;
168   return state->ack_data;
143169}
144170
145static WRITE8_HANDLER(unk_8f_w)
171static WRITE8_HANDLER( unk_8f_w )
146172{
147   logerror("8f -> %x\n",data);
173   logerror("8f -> %x\n", data);
148174}
149175
150static WRITE8_HANDLER(tilebank_w)
176static WRITE8_HANDLER( tilebank_w )
151177{
152   tile_bank=data==0x0f?0x100:0x00;
153   logerror("tilebank -> %x\n",data);
178   othello_state *state = (othello_state *)space->machine->driver_data;
179   state->tile_bank = (data == 0x0f) ? 0x100 : 0x00;
180   logerror("tilebank -> %x\n", data);
154181}
155182
156183static ADDRESS_MAP_START( main_portmap, ADDRESS_SPACE_IO, 8 )
r7500r7501
168195   AM_RANGE(0x8f, 0x8f) AM_WRITE(unk_8f_w)
169196ADDRESS_MAP_END
170197
171static READ8_HANDLER(latch_r)
198static READ8_HANDLER( latch_r )
172199{
173   int retval=soundlatch_r(space,0);
174   soundlatch_clear_w(space,0,0);
200   int retval = soundlatch_r(space, 0);
201   soundlatch_clear_w(space, 0, 0);
175202   return retval;
176203}
177204
178static WRITE8_HANDLER(ay_select_w)
205static WRITE8_HANDLER( ay_select_w )
179206{
180   ay_select=data;
207   othello_state *state = (othello_state *)space->machine->driver_data;
208   state->ay_select = data;
181209}
182210
183static WRITE8_HANDLER(ack_w)
211static WRITE8_HANDLER( ack_w )
184212{
185   ack_data=data;
213   othello_state *state = (othello_state *)space->machine->driver_data;
214   state->ack_data = data;
186215}
187216
188static WRITE8_HANDLER(ay_address_w)
217static WRITE8_HANDLER( ay_address_w )
189218{
190   if(ay_select&1) ay8910_address_w(devtag_get_device(space->machine, "ay1"),0,data);
191   if(ay_select&2) ay8910_address_w(devtag_get_device(space->machine, "ay2"),0,data);
219   othello_state *state = (othello_state *)space->machine->driver_data;
220
221   if (state->ay_select & 1) ay8910_address_w(state->ay1, 0, data);
222   if (state->ay_select & 2) ay8910_address_w(state->ay2, 0, data);
192223}
193224
194static WRITE8_HANDLER(ay_data_w)
225static WRITE8_HANDLER( ay_data_w )
195226{
196   if(ay_select&1) ay8910_data_w(devtag_get_device(space->machine, "ay1"),0,data);
197   if(ay_select&2) ay8910_data_w(devtag_get_device(space->machine, "ay2"),0,data);
227   othello_state *state = (othello_state *)space->machine->driver_data;
198228
229   if (state->ay_select & 1) ay8910_data_w(state->ay1, 0, data);
230   if (state->ay_select & 2) ay8910_data_w(state->ay2, 0, data);
199231}
200232
201233static ADDRESS_MAP_START( audio_map, ADDRESS_SPACE_PROGRAM, 8 )
r7500r7501
214246
215247static WRITE8_DEVICE_HANDLER( n7751_rom_control_w )
216248{
249   othello_state *state = (othello_state *)device->machine->driver_data;
250
217251   /* P4 - address lines 0-3 */
218252   /* P5 - address lines 4-7 */
219253   /* P6 - address lines 8-11 */
r7500r7501
221255   switch (offset)
222256   {
223257      case 0:
224         sound_addr = (sound_addr & ~0x00f) | ((data & 0x0f) << 0);
258         state->sound_addr = (state->sound_addr & ~0x00f) | ((data & 0x0f) << 0);
225259         break;
226260
227261      case 1:
228         sound_addr = (sound_addr & ~0x0f0) | ((data & 0x0f) << 4);
262         state->sound_addr = (state->sound_addr & ~0x0f0) | ((data & 0x0f) << 4);
229263         break;
230264
231265      case 2:
232         sound_addr = (sound_addr & ~0xf00) | ((data & 0x0f) << 8);
266         state->sound_addr = (state->sound_addr & ~0xf00) | ((data & 0x0f) << 8);
233267         break;
234268
235269      case 3:
236         sound_addr &= 0xfff;
270         state->sound_addr &= 0xfff;
237271         {
238272
239            if (!(data & 0x01) ) sound_addr |= 0x0000;
240            if (!(data & 0x02) ) sound_addr |= 0x1000;
241            if (!(data & 0x04) ) sound_addr |= 0x2000;
242            if (!(data & 0x08) ) sound_addr |= 0x3000;
273            if (!BIT(data, 0)) state->sound_addr |= 0x0000;
274            if (!BIT(data, 1)) state->sound_addr |= 0x1000;
275            if (!BIT(data, 2)) state->sound_addr |= 0x2000;
276            if (!BIT(data, 3)) state->sound_addr |= 0x3000;
243277         }
244278         break;
245279   }
r7500r7501
247281
248282static READ8_HANDLER( n7751_rom_r )
249283{
250   return memory_region(space->machine, "n7751data")[sound_addr];
284   othello_state *state = (othello_state *)space->machine->driver_data;
285   return memory_region(space->machine, "n7751data")[state->sound_addr];
251286}
252287
253288static READ8_HANDLER( n7751_command_r )
254289{
255   return 0x80 | ((n7751_command & 0x07) << 4);
290   othello_state *state = (othello_state *)space->machine->driver_data;
291   return 0x80 | ((state->n7751_command & 0x07) << 4);
256292}
257293
258294static WRITE8_DEVICE_HANDLER( n7751_p2_w )
259295{
296   othello_state *state = (othello_state *)device->machine->driver_data;
297
260298   /* write to P2; low 4 bits go to 8243 */
261299   i8243_p2_w(device, offset, data & 0x0f);
262300
263301   /* output of bit $80 indicates we are ready (1) or busy (0) */
264302   /* no other outputs are used */
265   n7751_busy = data;
303   state->n7751_busy = data;
266304}
267305
268306static READ8_HANDLER( n7751_t1_r )
r7500r7501
340378   NULL      /* update address callback */
341379};
342380
381
382static MACHINE_START( othello )
383{
384   othello_state *state = (othello_state *)machine->driver_data;
385
386   state->maincpu = devtag_get_device(machine, "maincpu");
387   state->mc6845 = devtag_get_device(machine, "crtc");
388   state->n7751 = devtag_get_device(machine, "n7751");
389   state->ay1 = devtag_get_device(machine, "ay1");
390   state->ay2 = devtag_get_device(machine, "ay2");
391
392   state_save_register_global(machine, state->tile_bank);
393   state_save_register_global(machine, state->ay_select);
394   state_save_register_global(machine, state->ack_data);
395   state_save_register_global(machine, state->n7751_command);
396   state_save_register_global(machine, state->sound_addr);
397   state_save_register_global(machine, state->n7751_busy);
398}
399
400static MACHINE_RESET( othello )
401{
402   othello_state *state = (othello_state *)machine->driver_data;
403
404   state->tile_bank = 0;
405   state->ay_select = 0;
406   state->ack_data = 0;
407   state->n7751_command = 0;
408   state->sound_addr = 0;
409   state->n7751_busy = 0;
410}
411
343412static MACHINE_DRIVER_START( othello )
344413
414   /* driver data */
415   MDRV_DRIVER_DATA(othello_state)
416
345417   /* basic machine hardware */
346418   MDRV_CPU_ADD("maincpu",Z80,XTAL_8MHz/2)
347419   MDRV_CPU_PROGRAM_MAP(main_map)
r7500r7501
357429
358430   MDRV_I8243_ADD("n7751_8243", NULL, n7751_rom_control_w)
359431
432   MDRV_MACHINE_START(othello)
433   MDRV_MACHINE_RESET(othello)
360434
361435   /* video hardware */
362436   MDRV_SCREEN_ADD("screen", RASTER)
r7500r7501
406480   ROM_LOAD( "7.ic42",   0x4000, 0x2000, CRC(a76705f7) SHA1(b7d2a65d65d065732ddd0b3b738749369b382b48))
407481ROM_END
408482
409GAME( 1984, othello,  0,       othello,  othello,  0, ROT0, "Success", "Othello (version 3.0)", GAME_WRONG_COLORS | GAME_IMPERFECT_SOUND )
483GAME( 1984, othello,  0,       othello,  othello,  0, ROT0, "Success", "Othello (version 3.0)", GAME_WRONG_COLORS | GAME_IMPERFECT_SOUND | GAME_SUPPORTS_SAVE )
src/mame/drivers/f-32.c
r7500r7501
1717#include "sound/2151intf.h"
1818#include "sound/okim6295.h"
1919
20typedef struct _mosaicf2_state mosaicf2_state;
21struct _mosaicf2_state
20class mosaicf2_state
2221{
22public:
23   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, mosaicf2_state(machine)); }
24
25   mosaicf2_state(running_machine &machine) { }
26
2327   /* memory pointers */
2428   UINT32 *  videoram;
2529};
src/mame/drivers/gstream.c
r7500r7501
126126#include "cpu/e132xs/e132xs.h"
127127#include "sound/okim6295.h"
128128
129typedef struct _gstream_state gstream_state;
130struct _gstream_state
129class gstream_state
131130{
131public:
132   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, gstream_state(machine)); }
133
134   gstream_state(running_machine &machine) { }
135
132136   /* memory pointers */
133137   UINT32 *  vram;
134138   UINT32 *  workram;
src/mame/drivers/cps2.c
r7500r7501
33663366   ROM_LOAD16_WORD_SWAP( "hs2j.03",  0x000000, 0x80000, CRC(00738f73) SHA1(99947a621f21a88dc4c425d9bfbc30b3c5f76ecd) )
33673367   ROM_LOAD16_WORD_SWAP( "hs2j.04",  0x080000, 0x80000, CRC(40072c4a) SHA1(85b95bd3c907b4276a31777e092b8c40d3763257) )
33683368   ROM_LOAD16_WORD_SWAP( "hs2.05",   0x100000, 0x80000, CRC(dde34a35) SHA1(f5be2d2916db6e86e0886d61d55bddf138273ebc) )
3369   ROM_LOAD16_WORD_SWAP( "hs2.06",   0x180000, 0x80000, CRC(f4e56dda) SHA1(c6490707c2a416ab88612c2d73abbe5853d8cb92) ) /* Rom 07 needs to be verified, US & Asia 07 match */
3370   ROM_LOAD16_WORD_SWAP( "hs2j.07",  0x200000, 0x80000, BAD_DUMP CRC(09fe85b4) SHA1(b15b3ae28a6a395d26580dc8f4b506507792df38) ) /* 1 bit difference at 7C1AD EF <-> FF */
3369   ROM_LOAD16_WORD_SWAP( "hs2.06",   0x180000, 0x80000, CRC(f4e56dda) SHA1(c6490707c2a416ab88612c2d73abbe5853d8cb92) )
3370   ROM_LOAD16_WORD_SWAP( "hs2.07",   0x200000, 0x80000, CRC(ee4420fc) SHA1(06cf76660b0c794d2460c52d9fe8334fff51e9de) )
33713371   ROM_LOAD16_WORD_SWAP( "hs2.08",   0x280000, 0x80000, CRC(c9441533) SHA1(bf178fac1f060fcce3ff9118333c8517dadc9429) )
33723372   ROM_LOAD16_WORD_SWAP( "hs2.09",   0x300000, 0x80000, CRC(3fc638a8) SHA1(2a42877b26c8abc437da46225701f0bba6e40058) )
33733373   ROM_LOAD16_WORD_SWAP( "hs2.10",   0x380000, 0x80000, CRC(20d0f9e4) SHA1(80a5eeef9472e327b0d4ee26434bad109a9434ea) )
r7500r7501
70937093
70947094ROM_START( xmcotaj )
70957095   ROM_REGION( CODE_SIZE, "maincpu", 0 )      /* 68000 code */
7096   ROM_LOAD16_WORD_SWAP( "xmnj.03e", 0x000000, 0x80000, CRC(0df29f5f) SHA1(83993ea90e7a602c3db137d08c008dcd9bee3055) )
7097   ROM_LOAD16_WORD_SWAP( "xmnj.04e", 0x080000, 0x80000, CRC(4a65833b) SHA1(cd899674ba6448fb3841247d3f434e82b19c5399) )
7098   ROM_LOAD16_WORD_SWAP( "xmn.05a",  0x100000, 0x80000, CRC(ac0d7759) SHA1(650d4474b13f16af7910a0f721fcda2ddb2414fd) )
7099   ROM_LOAD16_WORD_SWAP( "xmn.06a",  0x180000, 0x80000, CRC(1b86a328) SHA1(2469cd705139ee9f1142e6e379e68d0c9675b37e) )
7100   ROM_LOAD16_WORD_SWAP( "xmn.07a",  0x200000, 0x80000, CRC(2c142a44) SHA1(7624875f9c39b361fc83e52e87e0fd5e96279713) )
7101   ROM_LOAD16_WORD_SWAP( "xmn.08a",  0x280000, 0x80000, CRC(f712d44f) SHA1(0d18d4a4eacad94a66beca6ec509ac7f690c6882) )
7102   ROM_LOAD16_WORD_SWAP( "xmn.09a",  0x300000, 0x80000, CRC(9241cae8) SHA1(bb6980abf25aaf3eb14e230ca6942f3e2ab2c660) )
7103   ROM_LOAD16_WORD_SWAP( "xmn.10a",  0x380000, 0x80000, CRC(53c0eab9) SHA1(e3b1ec1fd517735f7801cfebb257c43185c6d3fb) )
7104
7105   ROM_REGION( 0x2000000, "gfx", 0 )
7106   ROMX_LOAD( "xmn.13m",   0x0000000, 0x400000, CRC(bf4df073) SHA1(4d2740c3a827f0ec2cf75ad99c65e393c6a11c23) , ROM_GROUPWORD | ROM_SKIP(6) )
7107   ROMX_LOAD( "xmn.15m",   0x0000002, 0x400000, CRC(4d7e4cef) SHA1(50b8797b8099a8d76ad063ba1201a13dbb88ae3a) , ROM_GROUPWORD | ROM_SKIP(6) )
7108   ROMX_LOAD( "xmn.17m",   0x0000004, 0x400000, CRC(513eea17) SHA1(a497477ad9ac13180911d8745ef6ee1955c0b877) , ROM_GROUPWORD | ROM_SKIP(6) )
7109   ROMX_LOAD( "xmn.19m",   0x0000006, 0x400000, CRC(d23897fc) SHA1(1e31627999736652252164d32662779a1ac6ca29) , ROM_GROUPWORD | ROM_SKIP(6) )
7110   ROMX_LOAD( "xmn.14m",   0x1000000, 0x400000, CRC(778237b7) SHA1(89a759ec383518ec52f5059d10ec342f2247aa20) , ROM_GROUPWORD | ROM_SKIP(6) )
7111   ROMX_LOAD( "xmn.16m",   0x1000002, 0x400000, CRC(67b36948) SHA1(692fb6e4096b880aa22996d554b160f664bbd907) , ROM_GROUPWORD | ROM_SKIP(6) )
7112   ROMX_LOAD( "xmn.18m",   0x1000004, 0x400000, CRC(015a7c4c) SHA1(cccc95dafd076a1a9fa004710006149c42d058ba) , ROM_GROUPWORD | ROM_SKIP(6) )
7113   ROMX_LOAD( "xmn.20m",   0x1000006, 0x400000, CRC(9dde2758) SHA1(17ba259cad03c7b5d56c0a5eda9ab53521665729) , ROM_GROUPWORD | ROM_SKIP(6) )
7114
7115   ROM_REGION( QSOUND_SIZE, "audiocpu", 0 ) /* 64k for the audio CPU (+banks) */
7116   ROM_LOAD( "xmn.01a",  0x00000, 0x08000, CRC(40f479ea) SHA1(f29e15f537675305264ae2138a0a537fb9e2008b) )
7117   ROM_CONTINUE(         0x10000, 0x18000 )
7118   ROM_LOAD( "xmn.02a",  0x28000, 0x20000, CRC(39d9b5ad) SHA1(af502debfd36100d4fc971ed25fdf9d7121d6f18) )
7119
7120   ROM_REGION( 0x400000, "qsound", 0 ) /* QSound samples */
7121   ROM_LOAD16_WORD_SWAP( "xmn.11m",   0x000000, 0x200000, CRC(c848a6bc) SHA1(ac8ac564d3c43225822f8bc330eba9f35b24b0a4) )
7122   ROM_LOAD16_WORD_SWAP( "xmn.12m",   0x200000, 0x200000, CRC(729c188f) SHA1(3279774ad8aebbcf0fc779cdfcbe21044dd192ad) )
7123ROM_END
7124
7125ROM_START( xmcotaj1 )
7126   ROM_REGION( CODE_SIZE, "maincpu", 0 )      /* 68000 code */
70967127   ROM_LOAD16_WORD_SWAP( "xmnj.03d", 0x000000, 0x80000, CRC(79086d62) SHA1(d99a48bd40593aa9c1ff1fcbfc40cfe3bc882fc5) )
70977128   ROM_LOAD16_WORD_SWAP( "xmnj.04d", 0x080000, 0x80000, CRC(38eed613) SHA1(86ecb58bf03adda705a39a9779862fe2c85cadad) )
70987129   ROM_LOAD16_WORD_SWAP( "xmn.05",   0x100000, 0x80000, CRC(c3ed62a2) SHA1(4e3317d7ca981e33318822103a16e59f4ce20deb) )
r7500r7501
71227153   ROM_LOAD16_WORD_SWAP( "xmn.12m",   0x200000, 0x200000, CRC(729c188f) SHA1(3279774ad8aebbcf0fc779cdfcbe21044dd192ad) )
71237154ROM_END
71247155
7125ROM_START( xmcotaj1 )
7156ROM_START( xmcotaj2 )
71267157   ROM_REGION( CODE_SIZE, "maincpu", 0 )      /* 68000 code */
71277158   ROM_LOAD16_WORD_SWAP( "xmnj.03b", 0x000000, 0x80000, CRC(c8175fb3) SHA1(ea25bd165f8794324a1e07719312798cf9742924) )
71287159   ROM_LOAD16_WORD_SWAP( "xmnj.04b", 0x080000, 0x80000, CRC(54b3fba3) SHA1(47eaff5d36a45e4196f87ed3d02e54d5407e7962) )
r7500r7501
71537184   ROM_LOAD16_WORD_SWAP( "xmn.12m",   0x200000, 0x200000, CRC(729c188f) SHA1(3279774ad8aebbcf0fc779cdfcbe21044dd192ad) )
71547185ROM_END
71557186
7156ROM_START( xmcotaj2 )
7187ROM_START( xmcotaj3 )
71577188   ROM_REGION( CODE_SIZE, "maincpu", 0 )      /* 68000 code */
71587189   ROM_LOAD16_WORD_SWAP( "xmnj.03a", 0x000000, 0x80000, CRC(00761611) SHA1(e780dbe1d21a0d5b6981f0395942c9fa59688113) )
71597190   ROM_LOAD16_WORD_SWAP( "xmnj.04a", 0x080000, 0x80000, CRC(614d3f60) SHA1(2272ae243557562a0bc85d2cd2b37dd876f6902c) )
r7500r7501
77197750GAME( 1994, xmcota,     0,        cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "X-Men: Children of the Atom (Euro 950105)", GAME_SUPPORTS_SAVE )
77207751GAME( 1994, xmcotau,    xmcota,   cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "X-Men: Children of the Atom (USA 950105)", GAME_SUPPORTS_SAVE )
77217752GAME( 1994, xmcotah,    xmcota,   cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "X-Men: Children of the Atom (Hispanic 950331)", GAME_SUPPORTS_SAVE )
7722GAME( 1994, xmcotaj,    xmcota,   cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "X-Men: Children of the Atom (Japan 941222)", GAME_SUPPORTS_SAVE )
7723GAME( 1994, xmcotaj1,   xmcota,   cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "X-Men: Children of the Atom (Japan 941219)", GAME_SUPPORTS_SAVE )
7724GAME( 1994, xmcotaj2,   xmcota,   cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "X-Men: Children of the Atom (Japan 941217)", GAME_SUPPORTS_SAVE )
7753GAME( 1994, xmcotaj,    xmcota,   cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "X-Men: Children of the Atom (Japan 950105)", GAME_SUPPORTS_SAVE )
7754GAME( 1994, xmcotaj1,   xmcota,   cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "X-Men: Children of the Atom (Japan 941222)", GAME_SUPPORTS_SAVE )
7755GAME( 1994, xmcotaj2,   xmcota,   cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "X-Men: Children of the Atom (Japan 941219)", GAME_SUPPORTS_SAVE )
7756GAME( 1994, xmcotaj3,   xmcota,   cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "X-Men: Children of the Atom (Japan 941217)", GAME_SUPPORTS_SAVE )
77257757GAME( 1994, xmcotajr,   xmcota,   cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "X-Men: Children of the Atom (Japan 941208 rent version)", GAME_SUPPORTS_SAVE )
77267758GAME( 1994, xmcotaa,    xmcota,   cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "X-Men: Children of the Atom (Asia 941217)", GAME_SUPPORTS_SAVE )
77277759GAME( 1995, nwarr,      0,        cps2, cps2_2p6b, cps2,     ROT0,   "Capcom", "Night Warriors: Darkstalkers' Revenge (Euro 950316)", GAME_SUPPORTS_SAVE )
src/mame/drivers/pushman.c
r7500r7501
1515    The hardware is actually very similar to F1-Dream and Tiger Road but
1616    with a 68705 for protection.
1717
18    There is a Top Tronic licensed version currently not dumped
18    Pushman is known to be released in a 2 PCB stack as well as a large
19    single plane board.
1920
2021 **************************************************************************
2122
r7500r7501
507508   ROM_REGION( 0x10000, "audiocpu", 0 )
508509   ROM_LOAD( "pushman.013", 0x00000, 0x08000,  CRC(adfe66c1) SHA1(fa4ed13d655c664b06e9b91292d2c0a88cb5a569) )
509510
510   ROM_REGION( 0x01000, "mcu", 0 ) /* Verified same for all 3 currently dumped versions */
511   ROM_LOAD( "pushman68705r3.bin",  0x00000, 0x01000, CRC(d7916657) SHA1(89c14c6044f082fffe2a8f86d0a82336f4a110a2) )
511   ROM_REGION( 0x01000, "mcu", 0 ) /* Verified same for all 4 currently dumped versions */
512   ROM_LOAD( "pushman68705r3p.ic23",  0x00000, 0x01000, CRC(d7916657) SHA1(89c14c6044f082fffe2a8f86d0a82336f4a110a2) )
512513
513514   ROM_REGION( 0x10000, "gfx1", 0 )
514515   ROM_LOAD( "pushman.001",  0x00000, 0x08000, CRC(626e5865) SHA1(4ab96c8512f439d18390094d71a898f5c576399c) )
r7500r7501
527528
528529   ROM_REGION( 0x10000, "gfx4", 0 )   /* bg tilemaps */
529530   ROM_LOAD( "pushman.010", 0x00000, 0x08000, CRC(a500132d) SHA1(26b02c9fea69b51c5f7dc1b43b838cd336ebf862) )
531
532   ROM_REGION( 0x0100, "proms", 0 ) /* this is the same as tiger road / f1-dream */
533   ROM_LOAD( "n82s129an.ic82",   0x0000, 0x0100, CRC(ec80ae36) SHA1(397ec8fc1b106c8b8d4bf6798aa429e8768a101a) ) /* priority (not used) */
530534ROM_END
531535
532536ROM_START( pushmana )
r7500r7501
537541   ROM_REGION( 0x10000, "audiocpu", 0 )
538542   ROM_LOAD( "pushman.013", 0x00000, 0x08000,  CRC(adfe66c1) SHA1(fa4ed13d655c664b06e9b91292d2c0a88cb5a569) ) // missing from this set?
539543
540   ROM_REGION( 0x01000, "mcu", 0 ) /* Verified same for all 3 currently dumped versions */
541   ROM_LOAD( "pushman68705r3.bin",  0x00000, 0x01000, CRC(d7916657) SHA1(89c14c6044f082fffe2a8f86d0a82336f4a110a2) )
544   ROM_REGION( 0x01000, "mcu", 0 ) /* Verified same for all 4 currently dumped versions */
545   ROM_LOAD( "pushman68705r3p.ic23",  0x00000, 0x01000, CRC(d7916657) SHA1(89c14c6044f082fffe2a8f86d0a82336f4a110a2) )
542546
543547   ROM_REGION( 0x10000, "gfx1", 0 )
544548   ROM_LOAD( "pushmana.130",  0x00000, 0x10000, CRC(f83f92e7) SHA1(37f337d7b496f8d81eed247c80390a6aabcf4b95) )
r7500r7501
557561
558562   ROM_REGION( 0x10000, "gfx4", 0 )   /* bg tilemaps */
559563   ROM_LOAD( "pushmana.189", 0x00000, 0x10000, CRC(59f25598) SHA1(ace33afd6e6d07376ed01048db99b13bcec790d7) )
564
565   ROM_REGION( 0x0100, "proms", 0 ) /* this is the same as tiger road / f1-dream */
566   ROM_LOAD( "n82s129an.ic82",   0x0000, 0x0100, CRC(ec80ae36) SHA1(397ec8fc1b106c8b8d4bf6798aa429e8768a101a) ) /* priority (not used) */
560567ROM_END
561568
562569ROM_START( pushmans )
563570   ROM_REGION( 0x20000, "maincpu", 0 )
564   ROM_LOAD16_BYTE( "pman-12.212", 0x000000, 0x10000, CRC(4251109d) SHA1(d4b020e4ecc2005b3a4c1b34d88de82b09bf5a6b) )
565   ROM_LOAD16_BYTE( "pman-11.197", 0x000001, 0x10000, CRC(1167ed9f) SHA1(ca0296950a75ef15ff6f9d3a776b02180b941d61) )
571   ROM_LOAD16_BYTE( "pman-12.ic212", 0x000000, 0x10000, CRC(4251109d) SHA1(d4b020e4ecc2005b3a4c1b34d88de82b09bf5a6b) )
572   ROM_LOAD16_BYTE( "pman-11.ic197", 0x000001, 0x10000, CRC(1167ed9f) SHA1(ca0296950a75ef15ff6f9d3a776b02180b941d61) )
566573
567574   ROM_REGION( 0x10000, "audiocpu", 0 )
568   ROM_LOAD( "pman-13.216", 0x00000, 0x08000, CRC(bc03827a) SHA1(b4d6ae164bbb7ba19e4934392fe2ba29575f28b9) )
575   ROM_LOAD( "pman-13.ic216", 0x00000, 0x08000, CRC(bc03827a) SHA1(b4d6ae164bbb7ba19e4934392fe2ba29575f28b9) )
569576
570   ROM_REGION( 0x01000, "mcu", 0 ) /* Verified same for all 3 currently dumped versions */
571   ROM_LOAD( "pushman68705r3.bin",  0x00000, 0x01000, CRC(d7916657) SHA1(89c14c6044f082fffe2a8f86d0a82336f4a110a2) )
577   ROM_REGION( 0x01000, "mcu", 0 ) /* Verified same for all 4 currently dumped versions */
578   ROM_LOAD( "pushman68705r3p.ic23",  0x00000, 0x01000, CRC(d7916657) SHA1(89c14c6044f082fffe2a8f86d0a82336f4a110a2) )
572579
573580   ROM_REGION( 0x10000, "gfx1", 0 )
574   ROM_LOAD( "pman-1.130",  0x00000, 0x08000, CRC(14497754) SHA1(a47d03c56add18c5d9aed221990550b18589ff43) )
581   ROM_LOAD( "pman-1.ic130",  0x00000, 0x08000, CRC(14497754) SHA1(a47d03c56add18c5d9aed221990550b18589ff43) )
575582
576583   ROM_REGION( 0x40000, "gfx2", 0 )
577   ROM_LOAD( "pman-4.58", 0x00000, 0x10000, CRC(16e5ce6b) SHA1(cb9c6094a853abc550eae29c35083f26a0d1de94) )
578   ROM_LOAD( "pman-5.59", 0x10000, 0x10000, CRC(b82140b8) SHA1(0a16b904eb2739bfa22a87d03266d3ff2b750b67) )
584   ROM_LOAD( "pman-4.ic58", 0x00000, 0x10000, CRC(16e5ce6b) SHA1(cb9c6094a853abc550eae29c35083f26a0d1de94) )
585   ROM_LOAD( "pman-5.ic59", 0x10000, 0x10000, CRC(b82140b8) SHA1(0a16b904eb2739bfa22a87d03266d3ff2b750b67) )
579586   ROM_LOAD( "pman-2.56", 0x20000, 0x10000, CRC(2cb2ac29) SHA1(165447ad7eb8593c0d4346096ec13ac386e905c9) )
580587   ROM_LOAD( "pman-3.57", 0x30000, 0x10000, CRC(8ab957c8) SHA1(143501819920c521353930f83e49f1e19fbba34f) )
581588
582589   ROM_REGION( 0x40000, "gfx3", 0 )
583   ROM_LOAD( "pman-6.131", 0x00000, 0x10000, CRC(bd0f9025) SHA1(7262410d4631f1b051c605d5cea5b91e9f68327e) )
584   ROM_LOAD( "pman-8.148", 0x10000, 0x10000, CRC(591bd5c0) SHA1(6e0e18e0912fa38e113420ac31c7f36853b830ec) )
585   ROM_LOAD( "pman-7.132", 0x20000, 0x10000, CRC(208cb197) SHA1(161633b6b0acf25447a5c0b3c6fbf18adc6e2243) )
586   ROM_LOAD( "pman-9.149", 0x30000, 0x10000, CRC(77ee8577) SHA1(63d13683dd097d8e7cb71ad3abe04e11f2a58bd3) )
590   ROM_LOAD( "pman-6.ic131", 0x00000, 0x10000, CRC(bd0f9025) SHA1(7262410d4631f1b051c605d5cea5b91e9f68327e) )
591   ROM_LOAD( "pman-8.ic148", 0x10000, 0x10000, CRC(591bd5c0) SHA1(6e0e18e0912fa38e113420ac31c7f36853b830ec) )
592   ROM_LOAD( "pman-7.ic132", 0x20000, 0x10000, CRC(208cb197) SHA1(161633b6b0acf25447a5c0b3c6fbf18adc6e2243) )
593   ROM_LOAD( "pman-9.ic149", 0x30000, 0x10000, CRC(77ee8577) SHA1(63d13683dd097d8e7cb71ad3abe04e11f2a58bd3) )
587594
588595   ROM_REGION( 0x10000, "gfx4", 0 )   /* bg tilemaps */
589   ROM_LOAD( "pman-10.189", 0x00000, 0x08000, CRC(5f9ae9a1) SHA1(87619918c28c942780f6dbd3818d4cc69932eefc) )
596   ROM_LOAD( "pman-10.ic189", 0x00000, 0x08000, CRC(5f9ae9a1) SHA1(87619918c28c942780f6dbd3818d4cc69932eefc) )
597
598   ROM_REGION( 0x0100, "proms", 0 ) /* this is the same as tiger road / f1-dream */
599   ROM_LOAD( "n82s129an.ic82",   0x0000, 0x0100, CRC(ec80ae36) SHA1(397ec8fc1b106c8b8d4bf6798aa429e8768a101a) ) /* priority (not used) */
590600ROM_END
591601
602ROM_START( pushmant ) /* Single plane PCB */
603   ROM_REGION( 0x20000, "maincpu", 0 )
604   ROM_LOAD16_BYTE( "12.ic212", 0x000000, 0x10000, CRC(f5c77d86) SHA1(66d2d5dc9f4662efc5a865c9cc1bba653e86a674) )
605   ROM_LOAD16_BYTE( "11.ic197", 0x000001, 0x10000, CRC(2e09ff08) SHA1(9bb05c51c985c3a12fb8d6fd915276e304651eb1) )
606
607   ROM_REGION( 0x10000, "audiocpu", 0 )
608   ROM_LOAD( "13.ic216", 0x00000, 0x08000, CRC(adfe66c1) SHA1(fa4ed13d655c664b06e9b91292d2c0a88cb5a569) ) /* Same as the Comad set */
609
610   ROM_REGION( 0x01000, "mcu", 0 ) /* Verified same for all 4 currently dumped versions */
611   ROM_LOAD( "pushman68705r3p.ic23",  0x00000, 0x01000, CRC(d7916657) SHA1(89c14c6044f082fffe2a8f86d0a82336f4a110a2) )
612
613   ROM_REGION( 0x10000, "gfx1", 0 )
614   ROM_LOAD( "1.ic130",  0x00000, 0x08000, CRC(14497754) SHA1(a47d03c56add18c5d9aed221990550b18589ff43) ) /* Same as the Sammy set */
615
616   ROM_REGION( 0x40000, "gfx2", 0 )
617   ROM_LOAD( "4.ic58", 0x00000, 0x10000, CRC(69209214) SHA1(c5b527234aefbdfb39864806e2b1784fdf2dd49c) )
618   ROM_LOAD( "5.ic59", 0x10000, 0x10000, CRC(75fc0ac4) SHA1(aa3a19573b96d89b94bfddda5b404d19cbb47335) )
619   ROM_LOAD( "2.ic56", 0x20000, 0x10000, CRC(2bb8093f) SHA1(e86048d676b06796a1d2ed325ea8ea9cada3c4b6) )
620   ROM_LOAD( "3.ic57", 0x30000, 0x10000, CRC(5f1c4e7a) SHA1(751caf2365eccbab6d7de5434c4656ac5bd7f13b) )
621
622   ROM_REGION( 0x40000, "gfx3", 0 )
623   ROM_LOAD( "6.ic131", 0x00000, 0x10000, CRC(bd0f9025) SHA1(7262410d4631f1b051c605d5cea5b91e9f68327e) ) /* These 4 are the same as the Sammy set */
624   ROM_LOAD( "8.ic148", 0x10000, 0x10000, CRC(591bd5c0) SHA1(6e0e18e0912fa38e113420ac31c7f36853b830ec) )
625   ROM_LOAD( "7.ic132", 0x20000, 0x10000, CRC(208cb197) SHA1(161633b6b0acf25447a5c0b3c6fbf18adc6e2243) )
626   ROM_LOAD( "9.ic149", 0x30000, 0x10000, CRC(77ee8577) SHA1(63d13683dd097d8e7cb71ad3abe04e11f2a58bd3) )
627
628   ROM_REGION( 0x10000, "gfx4", 0 )   /* bg tilemaps */
629   ROM_LOAD( "10.ic189", 0x00000, 0x08000, CRC(5f9ae9a1) SHA1(87619918c28c942780f6dbd3818d4cc69932eefc) ) /* Same as the Sammy set */
630
631   ROM_REGION( 0x0100, "proms", 0 ) /* this is the same as tiger road / f1-dream */
632   ROM_LOAD( "n82s129an.ic82",   0x0000, 0x0100, CRC(ec80ae36) SHA1(397ec8fc1b106c8b8d4bf6798aa429e8768a101a) ) /* priority (not used) */
633ROM_END
634
592635ROM_START( bballs )
593636   ROM_REGION( 0x20000, "maincpu", 0 )
594637   ROM_LOAD16_BYTE( "bb12.m17", 0x000000, 0x10000, CRC(4501c245) SHA1(b03ace135b077e8c226dd3be04fa8e86ad096770) )
r7500r7501
619662   ROM_LOAD( "bb10.l6", 0x00000, 0x08000, CRC(d06498f9) SHA1(9f33bbc40ebe11c03aec29289f76f1c3ca5bf009) )
620663
621664   ROM_REGION( 0x0100, "proms", 0 ) /* this is the same as tiger road / f1-dream */
622   ROM_LOAD( "bb_prom.e9",   0x0000, 0x0100, CRC(ec80ae36) SHA1(397ec8fc1b106c8b8d4bf6798aa429e8768a101a) )   /* priority (not used) */
665   ROM_LOAD( "bb_prom.e9",   0x0000, 0x0100, CRC(ec80ae36) SHA1(397ec8fc1b106c8b8d4bf6798aa429e8768a101a) )   /* priority (not used) N82S129 BPROM */
623666ROM_END
624667
625668GAME( 1990, pushman,  0,       pushman, pushman, 0, ROT0, "Comad", "Pushman (Korea, set 1)", 0 )
626669GAME( 1990, pushmana, pushman, pushman, pushman, 0, ROT0, "Comad", "Pushman (Korea, set 2)", 0 )
627670GAME( 1990, pushmans, pushman, pushman, pushman, 0, ROT0, "Comad (American Sammy license)", "Pushman (American Sammy license)", 0 )
671GAME( 1990, pushmant, pushman, pushman, pushman, 0, ROT0, "Comad (Top Tronic license)", "Pushman (Top Tronic license)", 0 )
628672GAME( 1991, bballs,   0,       bballs,  bballs,  0, ROT0, "Comad", "Bouncing Balls", 0 )
src/mame/drivers/namcos12.c
r7500r7501
3737Soul Calibur (SOC11/VER.B)               (C) Namco,        1998  COH-700     SYSTEM12 MOTHER(B)  SYSTEM12 M5F2    KC020
3838Soul Calibur (SOC11/VER.C)               (C) Namco,        1998  COH-700     SYSTEM12 MOTHER(B)  SYSTEM12 M5F4    KC020
3939Soul Calibur (SOC13/VER.B)               (C) Namco,        1998  COH-700     SYSTEM12 MOTHER(B)  SYSTEM12 M5F4    KC020
40Soul Calibur (SOC14/VER.B)               (C) Namco,        1998  COH-700     SYSTEM12 MOTHER(B)  SYSTEM12 M5F4    KC020
4041Soul Calibur (SOC14/VER.C)               (C) Namco,        1998  COH-700     SYSTEM12 MOTHER     JO 11-04-98      none
4142Super World Stadium '98 (SS81/VER.A)     (C) Namco,        1998  COH-700     SYSTEM12 MOTHER(B)  SYSTEM12 M4F6    KC025
4243Super World Stadium '99 (SS91/VER.A3)    (C) Namco,        1999  COH-700     SYSTEM12 MOTHER(B)  SYSTEM12 M5F4    KC043
r7500r7501
237238                     Soul Calibur              SOC1 Ver.A   SOC11/VER.A2     MOTHER(B)
238239                     Soul Calibur              SOC3 Ver.B   SOC13/VER.B      MOTHER(B)
239240                     Soul Calibur              SOC1 Ver.C   SOC11/VER.C      MOTHER(B)
241                     Soul Calibur              SOC4 Ver.B   SOC14/VER.B      MOTHER(B)
240242                     Super World Stadium 2000  SS01 Ver.A   SS01/VER.A3      MOTHER(C) (ROMs serialised)
241243                     Super World Stadium 2001  SS11 Ver.A   SS11/VER.A2      MOTHER(C) (ROMs serialised)
242244                     Tekken Tag Tournament     TEG3 Ver.B   TEG3/VER.B       MOTHER(B)
r7500r7501
476478                                                                                    SOC1 FL4L, SOC1 FL4H
477479                                                                                    SOC1 FL3L, SOC1 FL3H
478480
481Soul Calibur   SOC14/VER.B  SYSTEM 12 M5F4 PCB 8661961000 (8661971000)     none     SOC1 WAVE0
482                                                                                    SOC1 ROM0, SOC1 ROM1, SOC1 ROM2
483                                                                                    SOC1 FL4L, SOC1 FL4H
484                                                                                    SOC1 FL3L, SOC1 FL3H
485
486
479487********
480488*Type 4*
481489********
r7500r7501
19881996   ROM_LOAD( "soc1wave0.2",         0x0000000, 0x800000, CRC(c100618d) SHA1(b87f88ee42ad9c5affa674e5f816d902143fed99) )
19891997ROM_END
19901998
1999ROM_START( soulclbrb )
2000   ROM_REGION32_LE( 0x00400000, "user1", 0 ) /* main prg */
2001        ROM_LOAD16_BYTE( "soc14verb.2l", 0x000000, 0x200000, CRC(6af5c5f6) SHA1(51d1e7d78d95cfc765cd219ed07b405cd920044b) )
2002        ROM_LOAD16_BYTE( "soc14verb.2p", 0x000001, 0x200000, CRC(23e7a4c4) SHA1(a97f36cafdeff9e26fbd24e54ab8ac8080763761) )
2003
2004   ROM_REGION32_LE( 0x2000000, "user2", 0 ) /* main data */
2005   ROM_LOAD(        "soc1rom0.7",   0x0000000, 0x800000, CRC(cdc47b55) SHA1(315ea6b819de5c4883aa400f1b9f4172637757bf) )
2006   ROM_LOAD(        "soc1rom1.8",   0x0800000, 0x800000, CRC(30d2dd5a) SHA1(1c0c467ba339e0241efb8d5c3b025a046b2ca676) )
2007   ROM_LOAD(        "soc1rom2.9",   0x1000000, 0x800000, CRC(dbb93955) SHA1(624cd8ad94e8ae53206f798bff81784afe95e5f1) )
2008   ROM_LOAD(        "soc1fl3.6",    0x1800000, 0x400000, CRC(24d94c38) SHA1(0f9b9ab11dd4e02086d7b9104ce2f5d4e93cd696) )
2009   ROM_LOAD(        "soc1fl4.5",    0x1c00000, 0x400000, CRC(6212090e) SHA1(ed5e50771180935a0c2e760e7369673098722201) )
2010
2011   ROM_REGION( 0x0080000, "sub", 0 ) /* sound prg */
2012   ROM_LOAD16_WORD_SWAP( "soc1vera.11s", 0x0000000, 0x080000, CRC(52aa206a) SHA1(5abe9d6f800fa1b9623aa08b16e9b959b840e50b) )
2013
2014   ROM_REGION( 0x0800000, "c352", 0 ) /* samples */
2015   ROM_LOAD( "soc1wave0.2",         0x0000000, 0x800000, CRC(c100618d) SHA1(b87f88ee42ad9c5affa674e5f816d902143fed99) )
2016ROM_END
2017
19912018ROM_START( soulclbrj )
19922019   ROM_REGION32_LE( 0x00400000, "user1", 0 ) /* main prg */
19932020   ROM_LOAD16_BYTE( "soc11verc.2l", 0x0000000, 0x200000, CRC(f5e3679c) SHA1(b426cfc7707a6772e6aabbaf4a19b7f008324d55) )
r7500r7501
20072034   ROM_LOAD( "soc1wave0.2",         0x0000000, 0x800000, CRC(c100618d) SHA1(b87f88ee42ad9c5affa674e5f816d902143fed99) )
20082035ROM_END
20092036
2010ROM_START( soulclbrb )
2037ROM_START( soulclbrb2 )
20112038   ROM_REGION32_LE( 0x00400000, "user1", 0 ) /* main prg */
20122039   ROM_LOAD16_BYTE( "soc13verb.2e", 0x0000000, 0x200000, CRC(ad7cfb1e) SHA1(7d1e7fd0024e31780335690906846e91ba063003) )
20132040   ROM_LOAD16_BYTE( "soc13verb.2j", 0x0000001, 0x200000, CRC(7449c045) SHA1(1c7a8b659d0f12dded2a00bc83baeb392fd7a719) )
r7500r7501
24132440GAME( 1997, lbgrande,  0,        coh700,   namcos12, namcos12, ROT0, "Namco",         "Libero Grande (LG2/VER.A)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND ) /* KC006 */
24142441GAME( 1997, toukon3,   0,        coh700,   namcos12, namcos12, ROT0, "Tomy/Namco",    "Shin Nihon Pro Wrestling Toukon Retsuden 3 Arcade Edition (Japan, TR1/VER.A)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND ) /* KC019 */
24152442GAME( 1998, soulclbr,  0,        coh700,   namcos12, namcos12, ROT0, "Namco",         "Soul Calibur (SOC14/VER.C)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
2443GAME( 1998, soulclbrb, soulclbr, coh700,   namcos12, namcos12, ROT0, "Namco",         "Soul Calibur (SOC14/VER.B)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
24162444GAME( 1998, soulclbrj, soulclbr, coh700,   namcos12, namcos12, ROT0, "Namco",         "Soul Calibur (Japan, SOC11/VER.C)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND ) /* KC020 */
2417GAME( 1998, soulclbrb, soulclbr, coh700,   namcos12, namcos12, ROT0, "Namco",         "Soul Calibur (SOC13/VER.B)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND ) /* KC020 */
2445GAME( 1998, soulclbrb2, soulclbr, coh700,   namcos12, namcos12, ROT0, "Namco",         "Soul Calibur (SOC13/VER.B)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND ) /* KC020 */
24182446GAME( 1998, soulclbrjb,soulclbr, coh700,   namcos12, namcos12, ROT0, "Namco",         "Soul Calibur (Japan, SOC11/VER.B)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND ) /* KC020 */
24192447GAME( 1998, soulclbrja,soulclbr, coh700,   namcos12, namcos12, ROT0, "Namco",         "Soul Calibur (Japan, SOC11/VER.A2)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND ) /* KC020 */
24202448GAME( 1998, ehrgeiz,   0,        coh700,   namcos12, namcos12, ROT0, "Square/Namco",  "Ehrgeiz (EG3/VER.A)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND ) /* KC021 */
src/mame/drivers/mole.c
r7500r7501
1/* MOLE ATTACK by Yachiyo Electronics Co.,LTD. 1982
1/*****************************************************************************
22
3   MOLE ATTACK by Yachiyo Electronics Co.,LTD. 1982
4
35   Known Clones:
46   "Holey Moley", from tai (Thomas Automatics, Inc.)
57
r7500r7501
4345   0x3DC                    affects mole popmessage
4446   0x3E5                    round point/passing point control?
4547   0x3E7                    round point/passing point control?
46*/
4748
49******************************************************************************/
4850
4951#include "emu.h"
5052#include "cpu/m6502/m6502.h"
5153#include "sound/ay8910.h"
5254
53WRITE8_HANDLER(mole_videoram_w);
54WRITE8_HANDLER(mole_tilebank_w);
55WRITE8_HANDLER(mole_flipscreen_w);
5655
57PALETTE_INIT(mole);
58VIDEO_START(mole);
59VIDEO_UPDATE(mole);
56class mole_state
57{
58public:
59   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, mole_state(machine)); }
6060
61   mole_state(running_machine &machine) { }
6162
63   /* memory pointers */
64   UINT16 *     tileram;
65
66   /* video-related */
67   tilemap_t    *bg_tilemap;
68   int          tile_bank;
69};
70
71
72/*************************************
73 *
74 *  Video emulation
75 *
76 *************************************/
77
78static PALETTE_INIT( mole )
79{
80   int i;
81
82   for (i = 0; i < 8; i++)
83      palette_set_color_rgb(machine, i, pal1bit(i >> 0), pal1bit(i >> 2), pal1bit(i >> 1));
84}
85
86static TILE_GET_INFO( get_bg_tile_info )
87{
88   mole_state *state = (mole_state *)machine->driver_data;
89   UINT16 code = state->tileram[tile_index];
90
91   SET_TILE_INFO((code & 0x200) ? 1 : 0, code & 0x1ff, 0, 0);
92}
93
94static VIDEO_START( mole )
95{
96   mole_state *state = (mole_state *)machine->driver_data;
97   state->tileram = auto_alloc_array_clear(machine, UINT16, 0x400);
98   state->bg_tilemap = tilemap_create(machine, get_bg_tile_info, tilemap_scan_rows, 8, 8, 40, 25);
99
100   state_save_register_global_pointer(machine, state->tileram, 0x400);
101}
102
103static WRITE8_HANDLER( mole_videoram_w )
104{
105   mole_state *state = (mole_state *)space->machine->driver_data;
106
107   state->tileram[offset] = data | (state->tile_bank << 8);
108   tilemap_mark_tile_dirty(state->bg_tilemap, offset);
109}
110
111static WRITE8_HANDLER( mole_tilebank_w )
112{
113   mole_state *state = (mole_state *)space->machine->driver_data;
114
115   state->tile_bank = data;
116   tilemap_mark_all_tiles_dirty(state->bg_tilemap);
117}
118
119static WRITE8_HANDLER( mole_flipscreen_w )
120{
121   flip_screen_set(space->machine, data & 0x01);
122}
123
124static VIDEO_UPDATE( mole )
125{
126   mole_state *state = (mole_state *)screen->machine->driver_data;
127
128   tilemap_draw(bitmap, cliprect, state->bg_tilemap, 0, 0);
129   return 0;
130}
131
132
133
134/*************************************
135 *
136 *  Memory handlers
137 *
138 *************************************/
139
62140static READ8_HANDLER( mole_protection_r )
63141{
64142
r7500r7501
109187}
110188
111189
190/*************************************
191 *
192 *  Address maps
193 *
194 *************************************/
195
112196static ADDRESS_MAP_START( mole_map, ADDRESS_SPACE_PROGRAM, 8 )
113197   AM_RANGE(0x0000, 0x03ff) AM_RAM
114198   AM_RANGE(0x0800, 0x08ff) AM_READ(mole_protection_r)
r7500r7501
128212ADDRESS_MAP_END
129213
130214
215/*************************************
216 *
217 *  Input ports
218 *
219 *************************************/
220
131221static INPUT_PORTS_START( mole )
132222   PORT_START("DSW")   /* 0x8d00 */
133223   PORT_DIPNAME( 0x01, 0x00, "Round Points" )
r7500r7501
181271INPUT_PORTS_END
182272
183273
274/*************************************
275 *
276 *  Graphics definitions
277 *
278 *************************************/
279
184280static const gfx_layout tile_layout =
185281{
186282   8,8,   /* character size */
r7500r7501
199295GFXDECODE_END
200296
201297
298/*************************************
299 *
300 *  Machine driver
301 *
302 *************************************/
303
304static MACHINE_START( mole )
305{
306   mole_state *state = (mole_state *)machine->driver_data;
307
308   state_save_register_global(machine, state->tile_bank);
309}
310
311static MACHINE_RESET( mole )
312{
313   mole_state *state = (mole_state *)machine->driver_data;
314
315   state->tile_bank = 0;
316}
317
202318static MACHINE_DRIVER_START( mole )
203   // basic machine hardware
319
320   /* driver data */
321   MDRV_DRIVER_DATA(mole_state)
322
323   /* basic machine hardware */
204324   MDRV_CPU_ADD("maincpu", M6502, 4000000) // ???
205325   MDRV_CPU_PROGRAM_MAP(mole_map)
206326   MDRV_CPU_VBLANK_INT("screen", irq0_line_hold)
207327
208   // video hardware
328   MDRV_MACHINE_START(mole)
329   MDRV_MACHINE_RESET(mole)
209330
331   /* video hardware */
210332   MDRV_SCREEN_ADD("screen", RASTER)
211333   MDRV_SCREEN_REFRESH_RATE(60)
212334   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(0))
r7500r7501
221343   MDRV_VIDEO_START(mole)
222344   MDRV_VIDEO_UPDATE(mole)
223345
224   // sound hardware
346   /* sound hardware */
225347   MDRV_SPEAKER_STANDARD_MONO("mono")
226348
227349   MDRV_SOUND_ADD("aysnd", AY8910, 2000000)
r7500r7501
229351MACHINE_DRIVER_END
230352
231353
354/*************************************
355 *
356 *  ROM definition(s)
357 *
358 *************************************/
359
232360ROM_START( mole ) // ALL ROMS ARE 2732
233361   ROM_REGION( 0x10000, "maincpu", 0 )   // 64k for 6502 code
234362   ROM_LOAD( "m3a.5h",   0x5000, 0x1000, CRC(5fbbdfef) SHA1(8129e90a05b3ca50f47f7610eec51c16c8609590) )
r7500r7501
245373ROM_END
246374
247375
248GAME( 1982, mole, 0, mole, mole, 0, ROT0, "Yachiyo Electronics, Ltd.", "Mole Attack", 0 )
376/*************************************
377 *
378 *  Game driver(s)
379 *
380 *************************************/
381
382GAME( 1982, mole, 0, mole, mole, 0, ROT0, "Yachiyo Electronics, Ltd.", "Mole Attack", GAME_SUPPORTS_SAVE )
src/mame/drivers/dynadice.c
r7500r7501
3737#include "sound/ay8910.h"
3838
3939
40typedef struct _dynadice_state dynadice_state;
41struct _dynadice_state
40class dynadice_state
4241{
42public:
43   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, dynadice_state(machine)); }
44
45   dynadice_state(running_machine &machine) { }
46
4347   /* memory pointers */
4448   UINT8 *  videoram;
4549//  UINT8 *  nvram;     // currently this uses generic nvram handling
src/mame/drivers/jangou.c
r7500r7501
3333
3434#define MASTER_CLOCK   XTAL_19_968MHz
3535
36typedef struct _jangou_state jangou_state;
37struct _jangou_state
36class jangou_state
3837{
38public:
39   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, jangou_state(machine)); }
40
41   jangou_state(running_machine &machine) { }
42
3943   /* video-related */
4044   UINT8        *blit_buffer;
4145   UINT8        pen_data[0x10];
src/mame/drivers/namcos21.c
r7500r7501
331331
332332
333333#define DSP_BUF_MAX (4096*12)
334typedef struct _dsp_state dsp_state;
335struct _dsp_state
334struct dsp_state
336335{
337336   unsigned masterSourceAddr;
338337   UINT16 slaveInputBuffer[DSP_BUF_MAX];
src/mame/drivers/ssingles.c
r7500r7501
150150#define NUM_PENS (4*8)
151151#define VMEM_SIZE 0x100
152152
153typedef struct _ssingles_state ssingles_state;
154struct _ssingles_state
153class ssingles_state
155154{
155public:
156   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, ssingles_state(machine)); }
157
158   ssingles_state(running_machine &machine) { }
159
156160   UINT8 *videoram;
157161   UINT8 *colorram;
158162   UINT8 prot_data;
src/mame/drivers/sub.c
r7500r7501
112112
113113#define MASTER_CLOCK         XTAL_18_432MHz
114114
115typedef struct _sub_state sub_state;
116struct _sub_state
115class sub_state
117116{
117public:
118   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, sub_state(machine)); }
119
120   sub_state(running_machine &machine) { }
121
118122   UINT8* vid;
119123   UINT8* attr;
120124   UINT8* scrolly;
src/mame/drivers/skyarmy.c
r7500r7501
2424#include "cpu/z80/z80.h"
2525#include "sound/ay8910.h"
2626
27typedef struct _skyarmy_state skyarmy_state;
28struct _skyarmy_state
27class skyarmy_state
2928{
29public:
30   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, skyarmy_state(machine)); }
31
32   skyarmy_state(running_machine &machine) { }
33
3034   UINT8 *spriteram;
3135   UINT8 *videoram;
3236   UINT8 *colorram;
src/mame/drivers/suprgolf.c
r7500r7501
2424#include "sound/2203intf.h"
2525#include "sound/msm5205.h"
2626
27typedef struct _suprgolf_state suprgolf_state;
28struct _suprgolf_state
27class suprgolf_state
2928{
29public:
30   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, suprgolf_state(machine)); }
31
32   suprgolf_state(running_machine &machine) { }
33
3034   tilemap_t *tilemap;
3135   UINT8 *videoram;
3236   UINT8 *paletteram;
src/mame/drivers/adp.c
r7500r7501
152152#include "machine/microtch.h"
153153#include "machine/68681.h"
154154
155typedef struct _adp_state adp_state;
156struct _adp_state
155class adp_state
157156{
157public:
158   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, adp_state(machine)); }
159
160   adp_state(running_machine &machine) { }
161
158162   /* misc */
159163   UINT8 mux_data;
160164   UINT8 register_active;
r7500r7501
714718
715719   MDRV_DUART68681_ADD( "duart68681", XTAL_8_664MHz / 2, skattv_duart68681_config )
716720
721   MDRV_MACHINE_START(skattv)
722   MDRV_MACHINE_RESET(skattv)
723
717724   MDRV_SCREEN_ADD("screen", RASTER)
718725   MDRV_SCREEN_REFRESH_RATE(60)
719726   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(2500))
src/mame/drivers/mcatadv.c
r7500r7501
141141#include "sound/2610intf.h"
142142#include "includes/mcatadv.h"
143143
144UINT16* mcatadv_videoram1, *mcatadv_videoram2;
145UINT16* mcatadv_scroll, *mcatadv_scroll2;
146UINT16* mcatadv_vidregs;
147144
148
149145/*** Main CPU ***/
150146
151147static WRITE16_HANDLER( mcat_soundlatch_w )
152148{
149   mcatadv_state *state = (mcatadv_state *)space->machine->driver_data;
150
153151   soundlatch_w(space, 0, data);
154   cputag_set_input_line(space->machine, "soundcpu", INPUT_LINE_NMI, PULSE_LINE);
152   cpu_set_input_line(state->soundcpu, INPUT_LINE_NMI, PULSE_LINE);
155153}
156154
157155#if 0 // mcat only.. install read handler?
r7500r7501
169167
170168static READ16_HANDLER( mcat_wd_r )
171169{
172   watchdog_reset_r(space,0);
170   watchdog_reset_r(space, 0);
173171   return 0xc00;
174172}
175173
r7500r7501
180178
181179//  AM_RANGE(0x180018, 0x18001f) AM_READNOP // ?
182180
183   AM_RANGE(0x200000, 0x200005) AM_RAM AM_BASE(&mcatadv_scroll)
184   AM_RANGE(0x300000, 0x300005) AM_RAM AM_BASE(&mcatadv_scroll2)
181   AM_RANGE(0x200000, 0x200005) AM_RAM AM_BASE_MEMBER(mcatadv_state, scroll1)
182   AM_RANGE(0x300000, 0x300005) AM_RAM AM_BASE_MEMBER(mcatadv_state, scroll2)
185183
186   AM_RANGE(0x400000, 0x401fff) AM_RAM_WRITE(mcatadv_videoram1_w) AM_BASE(&mcatadv_videoram1) // Tilemap 0
187   AM_RANGE(0x500000, 0x501fff) AM_RAM_WRITE(mcatadv_videoram2_w) AM_BASE(&mcatadv_videoram2) // Tilemap 1
184   AM_RANGE(0x400000, 0x401fff) AM_RAM_WRITE(mcatadv_videoram1_w) AM_BASE_MEMBER(mcatadv_state, videoram1) // Tilemap 0
185   AM_RANGE(0x500000, 0x501fff) AM_RAM_WRITE(mcatadv_videoram2_w) AM_BASE_MEMBER(mcatadv_state, videoram2) // Tilemap 1
188186
189187   AM_RANGE(0x600000, 0x601fff) AM_RAM_WRITE(paletteram16_xGGGGGRRRRRBBBBB_word_w) AM_BASE_GENERIC(paletteram)
190188   AM_RANGE(0x602000, 0x602fff) AM_RAM // Bigger than needs to be?
191189
192   AM_RANGE(0x700000, 0x707fff) AM_RAM AM_BASE_SIZE_GENERIC(spriteram) // Sprites, two halves for double buffering
190   AM_RANGE(0x700000, 0x707fff) AM_RAM AM_BASE_SIZE_MEMBER(mcatadv_state, spriteram, spriteram_size) // Sprites, two halves for double buffering
193191   AM_RANGE(0x708000, 0x70ffff) AM_RAM // Tests more than is needed?
194192
195193   AM_RANGE(0x800000, 0x800001) AM_READ_PORT("P1")
r7500r7501
198196   AM_RANGE(0xa00000, 0xa00001) AM_READ_PORT("DSW1")
199197   AM_RANGE(0xa00002, 0xa00003) AM_READ_PORT("DSW2")
200198
201   AM_RANGE(0xb00000, 0xb0000f) AM_RAM AM_BASE(&mcatadv_vidregs)
199   AM_RANGE(0xb00000, 0xb0000f) AM_RAM AM_BASE_MEMBER(mcatadv_state, vidregs)
202200
203201   AM_RANGE(0xb00018, 0xb00019) AM_WRITE(watchdog_reset16_w) // NOST Only
204202   AM_RANGE(0xb0001e, 0xb0001f) AM_READ(mcat_wd_r) // MCAT Only
205   AM_RANGE(0xc00000, 0xc00001) AM_READWRITE(soundlatch2_word_r,mcat_soundlatch_w)
203   AM_RANGE(0xc00000, 0xc00001) AM_READWRITE(soundlatch2_word_r, mcat_soundlatch_w)
206204ADDRESS_MAP_END
207205
208206/*** Sound ***/
209207
210208static WRITE8_HANDLER ( mcatadv_sound_bw_w )
211209{
212   UINT8 *rom = memory_region(space->machine, "soundcpu") + 0x10000;
213
214   memory_set_bankptr(space->machine, "bank1",rom + data * 0x4000);
210   memory_set_bank(space->machine, "bank1", data);
215211}
216212
217213
r7500r7501
420416/* Stolen from Psikyo.c */
421417static void sound_irq( running_device *device, int irq )
422418{
423   cputag_set_input_line(device->machine, "soundcpu", 0, irq ? ASSERT_LINE : CLEAR_LINE);
419   mcatadv_state *state = (mcatadv_state *)device->machine->driver_data;
420   cpu_set_input_line(state->soundcpu, 0, irq ? ASSERT_LINE : CLEAR_LINE);
424421}
422
425423static const ym2610_interface mcatadv_ym2610_interface =
426424{
427425   sound_irq   /* irq */
428426};
429427
430428
429static MACHINE_START( mcatadv )
430{
431   mcatadv_state *state = (mcatadv_state *)machine->driver_data;
432   UINT8 *ROM = memory_region(machine, "soundcpu");
433
434   memory_configure_bank(machine, "bank1", 0, 8, &ROM[0x10000], 0x4000);
435   memory_set_bank(machine, "bank1", 1);
436
437   state->maincpu = devtag_get_device(machine, "maincpu");
438   state->soundcpu = devtag_get_device(machine, "soundcpu");
439
440   state_save_register_global(machine, state->palette_bank1);
441   state_save_register_global(machine, state->palette_bank2);
442}
443
431444static MACHINE_DRIVER_START( mcatadv )
432445
446   /* driver data */
447   MDRV_DRIVER_DATA(mcatadv_state)
448
433449   /* basic machine hardware */
434450   MDRV_CPU_ADD("maincpu", M68000, XTAL_16MHz) /* verified on pcb */
435451   MDRV_CPU_PROGRAM_MAP(mcatadv_map)
r7500r7501
439455   MDRV_CPU_PROGRAM_MAP(mcatadv_sound_map)
440456   MDRV_CPU_IO_MAP(mcatadv_sound_io_map)
441457
458   MDRV_MACHINE_START(mcatadv)
459
442460   /* video hardware */
443461   MDRV_SCREEN_ADD("screen", RASTER)
444462   MDRV_SCREEN_REFRESH_RATE(60)
r7500r7501
476494MACHINE_DRIVER_END
477495
478496
479static DRIVER_INIT( mcatadv )
480{
481   UINT8 *z80rom = memory_region(machine, "soundcpu") + 0x10000;
482
483   memory_set_bankptr(machine, "bank1", z80rom + 0x4000);
484}
485
486
487497ROM_START( mcatadv )
488498   ROM_REGION( 0x100000, "maincpu", 0 ) /* M68000 */
489499   ROM_LOAD16_BYTE( "mca-u30e", 0x00000, 0x80000, CRC(c62fbb65) SHA1(39a30a165d4811141db8687a4849626bef8e778e) )
r7500r7501
662672   ROM_LOAD( "nossn-00.u53", 0x00000, 0x100000, CRC(3bd1bcbc) SHA1(1bcad43792e985402db4eca122676c2c555f3313) )
663673ROM_END
664674
665GAME( 1993, mcatadv,  0,       mcatadv, mcatadv, mcatadv, ROT0,   "Wintechno", "Magical Cat Adventure", GAME_NO_COCKTAIL )
666GAME( 1993, mcatadvj, mcatadv, mcatadv, mcatadv, mcatadv, ROT0,   "Wintechno", "Magical Cat Adventure (Japan)", GAME_NO_COCKTAIL )
667GAME( 1993, catt,     mcatadv, mcatadv, mcatadv, mcatadv, ROT0,   "Wintechno", "Catt (Japan)", GAME_NO_COCKTAIL )
668GAME( 1993, nost,     0,       nost,    nost,    mcatadv, ROT270, "Face",      "Nostradamus", GAME_NO_COCKTAIL )
669GAME( 1993, nostj,    nost,    nost,    nost,    mcatadv, ROT270, "Face",      "Nostradamus (Japan)", GAME_NO_COCKTAIL )
670GAME( 1993, nostk,    nost,    nost,    nost,    mcatadv, ROT270, "Face",      "Nostradamus (Korea)", GAME_NO_COCKTAIL )
675
676GAME( 1993, mcatadv,  0,       mcatadv, mcatadv, 0, ROT0,   "Wintechno", "Magical Cat Adventure", GAME_NO_COCKTAIL | GAME_SUPPORTS_SAVE )
677GAME( 1993, mcatadvj, mcatadv, mcatadv, mcatadv, 0, ROT0,   "Wintechno", "Magical Cat Adventure (Japan)", GAME_NO_COCKTAIL | GAME_SUPPORTS_SAVE )
678GAME( 1993, catt,     mcatadv, mcatadv, mcatadv, 0, ROT0,   "Wintechno", "Catt (Japan)", GAME_NO_COCKTAIL | GAME_SUPPORTS_SAVE )
679GAME( 1993, nost,     0,       nost,    nost,    0, ROT270, "Face",      "Nostradamus", GAME_NO_COCKTAIL | GAME_SUPPORTS_SAVE )
680GAME( 1993, nostj,    nost,    nost,    nost,    0, ROT270, "Face",      "Nostradamus (Japan)", GAME_NO_COCKTAIL | GAME_SUPPORTS_SAVE )
681GAME( 1993, nostk,    nost,    nost,    nost,    0, ROT270, "Face",      "Nostradamus (Korea)", GAME_NO_COCKTAIL | GAME_SUPPORTS_SAVE )
src/mame/drivers/toaplan2.c
r7500r7501
52575257   ROM_LOAD( "rom-6.bin", 0x040000, 0x100000, CRC(2a1c2426) SHA1(8abc3688ffc5ebb94b8d5118d4fa0908f07fe791) )
52585258ROM_END
52595259
5260/* Version A is older, might have been only released in Japan? */
5260/* Version A is older, might have been only released in Japan and Taiwan? */
52615261ROM_START( batridja )
52625262   ROM_REGION( 0x200000, "maincpu", 0 )         /* Main 68k code */
52635263   ROM_LOAD16_BYTE( "prg0.bin", 0x000000, 0x080000, CRC(f93ea27c) SHA1(41023c2ee1efd70b5aa9c70e1ddd9e5c3d51d68a) )
r7500r7501
52825282   ROM_LOAD( "rom-6.bin", 0x040000, 0x100000, CRC(2a1c2426) SHA1(8abc3688ffc5ebb94b8d5118d4fa0908f07fe791) )
52835283ROM_END
52845284
5285ROM_START( batridta )
5286   ROM_REGION( 0x200000, "maincpu", 0 )         /* Main 68k code */
5287   ROM_LOAD16_BYTE( "u22.bin",  0x000000, 0x080000, CRC(b135820e) SHA1(c222887d18a0a3ea0fcc973b95b29d69c86f7ec3) )
5288   ROM_LOAD16_BYTE( "u23.bin",  0x000001, 0x080000, CRC(8ae7f592) SHA1(8a20ebf85eca621f578d2302c3a3988647b077a7) )
5289   ROM_LOAD16_BYTE( "prg2.u21", 0x100000, 0x080000, CRC(bdaa5fbf) SHA1(abd72ac633c0c8e7b4b1d7902c0d6e014ba995fe) )
5290   ROM_LOAD16_BYTE( "prg3.u24", 0x100001, 0x080000, CRC(7aa9f941) SHA1(99bdbad7a96d461073b06a53c50fc57c2fd6fc6d) )
52855291
5292   ROM_REGION( 0x48000, "audiocpu", 0 )         /* Sound Z80 code + bank */
5293   ROM_LOAD( "snd.u77", 0x00000, 0x08000, CRC(56682696) SHA1(a372450d9a6d535123dfc31d8116074b168ab646) )
5294   ROM_CONTINUE(        0x10000, 0x38000 )
52865295
5296   ROM_REGION( 0x1000000, "gfx1", 0 )
5297   ROM_LOAD( "rom-1.bin", 0x000000, 0x400000, CRC(0df69ca2) SHA1(49670347ebd7e1067ff988cf842b275b7ee7b5f7) )
5298   ROM_LOAD( "rom-3.bin", 0x400000, 0x400000, CRC(60167d38) SHA1(fd2429808c59ef51fd5f5db84ea89a8dc504186e) )
5299   ROM_LOAD( "rom-2.bin", 0x800000, 0x400000, CRC(1bfea593) SHA1(ce06dc3097ae56b0df56d104bbf7efc9b5d968d4) )
5300   ROM_LOAD( "rom-4.bin", 0xc00000, 0x400000, CRC(bee03c94) SHA1(5bc1e6769c42857c03456426b502fcb86a114f19) )
52875301
5302   ROM_REGION( 0x140000, "oki1", 0 )      /* ADPCM Samples 1 */
5303   ROM_LOAD( "rom-5.bin", 0x040000, 0x100000, CRC(4274daf6) SHA1(85557b4707d529e5914f03c7a856864f5c24950e) )
5304
5305   ROM_REGION( 0x140000, "oki2", 0 )      /* ADPCM Samples 2 */
5306   ROM_LOAD( "rom-6.bin", 0x040000, 0x100000, CRC(2a1c2426) SHA1(8abc3688ffc5ebb94b8d5118d4fa0908f07fe791) )
5307ROM_END
5308
5309
5310
52885311/*
52895312Battle Bakraid
52905313Raizing/8ing, 1999
r7500r7501
54665489GAME( 1998, batridj,  batrid,   batrider, batridrj, batrider, ROT270, "Raizing / Eighting", "Armed Police Batrider - B Version (Japan) (Fri Feb 13 1998)", GAME_SUPPORTS_SAVE )
54675490GAME( 1998, batridk,  batrid,   batrider, batrider, batrider, ROT270, "Raizing / Eighting", "Armed Police Batrider (Korea) (Fri Feb 13 1998)", GAME_SUPPORTS_SAVE )
54685491// version A is older code
5469GAME( 1998, batridja, batrid,   batrider, batridrj, batrider, ROT270, "Raizing / Eighting", "Armed Police Batrider (Japan) (Mon Dec 22 1997)", GAME_SUPPORTS_SAVE )
5492GAME( 1998, batridja, batrid,   batrider, batridrj, batrider, ROT270, "Raizing / Eighting", "Armed Police Batrider - A Version (Japan) (Mon Dec 22 1997)", GAME_SUPPORTS_SAVE )
5493GAME( 1998, batridta, batrid,   batrider, batridrj, batrider, ROT270, "Raizing / Eighting", "Armed Police Batrider - A Version (Taiwan) (Mon Dec 22 1997)", GAME_SUPPORTS_SAVE )
54705494
54715495// Battle Bakraid
54725496// the 'unlimited' version is a newer revision of the code.
src/mame/drivers/munchmo.c
r7500r7501
2828#include "deprecat.h"
2929#include "cpu/z80/z80.h"
3030#include "sound/ay8910.h"
31#include "includes/munchmo.h"
3132
32extern UINT8 *mnchmobl_vreg;
33extern UINT8 *mnchmobl_status_vram;
34extern UINT8 *mnchmobl_sprite_xpos;
35extern UINT8 *mnchmobl_sprite_attr;
36extern UINT8 *mnchmobl_sprite_tile;
3733
38PALETTE_INIT( mnchmobl );
39VIDEO_START( mnchmobl );
40WRITE8_HANDLER( mnchmobl_palette_bank_w );
41WRITE8_HANDLER( mnchmobl_flipscreen_w );
42VIDEO_UPDATE( mnchmobl );
34/*************************************
35 *
36 *  Memory handlers
37 *
38 *************************************/
4339
44
45/***************************************************************************/
46
47static int mnchmobl_nmi_enable = 0;
48
4940static WRITE8_HANDLER( mnchmobl_nmi_enable_w )
5041{
51   mnchmobl_nmi_enable = data;
42   munchmo_state *state = (munchmo_state *)space->machine->driver_data;
43   state->nmi_enable = data;
5244}
5345
5446static INTERRUPT_GEN( mnchmobl_interrupt )
5547{
56   static int which;
57   which = !which;
58   if( which ) cpu_set_input_line(device, 0, HOLD_LINE);
59   else if( mnchmobl_nmi_enable ) cpu_set_input_line(device, INPUT_LINE_NMI, PULSE_LINE);
48   munchmo_state *state = (munchmo_state *)device->machine->driver_data;
49   state->which = !state->which;
50
51   if (state->which)
52      cpu_set_input_line(device, 0, HOLD_LINE);
53   else if (state->nmi_enable)
54      cpu_set_input_line(device, INPUT_LINE_NMI, PULSE_LINE);
6055}
6156
6257static WRITE8_HANDLER( mnchmobl_soundlatch_w )
6358{
64   soundlatch_w( space, offset, data );
65   cputag_set_input_line(space->machine, "audiocpu", 0, HOLD_LINE );
59   munchmo_state *state = (munchmo_state *)space->machine->driver_data;
60
61   soundlatch_w(space, offset, data);
62   cpu_set_input_line(state->audiocpu, 0, HOLD_LINE );
6663}
6764
6865static WRITE8_HANDLER( sound_nmi_ack_w )
6966{
70   cputag_set_input_line(space->machine, "audiocpu", INPUT_LINE_NMI, CLEAR_LINE);
67   munchmo_state *state = (munchmo_state *)space->machine->driver_data;
68   cpu_set_input_line(state->audiocpu, INPUT_LINE_NMI, CLEAR_LINE);
7169}
7270
7371
72/*************************************
73 *
74 *  Address maps
75 *
76 *************************************/
77
7478static ADDRESS_MAP_START( mnchmobl_map, ADDRESS_SPACE_PROGRAM, 8 )
7579   AM_RANGE(0x0000, 0x3fff) AM_ROM
7680   AM_RANGE(0x8000, 0x83ff) AM_RAM
77   AM_RANGE(0xa000, 0xa3ff) AM_MIRROR(0x0400) AM_RAM AM_BASE(&mnchmobl_sprite_xpos)
78   AM_RANGE(0xa800, 0xabff) AM_MIRROR(0x0400) AM_RAM AM_BASE(&mnchmobl_sprite_tile)
79   AM_RANGE(0xb000, 0xb3ff) AM_MIRROR(0x0400) AM_RAM AM_BASE(&mnchmobl_sprite_attr)
80   AM_RANGE(0xb800, 0xb8ff) AM_MIRROR(0x0100) AM_RAM AM_BASE_GENERIC(videoram)
81   AM_RANGE(0xa000, 0xa3ff) AM_MIRROR(0x0400) AM_RAM AM_BASE_MEMBER(munchmo_state, sprite_xpos)
82   AM_RANGE(0xa800, 0xabff) AM_MIRROR(0x0400) AM_RAM AM_BASE_MEMBER(munchmo_state, sprite_tile)
83   AM_RANGE(0xb000, 0xb3ff) AM_MIRROR(0x0400) AM_RAM AM_BASE_MEMBER(munchmo_state, sprite_attr)
84   AM_RANGE(0xb800, 0xb8ff) AM_MIRROR(0x0100) AM_RAM AM_BASE_MEMBER(munchmo_state, videoram)
8185   AM_RANGE(0xbaba, 0xbaba) AM_WRITENOP /* ? */
82   AM_RANGE(0xbc00, 0xbc7f) AM_RAM AM_BASE(&mnchmobl_status_vram)
86   AM_RANGE(0xbc00, 0xbc7f) AM_RAM AM_BASE_MEMBER(munchmo_state, status_vram)
8387   AM_RANGE(0xbe00, 0xbe00) AM_WRITE(mnchmobl_soundlatch_w)
8488   AM_RANGE(0xbe01, 0xbe01) AM_WRITE(mnchmobl_palette_bank_w)
8589   AM_RANGE(0xbe02, 0xbe02) AM_READ_PORT("DSW1")
r7500r7501
8993   AM_RANGE(0xbe31, 0xbe31) AM_WRITENOP /* ? */
9094   AM_RANGE(0xbe41, 0xbe41) AM_WRITE(mnchmobl_flipscreen_w)
9195   AM_RANGE(0xbe61, 0xbe61) AM_WRITE(mnchmobl_nmi_enable_w) /* ENI 1-10C */
92   AM_RANGE(0xbf00, 0xbf07) AM_WRITEONLY AM_BASE(&mnchmobl_vreg) /* MY0 1-8C */
96   AM_RANGE(0xbf00, 0xbf07) AM_WRITEONLY AM_BASE_MEMBER(munchmo_state, vreg) /* MY0 1-8C */
9397   AM_RANGE(0xbf01, 0xbf01) AM_READ_PORT("SYSTEM")
9498   AM_RANGE(0xbf02, 0xbf02) AM_READ_PORT("P1")
9599   AM_RANGE(0xbf03, 0xbf03) AM_READ_PORT("P2")
r7500r7501
109113ADDRESS_MAP_END
110114
111115
116/*************************************
117 *
118 *  Input ports
119 *
120 *************************************/
121
112122static INPUT_PORTS_START( mnchmobl )
113123   PORT_START("SYSTEM")
114124   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_COIN1 )
r7500r7501
199209   PORT_DIPSETTING(    0x80, DEF_STR( Yes ) )
200210INPUT_PORTS_END
201211
212/*************************************
213 *
214 *  Graphics definitions
215 *
216 *************************************/
217
202218static const gfx_layout char_layout =
203219{
204220   8,8,
r7500r7501
268284   GFXDECODE_ENTRY( "gfx4", 0,      sprite_layout2, 128, 16 )   /* colors 128-255 */
269285GFXDECODE_END
270286
287/*************************************
288 *
289 *  Machine driver
290 *
291 *************************************/
292
293static MACHINE_START( munchmo )
294{
295   munchmo_state *state = (munchmo_state *)machine->driver_data;
296
297   state->maincpu = devtag_get_device(machine, "maincpu");
298   state->audiocpu = devtag_get_device(machine, "audiocpu");
299
300   state_save_register_global(machine, state->palette_bank);
301   state_save_register_global(machine, state->flipscreen);
302   state_save_register_global(machine, state->nmi_enable);
303   state_save_register_global(machine, state->which);
304}
305
306static MACHINE_RESET( munchmo )
307{
308   munchmo_state *state = (munchmo_state *)machine->driver_data;
309
310   state->palette_bank = 0;
311   state->flipscreen = 0;
312   state->nmi_enable = 0;
313   state->which = 0;
314}
315
271316static MACHINE_DRIVER_START( mnchmobl )
272317
318   /* driver data */
319   MDRV_DRIVER_DATA(munchmo_state)
320
273321   /* basic machine hardware */
274322   MDRV_CPU_ADD("maincpu", Z80, XTAL_15MHz/4) /* ? */
275323   MDRV_CPU_PROGRAM_MAP(mnchmobl_map)
r7500r7501
279327   MDRV_CPU_PROGRAM_MAP(sound_map)
280328   MDRV_CPU_VBLANK_INT("screen", nmi_line_assert)
281329
330   MDRV_MACHINE_START(munchmo)
331   MDRV_MACHINE_RESET(munchmo)
332
282333   /* video hardware */
283334   MDRV_SCREEN_ADD("screen", RASTER)
284335   MDRV_SCREEN_REFRESH_RATE(57)
r7500r7501
306357MACHINE_DRIVER_END
307358
308359
360/*************************************
361 *
362 *  ROM definition(s)
363 *
364 *************************************/
365
309366ROM_START( joyfulr )
310367   ROM_REGION( 0x10000, "maincpu", 0 ) /* 64k for CPUA */
311368   ROM_LOAD( "m1j.10e", 0x0000, 0x2000, CRC(1fe86e25) SHA1(e13abc20741dfd8a260f354efda3b3a25c820343) )
r7500r7501
363420ROM_END
364421
365422
366GAME( 1983, joyfulr,  0,        mnchmobl, mnchmobl, 0, ROT270, "SNK", "Joyful Road (Japan)", GAME_IMPERFECT_SOUND | GAME_NO_COCKTAIL )
367GAME( 1983, mnchmobl, joyfulr,  mnchmobl, mnchmobl, 0, ROT270, "SNK (Centuri license)", "Munch Mobile (US)", GAME_IMPERFECT_SOUND | GAME_NO_COCKTAIL )
423/*************************************
424 *
425 *  Game driver(s)
426 *
427 *************************************/
428
429GAME( 1983, joyfulr,  0,        mnchmobl, mnchmobl, 0, ROT270, "SNK", "Joyful Road (Japan)", GAME_IMPERFECT_SOUND | GAME_NO_COCKTAIL | GAME_SUPPORTS_SAVE )
430GAME( 1983, mnchmobl, joyfulr,  mnchmobl, mnchmobl, 0, ROT270, "SNK (Centuri license)", "Munch Mobile (US)", GAME_IMPERFECT_SOUND | GAME_NO_COCKTAIL | GAME_SUPPORTS_SAVE )
src/mame/drivers/boxer.c
r7500r7501
2020 *
2121 *************************************/
2222
23typedef struct _boxer_state boxer_state;
24struct _boxer_state
23class boxer_state
2524{
25public:
26   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, boxer_state(machine)); }
27
28   boxer_state(running_machine &machine) { }
29
2630   /* memory pointers */
2731   UINT8 * tile_ram;
2832   UINT8 * sprite_ram;
src/mame/drivers/cischeat.c
r7500r7501
227227static ADDRESS_MAP_START( bigrun_map, ADDRESS_SPACE_PROGRAM, 16 )
228228   AM_RANGE(0x000000, 0x07ffff) AM_ROM                                                   // ROM
229229   AM_RANGE(0x080000, 0x083fff) AM_READWRITE(bigrun_vregs_r, bigrun_vregs_w) AM_BASE(&megasys1_vregs)   // Vregs
230   AM_RANGE(0x084000, 0x087fff) AM_WRITEONLY                                       // Linking with other units
230   AM_RANGE(0x084000, 0x087fff) AM_RAM                                       // Linking with other units
231231   AM_RANGE(0x088000, 0x08bfff) AM_READWRITE(sharedram2_r, sharedram2_w) AM_BASE(&sharedram2)         // Sharedram with sub CPU#2
232232   AM_RANGE(0x08c000, 0x08ffff) AM_READWRITE(sharedram1_r, sharedram1_w) AM_BASE(&sharedram1)         // Sharedram with sub CPU#1
233233
r7500r7501
623623
624624static ADDRESS_MAP_START( bigrun_map3, ADDRESS_SPACE_PROGRAM, 16 )
625625   AM_RANGE(0x000000, 0x03ffff) AM_ROM                              // ROM
626   AM_RANGE(0x040000, 0x047fff) AM_READWRITE(sharedram2_r, sharedram1_w)   // Shared RAM (with Main CPU)
626   AM_RANGE(0x040000, 0x047fff) AM_READWRITE(sharedram2_r, sharedram2_w)   // Shared RAM (with Main CPU)
627627   AM_RANGE(0x080000, 0x0807ff) AM_RAM AM_BASE(&cischeat_roadram[1])      // Road RAM
628628   AM_RANGE(0x0c0000, 0x0c3fff) AM_RAM                              // RAM
629629ADDRESS_MAP_END
r7500r7501
703703   AM_RANGE(0x040000, 0x040001) AM_READWRITE(soundlatch_word_r, bigrun_soundbank_w)   // From Main CPU
704704   AM_RANGE(0x060000, 0x060001) AM_WRITE(soundlatch2_word_w)                     // To Main CPU
705705   AM_RANGE(0x080000, 0x080003) AM_DEVREADWRITE8("ymsnd", ym2151_r, ym2151_w, 0x00ff)
706   AM_RANGE(0x0a0000, 0x0a0001) AM_DEVREADWRITE8("oki1", okim6295_r, okim6295_w, 0x00ff)
707   AM_RANGE(0x0c0000, 0x0c0001) AM_DEVREADWRITE8("oki2", okim6295_r, okim6295_w, 0x00ff)
706   AM_RANGE(0x0a0000, 0x0a0003) AM_DEVREADWRITE8("oki1", okim6295_r, okim6295_w, 0x00ff)
707   AM_RANGE(0x0c0000, 0x0c0003) AM_DEVREADWRITE8("oki2", okim6295_r, okim6295_w, 0x00ff)
708708   AM_RANGE(0x0f0000, 0x0fffff) AM_RAM                                       // RAM
709709ADDRESS_MAP_END
710710
src/mame/drivers/vicdual.c
r7500r7501
23642364   ROM_LOAD( "316-0042.u88", 0x0020, 0x0020, CRC(a1506b9d) SHA1(037c3db2ea40eca459e8acba9d1506dd28d72d10) )   /* sequence PROM */
23652365ROM_END
23662366
2367ROM_START( safaria ) // bootleg board, but possibly a legit alt revision
2368   ROM_REGION( 0x10000, "maincpu", 0 )
2369   ROM_LOAD( "hu1.22c",      0x0000, 0x0400, CRC(f27d5961) SHA1(9780e9659746c959206b8700598cfb3925ae7938) )
2370   ROM_LOAD( "hu2.20c",      0x0400, 0x0400, CRC(11a9cb59) SHA1(5132151a97146d973292b15284e4d58de9ee7cc6) )
2371   ROM_LOAD( "hu3.19c",      0x0800, 0x0400, CRC(4fe746cb) SHA1(b4b6eac78dd9a76c102994990c219ae832442cc1) )
2372   ROM_LOAD( "hu4.17c",      0x0c00, 0x0400, CRC(f0bad948) SHA1(5dda4513e96cfb0b6535184c611ac5832afbbfde) )
2373   ROM_LOAD( "hu5.16c",      0x1000, 0x0400, CRC(d994f98a) SHA1(a51db8b8975f1fa7ca3bae56d4d929b8d3d7bfb7) )
2374   ROM_LOAD( "hu6.15c",      0x1400, 0x0400, CRC(174b5964) SHA1(dfa88aaa572d4d46ffe3c8f247dbc370e624f5c4) )
2375   ROM_LOAD( "hu7.13c",      0x1800, 0x0400, CRC(3e94caa1) SHA1(520ae5924b970126c07368bba900b7603997c5cc) )
2376   ROM_LOAD( "hu8.12c",      0x1c00, 0x0400, CRC(a8a5dca0) SHA1(2424d9e3b4ed2c73b14ec0c26d63453fb4f7f6c2) )
2377   ROM_LOAD( "hu9.11c",      0x2000, 0x0400, CRC(0ace0939) SHA1(34704b836445628341fb6a77b1ebd47a76c5640d) )
2378   ROM_LOAD( "hu10.9c",      0x2400, 0x0400, CRC(9dae33ca) SHA1(91472e3b60ff055724ae574b182a450d2a00081c) )
23672379
2380   ROM_REGION( 0x0040, "user1", 0 )   /* timing PROMs */
2381   ROM_LOAD( "32.21e", 0x0000, 0x0020, CRC(e60a7960) SHA1(b8b8716e859c57c35310efc4594262afedb84823) )   /* control PROM */
2382   ROM_LOAD( "31.22e", 0x0020, 0x0020, CRC(a1506b9d) SHA1(037c3db2ea40eca459e8acba9d1506dd28d72d10) )   /* sequence PROM */
2383ROM_END
2384
2385
23682386ROM_START( frogs )
23692387   ROM_REGION( 0x10000, "maincpu", 0 )
23702388   ROM_LOAD( "316-119a.u48",     0x0000, 0x0400, CRC(b1d1fce4) SHA1(572015bede39b14526e93919b63b6d01ae38a09a) )
r7500r7501
32453263GAMEL(1977, depthch,  0,        depthch,  depthch,  0, ROT0,   "Gremlin", "Depthcharge", GAME_IMPERFECT_SOUND, layout_depthch )
32463264GAMEL(1977, depthcho, depthch,  depthch,  depthch,  0, ROT0,   "Gremlin", "Depthcharge (older)", GAME_IMPERFECT_SOUND, layout_depthch )
32473265GAME( 1977, subhunt,  depthch,  depthch,  depthch,  0, ROT0,   "Taito", "Sub Hunter", GAME_IMPERFECT_SOUND )
3248GAME( 1977, safari,   0,        safari,   safari,   0, ROT0,   "Gremlin", "Safari", GAME_NO_SOUND )
3266GAME( 1977, safari,   0,        safari,   safari,   0, ROT0,   "Gremlin", "Safari (set 1)", GAME_NO_SOUND )
3267GAME( 1977, safaria,  safari,   safari,   safari,   0, ROT0,   "Gremlin", "Safari (set 2, bootleg?)", GAME_NO_SOUND ) // on a bootleg board, but seems a different code revision too
32493268GAME( 1978, frogs,    0,        frogs,    frogs,    0, ROT0,   "Gremlin", "Frogs", GAME_IMPERFECT_SOUND )
32503269GAME( 1979, sspaceat, 0,        sspaceat, sspaceat, 0, ROT270, "Sega", "Space Attack (upright set 1)", GAME_NO_SOUND )
32513270GAME( 1979, sspaceat2,sspaceat, sspaceat, sspaceat, 0, ROT270, "Sega", "Space Attack (upright set 2)", GAME_NO_SOUND )
src/mame/drivers/speglsht.c
r7500r7501
202202   return 0;
203203}
204204
205static READ32_HANDLER(irq_ack_clear)
206{
207   cputag_set_input_line(space->machine, "sub", R3000_IRQ4, CLEAR_LINE);
208   return 0;
209}
210
205211static ADDRESS_MAP_START( speglsht_mem, ADDRESS_SPACE_PROGRAM, 32 )
206212   AM_RANGE(0x00000000, 0x000fffff) AM_RAM
207213   AM_RANGE(0x01000000, 0x01007fff) AM_RAM //tested - STATIC RAM
r7500r7501
214220   AM_RANGE(0x01c00000, 0x01dfffff) AM_ROM AM_REGION("user2", 0)
215221   AM_RANGE(0x0a000000, 0x0a003fff) AM_READWRITE(shared_r, shared_w)
216222   AM_RANGE(0x1eff0000, 0x1eff001f) AM_RAM
217   AM_RANGE(0x1eff003c, 0x1eff003f) AM_READNOP //interrupt related
223   AM_RANGE(0x1eff003c, 0x1eff003f) AM_READ(irq_ack_clear)
218224   AM_RANGE(0x1fc00000, 0x1fdfffff) AM_ROM AM_REGION("user1", 0)
219225   AM_RANGE(0x2fc00000, 0x2fdfffff) AM_ROM AM_REGION("user1", 0) // mirror for interrupts
220226ADDRESS_MAP_END
r7500r7501
301307   &st0016_charram
302308};
303309
304 static INTERRUPT_GEN( irq4_gen )
305{
306   cpu_set_input_line(device, R3000_IRQ4, ASSERT_LINE);
307}
308
309310static const r3000_cpu_core config =
310311{
311312   0,
r7500r7501
329330   MDRV_CPU_ADD("sub", R3000LE, 25000000)
330331   MDRV_CPU_CONFIG(config)
331332   MDRV_CPU_PROGRAM_MAP(speglsht_mem)
332   MDRV_CPU_VBLANK_INT("screen", irq4_gen)
333   MDRV_CPU_VBLANK_INT("screen", irq4_line_assert)
333334
334335   MDRV_QUANTUM_TIME(HZ(6000))
335336   MDRV_MACHINE_RESET(speglsht)
src/mame/drivers/metro.c
r7500r7501
5050
5151Not dumped yet:
525294  Toride II
5394  Mouse Shooter GoGo (might be a prequel to Bang Bang Ball)
5354
5455To Do:
5556
src/mame/drivers/nightgal.c
r7500r7501
2424
2525#define MASTER_CLOCK   XTAL_19_968MHz
2626
27static UINT8 blit_raw_data[3];
28static UINT8 *blit_buffer;
29static UINT8 pen_data[0x10];
30static UINT8 pen_raw_data[0x10];
27class nightgal_state
28{
29public:
30   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, nightgal_state(machine)); }
3131
32   nightgal_state(running_machine &machine) { }
33
34   /* memory pointers */
35   UINT8 *    blit_buffer;
36
37   /* video-related */
38   UINT8 blit_raw_data[3];
39   UINT8 true_blit[7];
40   UINT8 pen_data[0x10];
41   UINT8 pen_raw_data[0x10];
42
43   /* misc */
44   UINT8 nsc_latch, z80_latch;
45   UINT8 mux_data;
46
47   /* devices */
48   running_device *maincpu;
49   running_device *subcpu;
50};
51
52
53
3254static READ8_HANDLER( blitter_status_r )
3355{
3456   return 0x80;
r7500r7501
3658
3759static VIDEO_START( nightgal )
3860{
39   blit_buffer = auto_alloc_array(machine, UINT8, 256*256);
61   nightgal_state *state = (nightgal_state *)machine->driver_data;
62   state->blit_buffer = auto_alloc_array(machine, UINT8, 256*256);
63
64   state_save_register_global_pointer(machine, state->blit_buffer, 256*256);
4065}
4166
4267static VIDEO_UPDATE( nightgal )
4368{
69   nightgal_state *state = (nightgal_state *)screen->machine->driver_data;
4470   int x, y;
4571
4672   for (y = cliprect->min_y; y <= cliprect->max_y; ++y)
4773   {
48      UINT8 *src = &blit_buffer[y * 512/2 + cliprect->min_x];
74      UINT8 *src = &state->blit_buffer[y * 512 / 2 + cliprect->min_x];
4975      UINT16 *dst = BITMAP_ADDR16(bitmap, y, cliprect->min_x);
5076
5177      for (x = cliprect->min_x; x <= cliprect->max_x; x += 2)
r7500r7501
6086   return 0;
6187}
6288
63static UINT8 nightgal_gfx_nibble(running_machine *machine,int niboffset)
89static UINT8 nightgal_gfx_nibble( running_machine *machine, int niboffset )
6490{
6591   UINT8 *blit_rom = memory_region(machine,"gfx1");
6692
67   if (niboffset&1)
93   if (niboffset & 1)
6894   {
69      return (blit_rom[(niboffset>>1)&0x1ffff] & 0xf0)>>4;
95      return (blit_rom[(niboffset >> 1) & 0x1ffff] & 0xf0) >> 4;
7096   }
7197   else
7298   {
73      return (blit_rom[(niboffset>>1)&0x1ffff] & 0x0f);
99      return (blit_rom[(niboffset >> 1) & 0x1ffff] & 0x0f);
74100   }
75101}
76102
77static void plot_nightgal_gfx_pixel(UINT8 pix, int x, int y)
103static void plot_nightgal_gfx_pixel( running_machine *machine, UINT8 pix, int x, int y )
78104{
79   if (y>=512) return;
80   if (x>=512) return;
81   if (y<0) return;
82   if (x<0) return;
105   nightgal_state *state = (nightgal_state *)machine->driver_data;
106   if (y >= 512) return;
107   if (x >= 512) return;
108   if (y < 0) return;
109   if (x < 0) return;
83110
84   if (x&1)
85   {
86      blit_buffer[(y*256)+(x>>1)] = (blit_buffer[(y*256)+(x>>1)] & 0x0f) | ((pix<<4) & 0xf0);
87   }
111   if (x & 1)
112      state->blit_buffer[(y * 256) + (x >> 1)] = (state->blit_buffer[(y * 256) + (x >> 1)] & 0x0f) | ((pix << 4) & 0xf0);
88113   else
89   {
90      blit_buffer[(y*256)+(x>>1)] = (blit_buffer[(y*256)+(x>>1)] & 0xf0) | (pix & 0x0f);
91   }
114      state->blit_buffer[(y * 256) + (x >> 1)] = (state->blit_buffer[(y * 256) + (x >> 1)] & 0xf0) | (pix & 0x0f);
92115}
93116
94117static WRITE8_HANDLER( nsc_true_blitter_w )
95118{
96   static UINT8 true_blit[7];
119   nightgal_state *state = (nightgal_state *)space->machine->driver_data;
120   int src, x, y, h, w, flipx;
121   state->true_blit[offset] = data;
97122
98   int src,x,y,h,w, flipx;
99   true_blit[offset] = data;
100
101123   /*trigger blitter write to ram,might not be correct...*/
102   if(offset == 5)
124   if (offset == 5)
103125   {
104      //printf("%02x %02x %02x %02x %02x %02x %02x\n",true_blit[0],true_blit[1],true_blit[2],true_blit[3],true_blit[4],true_blit[5],true_blit[6]);
105      w = (true_blit[4] & 0xff)+1;
106      h = (true_blit[5] & 0xff)+1;
107      src = ((true_blit[1]<<8)|(true_blit[0]<<0));
108      src |= (true_blit[6]&3)<<16;
126      //printf("%02x %02x %02x %02x %02x %02x %02x\n", state->true_blit[0], state->true_blit[1], state->true_blit[2], state->true_blit[3], state->true_blit[4], state->true_blit[5], state->true_blit[6]);
127      w = (state->true_blit[4] & 0xff) + 1;
128      h = (state->true_blit[5] & 0xff) + 1;
129      src = ((state->true_blit[1] << 8) | (state->true_blit[0] << 0));
130      src |= (state->true_blit[6] & 3) << 16;
109131
132      x = (state->true_blit[2] & 0xff);
133      y = (state->true_blit[3] & 0xff);
110134
111      x = (true_blit[2] & 0xff);
112      y = (true_blit[3] & 0xff);
113
114135      // lowest bit of src controls flipping / draw direction?
115      flipx=(true_blit[0] & 1);
136      flipx = (state->true_blit[0] & 1);
116137
117      if (!flipx) src += (w*h)-1;
118      else src -= (w*h)-1;
138      if (!flipx)
139         src += (w * h) - 1;
140      else
141         src -= (w * h) - 1;
119142
120143      {
121144         int count = 0;
122         int xcount,ycount;
123         for(ycount=0;ycount<h;ycount++)
145         int xcount, ycount;
146         for (ycount = 0; ycount < h; ycount++)
124147         {
125            for(xcount=0;xcount<w;xcount++)
148            for (xcount = 0; xcount < w; xcount++)
126149            {
127               int drawx = (x+xcount) & 0xff;
128               int drawy = (y+ycount) & 0xff;
129               UINT8 dat = nightgal_gfx_nibble(space->machine,src+count);
130               UINT8 cur_pen_hi = pen_data[(dat & 0xf0)>>4];
131               UINT8 cur_pen_lo = pen_data[(dat & 0x0f)>>0];
150               int drawx = (x + xcount) & 0xff;
151               int drawy = (y + ycount) & 0xff;
152               UINT8 dat = nightgal_gfx_nibble(space->machine, src + count);
153               UINT8 cur_pen_hi = state->pen_data[(dat & 0xf0) >> 4];
154               UINT8 cur_pen_lo = state->pen_data[(dat & 0x0f) >> 0];
132155
133               dat = cur_pen_lo | cur_pen_hi<<4;
156               dat = cur_pen_lo | (cur_pen_hi << 4);
134157
135               if((dat & 0xff) != 0)
136                  plot_nightgal_gfx_pixel(dat, drawx,drawy);
158               if ((dat & 0xff) != 0)
159                  plot_nightgal_gfx_pixel(space->machine, dat, drawx, drawy);
137160
138               if (!flipx)   count--;
139               else count++;
161               if (!flipx)
162                  count--;
163               else
164                  count++;
140165            }
141166         }
142167      }
r7500r7501
146171/* different register writes (probably a PAL line swapping).*/
147172static WRITE8_HANDLER( sexygal_nsc_true_blitter_w )
148173{
149   static UINT8 true_blit[7];
174   nightgal_state *state = (nightgal_state *)space->machine->driver_data;
175   int src, x, y, h, w, flipx;
176   state->true_blit[offset] = data;
150177
151   int src,x,y,h,w, flipx;
152   true_blit[offset] = data;
153
154178   /*trigger blitter write to ram,might not be correct...*/
155   if(offset == 6)
179   if (offset == 6)
156180   {
157      //printf("%02x %02x %02x %02x %02x %02x %02x\n",true_blit[0],true_blit[1],true_blit[2],true_blit[3],true_blit[4],true_blit[5],true_blit[6]);
158      w = (true_blit[5] & 0xff)+1;
159      h = (true_blit[6] & 0xff)+1;
160      src = ((true_blit[1]<<8)|(true_blit[0]<<0));
161      src |= (true_blit[2]&3)<<16;
181      //printf("%02x %02x %02x %02x %02x %02x %02x\n", state->true_blit[0], state->true_blit[1], state->true_blit[2], state->true_blit[3], state->true_blit[4], state->true_blit[5], state->true_blit[6]);
182      w = (state->true_blit[5] & 0xff) + 1;
183      h = (state->true_blit[6] & 0xff) + 1;
184      src = ((state->true_blit[1] << 8) | (state->true_blit[0] << 0));
185      src |= (state->true_blit[2] & 3) << 16;
162186
163187
164      x = (true_blit[3] & 0xff);
165      y = (true_blit[4] & 0xff);
188      x = (state->true_blit[3] & 0xff);
189      y = (state->true_blit[4] & 0xff);
166190
167191      // lowest bit of src controls flipping / draw direction?
168      flipx=(true_blit[0] & 1);
192      flipx = (state->true_blit[0] & 1);
169193
170      if (!flipx) src += (w*h)-1;
171      else src -= (w*h)-1;
194      if (!flipx)
195         src += (w * h) - 1;
196      else
197         src -= (w * h) - 1;
172198
173199      {
174200         int count = 0;
175         int xcount,ycount;
176         for(ycount=0;ycount<h;ycount++)
201         int xcount, ycount;
202         for (ycount = 0; ycount < h; ycount++)
177203         {
178            for(xcount=0;xcount<w;xcount++)
204            for (xcount = 0; xcount < w; xcount++)
179205            {
180               int drawx = (x+xcount) & 0xff;
181               int drawy = (y+ycount) & 0xff;
182               UINT8 dat = nightgal_gfx_nibble(space->machine,src+count);
183               UINT8 cur_pen_hi = pen_data[(dat & 0xf0)>>4];
184               UINT8 cur_pen_lo = pen_data[(dat & 0x0f)>>0];
206               int drawx = (x + xcount) & 0xff;
207               int drawy = (y + ycount) & 0xff;
208               UINT8 dat = nightgal_gfx_nibble(space->machine, src + count);
209               UINT8 cur_pen_hi = state->pen_data[(dat & 0xf0) >> 4];
210               UINT8 cur_pen_lo = state->pen_data[(dat & 0x0f) >> 0];
185211
186               dat = cur_pen_lo | cur_pen_hi<<4;
212               dat = cur_pen_lo | cur_pen_hi << 4;
187213
188               if((dat & 0xff) != 0)
189                  plot_nightgal_gfx_pixel(dat, drawx,drawy);
214               if ((dat & 0xff) != 0)
215                  plot_nightgal_gfx_pixel(space->machine, dat, drawx, drawy);
190216
191               if (!flipx)   count--;
192               else count++;
217               if (!flipx)
218                  count--;
219               else
220                  count++;
193221            }
194222         }
195         //printf("%02x %02x %02x %02x %02x %02x %02x\n",true_blit[0],true_blit[1],true_blit[2],true_blit[3],true_blit[4],true_blit[5],true_blit[6]);
196         //cputag_set_input_line(space->machine, "maincpu", INPUT_LINE_NMI, PULSE_LINE );
223         //cpu_set_input_line(state->maincpu, INPUT_LINE_NMI, PULSE_LINE );
197224      }
198225   }
199226}
r7500r7501
212239         2, resistances_b,  weights_b,  0, 0,
213240         0, 0, 0, 0, 0);
214241
215   for (i = 0;i < machine->config->total_colors; i++)
242   for (i = 0; i < machine->config->total_colors; i++)
216243   {
217244      int bit0, bit1, bit2;
218245      int r, g, b;
219246
220247      /* red component */
221      bit0 = (color_prom[i] >> 0) & 0x01;
222      bit1 = (color_prom[i] >> 1) & 0x01;
223      bit2 = (color_prom[i] >> 2) & 0x01;
248      bit0 = BIT(color_prom[i], 0);
249      bit1 = BIT(color_prom[i], 1);
250      bit2 = BIT(color_prom[i], 2);
224251      r = combine_3_weights(weights_rg, bit0, bit1, bit2);
225252
226253      /* green component */
227      bit0 = (color_prom[i] >> 3) & 0x01;
228      bit1 = (color_prom[i] >> 4) & 0x01;
229      bit2 = (color_prom[i] >> 5) & 0x01;
254      bit0 = BIT(color_prom[i], 3);
255      bit1 = BIT(color_prom[i], 4);
256      bit2 = BIT(color_prom[i], 5);
230257      g = combine_3_weights(weights_rg, bit0, bit1, bit2);
231258
232259      /* blue component */
233      bit0 = (color_prom[i] >> 6) & 0x01;
234      bit1 = (color_prom[i] >> 7) & 0x01;
260      bit0 = BIT(color_prom[i], 6);
261      bit1 = BIT(color_prom[i], 7);
235262      b = combine_2_weights(weights_b, bit0, bit1);
236263
237264      palette_set_color(machine, i, MAKE_RGB(r, g, b));
r7500r7501
261288-executes a wai (i.e. halt) opcode then expects to receive another irq...
262289*/
263290
264#define MAIN_Z80_RUN   if(offset == 2) z80_latch = 0x00
265#define MAIN_Z80_HALT  if(offset == 2) z80_latch = 0x80
266//#define SUB_NCS_RUN ncs_latch = 0x00
267//#define SUB_NCS_HALT ncs_latch = 0x80
291#define MAIN_Z80_RUN   if(offset == 2) state->z80_latch = 0x00
292#define MAIN_Z80_HALT  if(offset == 2) state->z80_latch = 0x80
293//#define SUB_NCS_RUN state->ncs_latch = 0x00
294//#define SUB_NCS_HALT state->ncs_latch = 0x80
268295
269static UINT8 nsc_latch,z80_latch;
270
271296static WRITE8_HANDLER( nsc_latch_w )
272297{
273   cputag_set_input_line(space->machine, "sub", 0, HOLD_LINE );
298   nightgal_state *state = (nightgal_state *)space->machine->driver_data;
299   cpu_set_input_line(state->subcpu, 0, HOLD_LINE );
274300}
275301
276302static READ8_HANDLER( nsc_latch_r )
277303{
278   return z80_latch;
304   nightgal_state *state = (nightgal_state *)space->machine->driver_data;
305   return state->z80_latch;
279306}
280307
281308static WRITE8_HANDLER( z80_latch_w )
282309{
283   nsc_latch = data;
310   nightgal_state *state = (nightgal_state *)space->machine->driver_data;
311   state->nsc_latch = data;
284312}
285313
286314static READ8_HANDLER( z80_latch_r )
287315{
288   return nsc_latch;
316   nightgal_state *state = (nightgal_state *)space->machine->driver_data;
317   return state->nsc_latch;
289318}
290319
291320/*z80 -> MCU video params*/
292321static WRITE8_HANDLER( blitter_w )
293322{
294   blit_raw_data[offset] = data;
323   nightgal_state *state = (nightgal_state *)space->machine->driver_data;
324   state->blit_raw_data[offset] = data;
295325   MAIN_Z80_HALT;
296326}
297327
298328static READ8_HANDLER( nsc_blit_r )
299329{
330   nightgal_state *state = (nightgal_state *)space->machine->driver_data;
300331   MAIN_Z80_RUN;
301   return blit_raw_data[offset];
332   return state->blit_raw_data[offset];
302333}
303334
304335static WRITE8_HANDLER( blit_vregs_w )
305336{
306   pen_raw_data[offset] = data;
337   nightgal_state *state = (nightgal_state *)space->machine->driver_data;
338   state->pen_raw_data[offset] = data;
307339}
308340
309341static READ8_HANDLER( blit_vregs_r )
310342{
311   return pen_raw_data[offset];
343   nightgal_state *state = (nightgal_state *)space->machine->driver_data;
344   return state->pen_raw_data[offset];
312345}
313346
314347static WRITE8_HANDLER( blit_true_vregs_w )
315348{
316   pen_data[offset] = data;
349   nightgal_state *state = (nightgal_state *)space->machine->driver_data;
350   state->pen_data[offset] = data;
317351}
318352
319353/********************************************
r7500r7501
322356*
323357********************************************/
324358
325static UINT8 mux_data;
326
327359static WRITE8_HANDLER( mux_w )
328360{
329   mux_data = ~data;
330//  printf("%02x\n",mux_data);
361   nightgal_state *state = (nightgal_state *)space->machine->driver_data;
362   state->mux_data = ~data;
363   //printf("%02x\n", state->mux_data);
331364}
332365
333366static READ8_DEVICE_HANDLER( input_1p_r )
334367{
335   static UINT8 cr_clear;
368   nightgal_state *state = (nightgal_state *)device->machine->driver_data;
369   UINT8 cr_clear = input_port_read(device->machine, "CR_CLEAR");
336370
337   cr_clear = input_port_read(device->machine, "CR_CLEAR");
338
339   switch(mux_data)
371   switch (state->mux_data)
340372   {
341373      case 0x01: return input_port_read(device->machine, "PL1_1") | cr_clear;
342374      case 0x02: return input_port_read(device->machine, "PL1_2") | cr_clear;
r7500r7501
345377      case 0x10: return input_port_read(device->machine, "PL1_5") | cr_clear;
346378      case 0x20: return input_port_read(device->machine, "PL1_6") | cr_clear;
347379   }
348//  printf("%04x\n",mux_data);
380   //printf("%04x\n", state->mux_data);
349381
350382   return (input_port_read(device->machine, "PL1_1") & input_port_read(device->machine, "PL1_2") & input_port_read(device->machine, "PL1_3") &
351          input_port_read(device->machine, "PL1_4") & input_port_read(device->machine, "PL1_5") & input_port_read(device->machine, "PL1_6")) | cr_clear;//input_port_read(device->machine, "PL1_0") && ;
383          input_port_read(device->machine, "PL1_4") & input_port_read(device->machine, "PL1_5") & input_port_read(device->machine, "PL1_6")) | cr_clear;
352384}
353385
354386static READ8_DEVICE_HANDLER( input_2p_r )
355387{
356   static UINT8 coin_port;
388   nightgal_state *state = (nightgal_state *)device->machine->driver_data;
389   UINT8 coin_port = input_port_read(device->machine, "COINS");
357390
358   coin_port = input_port_read(device->machine, "COINS");
359
360   switch(mux_data)
391   switch (state->mux_data)
361392   {
362393      case 0x01: return input_port_read(device->machine, "PL2_1") | coin_port;
363394      case 0x02: return input_port_read(device->machine, "PL2_2") | coin_port;
r7500r7501
366397      case 0x10: return input_port_read(device->machine, "PL2_5") | coin_port;
367398      case 0x20: return input_port_read(device->machine, "PL2_6") | coin_port;
368399   }
369//  printf("%04x\n",mux_data);
400   //printf("%04x\n", state->mux_data);
370401
371402   return (input_port_read(device->machine, "PL2_1") & input_port_read(device->machine, "PL2_2") & input_port_read(device->machine, "PL2_3") &
372          input_port_read(device->machine, "PL2_4") & input_port_read(device->machine, "PL2_5") & input_port_read(device->machine, "PL2_6")) | coin_port;//input_port_read(device->machine, "PL1_0") && ;
373
403          input_port_read(device->machine, "PL2_4") & input_port_read(device->machine, "PL2_5") & input_port_read(device->machine, "PL2_6")) | coin_port;
374404}
375405
376406/********************************************
r7500r7501
481511   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_MAHJONG_M )
482512   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_MAHJONG_KAN )
483513   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_START1 )
514
484515   PORT_START("PL1_2")
485516   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_MAHJONG_B )
486517   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_MAHJONG_F )
r7500r7501
488519   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_MAHJONG_N )
489520   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_MAHJONG_REACH )
490521   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_MAHJONG_BET ) PORT_CODE(KEYCODE_3)//rate button
522
491523   PORT_START("PL1_3")
492524   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_MAHJONG_C )
493525   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_MAHJONG_G )
r7500r7501
495527   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_MAHJONG_CHI )
496528   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_MAHJONG_RON )
497529   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_UNUSED ) //another D button
530
498531   PORT_START("PL1_4")
499532   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_MAHJONG_D )
500533   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_MAHJONG_H )
501534   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_MAHJONG_L )
502535   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_MAHJONG_PON )
503536   PORT_BIT( 0x30, IP_ACTIVE_LOW, IPT_UNUSED ) //another opt 1 button
537
504538   PORT_START("PL1_5")
505539   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_MAHJONG_LAST_CHANCE )
506540   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_OTHER ) PORT_NAME("1P Option 1")
r7500r7501
508542   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_MAHJONG_FLIP_FLOP )
509543   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_OTHER ) PORT_NAME("1P Option 3")
510544   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_OTHER ) PORT_NAME("1P Option 4")
545
511546   PORT_START("PL1_6")
512547   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNUSED )
513548   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_OTHER ) PORT_NAME("1P Pass") //???
r7500r7501
520555   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_MAHJONG_M ) PORT_PLAYER(2)
521556   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_MAHJONG_KAN ) PORT_PLAYER(2)
522557   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_START2 )
558
523559   PORT_START("PL2_2")
524560   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_MAHJONG_B ) PORT_PLAYER(2)
525561   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_MAHJONG_F ) PORT_PLAYER(2)
r7500r7501
527563   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_MAHJONG_N ) PORT_PLAYER(2)
528564   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_MAHJONG_REACH ) PORT_PLAYER(2)
529565   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_MAHJONG_BET ) PORT_CODE(KEYCODE_4) PORT_PLAYER(2)//rate button
566
530567   PORT_START("PL2_3")
531568   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_MAHJONG_C ) PORT_PLAYER(2)
532569   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_MAHJONG_G ) PORT_PLAYER(2)
r7500r7501
534571   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_MAHJONG_CHI ) PORT_PLAYER(2)
535572   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_MAHJONG_RON ) PORT_PLAYER(2)
536573   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_UNUSED ) //another D button
574
537575   PORT_START("PL2_4")
538576   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_MAHJONG_D ) PORT_PLAYER(2)
539577   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_MAHJONG_H ) PORT_PLAYER(2)
540578   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_MAHJONG_L ) PORT_PLAYER(2)
541579   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_MAHJONG_PON ) PORT_PLAYER(2)
542580   PORT_BIT( 0x30, IP_ACTIVE_LOW, IPT_UNUSED ) //another opt 1 button
581
543582   PORT_START("PL2_5")
544583   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_MAHJONG_LAST_CHANCE ) PORT_PLAYER(2)
545584   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_OTHER ) PORT_NAME("2P Option 1") PORT_PLAYER(2)
r7500r7501
547586   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_MAHJONG_FLIP_FLOP ) PORT_PLAYER(2)
548587   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_OTHER ) PORT_NAME("2P Option 3") PORT_PLAYER(2)
549588   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_OTHER ) PORT_NAME("2P Option 4") PORT_PLAYER(2)
589
550590   PORT_START("PL2_6")
551591   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNUSED )
552592   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_OTHER ) PORT_NAME("2P Pass") PORT_PLAYER(2) //???
r7500r7501
693733   DEVCB_NULL
694734};
695735
736
737static MACHINE_START( nightgal )
738{
739   nightgal_state *state = (nightgal_state *)machine->driver_data;
740
741   state->maincpu = devtag_get_device(machine, "maincpu");
742   state->subcpu = devtag_get_device(machine, "sub");
743
744   state_save_register_global(machine, state->nsc_latch);
745   state_save_register_global(machine, state->z80_latch);
746   state_save_register_global(machine, state->mux_data);
747
748   state_save_register_global_array(machine, state->blit_raw_data);
749   state_save_register_global_array(machine, state->true_blit);
750   state_save_register_global_array(machine, state->pen_data);
751   state_save_register_global_array(machine, state->pen_raw_data);
752}
753
754static MACHINE_RESET( nightgal )
755{
756   nightgal_state *state = (nightgal_state *)machine->driver_data;
757
758   state->nsc_latch = 0;
759   state->z80_latch = 0;
760   state->mux_data = 0;
761
762   memset(state->blit_raw_data, 0, ARRAY_LENGTH(state->blit_raw_data));
763   memset(state->true_blit, 0, ARRAY_LENGTH(state->true_blit));
764   memset(state->pen_data, 0, ARRAY_LENGTH(state->pen_data));
765   memset(state->pen_raw_data, 0, ARRAY_LENGTH(state->pen_raw_data));
766}
767
696768static MACHINE_DRIVER_START( nightgal )
769
770   /* driver data */
771   MDRV_DRIVER_DATA(nightgal_state)
772
697773   /* basic machine hardware */
698774   MDRV_CPU_ADD("maincpu", Z80,MASTER_CLOCK / 4)       /* ? MHz */
699775   MDRV_CPU_PROGRAM_MAP(nightgal_map)
r7500r7501
705781
706782   MDRV_QUANTUM_PERFECT_CPU("maincpu")
707783
784   MDRV_MACHINE_START(nightgal)
785   MDRV_MACHINE_RESET(nightgal)
786
708787   /* video hardware */
709788   MDRV_SCREEN_ADD("screen", RASTER)
710789   MDRV_SCREEN_REFRESH_RATE(60)
r7500r7501
10261105
10271106
10281107/* Type 1 HW*/
1029GAME( 1984, nightgal, 0,       nightgal, sexygal,  0, ROT0,"Nichibutsu", "Night Gal (Japan 840920 AG 1-00)", GAME_NOT_WORKING|GAME_UNEMULATED_PROTECTION )
1030GAME( 1984, ngtbunny, 0,       nightgal, sexygal,  0, ROT0,"Nichibutsu", "Night Bunny (Japan 840601 MRN 2-10)", GAME_NOT_WORKING|GAME_UNEMULATED_PROTECTION )
1031GAME( 1984, royalngt, ngtbunny,nightgal, sexygal,  0, ROT0,"Royal Denshi", "Royal Night (Japan 840220 RN 2-00)", GAME_NOT_WORKING|GAME_UNEMULATED_PROTECTION )
1108GAME( 1984, nightgal, 0,        nightgal, sexygal,  0, ROT0, "Nichibutsu",   "Night Gal (Japan 840920 AG 1-00)", GAME_NOT_WORKING | GAME_UNEMULATED_PROTECTION | GAME_SUPPORTS_SAVE )
1109GAME( 1984, ngtbunny, 0,        nightgal, sexygal,  0, ROT0, "Nichibutsu",   "Night Bunny (Japan 840601 MRN 2-10)", GAME_NOT_WORKING | GAME_UNEMULATED_PROTECTION | GAME_SUPPORTS_SAVE )
1110GAME( 1984, royalngt, ngtbunny, nightgal, sexygal,  0, ROT0, "Royal Denshi", "Royal Night (Japan 840220 RN 2-00)", GAME_NOT_WORKING | GAME_UNEMULATED_PROTECTION | GAME_SUPPORTS_SAVE )
10321111/* Type 2 HW*/
1033GAME( 1985, sexygal,  0,       sexygal,  sexygal,  0, ROT0,"Nichibutsu", "Sexy Gal (Japan 850501 SXG 1-00)", GAME_NOT_WORKING|GAME_UNEMULATED_PROTECTION )
1034GAME( 1985, sweetgal, sexygal, sexygal,  sexygal,  0, ROT0,"Nichibutsu", "Sweet Gal (Japan 850510 SWG 1-02)", GAME_NOT_WORKING|GAME_UNEMULATED_PROTECTION )
1112GAME( 1985, sexygal,  0,        sexygal,  sexygal,  0, ROT0, "Nichibutsu",   "Sexy Gal (Japan 850501 SXG 1-00)", GAME_NOT_WORKING | GAME_UNEMULATED_PROTECTION | GAME_SUPPORTS_SAVE )
1113GAME( 1985, sweetgal, sexygal,  sexygal,  sexygal,  0, ROT0, "Nichibutsu",   "Sweet Gal (Japan 850510 SWG 1-02)", GAME_NOT_WORKING | GAME_UNEMULATED_PROTECTION | GAME_SUPPORTS_SAVE )
10351114/* Type 3 HW*/
1036GAME( 1985, ngalsumr, 0,       nightgal, sexygal,  0, ROT0,"Nichibutsu", "Night Gal Summer", GAME_NOT_WORKING|GAME_UNEMULATED_PROTECTION )
1115GAME( 1985, ngalsumr, 0,        nightgal, sexygal,  0, ROT0, "Nichibutsu",   "Night Gal Summer", GAME_NOT_WORKING | GAME_UNEMULATED_PROTECTION | GAME_SUPPORTS_SAVE )
src/mame/drivers/namcond1.c
r7500r7501
88            Walter Fath
99
1010    Currently Supported Games:
11        Namco Classics Vol #1
12        Namco Classics Vol #2
11        Namco Classic Vol #1
12        Namco Classic Vol #2
1313
1414PCB Layout
1515----------
r7500r7501
408408    ROM_LOAD( "ncs1voic.7c",     0x000000, 0x200000, CRC(ed05fd88) SHA1(ad88632c89a9946708fc6b4c9247e1bae9b2944b) )
409409ROM_END
410410
411GAME( 1995, ncv1,      0, namcond1, namcond1, 0, ROT90, "Namco", "Namco Classics Collection Vol.1", GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS )
412GAME( 1995, ncv1j,  ncv1, namcond1, namcond1, 0, ROT90, "Namco", "Namco Classics Collection Vol.1 (Japan, v1.00)", GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS )
413GAME( 1995, ncv1j2, ncv1, namcond1, namcond1, 0, ROT90, "Namco", "Namco Classics Collection Vol.1 (Japan, v1.03)", GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS )
414GAME( 1996, ncv2,      0, namcond1, namcond1, 0, ROT90, "Namco", "Namco Classics Collection Vol.2", GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS | GAME_UNEMULATED_PROTECTION )
415GAME( 1996, ncv2j,  ncv2, namcond1, namcond1, 0, ROT90, "Namco", "Namco Classics Collection Vol.2 (Japan)", GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS | GAME_UNEMULATED_PROTECTION )
411GAME( 1995, ncv1,      0, namcond1, namcond1, 0, ROT90, "Namco", "Namco Classic Collection Vol.1", GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS )
412GAME( 1995, ncv1j,  ncv1, namcond1, namcond1, 0, ROT90, "Namco", "Namco Classic Collection Vol.1 (Japan, v1.00)", GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS )
413GAME( 1995, ncv1j2, ncv1, namcond1, namcond1, 0, ROT90, "Namco", "Namco Classic Collection Vol.1 (Japan, v1.03)", GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS )
414GAME( 1996, ncv2,      0, namcond1, namcond1, 0, ROT90, "Namco", "Namco Classic Collection Vol.2", GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS | GAME_UNEMULATED_PROTECTION )
415GAME( 1996, ncv2j,  ncv2, namcond1, namcond1, 0, ROT90, "Namco", "Namco Classic Collection Vol.2 (Japan)", GAME_IMPERFECT_SOUND | GAME_IMPERFECT_GRAPHICS | GAME_UNEMULATED_PROTECTION )
src/mame/drivers/rgum.c
r0r7501
1/*
2
3Royal Gum
4
5Unknown CPU (either Z80 or Z180)
6
7Big Black Box in the middle of the PCB (for encryption, or containing roms?)
8
9*/
10
11#include "emu.h"
12#include "cpu/z80/z80.h"
13
14static ADDRESS_MAP_START( rgum_map, ADDRESS_SPACE_PROGRAM, 8 )
15   AM_RANGE(0x0000, 0x7fff) AM_ROM
16ADDRESS_MAP_END
17
18
19static INPUT_PORTS_START( rgum )
20INPUT_PORTS_END
21
22
23static const gfx_layout tiles8x8_layout =
24{
25   8,8,
26   RGN_FRAC(1,3),
27   3,
28   { RGN_FRAC(0,3),RGN_FRAC(1,3),RGN_FRAC(2,3) },
29   { 0, 1,2,3,4,5,6,7 },
30   { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8 },
31   8*8
32};
33
34static GFXDECODE_START( rgum )
35   GFXDECODE_ENTRY( "gfx1", 0, tiles8x8_layout, 0, 16 )
36GFXDECODE_END
37
38VIDEO_START(royalgum)
39{
40
41}
42
43VIDEO_UPDATE(royalgum)
44{
45   return 0;
46}
47
48
49static MACHINE_DRIVER_START( rgum )
50   /* basic machine hardware */
51   MDRV_CPU_ADD("maincpu", Z80,8000000)       /* ? MHz */
52   MDRV_CPU_PROGRAM_MAP(rgum_map)
53//  MDRV_CPU_VBLANK_INT("screen", irq0_line_hold)
54
55   /* video hardware */
56   MDRV_SCREEN_ADD("screen", RASTER)
57   MDRV_SCREEN_REFRESH_RATE(60)
58   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(0))
59   MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16)
60   MDRV_SCREEN_SIZE(256, 256)
61   MDRV_SCREEN_VISIBLE_AREA(0, 256-1, 0, 256-1)
62
63   MDRV_GFXDECODE(rgum)
64   MDRV_PALETTE_LENGTH(0x100)
65
66   MDRV_VIDEO_START(royalgum)
67   MDRV_VIDEO_UPDATE(royalgum)
68MACHINE_DRIVER_END
69
70
71
72
73ROM_START( rgum )
74   ROM_REGION( 0x20000, "maincpu", 0 )
75   ROM_LOAD( "rgum.u47", 0x00000, 0x20000, CRC(fe410eb9) SHA1(25180ba336269279f251be5483c210a581d27197) ) // encrypted.. 2nd half empty
76
77   ROM_REGION( 0x10000, "data", 0 )
78   ROM_LOAD( "rgum.u5", 0x00000, 0x10000, CRC(9d2d1681) SHA1(1c1da0d970ea2cf58f7961417ab6986cc667da5c) ) // plaintext in here, but firt half is empty
79
80   ROM_REGION( 0x10000, "unk", 0 )
81   ROM_LOAD( "rgum.u6", 0x00000, 0x2000, CRC(15a34117) SHA1(c7e0aef4007abfaaa533feb026148ba03230b79f) ) // near the data rom, mostly empty
82
83   ROM_REGION( 0x18000, "gfx1", 0 )
84   ROM_LOAD( "rgum.u16", 0x00000, 0x8000, CRC(2a2c8d78) SHA1(2ce335b900dccbc34ad8ae7ae02ec7c75ffcd559) ) // first half empty
85   ROM_CONTINUE(0x00000,0x8000)
86   ROM_LOAD( "rgum.u17", 0x08000,  0x8000, CRC(fae4e41a) SHA1(421aac2b567040c3a56e01aa70880c94450eaf76) ) // first half empty
87   ROM_CONTINUE(0x08000,0x8000)
88   ROM_LOAD( "rgum.u18", 0x10000, 0x8000, CRC(79b17da7) SHA1(31e1845261b0152df56135c212e55c4048b7496f) ) // first half empty
89   ROM_CONTINUE(0x10000,0x8000)
90ROM_END
91
92
93GAME( 199?, rgum, 0, rgum, rgum, 0, ROT0, "<unknown>",         "Royal Gum (Italy)", GAME_NOT_WORKING | GAME_NO_SOUND )
src/mame/drivers/attckufo.c
r7500r7501
4343
4444#include "emu.h"
4545#include "cpu/m6502/m6502.h"
46#include "includes/attckufo.h"
46#include "sound/mos6560.h"
4747
4848
49static UINT8 *mainram;
50static UINT8 *tileram;
49class attckufo_state
50{
51public:
52   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, attckufo_state(machine)); }
5153
54   attckufo_state(running_machine &machine) { }
55
56   /* memory pointers */
57   UINT8 *      mainram;
58   UINT8 *      tileram;
59
60   /* devices */
61   running_device *maincpu;
62   running_device *mos6560;
63};
64
65
66
67static const rgb_t attckufo_palette[] =
68{
69/* ripped from vice, a very excellent emulator */
70   MAKE_RGB(0x00, 0x00, 0x00),
71   MAKE_RGB(0xff, 0xff, 0xff),
72   MAKE_RGB(0xf0, 0x00, 0x00),
73   MAKE_RGB(0x00, 0xf0, 0xf0),
74
75   MAKE_RGB(0x60, 0x00, 0x60),
76   MAKE_RGB(0x00, 0xa0, 0x00),
77   MAKE_RGB(0x00, 0x00, 0xf0),
78   MAKE_RGB(0xd0, 0xd0, 0x00),
79
80   MAKE_RGB(0xc0, 0xa0, 0x00),
81   MAKE_RGB(0xff, 0xa0, 0x00),
82   MAKE_RGB(0xf0, 0x80, 0x80),
83   MAKE_RGB(0x00, 0xff, 0xff),
84
85   MAKE_RGB(0xff, 0x00, 0xff),
86   MAKE_RGB(0x00, 0xff, 0x00),
87   MAKE_RGB(0x00, 0xa0, 0xff),
88   MAKE_RGB(0xff, 0xff, 0x00)
89};
90
5291static PALETTE_INIT( attckufo )
5392{
5493   palette_set_colors(machine, 0, attckufo_palette, ARRAY_LENGTH(attckufo_palette));
r7500r7501
79118
80119static ADDRESS_MAP_START( cpu_map, ADDRESS_SPACE_PROGRAM, 8 )
81120   ADDRESS_MAP_GLOBAL_MASK(0x3fff)
82   AM_RANGE(0x0000, 0x0fff) AM_RAM AM_BASE(&mainram)
83   AM_RANGE(0x1000, 0x100f) AM_READWRITE(attckufo_port_r, attckufo_port_w)
121   AM_RANGE(0x0000, 0x0fff) AM_RAM AM_BASE_MEMBER(attckufo_state, mainram)
122   AM_RANGE(0x1000, 0x100f) AM_DEVREADWRITE("mos6560", mos6560_port_r, mos6560_port_w)
84123   AM_RANGE(0x1400, 0x1403) AM_READWRITE(attckufo_io_r, attckufo_io_w)
85   AM_RANGE(0x1c00, 0x1fff) AM_RAM AM_BASE(&tileram)
124   AM_RANGE(0x1c00, 0x1fff) AM_RAM AM_BASE_MEMBER(attckufo_state, tileram)
86125   AM_RANGE(0x2000, 0x3fff) AM_ROM
87126ADDRESS_MAP_END
88127
r7500r7501
114153INPUT_PORTS_END
115154
116155
156INTERRUPT_GEN( attckufo_raster_interrupt )
157{
158   attckufo_state *state = (attckufo_state *)device->machine->driver_data;
159   mos6560_raster_interrupt_gen(state->mos6560);
160}
161
162VIDEO_UPDATE( attckufo )
163{
164   attckufo_state *state = (attckufo_state *)screen->machine->driver_data;
165   mos6560_video_update(state->mos6560, bitmap, cliprect);
166   return 0;
167}
168
169static int attckufo_dma_read( running_machine *machine, int offset )
170{
171   attckufo_state *state = (attckufo_state *)machine->driver_data;
172   const address_space *program = cpu_get_address_space(state->maincpu, ADDRESS_SPACE_PROGRAM);
173   return memory_read_byte(program, offset);
174}
175
176static int attckufo_dma_read_color( running_machine *machine, int offset )
177{
178   attckufo_state *state = (attckufo_state *)machine->driver_data;
179   const address_space *program = cpu_get_address_space(state->maincpu, ADDRESS_SPACE_PROGRAM);
180   return memory_read_byte(program, offset + 0x400);
181}
182
183static const mos6560_interface attckufo_6560_intf =
184{
185   "screen",   /* screen */
186   MOS6560_ATTACKUFO,
187   NULL, NULL, NULL,   /* lightgun cb */
188   NULL, NULL,      /* paddle cb */
189   attckufo_dma_read, attckufo_dma_read_color   /* DMA */
190};
191
192
193static MACHINE_START( attckufo )
194{
195   attckufo_state *state = (attckufo_state *)machine->driver_data;
196
197   state->maincpu = devtag_get_device(machine, "maincpu");
198   state->mos6560 = devtag_get_device(machine, "mos6560");
199}
200
117201static MACHINE_DRIVER_START( attckufo )
202
203   /* driver data */
204   MDRV_DRIVER_DATA(attckufo_state)
205
206   /* basic machine hardware */
118207   MDRV_CPU_ADD("maincpu", M6502, 14318181/14)
119208   MDRV_CPU_PROGRAM_MAP(cpu_map)
120   MDRV_CPU_PERIODIC_INT(attckufo_raster_interrupt, 15625)
209   MDRV_CPU_PERIODIC_INT(attckufo_raster_interrupt, MOS656X_HRETRACERATE)
121210
122  /* video hardware */
211   MDRV_MACHINE_START(attckufo)
123212
213   /* video hardware */
124214   MDRV_SCREEN_ADD("screen", RASTER)
125   MDRV_SCREEN_REFRESH_RATE(60)
126   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(2500) /* not accurate */)
215   MDRV_SCREEN_REFRESH_RATE(MOS6560_VRETRACERATE)
216   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(2500)) /* not accurate */
127217   MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16)
128   MDRV_SCREEN_SIZE(256, 256)
129   MDRV_SCREEN_VISIBLE_AREA(0, 23*8-1, 0, 22*8-1)
218   MDRV_SCREEN_SIZE((MOS6560_XSIZE + 7) & ~7, MOS6560_YSIZE)
219   MDRV_SCREEN_VISIBLE_AREA(0, 23*8 - 1, 0, 22*8 - 1)
130220
131221   MDRV_PALETTE_LENGTH(ARRAY_LENGTH(attckufo_palette))
132   MDRV_PALETTE_INIT( attckufo )
222   MDRV_PALETTE_INIT(attckufo)
133223
134   MDRV_VIDEO_UPDATE( attckufo )
224   MDRV_VIDEO_UPDATE(attckufo)
135225
136226   /* sound hardware */
137227   MDRV_SPEAKER_STANDARD_MONO("mono")
138   MDRV_SOUND_ADD("attckufo", ATTCKUFO, 0)
228   MDRV_MOS656X_ADD("mos6560", attckufo_6560_intf)
139229   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0)
140230MACHINE_DRIVER_END
141231
r7500r7501
154244   ROM_COPY( "maincpu", 0x02000, 0x00000, 0x400)
155245ROM_END
156246
157GAME( 1980, attckufo, 0,        attckufo, attckufo, 0, ROT270, "Ryoto Electric Co.", "Attack Ufo", 0)
247GAME( 1980, attckufo, 0,      attckufo, attckufo, 0, ROT270, "Ryoto Electric Co.", "Attack Ufo", GAME_SUPPORTS_SAVE )
src/mame/drivers/jongkyo.c
r7500r7501
3232#define JONGKYO_CLOCK 18432000
3333
3434
35typedef struct _jongkyo_state jongkyo_state;
36struct _jongkyo_state
35class jongkyo_state
3736{
37public:
38   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, jongkyo_state(machine)); }
39
40   jongkyo_state(running_machine &machine) { }
41
3842   /* memory pointers */
3943   UINT8 *  videoram;
4044   UINT8 *  videoram2;
src/mame/drivers/namcos23.c
r7500r7501
2323    TODO:
2424    - Palette is not right.
2525
26    - H8/3002 now communicates with the H8/3334 on the I/O board, but it's not reliable yet.
27
28    - Hook up actual inputs (?) via the 2 serial latches at d00004 and d00006.
26    - Hook up gun inputs (?) via the 2 serial latches at d00004 and d00006.
2927      Works like this: write to d00004, then read d00004 12 times.  Ditto at
30      d00006.  This gives 24 bits of inputs (?) from the I/O board (?).
28      d00006.  This gives 24 bits of inputs (?) from the I/O board (?) or guns (?)
3129
3230    - The entire 3D subsystem.  Is there a DSP living down there?  If not, why the 300k
3331      download on initial startup?
r7500r7501
3937    - Serial number data is at offset 0x201 in the BIOS.  Until the games are running
4038      and displaying it I'm not going to meddle with it though.
4139
40    - Ok, it's the "mt" roms, which the game calls data roms.  One pair is
41      at a8000000, the other at aa000000.  Point roms are accessed for
42      checksumming through a port at a200000x:
43      - reset the port by writing 0000 to a2000006
44      - write offset >> 16  to a2000004
45      - write offset & ffff to a2000004 (yes, same address, hence the reset)
46      - read 2 bytes from one rom at a200000a
47      - read 2 bytes from one rom at a200000c
48
49    - Super System 23 tests irqs in the post.  timecrs2c's code can
50    potentially test 7 sources, but only actually test 5.  With each
51    source there is code to clear the interrupt and code to raise it.
52    Levels 0 and 1 are not connected to anything according to the code.
53
54      VBlank (level 2):
55        clear: ad00000a.h = 0
56        raise: just wait for it
57
58      C361   (level 3):
59        clear: a6820008.h = 1ff
60               a100005c.w = 0
61               a100005c.w = 1
62               a4c3ff04.w = 0
63        raise: a6820008.h = c8
64               a100005c.w = 1
65
66      Subcpu (level 3, same as C361):
67        clear: same as C361
68        raise: a4405002.h = 3170
69
70      C435   (level 4):
71        clear: a200000e.h = 1
72               a200000e.h = 0
73        raise: a2000000.h = a200
74               a2000000.h = 1
75               a2000000.h = 1 (yes, twice)
76
77      C422   (level 5):
78        clear: a6400002.h = f
79               ad000008.h = 0
80        raise: a640000e.h = 0
81               a6400006.h = 1
82               a640000a.h = 1
83               a6400006.h = fffb
84               a6400006.h = 0
85
86      RS323  (level 6, not tested by timecrs2c):
87        clear: nothing
88        raise: nothing
89
90      Timer  (level 7, not tested by timecrs2c):
91        clear: c0.Compare = 10d880
92        raise: c0.Count   = 10c8e0
93               c0.Compare = 10d880
4294*/
4395
4496/*
r7500r7501
394446
395447      Game           Code and revision
396448      --------------------------------
397      GP500          5GP3 Ver.C
449      GP500          5GP3 Ver.C (for Super System 23)
450      Time Crisis 2  TSS4 Ver.A (for Super System 23)
451
398452Other games dumps with unknown PCB information....
399453
400454      Game             Code and revision
r7500r7501
498552      PIC16F84 - Microchip PIC16F84 Programmable Interrupt Controller stamped 'CAP10' (SOIC20)
499553      MCU      - Fujitsu MB90F574 Microcontroller, stamped 'FCAF10' (QFP120)
500554      ADM485   - Analog Devices ADM485 +5V Low Power EIA RS-485 Transceiver (SOIC8)
555
556I/O Boards for Gun games
557------------------------
558
559Type 1:
560
561V185 I/O PCB
5622479961102 (2479971102)
563|-----------------------------------------|
564|   J601      LED1 LED2         |-------| |
565|   DSW(4)JP1 |-------|         |TSSIO  | |
566|     |-----| | C78   |14.746MHz|PLD    | |
567|     |TSSIO| |       |PST592   |-------| |
568|     |PROG | |-------|                   |
569|     |-----|                             |
570|                                         |
571|     62256                               |
572|ADM485                                   |
573|J1               SLA4060               J5|
574|                          J3       J4    |
575|-----------------------------------------|
576Notes:
577      TSSIOPROG - Atmel AT29C020 EEPROM stamped 'TSSIOP8' (PLCC32)
578      C78       - Namco Custom C78, actually a rebadged Hitachi HD643334 MCU (PLCC84)
579      TSSIOPLD  - Altera MAX EPM7128ELC84 CPLD with label 'TSSIOPLD' (PLCC84)
580      SLA4060   -
581      J1        - 12 position connector for power and I/O
582      J3        - 12 position connector for buttons and gun connection
583      J4        - not used?
584      J5        - 6 position connector for network
585      J601      - not used?
586      JP1       - jumper set to 1-2 (lower position), labelled 'WR'
587      DSW       - 4 position dipswitch block, all off
588
589This board is used only on Time Crisis II.
590Note the gun is a standard light gun.
591--------------
592
593Type 2:
594
595V221 MIU PCB
5962512960101 (2512970101)
597additional sticker for Time Crisis 3 says '2591961001 V291 XMIU PCB'
598|---------------------------------------------|
599|J10      J9    29C020     LC35256  DSW(4)    |
600|    M0105          PRG.8F                LED |
601|2267     6393                            LED |
602|    T082  T082                 |------|      |
603|           |--------|          | C78  |   J8 |
604|           |ALTERA  |          |      |      |
605|J11        |MAX     |          |------|    J7|
606|   LM1881  |EPM7128 |                  3771  |
607|R305526    |--------|                        |
608|      ZUW1R51212            14.746MHz        |
609|                                 ADM485    J6|
610|                                             |
611|  J1       J2   J3          J4    J5         |
612|---------------------------------------------|
613Notes:
614      2267    - JRC2267 Current limiting diode array? (SOIC8)
615      R305526 - Some kind of mini transformer or regulator?
616      LC35256 - Sanyo LC35256 32k x8 SRAM (SOP28)
617      LM1881  - National Semiconductor LM1881 Video Sync Separator (SOIC8)
618      M0105   - Matsushita Panasonic 0105 = ? (SOIC16)
619      T082    - Texas Instruments T082 (=TL082) JFET-Input operational amplifier (SOIC8)
620      6393    - Sanyo 6393 (LA6393) High Performance Dual Comparator (SOIC8)
621      ADM485  - Analog Devices ADM485 5V Low Power EIA RS-485 Transceiver (SOIC8)
622      3771    - Fujitsu MB3771 Power Supply Monitor and Master Reset IC (SOIC8)
623      EPM7128 - Altera MAX EPM7128SLC84-15 PLD labelled 'TMIU1/PLD0' (Time Crisis 3)
624      29C020  - location for 29C020 PLCC32 Flash/EP ROM (not populated)
625      ZUW1R51212 - Cosel ZUW1R51212 DC to DC Power Supply Module (input 9-18VDC, output +-12VDC or +24VDC)
626      DSW     - 4 position dipswitch block, all off
627      J1      - 6-pin power input connector
628      J2      - 12-pin connector (cabinet buttons UP/DOWN/ENTER plus TEST/SERVICE/COIN etc)
629      J3      - 4 pin connector (not used)
630      J4      - 9 pin Namco female plug connector for gun (solenoid +24V/trigger/pedal/sensor)
631      J5      - 5 pin connector used for I/O --> S246 communications (connects to USB link connection on main unit)
632      J6      - 7-pin connector (not used)
633      J9      - 6-pin connector (not used)
634      J10     - 2-pin Namco female plug connector (not used)
635      J11     - 6-pin Namco female plug connector (video input from CCD camera)
636      PRG.8F  - 27C1001 EPROM with label...
637                                           'XMIU1 PRG0' (I/O program for Time Crisis 3)
638                                           'CSZ1 PRG0A' (I/O program for Crisis Zone)
639
640This board is used on Crisis Zone (System 23 Evolution2) and Time Crisis 3 (System 246)
641Note both games use a CCD camera for the gun sensor.
501642*/
502643
503644/*
r7500r7501
742883#include "cpu/h83002/h8.h"
743884#include "sound/c352.h"
744885
745static int ss23_vstat = 0, hstat = 0, vstate = 0;
886#define S23_BUSCLOCK   (66664460/2)   // 33 MHz CPU bus clock / input, somehow derived from 14.31721 MHz crystal
887#define S23_VSYNC1   (59.8824)
888#define S23_VSYNC2   (59.915)
889#define S23_HSYNC   (16666150)
890#define S23_MODECLOCK   (130205)
891
892//static int ss23_vstat = 0, hstat = 0, vstate = 0;
746893static tilemap_t *bgtilemap;
747894static UINT32 *namcos23_textram, *namcos23_shared_ram;
748895static UINT32 *namcos23_charram;
749896static UINT8 namcos23_jvssense;
897static INT32 has_jvsio;
750898
899static bool ctl_vbl_active;
900static UINT8 ctl_led;
901static UINT16 ctl_inp_buffer[2];
902
903static UINT16 c417_ram[0x10000], c417_adr = 0;
904
905static UINT16 c412_sdram_a[0x100000];
906static UINT16 c412_sdram_b[0x100000];
907static UINT16 c412_sram[0x20000];
908static UINT16 c412_pczram[0x200];
909static UINT32 c412_adr = 0;
910
911static UINT16 c421_dram_a[0x40000];
912static UINT16 c421_dram_b[0x40000];
913static UINT16 c421_sram[0x8000];
914static UINT32 c421_adr = 0;
915
916
751917static UINT16 nthword( const UINT32 *pSource, int offs )
752918{
753919   pSource += offs/2;
r7500r7501
774940static WRITE32_HANDLER( namcos23_textram_w )
775941{
776942   COMBINE_DATA( &namcos23_textram[offset] );
943   tilemap_mark_tile_dirty(bgtilemap, offset*2);
944   tilemap_mark_tile_dirty(bgtilemap, (offset*2)+1);
777945}
778946
779947static VIDEO_START( ss23 )
r7500r7501
8801048   bitmap_fill(bitmap, cliprect, get_black_pen(screen->machine));
8811049   bitmap_fill(screen->machine->priority_bitmap, cliprect, 0);
8821050
883   tilemap_mark_all_tiles_dirty(bgtilemap);
884   tilemap_set_palette_offset( bgtilemap, 0x7f00 );
8851051   tilemap_draw( bitmap, cliprect, bgtilemap, 0/*flags*/, 0/*priority*/ ); /* opaque */
8861052
8871053#if 0
r7500r7501
9341100   return 0;
9351101}
9361102
937static VIDEO_UPDATE( gorgon )
1103static READ32_HANDLER( s23_txtchar_r )
9381104{
939   return 0;
1105   return namcos23_charram[offset];
9401106}
9411107
9421108static WRITE32_HANDLER( s23_txtchar_w )
r7500r7501
9441110   COMBINE_DATA(&namcos23_charram[offset]);
9451111   gfx_element_mark_dirty(space->machine->gfx[0], offset/32);
9461112}
947
1113#if 0
9481114static READ32_HANDLER( ss23_vstat_r )
9491115{
9501116   if (offset == 1)
r7500r7501
9611127   }
9621128   return ss23_vstat;
9631129}
964
1130#endif
9651131static UINT8 nthbyte( const UINT32 *pSource, int offs )
9661132{
9671133   pSource += offs/4;
r7500r7501
9961162   UpdatePalette(space->machine, (offset % (0x10000/4))*2);
9971163}
9981164
999// must return this magic number
1000static UINT32 s23_vbl = 0;
1165static READ16_HANDLER(s23_c417_16_r)
1166{
1167   switch(offset) {
1168   case 0: return 0x8e | (video_screen_get_vblank(space->machine->primary_screen) ? 0x8000 : 0);
1169   case 1: return c417_adr;
1170   case 4:
1171      //      logerror("c417_r %04x = %04x (%08x, %08x)\n", c417_adr, c417_ram[c417_adr], cpu_get_pc(space->cpu), (unsigned int)cpu_get_reg(space->cpu, MIPS3_R31));
1172      return c417_ram[c417_adr];
1173   }
10011174
1002static INTERRUPT_GEN(s23_interrupt)
1175   logerror("c417_16_r %x @ %04x (%08x, %08x)\n", offset, mem_mask, cpu_get_pc(space->cpu), (unsigned int)cpu_get_reg(space->cpu, MIPS3_R31));
1176   return 0;
1177}
1178
1179static WRITE16_HANDLER(s23_c417_16_w)
10031180{
1004   s23_vbl ^= 0x80008000;
1181    switch(offset) {
1182    case 1:
1183        COMBINE_DATA(&c417_adr);
1184        break;
1185
1186    case 4:
1187      //        logerror("c417_w %04x = %04x (%08x, %08x)\n", c417_adr, data, cpu_get_pc(space->cpu), (unsigned int)cpu_get_reg(space->cpu, MIPS3_R31));
1188        COMBINE_DATA(c417_ram + c417_adr);
1189        break;
1190    default:
1191        logerror("c417_16_w %x, %04x @ %04x (%08x, %08x)\n", offset, data, mem_mask, cpu_get_pc(space->cpu), (unsigned int)cpu_get_reg(space->cpu, MIPS3_R31));
1192        break;
1193    }
10051194}
10061195
1007static READ32_HANDLER(s23_unk_r)
1196static READ32_HANDLER(s23_c417_32_r)
10081197{
1009   return 0x008e008e | s23_vbl;
1198    UINT32 data = 0;
1199    if (ACCESSING_BITS_16_31)
1200        data |= s23_c417_16_r(space, offset*2, mem_mask >> 16) << 16;
1201    if (ACCESSING_BITS_0_15)
1202        data |= s23_c417_16_r(space, offset*2+1, mem_mask);
1203    return data;
10101204}
10111205
1012// this & 8 and this & 4 are checked
1013// offset = 1 for magic latch
1014static READ32_HANDLER(sysctl_stat_r)
1206static WRITE32_HANDLER(s23_c417_32_w)
10151207{
1016   if (offset == 1) return 0x0000ffff;   // all inputs in
1208    if (ACCESSING_BITS_16_31)
1209        s23_c417_16_w(space, offset*2, data >> 16, mem_mask >> 16);
1210    if (ACCESSING_BITS_0_15)
1211        s23_c417_16_w(space, offset*2+1, data, mem_mask);
1212}
10171213
1018   return 0xffffffff;
1214static READ16_HANDLER(s23_c412_ram_r)
1215{
1216   //  logerror("c412_ram_r %06x (%08x, %08x)\n", offset, cpu_get_pc(space->cpu), (unsigned int)cpu_get_reg(space->cpu, MIPS3_R31));
1217   if(offset < 0x100000)
1218      return c412_sdram_a[offset & 0xfffff];
1219   else if(offset < 0x200000)
1220      return c412_sdram_b[offset & 0xfffff];
1221   else if(offset < 0x220000)
1222      return c412_sram   [offset & 0x1ffff];
1223   else if(offset < 0x220200)
1224      return c412_pczram [offset & 0x001ff];
1225
1226   return 0xffff;
10191227}
10201228
1229static WRITE16_HANDLER(s23_c412_ram_w)
1230{
1231   //  logerror("c412_ram_w %06x = %04x (%08x, %08x)\n", offset, data, cpu_get_pc(space->cpu), (unsigned int)cpu_get_reg(space->cpu, MIPS3_R31));
1232   if(offset < 0x100000)
1233      COMBINE_DATA(c412_sdram_a + (offset & 0xfffff));
1234   else if(offset < 0x200000)
1235      COMBINE_DATA(c412_sdram_b + (offset & 0xfffff));
1236   else if(offset < 0x220000)
1237      COMBINE_DATA(c412_sram    + (offset & 0x1ffff));
1238   else if(offset < 0x220200)
1239      COMBINE_DATA(c412_pczram  + (offset & 0x001ff));
1240}
1241
1242static READ16_HANDLER(s23_c412_16_r)
1243{
1244   switch(offset) {
1245   case 8: return c412_adr;
1246   case 9: return c412_adr >> 16;
1247   case 10: return s23_c412_ram_r(space, c412_adr, mem_mask);
1248   }
1249
1250   logerror("c412_16_r %x @ %04x (%08x, %08x)\n", offset, mem_mask, cpu_get_pc(space->cpu), (unsigned int)cpu_get_reg(space->cpu, MIPS3_R31));
1251   return 0;
1252}
1253
1254static WRITE16_HANDLER(s23_c412_16_w)
1255{
1256    switch(offset) {
1257   case 8: c412_adr = (data & mem_mask) | (c412_adr & (0xffffffff ^ mem_mask)); break;
1258   case 9: c412_adr = ((data & mem_mask) << 16) | (c412_adr & (0xffffffff ^ (mem_mask << 16))); break;
1259   case 10: s23_c412_ram_w(space, c412_adr, data, mem_mask); break;
1260    default:
1261        logerror("c412_16_w %x, %04x @ %04x (%08x, %08x)\n", offset, data, mem_mask, cpu_get_pc(space->cpu), (unsigned int)cpu_get_reg(space->cpu, MIPS3_R31));
1262        break;
1263    }
1264}
1265
1266static READ32_HANDLER(s23_c412_32_r)
1267{
1268    UINT32 data = 0;
1269    if (ACCESSING_BITS_16_31)
1270        data |= s23_c412_16_r(space, offset*2, mem_mask >> 16) << 16;
1271    if (ACCESSING_BITS_0_15)
1272        data |= s23_c412_16_r(space, offset*2+1, mem_mask);
1273    return data;
1274}
1275
1276static WRITE32_HANDLER(s23_c412_32_w)
1277{
1278    if (ACCESSING_BITS_16_31)
1279        s23_c412_16_w(space, offset*2, data >> 16, mem_mask >> 16);
1280    if (ACCESSING_BITS_0_15)
1281        s23_c412_16_w(space, offset*2+1, data, mem_mask);
1282}
1283
1284
1285static READ16_HANDLER(s23_c421_ram_r)
1286{
1287   //  logerror("c421_ram_r %06x (%08x, %08x)\n", offset, cpu_get_pc(space->cpu), (unsigned int)cpu_get_reg(space->cpu, MIPS3_R31));
1288   if(offset < 0x40000)
1289      return c421_dram_a[offset & 0x3ffff];
1290   else if(offset < 0x80000)
1291      return c421_dram_b[offset & 0x3ffff];
1292   else if(offset < 0x88000)
1293      return c421_sram  [offset & 0x07fff];
1294
1295   return 0xffff;
1296}
1297
1298static WRITE16_HANDLER(s23_c421_ram_w)
1299{
1300   //  logerror("c421_ram_w %06x = %04x (%08x, %08x)\n", offset, data, cpu_get_pc(space->cpu), (unsigned int)cpu_get_reg(space->cpu, MIPS3_R31));
1301   if(offset < 0x40000)
1302      COMBINE_DATA(c421_dram_a + (offset & 0x3ffff));
1303   else if(offset < 0x80000)
1304      COMBINE_DATA(c421_dram_b + (offset & 0x3ffff));
1305   else if(offset < 0x88000)
1306      COMBINE_DATA(c421_sram   + (offset & 0x07fff));
1307}
1308
1309static READ16_HANDLER(s23_c421_16_r)
1310{
1311   switch(offset) {
1312   case 0: return s23_c421_ram_r(space, c421_adr & 0xfffff, mem_mask);
1313   case 2: return c421_adr >> 16;
1314   case 3: return c421_adr;
1315   }
1316
1317   logerror("c421_16_r %x @ %04x (%08x, %08x)\n", offset, mem_mask, cpu_get_pc(space->cpu), (unsigned int)cpu_get_reg(space->cpu, MIPS3_R31));
1318   return 0;
1319}
1320
1321static WRITE16_HANDLER(s23_c421_16_w)
1322{
1323    switch(offset) {
1324   case 0: s23_c421_ram_w(space, c421_adr & 0xfffff, data, mem_mask); break;
1325   case 2: c421_adr = ((data & mem_mask) << 16) | (c421_adr & (0xffffffff ^ (mem_mask << 16))); break;
1326   case 3: c421_adr = (data & mem_mask) | (c421_adr & (0xffffffff ^ mem_mask)); break;
1327    default:
1328        logerror("c421_16_w %x, %04x @ %04x (%08x, %08x)\n", offset, data, mem_mask, cpu_get_pc(space->cpu), (unsigned int)cpu_get_reg(space->cpu, MIPS3_R31));
1329        break;
1330    }
1331}
1332
1333static READ32_HANDLER(s23_c421_32_r)
1334{
1335    UINT32 data = 0;
1336    if (ACCESSING_BITS_16_31)
1337        data |= s23_c421_16_r(space, offset*2, mem_mask >> 16) << 16;
1338    if (ACCESSING_BITS_0_15)
1339        data |= s23_c421_16_r(space, offset*2+1, mem_mask);
1340    return data;
1341}
1342
1343static WRITE32_HANDLER(s23_c421_32_w)
1344{
1345    if (ACCESSING_BITS_16_31)
1346        s23_c421_16_w(space, offset*2, data >> 16, mem_mask >> 16);
1347    if (ACCESSING_BITS_0_15)
1348        s23_c421_16_w(space, offset*2+1, data, mem_mask);
1349}
1350
1351static WRITE16_HANDLER(s23_ctl_16_w)
1352{
1353   switch(offset) {
1354   case 0: {
1355      if(ctl_led != (data & 0xff)) {
1356         ctl_led = data;
1357         logerror("LEDS %c%c%c%c%c%c%c%c\n",
1358                ctl_led & 0x80 ? '.' : '#',
1359                ctl_led & 0x40 ? '.' : '#',
1360                ctl_led & 0x20 ? '.' : '#',
1361                ctl_led & 0x10 ? '.' : '#',
1362                ctl_led & 0x08 ? '.' : '#',
1363                ctl_led & 0x04 ? '.' : '#',
1364                ctl_led & 0x02 ? '.' : '#',
1365                ctl_led & 0x01 ? '.' : '#');
1366      }
1367      break;
1368   }
1369
1370   case 2: case 3:
1371      // These may be coming from another CPU, in particular the I/O one
1372      ctl_inp_buffer[offset-2] = input_port_read(space->machine, offset == 2 ? "P1" : "P2");
1373      break;
1374   case 5:
1375      if(ctl_vbl_active) {
1376         ctl_vbl_active = false;
1377         cpu_set_input_line(space->cpu, MIPS3_IRQ0, CLEAR_LINE);
1378      }
1379      break;
1380
1381   default:
1382      logerror("ctl_w %x, %04x @ %04x (%08x, %08x)\n", offset, data, mem_mask, cpu_get_pc(space->cpu), (unsigned int)cpu_get_reg(space->cpu, MIPS3_R31));
1383   }
1384}
1385
1386static READ16_HANDLER(s23_ctl_16_r)
1387{
1388   switch(offset) {
1389      // dips ?
1390      // 0100 set freezes gorgon
1391      // 0080 is service mode for gorgon
1392      // 0004 unset freezes ss23 at the boot level
1393      // 0002 unset skips the post on ss23
1394   case 1: return 0x0004;
1395   case 2: case 3: {
1396      UINT16 res = ctl_inp_buffer[offset-2] & 0x800 ? 0xffff : 0x0000;
1397      ctl_inp_buffer[offset-2] = (ctl_inp_buffer[offset-2] << 1) | 1;
1398      return res;
1399   }
1400   }
1401   logerror("ctl_r %x @ %04x (%08x, %08x)\n", offset, mem_mask, cpu_get_pc(space->cpu), (unsigned int)cpu_get_reg(space->cpu, MIPS3_R31));
1402   return 0xffff;
1403}
1404
1405static WRITE32_HANDLER(s23_ctl_32_w)
1406{
1407    if (ACCESSING_BITS_16_31)
1408        s23_ctl_16_w(space, offset*2, data >> 16, mem_mask >> 16);
1409    if (ACCESSING_BITS_0_15)
1410        s23_ctl_16_w(space, offset*2+1, data, mem_mask);
1411}
1412
1413static READ32_HANDLER(s23_ctl_32_r)
1414{
1415    UINT32 data = 0;
1416    if (ACCESSING_BITS_16_31)
1417        data |= s23_ctl_16_r(space, offset*2, mem_mask >> 16) << 16;
1418    if (ACCESSING_BITS_0_15)
1419        data |= s23_ctl_16_r(space, offset*2+1, mem_mask);
1420    return data;
1421}
1422
1423
1424static WRITE16_HANDLER(s23_c361_16_w)
1425{
1426   switch(offset) {
1427   default:
1428      logerror("c361_w %x, %04x @ %04x (%08x, %08x)\n", offset, data, mem_mask, cpu_get_pc(space->cpu), (unsigned int)cpu_get_reg(space->cpu, MIPS3_R31));
1429   }
1430}
1431
1432static READ16_HANDLER(s23_c361_16_r)
1433{
1434   switch(offset) {
1435   case 5: return video_screen_get_vpos(space->machine->primary_screen);
1436   case 6: return video_screen_get_vblank(space->machine->primary_screen);
1437   }
1438   logerror("c361_r %x @ %04x (%08x, %08x)\n", offset, mem_mask, cpu_get_pc(space->cpu), (unsigned int)cpu_get_reg(space->cpu, MIPS3_R31));
1439   return 0xffff;
1440}
1441
1442static WRITE32_HANDLER(s23_c361_32_w)
1443{
1444    if (ACCESSING_BITS_16_31)
1445        s23_c361_16_w(space, offset*2, data >> 16, mem_mask >> 16);
1446    if (ACCESSING_BITS_0_15)
1447        s23_c361_16_w(space, offset*2+1, data, mem_mask);
1448}
1449
1450static READ32_HANDLER(s23_c361_32_r)
1451{
1452    UINT32 data = 0;
1453    if (ACCESSING_BITS_16_31)
1454        data |= s23_c361_16_r(space, offset*2, mem_mask >> 16) << 16;
1455    if (ACCESSING_BITS_0_15)
1456        data |= s23_c361_16_r(space, offset*2+1, mem_mask);
1457    return data;
1458}
1459
1460static INTERRUPT_GEN(s23_interrupt)
1461{
1462   if(!ctl_vbl_active) {
1463      ctl_vbl_active = true;
1464      cpu_set_input_line(device, MIPS3_IRQ0, ASSERT_LINE);
1465   }
1466}
1467
1468
10211469// as with System 22, we need to halt the MCU while checking shared RAM
10221470static WRITE32_HANDLER( s23_mcuen_w )
10231471{
1024   mame_printf_debug("mcuen_w: mask %08x, data %08x\n", mem_mask, data);
1472   logerror("mcuen_w: mask %08x, data %08x\n", mem_mask, data);
10251473   if (mem_mask == 0x0000ffff)
10261474   {
10271475      if (data)
r7500r7501
10371485   }
10381486}
10391487
1040static UINT32 gorgon_vbl = 0;
1041static READ32_HANDLER( gorgon_vbl_r )
1488static READ32_HANDLER( gorgon_magic_r )
10421489{
1043   gorgon_vbl ^= 0xffffffff;
1490   return 0xffffffff;   // must be non-zero (rapidrvr @ 8000229C)
1491}
10441492
1045   return gorgon_vbl;
1493/*
1494    Final Furlong has a bug: it forgets to halt the H8/3002 before it zeros out the shared RAM
1495    which contains the H8's stack and other working set.  This crashes MAME due to the PC going
1496    off into the weeds, so we intercept
1497*/
1498
1499static READ32_HANDLER( gorgon_sharedram_r )
1500{
1501   return namcos23_shared_ram[offset];
10461502}
10471503
1504static WRITE32_HANDLER( gorgon_sharedram_w )
1505{
1506   COMBINE_DATA(&namcos23_shared_ram[offset]);
1507
1508   // hack for final furlong
1509   if ((offset == 0x6000/4) && (data == 0) && (mem_mask == 0xff000000))
1510   {
1511      logerror("S23: Final Furlong hack stopping H8/3002\n");
1512      cputag_set_input_line(space->machine, "audiocpu", INPUT_LINE_RESET, ASSERT_LINE);
1513   }
1514}
1515
10481516static ADDRESS_MAP_START( gorgon_map, ADDRESS_SPACE_PROGRAM, 32 )
10491517   AM_RANGE(0x00000000, 0x003fffff) AM_RAM
1050   AM_RANGE(0x02000000, 0x02000003) AM_READ( gorgon_vbl_r )
1051   AM_RANGE(0x04400000, 0x0440ffff) AM_RAM AM_BASE(&namcos23_shared_ram)
1518   AM_RANGE(0x01000000, 0x010000ff) AM_READ( gorgon_magic_r )
1519   AM_RANGE(0x02000000, 0x0200000f) AM_READWRITE( s23_c417_32_r, s23_c417_32_w )
1520   AM_RANGE(0x04400000, 0x0440ffff) AM_READWRITE( gorgon_sharedram_r, gorgon_sharedram_w ) AM_BASE(&namcos23_shared_ram)
1521
1522   AM_RANGE(0x04c3ff08, 0x04c3ff0b) AM_WRITE( s23_mcuen_w )
10521523   AM_RANGE(0x04c3ff0c, 0x04c3ff0f) AM_RAM            // 3d FIFO
1053   AM_RANGE(0x0d000000, 0x0d000007) AM_READ(sysctl_stat_r)
1524
1525   AM_RANGE(0x06080000, 0x06081fff) AM_RAM
1526
1527   AM_RANGE(0x06108000, 0x061087ff) AM_RAM      // GAMMA (C404-3S)
1528   AM_RANGE(0x06110000, 0x0613ffff) AM_READWRITE(namcos23_paletteram_r, namcos23_paletteram_w) AM_BASE_GENERIC(paletteram)
1529   AM_RANGE(0x06400000, 0x06403fff) AM_READWRITE( s23_txtchar_r, s23_txtchar_w ) AM_BASE(&namcos23_charram)   // text layer characters
1530   AM_RANGE(0x06404000, 0x0641dfff) AM_RAM
1531   AM_RANGE(0x0641e000, 0x0641ffff) AM_READWRITE(namcos23_textram_r, namcos23_textram_w) AM_BASE(&namcos23_textram)
1532
1533   AM_RANGE(0x08000000, 0x087fffff) AM_ROM AM_REGION("data", 0)   // data ROMs
1534
1535   AM_RANGE(0x0c000000, 0x0c00ffff) AM_RAM   AM_BASE_SIZE_GENERIC(nvram) // BACKUP
1536
1537   AM_RANGE(0x0d000000, 0x0d00000f) AM_READWRITE (s23_ctl_32_r, s23_ctl_32_w ) // write for LEDs at d000000, watchdog at d000004
1538
1539   AM_RANGE(0x0f200000, 0x0f201fff) AM_RAM
1540
10541541   AM_RANGE(0x0fc00000, 0x0fffffff) AM_WRITENOP AM_ROM AM_REGION("user1", 0)
10551542   AM_RANGE(0x1fc00000, 0x1fffffff) AM_WRITENOP AM_ROM AM_REGION("user1", 0)
10561543ADDRESS_MAP_END
10571544
10581545static ADDRESS_MAP_START( ss23_map, ADDRESS_SPACE_PROGRAM, 32 )
10591546   AM_RANGE(0x00000000, 0x003fffff) AM_RAM
1060   AM_RANGE(0x02000000, 0x02000003) AM_READ( s23_unk_r )
1547   AM_RANGE(0x01000000, 0x010000ff) AM_READ( gorgon_magic_r )
1548   AM_RANGE(0x02000000, 0x0200000f) AM_READWRITE( s23_c417_32_r, s23_c417_32_w )
10611549   AM_RANGE(0x04400000, 0x0440ffff) AM_RAM AM_BASE(&namcos23_shared_ram)
10621550   AM_RANGE(0x04c3ff08, 0x04c3ff0b) AM_WRITE( s23_mcuen_w )
10631551   AM_RANGE(0x04c3ff0c, 0x04c3ff0f) AM_RAM            // 3d FIFO
1064   AM_RANGE(0x06800000, 0x06800fff) AM_RAM          // text layer palette
1065   AM_RANGE(0x06800000, 0x06803fff) AM_WRITE( s23_txtchar_w ) AM_BASE(&namcos23_charram)   // text layer characters
1552   AM_RANGE(0x06000000, 0x0600ffff) AM_RAM AM_BASE_SIZE_GENERIC(nvram) // Backup
1553   AM_RANGE(0x06200000, 0x06203fff) AM_RAM                             // C422
1554   AM_RANGE(0x06800000, 0x06807fff) AM_READWRITE( s23_txtchar_r, s23_txtchar_w ) AM_BASE(&namcos23_charram)   // text layer characters (shown as CGRAM in POST)
10661555   AM_RANGE(0x06804000, 0x0681dfff) AM_RAM
1067   AM_RANGE(0x0681e000, 0x0681ffff) AM_READ(namcos23_textram_r) AM_WRITE(namcos23_textram_w) AM_BASE(&namcos23_textram)
1068   AM_RANGE(0x06a08000, 0x06a0ffff) AM_RAM   //gamma?
1069   AM_RANGE(0x06a10000, 0x06a3ffff) AM_READ(namcos23_paletteram_r) AM_WRITE(namcos23_paletteram_w) AM_BASE_GENERIC(paletteram)
1070   AM_RANGE(0x06820008, 0x0682000f) AM_READ( ss23_vstat_r )   // vblank status?
1071   AM_RANGE(0x08000000, 0x08017fff) AM_RAM
1072   AM_RANGE(0x0d000000, 0x0d000007) AM_READ(sysctl_stat_r) AM_WRITENOP
1556   AM_RANGE(0x0681e000, 0x0681ffff) AM_READWRITE(namcos23_textram_r, namcos23_textram_w) AM_BASE(&namcos23_textram)
1557   AM_RANGE(0x06820000, 0x0682000f) AM_READWRITE( s23_c361_32_r, s23_c361_32_w )   // C361
1558   AM_RANGE(0x06a08000, 0x06a0ffff) AM_RAM   // GAMMA (C404)
1559   AM_RANGE(0x06a10000, 0x06a3ffff) AM_READWRITE(namcos23_paletteram_r, namcos23_paletteram_w) AM_BASE_GENERIC(paletteram)
1560   AM_RANGE(0x08000000, 0x08ffffff) AM_ROM AM_REGION("data", 0x0000000) AM_MIRROR(0x01000000)   // data ROMs
1561   AM_RANGE(0x0a000000, 0x0affffff) AM_ROM AM_REGION("data", 0x1000000) AM_MIRROR(0x01000000)
1562   AM_RANGE(0x0c000000, 0x0c00001f) AM_READWRITE( s23_c412_32_r, s23_c412_32_w )
1563   AM_RANGE(0x0c400000, 0x0c400007) AM_READWRITE( s23_c421_32_r, s23_c421_32_w )
1564   AM_RANGE(0x0d000000, 0x0d00000f) AM_READWRITE( s23_ctl_32_r, s23_ctl_32_w )
10731565   AM_RANGE(0x0fc00000, 0x0fffffff) AM_WRITENOP AM_ROM AM_REGION("user1", 0)
10741566   AM_RANGE(0x1fc00000, 0x1fffffff) AM_WRITENOP AM_ROM AM_REGION("user1", 0)
10751567ADDRESS_MAP_END
r7500r7501
10781570{
10791571   UINT16 *shared16 = (UINT16 *)namcos23_shared_ram;
10801572
1081   // fake that an I/O board is connected
1082   if ((offset == 0x4052/2) && (data == 0x78))
1573   // fake that an I/O board is connected for games w/o a dump or that aren't properly communicating with it yet
1574   if (!has_jvsio)
10831575   {
1084      data = 0;
1576      if ((offset == 0x4052/2) && (data == 0x78))
1577      {
1578         data = 0;
1579      }
10851580   }
10861581
10871582   COMBINE_DATA(&shared16[BYTE_XOR_BE(offset)]);
r7500r7501
10991594   AM_RANGE(0x000000, 0x07ffff) AM_ROM
11001595   AM_RANGE(0x080000, 0x08ffff) AM_READWRITE( sharedram_sub_r, sharedram_sub_w )
11011596   AM_RANGE(0x280000, 0x287fff) AM_DEVREADWRITE( "c352", c352_r, c352_w )
1102   AM_RANGE(0x300000, 0x300001) AM_READNOP //AM_READ_PORT("IN1")
1103   AM_RANGE(0x300002, 0x300003) AM_READNOP //AM_READ_PORT("IN2")
1597   AM_RANGE(0x300000, 0x300003) AM_NOP   // seems to be more inputs, maybe false leftover code from System 12?
11041598   AM_RANGE(0x300010, 0x300011) AM_NOP
11051599   AM_RANGE(0x300030, 0x300031) AM_WRITENOP   // timecrs2 writes this when writing to the sync shared ram location, motoxgo doesn't
11061600ADDRESS_MAP_END
r7500r7501
12221716   s23_setstate ^= 1;
12231717}
12241718
1225static UINT8 maintoio[64], mi_rd, mi_wr;
1226static UINT8 iotomain[64], im_rd, im_wr;
1719static UINT8 maintoio[128], mi_rd, mi_wr;
1720static UINT8 iotomain[128], im_rd, im_wr;
12271721
12281722static READ8_HANDLER( s23_mcu_iob_r )
12291723{
12301724   UINT8 ret = iotomain[im_rd];
12311725
12321726   im_rd++;
1233   im_rd &= 0x3f;
1727   im_rd &= 0x7f;
12341728
12351729   if (im_rd == im_wr)
12361730   {
r7500r7501
12481742static WRITE8_HANDLER( s23_mcu_iob_w )
12491743{
12501744   maintoio[mi_wr++] = data;
1251   mi_wr &= 0x3f;
1745   mi_wr &= 0x7f;
12521746
12531747   cputag_set_input_line(space->machine, "ioboard", H8_SCI_0_RX, ASSERT_LINE);
12541748}
12551749
12561750static INPUT_PORTS_START( ss23 )
12571751   PORT_START("H8PORT")
1752
1753   // No idea if start is actually there, but we need buttons to pass error screens
1754   PORT_START("P1")
1755   PORT_BIT( 0x001, IP_ACTIVE_LOW, IPT_START1 )
1756   PORT_BIT( 0xffe, IP_ACTIVE_LOW, IPT_UNKNOWN )
1757
1758   PORT_START("P2")
1759   PORT_BIT( 0x001, IP_ACTIVE_LOW, IPT_START2 )
1760   PORT_BIT( 0xffe, IP_ACTIVE_LOW, IPT_UNKNOWN )
1761
1762   PORT_START("TC2P0")
1763   PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_COIN1 )
1764   PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_UNKNOWN )
1765   PORT_BIT(0x04, IP_ACTIVE_HIGH, IPT_UNKNOWN )   // this is the "coin acceptor connected" signal
1766   PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_UNKNOWN )
1767   PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_SERVICE1 )
1768   PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN )
1769   PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_JOYSTICK_UP )
1770   PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_BUTTON3 )
1771
1772   PORT_START("TC2P1")
1773   PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_BUTTON1 )   // gun trigger
1774   PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_BUTTON2 )   // foot pedal
1775   PORT_BIT(0xfc, IP_ACTIVE_LOW, IPT_UNKNOWN )
12581776INPUT_PORTS_END
12591777
12601778
r7500r7501
12731791   AM_RANGE(H8_PORT_6, H8_PORT_6) AM_READWRITE( s23_mcu_p6_r, s23_mcu_p6_w )
12741792   AM_RANGE(H8_PORT_7, H8_PORT_7) AM_READ_PORT( "H8PORT" )
12751793   AM_RANGE(H8_PORT_8, H8_PORT_8) AM_READ( s23_mcu_p8_r ) AM_WRITENOP
1794   AM_RANGE(H8_PORT_9, H8_PORT_9) AM_NOP   // read on Gorgon, purpose unknown
12761795   AM_RANGE(H8_PORT_A, H8_PORT_A) AM_READWRITE( s23_mcu_pa_r, s23_mcu_pa_w )
12771796   AM_RANGE(H8_PORT_B, H8_PORT_B) AM_READWRITE( s23_mcu_portB_r, s23_mcu_portB_w )
12781797   AM_RANGE(H8_SERIAL_0, H8_SERIAL_0) AM_READWRITE( s23_mcu_iob_r, s23_mcu_iob_w )
r7500r7501
13021821   UINT8 ret = maintoio[mi_rd];
13031822
13041823   mi_rd++;
1305   mi_rd &= 0x3f;
1824   mi_rd &= 0x7f;
13061825
13071826   if (mi_rd == mi_wr)
13081827   {
r7500r7501
13151834static WRITE8_HANDLER( s23_iob_mcu_w )
13161835{
13171836   iotomain[im_wr++] = data;
1318   im_wr &= 0x3f;
1837   im_wr &= 0x7f;
13191838
13201839   cputag_set_input_line(space->machine, "audiocpu", H8_SCI_0_RX, ASSERT_LINE);
13211840}
r7500r7501
13341853   namcos23_jvssense = (data & 0x04) ? 0 : 1;
13351854}
13361855
1856static READ8_HANDLER(iob_r)
1857{
1858   return mame_rand(space->machine);
1859}
1860
13371861/* H8/3334 (Namco C78) I/O board MCU */
13381862static ADDRESS_MAP_START( s23iobrdmap, ADDRESS_SPACE_PROGRAM, 8 )
1339   AM_RANGE(0x0000, 0x0fff) AM_ROM
1340   AM_RANGE(0xc000, 0xdfff) AM_RAM
1863   AM_RANGE(0x0000, 0x1fff) AM_ROM AM_REGION("ioboard", 0)
1864   AM_RANGE(0x6000, 0x6000) AM_READ_PORT("TC2P0")     // 0-1 = coin 0-3 = coin connect, 0-5 = test 0-6 = down select, 0-7 = up select, 0-8 = enter
1865   AM_RANGE(0x6001, 0x6001) AM_READ_PORT("TC2P1")     // 1-1 = gun trigger 1-2 = foot pedal
1866   AM_RANGE(0x6002, 0x6003) AM_READ( iob_r )
1867   AM_RANGE(0x7000, 0x700f) AM_READ( iob_r )
1868
1869   AM_RANGE(0xc000, 0xf7ff) AM_RAM
13411870ADDRESS_MAP_END
13421871
13431872/*
r7500r7501
13461875*/
13471876static ADDRESS_MAP_START( s23iobrdiomap, ADDRESS_SPACE_IO, 8 )
13481877   AM_RANGE(H8_PORT_4, H8_PORT_4) AM_READWRITE( s23_iob_p4_r, s23_iob_p4_w )
1878   AM_RANGE(H8_PORT_5, H8_PORT_5) AM_NOP   // status LED in bit 2
1879   AM_RANGE(H8_PORT_6, H8_PORT_6) AM_NOP   // unknown
13491880   AM_RANGE(H8_SERIAL_0, H8_SERIAL_0) AM_READWRITE( s23_iob_mcu_r, s23_iob_mcu_w )
13501881ADDRESS_MAP_END
13511882
r7500r7501
13531884{
13541885   mi_rd = mi_wr = im_rd = im_wr = 0;
13551886   namcos23_jvssense = 1;
1356   s23_vbl = 0;
1887   ctl_vbl_active = false;
13571888   s23_lastpB = 0x50;
13581889   s23_setstate = 0;
13591890   s23_setnum = 0;
13601891   memset(s23_settings, 0, sizeof(s23_settings));
13611892   s23_tssio_port_4 = 0;
13621893   s23_porta = 0, s23_rtcstate = 0;
1363   gorgon_vbl = 0;
1894
1895   if ((!strcmp(machine->gamedrv->name, "motoxgo")) ||
1896       (!strcmp(machine->gamedrv->name, "panicprk")) ||
1897       (!strcmp(machine->gamedrv->name, "rapidrvr")) ||
1898       (!strcmp(machine->gamedrv->name, "finlflng")) ||
1899       (!strcmp(machine->gamedrv->name, "timecrs2")))
1900   {
1901      has_jvsio = 1;
1902   }
1903   else
1904   {
1905      has_jvsio = 0;
1906   }
13641907}
13651908
13661909#define XOR(a) WORD2_XOR_BE(a)
r7500r7501
13991942#endif
14001943
14011944static GFXDECODE_START( namcos23 )
1402   GFXDECODE_ENTRY( NULL, 0, namcos23_cg_layout, 0, 0x80 )
1945   GFXDECODE_ENTRY( NULL, 0, namcos23_cg_layout, 0x7f00, 0x80 )
14031946GFXDECODE_END
14041947
14051948static const mips3_config config =
r7500r7501
14081951   8192            /* data cache size - VERIFIED */
14091952};
14101953
1411static INTERRUPT_GEN( namcos23_interrupt )
1412{
1413}
1414
14151954static MACHINE_DRIVER_START( gorgon )
14161955
14171956   /* basic machine hardware */
1418   MDRV_CPU_ADD("maincpu", R4650BE, 133000000)
1957   MDRV_CPU_ADD("maincpu", R4650BE, S23_BUSCLOCK*4)
14191958   MDRV_CPU_CONFIG(config)
14201959   MDRV_CPU_PROGRAM_MAP(gorgon_map)
1960   MDRV_CPU_VBLANK_INT("screen", s23_interrupt)
14211961
14221962   MDRV_CPU_ADD("audiocpu", H83002, 14745600 )
1423   MDRV_CPU_PROGRAM_MAP( s23h8rwmap)
1424   MDRV_CPU_IO_MAP( s23h8ionoiobmap)
1963   MDRV_CPU_PROGRAM_MAP( s23h8rwmap )
1964   MDRV_CPU_IO_MAP( s23h8iomap )
14251965   MDRV_CPU_VBLANK_INT("screen", irq1_line_pulse)
14261966
1967   MDRV_CPU_ADD("ioboard", H83334, 14745600 )
1968   MDRV_CPU_PROGRAM_MAP( s23iobrdmap )
1969   MDRV_CPU_IO_MAP( s23iobrdiomap )
1970
14271971   MDRV_QUANTUM_TIME(HZ(60000))
14281972
14291973   MDRV_SCREEN_ADD("screen", RASTER)
1430   MDRV_SCREEN_REFRESH_RATE(60)
1431   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(0))
1974   MDRV_SCREEN_REFRESH_RATE(S23_VSYNC1)
1975   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(2500)) // Not in any way accurate
14321976   MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16)
1433   MDRV_SCREEN_SIZE(64*16, 30*16)
1434   MDRV_SCREEN_VISIBLE_AREA(0, 64*16-1, 0, 30*16-1)
1977   MDRV_SCREEN_SIZE(640, 480)
1978   MDRV_SCREEN_VISIBLE_AREA(0, 639, 0, 479)
14351979
14361980   MDRV_PALETTE_LENGTH(0x8000)
14371981
1982   MDRV_NVRAM_HANDLER(generic_0fill)
1983
14381984   MDRV_GFXDECODE(namcos23)
14391985
14401986   MDRV_VIDEO_START(ss23)
1441   MDRV_VIDEO_UPDATE(gorgon)
1987   MDRV_VIDEO_UPDATE(ss23)
14421988
14431989   /* sound hardware */
14441990   MDRV_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker")
r7500r7501
14531999static MACHINE_DRIVER_START( s23 )
14542000
14552001   /* basic machine hardware */
1456   MDRV_CPU_ADD("maincpu", R4650BE, 166000000)
2002   MDRV_CPU_ADD("maincpu", R4650BE, S23_BUSCLOCK*4)
14572003   MDRV_CPU_CONFIG(config)
14582004   MDRV_CPU_PROGRAM_MAP(ss23_map)
14592005   MDRV_CPU_VBLANK_INT("screen", s23_interrupt)
14602006
14612007   MDRV_CPU_ADD("audiocpu", H83002, 14745600 )
1462   MDRV_CPU_PROGRAM_MAP( s23h8rwmap)
1463   MDRV_CPU_IO_MAP( s23h8iomap)
2008   MDRV_CPU_PROGRAM_MAP( s23h8rwmap )
2009   MDRV_CPU_IO_MAP( s23h8iomap )
14642010   MDRV_CPU_VBLANK_INT("screen", irq1_line_pulse)
14652011
14662012   MDRV_CPU_ADD("ioboard", H83334, 14745600 )
1467   MDRV_CPU_PROGRAM_MAP( s23iobrdmap)
1468   MDRV_CPU_IO_MAP( s23iobrdiomap)
2013   MDRV_CPU_PROGRAM_MAP( s23iobrdmap )
2014   MDRV_CPU_IO_MAP( s23iobrdiomap )
14692015
14702016   MDRV_QUANTUM_TIME(HZ(60*18000))   // higher than 60*20000 causes timecrs2 crash after power-on test $1e
14712017
14722018   MDRV_SCREEN_ADD("screen", RASTER)
1473   MDRV_SCREEN_REFRESH_RATE(60)
1474   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(0))
2019   MDRV_SCREEN_REFRESH_RATE(S23_VSYNC1)
2020   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(2500)) // Not in any way accurate
14752021   MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16)
1476   MDRV_SCREEN_SIZE(64*16, 30*16)
1477   MDRV_SCREEN_VISIBLE_AREA(0, 64*16-1, 0, 30*16-1)
2022   MDRV_SCREEN_SIZE(640, 480)
2023   MDRV_SCREEN_VISIBLE_AREA(0, 639, 0, 479)
14782024
14792025   MDRV_PALETTE_LENGTH(0x8000)
14802026
14812027   MDRV_GFXDECODE(namcos23)
14822028
2029   MDRV_NVRAM_HANDLER(generic_0fill)
2030
14832031   MDRV_VIDEO_START(ss23)
14842032   MDRV_VIDEO_UPDATE(ss23)
14852033
r7500r7501
14962044static MACHINE_DRIVER_START( ss23 )
14972045
14982046   /* basic machine hardware */
1499   MDRV_CPU_ADD("maincpu", R4650BE, 166000000)
2047   MDRV_CPU_ADD("maincpu", R4650BE, S23_BUSCLOCK*5)
15002048   MDRV_CPU_CONFIG(config)
15012049   MDRV_CPU_PROGRAM_MAP(ss23_map)
1502   MDRV_CPU_VBLANK_INT("screen", namcos23_interrupt)
2050   MDRV_CPU_VBLANK_INT("screen", s23_interrupt)
15032051
15042052   MDRV_CPU_ADD("audiocpu", H83002, 14745600 )
1505   MDRV_CPU_PROGRAM_MAP( s23h8rwmap)
1506   MDRV_CPU_IO_MAP( s23h8ionoiobmap)
2053   MDRV_CPU_PROGRAM_MAP( s23h8rwmap )
2054   MDRV_CPU_IO_MAP( s23h8ionoiobmap )
15072055   MDRV_CPU_VBLANK_INT("screen", irq1_line_pulse)
15082056
15092057   MDRV_QUANTUM_TIME(HZ(60*40000))
15102058
15112059   MDRV_SCREEN_ADD("screen", RASTER)
1512   MDRV_SCREEN_REFRESH_RATE(60)
1513   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(0))
2060   MDRV_SCREEN_REFRESH_RATE(S23_VSYNC1)
2061   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(2500)) // Not in any way accurate
15142062   MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16)
1515   MDRV_SCREEN_SIZE(48*16, 30*16)
1516   MDRV_SCREEN_VISIBLE_AREA(0, 48*16-1, 0, 30*16-1)
2063   MDRV_SCREEN_SIZE(640, 480)
2064   MDRV_SCREEN_VISIBLE_AREA(0, 639, 0, 479)
15172065
15182066   MDRV_PALETTE_LENGTH(0x8000)
15192067
15202068   MDRV_GFXDECODE(namcos23)
15212069
2070   MDRV_NVRAM_HANDLER(generic_0fill)
2071
15222072   MDRV_VIDEO_START(ss23)
15232073   MDRV_VIDEO_UPDATE(ss23)
15242074
r7500r7501
15402090   ROM_REGION( 0x80000, "audiocpu", 0 )   /* Hitachi H8/3002 MCU code */
15412091   ROM_LOAD16_WORD_SWAP( "rd3verc.ic3",  0x000000, 0x080000, CRC(6e26fbaf) SHA1(4ab6637d22f0d26f7e1d10e9c80059c56f64303d) )
15422092
1543   ROM_REGION( 0x800000, "sprite", 0 )   /* sprite? tilemap? tiles */
1544        ROM_LOAD16_BYTE( "rd1mtal.1j",   0x000000, 0x400000, CRC(8f0efa86) SHA1(9953461c258f2a96be275a7b18d6518ddfac3860) )
1545        ROM_LOAD16_BYTE( "rd1mtah.3j",   0x000001, 0x400000, CRC(d8fa0f3d) SHA1(0d5bdb3a2e7be1dffe11b74baa2c10bfe011ae92) )
2093   ROM_REGION( 0x40000, "ioboard", 0 )   /* I/O board HD643334 H8/3334 MCU code */
2094        ROM_LOAD( "asca1_io-a.ic2", 0x000000, 0x040000, CRC(77cdf69a) SHA1(497af1059f85c07bea2dd0d303481623f6019dcf) )
15462095
2096   ROM_REGION32_BE( 0x800000, "data", 0 )   /* data */
2097        ROM_LOAD16_BYTE( "rd1mtah.3j",   0x000000, 0x400000, CRC(d8fa0f3d) SHA1(0d5bdb3a2e7be1dffe11b74baa2c10bfe011ae92) )
2098        ROM_LOAD16_BYTE( "rd1mtal.1j",   0x000001, 0x400000, CRC(8f0efa86) SHA1(9953461c258f2a96be275a7b18d6518ddfac3860) )
2099
15472100   ROM_REGION( 0x2000000, "textile", 0 )   /* texture tiles */
15482101        ROM_LOAD( "rd1cguu.5b",   0x0000000, 0x800000, CRC(611bab41) SHA1(84cddb2b63bf8336e92aecb06eddf1b34af73540) )
15492102        ROM_LOAD( "rd1cgum.6b",   0x0800000, 0x800000, CRC(c50de2ef) SHA1(24758a72b3569ce6a643a5786fce7c34b8aa692d) )
r7500r7501
15992152   ROM_REGION( 0x80000, "audiocpu", 0 )   /* Hitachi H8/3002 MCU code */
16002153        ROM_LOAD16_WORD_SWAP( "ff2vera.ic3",  0x000000, 0x080000, CRC(ab681078) SHA1(ec8367404458a54893ab6bea29c8a2ba3272b816) )
16012154
1602   ROM_REGION( 0x800000, "sprite", 0 )   /* sprite? tilemap? tiles */
1603        ROM_LOAD16_BYTE( "ff2mtal.1j",   0x000000, 0x400000, CRC(ed1a5bf2) SHA1(bd05388a125a0201a41af95fb2aa5fe1c8b0f270) )
1604        ROM_LOAD16_BYTE( "ff2mtah.3j",   0x000001, 0x400000, CRC(161003cd) SHA1(04409333a4776b17700fc6d1aa06a39560132e03) )
2155   ROM_REGION( 0x40000, "ioboard", 0 )   /* I/O board HD643334 H8/3334 MCU code */
2156        ROM_LOAD( "asca1_io-a.ic2", 0x000000, 0x040000, CRC(77cdf69a) SHA1(497af1059f85c07bea2dd0d303481623f6019dcf) )
16052157
2158   ROM_REGION32_BE( 0x800000, "data", 0 )   /* data */
2159        ROM_LOAD16_BYTE( "ff2mtah.3j",   0x000000, 0x400000, CRC(161003cd) SHA1(04409333a4776b17700fc6d1aa06a39560132e03) )
2160        ROM_LOAD16_BYTE( "ff2mtal.1j",   0x000001, 0x400000, CRC(ed1a5bf2) SHA1(bd05388a125a0201a41af95fb2aa5fe1c8b0f270) )
2161
16062162   ROM_REGION( 0x2000000, "textile", 0 )   /* texture tiles */
16072163        ROM_LOAD( "ff2cguu.5b",   0x0000000, 0x400000, CRC(595deee4) SHA1(b29ff9c6ba17737f1f87c05b2d899d80b0b72dbb) )
16082164        ROM_LOAD( "ff2cgum.6b",   0x0800000, 0x400000, CRC(b808be59) SHA1(906bfbb5d34feef9697da545a93930fe6e56685c) )
r7500r7501
16412197
16422198   ROM_REGION( 0x1000000, "c352", 0 ) /* C352 PCM samples */
16432199        ROM_LOAD( "ff2wavel.2s",  0x000000, 0x800000, CRC(6235c605) SHA1(521eaee80ac17c0936877d49394e5390fa0ff8a0) )
1644        ROM_LOAD( "ff2waveh.3s",  0x00000, 0x800000, CRC(2a59492a) SHA1(886ec0a4a71048d65f93c52df96416e74d23b3ec) )
2200        ROM_LOAD( "ff2waveh.3s",  0x800000, 0x800000, CRC(2a59492a) SHA1(886ec0a4a71048d65f93c52df96416e74d23b3ec) )
16452201ROM_END
16462202
16472203ROM_START( motoxgo )
r7500r7501
16582214   ROM_REGION( 0x20000, "exioboard", 0 )   /* "extra" I/O board (uses Fujitsu MB90611A MCU) */
16592215        ROM_LOAD( "mg1prog0a.3a", 0x000000, 0x020000, CRC(b2b5be8f) SHA1(803652b7b8fde2196b7fb742ba8b9843e4fcd2de) )
16602216
1661   ROM_REGION( 0x2000000, "sprite", ROMREGION_ERASEFF )   /* sprite? tilemap? tiles */
1662        ROM_LOAD16_BYTE( "mg1mtal.2h",   0x000000, 0x800000, CRC(fdad0f0a) SHA1(420d50f012af40f80b196d3aae320376e6c32367) )
1663        ROM_LOAD16_BYTE( "mg1mtah.2j",   0x000001, 0x800000, CRC(845f4768) SHA1(9c03b1f6dcd9d1f43c2958d855221be7f9415c47) )
2217   ROM_REGION32_BE( 0x2000000, "data", ROMREGION_ERASEFF )   /* data roms */
2218        ROM_LOAD16_BYTE( "mg1mtah.2j",   0x000000, 0x800000, CRC(845f4768) SHA1(9c03b1f6dcd9d1f43c2958d855221be7f9415c47) )
2219        ROM_LOAD16_BYTE( "mg1mtal.2h",   0x000001, 0x800000, CRC(fdad0f0a) SHA1(420d50f012af40f80b196d3aae320376e6c32367) )
16642220
16652221   ROM_REGION( 0x2000000, "textile", ROMREGION_ERASEFF )   /* texture tiles */
16662222        ROM_LOAD( "mg1cgum.4j",   0x000000, 0x800000, CRC(46a77d73) SHA1(132ce2452ee68ba374e98b59032ac0a1a277078d) )
r7500r7501
17022258   ROM_REGION( 0x40000, "ioboard", 0 )   /* I/O board HD643334 H8/3334 MCU code */
17032259   ROM_LOAD( "tssioprog.ic3", 0x000000, 0x040000, CRC(edad4538) SHA1(1330189184a636328d956c0e435f8d9ad2e96a80) )
17042260
1705   ROM_REGION( 0x2000000, "sprite", 0 )   /* sprite? tilemap? tiles */
1706        ROM_LOAD16_BYTE( "tss1mtal.2h",  0x0000000, 0x800000, CRC(bfc79190) SHA1(04bda00c4cc5660d27af4f3b0ee3550dea8d3805) )
1707        ROM_LOAD16_BYTE( "tss1mtah.2j",  0x0000001, 0x800000, CRC(697c26ed) SHA1(72f6f69e89496ba0c6183b35c3bde71f5a3c721f) )
1708        ROM_LOAD16_BYTE( "tss1mtbl.2f",  0x1000000, 0x800000, CRC(e648bea4) SHA1(3803d03e72b25fbcc124d5b25066d25629b76b94) )
1709        ROM_LOAD16_BYTE( "tss1mtbh.2m",  0x1000001, 0x800000, CRC(82582776) SHA1(7c790d09bac660ea1c62da3ffb21ab43f2461594) )
2261   ROM_REGION32_BE( 0x2000000, "data", 0 )   /* data roms */
2262        ROM_LOAD16_BYTE( "tss1mtah.2j",  0x0000000, 0x800000, CRC(697c26ed) SHA1(72f6f69e89496ba0c6183b35c3bde71f5a3c721f) )
2263        ROM_LOAD16_BYTE( "tss1mtal.2h",  0x0000001, 0x800000, CRC(bfc79190) SHA1(04bda00c4cc5660d27af4f3b0ee3550dea8d3805) )
2264        ROM_LOAD16_BYTE( "tss1mtbh.2m",  0x1000000, 0x800000, CRC(82582776) SHA1(7c790d09bac660ea1c62da3ffb21ab43f2461594) )
2265        ROM_LOAD16_BYTE( "tss1mtbl.2f",  0x1000001, 0x800000, CRC(e648bea4) SHA1(3803d03e72b25fbcc124d5b25066d25629b76b94) )
17102266
17112267   ROM_REGION( 0x2000000, "textile", 0 )   /* texture tiles */
17122268        ROM_LOAD( "tss1cguu.4f",  0x0000000, 0x800000, CRC(76924e04) SHA1(751065d6ce658cbbcd88f854f6937ebd2204ec68) )
r7500r7501
17422298   ROM_REGION( 0x40000, "ioboard", 0 )   /* I/O board HD643334 H8/3334 MCU code */
17432299   ROM_LOAD( "tssioprog.ic3", 0x000000, 0x040000, CRC(edad4538) SHA1(1330189184a636328d956c0e435f8d9ad2e96a80) )
17442300
1745   ROM_REGION( 0x2000000, "sprite", 0 )   /* sprite? tilemap? tiles */
1746        ROM_LOAD16_BYTE( "tss1mtal.2h",  0x0000000, 0x800000, CRC(bfc79190) SHA1(04bda00c4cc5660d27af4f3b0ee3550dea8d3805) )
1747        ROM_LOAD16_BYTE( "tss1mtah.2j",  0x0000001, 0x800000, CRC(697c26ed) SHA1(72f6f69e89496ba0c6183b35c3bde71f5a3c721f) )
1748        ROM_LOAD16_BYTE( "tss1mtbl.2f",  0x1000000, 0x800000, CRC(e648bea4) SHA1(3803d03e72b25fbcc124d5b25066d25629b76b94) )
1749        ROM_LOAD16_BYTE( "tss1mtbh.2m",  0x1000001, 0x800000, CRC(82582776) SHA1(7c790d09bac660ea1c62da3ffb21ab43f2461594) )
2301   ROM_REGION32_BE( 0x2000000, "data", 0 )   /* data roms */
2302        ROM_LOAD16_BYTE( "tss1mtah.2j",  0x0000000, 0x800000, CRC(697c26ed) SHA1(72f6f69e89496ba0c6183b35c3bde71f5a3c721f) )
2303        ROM_LOAD16_BYTE( "tss1mtal.2h",  0x0000001, 0x800000, CRC(bfc79190) SHA1(04bda00c4cc5660d27af4f3b0ee3550dea8d3805) )
2304        ROM_LOAD16_BYTE( "tss1mtbh.2m",  0x1000000, 0x800000, CRC(82582776) SHA1(7c790d09bac660ea1c62da3ffb21ab43f2461594) )
2305        ROM_LOAD16_BYTE( "tss1mtbl.2f",  0x1000001, 0x800000, CRC(e648bea4) SHA1(3803d03e72b25fbcc124d5b25066d25629b76b94) )
17502306
17512307   ROM_REGION( 0x2000000, "textile", 0 )   /* texture tiles */
17522308        ROM_LOAD( "tss1cguu.4f",  0x0000000, 0x800000, CRC(76924e04) SHA1(751065d6ce658cbbcd88f854f6937ebd2204ec68) )
r7500r7501
17712327        ROM_LOAD( "tss1waveh.2a", 0x800000, 0x800000, CRC(5c8758b4) SHA1(b85c8f6869900224ef83a2340b17f5bbb2801af9) )
17722328ROM_END
17732329
2330ROM_START( timecrs2c )
2331   ROM_REGION32_BE( 0x400000, "user1", 0 ) /* 4 megs for main R4650 code */
2332        ROM_LOAD16_BYTE( "tss4vera.2",   0x000000, 0x200000, CRC(c84edd3b) SHA1(0b577a8ef6e74afa991dd81c2db19041787724da) )
2333        ROM_LOAD16_BYTE( "tss4vera.1",   0x000001, 0x200000, CRC(26f57c83) SHA1(c8983c26b7524a35257a242b66a9413eb354ca0d) )
2334
2335   ROM_REGION( 0x80000, "audiocpu", 0 )   /* Hitachi H8/3002 MCU code */
2336        ROM_LOAD16_WORD_SWAP( "tss4vera.3",   0x000000, 0x080000, CRC(41e41994) SHA1(eabc1a307c329070bfc6486cb68169c94ff8a162) )
2337
2338   ROM_REGION( 0x40000, "ioboard", 0 )   /* I/O board HD643334 H8/3334 MCU code */
2339   ROM_LOAD( "tssioprog.ic3", 0x000000, 0x040000, CRC(edad4538) SHA1(1330189184a636328d956c0e435f8d9ad2e96a80) )
2340
2341   ROM_REGION32_BE( 0x2000000, "data", 0 )   /* data roms */
2342        ROM_LOAD16_BYTE( "tss1mtah.2j",  0x0000000, 0x800000, CRC(697c26ed) SHA1(72f6f69e89496ba0c6183b35c3bde71f5a3c721f) )
2343        ROM_LOAD16_BYTE( "tss1mtal.2h",  0x0000001, 0x800000, CRC(bfc79190) SHA1(04bda00c4cc5660d27af4f3b0ee3550dea8d3805) )
2344        ROM_LOAD16_BYTE( "tss1mtbh.2m",  0x1000000, 0x800000, CRC(82582776) SHA1(7c790d09bac660ea1c62da3ffb21ab43f2461594) )
2345        ROM_LOAD16_BYTE( "tss1mtbl.2f",  0x1000001, 0x800000, CRC(e648bea4) SHA1(3803d03e72b25fbcc124d5b25066d25629b76b94) )
2346
2347   ROM_REGION( 0x2000000, "textile", 0 )   /* texture tiles */
2348        ROM_LOAD( "tss1cguu.4f",  0x0000000, 0x800000, CRC(76924e04) SHA1(751065d6ce658cbbcd88f854f6937ebd2204ec68) )
2349        ROM_LOAD( "tss1cgum.4j",  0x0800000, 0x800000, CRC(c22739e1) SHA1(8671ee047bb248033656c50befd1c35e5e478e1a) )
2350        ROM_LOAD( "tss1cgll.4m",  0x1000000, 0x800000, CRC(18433aaa) SHA1(08539beb2e66ec4e41062621fc098b121c669546) )
2351        ROM_LOAD( "tss1cglm.4k",  0x1800000, 0x800000, CRC(669974c2) SHA1(cfebe199631e38f547b38fcd35f1645b74e8dd0a) )
2352
2353   ROM_REGION( 0x600000, "textilemap", 0 )   /* texture tilemap */
2354        ROM_LOAD( "tss1ccrl.7f",  0x000000, 0x400000, CRC(3a325fe7) SHA1(882735dce7aeb36f9e88a983498360f5de901e9d) )
2355        ROM_LOAD( "tss1ccrh.7e",  0x400000, 0x200000, CRC(f998de1a) SHA1(371f540f505608297c5ffcfb623b983ca8310afb) )
2356
2357   ROM_REGION32_LE( 0x2000000, "pointrom", 0 )   /* 3D model data */
2358        ROM_LOAD32_WORD( "tss1pt0l.7c",  0x0000000, 0x400000, CRC(896f0fb4) SHA1(bdfa99eb21ce4fc8021f9d95a5558a34f9942c57) )
2359        ROM_LOAD32_WORD( "tss1pt0h.7a",  0x0000002, 0x400000, CRC(cdbe0ba8) SHA1(f8c6da31654c0a2a8024888ffb7fc1c783b2d629) )
2360        ROM_LOAD32_WORD( "tss1pt1l.5c",  0x0800000, 0x400000, CRC(5a09921f) SHA1(c23885708c7adf0b81c2c9346e21b869634a5b35) )
2361        ROM_LOAD32_WORD( "tss1pt1h.5a",  0x0800002, 0x400000, CRC(63647596) SHA1(833412be8f61686bd7e06c2738df740e0e585d0f) )
2362        ROM_LOAD32_WORD( "tss1pt2l.4c",  0x1000000, 0x400000, CRC(4b230d79) SHA1(794cee0a19993e90913f58507c53224f361e9663) )
2363        ROM_LOAD32_WORD( "tss1pt2h.4a",  0x1000002, 0x400000, CRC(9b06e22d) SHA1(cff5ed098112a4f0a2bc8937e226f50066e605b1) )
2364
2365   ROM_REGION( 0x1000000, "c352", 0 ) /* C352 PCM samples */
2366        ROM_LOAD( "tss1wavel.2c", 0x000000, 0x800000, CRC(deaead26) SHA1(72dac0c3f41d4c3c290f9eb1b50236ae3040a472) )
2367        ROM_LOAD( "tss1waveh.2a", 0x800000, 0x800000, CRC(5c8758b4) SHA1(b85c8f6869900224ef83a2340b17f5bbb2801af9) )
2368ROM_END
2369
17742370ROM_START( 500gp )
17752371   /* r4650-generic-xrom-generic: NMON 1.0.8-sys23-19990105 P for SYSTEM23 P1 */
17762372   ROM_REGION32_BE( 0x400000, "user1", 0 ) /* 4 megs for main R4650 code */
r7500r7501
17802376   ROM_REGION( 0x80000, "audiocpu", 0 )   /* Hitachi H8/3002 MCU code */
17812377        ROM_LOAD16_WORD_SWAP( "5gp3verc.3",   0x000000, 0x080000, CRC(b323abdf) SHA1(8962e39b48a7074a2d492afb5db3f5f3e5ae2389) )
17822378
1783   ROM_REGION( 0x2000000, "sprite", 0 )   /* sprite? tilemap? tiles */
1784   ROM_LOAD16_BYTE( "5gp1mtal.2h",  0x0000000, 0x800000, CRC(1bb00c7b) SHA1(922be45d57330c31853b2dc1642c589952b09188) )
1785        ROM_LOAD16_BYTE( "5gp1mtah.2j",  0x0000001, 0x800000, CRC(246e4b7a) SHA1(75743294b8f48bffb84f062febfbc02230d49ce9) )
2379   ROM_REGION32_BE( 0x2000000, "data", 0 )   /* data roms */
2380        ROM_LOAD16_BYTE( "5gp1mtah.2j",  0x0000000, 0x800000, CRC(246e4b7a) SHA1(75743294b8f48bffb84f062febfbc02230d49ce9) )
2381      ROM_LOAD16_BYTE( "5gp1mtal.2h",  0x0000001, 0x800000, CRC(1bb00c7b) SHA1(922be45d57330c31853b2dc1642c589952b09188) )
17862382
17872383      /* COMMON FUJII YASUI WAKAO KURE INOUE
17882384         * 0x000000..0x57ffff: all 0xff
r7500r7501
18232419   ROM_REGION( 0x80000, "audiocpu", 0 )   /* Hitachi H8/3002 MCU code */
18242420        ROM_LOAD16_WORD_SWAP( "m29f400.ic3",  0x000000, 0x080000, CRC(9fd69bbd) SHA1(53a9bf505de70495dcccc43fdc722b3381aad97c) )
18252421
1826   ROM_REGION( 0x2000000, "sprite", 0 )   /* sprite? tilemap? tiles */
1827        ROM_LOAD16_BYTE( "ffs1mtal.2h",  0x0000000, 0x800000, CRC(98730ad5) SHA1(9ba276ad88ec8730edbacab80cdacc34a99593e4) )
1828        ROM_LOAD16_BYTE( "ffs1mtah.2j",  0x0000001, 0x800000, CRC(f336d81d) SHA1(a9177091e1412dea1b6ea6c53530ae31361b32d0) )
1829        ROM_LOAD16_BYTE( "ffs1mtbl.2f",  0x1000000, 0x800000, CRC(0abc9e50) SHA1(be5e5e2b637811c59804ef9442c6da5a5a1315e2) )
1830        ROM_LOAD16_BYTE( "ffs1mtbh.2m",  0x1000001, 0x800000, CRC(0f42c93b) SHA1(26b313fc5c33afb0a1ee42243486e38f052c95c2) )
2422   ROM_REGION32_BE( 0x2000000, "data", 0 )   /* data roms */
2423        ROM_LOAD16_BYTE( "ffs1mtah.2j",  0x0000000, 0x800000, CRC(f336d81d) SHA1(a9177091e1412dea1b6ea6c53530ae31361b32d0) )
2424        ROM_LOAD16_BYTE( "ffs1mtal.2h",  0x0000001, 0x800000, CRC(98730ad5) SHA1(9ba276ad88ec8730edbacab80cdacc34a99593e4) )
2425        ROM_LOAD16_BYTE( "ffs1mtbh.2m",  0x1000000, 0x800000, CRC(0f42c93b) SHA1(26b313fc5c33afb0a1ee42243486e38f052c95c2) )
2426        ROM_LOAD16_BYTE( "ffs1mtbl.2f",  0x1000001, 0x800000, CRC(0abc9e50) SHA1(be5e5e2b637811c59804ef9442c6da5a5a1315e2) )
18312427
18322428   ROM_REGION( 0x2000000, "textile", 0 )   /* texture tiles */
18332429        ROM_LOAD( "ffs1cguu.4f",  0x0000000, 0x800000, CRC(52c0a19f) SHA1(e6b4b90ff88da09cb2e653e450e7ae66942a719e) )
r7500r7501
18622458   ROM_REGION( 0x80000, "audiocpu", 0 )   /* Hitachi H8/3002 MCU code */
18632459        ROM_LOAD16_WORD_SWAP( "m29f400.ic3",  0x000000, 0x080000, CRC(9fd69bbd) SHA1(53a9bf505de70495dcccc43fdc722b3381aad97c) )
18642460
1865   ROM_REGION( 0x2000000, "sprite", 0 )   /* sprite? tilemap? tiles */
1866        ROM_LOAD16_BYTE( "ffs1mtal.2h",  0x0000000, 0x800000, CRC(98730ad5) SHA1(9ba276ad88ec8730edbacab80cdacc34a99593e4) )
1867        ROM_LOAD16_BYTE( "ffs1mtah.2j",  0x0000001, 0x800000, CRC(f336d81d) SHA1(a9177091e1412dea1b6ea6c53530ae31361b32d0) )
1868        ROM_LOAD16_BYTE( "ffs1mtbl.2f",  0x1000000, 0x800000, CRC(0abc9e50) SHA1(be5e5e2b637811c59804ef9442c6da5a5a1315e2) )
1869        ROM_LOAD16_BYTE( "ffs1mtbh.2m",  0x1000001, 0x800000, CRC(0f42c93b) SHA1(26b313fc5c33afb0a1ee42243486e38f052c95c2) )
2461   ROM_REGION32_BE( 0x2000000, "data", 0 )   /* data roms */
2462        ROM_LOAD16_BYTE( "ffs1mtah.2j",  0x0000000, 0x800000, CRC(f336d81d) SHA1(a9177091e1412dea1b6ea6c53530ae31361b32d0) )
2463        ROM_LOAD16_BYTE( "ffs1mtal.2h",  0x0000001, 0x800000, CRC(98730ad5) SHA1(9ba276ad88ec8730edbacab80cdacc34a99593e4) )
2464        ROM_LOAD16_BYTE( "ffs1mtbh.2m",  0x1000000, 0x800000, CRC(0f42c93b) SHA1(26b313fc5c33afb0a1ee42243486e38f052c95c2) )
2465        ROM_LOAD16_BYTE( "ffs1mtbl.2f",  0x1000001, 0x800000, CRC(0abc9e50) SHA1(be5e5e2b637811c59804ef9442c6da5a5a1315e2) )
18702466
18712467   ROM_REGION( 0x2000000, "textile", 0 )   /* texture tiles */
18722468        ROM_LOAD( "ffs1cguu.4f",  0x0000000, 0x800000, CRC(52c0a19f) SHA1(e6b4b90ff88da09cb2e653e450e7ae66942a719e) )
r7500r7501
19022498        ROM_LOAD16_WORD_SWAP( "pnp2ver-a.ic3", 0x000000, 0x080000, CRC(fe4bc6f4) SHA1(2114dc4bc63d589e6c3b26a73dbc60924f3b1765) )
19032499
19042500   ROM_REGION( 0x40000, "ioboard", 0 )   /* I/O board HD643334 H8/3334 MCU code */
1905   // i/o program from motoxgo, as it's "general". however, game crashes(H8 unknown opcode) if add this program
1906//      ROM_LOAD( "asca-3a.ic14", 0x000000, 0x040000, CRC(8e9266e5) SHA1(ffa8782ca641d71d57df23ed1c5911db05d3df97) )
1907      ROM_FILL( 0x00000, 0x40000, 0 ) // Temporary - fixes validity check warning
2501   ROM_LOAD( "asca-3a.ic14", 0x000000, 0x040000, CRC(8e9266e5) SHA1(ffa8782ca641d71d57df23ed1c5911db05d3df97) )
19082502
1909   ROM_REGION( 0x2000000, "sprite", 0 )   /* sprite? tilemap? tiles */
1910        ROM_LOAD16_BYTE( "pnp1mtal.2h",  0x000000, 0x800000, CRC(6490faaa) SHA1(03443746009b434e5d4074ea6314910418907360) )
1911        ROM_LOAD16_BYTE( "pnp1mtah.2j",  0x000001, 0x800000, CRC(37addddd) SHA1(3032989653304417df80606bc3fde6e9425d8cbb) )
2503   ROM_REGION32_BE( 0x2000000, "data", 0 )   /* data roms */
2504        ROM_LOAD16_BYTE( "pnp1mtah.2j",  0x000000, 0x800000, CRC(37addddd) SHA1(3032989653304417df80606bc3fde6e9425d8cbb) )
2505        ROM_LOAD16_BYTE( "pnp1mtal.2h",  0x000001, 0x800000, CRC(6490faaa) SHA1(03443746009b434e5d4074ea6314910418907360) )
19122506
19132507   ROM_REGION( 0x4000000, "textile", 0 )   /* texture tiles */
19142508        ROM_LOAD( "pnp1cguu.5f",  0x000000, 0x800000, CRC(cd64f57f) SHA1(8780270298e0823db1acbbf79396788df0c3c19c) )
r7500r7501
19442538GAME( 1997, motoxgo,  0,         s23, ss23, ss23, ROT0, "Namco", "Motocross Go! (MG3 Ver. A)", GAME_NOT_WORKING | GAME_UNEMULATED_PROTECTION | GAME_IMPERFECT_SOUND )
19452539GAME( 1997, timecrs2, 0,         s23, ss23, ss23, ROT0, "Namco", "Time Crisis 2 (TSS3 Ver. B)", GAME_NOT_WORKING | GAME_UNEMULATED_PROTECTION | GAME_IMPERFECT_SOUND )
19462540GAME( 1997, timecrs2b,timecrs2,  s23, ss23, ss23, ROT0, "Namco", "Time Crisis 2 (TSS2 Ver. B)", GAME_NOT_WORKING | GAME_UNEMULATED_PROTECTION | GAME_IMPERFECT_SOUND )
2541GAME( 1997, timecrs2c,timecrs2, ss23, ss23, ss23, ROT0, "Namco", "Time Crisis 2 (TSS4 Ver. A)", GAME_NOT_WORKING | GAME_UNEMULATED_PROTECTION | GAME_IMPERFECT_SOUND )
19472542GAME( 1998, panicprk, 0,         s23, ss23, ss23, ROT0, "Namco", "Panic Park (PNP2 Ver. A)", GAME_NOT_WORKING | GAME_UNEMULATED_PROTECTION | GAME_IMPERFECT_SOUND )
19482543GAME( 1999, 500gp,    0,        ss23, ss23, ss23, ROT0, "Namco", "500GP", GAME_NOT_WORKING | GAME_UNEMULATED_PROTECTION | GAME_IMPERFECT_SOUND )
19492544GAME( 1999, finfurl2, 0,        ss23, ss23, ss23, ROT0, "Namco", "Final Furlong 2 (World)", GAME_NOT_WORKING | GAME_UNEMULATED_PROTECTION | GAME_IMPERFECT_SOUND )
src/mame/drivers/mjsister.c
r7500r7501
11/*****************************************************************************
22
3Mahjong Sisters (c) 1986 Toa Plan
3    Mahjong Sisters (c) 1986 Toa Plan
44
55    Driver by Uki
66
r7500r7501
1414
1515#define MCLK 12000000
1616
17extern int mjsister_flip_screen;
18extern int mjsister_video_enable;
19extern int mjsister_screen_redraw;
2017
21extern int mjsister_vrambank;
22extern int mjsister_colorbank;
18class mjsister_state
19{
20public:
21   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, mjsister_state(machine)); }
2322
24VIDEO_START( mjsister );
25VIDEO_UPDATE( mjsister );
26WRITE8_HANDLER( mjsister_videoram_w );
23   mjsister_state(running_machine &machine) { }
2724
28static int mjsister_input_sel1;
29static int mjsister_input_sel2;
25   /* memory pointers */
26   UINT8 *     videoram0, *videoram1;
3027
31static int rombank0,rombank1;
28   /* video-related */
29   bitmap_t *tmpbitmap0, *tmpbitmap1;
30   int  flip_screen;
31   int  video_enable;
32   int  screen_redraw;
33   int  vrambank;
34   int  colorbank;
3235
33static UINT32 dac_adr,dac_bank,dac_adr_s,dac_adr_e,dac_busy;
36   /* misc */
37   int  input_sel1;
38   int  input_sel2;
3439
35/****************************************************************************/
40   int  rombank0,rombank1;
3641
42   UINT32 dac_adr, dac_bank, dac_adr_s, dac_adr_e, dac_busy;
43
44   /* devices */
45   running_device *maincpu;
46   running_device *dac;
47};
48
49
50/*************************************
51 *
52 *  Video emulation
53 *
54 *************************************/
55
56static VIDEO_START( mjsister )
57{
58   mjsister_state *state = (mjsister_state *)machine->driver_data;
59   state->tmpbitmap0 = auto_bitmap_alloc(machine, 256, 256, video_screen_get_format(machine->primary_screen));
60   state->tmpbitmap1 = auto_bitmap_alloc(machine, 256, 256, video_screen_get_format(machine->primary_screen));
61   state->videoram0 = auto_alloc_array(machine, UINT8, 0x8000);
62   state->videoram1 = auto_alloc_array(machine, UINT8, 0x8000);
63
64   state_save_register_global_pointer(machine, state->videoram0, 0x8000);
65   state_save_register_global_pointer(machine, state->videoram1, 0x8000);
66}
67
68static void mjsister_plot0( running_machine *machine, int offset, UINT8 data )
69{
70   mjsister_state *state = (mjsister_state *)machine->driver_data;
71   int x, y, c1, c2;
72
73   x = offset & 0x7f;
74   y = offset / 0x80;
75
76   c1 = (data & 0x0f)        + state->colorbank * 0x20;
77   c2 = ((data & 0xf0) >> 4) + state->colorbank * 0x20;
78
79   *BITMAP_ADDR16(state->tmpbitmap0, y, x * 2 + 0) = c1;
80   *BITMAP_ADDR16(state->tmpbitmap0, y, x * 2 + 1) = c2;
81}
82
83static void mjsister_plot1( running_machine *machine, int offset, UINT8 data )
84{
85   mjsister_state *state = (mjsister_state *)machine->driver_data;
86   int x, y, c1, c2;
87
88   x = offset & 0x7f;
89   y = offset / 0x80;
90
91   c1 = data & 0x0f;
92   c2 = (data & 0xf0) >> 4;
93
94   if (c1)
95      c1 += state->colorbank * 0x20 + 0x10;
96   if (c2)
97      c2 += state->colorbank * 0x20 + 0x10;
98
99   *BITMAP_ADDR16(state->tmpbitmap1, y, x * 2 + 0) = c1;
100   *BITMAP_ADDR16(state->tmpbitmap1, y, x * 2 + 1) = c2;
101}
102
103static WRITE8_HANDLER( mjsister_videoram_w )
104{
105   mjsister_state *state = (mjsister_state *)space->machine->driver_data;
106   if (state->vrambank)
107   {
108      state->videoram1[offset] = data;
109      mjsister_plot1(space->machine, offset, data);
110   }
111   else
112   {
113      state->videoram0[offset] = data;
114      mjsister_plot0(space->machine, offset, data);
115   }
116}
117
118static VIDEO_UPDATE( mjsister )
119{
120   mjsister_state *state = (mjsister_state *)screen->machine->driver_data;
121   int flip = state->flip_screen;
122   int i, j;
123
124   if (state->screen_redraw)
125   {
126      int offs;
127
128      for (offs = 0; offs < 0x8000; offs++)
129      {
130         mjsister_plot0(screen->machine, offs, state->videoram0[offs]);
131         mjsister_plot1(screen->machine, offs, state->videoram1[offs]);
132      }
133      state->screen_redraw = 0;
134   }
135
136   if (state->video_enable)
137   {
138      for (i = 0; i < 256; i++)
139         for (j = 0; j < 4; j++)
140            *BITMAP_ADDR16(bitmap, i, 256 + j) = state->colorbank * 0x20;
141
142      copybitmap(bitmap, state->tmpbitmap0, flip, flip, 0, 0, cliprect);
143      copybitmap_trans(bitmap, state->tmpbitmap1, flip, flip, 2, 0, cliprect, 0);
144   }
145   else
146      bitmap_fill(bitmap, cliprect, get_black_pen(screen->machine));
147   return 0;
148}
149
150/*************************************
151 *
152 *  Memory handlers
153 *
154 *************************************/
155
37156static TIMER_CALLBACK( dac_callback )
38157{
158   mjsister_state *state = (mjsister_state *)machine->driver_data;
39159   UINT8 *DACROM = memory_region(machine, "samples");
40160
41   dac_data_w(devtag_get_device(machine, "dac"),DACROM[(dac_bank * 0x10000 + dac_adr++) & 0x1ffff]);
161   dac_data_w(state->dac, DACROM[(state->dac_bank * 0x10000 + state->dac_adr++) & 0x1ffff]);
42162
43   if (((dac_adr & 0xff00 ) >> 8) !=  dac_adr_e )
163   if (((state->dac_adr & 0xff00 ) >> 8) !=  state->dac_adr_e)
44164      timer_set(machine, attotime_mul(ATTOTIME_IN_HZ(MCLK), 1024), NULL, 0, dac_callback);
45165   else
46      dac_busy = 0;
166      state->dac_busy = 0;
47167}
48168
49169static WRITE8_HANDLER( mjsister_dac_adr_s_w )
50170{
51   dac_adr_s = data;
171   mjsister_state *state = (mjsister_state *)space->machine->driver_data;
172   state->dac_adr_s = data;
52173}
53174
54175static WRITE8_HANDLER( mjsister_dac_adr_e_w )
55176{
56   dac_adr_e = data;
57   dac_adr = dac_adr_s << 8;
177   mjsister_state *state = (mjsister_state *)space->machine->driver_data;
178   state->dac_adr_e = data;
179   state->dac_adr = state->dac_adr_s << 8;
58180
59   if (dac_busy == 0)
60      timer_call_after_resynch(space->machine, NULL, 0,dac_callback);
181   if (state->dac_busy == 0)
182      timer_call_after_resynch(space->machine, NULL, 0, dac_callback);
61183
62   dac_busy = 1;
184   state->dac_busy = 1;
63185}
64186
65static MACHINE_RESET( mjsister )
66{
67   dac_busy = 0;
68}
69
70187static WRITE8_HANDLER( mjsister_banksel1_w )
71188{
72   UINT8 *BANKROM = memory_region(space->machine, "maincpu");
73   int tmp = mjsister_colorbank;
189   mjsister_state *state = (mjsister_state *)space->machine->driver_data;
190   int tmp = state->colorbank;
74191
75192   switch (data)
76193   {
77      case 0x0: rombank0 = 0 ; break;
78      case 0x1: rombank0 = 1 ; break;
194      case 0x0: state->rombank0 = 0 ; break;
195      case 0x1: state->rombank0 = 1 ; break;
79196
80      case 0x2: mjsister_flip_screen = 0 ; break;
81      case 0x3: mjsister_flip_screen = 1 ; break;
197      case 0x2: state->flip_screen = 0 ; break;
198      case 0x3: state->flip_screen = 1 ; break;
82199
83      case 0x4: mjsister_colorbank &=0xfe; break;
84      case 0x5: mjsister_colorbank |=0x01; break;
85      case 0x6: mjsister_colorbank &=0xfd; break;
86      case 0x7: mjsister_colorbank |=0x02; break;
87      case 0x8: mjsister_colorbank &=0xfb; break;
88      case 0x9: mjsister_colorbank |=0x04; break;
200      case 0x4: state->colorbank &= 0xfe; break;
201      case 0x5: state->colorbank |= 0x01; break;
202      case 0x6: state->colorbank &= 0xfd; break;
203      case 0x7: state->colorbank |= 0x02; break;
204      case 0x8: state->colorbank &= 0xfb; break;
205      case 0x9: state->colorbank |= 0x04; break;
89206
90      case 0xa: mjsister_video_enable = 0 ; break;
91      case 0xb: mjsister_video_enable = 1 ; break;
207      case 0xa: state->video_enable = 0 ; break;
208      case 0xb: state->video_enable = 1 ; break;
92209
93      case 0xe: mjsister_vrambank = 0 ; break;
94      case 0xf: mjsister_vrambank = 1 ; break;
210      case 0xe: state->vrambank = 0 ; break;
211      case 0xf: state->vrambank = 1 ; break;
95212
96213      default:
97         logerror("%04x p30_w:%02x\n",cpu_get_pc(space->cpu),data);
214         logerror("%04x p30_w:%02x\n", cpu_get_pc(space->cpu), data);
98215   }
99216
100   if (tmp != mjsister_colorbank)
101      mjsister_screen_redraw = 1;
217   if (tmp != state->colorbank)
218      state->screen_redraw = 1;
102219
103   memory_set_bankptr(space->machine, "bank1",&BANKROM[rombank0*0x10000+rombank1*0x8000]+0x10000);
220   memory_set_bank(space->machine, "bank1", state->rombank0 * 2 + state->rombank1);
104221}
105222
106223static WRITE8_HANDLER( mjsister_banksel2_w )
107224{
108   UINT8 *BANKROM = memory_region(space->machine, "maincpu");
225   mjsister_state *state = (mjsister_state *)space->machine->driver_data;
109226
110227   switch (data)
111228   {
112      case 0xa: dac_bank = 0; break;
113      case 0xb: dac_bank = 1; break;
229      case 0xa: state->dac_bank = 0; break;
230      case 0xb: state->dac_bank = 1; break;
114231
115      case 0xc: rombank1 = 0; break;
116      case 0xd: rombank1 = 1; break;
232      case 0xc: state->rombank1 = 0; break;
233      case 0xd: state->rombank1 = 1; break;
117234
118235      default:
119         logerror("%04x p31_w:%02x\n",cpu_get_pc(space->cpu),data);
236         logerror("%04x p31_w:%02x\n", cpu_get_pc(space->cpu), data);
120237   }
121238
122   memory_set_bankptr(space->machine, "bank1",&BANKROM[rombank0*0x10000+rombank1*0x8000]+0x10000);
239   memory_set_bank(space->machine, "bank1", state->rombank0 * 2 + state->rombank1);
123240}
124241
125242static WRITE8_HANDLER( mjsister_input_sel1_w )
126243{
127   mjsister_input_sel1 = data;
244   mjsister_state *state = (mjsister_state *)space->machine->driver_data;
245   state->input_sel1 = data;
128246}
129247
130248static WRITE8_HANDLER( mjsister_input_sel2_w )
131249{
132   mjsister_input_sel2 = data;
250   mjsister_state *state = (mjsister_state *)space->machine->driver_data;
251   state->input_sel2 = data;
133252}
134253
135254static READ8_HANDLER( mjsister_keys_r )
136255{
137   int p,i,ret = 0;
256   mjsister_state *state = (mjsister_state *)space->machine->driver_data;
257   int p, i, ret = 0;
138258   static const char *const keynames[] = { "KEY0", "KEY1", "KEY2", "KEY3", "KEY4", "KEY5" };
139259
140   p = mjsister_input_sel1 & 0x3f;
141//  p |= ((mjsister_input_sel2 & 8) << 4) | ((mjsister_input_sel2 & 0x20) << 1);
260   p = state->input_sel1 & 0x3f;
261   //  p |= ((state->input_sel2 & 8) << 4) | ((state->input_sel2 & 0x20) << 1);
142262
143   for (i=0; i<6; i++)
263   for (i = 0; i < 6; i++)
144264   {
145      if (p & (1 << i))
265      if (BIT(p, i))
146266         ret |= input_port_read(space->machine, keynames[i]);
147267   }
148268
149269   return ret;
150270}
151271
152/****************************************************************************/
272/*************************************
273 *
274 *  Address maps
275 *
276 *************************************/
153277
154278static ADDRESS_MAP_START( mjsister_map, ADDRESS_SPACE_PROGRAM, 8 )
155279   AM_RANGE(0x0000, 0x77ff) AM_ROM
r7500r7501
174298ADDRESS_MAP_END
175299
176300
177/****************************************************************************/
301/*************************************
302 *
303 *  Input ports
304 *
305 *************************************/
178306
179307static INPUT_PORTS_START( mjsister )
180
181   PORT_START("DSW1")   /* DSW1 (0) */
308   PORT_START("DSW1")
182309   PORT_DIPNAME( 0x07, 0x07, DEF_STR( Coinage ) )
183310   PORT_DIPSETTING(   0x03, DEF_STR( 5C_1C ) )
184311   PORT_DIPSETTING(   0x00, DEF_STR( 4C_1C ) )
r7500r7501
202329   PORT_DIPSETTING(   0x80, DEF_STR( Off ) )
203330   PORT_DIPSETTING(   0x00, DEF_STR( On ) )
204331
205   PORT_START("DSW2")   /* DSW2 (1) */
332   PORT_START("DSW2")
206333   PORT_DIPNAME( 0x01, 0x01, "Unknown 2-1" )
207334   PORT_DIPSETTING(   0x01, DEF_STR( Off ) )
208335   PORT_DIPSETTING(   0x00, DEF_STR( On ) )
r7500r7501
228355   PORT_DIPSETTING(   0x80, DEF_STR( Off ) )
229356   PORT_DIPSETTING(   0x00, DEF_STR( On ) )
230357
231   PORT_START("IN0")   /* (2) */
358   PORT_START("IN0")
232359   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_COIN2 )
233360   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_UNKNOWN ) /* memory reset 1 */
234361   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_UNKNOWN ) /* analyzer */
r7500r7501
238365   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_COIN1 )
239366   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_UNKNOWN ) /* hopper */
240367
241   PORT_START("KEY0")   /* (3) PORT 1-0 */
242   PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_MAHJONG_A )
243   PORT_BIT(0x02, IP_ACTIVE_HIGH, IPT_MAHJONG_B )
244   PORT_BIT(0x04, IP_ACTIVE_HIGH, IPT_MAHJONG_C )
245   PORT_BIT(0x08, IP_ACTIVE_HIGH, IPT_MAHJONG_D )
246   PORT_BIT(0x10, IP_ACTIVE_HIGH, IPT_MAHJONG_LAST_CHANCE )
368   PORT_START("KEY0")
369   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_MAHJONG_A )
370   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_MAHJONG_B )
371   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_MAHJONG_C )
372   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_MAHJONG_D )
373   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_MAHJONG_LAST_CHANCE )
247374   PORT_BIT( 0xe0, IP_ACTIVE_HIGH, IPT_UNUSED )
248375
249   PORT_START("KEY1")   /* (4) PORT 1-1 */
250   PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_MAHJONG_E )
251   PORT_BIT(0x02, IP_ACTIVE_HIGH, IPT_MAHJONG_F )
252   PORT_BIT(0x04, IP_ACTIVE_HIGH, IPT_MAHJONG_G )
253   PORT_BIT(0x08, IP_ACTIVE_HIGH, IPT_MAHJONG_H )
254   PORT_BIT(0x10, IP_ACTIVE_HIGH, IPT_MAHJONG_SCORE )
376   PORT_START("KEY1")
377   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_MAHJONG_E )
378   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_MAHJONG_F )
379   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_MAHJONG_G )
380   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_MAHJONG_H )
381   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_MAHJONG_SCORE )
255382   PORT_BIT( 0xe0, IP_ACTIVE_HIGH, IPT_UNUSED )
256383
257   PORT_START("KEY2")   /* (5) PORT 1-2 */
258   PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_MAHJONG_I )
259   PORT_BIT(0x02, IP_ACTIVE_HIGH, IPT_MAHJONG_J )
260   PORT_BIT(0x04, IP_ACTIVE_HIGH, IPT_MAHJONG_K )
261   PORT_BIT(0x08, IP_ACTIVE_HIGH, IPT_MAHJONG_L )
262   PORT_BIT(0x10, IP_ACTIVE_HIGH, IPT_MAHJONG_DOUBLE_UP )
384   PORT_START("KEY2")
385   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_MAHJONG_I )
386   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_MAHJONG_J )
387   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_MAHJONG_K )
388   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_MAHJONG_L )
389   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_MAHJONG_DOUBLE_UP )
263390   PORT_BIT( 0xe0, IP_ACTIVE_HIGH, IPT_UNUSED )
264391
265   PORT_START("KEY3")   /* (6) PORT 1-3 */
266   PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_MAHJONG_M )
267   PORT_BIT(0x02, IP_ACTIVE_HIGH, IPT_MAHJONG_N )
268   PORT_BIT(0x04, IP_ACTIVE_HIGH, IPT_MAHJONG_CHI )
269   PORT_BIT(0x08, IP_ACTIVE_HIGH, IPT_MAHJONG_PON )
270   PORT_BIT(0x10, IP_ACTIVE_HIGH, IPT_MAHJONG_FLIP_FLOP )
392   PORT_START("KEY3")
393   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_MAHJONG_M )
394   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_MAHJONG_N )
395   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_MAHJONG_CHI )
396   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_MAHJONG_PON )
397   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_MAHJONG_FLIP_FLOP )
271398   PORT_BIT( 0xe0, IP_ACTIVE_HIGH, IPT_UNUSED )
272399
273   PORT_START("KEY4")   /* (7) PORT 1-4 */
274   PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_MAHJONG_KAN )
275   PORT_BIT(0x02, IP_ACTIVE_HIGH, IPT_MAHJONG_REACH )
276   PORT_BIT(0x04, IP_ACTIVE_HIGH, IPT_MAHJONG_RON )
400   PORT_START("KEY4")
401   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_MAHJONG_KAN )
402   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_MAHJONG_REACH )
403   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_MAHJONG_RON )
277404   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_UNKNOWN )
278   PORT_BIT(0x10, IP_ACTIVE_HIGH, IPT_MAHJONG_BIG )
405   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_MAHJONG_BIG )
279406   PORT_BIT( 0xe0, IP_ACTIVE_HIGH, IPT_UNUSED )
280407
281   PORT_START("KEY5")   /* (8) PORT 1-5 */
408   PORT_START("KEY5")
282409   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_START1 )
283   PORT_BIT(0x02, IP_ACTIVE_HIGH, IPT_MAHJONG_BET )
410   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_MAHJONG_BET )
284411   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_UNKNOWN )
285412   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_UNKNOWN )
286   PORT_BIT(0x10, IP_ACTIVE_HIGH, IPT_MAHJONG_SMALL )
413   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_MAHJONG_SMALL )
287414   PORT_BIT( 0xe0, IP_ACTIVE_HIGH, IPT_UNUSED )
288415
289416INPUT_PORTS_END
290417
291/****************************************************************************/
418/*************************************
419 *
420 *  Sound interface
421 *
422 *************************************/
292423
293424static const ay8910_interface ay8910_config =
294425{
r7500r7501
300431   DEVCB_NULL
301432};
302433
434/*************************************
435 *
436 *  Machine driver
437 *
438 *************************************/
439
440static STATE_POSTLOAD( mjsister_redraw )
441{
442   mjsister_state *state = (mjsister_state *)machine->driver_data;
443
444   /* we can skip saving tmpbitmaps because we can redraw them from vram */
445   state->screen_redraw = 1;
446}
447
448static MACHINE_START( mjsister )
449{
450   mjsister_state *state = (mjsister_state *)machine->driver_data;
451   UINT8 *ROM = memory_region(machine, "maincpu");
452
453   memory_configure_bank(machine, "bank1", 0, 4, &ROM[0x10000], 0x8000);
454
455   state->maincpu = devtag_get_device(machine, "maincpu");
456   state->dac = devtag_get_device(machine, "dac");
457
458   state_save_register_global(machine, state->dac_busy);
459   state_save_register_global(machine, state->flip_screen);
460   state_save_register_global(machine, state->video_enable);
461   state_save_register_global(machine, state->vrambank);
462   state_save_register_global(machine, state->colorbank);
463   state_save_register_global(machine, state->input_sel1);
464   state_save_register_global(machine, state->input_sel2);
465   state_save_register_global(machine, state->rombank0);
466   state_save_register_global(machine, state->rombank1);
467   state_save_register_global(machine, state->dac_adr);
468   state_save_register_global(machine, state->dac_bank);
469   state_save_register_global(machine, state->dac_adr_s);
470   state_save_register_global(machine, state->dac_adr_e);
471   state_save_register_postload(machine, mjsister_redraw, 0);
472}
473
474static MACHINE_RESET( mjsister )
475{
476   mjsister_state *state = (mjsister_state *)machine->driver_data;
477
478   state->dac_busy = 0;
479   state->flip_screen = 0;
480   state->video_enable = 0;
481   state->screen_redraw = 0;
482   state->vrambank = 0;
483   state->colorbank = 0;
484   state->input_sel1 = 0;
485   state->input_sel2 = 0;
486   state->rombank0 = 0;
487   state->rombank1 = 0;
488   state->dac_adr = 0;
489   state->dac_bank = 0;
490   state->dac_adr_s = 0;
491   state->dac_adr_e = 0;
492}
493
494
303495static MACHINE_DRIVER_START( mjsister )
304496
497   /* driver data */
498   MDRV_DRIVER_DATA(mjsister_state)
499
305500   /* basic machine hardware */
306501   MDRV_CPU_ADD("maincpu", Z80, MCLK/2) /* 6.000 MHz */
307502   MDRV_CPU_PROGRAM_MAP(mjsister_map)
308503   MDRV_CPU_IO_MAP(mjsister_io_map)
309504   MDRV_CPU_VBLANK_INT_HACK(irq0_line_hold,2)
310505
506   MDRV_MACHINE_START(mjsister)
311507   MDRV_MACHINE_RESET(mjsister)
312508
313509   /* video hardware */
r7500r7501
335531   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0)
336532MACHINE_DRIVER_END
337533
338/***************************************************************************
534/*************************************
535 *
536 *  ROM definition(s)
537 *
538 *************************************/
339539
340  Game driver(s)
341
342***************************************************************************/
343
344540ROM_START( mjsister )
345541   ROM_REGION( 0x30000, "maincpu", 0 )   /* CPU */
346542   ROM_LOAD( "ms00.bin",  0x00000, 0x08000, CRC(9468c33b) SHA1(63aecdcaa8493d58549dfd1d217743210cf953bc) )
r7500r7501
358554   ROM_LOAD( "ms08.bpr", 0x0300,  0x0100, CRC(da2b3b38) SHA1(4de99c17b227653bc1b904f1309f447f5a0ab516) ) // ?
359555ROM_END
360556
361GAME( 1986, mjsister, 0, mjsister, mjsister, 0, ROT0, "Toaplan", "Mahjong Sisters (Japan)", 0 )
362557
558/*************************************
559 *
560 *  Game driver(s)
561 *
562 *************************************/
563
564GAME( 1986, mjsister, 0, mjsister, mjsister, 0, ROT0, "Toaplan", "Mahjong Sisters (Japan)", GAME_SUPPORTS_SAVE )
src/mame/drivers/onetwo.c
r7500r7501
4444#include "sound/okim6295.h"
4545#include "sound/3812intf.h"
4646
47static tilemap_t *fg_tilemap;
48static UINT8 *fgram;
47#define MASTER_CLOCK        XTAL_4MHz
4948
50#define MASTER_CLOCK   (XTAL_4MHz)
49class onetwo_state
50{
51public:
52   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, onetwo_state(machine)); }
5153
54   onetwo_state(running_machine &machine) { }
55
56   /* memory pointers */
57   UINT8 *  fgram;
58   UINT8 *  paletteram;
59   UINT8 *  paletteram2;
60
61   /* video-related */
62   tilemap_t *fg_tilemap;
63
64   /* devices */
65   running_device *maincpu;
66   running_device *audiocpu;
67};
68
69
70
71/*************************************
72 *
73 *  Video emulation
74 *
75 *************************************/
76
5277static TILE_GET_INFO( get_fg_tile_info )
5378{
54   int code = (fgram[tile_index*2+1]<<8) | fgram[tile_index*2];
55   int color = (fgram[tile_index*2+1] & 0x80) >> 7;
79   onetwo_state *state = (onetwo_state *)machine->driver_data;
80   int code = (state->fgram[tile_index * 2 + 1] << 8) | state->fgram[tile_index * 2];
81   int color = (state->fgram[tile_index * 2 + 1] & 0x80) >> 7;
5682
5783   code &= 0x7fff;
5884
5985   SET_TILE_INFO(0, code, color, 0);
6086}
6187
88static VIDEO_START( onetwo )
89{
90   onetwo_state *state = (onetwo_state *)machine->driver_data;
91   state->fg_tilemap = tilemap_create(machine, get_fg_tile_info, tilemap_scan_rows, 8, 8, 64, 32);
92}
93
94static VIDEO_UPDATE( onetwo )
95{
96   onetwo_state *state = (onetwo_state *)screen->machine->driver_data;
97   tilemap_draw(bitmap, cliprect, state->fg_tilemap, 0, 0);
98   return 0;
99}
100
101/*************************************
102 *
103 *  Memory handlers
104 *
105 *************************************/
106
62107static WRITE8_HANDLER( onetwo_fgram_w )
63108{
64   fgram[offset] = data;
65   tilemap_mark_tile_dirty(fg_tilemap, offset / 2);
109   onetwo_state *state = (onetwo_state *)space->machine->driver_data;
110   state->fgram[offset] = data;
111   tilemap_mark_tile_dirty(state->fg_tilemap, offset / 2);
66112}
67113
68114static WRITE8_HANDLER( onetwo_cpubank_w )
69115{
70   UINT8 *RAM = memory_region(space->machine, "maincpu") + 0x10000;
71
72   memory_set_bankptr(space->machine, "bank1", &RAM[data * 0x4000]);
116   memory_set_bank(space->machine, "bank1", data);
73117}
74118
75119static WRITE8_HANDLER( onetwo_coin_counters_w )
76120{
77121   watchdog_reset(space->machine);
78   coin_counter_w(space->machine, 0, data & 0x02);
79   coin_counter_w(space->machine, 1, data & 0x04);
122   coin_counter_w(space->machine, 0, BIT(data, 1));
123   coin_counter_w(space->machine, 1, BIT(data, 2));
80124}
81125
82126static WRITE8_HANDLER( onetwo_soundlatch_w )
83127{
128   onetwo_state *state = (onetwo_state *)space->machine->driver_data;
84129   soundlatch_w(space, 0, data);
85   cputag_set_input_line(space->machine, "audiocpu", INPUT_LINE_NMI, PULSE_LINE);
130   cpu_set_input_line(state->audiocpu, INPUT_LINE_NMI, PULSE_LINE);
86131}
87132
88static void setColor(running_machine *machine, int offset)
133static void set_color(running_machine *machine, int offset)
89134{
90      int r, g, b;
91      r = machine->generic.paletteram.u8[offset] & 0x1f;
92      g = machine->generic.paletteram2.u8[offset] & 0x1f;
93      b = ((machine->generic.paletteram.u8[offset] & 0x60) >> 2) | ((machine->generic.paletteram2.u8[offset] & 0xe0) >> 5);
94      palette_set_color_rgb(machine, offset, pal5bit(r), pal5bit(g), pal5bit(b));
135   onetwo_state *state = (onetwo_state *)machine->driver_data;
136   int r, g, b;
137
138   r = state->paletteram[offset] & 0x1f;
139   g = state->paletteram2[offset] & 0x1f;
140   b = ((state->paletteram[offset] & 0x60) >> 2) | ((state->paletteram2[offset] & 0xe0) >> 5);
141   palette_set_color_rgb(machine, offset, pal5bit(r), pal5bit(g), pal5bit(b));
95142}
96143
97144static WRITE8_HANDLER(palette1_w)
98145{
99   space->machine->generic.paletteram.u8[offset] = data;
100   setColor(space->machine, offset);
146   onetwo_state *state = (onetwo_state *)space->machine->driver_data;
147   state->paletteram[offset] = data;
148   set_color(space->machine, offset);
101149}
102150
103151static WRITE8_HANDLER(palette2_w)
104152{
105   space->machine->generic.paletteram2.u8[offset] = data;
106   setColor(space->machine, offset);
153   onetwo_state *state = (onetwo_state *)space->machine->driver_data;
154   state->paletteram2[offset] = data;
155   set_color(space->machine, offset);
107156}
108157
109/* Main CPU */
158/*************************************
159 *
160 *  Address maps
161 *
162 *************************************/
110163
111164static ADDRESS_MAP_START( main_cpu, ADDRESS_SPACE_PROGRAM, 8 )
112165   AM_RANGE(0x0000, 0x7fff) AM_ROM AM_REGION("maincpu", 0x10000)
113166   AM_RANGE(0x8000, 0xbfff) AM_ROMBANK("bank1")
114   AM_RANGE(0xc800, 0xc87f) AM_RAM_WRITE(palette1_w) AM_BASE_GENERIC(paletteram)
115   AM_RANGE(0xc900, 0xc97f) AM_RAM_WRITE(palette2_w) AM_BASE_GENERIC(paletteram2)
116   AM_RANGE(0xd000, 0xdfff) AM_RAM_WRITE(onetwo_fgram_w) AM_BASE(&fgram)
167   AM_RANGE(0xc800, 0xc87f) AM_RAM_WRITE(palette1_w) AM_BASE_MEMBER(onetwo_state, paletteram)
168   AM_RANGE(0xc900, 0xc97f) AM_RAM_WRITE(palette2_w) AM_BASE_MEMBER(onetwo_state, paletteram2)
169   AM_RANGE(0xd000, 0xdfff) AM_RAM_WRITE(onetwo_fgram_w) AM_BASE_MEMBER(onetwo_state, fgram)
117170   AM_RANGE(0xe000, 0xffff) AM_RAM
118171ADDRESS_MAP_END
119172
r7500r7501
126179   AM_RANGE(0x04, 0x04) AM_READ_PORT("SYSTEM")
127180ADDRESS_MAP_END
128181
129/* Sound CPU */
130
131182static ADDRESS_MAP_START( sound_cpu, ADDRESS_SPACE_PROGRAM, 8 )
132183   AM_RANGE(0x0000, 0x5fff) AM_ROM
133184   AM_RANGE(0xf000, 0xf7ff) AM_RAM
r7500r7501
142193   AM_RANGE(0xc0, 0xc0) AM_WRITE(soundlatch_clear_w)
143194ADDRESS_MAP_END
144195
196/*************************************
197 *
198 *  Input ports
199 *
200 *************************************/
201
145202static INPUT_PORTS_START( onetwo )
146203   PORT_START("DSW1")
147204   PORT_DIPNAME( 0x03, 0x03, "Timer" ) PORT_DIPLOCATION("SW1:1,2")
r7500r7501
240297   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
241298INPUT_PORTS_END
242299
300/*************************************
301 *
302 *  Graphics definitions
303 *
304 *************************************/
305
243306static const gfx_layout tiles8x8x6_layout =
244307{
245308   8,8,
r7500r7501
255318   GFXDECODE_ENTRY( "gfx1", 0, tiles8x8x6_layout, 0, 2 )
256319GFXDECODE_END
257320
258static VIDEO_START( onetwo )
259{
260   fg_tilemap = tilemap_create(machine, get_fg_tile_info, tilemap_scan_rows, 8, 8, 64, 32);
261}
321/*************************************
322 *
323 *  Sound interface
324 *
325 *************************************/
262326
263static VIDEO_UPDATE( onetwo )
264{
265   tilemap_draw(bitmap, cliprect, fg_tilemap, 0, 0);
266   return 0;
267}
268
269327static void irqhandler(running_device *device, int linestate)
270328{
271   cputag_set_input_line(device->machine, "audiocpu", 0, linestate);
329   onetwo_state *state = (onetwo_state *)device->machine->driver_data;
330   cpu_set_input_line(state->audiocpu, 0, linestate);
272331}
273332
274333static const ym3812_interface ym3812_config =
r7500r7501
276335   irqhandler   /* IRQ Line */
277336};
278337
338/*************************************
339 *
340 *  Machine driver
341 *
342 *************************************/
343
344static MACHINE_START( onetwo )
345{
346   onetwo_state *state = (onetwo_state *)machine->driver_data;
347   UINT8 *ROM = memory_region(machine, "maincpu");
348
349   memory_configure_bank(machine, "bank1", 0, 8, &ROM[0x10000], 0x4000);
350
351   state->maincpu = devtag_get_device(machine, "maincpu");
352   state->audiocpu = devtag_get_device(machine, "audiocpu");
353}
354
279355static MACHINE_DRIVER_START( onetwo )
356
357   /* driver data */
358   MDRV_DRIVER_DATA(onetwo_state)
359
280360   /* basic machine hardware */
281361   MDRV_CPU_ADD("maincpu", Z80,MASTER_CLOCK)   /* 4 MHz */
282362   MDRV_CPU_PROGRAM_MAP(main_cpu)
r7500r7501
287367   MDRV_CPU_PROGRAM_MAP(sound_cpu)
288368   MDRV_CPU_IO_MAP(sound_cpu_io)
289369
370   MDRV_MACHINE_START(onetwo)
371
290372   /* video hardware */
291373   MDRV_SCREEN_ADD("screen", RASTER)
292374   MDRV_SCREEN_REFRESH_RATE(60)
r7500r7501
313395   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0)
314396MACHINE_DRIVER_END
315397
398/*************************************
399 *
400 *  ROM definition(s)
401 *
402 *************************************/
403
316404ROM_START( onetwo )
317405   ROM_REGION( 0x30000, "maincpu", 0 ) /* main z80 */
318406   ROM_LOAD( "maincpu", 0x10000,  0x20000, CRC(83431e6e) SHA1(61ab386a1d0af050f091f5df28c55ad5ad1a0d4b) )
r7500r7501
345433   ROM_LOAD( "sample", 0x000000, 0x40000, CRC(b10d3132) SHA1(42613e17b6a1300063b8355596a2dc7bcd903777) )
346434ROM_END
347435
348GAME( 1997, onetwo,       0, onetwo, onetwo, 0, ROT0, "Barko", "One + Two", 0 )
349GAME( 1997, onetwoe, onetwo, onetwo, onetwo, 0, ROT0, "Barko", "One + Two (earlier)", 0 )
436/*************************************
437 *
438 *  Game driver(s)
439 *
440 *************************************/
441
442GAME( 1997, onetwo,       0, onetwo, onetwo, 0, ROT0, "Barko", "One + Two", GAME_SUPPORTS_SAVE )
443GAME( 1997, onetwoe, onetwo, onetwo, onetwo, 0, ROT0, "Barko", "One + Two (earlier)", GAME_SUPPORTS_SAVE )
src/mame/drivers/liberate.c
r7500r7501
3535      return ROM[offset];
3636
3737   /* Else the handler falls through to read the usual address */
38   if (offset<0x400) return state->colorram[offset];
39   if (offset<0x800) return state->videoram[offset-0x400];
40   if (offset<0x1000) return space->machine->generic.spriteram.u8[offset-0x800];
41   if (offset<0x2200) { logerror("%04x: Unmapped bank read %04x\n",cpu_get_pc(space->cpu),offset); return 0; }
42   if (offset<0x2800) return state->scratchram[offset-0x2200];
38   if (offset < 0x400)
39      return state->colorram[offset];
40   if (offset < 0x800)
41      return state->videoram[offset - 0x400];
42   if (offset < 0x1000)
43      return state->spriteram[offset - 0x800];
44   if (offset < 0x2200)
45   {
46      logerror("%04x: Unmapped bank read %04x\n", cpu_get_pc(space->cpu), offset);
47      return 0;
48   }
49   if (offset < 0x2800)
50      return state->scratchram[offset - 0x2200];
4351
44   logerror("%04x: Unmapped bank read %04x\n",cpu_get_pc(space->cpu),offset);
52   logerror("%04x: Unmapped bank read %04x\n", cpu_get_pc(space->cpu), offset);
4553   return 0;
4654}
4755
4856static READ8_HANDLER( deco16_io_r )
4957{
50   if (offset==0) return input_port_read(space->machine, "IN1"); /* Player 1 controls */
51   if (offset==1) return input_port_read(space->machine, "IN2"); /* Player 2 controls */
52   if (offset==2) return input_port_read(space->machine, "IN3"); /* Vblank, coins */
53   if (offset==3) return input_port_read(space->machine, "DSW1"); /* Dip 1 */
54   if (offset==4) return input_port_read(space->machine, "DSW2"); /* Dip 2 */
58   if (offset == 0) return input_port_read(space->machine, "IN1"); /* Player 1 controls */
59   if (offset == 1) return input_port_read(space->machine, "IN2"); /* Player 2 controls */
60   if (offset == 2) return input_port_read(space->machine, "IN3"); /* Vblank, coins */
61   if (offset == 3) return input_port_read(space->machine, "DSW1"); /* Dip 1 */
62   if (offset == 4) return input_port_read(space->machine, "DSW2"); /* Dip 2 */
5563
56   logerror("%04x:  Read input %d\n",cpu_get_pc(space->cpu),offset);
64   logerror("%04x:  Read input %d\n", cpu_get_pc(space->cpu), offset);
5765   return 0xff;
5866}
5967
r7500r7501
6371   state->bank = data;
6472
6573   if (state->bank)
66      memory_install_read8_handler(cputag_get_address_space(space->machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x8000, 0x800f, 0, 0, deco16_io_r);
74      memory_install_read8_handler(cpu_get_address_space(state->maincpu, ADDRESS_SPACE_PROGRAM), 0x8000, 0x800f, 0, 0, deco16_io_r);
6775   else
68      memory_install_read_bank(cputag_get_address_space(space->machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x8000, 0x800f, 0, 0, "bank1");
76      memory_install_read_bank(cpu_get_address_space(state->maincpu, ADDRESS_SPACE_PROGRAM), 0x8000, 0x800f, 0, 0, "bank1");
6977}
7078
7179static READ8_HANDLER( prosoccr_bank_r )
r7500r7501
7886      return ROM[offset];
7987
8088   /* Else the handler falls through to read the usual address */
81   if (offset<0x400) return state->colorram[offset];
82   if (offset<0x800) return state->videoram[offset-0x400];
83   if (offset<0xc00) return state->colorram[offset-0x800];
84   if (offset<0x1000) return space->machine->generic.spriteram.u8[offset-0xc00];
85   if (offset<0x2200) { logerror("%04x: Unmapped bank read %04x\n",cpu_get_pc(space->cpu),offset); return 0; }
86   if (offset<0x2800) return state->scratchram[offset-0x2200];
89   if (offset < 0x400)
90      return state->colorram[offset];
91   if (offset < 0x800)
92      return state->videoram[offset - 0x400];
93   if (offset < 0xc00)
94      return state->colorram[offset - 0x800];
95   if (offset < 0x1000)
96      return state->spriteram[offset - 0xc00];
97   if (offset < 0x2200)
98   {
99      logerror("%04x: Unmapped bank read %04x\n", cpu_get_pc(space->cpu), offset);
100      return 0;
101   }
102   if (offset < 0x2800)
103      return state->scratchram[offset - 0x2200];
87104
88   logerror("%04x: Unmapped bank read %04x\n",cpu_get_pc(space->cpu),offset);
105   logerror("%04x: Unmapped bank read %04x\n", cpu_get_pc(space->cpu), offset);
89106   return 0;
90107}
91108
r7500r7501
96113
97114   if (state->gfx_rom_readback)
98115   {
99      switch(offset & 0x1800)
116      switch (offset & 0x1800)
100117      {
101118         case 0x0000:
102            return SRC_GFX[(offset & 0x7ff)+(0x0000)+0x0000];
119            return SRC_GFX[(offset & 0x7ff) + (0x0000) + 0x0000];
103120         case 0x0800:
104            return SRC_GFX[(offset & 0x7ff)+(0x0000)+0x2000];
121            return SRC_GFX[(offset & 0x7ff) + (0x0000) + 0x2000];
105122         case 0x1000:
106            return SRC_GFX[(offset & 0x7ff)+(0x0000)+0x4000];
123            return SRC_GFX[(offset & 0x7ff) + (0x0000) + 0x4000];
107124      }
108125   }
109126
110127   /* note: gfx_rom_readback == 1 never happens. */
111   return state->charram[offset+state->gfx_rom_readback*0x1800];
128   return state->charram[offset + state->gfx_rom_readback * 0x1800];
112129}
113130
114131static WRITE8_HANDLER( prosoccr_charram_w )
r7500r7501
118135
119136   if (state->bank)
120137   {
121      prosoccr_io_w(space,offset & 0xf,data);
138      prosoccr_io_w(space, offset & 0x0f, data);
122139   }
123140   else
124141   {
125142      /* note: gfx_rom_readback == 1 never happens. */
126      state->charram[offset+state->gfx_rom_readback*0x1800] = data;
143      state->charram[offset + state->gfx_rom_readback * 0x1800] = data;
127144
128      switch(offset & 0x1800)
145      switch (offset & 0x1800)
129146      {
130147         case 0x0000:
131            FG_GFX[(offset & 0x7ff)+(0x0000)+0x0000] = data;
132            //FG_GFX[(offset & 0x7ff)+(0x1800)+0x0000] = data;
148            FG_GFX[(offset & 0x7ff) + (0x0000) + 0x0000] = data;
149            //FG_GFX[(offset & 0x7ff) + (0x1800) + 0x0000] = data;
133150            break;
134151         case 0x0800:
135            FG_GFX[(offset & 0x7ff)+(0x0000)+0x2000] = data;
136            //FG_GFX[(offset & 0x7ff)+(0x1800)+0x2000] = data;
152            FG_GFX[(offset & 0x7ff) + (0x0000) + 0x2000] = data;
153            //FG_GFX[(offset & 0x7ff) + (0x1800) + 0x2000] = data;
137154            break;
138155         case 0x1000:
139            FG_GFX[(offset & 0x7ff)+(0x0000)+0x4000] = data;
140            //FG_GFX[(offset & 0x7ff)+(0x1800)+0x4000] = data;
156            FG_GFX[(offset & 0x7ff) + (0x0000) + 0x4000] = data;
157            //FG_GFX[(offset & 0x7ff) + (0x1800) + 0x4000] = data;
141158            break;
142159      }
143160   }
144161
145   offset&=0x7ff;
162   offset &= 0x7ff;
146163
147164   /* dirty char */
148165   gfx_element_mark_dirty(space->machine->gfx[0], offset >> 3);
149//  gfx_element_mark_dirty(space->machine->gfx[0], (offset|0x1800) >> 3);
166//  gfx_element_mark_dirty(space->machine->gfx[0], (offset | 0x1800) >> 3);
150167}
151168
152169static WRITE8_HANDLER( prosoccr_char_bank_w )
153170{
154171   liberate_state *state = (liberate_state *)space->machine->driver_data;
155172   state->gfx_rom_readback = data & 1; //enable GFX rom read-back
156   if(data & 0xfe)
157      printf("%02x\n",data);
173
174   if (data & 0xfe)
175      printf("%02x\n", data);
158176}
159177
160178static WRITE8_HANDLER( prosoccr_io_bank_w )
r7500r7501
163181   state->bank = data & 1;
164182
165183   if (state->bank)
166      memory_install_read8_handler(cputag_get_address_space(space->machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x8000, 0x800f, 0, 0, deco16_io_r);
184      memory_install_read8_handler(cpu_get_address_space(state->maincpu, ADDRESS_SPACE_PROGRAM), 0x8000, 0x800f, 0, 0, deco16_io_r);
167185   else
168      memory_install_read8_handler(cputag_get_address_space(space->machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x8000, 0x800f, 0, 0, prosoccr_charram_r);
186      memory_install_read8_handler(cpu_get_address_space(state->maincpu, ADDRESS_SPACE_PROGRAM), 0x8000, 0x800f, 0, 0, prosoccr_charram_r);
169187
170188}
171189
r7500r7501
173191{
174192   UINT8 *FG_GFX = memory_region(space->machine, "progolf_fg_gfx");
175193
176   switch(offset & 0x1800)
194   switch (offset & 0x1800)
177195   {
178196      case 0x0000:
179         return FG_GFX[(offset & 0x7ff)+(0x0800)+0x0000];
180         //FG_GFX[(offset & 0x7ff)+(0x1800)+0x0000] = data;
197         return FG_GFX[(offset & 0x7ff) + (0x0800) + 0x0000];
198         //FG_GFX[(offset & 0x7ff) + (0x1800) + 0x0000] = data;
181199      case 0x0800:
182         return FG_GFX[(offset & 0x7ff)+(0x0800)+0x2000];
183         //FG_GFX[(offset & 0x7ff)+(0x1800)+0x2000] = data;
200         return FG_GFX[(offset & 0x7ff) + (0x0800) + 0x2000];
201         //FG_GFX[(offset & 0x7ff) + (0x1800) + 0x2000] = data;
184202      case 0x1000:
185         return FG_GFX[(offset & 0x7ff)+(0x0800)+0x4000];
186         //FG_GFX[(offset & 0x7ff)+(0x1800)+0x4000] = data;
203         return FG_GFX[(offset & 0x7ff) + (0x0800) + 0x4000];
204         //FG_GFX[(offset & 0x7ff) + (0x1800) + 0x4000] = data;
187205   }
188206
189207   return 0;
r7500r7501
193211{
194212   UINT8 *FG_GFX = memory_region(space->machine, "progolf_fg_gfx");
195213
196   switch(offset & 0x1800)
214   switch (offset & 0x1800)
197215   {
198216      case 0x0000:
199         FG_GFX[(offset & 0x7ff)+(0x0800)+0x0000] = data;
200         //FG_GFX[(offset & 0x7ff)+(0x1800)+0x0000] = data;
217         FG_GFX[(offset & 0x7ff) + (0x0800) + 0x0000] = data;
218         //FG_GFX[(offset & 0x7ff) + (0x1800) + 0x0000] = data;
201219         break;
202220      case 0x0800:
203         FG_GFX[(offset & 0x7ff)+(0x0800)+0x2000] = data;
204         //FG_GFX[(offset & 0x7ff)+(0x1800)+0x2000] = data;
221         FG_GFX[(offset & 0x7ff) + (0x0800) + 0x2000] = data;
222         //FG_GFX[(offset & 0x7ff) + (0x1800) + 0x2000] = data;
205223         break;
206224      case 0x1000:
207         FG_GFX[(offset & 0x7ff)+(0x0800)+0x4000] = data;
208         //FG_GFX[(offset & 0x7ff)+(0x1800)+0x4000] = data;
225         FG_GFX[(offset & 0x7ff) + (0x0800) + 0x4000] = data;
226         //FG_GFX[(offset & 0x7ff) + (0x1800) + 0x4000] = data;
209227         break;
210228   }
211229
212   offset&=0x7ff;
230   offset &= 0x7ff;
213231
214232   /* dirty char */
215   gfx_element_mark_dirty(space->machine->gfx[3], (offset+0x800) >> 3);
216   gfx_element_mark_dirty(space->machine->gfx[3+4], (offset+0x800) >> 5);
233   gfx_element_mark_dirty(space->machine->gfx[3], (offset + 0x800) >> 3);
234   gfx_element_mark_dirty(space->machine->gfx[3 + 4], (offset + 0x800) >> 5);
217235}
218236
219237
r7500r7501
224242 *************************************/
225243
226244static ADDRESS_MAP_START( prosport_map, ADDRESS_SPACE_PROGRAM, 8 )
227   AM_RANGE(0x0200, 0x021f) AM_RAM_WRITE(prosport_paletteram_w) AM_BASE_GENERIC(paletteram)
245   AM_RANGE(0x0200, 0x021f) AM_RAM_WRITE(prosport_paletteram_w) AM_BASE_MEMBER(liberate_state, paletteram)
228246   AM_RANGE(0x0000, 0x03ff) AM_MIRROR(0x2000) AM_RAM
229   AM_RANGE(0x0400, 0x07ff) AM_RAM_WRITE(prosport_bg_vram_w) AM_BASE_MEMBER(liberate_state,bg_vram)
247   AM_RANGE(0x0400, 0x07ff) AM_RAM_WRITE(prosport_bg_vram_w) AM_BASE_MEMBER(liberate_state, bg_vram)
230248   AM_RANGE(0x0800, 0x1fff) AM_READWRITE(prosport_charram_r,prosport_charram_w) //0x1e00-0x1fff isn't charram!
231249   AM_RANGE(0x2400, 0x2fff) AM_RAM
232   AM_RANGE(0x3000, 0x33ff) AM_RAM_WRITE(liberate_colorram_w) AM_BASE_MEMBER(liberate_state,colorram)
233   AM_RANGE(0x3400, 0x37ff) AM_RAM_WRITE(liberate_videoram_w) AM_BASE_MEMBER(liberate_state,videoram)
234   AM_RANGE(0x3800, 0x3fff) AM_RAM AM_BASE_GENERIC(spriteram)
250   AM_RANGE(0x3000, 0x33ff) AM_RAM_WRITE(liberate_colorram_w) AM_BASE_MEMBER(liberate_state, colorram)
251   AM_RANGE(0x3400, 0x37ff) AM_RAM_WRITE(liberate_videoram_w) AM_BASE_MEMBER(liberate_state, videoram)
252   AM_RANGE(0x3800, 0x3fff) AM_RAM AM_BASE_MEMBER(liberate_state, spriteram)
235253   AM_RANGE(0x8000, 0x800f) AM_WRITE(prosport_io_w)
236254   AM_RANGE(0x8000, 0x800f) AM_ROMBANK("bank1")
237255   AM_RANGE(0x4000, 0xffff) AM_ROM
r7500r7501
241259   AM_RANGE(0x0000, 0x0fff) AM_RAM
242260   AM_RANGE(0x1000, 0x3fff) AM_ROM /* Mirror of main rom */
243261   AM_RANGE(0x4000, 0x7fff) AM_READ(deco16_bank_r)
244   AM_RANGE(0x4000, 0x43ff) AM_WRITE(liberate_colorram_w) AM_BASE_MEMBER(liberate_state,colorram)
245   AM_RANGE(0x4400, 0x47ff) AM_WRITE(liberate_videoram_w) AM_BASE_MEMBER(liberate_state,videoram)
246   AM_RANGE(0x4800, 0x4fff) AM_WRITEONLY AM_BASE_GENERIC(spriteram)
247   AM_RANGE(0x6200, 0x67ff) AM_RAM AM_BASE_MEMBER(liberate_state,scratchram)
262   AM_RANGE(0x4000, 0x43ff) AM_WRITE(liberate_colorram_w) AM_BASE_MEMBER(liberate_state, colorram)
263   AM_RANGE(0x4400, 0x47ff) AM_WRITE(liberate_videoram_w) AM_BASE_MEMBER(liberate_state, videoram)
264   AM_RANGE(0x4800, 0x4fff) AM_WRITEONLY AM_BASE_MEMBER(liberate_state, spriteram)
265   AM_RANGE(0x6200, 0x67ff) AM_RAM AM_BASE_MEMBER(liberate_state, scratchram)
248266   AM_RANGE(0x8000, 0x800f) AM_WRITE(deco16_io_w)
249267   AM_RANGE(0x8000, 0x800f) AM_ROMBANK("bank1")
250268   AM_RANGE(0x8000, 0xffff) AM_ROM
r7500r7501
254272   AM_RANGE(0x0000, 0x0fff) AM_RAM
255273   AM_RANGE(0x1000, 0x3fff) AM_ROM /* Mirror of main rom */
256274   AM_RANGE(0x4000, 0x7fff) AM_READ(prosoccr_bank_r)
257   AM_RANGE(0x4000, 0x43ff) AM_MIRROR(0x800) AM_WRITE(liberate_colorram_w) AM_BASE_MEMBER(liberate_state,colorram)
258   AM_RANGE(0x4400, 0x47ff) AM_WRITE(liberate_videoram_w) AM_BASE_MEMBER(liberate_state,videoram)
259   AM_RANGE(0x4c00, 0x4fff) AM_WRITEONLY AM_BASE_GENERIC(spriteram)
260   AM_RANGE(0x6200, 0x67ff) AM_RAM AM_BASE_MEMBER(liberate_state,scratchram)
261   AM_RANGE(0x8000, 0x97ff) AM_READWRITE(prosoccr_charram_r,prosoccr_charram_w)
275   AM_RANGE(0x4000, 0x43ff) AM_MIRROR(0x800) AM_WRITE(liberate_colorram_w) AM_BASE_MEMBER(liberate_state, colorram)
276   AM_RANGE(0x4400, 0x47ff) AM_WRITE(liberate_videoram_w) AM_BASE_MEMBER(liberate_state, videoram)
277   AM_RANGE(0x4c00, 0x4fff) AM_WRITEONLY AM_BASE_MEMBER(liberate_state, spriteram)
278   AM_RANGE(0x6200, 0x67ff) AM_RAM AM_BASE_MEMBER(liberate_state, scratchram)
279   AM_RANGE(0x8000, 0x97ff) AM_READWRITE(prosoccr_charram_r, prosoccr_charram_w)
262280   AM_RANGE(0x9800, 0x9800) AM_WRITE(prosoccr_char_bank_w)
263281   AM_RANGE(0xa000, 0xffff) AM_ROM
264282ADDRESS_MAP_END
r7500r7501
278296   AM_RANGE(0x0000, 0x0fff) AM_RAM
279297   AM_RANGE(0x1000, 0x3fff) AM_ROM /* Mirror of main rom */
280298   AM_RANGE(0x4000, 0x7fff) AM_READ(deco16_bank_r)
281   AM_RANGE(0x4000, 0x43ff) AM_WRITE(liberate_colorram_w) AM_BASE_MEMBER(liberate_state,colorram)
282   AM_RANGE(0x4400, 0x47ff) AM_WRITE(liberate_videoram_w) AM_BASE_MEMBER(liberate_state,videoram)
283   AM_RANGE(0x4800, 0x4fff) AM_WRITEONLY AM_BASE_GENERIC(spriteram)
284   AM_RANGE(0x6200, 0x67ff) AM_WRITEONLY AM_BASE_MEMBER(liberate_state,scratchram)
299   AM_RANGE(0x4000, 0x43ff) AM_WRITE(liberate_colorram_w) AM_BASE_MEMBER(liberate_state, colorram)
300   AM_RANGE(0x4400, 0x47ff) AM_WRITE(liberate_videoram_w) AM_BASE_MEMBER(liberate_state, videoram)
301   AM_RANGE(0x4800, 0x4fff) AM_WRITEONLY AM_BASE_MEMBER(liberate_state, spriteram)
302   AM_RANGE(0x6200, 0x67ff) AM_WRITEONLY AM_BASE_MEMBER(liberate_state, scratchram)
285303   AM_RANGE(0xf000, 0xf00f) AM_WRITE(deco16_io_w)
286304   AM_RANGE(0xf000, 0xf000) AM_READ_PORT("IN1")
287305   AM_RANGE(0xf001, 0xf001) AM_READ_PORT("IN2")
r7500r7501
761779   else
762780   {
763781      if (!(p & 0x43))
764         state->latch=0;
782         state->latch = 0;
765783   }
766784}
767785
r7500r7501
779797 *
780798 *************************************/
781799
800static MACHINE_START( liberate )
801{
802   liberate_state *state = (liberate_state *)machine->driver_data;
803
804   state->maincpu = devtag_get_device(machine, "maincpu");
805   state->audiocpu = devtag_get_device(machine, "audiocpu");
806
807   state_save_register_global(machine, state->background_disable);
808   state_save_register_global(machine, state->background_color);
809   state_save_register_global(machine, state->gfx_rom_readback);
810   state_save_register_global(machine, state->latch);
811   state_save_register_global(machine, state->bank);
812
813   state_save_register_global_array(machine, state->io_ram);
814}
815
816static MACHINE_RESET( liberate )
817{
818   liberate_state *state = (liberate_state *)machine->driver_data;
819
820   memset(state->io_ram, 0, ARRAY_LENGTH(state->io_ram));
821
822   state->background_disable = 0;
823   state->background_color = 0;
824   state->gfx_rom_readback = 0;
825   state->latch = 0;
826   state->bank = 0;
827}
828
782829static MACHINE_DRIVER_START( liberate )
783830
784831   MDRV_DRIVER_DATA(liberate_state)
r7500r7501
795842
796843   MDRV_QUANTUM_TIME(HZ(12000))
797844
845   MDRV_MACHINE_START(liberate)
846   MDRV_MACHINE_RESET(liberate)
847
798848   /* video hardware */
799849   MDRV_SCREEN_ADD("screen", RASTER)
800850   MDRV_SCREEN_REFRESH_RATE(60)
r7500r7501
879929
880930//  MDRV_QUANTUM_TIME(HZ(12000))
881931
932   MDRV_MACHINE_START(liberate)
933   MDRV_MACHINE_RESET(liberate)
934
882935   /* video hardware */
883936   MDRV_SCREEN_ADD("screen", RASTER)
884937   MDRV_SCREEN_REFRESH_RATE(60)
r7500r7501
13191372   int i;
13201373
13211374   /* Bit swapping on sound cpu - Opcodes only */
1322   for (i=0xc000; i<0x10000; i++)
1323      decrypted[i-0xc000]=((rom[i] & 0x20) << 1) | ((rom[i] & 0x40) >> 1) | (rom[i] & 0x9f);
1375   for (i = 0xc000; i < 0x10000; i++)
1376      decrypted[i - 0xc000] = ((rom[i] & 0x20) << 1) | ((rom[i] & 0x40) >> 1) | (rom[i] & 0x9f);
13241377
13251378   memory_set_decrypted_region(space, 0xc000, 0xffff, decrypted);
13261379}
r7500r7501
13311384   int i;
13321385
13331386   /* Main cpu has the nibbles swapped */
1334   for (i=0; i<0x10000; i++)
1335      RAM[i]=((RAM[i] & 0x0f) << 4) | ((RAM[i] & 0xf0) >> 4);
1387   for (i = 0; i < 0x10000; i++)
1388      RAM[i] = ((RAM[i] & 0x0f) << 4) | ((RAM[i] & 0xf0) >> 4);
13361389
13371390   sound_cpu_decrypt(machine);
13381391}
r7500r7501
13541407   memory_set_decrypted_region(space, 0x0000, 0xffff, decrypted);
13551408
13561409   /* Swap bits for opcodes only, not data */
1357   for (A = 0;A < 0x10000;A++) {
1410   for (A = 0; A < 0x10000; A++) {
13581411      decrypted[A] = (ROM[A] & 0xd7) | ((ROM[A] & 0x08) << 2) | ((ROM[A] & 0x20) >> 2);
13591412      decrypted[A] = (decrypted[A] & 0xbb) | ((decrypted[A] & 0x04) << 4) | ((decrypted[A] & 0x40) >> 4);
13601413      decrypted[A] = (decrypted[A] & 0x7d) | ((decrypted[A] & 0x02) << 6) | ((decrypted[A] & 0x80) >> 6);
r7500r7501
13711424 *
13721425 *************************************/
13731426
1374GAME( 1983, prosoccr,  0,        prosoccr,  prosoccr, prosport, ROT270, "Data East Corporation", "Pro Soccer", 0 )
1375GAME( 1983, prosport,  0,        prosport,  prosport, prosport, ROT270, "Data East Corporation", "Pro. Sports", GAME_NO_COCKTAIL | GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
1376GAME( 1983, prosporta, prosport, prosport,  prosport, prosport, ROT270, "Data East Corporation", "Pro. Sports (alternate)", GAME_NO_COCKTAIL | GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND )
1377GAME( 1983, boomrang,  0,        boomrang,  boomrang, prosport, ROT270, "Data East Corporation", "Boomer Rang'r / Genesis (set 1)", 0 )
1378GAME( 1983, boomranga, boomrang, boomrang,  boomrang, prosport, ROT270, "Data East Corporation", "Boomer Rang'r / Genesis (set 2)", 0 )
1379GAME( 1984, kamikcab,  0,        boomrang,  kamikcab, prosport, ROT270, "Data East Corporation", "Kamikaze Cabbie", 0 )
1380GAME( 1984, yellowcbj, kamikcab, boomrang,  yellowcb, yellowcb, ROT270, "Data East Corporation", "Yellow Cab (Japan)", 0 )
1381GAME( 1984, yellowcbb, kamikcab, boomrang,  yellowcb, yellowcb, ROT270, "bootleg",               "Yellow Cab (bootleg)", 0 )
1382GAME( 1984, liberate,  0,        liberate,  liberate, liberate, ROT270, "Data East Corporation", "Liberation", 0 )
1383GAME( 1984, dualaslt,  liberate, liberate,  dualaslt, liberate, ROT270, "Data East USA",         "Dual Assault", 0 )
1384GAME( 1984, liberateb, liberate, liberatb,  liberatb, prosport, ROT270, "bootleg",               "Liberation (bootleg)", 0 )
1427GAME( 1983, prosoccr,  0,        prosoccr,  prosoccr, prosport, ROT270, "Data East Corporation", "Pro Soccer", GAME_SUPPORTS_SAVE )
1428GAME( 1983, prosport,  0,        prosport,  prosport, prosport, ROT270, "Data East Corporation", "Pro. Sports", GAME_NO_COCKTAIL | GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND | GAME_SUPPORTS_SAVE )
1429GAME( 1983, prosporta, prosport, prosport,  prosport, prosport, ROT270, "Data East Corporation", "Pro. Sports (alternate)", GAME_NO_COCKTAIL | GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND | GAME_SUPPORTS_SAVE )
1430GAME( 1983, boomrang,  0,        boomrang,  boomrang, prosport, ROT270, "Data East Corporation", "Boomer Rang'r / Genesis (set 1)", GAME_SUPPORTS_SAVE )
1431GAME( 1983, boomranga, boomrang, boomrang,  boomrang, prosport, ROT270, "Data East Corporation", "Boomer Rang'r / Genesis (set 2)", GAME_SUPPORTS_SAVE )
1432GAME( 1984, kamikcab,  0,        boomrang,  kamikcab, prosport, ROT270, "Data East Corporation", "Kamikaze Cabbie", GAME_SUPPORTS_SAVE )
1433GAME( 1984, yellowcbj, kamikcab, boomrang,  yellowcb, yellowcb, ROT270, "Data East Corporation", "Yellow Cab (Japan)", GAME_SUPPORTS_SAVE )
1434GAME( 1984, yellowcbb, kamikcab, boomrang,  yellowcb, yellowcb, ROT270, "bootleg",               "Yellow Cab (bootleg)", GAME_SUPPORTS_SAVE )
1435GAME( 1984, liberate,  0,        liberate,  liberate, liberate, ROT270, "Data East Corporation", "Liberation", GAME_SUPPORTS_SAVE )
1436GAME( 1984, dualaslt,  liberate, liberate,  dualaslt, liberate, ROT270, "Data East USA",         "Dual Assault", GAME_SUPPORTS_SAVE )
1437GAME( 1984, liberateb, liberate, liberatb,  liberatb, prosport, ROT270, "bootleg",               "Liberation (bootleg)", GAME_SUPPORTS_SAVE )
src/mame/drivers/naomi.c
r7500r7501
22272227        ROM_LOAD( "mpr-23508.ic5", 0x4800000, 0x1000000, CRC(0a3590aa) SHA1(84c0e1853f069b003d09b268caee97e58c4dacb6) )
22282228        ROM_LOAD( "mpr-23509.ic6", 0x5800000, 0x1000000, CRC(281d633d) SHA1(d773be8e95f7bf9212ee1061f3076220d4fce9e0) )
22292229        ROM_LOAD( "mpr-23510.ic7", 0x6800000, 0x1000000, CRC(b856fef5) SHA1(0634f86740c438b40286256a0269570d24cb845a) )
2230
2231   // trojaned protection data (filename is address read from)
2232   ROM_REGION( 0x200000, "naomibd_prot", ROMREGION_ERASE00 )
2233        ROM_LOAD( "a63a9260.bin", 0x000000, 0x008760, CRC(54efa963) SHA1(41874253567da56441d83de041f6e82111977fa4) )
2234        ROM_LOAD( "a63b19c0.bin", 0x010000, 0x008260, CRC(f0ca72ef) SHA1(87fc4654afaf763cdb3ea5b4501948bfe7b9e9dc) )
2235        ROM_LOAD( "a63b9c20.bin", 0x020000, 0x00a0c0, CRC(92eec22c) SHA1(c7267503a828e852edeb26f68f3f4b685b9b163e) )
2236        ROM_LOAD( "a63c3ce0.bin", 0x030000, 0x00d7e0, CRC(93201f32) SHA1(5aca43776306a5a5ecd68a7e8699a724703f329a) )
2237        ROM_LOAD( "a63d14c0.bin", 0x040000, 0x00a8e0, CRC(fb2e9f7b) SHA1(ae4fc9a82eafb5b511485eef1d65ee9d3adc27b6) )
2238        ROM_LOAD( "a63dbda0.bin", 0x050000, 0x008460, CRC(b4b74624) SHA1(6ae2f5d69e45d295a3d0dcf295b1fb76be201e8e) )
2239        ROM_LOAD( "a63e4200.bin", 0x060000, 0x00b500, CRC(69ee516d) SHA1(f358aff12b826d1685199a9d5950abd121b54192) )
2240        ROM_LOAD( "a63ef700.bin", 0x070000, 0x00cec0, CRC(b2f4df7e) SHA1(4aafcf65e3fc193ee191f06ffcce37e52fc12364) )
2241        ROM_LOAD( "a63fc5c0.bin", 0x080000, 0x004cfc, CRC(1d534f98) SHA1(32afbb1d1fd1abba9e49b7b4bcf310860e4e47dc) )
2242        ROM_LOAD( "a643a120.bin", 0x090000, 0x00d6e0, CRC(27a0deb7) SHA1(c8da2e212ca8f5985d9336e8200c3382d6d373a5) )
2243        ROM_LOAD( "a6447800.bin", 0x0a0000, 0x00c920, CRC(42c9e4b1) SHA1(d7ef0d23956b795fad888f49a4dc42d74899de71) )
2244        ROM_LOAD( "a6454120.bin", 0x0b0000, 0x00a540, CRC(69321860) SHA1(675767e9fd18a0d72de2decb68acd7d500b11de2) )
2245        ROM_LOAD( "a645e660.bin", 0x0c0000, 0x00ccc0, CRC(4919083d) SHA1(89dfc2837e5298dc691350ac470bc76557657736) )
2246        ROM_LOAD( "a646b320.bin", 0x0d0000, 0x00c120, CRC(a66da245) SHA1(48d543244cdc52887131e734e0643c69f9368681) )
2247        ROM_LOAD( "a6477440.bin", 0x0e0000, 0x0097a8, CRC(6289f812) SHA1(574459f7c79dd757ae94f8e06dbcefa5b203e510) )
2248        ROM_LOAD( "a6480c00.bin", 0x0f0000, 0x00eca0, CRC(a4128a65) SHA1(35625df0109a72cb508bb4a89641bcb86aa697fb) )
2249        ROM_LOAD( "a648f8a0.bin", 0x100000, 0x009520, CRC(45a06ed6) SHA1(e9ee99e329cf35a95440312b9d0bed40254481c2) )
2250        ROM_LOAD( "a6498dc0.bin", 0x110000, 0x009f40, CRC(2cea7b46) SHA1(5398b8f1ba01e21d5fee0b1c6a796ce396c9697f) )
2251        ROM_LOAD( "a64a2d00.bin", 0x120000, 0x00dbe0, CRC(9c75fc98) SHA1(aa1a630c77b29202a4045b1eade455f02f29b81a) )
2252        ROM_LOAD( "a64b08e0.bin", 0x130000, 0x00cb40, CRC(72ae0dd2) SHA1(f4e8face14dac9a5cc75c6ccdfb9911929e2d76e) )
2253        ROM_LOAD( "a64bd420.bin", 0x140000, 0x00e920, CRC(198e4aa9) SHA1(294b9c3f89b138898c3ef6db60ac5473516d74dc) )
2254        ROM_LOAD( "a64cbd40.bin", 0x150000, 0x005e94, CRC(cc4a4e58) SHA1(dce67374a8dc6d2c9b66c0cd7e68b4f9fdab3e27) )
2255        ROM_LOAD( "a6617be0.bin", 0x160000, 0x00e480, CRC(b7d6ce86) SHA1(c3d9a8cf6125c50a0129591d807bbb13a836a651) )
2256        ROM_LOAD( "a6626060.bin", 0x170000, 0x0078a8, CRC(8c258ad2) SHA1(51d4d227e037992905a7a7f2b5bb13646920670d) )
22572230ROM_END
22582231
22592232// ver 000804
r7500r7501
22712244        ROM_LOAD( "mpr-23508.ic5", 0x4800000, 0x1000000, CRC(0a3590aa) SHA1(84c0e1853f069b003d09b268caee97e58c4dacb6) )
22722245        ROM_LOAD( "mpr-23509.ic6", 0x5800000, 0x1000000, CRC(281d633d) SHA1(d773be8e95f7bf9212ee1061f3076220d4fce9e0) )
22732246        ROM_LOAD( "mpr-23510.ic7", 0x6800000, 0x1000000, CRC(b856fef5) SHA1(0634f86740c438b40286256a0269570d24cb845a) )
2274
2275   // trojaned protection data (filename is address read from)
2276   ROM_REGION( 0x200000, "naomibd_prot", ROMREGION_ERASE00 )
2277        ROM_LOAD( "a63a9260.bin", 0x000000, 0x008760, CRC(54efa963) SHA1(41874253567da56441d83de041f6e82111977fa4) )
2278        ROM_LOAD( "a63b19c0.bin", 0x010000, 0x008260, CRC(f0ca72ef) SHA1(87fc4654afaf763cdb3ea5b4501948bfe7b9e9dc) )
2279        ROM_LOAD( "a63b9c20.bin", 0x020000, 0x00a0c0, CRC(92eec22c) SHA1(c7267503a828e852edeb26f68f3f4b685b9b163e) )
2280        ROM_LOAD( "a63c3ce0.bin", 0x030000, 0x00d7e0, CRC(93201f32) SHA1(5aca43776306a5a5ecd68a7e8699a724703f329a) )
2281        ROM_LOAD( "a63d14c0.bin", 0x040000, 0x00a8e0, CRC(fb2e9f7b) SHA1(ae4fc9a82eafb5b511485eef1d65ee9d3adc27b6) )
2282        ROM_LOAD( "a63dbda0.bin", 0x050000, 0x008460, CRC(b4b74624) SHA1(6ae2f5d69e45d295a3d0dcf295b1fb76be201e8e) )
2283        ROM_LOAD( "a63e4200.bin", 0x060000, 0x00b500, CRC(69ee516d) SHA1(f358aff12b826d1685199a9d5950abd121b54192) )
2284        ROM_LOAD( "a63ef700.bin", 0x070000, 0x00cec0, CRC(b2f4df7e) SHA1(4aafcf65e3fc193ee191f06ffcce37e52fc12364) )
2285        ROM_LOAD( "a63fc5c0.bin", 0x080000, 0x004cfc, CRC(1d534f98) SHA1(32afbb1d1fd1abba9e49b7b4bcf310860e4e47dc) )
2286        ROM_LOAD( "a643a120.bin", 0x090000, 0x00d6e0, CRC(27a0deb7) SHA1(c8da2e212ca8f5985d9336e8200c3382d6d373a5) )
2287        ROM_LOAD( "a6447800.bin", 0x0a0000, 0x00c920, CRC(42c9e4b1) SHA1(d7ef0d23956b795fad888f49a4dc42d74899de71) )
2288        ROM_LOAD( "a6454120.bin", 0x0b0000, 0x00a540, CRC(69321860) SHA1(675767e9fd18a0d72de2decb68acd7d500b11de2) )
2289        ROM_LOAD( "a645e660.bin", 0x0c0000, 0x00ccc0, CRC(4919083d) SHA1(89dfc2837e5298dc691350ac470bc76557657736) )
2290        ROM_LOAD( "a646b320.bin", 0x0d0000, 0x00c120, CRC(a66da245) SHA1(48d543244cdc52887131e734e0643c69f9368681) )
2291        ROM_LOAD( "a6477440.bin", 0x0e0000, 0x0097a8, CRC(6289f812) SHA1(574459f7c79dd757ae94f8e06dbcefa5b203e510) )
2292        ROM_LOAD( "a6480c00.bin", 0x0f0000, 0x00eca0, CRC(a4128a65) SHA1(35625df0109a72cb508bb4a89641bcb86aa697fb) )
2293        ROM_LOAD( "a648f8a0.bin", 0x100000, 0x009520, CRC(45a06ed6) SHA1(e9ee99e329cf35a95440312b9d0bed40254481c2) )
2294        ROM_LOAD( "a6498dc0.bin", 0x110000, 0x009f40, CRC(2cea7b46) SHA1(5398b8f1ba01e21d5fee0b1c6a796ce396c9697f) )
2295        ROM_LOAD( "a64a2d00.bin", 0x120000, 0x00dbe0, CRC(9c75fc98) SHA1(aa1a630c77b29202a4045b1eade455f02f29b81a) )
2296        ROM_LOAD( "a64b08e0.bin", 0x130000, 0x00cb40, CRC(72ae0dd2) SHA1(f4e8face14dac9a5cc75c6ccdfb9911929e2d76e) )
2297        ROM_LOAD( "a64bd420.bin", 0x140000, 0x00e920, CRC(198e4aa9) SHA1(294b9c3f89b138898c3ef6db60ac5473516d74dc) )
2298        ROM_LOAD( "a64cbd40.bin", 0x150000, 0x005e94, CRC(cc4a4e58) SHA1(dce67374a8dc6d2c9b66c0cd7e68b4f9fdab3e27) )
2299        ROM_LOAD( "a6617be0.bin", 0x160000, 0x00e480, CRC(b7d6ce86) SHA1(c3d9a8cf6125c50a0129591d807bbb13a836a651) )
2300        ROM_LOAD( "a6626060.bin", 0x170000, 0x0078a8, CRC(8c258ad2) SHA1(51d4d227e037992905a7a7f2b5bb13646920670d) )
23012247ROM_END
23022248
23032249/*
r7500r7501
23382284   ROM_LOAD("mpr-23425.ic6",   0x3000000, 0x0800000, CRC(47f51da2) SHA1(af5ecd460114caed3a00157ffd3a2df0fbf348c0) )
23392285   ROM_LOAD("mpr-23426.ic7",   0x3800000, 0x0800000, CRC(7f91b13f) SHA1(2d534f77291ebfedc011bf0e803a1b9243fb477f) )
23402286   ROM_LOAD("mpr-23427.ic8",   0x4000000, 0x0800000, CRC(5851d525) SHA1(1cb1073542d75a3bcc0d363ed31d49bcaf1fd494) )
2341
2342   ROM_REGION( 0x200000, "naomibd_prot", ROMREGION_ERASE00 )
2343   ROM_COPY("user1", 0, 0, 0x200000)
23442287ROM_END
23452288
23462289ROM_START( csmasho )
r7500r7501
23592302   ROM_LOAD("mpr-23425.ic6", 0x3000000, 0x0800000, CRC(47f51da2) SHA1(af5ecd460114caed3a00157ffd3a2df0fbf348c0) )
23602303   ROM_LOAD("mpr-23426.ic7", 0x3800000, 0x0800000, CRC(7f91b13f) SHA1(2d534f77291ebfedc011bf0e803a1b9243fb477f) )
23612304   ROM_LOAD("mpr-23427.ic8", 0x4000000, 0x0800000, CRC(5851d525) SHA1(1cb1073542d75a3bcc0d363ed31d49bcaf1fd494) )
2362
2363   ROM_REGION( 0x200000, "naomibd_prot", ROMREGION_ERASE00 )
2364   ROM_COPY("user1", 0, 0, 0x200000)
23652305ROM_END
23662306
23672307/*
r7500r7501
28612801   NAOMI_DEFAULT_EEPROM
28622802
28632803   ROM_REGION( 0xb000000, "user1", ROMREGION_ERASEFF)
2864        ROM_LOAD( "epr22848.ic22", 0x0000000, 0x800000, CRC(54de0bd5) SHA1(5f6be36d2d39eea681ecac14358b92eaf4bf6c1e) )
2865        ROM_LOAD( "mpr22827.ic1",  0x0800000, 0x800000, CRC(eeb1b975) SHA1(929f453eaf5565ae3e660dbbb8f406ff8aa7897d) )
2866        ROM_LOAD( "mpr22828.ic2",  0x1000000, 0x800000, CRC(691d246a) SHA1(a2d538bc2e0d592a4f18d65f52fea035e1d4c625) )
2867        ROM_LOAD( "mpr22829.ic3",  0x1800000, 0x800000, CRC(00719c9c) SHA1(f0f19af4ebe2720bd822a9ea7e0004db163c706a) )
2868        ROM_LOAD( "mpr22830.ic4",  0x2000000, 0x800000, CRC(bfeb0e95) SHA1(a2dac7887dec722bd4b90a526bbcb9910b636618) )
2869        ROM_LOAD( "mpr22831.ic5",  0x2800000, 0x800000, CRC(697e60a8) SHA1(805dd3fb7b86d1ad8afadba58c7c026444e62e32) )
2870        ROM_LOAD( "mpr22832.ic6",  0x3000000, 0x800000, CRC(78e146a0) SHA1(cb6f1313ae51addbc84f78b3fb1e5d3adbe9af7c) )
2871        ROM_LOAD( "mpr22834.ic7",  0x3800000, 0x800000, CRC(cbd847ea) SHA1(7c54f909d9bc10fda12bf28d5d4b83052a0583d4) )
2872        ROM_LOAD( "mpr22834.ic8",  0x4000000, 0x800000, CRC(3bfc6571) SHA1(c3d7e1a75a8a2490c3b9b6f475ec948c40c84085) )
2873        ROM_LOAD( "mpr22835.ic9",  0x4800000, 0x800000, CRC(c0a14f8e) SHA1(811d95d3741a14a215f34b3dc465e4944d746568) )
2874        ROM_LOAD( "mpr22836.ic10", 0x5000000, 0x800000, CRC(ee68d756) SHA1(319f5633c3a377461fcedcf4b01edac41a26ad4b) )
2875        ROM_LOAD( "mpr22837.ic11", 0x5800000, 0x800000, CRC(3b53f0c9) SHA1(b9be9c3de9af3eefb16b77eb0ee8d2f144d66919) )
2876   ROM_LOAD( "mpr22838.ic12", 0x6000000, 0x800000, CRC(c17a2228) SHA1(0fcea748f5bacfdc784275e6f810001897f07bf5) )
2877        ROM_LOAD( "mpr22839.ic13", 0x6800000, 0x800000, CRC(31ab7352) SHA1(3a5b5a04172d4d32c2fcff540dd71ddb99bf662c) )
2878        ROM_LOAD( "mpr22840.ic14", 0x7000000, 0x800000, CRC(af4c757b) SHA1(b17722fa1f762c38e777ba36ffaf967062f86eb9) )
2879        ROM_LOAD( "mpr22841.ic15", 0x7800000, 0x800000, CRC(7adceb6b) SHA1(17e1833d3d22a244cd16ba93c74bd25bbaa1018d) )
2880        ROM_LOAD( "mpr22842.ic16", 0x8000000, 0x800000, CRC(1ce2ec11) SHA1(279464955f3b10c71aef1e41c68337f85d871739) )
2881        ROM_LOAD( "mpr22843.ic17", 0x8800000, 0x800000, CRC(1c659384) SHA1(4c5ca20c9924c56e5f7a51ecaaafac3c5c6f91c8) )
2882        ROM_LOAD( "mpr22844.ic18", 0x9000000, 0x800000, CRC(361ea725) SHA1(b2d17b2f09b9ae1e19bdc395189fa966ba462c06) )
2883        ROM_LOAD( "mpr22845.ic19", 0x9800000, 0x800000, CRC(3327aed1) SHA1(8bd81aa79ffe764da5810fe79a317530a4f3c191) )
2884        ROM_LOAD( "mpr22846.ic20", 0xa000000, 0x800000, CRC(d4148f39) SHA1(b6598ce52bcaa42805c581de326c953d27c1b2b4) )
2885        ROM_LOAD( "mpr22847.ic21", 0xa800000, 0x800000, CRC(955ad42e) SHA1(e396ca02b5786557434632c4fac56af3a4a9f8ce) )
2804        ROM_LOAD( "epr-22848.ic22", 0x0000000, 0x800000, CRC(54de0bd5) SHA1(5f6be36d2d39eea681ecac14358b92eaf4bf6c1e) )
2805        ROM_LOAD( "mpr-22827.ic1",  0x0800000, 0x800000, CRC(eeb1b975) SHA1(929f453eaf5565ae3e660dbbb8f406ff8aa7897d) )
2806        ROM_LOAD( "mpr-22828.ic2",  0x1000000, 0x800000, CRC(691d246a) SHA1(a2d538bc2e0d592a4f18d65f52fea035e1d4c625) )
2807        ROM_LOAD( "mpr-22829.ic3",  0x1800000, 0x800000, CRC(00719c9c) SHA1(f0f19af4ebe2720bd822a9ea7e0004db163c706a) )
2808        ROM_LOAD( "mpr-22830.ic4",  0x2000000, 0x800000, CRC(bfeb0e95) SHA1(a2dac7887dec722bd4b90a526bbcb9910b636618) )
2809        ROM_LOAD( "mpr-22831.ic5",  0x2800000, 0x800000, CRC(697e60a8) SHA1(805dd3fb7b86d1ad8afadba58c7c026444e62e32) )
2810        ROM_LOAD( "mpr-22832.ic6",  0x3000000, 0x800000, CRC(78e146a0) SHA1(cb6f1313ae51addbc84f78b3fb1e5d3adbe9af7c) )
2811        ROM_LOAD( "mpr-22834.ic7",  0x3800000, 0x800000, CRC(cbd847ea) SHA1(7c54f909d9bc10fda12bf28d5d4b83052a0583d4) )
2812        ROM_LOAD( "mpr-22834.ic8",  0x4000000, 0x800000, CRC(3bfc6571) SHA1(c3d7e1a75a8a2490c3b9b6f475ec948c40c84085) )
2813        ROM_LOAD( "mpr-22835.ic9",  0x4800000, 0x800000, CRC(c0a14f8e) SHA1(811d95d3741a14a215f34b3dc465e4944d746568) )
2814        ROM_LOAD( "mpr-22836.ic10", 0x5000000, 0x800000, CRC(ee68d756) SHA1(319f5633c3a377461fcedcf4b01edac41a26ad4b) )
2815        ROM_LOAD( "mpr-22837.ic11", 0x5800000, 0x800000, CRC(3b53f0c9) SHA1(b9be9c3de9af3eefb16b77eb0ee8d2f144d66919) )
2816   ROM_LOAD( "mpr-22838.ic12", 0x6000000, 0x800000, CRC(c17a2228) SHA1(0fcea748f5bacfdc784275e6f810001897f07bf5) )
2817        ROM_LOAD( "mpr-22839.ic13", 0x6800000, 0x800000, CRC(31ab7352) SHA1(3a5b5a04172d4d32c2fcff540dd71ddb99bf662c) )
2818        ROM_LOAD( "mpr-22840.ic14", 0x7000000, 0x800000, CRC(af4c757b) SHA1(b17722fa1f762c38e777ba36ffaf967062f86eb9) )
2819        ROM_LOAD( "mpr-22841.ic15", 0x7800000, 0x800000, CRC(7adceb6b) SHA1(17e1833d3d22a244cd16ba93c74bd25bbaa1018d) )
2820        ROM_LOAD( "mpr-22842.ic16", 0x8000000, 0x800000, CRC(1ce2ec11) SHA1(279464955f3b10c71aef1e41c68337f85d871739) )
2821        ROM_LOAD( "mpr-22843.ic17", 0x8800000, 0x800000, CRC(1c659384) SHA1(4c5ca20c9924c56e5f7a51ecaaafac3c5c6f91c8) )
2822        ROM_LOAD( "mpr-22844.ic18", 0x9000000, 0x800000, CRC(361ea725) SHA1(b2d17b2f09b9ae1e19bdc395189fa966ba462c06) )
2823        ROM_LOAD( "mpr-22845.ic19", 0x9800000, 0x800000, CRC(3327aed1) SHA1(8bd81aa79ffe764da5810fe79a317530a4f3c191) )
2824        ROM_LOAD( "mpr-22846.ic20", 0xa000000, 0x800000, CRC(d4148f39) SHA1(b6598ce52bcaa42805c581de326c953d27c1b2b4) )
2825        ROM_LOAD( "mpr-22847.ic21", 0xa800000, 0x800000, CRC(955ad42e) SHA1(e396ca02b5786557434632c4fac56af3a4a9f8ce) )
28862826ROM_END
28872827
28882828ROM_START( f355twn2 )
r7500r7501
28912831   NAOMI_DEFAULT_EEPROM
28922832
28932833   ROM_REGION( 0xb000000, "user1", ROMREGION_ERASEFF)
2894        ROM_LOAD( "epr23399.ic22", 0x0000000, 0x400000, CRC(36de514c) SHA1(1c32064169c233156921fdf170c1958dc0f8a750) )
2895        ROM_LOAD( "mpr23378.ic1",  0x0800000, 0x800000, CRC(1ad80f12) SHA1(415a021987e07bb298e43eacb54ff898619837b1) )
2896        ROM_LOAD( "mpr23379.ic2",  0x1000000, 0x800000, CRC(a198f0a8) SHA1(7025adfd26f80087fa405acb49797d5c77a55e98) )
2897        ROM_LOAD( "mpr23380.ic3",  0x1800000, 0x800000, CRC(b1993286) SHA1(01ddc81ba3542f37dd2dadac972114ec254059a1) )
2898        ROM_LOAD( "mpr23381.ic4",  0x2000000, 0x800000, CRC(1204d518) SHA1(5b272be2ff7d48ee8005194d03ae79a01cea1b92) )
2899        ROM_LOAD( "mpr23382.ic5",  0x2800000, 0x800000, CRC(f2f3f7ab) SHA1(3e662197d7cc0b606706a2edb9433093d2bcd2d9) )
2900        ROM_LOAD( "mpr23383.ic6",  0x3000000, 0x800000, CRC(f19069c1) SHA1(ccec4008d95f8305e9d77a5b34a3de8aec3606dc) )
2901        ROM_LOAD( "mpr23384.ic7",  0x3800000, 0x800000, CRC(5150bb17) SHA1(9fab19f02e6f79e68e8e10aad78e47135081957d) )
2902        ROM_LOAD( "mpr23385.ic8",  0x4000000, 0x800000, CRC(747e4025) SHA1(ad3ee65ac473fda8c82c5e3dd349abaa9312bd35) )
2903        ROM_LOAD( "mpr23386.ic9",  0x4800000, 0x800000, CRC(28e22914) SHA1(e57d627de314dd13c229de91d061588df53b2164) )
2904        ROM_LOAD( "mpr23387.ic10", 0x5000000, 0x800000, CRC(3b5c0fe4) SHA1(cbe93bf95d6386e5a0d44e27e6953e259f8667bd) )
2905        ROM_LOAD( "mpr23388.ic11", 0x5800000, 0x800000, CRC(35d55060) SHA1(7c566f2ee82478aa63689f96088138902d9ee710) )
2906        ROM_LOAD( "mpr23389.ic12", 0x6000000, 0x800000, CRC(360b9078) SHA1(26160273848d4f9c3992ea125b0d36bed58add49) )
2907        ROM_LOAD( "mpr23390.ic13", 0x6800000, 0x800000, CRC(d5878f2d) SHA1(d918a37198033c74dadc1c531889f61c88ef94a8) )
2908        ROM_LOAD( "mpr23391.ic14", 0x7000000, 0x800000, CRC(eef8b0c6) SHA1(0339a094cbecf97c785bb1071b2b598c1ab60e40) )
2909        ROM_LOAD( "mpr23392.ic15", 0x7800000, 0x800000, CRC(df16126b) SHA1(b932afe38dd8e5f96412807743f44043fe450f14) )
2910        ROM_LOAD( "mpr23393.ic16", 0x8000000, 0x800000, CRC(e6d383a3) SHA1(6a77318f718171fe998a8e18d542dd43b8a9b87d) )
2911        ROM_LOAD( "mpr23394.ic17", 0x8800000, 0x800000, CRC(045235c4) SHA1(f1c4e09847840769d26719a26bdcf3c9241280a5) )
2912        ROM_LOAD( "mpr23395.ic18", 0x9000000, 0x800000, CRC(ed645203) SHA1(b621c96c9ca49a7582a50bf5c513b910dead4e13) )
2913        ROM_LOAD( "mpr23396.ic19", 0x9800000, 0x800000, CRC(42826956) SHA1(386eca3cda2bddb1825dbae850f0c17d1374eb41) )
2914        ROM_LOAD( "mpr23397.ic20", 0xa000000, 0x800000, CRC(28d2caf6) SHA1(67a3bc19abccf7f211c3aae67e751815857bd564) )
2915        ROM_LOAD( "mpr23398.ic21", 0xa800000, 0x800000, CRC(ea4d4d2a) SHA1(3dc9c7164516ae7f3b988c088ab819d8fd40d75e) )
2834        ROM_LOAD( "epr-23399.ic22", 0x0000000, 0x400000, CRC(36de514c) SHA1(1c32064169c233156921fdf170c1958dc0f8a750) )
2835        ROM_LOAD( "mpr-23378.ic1",  0x0800000, 0x800000, CRC(1ad80f12) SHA1(415a021987e07bb298e43eacb54ff898619837b1) )
2836        ROM_LOAD( "mpr-23379.ic2",  0x1000000, 0x800000, CRC(a198f0a8) SHA1(7025adfd26f80087fa405acb49797d5c77a55e98) )
2837        ROM_LOAD( "mpr-23380.ic3",  0x1800000, 0x800000, CRC(b1993286) SHA1(01ddc81ba3542f37dd2dadac972114ec254059a1) )
2838        ROM_LOAD( "mpr-23381.ic4",  0x2000000, 0x800000, CRC(1204d518) SHA1(5b272be2ff7d48ee8005194d03ae79a01cea1b92) )
2839        ROM_LOAD( "mpr-23382.ic5",  0x2800000, 0x800000, CRC(f2f3f7ab) SHA1(3e662197d7cc0b606706a2edb9433093d2bcd2d9) )
2840        ROM_LOAD( "mpr-23383.ic6",  0x3000000, 0x800000, CRC(f19069c1) SHA1(ccec4008d95f8305e9d77a5b34a3de8aec3606dc) )
2841        ROM_LOAD( "mpr-23384.ic7",  0x3800000, 0x800000, CRC(5150bb17) SHA1(9fab19f02e6f79e68e8e10aad78e47135081957d) )
2842        ROM_LOAD( "mpr-23385.ic8",  0x4000000, 0x800000, CRC(747e4025) SHA1(ad3ee65ac473fda8c82c5e3dd349abaa9312bd35) )
2843        ROM_LOAD( "mpr-23386.ic9",  0x4800000, 0x800000, CRC(28e22914) SHA1(e57d627de314dd13c229de91d061588df53b2164) )
2844        ROM_LOAD( "mpr-23387.ic10", 0x5000000, 0x800000, CRC(3b5c0fe4) SHA1(cbe93bf95d6386e5a0d44e27e6953e259f8667bd) )
2845        ROM_LOAD( "mpr-23388.ic11", 0x5800000, 0x800000, CRC(35d55060) SHA1(7c566f2ee82478aa63689f96088138902d9ee710) )
2846        ROM_LOAD( "mpr-23389.ic12", 0x6000000, 0x800000, CRC(360b9078) SHA1(26160273848d4f9c3992ea125b0d36bed58add49) )
2847        ROM_LOAD( "mpr-23390.ic13", 0x6800000, 0x800000, CRC(d5878f2d) SHA1(d918a37198033c74dadc1c531889f61c88ef94a8) )
2848        ROM_LOAD( "mpr-23391.ic14", 0x7000000, 0x800000, CRC(eef8b0c6) SHA1(0339a094cbecf97c785bb1071b2b598c1ab60e40) )
2849        ROM_LOAD( "mpr-23392.ic15", 0x7800000, 0x800000, CRC(df16126b) SHA1(b932afe38dd8e5f96412807743f44043fe450f14) )
2850        ROM_LOAD( "mpr-23393.ic16", 0x8000000, 0x800000, CRC(e6d383a3) SHA1(6a77318f718171fe998a8e18d542dd43b8a9b87d) )
2851        ROM_LOAD( "mpr-23394.ic17", 0x8800000, 0x800000, CRC(045235c4) SHA1(f1c4e09847840769d26719a26bdcf3c9241280a5) )
2852        ROM_LOAD( "mpr-23395.ic18", 0x9000000, 0x800000, CRC(ed645203) SHA1(b621c96c9ca49a7582a50bf5c513b910dead4e13) )
2853        ROM_LOAD( "mpr-23396.ic19", 0x9800000, 0x800000, CRC(42826956) SHA1(386eca3cda2bddb1825dbae850f0c17d1374eb41) )
2854        ROM_LOAD( "mpr-23397.ic20", 0xa000000, 0x800000, CRC(28d2caf6) SHA1(67a3bc19abccf7f211c3aae67e751815857bd564) )
2855        ROM_LOAD( "mpr-23398.ic21", 0xa800000, 0x800000, CRC(ea4d4d2a) SHA1(3dc9c7164516ae7f3b988c088ab819d8fd40d75e) )
29162856ROM_END
29172857
29182858ROM_START( alpiltdx )
r7500r7501
29212861   NAOMI_DEFAULT_EEPROM
29222862
29232863   ROM_REGION( 0xb000000, "user1", ROMREGION_ERASEFF)
2924   ROM_LOAD( "epr21787b.ic22", 0x0000000, 0x400000, CRC(56893156) SHA1(8e56e0633f92b1f50105421b7eb8428f51a78b27) )
2925   ROM_LOAD( "mpr21728.ic1",  0x0800000, 0x800000, CRC(872338d4) SHA1(04857b300196c0ec51361d7cf7bb57274a15a326) )
2926   ROM_LOAD( "mpr21729.ic2",  0x1000000, 0x800000, CRC(9a9b72ad) SHA1(ce96da7904dd82abaa448df45e954521dd834ed8) )
2927   ROM_LOAD( "mpr21730.ic3",  0x1800000, 0x800000, CRC(93c25058) SHA1(658374bca3cf615982ebcf493eeaaa9e40e70f03) )
2928   ROM_LOAD( "mpr21731.ic4",  0x2000000, 0x800000, CRC(f14e578b) SHA1(d572903f7021757aebbb903b25a11a5aaf9f7a71) )
2929   ROM_LOAD( "mpr21732.ic5",  0x2800000, 0x800000, CRC(28ea4e8c) SHA1(7f87fe08819e756bb7aadca2aaacb0f6e59c13f0) )
2930   ROM_LOAD( "mpr21733.ic6",  0x3000000, 0x800000, CRC(5aee9e99) SHA1(8db726a73723c931fd8a4be2dd99d7c32352ad21) )
2931   ROM_LOAD( "mpr21734.ic7",  0x3800000, 0x800000, CRC(0574390d) SHA1(5988bdd089d23035ee2dd3596ea9c822455311d3) )
2932   ROM_LOAD( "mpr21735.ic8",  0x4000000, 0x800000, CRC(811400b4) SHA1(5f8d8b70f499b293b2d952c754c853c53b39c438) )
2933   ROM_LOAD( "mpr21736.ic9",  0x4800000, 0x800000, CRC(d74eda63) SHA1(d6794fa433cea9f06dc0a20dc9e10388162e7fd8) )
2934   ROM_LOAD( "mpr21737.ic10", 0x5000000, 0x800000, CRC(260aaa98) SHA1(d1082587afe9d79f286df8b107a553ee51c27643) )
2935   ROM_LOAD( "mpr21738.ic11", 0x5800000, 0x800000, CRC(95a592e8) SHA1(862dce467e8805381bab001df68262f1baf3c498) )
2864   ROM_LOAD( "epr-21787b.ic22", 0x0000000, 0x400000, CRC(56893156) SHA1(8e56e0633f92b1f50105421b7eb8428f51a78b27) )
2865   ROM_LOAD( "mpr-21728.ic1",  0x0800000, 0x800000, CRC(872338d4) SHA1(04857b300196c0ec51361d7cf7bb57274a15a326) )
2866   ROM_LOAD( "mpr-21729.ic2",  0x1000000, 0x800000, CRC(9a9b72ad) SHA1(ce96da7904dd82abaa448df45e954521dd834ed8) )
2867   ROM_LOAD( "mpr-21730.ic3",  0x1800000, 0x800000, CRC(93c25058) SHA1(658374bca3cf615982ebcf493eeaaa9e40e70f03) )
2868   ROM_LOAD( "mpr-21731.ic4",  0x2000000, 0x800000, CRC(f14e578b) SHA1(d572903f7021757aebbb903b25a11a5aaf9f7a71) )
2869   ROM_LOAD( "mpr-21732.ic5",  0x2800000, 0x800000, CRC(28ea4e8c) SHA1(7f87fe08819e756bb7aadca2aaacb0f6e59c13f0) )
2870   ROM_LOAD( "mpr-21733.ic6",  0x3000000, 0x800000, CRC(5aee9e99) SHA1(8db726a73723c931fd8a4be2dd99d7c32352ad21) )
2871   ROM_LOAD( "mpr-21734.ic7",  0x3800000, 0x800000, CRC(0574390d) SHA1(5988bdd089d23035ee2dd3596ea9c822455311d3) )
2872   ROM_LOAD( "mpr-21735.ic8",  0x4000000, 0x800000, CRC(811400b4) SHA1(5f8d8b70f499b293b2d952c754c853c53b39c438) )
2873   ROM_LOAD( "mpr-21736.ic9",  0x4800000, 0x800000, CRC(d74eda63) SHA1(d6794fa433cea9f06dc0a20dc9e10388162e7fd8) )
2874   ROM_LOAD( "mpr-21737.ic10", 0x5000000, 0x800000, CRC(260aaa98) SHA1(d1082587afe9d79f286df8b107a553ee51c27643) )
2875   ROM_LOAD( "mpr-21738.ic11", 0x5800000, 0x800000, CRC(95a592e8) SHA1(862dce467e8805381bab001df68262f1baf3c498) )
29362876
29372877   // on-cart X76F100 eeprom contents
29382878   ROM_REGION( 0x100, "naomibd_eeprom", ROMREGION_ERASE00 )
r7500r7501
29462886
29472887   ROM_REGION( 0xb000000, "user1", ROMREGION_ERASEFF)
29482888   ROM_LOAD( "epr-21739a.ic22", 0x000000, 0x400000, CRC(08f22bab) SHA1(fedc80eef7c824381fd834cc04202383c9340c4f) )
2949   ROM_LOAD( "mpr21728.ic1",  0x0800000, 0x800000, CRC(872338d4) SHA1(04857b300196c0ec51361d7cf7bb57274a15a326) )
2950   ROM_LOAD( "mpr21729.ic2",  0x1000000, 0x800000, CRC(9a9b72ad) SHA1(ce96da7904dd82abaa448df45e954521dd834ed8) )
2951   ROM_LOAD( "mpr21730.ic3",  0x1800000, 0x800000, CRC(93c25058) SHA1(658374bca3cf615982ebcf493eeaaa9e40e70f03) )
2952   ROM_LOAD( "mpr21731.ic4",  0x2000000, 0x800000, CRC(f14e578b) SHA1(d572903f7021757aebbb903b25a11a5aaf9f7a71) )
2953   ROM_LOAD( "mpr21732.ic5",  0x2800000, 0x800000, CRC(28ea4e8c) SHA1(7f87fe08819e756bb7aadca2aaacb0f6e59c13f0) )
2954   ROM_LOAD( "mpr21733.ic6",  0x3000000, 0x800000, CRC(5aee9e99) SHA1(8db726a73723c931fd8a4be2dd99d7c32352ad21) )
2955   ROM_LOAD( "mpr21734.ic7",  0x3800000, 0x800000, CRC(0574390d) SHA1(5988bdd089d23035ee2dd3596ea9c822455311d3) )
2956   ROM_LOAD( "mpr21735.ic8",  0x4000000, 0x800000, CRC(811400b4) SHA1(5f8d8b70f499b293b2d952c754c853c53b39c438) )
2957   ROM_LOAD( "mpr21736.ic9",  0x4800000, 0x800000, CRC(d74eda63) SHA1(d6794fa433cea9f06dc0a20dc9e10388162e7fd8) )
2958   ROM_LOAD( "mpr21737.ic10", 0x5000000, 0x800000, CRC(260aaa98) SHA1(d1082587afe9d79f286df8b107a553ee51c27643) )
2959   ROM_LOAD( "mpr21738.ic11", 0x5800000, 0x800000, CRC(95a592e8) SHA1(862dce467e8805381bab001df68262f1baf3c498) )
2889   ROM_LOAD( "mpr-21728.ic1",  0x0800000, 0x800000, CRC(872338d4) SHA1(04857b300196c0ec51361d7cf7bb57274a15a326) )
2890   ROM_LOAD( "mpr-21729.ic2",  0x1000000, 0x800000, CRC(9a9b72ad) SHA1(ce96da7904dd82abaa448df45e954521dd834ed8) )
2891   ROM_LOAD( "mpr-21730.ic3",  0x1800000, 0x800000, CRC(93c25058) SHA1(658374bca3cf615982ebcf493eeaaa9e40e70f03) )
2892   ROM_LOAD( "mpr-21731.ic4",  0x2000000, 0x800000, CRC(f14e578b) SHA1(d572903f7021757aebbb903b25a11a5aaf9f7a71) )
2893   ROM_LOAD( "mpr-21732.ic5",  0x2800000, 0x800000, CRC(28ea4e8c) SHA1(7f87fe08819e756bb7aadca2aaacb0f6e59c13f0) )
2894   ROM_LOAD( "mpr-21733.ic6",  0x3000000, 0x800000, CRC(5aee9e99) SHA1(8db726a73723c931fd8a4be2dd99d7c32352ad21) )
2895   ROM_LOAD( "mpr-21734.ic7",  0x3800000, 0x800000, CRC(0574390d) SHA1(5988bdd089d23035ee2dd3596ea9c822455311d3) )
2896   ROM_LOAD( "mpr-21735.ic8",  0x4000000, 0x800000, CRC(811400b4) SHA1(5f8d8b70f499b293b2d952c754c853c53b39c438) )
2897   ROM_LOAD( "mpr-21736.ic9",  0x4800000, 0x800000, CRC(d74eda63) SHA1(d6794fa433cea9f06dc0a20dc9e10388162e7fd8) )
2898   ROM_LOAD( "mpr-21737.ic10", 0x5000000, 0x800000, CRC(260aaa98) SHA1(d1082587afe9d79f286df8b107a553ee51c27643) )
2899   ROM_LOAD( "mpr-21738.ic11", 0x5800000, 0x800000, CRC(95a592e8) SHA1(862dce467e8805381bab001df68262f1baf3c498) )
29602900ROM_END
29612901
29622902ROM_START( hotd2 )
r7500r7501
30663006
30673007   ROM_REGION( 0xb000000, "user1", ROMREGION_ERASEFF)
30683008   ROM_LOAD("epr-23377.ic11",        0x0000000, 0x0400000, CRC(4ca3149c) SHA1(9d25fc659658b416202b033754669be2f3abcdbe) )
3069   /* Test mode returns IC1 as bad dump, it looks like that is data provided by the Actel A54SX32 FPGA present on board
3070       and mirrored there.  Provided as documentation until we know more about it. */
3071   ROM_LOAD("gram2000.ic1",          0x0800000, 0x0800000, CRC(4a86556a) SHA1(61100dc84c95dd47d9f61c7cc52ea25579b90632) )
3009   // the 0x0800000 - 0x0ffffff space mirrors part of roms 17/18, see ROM_COPY below, gets tested as 'IC1' if actel_id is 0xffff
30723010   ROM_LOAD32_WORD("mpr-23357.ic17", 0x1000000, 0x0800000, CRC(eaf77487) SHA1(bdfc4666a6724441c11b31d89fa30c4bd11cbdd1) ) //ic 2
30733011   ROM_LOAD32_WORD("mpr-23358.ic18", 0x1000002, 0x0800000, CRC(96819a5b) SHA1(e28c9d7b0579ab5d6116401b49f30dc8e4961618) ) //ic 3
30743012   ROM_LOAD32_WORD("mpr-23359.ic19", 0x2000000, 0x0800000, CRC(757b9e89) SHA1(b131af1cbcb4fcebb7081b208acc86841192ff14) ) //ic 4
r7500r7501
30893027   ROM_LOAD32_WORD("mpr-23374.ic34", 0x9000002, 0x0800000, CRC(1f8a2e08) SHA1(ff9b9bfada831baeb4830a3d1a4bfb38570b9972) ) //ic 19
30903028   ROM_LOAD32_WORD("mpr-23375.ic35", 0xa000000, 0x0800000, CRC(7d4043db) SHA1(cadf22419e5b63c33a179bb6b0742035fc9d8028) ) //ic 20
30913029   ROM_LOAD32_WORD("mpr-23376.ic36", 0xa000002, 0x0800000, CRC(e09cb473) SHA1(c3ec980f1a56142a0e06bae9594d6038acf0690d) ) //ic 21
3030
3031   ROM_COPY( "user1", 0x1400000, 0x0800000, 0x0800000 ) // mirror data so IC1 check can pass
3032   //ROM_COPY( "user1", 0x1000000, 0x0400000, 0x0c00000 ) // or does it mirror the start of 17/18 from 0x0400000 upwards like this, check on real hw
30923033ROM_END
30933034
30943035ROM_START( crackndj )
r7500r7501
32063147   ROM_LOAD("mpr-23713.ic9", 0x4800000, 0x0800000, CRC(2969bac7) SHA1(5f1cf6ac726c2fe183d66e4022962e44592f9ccd) )
32073148   ROM_LOAD("mpr-23714.ic10",0x5000000, 0x0800000, CRC(da462c44) SHA1(ca450b6c07f939f96eba7b44c45b4e38abd598aa) )
32083149        ROM_LOAD("mpr-23715.ic11",0x5800000, 0x0800000, CRC(c750abbd) SHA1(2a5bedc2b21cd3f991c7145ccfd8c7a9e7f647ae) )
3209   // trojaned protection data
3210   ROM_REGION( 0x200000, "naomibd_prot", ROMREGION_ERASE00 )
3211        ROM_LOAD( "a3075ac0.bin", 0x000000, 0x00ff04, CRC(440dca2a) SHA1(4e261ff309e7e774fa2061de30174b0e4e967c00) )
3212        ROM_LOAD( "a30859c4.bin", 0x010000, 0x00ff04, CRC(c22c76a7) SHA1(76d9e47730e4551e6e1a96eeee937296f1153b8b) )
3213        ROM_LOAD( "a30958c8.bin", 0x020000, 0x00ff04, CRC(8f29ee4d) SHA1(e1ac1ccf85dc338e9d5381dfa8ededc8af8f3e92) )
3214        ROM_LOAD( "a30a57cc.bin", 0x030000, 0x00ff04, CRC(479846c1) SHA1(b063e2f7d521cd8a60b770477c13946679e06dd7) )
3215        ROM_LOAD( "a30b56d0.bin", 0x040000, 0x00ff04, CRC(107f777e) SHA1(002f062a2073dff5f0d4722803aef0a8ffc7a61a) )
3216        ROM_LOAD( "a30c55d4.bin", 0x050000, 0x00ff04, CRC(d73b35c1) SHA1(951cceaf6a53d4fc4b967c3675d3fa98a6874b2a) )
3217        ROM_LOAD( "a30d54d8.bin", 0x060000, 0x00ff04, CRC(969a6957) SHA1(ee6909f832b96ec3e6ae0cec3f18a7983cae89d9) )
3218        ROM_LOAD( "a30e53dc.bin", 0x070000, 0x00ff04, CRC(002f7b41) SHA1(12bb33f1229d74b32ab481f5a2e57332f0def6e7) )
3219        ROM_LOAD( "a30f52e0.bin", 0x080000, 0x00a904, CRC(97e32fdd) SHA1(a40f412e40544a45784b2f8d9d5494b6491efc4a) )
3220        ROM_LOAD( "a30ffbe4.bin", 0x090000, 0x000084, CRC(c4311af6) SHA1(7a53061a1a1a024d72880a9a9c2e6a61d2607a46) )
3221        ROM_LOAD( "a30ffc80.bin", 0x0a0000, 0x00ff04, CRC(b1b5e559) SHA1(2f5963d8aa46d7aeb869769a7052d3006d56d5a4) )
3222        ROM_LOAD( "a310fb84.bin", 0x0b0000, 0x00ff04, CRC(91bdc0b2) SHA1(3f77fe6b67dba605296c3c038265b4e0e7eabd97) )
3223        ROM_LOAD( "a311fa88.bin", 0x0c0000, 0x00ff04, CRC(dc5d1334) SHA1(52287bd3ade05be4511e43a7707de8cc38117316) )
3224        ROM_LOAD( "a312f98c.bin", 0x0d0000, 0x00ff04, CRC(e3d9ea36) SHA1(0860f5ac3086d16132f3d0d27266c644470b4f1e) )
3225        ROM_LOAD( "a313f890.bin", 0x0e0000, 0x00ff04, CRC(8b23c562) SHA1(fcc9d04c150f007dcd4a9a2bbee1e438a81b7c49) )
3226        ROM_LOAD( "a314f794.bin", 0x0f0000, 0x009104, CRC(0c0a9aa2) SHA1(1b9063a18703ce4a03ffe20e3f13e9bae06bdb57) )
3227        ROM_LOAD( "a3158898.bin", 0x100000, 0x0000ac, CRC(e23f61d5) SHA1(80ff570a6846f1af2b87e5888675257728e8e253) )
3228        ROM_LOAD( "a0800f40.bin", 0x110000, 0x000204, CRC(f4935846) SHA1(d7eaa710274080f378afa4fb2e14f3bd406c45fe) )
3229        ROM_LOAD( "a0801144.bin", 0x120000, 0x000034, CRC(28a62ac0) SHA1(d9bb6baf5feaca655f333e2f0b9b200f44ef1726) )
3230        ROM_LOAD( "a0801180.bin", 0x130000, 0x00ff04, CRC(4b9e08b7) SHA1(dab208f7af4475210135aeb648e6bed7db7399b9) )
3231        ROM_LOAD( "a0811084.bin", 0x140000, 0x00ff04, CRC(4003bab7) SHA1(0b1df4b9b1d1a1072719b559a71f5ae5811be63c) )
3232        ROM_LOAD( "a0820f88.bin", 0x150000, 0x007e04, CRC(67fb4342) SHA1(8b8c384a1628756a08aa8131095e49756967b5e2) )
3233        ROM_LOAD( "a0828d8c.bin", 0x160000, 0x0000f4, CRC(71c85e2b) SHA1(680b6ee02ea24a502bc42bade23e11e6a7ddc7ad) )
32343150ROM_END
32353151
32363152/*
r7500r7501
32533169IC9     64M     717F    40ED
32543170IC10    64M     1E43    0F1A
32553171
3256byteswaped @ e0158 key b957 read count 400, write 404
3257e055c key 37ca read count 400, write 404
3258
32593172*/
32603173
32613174ROM_START( gwing2 )
r7500r7501
32703183        ROM_LOAD("mpr-22273.ic3", 0x2800000, 0x1000000, CRC(cd633dcf) SHA1(f044d93802a4ba29d0e70c597d3fbe65da591335) )
32713184        ROM_LOAD("mpr-22274.ic4", 0x3800000, 0x1000000, CRC(f8daaaf3) SHA1(8854d3f8e3d55715ede33ee918b641e251f752b4) )
32723185        ROM_LOAD("mpr-22275.ic5", 0x4800000, 0x1000000, CRC(61aa1521) SHA1(7d9f5790e72a9151d128ac7887e236526fdf72a0) )
3273
3274   // trojaned protection data (filename is address read from)
3275   ROM_REGION( 0x200000, "naomibd_prot", ROMREGION_ERASE00 )
3276        ROM_LOAD( "a085ddc0.bin", 0x000000, 0x00c960, CRC(77303f1c) SHA1(5dc8799b9ec102540c6e7647eccb69dfc5e6ecfb) )
3277        ROM_LOAD( "a080c6c0.bin", 0x010000, 0x020000, CRC(168e551a) SHA1(03bb8ce4bb233db75a0e07a8b5ad28149b5f126e) )
3278        ROM_LOAD( "a082c6c4.bin", 0x030000, 0x020000, CRC(bd2fcd3a) SHA1(2eefa22472d7caf30a3467c1f7ed8dc72f1665c1) )
3279        ROM_LOAD( "a084c6c8.bin", 0x050000, 0x020000, CRC(c1d28ba0) SHA1(5e497758c3756fe993b481ab2009402a105fbc63) )
3280        ROM_LOAD( "a08c67e0.bin", 0x070000, 0x020000, CRC(ceabcb70) SHA1(bbc97218f32913eefe52b1bb1606bad60d7c2894) )
3281        ROM_LOAD( "a08e67e4.bin", 0x090000, 0x020000, CRC(4bc98e7b) SHA1(5f506d05a05a129bf500f0112e39b722872f1220) )
3282        ROM_LOAD( "a09067e8.bin", 0x0b0000, 0x020000, CRC(4cd8a958) SHA1(d3a96287986ab851acced420c4ff9f4d2035188a) )
3283        ROM_LOAD( "a09267ec.bin", 0x0d0000, 0x020000, CRC(17c1df0d) SHA1(62964224f27c54651518a8622756c253d777629a) )
3284        ROM_LOAD( "a09467f0.bin", 0x0f0000, 0x020000, CRC(99c78505) SHA1(bbb95757bc0be76c680255a0e72d2eacc4ca525e) )
3285        ROM_LOAD( "a09667f4.bin", 0x110000, 0x016360, CRC(bec1fd2f) SHA1(e2e9d47d6d5d35bfa9a432c7f47f95c780b17551) )
3286        ROM_LOAD( "a088acc0.bin", 0x130000, 0x020000, CRC(abb1e0d9) SHA1(a1d5d484faaa806b365069755660ec14c1cecada) )
3287        ROM_LOAD( "a08aacc4.bin", 0x150000, 0x01bb00, CRC(2acc08c8) SHA1(c04276ec940a73e4b8fe140ef9f4bec8c629ecc9) )
3288        ROM_LOAD( "a086a740.bin", 0x170000, 0x020000, CRC(5d90c88c) SHA1(7af4107e1930292d3c64b80cb29d31aae8a565b6) )
3289        ROM_LOAD( "a088a744.bin", 0x190000, 0x000560, CRC(79c8eb0f) SHA1(0216fa128d9851b96f3864446ef71e0ed6f4ccd0) )
3290        ROM_LOAD( "a097cb60.bin", 0x1a0000, 0x010820, CRC(371e88d9) SHA1(04f0167000e96d556227e8abf6e06e0698e61e9f) )
3291   ROM_LOAD( "a0807fa0.bin", 0x1c0000, 0x004700, CRC(4eed5ff3) SHA1(26425baa06959d612b3b7e9f367fbb97258f544e) )
3292        ROM_LOAD( "a0800000.bin", 0x1d0000, 0x006040, CRC(17651005) SHA1(500806ba917133ae604817c6ee2913d10762e290) )
3293        ROM_LOAD( "a0806060.bin", 0x1e0000, 0x001f20, CRC(ff25a8fe) SHA1(e8c0ddf63802e3d35478e1a491dc7162283b2474) )
32943186ROM_END
32953187
32963188/*
r7500r7501
34013293   ROM_LOAD("mpr-23059.ic28",  0x6000000, 0x0800000, CRC(64808024) SHA1(1a6c60c330642b273978d3dd02d95d17d36ee3f2) )
34023294   ROM_LOAD("mpr-23060.ic29",  0x6800000, 0x0800000, CRC(67519942) SHA1(fc758d9075625f8140d5d828c8f6b7a91bcc9119) )
34033295   ROM_LOAD("mpr-23061.ic30",  0x7000000, 0x0800000, CRC(fb1844c4) SHA1(1d1571516a6dbed0c4ded3b80efde9cc9281f66f) )
3404        ROM_LOAD("mpr-23083.ic31",  0x7800000, 0x0400000, CRC(c61d2dfe) SHA1(a05fb979ed7c8040de91716fc8814e6bd995efa2) )
3405        ROM_LOAD("mpr-23084.ic32",  0x8000000, 0x0400000, CRC(e228cdfd) SHA1(d02a2e3557bd24cf34c5ddb42d41ca15e78ae885) )
3296   ROM_LOAD("mpr-23083.ic31",  0x7800000, 0x0400000, CRC(c61d2dfe) SHA1(a05fb979ed7c8040de91716fc8814e6bd995efa2) )
3297   ROM_LOAD("mpr-23084.ic32",  0x8000000, 0x0400000, CRC(e228cdfd) SHA1(d02a2e3557bd24cf34c5ddb42d41ca15e78ae885) )
34063298
3299
3300
34073301   // DMA protection data
3408        ROM_LOAD("88000000.bin", 0x8800000, 0x025f00, CRC(77d79823) SHA1(2545d28eee47114e8ffb9bc6d7a910e90fc48420) )
3409        ROM_LOAD("88026440.bin", 0x8830000, 0x016520, CRC(dad9ebbd) SHA1(39c0697caa2b5ee11d99e75726e92ed86a23f10b) )
3410        ROM_LOAD("8803bda0.bin", 0x8850000, 0x01e5e0, CRC(9e0b8202) SHA1(729bed557c1a00da13c990603bbadab38d90285e) )
3411        ROM_LOAD("8805a560.bin", 0x8870000, 0x0017a0, CRC(7bc27482) SHA1(6ce6074cf47989f42af02deb7aac52883912784a) )
3412        ROM_LOAD("8805b720.bin", 0x8880000, 0x02b5a0, CRC(485d0aef) SHA1(853f4b49b489cc512c906edcaf3cd8b5bf4c64c0) )
3413        ROM_LOAD("8808b7e0.bin", 0x88a0000, 0x013ec0, CRC(0fc8f363) SHA1(dad30d43cef89d01ce80301b1d796aabad755de6) )
3302   ROM_LOAD("88000000.bin", 0x8800000, 0x025f00, CRC(77d79823) SHA1(2545d28eee47114e8ffb9bc6d7a910e90fc48420) )
3303   ROM_LOAD("88026440.bin", 0x8830000, 0x016520, CRC(dad9ebbd) SHA1(39c0697caa2b5ee11d99e75726e92ed86a23f10b) )
3304   ROM_LOAD("8803bda0.bin", 0x8850000, 0x01e5e0, CRC(9e0b8202) SHA1(729bed557c1a00da13c990603bbadab38d90285e) )
3305   ROM_LOAD("8805a560.bin", 0x8870000, 0x0017a0, CRC(7bc27482) SHA1(6ce6074cf47989f42af02deb7aac52883912784a) )
3306   ROM_LOAD("8805b720.bin", 0x8880000, 0x02b5a0, CRC(485d0aef) SHA1(853f4b49b489cc512c906edcaf3cd8b5bf4c64c0) )
3307   ROM_LOAD("8808b7e0.bin", 0x88a0000, 0x013ec0, CRC(0fc8f363) SHA1(dad30d43cef89d01ce80301b1d796aabad755de6) )
34143308ROM_END
34153309
34163310/* toy fighter - 1999 sega */
r7500r7501
34333327   ROM_LOAD("mpr-22032.ic8", 0x4000000, 0x0800000, CRC(3c48c9ba) SHA1(00be199b23040f8e81db2ec489ba98cbf615652c) )
34343328   ROM_LOAD("mpr-22033.ic9", 0x4800000, 0x0800000, CRC(5fe5586e) SHA1(3ff41ae1f81469597684faadd88e62b5e0634352) )
34353329   ROM_LOAD("mpr-22034.ic10",0x5000000, 0x0800000, CRC(3aa5ce5e) SHA1(f00a906235e4522d6fc2ac771324114346875314) )
3436
3437   // protection data (also found in cleartext in the program ROM!)
3438   ROM_REGION( 0x400000, "naomibd_prot", ROMREGION_ERASE00 )
3439   ROM_COPY("user1", 0, 0, 0x400000)
34403330ROM_END
34413331
34423332/* Crazy Taxi */
3443/* protection: crypt data at 0x3ff000, key 0x0219, feed 0x504, read 0x500 */
34443333ROM_START( crzytaxi )
34453334   ROM_REGION( 0x200000, "maincpu", 0)
34463335   NAOMI_BIOS
34473336   NAOMI_DEFAULT_EEPROM
34483337
34493338   ROM_REGION( 0x8800000, "user1", ROMREGION_ERASEFF)
3450        ROM_LOAD( "epr21684.bin",   0x0000000, 0x400000, CRC(f1de77b7) SHA1(4490b828534db6676b2d0129498fd7694eb9e5ff) )
3451        ROM_LOAD( "mpr21671.ic1",   0x0800000, 0x800000, CRC(2d362137) SHA1(ed6eb45eadb784910eee44d0273534ab68ad6937) )
3452        ROM_LOAD( "mpr21672.ic2",   0x1000000, 0x800000, CRC(72c7da8e) SHA1(0ed3d71c052a2cccbbf0f7b20e2ec688316c7247) )
3453        ROM_LOAD( "mpr21673.ic3",   0x1800000, 0x800000, CRC(27481c0d) SHA1(08779e33eda1a45cb06319327cb4254dc3e4460f) )
3454        ROM_LOAD( "mpr21674.ic4",   0x2000000, 0x800000, CRC(c2e2a98c) SHA1(9a40456ca025c2a6314cef705f7d147bbf95c0f0) )
3455        ROM_LOAD( "mpr21675.ic5",   0x2800000, 0x800000, CRC(6b755510) SHA1(3fa967587e05c5bd45db3fe8a2cbc56f44166ef6) )
3456        ROM_LOAD( "mpr21676.ic6",   0x3000000, 0x800000, CRC(f33d1f39) SHA1(b1d589a9ab7ec4988e63bfb458ef006308e1de70) )
3457        ROM_LOAD( "mpr21677.ic7",   0x3800000, 0x800000, CRC(ab4dc61b) SHA1(d92ff434e7a2b9d3598f9d7004aa717b9bd21980) )
3458        ROM_LOAD( "mpr21678.ic10",  0x5000000, 0x800000, CRC(297c778a) SHA1(67e5685cd03a3aaaac1c47f15c7b3f3e341d34b1) )
3459        ROM_LOAD( "mpr21679.ic11",  0x5800000, 0x800000, CRC(6b540c4a) SHA1(9877c31b41110230182c0ee8d40753907981c7f9) )
3460        ROM_LOAD( "mpr21680.ic12s", 0x6000000, 0x800000, CRC(e76f03f9) SHA1(ea20aa86d02a77315cca8cb6be75ca4ca9cc7484) )
3461        ROM_LOAD( "mpr21681.ic13s", 0x6800000, 0x800000, CRC(e5dcde7d) SHA1(8a90d9fb4ce0d2ceb609fcf4c54cf5b55c266c50) )
3462        ROM_LOAD( "mpr21682.ic14s", 0x7000000, 0x800000, CRC(54c0290e) SHA1(6e07ab6e95c29a2aabed0ba1a7af0d7d605e0309) )
3463        ROM_LOAD( "mpr21683.ic15s", 0x7800000, 0x800000, CRC(ac8a27e0) SHA1(8e71d853a102dd6c164d5326e6d157ccfb8c7b36) )
3464
3465   ROM_REGION( 0x200000, "naomibd_prot", ROMREGION_ERASE00 )
3466        ROM_LOAD( "a03ff000.bin", 0x000000, 0x000500, CRC(be5e415d) SHA1(baf87191236f332c8df7674a080c2be4824a4bcb) )
3339        ROM_LOAD( "epr-21684.ic22",   0x0000000, 0x400000, CRC(f1de77b7) SHA1(4490b828534db6676b2d0129498fd7694eb9e5ff) )
3340        ROM_LOAD( "mpr-21671.ic1",   0x0800000, 0x800000, CRC(2d362137) SHA1(ed6eb45eadb784910eee44d0273534ab68ad6937) )
3341        ROM_LOAD( "mpr-21672.ic2",   0x1000000, 0x800000, CRC(72c7da8e) SHA1(0ed3d71c052a2cccbbf0f7b20e2ec688316c7247) )
3342        ROM_LOAD( "mpr-21673.ic3",   0x1800000, 0x800000, CRC(27481c0d) SHA1(08779e33eda1a45cb06319327cb4254dc3e4460f) )
3343        ROM_LOAD( "mpr-21674.ic4",   0x2000000, 0x800000, CRC(c2e2a98c) SHA1(9a40456ca025c2a6314cef705f7d147bbf95c0f0) )
3344        ROM_LOAD( "mpr-21675.ic5",   0x2800000, 0x800000, CRC(6b755510) SHA1(3fa967587e05c5bd45db3fe8a2cbc56f44166ef6) )
3345        ROM_LOAD( "mpr-21676.ic6",   0x3000000, 0x800000, CRC(f33d1f39) SHA1(b1d589a9ab7ec4988e63bfb458ef006308e1de70) )
3346        ROM_LOAD( "mpr-21677.ic7",   0x3800000, 0x800000, CRC(ab4dc61b) SHA1(d92ff434e7a2b9d3598f9d7004aa717b9bd21980) )
3347        ROM_LOAD( "mpr-21678.ic10",  0x5000000, 0x800000, CRC(297c778a) SHA1(67e5685cd03a3aaaac1c47f15c7b3f3e341d34b1) )
3348        ROM_LOAD( "mpr-21679.ic11",  0x5800000, 0x800000, CRC(6b540c4a) SHA1(9877c31b41110230182c0ee8d40753907981c7f9) )
3349        ROM_LOAD( "mpr-21680.ic12s", 0x6000000, 0x800000, CRC(e76f03f9) SHA1(ea20aa86d02a77315cca8cb6be75ca4ca9cc7484) )
3350        ROM_LOAD( "mpr-21681.ic13s", 0x6800000, 0x800000, CRC(e5dcde7d) SHA1(8a90d9fb4ce0d2ceb609fcf4c54cf5b55c266c50) )
3351        ROM_LOAD( "mpr-21682.ic14s", 0x7000000, 0x800000, CRC(54c0290e) SHA1(6e07ab6e95c29a2aabed0ba1a7af0d7d605e0309) )
3352        ROM_LOAD( "mpr-21683.ic15s", 0x7800000, 0x800000, CRC(ac8a27e0) SHA1(8e71d853a102dd6c164d5326e6d157ccfb8c7b36) )
34673353ROM_END
34683354
34693355/* Jambo! Safari */
r7500r7501
34733359   NAOMI_DEFAULT_EEPROM
34743360
34753361   ROM_REGION( 0x8800000, "user1", ROMREGION_ERASEFF)
3476        ROM_LOAD( "epr22826a.bin", 0x0000000, 0x400000, CRC(18f8f3bc) SHA1(417f2282c9970775e51b56d2eeb671a50ca293a7) )
3477        ROM_LOAD( "mpr22818.ic1",  0x0800000, 0x800000, CRC(3a709e11) SHA1(e7dd71dd244e872c35595456bd428dd79a81f081) )
3478        ROM_LOAD( "mpr22819.ic2",  0x1000000, 0x800000, CRC(57b2d565) SHA1(be5e6404c8187dc75cd6f033a36af413bf28bdee) )
3479        ROM_LOAD( "mpr22820.ic3",  0x1800000, 0x800000, CRC(3284e16b) SHA1(bdf9249f19c0a444a9f00e831563e91c576a7cca) )
3480        ROM_LOAD( "mpr22821.ic4",  0x2000000, 0x800000, CRC(5ca54154) SHA1(7bb1ba3fae71368145fd68d31bdce0588f641f78) )
3481        ROM_LOAD( "mpr22822.ic5",  0x2800000, 0x800000, CRC(8bc0c4d5) SHA1(b250ddeaab904b15737f1348b62d7b3f11103609) )
3482        ROM_LOAD( "mpr22823.ic6",  0x3000000, 0x800000, CRC(00c33e51) SHA1(c55646a146ed259e6c61fd912c93fa784b5e6910) )
3483        ROM_LOAD( "mpr22824.ic7",  0x3800000, 0x800000, CRC(cc55304a) SHA1(e548d8de83469e5816c55dbbb00afbb894282fd6) )
3484        ROM_LOAD( "mpr22825.ic8",  0x4000000, 0x800000, CRC(85bada10) SHA1(b6e15d8f1d6bca12ffa4816ed0393c04ca500fba) )
3485
3486   ROM_REGION( 0x200000, "naomibd_prot", ROMREGION_ERASE00 )
3487        ROM_LOAD( "a03ff000.bin", 0x000000, 0x000500, CRC(74ffc580) SHA1(8de297303b14a6773c0d944de1bc1dcc3b1d042e) )
3362        ROM_LOAD( "epr-22826a.ic22", 0x0000000, 0x400000, CRC(18f8f3bc) SHA1(417f2282c9970775e51b56d2eeb671a50ca293a7) )
3363        ROM_LOAD( "mpr-22818.ic1",  0x0800000, 0x800000, CRC(3a709e11) SHA1(e7dd71dd244e872c35595456bd428dd79a81f081) )
3364        ROM_LOAD( "mpr-22819.ic2",  0x1000000, 0x800000, CRC(57b2d565) SHA1(be5e6404c8187dc75cd6f033a36af413bf28bdee) )
3365        ROM_LOAD( "mpr-22820.ic3",  0x1800000, 0x800000, CRC(3284e16b) SHA1(bdf9249f19c0a444a9f00e831563e91c576a7cca) )
3366        ROM_LOAD( "mpr-22821.ic4",  0x2000000, 0x800000, CRC(5ca54154) SHA1(7bb1ba3fae71368145fd68d31bdce0588f641f78) )
3367        ROM_LOAD( "mpr-22822.ic5",  0x2800000, 0x800000, CRC(8bc0c4d5) SHA1(b250ddeaab904b15737f1348b62d7b3f11103609) )
3368        ROM_LOAD( "mpr-22823.ic6",  0x3000000, 0x800000, CRC(00c33e51) SHA1(c55646a146ed259e6c61fd912c93fa784b5e6910) )
3369        ROM_LOAD( "mpr-22824.ic7",  0x3800000, 0x800000, CRC(cc55304a) SHA1(e548d8de83469e5816c55dbbb00afbb894282fd6) )
3370        ROM_LOAD( "mpr-22825.ic8",  0x4000000, 0x800000, CRC(85bada10) SHA1(b6e15d8f1d6bca12ffa4816ed0393c04ca500fba) )
34883371ROM_END
34893372
34903373/* 18 Wheeler */
r7500r7501
34943377   NAOMI_DEFAULT_EEPROM
34953378
34963379   ROM_REGION( 0xa800000, "user1", ROMREGION_ERASEFF)
3497        ROM_LOAD( "epr22185.bin",   0x0000000, 0x400000, CRC(219b29b0) SHA1(2f32caf3906fc1408fd8126a500e74c682ff20fa) )
3498        ROM_LOAD( "mpr22164.ic1",   0x0800000, 0x800000, CRC(ca045315) SHA1(0c5becb5220659fa86f1e7901032f8c9a1329a51) )
3499        ROM_LOAD( "mpr22165.ic2",   0x1000000, 0x800000, CRC(e43f4ba8) SHA1(768159bccae6a72c809e9f374538df304c92fbfe) )
3500        ROM_LOAD( "mpr22166.ic3",   0x1800000, 0x800000, CRC(ea67edb1) SHA1(1214fdbfd8ce9f7a2b33e97f7c4e22ebb3eee988) )
3501        ROM_LOAD( "mpr22167.ic4",   0x2000000, 0x800000, CRC(df6125e2) SHA1(7244278cf89b88dbc7b8b1e3a537bf0b3f521c3a) )
3502        ROM_LOAD( "mpr22168.ic5",   0x2800000, 0x800000, CRC(8a919f9c) SHA1(28f1f9d8943e0a0b7bc186808cdab5d21d914e05) )
3503        ROM_LOAD( "mpr22169.ic6",   0x3000000, 0x800000, CRC(a0fa7d68) SHA1(010fc87f0df3cf9e3d01a5ca4d4aa7e84728652d) )
3504        ROM_LOAD( "mpr22170.ic7",   0x3800000, 0x800000, CRC(1f407049) SHA1(3c11b25168715d200f8d78a3db7bfc8cb3c29897) )
3505        ROM_LOAD( "mpr22171.ic8",   0x4000000, 0x800000, CRC(03ce8dcd) SHA1(9bf1eb0a2628317bea5d8899e34f6f4363729c52) )
3506        ROM_LOAD( "mpr22172.ic9",   0x4800000, 0x800000, CRC(c3e8c978) SHA1(96cbaa0f13e22365b04818cb5cad2ddc2027e38a) )
3507        ROM_LOAD( "mpr22173.ic10",  0x5000000, 0x800000, CRC(3caec8fc) SHA1(88ee6b0a1735788570d0a6507eec14a31ebabb9a) )
3508        ROM_LOAD( "mpr22174.ic11",  0x5800000, 0x800000, CRC(17245a27) SHA1(b3701155b1bbdbcbfb5ea686470c3c432d2573b7) )
3509        ROM_LOAD( "mpr22175.ic12s", 0x6000000, 0x800000, CRC(4d984682) SHA1(60270d6caa3bbc0025a0c01cf4d7b10783216e0b) )
3510        ROM_LOAD( "mpr22176.ic13s", 0x6800000, 0x800000, CRC(3ea2403f) SHA1(efde74c621a8fe17d8aa3a24da35e2ca6bc0bd9a) )
3511        ROM_LOAD( "mpr22177.ic14s", 0x7000000, 0x800000, CRC(15514cbc) SHA1(0171d67560b8d72ca3f718dcce301acc60dee1fa) )
3512        ROM_LOAD( "mpr22178.ic15s", 0x7800000, 0x800000, CRC(9ea0552f) SHA1(4b282110ef9f60f942518f3849acfff4a5faf4bd) )
3513        ROM_LOAD( "mpr22179.ic16s", 0x8000000, 0x800000, CRC(6915c4e6) SHA1(b44d49edcfdc0f2958bf1a3856b09b5442e8f1a3) )
3514        ROM_LOAD( "mpr22180.ic17s", 0x8800000, 0x800000, CRC(744c3a40) SHA1(56fba6ebc45d542ba6e4f4dd205194344f127ac2) )
3515        ROM_LOAD( "mpr22181.ic18s", 0x9000000, 0x800000, CRC(5a39b68e) SHA1(0f81ed1116b1829262f320fc82f93df107b6f848) )
3516        ROM_LOAD( "mpr22182.ic19s", 0x9800000, 0x800000, CRC(c5606c42) SHA1(5871104ff1c7acde0493e13b9a4d0abdf8a40728) )
3517        ROM_LOAD( "mpr22183.ic20s", 0xa000000, 0x800000, CRC(776af308) SHA1(7d29cb4dce75d34c622549fea7e102868d0da60a) )
3380        ROM_LOAD( "epr-22185.ic22",   0x0000000, 0x400000, CRC(219b29b0) SHA1(2f32caf3906fc1408fd8126a500e74c682ff20fa) )
3381        ROM_LOAD( "mpr-22164.ic1",   0x0800000, 0x800000, CRC(ca045315) SHA1(0c5becb5220659fa86f1e7901032f8c9a1329a51) )
3382        ROM_LOAD( "mpr-22165.ic2",   0x1000000, 0x800000, CRC(e43f4ba8) SHA1(768159bccae6a72c809e9f374538df304c92fbfe) )
3383        ROM_LOAD( "mpr-22166.ic3",   0x1800000, 0x800000, CRC(ea67edb1) SHA1(1214fdbfd8ce9f7a2b33e97f7c4e22ebb3eee988) )
3384        ROM_LOAD( "mpr-22167.ic4",   0x2000000, 0x800000, CRC(df6125e2) SHA1(7244278cf89b88dbc7b8b1e3a537bf0b3f521c3a) )
3385        ROM_LOAD( "mpr-22168.ic5",   0x2800000, 0x800000, CRC(8a919f9c) SHA1(28f1f9d8943e0a0b7bc186808cdab5d21d914e05) )
3386        ROM_LOAD( "mpr-22169.ic6",   0x3000000, 0x800000, CRC(a0fa7d68) SHA1(010fc87f0df3cf9e3d01a5ca4d4aa7e84728652d) )
3387        ROM_LOAD( "mpr-22170.ic7",   0x3800000, 0x800000, CRC(1f407049) SHA1(3c11b25168715d200f8d78a3db7bfc8cb3c29897) )
3388        ROM_LOAD( "mpr-22171.ic8",   0x4000000, 0x800000, CRC(03ce8dcd) SHA1(9bf1eb0a2628317bea5d8899e34f6f4363729c52) )
3389        ROM_LOAD( "mpr-22172.ic9",   0x4800000, 0x800000, CRC(c3e8c978) SHA1(96cbaa0f13e22365b04818cb5cad2ddc2027e38a) )
3390        ROM_LOAD( "mpr-22173.ic10",  0x5000000, 0x800000, CRC(3caec8fc) SHA1(88ee6b0a1735788570d0a6507eec14a31ebabb9a) )
3391        ROM_LOAD( "mpr-22174.ic11",  0x5800000, 0x800000, CRC(17245a27) SHA1(b3701155b1bbdbcbfb5ea686470c3c432d2573b7) )
3392        ROM_LOAD( "mpr-22175.ic12s", 0x6000000, 0x800000, CRC(4d984682) SHA1(60270d6caa3bbc0025a0c01cf4d7b10783216e0b) )
3393        ROM_LOAD( "mpr-22176.ic13s", 0x6800000, 0x800000, CRC(3ea2403f) SHA1(efde74c621a8fe17d8aa3a24da35e2ca6bc0bd9a) )
3394        ROM_LOAD( "mpr-22177.ic14s", 0x7000000, 0x800000, CRC(15514cbc) SHA1(0171d67560b8d72ca3f718dcce301acc60dee1fa) )
3395        ROM_LOAD( "mpr-22178.ic15s", 0x7800000, 0x800000, CRC(9ea0552f) SHA1(4b282110ef9f60f942518f3849acfff4a5faf4bd) )
3396        ROM_LOAD( "mpr-22179.ic16s", 0x8000000, 0x800000, CRC(6915c4e6) SHA1(b44d49edcfdc0f2958bf1a3856b09b5442e8f1a3) )
3397        ROM_LOAD( "mpr-22180.ic17s", 0x8800000, 0x800000, CRC(744c3a40) SHA1(56fba6ebc45d542ba6e4f4dd205194344f127ac2) )
3398        ROM_LOAD( "mpr-22181.ic18s", 0x9000000, 0x800000, CRC(5a39b68e) SHA1(0f81ed1116b1829262f320fc82f93df107b6f848) )
3399        ROM_LOAD( "mpr-22182.ic19s", 0x9800000, 0x800000, CRC(c5606c42) SHA1(5871104ff1c7acde0493e13b9a4d0abdf8a40728) )
3400        ROM_LOAD( "mpr-22183.ic20s", 0xa000000, 0x800000, CRC(776af308) SHA1(7d29cb4dce75d34c622549fea7e102868d0da60a) )
35183401
35193402   ROM_REGION( 0x200000, "naomibd_prot", ROMREGION_ERASE00 )
35203403        ROM_LOAD( "00800000.bin", 0x000000, 0x002000, CRC(7fc42084) SHA1(7c7b9e7e0b8885e690f3edd25e6d26201c899f2f) )
r7500r7501
36603543        ROM_LOAD( "mpr-23545.ic9",  0x8800000, 0x1000000, CRC(60bd692f) SHA1(37b508f4a821d832eafff81574e7df3fe1c729f8) )
36613544        ROM_LOAD( "mpr-23546.ic10", 0x9800000, 0x1000000, CRC(85db2248) SHA1(37845c269a2e65ee6181a8e7500c2e7dd9b2e343) )
36623545        ROM_LOAD( "mpr-23547.ic11", 0xa800000, 0x1000000, CRC(18b369c7) SHA1(b61cb3fda8cc685865684f7afc7dad0b29d93ca5) )
3663
3664   // trojaned protection data (filename is address read from)
3665   ROM_REGION( 0x200000, "naomibd_prot", ROMREGION_ERASE00 )
3666        ROM_LOAD( "a0820000.bin", 0x000000, 0x00267e, CRC(15db53ed) SHA1(a28ba1abc77ca559cff2fd34f3499c556ad8674e) )
3667        ROM_LOAD( "a0920000.bin", 0x010000, 0x00c91c, CRC(431436f8) SHA1(0136d6b210689b2023f982300bc8842b5c0914b4) )
3668        ROM_LOAD( "a092c920.bin", 0x020000, 0x00a53c, CRC(43e1a419) SHA1(34020cc7b10a1c5b2860db84d133489bce53d3d4) )
3669        ROM_LOAD( "a0936e60.bin", 0x030000, 0x001a32, CRC(2a998df6) SHA1(c7bed2777b2358bc0f1d7a3c23f3029591eb674d) )
3670        ROM_LOAD( "a3480000.bin", 0x040000, 0x008e9c, CRC(c8939e48) SHA1(a8d26c2b32211a50b8cc49b51c0d2e34416cc715) )
36713546ROM_END
36723547
36733548/*
r7500r7501
37493624   ROM_LOAD("mpr-23124.ic7", 0x3800000, 0x0800000, CRC(508c0207) SHA1(e50d97a17cdd6771fbc63a254a4d638e7daa8f57) )
37503625   ROM_LOAD("mpr-23125.ic8", 0x4000000, 0x0800000, CRC(b9938bbc) SHA1(d55d7adecb5a5a4a276a5a17c12808085d980fd9) )
37513626   ROM_LOAD("mpr-23126.ic9", 0x4800000, 0x0800000, CRC(fbb0325b) SHA1(21b965519d7508d84344641d43e8af2c3ca29ba4) )
3752
3753   // trojaned protection data (filename is address read from)
3754   ROM_REGION( 0x200000, "naomibd_prot", ROMREGION_ERASE00 )
3755        ROM_LOAD( "a2785e20.bin", 0x000000, 0x0072f0, CRC(52912418) SHA1(ec0992eda50953001801d152e09195a17132cb0f) )
3756        ROM_LOAD( "a2765e00.bin", 0x010000, 0x00e47c, CRC(d9acaa94) SHA1(6ab7ebc2dd78c0bc007f3656a67f3c24d23d48ae) )
3757        ROM_LOAD( "a2774280.bin", 0x020000, 0x00c61c, CRC(8dd9581f) SHA1(f852c44e423effa894769d3e156325a132b2df8e) )
3758        ROM_LOAD( "a27808a0.bin", 0x030000, 0x005568, CRC(4f4aee03) SHA1(453c0ec08ca69ad844f24be290e92bf16231a713) )
3759        ROM_LOAD( "a154bdc0.bin", 0x040000, 0x00ec9c, CRC(755a7343) SHA1(a4355850e1cb6f81d53d461e70884a5c51083454) )
3760        ROM_LOAD( "a155aa60.bin", 0x050000, 0x00951c, CRC(fc7a23d8) SHA1(a428114d89471f4b4c8af6d932376e7b0887c4cc) )
3761        ROM_LOAD( "a1563f80.bin", 0x060000, 0x009f3c, CRC(90903b9c) SHA1(da6fcda74710497bab97c4c8342d93b5dfb14184) )
3762        ROM_LOAD( "a156dec0.bin", 0x070000, 0x00dbdc, CRC(fb7b0b77) SHA1(ace73e925e5ffa3f805ff0ef68b564119cf4ce41) )
3763        ROM_LOAD( "a157baa0.bin", 0x080000, 0x00cb3c, CRC(60e5dad6) SHA1(db8880ebbc3ebb02d861aa3bcf2cc34071d613e8) )
3764        ROM_LOAD( "a15885e0.bin", 0x090000, 0x00e91c, CRC(6b2e1400) SHA1(8965e97e3d85a568c2bef2d1d0faf5b8aee289d0) )
3765        ROM_LOAD( "a1596f00.bin", 0x0a0000, 0x00a3bc, CRC(cf538afa) SHA1(b7f94195760a0b14c18654823ead2e28fe526b07) )
3766        ROM_LOAD( "a15a12c0.bin", 0x0b0000, 0x007f04, CRC(e07d589b) SHA1(60bc7f3e91d1f22b4854777644add346e5df58bb) )
3767        ROM_LOAD( "a15a91e0.bin", 0x0c0000, 0x00c91c, CRC(124fce0b) SHA1(8949df4586c736e22c88b7594221ae114848284a) )
3768        ROM_LOAD( "a15b5b00.bin", 0x0d0000, 0x00a53c, CRC(453bb126) SHA1(d5251f54e80504f3c427f6cc3443fe56edcd62c0) )
3769        ROM_LOAD( "a15c0040.bin", 0x0e0000, 0x0088e0, CRC(7d601fb3) SHA1(ff2aca546e0db05b79f48fdb086f0e8e7e0853e4) )
3770        ROM_LOAD( "a16203e0.bin", 0x0f0000, 0x00c61c, CRC(300c8e1e) SHA1(25f9c4af3bed0da5fc9e440096fb5cf4c29a89b3) )
3771        ROM_LOAD( "a162ca00.bin", 0x100000, 0x009e9c, CRC(8f0ccd81) SHA1(0ae2209912e31195bb8110e28d0791fc398b49cd) )
3772        ROM_LOAD( "a16368a0.bin", 0x110000, 0x00b2dc, CRC(e497f060) SHA1(05d8ffc0ead6c31ddc3197c877466fec354a71d9) )
3773        ROM_LOAD( "a1641b80.bin", 0x120000, 0x00ac5c, CRC(e6d81d57) SHA1(97cfe0b14e1e23c7428dad426848de3fe2496ddb) )
3774        ROM_LOAD( "a164c7e0.bin", 0x130000, 0x008b7c, CRC(ab6ca421) SHA1(84979f01f82f34a9d708b645e9f2cc45abed03a9) )
3775        ROM_LOAD( "a1655360.bin", 0x140000, 0x00c8bc, CRC(c5554803) SHA1(06b712aed14a489d167876217cec48ad0aee495f) )
3776        ROM_LOAD( "a1661c20.bin", 0x150000, 0x0083dc, CRC(4f5abf07) SHA1(3d03f8728ce445b6070f182d84f843f08420ad05) )
3777        ROM_LOAD( "a166a000.bin", 0x160000, 0x00f73c, CRC(bfddc3bf) SHA1(a89bdebefaffc235e163a022d85b7c3bdbffcaf6) )
3778        ROM_LOAD( "a1679740.bin", 0x170000, 0x00fb5c, CRC(ec9889a5) SHA1(d7f04b62a8a78b3bfc9a25f1b21be08dcb986546) )
3779        ROM_LOAD( "a1688d00.bin", 0x180000, 0x00e080, CRC(ad7adaf6) SHA1(516858081ebab25ef0561e4b0f8842026504c5dd) )
3780        ROM_LOAD( "a1696d80.bin", 0x190000, 0x007c10, CRC(4e0c7365) SHA1(0d564956c8330aa57c504a247aef6a230b1e8884) )
37813627ROM_END
37823628
37833629
r7500r7501
38793725   ROM_LOAD32_WORD("mpr-23225.ic31", 0x8000000, 0x0800000, CRC(ea558614) SHA1(b7dfe5598639a8e59e3cbbee38b1d9a1d8e022ea) ) //ic 16
38803726   ROM_LOAD32_WORD("mpr-23226.ic32", 0x8000002, 0x0800000, CRC(cd5da506) SHA1(2e76c8892c1d389b0f12a0046213f43d2ab07d78) ) //ic 17
38813727
3728   ROM_COPY( "user1", 0x1400000, 0x0800000, 0x0800000 ) // mirror data for IC1 (no test on this game, but layout is the same as gram2000)
3729
38823730   // trojaned protection data (must be in the "user1" region because it's accessed via DMA)
38833731   ROM_LOAD( "81452000_dma.bin", 0x9000000, 0x000120, CRC(96049488) SHA1(e2b98e8986f8cbf026db50a652300081a8e470b0) )
38843732ROM_END
r7500r7501
39813829   NAOMI_DEFAULT_EEPROM
39823830
39833831   ROM_REGION( 0x2800000, "user1", ROMREGION_ERASEFF)
3984   ROM_LOAD("epr-a-24065.rom0.ic11",0x0000000, 0x0400000, CRC(622a9ba0) SHA1(2f4963b8447ecda78fea0107497c2811f075c07a) )
3832   ROM_LOAD("epr-a-24065.ic11",0x0000000, 0x0400000, CRC(622a9ba0) SHA1(2f4963b8447ecda78fea0107497c2811f075c07a) )
39853833   ROM_RELOAD( 0x400000, 0x400000)
3986   ROM_LOAD32_WORD("opr-24060.rom1.ic17s", 0x0800000, 0x0800000, CRC(7f3d868c) SHA1(dc352981371c5479a69756bb1cbbbca43252216d) )
3987   ROM_LOAD32_WORD("opr-24061.rom2.ic18",  0x0800002, 0x0800000, CRC(e934267c) SHA1(fdbe2b80e309aa8d9fefd2634aef20153735019d) )
3988   ROM_LOAD32_WORD("opr-24062.rom3.ic19s", 0x1800000, 0x0800000, CRC(26e32af4) SHA1(49412a04198175240ef9adb4b7afb8a628eb127d) )
3989   ROM_LOAD32_WORD("opr-24063.rom4.ic20",  0x1800002, 0x0800000, CRC(683fdcff) SHA1(890816ef1b3e604e16289998cf66e221ef75a0fe) )
3834   ROM_LOAD32_WORD("opr-24060.ic17s", 0x0800000, 0x0800000, CRC(7f3d868c) SHA1(dc352981371c5479a69756bb1cbbbca43252216d) )
3835   ROM_LOAD32_WORD("opr-24061.ic18",  0x0800002, 0x0800000, CRC(e934267c) SHA1(fdbe2b80e309aa8d9fefd2634aef20153735019d) )
3836   ROM_LOAD32_WORD("opr-24062.ic19s", 0x1800000, 0x0800000, CRC(26e32af4) SHA1(49412a04198175240ef9adb4b7afb8a628eb127d) )
3837   ROM_LOAD32_WORD("opr-24063.ic20",  0x1800002, 0x0800000, CRC(683fdcff) SHA1(890816ef1b3e604e16289998cf66e221ef75a0fe) )
39903838ROM_END
39913839
39923840// SHOOTOUT POOL (the original, the above set is a sequel)
r7500r7501
39963844   NAOMI_DEFAULT_EEPROM
39973845
39983846   ROM_REGION( 0x2800000, "user1", ROMREGION_ERASEFF)
3999        ROM_LOAD( "epr23844.bin", 0x000000, 0x400000, CRC(5c229638) SHA1(9185f9f2369bb2423faff4222419001ac9037d3f) )
3847        ROM_LOAD( "epr-23844.ic22", 0x000000, 0x400000, CRC(5c229638) SHA1(9185f9f2369bb2423faff4222419001ac9037d3f) )
40003848   ROM_RELOAD( 0x400000, 0x400000)
4001        ROM_LOAD32_WORD( "mpr23840.17s", 0x0800000, 0x800000, CRC(985e5ff4) SHA1(a6f529b1855cc2aef3bed8503746c2e38061f944) )
4002        ROM_LOAD32_WORD( "mpr23841.18",  0x0800002, 0x800000, CRC(255fc335) SHA1(34ffec963880383bb9c02642f73ba3c852699831) )
4003        ROM_LOAD32_WORD( "mpr23842.19s", 0x1800000, 0x800000, CRC(80724895) SHA1(ed4fa1160b35b3987702c0178bd31c3c5db69e6e) )
4004        ROM_LOAD32_WORD( "mpr23843.20",  0x1800002, 0x800000, CRC(3574f616) SHA1(40130e8f98fb31c98428d444b79491f6a06ac208) )
3849        ROM_LOAD32_WORD( "mpr-23840.17s", 0x0800000, 0x800000, CRC(985e5ff4) SHA1(a6f529b1855cc2aef3bed8503746c2e38061f944) )
3850        ROM_LOAD32_WORD( "mpr-23841.18",  0x0800002, 0x800000, CRC(255fc335) SHA1(34ffec963880383bb9c02642f73ba3c852699831) )
3851        ROM_LOAD32_WORD( "mpr-23842.19s", 0x1800000, 0x800000, CRC(80724895) SHA1(ed4fa1160b35b3987702c0178bd31c3c5db69e6e) )
3852        ROM_LOAD32_WORD( "mpr-23843.20",  0x1800002, 0x800000, CRC(3574f616) SHA1(40130e8f98fb31c98428d444b79491f6a06ac208) )
40053853ROM_END
40063854
40073855/*
r7500r7501
42974145        ROM_LOAD( "mpr-22267.ic6", 0x5800000, 0x1000000, CRC(67ec1027) SHA1(2432b33983bbc9b07477459adb5ee1a62b6c0ea3) )
42984146        ROM_LOAD( "mpr-22268.ic7", 0x6800000, 0x1000000, CRC(536f5eea) SHA1(f1de8624f82595adf75693b604fb026bf3f778ee) )
42994147        ROM_LOAD( "mpr-22269.ic8", 0x7800000, 0x1000000, CRC(6c0cf740) SHA1(da10b33a6e54afbe1d7e52801216e7119b0b33b1) )
4300
4301   // trojaned protection data (filename is address read from)
4302   ROM_REGION( 0x200000, "naomibd_prot", ROMREGION_ERASE00 )
4303   ROM_LOAD( "a24db210.bin", 0x000000, 0x00005e, CRC(79fc852b) SHA1(58229b71d1a7067dd6ce3a617edc7d8bdd132036) )
43044148ROM_END
43054149
43064150/*
r7500r7501
44044248   NAOMI_DEFAULT_EEPROM
44054249
44064250   ROM_REGION( 0x10000000, "user1", ROMREGION_ERASEFF)
4407        ROM_LOAD( "epr22327a.bin", 0x000000, 0x400000, CRC(e949004c) SHA1(54db84c3e1db30b233612f68dcd094b597deffd0) )
4408        ROM_LOAD32_WORD( "mpr22307.17s",  0x0800000, 0x800000, CRC(db5c0818) SHA1(d39d2241adeb962d68bfb76a9d1c0dcd538c3538) )
4409        ROM_LOAD32_WORD( "mpr22308.18",   0x0800002, 0x800000, CRC(ac996a0e) SHA1(5cf110b79ef250cd64919205874278b4a85a42f6) )
4410        ROM_LOAD32_WORD( "mpr22309.19s",  0x1800000, 0x800000, CRC(fba79592) SHA1(09f2be133cf503e6f5e13eef1b1e38c268529b68) )
4411        ROM_LOAD32_WORD( "mpr22310.20",   0x1800002, 0x800000, CRC(10876476) SHA1(590fd5532c72c67e285a12acd33e828f2e1ff5b1) )
4412        ROM_LOAD32_WORD( "mpr22311.21s",  0x2800000, 0x800000, CRC(ad735e61) SHA1(6d340ae2f8fe44b82b1bbace02b5c10e89e40400) )
4413        ROM_LOAD32_WORD( "mpr22312.22",   0x2800002, 0x800000, CRC(46830ffa) SHA1(89b843588a48352b958a70e85deb625c19a2fcc7) )
4414        ROM_LOAD32_WORD( "mpr22313.23s",  0x3800000, 0x800000, CRC(44900a20) SHA1(3a82938a81fd6634c51595479d59ae4215fb8af3) )
4415        ROM_LOAD32_WORD( "mpr22314.24",   0x3800002, 0x800000, CRC(3b0ba6e9) SHA1(0ee1dd2d67dd688de19b1ede00c48234994a4832) )
4416        ROM_LOAD32_WORD( "mpr22315.25s",  0x4800000, 0x800000, CRC(eebe4877) SHA1(bc13e50d85f51aa2baf3c00440a089a8aff998ef) )
4417        ROM_LOAD32_WORD( "mpr22316.26",   0x4800002, 0x800000, CRC(0a82d403) SHA1(fc002210397eb792c27885d440671225d0bed71f) )
4418        ROM_LOAD32_WORD( "mpr22317.27s",  0x5800000, 0x800000, CRC(55ef3e71) SHA1(d7643c5d3bb6ccf4b35511be2b5c776fc46a2f45) )
4419        ROM_LOAD32_WORD( "mpr22318.28",   0x5800002, 0x800000, CRC(3dfabb96) SHA1(97863c939e5bb3e976c517839faa49bcfbee83c5) )
4420        ROM_LOAD32_WORD( "mpr22319.29s",  0x6800000, 0x800000, CRC(9b92fd02) SHA1(19c9b279aca1aa6575047494ce26a36dbc93812f) )
4421        ROM_LOAD32_WORD( "mpr22320.30",   0x6800002, 0x800000, CRC(9b762f6e) SHA1(7f787a89574e45f529970377e8b6394472cd001b) )
4422        ROM_LOAD32_WORD( "mpr22321.31s",  0x7800000, 0x800000, CRC(5ce2b3f1) SHA1(9bac49167ced0415ab3b2cac20c7bcf205aecfdf) )
4423        ROM_LOAD32_WORD( "mpr22322.32",   0x7800002, 0x800000, CRC(21bf1caf) SHA1(bc1828db2f5f71ef87153a81b49b2ba72ba176e1) )
4424        ROM_LOAD32_WORD( "mpr22323.33s",  0x8800000, 0x800000, CRC(0bd632ab) SHA1(21acab5336dd0ba317839176f2557df95917729e) )
4425        ROM_LOAD32_WORD( "mpr22324.34",   0x8800002, 0x800000, CRC(ff2571d4) SHA1(c2cbb2345163bbf1973e63cefb9a952e5a52a6cf) )
4251        ROM_LOAD( "epr-22327a.bin", 0x000000, 0x400000, CRC(e949004c) SHA1(54db84c3e1db30b233612f68dcd094b597deffd0) )
4252        ROM_LOAD32_WORD( "mpr-22307.17s",  0x0800000, 0x800000, CRC(db5c0818) SHA1(d39d2241adeb962d68bfb76a9d1c0dcd538c3538) )
4253        ROM_LOAD32_WORD( "mpr-22308.18",   0x0800002, 0x800000, CRC(ac996a0e) SHA1(5cf110b79ef250cd64919205874278b4a85a42f6) )
4254        ROM_LOAD32_WORD( "mpr-22309.19s",  0x1800000, 0x800000, CRC(fba79592) SHA1(09f2be133cf503e6f5e13eef1b1e38c268529b68) )
4255        ROM_LOAD32_WORD( "mpr-22310.20",   0x1800002, 0x800000, CRC(10876476) SHA1(590fd5532c72c67e285a12acd33e828f2e1ff5b1) )
4256        ROM_LOAD32_WORD( "mpr-22311.21s",  0x2800000, 0x800000, CRC(ad735e61) SHA1(6d340ae2f8fe44b82b1bbace02b5c10e89e40400) )
4257        ROM_LOAD32_WORD( "mpr-22312.22",   0x2800002, 0x800000, CRC(46830ffa) SHA1(89b843588a48352b958a70e85deb625c19a2fcc7) )
4258        ROM_LOAD32_WORD( "mpr-22313.23s",  0x3800000, 0x800000, CRC(44900a20) SHA1(3a82938a81fd6634c51595479d59ae4215fb8af3) )
4259        ROM_LOAD32_WORD( "mpr-22314.24",   0x3800002, 0x800000, CRC(3b0ba6e9) SHA1(0ee1dd2d67dd688de19b1ede00c48234994a4832) )
4260        ROM_LOAD32_WORD( "mpr-22315.25s",  0x4800000, 0x800000, CRC(eebe4877) SHA1(bc13e50d85f51aa2baf3c00440a089a8aff998ef) )
4261        ROM_LOAD32_WORD( "mpr-22316.26",   0x4800002, 0x800000, CRC(0a82d403) SHA1(fc002210397eb792c27885d440671225d0bed71f) )
4262        ROM_LOAD32_WORD( "mpr-22317.27s",  0x5800000, 0x800000, CRC(55ef3e71) SHA1(d7643c5d3bb6ccf4b35511be2b5c776fc46a2f45) )
4263        ROM_LOAD32_WORD( "mpr-22318.28",   0x5800002, 0x800000, CRC(3dfabb96) SHA1(97863c939e5bb3e976c517839faa49bcfbee83c5) )
4264        ROM_LOAD32_WORD( "mpr-22319.29s",  0x6800000, 0x800000, CRC(9b92fd02) SHA1(19c9b279aca1aa6575047494ce26a36dbc93812f) )
4265        ROM_LOAD32_WORD( "mpr-22320.30",   0x6800002, 0x800000, CRC(9b762f6e) SHA1(7f787a89574e45f529970377e8b6394472cd001b) )
4266        ROM_LOAD32_WORD( "mpr-22321.31s",  0x7800000, 0x800000, CRC(5ce2b3f1) SHA1(9bac49167ced0415ab3b2cac20c7bcf205aecfdf) )
4267        ROM_LOAD32_WORD( "mpr-22322.32",   0x7800002, 0x800000, CRC(21bf1caf) SHA1(bc1828db2f5f71ef87153a81b49b2ba72ba176e1) )
4268        ROM_LOAD32_WORD( "mpr-22323.33s",  0x8800000, 0x800000, CRC(0bd632ab) SHA1(21acab5336dd0ba317839176f2557df95917729e) )
4269        ROM_LOAD32_WORD( "mpr-22324.34",   0x8800002, 0x800000, CRC(ff2571d4) SHA1(c2cbb2345163bbf1973e63cefb9a952e5a52a6cf) )
44264270
44274271   ROM_REGION( 0x200000, "naomibd_prot", ROMREGION_ERASE00 )
44284272        ROM_LOAD( "01f169c0.bin", 0x000000, 0x000100, CRC(b0a330f4) SHA1(10c7a7f4d6c7f265a32887beaca73686c4cb1e03) )
r7500r7501
46424486   DISK_IMAGE_READONLY( "gdl-0001", 0, SHA1(615e19c22f32096f3aad557019a14313b60a4070) )
46434487
46444488   ROM_REGION( 0x50, "picreturn", ROMREGION_ERASE)
4489   //ROM_LOAD("317-5069-com.data", 0x00, 0x50, CRC(8e2f0cbd) SHA1(a5f3a990a03bfa50a1a742593c5ec07645c8718d) )
4490
4491   ROM_REGION( 0x4000, "pic", ROMREGION_ERASEFF)
46454492   //PIC16C622A (317-5069-COM)
46464493   //(sticker 253-5509-5069)
4647   ROM_LOAD("317-5069-com.data", 0x00, 0x50, CRC(8e2f0cbd) SHA1(a5f3a990a03bfa50a1a742593c5ec07645c8718d) )
4494   ROM_LOAD("317-5069-com.pic", 0x00, 0x4000, CRC(44d0b242) SHA1(cac31c2ed317e2b44ee93d762188aacea2398949) )
4495
46484496ROM_END
46494497
46504498
r7500r7501
46584506   DISK_IMAGE_READONLY( "gdl-0002", 0, SHA1(af4669fdd7ce8e6ec4a170748d401e322a3d7ae8) )
46594507
46604508   ROM_REGION( 0x50, "picreturn", ROMREGION_ERASE)
4509   //ROM_LOAD("317-5072-com.data", 0x00, 0x50, CRC(6d2992b9) SHA1(88e6dc6711f9f883362ba1217a3350d452a70896) )
4510
4511   ROM_REGION( 0x4000, "pic", ROMREGION_ERASEFF)
46614512   //PIC16C622A (317-5072-COM)
46624513   //(sticker 253-5509-5072)
4663   ROM_LOAD("317-5072-com.data", 0x00, 0x50, CRC(6d2992b9) SHA1(88e6dc6711f9f883362ba1217a3350d452a70896) )
4514   ROM_LOAD("317-5072-com.pic", 0x00, 0x4000, CRC(3238ba01) SHA1(07c28f17c19eaa652295bbf2d3a96aa27c3748ae) )
46644515ROM_END
46654516
46664517ROM_START( cvsgd )
r7500r7501
46734524   DISK_IMAGE_READONLY( "gdl-0004", 0,  SHA1(7a7fba0fbbc769c5120b08e6d692f1ac63a42225) )
46744525
46754526   ROM_REGION( 0x50, "picreturn", ROMREGION_ERASE)
4527   //ROM_LOAD("317-5076-jpn.data", 0x00, 0x50, CRC(5004161b) SHA1(8b2cdfec12ffd9160bc74659e08d07cbc46a4011) )
4528
4529   ROM_REGION( 0x4000, "pic", ROMREGION_ERASEFF)
46764530   //PIC16C622A (317-5076-JPN)
46774531   //(sticker 253-5509-5076J)
4678   ROM_LOAD("317-5076-jpn.data", 0x00, 0x50, CRC(5004161b) SHA1(8b2cdfec12ffd9160bc74659e08d07cbc46a4011) )
4532   ROM_LOAD("317-5076-jpn.pic", 0x00, 0x4000, CRC(7c125b10) SHA1(557675e33bb45e4969560bbfd61f48d1784a728d) )
46794533ROM_END
46804534
46814535
r7500r7501
46894543   DISK_IMAGE_READONLY( "gdl-0006", 0, SHA1(b28d6598711b5a9c744bbf07ad03fc60962d2e28) )
46904544
46914545   ROM_REGION( 0x50, "picreturn", ROMREGION_ERASE)
4546   //ROM_LOAD("317-5079-com.data", 0x00, 0x50, CRC(e6abe978) SHA1(700e610d84e517793a22d6cabd1aef9c3b8bc092) )
4547
4548   ROM_REGION( 0x4000, "pic", ROMREGION_ERASEFF)
46924549   //PIC16C622A (317-5079-COM)
46934550   //(sticker 253-5509-5079)
4694   ROM_LOAD("317-5079-com.data", 0x00, 0x50, CRC(e6abe978) SHA1(700e610d84e517793a22d6cabd1aef9c3b8bc092) )
4551   ROM_LOAD("317-5079-com.pic", 0x00, 0x4000, CRC(8f9fb55d) SHA1(ca93814ae7a4e99762dd1c2a743e21402b143811) )
46954552ROM_END
46964553
46974554
r7500r7501
47054562   DISK_IMAGE_READONLY( "gdl-0007a", 0, SHA1(56510390667b39b3915d8bc078660cbe093cf566) )
47064563
47074564   ROM_REGION( 0x50, "picreturn", ROMREGION_ERASE)
4565   //ROM_LOAD("317-5078-com.data", 0x00, 0x50, CRC(1c8d94ee) SHA1(bec4a6901f62dc8f76f7b9d72284b3eaac340bf3) )
4566
4567   ROM_REGION( 0x4000, "pic", ROMREGION_ERASEFF)
47084568   //PIC16C622A (317-5078-COM)
47094569   //(sticker 253-5509-5078)
4710   ROM_LOAD("317-5078-com.data", 0x00, 0x50, CRC(1c8d94ee) SHA1(bec4a6901f62dc8f76f7b9d72284b3eaac340bf3) )
4570   ROM_LOAD("317-5078-com.pic", 0x00, 0x4000, CRC(e7bb621d) SHA1(0882d0e12ca4fb81dda2268cd12724a10278c220) )
47114571ROM_END
47124572
47134573ROM_START( ikaruga )
r7500r7501
47204580   DISK_IMAGE_READONLY( "gdl-0010", 0, SHA1(65dcc22dd9e9b70975096464ad8e31a4a73dc5fd) )
47214581
47224582   ROM_REGION( 0x50, "picreturn", ROMREGION_ERASE)
4583   //ROM_LOAD("317-5081-jpn.data", 0x00, 0x50, CRC(d4cc5c8c) SHA1(44c0c5c2744fbd419b684cbc36f01973487bafbc) )
4584
4585   ROM_REGION( 0x4000, "pic", ROMREGION_ERASEFF)
47234586   //PIC16C622A (317-5081-JPN)
47244587   //(sticker 253-5509-5081J)
4725   ROM_LOAD("317-5081-jpn.data", 0x00, 0x50, CRC(d4cc5c8c) SHA1(44c0c5c2744fbd419b684cbc36f01973487bafbc) )
4588   ROM_LOAD("317-5081-jpn.pic", 0x00, 0x4000, CRC(72ca4579) SHA1(8a46e92fc4a32016438ea877807928b51b3f3861) )
47264589ROM_END
47274590
47284591
r7500r7501
47364599   DISK_IMAGE_READONLY( "gdl-0011", 0, SHA1(b7328eb2c588d55284bdcea0fe89bb8e629a8669) )
47374600
47384601   ROM_REGION( 0x50, "picreturn", ROMREGION_ERASE)
4602//  ROM_LOAD("317-5082-com.data", 0x00, 0x50, CRC(fa31209d) SHA1(bb18e6412a02510832f7200a06a3179ef1695ef2) )
4603//  ROM_REGION( 0x9a49, "pichex", ROMREGION_ERASE)
4604//  ROM_LOAD("gdl-0011.hex", 0x00, 0x0009a49, CRC(36361df8) SHA1(86aa50c9b3debd49c7b67f1c9bfd052c0fefc593) ) // actual decap results for ggxx in ascii/hex form
4605
4606   ROM_REGION( 0x4000, "pic", ROMREGION_ERASEFF)
47394607   //PIC16C622A (317-5082-COM)
47404608   //(sticker 253-5509-5082)
4741   ROM_LOAD("317-5082-com.data", 0x00, 0x50, CRC(fa31209d) SHA1(bb18e6412a02510832f7200a06a3179ef1695ef2) )
4609   ROM_LOAD("317-5082-com.pic", 0x00, 0x4000, CRC(1b41189b) SHA1(efa0bf233ea4f64a8ed1c7a72b37de40ed069f33) )
47424610ROM_END
47434611
47444612
r7500r7501
47524620   DISK_IMAGE_READONLY( "gdl-0013", 0, SHA1(c8869069c28bc8eec96d820886bc388d69d46143) )
47534621
47544622   ROM_REGION( 0x50, "picreturn", ROMREGION_ERASE)
4623   //ROM_LOAD("317-5084-jpn.data", 0x00, 0x50, CRC(56de2066) SHA1(a16a6d9f7272d3f8d322c85222a0487a87811910) )
4624
4625   ROM_REGION( 0x4000, "pic", ROMREGION_ERASEFF)
47554626   //PIC16C622A (317-5084-JPN)
47564627   //(sticker 253-5509-5084J)
4757   ROM_LOAD("317-5084-jpn.data", 0x00, 0x50, CRC(56de2066) SHA1(a16a6d9f7272d3f8d322c85222a0487a87811910) )
4628   ROM_LOAD("317-5084-jpn.pic", 0x00, 0x4000, CRC(db7dac1e) SHA1(b6f7afe9d9d2681005c1abcd4fde24867e65d1e4) )
4629
47584630ROM_END
47594631
47604632
r7500r7501
47684640   DISK_IMAGE_READONLY( "gdl-0014a", 0, SHA1(f88d8203c8692f51c9492d5549a3ad7d9583dc6f) )
47694641
47704642   ROM_REGION( 0x50, "picreturn", ROMREGION_ERASE)
4643   //ROM_LOAD("317-5085-jpn.data", 0x00, 0x50, CRC(eecd8140) SHA1(471fb6b242eff646173265df891109e3e0a37a7d) )
4644
4645   ROM_REGION( 0x4000, "pic", ROMREGION_ERASEFF)
47714646   //PIC16C622A (317-5085-JPN)
47724647   //(sticker 253-5509-5085J)
4773   ROM_LOAD("317-5085-jpn.data", 0x00, 0x50, CRC(eecd8140) SHA1(471fb6b242eff646173265df891109e3e0a37a7d) )
4648   ROM_LOAD("317-5085-jpn.pic", 0x00, 0x4000, CRC(677fd544) SHA1(cccd4931bfe3fbcfcde6722088961ddf29a45e89) )
47744649ROM_END
47754650
47764651
r7500r7501
47844659   DISK_IMAGE_READONLY( "gdl-0017", 0, SHA1(94a9319633388968611892e36691b45c94b4f83f) )
47854660
47864661   ROM_REGION( 0x50, "picreturn", ROMREGION_ERASE)
4662   //ROM_LOAD("317-5090-jpn.data", 0x00, 0x50, CRC(b4dd88f6) SHA1(c9aacd79c1088225fa5a69b7bd31a7c1286160e1) )
4663
4664   ROM_REGION( 0x4000, "pic", ROMREGION_ERASEFF)
47874665   //PIC16C622A (317-5090-JPN)
47884666   //(sticker 253-5509-5090J)
4789   ROM_LOAD("317-5090-jpn.data", 0x00, 0x50, CRC(b4dd88f6) SHA1(c9aacd79c1088225fa5a69b7bd31a7c1286160e1) )
4667   ROM_LOAD("317-5090-jpn.pic", 0x00, 0x4000, CRC(141cced2) SHA1(c7fe2fc61be3585e95a2ce4c6d4373ea71e920de) )
47904668ROM_END
47914669
4670ROM_START( azumanga )
4671   NAOMIGD_BIOS
4672   NAOMI_DEFAULT_EEPROM
47924673
4674   ROM_REGION( 0x10000000, "user1", ROMREGION_ERASE) // allocate max size in init instead?
4675
4676   DISK_REGION( "gdrom" )
4677   DISK_IMAGE_READONLY( "gdl-0018", 0, SHA1(3e40ca7d43173fe7048d199fdc127b9411e10360) )
4678
4679   ROM_REGION( 0x50, "picreturn", ROMREGION_ERASE)
4680   //PIC16C622A (317-5091-JPN)
4681   //(sticker 253-5509-5091J)
4682   ROM_LOAD("317-5091-jpn.data", 0x00, 0x50, CRC(ca589c79) SHA1(ac44bfdfc8db2f9dbe4d563205719524bf43a674) )
4683ROM_END
4684
47934685ROM_START( ggxxrl )
47944686   NAOMIGD_BIOS
47954687   NAOMI_DEFAULT_EEPROM
r7500r7501
48004692   DISK_IMAGE_READONLY( "gdl-0019a", 0, SHA1(d44906505ff698eda6feee6c2b9402e19f64e5d3) )
48014693
48024694   ROM_REGION( 0x50, "picreturn", ROMREGION_ERASE)
4695   //ROM_LOAD("317-5092-jpn.data", 0x00, 0x50, CRC(7c8cca4b) SHA1(92c5a0fd8916744eefc023e64daea69803573928) )
4696
4697   ROM_REGION( 0x4000, "pic", ROMREGION_ERASEFF)
48034698   //PIC16C622A (317-5092-JPN)
48044699   //(sticker 253-5509-5092J)
4805   ROM_LOAD("317-5092-jpn.data", 0x00, 0x50, CRC(7c8cca4b) SHA1(92c5a0fd8916744eefc023e64daea69803573928) )
4700   ROM_LOAD("317-5092-jpn.pic", 0x00, 0x4000, CRC(7ad7b541) SHA1(45c1e3da030add3bb07797ee7f22003224ae3f7f) )
48064701ROM_END
48074702
48084703
r7500r7501
48164711   DISK_IMAGE_READONLY( "gdl-0020", 0, SHA1(7b2ef47ca2038d6a93615b760b03e8f7cb1b83c2) )
48174712
48184713   ROM_REGION( 0x50, "picreturn", ROMREGION_ERASE)
4714   //ROM_LOAD("317-5093-jpn.data", 0x00, 0x50, CRC(06bc5013) SHA1(f7a46b7e34b20409ce2fdae80e5cdfff7adb9c64) )
4715
4716   ROM_REGION( 0x4000, "pic", ROMREGION_ERASEFF)
48194717   //PIC16C622A (317-5093-JPN)
48204718   //(sticker 253-5509-5093J)
4821   ROM_LOAD("317-5093-jpn.data", 0x00, 0x50, CRC(06bc5013) SHA1(f7a46b7e34b20409ce2fdae80e5cdfff7adb9c64) )
4719   ROM_LOAD("317-5093-jpn.pic", 0x00, 0x4000, CRC(a61e1e2a) SHA1(ccbec76da6454d4d2384a2adb3f8b62aa1fece24) )
48224720ROM_END
48234721
48244722
r7500r7501
48324730   DISK_IMAGE_READONLY( "gdl-0021", 0, SHA1(f5036711a28a211e8d71400a8322db3172c5733f) )
48334731
48344732   ROM_REGION( 0x50, "picreturn", ROMREGION_ERASE)
4733   //ROM_LOAD("317-5095-jpn.data", 0x00, 0x50, CRC(6033ec89) SHA1(9e99a8ad43fa29296dbf2e13b3a3d4552130b4e8) )
4734
4735   ROM_REGION( 0x4000, "pic", ROMREGION_ERASEFF)
48354736   //PIC16C622A (317-5095-JPN)
48364737   //(sticker 253-5509-5095J)
4837   ROM_LOAD("317-5095-jpn.data", 0x00, 0x50, CRC(6033ec89) SHA1(9e99a8ad43fa29296dbf2e13b3a3d4552130b4e8) )
4738   ROM_LOAD("317-5095-jpn.pic", 0x00, 0x4000, CRC(7c25cb5c) SHA1(02797e890030ddf2df470e85ebd6c539f6621e53) )
48384739ROM_END
48394740
48404741
r7500r7501
48484749   DISK_IMAGE_READONLY( "gdl-0022", 0, SHA1(45deba05a12abbf6390c0fc0e4cdeaedfa7d2ca5) )
48494750
48504751   ROM_REGION( 0x50, "picreturn", ROMREGION_ERASE)
4752   //ROM_LOAD("317-5096-jpn.data", 0x00, 0x50, CRC(621e827a) SHA1(cdc7580f5d1dfe85d2806233f22bc4f13fd62946) )
4753
4754   ROM_REGION( 0x4000, "pic", ROMREGION_ERASEFF)
48514755   //PIC16C622A (317-5096-JPN)
48524756   //(sticker 253-5509-5096J)
4853   ROM_LOAD("317-5096-jpn.data", 0x00, 0x50, CRC(621e827a) SHA1(cdc7580f5d1dfe85d2806233f22bc4f13fd62946) )
4757   ROM_LOAD("317-5096-jpn.pic", 0x00, 0x4000, CRC(2d16887b) SHA1(32d11691c3d1242b16bc3fbcc0f1157bb16436e0) )
48544758ROM_END
48554759
48564760
r7500r7501
48644768   DISK_IMAGE_READONLY( "gdl-0023a", 0, SHA1(caac915104d61f2122f5afe27da1ef5fa9cf9f9a) )
48654769
48664770   ROM_REGION( 0x50, "picreturn", ROMREGION_ERASE)
4771   //ROM_LOAD("317-5097-jpn.data", 0x00, 0x50, CRC(e689d047) SHA1(7e3e298d9a8076af0254faeb0eb89fbfce94718d) )
4772
4773   ROM_REGION( 0x4000, "pic", ROMREGION_ERASEFF)
48674774   //PIC16C622A (317-5097-JPN)
48684775   //(sticker 253-5509-5097J)
4869   ROM_LOAD("317-5097-jpn.data", 0x00, 0x50, CRC(e689d047) SHA1(7e3e298d9a8076af0254faeb0eb89fbfce94718d) )
4776   ROM_LOAD("317-5097-jpn.pic", 0x00, 0x4000, CRC(16d2a748) SHA1(5358f89c26427428840fd9af7d584a55db5a76de) )
4777
48704778ROM_END
48714779
48724780
r7500r7501
48804788   DISK_IMAGE_READONLY( "gdl-0024", 0,  SHA1(d346762036fb1c40a261a434b50e63459f306f14) )
48814789
48824790   ROM_REGION( 0x50, "picreturn", ROMREGION_ERASE)
4791   //ROM_LOAD("317-5100-jpn.data", 0x00, 0x50, CRC(94316f0f) SHA1(e1ec2b4225105dbaa1e59e8a05027e73f7b725a9) )
4792
4793   ROM_REGION( 0x4000, "pic", ROMREGION_ERASEFF)
48834794   //PIC16C621A (317-5100-JPN)
48844795   //(sticker 253-5509-5100J)
4885   ROM_LOAD("317-5100-jpn.data", 0x00, 0x50, CRC(94316f0f) SHA1(e1ec2b4225105dbaa1e59e8a05027e73f7b725a9) )
4796   ROM_LOAD("317-5100-jpn.pic", 0x00, 0x4000, CRC(f37a1dbe) SHA1(a0b43069c9ecd5633418404344b7750db5371ac4) )
48864797ROM_END
48874798
48884799
r7500r7501
48974808
48984809
48994810   ROM_REGION( 0x50, "picreturn", ROMREGION_ERASE)
4811   //ROM_LOAD("317-5102-com.data", 0x00, 0x50, CRC(32adf2eb) SHA1(d86752e6fe9ccac093c512828fca5b7ae62a3ff2) )
4812
4813   ROM_REGION( 0x4000, "pic", ROMREGION_ERASEFF)
49004814   //PIC16C621A (317-5102-COM)
49014815   //(sticker 253-5509-5102)
4902   ROM_LOAD("317-5102-com.data", 0x00, 0x50, CRC(32adf2eb) SHA1(d86752e6fe9ccac093c512828fca5b7ae62a3ff2) )
4816   ROM_LOAD("317-5102-com.pic", 0x00, 0x4000, CRC(8f1d8387) SHA1(1f9427aca21b2de44959cd510b5f9105b845a532) )
49034817ROM_END
49044818
49054819
r7500r7501
49144828
49154829
49164830   ROM_REGION( 0x50, "picreturn", ROMREGION_ERASE)
4831   //ROM_LOAD("317-5103-jpn.data", 0x00, 0x50,  CRC(3affbf82) SHA1(268746e86e7546f4bab54bdd268f7b58f10c1aaf) )
4832
4833   ROM_REGION( 0x4000, "pic", ROMREGION_ERASEFF)
49174834   //PIC16C621A (317-5103-JPN)
49184835   //(sticker 253-5509-5103J)
4919   ROM_LOAD("317-5103-jpn.data", 0x00, 0x50, CRC(3affbf82) SHA1(268746e86e7546f4bab54bdd268f7b58f10c1aaf) )
4836   ROM_LOAD("317-5103-jpn.pic", 0x00, 0x4000, CRC(93feaff4) SHA1(0b362e9794c83b43e23a3d7299ff0b69f4740481) )
49204837ROM_END
49214838
49224839
r7500r7501
49304847   DISK_IMAGE_READONLY( "gdl-0028c", 0, SHA1(66de09738551e351784cc9695a58b35fdf6b6c4b) )
49314848
49324849   ROM_REGION( 0x50, "picreturn", ROMREGION_ERASE)
4850   //ROM_LOAD("317-5104-jpn.data", 0x00, 0x50, CRC(fedc8305) SHA1(c535545937213f726f25e6aa8eb3746a794e9100) )
4851
4852   ROM_REGION( 0x4000, "pic", ROMREGION_ERASEFF)
49334853   //PIC16C622A (317-5104-JPN)
49344854   //(sticker 253-5509-5104J)
4935   ROM_LOAD("317-5104-jpn.data", 0x00, 0x50, CRC(fedc8305) SHA1(c535545937213f726f25e6aa8eb3746a794e9100) )
4855   ROM_LOAD("317-5104-jpn.pic", 0x00, 0x4000, CRC(afa5e709) SHA1(c107f6c5b7574f2c7e7ac6ed1fcc37edabdc95e8) )
49364856ROM_END
49374857
49384858
r7500r7501
49464866   DISK_IMAGE_READONLY( "gdl-0030a", 0,  SHA1(1f7ade47e37a0026451b5baf3ba746400de8d156) )
49474867
49484868   ROM_REGION( 0x50, "picreturn", ROMREGION_ERASE)
4869   //ROM_LOAD("317-5107-jpn.data", 0x00, 0x50, CRC(7b607409) SHA1(a9946a0637453e4813bef18060d4420355cff800) )
4870
4871   ROM_REGION( 0x4000, "pic", ROMREGION_ERASEFF)
49494872   //PIC16C622A (317-5107-JPN)
49504873   //(sticker 253-5509-5107J)
4951   ROM_LOAD("317-5107-jpn.data", 0x00, 0x50, CRC(7b607409) SHA1(a9946a0637453e4813bef18060d4420355cff800) )
4874   ROM_LOAD("317-5107-jpn.pic", 0x00, 0x4000, CRC(6bc3fad0) SHA1(6d5196265232f4c0715a97acc84d6f7376056894) )
49524875ROM_END
49534876
49544877ROM_START( senkoo )
r7500r7501
49614884   DISK_IMAGE_READONLY( "gdl-0030", 0,  SHA1(c7f25c05f47a490c5da9369c588b6136e93c280e) )
49624885
49634886   ROM_REGION( 0x50, "picreturn", ROMREGION_ERASE)
4964   //PIC16C621A (317-5107-JPN)
4887   //ROM_LOAD("317-5107-jpn.data", 0x00, 0x50, CRC(7b607409) SHA1(a9946a0637453e4813bef18060d4420355cff800) )
4888
4889   ROM_REGION( 0x4000, "pic", ROMREGION_ERASEFF)
4890   //PIC16C622A (317-5107-JPN)
49654891   //(sticker 253-5509-5107J)
4966   ROM_LOAD("317-5107-jpn.data", 0x00, 0x50, CRC(7b607409) SHA1(a9946a0637453e4813bef18060d4420355cff800) )
4892   ROM_LOAD("317-5107-jpn.pic", 0x00, 0x4000, CRC(6bc3fad0) SHA1(6d5196265232f4c0715a97acc84d6f7376056894) )
49674893ROM_END
49684894
49694895
r7500r7501
49774903   DISK_IMAGE_READONLY( "gdl-0031a", 0, SHA1(6091525845fc2042ed43cae5a1b60c603e16cf97) )
49784904
49794905   ROM_REGION( 0x50, "picreturn", ROMREGION_ERASE)
4906   //ROM_LOAD("317-5108-jpn.data", 0x00, 0x50, CRC(6a2eb334) SHA1(cab407d2e994f33aa921d50f399b17e6fbf98eb0) )
4907
4908   ROM_REGION( 0x4000, "pic", ROMREGION_ERASEFF)
49804909   //PIC16C622A (317-5108-JPN)
49814910   //(sticker 253-5509-5108J)
4982   ROM_LOAD("317-5108-jpn.data", 0x00, 0x50, CRC(6a2eb334) SHA1(cab407d2e994f33aa921d50f399b17e6fbf98eb0) )
4911   ROM_LOAD("317-5108-jpn.pic", 0x00, 0x4000, CRC(4fa7dede) SHA1(f9011e951378364a12512d398f76be174dccce69) )
49834912ROM_END
49844913
49854914
r7500r7501
49934922   DISK_IMAGE_READONLY( "gdl-0032", 0, SHA1(ebd7a40e59082e660ebf9a2d4ae7cb64371dae8d) )
49944923
49954924   ROM_REGION( 0x50, "picreturn", ROMREGION_ERASE)
4925   //ROM_LOAD("317-5110-jpn.data", 0x00, 0x50, CRC(04e4ac45) SHA1(4102a4d68f20a7e78f6c7e3494e7229018e30e39) )
4926
4927   ROM_REGION( 0x4000, "pic", ROMREGION_ERASEFF)
49964928   //PIC16C621A (317-5110-JPN)
49974929   //(sticker 253-5509-5110J)
4998   ROM_LOAD("317-5110-jpn.data", 0x00, 0x50, CRC(04e4ac45) SHA1(4102a4d68f20a7e78f6c7e3494e7229018e30e39) )
4930   ROM_LOAD("317-5110-jpn.pic", 0x00, 0x4000, CRC(829d06e2) SHA1(c53d791e82cc75f2bcd49575185c89d448fed672) )
49994931ROM_END
50004932
50014933
r7500r7501
50094941   DISK_IMAGE_READONLY( "gdl-0033a", 0, SHA1(29de69ae97a9099b1bbe936dfa965bb4a3195f68) )
50104942
50114943   ROM_REGION( 0x50, "picreturn", ROMREGION_ERASE)
4944   //ROM_LOAD("317-5111-jpn.data", 0x00, 0x50, CRC(a517c70d) SHA1(5f9798941355fb9abce511508c860653d6369e72) )
4945
4946
4947   ROM_REGION( 0x4000, "pic", ROMREGION_ERASEFF)
50124948   //PIC16C621A (317-5111-JPN)
50134949   //(sticker 253-5509-5111J)
5014   ROM_LOAD("317-5111-jpn.data", 0x00, 0x50, CRC(a517c70d) SHA1(5f9798941355fb9abce511508c860653d6369e72) )
4950   ROM_LOAD("317-5111-jpn.pic", 0x00, 0x4000, CRC(96bcbd42) SHA1(af4efdf2a02920af9885d104091da0584fca988c) )
50154951ROM_END
50164952
50174953
r7500r7501
50254961   DISK_IMAGE_READONLY( "gdl-0034", 0, SHA1(10fd7edb0b620133c003d686e5af2ed27004fa09) )
50264962
50274963   ROM_REGION( 0x50, "picreturn", ROMREGION_ERASE)
4964   //ROM_LOAD("317-5115-jpn.data", 0x00, 0x50,  CRC(f40072a8) SHA1(366df2079a4d2ff7a93082c9bf849aad40ab079d) )
4965
4966   ROM_REGION( 0x4000, "pic", ROMREGION_ERASEFF)
50284967   //PIC16C621A (317-5115-JPN)
50294968   //(sticker 253-5509-5115J)
5030   ROM_LOAD("317-5115-jpn.data", 0x00, 0x50, CRC(f40072a8) SHA1(366df2079a4d2ff7a93082c9bf849aad40ab079d) )
4969   ROM_LOAD("317-5115-jpn.pic", 0x00, 0x4000, CRC(e5435e85) SHA1(9d5b25de82284e5fcab2cbf7fb73669d1130648a) )
50314970ROM_END
50324971
50334972
r7500r7501
50414980   DISK_IMAGE_READONLY( "gdl-0035", 0, SHA1(91da482a6a082e48bee5b3bd20d9c92d23936965) )
50424981
50434982   ROM_REGION( 0x50, "picreturn", ROMREGION_ERASE)
4983   //ROM_LOAD("317-5117-jpn.data", 0x00, 0x50,  CRC(f90f6d3b) SHA1(a18f803a8e951c375a3a55e4b0e74b698ae93f92) )
4984
4985   ROM_REGION( 0x4000, "pic", ROMREGION_ERASEFF)
50444986   //PIC16C622A (317-5117-JPN)
50454987   //(sticker 253-5509-5117J)
5046   ROM_LOAD("317-5117-jpn.data", 0x00, 0x50,  CRC(f90f6d3b) SHA1(a18f803a8e951c375a3a55e4b0e74b698ae93f92) )
4988   ROM_LOAD("317-5117-jpn.pic", 0x00, 0x4000,  CRC(61e65ca8) SHA1(f1a242d3dd1af0df084dd1568320f6b4c51d9e20) )
50474989ROM_END
50484990
50494991
r7500r7501
50574999   DISK_IMAGE_READONLY( "gdl-0039", 0, SHA1(ffc7f6e113ad69422a4f22f318bdf9b1dc5c25db) )
50585000
50595001   ROM_REGION( 0x50, "picreturn", ROMREGION_ERASE)
5002   //ROM_LOAD("317-5124-jpn.data", 0x00, 0x50, CRC(4d6e2c77) SHA1(3bed734c291140d0a61afa40f221395369a251a9) )
5003
5004   ROM_REGION( 0x4000, "pic", ROMREGION_ERASEFF)
50605005   //PIC16C622A (317-5124-JPN)
50615006   //(sticker 253-5509-5124J)
5062   ROM_LOAD("317-5124-jpn.data", 0x00, 0x50, CRC(4d6e2c77) SHA1(3bed734c291140d0a61afa40f221395369a251a9) )
5007   ROM_LOAD("317-5124-jpn.pic", 0x00, 0x4000, CRC(ad162bfa) SHA1(0e9740ba65a724eb7cd70fb897e5cd9ac17aa55c) )
50635008ROM_END
50645009
50655010ROM_START( meltyba )
r7500r7501
50725017   DISK_IMAGE_READONLY( "gdl-0039a", 0, SHA1(e6aa3d65b43a20606e6754bcb8665438770a1f8c) )
50735018
50745019   ROM_REGION( 0x50, "picreturn", ROMREGION_ERASE)
5020   //ROM_LOAD("317-5124-jpn.data", 0x00, 0x50, CRC(4d6e2c77) SHA1(3bed734c291140d0a61afa40f221395369a251a9) )
5021
5022   ROM_REGION( 0x4000, "pic", ROMREGION_ERASEFF)
50755023   //PIC16C622A (317-5124-JPN)
50765024   //(sticker 253-5509-5124J)
5077   ROM_LOAD("317-5124-jpn.data", 0x00, 0x50, CRC(4d6e2c77) SHA1(3bed734c291140d0a61afa40f221395369a251a9) )
5025   ROM_LOAD("317-5124-jpn.pic", 0x00, 0x4000, CRC(ad162bfa) SHA1(0e9740ba65a724eb7cd70fb897e5cd9ac17aa55c) )
50785026ROM_END
50795027
50805028
r7500r7501
50885036   DISK_IMAGE_READONLY( "gdl-0036a", 0, SHA1(91f1e19136997cb1e2edfb1ad342b9427d1d3bfb) )
50895037
50905038   ROM_REGION( 0x50, "picreturn", ROMREGION_ERASE)
5039   //ROM_LOAD("317-5121-jpn.data", 0x00, 0x50, CRC(a417b20f) SHA1(af6ed7ebf95948bff3e8df915b229189b8de1e46) )
5040
5041   ROM_REGION( 0x4000, "pic", ROMREGION_ERASEFF)
50915042   //PIC16C622A (317-5121-JPN)
50925043   //(sticker 253-5509-5121J)
5093   ROM_LOAD("317-5121-jpn.data", 0x00, 0x50, CRC(a417b20f) SHA1(af6ed7ebf95948bff3e8df915b229189b8de1e46) )
5044   ROM_LOAD("317-5121-jpn.pic", 0x00, 0x4000, CRC(cdb9b179) SHA1(8f7d1e9a99ad90344449c6ebb623e2968f611ec0) )
50945045ROM_END
50955046
50965047
r7500r7501
51055056
51065057
51075058   ROM_REGION( 0x50, "picreturn", ROMREGION_ERASE)
5059   //ROM_LOAD("317-5122-jpn.data", 0x00, 0x50, CRC(0b85b7e4) SHA1(f4e419682ddc4b98a330e5ae543f9276c9bde030) )
5060
5061   ROM_REGION( 0x4000, "pic", ROMREGION_ERASEFF)
51085062   //PIC16C622A (317-5122-JPN)
51095063   //(sticker 253-5509-5122J)
5110   ROM_LOAD("317-5122-jpn.data", 0x00, 0x50, CRC(0b85b7e4) SHA1(f4e419682ddc4b98a330e5ae543f9276c9bde030) )
5064   ROM_LOAD("317-5122-jpn.pic", 0x00, 0x4000, CRC(88983220) SHA1(410ee292794c44d2249778c8b6adda023286eb04) )
51115065ROM_END
51125066
51135067
r7500r7501
51215075   DISK_IMAGE_READONLY( "gdl-0040", 0, SHA1(a62c8d4b6c5be44a4aeeea1a1a94f3d0fe542593) )
51225076
51235077   ROM_REGION( 0x50, "picreturn", ROMREGION_ERASE)
5078   //ROM_LOAD("317-5125-com.data", 0x00, 0x50, CRC(9d37b5e3) SHA1(e1d3cdc2ed82c864c9ff54d9399a80b70ba150c5) )
5079
5080   ROM_REGION( 0x4000, "pic", ROMREGION_ERASEFF)
51245081   //PIC16C621A (317-5125-COM)
51255082   //(sticker 253-5509-5125)
5126   ROM_LOAD("317-5125-com.data", 0x00, 0x50, CRC(9d37b5e3) SHA1(e1d3cdc2ed82c864c9ff54d9399a80b70ba150c5) )
5083   ROM_LOAD("317-5125-com.pic", 0x00, 0x4000, CRC(918efc4f) SHA1(e32502b8df0b432eebaf0286176dd3bcd3f65dbb) )
51275084ROM_END
51285085
51295086
r7500r7501
51375094   DISK_IMAGE_READONLY( "gdl-0042", 0, SHA1(984a4fa012d83dd8c748304958c847c9867f4125) )
51385095
51395096   ROM_REGION( 0x50, "picreturn", ROMREGION_ERASE)
5097   //ROM_LOAD("317-5127-jpn.data", 0x00, 0x50, CRC(e1a6dbe4) SHA1(61b458937acca55e4010f86b684aaa86b8c10eac) )
5098
5099   ROM_REGION( 0x4000, "pic", ROMREGION_ERASEFF)
51405100   //PIC16C621A (317-5127-JPN)
51415101   //(sticker 253-5509-5127J)
5142   ROM_LOAD("317-5127-jpn.data", 0x00, 0x50, CRC(e1a6dbe4) SHA1(61b458937acca55e4010f86b684aaa86b8c10eac) )
5102   ROM_LOAD("317-5127-jpn.pic", 0x00, 0x4000, CRC(870c55eb) SHA1(cd8861726047250882c73a5f0c2480f45c30f21b) )
51435103ROM_END
51445104
51455105/* -------------------------------- 1st party -------------- */
r7500r7501
51765136   DISK_IMAGE_READONLY( "gds-0001", 0, SHA1(bd05f197ba8643577883dd25d9d5a74c91b27ca9) )
51775137
51785138   ROM_REGION( 0x50, "picreturn", ROMREGION_ERASE)
5179   ROM_LOAD("317-0298-com.data", 0x00, 0x50, CRC(c989b336) SHA1(40075500888626cc2261133eec496b3e753631e5) )
5139   //ROM_LOAD("317-0298-com.data", 0x00, 0x50, CRC(c989b336) SHA1(40075500888626cc2261133eec496b3e753631e5) )
5140
5141   ROM_REGION( 0x4000, "pic", ROMREGION_ERASEFF)
5142   ROM_LOAD("317-0298-com.pic", 0x00, 0x4000, CRC(15971bf6) SHA1(815152ab05edb1789a26898cfd66b5a7c4a1f765) )
51805143ROM_END
51815144
51825145
r7500r7501
51925155   ROM_REGION( 0x50, "picreturn", ROMREGION_ERASE)
51935156   //PIC16C622A (317-0300-COM)
51945157   //(sticker 253-5508-0300)
5195   ROM_LOAD("317-0300-com.data", 0x00, 0x50, CRC(9a08413f) SHA1(d57649dcc3af578d55a93dd7a3f41da62d580f54) )
5158   //ROM_LOAD("317-0300-com.data", 0x00, 0x50, CRC(9a08413f) SHA1(d57649dcc3af578d55a93dd7a3f41da62d580f54) )
5159
5160   ROM_REGION( 0x4000, "pic", ROMREGION_ERASEFF)
5161   ROM_LOAD("317-0300-com.pic", 0x00, 0x4000, CRC(19a97214) SHA1(bcee1af2c16daabc7a0f723e1f9281a7c95600c6) )
51965162ROM_END
51975163
51985164
r7500r7501
52065172   DISK_IMAGE_READONLY( "gds-0004", 0, SHA1(3cce788393ed194ba9b603f9896ff893691d6b00) )
52075173
52085174   ROM_REGION( 0x50, "picreturn", ROMREGION_ERASE)
5175   //ROM_LOAD("317-0302-com.data", 0x00, 0x50, CRC(4bf6cd62) SHA1(c1fdf12a4d80fa3008170c89d2dc583f19e0450b) )
5176
5177   ROM_REGION( 0x4000, "pic", ROMREGION_ERASEFF)
52095178   //PIC16C622A (317-0302-COM)
52105179   //(sticker 253-5508-0302)
5211   ROM_LOAD("317-0302-com.data", 0x00, 0x50, CRC(4bf6cd62) SHA1(c1fdf12a4d80fa3008170c89d2dc583f19e0450b) )
5180   ROM_LOAD("317-0302-com.pic", 0x00, 0x4000, CRC(fa290329) SHA1(76c7266a124b23eaa5747f870cd2cfe881dd23af) )
52125181ROM_END
52135182
52145183
r7500r7501
52225191   DISK_IMAGE_READONLY( "gds-0005", 0, SHA1(d1c3fb2350e4a89372373e7f629c42b741af29b3) )
52235192
52245193   ROM_REGION( 0x50, "picreturn", ROMREGION_ERASE)
5194   //ROM_LOAD("317-0303-com.data", 0x00, 0x50, CRC(6e7888a3) SHA1(5ca78052bcfd9e9f81934cbddd9c173e88973e0e) )
5195
5196   ROM_REGION( 0x4000, "pic", ROMREGION_ERASEFF)
52255197   //PIC16C622A (317-0303-COM)
52265198   //(sticker 253-5508-0303)
5227   ROM_LOAD("317-0303-com.data", 0x00, 0x50, CRC(6e7888a3) SHA1(5ca78052bcfd9e9f81934cbddd9c173e88973e0e) )
5199   ROM_LOAD("317-0303-com.pic", 0x00, 0x4000, CRC(b42999dd) SHA1(f285bdf34904517e119bd170b4ed0624eefac7bd) )
52285200ROM_END
52295201
52305202/*
r7500r7501
52595231   DISK_IMAGE_READONLY( "gds-0008", 0, SHA1(2fadcd141bdbde77b2b335b270959a516af44d99) )
52605232
52615233   ROM_REGION( 0x50, "picreturn", ROMREGION_ERASE)
5262   ROM_LOAD("317-0307-com.data", 0x00, 0x50, CRC(448bedc7) SHA1(092dbe5e28890d3ee40d62ca8cbf225c3ce90304) )
5234   //ROM_LOAD("317-0307-com.data", 0x00, 0x50, CRC(448bedc7) SHA1(092dbe5e28890d3ee40d62ca8cbf225c3ce90304) )
5235
5236   ROM_REGION( 0x4000, "pic", ROMREGION_ERASEFF)
5237   ROM_LOAD("317-0307-com.pic", 0x00, 0x4000, CRC(4046de19) SHA1(8adda9f223e926148b36744bbbaa89557544a229) )
52635238ROM_END
52645239
52655240/*
r7500r7501
52955270   NAOMIGD_BIOS
52965271   NAOMI_DEFAULT_EEPROM
52975272
5273   ROM_REGION( 0x10000, "io_board", 0)
5274   ROM_LOAD("epr-22084.ic3", 0x0000, 0x10000, CRC(18cf58bb) SHA1(1494f8215231929e41bbe2a133658d01882fbb0f) )
5275
52985276   ROM_REGION( 0x10000000, "user1", ROMREGION_ERASE) // allocate max size in init instead?
52995277
53005278   DISK_REGION( "gdrom" )
53015279   DISK_IMAGE_READONLY( "gds-0009", 0, SHA1(d502155ddaf881c2c9505528004b9904aa32a59c) )
53025280
53035281   ROM_REGION( 0x50, "picreturn", ROMREGION_ERASE)
5282   //ROM_LOAD("317-0308-com.data", 0x00, 0x50,  CRC(56f63af0) SHA1(3c453226fc53d2f700b3634db3ef8ce206d94392) )
5283
5284   ROM_REGION( 0x4000, "pic", ROMREGION_ERASEFF)
53045285   //PIC16C622A (317-0308-COM)
53055286   //(sticker 253-5508-0308)
5306   ROM_LOAD("317-0308-com.data", 0x00, 0x50,  CRC(56f63af0) SHA1(3c453226fc53d2f700b3634db3ef8ce206d94392) )
5307
5308   ROM_REGION( 0x10000, "io_board", 0)
5309   ROM_LOAD("epr-22084.ic3", 0x0000, 0x10000, CRC(18cf58bb) SHA1(1494f8215231929e41bbe2a133658d01882fbb0f) )
5287   ROM_LOAD("317-0308-com.pic", 0x00, 0x4000, CRC(5e1ef2c4) SHA1(57fa3efbb24f8b54e62fe0a2133d863cc7638f53) )
53105288ROM_END
53115289
53125290
r7500r7501
53205298   DISK_IMAGE_READONLY( "gds-0010", 0,  SHA1(c3135ede3a8bdadab91aed49abacbfbde8037069) )
53215299
53225300   ROM_REGION( 0x50, "picreturn", ROMREGION_ERASE)
5301   //ROM_LOAD("317-0309-com.data", 0x00, 0x50, CRC(8792c550) SHA1(e8d6d91583d1673d8d3fa9ccb0ab1097c5c5ad08) )
5302
5303   ROM_REGION( 0x4000, "pic", ROMREGION_ERASEFF)
53235304   //PIC16C622A (317-0309-COM)
53245305   //(sticker 253-5508-0309)
5325   ROM_LOAD("317-0309-com.data", 0x00, 0x50, CRC(8792c550) SHA1(e8d6d91583d1673d8d3fa9ccb0ab1097c5c5ad08) )
5306   ROM_LOAD("317-0309-com.pic", 0x00, 0x4000, CRC(62d760bf) SHA1(9cf247a63250ce1770ec18e76e1637b2e4e442d9) )
53265307ROM_END
53275308
53285309
r7500r7501
53365317   DISK_IMAGE_READONLY( "gds-0011", 0,  SHA1(b778403d73c8cdd13383691c9be2094ddfc1ba84) )
53375318
53385319   ROM_REGION( 0x50, "picreturn", ROMREGION_ERASE)
5320   //ROM_LOAD("317-0312-com.data", 0x00, 0x50, CRC(6b24f78f) SHA1(43f89815ec46cf014d941b4b9238da044b338b4c) )
5321
5322   ROM_REGION( 0x4000, "pic", ROMREGION_ERASEFF)
53395323   //PIC16C621A (317-0312-COM)
53405324   //(sticker 253-5508-0312)
5341   ROM_LOAD("317-0312-com.data", 0x00, 0x50, CRC(6b24f78f) SHA1(43f89815ec46cf014d941b4b9238da044b338b4c) )
5325   ROM_LOAD("317-0312-com.pic", 0x00, 0x4000, CRC(7213684e) SHA1(0b1adb2f6b7576534096832752cf7606a52c166e) )
53425326ROM_END
53435327
53445328ROM_START( keyboard )
r7500r7501
53515335   DISK_IMAGE_READONLY( "gds-0017", 0, SHA1(fb86eff3ef38de7fd78cfde897d5332d2092c172) )
53525336
53535337   ROM_REGION( 0x50, "picreturn", ROMREGION_ERASE)
5354   ROM_LOAD("317-0323-com.data", 0x00, 0x50, CRC(c1277eb3) SHA1(529ed5a133550e2854f8656cd377706060a7befa) )
5338   //ROM_LOAD("317-0323-com.data", 0x00, 0x50, CRC(c1277eb3) SHA1(529ed5a133550e2854f8656cd377706060a7befa) )
5339
5340   ROM_REGION( 0x4000, "pic", ROMREGION_ERASEFF)
5341   ROM_LOAD("317-0323-com.pic", 0x00, 0x4000, CRC(c8854ef2) SHA1(b43b956df142fe4167dcc2ec805921e25bba180f) )
5342
53555343ROM_END
53565344
53575345
r7500r7501
53655353   DISK_IMAGE_READONLY( "gds-0019", 0, SHA1(955d3c0cb991be3057138c562cff69c5ef887787) )
53665354
53675355   ROM_REGION( 0x50, "picreturn", ROMREGION_ERASE)
5356   //ROM_LOAD("317-0330-com.data", 0x00, 0x50, CRC(f5e7f7d4) SHA1(3903337e82011d132993e4366475586866bd39b1) )
5357
5358   ROM_REGION( 0x4000, "pic", ROMREGION_ERASEFF)
53685359   //PIC16C622A (317-0330-COM)
53695360   //(sticker 253-5508-0330)
5370   ROM_LOAD("317-0330-com.data", 0x00, 0x50, CRC(f5e7f7d4) SHA1(3903337e82011d132993e4366475586866bd39b1) )
5361   ROM_LOAD("317-0330-com.pic", 0x00, 0x4000, CRC(33ccf2d1) SHA1(669d459fcbb327d2fcf34777d7a731979477fb02) )
53715362ROM_END
53725363
53735364/*
r7500r7501
54045395   DISK_IMAGE_READONLY( "gds-0015a", 0, SHA1(c6e9c9901bd4f075454b7f18baf08df81bc2f1ad) )
54055396
54065397   ROM_REGION( 0x50, "picreturn", ROMREGION_ERASE)
5407   ROM_LOAD("317-0318-exp.data", 0x00, 0x50, CRC(7758ade6) SHA1(c62f35810bce466bfb0f55fd555066efd53e9bb6) )
5398   //ROM_LOAD("317-0318-exp.data", 0x00, 0x50, CRC(7758ade6) SHA1(c62f35810bce466bfb0f55fd555066efd53e9bb6) )
5399
5400   ROM_REGION( 0x4000, "pic", ROMREGION_ERASEFF)
5401   ROM_LOAD("317-0318-exp.pic", 0x00, 0x4000, CRC(83de4047) SHA1(1808ac0d8353b92296de37f98b490a42a0e141cf) )
5402
54085403ROM_END
54095404
54105405
r7500r7501
54185413   DISK_IMAGE_READONLY( "gds-0018", 0, SHA1(0633a99a666f363ab30450a76b9753685d6b1f57) )
54195414
54205415   ROM_REGION( 0x50, "picreturn", ROMREGION_ERASE)
5421   ROM_LOAD("317-0332-j.data", 0x00, 0x50, CRC(31f2b632) SHA1(bbf253bfe831308a7e7fde3a4a28e5bcd2fbb273) )
5416   //ROM_LOAD("317-0332-j.data", 0x00, 0x50, CRC(31f2b632) SHA1(bbf253bfe831308a7e7fde3a4a28e5bcd2fbb273) )
5417
5418   ROM_REGION( 0x4000, "pic", ROMREGION_ERASEFF)
5419   ROM_LOAD("317-0332-j.pic", 0x00, 0x4000, CRC(f71cb2fc) SHA1(281b3b3b03edf9a39e380976de528b7c9674de53) )
54225420ROM_END
54235421
54245422
r7500r7501
54325430   DISK_IMAGE_READONLY( "gds-0021a", 0,  SHA1(15c6f9434494a31693cbb8e33da36e0e8a8f7c62) )
54335431
54345432   ROM_REGION( 0x50, "picreturn", ROMREGION_ERASE)
5433   //ROM_LOAD("317-0332-jpn.data", 0x00, 0x50, CRC(ab302661) SHA1(65164cf76d78b281772bfcbf5a733b0200e86e09) )
5434
5435   ROM_REGION( 0x4000, "pic", ROMREGION_ERASEFF)
54355436   //PIC16C622A (317-0332-JPN)
54365437   //(sticker 253-5508-0332J)
5437   ROM_LOAD("317-0332-jpn.data", 0x00, 0x50, CRC(ab302661) SHA1(65164cf76d78b281772bfcbf5a733b0200e86e09) )
5438   ROM_LOAD("317-0332-jpn.pic", 0x00, 0x4000, CRC(43e78ecf) SHA1(bbe4b036e965fbba6ab79c88cba4ea8f0ea3f9fc) )
5439
54385440ROM_END
54395441
54405442/*
r7500r7501
54695471   DISK_IMAGE_READONLY( "gds-0022", 0, SHA1(70b41745225006e7876176cbd239edecd4c3f8b6) )
54705472
54715473   ROM_REGION( 0x50, "picreturn", ROMREGION_ERASE)
5472   ROM_LOAD("317-0333-com.data", 0x00, 0x50, CRC(0c07970f) SHA1(8882dd2f8ed522790ea78eed80cfa9442f88f67b) )
5474   //ROM_LOAD("317-0333-com.data", 0x00, 0x50, CRC(0c07970f) SHA1(8882dd2f8ed522790ea78eed80cfa9442f88f67b) )
5475
5476   ROM_REGION( 0x4000, "pic", ROMREGION_ERASEFF)
5477   ROM_LOAD("317-0333-com.pic", 0x00, 0x4000, CRC(15fb7792) SHA1(03932ba9b1738d5ab75b2a465cc3254e75f59f63) )
5478
54735479ROM_END
54745480
54755481
r7500r7501
54825488   DISK_REGION( "gdrom" )
54835489   DISK_IMAGE_READONLY( "gds-0023a", 0, SHA1(cd9d808b59eb8f40673ec4353d476f2b9c7f783c) )
54845490
5485   ROM_REGION( 0x50, "picreturn", ROMREGION_ERASE) // uses the vf4 pic
5491   ROM_REGION( 0x50, "picreturn", ROMREGION_ERASE)
5492   //ROM_LOAD("317-0314-com.data", 0x00, 0x50, CRC(91a97eb4) SHA1(059342368bc5d25b494ed3c729870695f9584fc7) )
5493
5494   ROM_REGION( 0x4000, "pic", ROMREGION_ERASEFF) // uses the vf4 pic
54865495   //PIC16C622A (317-0314-COM)
54875496   //(sticker 253-5508-0314)
5488   ROM_LOAD("317-0314-com.data", 0x00, 0x50, CRC(91a97eb4) SHA1(059342368bc5d25b494ed3c729870695f9584fc7) )
5497   ROM_LOAD("317-0314-com.pic", 0x00, 0x4000,  CRC(fa0b6c70) SHA1(c29936cb18e1dd592563b1104281f031e3b12fc2) )
5498
54895499ROM_END
54905500
54915501ROM_START( ngdup23c )
r7500r7501
54975507   DISK_REGION( "gdrom" )
54985508   DISK_IMAGE_READONLY( "gds-0023c", 0, SHA1(1fcb5530748886f4c4f45487d047859182ff7496))
54995509
5500   ROM_REGION( 0x50, "picreturn", ROMREGION_ERASE) // uses the vf4 evolution pic
5510   ROM_REGION( 0x50, "picreturn", ROMREGION_ERASE)
5511   //ROM_LOAD("317-0338-jpn.data", 0x00, 0x50, CRC(eeb2c9e9) SHA1(d30b5914c603219daea9923e1cf8da2be6096742) )
5512
5513   ROM_REGION( 0x4000, "pic", ROMREGION_ERASEFF) // uses the vf4 evolution pic
55015514   //PIC16C622A (317-0338-JPN)
55025515   //(sticker 253-5508-0338J)
5503   ROM_LOAD("317-0338-jpn.data", 0x00, 0x50, CRC(eeb2c9e9) SHA1(d30b5914c603219daea9923e1cf8da2be6096742) )
5516   ROM_LOAD("317-0338-jpn.pic", 0x00, 0x4000, CRC(b177ba7d) SHA1(f751ec43a8e944a01eeda58c01b7bc73e5df749d) )
55045517ROM_END
55055518
55065519
r7500r7501
55145527   DISK_IMAGE_READONLY( "gds-0031", 0, SHA1(da2d421da9472b149619b6931bb2fe624be75fa2) )
55155528
55165529   ROM_REGION( 0x50, "picreturn", ROMREGION_ERASE)
5530   //ROM_LOAD("317-0375-com.data", 0x00, 0x50, CRC(32bf1825) SHA1(42dfbc6777c154d8de6c6f7350da9ea737380220) )
5531
5532   ROM_REGION( 0x4000, "pic", ROMREGION_ERASEFF)
55175533   //PIC16C621A (317-0375-COM)
55185534   //(sticker 253-5508-0375)
5519   ROM_LOAD("317-0375-com.data", 0x00, 0x50, CRC(32bf1825) SHA1(42dfbc6777c154d8de6c6f7350da9ea737380220) )
5535   ROM_LOAD("317-0375-com.pic", 0x00, 0x4000, CRC(52b56b52) SHA1(221590efbb09824621714cb163bda51a921d7d54) )
55205536ROM_END
55215537
55225538
r7500r7501
55435559//GDL-0015 Mazan
55445560//GDL-0016 Yonin Uchi Mahjong MJ
55455561GAME( 2002, quizqgd,   naomigd,  naomigd,  naomi,    naomi,   ROT270, "Amedio (Taito license)", "Quiz Keitai Q mode (GDL-0017)", GAME_IMPERFECT_GRAPHICS|GAME_IMPERFECT_SOUND|GAME_NOT_WORKING )
5546//GDL-0018 Azumanga Daioh Puzzle Bobble
5562GAME( 2002, azumanga,  naomigd,  naomigd,  naomi,    naomi,   ROT0,   "Moss (Taito license)",   "Azumanga Daioh Puzzle Bobble (GDL-0018)", GAME_IMPERFECT_GRAPHICS|GAME_IMPERFECT_SOUND|GAME_NOT_WORKING )
55475563//GDL-0019 Guilty Gear XX #Reload
55485564GAME( 2003, ggxxrl,    naomigd,  naomigd,  naomi,    ggxxrl,  ROT0,   "Arc System Works",       "Guilty Gear XX #Reload (Rev A) (GDL-0019A)", GAME_IMPERFECT_GRAPHICS|GAME_IMPERFECT_SOUND|GAME_NOT_WORKING )
55495565GAME( 2004, tetkiwam,  naomigd,  naomigd,  naomi,    naomi,   ROT0,   "Success",                "Tetris Kiwamemichi (GDL-0020)", GAME_IMPERFECT_GRAPHICS|GAME_IMPERFECT_SOUND|GAME_NOT_WORKING )
r7500r7501
56995715ROM_END
57005716
57015717/*
5702    This is the same nonsense layout rom board as gram2000, and just like
5703    that it tests IC1 which doesn't exist - is it a mirror, or protection
5704    related?  There is no physical rom for it, also note, the roms are
5705    interleaved, so each test is testing 2 roms and the labeling / ic
5706    positions on the cart don't relate to the display in test mode.
5707
5708    Desired IC1 @ 0x800000 sums from the header = 9f39 fdc4
5709
5710    We need a USB dump of this from 0x800000 to 0x1000000.
5718    Tests IC1 like gram2000 if actel_id is 0xffff, see ROM_COPY
57115719*/
57125720ROM_START( vf4evoct )
57135721   NAOMI2_BIOS
r7500r7501
57355743        ROM_LOAD32_WORD( "mpr-23929.ic34s", 0x9000002, 0x800000, CRC(d768f242) SHA1(3ade29b094308d870ecac53cfe77b843d50af85a) )
57365744        ROM_LOAD32_WORD( "mpr-23930.ic35",  0xa000000, 0x800000, CRC(0e45e4c4) SHA1(974b83d4cc35e8ac9f83d04ebd395f1e2196e829) )
57375745        ROM_LOAD32_WORD( "mpr-23931.ic36s", 0xa000002, 0x800000, CRC(12ecd2f0) SHA1(3222d4d9d3e30c297a072a8888c28503306db40c) )
5746
5747   ROM_COPY( "user1", 0x1400000, 0x0800000, 0x0800000 ) // mirror data so IC1 check can pass
57385748ROM_END
57395749
57405750ROM_START( clubkrte )
r7500r7501
57725782   DISK_IMAGE_READONLY( "gds-0006", 0, SHA1(aca09a88506f5e462ad3fb33eac5478a2a010609) )
57735783
57745784   ROM_REGION( 0x50, "picreturn", ROMREGION_ERASE)
5785   //ROM_LOAD("317-0304-com.data", 0x00, 0x50, CRC(a181c601) SHA1(6a489904941e638ac1069b66e76ee0bcec7d0bab) )
5786
5787   ROM_REGION( 0x4000, "pic", ROMREGION_ERASEFF)
57755788   //PIC16C622A (317-0304-COM)
57765789   //(sticker 253-5508-0304)
5777   ROM_LOAD("317-0304-com.data", 0x00, 0x50, CRC(a181c601) SHA1(6a489904941e638ac1069b66e76ee0bcec7d0bab) )
5790   ROM_LOAD("317-0304-com.bin", 0x00, 0x4000, CRC(8e82d17a) SHA1(141a4d492b13bbb222dfbe7a1ad296b548d12a3b) )
57785791ROM_END
57795792
57805793ROM_START( vf4 )
r7500r7501
57875800   DISK_IMAGE_READONLY( "gds-0012", 0, SHA1(c34588f59c6091cd1c3ef235171dad8d5247e707) )
57885801
57895802   ROM_REGION( 0x50, "picreturn", ROMREGION_ERASE)
5803   //ROM_LOAD("317-0314-com.data", 0x00, 0x50, CRC(91a97eb4) SHA1(059342368bc5d25b494ed3c729870695f9584fc7) )
5804
5805   ROM_REGION( 0x4000, "pic", ROMREGION_ERASEFF)
57905806   //PIC16C622A (317-0314-COM)
57915807   //(sticker 253-5508-0314)
5792   ROM_LOAD("317-0314-com.data", 0x00, 0x50, CRC(91a97eb4) SHA1(059342368bc5d25b494ed3c729870695f9584fc7) )
5808   ROM_LOAD("317-0314-com.pic", 0x00, 0x4000, CRC(fa0b6c70) SHA1(c29936cb18e1dd592563b1104281f031e3b12fc2) )
5809
57935810ROM_END
57945811
57955812ROM_START( vf4b )
r7500r7501
58025819   DISK_IMAGE_READONLY( "gds-0012b", 0, SHA1(9b8e05c3d28a09323b13c198dfcc2b771bba67cd) )
58035820
58045821   ROM_REGION( 0x50, "picreturn", ROMREGION_ERASE)
5822   //ROM_LOAD("317-0314-com.data", 0x00, 0x50, CRC(91a97eb4) SHA1(059342368bc5d25b494ed3c729870695f9584fc7) )
5823
5824   ROM_REGION( 0x4000, "pic", ROMREGION_ERASEFF)
58055825   //PIC16C622A (317-0314-COM)
58065826   //(sticker 253-5508-0314)
5807   ROM_LOAD("317-0314-com.data", 0x00, 0x50, CRC(91a97eb4) SHA1(059342368bc5d25b494ed3c729870695f9584fc7) )
5827   ROM_LOAD("317-0314-com.pic", 0x00, 0x4000, CRC(fa0b6c70) SHA1(c29936cb18e1dd592563b1104281f031e3b12fc2) )
5828
58085829ROM_END
58095830
58105831ROM_START( vf4c )
r7500r7501
58175838   DISK_IMAGE_READONLY( "gds-0012c", 0, SHA1(0ec149d7edfb326777cdc45a2ac8ad578a32aba1) )
58185839
58195840   ROM_REGION( 0x50, "picreturn", ROMREGION_ERASE)
5841   //ROM_LOAD("317-0314-com.data", 0x00, 0x50, CRC(91a97eb4) SHA1(059342368bc5d25b494ed3c729870695f9584fc7) )
5842
5843   ROM_REGION( 0x4000, "pic", ROMREGION_ERASEFF)
58205844   //PIC16C622A (317-0314-COM)
58215845   //(sticker 253-5508-0314)
5822   ROM_LOAD("317-0314-com.data", 0x00, 0x50, CRC(91a97eb4) SHA1(059342368bc5d25b494ed3c729870695f9584fc7) )
5846   ROM_LOAD("317-0314-com.pic", 0x00, 0x4000, CRC(fa0b6c70) SHA1(c29936cb18e1dd592563b1104281f031e3b12fc2) )
5847
58235848ROM_END
58245849
58255850
r7500r7501
58335858   DISK_IMAGE_READONLY( "gds-0024b", 0, SHA1(a829169542f3bed76095ad6bfbbde7d494d04d72) )
58345859
58355860   ROM_REGION( 0x50, "picreturn", ROMREGION_ERASE)
5861   //ROM_LOAD("317-0338-jpn.data", 0x00, 0x50, CRC(eeb2c9e9) SHA1(d30b5914c603219daea9923e1cf8da2be6096742) )
5862
5863   ROM_REGION( 0x4000, "pic", ROMREGION_ERASEFF)
58365864   //PIC16C622A (317-0338-JPN)
58375865   //(sticker 253-5508-0338J)
5838   ROM_LOAD("317-0338-jpn.data", 0x00, 0x50, CRC(eeb2c9e9) SHA1(d30b5914c603219daea9923e1cf8da2be6096742) )
5866   ROM_LOAD("317-0338-jpn.pic", 0x00, 0x4000, CRC(b177ba7d) SHA1(f751ec43a8e944a01eeda58c01b7bc73e5df749d) )
5867
58395868ROM_END
58405869
58415870ROM_START( vf4evoa )
r7500r7501
58485877   DISK_IMAGE_READONLY( "gds-0024a", 0, SHA1(6225e778d73db18be26f882d4f9cd3b3a136d1c9) )
58495878
58505879   ROM_REGION( 0x50, "picreturn", ROMREGION_ERASE)
5880   //ROM_LOAD("317-0338-jpn.data", 0x00, 0x50, CRC(eeb2c9e9) SHA1(d30b5914c603219daea9923e1cf8da2be6096742) )
5881
5882   ROM_REGION( 0x4000, "pic", ROMREGION_ERASEFF)
58515883   //PIC16C622A (317-0338-JPN)
58525884   //(sticker 253-5508-0338J)
5853   ROM_LOAD("317-0338-jpn.data", 0x00, 0x50, CRC(eeb2c9e9) SHA1(d30b5914c603219daea9923e1cf8da2be6096742) )
5885   ROM_LOAD("317-0338-jpn.pic", 0x00, 0x4000, CRC(b177ba7d) SHA1(f751ec43a8e944a01eeda58c01b7bc73e5df749d) )
58545886ROM_END
58555887
58565888ROM_START( initdv2j )
r7500r7501
58765908   DISK_IMAGE_READONLY( "gds-0036f", 0, SHA1(ea35d6ecdf94e5c9a545952758da80f658755df0) )
58775909
58785910   ROM_REGION( 0x50, "picreturn", ROMREGION_ERASE)
5911   //ROM_LOAD("317-0387-com.data", 0x00, 0x50, CRC(ab9f3851) SHA1(8b64dc6df176eb7adb48267709a27db221d5e3c3) )
5912
5913   ROM_REGION( 0x4000, "pic", ROMREGION_ERASEFF)
58795914   //PIC16C622A (317-0387-COM)
58805915   //(sticker 253-5508-0387)
5881   ROM_LOAD("317-0387-com.data", 0x00, 0x50, CRC(ab9f3851) SHA1(8b64dc6df176eb7adb48267709a27db221d5e3c3) )
5916   ROM_LOAD("317-0387-com.pic", 0x00, 0x4000, CRC(8728aeaa) SHA1(07983ab41d143f845c3150dfc9b7301968708e18) )
58825917ROM_END
58835918
58845919ROM_START( vf4tunedd )
r7500r7501
58915926   DISK_IMAGE_READONLY( "gds-0036d", 0, SHA1(2f7654307a4c978c5af6c8238c44e70275dd34f9) )
58925927
58935928   ROM_REGION( 0x50, "picreturn", ROMREGION_ERASE)
5929   //ROM_LOAD("317-0387-com.data", 0x00, 0x50, CRC(ab9f3851) SHA1(8b64dc6df176eb7adb48267709a27db221d5e3c3) )
5930
5931   ROM_REGION( 0x4000, "pic", ROMREGION_ERASEFF)
58945932   //PIC16C622A (317-0387-COM)
58955933   //(sticker 253-5508-0387)
5896   ROM_LOAD("317-0387-com.data", 0x00, 0x50, CRC(ab9f3851) SHA1(8b64dc6df176eb7adb48267709a27db221d5e3c3) )
5934   ROM_LOAD("317-0387-com.pic", 0x00, 0x4000, CRC(8728aeaa) SHA1(07983ab41d143f845c3150dfc9b7301968708e18) )
5935
58975936ROM_END
58985937
58995938
r7500r7501
59075946   DISK_IMAGE_READONLY( "gds-0036a", 0, SHA1(cd630fc4e8f7ed5641b85c609584d7efe0eac137) )
59085947
59095948   ROM_REGION( 0x50, "picreturn", ROMREGION_ERASE)
5949   //ROM_LOAD("317-0387-com.data", 0x00, 0x50, CRC(ab9f3851) SHA1(8b64dc6df176eb7adb48267709a27db221d5e3c3) )
5950
5951   ROM_REGION( 0x4000, "pic", ROMREGION_ERASEFF)
59105952   //PIC16C622A (317-0387-COM)
59115953   //(sticker 253-5508-0387)
5912   ROM_LOAD("317-0387-com.data", 0x00, 0x50, CRC(ab9f3851) SHA1(8b64dc6df176eb7adb48267709a27db221d5e3c3) )
5954   ROM_LOAD("317-0387-com.pic", 0x00, 0x4000, CRC(8728aeaa) SHA1(07983ab41d143f845c3150dfc9b7301968708e18) )
59135955ROM_END
59145956
59155957
r7500r7501
59505992   ROM_REGION( 0x50, "picreturn", ROMREGION_ERASE)
59515993   //PIC16C622A (317-0317-COM)
59525994   //(sticker 253-5508-0317)
5953   ROM_LOAD("317-0317-com.data", 0x00, 0x50, CRC(66efe433) SHA1(7f7b52202ed9b1e20516aaa7553cc3cc677a70b5) )
5995   //ROM_LOAD("317-0317-com.data", 0x00, 0x50, CRC(66efe433) SHA1(7f7b52202ed9b1e20516aaa7553cc3cc677a70b5) )
5996
5997   ROM_REGION( 0x4000, "pic", ROMREGION_ERASEFF)
5998   ROM_LOAD("317-0317-com.pic", 0x00, 0x4000, CRC(ef65fe73) SHA1(2c02d1570c1fdad56bc684c60bb17255c73c6d45) )
5999
59546000ROM_END
59556001
59566002ROM_START( initd )
r7500r7501
59636009   DISK_REGION( "gdrom" )
59646010   DISK_IMAGE_READONLY( "gds-0020b", 0, SHA1(c0e901623ef4fcd97b7e4d29ae556e6f2e91b8ad) )
59656011
5966   ROM_REGION( 0x50, "picreturn", ROMREGION_ERASE)
6012   ROM_REGION( 0x50, "picreturn", ROMREGION_ERASE) // custom format containing data returned from pic
6013   //ROM_LOAD("317-0331-jpn.data", 0x00, 0x50, CRC(bb39742e) SHA1(b3100b18aeb80ebfd5312ba5c320e7e647710b55) )
6014
6015   //ROM_REGION( 0x9a49, "pichex", ROMREGION_ERASE) // actual pic dump (in hex/ascii mode) from decap
6016   //ROM_LOAD("gds-0020b.hex", 0x00, 0x0009a49, CRC(80d9fe04) SHA1(7a6fe325ce2e12e9270205d32f549aaf66505de5) )
6017
6018   ROM_REGION( 0x4000, "pic", ROMREGION_ERASEFF)
59676019   //PIC16C622A (317-0331-JPN)
59686020   //(sticker 253-5508-0331J)
5969   ROM_LOAD("317-0331-jpn.data", 0x00, 0x50, CRC(bb39742e) SHA1(b3100b18aeb80ebfd5312ba5c320e7e647710b55) )
6021   ROM_LOAD("317-0331-jpn.pic", 0x00, 0x4000, CRC(0a3bf606) SHA1(7c0e22df4a43a440571ac55fd0a6575931e8f959) )
59706022ROM_END
59716023
59726024ROM_START( initdexp )
r7500r7501
59806032   DISK_IMAGE_READONLY( "gds-0025", 0, SHA1(8ea92cf6b493f21b9453832edad7cbc5e5b350c1) )
59816033
59826034   ROM_REGION( 0x50, "picreturn", ROMREGION_ERASE)
5983   ROM_LOAD("317-0343-com.data", 0x00, 0x50, CRC(e9d8fac0) SHA1(85f5bbffbd9d1f7162bae46ddd49e7870fe93662) )
6035   //ROM_LOAD("317-0343-com.data", 0x00, 0x50, CRC(e9d8fac0) SHA1(85f5bbffbd9d1f7162bae46ddd49e7870fe93662) )
6036
6037   ROM_REGION( 0x4000, "pic", ROMREGION_ERASEFF)
6038   ROM_LOAD("317-0343-com.pic", 0x00, 0x4000, CRC(80eea4eb) SHA1(5aedc0d52a2a8a2d186ca591094835d972574092) )
59846039ROM_END
59856040
59866041ROM_START( initdv3j )
r7500r7501
60096064GAME( 2002, clubkrte, naomi2,  naomi,    naomi,    0,  ROT0,  "Sega",          "Club Kart: European Session", GAME_UNEMULATED_PROTECTION|GAME_IMPERFECT_GRAPHICS|GAME_IMPERFECT_SOUND|GAME_NOT_WORKING )
60106065
60116066/* GDS-xxxx (Sega first party games) */
6012GAME( 2001, vstrik3, naomi2,  naomigd,    naomi,    0,  ROT0, "Sega",          "Virtua Striker 3 (GDS-0006)", GAME_IMPERFECT_GRAPHICS|GAME_IMPERFECT_SOUND|GAME_NOT_WORKING )
6013GAME( 2001, vf4,     naomi2,  naomigd,    naomi,    0,  ROT0, "Sega",          "Virtua Fighter 4 (GDS-0012)", GAME_IMPERFECT_GRAPHICS|GAME_IMPERFECT_SOUND|GAME_NOT_WORKING )
6014GAME( 2001, vf4b,    vf4,     naomigd,    naomi,    0,  ROT0, "Sega",          "Virtua Fighter 4 (Rev B) (GDS-0012B)", GAME_IMPERFECT_GRAPHICS|GAME_IMPERFECT_SOUND|GAME_NOT_WORKING )
6015GAME( 2001, vf4c,    vf4,     naomigd,    naomi,    0,  ROT0, "Sega",          "Virtua Fighter 4 (Rev C) (GDS-0012C)", GAME_IMPERFECT_GRAPHICS|GAME_IMPERFECT_SOUND|GAME_NOT_WORKING )
6016GAME( 2002, initd,   naomi2,  naomigd,    naomi,    0,  ROT0, "Sega",          "Initial D Arcade Stage (Rev B) (Japan) (GDS-0020B)", GAME_IMPERFECT_GRAPHICS|GAME_IMPERFECT_SOUND|GAME_NOT_WORKING )
6017GAME( 2002, beachspi,naomi2,  naomigd,    naomi,    0,  ROT0, "Sega",          "Beach Spikers (GDS-0014)", GAME_IMPERFECT_GRAPHICS|GAME_IMPERFECT_SOUND|GAME_NOT_WORKING )
6018GAME( 2002, initdexp,naomi2,  naomigd,    naomi,    0,  ROT0, "Sega",          "Initial D Arcade Stage (Export) (GDS-0025)", GAME_IMPERFECT_GRAPHICS|GAME_IMPERFECT_SOUND|GAME_NOT_WORKING )
6019GAME( 2002, vf4evo,  naomi2,  naomigd,    naomi,    0,  ROT0, "Sega",          "Virtua Fighter 4 Evolution (Rev B) (GDS-0024B)", GAME_IMPERFECT_GRAPHICS|GAME_IMPERFECT_SOUND|GAME_NOT_WORKING )
6020GAME( 2002, vf4evoa, vf4evo,  naomigd,    naomi,    0,  ROT0, "Sega",          "Virtua Fighter 4 Evolution (Rev A) (GDS-0024A)", GAME_IMPERFECT_GRAPHICS|GAME_IMPERFECT_SOUND|GAME_NOT_WORKING )
6021GAME( 2002, initdv2j,naomi2,  naomigd,    naomi,    0,  ROT0, "Sega",          "Initial D : Arcade Stage Ver. 2 (Japan) (GDS-0026)", GAME_IMPERFECT_GRAPHICS|GAME_IMPERFECT_SOUND|GAME_NOT_WORKING )
6022GAME( 2004, initdv3j,naomi2,  naomigd,    naomi,    0,  ROT0, "Sega",          "Initial D : Arcade Stage Ver. 3 (Japan) (Rev B) (GDS-0032B)", GAME_IMPERFECT_GRAPHICS|GAME_IMPERFECT_SOUND|GAME_NOT_WORKING )
6023GAME( 2004, vf4tuned,naomi2,  naomigd,    naomi,    0,  ROT0, "Sega",          "Virtua Fighter 4 Final Tuned (Rev F) (GDS-0036F)", GAME_IMPERFECT_GRAPHICS|GAME_IMPERFECT_SOUND|GAME_NOT_WORKING )
6024GAME( 2004, vf4tunedd,vf4tuned,naomigd,   naomi,    0,  ROT0, "Sega",          "Virtua Fighter 4 Final Tuned (Rev D) (GDS-0036D)", GAME_IMPERFECT_GRAPHICS|GAME_IMPERFECT_SOUND|GAME_NOT_WORKING )
6025GAME( 2004, vf4tuneda,vf4tuned,naomigd,   naomi,    0,  ROT0, "Sega",          "Virtua Fighter 4 Final Tuned (Rev A) (GDS-0036A)", GAME_IMPERFECT_GRAPHICS|GAME_IMPERFECT_SOUND|GAME_NOT_WORKING )
6067GAME( 2001, vstrik3, naomi2,  naomigd,    naomi,    naomi2,  ROT0, "Sega",          "Virtua Striker 3 (GDS-0006)", GAME_IMPERFECT_GRAPHICS|GAME_IMPERFECT_SOUND|GAME_NOT_WORKING )
6068GAME( 2001, vf4,     naomi2,  naomigd,    naomi,    naomi2,  ROT0, "Sega",          "Virtua Fighter 4 (GDS-0012)", GAME_IMPERFECT_GRAPHICS|GAME_IMPERFECT_SOUND|GAME_NOT_WORKING )
6069GAME( 2001, vf4b,    vf4,     naomigd,    naomi,    naomi2,  ROT0, "Sega",          "Virtua Fighter 4 (Rev B) (GDS-0012B)", GAME_IMPERFECT_GRAPHICS|GAME_IMPERFECT_SOUND|GAME_NOT_WORKING )
6070GAME( 2001, vf4c,    vf4,     naomigd,    naomi,    naomi2,  ROT0, "Sega",          "Virtua Fighter 4 (Rev C) (GDS-0012C)", GAME_IMPERFECT_GRAPHICS|GAME_IMPERFECT_SOUND|GAME_NOT_WORKING )
6071GAME( 2002, initd,   naomi2,  naomigd,    naomi,    naomi2,  ROT0, "Sega",          "Initial D Arcade Stage (Rev B) (Japan) (GDS-0020B)", GAME_IMPERFECT_GRAPHICS|GAME_IMPERFECT_SOUND|GAME_NOT_WORKING )
6072GAME( 2002, beachspi,naomi2,  naomigd,    naomi,    naomi2,  ROT0, "Sega",          "Beach Spikers (GDS-0014)", GAME_IMPERFECT_GRAPHICS|GAME_IMPERFECT_SOUND|GAME_NOT_WORKING )
6073GAME( 2002, initdexp,naomi2,  naomigd,    naomi,    naomi2,  ROT0, "Sega",          "Initial D Arcade Stage (Export) (GDS-0025)", GAME_IMPERFECT_GRAPHICS|GAME_IMPERFECT_SOUND|GAME_NOT_WORKING )
6074GAME( 2002, vf4evo,  naomi2,  naomigd,    naomi,    naomi2,  ROT0, "Sega",          "Virtua Fighter 4 Evolution (Rev B) (GDS-0024B)", GAME_IMPERFECT_GRAPHICS|GAME_IMPERFECT_SOUND|GAME_NOT_WORKING )
6075GAME( 2002, vf4evoa, vf4evo,  naomigd,    naomi,    naomi2,  ROT0, "Sega",          "Virtua Fighter 4 Evolution (Rev A) (GDS-0024A)", GAME_IMPERFECT_GRAPHICS|GAME_IMPERFECT_SOUND|GAME_NOT_WORKING )
6076GAME( 2002, initdv2j,naomi2,  naomigd,    naomi,    naomi2,  ROT0, "Sega",          "Initial D : Arcade Stage Ver. 2 (Japan) (GDS-0026)", GAME_IMPERFECT_GRAPHICS|GAME_IMPERFECT_SOUND|GAME_NOT_WORKING )
6077GAME( 2004, initdv3j,naomi2,  naomigd,    naomi,    naomi2,  ROT0, "Sega",          "Initial D : Arcade Stage Ver. 3 (Japan) (Rev B) (GDS-0032B)", GAME_IMPERFECT_GRAPHICS|GAME_IMPERFECT_SOUND|GAME_NOT_WORKING )
6078GAME( 2004, vf4tuned,naomi2,  naomigd,    naomi,    naomi2,  ROT0, "Sega",          "Virtua Fighter 4 Final Tuned (Rev F) (GDS-0036F)", GAME_IMPERFECT_GRAPHICS|GAME_IMPERFECT_SOUND|GAME_NOT_WORKING )
6079GAME( 2004, vf4tunedd,vf4tuned,naomigd,   naomi,    naomi2,  ROT0, "Sega",          "Virtua Fighter 4 Final Tuned (Rev D) (GDS-0036D)", GAME_IMPERFECT_GRAPHICS|GAME_IMPERFECT_SOUND|GAME_NOT_WORKING )
6080GAME( 2004, vf4tuneda,vf4tuned,naomigd,   naomi,    naomi2,  ROT0, "Sega",          "Virtua Fighter 4 Final Tuned (Rev A) (GDS-0036A)", GAME_IMPERFECT_GRAPHICS|GAME_IMPERFECT_SOUND|GAME_NOT_WORKING )
60266081
60276082/**********************************************
60286083 *
src/mame/drivers/megatech.c
r7500r7501
12111211/* 52 */ GAME( 1991, mt_sonic, megatech, megatech, megatech, mtnew, ROT0, "Sega",                  "Sonic The Hedgehog (Mega-Tech, set 1)", GAME_NOT_WORKING )
12121212/*    */ GAME( 1991, mt_sonia, mt_sonic, megatech, megatech, mtnew, ROT0, "Sega",                  "Sonic The Hedgehog (Mega-Tech, set 2)", GAME_NOT_WORKING )
12131213/* 53 */ GAME( 1990, mt_fshrk, megatech, megatech, megatech, mtnew, ROT0, "Toaplan / Sega",        "Fire Shark (Mega-Tech)", GAME_NOT_WORKING )
1214/* 54 */ // unknown
1214/* 54 */ // Spider-Man
12151215/* 55 */ // unknown
12161216/* 56 */ // unknown
12171217/* 57 */ GAME( 1991, mt_gaxe2, megatech, megatech, megatech, mtnew, ROT0, "Sega",                  "Golden Axe II (Mega-Tech)", GAME_NOT_WORKING )
src/mame/drivers/vamphalf.c
r7500r7501
2222    Mr. Kicker                 (c) 2001 SemiCom
2323    Age Of Heroes - Silkroad 2 (c) 2001 Unico              (v0.63 - 2001/02/07)
2424
25Known games on simular hardware but not dumped:
26    Mr. Dig (c) 2000 Sun (Mr. Driller clone) on a F-E1-16-002 PCB
27
2528 Real games bugs:
2629 - dquizgo2: bugged video test
2730
r7500r7501
18081811GAME( 2000, dquizgo2, 0,        coolmini, common,   dquizgo2, ROT0,   "SemiCom",           "Date Quiz Go Go Episode 2" , 0)
18091812GAME( 2000, misncrft, 0,        misncrft, common,   misncrft, ROT90,  "Sun",               "Mission Craft (version 2.4)", GAME_NO_SOUND )
18101813GAME( 2001, finalgdr, 0,        finalgdr, finalgdr, finalgdr, ROT0,   "SemiCom",           "Final Godori (Korea, version 2.20.5915)", 0 )
1811GAME( 2001, mrkicker, 0,        finalgdr, finalgdr, mrkicker, ROT0,   "SemiCom",           "Mr. Kicker", 0 )
1814GAME( 2001, mrkicker, 0,        finalgdr, finalgdr, mrkicker, ROT0,   "SemiCom",           "Mr. Kicker", GAME_NOT_WORKING )
18121815GAME( 2001, wyvernwg, 0,        wyvernwg, common,   wyvernwg, ROT270, "SemiCom (Game Vision License)", "Wyvern Wings", GAME_NO_SOUND )
18131816GAME( 2001, aoh,      0,        aoh,      aoh,      aoh,      ROT0,   "Unico",             "Age Of Heroes - Silkroad 2 (v0.63 - 2001/02/07)", 0 )
src/mame/drivers/mayumi.c
r7500r7501
11/*****************************************************************************
22
3Kikiippatsu Mayumi-chan (c) 1988 Victory L.L.C.
3    Kikiippatsu Mayumi-chan (c) 1988 Victory L.L.C.
44
55    Driver by Uki
66
r7500r7501
1212
1313#define MCLK 10000000
1414
15extern UINT8 *mayumi_videoram;
16WRITE8_HANDLER( mayumi_videoram_w );
17VIDEO_START( mayumi );
18VIDEO_UPDATE( mayumi );
1915
20static int int_enable;
21static int input_sel;
16class mayumi_state
17{
18public:
19   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, mayumi_state(machine)); }
2220
23/****************************************************************************/
21   mayumi_state(running_machine &machine) { }
2422
23   /* memory pointers */
24   UINT8 *    videoram;
25//  UINT8 *    nvram;       // this currently uses generic nvram handlers
26
27   /* video-related */
28   tilemap_t *tilemap;
29
30   /* misc */
31   int int_enable;
32   int input_sel;
33};
34
35
36/*************************************
37 *
38 *  Video emulation
39 *
40 *************************************/
41
42static TILE_GET_INFO( get_tile_info )
43{
44   mayumi_state *state = (mayumi_state *)machine->driver_data;
45   int code = state->videoram[tile_index] + (state->videoram[tile_index + 0x800] & 0x1f) * 0x100;
46   int col = (state->videoram[tile_index + 0x1000] >> 3) & 0x1f;
47
48   SET_TILE_INFO(0, code, col, 0);
49}
50
51static VIDEO_START( mayumi )
52{
53   mayumi_state *state = (mayumi_state *)machine->driver_data;
54   state->tilemap = tilemap_create(machine, get_tile_info, tilemap_scan_rows, 8, 8, 64, 32);
55}
56
57static WRITE8_HANDLER( mayumi_videoram_w )
58{
59   mayumi_state *state = (mayumi_state *)space->machine->driver_data;
60   state->videoram[offset] = data;
61   tilemap_mark_tile_dirty(state->tilemap, offset & 0x7ff);
62}
63
64static VIDEO_UPDATE( mayumi )
65{
66   mayumi_state *state = (mayumi_state *)screen->machine->driver_data;
67   tilemap_draw(bitmap, cliprect, state->tilemap, 0, 0);
68   return 0;
69}
70
71/*************************************
72 *
73 *  Interrupt generator
74 *
75 *************************************/
76
2577static INTERRUPT_GEN( mayumi_interrupt )
2678{
27   if (int_enable)
79   mayumi_state *state = (mayumi_state *)device->machine->driver_data;
80
81   if (state->int_enable)
2882       cpu_set_input_line(device, 0, HOLD_LINE);
2983}
3084
85/*************************************
86 *
87 *  Memory handlers
88 *
89 *************************************/
90
3191static WRITE8_HANDLER( bank_sel_w )
3292{
33   UINT8 *BANKROM = memory_region(space->machine, "maincpu");
34   int bank = ((data & 0x80)) >> 7 | ((data & 0x40) >> 5);
35   memory_set_bankptr(space->machine, "bank1", &BANKROM[0x10000+bank*0x4000]);
93   mayumi_state *state = (mayumi_state *)space->machine->driver_data;
94   int bank = BIT(data, 7) | (BIT(data, 6) << 1);
3695
37   int_enable = data & 1;
96   memory_set_bank(space->machine, "bank1", bank);
3897
98   state->int_enable = data & 1;
99
39100   flip_screen_set(space->machine, data & 2);
40101}
41102
42static MACHINE_RESET( mayumi )
43{
44   const address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM);
45   bank_sel_w(space, 0, 0);
46}
47
48103static WRITE8_HANDLER( input_sel_w )
49104{
50   input_sel = data;
105   mayumi_state *state = (mayumi_state *)space->machine->driver_data;
106   state->input_sel = data;
51107}
52108
53109static READ8_HANDLER( key_matrix_r )
54110{
55   int p,i,ret;
111   mayumi_state *state = (mayumi_state *)space->machine->driver_data;
112   int p, i, ret;
56113   static const char *const keynames[2][5] =
57114         {
58115            { "KEY5", "KEY6", "KEY7", "KEY8", "KEY9" },
r7500r7501
61118
62119   ret = 0xff;
63120
64   p = ~input_sel & 0x1f;
121   p = ~state->input_sel & 0x1f;
65122
66   for (i=0; i<5; i++)
123   for (i = 0; i < 5; i++)
67124   {
68      if (p & (1 << i))
125      if (BIT(p, i))
69126         ret &= input_port_read(space->machine, keynames[offset][i]);
70127   }
71128
72129   return ret;
73130}
74131
75/****************************************************************************/
132/*************************************
133 *
134 *  Address maps
135 *
136 *************************************/
76137
77138static ADDRESS_MAP_START( mayumi_map, ADDRESS_SPACE_PROGRAM, 8 )
78139   AM_RANGE(0x0000, 0x7fff) AM_ROM
79140   AM_RANGE(0x8000, 0xbfff) AM_ROMBANK("bank1")
80141   AM_RANGE(0xc000, 0xdfff) AM_RAM AM_BASE_SIZE_GENERIC(nvram)
81   AM_RANGE(0xe000, 0xf7ff) AM_RAM_WRITE(mayumi_videoram_w) AM_BASE(&mayumi_videoram)
142   AM_RANGE(0xe000, 0xf7ff) AM_RAM_WRITE(mayumi_videoram_w) AM_BASE_MEMBER(mayumi_state, videoram)
82143ADDRESS_MAP_END
83144
84145
r7500r7501
91152   AM_RANGE(0xd0, 0xd1) AM_DEVREADWRITE("ymsnd", ym2203_r, ym2203_w)
92153ADDRESS_MAP_END
93154
94/****************************************************************************/
155/*************************************
156 *
157 *  Input ports
158 *
159 *************************************/
95160
96161static INPUT_PORTS_START( mayumi )
97
98    PORT_START("DSW1")  /* dsw1 */
162   PORT_START("DSW1")
99163   PORT_DIPNAME( 0x80, 0x80, DEF_STR( Flip_Screen ) )
100164   PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
101165   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
r7500r7501
120184   PORT_DIPSETTING(    0x01, DEF_STR( Off ) )
121185   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
122186
123   PORT_START("DSW2")  /* dsw2 */
187   PORT_START("DSW2")
124188   PORT_DIPNAME( 0x80, 0x80, "Unknown 2-1" )
125189   PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
126190   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
r7500r7501
146210   PORT_DIPSETTING(    0x01, DEF_STR( Off ) )
147211   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
148212
149   PORT_START("KEY0")   /* P1 IN0 (2) */
213   PORT_START("KEY0")
150214   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_MAHJONG_A )
151215   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_MAHJONG_E )
152216   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_MAHJONG_I )
r7500r7501
155219   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_START1 )
156220   PORT_BIT( 0xc0, IP_ACTIVE_LOW, IPT_UNUSED )
157221
158   PORT_START("KEY1")   /* P1 IN1 (3) */
222   PORT_START("KEY1")
159223   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_MAHJONG_B )
160224   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_MAHJONG_F )
161225   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_MAHJONG_J )
r7500r7501
164228   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNKNOWN )
165229   PORT_BIT( 0xc0, IP_ACTIVE_LOW, IPT_UNUSED )
166230
167   PORT_START("KEY2")   /* P1 IN2 (4) */
231   PORT_START("KEY2")
168232   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_MAHJONG_C )
169233   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_MAHJONG_G )
170234   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_MAHJONG_K )
r7500r7501
173237   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNKNOWN )
174238   PORT_BIT( 0xc0, IP_ACTIVE_LOW, IPT_UNUSED )
175239
176   PORT_START("KEY3")   /* P1 IN3 (5) */
240   PORT_START("KEY3")
177241   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_MAHJONG_D )
178242   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_MAHJONG_H )
179243   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_MAHJONG_L )
r7500r7501
182246   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNKNOWN )
183247   PORT_BIT( 0xc0, IP_ACTIVE_LOW, IPT_UNUSED )
184248
185   PORT_START("KEY4")   /* P1 IN4 (6) */
249   PORT_START("KEY4")
186250   PORT_BIT( 0x3f, IP_ACTIVE_LOW, IPT_UNKNOWN )
187251   PORT_BIT( 0xc0, IP_ACTIVE_LOW, IPT_UNUSED )
188252
189   PORT_START("KEY5")   /* P2 IN0 (7) */
253   PORT_START("KEY5")
190254   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_MAHJONG_A ) PORT_PLAYER(2)
191255   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_MAHJONG_E ) PORT_PLAYER(2)
192256   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_MAHJONG_I ) PORT_PLAYER(2)
r7500r7501
195259   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_START2 )
196260   PORT_BIT( 0xc0, IP_ACTIVE_LOW, IPT_UNUSED )
197261
198   PORT_START("KEY6")   /* P2 IN1 (8) */
262   PORT_START("KEY6")
199263   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_MAHJONG_B ) PORT_PLAYER(2)
200264   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_MAHJONG_F ) PORT_PLAYER(2)
201265   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_MAHJONG_J ) PORT_PLAYER(2)
r7500r7501
204268   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNKNOWN )
205269   PORT_BIT( 0xc0, IP_ACTIVE_LOW, IPT_UNUSED )
206270
207   PORT_START("KEY7")   /* P2 IN2 (9) */
271   PORT_START("KEY7")
208272   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_MAHJONG_C ) PORT_PLAYER(2)
209273   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_MAHJONG_G ) PORT_PLAYER(2)
210274   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_MAHJONG_K ) PORT_PLAYER(2)
r7500r7501
213277   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNKNOWN )
214278   PORT_BIT( 0xc0, IP_ACTIVE_LOW, IPT_UNUSED )
215279
216   PORT_START("KEY8")   /* P2 IN3 (10) */
280   PORT_START("KEY8")
217281   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_MAHJONG_D ) PORT_PLAYER(2)
218282   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_MAHJONG_H ) PORT_PLAYER(2)
219283   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_MAHJONG_L ) PORT_PLAYER(2)
r7500r7501
222286   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNKNOWN )
223287   PORT_BIT( 0xc0, IP_ACTIVE_LOW, IPT_UNUSED )
224288
225   PORT_START("KEY9")   /* P2 IN4 (11) */
289   PORT_START("KEY9")
226290   PORT_BIT( 0x3f, IP_ACTIVE_LOW, IPT_UNKNOWN )
227291   PORT_BIT( 0xc0, IP_ACTIVE_LOW, IPT_UNUSED )
228292
229293   PORT_START("IN0")
230    PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_UNKNOWN )
231    PORT_BIT( 0x40, IP_ACTIVE_LOW , IPT_COIN1 )
232    PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_UNKNOWN )
294   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_UNKNOWN )
295   PORT_BIT( 0x40, IP_ACTIVE_LOW , IPT_COIN1 )
296   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_UNKNOWN )
233297   PORT_SERVICE( 0x10, IP_ACTIVE_HIGH )
234    PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_SERVICE2 ) // analyzer
235    PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_UNKNOWN )
236    PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_UNKNOWN )
237    PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_SERVICE4 ) // memory reset
238
298   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_SERVICE2 ) // analyzer
299   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_UNKNOWN )
300   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_UNKNOWN )
301   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_SERVICE4 ) // memory reset
239302INPUT_PORTS_END
240303
241/****************************************************************************/
304/*************************************
305 *
306 *  Graphics definitions
307 *
308 *************************************/
242309
243310static const gfx_layout charlayout =
244311{
r7500r7501
255322   GFXDECODE_ENTRY( "gfx1", 0x00000, charlayout, 0, 32 )
256323GFXDECODE_END
257324
325/*************************************
326 *
327 *  Sound interfaces
328 *
329 *************************************/
330
258331static const ym2203_interface ym2203_config =
259332{
260333   {
r7500r7501
268341   NULL
269342};
270343
344/*************************************
345 *
346 *  Machine driver
347 *
348 *************************************/
349
350static MACHINE_START( mayumi )
351{
352   mayumi_state *state = (mayumi_state *)machine->driver_data;
353   UINT8 *ROM = memory_region(machine, "maincpu");
354
355   memory_configure_bank(machine, "bank1", 0, 4, &ROM[0x10000], 0x4000);
356   memory_set_bank(machine, "bank1", 0);
357
358   state_save_register_global(machine, state->int_enable);
359   state_save_register_global(machine, state->input_sel);
360}
361
362static MACHINE_RESET( mayumi )
363{
364   mayumi_state *state = (mayumi_state *)machine->driver_data;
365
366   state->int_enable = 0;
367   state->input_sel = 0;
368}
369
271370static MACHINE_DRIVER_START( mayumi )
272371
372   /* driver data */
373   MDRV_DRIVER_DATA(mayumi_state)
374
273375   /* basic machine hardware */
274376   MDRV_CPU_ADD("maincpu", Z80, MCLK/2) /* 5.000 MHz ? */
275377   MDRV_CPU_PROGRAM_MAP(mayumi_map)
276378   MDRV_CPU_IO_MAP(mayumi_io_map)
277379   MDRV_CPU_VBLANK_INT("screen", mayumi_interrupt)
278380
381   MDRV_MACHINE_START( mayumi )
279382   MDRV_MACHINE_RESET( mayumi )
280383
281384   /* video hardware */
r7500r7501
307410
308411MACHINE_DRIVER_END
309412
310/****************************************************************************/
413/*************************************
414 *
415 *  ROM definition(s)
416 *
417 *************************************/
311418
312419ROM_START( mayumi )
313420   ROM_REGION( 0x20000, "maincpu", 0 ) /* CPU */
r7500r7501
326433   ROM_LOAD( "my-9k.bin", 0x0200,  0x0100, CRC(3e7a8012) SHA1(24129586a1c39f68dad274b5afbdd6c027ab0901) ) // B
327434ROM_END
328435
329GAME( 1988, mayumi, 0, mayumi, mayumi, 0, ROT0, "[Sanritsu] Victory L.L.C.",  "Kikiippatsu Mayumi-chan (Japan)", 0 )
436/*************************************
437 *
438 *  Game driver(s)
439 *
440 *************************************/
441
442GAME( 1988, mayumi, 0, mayumi, mayumi, 0, ROT0, "[Sanritsu] Victory L.L.C.",  "Kikiippatsu Mayumi-chan (Japan)", GAME_SUPPORTS_SAVE )
src/mame/drivers/diverboy.c
r7500r7501
5353
5454
5555
56typedef struct _diverboy_state diverboy_state;
57struct _diverboy_state
56class diverboy_state
5857{
58public:
59   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, diverboy_state(machine)); }
60
61   diverboy_state(running_machine &machine) { }
62
5963   /* memory pointers */
6064   UINT16 *  spriteram;
6165//  UINT16 *  paletteram;   // currently this uses generic palette handling
src/mame/drivers/mrdo.c
r7500r7501
2222#include "emu.h"
2323#include "cpu/z80/z80.h"
2424#include "sound/sn76496.h"
25#include "includes/mrdo.h"
2526
27
2628#define MAIN_CLOCK      XTAL_8_2MHz
2729#define VIDEO_CLOCK      XTAL_19_6MHz
2830
2931
30extern UINT8 *mrdo_bgvideoram,*mrdo_fgvideoram;
31WRITE8_HANDLER( mrdo_bgvideoram_w );
32WRITE8_HANDLER( mrdo_fgvideoram_w );
33WRITE8_HANDLER( mrdo_scrollx_w );
34WRITE8_HANDLER( mrdo_scrolly_w );
35WRITE8_HANDLER( mrdo_flipscreen_w );
36PALETTE_INIT( mrdo );
37VIDEO_START( mrdo );
38VIDEO_UPDATE( mrdo );
3932
40
41
4233/* this looks like some kind of protection. The game doesn't clear the screen */
4334/* if a read from this address doesn't return the value it expects. */
4435static READ8_HANDLER( mrdo_SECRE_r )
4536{
4637   UINT8 *RAM = memory_region(space->machine, "maincpu");
47   return RAM[ cpu_get_reg(space->cpu, Z80_HL) ];
38   return RAM[cpu_get_reg(space->cpu, Z80_HL)];
4839}
4940
5041
5142
5243static ADDRESS_MAP_START( main_map, ADDRESS_SPACE_PROGRAM, 8 )
5344   AM_RANGE(0x0000, 0x7fff) AM_ROM
54   AM_RANGE(0x8000, 0x87ff) AM_RAM_WRITE(mrdo_bgvideoram_w) AM_BASE(&mrdo_bgvideoram)
55   AM_RANGE(0x8800, 0x8fff) AM_RAM_WRITE(mrdo_fgvideoram_w) AM_BASE(&mrdo_fgvideoram)
56   AM_RANGE(0x9000, 0x90ff) AM_WRITEONLY AM_BASE_SIZE_GENERIC(spriteram)
45   AM_RANGE(0x8000, 0x87ff) AM_RAM_WRITE(mrdo_bgvideoram_w) AM_BASE_MEMBER(mrdo_state, bgvideoram)
46   AM_RANGE(0x8800, 0x8fff) AM_RAM_WRITE(mrdo_fgvideoram_w) AM_BASE_MEMBER(mrdo_state, fgvideoram)
47   AM_RANGE(0x9000, 0x90ff) AM_WRITEONLY AM_BASE_SIZE_MEMBER(mrdo_state, spriteram, spriteram_size)
5748   AM_RANGE(0x9800, 0x9800) AM_WRITE(mrdo_flipscreen_w)   /* screen flip + playfield priority */
5849   AM_RANGE(0x9801, 0x9801) AM_DEVWRITE("sn1", sn76496_w)
5950   AM_RANGE(0x9802, 0x9802) AM_DEVWRITE("sn2", sn76496_w)
r7500r7501
176167
177168static MACHINE_DRIVER_START( mrdo )
178169
170   /* driver data */
171   MDRV_DRIVER_DATA(mrdo_state)
172
179173   /* basic machine hardware */
180174   MDRV_CPU_ADD("maincpu", Z80, MAIN_CLOCK/2)   /* Verified */
181175   MDRV_CPU_PROGRAM_MAP(main_map)
src/mame/drivers/galdrvr.c
r7500r7501
14561456INPUT_PORTS_END
14571457
14581458
1459static INPUT_PORTS_START( thepitm )
1460   PORT_START("IN0")
1461   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_COIN1 )
1462   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_COIN2 )
1463   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT )
1464   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT )
1465   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP )
1466   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_BUTTON1 )
1467   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN ) PORT_COCKTAIL
1468   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN )
14591469
1470   PORT_START("IN1")
1471   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_START1 )
1472   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_START2 )
1473   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT ) PORT_COCKTAIL
1474   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT ) PORT_COCKTAIL
1475   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP ) PORT_COCKTAIL
1476   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_COCKTAIL
1477    PORT_DIPNAME( 0x40, 0x00, DEF_STR( Unknown ) ) // turning both of these on boots with 9 credits?
1478    PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
1479    PORT_DIPSETTING(    0x40, DEF_STR( On ) )
1480    PORT_DIPNAME( 0x80, 0x00, DEF_STR( Unknown ) )
1481    PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
1482    PORT_DIPSETTING(    0x80, DEF_STR( On ) )
1483
1484   PORT_START("IN2")
1485    PORT_DIPNAME( 0x01, 0x00, DEF_STR( Unknown ) )
1486    PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
1487    PORT_DIPSETTING(    0x01, DEF_STR( On ) )
1488    PORT_DIPNAME( 0x02, 0x00, DEF_STR( Unknown ) )
1489    PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
1490    PORT_DIPSETTING(    0x02, DEF_STR( On ) )
1491    PORT_DIPNAME( 0x04, 0x00, DEF_STR( Flip_Screen ) )
1492    PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
1493    PORT_DIPSETTING(    0x04, DEF_STR( On ) )
1494   PORT_DIPNAME( 0x08, 0x00, DEF_STR( Cabinet ) )
1495   PORT_DIPSETTING(    0x00, DEF_STR( Upright ) )
1496   PORT_DIPSETTING(    0x08, DEF_STR( Cocktail ) )
1497    PORT_DIPNAME( 0x10, 0x00, DEF_STR( Unknown ) )
1498    PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
1499    PORT_DIPSETTING(    0x10, DEF_STR( On ) )
1500    PORT_DIPNAME( 0x20, 0x00, DEF_STR( Unknown ) )
1501    PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
1502    PORT_DIPSETTING(    0x20, DEF_STR( On ) )
1503    PORT_DIPNAME( 0x40, 0x00, DEF_STR( Unknown ) )
1504    PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
1505    PORT_DIPSETTING(    0x40, DEF_STR( On ) )
1506    PORT_DIPNAME( 0x80, 0x00, DEF_STR( Unknown ) )
1507    PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
1508    PORT_DIPSETTING(    0x80, DEF_STR( On ) )
1509INPUT_PORTS_END
1510
14601511/*************************************
14611512 *
14621513 *  Input Ports
r7500r7501
20482099INPUT_PORTS_END
20492100
20502101
2102static INPUT_PORTS_START( aracnis )
2103   PORT_START("IN0")      /* 0xa000 */
2104   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_SERVICE1 )      // COIN2? (it ALWAYS adds 1 credit)
2105   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_COIN1 )
2106   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT ) PORT_8WAY
2107   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT ) PORT_8WAY
2108   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_8WAY
2109    PORT_DIPNAME( 0x20, 0x20, DEF_STR( Unknown ) )
2110    PORT_DIPSETTING(    0x20, DEF_STR( Off ) )
2111    PORT_DIPSETTING(    0x00, DEF_STR( On ) )
2112   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_BUTTON2 )
2113   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP ) PORT_8WAY
2114
2115   PORT_START("IN1")      /* 0xa800 - needs verifying */
2116   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_START1 ) PORT_NAME("Start 1 / P1 Button 1")      /* also P1 Button 1 */
2117   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_START2 ) PORT_NAME("Start 2 / P1 Button 2")      /* also P1 Button 2 */
2118   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN ) PORT_8WAY
2119    PORT_DIPNAME( 0x08, 0x08, DEF_STR( Unknown ) )
2120    PORT_DIPSETTING(    0x08, DEF_STR( Off ) )
2121    PORT_DIPSETTING(    0x00, DEF_STR( On ) )
2122    PORT_DIPNAME( 0x10, 0x10, DEF_STR( Unknown ) )
2123    PORT_DIPSETTING(    0x10, DEF_STR( Off ) )
2124    PORT_DIPSETTING(    0x00, DEF_STR( On ) )
2125    PORT_DIPNAME( 0x20, 0x20, DEF_STR( Unknown ) )
2126    PORT_DIPSETTING(    0x20, DEF_STR( Off ) )
2127    PORT_DIPSETTING(    0x00, DEF_STR( On ) )
2128    PORT_DIPNAME( 0x40, 0x40, DEF_STR( Unknown ) )
2129    PORT_DIPSETTING(    0x40, DEF_STR( Off ) )
2130    PORT_DIPSETTING(    0x00, DEF_STR( On ) )
2131    PORT_DIPNAME( 0x80, 0x80, DEF_STR( Unknown ) )
2132    PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
2133    PORT_DIPSETTING(    0x00, DEF_STR( On ) )
2134
2135
2136   PORT_START("IN2")      /* 0xb001 */
2137   PORT_DIPNAME( 0x03, 0x03, DEF_STR( Coinage ) )
2138   PORT_DIPSETTING(    0x00, DEF_STR( 2C_1C ) )
2139   PORT_DIPSETTING(    0x01, DEF_STR( 1C_1C ) )
2140   PORT_DIPSETTING(    0x02, DEF_STR( 1C_2C ) )
2141   PORT_DIPSETTING(    0x03, DEF_STR( 1C_3C ) )
2142   PORT_DIPNAME( 0x04, 0x04, DEF_STR( Unknown ) )
2143    PORT_DIPSETTING(    0x04, DEF_STR( Off ) )
2144    PORT_DIPSETTING(    0x00, DEF_STR( On ) )
2145    PORT_DIPNAME( 0x08, 0x08, DEF_STR( Unknown ) )
2146    PORT_DIPSETTING(    0x08, DEF_STR( Off ) )
2147    PORT_DIPSETTING(    0x00, DEF_STR( On ) )
2148    PORT_DIPNAME( 0x10, 0x10, DEF_STR( Unknown ) )
2149    PORT_DIPSETTING(    0x10, DEF_STR( Off ) )
2150    PORT_DIPSETTING(    0x00, DEF_STR( On ) )
2151    PORT_DIPNAME( 0x20, 0x20, DEF_STR( Unknown ) )
2152    PORT_DIPSETTING(    0x20, DEF_STR( Off ) )
2153    PORT_DIPSETTING(    0x00, DEF_STR( On ) )
2154    PORT_DIPNAME( 0x40, 0x40, DEF_STR( Unknown ) )
2155    PORT_DIPSETTING(    0x40, DEF_STR( Off ) )
2156    PORT_DIPSETTING(    0x00, DEF_STR( On ) )
2157    PORT_DIPNAME( 0x80, 0x80, DEF_STR( Unknown ) )
2158    PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
2159    PORT_DIPSETTING(    0x00, DEF_STR( On ) )
2160
2161   PORT_START("IN3")      /* 0xb002 */
2162    PORT_DIPNAME( 0x01, 0x01, "0xb002" )
2163    PORT_DIPSETTING(    0x01, DEF_STR( Off ) )
2164    PORT_DIPSETTING(    0x00, DEF_STR( On ) )
2165    PORT_DIPNAME( 0x02, 0x02, DEF_STR( Unknown ) )
2166    PORT_DIPSETTING(    0x02, DEF_STR( Off ) )
2167    PORT_DIPSETTING(    0x00, DEF_STR( On ) )
2168    PORT_DIPNAME( 0x04, 0x04, DEF_STR( Unknown ) )
2169    PORT_DIPSETTING(    0x04, DEF_STR( Off ) )
2170    PORT_DIPSETTING(    0x00, DEF_STR( On ) )
2171    PORT_DIPNAME( 0x08, 0x08, DEF_STR( Unknown ) )
2172    PORT_DIPSETTING(    0x08, DEF_STR( Off ) )
2173    PORT_DIPSETTING(    0x00, DEF_STR( On ) )
2174    PORT_DIPNAME( 0x10, 0x10, DEF_STR( Unknown ) )
2175    PORT_DIPSETTING(    0x10, DEF_STR( Off ) )
2176    PORT_DIPSETTING(    0x00, DEF_STR( On ) )
2177    PORT_DIPNAME( 0x20, 0x20, DEF_STR( Unknown ) )
2178    PORT_DIPSETTING(    0x20, DEF_STR( Off ) )
2179    PORT_DIPSETTING(    0x00, DEF_STR( On ) )
2180    PORT_DIPNAME( 0x40, 0x40, DEF_STR( Unknown ) )
2181    PORT_DIPSETTING(    0x40, DEF_STR( Off ) )
2182    PORT_DIPSETTING(    0x00, DEF_STR( On ) )
2183    PORT_DIPNAME( 0x80, 0x80, DEF_STR( Unknown ) )
2184    PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
2185    PORT_DIPSETTING(    0x00, DEF_STR( On ) )
2186INPUT_PORTS_END
2187
2188
20512189static INPUT_PORTS_START( sfx )
20522190   PORT_START("IN0")
20532191   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_8WAY PORT_PLAYER(2)
r7500r7501
37313869   ROM_LOAD( "mmi6331.6l", 0x0000, 0x0020, CRC(6a0c7d87) SHA1(140335d85c67c75b65689d4e76d29863c209cf32) ) /* Compatible with 82s123 prom */
37323870ROM_END
37333871
3872ROM_START( mooncrstuk )
3873   ROM_REGION( 0x8000, "maincpu", 0 )
3874   ROM_LOAD( "mc1",          0x0000, 0x0800, CRC(7d954a7a) SHA1(a93ee403cfd7887538ad12d33f6dd6c71bea2a32) )
3875   ROM_LOAD( "mc2",          0x0800, 0x0800, CRC(44bb7cfa) SHA1(349c2e23a9fce73f95bb8168d369082fa129fe3d) )
3876   ROM_LOAD( "mc3",          0x1000, 0x0800, CRC(9c412104) SHA1(1b40054ebb1ace965a8522119bb23f09797bc5f6) )
3877   ROM_LOAD( "mc4",          0x1800, 0x0800, CRC(7e9b1ab5) SHA1(435f603c0c3e788a509dd144a7916a34e791ae44) )
3878   ROM_LOAD( "mc5.7r",       0x2000, 0x0800, CRC(16c759af) SHA1(3b48050411f65f9d3fb41ff22901e22d82bf1cf6) )
3879   ROM_LOAD( "mc6.8d",       0x2800, 0x0800, CRC(69bcafdb) SHA1(939c8c6ed1cd4660a3d99b8f17ed99cbd7e1352a) )
3880   ROM_LOAD( "mc7.8e",       0x3000, 0x0800, CRC(b50dbc46) SHA1(4fa084fd1ba5f78e7703e684c57af15ca7a844e4) )
3881   ROM_LOAD( "8_uk.bin",     0x3800, 0x0800, CRC(ce727ad4) SHA1(247fe0ea7dcc7cc50f19da0a54385b8545f03609) )
3882
3883   ROM_REGION( 0x2000, "gfx1", 0 )
3884   ROM_LOAD( "mcs_b",        0x0000, 0x0800, CRC(fb0f1f81) SHA1(38a6679a8b69bc1870a0e67e692131c42f9535c8) )
3885   ROM_LOAD( "mcs_d",        0x0800, 0x0800, CRC(13932a15) SHA1(b8885c555c6ad7021be55c6925a0a0872c1b6abd) )
3886   ROM_LOAD( "mcs_a",        0x1000, 0x0800, CRC(631ebb5a) SHA1(5bc9493afa76c55858b8c8849524cbc77dc838fc) )
3887   ROM_LOAD( "mcs_c",        0x1800, 0x0800, CRC(24cfd145) SHA1(08c6599db170dd6ee364c44f70a0f5c0f881b6ef) )
3888
3889   ROM_REGION( 0x0020, "proms", 0 )
3890   ROM_LOAD( "mmi6331.6l", 0x0000, 0x0020, CRC(6a0c7d87) SHA1(140335d85c67c75b65689d4e76d29863c209cf32) ) /* Compatible with 82s123 prom */
3891ROM_END
3892
37343893ROM_START( mooncrstu )
37353894   ROM_REGION( 0x8000, "maincpu", 0 )
37363895   ROM_LOAD( "smc1f",        0x0000, 0x0800, CRC(389ca0d6) SHA1(51cf6d190a0ebf23b70c2bcf1ccaa4705e29cd09) )
r7500r7501
51005259   ROM_LOAD( "mmi6331.bpr",  0x0000, 0x0020, CRC(6a0c7d87) SHA1(140335d85c67c75b65689d4e76d29863c209cf32) ) /* Compatible with 82s123 prom */
51015260ROM_END
51025261
5262ROM_START( aracnis )
5263   ROM_REGION( 0x10000, "maincpu", 0 )
5264   ROM_LOAD( "00sc.bin",       0x0000, 0x1000, CRC(c7e0d6b9) SHA1(3aac51d22939da8a595237ad26fe0f06a3acfb6a) )
5265   ROM_LOAD( "01sc.bin",       0x1000, 0x1000, CRC(03eb27dc) SHA1(8dae30006c9e81ab0d2b5c5faa7257813ea00a89) )
5266   ROM_LOAD( "02sc.bin",       0x2000, 0x1000, CRC(f3d49d4f) SHA1(19f603a2bda88e51608414f2748a33b4fb6e31c1) )
5267   ROM_LOAD( "03sc.bin",       0x3000, 0x1000, CRC(0e741984) SHA1(6e2c7820bbb1834c49f312664c786b50af0cff26) )
5268   ROM_LOAD( "05sc.bin",       0x5000, 0x1000, CRC(f27ee3e4) SHA1(e034507b99705492b6a8aa34764a1e3222ba31b2) )
5269   ROM_LOAD( "06sc.bin",       0x6000, 0x0800, CRC(fdfc2c82) SHA1(6b8914d6496c216de5bf160cd798b8f6facd44d2) )
51035270
5271   ROM_REGION( 0x2000, "gfx1", 0 )
5272   ROM_LOAD( "08sc.1h",        0x0000, 0x1000, CRC(1e5da9d6) SHA1(ca8b27e6dd40e4ca13e7e6b5f813bafca78b62f4) )
5273   ROM_LOAD( "07sc.1k",        0x1000, 0x1000, CRC(a57adb0a) SHA1(d97c7dc4a6c5efb59cc0148e2498156c682c6714) )
5274
5275   ROM_REGION( 0x0020, "proms", 0 )
5276   // colours are wrong, but this is the prom that was on the board
5277
5278   // note: pin 13 is marked with red paint, and is not connected
5279   //  ^ this is important for getting correct colours on real hw
5280   ROM_LOAD( "mmi6331-1.6l",  0x0000, 0x0020, CRC(24652bc4) SHA1(d89575f3749c75dc963317fe451ffeffd9856e4d) )
5281ROM_END
5282
51045283ROM_START( sfx )
51055284   ROM_REGION( 0x10000, "maincpu", 0 )
51065285   ROM_LOAD( "sfx_b-0.1j",   0x0000, 0x1000, CRC(e5bc6952) SHA1(7bfb772418d738d3c49fd59c0bfc04590945977a) )
r7500r7501
55785757   ROM_LOAD( "bprom.bin",       0x0000, 0x0020, CRC(2b4cf53f) SHA1(8d7eb0453173b9821eea32419b67559bfb4578d0) )
55795758ROM_END
55805759
5760/*
55815761
5762The Pit (on Moon Quasar hardware)
5763^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
5764
5765Dumped by Andrew Welburn
5766on the sunny morning of 2/03/10
5767
5768http://www.andys-arcade.com
5769
5770*************************************************
5771**Do not seperate this text file from the roms.**
5772*************************************************
5773
5774Nichibutsu Moon Quasar pcb largely unhacked, but
5775with an odd looking set of roms. One gfx rom
5776identifies itself as 'The Pit' so that is my only
5777guess at what the game actually is.
5778
5779Roms 1 through 8 read well in-circuit in the right
5780places in the memory map for moon cresta,
5781(through the fluke 9100) but the game does not
5782currently run. Roms dumped adn verified with no
5783anomolies.
5784
5785Rom 9 was placed on the through-socket and has
5786pins 20 and 18 (/E and A11 respectively) tied to
5787pin 5 of 8E (A14/A15/MREQ demux). This demux has
5788some patches, the trace to pin 13 is cut, and is
5789instead wired to pin 3.
5790
5791*/
5792
5793ROM_START( thepitm )
5794   ROM_REGION( 0x10000, "maincpu", 0 )
5795   ROM_LOAD( "1.bin",          0x0000, 0x0800, CRC(0f78d6ea) SHA1(e224b2fb9b4a26295b03af720fa647d4488a1287) )
5796   ROM_LOAD( "2.bin",          0x0800, 0x0800, CRC(ebacc6eb) SHA1(8b73d96ebe8070fbbb16434aa6a30ec8985ddec6) )
5797   ROM_LOAD( "3.bin",          0x1000, 0x0800, CRC(14fd0706) SHA1(5d905d8272731c307dc9f96caf4973b28413198e) )
5798   ROM_LOAD( "4.bin",          0x1800, 0x0800, CRC(613e920f) SHA1(078c7f36ba0145fbbd24bdae4cb6b03c5c27c1cc) )
5799   ROM_LOAD( "5.bin",          0x2000, 0x0800, CRC(5a791f3f) SHA1(166f07f7fe260e53e611784976792638a25485c1) )
5800   ROM_LOAD( "6.bin",          0x2800, 0x0800, CRC(0bb37f51) SHA1(32e31678388bad048c829bd43a18dc4e24869840) )
5801   ROM_LOAD( "7.bin",          0x3000, 0x0800, CRC(4dfdec6f) SHA1(eb88a278860998c343f94e27c8c6c723cffb2dd9) )
5802   ROM_LOAD( "8.bin",          0x3800, 0x0800, CRC(a39a9189) SHA1(aacd54edca6bc7f7feacd651a0de57b3d9592aad) )
5803   ROM_LOAD( "9.bin",          0x4000, 0x0800, CRC(2eb90e07) SHA1(92678fc5cfeb7119ce27f042571daa831fa1dad5) )
5804
5805   ROM_REGION( 0x2000, "gfx1", 0 )
5806   ROM_LOAD( "1h.bin",      0x0000, 0x0800, CRC(00dce65f) SHA1(ba0cce484d1f8693a85b85e0689d107588df9043) )
5807   ROM_LOAD( "1k.bin",      0x1000, 0x0800, CRC(3ec0056e) SHA1(1dd19e7535ab9abd62b4b32663437f8e8acb91b5) )
5808
5809   ROM_REGION( 0x0020, "proms", 0 )
5810   ROM_LOAD( "6l.bin",   0x0000, 0x0020, CRC(6a0c7d87) SHA1(140335d85c67c75b65689d4e76d29863c209cf32) )
5811ROM_END
5812
55825813/*************************************
55835814 *
55845815 *  Game drivers
r7500r7501
56715902
56725903/* based on Galaxian, but with altered address map for more ROM */
56735904GAME( 1980, mooncrst,  0,        mooncrst, mooncrst, mooncrst, ROT90,  "Nichibutsu", "Moon Cresta (Nichibutsu)", GAME_SUPPORTS_SAVE )
5674GAME( 1980, mooncrstu, mooncrst, mooncrst, mooncrst, mooncrsu, ROT90,  "Nichibutsu USA", "Moon Cresta (Nichibutsu, unencrypted)", GAME_SUPPORTS_SAVE )
5905GAME( 1980, mooncrstuk,mooncrst, mooncrst, mooncrst, mooncrst, ROT90,  "Nichibutsu UK", "Moon Cresta (Nichibutsu UK)", GAME_SUPPORTS_SAVE )
5906GAME( 1980, mooncrstu, mooncrst, mooncrst, mooncrst, mooncrsu, ROT90,  "Nichibutsu USA", "Moon Cresta (Nichibutsu USA, unencrypted)", GAME_SUPPORTS_SAVE )
56755907GAME( 1980, mooncrsto, mooncrst, mooncrst, mooncrsa, mooncrst, ROT90,  "Nichibutsu", "Moon Cresta (Nichibutsu, old rev)", GAME_SUPPORTS_SAVE )
56765908GAME( 1980, mooncrstg, mooncrst, mooncrst, mooncrsg, mooncrsu, ROT90,  "Gremlin", "Moon Cresta (Gremlin)", GAME_SUPPORTS_SAVE )
56775909
r7500r7501
56955927GAME( 1980, moonal2,  galaxian, mooncrst, moonal2,  galaxian, ROT90,  "Nichibutsu", "Moon Alien Part 2", GAME_SUPPORTS_SAVE )
56965928GAME( 1980, moonal2b, galaxian, mooncrst, moonal2,  galaxian, ROT90,  "Nichibutsu", "Moon Alien Part 2 (older version)", GAME_SUPPORTS_SAVE )
56975929
5930/* larger romspace, interrupt enable moved */
5931GAME( 198?, thepitm,  thepit,   mooncrst, thepitm,  thepitm,  ROT90,  "KZH", "The Pit (bootleg on Moon Quasar hardware)", GAME_SUPPORTS_SAVE ) // on an original MQ-2FJ pcb, even if the memory map appears closer to Moon Cresta
5932
5933
56985934/* other games on basic mooncrst hardware */
56995935GAME( 1982, skybase,  0,        mooncrst, skybase,  skybase,  ROT90,  "Omori Electric Co., Ltd.", "Sky Base", GAME_SUPPORTS_SAVE )
57005936
r7500r7501
57736009GAME( 1982, scorpiona,scorpion, scorpion, scorpion, scorpion, ROT90,  "Zaccaria", "Scorpion (set 2)", GAME_NOT_WORKING | GAME_IMPERFECT_SOUND | GAME_SUPPORTS_SAVE)
57746010GAME( 1982, scorpionb,scorpion, scorpion, scorpion, scorpion, ROT90,  "Zaccaria", "Scorpion (set 3)", GAME_IMPERFECT_SOUND | GAME_SUPPORTS_SAVE)
57756011GAME( 19??, scorpionmc,scorpion, mooncrst, scorpnmc, scorpnmc, ROT90,  "Dorneer",  "Scorpion (Moon Cresta hardware)", GAME_SUPPORTS_SAVE )
6012GAME( 19??, aracnis,   scorpion, mooncrst, aracnis,  scorpnmc, ROT90,  "bootleg",  "Aracnis (bootleg of Scorpion on Moon Cresta hardware)", GAME_SUPPORTS_SAVE | GAME_IMPERFECT_GRAPHICS )
57766013
57776014/* SF-X hardware; based on Scramble with extra Z80 and 8255 driving a DAC-based sample player */
57786015GAME( 1983, sfx,      0,        sfx,      sfx,      sfx,      ORIENTATION_FLIP_X, "Nichibutsu", "SF-X", GAME_SUPPORTS_SAVE )
src/mame/drivers/deco156.c
r7500r7501
1313*/
1414
1515#define DE156CPU ARM
16
1617#include "emu.h"
18#include "cpu/arm/arm.h"
1719#include "includes/decocrpt.h"
18#include "includes/deco32.h"
1920#include "machine/eeprom.h"
2021#include "sound/okim6295.h"
2122#include "sound/ymz280b.h"
22#include "cpu/arm/arm.h"
23#include "includes/deco16ic.h"
23#include "video/deco16ic.h"
2424
25static int simpl156_bank_callback(const int bank)
25class deco156_state
2626{
27   return ((bank>>4)&0x7) * 0x1000;
28}
27public:
28   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, deco156_state(machine)); }
2929
30   deco156_state(running_machine &machine) { }
3031
32   /* memory pointers */
33   UINT16 *  pf1_rowscroll;
34   UINT16 *  pf2_rowscroll;
35
36   /* devices */
37   running_device *maincpu;
38   running_device *deco16ic;
39   running_device *oki2;
40};
41
42
3143static VIDEO_START( wcvol95 )
3244{
45   deco156_state *state = (deco156_state *)machine->driver_data;
46
3347   /* allocate the ram as 16-bit (we do it here because the CPU is 32-bit) */
34   deco16_pf1_data = auto_alloc_array(machine, UINT16, 0x2000/2);
35   deco16_pf2_data = auto_alloc_array(machine, UINT16, 0x2000/2);
36   deco16_pf1_rowscroll = auto_alloc_array(machine, UINT16, 0x800/2);
37   deco16_pf2_rowscroll = auto_alloc_array(machine, UINT16, 0x800/2);
38   deco16_pf12_control = auto_alloc_array(machine, UINT16, 0x10/2);
48   state->pf1_rowscroll = auto_alloc_array(machine, UINT16, 0x800/2);
49   state->pf2_rowscroll = auto_alloc_array(machine, UINT16, 0x800/2);
3950   machine->generic.paletteram.u16 =  auto_alloc_array(machine, UINT16, 0x1000/2);
4051
4152   /* and register the allocated ram so that save states still work */
42   state_save_register_global_pointer(machine, deco16_pf1_data, 0x2000/2);
43   state_save_register_global_pointer(machine, deco16_pf2_data, 0x2000/2);
44   state_save_register_global_pointer(machine, deco16_pf1_rowscroll, 0x800/2);
45   state_save_register_global_pointer(machine, deco16_pf2_rowscroll, 0x800/2);
46   state_save_register_global_pointer(machine, deco16_pf12_control, 0x10/2);
53   state_save_register_global_pointer(machine, state->pf1_rowscroll, 0x800/2);
54   state_save_register_global_pointer(machine, state->pf2_rowscroll, 0x800/2);
4755   state_save_register_global_pointer(machine, machine->generic.paletteram.u16, 0x1000/2);
48
49   deco16_1_video_init(machine);
50
51   deco16_set_tilemap_bank_callback(0, simpl156_bank_callback);
52   deco16_set_tilemap_bank_callback(1, simpl156_bank_callback);
5356}
5457
5558/* spriteram is really 16-bit.. this can be changed to use 16-bit ram like the tilemaps
5659 its the same sprite chip Data East used on many, many 16-bit era titles */
5760static void draw_sprites(running_machine *machine, bitmap_t *bitmap,const rectangle *cliprect)
5861{
59   UINT32 *spriteram32 = machine->generic.spriteram.u32;
62   UINT32 *spriteram = machine->generic.spriteram.u32;
6063   int offs;
6164
6265   flip_screen_set_no_update(machine, 1);
6366
64   for (offs = (0x1400/4)-4;offs >= 0;offs -= 4) // 0x1400 for charlien
67   for (offs = (0x1400 / 4) - 4; offs >= 0; offs -= 4) // 0x1400 for charlien
6568   {
66      int x,y,sprite,colour,multi,fx,fy,inc,flash,mult, pri;
69      int x, y, sprite, colour, multi, fx, fy, inc, flash, mult, pri;
6770
68      sprite = spriteram32[offs+1]&0xffff;
71      sprite = spriteram[offs + 1] & 0xffff;
6972
70      y = spriteram32[offs]&0xffff;
71      flash=y&0x1000;
72      if (flash && (video_screen_get_frame_number(machine->primary_screen) & 1)) continue;
73      y = spriteram[offs] & 0xffff;
74      flash = y & 0x1000;
75      if (flash && (video_screen_get_frame_number(machine->primary_screen) & 1))
76         continue;
7377
74      x = spriteram32[offs+2]&0xffff;
75      colour = (x >>9) & 0x1f;
78      x = spriteram[offs + 2] & 0xffff;
79      colour = (x >> 9) & 0x1f;
7680
77      pri = (x&0xc000); // 2 bits or 1?
81      pri = (x & 0xc000); // 2 bits or 1?
7882
79      switch (pri&0xc000) {
80      case 0x0000: pri=0; break;
81      case 0x4000: pri=0xf0; break;
82      case 0x8000: pri=0xf0|0xcc; break;
83      case 0xc000: pri=0xf0|0xcc; break; /*  or 0xf0|0xcc|0xaa ? */
83      switch (pri & 0xc000)
84      {
85      case 0x0000: pri = 0; break;
86      case 0x4000: pri = 0xf0; break;
87      case 0x8000: pri = 0xf0 | 0xcc; break;
88      case 0xc000: pri = 0xf0 | 0xcc; break; /*  or 0xf0|0xcc|0xaa ? */
8489      }
8590
8691      fx = y & 0x2000;
r7500r7501
9297      if (x >= 320) x -= 512;
9398      if (y >= 256) y -= 512;
9499      y = 240 - y;
95        x = 304 - x;
100      x = 304 - x;
96101
97      if (x>320) continue;
102      if (x > 320)
103         continue;
98104
99105      sprite &= ~multi;
100106      if (fy)
r7500r7501
107113
108114      if (flip_screen_x_get(machine))
109115      {
110         y=240-y;
111         x=304-x;
112         if (fx) fx=0; else fx=1;
113         if (fy) fy=0; else fy=1;
114         mult=16;
116         y = 240 - y;
117         x = 304 - x;
118         if (fx) fx = 0; else fx = 1;
119         if (fy) fy = 0; else fy = 1;
120         mult = 16;
115121      }
116      else mult=-16;
122      else mult = -16;
117123
118124      while (multi >= 0)
119125      {
r7500r7501
133139
134140static VIDEO_UPDATE( wcvol95 )
135141{
136   bitmap_fill(screen->machine->priority_bitmap,NULL,0);
137   bitmap_fill(bitmap,NULL,0);
142   deco156_state *state = (deco156_state *)screen->machine->driver_data;
138143
139   deco16_pf12_update(deco16_pf1_rowscroll,deco16_pf2_rowscroll);
144   bitmap_fill(screen->machine->priority_bitmap, NULL, 0);
145   bitmap_fill(bitmap, NULL, 0);
140146
141   deco16_tilemap_2_draw(screen,bitmap,cliprect,TILEMAP_DRAW_OPAQUE,0);
142   draw_sprites(screen->machine,bitmap,cliprect);
143   deco16_tilemap_1_draw(screen,bitmap,cliprect,0,0);
147   deco16ic_pf12_update(state->deco16ic, state->pf1_rowscroll, state->pf2_rowscroll);
148
149   deco16ic_tilemap_2_draw(state->deco16ic, bitmap, cliprect, TILEMAP_DRAW_OPAQUE, 0);
150   draw_sprites(screen->machine, bitmap, cliprect);
151   deco16ic_tilemap_1_draw(state->deco16ic, bitmap, cliprect, 0, 0);
144152   return 0;
145153}
146154
r7500r7501
148156
149157static WRITE32_HANDLER(hvysmsh_eeprom_w)
150158{
159   deco156_state *state = (deco156_state *)space->machine->driver_data;
151160   if (ACCESSING_BITS_0_7)
152161   {
153      okim6295_set_bank_base(devtag_get_device(space->machine, "oki2"), 0x40000 * (data & 0x7) );
162      okim6295_set_bank_base(state->oki2, 0x40000 * (data & 0x7));
154163      input_port_write(space->machine, "EEPROMOUT", data, 0xff);
155164   }
156165}
r7500r7501
166175   palette_set_color_rgb(space->machine,offset,pal5bit(space->machine->generic.paletteram.u32[offset] >> 0),pal5bit(space->machine->generic.paletteram.u32[offset] >> 5),pal5bit(space->machine->generic.paletteram.u32[offset] >> 10));
167176}
168177
169/***************************************************************************/
170static READ32_HANDLER( wcvol95_pf1_rowscroll_r ) { return deco16_pf1_rowscroll[offset]^0xffff0000; }
171static READ32_HANDLER( wcvol95_pf2_rowscroll_r ) { return deco16_pf2_rowscroll[offset]^0xffff0000; }
172static WRITE32_HANDLER( wcvol95_pf1_rowscroll_w ) { data &=0x0000ffff; mem_mask &=0x0000ffff; COMBINE_DATA(&deco16_pf1_rowscroll[offset]); }
173static WRITE32_HANDLER( wcvol95_pf2_rowscroll_w ) { data &=0x0000ffff; mem_mask &=0x0000ffff; COMBINE_DATA(&deco16_pf2_rowscroll[offset]); }
174static READ32_HANDLER ( wcvol95_pf12_control_r ) { return deco16_pf12_control[offset]^0xffff0000; }
175static WRITE32_HANDLER( wcvol95_pf12_control_w ) { data &=0x0000ffff; mem_mask &=0x0000ffff; COMBINE_DATA(&deco16_pf12_control[offset]); }
176static READ32_HANDLER( wcvol95_pf1_data_r ) {   return deco16_pf1_data[offset]^0xffff0000; }
177static READ32_HANDLER( wcvol95_pf2_data_r ) {   return deco16_pf2_data[offset]^0xffff0000; }
178static WRITE32_HANDLER( wcvol95_pf1_data_w ) { data &=0x0000ffff; mem_mask &=0x0000ffff; deco16_pf1_data_w(space,offset,data,mem_mask); }
179static WRITE32_HANDLER( wcvol95_pf2_data_w ) { data &=0x0000ffff; mem_mask &=0x0000ffff; deco16_pf2_data_w(space,offset,data,mem_mask); }
178/* This is the same as deco32_nonbuffered_palette_w in video/deco32.c */
179static WRITE32_HANDLER( deco156_nonbuffered_palette_w )
180{
181   int r,g,b;
180182
183   COMBINE_DATA(&space->machine->generic.paletteram.u32[offset]);
181184
185   b = (space->machine->generic.paletteram.u32[offset] >>16) & 0xff;
186   g = (space->machine->generic.paletteram.u32[offset] >> 8) & 0xff;
187   r = (space->machine->generic.paletteram.u32[offset] >> 0) & 0xff;
188
189   palette_set_color(space->machine,offset,MAKE_RGB(r,g,b));
190}
191
192static READ32_HANDLER( wcvol95_pf1_rowscroll_r ) { deco156_state *state = (deco156_state *)space->machine->driver_data; return state->pf1_rowscroll[offset] ^ 0xffff0000; }
193static READ32_HANDLER( wcvol95_pf2_rowscroll_r ) { deco156_state *state = (deco156_state *)space->machine->driver_data;   return state->pf2_rowscroll[offset] ^ 0xffff0000; }
194static WRITE32_HANDLER( wcvol95_pf1_rowscroll_w ) { deco156_state *state = (deco156_state *)space->machine->driver_data; data &= 0x0000ffff; mem_mask &= 0x0000ffff; COMBINE_DATA(&state->pf1_rowscroll[offset]); }
195static WRITE32_HANDLER( wcvol95_pf2_rowscroll_w ) { deco156_state *state = (deco156_state *)space->machine->driver_data; data &= 0x0000ffff; mem_mask &= 0x0000ffff; COMBINE_DATA(&state->pf2_rowscroll[offset]); }
196
197
182198static ADDRESS_MAP_START( hvysmsh_map, ADDRESS_SPACE_PROGRAM, 32 )
183199   AM_RANGE(0x000000, 0x0fffff) AM_ROM
184200   AM_RANGE(0x100000, 0x107fff) AM_RAM
r7500r7501
189205   AM_RANGE(0x12000c, 0x12000f) AM_DEVWRITE("oki1", hvysmsh_oki_0_bank_w)
190206   AM_RANGE(0x140000, 0x140003) AM_DEVREADWRITE8("oki1", okim6295_r, okim6295_w, 0x000000ff)
191207   AM_RANGE(0x160000, 0x160003) AM_DEVREADWRITE8("oki2", okim6295_r, okim6295_w, 0x000000ff)
192   AM_RANGE(0x180000, 0x18001f) AM_READWRITE( wcvol95_pf12_control_r, wcvol95_pf12_control_w )
193   AM_RANGE(0x190000, 0x191fff) AM_READWRITE( wcvol95_pf1_data_r, wcvol95_pf1_data_w )
194   AM_RANGE(0x194000, 0x195fff) AM_READWRITE( wcvol95_pf2_data_r, wcvol95_pf2_data_w )
195   AM_RANGE(0x1a0000, 0x1a0fff) AM_READWRITE( wcvol95_pf1_rowscroll_r, wcvol95_pf1_rowscroll_w )
196   AM_RANGE(0x1a4000, 0x1a4fff) AM_READWRITE( wcvol95_pf2_rowscroll_r, wcvol95_pf2_rowscroll_w )
197   AM_RANGE(0x1c0000, 0x1c0fff) AM_RAM_WRITE(deco32_nonbuffered_palette_w) AM_BASE_GENERIC(paletteram)
208   AM_RANGE(0x180000, 0x18001f) AM_DEVREADWRITE("deco_custom", deco16ic_pf12_control_dword_r, deco16ic_pf12_control_dword_w)
209   AM_RANGE(0x190000, 0x191fff) AM_DEVREADWRITE("deco_custom", deco16ic_pf1_data_dword_r, deco16ic_pf1_data_dword_w)
210   AM_RANGE(0x194000, 0x195fff) AM_DEVREADWRITE("deco_custom", deco16ic_pf2_data_dword_r, deco16ic_pf2_data_dword_w)
211   AM_RANGE(0x1a0000, 0x1a0fff) AM_READWRITE(wcvol95_pf1_rowscroll_r, wcvol95_pf1_rowscroll_w)
212   AM_RANGE(0x1a4000, 0x1a4fff) AM_READWRITE(wcvol95_pf2_rowscroll_r, wcvol95_pf2_rowscroll_w)
213   AM_RANGE(0x1c0000, 0x1c0fff) AM_RAM_WRITE(deco156_nonbuffered_palette_w) AM_BASE_GENERIC(paletteram)
198214   AM_RANGE(0x1d0010, 0x1d002f) AM_READNOP // Check for DMA complete?
199215   AM_RANGE(0x1e0000, 0x1e1fff) AM_RAM AM_BASE_SIZE_GENERIC(spriteram)
200216ADDRESS_MAP_END
201217
202218static ADDRESS_MAP_START( wcvol95_map, ADDRESS_SPACE_PROGRAM, 32 )
203219   AM_RANGE(0x000000, 0x0fffff) AM_ROM
204   AM_RANGE(0x100000, 0x10001f) AM_READWRITE( wcvol95_pf12_control_r, wcvol95_pf12_control_w )
205   AM_RANGE(0x110000, 0x111fff) AM_READWRITE( wcvol95_pf1_data_r, wcvol95_pf1_data_w )
206   AM_RANGE(0x114000, 0x115fff) AM_READWRITE( wcvol95_pf2_data_r, wcvol95_pf2_data_w )
207   AM_RANGE(0x120000, 0x120fff) AM_READWRITE( wcvol95_pf1_rowscroll_r, wcvol95_pf1_rowscroll_w )
208   AM_RANGE(0x124000, 0x124fff) AM_READWRITE( wcvol95_pf2_rowscroll_r, wcvol95_pf2_rowscroll_w )
220   AM_RANGE(0x100000, 0x10001f) AM_DEVREADWRITE("deco_custom", deco16ic_pf12_control_dword_r, deco16ic_pf12_control_dword_w)
221   AM_RANGE(0x110000, 0x111fff) AM_DEVREADWRITE("deco_custom", deco16ic_pf1_data_dword_r, deco16ic_pf1_data_dword_w)
222   AM_RANGE(0x114000, 0x115fff) AM_DEVREADWRITE("deco_custom", deco16ic_pf2_data_dword_r, deco16ic_pf2_data_dword_w)
223   AM_RANGE(0x120000, 0x120fff) AM_READWRITE(wcvol95_pf1_rowscroll_r, wcvol95_pf1_rowscroll_w)
224   AM_RANGE(0x124000, 0x124fff) AM_READWRITE(wcvol95_pf2_rowscroll_r, wcvol95_pf2_rowscroll_w)
209225   AM_RANGE(0x130000, 0x137fff) AM_RAM
210226   AM_RANGE(0x140000, 0x140003) AM_READ_PORT("INPUTS")
211227   AM_RANGE(0x150000, 0x150003) AM_WRITE_PORT("EEPROMOUT")
r7500r7501
366382   cpu_set_input_line(device, ARM_IRQ_LINE, HOLD_LINE);
367383}
368384
385static int deco156_bank_callback(const int bank)
386{
387   return ((bank >> 4) & 0x7) * 0x1000;
388}
389
390static const deco16ic_interface deco156_deco16ic_intf =
391{
392   "screen",
393   1, 0, 1,
394   0x0f, 0x0f, 0x0f, 0x0f,   /* trans masks (default values) */
395   0, 16, 0, 16, /* color base (default values) */
396   0x0f, 0x0f, 0x0f, 0x0f,   /* color masks (default values) */
397   deco156_bank_callback,
398   deco156_bank_callback,
399   NULL,
400   NULL
401};
402
403static MACHINE_START( deco156 )
404{
405   deco156_state *state = (deco156_state *)machine->driver_data;
406
407   state->maincpu = devtag_get_device(machine, "maincpu");
408   state->deco16ic = devtag_get_device(machine, "deco_custom");
409   state->oki2 = devtag_get_device(machine, "oki2");
410}
411
369412static MACHINE_DRIVER_START( hvysmsh )
370413
414   /* driver data */
415   MDRV_DRIVER_DATA(deco156_state)
416
371417   /* basic machine hardware */
372418   MDRV_CPU_ADD("maincpu", ARM, 28000000) /* Unconfirmed */
373419   MDRV_CPU_PROGRAM_MAP(hvysmsh_map)
r7500r7501
375421
376422   MDRV_EEPROM_93C46_ADD("eeprom")
377423
424   MDRV_MACHINE_START(deco156)
425
378426   /* video hardware */
379427   MDRV_VIDEO_ATTRIBUTES(VIDEO_BUFFERS_SPRITERAM )
380428
r7500r7501
391439   MDRV_VIDEO_START(wcvol95)
392440   MDRV_VIDEO_UPDATE(wcvol95)
393441
442   MDRV_DECO16IC_ADD("deco_custom", deco156_deco16ic_intf)
443
394444   /* sound hardware */
395445   MDRV_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker")
396446
r7500r7501
407457
408458static MACHINE_DRIVER_START( wcvol95 )
409459
460   /* driver data */
461   MDRV_DRIVER_DATA(deco156_state)
462
410463   /* basic machine hardware */
411464   MDRV_CPU_ADD("maincpu", ARM, 28000000) /* Unconfirmed */
412465   MDRV_CPU_PROGRAM_MAP(wcvol95_map)
r7500r7501
414467
415468   MDRV_EEPROM_93C46_ADD("eeprom")
416469
470   MDRV_MACHINE_START(deco156)
471
417472   /* video hardware */
418473   MDRV_VIDEO_ATTRIBUTES(VIDEO_BUFFERS_SPRITERAM )
419474
r7500r7501
430485   MDRV_VIDEO_START(wcvol95)
431486   MDRV_VIDEO_UPDATE(wcvol95)
432487
488   MDRV_DECO16IC_ADD("deco_custom", deco156_deco16ic_intf)
489
433490   /* sound hardware */
434491   MDRV_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker")
435492
r7500r7501
639696   UINT8 *buf1 = auto_alloc_array(machine, UINT8, length);
640697   UINT32 x;
641698
642   for (x=0;x<length;x++)
699   for (x = 0; x < length; x++)
643700   {
644701      UINT32 addr;
645702
r7500r7501
655712
656713   memcpy(rom,buf1,length);
657714
658   auto_free (machine, buf1);
715   auto_free(machine, buf1);
659716}
660717
661718static DRIVER_INIT( hvysmsh )
r7500r7501
675732
676733/**********************************************************************************/
677734
678GAME( 1993, hvysmsh,  0,       hvysmsh, hvysmsh, hvysmsh,  ROT0, "Data East Corporation", "Heavy Smash (Europe version -2)", 0)
679GAME( 1993, hvysmsha, hvysmsh, hvysmsh, hvysmsh, hvysmsh,  ROT0, "Data East Corporation", "Heavy Smash (Asia version -4)", 0)
680GAME( 1993, hvysmshj, hvysmsh, hvysmsh, hvysmsh, hvysmsh,  ROT0, "Data East Corporation", "Heavy Smash (Japan version -2)", 0)
681GAME( 1995, wcvol95,  0,       wcvol95, wcvol95, wcvol95,  ROT0, "Data East Corporation", "World Cup Volley '95 (Japan v1.0)",0 )
735GAME( 1993, hvysmsh,  0,       hvysmsh, hvysmsh, hvysmsh,  ROT0, "Data East Corporation", "Heavy Smash (Europe version -2)", GAME_SUPPORTS_SAVE )
736GAME( 1993, hvysmsha, hvysmsh, hvysmsh, hvysmsh, hvysmsh,  ROT0, "Data East Corporation", "Heavy Smash (Asia version -4)", GAME_SUPPORTS_SAVE )
737GAME( 1993, hvysmshj, hvysmsh, hvysmsh, hvysmsh, hvysmsh,  ROT0, "Data East Corporation", "Heavy Smash (Japan version -2)", GAME_SUPPORTS_SAVE )
738GAME( 1995, wcvol95,  0,       wcvol95, wcvol95, wcvol95,  ROT0, "Data East Corporation", "World Cup Volley '95 (Japan v1.0)", GAME_SUPPORTS_SAVE )
src/mame/drivers/dwarfd.c
r7500r7501
278278#include "cpu/i8085/i8085.h"
279279#include "sound/ay8910.h"
280280
281typedef struct _dwarfd_state dwarfd_state;
282struct _dwarfd_state
281class dwarfd_state
283282{
283public:
284   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, dwarfd_state(machine)); }
285
286   dwarfd_state(running_machine &machine) { }
287
284288   /* memory pointers */
285289   UINT8 *  dw_ram;
286290   UINT8 *  videobuf;
src/mame/drivers/tail2nos.c
r7500r7501
7272   PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_UNKNOWN )
7373   PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_2WAY
7474   PORT_BIT( 0x0008, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_2WAY
75   PORT_BIT( 0x0010, IP_ACTIVE_LOW, IPT_BUTTON2 )
76   PORT_BIT( 0x0020, IP_ACTIVE_LOW, IPT_BUTTON1 )
75   PORT_BIT( 0x0010, IP_ACTIVE_LOW, IPT_BUTTON1 )
76   PORT_BIT( 0x0020, IP_ACTIVE_LOW, IPT_BUTTON2 )
7777   PORT_BIT( 0x0040, IP_ACTIVE_LOW, IPT_UNKNOWN )
7878   PORT_BIT( 0x0080, IP_ACTIVE_LOW, IPT_UNKNOWN )
7979   PORT_BIT( 0x0100, IP_ACTIVE_LOW, IPT_COIN1 )
src/mame/drivers/mrjong.c
r7500r7501
11/***************************************************************************
22
3Mr.Jong
4(c)1983 Kiwako (This game is distributed by Sanritsu.)
3    Mr. Jong
4    (c)1983 Kiwako (This game is distributed by Sanritsu.)
55
6Crazy Blocks
7(c)1983 Kiwako/ECI
6    Crazy Blocks
7    (c)1983 Kiwako/ECI
88
9Driver by Takahiro Nogi (nogi@kt.rim.or.jp) 2000/03/20 -
9    Driver by Takahiro Nogi (nogi@kt.rim.or.jp) 2000/03/20 -
1010
11Block Buster
12(c)1983 Kiwako/ECI
11    Block Buster
12    (c)1983 Kiwako/ECI
1313
14
1415PCB Layout
1516----------
1617
r7500r7501
4546#include "emu.h"
4647#include "cpu/z80/z80.h"
4748#include "sound/sn76496.h"
49#include "includes/mrjong.h"
4850
4951
50extern UINT8 *mrjong_videoram;
51extern UINT8 *mrjong_colorram;
52/*************************************
53 *
54 *  Memory handlers
55 *
56 *************************************/
5257
53extern WRITE8_HANDLER( mrjong_videoram_w );
54extern WRITE8_HANDLER( mrjong_colorram_w );
55extern WRITE8_HANDLER( mrjong_flipscreen_w );
58static READ8_HANDLER( io_0x03_r )
59{
60   return 0x00;
61}
5662
57extern PALETTE_INIT( mrjong );
58extern VIDEO_START( mrjong );
59extern VIDEO_UPDATE( mrjong );
6063
64/*************************************
65 *
66 *  Address maps
67 *
68 *************************************/
6169
6270static ADDRESS_MAP_START( mrjong_map, ADDRESS_SPACE_PROGRAM, 8 )
6371   AM_RANGE(0x0000, 0x7fff) AM_ROM
6472   AM_RANGE(0x8000, 0x87ff) AM_RAM
6573   AM_RANGE(0xa000, 0xa7ff) AM_RAM
66   AM_RANGE(0xe000, 0xe3ff) AM_RAM_WRITE(mrjong_videoram_w) AM_BASE(&mrjong_videoram)
67   AM_RANGE(0xe400, 0xe7ff) AM_RAM_WRITE(mrjong_colorram_w) AM_BASE(&mrjong_colorram)
74   AM_RANGE(0xe000, 0xe3ff) AM_RAM_WRITE(mrjong_videoram_w) AM_BASE_MEMBER(mrjong_state, videoram)
75   AM_RANGE(0xe400, 0xe7ff) AM_RAM_WRITE(mrjong_colorram_w) AM_BASE_MEMBER(mrjong_state, colorram)
6876ADDRESS_MAP_END
6977
70static WRITE8_HANDLER( io_0x00_w )
71{
72   mrjong_flipscreen_w(space, 0, ((data & 0x04) > 2));
73}
74
75static READ8_HANDLER( io_0x03_r )
76{
77   return 0x00;
78}
79
80
8178static ADDRESS_MAP_START( mrjong_io_map, ADDRESS_SPACE_IO, 8 )
8279   ADDRESS_MAP_GLOBAL_MASK(0xff)
83   AM_RANGE(0x00, 0x00) AM_READ_PORT("P2") AM_WRITE(io_0x00_w)
80   AM_RANGE(0x00, 0x00) AM_READ_PORT("P2") AM_WRITE(mrjong_flipscreen_w)
8481   AM_RANGE(0x01, 0x01) AM_READ_PORT("P1") AM_DEVWRITE("sn1", sn76496_w)
8582   AM_RANGE(0x02, 0x02) AM_READ_PORT("DSW") AM_DEVWRITE("sn2", sn76496_w)
8683   AM_RANGE(0x03, 0x03) AM_READ(io_0x03_r)      // Unknown
8784ADDRESS_MAP_END
8885
86/*************************************
87 *
88 *  Input ports
89 *
90 *************************************/
91
8992static INPUT_PORTS_START( mrjong )
9093   PORT_START("P2")
9194   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP ) PORT_4WAY PORT_PLAYER(2)
r7500r7501
133136INPUT_PORTS_END
134137
135138
139/*************************************
140 *
141 *  Graphics definitions
142 *
143 *************************************/
144
136145static const gfx_layout tilelayout =
137146{
138147   8, 8,            /* 8*8 characters */
r7500r7501
163172GFXDECODE_END
164173
165174
175/*************************************
176 *
177 *  Machine driver
178 *
179 *************************************/
180
166181static MACHINE_DRIVER_START( mrjong )
167182
183   /* driver data */
184   MDRV_DRIVER_DATA(mrjong_state)
185
168186   /* basic machine hardware */
169187   MDRV_CPU_ADD("maincpu", Z80,15468000/6)   /* 2.578 MHz?? */
170188   MDRV_CPU_PROGRAM_MAP(mrjong_map)
r7500r7501
189207   /* sound hardware */
190208   MDRV_SPEAKER_STANDARD_MONO("mono")
191209
192   MDRV_SOUND_ADD("sn1", SN76489, 15468000/6)
210   MDRV_SOUND_ADD("sn1", SN76489, 15468000/6)
193211   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0)
194212
195   MDRV_SOUND_ADD("sn2", SN76489, 15468000/6)
213   MDRV_SOUND_ADD("sn2", SN76489, 15468000/6)
196214   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0)
197215MACHINE_DRIVER_END
198216
199217
200/***************************************************************************
218/*************************************
219 *
220 *  ROM definition(s)
221 *
222 *************************************/
201223
202  Game driver(s)
203
204***************************************************************************/
205
206224ROM_START( mrjong )
207225   ROM_REGION( 0x10000, "maincpu", 0 )   /* code */
208226   ROM_LOAD( "mj00", 0x0000, 0x2000, CRC(d211aed3) SHA1(01f252ca1d2399146fa3ed44cb2daa1d5925cae5) )
r7500r7501
251269   ROM_LOAD( "clr.g5", 0x0020, 0x0100, CRC(bcb1e2e3) SHA1(c09731836a9d4e50316a84b86f61b599a1ef944d) )
252270ROM_END
253271
254GAME( 1983, mrjong,   0,      mrjong, mrjong, 0, ROT90, "Kiwako", "Mr. Jong (Japan)", 0 )
255GAME( 1983, crazyblk, mrjong, mrjong, mrjong, 0, ROT90, "Kiwako (ECI license)", "Crazy Blocks", 0 )
256GAME( 1983, blkbustr, mrjong, mrjong, mrjong, 0, ROT90, "Kiwako (ECI license)", "BlockBuster", 0 )
272/*************************************
273 *
274 *  Game driver(s)
275 *
276 *************************************/
257277
278GAME( 1983, mrjong,   0,      mrjong, mrjong, 0, ROT90, "Kiwako", "Mr. Jong (Japan)", GAME_SUPPORTS_SAVE )
279GAME( 1983, crazyblk, mrjong, mrjong, mrjong, 0, ROT90, "Kiwako (ECI license)", "Crazy Blocks", GAME_SUPPORTS_SAVE )
280GAME( 1983, blkbustr, mrjong, mrjong, mrjong, 0, ROT90, "Kiwako (ECI license)", "BlockBuster", GAME_SUPPORTS_SAVE )
src/mame/drivers/m79amb.c
r7500r7501
5858#include "includes/m79amb.h"
5959#include "cpu/i8085/i8085.h"
6060
61static UINT8 *ramtek_videoram;
62static UINT8 *mask;
61class m79amb_state
62{
63public:
64   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, m79amb_state(machine)); }
6365
66   m79amb_state(running_machine &machine) { }
6467
68   /* memory pointers */
69   UINT8 *        videoram;
70   UINT8 *        mask;
71
72   /* misc */
73   UINT8 lut_gun1[0x100];
74   UINT8 lut_gun2[0x100];
75};
76
77
6578static WRITE8_HANDLER( ramtek_videoram_w )
6679{
67   ramtek_videoram[offset] = data & ~*mask;
80   m79amb_state *state = (m79amb_state *)space->machine->driver_data;
81   state->videoram[offset] = data & ~*state->mask;
6882}
6983
7084static VIDEO_UPDATE( ramtek )
7185{
86   m79amb_state *state = (m79amb_state *)screen->machine->driver_data;
7287   offs_t offs;
7388
7489   for (offs = 0; offs < 0x2000; offs++)
7590   {
7691      int i;
7792
78      UINT8 data = ramtek_videoram[offs];
93      UINT8 data = state->videoram[offs];
7994      int y = offs >> 5;
8095      int x = (offs & 0x1f) << 3;
8196
r7500r7501
93108}
94109
95110
96/* grenade trajectory per gun position is inconsistent and sloppy in the game:
97     0,     1,     3,     2,     6,     7,     5,     4     - gun position
98    90.00, 90.00, 90.00, 90.00, 86.42, 86.42, 86.42, 86.42  - grenade trajectory (angle, est)
99     18.0,  18.0,  18.0,  18.0,  27.2,  27.2,  27.2,  31.2  - crosses with y=28 (x, est)
100
101    12,    13,    15,    14,    10,    11,     9,     8,
102    84.39, 84.39, 84.39, 80.87, 79.00, 80.87, 79.00, 79.00
103     41.9,  48.9,  56.8,  75.8,  87.2,  88.8, 101.6, 107.6
104
105    24,    25,    27,    26,    30,    31,    29,    28,
106    79.00, 79.00, 75.59, 75.59, 75.59, 73.72, 73.72, 73.72
107    114.1, 121.5, 138.8, 146.0, 152.7, 162.6, 167.6, 172.7
108
109    20,    21,    23,    22,    18,    19,    17,    16
110    73.72, 70.08, 70.08, 70.08, 67.97, 67.97, 64.34, 64.34
111    181.6, 199.9, 205.4, 211.9, 223.5, 232.4, 254.0, 254.0
112*/
113static const UINT8 lut_cross[0x20] = {
114     19,    20,    21,    23,    25,    27,    29,    37,
115     45,    53,    66,    82,    88,    95,   105,   111,
116    118,   130,   142,   149,   158,   165,   170,   177,
117    191,   203,   209,   218,   228,   243,   249,   255,
118};
119static const UINT8 lut_pos[0x20] = {
120    0x1f,  0x1e,  0x1c,  0x1d,  0x19,  0x18,  0x1a,  0x1b,
121    0x13,  0x12,  0x10,  0x11,  0x15,  0x14,  0x16,  0x17,
122    0x07,  0x06,  0x04,  0x05,  0x01,  0x00,  0x02,  0x03,
123    0x0b,  0x0a,  0x08,  0x09,  0x0d,  0x0c,  0x0e,  0x0f
124};
125
126static UINT8 lut_gun1[0x100];
127static UINT8 lut_gun2[0x100];
128
129111static READ8_HANDLER( gray5bit_controller0_r )
130112{
131    UINT8 port_data = input_port_read(space->machine, "8004");
132    UINT8 gun_pos = input_port_read(space->machine, "GUN1");
133    return (port_data & 0xe0) | lut_gun1[gun_pos];
113   m79amb_state *state = (m79amb_state *)space->machine->driver_data;
114   UINT8 port_data = input_port_read(space->machine, "8004");
115   UINT8 gun_pos = input_port_read(space->machine, "GUN1");
116
117   return (port_data & 0xe0) | state->lut_gun1[gun_pos];
134118}
135119
136120static READ8_HANDLER( gray5bit_controller1_r )
137121{
138    UINT8 port_data = input_port_read(space->machine, "8005");
139    UINT8 gun_pos = input_port_read(space->machine, "GUN2");
140    return (port_data & 0xe0) | lut_gun2[gun_pos];
122   m79amb_state *state = (m79amb_state *)space->machine->driver_data;
123   UINT8 port_data = input_port_read(space->machine, "8005");
124   UINT8 gun_pos = input_port_read(space->machine, "GUN2");
125
126   return (port_data & 0xe0) | state->lut_gun2[gun_pos];
141127}
142128
143129static WRITE8_HANDLER( m79amb_8002_w )
r7500r7501
149135
150136static ADDRESS_MAP_START( main_map, ADDRESS_SPACE_PROGRAM, 8 )
151137   AM_RANGE(0x0000, 0x1fff) AM_ROM
152   AM_RANGE(0x4000, 0x5fff) AM_RAM_WRITE(ramtek_videoram_w) AM_BASE(&ramtek_videoram)
138   AM_RANGE(0x4000, 0x5fff) AM_RAM_WRITE(ramtek_videoram_w) AM_BASE_MEMBER(m79amb_state, videoram)
153139   AM_RANGE(0x6000, 0x63ff) AM_RAM               /* ?? */
154140   AM_RANGE(0x8000, 0x8000) AM_READ_PORT("8000") AM_DEVWRITE("discrete", m79amb_8000_w)
155   AM_RANGE(0x8001, 0x8001) AM_WRITEONLY AM_BASE(&mask)
141   AM_RANGE(0x8001, 0x8001) AM_WRITEONLY AM_BASE_MEMBER(m79amb_state, mask)
156142   AM_RANGE(0x8002, 0x8002) AM_READ_PORT("8002") AM_WRITE(m79amb_8002_w)
157143   AM_RANGE(0x8003, 0x8003) AM_DEVWRITE("discrete", m79amb_8003_w)
158144   AM_RANGE(0x8004, 0x8004) AM_READ(gray5bit_controller0_r)
r7500r7501
218204   cpu_set_input_line_and_vector(device, 0, HOLD_LINE, 0xcf);  /* RST 08h */
219205}
220206
221static DRIVER_INIT( m79amb )
222{
223   UINT8 *rom = memory_region(machine, "maincpu");
224   int i,j;
207static MACHINE_DRIVER_START( m79amb )
225208
226   /* PROM data is active low */
227   for (i = 0;i < 0x2000;i++)
228      rom[i] = ~rom[i];
209   /* driver data */
210   MDRV_DRIVER_DATA(m79amb_state)
229211
230   /* gun positions */
231   for (i=0;i<0x100;i++) {
232      /* gun 1, start at left 18 */
233      for (j=0;j<0x20;j++) {
234         if (i<=lut_cross[j]) {
235            lut_gun1[i]=lut_pos[j];
236            break;
237         }
238      }
239
240      /* gun 2, start at right 235 */
241      for (j=0;j<0x20;j++) {
242         if (i>=(253-lut_cross[j])) {
243            lut_gun2[i]=lut_pos[j];
244            break;
245         }
246      }
247   }
248}
249
250static MACHINE_DRIVER_START( m79amb )
251
252212   /* basic machine hardware */
253213   MDRV_CPU_ADD("maincpu", 8080, XTAL_19_6608MHz / 10)
254214   MDRV_CPU_PROGRAM_MAP(main_map)
r7500r7501
297257
298258
299259
300GAME( 1977, m79amb, 0, m79amb, m79amb, m79amb, ROT0, "Ramtek", "M-79 Ambush", GAME_IMPERFECT_SOUND )
260/* grenade trajectory per gun position is inconsistent and sloppy in the game:
261     0,     1,     3,     2,     6,     7,     5,     4     - gun position
262    90.00, 90.00, 90.00, 90.00, 86.42, 86.42, 86.42, 86.42  - grenade trajectory (angle, est)
263     18.0,  18.0,  18.0,  18.0,  27.2,  27.2,  27.2,  31.2  - crosses with y=28 (x, est)
264
265    12,    13,    15,    14,    10,    11,     9,     8,
266    84.39, 84.39, 84.39, 80.87, 79.00, 80.87, 79.00, 79.00
267     41.9,  48.9,  56.8,  75.8,  87.2,  88.8, 101.6, 107.6
268
269    24,    25,    27,    26,    30,    31,    29,    28,
270    79.00, 79.00, 75.59, 75.59, 75.59, 73.72, 73.72, 73.72
271    114.1, 121.5, 138.8, 146.0, 152.7, 162.6, 167.6, 172.7
272
273    20,    21,    23,    22,    18,    19,    17,    16
274    73.72, 70.08, 70.08, 70.08, 67.97, 67.97, 64.34, 64.34
275    181.6, 199.9, 205.4, 211.9, 223.5, 232.4, 254.0, 254.0
276*/
277
278static const UINT8 lut_cross[0x20] = {
279     19,    20,    21,    23,    25,    27,    29,    37,
280     45,    53,    66,    82,    88,    95,   105,   111,
281    118,   130,   142,   149,   158,   165,   170,   177,
282    191,   203,   209,   218,   228,   243,   249,   255,
283};
284
285static const UINT8 lut_pos[0x20] = {
286    0x1f,  0x1e,  0x1c,  0x1d,  0x19,  0x18,  0x1a,  0x1b,
287    0x13,  0x12,  0x10,  0x11,  0x15,  0x14,  0x16,  0x17,
288    0x07,  0x06,  0x04,  0x05,  0x01,  0x00,  0x02,  0x03,
289    0x0b,  0x0a,  0x08,  0x09,  0x0d,  0x0c,  0x0e,  0x0f
290};
291
292
293static DRIVER_INIT( m79amb )
294{
295   m79amb_state *state = (m79amb_state *)machine->driver_data;
296   UINT8 *rom = memory_region(machine, "maincpu");
297   int i, j;
298
299   /* PROM data is active low */
300   for (i = 0; i < 0x2000; i++)
301      rom[i] = ~rom[i];
302
303   /* gun positions */
304   for (i = 0; i < 0x100; i++)
305   {
306      /* gun 1, start at left 18 */
307      for (j = 0; j < 0x20; j++)
308      {
309         if (i <= lut_cross[j])
310         {
311            state->lut_gun1[i] = lut_pos[j];
312            break;
313         }
314      }
315
316      /* gun 2, start at right 235 */
317      for (j = 0; j < 0x20; j++)
318      {
319         if (i >= (253 - lut_cross[j]))
320         {
321            state->lut_gun2[i] = lut_pos[j];
322            break;
323         }
324      }
325   }
326}
327
328GAME( 1977, m79amb, 0, m79amb, m79amb, m79amb, ROT0, "Ramtek", "M-79 Ambush", GAME_IMPERFECT_SOUND | GAME_SUPPORTS_SAVE )
src/mame/drivers/meritm.c
r7500r7501
299299 *
300300 *************************************/
301301
302static int meritm_vint = 0x00;
302static int meritm_vint = 0x18;
303303static int meritm_interrupt_vdp0_state = 0;
304304static int meritm_interrupt_vdp1_state = 0;
305305static bitmap_t *vdp0_bitmap, *vdp1_bitmap;
r7500r7501
317317
318318static void meritm_vdp0_interrupt(running_machine *machine, int i)
319319{
320   if ( meritm_interrupt_vdp0_state != i )
321   {
322      meritm_interrupt_vdp0_state = i;
323      if (i)
324         meritm_vint &= ~0x08;
325      else
326         meritm_vint |= 0x08;
327
328      if(i)
329         z80pio_p_w(meritm_z80pio[0], 0, meritm_vint);
330   }
320   /* this is not used as the v9938 interrupt callbacks are broken
321       interrupts seem to be fired quite randomly */
331322}
332323
333324static void meritm_vdp1_interrupt(running_machine *machine, int i)
334325{
335   if ( meritm_interrupt_vdp1_state != i )
336   {
337      meritm_interrupt_vdp1_state = i;
338      if (i)
339         meritm_vint &= ~0x10;
340      else
341         meritm_vint |= 0x10;
342
343      if(i)
344         z80pio_p_w(meritm_z80pio[0], 0, meritm_vint);
345   }
326   /* this is not used as the v9938 interrupt callbacks are broken
327       interrupts seem to be fired quite randomly */
346328}
347329
348330static int layer0_enabled, layer1_enabled;
r7500r7501
587569   AM_RANGE(0x22, 0x22) AM_WRITE(v9938_1_palette_w)
588570   AM_RANGE(0x23, 0x23) AM_WRITE(v9938_1_register_w)
589571   AM_RANGE(0x30, 0x33) AM_DEVREADWRITE("ppi8255", ppi8255_r, ppi8255_w)
590   AM_RANGE(0x40, 0x43) AM_DEVREADWRITE("z80pio_0", z80pio_r, z80pio_w)
591   AM_RANGE(0x50, 0x53) AM_DEVREADWRITE("z80pio_1", z80pio_r, z80pio_w)
572   AM_RANGE(0x40, 0x43) AM_DEVREADWRITE("z80pio_0", z80pio_cd_ba_r, z80pio_cd_ba_w)
573   AM_RANGE(0x50, 0x53) AM_DEVREADWRITE("z80pio_1", z80pio_cd_ba_r, z80pio_cd_ba_w)
592574   AM_RANGE(0x80, 0x80) AM_DEVREAD("aysnd", ay8910_r)
593575   AM_RANGE(0x80, 0x81) AM_DEVWRITE("aysnd", ay8910_address_data_w)
594576   AM_RANGE(0xff, 0xff) AM_WRITE(meritm_crt250_bank_w)
r7500r7501
605587   AM_RANGE(0x22, 0x22) AM_WRITE(v9938_1_palette_w)
606588   AM_RANGE(0x23, 0x23) AM_WRITE(v9938_1_register_w)
607589   AM_RANGE(0x30, 0x33) AM_DEVREADWRITE("ppi8255", ppi8255_r, ppi8255_w)
608   AM_RANGE(0x40, 0x43) AM_DEVREADWRITE("z80pio_0", z80pio_r, z80pio_w)
609   AM_RANGE(0x50, 0x53) AM_DEVREADWRITE("z80pio_1", z80pio_r, z80pio_w)
590   AM_RANGE(0x40, 0x43) AM_DEVREADWRITE("z80pio_0", z80pio_cd_ba_r, z80pio_cd_ba_w)
591   AM_RANGE(0x50, 0x53) AM_DEVREADWRITE("z80pio_1", z80pio_cd_ba_r, z80pio_cd_ba_w)
610592   AM_RANGE(0x60, 0x67) AM_READWRITE(pc16552d_0_r,pc16552d_0_w)
611593   AM_RANGE(0x80, 0x80) AM_DEVREAD("aysnd", ay8910_r)
612594   AM_RANGE(0x80, 0x81) AM_DEVWRITE("aysnd", ay8910_address_data_w)
r7500r7501
632614   AM_RANGE(0x22, 0x22) AM_WRITE(v9938_1_palette_w)
633615   AM_RANGE(0x23, 0x23) AM_WRITE(v9938_1_register_w)
634616   AM_RANGE(0x30, 0x33) AM_DEVREADWRITE("ppi8255", ppi8255_r, ppi8255_w)
635   AM_RANGE(0x40, 0x43) AM_DEVREADWRITE("z80pio_0", z80pio_r, z80pio_w)
636   AM_RANGE(0x50, 0x53) AM_DEVREADWRITE("z80pio_1", z80pio_r, z80pio_w)
617   AM_RANGE(0x40, 0x43) AM_DEVREADWRITE("z80pio_0", z80pio_cd_ba_r, z80pio_cd_ba_w)
618   AM_RANGE(0x50, 0x53) AM_DEVREADWRITE("z80pio_1", z80pio_cd_ba_r, z80pio_cd_ba_w)
637619   AM_RANGE(0x60, 0x67) AM_READWRITE(pc16552d_0_r,pc16552d_0_w)
638620   AM_RANGE(0x80, 0x80) AM_DEVREAD("aysnd", ay8910_r)
639621   AM_RANGE(0x80, 0x81) AM_DEVWRITE("aysnd", ay8910_address_data_w)
r7500r7501
833815 *
834816 *************************************/
835817
836static WRITE_LINE_DEVICE_HANDLER( meritm_audio_pio_interrupt )
818static READ8_DEVICE_HANDLER(meritm_audio_pio_port_a_r)
837819{
838   //logerror( "PIO(0) interrupt line: %d, V = %d, H = %d\n", state, video_screen_get_vpos(0), video_screen_get_hpos(0) );
839   cputag_set_input_line(device->machine, "maincpu", 0, state);
840}
820   /*
841821
842static WRITE_LINE_DEVICE_HANDLER( meritm_io_pio_interrupt  )
843{
844   //logerror( "PIO(1) interrupt line: %d, V = %d, H = %d\n", state, video_screen_get_vpos(0), video_screen_get_hpos(0) );
845   cputag_set_input_line(device->machine, "maincpu", 0, state);
846}
822        bit     signal      description
847823
824        0       BANK0
825        1       BANK1
826        2       BANK2
827        3       /VINT1      V9938 #1 INT
828        4       /VINT2      V9938 #2 INT
829        5       BANK3
830        6
831        7
848832
849static READ8_DEVICE_HANDLER(meritm_audio_pio_port_a_r)
850{
833    */
834
851835   return meritm_vint;
852836};
853837
854838static READ8_DEVICE_HANDLER(meritm_audio_pio_port_b_r)
855839{
840   /*
841
842        bit     description
843
844        0       J4 D0
845        1       J4 D1
846        2       J4 D2
847        3       J4 D3
848        4       J4 D4
849        5       J4 D5
850        6       J4 D6
851        7       J4 D7
852
853    */
854
856855   return ds1204_r();
857856};
858857
859858static WRITE8_DEVICE_HANDLER(meritm_audio_pio_port_a_w)
860859{
860   /*
861
862        bit     signal      description
863
864        0       BANK0
865        1       BANK1
866        2       BANK2
867        3       /VINT1      V9938 #1 INT
868        4       /VINT2      V9938 #2 INT
869        5       BANK3
870        6
871        7
872
873    */
874
861875   meritm_bank = (data & 7) | ((data >> 2) & 0x18);
862876   //logerror("Writing BANK with %x (raw = %x)\n", meritm_bank, data);
863877};
864878
865879static WRITE8_DEVICE_HANDLER(meritm_audio_pio_port_b_w)
866880{
881   /*
882
883        bit     description
884
885        0       J4 D0
886        1       J4 D1
887        2       J4 D2
888        3       J4 D3
889        4       J4 D4
890        5       J4 D5
891        6       J4 D6
892        7       J4 D7
893
894    */
895
867896   ds1204_w((data & 0x4) >> 2, (data & 0x2) >> 1, data & 0x01);
868897};
869898
870899static WRITE8_DEVICE_HANDLER(meritm_io_pio_port_a_w)
871900{
901   /*
902
903        bit     description
904
905        0       J3 PE0
906        1       J3 PE1
907        2       J3 PE2
908        3       J3 PE3
909        4       J3 PE4
910        5       J3 PE5
911        6       J3 PE6
912        7       J3 PE7
913
914    */
872915};
873916
874917static WRITE8_DEVICE_HANDLER(meritm_io_pio_port_b_w)
875918{
919   /*
920
921        bit     description
922
923        0       J3 PF0
924        1       J3 PF1
925        2       J3 PF2
926        3       J3 PF3
927        4       J3 PF4
928        5       J3 PF5
929        6       J3 PF6
930        7       J3 PF7
931
932    */
876933};
877934
878static const z80pio_interface meritm_audio_pio_intf =
935static Z80PIO_INTERFACE( meritm_audio_pio_intf )
879936{
880   DEVCB_LINE(meritm_audio_pio_interrupt),
937   DEVCB_CPU_INPUT_LINE("maincpu", INPUT_LINE_IRQ0),
881938   DEVCB_HANDLER(meritm_audio_pio_port_a_r),
939   DEVCB_HANDLER(meritm_audio_pio_port_a_w),
940   DEVCB_NULL,
882941   DEVCB_HANDLER(meritm_audio_pio_port_b_r),
883   DEVCB_HANDLER(meritm_audio_pio_port_a_w),
884942   DEVCB_HANDLER(meritm_audio_pio_port_b_w),
885   DEVCB_NULL,
886943   DEVCB_NULL
887944};
888945
889static const z80pio_interface meritm_io_pio_intf =
946static Z80PIO_INTERFACE( meritm_io_pio_intf )
890947{
891   DEVCB_LINE(meritm_io_pio_interrupt),
948   DEVCB_CPU_INPUT_LINE("maincpu", INPUT_LINE_IRQ0),
892949   DEVCB_INPUT_PORT("PIO1_PORTA"),
950   DEVCB_HANDLER(meritm_io_pio_port_a_w),
951   DEVCB_NULL,
893952   DEVCB_INPUT_PORT("PIO1_PORTB"),
894   DEVCB_HANDLER(meritm_io_pio_port_a_w),
895953   DEVCB_HANDLER(meritm_io_pio_port_b_w),
896   DEVCB_NULL,
897954   DEVCB_NULL
898955};
899956
900957static const z80_daisy_chain meritm_daisy_chain[] =
901958{
959   { "z80pio_0" },
902960   { "z80pio_1" },
903   { "z80pio_0" },
904961   { NULL }
905962};
906963
r7500r7501
909966   meritm_z80pio[0] = devtag_get_device( machine, "z80pio_0" );
910967   meritm_z80pio[1] = devtag_get_device( machine, "z80pio_1" );
911968
969   z80pio_astb_w(meritm_z80pio[0], 1);
970   z80pio_bstb_w(meritm_z80pio[0], 1);
971   z80pio_astb_w(meritm_z80pio[1], 1);
972   z80pio_bstb_w(meritm_z80pio[1], 1);
912973};
913974
914975static MACHINE_START(meritm_crt250)
r7500r7501
9721033#define MSX2_VISIBLE_XBORDER_PIXELS   8 * 2
9731034#define MSX2_VISIBLE_YBORDER_PIXELS   14 * 2
9741035
1036static TIMER_DEVICE_CALLBACK( vblank_start_tick )
1037{
1038   /* this is a workaround to signal the v9938 vblank interrupt correctly */
1039   meritm_vint = 0x08;
1040   z80pio_pa_w(meritm_z80pio[0], 0, meritm_vint);
1041}
1042
1043static TIMER_DEVICE_CALLBACK( vblank_end_tick )
1044{
1045   /* this is a workaround to signal the v9938 vblank interrupt correctly */
1046   meritm_vint = 0x18;
1047   z80pio_pa_w(meritm_z80pio[0], 0, meritm_vint);
1048}
1049
9751050static MACHINE_DRIVER_START(meritm_crt250)
9761051   MDRV_CPU_ADD("maincpu", Z80, SYSTEM_CLK/6)
9771052   MDRV_CPU_PROGRAM_MAP(meritm_crt250_map)
r7500r7501
9831058
9841059   MDRV_PPI8255_ADD( "ppi8255", crt250_ppi8255_intf )
9851060
986   MDRV_Z80PIO_ADD( "z80pio_0", meritm_audio_pio_intf )
987   MDRV_Z80PIO_ADD( "z80pio_1", meritm_io_pio_intf )
1061   MDRV_Z80PIO_ADD( "z80pio_0", SYSTEM_CLK/6, meritm_audio_pio_intf )
1062   MDRV_Z80PIO_ADD( "z80pio_1", SYSTEM_CLK/6, meritm_io_pio_intf )
9881063
1064   MDRV_TIMER_ADD_SCANLINE("vblank_start", vblank_start_tick, "screen", 259, 262)
1065   MDRV_TIMER_ADD_SCANLINE("vblank_end",   vblank_end_tick,   "screen", 262, 262)
1066
9891067   MDRV_NVRAM_HANDLER(generic_0fill)
9901068
9911069   MDRV_VIDEO_ATTRIBUTES(VIDEO_UPDATE_BEFORE_VBLANK)
src/mame/drivers/wardner.c
r7500r7501
1818          except for the Main CPU which is a Z80 here.
1919        See twincobr.c machine and video drivers to complete the
2020          hardware setup.
21        Also see Input Port definition header below, for instructions
22          on how to enter test mode.
21        To enter the "test mode", press START1 when the grid is displayed.
22        Press F1 (initially P1 button 3) on startup to skip some video RAM tests
23        (code at 0x6d25 in 'wardner', 0x6d2f in 'wardnerj' or 0x6d2c in 'pyros').
2324
2425**************************** Memory & I/O Maps *****************************
2526Z80:(0)  Main CPU
r7500r7501
126127#include "emu.h"
127128#include "cpu/z80/z80.h"
128129#include "cpu/tms32010/tms32010.h"
130#include "includes/toaplipt.h"
129131#include "includes/twincobr.h"
130132#include "sound/3812intf.h"
131133
r7500r7501
255257ADDRESS_MAP_END
256258
257259
258
259
260260/*****************************************************************************
261
261262    Input Port definitions
262263
263    There is a test mode for button/switch tests. To enter Test mode,
264    set the Cross Hatch Pattern DSW to on, restart and then press
265    player 1 start button when in the cross-hatch screen.
266264*****************************************************************************/
267265
268#define  WARDNER_PLAYER_INPUT( player )      /* Player 1 button 3 skips video RAM tests */    \
269   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP ) PORT_PLAYER(player) PORT_8WAY \
270   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN ) PORT_PLAYER(player) PORT_8WAY \
271   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT ) PORT_PLAYER(player) PORT_8WAY \
272   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT ) PORT_PLAYER(player) PORT_8WAY \
273   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_PLAYER(player)   /* Fire */       \
274   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_BUTTON2 ) PORT_PLAYER(player)   /* Jump */       \
275   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_BUTTON3 ) PORT_PLAYER(player)   /* Shot C */    \
276   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_BUTTON4 ) PORT_PLAYER(player)   /* Shot D */
277
278static INPUT_PORTS_START( wardner )
279   PORT_START("SYSTEM")   /* test button doesnt seem to do anything ? */
280   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_COIN3 )      /* Service button */
281   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_TILT )
282   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_UNUSED )   /* Test button */
283   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_COIN1 )
284   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_COIN2 )
285   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_START1 )
286   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_START2 )
287   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_VBLANK )   /* V-Blank */
288
289   PORT_START("P1")
290   WARDNER_PLAYER_INPUT( 1 )
291
292   PORT_START("P2")
293   WARDNER_PLAYER_INPUT( 2 )
294
266/* verified from Z80 code */
267static INPUT_PORTS_START( wardner_generic )
295268   PORT_START("DSWA")
296   PORT_DIPNAME( 0x01, 0x01, DEF_STR( Cabinet ) )
297   PORT_DIPSETTING(   0x01, DEF_STR( Upright ) )
298   PORT_DIPSETTING(   0x00, DEF_STR( Cocktail ) )
299   PORT_DIPNAME( 0x02, 0x00, DEF_STR( Flip_Screen ) )
300   PORT_DIPSETTING(   0x00, DEF_STR( Off ) )
301   PORT_DIPSETTING(   0x02, DEF_STR( On ) )
302   PORT_DIPNAME( 0x04, 0x00, "Cross Hatch Pattern" )
303   PORT_DIPSETTING(   0x00, DEF_STR( Off ) )
304   PORT_DIPSETTING(   0x04, DEF_STR( On ) )
305   PORT_DIPNAME( 0x08, 0x00, DEF_STR( Demo_Sounds ) )
306   PORT_DIPSETTING(   0x08, DEF_STR( Off ) )
307   PORT_DIPSETTING(   0x00, DEF_STR( On ) )
308   PORT_DIPNAME( 0x30, 0x00, DEF_STR( Coin_A ) )
309   PORT_DIPSETTING(   0x30, DEF_STR( 4C_1C ) )
310   PORT_DIPSETTING(   0x20, DEF_STR( 3C_1C ) )
311   PORT_DIPSETTING(   0x10, DEF_STR( 2C_1C ) )
312   PORT_DIPSETTING(   0x00, DEF_STR( 1C_1C ) )
313   PORT_DIPNAME( 0xc0, 0x00, DEF_STR( Coin_B ) )
314   PORT_DIPSETTING(   0x00, DEF_STR( 1C_2C ) )
315   PORT_DIPSETTING(   0x40, DEF_STR( 1C_3C ) )
316   PORT_DIPSETTING(   0x80, DEF_STR( 1C_4C ) )
317   PORT_DIPSETTING(   0xc0, DEF_STR( 1C_6C ) )
269   TOAPLAN_MACHINE_COCKTAIL
270   TOAPLAN_COINAGE_WORLD
318271
319272   PORT_START("DSWB")
320   PORT_DIPNAME( 0x03, 0x00, DEF_STR( Difficulty ) )
321   PORT_DIPSETTING(   0x01, DEF_STR( Easy ) )
322   PORT_DIPSETTING(   0x00, DEF_STR( Normal ) )
323   PORT_DIPSETTING(   0x02, DEF_STR( Hard ) )
324   PORT_DIPSETTING(   0x03, DEF_STR( Hardest ) )
325   PORT_DIPNAME( 0x0c, 0x00, DEF_STR( Bonus_Life ) )
326   PORT_DIPSETTING(   0x00, "30000 & 80000" )
327   PORT_DIPSETTING(   0x04, "50000 & 100000" )
328   PORT_DIPSETTING(   0x08, "50000" )
329   PORT_DIPSETTING(   0x0c, "100000" )
273   TOAPLAN_DIFFICULTY
274   PORT_DIPNAME( 0x0c, 0x00, DEF_STR( Bonus_Life ) )       /* table at 0x13ce ('wardner') or 0x13de ('wardnerj') */
275   PORT_DIPSETTING(   0x00, "30k 80k 50k+" )
276   PORT_DIPSETTING(   0x04, "50k 100k 50k+" )
277   PORT_DIPSETTING(   0x08, "30k Only" )
278   PORT_DIPSETTING(   0x0c, "50k Only" )
330279   PORT_DIPNAME( 0x30, 0x00, DEF_STR( Lives ) )
331280   PORT_DIPSETTING(   0x30, "1" )
332281   PORT_DIPSETTING(   0x00, "3" )
333282   PORT_DIPSETTING(   0x10, "4" )
334283   PORT_DIPSETTING(   0x20, "5" )
335   PORT_DIPNAME( 0x40, 0x00, DEF_STR( Unknown ) )
336   PORT_DIPSETTING(   0x00, DEF_STR( Off ) )
337   PORT_DIPSETTING(   0x40, DEF_STR( On ) )
338   PORT_DIPNAME( 0x80, 0x00, DEF_STR( Unknown ) )
339   PORT_DIPSETTING(   0x00, DEF_STR( Off ) )
340   PORT_DIPSETTING(   0x80, DEF_STR( On ) )
284   PORT_DIPUNUSED( 0x40, IP_ACTIVE_HIGH )
285   PORT_DIPUNUSED( 0x80, IP_ACTIVE_HIGH )
286
287   PORT_START("P1")
288   TOAPLAN_JOY_UDLR_2_BUTTONS( 1 )                         /* buttons 3 & 4 named "SHOTC" and "SHOTD" in "test mode" */
289
290   PORT_START("P2")
291   TOAPLAN_JOY_UDLR_2_BUTTONS( 2 )                         /* buttons 3 & 4 named "SHOTC" and "SHOTD" in "test mode" */
292
293   PORT_START("SYSTEM")
294   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_SERVICE1 )
295   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_TILT )
296   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_UNUSED )            /* "TEST" in "test mode" - no effect outside */
297   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_COIN1 )
298   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_COIN2 )
299   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_START1 )
300   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_START2 )
301   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_VBLANK )            /* "V-BLANKING" in "test mode" */
341302INPUT_PORTS_END
342303
304/* verified from Z80 code */
305static INPUT_PORTS_START( wardner )
306   PORT_INCLUDE( wardner_generic )
307
308   PORT_MODIFY("P1")
309   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_OTHER ) PORT_NAME("Skip Video RAM Tests") PORT_CODE(KEYCODE_F1)
310   /* code at 0x6d25 ('wardner'), 0x6d2f ('wardnerj') or 0x6d2c ('pyros') */
311INPUT_PORTS_END
312
313/* verified from Z80 code */
343314static INPUT_PORTS_START( wardnerj )
344315   PORT_INCLUDE( wardner )
345316
346317   PORT_MODIFY("DSWA")
347   PORT_DIPNAME( 0x30, 0x00, DEF_STR( Coin_A ) )
348   PORT_DIPSETTING(   0x20, DEF_STR( 2C_1C ) )
349   PORT_DIPSETTING(   0x00, DEF_STR( 1C_1C ) )
350   PORT_DIPSETTING(   0x30, DEF_STR( 2C_3C ) )
351   PORT_DIPSETTING(   0x10, DEF_STR( 1C_2C ) )
352   PORT_DIPNAME( 0xc0, 0x00, DEF_STR( Coin_B ) )
353   PORT_DIPSETTING(   0x80, DEF_STR( 2C_1C ) )
354   PORT_DIPSETTING(   0x00, DEF_STR( 1C_1C ) )
355   PORT_DIPSETTING(   0xc0, DEF_STR( 2C_3C ) )
356   PORT_DIPSETTING(   0x40, DEF_STR( 1C_2C ) )
318   TOAPLAN_COINAGE_JAPAN_OLD
357319INPUT_PORTS_END
358320
321/* verified from Z80 code */
359322static INPUT_PORTS_START( pyros )
360   PORT_INCLUDE( wardner )
323   PORT_INCLUDE( wardnerj )
361324
362   PORT_MODIFY("DSWA")
363   PORT_DIPNAME( 0x30, 0x00, DEF_STR( Coin_A ) )
364   PORT_DIPSETTING(   0x20, DEF_STR( 2C_1C ) )
365   PORT_DIPSETTING(   0x00, DEF_STR( 1C_1C ) )
366   PORT_DIPSETTING(   0x30, DEF_STR( 2C_3C ) )
367   PORT_DIPSETTING(   0x10, DEF_STR( 1C_2C ) )
368   PORT_DIPNAME( 0xc0, 0x00, DEF_STR( Coin_B ) )
369   PORT_DIPSETTING(   0x80, DEF_STR( 2C_1C ) )
370   PORT_DIPSETTING(   0x00, DEF_STR( 1C_1C ) )
371   PORT_DIPSETTING(   0xc0, DEF_STR( 2C_3C ) )
372   PORT_DIPSETTING(   0x40, DEF_STR( 1C_2C ) )
373
374325   PORT_MODIFY("DSWB")
375   PORT_DIPNAME( 0x40, 0x00, DEF_STR( Allow_Continue ) )
326   PORT_DIPNAME( 0x0c, 0x00, DEF_STR( Bonus_Life ) )       /* table at 0x13ce */
327   PORT_DIPSETTING(   0x00, "30k 80k 50k+" )
328   PORT_DIPSETTING(   0x04, "50k 100k 50k+" )
329   PORT_DIPSETTING(   0x08, "50k Only" )
330   PORT_DIPSETTING(   0x0c, "100k Only" )
331   PORT_DIPNAME( 0x40, 0x00, DEF_STR( Allow_Continue ) )   /* additional code at 0x6037 */
376332   PORT_DIPSETTING(   0x40, DEF_STR( No ) )
377333   PORT_DIPSETTING(   0x00, DEF_STR( Yes ) )
378334INPUT_PORTS_END
src/mame/drivers/cninja.c
r7500r7501
4343#include "emu.h"
4444#include "cpu/z80/z80.h"
4545#include "cpu/m68000/m68000.h"
46#include "cpu/h6280/h6280.h"
4647#include "includes/cninja.h"
47#include "cpu/h6280/h6280.h"
48#include "includes/deco16ic.h"
4948#include "includes/decocrpt.h"
5049#include "includes/decoprot.h"
5150#include "sound/2203intf.h"
5251#include "sound/2151intf.h"
5352#include "sound/okim6295.h"
53#include "video/deco16ic.h"
5454
55static int cninja_scanline, cninja_irq_mask;
56static running_device *raster_irq_timer;
57static UINT16 *cninja_ram;
5855
59/**********************************************************************************/
60
6156static WRITE16_HANDLER( cninja_sound_w )
6257{
63   soundlatch_w(space,0,data&0xff);
64   cputag_set_input_line(space->machine, "audiocpu", 0, HOLD_LINE);
58   cninja_state *state = (cninja_state *)space->machine->driver_data;
59
60   soundlatch_w(space, 0, data & 0xff);
61   cpu_set_input_line(state->audiocpu, 0, HOLD_LINE);
6562}
6663
6764static WRITE16_HANDLER( stoneage_sound_w )
6865{
69   soundlatch_w(space,0,data&0xff);
70   cputag_set_input_line(space->machine, "audiocpu", INPUT_LINE_NMI, PULSE_LINE);
66   cninja_state *state = (cninja_state *)space->machine->driver_data;
67
68   soundlatch_w(space, 0, data & 0xff);
69   cpu_set_input_line(state->audiocpu, INPUT_LINE_NMI, PULSE_LINE);
7170}
7271
7372static TIMER_DEVICE_CALLBACK( interrupt_gen )
7473{
75   cputag_set_input_line(timer->machine, "maincpu", (cninja_irq_mask&0x10) ? 3 : 4, ASSERT_LINE);
76   timer_device_adjust_oneshot(raster_irq_timer, attotime_never, 0);
74   cninja_state *state = (cninja_state *)timer->machine->driver_data;
75
76   cpu_set_input_line(state->maincpu, (state->irq_mask & 0x10) ? 3 : 4, ASSERT_LINE);
77   timer_device_adjust_oneshot(state->raster_irq_timer, attotime_never, 0);
7778}
7879
7980static READ16_HANDLER( cninja_irq_r )
8081{
81   switch (offset) {
82   cninja_state *state = (cninja_state *)space->machine->driver_data;
8283
84   switch (offset)
85   {
86
8387   case 1: /* Raster IRQ scanline position */
84      return cninja_scanline;
88      return state->scanline;
8589
8690   case 2: /* Raster IRQ ACK - value read is not used */
87      cputag_set_input_line(space->machine, "maincpu", 3, CLEAR_LINE);
88      cputag_set_input_line(space->machine, "maincpu", 4, CLEAR_LINE);
91      cpu_set_input_line(state->maincpu, 3, CLEAR_LINE);
92      cpu_set_input_line(state->maincpu, 4, CLEAR_LINE);
8993      return 0;
9094   }
9195
92   logerror("%08x:  Unmapped IRQ read %d\n",cpu_get_pc(space->cpu),offset);
96   logerror("%08x:  Unmapped IRQ read %d\n", cpu_get_pc(space->cpu), offset);
9397   return 0;
9498}
9599
96100static WRITE16_HANDLER( cninja_irq_w )
97101{
98   switch (offset) {
102   cninja_state *state = (cninja_state *)space->machine->driver_data;
103
104   switch (offset)
105   {
99106   case 0:
100107      /* IRQ enable:
101108            0xca:   Raster IRQ turned off
102109            0xc8:   Raster IRQ turned on (68k IRQ level 4)
103110            0xd8:   Raster IRQ turned on (68k IRQ level 3)
104111        */
105      logerror("%08x:  IRQ write %d %08x\n",cpu_get_pc(space->cpu),offset,data);
106      cninja_irq_mask=data&0xff;
112      logerror("%08x:  IRQ write %d %08x\n", cpu_get_pc(space->cpu), offset, data);
113      state->irq_mask = data & 0xff;
107114      return;
108115
109116   case 1: /* Raster IRQ scanline position, only valid for values between 1 & 239 (0 and 240-256 do NOT generate IRQ's) */
110      cninja_scanline=data&0xff;
111      if ((cninja_irq_mask&0x2)==0 && cninja_scanline>0 && cninja_scanline<240)
112      {
113         timer_device_adjust_oneshot(raster_irq_timer, video_screen_get_time_until_pos(space->machine->primary_screen, cninja_scanline, 0), cninja_scanline);
114      }
117      state->scanline = data & 0xff;
118
119      if (!BIT(state->irq_mask, 1) && state->scanline > 0 && state->scanline < 240)
120         timer_device_adjust_oneshot(state->raster_irq_timer, video_screen_get_time_until_pos(space->machine->primary_screen, state->scanline, 0), state->scanline);
115121      else
116         timer_device_adjust_oneshot(raster_irq_timer,attotime_never,0);
122         timer_device_adjust_oneshot(state->raster_irq_timer, attotime_never, 0);
117123      return;
118124
119125   case 2: /* VBL irq ack */
120126      return;
121127   }
122128
123   logerror("%08x:  Unmapped IRQ write %d %04x\n",cpu_get_pc(space->cpu),offset,data);
129   logerror("%08x:  Unmapped IRQ write %d %04x\n", cpu_get_pc(space->cpu), offset, data);
124130}
125131
126132static READ16_HANDLER( robocop2_prot_r )
127133{
128   switch (offset<<1) {
134   switch (offset << 1)
135   {
129136      case 0x41a: /* Player 1 & 2 input ports */
130137         return input_port_read(space->machine, "IN0");
131138      case 0x320: /* Coins */
r7500r7501
133140      case 0x4e6: /* Dip switches */
134141         return input_port_read(space->machine, "DSW");
135142      case 0x504: /* PC: 6b6.  b4, 2c, 36 written before read */
136         logerror("Protection PC %06x: warning - read unmapped memory address %04x\n",cpu_get_pc(space->cpu),offset);
143         logerror("Protection PC %06x: warning - read unmapped memory address %04x\n", cpu_get_pc(space->cpu), offset);
137144         return 0x84;
138145   }
139   logerror("Protection PC %06x: warning - read unmapped memory address %04x\n",cpu_get_pc(space->cpu),offset);
146   logerror("Protection PC %06x: warning - read unmapped memory address %04x\n", cpu_get_pc(space->cpu), offset);
140147   return 0;
141148}
142149
143150/**********************************************************************************/
144151
145static WRITE16_HANDLER( deco16_pf12_control_w )
152static WRITE16_HANDLER( cninja_pf12_control_w )
146153{
147   COMBINE_DATA(&deco16_pf12_control[offset]);
154   cninja_state *state = (cninja_state *)space->machine->driver_data;
155   deco16ic_pf12_control_w(state->deco16ic, offset, data, mem_mask);
148156   video_screen_update_partial(space->machine->primary_screen, video_screen_get_vpos(space->machine->primary_screen));
149157}
150158
151159
152static WRITE16_HANDLER( deco16_pf34_control_w )
160static WRITE16_HANDLER( cninja_pf34_control_w )
153161{
154   COMBINE_DATA(&deco16_pf34_control[offset]);
162   cninja_state *state = (cninja_state *)space->machine->driver_data;
163   deco16ic_pf34_control_w(state->deco16ic, offset, data, mem_mask);
155164   video_screen_update_partial(space->machine->primary_screen, video_screen_get_vpos(space->machine->primary_screen));
156165}
157166
r7500r7501
159168static ADDRESS_MAP_START( cninja_map, ADDRESS_SPACE_PROGRAM, 16 )
160169   AM_RANGE(0x000000, 0x0bffff) AM_ROM
161170
162   AM_RANGE(0x140000, 0x14000f) AM_WRITE(deco16_pf12_control_w) AM_BASE(&deco16_pf12_control)
163   AM_RANGE(0x144000, 0x144fff) AM_RAM_WRITE(deco16_pf1_data_w) AM_BASE(&deco16_pf1_data)
164   AM_RANGE(0x146000, 0x146fff) AM_RAM_WRITE(deco16_pf2_data_w) AM_BASE(&deco16_pf2_data)
165   AM_RANGE(0x14c000, 0x14c7ff) AM_WRITEONLY AM_BASE(&deco16_pf1_rowscroll)
166   AM_RANGE(0x14e000, 0x14e7ff) AM_RAM AM_BASE(&deco16_pf2_rowscroll)
171   AM_RANGE(0x140000, 0x14000f) AM_WRITE(cninja_pf12_control_w)
172   AM_RANGE(0x144000, 0x144fff) AM_DEVREADWRITE("deco_custom", deco16ic_pf1_data_r, deco16ic_pf1_data_w)
173   AM_RANGE(0x146000, 0x146fff) AM_DEVREADWRITE("deco_custom", deco16ic_pf2_data_r, deco16ic_pf2_data_w)
174   AM_RANGE(0x14c000, 0x14c7ff) AM_WRITEONLY AM_BASE_MEMBER(cninja_state, pf1_rowscroll)
175   AM_RANGE(0x14e000, 0x14e7ff) AM_RAM AM_BASE_MEMBER(cninja_state, pf2_rowscroll)
167176
168   AM_RANGE(0x150000, 0x15000f) AM_WRITE(deco16_pf34_control_w) AM_BASE(&deco16_pf34_control)
169   AM_RANGE(0x154000, 0x154fff) AM_RAM_WRITE(deco16_pf3_data_w) AM_BASE(&deco16_pf3_data)
170   AM_RANGE(0x156000, 0x156fff) AM_RAM_WRITE(deco16_pf4_data_w) AM_BASE(&deco16_pf4_data)
171   AM_RANGE(0x15c000, 0x15c7ff) AM_RAM AM_BASE(&deco16_pf3_rowscroll)
172   AM_RANGE(0x15e000, 0x15e7ff) AM_RAM AM_BASE(&deco16_pf4_rowscroll)
177   AM_RANGE(0x150000, 0x15000f) AM_WRITE(cninja_pf34_control_w)
178   AM_RANGE(0x154000, 0x154fff) AM_DEVREADWRITE("deco_custom", deco16ic_pf3_data_r, deco16ic_pf3_data_w)
179   AM_RANGE(0x156000, 0x156fff) AM_DEVREADWRITE("deco_custom", deco16ic_pf4_data_r, deco16ic_pf4_data_w)
180   AM_RANGE(0x15c000, 0x15c7ff) AM_RAM AM_BASE_MEMBER(cninja_state, pf3_rowscroll)
181   AM_RANGE(0x15e000, 0x15e7ff) AM_RAM AM_BASE_MEMBER(cninja_state, pf4_rowscroll)
173182
174   AM_RANGE(0x184000, 0x187fff) AM_RAM AM_BASE(&cninja_ram)
183   AM_RANGE(0x184000, 0x187fff) AM_RAM AM_BASE_MEMBER(cninja_state, ram)
175184   AM_RANGE(0x190000, 0x190007) AM_READWRITE(cninja_irq_r, cninja_irq_w)
176   AM_RANGE(0x19c000, 0x19dfff) AM_RAM_WRITE(deco16_nonbuffered_palette_w) AM_BASE_GENERIC(paletteram)
185   AM_RANGE(0x19c000, 0x19dfff) AM_RAM_DEVWRITE("deco_custom", deco16ic_nonbuffered_palette_w) AM_BASE_GENERIC(paletteram)
177186
178   AM_RANGE(0x1a4000, 0x1a47ff) AM_RAM AM_BASE_SIZE_GENERIC(spriteram)             /* Sprites */
187   AM_RANGE(0x1a4000, 0x1a47ff) AM_RAM AM_BASE_SIZE_GENERIC(spriteram)         /* Sprites */
179188   AM_RANGE(0x1b4000, 0x1b4001) AM_WRITE(buffer_spriteram16_w) /* DMA flag */
180189   AM_RANGE(0x1bc000, 0x1bc0ff) AM_WRITE(deco16_104_cninja_prot_w) AM_BASE(&deco16_prot_ram)      /* Protection writes */
181190   AM_RANGE(0x1bc000, 0x1bcfff) AM_READ(deco16_104_cninja_prot_r) AM_BASE(&deco16_prot_ram)      /* Protection device */
r7500r7501
193202
194203   AM_RANGE(0x138000, 0x1387ff) AM_RAM AM_BASE_SIZE_GENERIC(spriteram) /* bootleg sprite-ram (sprites rewritten here in new format) */
195204
196   AM_RANGE(0x140000, 0x14000f) AM_WRITE(deco16_pf12_control_w) AM_BASE(&deco16_pf12_control)
197   AM_RANGE(0x144000, 0x144fff) AM_RAM_WRITE(deco16_pf1_data_w) AM_BASE(&deco16_pf1_data)
198   AM_RANGE(0x146000, 0x146fff) AM_RAM_WRITE(deco16_pf2_data_w) AM_BASE(&deco16_pf2_data)
199   AM_RANGE(0x14c000, 0x14c7ff) AM_WRITEONLY AM_BASE(&deco16_pf1_rowscroll)
200   AM_RANGE(0x14e000, 0x14e7ff) AM_RAM AM_BASE(&deco16_pf2_rowscroll)
205   AM_RANGE(0x140000, 0x14000f) AM_WRITE(cninja_pf12_control_w)
206   AM_RANGE(0x144000, 0x144fff) AM_DEVREADWRITE("deco_custom", deco16ic_pf1_data_r, deco16ic_pf1_data_w)
207   AM_RANGE(0x146000, 0x146fff) AM_DEVREADWRITE("deco_custom", deco16ic_pf2_data_r, deco16ic_pf2_data_w)
208   AM_RANGE(0x14c000, 0x14c7ff) AM_WRITEONLY AM_BASE_MEMBER(cninja_state, pf1_rowscroll)
209   AM_RANGE(0x14e000, 0x14e7ff) AM_RAM AM_BASE_MEMBER(cninja_state, pf2_rowscroll)
201210
202   AM_RANGE(0x150000, 0x15000f) AM_WRITE(deco16_pf34_control_w) AM_BASE(&deco16_pf34_control) // not used / incorrect on this
203   AM_RANGE(0x154000, 0x154fff) AM_RAM_WRITE(deco16_pf3_data_w) AM_BASE(&deco16_pf3_data)
204   AM_RANGE(0x156000, 0x156fff) AM_RAM_WRITE(deco16_pf4_data_w) AM_BASE(&deco16_pf4_data)
205   AM_RANGE(0x15c000, 0x15c7ff) AM_RAM AM_BASE(&deco16_pf3_rowscroll)
206   AM_RANGE(0x15e000, 0x15e7ff) AM_RAM AM_BASE(&deco16_pf4_rowscroll)
211   AM_RANGE(0x150000, 0x15000f) AM_WRITE(cninja_pf34_control_w)   // not used / incorrect on this
212   AM_RANGE(0x154000, 0x154fff) AM_DEVREADWRITE("deco_custom", deco16ic_pf3_data_r, deco16ic_pf3_data_w)
213   AM_RANGE(0x156000, 0x156fff) AM_DEVREADWRITE("deco_custom", deco16ic_pf4_data_r, deco16ic_pf4_data_w)
214   AM_RANGE(0x15c000, 0x15c7ff) AM_RAM AM_BASE_MEMBER(cninja_state, pf3_rowscroll)
215   AM_RANGE(0x15e000, 0x15e7ff) AM_RAM AM_BASE_MEMBER(cninja_state, pf4_rowscroll)
207216
208217   AM_RANGE(0x17ff22, 0x17ff23) AM_READ_PORT("DSW")
209218   AM_RANGE(0x17ff28, 0x17ff29) AM_READ_PORT("IN1")
210   AM_RANGE(0x17ff2a, 0x17ff2b) AM_WRITE( cninjabl_soundlatch_w )
219   AM_RANGE(0x17ff2a, 0x17ff2b) AM_WRITE(cninjabl_soundlatch_w)
211220   AM_RANGE(0x17ff2c, 0x17ff2d) AM_READ_PORT("IN0")
212221
213222   AM_RANGE(0x180000, 0x187fff) AM_RAM // more ram on bootleg?
214223
215224   AM_RANGE(0x190000, 0x190007) AM_READWRITE(cninja_irq_r, cninja_irq_w)
216   AM_RANGE(0x19c000, 0x19dfff) AM_RAM_WRITE(deco16_nonbuffered_palette_w) AM_BASE_GENERIC(paletteram)
225   AM_RANGE(0x19c000, 0x19dfff) AM_RAM_DEVWRITE("deco_custom", deco16ic_nonbuffered_palette_w) AM_BASE_GENERIC(paletteram)
217226
218227   AM_RANGE(0x1b4000, 0x1b4001) AM_WRITE(buffer_spriteram16_w) /* DMA flag */
219228ADDRESS_MAP_END
r7500r7501
221230static ADDRESS_MAP_START( edrandy_map, ADDRESS_SPACE_PROGRAM, 16 )
222231   AM_RANGE(0x000000, 0x0fffff) AM_ROM
223232
224   AM_RANGE(0x140000, 0x14000f) AM_WRITE(deco16_pf12_control_w) AM_BASE(&deco16_pf12_control)
225   AM_RANGE(0x144000, 0x144fff) AM_RAM_WRITE(deco16_pf1_data_w) AM_BASE(&deco16_pf1_data)
226   AM_RANGE(0x146000, 0x146fff) AM_RAM_WRITE(deco16_pf2_data_w) AM_BASE(&deco16_pf2_data)
227   AM_RANGE(0x14c000, 0x14c7ff) AM_RAM AM_BASE(&deco16_pf1_rowscroll)
228   AM_RANGE(0x14e000, 0x14e7ff) AM_RAM AM_BASE(&deco16_pf2_rowscroll)
233   AM_RANGE(0x140000, 0x14000f) AM_WRITE(cninja_pf12_control_w)
234   AM_RANGE(0x144000, 0x144fff) AM_DEVREADWRITE("deco_custom", deco16ic_pf1_data_r, deco16ic_pf1_data_w)
235   AM_RANGE(0x146000, 0x146fff) AM_DEVREADWRITE("deco_custom", deco16ic_pf2_data_r, deco16ic_pf2_data_w)
236   AM_RANGE(0x14c000, 0x14c7ff) AM_RAM AM_BASE_MEMBER(cninja_state, pf1_rowscroll)
237   AM_RANGE(0x14e000, 0x14e7ff) AM_RAM AM_BASE_MEMBER(cninja_state, pf2_rowscroll)
229238
230   AM_RANGE(0x150000, 0x15000f) AM_WRITE(deco16_pf34_control_w) AM_BASE(&deco16_pf34_control)
231   AM_RANGE(0x154000, 0x154fff) AM_RAM_WRITE(deco16_pf3_data_w) AM_BASE(&deco16_pf3_data)
232   AM_RANGE(0x156000, 0x156fff) AM_RAM_WRITE(deco16_pf4_data_w) AM_BASE(&deco16_pf4_data)
233   AM_RANGE(0x15c000, 0x15c7ff) AM_RAM AM_BASE(&deco16_pf3_rowscroll)
234   AM_RANGE(0x15e000, 0x15e7ff) AM_RAM AM_BASE(&deco16_pf4_rowscroll)
239   AM_RANGE(0x150000, 0x15000f) AM_WRITE(cninja_pf34_control_w)
240   AM_RANGE(0x154000, 0x154fff) AM_DEVREADWRITE("deco_custom", deco16ic_pf3_data_r, deco16ic_pf3_data_w)
241   AM_RANGE(0x156000, 0x156fff) AM_DEVREADWRITE("deco_custom", deco16ic_pf4_data_r, deco16ic_pf4_data_w)
242   AM_RANGE(0x15c000, 0x15c7ff) AM_RAM AM_BASE_MEMBER(cninja_state, pf3_rowscroll)
243   AM_RANGE(0x15e000, 0x15e7ff) AM_RAM AM_BASE_MEMBER(cninja_state, pf4_rowscroll)
235244
236   AM_RANGE(0x188000, 0x189fff) AM_RAM_WRITE(deco16_nonbuffered_palette_w) AM_BASE_GENERIC(paletteram)
237   AM_RANGE(0x194000, 0x197fff) AM_RAM AM_BASE(&cninja_ram) /* Main ram */
245   AM_RANGE(0x188000, 0x189fff) AM_RAM_DEVWRITE("deco_custom", deco16ic_nonbuffered_palette_w) AM_BASE_GENERIC(paletteram)
246   AM_RANGE(0x194000, 0x197fff) AM_RAM AM_BASE_MEMBER(cninja_state, ram) /* Main ram */
238247   AM_RANGE(0x198000, 0x1987ff) AM_READWRITE(deco16_60_prot_r, deco16_60_prot_w) AM_BASE(&deco16_prot_ram) /* Protection device */
239248   AM_RANGE(0x199550, 0x199551) AM_WRITENOP /* Looks like a bug in game code, a protection write is referenced off a5 instead of a6 and ends up here */
240249   AM_RANGE(0x199750, 0x199751) AM_WRITENOP /* Looks like a bug in game code, a protection write is referenced off a5 instead of a6 and ends up here */
r7500r7501
249258static ADDRESS_MAP_START( robocop2_map, ADDRESS_SPACE_PROGRAM, 16 )
250259   AM_RANGE(0x000000, 0x0fffff) AM_ROM
251260
252   AM_RANGE(0x140000, 0x14000f) AM_WRITE(deco16_pf12_control_w) AM_BASE(&deco16_pf12_control)
253   AM_RANGE(0x144000, 0x144fff) AM_RAM_WRITE(deco16_pf1_data_w) AM_BASE(&deco16_pf1_data)
254   AM_RANGE(0x146000, 0x146fff) AM_RAM_WRITE(deco16_pf2_data_w) AM_BASE(&deco16_pf2_data)
255   AM_RANGE(0x14c000, 0x14c7ff) AM_RAM AM_BASE(&deco16_pf1_rowscroll)
256   AM_RANGE(0x14e000, 0x14e7ff) AM_RAM AM_BASE(&deco16_pf2_rowscroll)
261   AM_RANGE(0x140000, 0x14000f) AM_WRITE(cninja_pf12_control_w)
262   AM_RANGE(0x144000, 0x144fff) AM_DEVREADWRITE("deco_custom", deco16ic_pf1_data_r, deco16ic_pf1_data_w)
263   AM_RANGE(0x146000, 0x146fff) AM_DEVREADWRITE("deco_custom", deco16ic_pf2_data_r, deco16ic_pf2_data_w)
264   AM_RANGE(0x14c000, 0x14c7ff) AM_RAM AM_BASE_MEMBER(cninja_state, pf1_rowscroll)
265   AM_RANGE(0x14e000, 0x14e7ff) AM_RAM AM_BASE_MEMBER(cninja_state, pf2_rowscroll)
257266
258   AM_RANGE(0x150000, 0x15000f) AM_WRITE(deco16_pf34_control_w) AM_BASE(&deco16_pf34_control)
259   AM_RANGE(0x154000, 0x154fff) AM_RAM_WRITE(deco16_pf3_data_w) AM_BASE(&deco16_pf3_data)
260   AM_RANGE(0x156000, 0x156fff) AM_RAM_WRITE(deco16_pf4_data_w) AM_BASE(&deco16_pf4_data)
261   AM_RANGE(0x15c000, 0x15c7ff) AM_RAM AM_BASE(&deco16_pf3_rowscroll)
262   AM_RANGE(0x15e000, 0x15e7ff) AM_RAM AM_BASE(&deco16_pf4_rowscroll)
267   AM_RANGE(0x150000, 0x15000f) AM_WRITE(cninja_pf34_control_w)
268   AM_RANGE(0x154000, 0x154fff) AM_DEVREADWRITE("deco_custom", deco16ic_pf3_data_r, deco16ic_pf3_data_w)
269   AM_RANGE(0x156000, 0x156fff) AM_DEVREADWRITE("deco_custom", deco16ic_pf4_data_r, deco16ic_pf4_data_w)
270   AM_RANGE(0x15c000, 0x15c7ff) AM_RAM AM_BASE_MEMBER(cninja_state, pf3_rowscroll)
271   AM_RANGE(0x15e000, 0x15e7ff) AM_RAM AM_BASE_MEMBER(cninja_state, pf4_rowscroll)
263272
264273   AM_RANGE(0x180000, 0x1807ff) AM_RAM AM_BASE_SIZE_GENERIC(spriteram)
265274//  AM_RANGE(0x18c000, 0x18c0ff) AM_WRITE(cninja_loopback_w) /* Protection writes */
266275   AM_RANGE(0x18c000, 0x18c7ff) AM_READ(robocop2_prot_r) /* Protection device */
267276   AM_RANGE(0x18c064, 0x18c065) AM_WRITE(cninja_sound_w)
268277   AM_RANGE(0x198000, 0x198001) AM_WRITE(buffer_spriteram16_w) /* DMA flag */
269   AM_RANGE(0x1a8000, 0x1a9fff) AM_RAM_WRITE(deco16_nonbuffered_palette_w) AM_BASE_GENERIC(paletteram)
278   AM_RANGE(0x1a8000, 0x1a9fff) AM_RAM_DEVWRITE("deco_custom", deco16ic_nonbuffered_palette_w) AM_BASE_GENERIC(paletteram)
270279   AM_RANGE(0x1b0000, 0x1b0007) AM_READWRITE(cninja_irq_r, cninja_irq_w)
271   AM_RANGE(0x1b8000, 0x1bbfff) AM_RAM AM_BASE(&cninja_ram) /* Main ram */
272   AM_RANGE(0x1f0000, 0x1f0001) AM_WRITE(deco16_priority_w)
280   AM_RANGE(0x1b8000, 0x1bbfff) AM_RAM AM_BASE_MEMBER(cninja_state, ram) /* Main ram */
281   AM_RANGE(0x1f0000, 0x1f0001) AM_DEVWRITE("deco_custom", deco16ic_priority_w)
273282   AM_RANGE(0x1f8000, 0x1f8001) AM_READ_PORT("DSW3") /* Dipswitch #3 */
274283ADDRESS_MAP_END
275284
r7500r7501
278287   AM_RANGE(0x100000, 0x103fff) AM_RAM
279288   AM_RANGE(0x120000, 0x1207ff) AM_RAM AM_BASE_SIZE_GENERIC(spriteram)
280289   AM_RANGE(0x140000, 0x1407ff) AM_RAM AM_BASE_SIZE_GENERIC(spriteram2)
281   AM_RANGE(0x160000, 0x161fff) AM_RAM_WRITE(deco16_nonbuffered_palette_w) AM_BASE_GENERIC(paletteram)
282   AM_RANGE(0x180000, 0x180001) AM_WRITE(deco16_priority_w)
290   AM_RANGE(0x160000, 0x161fff) AM_RAM_DEVWRITE("deco_custom", deco16ic_nonbuffered_palette_w) AM_BASE_GENERIC(paletteram)
291   AM_RANGE(0x180000, 0x180001) AM_DEVWRITE("deco_custom", deco16ic_priority_w)
283292   AM_RANGE(0x180002, 0x180003) AM_WRITENOP /* VBL irq ack */
284293   AM_RANGE(0x1a0000, 0x1a07ff) AM_READWRITE(deco16_66_prot_r, deco16_66_prot_w) AM_BASE(&deco16_prot_ram) /* Protection device */
285   AM_RANGE(0x1c0000, 0x1c0001) AM_READWRITE(deco16_71_r, buffer_spriteram16_w)
294   AM_RANGE(0x1c0000, 0x1c0001) AM_WRITE(buffer_spriteram16_w) AM_DEVREAD("deco_custom", deco16ic_71_r)
286295   AM_RANGE(0x1e0000, 0x1e0001) AM_WRITE(buffer_spriteram16_2_w)
287296
288   AM_RANGE(0x300000, 0x30000f) AM_WRITE(deco16_pf12_control_w) AM_BASE(&deco16_pf12_control)
289   AM_RANGE(0x304000, 0x305fff) AM_RAM_WRITE(deco16_pf1_data_w) AM_BASE(&deco16_pf1_data)
290   AM_RANGE(0x306000, 0x307fff) AM_RAM_WRITE(deco16_pf2_data_w) AM_BASE(&deco16_pf2_data)
291   AM_RANGE(0x308000, 0x3087ff) AM_RAM AM_BASE(&deco16_pf1_rowscroll)
292   AM_RANGE(0x30a000, 0x30a7ff) AM_RAM AM_BASE(&deco16_pf2_rowscroll)
297   AM_RANGE(0x300000, 0x30000f) AM_WRITE(cninja_pf12_control_w)
298   AM_RANGE(0x304000, 0x305fff) AM_DEVREADWRITE("deco_custom", deco16ic_pf1_data_r, deco16ic_pf1_data_w)
299   AM_RANGE(0x306000, 0x307fff) AM_DEVREADWRITE("deco_custom", deco16ic_pf2_data_r, deco16ic_pf2_data_w)
300   AM_RANGE(0x308000, 0x3087ff) AM_RAM AM_BASE_MEMBER(cninja_state, pf1_rowscroll)
301   AM_RANGE(0x30a000, 0x30a7ff) AM_RAM AM_BASE_MEMBER(cninja_state, pf2_rowscroll)
293302
294   AM_RANGE(0x310000, 0x31000f) AM_WRITE(deco16_pf34_control_w) AM_BASE(&deco16_pf34_control)
295   AM_RANGE(0x314000, 0x315fff) AM_RAM_WRITE(deco16_pf3_data_w) AM_BASE(&deco16_pf3_data)
296   AM_RANGE(0x316000, 0x317fff) AM_RAM_WRITE(deco16_pf4_data_w) AM_BASE(&deco16_pf4_data)
297   AM_RANGE(0x318000, 0x3187ff) AM_RAM AM_BASE(&deco16_pf3_rowscroll)
298   AM_RANGE(0x31a000, 0x31a7ff) AM_RAM AM_BASE(&deco16_pf4_rowscroll)
303   AM_RANGE(0x310000, 0x31000f) AM_WRITE(cninja_pf34_control_w)
304   AM_RANGE(0x314000, 0x315fff) AM_DEVREADWRITE("deco_custom", deco16ic_pf3_data_r, deco16ic_pf3_data_w)
305   AM_RANGE(0x316000, 0x317fff) AM_DEVREADWRITE("deco_custom", deco16ic_pf4_data_r, deco16ic_pf4_data_w)
306   AM_RANGE(0x318000, 0x3187ff) AM_RAM AM_BASE_MEMBER(cninja_state, pf3_rowscroll)
307   AM_RANGE(0x31a000, 0x31a7ff) AM_RAM AM_BASE_MEMBER(cninja_state, pf4_rowscroll)
299308
300309   AM_RANGE(0xad00ac, 0xad00ff) AM_READNOP /* Reads from here seem to be a game code bug */
301310ADDRESS_MAP_END
r7500r7501
710719
711720/**********************************************************************************/
712721
713static MACHINE_RESET( cninja )
714{
715   raster_irq_timer = devtag_get_device(machine, "raster_timer");
716   cninja_scanline=0;
717   cninja_irq_mask=0;
718}
719
720722static void sound_irq(running_device *device, int state)
721723{
722   cputag_set_input_line(device->machine, "audiocpu", 1, state); /* IRQ 2 */
724   cninja_state *driver_state = (cninja_state *)device->machine->driver_data;
725   cpu_set_input_line(driver_state->audiocpu, 1, state); /* IRQ 2 */
723726}
724727
725728static void sound_irq2(running_device *device, int state)
726729{
727   cputag_set_input_line(device->machine, "audiocpu", 0, state);
730   cninja_state *driver_state = (cninja_state *)device->machine->driver_data;
731   cpu_set_input_line(driver_state->audiocpu, 0, state);
728732}
729733
730734static WRITE8_DEVICE_HANDLER( sound_bankswitch_w )
731735{
736   cninja_state *state = (cninja_state *)device->machine->driver_data;
737
732738   /* the second OKIM6295 ROM is bank switched */
733   okim6295_set_bank_base(devtag_get_device(device->machine, "oki2"), (data & 1) * 0x40000);
739   okim6295_set_bank_base(state->oki2, (data & 1) * 0x40000);
734740}
735741
736742static const ym2151_interface ym2151_config =
r7500r7501
746752
747753/**********************************************************************************/
748754
755static int cninja_bank_callback( const int bank )
756{
757   if ((bank >> 4) & 0xf)
758      return 0x0000; /* Only 2 banks */
759   return 0x1000;
760}
761
762static int robocop2_bank_callback( const int bank )
763{
764   return (bank & 0x30) << 8;
765}
766
767static int mutantf_1_bank_callback( const int bank )
768{
769   return ((bank >> 4) & 0x3) << 12;
770}
771
772static int mutantf_2_bank_callback( const int bank )
773{
774   return ((bank >> 5) & 0x1) << 14;
775}
776
777static const deco16ic_interface cninja_deco16ic_intf =
778{
779   "screen",
780   0, 1, 1,
781   0x0f, 0x0f, 0x0f, 0x0f,   /* trans masks (default values) */
782   0, 16, 0, 48, /* color base */
783   0x0f, 0x0f, 0x0f, 0x0f,   /* color masks (default values) */
784   NULL,
785   NULL,
786   cninja_bank_callback,
787   cninja_bank_callback
788};
789
790static const deco16ic_interface edrandy_deco16ic_intf =
791{
792   "screen",
793   0, 0, 1,
794   0x0f, 0x0f, 0x0f, 0x0f,   /* trans masks (default values) */
795   0, 16, 0, 48, /* color base  */
796   0x0f, 0x0f, 0x0f, 0x0f,   /* color masks (default values) */
797   NULL,
798   NULL,
799   cninja_bank_callback,
800   cninja_bank_callback
801};
802
803static const deco16ic_interface robocop2_deco16ic_intf =
804{
805   "screen",
806   0, 0, 1,
807   0x0f, 0x0f, 0x0f, 0x0f,   /* trans masks (default values) */
808   0, 16, 0, 48, /* color base */
809   0x0f, 0x0f, 0x0f, 0x0f,   /* color masks (default values) */
810   NULL,
811   robocop2_bank_callback,
812   robocop2_bank_callback,
813   robocop2_bank_callback
814};
815
816static const deco16ic_interface mutantf_deco16ic_intf =
817{
818   "screen",
819   0, 0, 1,
820   0x0f, 0x0f, 0x0f, 0x0f,   /* trans masks (default values) */
821   0, 0x30, 0x20, 0x40, /* color base */
822   0x0f, 0x0f, 0x0f, 0x0f,   /* color masks (default values) */
823   mutantf_1_bank_callback,
824   mutantf_2_bank_callback,
825   mutantf_1_bank_callback,
826   mutantf_1_bank_callback
827};
828
829static MACHINE_START( cninja )
830{
831   cninja_state *state = (cninja_state *)machine->driver_data;
832
833   state->maincpu = devtag_get_device(machine, "maincpu");
834   state->audiocpu = devtag_get_device(machine, "audiocpu");
835   state->deco16ic = devtag_get_device(machine, "deco_custom");
836   state->raster_irq_timer = devtag_get_device(machine, "raster_timer");
837   state->oki2 = devtag_get_device(machine, "oki2");
838
839   state_save_register_global(machine, state->scanline);
840   state_save_register_global(machine, state->irq_mask);
841}
842
843static MACHINE_RESET( cninja )
844{
845   cninja_state *state = (cninja_state *)machine->driver_data;
846
847   state->scanline = 0;
848   state->irq_mask = 0;
849}
850
749851static MACHINE_DRIVER_START( cninja )
750852
853   /* driver data */
854   MDRV_DRIVER_DATA(cninja_state)
855
751856   /* basic machine hardware */
752857   MDRV_CPU_ADD("maincpu", M68000, 12000000)
753858   MDRV_CPU_PROGRAM_MAP(cninja_map)
r7500r7501
756861   MDRV_CPU_ADD("audiocpu", H6280,32220000/8)   /* Accurate */
757862   MDRV_CPU_PROGRAM_MAP(sound_map)
758863
864   MDRV_MACHINE_START(cninja)
759865   MDRV_MACHINE_RESET(cninja)
760866
761867   MDRV_TIMER_ADD("raster_timer", interrupt_gen)
r7500r7501
772878   MDRV_GFXDECODE(cninja)
773879   MDRV_PALETTE_LENGTH(2048)
774880
775   MDRV_VIDEO_START(cninja)
776881   MDRV_VIDEO_UPDATE(cninja)
777882
883   MDRV_DECO16IC_ADD("deco_custom", cninja_deco16ic_intf)
884
778885   /* sound hardware */
779886   MDRV_SPEAKER_STANDARD_MONO("mono")
780887
r7500r7501
797904
798905static MACHINE_DRIVER_START( stoneage )
799906
907   /* driver data */
908   MDRV_DRIVER_DATA(cninja_state)
909
800910   /* basic machine hardware */
801911   MDRV_CPU_ADD("maincpu", M68000, 12000000)
802912   MDRV_CPU_PROGRAM_MAP(cninja_map)
r7500r7501
805915   MDRV_CPU_ADD("audiocpu", Z80, 3579545)
806916   MDRV_CPU_PROGRAM_MAP(stoneage_s_map)
807917
918   MDRV_MACHINE_START(cninja)
808919   MDRV_MACHINE_RESET(cninja)
809920
810921   MDRV_TIMER_ADD("raster_timer", interrupt_gen)
r7500r7501
824935   MDRV_VIDEO_START(stoneage)
825936   MDRV_VIDEO_UPDATE(cninja)
826937
938   MDRV_DECO16IC_ADD("deco_custom", cninja_deco16ic_intf)
939
827940   /* sound hardware */
828941   MDRV_SPEAKER_STANDARD_MONO("mono")
829942
r7500r7501
844957
845958static MACHINE_DRIVER_START( cninjabl )
846959
960   /* driver data */
961   MDRV_DRIVER_DATA(cninja_state)
962
847963   /* basic machine hardware */
848964   MDRV_CPU_ADD("maincpu", M68000, 12000000)
849965   MDRV_CPU_PROGRAM_MAP(cninjabl_map)
r7500r7501
852968   MDRV_CPU_ADD("audiocpu", Z80, 3579545)
853969   MDRV_CPU_PROGRAM_MAP(stoneage_s_map)
854970
971   MDRV_MACHINE_START(cninja)
855972   MDRV_MACHINE_RESET(cninja)
856973
857974   MDRV_TIMER_ADD("raster_timer", interrupt_gen)
r7500r7501
868985   MDRV_GFXDECODE(cninjabl)
869986   MDRV_PALETTE_LENGTH(2048)
870987
871   MDRV_VIDEO_START(cninja)
872988   MDRV_VIDEO_UPDATE(cninjabl)
873989
990   MDRV_DECO16IC_ADD("deco_custom", cninja_deco16ic_intf)
991
874992   /* sound hardware */
875993   MDRV_SPEAKER_STANDARD_MONO("mono")
876994
r7500r7501
8871005
8881006static MACHINE_DRIVER_START( edrandy )
8891007
1008   /* driver data */
1009   MDRV_DRIVER_DATA(cninja_state)
1010
8901011   /* basic machine hardware */
8911012   MDRV_CPU_ADD("maincpu", M68000, 12000000)
8921013   MDRV_CPU_PROGRAM_MAP(edrandy_map)
r7500r7501
8951016   MDRV_CPU_ADD("audiocpu", H6280,32220000/8)   /* Accurate */
8961017   MDRV_CPU_PROGRAM_MAP(sound_map)
8971018
1019   MDRV_MACHINE_START(cninja)
8981020   MDRV_MACHINE_RESET(cninja)
8991021
9001022   MDRV_TIMER_ADD("raster_timer", interrupt_gen)
r7500r7501
9111033   MDRV_GFXDECODE(cninja)
9121034   MDRV_PALETTE_LENGTH(2048)
9131035
914   MDRV_VIDEO_START(edrandy)
9151036   MDRV_VIDEO_UPDATE(edrandy)
9161037
1038   MDRV_DECO16IC_ADD("deco_custom", edrandy_deco16ic_intf)
1039
9171040   /* sound hardware */
9181041   MDRV_SPEAKER_STANDARD_MONO("mono")
9191042
r7500r7501
9361059
9371060static MACHINE_DRIVER_START( robocop2 )
9381061
1062   /* driver data */
1063   MDRV_DRIVER_DATA(cninja_state)
1064
9391065   /* basic machine hardware */
9401066   MDRV_CPU_ADD("maincpu", M68000, 14000000)
9411067   MDRV_CPU_PROGRAM_MAP(robocop2_map)
r7500r7501
9441070   MDRV_CPU_ADD("audiocpu", H6280,32220000/8)   /* Accurate */
9451071   MDRV_CPU_PROGRAM_MAP(sound_map)
9461072
1073   MDRV_MACHINE_START(cninja)
9471074   MDRV_MACHINE_RESET(cninja)
9481075
9491076   MDRV_TIMER_ADD("raster_timer", interrupt_gen)
r7500r7501
9601087   MDRV_GFXDECODE(robocop2)
9611088   MDRV_PALETTE_LENGTH(2048)
9621089
963   MDRV_VIDEO_START(robocop2)
9641090   MDRV_VIDEO_UPDATE(robocop2)
9651091
1092   MDRV_DECO16IC_ADD("deco_custom", robocop2_deco16ic_intf)
1093
9661094   /* sound hardware */
9671095   MDRV_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker")
9681096
r7500r7501
9881116
9891117static MACHINE_DRIVER_START( mutantf )
9901118
1119   /* driver data */
1120   MDRV_DRIVER_DATA(cninja_state)
1121
9911122   /* basic machine hardware */
9921123   MDRV_CPU_ADD("maincpu", M68000, 14000000)
9931124   MDRV_CPU_PROGRAM_MAP(mutantf_map)
r7500r7501
9961127   MDRV_CPU_ADD("audiocpu", H6280,32220000/8)
9971128   MDRV_CPU_PROGRAM_MAP(sound_map_mutantf)
9981129
1130   MDRV_MACHINE_START(cninja)
1131   MDRV_MACHINE_RESET(cninja)
1132
9991133   /* video hardware */
10001134   MDRV_VIDEO_ATTRIBUTES(VIDEO_BUFFERS_SPRITERAM )
10011135
r7500r7501
10081142   MDRV_GFXDECODE(mutantf)
10091143   MDRV_PALETTE_LENGTH(2048)
10101144
1011   MDRV_VIDEO_START(mutantf)
10121145   MDRV_VIDEO_UPDATE(mutantf)
10131146
1147   MDRV_DECO16IC_ADD("deco_custom", mutantf_deco16ic_intf)
1148
10141149   /* sound hardware */
10151150   MDRV_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker")
10161151
r7500r7501
17931928
17941929/**********************************************************************************/
17951930
1796static void cninja_patch(running_machine *machine)
1931static void cninja_patch( running_machine *machine )
17971932{
17981933   UINT16 *RAM = (UINT16 *)memory_region(machine, "maincpu");
17991934   int i;
18001935
1801   for (i=0; i<0x80000/2; i++) {
1802      int aword=RAM[i];
1936   for (i = 0; i < 0x80000 / 2; i++)
1937   {
1938      int aword = RAM[i];
18031939
1804      if (aword==0x66ff || aword==0x67ff) {
1805         UINT16 doublecheck=RAM[i-4];
1940      if (aword == 0x66ff || aword == 0x67ff)
1941      {
1942         UINT16 doublecheck = RAM[i - 4];
18061943
18071944         /* Cmpi + btst controlling opcodes */
1808         if (doublecheck==0xc39 || doublecheck==0x839) {
1809            RAM[i]=0x4E71;
1810              RAM[i-1]=0x4E71;
1811              RAM[i-2]=0x4E71;
1812              RAM[i-3]=0x4E71;
1813              RAM[i-4]=0x4E71;
1945         if (doublecheck == 0xc39 || doublecheck == 0x839)
1946         {
1947            RAM[i]     = 0x4e71;
1948            RAM[i - 1] = 0x4e71;
1949            RAM[i - 2] = 0x4e71;
1950            RAM[i - 3] = 0x4e71;
1951            RAM[i - 4] = 0x4e71;
18141952         }
18151953      }
18161954   }
r7500r7501
18351973   UINT8 *dst = memory_region(machine, "gfx1");
18361974
18371975   /* The 16x16 graphic has some 8x8 chars in it - decode them in GFX1 */
1838   memcpy(dst+0x50000,dst+0x10000,0x10000);
1839   memcpy(dst+0x10000,src,0x40000);
1840   memcpy(dst+0x60000,src+0x40000,0x40000);
1976   memcpy(dst + 0x50000, dst + 0x10000, 0x10000);
1977   memcpy(dst + 0x10000, src, 0x40000);
1978   memcpy(dst + 0x60000, src + 0x40000, 0x40000);
18411979
18421980   deco56_decrypt_gfx(machine, "gfx1");
18431981   deco56_decrypt_gfx(machine, "gfx2");
r7500r7501
18451983
18461984/**********************************************************************************/
18471985
1848GAME( 1990, edrandy,  0,       edrandy,  edrandy, 0,        ROT0, "Data East Corporation", "The Cliffhanger - Edward Randy (World ver 3)", 0 )
1849GAME( 1990, edrandy2, edrandy, edrandy,  edrandc, 0,        ROT0, "Data East Corporation", "The Cliffhanger - Edward Randy (World ver 2)", 0 )
1850GAME( 1990, edrandy1, edrandy, edrandy,  edrandc, 0,        ROT0, "Data East Corporation", "The Cliffhanger - Edward Randy (World ver 1)", 0 )
1851GAME( 1990, edrandyj, edrandy, edrandy,  edrandc, 0,        ROT0, "Data East Corporation", "The Cliffhanger - Edward Randy (Japan ver 3)", 0 )
1852GAME( 1991, cninja,   0,       cninja,   cninja,  cninja,   ROT0, "Data East Corporation", "Caveman Ninja (World ver 4)", 0 )
1853GAME( 1991, cninja1,  cninja,  cninja,   cninja,  cninja,   ROT0, "Data East Corporation", "Caveman Ninja (World ver 1)", 0 )
1854GAME( 1991, cninjau,  cninja,  cninja,   cninjau, cninja,   ROT0, "Data East Corporation", "Caveman Ninja (US ver 4)", 0 )
1855GAME( 1991, joemac,   cninja,  cninja,   cninja,  cninja,   ROT0, "Data East Corporation", "Tatakae Genshizin Joe & Mac (Japan ver 1)", 0 )
1856GAME( 1991, stoneage, cninja,  stoneage, cninja,  stoneage, ROT0, "bootleg", "Stoneage (bootleg of Caveman Ninja)", 0 )
1857GAME( 1991, cninjabl, cninja,  cninjabl, cninja,  0,        ROT0, "bootleg", "Caveman Ninja (bootleg)", GAME_NOT_WORKING )
1858GAME( 1991, robocop2, 0,       robocop2, robocop2,0,        ROT0, "Data East Corporation", "Robocop 2 (Euro/Asia v0.10)", 0 )
1859GAME( 1991, robocop2u,robocop2,robocop2, robocop2,0,        ROT0, "Data East Corporation", "Robocop 2 (US v0.05)", 0 )
1860GAME( 1991, robocop2j,robocop2,robocop2, robocop2,0,        ROT0, "Data East Corporation", "Robocop 2 (Japan v0.11)", 0 )
1861GAME( 1992, mutantf,  0,       mutantf,  mutantf, mutantf,  ROT0, "Data East Corporation", "Mutant Fighter (World ver EM-5)", 0 )
1862GAME( 1992, mutantf4, mutantf, mutantf,  mutantf, mutantf,  ROT0, "Data East Corporation", "Mutant Fighter (World ver EM-4)", 0 )
1863GAME( 1992, mutantf3, mutantf, mutantf,  mutantf, mutantf,  ROT0, "Data East Corporation", "Mutant Fighter (World ver EM-3)", 0 )
1864GAME( 1992, deathbrd, mutantf, mutantf,  mutantf, mutantf,  ROT0, "Data East Corporation", "Death Brade (Japan ver JM-3)", 0 )
1986GAME( 1990, edrandy,  0,       edrandy,  edrandy, 0,        ROT0, "Data East Corporation", "The Cliffhanger - Edward Randy (World ver 3)", GAME_SUPPORTS_SAVE )
1987GAME( 1990, edrandy2, edrandy, edrandy,  edrandc, 0,        ROT0, "Data East Corporation", "The Cliffhanger - Edward Randy (World ver 2)", GAME_SUPPORTS_SAVE )
1988GAME( 1990, edrandy1, edrandy, edrandy,  edrandc, 0,        ROT0, "Data East Corporation", "The Cliffhanger - Edward Randy (World ver 1)", GAME_SUPPORTS_SAVE )
1989GAME( 1990, edrandyj, edrandy, edrandy,  edrandc, 0,        ROT0, "Data East Corporation", "The Cliffhanger - Edward Randy (Japan ver 3)", GAME_SUPPORTS_SAVE )
1990GAME( 1991, cninja,   0,       cninja,   cninja,  cninja,   ROT0, "Data East Corporation", "Caveman Ninja (World ver 4)", GAME_SUPPORTS_SAVE )
1991GAME( 1991, cninja1,  cninja,  cninja,   cninja,  cninja,   ROT0, "Data East Corporation", "Caveman Ninja (World ver 1)", GAME_SUPPORTS_SAVE )
1992GAME( 1991, cninjau,  cninja,  cninja,   cninjau, cninja,   ROT0, "Data East Corporation", "Caveman Ninja (US ver 4)", GAME_SUPPORTS_SAVE )
1993GAME( 1991, joemac,   cninja,  cninja,   cninja,  cninja,   ROT0, "Data East Corporation", "Tatakae Genshizin Joe & Mac (Japan ver 1)", GAME_SUPPORTS_SAVE )
1994GAME( 1991, stoneage, cninja,  stoneage, cninja,  stoneage, ROT0, "bootleg", "Stoneage (bootleg of Caveman Ninja)", GAME_SUPPORTS_SAVE )
1995GAME( 1991, cninjabl, cninja,  cninjabl, cninja,  0,        ROT0, "bootleg", "Caveman Ninja (bootleg)", GAME_NOT_WORKING | GAME_SUPPORTS_SAVE )
1996GAME( 1991, robocop2, 0,       robocop2, robocop2,0,        ROT0, "Data East Corporation", "Robocop 2 (Euro/Asia v0.10)", GAME_SUPPORTS_SAVE )
1997GAME( 1991, robocop2u,robocop2,robocop2, robocop2,0,        ROT0, "Data East Corporation", "Robocop 2 (US v0.05)", GAME_SUPPORTS_SAVE )
1998GAME( 1991, robocop2j,robocop2,robocop2, robocop2,0,        ROT0, "Data East Corporation", "Robocop 2 (Japan v0.11)", GAME_SUPPORTS_SAVE )
1999GAME( 1992, mutantf,  0,       mutantf,  mutantf, mutantf,  ROT0, "Data East Corporation", "Mutant Fighter (World ver EM-5)", GAME_SUPPORTS_SAVE )
2000GAME( 1992, mutantf4, mutantf, mutantf,  mutantf, mutantf,  ROT0, "Data East Corporation", "Mutant Fighter (World ver EM-4)", GAME_SUPPORTS_SAVE )
2001GAME( 1992, mutantf3, mutantf, mutantf,  mutantf, mutantf,  ROT0, "Data East Corporation", "Mutant Fighter (World ver EM-3)", GAME_SUPPORTS_SAVE )
2002GAME( 1992, deathbrd, mutantf, mutantf,  mutantf, mutantf,  ROT0, "Data East Corporation", "Death Brade (Japan ver JM-3)", GAME_SUPPORTS_SAVE )
src/mame/drivers/go2000.c
r7500r7501
3434#include "cpu/z80/z80.h"
3535#include "sound/dac.h"
3636
37typedef struct _go2000_state go2000_state;
38struct _go2000_state
37class go2000_state
3938{
39public:
40   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, go2000_state(machine)); }
41
42   go2000_state(running_machine &machine) { }
43
4044   /* memory pointers */
4145   UINT16 *  videoram;
4246   UINT16 *  videoram2;
src/mame/drivers/m63.c
r7500r7501
121121#include "sound/ay8910.h"
122122#include "sound/samples.h"
123123
124typedef struct _m63_state m63_state;
125struct _m63_state
124class m63_state
126125{
126public:
127   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, m63_state(machine)); }
128
129   m63_state(running_machine &machine) { }
130
127131   UINT8 *  videoram;
128132   UINT8 *  colorram;
129133   UINT8 *  spriteram;
src/mame/drivers/dassault.c
r7500r7501
124124#include "emu.h"
125125#include "cpu/m68000/m68000.h"
126126#include "cpu/h6280/h6280.h"
127#include "includes/deco16ic.h"
127#include "includes/dassault.h"
128128#include "sound/2203intf.h"
129129#include "sound/2151intf.h"
130130#include "sound/okim6295.h"
131#include "video/deco16ic.h"
131132
132VIDEO_START( dassault );
133VIDEO_UPDATE( dassault );
134133
135static UINT16 *dassault_ram,*shared_ram,*dassault_ram2;
136
137134/**********************************************************************************/
138135
139136static READ16_HANDLER( dassault_control_r )
140137{
141   switch (offset<<1)
138   switch (offset << 1)
142139   {
143140      case 0: /* Player 1 & Player 2 joysticks & fire buttons */
144141         return input_port_read(space->machine, "P1_P2");
r7500r7501
161158
162159static WRITE16_HANDLER( dassault_control_w )
163160{
164   coin_counter_w(space->machine, 0,data&1);
165   if (data&0xfffe)
166      logerror("Coin cointrol %04x\n",data);
161   coin_counter_w(space->machine, 0, data & 1);
162   if (data & 0xfffe)
163      logerror("Coin cointrol %04x\n", data);
167164}
168165
169166static READ16_HANDLER( dassault_sub_control_r )
r7500r7501
173170
174171static WRITE16_HANDLER( dassault_sound_w )
175172{
173   dassault_state *state = (dassault_state *)space->machine->driver_data;
176174   soundlatch_w(space, 0, data & 0xff);
177   cputag_set_input_line(space->machine, "audiocpu", 0, HOLD_LINE); /* IRQ1 */
175   cpu_set_input_line(state->audiocpu, 0, HOLD_LINE); /* IRQ1 */
178176}
179177
180178/* The CPU-CPU irq controller is overlaid onto the end of the shared memory */
181179static READ16_HANDLER( dassault_irq_r )
182180{
183   switch (offset) {
184      case 0: cputag_set_input_line(space->machine, "maincpu", 5, CLEAR_LINE); break;
185      case 1: cputag_set_input_line(space->machine, "sub", 6, CLEAR_LINE); break;
181   dassault_state *state = (dassault_state *)space->machine->driver_data;
182   switch (offset)
183   {
184   case 0: cpu_set_input_line(state->maincpu, 5, CLEAR_LINE); break;
185   case 1: cpu_set_input_line(state->subcpu, 6, CLEAR_LINE); break;
186186   }
187   return shared_ram[(0xffc/2)+offset]; /* The values probably don't matter */
187   return state->shared_ram[(0xffc / 2) + offset]; /* The values probably don't matter */
188188}
189189
190190static WRITE16_HANDLER( dassault_irq_w )
191191{
192   dassault_state *state = (dassault_state *)space->machine->driver_data;
192193   switch (offset)
193194   {
194      case 0: cputag_set_input_line(space->machine, "maincpu", 5, ASSERT_LINE); break;
195      case 1: cputag_set_input_line(space->machine, "sub", 6, ASSERT_LINE); break;
195   case 0: cpu_set_input_line(state->maincpu, 5, ASSERT_LINE); break;
196   case 1: cpu_set_input_line(state->subcpu, 6, ASSERT_LINE); break;
196197   }
197198
198   COMBINE_DATA(&shared_ram[(0xffc / 2) + offset]); /* The values probably don't matter */
199   COMBINE_DATA(&state->shared_ram[(0xffc / 2) + offset]); /* The values probably don't matter */
199200}
200201
201202static WRITE16_HANDLER( shared_ram_w )
202203{
203   COMBINE_DATA(&shared_ram[offset]);
204   dassault_state *state = (dassault_state *)space->machine->driver_data;
205   COMBINE_DATA(&state->shared_ram[offset]);
204206}
205207
206208static READ16_HANDLER( shared_ram_r )
207209{
208   return shared_ram[offset];
210   dassault_state *state = (dassault_state *)space->machine->driver_data;
211   return state->shared_ram[offset];
209212}
210213
211214/**********************************************************************************/
r7500r7501
213216static ADDRESS_MAP_START( dassault_map, ADDRESS_SPACE_PROGRAM, 16 )
214217   AM_RANGE(0x000000, 0x07ffff) AM_ROM
215218
216   AM_RANGE(0x100000, 0x103fff) AM_RAM_WRITE(deco16_nonbuffered_palette_w) AM_BASE_GENERIC(paletteram)
219   AM_RANGE(0x100000, 0x103fff) AM_RAM_DEVWRITE("deco_custom", deco16ic_nonbuffered_palette_w) AM_BASE_GENERIC(paletteram)
217220
218221   AM_RANGE(0x140004, 0x140007) AM_WRITENOP /* ? */
219222   AM_RANGE(0x180000, 0x180001) AM_WRITE(dassault_sound_w)
220223
221224   AM_RANGE(0x1c0000, 0x1c000f) AM_READ(dassault_control_r)
222   AM_RANGE(0x1c000a, 0x1c000b) AM_WRITE(deco16_priority_w)
225   AM_RANGE(0x1c000a, 0x1c000b) AM_DEVWRITE("deco_custom", deco16ic_priority_w)
223226   AM_RANGE(0x1c000c, 0x1c000d) AM_WRITE(buffer_spriteram16_2_w)
224227   AM_RANGE(0x1c000e, 0x1c000f) AM_WRITE(dassault_control_w)
225228
226   AM_RANGE(0x200000, 0x201fff) AM_RAM_WRITE(deco16_pf1_data_w) AM_BASE(&deco16_pf1_data)
227   AM_RANGE(0x202000, 0x203fff) AM_RAM_WRITE(deco16_pf2_data_w) AM_BASE(&deco16_pf2_data)
228   AM_RANGE(0x212000, 0x212fff) AM_WRITEONLY AM_BASE(&deco16_pf2_rowscroll)
229   AM_RANGE(0x220000, 0x22000f) AM_WRITEONLY AM_BASE(&deco16_pf12_control)
229   AM_RANGE(0x200000, 0x201fff) AM_DEVREADWRITE("deco_custom", deco16ic_pf1_data_r, deco16ic_pf1_data_w)
230   AM_RANGE(0x202000, 0x203fff) AM_DEVREADWRITE("deco_custom", deco16ic_pf2_data_r, deco16ic_pf2_data_w)
231   AM_RANGE(0x212000, 0x212fff) AM_WRITEONLY AM_BASE_MEMBER(dassault_state, pf2_rowscroll)
232   AM_RANGE(0x220000, 0x22000f) AM_DEVWRITE("deco_custom", deco16ic_pf12_control_w)
230233
231   AM_RANGE(0x240000, 0x240fff) AM_RAM_WRITE(deco16_pf3_data_w) AM_BASE(&deco16_pf3_data)
232   AM_RANGE(0x242000, 0x242fff) AM_RAM_WRITE(deco16_pf4_data_w) AM_BASE(&deco16_pf4_data)
233   AM_RANGE(0x252000, 0x252fff) AM_WRITEONLY AM_BASE(&deco16_pf4_rowscroll)
234   AM_RANGE(0x260000, 0x26000f) AM_WRITEONLY AM_BASE(&deco16_pf34_control)
234   AM_RANGE(0x240000, 0x240fff) AM_DEVREADWRITE("deco_custom", deco16ic_pf3_data_r, deco16ic_pf3_data_w)
235   AM_RANGE(0x242000, 0x242fff) AM_DEVREADWRITE("deco_custom", deco16ic_pf4_data_r, deco16ic_pf4_data_w)
236   AM_RANGE(0x252000, 0x252fff) AM_WRITEONLY AM_BASE_MEMBER(dassault_state, pf4_rowscroll)
237   AM_RANGE(0x260000, 0x26000f) AM_DEVWRITE("deco_custom", deco16ic_pf34_control_w)
235238
236   AM_RANGE(0x3f8000, 0x3fbfff) AM_RAM AM_BASE(&dassault_ram) /* Main ram */
239   AM_RANGE(0x3f8000, 0x3fbfff) AM_RAM AM_BASE_MEMBER(dassault_state, ram) /* Main ram */
237240   AM_RANGE(0x3fc000, 0x3fcfff) AM_RAM AM_BASE_SIZE_GENERIC(spriteram2) /* Spriteram (2nd) */
238241   AM_RANGE(0x3feffc, 0x3fefff) AM_READWRITE(dassault_irq_r, dassault_irq_w)
239   AM_RANGE(0x3fe000, 0x3fefff) AM_READWRITE(shared_ram_r, shared_ram_w) AM_BASE(&shared_ram) /* Shared ram */
242   AM_RANGE(0x3fe000, 0x3fefff) AM_READWRITE(shared_ram_r, shared_ram_w) AM_BASE_MEMBER(dassault_state, shared_ram) /* Shared ram */
240243ADDRESS_MAP_END
241244
242245static ADDRESS_MAP_START( dassault_sub_map, ADDRESS_SPACE_PROGRAM, 16 )
r7500r7501
246249   AM_RANGE(0x100002, 0x100007) AM_WRITENOP /* ? */
247250   AM_RANGE(0x100004, 0x100005) AM_READ(dassault_sub_control_r)
248251
249   AM_RANGE(0x3f8000, 0x3fbfff) AM_RAM AM_BASE(&dassault_ram2) /* Sub cpu ram */
252   AM_RANGE(0x3f8000, 0x3fbfff) AM_RAM AM_BASE_MEMBER(dassault_state, ram2) /* Sub cpu ram */
250253   AM_RANGE(0x3fc000, 0x3fcfff) AM_RAM AM_BASE_SIZE_GENERIC(spriteram) /* Sprite ram */
251254   AM_RANGE(0x3feffc, 0x3fefff) AM_READWRITE(dassault_irq_r, dassault_irq_w)
252255   AM_RANGE(0x3fe000, 0x3fefff) AM_READWRITE(shared_ram_r, shared_ram_w)
r7500r7501
510513
511514static void sound_irq(running_device *device, int state)
512515{
513   cputag_set_input_line(device->machine, "audiocpu", 1, state);
516   dassault_state *driver_state = (dassault_state *)device->machine->driver_data;
517   cpu_set_input_line(driver_state->audiocpu, 1, state);
514518}
515519
516520static WRITE8_DEVICE_HANDLER( sound_bankswitch_w )
517521{
522   dassault_state *state = (dassault_state *)device->machine->driver_data;
523
518524   /* the second OKIM6295 ROM is bank switched */
519   okim6295_set_bank_base(devtag_get_device(device->machine, "oki2"), (data & 1) * 0x40000);
525   okim6295_set_bank_base(state->oki2, (data & 1) * 0x40000);
520526}
521527
522528static const ym2151_interface ym2151_config =
r7500r7501
527533
528534/**********************************************************************************/
529535
536static int dassault_bank_callback( const int bank )
537{
538   return ((bank >> 4) & 0xf) << 12;
539}
540
541static const deco16ic_interface dassault_deco16ic_intf =
542{
543   "screen",
544   0, 0, 1,
545   0x0f, 0x0f, 0x0f, 0x0f,   /* trans masks (default values) */
546   0, 16, 0, 16, /* color base (default values) */
547   0x0f, 0x0f, 0x0f, 0x0f,   /* color masks (default values) */
548   dassault_bank_callback,
549   dassault_bank_callback,
550   dassault_bank_callback,
551   dassault_bank_callback
552};
553
554static MACHINE_START( dassault )
555{
556   dassault_state *state = (dassault_state *)machine->driver_data;
557
558   state->maincpu = devtag_get_device(machine, "maincpu");
559   state->audiocpu = devtag_get_device(machine, "audiocpu");
560   state->subcpu = devtag_get_device(machine, "sub");
561   state->deco16ic = devtag_get_device(machine, "deco_custom");
562   state->oki2 = devtag_get_device(machine, "oki2");
563}
564
530565static MACHINE_DRIVER_START( dassault )
531566
567   /* driver data */
568   MDRV_DRIVER_DATA(dassault_state)
569
532570   /* basic machine hardware */
533571   MDRV_CPU_ADD("maincpu", M68000, 14000000) /* Accurate */
534572   MDRV_CPU_PROGRAM_MAP(dassault_map)
r7500r7501
543581
544582   MDRV_QUANTUM_TIME(HZ(8400)) /* 140 CPU slices per frame */
545583
584   MDRV_MACHINE_START(dassault)
585
546586   /* video hardware */
547587   MDRV_VIDEO_ATTRIBUTES(VIDEO_BUFFERS_SPRITERAM)
548588
r7500r7501
556596   MDRV_GFXDECODE(dassault)
557597   MDRV_PALETTE_LENGTH(4096)
558598
559   MDRV_VIDEO_START(dassault)
560599   MDRV_VIDEO_UPDATE(dassault)
561600
601   MDRV_DECO16IC_ADD("deco_custom", dassault_deco16ic_intf)
602
562603   /* sound hardware */
563604   MDRV_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker")
564605
r7500r7501
786827
787828static READ16_HANDLER( dassault_main_skip )
788829{
789   int ret=dassault_ram[0];
830   dassault_state *state = (dassault_state *)space->machine->driver_data;
831   int ret = state->ram[0];
790832
791   if (cpu_get_previouspc(space->cpu)==0x1170 && ret&0x8000)
833   if (cpu_get_previouspc(space->cpu) == 0x1170 && ret & 0x8000)
792834      cpu_spinuntil_int(space->cpu);
793835
794836   return ret;
r7500r7501
796838
797839static READ16_HANDLER( thndzone_main_skip )
798840{
799   int ret=dassault_ram[0];
841   dassault_state *state = (dassault_state *)space->machine->driver_data;
842   int ret = state->ram[0];
800843
801   if (cpu_get_pc(space->cpu)==0x114c && ret&0x8000)
844   if (cpu_get_pc(space->cpu) == 0x114c && ret & 0x8000)
802845      cpu_spinuntil_int(space->cpu);
803846
804847   return ret;
r7500r7501
813856   /* Playfield 4 also has access to the char graphics, make things easier
814857    by just copying the chars to both banks (if I just used a different gfx
815858    bank then the colours would be wrong). */
816   memcpy(tmp+0x000000,dst+0x80000,0x80000);
817   memcpy(dst+0x090000,tmp+0x00000,0x80000);
818   memcpy(dst+0x080000,src+0x00000,0x10000);
819   memcpy(dst+0x110000,src+0x10000,0x10000);
859   memcpy(tmp + 0x000000, dst + 0x80000, 0x80000);
860   memcpy(dst + 0x090000, tmp + 0x00000, 0x80000);
861   memcpy(dst + 0x080000, src + 0x00000, 0x10000);
862   memcpy(dst + 0x110000, src + 0x10000, 0x10000);
820863
821864   auto_free(machine, tmp);
822865
r7500r7501
833876   /* Playfield 4 also has access to the char graphics, make things easier
834877    by just copying the chars to both banks (if I just used a different gfx
835878    bank then the colours would be wrong). */
836   memcpy(tmp+0x000000,dst+0x80000,0x80000);
837   memcpy(dst+0x090000,tmp+0x00000,0x80000);
838   memcpy(dst+0x080000,src+0x00000,0x10000);
839   memcpy(dst+0x110000,src+0x10000,0x10000);
879   memcpy(tmp + 0x000000, dst + 0x80000, 0x80000);
880   memcpy(dst + 0x090000, tmp + 0x00000, 0x80000);
881   memcpy(dst + 0x080000, src + 0x00000, 0x10000);
882   memcpy(dst + 0x110000, src + 0x10000, 0x10000);
840883
841884   auto_free(machine, tmp);
842885
r7500r7501
846889
847890/**********************************************************************************/
848891
849GAME( 1991, thndzone, 0,        dassault, thndzone, thndzone, ROT0, "Data East Corporation", "Thunder Zone (World)", 0 )
850GAME( 1991, dassault, thndzone, dassault, dassault, dassault, ROT0, "Data East Corporation", "Desert Assault (US)", 0 )
851GAME( 1991, dassault4,thndzone, dassault, dassault4,dassault, ROT0, "Data East Corporation", "Desert Assault (US 4 Players)", 0 )
892GAME( 1991, thndzone, 0,        dassault, thndzone, thndzone, ROT0, "Data East Corporation", "Thunder Zone (World)", GAME_SUPPORTS_SAVE )
893GAME( 1991, dassault, thndzone, dassault, dassault, dassault, ROT0, "Data East Corporation", "Desert Assault (US)", GAME_SUPPORTS_SAVE )
894GAME( 1991, dassault4,thndzone, dassault, dassault4,dassault, ROT0, "Data East Corporation", "Desert Assault (US 4 Players)", GAME_SUPPORTS_SAVE )
src/mame/drivers/supbtime.c
r7500r7501
2525#include "cpu/h6280/h6280.h"
2626#include "sound/2151intf.h"
2727#include "sound/okim6295.h"
28#include "includes/deco16ic.h"
28#include "video/deco16ic.h"
29#include "includes/supbtime.h"
2930
30VIDEO_START( supbtime );
31VIDEO_UPDATE( supbtime );
3231
3332/******************************************************************************/
3433
3534static READ16_HANDLER( supbtime_controls_r )
3635{
37   switch (offset<<1)
36   switch (offset << 1)
3837   {
3938      case 0:
4039         return input_port_read(space->machine, "INPUTS");
r7500r7501
4746         return 0;
4847   }
4948
50   logerror("CPU #0 PC %06x: warning - read unmapped control address %06x\n",cpu_get_pc(space->cpu),offset);
49   logerror("CPU #0 PC %06x: warning - read unmapped control address %06x\n", cpu_get_pc(space->cpu), offset);
5150   return ~0;
5251}
5352
5453static WRITE16_HANDLER( sound_w )
5554{
55   supbtime_state *state = (supbtime_state *)space->machine->driver_data;
5656   soundlatch_w(space, 0, data & 0xff);
57   cputag_set_input_line(space->machine, "audiocpu", 0, HOLD_LINE);
57   cpu_set_input_line(state->audiocpu, 0, HOLD_LINE);
5858}
5959
6060/******************************************************************************/
r7500r7501
6363   AM_RANGE(0x000000, 0x03ffff) AM_ROM
6464   AM_RANGE(0x100000, 0x103fff) AM_RAM
6565   AM_RANGE(0x104000, 0x11ffff) AM_WRITENOP /* Nothing there */
66   AM_RANGE(0x120000, 0x1207ff) AM_RAM AM_BASE_GENERIC(spriteram)
66   AM_RANGE(0x120000, 0x1207ff) AM_RAM AM_BASE_SIZE_MEMBER(supbtime_state, spriteram, spriteram_size)
6767   AM_RANGE(0x120800, 0x13ffff) AM_WRITENOP /* Nothing there */
6868   AM_RANGE(0x140000, 0x1407ff) AM_RAM_WRITE(paletteram16_xxxxBBBBGGGGRRRR_word_w) AM_BASE_GENERIC(paletteram)
6969   AM_RANGE(0x180000, 0x18000f) AM_READ(supbtime_controls_r)
7070   AM_RANGE(0x18000a, 0x18000d) AM_WRITENOP
7171   AM_RANGE(0x1a0000, 0x1a0001) AM_WRITE(sound_w)
72   AM_RANGE(0x300000, 0x30000f) AM_RAM AM_BASE(&deco16_pf12_control)
73   AM_RANGE(0x320000, 0x321fff) AM_RAM_WRITE(deco16_pf1_data_w) AM_BASE(&deco16_pf1_data)
74   AM_RANGE(0x322000, 0x323fff) AM_RAM_WRITE(deco16_pf2_data_w) AM_BASE(&deco16_pf2_data)
75   AM_RANGE(0x340000, 0x3407ff) AM_RAM AM_BASE(&deco16_pf1_rowscroll)
76   AM_RANGE(0x342000, 0x3427ff) AM_RAM AM_BASE(&deco16_pf2_rowscroll)
72   AM_RANGE(0x300000, 0x30000f) AM_DEVREADWRITE("deco_custom", deco16ic_pf12_control_r, deco16ic_pf12_control_w)
73   AM_RANGE(0x320000, 0x321fff) AM_DEVREADWRITE("deco_custom", deco16ic_pf1_data_r, deco16ic_pf1_data_w)
74   AM_RANGE(0x322000, 0x323fff) AM_DEVREADWRITE("deco_custom", deco16ic_pf2_data_r, deco16ic_pf2_data_w)
75   AM_RANGE(0x340000, 0x3407ff) AM_RAM AM_BASE_MEMBER(supbtime_state, pf1_rowscroll)
76   AM_RANGE(0x342000, 0x3427ff) AM_RAM AM_BASE_MEMBER(supbtime_state, pf2_rowscroll)
7777ADDRESS_MAP_END
7878
7979static ADDRESS_MAP_START( chinatwn_map, ADDRESS_SPACE_PROGRAM, 16 )
8080   AM_RANGE(0x000000, 0x03ffff) AM_ROM
8181   AM_RANGE(0x100000, 0x100001) AM_WRITE(sound_w)
82   AM_RANGE(0x120000, 0x1207ff) AM_RAM AM_BASE_GENERIC(spriteram)
82   AM_RANGE(0x120000, 0x1207ff) AM_RAM AM_BASE_SIZE_MEMBER(supbtime_state, spriteram, spriteram_size)
8383   AM_RANGE(0x140000, 0x1407ff) AM_RAM_WRITE(paletteram16_xxxxBBBBGGGGRRRR_word_w) AM_BASE_GENERIC(paletteram)
8484   AM_RANGE(0x180000, 0x18000f) AM_READ(supbtime_controls_r)
8585   AM_RANGE(0x18000a, 0x18000d) AM_WRITENOP
8686   AM_RANGE(0x1a0000, 0x1a3fff) AM_RAM
87   AM_RANGE(0x300000, 0x30000f) AM_RAM AM_BASE(&deco16_pf12_control)
88   AM_RANGE(0x320000, 0x321fff) AM_RAM_WRITE(deco16_pf1_data_w) AM_BASE(&deco16_pf1_data)
89   AM_RANGE(0x322000, 0x323fff) AM_RAM_WRITE(deco16_pf2_data_w) AM_BASE(&deco16_pf2_data)
90   AM_RANGE(0x340000, 0x3407ff) AM_RAM AM_BASE(&deco16_pf1_rowscroll) // unused
91   AM_RANGE(0x342000, 0x3427ff) AM_RAM AM_BASE(&deco16_pf2_rowscroll) // unused
87   AM_RANGE(0x300000, 0x30000f) AM_DEVREADWRITE("deco_custom", deco16ic_pf12_control_r, deco16ic_pf12_control_w)
88   AM_RANGE(0x320000, 0x321fff) AM_DEVREADWRITE("deco_custom", deco16ic_pf1_data_r, deco16ic_pf1_data_w)
89   AM_RANGE(0x322000, 0x323fff) AM_DEVREADWRITE("deco_custom", deco16ic_pf2_data_r, deco16ic_pf2_data_w)
90   AM_RANGE(0x340000, 0x3407ff) AM_RAM AM_BASE_MEMBER(supbtime_state, pf1_rowscroll) // unused
91   AM_RANGE(0x342000, 0x3427ff) AM_RAM AM_BASE_MEMBER(supbtime_state, pf2_rowscroll) // unused
9292ADDRESS_MAP_END
9393
9494/******************************************************************************/
r7500r7501
311311
312312static void sound_irq(running_device *device, int state)
313313{
314   cputag_set_input_line(device->machine, "audiocpu", 1, state); /* IRQ 2 */
314   supbtime_state *driver_state = (supbtime_state *)device->machine->driver_data;
315   cpu_set_input_line(driver_state->audiocpu, 1, state); /* IRQ 2 */
315316}
316317
317318static const ym2151_interface ym2151_config =
r7500r7501
319320   sound_irq
320321};
321322
323static const deco16ic_interface supbtime_deco16ic_intf =
324{
325   "screen",
326   1, 0, 1,
327   0x0f, 0x0f, 0x0f, 0x0f,   /* trans masks (default values) */
328   0, 16, 0, 16, /* color base (default values) */
329   0x0f, 0x0f, 0x0f, 0x0f,   /* color masks (default values) */
330   NULL, NULL, NULL, NULL
331};
332
333static MACHINE_START( supbtime )
334{
335   supbtime_state *state = (supbtime_state *)machine->driver_data;
336
337   state->maincpu = devtag_get_device(machine, "maincpu");
338   state->audiocpu = devtag_get_device(machine, "audiocpu");
339   state->deco16ic = devtag_get_device(machine, "deco_custom");
340}
341
322342static MACHINE_DRIVER_START( supbtime )
323343
344   /* driver data */
345   MDRV_DRIVER_DATA(supbtime_state)
346
324347   /* basic machine hardware */
325348   MDRV_CPU_ADD("maincpu", M68000, 14000000)
326349   MDRV_CPU_PROGRAM_MAP(supbtime_map)
r7500r7501
329352   MDRV_CPU_ADD("audiocpu", H6280, 32220000/8)   /* Custom chip 45, audio section crystal is 32.220 MHz */
330353   MDRV_CPU_PROGRAM_MAP(sound_map)
331354
355   MDRV_MACHINE_START(supbtime)
356
332357   /* video hardware */
333358   MDRV_VIDEO_ATTRIBUTES(VIDEO_UPDATE_BEFORE_VBLANK)
334359
r7500r7501
342367   MDRV_GFXDECODE(supbtime)
343368   MDRV_PALETTE_LENGTH(1024)
344369
345   MDRV_VIDEO_START(supbtime)
346370   MDRV_VIDEO_UPDATE(supbtime)
347371
372   MDRV_DECO16IC_ADD("deco_custom", supbtime_deco16ic_intf)
373
348374   /* sound hardware */
349375   MDRV_SPEAKER_STANDARD_MONO("mono")
350376
r7500r7501
361387
362388static MACHINE_DRIVER_START( chinatwn )
363389
390   /* driver data */
391   MDRV_DRIVER_DATA(supbtime_state)
392
364393   /* basic machine hardware */
365394   MDRV_CPU_ADD("maincpu", M68000, 14000000)
366395   MDRV_CPU_PROGRAM_MAP(chinatwn_map)
r7500r7501
369398   MDRV_CPU_ADD("audiocpu", H6280, 32220000/8) /* Custom chip 45, audio section crystal is 32.220 MHz */
370399   MDRV_CPU_PROGRAM_MAP(sound_map)
371400
401   MDRV_MACHINE_START(supbtime)
402
372403   /* video hardware */
373404   MDRV_VIDEO_ATTRIBUTES(VIDEO_UPDATE_BEFORE_VBLANK)
374405
r7500r7501
382413   MDRV_GFXDECODE(supbtime)
383414   MDRV_PALETTE_LENGTH(1024)
384415
385   MDRV_VIDEO_START(supbtime)
386416   MDRV_VIDEO_UPDATE(supbtime)
387417
418   MDRV_DECO16IC_ADD("deco_custom", supbtime_deco16ic_intf)
419
388420   /* sound hardware */
389421   MDRV_SPEAKER_STANDARD_MONO("mono")
390422
r7500r7501
479511
480512/******************************************************************************/
481513
482GAME( 1990, supbtime, 0,        supbtime, supbtime, 0, ROT0, "Data East Corporation", "Super Burger Time (World, set 1)", 0 )
483GAME( 1990, supbtimea,supbtime, supbtime, supbtime, 0, ROT0, "Data East Corporation", "Super Burger Time (World, set 2)", 0 )
484GAME( 1990, supbtimej,supbtime, supbtime, supbtime, 0, ROT0, "Data East Corporation", "Super Burger Time (Japan)", 0 )
485GAME( 1991, chinatwn, 0,        chinatwn, chinatwn, 0, ROT0, "Data East Corporation", "China Town (Japan)", 0 )
514GAME( 1990, supbtime, 0,        supbtime, supbtime, 0, ROT0, "Data East Corporation", "Super Burger Time (World, set 1)", GAME_SUPPORTS_SAVE )
515GAME( 1990, supbtimea,supbtime, supbtime, supbtime, 0, ROT0, "Data East Corporation", "Super Burger Time (World, set 2)", GAME_SUPPORTS_SAVE )
516GAME( 1990, supbtimej,supbtime, supbtime, supbtime, 0, ROT0, "Data East Corporation", "Super Burger Time (Japan)", GAME_SUPPORTS_SAVE )
517GAME( 1991, chinatwn, 0,        chinatwn, chinatwn, 0, ROT0, "Data East Corporation", "China Town (Japan)", GAME_SUPPORTS_SAVE )
src/mame/drivers/toratora.c
r7500r7501
2323#include "sound/sn76477.h"
2424
2525
26typedef struct _toratora_state toratora_state;
27struct _toratora_state
26class toratora_state
2827{
28public:
29   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, toratora_state(machine)); }
30
31   toratora_state(running_machine &machine) { }
32
2933   /* memory pointers */
3034   UINT8 *    videoram;
3135   size_t     videoram_size;
src/mame/drivers/atarig1.c
r7500r7501
626626
627627
628628/*
629This (rev 7) is the most recent Pit Fighter pcb that we have documented.
630It has printed Atari stickers that show the following:
629Pit Fighter (rev 9)
631630
631There are printed Atari stickers that show the following:
632
6326332 main board stickers:
633634
635PITFIGHTER
636A0478936-03
637
638WO#-PITPCB08
639G1 REV.D BD.
640
6412 stickers on JSA Audio II board:
642
643JSA II PITJSA10
644PIT
645FIGHTER
646A047184-05
647
648SBOM
64900R5
650001
651
652The card stuck into location 10P has 1 sticker:
653
654OOPSPCB01
655G1 OOPS
656PCB
657A048490-01
658
659The chip on the 10P card is labeled 136079-2053
660*/
661ROM_START( pitfight )
662   ROM_REGION( 0x80000, "maincpu", 0 )   /* 8*64k for 68000 code */
663   ROM_LOAD16_BYTE( "136081-9028.05d", 0x00000, 0x10000, CRC(427713e9) SHA1(8b4913188cac9fe3845c812a07c81f5fdb4a2ded) )
664   ROM_LOAD16_BYTE( "136081-9029.05b", 0x00001, 0x10000, CRC(2cdeaeba) SHA1(e02c99d7f5a7080ea75dc2dd59d4678b62f6bd55) )
665   ROM_LOAD16_BYTE( "136081-9030.15d", 0x20000, 0x10000, CRC(3bace9ef) SHA1(29072871b268f343fa1e7fcc9682674df2b2e34f) )
666   ROM_LOAD16_BYTE( "136081-9031.15b", 0x20001, 0x10000, CRC(c717f011) SHA1(3c5d6c12b85285422345a1aba3f8c497f74c6889) )
667
668   ROM_REGION( 0x14000, "jsa", 0 )   /* 64k for 6502 code */
669   ROM_LOAD( "136081-1060.1b", 0x10000, 0x4000, CRC(231d71d7) SHA1(24622eee5fe873ef81e1df2691bd7a1d3ea7ef6b) )
670   ROM_CONTINUE(               0x04000, 0xc000 )
671
672   ROM_REGION( 0x0a0000, "gfx1", 0 )
673   ROM_LOAD( "136081-1017.130m", 0x000000, 0x10000, CRC(ad3cfea5) SHA1(7b6fec131230e84ab87b7fc95f08989916f30e02) ) /* playfield, planes 0-3 odd */
674   ROM_LOAD( "136081-1018.120m", 0x010000, 0x10000, CRC(1a0f8bcf) SHA1(b965e73246db9507d2ad42dfcb033692b43b9b7a) )
675   ROM_LOAD( "136081-1021.90m",  0x040000, 0x10000, CRC(777efee3) SHA1(07591f11685c4c75c24c55fd242878253d32481b) ) /* playfield, planes 0-3 even */
676   ROM_LOAD( "136081-1022.75m",  0x050000, 0x10000, CRC(524319d0) SHA1(6f47a69d7d4e2a8f79b7470138e8b4edd6d0b2bb) )
677   ROM_LOAD( "136081-1025.45m",  0x080000, 0x10000, CRC(fc41691a) SHA1(4ef2f9093f20d27e1ba7d218b90ff6abb1f33646) ) /* playfield plane 4 */
678
679   ROM_REGION( 0x020000, "gfx2", 0 )
680   ROM_LOAD( "136081-1027.15l",  0x000000, 0x10000, CRC(a59f381d) SHA1(b14e878340ad2adbf4f6d4fc331c58f62037c7c7) ) /* alphanumerics */
681
682   ROM_REGION16_BE( 0x200000, "gfx3", 0 )
683   ROM_LOAD16_BYTE( "136081-1001.65r",  0x000001, 0x20000, CRC(3af31444) SHA1(91fc02786b82abdf12ebdbaacdd1f158f8ce6d06) )
684   ROM_LOAD16_BYTE( "136081-1002.65n",  0x000000, 0x20000, CRC(f1d76a4c) SHA1(ca769d2cdd096f4a54f7bcaa4840fc9ffaabf499) )
685   ROM_LOAD16_BYTE( "136081-1003.70r",  0x040001, 0x20000, CRC(28c41c2a) SHA1(75cd527f98c8475e3b880f53c5a355d6c3bd8766) )
686   ROM_LOAD16_BYTE( "136081-1004.70n",  0x040000, 0x20000, CRC(977744da) SHA1(10f388eef999f702863e2b1a02a188df9a0a6086) )
687   ROM_LOAD16_BYTE( "136081-1005.75r",  0x080001, 0x20000, CRC(ae59aef2) SHA1(44eda8a01016f6911b47df973b9427ff9f2ecef0) )
688   ROM_LOAD16_BYTE( "136081-1006.75n",  0x080000, 0x20000, CRC(b6ccd77e) SHA1(f09a829143abd972699f3e671d4a1362fd362b19) )
689   ROM_LOAD16_BYTE( "136081-1007.90r",  0x0c0001, 0x20000, CRC(ba33b0c0) SHA1(be09ba8796d3db2a859a2776336c1e9acbdaee95) )
690   ROM_LOAD16_BYTE( "136081-1008.90n",  0x0c0000, 0x20000, CRC(09bd047c) SHA1(c283d526c7b08ce06e3981d1fc69433ea0dae657) )
691   ROM_LOAD16_BYTE( "136081-1009.100r", 0x100001, 0x20000, CRC(ab85b00b) SHA1(6c60b9b58ff93ffdd1cffc49c3ea67400d56bf61) )
692   ROM_LOAD16_BYTE( "136081-1010.100n", 0x100000, 0x20000, CRC(eca94bdc) SHA1(c474dfc9dc4460cd2f40cc6012214e760b133c0d) )
693   ROM_LOAD16_BYTE( "136081-1011.115r", 0x140001, 0x20000, CRC(a86582fd) SHA1(8b557622c53c8ff388248ea54d3cc85b0d77cafb) )
694   ROM_LOAD16_BYTE( "136081-1012.115n", 0x140000, 0x20000, CRC(efd1152d) SHA1(77d1752b76b079c9e834a8b73e8601873d3afdbe) )
695   ROM_LOAD16_BYTE( "136081-1013.120r", 0x180001, 0x20000, CRC(a141379e) SHA1(d4c98b364495e19e2e7bee5431834f38ba20a514) )
696   ROM_LOAD16_BYTE( "136081-1014.120n", 0x180000, 0x20000, CRC(93bfcc15) SHA1(4d8f6c8c279533b2fc35f87c3eb5ed614cb03248) )
697   ROM_LOAD16_BYTE( "136081-1015.130r", 0x1c0001, 0x20000, CRC(9378ad0b) SHA1(909f9879f5b8fc3ed0622fd27d903ccb1f7a90c6) )
698   ROM_LOAD16_BYTE( "136081-1016.130n", 0x1c0000, 0x20000, CRC(19c3fbe0) SHA1(ba28f71edb04387f009afe39bfe0ffeff8fbf5e9) )
699
700   ROM_REGION( 0x40000, "adpcm", 0 )   /* 256k for ADPCM samples */
701   ROM_LOAD( "136081-1061.7k",  0x00000, 0x10000, CRC(5b0468c6) SHA1(c910344622386e6be336fe04bc0be758ac6c59db) )
702   ROM_LOAD( "136081-1062.7j",  0x10000, 0x10000, CRC(f73fe3cb) SHA1(547b5c4add617237c4c851751a27cda091fb7933) )
703   ROM_LOAD( "136081-1063.7e",  0x20000, 0x10000, CRC(aa93421d) SHA1(f319057dadcb77a489d0bcffb24e0afe88adc769) )
704   ROM_LOAD( "136081-1064.7d",  0x30000, 0x10000, CRC(33f045d5) SHA1(1fc7bedafeb3c1ffa0f115538cc300959c8d4601) )
705
706   ROM_REGION( 0x0600, "proms", 0 )   /* microcode for growth renderer */
707   ROM_LOAD( "136081-1040.30s",  0x0000, 0x0200, CRC(9b0f8b95) SHA1(d03987fe2d50a9f7769c600885bd1c7e1dee0789) )
708   ROM_LOAD( "136081-1041.25s",  0x0200, 0x0200, CRC(f7ba6153) SHA1(d58792c9e9ea72d8f53f41ac1b420a86db6da3a3) )
709   ROM_LOAD( "136081-1042.20s",  0x0400, 0x0200, CRC(3572fe68) SHA1(ab34ff337c16cd4d568cd2bd6a5063f5ed97368f) )
710
711   ROM_REGION( 0x1200, "plds", 0 )
712   ROM_LOAD( "gal16v8a-136081-1043.15e",  0x0000, 0x0117, CRC(649d9c0d) SHA1(bba2f3cf4607946340de27157c799f6b84c48584) )
713   ROM_LOAD( "gal16v8a-136079-1045.40p",  0x0200, 0x0117, CRC(535c4d2e) SHA1(a428eef81723546566216e6af0db3baebda9a1f2) )
714   ROM_LOAD( "gal16v8a-136079-1046.65d",  0x0400, 0x0117, CRC(38b22b2c) SHA1(cf9051129a790f3427e1c6d74a5c66f16acbd4be) )
715   ROM_LOAD( "gal16v8a-136079-1047.40s",  0x0600, 0x0117, CRC(20839904) SHA1(134d1b379b7708ce33fbbf75e5c879dad971cd22) )
716   ROM_LOAD( "gal16v8a-136079-1048.125f", 0x0800, 0x0117, CRC(d16e8d6e) SHA1(61cc270d80cb34f63fc407e41b55f95d59717757) )
717   ROM_LOAD( "gal16v8a-136079-1049.120f", 0x0a00, 0x0117, CRC(68440ab1) SHA1(2f4eabac27d9a5778fcba0d9aa47460bcb153378) )
718   ROM_LOAD( "gal16v8a-136079-1050.115f", 0x0c00, 0x0117, CRC(20dc296a) SHA1(9179fca2efcdd0782bb15cbf1923670806755bc8) )
719   ROM_LOAD( "gal16v8a-136079-1051.105f", 0x0e00, 0x0117, CRC(45f0cb5f) SHA1(a7043231f68374871253da50cfd905519f283d9e) )
720   ROM_LOAD( "gal16v8a-136079-1052.30n",  0x1000, 0x0117, CRC(6b3d2669) SHA1(143178d9c36a87aa58034faea2e4d4038ae565e7) )
721ROM_END
722
723
724/*
725Pit Fighter (rev 7)
726
727There are printed Atari stickers that show the following:
728
7292 main board stickers:
730
634731PIT FIGHTER
635732A0478936-03
636733
r7500r7501
657754
658755The chip on the 10P card is labeled 136079-2053.
659756*/
660
661ROM_START( pitfight )
757ROM_START( pitfight7 )
662758   ROM_REGION( 0x80000, "maincpu", 0 )   /* 8*64k for 68000 code */
663759   ROM_LOAD16_BYTE( "136081-7028.05d", 0x00000, 0x10000, CRC(7391dc8b) SHA1(2140b21e71871c2cb81cccd92f536763d955ec97) )
664760   ROM_LOAD16_BYTE( "136081-7029.05b", 0x00001, 0x10000, CRC(b3b88382) SHA1(0a0de330d7261c7eaa5aa705328d6c0c28d27536) )
r7500r7501
10931189static DRIVER_INIT( hydra )    { init_g1_common(machine, 0x078000, 116, 0); }
10941190static DRIVER_INIT( hydrap )   { init_g1_common(machine, 0x000000,   0, 0); }
10951191
1096static DRIVER_INIT( pitfight7 ) { init_g1_common(machine, 0x038000, 112, 2); }
1097static DRIVER_INIT( pitfight ) { init_g1_common(machine, 0x038000, 111, 1); }
1192static DRIVER_INIT( pitfight9 ) { init_g1_common(machine, 0x038000, 114, 1); }
1193static DRIVER_INIT( pitfight7 ) { init_g1_common(machine, 0x038000, 112, 1); }
1194static DRIVER_INIT( pitfight )  { init_g1_common(machine, 0x038000, 111, 1); }
10981195static DRIVER_INIT( pitfightj ) { init_g1_common(machine, 0x038000, 113, 1); }
10991196static DRIVER_INIT( pitfightb ) { init_g1_common(machine, 0x038000,  -1, 1); }
11001197
r7500r7501
11091206GAME( 1990, hydrap,   hydra,    atarig1, hydra,    hydrap,   ROT0, "Atari Games", "Hydra (prototype 5/14/90)", GAME_SUPPORTS_SAVE )
11101207GAME( 1990, hydrap2,  hydra,    atarig1, hydra,    hydrap,   ROT0, "Atari Games", "Hydra (prototype 5/25/90)", GAME_SUPPORTS_SAVE )
11111208
1112GAME( 1990, pitfight,  0,        atarig1, pitfight, pitfight7,ROT0, "Atari Games", "Pit Fighter (rev 7)", GAME_SUPPORTS_SAVE )
1113GAME( 1990, pitfight6, pitfight, atarig1, pitfight, pitfightj,ROT0, "Atari Games", "Pit Fighter (rev 6)", GAME_SUPPORTS_SAVE )
1114GAME( 1990, pitfight5, pitfight, atarig1, pitfight, pitfight7,ROT0, "Atari Games", "Pit Fighter (rev 5)", GAME_SUPPORTS_SAVE )
1115GAME( 1990, pitfight4, pitfight, atarig1, pitfight, pitfight, ROT0, "Atari Games", "Pit Fighter (rev 4)", GAME_SUPPORTS_SAVE )
1116GAME( 1990, pitfight3, pitfight, atarig1, pitfight, pitfight, ROT0, "Atari Games", "Pit Fighter (rev 3)", GAME_SUPPORTS_SAVE )
1117GAME( 1990, pitfightj, pitfight, atarig1, pitfightj,pitfightj,ROT0, "Atari Games", "Pit Fighter (Japan, 2 players)", GAME_SUPPORTS_SAVE )
1118GAME( 1990, pitfightb, pitfight, atarig1, pitfight, pitfightb,ROT0, "Atari Games", "Pit Fighter (bootleg)", GAME_SUPPORTS_SAVE )
1209GAME( 1990, pitfight,  0,        atarig1, pitfight, pitfight9, ROT0, "Atari Games", "Pit Fighter (rev 9)", GAME_SUPPORTS_SAVE )
1210GAME( 1990, pitfight7, pitfight, atarig1, pitfight, pitfight7, ROT0, "Atari Games", "Pit Fighter (rev 7)", GAME_SUPPORTS_SAVE )
1211GAME( 1990, pitfight6, pitfight, atarig1, pitfight, pitfightj, ROT0, "Atari Games", "Pit Fighter (rev 6)", GAME_SUPPORTS_SAVE )
1212GAME( 1990, pitfight5, pitfight, atarig1, pitfight, pitfight7, ROT0, "Atari Games", "Pit Fighter (rev 5)", GAME_SUPPORTS_SAVE )
1213GAME( 1990, pitfight4, pitfight, atarig1, pitfight, pitfight,  ROT0, "Atari Games", "Pit Fighter (rev 4)", GAME_SUPPORTS_SAVE )
1214GAME( 1990, pitfight3, pitfight, atarig1, pitfight, pitfight,  ROT0, "Atari Games", "Pit Fighter (rev 3)", GAME_SUPPORTS_SAVE )
1215GAME( 1990, pitfightj, pitfight, atarig1, pitfightj,pitfightj, ROT0, "Atari Games", "Pit Fighter (Japan, 2 players)", GAME_SUPPORTS_SAVE )
1216GAME( 1990, pitfightb, pitfight, atarig1, pitfight, pitfightb, ROT0, "Atari Games", "Pit Fighter (bootleg)", GAME_SUPPORTS_SAVE )
src/mame/drivers/albazc.c
r7500r7501
1414#include "cpu/z80/z80.h"
1515#include "sound/ay8910.h"
1616
17typedef struct _albazc_state albazc_state;
18struct _albazc_state
17class albazc_state
1918{
19public:
20   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, albazc_state(machine)); }
21
22   albazc_state(running_machine &machine) { }
23
2024   /* video-related */
2125   UINT8 *  spriteram1;
2226   UINT8 *  spriteram2;
src/mame/drivers/galaxi.c
r7500r7501
4444#include "sound/okim6295.h"
4545#include "galaxi.lh"
4646
47typedef struct _galaxi_state galaxi_state;
48struct _galaxi_state
47class galaxi_state
4948{
49public:
50   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, galaxi_state(machine)); }
51
52   galaxi_state(running_machine &machine) { }
53
5054   /* memory pointers */
5155   UINT16 *  bg1_ram;
5256   UINT16 *  bg2_ram;
src/mame/drivers/tumbleb.c
r7500r7501
322322#define FNCYWLD_HACK   0
323323
324324static WRITE16_HANDLER( semicom_soundcmd_w );
325static UINT16* tumblepb_mainram;
326UINT16* jumppop_control;
327UINT16* suprtrio_control;
328325
329326/******************************************************************************/
330327
331328static WRITE16_DEVICE_HANDLER( tumblepb_oki_w )
332329{
333   if (mem_mask==0xffff)
330   if (mem_mask == 0xffff)
334331   {
335      okim6295_w(device,0,data&0xff);
336      //printf("tumbleb_oki_w %04x %04x\n",data,mem_mask);
332      okim6295_w(device, 0, data & 0xff);
333      //printf("tumbleb_oki_w %04x %04x\n", data, mem_mask);
337334   }
338335   else
339336   {
340      okim6295_w(device,0,(data>>8)&0xff);
341      //printf("tumbleb_oki_w %04x %04x\n",data,mem_mask);
337      okim6295_w(device, 0, (data >> 8) & 0xff);
338      //printf("tumbleb_oki_w %04x %04x\n", data, mem_mask);
342339   }
343340    /* STUFF IN OTHER BYTE TOO..*/
344341}
r7500r7501
351348#ifdef UNUSED_FUNCTION
352349static WRITE16_HANDLER( tumblepb_sound_w )
353350{
354   soundlatch_w(space,0,data & 0xff);
355   cputag_set_input_line(space->machine, "audiocpu", 0, HOLD_LINE);
351   tumbleb_state *state = (tumbleb_state *)space->machine->driver_data;
352   soundlatch_w(space, 0, data & 0xff);
353   cpu_set_input_line(state->audiocpu, 0, HOLD_LINE);
356354}
357355#endif
358356
359357static WRITE16_HANDLER( jumppop_sound_w )
360358{
361   soundlatch_w(space,0,data & 0xff);
362   cputag_set_input_line(space->machine, "audiocpu", 0, ASSERT_LINE );
359   tumbleb_state *state = (tumbleb_state *)space->machine->driver_data;
360   soundlatch_w(space, 0, data & 0xff);
361   cpu_set_input_line(state->audiocpu, 0, ASSERT_LINE);
363362}
364363
365364/******************************************************************************/
366365
367366static READ16_HANDLER( tumblepopb_controls_r )
368367{
369   switch (offset<<1)
368   switch (offset << 1)
370369   {
371370      case 0:
372371         return input_port_read(space->machine, "PLAYERS");
r7500r7501
451450*/
452451
453452
454
455static int tumblep_music_command;
456static int tumblep_music_bank;
457static int tumbleb2_music_is_playing;
458
459static void tumbleb2_playmusic(running_device *device)
453static void tumbleb2_playmusic( running_device *device )
460454{
461   int status = okim6295_r(device,0);
455   tumbleb_state *state = (tumbleb_state *)device->machine->driver_data;
456   int status = okim6295_r(device, 0);
462457
463   if (tumbleb2_music_is_playing)
458   if (state->music_is_playing)
464459   {
465      if ((status&0x08)==0x00)
460      if (!BIT(status, 3))
466461      {
467         okim6295_w(device,0,0x80|tumblep_music_command);
468         okim6295_w(device,0,0x00|0x82);
462         okim6295_w(device, 0, 0x80 | state->music_command);
463         okim6295_w(device, 0, 0x00 | 0x82);
469464      }
470465   }
471466}
r7500r7501
473468
474469static INTERRUPT_GEN( tumbleb2_interrupt )
475470{
471   tumbleb_state *state = (tumbleb_state *)device->machine->driver_data;
476472   cpu_set_input_line(device, 6, HOLD_LINE);
477   tumbleb2_playmusic(devtag_get_device(device->machine, "oki"));
473   tumbleb2_playmusic(state->oki);
478474}
479475
480476static const int tumbleb_sound_lookup[256] = {
r7500r7501
498494};
499495
500496/* we use channels 1,2,3 for sound effects, and channel 4 for music */
501static void tumbleb2_set_music_bank(running_machine *machine, int bank)
497static void tumbleb2_set_music_bank( running_machine *machine, int bank )
502498{
503499   UINT8 *oki = memory_region(machine, "oki");
504   memcpy(&oki[0x38000], &oki[0x80000+0x38000+0x8000*bank],0x8000);
500   memcpy(&oki[0x38000], &oki[0x80000 + 0x38000 + 0x8000 * bank], 0x8000);
505501}
506502
507static void tumbleb2_play_sound (running_device *device, int data)
503static void tumbleb2_play_sound( running_device *device, int data )
508504{
509   int status = okim6295_r(device,0);
505   int status = okim6295_r(device, 0);
510506
511   if ((status&0x01)==0x00)
507   if (!BIT(status, 0))
512508   {
513      okim6295_w(device,0,0x80|data);
514      okim6295_w(device,0,0x00|0x12);
509      okim6295_w(device, 0, 0x80 | data);
510      okim6295_w(device, 0, 0x00 | 0x12);
515511   }
516   else if ((status&0x02)==0x00)
512   else if (!BIT(status, 1))
517513   {
518      okim6295_w(device,0,0x80|data);
519      okim6295_w(device,0,0x00|0x22);
514      okim6295_w(device, 0, 0x80 | data);
515      okim6295_w(device, 0, 0x00 | 0x22);
520516   }
521   else if ((status&0x04)==0x00)
517   else if (!BIT(status, 2))
522518   {
523      okim6295_w(device,0,0x80|data);
524      okim6295_w(device,0,0x00|0x42);
519      okim6295_w(device, 0, 0x80 | data);
520      okim6295_w(device, 0, 0x00 | 0x42);
525521   }
526522}
527523
r7500r7501
537533// bank 7 = how to play?
538534// bank 8 = boss???
539535
540static void process_tumbleb2_music_command(running_device *device, int data)
536static void process_tumbleb2_music_command( running_device *device, int data )
541537{
542   int status = okim6295_r(device,0);
538   tumbleb_state *state = (tumbleb_state *)device->machine->driver_data;
539   int status = okim6295_r(device, 0);
543540
544541   if (data == 1) // stop?
545542   {
546      if ((status&0x08)==0x08)
543      if (BIT(status, 3))
547544      {
548         okim6295_w(device,0,0x40);      /* Stop playing music */
549         tumbleb2_music_is_playing = 0;
545         okim6295_w(device, 0, 0x40);      /* Stop playing music */
546         state->music_is_playing = 0;
550547      }
551548   }
552549   else
553550   {
554      if (tumbleb2_music_is_playing != data)
551      if (state->music_is_playing != data)
555552      {
556         tumbleb2_music_is_playing = data;
557         okim6295_w(device,0,0x40); // stop the current music
553         state->music_is_playing = data;
554         okim6295_w(device, 0, 0x40); // stop the current music
558555         switch (data)
559556         {
560557            case 0x04: // map screen
561               tumblep_music_bank = 1;
562               tumblep_music_command = 0x38;
558               state->music_bank = 1;
559               state->music_command = 0x38;
563560               break;
564561
565562            case 0x05: // america
566               tumblep_music_bank = 6;
567               tumblep_music_command = 0x38;
563               state->music_bank = 6;
564               state->music_command = 0x38;
568565               break;
569566
570567            case 0x06: // asia
571               tumblep_music_bank = 2;
572               tumblep_music_command = 0x38;
568               state->music_bank = 2;
569               state->music_command = 0x38;
573570               break;
574571
575572            case 0x07: // africa/egypt -- don't seem to have a tune for this one
576               tumblep_music_bank = 4;
577               tumblep_music_command = 0x38;
573               state->music_bank = 4;
574               state->music_command = 0x38;
578575               break;
579576
580577            case 0x08: // antartica
581               tumblep_music_bank = 3;
582               tumblep_music_command = 0x38;
578               state->music_bank = 3;
579               state->music_command = 0x38;
583580               break;
584581
585582            case 0x09: // brazil / south america
586               tumblep_music_bank = 4;
587               tumblep_music_command = 0x38;
583               state->music_bank = 4;
584               state->music_command = 0x38;
588585               break;
589586
590587            case 0x0a: // japan -- don't seem to have a tune
591               tumblep_music_bank = 2;
592               tumblep_music_command = 0x38;
588               state->music_bank = 2;
589               state->music_command = 0x38;
593590               break;
594591
595592            case 0x0b: // australia
596               tumblep_music_bank = 5;
597               tumblep_music_command = 0x38;
593               state->music_bank = 5;
594               state->music_command = 0x38;
598595               break;
599596
600597            case 0x0c: // france/europe
601               tumblep_music_bank = 6;
602               tumblep_music_command = 0x38;
598               state->music_bank = 6;
599               state->music_command = 0x38;
603600               break;
604601
605602            case 0x0d: // how to play
606               tumblep_music_bank = 7;
607               tumblep_music_command = 0x38;
603               state->music_bank = 7;
604               state->music_command = 0x38;
608605               break;
609606
610607            case 0x0f: // stage clear
611               tumblep_music_bank = 0;
612               tumblep_music_command = 0x33;
608               state->music_bank = 0;
609               state->music_command = 0x33;
613610               break;
614611
615612            case 0x10: // boss stage
616               tumblep_music_bank = 8;
617               tumblep_music_command = 0x38;
613               state->music_bank = 8;
614               state->music_command = 0x38;
618615               break;
619616
620617            case 0x12: // world clear
621               tumblep_music_bank = 0;
622               tumblep_music_command = 0x34;
618               state->music_bank = 0;
619               state->music_command = 0x34;
623620               break;
624621
625622            default: // anything else..
626               tumblep_music_bank = 8;
627               tumblep_music_command = 0x38;
623               state->music_bank = 8;
624               state->music_command = 0x38;
628625               break;
629626         }
630         tumbleb2_set_music_bank(device->machine, tumblep_music_bank);
627
628         tumbleb2_set_music_bank(device->machine, state->music_bank);
631629         tumbleb2_playmusic(device);
632
633630      }
634
635
636631   }
637632}
638633
639634
640635static WRITE16_DEVICE_HANDLER( tumbleb2_soundmcu_w )
641636{
642   int sound;
637   int sound = tumbleb_sound_lookup[data & 0xff];
643638
644   sound = tumbleb_sound_lookup[data&0xff];
645
646639   if (sound == 0x00)
647640   {
648641      /* pangpang has more commands than tumbleb2, extra sounds */
649      //mame_printf_debug("Command %04x\n",data);
642      //mame_printf_debug("Command %04x\n", data);
650643   }
651644   else if (sound == -2)
652645   {
r7500r7501
666659   AM_RANGE(0x000000, 0x07ffff) AM_WRITEONLY   /* To write levels modifications */
667660#endif
668661   AM_RANGE(0x100000, 0x100001) AM_READ(tumblepb_prot_r) AM_DEVWRITE("oki", tumblepb_oki_w)
669   AM_RANGE(0x120000, 0x123fff) AM_RAM AM_BASE(&tumblepb_mainram)
662   AM_RANGE(0x120000, 0x123fff) AM_RAM AM_BASE_MEMBER(tumbleb_state, mainram)
670663   AM_RANGE(0x140000, 0x1407ff) AM_RAM_WRITE(paletteram16_xxxxBBBBGGGGRRRR_word_w) AM_BASE_GENERIC(paletteram)
671   AM_RANGE(0x160000, 0x1607ff) AM_RAM AM_BASE_SIZE_GENERIC(spriteram) /* Bootleg sprite buffer */
664   AM_RANGE(0x160000, 0x1607ff) AM_RAM AM_BASE_SIZE_MEMBER(tumbleb_state, spriteram, spriteram_size) /* Bootleg sprite buffer */
672665   AM_RANGE(0x160800, 0x160807) AM_WRITEONLY /* writes past the end of spriteram */
673666   AM_RANGE(0x180000, 0x18000f) AM_READ(tumblepopb_controls_r)
674667   AM_RANGE(0x18000c, 0x18000d) AM_WRITENOP
675668   AM_RANGE(0x1a0000, 0x1a07ff) AM_RAM
676669   AM_RANGE(0x300000, 0x30000f) AM_WRITE(tumblepb_control_0_w)
677   AM_RANGE(0x320000, 0x320fff) AM_WRITE(tumblepb_pf1_data_w) AM_BASE(&tumblepb_pf1_data)
678   AM_RANGE(0x322000, 0x322fff) AM_WRITE(tumblepb_pf2_data_w) AM_BASE(&tumblepb_pf2_data)
670   AM_RANGE(0x320000, 0x320fff) AM_WRITE(tumblepb_pf1_data_w) AM_BASE_MEMBER(tumbleb_state, pf1_data)
671   AM_RANGE(0x322000, 0x322fff) AM_WRITE(tumblepb_pf2_data_w) AM_BASE_MEMBER(tumbleb_state, pf2_data)
679672   AM_RANGE(0x340000, 0x3401ff) AM_WRITENOP /* Unused row scroll */
680673   AM_RANGE(0x340400, 0x34047f) AM_WRITENOP /* Unused col scroll */
681674   AM_RANGE(0x342000, 0x3421ff) AM_WRITENOP
r7500r7501
690683   AM_RANGE(0x100000, 0x100003) AM_DEVREADWRITE8("ymsnd", ym2151_r, ym2151_w, 0x00ff)
691684   AM_RANGE(0x100004, 0x100005) AM_DEVREADWRITE8("oki", okim6295_r, okim6295_w, 0x00ff)
692685   AM_RANGE(0x140000, 0x140fff) AM_RAM_WRITE(paletteram16_xxxxRRRRGGGGBBBB_word_w) AM_BASE_GENERIC(paletteram)
693   AM_RANGE(0x160000, 0x1607ff) AM_RAM AM_BASE_SIZE_GENERIC(spriteram) /* sprites */
686   AM_RANGE(0x160000, 0x1607ff) AM_RAM AM_BASE_SIZE_MEMBER(tumbleb_state, spriteram, spriteram_size) /* sprites */
694687   AM_RANGE(0x160800, 0x16080f) AM_WRITEONLY /* goes slightly past the end of spriteram? */
695688   AM_RANGE(0x180000, 0x18000f) AM_READ(tumblepopb_controls_r)
696689   AM_RANGE(0x18000c, 0x18000d) AM_WRITENOP
697690   AM_RANGE(0x1a0000, 0x1a07ff) AM_RAM
698691   AM_RANGE(0x300000, 0x30000f) AM_WRITE(tumblepb_control_0_w)
699   AM_RANGE(0x320000, 0x321fff) AM_RAM_WRITE(fncywld_pf1_data_w) AM_BASE(&tumblepb_pf1_data)
700   AM_RANGE(0x322000, 0x323fff) AM_RAM_WRITE(fncywld_pf2_data_w) AM_BASE(&tumblepb_pf2_data)
692   AM_RANGE(0x320000, 0x321fff) AM_RAM_WRITE(fncywld_pf1_data_w) AM_BASE_MEMBER(tumbleb_state, pf1_data)
693   AM_RANGE(0x322000, 0x323fff) AM_RAM_WRITE(fncywld_pf2_data_w) AM_BASE_MEMBER(tumbleb_state, pf2_data)
701694   AM_RANGE(0x340000, 0x3401ff) AM_WRITENOP /* Unused row scroll */
702695   AM_RANGE(0x340400, 0x34047f) AM_WRITENOP /* Unused col scroll */
703696   AM_RANGE(0x342000, 0x3421ff) AM_WRITENOP
r7500r7501
710703{
711704   return mame_rand(space->machine);
712705}
706
713707static ADDRESS_MAP_START( htchctch_main_map, ADDRESS_SPACE_PROGRAM, 16 )
714708   AM_RANGE(0x000000, 0x0fffff) AM_ROM
715709   AM_RANGE(0x100000, 0x10000f) AM_READ(semibase_unknown_r)
716710   AM_RANGE(0x100000, 0x100001) AM_WRITE(semicom_soundcmd_w)
717711   AM_RANGE(0x100002, 0x100003) AM_WRITE(bcstory_tilebank_w)
718   AM_RANGE(0x120000, 0x123fff) AM_RAM AM_BASE(&tumblepb_mainram)
712   AM_RANGE(0x120000, 0x123fff) AM_RAM AM_BASE_MEMBER(tumbleb_state, mainram)
719713   AM_RANGE(0x140000, 0x1407ff) AM_RAM_WRITE(paletteram16_xBBBBBGGGGGRRRRR_word_w) AM_BASE_GENERIC(paletteram)
720   AM_RANGE(0x160000, 0x160fff) AM_RAM AM_BASE_SIZE_GENERIC(spriteram) /* Bootleg sprite buffer */
714   AM_RANGE(0x160000, 0x160fff) AM_RAM AM_BASE_SIZE_MEMBER(tumbleb_state, spriteram, spriteram_size) /* Bootleg sprite buffer */
721715   AM_RANGE(0x180000, 0x18000f) AM_READ(tumblepopb_controls_r)
722716   AM_RANGE(0x18000c, 0x18000d) AM_WRITENOP
723717   AM_RANGE(0x1a0000, 0x1a0fff) AM_RAM
724718   AM_RANGE(0x300000, 0x30000f) AM_WRITE(tumblepb_control_0_w)
725   AM_RANGE(0x320000, 0x321fff) AM_WRITE(tumblepb_pf1_data_w) AM_BASE(&tumblepb_pf1_data)
726   AM_RANGE(0x322000, 0x322fff) AM_WRITE(tumblepb_pf2_data_w) AM_BASE(&tumblepb_pf2_data)
719   AM_RANGE(0x320000, 0x321fff) AM_WRITE(tumblepb_pf1_data_w) AM_BASE_MEMBER(tumbleb_state, pf1_data)
720   AM_RANGE(0x322000, 0x322fff) AM_WRITE(tumblepb_pf2_data_w) AM_BASE_MEMBER(tumbleb_state, pf2_data)
727721   AM_RANGE(0x341000, 0x342fff) AM_RAM            // Extra ram?
728722ADDRESS_MAP_END
729723
730724
731725static ADDRESS_MAP_START( jumppop_main_map, ADDRESS_SPACE_PROGRAM, 16 )
732726   AM_RANGE(0x000000, 0x07ffff) AM_ROM
733   AM_RANGE(0x120000, 0x123fff) AM_RAM AM_BASE(&tumblepb_mainram)
727   AM_RANGE(0x120000, 0x123fff) AM_RAM AM_BASE_MEMBER(tumbleb_state, mainram)
734728   AM_RANGE(0x140000, 0x1407ff) AM_RAM_WRITE(paletteram16_xRRRRRGGGGGBBBBB_word_w) AM_BASE_GENERIC(paletteram)
735   AM_RANGE(0x160000, 0x160fff) AM_RAM AM_BASE_SIZE_GENERIC(spriteram) /* Bootleg sprite buffer */
729   AM_RANGE(0x160000, 0x160fff) AM_RAM AM_BASE_SIZE_MEMBER(tumbleb_state, spriteram, spriteram_size) /* Bootleg sprite buffer */
736730   AM_RANGE(0x180000, 0x180001) AM_NOP   /* IRQ ack? */
737731   AM_RANGE(0x180002, 0x180003) AM_READ_PORT("PLAYERS")
738732   AM_RANGE(0x180004, 0x180005) AM_READ_PORT("SYSTEM")
739733   AM_RANGE(0x180006, 0x180007) AM_READ_PORT("DSW")
740734   AM_RANGE(0x18000c, 0x18000d) AM_WRITE(jumppop_sound_w)
741735   AM_RANGE(0x1a0000, 0x1a7fff) AM_RAM
742   AM_RANGE(0x300000, 0x303fff) AM_RAM_WRITE(tumblepb_pf2_data_w) AM_BASE(&tumblepb_pf2_data)
743   AM_RANGE(0x320000, 0x323fff) AM_RAM_WRITE(tumblepb_pf1_data_w) AM_BASE(&tumblepb_pf1_data)
744   AM_RANGE(0x380000, 0x38000f) AM_WRITEONLY AM_BASE(&jumppop_control)
736   AM_RANGE(0x300000, 0x303fff) AM_RAM_WRITE(tumblepb_pf2_data_w) AM_BASE_MEMBER(tumbleb_state, pf2_data)
737   AM_RANGE(0x320000, 0x323fff) AM_RAM_WRITE(tumblepb_pf1_data_w) AM_BASE_MEMBER(tumbleb_state, pf1_data)
738   AM_RANGE(0x380000, 0x38000f) AM_WRITEONLY AM_BASE_MEMBER(tumbleb_state, control)
745739ADDRESS_MAP_END
746740
747741static WRITE16_HANDLER( jumpkids_sound_w )
748742{
743   tumbleb_state *state = (tumbleb_state *)space->machine->driver_data;
749744   soundlatch_w(space, 0, data & 0xff);
750   cputag_set_input_line(space->machine, "audiocpu", 0, HOLD_LINE);
745   cpu_set_input_line(state->audiocpu, 0, HOLD_LINE);
751746}
752747
753
754748static ADDRESS_MAP_START( suprtrio_main_map, ADDRESS_SPACE_PROGRAM, 16 )
755749   AM_RANGE(0x000000, 0x07ffff) AM_ROM
756   AM_RANGE(0x700000, 0x700fff) AM_RAM AM_BASE_SIZE_GENERIC(spriteram)
757   AM_RANGE(0xa00000, 0xa0000f) AM_RAM AM_BASE(&suprtrio_control)
758   AM_RANGE(0xa20000, 0xa20fff) AM_RAM_WRITE(tumblepb_pf1_data_w) AM_BASE(&tumblepb_pf1_data)
759   AM_RANGE(0xa22000, 0xa22fff) AM_RAM_WRITE(tumblepb_pf2_data_w) AM_BASE(&tumblepb_pf2_data)
750   AM_RANGE(0x700000, 0x700fff) AM_RAM AM_BASE_SIZE_MEMBER(tumbleb_state, spriteram, spriteram_size)
751   AM_RANGE(0xa00000, 0xa0000f) AM_RAM AM_BASE_MEMBER(tumbleb_state, control)
752   AM_RANGE(0xa20000, 0xa20fff) AM_RAM_WRITE(tumblepb_pf1_data_w) AM_BASE_MEMBER(tumbleb_state, pf1_data)
753   AM_RANGE(0xa22000, 0xa22fff) AM_RAM_WRITE(tumblepb_pf2_data_w) AM_BASE_MEMBER(tumbleb_state, pf2_data)
760754   AM_RANGE(0xcf0000, 0xcf05ff) AM_RAM_WRITE(paletteram16_xBBBBBGGGGGRRRRR_word_w) AM_BASE_GENERIC(paletteram)
761755   AM_RANGE(0xe00000, 0xe00001) AM_READ_PORT("PLAYERS") AM_WRITE(suprtrio_tilebank_w)
762756   AM_RANGE(0xe40000, 0xe40001) AM_READ_PORT("SYSTEM")
r7500r7501
767761
768762static ADDRESS_MAP_START( pangpang_main_map, ADDRESS_SPACE_PROGRAM, 16 )
769763   AM_RANGE(0x000000, 0x07ffff) AM_ROM
770   AM_RANGE(0x120000, 0x123fff) AM_RAM AM_BASE(&tumblepb_mainram)
764   AM_RANGE(0x120000, 0x123fff) AM_RAM AM_BASE_MEMBER(tumbleb_state, mainram)
771765   AM_RANGE(0x140000, 0x1407ff) AM_RAM_WRITE(paletteram16_xxxxBBBBGGGGRRRR_word_w) AM_BASE_GENERIC(paletteram)
772   AM_RANGE(0x160000, 0x1607ff) AM_RAM AM_BASE_SIZE_GENERIC(spriteram) /* Bootleg sprite buffer */
766   AM_RANGE(0x160000, 0x1607ff) AM_RAM AM_BASE_SIZE_MEMBER(tumbleb_state, spriteram, spriteram_size) /* Bootleg sprite buffer */
773767   AM_RANGE(0x160800, 0x160807) AM_WRITEONLY // writes past the end of spriteram
774768   AM_RANGE(0x180000, 0x18000f) AM_READ(tumblepopb_controls_r)
775769   AM_RANGE(0x1a0000, 0x1a07ff) AM_RAM
776770   AM_RANGE(0x300000, 0x30000f) AM_WRITE(tumblepb_control_0_w)
777   AM_RANGE(0x320000, 0x321fff) AM_RAM_WRITE(pangpang_pf1_data_w) AM_BASE(&tumblepb_pf1_data)
778   AM_RANGE(0x340000, 0x341fff) AM_RAM_WRITE(pangpang_pf2_data_w) AM_BASE(&tumblepb_pf2_data)
771   AM_RANGE(0x320000, 0x321fff) AM_RAM_WRITE(pangpang_pf1_data_w) AM_BASE_MEMBER(tumbleb_state, pf1_data)
772   AM_RANGE(0x340000, 0x341fff) AM_RAM_WRITE(pangpang_pf2_data_w) AM_BASE_MEMBER(tumbleb_state, pf2_data)
779773ADDRESS_MAP_END
780774
781775
r7500r7501
785779{
786780   if (ACCESSING_BITS_0_7)
787781   {
788      soundlatch_w(space,0,data & 0xff);
782      soundlatch_w(space, 0, data & 0xff);
789783      // needed for Super Trio which reads the sound with polling
790//      cpu_spinuntil_time(space->cpu, ATTOTIME_IN_USEC(100));
784      // cpu_spinuntil_time(space->cpu, ATTOTIME_IN_USEC(100));
791785      cpuexec_boost_interleave(space->machine, attotime_zero, ATTOTIME_IN_USEC(20));
792786
793787   }
r7500r7501
804798   AM_RANGE(0xd000, 0xd7ff) AM_RAM
805799   AM_RANGE(0xf000, 0xf001) AM_DEVREADWRITE("ymsnd", ym2151_r, ym2151_w)
806800   AM_RANGE(0xf002, 0xf002) AM_DEVREADWRITE("oki", okim6295_r, okim6295_w)
807//  AM_RANGE(0xf006, 0xf006) ??
801   //AM_RANGE(0xf006, 0xf006) ??
808802   AM_RANGE(0xf008, 0xf008) AM_READ(soundlatch_r)
809803   AM_RANGE(0xf00e, 0xf00e) AM_WRITE(oki_sound_bank_w)
810804ADDRESS_MAP_END
r7500r7501
813807   AM_RANGE(0x0000, 0xcfff) AM_ROM
814808   AM_RANGE(0xd000, 0xd7ff) AM_RAM
815809   AM_RANGE(0xf002, 0xf002) AM_DEVREADWRITE("oki", okim6295_r, okim6295_w)
816//  AM_RANGE(0xf006, 0xf006) ??
810   //AM_RANGE(0xf006, 0xf006) ??
817811   AM_RANGE(0xf008, 0xf008) AM_READ(soundlatch_r)
818812   AM_RANGE(0xf00e, 0xf00e) AM_WRITE(oki_sound_bank_w)
819813ADDRESS_MAP_END
r7500r7501
831825
832826static READ8_HANDLER(jumppop_z80latch_r)
833827{
834   cputag_set_input_line(space->machine, "audiocpu", 0, CLEAR_LINE);
828   tumbleb_state *state = (tumbleb_state *)space->machine->driver_data;
829   cpu_set_input_line(state->audiocpu, 0, CLEAR_LINE);
835830   return soundlatch_r(space, 0);
836831}
837832
r7500r7501
850845static ADDRESS_MAP_START( jumpkids_main_map, ADDRESS_SPACE_PROGRAM, 16 )
851846   AM_RANGE(0x000000, 0x07ffff) AM_ROM
852847   AM_RANGE(0x100000, 0x100001) AM_WRITE(jumpkids_sound_w)
853   AM_RANGE(0x120000, 0x123fff) AM_RAM AM_BASE(&tumblepb_mainram)
848   AM_RANGE(0x120000, 0x123fff) AM_RAM AM_BASE_MEMBER(tumbleb_state, mainram)
854849   AM_RANGE(0x140000, 0x1407ff) AM_RAM_WRITE(paletteram16_xxxxBBBBGGGGRRRR_word_w) AM_BASE_GENERIC(paletteram)
855   AM_RANGE(0x160000, 0x1607ff) AM_RAM AM_BASE_SIZE_GENERIC(spriteram) /* Bootleg sprite buffer */
850   AM_RANGE(0x160000, 0x1607ff) AM_RAM AM_BASE_SIZE_MEMBER(tumbleb_state, spriteram, spriteram_size) /* Bootleg sprite buffer */
856851   AM_RANGE(0x160800, 0x160807) AM_WRITEONLY /* writes past the end of spriteram */
857852   AM_RANGE(0x180000, 0x18000f) AM_READ(tumblepopb_controls_r)
858853   AM_RANGE(0x18000c, 0x18000d) AM_WRITENOP
859854   AM_RANGE(0x1a0000, 0x1a07ff) AM_RAM
860855   AM_RANGE(0x300000, 0x30000f) AM_WRITE(tumblepb_control_0_w)
861   AM_RANGE(0x320000, 0x320fff) AM_WRITE(tumblepb_pf1_data_w) AM_BASE(&tumblepb_pf1_data)
862   AM_RANGE(0x322000, 0x322fff) AM_WRITE(tumblepb_pf2_data_w) AM_BASE(&tumblepb_pf2_data)
856   AM_RANGE(0x320000, 0x320fff) AM_WRITE(tumblepb_pf1_data_w) AM_BASE_MEMBER(tumbleb_state, pf1_data)
857   AM_RANGE(0x322000, 0x322fff) AM_WRITE(tumblepb_pf2_data_w) AM_BASE_MEMBER(tumbleb_state, pf2_data)
863858   AM_RANGE(0x340000, 0x3401ff) AM_WRITENOP /* Unused row scroll */
864859   AM_RANGE(0x340400, 0x34047f) AM_WRITENOP /* Unused col scroll */
865860   AM_RANGE(0x342000, 0x3421ff) AM_WRITENOP
r7500r7501
872867   UINT8* sound2 = memory_region(space->machine, "oki2");
873868   int bank = data & 0x03;
874869
875   memcpy (sound1+0x20000, sound2+bank*0x20000, 0x20000);
870   memcpy(sound1 + 0x20000, sound2 + bank * 0x20000, 0x20000);
876871}
877872
878873static ADDRESS_MAP_START( jumpkids_sound_map, ADDRESS_SPACE_PROGRAM, 8 )
r7500r7501
19881983/******************************************************************************/
19891984
19901985
1986static MACHINE_START( tumbleb )
1987{
1988   tumbleb_state *state = (tumbleb_state *)machine->driver_data;
1989
1990   state->maincpu = devtag_get_device(machine, "maincpu");
1991   state->audiocpu = devtag_get_device(machine, "audiocpu");
1992   state->oki = devtag_get_device(machine, "oki");
1993
1994   state_save_register_global(machine, state->music_command);
1995   state_save_register_global(machine, state->music_bank);
1996   state_save_register_global(machine, state->music_is_playing);
1997
1998   state_save_register_global_array(machine, state->control_0);
1999   state_save_register_global(machine, state->flipscreen);
2000   state_save_register_global(machine, state->tilebank);
2001}
2002
2003static MACHINE_RESET( tumbleb )
2004{
2005   tumbleb_state *state = (tumbleb_state *)machine->driver_data;
2006
2007   state->music_command = 0;
2008   state->music_bank = 0;
2009   state->music_is_playing = 0;
2010   state->flipscreen = 0;
2011   state->tilebank = 0;
2012   memset(state->control_0, 0, ARRAY_LENGTH(state->control_0));
2013}
2014
19912015static MACHINE_DRIVER_START( tumblepb )
19922016
2017   /* driver data */
2018   MDRV_DRIVER_DATA(tumbleb_state)
2019
19932020   /* basic machine hardware */
19942021   MDRV_CPU_ADD("maincpu", M68000, 14000000)
19952022   MDRV_CPU_PROGRAM_MAP(tumblepopb_main_map)
19962023   MDRV_CPU_VBLANK_INT("screen", irq6_line_hold)
19972024
2025   MDRV_MACHINE_START(tumbleb)
2026   MDRV_MACHINE_RESET(tumbleb)
2027
19982028   /* video hardware */
19992029   MDRV_SCREEN_ADD("screen", RASTER)
20002030   MDRV_SCREEN_REFRESH_RATE(58)
r7500r7501
20202050
20212051static MACHINE_DRIVER_START( tumbleb2 )
20222052
2053   /* driver data */
2054   MDRV_DRIVER_DATA(tumbleb_state)
2055
20232056   /* basic machine hardware */
20242057   MDRV_CPU_ADD("maincpu", M68000, 14000000)
20252058   MDRV_CPU_PROGRAM_MAP(tumblepopb_main_map)
20262059   MDRV_CPU_VBLANK_INT("screen", tumbleb2_interrupt)
20272060
2061   MDRV_MACHINE_START(tumbleb)
2062   MDRV_MACHINE_RESET(tumbleb)
2063
20282064   /* video hardware */
20292065   MDRV_SCREEN_ADD("screen", RASTER)
20302066   MDRV_SCREEN_REFRESH_RATE(58)
r7500r7501
20492085
20502086static MACHINE_DRIVER_START( jumpkids )
20512087
2088   /* driver data */
2089   MDRV_DRIVER_DATA(tumbleb_state)
2090
20522091   /* basic machine hardware */
20532092   MDRV_CPU_ADD("maincpu", M68000, 12000000)
20542093   MDRV_CPU_PROGRAM_MAP(jumpkids_main_map)
r7500r7501
20582097   MDRV_CPU_ADD("audiocpu", Z80, 8000000/2)
20592098   MDRV_CPU_PROGRAM_MAP(jumpkids_sound_map)
20602099
2100   MDRV_MACHINE_START(tumbleb)
2101   MDRV_MACHINE_RESET(tumbleb)
2102
20612103   /* video hardware */
20622104   MDRV_SCREEN_ADD("screen", RASTER)
20632105   MDRV_SCREEN_REFRESH_RATE(60)
r7500r7501
20812123MACHINE_DRIVER_END
20822124
20832125static MACHINE_DRIVER_START( fncywld )
2126
2127   /* driver data */
2128   MDRV_DRIVER_DATA(tumbleb_state)
2129
20842130   /* basic machine hardware */
20852131   MDRV_CPU_ADD("maincpu", M68000, 12000000)
20862132   MDRV_CPU_PROGRAM_MAP(fncywld_main_map)
20872133   MDRV_CPU_VBLANK_INT("screen", irq6_line_hold)
20882134
2135   MDRV_MACHINE_START(tumbleb)
2136   MDRV_MACHINE_RESET(tumbleb)
2137
20892138   /* video hardware */
20902139   MDRV_SCREEN_ADD("screen", RASTER)
20912140   MDRV_SCREEN_REFRESH_RATE(60)
r7500r7501
21152164
21162165
21172166
2118static void semicom_irqhandler(running_device *device, int irq)
2167static void semicom_irqhandler( running_device *device, int irq )
21192168{
2120   cputag_set_input_line(device->machine, "audiocpu", 0, irq ? ASSERT_LINE : CLEAR_LINE);
2169   tumbleb_state *state = (tumbleb_state *)device->machine->driver_data;
2170   cpu_set_input_line(state->audiocpu, 0, irq ? ASSERT_LINE : CLEAR_LINE);
21212171}
21222172
21232173
r7500r7501
21282178
21292179static MACHINE_RESET (htchctch)
21302180{
2181   tumbleb_state *state = (tumbleb_state *)machine->driver_data;
2182
21312183   /* copy protection data every reset */
2132
21332184   UINT16 *PROTDATA = (UINT16*)memory_region(machine, "user1");
21342185   int i, len = memory_region_length(machine, "user1");
21352186
2136   for (i = 0;i < len/2;i++)
2137      tumblepb_mainram[0x000/2 + i] = PROTDATA[i];
2187   for (i = 0; i < len / 2; i++)
2188      state->mainram[0x000/2 + i] = PROTDATA[i];
21382189
2190   MACHINE_RESET_CALL(tumbleb);
21392191}
21402192
21412193static MACHINE_DRIVER_START( htchctch )
2194
2195   /* driver data */
2196   MDRV_DRIVER_DATA(tumbleb_state)
2197
21422198   /* basic machine hardware */
21432199   MDRV_CPU_ADD("maincpu", M68000, 15000000) /* verified */
21442200   MDRV_CPU_PROGRAM_MAP(htchctch_main_map)
r7500r7501
21472203   MDRV_CPU_ADD("audiocpu", Z80, 15000000/4) /* verified on dquizgo */
21482204   MDRV_CPU_PROGRAM_MAP(semicom_sound_map)
21492205
2150   MDRV_MACHINE_RESET ( htchctch )
2206   MDRV_MACHINE_START(tumbleb)
2207   MDRV_MACHINE_RESET(htchctch)
21512208
21522209   /* video hardware */
21532210   MDRV_SCREEN_ADD("screen", RASTER)
r7500r7501
21842241
21852242static MACHINE_DRIVER_START( bcstory )
21862243   MDRV_IMPORT_FROM(htchctch)
2187   MDRV_VIDEO_UPDATE( bcstory )
2244   MDRV_VIDEO_UPDATE(bcstory)
21882245
21892246   MDRV_SOUND_REPLACE("ymsnd", YM2151, 3427190)
21902247   MDRV_SOUND_CONFIG(semicom_ym2151_interface)
r7500r7501
22142271MACHINE_DRIVER_END
22152272
22162273static MACHINE_DRIVER_START( jumppop )
2274
2275   /* driver data */
2276   MDRV_DRIVER_DATA(tumbleb_state)
2277
22172278   /* basic machine hardware */
22182279   MDRV_CPU_ADD("maincpu", M68000, 16000000)
22192280   MDRV_CPU_PROGRAM_MAP(jumppop_main_map)
r7500r7501
22242285   MDRV_CPU_IO_MAP(jumppop_sound_io_map)
22252286   MDRV_CPU_PERIODIC_INT(nmi_line_pulse, 1953)   /* measured */
22262287
2288   MDRV_MACHINE_START(tumbleb)
2289   MDRV_MACHINE_RESET(tumbleb)
2290
22272291   /* video hardware */
22282292   MDRV_SCREEN_ADD("screen", RASTER)
22292293   MDRV_SCREEN_REFRESH_RATE(60)
r7500r7501
22522316
22532317static MACHINE_DRIVER_START( suprtrio )
22542318
2319   /* driver data */
2320   MDRV_DRIVER_DATA(tumbleb_state)
2321
22552322   /* basic machine hardware */
22562323   MDRV_CPU_ADD("maincpu", M68000, 14000000) /* 14mhz should be correct, but lots of sprite flicker later in game */
22572324   MDRV_CPU_PROGRAM_MAP(suprtrio_main_map)
r7500r7501
22602327   MDRV_CPU_ADD("audiocpu", Z80, 8000000)
22612328   MDRV_CPU_PROGRAM_MAP(suprtrio_sound_map)
22622329
2330   MDRV_MACHINE_START(tumbleb)
2331   MDRV_MACHINE_RESET(tumbleb)
2332
22632333   /* video hardware */
22642334   MDRV_SCREEN_ADD("screen", RASTER)
22652335   MDRV_SCREEN_REFRESH_RATE(60)
r7500r7501
22852355
22862356static MACHINE_DRIVER_START( pangpang )
22872357
2358   /* driver data */
2359   MDRV_DRIVER_DATA(tumbleb_state)
2360
22882361   /* basic machine hardware */
22892362   MDRV_CPU_ADD("maincpu", M68000, 14000000)
22902363   MDRV_CPU_PROGRAM_MAP(pangpang_main_map)
22912364   MDRV_CPU_VBLANK_INT("screen", tumbleb2_interrupt)
22922365
2366   MDRV_MACHINE_START(tumbleb)
2367   MDRV_MACHINE_RESET(tumbleb)
2368
22932369   /* video hardware */
22942370   MDRV_SCREEN_ADD("screen", RASTER)
22952371   MDRV_SCREEN_REFRESH_RATE(58)
r7500r7501
32553331   int i;
32563332
32573333   /* gfx data is in the wrong order */
3258   for (i = 0;i < len;i++)
3334   for (i = 0; i < len; i++)
32593335   {
32603336      if ((i & 0x20) == 0)
32613337      {
r7500r7501
32633339      }
32643340   }
32653341   /* low/high half are also swapped */
3266   for (i = 0;i < len/2;i++)
3342   for (i = 0; i < len/2; i++)
32673343   {
32683344      int t = rom[i]; rom[i] = rom[i + len/2]; rom[i + len/2] = t;
32693345   }
r7500r7501
33153391}
33163392
33173393
3318
3319
33203394static READ16_HANDLER( bcstory_1a0_read )
33213395{
3322
33233396   //mame_printf_debug("bcstory_io %06x\n",cpu_get_pc(space->cpu));
33243397
33253398   if (cpu_get_pc(space->cpu)==0x0560) return 0x1a0;
r7500r7501
33363409static DRIVER_INIT( htchctch )
33373410{
33383411
3412   tumbleb_state *state = (tumbleb_state *)machine->driver_data;
33393413//  UINT16 *HCROM = (UINT16*)memory_region(machine, "maincpu");
33403414   UINT16 *PROTDATA = (UINT16*)memory_region(machine, "user1");
33413415   int i, len = memory_region_length(machine, "user1");
r7500r7501
33473421//  };
33483422
33493423
3350//  for (i = 0;i < sizeof(htchctch_mcu68k)/sizeof(htchctch_mcu68k[0]);i++)
3351//      tumblepb_mainram[0x000/2 + i] = htchctch_mcu68k[i];
3424//  for (i = 0; i < sizeof(htchctch_mcu68k) / sizeof(htchctch_mcu68k[0]); i++)
3425//      state->mainram[0x000/2 + i] = htchctch_mcu68k[i];
33523426
3353   for (i = 0;i < len/2;i++)
3354      tumblepb_mainram[0x000/2 + i] = PROTDATA[i];
3427   for (i = 0; i < len / 2; i++)
3428      state->mainram[0x000/2 + i] = PROTDATA[i];
33553429
33563430
33573431
r7500r7501
35953669   int i;
35963670
35973671   /* decrypt main ROMs */
3598   memcpy(buf,rom,0x80000);
3599   for (i = 0;i < 0x40000;i++)
3672   memcpy(buf, rom, 0x80000);
3673   for (i = 0; i < 0x40000; i++)
36003674   {
36013675      int j = i ^ 0x06;
36023676      if ((i & 1) == 0) j ^= 0x02;
r7500r7501
36133687   int i;
36143688
36153689   /* decrypt tiles */
3616   memcpy(buf,rom,0x100000);
3617   for (i = 0;i < 0x80000;i++)
3690   memcpy(buf, rom, 0x100000);
3691   for (i = 0; i < 0x80000; i++)
36183692   {
36193693      int j = i ^ 0x02;
36203694      if (i & 1) j ^= 0x04;
r7500r7501
36563730
36573731/******************************************************************************/
36583732
3659GAME( 1991, tumbleb,  tumblep, tumblepb,  tumblepb, tumblepb, ROT0, "bootleg", "Tumble Pop (bootleg set 1)", GAME_IMPERFECT_SOUND )
3660GAME( 1991, tumbleb2, tumblep, tumbleb2,  tumblepb, tumbleb2, ROT0, "bootleg", "Tumble Pop (bootleg set 2)", GAME_IMPERFECT_SOUND ) // PIC is protected, sound simulation not 100%
3661GAME( 1993, jumpkids, 0,       jumpkids,  tumblepb, jumpkids, ROT0, "Comad", "Jump Kids", 0 )
3662GAME( 1994, metlsavr, 0,       metlsavr,  metlsavr, chokchok, ROT0, "First Amusement", "Metal Saver", 0 )
3663GAME( 1994, pangpang, 0,       pangpang,  tumblepb, tumbleb2, ROT0, "Dong Gue La Mi Ltd.", "Pang Pang", GAME_IMPERFECT_SOUND ) // PIC is protected, sound simulation not 100%
3664GAME( 1994, suprtrio, 0,       suprtrio,  suprtrio, suprtrio, ROT0, "Gameace", "Super Trio", 0 )
3733GAME( 1991, tumbleb,  tumblep, tumblepb,  tumblepb, tumblepb, ROT0, "bootleg", "Tumble Pop (bootleg set 1)", GAME_IMPERFECT_SOUND | GAME_SUPPORTS_SAVE  )
3734GAME( 1991, tumbleb2, tumblep, tumbleb2,  tumblepb, tumbleb2, ROT0, "bootleg", "Tumble Pop (bootleg set 2)", GAME_IMPERFECT_SOUND | GAME_SUPPORTS_SAVE  ) // PIC is protected, sound simulation not 100%
3735GAME( 1993, jumpkids, 0,       jumpkids,  tumblepb, jumpkids, ROT0, "Comad", "Jump Kids", GAME_SUPPORTS_SAVE )
3736GAME( 1994, metlsavr, 0,       metlsavr,  metlsavr, chokchok, ROT0, "First Amusement", "Metal Saver", GAME_SUPPORTS_SAVE )
3737GAME( 1994, pangpang, 0,       pangpang,  tumblepb, tumbleb2, ROT0, "Dong Gue La Mi Ltd.", "Pang Pang", GAME_IMPERFECT_SOUND | GAME_SUPPORTS_SAVE  ) // PIC is protected, sound simulation not 100%
3738GAME( 1994, suprtrio, 0,       suprtrio,  suprtrio, suprtrio, ROT0, "Gameace", "Super Trio", GAME_SUPPORTS_SAVE )
36653739// Should also be 'Magicball Fighting' (c)1994  see  http://kmrb.or.kr/Game_Image/1999/%EC%A0%9C1248%ED%98%B8.jpg
3666GAME( 1995, htchctch, 0,       htchctch,  htchctch, htchctch, ROT0, "SemiCom", "Hatch Catch" , 0 ) // not 100% sure about gfx offsets
3667GAME( 1995, cookbib,  0,       cookbib,   cookbib,  htchctch, ROT0, "SemiCom", "Cookie & Bibi" , 0 ) // not 100% sure about gfx offsets
3668GAME( 1995, chokchok, 0,       cookbib,   chokchok, chokchok, ROT0, "SemiCom", "Choky! Choky!", GAME_IMPERFECT_GRAPHICS ) // corruption during attract mode (tmap disable?)
3669GAME( 1995, wlstar,   0,       cookbib,   wlstar,   wlstar,   ROT0, "Mijin", "Wonder League Star - Sok-Magicball Fighting (Korea)", 0) // translates to 'Wonder League Star - Return of Magicball Fighting'
3670GAME( 1996, wondl96,  0,       cookbib,   wondl96,  wlstar,   ROT0, "SemiCom", "Wonder League '96 (Korea)", 0)
3671GAME( 1996, fncywld,  0,       fncywld,   fncywld,  fncywld,  ROT0, "Unico", "Fancy World - Earth of Crisis" , 0 ) // game says 1996, testmode 1995?
3672GAME( 1996, sdfight,  0,       sdfight,   sdfight,  bcstory,  ROT0, "SemiCom", "SD Fighters (Korea)", 0)
3673GAME( 1997, bcstry,   0,       bcstory,   bcstory,  bcstory,  ROT0, "SemiCom", "B.C. Story (set 1)", GAME_IMPERFECT_GRAPHICS) // gfx offsets?
3674GAME( 1997, bcstrya,  bcstry,  bcstory,   bcstory,  bcstory,  ROT0, "SemiCom", "B.C. Story (set 2)", GAME_IMPERFECT_GRAPHICS) // gfx offsets?
3675GAME( 1997, semibase, 0,       semibase,  semibase, bcstory,  ROT0, "SemiCom", "MuHanSeungBu (SemiCom Baseball) (Korea)", GAME_IMPERFECT_GRAPHICS)// sprite offsets..
3676GAME( 1998, dquizgo,  0,       cookbib,   dquizgo,  dquizgo,  ROT0, "SemiCom", "Date Quiz Go Go (Korea)", GAME_IMPERFECT_GRAPHICS) // check layer offsets
3677GAME( 2001, jumppop,  0,       jumppop,   jumppop,  0,        ORIENTATION_FLIP_X, "ESD", "Jumping Pop", 0 )
3740GAME( 1995, htchctch, 0,       htchctch,  htchctch, htchctch, ROT0, "SemiCom", "Hatch Catch" , GAME_SUPPORTS_SAVE ) // not 100% sure about gfx offsets
3741GAME( 1995, cookbib,  0,       cookbib,   cookbib,  htchctch, ROT0, "SemiCom", "Cookie & Bibi" , GAME_SUPPORTS_SAVE ) // not 100% sure about gfx offsets
3742GAME( 1995, chokchok, 0,       cookbib,   chokchok, chokchok, ROT0, "SemiCom", "Choky! Choky!", GAME_IMPERFECT_GRAPHICS | GAME_SUPPORTS_SAVE  ) // corruption during attract mode (tmap disable?)
3743GAME( 1995, wlstar,   0,       cookbib,   wlstar,   wlstar,   ROT0, "Mijin", "Wonder League Star - Sok-Magicball Fighting (Korea)", GAME_SUPPORTS_SAVE ) // translates to 'Wonder League Star - Return of Magicball Fighting'
3744GAME( 1996, wondl96,  0,       cookbib,   wondl96,  wlstar,   ROT0, "SemiCom", "Wonder League '96 (Korea)", GAME_SUPPORTS_SAVE )
3745GAME( 1996, fncywld,  0,       fncywld,   fncywld,  fncywld,  ROT0, "Unico", "Fancy World - Earth of Crisis" , GAME_SUPPORTS_SAVE ) // game says 1996, testmode 1995?
3746GAME( 1996, sdfight,  0,       sdfight,   sdfight,  bcstory,  ROT0, "SemiCom", "SD Fighters (Korea)", GAME_SUPPORTS_SAVE )
3747GAME( 1997, bcstry,   0,       bcstory,   bcstory,  bcstory,  ROT0, "SemiCom", "B.C. Story (set 1)", GAME_IMPERFECT_GRAPHICS | GAME_SUPPORTS_SAVE ) // gfx offsets?
3748GAME( 1997, bcstrya,  bcstry,  bcstory,   bcstory,  bcstory,  ROT0, "SemiCom", "B.C. Story (set 2)", GAME_IMPERFECT_GRAPHICS | GAME_SUPPORTS_SAVE ) // gfx offsets?
3749GAME( 1997, semibase, 0,       semibase,  semibase, bcstory,  ROT0, "SemiCom", "MuHanSeungBu (SemiCom Baseball) (Korea)", GAME_IMPERFECT_GRAPHICS | GAME_SUPPORTS_SAVE )// sprite offsets..
3750GAME( 1998, dquizgo,  0,       cookbib,   dquizgo,  dquizgo,  ROT0, "SemiCom", "Date Quiz Go Go (Korea)", GAME_IMPERFECT_GRAPHICS | GAME_SUPPORTS_SAVE ) // check layer offsets
3751GAME( 2001, jumppop,  0,       jumppop,   jumppop,  0,        ORIENTATION_FLIP_X, "ESD", "Jumping Pop", GAME_SUPPORTS_SAVE )
src/mame/drivers/momoko.c
r7500r7501
11/*****************************************************************************
22
3Momoko 120% (c) 1986 Jaleco
3    Momoko 120% (c) 1986 Jaleco
44
55    Driver by Uki
66
r7500r7501
4444#include "emu.h"
4545#include "cpu/z80/z80.h"
4646#include "sound/2203intf.h"
47#include "includes/momoko.h"
4748
48extern UINT8 *momoko_bg_scrollx;
49extern UINT8 *momoko_bg_scrolly;
5049
51VIDEO_UPDATE( momoko );
52
53WRITE8_HANDLER( momoko_fg_scrollx_w );
54WRITE8_HANDLER( momoko_fg_scrolly_w );
55WRITE8_HANDLER( momoko_text_scrolly_w );
56WRITE8_HANDLER( momoko_text_mode_w );
57WRITE8_HANDLER( momoko_bg_scrollx_w );
58WRITE8_HANDLER( momoko_bg_scrolly_w );
59WRITE8_HANDLER( momoko_flipscreen_w );
60WRITE8_HANDLER( momoko_fg_select_w);
61WRITE8_HANDLER( momoko_bg_select_w);
62WRITE8_HANDLER( momoko_bg_priority_w);
63
6450static WRITE8_HANDLER( momoko_bg_read_bank_w )
6551{
66   UINT8 *BG_MAP = memory_region(space->machine, "user1");
67   int bank_address = (data & 0x1f) * 0x1000;
68   memory_set_bankptr(space->machine, "bank1", &BG_MAP[bank_address]);
52   memory_set_bank(space->machine, "bank1", data & 0x1f);
6953}
7054
7155/****************************************************************************/
r7500r7501
7357static ADDRESS_MAP_START( momoko_map, ADDRESS_SPACE_PROGRAM, 8 )
7458   AM_RANGE(0x0000, 0xbfff) AM_ROM
7559   AM_RANGE(0xc000, 0xcfff) AM_RAM
76   AM_RANGE(0xd064, 0xd0ff) AM_RAM AM_BASE_SIZE_GENERIC(spriteram)
60   AM_RANGE(0xd064, 0xd0ff) AM_RAM AM_BASE_SIZE_MEMBER(momoko_state, spriteram, spriteram_size)
7761   AM_RANGE(0xd400, 0xd400) AM_READ_PORT("IN0") AM_WRITENOP /* interrupt ack? */
7862   AM_RANGE(0xd402, 0xd402) AM_READ_PORT("IN1") AM_WRITE(momoko_flipscreen_w)
7963   AM_RANGE(0xd404, 0xd404) AM_WRITE(watchdog_reset_w)
r7500r7501
8367   AM_RANGE(0xdc00, 0xdc00) AM_WRITE(momoko_fg_scrolly_w)
8468   AM_RANGE(0xdc01, 0xdc01) AM_WRITE(momoko_fg_scrollx_w)
8569   AM_RANGE(0xdc02, 0xdc02) AM_WRITE(momoko_fg_select_w)
86   AM_RANGE(0xe000, 0xe3ff) AM_RAM AM_BASE_GENERIC(videoram) AM_SIZE_GENERIC(videoram)
70   AM_RANGE(0xe000, 0xe3ff) AM_RAM AM_BASE_SIZE_MEMBER(momoko_state, videoram, videoram_size)
8771   AM_RANGE(0xe800, 0xe800) AM_WRITE(momoko_text_scrolly_w)
8872   AM_RANGE(0xe801, 0xe801) AM_WRITE(momoko_text_mode_w)
8973   AM_RANGE(0xf000, 0xffff) AM_ROMBANK("bank1")
90   AM_RANGE(0xf000, 0xf001) AM_WRITE(momoko_bg_scrolly_w) AM_BASE(&momoko_bg_scrolly)
91   AM_RANGE(0xf002, 0xf003) AM_WRITE(momoko_bg_scrollx_w) AM_BASE(&momoko_bg_scrollx)
74   AM_RANGE(0xf000, 0xf001) AM_WRITE(momoko_bg_scrolly_w) AM_BASE_MEMBER(momoko_state, bg_scrolly)
75   AM_RANGE(0xf002, 0xf003) AM_WRITE(momoko_bg_scrollx_w) AM_BASE_MEMBER(momoko_state, bg_scrollx)
9276   AM_RANGE(0xf004, 0xf004) AM_WRITE(momoko_bg_read_bank_w)
9377   AM_RANGE(0xf006, 0xf006) AM_WRITE(momoko_bg_select_w)
9478   AM_RANGE(0xf007, 0xf007) AM_WRITE(momoko_bg_priority_w)
r7500r7501
241225   NULL
242226};
243227
228static MACHINE_START( momoko )
229{
230   momoko_state *state = (momoko_state *)machine->driver_data;
231   UINT8 *BG_MAP = memory_region(machine, "user1");
232
233   memory_configure_bank(machine, "bank1", 0, 32, &BG_MAP[0x0000], 0x1000);
234
235   state_save_register_global(machine, state->fg_scrollx);
236   state_save_register_global(machine, state->fg_scrolly);
237   state_save_register_global(machine, state->fg_select);
238   state_save_register_global(machine, state->text_scrolly);
239   state_save_register_global(machine, state->text_mode);
240   state_save_register_global(machine, state->bg_select);
241   state_save_register_global(machine, state->bg_priority);
242   state_save_register_global(machine, state->bg_mask);
243   state_save_register_global(machine, state->fg_mask);
244   state_save_register_global(machine, state->flipscreen);
245}
246
247static MACHINE_RESET( momoko )
248{
249   momoko_state *state = (momoko_state *)machine->driver_data;
250
251   state->fg_scrollx = 0;
252   state->fg_scrolly = 0;
253   state->fg_select = 0;
254   state->text_scrolly = 0;
255   state->text_mode = 0;
256   state->bg_select = 0;
257   state->bg_priority = 0;
258   state->bg_mask = 0;
259   state->fg_mask = 0;
260   state->flipscreen = 0;
261}
262
244263static MACHINE_DRIVER_START( momoko )
245264
265   /* driver data */
266   MDRV_DRIVER_DATA(momoko_state)
267
246268   /* basic machine hardware */
247269   MDRV_CPU_ADD("maincpu", Z80, 5000000)   /* 5.0MHz */
248270   MDRV_CPU_PROGRAM_MAP(momoko_map)
r7500r7501
251273   MDRV_CPU_ADD("audiocpu", Z80, 2500000)   /* 2.5MHz */
252274   MDRV_CPU_PROGRAM_MAP(momoko_sound_map)
253275
276   MDRV_MACHINE_START(momoko)
277   MDRV_MACHINE_RESET(momoko)
278
254279   /* video hardware */
255280   MDRV_SCREEN_ADD("screen", RASTER)
256281   MDRV_SCREEN_REFRESH_RATE(60)
r7500r7501
324349   ROM_LOAD( "momoko-b.bin", 0x0100,  0x0020, CRC(427b0e5c) SHA1(aa2797b899571527cc96013fd3420b841954ee67) )
325350ROM_END
326351
327GAME( 1986, momoko, 0, momoko, momoko, 0, ROT0, "Jaleco", "Momoko 120%", 0 )
352GAME( 1986, momoko, 0, momoko, momoko, 0, ROT0, "Jaleco", "Momoko 120%", GAME_SUPPORTS_SAVE )
src/mame/drivers/olibochu.c
r7500r7501
5656#include "deprecat.h"
5757#include "sound/ay8910.h"
5858
59static UINT8 *videoram;
60static UINT8 *colorram;
61static tilemap_t *bg_tilemap;
59class olibochu_state
60{
61public:
62   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, olibochu_state(machine)); }
6263
64   olibochu_state(running_machine &machine) { }
65
66   /* memory pointers */
67   UINT8 *  videoram;
68   UINT8 *  colorram;
69   UINT8 *  spriteram;
70   UINT8 *  spriteram2;
71//  UINT8 *  paletteram;    // currently this uses generic palette handling
72   size_t   spriteram_size;
73   size_t   spriteram2_size;
74
75   /* video-related */
76   tilemap_t  *bg_tilemap;
77
78   /* misc */
79   int cmd;
80};
81
82
83
6384static PALETTE_INIT( olibochu )
6485{
6586   int i;
r7500r7501
7798         pen = (color_prom[0x120 + (i - 0x100)] & 0x0f) | 0x00;
7899
79100      /* red component */
80      bit0 = (color_prom[pen] >> 0) & 0x01;
81      bit1 = (color_prom[pen] >> 1) & 0x01;
82      bit2 = (color_prom[pen] >> 2) & 0x01;
101      bit0 = BIT(color_prom[pen], 0);
102      bit1 = BIT(color_prom[pen], 1);
103      bit2 = BIT(color_prom[pen], 2);
83104      r = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2;
84105
85106      /* green component */
86      bit0 = (color_prom[pen] >> 3) & 0x01;
87      bit1 = (color_prom[pen] >> 4) & 0x01;
88      bit2 = (color_prom[pen] >> 5) & 0x01;
107      bit0 = BIT(color_prom[pen], 3);
108      bit1 = BIT(color_prom[pen], 4);
109      bit2 = BIT(color_prom[pen], 5);
89110      g = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2;
90111
91112      /* blue component */
92      bit0 = (color_prom[pen] >> 6) & 0x01;
93      bit1 = (color_prom[pen] >> 7) & 0x01;
113      bit0 = BIT(color_prom[pen], 6);
114      bit1 = BIT(color_prom[pen], 7);
94115      b = 0x4f * bit0 + 0xa8 * bit1;
95116
96117      palette_set_color(machine, i, MAKE_RGB(r, g, b));
r7500r7501
99120
100121static WRITE8_HANDLER( olibochu_videoram_w )
101122{
102   videoram[offset] = data;
103   tilemap_mark_tile_dirty(bg_tilemap, offset);
123   olibochu_state *state = (olibochu_state *)space->machine->driver_data;
124   state->videoram[offset] = data;
125   tilemap_mark_tile_dirty(state->bg_tilemap, offset);
104126}
105127
106128static WRITE8_HANDLER( olibochu_colorram_w )
107129{
108   colorram[offset] = data;
109   tilemap_mark_tile_dirty(bg_tilemap, offset);
130   olibochu_state *state = (olibochu_state *)space->machine->driver_data;
131   state->colorram[offset] = data;
132   tilemap_mark_tile_dirty(state->bg_tilemap, offset);
110133}
111134
112135static WRITE8_HANDLER( olibochu_flipscreen_w )
r7500r7501
122145
123146static TILE_GET_INFO( get_bg_tile_info )
124147{
125   int attr = colorram[tile_index];
126   int code = videoram[tile_index] + ((attr & 0x20) << 3);
148   olibochu_state *state = (olibochu_state *)machine->driver_data;
149   int attr = state->colorram[tile_index];
150   int code = state->videoram[tile_index] + ((attr & 0x20) << 3);
127151   int color = (attr & 0x1f) + 0x20;
128152   int flags = ((attr & 0x40) ? TILE_FLIPX : 0) | ((attr & 0x80) ? TILE_FLIPY : 0);
129153
r7500r7501
132156
133157static VIDEO_START( olibochu )
134158{
135   bg_tilemap = tilemap_create(machine, get_bg_tile_info, tilemap_scan_rows,
136      8, 8, 32, 32);
159   olibochu_state *state = (olibochu_state *)machine->driver_data;
160   state->bg_tilemap = tilemap_create(machine, get_bg_tile_info, tilemap_scan_rows, 8, 8, 32, 32);
137161}
138162
139static void draw_sprites(running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect)
163static void draw_sprites( running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect )
140164{
141   UINT8 *spriteram = machine->generic.spriteram.u8;
142   UINT8 *spriteram_2 = machine->generic.spriteram2.u8;
165   olibochu_state *state = (olibochu_state *)machine->driver_data;
166   UINT8 *spriteram = state->spriteram;
167   UINT8 *spriteram_2 = state->spriteram2;
143168   int offs;
144169
145170   /* 16x16 sprites */
146
147   for (offs = 0;offs < machine->generic.spriteram_size;offs += 4)
171   for (offs = 0; offs < state->spriteram_size; offs += 4)
148172   {
149      int attr = spriteram[offs+1];
173      int attr = spriteram[offs + 1];
150174      int code = spriteram[offs];
151175      int color = attr & 0x3f;
152176      int flipx = attr & 0x40;
153177      int flipy = attr & 0x80;
154      int sx = spriteram[offs+3];
155      int sy = ((spriteram[offs+2] + 8) & 0xff) - 8;
178      int sx = spriteram[offs + 3];
179      int sy = ((spriteram[offs + 2] + 8) & 0xff) - 8;
156180
157181      if (flip_screen_get(machine))
158182      {
r7500r7501
170194   }
171195
172196   /* 8x8 sprites */
173
174   for (offs = 0;offs < machine->generic.spriteram2_size;offs += 4)
197   for (offs = 0; offs < state->spriteram2_size; offs += 4)
175198   {
176      int attr = spriteram_2[offs+1];
199      int attr = spriteram_2[offs + 1];
177200      int code = spriteram_2[offs];
178201      int color = attr & 0x3f;
179202      int flipx = attr & 0x40;
180203      int flipy = attr & 0x80;
181      int sx = spriteram_2[offs+3];
182      int sy = spriteram_2[offs+2];
204      int sx = spriteram_2[offs + 3];
205      int sy = spriteram_2[offs + 2];
183206
184207      if (flip_screen_get(machine))
185208      {
r7500r7501
199222
200223static VIDEO_UPDATE( olibochu )
201224{
202   tilemap_draw(bitmap, cliprect, bg_tilemap, 0, 0);
225   olibochu_state *state = (olibochu_state *)screen->machine->driver_data;
226   tilemap_draw(bitmap, cliprect, state->bg_tilemap, 0, 0);
203227   draw_sprites(screen->machine, bitmap, cliprect);
204228   return 0;
205229}
r7500r7501
207231
208232static WRITE8_HANDLER( sound_command_w )
209233{
210   static int cmd;
234   olibochu_state *state = (olibochu_state *)space->machine->driver_data;
211235   int c;
212236
213   if (offset == 0) cmd = (cmd & 0x00ff) | (data << 8);
214   else cmd = (cmd & 0xff00) | data;
237   if (offset == 0)
238      state->cmd = (state->cmd & 0x00ff) | (data << 8);
239   else
240      state->cmd = (state->cmd & 0xff00) | data;
215241
216   for (c = 15;c >= 0;c--)
217      if (cmd & (1 << c)) break;
242   for (c = 15; c >= 0; c--)
243      if (state->cmd & (1 << c)) break;
218244
219   if (c >= 0) soundlatch_w(space,0,15-c);
245   if (c >= 0) soundlatch_w(space, 0, 15 - c);
220246}
221247
222248
223249static ADDRESS_MAP_START( olibochu_map, ADDRESS_SPACE_PROGRAM, 8 )
224250   AM_RANGE(0x0000, 0x7fff) AM_ROM
225   AM_RANGE(0x8000, 0x83ff) AM_RAM_WRITE(olibochu_videoram_w) AM_BASE(&videoram)
226   AM_RANGE(0x8400, 0x87ff) AM_RAM_WRITE(olibochu_colorram_w) AM_BASE(&colorram)
251   AM_RANGE(0x8000, 0x83ff) AM_RAM_WRITE(olibochu_videoram_w) AM_BASE_MEMBER(olibochu_state, videoram)
252   AM_RANGE(0x8400, 0x87ff) AM_RAM_WRITE(olibochu_colorram_w) AM_BASE_MEMBER(olibochu_state, colorram)
227253   AM_RANGE(0x9000, 0x903f) AM_RAM //???
228254   AM_RANGE(0x9800, 0x983f) AM_RAM //???
229255   AM_RANGE(0xa000, 0xa000) AM_READ_PORT("IN0")
r7500r7501
234260   AM_RANGE(0xa005, 0xa005) AM_READ_PORT("DSW2")
235261   AM_RANGE(0xa800, 0xa801) AM_WRITE(sound_command_w)
236262   AM_RANGE(0xa802, 0xa802) AM_WRITE(olibochu_flipscreen_w)   /* bit 6 = enable sound? */
237   AM_RANGE(0xf400, 0xf41f) AM_RAM AM_BASE_SIZE_GENERIC(spriteram)
238   AM_RANGE(0xf440, 0xf47f) AM_RAM AM_BASE_SIZE_GENERIC(spriteram2)
263   AM_RANGE(0xf400, 0xf41f) AM_RAM AM_BASE_SIZE_MEMBER(olibochu_state, spriteram, spriteram_size)
264   AM_RANGE(0xf440, 0xf47f) AM_RAM AM_BASE_SIZE_MEMBER(olibochu_state, spriteram2, spriteram2_size)
239265   AM_RANGE(0xf000, 0xffff) AM_RAM
240266ADDRESS_MAP_END
241267
r7500r7501
397423      cpu_set_input_line_and_vector(device, 0, HOLD_LINE, 0xd7);   /* RST 10h */
398424}
399425
426static MACHINE_START( olibochu )
427{
428   olibochu_state *state = (olibochu_state *)machine->driver_data;
429
430   state_save_register_global(machine, state->cmd);
431}
432
433static MACHINE_RESET( olibochu )
434{
435   olibochu_state *state = (olibochu_state *)machine->driver_data;
436
437   state->cmd = 0;
438}
439
400440static MACHINE_DRIVER_START( olibochu )
401441
442   /* driver data */
443   MDRV_DRIVER_DATA(olibochu_state)
444
402445   /* basic machine hardware */
403446   MDRV_CPU_ADD("maincpu", Z80, 4000000)   /* 4 MHz ?? */
404447   MDRV_CPU_PROGRAM_MAP(olibochu_map)
r7500r7501
410453
411454//  MDRV_QUANTUM_PERFECT_CPU("maincpu")
412455
456   MDRV_MACHINE_START(olibochu)
457   MDRV_MACHINE_RESET(olibochu)
458
413459   /* video hardware */
414460   MDRV_SCREEN_ADD("screen", RASTER)
415461   MDRV_SCREEN_REFRESH_RATE(60)
r7500r7501
477523
478524
479525
480GAME( 1981, olibochu, 0, olibochu, olibochu, 0, ROT270, "Irem + GDI", "Oli-Boo-Chu", GAME_WRONG_COLORS | GAME_IMPERFECT_SOUND )
526GAME( 1981, olibochu, 0, olibochu, olibochu, 0, ROT270, "Irem + GDI", "Oli-Boo-Chu", GAME_WRONG_COLORS | GAME_IMPERFECT_SOUND | GAME_SUPPORTS_SAVE )
src/mame/drivers/kingdrby.c
r7500r7501
33King Derby (c) 1981 Tatsumi
44
55driver by Andrew Gardner, Angelo Salese & Roberto Fresca
6original cowrace.c by Luca Elia
67
78TODO:
89- remaining video issues, priorities, sprites etc.;
r7500r7501
1314- unknown memories;
1415- Garbage on the window tilemap if you win, it could be a BTANB (masked by the color prom).
1516- the name "King Derby" is a raw guess, there's a chance that it uses a different name
16  (but there isn't any title screen on the game?)
17  (but there isn't any title screen in the game?)
18- Fix I/O in the 1986 bootleg version;
1719
1820============================================================================================
1921
r7500r7501
6567#include "video/mc6845.h"
6668#include "machine/8255ppi.h"
6769#include "sound/ay8910.h"
70#include "sound/okim6295.h"
71#include "sound/2203intf.h"
6872
6973#define CLK_1   XTAL_20MHz
7074#define CLK_2   XTAL_3_579545MHz
r7500r7501
364368   AM_RANGE(0x7c00, 0x7c00) AM_READ_PORT("DSW")
365369ADDRESS_MAP_END
366370
371static ADDRESS_MAP_START( slave_1986_map, ADDRESS_SPACE_PROGRAM, 8 )
372   AM_RANGE(0x0000, 0x2fff) AM_ROM
373   AM_RANGE(0x3000, 0x3fff) AM_ROM //sound rom tested for the post check
374   AM_RANGE(0x4000, 0x47ff) AM_RAM AM_BASE_SIZE_GENERIC(nvram) //backup ram
375   AM_RANGE(0x5000, 0x5003) AM_DEVREADWRITE("ppi8255_0", ppi8255_r, ppi8255_w)   /* I/O Ports */
376   AM_RANGE(0x6000, 0x6003) AM_DEVREADWRITE("ppi8255_1", ppi8255_r, ppi8255_w)   /* I/O Ports */
377   AM_RANGE(0x7000, 0x73ff) AM_RAM AM_SHARE("share1")
378   AM_RANGE(0x7400, 0x74ff) AM_RAM AM_BASE_GENERIC(spriteram)
379   AM_RANGE(0x7600, 0x7600) AM_DEVWRITE("crtc", mc6845_address_w)
380   AM_RANGE(0x7601, 0x7601) AM_DEVREADWRITE("crtc", mc6845_register_r, mc6845_register_w)
381//  AM_RANGE(0x7800, 0x7803) AM_READ(test_r)
382   AM_RANGE(0x7a00, 0x7a00) AM_RAM //buffer for the key matrix
383   AM_RANGE(0x7c00, 0x7c00) AM_READ_PORT("DSW")
384ADDRESS_MAP_END
385
367386static ADDRESS_MAP_START( slave_io_map, ADDRESS_SPACE_IO, 8 )
368387   ADDRESS_MAP_GLOBAL_MASK(0xff)
369388   AM_RANGE(0x00, 0x00) AM_NOP //interrupt ack
r7500r7501
380399   AM_RANGE(0x40, 0x41) AM_DEVWRITE("aysnd", ay8910_data_address_w)
381400ADDRESS_MAP_END
382401
402static ADDRESS_MAP_START( cowrace_sound_map, ADDRESS_SPACE_PROGRAM, 8 )
403   AM_RANGE(0x0000, 0x1fff) AM_ROM
404   AM_RANGE(0x2000, 0x23ff) AM_RAM
405ADDRESS_MAP_END
406
407static ADDRESS_MAP_START( cowrace_sound_io, ADDRESS_SPACE_IO, 8 )
408   ADDRESS_MAP_GLOBAL_MASK(0xff)
409   AM_RANGE(0x40, 0x41) AM_DEVWRITE("aysnd", ym2203_w)
410ADDRESS_MAP_END
411
412
383413/*************************************
384414*
385415* PPI configuration
r7500r7501
412442   }
413443};
414444
445static const ppi8255_interface ppi8255_1986_intf[2] =
446{
447   /* C as input, (all) as output */
448   {
449      DEVCB_NULL,                           /* Port A read */
450      DEVCB_INPUT_PORT("IN0"),           /* Port B read */
451      DEVCB_INPUT_PORT("IN1"),      /* Port C read */
452      DEVCB_NULL,               /* Port A write */
453      DEVCB_NULL,               /* Port B write */
454      DEVCB_NULL   /* Port C write */
455   },
456
457   /*  */
458   {
459      DEVCB_NULL,               /* Port A read */
460      DEVCB_HANDLER(key_matrix_r),/* Port B read */
461      DEVCB_HANDLER(input_mux_r),   /* Port C read */
462      DEVCB_HANDLER(sound_cmd_w),  /* Port A write */
463      DEVCB_NULL,               /* Port B write */
464      DEVCB_HANDLER(outport2_w)   /* Port C write */
465   }
466};
467
415468/*************************************
416469 *
417470 *  Input Port Definitions
r7500r7501
575628   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
576629INPUT_PORTS_END
577630
631static INPUT_PORTS_START( kingdrbb )
632   /*this might be different.*/
633   PORT_START("HPIO")   // ppi0 (5000)
634   PORT_DIPNAME( 0x01, 0x01, "HPIO" )
635   PORT_DIPSETTING(    0x01, DEF_STR( Off ) )
636   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
637   PORT_DIPNAME( 0x02, 0x02, DEF_STR( Unknown ) )
638   PORT_DIPSETTING(    0x02, DEF_STR( Off ) )
639   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
640   PORT_DIPNAME( 0x04, 0x04, DEF_STR( Unknown ) )
641   PORT_DIPSETTING(    0x04, DEF_STR( Off ) )
642   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
643   PORT_DIPNAME( 0x08, 0x08, DEF_STR( Unknown ) )
644   PORT_DIPSETTING(    0x08, DEF_STR( Off ) )
645   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
646   PORT_DIPNAME( 0x10, 0x10, DEF_STR( Unknown ) )
647   PORT_DIPSETTING(    0x10, DEF_STR( Off ) )
648   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
649   PORT_DIPNAME( 0x20, 0x20, DEF_STR( Unknown ) )
650   PORT_DIPSETTING(    0x20, DEF_STR( Off ) )
651   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
652   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_SPECIAL ) //1p hopper i/o
653   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_SPECIAL ) //2p hopper i/o
654
655   PORT_START("IN0")   // ppi0 (5001)
656   PORT_DIPNAME( 0x01, 0x01, "IN0" )
657   PORT_DIPSETTING(    0x01, DEF_STR( Off ) )
658   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
659   PORT_DIPNAME( 0x02, 0x02, DEF_STR( Unknown ) )
660   PORT_DIPSETTING(    0x02, DEF_STR( Off ) )
661   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
662   PORT_DIPNAME( 0x04, 0x04, DEF_STR( Unknown ) )
663   PORT_DIPSETTING(    0x04, DEF_STR( Off ) )
664   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
665   PORT_DIPNAME( 0x08, 0x08, DEF_STR( Unknown ) )
666   PORT_DIPSETTING(    0x08, DEF_STR( Off ) )
667   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
668   PORT_DIPNAME( 0x10, 0x10, DEF_STR( Unknown ) )
669   PORT_DIPSETTING(    0x10, DEF_STR( Off ) )
670   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
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 ) )
680
681   PORT_START("IN1")   // ppi0 (5001)
682   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_VBLANK ) //?
683   PORT_DIPNAME( 0x02, 0x02, "IN1" )
684   PORT_DIPSETTING(    0x02, DEF_STR( Off ) )
685   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
686   PORT_DIPNAME( 0x04, 0x04, DEF_STR( Unknown ) )
687   PORT_DIPSETTING(    0x04, DEF_STR( Off ) )
688   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
689   PORT_DIPNAME( 0x08, 0x08, DEF_STR( Unknown ) )
690   PORT_DIPSETTING(    0x08, DEF_STR( Off ) )
691   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
692   PORT_DIPNAME( 0x10, 0x10, DEF_STR( Unknown ) )
693   PORT_DIPSETTING(    0x10, DEF_STR( Off ) )
694   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
695   PORT_DIPNAME( 0x20, 0x20, DEF_STR( Unknown ) )
696   PORT_DIPSETTING(    0x20, DEF_STR( Off ) )
697   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
698   PORT_DIPNAME( 0x40, 0x40, DEF_STR( Unknown ) )
699   PORT_DIPSETTING(    0x40, DEF_STR( Off ) )
700   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
701   PORT_DIPNAME( 0x80, 0x80, DEF_STR( Unknown ) )
702   PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
703   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
704
705   PORT_START("KEY_1P")   // ppi1 (6001)
706   PORT_BIT( 0x0001, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_NAME("1P 1-2") PORT_CODE(KEYCODE_Q)
707   PORT_BIT( 0x0002, IP_ACTIVE_HIGH, IPT_BUTTON2 ) PORT_NAME("1P 1-3") PORT_CODE(KEYCODE_W)
708   PORT_BIT( 0x0004, IP_ACTIVE_HIGH, IPT_BUTTON3 ) PORT_NAME("1P 1-4") PORT_CODE(KEYCODE_E)
709   PORT_BIT( 0x0008, IP_ACTIVE_HIGH, IPT_BUTTON4 ) PORT_NAME("1P 1-5") PORT_CODE(KEYCODE_R)
710   PORT_BIT( 0x0010, IP_ACTIVE_HIGH, IPT_BUTTON5 ) PORT_NAME("1P 1-6") PORT_CODE(KEYCODE_T)
711   PORT_BIT( 0x0020, IP_ACTIVE_HIGH, IPT_BUTTON6 ) PORT_NAME("1P 2-3") PORT_CODE(KEYCODE_A)
712   PORT_BIT( 0x0040, IP_ACTIVE_HIGH, IPT_BUTTON7 ) PORT_NAME("1P 2-4") PORT_CODE(KEYCODE_S)
713   PORT_BIT( 0x0080, IP_ACTIVE_HIGH, IPT_BUTTON8 ) PORT_NAME("1P 2-5") PORT_CODE(KEYCODE_D)
714   PORT_BIT( 0x0100, IP_ACTIVE_HIGH, IPT_BUTTON9 ) PORT_NAME("1P 2-6") PORT_CODE(KEYCODE_F)
715   PORT_BIT( 0x0200, IP_ACTIVE_HIGH, IPT_BUTTON10 ) PORT_NAME("1P 3-4") PORT_CODE(KEYCODE_G)
716   PORT_BIT( 0x0400, IP_ACTIVE_HIGH, IPT_BUTTON11 ) PORT_NAME("1P 3-5") PORT_CODE(KEYCODE_H)
717   PORT_BIT( 0x0800, IP_ACTIVE_HIGH, IPT_BUTTON12 ) PORT_NAME("1P 3-6") PORT_CODE(KEYCODE_Z)
718   PORT_BIT( 0x1000, IP_ACTIVE_HIGH, IPT_BUTTON13 ) PORT_NAME("1P 4-5") PORT_CODE(KEYCODE_X)
719   PORT_BIT( 0x2000, IP_ACTIVE_HIGH, IPT_BUTTON14 ) PORT_NAME("1P 4-6") PORT_CODE(KEYCODE_C)
720   PORT_BIT( 0x4000, IP_ACTIVE_HIGH, IPT_BUTTON15 ) PORT_NAME("1P 5-6") PORT_CODE(KEYCODE_V)
721   PORT_BIT( 0x8000, IP_ACTIVE_HIGH, IPT_UNUSED )
722
723   PORT_START("KEY_2P")   // ppi1 (6001)
724   PORT_BIT( 0x0001, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_NAME("2P 1-2") PORT_CODE(KEYCODE_Q) PORT_COCKTAIL
725   PORT_BIT( 0x0002, IP_ACTIVE_HIGH, IPT_BUTTON2 ) PORT_NAME("2P 1-3") PORT_CODE(KEYCODE_W) PORT_COCKTAIL
726   PORT_BIT( 0x0004, IP_ACTIVE_HIGH, IPT_BUTTON3 ) PORT_NAME("2P 1-4") PORT_CODE(KEYCODE_E) PORT_COCKTAIL
727   PORT_BIT( 0x0008, IP_ACTIVE_HIGH, IPT_BUTTON4 ) PORT_NAME("2P 1-5") PORT_CODE(KEYCODE_R) PORT_COCKTAIL
728   PORT_BIT( 0x0010, IP_ACTIVE_HIGH, IPT_BUTTON5 ) PORT_NAME("2P 1-6") PORT_CODE(KEYCODE_T) PORT_COCKTAIL
729   PORT_BIT( 0x0020, IP_ACTIVE_HIGH, IPT_BUTTON6 ) PORT_NAME("2P 2-3") PORT_CODE(KEYCODE_A) PORT_COCKTAIL
730   PORT_BIT( 0x0040, IP_ACTIVE_HIGH, IPT_BUTTON7 ) PORT_NAME("2P 2-4") PORT_CODE(KEYCODE_S) PORT_COCKTAIL
731   PORT_BIT( 0x0080, IP_ACTIVE_HIGH, IPT_BUTTON8 ) PORT_NAME("2P 2-5") PORT_CODE(KEYCODE_D) PORT_COCKTAIL
732   PORT_BIT( 0x0100, IP_ACTIVE_HIGH, IPT_BUTTON9 ) PORT_NAME("2P 2-6") PORT_CODE(KEYCODE_F) PORT_COCKTAIL
733   PORT_BIT( 0x0200, IP_ACTIVE_HIGH, IPT_BUTTON10 ) PORT_NAME("2P 3-4") PORT_CODE(KEYCODE_G) PORT_COCKTAIL
734   PORT_BIT( 0x0400, IP_ACTIVE_HIGH, IPT_BUTTON11 ) PORT_NAME("2P 3-5") PORT_CODE(KEYCODE_H) PORT_COCKTAIL
735   PORT_BIT( 0x0800, IP_ACTIVE_HIGH, IPT_BUTTON12 ) PORT_NAME("2P 3-6") PORT_CODE(KEYCODE_Z) PORT_COCKTAIL
736   PORT_BIT( 0x1000, IP_ACTIVE_HIGH, IPT_BUTTON13 ) PORT_NAME("2P 4-5") PORT_CODE(KEYCODE_X) PORT_COCKTAIL
737   PORT_BIT( 0x2000, IP_ACTIVE_HIGH, IPT_BUTTON14 ) PORT_NAME("2P 4-6") PORT_CODE(KEYCODE_C) PORT_COCKTAIL
738   PORT_BIT( 0x4000, IP_ACTIVE_HIGH, IPT_BUTTON15 ) PORT_NAME("2P 5-6") PORT_CODE(KEYCODE_V) PORT_COCKTAIL
739   PORT_BIT( 0x8000, IP_ACTIVE_HIGH, IPT_UNUSED )
740
741   PORT_START("MUX0")   // ppi1 (6002)
742   PORT_DIPNAME( 0x01, 0x01, "SYSTEM" )
743   PORT_DIPSETTING(    0x01, DEF_STR( Off ) )
744   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
745   PORT_DIPNAME( 0x02, 0x02, DEF_STR( Unknown ) )
746   PORT_DIPSETTING(    0x02, DEF_STR( Off ) )
747   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
748   PORT_DIPNAME( 0x04, 0x04, DEF_STR( Unknown ) )
749   PORT_DIPSETTING(    0x04, DEF_STR( Off ) )
750   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
751   PORT_DIPNAME( 0x08, 0x08, DEF_STR( Unknown ) )
752   PORT_DIPSETTING(    0x08, DEF_STR( Off ) )
753   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
754   PORT_DIPNAME( 0x10, 0x10, DEF_STR( Unknown ) )
755   PORT_DIPSETTING(    0x10, DEF_STR( Off ) )
756   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
757   PORT_DIPNAME( 0x20, 0x20, DEF_STR( Unknown ) )
758   PORT_DIPSETTING(    0x20, DEF_STR( Off ) )
759   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
760   PORT_DIPNAME( 0x40, 0x40, DEF_STR( Unknown ) )
761   PORT_DIPSETTING(    0x40, DEF_STR( Off ) )
762   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
763   PORT_DIPNAME( 0x80, 0x80, DEF_STR( Unknown ) )
764   PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
765   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
766
767   PORT_START("MUX1")
768   PORT_DIPNAME( 0x01, 0x01, "SYSTEM" )
769   PORT_DIPSETTING(    0x01, DEF_STR( Off ) )
770   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
771   PORT_DIPNAME( 0x02, 0x02, DEF_STR( Unknown ) )
772   PORT_DIPSETTING(    0x02, DEF_STR( Off ) )
773   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
774   PORT_DIPNAME( 0x04, 0x04, DEF_STR( Unknown ) )
775   PORT_DIPSETTING(    0x04, DEF_STR( Off ) )
776   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
777   PORT_DIPNAME( 0x08, 0x08, DEF_STR( Unknown ) )
778   PORT_DIPSETTING(    0x08, DEF_STR( Off ) )
779   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
780   PORT_DIPNAME( 0x10, 0x10, DEF_STR( Unknown ) )
781   PORT_DIPSETTING(    0x10, DEF_STR( Off ) )
782   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
783   PORT_DIPNAME( 0x20, 0x20, DEF_STR( Unknown ) )
784   PORT_DIPSETTING(    0x20, DEF_STR( Off ) )
785   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
786   PORT_DIPNAME( 0x40, 0x40, DEF_STR( Unknown ) )
787   PORT_DIPSETTING(    0x40, DEF_STR( Off ) )
788   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
789   PORT_DIPNAME( 0x80, 0x80, DEF_STR( Unknown ) )
790   PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
791   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
792
793   PORT_START("DSW")
794   PORT_DIPNAME( 0x01, 0x01, "SYSTEM" )
795   PORT_DIPSETTING(    0x01, DEF_STR( Off ) )
796   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
797   PORT_DIPNAME( 0x02, 0x02, DEF_STR( Unknown ) )
798   PORT_DIPSETTING(    0x02, DEF_STR( Off ) )
799   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
800   PORT_DIPNAME( 0x04, 0x04, DEF_STR( Unknown ) )
801   PORT_DIPSETTING(    0x04, DEF_STR( Off ) )
802   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
803   PORT_DIPNAME( 0x08, 0x08, DEF_STR( Unknown ) )
804   PORT_DIPSETTING(    0x08, DEF_STR( Off ) )
805   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
806   PORT_DIPNAME( 0x10, 0x10, DEF_STR( Unknown ) )
807   PORT_DIPSETTING(    0x10, DEF_STR( Off ) )
808   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
809   PORT_DIPNAME( 0x20, 0x20, "Game Type?" ) //enables two new msgs "advance" and "exchange" in analyzer mode
810   PORT_DIPSETTING(    0x20, DEF_STR( Off ) )
811   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
812   PORT_DIPNAME( 0x40, 0x40, "POST Check" )
813   PORT_DIPSETTING(    0x40, DEF_STR( Off ) )
814   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
815   PORT_DIPNAME( 0x80, 0x80, DEF_STR( Unknown ) )
816   PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
817   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
818INPUT_PORTS_END
819
578820/*************************************
579821*
580822* GFX decoding
r7500r7501
609851   16*16
610852};
611853
854/* seems more suitable with 2bpp?*/
855static const gfx_layout cowrace_layout16x16x2 =
856{
857   16,16,
858   RGN_FRAC(1,2),
859   2,
860   {
861      RGN_FRAC(1,2),
862      RGN_FRAC(0,2),
863   },
864   { 16*8+0,16*8+1,16*8+2,16*8+3,16*8+4,16*8+5,16*8+6,16*8+7,0,1,2,3,4,5,6,7 },
865   { 0*8,1*8,2*8,3*8,4*8,5*8,6*8,7*8,8*8,9*8,10*8,11*8,12*8,13*8,14*8,15*8  },
866   16*16
867};
868
612869static GFXDECODE_START( kingdrby )
613870   GFXDECODE_ENTRY( "gfx1", 0x0000, layout16x16x2, 0x080, 0x10 )
614871   GFXDECODE_ENTRY( "gfx2", 0x0000, layout8x8x2,   0x000, 0x80 )
615872GFXDECODE_END
616873
874static GFXDECODE_START( cowrace )
875   GFXDECODE_ENTRY( "gfx1", 0x000000, cowrace_layout16x16x2, 0x080, 0x10 )
876   GFXDECODE_ENTRY( "gfx2", 0x000000, layout8x8x2, 0x000, 0x80 )
877GFXDECODE_END
878
617879/**********************************************************************************************************
618880*
619881* MC6845 interface
r7500r7501
655917   DEVCB_NULL /* discrete write? */
656918};
657919
920static const ym2203_interface cowrace_ym2203_interface =
921{
922   {
923      AY8910_LEGACY_OUTPUT,
924      AY8910_DEFAULT_LOADS,
925      DEVCB_HANDLER(sound_cmd_r),                           // read A
926      DEVCB_DEVICE_HANDLER("oki", okim6295_r),               // read B
927      DEVCB_NULL,                                       // write A
928      DEVCB_DEVICE_HANDLER("oki", okim6295_w)                  // write B
929   },
930   NULL
931};
932
658933static PALETTE_INIT(kingdrby)
659934{
660935   int   bit0, bit1, bit2 , r, g, b;
r7500r7501
7261001   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.25)
7271002MACHINE_DRIVER_END
7281003
1004static MACHINE_DRIVER_START( kingdrbb )
1005   MDRV_IMPORT_FROM( kingdrby )
7291006
1007   MDRV_CPU_MODIFY("slave")
1008   MDRV_CPU_PROGRAM_MAP(slave_1986_map)
1009
1010   MDRV_PPI8255_RECONFIG( "ppi8255_0", ppi8255_1986_intf[0] )
1011   MDRV_PPI8255_RECONFIG( "ppi8255_1", ppi8255_1986_intf[1] )
1012MACHINE_DRIVER_END
1013
1014static MACHINE_DRIVER_START( cowrace )
1015   MDRV_IMPORT_FROM( kingdrbb )
1016
1017   MDRV_CPU_MODIFY("soundcpu")
1018   MDRV_CPU_PROGRAM_MAP(cowrace_sound_map)
1019   MDRV_CPU_IO_MAP(cowrace_sound_io)
1020
1021   MDRV_GFXDECODE(cowrace)
1022
1023   MDRV_SOUND_ADD("oki", OKIM6295, 1056000)
1024   MDRV_SOUND_CONFIG(okim6295_interface_pin7high) // clock frequency & pin 7 not verified
1025   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.80)
1026
1027   MDRV_SOUND_REPLACE("aysnd", YM2203, 3000000)
1028   MDRV_SOUND_CONFIG(cowrace_ym2203_interface)
1029   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.80)
1030MACHINE_DRIVER_END
1031
7301032ROM_START( kingdrby )
7311033   ROM_REGION( 0x3000, "master", 0 )
7321034   ROM_LOAD( "im4_d.d6",  0x0000, 0x1000, CRC(20f2d999) SHA1(91db46059f32b4791460df3330260f4e60f016a5) )
r7500r7501
7631065   ROM_LOAD( "147.f8",  0x000, 0x200, CRC(9245c4af) SHA1(813d628ac55913542a4deabe6ac0a4f9db09cf19) )
7641066ROM_END
7651067
766GAME( 1981, kingdrby,  0,      kingdrby,   kingdrby,   0,       ROT0,   "Tazmi",    "King Derby",   GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_COLORS| GAME_IMPERFECT_SOUND )
1068// might be closer to the original than the cowrace bootleg even if it shares some roms with cowrace?
1069ROM_START( kingdrbb ) // has 'Made in Taiwan' on the PCB.
1070   ROM_REGION( 0x8000, "master", 0 )
1071   ROM_LOAD( "kingdrbb_u3.bin", 0x0000, 0x4000, CRC(90a14686) SHA1(ce2ee8c0cbb4212aa8e71d7145b1eefb4f282590) )
1072   ROM_CONTINUE(0x0000,0x4000)
1073
1074   ROM_REGION( 0x4000, "slave", 0 ) // slave z80?
1075   ROM_LOAD( "kingdrbb_u30.bin", 0x0000, 0x4000, CRC(98717214) SHA1(70ca61c15f66642b85dd248b24638a95a8254bbb) )
1076   ROM_CONTINUE(0x0000,0x4000)
1077
1078   ROM_REGION( 0x4000, "soundcpu", 0 ) // audio z80?
1079   ROM_LOAD( "kingdrbb_u161.bin", 0x0000, 0x4000, CRC(7d84b577) SHA1(d230b49df19bf68793a561f4c07413d22fa8ff28) )
1080
1081   ROM_REGION( 0x8000, "gfx1", 0 )
1082   ROM_LOAD( "kingdrbb_u94.bin", 0x0000, 0x4000, CRC(ba59e4b8) SHA1(425dc4055d5ea400eeef33e26fcc73fa726f414d) )
1083   ROM_LOAD( "kingdrbb_u95.bin", 0x4000, 0x4000, CRC(fa97deb6) SHA1(1630281f0cac3fe3bfaf924e1c6316107200eb4a) )
1084
1085   ROM_REGION( 0x4000, "gfx2", 0 )
1086   ROM_LOAD( "kingdrbb_u39.bin", 0x0000, 0x2000, CRC(4a34cef0) SHA1(b54f1f2ccd3dd773e47bfb044c5aec15c11426c2) )
1087   ROM_LOAD( "kingdrbb_u140.bin", 0x2000, 0x2000, CRC(7e24b674) SHA1(c774efeb8e4e833e73c29007d5294c93df1abef4) )
1088
1089   ROM_REGION( 0x4000, "raw_prom", 0 )
1090   ROM_LOAD( "kingdrbb_u1.bin", 0x0000, 0x4000, CRC(97931952) SHA1(a0ef3be105f2ed7f744c73e92c583d25bb322e6a) ) // palette but in a normal rom?
1091
1092   ROM_REGION( 0x200, "proms", 0 )
1093   ROM_COPY( "raw_prom", 0x1000, 0x000, 0x200 )
1094//  ROM_COPY( "raw_prom", 0x3000, 0x200, 0x200 ) //identical to 0x1000 bank
1095
1096   ROM_REGION( 0x4000, "pals", 0 ) // all read protected
1097   ROM_LOAD( "palce16v.u101.bin", 0x0000, 0x117, CRC(c89d2f52) SHA1(f9d52d9c42ef95b7b85bbf6d09888ebdeac11fd3) )
1098   ROM_LOAD( "palce16v.u113.bin", 0x0000, 0x117, CRC(c89d2f52) SHA1(f9d52d9c42ef95b7b85bbf6d09888ebdeac11fd3) )
1099   ROM_LOAD( "palce16v.u160.bin", 0x0000, 0x117, CRC(c89d2f52) SHA1(f9d52d9c42ef95b7b85bbf6d09888ebdeac11fd3) )
1100   ROM_LOAD( "palce16v.u2.bin",   0x0000, 0x117, CRC(c89d2f52) SHA1(f9d52d9c42ef95b7b85bbf6d09888ebdeac11fd3) )
1101   ROM_LOAD( "palce16v.u29.bin",  0x0000, 0x117, CRC(c89d2f52) SHA1(f9d52d9c42ef95b7b85bbf6d09888ebdeac11fd3) )
1102   ROM_LOAD( "palce16v.u4.bin",   0x0000, 0x117, CRC(c89d2f52) SHA1(f9d52d9c42ef95b7b85bbf6d09888ebdeac11fd3) )
1103   ROM_LOAD( "palce16v.u75.bin",  0x0000, 0x117, CRC(c89d2f52) SHA1(f9d52d9c42ef95b7b85bbf6d09888ebdeac11fd3) )
1104   // jedutil just complains these are invalid..
1105   ROM_LOAD( "palce16v8q.u53.jed", 0x0000, 0x892, CRC(123d539a) SHA1(cccf0cbae3175b091a998eedf4aa44a55b679400) )
1106   ROM_LOAD( "palce16v8q.u77.jed", 0x0000, 0x892, CRC(b7956421) SHA1(57db38b571adf6cf49d7c221cd65a068a9a3383a) )
1107   ROM_LOAD( "palce16v8q.u87.jed", 0x0000, 0x892, CRC(b7956421) SHA1(57db38b571adf6cf49d7c221cd65a068a9a3383a) )
1108ROM_END
1109
1110ROM_START( cowrace )
1111   ROM_REGION( 0x8000, "master", 0 )
1112   ROM_LOAD( "u3.bin", 0x0000, 0x8000, CRC(c05c3bd3) SHA1(b7199a069ab45edd25e021589b79105cdfa5511a) )
1113
1114   ROM_REGION( 0x8000, "slave", ROMREGION_ERASEFF ) // slave z80?
1115   /* I've tried the kingdrbb slave CPU rom ... game works until the auto race in attract mode. We need to locate and dump this on the PCB. */
1116   ROM_LOAD( "slave.bin", 0x0000, 0x8000, NO_DUMP )
1117   ROM_FILL( 0x0000, 0x8000, 0xff ) // <- to remove once that the above is dumped
1118
1119   ROM_REGION( 0x2000, "soundcpu", 0 )
1120   ROM_LOAD( "u164.bin", 0x0000, 0x2000, CRC(9affa1c8) SHA1(bfc07693e8f749cbf20ab8cda33975b66f567962) )
1121
1122   ROM_REGION( 0x10000, "gfx1", 0 )
1123   ROM_LOAD( "u94.bin", 0x8000, 0x8000, CRC(945dc115) SHA1(bdd145234e6361c42ed20e8ca4cac64f07332748) )
1124   ROM_LOAD( "u95.bin", 0x0000, 0x8000, CRC(fc1fc006) SHA1(326a67c1ea0f487ecc8b7aef2d90124a01e6dee3) )
1125
1126   ROM_REGION( 0x4000, "gfx2", 0 )
1127   ROM_LOAD( "u139.bin", 0x2000, 0x2000, CRC(b746bb2f) SHA1(5f5f48752689079ed65fe7bb4a69512ada5db05d) )
1128   ROM_LOAD( "u140.bin", 0x0000, 0x2000, CRC(7e24b674) SHA1(c774efeb8e4e833e73c29007d5294c93df1abef4) )
1129
1130   ROM_REGION( 0x40000, "oki", 0 )
1131   ROM_LOAD( "u4.bin", 0x00000, 0x20000, CRC(f92a3ab5) SHA1(fc164492793597eadb8a50154410936edb74fa23) )
1132
1133   ROM_REGION( 0x20000, "proms", 0 )
1134   ROM_LOAD( "u149.bin", 0x00000, 0x200, CRC(f41a5eca) SHA1(797f2d95d4e00f96e5a99604935810e1add59689) )
1135ROM_END
1136
1137
1138GAME( 1981, kingdrby,  0,             kingdrby,   kingdrby,   0,       ROT0,   "Tazmi",    "King Derby (1981)",   GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_COLORS| GAME_IMPERFECT_SOUND )
1139GAME( 1986, kingdrbb,  kingdrby,      kingdrbb,   kingdrbb,   0,       ROT0,   "bootleg",  "King Derby (1986 Taiwan bootleg)",   GAME_NOT_WORKING | GAME_IMPERFECT_GRAPHICS | GAME_WRONG_COLORS | GAME_IMPERFECT_SOUND )
1140GAME( 2000, cowrace,   kingdrby,      cowrace,    kingdrbb,   0,       ROT0,   "bootleg",  "Cow Race (1986 King Derby hack)", GAME_NOT_WORKING | GAME_WRONG_COLORS )
src/mame/drivers/embargo.c
r7500r7501
88#include "cpu/s2650/s2650.h"
99
1010
11typedef struct _embargo_state embargo_state;
12struct _embargo_state
11class embargo_state
1312{
13public:
14   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, embargo_state(machine)); }
15
16   embargo_state(running_machine &machine) { }
17
1418   /* memory pointers */
1519   UINT8 *  videoram;
1620   size_t   videoram_size;
src/mame/drivers/lastfght.c
r7500r7501
6666#include "deprecat.h"
6767#include "cpu/h83002/h8.h"
6868
69typedef struct _lastfght_state lastfght_state;
70struct _lastfght_state
69class lastfght_state
7170{
71public:
72   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, lastfght_state(machine)); }
73
74   lastfght_state(running_machine &machine) { }
75
7276   /* memory pointers */
7377   UINT8 *  colorram;
7478//  UINT8 *  nvram; // currently this uses generic nvram handling
src/mame/drivers/markham.c
r7500r7501
11/*****************************************************************************
22
3Markham (c) 1983 Sun Electronics
3    Markham (c) 1983 Sun Electronics
44
55    Driver by Uki
66
r7500r7501
1111#include "emu.h"
1212#include "cpu/z80/z80.h"
1313#include "sound/sn76496.h"
14#include "includes/markham.h"
1415
15WRITE8_HANDLER( markham_videoram_w );
16WRITE8_HANDLER( markham_flipscreen_w );
1716
18PALETTE_INIT( markham );
19VIDEO_START( markham );
20VIDEO_UPDATE( markham );
21
22extern UINT8 *markham_xscroll;
23
24
2517static READ8_HANDLER( markham_e004_r )
2618{
2719   return 0;
r7500r7501
3325   AM_RANGE(0x0000, 0x5fff) AM_ROM
3426
3527   AM_RANGE(0xc000, 0xc7ff) AM_RAM
36   AM_RANGE(0xc800, 0xcfff) AM_RAM AM_BASE_SIZE_GENERIC(spriteram)
37   AM_RANGE(0xd000, 0xd7ff) AM_RAM_WRITE(markham_videoram_w) AM_BASE_GENERIC(videoram)
28   AM_RANGE(0xc800, 0xcfff) AM_RAM AM_BASE_SIZE_MEMBER(markham_state, spriteram, spriteram_size)
29   AM_RANGE(0xd000, 0xd7ff) AM_RAM_WRITE(markham_videoram_w) AM_BASE_MEMBER(markham_state, videoram)
3830   AM_RANGE(0xd800, 0xdfff) AM_RAM AM_SHARE("share1")
3931
4032   AM_RANGE(0xe000, 0xe000) AM_READ_PORT("DSW2")
r7500r7501
4941   AM_RANGE(0xe008, 0xe008) AM_WRITENOP /* coin counter? */
5042   AM_RANGE(0xe009, 0xe009) AM_WRITENOP /* to CPU2 busreq */
5143
52   AM_RANGE(0xe00c, 0xe00d) AM_WRITEONLY AM_BASE(&markham_xscroll)
44   AM_RANGE(0xe00c, 0xe00d) AM_WRITEONLY AM_BASE_MEMBER(markham_state, xscroll)
5345   AM_RANGE(0xe00e, 0xe00e) AM_WRITE(markham_flipscreen_w)
5446ADDRESS_MAP_END
5547
r7500r7501
182174
183175static MACHINE_DRIVER_START( markham )
184176
177   /* driver data */
178   MDRV_DRIVER_DATA(markham_state)
179
185180   /* basic machine hardware */
186181   MDRV_CPU_ADD("maincpu", Z80,8000000/2) /* 4.000MHz */
187182   MDRV_CPU_PROGRAM_MAP(markham_master_map)
r7500r7501
249244ROM_END
250245
251246
252GAME( 1983, markham, 0, markham, markham, 0, ROT0, "Sun Electronics", "Markham", 0 )
247GAME( 1983, markham, 0, markham, markham, 0, ROT0, "Sun Electronics", "Markham", GAME_SUPPORTS_SAVE )
src/mame/drivers/lockon.c
r7500r7501
1616#include "sound/flt_vol.h"
1717#include "includes/lockon.h"
1818
19#define V30_GND_ADDR   ((lockon_ctrl_reg & 0x3) << 16)
20#define V30_OBJ_ADDR   ((lockon_ctrl_reg & 0x18) << 13)
19#define V30_GND_ADDR   ((state->ctrl_reg & 0x3) << 16)
20#define V30_OBJ_ADDR   ((state->ctrl_reg & 0x18) << 13)
2121
2222
2323/*************************************
r7500r7501
3232
3333/*************************************
3434 *
35 *  Globals
36 *
37 *************************************/
38
39UINT32   lockon_main_inten;
40UINT8   lockon_ctrl_reg;
41
42
43/*************************************
44 *
4535 *  Machine functions
4636 *
4737 *************************************/
r7500r7501
6353
6454static WRITE16_HANDLER( adrst_w )
6555{
66   lockon_ctrl_reg = data & 0xff;
56   lockon_state *state = (lockon_state *)space->machine->driver_data;
57   state->ctrl_reg = data & 0xff;
6758
6859   /* Bus mastering for shared access */
69   cputag_set_input_line(space->machine, "ground", INPUT_LINE_HALT, data & 0x04 ? ASSERT_LINE : CLEAR_LINE);
70   cputag_set_input_line(space->machine, "object", INPUT_LINE_HALT, data & 0x20 ? ASSERT_LINE : CLEAR_LINE);
71   cputag_set_input_line(space->machine, "audiocpu", INPUT_LINE_HALT, data & 0x40 ? CLEAR_LINE : ASSERT_LINE);
60   cpu_set_input_line(state->ground, INPUT_LINE_HALT, data & 0x04 ? ASSERT_LINE : CLEAR_LINE);
61   cpu_set_input_line(state->object, INPUT_LINE_HALT, data & 0x20 ? ASSERT_LINE : CLEAR_LINE);
62   cpu_set_input_line(state->audiocpu, INPUT_LINE_HALT, data & 0x40 ? CLEAR_LINE : ASSERT_LINE);
7263}
7364
7465static READ16_HANDLER( main_gnd_r )
7566{
76   const address_space *gndspace = cputag_get_address_space(space->machine, "ground", ADDRESS_SPACE_PROGRAM);
67   lockon_state *state = (lockon_state *)space->machine->driver_data;
68   const address_space *gndspace = cpu_get_address_space(state->ground, ADDRESS_SPACE_PROGRAM);
7769   return memory_read_word(gndspace, V30_GND_ADDR | offset * 2);
7870}
7971
8072static WRITE16_HANDLER( main_gnd_w )
8173{
82   const address_space *gndspace = cputag_get_address_space(space->machine, "ground", ADDRESS_SPACE_PROGRAM);
74   lockon_state *state = (lockon_state *)space->machine->driver_data;
75   const address_space *gndspace = cpu_get_address_space(state->ground, ADDRESS_SPACE_PROGRAM);
8376
8477   if (ACCESSING_BITS_0_7)
8578      memory_write_byte(gndspace, V30_GND_ADDR | (offset * 2 + 0), data);
r7500r7501
8982
9083static READ16_HANDLER( main_obj_r )
9184{
92   const address_space *objspace = cputag_get_address_space(space->machine, "object", ADDRESS_SPACE_PROGRAM);
85   lockon_state *state = (lockon_state *)space->machine->driver_data;
86   const address_space *objspace = cpu_get_address_space(state->object, ADDRESS_SPACE_PROGRAM);
9387   return memory_read_word(objspace, V30_OBJ_ADDR | offset * 2);
9488}
9589
9690static WRITE16_HANDLER( main_obj_w )
9791{
98   const address_space *objspace = cputag_get_address_space(space->machine, "object", ADDRESS_SPACE_PROGRAM);
92   lockon_state *state = (lockon_state *)space->machine->driver_data;
93   const address_space *objspace = cpu_get_address_space(state->object, ADDRESS_SPACE_PROGRAM);
9994
10095   if (ACCESSING_BITS_0_7)
10196      memory_write_byte(objspace, V30_OBJ_ADDR | (offset * 2 + 0), data);
r7500r7501
105100
106101static WRITE16_HANDLER( tst_w )
107102{
103   lockon_state *state = (lockon_state *)space->machine->driver_data;
104
108105   if (offset < 0x800)
109106   {
110      const address_space *gndspace = cputag_get_address_space(space->machine, "ground", ADDRESS_SPACE_PROGRAM);
111      const address_space *objspace = cputag_get_address_space(space->machine, "object", ADDRESS_SPACE_PROGRAM);
107      const address_space *gndspace = cpu_get_address_space(state->ground, ADDRESS_SPACE_PROGRAM);
108      const address_space *objspace = cpu_get_address_space(state->object, ADDRESS_SPACE_PROGRAM);
112109
113110      if (ACCESSING_BITS_0_7)
114111         memory_write_byte(gndspace, V30_GND_ADDR | (offset * 2 + 0), data);
r7500r7501
124121
125122static READ16_HANDLER( main_z80_r )
126123{
127   const address_space *sndspace = cputag_get_address_space(space->machine, "audiocpu", ADDRESS_SPACE_PROGRAM);
124   lockon_state *state = (lockon_state *)space->machine->driver_data;
125   const address_space *sndspace = cpu_get_address_space(state->audiocpu, ADDRESS_SPACE_PROGRAM);
128126   return 0xff00 | memory_read_byte(sndspace, offset);
129127}
130128
131129static WRITE16_HANDLER( main_z80_w )
132130{
133   const address_space *sndspace = cputag_get_address_space(space->machine, "audiocpu", ADDRESS_SPACE_PROGRAM);
131   lockon_state *state = (lockon_state *)space->machine->driver_data;
132   const address_space *sndspace = cpu_get_address_space(state->audiocpu, ADDRESS_SPACE_PROGRAM);
134133   memory_write_byte(sndspace, offset, data);
135134}
136135
137136static WRITE16_HANDLER( inten_w )
138137{
139   lockon_main_inten = 1;
138   lockon_state *state = (lockon_state *)space->machine->driver_data;
139   state->main_inten = 1;
140140}
141141
142142static WRITE16_HANDLER( emres_w )
143143{
144   lockon_state *state = (lockon_state *)space->machine->driver_data;
144145   watchdog_reset(space->machine);
145   lockon_main_inten = 0;
146   state->main_inten = 0;
146147}
147148
148149
r7500r7501
157158   AM_RANGE(0x00000, 0x03fff) AM_RAM
158159   AM_RANGE(0x04000, 0x04003) AM_READWRITE(lockon_crtc_r, lockon_crtc_w)
159160   AM_RANGE(0x06000, 0x06001) AM_READ_PORT("DSW")
160   AM_RANGE(0x08000, 0x081ff) AM_RAM AM_BASE(&lockon_hud_ram) AM_SIZE(&lockon_hudram_size)
161   AM_RANGE(0x09000, 0x09fff) AM_RAM_WRITE(lockon_char_w) AM_BASE(&lockon_char_ram)
161   AM_RANGE(0x08000, 0x081ff) AM_RAM AM_BASE_SIZE_MEMBER(lockon_state, hud_ram, hudram_size)
162   AM_RANGE(0x09000, 0x09fff) AM_RAM_WRITE(lockon_char_w) AM_BASE_MEMBER(lockon_state, char_ram)
162163   AM_RANGE(0x0a000, 0x0a001) AM_WRITE(adrst_w)
163164   AM_RANGE(0x0b000, 0x0bfff) AM_WRITE(lockon_rotate_w)
164165   AM_RANGE(0x0c000, 0x0cfff) AM_WRITE(lockon_fb_clut_w)
r7500r7501
177178static ADDRESS_MAP_START( ground_v30, ADDRESS_SPACE_PROGRAM, 16 )
178179   ADDRESS_MAP_UNMAP_HIGH
179180   AM_RANGE(0x00000, 0x03fff) AM_RAM
180   AM_RANGE(0x04000, 0x04fff) AM_RAM AM_BASE(&lockon_scene_ram)
181   AM_RANGE(0x08000, 0x08fff) AM_RAM AM_BASE(&lockon_ground_ram) AM_SIZE(&lockon_groundram_size)
181   AM_RANGE(0x04000, 0x04fff) AM_RAM AM_BASE_MEMBER(lockon_state, scene_ram)
182   AM_RANGE(0x08000, 0x08fff) AM_RAM AM_BASE_SIZE_MEMBER(lockon_state, ground_ram, groundram_size)
182183   AM_RANGE(0x0C000, 0x0C001) AM_WRITE(lockon_scene_h_scr_w)
183184   AM_RANGE(0x0C002, 0x0C003) AM_WRITE(lockon_scene_v_scr_w)
184185   AM_RANGE(0x0C004, 0x0C005) AM_WRITE(lockon_ground_ctrl_w)
r7500r7501
192193   AM_RANGE(0x00000, 0x03fff) AM_RAM
193194   AM_RANGE(0x04000, 0x04001) AM_READWRITE(lockon_obj_4000_r, lockon_obj_4000_w)
194195   AM_RANGE(0x08000, 0x08fff) AM_WRITE(lockon_tza112_w)
195   AM_RANGE(0x0c000, 0x0c1ff) AM_RAM AM_BASE(&lockon_object_ram) AM_SIZE(&lockon_objectram_size)
196   AM_RANGE(0x0c000, 0x0c1ff) AM_RAM AM_BASE_SIZE_MEMBER(lockon_state, object_ram, objectram_size)
196197   AM_RANGE(0x30000, 0x3ffff) AM_MIRROR(0xc0000) AM_ROM
197198ADDRESS_MAP_END
198199
r7500r7501
391392#define LO_RI      100000.0
392393#define LO_RP      100000.0
393394
395   lockon_state *state = (lockon_state *)space->machine->driver_data;
396
394397   static const double gains[16] =
395398   {
396399      -( 1 / (1/LO_RP + 1/(LO_R3   + LO_R2   + LO_R1   + LO_R0))  ) / LO_RI,
r7500r7501
414417   double lgain = gains[data & 0xf];
415418   double rgain = gains[data >> 4];
416419
417   flt_volume_set_volume(devtag_get_device(space->machine, "f2203.1l"), lgain);
418   flt_volume_set_volume(devtag_get_device(space->machine, "f2203.2l"), lgain);
419   flt_volume_set_volume(devtag_get_device(space->machine, "f2203.3l"), lgain);
420   flt_volume_set_volume(state->f2203_1l, lgain);
421   flt_volume_set_volume(state->f2203_2l, lgain);
422   flt_volume_set_volume(state->f2203_3l, lgain);
420423
421   flt_volume_set_volume(devtag_get_device(space->machine, "f2203.1r"), rgain);
422   flt_volume_set_volume(devtag_get_device(space->machine, "f2203.2r"), rgain);
423   flt_volume_set_volume(devtag_get_device(space->machine, "f2203.3r"), rgain);
424   flt_volume_set_volume(state->f2203_1r, rgain);
425   flt_volume_set_volume(state->f2203_2r, rgain);
426   flt_volume_set_volume(state->f2203_3r, rgain);
424427}
425428
426429static void ym2203_irq(running_device *device, int irq)
427430{
428   cputag_set_input_line(device->machine, "audiocpu", 0, irq ? ASSERT_LINE : CLEAR_LINE );
431   lockon_state *state = (lockon_state *)device->machine->driver_data;
432   cpu_set_input_line(state->audiocpu, 0, irq ? ASSERT_LINE : CLEAR_LINE );
429433}
430434
431435static WRITE8_DEVICE_HANDLER( ym2203_out_b )
r7500r7501
458462 *
459463 *************************************/
460464
465static MACHINE_START( lockon )
466{
467   lockon_state *state = (lockon_state *)machine->driver_data;
468
469   state->maincpu = devtag_get_device(machine, "maincpu");
470   state->audiocpu = devtag_get_device(machine, "audiocpu");
471   state->ground = devtag_get_device(machine, "ground");
472   state->object = devtag_get_device(machine, "object");
473   state->f2203_1l = devtag_get_device(machine, "f2203.1l");
474   state->f2203_2l = devtag_get_device(machine, "f2203.2l");
475   state->f2203_3l = devtag_get_device(machine, "f2203.3l");
476   state->f2203_1r = devtag_get_device(machine, "f2203.1r");
477   state->f2203_2r = devtag_get_device(machine, "f2203.2r");
478   state->f2203_3r = devtag_get_device(machine, "f2203.3r");
479
480   state_save_register_global(machine, state->ground_ctrl);
481   state_save_register_global(machine, state->scroll_h);
482   state_save_register_global(machine, state->scroll_v);
483   state_save_register_global(machine, state->xsal);
484   state_save_register_global(machine, state->x0ll);
485   state_save_register_global(machine, state->dx0ll);
486   state_save_register_global(machine, state->dxll);
487   state_save_register_global(machine, state->ysal);
488   state_save_register_global(machine, state->y0ll);
489   state_save_register_global(machine, state->dy0ll);
490   state_save_register_global(machine, state->dyll);
491   state_save_register_global(machine, state->iden);
492   state_save_register_global(machine, state->obj_pal_latch);
493   state_save_register_global(machine, state->obj_pal_addr);
494   state_save_register_global(machine, state->ctrl_reg);
495   state_save_register_global(machine, state->main_inten);
496}
497
498static MACHINE_RESET( lockon )
499{
500   lockon_state *state = (lockon_state *)machine->driver_data;
501
502   state->ground_ctrl = 0;
503   state->scroll_h = 0;
504   state->scroll_v = 0;
505   state->xsal = 0;
506   state->x0ll = 0;
507   state->dx0ll = 0;
508   state->dxll = 0;
509   state->ysal = 0;
510   state->y0ll = 0;
511   state->dy0ll = 0;
512   state->dyll = 0;
513   state->iden = 0;
514   state->obj_pal_latch = 0;
515   state->obj_pal_addr = 0;
516   state->ctrl_reg = 0;
517   state->main_inten = 0;
518}
519
461520static MACHINE_DRIVER_START( lockon )
521
522   /* driver data */
523   MDRV_DRIVER_DATA(lockon_state)
524
462525   MDRV_CPU_ADD("maincpu", V30, XTAL_16MHz / 2)
463526   MDRV_CPU_PROGRAM_MAP(main_v30)
464527
r7500r7501
475538   MDRV_WATCHDOG_TIME_INIT(NSEC(PERIOD_OF_555_ASTABLE_NSEC(10000, 4700, 10000e-12) * 4096))
476539   MDRV_QUANTUM_TIME(HZ(600))
477540
541   MDRV_MACHINE_START(lockon)
542   MDRV_MACHINE_RESET(lockon)
543
478544   MDRV_VIDEO_ATTRIBUTES(VIDEO_UPDATE_AFTER_VBLANK)
479545
480546   MDRV_SCREEN_ADD("screen", RASTER)
r7500r7501
754820 *
755821 *************************************/
756822
757GAME( 1986, lockon,  0,      lockon,  lockon,  0, ROT0, "Tatsumi", "Lock-On (rev. E)", 0 )
758GAME( 1986, lockonc, lockon, lockon,  lockone, 0, ROT0, "Tatsumi", "Lock-On (rev. C)", 0 )
823GAME( 1986, lockon,  0,      lockon,  lockon,  0, ROT0, "Tatsumi", "Lock-On (rev. E)", GAME_SUPPORTS_SAVE )
824GAME( 1986, lockonc, lockon, lockon,  lockone, 0, ROT0, "Tatsumi", "Lock-On (rev. C)", GAME_SUPPORTS_SAVE )
src/mame/drivers/spaceg.c
r7500r7501
173173 *
174174 *************************************/
175175
176typedef struct _spaceg_state spaceg_state;
177struct _spaceg_state
176class spaceg_state
178177{
178public:
179   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, spaceg_state(machine)); }
180
181   spaceg_state(running_machine &machine) { }
182
179183   UINT8 *  videoram;
180184   UINT8 *  unkram;
181185   UINT8 *  io9400;
src/mame/drivers/segas32.c
r7500r7501
18771877   PORT_INCLUDE( multi32_generic )
18781878
18791879   PORT_MODIFY("P1_A")
1880   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(1) PORT_CODE(KEYCODE_SPACE)   /*  */
1881   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(1) PORT_CODE(KEYCODE_LSHIFT)   /*  */
1882   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_PLAYER(1) PORT_CODE(KEYCODE_LALT)      /* brake */
1880   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(1) PORT_CODE(KEYCODE_SPACE)      /* P1 Attack */
1881   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_BUTTON2 ) PORT_PLAYER(1) PORT_CODE(KEYCODE_LSHIFT)      /* P1 Wheelie */
1882   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_PLAYER(1) PORT_CODE(KEYCODE_LALT)      /* P1 Brake */
18831883   PORT_BIT( 0xf8, IP_ACTIVE_LOW, IPT_UNKNOWN )
18841884
18851885   PORT_MODIFY("P1_B")
1886   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(2) PORT_CODE(KEYCODE_Q)      /*  */
1887   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(2) PORT_CODE(KEYCODE_W)      /*  */
1888   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_PLAYER(2) PORT_CODE(KEYCODE_S)      /* brake */
1886   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(2) PORT_CODE(KEYCODE_Q)      /* P2 Attack */
1887   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_BUTTON2 ) PORT_PLAYER(2) PORT_CODE(KEYCODE_W)      /* P2 Wheelie */
1888   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_PLAYER(2) PORT_CODE(KEYCODE_S)      /* P2 Brake */
18891889   PORT_BIT( 0xf8, IP_ACTIVE_LOW, IPT_UNKNOWN )
18901890
18911891   PORT_MODIFY("P2_A")
r7500r7501
18941894   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNUSED )
18951895
18961896   PORT_START("ANALOG1")
1897   PORT_BIT( 0xff, 0x80, IPT_PADDLE ) PORT_SENSITIVITY(30) PORT_KEYDELTA(10) PORT_PLAYER(1)
1897   PORT_BIT( 0xff, 0x80, IPT_PADDLE ) PORT_SENSITIVITY(30) PORT_KEYDELTA(10) PORT_REVERSE PORT_PLAYER(1)
18981898
18991899   PORT_START("ANALOG2")
19001900   PORT_BIT( 0xff, 0x00, IPT_PEDAL ) PORT_SENSITIVITY(30) PORT_KEYDELTA(10) PORT_PLAYER(1)
19011901
19021902   PORT_START("ANALOG3")
1903   PORT_BIT( 0xff, 0x80, IPT_PADDLE ) PORT_SENSITIVITY(30) PORT_KEYDELTA(10) PORT_PLAYER(2)
1903   PORT_BIT( 0xff, 0x80, IPT_PADDLE ) PORT_SENSITIVITY(30) PORT_KEYDELTA(10) PORT_REVERSE PORT_PLAYER(2)
19041904
19051905   PORT_START("ANALOG4")
19061906   PORT_BIT( 0xff, 0x00, IPT_PEDAL ) PORT_SENSITIVITY(30) PORT_KEYDELTA(10) PORT_PLAYER(2)
src/mame/drivers/looping.c
r7500r7501
9595 *
9696 *************************************/
9797
98typedef struct _looping_state looping_state;
99struct _looping_state
98class looping_state
10099{
100public:
101   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, looping_state(machine)); }
102
103   looping_state(running_machine &machine) { }
104
101105   /* memory pointers */
102106   UINT8 *      videoram;
103107   UINT8 *      colorram;
src/mame/drivers/1945kiii.c
r7500r7501
4747#define MASTER_CLOCK   XTAL_16MHz
4848
4949
50typedef struct _k3_state k3_state;
51struct _k3_state
50class k3_state
5251{
52public:
53   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, k3_state(machine)); }
54
55   k3_state(running_machine &machine) { }
56
5357   /* memory pointers */
5458   UINT16 *  spriteram_1;
5559   UINT16 *  spriteram_2;
src/mame/drivers/astinvad.c
r7500r7501
4141};
4242
4343
44typedef struct _astinvad_state astinvad_state;
45struct _astinvad_state
44class astinvad_state
4645{
46public:
47   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, astinvad_state(machine)); }
48
49   astinvad_state(running_machine &machine) { }
50
4751   UINT8 *    colorram;
4852   UINT8 *    videoram;
4953   size_t     videoram_size;
src/mame/drivers/supertnk.c
r7500r7501
105105   every 8 bytes */
106106#define NUM_PENS   (8)
107107
108typedef struct _supertnk_state supertnk_state;
109struct _supertnk_state
108class supertnk_state
110109{
110public:
111   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, supertnk_state(machine)); }
112
113   supertnk_state(running_machine &machine) { }
114
111115   UINT8 *videoram[3];
112116   UINT8 rom_bank;
113117   UINT8 bitplane_select;
src/mame/drivers/boogwing.c
r7500r7501
8181#include "emu.h"
8282#include "cpu/m68000/m68000.h"
8383#include "cpu/h6280/h6280.h"
84#include "includes/boogwing.h"
8485#include "includes/decocrpt.h"
85#include "includes/deco16ic.h"
8686#include "includes/decoprot.h"
8787#include "sound/2151intf.h"
8888#include "sound/okim6295.h"
89#include "video/deco16ic.h"
8990
90VIDEO_START(boogwing);
91VIDEO_UPDATE(boogwing);
9291
93/**********************************************************************************/
94
9592static ADDRESS_MAP_START( boogwing_map, ADDRESS_SPACE_PROGRAM, 16 )
9693   AM_RANGE(0x000000, 0x0fffff) AM_ROM
9794   AM_RANGE(0x200000, 0x20ffff) AM_RAM
9895
99   AM_RANGE(0x220000, 0x220001) AM_WRITE(deco16_priority_w)
96   AM_RANGE(0x220000, 0x220001) AM_DEVWRITE("deco_custom", deco16ic_priority_w)
10097   AM_RANGE(0x220002, 0x22000f) AM_NOP
10198
10299   AM_RANGE(0x240000, 0x240001) AM_WRITE(buffer_spriteram16_w)
r7500r7501
109106   AM_RANGE(0x24e344, 0x24e345) AM_READ_PORT("INPUTS")
110107   AM_RANGE(0x24e000, 0x24e7ff) AM_WRITE(deco16_104_prot_w) AM_BASE(&deco16_prot_ram)
111108
112   AM_RANGE(0x260000, 0x26000f) AM_WRITEONLY AM_BASE(&deco16_pf12_control)
113   AM_RANGE(0x264000, 0x265fff) AM_RAM_WRITE(deco16_pf1_data_w) AM_BASE(&deco16_pf1_data)
114   AM_RANGE(0x266000, 0x267fff) AM_RAM_WRITE(deco16_pf2_data_w) AM_BASE(&deco16_pf2_data)
115   AM_RANGE(0x268000, 0x268fff) AM_RAM AM_BASE(&deco16_pf1_rowscroll)
116   AM_RANGE(0x26a000, 0x26afff) AM_RAM AM_BASE(&deco16_pf2_rowscroll)
109   AM_RANGE(0x260000, 0x26000f) AM_DEVWRITE("deco_custom", deco16ic_pf12_control_w)
110   AM_RANGE(0x264000, 0x265fff) AM_DEVREADWRITE("deco_custom", deco16ic_pf1_data_r, deco16ic_pf1_data_w)
111   AM_RANGE(0x266000, 0x267fff) AM_DEVREADWRITE("deco_custom", deco16ic_pf2_data_r, deco16ic_pf2_data_w)
112   AM_RANGE(0x268000, 0x268fff) AM_RAM AM_BASE_MEMBER(boogwing_state, pf1_rowscroll)
113   AM_RANGE(0x26a000, 0x26afff) AM_RAM AM_BASE_MEMBER(boogwing_state, pf2_rowscroll)
117114
118   AM_RANGE(0x270000, 0x27000f) AM_WRITEONLY AM_BASE(&deco16_pf34_control)
119   AM_RANGE(0x274000, 0x275fff) AM_RAM_WRITE(deco16_pf3_data_w) AM_BASE(&deco16_pf3_data)
120   AM_RANGE(0x276000, 0x277fff) AM_RAM_WRITE(deco16_pf4_data_w) AM_BASE(&deco16_pf4_data)
121   AM_RANGE(0x278000, 0x278fff) AM_RAM AM_BASE(&deco16_pf3_rowscroll)
122   AM_RANGE(0x27a000, 0x27afff) AM_RAM AM_BASE(&deco16_pf4_rowscroll)
115   AM_RANGE(0x270000, 0x27000f) AM_DEVWRITE("deco_custom", deco16ic_pf34_control_w)
116   AM_RANGE(0x274000, 0x275fff) AM_RAM_DEVWRITE("deco_custom", deco16ic_pf3_data_w)
117   AM_RANGE(0x276000, 0x277fff) AM_RAM_DEVWRITE("deco_custom", deco16ic_pf4_data_w)
118   AM_RANGE(0x278000, 0x278fff) AM_RAM AM_BASE_MEMBER(boogwing_state, pf3_rowscroll)
119   AM_RANGE(0x27a000, 0x27afff) AM_RAM AM_BASE_MEMBER(boogwing_state, pf4_rowscroll)
123120
124121   AM_RANGE(0x280000, 0x28000f) AM_NOP // ?
125122   AM_RANGE(0x282000, 0x282001) AM_NOP // Palette setup?
126   AM_RANGE(0x282008, 0x282009) AM_WRITE(deco16_palette_dma_w)
127   AM_RANGE(0x284000, 0x285fff) AM_WRITE(deco16_buffered_palette_w) AM_BASE_GENERIC(paletteram)
123   AM_RANGE(0x282008, 0x282009) AM_DEVWRITE("deco_custom", deco16ic_palette_dma_w)
124   AM_RANGE(0x284000, 0x285fff) AM_DEVWRITE("deco_custom", deco16ic_buffered_palette_w) AM_BASE_GENERIC(paletteram)
128125
129126   AM_RANGE(0x3c0000, 0x3c004f) AM_RAM // ?
130127ADDRESS_MAP_END
r7500r7501
146143/**********************************************************************************/
147144
148145static INPUT_PORTS_START( boogwing )
149   PORT_START("SYSTEM")   /* 16bit */
146   PORT_START("SYSTEM")
150147   PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_COIN1 )
151148   PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_COIN2 )
152149   PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_SERVICE1 )
153150   PORT_BIT( 0x0008, IP_ACTIVE_HIGH, IPT_VBLANK )
154151
155   PORT_START("DSW")   /* 16bit */
152   PORT_START("DSW")
156153   PORT_DIPNAME( 0x0007, 0x0007, DEF_STR( Coin_A ) ) PORT_DIPLOCATION("SW1:1,2,3")
157154   PORT_DIPSETTING(      0x0000, DEF_STR( 3C_1C ) )
158155   PORT_DIPSETTING(      0x0001, DEF_STR( 2C_1C ) )
r7500r7501
200197   PORT_DIPSETTING(      0x8000, DEF_STR( Off ) )
201198   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
202199
203   PORT_START("INPUTS")   /* 16bit */
200   PORT_START("INPUTS")
204201   PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_8WAY PORT_PLAYER(1)
205202   PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_8WAY PORT_PLAYER(1)
206203   PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_8WAY PORT_PLAYER(1)
r7500r7501
279276
280277static void sound_irq(running_device *device, int state)
281278{
282   cputag_set_input_line(device->machine, "audiocpu", 1, state); /* IRQ 2 */
279   boogwing_state *driver_state = (boogwing_state *)device->machine->driver_data;
280   cpu_set_input_line(driver_state->audiocpu, 1, state); /* IRQ 2 */
283281}
284282
285283static WRITE8_DEVICE_HANDLER( sound_bankswitch_w )
286284{
287   okim6295_set_bank_base(devtag_get_device(device->machine, "oki2"), ((data & 2)>>1) * 0x40000);
288   okim6295_set_bank_base(devtag_get_device(device->machine, "oki1"), (data & 1) * 0x40000);
285   boogwing_state *state = (boogwing_state *)device->machine->driver_data;
286   okim6295_set_bank_base(state->oki2, ((data & 2) >> 1) * 0x40000);
287   okim6295_set_bank_base(state->oki1, (data & 1) * 0x40000);
289288}
290289
291290static const ym2151_interface ym2151_config =
r7500r7501
295294};
296295
297296
297static int boogwing_bank_callback( const int bank )
298{
299   return ((bank >> 4) & 0x7) * 0x1000;
300}
301
302static int boogwing_bank_callback2( const int bank )
303{
304   int offset = ((bank >> 4) & 0x7) * 0x1000;
305   if ((bank & 0xf) == 0xa)
306      offset += 0x800; // strange - transporter level
307
308   return offset;
309}
310
311static const deco16ic_interface boogwing_deco16ic_intf =
312{
313   "screen",
314   0, 0, 1,
315   0x0f, 0x1f, 0x0f, 0x0f, /* trans masks (pf2 has 5bpp graphics) */
316   0, 0, 0, 16, /* color base (pf2 is non default) */
317   0x0f, 0x0f, 0x0f, 0x0f,   /* color masks (default values) */
318   NULL,
319   boogwing_bank_callback,
320   boogwing_bank_callback2,
321   boogwing_bank_callback2
322};
323
324
325static MACHINE_START( boogwing )
326{
327   boogwing_state *state = (boogwing_state *)machine->driver_data;
328
329   state->maincpu = devtag_get_device(machine, "maincpu");
330   state->audiocpu = devtag_get_device(machine, "audiocpu");
331   state->deco16ic = devtag_get_device(machine, "deco_custom");
332   state->oki1 = devtag_get_device(machine, "oki1");
333   state->oki2 = devtag_get_device(machine, "oki2");
334}
335
298336static MACHINE_DRIVER_START( boogwing )
337
338   /* driver data */
339   MDRV_DRIVER_DATA(boogwing_state)
340
299341   /* basic machine hardware */
300342   MDRV_CPU_ADD("maincpu", M68000, 14000000)   /* DE102 */
301343   MDRV_CPU_PROGRAM_MAP(boogwing_map)
r7500r7501
304346   MDRV_CPU_ADD("audiocpu", H6280,32220000/4)
305347   MDRV_CPU_PROGRAM_MAP(audio_map)
306348
349   MDRV_MACHINE_START(boogwing)
350
307351   /* video hardware */
308352   MDRV_VIDEO_ATTRIBUTES(VIDEO_BUFFERS_SPRITERAM )
309353
r7500r7501
317361   MDRV_PALETTE_LENGTH(2048)
318362   MDRV_GFXDECODE(boogwing)
319363
320   MDRV_VIDEO_START(boogwing)
321364   MDRV_VIDEO_UPDATE(boogwing)
322365
366   MDRV_DECO16IC_ADD("deco_custom", boogwing_deco16ic_intf)
367
323368   /* sound hardware */
324369   MDRV_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker")
325370
r7500r7501
519564
520565static DRIVER_INIT( boogwing )
521566{
522   const UINT8* src=memory_region(machine, "gfx6");
523   UINT8* dst=memory_region(machine, "tiles2") + 0x200000;
567   const UINT8* src = memory_region(machine, "gfx6");
568   UINT8* dst = memory_region(machine, "tiles2") + 0x200000;
524569
525570   deco56_decrypt_gfx(machine, "tiles1");
526571   deco56_decrypt_gfx(machine, "tiles2");
r7500r7501
530575   memcpy(dst, src, 0x100000);
531576}
532577
533GAME( 1992, boogwing, 0,        boogwing, boogwing,  boogwing,  ROT0, "Data East Corporation", "Boogie Wings (Euro v1.5, 92.12.07)", 0 )
534GAME( 1992, boogwinga,boogwing, boogwing, boogwing,  boogwing,  ROT0, "Data East Corporation", "Boogie Wings (Asia v1.5, 92.12.07)", 0 )
535GAME( 1992, ragtime,  boogwing, boogwing, boogwing,  boogwing,  ROT0, "Data East Corporation", "The Great Ragtime Show (Japan v1.5, 92.12.07)", 0 )
536GAME( 1992, ragtimea, boogwing, boogwing, boogwing,  boogwing,  ROT0, "Data East Corporation", "The Great Ragtime Show (Japan v1.3, 92.11.26)", 0 )
578GAME( 1992, boogwing, 0,        boogwing, boogwing,  boogwing,  ROT0, "Data East Corporation", "Boogie Wings (Euro v1.5, 92.12.07)", GAME_SUPPORTS_SAVE )
579GAME( 1992, boogwinga,boogwing, boogwing, boogwing,  boogwing,  ROT0, "Data East Corporation", "Boogie Wings (Asia v1.5, 92.12.07)", GAME_SUPPORTS_SAVE )
580GAME( 1992, ragtime,  boogwing, boogwing, boogwing,  boogwing,  ROT0, "Data East Corporation", "The Great Ragtime Show (Japan v1.5, 92.12.07)", GAME_SUPPORTS_SAVE )
581GAME( 1992, ragtimea, boogwing, boogwing, boogwing,  boogwing,  ROT0, "Data East Corporation", "The Great Ragtime Show (Japan v1.3, 92.11.26)", GAME_SUPPORTS_SAVE )
src/mame/drivers/neodrvr.c
r7500r7501
79017901GAME( 1996, aof3k,     aof3,     neogeo,   neogeo,   neogeo,   ROT0, "SNK", "Art of Fighting 3 - The Path of the Warrior (Korean release)", GAME_SUPPORTS_SAVE ) // no Japanese title / mode
79027902GAME( 1996, kof96,     neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "SNK", "The King of Fighters '96 (set 1)", GAME_SUPPORTS_SAVE )
79037903GAME( 1996, kof96h,    kof96,    neogeo,   neogeo,   neogeo,   ROT0, "SNK", "The King of Fighters '96 (set 2)", GAME_SUPPORTS_SAVE )
7904GAME( 1996, ssideki4,  neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "SNK", "Ultimate 11 - The SNK Football Championship / Tokuten Ou - Honoo no Libero, The", GAME_SUPPORTS_SAVE )
7904GAME( 1996, ssideki4,  neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "SNK", "The Ultimate 11 - The SNK Football Championship / Tokuten Ou - Honoo no Libero", GAME_SUPPORTS_SAVE )
79057905GAME( 1996, kizuna,    neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "SNK", "Kizuna Encounter - Super Tag Battle / Fu'un Super Tag Battle", GAME_SUPPORTS_SAVE )
79067906GAME( 1996, samsho4,   neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "SNK", "Samurai Shodown IV - Amakusa's Revenge / Samurai Spirits - Amakusa Kourin", GAME_SUPPORTS_SAVE )
79077907GAME( 1996, samsho4k,  samsho4,  neogeo,   neogeo,   neogeo,   ROT0, "SNK", "Pae Wang Jeon Seol / Legend of a Warrior (Korean censored Samurai Shodown IV)", GAME_SUPPORTS_SAVE )
r7500r7501
79107910GAME( 1997, kof97h,    kof97,    neogeo,   neogeo,   neogeo,   ROT0, "SNK", "The King of Fighters '97 (set 2)", GAME_SUPPORTS_SAVE )
79117911GAME( 1997, kof97pls,  kof97,    neogeo,   neogeo,   neogeo,   ROT0, "bootleg", "The King of Fighters '97 Plus (bootleg)", GAME_SUPPORTS_SAVE )
79127912GAME( 1997, kog,       kof97,    neogeo,   kog,      kog,      ROT0, "bootleg", "King of Gladiator (The King of Fighters '97 bootleg)", GAME_NOT_WORKING | GAME_SUPPORTS_SAVE ) // protected bootleg
7913GAME( 1997, lastblad,  neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "SNK", "Last Blade / Bakumatsu Roman - Gekka no Kenshi, The (set 1)", GAME_SUPPORTS_SAVE )
7914GAME( 1997, lastbladh, lastblad, neogeo,   neogeo,   neogeo,   ROT0, "SNK", "Last Blade / Bakumatsu Roman - Gekka no Kenshi, The (set 2)", GAME_SUPPORTS_SAVE )
7913GAME( 1997, lastblad,  neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "SNK", "The Last Blade / Bakumatsu Roman - Gekka no Kenshi (set 1)", GAME_SUPPORTS_SAVE )
7914GAME( 1997, lastbladh, lastblad, neogeo,   neogeo,   neogeo,   ROT0, "SNK", "The Last Blade / Bakumatsu Roman - Gekka no Kenshi (set 2)", GAME_SUPPORTS_SAVE )
79157915GAME( 1997, lastsold,  lastblad, neogeo,   neogeo,   neogeo,   ROT0, "SNK", "The Last Soldier (Korean release of The Last Blade)", GAME_SUPPORTS_SAVE )
79167916GAME( 1997, irrmaze,   neogeo,   neogeo,   irrmaze,  neogeo,   ROT0, "SNK / Saurus", "The Irritating Maze / Ultra Denryu Iraira Bou", GAME_SUPPORTS_SAVE )
79177917GAME( 1998, rbff2,     neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "SNK", "Real Bout Fatal Fury 2 - The Newcomers / Real Bout Garou Densetsu 2 - the newcomers (set 1)", GAME_SUPPORTS_SAVE )
r7500r7501
79217921GAME( 1998, kof98,     neogeo,   neogeo,   neogeo,   kof98,    ROT0, "SNK", "The King of Fighters '98 - The Slugfest / King of Fighters '98 - dream match never ends", GAME_SUPPORTS_SAVE )
79227922GAME( 1998, kof98k,    kof98,    neogeo,   neogeo,   kof98,    ROT0, "SNK", "The King of Fighters '98 - The Slugfest / King of Fighters '98 - dream match never ends (Korean board)", GAME_SUPPORTS_SAVE )
79237923GAME( 1998, kof98n,    kof98,    neogeo,   neogeo,   neogeo,   ROT0, "SNK", "The King of Fighters '98 - The Slugfest / King of Fighters '98 - dream match never ends (not encrypted)", GAME_SUPPORTS_SAVE )
7924GAME( 1998, lastbld2,  neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "SNK", "Last Blade 2 / Bakumatsu Roman - Dai Ni Maku Gekka no Kenshi, The", GAME_SUPPORTS_SAVE )
7924GAME( 1998, lastbld2,  neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "SNK", "The Last Blade 2 / Bakumatsu Roman - Dai Ni Maku Gekka no Kenshi", GAME_SUPPORTS_SAVE )
79257925GAME( 1998, neocup98,  neogeo,   neogeo,   neogeo,   neogeo,   ROT0, "SNK", "Neo-Geo Cup '98 - The Road to the Victory", GAME_SUPPORTS_SAVE )
79267926GAME( 1999, mslugx,    neogeo,   neogeo,   neogeo,   mslugx,   ROT0, "SNK", "Metal Slug X - Super Vehicle-001", GAME_SUPPORTS_SAVE )
79277927GAME( 1999, kof99,     neogeo,   neogeo,   neogeo,   kof99,    ROT0, "SNK", "The King of Fighters '99 - Millennium Battle (set 1)" , GAME_SUPPORTS_SAVE ) /* Encrypted Code & GFX */
src/mame/drivers/srmp5.c
r7500r7501
6262
6363#define SPRITE_DATA_GRANULARITY 0x80
6464
65typedef struct _srmp5_state srmp5_state;
66struct _srmp5_state
65class srmp5_state
6766{
67public:
68   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, srmp5_state(machine)); }
69
70   srmp5_state(running_machine &machine) { }
71
6872   UINT32 databank;
6973   UINT16 *tileram;
7074   UINT16 *palram;
r7500r7501
336340      logerror("vidregs write %08X %08X\n", offset << 2, state->vidregs[offset]);
337341}
338342
343static READ32_HANDLER(irq_ack_clear)
344{
345   cputag_set_input_line(space->machine, "sub", R3000_IRQ4, CLEAR_LINE);
346   return 0;
347}
348
339349static ADDRESS_MAP_START( srmp5_mem, ADDRESS_SPACE_PROGRAM, 32 )
340350   AM_RANGE(0x00000000, 0x000fffff) AM_RAM //maybe 0 - 2fffff ?
341351   AM_RANGE(0x002f0000, 0x002f7fff) AM_RAM
r7500r7501
362372   AM_RANGE(0x0a200000, 0x0a3fffff) AM_READWRITE(tileram_r, tileram_w)
363373
364374   AM_RANGE(0x1eff0000, 0x1eff001f) AM_WRITEONLY
365   AM_RANGE(0x1eff003c, 0x1eff003f) AM_READNOP
375   AM_RANGE(0x1eff003c, 0x1eff003f) AM_READ(irq_ack_clear)
366376   AM_RANGE(0x1fc00000, 0x1fdfffff) AM_ROM AM_REGION("user1", 0)
367377   AM_RANGE(0x2fc00000, 0x2fdfffff) AM_ROM AM_REGION("user1", 0)
368378ADDRESS_MAP_END
r7500r7501
510520   &st0016_charram
511521};
512522
513//It seems that interrupt flags are never cleared, so I use last line only.
514
515static INTERRUPT_GEN( irq4_gen )
516{
517   if(cpu_getiloops(device) == 0)
518      cpu_set_input_line(device, R3000_IRQ4, ASSERT_LINE);
519   else
520      cpu_set_input_line(device, R3000_IRQ4, CLEAR_LINE);
521}
522
523523static const r3000_cpu_core config =
524524{
525525   1,   /* 1 if we have an FPU, 0 otherwise */
r7500r7501
569569   MDRV_CPU_ADD("sub", R3000LE, 25000000)
570570   MDRV_CPU_CONFIG(config)
571571   MDRV_CPU_PROGRAM_MAP(srmp5_mem)
572   //256???K??
573   MDRV_CPU_VBLANK_INT_HACK(irq4_gen, 256)
572   MDRV_CPU_VBLANK_INT("screen", irq4_line_assert)
574573
575574   MDRV_QUANTUM_TIME(HZ(6000))
576575
src/mame/drivers/destroyr.c
r7500r7501
99#include "deprecat.h"
1010
1111
12typedef struct _destroyr_state destroyr_state;
13struct _destroyr_state
12class destroyr_state
1413{
14public:
15   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, destroyr_state(machine)); }
16
17   destroyr_state(running_machine &machine) { }
18
1519   /* memory pointers */
1620   UINT8 *        major_obj_ram;
1721   UINT8 *        minor_obj_ram;
src/mame/drivers/39in1.c
r7500r7501
2727#include "machine/pxa255.h"
2828#include "sound/dmadac.h"
2929
30typedef struct __39in1_state _39in1_state;
31struct __39in1_state
30class _39in1_state
3231{
32public:
33   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, _39in1_state(machine)); }
34
35   _39in1_state(running_machine &machine) { }
36
3337   UINT32 seed;
3438   UINT32 magic;
3539   UINT32 state;
src/mame/drivers/mcr.c
r7500r7501
708708static ADDRESS_MAP_START( ipu_91695_portmap, ADDRESS_SPACE_IO, 8 )
709709   ADDRESS_MAP_UNMAP_HIGH
710710   ADDRESS_MAP_GLOBAL_MASK(0xff)
711   AM_RANGE(0x00, 0x03) AM_MIRROR(0xe0) AM_DEVREADWRITE("ipu_pio0", z80pio_r, z80pio_w)
711   AM_RANGE(0x00, 0x03) AM_MIRROR(0xe0) AM_DEVREADWRITE("ipu_pio0", z80pio_cd_ba_r, z80pio_cd_ba_w)
712712   AM_RANGE(0x04, 0x07) AM_MIRROR(0xe0) AM_DEVREADWRITE("ipu_sio", mcr_ipu_sio_r, mcr_ipu_sio_w)
713713   AM_RANGE(0x08, 0x0b) AM_MIRROR(0xe0) AM_DEVREADWRITE("ipu_ctc", z80ctc_r, z80ctc_w)
714   AM_RANGE(0x0c, 0x0f) AM_MIRROR(0xe0) AM_DEVREADWRITE("ipu_pio1", z80pio_r, z80pio_w)
714   AM_RANGE(0x0c, 0x0f) AM_MIRROR(0xe0) AM_DEVREADWRITE("ipu_pio1", z80pio_cd_ba_r, z80pio_cd_ba_w)
715715   AM_RANGE(0x10, 0x13) AM_MIRROR(0xe0) AM_WRITE(mcr_ipu_laserdisk_w)
716716   AM_RANGE(0x1c, 0x1f) AM_MIRROR(0xe0) AM_READWRITE(mcr_ipu_watchdog_r, mcr_ipu_watchdog_w)
717717ADDRESS_MAP_END
r7500r7501
16701670   MDRV_CPU_VBLANK_INT_HACK(mcr_ipu_interrupt,2)
16711671
16721672   MDRV_Z80CTC_ADD("ipu_ctc", 7372800/2 /* same as "ipu" */, nflfoot_ctc_intf)
1673   MDRV_Z80PIO_ADD("ipu_pio0", nflfoot_pio_intf)
1674   MDRV_Z80PIO_ADD("ipu_pio1", nflfoot_pio_intf)
1673   MDRV_Z80PIO_ADD("ipu_pio0", 7372800/2, nflfoot_pio_intf)
1674   MDRV_Z80PIO_ADD("ipu_pio1", 7372800/2, nflfoot_pio_intf)
16751675   MDRV_Z80SIO_ADD("ipu_sio", 7372800/2 /* same as "ipu" */, nflfoot_sio_intf)
16761676MACHINE_DRIVER_END
16771677
src/mame/drivers/beaminv.c
r7500r7501
5555#include "cpu/z80/z80.h"
5656
5757
58typedef struct _beaminv_state beaminv_state;
59struct _beaminv_state
58class beaminv_state
6059{
60public:
61   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, beaminv_state(machine)); }
62
63   beaminv_state(running_machine &machine) { }
64
6165   /* memory pointers */
6266   UINT8 *    videoram;
6367   size_t     videoram_size;
src/mame/drivers/matmania.c
r7500r7501
3939#include "sound/3526intf.h"
4040#include "includes/matmania.h"
4141
42/*************************************
43 *
44 *  Memory handlers
45 *
46 *************************************/
47
4248static WRITE8_HANDLER( matmania_sh_command_w )
4349{
44   soundlatch_w(space,offset,data);
45   cputag_set_input_line(space->machine, "audiocpu", M6502_IRQ_LINE, HOLD_LINE);
50   matmania_state *state = (matmania_state *)space->machine->driver_data;
51   soundlatch_w(space, offset, data);
52   cpu_set_input_line(state->audiocpu, M6502_IRQ_LINE, HOLD_LINE);
4653}
4754
4855static WRITE8_HANDLER( maniach_sh_command_w )
4956{
57   matmania_state *state = (matmania_state *)space->machine->driver_data;
5058   soundlatch_w(space, offset, data);
51   cputag_set_input_line(space->machine, "audiocpu", M6809_IRQ_LINE, HOLD_LINE);
59   cpu_set_input_line(state->audiocpu, M6809_IRQ_LINE, HOLD_LINE);
5260}
5361
5462
63/*************************************
64 *
65 *  Address maps
66 *
67 *************************************/
5568
5669static ADDRESS_MAP_START( matmania_map, ADDRESS_SPACE_PROGRAM, 8 )
5770   AM_RANGE(0x0000, 0x077f) AM_RAM
58   AM_RANGE(0x0780, 0x07df) AM_WRITEONLY AM_BASE_SIZE_GENERIC(spriteram)
59   AM_RANGE(0x1000, 0x13ff) AM_RAM AM_BASE(&matmania_videoram2) AM_SIZE(&matmania_videoram2_size)
60   AM_RANGE(0x1400, 0x17ff) AM_RAM AM_BASE(&matmania_colorram2)
61   AM_RANGE(0x2000, 0x21ff) AM_RAM AM_BASE(&matmania_videoram) AM_SIZE(&matmania_videoram_size)
62   AM_RANGE(0x2200, 0x23ff) AM_RAM AM_BASE(&matmania_colorram)
63   AM_RANGE(0x2400, 0x25ff) AM_RAM AM_BASE(&matmania_videoram3) AM_SIZE(&matmania_videoram3_size)
64   AM_RANGE(0x2600, 0x27ff) AM_RAM AM_BASE(&matmania_colorram3)
65   AM_RANGE(0x3000, 0x3000) AM_READ_PORT("IN0") AM_WRITEONLY AM_BASE(&matmania_pageselect)
71   AM_RANGE(0x0780, 0x07df) AM_WRITEONLY AM_BASE_SIZE_MEMBER(matmania_state, spriteram, spriteram_size)
72   AM_RANGE(0x1000, 0x13ff) AM_RAM AM_BASE_SIZE_MEMBER(matmania_state, videoram2, videoram2_size)
73   AM_RANGE(0x1400, 0x17ff) AM_RAM AM_BASE_MEMBER(matmania_state, colorram2)
74   AM_RANGE(0x2000, 0x21ff) AM_RAM AM_BASE_SIZE_MEMBER(matmania_state, videoram, videoram_size)
75   AM_RANGE(0x2200, 0x23ff) AM_RAM AM_BASE_MEMBER(matmania_state, colorram)
76   AM_RANGE(0x2400, 0x25ff) AM_RAM AM_BASE_SIZE_MEMBER(matmania_state, videoram3, videoram3_size)
77   AM_RANGE(0x2600, 0x27ff) AM_RAM AM_BASE_MEMBER(matmania_state, colorram3)
78   AM_RANGE(0x3000, 0x3000) AM_READ_PORT("IN0") AM_WRITEONLY AM_BASE_MEMBER(matmania_state, pageselect)
6679   AM_RANGE(0x3010, 0x3010) AM_READ_PORT("IN1") AM_WRITE(matmania_sh_command_w)
67   AM_RANGE(0x3020, 0x3020) AM_READ_PORT("DSW2") AM_WRITEONLY AM_BASE(&matmania_scroll)
80   AM_RANGE(0x3020, 0x3020) AM_READ_PORT("DSW2") AM_WRITEONLY AM_BASE_MEMBER(matmania_state, scroll)
6881   AM_RANGE(0x3030, 0x3030) AM_READ_PORT("DSW1") AM_WRITENOP /* ?? */
69   AM_RANGE(0x3050, 0x307f) AM_WRITE(matmania_paletteram_w) AM_BASE_GENERIC(paletteram)
82   AM_RANGE(0x3050, 0x307f) AM_WRITE(matmania_paletteram_w) AM_BASE_MEMBER(matmania_state, paletteram)
7083   AM_RANGE(0x4000, 0xffff) AM_ROM
7184ADDRESS_MAP_END
7285
7386static ADDRESS_MAP_START( maniach_map, ADDRESS_SPACE_PROGRAM, 8 )
7487   AM_RANGE(0x0000, 0x077f) AM_RAM
75   AM_RANGE(0x0780, 0x07df) AM_RAM AM_BASE_SIZE_GENERIC(spriteram)
76   AM_RANGE(0x1000, 0x13ff) AM_RAM AM_BASE(&matmania_videoram2) AM_SIZE(&matmania_videoram2_size)
77   AM_RANGE(0x1400, 0x17ff) AM_RAM AM_BASE(&matmania_colorram2)
78   AM_RANGE(0x2000, 0x21ff) AM_RAM AM_BASE(&matmania_videoram) AM_SIZE(&matmania_videoram_size)
79   AM_RANGE(0x2200, 0x23ff) AM_RAM AM_BASE(&matmania_colorram)
80   AM_RANGE(0x2400, 0x25ff) AM_RAM AM_BASE(&matmania_videoram3) AM_SIZE(&matmania_videoram3_size)
81   AM_RANGE(0x2600, 0x27ff) AM_RAM AM_BASE(&matmania_colorram3)
82   AM_RANGE(0x3000, 0x3000) AM_READ_PORT("IN0") AM_WRITEONLY AM_BASE(&matmania_pageselect)
88   AM_RANGE(0x0780, 0x07df) AM_RAM AM_BASE_SIZE_MEMBER(matmania_state, spriteram, spriteram_size)
89   AM_RANGE(0x1000, 0x13ff) AM_RAM AM_BASE_SIZE_MEMBER(matmania_state, videoram2, videoram2_size)
90   AM_RANGE(0x1400, 0x17ff) AM_RAM AM_BASE_MEMBER(matmania_state, colorram2)
91   AM_RANGE(0x2000, 0x21ff) AM_RAM AM_BASE_SIZE_MEMBER(matmania_state, videoram, videoram_size)
92   AM_RANGE(0x2200, 0x23ff) AM_RAM AM_BASE_MEMBER(matmania_state, colorram)
93   AM_RANGE(0x2400, 0x25ff) AM_RAM AM_BASE_SIZE_MEMBER(matmania_state, videoram3, videoram3_size)
94   AM_RANGE(0x2600, 0x27ff) AM_RAM AM_BASE_MEMBER(matmania_state, colorram3)
95   AM_RANGE(0x3000, 0x3000) AM_READ_PORT("IN0") AM_WRITEONLY AM_BASE_MEMBER(matmania_state, pageselect)
8396   AM_RANGE(0x3010, 0x3010) AM_READ_PORT("IN1") AM_WRITE(maniach_sh_command_w)
84   AM_RANGE(0x3020, 0x3020) AM_READ_PORT("DSW2") AM_WRITEONLY AM_BASE(&matmania_scroll)
97   AM_RANGE(0x3020, 0x3020) AM_READ_PORT("DSW2") AM_WRITEONLY AM_BASE_MEMBER(matmania_state, scroll)
8598   AM_RANGE(0x3030, 0x3030) AM_READ_PORT("DSW1") AM_WRITENOP   /* ?? */
8699   AM_RANGE(0x3040, 0x3040) AM_READWRITE(maniach_mcu_r,maniach_mcu_w)
87100   AM_RANGE(0x3041, 0x3041) AM_READ(maniach_mcu_status_r)
88   AM_RANGE(0x3050, 0x307f) AM_WRITE(matmania_paletteram_w) AM_BASE_GENERIC(paletteram)
101   AM_RANGE(0x3050, 0x307f) AM_WRITE(matmania_paletteram_w) AM_BASE_MEMBER(matmania_state, paletteram)
89102   AM_RANGE(0x4000, 0xffff) AM_ROM
90103ADDRESS_MAP_END
91104
r7500r7501
110123
111124static ADDRESS_MAP_START( maniach_mcu_map, ADDRESS_SPACE_PROGRAM, 8 )
112125   ADDRESS_MAP_GLOBAL_MASK(0x7ff)
113   AM_RANGE(0x0000, 0x0000) AM_READWRITE(maniach_68705_portA_r,maniach_68705_portA_w)
114   AM_RANGE(0x0001, 0x0001) AM_READWRITE(maniach_68705_portB_r,maniach_68705_portB_w)
115   AM_RANGE(0x0002, 0x0002) AM_READWRITE(maniach_68705_portC_r,maniach_68705_portC_w)
116   AM_RANGE(0x0004, 0x0004) AM_WRITE(maniach_68705_ddrA_w)
117   AM_RANGE(0x0005, 0x0005) AM_WRITE(maniach_68705_ddrB_w)
118   AM_RANGE(0x0006, 0x0006) AM_WRITE(maniach_68705_ddrC_w)
126   AM_RANGE(0x0000, 0x0000) AM_READWRITE(maniach_68705_port_a_r,maniach_68705_port_a_w)
127   AM_RANGE(0x0001, 0x0001) AM_READWRITE(maniach_68705_port_b_r,maniach_68705_port_b_w)
128   AM_RANGE(0x0002, 0x0002) AM_READWRITE(maniach_68705_port_c_r,maniach_68705_port_c_w)
129   AM_RANGE(0x0004, 0x0004) AM_WRITE(maniach_68705_ddr_a_w)
130   AM_RANGE(0x0005, 0x0005) AM_WRITE(maniach_68705_ddr_b_w)
131   AM_RANGE(0x0006, 0x0006) AM_WRITE(maniach_68705_ddr_c_w)
119132   AM_RANGE(0x0010, 0x007f) AM_RAM
120133   AM_RANGE(0x0080, 0x07ff) AM_ROM
121134ADDRESS_MAP_END
122135
123136
137/*************************************
138 *
139 *  Input ports
140 *
141 *************************************/
142
124143static INPUT_PORTS_START( matmania )
125144   PORT_START("IN0")
126145   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_8WAY
r7500r7501
191210INPUT_PORTS_END
192211
193212
213/*************************************
214 *
215 *  Graphics definitions
216 *
217 *************************************/
218
194219static const gfx_layout charlayout =
195220{
196221   8,8,   /* 8*8 characters */
r7500r7501
268293
269294
270295
296/*************************************
297 *
298 *  Machine driver
299 *
300 *************************************/
301
302static MACHINE_START( matmania )
303{
304   matmania_state *state = (matmania_state *)machine->driver_data;
305
306   state->maincpu = devtag_get_device(machine, "maincpu");
307   state->audiocpu = devtag_get_device(machine, "audiocpu");
308   state->mcu = devtag_get_device(machine, "mcu");
309}
310
271311static MACHINE_DRIVER_START( matmania )
272312
313   /* driver data */
314   MDRV_DRIVER_DATA(matmania_state)
315
273316   /* basic machine hardware */
274317   MDRV_CPU_ADD("maincpu", M6502, 1500000)   /* 1.5 MHz ???? */
275318   MDRV_CPU_PROGRAM_MAP(matmania_map)
r7500r7501
281324                        /* IRQs are caused by the main CPU */
282325   MDRV_QUANTUM_TIME(HZ(600))
283326
327   MDRV_MACHINE_START(matmania)
328
284329   /* video hardware */
285330   MDRV_SCREEN_ADD("screen", RASTER)
286331   MDRV_SCREEN_REFRESH_RATE(60)
r7500r7501
314359/* handler called by the 3526 emulator when the internal timers cause an IRQ */
315360static void irqhandler(running_device *device, int linestate)
316361{
317   cputag_set_input_line(device->machine, "audiocpu", 1, linestate);
362   matmania_state *state = (matmania_state *)device->machine->driver_data;
363   cpu_set_input_line(state->audiocpu, 1, linestate);
318364}
319365
320366static const ym3526_interface ym3526_config =
r7500r7501
323369};
324370
325371
372static MACHINE_START( maniach )
373{
374   matmania_state *state = (matmania_state *)machine->driver_data;
375
376   MACHINE_START_CALL(matmania);
377
378   state_save_register_global(machine, state->port_a_in);
379   state_save_register_global(machine, state->port_a_out);
380   state_save_register_global(machine, state->ddr_a);
381   state_save_register_global(machine, state->port_b_in);
382   state_save_register_global(machine, state->port_b_out);
383   state_save_register_global(machine, state->ddr_b);
384   state_save_register_global(machine, state->port_c_in);
385   state_save_register_global(machine, state->port_c_out);
386   state_save_register_global(machine, state->ddr_c);
387   state_save_register_global(machine, state->mcu_sent);
388   state_save_register_global(machine, state->main_sent);
389   state_save_register_global(machine, state->from_main);
390   state_save_register_global(machine, state->from_mcu);
391}
392
393static MACHINE_RESET( maniach )
394{
395   matmania_state *state = (matmania_state *)machine->driver_data;
396
397   state->port_a_in = 0;
398   state->port_a_out = 0;
399   state->ddr_a = 0;
400   state->port_b_in = 0;
401   state->port_b_out = 0;
402   state->ddr_b = 0;
403   state->port_c_in = 0;
404   state->port_c_out = 0;
405   state->ddr_c = 0;
406   state->mcu_sent = 0;
407   state->main_sent = 0;
408   state->from_main = 0;
409   state->from_mcu = 0;
410}
411
326412static MACHINE_DRIVER_START( maniach )
327413
414   /* driver data */
415   MDRV_DRIVER_DATA(matmania_state)
416
328417   /* basic machine hardware */
329418   MDRV_CPU_ADD("maincpu", M6502, 1500000)   /* 1.5 MHz ???? */
330419   MDRV_CPU_PROGRAM_MAP(maniach_map)
r7500r7501
339428
340429   MDRV_QUANTUM_TIME(HZ(6000))   /* 100 CPU slice per frame - high interleaving to sync main and mcu */
341430
431   MDRV_MACHINE_START(maniach)
432   MDRV_MACHINE_RESET(maniach)
433
342434   /* video hardware */
343435   MDRV_SCREEN_ADD("screen", RASTER)
344436   MDRV_SCREEN_REFRESH_RATE(60)
r7500r7501
365457   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.40)
366458MACHINE_DRIVER_END
367459
368/***************************************************************************
460/*************************************
461 *
462 *  ROM definition(s)
463 *
464 *************************************/
369465
370  Mat Mania driver
371
372***************************************************************************/
373
374466ROM_START( matmania )
375467   ROM_REGION( 0x10000, "maincpu", 0 )
376468   ROM_LOAD( "k0-03",        0x4000, 0x4000, CRC(314ab8a4) SHA1(dc86b2f71a9af8524edad2317343b0d05fe5ef4a) )
r7500r7501
593685
594686
595687
596GAME( 1985, matmania, 0,        matmania, matmania, 0, ROT270, "Technos Japan (Taito America license)", "Mat Mania", 0 )
597GAME( 1985, excthour, matmania, matmania, maniach,  0, ROT270, "Technos Japan (Taito license)", "Exciting Hour", 0 )
598GAME( 1986, maniach,  0,        maniach,  maniach,  0, ROT270, "Technos Japan (Taito America license)", "Mania Challenge (set 1)", 0 )
599GAME( 1986, maniach2, maniach,  maniach,  maniach,  0, ROT270, "Technos Japan (Taito America license)", "Mania Challenge (set 2)" , 0)   /* earlier version? */
688/*************************************
689 *
690 *  Game driver(s)
691 *
692 *************************************/
693
694GAME( 1985, matmania, 0,        matmania, matmania, 0, ROT270, "Technos Japan (Taito America license)", "Mat Mania", GAME_SUPPORTS_SAVE )
695GAME( 1985, excthour, matmania, matmania, maniach,  0, ROT270, "Technos Japan (Taito license)", "Exciting Hour", GAME_SUPPORTS_SAVE )
696GAME( 1986, maniach,  0,        maniach,  maniach,  0, ROT270, "Technos Japan (Taito America license)", "Mania Challenge (set 1)", GAME_SUPPORTS_SAVE )
697GAME( 1986, maniach2, maniach,  maniach,  maniach,  0, ROT270, "Technos Japan (Taito America license)", "Mania Challenge (set 2)", GAME_SUPPORTS_SAVE )   /* earlier version? */
src/mame/drivers/lsasquad.c
r7500r7501
155155
156156static WRITE8_HANDLER( lsasquad_bankswitch_w )
157157{
158   UINT8 *ROM = memory_region(space->machine, "maincpu");
159
160158   /* bits 0-2 select ROM bank */
161   memory_set_bankptr(space->machine, "bank1",&ROM[0x10000 + 0x2000 * (data & 7)]);
159   memory_set_bank(space->machine, "bank1", data & 0x07);
162160
163161   /* bit 3 is zeroed on startup, maybe reset sound CPU */
164162
r7500r7501
172170   AM_RANGE(0x0000, 0x7fff) AM_ROM
173171   AM_RANGE(0x8000, 0x9fff) AM_ROMBANK("bank1")
174172   AM_RANGE(0xa000, 0xbfff) AM_RAM   /* SRAM */
175   AM_RANGE(0xc000, 0xdfff) AM_RAM AM_BASE_GENERIC(videoram) AM_SIZE_GENERIC(videoram)   /* SCREEN RAM */
176   AM_RANGE(0xe000, 0xe3ff) AM_RAM AM_BASE(&lsasquad_scrollram)   /* SCROLL RAM */
177   AM_RANGE(0xe400, 0xe5ff) AM_RAM AM_BASE_SIZE_GENERIC(spriteram)   /* OBJECT RAM */
173   AM_RANGE(0xc000, 0xdfff) AM_RAM AM_BASE_SIZE_MEMBER(lsasquad_state, videoram, videoram_size)   /* SCREEN RAM */
174   AM_RANGE(0xe000, 0xe3ff) AM_RAM AM_BASE_MEMBER(lsasquad_state, scrollram)   /* SCROLL RAM */
175   AM_RANGE(0xe400, 0xe5ff) AM_RAM AM_BASE_SIZE_MEMBER(lsasquad_state, spriteram, spriteram_size)   /* OBJECT RAM */
178176   AM_RANGE(0xe800, 0xe800) AM_READ_PORT("DSWA")
179177   AM_RANGE(0xe801, 0xe801) AM_READ_PORT("DSWB")
180178   AM_RANGE(0xe802, 0xe802) AM_READ_PORT("DSWC")
r7500r7501
194192   AM_RANGE(0x8000, 0x87ff) AM_RAM
195193   AM_RANGE(0xa000, 0xa001) AM_DEVREADWRITE("ymsnd", ym2203_r,ym2203_w)
196194   AM_RANGE(0xc000, 0xc001) AM_DEVWRITE("aysnd", ay8910_address_data_w)
197   AM_RANGE(0xd000, 0xd000) AM_READWRITE(lsasquad_sh_sound_command_r,lsasquad_sh_result_w)
195   AM_RANGE(0xd000, 0xd000) AM_READWRITE(lsasquad_sh_sound_command_r, lsasquad_sh_result_w)
198196   AM_RANGE(0xd400, 0xd400) AM_WRITE(lsasquad_sh_nmi_disable_w)
199197   AM_RANGE(0xd800, 0xd800) AM_WRITE(lsasquad_sh_nmi_enable_w)
200198   AM_RANGE(0xd800, 0xd800) AM_READ(lsasquad_sound_status_r)
r7500r7501
203201
204202static ADDRESS_MAP_START( lsasquad_m68705_map, ADDRESS_SPACE_PROGRAM, 8 )
205203   ADDRESS_MAP_GLOBAL_MASK(0x7ff)
206   AM_RANGE(0x0000, 0x0000) AM_READWRITE(lsasquad_68705_portA_r,lsasquad_68705_portA_w)
207   AM_RANGE(0x0001, 0x0001) AM_READWRITE(lsasquad_68705_portB_r,lsasquad_68705_portB_w)
204   AM_RANGE(0x0000, 0x0000) AM_READWRITE(lsasquad_68705_port_a_r,lsasquad_68705_port_a_w)
205   AM_RANGE(0x0001, 0x0001) AM_READWRITE(lsasquad_68705_port_b_r,lsasquad_68705_port_b_w)
208206   AM_RANGE(0x0002, 0x0002) AM_READ(lsasquad_mcu_status_r)
209   AM_RANGE(0x0004, 0x0004) AM_WRITE(lsasquad_68705_ddrA_w)
210   AM_RANGE(0x0005, 0x0005) AM_WRITE(lsasquad_68705_ddrB_w)
207   AM_RANGE(0x0004, 0x0004) AM_WRITE(lsasquad_68705_ddr_a_w)
208   AM_RANGE(0x0005, 0x0005) AM_WRITE(lsasquad_68705_ddr_b_w)
211209   AM_RANGE(0x0010, 0x007f) AM_RAM
212210   AM_RANGE(0x0080, 0x07ff) AM_ROM
213211ADDRESS_MAP_END
r7500r7501
342340   AM_RANGE(0x0000, 0x7fff) AM_ROM
343341   AM_RANGE(0x8000, 0x9fff) AM_ROMBANK("bank1")
344342   AM_RANGE(0xa000, 0xbfff) AM_RAM   /* SRAM */
345   AM_RANGE(0xc000, 0xdfff) AM_RAM AM_BASE_GENERIC(videoram) AM_SIZE_GENERIC(videoram)   /* SCREEN RAM */
346   AM_RANGE(0xe000, 0xe3ff) AM_RAM AM_BASE(&lsasquad_scrollram)   /* SCROLL RAM */
347   AM_RANGE(0xe400, 0xe7ff) AM_RAM AM_BASE_SIZE_GENERIC(spriteram)   /* OBJECT RAM */
343   AM_RANGE(0xc000, 0xdfff) AM_RAM AM_BASE_SIZE_MEMBER(lsasquad_state, videoram, videoram_size)   /* SCREEN RAM */
344   AM_RANGE(0xe000, 0xe3ff) AM_RAM AM_BASE_MEMBER(lsasquad_state, scrollram)   /* SCROLL RAM */
345   AM_RANGE(0xe400, 0xe7ff) AM_RAM AM_BASE_SIZE_MEMBER(lsasquad_state, spriteram, spriteram_size)   /* OBJECT RAM */
348346   AM_RANGE(0xe800, 0xe800) AM_READ_PORT("DSWA")
349347   AM_RANGE(0xe801, 0xe801) AM_READ_PORT("DSWB")
350348   AM_RANGE(0xe803, 0xe803) AM_READ(daikaiju_mcu_status_r)   /* COIN + 68705 status */
r7500r7501
505503
506504static void irqhandler(running_device *device, int irq)
507505{
508   cputag_set_input_line(device->machine, "audiocpu", 0, irq ? ASSERT_LINE : CLEAR_LINE);
506   lsasquad_state *state = (lsasquad_state *)device->machine->driver_data;
507   cpu_set_input_line(state->audiocpu, 0, irq ? ASSERT_LINE : CLEAR_LINE);
509508}
510509
511510static WRITE8_DEVICE_HANDLER( unk )
r7500r7501
528527};
529528
530529
530static MACHINE_START( lsasquad )
531{
532   lsasquad_state *state = (lsasquad_state *)machine->driver_data;
533   UINT8 *ROM = memory_region(machine, "maincpu");
534
535   memory_configure_bank(machine, "bank1", 0, 8, &ROM[0x10000], 0x2000);
536
537   state->maincpu = devtag_get_device(machine, "maincpu");
538   state->audiocpu = devtag_get_device(machine, "audiocpu");
539   state->mcu = devtag_get_device(machine, "mcu");
540
541   state_save_register_global(machine, state->port_a_in);
542   state_save_register_global(machine, state->port_a_out);
543   state_save_register_global(machine, state->ddr_a);
544   state_save_register_global(machine, state->port_b_in);
545   state_save_register_global(machine, state->port_b_out);
546   state_save_register_global(machine, state->ddr_b);
547   state_save_register_global(machine, state->mcu_sent);
548   state_save_register_global(machine, state->main_sent);
549   state_save_register_global(machine, state->from_main);
550   state_save_register_global(machine, state->from_mcu);
551
552   state_save_register_global(machine, state->sound_pending);
553   state_save_register_global(machine, state->sound_nmi_enable);
554   state_save_register_global(machine, state->pending_nmi);
555   state_save_register_global(machine, state->sound_cmd);
556   state_save_register_global(machine, state->sound_result);
557
558   state_save_register_global(machine, state->daikaiju_xor);
559   state_save_register_global(machine, state->daikaiju_command);
560   state_save_register_global(machine, state->daikaiju_length);
561   state_save_register_global(machine, state->daikaiju_prev);
562   state_save_register_global(machine, state->daikaiju_cnt);
563   state_save_register_global(machine, state->daikaiju_cntr);
564
565   state_save_register_global_array(machine, state->daikaiju_buffer);
566}
567
568static MACHINE_RESET( lsasquad )
569{
570   lsasquad_state *state = (lsasquad_state *)machine->driver_data;
571
572   state->sound_pending = 0;
573   state->sound_nmi_enable = 0;
574   state->pending_nmi = 0;
575   state->sound_cmd = 0;
576   state->sound_result = 0;
577
578   state->port_a_in = 0;
579   state->port_a_out = 0;
580   state->ddr_a = 0;
581   state->port_b_in = 0;
582   state->port_b_out = 0;
583   state->ddr_b = 0;
584   state->mcu_sent = 0;
585   state->main_sent = 0;
586   state->from_main = 0;
587   state->from_mcu = 0;
588
589   /* daikaiju */
590   state->daikaiju_xor = -1;
591   state->daikaiju_command = 0;
592   state->daikaiju_length = 0;
593   state->daikaiju_prev = 0;
594   state->daikaiju_cnt = 0;
595   state->daikaiju_cntr = 0;
596
597   memset(state->daikaiju_buffer, 0, ARRAY_LENGTH(state->daikaiju_buffer));
598}
599
531600static MACHINE_DRIVER_START( lsasquad )
532601
602   /* driver data */
603   MDRV_DRIVER_DATA(lsasquad_state)
604
533605   /* basic machine hardware */
534606   MDRV_CPU_ADD("maincpu", Z80, 6000000)   /* 6 MHz? */
535607   MDRV_CPU_PROGRAM_MAP(lsasquad_map)
r7500r7501
545617                     /* synchronization of the CPUs */
546618                     /* main<->sound synchronization depends on this */
547619
620   MDRV_MACHINE_START(lsasquad)
621   MDRV_MACHINE_RESET(lsasquad)
622
548623   /* video hardware */
549624   MDRV_SCREEN_ADD("screen", RASTER)
550625   MDRV_SCREEN_REFRESH_RATE(60)
r7500r7501
575650
576651static MACHINE_DRIVER_START( daikaiju )
577652
653   /* driver data */
654   MDRV_DRIVER_DATA(lsasquad_state)
655
578656   /* basic machine hardware */
579657   MDRV_CPU_ADD("maincpu", Z80, 6000000)
580658   MDRV_CPU_PROGRAM_MAP(daikaiju_map)
r7500r7501
588666                     /* synchronization of the CPUs */
589667                     /* main<->sound synchronization depends on this */
590668
591   MDRV_MACHINE_RESET(daikaiju)
669   MDRV_MACHINE_START(lsasquad)
670   MDRV_MACHINE_RESET(lsasquad)
592671
593672   /* video hardware */
594673   MDRV_SCREEN_ADD("screen", RASTER)
r7500r7501
730809
731810
732811/* coin inputs are inverted in storming */
733static DRIVER_INIT( lsasquad ) { lsasquad_invertcoin = 0x00; }
734static DRIVER_INIT( storming ) { lsasquad_invertcoin = 0x0c; }
812static DRIVER_INIT( lsasquad )
813{
814   lsasquad_state *state = (lsasquad_state *)machine->driver_data;
815   state->invertcoin = 0x00;
816}
735817
818static DRIVER_INIT( storming )
819{
820   lsasquad_state *state = (lsasquad_state *)machine->driver_data;
821   state->invertcoin = 0x0c;
822}
736823
737GAME( 1986, lsasquad, 0,        lsasquad, lsasquad, lsasquad, ROT270, "Taito", "Land Sea Air Squad / Riku Kai Kuu Saizensen", GAME_IMPERFECT_GRAPHICS )
738GAME( 1986, storming, lsasquad, lsasquad, lsasquad, storming, ROT270, "Taito", "Storming Party / Riku Kai Kuu Saizensen", GAME_IMPERFECT_GRAPHICS )
739GAME( 1986, daikaiju, 0,   daikaiju, daikaiju, 0, ROT270, "Taito", "Daikaiju no Gyakushu", GAME_IMPERFECT_GRAPHICS | GAME_UNEMULATED_PROTECTION)
740824
825GAME( 1986, lsasquad, 0,        lsasquad, lsasquad, lsasquad, ROT270, "Taito", "Land Sea Air Squad / Riku Kai Kuu Saizensen", GAME_IMPERFECT_GRAPHICS | GAME_SUPPORTS_SAVE )
826GAME( 1986, storming, lsasquad, lsasquad, lsasquad, storming, ROT270, "Taito", "Storming Party / Riku Kai Kuu Saizensen", GAME_IMPERFECT_GRAPHICS | GAME_SUPPORTS_SAVE )
827GAME( 1986, daikaiju, 0,   daikaiju, daikaiju, 0, ROT270, "Taito", "Daikaiju no Gyakushu", GAME_IMPERFECT_GRAPHICS | GAME_UNEMULATED_PROTECTION | GAME_SUPPORTS_SAVE )
src/mame/drivers/albazg.c
r7500r7501
6161#include "machine/8255ppi.h"
6262
6363
64typedef struct _albazg_state albazg_state;
65struct _albazg_state
64class albazg_state
6665{
66public:
67   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, albazg_state(machine)); }
68
69   albazg_state(running_machine &machine) { }
70
6771   /* memory pointers */
6872   UINT8 *  cus_ram;
6973   UINT8 *  videoram;
src/mame/drivers/sstrangr.c
r7500r7501
1212
1313#define NUM_PENS   (8)
1414
15typedef struct _sstrangr_state sstrangr_state;
16struct _sstrangr_state
15class sstrangr_state
1716{
17public:
18   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, sstrangr_state(machine)); }
19
20   sstrangr_state(running_machine &machine) { }
21
1822   UINT8 *ram;
1923   UINT8 flip_screen;
2024   UINT8 *proms;
src/mame/drivers/backfire.c
r7500r7501
1313#define DE156CPU ARM
1414#include "emu.h"
1515#include "includes/decocrpt.h"
16#include "includes/deco32.h"
1716#include "machine/eeprom.h"
1817#include "sound/okim6295.h"
1918#include "sound/ymz280b.h"
2019#include "cpu/arm/arm.h"
21#include "includes/deco16ic.h"
20#include "video/deco16ic.h"
2221#include "rendlay.h"
2322
24static UINT32 *backfire_spriteram32_1;
25static UINT32 *backfire_spriteram32_2;
26static UINT32 *backfire_mainram;
27static bitmap_t *backfire_left;
28static bitmap_t *backfire_right;
29
30//UINT32 *backfire_180010, *backfire_188010;
31static UINT32 *backfire_left_priority, *backfire_right_priority;
32
33/* I'm using the functions in deco16ic.c ... same chips, why duplicate code? */
34
35static int backfire_bank_callback(int bank)
23class backfire_state
3624{
37//  mame_printf_debug("bank callback %04x\n",bank); // bit 1 gets set too?
25public:
26   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, backfire_state(machine)); }
3827
39   bank = bank >> 4;
28   backfire_state(running_machine &machine) { }
4029
41   bank = (bank & 1) |  ( (bank & 4) >> 1 ) | ((bank & 2) << 1);
30   /* memory pointers */
31   UINT16 *  pf1_rowscroll;
32   UINT16 *  pf2_rowscroll;
33   UINT16 *  pf3_rowscroll;
34   UINT16 *  pf4_rowscroll;
35   UINT32 *  spriteram_1;
36   UINT32 *  spriteram_2;
37   UINT32 *  mainram;
38   UINT32 *  left_priority;
39   UINT32 *  right_priority;
4240
43   return bank * 0x1000;
44}
41   /* video related */
42   bitmap_t  *left;
43   bitmap_t  *right;
4544
45   /* devices */
46   running_device *maincpu;
47   running_device *deco16ic;
48   running_device *lscreen;
49   running_device *rscreen;
50   running_device *eeprom;
51};
4652
53//UINT32 *backfire_180010, *backfire_188010;
4754
48static VIDEO_START(backfire)
55/* I'm using the functions in deco16ic.c ... same chips, why duplicate code? */
56static VIDEO_START( backfire )
4957{
58   backfire_state *state = (backfire_state *)machine->driver_data;
59
5060   /* allocate the ram as 16-bit (we do it here because the CPU is 32-bit) */
51   deco16_pf1_data = auto_alloc_array(machine, UINT16, 0x2000/2);
52   deco16_pf2_data = auto_alloc_array(machine, UINT16, 0x2000/2);
53   deco16_pf3_data = auto_alloc_array(machine, UINT16, 0x2000/2);
54   deco16_pf4_data = auto_alloc_array(machine, UINT16, 0x2000/2);
55   deco16_pf1_rowscroll = auto_alloc_array(machine, UINT16, 0x0800/2);
56   deco16_pf2_rowscroll = auto_alloc_array(machine, UINT16, 0x0800/2);
57   deco16_pf3_rowscroll = auto_alloc_array(machine, UINT16, 0x0800/2);
58   deco16_pf4_rowscroll = auto_alloc_array(machine, UINT16, 0x0800/2);
59   deco16_pf12_control = auto_alloc_array(machine, UINT16, 0x10/2);
60   deco16_pf34_control =auto_alloc_array(machine,  UINT16, 0x10/2);
61   state->pf1_rowscroll = auto_alloc_array(machine, UINT16, 0x0800/2);
62   state->pf2_rowscroll = auto_alloc_array(machine, UINT16, 0x0800/2);
63   state->pf3_rowscroll = auto_alloc_array(machine, UINT16, 0x0800/2);
64   state->pf4_rowscroll = auto_alloc_array(machine, UINT16, 0x0800/2);
6165
6266   /* and register the allocated ram so that save states still work */
63   state_save_register_global_pointer(machine, deco16_pf1_data, 0x2000/2);
64   state_save_register_global_pointer(machine, deco16_pf2_data, 0x2000/2);
65   state_save_register_global_pointer(machine, deco16_pf3_data, 0x2000/2);
66   state_save_register_global_pointer(machine, deco16_pf4_data, 0x2000/2);
67   state_save_register_global_pointer(machine, deco16_pf1_rowscroll, 0x800/2);
68   state_save_register_global_pointer(machine, deco16_pf2_rowscroll, 0x800/2);
69   state_save_register_global_pointer(machine, deco16_pf3_rowscroll, 0x800/2);
70   state_save_register_global_pointer(machine, deco16_pf4_rowscroll, 0x800/2);
71   state_save_register_global_pointer(machine, deco16_pf12_control, 0x10/2);
72   state_save_register_global_pointer(machine, deco16_pf34_control, 0x10/2);
67   state_save_register_global_pointer(machine, state->pf1_rowscroll, 0x800/2);
68   state_save_register_global_pointer(machine, state->pf2_rowscroll, 0x800/2);
69   state_save_register_global_pointer(machine, state->pf3_rowscroll, 0x800/2);
70   state_save_register_global_pointer(machine, state->pf4_rowscroll, 0x800/2);
7371
74   deco16_2_video_init(machine, 0);
72   state->left =  auto_bitmap_alloc(machine, 80*8, 32*8, BITMAP_FORMAT_INDEXED16);
73   state->right = auto_bitmap_alloc(machine, 80*8, 32*8, BITMAP_FORMAT_INDEXED16);
7574
76   deco16_pf1_colour_bank = 0x00;
77   deco16_pf2_colour_bank = 0x40;
78   deco16_pf3_colour_bank = 0x10;
79   deco16_pf4_colour_bank = 0x50;
80
81   deco16_set_tilemap_bank_callback(0, backfire_bank_callback);
82   deco16_set_tilemap_bank_callback(1, backfire_bank_callback);
83   deco16_set_tilemap_bank_callback(2, backfire_bank_callback);
84   deco16_set_tilemap_bank_callback(3, backfire_bank_callback);
85
86   backfire_left =  auto_bitmap_alloc(machine, 80*8, 32*8, BITMAP_FORMAT_INDEXED16);
87   backfire_right = auto_bitmap_alloc(machine, 80*8, 32*8, BITMAP_FORMAT_INDEXED16);
75   state_save_register_global_bitmap(machine, state->left);
76   state_save_register_global_bitmap(machine, state->right);
8877}
8978
90static void draw_sprites(running_machine *machine,bitmap_t *bitmap,const rectangle *cliprect, UINT32 *backfire_spriteram32, int region)
79static void draw_sprites( running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, UINT32 *spriteram, int region )
9180{
9281   int offs;
9382
9483   flip_screen_set_no_update(machine, 1);
9584
96   for (offs = (0x1400/4)-4;offs >= 0;offs -= 4) // 0x1400 for charlien
85   for (offs = (0x1400 / 4) - 4; offs >= 0; offs -= 4) // 0x1400 for charlien
9786   {
98      int x,y,sprite,colour,multi,fx,fy,inc,flash,mult, pri;
87      int x, y, sprite, colour, multi, fx, fy, inc, flash, mult, pri;
9988
100      sprite = backfire_spriteram32[offs+1]&0xffff;
89      sprite = spriteram[offs + 1] & 0xffff;
10190
102      y = backfire_spriteram32[offs]&0xffff;
103      flash=y&0x1000;
104      if (flash && (video_screen_get_frame_number(machine->primary_screen) & 1)) continue;
91      y = spriteram[offs] & 0xffff;
92      flash = y & 0x1000;
93      if (flash && (video_screen_get_frame_number(machine->primary_screen) & 1))
94         continue;
10595
106      x = backfire_spriteram32[offs+2]&0xffff;
107      colour = (x >>9) & 0x1f;
96      x = spriteram[offs + 2] & 0xffff;
97      colour = (x >> 9) & 0x1f;
10898
109      pri = (x&0xc000); // 2 bits or 1?
99      pri = (x & 0xc000); // 2 bits or 1?
110100
111      switch (pri&0xc000) {
112         case 0x0000: pri=0;   break; // numbers, people, cars when in the air, status display..
113         case 0x4000: pri=0xf0;break; // cars most of the time
114         case 0x8000: pri=0;   break; // car wheels during jump?
115         case 0xc000: pri=0xf0;break; /* car wheels in race? */
101      switch (pri & 0xc000)
102      {
103         case 0x0000: pri = 0;   break; // numbers, people, cars when in the air, status display..
104         case 0x4000: pri = 0xf0;break; // cars most of the time
105         case 0x8000: pri = 0;   break; // car wheels during jump?
106         case 0xc000: pri = 0xf0;break; /* car wheels in race? */
116107      }
117108
118109      // pri 0 = ontop of everything//
119110
120//      pri = 0;
111      // pri = 0;
121112
122113      fx = y & 0x2000;
123114      fy = y & 0x4000;
r7500r7501
128119      if (x >= 320) x -= 512;
129120      if (y >= 256) y -= 512;
130121      y = 240 - y;
131        x = 304 - x;
122      x = 304 - x;
132123
133      if (x>320) continue;
124      if (x > 320) continue;
134125
135126      sprite &= ~multi;
136127      if (fy)
r7500r7501
143134
144135      if (flip_screen_x_get(machine))
145136      {
146         y=240-y;
147         x=304-x;
148         if (fx) fx=0; else fx=1;
149         if (fy) fy=0; else fy=1;
150         mult=16;
137         y = 240 - y;
138         x = 304 - x;
139         if (fx) fx = 0; else fx = 1;
140         if (fy) fy = 0; else fy = 1;
141         mult = 16;
151142      }
152      else mult=-16;
143      else mult = -16;
153144
154145      while (multi >= 0)
155146      {
r7500r7501
167158
168159
169160
170static VIDEO_UPDATE(backfire)
161static VIDEO_UPDATE( backfire )
171162{
172   running_device *left_screen = devtag_get_device(screen->machine, "lscreen");
173   running_device *right_screen = devtag_get_device(screen->machine, "rscreen");
163   backfire_state *state = (backfire_state *)screen->machine->driver_data;
174164
175165   /* screen 1 uses pf1 as the forground and pf3 as the background */
176166   /* screen 2 uses pf2 as the foreground and pf4 as the background */
167   deco16ic_pf12_update(state->deco16ic, state->pf1_rowscroll, state->pf2_rowscroll);
168   deco16ic_pf34_update(state->deco16ic, state->pf3_rowscroll, state->pf4_rowscroll);
177169
178   deco16_pf12_update(deco16_pf1_rowscroll,deco16_pf2_rowscroll);
179   deco16_pf34_update(deco16_pf3_rowscroll,deco16_pf4_rowscroll);
180
181   if (screen == left_screen)
170   if (screen == state->lscreen)
182171   {
183172
184      bitmap_fill(screen->machine->priority_bitmap,NULL,0);
185      bitmap_fill(bitmap,cliprect,0x100);
173      bitmap_fill(screen->machine->priority_bitmap, NULL, 0);
174      bitmap_fill(bitmap, cliprect, 0x100);
186175
187      if (backfire_left_priority[0] == 0)
176      if (state->left_priority[0] == 0)
188177      {
189         deco16_tilemap_3_draw(screen,bitmap,cliprect,0,1);
190         deco16_tilemap_1_draw(screen,bitmap,cliprect,0,2);
191         draw_sprites(screen->machine,bitmap,cliprect,backfire_spriteram32_1,3);
178         deco16ic_tilemap_3_draw(state->deco16ic, bitmap, cliprect, 0, 1);
179         deco16ic_tilemap_1_draw(state->deco16ic, bitmap, cliprect, 0, 2);
180         draw_sprites(screen->machine, bitmap, cliprect, state->spriteram_1, 3);
192181      }
193      else if (backfire_left_priority[0] == 2)
182      else if (state->left_priority[0] == 2)
194183      {
195         deco16_tilemap_1_draw(screen,bitmap,cliprect,0,2);
196         deco16_tilemap_3_draw(screen,bitmap,cliprect,0,4);
197         draw_sprites(screen->machine,bitmap,cliprect,backfire_spriteram32_1,3);
184         deco16ic_tilemap_1_draw(state->deco16ic, bitmap, cliprect, 0, 2);
185         deco16ic_tilemap_3_draw(state->deco16ic, bitmap, cliprect, 0, 4);
186         draw_sprites(screen->machine, bitmap, cliprect, state->spriteram_1, 3);
198187      }
199188      else
200         popmessage( "unknown left priority %08x", backfire_left_priority[0] );
189         popmessage( "unknown left priority %08x", state->left_priority[0]);
201190   }
202   else if (screen == right_screen)
191   else if (screen == state->rscreen)
203192   {
204      bitmap_fill(screen->machine->priority_bitmap,NULL,0);
205      bitmap_fill(bitmap,cliprect,0x500);
193      bitmap_fill(screen->machine->priority_bitmap, NULL, 0);
194      bitmap_fill(bitmap, cliprect, 0x500);
206195
207      if (backfire_right_priority[0] == 0)
196      if (state->right_priority[0] == 0)
208197      {
209         deco16_tilemap_4_draw(screen,bitmap,cliprect,0,1);
210         deco16_tilemap_2_draw(screen,bitmap,cliprect,0,2);
211         draw_sprites(screen->machine,bitmap,cliprect,backfire_spriteram32_2,4);
198         deco16ic_tilemap_4_draw(state->deco16ic, bitmap, cliprect, 0, 1);
199         deco16ic_tilemap_2_draw(state->deco16ic, bitmap, cliprect, 0, 2);
200         draw_sprites(screen->machine, bitmap, cliprect, state->spriteram_2, 4);
212201      }
213      else if (backfire_right_priority[0] == 2)
202      else if (state->right_priority[0] == 2)
214203      {
215         deco16_tilemap_2_draw(screen,bitmap,cliprect,0,2);
216         deco16_tilemap_4_draw(screen,bitmap,cliprect,0,4);
217         draw_sprites(screen->machine,bitmap,cliprect,backfire_spriteram32_2,4);
204         deco16ic_tilemap_2_draw(state->deco16ic, bitmap, cliprect, 0, 2);
205         deco16ic_tilemap_4_draw(state->deco16ic, bitmap, cliprect, 0, 4);
206         draw_sprites(screen->machine, bitmap, cliprect, state->spriteram_2, 4);
218207      }
219208      else
220         popmessage( "unknown right priority %08x", backfire_right_priority[0] );
209         popmessage( "unknown right priority %08x", state->right_priority[0]);
221210   }
222211   return 0;
223212}
224213
225214
226215
227static READ32_DEVICE_HANDLER(backfire_eeprom_r)
216static READ32_DEVICE_HANDLER( backfire_eeprom_r )
228217{
229218   /* some kind of screen indicator?  checked by backfirea set before it will boot */
230219   int backfire_screen = mame_rand(device->machine) & 1;
r7500r7501
233222         | ((input_port_read(device->machine, "IN3") & 0x40) << 16)) ^ (backfire_screen << 26) ;
234223}
235224
236static READ32_HANDLER(backfire_control2_r)
225static READ32_HANDLER( backfire_control2_r )
237226{
227   backfire_state *state = (backfire_state *)space->machine->driver_data;
228
238229//  logerror("%08x:Read eprom %08x (%08x)\n", cpu_get_pc(space->cpu), offset << 1, mem_mask);
239   return (eeprom_read_bit(devtag_get_device(space->machine, "eeprom")) << 24) | input_port_read(space->machine, "IN1") | (input_port_read(space->machine, "IN1") << 16);
230   return (eeprom_read_bit(state->eeprom) << 24) | input_port_read(space->machine, "IN1") | (input_port_read(space->machine, "IN1") << 16);
240231}
241232
242233#ifdef UNUSED_FUNCTION
243234static READ32_HANDLER(backfire_control3_r)
244235{
236   backfire_state *state = (backfire_state *)space->machine->driver_data;
237
245238//  logerror("%08x:Read eprom %08x (%08x)\n", cpu_get_pc(space->cpu), offset << 1, mem_mask);
246   return (eeprom_read_bit(devtag_get_device(space->machine, "eeprom")) << 24) | input_port_read(space->machine, "IN2") | (input_port_read(space->machine, "IN2") << 16);
239   return (eeprom_read_bit(state->eeprom) << 24) | input_port_read(space->machine, "IN2") | (input_port_read(space->machine, "IN2") << 16);
247240}
248241#endif
249242
r7500r7501
251244static WRITE32_DEVICE_HANDLER(backfire_eeprom_w)
252245{
253246   logerror("%s:write eprom %08x (%08x) %08x\n",cpuexec_describe_context(device->machine),offset<<1,mem_mask,data);
254   if (ACCESSING_BITS_0_7) {
255      eeprom_set_clock_line(device, (data & 0x2) ? ASSERT_LINE : CLEAR_LINE);
256      eeprom_write_bit(device, data & 0x1);
257      eeprom_set_cs_line(device, (data & 0x4) ? CLEAR_LINE : ASSERT_LINE);
247   if (ACCESSING_BITS_0_7)
248   {
249      eeprom_set_clock_line(device, BIT(data, 1) ? ASSERT_LINE : CLEAR_LINE);
250      eeprom_write_bit(device, BIT(data, 0));
251      eeprom_set_cs_line(device, BIT(data, 2) ? CLEAR_LINE : ASSERT_LINE);
258252   }
259253}
260254
261255
262static WRITE32_HANDLER(wcvol95_nonbuffered_palette_w)
256static WRITE32_HANDLER(backfire_nonbuffered_palette_w)
263257{
264258   COMBINE_DATA(&space->machine->generic.paletteram.u32[offset]);
265259   palette_set_color_rgb(space->machine,offset,pal5bit(space->machine->generic.paletteram.u32[offset] >> 0),pal5bit(space->machine->generic.paletteram.u32[offset] >> 5),pal5bit(space->machine->generic.paletteram.u32[offset] >> 10));
r7500r7501
267261
268262/* map 32-bit writes to 16-bit */
269263
270static READ32_HANDLER( backfire_pf1_rowscroll_r ) { return deco16_pf1_rowscroll[offset]^0xffff0000; }
271static READ32_HANDLER( backfire_pf2_rowscroll_r ) { return deco16_pf2_rowscroll[offset]^0xffff0000; }
272static READ32_HANDLER( backfire_pf3_rowscroll_r ) { return deco16_pf3_rowscroll[offset]^0xffff0000; }
273static READ32_HANDLER( backfire_pf4_rowscroll_r ) { return deco16_pf4_rowscroll[offset]^0xffff0000; }
274static WRITE32_HANDLER( backfire_pf1_rowscroll_w ) { data &=0x0000ffff; mem_mask &=0x0000ffff; COMBINE_DATA(&deco16_pf1_rowscroll[offset]); }
275static WRITE32_HANDLER( backfire_pf2_rowscroll_w ) { data &=0x0000ffff; mem_mask &=0x0000ffff; COMBINE_DATA(&deco16_pf2_rowscroll[offset]); }
276static WRITE32_HANDLER( backfire_pf3_rowscroll_w ) { data &=0x0000ffff; mem_mask &=0x0000ffff; COMBINE_DATA(&deco16_pf3_rowscroll[offset]); }
277static WRITE32_HANDLER( backfire_pf4_rowscroll_w ) { data &=0x0000ffff; mem_mask &=0x0000ffff; COMBINE_DATA(&deco16_pf4_rowscroll[offset]); }
278static READ32_HANDLER ( backfire_pf12_control_r ) { return deco16_pf12_control[offset]^0xffff0000; }
279static READ32_HANDLER ( backfire_pf34_control_r ) { return deco16_pf34_control[offset]^0xffff0000; }
280static WRITE32_HANDLER( backfire_pf12_control_w ) { data &=0x0000ffff; mem_mask &=0x0000ffff; COMBINE_DATA(&deco16_pf12_control[offset]); }
281static WRITE32_HANDLER( backfire_pf34_control_w ) { data &=0x0000ffff; mem_mask &=0x0000ffff; COMBINE_DATA(&deco16_pf34_control[offset]); }
282static READ32_HANDLER( backfire_pf1_data_r ) {   return deco16_pf1_data[offset]^0xffff0000; }
283static READ32_HANDLER( backfire_pf2_data_r ) {   return deco16_pf2_data[offset]^0xffff0000; }
284static READ32_HANDLER( backfire_pf3_data_r ) {   return deco16_pf3_data[offset]^0xffff0000; }
285static READ32_HANDLER( backfire_pf4_data_r ) {   return deco16_pf4_data[offset]^0xffff0000; }
286static WRITE32_HANDLER( backfire_pf1_data_w ) { data &=0x0000ffff; mem_mask &=0x0000ffff; deco16_pf1_data_w(space,offset,data,mem_mask); }
287static WRITE32_HANDLER( backfire_pf2_data_w ) { data &=0x0000ffff; mem_mask &=0x0000ffff; deco16_pf2_data_w(space,offset,data,mem_mask); }
288static WRITE32_HANDLER( backfire_pf3_data_w ) { data &=0x0000ffff; mem_mask &=0x0000ffff; deco16_pf3_data_w(space,offset,data,mem_mask); }
289static WRITE32_HANDLER( backfire_pf4_data_w ) { data &=0x0000ffff; mem_mask &=0x0000ffff; deco16_pf4_data_w(space,offset,data,mem_mask); }
264static READ32_HANDLER( backfire_pf1_rowscroll_r ) { backfire_state *state = (backfire_state *)space->machine->driver_data; return state->pf1_rowscroll[offset] ^ 0xffff0000; }
265static READ32_HANDLER( backfire_pf2_rowscroll_r ) { backfire_state *state = (backfire_state *)space->machine->driver_data; return state->pf2_rowscroll[offset] ^ 0xffff0000; }
266static READ32_HANDLER( backfire_pf3_rowscroll_r ) { backfire_state *state = (backfire_state *)space->machine->driver_data; return state->pf3_rowscroll[offset] ^ 0xffff0000; }
267static READ32_HANDLER( backfire_pf4_rowscroll_r ) { backfire_state *state = (backfire_state *)space->machine->driver_data; return state->pf4_rowscroll[offset] ^ 0xffff0000; }
268static WRITE32_HANDLER( backfire_pf1_rowscroll_w ) { backfire_state *state = (backfire_state *)space->machine->driver_data; data &= 0x0000ffff; mem_mask &= 0x0000ffff; COMBINE_DATA(&state->pf1_rowscroll[offset]); }
269static WRITE32_HANDLER( backfire_pf2_rowscroll_w ) { backfire_state *state = (backfire_state *)space->machine->driver_data; data &= 0x0000ffff; mem_mask &= 0x0000ffff; COMBINE_DATA(&state->pf2_rowscroll[offset]); }
270static WRITE32_HANDLER( backfire_pf3_rowscroll_w ) { backfire_state *state = (backfire_state *)space->machine->driver_data; data &= 0x0000ffff; mem_mask &= 0x0000ffff; COMBINE_DATA(&state->pf3_rowscroll[offset]); }
271static WRITE32_HANDLER( backfire_pf4_rowscroll_w ) { backfire_state *state = (backfire_state *)space->machine->driver_data; data &= 0x0000ffff; mem_mask &= 0x0000ffff; COMBINE_DATA(&state->pf4_rowscroll[offset]); }
290272
273
291274#ifdef UNUSED_FUNCTION
292275READ32_HANDLER( backfire_unknown_wheel_r )
293276{
r7500r7501
308291
309292static ADDRESS_MAP_START( backfire_map, ADDRESS_SPACE_PROGRAM, 32 )
310293   AM_RANGE(0x000000, 0x0fffff) AM_ROM
311   AM_RANGE(0x100000, 0x10001f) AM_READWRITE( backfire_pf12_control_r, backfire_pf12_control_w)
312   AM_RANGE(0x110000, 0x111fff) AM_READWRITE( backfire_pf1_data_r, backfire_pf1_data_w)
313   AM_RANGE(0x114000, 0x115fff) AM_READWRITE( backfire_pf2_data_r, backfire_pf2_data_w)
314   AM_RANGE(0x120000, 0x120fff) AM_READWRITE( backfire_pf1_rowscroll_r, backfire_pf1_rowscroll_w)
315   AM_RANGE(0x124000, 0x124fff) AM_READWRITE( backfire_pf2_rowscroll_r, backfire_pf2_rowscroll_w)
316   AM_RANGE(0x130000, 0x13001f) AM_READWRITE( backfire_pf34_control_r, backfire_pf34_control_w)
317   AM_RANGE(0x140000, 0x141fff) AM_READWRITE( backfire_pf3_data_r, backfire_pf3_data_w)
318   AM_RANGE(0x144000, 0x145fff) AM_READWRITE( backfire_pf4_data_r, backfire_pf4_data_w)
319   AM_RANGE(0x150000, 0x150fff) AM_READWRITE( backfire_pf3_rowscroll_r, backfire_pf3_rowscroll_w)
320   AM_RANGE(0x154000, 0x154fff) AM_READWRITE( backfire_pf4_rowscroll_r, backfire_pf4_rowscroll_w)
321   AM_RANGE(0x160000, 0x161fff) AM_WRITE(wcvol95_nonbuffered_palette_w) AM_BASE_GENERIC(paletteram)
322   AM_RANGE(0x170000, 0x177fff) AM_RAM AM_BASE( &backfire_mainram )// main ram
294   AM_RANGE(0x100000, 0x10001f) AM_DEVREADWRITE("deco_custom", deco16ic_pf12_control_dword_r, deco16ic_pf12_control_dword_w)
295   AM_RANGE(0x110000, 0x111fff) AM_DEVREADWRITE("deco_custom", deco16ic_pf1_data_dword_r, deco16ic_pf1_data_dword_w)
296   AM_RANGE(0x114000, 0x115fff) AM_DEVREADWRITE("deco_custom", deco16ic_pf2_data_dword_r, deco16ic_pf2_data_dword_w)
297   AM_RANGE(0x120000, 0x120fff) AM_READWRITE(backfire_pf1_rowscroll_r, backfire_pf1_rowscroll_w)
298   AM_RANGE(0x124000, 0x124fff) AM_READWRITE(backfire_pf2_rowscroll_r, backfire_pf2_rowscroll_w)
299   AM_RANGE(0x130000, 0x13001f) AM_DEVREADWRITE("deco_custom", deco16ic_pf34_control_dword_r, deco16ic_pf34_control_dword_w)
300   AM_RANGE(0x140000, 0x141fff) AM_DEVREADWRITE("deco_custom", deco16ic_pf3_data_dword_r, deco16ic_pf3_data_dword_w)
301   AM_RANGE(0x144000, 0x145fff) AM_DEVREADWRITE("deco_custom", deco16ic_pf4_data_dword_r, deco16ic_pf4_data_dword_w)
302   AM_RANGE(0x150000, 0x150fff) AM_READWRITE(backfire_pf3_rowscroll_r, backfire_pf3_rowscroll_w)
303   AM_RANGE(0x154000, 0x154fff) AM_READWRITE(backfire_pf4_rowscroll_r, backfire_pf4_rowscroll_w)
304   AM_RANGE(0x160000, 0x161fff) AM_WRITE(backfire_nonbuffered_palette_w) AM_BASE_GENERIC(paletteram)
305   AM_RANGE(0x170000, 0x177fff) AM_RAM AM_BASE_MEMBER(backfire_state, mainram)// main ram
323306
324307//  AM_RANGE(0x180010, 0x180013) AM_RAM AM_BASE(&backfire_180010) // always 180010 ?
325308//  AM_RANGE(0x188010, 0x188013) AM_RAM AM_BASE(&backfire_188010) // always 188010 ?
326309
327   AM_RANGE(0x184000, 0x185fff) AM_RAM AM_BASE( &backfire_spriteram32_1 )
328   AM_RANGE(0x18c000, 0x18dfff) AM_RAM AM_BASE( &backfire_spriteram32_2 )
310   AM_RANGE(0x184000, 0x185fff) AM_RAM AM_BASE_MEMBER(backfire_state, spriteram_1)
311   AM_RANGE(0x18c000, 0x18dfff) AM_RAM AM_BASE_MEMBER(backfire_state, spriteram_2)
329312   AM_RANGE(0x190000, 0x190003) AM_DEVREAD("eeprom", backfire_eeprom_r)
330313   AM_RANGE(0x194000, 0x194003) AM_READ(backfire_control2_r)
331314   AM_RANGE(0x1a4000, 0x1a4003) AM_DEVWRITE("eeprom", backfire_eeprom_w)
332315
333   AM_RANGE(0x1a8000, 0x1a8003) AM_RAM AM_BASE(&backfire_left_priority)
334   AM_RANGE(0x1ac000, 0x1ac003) AM_RAM AM_BASE(&backfire_right_priority)
316   AM_RANGE(0x1a8000, 0x1a8003) AM_RAM AM_BASE_MEMBER(backfire_state, left_priority)
317   AM_RANGE(0x1ac000, 0x1ac003) AM_RAM AM_BASE_MEMBER(backfire_state, right_priority)
335318//  AM_RANGE(0x1b0000, 0x1b0003) AM_WRITENOP // always 1b0000
336319
337320   /* when set to pentometer in test mode */
r7500r7501
462445
463446
464447
448static int backfire_bank_callback( int bank )
449{
450   //  mame_printf_debug("bank callback %04x\n",bank); // bit 1 gets set too?
451   bank = bank >> 4;
452   bank = (bank & 1) | ((bank & 4) >> 1) | ((bank & 2) << 1);
453
454   return bank * 0x1000;
455}
456
457static const deco16ic_interface backfire_deco16ic_intf =
458{
459   "lscreen",
460   0, 0, 1,
461   0x0f, 0x0f, 0x0f, 0x0f,   /* trans masks (default values) */
462   0x00, 0x40, 0x10, 0x50, /* color base */
463   0x0f, 0x0f, 0x0f, 0x0f,   /* color masks (default values) */
464   backfire_bank_callback,
465   backfire_bank_callback,
466   backfire_bank_callback,
467   backfire_bank_callback
468};
469
470static MACHINE_START( backfire )
471{
472   backfire_state *state = (backfire_state *)machine->driver_data;
473
474   state->maincpu = devtag_get_device(machine, "maincpu");
475   state->deco16ic = devtag_get_device(machine, "deco_custom");
476   state->lscreen = devtag_get_device(machine, "lscreen");
477   state->rscreen = devtag_get_device(machine, "rscreen");
478   state->eeprom = devtag_get_device(machine, "eeprom");
479}
480
465481static MACHINE_DRIVER_START( backfire )
466482
483   /* driver data */
484   MDRV_DRIVER_DATA(backfire_state)
485
467486   /* basic machine hardware */
468487   MDRV_CPU_ADD("maincpu", ARM, 28000000/4) /* Unconfirmed */
469488   MDRV_CPU_PROGRAM_MAP(backfire_map)
r7500r7501
471490
472491   MDRV_EEPROM_93C46_ADD("eeprom")
473492
493   MDRV_MACHINE_START(backfire)
494
474495   /* video hardware */
475496   MDRV_PALETTE_LENGTH(2048)
476497   MDRV_GFXDECODE(backfire)
r7500r7501
493514   MDRV_VIDEO_START(backfire)
494515   MDRV_VIDEO_UPDATE(backfire)
495516
517   MDRV_DECO16IC_ADD("deco_custom", backfire_deco16ic_intf)
518
496519   /* sound hardware */
497520   MDRV_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker")
498521
r7500r7501
631654   UINT8 *buf1 = auto_alloc_array(machine, UINT8, length);
632655   UINT32 x;
633656
634   for (x=0;x<length;x++)
657   for (x = 0; x < length; x++)
635658   {
636659      UINT32 addr;
637660
r7500r7501
645668      buf1[addr] = rom[x];
646669   }
647670
648   memcpy(rom,buf1,length);
671   memcpy(rom, buf1, length);
649672
650   auto_free (machine, buf1);
673   auto_free(machine, buf1);
651674}
652675
653676static READ32_HANDLER( backfire_speedup_r )
654677{
655//  mame_printf_debug( "%08x\n",cpu_get_pc(space->cpu));
678   backfire_state *state = (backfire_state *)space->machine->driver_data;
656679
657   if (cpu_get_pc(space->cpu)==0xce44)  cpu_spinuntil_time(space->cpu, ATTOTIME_IN_USEC(400)); // backfire
658   if (cpu_get_pc(space->cpu)==0xcee4)  cpu_spinuntil_time(space->cpu, ATTOTIME_IN_USEC(400)); // backfirea
680   //mame_printf_debug( "%08x\n",cpu_get_pc(space->cpu));
659681
660   return backfire_mainram[0x18/4];
682   if (cpu_get_pc(space->cpu )== 0xce44)  cpu_spinuntil_time(space->cpu, ATTOTIME_IN_USEC(400)); // backfire
683   if (cpu_get_pc(space->cpu) == 0xcee4)  cpu_spinuntil_time(space->cpu, ATTOTIME_IN_USEC(400)); // backfirea
684
685   return state->mainram[0x18/4];
661686}
662687
663688
r7500r7501
671696   memory_install_read32_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x0170018, 0x017001b, 0, 0, backfire_speedup_r );
672697}
673698
674GAME( 1995, backfire, 0,        backfire,      backfire, backfire, ROT0, "Data East Corporation", "Backfire! (set 1)", 0 )
675GAME( 1995, backfirea,backfire, backfire,      backfire, backfire, ROT0, "Data East Corporation", "Backfire! (set 2)", 0 ) // defaults to wheel controls, must change to joystick to play
699GAME( 1995, backfire,  0,        backfire,   backfire, backfire, ROT0, "Data East Corporation", "Backfire! (set 1)", GAME_SUPPORTS_SAVE )
700GAME( 1995, backfirea, backfire, backfire,   backfire, backfire, ROT0, "Data East Corporation", "Backfire! (set 2)", GAME_SUPPORTS_SAVE ) // defaults to wheel controls, must change to joystick to play
src/mame/drivers/exerion.c
r7500r7501
1111    * The freakish graphics encoding scheme, which no other MAME-supported game uses
1212    * The sprite-ram, and all the funky parameters that go along with it
1313
14
15Stephh's notes (based on the games Z80 code and some tests) :
16
171) 'exerion'
18
19  - The coin insertion routine (code at 0x0066) is buggy as you get a credit
20    on first coin after initialisation even if you need more than 1 coin for 1 credit :
21      * when coinage is set to 2C_1C, you get a credit when inserting
22        1, 2, 4, 6 ... multiples of 2 coins
23      * when coinage is set to 3C_1C, you get a credit when inserting
24        1, 3, 6, 9 ... multiples of 3 coins
25      * when coinage is set to 4C_1C, you get a credit when inserting
26        1, 4, 8, 12 ... multiples of 4 coins
27      * when coinage is set to 5C_1C, you get a credit when inserting
28        1, 5, 10, 15 ... multiples of 5 coins
29  - According to the Dip Switches sheet, difficulty is handled by DSW0 bits 5 and 6.
30    In fact, bit 6 determines the overall difficulty (0x40 = OFF easy - 0x00 = ON hard)
31    while bit 5 determines enemies' number of bullets (0x20 = OFF for less bullets and
32    0x00 = ON for more bullets).
33  - When starting a 1 or 2 players game, 2 checksums are computed (code at 0x00e4) :
34    one from 0x05f0 to 0x06ee (stored at 0x6030), one from 0x00d8 to 0x01d6 (stored
35    at 0x6031). Contents of 0x0625 is also stored to 0x6032.
36  - Each time before attract mode sequence starts, a checksum is computed from 0x0000
37    to 0x1fff (code at 0x28b8) if 17th score in the high-score table is not 0.
38    If checksum doesn't match the hardcoded value (0xb5), you get one more credit
39    and you are allowed to continue the game with an extra life (score, charge and
40    level are not reset to original values).
41  - At the begining of each life of each player, a checksum is computed from 0x4100
42    to 0x4dff (code at 0x07d8) if 1st score in the high-score table is >= 80000.
43    If checksum doesn't match the hardcoded value (0x63), you get 255 credits !
44    Notice that the displayed number of credits won't be correct as the game
45    isn't suppose to allow more than 9 credits.
46  - In a 2 players game, when player changes, if player it was player 2 turn,
47    values from 0x6030 to 0x6032 (see above) are compared with hard-coded values
48    (code at 0x04c8). If they don't match respectively 0xfe, 0xb3 and 0x4c,
49    and if 9th score in the high-score table is not 0, the game resets !
50  - Before entering player's initials, a checksum is computed from 0x5f00 to 0x5fff
51    (code at 0x5bd0) if player has reached level 6 (2nd kind of enemies after bonus
52    stage). If checksum doesn't match the hardcoded value (0x9a), the game resets !
53  - There is sort of protection routine at 0x4120 which has an effect when
54    player loses a life on reaching first bonus stage or after. If values read
55    from 0x6008 to 0x600b don't match values from ROM area 0x33c0-0x33ff,
56    the game resets. See 'exerion_protection_r' read handler.
57  - There is an unknown routine at 0x5f70 which is called when the game boots
58    which reads value from 0x600c and see if it matches a hardcoded value (0xbe).
59    If they don't match, the game resets after displaying the high-scores table.
60  - There is another unknown routine at 0x414e which is called when a game is over
61    which reads value from 0x600c and see if it matches value from ROM area
62    0x4000-0x400f based on internal timer value for a game at 0x604a. If they don't
63    match, its only effect is to set lives to 0, which is always the case when the
64    game is over, so it doesn't seem to have any real effect.
65    Was it supposed to be called at another time ?
66  - The routine at 0x5f90 writes to adresses 0x6008-0x600c values read from AY port A
67    (one write after one read). This routine is called by the 2 unknown routines.
68
692) 'exeriont'
70
71  - The coin insertion routine is fixed in this set (see the subttle changes
72    in the code from 0x0077 to 0x0082).
73  - The routine at 0x28b8 is the same as in 'exerion' (same hardcoded value).
74  - The routine at 0x07d8 is the same as in 'exerion' (same hardcoded value).
75  - The routine at 0x04c8 is the same as in 'exerion' (same hardcoded values).
76  - The routine at 0x5bd0 is the same as in 'exerion' (same hardcoded value).
77  - The routine at 0x4120 is the same as in 'exerion', but data from 0x33c0 to 0x33ff
78    is slightly different :
79
80      address   exerion  exeriont
81      0x33c1:     0x3e     0x36
82      0x33c2:     0x37     0x32
83      0x33c8:     0x76     0x7e
84      0x33ca:     0x32     0x26
85      0x33cb:     0x34     0x1e
86      0x33d5:     0x07     0x3f
87      0x33fc:     0x76     0x40
88      0x33fd:     0x37     0x00
89      0x33fe:     0x32     0x00
90      0x33ff:     0x26     0x00
91
92  - The routine at 0x5f70 is similar to the one in 'exerion' (hardcoded value = 0x9e).
93  - The routine at 0x414e is the same as in 'exerion', but data from 0x4000 to 0x400f
94    is slightly different :
95
96      address   exerion  exeriont
97      0x4002:     0xb2     0x9e
98      0x400f:     0xbe     0x9e
99
100  - The routine at 0x5f90 is the same as in 'exerion'.
101
1023) 'exerionb'
103
104  - This set is based on 'exerion' as the coin insertion routine at 0x0066
105    (and as a consequence the bug) is the same.
106  - The routine at 0x28b8 has been patched, so you can never see the "continue" feature.
107  - The routine at 0x07d8 has been patched, so you can never get 255 credits.
108  - The routine at 0x04c8 and the computed values from 0x6030 to 0x6032 are surprisingly
109    the same as in 'exerion'.
110  - The routine at 0x5bd0 has been patched, so the game can't reset.
111  - The "protection" routine at 0x4120 has been patched, so the game can't reset.
112  - The first unknown routine at 0x5f70 has been patched, so the game can't reset.
113  - The second unknown routine at 0x414e has been patched, so lives can't be set to 0.
114  - The routine at 0x5f90 is completely different : it reads values from AY port A,
115    but nothing is written to adresses 0x6008-0x600c, and there are lots of writes
116    to AY port B (0xd001) due to extra code at 0x0050 and extra data at 0x0040.
117
14118***************************************************************************/
15119
16120#include "emu.h"
r7500r7501
25129 *
26130 *************************************/
27131
28static READ8_HANDLER( exerion_port01_r )
132/* Players inputs are muxed at 0xa000 */
133static CUSTOM_INPUT( exerion_controls_r )
29134{
30   exerion_state *state = (exerion_state *)space->machine->driver_data;
31   /* the cocktail flip bit muxes between ports 0 and 1 */
32   return state->cocktail_flip ? input_port_read(space->machine, "IN1") : input_port_read(space->machine, "IN0");
135   static const char *const inname[2] = { "P1", "P2" };
136   exerion_state *state = (exerion_state *)field->port->machine->driver_data;
137   return input_port_read(field->port->machine, inname[state->cocktail_flip]) & 0x3f;
33138}
34139
35140
r7500r7501
48153 *
49154 *************************************/
50155
51/* This is the first of many Exerion "features." No clue if it's */
156/* This is the first of many Exerion "features". No clue if it's */
52157/* protection or some sort of timer. */
53158static READ8_DEVICE_HANDLER( exerion_porta_r )
54159{
r7500r7501
61166static WRITE8_DEVICE_HANDLER( exerion_portb_w )
62167{
63168   exerion_state *state = (exerion_state *)device->machine->driver_data;
64
65169   /* pull the expected value from the ROM */
66170   state->porta = memory_region(device->machine, "maincpu")[0x5f76];
67171   state->portb = data;
r7500r7501
73177static READ8_HANDLER( exerion_protection_r )
74178{
75179   exerion_state *state = (exerion_state *)space->machine->driver_data;
76
77180   if (cpu_get_pc(space->cpu) == 0x4143)
78181      return memory_region(space->machine, "maincpu")[0x33c0 + (state->main_ram[0xd] << 2) + offset];
79182   else
r7500r7501
95198   AM_RANGE(0x8000, 0x87ff) AM_RAM AM_BASE_SIZE_MEMBER(exerion_state, videoram, videoram_size)
96199   AM_RANGE(0x8800, 0x887f) AM_RAM AM_BASE_SIZE_MEMBER(exerion_state, spriteram, spriteram_size)
97200   AM_RANGE(0x8800, 0x8bff) AM_RAM
98   AM_RANGE(0xa000, 0xa000) AM_READ(exerion_port01_r)
201   AM_RANGE(0xa000, 0xa000) AM_READ_PORT("IN0")
99202   AM_RANGE(0xa800, 0xa800) AM_READ_PORT("DSW0")
100203   AM_RANGE(0xb000, 0xb000) AM_READ_PORT("DSW1")
101204   AM_RANGE(0xc000, 0xc000) AM_WRITE(exerion_videoreg_w)
r7500r7501
129232 *
130233 *************************************/
131234
235/* verified from Z80 code */
132236static INPUT_PORTS_START( exerion )
133   PORT_START("IN0")      /* player 1 inputs (muxed on 0xa000) */
134   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_8WAY PORT_PLAYER(1)
135   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_8WAY PORT_PLAYER(1)
136   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_8WAY PORT_PLAYER(1)
137   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_8WAY PORT_PLAYER(1)
138   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(1)
139   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(1)
237   PORT_START("IN0")
238   PORT_BIT( 0x3f, IP_ACTIVE_HIGH, IPT_SPECIAL ) PORT_CUSTOM(exerion_controls_r, (void *)0)
140239   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_START1 )
141240   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_START2 )
142241
143   PORT_START("IN1")      /* player 2 inputs (muxed on 0xa000) */
144   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_8WAY PORT_PLAYER(2)
145   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_8WAY PORT_PLAYER(2)
146   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_8WAY PORT_PLAYER(2)
147   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_8WAY PORT_PLAYER(2)
148   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(2)
149   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(2)
150   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_START1 )
151   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_START2 )
152
153   PORT_START("DSW0")      /* dip switches (0xa800) */
242   PORT_START("DSW0")
154243   PORT_DIPNAME( 0x07, 0x02, DEF_STR( Lives ) )
155244   PORT_DIPSETTING(    0x00, "1" )
156245   PORT_DIPSETTING(    0x01, "2" )
157246   PORT_DIPSETTING(    0x02, "3" )
158247   PORT_DIPSETTING(    0x03, "4" )
159248   PORT_DIPSETTING(    0x04, "5" )
160   PORT_DIPSETTING(    0x07, "Infinite (Cheat)")
249//  PORT_DIPSETTING(    0x05, "5" )                         /* duplicated setting */
250//  PORT_DIPSETTING(    0x06, "5" )                         /* duplicated setting */
251   PORT_DIPSETTING(    0x07, "254 (Cheat)")
161252   PORT_DIPNAME( 0x18, 0x00, DEF_STR( Bonus_Life ) )
162253   PORT_DIPSETTING(    0x00, "10000" )
163254   PORT_DIPSETTING(    0x08, "20000" )
164255   PORT_DIPSETTING(    0x10, "30000" )
165256   PORT_DIPSETTING(    0x18, "40000" )
166   PORT_DIPNAME( 0x20, 0x20, DEF_STR( Unknown ) )      /* used */
167   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
168   PORT_DIPSETTING(    0x20, DEF_STR( On ) )
169   PORT_DIPNAME( 0x40, 0x00, DEF_STR( Difficulty ) )
257   PORT_DIPNAME( 0x60, 0x00, DEF_STR( Difficulty ) )       /* see notes */
170258   PORT_DIPSETTING(    0x00, DEF_STR( Easy ) )
259   PORT_DIPSETTING(    0x20, DEF_STR( Medium ) )
171260   PORT_DIPSETTING(    0x40, DEF_STR( Hard ) )
261   PORT_DIPSETTING(    0x60, DEF_STR( Hardest ) )
172262   PORT_DIPNAME( 0x80, 0x00, DEF_STR( Cabinet ) )
173263   PORT_DIPSETTING(    0x00, DEF_STR( Upright ) )
174264   PORT_DIPSETTING(    0x80, DEF_STR( Cocktail ) )
175265
176   PORT_START("DSW1")      /* dip switches/VBLANK (0xb000) */
266   PORT_START("DSW1")
177267   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_VBLANK )
178   PORT_DIPNAME( 0x02, 0x00, DEF_STR( Unknown ) )
179   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
180   PORT_DIPSETTING(    0x02, DEF_STR( On ) )
181   PORT_DIPNAME( 0x0c, 0x00, DEF_STR( Coinage ) )
268   PORT_DIPNAME( 0x0e, 0x00, DEF_STR( Coinage ) )          /* see notes */
269   PORT_DIPSETTING(    0x0e, DEF_STR( 5C_1C ) )
270   PORT_DIPSETTING(    0x0a, DEF_STR( 4C_1C ) )
271   PORT_DIPSETTING(    0x06, DEF_STR( 3C_1C ) )
272   PORT_DIPSETTING(    0x02, DEF_STR( 2C_1C ) )
182273   PORT_DIPSETTING(    0x00, DEF_STR( 1C_1C ) )
183274   PORT_DIPSETTING(    0x04, DEF_STR( 1C_2C ) )
184275   PORT_DIPSETTING(    0x08, DEF_STR( 1C_3C ) )
r7500r7501
187278
188279   PORT_START("COIN")
189280   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_COIN1 ) PORT_CHANGED(coin_inserted, 0)
281
282   PORT_START("P1")          /* fake input port */
283   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_UP )    PORT_8WAY
284   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN )  PORT_8WAY
285   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_8WAY
286   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT )  PORT_8WAY
287   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 )
288   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON2 )
289
290   PORT_START("P2")          /* fake input port */
291   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_UP )    PORT_8WAY PORT_COCKTAIL
292   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN )  PORT_8WAY PORT_COCKTAIL
293   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_8WAY PORT_COCKTAIL
294   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT )  PORT_8WAY PORT_COCKTAIL
295   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_COCKTAIL
296   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_COCKTAIL
190297INPUT_PORTS_END
191298
192299
src/mame/drivers/mosaic.c
r7500r7501
11/***************************************************************************
22
3Mosaic (c) 1990 Space
3    Mosaic (c) 1990 Space
44
5Notes:
6- the ROM OK / RAM OK message in service mode is fake: ROM and RAM are not tested.
5    Notes:
6    - the ROM OK / RAM OK message in service mode is fake: ROM and RAM are not tested.
77
88***************************************************************************/
99
1010#include "emu.h"
1111#include "cpu/z180/z180.h"
1212#include "sound/2203intf.h"
13#include "includes/mosaic.h"
1314
14
15extern UINT8 *mosaic_fgvideoram;
16extern UINT8 *mosaic_bgvideoram;
17WRITE8_HANDLER( mosaic_fgvideoram_w );
18WRITE8_HANDLER( mosaic_bgvideoram_w );
19VIDEO_START( mosaic );
20VIDEO_UPDATE( mosaic );
21
22
23
24static int prot_val;
25
2615static WRITE8_HANDLER( protection_w )
2716{
28   if ((data & 0x80) == 0)
17   mosaic_state *state = (mosaic_state *)space->machine->driver_data;
18
19   if (!BIT(data, 7))
2920   {
3021      /* simply increment given value */
31      prot_val = (data + 1) << 8;
22      state->prot_val = (data + 1) << 8;
3223   }
3324   else
3425   {
r7500r7501
4334         0x411f, 0x473f
4435      };
4536
46      prot_val = jumptable[data & 0x7f];
37      state->prot_val = jumptable[data & 0x7f];
4738   }
4839}
4940
5041static READ8_HANDLER( protection_r )
5142{
52   int res = (prot_val >> 8) & 0xff;
43   mosaic_state *state = (mosaic_state *)space->machine->driver_data;
44   int res = (state->prot_val >> 8) & 0xff;
5345
54   logerror("%06x: protection_r %02x\n",cpu_get_pc(space->cpu),res);
46   logerror("%06x: protection_r %02x\n", cpu_get_pc(space->cpu), res);
5547
56   prot_val <<= 8;
48   state->prot_val <<= 8;
5749
5850   return res;
5951}
6052
6153static WRITE8_HANDLER( gfire2_protection_w )
6254{
63   logerror("%06x: protection_w %02x\n",cpu_get_pc(space->cpu),data);
55   mosaic_state *state = (mosaic_state *)space->machine->driver_data;
6456
57   logerror("%06x: protection_w %02x\n", cpu_get_pc(space->cpu), data);
58
6559   switch(data)
6660   {
6761      case 0x01:
6862         /* written repeatedly; no effect?? */
6963         break;
7064      case 0x02:
71         prot_val = 0x0a10;
65         state->prot_val = 0x0a10;
7266         break;
7367      case 0x04:
74         prot_val = 0x0a15;
68         state->prot_val = 0x0a15;
7569         break;
7670      case 0x06:
77         prot_val = 0x80e3;
71         state->prot_val = 0x80e3;
7872         break;
7973      case 0x08:
80         prot_val = 0x0965;
74         state->prot_val = 0x0965;
8175         break;
8276      case 0x0a:
83         prot_val = 0x04b4;
77         state->prot_val = 0x04b4;
8478         break;
8579   }
8680}
8781
8882static READ8_HANDLER( gfire2_protection_r )
8983{
90   int res = prot_val & 0xff;
84   mosaic_state *state = (mosaic_state *)space->machine->driver_data;
85   int res = state->prot_val & 0xff;
9186
92   prot_val >>= 8;
87   state->prot_val >>= 8;
9388
9489   return res;
9590}
r7500r7501
9994static ADDRESS_MAP_START( mosaic_map, ADDRESS_SPACE_PROGRAM, 8 )
10095   AM_RANGE(0x00000, 0x0ffff) AM_ROM
10196   AM_RANGE(0x20000, 0x21fff) AM_RAM
102   AM_RANGE(0x22000, 0x22fff) AM_RAM_WRITE(mosaic_bgvideoram_w) AM_BASE(&mosaic_bgvideoram)
103   AM_RANGE(0x23000, 0x23fff) AM_RAM_WRITE(mosaic_fgvideoram_w) AM_BASE(&mosaic_fgvideoram)
97   AM_RANGE(0x22000, 0x22fff) AM_RAM_WRITE(mosaic_bgvideoram_w) AM_BASE_MEMBER(mosaic_state, bgvideoram)
98   AM_RANGE(0x23000, 0x23fff) AM_RAM_WRITE(mosaic_fgvideoram_w) AM_BASE_MEMBER(mosaic_state, fgvideoram)
10499   AM_RANGE(0x24000, 0x241ff) AM_RAM_WRITE(paletteram_xRRRRRGGGGGBBBBB_le_w) AM_BASE_GENERIC(paletteram)
105100ADDRESS_MAP_END
106101
107102static ADDRESS_MAP_START( gfire2_map, ADDRESS_SPACE_PROGRAM, 8 )
108103   AM_RANGE(0x00000, 0x0ffff) AM_ROM
109104   AM_RANGE(0x10000, 0x17fff) AM_RAM
110   AM_RANGE(0x22000, 0x22fff) AM_RAM_WRITE(mosaic_bgvideoram_w) AM_BASE(&mosaic_bgvideoram)
111   AM_RANGE(0x23000, 0x23fff) AM_RAM_WRITE(mosaic_fgvideoram_w) AM_BASE(&mosaic_fgvideoram)
105   AM_RANGE(0x22000, 0x22fff) AM_RAM_WRITE(mosaic_bgvideoram_w) AM_BASE_MEMBER(mosaic_state, bgvideoram)
106   AM_RANGE(0x23000, 0x23fff) AM_RAM_WRITE(mosaic_fgvideoram_w) AM_BASE_MEMBER(mosaic_state, fgvideoram)
112107   AM_RANGE(0x24000, 0x241ff) AM_RAM_WRITE(paletteram_xRRRRRGGGGGBBBBB_le_w) AM_BASE_GENERIC(paletteram)
113108ADDRESS_MAP_END
114109
r7500r7501
258253
259254
260255
256static MACHINE_START( mosaic )
257{
258   mosaic_state *state = (mosaic_state *)machine->driver_data;
259
260   state_save_register_global(machine, state->prot_val);
261}
262
263static MACHINE_RESET( mosaic )
264{
265   mosaic_state *state = (mosaic_state *)machine->driver_data;
266
267   state->prot_val = 0;
268}
269
261270static MACHINE_DRIVER_START( mosaic )
271
272   /* driver data */
273   MDRV_DRIVER_DATA(mosaic_state)
274
275   /* basic machine hardware */
262276   MDRV_CPU_ADD("maincpu", Z180, 7000000)   /* ??? */
263277   MDRV_CPU_PROGRAM_MAP(mosaic_map)
264278   MDRV_CPU_IO_MAP(mosaic_io_map)
265279   MDRV_CPU_VBLANK_INT("screen", irq0_line_hold)
266280
281   MDRV_MACHINE_START(mosaic)
282   MDRV_MACHINE_RESET(mosaic)
283
267284   /* video hardware */
268285   MDRV_SCREEN_ADD("screen", RASTER)
269286   MDRV_SCREEN_REFRESH_RATE(60)
src/mame/drivers/astrocorp.c
r7500r7501
2424#include "machine/ticket.h"
2525#include "sound/okim6295.h"
2626
27typedef struct _astrocorp_state astrocorp_state;
28struct _astrocorp_state
27class astrocorp_state
2928{
29public:
30   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, astrocorp_state(machine)); }
31
32   astrocorp_state(running_machine &machine) { }
33
3034   /* memory pointers */
3135   UINT16 *   spriteram;
3236   UINT16 *   paletteram;
src/mame/drivers/meijinsn.c
r7500r7501
6565#include "video/resnet.h"
6666#include "sound/ay8910.h"
6767
68static UINT16 *shared_ram;
69static unsigned deposits1=0, deposits2=0, credits=0;
68class meijinsn_state
69{
70public:
71   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, meijinsn_state(machine)); }
7072
73   meijinsn_state(running_machine &machine) { }
74
75   /* memory pointers */
76   UINT16 *   shared_ram;
77   UINT16 *   videoram;
78
79   /* video-related */
80   tilemap_t  *bg_tilemap,*fg_tilemap;
81   UINT8    bg_bank;
82
83   /* misc */
84   UINT8 deposits1, deposits2, credits;
85   UINT8 coinvalue;
86   int mcu_latch;
87};
88
89
90
7191static WRITE16_HANDLER( sound_w )
7292{
73   if(ACCESSING_BITS_0_7)
74      soundlatch_w(space, 0, data&0xff);
93   if (ACCESSING_BITS_0_7)
94      soundlatch_w(space, 0, data & 0xff);
7595}
7696
7797static READ16_HANDLER( alpha_mcu_r )
7898{
79   static unsigned coinvalue=0;
80   static const UINT8 coinage1[2][2]={{1,1},{1,2}};
81   static const UINT8 coinage2[2][2]={{1,5},{2,1}};
99   meijinsn_state *state = (meijinsn_state *)space->machine->driver_data;
100   static const UINT8 coinage1[2][2] = {{1,1}, {1,2}};
101   static const UINT8 coinage2[2][2] = {{1,5}, {2,1}};
82102
83   static int latch;
84   int source=shared_ram[offset];
103   int source = state->shared_ram[offset];
85104
86105   switch (offset)
87106   {
88107      case 0: /* Dipswitch 2 */
89         shared_ram[0] = (source&0xff00)|input_port_read(space->machine, "DSW");
108         state->shared_ram[0] = (source & 0xff00) | input_port_read(space->machine, "DSW");
90109         return 0;
91110
92111      case 0x22: /* Coin value */
93         shared_ram[0x22] = (source&0xff00)|(credits&0x00ff);
112         state->shared_ram[0x22] = (source & 0xff00) | (state->credits & 0x00ff);
94113         return 0;
95114
96115      case 0x29: /* Query microcontroller for coin insert */
97116
98         credits=0;
117         state->credits = 0;
99118
100         if ((input_port_read(space->machine, "COINS")&0x3)==3) latch=0;
119         if ((input_port_read(space->machine, "COINS") & 0x3) == 3)
120            state->mcu_latch = 0;
101121
102         if ((input_port_read(space->machine, "COINS")&0x1)==0 && !latch)
122         if ((input_port_read(space->machine, "COINS") & 0x1) == 0 && !state->mcu_latch)
103123         {
104            shared_ram[0x29] = (source&0xff00)|(0x22);   // coinA
105            shared_ram[0x22] = (source&0xff00)|0x0;
106            latch=1;
124            state->shared_ram[0x29] = (source & 0xff00) | 0x22;   // coinA
125            state->shared_ram[0x22] = (source & 0xff00) | 0x00;
126            state->mcu_latch = 1;
107127
108            coinvalue = (~input_port_read(space->machine, "DSW")>>3) & 1;
128            state->coinvalue = (~input_port_read(space->machine, "DSW")>>3) & 1;
109129
110            deposits1++;
111            if (deposits1 == coinage1[coinvalue][0])
130            state->deposits1++;
131            if (state->deposits1 == coinage1[state->coinvalue][0])
112132            {
113               credits = coinage1[coinvalue][1];
114               deposits1 = 0;
133               state->credits = coinage1[state->coinvalue][1];
134               state->deposits1 = 0;
115135            }
116136            else
117               credits = 0;
137               state->credits = 0;
118138         }
119         else if ((input_port_read(space->machine, "COINS")&0x2)==0 && !latch)
139         else if ((input_port_read(space->machine, "COINS") & 0x2) == 0 && !state->mcu_latch)
120140         {
121            shared_ram[0x29] = (source&0xff00)|(0x22);   // coinA
122            shared_ram[0x22] = (source&0xff00)|0x0;
123            latch=1;
141            state->shared_ram[0x29] = (source & 0xff00) | 0x22;   // coinA
142            state->shared_ram[0x22] = (source & 0xff00) | 0x00;
143            state->mcu_latch = 1;
124144
125            coinvalue = (~input_port_read(space->machine, "DSW")>>3) & 1;
145            state->coinvalue = (~input_port_read(space->machine, "DSW") >> 3) & 1;
126146
127            deposits2++;
128            if (deposits2 == coinage2[coinvalue][0])
147            state->deposits2++;
148            if (state->deposits2 == coinage2[state->coinvalue][0])
129149            {
130               credits = coinage2[coinvalue][1];
131               deposits2 = 0;
150               state->credits = coinage2[state->coinvalue][1];
151               state->deposits2 = 0;
132152            }
133153            else
134               credits = 0;
154               state->credits = 0;
135155         }
136156         else
137157         {
138            shared_ram[0x29] = (source&0xff00)|0x22;
158            state->shared_ram[0x29] = (source & 0xff00) | 0x22;
139159         }
140160         return 0;
141161   }
r7500r7501
147167static ADDRESS_MAP_START( meijinsn_map, ADDRESS_SPACE_PROGRAM, 16 )
148168   AM_RANGE(0x000000, 0x03ffff) AM_ROM
149169   AM_RANGE(0x080e00, 0x080fff) AM_READ(alpha_mcu_r) AM_WRITENOP
150   AM_RANGE(0x100000, 0x107fff) AM_RAM AM_BASE_GENERIC(videoram)
170   AM_RANGE(0x100000, 0x107fff) AM_RAM AM_BASE_MEMBER(meijinsn_state, videoram)
151171   AM_RANGE(0x180000, 0x180dff) AM_RAM
152   AM_RANGE(0x180e00, 0x180fff) AM_RAM AM_BASE(&shared_ram)
172   AM_RANGE(0x180e00, 0x180fff) AM_RAM AM_BASE_MEMBER(meijinsn_state, shared_ram)
153173   AM_RANGE(0x181000, 0x181fff) AM_RAM
154174   AM_RANGE(0x1c0000, 0x1c0001) AM_READ_PORT("P2")
155175   AM_RANGE(0x1a0000, 0x1a0001) AM_READ_PORT("P1") AM_WRITE(sound_w)
r7500r7501
232252         3,   resistances_rg,   weights_g,   0,   1000+1000,
233253         2,   resistances_b,   weights_b,   0,   1000+1000);
234254
235   for (i = 0;i < machine->config->total_colors;i++)
255   for (i = 0; i < machine->config->total_colors; i++)
236256   {
237      int bit0,bit1,bit2,r,g,b;
257      int bit0, bit1, bit2, r, g, b;
238258
239259      /* red component */
240      bit0 = (color_prom[i] >> 0) & 0x01;
241      bit1 = (color_prom[i] >> 1) & 0x01;
242      bit2 = (color_prom[i] >> 2) & 0x01;
260      bit0 = BIT(color_prom[i], 0);
261      bit1 = BIT(color_prom[i], 1);
262      bit2 = BIT(color_prom[i], 2);
243263      r = combine_3_weights(weights_r, bit0, bit1, bit2);
244264
245265      /* green component */
246      bit0 = (color_prom[i] >> 3) & 0x01;
247      bit1 = (color_prom[i] >> 4) & 0x01;
248      bit2 = (color_prom[i] >> 5) & 0x01;
266      bit0 = BIT(color_prom[i], 3);
267      bit1 = BIT(color_prom[i], 4);
268      bit2 = BIT(color_prom[i], 5);
249269      g = combine_3_weights(weights_g, bit0, bit1, bit2);
250270
251271      /* blue component */
252      bit0 = (color_prom[i] >> 6) & 0x01;
253      bit1 = (color_prom[i] >> 7) & 0x01;
272      bit0 = BIT(color_prom[i], 6);
273      bit1 = BIT(color_prom[i], 7);
254274      b = combine_2_weights(weights_b, bit0, bit1);
255275
256      palette_set_color(machine,i,MAKE_RGB(r,g,b));
276      palette_set_color(machine, i, MAKE_RGB(r, g, b));
257277   }
258278}
259279
260280
261281static VIDEO_UPDATE(meijinsn)
262282{
283   meijinsn_state *state = (meijinsn_state *)screen->machine->driver_data;
263284   int offs;
264285
265   for (offs = 0;offs <0x4000; offs++)
286   for (offs = 0; offs < 0x4000; offs++)
266287   {
267288      int sx, sy, x, data1, data2, color, data;
268289
269290      sx = offs >> 8;
270291      sy = offs & 0xff;
271292
272      data1 = screen->machine->generic.videoram.u16[offs]>>8;
273      data2 = screen->machine->generic.videoram.u16[offs]&0xff;
293      data1 = state->videoram[offs] >> 8;
294      data2 = state->videoram[offs] & 0xff;
274295
275      for (x=0; x<4; x++)
296      for (x = 0; x < 4; x++)
276297      {
277         color= ((data1>>x) & 1) | (((data1>>(4+x)) & 1)<<1);
278         data = ((data2>>x) & 1) | (((data2>>(4+x)) & 1)<<1);
279         *BITMAP_ADDR16(bitmap, sy, (sx*4 + (3-x))) = color*4 + data;
298         color= BIT(data1, x) | (BIT(data1, x + 4) << 1);
299         data = BIT(data2, x) | (BIT(data2, x + 4) << 1);
300         *BITMAP_ADDR16(bitmap, sy, (sx * 4 + (3 - x))) = color * 4 + data;
280301      }
281302   }
282303   return 0;
r7500r7501
298319   DEVCB_MEMORY_HANDLER("audiocpu", PROGRAM, soundlatch_r)
299320};
300321
322static MACHINE_START( meijinsn )
323{
324   meijinsn_state *state = (meijinsn_state *)machine->driver_data;
325
326   state_save_register_global(machine, state->deposits1);
327   state_save_register_global(machine, state->deposits2);
328   state_save_register_global(machine, state->credits);
329}
330
301331static MACHINE_RESET( meijinsn )
302332{
303   deposits1 = 0;
304   deposits2 = 0;
305   credits   = 0;
333   meijinsn_state *state = (meijinsn_state *)machine->driver_data;
334
335   state->deposits1 = 0;
336   state->deposits2 = 0;
337   state->credits   = 0;
306338}
307339
308340
309341static MACHINE_DRIVER_START( meijinsn )
342
343   /* driver data */
344   MDRV_DRIVER_DATA(meijinsn_state)
345
346   /* basic machine hardware */
310347   MDRV_CPU_ADD("maincpu", M68000, 9000000 )
311348   MDRV_CPU_PROGRAM_MAP(meijinsn_map)
312349   MDRV_CPU_VBLANK_INT_HACK(meijinsn_interrupt,2)
r7500r7501
316353   MDRV_CPU_IO_MAP(meijinsn_sound_io_map)
317354   MDRV_CPU_VBLANK_INT_HACK(irq0_line_hold, 160)
318355
356   MDRV_MACHINE_START(meijinsn)
319357   MDRV_MACHINE_RESET(meijinsn)
320358
321359   /* video hardware */
r7500r7501
369407   ROM_LOAD( "clr", 0x00, 0x20, CRC(7b95b5a7) SHA1(c15be28bcd6f5ffdde659f2d352ae409f04b2557) )
370408ROM_END
371409
372GAME( 1986, meijinsn, 0, meijinsn, meijinsn, 0, ROT0, "SNK Electronics corp.", "Meijinsen", 0 )
410GAME( 1986, meijinsn, 0, meijinsn, meijinsn, 0, ROT0, "SNK Electronics corp.", "Meijinsen", GAME_SUPPORTS_SAVE )
src/mame/drivers/nitedrvr.c
r7500r7501
4444
4545static ADDRESS_MAP_START( nitedrvr_map, ADDRESS_SPACE_PROGRAM, 8 )
4646   AM_RANGE(0x0000, 0x00ff) AM_RAM AM_MIRROR(0x100) // SCRAM
47   AM_RANGE(0x0200, 0x027f) AM_RAM_WRITE(nitedrvr_videoram_w) AM_MIRROR(0x180) AM_BASE_GENERIC(videoram) // PFW
48   AM_RANGE(0x0400, 0x05ff) AM_WRITE(nitedrvr_hvc_w) AM_BASE(&nitedrvr_hvc) // POSH, POSV, CHAR, Watchdog
47   AM_RANGE(0x0200, 0x027f) AM_RAM_WRITE(nitedrvr_videoram_w) AM_MIRROR(0x180) AM_BASE_MEMBER(nitedrvr_state, videoram) // PFW
48   AM_RANGE(0x0400, 0x05ff) AM_WRITE(nitedrvr_hvc_w) AM_BASE_MEMBER(nitedrvr_state, hvc) // POSH, POSV, CHAR, Watchdog
4949   AM_RANGE(0x0600, 0x07ff) AM_READ(nitedrvr_in0_r)
5050   AM_RANGE(0x0800, 0x09ff) AM_READ(nitedrvr_in1_r)
5151   AM_RANGE(0x0a00, 0x0bff) AM_WRITE(nitedrvr_out0_w)
5252   AM_RANGE(0x0c00, 0x0dff) AM_WRITE(nitedrvr_out1_w)
53   AM_RANGE(0x8000, 0x807f) AM_RAM AM_MIRROR(0x380) AM_BASE_GENERIC(videoram) // PFR
53   AM_RANGE(0x8000, 0x807f) AM_RAM AM_MIRROR(0x380) AM_BASE_MEMBER(nitedrvr_state, videoram) // PFR
5454   AM_RANGE(0x8400, 0x87ff) AM_READWRITE(nitedrvr_steering_reset_r, nitedrvr_steering_reset_w)
5555   AM_RANGE(0x9000, 0x9fff) AM_ROM // ROM1-ROM2
5656   AM_RANGE(0xfff0, 0xffff) AM_ROM // ROM2 for 6502 vectors
r7500r7501
135135/* Machine Driver */
136136
137137static MACHINE_DRIVER_START( nitedrvr )
138   // basic machine hardware
138
139   /* driver data */
140   MDRV_DRIVER_DATA(nitedrvr_state)
141
142   /* basic machine hardware */
139143   MDRV_CPU_ADD("maincpu", M6502, XTAL_12_096MHz/12) // 1 MHz
140144   MDRV_CPU_PROGRAM_MAP(nitedrvr_map)
141145   MDRV_CPU_VBLANK_INT("screen", irq0_line_hold)
r7500r7501
146150
147151   MDRV_TIMER_ADD_PERIODIC("crash_timer", nitedrvr_crash_toggle_callback, NSEC(PERIOD_OF_555_ASTABLE_NSEC(RES_K(180), 330, CAP_U(1))))
148152
149   // video hardware
150
153   /* video hardware */
151154   MDRV_SCREEN_ADD("screen", RASTER)
152155   MDRV_SCREEN_REFRESH_RATE(57) // how is this derived?
153156   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(2500) /* not accurate */)
r7500r7501
162165   MDRV_VIDEO_START(nitedrvr)
163166   MDRV_VIDEO_UPDATE(nitedrvr)
164167
165   // sound hardware
168   /* sound hardware */
166169   MDRV_SPEAKER_STANDARD_MONO("mono")
167170
168171   MDRV_SOUND_ADD("discrete", DISCRETE, 0)
r7500r7501
201204
202205/* Game Drivers */
203206
204GAME( 1976, nitedrvr, 0, nitedrvr, nitedrvr, 0, ROT0, "Atari", "Night Driver", GAME_IMPERFECT_SOUND | GAME_SUPPORTS_SAVE)
207GAME( 1976, nitedrvr, 0, nitedrvr, nitedrvr, 0, ROT0, "Atari", "Night Driver", GAME_IMPERFECT_SOUND | GAME_SUPPORTS_SAVE )
src/mame/drivers/sfbonus.c
r7500r7501
4646Older versions are named as: parent + 'o' + progressive number
4747In a couple of cases, due to too many older revisions, I used: parent + version + 'o' + progr. num.
4848
49
50------------------------------------------------------------
51
52There is known to be a "Classic Edition Compact Format" PCB
53
54ROM1 (program rom) and ROM2 (sound sample) are stadard 32 pin
55style PROMs.  The graphics are stored in ROM3 & ROM4 which
56appear to be surface mounted 8 Mbit roms.
57
58------------------------------------------------------------
59
60Model No. S2000-B
61+---------+   +-------------+   +--------------------+
62|         +---+  Connector  +---+                    |
63|   386D VR1          +---+ +---+ +---+ +---+        |
64|            +---+    | R | | R | | R | | R |   U    |
65+-+          | R |    | O | | O | | O | | O |   2    |
66  |          | O |    | M | | M | | M | | M |   1    |
67+-+          | M |    | 3 | | 4 | | 5 | | 6 |        |
68|            | 2 |    |   | |   | |   | |   |        |
69|            |   |    +---+ +---+ +---+ +---+   U    |
70|8 ULN2003A  +---+                              1    |
71|                                               5    |
72|L ULN2003A   +----+    +----------+                 |
73|i            |6295|    |          |   MH61C256AH-15 |
74|n            +----+    |  AMCOE   |                 |
75|e                      |  SGC2000 |                 |
76|r          +------+    |          |     25MHz       |
77|           |      |    +----------+     75176    CN2|
78|C          | 9536 |                              CN1|
79|o          |      |    12MHz      4.9152MHz         |
80|n          +------+                               +-+
81|n               +---+  +---+  +---+               |P|
82|e               | 8 |  | R |  | 5 |               |r|
83|c               | 6 |  | O |  | 1 |             S |i|
84|t               | 1 |  | M |  | 8 |             W |n|
85|o               | 7 |  | 1 |  | 6 |             6 |t|
86|r               | 1 |  |   |  | 4 |               |e|
87|                +---+  +---+  +---+               |r|
88+-+      S   S   S   S   S        B     R          +-+
89  |      W   W   W   W   W        A     S            |
90+-+      1   2   3   4   5        T     T            |
91+---------------------------------------------------+
92
93     CPU: Amcoe SGC2000 208PQFP (Z80 core)
94Graphics: HM86171
95     OSC: 25.000MHz, 12.000MHz & 4.9152MHz
96   Sound: OKI M6295
97   Other: XILINX XC9536XL (socketted)
98
99HM86171-120 - HMC 28 pin DIP Color Pallete RAMDAC
100   ULN2003A - 16 pin DIP Seven Darlington Arrays
101      51864 - V62C51864L-35P 64Kb SRAM
102      75176 - SN75176BP Differential BUS Transceiver (Bidirectional data communication on multipoint bus transmission line)
103       386D - JRC 386D low voltage AMP
104        VR1 - Sound adjust pot
105
106BAT - 3.6v battery
107RST - Reset switch (to clear ram?)
108
109CN1 & CN2 are 4 pin link connectors
110
111U15 & U21 are unpopulated 32 pin DIP ROM sockets
112SW1 - SW4 are unpopulated
113
114------------------------------------------------------------
115
116Model No. S2000C SALTIRE
117  +-------+   +-------------+   +---+----++----+-----+
118  |       +---+  Connector  +---+   |CN2 ||CN1 |75176|
119  |      VR1                        +----++----+     |
120  | 386D +----------+   +----------+                 |
121  |      |   ROM2   |   |   ROM4   |   +----------+  |
122  |      +----------+   +----------+   |   ROM5   |  |
123+-+          +----+     +----------+   +----------+  |
124|            |6295|     |   ROM3   |   +----------+  |
125|            +----+     +----------+   |   ROM6   |  |
126|8 ULN2003A                            +----------+  |
127|            +------+                                |
128|L ULN2003A  |      |                                |
129|i           | 9536 |   +----------+   IC61C256AH-12 |
130|n           |      |   |          |                 |
131|e           +------+   |  AMCOE   |                 |
132|r                      |  SALTIRE |                 |
133|                       |          |                 |
134|C                      +----------+        25MHz SW1|
135|o                                                   |
136|n                                                 +-+
137|n                      12MHz      4.9152MHz       |P|
138|e                                                 |r|
139|c                      +----------+               |i|
140|t  +---------+         |   ROM1   |               |n|
141|o  | HM86171 |         +----------+           SW4 |t|
142|r  +---------+                                    |e|
143|                       FM1608-120             SW5 |r|
144|            +-------+                             +-+
145+-+          |  VGA  |           H3                  |
146  +----------+-------+-------------------------------+
147
148Basicly the same as the VCG-1 SALTIRE below, but the
149XILINX chip is socketted and no H1 or H2 connector.
150
151------------------------------------------------------------
152
153Starting in 2005 with Money Machine and later
154
155Model No. VCG-1 SALTIRE
156  +-------+   +-------------+   +---+----++----+-----+
157  |       +---+  Connector  +---+   |CN2 ||CN1 |75176|
158  |      VR1                        +----++----+     |
159  | 386D +----------+   +----------+                 |
160  |      |   ROM2   |   |   ROM4   |   +----------+  |
161  |      +----------+   +----------+   |   ROM5   |  |
162+-+          +----+     +----------+   +----------+  |
163|            |6295|     |   ROM3   |   +----------+  |
164|            +----+     +----------+   |   ROM6   |  |
165|8 ULN2003A                            +----------+  |
166|            +----+                                  |
167|L ULN2003A  |9536|                                  |
168|i           +----+     +----------+   IC61C256AH-12 |
169|n                      |          |                 |
170|e            H2        |  AMCOE   |                 |
171|r                      |  SALTIRE |                 |
172|                       |          |                 |
173|C                      +----------+   H1   25MHz SW1|
174|o                                                   |
175|n                                                 +-+
176|n                      12MHz      4.9152MHz       |P|
177|e                                                 |r|
178|c                      +----------+               |i|
179|t  +---------+         |   ROM1   |           SW4 |n|
180|o  | HM86171 |         +----------+               |t|
181|r  +---------+                                    |e|
182|                       FM1608-120                 |r|
183|            +-------+                         SW5 +-+
184+-+          |  VGA  |           H3                  |
185  +----------+-------+-------------------------------+
186
187     CPU: Amcoe Saltire 208PQFP (Z80 core)
188Graphics: HM86171
189     OSC: 25.000MHz, 12.000MHz & 4.9152MHz
190   Sound: OKI M6295
191   Other: XILINX XC9536XL (used for programable protection, connected to H2)
192
193HM86171-120 - HMC 28 pin DIP Color Pallete RAMDAC
194 FM1608-120 - RAMTRON 64Kb bytewide Ferroelectric Nonvolatile RAM
195   ULN2003A - 16 pin DIP Seven Darlington Arrays
196      75176 - SN75176BP Differential BUS Transceiver (Bidirectional data communication on multipoint bus transmission line)
197       386D - JRC 386D low voltage AMP
198        VR1 - Sound adjust pot
199
200H1 - 3 pin Jumper (Pins 1+2 is CGA, pins 2+3 is XVGA)
201H2 - 6 pin header used to program the XC9536XL (JTAG?)
202H3 - 20 pin dual row connector
203
204CN1 & CN2 are RJ45 LINK connectors
205
206ROMs 1 & 3-6 are AMIC 29040B
207ROM  2 is a AMIC 290021T
208
209--------------------------------------------------------------------
210
211MH86171 Color Pallete RAMDAC
212 Hardware & software compatible with VGA, MCGA & 8514/A graphics
213 Compatible with the RS170 video stadard
214 Single monolithic, high performance CMOS
215 Pixel rates up to 50MHz
216 256K possible colors
217 Pixel word mask
218 Up to 8 bits per pixel
219 RGB analogue output, 6 bit DAC per gun, composite blank
220 Triple six-bit video DAC
221 256 x 18 bit high speed SRAM
222
49223*/
50224
225
51226#include "emu.h"
52227#include "cpu/z80/z80.h"
53228#include "sound/okim6295.h"
r7500r7501
35253700   ROM_LOAD_OPTIONAL( "fb415e.id", 0x00, 0x20, CRC(f1663488) SHA1(93ba94df442d90790cb0eafb6e5db0506ffa8bc5))
35263701ROM_END
35273702
3528
3529/*
3530
3531Action 2000 by AMCOE
3532
3533
3534Graphics - HM86171-80 ? 28DIP
3535Processor - Amcoe Saltire ? 208PQFP
3536
3537QUARTZ OSCILLATORS 12.000, 4.9152 and 27.000
3538
3539RAM
3540
3541HM6264ALP-15 - 28DIP
3542UN61256FK-15 - 28DIP
3543
3544Unknown
3545
3546Chip Markings removed 44Pin PLCC
3547
3548Roms
3549
3550a2k1-1.2.u28 - F29C51001T
3551a2k-2.u11 - F29C51002T
3552a2k-3.u9 - F29C51004T
3553a2k-4.u8 - F29C51004T
3554a2k-5.u6 - F29C51004T
3555a2k-6.u4 - F29C51004T
3556
3557Dumped by Dang_Spot 08/12/04
3558*/
3703/* Action 2000 */
35593704ROM_START( act2000 )
35603705   ROM_REGION( 0x80000, "maincpu", 0 ) /* Z80 Code */
35613706   ROM_LOAD( "a2v35e.bin", 0x00000, 0x40000, CRC(dfe5c8b5) SHA1(09ac6df25395d0a5c632c05ba93bf784b69319a0) )
r7500r7501
46104755   ROM_LOAD_OPTIONAL( "mm17lt.id", 0x00, 0x20,  CRC(b6b08ea0) SHA1(a56c7648424ca4dd0d405059f07af6f7cee0111a) )
46114756ROM_END
46124757
4613/* Around The World */
4614ROM_START( atworld )
4615   ROM_REGION( 0x80000, "maincpu", 0 ) /* Z80 Code */
4616   ROM_LOAD( "awd13e.bin", 0x00000, 0x80000, CRC(ec46b48d) SHA1(bfae55520bb36a6dfb55e12b115e818d9cd060e7) )
4617
4618   ROM_REGION( 0x040000, "oki", ROMREGION_ERASE00 ) /* Samples */
4619   ROM_LOAD( "aw_rom2.bin", 0x00000, 0x40000, CRC(aff26a52) SHA1(176fb42d735a85cdc3b74d6dde76fea9115bf36d) )
4620
4621   ROM_REGION( 0x100000, "gfx1", 0 )
4622   ROM_LOAD16_BYTE( "aw_rom3.bin", 0x00000, 0x80000, CRC(36db794a) SHA1(a5cb32fc401faf52e221f0a4d8bbfae819e7d08b) )
4623   ROM_LOAD16_BYTE( "aw_rom4.bin", 0x00001, 0x80000, CRC(3927d187) SHA1(4d6e509ec6cc33e6985142894bbce547e1ee9f4f) )
4624
4625   ROM_REGION( 0x100000, "gfx2", 0 )
4626   ROM_LOAD16_BYTE( "aw_rom5.bin", 0x00000, 0x80000, CRC(c461c4d5) SHA1(2815511f8ae9b74c44aa9987eebf1a14642b4458) )
4627   ROM_LOAD16_BYTE( "aw_rom6.bin", 0x00001, 0x80000, CRC(686c9f2d) SHA1(94da22c775292020aa00c8f12f833a7f5c70ec36) )
4628
4629   ROM_REGION( 0x1000, "defaults", 0 ) /* default settings */
4630   ROM_LOAD_OPTIONAL( "aw13ex.id", 0x00, 0x1000, CRC(c26305c9) SHA1(ee3aea8926ee4890d45896cf0be175c2262c7341) )
4631ROM_END
4632
4633ROM_START( atworldd1 )
4634   ROM_REGION( 0x80000, "maincpu", 0 ) /* Z80 Code */
4635   ROM_LOAD( "awd13r.bin", 0x00000, 0x80000, CRC(786079a8) SHA1(862abc511c5ac0d667c6b9abd914ce6035e9aed9) )
4636
4637   ROM_REGION( 0x040000, "oki", ROMREGION_ERASE00 ) /* Samples */
4638   ROM_LOAD( "aw_rom2.bin", 0x00000, 0x40000, CRC(aff26a52) SHA1(176fb42d735a85cdc3b74d6dde76fea9115bf36d) )
4639
4640   ROM_REGION( 0x100000, "gfx1", 0 )
4641   ROM_LOAD16_BYTE( "aw_rom3.bin", 0x00000, 0x80000, CRC(36db794a) SHA1(a5cb32fc401faf52e221f0a4d8bbfae819e7d08b) )
4642   ROM_LOAD16_BYTE( "aw_rom4.bin", 0x00001, 0x80000, CRC(3927d187) SHA1(4d6e509ec6cc33e6985142894bbce547e1ee9f4f) )
4643
4644   ROM_REGION( 0x100000, "gfx2", 0 )
4645   ROM_LOAD16_BYTE( "aw_rom5.bin", 0x00000, 0x80000, CRC(c461c4d5) SHA1(2815511f8ae9b74c44aa9987eebf1a14642b4458) )
4646   ROM_LOAD16_BYTE( "aw_rom6.bin", 0x00001, 0x80000, CRC(686c9f2d) SHA1(94da22c775292020aa00c8f12f833a7f5c70ec36) )
4647
4648   ROM_REGION( 0x1000, "defaults", 0 ) /* default settings */
4649   ROM_LOAD_OPTIONAL( "aw13re.id", 0x00, 0x1000,  CRC(0f9991fb) SHA1(5ea9e49c6b8b00c2c3638cc39e479d6e5e112b7a) )
4650ROM_END
4651
46524758// incomplete / mixed sets etc. sort these first before doing anything else with them
46534759/* Fruit Bonus 2005 */
46544760ROM_START( fb5 )
r7500r7501
50015107   ROM_LOAD_OPTIONAL( "fb6se14lt.id", 0x00, 0x20, CRC(8d72c5a4) SHA1(51d874c14f4fcb5e0f72cbc0bef053170bdc5ee5) )
50025108ROM_END
50035109
5004/* Not working sets (due to incomplete dumps) */
5005ROM_START( version4 )
5110/* Bugs Fever */
5111ROM_START( bugfever )
50065112   ROM_REGION( 0x80000, "maincpu", 0 ) /* Z80 Code */
5007   ROM_LOAD( "96d42r.bin", 0x00000, 0x40000, CRC(dab5706c) SHA1(9fc37b66942a5e7535b4590f132727d793f9d705) )
5113   ROM_LOAD( "bfd17r.bin", 0x00000, 0x80000, CRC(6fc33307) SHA1(fdb10bd3e463cac2f9050d2d37fdfba9ccee91dc) )
50085114
50095115   ROM_REGION( 0x040000, "oki", ROMREGION_ERASE00 ) /* Samples */
5010   ROM_LOAD( "96rom2.bin", 0x00000, 0x40000, NO_DUMP )
5116   ROM_LOAD( "bfrom2.bin", 0x00000, 0x40000, CRC(d0e7ee66) SHA1(3dd08bbe31b8170df5206be454db4993dd186a16) )
50115117
50125118   ROM_REGION( 0x100000, "gfx1", 0 )
5013   ROM_LOAD16_BYTE( "96rom3.bin", 0x00000, 0x40000, NO_DUMP )
5014   ROM_LOAD16_BYTE( "96rom4.bin", 0x00001, 0x40000, NO_DUMP)
5119   ROM_LOAD16_BYTE( "bfrom3.bin", 0x00000, 0x80000, CRC(c571591e) SHA1(3233cc9a0f094911f89a0a0d56a28c24d1502e63) )
5120   ROM_LOAD16_BYTE( "bfrom4.bin", 0x00001, 0x80000, CRC(ed7080a5) SHA1(d198019788f5fd70680296a9c2bab17a27589998) )
50155121
50165122   ROM_REGION( 0x100000, "gfx2", 0 )
5017   ROM_LOAD16_BYTE( "96rom5.bin", 0x00000, 0x40000, NO_DUMP )
5018   ROM_LOAD16_BYTE( "96rom6.bin", 0x00001, 0x40000, NO_DUMP )
5123   ROM_LOAD16_BYTE( "bfrom5.bin", 0x00000, 0x80000, CRC(a2697da1) SHA1(2a3b03c7d02225ae8ce98b65face6554c37172d5) )
5124   ROM_LOAD16_BYTE( "bfrom6.bin", 0x00001, 0x80000, CRC(28d6810b) SHA1(f446710b34db5bec97f81af0ca83e6b4f1a5ec46) )
50195125
50205126   ROM_REGION( 0x20, "defaults", 0 ) /* default settings */
5021   ROM_LOAD_OPTIONAL( "fcs40r1.id", 0x00, 0x20, CRC(b3638cdb) SHA1(283824c57f3f62f6e2b505f6e13b100a7d7f33af) )
5127   ROM_LOAD_OPTIONAL( "bf17re.id", 0x00, 0x20, CRC(a482948d) SHA1(62b802e4906ebb00b2584bb0562a64e9a30aa6ed) )
50225128ROM_END
50235129
5024ROM_START( bugfever )
5130ROM_START( bugfevero )
50255131   ROM_REGION( 0x80000, "maincpu", 0 ) /* Z80 Code */
5026   ROM_LOAD( "bfd17r.bin", 0x00000, 0x80000, CRC(6fc33307) SHA1(fdb10bd3e463cac2f9050d2d37fdfba9ccee91dc) )
5132   ROM_LOAD( "bfd16r.bin", 0x00000, 0x80000, CRC(3ef176c7) SHA1(d1886ebe89fffd14b93f594ed494084094aa3f49) )
50275133
50285134   ROM_REGION( 0x040000, "oki", ROMREGION_ERASE00 ) /* Samples */
5029   ROM_LOAD( "bfrom2.bin", 0x00000, 0x40000, NO_DUMP )
5135   ROM_LOAD( "bfrom2.bin", 0x00000, 0x40000, CRC(d0e7ee66) SHA1(3dd08bbe31b8170df5206be454db4993dd186a16) )
50305136
50315137   ROM_REGION( 0x100000, "gfx1", 0 )
5032   ROM_LOAD16_BYTE( "bfrom3.bin", 0x00000, 0x80000, NO_DUMP )
5033   ROM_LOAD16_BYTE( "bfrom4.bin", 0x00001, 0x80000, NO_DUMP )
5138   ROM_LOAD16_BYTE( "bfrom3.bin", 0x00000, 0x80000, CRC(c571591e) SHA1(3233cc9a0f094911f89a0a0d56a28c24d1502e63) )
5139   ROM_LOAD16_BYTE( "bfrom4.bin", 0x00001, 0x80000, CRC(ed7080a5) SHA1(d198019788f5fd70680296a9c2bab17a27589998) )
50345140
50355141   ROM_REGION( 0x100000, "gfx2", 0 )
5036   ROM_LOAD16_BYTE( "bfrom5.bin", 0x00000, 0x80000, NO_DUMP )
5037   ROM_LOAD16_BYTE( "bfrom6.bin", 0x00001, 0x80000, NO_DUMP )
5142   ROM_LOAD16_BYTE( "bfrom5.bin", 0x00000, 0x80000, CRC(a2697da1) SHA1(2a3b03c7d02225ae8ce98b65face6554c37172d5) )
5143   ROM_LOAD16_BYTE( "bfrom6.bin", 0x00001, 0x80000, CRC(28d6810b) SHA1(f446710b34db5bec97f81af0ca83e6b4f1a5ec46) )
50385144
50395145   ROM_REGION( 0x20, "defaults", 0 ) /* default settings */
5040   ROM_LOAD_OPTIONAL( "bf17re.id", 0x00, 0x20, CRC(a482948d) SHA1(62b802e4906ebb00b2584bb0562a64e9a30aa6ed) )
5146   ROM_LOAD_OPTIONAL( "bf16re.id", 0x00, 0x20, CRC(b3f980ce) SHA1(005f45ddae959f1f985789e4015e3ec8801e99ee) )
50415147ROM_END
50425148
50435149ROM_START( bugfeverd )
r7500r7501
50455151   ROM_LOAD( "bfd17e.bin", 0x00000, 0x80000, CRC(35324195) SHA1(ad290912556f4ddbc33667b3bce5d05f321870d0) )
50465152
50475153   ROM_REGION( 0x040000, "oki", ROMREGION_ERASE00 ) /* Samples */
5048   ROM_LOAD( "bfrom2.bin", 0x00000, 0x40000, NO_DUMP )
5154   ROM_LOAD( "bfrom2.bin", 0x00000, 0x40000, CRC(d0e7ee66) SHA1(3dd08bbe31b8170df5206be454db4993dd186a16) )
50495155
50505156   ROM_REGION( 0x100000, "gfx1", 0 )
5051   ROM_LOAD16_BYTE( "bfrom3.bin", 0x00000, 0x80000, NO_DUMP )
5052   ROM_LOAD16_BYTE( "bfrom4.bin", 0x00001, 0x80000, NO_DUMP )
5157   ROM_LOAD16_BYTE( "bfrom3.bin", 0x00000, 0x80000, CRC(c571591e) SHA1(3233cc9a0f094911f89a0a0d56a28c24d1502e63) )
5158   ROM_LOAD16_BYTE( "bfrom4.bin", 0x00001, 0x80000, CRC(ed7080a5) SHA1(d198019788f5fd70680296a9c2bab17a27589998) )
50535159
50545160   ROM_REGION( 0x100000, "gfx2", 0 )
5055   ROM_LOAD16_BYTE( "bfrom5.bin", 0x00000, 0x80000, NO_DUMP )
5056   ROM_LOAD16_BYTE( "bfrom6.bin", 0x00001, 0x80000, NO_DUMP )
5161   ROM_LOAD16_BYTE( "bfrom5.bin", 0x00000, 0x80000, CRC(a2697da1) SHA1(2a3b03c7d02225ae8ce98b65face6554c37172d5) )
5162   ROM_LOAD16_BYTE( "bfrom6.bin", 0x00001, 0x80000, CRC(28d6810b) SHA1(f446710b34db5bec97f81af0ca83e6b4f1a5ec46) )
50575163
50585164   ROM_REGION( 0x20, "defaults", 0 ) /* default settings */
50595165   ROM_LOAD_OPTIONAL( "bf17ex.id", 0x00, 0x20, CRC(38bd8ec4) SHA1(4e6b85348f2fa821934f7666f77ba0f016e200ec) )
r7500r7501
50645170   ROM_LOAD( "bfv17r.bin", 0x00000, 0x80000, CRC(8b6ee6f5) SHA1(981d60f04ab44ce8fc63019ac3e5b689aa80baf0) )
50655171
50665172   ROM_REGION( 0x040000, "oki", ROMREGION_ERASE00 ) /* Samples */
5067   ROM_LOAD( "bfrom2.bin", 0x00000, 0x40000, NO_DUMP )
5173   ROM_LOAD( "bfrom2.bin", 0x00000, 0x40000, CRC(d0e7ee66) SHA1(3dd08bbe31b8170df5206be454db4993dd186a16) )
50685174
50695175   ROM_REGION( 0x100000, "gfx1", 0 )
5070   ROM_LOAD16_BYTE( "bfrom3.bin", 0x00000, 0x80000, NO_DUMP )
5071   ROM_LOAD16_BYTE( "bfrom4.bin", 0x00001, 0x80000, NO_DUMP )
5176   ROM_LOAD16_BYTE( "bfrom3.bin", 0x00000, 0x80000, CRC(c571591e) SHA1(3233cc9a0f094911f89a0a0d56a28c24d1502e63) )
5177   ROM_LOAD16_BYTE( "bfrom4.bin", 0x00001, 0x80000, CRC(ed7080a5) SHA1(d198019788f5fd70680296a9c2bab17a27589998) )
50725178
50735179   ROM_REGION( 0x100000, "gfx2", 0 )
5074   ROM_LOAD16_BYTE( "bfrom5.bin", 0x00000, 0x80000, NO_DUMP )
5075   ROM_LOAD16_BYTE( "bfrom6.bin", 0x00001, 0x80000, NO_DUMP )
5180   ROM_LOAD16_BYTE( "bfrom5.bin", 0x00000, 0x80000, CRC(a2697da1) SHA1(2a3b03c7d02225ae8ce98b65face6554c37172d5) )
5181   ROM_LOAD16_BYTE( "bfrom6.bin", 0x00001, 0x80000, CRC(28d6810b) SHA1(f446710b34db5bec97f81af0ca83e6b4f1a5ec46) )
50765182
50775183   ROM_REGION( 0x20, "defaults", 0 ) /* default settings */
50785184   ROM_LOAD_OPTIONAL( "bf17re.id", 0x00, 0x20, CRC(a482948d) SHA1(62b802e4906ebb00b2584bb0562a64e9a30aa6ed) )
r7500r7501
50835189   ROM_LOAD( "bfv17e.bin", 0x00000, 0x80000, CRC(b9afd39a) SHA1(d331551f679b8694bf63812e5e1a54361c87c52a) )
50845190
50855191   ROM_REGION( 0x040000, "oki", ROMREGION_ERASE00 ) /* Samples */
5086   ROM_LOAD( "bfrom2.bin", 0x00000, 0x40000, NO_DUMP )
5192   ROM_LOAD( "bfrom2.bin", 0x00000, 0x40000, CRC(d0e7ee66) SHA1(3dd08bbe31b8170df5206be454db4993dd186a16) )
50875193
50885194   ROM_REGION( 0x100000, "gfx1", 0 )
5089   ROM_LOAD16_BYTE( "bfrom3.bin", 0x00000, 0x80000, NO_DUMP )
5090   ROM_LOAD16_BYTE( "bfrom4.bin", 0x00001, 0x80000, NO_DUMP )
5195   ROM_LOAD16_BYTE( "bfrom3.bin", 0x00000, 0x80000, CRC(c571591e) SHA1(3233cc9a0f094911f89a0a0d56a28c24d1502e63) )
5196   ROM_LOAD16_BYTE( "bfrom4.bin", 0x00001, 0x80000, CRC(ed7080a5) SHA1(d198019788f5fd70680296a9c2bab17a27589998) )
50915197
50925198   ROM_REGION( 0x100000, "gfx2", 0 )
5093   ROM_LOAD16_BYTE( "bfrom5.bin", 0x00000, 0x80000, NO_DUMP )
5094   ROM_LOAD16_BYTE( "bfrom6.bin", 0x00001, 0x80000, NO_DUMP )
5199   ROM_LOAD16_BYTE( "bfrom5.bin", 0x00000, 0x80000, CRC(a2697da1) SHA1(2a3b03c7d02225ae8ce98b65face6554c37172d5) )
5200   ROM_LOAD16_BYTE( "bfrom6.bin", 0x00001, 0x80000, CRC(28d6810b) SHA1(f446710b34db5bec97f81af0ca83e6b4f1a5ec46) )
50955201
50965202   ROM_REGION( 0x20, "defaults", 0 ) /* default settings */
50975203   ROM_LOAD_OPTIONAL( "bf17ex.id", 0x00, 0x20, CRC(38bd8ec4) SHA1(4e6b85348f2fa821934f7666f77ba0f016e200ec) )
50985204ROM_END
50995205
5206/* Around The World */
5207ROM_START( atworld )
5208   ROM_REGION( 0x80000, "maincpu", 0 ) /* Z80 Code */
5209   ROM_LOAD( "awd13e.bin", 0x00000, 0x80000, CRC(ec46b48d) SHA1(bfae55520bb36a6dfb55e12b115e818d9cd060e7) )
5210
5211   ROM_REGION( 0x040000, "oki", ROMREGION_ERASE00 ) /* Samples */
5212   ROM_LOAD( "aw_rom2.bin", 0x00000, 0x40000, CRC(aff26a52) SHA1(176fb42d735a85cdc3b74d6dde76fea9115bf36d) )
5213
5214   ROM_REGION( 0x100000, "gfx1", 0 )
5215   ROM_LOAD16_BYTE( "aw_rom3.bin", 0x00000, 0x80000, CRC(36db794a) SHA1(a5cb32fc401faf52e221f0a4d8bbfae819e7d08b) )
5216   ROM_LOAD16_BYTE( "aw_rom4.bin", 0x00001, 0x80000, CRC(3927d187) SHA1(4d6e509ec6cc33e6985142894bbce547e1ee9f4f) )
5217
5218   ROM_REGION( 0x100000, "gfx2", 0 )
5219   ROM_LOAD16_BYTE( "aw_rom5.bin", 0x00000, 0x80000, CRC(c461c4d5) SHA1(2815511f8ae9b74c44aa9987eebf1a14642b4458) )
5220   ROM_LOAD16_BYTE( "aw_rom6.bin", 0x00001, 0x80000, CRC(686c9f2d) SHA1(94da22c775292020aa00c8f12f833a7f5c70ec36) )
5221
5222   ROM_REGION( 0x1000, "defaults", 0 ) /* default settings */
5223   ROM_LOAD_OPTIONAL( "aw13ex.id", 0x00, 0x1000, CRC(c26305c9) SHA1(ee3aea8926ee4890d45896cf0be175c2262c7341) )
5224ROM_END
5225
5226ROM_START( atworldd1 )
5227   ROM_REGION( 0x80000, "maincpu", 0 ) /* Z80 Code */
5228   ROM_LOAD( "awd13r.bin", 0x00000, 0x80000, CRC(786079a8) SHA1(862abc511c5ac0d667c6b9abd914ce6035e9aed9) )
5229
5230   ROM_REGION( 0x040000, "oki", ROMREGION_ERASE00 ) /* Samples */
5231   ROM_LOAD( "aw_rom2.bin", 0x00000, 0x40000, CRC(aff26a52) SHA1(176fb42d735a85cdc3b74d6dde76fea9115bf36d) )
5232
5233   ROM_REGION( 0x100000, "gfx1", 0 )
5234   ROM_LOAD16_BYTE( "aw_rom3.bin", 0x00000, 0x80000, CRC(36db794a) SHA1(a5cb32fc401faf52e221f0a4d8bbfae819e7d08b) )
5235   ROM_LOAD16_BYTE( "aw_rom4.bin", 0x00001, 0x80000, CRC(3927d187) SHA1(4d6e509ec6cc33e6985142894bbce547e1ee9f4f) )
5236
5237   ROM_REGION( 0x100000, "gfx2", 0 )
5238   ROM_LOAD16_BYTE( "aw_rom5.bin", 0x00000, 0x80000, CRC(c461c4d5) SHA1(2815511f8ae9b74c44aa9987eebf1a14642b4458) )
5239   ROM_LOAD16_BYTE( "aw_rom6.bin", 0x00001, 0x80000, CRC(686c9f2d) SHA1(94da22c775292020aa00c8f12f833a7f5c70ec36) )
5240
5241   ROM_REGION( 0x1000, "defaults", 0 ) /* default settings */
5242   ROM_LOAD_OPTIONAL( "aw13re.id", 0x00, 0x1000,  CRC(0f9991fb) SHA1(5ea9e49c6b8b00c2c3638cc39e479d6e5e112b7a) )
5243ROM_END
5244
5245/* Not working sets (due to incomplete dumps) */
5246ROM_START( version4 )
5247   ROM_REGION( 0x80000, "maincpu", 0 ) /* Z80 Code */
5248   ROM_LOAD( "96d42r.bin", 0x00000, 0x40000, CRC(dab5706c) SHA1(9fc37b66942a5e7535b4590f132727d793f9d705) )
5249
5250   ROM_REGION( 0x040000, "oki", ROMREGION_ERASE00 ) /* Samples */
5251   ROM_LOAD( "96rom2.bin", 0x00000, 0x40000, NO_DUMP )
5252
5253   ROM_REGION( 0x100000, "gfx1", 0 )
5254   ROM_LOAD16_BYTE( "96rom3.bin", 0x00000, 0x40000, NO_DUMP )
5255   ROM_LOAD16_BYTE( "96rom4.bin", 0x00001, 0x40000, NO_DUMP)
5256
5257   ROM_REGION( 0x100000, "gfx2", 0 )
5258   ROM_LOAD16_BYTE( "96rom5.bin", 0x00000, 0x40000, NO_DUMP )
5259   ROM_LOAD16_BYTE( "96rom6.bin", 0x00001, 0x40000, NO_DUMP )
5260
5261   ROM_REGION( 0x20, "defaults", 0 ) /* default settings */
5262   ROM_LOAD_OPTIONAL( "fcs40r1.id", 0x00, 0x20, CRC(b3638cdb) SHA1(283824c57f3f62f6e2b505f6e13b100a7d7f33af) )
5263ROM_END
5264
51005265ROM_START( dvisland )
51015266   ROM_REGION( 0x80000, "maincpu", 0 ) /* Z80 Code */
51025267   ROM_LOAD( "did14r.bin", 0x00000, 0x80000, CRC(28c3a7eb) SHA1(5389338ef42e05542e3ff052b2bbc918cf619874) )
r7500r7501
51545319   ROM_LOAD_OPTIONAL( "fr14r.id", 0x00, 0x20, CRC(1542e2bc) SHA1(56e615866d451abd2d6c2d689a85bdca447c2538) )
51555320ROM_END
51565321
5322ROM_START( spooky )
5323   ROM_REGION( 0x80000, "maincpu", 0 ) /* Z80 Code */
5324   ROM_LOAD( "snd204r.bin", 0x00000, 0x80000, CRC(0e737c07) SHA1(50b55390f6ae6ae661d020dabd685651a7f160b2) )
5325
5326   ROM_REGION( 0x040000, "oki", ROMREGION_ERASE00 ) /* Samples */
5327   ROM_LOAD( "snrom2.bin", 0x00000, 0x40000, NO_DUMP )
5328
5329   ROM_REGION( 0x100000, "gfx1", 0 )
5330   ROM_LOAD16_BYTE( "snrom3.bin", 0x00000, 0x80000, NO_DUMP )
5331   ROM_LOAD16_BYTE( "snrom4.bin", 0x00001, 0x80000, NO_DUMP )
5332
5333   ROM_REGION( 0x100000, "gfx2", 0 )
5334   ROM_LOAD16_BYTE( "snrom5.bin", 0x00000, 0x80000, NO_DUMP )
5335   ROM_LOAD16_BYTE( "snrom6.bin", 0x00001, 0x80000, NO_DUMP )
5336ROM_END
5337
5338ROM_START( fbdeluxe )
5339   ROM_REGION( 0x80000, "maincpu", 0 ) /* Z80 Code */
5340   ROM_LOAD( "fbd107r.bin", 0x00000, 0x80000, CRC(b29be47d) SHA1(bd3098fa6b914b2f9dcbe36e2cf36f90c67c1424) )
5341
5342   ROM_REGION( 0x040000, "oki", ROMREGION_ERASE00 ) /* Samples */
5343   ROM_LOAD( "fbrom2.bin", 0x00000, 0x40000, NO_DUMP )
5344
5345   ROM_REGION( 0x100000, "gfx1", 0 )
5346   ROM_LOAD16_BYTE( "fbrom3.bin", 0x00000, 0x80000, NO_DUMP )
5347   ROM_LOAD16_BYTE( "fbrom4.bin", 0x00001, 0x80000, NO_DUMP )
5348
5349   ROM_REGION( 0x100000, "gfx2", 0 )
5350   ROM_LOAD16_BYTE( "fbrom5.bin", 0x00000, 0x80000, NO_DUMP )
5351   ROM_LOAD16_BYTE( "fbrom6.bin", 0x00001, 0x80000, NO_DUMP )
5352ROM_END
5353
51575354// diagnostics?
51585355ROM_START( amclink )
51595356   ROM_REGION( 0x80000, "maincpu", 0 ) /* Z80 Code */
r7500r7501
53785575static DRIVER_INIT(tighookd) { sfbonus_bitswap(machine,   0x3d, 0,1,7,6,5,4,3,2, 0xed, 1,7,6,5,4,3,0,2, 0x26, 2,1,0,7,6,5,4,3, 0xa9, 4,3,0,1,2,7,6,5, 0x3c, 1,0,7,6,5,4,3,2, 0xed, 2,7,6,5,4,3,1,0, 0x26, 2,1,0,7,6,5,4,3, 0xae, 4,3,1,2,0,7,6,5); }
53795576static DRIVER_INIT(tighookv) { sfbonus_bitswap(machine,   0x39, 1,2,7,6,5,4,3,0, 0xef, 2,7,6,5,4,3,0,1, 0x26, 0,2,1,7,6,5,4,3, 0xa8, 4,3,1,2,0,7,6,5, 0x3b, 0,1,7,6,5,4,3,2, 0xec, 0,7,6,5,4,3,2,1, 0x21, 1,0,2,7,6,5,4,3, 0xac, 4,3,0,1,2,7,6,5); }
53805577static DRIVER_INIT(tighookv2) { sfbonus_bitswap(machine,  0x39, 1,2,7,6,5,4,3,0, 0xef, 2,7,6,5,4,3,0,1, 0x23, 0,2,1,7,6,5,4,3, 0xa8, 4,3,1,2,0,7,6,5, 0x3b, 0,1,7,6,5,4,3,2, 0xea, 0,7,6,5,4,3,2,1, 0x21, 1,0,2,7,6,5,4,3, 0xac, 4,3,0,1,2,7,6,5); }
5381
5382static DRIVER_INIT(version4) { sfbonus_bitswap(machine,   0x39, 1,2,7,6,5,4,3,0, 0xef, 2,7,6,5,4,3,0,1, 0x26, 1,0,2,7,6,5,4,3, 0xa8, 4,3,1,2,0,7,6,5, 0x3b, 0,1,7,6,5,4,3,2, 0xec, 1,7,6,5,4,3,0,2, 0x22, 2,1,0,7,6,5,4,3, 0xac, 4,3,0,1,2,7,6,5); }
53835578static DRIVER_INIT(bugfever) { sfbonus_bitswap(machine,   0x3c, 1,2,7,6,5,4,3,0, 0xea, 2,7,6,5,4,3,0,1, 0x22, 2,1,0,7,6,5,4,3, 0xa8, 4,3,1,2,0,7,6,5, 0x3b, 0,1,7,6,5,4,3,2, 0xe9, 1,7,6,5,4,3,0,2, 0x23, 1,0,2,7,6,5,4,3, 0xa9, 4,3,0,1,2,7,6,5); }
53845579static DRIVER_INIT(bugfeverd) { sfbonus_bitswap(machine,  0x39, 1,2,7,6,5,4,3,0, 0xef, 2,7,6,5,4,3,0,1, 0x26, 1,0,2,7,6,5,4,3, 0xa8, 4,3,1,2,0,7,6,5, 0x3a, 0,1,7,6,5,4,3,2, 0xe8, 1,7,6,5,4,3,0,2, 0x22, 2,1,0,7,6,5,4,3, 0xac, 4,3,0,1,2,7,6,5); }
53855580static DRIVER_INIT(bugfeverv) { sfbonus_bitswap(machine,  0x3c, 1,0,7,6,5,4,3,2, 0xef, 0,7,6,5,4,3,2,1, 0x22, 0,2,1,7,6,5,4,3, 0xa8, 4,3,1,2,0,7,6,5, 0x3a, 0,1,7,6,5,4,3,2, 0xea, 2,7,6,5,4,3,1,0, 0x22, 0,1,2,7,6,5,4,3, 0xa9, 4,3,2,1,0,7,6,5); }
53865581static DRIVER_INIT(bugfeverv2) { sfbonus_bitswap(machine, 0x3c, 1,2,7,6,5,4,3,0, 0xea, 2,7,6,5,4,3,0,1, 0x23, 0,2,1,7,6,5,4,3, 0xa8, 4,3,1,2,0,7,6,5, 0x3b, 0,1,7,6,5,4,3,2, 0xed, 2,7,6,5,4,3,1,0, 0x26, 2,1,0,7,6,5,4,3, 0xa9, 4,3,0,1,2,7,6,5); }
5582
5583static DRIVER_INIT(version4) { sfbonus_bitswap(machine,   0x39, 1,2,7,6,5,4,3,0, 0xef, 2,7,6,5,4,3,0,1, 0x26, 1,0,2,7,6,5,4,3, 0xa8, 4,3,1,2,0,7,6,5, 0x3b, 0,1,7,6,5,4,3,2, 0xec, 1,7,6,5,4,3,0,2, 0x22, 2,1,0,7,6,5,4,3, 0xac, 4,3,0,1,2,7,6,5); }
53875584static DRIVER_INIT(dvisland) { sfbonus_bitswap(machine,   0x39, 1,2,7,6,5,4,3,0, 0xef, 2,7,6,5,4,3,0,1, 0x21, 1,0,2,7,6,5,4,3, 0xa8, 4,3,1,2,0,7,6,5, 0x3b, 0,1,7,6,5,4,3,2, 0xe9, 1,7,6,5,4,3,0,2, 0x23, 2,1,0,7,6,5,4,3, 0xac, 4,3,0,1,2,7,6,5); }
53885585static DRIVER_INIT(funriver) { sfbonus_bitswap(machine,   0x3c, 1,2,7,6,5,4,3,0, 0xea, 2,7,6,5,4,3,0,1, 0x24, 0,2,1,7,6,5,4,3, 0xa8, 4,3,1,2,0,7,6,5, 0x3b, 0,1,7,6,5,4,3,2, 0xec, 0,7,6,5,4,3,2,1, 0x23, 1,0,2,7,6,5,4,3, 0xa9, 4,3,0,1,2,7,6,5); }
53895586static DRIVER_INIT(funriverv) { sfbonus_bitswap(machine,  0x39, 1,2,7,6,5,4,3,0, 0xef, 2,7,6,5,4,3,0,1, 0x26, 0,2,1,7,6,5,4,3, 0xa8, 4,3,1,2,0,7,6,5, 0x3b, 0,1,7,6,5,4,3,2, 0xea, 2,7,6,5,4,3,1,0, 0x22, 2,1,0,7,6,5,4,3, 0xac, 4,3,0,1,2,7,6,5); }
5587static DRIVER_INIT(spooky)    { sfbonus_bitswap(machine,  0x39, 1,2,7,6,5,4,3,0, 0xef, 2,7,6,5,4,3,0,1, 0x21, 1,0,2,7,6,5,4,3, 0xa8, 4,3,1,2,0,7,6,5, 0x39, 1,0,7,6,5,4,3,2, 0xe8, 1,7,6,5,4,3,2,0, 0x23, 0,2,1,7,6,5,4,3, 0xac, 4,3,0,1,2,7,6,5); }
5588static DRIVER_INIT(fbdeluxe)  { sfbonus_bitswap(machine,  0x39, 1,2,7,6,5,4,3,0, 0xef, 2,7,6,5,4,3,0,1, 0x21, 1,0,2,7,6,5,4,3, 0xa8, 4,3,1,2,0,7,6,5, 0x3b, 1,0,7,6,5,4,3,2, 0xec, 1,7,6,5,4,3,2,0, 0x26, 0,2,1,7,6,5,4,3, 0xac, 4,3,0,1,2,7,6,5); }
53905589
53915590
53925591
r7500r7501
56075806GAME( 2004, classiced2,  classice, sfbonus,    amcoe1_reels3,    classiced,       ROT0,  "Amcoe", "Classic Edition (Version 1.6LT, set 2)", 0)
56085807GAME( 2004, classicev2,  classice, sfbonus,    amcoe1_reels3,    classicev,       ROT0,  "Amcoe", "Classic Edition (Version 1.6LT Dual)", 0)
56095808
5610GAME( 2007, atworld,     0,        sfbonus,    amcoe1_reels3,    atworld,         ROT0,  "Amcoe", "Around The World (Version 1.3E CGA)", 0) /* Year according to Amcoe web site - too new */
5611GAME( 2007, atworldd1,   atworld,  sfbonus,    amcoe1_reels3,    atworldd,        ROT0,  "Amcoe", "Around The World (Version 1.3R CGA)", 0) /* Year according to Amcoe web site - too new */
5809GAME( 2005, seawld,      0,        sfbonus,    amcoe1_reels3,    seawldv,         ROT0,  "Amcoe", "Sea World (Version 1.6E Dual)", 0)
5810GAME( 2005, seawldd1,    seawld,   sfbonus,    amcoe1_reels3,    seawld,          ROT0,  "Amcoe", "Sea World (Version 1.6R CGA)", 0)
56125811
5613GAME( 200?, seawld,      0,        sfbonus,    amcoe1_reels3,    seawldv,         ROT0,  "Amcoe", "Sea World (Version 1.6E Dual)", 0)
5614GAME( 200?, seawldd1,    seawld,   sfbonus,    amcoe1_reels3,    seawld,          ROT0,  "Amcoe", "Sea World (Version 1.6R CGA)", 0)
5812GAME( 2005, moneymac,    0,        sfbonus,    amcoe1_reels3,    moneymacv,       ROT0,  "Amcoe", "Money Machine (Version 1.7E Dual)", 0)
5813GAME( 2005, moneymacd1,  moneymac, sfbonus,    amcoe1_reels3,    moneymacd,       ROT0,  "Amcoe", "Money Machine (Version 1.7R)", 0)
5814GAME( 2005, moneymacv1,  moneymac, sfbonus,    amcoe1_reels3,    moneymac,        ROT0,  "Amcoe", "Money Machine (Version 1.7R Dual)", 0)
5815GAME( 2005, moneymacd2,  moneymac, sfbonus,    amcoe1_reels3,    moneymacd,       ROT0,  "Amcoe", "Money Machine (Version 1.7LT)", 0)
5816GAME( 2005, moneymacv2,  moneymac, sfbonus,    amcoe1_reels3,    moneymac,        ROT0,  "Amcoe", "Money Machine (Version 1.7LT Dual)", 0)
56155817
5616GAME( 200?, moneymac,    0,        sfbonus,    amcoe1_reels3,    moneymacv,       ROT0,  "Amcoe", "Money Machine (Version 1.7E Dual)", 0)
5617GAME( 200?, moneymacd1,  moneymac, sfbonus,    amcoe1_reels3,    moneymacd,       ROT0,  "Amcoe", "Money Machine (Version 1.7R)", 0)
5618GAME( 200?, moneymacv1,  moneymac, sfbonus,    amcoe1_reels3,    moneymac,        ROT0,  "Amcoe", "Money Machine (Version 1.7R Dual)", 0)
5619GAME( 200?, moneymacd2,  moneymac, sfbonus,    amcoe1_reels3,    moneymacd,       ROT0,  "Amcoe", "Money Machine (Version 1.7LT)", 0)
5620GAME( 200?, moneymacv2,  moneymac, sfbonus,    amcoe1_reels3,    moneymac,        ROT0,  "Amcoe", "Money Machine (Version 1.7LT Dual)", 0)
5621
56225818GAME( 2005, fb5,         0,        sfbonus,    amcoe2_reels3,    fb5,             ROT0,  "Amcoe", "Fruit Bonus 2005 (Version 1.5SH, set 1)", 0)
56235819GAME( 2005, fb5c,        fb5,      sfbonus,    amcoe1_reels3,    fb5,             ROT0,  "Amcoe", "Fruit Bonus 2005 (Version 1.5SH, set 2)", 0)
56245820GAME( 2005, fb5d,        fb5,      sfbonus,    amcoe1_reels3,    fb5d,            ROT0,  "Amcoe", "Fruit Bonus 2005 (Version 1.5SH, set 3)", 0)
56255821GAME( 2005, fb5v,        fb5,      sfbonus,    amcoe1_reels3,    fb5v,            ROT0,  "Amcoe", "Fruit Bonus 2005 (Version 1.5SH Dual)", 0)
56265822
5627GAME( 200?, fb6,         0,        sfbonus,    amcoe1_reels3,    fb6,             ROT0,  "Amcoe", "Fruit Bonus '06 - 10th anniversary (Version 1.7E CGA)", 0)
5628GAME( 200?, fb6v,        fb6,      sfbonus,    amcoe1_reels3,    fb6v3,           ROT0,  "Amcoe", "Fruit Bonus '06 - 10th anniversary (Version 1.7E Dual)", 0)
5629GAME( 200?, fb6d1,       fb6,      sfbonus,    amcoe1_reels3,    fb6d,            ROT0,  "Amcoe", "Fruit Bonus '06 - 10th anniversary (Version 1.7R CGA, set 1)", 0)
5630GAME( 200?, fb6s1,       fb6,      sfbonus,    amcoe1_reels3,    fb6s,            ROT0,  "Amcoe", "Fruit Bonus '06 - 10th anniversary (Version 1.7R CGA, set 2)", GAME_NOT_WORKING) // no reel gfx
5631GAME( 200?, fb6v1,       fb6,      sfbonus,    amcoe1_reels3,    fb6v,            ROT0,  "Amcoe", "Fruit Bonus '06 - 10th anniversary (Version 1.7R Dual)", 0)
5632GAME( 200?, fb6d2,       fb6,      sfbonus,    amcoe1_reels3,    fb6d,            ROT0,  "Amcoe", "Fruit Bonus '06 - 10th anniversary (Version 1.7LT CGA, set 1)", 0)
5633GAME( 200?, fb6s2,       fb6,      sfbonus,    amcoe1_reels3,    fb6s,            ROT0,  "Amcoe", "Fruit Bonus '06 - 10th anniversary (Version 1.7LT CGA, set 2)", GAME_NOT_WORKING) // no reel gfx
5634GAME( 200?, fb6v2,       fb6,      sfbonus,    amcoe1_reels3,    fb6v,            ROT0,  "Amcoe", "Fruit Bonus '06 - 10th anniversary (Version 1.7LT Dual)", 0)
5823GAME( 2006, fb6,         0,        sfbonus,    amcoe1_reels3,    fb6,             ROT0,  "Amcoe", "Fruit Bonus '06 - 10th anniversary (Version 1.7E CGA)", 0)
5824GAME( 2006, fb6v,        fb6,      sfbonus,    amcoe1_reels3,    fb6v3,           ROT0,  "Amcoe", "Fruit Bonus '06 - 10th anniversary (Version 1.7E Dual)", 0)
5825GAME( 2006, fb6d1,       fb6,      sfbonus,    amcoe1_reels3,    fb6d,            ROT0,  "Amcoe", "Fruit Bonus '06 - 10th anniversary (Version 1.7R CGA, set 1)", 0)
5826GAME( 2006, fb6s1,       fb6,      sfbonus,    amcoe1_reels3,    fb6s,            ROT0,  "Amcoe", "Fruit Bonus '06 - 10th anniversary (Version 1.7R CGA, set 2)", GAME_NOT_WORKING) // no reel gfx
5827GAME( 2006, fb6v1,       fb6,      sfbonus,    amcoe1_reels3,    fb6v,            ROT0,  "Amcoe", "Fruit Bonus '06 - 10th anniversary (Version 1.7R Dual)", 0)
5828GAME( 2006, fb6d2,       fb6,      sfbonus,    amcoe1_reels3,    fb6d,            ROT0,  "Amcoe", "Fruit Bonus '06 - 10th anniversary (Version 1.7LT CGA, set 1)", 0)
5829GAME( 2006, fb6s2,       fb6,      sfbonus,    amcoe1_reels3,    fb6s,            ROT0,  "Amcoe", "Fruit Bonus '06 - 10th anniversary (Version 1.7LT CGA, set 2)", GAME_NOT_WORKING) // no reel gfx
5830GAME( 2006, fb6v2,       fb6,      sfbonus,    amcoe1_reels3,    fb6v,            ROT0,  "Amcoe", "Fruit Bonus '06 - 10th anniversary (Version 1.7LT Dual)", 0)
56355831
56365832GAME( 2006, fb6se,       0,        sfbonus,    amcoe1_reels3,    fb6,             ROT0,  "Amcoe", "Fruit Bonus 2006 Special Edition (Version 1.4E CGA)", 0) /* Released August 2006 according to Amcoe web site */
56375833GAME( 2006, fb6sev,      fb6se,    sfbonus,    amcoe1_reels3,    fb6v3,           ROT0,  "Amcoe", "Fruit Bonus 2006 Special Edition (Version 1.4E Dual)", 0)
r7500r7501
56405836GAME( 2006, fb6sed2,     fb6se,    sfbonus,    amcoe1_reels3,    fb6d,            ROT0,  "Amcoe", "Fruit Bonus 2006 Special Edition (Version 1.4LT CGA)", 0)
56415837GAME( 2006, fb6sev2,     fb6se,    sfbonus,    amcoe1_reels3,    fb6v,            ROT0,  "Amcoe", "Fruit Bonus 2006 Special Edition (Version 1.4LT Dual)", 0)
56425838
5643// no gfx / sound roms
5644GAME( 200?, version4,    0,        sfbonus,    amcoe1_reels3,    version4,        ROT0,  "Amcoe", "Version 4 (Version 4.2R)", GAME_NOT_WORKING)
5645// no gfx / sound roms
5646GAME( 2006, bugfever,    0,        sfbonus,    amcoe1_reels3,    bugfever,        ROT0,  "Amcoe", "Bug Fever (set 1)", GAME_NOT_WORKING) /* Released August 2006 according to Amcoe web site */
5647GAME( 2006, bugfeverd,   bugfever, sfbonus,    amcoe1_reels3,    bugfeverd,       ROT0,  "Amcoe", "Bug Fever (set 2)", GAME_NOT_WORKING)
5648GAME( 2006, bugfeverv,   bugfever, sfbonus,    amcoe1_reels3,    bugfeverv,       ROT0,  "Amcoe", "Bug Fever (set 3)", GAME_NOT_WORKING)
5649GAME( 2006, bugfeverv2,  bugfever, sfbonus,    amcoe1_reels3,    bugfeverv2,      ROT0,  "Amcoe", "Bug Fever (set 4)", GAME_NOT_WORKING)
5650// no gfx / sound roms
5651GAME( 200?, dvisland,    0,        sfbonus,    amcoe1_reels3,    dvisland,        ROT0,  "Amcoe", "Devil Island", GAME_NOT_WORKING)
5652// no gfx / sound roms
5653GAME( 200?, funriver,    0,        sfbonus,    amcoe1_reels3,    funriver,        ROT0,  "Amcoe", "Fun River (set 1)", GAME_NOT_WORKING)
5654GAME( 200?, funriverv,   funriver, sfbonus,    amcoe1_reels3,    funriverv,       ROT0,  "Amcoe", "Fun River (set 2)", GAME_NOT_WORKING)
5839GAME( 2006, bugfever,    0,        sfbonus,    amcoe1_reels3,    bugfever,        ROT0,  "Amcoe", "Bugs Fever (Version 1.7R CGA)", 0) /* Released August 2006 according to Amcoe web site */
5840GAME( 2006, bugfeverv,   bugfever, sfbonus,    amcoe1_reels3,    bugfeverv,       ROT0,  "Amcoe", "Bugs Fever (Version 1.7R Dual)", 0)
5841GAME( 2006, bugfeverd,   bugfever, sfbonus,    amcoe1_reels3,    bugfeverd,       ROT0,  "Amcoe", "Bugs Fever (Version 1.7E CGA)", 0)
5842GAME( 2006, bugfeverv2,  bugfever, sfbonus,    amcoe1_reels3,    bugfeverv2,      ROT0,  "Amcoe", "Bugs Fever (Version 1.7E Dual)", 0)
5843GAME( 2006, bugfevero,   bugfever, sfbonus,    amcoe1_reels3,    bugfever,        ROT0,  "Amcoe", "Bugs Fever (Version 1.6R CGA)", 0)
5844
5845GAME( 2007, atworld,     0,        sfbonus,    amcoe1_reels3,    atworld,         ROT0,  "Amcoe", "Around The World (Version 1.3E CGA)", 0) /* Year according to Amcoe web site - too new */
5846GAME( 2007, atworldd1,   atworld,  sfbonus,    amcoe1_reels3,    atworldd,        ROT0,  "Amcoe", "Around The World (Version 1.3R CGA)", 0) /* Year according to Amcoe web site - too new */
5847
5848// no graphic / sound roms dumped for these sets, but functional program roms & descramble are in place
5849GAME( 2005, funriver,    0,        sfbonus,    amcoe1_reels3,    funriver,        ROT0,  "Amcoe", "Fun River (set 1)", GAME_NOT_WORKING)
5850GAME( 2005, funriverv,   funriver, sfbonus,    amcoe1_reels3,    funriverv,       ROT0,  "Amcoe", "Fun River (set 2)", GAME_NOT_WORKING)
5851GAME( 2006, version4,    0,        sfbonus,    amcoe1_reels3,    version4,        ROT0,  "Amcoe", "Version 4 (Version 4.2R)", GAME_NOT_WORKING)
5852GAME( 2006, dvisland,    0,        sfbonus,    amcoe1_reels3,    dvisland,        ROT0,  "Amcoe", "Devil Island", GAME_NOT_WORKING)
5853GAME( 200?, spooky,      0,        sfbonus,    amcoe1_reels3,    spooky,          ROT0,  "Amcoe", "Spooky Night (Version 2.0.4)", GAME_NOT_WORKING) /* After Around The World */
5854GAME( 200?, fbdeluxe,    0,        sfbonus,    amcoe1_reels3,    fbdeluxe,        ROT0,  "Amcoe", "Fruit Bonus Deluxe (Version 1.0.7)", GAME_NOT_WORKING) /* After Around The World */
5855
5856// Known sets but no roms dumped at all for these:
5857// Merry Circus
5858// Fruit Bonus 3G
5859
56555860// ?? what is this
56565861GAME( 200?, amclink,     0,        sfbonus,    amcoe1_reels3,    sfbonus_common,  ROT0,  "Amcoe", "Amcoe Link Control Box (Version 2.2)", GAME_NOT_WORKING)
src/mame/drivers/madmotor.c
r7500r7501
1818#include "sound/2203intf.h"
1919#include "sound/2151intf.h"
2020#include "sound/okim6295.h"
21#include "includes/madmotor.h"
2122
22VIDEO_START( madmotor );
23VIDEO_UPDATE( madmotor );
24
25WRITE16_HANDLER( madmotor_pf1_data_w );
26WRITE16_HANDLER( madmotor_pf2_data_w );
27WRITE16_HANDLER( madmotor_pf3_data_w );
28extern UINT16 *madmotor_pf1_rowscroll;
29extern UINT16 *madmotor_pf1_data,*madmotor_pf2_data,*madmotor_pf3_data;
30extern UINT16 *madmotor_pf1_control,*madmotor_pf2_control,*madmotor_pf3_control;
31
3223/******************************************************************************/
3324
3425static WRITE16_HANDLER( madmotor_sound_w )
3526{
27   madmotor_state *state = (madmotor_state *)space->machine->driver_data;
28
3629   if (ACCESSING_BITS_0_7)
3730   {
3831      soundlatch_w(space, 0, data & 0xff);
39      cputag_set_input_line(space->machine, "audiocpu", 0, HOLD_LINE);
32      cpu_set_input_line(state->audiocpu, 0, HOLD_LINE);
4033   }
4134}
4235
r7500r7501
4538
4639static ADDRESS_MAP_START( madmotor_map, ADDRESS_SPACE_PROGRAM, 16 )
4740   AM_RANGE(0x000000, 0x07ffff) AM_ROM
48   AM_RANGE(0x180000, 0x18001f) AM_WRITEONLY AM_BASE(&madmotor_pf1_control)
49   AM_RANGE(0x184000, 0x1847ff) AM_RAM AM_BASE(&madmotor_pf1_rowscroll)
50   AM_RANGE(0x188000, 0x189fff) AM_RAM_WRITE(madmotor_pf1_data_w) AM_BASE(&madmotor_pf1_data)
41   AM_RANGE(0x180000, 0x18001f) AM_WRITEONLY AM_BASE_MEMBER(madmotor_state, pf1_control)
42   AM_RANGE(0x184000, 0x1847ff) AM_RAM AM_BASE_MEMBER(madmotor_state, pf1_rowscroll)
43   AM_RANGE(0x188000, 0x189fff) AM_RAM_WRITE(madmotor_pf1_data_w) AM_BASE_MEMBER(madmotor_state, pf1_data)
5144   AM_RANGE(0x18c000, 0x18c001) AM_NOP
52   AM_RANGE(0x190000, 0x19001f) AM_WRITEONLY AM_BASE(&madmotor_pf2_control)
53   AM_RANGE(0x198000, 0x1987ff) AM_RAM_WRITE(madmotor_pf2_data_w) AM_BASE(&madmotor_pf2_data)
45   AM_RANGE(0x190000, 0x19001f) AM_WRITEONLY AM_BASE_MEMBER(madmotor_state, pf2_control)
46   AM_RANGE(0x198000, 0x1987ff) AM_RAM_WRITE(madmotor_pf2_data_w) AM_BASE_MEMBER(madmotor_state, pf2_data)
5447   AM_RANGE(0x19c000, 0x19c001) AM_READNOP
55   AM_RANGE(0x1a0000, 0x1a001f) AM_WRITEONLY AM_BASE(&madmotor_pf3_control)
56   AM_RANGE(0x1a4000, 0x1a4fff) AM_RAM_WRITE(madmotor_pf3_data_w) AM_BASE(&madmotor_pf3_data)
48   AM_RANGE(0x1a0000, 0x1a001f) AM_WRITEONLY AM_BASE_MEMBER(madmotor_state, pf3_control)
49   AM_RANGE(0x1a4000, 0x1a4fff) AM_RAM_WRITE(madmotor_pf3_data_w) AM_BASE_MEMBER(madmotor_state, pf3_data)
5750   AM_RANGE(0x3e0000, 0x3e3fff) AM_RAM
58   AM_RANGE(0x3e8000, 0x3e87ff) AM_RAM AM_BASE_SIZE_GENERIC(spriteram)
51   AM_RANGE(0x3e8000, 0x3e87ff) AM_RAM AM_BASE_SIZE_MEMBER(madmotor_state, spriteram, spriteram_size)
5952   AM_RANGE(0x3f0000, 0x3f07ff) AM_RAM_WRITE(paletteram16_xxxxBBBBGGGGRRRR_word_w) AM_BASE_GENERIC(paletteram)
6053   AM_RANGE(0x3f8002, 0x3f8003) AM_READ_PORT("P1_P2")
6154   AM_RANGE(0x3f8004, 0x3f8005) AM_READ_PORT("DSW")
r7500r7501
221214
222215static void sound_irq(running_device *device, int state)
223216{
224   cputag_set_input_line(device->machine, "audiocpu", 1, state); /* IRQ 2 */
217   madmotor_state *driver_state = (madmotor_state *)device->machine->driver_data;
218   cpu_set_input_line(driver_state->audiocpu, 1, state); /* IRQ 2 */
225219}
226220
227221static const ym2151_interface ym2151_config =
r7500r7501
229223   sound_irq
230224};
231225
226static MACHINE_START( madmotor )
227{
228   madmotor_state *state = (madmotor_state *)machine->driver_data;
229
230   state->maincpu = devtag_get_device(machine, "maincpu");
231   state->audiocpu = devtag_get_device(machine, "audiocpu");
232
233   state_save_register_global(machine, state->flipscreen);
234}
235
236static MACHINE_RESET( madmotor )
237{
238   madmotor_state *state = (madmotor_state *)machine->driver_data;
239
240   state->flipscreen = 0;
241}
242
232243static MACHINE_DRIVER_START( madmotor )
233244
245   /* driver data */
246   MDRV_DRIVER_DATA(madmotor_state)
247
234248   /* basic machine hardware */
235249   MDRV_CPU_ADD("maincpu", M68000, 12000000) /* Custom chip 59, 24 MHz crystal */
236250   MDRV_CPU_PROGRAM_MAP(madmotor_map)
r7500r7501
239253   MDRV_CPU_ADD("audiocpu", H6280, 8053000/2) /* Custom chip 45, Crystal near CPU is 8.053 MHz */
240254   MDRV_CPU_PROGRAM_MAP(sound_map)
241255
256   MDRV_MACHINE_START(madmotor)
257   MDRV_MACHINE_RESET(madmotor)
258
242259   /* video hardware */
243260   MDRV_VIDEO_ATTRIBUTES(VIDEO_UPDATE_BEFORE_VBLANK)
244261
r7500r7501
334351
335352
336353 /* The title screen is undated, but it's (c) 1989 Data East at 0xefa0 */
337GAME( 1989, madmotor, 0, madmotor, madmotor, madmotor, ROT0, "Mitchell", "Mad Motor", 0 )
354GAME( 1989, madmotor, 0, madmotor, madmotor, madmotor, ROT0, "Mitchell", "Mad Motor", GAME_SUPPORTS_SAVE )
src/mame/drivers/chinsan.c
r7500r7501
4747#include "sound/2203intf.h"
4848#include "sound/msm5205.h"
4949
50typedef struct _chinsan_state chinsan_state;
51struct _chinsan_state
50class chinsan_state
5251{
52public:
53   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, chinsan_state(machine)); }
54
55   chinsan_state(running_machine &machine) { }
56
5357   /* memory pointers */
5458   UINT8 *  video;
5559
src/mame/drivers/senjyo.c
r7500r7501
7575#include "machine/segacrpt.h"
7676#include "includes/senjyo.h"
7777
78
78extern UINT8 senjyo_sound_cmd;
7979static int int_delay_kludge;
8080
8181static MACHINE_RESET( senjyo )
r7500r7501
9898   flip_screen_set(space->machine, data);
9999}
100100
101static WRITE8_DEVICE_HANDLER( sound_cmd_w )
102{
103   senjyo_sound_cmd = data;
101104
105   z80pio_astb_w(device, 0);
106   z80pio_astb_w(device, 1);
107}
108
102109static ADDRESS_MAP_START( senjyo_map, ADDRESS_SPACE_PROGRAM, 8 )
103110   AM_RANGE(0x0000, 0x7fff) AM_ROM
104111   AM_RANGE(0x8000, 0x8fff) AM_RAM
r7500r7501
127134   AM_RANGE(0xd000, 0xd000) AM_READ_PORT("P1") AM_WRITE(flip_screen_w)
128135   AM_RANGE(0xd001, 0xd001) AM_READ_PORT("P2")
129136   AM_RANGE(0xd002, 0xd002) AM_READ_PORT("SYSTEM")
130   AM_RANGE(0xd004, 0xd004) AM_READ_PORT("DSW1") AM_DEVWRITE("z80pio", z80pio_p_w)
137   AM_RANGE(0xd004, 0xd004) AM_READ_PORT("DSW1") AM_DEVWRITE("z80pio", sound_cmd_w)
131138   AM_RANGE(0xd005, 0xd005) AM_READ_PORT("DSW2")
132139ADDRESS_MAP_END
133140
134
135static WRITE8_DEVICE_HANDLER( pio_w )
136{
137   if (offset & 1)
138      z80pio_c_w(device, (offset >> 1) & 1, data);
139   else
140      z80pio_d_w(device, (offset >> 1) & 1, data);
141}
142
143static READ8_DEVICE_HANDLER( pio_r )
144{
145   return (offset & 1) ? z80pio_c_r(device, (offset >> 1) & 1) : z80pio_d_r(device, (offset >> 1) & 1);
146}
147
148141static ADDRESS_MAP_START( senjyo_sound_map, ADDRESS_SPACE_PROGRAM, 8 )
149142   AM_RANGE(0x0000, 0x3fff) AM_ROM
150143   AM_RANGE(0x4000, 0x43ff) AM_RAM
r7500r7501
160153
161154static ADDRESS_MAP_START( senjyo_sound_io_map, ADDRESS_SPACE_IO, 8 )
162155   ADDRESS_MAP_GLOBAL_MASK(0xff)
163   AM_RANGE(0x00, 0x03) AM_DEVREADWRITE("z80pio", pio_r, pio_w)
156   AM_RANGE(0x00, 0x03) AM_DEVREADWRITE("z80pio", z80pio_ba_cd_r, z80pio_ba_cd_w)
164157   AM_RANGE(0x08, 0x0b) AM_DEVREADWRITE("z80ctc", z80ctc_r, z80ctc_w)
165158ADDRESS_MAP_END
166159
r7500r7501
200193   AM_RANGE(0xd000, 0xd000) AM_READ_PORT("P1") AM_WRITE(flip_screen_w)
201194   AM_RANGE(0xd001, 0xd001) AM_READ_PORT("P2")
202195   AM_RANGE(0xd002, 0xd002) AM_READ_PORT("SYSTEM")
203   AM_RANGE(0xd004, 0xd004) AM_READ_PORT("DSW1") AM_DEVWRITE("z80pio", z80pio_p_w)
196   AM_RANGE(0xd004, 0xd004) AM_READ_PORT("DSW1") AM_DEVWRITE("z80pio", sound_cmd_w)
204197   AM_RANGE(0xd005, 0xd005) AM_READ_PORT("DSW2")
205198
206199   /* these aren't used / written, left here to make sure memory is allocated */
r7500r7501
558551
559552   MDRV_MACHINE_RESET(senjyo)
560553
561   MDRV_Z80PIO_ADD( "z80pio", senjyo_pio_intf )
554   MDRV_Z80PIO_ADD( "z80pio", 2000000, senjyo_pio_intf )
562555   MDRV_Z80CTC_ADD( "z80ctc", 2000000 /* same as "sub" */, senjyo_ctc_intf )
563556
564557   /* video hardware */
src/mame/drivers/maygay1b.c
r7500r7501
4545static UINT8 Lamps[256];      // 256 multiplexed lamps
4646static int optic_pattern;
4747
48typedef struct _i8279_state i8279_state;
49struct _i8279_state
48struct i8279_state
5049{
5150   UINT8      command;
5251   UINT8      mode;
src/mame/drivers/spool99.c
r7500r7501
9292#include "sound/okim6295.h"
9393#include "machine/eeprom.h"
9494
95typedef struct _spool99_state spool99_state;
96struct _spool99_state
95class spool99_state
9796{
97public:
98   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, spool99_state(machine)); }
99
100   spool99_state(running_machine &machine) { }
101
98102   UINT8 *main;
99103   tilemap_t *sc0_tilemap;
100104   UINT8 *cram;
src/mame/drivers/simpl156.c
r7500r7501
9090
9191#include "emu.h"
9292#include "includes/decocrpt.h"
93#include "includes/deco32.h"
9493#include "cpu/arm/arm.h"
94#include "includes/simpl156.h"
9595#include "machine/eeprom.h"
9696#include "sound/okim6295.h"
97#include "includes/deco16ic.h"
97#include "video/deco16ic.h"
9898
99static UINT32 *simpl156_systemram;
10099
101extern VIDEO_START( simpl156 );
102extern VIDEO_UPDATE( simpl156 );
103
104
105100static INPUT_PORTS_START( simpl156 )
106   PORT_START("IN0")   /* 16bit */
101   PORT_START("IN0")
107102   PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_COIN1 )
108103   PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_COIN2 )
109104   PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_SERVICE1 )
r7500r7501
112107   PORT_BIT( 0x0100, IP_ACTIVE_HIGH, IPT_SPECIAL ) // eeprom?..
113108
114109
115   PORT_START("IN1")   /* 16bit */
110   PORT_START("IN1")
116111   PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_8WAY PORT_PLAYER(1)
117112   PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_8WAY PORT_PLAYER(1)
118113   PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_8WAY PORT_PLAYER(1)
r7500r7501
134129
135130static READ32_HANDLER( simpl156_inputs_read )
136131{
137   int eep = eeprom_read_bit(devtag_get_device(space->machine, "eeprom"));
138   UINT32 returndata;
132   simpl156_state *state = (simpl156_state *)space->machine->driver_data;
133   int eep = eeprom_read_bit(state->eeprom);
134   UINT32 returndata = input_port_read(space->machine, "IN0") ^ 0xffff0000;
139135
140   returndata = input_port_read(space->machine, "IN0") ^ 0xffff0000;
141
142   returndata^= ( (eep<<8)  );
136   returndata ^= ((eep << 8));
143137   return returndata;
144138}
145139
r7500r7501
153147   UINT16 dat;
154148   int color;
155149
156   data &=0x0000ffff;
157   mem_mask &=0x0000ffff;
150   data &= 0x0000ffff;
151   mem_mask &= 0x0000ffff;
158152
159153   COMBINE_DATA(&space->machine->generic.paletteram.u16[offset]);
160154   color = offset;
161155
162   dat = space->machine->generic.paletteram.u16[offset]&0xffff;
156   dat = space->machine->generic.paletteram.u16[offset] & 0xffff;
163157   palette_set_color_rgb(space->machine,color,pal5bit(dat >> 0),pal5bit(dat >> 5),pal5bit(dat >> 10));
164158}
165159
r7500r7501
175169
176170static WRITE32_HANDLER( simpl156_eeprom_w )
177171{
178   running_device *device = devtag_get_device(space->machine, "eeprom");
172   simpl156_state *state = (simpl156_state *)space->machine->driver_data;
179173   //int okibank;
180174
181175   //okibank = data & 0x07;
182176
183   okim6295_set_bank_base(devtag_get_device(space->machine, "okimusic"), 0x40000 * (data & 0x7) );
177   okim6295_set_bank_base(state->okimusic, 0x40000 * (data & 0x7));
184178
185   eeprom_set_clock_line(device, (data & 0x20) ? ASSERT_LINE : CLEAR_LINE);
186   eeprom_write_bit(device, data & 0x10);
187   eeprom_set_cs_line(device, (data & 0x40) ? CLEAR_LINE : ASSERT_LINE);
179   eeprom_set_clock_line(state->eeprom, BIT(data, 5) ? ASSERT_LINE : CLEAR_LINE);
180   eeprom_write_bit(state->eeprom, BIT(data, 4));
181   eeprom_set_cs_line(state->eeprom, BIT(data, 6) ? CLEAR_LINE : ASSERT_LINE);
188182}
189183
190184
r7500r7501
192186
193187static READ32_HANDLER( simpl156_spriteram_r )
194188{
195   return space->machine->generic.spriteram.u32[offset]^0xffff0000;
189   return space->machine->generic.spriteram.u32[offset] ^ 0xffff0000;
196190}
197191
198192static WRITE32_HANDLER( simpl156_spriteram_w )
199193{
200   data &=0x0000ffff;
201   mem_mask &=0x0000ffff;
194   data &= 0x0000ffff;
195   mem_mask &= 0x0000ffff;
202196
203197   COMBINE_DATA(&space->machine->generic.spriteram.u32[offset]);
204198}
205199
206static UINT32*simpl156_mainram;
207200
208
209201static READ32_HANDLER( simpl156_mainram_r )
210202{
211   return simpl156_mainram[offset]^0xffff0000;
203   simpl156_state *state = (simpl156_state *)space->machine->driver_data;
204   return state->mainram[offset]^0xffff0000;
212205}
213206
214207static WRITE32_HANDLER( simpl156_mainram_w )
215208{
216   data &=0x0000ffff;
217   mem_mask &=0x0000ffff;
209   simpl156_state *state = (simpl156_state *)space->machine->driver_data;
210   data &= 0x0000ffff;
211   mem_mask &= 0x0000ffff;
218212
219   COMBINE_DATA(&simpl156_mainram[offset]);
213   COMBINE_DATA(&state->mainram[offset]);
220214}
221215
222216static READ32_HANDLER( simpl156_pf1_rowscroll_r )
223217{
224   return deco16_pf1_rowscroll[offset]^0xffff0000;
218   simpl156_state *state = (simpl156_state *)space->machine->driver_data;
219   return state->pf1_rowscroll[offset] ^ 0xffff0000;
225220}
226221
227222static WRITE32_HANDLER( simpl156_pf1_rowscroll_w )
228223{
229   data &=0x0000ffff;
230   mem_mask &=0x0000ffff;
224   simpl156_state *state = (simpl156_state *)space->machine->driver_data;
225   data &= 0x0000ffff;
226   mem_mask &= 0x0000ffff;
231227
232   COMBINE_DATA(&deco16_pf1_rowscroll[offset]);
228   COMBINE_DATA(&state->pf1_rowscroll[offset]);
233229}
234230
235231static READ32_HANDLER( simpl156_pf2_rowscroll_r )
236232{
237   return deco16_pf2_rowscroll[offset]^0xffff0000;
233   simpl156_state *state = (simpl156_state *)space->machine->driver_data;
234   return state->pf2_rowscroll[offset] ^ 0xffff0000;
238235}
239236
240237static WRITE32_HANDLER( simpl156_pf2_rowscroll_w )
241238{
242   data &=0x0000ffff;
243   mem_mask &=0x0000ffff;
239   simpl156_state *state = (simpl156_state *)space->machine->driver_data;
240   data &= 0x0000ffff;
241   mem_mask &= 0x0000ffff;
244242
245   COMBINE_DATA(&deco16_pf2_rowscroll[offset]);
243   COMBINE_DATA(&state->pf2_rowscroll[offset]);
246244}
247245
248static READ32_HANDLER ( simpl156_pf12_control_r )
249{
250   return deco16_pf12_control[offset]^0xffff0000;
251}
252
253static WRITE32_HANDLER( simpl156_pf12_control_w )
254{
255   data &=0x0000ffff;
256   mem_mask &=0x0000ffff;
257
258   COMBINE_DATA(&deco16_pf12_control[offset]);
259}
260
261
262static READ32_HANDLER( simpl156_pf1_data_r )
263{
264   return deco16_pf1_data[offset]^0xffff0000;
265}
266
267static WRITE32_HANDLER( simpl156_pf1_data_w )
268{
269   data &=0x0000ffff;
270   mem_mask &=0x0000ffff;
271
272   deco16_pf1_data_w(space,offset,data,mem_mask);
273}
274
275static READ32_HANDLER( simpl156_pf2_data_r )
276{
277   return deco16_pf2_data[offset]^0xffff0000;
278}
279
280
281static WRITE32_HANDLER( simpl156_pf2_data_w )
282{
283   data &=0x0000ffff;
284   mem_mask &=0x0000ffff;
285   deco16_pf2_data_w(space,offset,data,mem_mask);
286}
287
288246/* Memory Map controled by PALs */
289247
290248/* Joe and Mac Returns */
291249static ADDRESS_MAP_START( joemacr_map, ADDRESS_SPACE_PROGRAM, 32 )
292250   AM_RANGE(0x000000, 0x07ffff) AM_ROM
293   AM_RANGE(0x100000, 0x107fff) AM_READWRITE(simpl156_mainram_r, simpl156_mainram_w) AM_BASE(&simpl156_mainram) // main ram
251   AM_RANGE(0x100000, 0x107fff) AM_READWRITE(simpl156_mainram_r, simpl156_mainram_w) AM_BASE_MEMBER(simpl156_state, mainram) // main ram
294252   AM_RANGE(0x110000, 0x111fff) AM_READWRITE(simpl156_spriteram_r, simpl156_spriteram_w) AM_BASE_SIZE_GENERIC(spriteram)
295   AM_RANGE(0x120000, 0x120fff) AM_READWRITE(simpl156_palette_r,simpl156_palette_w)
296   AM_RANGE(0x130000, 0x130003) AM_READWRITE(simpl156_system_r,simpl156_eeprom_w)
297   AM_RANGE(0x140000, 0x14001f) AM_READWRITE(simpl156_pf12_control_r, simpl156_pf12_control_w)
298   AM_RANGE(0x150000, 0x151fff) AM_READWRITE(simpl156_pf1_data_r, simpl156_pf1_data_w)
299   AM_RANGE(0x152000, 0x153fff) AM_READWRITE(simpl156_pf1_data_r, simpl156_pf1_data_w)
300   AM_RANGE(0x154000, 0x155fff) AM_READWRITE(simpl156_pf2_data_r, simpl156_pf2_data_w)
253   AM_RANGE(0x120000, 0x120fff) AM_READWRITE(simpl156_palette_r, simpl156_palette_w)
254   AM_RANGE(0x130000, 0x130003) AM_READWRITE(simpl156_system_r, simpl156_eeprom_w)
255   AM_RANGE(0x140000, 0x14001f) AM_DEVREADWRITE("deco_custom", deco16ic_pf12_control_dword_r, deco16ic_pf12_control_dword_w)
256   AM_RANGE(0x150000, 0x151fff) AM_DEVREADWRITE("deco_custom", deco16ic_pf1_data_dword_r, deco16ic_pf1_data_dword_w)
257   AM_RANGE(0x152000, 0x153fff) AM_DEVREADWRITE("deco_custom", deco16ic_pf1_data_dword_r, deco16ic_pf1_data_dword_w)
258   AM_RANGE(0x154000, 0x155fff) AM_DEVREADWRITE("deco_custom", deco16ic_pf2_data_dword_r, deco16ic_pf2_data_dword_w)
301259   AM_RANGE(0x160000, 0x161fff) AM_READWRITE(simpl156_pf1_rowscroll_r, simpl156_pf1_rowscroll_w)
302260   AM_RANGE(0x164000, 0x165fff) AM_READWRITE(simpl156_pf2_rowscroll_r, simpl156_pf2_rowscroll_w)
303261   AM_RANGE(0x170000, 0x170003) AM_READONLY AM_WRITENOP // ?
304262   AM_RANGE(0x180000, 0x180003) AM_DEVREADWRITE8("okisfx", okim6295_r, okim6295_w, 0x000000ff)
305263   AM_RANGE(0x1c0000, 0x1c0003) AM_DEVREADWRITE8("okimusic", okim6295_r, okim6295_w, 0x000000ff)
306264   AM_RANGE(0x200000, 0x200003) AM_READ(simpl156_inputs_read)
307   AM_RANGE(0x201000, 0x201fff) AM_RAM AM_BASE(&simpl156_systemram) // work ram (32-bit)
265   AM_RANGE(0x201000, 0x201fff) AM_RAM AM_BASE_MEMBER(simpl156_state, systemram) // work ram (32-bit)
308266ADDRESS_MAP_END
309267
310268
r7500r7501
312270static ADDRESS_MAP_START( chainrec_map, ADDRESS_SPACE_PROGRAM, 32 )
313271   AM_RANGE(0x000000, 0x07ffff) AM_ROM // rom (32-bit)
314272   AM_RANGE(0x200000, 0x200003) AM_READ(simpl156_inputs_read)
315   AM_RANGE(0x201000, 0x201fff) AM_RAM AM_BASE(&simpl156_systemram) // work ram (32-bit)
273   AM_RANGE(0x201000, 0x201fff) AM_RAM AM_BASE_MEMBER(simpl156_state, systemram) // work ram (32-bit)
316274   AM_RANGE(0x3c0000, 0x3c0003) AM_DEVREADWRITE8("okimusic", okim6295_r, okim6295_w, 0x000000ff)
317   AM_RANGE(0x400000, 0x407fff) AM_READWRITE(simpl156_mainram_r, simpl156_mainram_w) AM_BASE(&simpl156_mainram) // main ram?
275   AM_RANGE(0x400000, 0x407fff) AM_READWRITE(simpl156_mainram_r, simpl156_mainram_w) AM_BASE_MEMBER(simpl156_state, mainram) // main ram?
318276   AM_RANGE(0x410000, 0x411fff) AM_READWRITE(simpl156_spriteram_r, simpl156_spriteram_w) AM_BASE_SIZE_GENERIC(spriteram)
319277   AM_RANGE(0x420000, 0x420fff) AM_READWRITE(simpl156_palette_r,simpl156_palette_w)
320278   AM_RANGE(0x430000, 0x430003) AM_READWRITE(simpl156_system_r,simpl156_eeprom_w)
321   AM_RANGE(0x440000, 0x44001f) AM_READWRITE(simpl156_pf12_control_r, simpl156_pf12_control_w)
322   AM_RANGE(0x450000, 0x451fff) AM_READWRITE(simpl156_pf1_data_r, simpl156_pf1_data_w)
323   AM_RANGE(0x452000, 0x453fff) AM_READWRITE(simpl156_pf1_data_r, simpl156_pf1_data_w)
324   AM_RANGE(0x454000, 0x455fff) AM_READWRITE(simpl156_pf2_data_r, simpl156_pf2_data_w)
279   AM_RANGE(0x440000, 0x44001f) AM_DEVREADWRITE("deco_custom", deco16ic_pf12_control_dword_r, deco16ic_pf12_control_dword_w)
280   AM_RANGE(0x450000, 0x451fff) AM_DEVREADWRITE("deco_custom", deco16ic_pf1_data_dword_r, deco16ic_pf1_data_dword_w)
281   AM_RANGE(0x452000, 0x453fff) AM_DEVREADWRITE("deco_custom", deco16ic_pf1_data_dword_r, deco16ic_pf1_data_dword_w)
282   AM_RANGE(0x454000, 0x455fff) AM_DEVREADWRITE("deco_custom", deco16ic_pf2_data_dword_r, deco16ic_pf2_data_dword_w)
325283   AM_RANGE(0x460000, 0x461fff) AM_READWRITE(simpl156_pf1_rowscroll_r, simpl156_pf1_rowscroll_w)
326284   AM_RANGE(0x464000, 0x465fff) AM_READWRITE(simpl156_pf2_rowscroll_r, simpl156_pf2_rowscroll_w)
327285   AM_RANGE(0x470000, 0x470003) AM_READONLY AM_WRITENOP // ??
r7500r7501
333291static ADDRESS_MAP_START( magdrop_map, ADDRESS_SPACE_PROGRAM, 32 )
334292   AM_RANGE(0x000000, 0x07ffff) AM_ROM
335293   AM_RANGE(0x200000, 0x200003) AM_READ(simpl156_inputs_read)
336   AM_RANGE(0x201000, 0x201fff) AM_RAM AM_BASE(&simpl156_systemram) // work ram (32-bit)
294   AM_RANGE(0x201000, 0x201fff) AM_RAM AM_BASE_MEMBER(simpl156_state, systemram) // work ram (32-bit)
337295   AM_RANGE(0x340000, 0x340003) AM_DEVREADWRITE8("okimusic", okim6295_r, okim6295_w, 0x000000ff)
338   AM_RANGE(0x380000, 0x387fff) AM_READWRITE(simpl156_mainram_r, simpl156_mainram_w) AM_BASE(&simpl156_mainram) // main ram?
296   AM_RANGE(0x380000, 0x387fff) AM_READWRITE(simpl156_mainram_r, simpl156_mainram_w) AM_BASE_MEMBER(simpl156_state, mainram) // main ram?
339297   AM_RANGE(0x390000, 0x391fff) AM_READWRITE(simpl156_spriteram_r, simpl156_spriteram_w) AM_BASE_SIZE_GENERIC(spriteram)
340298   AM_RANGE(0x3a0000, 0x3a0fff) AM_READWRITE(simpl156_palette_r,simpl156_palette_w)
341299   AM_RANGE(0x3b0000, 0x3b0003) AM_READWRITE(simpl156_system_r,simpl156_eeprom_w)
342   AM_RANGE(0x3c0000, 0x3c001f) AM_READWRITE(simpl156_pf12_control_r, simpl156_pf12_control_w)
343   AM_RANGE(0x3d0000, 0x3d1fff) AM_READWRITE(simpl156_pf1_data_r, simpl156_pf1_data_w)
344   AM_RANGE(0x3d2000, 0x3d3fff) AM_READWRITE(simpl156_pf1_data_r, simpl156_pf1_data_w)
345   AM_RANGE(0x3d4000, 0x3d5fff) AM_READWRITE(simpl156_pf2_data_r, simpl156_pf2_data_w)
300   AM_RANGE(0x3c0000, 0x3c001f) AM_DEVREADWRITE("deco_custom", deco16ic_pf12_control_dword_r, deco16ic_pf12_control_dword_w)
301   AM_RANGE(0x3d0000, 0x3d1fff) AM_DEVREADWRITE("deco_custom", deco16ic_pf1_data_dword_r, deco16ic_pf1_data_dword_w)
302   AM_RANGE(0x3d2000, 0x3d3fff) AM_DEVREADWRITE("deco_custom", deco16ic_pf1_data_dword_r, deco16ic_pf1_data_dword_w)
303   AM_RANGE(0x3d4000, 0x3d5fff) AM_DEVREADWRITE("deco_custom", deco16ic_pf2_data_dword_r, deco16ic_pf2_data_dword_w)
346304   AM_RANGE(0x3e0000, 0x3e1fff) AM_READWRITE(simpl156_pf1_rowscroll_r, simpl156_pf1_rowscroll_w)
347305   AM_RANGE(0x3e4000, 0x3e5fff) AM_READWRITE(simpl156_pf2_rowscroll_r, simpl156_pf2_rowscroll_w)
348306   AM_RANGE(0x3f0000, 0x3f0003) AM_READONLY AM_WRITENOP //?
r7500r7501
354312static ADDRESS_MAP_START( magdropp_map, ADDRESS_SPACE_PROGRAM, 32 )
355313   AM_RANGE(0x000000, 0x07ffff) AM_ROM
356314   AM_RANGE(0x200000, 0x200003) AM_READ(simpl156_inputs_read)
357   AM_RANGE(0x201000, 0x201fff) AM_RAM AM_BASE(&simpl156_systemram) // work ram (32-bit)
315   AM_RANGE(0x201000, 0x201fff) AM_RAM AM_BASE_MEMBER(simpl156_state, systemram) // work ram (32-bit)
358316   AM_RANGE(0x4c0000, 0x4c0003) AM_DEVREADWRITE8("okimusic", okim6295_r, okim6295_w, 0x000000ff)
359   AM_RANGE(0x680000, 0x687fff) AM_READWRITE(simpl156_mainram_r, simpl156_mainram_w) AM_BASE(&simpl156_mainram) // main ram?
317   AM_RANGE(0x680000, 0x687fff) AM_READWRITE(simpl156_mainram_r, simpl156_mainram_w) AM_BASE_MEMBER(simpl156_state, mainram) // main ram?
360318   AM_RANGE(0x690000, 0x691fff) AM_READWRITE(simpl156_spriteram_r, simpl156_spriteram_w) AM_BASE_SIZE_GENERIC(spriteram)
361319   AM_RANGE(0x6a0000, 0x6a0fff) AM_READWRITE(simpl156_palette_r,simpl156_palette_w)
362320   AM_RANGE(0x6b0000, 0x6b0003) AM_READWRITE(simpl156_system_r,simpl156_eeprom_w)
363   AM_RANGE(0x6c0000, 0x6c001f) AM_READWRITE(simpl156_pf12_control_r, simpl156_pf12_control_w)
364   AM_RANGE(0x6d0000, 0x6d1fff) AM_READWRITE(simpl156_pf1_data_r, simpl156_pf1_data_w)
365   AM_RANGE(0x6d2000, 0x6d3fff) AM_READWRITE(simpl156_pf1_data_r, simpl156_pf1_data_w)
366   AM_RANGE(0x6d4000, 0x6d5fff) AM_READWRITE(simpl156_pf2_data_r, simpl156_pf2_data_w)
321   AM_RANGE(0x6c0000, 0x6c001f) AM_DEVREADWRITE("deco_custom", deco16ic_pf12_control_dword_r, deco16ic_pf12_control_dword_w)
322   AM_RANGE(0x6d0000, 0x6d1fff) AM_DEVREADWRITE("deco_custom", deco16ic_pf1_data_dword_r, deco16ic_pf1_data_dword_w)
323   AM_RANGE(0x6d2000, 0x6d3fff) AM_DEVREADWRITE("deco_custom", deco16ic_pf1_data_dword_r, deco16ic_pf1_data_dword_w)
324   AM_RANGE(0x6d4000, 0x6d5fff) AM_DEVREADWRITE("deco_custom", deco16ic_pf2_data_dword_r, deco16ic_pf2_data_dword_w)
367325   AM_RANGE(0x6e0000, 0x6e1fff) AM_READWRITE(simpl156_pf1_rowscroll_r, simpl156_pf1_rowscroll_w)
368326   AM_RANGE(0x6e4000, 0x6e5fff) AM_READWRITE(simpl156_pf2_rowscroll_r, simpl156_pf2_rowscroll_w)
369327   AM_RANGE(0x6f0000, 0x6f0003) AM_READONLY AM_WRITENOP // ?
r7500r7501
376334   AM_RANGE(0x000000, 0x07ffff) AM_ROM
377335   AM_RANGE(0x100000, 0x100003) AM_DEVREADWRITE8("okisfx", okim6295_r, okim6295_w, 0x000000ff)
378336   AM_RANGE(0x140000, 0x140003) AM_DEVREADWRITE8("okimusic", okim6295_r, okim6295_w, 0x000000ff)
379   AM_RANGE(0x180000, 0x187fff) AM_READWRITE(simpl156_mainram_r, simpl156_mainram_w) AM_BASE(&simpl156_mainram) // main ram
337   AM_RANGE(0x180000, 0x187fff) AM_READWRITE(simpl156_mainram_r, simpl156_mainram_w) AM_BASE_MEMBER(simpl156_state, mainram) // main ram
380338   AM_RANGE(0x190000, 0x191fff) AM_READWRITE(simpl156_spriteram_r, simpl156_spriteram_w) AM_BASE_SIZE_GENERIC(spriteram)
381339   AM_RANGE(0x1a0000, 0x1a0fff) AM_READWRITE(simpl156_palette_r,simpl156_palette_w)
382340   AM_RANGE(0x1b0000, 0x1b0003) AM_READWRITE(simpl156_system_r,simpl156_eeprom_w)
383   AM_RANGE(0x1c0000, 0x1c001f) AM_READWRITE(simpl156_pf12_control_r, simpl156_pf12_control_w)
384   AM_RANGE(0x1d0000, 0x1d1fff) AM_READWRITE(simpl156_pf1_data_r, simpl156_pf1_data_w)
385   AM_RANGE(0x1d2000, 0x1d3fff) AM_READWRITE(simpl156_pf1_data_r, simpl156_pf1_data_w)
386   AM_RANGE(0x1d4000, 0x1d5fff) AM_READWRITE(simpl156_pf2_data_r, simpl156_pf2_data_w)
341   AM_RANGE(0x1c0000, 0x1c001f) AM_DEVREADWRITE("deco_custom", deco16ic_pf12_control_dword_r, deco16ic_pf12_control_dword_w)
342   AM_RANGE(0x1d0000, 0x1d1fff) AM_DEVREADWRITE("deco_custom", deco16ic_pf1_data_dword_r, deco16ic_pf1_data_dword_w)
343   AM_RANGE(0x1d2000, 0x1d3fff) AM_DEVREADWRITE("deco_custom", deco16ic_pf1_data_dword_r, deco16ic_pf1_data_dword_w)
344   AM_RANGE(0x1d4000, 0x1d5fff) AM_DEVREADWRITE("deco_custom", deco16ic_pf2_data_dword_r, deco16ic_pf2_data_dword_w)
387345   AM_RANGE(0x1e0000, 0x1e1fff) AM_READWRITE(simpl156_pf1_rowscroll_r, simpl156_pf1_rowscroll_w)
388346   AM_RANGE(0x1e4000, 0x1e5fff) AM_READWRITE(simpl156_pf2_rowscroll_r, simpl156_pf2_rowscroll_w)
389347   AM_RANGE(0x1f0000, 0x1f0003) AM_READONLY AM_WRITENOP // ?
390348   AM_RANGE(0x200000, 0x200003) AM_READ(simpl156_inputs_read)
391   AM_RANGE(0x201000, 0x201fff) AM_RAM AM_BASE(&simpl156_systemram) // work ram (32-bit)
349   AM_RANGE(0x201000, 0x201fff) AM_RAM AM_BASE_MEMBER(simpl156_state, systemram) // work ram (32-bit)
392350ADDRESS_MAP_END
393351
394352
r7500r7501
439397}
440398
441399
400static int simpl156_bank_callback(const int bank)
401{
402   return ((bank >> 4) & 0x7) * 0x1000;
403}
404
405static const deco16ic_interface simpl156_deco16ic_intf =
406{
407   "screen",
408   1, 0, 1,
409   0x0f, 0x0f, 0x0f, 0x0f,   /* trans masks (default values) */
410   0, 16, 0, 16, /* color base (default values) */
411   0x0f, 0x0f, 0x0f, 0x0f,   /* color masks (default values) */
412   simpl156_bank_callback,
413   simpl156_bank_callback,
414   NULL,
415   NULL
416};
417
418static MACHINE_START( simpl156 )
419{
420   simpl156_state *state = (simpl156_state *)machine->driver_data;
421
422   state->maincpu = devtag_get_device(machine, "maincpu");
423   state->deco16ic = devtag_get_device(machine, "deco_custom");
424   state->eeprom = devtag_get_device(machine, "eeprom");
425   state->okimusic = devtag_get_device(machine, "okimusic");
426}
427
442428static MACHINE_DRIVER_START( chainrec )
429
430   /* driver data */
431   MDRV_DRIVER_DATA(simpl156_state)
432
443433   /* basic machine hardware */
444
445434   MDRV_CPU_ADD("maincpu", ARM, 28000000 /* /4 */)   /*DE156*/ /* 7.000 MHz */ /* measured at 7.. seems to need 28? */
446435   MDRV_CPU_PROGRAM_MAP(chainrec_map)
447436   MDRV_CPU_VBLANK_INT("screen", simpl156_vbl_interrupt)
448437
449438   MDRV_EEPROM_93C46_ADD("eeprom")  // 93C45
450439
440   MDRV_MACHINE_START(simpl156)
441
451442   /* video hardware */
452443   MDRV_SCREEN_ADD("screen", RASTER)
453444   MDRV_SCREEN_REFRESH_RATE(58)
r7500r7501
461452   MDRV_VIDEO_START(simpl156)
462453   MDRV_VIDEO_UPDATE(simpl156)
463454
455   MDRV_DECO16IC_ADD("deco_custom", simpl156_deco16ic_intf)
456
464457   MDRV_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker")
465458
466
467459   MDRV_SOUND_ADD("okisfx", OKIM6295, 32220000/32)
468460   MDRV_SOUND_CONFIG(okim6295_interface_pin7high)
469461   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 0.6)
r7500r7501
509501MACHINE_DRIVER_END
510502
511503
512static DRIVER_INIT(simpl156)
513{
514   UINT8 *rom = memory_region(machine, "okimusic");
515   int length = memory_region_length(machine, "okimusic");
516   UINT8 *buf1 = auto_alloc_array(machine, UINT8, length);
517
518   UINT32 x;
519
520   /* hmm low address line goes to banking chip instead? */
521   for (x=0;x<length;x++)
522   {
523      UINT32 addr;
524
525      addr = BITSWAP24 (x,23,22,21,0, 20,
526                          19,18,17,16,
527                          15,14,13,12,
528                          11,10,9, 8,
529                          7, 6, 5, 4,
530                          3, 2, 1 );
531
532      buf1[addr] = rom[x];
533   }
534
535   memcpy(rom,buf1,length);
536
537   auto_free (machine, buf1);
538
539   deco56_decrypt_gfx(machine, "gfx1");
540   deco156_decrypt(machine);
541}
542
543504/*
544505
545506Joe and Mac Returns
r7500r7501
10701031*/
10711032
10721033
1034static DRIVER_INIT( simpl156 )
1035{
1036   UINT8 *rom = memory_region(machine, "okimusic");
1037   int length = memory_region_length(machine, "okimusic");
1038   UINT8 *buf1 = auto_alloc_array(machine, UINT8, length);
1039
1040   UINT32 x;
1041
1042   /* hmm low address line goes to banking chip instead? */
1043   for (x = 0; x < length; x++)
1044   {
1045      UINT32 addr;
1046
1047      addr = BITSWAP24 (x,23,22,21,0, 20,
1048                          19,18,17,16,
1049                          15,14,13,12,
1050                          11,10,9, 8,
1051                          7, 6, 5, 4,
1052                          3, 2, 1 );
1053
1054      buf1[addr] = rom[x];
1055   }
1056
1057   memcpy(rom, buf1, length);
1058
1059   auto_free(machine, buf1);
1060
1061   deco56_decrypt_gfx(machine, "gfx1");
1062   deco156_decrypt(machine);
1063}
1064
10731065/* Everything seems more stable if we run the CPU speed x4 and use Idle skips.. maybe it has an internal multipler? */
10741066static READ32_HANDLER( joemacr_speedup_r )
10751067{
1076   if (cpu_get_pc(space->cpu)==0x284)  cpu_spinuntil_time(space->cpu, ATTOTIME_IN_USEC(400));
1077   return simpl156_systemram[0x18/4];
1068   simpl156_state *state = (simpl156_state *)space->machine->driver_data;
1069   if (cpu_get_pc(space->cpu) == 0x284)
1070      cpu_spinuntil_time(space->cpu, ATTOTIME_IN_USEC(400));
1071   return state->systemram[0x18/4];
10781072}
10791073
10801074
1081static DRIVER_INIT (joemacr)
1075static DRIVER_INIT( joemacr )
10821076{
10831077   memory_install_read32_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x0201018, 0x020101b, 0, 0, joemacr_speedup_r );
10841078   DRIVER_INIT_CALL(simpl156);
r7500r7501
10861080
10871081static READ32_HANDLER( chainrec_speedup_r )
10881082{
1089   if (cpu_get_pc(space->cpu)==0x2d4)  cpu_spinuntil_time(space->cpu, ATTOTIME_IN_USEC(400));
1090   return simpl156_systemram[0x18/4];
1083   simpl156_state *state = (simpl156_state *)space->machine->driver_data;
1084   if (cpu_get_pc(space->cpu) == 0x2d4)
1085      cpu_spinuntil_time(space->cpu, ATTOTIME_IN_USEC(400));
1086   return state->systemram[0x18/4];
10911087}
10921088
1093static DRIVER_INIT (chainrec)
1089static DRIVER_INIT( chainrec )
10941090{
10951091   memory_install_read32_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x0201018, 0x020101b, 0, 0, chainrec_speedup_r );
10961092   DRIVER_INIT_CALL(simpl156);
r7500r7501
10981094
10991095static READ32_HANDLER( prtytime_speedup_r )
11001096{
1101   if (cpu_get_pc(space->cpu)==0x4f0)  cpu_spinuntil_time(space->cpu, ATTOTIME_IN_USEC(400));
1102   return simpl156_systemram[0xae0/4];
1097   simpl156_state *state = (simpl156_state *)space->machine->driver_data;
1098   if (cpu_get_pc(space->cpu) == 0x4f0)
1099      cpu_spinuntil_time(space->cpu, ATTOTIME_IN_USEC(400));
1100   return state->systemram[0xae0/4];
11031101}
11041102
1105static DRIVER_INIT (prtytime)
1103static DRIVER_INIT( prtytime )
11061104{
11071105   memory_install_read32_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x0201ae0, 0x0201ae3, 0, 0, prtytime_speedup_r );
11081106   DRIVER_INIT_CALL(simpl156);
r7500r7501
11111109
11121110static READ32_HANDLER( charlien_speedup_r )
11131111{
1114   if (cpu_get_pc(space->cpu)==0xc8c8)  cpu_spinuntil_time(space->cpu, ATTOTIME_IN_USEC(400));
1115   return simpl156_systemram[0x10/4];
1112   simpl156_state *state = (simpl156_state *)space->machine->driver_data;
1113   if (cpu_get_pc(space->cpu) == 0xc8c8)
1114      cpu_spinuntil_time(space->cpu, ATTOTIME_IN_USEC(400));
1115   return state->systemram[0x10/4];
11161116}
11171117
1118static DRIVER_INIT (charlien)
1118static DRIVER_INIT( charlien )
11191119{
11201120   memory_install_read32_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x0201010, 0x0201013, 0, 0, charlien_speedup_r );
11211121   DRIVER_INIT_CALL(simpl156);
r7500r7501
11231123
11241124static READ32_HANDLER( osman_speedup_r )
11251125{
1126   if (cpu_get_pc(space->cpu)==0x5974)  cpu_spinuntil_time(space->cpu, ATTOTIME_IN_USEC(400));
1127   return simpl156_systemram[0x10/4];
1126   simpl156_state *state = (simpl156_state *)space->machine->driver_data;
1127   if (cpu_get_pc(space->cpu) == 0x5974)
1128      cpu_spinuntil_time(space->cpu, ATTOTIME_IN_USEC(400));
1129   return state->systemram[0x10/4];
11281130}
11291131
1130static DRIVER_INIT (osman)
1132static DRIVER_INIT( osman )
11311133{
11321134   memory_install_read32_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0x0201010, 0x0201013, 0, 0, osman_speedup_r );
11331135   DRIVER_INIT_CALL(simpl156);
r7500r7501
11351137}
11361138
11371139/* Data East games running on the DE-0409-1 or DE-0491-1 PCB */
1138GAME( 1994, joemacr,  0,        joemacr,     simpl156, joemacr,  ROT0, "Data East", "Joe & Mac Returns (World, Version 1.1, 1994.05.27)", 0 ) /* bootleg board with genuine DECO parts */
1139GAME( 1994, joemacra, joemacr,  joemacr,     simpl156, joemacr,  ROT0, "Data East", "Joe & Mac Returns (World, Version 1.0, 1994.05.19)", 0 )
1140GAME( 1995, chainrec, 0,        chainrec,    simpl156, chainrec, ROT0, "Data East", "Chain Reaction (World, Version 2.2, 1995.09.25)", 0 )
1141GAME( 1995, magdrop,  chainrec, magdrop,     simpl156, chainrec, ROT0, "Data East", "Magical Drop (Japan, Version 1.1, 1995.06.21)", 0 )
1142GAME( 1995, magdropp, chainrec, magdropp,    simpl156, chainrec, ROT0, "Data East", "Magical Drop Plus 1 (Japan, Version 2.1, 1995.09.12)", 0 )
1140GAME( 1994, joemacr,  0,        joemacr,     simpl156, joemacr,  ROT0, "Data East", "Joe & Mac Returns (World, Version 1.1, 1994.05.27)", GAME_SUPPORTS_SAVE ) /* bootleg board with genuine DECO parts */
1141GAME( 1994, joemacra, joemacr,  joemacr,     simpl156, joemacr,  ROT0, "Data East", "Joe & Mac Returns (World, Version 1.0, 1994.05.19)", GAME_SUPPORTS_SAVE )
1142GAME( 1995, chainrec, 0,        chainrec,    simpl156, chainrec, ROT0, "Data East", "Chain Reaction (World, Version 2.2, 1995.09.25)", GAME_SUPPORTS_SAVE )
1143GAME( 1995, magdrop,  chainrec, magdrop,     simpl156, chainrec, ROT0, "Data East", "Magical Drop (Japan, Version 1.1, 1995.06.21)", GAME_SUPPORTS_SAVE )
1144GAME( 1995, magdropp, chainrec, magdropp,    simpl156, chainrec, ROT0, "Data East", "Magical Drop Plus 1 (Japan, Version 2.1, 1995.09.12)", GAME_SUPPORTS_SAVE )
11431145
11441146/* Mitchell games running on the DEC-22VO / MT5601-0 PCB */
1145GAME( 1995, charlien, 0,        mitchell156, simpl156, charlien, ROT0,  "Mitchell", "Charlie Ninja" , 0) /* language in service mode */
1146GAME( 1995, prtytime, 0,        mitchell156, simpl156, prtytime, ROT90, "Mitchell", "Party Time: Gonta the Diver II / Ganbare! Gonta!! 2 (World Release)", 0) /* language in service mode */
1147GAME( 1995, gangonta, prtytime, mitchell156, simpl156, prtytime, ROT90, "Mitchell", "Ganbare! Gonta!! 2 / Party Time: Gonta the Diver II (Japan Release)", 0) /* language in service mode */
1148GAME( 1996, osman,    0,        mitchell156, simpl156, osman,    ROT0,  "Mitchell", "Osman (World)", 0 )
1149GAME( 1996, candance, osman,    mitchell156, simpl156, osman,    ROT0,  "Mitchell (Atlus License)", "Cannon Dancer (Japan)", 0 )
1147GAME( 1995, charlien, 0,        mitchell156, simpl156, charlien, ROT0,  "Mitchell", "Charlie Ninja" , GAME_SUPPORTS_SAVE ) /* language in service mode */
1148GAME( 1995, prtytime, 0,        mitchell156, simpl156, prtytime, ROT90, "Mitchell", "Party Time: Gonta the Diver II / Ganbare! Gonta!! 2 (World Release)", GAME_SUPPORTS_SAVE ) /* language in service mode */
1149GAME( 1995, gangonta, prtytime, mitchell156, simpl156, prtytime, ROT90, "Mitchell", "Ganbare! Gonta!! 2 / Party Time: Gonta the Diver II (Japan Release)", GAME_SUPPORTS_SAVE ) /* language in service mode */
1150GAME( 1996, osman,    0,        mitchell156, simpl156, osman,    ROT0,  "Mitchell", "Osman (World)", GAME_SUPPORTS_SAVE )
1151GAME( 1996, candance, osman,    mitchell156, simpl156, osman,    ROT0,  "Mitchell (Atlus License)", "Cannon Dancer (Japan)", GAME_SUPPORTS_SAVE )
src/mame/drivers/twincobr.c
r7500r7501
2626    Comad game number:      ???
2727        GulfWar II (Game play very similar to Twin cobra)
2828
29
2930Difference between Twin Cobra and Kyukyoko Tiger:
3031    T.C. supports two simultaneous players.
3132    K.T. supports two players, but only one at a time.
r7500r7501
4647    K.T. Due to this difference in continue sequence, Kyukyoko Tiger is MUCH
4748         harder, challenging, and nearly impossible to complete !
4849
50
51Stephh's notes (based on the games M68000 and Z80 code and some tests) :
52
531) 'twincobr' and "clones"
54
55  - There is no real "test mode" : only a grid with colors ("Cross Hatch Pattern")
56    is displayed. There is a specific "Show Dip Switches Settings".
57
581a) 'twincobr'
59
60  - No notice screen.
61  - Game uses TOAPLAN_COINAGE_WORLD (code at 0x0bfd in CPU1).
62  - Press any players buttons on startup to skip some tests (code at 0x025ed8).
63
641b) 'twincobru'
65
66  - "FOR USE IN U.S.A. ONLY" notice screen.
67  - Game uses TOAPLAN_COINAGE_JAPAN_OLD (code at 0x0bfd in CPU1).
68  - Press any players buttons on startup to skip some tests (code at 0x025ed6).
69
701c) 'ktiger'
71
72  - "FOR USE IN JAPAN ONLY" notice screen.
73  - Game uses TOAPLAN_COINAGE_JAPAN_OLD (code at 0x0bfd in CPU1 - same as in 'twincobru').
74  - Press any players buttons on startup to skip some tests (code at 0x0259d0).
75  - "Bonus Lives" settings are different than the ones in the other sets.
76  - See other differences with 'twincobr' and 'twincobru' above.
77
781d) 'gulfwar2'
79
80  - No notice screen.
81  - Game uses TOAPLAN_COINAGE_JAPAN_OLD (code at 0x0bfd in CPU1 - same as in 'twincobru').
82    Surprisingly, when Dip Switches are displayed, it shows TOAPLAN_COINAGE_WORLD.
83  - Press any players buttons on startup to skip some tests (code at 0x025ed8).
84  - VBLANK bit is inverted (ACTIVE_LOW instead of ACTIVE_HIGH).
85
86
872) 'fshark' and "clones"
88
89  - There is no real "test mode" : only a grid with colors ("Cross Hatch Pattern")
90    is displayed. There is a specific "Show Dip Switches Settings".
91
922a) 'fshark'
93
94  - No notice screen.
95  - Game uses TOAPLAN_COINAGE_WORLD.
96  - When cabinet set to "Upright", you can use joystick and buttons from both players
97    (code at 0x002434).
98
992b) 'skyshark'
100
101  - "FOR USE IN U.S.A. ONLY" notice screen.
102  - Game uses a specific coinage.
103  - When cabinet set to "Upright", you can use joystick and buttons from both players
104    (code at 0x002436).
105
1062c) 'hishouza'
107
108  - "FOR USE IN JAPAN ONLY" notice screen.
109  - Game uses TOAPLAN_COINAGE_JAPAN_OLD.
110  - When cabinet set to "Upright", you can use joystick and buttons from both players
111    (code at 0x002456).
112
1132d) 'fsharkbt'
114
115  - This bootleg is heavily based on 'skyshark', so they share the same infos.
116    However, the values written to the DSP (0x030004) are the same as in 'hishouza'
117    and the chars ROMS (gfx1) are the same as in 'fshark' !
118
49119**************************** Memory & I/O Maps *****************************
5012068000: Main CPU
51121
r7500r7501
191261#include "cpu/z80/z80.h"
192262#include "cpu/m68000/m68000.h"
193263#include "cpu/tms32010/tms32010.h"
264#include "includes/toaplipt.h"
194265#include "includes/twincobr.h"
195266#include "sound/3812intf.h"
196267
r7500r7501
268339    Input Port definitions
269340*****************************************************************************/
270341
271#define  TOAPLAN_PLAYER_INPUT( player )                               \
272   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP ) PORT_PLAYER(player) PORT_8WAY \
273   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN ) PORT_PLAYER(player) PORT_8WAY \
274   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT ) PORT_PLAYER(player) PORT_8WAY \
275   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT ) PORT_PLAYER(player) PORT_8WAY \
276   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_PLAYER(player)                \
277   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_BUTTON2 ) PORT_PLAYER(player)                \
278   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_UNKNOWN )                      \
279   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_UNKNOWN )
280
281#define  TOAPLAN_JAPAN_DSW_A                     \
282   PORT_DIPNAME( 0x01, 0x01, DEF_STR( Cabinet ) )      \
283   PORT_DIPSETTING(   0x01, DEF_STR( Upright ) )      \
284   PORT_DIPSETTING(   0x00, DEF_STR( Cocktail ) )      \
285   PORT_DIPNAME( 0x02, 0x00, DEF_STR( Flip_Screen ) )   \
286   PORT_DIPSETTING(   0x00, DEF_STR( Off ) )         \
287   PORT_DIPSETTING(   0x02, DEF_STR( On ) )         \
288   PORT_DIPNAME( 0x04, 0x00, "Cross Hatch Pattern" )   \
289   PORT_DIPSETTING(   0x00, DEF_STR( Off ) )         \
290   PORT_DIPSETTING(   0x04, DEF_STR( On ) )         \
291   PORT_DIPNAME( 0x08, 0x00, DEF_STR( Demo_Sounds ) )   \
292   PORT_DIPSETTING(   0x08, DEF_STR( Off ) )         \
293   PORT_DIPSETTING(   0x00, DEF_STR( On ) )         \
294   PORT_DIPNAME( 0x30, 0x00, DEF_STR( Coin_A ) )      \
295   PORT_DIPSETTING(   0x20, DEF_STR( 2C_1C ) )      \
296   PORT_DIPSETTING(   0x00, DEF_STR( 1C_1C ) )      \
297   PORT_DIPSETTING(   0x30, DEF_STR( 2C_3C ) )      \
298   PORT_DIPSETTING(   0x10, DEF_STR( 1C_2C ) )      \
299   PORT_DIPNAME( 0xc0, 0x00, DEF_STR( Coin_B ) )      \
300   PORT_DIPSETTING(   0x80, DEF_STR( 2C_1C ) )      \
301   PORT_DIPSETTING(   0x00, DEF_STR( 1C_1C ) )      \
302   PORT_DIPSETTING(   0xc0, DEF_STR( 2C_3C ) )      \
303   PORT_DIPSETTING(   0x40, DEF_STR( 1C_2C ) )
304
305#define  TWINCOBR_VBLANK_INPUT( active_level )      \
306   PORT_BIT( 0x7f, active_level, IPT_UNKNOWN )      \
307   PORT_BIT( 0x80, active_level, IPT_VBLANK )
308
309#define  TWINCOBR_SYSTEM_INPUTS                     \
310   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_COIN3 )         \
311   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_TILT )         \
312   PORT_DIPNAME( 0x04, 0x00, "Cross Hatch Pattern" )   \
313   PORT_DIPSETTING(   0x00, DEF_STR( Off ) )         \
314   PORT_DIPSETTING(   0x04, DEF_STR( On ) )         \
315   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_COIN1 )         \
316   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_COIN2 )         \
317   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_START1 )      \
318   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_START2 )      \
319   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_UNKNOWN )
320
321#define TWINCOBR_DSW_B      /* not KTIGER */         \
322   PORT_DIPNAME( 0x03, 0x00, DEF_STR( Difficulty ) )   \
323   PORT_DIPSETTING(   0x01, DEF_STR( Easy ) )               \
324   PORT_DIPSETTING(   0x00, DEF_STR( Normal ) )            \
325   PORT_DIPSETTING(   0x02, DEF_STR( Hard ) )               \
326   PORT_DIPSETTING(   0x03, DEF_STR( Hardest ) )            \
327   PORT_DIPNAME( 0x0c, 0x00, DEF_STR( Bonus_Life ) )   \
328   PORT_DIPSETTING(   0x00, "50K, then every 150K" )   \
329   PORT_DIPSETTING(   0x04, "70K, then every 200K" )   \
330   PORT_DIPSETTING(   0x08, "50000" )               \
331   PORT_DIPSETTING(   0x0c, "100000" )            \
332   PORT_DIPNAME( 0x30, 0x00, DEF_STR( Lives ) )      \
333   PORT_DIPSETTING(   0x30, "2" )                  \
334   PORT_DIPSETTING(   0x00, "3" )                  \
335   PORT_DIPSETTING(   0x20, "4" )                  \
336   PORT_DIPSETTING(   0x10, "5" )                  \
337   PORT_DIPNAME( 0x40, 0x00, "Show DIP SW Settings" )   \
338   PORT_DIPSETTING(   0x00, DEF_STR( No ) )         \
339   PORT_DIPSETTING(   0x40, DEF_STR( Yes ) )         \
340   PORT_DIPNAME( 0x80, 0x00, DEF_STR( Unknown ) )      \
341   PORT_DIPSETTING(   0x00, DEF_STR( Off ) )         \
342   PORT_DIPSETTING(   0x80, DEF_STR( On ) )
343
344#define  FSHARK_SYSTEM_INPUTS      /* V-Blank is also here */             \
345   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_COIN3 )                         \
346   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_TILT )      /* tilt causes freeze */ \
347   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_UNUSED )   /* reset button */       \
348   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_COIN1 )                         \
349   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_COIN2 )                         \
350   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_START1 )                      \
351   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_START2 )                      \
352   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_VBLANK )
353
354#define FSHARK_DSW_B                           \
355   PORT_DIPNAME( 0x03, 0x00, DEF_STR( Difficulty ) )   \
356   PORT_DIPSETTING(   0x01, DEF_STR( Easy ) )               \
357   PORT_DIPSETTING(   0x00, DEF_STR( Normal ) )            \
358   PORT_DIPSETTING(   0x02, DEF_STR( Hard ) )               \
359   PORT_DIPSETTING(   0x03, DEF_STR( Hardest ) )            \
360   PORT_DIPNAME( 0x0c, 0x00, DEF_STR( Bonus_Life ) )   \
361   PORT_DIPSETTING(   0x00, "50K, then every 150K" )   \
362   PORT_DIPSETTING(   0x04, "70K, then every 200K" )   \
363   PORT_DIPSETTING(   0x08, "50000" )               \
364   PORT_DIPSETTING(   0x0c, "100000" )            \
365   PORT_DIPNAME( 0x30, 0x00, DEF_STR( Lives ) )      \
366   PORT_DIPSETTING(   0x20, "1" )                  \
367   PORT_DIPSETTING(   0x30, "2" )                  \
368   PORT_DIPSETTING(   0x00, "3" )                  \
369   PORT_DIPSETTING(   0x10, "5" )                  \
370   PORT_DIPNAME( 0x40, 0x00, "Show DIP SW Settings" )   \
371   PORT_DIPSETTING(   0x00, DEF_STR( No ) )         \
372   PORT_DIPSETTING(   0x40, DEF_STR( Yes ) )         \
373   PORT_DIPNAME( 0x80, 0x80, DEF_STR( Allow_Continue ) )      \
374   PORT_DIPSETTING(   0x00, DEF_STR( No ) )         \
375   PORT_DIPSETTING(   0x80, DEF_STR( Yes ) )
376
377
378
379
342/* verified from M68000 and Z80 code */
380343static INPUT_PORTS_START( twincobr )
381   PORT_START("VBLANK")
382   TWINCOBR_VBLANK_INPUT( IP_ACTIVE_HIGH )
344   PORT_START("DSWA")
345   TOAPLAN_MACHINE_NO_COCKTAIL
346   TOAPLAN_COINAGE_WORLD                                   /* tables at 0x0c30 (COIN1) and 0x0c38 (COIN2) in CPU1 */
383347
348   PORT_START("DSWB")
349   TOAPLAN_DIFFICULTY
350   PORT_DIPNAME( 0x0c, 0x00, DEF_STR( Bonus_Life ) )       /* table at 0x020988 ('twincobr' and 'twincobru') */
351   PORT_DIPSETTING(   0x00, "50k 200k 150k+" )
352   PORT_DIPSETTING(   0x04, "70k 270k 200k+" )
353   PORT_DIPSETTING(   0x08, "50k Only" )
354   PORT_DIPSETTING(   0x0c, "100k Only" )
355   PORT_DIPNAME( 0x30, 0x00, DEF_STR( Lives ) )
356   PORT_DIPSETTING(   0x30, "2" )
357   PORT_DIPSETTING(   0x00, "3" )
358   PORT_DIPSETTING(   0x20, "4" )
359   PORT_DIPSETTING(   0x10, "5" )
360   PORT_DIPNAME( 0x40, 0x00, "Show Dip Switches Settings" )
361   PORT_DIPSETTING(   0x00, DEF_STR( No ) )
362   PORT_DIPSETTING(   0x40, DEF_STR( Yes ) )
363   PORT_DIPUNUSED( 0x80, IP_ACTIVE_HIGH )
364
384365   PORT_START("P1")
385   TOAPLAN_PLAYER_INPUT( 1 )
366   TOAPLAN_JOY_UDLR_2_BUTTONS( 1 )
386367
387368   PORT_START("P2")
388   TOAPLAN_PLAYER_INPUT( 2 )
369   TOAPLAN_JOY_UDLR_2_BUTTONS( 2 )
389370
390   PORT_START("DSWA")
391   PORT_DIPNAME( 0x01, 0x00, DEF_STR( Unknown ) )
392   PORT_DIPSETTING(   0x00, DEF_STR( Off ) )
393   PORT_DIPSETTING(   0x01, DEF_STR( On ) )
394   PORT_DIPNAME( 0x02, 0x00, DEF_STR( Flip_Screen ) )
395   PORT_DIPSETTING(   0x00, DEF_STR( Off ) )
396   PORT_DIPSETTING(   0x02, DEF_STR( On ) )
397   PORT_DIPNAME( 0x04, 0x00, "Cross Hatch Pattern" )
398   PORT_DIPSETTING(   0x00, DEF_STR( Off ) )
399   PORT_DIPSETTING(   0x04, DEF_STR( On ) )
400   PORT_DIPNAME( 0x08, 0x00, DEF_STR( Demo_Sounds ) )
401   PORT_DIPSETTING(   0x08, DEF_STR( Off ) )
402   PORT_DIPSETTING(   0x00, DEF_STR( On ) )
403   PORT_DIPNAME( 0x30, 0x00, DEF_STR( Coin_A ) )
404   PORT_DIPSETTING(   0x30, DEF_STR( 4C_1C ) )
405   PORT_DIPSETTING(   0x20, DEF_STR( 3C_1C ) )
406   PORT_DIPSETTING(   0x10, DEF_STR( 2C_1C ) )
407   PORT_DIPSETTING(   0x00, DEF_STR( 1C_1C ) )
408   PORT_DIPNAME( 0xc0, 0x00, DEF_STR( Coin_B ) )
409   PORT_DIPSETTING(   0x00, DEF_STR( 1C_2C ) )
410   PORT_DIPSETTING(   0x40, DEF_STR( 1C_3C ) )
411   PORT_DIPSETTING(   0x80, DEF_STR( 1C_4C ) )
412   PORT_DIPSETTING(   0xc0, DEF_STR( 1C_6C ) )
413
414   PORT_START("DSWB")
415   TWINCOBR_DSW_B
416
417371   PORT_START("SYSTEM")
418   TWINCOBR_SYSTEM_INPUTS
419INPUT_PORTS_END
372   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_SERVICE1 )          /* uses COIN1 coinage */
373   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_TILT )
374   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_UNUSED )            /* same effect as the DSWA bit 2 */
375   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_COIN1 )
376   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_COIN2 )
377   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_START1 )
378   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_START2 )
379   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_UNUSED )
420380
421static INPUT_PORTS_START( twincobu )
422381   PORT_START("VBLANK")
423   TWINCOBR_VBLANK_INPUT( IP_ACTIVE_HIGH )
382   PORT_BIT( 0x7f, IP_ACTIVE_HIGH, IPT_UNUSED )
383   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_VBLANK )
384INPUT_PORTS_END
424385
425   PORT_START("P1")
426   TOAPLAN_PLAYER_INPUT( 1 )
386/* verified from M68000 and Z80 code */
387static INPUT_PORTS_START( twincobru )
388   PORT_INCLUDE( twincobr )
427389
428   PORT_START("P2")
429   TOAPLAN_PLAYER_INPUT( 2 )
390   PORT_MODIFY("DSWA")
391   TOAPLAN_COINAGE_JAPAN_OLD                               /* table at 0x0c20 (COIN1 AND COIN2) in CPU1 */
392INPUT_PORTS_END
430393
431   PORT_START("DSWA")
432   PORT_DIPNAME( 0x01, 0x00, DEF_STR( Unknown ) )
433   PORT_DIPSETTING(   0x00, DEF_STR( Off ) )
434   PORT_DIPSETTING(   0x01, DEF_STR( On ) )
435   PORT_DIPNAME( 0x02, 0x00, DEF_STR( Flip_Screen ) )
436   PORT_DIPSETTING(   0x00, DEF_STR( Off ) )
437   PORT_DIPSETTING(   0x02, DEF_STR( On ) )
438   PORT_DIPNAME( 0x04, 0x00, "Cross Hatch Pattern" )
439   PORT_DIPSETTING(   0x00, DEF_STR( Off ) )
440   PORT_DIPSETTING(   0x04, DEF_STR( On ) )
441   PORT_DIPNAME( 0x08, 0x00, DEF_STR( Demo_Sounds ) )
442   PORT_DIPSETTING(   0x08, DEF_STR( Off ) )
443   PORT_DIPSETTING(   0x00, DEF_STR( On ) )
444   PORT_DIPNAME( 0x30, 0x00, DEF_STR( Coin_A ) )
445   PORT_DIPSETTING(   0x20, DEF_STR( 2C_1C ) )
446   PORT_DIPSETTING(   0x00, DEF_STR( 1C_1C ) )
447   PORT_DIPSETTING(   0x30, DEF_STR( 2C_3C ) )
448   PORT_DIPSETTING(   0x10, DEF_STR( 1C_2C ) )
449   PORT_DIPNAME( 0xc0, 0x00, DEF_STR( Coin_B ) )
450   PORT_DIPSETTING(   0x80, DEF_STR( 2C_1C ) )
451   PORT_DIPSETTING(   0x00, DEF_STR( 1C_1C ) )
452   PORT_DIPSETTING(   0xc0, DEF_STR( 2C_3C ) )
453   PORT_DIPSETTING(   0x40, DEF_STR( 1C_2C ) )
394/* verified from M68000 and Z80 code */
395static INPUT_PORTS_START( ktiger )
396   PORT_INCLUDE( twincobru )
454397
455   PORT_START("DSWB")
456   TWINCOBR_DSW_B
398   PORT_MODIFY("DSWA")
399   TOAPLAN_MACHINE_COCKTAIL
457400
458   PORT_START("SYSTEM")
459   TWINCOBR_SYSTEM_INPUTS
401   PORT_MODIFY("DSWB")
402   PORT_DIPNAME( 0x0c, 0x00, DEF_STR( Bonus_Life ) )       /* table at 0x0208d0 */
403   PORT_DIPSETTING(   0x04, "50k 200k 150k+" )
404   PORT_DIPSETTING(   0x00, "70k 270k 200k+" )
405   PORT_DIPSETTING(   0x08, "100k Only" )
406   PORT_DIPSETTING(   0x0c, DEF_STR( None ) )
407   PORT_DIPNAME( 0x80, 0x80, DEF_STR( Allow_Continue ) )   /* additional code at 0x020b3c */
408   PORT_DIPSETTING(   0x00, DEF_STR( No ) )
409   PORT_DIPSETTING(   0x80, DEF_STR( Yes ) )
460410INPUT_PORTS_END
461411
462static INPUT_PORTS_START( ktiger )
463   PORT_START("VBLANK")
464   TWINCOBR_VBLANK_INPUT( IP_ACTIVE_HIGH )
412/* verified from M68000 and Z80 code */
413static INPUT_PORTS_START( gulfwar2 )
414   PORT_INCLUDE( twincobru )
465415
466   PORT_START("P1")
467   TOAPLAN_PLAYER_INPUT( 1 )
416   PORT_MODIFY("VBLANK")
417   PORT_BIT( 0x7f, IP_ACTIVE_LOW, IPT_UNUSED )
418   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_VBLANK )
419INPUT_PORTS_END
468420
469   PORT_START("P2")
470   TOAPLAN_PLAYER_INPUT( 2 )
471421
422/* verified from M68000 code */
423static INPUT_PORTS_START( fshark )
472424   PORT_START("DSWA")
473   TOAPLAN_JAPAN_DSW_A
425   TOAPLAN_MACHINE_COCKTAIL
426   TOAPLAN_COINAGE_WORLD                                   /* tables at 0x00031c (COIN1) and 0x00032c (COIN2) */
474427
475428   PORT_START("DSWB")
476   PORT_DIPNAME( 0x03, 0x00, DEF_STR( Difficulty ) )
477   PORT_DIPSETTING(   0x01, DEF_STR( Easy ) )
478   PORT_DIPSETTING(   0x00, DEF_STR( Normal ) )
479   PORT_DIPSETTING(   0x02, DEF_STR( Hard ) )
480   PORT_DIPSETTING(   0x03, DEF_STR( Hardest ) )
481   PORT_DIPNAME( 0x0c, 0x00, DEF_STR( Bonus_Life ) )
482   PORT_DIPSETTING(   0x00, "70K, then every 200K" )
483   PORT_DIPSETTING(   0x04, "50K, then every 150K" )
484   PORT_DIPSETTING(   0x08, "100000" )
485   PORT_DIPSETTING(   0x0c, "No Extend" )
429   TOAPLAN_DIFFICULTY
430   PORT_DIPNAME( 0x0c, 0x00, DEF_STR( Bonus_Life ) )       /* table at 0x000b96 (fshark), 0x000b80 (skyshark) or 0x000b7e (hishouza) */
431   PORT_DIPSETTING(   0x00, "50k 200k 150k+" )
432   PORT_DIPSETTING(   0x04, "70k 270k 200k+" )
433   PORT_DIPSETTING(   0x08, "50k Only" )
434   PORT_DIPSETTING(   0x0c, "100k Only" )
486435   PORT_DIPNAME( 0x30, 0x00, DEF_STR( Lives ) )
436   PORT_DIPSETTING(   0x20, "1" )
487437   PORT_DIPSETTING(   0x30, "2" )
488438   PORT_DIPSETTING(   0x00, "3" )
489   PORT_DIPSETTING(   0x20, "4" )
490439   PORT_DIPSETTING(   0x10, "5" )
491   PORT_DIPNAME( 0x40, 0x00, "Show DIP SW Settings" )
440   PORT_DIPNAME( 0x40, 0x00, "Show Dip Switches Settings" )
492441   PORT_DIPSETTING(   0x00, DEF_STR( No ) )
493442   PORT_DIPSETTING(   0x40, DEF_STR( Yes ) )
494443   PORT_DIPNAME( 0x80, 0x80, DEF_STR( Allow_Continue ) )
495444   PORT_DIPSETTING(   0x00, DEF_STR( No ) )
496445   PORT_DIPSETTING(   0x80, DEF_STR( Yes ) )
497446
498   PORT_START("SYSTEM")
499   TWINCOBR_SYSTEM_INPUTS
500INPUT_PORTS_END
501
502static INPUT_PORTS_START( fshark )
503   PORT_START("VBLANK")
504   FSHARK_SYSTEM_INPUTS
505
506447   PORT_START("P1")
507   TOAPLAN_PLAYER_INPUT( 1 )
448   TOAPLAN_JOY_UDLR_2_BUTTONS( 1 )
508449
509450   PORT_START("P2")
510   TOAPLAN_PLAYER_INPUT( 2 )
451   TOAPLAN_JOY_UDLR_2_BUTTONS( 2 )
511452
512   PORT_START("DSWA")
513   PORT_DIPNAME( 0x01, 0x01, DEF_STR( Cabinet ) )
514   PORT_DIPSETTING(   0x01, DEF_STR( Upright ) )
515   PORT_DIPSETTING(   0x00, DEF_STR( Cocktail ) )
516   PORT_DIPNAME( 0x02, 0x00, DEF_STR( Flip_Screen ) )
517   PORT_DIPSETTING(   0x00, DEF_STR( Off ) )
518   PORT_DIPSETTING(   0x02, DEF_STR( On ) )
519   PORT_DIPNAME( 0x04, 0x00, "Cross Hatch Pattern" )
520   PORT_DIPSETTING(   0x00, DEF_STR( Off ) )
521   PORT_DIPSETTING(   0x04, DEF_STR( On ) )
522   PORT_DIPNAME( 0x08, 0x00, DEF_STR( Demo_Sounds ) )
523   PORT_DIPSETTING(   0x08, DEF_STR( Off ) )
524   PORT_DIPSETTING(   0x00, DEF_STR( On ) )
525   PORT_DIPNAME( 0x30, 0x00, DEF_STR( Coin_A ) )
526   PORT_DIPSETTING(   0x30, DEF_STR( 4C_1C ) )
527   PORT_DIPSETTING(   0x20, DEF_STR( 3C_1C ) )
528   PORT_DIPSETTING(   0x10, DEF_STR( 2C_1C ) )
529   PORT_DIPSETTING(   0x00, DEF_STR( 1C_1C ) )
530   PORT_DIPNAME( 0xc0, 0x00, DEF_STR( Coin_B ) )
531   PORT_DIPSETTING(   0x00, DEF_STR( 1C_2C ) )
532   PORT_DIPSETTING(   0x40, DEF_STR( 1C_3C ) )
533   PORT_DIPSETTING(   0x80, DEF_STR( 1C_4C ) )
534   PORT_DIPSETTING(   0xc0, DEF_STR( 1C_6C ) )
535
536   PORT_START("DSWB")
537   FSHARK_DSW_B
538
539   PORT_START("SYSTEM")
453   PORT_START("SYSTEM")      /* Port name kept to fit other games in the driver - it doesn't even exist */
540454   PORT_BIT( 0xff, IP_ACTIVE_HIGH, IPT_UNUSED )
455
456   PORT_START("VBLANK")      /* Port name kept to fit other games in the driver - it shall be "SYSTEM" */
457   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_SERVICE1 )          /* uses COIN1 coinage */
458   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_TILT )
459   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_UNUSED )            /* reset button */
460   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_COIN1 )
461   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_COIN2 )
462   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_START1 )
463   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_START2 )
464   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_VBLANK )
541465INPUT_PORTS_END
542466
467/* verified from M68000 code */
543468static INPUT_PORTS_START( skyshark )
544   PORT_START("VBLANK")
545   FSHARK_SYSTEM_INPUTS
469   PORT_INCLUDE( fshark )
546470
547   PORT_START("P1")
548   TOAPLAN_PLAYER_INPUT( 1 )
549
550   PORT_START("P2")
551   TOAPLAN_PLAYER_INPUT( 2 )
552
553   PORT_START("DSWA")
554   PORT_DIPNAME( 0x01, 0x01, DEF_STR( Cabinet ) )
555   PORT_DIPSETTING(   0x01, DEF_STR( Upright ) )
556   PORT_DIPSETTING(   0x00, DEF_STR( Cocktail ) )
557   PORT_DIPNAME( 0x02, 0x00, DEF_STR( Flip_Screen ) )
558   PORT_DIPSETTING(   0x00, DEF_STR( Off ) )
559   PORT_DIPSETTING(   0x02, DEF_STR( On ) )
560   PORT_DIPNAME( 0x04, 0x00, "Cross Hatch Pattern" )
561   PORT_DIPSETTING(   0x00, DEF_STR( Off ) )
562   PORT_DIPSETTING(   0x04, DEF_STR( On ) )
563   PORT_DIPNAME( 0x08, 0x00, DEF_STR( Demo_Sounds ) )
564   PORT_DIPSETTING(   0x08, DEF_STR( Off ) )
565   PORT_DIPSETTING(   0x00, DEF_STR( On ) )
566   PORT_DIPNAME( 0x30, 0x00, DEF_STR( Coin_A ) )
471   PORT_MODIFY("DSWA")
472   PORT_DIPNAME( 0x30, 0x00, DEF_STR( Coin_A ) )           /* table at 0x000316 */
567473   PORT_DIPSETTING(   0x10, DEF_STR( 2C_1C ) )
568474   PORT_DIPSETTING(   0x00, DEF_STR( 1C_1C ) )
569475   PORT_DIPSETTING(   0x20, DEF_STR( 1C_2C ) )
570/*  PORT_DIPSETTING(    0x30, DEF_STR( 1C_2C ) )    Same as previous */
571   PORT_DIPNAME( 0xc0, 0x00, DEF_STR( Coin_B ) )
476//  PORT_DIPSETTING(    0x30, DEF_STR( 1C_2C ) )            /* duplicated setting */
477   PORT_DIPNAME( 0xc0, 0x00, DEF_STR( Coin_B ) )           /* table at 0x000316 */
572478   PORT_DIPSETTING(   0x40, DEF_STR( 2C_1C ) )
573479   PORT_DIPSETTING(   0x00, DEF_STR( 1C_1C ) )
574480   PORT_DIPSETTING(   0x80, DEF_STR( 1C_2C ) )
575/*  PORT_DIPSETTING(    0xc0, DEF_STR( 1C_2C ) )    Same as previous */
576
577   PORT_START("DSWB")
578   FSHARK_DSW_B
579
580   PORT_START("SYSTEM")
581   PORT_BIT( 0xff, IP_ACTIVE_HIGH, IPT_UNUSED )
481//  PORT_DIPSETTING(    0xc0, DEF_STR( 1C_2C ) )            /* duplicated setting */
582482INPUT_PORTS_END
583483
484/* verified from M68000 code */
584485static INPUT_PORTS_START( hishouza )
585   PORT_START("VBLANK")
586   FSHARK_SYSTEM_INPUTS
486   PORT_INCLUDE( fshark )
587487
588   PORT_START("P1")
589   TOAPLAN_PLAYER_INPUT( 1 )
590
591   PORT_START("P2")
592   TOAPLAN_PLAYER_INPUT( 2 )
593
594   PORT_START("DSWA")
595   TOAPLAN_JAPAN_DSW_A
596
597   PORT_START("DSWB")
598   FSHARK_DSW_B
599
600   PORT_START("SYSTEM")
601   PORT_BIT( 0xff, IP_ACTIVE_HIGH, IPT_UNUSED )
488   PORT_MODIFY("DSWA")
489   TOAPLAN_COINAGE_JAPAN_OLD                               /* table at 0x000316 (COIN1 AND COIN2) */
602490INPUT_PORTS_END
603491
604static INPUT_PORTS_START( gulfwar2 )
605   PORT_START("VBLANK")
606   TWINCOBR_VBLANK_INPUT( IP_ACTIVE_LOW )
607492
608   PORT_START("P1")
609   TOAPLAN_PLAYER_INPUT( 1 )
610493
611   PORT_START("P2")
612   TOAPLAN_PLAYER_INPUT( 2 )
613494
614   PORT_START("DSWA")
615   PORT_DIPNAME( 0x01, 0x00, DEF_STR( Unknown ) )
616   PORT_DIPSETTING(   0x00, DEF_STR( Off ) )
617   PORT_DIPSETTING(   0x01, DEF_STR( On ) )
618   PORT_DIPNAME( 0x02, 0x00, DEF_STR( Flip_Screen ) )
619   PORT_DIPSETTING(   0x00, DEF_STR( Off ) )
620   PORT_DIPSETTING(   0x02, DEF_STR( On ) )
621   PORT_DIPNAME( 0x04, 0x00, "Cross Hatch Pattern" )
622   PORT_DIPSETTING(   0x00, DEF_STR( Off ) )
623   PORT_DIPSETTING(   0x04, DEF_STR( On ) )
624   PORT_DIPNAME( 0x08, 0x00, DEF_STR( Demo_Sounds ) )
625   PORT_DIPSETTING(   0x08, DEF_STR( Off ) )
626   PORT_DIPSETTING(   0x00, DEF_STR( On ) )
627   PORT_DIPNAME( 0x30, 0x00, DEF_STR( Coin_A ) )
628   PORT_DIPSETTING(   0x30, DEF_STR( 4C_1C ) )
629   PORT_DIPSETTING(   0x20, DEF_STR( 3C_1C ) )
630   PORT_DIPSETTING(   0x10, DEF_STR( 2C_1C ) )
631   PORT_DIPSETTING(   0x00, DEF_STR( 1C_1C ) )
632   PORT_DIPNAME( 0xc0, 0x00, DEF_STR( Coin_B ) )
633   PORT_DIPSETTING(   0x00, DEF_STR( 1C_2C ) )
634   PORT_DIPSETTING(   0x40, DEF_STR( 1C_3C ) )
635   PORT_DIPSETTING(   0x80, DEF_STR( 1C_4C ) )
636   PORT_DIPSETTING(   0xc0, DEF_STR( 1C_6C ) )
637
638   PORT_START("DSWB")
639   TWINCOBR_DSW_B
640
641   PORT_START("SYSTEM")
642   TWINCOBR_SYSTEM_INPUTS
643INPUT_PORTS_END
644
645
646
647495static const gfx_layout charlayout =
648496{
649497   8,8,         /* 8*8 characters */
r7500r7501
893741   ROM_LOAD( "82s123.b24",   0x240, 0x020, CRC(4fb5df2a) SHA1(506ef2c8e4cf45c256d6831a0a5760732f2de422) )   /* tile to sprite priority ?? */
894742ROM_END
895743
744ROM_START( gulfwar2 )
745   ROM_REGION( 0x40000, "maincpu", 0 )   /* Main 68K code */
746   ROM_LOAD16_BYTE( "08-u119.bin", 0x00000, 0x20000, CRC(41ebf9c0) SHA1(85207dda76abded727ed95717024a2ea2bd85dac) )
747   ROM_LOAD16_BYTE( "07-u92.bin",  0x00001, 0x20000, CRC(b73e6b25) SHA1(53cde41e5a2e8f721c3f43abf1fff46479f658d8) )
748
749   ROM_REGION( 0x10000, "audiocpu", 0 )   /* Sound Z80 code */
750   ROM_LOAD( "06-u51.bin", 0x00000, 0x08000, CRC(75504f95) SHA1(5bd23e700e1bd4f0fac622dfb7c8cc69ba764956) )
751
752   ROM_REGION( 0x2000, "dsp", 0 )   /* Co-Processor TMS320C10 MCU code */
753   /* ROMs are duplicated 4 times */
754   ROM_LOAD16_BYTE( "01-u2.rom", 0x000, 0x800, CRC(01399b65) SHA1(4867ec815e22c9124c7aa00ebb6089c2611fa31f) ) // Same code as Twin Cobra
755   ROM_CONTINUE(                 0x000, 0x800 )
756   ROM_CONTINUE(                 0x000, 0x800 )
757   ROM_CONTINUE(                 0x000, 0x800 )
758   ROM_LOAD16_BYTE( "02-u1.rom", 0x001, 0x800, CRC(abefe4ca) SHA1(f05f12a1ff19411f34f4eee98ce9ba450fec38f2) ) // Same code as Twin Cobra
759   ROM_CONTINUE(                 0x001, 0x800 )
760   ROM_CONTINUE(                 0x001, 0x800 )
761   ROM_CONTINUE(                 0x001, 0x800 )
762
763   ROM_REGION( 0x0c000, "gfx1", 0 )   /* chars */
764   ROM_LOAD( "03-u9.bin",   0x00000, 0x04000, CRC(1b7934b3) SHA1(c7f5ac364dec4c7843c30e098fd02e0901bdf4b7) )
765   ROM_LOAD( "04-u10.bin", 0x04000, 0x04000, CRC(6f7bfb58) SHA1(4c5602668938a52321b70cd971326fe1a4930889) )
766   ROM_LOAD( "05-u11.bin", 0x08000, 0x04000, CRC(31814724) SHA1(bdcf270e6219555a7f776167f6bf971c6ff18a83) )
767
768   ROM_REGION( 0x40000, "gfx2", 0 )   /* fg tiles */
769   ROM_LOAD( "16-u202.bin", 0x00000, 0x10000, CRC(d815d175) SHA1(917043d0731226d18bcc22dfe27e5a5a18b03c06) )
770   ROM_LOAD( "13-u199.bin", 0x10000, 0x10000, CRC(d949b0d9) SHA1(1974d3b54e082baa9084dd619c8a879d954644cd) )
771   ROM_LOAD( "14-u200.bin", 0x20000, 0x10000, CRC(c109a6ac) SHA1(3a13ec802e5bafcf599c273a0bb0fd078e01e171) )
772   ROM_LOAD( "15-u201.bin", 0x30000, 0x10000, CRC(ad21f2ab) SHA1(0ab6eeb4dc9c2531c6f19479e7f9bc54fc1c1fdf) )
773
774   ROM_REGION( 0x20000, "gfx3", 0 )   /* bg tiles */
775   ROM_LOAD( "09-u195.bin", 0x00000, 0x08000, CRC(b7be3a6d) SHA1(68b9223fd07e81d443a1ae3ff04b2af105b27548) )
776   ROM_LOAD( "12-u198.bin", 0x08000, 0x08000, CRC(fd7032a6) SHA1(8be6315d732b154163a3573e2017fdfc77c92e54) )
777   ROM_LOAD( "11-u197.bin", 0x10000, 0x08000, CRC(7b721ed3) SHA1(afd10229414c65a56e184d56a69460ca3a502a27) )
778   ROM_LOAD( "10-u196.rom", 0x18000, 0x08000, CRC(160f38ab) SHA1(da310ec387d439b26c8b6b881e5dcc07c2b9bb00) )
779
780   ROM_REGION( 0x40000, "gfx4", 0 )   /* sprites */
781   ROM_LOAD( "20-u262.bin", 0x00000, 0x10000, CRC(10665ca0) SHA1(0c552c3807e00a7ef4f9fd28c7988a232628a1f5) )
782   ROM_LOAD( "19-u261.bin", 0x10000, 0x10000, CRC(cfa6d417) SHA1(f6c17d938b58dc5756ecf617f00fbfaf701602a7) )
783   ROM_LOAD( "18-u260.bin", 0x20000, 0x10000, CRC(2e6a0c49) SHA1(0b7ddad8775dcebe240a8246ef7816113f517f87) )
784   ROM_LOAD( "17-u259.bin", 0x30000, 0x10000, CRC(66c1b0e6) SHA1(82f3659245913f835c4434131c179b49ee195961) )
785
786   ROM_REGION( 0x260, "proms", 0 )
787   ROM_LOAD( "82s129.d3",   0x000, 0x100, CRC(24e7d62f) SHA1(1c06a1ef1b6a722794ca1d5ee2c476ecaa5178a3) )   /* sprite priority control ?? */
788   ROM_LOAD( "82s129.d4",   0x100, 0x100, CRC(a50cef09) SHA1(55cafb5b2551b80ae708e9b966cf37c70a16d310) )   /* sprite priority control ?? */
789   ROM_LOAD( "82s123.d2",   0x200, 0x020, CRC(f72482db) SHA1(b0cb911f9c81f6088a5aa8760916ddae1f8534d7) )   /* sprite control ?? */
790   ROM_LOAD( "82s123.e18",   0x220, 0x020, CRC(bc88cced) SHA1(5055362710c0f58823c05fb4c0e0eec638b91e3d) )   /* sprite attribute (flip/position) ?? */
791   ROM_LOAD( "82s123.b24",   0x240, 0x020, CRC(4fb5df2a) SHA1(506ef2c8e4cf45c256d6831a0a5760732f2de422) )   /* tile to sprite priority ?? */
792ROM_END
793
896794ROM_START( fshark )
897795   ROM_REGION( 0x30000, "maincpu", 0 )   /* Main 68K code */
898796   ROM_LOAD16_BYTE( "b02_18-1.m8", 0x00000, 0x10000, CRC(04739e02) SHA1(8a14284adb0f0f33adf9affdec081c90de85d594) )
r7500r7501
1049947   ROM_LOAD( "b02_16.l5", 0x0000, 0x8000, CRC(cdd1a153) SHA1(de9827a959039cf753ecac6756fb1925c37466d8) )
1050948
1051949   ROM_REGION( 0x2000, "dsp", 0 )   /* Co-Processor TMS320C10 MCU code */
1052   ROMX_LOAD( "82s137-1.mcu",  0x0000, 0x0400, CRC(cc5b3f53) SHA1(33589665ac995cc4645b56bbcd6d1c1cd5368f88), ROM_NIBBLE | ROM_SHIFT_NIBBLE_HI | ROM_SKIP(1) )
1053   ROMX_LOAD( "82s137-2.mcu",  0x0000, 0x0400, CRC(47351d55) SHA1(826add3ea3987f2c9ba2d3fc69a4ad2d9b033c89), ROM_NIBBLE | ROM_SHIFT_NIBBLE_LO | ROM_SKIP(1) )
1054   ROMX_LOAD( "82s137-3.mcu",  0x0001, 0x0400, CRC(70b537b9) SHA1(5211ec4605894727747dda66b70c9427652b16b4), ROM_NIBBLE | ROM_SHIFT_NIBBLE_HI | ROM_SKIP(1) )
1055   ROMX_LOAD( "82s137-4.mcu",  0x0001, 0x0400, CRC(6edb2de8) SHA1(48459037c3b865f0c0d63a416fa71ba1119f7a09), ROM_NIBBLE | ROM_SHIFT_NIBBLE_LO | ROM_SKIP(1) )
1056   ROMX_LOAD( "82s137-5.mcu",  0x0800, 0x0400, CRC(f35b978a) SHA1(90da4ab12126727cd9510fdfe4f626452116c543), ROM_NIBBLE | ROM_SHIFT_NIBBLE_HI | ROM_SKIP(1) )
1057   ROMX_LOAD( "82s137-6.mcu",  0x0800, 0x0400, CRC(0459e51b) SHA1(b673f5e1fcf60c0ba668aeb98d545d17b988945d), ROM_NIBBLE | ROM_SHIFT_NIBBLE_LO | ROM_SKIP(1) )
1058   ROMX_LOAD( "82s137-7.mcu",  0x0801, 0x0400, CRC(cbf3184b) SHA1(a3eafadc319183ed688dc081c4dfcbe8d476abea), ROM_NIBBLE | ROM_SHIFT_NIBBLE_HI | ROM_SKIP(1) )
1059   ROMX_LOAD( "82s137-8.mcu",  0x0801, 0x0400, CRC(8246a05c) SHA1(2511fa99fbdd6c75281fa85ecca2a617d36eb360), ROM_NIBBLE | ROM_SHIFT_NIBBLE_LO | ROM_SKIP(1) )
950   /* FIXME : DSP ROMS from 'hishouza' (the only way to play the game) */
951   ROMX_LOAD( "dsp-a1.bpr", 0x0000, 0x0400, CRC(45d4d1b1) SHA1(e776a056f0f72cbeb309c5a23f803330cb8b3763), ROM_NIBBLE | ROM_SHIFT_NIBBLE_HI | ROM_SKIP(1) )
952   ROMX_LOAD( "dsp-a2.bpr", 0x0000, 0x0400, CRC(edd227fa) SHA1(34aba84b5216ecbe462e7166d0f66785ca049a34), ROM_NIBBLE | ROM_SHIFT_NIBBLE_LO | ROM_SKIP(1) )
953   ROMX_LOAD( "dsp-a3.bpr", 0x0001, 0x0400, CRC(df88e79b) SHA1(661b057fa2eef37b9d794151381d7d74a7bfa93a), ROM_NIBBLE | ROM_SHIFT_NIBBLE_HI | ROM_SKIP(1) )
954   ROMX_LOAD( "dsp-a4.bpr", 0x0001, 0x0400, CRC(a2094a7f) SHA1(0f1c173643046c76aa89eab66fba6ea51c3f2223), ROM_NIBBLE | ROM_SHIFT_NIBBLE_LO | ROM_SKIP(1) )
955   ROMX_LOAD( "dsp-b5.bpr", 0x0800, 0x0400, CRC(85ca5d47) SHA1(3c6e21e2897fd35834021ec9f81f57bebfd13ef8), ROM_NIBBLE | ROM_SHIFT_NIBBLE_HI | ROM_SKIP(1) )
956   ROMX_LOAD( "dsp-b6.bpr", 0x0800, 0x0400, CRC(81816b2c) SHA1(1e58ab7aef2a34f42267debf4cad9558d5e14159), ROM_NIBBLE | ROM_SHIFT_NIBBLE_LO | ROM_SKIP(1) )
957   ROMX_LOAD( "dsp-b7.bpr", 0x0801, 0x0400, CRC(e87540cd) SHA1(bb6e98c47ed46abbbfa06571806cb2d663880419), ROM_NIBBLE | ROM_SHIFT_NIBBLE_HI | ROM_SKIP(1) )
958   ROMX_LOAD( "dsp-b8.bpr", 0x0801, 0x0400, CRC(d3c16c5c) SHA1(a24d9536914734c1875c8a39938a346ff4418dd0), ROM_NIBBLE | ROM_SHIFT_NIBBLE_LO | ROM_SKIP(1) )
1060959
1061960   ROM_REGION( 0x0c000, "gfx1", 0 )   /* chars */
1062961   ROM_LOAD( "b02_07-1.h11", 0x00000, 0x04000, CRC(e669f80e) SHA1(05c1a4ff9adaa6c8035f38a76c5ee333fafba2bf) )
r7500r7501
1089988   ROM_LOAD( "b02-23.f28", 0x240, 0x020, CRC(4fb5df2a) SHA1(506ef2c8e4cf45c256d6831a0a5760732f2de422) ) /* bprom type: 82s123AN - tile to sprite priority ?? */
1090989ROM_END
1091990
1092ROM_START( gulfwar2 )
1093   ROM_REGION( 0x40000, "maincpu", 0 )   /* Main 68K code */
1094   ROM_LOAD16_BYTE( "08-u119.bin", 0x00000, 0x20000, CRC(41ebf9c0) SHA1(85207dda76abded727ed95717024a2ea2bd85dac) )
1095   ROM_LOAD16_BYTE( "07-u92.bin",  0x00001, 0x20000, CRC(b73e6b25) SHA1(53cde41e5a2e8f721c3f43abf1fff46479f658d8) )
1096991
1097   ROM_REGION( 0x10000, "audiocpu", 0 )   /* Sound Z80 code */
1098   ROM_LOAD( "06-u51.bin", 0x00000, 0x08000, CRC(75504f95) SHA1(5bd23e700e1bd4f0fac622dfb7c8cc69ba764956) )
1099
1100   ROM_REGION( 0x2000, "dsp", 0 )   /* Co-Processor TMS320C10 MCU code */
1101   /* ROMs are duplicated 4 times */
1102   ROM_LOAD16_BYTE( "01-u2.rom", 0x000, 0x800, CRC(01399b65) SHA1(4867ec815e22c9124c7aa00ebb6089c2611fa31f) ) // Same code as Twin Cobra
1103   ROM_CONTINUE(                 0x000, 0x800 )
1104   ROM_CONTINUE(                 0x000, 0x800 )
1105   ROM_CONTINUE(                 0x000, 0x800 )
1106   ROM_LOAD16_BYTE( "02-u1.rom", 0x001, 0x800, CRC(abefe4ca) SHA1(f05f12a1ff19411f34f4eee98ce9ba450fec38f2) ) // Same code as Twin Cobra
1107   ROM_CONTINUE(                 0x001, 0x800 )
1108   ROM_CONTINUE(                 0x001, 0x800 )
1109   ROM_CONTINUE(                 0x001, 0x800 )
1110
1111   ROM_REGION( 0x0c000, "gfx1", 0 )   /* chars */
1112   ROM_LOAD( "03-u9.bin",   0x00000, 0x04000, CRC(1b7934b3) SHA1(c7f5ac364dec4c7843c30e098fd02e0901bdf4b7) )
1113   ROM_LOAD( "04-u10.bin", 0x04000, 0x04000, CRC(6f7bfb58) SHA1(4c5602668938a52321b70cd971326fe1a4930889) )
1114   ROM_LOAD( "05-u11.bin", 0x08000, 0x04000, CRC(31814724) SHA1(bdcf270e6219555a7f776167f6bf971c6ff18a83) )
1115
1116   ROM_REGION( 0x40000, "gfx2", 0 )   /* fg tiles */
1117   ROM_LOAD( "16-u202.bin", 0x00000, 0x10000, CRC(d815d175) SHA1(917043d0731226d18bcc22dfe27e5a5a18b03c06) )
1118   ROM_LOAD( "13-u199.bin", 0x10000, 0x10000, CRC(d949b0d9) SHA1(1974d3b54e082baa9084dd619c8a879d954644cd) )
1119   ROM_LOAD( "14-u200.bin", 0x20000, 0x10000, CRC(c109a6ac) SHA1(3a13ec802e5bafcf599c273a0bb0fd078e01e171) )
1120   ROM_LOAD( "15-u201.bin", 0x30000, 0x10000, CRC(ad21f2ab) SHA1(0ab6eeb4dc9c2531c6f19479e7f9bc54fc1c1fdf) )
1121
1122   ROM_REGION( 0x20000, "gfx3", 0 )   /* bg tiles */
1123   ROM_LOAD( "09-u195.bin", 0x00000, 0x08000, CRC(b7be3a6d) SHA1(68b9223fd07e81d443a1ae3ff04b2af105b27548) )
1124   ROM_LOAD( "12-u198.bin", 0x08000, 0x08000, CRC(fd7032a6) SHA1(8be6315d732b154163a3573e2017fdfc77c92e54) )
1125   ROM_LOAD( "11-u197.bin", 0x10000, 0x08000, CRC(7b721ed3) SHA1(afd10229414c65a56e184d56a69460ca3a502a27) )
1126   ROM_LOAD( "10-u196.rom", 0x18000, 0x08000, CRC(160f38ab) SHA1(da310ec387d439b26c8b6b881e5dcc07c2b9bb00) )
1127
1128   ROM_REGION( 0x40000, "gfx4", 0 )   /* sprites */
1129   ROM_LOAD( "20-u262.bin", 0x00000, 0x10000, CRC(10665ca0) SHA1(0c552c3807e00a7ef4f9fd28c7988a232628a1f5) )
1130   ROM_LOAD( "19-u261.bin", 0x10000, 0x10000, CRC(cfa6d417) SHA1(f6c17d938b58dc5756ecf617f00fbfaf701602a7) )
1131   ROM_LOAD( "18-u260.bin", 0x20000, 0x10000, CRC(2e6a0c49) SHA1(0b7ddad8775dcebe240a8246ef7816113f517f87) )
1132   ROM_LOAD( "17-u259.bin", 0x30000, 0x10000, CRC(66c1b0e6) SHA1(82f3659245913f835c4434131c179b49ee195961) )
1133
1134   ROM_REGION( 0x260, "proms", 0 )
1135   ROM_LOAD( "82s129.d3",   0x000, 0x100, CRC(24e7d62f) SHA1(1c06a1ef1b6a722794ca1d5ee2c476ecaa5178a3) )   /* sprite priority control ?? */
1136   ROM_LOAD( "82s129.d4",   0x100, 0x100, CRC(a50cef09) SHA1(55cafb5b2551b80ae708e9b966cf37c70a16d310) )   /* sprite priority control ?? */
1137   ROM_LOAD( "82s123.d2",   0x200, 0x020, CRC(f72482db) SHA1(b0cb911f9c81f6088a5aa8760916ddae1f8534d7) )   /* sprite control ?? */
1138   ROM_LOAD( "82s123.e18",   0x220, 0x020, CRC(bc88cced) SHA1(5055362710c0f58823c05fb4c0e0eec638b91e3d) )   /* sprite attribute (flip/position) ?? */
1139   ROM_LOAD( "82s123.b24",   0x240, 0x020, CRC(4fb5df2a) SHA1(506ef2c8e4cf45c256d6831a0a5760732f2de422) )   /* tile to sprite priority ?? */
1140ROM_END
1141
1142
1143992static DRIVER_INIT( twincobr )
1144993{
1145994   twincobr_driver_savestate(machine);
1146995}
1147996
1148997
1149GAME( 1987, twincobr, 0,        twincobr, twincobr, twincobr, ROT270, "[Toaplan] Taito Corporation", "Twin Cobra (World)", 0 )
1150GAME( 1987, twincobru,twincobr, twincobr, twincobu, twincobr, ROT270, "[Toaplan] Taito America Corporation (Romstar license)", "Twin Cobra (US)", 0 )
1151GAME( 1987, ktiger,   twincobr, twincobr, ktiger,   twincobr, ROT270, "[Toaplan] Taito Corporation", "Kyukyoku Tiger (Japan)", 0 )
1152GAME( 1987, fshark,   0,        twincobr, fshark,   twincobr, ROT270, "[Toaplan] Taito Corporation", "Flying Shark (World)", 0 )
1153GAME( 1987, skyshark, fshark,   twincobr, skyshark, twincobr, ROT270, "[Toaplan] Taito America Corporation (Romstar license)", "Sky Shark (US)", 0 )
1154GAME( 1987, hishouza, fshark,   twincobr, hishouza, twincobr, ROT270, "[Toaplan] Taito Corporation", "Hishou Zame (Japan)", 0 )
1155GAME( 1987, fsharkbt, fshark,   twincobr, skyshark, twincobr, ROT270, "bootleg", "Flying Shark (bootleg)", 0 )
1156GAME( 1991, gulfwar2, 0,        twincobr, gulfwar2, twincobr, ROT270, "Comad", "Gulf War II", 0 )
998GAME( 1987, twincobr,  0,        twincobr, twincobr,  twincobr, ROT270, "[Toaplan] Taito Corporation", "Twin Cobra (World)", 0 )
999GAME( 1987, twincobru, twincobr, twincobr, twincobru, twincobr, ROT270, "[Toaplan] Taito America Corporation (Romstar license)", "Twin Cobra (US)", 0 )
1000GAME( 1987, ktiger,    twincobr, twincobr, ktiger,    twincobr, ROT270, "[Toaplan] Taito Corporation", "Kyukyoku Tiger (Japan)", 0 )
1001GAME( 1991, gulfwar2,  0,        twincobr, gulfwar2,  twincobr, ROT270, "Comad", "Gulf War II", 0 )
1002
1003GAME( 1987, fshark,    0,        twincobr, fshark,    twincobr, ROT270, "[Toaplan] Taito Corporation", "Flying Shark (World)", 0 )
1004GAME( 1987, skyshark,  fshark,   twincobr, skyshark,  twincobr, ROT270, "[Toaplan] Taito America Corporation (Romstar license)", "Sky Shark (US)", 0 )
1005GAME( 1987, hishouza,  fshark,   twincobr, hishouza,  twincobr, ROT270, "[Toaplan] Taito Corporation", "Hishou Zame (Japan)", 0 )
1006GAME( 1987, fsharkbt,  fshark,   twincobr, skyshark,  twincobr, ROT270, "bootleg", "Flying Shark (bootleg)", 0 )
src/mame/drivers/system1.c
r7500r7501
496496      return soundlatch_r(space, offset);
497497   }
498498
499   /* if we have a Z80 PIO, just do a port read which will auto-ack */
499   /* if we have a Z80 PIO, get the data from the port and toggle the strobe */
500500   else if (pio != NULL)
501      return z80pio_p_r(pio, 0);
501   {
502      UINT8 data = z80pio_pa_r(pio, 0);
503      z80pio_astb_w(pio, 0);
504      z80pio_astb_w(pio, 1);
505      return data;
506   }
502507
503508   return 0xff;
504509}
r7500r7501
519524}
520525
521526
522static WRITE_LINE_DEVICE_HANDLER( pio_ready_w )
523{
524   cputag_set_input_line(device->machine, "soundcpu", INPUT_LINE_NMI, state ? ASSERT_LINE : CLEAR_LINE);
525}
526527
527
528
529528/*************************************
530529 *
531530 *  MCU I/O
r7500r7501
756755   AM_RANGE(0x0c, 0x0c) AM_MIRROR(0x02) AM_READ_PORT("SWA")   /* DIP2 */
757756   AM_RANGE(0x0d, 0x0d) AM_MIRROR(0x02) AM_READ_PORT("SWB")   /* DIP1 some games read it from here... */
758757   AM_RANGE(0x10, 0x10) AM_MIRROR(0x03) AM_READ_PORT("SWB")   /* DIP1 ... and some others from here but there are games which check BOTH! */
759   AM_RANGE(0x18, 0x1b) AM_DEVREADWRITE("pio", z80pio_r, z80pio_w)
758   AM_RANGE(0x18, 0x1b) AM_DEVREADWRITE("pio", z80pio_cd_ba_r, z80pio_cd_ba_w)
760759ADDRESS_MAP_END
761760
762761
r7500r7501
20792078   DEVCB_HANDLER(sound_control_w)
20802079};
20812080
2082static const z80pio_interface pio_interface =
2081static Z80PIO_INTERFACE( pio_interface )
20832082{
20842083   DEVCB_NULL,
20852084   DEVCB_NULL,
2086   DEVCB_NULL,
20872085   DEVCB_MEMORY_HANDLER("maincpu", PROGRAM, soundport_w),
2086   DEVCB_CPU_INPUT_LINE("soundcpu", INPUT_LINE_NMI),
2087   DEVCB_NULL,
20882088   DEVCB_MEMORY_HANDLER("maincpu", PROGRAM, videomode_w),
2089   DEVCB_LINE(pio_ready_w),
20902089   DEVCB_NULL
20912090};
20922091
r7500r7501
21582157   MDRV_CPU_IO_MAP(system1_pio_io_map)
21592158
21602159   MDRV_DEVICE_REMOVE("ppi")
2161   MDRV_Z80PIO_ADD("pio", pio_interface)
2160   MDRV_Z80PIO_ADD("pio", MASTER_CLOCK, pio_interface)
21622161MACHINE_DRIVER_END
21632162
21642163/* reduced visible area for scrolling games */
src/mame/drivers/luckgrln.c
r7500r7501
55
66 The program rom extracted from the Z180 also refers to this as Lucky 74..
77
8 TODO:
9 - interrupt generation (nested NMIs? disabled for now)
10 - video emulation (uses tilexor)
811
9
10
11
1212 Lucky Girl
1313 Wing 1991
1414
r7500r7501
7777#include "cpu/z180/z180.h"
7878#include "video/mc6845.h"
7979
80static UINT8 *luck_vram1,*luck_vram2,*luck_vram3;
81static UINT8 nmi_enable;
8082
83static VIDEO_START(luckgrln)
84{
85
86}
87
88static VIDEO_UPDATE(luckgrln)
89{
90   int y,x;
91   int count = 0;
92
93   for (y=0;y<32;y++)
94   {
95      for (x=0;x<64;x++)
96      {
97         UINT16 tile = (luck_vram1[count] & 0xff);
98         UINT16 enc_tile = (luck_vram2[count] & 0xff) | (luck_vram3[count] << 8);
99         UINT16 dec_tile;
100         UINT8 col = 0;
101         UINT8 region = 0;
102         //UINT8 region = (luck_vram2[count] & 0x20) >> 5;
103
104         dec_tile = enc_tile & 0x0200 ? 0x10 : 0x00;
105         dec_tile |= (enc_tile & 0x00f0)>>4;
106
107         tile = tile|(dec_tile<<8);
108
109         drawgfx_opaque(bitmap,cliprect,screen->machine->gfx[region],tile,col,0,0,x*8,y*8);
110
111         count++;
112      }
113   }
114   return 0;
115}
116
81117static ADDRESS_MAP_START( mainmap, ADDRESS_SPACE_PROGRAM, 8 )
82118   AM_RANGE(0x00000, 0x03fff) AM_ROM
83   AM_RANGE(0x10000, 0x1ffff) AM_ROMBANK("bank1")
119   AM_RANGE(0x10000, 0x1ffff) AM_ROM AM_REGION("rom_data",0x10000)
120   AM_RANGE(0x20000, 0x2ffff) AM_ROM AM_REGION("rom_data",0x00000)
121
122   AM_RANGE(0x0c200, 0x0c5ff) AM_RAM
123   AM_RANGE(0x0ca00, 0x0cdff) AM_RAM
124
125   AM_RANGE(0x0d000, 0x0d03f) AM_RAM
126   AM_RANGE(0x0d200, 0x0d2ff) AM_RAM
127   AM_RANGE(0x0d400, 0x0d43f) AM_RAM
128
84129   AM_RANGE(0x0d800, 0x0dfff) AM_RAM
85   AM_RANGE(0x0f000, 0x0ffff) AM_RAM
130
131   AM_RANGE(0x0e000, 0x0e7ff) AM_RAM AM_BASE(&luck_vram1)
132   AM_RANGE(0x0e800, 0x0efff) AM_RAM AM_BASE(&luck_vram2)
133   AM_RANGE(0x0f000, 0x0f7ff) AM_RAM AM_BASE(&luck_vram3)
134
135   /* patch NMI checks until I understand. */
136   AM_RANGE(0x0faff, 0x0faff) AM_NOP
137   AM_RANGE(0x0fb02, 0x0fb02) AM_NOP
138
139   AM_RANGE(0x0f800, 0x0ffff) AM_RAM
86140   AM_RANGE(0xf0000, 0xfffff) AM_RAM
87141ADDRESS_MAP_END
88142
143static WRITE8_HANDLER( output_w )
144{
145   /* correct? */
146   nmi_enable = data & 1;
147   // other values unknown
148//  printf("%02x\n",data);
149}
150
151static READ8_HANDLER( test_r )
152{
153   return mame_rand(space->machine);
154}
155
89156static ADDRESS_MAP_START( portmap, ADDRESS_SPACE_IO, 8 )
90157   ADDRESS_MAP_GLOBAL_MASK(0xff) // i think
91158   AM_RANGE(0x0000, 0x003f) AM_RAM // Z180 internal regs
159   AM_RANGE(0x0060, 0x0060) AM_WRITE(output_w)
160   AM_RANGE(0x0090, 0x009d) AM_READ(test_r)
92161   AM_RANGE(0x00b0, 0x00b0) AM_DEVWRITE("crtc", mc6845_address_w)
93162   AM_RANGE(0x00b1, 0x00b1) AM_DEVWRITE("crtc", mc6845_register_w)
94163ADDRESS_MAP_END
r7500r7501
104173   RGN_FRAC(1,6),
105174   6,
106175   { RGN_FRAC(0,6),RGN_FRAC(1,6),RGN_FRAC(2,6),RGN_FRAC(3,6),RGN_FRAC(4,6),RGN_FRAC(5,6) },
107   { 0,1,2,3,4,5,6,7 },
176   { STEP8(0,1) },
108177   { 0*8,1*8,2*8,3*8,4*8,5*8,6*8,7*8},
109178   8*8
110179};
111180static GFXDECODE_START( luckgrln )
181   GFXDECODE_ENTRY( "gfx2", 0, tiles8x8_layout, 0, 16 )
112182   GFXDECODE_ENTRY( "gfx1", 0, tiles8x8_layout, 0, 16 )
113   GFXDECODE_ENTRY( "gfx2", 0, tiles8x8_layout, 0, 16 )
114183GFXDECODE_END
115184
116static VIDEO_START(luckgrln)
117{
118
119}
120
121static VIDEO_UPDATE(luckgrln)
122{
123   return 0;
124}
125
126185static const mc6845_interface mc6845_intf =
127186{
128187   "screen",   /* screen we are acting on */
r7500r7501
137196   NULL      /* update address callback */
138197};
139198
199static INTERRUPT_GEN( luckgrln_irq )
200{
201   #if 0
202   if(nmi_enable)
203      cputag_set_input_line(device->machine, "maincpu", INPUT_LINE_NMI, PULSE_LINE);
204   #endif
205}
206
140207static MACHINE_DRIVER_START( luckgrln )
141208   MDRV_CPU_ADD("maincpu", Z180,8000000)
142209   MDRV_CPU_PROGRAM_MAP(mainmap)
143210   MDRV_CPU_IO_MAP(portmap)
144   MDRV_CPU_VBLANK_INT("screen", irq0_line_hold)
211   MDRV_CPU_VBLANK_INT("screen", luckgrln_irq)
145212
146213   MDRV_MC6845_ADD("crtc", H46505, 6000000/4, mc6845_intf)   /* unknown clock, hand tuned to get ~60 fps */
147214
148
149215   MDRV_SCREEN_ADD("screen", RASTER)
150216   MDRV_SCREEN_REFRESH_RATE(60)
151217   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(0))
152218   MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16)
153   MDRV_SCREEN_SIZE(256, 256)
154   MDRV_SCREEN_VISIBLE_AREA(0, 256-1, 16, 256-16-1)
219   MDRV_SCREEN_SIZE(512, 256)
220   MDRV_SCREEN_VISIBLE_AREA(0, 512-1, 0, 256-1)
155221
156222   MDRV_GFXDECODE(luckgrln)
157223   MDRV_PALETTE_LENGTH(0x100)
r7500r7501
164230{
165231   int i;
166232   UINT8 x,v;
167   UINT8* rom = memory_region(machine,"user1");
233   UINT8* rom = memory_region(machine,"rom_data");
168234
169235   for (i=0;i<0x20000;i++)
170236   {
r7500r7501
191257   #endif
192258
193259   // ??
194   memory_set_bankptr(machine, "bank1",&rom[0x010000]);
260//  memory_set_bankptr(machine, "bank1",&rom[0x010000]);
195261}
196262
197263ROM_START( luckgrln )
198264   ROM_REGION( 0x4000, "maincpu", 0 ) // internal Z180 rom
199265   ROM_LOAD( "lucky74.bin",  0x00000, 0x4000, CRC(fa128e05) SHA1(97a9534b8414f984159271db48b153b0724d22f9) )
200266
201   ROM_REGION( 0x20000, "user1", 0 ) // external data / cpu rom
267   ROM_REGION( 0x20000, "rom_data", 0 ) // external data / cpu rom
202268   ROM_LOAD( "falcon.13",  0x00000, 0x20000, CRC(f7a717fd) SHA1(49a39b84620876ee2faf73aaa405a1e17cab2da2) )
203269
204270   ROM_REGION( 0x60000, "gfx1", 0 )
src/mame/drivers/dynax.c
r7500r7501
50945094   ROM_LOAD( "prom1.6b",  0x200, 0x200, CRC(e38eb360) SHA1(739960dd57ec3305edd57aa63816a81ddfbebf3e) )
50955095ROM_END
50965096
5097ROM_START( mayaa )
5098   ROM_REGION( 0x90000, "maincpu", 0 )   // Z80 Code
5099   ROM_LOAD( "512-1.bin", 0x00000, 0x10000, CRC(8ac94f49) SHA1(3c1e86c1aad67fb8cb1eb534a272222b58f1ff0f) )
5100   ROM_LOAD( "512-2.bin", 0x28000, 0x10000, CRC(7ea5b49a) SHA1(aaae848669d9f88c0660f46cc801e4eb0f5e3b89) )
5101
5102   ROM_REGION( 0xc0000, "gfx1", 0 )
5103   ROM_LOAD( "27c020-1.bin", 0x00000, 0x40000, CRC(8d41d7ca) SHA1(7e28845457d00481b313ee52b8c7674f75b8c3c0) )
5104   ROM_LOAD( "27c020-2.bin", 0x40000, 0x40000, CRC(ab85ce5e) SHA1(845b846e0fb8c9fcd1540960cda006fdac364fea) )
5105   ROM_LOAD( "27c020-3.bin", 0x80000, 0x40000, CRC(c4316dec) SHA1(2e727a491a71eb1f4d9f338cc6ec76e03f7b46fd) )
5106
5107   ROM_REGION( 0x400, "proms", 0 )   // Color PROMs
5108   ROM_LOAD( "promat01.bin",  0x000, 0x200, CRC(d276bf61) SHA1(987058b37182a54a360a80a2f073b000606a11c9) )   // FIXED BITS (0xxxxxxx)
5109   ROM_LOAD( "promat02.bin",  0x200, 0x200, CRC(e38eb360) SHA1(739960dd57ec3305edd57aa63816a81ddfbebf3e) )
5110ROM_END
5111
50975112ROM_START( inca )
50985113   ROM_REGION( 0x90000, "maincpu", 0 )   // Z80 Code
50995114   ROM_LOAD( "am27c512.1", 0x00000, 0x10000, CRC(b0d513f7) SHA1(65ef4702302bbfc7c7a77f7353120ee3f5c94b31) )
r7500r7501
51095124   ROM_LOAD( "n82s147n.1",  0x200, 0x200, CRC(618dbeb3) SHA1(10c8a558430fd1c2cabf9133d3e4f0a5f80eab83) )
51105125ROM_END
51115126
5127
5128
51125129/*
51135130
51145131Black Touch
r7500r7501
69606977GAME( 1989, hnoridur, hjingi,   hnoridur, hnoridur, 0,        ROT180, "Dynax",                    "Hana Oriduru (Japan)",                                         0 )
69616978GAME( 1989, drgpunch, 0,        sprtmtch, sprtmtch, 0,        ROT0,   "Dynax",                    "Dragon Punch (Japan)",                                         0 )
69626979GAME( 1989, sprtmtch, drgpunch, sprtmtch, sprtmtch, 0,        ROT0,   "Dynax (Fabtek license)",   "Sports Match",                                                 0 )
6963/* these 3 are Korean hacks / bootlegs of Dragon Punch / Sports Match */
6964GAME( 1994, maya,     0,        sprtmtch, sprtmtch, maya,     ROT0,   "Promat",                   "Maya",                                                         0 )
6980/* these 4 are Korean hacks / bootlegs of Dragon Punch / Sports Match */
6981GAME( 1994, maya,     0,        sprtmtch, sprtmtch, maya,     ROT0,   "Promat",                   "Maya (set 1)",                                                 0 ) // this set has backgrounds blacked out in attract
6982GAME( 1994, mayaa,    maya,     sprtmtch, sprtmtch, maya,     ROT0,   "Promat",                   "Maya (set 2)",                                                 0 )
69656983GAME( 199?, inca,     0,        sprtmtch, sprtmtch, maya,     ROT0,   "<unknown>",                "Inca",                                                         0 )
69666984GAME( 199?, blktouch, 0,        sprtmtch, sprtmtch, blktouch, ROT0,   "Yang Gi Co Ltd.",          "Black Touch (Korea)",                                          0 )
6985
69676986GAME( 1989, mjfriday, 0,        mjfriday, mjfriday, 0,        ROT180, "Dynax",                    "Mahjong Friday (Japan)",                                       0 )
69686987GAME( 1989, gekisha,  0,        gekisha,  gekisha,  0,        ROT180, "Dynax",                    "Mahjong Gekisha",                                              0 )
69696988GAME( 1990, mcnpshnt, 0,        mcnpshnt, mcnpshnt, 0,        ROT0,   "Dynax",                    "Mahjong Campus Hunting (Japan)",                               0 )
src/mame/drivers/megadriv.c
r7500r7501
16061606//  PORT_DIPSETTING(    0x00, "10 (Fastest)" )
16071607INPUT_PORTS_END
16081608
1609INPUT_PORTS_START(mk3ghw)
1610   PORT_INCLUDE( md_common )
16091611
1612   PORT_MODIFY("PAD1")
1613   PORT_BIT( 0x0010, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(1)
1614   PORT_BIT( 0x0020, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_PLAYER(1)
1615   PORT_BIT( 0x0040, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(1)
1616   PORT_BIT( 0x0080, IP_ACTIVE_LOW, IPT_START1 )
1617
1618   PORT_MODIFY("PAD2")
1619   PORT_BIT( 0x0010, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_PLAYER(2)
1620   PORT_BIT( 0x0020, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_PLAYER(2)
1621   PORT_BIT( 0x0040, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_PLAYER(2)
1622   PORT_BIT( 0x0080, IP_ACTIVE_LOW, IPT_START2 )
1623
1624   PORT_START("EXTRA1")   /* Extra buttons for Joypad 1 (6 button + start + mode) NOT READ DIRECTLY */
1625   PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_BUTTON6 ) PORT_PLAYER(1)
1626   PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_BUTTON5 ) PORT_PLAYER(1)
1627   PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_BUTTON4 ) PORT_PLAYER(1)
1628   PORT_BIT( 0x0008, IP_ACTIVE_LOW, IPT_UNUSED )
1629
1630   PORT_START("EXTRA2")   /* Extra buttons for Joypad 2 (6 button + start + mode) NOT READ DIRECTLY */
1631   PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_BUTTON6 ) PORT_PLAYER(2)
1632   PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_BUTTON5 ) PORT_PLAYER(2)
1633   PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_BUTTON4 ) PORT_PLAYER(2)
1634   PORT_BIT( 0x0008, IP_ACTIVE_LOW, IPT_UNUSED )
1635
1636   PORT_START("IN0")
1637   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_COIN1 ) PORT_IMPULSE(1)
1638   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_COIN2 ) PORT_IMPULSE(1)
1639
1640   PORT_START("DSWA")
1641   PORT_DIPNAME( 0x07, 0x07, DEF_STR( Coinage ) )
1642   PORT_DIPSETTING(    0x01, DEF_STR( 4C_1C ) )
1643   PORT_DIPSETTING(    0x02, DEF_STR( 3C_1C ) )
1644   PORT_DIPSETTING(    0x03, DEF_STR( 2C_1C ) )
1645   PORT_DIPSETTING(    0x07, DEF_STR( 1C_1C ) )
1646   PORT_DIPSETTING(    0x06, DEF_STR( 1C_2C ) )
1647   PORT_DIPSETTING(    0x05, DEF_STR( 1C_3C ) )
1648   PORT_DIPSETTING(    0x04, DEF_STR( 1C_4C ) )
1649   PORT_BIT( 0xf8, 0x00, IPT_UNUSED )
1650
1651   PORT_START("DSWB")
1652   PORT_DIPUNKNOWN( 0x01, 0x00 )
1653   PORT_DIPUNKNOWN( 0x02, 0x00 )
1654   PORT_DIPUNKNOWN( 0x04, 0x00 )
1655   PORT_DIPUNKNOWN( 0x08, 0x00 )
1656   PORT_DIPUNKNOWN( 0x10, 0x00 )
1657   PORT_DIPUNKNOWN( 0x20, 0x00 )
1658   PORT_DIPNAME( 0x40, 0x40, DEF_STR( Demo_Sounds ) )
1659   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
1660   PORT_DIPSETTING(    0x40, DEF_STR( On ) )
1661   PORT_DIPUNKNOWN( 0x80, 0x00 )
1662INPUT_PORTS_END
1663
1664
16101665INPUT_PORTS_START( aladbl )
16111666   PORT_INCLUDE( md_common )
16121667
r7500r7501
16541709
16551710   if (ipt == INPUT_PORTS_NAME(ssf2ghw))
16561711      init_megadri6_io(machine);
1712
1713   if (ipt == INPUT_PORTS_NAME(mk3ghw))
1714      init_megadri6_io(machine);
16571715}
16581716
16591717static void megadrive_reset_io(running_machine *machine)
r7500r7501
63026360
63036361   m68k_set_tas_callback(devtag_get_device(machine, "maincpu"), megadriv_tas_callback);
63046362
6305   if ((ipt == INPUT_PORTS_NAME(megadri6)) || (ipt == INPUT_PORTS_NAME(ssf2ghw)))
6363   if ((ipt == INPUT_PORTS_NAME(megadri6)) || (ipt == INPUT_PORTS_NAME(ssf2ghw)) || (ipt == INPUT_PORTS_NAME(mk3ghw)))
63066364   {
63076365      megadrive_io_read_data_port_ptr   = megadrive_io_read_data_port_6button;
63086366      megadrive_io_write_data_port_ptr = megadrive_io_write_data_port_6button;
src/mame/drivers/mexico86.c
r7500r7501
4141
4242Note MCU labeling:
4343
44Bubble Bobble   KiKi KaiKai      Kick and RUN
44Bubble Bobble   KiKi KaiKai      Kick and Run
4545-------------   -------------    -------------
4646TAITO A78-01    TAITO A85-01     TAITO A87-01
4747JPH1011P        JPH1020P         JPH1021P
r7500r7501
5757#include "sound/2203intf.h"
5858#include "includes/mexico86.h"
5959
60//AT
60
61/*************************************
62 *
63 *  Memory handlers
64 *
65 *************************************/
66
6167static READ8_DEVICE_HANDLER( kiki_ym2203_r )
6268{
6369   UINT8 result = ym2203_r(device, offset);
70
6471   if (offset == 0)
6572      result &= 0x7f;
73
6674   return result;
6775}
68//ZT
6976
77
78/*************************************
79 *
80 *  Address maps
81 *
82 *************************************/
83
7084static ADDRESS_MAP_START( mexico86_map, ADDRESS_SPACE_PROGRAM, 8 )
7185   AM_RANGE(0x0000, 0x7fff) AM_ROM
7286   AM_RANGE(0x8000, 0xbfff) AM_ROMBANK("bank1")               /* banked roms */
7387   AM_RANGE(0xc000, 0xe7ff) AM_RAM AM_SHARE("share1")              /* shared with sound cpu */
74   AM_RANGE(0xd500, 0xd7ff) AM_RAM AM_BASE(&mexico86_objectram) AM_SIZE(&mexico86_objectram_size)
75   AM_RANGE(0xe800, 0xe8ff) AM_RAM AM_BASE(&mexico86_protection_ram)  /* shared with mcu */
88   AM_RANGE(0xd500, 0xd7ff) AM_RAM AM_BASE_SIZE_MEMBER(mexico86_state, objectram, objectram_size)
89   AM_RANGE(0xe800, 0xe8ff) AM_RAM AM_BASE_MEMBER(mexico86_state, protection_ram)  /* shared with mcu */
7690   AM_RANGE(0xe900, 0xefff) AM_RAM
77   AM_RANGE(0xc000, 0xd4ff) AM_RAM AM_BASE(&mexico86_videoram) //AT: corrected size
91   AM_RANGE(0xc000, 0xd4ff) AM_RAM AM_BASE_MEMBER(mexico86_state, videoram)
7892   AM_RANGE(0xf000, 0xf000) AM_WRITE(mexico86_bankswitch_w)   /* program and gfx ROM banks */
7993   AM_RANGE(0xf008, 0xf008) AM_WRITE(mexico86_f008_w)        /* cpu reset lines + other unknown stuff */
8094   AM_RANGE(0xf010, 0xf010) AM_READ_PORT("IN3")
r7500r7501
91105
92106static ADDRESS_MAP_START( mexico86_m68705_map, ADDRESS_SPACE_PROGRAM, 8 )
93107   ADDRESS_MAP_GLOBAL_MASK(0x7ff)
94   AM_RANGE(0x0000, 0x0000) AM_READWRITE(mexico86_68705_portA_r,mexico86_68705_portA_w)
95   AM_RANGE(0x0001, 0x0001) AM_READWRITE(mexico86_68705_portB_r,mexico86_68705_portB_w)
108   AM_RANGE(0x0000, 0x0000) AM_READWRITE(mexico86_68705_port_a_r,mexico86_68705_port_a_w)
109   AM_RANGE(0x0001, 0x0001) AM_READWRITE(mexico86_68705_port_b_r,mexico86_68705_port_b_w)
96110   AM_RANGE(0x0002, 0x0002) AM_READ_PORT("IN0") /* COIN */
97   AM_RANGE(0x0004, 0x0004) AM_WRITE(mexico86_68705_ddrA_w)
98   AM_RANGE(0x0005, 0x0005) AM_WRITE(mexico86_68705_ddrB_w)
111   AM_RANGE(0x0004, 0x0004) AM_WRITE(mexico86_68705_ddr_a_w)
112   AM_RANGE(0x0005, 0x0005) AM_WRITE(mexico86_68705_ddr_b_w)
99113   AM_RANGE(0x000a, 0x000a) AM_WRITENOP    /* looks like a bug in the code, writes to */
100114                                 /* 0x0a (=10dec) instead of 0x10 */
101115   AM_RANGE(0x0010, 0x007f) AM_RAM
r7500r7501
121135   AM_RANGE(0xc004, 0xc004) AM_WRITE(mexico86_sub_output_w)
122136ADDRESS_MAP_END
123137
138/*************************************
139 *
140 *  Input ports
141 *
142 *************************************/
143
124144static INPUT_PORTS_START( mexico86 )
125   PORT_START("IN0")   /* IN0 */
145   PORT_START("IN0")
126146   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_COIN1 )
127147   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_COIN2 )
128148   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNKNOWN )
r7500r7501
132152   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )
133153   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
134154
135   PORT_START("IN1")   /* IN1 */
155   PORT_START("IN1")
136156   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_8WAY PORT_PLAYER(1)
137157   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_8WAY PORT_PLAYER(1)
138158   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_8WAY PORT_PLAYER(1)
r7500r7501
142162   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )
143163   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_SERVICE )    /* service 2 */
144164
145   PORT_START("IN2")   /* IN2 */
165   PORT_START("IN2")
146166   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_8WAY PORT_PLAYER(2)
147167   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_8WAY PORT_PLAYER(2)
148168   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_8WAY PORT_PLAYER(2)
r7500r7501
247267INPUT_PORTS_END
248268
249269static INPUT_PORTS_START( kikikai )
250   PORT_START("IN0")   /* IN0 */
270   PORT_START("IN0")
251271   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_COIN1 )
252272   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_COIN2 )
253273   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNKNOWN )
r7500r7501
257277   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )
258278   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
259279
260   PORT_START("IN1")   /* IN1 */
280   PORT_START("IN1")
261281   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_8WAY
262282   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_8WAY
263283   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_8WAY
r7500r7501
267287   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )
268288   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
269289
270   PORT_START("IN2")   /* IN2 */
290   PORT_START("IN2")
271291   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_8WAY PORT_COCKTAIL
272292   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_8WAY PORT_COCKTAIL
273293   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_8WAY PORT_COCKTAIL
r7500r7501
277297   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )
278298   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
279299
280//AT
281   PORT_START("DSW0")   /* DSW0 */
300   PORT_START("DSW0")
282301   PORT_DIPNAME( 0x01, 0x00, DEF_STR( Cabinet ) ) PORT_DIPLOCATION("SW1:1")
283302   PORT_DIPSETTING(    0x00, DEF_STR( Upright ) )
284303   PORT_DIPSETTING(    0x01, DEF_STR( Cocktail ) )
r7500r7501
315334   PORT_DIPSETTING(    0x00, DEF_STR( 2C_3C ) )
316335   PORT_DIPSETTING(    0x80, DEF_STR( 1C_2C ) )
317336
318   PORT_START("DSW1")   /* DSW1 */
337   PORT_START("DSW1")
319338   PORT_DIPNAME( 0x03, 0x03, DEF_STR( Difficulty ) )  PORT_DIPLOCATION("SW2:1,2")
320339   PORT_DIPSETTING(    0x02, DEF_STR( Easy ) )
321340   PORT_DIPSETTING(    0x03, DEF_STR( Normal ) )
r7500r7501
337356   PORT_DIPNAME( 0x80, 0x00, "Number Match" )  PORT_DIPLOCATION("SW2:8")
338357   PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
339358   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
340//ZT
341359
342360   PORT_START("IN3")
343361   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_COIN3 )
r7500r7501
352370
353371
354372
373/*************************************
374 *
375 *  Graphics definitions
376 *
377 *************************************/
378
355379static const gfx_layout charlayout =
356380{
357381   8,8,
r7500r7501
369393
370394
371395
396/*************************************
397 *
398 *  Sound interfaces
399 *
400 *************************************/
401
372402static const ym2203_interface ym2203_config =
373403{
374404   {
r7500r7501
383413};
384414
385415
416/*************************************
417 *
418 *  Machine driver
419 *
420 *************************************/
421
422static MACHINE_START( mexico86 )
423{
424   mexico86_state *state = (mexico86_state *)machine->driver_data;
425   UINT8 *ROM = memory_region(machine, "maincpu");
426
427   memory_configure_bank(machine, "bank1", 0, 6, &ROM[0x10000], 0x4000);
428
429   state->maincpu = devtag_get_device(machine, "maincpu");
430   state->audiocpu = devtag_get_device(machine, "audiocpu");
431   state->subcpu = devtag_get_device(machine, "sub");
432   state->mcu = devtag_get_device(machine, "mcu");
433
434   state_save_register_global(machine, state->port_a_in);
435   state_save_register_global(machine, state->port_a_out);
436   state_save_register_global(machine, state->ddr_a);
437   state_save_register_global(machine, state->port_b_in);
438   state_save_register_global(machine, state->port_b_out);
439   state_save_register_global(machine, state->ddr_b);
440   state_save_register_global(machine, state->address);
441   state_save_register_global(machine, state->latch);
442
443   state_save_register_global(machine, state->mcu_running);
444   state_save_register_global(machine, state->mcu_initialised);
445   state_save_register_global(machine, state->coin_last);
446
447   state_save_register_global(machine, state->charbank);
448}
449
386450static MACHINE_RESET( mexico86 )
387451{
452   mexico86_state *state = (mexico86_state *)machine->driver_data;
453
388454   /*TODO: check the PCB and see how the halt / reset lines are connected. */
389455   if (devtag_get_device(machine, "sub") != NULL)
390456      cputag_set_input_line(machine, "sub", INPUT_LINE_RESET, (input_port_read(machine, "DSW1") & 0x80) ? ASSERT_LINE : CLEAR_LINE);
457
458   state->port_a_in = 0;
459   state->port_a_out = 0;
460   state->ddr_a = 0;
461   state->port_b_in = 0;
462   state->port_b_out = 0;
463   state->ddr_b = 0;
464   state->address = 0;
465   state->latch = 0;
466
467   state->mcu_running = 0;
468   state->mcu_initialised = 0;
469   state->coin_last = 0;
470
471   state->charbank = 0;
391472}
392473
393474static MACHINE_DRIVER_START( mexico86 )
394475
476   /* driver data */
477   MDRV_DRIVER_DATA(mexico86_state)
478
395479   /* basic machine hardware */
396480   MDRV_CPU_ADD("maincpu",Z80, 24000000/4)      /* 6 MHz, Uses clock divided 24MHz OSC */
397481   MDRV_CPU_PROGRAM_MAP(mexico86_map)
r7500r7501
408492   MDRV_CPU_PROGRAM_MAP(mexico86_sub_cpu_map)
409493   MDRV_CPU_VBLANK_INT("screen", irq0_line_hold)
410494
411   MDRV_QUANTUM_TIME(HZ(6000))    /* 100 CPU slices per frame - an high value to ensure proper */
412                     /* synchronization of the CPUs */
495   MDRV_QUANTUM_TIME(HZ(6000))    /* 100 CPU slices per frame - an high value to ensure proper synchronization of the CPUs */
413496
497   MDRV_MACHINE_START(mexico86)
414498   MDRV_MACHINE_RESET(mexico86)
415499
416500   /* video hardware */
r7500r7501
466550MACHINE_DRIVER_END
467551
468552
469/***************************************************************************
553/*************************************
554 *
555 *  ROM definition(s)
556 *
557 *************************************/
470558
471  Game driver(s)
472
473***************************************************************************/
474
475559ROM_START( kikikai )
476560   ROM_REGION( 0x28000, "maincpu", 0 )
477561   ROM_LOAD( "a85-17.h16", 0x00000, 0x08000, CRC(c141d5ab) SHA1(fe3622ba283e514416c43a44f83f922a958b27cd) ) /* 1st half, main code        */
r7500r7501
622706ROM_END
623707
624708
625GAME( 1986, kikikai,  0,        kikikai,  kikikai,  0, ROT90, "Taito Corporation", "KiKi KaiKai", 0 )
626GAME( 1986, knightb,  kikikai,  knightb,  kikikai,  0, ROT90, "bootleg", "Knight Boy", 0 )
627GAME( 1986, kicknrun, 0,        mexico86, mexico86, 0, ROT0,  "Taito Corporation", "Kick and Run (World)", 0 )
628GAME( 1986, kicknrunu,kicknrun, mexico86, mexico86, 0, ROT0,  "Taito America Corp", "Kick and Run (US)", 0 )
629GAME( 1986, mexico86, kicknrun, mexico86, mexico86, 0, ROT0,  "bootleg", "Mexico 86", 0 )
709/*************************************
710 *
711 *  Game driver(s)
712 *
713 *************************************/
714
715GAME( 1986, kikikai,  0,        kikikai,  kikikai,  0, ROT90, "Taito Corporation", "KiKi KaiKai", GAME_SUPPORTS_SAVE )
716GAME( 1986, knightb,  kikikai,  knightb,  kikikai,  0, ROT90, "bootleg", "Knight Boy", GAME_SUPPORTS_SAVE )
717GAME( 1986, kicknrun, 0,        mexico86, mexico86, 0, ROT0,  "Taito Corporation", "Kick and Run (World)", GAME_SUPPORTS_SAVE )
718GAME( 1986, kicknrunu,kicknrun, mexico86, mexico86, 0, ROT0,  "Taito America Corp", "Kick and Run (US)", GAME_SUPPORTS_SAVE )
719GAME( 1986, mexico86, kicknrun, mexico86, mexico86, 0, ROT0,  "bootleg", "Mexico 86", GAME_SUPPORTS_SAVE )
src/mame/drivers/minivadr.c
r7500r7501
1414#include "cpu/z80/z80.h"
1515
1616
17class minivadr_state
18{
19public:
20   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, minivadr_state(machine)); }
1721
22   minivadr_state(running_machine &machine) { }
23
24   /* memory pointers */
25   UINT8 *  videoram;
26   size_t   videoram_size;
27};
28
1829/*************************************
1930 *
2031 *  Video update
r7500r7501
2334
2435static VIDEO_UPDATE( minivadr )
2536{
37   minivadr_state *state = (minivadr_state *)screen->machine->driver_data;
2638   offs_t offs;
2739
28   for (offs = 0; offs < screen->machine->generic.videoram_size; offs++)
40   for (offs = 0; offs < state->videoram_size; offs++)
2941   {
3042      int i;
3143
3244      UINT8 x = offs << 3;
3345      int y = offs >> 5;
34      UINT8 data = screen->machine->generic.videoram.u8[offs];
46      UINT8 data = state->videoram[offs];
3547
3648      for (i = 0; i < 8; i++)
3749      {
r7500r7501
4961
5062static ADDRESS_MAP_START( minivadr_map, ADDRESS_SPACE_PROGRAM, 8 )
5163   AM_RANGE(0x0000, 0x1fff) AM_ROM
52   AM_RANGE(0xa000, 0xbfff) AM_RAM AM_BASE_GENERIC(videoram) AM_SIZE_GENERIC(videoram)
64   AM_RANGE(0xa000, 0xbfff) AM_RAM AM_BASE_SIZE_MEMBER(minivadr_state, videoram, videoram_size)
5365   AM_RANGE(0xe008, 0xe008) AM_READ_PORT("INPUTS") AM_WRITENOP      // W - ???
5466ADDRESS_MAP_END
5567
r7500r7501
6981
7082static MACHINE_DRIVER_START( minivadr )
7183
84   /* driver data */
85   MDRV_DRIVER_DATA(minivadr_state)
86
7287   /* basic machine hardware */
7388   MDRV_CPU_ADD("maincpu", Z80,24000000 / 6)       /* 4 MHz ? */
7489   MDRV_CPU_PROGRAM_MAP(minivadr_map)
r7500r7501
100115ROM_END
101116
102117
103GAME( 1990, minivadr, 0, minivadr, minivadr, 0, ROT0, "Taito Corporation", "Minivader", GAME_SUPPORTS_SAVE | GAME_NO_SOUND_HW)
118GAME( 1990, minivadr, 0, minivadr, minivadr, 0, ROT0, "Taito Corporation", "Minivader", GAME_SUPPORTS_SAVE | GAME_NO_SOUND_HW )
src/mame/drivers/mouser.c
r7500r7501
1616#include "cpu/z80/z80.h"
1717#include "deprecat.h"
1818#include "sound/ay8910.h"
19#include "includes/mouser.h"
1920
20static UINT8 mouser_sound_byte;
21static UINT8 mouser_nmi_enable;
22
23/* From "video/mouser.c" */
24extern UINT8 *mouser_videoram;
25extern UINT8 *mouser_colorram;
26
27PALETTE_INIT( mouser );
28WRITE8_HANDLER( mouser_flip_screen_x_w );
29WRITE8_HANDLER( mouser_flip_screen_y_w );
30VIDEO_UPDATE( mouser );
31
3221/* Mouser has external masking circuitry around
3322 * the NMI input on the main CPU */
34
3523static WRITE8_HANDLER( mouser_nmi_enable_w )
3624{
37   mouser_nmi_enable = data;
25   mouser_state *state = (mouser_state *)space->machine->driver_data;
26   state->nmi_enable = data;
3827}
3928
4029static INTERRUPT_GEN( mouser_nmi_interrupt )
4130{
42   if ((mouser_nmi_enable & 1) == 1)
31   mouser_state *state = (mouser_state *)device->machine->driver_data;
32
33   if (BIT(state->nmi_enable, 0))
4334      nmi_line_pulse(device);
4435}
4536
r7500r7501
4738
4839static WRITE8_HANDLER( mouser_sound_interrupt_w )
4940{
50   mouser_sound_byte = data;
51   cputag_set_input_line(space->machine, "audiocpu", 0, HOLD_LINE);
41   mouser_state *state = (mouser_state *)space->machine->driver_data;
42   state->sound_byte = data;
43   cpu_set_input_line(state->audiocpu, 0, HOLD_LINE);
5244}
5345
5446static READ8_HANDLER( mouser_sound_byte_r )
5547{
56   return mouser_sound_byte;
48   mouser_state *state = (mouser_state *)space->machine->driver_data;
49   return state->sound_byte;
5750}
5851
5952static ADDRESS_MAP_START( mouser_map, ADDRESS_SPACE_PROGRAM, 8 )
6053   AM_RANGE(0x0000, 0x5fff) AM_ROM
6154   AM_RANGE(0x6000, 0x6bff) AM_RAM
6255   AM_RANGE(0x8800, 0x88ff) AM_WRITENOP /* unknown */
63   AM_RANGE(0x9000, 0x93ff) AM_RAM AM_BASE(&mouser_videoram)
64   AM_RANGE(0x9800, 0x9cff) AM_RAM AM_BASE_SIZE_GENERIC(spriteram)
65   AM_RANGE(0x9c00, 0x9fff) AM_RAM AM_BASE(&mouser_colorram)
56   AM_RANGE(0x9000, 0x93ff) AM_RAM AM_BASE_MEMBER(mouser_state, videoram)
57   AM_RANGE(0x9800, 0x9cff) AM_RAM AM_BASE_SIZE_MEMBER(mouser_state, spriteram, spriteram_size)
58   AM_RANGE(0x9c00, 0x9fff) AM_RAM AM_BASE_MEMBER(mouser_state, colorram)
6659   AM_RANGE(0xa000, 0xa000) AM_READ_PORT("P1") AM_WRITE(mouser_nmi_enable_w) /* bit 0 = NMI Enable */
6760   AM_RANGE(0xa001, 0xa001) AM_WRITE(mouser_flip_screen_x_w)
6861   AM_RANGE(0xa002, 0xa002) AM_WRITE(mouser_flip_screen_y_w)
r7500r7501
178171GFXDECODE_END
179172
180173
174static MACHINE_START( mouser )
175{
176   mouser_state *state = (mouser_state *)machine->driver_data;
177
178   state->maincpu = devtag_get_device(machine, "maincpu");
179   state->audiocpu = devtag_get_device(machine, "audiocpu");
180
181   state_save_register_global(machine, state->sound_byte);
182   state_save_register_global(machine, state->nmi_enable);
183}
184
185static MACHINE_RESET( mouser )
186{
187   mouser_state *state = (mouser_state *)machine->driver_data;
188
189   state->sound_byte = 0;
190   state->nmi_enable = 0;
191}
192
181193static MACHINE_DRIVER_START( mouser )
182194
195   /* driver data */
196   MDRV_DRIVER_DATA(mouser_state)
197
183198   /* basic machine hardware */
184199   MDRV_CPU_ADD("maincpu", Z80, 4000000)   /* 4 MHz ? */
185200   MDRV_CPU_PROGRAM_MAP(mouser_map)
r7500r7501
190205   MDRV_CPU_IO_MAP(mouser_sound_io_map)
191206   MDRV_CPU_VBLANK_INT_HACK(nmi_line_pulse,4) /* ??? This controls the sound tempo */
192207
208   MDRV_MACHINE_START(mouser)
209   MDRV_MACHINE_RESET(mouser)
210
193211   /* video hardware */
194212   MDRV_SCREEN_ADD("screen", RASTER)
195213   MDRV_SCREEN_REFRESH_RATE(60)
r7500r7501
275293
276294   memory_set_decrypted_region(space, 0x0000, 0x5fff, decrypted);
277295
278   for (i = 0;i < 0x6000;i++)
296   for (i = 0; i < 0x6000; i++)
279297   {
280298      decrypted[i] = table[rom[i]];
281299   }
282300}
283301
284302
285GAME( 1983, mouser,   0,      mouser, mouser, mouser, ROT90, "UPL", "Mouser", 0 )
286GAME( 1983, mouserc,  mouser, mouser, mouser, mouser, ROT90, "[UPL] (Cosmos license)", "Mouser (Cosmos)", 0 )
303GAME( 1983, mouser,   0,      mouser, mouser, mouser, ROT90, "UPL", "Mouser", GAME_SUPPORTS_SAVE )
304GAME( 1983, mouserc,  mouser, mouser, mouser, mouser, ROT90, "[UPL] (Cosmos license)", "Mouser (Cosmos)", GAME_SUPPORTS_SAVE )
src/mame/drivers/lkage.c
r7500r7501
8585#include "includes/lkage.h"
8686
8787
88static int sound_nmi_enable,pending_nmi;
89
9088static TIMER_CALLBACK( nmi_callback )
9189{
92   if (sound_nmi_enable) cputag_set_input_line(machine, "audiocpu", INPUT_LINE_NMI, PULSE_LINE);
93   else pending_nmi = 1;
90   lkage_state *state = (lkage_state *)machine->driver_data;
91   if (state->sound_nmi_enable)
92      cpu_set_input_line(state->audiocpu, INPUT_LINE_NMI, PULSE_LINE);
93   else
94      state->pending_nmi = 1;
9495}
9596
9697static WRITE8_HANDLER( lkage_sound_command_w )
9798{
98   soundlatch_w(space,offset,data);
99   timer_call_after_resynch(space->machine, NULL, data,nmi_callback);
99   soundlatch_w(space, offset, data);
100   timer_call_after_resynch(space->machine, NULL, data, nmi_callback);
100101}
101102
102103static WRITE8_HANDLER( lkage_sh_nmi_disable_w )
103104{
104   sound_nmi_enable = 0;
105   lkage_state *state = (lkage_state *)space->machine->driver_data;
106   state->sound_nmi_enable = 0;
105107}
106108
107109static WRITE8_HANDLER( lkage_sh_nmi_enable_w )
108110{
109   sound_nmi_enable = 1;
110   if (pending_nmi)
111   { /* probably wrong but commands may go lost otherwise */
112      cputag_set_input_line(space->machine, "audiocpu", INPUT_LINE_NMI, PULSE_LINE);
113      pending_nmi = 0;
111   lkage_state *state = (lkage_state *)space->machine->driver_data;
112
113   state->sound_nmi_enable = 1;
114   if (state->pending_nmi)
115   {
116      /* probably wrong but commands may go lost otherwise */
117      cpu_set_input_line(state->audiocpu, INPUT_LINE_NMI, PULSE_LINE);
118      state->pending_nmi = 0;
114119   }
115120}
116121
r7500r7501
118123   AM_RANGE(0x0000, 0xdfff) AM_ROM
119124   AM_RANGE(0xe000, 0xe7ff) AM_RAM /* work ram */
120125   AM_RANGE(0xe800, 0xefff) AM_RAM_WRITE(paletteram_xxxxRRRRGGGGBBBB_le_w) AM_BASE_GENERIC(paletteram)
121   AM_RANGE(0xf000, 0xf003) AM_RAM AM_BASE(&lkage_vreg) /* video registers */
126   AM_RANGE(0xf000, 0xf003) AM_RAM AM_BASE_MEMBER(lkage_state, vreg) /* video registers */
122127   AM_RANGE(0xf060, 0xf060) AM_WRITE(lkage_sound_command_w)
123128   AM_RANGE(0xf061, 0xf061) AM_WRITENOP
124129   AM_RANGE(0xf062, 0xf062) AM_READWRITE(lkage_mcu_r,lkage_mcu_w)
r7500r7501
131136   AM_RANGE(0xf086, 0xf086) AM_READ_PORT("P2")
132137   AM_RANGE(0xf087, 0xf087) AM_READ(lkage_mcu_status_r)
133138   AM_RANGE(0xf0a0, 0xf0a3) AM_RAM /* unknown */
134   AM_RANGE(0xf0c0, 0xf0c5) AM_RAM AM_BASE(&lkage_scroll)
139   AM_RANGE(0xf0c0, 0xf0c5) AM_RAM AM_BASE_MEMBER(lkage_state, scroll)
135140   AM_RANGE(0xf0e1, 0xf0e1) AM_WRITENOP /* pulsed */
136   AM_RANGE(0xf100, 0xf15f) AM_RAM AM_BASE_GENERIC(spriteram)
137   AM_RANGE(0xf400, 0xffff) AM_RAM_WRITE(lkage_videoram_w) AM_BASE_GENERIC(videoram) /* videoram */
141   AM_RANGE(0xf100, 0xf15f) AM_RAM AM_BASE_MEMBER(lkage_state, spriteram)
142   AM_RANGE(0xf400, 0xffff) AM_RAM_WRITE(lkage_videoram_w) AM_BASE_MEMBER(lkage_state, videoram)
138143ADDRESS_MAP_END
139144
140145static READ8_HANDLER( port_fetch_r )
r7500r7501
148153
149154static ADDRESS_MAP_START( lkage_m68705_map, ADDRESS_SPACE_PROGRAM, 8 )
150155   ADDRESS_MAP_GLOBAL_MASK(0x7ff)
151   AM_RANGE(0x0000, 0x0000) AM_READWRITE(lkage_68705_portA_r,lkage_68705_portA_w)
152   AM_RANGE(0x0001, 0x0001) AM_READWRITE(lkage_68705_portB_r,lkage_68705_portB_w)
153   AM_RANGE(0x0002, 0x0002) AM_READWRITE(lkage_68705_portC_r,lkage_68705_portC_w)
154   AM_RANGE(0x0004, 0x0004) AM_WRITE(lkage_68705_ddrA_w)
155   AM_RANGE(0x0005, 0x0005) AM_WRITE(lkage_68705_ddrB_w)
156   AM_RANGE(0x0006, 0x0006) AM_WRITE(lkage_68705_ddrC_w)
156   AM_RANGE(0x0000, 0x0000) AM_READWRITE(lkage_68705_port_a_r,lkage_68705_port_a_w)
157   AM_RANGE(0x0001, 0x0001) AM_READWRITE(lkage_68705_port_b_r,lkage_68705_port_b_w)
158   AM_RANGE(0x0002, 0x0002) AM_READWRITE(lkage_68705_port_c_r,lkage_68705_port_c_w)
159   AM_RANGE(0x0004, 0x0004) AM_WRITE(lkage_68705_ddr_a_w)
160   AM_RANGE(0x0005, 0x0005) AM_WRITE(lkage_68705_ddr_b_w)
161   AM_RANGE(0x0006, 0x0006) AM_WRITE(lkage_68705_ddr_c_w)
157162   AM_RANGE(0x0010, 0x007f) AM_RAM
158163   AM_RANGE(0x0080, 0x07ff) AM_ROM
159164ADDRESS_MAP_END
r7500r7501
337342
338343static void irqhandler(running_device *device, int irq)
339344{
340   cputag_set_input_line(device->machine, "audiocpu", 0, irq ? ASSERT_LINE : CLEAR_LINE);
345   lkage_state *state = (lkage_state *)device->machine->driver_data;
346   cpu_set_input_line(state->audiocpu, 0, irq ? ASSERT_LINE : CLEAR_LINE);
341347}
342348
343349static const ym2203_interface ym2203_config =
r7500r7501
350356   irqhandler
351357};
352358
359static MACHINE_START( lkage )
360{
361   lkage_state *state = (lkage_state *)machine->driver_data;
362
363   state->maincpu = devtag_get_device(machine, "maincpu");
364   state->audiocpu = devtag_get_device(machine, "audiocpu");
365   state->mcu = devtag_get_device(machine, "mcu");
366
367   state_save_register_global(machine, state->bg_tile_bank);
368   state_save_register_global(machine, state->fg_tile_bank);
369
370   state_save_register_global(machine, state->mcu_ready);
371   state_save_register_global(machine, state->mcu_val);
372   state_save_register_global(machine, state->sound_nmi_enable);
373   state_save_register_global(machine, state->pending_nmi);
374
375   state_save_register_global(machine, state->port_a_in);
376   state_save_register_global(machine, state->port_a_out);
377   state_save_register_global(machine, state->ddr_a);
378   state_save_register_global(machine, state->port_b_in);
379   state_save_register_global(machine, state->port_b_out);
380   state_save_register_global(machine, state->ddr_b);
381   state_save_register_global(machine, state->port_c_in);
382   state_save_register_global(machine, state->port_c_out);
383   state_save_register_global(machine, state->ddr_c);
384   state_save_register_global(machine, state->mcu_sent);
385   state_save_register_global(machine, state->main_sent);
386   state_save_register_global(machine, state->from_main);
387   state_save_register_global(machine, state->from_mcu);
388}
389
390static MACHINE_RESET( lkage )
391{
392   lkage_state *state = (lkage_state *)machine->driver_data;
393
394   state->bg_tile_bank = state->fg_tile_bank = 0;
395
396   state->mcu_ready = 3;
397   state->mcu_val = 0;
398   state->sound_nmi_enable = 0;
399   state->pending_nmi = 0;
400
401   state->port_a_in = 0;
402   state->port_a_out = 0;
403   state->ddr_a = 0;
404   state->port_b_in = 0;
405   state->port_b_out = 0;
406   state->ddr_b = 0;
407   state->port_c_in = 0;
408   state->port_c_out = 0;
409   state->ddr_c = 0;
410   state->mcu_sent = 0;
411   state->main_sent = 0;
412   state->from_main = 0;
413   state->from_mcu = 0;
414}
415
416
353417static MACHINE_DRIVER_START( lkage )
418
419   /* driver data */
420   MDRV_DRIVER_DATA(lkage_state)
421
354422   /* basic machine hardware */
355423   MDRV_CPU_ADD("maincpu", Z80,6000000)
356424   MDRV_CPU_PROGRAM_MAP(lkage_map)
r7500r7501
364432   MDRV_CPU_ADD("mcu", M68705,4000000)   /* ??? */
365433   MDRV_CPU_PROGRAM_MAP(lkage_m68705_map)
366434
435   MDRV_MACHINE_START(lkage)
436   MDRV_MACHINE_RESET(lkage)
437
367438   /* video hardware */
368439   MDRV_SCREEN_ADD("screen", RASTER)
369440   MDRV_SCREEN_REFRESH_RATE(60)
r7500r7501
397468
398469
399470static MACHINE_DRIVER_START( lkageb )
471
472   /* driver data */
473   MDRV_DRIVER_DATA(lkage_state)
474
400475   /* basic machine hardware */
401476   MDRV_CPU_ADD("maincpu", Z80,6000000)
402477   MDRV_CPU_PROGRAM_MAP(lkage_map)
r7500r7501
407482   MDRV_CPU_PROGRAM_MAP(lkage_sound_map)
408483                        /* IRQs are triggered by the YM2203 */
409484
485   MDRV_MACHINE_START(lkage)
486   MDRV_MACHINE_RESET(lkage)
487
410488   /* video hardware */
411489   MDRV_SCREEN_ADD("screen", RASTER)
412490   MDRV_SCREEN_REFRESH_RATE(60)
r7500r7501
592670   ROM_LOAD( "a54-10.2",    0x0000, 0x0200, CRC(17dfbd14) SHA1(f8f0b6dfedd4ba108dad43ccc7697ef4ab9cbf86) )   /* unknown */
593671ROM_END
594672
595static UINT8 mcu_val;
596
597673/*Note: This probably uses another MCU dump,which is undumped.*/
598674
599675static READ8_HANDLER( fake_mcu_r )
600676{
677   lkage_state *state = (lkage_state *)space->machine->driver_data;
601678   int result = 0;
602679
603   switch(mcu_val)
680   switch (state->mcu_val)
604681   {
605682      /*These are for the attract mode*/
606683      case 0x01:
607         result = mcu_val-1;
684         result = state->mcu_val - 1;
608685         break;
609686
610687      case 0x90:
611         result = mcu_val+0x43;
688         result = state->mcu_val + 0x43;
612689         break;
613690
614691      /*Gameplay Protection,checked in this order at a start of a play*/
615692      case 0xa6:
616         result = mcu_val+0x27;
693         result = state->mcu_val + 0x27;
617694         break;
618695
619696      case 0x34:
620         result = mcu_val+0x7f;
697         result = state->mcu_val + 0x7f;
621698         break;
622699
623700      case 0x48:
624         result = mcu_val+0xb7;
701         result = state->mcu_val + 0xb7;
625702         break;
626703
627704      default:
628         result = mcu_val;
705         result = state->mcu_val;
629706         break;
630707   }
631708   return result;
r7500r7501
633710
634711static WRITE8_HANDLER( fake_mcu_w )
635712{
636   mcu_val = data;
713   lkage_state *state = (lkage_state *)space->machine->driver_data;
714   state->mcu_val = data;
637715}
638716
639717static READ8_HANDLER( fake_status_r )
640718{
641   static int res = 3; /* cpu data/mcu ready status */
642   return res;
719   lkage_state *state = (lkage_state *)space->machine->driver_data;
720   return state->mcu_ready;
643721}
644722
645723static DRIVER_INIT( lkageb )
r7500r7501
649727   memory_install_write8_handler(cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0xf062, 0xf062, 0, 0, fake_mcu_w );
650728}
651729
652GAME( 1984, lkage,    0,        lkage,    lkage,    0,        ROT0, "Taito Corporation", "The Legend of Kage", GAME_NO_COCKTAIL )
653GAME( 1984, lkageo,   lkage,    lkage,    lkage,    0,        ROT0, "Taito Corporation", "The Legend of Kage (older)", GAME_NO_COCKTAIL )
654GAME( 1984, lkageoo,  lkage,    lkage,    lkage,    0,        ROT0, "Taito Corporation", "The Legend of Kage (oldest)", GAME_NO_COCKTAIL )
655GAME( 1984, lkageb,   lkage,    lkageb,   lkageb,   lkageb,   ROT0, "bootleg", "The Legend of Kage (bootleg set 1)", GAME_NO_COCKTAIL )
656GAME( 1984, lkageb2,  lkage,    lkageb,   lkageb,   lkageb,   ROT0, "bootleg", "The Legend of Kage (bootleg set 2)", GAME_NO_COCKTAIL )
657GAME( 1984, lkageb3,  lkage,    lkageb,   lkageb,   lkageb,   ROT0, "bootleg", "The Legend of Kage (bootleg set 3)", GAME_NO_COCKTAIL )
730GAME( 1984, lkage,    0,        lkage,    lkage,    0,        ROT0, "Taito Corporation", "The Legend of Kage", GAME_NO_COCKTAIL | GAME_SUPPORTS_SAVE )
731GAME( 1984, lkageo,   lkage,    lkage,    lkage,    0,        ROT0, "Taito Corporation", "The Legend of Kage (older)", GAME_NO_COCKTAIL | GAME_SUPPORTS_SAVE )
732GAME( 1984, lkageoo,  lkage,    lkage,    lkage,    0,        ROT0, "Taito Corporation", "The Legend of Kage (oldest)", GAME_NO_COCKTAIL | GAME_SUPPORTS_SAVE )
733GAME( 1984, lkageb,   lkage,    lkageb,   lkageb,   lkageb,   ROT0, "bootleg", "The Legend of Kage (bootleg set 1)", GAME_NO_COCKTAIL | GAME_SUPPORTS_SAVE )
734GAME( 1984, lkageb2,  lkage,    lkageb,   lkageb,   lkageb,   ROT0, "bootleg", "The Legend of Kage (bootleg set 2)", GAME_NO_COCKTAIL | GAME_SUPPORTS_SAVE )
735GAME( 1984, lkageb3,  lkage,    lkageb,   lkageb,   lkageb,   ROT0, "bootleg", "The Legend of Kage (bootleg set 3)", GAME_NO_COCKTAIL | GAME_SUPPORTS_SAVE )
src/mame/drivers/enigma2.c
r7500r7501
5454#define NUM_PENS   (8)
5555
5656
57typedef struct _enigma2_state enigma2_state;
58struct _enigma2_state
57class enigma2_state
5958{
59public:
60   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, enigma2_state(machine)); }
61
62   enigma2_state(running_machine &machine) { }
63
6064   /* memory pointers */
6165   UINT8 *  videoram;
6266
src/mame/drivers/koikoi.c
r7500r7501
4545
4646static const int input_tab[]= { 0x22, 0x64, 0x44, 0x68, 0x30, 0x50, 0x70, 0x48, 0x28, 0x21, 0x41, 0x82, 0x81, 0x42 };
4747
48typedef struct _koikoi_state koikoi_state;
49struct _koikoi_state
48class koikoi_state
5049{
50public:
51   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, koikoi_state(machine)); }
52
53   koikoi_state(running_machine &machine) { }
54
5155   /* memory pointers */
5256   UINT8 *  videoram;
5357
src/mame/drivers/mazerbla.c
r7500r7501
4343
4444#define MAZERBLA 0x01
4545#define GREATGUN 0x02
46static UINT8 game_id = 0; /* hacks per game */
4746
4847#define MASTER_CLOCK XTAL_4MHz
4948#define SOUND_CLOCK XTAL_14_31818MHz
5049
51static UINT8 *cfb_ram;
5250
53static UINT8 ls670_0[4];
54static UINT8 ls670_1[4];
51class mazerbla_state
52{
53public:
54   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, mazerbla_state(machine)); }
5555
56static UINT8 zpu_int_vector;
56   mazerbla_state(running_machine &machine) { }
5757
58static UINT8 bcd_7445 = 0;
58   /* memory pointers */
59   UINT8 *   cfb_ram;
60   UINT8 *   videoram;
61   size_t    videoram_size;
5962
60static UINT8 vsb_ls273;
61static UINT8 soundlatch;
63   /* video-related */
64   bitmap_t * tmpbitmaps[4];
6265
66   UINT8 vcu_video_reg[4];
67   UINT32 vcu_gfx_addr;
68   UINT32 vcu_gfx_param_addr;
6369
64/*************************************
65 *
66 *  Video Hardware
67 *
68 *************************************/
70   UINT8 bknd_col;
71   UINT8 port02_status;
72   UINT8 vbank;      /* video page select signal, likely for double buffering ?*/
73   UINT32 xpos, ypos, pix_xsize, pix_ysize;
74   UINT8 color1, color2, mode, plane;
75   UINT8 lookup_ram[0x100*4];
76   UINT32 gfx_rom_bank;   /* graphics ROMs are banked */
6977
70static UINT8 bknd_col;
71static UINT8 port02_status = 0;
72static UINT8 VCU_video_reg[4];
73static UINT8 vbank = 0; /* video page select signal, likely for double buffering ?*/
74static UINT32 VCU_gfx_addr = 0;
75static UINT32 VCU_gfx_param_addr = 0;
76static UINT32 xpos=0, ypos=0, pix_xsize=0, pix_ysize=0;
77static UINT8 color=0, color2=0, mode=0, plane=0;
78static UINT8 lookup_RAM[0x100*4];
79static UINT32 gfx_rom_bank;   /* graphics ROMs are banked */
78   double weights_r[2], weights_g[3], weights_b[3];
8079
80   /* misc */
81   UINT8 game_id; /* hacks per game */
82   UINT8 ls670_0[4];
83   UINT8 ls670_1[4];
8184
85   UINT8 zpu_int_vector;
86
87   UINT8 bcd_7445;
88
89   UINT8 vsb_ls273;
90   UINT8 soundlatch;
91
92   /* devices */
93   running_device *maincpu;
94   running_device *subcpu;
95};
96
97
98
8299/***************************************************************************
83100
84101  Convert the color PROMs into a more useable format.
r7500r7501
97114
98115***************************************************************************/
99116
100static double weights_r[2], weights_g[3], weights_b[3];
101
102117static PALETTE_INIT( mazerbla )
103118{
119   mazerbla_state *state = (mazerbla_state *)machine->driver_data;
104120   static const int resistances_r[2]  = { 4700, 2200 };
105121   static const int resistances_gb[3] = { 10000, 4700, 2200 };
106122
107123   /* just to calculate coefficients for later use */
108124   compute_resistor_weights(0,   255,   -1.0,
109         3,   resistances_gb,   weights_g,   3600,   0,
110         3,   resistances_gb,   weights_b,   3600,   0,
111         2,   resistances_r,   weights_r,   3600,   0);
125         3,   resistances_gb,   state->weights_g,   3600,   0,
126         3,   resistances_gb,   state->weights_b,   3600,   0,
127         2,   resistances_r,   state->weights_r,   3600,   0);
112128
113129}
114130
115
116static bitmap_t * tmpbitmaps[4];
117
118131static VIDEO_START( mazerbla )
119132{
120   tmpbitmaps[0] = video_screen_auto_bitmap_alloc(machine->primary_screen);
121   tmpbitmaps[1] = video_screen_auto_bitmap_alloc(machine->primary_screen);
122   tmpbitmaps[2] = video_screen_auto_bitmap_alloc(machine->primary_screen);
123   tmpbitmaps[3] = video_screen_auto_bitmap_alloc(machine->primary_screen);
133   mazerbla_state *state = (mazerbla_state *)machine->driver_data;
134   state->tmpbitmaps[0] = video_screen_auto_bitmap_alloc(machine->primary_screen);
135   state->tmpbitmaps[1] = video_screen_auto_bitmap_alloc(machine->primary_screen);
136   state->tmpbitmaps[2] = video_screen_auto_bitmap_alloc(machine->primary_screen);
137   state->tmpbitmaps[3] = video_screen_auto_bitmap_alloc(machine->primary_screen);
138
139   state_save_register_global_bitmap(machine, state->tmpbitmaps[0]);
140   state_save_register_global_bitmap(machine, state->tmpbitmaps[1]);
141   state_save_register_global_bitmap(machine, state->tmpbitmaps[2]);
142   state_save_register_global_bitmap(machine, state->tmpbitmaps[3]);
124143}
125144
126145#ifdef UNUSED_DEFINITION
r7500r7501
134153
135154VIDEO_UPDATE( test_vcu )
136155{
156   mazerbla_state *state = (mazerbla_state *)screen->machine->driver_data;
137157   int j;
138158   char buf[128];
139159
140   UINT32 color_base=0;
160   UINT32 color_base = 0;
141161
142   if (game_id==MAZERBLA)
162   if (state->game_id == MAZERBLA)
143163      color_base = 0x80;   /* 0x80 constant: matches Mazer Blazer movie */
144164
145   if (game_id==GREATGUN)
146      color_base = 0x0;
165   if (state->game_id == GREATGUN)
166      color_base = 0x00;
147167
148   bitmap_fill(bitmap,NULL,0);
168   bitmap_fill(bitmap, NULL, 0);
149169//  logerror("-->frame\n");
150170
151171   if (planes_enabled[3])
152      copybitmap(bitmap,tmpbitmaps[3],0,0,0,0,cliprect);
172      copybitmap(bitmap, state->tmpbitmaps[3], 0, 0, 0, 0, cliprect);
153173
154174   if (planes_enabled[2])
155      copybitmap_trans(bitmap,tmpbitmaps[2],0,0,0,0,cliprect,color_base);
175      copybitmap_trans(bitmap, state->tmpbitmaps[2], 0, 0, 0, 0,cliprect, color_base);
156176
157   bitmap_fill(tmpbitmaps[2],NULL,color_base);
177   bitmap_fill(state->tmpbitmaps[2], NULL, color_base);
158178
159179   if (planes_enabled[1])
160      copybitmap_trans(bitmap,tmpbitmaps[1],0,0,0,0,cliprect,color_base);
180      copybitmap_trans(bitmap, state->tmpbitmaps[1], 0, 0, 0, 0,cliprect, color_base);
161181
162   bitmap_fill(tmpbitmaps[1],NULL,color_base);
182   bitmap_fill(state->tmpbitmaps[1], NULL, color_base);
163183
164184   if (planes_enabled[0])
165      copybitmap_trans(bitmap,tmpbitmaps[0],0,0,0,0,cliprect,color_base);
185      copybitmap_trans(bitmap, state->tmpbitmaps[0], 0, 0, 0, 0,cliprect, color_base);
166186
167   bitmap_fill(tmpbitmaps[0],NULL,color_base);
187   bitmap_fill(state->tmpbitmaps[0], NULL, color_base);
168188
169189   if (input_code_pressed_once(screen->machine, KEYCODE_1))   /* plane 1 */
170190      planes_enabled[0] ^= 1;
r7500r7501
191211      dbg_vbank ^= 1;
192212
193213   if (input_code_pressed_once(screen->machine, KEYCODE_L))   /* showlookup ram */
194      dbg_lookup = (dbg_lookup+1)%5;//0,1,2,3, 4-off
214      dbg_lookup = (dbg_lookup + 1) % 5;   //0,1,2,3, 4-off
195215
196216
197217   if (dbg_info)
r7500r7501
210230      if (dbg_lookup!=4)
211231      {
212232         int lookup_offs = (dbg_lookup)*256; //=0,1,2,3*256
213         int y,x;
233         int y, x;
214234
215         for (y=0; y<16; y++)
235         for (y = 0; y < 16; y++)
216236         {
217            memset(buf,0,128);
218            sprintf( buf+strlen(buf), "%04x ", lookup_offs+y*16 );
219            for (x=0; x<16; x++)
237            memset(buf, 0, 128);
238            sprintf(buf + strlen(buf), "%04x ", lookup_offs + y * 16);
239            for (x = 0; x < 16; x++)
220240            {
221               sprintf( buf+strlen(buf), "%02x ", lookup_RAM[ lookup_offs+x+y*16 ] );
241               sprintf(buf + strlen(buf), "%02x ", lookup_ram[lookup_offs + x + y * 16]);
222242            }
223243            ui_draw_text(buf, 0, (2 + y) * ui_get_line_height());
224244         }
r7500r7501
230250#endif
231251
232252
233/* these two VIDEO_UPDATE()s will be joined one day */
234static VIDEO_UPDATE( greatgun )
235{
236   UINT32 color_base=0;
237
238   if (game_id==MAZERBLA)
239      color_base = 0x80;   /* 0x80 constant: matches Mazer Blazer movie */
240
241   if (game_id==GREATGUN)
242      color_base = 0x0;
243
244//  bitmap_fill(bitmap,NULL,0);
245
246   copybitmap      (bitmap,tmpbitmaps[3],0,0,0,0,cliprect);
247   copybitmap_trans(bitmap,tmpbitmaps[2],0,0,0,0,cliprect,color_base);
248   copybitmap_trans(bitmap,tmpbitmaps[1],0,0,0,0,cliprect,color_base);
249   copybitmap_trans(bitmap,tmpbitmaps[0],0,0,0,0,cliprect,color_base);
250   return 0;
251}
252
253253static VIDEO_UPDATE( mazerbla )
254254{
255   UINT32 color_base=0;
255   mazerbla_state *state = (mazerbla_state *)screen->machine->driver_data;
256   UINT32 color_base = 0;
256257
257   if (game_id==MAZERBLA)
258   if (state->game_id == MAZERBLA)
258259      color_base = 0x80;   /* 0x80 constant: matches Mazer Blazer movie */
259260
260   if (game_id==GREATGUN)
261      color_base = 0x0;
261   if (state->game_id == GREATGUN)
262      color_base = 0x00;
262263
263//  bitmap_fill(bitmap,NULL,0);
264   //  bitmap_fill(bitmap, NULL, 0);
264265
265   copybitmap      (bitmap,tmpbitmaps[3],0,0,0,0,cliprect); //text
266   copybitmap_trans(bitmap,tmpbitmaps[2],0,0,0,0,cliprect,0);
267   copybitmap_trans(bitmap,tmpbitmaps[1],0,0,0,0,cliprect,0); //haircross
268   copybitmap_trans(bitmap,tmpbitmaps[0],0,0,0,0,cliprect,0); //sprites
266   copybitmap(bitmap, state->tmpbitmaps[3], 0, 0, 0, 0, cliprect);
267   copybitmap_trans(bitmap, state->tmpbitmaps[2], 0, 0, 0, 0, cliprect, 0);
268   copybitmap_trans(bitmap, state->tmpbitmaps[1], 0, 0, 0, 0, cliprect, 0);
269   copybitmap_trans(bitmap, state->tmpbitmaps[0], 0, 0, 0, 0, cliprect, 0);
269270   return 0;
270271}
271272
272273
273274static WRITE8_HANDLER( cfb_backgnd_color_w )
274275{
275   if (bknd_col != data)
276   mazerbla_state *state = (mazerbla_state *)space->machine->driver_data;
277
278   if (state->bknd_col != data)
276279   {
277      int r,g,b, bit0, bit1, bit2;
280      int r, g, b, bit0, bit1, bit2;
278281
279      bknd_col = data;
282      state->bknd_col = data;
280283
281284      /* red component */
282      bit1 = (data >> 7) & 0x01;
283      bit0 = (data >> 6) & 0x01;
284      r = combine_2_weights(weights_r, bit0, bit1);
285      bit1 = BIT(data, 7);
286      bit0 = BIT(data, 6);
287      r = combine_2_weights(state->weights_r, bit0, bit1);
285288
286289      /* green component */
287      bit2 = (data >> 5) & 0x01;
288      bit1 = (data >> 4) & 0x01;
289      bit0 = (data >> 3) & 0x01;
290      g = combine_3_weights(weights_g, bit0, bit1, bit2);
290      bit2 = BIT(data, 5);
291      bit1 = BIT(data, 4);
292      bit0 = BIT(data, 3);
293      g = combine_3_weights(state->weights_g, bit0, bit1, bit2);
291294
292295      /* blue component */
293      bit2 = (data >> 2) & 0x01;
294      bit1 = (data >> 1) & 0x01;
295      bit0 = (data >> 0) & 0x01;
296      b = combine_3_weights(weights_b, bit0, bit1, bit2);
296      bit2 = BIT(data, 2);
297      bit1 = BIT(data, 1);
298      bit0 = BIT(data, 0);
299      b = combine_3_weights(state->weights_b, bit0, bit1, bit2);
297300
298301      palette_set_color(space->machine, 255, MAKE_RGB(r, g, b));
299302      //logerror("background color (port 01) write=%02x\n",data);
r7500r7501
301304}
302305
303306
304static WRITE8_HANDLER(cfb_vbank_w)
307static WRITE8_HANDLER( cfb_vbank_w )
305308{
309   mazerbla_state *state = (mazerbla_state *)space->machine->driver_data;
310
306311   /* only bit 6 connected */
307   vbank = (data & 0x40)>>6;
312   state->vbank = BIT(data, 6);
308313}
309314
310315
311static WRITE8_HANDLER(cfb_rom_bank_sel_w)   /* mazer blazer */
316static WRITE8_HANDLER( cfb_rom_bank_sel_w )   /* mazer blazer */
312317{
313   gfx_rom_bank = data;
318   mazerbla_state *state = (mazerbla_state *)space->machine->driver_data;
319   state->gfx_rom_bank = data;
314320
315   memory_set_bankptr(space->machine,  "bank1", memory_region(space->machine, "sub2") + (gfx_rom_bank * 0x2000) + 0x10000 );
321   memory_set_bankptr(space->machine,  "bank1", memory_region(space->machine, "sub2") + (state->gfx_rom_bank * 0x2000) + 0x10000);
316322}
317323
318static WRITE8_HANDLER(cfb_rom_bank_sel_w_gg)   /* great guns */
324static WRITE8_HANDLER( cfb_rom_bank_sel_w_gg )   /* great guns */
319325{
320   gfx_rom_bank = data>>1;
326   mazerbla_state *state = (mazerbla_state *)space->machine->driver_data;
327   state->gfx_rom_bank = data >> 1;
321328
322   memory_set_bankptr(space->machine,  "bank1", memory_region(space->machine, "sub2") + (gfx_rom_bank * 0x2000) + 0x10000 );
329   memory_set_bankptr(space->machine,  "bank1", memory_region(space->machine, "sub2") + (state->gfx_rom_bank * 0x2000) + 0x10000);
323330}
324331
325332
326333/* VCU status? */
327334static READ8_HANDLER( cfb_port_02_r )
328335{
329   port02_status ^= 0xff;
330   return (port02_status);
336   mazerbla_state *state = (mazerbla_state *)space->machine->driver_data;
337   state->port02_status ^= 0xff;
338   return state->port02_status;
331339}
332340
333341
334static WRITE8_HANDLER( VCU_video_reg_w )
342static WRITE8_HANDLER( vcu_video_reg_w )
335343{
336   if (VCU_video_reg[offset] != data)
344   mazerbla_state *state = (mazerbla_state *)space->machine->driver_data;
345   if (state->vcu_video_reg[offset] != data)
337346   {
338      VCU_video_reg[offset] = data;
339      //popmessage("video_reg= %02x %02x %02x %02x", VCU_video_reg[0], VCU_video_reg[1], VCU_video_reg[2], VCU_video_reg[3] );
340      //logerror("video_reg= %02x %02x %02x %02x\n", VCU_video_reg[0], VCU_video_reg[1], VCU_video_reg[2], VCU_video_reg[3] );
347      state->vcu_video_reg[offset] = data;
348      //popmessage("video_reg= %02x %02x %02x %02x", state->vcu_video_reg[0], state->vcu_video_reg[1], state->vcu_video_reg[2], state->vcu_video_reg[3]);
349      //logerror("video_reg= %02x %02x %02x %02x\n", state->vcu_video_reg[0], state->vcu_video_reg[1], state->vcu_video_reg[2], state->vcu_video_reg[3]);
341350   }
342351}
343352
344static READ8_HANDLER( VCU_set_cmd_param_r )
353static READ8_HANDLER( vcu_set_cmd_param_r )
345354{
346   VCU_gfx_param_addr = offset;
355   mazerbla_state *state = (mazerbla_state *)space->machine->driver_data;
356   state->vcu_gfx_param_addr = offset;
347357
348358   /* offset  = 0 is not known */
349   xpos      = cfb_ram[VCU_gfx_param_addr + 1] | (cfb_ram[VCU_gfx_param_addr + 2]<<8);
350   ypos      = cfb_ram[VCU_gfx_param_addr + 3] | (cfb_ram[VCU_gfx_param_addr + 4]<<8);
351   color     = cfb_ram[VCU_gfx_param_addr + 5];
352   color2    = cfb_ram[VCU_gfx_param_addr + 6];
353   mode      = cfb_ram[VCU_gfx_param_addr + 7];
354   pix_xsize = cfb_ram[VCU_gfx_param_addr + 8];
355   pix_ysize = cfb_ram[VCU_gfx_param_addr + 9];
359   state->xpos      = state->cfb_ram[state->vcu_gfx_param_addr + 1] | (state->cfb_ram[state->vcu_gfx_param_addr + 2]<<8);
360   state->ypos      = state->cfb_ram[state->vcu_gfx_param_addr + 3] | (state->cfb_ram[state->vcu_gfx_param_addr + 4]<<8);
361   state->color1    = state->cfb_ram[state->vcu_gfx_param_addr + 5];
362   state->color2    = state->cfb_ram[state->vcu_gfx_param_addr + 6];
363   state->mode      = state->cfb_ram[state->vcu_gfx_param_addr + 7];
364   state->pix_xsize = state->cfb_ram[state->vcu_gfx_param_addr + 8];
365   state->pix_ysize = state->cfb_ram[state->vcu_gfx_param_addr + 9];
356366
357   plane = mode & 3;
367   state->plane = state->mode & 3;
358368
359369   return 0;
360370}
361371
362372
363static READ8_HANDLER( VCU_set_gfx_addr_r )
373static READ8_HANDLER( vcu_set_gfx_addr_r )
364374{
375   mazerbla_state *state = (mazerbla_state *)space->machine->driver_data;
376   UINT8 * rom = memory_region(space->machine, "sub2") + (state->gfx_rom_bank * 0x2000) + 0x10000;
365377   int offs;
366   int x,y;
378   int x, y;
367379   int bits = 0;
380   UINT8 color_base = 0;
368381
369   UINT8 color_base=0;
382   if (state->game_id == MAZERBLA)
383      color_base = 0x80;   /* 0x80 - good for Mazer Blazer: (only in game, CRT test mode is bad) */
370384
371   UINT8 * rom = memory_region(space->machine, "sub2") + (gfx_rom_bank * 0x2000) + 0x10000;
372
385   if (state->game_id == GREATGUN)
386      color_base = 0x00;   /* 0x00 - good for Great Guns: (both in game and CRT test mode) */
373387/*
374    if ((mode<=0x07) || (mode>=0x10))
388    if ((mode <= 0x07) || (mode >= 0x10))
375389    {
376390        logerror("paradr=");
377        logerror("%3x ",VCU_gfx_param_addr );
391        logerror("%3x ", state->vcu_gfx_param_addr );
378392
379        logerror("%02x ", cfb_ram[VCU_gfx_param_addr + 0] );
380        logerror("x=%04x ", xpos );                 //1,2
381        logerror("y=%04x ", ypos );                 //3,4
382        logerror("color=%02x ", color);             //5
383        logerror("color2=%02x ", color2);           //6
384        logerror("mode=%02x ", mode );              //7
385        logerror("xpix=%02x ", pix_xsize );         //8
386        logerror("ypix=%02x ", pix_ysize );         //9
393        logerror("%02x ", state->cfb_ram[vcu_gfx_param_addr + 0] );
394        logerror("x=%04x ", state->xpos );                 //1,2
395        logerror("y=%04x ", state->ypos );                 //3,4
396        logerror("color1=%02x ", state->color1);             //5
397        logerror("color2=%02x ", state->color2);           //6
398        logerror("mode=%02x ", state->mode );              //7
399        logerror("xpix=%02x ", state->pix_xsize );         //8
400        logerror("ypix=%02x ", state->pix_ysize );         //9
387401
388        logerror("addr=%4i bank=%1i\n", offset, gfx_rom_bank);
402        logerror("addr=%4i bank=%1i\n", offset, state->gfx_rom_bank);
389403    }
390404*/
391405
392   VCU_gfx_addr = offset;
406   state->vcu_gfx_addr = offset;
393407
394408   /* draw */
395   offs = VCU_gfx_addr;
409   offs = state->vcu_gfx_addr;
396410
397   switch(mode)
411   switch(state->mode)
398412   {
399413      /* 2 bits per pixel */
400414      case 0x0f:
r7500r7501
403417      case 0x0c:
404418//      if (dbg_gfx_e)
405419//      {
406//          if (vbank==dbg_vbank)
420//          if (state->vbank == dbg_vbank)
407421      {
408         if (game_id==MAZERBLA)
409            color_base = 0x80;   /* 0x80 constant: matches Mazer Blazer movie */
410
411         if (game_id==GREATGUN)
412            color_base = 0x00;
413
414         for (y = 0; y <= pix_ysize; y++)
422         for (y = 0; y <= state->pix_ysize; y++)
415423         {
416            for (x = 0; x <= pix_xsize; x++)
424            for (x = 0; x <= state->pix_xsize; x++)
417425            {
418               UINT8 pixeldata = rom[(offs + (bits>>3)) % 0x2000];
419               UINT8 data = (pixeldata>>(6-(bits&7))) & 3;
426               UINT8 pixeldata = rom[(offs + (bits >> 3)) % 0x2000];
427               UINT8 data = (pixeldata >> (6 - (bits & 7))) & 3;
420428               UINT8 col = 0;
421429
422430               switch(data)
423431               {
424432                  case 0:
425                     col = color_base | ((color &0x0f));      //background PEN
433                     col = color_base | ((state->color1 & 0x0f));      //background PEN
426434                     break;
427435                  case 1:
428                     col = color_base | ((color &0xf0)>>4);   //foreground PEN
436                     col = color_base | ((state->color1 & 0xf0) >> 4);   //foreground PEN
429437                     break;
430438                  case 2:
431                     col = color_base | ((color2 &0x0f));   //background PEN2
439                     col = color_base | ((state->color2 & 0x0f));   //background PEN2
432440                     break;
433441                  case 3:
434                     col = color_base | ((color2 &0xf0)>>4);   //foreground PEN2
442                     col = color_base | ((state->color2 & 0xf0) >> 4);   //foreground PEN2
435443                     break;
436444               }
437445
438               if ( ((xpos+x)<256) && ((ypos+y)<256) )
439                  *BITMAP_ADDR16(tmpbitmaps[plane], ypos+y, xpos+x) = col;
446               if (((state->xpos + x) < 256) && ((state->ypos + y) < 256) )
447                  *BITMAP_ADDR16(state->tmpbitmaps[state->plane], state->ypos + y, state->xpos + x) = col;
440448
441               bits+=2;
449               bits += 2;
442450            }
443451         }
444452      }
r7500r7501
452460      case 0x08:/* */
453461//      if (dbg_gfx_e)
454462//      {
455//          if (vbank==dbg_vbank)
463//          if (state->vbank == dbg_vbank)
456464      {
457         if (game_id==MAZERBLA)
458            color_base = 0x80;   /* 0x80 - good for Mazer Blazer: (only in game, CRT test mode is bad) */
459465
460         if (game_id==GREATGUN)
461            color_base = 0x00;   /* 0x00 - good for Great Guns: (both in game and CRT test mode) */
462
463         for (y = 0; y <= pix_ysize; y++)
466         for (y = 0; y <= state->pix_ysize; y++)
464467         {
465            for (x = 0; x <= pix_xsize; x++)
468            for (x = 0; x <= state->pix_xsize; x++)
466469            {
467               UINT8 pixeldata = rom[(offs + (bits>>3)) % 0x2000];
468               UINT8 data = (pixeldata>>(7-(bits&7))) & 1;
470               UINT8 pixeldata = rom[(offs + (bits >> 3)) % 0x2000];
471               UINT8 data = (pixeldata >> (7 - (bits & 7))) & 1;
469472
470473               /* color = 4 MSB = front PEN, 4 LSB = background PEN */
471474
472               if ( ((xpos+x)<256) && ((ypos+y)<256) )
473                  *BITMAP_ADDR16(tmpbitmaps[plane], ypos+y, xpos+x) = data? color_base | ((color&0xf0)>>4): color_base | ((color&0x0f));
475               if (((state->xpos + x) < 256) && ((state->ypos + y) < 256))
476                  *BITMAP_ADDR16(state->tmpbitmaps[state->plane], state->ypos + y, state->xpos + x) = data ? color_base | ((state->color1 & 0xf0) >> 4): color_base | ((state->color1 & 0x0f));
474477
475               bits+=1;
478               bits += 1;
476479            }
477480         }
478481      }
r7500r7501
485488      case 0x00:
486489//      if (dbg_gfx_e)
487490//      {
488//          if (vbank==dbg_vbank)
491//          if (state->vbank == dbg_vbank)
489492      {
490         if (game_id==MAZERBLA)
491            color_base = 0x80;   /* 0x80 - good for Mazer Blazer: (only in game, CRT test mode is bad) */
492
493         if (game_id==GREATGUN)
494            color_base = 0x00;   /* 0x00 - good for Great Guns: (both in game and CRT test mode) */
495
496         for (y = 0; y <= pix_ysize; y++)
493         for (y = 0; y <= state->pix_ysize; y++)
497494         {
498            for (x = 0; x <= pix_xsize; x++)
495            for (x = 0; x <= state->pix_xsize; x++)
499496            {
500               UINT8 pixeldata = rom[(offs + (bits>>3)) % 0x2000];
501               UINT8 data = (pixeldata>>(4-(bits&7))) & 15;
497               UINT8 pixeldata = rom[(offs + (bits >> 3)) % 0x2000];
498               UINT8 data = (pixeldata >> (4 - (bits & 7))) & 15;
502499               UINT8 col = 0;
503500
504501               col = color_base | data;
505502
506               if ( ((xpos+x)<256) && ((ypos+y)<256) )
507                  *BITMAP_ADDR16(tmpbitmaps[plane], ypos+y, xpos+x) = col;
503               if (((state->xpos + x) < 256) && ((state->ypos + y) < 256))
504                  *BITMAP_ADDR16(state->tmpbitmaps[state->plane], state->ypos + y, state->xpos + x) = col;
508505
509               bits+=4;
506               bits += 4;
510507            }
511508         }
512509      }
513510//      }
514511      break;
515512   default:
516      popmessage("not supported VCU drawing mode=%2x", mode);
513      popmessage("not supported VCU drawing mode=%2x", state->mode);
517514      break;
518515   }
519516
520517   return 0;
521518}
522519
523static READ8_HANDLER( VCU_set_clr_addr_r )
520static READ8_HANDLER( vcu_set_clr_addr_r )
524521{
522   mazerbla_state *state = (mazerbla_state *)space->machine->driver_data;
523   UINT8 * rom = memory_region(space->machine, "sub2") + (state->gfx_rom_bank * 0x2000) + 0x10000;
525524   int offs;
526   int x,y;
525   int x, y;
527526   int bits = 0;
528527
529   UINT8 color_base=0;
528   UINT8 color_base = 0;
530529
531   UINT8 * rom = memory_region(space->machine, "sub2") + (gfx_rom_bank * 0x2000) + 0x10000;
532530
533531/*
534532    //if (0) //(mode != 0x07)
535533    {
536534        logerror("paladr=");
537        logerror("%3x ",VCU_gfx_param_addr );
535        logerror("%3x ", state->vcu_gfx_param_addr );
538536
539        logerror("%02x ", cfb_ram[VCU_gfx_param_addr + 0] );
540        logerror("x=%04x ", xpos );                 //1,2
541        logerror("y=%04x ", ypos );                 //3,4
542        logerror("color=%02x ", color);             //5
543        logerror("color2=%02x ", color2 );          //6
544        logerror("mode=%02x ", mode );              //7
545        logerror("xpix=%02x ", pix_xsize );         //8
546        logerror("ypix=%02x ", pix_ysize );         //9
537        logerror("%02x ", state->cfb_ram[state->vcu_gfx_param_addr + 0] );
538        logerror("x=%04x ", state->xpos );                 //1,2
539        logerror("y=%04x ", state->ypos );                 //3,4
540        logerror("color1=%02x ", state->color1);             //5
541        logerror("color2=%02x ", state->color2 );          //6
542        logerror("mode=%02x ", state->mode );              //7
543        logerror("xpix=%02x ", state->pix_xsize );         //8
544        logerror("ypix=%02x ", state->pix_ysize );         //9
547545
548        logerror("addr=%4i bank=%1i\n", offset, gfx_rom_bank);
546        logerror("addr=%4i bank=%1i\n", offset, state->gfx_rom_bank);
549547
550        for (y=0; y<16; y++)
548        for (y = 0; y < 16; y++)
551549        {
552            logerror("%04x: ",offset+y*16);
553            for (x=0; x<16; x++)
550            logerror("%04x: ", offset + y * 16);
551            for (x = 0; x < 16; x++)
554552            {
555                logerror("%02x ",cfb_ram[offset+x+y*16]);
553                logerror("%02x ", state->cfb_ram[offset + x + y * 16]);
556554            }
557555            logerror("\n");
558556        }
r7500r7501
563561/* copy palette / CLUT(???) */
564562
565563
566   switch(mode)
564   switch (state->mode)
567565   {
568566      case 0x13: /* draws sprites?? in mazer blazer and ... wrong sprite in place of targeting-cross and UFO laser */
569567      case 0x03:
r7500r7501
571569           the draw command/palette selector is done via the 'mode' only ... */
572570      //if (dbg_clr_e)
573571      {
574         offs = VCU_gfx_addr;
572         offs = state->vcu_gfx_addr;
575573
576         if (game_id==MAZERBLA)
574         if (state->game_id == MAZERBLA)
577575            color_base = 0x80;   /* 0x80 constant: matches Mazer Blazer movie */
578576
579         if (game_id==GREATGUN)
577         if (state->game_id == GREATGUN)
580578            color_base = 0x00;
581579
582         for (y = 0; y <= pix_ysize; y++)
580         for (y = 0; y <= state->pix_ysize; y++)
583581         {
584            for (x = 0; x <= pix_xsize; x++)
582            for (x = 0; x <= state->pix_xsize; x++)
585583            {
586               UINT8 pixeldata = rom[(offs + (bits>>3)) % 0x2000];
587               UINT8 data = (pixeldata>>(6-(bits&7))) & 3;
584               UINT8 pixeldata = rom[(offs + (bits >> 3)) % 0x2000];
585               UINT8 data = (pixeldata >> (6 - (bits & 7))) & 3;
588586               UINT8 col = 0;
589587
590588               switch(data)
591589               {
592590                  case 0:
593                     col = color_base | ((color &0x0f));      //background PEN
591                     col = color_base | ((state->color1 & 0x0f));      //background PEN
594592                     break;
595593                  case 1:
596                     col = color_base | ((color &0xf0)>>4);   //foreground PEN
594                     col = color_base | ((state->color1 & 0xf0) >> 4);   //foreground PEN
597595                     break;
598596                  case 2:
599                     col = color_base | ((color2 &0x0f));   //background PEN2
597                     col = color_base | ((state->color2 & 0x0f));   //background PEN2
600598                     break;
601599                  case 3:
602                     col = color_base | ((color2 &0xf0)>>4);   //foreground PEN2
600                     col = color_base | ((state->color2 & 0xf0) >> 4);   //foreground PEN2
603601                     break;
604602               }
605603
606               if ( ((xpos+x)<256) && ((ypos+y)<256) )
607                  *BITMAP_ADDR16(tmpbitmaps[plane], ypos+y, xpos+x) = col;
604               if (((state->xpos + x) < 256) && ((state->ypos + y) < 256))
605                  *BITMAP_ADDR16(state->tmpbitmaps[state->plane], state->ypos + y, state->xpos + x) = col;
608606
609                  bits+=2;
607                  bits += 2;
610608            }
611609         }
612610      }
r7500r7501
616614      case 0x07:
617615      offs = offset;
618616
619      switch(ypos)
617      switch(state->ypos)
620618      {
621619         case 6: //seems to encode palette write
622620         {
623            int r,g,b, bit0, bit1, bit2;
621            int r, g, b, bit0, bit1, bit2;
624622
625623            //pix_xsize and pix_ysize seem to be related to palette length ? (divide by 2)
626            int lookup_offs = (ypos>>1)*256; //=3*256
624            int lookup_offs = (state->ypos >> 1) * 256; //=3*256
627625
628            for (y=0; y<16; y++)
626            for (y = 0; y < 16; y++)
629627            {
630               for (x=0; x<16; x++)
628               for (x = 0; x < 16; x++)
631629               {
632                  UINT8 colour = cfb_ram[ offs + x + y*16 ];
630                  UINT8 colour = state->cfb_ram[offs + x + y * 16];
633631
634632                  /* red component */
635633                  bit1 = (colour >> 7) & 0x01;
636634                  bit0 = (colour >> 6) & 0x01;
637                  r = combine_2_weights(weights_r, bit0, bit1);
635                  r = combine_2_weights(state->weights_r, bit0, bit1);
638636
639637                  /* green component */
640638                  bit2 = (colour >> 5) & 0x01;
641639                  bit1 = (colour >> 4) & 0x01;
642640                  bit0 = (colour >> 3) & 0x01;
643                  g = combine_3_weights(weights_g, bit0, bit1, bit2);
641                  g = combine_3_weights(state->weights_g, bit0, bit1, bit2);
644642
645643                  /* blue component */
646644                  bit2 = (colour >> 2) & 0x01;
647645                  bit1 = (colour >> 1) & 0x01;
648646                  bit0 = (colour >> 0) & 0x01;
649                  b = combine_3_weights(weights_b, bit0, bit1, bit2);
647                  b = combine_3_weights(state->weights_b, bit0, bit1, bit2);
650648
651                  if ((x+y*16)<255)//keep color 255 free for use as background color
652                     palette_set_color(space->machine, x+y*16, MAKE_RGB(r, g, b));
649                  if ((x + y * 16) < 255)//keep color 255 free for use as background color
650                     palette_set_color(space->machine, x + y * 16, MAKE_RGB(r, g, b));
653651
654                  lookup_RAM[ lookup_offs + x + y*16 ] = colour;
652                  state->lookup_ram[lookup_offs + x + y * 16] = colour;
655653               }
656654            }
657655         }
658656         break;
659657         case 4: //seems to encode lookup???? table write
660658         {
661            int lookup_offs = (ypos>>1)*256; //=2*256
659            int lookup_offs = (state->ypos >> 1) * 256; //=2*256
662660
663            for (y=0; y<16; y++)
661            for (y = 0; y < 16; y++)
664662            {
665               for (x=0; x<16; x++)
663               for (x = 0; x < 16; x++)
666664               {
667                  UINT8 dat = cfb_ram[ offs + x + y*16 ];
668                  lookup_RAM[ lookup_offs + x + y*16 ] = dat;
665                  UINT8 dat = state->cfb_ram[offs + x + y * 16];
666                  state->lookup_ram[lookup_offs + x + y * 16] = dat;
669667               }
670668            }
671669         }
672670         break;
673671         case 2: //seems to encode lookup???? table write
674672         {
675            int lookup_offs = (ypos>>1)*256; //=1*256
673            int lookup_offs = (state->ypos >> 1) * 256; //=1*256
676674
677            for (y=0; y<16; y++)
675            for (y = 0; y < 16; y++)
678676            {
679               for (x=0; x<16; x++)
677               for (x = 0; x < 16; x++)
680678               {
681                  UINT8 dat = cfb_ram[ offs + x + y*16 ];
682                  lookup_RAM[ lookup_offs + x + y*16 ] = dat;
679                  UINT8 dat = state->cfb_ram[offs + x + y * 16];
680                  state->lookup_ram[lookup_offs + x + y * 16] = dat;
683681               }
684682            }
685683         }
686684         break;
687685         case 0: //seems to encode lookup???? table write
688686         {
689            int lookup_offs = (ypos>>1)*256; //=0*256
687            int lookup_offs = (state->ypos >> 1) * 256; //=0*256
690688
691            for (y=0; y<16; y++)
689            for (y = 0; y < 16; y++)
692690            {
693               for (x=0; x<16; x++)
691               for (x = 0; x < 16; x++)
694692               {
695                  UINT8 dat = cfb_ram[ offs + x + y*16 ];
696                  lookup_RAM[ lookup_offs + x + y*16 ] = dat;
693                  UINT8 dat = state->cfb_ram[offs + x + y * 16];
694                  state->lookup_ram[lookup_offs + x + y * 16] = dat;
697695               }
698696            }
699697         }
700698         break;
701699
702700         default:
703         popmessage("not supported lookup/color write mode=%2x", ypos);
701         popmessage("not supported lookup/color write mode=%2x", state->ypos);
704702         break;
705703      }
706704      break;
707705
708706   default:
709      popmessage("not supported VCU color mode=%2x", mode);
707      popmessage("not supported VCU color mode=%2x", state->mode);
710708      break;
711709   }
712710
r7500r7501
721719
722720static WRITE8_HANDLER( cfb_zpu_int_req_set_w )
723721{
724   zpu_int_vector &= ~2;   /* clear D1 on INTA (interrupt acknowledge) */
722   mazerbla_state *state = (mazerbla_state *)space->machine->driver_data;
725723
726   cputag_set_input_line(space->machine, "maincpu", 0, ASSERT_LINE);   /* main cpu interrupt (comes from CFB (generated at the start of INT routine on CFB) - vblank?) */
724   state->zpu_int_vector &= ~2;   /* clear D1 on INTA (interrupt acknowledge) */
725
726   cpu_set_input_line(state->maincpu, 0, ASSERT_LINE);   /* main cpu interrupt (comes from CFB (generated at the start of INT routine on CFB) - vblank?) */
727727}
728728
729729static READ8_HANDLER( cfb_zpu_int_req_clr )
730730{
731   zpu_int_vector |= 2;
731   mazerbla_state *state = (mazerbla_state *)space->machine->driver_data;
732732
733   state->zpu_int_vector |= 2;
734
733735   /* clear the INT line when there are no more interrupt requests */
734   if (zpu_int_vector == 0xff)
735      cputag_set_input_line(space->machine, "maincpu", 0, CLEAR_LINE);
736   if (state->zpu_int_vector == 0xff)
737      cpu_set_input_line(state->maincpu, 0, CLEAR_LINE);
736738
737739   return 0;
738740}
739741
740742static READ8_HANDLER( ls670_0_r )
741743{
744   mazerbla_state *state = (mazerbla_state *)space->machine->driver_data;
745
742746   /* set a timer to force synchronization after the read */
743747   timer_call_after_resynch(space->machine, NULL, 0, NULL);
744748
745   return ls670_0[offset];
749   return state->ls670_0[offset];
746750}
747751
748752static TIMER_CALLBACK( deferred_ls670_0_w )
749753{
750   int offset = (param>>8) & 255;
754   mazerbla_state *state = (mazerbla_state *)machine->driver_data;
755   int offset = (param >> 8) & 255;
751756   int data = param & 255;
752757
753   ls670_0[offset] = data;
758   state->ls670_0[offset] = data;
754759}
755760
756761static WRITE8_HANDLER( ls670_0_w )
757762{
758763   /* do this on a timer to let the CPUs synchronize */
759   timer_call_after_resynch(space->machine, NULL, (offset<<8) | data, deferred_ls670_0_w);
764   timer_call_after_resynch(space->machine, NULL, (offset << 8) | data, deferred_ls670_0_w);
760765}
761766
762767static READ8_HANDLER( ls670_1_r )
763768{
769   mazerbla_state *state = (mazerbla_state *)space->machine->driver_data;
770
764771   /* set a timer to force synchronization after the read */
765772   timer_call_after_resynch(space->machine, NULL, 0, NULL);
766773
767   return ls670_1[offset];
774   return state->ls670_1[offset];
768775}
769776
770777static TIMER_CALLBACK( deferred_ls670_1_w )
771778{
772   int offset = (param>>8) & 255;
779   mazerbla_state *state = (mazerbla_state *)machine->driver_data;
780   int offset = (param >> 8) & 255;
773781   int data = param & 255;
774782
775   ls670_1[offset] = data;
783   state->ls670_1[offset] = data;
776784}
777785
778786static WRITE8_HANDLER( ls670_1_w )
779787{
780788   /* do this on a timer to let the CPUs synchronize */
781   timer_call_after_resynch(space->machine, NULL, (offset<<8) | data, deferred_ls670_1_w);
789   timer_call_after_resynch(space->machine, NULL, (offset << 8) | data, deferred_ls670_1_w);
782790}
783791
784792
r7500r7501
836844
837845static WRITE8_HANDLER( zpu_bcd_decoder_w )
838846{
847   mazerbla_state *state = (mazerbla_state *)space->machine->driver_data;
848
839849   /* bcd decoder used a input select (a mux) for reads from port 0x62 */
840   bcd_7445 = data & 0xf;
850   state->bcd_7445 = data & 0xf;
841851}
842852
843853static READ8_HANDLER( zpu_inputs_r )
844854{
855   mazerbla_state *state = (mazerbla_state *)space->machine->driver_data;
845856   static const char *const strobenames[] = { "ZPU", "DSW0", "DSW1", "DSW2", "DSW3", "BUTTONS", "STICK0_X", "STICK0_Y",
846857                                              "STICK1_X", "STICK1_Y", "UNUSED", "UNUSED", "UNUSED", "UNUSED", "UNUSED", "UNUSED" };
847858
848859   UINT8 ret = 0;
849860
850   ret = input_port_read(space->machine, strobenames[bcd_7445]);
861   ret = input_port_read(space->machine, strobenames[state->bcd_7445]);
851862
852863   return ret;
853864}
r7500r7501
856867{
857868   /* 0x6e - reset (offset = 0)*/
858869   /* 0x6f - set */
859   set_led_status(space->machine, 0, offset&1 );
870   set_led_status(space->machine, 0, offset & 1);
860871}
861872
862873static WRITE8_HANDLER( zpu_lamps_w)
r7500r7501
864875   /* bit 4 = /LAMP0 */
865876   /* bit 5 = /LAMP1 */
866877
867   /*set_led_status(space->machine, 0, (data&0x10)>>4 );*/
868   /*set_led_status(space->machine, 1, (data&0x20)>>4 );*/
878   /*set_led_status(space->machine, 0, (data & 0x10) >> 4);*/
879   /*set_led_status(space->machine, 1, (data & 0x20) >> 4);*/
869880}
870881
871882static WRITE8_HANDLER( zpu_coin_counter_w )
872883{
873884   /* bit 6 = coin counter */
874   coin_counter_w(space->machine, offset, (data&0x40)>>6 );
885   coin_counter_w(space->machine, offset, BIT(data, 6));
875886}
876887
877888static WRITE8_HANDLER(cfb_led_w)
878889{
879890   /* bit 7 - led on */
880   set_led_status(space->machine, 2,(data&0x80)>>7);
891   set_led_status(space->machine, 2, BIT(data, 7));
881892}
882893
883894static WRITE8_DEVICE_HANDLER( gg_led_ctrl_w )
884895{
885896   /* bit 0, bit 1 - led on */
886   set_led_status(device->machine,1,data&0x01);
897   set_led_status(device->machine, 1, BIT(data, 0));
887898}
888899
889900
r7500r7501
895906
896907static WRITE8_HANDLER( vsb_ls273_audio_control_w )
897908{
898   vsb_ls273 = data;
909   mazerbla_state *state = (mazerbla_state *)space->machine->driver_data;
910   state->vsb_ls273 = data;
899911
900912   /* bit 5 - led on */
901   set_led_status(space->machine, 1,(data&0x20)>>5);
913   set_led_status(space->machine, 1, BIT(data, 5));
902914}
903915
904916static READ8_DEVICE_HANDLER( soundcommand_r )
905917{
906   return soundlatch;
918   mazerbla_state *state = (mazerbla_state *)device->machine->driver_data;
919   return state->soundlatch;
907920}
908921
909922static TIMER_CALLBACK( delayed_sound_w )
910923{
911   soundlatch = param;
924   mazerbla_state *state = (mazerbla_state *)machine->driver_data;
925   state->soundlatch = param;
912926
913927   /* cause NMI on sound CPU */
914   cputag_set_input_line(machine, "sub", INPUT_LINE_NMI, ASSERT_LINE);
928   cpu_set_input_line(state->subcpu, INPUT_LINE_NMI, ASSERT_LINE);
915929}
916930
917931static WRITE8_HANDLER( main_sound_w )
r7500r7501
921935
922936static WRITE8_HANDLER( sound_int_clear_w )
923937{
924   cputag_set_input_line(space->machine, "sub", 0, CLEAR_LINE);
938   mazerbla_state *state = (mazerbla_state *)space->machine->driver_data;
939   cpu_set_input_line(state->subcpu, 0, CLEAR_LINE);
925940}
926941
927942static WRITE8_HANDLER( sound_nmi_clear_w )
928943{
929   cputag_set_input_line(space->machine, "sub", INPUT_LINE_NMI, CLEAR_LINE);
944   mazerbla_state *state = (mazerbla_state *)space->machine->driver_data;
945   cpu_set_input_line(state->subcpu, INPUT_LINE_NMI, CLEAR_LINE);
930946}
931947
932948
r7500r7501
940956   AM_RANGE(0x0000, 0x7fff) AM_ROM
941957   AM_RANGE(0xc000, 0xc7ff) AM_RAM AM_SHARE("share1")
942958   AM_RANGE(0xd800, 0xd800) AM_READ(cfb_zpu_int_req_clr)
943   AM_RANGE(0xe000, 0xe7ff) AM_RAM AM_BASE_GENERIC(videoram) AM_SIZE_GENERIC(videoram)
959   AM_RANGE(0xe000, 0xe7ff) AM_RAM AM_BASE_SIZE_MEMBER(mazerbla_state, videoram, videoram_size)
944960   AM_RANGE(0xe800, 0xefff) AM_RAM
945961ADDRESS_MAP_END
946962
r7500r7501
970986   AM_RANGE(0x0000, 0x37ff) AM_ROM
971987   AM_RANGE(0x3800, 0x3fff) AM_RAM AM_SHARE("share1")
972988   AM_RANGE(0x4000, 0x5fff) AM_ROMBANK("bank1")               /* GFX roms */
973   AM_RANGE(0x4000, 0x4003) AM_WRITE(VCU_video_reg_w)
974   AM_RANGE(0x6000, 0x67ff) AM_RAM AM_BASE(&cfb_ram)      /* Color Frame Buffer PCB, a.k.a. RAM for VCU commands and parameters */
975   AM_RANGE(0xa000, 0xa7ff) AM_READ(VCU_set_cmd_param_r)   /* VCU command and parameters LOAD */
976   AM_RANGE(0xc000, 0xdfff) AM_READ(VCU_set_gfx_addr_r)   /* gfx LOAD (blit) */
977   AM_RANGE(0xe000, 0xffff) AM_READ(VCU_set_clr_addr_r)   /* palette? LOAD */
989   AM_RANGE(0x4000, 0x4003) AM_WRITE(vcu_video_reg_w)
990   AM_RANGE(0x6000, 0x67ff) AM_RAM AM_BASE_MEMBER(mazerbla_state, cfb_ram)      /* Color Frame Buffer PCB, a.k.a. RAM for VCU commands and parameters */
991   AM_RANGE(0xa000, 0xa7ff) AM_READ(vcu_set_cmd_param_r)   /* VCU command and parameters LOAD */
992   AM_RANGE(0xc000, 0xdfff) AM_READ(vcu_set_gfx_addr_r)   /* gfx LOAD (blit) */
993   AM_RANGE(0xe000, 0xffff) AM_READ(vcu_set_clr_addr_r)   /* palette? LOAD */
978994ADDRESS_MAP_END
979995
980996static ADDRESS_MAP_START( mazerbla_cpu3_io_map, ADDRESS_SPACE_IO, 8 )
r7500r7501
13671383    note:
13681384    1111 11110 (0xfe) - cannot happen and is not handled by game */
13691385
1370   return (zpu_int_vector & ~1);   /* D0->GND is performed on CFB board */
1386   mazerbla_state *state = (mazerbla_state *)device->machine->driver_data;
1387   return (state->zpu_int_vector & ~1);   /* D0->GND is performed on CFB board */
13711388}
13721389
13731390/* frequency is 14.318 MHz/16/16/16/16 */
r7500r7501
13831400 *
13841401 *************************************/
13851402
1386static MACHINE_RESET( mazerbla )
1403static MACHINE_START( mazerbla )
13871404{
1388   game_id = MAZERBLA;
1389   zpu_int_vector = 0xff;
1390   cpu_set_irq_callback(devtag_get_device(machine, "maincpu"), irq_callback);
1405   mazerbla_state *state = (mazerbla_state *)machine->driver_data;
1406
1407   state->maincpu = devtag_get_device(machine, "maincpu");
1408   state->subcpu = devtag_get_device(machine, "sub");
1409
1410   state_save_register_global_array(machine, state->vcu_video_reg);
1411   state_save_register_global(machine, state->vcu_gfx_addr);
1412   state_save_register_global(machine, state->vcu_gfx_param_addr);
1413
1414   state_save_register_global(machine, state->bknd_col);
1415   state_save_register_global(machine, state->port02_status);
1416   state_save_register_global(machine, state->vbank);
1417   state_save_register_global(machine, state->xpos);
1418   state_save_register_global(machine, state->ypos);
1419   state_save_register_global(machine, state->pix_xsize);
1420   state_save_register_global(machine, state->pix_ysize);
1421   state_save_register_global(machine, state->color1);
1422   state_save_register_global(machine, state->color2);
1423   state_save_register_global(machine, state->mode);
1424   state_save_register_global(machine, state->plane);
1425   state_save_register_global_array(machine, state->lookup_ram);
1426   state_save_register_global(machine, state->gfx_rom_bank);
1427
1428   state_save_register_global_array(machine, state->ls670_0);
1429   state_save_register_global_array(machine, state->ls670_1);
1430
1431   state_save_register_global(machine, state->zpu_int_vector);
1432
1433   state_save_register_global(machine, state->bcd_7445);
1434
1435   state_save_register_global(machine, state->vsb_ls273);
1436   state_save_register_global(machine, state->soundlatch);
13911437}
13921438
1393
1394static MACHINE_RESET( greatgun )
1439static MACHINE_RESET( mazerbla )
13951440{
1396   UINT8 *rom = memory_region(machine, "sub2");
1397   game_id = GREATGUN;
1398   zpu_int_vector = 0xff;
1399   cpu_set_irq_callback(devtag_get_device(machine, "maincpu"), irq_callback);
1441   mazerbla_state *state = (mazerbla_state *)machine->driver_data;
1442   int i;
14001443
1444   state->zpu_int_vector = 0xff;
14011445
1402//  patch VCU test
1403//  VCU test starts at PC=0x56f
1404   rom[0x05b6] = 0;
1405   rom[0x05b7] = 0;
1406//  so we also need to patch ROM checksum test
1407   rom[0x037f] = 0;
1408   rom[0x0380] = 0;
1446   state->bknd_col = 0xaa;
1447   state->gfx_rom_bank = 0xff;
1448
1449   state->vcu_gfx_addr = 0;
1450   state->vcu_gfx_param_addr = 0;
1451   state->port02_status = 0;
1452   state->vbank = 0;
1453   state->xpos = 0;
1454   state->ypos = 0;
1455   state->pix_xsize = 0;
1456   state->pix_ysize = 0;
1457   state->color1 = 0;
1458   state->color2 = 0;
1459   state->mode = 0;
1460   state->plane = 0;
1461   state->bcd_7445 = 0;
1462   state->vsb_ls273 = 0;
1463   state->soundlatch = 0;
1464
1465   for (i = 0; i < 4; i++)
1466   {
1467      state->vcu_video_reg[i] = 0;
1468      state->ls670_0[i] = 0;
1469      state->ls670_1[i] = 0;
1470   }
1471
1472   memset(state->lookup_ram, 0, ARRAY_LENGTH(state->lookup_ram));
1473
1474   cpu_set_irq_callback(devtag_get_device(machine, "maincpu"), irq_callback);
14091475}
14101476
1477
14111478static MACHINE_DRIVER_START( mazerbla )
1479
1480   /* driver data */
1481   MDRV_DRIVER_DATA(mazerbla_state)
1482
14121483   /* basic machine hardware */
14131484   MDRV_CPU_ADD("maincpu", Z80, MASTER_CLOCK)   /* 4 MHz, no NMI, IM2 - vectors at 0xf8, 0xfa, 0xfc */
14141485   MDRV_CPU_PROGRAM_MAP(mazerbla_map)
r7500r7501
14291500   MDRV_CPU_VBLANK_INT("screen", irq0_line_hold)
14301501
14311502   /* synchronization forced on the fly */
1503   MDRV_MACHINE_START(mazerbla)
14321504   MDRV_MACHINE_RESET(mazerbla)
14331505
14341506   /* video hardware */
r7500r7501
14511523
14521524static MACHINE_DRIVER_START( greatgun )
14531525
1526   /* driver data */
1527   MDRV_DRIVER_DATA(mazerbla_state)
1528
14541529   /* basic machine hardware */
14551530   MDRV_CPU_ADD("maincpu", Z80, MASTER_CLOCK)   /* 4 MHz, no NMI, IM2 - vectors at 0xf8, 0xfa, 0xfc */
14561531   MDRV_CPU_PROGRAM_MAP(mazerbla_map)
r7500r7501
14691544    */
14701545   MDRV_CPU_VBLANK_INT("screen", irq0_line_hold)
14711546
1472   MDRV_MACHINE_RESET(greatgun)
1547   MDRV_MACHINE_START(mazerbla)
1548   MDRV_MACHINE_RESET(mazerbla)
14731549
14741550   /* video hardware */
14751551   MDRV_SCREEN_ADD("screen", RASTER)
r7500r7501
14831559
14841560   MDRV_PALETTE_INIT(mazerbla)
14851561   MDRV_VIDEO_START(mazerbla)
1486   MDRV_VIDEO_UPDATE(greatgun)
1562   MDRV_VIDEO_UPDATE(mazerbla)
14871563
14881564   /* sound hardware */
14891565   MDRV_SPEAKER_STANDARD_MONO("mono")
r7500r7501
16101686
16111687static DRIVER_INIT( mazerbla )
16121688{
1613   bknd_col = 0xaa;
1614   gfx_rom_bank = 0xff;
1689   mazerbla_state *state = (mazerbla_state *)machine->driver_data;
1690   state->game_id = MAZERBLA;
16151691}
16161692
1617GAME( 1983, mazerbla, 0,        mazerbla,  mazerbla, mazerbla, ROT0, "Stern", "Mazer Blazer (set 1)", GAME_IMPERFECT_GRAPHICS | GAME_NO_SOUND | GAME_NOT_WORKING )
1618GAME( 1983, mazerblaa,mazerbla, mazerbla,  mazerbla, mazerbla, ROT0, "Stern", "Mazer Blazer (set 2)", GAME_IMPERFECT_GRAPHICS | GAME_NO_SOUND | GAME_NOT_WORKING )
1619GAME( 1983, greatgun, 0,        greatgun,  greatgun, mazerbla, ROT0, "Stern", "Great Guns", GAME_IMPERFECT_GRAPHICS | GAME_NOT_WORKING )
1693static DRIVER_INIT( greatgun )
1694{
1695   mazerbla_state *state = (mazerbla_state *)machine->driver_data;
1696   UINT8 *rom = memory_region(machine, "sub2");
1697
1698   state->game_id = GREATGUN;
1699
1700   //  patch VCU test
1701   //  VCU test starts at PC=0x56f
1702   rom[0x05b6] = 0;
1703   rom[0x05b7] = 0;
1704   //  so we also need to patch ROM checksum test
1705   rom[0x037f] = 0;
1706   rom[0x0380] = 0;
1707}
1708
1709GAME( 1983, mazerbla,  0,        mazerbla,  mazerbla, mazerbla, ROT0, "Stern", "Mazer Blazer (set 1)", GAME_IMPERFECT_GRAPHICS | GAME_NO_SOUND | GAME_NOT_WORKING | GAME_SUPPORTS_SAVE )
1710GAME( 1983, mazerblaa, mazerbla, mazerbla,  mazerbla, mazerbla, ROT0, "Stern", "Mazer Blazer (set 2)", GAME_IMPERFECT_GRAPHICS | GAME_NO_SOUND | GAME_NOT_WORKING | GAME_SUPPORTS_SAVE )
1711GAME( 1983, greatgun,  0,        greatgun,  greatgun, greatgun, ROT0, "Stern", "Great Guns", GAME_IMPERFECT_GRAPHICS | GAME_NOT_WORKING | GAME_SUPPORTS_SAVE )
src/mame/drivers/metlclsh.c
r7500r7501
3636#include "cpu/m6809/m6809.h"
3737#include "sound/2203intf.h"
3838#include "sound/3526intf.h"
39#include "includes/metlclsh.h"
3940
40/* Variables defined in video: */
4141
42extern UINT8 *metlclsh_bgram, *metlclsh_fgram, *metlclsh_scrollx;
43
44/* Functions defined in video: */
45
46WRITE8_HANDLER( metlclsh_bgram_w );
47WRITE8_HANDLER( metlclsh_fgram_w );
48WRITE8_HANDLER( metlclsh_gfxbank_w );
49WRITE8_HANDLER( metlclsh_rambank_w );
50
51VIDEO_START( metlclsh );
52VIDEO_UPDATE( metlclsh );
53
5442/***************************************************************************
5543
5644                            Memory Maps - CPU #1
r7500r7501
5947
6048static WRITE8_HANDLER( metlclsh_cause_irq )
6149{
62   cputag_set_input_line(space->machine, "sub", M6809_IRQ_LINE, ASSERT_LINE);
50   metlclsh_state *state = (metlclsh_state *)space->machine->driver_data;
51   cpu_set_input_line(state->subcpu, M6809_IRQ_LINE, ASSERT_LINE);
6352}
6453
6554static WRITE8_HANDLER( metlclsh_ack_nmi )
6655{
67   cputag_set_input_line(space->machine, "maincpu", INPUT_LINE_NMI, CLEAR_LINE);
56   metlclsh_state *state = (metlclsh_state *)space->machine->driver_data;
57   cpu_set_input_line(state->maincpu, INPUT_LINE_NMI, CLEAR_LINE);
6858}
6959
7060static ADDRESS_MAP_START( metlclsh_master_map, ADDRESS_SPACE_PROGRAM, 8 )
r7500r7501
8171/**/AM_RANGE(0xc800, 0xc82f) AM_RAM_WRITE(paletteram_xxxxBBBBGGGGRRRR_split1_w) AM_BASE_GENERIC(paletteram)
8272/**/AM_RANGE(0xcc00, 0xcc2f) AM_RAM_WRITE(paletteram_xxxxBBBBGGGGRRRR_split2_w) AM_BASE_GENERIC(paletteram2)
8373   AM_RANGE(0xd000, 0xd001) AM_DEVREADWRITE("ym1", ym2203_r,ym2203_w)
84/**/AM_RANGE(0xd800, 0xdfff) AM_RAM_WRITE(metlclsh_fgram_w) AM_BASE(&metlclsh_fgram)
74/**/AM_RANGE(0xd800, 0xdfff) AM_RAM_WRITE(metlclsh_fgram_w) AM_BASE_MEMBER(metlclsh_state, fgram)
8575   AM_RANGE(0xe000, 0xe001) AM_DEVWRITE("ym2", ym3526_w   )
86   AM_RANGE(0xe800, 0xe9ff) AM_RAM AM_BASE_SIZE_GENERIC(spriteram)
76   AM_RANGE(0xe800, 0xe9ff) AM_RAM AM_BASE_SIZE_MEMBER(metlclsh_state, spriteram, spriteram_size)
8777   AM_RANGE(0xfff0, 0xffff) AM_ROM                           // Reset/IRQ vectors
8878ADDRESS_MAP_END
8979
r7500r7501
9686
9787static WRITE8_HANDLER( metlclsh_cause_nmi2 )
9888{
99   cputag_set_input_line(space->machine, "maincpu", INPUT_LINE_NMI, ASSERT_LINE);
89   metlclsh_state *state = (metlclsh_state *)space->machine->driver_data;
90   cpu_set_input_line(state->maincpu, INPUT_LINE_NMI, ASSERT_LINE);
10091}
10192
10293static WRITE8_HANDLER( metlclsh_ack_irq2 )
10394{
104   cputag_set_input_line(space->machine, "sub", M6809_IRQ_LINE, CLEAR_LINE);
95   metlclsh_state *state = (metlclsh_state *)space->machine->driver_data;
96   cpu_set_input_line(state->subcpu, M6809_IRQ_LINE, CLEAR_LINE);
10597}
10698
10799static WRITE8_HANDLER( metlclsh_ack_nmi2 )
108100{
109   cputag_set_input_line(space->machine, "sub", INPUT_LINE_NMI, CLEAR_LINE);
101   metlclsh_state *state = (metlclsh_state *)space->machine->driver_data;
102   cpu_set_input_line(state->subcpu, INPUT_LINE_NMI, CLEAR_LINE);
110103}
111104
112105static WRITE8_HANDLER( metlclsh_flipscreen_w )
r7500r7501
123116   AM_RANGE(0xc003, 0xc003) AM_READ_PORT("DSW")
124117   AM_RANGE(0xc0c0, 0xc0c0) AM_WRITE(metlclsh_cause_nmi2)         // cause nmi on cpu #1
125118   AM_RANGE(0xc0c1, 0xc0c1) AM_WRITE(metlclsh_ack_irq2)         // irq ack
126   AM_RANGE(0xd000, 0xd7ff) AM_ROMBANK("bank1") AM_WRITE(metlclsh_bgram_w) AM_BASE(&metlclsh_bgram) // this is banked
119   AM_RANGE(0xd000, 0xd7ff) AM_ROMBANK("bank1") AM_WRITE(metlclsh_bgram_w) AM_BASE_MEMBER(metlclsh_state, bgram) // this is banked
127120   AM_RANGE(0xe301, 0xe301) AM_WRITE(metlclsh_flipscreen_w)      // 0/1
128121   AM_RANGE(0xe401, 0xe401) AM_WRITE(metlclsh_rambank_w)
129   AM_RANGE(0xe402, 0xe403) AM_WRITEONLY AM_BASE(&metlclsh_scrollx)
122   AM_RANGE(0xe402, 0xe403) AM_WRITEONLY AM_BASE_MEMBER(metlclsh_state, scrollx)
130123//  AM_RANGE(0xe404, 0xe404) AM_WRITENOP                            // ? 0
131124//  AM_RANGE(0xe410, 0xe410) AM_WRITENOP                            // ? 0 on startup only
132125   AM_RANGE(0xe417, 0xe417) AM_WRITE(metlclsh_ack_nmi2)         // nmi ack
r7500r7501
167160   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
168161
169162   PORT_START("IN1")      /* c001 */
170   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT   )
171   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT   )
172   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_UP      )
173   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN   )
174   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1         )
175   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON2         )
176   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_START1         )
177   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_START2         )
163   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT )
164   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT )
165   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_UP )
166   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN )
167   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 )
168   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON2 )
169   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_START1 )
170   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_START2 )
178171
179172   PORT_START("IN2")      /* c002 */
180   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT   ) PORT_COCKTAIL
181   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT   ) PORT_COCKTAIL
182   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_UP      ) PORT_COCKTAIL
183   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN   ) PORT_COCKTAIL
184   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1         ) PORT_COCKTAIL
185   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON2         ) PORT_COCKTAIL
173   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_COCKTAIL
174   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_COCKTAIL
175   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_COCKTAIL
176   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_COCKTAIL
177   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 ) PORT_COCKTAIL
178   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_BUTTON2 ) PORT_COCKTAIL
186179   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_COIN1 ) PORT_IMPULSE(1)
187180   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_COIN2 ) PORT_IMPULSE(1)
188181
r7500r7501
262255
263256static void metlclsh_irqhandler(running_device *device, int linestate)
264257{
265   cputag_set_input_line(device->machine, "maincpu", M6809_IRQ_LINE, linestate);
258   metlclsh_state *state = (metlclsh_state *)device->machine->driver_data;
259   cpu_set_input_line(state->maincpu, M6809_IRQ_LINE, linestate);
266260}
267261
268262static const ym3526_interface ym3526_config =
r7500r7501
279273      cpu_set_input_line(device, INPUT_LINE_NMI, ASSERT_LINE);
280274}
281275
276static MACHINE_START( metlclsh )
277{
278   metlclsh_state *state = (metlclsh_state *)machine->driver_data;
279
280   state->maincpu = devtag_get_device(machine, "maincpu");
281   state->subcpu = devtag_get_device(machine, "sub");
282
283   state_save_register_global(machine, state->write_mask);
284   state_save_register_global(machine, state->gfxbank);
285}
286
282287static MACHINE_RESET( metlclsh )
283288{
289   metlclsh_state *state = (metlclsh_state *)machine->driver_data;
290
284291   flip_screen_set(machine, 0);
292
293   state->write_mask = 0;
294   state->gfxbank = 0;
285295}
286296
287297static MACHINE_DRIVER_START( metlclsh )
288298
299   /* driver data */
300   MDRV_DRIVER_DATA(metlclsh_state)
301
289302   /* basic machine hardware */
290303   MDRV_CPU_ADD("maincpu", M6809, 1500000)        // ?
291304   MDRV_CPU_PROGRAM_MAP(metlclsh_master_map)
r7500r7501
296309   MDRV_CPU_VBLANK_INT_HACK(metlclsh_interrupt2,2)
297310   // IRQ by cpu #1, NMI by coins insertion
298311
312   MDRV_MACHINE_START(metlclsh)
299313   MDRV_MACHINE_RESET(metlclsh)
300314
301315   /* video hardware */
r7500r7501
430444   ROM_LOAD( "82s123.prm",   0x0000, 0x20, CRC(6844cc88) SHA1(89d23367aa6ff541205416e82781fe938dfeeb52) )
431445ROM_END
432446
433GAME( 1985, metlclsh, 0, metlclsh, metlclsh, 0, ROT0, "Data East", "Metal Clash (Japan)", 0 )
447GAME( 1985, metlclsh, 0, metlclsh, metlclsh, 0, ROT0, "Data East", "Metal Clash (Japan)", GAME_SUPPORTS_SAVE )
src/mame/drivers/goldstar.c
r7500r7501
58375837ROM_END
58385838
58395839
5840ROM_START( cmwm )
5841   ROM_REGION( 0x10000, "maincpu", 0 )
5842   ROM_LOAD( "waterm.rom",  0x0000, 0x1000, CRC(93b6cb9b) SHA1(294e1e5909b304252c79a7d3f50fc175558e713b) )
5843   ROM_CONTINUE(0x4000,0x1000)
5844   ROM_CONTINUE(0x3000,0x1000)
5845   ROM_CONTINUE(0x7000,0x1000)
5846   ROM_CONTINUE(0x1000,0x1000)
5847   ROM_CONTINUE(0x6000,0x1000)
5848   ROM_CONTINUE(0x2000,0x1000)
5849   ROM_CONTINUE(0x5000,0x1000)
5850
5851   ROM_REGION( 0x18000, "gfx1", 0 )
5852   ROM_LOAD( "27256.u16",  0x00000, 0x8000, CRC(19cc1d67) SHA1(47487f9362bfb36a32100ed772960628844462bf) )
5853   ROM_LOAD( "27256.u11",  0x08000, 0x8000, CRC(63b3df4e) SHA1(9bacd23da598805ec18ec5ad15cab95d71eb9262) )
5854   ROM_LOAD( "27256.u4",   0x10000, 0x8000, CRC(e39fff9c) SHA1(22fdc517fa478441622c6245cecb5728c5595757) )
5855
5856   ROM_REGION( 0x8000, "gfx2", 0 )
5857   ROM_LOAD( "2764.u15",   0x0000, 0x2000, CRC(8607ffd9) SHA1(9bc94715554aa2473ae2ed249a47f29c7886b3dc) )
5858   ROM_LOAD( "2764.u10",   0x2000, 0x2000, CRC(c32367be) SHA1(ff217021b9c58e23b2226f8b0a7f5da966225715) )
5859   ROM_LOAD( "2764.u14",   0x4000, 0x2000, CRC(6dfcb188) SHA1(22430429c798954d9d979e62699b58feae7fdbf4) )
5860   ROM_LOAD( "2764.u9",    0x6000, 0x2000, CRC(9678ead2) SHA1(e80aefa98b2363fe9e6b2415762695ace272e4d3) )
5861
5862   ROM_REGION( 0x10000, "user1", 0 ) // girl bitmaps
5863   ROM_LOAD( "27512.u53",  0x0000, 0x10000, CRC(e92443d3) SHA1(4b6ca4521841610054165f085ae05510e77af191) )
5864
5865   ROM_REGION( 0x200, "proms", 0 )
5866   ROM_LOAD( "82s129.u84", 0x0000, 0x0100, CRC(0489b760) SHA1(78f8632b17a76335183c5c204cdec856988368b0) )
5867   ROM_LOAD( "82s129.u70", 0x0100, 0x0100, CRC(21eb5b19) SHA1(9b8425bdb97f11f4855c998c7792c3291fd07470) )
5868
5869   ROM_REGION( 0x100, "proms2", 0 )
5870   ROM_LOAD( "82s129.u46", 0x0000, 0x0100, CRC(50ec383b) SHA1(ae95b92bd3946b40134bcdc22708d5c6b0f4c23e) )
5871ROM_END
5872
5873ROM_START( cmfun )
5874   ROM_REGION( 0x10000, "maincpu", 0 )
5875   ROM_LOAD( "cmvfun.rom",  0x0000, 0x1000, CRC(128f373e) SHA1(24d51ab669d568c004e2c94cac22eb8476ce2718) )
5876   ROM_CONTINUE(0x4000,0x1000)
5877   ROM_CONTINUE(0x3000,0x1000)
5878   ROM_CONTINUE(0x7000,0x1000)
5879   ROM_CONTINUE(0x1000,0x1000)
5880   ROM_CONTINUE(0x6000,0x1000)
5881   ROM_CONTINUE(0x2000,0x1000)
5882   ROM_CONTINUE(0x5000,0x1000)
5883
5884   ROM_REGION( 0x18000, "gfx1", 0 )
5885   ROM_LOAD( "27256.u16",  0x00000, 0x8000, CRC(19cc1d67) SHA1(47487f9362bfb36a32100ed772960628844462bf) )
5886   ROM_LOAD( "27256.u11",  0x08000, 0x8000, CRC(63b3df4e) SHA1(9bacd23da598805ec18ec5ad15cab95d71eb9262) )
5887   ROM_LOAD( "27256.u4",   0x10000, 0x8000, CRC(e39fff9c) SHA1(22fdc517fa478441622c6245cecb5728c5595757) )
5888
5889   ROM_REGION( 0x8000, "gfx2", 0 )
5890   ROM_LOAD( "2764.u15",   0x0000, 0x2000, CRC(8607ffd9) SHA1(9bc94715554aa2473ae2ed249a47f29c7886b3dc) )
5891   ROM_LOAD( "2764.u10",   0x2000, 0x2000, CRC(c32367be) SHA1(ff217021b9c58e23b2226f8b0a7f5da966225715) )
5892   ROM_LOAD( "2764.u14",   0x4000, 0x2000, CRC(6dfcb188) SHA1(22430429c798954d9d979e62699b58feae7fdbf4) )
5893   ROM_LOAD( "2764.u9",    0x6000, 0x2000, CRC(9678ead2) SHA1(e80aefa98b2363fe9e6b2415762695ace272e4d3) )
5894
5895   ROM_REGION( 0x10000, "user1", 0 ) // girl bitmaps
5896   ROM_LOAD( "27512.u53",  0x0000, 0x10000, CRC(e92443d3) SHA1(4b6ca4521841610054165f085ae05510e77af191) )
5897
5898   ROM_REGION( 0x200, "proms", 0 )
5899   ROM_LOAD( "82s129.u84", 0x0000, 0x0100, CRC(0489b760) SHA1(78f8632b17a76335183c5c204cdec856988368b0) )
5900   ROM_LOAD( "82s129.u70", 0x0100, 0x0100, CRC(21eb5b19) SHA1(9b8425bdb97f11f4855c998c7792c3291fd07470) )
5901
5902   ROM_REGION( 0x100, "proms2", 0 )
5903   ROM_LOAD( "82s129.u46", 0x0000, 0x0100, CRC(50ec383b) SHA1(ae95b92bd3946b40134bcdc22708d5c6b0f4c23e) )
5904ROM_END
5905
58405906/* looks like a bootleg of cmv4 */
58415907ROM_START( cmaster )
58425908   ROM_REGION( 0x10000, "maincpu", 0 )
r7500r7501
86658731// even original boards almost always run modified sets
86668732GAME( 1992, cmv4,      0,        cm,       cmv4,     cmv4,      ROT0, "Dyna",              "Cherry Master (ver.4, set 1)",                0 )
86678733GAME( 1992, cmv4a,     cmv4,     cm,       cmv4,     cmv4,      ROT0, "Dyna",              "Cherry Master (ver.4, set 2)",                GAME_NOT_WORKING )   /* stealth game? */
8734GAME( 199?, cmwm,      cmv4,     cm,       cmv4,     cmv4,      ROT0, "Dyna",              "Cherry Master (Watermelon bootleg / hack)",   0 )
8735GAME( 1995, cmfun,     cmv4,     cm,       cmv4,     cmv4,      ROT0, "Dyna",              "Cherry Master (Fun USA v2.5 bootleg / hack)",  0 )
86688736GAME( 1991, cmaster,   0,        cm,       cmaster,  0,         ROT0, "Dyna",              "Cherry Master I (ver.1.01, set 1)",           0 )
86698737GAME( 1991, cmasterb,  cmaster,  cm,       cmasterb, cmv4,      ROT0, "Dyna",              "Cherry Master I (ver.1.01, set 2)",           0 )
86708738GAME( 1991, cmasterc,  cmaster,  cmasterc, cmasterc, cmv4,      ROT0, "Dyna",              "Cherry Master I (ver.1.01, set 3)",           0 )
src/mame/drivers/nyny.c
r7500r7501
7272#include "sound/dac.h"
7373
7474
75#define MAIN_CPU_MASTER_CLOCK           XTAL_11_2MHz
76#define PIXEL_CLOCK                   (MAIN_CPU_MASTER_CLOCK / 2)
77#define CRTC_CLOCK                    (MAIN_CPU_MASTER_CLOCK / 16)
78#define AUDIO_1_MASTER_CLOCK          XTAL_4MHz
79#define AUDIO_CPU_1_CLOCK             AUDIO_1_MASTER_CLOCK
80#define AUDIO_2_MASTER_CLOCK          XTAL_4MHz
81#define AUDIO_CPU_2_CLOCK             AUDIO_2_MASTER_CLOCK
7582
76#define MAIN_CPU_MASTER_CLOCK   (XTAL_11_2MHz)
77#define PIXEL_CLOCK            (MAIN_CPU_MASTER_CLOCK / 2)
78#define CRTC_CLOCK            (MAIN_CPU_MASTER_CLOCK / 16)
79#define AUDIO_1_MASTER_CLOCK   (XTAL_4MHz)
80#define AUDIO_CPU_1_CLOCK      (AUDIO_1_MASTER_CLOCK)
81#define AUDIO_2_MASTER_CLOCK   (XTAL_4MHz)
82#define AUDIO_CPU_2_CLOCK      (AUDIO_2_MASTER_CLOCK)
8383
84class nyny_state
85{
86public:
87   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, nyny_state(machine)); }
8488
85static UINT8 *nyny_videoram_1;
86static UINT8 *nyny_videoram_2;
87static UINT8 *nyny_colorram_1;
88static UINT8 *nyny_colorram_2;
89static UINT8 flipscreen;
89   nyny_state(running_machine &machine) { }
9090
91static UINT8 star_enable;
92static UINT16 star_delay_counter;
93static UINT16 star_shift_reg;
91   /* memory pointers */
92   UINT8 *  videoram1;
93   UINT8 *  videoram2;
94   UINT8 *  colorram1;
95   UINT8 *  colorram2;
9496
97   /* video-related */
98   int      flipscreen;
99   UINT8    star_enable;
100   UINT16   star_delay_counter;
101   UINT16   star_shift_reg;
95102
103   /* devices */
104   running_device *maincpu;
105   running_device *audiocpu;
106   running_device *audiocpu2;
107   running_device *ic48_1;
108   running_device *mc6845;
109   running_device *pia1;
110   running_device *pia2;
111};
96112
113
97114/*************************************
98115 *
99116 *  Prototypes
r7500r7501
104121static WRITE8_HANDLER( audio_2_command_w );
105122
106123
107
108124/*************************************
109125 *
110126 *  Interrupt generation
r7500r7501
113129
114130static WRITE_LINE_DEVICE_HANDLER( main_cpu_irq )
115131{
116   running_device *pia1 = devtag_get_device(device->machine, "pia1");
117   running_device *pia2 = devtag_get_device(device->machine, "pia2");
118   int combined_state = pia6821_get_irq_a(pia1) | pia6821_get_irq_b(pia1) | pia6821_get_irq_b(pia2);
132   nyny_state *driver_state = (nyny_state *)device->machine->driver_data;
133   int combined_state = pia6821_get_irq_a(driver_state->pia1) | pia6821_get_irq_b(driver_state->pia1) | pia6821_get_irq_b(driver_state->pia2);
119134
120   cputag_set_input_line(device->machine, "maincpu", M6809_IRQ_LINE, combined_state ? ASSERT_LINE : CLEAR_LINE);
135   cpu_set_input_line(driver_state->maincpu, M6809_IRQ_LINE, combined_state ? ASSERT_LINE : CLEAR_LINE);
121136}
122137
123138
124139static WRITE_LINE_DEVICE_HANDLER( main_cpu_firq )
125140{
126   cputag_set_input_line(device->machine, "maincpu", M6809_FIRQ_LINE, state ? ASSERT_LINE : CLEAR_LINE);
141   nyny_state *driver_state = (nyny_state *)device->machine->driver_data;
142   cpu_set_input_line(driver_state->maincpu, M6809_FIRQ_LINE, state ? ASSERT_LINE : CLEAR_LINE);
127143}
128144
129145
r7500r7501
136152
137153static INTERRUPT_GEN( update_pia_1 )
138154{
139   running_device *pia1 = devtag_get_device(device->machine, "pia1");
155   nyny_state *state = (nyny_state *)device->machine->driver_data;
156
140157   /* update the different PIA pins from the input ports */
141158
142159   /* CA1 - copy of PA0 (COIN1) */
143   pia6821_ca1_w(pia1, 0, input_port_read(device->machine, "IN0") & 0x01);
160   pia6821_ca1_w(state->pia1, 0, input_port_read(device->machine, "IN0") & 0x01);
144161
145162   /* CA2 - copy of PA1 (SERVICE1) */
146   pia6821_ca2_w(pia1, 0, input_port_read(device->machine, "IN0") & 0x02);
163   pia6821_ca2_w(state->pia1, 0, input_port_read(device->machine, "IN0") & 0x02);
147164
148165   /* CB1 - (crosshatch) */
149   pia6821_cb1_w(pia1, 0, input_port_read(device->machine, "CROSS"));
166   pia6821_cb1_w(state->pia1, 0, input_port_read(device->machine, "CROSS"));
150167
151168   /* CB2 - NOT CONNECTED */
152169}
r7500r7501
178195
179196static WRITE8_DEVICE_HANDLER( pia_2_port_a_w )
180197{
181   star_delay_counter = (star_delay_counter & 0x0f00) | data;
198   nyny_state *state = (nyny_state *)device->machine->driver_data;
199   state->star_delay_counter = (state->star_delay_counter & 0x0f00) | data;
182200}
183201
184202
185203static WRITE8_DEVICE_HANDLER( pia_2_port_b_w )
186204{
205   nyny_state *state = (nyny_state *)device->machine->driver_data;
206
187207   /* bits 0-3 go to bits 8-11 of the star delay counter */
188   star_delay_counter = (star_delay_counter & 0x00ff) | ((data & 0x0f) << 8);
208   state->star_delay_counter = (state->star_delay_counter & 0x00ff) | ((data & 0x0f) << 8);
189209
190210   /* bit 4 is star field enable */
191   star_enable = data & 0x10;
211   state->star_enable = data & 0x10;
192212
193213   /* bits 5-7 go to the music board connector */
194   audio_2_command_w(cputag_get_address_space(device->machine, "maincpu", ADDRESS_SPACE_PROGRAM), 0, data & 0xe0);
214   audio_2_command_w(cpu_get_address_space(state->maincpu, ADDRESS_SPACE_PROGRAM), 0, data & 0xe0);
195215}
196216
197217
r7500r7501
225245 *
226246 *************************************/
227247
228static WRITE8_DEVICE_HANDLER(ic48_1_74123_output_changed)
248static WRITE8_DEVICE_HANDLER( ic48_1_74123_output_changed )
229249{
230   running_device *pia2 = devtag_get_device(device->machine, "pia2");
231   pia6821_ca1_w(pia2, 0, data);
250   nyny_state *state = (nyny_state *)device->machine->driver_data;
251   pia6821_ca1_w(state->pia2, 0, data);
232252}
233253
234254
r7500r7501
247267
248268/*************************************
249269 *
250 *  Machine start
251 *
252 *************************************/
253
254static MACHINE_START( nyny )
255{
256   /* setup for save states */
257   state_save_register_global(machine, flipscreen);
258   state_save_register_global(machine, star_enable);
259   state_save_register_global(machine, star_delay_counter);
260   state_save_register_global(machine, star_shift_reg);
261}
262
263
264
265/*************************************
266 *
267270 *  Video system
268271 *
269272 *************************************/
270273
271#define NUM_PENS   (8)
274#define NUM_PENS      8
272275
273276
274277static WRITE_LINE_DEVICE_HANDLER( flipscreen_w )
275278{
276   flipscreen = state ? 0 : 1;
279   nyny_state *driver_state = (nyny_state *)device->machine->driver_data;
280   driver_state->flipscreen = state ? 0 : 1;
277281}
278282
279283
r7500r7501
294298
295299static MC6845_UPDATE_ROW( update_row )
296300{
301   nyny_state *state = (nyny_state *)device->machine->driver_data;
297302   UINT8 cx;
298
299303   pen_t *pens = (pen_t *)param;
300304   UINT8 x = 0;
301305
r7500r7501
310314                 ((ra << 5) & 0x00e0) |
311315                 ((ma << 0) & 0x001f);
312316
313      if (flipscreen)
317      if (state->flipscreen)
314318         offs = offs ^ 0x9fff;
315319
316      data1 = nyny_videoram_1[offs];
317      data2 = nyny_videoram_2[offs];
318      color1 = nyny_colorram_1[offs] & 0x07;
319      color2 = nyny_colorram_2[offs] & 0x07;
320      data1 = state->videoram1[offs];
321      data2 = state->videoram2[offs];
322      color1 = state->colorram1[offs] & 0x07;
323      color2 = state->colorram2[offs] & 0x07;
320324
321325      for (i = 0; i < 8; i++)
322326      {
323327         UINT8 bit1, bit2, color;
324328
325         if (flipscreen)
329         if (state->flipscreen)
326330         {
327            bit1 = data1 & 0x80;
328            bit2 = data2 & 0x80;
331            bit1 = BIT(data1, 7);
332            bit2 = BIT(data2, 7);
329333
330334            data1 = data1 << 1;
331335            data2 = data2 << 1;
332336         }
333337         else
334338         {
335            bit1 = data1 & 0x01;
336            bit2 = data2 & 0x01;
339            bit1 = BIT(data1, 0);
340            bit2 = BIT(data2, 0);
337341
338342            data1 = data1 >> 1;
339343            data2 = data2 >> 1;
r7500r7501
347351
348352         *BITMAP_ADDR32(bitmap, y, x) = pens[color];
349353
350         x = x + 1;
354         x += 1;
351355      }
352356
353      ma = ma + 1;
357      ma += 1;
354358   }
355359}
356360
357361
358INLINE void shift_star_generator(void)
362INLINE void shift_star_generator( running_machine *machine )
359363{
360   star_shift_reg = (star_shift_reg << 1) | (((~star_shift_reg >> 15) & 0x01) ^ ((star_shift_reg >> 2) & 0x01));
364   nyny_state *state = (nyny_state *)machine->driver_data;
365   state->star_shift_reg = (state->star_shift_reg << 1) | (((~state->star_shift_reg >> 15) & 0x01) ^ ((state->star_shift_reg >> 2) & 0x01));
361366}
362367
363368
364369static MC6845_END_UPDATE( end_update )
365370{
371   nyny_state *state = (nyny_state *)device->machine->driver_data;
372
366373   /* draw the star field into the bitmap */
367374   int y;
368375
369376   pen_t *pens = (pen_t *)param;
370   UINT16 delay_counter = star_delay_counter;
377   UINT16 delay_counter = state->star_delay_counter;
371378
372379   for (y = cliprect->min_y; y <= cliprect->max_y; y++)
373380   {
r7500r7501
376383      for (x = cliprect->min_x; x <= cliprect->max_x; x++)
377384      {
378385         /* check if the star status */
379         if (star_enable &&
386         if (state->star_enable &&
380387             (*BITMAP_ADDR32(bitmap, y, x) == 0) &&
381             ((star_shift_reg & 0x80ff) == 0x00ff) &&
382             (((y & 0x01) ^ flipscreen) ^ (((x & 0x08) >> 3) ^ flipscreen)))
388             ((state->star_shift_reg & 0x80ff) == 0x00ff) &&
389             (((y & 0x01) ^ state->flipscreen) ^ (((x & 0x08) >> 3) ^ state->flipscreen)))
383390         {
384            UINT8 color = ((star_shift_reg & 0x0100) >>  8) |   /* R */
385                       ((star_shift_reg & 0x0400) >>  9) |   /* G */
386                       ((star_shift_reg & 0x1000) >> 10);   /* B */
391            UINT8 color = ((state->star_shift_reg & 0x0100) >>  8) |   /* R */
392                       ((state->star_shift_reg & 0x0400) >>  9) |   /* G */
393                       ((state->star_shift_reg & 0x1000) >> 10);   /* B */
387394
388395            *BITMAP_ADDR32(bitmap, y, x) = pens[color];
389396         }
390397
391398         if (delay_counter == 0)
392            shift_star_generator();
399            shift_star_generator(device->machine);
393400         else
394401            delay_counter = delay_counter - 1;
395402      }
r7500r7501
399406
400407static WRITE_LINE_DEVICE_HANDLER( display_enable_changed )
401408{
402   ttl74123_a_w(devtag_get_device(device->machine, "ic48_1"), 0, state);
409   nyny_state *driver_state = (nyny_state *)device->machine->driver_data;
410   ttl74123_a_w(driver_state->ic48_1, 0, state);
403411}
404412
405413
r7500r7501
420428
421429static VIDEO_UPDATE( nyny )
422430{
423   running_device *mc6845 = devtag_get_device(screen->machine, "crtc");
424   mc6845_update(mc6845, bitmap, cliprect);
431   nyny_state *state = (nyny_state *)screen->machine->driver_data;
425432
433   mc6845_update(state->mc6845, bitmap, cliprect);
434
426435   return 0;
427436}
428437
r7500r7501
436445
437446static WRITE8_HANDLER( audio_1_command_w )
438447{
448   nyny_state *state = (nyny_state *)space->machine->driver_data;
449
439450   soundlatch_w(space, 0, data);
440   cputag_set_input_line(space->machine, "audiocpu", M6800_IRQ_LINE, HOLD_LINE);
451   cpu_set_input_line(state->audiocpu, M6800_IRQ_LINE, HOLD_LINE);
441452}
442453
443454
444455static WRITE8_HANDLER( audio_1_answer_w )
445456{
457   nyny_state *state = (nyny_state *)space->machine->driver_data;
458
446459   soundlatch3_w(space, 0, data);
447   cputag_set_input_line(space->machine, "maincpu", M6809_IRQ_LINE, HOLD_LINE);
460   cpu_set_input_line(state->maincpu, M6809_IRQ_LINE, HOLD_LINE);
448461}
449462
450463
r7500r7501
487500
488501static WRITE8_HANDLER( audio_2_command_w )
489502{
503   nyny_state *state = (nyny_state *)space->machine->driver_data;
504
490505   soundlatch2_w(space, 0, (data & 0x60) >> 5);
491   cputag_set_input_line(space->machine, "audio2", M6800_IRQ_LINE, (data & 0x80) ? CLEAR_LINE : ASSERT_LINE);
506   cpu_set_input_line(state->audiocpu2, M6800_IRQ_LINE, BIT(data, 7) ? CLEAR_LINE : ASSERT_LINE);
492507}
493508
494509
r7500r7501
501516
502517static READ8_HANDLER( nyny_pia_1_2_r )
503518{
504   running_device *pia1 = devtag_get_device(space->machine, "pia1");
505   running_device *pia2 = devtag_get_device(space->machine, "pia2");
519   nyny_state *state = (nyny_state *)space->machine->driver_data;
506520   UINT8 ret = 0;
507521
508522   /* the address bits are directly connected to the chip selects */
509   if (offset & 0x04)  ret = pia6821_r(pia1, offset & 0x03);
510   if (offset & 0x08)  ret = pia6821_alt_r(pia2, offset & 0x03);
523   if (BIT(offset, 2))  ret = pia6821_r(state->pia1, offset & 0x03);
524   if (BIT(offset, 3))  ret = pia6821_alt_r(state->pia2, offset & 0x03);
511525
512526   return ret;
513527}
r7500r7501
515529
516530static WRITE8_HANDLER( nyny_pia_1_2_w )
517531{
518   running_device *pia1 = devtag_get_device(space->machine, "pia1");
519   running_device *pia2 = devtag_get_device(space->machine, "pia2");
532   nyny_state *state = (nyny_state *)space->machine->driver_data;
520533
521534   /* the address bits are directly connected to the chip selects */
522   if (offset & 0x04)  pia6821_w(pia1, offset & 0x03, data);
523   if (offset & 0x08)  pia6821_alt_w(pia2, offset & 0x03, data);
535   if (BIT(offset, 2))  pia6821_w(state->pia1, offset & 0x03, data);
536   if (BIT(offset, 3))  pia6821_alt_w(state->pia2, offset & 0x03, data);
524537}
525538
526539
527540static ADDRESS_MAP_START( nyny_main_map, ADDRESS_SPACE_PROGRAM, 8 )
528   AM_RANGE(0x0000, 0x1fff) AM_RAM AM_BASE(&nyny_videoram_1)
529   AM_RANGE(0x2000, 0x3fff) AM_RAM AM_BASE(&nyny_colorram_1)
530   AM_RANGE(0x4000, 0x5fff) AM_RAM AM_BASE(&nyny_videoram_2)
531   AM_RANGE(0x6000, 0x7fff) AM_RAM AM_BASE(&nyny_colorram_2)
541   AM_RANGE(0x0000, 0x1fff) AM_RAM AM_BASE_MEMBER(nyny_state, videoram1)
542   AM_RANGE(0x2000, 0x3fff) AM_RAM AM_BASE_MEMBER(nyny_state, colorram1)
543   AM_RANGE(0x4000, 0x5fff) AM_RAM AM_BASE_MEMBER(nyny_state, videoram2)
544   AM_RANGE(0x6000, 0x7fff) AM_RAM AM_BASE_MEMBER(nyny_state, colorram2)
532545   AM_RANGE(0x8000, 0x9fff) AM_RAM
533546   AM_RANGE(0xa000, 0xa0ff) AM_RAM AM_BASE_SIZE_GENERIC(nvram) /* SRAM (coin counter, shown when holding F2) */
534547   AM_RANGE(0xa100, 0xa100) AM_MIRROR(0x00fe) AM_DEVWRITE("crtc", mc6845_address_w)
r7500r7501
587600   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_COCKTAIL /* PIA0 PA4 */
588601   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_START1 )   /* PIA0 PA5 */
589602   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_START2 )   /* PIA0 PA6 */
590    PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_UNUSED )
603   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_UNUSED )
591604
592605   PORT_START("IN1")
593606   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT ) PORT_2WAY PORT_COCKTAIL /* PIA0 PB0 */
594607   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT ) PORT_2WAY PORT_COCKTAIL /* PIA0 PB1 */
595608   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT ) PORT_2WAY   /* PIA0 PB2 */
596609   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT ) PORT_2WAY   /* PIA0 PB3 */
597    PORT_BIT( 0xf0, IP_ACTIVE_HIGH, IPT_UNUSED )
610   PORT_BIT( 0xf0, IP_ACTIVE_HIGH, IPT_UNUSED )
598611
599   PORT_START("SW1")   /* port 2 */
612   PORT_START("SW1")
600613   PORT_DIPNAME( 0x03, 0x03, "Bombs from UFO (Screens 3+)" ) PORT_DIPLOCATION("SW1:1,2")
601614   PORT_DIPSETTING(   0x01, "3" )
602615   PORT_DIPSETTING(   0x00, "6" )
r7500r7501
609622   PORT_DIPSETTING(   0x00, DEF_STR( Low ) )
610623   PORT_DIPSETTING(   0x80, DEF_STR( High ) )
611624
612   PORT_START("SW2")   /* port 3 */
625   PORT_START("SW2")
613626   PORT_DIPNAME( 0x03, 0x03, DEF_STR( Coin_A ) ) PORT_DIPLOCATION("SW2:1,2")
614627   PORT_DIPSETTING(   0x02, DEF_STR( 2C_1C ) )
615628   PORT_DIPSETTING(   0x03, DEF_STR( 1C_1C ) )
r7500r7501
627640   PORT_DIPSETTING(   0x00, DEF_STR( No ) )
628641   PORT_DIPSETTING(   0x80, DEF_STR( Yes ) )
629642
630   PORT_START("SW3")   /* port 4 */
643   PORT_START("SW3")
631644   PORT_DIPNAME( 0x01, 0x00, DEF_STR( Flip_Screen ) ) PORT_DIPLOCATION("SW3:1")
632645   PORT_DIPSETTING(   0x00, DEF_STR( Off ) )
633646   PORT_DIPSETTING(   0x01, DEF_STR( On ) )
r7500r7501
651664   PORT_DIPSETTING(   0x40, "+2" )
652665   PORT_DIPSETTING(   0x20, "+3" )
653666
654    PORT_START("CROSS")      /* connected to PIA1 CB1 input */
655    PORT_BIT( 0xff, IP_ACTIVE_LOW, IPT_OTHER ) PORT_NAME("PS1 (Crosshatch)") PORT_CODE(KEYCODE_F1)
667   PORT_START("CROSS")      /* connected to PIA1 CB1 input */
668   PORT_BIT( 0xff, IP_ACTIVE_LOW, IPT_OTHER ) PORT_NAME("PS1 (Crosshatch)") PORT_CODE(KEYCODE_F1)
656669
657670INPUT_PORTS_END
658671
r7500r7501
660673
661674/*************************************
662675 *
676 *  Machine start & reset
677 *
678 *************************************/
679
680static MACHINE_START( nyny )
681{
682   nyny_state *state = (nyny_state *)machine->driver_data;
683
684   state->maincpu = devtag_get_device(machine, "maincpu");
685   state->audiocpu = devtag_get_device(machine, "audiocpu");
686   state->audiocpu2 = devtag_get_device(machine, "audio2");
687   state->ic48_1 = devtag_get_device(machine, "ic48_1");
688   state->mc6845 = devtag_get_device(machine, "crtc");
689   state->pia1 = devtag_get_device(machine, "pia1");
690   state->pia2 = devtag_get_device(machine, "pia2");
691
692   /* setup for save states */
693   state_save_register_global(machine, state->flipscreen);
694   state_save_register_global(machine, state->star_enable);
695   state_save_register_global(machine, state->star_delay_counter);
696   state_save_register_global(machine, state->star_shift_reg);
697}
698
699static MACHINE_RESET( nyny )
700{
701   nyny_state *state = (nyny_state *)machine->driver_data;
702
703   state->flipscreen = 0;
704   state->star_enable = 0;
705   state->star_delay_counter = 0;
706   state->star_shift_reg = 0;
707}
708
709/*************************************
710 *
663711 *  Machine driver
664712 *
665713 *************************************/
666714
667715static MACHINE_DRIVER_START( nyny )
668716
717   /* driver data */
718   MDRV_DRIVER_DATA(nyny_state)
719
669720   /* basic machine hardware */
670721   MDRV_CPU_ADD("maincpu", M6809, 1400000)   /* 1.40 MHz? The clock signal is generated by analog chips */
671722   MDRV_CPU_PROGRAM_MAP(nyny_main_map)
r7500r7501
678729   MDRV_CPU_PROGRAM_MAP(nyny_audio_2_map)
679730
680731   MDRV_MACHINE_START(nyny)
732   MDRV_MACHINE_RESET(nyny)
681733   MDRV_NVRAM_HANDLER(generic_0fill)
682734
683735   /* video hardware */
src/mame/drivers/poo.c
r0r7501
1/*******************************************************************************************
2
3Uncle Poo (c) 1983 Diatec
4
5actually an hack of Joinem? Or there's something even more similar?
6
7driver by David Haywood and Angelo Salese
8
9TODO:
10-merge with jack.c driver, this is a modification of that HW (with colscroll)
11-accurate game speed (controlled by an irq)
12-title screen colors are wrong? But I can't see how I could fix it without breaking anything
13 else
14-a bunch of unmapped read / writes
15-writes to ROM regions
16
17*******************************************************************************************/
18
19/* Stephh's Notes:
20
21'unclepoo'
22
23SYSTEM bit 7 is sort of "freeze", but it doesn't seem to have any effect when playing
24(only during boot up sequence - unsure about attract mode)
25
26DSW1 bit 5 is "Bonus Lives" :
27  - when Off (0x00), you get an extra life EVERY 30000 points
28  - When On  (0x20), you get an extra life at 30000 points ONLY
29
30DSW1 bits 6 and 7 might be used for difficulty (to be confirmed)
31
32DSW2 bit 0 is the "Cabinet" Dip Switch :
33  - when Off (0x00), cabinet is cocktail
34  - When On  (0x01), cabinet is upright
35This affects write to 0xb700 (bit 7) and reads from 0xb506 and 0xb507 ...
36BTW, remove PORT_PLAYER(1) and change PORT_PLAYER(2) to PORT_COCKTAIL ...
37
38DSW2 bit 7 overwrites the number of lives :
39  - When Off (0x00), lives are based on DSW1 bit 4
40  - When On  (0x80), lives are set to 255 (0xff) but they are NOT infinite
41
42Other bits from DSW2 (but bit 5) don't seem to be read / tested at all ...
43*/
44
45
46#include "emu.h"
47#include "cpu/z80/z80.h"
48#include "sound/ay8910.h"
49
50static UINT8 *poo_vram, *poo_scrolly, *poo_sprites;
51
52VIDEO_START(unclepoo)
53{
54
55}
56
57VIDEO_UPDATE(unclepoo)
58{
59   int y,x;
60   int count;
61   const gfx_element *gfx = screen->machine->gfx[0];
62
63   count = 0;
64
65   for (x=0;x<32;x++)
66   {
67      for (y=0;y<32;y++)
68      {
69         int tile = poo_vram[count+0x000] | ((poo_vram[count+0x400] & 3) <<8);
70         int color = (poo_vram[count+0x400] & 0xf8) >> 3;
71         int scrolly = (poo_scrolly[x*4]);
72
73         drawgfx_opaque(bitmap,cliprect,gfx,tile,color,0,0,x*8,256-(y*8)+scrolly);
74         drawgfx_opaque(bitmap,cliprect,gfx,tile,color,0,0,x*8,0-(y*8)+scrolly);
75
76         count++;
77      }
78   }
79
80   {
81      int spr_offs,x,y,col,fx,fy,i;
82
83      for(i=0;i<0x80;i+=4)
84      {
85         spr_offs = poo_sprites[i+2] | (poo_sprites[i+3] & 3) << 8;
86         y = poo_sprites[i+0]+8;
87         x = poo_sprites[i+1];
88         col = (poo_sprites[i+3] & 0xf8) >> 3;
89         fx = 0;
90         fy = 0;
91
92         drawgfx_transpen(bitmap,cliprect,gfx,spr_offs,col,fx,fy,x,y,0);
93      }
94   }
95
96   return 0;
97}
98
99static READ8_HANDLER( unk_inp_r )
100{
101   return 0x00;//mame_rand(space->machine);
102}
103
104#if 0
105
106static READ8_HANDLER( unk_inp2_r )
107{
108   return 0xff;
109}
110
111static READ8_HANDLER( unk_inp3_r )
112{
113   return mame_rand(space->machine);
114}
115#endif
116
117
118static WRITE8_HANDLER( unk_w )
119{
120
121}
122
123/* soundlatch write */
124static WRITE8_HANDLER( test_w )
125{
126   soundlatch_w(space, 0, (data & 0xff));
127   cputag_set_input_line(space->machine, "subcpu", 0, HOLD_LINE);
128}
129
130static WRITE8_HANDLER( test2_w )
131{
132   //x[1] = data;
133   //soundlatch2_w(space, 0, (data & 0xff));
134   //cputag_set_input_line(space->machine, "subcpu", 0, HOLD_LINE);
135}
136
137static ADDRESS_MAP_START( unclepoo_main_map, ADDRESS_SPACE_PROGRAM, 8 )
138   AM_RANGE(0x0000, 0x7fff) AM_ROM
139   AM_RANGE(0x8000, 0x8fff) AM_RAM
140   AM_RANGE(0x9000, 0x97ff) AM_RAM
141   AM_RANGE(0xb000, 0xb07f) AM_RAM AM_BASE(&poo_sprites)
142   AM_RANGE(0xb080, 0xb0ff) AM_RAM AM_BASE(&poo_scrolly)
143
144   AM_RANGE(0x9800, 0x9801) AM_READ(unk_inp_r) AM_WRITE( unk_w )
145
146   AM_RANGE(0xb400, 0xb400) AM_WRITE(test_w)
147
148   AM_RANGE(0xb500, 0xb500) AM_READ_PORT("DSW1")
149   AM_RANGE(0xb501, 0xb501) AM_READ_PORT("DSW2")
150   AM_RANGE(0xb502, 0xb502) AM_READ_PORT("P1")
151   AM_RANGE(0xb503, 0xb503) AM_READ_PORT("P2")
152   AM_RANGE(0xb504, 0xb504) AM_READ_PORT("SYSTEM")
153
154   AM_RANGE(0xb700, 0xb700) AM_WRITE(test2_w)
155
156   AM_RANGE(0xb800, 0xbfff) AM_RAM AM_BASE(&poo_vram)
157
158ADDRESS_MAP_END
159
160static ADDRESS_MAP_START( unclepoo_main_portmap, ADDRESS_SPACE_IO, 8 )
161   ADDRESS_MAP_GLOBAL_MASK(0xff)
162
163ADDRESS_MAP_END
164
165#if 0
166static WRITE8_HANDLER( mem_w )
167{
168
169}
170#endif
171
172static ADDRESS_MAP_START( unclepoo_sub_map, ADDRESS_SPACE_PROGRAM, 8 )
173   AM_RANGE(0x0000, 0x0fff) AM_ROM
174
175   AM_RANGE(0x4000, 0x43ff) AM_RAM
176
177   AM_RANGE(0x6000, 0x6000) AM_WRITENOP  /* R/C filter ??? */
178ADDRESS_MAP_END
179
180
181
182static ADDRESS_MAP_START( unclepoo_sub_portmap, ADDRESS_SPACE_IO, 8 )
183   ADDRESS_MAP_GLOBAL_MASK(0xff)
184
185   AM_RANGE(0x40, 0x40) AM_DEVREADWRITE("ay", ay8910_r, ay8910_data_w)
186   AM_RANGE(0x80, 0x80) AM_DEVWRITE("ay", ay8910_address_w)
187ADDRESS_MAP_END
188
189
190static INPUT_PORTS_START( unclepoo )
191   PORT_START("P1")
192   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP ) PORT_PLAYER(1)
193   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN ) PORT_PLAYER(1)
194   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT ) PORT_PLAYER(1)
195   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT ) PORT_PLAYER(1)
196   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_PLAYER(1)
197   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_BUTTON2 ) PORT_PLAYER(1)
198   PORT_BIT( 0xc0, IP_ACTIVE_HIGH, IPT_UNUSED )
199
200   PORT_START("P2")
201   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP ) PORT_PLAYER(2)
202   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN ) PORT_PLAYER(2)
203   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT ) PORT_PLAYER(2)
204   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT ) PORT_PLAYER(2)
205   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_PLAYER(2)
206   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_BUTTON2 ) PORT_PLAYER(2)
207   PORT_BIT( 0xc0, IP_ACTIVE_HIGH, IPT_UNUSED )
208
209   PORT_START("SYSTEM")
210   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_COIN1 )
211   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_COIN2 )
212   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_START1 )
213   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_START2 )
214   PORT_DIPNAME( 0x10, 0x00, DEF_STR( Unknown ) )
215   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
216   PORT_DIPSETTING(    0x10, DEF_STR( On ) )
217   PORT_DIPNAME( 0x20, 0x00, DEF_STR( Unknown ) )
218   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
219   PORT_DIPSETTING(    0x20, DEF_STR( On ) )
220   PORT_DIPNAME( 0x40, 0x00, DEF_STR( Unknown ) )
221   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
222   PORT_DIPSETTING(    0x40, DEF_STR( On ) )
223   PORT_DIPNAME( 0x80, 0x00, DEF_STR( Unknown ) )
224   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
225   PORT_DIPSETTING(    0x80, DEF_STR( On ) )
226
227   PORT_START("DSW1")
228   PORT_DIPNAME( 0x03, 0x00, DEF_STR( Coin_A ) )      PORT_DIPLOCATION("SW1:1,2")
229   PORT_DIPSETTING(    0x01, DEF_STR( 2C_1C ) )
230   PORT_DIPSETTING(    0x03, DEF_STR( 4C_3C ) )
231   PORT_DIPSETTING(    0x00, DEF_STR( 1C_1C ) )
232   PORT_DIPSETTING(    0x02, DEF_STR( 1C_3C ) )
233   PORT_DIPNAME( 0x0c, 0x00, DEF_STR( Coin_B ) )      PORT_DIPLOCATION("SW1:3,4")
234   PORT_DIPSETTING(    0x08, DEF_STR( 3C_1C ) )
235   PORT_DIPSETTING(    0x04, DEF_STR( 2C_1C ) )
236   PORT_DIPSETTING(    0x0c, DEF_STR( 4C_3C ) )
237   PORT_DIPSETTING(    0x00, DEF_STR( 1C_1C ) )
238   PORT_DIPNAME( 0x10, 0x00, DEF_STR( Lives ) )      PORT_DIPLOCATION("SW1:5")
239   PORT_DIPSETTING(    0x00, "3" )
240   PORT_DIPSETTING(    0x10, "5" )
241   PORT_DIPNAME( 0x20, 0x00, DEF_STR( Unknown ) )      PORT_DIPLOCATION("SW1:6")
242   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
243   PORT_DIPSETTING(    0x20, DEF_STR( On ) )
244   PORT_DIPNAME( 0x40, 0x00, DEF_STR( Unknown ) )      PORT_DIPLOCATION("SW1:7")
245   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
246   PORT_DIPSETTING(    0x40, DEF_STR( On ) )
247   PORT_DIPNAME( 0x80, 0x00, DEF_STR( Unknown ) )      PORT_DIPLOCATION("SW1:8")
248   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
249   PORT_DIPSETTING(    0x80, DEF_STR( On ) )
250
251   PORT_START("DSW2")
252   PORT_DIPNAME( 0x01, 0x00, "IN2" )         PORT_DIPLOCATION("SW2:1")
253   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
254   PORT_DIPSETTING(    0x01, DEF_STR( On ) )
255   PORT_DIPNAME( 0x02, 0x00, DEF_STR( Unknown ) )      PORT_DIPLOCATION("SW2:2")
256   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
257   PORT_DIPSETTING(    0x02, DEF_STR( On ) )
258   PORT_DIPNAME( 0x04, 0x00, DEF_STR( Unknown ) )      PORT_DIPLOCATION("SW2:3")
259   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
260   PORT_DIPSETTING(    0x04, DEF_STR( On ) )
261   PORT_DIPNAME( 0x08, 0x00, DEF_STR( Unknown ) )      PORT_DIPLOCATION("SW2:4")
262   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
263   PORT_DIPSETTING(    0x08, DEF_STR( On ) )
264   PORT_DIPNAME( 0x10, 0x00, DEF_STR( Unknown ) )      PORT_DIPLOCATION("SW2:5")
265   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
266   PORT_DIPSETTING(    0x10, DEF_STR( On ) )
267   PORT_DIPNAME( 0x20, 0x00, "Test Mode" )         PORT_DIPLOCATION("SW2:6")
268   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
269   PORT_DIPSETTING(    0x20, DEF_STR( On ) )
270   PORT_DIPNAME( 0x40, 0x00, DEF_STR( Unknown ) )      PORT_DIPLOCATION("SW2:7")
271   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
272   PORT_DIPSETTING(    0x40, DEF_STR( On ) )
273   PORT_DIPNAME( 0x80, 0x00, DEF_STR( Unknown ) )      PORT_DIPLOCATION("SW2:8")
274   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
275   PORT_DIPSETTING(    0x80, DEF_STR( On ) )
276
277
278INPUT_PORTS_END
279
280static const gfx_layout tiles8x8_layout =
281{
282   8,8,
283   RGN_FRAC(1,3),
284   3,
285   { RGN_FRAC(2,3), RGN_FRAC(1,3), RGN_FRAC(0,3) },
286   { 0, 1,2,3,4,5,6,7 },
287   { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8 },
288   8*8
289};
290
291static GFXDECODE_START( unclepoo )
292   GFXDECODE_ENTRY( "gfx", 0, tiles8x8_layout, 0, 0x20 )
293GFXDECODE_END
294
295static PALETTE_INIT( unclepoo )
296{
297   int i,r,g,b,val;
298   int bit0,bit1,bit2;
299
300   for (i = 0; i < 0x200; i++)
301   {
302      val = (color_prom[i+0x100]) | (color_prom[i+0x000]<<4);
303
304      bit0 = 0;
305      bit1 = (val >> 6) & 0x01;
306      bit2 = (val >> 7) & 0x01;
307      b = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2;
308      bit0 = (val >> 3) & 0x01;
309      bit1 = (val >> 4) & 0x01;
310      bit2 = (val >> 5) & 0x01;
311      g = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2;
312      bit0 = (val >> 0) & 0x01;
313      bit1 = (val >> 1) & 0x01;
314      bit2 = (val >> 2) & 0x01;
315      r = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2;
316
317      palette_set_color(machine, i, MAKE_RGB(r, g, b));
318   }
319}
320
321/* ??? */
322#if 0
323
324static READ8_HANDLER( test_r )
325{
326   return 0xf6;
327}
328
329/* soundlatch */
330static READ8_HANDLER( test2_r )
331{
332   return 0x00;
333}
334#endif
335
336 static READ8_HANDLER( timer_r )
337{
338   return cpu_get_total_cycles(space->cpu) / 16;
339}
340
341
342static const ay8910_interface ay8910_config =
343{
344   AY8910_LEGACY_OUTPUT,
345   AY8910_DEFAULT_LOADS,
346   DEVCB_MEMORY_HANDLER("subcpu", PROGRAM, soundlatch_r),
347   DEVCB_MEMORY_HANDLER("subcpu", PROGRAM, timer_r),
348   DEVCB_NULL,
349   DEVCB_NULL
350};
351
352static MACHINE_DRIVER_START( unclepoo )
353   /* basic machine hardware */
354   MDRV_CPU_ADD("maincpu", Z80,18000000/6)       /* ? MHz */
355   MDRV_CPU_PROGRAM_MAP(unclepoo_main_map)
356   MDRV_CPU_IO_MAP(unclepoo_main_portmap)
357   MDRV_CPU_VBLANK_INT("screen", nmi_line_pulse)
358   MDRV_CPU_PERIODIC_INT(irq0_line_hold,256) // ??? controls game speed
359
360   MDRV_CPU_ADD("subcpu", Z80,18000000/12)       /* ? MHz */
361   MDRV_CPU_PROGRAM_MAP(unclepoo_sub_map)
362   MDRV_CPU_IO_MAP(unclepoo_sub_portmap)
363//  MDRV_CPU_VBLANK_INT("screen", irq0_line_hold)
364
365   /* video hardware */
366   MDRV_SCREEN_ADD("screen", RASTER)
367   MDRV_SCREEN_REFRESH_RATE(60)
368   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(0))
369   MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16)
370   MDRV_SCREEN_SIZE(256, 256)
371   MDRV_SCREEN_VISIBLE_AREA(0, 256-1, 16, 256-1)
372
373   MDRV_GFXDECODE(unclepoo)
374   MDRV_PALETTE_LENGTH(0x100)
375   MDRV_PALETTE_INIT(unclepoo)
376
377   MDRV_VIDEO_START(unclepoo)
378   MDRV_VIDEO_UPDATE(unclepoo)
379
380   MDRV_SPEAKER_STANDARD_MONO("mono")
381   MDRV_SOUND_ADD("ay", AY8910, 18000000/12) /* ? Mhz */
382   MDRV_SOUND_CONFIG(ay8910_config)
383   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50)
384MACHINE_DRIVER_END
385
386
387
388ROM_START( unclepoo )
389   ROM_REGION( 0x8000, "maincpu", 0 )
390   ROM_LOAD( "01.f17", 0x00000, 0x2000, CRC(92fb238c) SHA1(e9476c5c1a0bf9e8c6c364ac022ed1d97ae66d2e) )
391   ROM_LOAD( "02.f14", 0x02000, 0x2000, CRC(b99214ef) SHA1(c8e4af0efbc5ea543277b2764dc6f119aae477ca) )
392   ROM_LOAD( "03.f11", 0x04000, 0x2000, CRC(a136af97) SHA1(cfa610bf357870053617fed8aef6bb30bd996422) )
393   ROM_LOAD( "04.f09", 0x06000, 0x2000, CRC(c4bcd414) SHA1(df3125358530f5fb8d202bddcb0ef5e322fabb7b) )
394
395   ROM_REGION( 0x1000, "subcpu", 0 )
396   ROM_LOAD( "08.c15", 0x00000, 0x1000, CRC(fd84106b) SHA1(891853d2b39850a981016108b74ca20337d2cdd8) )
397
398   ROM_REGION( 0x6000, "gfx", 0 )
399   ROM_LOAD( "05.k04", 0x0000, 0x2000, CRC(64026934) SHA1(a5342335d02d34fa6ba2b29484ed71ecc96292f2) )
400   ROM_LOAD( "06.j04", 0x2000, 0x2000, CRC(94b5f676) SHA1(32c27854726636c4ce03bb6a83b32d04ed6c42af) )
401   ROM_LOAD( "07.h04", 0x4000, 0x2000, CRC(e2f73e99) SHA1(61cb09ff424ba63b892b4822e7ed916af73412f1) )
402
403   ROM_REGION( 0x200, "proms", 0 )
404   ROM_LOAD( "diatec_h.bin", 0x000, 0x100, CRC(938601b1) SHA1(8213284989bebb5f7375878181840de8079dc1f3) )
405   ROM_LOAD( "diatec_l.bin", 0x100, 0x100, CRC(b04d466a) SHA1(1438abeae76ef807ba34bd6d3e4c44f707dbde6e) )
406ROM_END
407
408GAME( 1983, unclepoo, 0, unclepoo, unclepoo, 0, ROT90, "Diatec",         "Uncle Poo", 0 )
src/mame/drivers/calorie.c
r7500r7501
8383#include "sound/ay8910.h"
8484
8585
86typedef struct _calorie_state calorie_state;
87struct _calorie_state
86class calorie_state
8887{
88public:
89   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, calorie_state(machine)); }
90
91   calorie_state(running_machine &machine) { }
92
8993   /* memory pointers */
9094   UINT8 *  fg_ram;
9195   UINT8 *  sprites;
src/mame/drivers/drtomy.c
r7500r7501
1111#include "cpu/m68000/m68000.h"
1212#include "sound/okim6295.h"
1313
14typedef struct _drtomy_state drtomy_state;
15struct _drtomy_state
14class drtomy_state
1615{
16public:
17   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, drtomy_state(machine)); }
18
19   drtomy_state(running_machine &machine) { }
20
1721   /* memory pointers */
1822   UINT16 *  spriteram;
1923   UINT16 *  videoram_bg;
src/mame/drivers/galaxian.c
r7500r7501
28762876   memory_unmap_readwrite(space, 0x8000, 0x87ff, 0, 0);
28772877}
28782878
2879static DRIVER_INIT( thepitm )
2880{
2881   const address_space *space = cputag_get_address_space(machine, "maincpu", ADDRESS_SPACE_PROGRAM);
28792882
2883   /* video extensions */
2884   common_init(machine, galaxian_draw_bullet, galaxian_draw_background, mooncrst_extend_tile_info, mooncrst_extend_sprite_info);
28802885
2886   /* move the interrupt enable from $b000 to $b001 */
2887   memory_unmap_write(space, 0xb000, 0xb000, 0, 0x7f8);
2888   memory_install_write8_handler(space, 0xb001, 0xb001, 0, 0x7f8, irq_enable_w);
2889
2890   /* disable the stars */
2891   memory_unmap_write(space, 0xb004, 0xb004, 0, 0x07f8);
2892
2893   /* extend ROM */
2894   memory_install_rom(space, 0x0000, 0x47ff, 0, 0, memory_region(machine, "maincpu"));
2895}
2896
28812897/*************************************
28822898 *
28832899 *  Konami games
src/mame/drivers/othldrby.c
r7500r7501
1717#include "emu.h"
1818#include "cpu/m68000/m68000.h"
1919#include "sound/okim6295.h"
20#include "includes/othldrby.h"
2021
2122
22WRITE16_HANDLER( othldrby_videoram_addr_w );
23READ16_HANDLER( othldrby_videoram_r );
24WRITE16_HANDLER( othldrby_videoram_w );
25WRITE16_HANDLER( othldrby_vreg_addr_w );
26WRITE16_HANDLER( othldrby_vreg_w );
27
28VIDEO_START( othldrby );
29VIDEO_EOF( othldrby );
30VIDEO_UPDATE( othldrby );
31
32static int toggle;
33
34
3523static READ16_HANDLER( pip )
3624{
37   return toggle ^= 1;
25   othldrby_state *state = (othldrby_state *)space->machine->driver_data;
26   return state->toggle ^= 1;
3827}
3928
4029static READ16_HANDLER( pap )
r7500r7501
5342{
5443   if (ACCESSING_BITS_0_7)
5544   {
56      coin_counter_w(space->machine, 0,data & 1);
57      coin_counter_w(space->machine, 1,data & 2);
58      coin_lockout_w(space->machine, 0,~data & 4);
59      coin_lockout_w(space->machine, 1,~data & 8);
45      coin_counter_w(space->machine, 0, data & 1);
46      coin_counter_w(space->machine, 1, data & 2);
47      coin_lockout_w(space->machine, 0, ~data & 4);
48      coin_lockout_w(space->machine, 1, ~data & 8);
6049   }
6150}
6251
r7500r7501
9382}
9483
9584
96
9785static ADDRESS_MAP_START( othldrby_map, ADDRESS_SPACE_PROGRAM, 16 )
9886   AM_RANGE(0x000000, 0x07ffff) AM_ROM
9987   AM_RANGE(0x100000, 0x10ffff) AM_RAM
100   AM_RANGE(0x200000, 0x20000f) AM_READWRITE(calendar_r,calendar_w)
88   AM_RANGE(0x200000, 0x20000f) AM_READWRITE(calendar_r, calendar_w)
10189   AM_RANGE(0x300000, 0x300001) AM_WRITE(othldrby_videoram_addr_w)
102   AM_RANGE(0x300004, 0x300007) AM_READWRITE(othldrby_videoram_r,othldrby_videoram_w)
90   AM_RANGE(0x300004, 0x300007) AM_READWRITE(othldrby_videoram_r, othldrby_videoram_w)
10391   AM_RANGE(0x300008, 0x300009) AM_WRITE(othldrby_vreg_addr_w)
10492   AM_RANGE(0x30000c, 0x30000d) AM_READ(pip)   // vblank?
10593   AM_RANGE(0x30000c, 0x30000f) AM_WRITE(othldrby_vreg_w)
10694   AM_RANGE(0x400000, 0x400fff) AM_RAM_WRITE(paletteram16_xBBBBBGGGGGRRRRR_word_w) AM_BASE_GENERIC(paletteram)
107   AM_RANGE(0x600000, 0x600001) AM_DEVREADWRITE8("oki", okim6295_r,okim6295_w, 0x00ff)
95   AM_RANGE(0x600000, 0x600001) AM_DEVREADWRITE8("oki", okim6295_r, okim6295_w, 0x00ff)
10896   AM_RANGE(0x700000, 0x700001) AM_READ(pap)   // scanline???
10997   AM_RANGE(0x700004, 0x700005) AM_READ_PORT("DSW1")
11098   AM_RANGE(0x700008, 0x700009) AM_READ_PORT("DSW2")
r7500r7501
228216
229217
230218
219static MACHINE_START( othldrby )
220{
221   othldrby_state *state = (othldrby_state *)machine->driver_data;
222
223   state_save_register_global(machine, state->toggle);
224   state_save_register_global(machine, state->vram_addr);
225   state_save_register_global(machine, state->vreg_addr);
226   state_save_register_global_array(machine, state->vreg);
227}
228
229static MACHINE_RESET( othldrby )
230{
231   othldrby_state *state = (othldrby_state *)machine->driver_data;
232
233   state->toggle = 0xff;
234   state->vram_addr = 0;
235   state->vreg_addr = 0;
236
237   memset(state->vreg, 0, ARRAY_LENGTH(state->vreg));
238}
239
231240static MACHINE_DRIVER_START( othldrby )
232241
242   /* driver data */
243   MDRV_DRIVER_DATA(othldrby_state)
244
233245   /* basic machine hardware */
234246   MDRV_CPU_ADD("maincpu", M68000, 16000000)
235247   MDRV_CPU_PROGRAM_MAP(othldrby_map)
236248   MDRV_CPU_VBLANK_INT("screen", irq4_line_hold)
237249
250   MDRV_MACHINE_START(othldrby)
251   MDRV_MACHINE_RESET(othldrby)
252
238253   /* video hardware */
239254   MDRV_SCREEN_ADD("screen", RASTER)
240255   MDRV_SCREEN_REFRESH_RATE(60)
r7500r7501
278293   ROM_LOAD( "db0.4",        0x00000, 0x80000, CRC(a9701868) SHA1(9ee89556666d358e8d3915622573b3ba660048b8) )
279294ROM_END
280295
281static DRIVER_INIT( othldrby )
282{
283   toggle = 0xff;
284}
285
286GAME( 1995, othldrby, 0, othldrby, othldrby, othldrby, ROT0, "Sunwise", "Othello Derby (Japan)", 0 )
296GAME( 1995, othldrby, 0, othldrby, othldrby, 0, ROT0, "Sunwise", "Othello Derby (Japan)", GAME_SUPPORTS_SAVE )
src/mame/drivers/pachifev.c
r7500r7501
5959#define USE_MSM 0
6060#define NUM_PLUNGER_REPEATS    50
6161
62typedef struct _pachifev_state pachifev_state;
62class pachifev_state
63{
64public:
65   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, pachifev_state(machine)); }
6366
64struct _pachifev_state
65{
67   pachifev_state(running_machine &machine) { }
68
6669 /* controls related */
6770
6871 int power;
src/mame/drivers/toaplan1.c
r7500r7501
5353    level sequence compared to the Taito licensed version.
5454
5555
56Stephh's notes (based on the games M68000 and Z80 code and some tests) :
57
581) 'rallybik'
59
60  - Region read from DSWB (port 0x50 in CPU1) then stored at 0x8004 (CPU1 shared RAM) =
61    0x180008.w (CPU0 shared RAM) then stored at 0x0804f4.w .
62  - Coinage relies on bits 4 and 5 of the region (code at 0x0ccc in CPU1) :
63      * ..10.... : TOAPLAN_COINAGE_WORLD     (tables at 0x0c35 (COIN1) and 0x0c3d (COIN2) in CPU1)
64      *  else    : TOAPLAN_COINAGE_JAPAN_OLD (table at 0x0c25 (COIN1 AND COIN2) in CPU1)
65  - Title screen relies on bits 4 and 5 of the region (code at 0x00220e) :
66      * ..00.... : "Dash Yarou"
67      *  else    : "Rally Bike"
68  - Notice screen relies on bits 4 and 5 of the region (code at 0x001ac0) :
69      * ..00.... : "FOR USE IN JAPAN ONLY"
70      *  else    : no notice screen
71  - Copyright relies on bits 4 and 5 of the region (code at 0x001e68) :
72      * ..00.... : "TAITO CORPORATION" / "ALL RIGHTS RESERVED"
73      * ..01.... : "TAITO AMERICA CORP." / "ALL RIGHTS RESERVED"
74      * ..10.... : "TAITO CORP. JAPAN" / "ALL RIGHTS RESERVED"
75      * ..11.... : "TAITO AMERICA CORP." / "LICENCED TO ROMSTAR"
76  - Number of letters for initials relies on bits 4 and 5 of the region
77    (code at 0x0008fe = init - code at 0x0022e8 = enter) :
78      * ..00.... : 6 letters
79      *  else    : 3 letters
80  - To enter the "test mode", press START1 when the grid is displayed.
81  - When "TEST" Switch is ON, you can do the following with the STARTn buttons :
82      * press START2 to pause game
83      * press START1 to unpause game
84      * when START1 and START2 are pressed, the game enters in "slow motion" mode
85  - When "TEST" Switch is ON, collision and fuel consuption routines are not called.
86    Don't forget to turn the Debug Switch OFF when time is over on bonus stage,
87    or the level will never end !
88  - When cabinet is set to "Upright", you can use joystick and buttons from both players
89    (code at 0x001c44).
90
912) 'truxton'
92
93  - Region read from Territory Jumper (port 0x70 in CPU1) then stored at 0x8005 (CPU1 shared RAM) =
94    0x18000a.w (CPU0 shared RAM) then stored at 0x081b7c.w .
95  - Coinage relies on bits 0 and 1 of the region (code at 0x0ccc in CPU1) :
96      * ......00 : TOAPLAN_COINAGE_JAPAN_OLD (table at 0x0d21 (COIN1 AND COIN2) in CPU1)
97      * ......01 : TOAPLAN_COINAGE_JAPAN_OLD (table at 0x0d29 (COIN1 AND COIN2) in CPU1)
98      * ......10 : TOAPLAN_COINAGE_WORLD     (tables at 0x0d31 (COIN1) and 0x0d39 (COIN2) in CPU1)
99      * ......11 : TOAPLAN_COINAGE_JAPAN_OLD (table at 0x0d21 (COIN1 AND COIN2) in CPU1)
100  - Title screen relies on bits 0 to 2 of the region (code at 0x002c58) :
101      * .....000 : "Tatsujin"
102      *     else : "Truxton"
103  - Notice screen relies on bits 0 to 2 of the region (code at 0x004eb0) :
104      * .....000 : "FOR USE IN JAPAN ONLY"
105      * ......01 : "FOR USE IN U.S.A. ONLY"
106      * ......1. : no notice screen
107  - Copyright relies on bits 0 to 2 of the region (code at 0x003050) :
108      * .....000 : "TAITO CORPORATION" / "ALL RIGHTS RESERVED"
109      * .....001 : "TAITO AMERICA CORP." / "LICENCED TO ROMSTAR FOR U.S.A."
110      * .....01. : "TAITO CORPORATION" / "ALL RIGHTS RESERVED"
111      * .....1.. : "TAITO AMERICA CORP."
112  - Number of letters for initials relies on bits 0 to 2 of the region
113    (code at 0x000976 = init - code at 0x0004a6 = enter) :
114      * .....000 : 6 letters
115      *     else : 3 letters
116  - Jumper displayed in the Dip Switches screen relies on bits 0 and 1 of the region
117    (code at 0x004546) :
118      * ......00 : "FOR JAPAN"
119      * ......01 : "FOR U.S.A."
120      * ......1. : "FOR EUROPE"
121    So when territory is set to "USA/Taito America" (0x04), it will display "FOR JAPAN" !
122    Jumpers 3 and 4 status is updated but they are always listed as unused.
123  - To enter the "test mode", press START1 when the grid is displayed.
124  - The "TEST" switch has the same effect as the "Service Mode" Dip Switch (DSWA bit 2).
125  - When cabinet is set to "Upright", you can use joystick and buttons from both players
126    (code at 0x002856).
127
128
1293) 'hellfire' and "clones"
130
131    TO DO !
132
133
1344) 'zerowing' and "clones"
135
1364a) 'zerowing'
137
138  - Region read from Territory Jumper (port 0x70 in CPU1) then stored at 0x8005 (CPU1 shared RAM) =
139    0x44000a.w (CPU0 shared RAM) then stored at 0x081810.w .
140  - Coinage relies on bits 0 and 1 of the region (code at 0x0c59 in CPU1) :
141      * ......00 : TOAPLAN_COINAGE_JAPAN_OLD (table at 0x0cae (COIN1 AND COIN2) in CPU1)
142      * ......01 : TOAPLAN_COINAGE_JAPAN_OLD (table at 0x0cb6 (COIN1 AND COIN2) in CPU1)
143      * ......1. : TOAPLAN_COINAGE_WORLD     (tables at 0x0cbe (COIN1) and 0x0cb6 (COIN2) in CPU1)
144  - Notice screen relies on bit 0 of the region (code at 0x000564) :
145      * .......0 : "FOR USE IN JAPAN ONLY"
146      * .......1 : "FOR USE IN U.S.A. ONLY"
147    But this routine is only called if both bits 0 and 1 of the region are set to 0
148    (code at 0x000530), so there is a notice screen only when "Territory" is set to "Japan".
149  - Copyright does NOT rely on the region, it is hard-coded in the M68000 ROMS.
150  - Number of letters for initials relies on bits 0 and 1 of the region, but it is buggy :
151    in the init routine (code at 0x000de0), bit 1 is tested (0 = 6 letters - 1 = 3 letters),
152    but in the enter routine (code at 0x001bf4), bit 0 is tested ! So you get the following :
153      * ......00 : 6 letters with default high-scores initials filled with "......"
154      * ......01 : 3 letters with default high-scores initials filled with "   ..."
155      * ......10 : 6 letters with default high-scores initials filled with "...000"
156      * ......11 : 3 letters with default high-scores initials filled with "   ..."
157  - Jumper displayed in the Dip Switches screen relies on bits 0 and 1 of the region
158    (code at 0x000922) :
159      * ......00 : "FOR JAPAN."
160      * ......01 : "FOR U.S.A."
161      * ......1. : "FOR EUROPE"
162  - When "Invulnerability" Dip Switch is ON, you can do the following with the STARTn buttons :
163      * press START2 to pause game
164      * press START1 to unpause game
165      * when START1 and START2 are pressed, the game enters in "slow motion" mode
166  - When "Invulnerability" Dip Switch is ON, you can't die (of course), but you also can't move
167    nor shoot while "captured" by an enemy or the background ! So you have to wait until enemy
168    gives up or background scrolls enough to "free" you.
169  - When cabinet is set to "Upright", you can use joystick and buttons from both players
170    (code at 0x00541a).
171
1724b) 'zerowing2'
173
174  - Region read from Territory Jumper (port 0x70 in CPU1) then stored at 0x8005 (CPU1 shared RAM) =
175    0x44000a.w (CPU0 shared RAM) then stored at 0x081ae2.w .
176  - Same sound CPU as in 'zerowing', so same coinage infos.
177  - Notice screen relies on bit 0 of the region (code at 0x0005f4) :
178      * .......0 : "FOR USE IN JAPAN ONLY"
179      * .......1 : "FOR USE IN U.S.A. ONLY"
180    But this routine is only called if bit 1 of the region is set to 0 (code at 0x0005c2),
181    so there shall be a notice screen only when "Territory" is not set to "Europe".
182    Furthermore, because of the 'bra' instruction at 0x00059e, there is never a notice screen !
183  - Copyright does NOT rely on the region, it is hard-coded in the M68000 ROMS.
184    It is different from the one in 'zerowing' though.
185  - Number of letters for initials relies on bit 1 of the region in the init routine (code at 0x000e64) :
186      * ......0. : 6 letters
187      * ......1. : 3 letters
188    But there are then no more tests on the region and only 3 letters can be entered (display ". . .") .
189  - Jumper displayed in the Dip Switches screen relies on bits 0 and 1 of the region
190    (code at 0x0009b2), but some data has been altered not to display "FOR JAPAN." !
191    So you get the following :
192      * ......0. : "FOR U.S.A."
193      * ......1. : "FOR EUROPE"
194  - When "Invulnerability" Dip Switch is ON, you can do the following with the STARTn buttons :
195      * press START2 to pause game
196      * press START1 to unpause game
197      * when START1 and START2 are pressed, the game enters in "slow motion" mode
198  - When "Invulnerability" Dip Switch is ON, you can't die (of course), but you also can't move
199    nor shoot while "captured" by an enemy or the background ! So you have to wait until enemy
200    gives up or background scrolls enough to "free" you.
201  - As you can play with 2 players at the same time, there is no need of a "Cabinet" setting,
202    so DSWA bit 0 is unused (it is even no more tested).
203  - As other player can join in at any time, there is no need of a "Continue" setting,
204    so DSWB bit 7 is unused (it is even no more tested).
205  - Here are some differences I noticed with 'zerowing' :
206      * you get the twin ships when starting a new life
207      * speed range is 0x14-0x2c instead of 0x10-0x30 (but still +0x08)
208    There might be some other differences, but as the M68000 code is heavily modified and as
209    many addresses in RAM are different, it isn't very easy to spot which ones :( Any help is welcome !
210
211
56212To Do:
57    Add support for HD647180 (Z180) sound CPUs (once their internal
58    ROMS are dumped). These are:
59        Fire Shark/Same! Same! Same!
213    Add support for HD647180 (Z180) sound CPUs (once their internal ROMS are dumped).
214    These are:
215        Fire Shark / Same! Same! Same!
60216        Vimana
217    In the meantime, it can be interesting to simulate the basic communications (coinage and credits)
218    between the M68000 and the Z180 based on what is done for games with a Z80 sound CPU.  [stephh]
61219
62220***************************************************************************/
63221
r7500r7501
65223#include "cpu/z80/z80.h"
66224#include "cpu/m68000/m68000.h"
67225#include "cpu/tms32010/tms32010.h"
226#include "includes/toaplipt.h"
68227#include "includes/toaplan1.h"
69228#include "sound/3812intf.h"
70229
r7500r7501
365524
366525
367526/*****************************************************************************
368    Input Port definitions
527    Generic Input Port definitions
369528*****************************************************************************/
529static INPUT_PORTS_START( toaplan1_2b )
530   PORT_START("P1")
531   TOAPLAN_JOY_UDLR_2_BUTTONS( 1 )
370532
533   PORT_START("P2")
534   TOAPLAN_JOY_UDLR_2_BUTTONS( 2 )
535
536   PORT_START("SYSTEM")
537   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_SERVICE1 )
538   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_TILT )
539   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_SPECIAL )           /* "TEST" switch - see notes */
540   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_COIN1 )
541   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_COIN2 )
542   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_START1 )
543   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_START2 )
544   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_UNUSED )
545
546   PORT_START("VBLANK")
547   PORT_BIT( 0x0001, IP_ACTIVE_HIGH, IPT_VBLANK )
548   PORT_BIT( 0xfffe, IP_ACTIVE_HIGH, IPT_UNKNOWN )
549INPUT_PORTS_END
550
551static INPUT_PORTS_START( toaplan1_3b )
552   PORT_INCLUDE( toaplan1_2b )
553
554   PORT_MODIFY("P1")
555   TOAPLAN_JOY_UDLR_3_BUTTONS( 1 )
556
557   PORT_MODIFY("P2")
558   TOAPLAN_JOY_UDLR_3_BUTTONS( 2 )
559INPUT_PORTS_END
560
561
371562#define  TOAPLAN1_PLAYER_INPUT( player, button3, options )                              \
372563   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP ) PORT_PLAYER(player) options PORT_8WAY      \
373564   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN ) PORT_PLAYER(player) options PORT_8WAY   \
r7500r7501
395586   PORT_BIT( 0xfffe, IP_ACTIVE_HIGH, IPT_UNKNOWN )
396587
397588
589/*****************************************************************************
590    Game-specific Input Port definitions
591*****************************************************************************/
592
593/* verified from M68000 and Z80 code */
398594static INPUT_PORTS_START( rallybik )
399   TOAPLAN1_VBLANK_INPUT
595   PORT_INCLUDE( toaplan1_2b )
400596
401   PORT_START("P1")
402   TOAPLAN1_PLAYER_INPUT( 1, IPT_UNKNOWN, )
597   /* in 0x40 (CPU1) -> 0x8003 (CPU1 shared RAM) = 0x180006.w (CPU0 shared RAM) -> 0x0804f2.w */
598   PORT_START("DSWA")
599   TOAPLAN_MACHINE_COCKTAIL
600   TOAPLAN_COINAGE_DUAL(DSWB, 0x30, 0x20)                  /* see notes */
403601
404   PORT_START("P2")
405   TOAPLAN1_PLAYER_INPUT( 2, IPT_UNKNOWN, PORT_COCKTAIL )
406
407   PORT_START("DSWA")   /* DSW A */
408   PORT_DIPNAME( 0x01, 0x01, DEF_STR( Cabinet ) )
409   PORT_DIPSETTING(    0x01, DEF_STR( Upright ) )
410   PORT_DIPSETTING(    0x00, DEF_STR( Cocktail ) )
411   PORT_DIPNAME( 0x02, 0x00, DEF_STR( Flip_Screen ) )
412   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
413   PORT_DIPSETTING(    0x02, DEF_STR( On ) )
414   PORT_SERVICE( 0x04, IP_ACTIVE_HIGH )
415   PORT_DIPNAME( 0x08, 0x00, DEF_STR( Demo_Sounds ) )
416   PORT_DIPSETTING(    0x08, DEF_STR( Off ) )
417   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
418   PORT_DIPNAME( 0x30, 0x00, DEF_STR( Coin_A ) )
419   PORT_DIPSETTING(    0x20, DEF_STR( 2C_1C ) )
420   PORT_DIPSETTING(    0x00, DEF_STR( 1C_1C ) )
421   PORT_DIPSETTING(    0x30, DEF_STR( 2C_3C ) )
422   PORT_DIPSETTING(    0x10, DEF_STR( 1C_2C ) )
423   PORT_DIPNAME( 0xc0, 0x00, DEF_STR( Coin_B ) )
424   PORT_DIPSETTING(    0x80, DEF_STR( 2C_1C ) )
425   PORT_DIPSETTING(    0x00, DEF_STR( 1C_1C ) )
426   PORT_DIPSETTING(    0xc0, DEF_STR( 2C_3C ) )
427   PORT_DIPSETTING(    0x40, DEF_STR( 1C_2C ) )
428
429   PORT_START("DSWB")   /* DSW B */
430   PORT_DIPNAME( 0x03, 0x00, DEF_STR( Difficulty ) )
431   PORT_DIPSETTING(    0x01, DEF_STR( Easy ) )
432   PORT_DIPSETTING(    0x00, DEF_STR( Medium ) )
433   PORT_DIPSETTING(    0x02, DEF_STR( Hard ) )
434   PORT_DIPSETTING(    0x03, DEF_STR( Hardest ) )
435   PORT_DIPNAME( 0x04, 0x00, DEF_STR( Unknown ) )
436   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
437   PORT_DIPSETTING(    0x04, DEF_STR( On ) )
438   PORT_DIPNAME( 0x08, 0x00, DEF_STR( Unknown ) )
439   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
440   PORT_DIPSETTING(    0x08, DEF_STR( On ) )
441   PORT_DIPNAME( 0x30, 0x20, "Territory/Copyright" )
442   PORT_DIPSETTING(    0x20, "World/Taito Corp Japan" )
602   /* in 0x50 (CPU1) -> 0x8004 (CPU1 shared RAM) = 0x180008.w (CPU0 shared RAM) -> 0x0804f4.w */
603   PORT_START("DSWB")
604   TOAPLAN_DIFFICULTY
605   PORT_DIPUNUSED( 0x04, IP_ACTIVE_HIGH )
606   PORT_DIPUNUSED( 0x08, IP_ACTIVE_HIGH )
607   PORT_DIPNAME( 0x30, 0x20, "Territory/Copyright" )       /* bits 4 and 5 listed as unused in the Dip Switches screen */
608   PORT_DIPSETTING(    0x20, "Europe/Taito Corp Japan" )
443609   PORT_DIPSETTING(    0x10, "USA/Taito America" )
610   PORT_DIPSETTING(    0x30, "USA/Taito America (Romstar)" )
444611   PORT_DIPSETTING(    0x00, "Japan/Taito Corp" )
445   PORT_DIPSETTING(    0x30, "USA/Taito America (Romstar)" )
446   PORT_DIPNAME( 0x40, 0x00, "Dip Switch Display" )
447   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
448   PORT_DIPSETTING(    0x40, DEF_STR( On ) )
449   PORT_DIPNAME( 0x80, 0x00, DEF_STR( Allow_Continue ) )
612   PORT_DIPNAME( 0x40, 0x00, "Show Dip Switches Settings" )
613   PORT_DIPSETTING(   0x00, DEF_STR( No ) )
614   PORT_DIPSETTING(   0x40, DEF_STR( Yes ) )
615   PORT_DIPNAME( 0x80, 0x00, DEF_STR( Allow_Continue ) )   /* not on race 1 */
450616   PORT_DIPSETTING(    0x80, DEF_STR( No ) )
451617   PORT_DIPSETTING(    0x00, DEF_STR( Yes ) )
452618
453   TOAPLAN1_SYSTEM_INPUTS
619   PORT_START("TJUMP")       /* Territory Jumper Block (not present ? this port isn't even read) */
620   PORT_BIT( 0xff, IP_ACTIVE_HIGH, IPT_UNUSED )
454621
455   PORT_START("TJUMP")   /* Territory Jumper Block (not present?) */
456   PORT_BIT( 0xff, IP_ACTIVE_HIGH, IPT_UNKNOWN )
622   /* P1 : in 0x00 (CPU1) -> 0x8006 (CPU1 shared RAM) = 0x18000c.w (CPU0 shared RAM) */
623   /* P2 : in 0x10 (CPU1) -> 0x8007 (CPU1 shared RAM) = 0x18000e.w (CPU0 shared RAM) */
624
625   /* in 0x20 (CPU1) -> 0x8005 (CPU1 shared RAM) = 0x18000a.w (CPU0 shared RAM) -> 0x0804f4.w */
626   PORT_MODIFY("SYSTEM")
627   TOAPLAN_TEST_SWITCH( 0x04, IP_ACTIVE_HIGH )             /* see notes */
628
629   /* VBLANK : 0x140000.w */
457630INPUT_PORTS_END
458631
632
633/* verified from M68000 and Z80 code */
459634static INPUT_PORTS_START( truxton )
460   TOAPLAN1_VBLANK_INPUT
635   PORT_INCLUDE( toaplan1_2b )
461636
462   PORT_START("P1")
463   TOAPLAN1_PLAYER_INPUT( 1, IPT_UNKNOWN, )
637   /* in 0x40 (CPU1) -> 0x8003 (CPU1 shared RAM) = 0x180006.w (CPU0 shared RAM) -> 0x081b78.w */
638   PORT_START("DSWA")
639   TOAPLAN_MACHINE_COCKTAIL
640   TOAPLAN_COINAGE_DUAL(TJUMP, 0x03, 0x02)                 /* see notes */
464641
465   PORT_START("P2")
466   TOAPLAN1_PLAYER_INPUT( 2, IPT_UNKNOWN, PORT_COCKTAIL )
467
468   PORT_START("DSWA")   /* DSW A */
469   PORT_DIPNAME( 0x01, 0x01, DEF_STR( Cabinet ) )
470   PORT_DIPSETTING(    0x01, DEF_STR( Upright ) )
471   PORT_DIPSETTING(    0x00, DEF_STR( Cocktail ) )
472   PORT_DIPNAME( 0x02, 0x00, DEF_STR( Flip_Screen ) )
473   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
474   PORT_DIPSETTING(    0x02, DEF_STR( On ) )
475   PORT_SERVICE( 0x04, IP_ACTIVE_HIGH )
476   PORT_DIPNAME( 0x08, 0x00, DEF_STR( Demo_Sounds ) )
477   PORT_DIPSETTING(    0x08, DEF_STR( Off ) )
478   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
479/* credits per coin options change, depending on the territory setting */
480   PORT_DIPNAME( 0x30, 0x00, DEF_STR( Coin_A ) )
481   PORT_DIPSETTING(    0x20, DEF_STR( 2C_1C ) )
482   PORT_DIPSETTING(    0x00, DEF_STR( 1C_1C ) )
483   PORT_DIPSETTING(    0x30, DEF_STR( 2C_3C ) )
484   PORT_DIPSETTING(    0x10, DEF_STR( 1C_2C ) )
485   PORT_DIPNAME( 0xc0, 0x00, DEF_STR( Coin_B ) )
486   PORT_DIPSETTING(    0x80, DEF_STR( 2C_1C ) )
487   PORT_DIPSETTING(    0x00, DEF_STR( 1C_1C ) )
488   PORT_DIPSETTING(    0xc0, DEF_STR( 2C_3C ) )
489   PORT_DIPSETTING(    0x40, DEF_STR( 1C_2C ) )
490/* The following are coin settings for Japan
491    PORT_DIPNAME( 0x30, 0x00, DEF_STR( Coin_A ) )
492    PORT_DIPSETTING(    0x30, DEF_STR( 4C_1C ) )
493    PORT_DIPSETTING(    0x20, DEF_STR( 3C_1C ) )
494    PORT_DIPSETTING(    0x10, DEF_STR( 2C_1C ) )
495    PORT_DIPSETTING(    0x00, DEF_STR( 1C_1C ) )
496    PORT_DIPNAME( 0xc0, 0x00, DEF_STR( Coin_B ) )
497    PORT_DIPSETTING(    0x00, DEF_STR( 1C_2C ) )
498    PORT_DIPSETTING(    0x40, DEF_STR( 1C_3C ) )
499    PORT_DIPSETTING(    0x80, DEF_STR( 1C_4C ) )
500    PORT_DIPSETTING(    0xc0, DEF_STR( 1C_6C ) )
501*/
502
503   PORT_START("DSWB")   /* DSW B */
504   PORT_DIPNAME( 0x03, 0x00, DEF_STR( Difficulty ) )
505   PORT_DIPSETTING(    0x01, DEF_STR( Easy ) )
506   PORT_DIPSETTING(    0x00, DEF_STR( Medium ) )
507   PORT_DIPSETTING(    0x02, DEF_STR( Hard ) )
508   PORT_DIPSETTING(    0x03, DEF_STR( Hardest ) )
509   PORT_DIPNAME( 0x0c, 0x00, DEF_STR( Bonus_Life ) )
510   PORT_DIPSETTING(    0x04, "50K, every 150K" )
511   PORT_DIPSETTING(    0x00, "70K, every 200K" )
512   PORT_DIPSETTING(    0x08, "100K only" )
642   /* in 0x50 (CPU1) -> 0x8004 (CPU1 shared RAM) = 0x180008.w (CPU0 shared RAM) -> 0x081b7a.w */
643   PORT_START("DSWB")
644   TOAPLAN_DIFFICULTY
645   PORT_DIPNAME( 0x0c, 0x00, DEF_STR( Bonus_Life ) )       /* table at 0x000930 */
646   PORT_DIPSETTING(    0x04, "50k 200k 150k+" )
647   PORT_DIPSETTING(    0x00, "70k 270k 200k+" )
648   PORT_DIPSETTING(    0x08, "100k Only" )
513649   PORT_DIPSETTING(    0x0c, DEF_STR( None ) )
514650   PORT_DIPNAME( 0x30, 0x00, DEF_STR( Lives ) )
515651   PORT_DIPSETTING(    0x30, "2" )
516652   PORT_DIPSETTING(    0x00, "3" )
517653   PORT_DIPSETTING(    0x20, "4" )
518654   PORT_DIPSETTING(    0x10, "5" )
519   PORT_DIPNAME( 0x40, 0x00, "Dip Switch Display" )
520   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
521   PORT_DIPSETTING(    0x40, DEF_STR( On ) )
655   PORT_DIPNAME( 0x40, 0x00, "Show Dip Switches Settings" )
656   PORT_DIPSETTING(   0x00, DEF_STR( No ) )
657   PORT_DIPSETTING(   0x40, DEF_STR( Yes ) )
522658   PORT_DIPNAME( 0x80, 0x00, DEF_STR( Allow_Continue ) )
523659   PORT_DIPSETTING(    0x80, DEF_STR( No ) )
524660   PORT_DIPSETTING(    0x00, DEF_STR( Yes ) )
525661
526   TOAPLAN1_SYSTEM_INPUTS
662   /* in 0x70 (CPU1) -> 0x8005 (CPU1 shared RAM) = 0x18000a.w (CPU0 shared RAM) -> 0x081b7c.w */
663   PORT_START("TJUMP")       /* Territory Jumper Block - see notes */
664   PORT_DIPNAME( 0x07, 0x02, "Territory/Copyright" )
665   PORT_DIPSETTING(    0x02, "Europe/Taito Corp" )         /* TOAPLAN_COINAGE_WORLD */
666//  PORT_DIPSETTING(    0x03, "Europe/Taito Corp" )         /* TOAPLAN_COINAGE_JAPAN_OLD */
667//  PORT_DIPSETTING(    0x06, "Europe/Taito America" )      /* TOAPLAN_COINAGE_WORLD */
668//  PORT_DIPSETTING(    0x07, "Europe/Taito America" )      /* TOAPLAN_COINAGE_JAPAN_OLD */
669   PORT_DIPSETTING(    0x04, "USA/Taito America" )         /* TOAPLAN_COINAGE_JAPAN_OLD */
670//  PORT_DIPSETTING(    0x05, "USA/Taito America" )         /* TOAPLAN_COINAGE_JAPAN_OLD */
671   PORT_DIPSETTING(    0x01, "USA/Taito America (Romstar)" )/*TOAPLAN_COINAGE_JAPAN_OLD */
672   PORT_DIPSETTING(    0x00, "Japan/Taito Corp" )          /* TOAPLAN_COINAGE_JAPAN_OLD */
673   PORT_DIPUNUSED( 0x08, IP_ACTIVE_HIGH )
674   PORT_BIT( 0xf0, IP_ACTIVE_HIGH, IPT_UNUSED )
527675
528   PORT_START("TJUMP")   /* Territory Jumper Block */
529   PORT_DIPNAME( 0x07, 0x02, "Territory/Copyright" )
530   PORT_DIPSETTING(    0x02, "World/Taito Corp" )
531   PORT_DIPSETTING(    0x06, "World/Taito America" )
532   PORT_DIPSETTING(    0x04, "US/Taito America" )
533   PORT_DIPSETTING(    0x01, "US/Romstar" )
534   PORT_DIPSETTING(    0x00, "Japan/Taito Corp" )
535//  PORT_DIPSETTING(    0x05, "Same as 0x04" )
536//  PORT_DIPSETTING(    0x03, "Same as 0x02" )
537//  PORT_DIPSETTING(    0x07, "Same as 0x06" )
538   PORT_DIPNAME( 0x08, 0x00, DEF_STR( Unused ) )
539   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
540   PORT_DIPSETTING(    0x08, DEF_STR( On ) )
541   PORT_BIT( 0xf0, IP_ACTIVE_HIGH, IPT_UNKNOWN )
676   /* P1 : in 0x00 (CPU1) -> 0x8007 (CPU1 shared RAM) = 0x18000e.w (CPU0 shared RAM) -> 0x081b82.w */
677   /* P2 : in 0x10 (CPU1) -> 0x8008 (CPU1 shared RAM) = 0x180010.w (CPU0 shared RAM) -> 0x081b84.w */
678
679   /* SYSTEM : in 0x20 (CPU1) -> 0x8006 (CPU1 shared RAM) = 0x18000c.w (CPU0 shared RAM) -> 0x081b7e.w */
680
681   /* VBLANK : 0x140000.w */
542682INPUT_PORTS_END
543683
684
544685static INPUT_PORTS_START( hellfire )
545686   TOAPLAN1_VBLANK_INPUT
546687
r7500r7501
612753   PORT_BIT( 0xf0, IP_ACTIVE_HIGH, IPT_UNKNOWN )
613754INPUT_PORTS_END
614755
615static INPUT_PORTS_START( hellfir1 )
756static INPUT_PORTS_START( hellfire1 )
616757   PORT_INCLUDE( hellfire )
617758
618759   PORT_MODIFY("DSWA")
r7500r7501
621762   PORT_DIPSETTING(    0x00, DEF_STR( Cocktail ) )
622763INPUT_PORTS_END
623764
765
766/* verified from M68000 and Z80 code */
624767static INPUT_PORTS_START( zerowing )
625   TOAPLAN1_VBLANK_INPUT
768   PORT_INCLUDE( toaplan1_2b )
626769
627   PORT_START("P1")
628   TOAPLAN1_PLAYER_INPUT( 1, IPT_UNKNOWN, )
770   /* in 0x20 (CPU1) -> 0x8003 (CPU1 shared RAM) = 0x440006.w (CPU0 shared RAM) -> 0x08180c.w */
771   PORT_START("DSWA")
772   TOAPLAN_MACHINE_COCKTAIL
773   TOAPLAN_COINAGE_DUAL(TJUMP, 0x02, 0x02)                 /* see notes */
629774
630   PORT_START("P2")
631   TOAPLAN1_PLAYER_INPUT( 2, IPT_UNKNOWN, PORT_COCKTAIL )
632
633   PORT_START("DSWA")      /* DSW A */
634   PORT_DIPNAME( 0x01, 0x01, DEF_STR( Cabinet ) )
635   PORT_DIPSETTING(    0x01, DEF_STR( Upright ) )
636   PORT_DIPSETTING(    0x00, DEF_STR( Cocktail ) )
637   PORT_DIPNAME( 0x02, 0x00, DEF_STR( Flip_Screen ) )
638   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
639   PORT_DIPSETTING(    0x02, DEF_STR( On ) )
640   PORT_SERVICE( 0x04, IP_ACTIVE_HIGH )
641   PORT_DIPNAME( 0x08, 0x00, DEF_STR( Demo_Sounds ) )
642   PORT_DIPSETTING(    0x08, DEF_STR( Off ) )
643   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
644   PORT_DIPNAME( 0x30, 0x00, DEF_STR( Coin_A ) )
645   PORT_DIPSETTING(    0x30, DEF_STR( 4C_1C ) )
646   PORT_DIPSETTING(    0x20, DEF_STR( 3C_1C ) )
647   PORT_DIPSETTING(    0x10, DEF_STR( 2C_1C ) )
648   PORT_DIPSETTING(    0x00, DEF_STR( 1C_1C ) )
649   PORT_DIPNAME( 0xc0, 0x00, DEF_STR( Coin_B ) )
650   PORT_DIPSETTING(    0x00, DEF_STR( 1C_2C ) )
651   PORT_DIPSETTING(    0x40, DEF_STR( 1C_3C ) )
652   PORT_DIPSETTING(    0x80, DEF_STR( 1C_4C ) )
653   PORT_DIPSETTING(    0xc0, DEF_STR( 1C_6C ) )
654
655   PORT_START("DSWB")      /* DSW B */
656   PORT_DIPNAME( 0x03, 0x00, DEF_STR( Difficulty ) )
657   PORT_DIPSETTING(    0x01, DEF_STR( Easy ) )
658   PORT_DIPSETTING(    0x00, DEF_STR( Medium ) )
659   PORT_DIPSETTING(    0x02, DEF_STR( Hard ) )
660   PORT_DIPSETTING(    0x03, DEF_STR( Hardest ) )
661   PORT_DIPNAME( 0x0c, 0x00, DEF_STR( Bonus_Life ) )
662   PORT_DIPSETTING(    0x00, "200K, every 500K" )
663   PORT_DIPSETTING(    0x04, "500K, every 1M" )
664   PORT_DIPSETTING(    0x08, "500K" )
775   /* in 0x28 (CPU1) -> 0x8004 (CPU1 shared RAM) = 0x440008.w (CPU0 shared RAM) -> 0x08180e.w */
776   PORT_START("DSWB")
777   TOAPLAN_DIFFICULTY
778   PORT_DIPNAME( 0x0c, 0x00, DEF_STR( Bonus_Life ) )       /* table at 0x00216c ('zerowing') or 0x002606 ('zerowing2') */
779   PORT_DIPSETTING(    0x00, "200k 700k 500k+" )
780   PORT_DIPSETTING(    0x04, "500k 1500k 1000k+" )
781   PORT_DIPSETTING(    0x08, "500k Only" )
665782   PORT_DIPSETTING(    0x0c, DEF_STR( None ) )
666783   PORT_DIPNAME( 0x30, 0x00, DEF_STR( Lives ) )
667784   PORT_DIPSETTING(    0x30, "2" )
r7500r7501
675792   PORT_DIPSETTING(    0x80, DEF_STR( No ) )
676793   PORT_DIPSETTING(    0x00, DEF_STR( Yes ) )
677794
678   TOAPLAN1_SYSTEM_INPUTS
795   /* in 0x88 (CPU1) -> 0x8005 (CPU1 shared RAM) = 0x44000a.w (CPU0 shared RAM) -> 0x081810.w */
796   PORT_START("TJUMP")       /* Territory Jumper Block - see notes */
797   PORT_DIPNAME( 0x03, 0x03, "Territory" )
798   PORT_DIPSETTING(    0x03, DEF_STR( Europe ) )           /* 3 letters initials - right */
799//  PORT_DIPSETTING(    0x02, DEF_STR( Europe ) )           /* 6 letters initials - wrong */
800   PORT_DIPSETTING(    0x01, DEF_STR( USA ) )
801   PORT_DIPSETTING(    0x00, DEF_STR( Japan ) )
802   PORT_DIPUNUSED( 0x04, IP_ACTIVE_HIGH )
803   PORT_DIPUNUSED( 0x08, IP_ACTIVE_HIGH )
804   PORT_BIT( 0xf0, IP_ACTIVE_HIGH, IPT_UNUSED )
679805
680   PORT_START("TJUMP")      /* Territory Jumper block */
681   PORT_DIPNAME( 0x03, 0x02, "Territory" )
682   PORT_DIPSETTING(    0x02, DEF_STR( Europe ) )
683//  PORT_DIPSETTING(    0x03, DEF_STR( Europe ) )
684   PORT_DIPSETTING(    0x01, "US" )
685   PORT_DIPSETTING(    0x00, DEF_STR( Japan ) )
686   PORT_DIPNAME( 0x04, 0x00, DEF_STR( Unused ) )
687   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
688   PORT_DIPSETTING(    0x04, DEF_STR( On ) )
689   PORT_DIPNAME( 0x08, 0x00, DEF_STR( Unused ) )
690   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
691   PORT_DIPSETTING(    0x08, DEF_STR( On ) )
692   PORT_BIT( 0xf0, IP_ACTIVE_HIGH, IPT_UNKNOWN )
806   /* P1 : in 0x00 (CPU1) -> 0x8007 (CPU1 shared RAM) = 0x44000e.w (CPU0 shared RAM) -> 0x081818.w */
807   /* P2 : in 0x08 (CPU1) -> 0x8008 (CPU1 shared RAM) = 0x440010.w (CPU0 shared RAM) -> 0x08181a.w */
808
809   /* SYSTEM : in 0x80 (CPU1) -> 0x8006 (CPU1 shared RAM) = 0x44000c.w (CPU0 shared RAM) -> 0x081812.w */
810
811   /* VBLANK : 0x400000.w */
693812INPUT_PORTS_END
694813
695
696static INPUT_PORTS_START( zerowng2 ) /* Always shows "Williams Electronics Games, Inc" */
814/* verified from M68000 and Z80 code */
815static INPUT_PORTS_START( zerowing2 )
697816   PORT_INCLUDE( zerowing )
698817
818   /* in 0x20 (CPU1) -> 0x8003 (CPU1 shared RAM) = 0x440006.w (CPU0 shared RAM) -> 0x081ade.w */
819   PORT_MODIFY("DSWA")
820   TOAPLAN_MACHINE_NO_COCKTAIL
821
822   /* in 0x28 (CPU1) -> 0x8004 (CPU1 shared RAM) = 0x440008.w (CPU0 shared RAM) -> 0x081ae0.w */
823   PORT_MODIFY("DSWB")
824   PORT_DIPUNUSED( 0x80, IP_ACTIVE_HIGH )
825
826   /* in 0x88 (CPU1) -> 0x8005 (CPU1 shared RAM) = 0x44000a.w (CPU0 shared RAM) -> 0x081ae2.w */
699827   PORT_MODIFY("TJUMP")      /* Territory Jumper block */
700   PORT_DIPNAME( 0x01, 0x00, DEF_STR( Unused ) )
701   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
702   PORT_DIPSETTING(    0x01, DEF_STR( On ) )
828   PORT_DIPUNUSED( 0x01, IP_ACTIVE_HIGH )
703829   PORT_DIPNAME( 0x02, 0x00, DEF_STR( Region ) )
704830   PORT_DIPSETTING(    0x00, DEF_STR( USA ) )
705831   PORT_DIPSETTING(    0x02, DEF_STR( Europe ) )
832   PORT_DIPUNUSED( 0x04, IP_ACTIVE_HIGH )
833   PORT_DIPUNUSED( 0x08, IP_ACTIVE_HIGH )
834   PORT_BIT( 0xf0, IP_ACTIVE_HIGH, IPT_UNUSED )
835
836   /* P1 : in 0x00 (CPU1) -> 0x8007 (CPU1 shared RAM) = 0x44000e.w (CPU0 shared RAM) -> 0x081aea.w */
837   /* P2 : in 0x08 (CPU1) -> 0x8008 (CPU1 shared RAM) = 0x440010.w (CPU0 shared RAM) -> 0x081aec.w */
838
839   /* SYSTEM : in 0x80 (CPU1) -> 0x8006 (CPU1 shared RAM) = 0x44000c.w (CPU0 shared RAM) -> 0x081ae4.w */
840
841   /* VBLANK : 0x400000.w */
706842INPUT_PORTS_END
707843
844
708845static INPUT_PORTS_START( demonwld )
709846   TOAPLAN1_VBLANK_INPUT
710847
r7500r7501
777914   PORT_BIT( 0xf0, IP_ACTIVE_HIGH, IPT_UNKNOWN )
778915INPUT_PORTS_END
779916
780static INPUT_PORTS_START( demonwl1 )
917static INPUT_PORTS_START( demonwld1 )
781918   PORT_INCLUDE( demonwld )
782919
783920   PORT_MODIFY("TJUMP")      /* Territory Jumper Block */
r7500r7501
788925   PORT_DIPSETTING(    0x00, "Japan/Taito Corp" )
789926INPUT_PORTS_END
790927
791static INPUT_PORTS_START( samesame )
928
929static INPUT_PORTS_START( fireshrk )
792930   TOAPLAN1_VBLANK_INPUT
793931
794932   PORT_START("P1")
r7500r7501
808946   PORT_DIPNAME( 0x08, 0x00, DEF_STR( Demo_Sounds ) )
809947   PORT_DIPSETTING(    0x08, DEF_STR( Off ) )
810948   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
811   PORT_DIPNAME( 0x10, 0x00, DEF_STR( Unknown ) )
812   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
813   PORT_DIPSETTING(    0x10, DEF_STR( On ) )
814   PORT_DIPNAME( 0x20, 0x00, DEF_STR( Unknown ) )
815   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
816   PORT_DIPSETTING(    0x20, DEF_STR( On ) )
817   PORT_DIPNAME( 0x40, 0x00, DEF_STR( Unknown ) )
818   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
819   PORT_DIPSETTING(    0x40, DEF_STR( On ) )
820   PORT_DIPNAME( 0x80, 0x00, DEF_STR( Unknown ) )
821   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
822   PORT_DIPSETTING(    0x80, DEF_STR( On ) )
823/* settings listed in service mode, but not actually used ???
824    PORT_DIPNAME( 0x30, 0x00, DEF_STR( Coin_A ) )
825    PORT_DIPSETTING(    0x20, DEF_STR( 2C_1C ) )
826    PORT_DIPSETTING(    0x00, DEF_STR( 1C_1C ) )
827    PORT_DIPSETTING(    0x30, DEF_STR( 2C_3C ) )
828    PORT_DIPSETTING(    0x10, DEF_STR( 1C_2C ) )
829    PORT_DIPNAME( 0xc0, 0x00, DEF_STR( Coin_B ) )
830    PORT_DIPSETTING(    0x80, DEF_STR( 2C_1C ) )
831    PORT_DIPSETTING(    0x00, DEF_STR( 1C_1C ) )
832    PORT_DIPSETTING(    0xc0, DEF_STR( 2C_3C ) )
833    PORT_DIPSETTING(    0x40, DEF_STR( 1C_2C ) )
834*/
949   PORT_DIPNAME( 0x30, 0x00, DEF_STR( Coin_A ) )
950   PORT_DIPSETTING(    0x30, DEF_STR( 4C_1C ) )
951   PORT_DIPSETTING(    0x20, DEF_STR( 3C_1C ) )
952   PORT_DIPSETTING(    0x10, DEF_STR( 2C_1C ) )
953   PORT_DIPSETTING(    0x00, DEF_STR( 1C_1C ) )
954   PORT_DIPNAME( 0xc0, 0x00, DEF_STR( Coin_B ) )
955   PORT_DIPSETTING(    0x00, DEF_STR( 1C_2C ) )
956   PORT_DIPSETTING(    0x40, DEF_STR( 1C_3C ) )
957   PORT_DIPSETTING(    0x80, DEF_STR( 1C_4C ) )
958   PORT_DIPSETTING(    0xc0, DEF_STR( 1C_6C ) )
835959
836960   PORT_START("DSWB")      /* DSW B */
837961   PORT_DIPNAME( 0x03, 0x00, DEF_STR( Difficulty ) )
r7500r7501
859983   TOAPLAN1_SYSTEM_INPUTS
860984
861985   PORT_START("TJUMP")      /* Territory Jumper Block */
986   PORT_DIPNAME( 0x06, 0x02, "Territory" )
987   PORT_DIPSETTING(    0x02, DEF_STR( Europe ) )
988   PORT_DIPSETTING(    0x04, DEF_STR( USA ) )
989   PORT_DIPSETTING(    0x00, "USA (Romstar)" )
990   PORT_BIT( 0xf0, IP_ACTIVE_HIGH, IPT_UNKNOWN )
991INPUT_PORTS_END
992
993static INPUT_PORTS_START( samesame )
994   PORT_INCLUDE( fireshrk )
995
996   PORT_MODIFY("DSWA")      /* DSW A */
997   PORT_DIPNAME( 0x10, 0x00, DEF_STR( Unknown ) )
998   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
999   PORT_DIPSETTING(    0x10, DEF_STR( On ) )
1000   PORT_DIPNAME( 0x20, 0x00, DEF_STR( Unknown ) )
1001   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
1002   PORT_DIPSETTING(    0x20, DEF_STR( On ) )
1003   PORT_DIPNAME( 0x40, 0x00, DEF_STR( Unknown ) )
1004   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
1005   PORT_DIPSETTING(    0x40, DEF_STR( On ) )
1006   PORT_DIPNAME( 0x80, 0x00, DEF_STR( Unknown ) )
1007   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
1008   PORT_DIPSETTING(    0x80, DEF_STR( On ) )
1009/* settings listed in service mode, but not actually used ???
1010    PORT_DIPNAME( 0x30, 0x00, DEF_STR( Coin_A ) )
1011    PORT_DIPSETTING(    0x20, DEF_STR( 2C_1C ) )
1012    PORT_DIPSETTING(    0x00, DEF_STR( 1C_1C ) )
1013    PORT_DIPSETTING(    0x30, DEF_STR( 2C_3C ) )
1014    PORT_DIPSETTING(    0x10, DEF_STR( 1C_2C ) )
1015    PORT_DIPNAME( 0xc0, 0x00, DEF_STR( Coin_B ) )
1016    PORT_DIPSETTING(    0x80, DEF_STR( 2C_1C ) )
1017    PORT_DIPSETTING(    0x00, DEF_STR( 1C_1C ) )
1018    PORT_DIPSETTING(    0xc0, DEF_STR( 2C_3C ) )
1019    PORT_DIPSETTING(    0x40, DEF_STR( 1C_2C ) )
1020*/
1021
1022   PORT_MODIFY("TJUMP")      /* Territory Jumper Block */
8621023   PORT_DIPNAME( 0x01, 0x00, DEF_STR( Unknown ) )
8631024   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
8641025   PORT_DIPSETTING(    0x01, DEF_STR( On ) )
r7500r7501
8741035   PORT_BIT( 0xf0, IP_ACTIVE_HIGH, IPT_UNKNOWN )
8751036INPUT_PORTS_END
8761037
877static INPUT_PORTS_START( samesam2 )
1038static INPUT_PORTS_START( samesame2 )
8781039   PORT_INCLUDE( samesame )
8791040
8801041   PORT_MODIFY("TJUMP")      /* Territory Jumper Block */
r7500r7501
8941055   PORT_BIT( 0xf2, IP_ACTIVE_HIGH, IPT_UNKNOWN )   /* Mask bit 2 aswell */
8951056INPUT_PORTS_END
8961057
897static INPUT_PORTS_START( fireshrk )
898   PORT_INCLUDE( samesame )
8991058
900   PORT_MODIFY("DSWA")      /* DSW A */
901   PORT_DIPNAME( 0x30, 0x00, DEF_STR( Coin_A ) )
902   PORT_DIPSETTING(    0x30, DEF_STR( 4C_1C ) )
903   PORT_DIPSETTING(    0x20, DEF_STR( 3C_1C ) )
904   PORT_DIPSETTING(    0x10, DEF_STR( 2C_1C ) )
905   PORT_DIPSETTING(    0x00, DEF_STR( 1C_1C ) )
906   PORT_DIPNAME( 0xc0, 0x00, DEF_STR( Coin_B ) )
907   PORT_DIPSETTING(    0x00, DEF_STR( 1C_2C ) )
908   PORT_DIPSETTING(    0x40, DEF_STR( 1C_3C ) )
909   PORT_DIPSETTING(    0x80, DEF_STR( 1C_4C ) )
910   PORT_DIPSETTING(    0xc0, DEF_STR( 1C_6C ) )
911
912   PORT_MODIFY("TJUMP")      /* Territory Jumper Block */
913   PORT_DIPNAME( 0x06, 0x02, "Territory" )
914   PORT_DIPSETTING(    0x02, DEF_STR( Europe ) )
915   PORT_DIPSETTING(    0x04, DEF_STR( USA ) )
916   PORT_DIPSETTING(    0x00, "USA (Romstar)" )
917INPUT_PORTS_END
918
919
9201059static INPUT_PORTS_START( outzone )
9211060   TOAPLAN1_VBLANK_INPUT
9221061
r7500r7501
22842423
22852424
22862425
2287GAME( 1988, rallybik, 0,        rallybik, rallybik, toaplan1, ROT270, "[Toaplan] Taito Corporation", "Rally Bike / Dash Yarou", 0 )
2288GAME( 1988, truxton,  0,        truxton,  truxton,  toaplan1, ROT270, "[Toaplan] Taito Corporation", "Truxton / Tatsujin", 0 )
2289GAME( 1989, hellfire, 0,        hellfire, hellfire, toaplan1, ROT0,   "Toaplan (Taito license)", "Hellfire (2P Ver.)", 0 )
2290GAME( 1989, hellfire1,hellfire, hellfire, hellfir1, toaplan1, ROT0,   "Toaplan (Taito license)", "Hellfire (1P Ver.)", 0 )
2291GAME( 1989, hellfire2,hellfire, hellfire, hellfire, toaplan1, ROT0,   "Toaplan (Taito license)", "Hellfire (2P Ver., first edition)", 0 )
2292GAME( 1989, hellfire3,hellfire, hellfire, hellfire, toaplan1, ROT0,   "Toaplan (Taito license)", "Hellfire (1P Ver., alt)", 0 )
2293GAME( 1989, zerowing, 0,        zerowing, zerowing, toaplan1, ROT0,   "Toaplan", "Zero Wing", 0 )
2294GAME( 1989, zerowing2,zerowing, zerowing, zerowng2, toaplan1, ROT0,   "[Toaplan] Williams Electronics Games, Inc", "Zero Wing (2 player simultaneous ver.)", 0 )
2295GAME( 1990, demonwld, 0,        demonwld, demonwld, demonwld, ROT0,   "Toaplan", "Demon's World / Horror Story (set 1)", 0 )
2296GAME( 1989, demonwld1,demonwld, demonwld, demonwl1, demonwld, ROT0,   "Toaplan", "Demon's World / Horror Story (Taito license, set 2)", 0 )
2297GAME( 1989, demonwld2,demonwld, demonwld, demonwl1, demonwld, ROT0,   "Toaplan", "Demon's World / Horror Story (set 3)", 0 )
2298GAME( 1989, demonwld3,demonwld, demonwld, demonwl1, demonwld, ROT0,   "Toaplan", "Demon's World / Horror Story (set 4)", 0 )
2299GAME( 1989, demonwld4,demonwld, demonwld, demonwl1, demonwld, ROT0,   "Toaplan", "Demon's World / Horror Story (set 5)", 0 )
2300GAME( 1990, fireshrk, 0,        samesame, fireshrk, toaplan1, ROT270, "Toaplan", "Fire Shark", GAME_NO_SOUND )
2301GAME( 1990, fireshrkd,  fireshrk, samesame, samesam2, toaplan1, ROT270, "Toaplan (Dooyong license)", "Fire Shark (Korea, set 1, easier)", GAME_NO_SOUND )
2302GAME( 1990, fireshrkdh, fireshrk, samesame, samesam2, toaplan1, ROT270, "Toaplan (Dooyong license)", "Fire Shark (Korea, set 2, harder)", GAME_NO_SOUND )
2303GAME( 1989, samesame, fireshrk, samesame, samesame, toaplan1, ROT270, "Toaplan", "Same! Same! Same! (2 player alternating ver.)", GAME_NO_SOUND )
2304GAME( 1989, samesame2,fireshrk, samesame, samesam2, toaplan1, ROT270, "Toaplan", "Same! Same! Same!", GAME_NO_SOUND )
2305GAME( 1990, outzone,  0,        outzone,  outzone,  toaplan1, ROT270, "Toaplan", "Out Zone (set 1)", 0 ) // later fixed version
2306GAME( 1990, outzonea, outzone,  outzone,  outzone,  toaplan1, ROT270, "Toaplan", "Out Zone (set 2)", 0 )
2307GAME( 1990, outzoneb, outzone,  outzone,  outzoneb, toaplan1, ROT270, "Toaplan", "Out Zone (set 3, prototype?)", 0 ) // early revision at least
2308GAME( 1990, outzonec, outzone,  outzone,  outzonec, toaplan1, ROT270, "Toaplan", "Out Zone (set 4)", 0 )
2309GAME( 1990, outzoned, outzone,  outzone,  outzonec, toaplan1, ROT270, "Toaplan", "Out Zone (set 5)", 0 )
2310GAME( 1991, vimana,   0,        vimana,   vimana,   vimana,   ROT270, "Toaplan", "Vimana", GAME_NO_SOUND )
2311GAME( 1991, vimana1,  vimana,   vimana,   vimana,   vimana,   ROT270, "Toaplan", "Vimana (old set)", GAME_NO_SOUND )
2312GAME( 1991, vimanan,  vimana,   vimana,   vimanan,  vimana,   ROT270, "Toaplan (Nova Apparate GMBH & Co license)", "Vimana (Nova Apparate GMBH & Co)", GAME_NO_SOUND )
2426GAME( 1988, rallybik,   0,        rallybik, rallybik,  toaplan1, ROT270, "[Toaplan] Taito Corporation", "Rally Bike / Dash Yarou", GAME_NO_COCKTAIL )
2427GAME( 1988, truxton,    0,        truxton,  truxton,   toaplan1, ROT270, "[Toaplan] Taito Corporation", "Truxton / Tatsujin", GAME_NO_COCKTAIL )
2428GAME( 1989, hellfire,   0,        hellfire, hellfire,  toaplan1, ROT0,   "Toaplan (Taito license)", "Hellfire (2P Ver.)", 0 )
2429GAME( 1989, hellfire1,  hellfire, hellfire, hellfire1, toaplan1, ROT0,   "Toaplan (Taito license)", "Hellfire (1P Ver.)", 0 )
2430GAME( 1989, hellfire2,  hellfire, hellfire, hellfire,  toaplan1, ROT0,   "Toaplan (Taito license)", "Hellfire (2P Ver., first edition)", 0 )
2431GAME( 1989, hellfire3,  hellfire, hellfire, hellfire,  toaplan1, ROT0,   "Toaplan (Taito license)", "Hellfire (1P Ver., alt)", 0 )
2432GAME( 1989, zerowing,   0,        zerowing, zerowing,  toaplan1, ROT0,   "Toaplan", "Zero Wing (single players)", GAME_NO_COCKTAIL )
2433GAME( 1989, zerowing2,  zerowing, zerowing, zerowing2, toaplan1, ROT0,   "[Toaplan] Williams Electronics Games, Inc", "Zero Wing (dual players)", GAME_NO_COCKTAIL )
2434GAME( 1990, demonwld,   0,        demonwld, demonwld,  demonwld, ROT0,   "Toaplan", "Demon's World / Horror Story (set 1)", 0 )
2435GAME( 1989, demonwld1,  demonwld, demonwld, demonwld1, demonwld, ROT0,   "Toaplan", "Demon's World / Horror Story (Taito license, set 2)", 0 )
2436GAME( 1989, demonwld2,  demonwld, demonwld, demonwld1, demonwld, ROT0,   "Toaplan", "Demon's World / Horror Story (set 3)", 0 )
2437GAME( 1989, demonwld3,  demonwld, demonwld, demonwld1, demonwld, ROT0,   "Toaplan", "Demon's World / Horror Story (set 4)", 0 )
2438GAME( 1989, demonwld4,  demonwld, demonwld, demonwld1, demonwld, ROT0,   "Toaplan", "Demon's World / Horror Story (set 5)", 0 )
2439GAME( 1990, fireshrk,   0,        samesame, fireshrk,  toaplan1, ROT270, "Toaplan", "Fire Shark", GAME_NO_SOUND )
2440GAME( 1990, fireshrkd,  fireshrk, samesame, samesame2, toaplan1, ROT270, "Toaplan (Dooyong license)", "Fire Shark (Korea, set 1, easier)", GAME_NO_SOUND )
2441GAME( 1990, fireshrkdh, fireshrk, samesame, samesame2, toaplan1, ROT270, "Toaplan (Dooyong license)", "Fire Shark (Korea, set 2, harder)", GAME_NO_SOUND )
2442GAME( 1989, samesame,   fireshrk, samesame, samesame,  toaplan1, ROT270, "Toaplan", "Same! Same! Same! (2 player alternating ver.)", GAME_NO_SOUND )
2443GAME( 1989, samesame2,  fireshrk, samesame, samesame2, toaplan1, ROT270, "Toaplan", "Same! Same! Same!", GAME_NO_SOUND )
2444GAME( 1990, outzone,    0,        outzone,  outzone,   toaplan1, ROT270, "Toaplan", "Out Zone (set 1)", 0 ) // later fixed version
2445GAME( 1990, outzonea,   outzone,  outzone,  outzone,   toaplan1, ROT270, "Toaplan", "Out Zone (set 2)", 0 )
2446GAME( 1990, outzoneb,   outzone,  outzone,  outzoneb,  toaplan1, ROT270, "Toaplan", "Out Zone (set 3, prototype?)", 0 ) // early revision at least
2447GAME( 1990, outzonec,   outzone,  outzone,  outzonec,  toaplan1, ROT270, "Toaplan", "Out Zone (set 4)", 0 )
2448GAME( 1990, outzoned,   outzone,  outzone,  outzonec,  toaplan1, ROT270, "Toaplan", "Out Zone (set 5)", 0 )
2449GAME( 1991, vimana,     0,        vimana,   vimana,    vimana,   ROT270, "Toaplan", "Vimana", GAME_NO_SOUND )
2450GAME( 1991, vimana1,    vimana,   vimana,   vimana,    vimana,   ROT270, "Toaplan", "Vimana (old set)", GAME_NO_SOUND )
2451GAME( 1991, vimanan,    vimana,   vimana,   vimanan,   vimana,   ROT270, "Toaplan (Nova Apparate GMBH & Co license)", "Vimana (Nova Apparate GMBH & Co)", GAME_NO_SOUND )
src/mame/drivers/mogura.c
r7500r7501
55#include "sound/dac.h"
66#include "includes/konamipt.h"
77
8static UINT8 *mogura_tileram;
9static UINT8* mogura_gfxram;
10static tilemap_t *mogura_tilemap;
8class mogura_state
9{
10public:
11   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, mogura_state(machine)); }
1112
13   mogura_state(running_machine &machine) { }
14
15   /* memory pointers */
16   UINT8 *   tileram;
17   UINT8 *   gfxram;
18
19   /* video-related */
20   tilemap_t *tilemap;
21
22   /* devices */
23   running_device *maincpu;
24   running_device *dac1;
25   running_device *dac2;
26};
27
28
1229static PALETTE_INIT( mogura )
1330{
14   int i,j;
31   int i, j;
1532
1633   j = 0;
17   for (i = 0;i < 0x20;i++)
34   for (i = 0; i < 0x20; i++)
1835   {
19      int bit0,bit1,bit2,r,g,b;
36      int bit0, bit1, bit2, r, g, b;
2037
2138      /* red component */
22      bit0 = (color_prom[i] >> 0) & 0x01;
23      bit1 = (color_prom[i] >> 1) & 0x01;
24      bit2 = (color_prom[i] >> 2) & 0x01;
39      bit0 = BIT(color_prom[i], 0);
40      bit1 = BIT(color_prom[i], 1);
41      bit2 = BIT(color_prom[i], 2);
2542      r = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2;
2643      /* green component */
27      bit0 = (color_prom[i] >> 3) & 0x01;
28      bit1 = (color_prom[i] >> 4) & 0x01;
29      bit2 = (color_prom[i] >> 5) & 0x01;
44      bit0 = BIT(color_prom[i], 3);
45      bit1 = BIT(color_prom[i], 4);
46      bit2 = BIT(color_prom[i], 5);
3047      g = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2;
3148      /* blue component */
3249      bit0 = 0;
33      bit1 = (color_prom[i] >> 6) & 0x01;
34      bit2 = (color_prom[i] >> 7) & 0x01;
50      bit1 = BIT(color_prom[i], 6);
51      bit2 = BIT(color_prom[i], 7);
3552      b = 0x21 * bit0 + 0x47 * bit1 + 0x97 * bit2;
3653
37      palette_set_color(machine,j,MAKE_RGB(r,g,b));
38      j+=4;
39      if (j>31) j-=31;
54      palette_set_color(machine, j, MAKE_RGB(r, g, b));
55      j += 4;
56      if (j > 31) j -= 31;
4057   }
4158}
4259
4360
4461static TILE_GET_INFO( get_mogura_tile_info )
4562{
46   int code = mogura_tileram[tile_index];
47   int attr = mogura_tileram[tile_index+0x800];
63   mogura_state *state = (mogura_state *)machine->driver_data;
64   int code = state->tileram[tile_index];
65   int attr = state->tileram[tile_index + 0x800];
4866
4967   SET_TILE_INFO(
5068         0,
5169         code,
52         (attr>>1)&7,
70         (attr >> 1) & 7,
5371         0);
5472}
5573
5674
5775static VIDEO_START( mogura )
5876{
59   gfx_element_set_source(machine->gfx[0], mogura_gfxram);
60   mogura_tilemap = tilemap_create(machine, get_mogura_tile_info,tilemap_scan_rows,8,8,64, 32);
77   mogura_state *state = (mogura_state *)machine->driver_data;
78   gfx_element_set_source(machine->gfx[0], state->gfxram);
79   state->tilemap = tilemap_create(machine, get_mogura_tile_info, tilemap_scan_rows, 8, 8, 64, 32);
6180}
6281
6382static VIDEO_UPDATE( mogura )
6483{
84   mogura_state *state = (mogura_state *)screen->machine->driver_data;
6585   const rectangle *visarea = video_screen_get_visible_area(screen);
6686
6787   /* tilemap layout is a bit strange ... */
6888   rectangle clip;
6989   clip.min_x = visarea->min_x;
70   clip.max_x = 256-1;
90   clip.max_x = 256 - 1;
7191   clip.min_y = visarea->min_y;
7292   clip.max_y = visarea->max_y;
73   tilemap_set_scrollx(mogura_tilemap,0, 256);
74   tilemap_draw(bitmap,&clip,mogura_tilemap,0,0);
93   tilemap_set_scrollx(state->tilemap, 0, 256);
94   tilemap_draw(bitmap, &clip, state->tilemap, 0, 0);
7595
7696   clip.min_x = 256;
77   clip.max_x = 512-1;
97   clip.max_x = 512 - 1;
7898   clip.min_y = visarea->min_y;
7999   clip.max_y = visarea->max_y;
80   tilemap_set_scrollx(mogura_tilemap,0, -128);
81   tilemap_draw(bitmap,&clip,mogura_tilemap,0,0);
100   tilemap_set_scrollx(state->tilemap, 0, -128);
101   tilemap_draw(bitmap, &clip, state->tilemap, 0, 0);
82102
83103   return 0;
84104}
85105
86106static WRITE8_HANDLER( mogura_tileram_w )
87107{
88   mogura_tileram[offset] = data;
89   tilemap_mark_tile_dirty(mogura_tilemap,offset&0x7ff);
108   mogura_state *state = (mogura_state *)space->machine->driver_data;
109   state->tileram[offset] = data;
110   tilemap_mark_tile_dirty(state->tilemap, offset & 0x7ff);
90111}
91112
92113static WRITE8_HANDLER(mogura_dac_w)
93114{
94   dac_data_w(devtag_get_device(space->machine, "dac1"), data & 0xf0 );   /* left */
95   dac_data_w(devtag_get_device(space->machine, "dac2"), (data & 0x0f)<<4 );   /* right */
115   mogura_state *state = (mogura_state *)space->machine->driver_data;
116   dac_data_w(state->dac1, data & 0xf0);   /* left */
117   dac_data_w(state->dac2, (data & 0x0f) << 4);   /* right */
96118}
97119
98120
99
100
101121static WRITE8_HANDLER ( mogura_gfxram_w )
102122{
103   mogura_gfxram[offset] = data ;
123   mogura_state *state = (mogura_state *)space->machine->driver_data;
124   state->gfxram[offset] = data ;
104125
105   gfx_element_mark_dirty(space->machine->gfx[0], offset/16);
126   gfx_element_mark_dirty(space->machine->gfx[0], offset / 16);
106127}
107128
108129
109130static ADDRESS_MAP_START( mogura_map, ADDRESS_SPACE_PROGRAM, 8 )
110131   AM_RANGE(0x0000, 0x7fff) AM_ROM
111132   AM_RANGE(0xc000, 0xdfff) AM_RAM // main ram
112   AM_RANGE(0xe000, 0xefff) AM_RAM_WRITE(mogura_gfxram_w) AM_BASE(&mogura_gfxram) // ram based characters
113   AM_RANGE(0xf000, 0xffff) AM_RAM_WRITE(mogura_tileram_w) AM_BASE(&mogura_tileram) // tilemap
133   AM_RANGE(0xe000, 0xefff) AM_RAM_WRITE(mogura_gfxram_w) AM_BASE_MEMBER(mogura_state, gfxram) // ram based characters
134   AM_RANGE(0xf000, 0xffff) AM_RAM_WRITE(mogura_tileram_w) AM_BASE_MEMBER(mogura_state, tileram) // tilemap
114135ADDRESS_MAP_END
115136
116137static ADDRESS_MAP_START( mogura_io_map, ADDRESS_SPACE_IO, 8 )
r7500r7501
170191   GFXDECODE_ENTRY( NULL, 0, tiles8x8_layout, 0, 8 )
171192GFXDECODE_END
172193
194static MACHINE_START( mogura )
195{
196   mogura_state *state = (mogura_state *)machine->driver_data;
197
198   state->maincpu = devtag_get_device(machine, "maincpu");
199   state->dac1 = devtag_get_device(machine, "dac1");
200   state->dac2 = devtag_get_device(machine, "dac2");
201}
202
173203static MACHINE_DRIVER_START( mogura )
204
205   /* driver data */
206   MDRV_DRIVER_DATA(mogura_state)
207
174208   /* basic machine hardware */
175209   MDRV_CPU_ADD("maincpu", Z80,3000000)       /* 3 MHz */
176210   MDRV_CPU_PROGRAM_MAP(mogura_map)
177211   MDRV_CPU_IO_MAP(mogura_io_map)
178212   MDRV_CPU_VBLANK_INT("screen", irq0_line_hold)
179213
214   MDRV_MACHINE_START(mogura)
215
180216   MDRV_GFXDECODE(mogura)
181217
182218   /* video hardware */
r7500r7501
211247   ROM_LOAD( "gx141.7j", 0x00, 0x20,  CRC(b21c5d5f) SHA1(6913c840dd69a7d4687f4c4cbe3ff12300f62bc2) )
212248ROM_END
213249
214GAME( 1991, mogura, 0, mogura, mogura, 0, ROT0, "Konami", "Mogura Desse (Japan)", 0 )
250GAME( 1991, mogura, 0, mogura, mogura, 0, ROT0, "Konami", "Mogura Desse (Japan)", GAME_SUPPORTS_SAVE )
src/mame/drivers/ddealer.c
r7500r7501
113113#include "cpu/m68000/m68000.h"
114114#include "sound/2203intf.h"
115115
116typedef struct _ddealer_state ddealer_state;
117struct _ddealer_state
116class ddealer_state
118117{
118public:
119   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, ddealer_state(machine)); }
120
121   ddealer_state(running_machine &machine) { }
122
119123   /* memory pointers */
120124   UINT16 *  mcu_shared_ram;
121125   UINT16 *  work_ram;
src/mame/drivers/dacholer.c
r7500r7501
2424#include "sound/ay8910.h"
2525
2626
27typedef struct _dacholer_state dacholer_state;
28struct _dacholer_state
27class dacholer_state
2928{
29public:
30   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, dacholer_state(machine)); }
31
32   dacholer_state(running_machine &machine) { }
33
3034   /* memory pointers */
3135   UINT8 *  bgvideoram;
3236   UINT8 *  fgvideoram;
src/mame/drivers/model3.c
r7500r7501
46064606   ROM_FILL( 0x000000, 0x80000, 0 )
46074607ROM_END
46084608
4609ROM_START( oceanhun )   /* Step 2.0   317-0244-COM security chip (837-13666-com security board) */
4610   ROM_REGION64_BE( 0x4800000, "user1", 0 ) /* program + data ROMs */
4611   // CROM
4612   ROM_LOAD64_WORD_SWAP( "epr21114.17", 0x000006, 0x200000, CRC(3adfcb9d) SHA1(22307e36a48e59ab881d6df2fbf2864f6a8b239c) )
4613   ROM_LOAD64_WORD_SWAP( "epr21115.18", 0x000004, 0x200000, CRC(0bb9c107) SHA1(9778b9d020669a5f5736c80e77f0fb1c7d0e1f1b) )
4614   ROM_LOAD64_WORD_SWAP( "epr21116.19", 0x000002, 0x200000, CRC(69e31e85) SHA1(0dbba531fd9a7e0ca7ca9d25d8be41050e809cf7) )
4615   ROM_LOAD64_WORD_SWAP( "epr21117.20", 0x000000, 0x200000, CRC(58d985f1) SHA1(1a3376906212a8a3bfb196ea29b5e4455a30e8f2) )
46094616
4617   // CROM1
4618   ROM_LOAD64_WORD_SWAP( "mpr21082.5",  0x1800006, 0x400000, CRC(5bfeaa64) SHA1(3aa9f0b10c17e999dc917e3ff888887f42c54d31) )
4619   ROM_LOAD64_WORD_SWAP( "mpr21083.6",  0x1800004, 0x400000, CRC(667e236f) SHA1(a3354a72ba3f535cbe54af592eafda1a9816a6e6) )
4620   ROM_LOAD64_WORD_SWAP( "mpr21084.7",  0x1800002, 0x400000, CRC(36d5c4c1) SHA1(827590934023313e006330c66fe69763559effae) )
4621   ROM_LOAD64_WORD_SWAP( "mpr21085.8",  0x1800000, 0x400000, CRC(8d62406a) SHA1(d8be8a7bf6f8c48c07a5532f772101888e65f9d4) )
4622
4623   // CROM2
4624   ROM_LOAD64_WORD_SWAP( "mpr21086.9",  0x2800006, 0x400000, CRC(1e704e51) SHA1(970f19521aea6802276f46a20b39d23f23e09b84) )
4625   ROM_LOAD64_WORD_SWAP( "mpr21087.10", 0x2800004, 0x400000, CRC(5db59035) SHA1(6e511e1819a48ca4d437587f3c9a14dc530352fe) )
4626   ROM_LOAD64_WORD_SWAP( "mpr21088.11", 0x2800002, 0x400000, CRC(7730742b) SHA1(267444812a07ff4cf69da8545d4a7a2de1a3ba29) )
4627   ROM_LOAD64_WORD_SWAP( "mpr21089.12", 0x2800000, 0x400000, CRC(a74d2dcb) SHA1(449a188a7e5a21e2b51748cf7ceae84e2e3beab4) )
4628
4629   // CROM3
4630   ROM_LOAD64_WORD_SWAP( "mpr21090.13", 0x3800006, 0x400000, CRC(7a95c388) SHA1(9a0f8b4e3bf0670d4f838a6fb18f29f5e1b3721b) )
4631   ROM_LOAD64_WORD_SWAP( "mpr21091.14", 0x3800004, 0x400000, CRC(4031b961) SHA1(0c663171f15dea67709e7ffc3f45b7571e745232) )
4632   ROM_LOAD64_WORD_SWAP( "mpr21092.15", 0x3800002, 0x400000, CRC(0ce200d9) SHA1(dd27ee6754df1330544a61ca6ec1ec2e79d11284) )
4633   ROM_LOAD64_WORD_SWAP( "mpr21093.16", 0x3800000, 0x400000, CRC(6eae1fc4) SHA1(e83671d1ba7bcc8c8a577c725b54b7caa2e3666e) )
4634
4635   ROM_REGION( 0x2000000, "user3", 0 )  /* Video ROMs Part 1 */
4636   ROM_LOAD_VROM( "mpr21098.26",  0x000002, 0x400000, CRC(91e71855) SHA1(d3dcea5e983b3a9139e0091a13e3f4b2764417b8) )
4637   ROM_LOAD_VROM( "mpr21099.27",  0x000000, 0x400000, CRC(308a2768) SHA1(c6f2eefc7195541049c6c3b05495884be4876b48) )
4638   ROM_LOAD_VROM( "mpr21100.28",  0x000006, 0x400000, CRC(5149b286) SHA1(3a30f2a356fd7625b0d41976b9ef945e25e270b9) )
4639   ROM_LOAD_VROM( "mpr21101.29",  0x000004, 0x400000, CRC(e9ed4250) SHA1(decd47ab5ac251faa4a6bfd3f83dcaa24631ad2b) )
4640   ROM_LOAD_VROM( "mpr21102.30",  0x00000a, 0x400000, CRC(06c6d4fc) SHA1(e3a369f26a7a477752ca8459c5bd5b2c44ba5a6e) )
4641   ROM_LOAD_VROM( "mpr21103.31",  0x000008, 0x400000, CRC(17c4b27a) SHA1(aec6436bf74af251b0c84d4f54b5fbad47b44f4c) )
4642   ROM_LOAD_VROM( "mpr21104.32",  0x00000e, 0x400000, CRC(f6f80ffb) SHA1(cd7c61cb660ebe7a686fad7a176807da12381f70) )
4643   ROM_LOAD_VROM( "mpr21105.33",  0x00000c, 0x400000, CRC(99bdb52b) SHA1(8719a9871756d94ce21891082d97e897dcab43b0) )
4644
4645   ROM_REGION( 0x2000000, "user4", 0 )  /* Video ROMs Part 2 */
4646   ROM_LOAD_VROM( "mpr21106.34",  0x000002, 0x400000, CRC(ad2b7981) SHA1(958a6af5266fa9f4361c3b93f51ada2bb018e29b) )
4647   ROM_LOAD_VROM( "mpr21107.35",  0x000000, 0x400000, CRC(e108ff62) SHA1(8679049ef2c60f614e7a7fe9712815c1d4a89235) )
4648   ROM_LOAD_VROM( "mpr21108.36",  0x000006, 0x400000, CRC(cddc7a6e) SHA1(e20461d9f13da062c2ad1463a4b22716486a0fa3) )
4649   ROM_LOAD_VROM( "mpr21109.37",  0x000004, 0x400000, CRC(92d6141d) SHA1(ad26e8451568f1215d7bdc16511d645ddbefc74a) )
4650   ROM_LOAD_VROM( "mpr21110.38",  0x00000a, 0x400000, CRC(4d6e3148) SHA1(52faf77ab85a6cb794d7ccdc751af444f32f913d) )
4651   ROM_LOAD_VROM( "mpr21111.39",  0x000008, 0x400000, CRC(0a046d7a) SHA1(b3134c60486baec82b899439cd90b5aa9d7e9a79) )
4652   ROM_LOAD_VROM( "mpr21112.40",  0x00000e, 0x400000, CRC(9afd9feb) SHA1(068600364d7e8218c02c04c5eef041e0a1e14968) )
4653   ROM_LOAD_VROM( "mpr21113.41",  0x00000c, 0x400000, CRC(864bf325) SHA1(e78aa9aa03425d473c8337b8546e590687e06226) )
4654
4655   ROM_REGION( 0x100000, "audiocpu", 0 )   /* 68000 code */
4656   ROM_LOAD16_WORD_SWAP( "epr21118.21",  0x080000, 0x080000, CRC(598c00f0) SHA1(75e97abd6fff06547b628003c9d6498e3374208c) )
4657
4658   ROM_REGION( 0x1000000, "samples", 0 )   /* SCSP samples */
4659   ROM_LOAD( "mpr21094.22",  0x000000, 0x400000, CRC(c262b80a) SHA1(b9566474612c8359c40c416c909003b462aff3a3) )
4660   ROM_LOAD( "mpr21096.24",  0x400000, 0x400000, CRC(0a0021a0) SHA1(6409a88c895ba33a884d7e6f3f5bdded23ea65ac) )
4661   ROM_LOAD( "mpr21095.23",  0x800000, 0x400000, CRC(16d27a0a) SHA1(e21582d261ba9a7ee59fe3caf4549d4fe105a76c) )
4662   ROM_LOAD( "mpr21097.25",  0xc00000, 0x400000, CRC(0d8033fc) SHA1(d849a99d5f906d3a8f07b8f14183af14fd0d96e9) )
4663
4664   ROM_REGION( 0x20000, "cpu2", 0 )   /* Z80 code */
4665   ROM_FILL( 0x000000, 0x20000, 0 )
4666
4667   ROM_REGION( 0x1000000, "dsb", 0 )   /* DSB samples */
4668   ROM_FILL( 0x000000, 0x1000000, 0 )
4669
4670   ROM_REGION( 0x80000, "scsp1", 0 )   /* first SCSP's RAM */
4671   ROM_FILL( 0x000000, 0x80000, 0 )
4672
4673   ROM_REGION( 0x80000, "scsp2", 0 )   /* second SCSP's RAM */
4674   ROM_FILL( 0x000000, 0x80000, 0 )
4675ROM_END
4676
4677ROM_START( lamachin )   /* Step 2.0   317-0242-COM security chip (837-13576-com security board) */
4678   ROM_REGION64_BE( 0x4800000, "user1", 0 ) /* program + data ROMs */
4679   // CROM
4680   ROM_LOAD64_WORD_SWAP( "epr21483.17", 0x000006, 0x200000, CRC(940637c2) SHA1(89894b603c17d27f57500ec8030eaa7e0e991479) )
4681   ROM_LOAD64_WORD_SWAP( "epr21484.18", 0x000004, 0x200000, CRC(58102168) SHA1(38dd9a41f653c0a84ac927b476f014c949454ffa) )
4682   ROM_LOAD64_WORD_SWAP( "epr21485.19", 0x000002, 0x200000, CRC(f68f7703) SHA1(96d67aa80d6121ccebf1d50f80d509d25bab6386) )
4683   ROM_LOAD64_WORD_SWAP( "epr21486.20", 0x000000, 0x200000, CRC(64de433f) SHA1(866ae858c5c38397878836460c7418045572aff0) )
4684
4685   // CROM0
4686   ROM_LOAD64_WORD_SWAP( "mpr21451.1",   0x800006, 0x400000, CRC(42bdc56c) SHA1(e6fd07a7e9c1c5b090aacb3c68c0db0b0b95b274) )
4687   ROM_LOAD64_WORD_SWAP( "mpr21452.2",   0x800004, 0x400000, CRC(01ac050c) SHA1(40a144c30db7be30e99ec1164f05ecbc1a7c116f) )
4688   ROM_LOAD64_WORD_SWAP( "mpr21453.3",   0x800002, 0x400000, CRC(082d98ab) SHA1(48d8efc6dbba9952e69be711a90fbe749ddc60ac) )
4689   ROM_LOAD64_WORD_SWAP( "mpr21454.4",   0x800000, 0x400000, CRC(97ff94a7) SHA1(f22dc44bc7ed4ad691565973e1aa1f1497c7a184) )
4690
4691   // CROM1
4692   ROM_LOAD64_WORD_SWAP( "mpr21455.5",  0x1800006, 0x400000, CRC(0b4a3cc5) SHA1(380e441405da244459b11e2ed7fd1eb9ee9e6d50) )
4693   ROM_LOAD64_WORD_SWAP( "mpr21456.6",  0x1800004, 0x400000, CRC(73a50547) SHA1(ac441e4b389e5572fdb1eb2378666ba85755cb5c) )
4694   ROM_LOAD64_WORD_SWAP( "mpr21457.7",  0x1800002, 0x400000, CRC(2034dbd4) SHA1(357729015782fdcd1332c6ad510b2e4c0575979f) )
4695   ROM_LOAD64_WORD_SWAP( "mpr21458.8",  0x1800000, 0x400000, CRC(b748f5a1) SHA1(c4e2ee16c58f6a8147b1d33626bb6d59abe27164) )
4696
4697   // CROM2
4698   ROM_LOAD64_WORD_SWAP( "mpr21459.9",  0x2800006, 0x400000, CRC(71a7b6b3) SHA1(ecfa0b6144a6b1cef2580b1ff8719bef9df13745) )
4699   ROM_LOAD64_WORD_SWAP( "mpr21460.10", 0x2800004, 0x400000, CRC(02268361) SHA1(c6be05d1df9871585c2c56d6be71ccbb0234ded8) )
4700   ROM_LOAD64_WORD_SWAP( "mpr21461.11", 0x2800002, 0x400000, CRC(33d8f0da) SHA1(f77fd50b06a05c0809d3e90d70525ff67136908b) )
4701   ROM_LOAD64_WORD_SWAP( "mpr21462.12", 0x2800000, 0x400000, CRC(03d22ee8) SHA1(cb0c80aefc2aa7127a5f882ecb61c29f2cd3eb4e) )
4702
4703
4704   ROM_REGION( 0x2000000, "user3", 0 )  /* Video ROMs Part 1 */
4705   ROM_LOAD_VROM( "mpr21467.26",  0x000002, 0x400000, CRC(73635100) SHA1(70850cbd39ac5ddc443c9c24ac24c554d1565b1a) )
4706   ROM_LOAD_VROM( "mpr21468.27",  0x000000, 0x400000, CRC(462e5c81) SHA1(05eb1f580a9dcd1f59ccb2791e974325494e5910) )
4707   ROM_LOAD_VROM( "mpr21469.28",  0x000006, 0x400000, CRC(4ba3f192) SHA1(c9afc434165b4dfcaa856f8d5c954bc1484f38f0) )
4708   ROM_LOAD_VROM( "mpr21470.29",  0x000004, 0x400000, CRC(670f0df5) SHA1(fcb181231003e6a4225dfaedb36d2814d8137a46) )
4709   ROM_LOAD_VROM( "mpr21471.30",  0x00000a, 0x400000, CRC(1f07e6e3) SHA1(b4948d5b3763d95a0f8e5364bd41f1a87d1ab468) )
4710   ROM_LOAD_VROM( "mpr21472.31",  0x000008, 0x400000, CRC(e6dc64a3) SHA1(047681ea60e2714aad9117114cbcf40a70884d1c) )
4711   ROM_LOAD_VROM( "mpr21473.32",  0x00000e, 0x400000, CRC(d1c9b54a) SHA1(e670431da482a6a58a83ac6b47ab2649033db9c8) )
4712   ROM_LOAD_VROM( "mpr21474.33",  0x00000c, 0x400000, CRC(aa2f19ae) SHA1(9abae5a2f7719bbc61ae08cf0dc88133234fe202) )
4713
4714   ROM_REGION( 0x2000000, "user4", 0 )  /* Video ROMs Part 2 */
4715   ROM_LOAD_VROM( "mpr21475.34",  0x000002, 0x400000, CRC(bae9b381) SHA1(0be17607b27f2733a14183b371fe04b52a6cb416) )
4716   ROM_LOAD_VROM( "mpr21476.35",  0x000000, 0x400000, CRC(3833df51) SHA1(1ff02356d8af427f5d0e12b513a6fe010db0a9de) )
4717   ROM_LOAD_VROM( "mpr21477.36",  0x000006, 0x400000, CRC(46032c35) SHA1(4445529a55bfdde5890f13d36716ad2c6be9513e) )
4718   ROM_LOAD_VROM( "mpr21478.37",  0x000004, 0x400000, CRC(35ef75b8) SHA1(a115d94f87a29aec87434bd9fcbbeeece5f558cd) )
4719   ROM_LOAD_VROM( "mpr21479.38",  0x00000a, 0x400000, CRC(783e8ece) SHA1(6ad89c5f8c8583859830b9f1c54a144630e13203) )
4720   ROM_LOAD_VROM( "mpr21480.39",  0x000008, 0x400000, CRC(c947bcb8) SHA1(15efe0541c068263a8902ae2bbe0f4614f68914c) )
4721   ROM_LOAD_VROM( "mpr21481.40",  0x00000e, 0x400000, CRC(6ce566ac) SHA1(cfacc090cce3cfcfde73d5ed9439ff96c1a35f48) )
4722   ROM_LOAD_VROM( "mpr21482.41",  0x00000c, 0x400000, CRC(e995f554) SHA1(274aed8361884137a4b52153720ae4dc4b75747b) )
4723
4724   ROM_REGION( 0x100000, "audiocpu", 0 )   /* 68000 code */
4725   ROM_LOAD16_WORD_SWAP( "epr21487.21",  0x080000, 0x080000, CRC(c2942448) SHA1(71836a4106b6f5a63f34db09503ae538dd3320db) )
4726
4727   ROM_REGION( 0x1000000, "samples", 0 )   /* SCSP samples */
4728   ROM_LOAD( "mpr21463.22",  0x000000, 0x400000, CRC(0e6d6c0e) SHA1(d703c1021cf9169aec9b054d34f2ef0284fcfcb3) )
4729   ROM_LOAD( "mpr21465.24",  0x400000, 0x400000, CRC(1a62d925) SHA1(a3a8047f1898dfd76fe1747df18bfc1e87bf35bd) )
4730   ROM_LOAD( "mpr21464.23",  0x800000, 0x400000, CRC(8230c1de) SHA1(6ba3bc72a55d5ce79f37804348064c50431fd490) )
4731   ROM_LOAD( "mpr21466.25",  0xc00000, 0x400000, CRC(ca20359e) SHA1(1948f71f7eea27f757f0d508ee1390aeb576a8fa) )
4732
4733   ROM_REGION( 0x20000, "cpu2", 0 )   /* Z80 code */
4734   ROM_FILL( 0x000000, 0x20000, 0 )
4735
4736   ROM_REGION( 0x1000000, "dsb", 0 )   /* DSB samples */
4737   ROM_FILL( 0x000000, 0x1000000, 0 )
4738
4739   ROM_REGION( 0x80000, "scsp1", 0 )   /* first SCSP's RAM */
4740   ROM_FILL( 0x000000, 0x80000, 0 )
4741
4742   ROM_REGION( 0x80000, "scsp2", 0 )   /* second SCSP's RAM */
4743   ROM_FILL( 0x000000, 0x80000, 0 )
4744ROM_END
4745
46104746/* Model 3 sound board emulation */
46114747
46124748static WRITE16_HANDLER( model3snd_ctrl )
r7500r7501
52715407/* Model 3 Step 2.0 */
52725408GAME( 1997, vs2,            0, model3_20, model3,        vs2, ROT0, "Sega", "Virtua Striker 2 (Step 2.0)", GAME_NOT_WORKING | GAME_IMPERFECT_GRAPHICS | GAME_NO_SOUND )
52735409GAME( 1997, harley,         0, model3_20, harley,     harley, ROT0, "Sega", "Harley-Davidson and L.A. Riders (Revision A)", GAME_NOT_WORKING | GAME_IMPERFECT_GRAPHICS | GAME_NO_SOUND )
5410GAME( 1998, lamachin,       0, model3_20, model3,  model3_20, ROT0, "Sega", "L.A. Machineguns", GAME_NOT_WORKING | GAME_IMPERFECT_GRAPHICS | GAME_NO_SOUND )
5411GAME( 1998, oceanhun,       0, model3_20, model3,  model3_20, ROT0, "Sega", "The Ocean Hunter", GAME_NOT_WORKING | GAME_IMPERFECT_GRAPHICS | GAME_NO_SOUND )
52745412GAME( 1998, skichamp,       0, model3_20, skichamp, skichamp, ROT0, "Sega", "Ski Champ", GAME_NOT_WORKING | GAME_IMPERFECT_GRAPHICS | GAME_NO_SOUND )
52755413GAME( 1998, srally2,        0, model3_20, scud,      srally2, ROT0, "Sega", "Sega Rally 2", GAME_NOT_WORKING | GAME_IMPERFECT_GRAPHICS | GAME_NO_SOUND )
52765414GAME( 1998, srally2x,       0, model3_20, scud,      srally2, ROT0, "Sega", "Sega Rally 2 DX", GAME_NOT_WORKING | GAME_IMPERFECT_GRAPHICS | GAME_NO_SOUND )
src/mame/drivers/funkyjet.c
r7500r7501
9090#include "emu.h"
9191#include "cpu/m68000/m68000.h"
9292#include "cpu/h6280/h6280.h"
93#include "includes/decocrpt.h"
94#include "includes/decoprot.h"
95#include "includes/funkyjet.h"
9396#include "sound/2151intf.h"
9497#include "sound/okim6295.h"
98#include "video/deco16ic.h"
9599
96#include "includes/decocrpt.h"
97#include "includes/decoprot.h"
98#include "includes/deco16ic.h"
99100
100VIDEO_START( funkyjet );
101VIDEO_UPDATE( funkyjet );
102
103101/******************************************************************************/
104102
105103static ADDRESS_MAP_START( funkyjet_map, ADDRESS_SPACE_PROGRAM, 16 )
106104   AM_RANGE(0x000000, 0x07ffff) AM_ROM
107105   AM_RANGE(0x120000, 0x1207ff) AM_RAM_WRITE(paletteram16_xxxxBBBBGGGGRRRR_word_w) AM_BASE_GENERIC(paletteram)
108106   AM_RANGE(0x140000, 0x143fff) AM_RAM
109   AM_RANGE(0x160000, 0x1607ff) AM_RAM AM_BASE_GENERIC(spriteram)
107   AM_RANGE(0x160000, 0x1607ff) AM_RAM AM_BASE_SIZE_MEMBER(funkyjet_state, spriteram, spriteram_size)
110108   AM_RANGE(0x180000, 0x1807ff) AM_READWRITE(deco16_146_funkyjet_prot_r, deco16_146_funkyjet_prot_w) AM_BASE(&deco16_prot_ram)
111109   AM_RANGE(0x184000, 0x184001) AM_WRITENOP
112110   AM_RANGE(0x188000, 0x188001) AM_WRITENOP
113   AM_RANGE(0x300000, 0x30000f) AM_WRITEONLY AM_BASE(&deco16_pf12_control)
114   AM_RANGE(0x320000, 0x321fff) AM_RAM_WRITE(deco16_pf1_data_w) AM_BASE(&deco16_pf1_data)
115   AM_RANGE(0x322000, 0x323fff) AM_RAM_WRITE(deco16_pf2_data_w) AM_BASE(&deco16_pf2_data)
116   AM_RANGE(0x340000, 0x340bff) AM_RAM AM_BASE(&deco16_pf1_rowscroll)
117   AM_RANGE(0x342000, 0x342bff) AM_RAM AM_BASE(&deco16_pf2_rowscroll)
111   AM_RANGE(0x300000, 0x30000f) AM_DEVWRITE("deco_custom", deco16ic_pf12_control_w)
112   AM_RANGE(0x320000, 0x321fff) AM_DEVREADWRITE("deco_custom", deco16ic_pf1_data_r, deco16ic_pf1_data_w)
113   AM_RANGE(0x322000, 0x323fff) AM_DEVREADWRITE("deco_custom", deco16ic_pf2_data_r, deco16ic_pf2_data_w)
114   AM_RANGE(0x340000, 0x340bff) AM_RAM AM_BASE_MEMBER(funkyjet_state, pf1_rowscroll)
115   AM_RANGE(0x342000, 0x342bff) AM_RAM AM_BASE_MEMBER(funkyjet_state, pf2_rowscroll)
118116ADDRESS_MAP_END
119117
120118/******************************************************************************/
r7500r7501
277275
278276/******************************************************************************/
279277
280static void sound_irq(running_device *device, int state)
278static void sound_irq( running_device *device, int state )
281279{
282   cputag_set_input_line(device->machine, "audiocpu", 1, state); /* IRQ 2 */
280   funkyjet_state *driver_state = (funkyjet_state *)device->machine->driver_data;
281   cpu_set_input_line(driver_state->audiocpu, 1, state); /* IRQ 2 */
283282}
284283
285284static const ym2151_interface ym2151_config =
r7500r7501
287286   sound_irq
288287};
289288
289static const deco16ic_interface funkyjet_deco16ic_intf =
290{
291   "screen",
292   1, 0, 1,
293   0x0f, 0x0f, 0x0f, 0x0f,   /* trans masks (default values) */
294   0, 16, 0, 16, /* color base (default values) */
295   0x0f, 0x0f, 0x0f, 0x0f,   /* color masks (default values) */
296   NULL, NULL, NULL, NULL
297};
298
299static MACHINE_START( funkyjet )
300{
301   funkyjet_state *state = (funkyjet_state *)machine->driver_data;
302
303   state->maincpu = devtag_get_device(machine, "maincpu");
304   state->audiocpu = devtag_get_device(machine, "audiocpu");
305   state->deco16ic = devtag_get_device(machine, "deco_custom");
306}
307
290308static MACHINE_DRIVER_START( funkyjet )
291309
310   /* driver data */
311   MDRV_DRIVER_DATA(funkyjet_state)
312
292313   /* basic machine hardware */
293314   MDRV_CPU_ADD("maincpu", M68000, 14000000) /* 28 MHz crystal */
294315   MDRV_CPU_PROGRAM_MAP(funkyjet_map)
r7500r7501
297318   MDRV_CPU_ADD("audiocpu", H6280,32220000/4)   /* Custom chip 45, Audio section crystal is 32.220 MHz */
298319   MDRV_CPU_PROGRAM_MAP(sound_map)
299320
321   MDRV_MACHINE_START(funkyjet)
322
300323   /* video hardware */
301324   MDRV_SCREEN_ADD("screen", RASTER)
302325   MDRV_SCREEN_REFRESH_RATE(58)
r7500r7501
308331   MDRV_GFXDECODE(funkyjet)
309332   MDRV_PALETTE_LENGTH(1024)
310333
311   MDRV_VIDEO_START(funkyjet)
312334   MDRV_VIDEO_UPDATE(funkyjet)
313335
336   MDRV_DECO16IC_ADD("deco_custom", funkyjet_deco16ic_intf)
337
314338   /* sound hardware */
315339   MDRV_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker")
316340
src/mame/drivers/marinedt.c
r7500r7501
9797#include "emu.h"
9898#include "cpu/z80/z80.h"
9999
100static bitmap_t *tile, *obj1, *obj2;
101static tilemap_t *tx_tilemap;
100class marinedt_state
101{
102public:
103   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, marinedt_state(machine)); }
102104
103static UINT8 *tx_tileram;
105   marinedt_state(running_machine &machine) { }
104106
105static UINT8 marinedt_obj1_a, marinedt_obj1_x, marinedt_obj1_y;
106static UINT8 marinedt_obj2_a, marinedt_obj2_x, marinedt_obj2_y;
107static UINT8 marinedt_pd, marinedt_pf;
108static UINT8 marinedt_music, marinedt_sound;
109static UINT8 coll, cx, cyr, cyq;
110static UINT8 collh, cxh, cyrh, cyqh;
107   /* memory pointers */
108   UINT8 *     tx_tileram;
111109
110   /* video-related */
111   bitmap_t *tile, *obj1, *obj2;
112   tilemap_t *tx_tilemap;
113
114   UINT8 obj1_a, obj1_x, obj1_y;
115   UINT8 obj2_a, obj2_x, obj2_y;
116   UINT8 pd, pf;
117   UINT8 music, sound;
118   UINT8 coll, cx, cyr, cyq;
119   UINT8 collh, cxh, cyrh, cyqh;
120};
121
122
112123static WRITE8_HANDLER( tx_tileram_w )
113124{
114   tx_tileram[offset] = data;
115   tilemap_mark_tile_dirty(tx_tilemap, offset);
125   marinedt_state *state = (marinedt_state *)space->machine->driver_data;
126
127   state->tx_tileram[offset] = data;
128   tilemap_mark_tile_dirty(state->tx_tilemap, offset);
116129}
117130
118131static READ8_HANDLER( marinedt_port1_r )
119132{
120//might need to be reversed for cocktail stuff
133   marinedt_state *state = (marinedt_state *)space->machine->driver_data;
121134
135   //might need to be reversed for cocktail stuff
136
122137   /* x/y multiplexed */
123   return input_port_read(space->machine, ((marinedt_pf & 0x08)>>3) ? "TRACKY" : "TRACKX");
138   return input_port_read(space->machine, ((state->pf & 0x08) >> 3) ? "TRACKY" : "TRACKX");
124139}
125140
126141static READ8_HANDLER( marinedt_coll_r )
r7500r7501
131146   //----x--- obj1 to playfield collision
132147   //-----xxx unused
133148
134   return coll | collh;
149   marinedt_state *state = (marinedt_state *)space->machine->driver_data;
150   return state->coll | state->collh;
135151}
136152
137153//are these returning only during a collision?
r7500r7501
144160   //xxxx---- unknown
145161   //----xxxx x pos in tile ram
146162
163   marinedt_state *state = (marinedt_state *)space->machine->driver_data;
147164   UINT8 *RAM = memory_region(space->machine, "maincpu");
148if(RAM[0x430e]) --cx; else ++cx;
149//figure out why inc/dec based on 430e?
150   return cx | (cxh<<4);
165
166   if (RAM[0x430e])
167      --state->cx;
168   else
169      ++state->cx;
170
171   //figure out why inc/dec based on 430e?
172   return state->cx | (state->cxh << 4);
151173}
152174
153175static READ8_HANDLER( marinedt_obj1_yr_r )
r7500r7501
155177   //76543210
156178   //xxxx---- unknown
157179   //----xxxx row in current screen quarter
158//has to be +1 if cx went over?
159if (cx==0x10) cyr++;
160180
161   return cyr | (cyrh<<4);
181   marinedt_state *state = (marinedt_state *)space->machine->driver_data;
182
183   //has to be +1 if cx went over?
184   if (state->cx == 0x10)
185      state->cyr++;
186
187   return state->cyr | (state->cyrh << 4);
162188}
163189
164190static READ8_HANDLER( marinedt_obj1_yq_r )
r7500r7501
169195   //----xx-- unknown
170196   //------xx screen quarter
171197
172   return cyq | (cyqh<<4);
198   marinedt_state *state = (marinedt_state *)space->machine->driver_data;
199   return state->cyq | (state->cyqh << 4);
173200}
174201
175static WRITE8_HANDLER( marinedt_obj1_a_w ) { marinedt_obj1_a = data; }
176static WRITE8_HANDLER( marinedt_obj1_x_w ) { marinedt_obj1_x = data; }
177static WRITE8_HANDLER( marinedt_obj1_y_w ) { marinedt_obj1_y = data; }
178static WRITE8_HANDLER( marinedt_obj2_a_w ) { marinedt_obj2_a = data; }
179static WRITE8_HANDLER( marinedt_obj2_x_w ) { marinedt_obj2_x = data; }
180static WRITE8_HANDLER( marinedt_obj2_y_w ) { marinedt_obj2_y = data; }
202static WRITE8_HANDLER( marinedt_obj1_a_w ) { marinedt_state *state = (marinedt_state *)space->machine->driver_data;    state->obj1_a = data; }
203static WRITE8_HANDLER( marinedt_obj1_x_w ) { marinedt_state *state = (marinedt_state *)space->machine->driver_data;    state->obj1_x = data; }
204static WRITE8_HANDLER( marinedt_obj1_y_w ) { marinedt_state *state = (marinedt_state *)space->machine->driver_data;    state->obj1_y = data; }
205static WRITE8_HANDLER( marinedt_obj2_a_w ) { marinedt_state *state = (marinedt_state *)space->machine->driver_data;    state->obj2_a = data; }
206static WRITE8_HANDLER( marinedt_obj2_x_w ) { marinedt_state *state = (marinedt_state *)space->machine->driver_data;    state->obj2_x = data; }
207static WRITE8_HANDLER( marinedt_obj2_y_w ) { marinedt_state *state = (marinedt_state *)space->machine->driver_data;    state->obj2_y = data; }
181208
182static WRITE8_HANDLER( marinedt_music_w ){ marinedt_music = data; }
209static WRITE8_HANDLER( marinedt_music_w ){ marinedt_state *state = (marinedt_state *)space->machine->driver_data;    state->music = data; }
183210
184211static WRITE8_HANDLER( marinedt_sound_w )
185212{
r7500r7501
192219   //------x- dots hit
193220   //-------x ??
194221
195   marinedt_sound = data;
222   marinedt_state *state = (marinedt_state *)space->machine->driver_data;
223   state->sound = data;
196224}
197225
198226static WRITE8_HANDLER( marinedt_pd_w )
r7500r7501
205233   //------x- obj2 enable
206234   //-------x obj1 enable
207235
208   marinedt_pd = data;
236   marinedt_state *state = (marinedt_state *)space->machine->driver_data;
237   state->pd = data;
209238}
210239
211240/*
r7500r7501
232261   //------x- ?? upright/cocktail
233262   //-------x ?? service mode (coin lockout??)
234263
235   //if ((marinedt_pf & 0x07) != (data & 0x07))
264   marinedt_state *state = (marinedt_state *)space->machine->driver_data;
265
266   //if ((state->pf & 0x07) != (data & 0x07))
236267   //  mame_printf_debug("marinedt_pf_w: %02x\n", data & 0x07);
237268
238   if ((marinedt_pf & 0x02) != (data & 0x02))
269   if ((state->pf & 0x02) != (data & 0x02))
239270   {
240271      if (data & 0x02)
241272         mame_printf_debug("tile flip\n");
r7500r7501
243274         mame_printf_debug("tile non-flip\n");
244275
245276      if (data & 0x02)
246         tilemap_set_flip(tx_tilemap, TILEMAP_FLIPX | TILEMAP_FLIPY);
277         tilemap_set_flip(state->tx_tilemap, TILEMAP_FLIPX | TILEMAP_FLIPY);
247278      else
248         tilemap_set_flip(tx_tilemap, 0);
279         tilemap_set_flip(state->tx_tilemap, 0);
249280   }
250281
251   marinedt_pf = data;
282   state->pf = data;
252283
253//if(data&0xf0)
254//  logerror("pf:%02x %d\n",marinedt_pf);
255//logerror("pd:%02x %d\n",marinedt_pd, video_screen_get_frame_number(space->machine->primary_screen));
284   //if (data & 0xf0)
285   //    logerror("pf:%02x %d\n", state->pf);
286   //logerror("pd:%02x %d\n", state->pd, video_screen_get_frame_number(space->machine->primary_screen));
256287
257288}
258289
r7500r7501
260291   AM_RANGE(0x0000, 0x37ff) AM_ROM
261292   AM_RANGE(0x4000, 0x43ff) AM_RAM
262293   AM_RANGE(0x4400, 0x47ff) AM_RAM            //unused, vram mirror?
263   AM_RANGE(0x4800, 0x4bff) AM_RAM_WRITE(tx_tileram_w) AM_BASE(&tx_tileram)
294   AM_RANGE(0x4800, 0x4bff) AM_RAM_WRITE(tx_tileram_w) AM_BASE_MEMBER(marinedt_state, tx_tileram)
264295   AM_RANGE(0x4c00, 0x4c00) AM_WRITENOP   //?? maybe off by one error
265296ADDRESS_MAP_END
266297
r7500r7501
283314
284315
285316static INPUT_PORTS_START( marinedt )
286   PORT_START("DSW0")      /* IN0 */
317   PORT_START("DSW0")
287318   PORT_DIPNAME( 0x0f, 0x00, DEF_STR( Coin_A ) )
288319   PORT_DIPSETTING(    0x0f, DEF_STR( 9C_1C ) )
289320   PORT_DIPSETTING(    0x0e, DEF_STR( 8C_1C ) )
r7500r7501
319350   PORT_DIPSETTING(    0x60, DEF_STR( 1C_7C ) )
320351   PORT_DIPSETTING(    0x70, DEF_STR( 1C_8C ) )
321352
322   PORT_START("IN0")      /* IN1 */
353   PORT_START("IN0")
323354   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_COIN1 )
324355   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_COIN2 )
325356   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_SERVICE1 )
r7500r7501
329360   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_START2 )
330361   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_START1 )
331362
332   PORT_START("DSW1")      /* IN2 */
363   PORT_START("DSW1")
333364   PORT_DIPNAME( 0x01, 0x00, DEF_STR( Bonus_Life ) )
334365   PORT_DIPSETTING(    0x01, "5000" )
335366   PORT_DIPSETTING(    0x00, "10000" )
r7500r7501
355386   PORT_DIPSETTING(    0x80, "5" )
356387   PORT_DIPSETTING(    0xc0, "6" )
357388
358   PORT_START("TRACKX")   /* IN3 - FAKE MUXED */
389   PORT_START("TRACKX")   /* FAKE MUXED */
359390//check all bits are used
360391   PORT_BIT( 0xff, 0x00, IPT_TRACKBALL_X ) PORT_SENSITIVITY(25) PORT_KEYDELTA(10) PORT_REVERSE
361392
362   PORT_START("TRACKY")   /* IN4 - FAKE MUXED */
393   PORT_START("TRACKY")   /* FAKE MUXED */
363394   PORT_BIT( 0xff, 0x00, IPT_TRACKBALL_Y ) PORT_SENSITIVITY(25) PORT_KEYDELTA(10)
364395INPUT_PORTS_END
365396
r7500r7501
395426{
396427   int i,r,b,g;
397428
398   for (i = 0;i < machine->config->total_colors; i++)
429   for (i = 0; i < machine->config->total_colors; i++)
399430   {
400      int bit0,bit1,bit2;
431      int bit0, bit1, bit2;
401432
402433      /* red component */
403434      bit0 = (~color_prom[i] >> 0) & 0x01;
r7500r7501
415446      bit0 = (~color_prom[i] >> 5) & 0x01;
416447      bit1 = (~color_prom[i] >> 6) & 0x01;
417448      bit2 = (~color_prom[i] >> 7) & 0x01;
418bit0=0;
449bit0 = 0;
419450//      *(palette++) = 0x92 * bit0 + 0x46 * bit1 + 0x27 * bit2;
420451      b = 0x27 * bit0 + 0x46 * bit1 + 0x92 * bit2;
421452
r7500r7501
426457
427458static TILE_GET_INFO( get_tile_info )
428459{
429   int code = tx_tileram[tile_index];
460   marinedt_state *state = (marinedt_state *)machine->driver_data;
461   int code = state->tx_tileram[tile_index];
430462   int color = 0;
431463   int flags = TILE_FLIPX;
432464
r7500r7501
435467
436468static VIDEO_START( marinedt )
437469{
438   tx_tilemap = tilemap_create(machine, get_tile_info, tilemap_scan_rows, 8, 8,32,32);
470   marinedt_state *state = (marinedt_state *)machine->driver_data;
471   state->tx_tilemap = tilemap_create(machine, get_tile_info, tilemap_scan_rows, 8, 8, 32, 32);
439472
440   tilemap_set_transparent_pen(tx_tilemap, 0);
441   tilemap_set_scrolldx(tx_tilemap, 0, 4*8);
442   tilemap_set_scrolldy(tx_tilemap, 0, -4*8);
473   tilemap_set_transparent_pen(state->tx_tilemap, 0);
474   tilemap_set_scrolldx(state->tx_tilemap, 0, 4*8);
475   tilemap_set_scrolldy(state->tx_tilemap, 0, -4*8);
443476
444   tile = auto_bitmap_alloc(machine,32 * 8, 32 * 8, video_screen_get_format(machine->primary_screen));
445   obj1 = auto_bitmap_alloc(machine,32,32,video_screen_get_format(machine->primary_screen));
446   obj2 = auto_bitmap_alloc(machine,32,32,video_screen_get_format(machine->primary_screen));
477   state->tile = auto_bitmap_alloc(machine, 32 * 8, 32 * 8, video_screen_get_format(machine->primary_screen));
478   state->obj1 = auto_bitmap_alloc(machine, 32, 32, video_screen_get_format(machine->primary_screen));
479   state->obj2 = auto_bitmap_alloc(machine, 32, 32, video_screen_get_format(machine->primary_screen));
447480}
448481
449482
r7500r7501
457490#define OBJ_COLOR(a)   ((a) & 0x03)
458491#define OBJ_X(x)   (256 - 32 - (x))
459492#define OBJ_Y(y)   (256 - 1 - (y))
460#define OBJ_FLIPX(a)   ((marinedt_pf & 0x02) == 0)
493#define OBJ_FLIPX(a)   ((state->pf & 0x02) == 0)
461494#define OBJ_FLIPY(a)   ((a) & 0x80)
462495
463496static VIDEO_UPDATE( marinedt )
464497{
498   marinedt_state *state = (marinedt_state *)screen->machine->driver_data;
465499   int sx, sy;
466500
467   bitmap_fill(tile, NULL, 0);
468   tilemap_draw(tile, cliprect, tx_tilemap, 0, 0);
501   bitmap_fill(state->tile, NULL, 0);
502   tilemap_draw(state->tile, cliprect, state->tx_tilemap, 0, 0);
469503
470   bitmap_fill(obj1, NULL, 0);
471   drawgfx_transpen(obj1, NULL, screen->machine->gfx[1],
472         OBJ_CODE(marinedt_obj1_a),
473         OBJ_COLOR(marinedt_obj1_a),
474         OBJ_FLIPX(marinedt_obj1_a), OBJ_FLIPY(marinedt_obj1_a),
504   bitmap_fill(state->obj1, NULL, 0);
505   drawgfx_transpen(state->obj1, NULL, screen->machine->gfx[1],
506         OBJ_CODE(state->obj1_a),
507         OBJ_COLOR(state->obj1_a),
508         OBJ_FLIPX(state->obj1_a), OBJ_FLIPY(state->obj1_a),
475509         0, 0, 0);
476510
477   bitmap_fill(obj2, NULL, 0);
478   drawgfx_transpen(obj2, NULL, screen->machine->gfx[2],
479         OBJ_CODE(marinedt_obj2_a),
480         OBJ_COLOR(marinedt_obj2_a),
481         OBJ_FLIPX(marinedt_obj2_a), OBJ_FLIPY(marinedt_obj2_a),
511   bitmap_fill(state->obj2, NULL, 0);
512   drawgfx_transpen(state->obj2, NULL, screen->machine->gfx[2],
513         OBJ_CODE(state->obj2_a),
514         OBJ_COLOR(state->obj2_a),
515         OBJ_FLIPX(state->obj2_a), OBJ_FLIPY(state->obj2_a),
482516         0, 0, 0);
483517
484518   bitmap_fill(bitmap, NULL, 0);
485519
486   if (marinedt_pd & 0x02)
487      copybitmap_trans(bitmap, obj2, 0, 0, OBJ_X(marinedt_obj2_x), OBJ_Y(marinedt_obj2_y), cliprect, 0);
520   if (state->pd & 0x02)
521      copybitmap_trans(bitmap, state->obj2, 0, 0, OBJ_X(state->obj2_x), OBJ_Y(state->obj2_y), cliprect, 0);
488522
489   if (marinedt_pd & 0x01)
490      copybitmap_trans(bitmap, obj1, 0, 0, OBJ_X(marinedt_obj1_x), OBJ_Y(marinedt_obj1_y), cliprect, 0);
523   if (state->pd & 0x01)
524      copybitmap_trans(bitmap, state->obj1, 0, 0, OBJ_X(state->obj1_x), OBJ_Y(state->obj1_y), cliprect, 0);
491525
492   copybitmap_trans(bitmap, tile, 0, 0, 0, 0, cliprect, 0);
526   copybitmap_trans(bitmap, state->tile, 0, 0, 0, 0, cliprect, 0);
493527
494   coll = cx = cyr = cyq = 0;
495   if (marinedt_pd & 0x01)
528   state->coll = state->cx = state->cyr = state->cyq = 0;
529   if (state->pd & 0x01)
496530   {
497531      for (sx = 0; sx < 32; sx++)
498532         for (sy = 0; sy < 32; sy++)
499533         {
500            int x = OBJ_X(marinedt_obj1_x) + sx;
501            int y = OBJ_Y(marinedt_obj1_y) + sy;
534            int x = OBJ_X(state->obj1_x) + sx;
535            int y = OBJ_Y(state->obj1_y) + sy;
502536
503            if (x < cliprect->min_x || x > cliprect->max_x
504             || y < cliprect->min_y || y > cliprect->max_y)
537            if (x < cliprect->min_x || x > cliprect->max_x || y < cliprect->min_y || y > cliprect->max_y)
505538               continue;
506539
507            if (*BITMAP_ADDR16(obj1, sy, sx) == 0)
540            if (*BITMAP_ADDR16(state->obj1, sy, sx) == 0)
508541               continue;
509542
510            if (*BITMAP_ADDR16(tile, y, x) != 0)
543            if (*BITMAP_ADDR16(state->tile, y, x) != 0)
511544            {
512               coll = 0x08;
545               state->coll = 0x08;
513546
514               cx = (x % 128) / 8;
515               cx &= 0x0f;
547               state->cx = (x % 128) / 8;
548               state->cx &= 0x0f;
516549
517               cyr = ((y % 64) / 8) * 2 + (x > 127 ? 1 : 0);
518               cyr &= 0x0f;
550               state->cyr = ((y % 64) / 8) * 2 + (x > 127 ? 1 : 0);
551               state->cyr &= 0x0f;
519552
520               cyq = y / 64;
521               cyq &= 0x0f;
553               state->cyq = y / 64;
554               state->cyq &= 0x0f;
522555
523556               break;
524557            }
525558         }
526559   }
527560
528   collh = cxh = cyrh = cyqh = 0;
529   if ((marinedt_pd & 0x03) == 0x03)
561   state->collh = state->cxh = state->cyrh = state->cyqh = 0;
562   if ((state->pd & 0x03) == 0x03)
530563   {
531564      for (sx = 0; sx < 32; sx++)
532565         for (sy = 0; sy < 32; sy++)
533566         {
534            int x = OBJ_X(marinedt_obj1_x + sx);
535            int y = OBJ_Y(marinedt_obj1_y + sy);
567            int x = OBJ_X(state->obj1_x + sx);
568            int y = OBJ_Y(state->obj1_y + sy);
536569
537            int xx = OBJ_X(marinedt_obj2_x) - x;
538            int yy = OBJ_Y(marinedt_obj2_y) - y;
570            int xx = OBJ_X(state->obj2_x) - x;
571            int yy = OBJ_Y(state->obj2_y) - y;
539572
540            if (xx < 0 || xx >= 32
541             || yy < 0 || yy >= 32)
573            if (xx < 0 || xx >= 32 || yy < 0 || yy >= 32)
542574               continue;
543575
544            if (*BITMAP_ADDR16(obj1, sy, sx) == 0)
576            if (*BITMAP_ADDR16(state->obj1, sy, sx) == 0)
545577               continue;
546578
547            if (*BITMAP_ADDR16(obj2, yy, xx) != 0)
579            if (*BITMAP_ADDR16(state->obj2, yy, xx) != 0)
548580            {
549               collh = 0x80;
581               state->collh = 0x80;
550582
551               cxh = (x % 128) / 8;
552               cxh &= 0x0f;
583               state->cxh = (x % 128) / 8;
584               state->cxh &= 0x0f;
553585
554               cyrh = ((y % 64) / 8) * 2 + (x > 127 ? 1 : 0);
555               cyrh &= 0x0f;
586               state->cyrh = ((y % 64) / 8) * 2 + (x > 127 ? 1 : 0);
587               state->cyrh &= 0x0f;
556588
557               cyqh= y / 64;
558               cyqh &= 0x0f;
589               state->cyqh= y / 64;
590               state->cyqh &= 0x0f;
559591
560592               break;
561593            }
r7500r7501
564596   return 0;
565597}
566598
599static MACHINE_START( marinedt )
600{
601   marinedt_state *state = (marinedt_state *)machine->driver_data;
602
603   state_save_register_global(machine, state->obj1_a);
604   state_save_register_global(machine, state->obj1_x);
605   state_save_register_global(machine, state->obj1_y);
606   state_save_register_global(machine, state->obj2_a);
607   state_save_register_global(machine, state->obj2_x);
608   state_save_register_global(machine, state->obj2_y);
609   state_save_register_global(machine, state->pd);
610   state_save_register_global(machine, state->pf);
611   state_save_register_global(machine, state->music);
612   state_save_register_global(machine, state->sound);
613   state_save_register_global(machine, state->coll);
614   state_save_register_global(machine, state->cx);
615   state_save_register_global(machine, state->cyr);
616   state_save_register_global(machine, state->cyq);
617   state_save_register_global(machine, state->collh);
618   state_save_register_global(machine, state->cxh);
619   state_save_register_global(machine, state->cyrh);
620   state_save_register_global(machine, state->cyqh);
621}
622
623static MACHINE_RESET( marinedt )
624{
625   marinedt_state *state = (marinedt_state *)machine->driver_data;
626
627   state->obj1_a = 0;
628   state->obj1_x = 0;
629   state->obj1_y = 0;
630   state->obj2_a = 0;
631   state->obj2_x = 0;
632   state->obj2_y = 0;
633   state->pd = 0;
634   state->pf = 0;
635   state->music = 0;
636   state->sound = 0;
637   state->coll = 0;
638   state->cx = 0;
639   state->cyr = 0;
640   state->cyq = 0;
641   state->collh = 0;
642   state->cxh = 0;
643   state->cyrh = 0;
644   state->cyqh = 0;
645}
646
567647static MACHINE_DRIVER_START( marinedt )
568648
649   /* driver data */
650   MDRV_DRIVER_DATA(marinedt_state)
651
569652   /* basic machine hardware */
570653   MDRV_CPU_ADD("maincpu", Z80,10000000/4)
571654   MDRV_CPU_PROGRAM_MAP(marinedt_map)
572655   MDRV_CPU_IO_MAP(marinedt_io_map)
573656   MDRV_CPU_VBLANK_INT("screen", irq0_line_hold)
574657
658   MDRV_MACHINE_START(marinedt)
659   MDRV_MACHINE_RESET(marinedt)
660
575661   /* video hardware */
576662   MDRV_SCREEN_ADD("screen", RASTER)
577663   MDRV_SCREEN_REFRESH_RATE(60)
r7500r7501
626712   ROM_LOAD( "mg17.bpr", 0x0060, 0x0020, CRC(13261a02) SHA1(050edd18e4f79d19d5206f55f329340432fd4099) )   //?? table of increasing values
627713ROM_END
628714
629GAME( 1981, marinedt, 0, marinedt, marinedt, 0, ROT270, "Taito", "Marine Date", GAME_NO_SOUND )
630
715GAME( 1981, marinedt, 0, marinedt, marinedt, 0, ROT270, "Taito", "Marine Date", GAME_NO_SOUND | GAME_SUPPORTS_SAVE )
src/mame/drivers/sliver.c
r7500r7501
7676#define x_offset 0x45
7777#define y_offset 0x0d
7878
79typedef struct _sliver_state sliver_state;
80struct _sliver_state
79class sliver_state
8180{
81public:
82   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, sliver_state(machine)); }
83
84   sliver_state(running_machine &machine) { }
85
8286   UINT16 io_offset;
8387   UINT16 io_reg[IO_SIZE];
8488   UINT16 fifo[FIFO_SIZE];
src/mame/drivers/mrflea.c
r7500r7501
4343#include "deprecat.h"
4444#include "cpu/z80/z80.h"
4545#include "sound/ay8910.h"
46#include "includes/mrflea.h"
4647
47static int mrflea_io;
48static int mrflea_main;
4948
50static int mrflea_status;
49/*************************************
50 *
51 *  Memory handlers
52 *
53 *************************************/
5154
52static int mrflea_select1;
53
54extern WRITE8_HANDLER( mrflea_gfx_bank_w );
55extern WRITE8_HANDLER( mrflea_videoram_w );
56extern WRITE8_HANDLER( mrflea_spriteram_w );
57extern VIDEO_START( mrflea );
58extern VIDEO_UPDATE( mrflea );
59
60static const gfx_layout tile_layout = {
61   8,8,
62   0x800, /* number of tiles */
63   4,
64   { 0,1,2,3 },
65   { 0*4,1*4,2*4,3*4, 4*4,5*4,6*4,7*4 },
66   { 0*32,1*32,2*32,3*32, 4*32,5*32,6*32,7*32 },
67   8*32
68};
69
70static const gfx_layout sprite_layout = {
71   16,16,
72   0x200, /* number of sprites */
73   4,
74   { 0*0x4000*8,1*0x4000*8,2*0x4000*8,3*0x4000*8 },
75   { 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15 },
76   {
77      0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,
78      0x80,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0
79   },
80   16*16
81};
82
83static GFXDECODE_START( mrflea )
84   GFXDECODE_ENTRY( "gfx1", 0, sprite_layout,   0x10, 1 )
85   GFXDECODE_ENTRY( "gfx2", 0, tile_layout,   0x00, 1 )
86GFXDECODE_END
87
88/*******************************************************/
89
9055static WRITE8_HANDLER( mrflea_main_w )
9156{
92   mrflea_status |= 0x01; // pending command to main CPU
93   mrflea_main = data;
57   mrflea_state *state = (mrflea_state *)space->machine->driver_data;
58   state->status |= 0x01; // pending command to main CPU
59   state->main = data;
9460}
9561
9662static WRITE8_HANDLER( mrflea_io_w )
9763{
98   mrflea_status |= 0x08; // pending command to IO CPU
99   mrflea_io = data;
100   cputag_set_input_line(space->machine, "sub", 0, HOLD_LINE );
64   mrflea_state *state = (mrflea_state *)space->machine->driver_data;
65   state->status |= 0x08; // pending command to IO CPU
66   state->io = data;
67   cpu_set_input_line(state->subcpu, 0, HOLD_LINE );
10168}
10269
10370static READ8_HANDLER( mrflea_main_r )
10471{
105   mrflea_status &= ~0x01; // main CPU command read
106   return mrflea_main;
72   mrflea_state *state = (mrflea_state *)space->machine->driver_data;
73   state->status &= ~0x01; // main CPU command read
74   return state->main;
10775}
10876
10977static READ8_HANDLER( mrflea_io_r )
11078{
111   mrflea_status &= ~0x08; // IO CPU command read
112   return mrflea_io;
79   mrflea_state *state = (mrflea_state *)space->machine->driver_data;
80   state->status &= ~0x08; // IO CPU command read
81   return state->io;
11382}
11483
115/*******************************************************/
116
11784static READ8_HANDLER( mrflea_main_status_r )
11885{
86   mrflea_state *state = (mrflea_state *)space->machine->driver_data;
87
11988   /*  0x01: main CPU command pending
12089        0x08: io cpu ready */
121   return mrflea_status^0x08;
90   return state->status ^ 0x08;
12291}
12392
12493static READ8_HANDLER( mrflea_io_status_r )
12594{
95   mrflea_state *state = (mrflea_state *)space->machine->driver_data;
96
12697   /*  0x08: IO CPU command pending
12798        0x01: main cpu ready */
128   return mrflea_status^0x01;
99   return state->status ^ 0x01;
129100}
130101
131102static INTERRUPT_GEN( mrflea_slave_interrupt )
132103{
133   if( cpu_getiloops(device)==0 || (mrflea_status&0x08) )
104   mrflea_state *state = (mrflea_state *)device->machine->driver_data;
105   if (cpu_getiloops(device) == 0 || (state->status & 0x08))
134106      cpu_set_input_line(device, 0, HOLD_LINE);
135107}
136108
r7500r7501
140112    1. triggered (in response to sound command)
141113    2. heartbeat (for music timing)
142114*/
143   if( mrflea_status&0x08 ) return 0x00; /* process command */
115   mrflea_state *state = (mrflea_state *)space->machine->driver_data;
116
117   if (state->status & 0x08 )
118      return 0x00; /* process command */
119
144120   return 0x01; /* music/sound update? */
145121}
146122
147/*******************************************************/
123static WRITE8_HANDLER( mrflea_select1_w )
124{
125   mrflea_state *state = (mrflea_state *)space->machine->driver_data;
126   state->select1 = data;
127}
148128
129static READ8_HANDLER( mrflea_input1_r )
130{
131   return 0x00;
132}
133
134static WRITE8_HANDLER( mrflea_data1_w )
135{
136}
137
138/*************************************
139 *
140 *  Address maps
141 *
142 *************************************/
143
149144static ADDRESS_MAP_START( mrflea_master_map, ADDRESS_SPACE_PROGRAM, 8 )
150145   AM_RANGE(0x0000, 0xbfff) AM_ROM
151146   AM_RANGE(0xc000, 0xcfff) AM_RAM
152   AM_RANGE(0xe000, 0xe7ff) AM_RAM_WRITE(mrflea_videoram_w) AM_BASE_GENERIC(videoram)
147   AM_RANGE(0xe000, 0xe7ff) AM_RAM_WRITE(mrflea_videoram_w) AM_BASE_MEMBER(mrflea_state, videoram)
153148   AM_RANGE(0xe800, 0xe83f) AM_RAM_WRITE(paletteram_xxxxRRRRGGGGBBBB_le_w) AM_BASE_GENERIC(paletteram)
154   AM_RANGE(0xec00, 0xecff) AM_RAM_WRITE(mrflea_spriteram_w) AM_BASE_GENERIC(spriteram)
149   AM_RANGE(0xec00, 0xecff) AM_RAM_WRITE(mrflea_spriteram_w) AM_BASE_MEMBER(mrflea_state, spriteram)
155150ADDRESS_MAP_END
156151
157152static ADDRESS_MAP_START( mrflea_master_io_map, ADDRESS_SPACE_IO, 8 )
r7500r7501
164159   AM_RANGE(0x60, 0x60) AM_WRITE(mrflea_gfx_bank_w)
165160ADDRESS_MAP_END
166161
167/*******************************************************/
168162
169static WRITE8_HANDLER( mrflea_select1_w )
170{
171   mrflea_select1 = data;
172}
173
174static READ8_HANDLER( mrflea_input1_r )
175{
176   return 0x00;
177}
178
179static WRITE8_HANDLER( mrflea_data1_w )
180{
181}
182
183163static ADDRESS_MAP_START( mrflea_slave_map, ADDRESS_SPACE_PROGRAM, 8 )
184164   AM_RANGE(0x0000, 0x0fff) AM_ROM
185165   AM_RANGE(0x2000, 0x3fff) AM_ROM
r7500r7501
206186   AM_RANGE(0x46, 0x47) AM_DEVWRITE("ay3", ay8910_data_address_w)
207187ADDRESS_MAP_END
208188
209/*******************************************************/
189/*************************************
190 *
191 *  Input ports
192 *
193 *************************************/
210194
195static INPUT_PORTS_START( mrflea )
196   PORT_START("IN0")
197   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_4WAY
198   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_4WAY
199   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_4WAY
200   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_4WAY
201   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_START1 )
202   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_START2 )
203   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_BUTTON1 )
204   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNKNOWN )
205
206   PORT_START("IN1")
207   PORT_BIT( 0x03, IP_ACTIVE_LOW, IPT_UNKNOWN )
208   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_COIN1 )
209   PORT_BIT( 0xf8, IP_ACTIVE_LOW, IPT_UNKNOWN )
210
211   PORT_START("DSW1")
212/*
213    ------xx
214    -----x--
215    ----x---
216*/
217   PORT_DIPNAME( 0x03, 0x03, "Bonus?" )
218   PORT_DIPSETTING( 0x03, "A" )
219   PORT_DIPSETTING( 0x02, "B" )
220   PORT_DIPSETTING( 0x01, "C" )
221   PORT_DIPSETTING( 0x00, "D" )
222   PORT_DIPNAME( 0x04, 0x04, DEF_STR( Unknown ) )
223   PORT_DIPSETTING( 0x04, DEF_STR( Off ) )
224   PORT_DIPSETTING( 0x00, DEF_STR( On ) )
225   PORT_DIPNAME( 0x08, 0x08, DEF_STR( Unknown ) )
226   PORT_DIPSETTING( 0x08, DEF_STR( Off ) )
227   PORT_DIPSETTING( 0x00, DEF_STR( On ) )
228   PORT_DIPNAME( 0x10, 0x10, DEF_STR( Unused ) )
229   PORT_DIPSETTING( 0x10, DEF_STR( Off ) )
230   PORT_DIPSETTING( 0x00, DEF_STR( On ) )
231   PORT_DIPNAME( 0x20, 0x20, DEF_STR( Unused ) )
232   PORT_DIPSETTING( 0x20, DEF_STR( Off ) )
233   PORT_DIPSETTING( 0x00, DEF_STR( On ) )
234   PORT_DIPNAME( 0x40, 0x40, DEF_STR( Unused ) )
235   PORT_DIPSETTING( 0x40, DEF_STR( Off ) )
236   PORT_DIPSETTING( 0x00, DEF_STR( On ) )
237   PORT_DIPNAME( 0x80, 0x80, DEF_STR( Unused ) )
238   PORT_DIPSETTING( 0x80, DEF_STR( Off ) )
239   PORT_DIPSETTING( 0x00, DEF_STR( On ) )
240
241   PORT_START("DSW2")
242   PORT_DIPNAME( 0x03, 0x03, DEF_STR( Coinage ) )
243   PORT_DIPSETTING( 0x02, DEF_STR( 2C_1C ) )
244   PORT_DIPSETTING( 0x03, DEF_STR( 1C_1C ) )
245   PORT_DIPSETTING( 0x00, DEF_STR( 2C_3C ) )
246   PORT_DIPSETTING( 0x01, DEF_STR( 1C_2C ) )
247   PORT_DIPNAME( 0x0c, 0x0c, DEF_STR( Lives ) )
248   PORT_DIPSETTING( 0x0c, "3" )
249   PORT_DIPSETTING( 0x08, "4" )
250   PORT_DIPSETTING( 0x04, "5" )
251   PORT_DIPSETTING( 0x00, "7" )
252   PORT_DIPNAME( 0x30, 0x30, DEF_STR( Difficulty ) )
253   PORT_DIPSETTING( 0x30, DEF_STR( Easy ) )
254   PORT_DIPSETTING( 0x20, DEF_STR( Medium ) )
255   PORT_DIPSETTING( 0x10, DEF_STR( Hard ) )
256   PORT_DIPSETTING( 0x00, DEF_STR( Hardest ) )
257   PORT_DIPNAME( 0x40, 0x40, DEF_STR( Unused ) )
258   PORT_DIPSETTING( 0x40, DEF_STR( Off ) )
259   PORT_DIPSETTING( 0x00, DEF_STR( On ) )
260   PORT_DIPNAME( 0x80, 0x80, DEF_STR( Unused ) )
261   PORT_DIPSETTING( 0x80, DEF_STR( Off ) )
262   PORT_DIPSETTING( 0x00, DEF_STR( On ) )
263INPUT_PORTS_END
264
265
266/*************************************
267 *
268 *  Graphics definitions
269 *
270 *************************************/
271
272static const gfx_layout tile_layout = {
273   8,8,
274   0x800, /* number of tiles */
275   4,
276   { 0,1,2,3 },
277   { 0*4,1*4,2*4,3*4, 4*4,5*4,6*4,7*4 },
278   { 0*32,1*32,2*32,3*32, 4*32,5*32,6*32,7*32 },
279   8*32
280};
281
282static const gfx_layout sprite_layout = {
283   16,16,
284   0x200, /* number of sprites */
285   4,
286   { 0*0x4000*8,1*0x4000*8,2*0x4000*8,3*0x4000*8 },
287   { 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15 },
288   {
289      0x00,0x10,0x20,0x30,0x40,0x50,0x60,0x70,
290      0x80,0x90,0xa0,0xb0,0xc0,0xd0,0xe0,0xf0
291   },
292   16*16
293};
294
295static GFXDECODE_START( mrflea )
296   GFXDECODE_ENTRY( "gfx1", 0, sprite_layout,   0x10, 1 )
297   GFXDECODE_ENTRY( "gfx2", 0, tile_layout,   0x00, 1 )
298GFXDECODE_END
299
300/*************************************
301 *
302 *  Sound interfaces
303 *
304 *************************************/
305
211306static const ay8910_interface mrflea_ay8910_interface_0 =
212307{
213308   AY8910_LEGACY_OUTPUT,
r7500r7501
224319   DEVCB_INPUT_PORT("DSW1")
225320};
226321
322/*************************************
323 *
324 *  Machine driver
325 *
326 *************************************/
327
328static MACHINE_START( mrflea )
329{
330   mrflea_state *state = (mrflea_state *)machine->driver_data;
331
332   state->maincpu = devtag_get_device(machine, "maincpu");
333   state->subcpu = devtag_get_device(machine, "sub");
334
335   state_save_register_global(machine, state->gfx_bank);
336   state_save_register_global(machine, state->io);
337   state_save_register_global(machine, state->main);
338   state_save_register_global(machine, state->status);
339   state_save_register_global(machine, state->select1);
340}
341
342static MACHINE_RESET( mrflea )
343{
344   mrflea_state *state = (mrflea_state *)machine->driver_data;
345
346   state->gfx_bank = 0;
347   state->io = 0;
348   state->main = 0;
349   state->status = 0;
350   state->select1 = 0;
351}
352
227353static MACHINE_DRIVER_START( mrflea )
228354
355   /* driver data */
356   MDRV_DRIVER_DATA(mrflea_state)
357
229358   /* basic machine hardware */
230359   MDRV_CPU_ADD("maincpu", Z80, 4000000) /* 4 MHz? */
231360   MDRV_CPU_PROGRAM_MAP(mrflea_master_map)
r7500r7501
239368
240369   MDRV_QUANTUM_TIME(HZ(6000))
241370
371   MDRV_MACHINE_START(mrflea)
372   MDRV_MACHINE_RESET(mrflea)
373
242374   /* video hardware */
243375   MDRV_SCREEN_ADD("screen", RASTER)
244376   MDRV_SCREEN_REFRESH_RATE(60)
r7500r7501
250382   MDRV_GFXDECODE(mrflea)
251383   MDRV_PALETTE_LENGTH(32)
252384
253   MDRV_VIDEO_START(mrflea)
254385   MDRV_VIDEO_UPDATE(mrflea)
255386
256387   /* sound hardware */
r7500r7501
268399   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.25)
269400MACHINE_DRIVER_END
270401
402/*************************************
403 *
404 *  ROM definition(s)
405 *
406 *************************************/
407
271408ROM_START( mrflea )
272409   ROM_REGION( 0x10000, "maincpu", 0 ) /* Z80 code; main CPU */
273410   ROM_LOAD( "cpu_d1",   0x0000, 0x2000, CRC(d286217c) SHA1(d750d64bb70f735a38b737881abb9a5fbde1c98c) )
r7500r7501
303440   ROM_LOAD( "vd_l4",   0xe000, 0x2000, CRC(423735a5) SHA1(4ee93f93cd2b08560e148525e08880d64c64fcd2) )
304441ROM_END
305442
306static INPUT_PORTS_START( mrflea )
307   PORT_START("IN0")
308   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_4WAY
309   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_4WAY
310   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_4WAY
311   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_4WAY
312   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_START1 )
313   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_START2 )
314   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_BUTTON1 )
315   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNKNOWN )
443/*************************************
444 *
445 *  Game driver(s)
446 *
447 *************************************/
316448
317   PORT_START("IN1")
318   PORT_BIT( 0x03, IP_ACTIVE_LOW, IPT_UNKNOWN )
319   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_COIN1 )
320   PORT_BIT( 0xf8, IP_ACTIVE_LOW, IPT_UNKNOWN )
321
322   PORT_START("DSW1")      /* DSW1 */
323/*
324    ------xx
325    -----x--
326    ----x---
327*/
328   PORT_DIPNAME( 0x03, 0x03, "Bonus?" )
329   PORT_DIPSETTING( 0x03, "A" )
330   PORT_DIPSETTING( 0x02, "B" )
331   PORT_DIPSETTING( 0x01, "C" )
332   PORT_DIPSETTING( 0x00, "D" )
333   PORT_DIPNAME( 0x04, 0x04, DEF_STR( Unknown ) )
334   PORT_DIPSETTING( 0x04, DEF_STR( Off ) )
335   PORT_DIPSETTING( 0x00, DEF_STR( On ) )
336   PORT_DIPNAME( 0x08, 0x08, DEF_STR( Unknown ) )
337   PORT_DIPSETTING( 0x08, DEF_STR( Off ) )
338   PORT_DIPSETTING( 0x00, DEF_STR( On ) )
339   PORT_DIPNAME( 0x10, 0x10, DEF_STR( Unused ) )
340   PORT_DIPSETTING( 0x10, DEF_STR( Off ) )
341   PORT_DIPSETTING( 0x00, DEF_STR( On ) )
342   PORT_DIPNAME( 0x20, 0x20, DEF_STR( Unused ) )
343   PORT_DIPSETTING( 0x20, DEF_STR( Off ) )
344   PORT_DIPSETTING( 0x00, DEF_STR( On ) )
345   PORT_DIPNAME( 0x40, 0x40, DEF_STR( Unused ) )
346   PORT_DIPSETTING( 0x40, DEF_STR( Off ) )
347   PORT_DIPSETTING( 0x00, DEF_STR( On ) )
348   PORT_DIPNAME( 0x80, 0x80, DEF_STR( Unused ) )
349   PORT_DIPSETTING( 0x80, DEF_STR( Off ) )
350   PORT_DIPSETTING( 0x00, DEF_STR( On ) )
351
352   PORT_START("DSW2")      /* DSW2 */
353   PORT_DIPNAME( 0x03, 0x03, DEF_STR( Coinage ) )
354   PORT_DIPSETTING( 0x02, DEF_STR( 2C_1C ) )
355   PORT_DIPSETTING( 0x03, DEF_STR( 1C_1C ) )
356   PORT_DIPSETTING( 0x00, DEF_STR( 2C_3C ) )
357   PORT_DIPSETTING( 0x01, DEF_STR( 1C_2C ) )
358   PORT_DIPNAME( 0x0c, 0x0c, DEF_STR( Lives ) )
359   PORT_DIPSETTING( 0x0c, "3" )
360   PORT_DIPSETTING( 0x08, "4" )
361   PORT_DIPSETTING( 0x04, "5" )
362   PORT_DIPSETTING( 0x00, "7" )
363   PORT_DIPNAME( 0x30, 0x30, DEF_STR( Difficulty ) )
364   PORT_DIPSETTING( 0x30, DEF_STR( Easy ) )
365   PORT_DIPSETTING( 0x20, DEF_STR( Medium ) )
366   PORT_DIPSETTING( 0x10, DEF_STR( Hard ) )
367   PORT_DIPSETTING( 0x00, DEF_STR( Hardest ) )
368   PORT_DIPNAME( 0x40, 0x40, DEF_STR( Unused ) )
369   PORT_DIPSETTING( 0x40, DEF_STR( Off ) )
370   PORT_DIPSETTING( 0x00, DEF_STR( On ) )
371   PORT_DIPNAME( 0x80, 0x80, DEF_STR( Unused ) )
372   PORT_DIPSETTING( 0x80, DEF_STR( Off ) )
373   PORT_DIPSETTING( 0x00, DEF_STR( On ) )
374INPUT_PORTS_END
375
376
377GAME( 1982, mrflea,   0,        mrflea,   mrflea,   0,        ROT270, "Pacific Novelty", "The Amazing Adventures of Mr. F. Lea" , 0 )
378
449GAME( 1982, mrflea,   0,        mrflea,   mrflea,   0,        ROT270, "Pacific Novelty", "The Amazing Adventures of Mr. F. Lea" , GAME_SUPPORTS_SAVE )
src/mame/drivers/tmaster.c
r7500r7501
10101010
10111011ROM_START( tm )
10121012   ROM_REGION( 0x200000, "maincpu", 0 ) // 68000 Code
1013   ROM_LOAD16_BYTE( "tmaster.u51", 0x000000, 0x080000, CRC(edaa5874) SHA1(48b99bc7f5a6453def265967ca7d8eefdf9dc97b) ) /* Ver: 3.00 Euro 11-25-96 */
1014   ROM_LOAD16_BYTE( "tmaster.u52", 0x000001, 0x080000, CRC(e9fd30fc) SHA1(d91ea05d5f574603883336729fb9df705688945d) ) /* Ver: 3.00 Euro 11-25-96 */
1013   ROM_LOAD16_BYTE( "tmaster_v300_euro.u51", 0x000000, 0x080000, CRC(edaa5874) SHA1(48b99bc7f5a6453def265967ca7d8eefdf9dc97b) ) /* Ver: 3.00 Euro 11-25-96 */
1014   ROM_LOAD16_BYTE( "tmaster_v300_euro.u52", 0x000001, 0x080000, CRC(e9fd30fc) SHA1(d91ea05d5f574603883336729fb9df705688945d) ) /* Ver: 3.00 Euro 11-25-96 */
10151015
10161016   ROM_REGION( 0x400000, "blitter", ROMREGION_ERASE )   // Blitter gfx
1017   ROM_LOAD16_BYTE( "tmaster.u38", 0x100000, 0x080000, CRC(68885ef6) SHA1(010602b59c33c3e490491a296ddaf8952e315b83) )
1018   ROM_LOAD16_BYTE( "tmaster.u36", 0x100001, 0x080000, CRC(204096ec) SHA1(9239923b7eedb6003c63ef2e8ff224edee657bbc) )
1017   ROM_LOAD16_BYTE( "tmaster.u38", 0x100000, 0x080000, CRC(68885ef6) SHA1(010602b59c33c3e490491a296ddaf8952e315b83) ) /* Same as U38 below */
1018   ROM_LOAD16_BYTE( "tmaster.u36", 0x100001, 0x080000, CRC(204096ec) SHA1(9239923b7eedb6003c63ef2e8ff224edee657bbc) ) /* Same as U36 below */
10191019   // unused gap
1020   ROM_LOAD16_BYTE( "tmaster.u39", 0x300000, 0x080000, CRC(cbb716cb) SHA1(4e8d8f6cbfb25a8161ff8fe7505d6b209650dd2b) )
1021   ROM_LOAD16_BYTE( "tmaster.u37", 0x300001, 0x080000, CRC(e0b6a9f7) SHA1(7e057ca87833c682e5be03668469259bbdefbf20) )
1020   ROM_LOAD16_BYTE( "tmaster.u39", 0x300000, 0x080000, CRC(cbb716cb) SHA1(4e8d8f6cbfb25a8161ff8fe7505d6b209650dd2b) ) /* Different then U39 below, newer or region specific? */
1021   ROM_LOAD16_BYTE( "tmaster.u37", 0x300001, 0x080000, CRC(e0b6a9f7) SHA1(7e057ca87833c682e5be03668469259bbdefbf20) ) /* Different then U37 below, newer or region specific? */
10221022
10231023   ROM_REGION( 0x100000, "oki", 0 ) // Samples
1024   ROM_LOAD( "tmaster.u8", 0x40000, 0x040000, CRC(f39ad4cf) SHA1(9bcb9a5dd3636d6541eeb3e737c7253ab0ed4e8d) )
1024   ROM_LOAD( "tmaster.u8", 0x40000, 0x040000, CRC(f39ad4cf) SHA1(9bcb9a5dd3636d6541eeb3e737c7253ab0ed4e8d) ) /* Same as U8 below */
10251025   ROM_CONTINUE(           0xc0000, 0x040000 )
10261026ROM_END
10271027
1028ROM_START( tmdo )
1029   ROM_REGION( 0x200000, "maincpu", 0 ) // 68000 Code
1030   ROM_LOAD16_BYTE( "tmaster_v22-01.u51", 0x000000, 0x080000, CRC(12e1b085) SHA1(b01325e0067204991a707db24e3e2036708ebccf) ) /* Ver: 2.2-01 Standard 10-17-96 */
1031   ROM_LOAD16_BYTE( "tmaster_v22-01.u52", 0x000001, 0x080000, CRC(6c2c643f) SHA1(8dd7930f4c499483ca46b0b97bde94cb8d6e06aa) ) /* Ver: 2.2-01 Standard 10-17-96 */
1032
1033   ROM_REGION( 0x400000, "blitter", ROMREGION_ERASE )   // Blitter gfx
1034   ROM_LOAD16_BYTE( "tmaster.u38", 0x100000, 0x080000, CRC(68885ef6) SHA1(010602b59c33c3e490491a296ddaf8952e315b83) ) /* Marked as Rev 2.1 */
1035   ROM_LOAD16_BYTE( "tmaster.u36", 0x100001, 0x080000, CRC(204096ec) SHA1(9239923b7eedb6003c63ef2e8ff224edee657bbc) ) /* Marked as Rev 2.1 */
1036   // unused gap
1037   ROM_LOAD16_BYTE( "tmaster_v21.u39", 0x300000, 0x080000, CRC(a4445260) SHA1(915347f69d7ea45f8f299a67d77ff437983495d2) ) /* Marked as Rev 2.1 */
1038   ROM_LOAD16_BYTE( "tmaster_v21.u37", 0x300001, 0x080000, CRC(0e140a3e) SHA1(10a34e3b95c0d36fe687fe8c1124ef244a93d720) ) /* Marked as Rev 2.1 */
1039
1040   ROM_REGION( 0x100000, "oki", 0 ) // Samples
1041   ROM_LOAD( "tmaster.u8", 0x40000, 0x040000, CRC(f39ad4cf) SHA1(9bcb9a5dd3636d6541eeb3e737c7253ab0ed4e8d) ) /* Marked as Rev 1.0 */
1042   ROM_CONTINUE(           0xc0000, 0x040000 )
1043ROM_END
1044
10281045/***************************************************************************
10291046
10301047Touchmaster 2000
r7500r7501
11481165
11491166Name_Board Location        Version               Use                      Checksum
11501167-----------------------------------------------------------------------------------
1168TM4K_v603.u51              6.03 Game Program & Cpu instructions 96B0
1169TM4K_v603.u52              6.03 Game Program & Cpu instructions 2842
1170
11511171TM4K_v602.u51              6.02 Game Program & Cpu instructions FEA0
11521172TM4K_v602.u52              6.02 Game Program & Cpu instructions 9A71
1173
11531174TM4K_graphic.u36           6.0  Video Images & Graphics         54f1 (same as TM3K)
11541175TM4K_graphic.u37           6.0  Video Images & Graphics         609E
11551176TM4K_graphic.u38           6.0  Video Images & Graphics         5493 (same as TM3K)
r7500r7501
11681189
11691190ROM_START( tm4k )
11701191   ROM_REGION( 0x200000, "maincpu", 0 ) // 68000 Code
1192   ROM_LOAD16_BYTE( "tm4k_v603.u51", 0x000000, 0x100000, CRC(0c88c856) SHA1(4c60c09812ab05f9dccef3038a5ddbd4632dbf4e) ) /* TOUCHMASTER 4000 U51 DOMESTIC  6.03 (Standard 6-23-98) */
1193   ROM_LOAD16_BYTE( "tm4k_v603.u52", 0x000001, 0x100000, CRC(9320bfe9) SHA1(cc3a51f439c139ca30efe28a817cf4f68679180e) ) /* TOUCHMASTER 4000 U52 DOMESTIC  6.03 (Standard 6-23-98) */
1194
1195   ROM_REGION( 0x600000, "blitter", 0 )   // Blitter gfx
1196   ROM_LOAD16_BYTE( "tm4k_graphic.u38", 0x000000, 0x100000, CRC(a6683899) SHA1(d05024390917cdb1871d030996da8e1eb6460918) ) /* Mask rom labeled 5341-15746-03 U38 VIDEO IMAGE */
1197   ROM_LOAD16_BYTE( "tm4k_graphic.u36", 0x000001, 0x100000, CRC(7bde520d) SHA1(77750b689e2f0d47804042456e54bbd9c28deeac) ) /* Mask rom labeled 5341-15746-01 U36 VIDEO IMAGE */
1198   ROM_LOAD16_BYTE( "tm4k_graphic.u39", 0x200000, 0x100000, CRC(bac88cfb) SHA1(26ed169296b890c5f5b50c418c15299355a6592f) ) /* Mask rom labeled 5341-15746-04 U39 VIDEO IMAGE */
1199   ROM_LOAD16_BYTE( "tm4k_graphic.u37", 0x200001, 0x100000, CRC(bf49fafa) SHA1(b400667bf654dc9cd01a85c8b99670459400fd60) ) /* Mask rom labeled 5341-15746-02 U37 VIDEO IMAGE */
1200   ROM_LOAD16_BYTE( "tm4k_graphic.u41", 0x400000, 0x100000, CRC(e97edb1e) SHA1(75510676cf1692ad03efd4ccd57d25af1cc8ef2a) ) /* Mask rom labeled 5341-15746-06 U41 VIDEO IMAGE */
1201   ROM_LOAD16_BYTE( "tm4k_graphic.u40", 0x400001, 0x100000, CRC(f6771a09) SHA1(74f71d5e910006c83a38170f24aa811c38a3e020) ) /* Mask rom labeled 5341-15746-05 U40 VIDEO IMAGE */
1202
1203   ROM_REGION( 0x100000, "oki", 0 ) // Samples
1204   ROM_LOAD( "tm4k_sound.u8", 0x00000, 0x100000, CRC(48c3782b) SHA1(bfe105ddbde8bbbd84665dfdd565d6d41926834a) ) /* Mask rom labeled 5341-15746-07 U8 SOUND IMAGE */
1205ROM_END
1206
1207ROM_START( tm4ka )
1208   ROM_REGION( 0x200000, "maincpu", 0 ) // 68000 Code
11711209   ROM_LOAD16_BYTE( "tm4k_v602.u51", 0x000000, 0x100000, CRC(3d8d7848) SHA1(31638f23cdd5e6cfbb2270e953f84fe1bd437950) ) /* TOUCHMASTER 4000 U51 DOMESTIC  6.02 (Standard 4-14-98) */
11721210   ROM_LOAD16_BYTE( "tm4k_v602.u52", 0x000001, 0x100000, CRC(6d412871) SHA1(ae27c7723b292daf6682c53bafac22e4a3cd1ece) ) /* TOUCHMASTER 4000 U52 DOMESTIC  6.02 (Standard 4-14-98) */
11731211
r7500r7501
14921530   UINT16 *ROM = (UINT16 *)memory_region( machine, "maincpu" );
14931531
14941532   // protection
1533   ROM[0x834ce/2] = 0x4e75;
1534
1535   ROM[0x8349c/2] = 0x6002;
1536   ROM[0x834c4/2] = 0x6002;
1537/*
1538
1539Protection resembles that of tm5k rather than tm4ka:
1540
1541 83470: addi.w  #$384, D0       0640 0384
1542 83474: move.w  D0, $207a86.l   33C0 0020 7A86
1543
1544*/
1545
1546}
1547
1548
1549static DRIVER_INIT( tm4ka )
1550{
1551   UINT16 *ROM = (UINT16 *)memory_region( machine, "maincpu" );
1552
1553   // protection
14951554   ROM[0x83476/2] = 0x4e75;
14961555
14971556   ROM[0x8342C/2] = 0x601a;
r7500r7501
17111770}
17121771
17131772
1714GAME( 1996, tm,       0,        tm,       tm,       0,        ROT0, "Midway",                                  "Touchmaster (v3.00 Euro)",            0 )
1715GAME( 1996, tm2k,     0,        tm3k,     tmaster,  0,        ROT0, "Midway",                                  "Touchmaster 2000 (v4.02 Standard)",   0 )
1716GAME( 1997, tm3k,     0,        tm3k,     tmaster,  0,        ROT0, "Midway",                                  "Touchmaster 3000 (v5.02 Standard)",   0 )
1717GAME( 1997, tm3ka,    tm3k,     tm3k,     tmaster,  0,        ROT0, "Midway",                                  "Touchmaster 3000 (v5.01 Standard)",   0 )
1718GAME( 1998, tm4k,     0,        tm3k,     tmaster,  tm4k,     ROT0, "Midway",                                  "Touchmaster 4000 (v6.02 Standard)",   0 )
1719GAME( 1998, tm5k,     0,        tm3k,     tmaster,  tm5k,     ROT0, "Midway",                                  "Touchmaster 5000 (v7.10 Standard)",   0 )
1720GAME( 1998, tm5kca,   tm5k,     tm3k,     tmaster,  tm5kca,   ROT0, "Midway",                                  "Touchmaster 5000 (v7.10 California)", 0 )
1721GAME( 1998, tm5ka,    tm5k,     tm3k,     tmaster,  tm5ka,    ROT0, "Midway",                                  "Touchmaster 5000 (v7.01 Standard)",   0 )
1722GAME( 1999, tm7k,     0,        tm3k,     tmaster,  tm7k,     ROT0, "Midway",                                  "Touchmaster 7000 (v8.04 Standard)",   0 )
1723GAME( 1999, tm7ka,    tm7k,     tm3k,     tmaster,  tm7ka,    ROT0, "Midway",                                  "Touchmaster 7000 (v8.00 Standard)",   0 )
1724GAME( 1999, tm7keval, tm7k,     tm3k,     tmaster,  tm7keval, ROT0, "Midway",                                  "Touchmaster 7000 (v8.1X Evaluation)", 0 )
1725GAME( 2000, tm8k,     0,        tm3k,     tmaster,  tm8k,     ROT0, "Midway",                                  "Touchmaster 8000 (v9.04 Standard)",   0 )
1773GAME( 1996, tm,       0,        tm,       tm,       0,        ROT0, "CES Inc., Midway Games Inc.",             "Touchmaster (v3.00 Euro)",            0 )
1774GAME( 1996, tmdo,     tm,       tm,       tm,       0,        ROT0, "CES Inc., Midway Games Inc.",             "Touchmaster (v2.2-01 Standard)",      0 )
1775GAME( 1996, tm2k,     0,        tm3k,     tmaster,  0,        ROT0, "Midway Games Inc.",                       "Touchmaster 2000 (v4.02 Standard)",   0 )
1776GAME( 1997, tm3k,     0,        tm3k,     tmaster,  0,        ROT0, "Midway Games Inc.",                       "Touchmaster 3000 (v5.02 Standard)",   0 )
1777GAME( 1997, tm3ka,    tm3k,     tm3k,     tmaster,  0,        ROT0, "Midway Games Inc.",                       "Touchmaster 3000 (v5.01 Standard)",   0 )
1778GAME( 1998, tm4k,     0,        tm3k,     tmaster,  tm4k,     ROT0, "Midway Games Inc.",                       "Touchmaster 4000 (v6.03 Standard)",   0 )
1779GAME( 1998, tm4ka,    tm4k,     tm3k,     tmaster,  tm4ka,    ROT0, "Midway Games Inc.",                       "Touchmaster 4000 (v6.02 Standard)",   0 )
1780GAME( 1998, tm5k,     0,        tm3k,     tmaster,  tm5k,     ROT0, "Midway Games Inc.",                       "Touchmaster 5000 (v7.10 Standard)",   0 )
1781GAME( 1998, tm5kca,   tm5k,     tm3k,     tmaster,  tm5kca,   ROT0, "Midway Games Inc.",                       "Touchmaster 5000 (v7.10 California)", 0 )
1782GAME( 1998, tm5ka,    tm5k,     tm3k,     tmaster,  tm5ka,    ROT0, "Midway Games Inc.",                       "Touchmaster 5000 (v7.01 Standard)",   0 )
1783GAME( 1999, tm7k,     0,        tm3k,     tmaster,  tm7k,     ROT0, "Midway Games Inc.",                       "Touchmaster 7000 (v8.04 Standard)",   0 )
1784GAME( 1999, tm7ka,    tm7k,     tm3k,     tmaster,  tm7ka,    ROT0, "Midway Games Inc.",                       "Touchmaster 7000 (v8.00 Standard)",   0 )
1785GAME( 1999, tm7keval, tm7k,     tm3k,     tmaster,  tm7keval, ROT0, "Midway Games Inc.",                       "Touchmaster 7000 (v8.1X Evaluation)", 0 )
1786GAME( 2000, tm8k,     0,        tm3k,     tmaster,  tm8k,     ROT0, "Midway Games Inc.",                       "Touchmaster 8000 (v9.04 Standard)",   0 )
17261787GAME( 1998, galgbios, 0,        galgames, galgames, galgames, ROT0, "Creative Electronics & Software",         "Galaxy Games (BIOS v1.90)",           GAME_IS_BIOS_ROOT )
17271788GAME( 1998, galgame2, galgbios, galgame2, galgames, galgame2, ROT0, "Creative Electronics & Software / Namco", "Galaxy Games StarPak 2",              0 )
src/mame/drivers/flyball.c
r7500r7501
1111
1212
1313
14typedef struct _flyball_state flyball_state;
15struct _flyball_state
14class flyball_state
1615{
16public:
17   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, flyball_state(machine)); }
18
19   flyball_state(running_machine &machine) { }
20
1721   /* memory pointers */
1822   UINT8 *  rombase;
1923   UINT8 *  playfield_ram;
src/mame/drivers/laserbas.c
r7500r7501
2020#include "cpu/z80/z80.h"
2121#include "deprecat.h"
2222
23typedef struct _laserbas_state laserbas_state;
24struct _laserbas_state
23class laserbas_state
2524{
25public:
26   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, laserbas_state(machine)); }
27
28   laserbas_state(running_machine &machine) { }
29
2630   /* video-related */
2731   UINT8    *vram1;
2832   UINT8    *vram2;
src/mame/drivers/mikie.c
r7500r7501
11/***************************************************************************
22
3Mikie memory map (preliminary)
3    Mikie memory map (preliminary)
44
5driver by Allard Van Der Bas
5    driver by Allard Van Der Bas
66
77
8MAIN BOARD:
92800-288f Sprite RAM (288f, not 287f - quite unusual)
103800-3bff Color RAM
113c00-3fff Video RAM
124000-5fff ROM (?)
135ff0      Watchdog (?)
146000-ffff ROM
8    MAIN BOARD:
9    2800-288f Sprite RAM (288f, not 287f - quite unusual)
10    3800-3bff Color RAM
11    3c00-3fff Video RAM
12    4000-5fff ROM (?)
13    5ff0      Watchdog (?)
14    6000-ffff ROM
1515
1616
1717***************************************************************************/
r7500r7501
2121#include "cpu/m6809/m6809.h"
2222#include "sound/sn76496.h"
2323#include "includes/konamipt.h"
24#include "includes/mikie.h"
2425
25extern UINT8 *mikie_videoram;
26extern UINT8 *mikie_colorram;
2726
28extern WRITE8_HANDLER( mikie_videoram_w );
29extern WRITE8_HANDLER( mikie_colorram_w );
30extern WRITE8_HANDLER( mikie_palettebank_w );
31extern WRITE8_HANDLER( mikie_flipscreen_w );
27#define MIKIE_TIMER_RATE 512
3228
33extern PALETTE_INIT( mikie );
34extern VIDEO_START( mikie );
35extern VIDEO_UPDATE( mikie );
29#define XTAL   14318180
30#define OSC      18432000
31#define CLK      XTAL/4
3632
37/* Read/Write Handlers */
3833
34/*************************************
35 *
36 *  Memory handlers
37 *
38 *************************************/
39
3940static READ8_HANDLER( mikie_sh_timer_r )
4041{
41   int clock;
42   int clock = cpu_get_total_cycles(space->cpu) / MIKIE_TIMER_RATE;
4243
43   #define TIMER_RATE 512
44
45   clock = cpu_get_total_cycles(space->cpu) / TIMER_RATE;
46
4744   return clock;
4845}
4946
5047static WRITE8_HANDLER( mikie_sh_irqtrigger_w )
5148{
52   static int last;
49   mikie_state *state = (mikie_state *)space->machine->driver_data;
5350
54   if (last == 0 && data == 1)
51   if (state->last_irq == 0 && data == 1)
5552   {
5653      // setting bit 0 low then high triggers IRQ on the sound CPU
57      cputag_set_input_line_and_vector(space->machine, "audiocpu", 0, HOLD_LINE, 0xff);
54      cpu_set_input_line_and_vector(state->audiocpu, 0, HOLD_LINE, 0xff);
5855   }
5956
60   last = data;
57   state->last_irq = data;
6158}
6259
6360static WRITE8_HANDLER( mikie_coin_counter_w )
r7500r7501
6562   coin_counter_w(space->machine, offset, data);
6663}
6764
68/* Memory Maps */
65/*************************************
66 *
67 *  Address maps
68 *
69 *************************************/
6970
7071static ADDRESS_MAP_START( mikie_map, ADDRESS_SPACE_PROGRAM, 8 )
7172   AM_RANGE(0x0000, 0x00ff) AM_RAM
r7500r7501
8283   AM_RANGE(0x2403, 0x2403) AM_READ_PORT("DSW2")
8384   AM_RANGE(0x2500, 0x2500) AM_READ_PORT("DSW0")
8485   AM_RANGE(0x2501, 0x2501) AM_READ_PORT("DSW1")
85   AM_RANGE(0x2800, 0x288f) AM_RAM AM_BASE_SIZE_GENERIC(spriteram)
86   AM_RANGE(0x2800, 0x288f) AM_RAM AM_BASE_SIZE_MEMBER(mikie_state, spriteram, spriteram_size)
8687   AM_RANGE(0x2890, 0x37ff) AM_RAM
87   AM_RANGE(0x3800, 0x3bff) AM_RAM_WRITE(mikie_colorram_w) AM_BASE(&mikie_colorram)
88   AM_RANGE(0x3c00, 0x3fff) AM_RAM_WRITE(mikie_videoram_w) AM_BASE(&mikie_videoram)
88   AM_RANGE(0x3800, 0x3bff) AM_RAM_WRITE(mikie_colorram_w) AM_BASE_MEMBER(mikie_state, colorram)
89   AM_RANGE(0x3c00, 0x3fff) AM_RAM_WRITE(mikie_videoram_w) AM_BASE_MEMBER(mikie_state, videoram)
8990   AM_RANGE(0x4000, 0x5fff) AM_ROM   // Machine checks for extra rom
9091   AM_RANGE(0x6000, 0xffff) AM_ROM
9192ADDRESS_MAP_END
r7500r7501
103104   AM_RANGE(0xa003, 0xa003) AM_WRITENOP   // ???
104105ADDRESS_MAP_END
105106
106/* Input Ports */
107/*************************************
108 *
109 *  Input ports
110 *
111 *************************************/
107112
108113static INPUT_PORTS_START( mikie )
109114   PORT_START("SYSTEM")
r7500r7501
152157   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
153158INPUT_PORTS_END
154159
155/* Graphics Layouts */
156160
161/*************************************
162 *
163 *  Graphics definitions
164 *
165 *************************************/
166
157167static const gfx_layout charlayout =
158168{
159169   8,8,    /* 8*8 characters */
r7500r7501
178188   128*8   /* every sprite takes 64 bytes */
179189};
180190
181/* Graphics Decode Information */
182
183191static GFXDECODE_START( mikie )
184192   GFXDECODE_ENTRY( "gfx1", 0x0000, charlayout,         0, 16*8 )
185193   GFXDECODE_ENTRY( "gfx2", 0x0000, spritelayout, 16*8*16, 16*8 )
186194   GFXDECODE_ENTRY( "gfx2", 0x0001, spritelayout, 16*8*16, 16*8 )
187195GFXDECODE_END
188196
189/* Sound Interface */
190197
191#define XTAL   14318180
192#define OSC      18432000
193#define CLK      XTAL/4
198/*************************************
199 *
200 *  Machine driver
201 *
202 *************************************/
194203
195/* Machine Driver */
204static MACHINE_START( mikie )
205{
206   mikie_state *state = (mikie_state *)machine->driver_data;
196207
208   state->maincpu = devtag_get_device(machine, "maincpu");
209   state->audiocpu = devtag_get_device(machine, "audiocpu");
210
211   state_save_register_global(machine, state->palettebank);
212   state_save_register_global(machine, state->last_irq);
213}
214
215static MACHINE_RESET( mikie )
216{
217   mikie_state *state = (mikie_state *)machine->driver_data;
218
219   state->palettebank = 0;
220   state->last_irq = 0;
221}
222
197223static MACHINE_DRIVER_START( mikie )
198   // basic machine hardware
224
225   /* driver data */
226   MDRV_DRIVER_DATA(mikie_state)
227
228   /* basic machine hardware */
199229   MDRV_CPU_ADD("maincpu", M6809, OSC/12)
200230   MDRV_CPU_PROGRAM_MAP(mikie_map)
201231   MDRV_CPU_VBLANK_INT("screen", irq0_line_hold)
r7500r7501
203233   MDRV_CPU_ADD("audiocpu", Z80, CLK)
204234   MDRV_CPU_PROGRAM_MAP(sound_map)
205235
206   // video hardware
236   MDRV_MACHINE_START(mikie)
237   MDRV_MACHINE_RESET(mikie)
207238
239   /* video hardware */
208240   MDRV_SCREEN_ADD("screen", RASTER)
209241   MDRV_SCREEN_REFRESH_RATE(60.59)
210242   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(0))
r7500r7501
219251   MDRV_VIDEO_START(mikie)
220252   MDRV_VIDEO_UPDATE(mikie)
221253
222   // sound hardware
254   /* sound hardware */
223255   // on the pcb there are 2x76489AN but SN76489 sounds correct in the locker room level (sound test 24)
224256   MDRV_SPEAKER_STANDARD_MONO("mono")
225257
r7500r7501
230262   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.60)
231263MACHINE_DRIVER_END
232264
233/* ROMs */
265/*************************************
266 *
267 *  ROM definition(s)
268 *
269 *************************************/
234270
235271ROM_START( mikie )
236272   ROM_REGION( 0x10000, "maincpu", 0 )
r7500r7501
310346   ROM_LOAD( "d18.f9",  0x0400, 0x0100, CRC(7396b374) SHA1(fedcc421a61d6623dc9c41b0a3e164efeb50ec7c) )   // sprite lookup table
311347ROM_END
312348
313/* Game Drivers */
349/*************************************
350 *
351 *  Game driver(s)
352 *
353 *************************************/
314354
315GAME( 1984, mikie,   0,     mikie, mikie, 0, ROT270, "Konami", "Mikie", 0 )
316GAME( 1984, mikiej,  mikie, mikie, mikie, 0, ROT270, "Konami", "Shinnyuushain Tooru-kun", 0 )
317GAME( 1984, mikiehs, mikie, mikie, mikie, 0, ROT270, "Konami", "Mikie (High School Graffiti)", 0 )
355GAME( 1984, mikie,   0,     mikie, mikie, 0, ROT270, "Konami", "Mikie", GAME_SUPPORTS_SAVE )
356GAME( 1984, mikiej,  mikie, mikie, mikie, 0, ROT270, "Konami", "Shinnyuushain Tooru-kun", GAME_SUPPORTS_SAVE )
357GAME( 1984, mikiehs, mikie, mikie, mikie, 0, ROT270, "Konami", "Mikie (High School Graffiti)", GAME_SUPPORTS_SAVE )
src/mame/drivers/clayshoo.c
r7500r7501
1717#include "machine/8255ppi.h"
1818
1919
20typedef struct _clayshoo_state clayshoo_state;
21struct _clayshoo_state
20class clayshoo_state
2221{
22public:
23   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, clayshoo_state(machine)); }
24
25   clayshoo_state(running_machine &machine) { }
26
2327   /* memory pointers */
2428   UINT8 *   videoram;
2529   size_t    videoram_size;
src/mame/drivers/cbuster.c
r7500r7501
1919#include "emu.h"
2020#include "cpu/m68000/m68000.h"
2121#include "cpu/h6280/h6280.h"
22#include "includes/cbuster.h"
2223#include "sound/2203intf.h"
2324#include "sound/2151intf.h"
2425#include "sound/okim6295.h"
25#include "includes/deco16ic.h"
26#include "video/deco16ic.h"
2627
27VIDEO_START( twocrude );
28VIDEO_UPDATE( twocrude );
2928
30WRITE16_HANDLER( twocrude_palette_24bit_rg_w );
31WRITE16_HANDLER( twocrude_palette_24bit_b_w );
32
33static UINT16 *twocrude_ram;
34extern void twocrude_pri_w(int pri);
35static UINT16 prot;
36
37/******************************************************************************/
38
3929static WRITE16_HANDLER( twocrude_control_w )
4030{
31   cbuster_state *state = (cbuster_state *)space->machine->driver_data;
32
4133   switch (offset << 1)
4234   {
4335   case 0: /* DMA flag */
r7500r7501
4941
5042    case 2: /* Sound CPU write */
5143      soundlatch_w(space, 0, data & 0xff);
52      cputag_set_input_line(space->machine, "audiocpu", 0, HOLD_LINE);
44      cpu_set_input_line(state->audiocpu, 0, HOLD_LINE);
5345       return;
5446
5547   case 4: /* Protection, maybe this is a PAL on the board?
r7500r7501
6961            protection?!
7062
7163        */
72      if ((data & 0xffff) == 0x9a00) prot = 0;
73      if ((data & 0xffff) == 0xaa)   prot = 0x74;
74      if ((data & 0xffff) == 0x0200) prot = 0x63 << 8;
75      if ((data & 0xffff) == 0x9a)   prot = 0xe;
76      if ((data & 0xffff) == 0x55)   prot = 0x1e;
77      if ((data & 0xffff) == 0x0e)  {prot = 0x0e; twocrude_pri_w(0);} /* start */
78      if ((data & 0xffff) == 0x00)  {prot = 0x0e; twocrude_pri_w(0);} /* level 0 */
79      if ((data & 0xffff) == 0xf1)  {prot = 0x36; twocrude_pri_w(1);} /* level 1 */
80      if ((data & 0xffff) == 0x80)  {prot = 0x2e; twocrude_pri_w(1);} /* level 2 */
81      if ((data & 0xffff) == 0x40)  {prot = 0x1e; twocrude_pri_w(1);} /* level 3 */
82      if ((data & 0xffff) == 0xc0)  {prot = 0x3e; twocrude_pri_w(0);} /* level 4 */
83      if ((data & 0xffff) == 0xff)  {prot = 0x76; twocrude_pri_w(1);} /* level 5 */
64      if ((data & 0xffff) == 0x9a00) state->prot = 0;
65      if ((data & 0xffff) == 0xaa)   state->prot = 0x74;
66      if ((data & 0xffff) == 0x0200) state->prot = 0x63 << 8;
67      if ((data & 0xffff) == 0x9a)   state->prot = 0xe;
68      if ((data & 0xffff) == 0x55)   state->prot = 0x1e;
69      if ((data & 0xffff) == 0x0e)  {state->prot = 0x0e; state->pri = 0;} /* start */
70      if ((data & 0xffff) == 0x00)  {state->prot = 0x0e; state->pri = 0;} /* level 0 */
71      if ((data & 0xffff) == 0xf1)  {state->prot = 0x36; state->pri = 1;} /* level 1 */
72      if ((data & 0xffff) == 0x80)  {state->prot = 0x2e; state->pri = 1;} /* level 2 */
73      if ((data & 0xffff) == 0x40)  {state->prot = 0x1e; state->pri = 1;} /* level 3 */
74      if ((data & 0xffff) == 0xc0)  {state->prot = 0x3e; state->pri = 0;} /* level 4 */
75      if ((data & 0xffff) == 0xff)  {state->prot = 0x76; state->pri = 1;} /* level 5 */
8476
8577      break;
8678   }
r7500r7501
8981
9082static READ16_HANDLER( twocrude_control_r )
9183{
92   switch (offset<<1)
84   cbuster_state *state = (cbuster_state *)space->machine->driver_data;
85
86   switch (offset << 1)
9387   {
9488      case 0: /* Player 1 & Player 2 joysticks & fire buttons */
9589         return input_port_read(space->machine, "P1_P2");
r7500r7501
9892         return input_port_read(space->machine, "DSW");
9993
10094      case 4: /* Protection */
101         logerror("%04x : protection control read at 30c000 %d\n",cpu_get_pc(space->cpu),offset);
102         return prot;
95         logerror("%04x : protection control read at 30c000 %d\n", cpu_get_pc(space->cpu), offset);
96         return state->prot;
10397
10498      case 6: /* Credits, VBL in byte 7 */
10599         return input_port_read(space->machine, "COINS");
r7500r7501
112106
113107static ADDRESS_MAP_START( twocrude_map, ADDRESS_SPACE_PROGRAM, 16 )
114108   AM_RANGE(0x000000, 0x07ffff) AM_ROM
115   AM_RANGE(0x080000, 0x083fff) AM_RAM AM_BASE(&twocrude_ram)
109   AM_RANGE(0x080000, 0x083fff) AM_RAM AM_BASE_MEMBER(cbuster_state, ram)
116110
117   AM_RANGE(0x0a0000, 0x0a1fff) AM_RAM_WRITE(deco16_pf1_data_w) AM_BASE(&deco16_pf1_data)
118   AM_RANGE(0x0a2000, 0x0a2fff) AM_RAM_WRITE(deco16_pf2_data_w) AM_BASE(&deco16_pf2_data)
119   AM_RANGE(0x0a4000, 0x0a47ff) AM_RAM AM_BASE(&deco16_pf1_rowscroll)
120   AM_RANGE(0x0a6000, 0x0a67ff) AM_RAM AM_BASE(&deco16_pf2_rowscroll)
111   AM_RANGE(0x0a0000, 0x0a1fff) AM_DEVREADWRITE("deco_custom", deco16ic_pf1_data_r, deco16ic_pf1_data_w)
112   AM_RANGE(0x0a2000, 0x0a2fff) AM_DEVREADWRITE("deco_custom", deco16ic_pf2_data_r, deco16ic_pf2_data_w)
113   AM_RANGE(0x0a4000, 0x0a47ff) AM_RAM AM_BASE_MEMBER(cbuster_state, pf1_rowscroll)
114   AM_RANGE(0x0a6000, 0x0a67ff) AM_RAM AM_BASE_MEMBER(cbuster_state, pf2_rowscroll)
121115
122   AM_RANGE(0x0a8000, 0x0a8fff) AM_RAM_WRITE(deco16_pf3_data_w) AM_BASE(&deco16_pf3_data)
123   AM_RANGE(0x0aa000, 0x0aafff) AM_RAM_WRITE(deco16_pf4_data_w) AM_BASE(&deco16_pf4_data)
124   AM_RANGE(0x0ac000, 0x0ac7ff) AM_RAM AM_BASE(&deco16_pf3_rowscroll)
125   AM_RANGE(0x0ae000, 0x0ae7ff) AM_RAM AM_BASE(&deco16_pf4_rowscroll)
116   AM_RANGE(0x0a8000, 0x0a8fff) AM_DEVREADWRITE("deco_custom", deco16ic_pf3_data_r, deco16ic_pf3_data_w)
117   AM_RANGE(0x0aa000, 0x0aafff) AM_DEVREADWRITE("deco_custom", deco16ic_pf4_data_r, deco16ic_pf4_data_w)
118   AM_RANGE(0x0ac000, 0x0ac7ff) AM_RAM AM_BASE_MEMBER(cbuster_state, pf3_rowscroll)
119   AM_RANGE(0x0ae000, 0x0ae7ff) AM_RAM AM_BASE_MEMBER(cbuster_state, pf4_rowscroll)
126120
127121   AM_RANGE(0x0b0000, 0x0b07ff) AM_RAM AM_BASE_SIZE_GENERIC(spriteram)
128122   AM_RANGE(0x0b4000, 0x0b4001) AM_WRITENOP
129   AM_RANGE(0x0b5000, 0x0b500f) AM_WRITEONLY AM_BASE(&deco16_pf12_control)
130   AM_RANGE(0x0b6000, 0x0b600f) AM_WRITEONLY AM_BASE(&deco16_pf34_control)
123   AM_RANGE(0x0b5000, 0x0b500f) AM_DEVWRITE("deco_custom", deco16ic_pf12_control_w)
124   AM_RANGE(0x0b6000, 0x0b600f) AM_DEVWRITE("deco_custom", deco16ic_pf34_control_w)
131125   AM_RANGE(0x0b8000, 0x0b8fff) AM_RAM_WRITE(twocrude_palette_24bit_rg_w) AM_BASE_GENERIC(paletteram)
132126   AM_RANGE(0x0b9000, 0x0b9fff) AM_RAM_WRITE(twocrude_palette_24bit_b_w) AM_BASE_GENERIC(paletteram2)
133127   AM_RANGE(0x0bc000, 0x0bc00f) AM_READWRITE(twocrude_control_r, twocrude_control_w)
r7500r7501
168162   PORT_BIT( 0x4000, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_PLAYER(2)
169163   PORT_BIT( 0x8000, IP_ACTIVE_LOW, IPT_START2 )
170164
171   PORT_START("COINS")   /* Credits */
165   PORT_START("COINS")
172166   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_COIN1 )
173167   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_COIN2 )
174168   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_COIN3 )
r7500r7501
272266
273267static void sound_irq(running_device *device, int state)
274268{
275   cputag_set_input_line(device->machine, "audiocpu", 1, state); /* IRQ 2 */
269   cbuster_state *driver_state = (cbuster_state *)device->machine->driver_data;
270   cpu_set_input_line(driver_state->audiocpu, 1, state); /* IRQ 2 */
276271}
277272
278273static const ym2151_interface ym2151_config =
r7500r7501
280275   sound_irq
281276};
282277
278static int twocrude_bank_callback( const int bank )
279{
280   return ((bank >> 4) & 0x7) * 0x1000;
281}
282
283static const deco16ic_interface twocrude_deco16ic_intf =
284{
285   "screen",
286   0, 0, 1,
287   0x0f, 0x0f, 0x0f, 0x0f,   /* trans masks (default values) */
288   0x00, 0x20, 0x30, 0x40, /* color base (default values) */
289   0x0f, 0x0f, 0x0f, 0x0f,   /* color masks (default values) */
290   twocrude_bank_callback,
291   twocrude_bank_callback,
292   twocrude_bank_callback,
293   twocrude_bank_callback
294};
295
296static MACHINE_START( cbuster )
297{
298   cbuster_state *state = (cbuster_state *)machine->driver_data;
299
300   state->maincpu = devtag_get_device(machine, "maincpu");
301   state->audiocpu = devtag_get_device(machine, "audiocpu");
302   state->deco16ic = devtag_get_device(machine, "deco_custom");
303
304   state_save_register_global(machine, state->prot);
305   state_save_register_global(machine, state->pri);
306}
307
308static MACHINE_RESET( cbuster )
309{
310   cbuster_state *state = (cbuster_state *)machine->driver_data;
311
312   state->prot = 0;
313   state->pri = 0;
314}
315
283316static MACHINE_DRIVER_START( twocrude )
284317
318   /* driver data */
319   MDRV_DRIVER_DATA(cbuster_state)
320
285321   /* basic machine hardware */
286322   MDRV_CPU_ADD("maincpu", M68000, 12000000) /* Custom chip 59 */
287323   MDRV_CPU_PROGRAM_MAP(twocrude_map)
r7500r7501
290326   MDRV_CPU_ADD("audiocpu", H6280,32220000/4) /* Custom chip 45, Audio section crystal is 32.220 MHz */
291327   MDRV_CPU_PROGRAM_MAP(sound_map)
292328
329   MDRV_MACHINE_START(cbuster)
330   MDRV_MACHINE_RESET(cbuster)
331
293332   /* video hardware */
294333   MDRV_VIDEO_ATTRIBUTES(VIDEO_BUFFERS_SPRITERAM)
295334
r7500r7501
303342   MDRV_GFXDECODE(cbuster)
304343   MDRV_PALETTE_LENGTH(2048)
305344
306   MDRV_VIDEO_START(twocrude)
307345   MDRV_VIDEO_UPDATE(twocrude)
308346
347   MDRV_DECO16IC_ADD("deco_custom", twocrude_deco16ic_intf)
348
309349   /* sound hardware */
310350   MDRV_SPEAKER_STANDARD_MONO("mono")
311351
r7500r7501
486526{
487527   UINT8 *RAM = memory_region(machine, "maincpu");
488528   UINT8 *PTR;
489   int i,j;
529   int i, j;
490530
491531   /* Main cpu decrypt */
492   for (i=0x00000; i<0x80000; i+=2) {
493      int h = i+NATIVE_ENDIAN_VALUE_LE_BE(1,0), l = i+NATIVE_ENDIAN_VALUE_LE_BE(0,1);
532   for (i = 0x00000; i < 0x80000; i += 2)
533   {
534      int h = i + NATIVE_ENDIAN_VALUE_LE_BE(1,0), l = i + NATIVE_ENDIAN_VALUE_LE_BE(0,1);
494535
495      RAM[h]=(RAM[h] & 0xcf) | ((RAM[h] & 0x10) << 1) | ((RAM[h] & 0x20) >> 1);
496      RAM[h]=(RAM[h] & 0x5f) | ((RAM[h] & 0x20) << 2) | ((RAM[h] & 0x80) >> 2);
536      RAM[h] = (RAM[h] & 0xcf) | ((RAM[h] & 0x10) << 1) | ((RAM[h] & 0x20) >> 1);
537      RAM[h] = (RAM[h] & 0x5f) | ((RAM[h] & 0x20) << 2) | ((RAM[h] & 0x80) >> 2);
497538
498      RAM[l]=(RAM[l] & 0xbd) | ((RAM[l] & 0x2) << 5) | ((RAM[l] & 0x40) >> 5);
499      RAM[l]=(RAM[l] & 0xf5) | ((RAM[l] & 0x2) << 2) | ((RAM[l] & 0x8) >> 2);
539      RAM[l] = (RAM[l] & 0xbd) | ((RAM[l] & 0x2) << 5) | ((RAM[l] & 0x40) >> 5);
540      RAM[l] = (RAM[l] & 0xf5) | ((RAM[l] & 0x2) << 2) | ((RAM[l] & 0x8) >> 2);
500541   }
501542
502543   /* Rearrange the 'extra' sprite bank to be in the same format as main sprites */
503544   RAM = memory_region(machine, "gfx3") + 0x080000;
504545   PTR = memory_region(machine, "gfx3") + 0x140000;
505   for (i=0; i<0x20000; i+=64) {
506      for (j=0; j<16; j+=1) { /* Copy 16 lines down */
507         RAM[i+      0+j*2]=PTR[i/2+      0+j]; /* Pixels 0-7 for each plane */
508         RAM[i+      1+j*2]=PTR[i/2+0x10000+j];
509         RAM[i+0xa0000+j*2]=PTR[i/2+0x20000+j];
510         RAM[i+0xa0001+j*2]=PTR[i/2+0x30000+j];
546   for (i = 0; i < 0x20000; i += 64)
547   {
548      for (j = 0; j < 16; j += 1)
549      { /* Copy 16 lines down */
550         RAM[i +       0 + j * 2] = PTR[i / 2 +       0 + j]; /* Pixels 0-7 for each plane */
551         RAM[i +       1 + j * 2] = PTR[i / 2 + 0x10000 + j];
552         RAM[i + 0xa0000 + j * 2] = PTR[i / 2 + 0x20000 + j];
553         RAM[i + 0xa0001 + j * 2] = PTR[i / 2 + 0x30000 + j];
511554      }
512555
513      for (j=0; j<16; j+=1) { /* Copy 16 lines down */
514         RAM[i+   0x20+j*2]=PTR[i/2+   0x10+j]; /* Pixels 8-15 for each plane */
515         RAM[i+   0x21+j*2]=PTR[i/2+0x10010+j];
516         RAM[i+0xa0020+j*2]=PTR[i/2+0x20010+j];
517         RAM[i+0xa0021+j*2]=PTR[i/2+0x30010+j];
556      for (j = 0; j < 16; j += 1)
557      { /* Copy 16 lines down */
558         RAM[i +    0x20 + j * 2] = PTR[i / 2 +    0x10 + j]; /* Pixels 8-15 for each plane */
559         RAM[i +    0x21 + j * 2] = PTR[i / 2 + 0x10010 + j];
560         RAM[i + 0xa0020 + j * 2] = PTR[i / 2 + 0x20010 + j];
561         RAM[i + 0xa0021 + j * 2] = PTR[i / 2 + 0x30010 + j];
518562      }
519563   }
520564}
521565
522566/******************************************************************************/
523567
524GAME( 1990, cbuster,  0,       twocrude, twocrude, twocrude, ROT0, "Data East Corporation", "Crude Buster (World FX version)", 0 )
525GAME( 1990, cbusterw, cbuster, twocrude, twocrude, twocrude, ROT0, "Data East Corporation", "Crude Buster (World FU version)", 0 )
526GAME( 1990, cbusterj, cbuster, twocrude, twocrude, twocrude, ROT0, "Data East Corporation", "Crude Buster (Japan)", 0 )
527GAME( 1990, twocrude, cbuster, twocrude, twocrude, twocrude, ROT0, "Data East USA", "Two Crude (US)", 0 )
568GAME( 1990, cbuster,  0,       twocrude, twocrude, twocrude, ROT0, "Data East Corporation", "Crude Buster (World FX version)", GAME_SUPPORTS_SAVE )
569GAME( 1990, cbusterw, cbuster, twocrude, twocrude, twocrude, ROT0, "Data East Corporation", "Crude Buster (World FU version)", GAME_SUPPORTS_SAVE )
570GAME( 1990, cbusterj, cbuster, twocrude, twocrude, twocrude, ROT0, "Data East Corporation", "Crude Buster (Japan)", GAME_SUPPORTS_SAVE )
571GAME( 1990, twocrude, cbuster, twocrude, twocrude, twocrude, ROT0, "Data East USA", "Two Crude (US)", GAME_SUPPORTS_SAVE )
src/mame/drivers/dunhuang.c
r7500r7501
5858#define DUNHUANG_DEBUG   0
5959
6060
61typedef struct _dunhuang_state dunhuang_state;
62struct _dunhuang_state
61class dunhuang_state
6362{
63public:
64   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, dunhuang_state(machine)); }
65
66   dunhuang_state(running_machine &machine) { }
67
6468   /* memory pointers */
6569   UINT16 *        videoram;
6670   UINT16 *        videoram2;
src/mame/drivers/ojankohs.c
r7500r7501
2020    Driver by Takahiro Nogi <nogi@kt.rim.or.jp> 2000/06/10 -
2121    Driver by Uki 2001/12/10 -
2222
23******************************************************************************/
24/******************************************************************************
23******************************************************************************
24
2525Memo:
2626
2727- Sometimes RAM check in testmode fails (reason unknown).
r7500r7501
3333
3434#include "emu.h"
3535#include "cpu/z80/z80.h"
36#include "includes/ojankohs.h"
3637#include "sound/ay8910.h"
3738#include "sound/msm5205.h"
3839
3940
40VIDEO_UPDATE( ojankohs );
41PALETTE_INIT( ojankoy );
42VIDEO_START( ojankohs );
43VIDEO_START( ojankoy );
44WRITE8_HANDLER( ojankohs_palette_w );
45WRITE8_HANDLER( ccasino_palette_w );
46WRITE8_HANDLER( ojankohs_videoram_w );
47WRITE8_HANDLER( ojankohs_colorram_w );
48WRITE8_HANDLER( ojankohs_gfxreg_w );
49WRITE8_HANDLER( ojankohs_flipscreen_w );
50VIDEO_UPDATE( ojankoc );
51VIDEO_START( ojankoc );
52WRITE8_HANDLER( ojankoc_palette_w );
53WRITE8_HANDLER( ojankoc_videoram_w );
54void ojankoc_flipscreen(const address_space *space, int data);
55
56
57static int ojankohs_portselect;
58static int ojankohs_adpcm_reset;
59static int ojankohs_adpcm_data;
60static int ojankohs_vclk_left;
61
62
63static MACHINE_RESET( ojankohs )
64{
65   ojankohs_portselect = 0;
66
67   ojankohs_adpcm_reset = 0;
68   ojankohs_adpcm_data = 0;
69   ojankohs_vclk_left = 0;
70}
71
7241static WRITE8_HANDLER( ojankohs_rombank_w )
7342{
74   UINT8 *ROM = memory_region(space->machine, "maincpu");
75
76   memory_set_bankptr(space->machine, "bank1", &ROM[0x10000 + (0x4000 * (data & 0x3f))]);
43   memory_set_bank(space->machine, "bank1", data & 0x3f);
7744}
7845
7946static WRITE8_HANDLER( ojankoy_rombank_w )
8047{
81   UINT8 *ROM = memory_region(space->machine, "maincpu");
48   ojankohs_state *state = (ojankohs_state *)space->machine->driver_data;
8249
83   memory_set_bankptr(space->machine, "bank1", &ROM[0x10000 + (0x4000 * (data & 0x1f))]);
50   memory_set_bank(space->machine, "bank1", data & 0x1f);
8451
85   ojankohs_adpcm_reset = ((data & 0x20) >> 5);
86   if (!ojankohs_adpcm_reset) ojankohs_vclk_left = 0;
52   state->adpcm_reset = BIT(data, 5);
53   if (!state->adpcm_reset)
54      state->vclk_left = 0;
8755
88   msm5205_reset_w(devtag_get_device(space->machine, "msm"), !ojankohs_adpcm_reset);
56   msm5205_reset_w(state->msm, !state->adpcm_reset);
8957}
9058
9159static WRITE8_DEVICE_HANDLER( ojankohs_adpcm_reset_w )
9260{
93   ojankohs_adpcm_reset = (data & 0x01);
94   ojankohs_vclk_left = 0;
61   ojankohs_state *state = (ojankohs_state *)device->machine->driver_data;
62   state->adpcm_reset = BIT(data, 0);
63   state->vclk_left = 0;
9564
96   msm5205_reset_w(device, !ojankohs_adpcm_reset);
65   msm5205_reset_w(device, !state->adpcm_reset);
9766}
9867
9968static WRITE8_HANDLER( ojankohs_msm5205_w )
10069{
101   ojankohs_adpcm_data = data;
102   ojankohs_vclk_left = 2;
70   ojankohs_state *state = (ojankohs_state *)space->machine->driver_data;
71   state->adpcm_data = data;
72   state->vclk_left = 2;
10373}
10474
105static void ojankohs_adpcm_int(running_device *device)
75static void ojankohs_adpcm_int( running_device *device )
10676{
77   ojankohs_state *state = (ojankohs_state *)device->machine->driver_data;
78
10779   /* skip if we're reset */
108   if (!ojankohs_adpcm_reset)
80   if (!state->adpcm_reset)
10981      return;
11082
11183   /* clock the data through */
112   if (ojankohs_vclk_left) {
113      msm5205_data_w(device, (ojankohs_adpcm_data >> 4));
114      ojankohs_adpcm_data <<= 4;
115      ojankohs_vclk_left--;
84   if (state->vclk_left)
85   {
86      msm5205_data_w(device, (state->adpcm_data >> 4));
87      state->adpcm_data <<= 4;
88      state->vclk_left--;
11689   }
11790
11891   /* generate an NMI if we're out of data */
119   if (!ojankohs_vclk_left)
120      cputag_set_input_line(device->machine, "maincpu", INPUT_LINE_NMI, PULSE_LINE);
92   if (!state->vclk_left)
93      cpu_set_input_line(state->maincpu, INPUT_LINE_NMI, PULSE_LINE);
12194}
12295
12396static WRITE8_HANDLER( ojankoc_ctrl_w )
12497{
125   UINT8 *BANKROM = memory_region(space->machine, "user1");
126   UINT32 bank_address = (data & 0x0f) * 0x8000;
98   ojankohs_state *state = (ojankohs_state *)space->machine->driver_data;
12799
128   memory_set_bankptr(space->machine, "bank1", &BANKROM[bank_address]);
100   memory_set_bank(space->machine, "bank1", data & 0x0f);
129101
130   ojankohs_adpcm_reset = ((data & 0x10) >> 4);
131   msm5205_reset_w(devtag_get_device(space->machine, "msm"), (!(data & 0x10) >> 4));
102   state->adpcm_reset = BIT(data, 4);
103   msm5205_reset_w(state->msm, !BIT(data, 4));
132104   ojankoc_flipscreen(space, data);
133105}
134106
135107static WRITE8_HANDLER( ojankohs_portselect_w )
136108{
137   ojankohs_portselect = data;
109   ojankohs_state *state = (ojankohs_state *)space->machine->driver_data;
110   state->portselect = data;
138111}
139112
140113static READ8_HANDLER( ojankohs_keymatrix_r )
141114{
115   ojankohs_state *state = (ojankohs_state *)space->machine->driver_data;
142116   int ret;
143117
144   switch (ojankohs_portselect) {
118   switch (state->portselect)
119   {
145120      case 0x01:   ret = input_port_read(space->machine, "KEY0");   break;
146121      case 0x02:   ret = input_port_read(space->machine, "KEY1"); break;
147122      case 0x04:   ret = input_port_read(space->machine, "KEY2"); break;
r7500r7501
156131               ret &= input_port_read(space->machine, "KEY4");
157132               break;
158133      default:   ret = 0xff;
159               logerror("PC:%04X unknown %02X\n", cpu_get_pc(space->cpu), ojankohs_portselect);
134               logerror("PC:%04X unknown %02X\n", cpu_get_pc(space->cpu), state->portselect);
160135               break;
161136   }
162137
r7500r7501
165140
166141static READ8_HANDLER( ojankoc_keymatrix_r )
167142{
143   ojankohs_state *state = (ojankohs_state *)space->machine->driver_data;
168144   int i;
169145   int ret = 0;
170146   static const char *const keynames[2][5] =
r7500r7501
173149            { "KEY5", "KEY6", "KEY7", "KEY8", "KEY9" }
174150         };
175151
176   for (i = 0; i < 5; i++) {
177      if (~ojankohs_portselect & (1 << i))
152   for (i = 0; i < 5; i++)
153   {
154      if (!BIT(state->portselect, i))
178155         ret |= input_port_read(space->machine, keynames[offset][i]);
179156   }
180157
r7500r7501
211188
212189static WRITE8_HANDLER( ojankoy_coinctr_w )
213190{
214   coin_counter_w( space->machine, 0, (data & 0x01));
191   coin_counter_w(space->machine, 0, BIT(data, 0));
215192}
216193
217194static WRITE8_HANDLER( ccasino_coinctr_w )
218195{
219   coin_counter_w(space->machine, 0, (data & 0x02));
196   coin_counter_w(space->machine, 0, BIT(data, 1));
220197}
221198
222199
r7500r7501
299276
300277
301278static INPUT_PORTS_START( mahjong_p1 )
302   PORT_START("KEY0")   /* PORT 1-0 */
279   PORT_START("KEY0")
303280   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_MAHJONG_A )
304281   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_MAHJONG_E )
305282   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_MAHJONG_I )
r7500r7501
309286   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )
310287   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
311288
312   PORT_START("KEY1")   /* PORT 1-1 */
289   PORT_START("KEY1")
313290   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_MAHJONG_B )
314291   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_MAHJONG_F )
315292   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_MAHJONG_J )
r7500r7501
319296   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )
320297   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
321298
322   PORT_START("KEY2")   /* PORT 1-2 */
299   PORT_START("KEY2")
323300   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_MAHJONG_C )
324301   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_MAHJONG_G )
325302   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_MAHJONG_K )
r7500r7501
329306   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )
330307   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
331308
332   PORT_START("KEY3")   /* PORT 1-3 */
309   PORT_START("KEY3")
333310   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_MAHJONG_D )
334311   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_MAHJONG_H )
335312   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_MAHJONG_L )
r7500r7501
339316   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNKNOWN )
340317   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNKNOWN )
341318
342   PORT_START("KEY4")   /* PORT 1-4 */
319   PORT_START("KEY4")
343320   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_MAHJONG_LAST_CHANCE )
344321   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_MAHJONG_SCORE )
345322   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_MAHJONG_DOUBLE_UP )
r7500r7501
351328INPUT_PORTS_END
352329
353330static INPUT_PORTS_START( ojankohs )
354   PORT_START("IN0")   /* TEST SW */
331   PORT_START("IN0")
355332   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNUSED )
356333   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_SERVICE3 )      // MEMORY RESET
357334   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_SERVICE2 )      // ANALYZER
r7500r7501
361338   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNUSED )
362339   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNUSED )
363340
364   PORT_START("IN1")   /* COIN SW */
341   PORT_START("IN1")
365342   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNUSED )
366343   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNUSED )
367344   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNUSED )
r7500r7501
412389INPUT_PORTS_END
413390
414391static INPUT_PORTS_START( ojankoy )
415   PORT_START("IN0")   /* TEST SW */
392   PORT_START("IN0")
416393   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNUSED )
417394   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_SERVICE3 )      // MEMORY RESET
418395   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_SERVICE2 )      // ANALYZER
r7500r7501
422399   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNUSED )
423400   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNUSED )
424401
425   PORT_START("IN1")   /* COIN SW */
402   PORT_START("IN1")
426403   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNUSED )
427404   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNUSED )
428405   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNUSED )
r7500r7501
483460INPUT_PORTS_END
484461
485462static INPUT_PORTS_START( ccasino )
486   PORT_START("IN0")   /* TEST SW */
463   PORT_START("IN0")
487464   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNUSED )
488465   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_SERVICE3 )      // MEMORY RESET
489466   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_SERVICE2 )      // ANALYZER
r7500r7501
493470   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_UNUSED )
494471   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNUSED )
495472
496   PORT_START("IN1")   /* COIN SW */
473   PORT_START("IN1")
497474   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNUSED )
498475   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNUSED )
499476   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_UNUSED )
r7500r7501
661638   PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
662639   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
663640
664   PORT_START("KEY0")   /* PORT 1-0 */
641   PORT_START("KEY0")
665642   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_MAHJONG_A )
666643   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_MAHJONG_E )
667644   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_MAHJONG_I )
r7500r7501
671648   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_UNKNOWN )
672649   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_UNKNOWN )
673650
674   PORT_START("KEY1")   /* PORT 1-1 */
651   PORT_START("KEY1")
675652   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_MAHJONG_B )
676653   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_MAHJONG_F )
677654   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_MAHJONG_J )
r7500r7501
681658   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_UNKNOWN )
682659   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_UNKNOWN )
683660
684   PORT_START("KEY2")   /* PORT 1-2 */
661   PORT_START("KEY2")
685662   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_MAHJONG_C )
686663   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_MAHJONG_G )
687664   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_MAHJONG_K )
r7500r7501
691668   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_UNKNOWN )
692669   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_UNKNOWN )
693670
694   PORT_START("KEY3")   /* PORT 1-3 */
671   PORT_START("KEY3")
695672   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_MAHJONG_D )
696673   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_MAHJONG_H )
697674   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_MAHJONG_L )
r7500r7501
701678   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_UNKNOWN )
702679   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_UNKNOWN )
703680
704   PORT_START("KEY4")   /* PORT 1-4 */
681   PORT_START("KEY4")
705682   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_MAHJONG_LAST_CHANCE )
706683   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_MAHJONG_SCORE )
707684   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_MAHJONG_DOUBLE_UP )
r7500r7501
711688   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_UNKNOWN )
712689   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_UNKNOWN )
713690
714   PORT_START("KEY5")   /* PORT 2-0 */
691   PORT_START("KEY5")
715692   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_MAHJONG_A ) PORT_PLAYER(2)
716693   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_MAHJONG_E ) PORT_PLAYER(2)
717694   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_MAHJONG_I ) PORT_PLAYER(2)
r7500r7501
720697   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_START2 )
721698   PORT_BIT( 0xc0, IP_ACTIVE_HIGH, IPT_UNUSED )
722699
723   PORT_START("KEY6")   /* PORT 2-1 */
700   PORT_START("KEY6")
724701   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_MAHJONG_B ) PORT_PLAYER(2)
725702   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_MAHJONG_F ) PORT_PLAYER(2)
726703   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_MAHJONG_J ) PORT_PLAYER(2)
r7500r7501
729706   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_MAHJONG_BET ) PORT_PLAYER(2)
730707   PORT_BIT( 0xc0, IP_ACTIVE_HIGH, IPT_UNUSED )
731708
732   PORT_START("KEY7")   /* PORT 2-2 */
709   PORT_START("KEY7")
733710   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_MAHJONG_C ) PORT_PLAYER(2)
734711   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_MAHJONG_G ) PORT_PLAYER(2)
735712   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_MAHJONG_K ) PORT_PLAYER(2)
r7500r7501
738715   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_UNKNOWN )
739716   PORT_BIT( 0xc0, IP_ACTIVE_HIGH, IPT_UNUSED )
740717
741   PORT_START("KEY8")   /* PORT 2-3 */
718   PORT_START("KEY8")
742719   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_MAHJONG_D ) PORT_PLAYER(2)
743720   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_MAHJONG_H ) PORT_PLAYER(2)
744721   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_MAHJONG_L ) PORT_PLAYER(2)
r7500r7501
747724   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_UNKNOWN )
748725   PORT_BIT( 0xc0, IP_ACTIVE_HIGH, IPT_UNUSED )
749726
750   PORT_START("KEY9")   /* PORT 2-4 */
727   PORT_START("KEY9")
751728   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_MAHJONG_LAST_CHANCE ) PORT_PLAYER(2)
752729   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_MAHJONG_SCORE ) PORT_PLAYER(2)
753730   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_MAHJONG_DOUBLE_UP ) PORT_PLAYER(2)
r7500r7501
815792};
816793
817794
795static MACHINE_START( common )
796{
797   ojankohs_state *state = (ojankohs_state *)machine->driver_data;
798
799   state->maincpu = devtag_get_device(machine, "maincpu");
800   state->msm = devtag_get_device(machine, "msm");
801
802   state_save_register_global(machine, state->gfxreg);
803   state_save_register_global(machine, state->flipscreen);
804   state_save_register_global(machine, state->flipscreen_old);
805   state_save_register_global(machine, state->scrollx);
806   state_save_register_global(machine, state->scrolly);
807   state_save_register_global(machine, state->screen_refresh);
808   state_save_register_global(machine, state->portselect);
809   state_save_register_global(machine, state->adpcm_reset);
810   state_save_register_global(machine, state->adpcm_data);
811   state_save_register_global(machine, state->vclk_left);
812}
813
814static MACHINE_START( ojankohs )
815{
816   UINT8 *ROM = memory_region(machine, "maincpu");
817
818   memory_configure_bank(machine, "bank1", 0, 0x40, &ROM[0x10000], 0x4000);
819
820   MACHINE_START_CALL(common);
821}
822
823static MACHINE_START( ojankoy )
824{
825   UINT8 *ROM = memory_region(machine, "maincpu");
826
827   memory_configure_bank(machine, "bank1", 0, 0x20, &ROM[0x10000], 0x4000);
828
829   MACHINE_START_CALL(common);
830}
831
832static MACHINE_START( ojankoc )
833{
834   UINT8 *ROM = memory_region(machine, "user1");
835
836   memory_configure_bank(machine, "bank1", 0, 0x10, &ROM[0x0000], 0x8000);
837
838   MACHINE_START_CALL(common);
839}
840
841static MACHINE_RESET( ojankohs )
842{
843   ojankohs_state *state = (ojankohs_state *)machine->driver_data;
844
845   state->portselect = 0;
846
847   state->adpcm_reset = 0;
848   state->adpcm_data = 0;
849   state->vclk_left = 0;
850
851   state->gfxreg = 0;
852   state->flipscreen = 0;
853   state->flipscreen_old = 0;
854   state->scrollx = 0;
855   state->scrolly = 0;
856   state->screen_refresh = 0;
857}
858
818859static MACHINE_DRIVER_START( ojankohs )
819860
861   /* driver data */
862   MDRV_DRIVER_DATA(ojankohs_state)
863
820864   /* basic machine hardware */
821865   MDRV_CPU_ADD("maincpu", Z80,12000000/2)      /* 6.00 MHz ? */
822866   MDRV_CPU_PROGRAM_MAP(ojankohs_map)
823867   MDRV_CPU_IO_MAP(ojankohs_io_map)
824868   MDRV_CPU_VBLANK_INT("screen", irq0_line_hold)
825869
870   MDRV_MACHINE_START(ojankohs)
826871   MDRV_MACHINE_RESET(ojankohs)
827872   MDRV_NVRAM_HANDLER(generic_0fill)
828873
r7500r7501
854899
855900static MACHINE_DRIVER_START( ojankoy )
856901
902   /* driver data */
903   MDRV_DRIVER_DATA(ojankohs_state)
904
857905   /* basic machine hardware */
858906   MDRV_CPU_ADD("maincpu", Z80,12000000/2)      /* 6.00 MHz ? */
859907   MDRV_CPU_PROGRAM_MAP(ojankoy_map)
860908   MDRV_CPU_IO_MAP(ojankoy_io_map)
861909   MDRV_CPU_VBLANK_INT("screen", irq0_line_hold)
862910
911   MDRV_MACHINE_START(ojankoy)
863912   MDRV_MACHINE_RESET(ojankohs)
864913   MDRV_NVRAM_HANDLER(generic_0fill)
865914
r7500r7501
892941
893942static MACHINE_DRIVER_START( ccasino )
894943
944   /* driver data */
945   MDRV_DRIVER_DATA(ojankohs_state)
946
895947   /* basic machine hardware */
896948   MDRV_CPU_ADD("maincpu", Z80,12000000/2)      /* 6.00 MHz ? */
897949   MDRV_CPU_PROGRAM_MAP(ojankoy_map)
898950   MDRV_CPU_IO_MAP(ccasino_io_map)
899951   MDRV_CPU_VBLANK_INT("screen", irq0_line_hold)
900952
953   MDRV_MACHINE_START(ojankohs)
901954   MDRV_MACHINE_RESET(ojankohs)
902955   MDRV_NVRAM_HANDLER(generic_0fill)
903956
r7500r7501
929982
930983static MACHINE_DRIVER_START( ojankoc )
931984
985   /* driver data */
986   MDRV_DRIVER_DATA(ojankohs_state)
987
932988   /* basic machine hardware */
933989   MDRV_CPU_ADD("maincpu", Z80,8000000/2)         /* 4.00 MHz */
934990   MDRV_CPU_PROGRAM_MAP(ojankoc_map)
935991   MDRV_CPU_IO_MAP(ojankoc_io_map)
936992   MDRV_CPU_VBLANK_INT("screen", irq0_line_hold)
937993
994   MDRV_MACHINE_START(ojankoc)
938995   MDRV_MACHINE_RESET(ojankohs)
939996   MDRV_NVRAM_HANDLER(generic_0fill)
940997
r7500r7501
10561113ROM_END
10571114
10581115
1059GAME( 1986, ojankoc,  0, ojankoc,  ojankoc,  0, ROT0, "V-System Co.", "Ojanko Club (Japan)", 0 )
1060GAME( 1986, ojankoy,  0, ojankoy,  ojankoy,  0, ROT0, "V-System Co.", "Ojanko Yakata (Japan)", 0 )
1061GAME( 1987, ojanko2,  0, ojankoy,  ojankoy,  0, ROT0, "V-System Co.", "Ojanko Yakata 2bankan (Japan)", 0 )
1062GAME( 1987, ccasino,  0, ccasino,  ccasino,  0, ROT0, "V-System Co.", "Chinese Casino [BET] (Japan)", 0 )
1063GAME( 1988, ojankohs, 0, ojankohs, ojankohs, 0, ROT0, "V-System Co.", "Ojanko High School (Japan)", 0 )
1116GAME( 1986, ojankoc,  0, ojankoc,  ojankoc,  0, ROT0, "V-System Co.", "Ojanko Club (Japan)", GAME_SUPPORTS_SAVE )
1117GAME( 1986, ojankoy,  0, ojankoy,  ojankoy,  0, ROT0, "V-System Co.", "Ojanko Yakata (Japan)", GAME_SUPPORTS_SAVE )
1118GAME( 1987, ojanko2,  0, ojankoy,  ojankoy,  0, ROT0, "V-System Co.", "Ojanko Yakata 2bankan (Japan)", GAME_SUPPORTS_SAVE )
1119GAME( 1987, ccasino,  0, ccasino,  ccasino,  0, ROT0, "V-System Co.", "Chinese Casino [BET] (Japan)", GAME_SUPPORTS_SAVE )
1120GAME( 1988, ojankohs, 0, ojankohs, ojankohs, 0, ROT0, "V-System Co.", "Ojanko High School (Japan)", GAME_SUPPORTS_SAVE )
src/mame/drivers/rohga.c
r7500r7501
109109#include "cpu/h6280/h6280.h"
110110#include "includes/decocrpt.h"
111111#include "includes/decoprot.h"
112#include "includes/deco16ic.h"
112#include "includes/rohga.h"
113113#include "sound/2151intf.h"
114114#include "sound/okim6295.h"
115#include "video/deco16ic.h"
115116
116VIDEO_START( rohga );
117VIDEO_START( wizdfire );
118VIDEO_START( nitrobal );
119VIDEO_UPDATE( rohga );
120VIDEO_UPDATE( schmeisr );
121VIDEO_UPDATE( wizdfire );
122VIDEO_UPDATE( nitrobal );
123WRITE16_HANDLER( rohga_buffer_spriteram16_w );
124117
125118static READ16_HANDLER( rohga_irq_ack_r )
126119{
127   cputag_set_input_line(space->machine, "maincpu", 6, CLEAR_LINE);
120   rohga_state *state = (rohga_state *)space->machine->driver_data;
121
122   cpu_set_input_line(state->maincpu, 6, CLEAR_LINE);
128123   return 0;
129124}
130125
r7500r7501
133128   /* This might actually do more, nitrobal for example sets 0xca->0xffff->0x80 at startup then writes 7 all the time
134129       except when a credit is inserted (writes 6 twice).
135130       Wizard Fire / Dark Seal 2 just writes 1 all the time, so I just don't trust it much for now... -AS */
136   cputag_set_input_line(space->machine, "maincpu", 6, CLEAR_LINE);
131   rohga_state *state = (rohga_state *)space->machine->driver_data;
132   cpu_set_input_line(state->maincpu, 6, CLEAR_LINE);
137133}
138134
139135/**********************************************************************************/
r7500r7501
141137static ADDRESS_MAP_START( rohga_map, ADDRESS_SPACE_PROGRAM, 16 )
142138   AM_RANGE(0x000000, 0x1fffff) AM_ROM
143139
144   AM_RANGE(0x200000, 0x20000f) AM_WRITEONLY AM_BASE(&deco16_pf12_control)
145   AM_RANGE(0x240000, 0x24000f) AM_WRITEONLY AM_BASE(&deco16_pf34_control)
140   AM_RANGE(0x200000, 0x20000f) AM_DEVWRITE("deco_custom", deco16ic_pf12_control_w)
141   AM_RANGE(0x240000, 0x24000f) AM_DEVWRITE("deco_custom", deco16ic_pf34_control_w)
146142
147143   AM_RANGE(0x280000, 0x2807ff) AM_MIRROR(0x800) AM_READWRITE(deco16_104_rohga_prot_r,deco16_104_rohga_prot_w)  AM_BASE(&deco16_prot_ram) /* Protection device */
148144
r7500r7501
150146
151147   AM_RANGE(0x300000, 0x300001) AM_WRITE(rohga_buffer_spriteram16_w) /* write 1 for sprite dma */
152148   AM_RANGE(0x310000, 0x310009) AM_WRITENOP /* Palette control? */
153   AM_RANGE(0x31000a, 0x31000b) AM_WRITE(deco16_palette_dma_w) /* Write 1111 for dma?  (Or any value?) */
149   AM_RANGE(0x31000a, 0x31000b) AM_DEVWRITE("deco_custom", deco16ic_palette_dma_w) /* Write 1111 for dma?  (Or any value?) */
154150   AM_RANGE(0x320000, 0x320001) AM_WRITENOP /* ? */
155   AM_RANGE(0x322000, 0x322001) AM_WRITE(deco16_priority_w)
151   AM_RANGE(0x322000, 0x322001) AM_DEVWRITE("deco_custom", deco16ic_priority_w)
156152   AM_RANGE(0x321100, 0x321101) AM_READ(rohga_irq_ack_r) /* Irq ack?  Value not used */
157153
158   AM_RANGE(0x3c0000, 0x3c1fff) AM_RAM_WRITE(deco16_pf1_data_w) AM_BASE(&deco16_pf1_data)
159   AM_RANGE(0x3c2000, 0x3c2fff) AM_RAM_WRITE(deco16_pf2_data_w) AM_BASE(&deco16_pf2_data)
160   AM_RANGE(0x3c4000, 0x3c4fff) AM_RAM_WRITE(deco16_pf3_data_w) AM_BASE(&deco16_pf3_data)
161   AM_RANGE(0x3c6000, 0x3c6fff) AM_RAM_WRITE(deco16_pf4_data_w) AM_BASE(&deco16_pf4_data)
154   AM_RANGE(0x3c0000, 0x3c1fff) AM_DEVREADWRITE("deco_custom", deco16ic_pf1_data_r, deco16ic_pf1_data_w)
155   AM_RANGE(0x3c2000, 0x3c2fff) AM_DEVREADWRITE("deco_custom", deco16ic_pf2_data_r, deco16ic_pf2_data_w)
156   AM_RANGE(0x3c4000, 0x3c4fff) AM_DEVREADWRITE("deco_custom", deco16ic_pf3_data_r, deco16ic_pf3_data_w)
157   AM_RANGE(0x3c6000, 0x3c6fff) AM_DEVREADWRITE("deco_custom", deco16ic_pf4_data_r, deco16ic_pf4_data_w)
162158
163   AM_RANGE(0x3c8000, 0x3c8fff) AM_MIRROR(0x1000) AM_RAM AM_BASE(&deco16_pf1_rowscroll)
164   AM_RANGE(0x3ca000, 0x3cafff) AM_MIRROR(0x1000) AM_RAM AM_BASE(&deco16_pf2_rowscroll)
165   AM_RANGE(0x3cc000, 0x3ccfff) AM_MIRROR(0x1000) AM_RAM AM_BASE(&deco16_pf3_rowscroll)
166   AM_RANGE(0x3ce000, 0x3cefff) AM_MIRROR(0x1000) AM_RAM AM_BASE(&deco16_pf4_rowscroll)
159   AM_RANGE(0x3c8000, 0x3c8fff) AM_MIRROR(0x1000) AM_RAM AM_BASE_MEMBER(rohga_state, pf1_rowscroll)
160   AM_RANGE(0x3ca000, 0x3cafff) AM_MIRROR(0x1000) AM_RAM AM_BASE_MEMBER(rohga_state, pf2_rowscroll)
161   AM_RANGE(0x3cc000, 0x3ccfff) AM_MIRROR(0x1000) AM_RAM AM_BASE_MEMBER(rohga_state, pf3_rowscroll)
162   AM_RANGE(0x3ce000, 0x3cefff) AM_MIRROR(0x1000) AM_RAM AM_BASE_MEMBER(rohga_state, pf4_rowscroll)
167163
168164   AM_RANGE(0x3d0000, 0x3d07ff) AM_RAM AM_BASE_SIZE_GENERIC(spriteram)
169   AM_RANGE(0x3e0000, 0x3e1fff) AM_RAM_WRITE(deco16_buffered_palette_w) AM_BASE_GENERIC(paletteram)
165   AM_RANGE(0x3e0000, 0x3e1fff) AM_RAM_DEVWRITE("deco_custom", deco16ic_buffered_palette_w) AM_BASE_GENERIC(paletteram)
170166   AM_RANGE(0x3f0000, 0x3f3fff) AM_RAM /* Main ram */
171167ADDRESS_MAP_END
172168
173169static ADDRESS_MAP_START( wizdfire_map, ADDRESS_SPACE_PROGRAM, 16 )
174170   AM_RANGE(0x000000, 0x1fffff) AM_ROM
175171
176   AM_RANGE(0x200000, 0x200fff) AM_RAM_WRITE(deco16_pf1_data_w) AM_BASE(&deco16_pf1_data)
177   AM_RANGE(0x202000, 0x202fff) AM_RAM_WRITE(deco16_pf2_data_w) AM_BASE(&deco16_pf2_data)
178   AM_RANGE(0x208000, 0x208fff) AM_RAM_WRITE(deco16_pf3_data_w) AM_BASE(&deco16_pf3_data)
179   AM_RANGE(0x20a000, 0x20afff) AM_RAM_WRITE(deco16_pf4_data_w) AM_BASE(&deco16_pf4_data)
172   AM_RANGE(0x200000, 0x200fff) AM_DEVREADWRITE("deco_custom", deco16ic_pf1_data_r, deco16ic_pf1_data_w)
173   AM_RANGE(0x202000, 0x202fff) AM_DEVREADWRITE("deco_custom", deco16ic_pf2_data_r, deco16ic_pf2_data_w)
174   AM_RANGE(0x208000, 0x208fff) AM_DEVREADWRITE("deco_custom", deco16ic_pf3_data_r, deco16ic_pf3_data_w)
175   AM_RANGE(0x20a000, 0x20afff) AM_DEVREADWRITE("deco_custom", deco16ic_pf4_data_r, deco16ic_pf4_data_w)
180176
181177   AM_RANGE(0x20b000, 0x20b3ff) AM_WRITEONLY /* ? Always 0 written */
182   AM_RANGE(0x20c000, 0x20c7ff) AM_RAM AM_BASE(&deco16_pf3_rowscroll)
183   AM_RANGE(0x20e000, 0x20e7ff) AM_RAM AM_BASE(&deco16_pf4_rowscroll)
178   AM_RANGE(0x20c000, 0x20c7ff) AM_RAM AM_BASE_MEMBER(rohga_state, pf3_rowscroll)
179   AM_RANGE(0x20e000, 0x20e7ff) AM_RAM AM_BASE_MEMBER(rohga_state, pf4_rowscroll)
184180
185   AM_RANGE(0x300000, 0x30000f) AM_WRITEONLY AM_BASE(&deco16_pf12_control)
186   AM_RANGE(0x310000, 0x31000f) AM_WRITEONLY AM_BASE(&deco16_pf34_control)
181   AM_RANGE(0x300000, 0x30000f) AM_DEVWRITE("deco_custom", deco16ic_pf12_control_w)
182   AM_RANGE(0x310000, 0x31000f) AM_DEVWRITE("deco_custom", deco16ic_pf34_control_w)
187183
188   AM_RANGE(0x320000, 0x320001) AM_WRITE(deco16_priority_w) /* Priority */
184   AM_RANGE(0x320000, 0x320001) AM_DEVWRITE("deco_custom", deco16ic_priority_w) /* Priority */
189185   AM_RANGE(0x320002, 0x320003) AM_WRITENOP /* ? */
190186   AM_RANGE(0x320004, 0x320005) AM_WRITE(wizdfire_irq_ack_w) /* VBL IRQ ack */
191187
r7500r7501
194190   AM_RANGE(0x360000, 0x3607ff) AM_RAM AM_BASE_SIZE_GENERIC(spriteram2)
195191   AM_RANGE(0x370000, 0x370001) AM_WRITE(buffer_spriteram16_2_w) /* Triggers DMA for spriteram */
196192
197   AM_RANGE(0x380000, 0x381fff) AM_RAM_WRITE(deco16_buffered_palette_w) AM_BASE_GENERIC(paletteram)
198   AM_RANGE(0x390008, 0x390009) AM_WRITE(deco16_palette_dma_w)
193   AM_RANGE(0x380000, 0x381fff) AM_RAM_DEVWRITE("deco_custom", deco16ic_buffered_palette_w) AM_BASE_GENERIC(paletteram)
194   AM_RANGE(0x390008, 0x390009) AM_DEVWRITE("deco_custom", deco16ic_palette_dma_w)
199195
200196   AM_RANGE(0xfe4000, 0xfe47ff) AM_READWRITE(deco16_104_prot_r,deco16_104_prot_w) AM_BASE(&deco16_prot_ram) /* Protection device */
201197   AM_RANGE(0xfdc000, 0xffffff) AM_RAM
r7500r7501
204200static ADDRESS_MAP_START( nitrobal_map, ADDRESS_SPACE_PROGRAM, 16 )
205201   AM_RANGE(0x000000, 0x1fffff) AM_ROM
206202
207   AM_RANGE(0x200000, 0x200fff) AM_MIRROR(0x1000) AM_RAM_WRITE(deco16_pf1_data_w) AM_BASE(&deco16_pf1_data)
208   AM_RANGE(0x202000, 0x2027ff) AM_MIRROR(0x800) AM_RAM_WRITE(deco16_pf2_data_w) AM_BASE(&deco16_pf2_data)
209   AM_RANGE(0x208000, 0x2087ff) AM_MIRROR(0x800) AM_RAM_WRITE(deco16_pf3_data_w) AM_BASE(&deco16_pf3_data)
210   AM_RANGE(0x20a000, 0x20a7ff) AM_MIRROR(0x800) AM_RAM_WRITE(deco16_pf4_data_w) AM_BASE(&deco16_pf4_data)
203   AM_RANGE(0x200000, 0x200fff) AM_MIRROR(0x1000) AM_DEVREADWRITE("deco_custom", deco16ic_pf1_data_r, deco16ic_pf1_data_w)
204   AM_RANGE(0x202000, 0x2027ff) AM_MIRROR(0x800) AM_DEVREADWRITE("deco_custom", deco16ic_pf2_data_r, deco16ic_pf2_data_w)
205   AM_RANGE(0x208000, 0x2087ff) AM_MIRROR(0x800) AM_DEVREADWRITE("deco_custom", deco16ic_pf3_data_r, deco16ic_pf3_data_w)
206   AM_RANGE(0x20a000, 0x20a7ff) AM_MIRROR(0x800) AM_DEVREADWRITE("deco_custom", deco16ic_pf4_data_r, deco16ic_pf4_data_w)
211207
212   AM_RANGE(0x204000, 0x2047ff) AM_RAM AM_BASE(&deco16_pf1_rowscroll)
213   AM_RANGE(0x206000, 0x2067ff) AM_RAM AM_BASE(&deco16_pf2_rowscroll)
214   AM_RANGE(0x20c000, 0x20c7ff) AM_RAM AM_BASE(&deco16_pf3_rowscroll)
215   AM_RANGE(0x20e000, 0x20e7ff) AM_RAM AM_BASE(&deco16_pf4_rowscroll)
208   AM_RANGE(0x204000, 0x2047ff) AM_RAM AM_BASE_MEMBER(rohga_state, pf1_rowscroll)
209   AM_RANGE(0x206000, 0x2067ff) AM_RAM AM_BASE_MEMBER(rohga_state, pf2_rowscroll)
210   AM_RANGE(0x20c000, 0x20c7ff) AM_RAM AM_BASE_MEMBER(rohga_state, pf3_rowscroll)
211   AM_RANGE(0x20e000, 0x20e7ff) AM_RAM AM_BASE_MEMBER(rohga_state, pf4_rowscroll)
216212
217   AM_RANGE(0x300000, 0x30000f) AM_WRITEONLY AM_BASE(&deco16_pf12_control)
218   AM_RANGE(0x310000, 0x31000f) AM_WRITEONLY AM_BASE(&deco16_pf34_control)
213   AM_RANGE(0x300000, 0x30000f) AM_DEVWRITE("deco_custom", deco16ic_pf12_control_w)
214   AM_RANGE(0x310000, 0x31000f) AM_DEVWRITE("deco_custom", deco16ic_pf34_control_w)
219215
220   AM_RANGE(0x320000, 0x320001) AM_READ_PORT("DSW3") AM_WRITE(deco16_priority_w) /* Priority */
216   AM_RANGE(0x320000, 0x320001) AM_READ_PORT("DSW3") AM_DEVWRITE("deco_custom", deco16ic_priority_w) /* Priority */
221217   AM_RANGE(0x320002, 0x320003) AM_WRITENOP /* ? */
222218   AM_RANGE(0x320004, 0x320005) AM_WRITE(wizdfire_irq_ack_w) /* VBL IRQ ack */
223219
r7500r7501
226222   AM_RANGE(0x360000, 0x3607ff) AM_RAM AM_BASE_SIZE_GENERIC(spriteram2)
227223   AM_RANGE(0x370000, 0x370001) AM_WRITE(buffer_spriteram16_2_w) /* Triggers DMA for spriteram */
228224
229   AM_RANGE(0x380000, 0x381fff) AM_RAM_WRITE(deco16_buffered_palette_w) AM_BASE_GENERIC(paletteram)
230   AM_RANGE(0x390008, 0x390009) AM_WRITE(deco16_palette_dma_w)
225   AM_RANGE(0x380000, 0x381fff) AM_RAM_DEVWRITE("deco_custom", deco16ic_buffered_palette_w) AM_BASE_GENERIC(paletteram)
226   AM_RANGE(0x390008, 0x390009) AM_DEVWRITE("deco_custom", deco16ic_palette_dma_w)
231227
232228   AM_RANGE(0xfec000, 0xff3fff) AM_RAM
233229   AM_RANGE(0xff4000, 0xff47ff) AM_MIRROR(0x800) AM_READWRITE(deco16_146_nitroball_prot_r,deco16_146_nitroball_prot_w) AM_BASE(&deco16_prot_ram) /* Protection device */
r7500r7501
236232
237233static ADDRESS_MAP_START( schmeisr_map, ADDRESS_SPACE_PROGRAM, 16 )
238234   AM_RANGE(0x000000, 0x0fffff) AM_ROM
239   AM_RANGE(0x200000, 0x20000f) AM_WRITEONLY AM_BASE(&deco16_pf12_control)
240   AM_RANGE(0x240000, 0x24000f) AM_WRITEONLY AM_BASE(&deco16_pf34_control)
235   AM_RANGE(0x200000, 0x20000f) AM_DEVWRITE("deco_custom", deco16ic_pf12_control_w)
236   AM_RANGE(0x240000, 0x24000f) AM_DEVWRITE("deco_custom", deco16ic_pf34_control_w)
241237   AM_RANGE(0x280000, 0x2807ff) AM_MIRROR(0x800) AM_READWRITE(deco16_104_rohga_prot_r,deco16_104_rohga_prot_w) AM_BASE(&deco16_prot_ram) /* Protection device */
242238
243239   AM_RANGE(0x2c0000, 0x2c0001) AM_READ_PORT("DSW3")
244240   AM_RANGE(0x300000, 0x300001) AM_READ_PORT("DSW3")  AM_WRITE(rohga_buffer_spriteram16_w) /* write 1 for sprite dma */
245241   AM_RANGE(0x310002, 0x310003) AM_READ_PORT("IN1")
246242   AM_RANGE(0x310000, 0x310009) AM_WRITENOP /* Palette control? */
247   AM_RANGE(0x31000a, 0x31000b) AM_WRITE(deco16_palette_dma_w) /* Write 1111 for dma?  (Or any value?) */
243   AM_RANGE(0x31000a, 0x31000b) AM_DEVWRITE("deco_custom", deco16ic_palette_dma_w) /* Write 1111 for dma?  (Or any value?) */
248244   AM_RANGE(0x320000, 0x320001) AM_WRITENOP /* ? */
249   AM_RANGE(0x322000, 0x322001) AM_WRITE(deco16_priority_w)
245   AM_RANGE(0x322000, 0x322001) AM_DEVWRITE("deco_custom", deco16ic_priority_w)
250246   AM_RANGE(0x321100, 0x321101) AM_WRITE(wizdfire_irq_ack_w)  /* Irq ack?  Value not used */
251247
252   AM_RANGE(0x3c0000, 0x3c1fff) AM_RAM_WRITE(deco16_pf1_data_w) AM_BASE(&deco16_pf1_data)
253   AM_RANGE(0x3c2000, 0x3c2fff) AM_RAM_WRITE(deco16_pf2_data_w) AM_BASE(&deco16_pf2_data)
254   AM_RANGE(0x3c4000, 0x3c4fff) AM_RAM_WRITE(deco16_pf3_data_w) AM_BASE(&deco16_pf3_data)
255   AM_RANGE(0x3c6000, 0x3c6fff) AM_RAM_WRITE(deco16_pf4_data_w) AM_BASE(&deco16_pf4_data)
256   AM_RANGE(0x3c8000, 0x3c8fff) AM_MIRROR(0x1000) AM_RAM AM_BASE(&deco16_pf1_rowscroll)
257   AM_RANGE(0x3ca000, 0x3cafff) AM_MIRROR(0x1000) AM_RAM AM_BASE(&deco16_pf2_rowscroll)
258   AM_RANGE(0x3cc000, 0x3ccfff) AM_MIRROR(0x1000) AM_RAM AM_BASE(&deco16_pf3_rowscroll)
259   AM_RANGE(0x3ce000, 0x3cefff) AM_MIRROR(0x1000) AM_RAM AM_BASE(&deco16_pf4_rowscroll)
248   AM_RANGE(0x3c0000, 0x3c1fff) AM_DEVREADWRITE("deco_custom", deco16ic_pf1_data_r, deco16ic_pf1_data_w)
249   AM_RANGE(0x3c2000, 0x3c2fff) AM_DEVREADWRITE("deco_custom", deco16ic_pf2_data_r, deco16ic_pf2_data_w)
250   AM_RANGE(0x3c4000, 0x3c4fff) AM_DEVREADWRITE("deco_custom", deco16ic_pf3_data_r, deco16ic_pf3_data_w)
251   AM_RANGE(0x3c6000, 0x3c6fff) AM_DEVREADWRITE("deco_custom", deco16ic_pf4_data_r, deco16ic_pf4_data_w)
252   AM_RANGE(0x3c8000, 0x3c8fff) AM_MIRROR(0x1000) AM_RAM AM_BASE_MEMBER(rohga_state, pf1_rowscroll)
253   AM_RANGE(0x3ca000, 0x3cafff) AM_MIRROR(0x1000) AM_RAM AM_BASE_MEMBER(rohga_state, pf2_rowscroll)
254   AM_RANGE(0x3cc000, 0x3ccfff) AM_MIRROR(0x1000) AM_RAM AM_BASE_MEMBER(rohga_state, pf3_rowscroll)
255   AM_RANGE(0x3ce000, 0x3cefff) AM_MIRROR(0x1000) AM_RAM AM_BASE_MEMBER(rohga_state, pf4_rowscroll)
260256
261257   AM_RANGE(0x3d0000, 0x3d07ff) AM_RAM AM_BASE_SIZE_GENERIC(spriteram)
262   AM_RANGE(0x3e0000, 0x3e1fff) AM_MIRROR(0x2000) AM_RAM_WRITE(deco16_buffered_palette_w) AM_BASE_GENERIC(paletteram)
258   AM_RANGE(0x3e0000, 0x3e1fff) AM_MIRROR(0x2000) AM_RAM_DEVWRITE("deco_custom", deco16ic_buffered_palette_w) AM_BASE_GENERIC(paletteram)
263259   AM_RANGE(0xff0000, 0xff7fff) AM_RAM /* Main ram */
264260ADDRESS_MAP_END
265261
r7500r7501
727723
728724static void sound_irq(running_device *device, int state)
729725{
730   cputag_set_input_line(device->machine, "audiocpu", 1, state); /* IRQ 2 */
726   rohga_state *driver_state = (rohga_state *)device->machine->driver_data;
727   cpu_set_input_line(driver_state->audiocpu, 1, state); /* IRQ 2 */
731728}
732729
733730static WRITE8_DEVICE_HANDLER( sound_bankswitch_w )
734731{
735   okim6295_set_bank_base(devtag_get_device(device->machine, "oki1"), ((data & 1)>>0) * 0x40000);
736   okim6295_set_bank_base(devtag_get_device(device->machine, "oki2"), ((data & 2)>>1) * 0x40000);
732   rohga_state *state = (rohga_state *)device->machine->driver_data;
733   okim6295_set_bank_base(state->oki1, BIT(data, 0) * 0x40000);
734   okim6295_set_bank_base(state->oki2, BIT(data, 1) * 0x40000);
737735}
738736
739737static const ym2151_interface ym2151_config =
r7500r7501
744742
745743/**********************************************************************************/
746744
745static int rohga_bank_callback( const int bank )
746{
747   return ((bank >> 4) & 0x3) << 12;
748}
749
750static const deco16ic_interface rohga_deco16ic_intf =
751{
752   "screen",
753   0, 0, 1,
754   0x0f, 0x0f, 0x0f, 0x0f,   /* trans masks (default values) */
755   0, 16, 0, 16, /* color base (default values) */
756   0x0f, 0x0f, 0x0f, 0x0f,   /* color masks (default values) */
757   rohga_bank_callback,
758   rohga_bank_callback,
759   rohga_bank_callback,
760   rohga_bank_callback
761};
762
763static const deco16ic_interface nitrobal_deco16ic_intf =
764{
765   "screen",
766   0, 0, 0,
767   0x0f, 0x0f, 0x0f, 0x0f,   /* trans masks (default values) */
768   0, 16, 0, 0, /* color base (pf4 is not default) */
769   0x0f, 0x0f, 0, 0,   /* color masks */
770   rohga_bank_callback,
771   rohga_bank_callback,
772   rohga_bank_callback,
773   rohga_bank_callback
774};
775
776static MACHINE_START( rohga )
777{
778   rohga_state *state = (rohga_state *)machine->driver_data;
779
780   state->maincpu = devtag_get_device(machine, "maincpu");
781   state->audiocpu = devtag_get_device(machine, "audiocpu");
782   state->deco16ic = devtag_get_device(machine, "deco_custom");
783   state->oki1 = devtag_get_device(machine, "oki1");
784   state->oki2 = devtag_get_device(machine, "oki2");
785}
786
747787static MACHINE_DRIVER_START( rohga )
748788
789   /* driver data */
790   MDRV_DRIVER_DATA(rohga_state)
791
749792   /* basic machine hardware */
750793   MDRV_CPU_ADD("maincpu", M68000, 14000000)
751794   MDRV_CPU_PROGRAM_MAP(rohga_map)
r7500r7501
754797   MDRV_CPU_ADD("audiocpu", H6280,32220000/4/3) /* verified on pcb (8.050Mhz is XIN on pin 10 of H6280 */
755798   MDRV_CPU_PROGRAM_MAP(rohga_sound_map)
756799
800   MDRV_MACHINE_START(rohga)
801
757802   /* video hardware */
758803   MDRV_VIDEO_ATTRIBUTES(VIDEO_BUFFERS_SPRITERAM)
759804
r7500r7501
770815   MDRV_VIDEO_START(rohga)
771816   MDRV_VIDEO_UPDATE(rohga)
772817
818   MDRV_DECO16IC_ADD("deco_custom", rohga_deco16ic_intf)
819
773820   /* sound hardware */
774821   MDRV_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker")
775822
r7500r7501
791838
792839static MACHINE_DRIVER_START( wizdfire )
793840
841   /* driver data */
842   MDRV_DRIVER_DATA(rohga_state)
843
794844   /* basic machine hardware */
795845   MDRV_CPU_ADD("maincpu", M68000, 14000000)
796846   MDRV_CPU_PROGRAM_MAP(wizdfire_map)
r7500r7501
799849   MDRV_CPU_ADD("audiocpu", H6280,32220000/4/3) /* verified on pcb (8.050Mhz is XIN on pin 10 of H6280 */
800850   MDRV_CPU_PROGRAM_MAP(rohga_sound_map)
801851
852   MDRV_MACHINE_START(rohga)
853
802854   /* video hardware */
803855   MDRV_VIDEO_ATTRIBUTES(VIDEO_BUFFERS_SPRITERAM )
804856
r7500r7501
812864   MDRV_GFXDECODE(wizdfire)
813865   MDRV_PALETTE_LENGTH(2048)
814866
815   MDRV_VIDEO_START(wizdfire)
816867   MDRV_VIDEO_UPDATE(wizdfire)
817868
869   MDRV_DECO16IC_ADD("deco_custom", rohga_deco16ic_intf)
870
818871   /* sound hardware */
819872   MDRV_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker")
820873
r7500r7501
836889
837890static MACHINE_DRIVER_START( nitrobal )
838891
892   /* driver data */
893   MDRV_DRIVER_DATA(rohga_state)
894
839895   /* basic machine hardware */
840896   MDRV_CPU_ADD("maincpu", M68000, 14000000)
841897   MDRV_CPU_PROGRAM_MAP(nitrobal_map)
r7500r7501
844900   MDRV_CPU_ADD("audiocpu", H6280,32220000/4/3) /* verified on pcb (8.050Mhz is XIN on pin 10 of H6280 */
845901   MDRV_CPU_PROGRAM_MAP(rohga_sound_map)
846902
903   MDRV_MACHINE_START(rohga)
904
847905   /* video hardware */
848906   MDRV_VIDEO_ATTRIBUTES(VIDEO_BUFFERS_SPRITERAM )
849907
r7500r7501
857915   MDRV_GFXDECODE(wizdfire)
858916   MDRV_PALETTE_LENGTH(2048)
859917
860   MDRV_VIDEO_START(nitrobal)
861918   MDRV_VIDEO_UPDATE(nitrobal)
862919
920   MDRV_DECO16IC_ADD("deco_custom", nitrobal_deco16ic_intf)
921
863922   /* sound hardware */
864923   MDRV_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker")
865924
r7500r7501
881940
882941static MACHINE_DRIVER_START( schmeisr )
883942
943   /* driver data */
944   MDRV_DRIVER_DATA(rohga_state)
945
884946   /* basic machine hardware */
885947   MDRV_CPU_ADD("maincpu", M68000, 14000000)
886948   MDRV_CPU_PROGRAM_MAP(schmeisr_map)
r7500r7501
889951   MDRV_CPU_ADD("audiocpu", H6280,32220000/4/3) /* verified on pcb (8.050Mhz is XIN on pin 10 of H6280 */
890952   MDRV_CPU_PROGRAM_MAP(rohga_sound_map)
891953
954   MDRV_MACHINE_START(rohga)
955
892956   /* video hardware */
893957   MDRV_VIDEO_ATTRIBUTES(VIDEO_BUFFERS_SPRITERAM)
894958
r7500r7501
905969   MDRV_VIDEO_START(rohga)
906970   MDRV_VIDEO_UPDATE(schmeisr)
907971
972   MDRV_DECO16IC_ADD("deco_custom", rohga_deco16ic_intf)
973
908974   /* sound hardware */
909975   MDRV_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker")
910976
r7500r7501
14801546   const UINT8 *src = memory_region(machine, "gfx2");
14811547   UINT8 *dst = memory_region(machine, "gfx1");
14821548
1483   memcpy(dst,src,0x20000);
1484   memcpy(dst+0x20000,src+0x80000,0x20000);
1549   memcpy(dst, src, 0x20000);
1550   memcpy(dst + 0x20000, src + 0x80000, 0x20000);
14851551
14861552   deco74_decrypt_gfx(machine, "gfx1");
14871553   deco74_decrypt_gfx(machine, "gfx2");
r7500r7501
14891555   decoprot_reset(machine);
14901556}
14911557
1492GAME( 1991, rohga,    0,       rohga,    rohga,    rohga,    ROT0,   "Data East Corporation", "Rohga Armor Force (Asia/Europe v5.0)" , 0 )
1493GAME( 1991, rohga1,   rohga,   rohga,    rohga,    rohga,    ROT0,   "Data East Corporation", "Rohga Armor Force (Asia/Europe v3.0 Set 1)", 0 )
1494GAME( 1991, rohga2,   rohga,   rohga,    rohga,    rohga,    ROT0,   "Data East Corporation", "Rohga Armor Force (Asia/Europe v3.0 Set 2)", 0 )
1495GAME( 1991, rohgah,   rohga,   rohga,    rohga,    rohga,    ROT0,   "Data East Corporation", "Rohga Armor Force (Hong Kong v3.0)", 0 )
1496GAME( 1991, rohgau,   rohga,   rohga,    rohga,    rohga,    ROT0,   "Data East Corporation", "Rohga Armor Force (US v1.0)", 0 )
1497GAME( 1991, wolffang, rohga,   rohga,    rohga,    rohga,    ROT0,   "Data East Corporation", "Wolf Fang -Kuhga 2001- (Japan)", 0 )
1498GAME( 1992, wizdfire, 0,       wizdfire, wizdfire, wizdfire, ROT0,   "Data East Corporation", "Wizard Fire (Over Sea v2.1)", 0 )
1499GAME( 1992, wizdfireu,wizdfire,wizdfire, wizdfire, wizdfire, ROT0,   "Data East Corporation", "Wizard Fire (US v1.1)", 0 )
1500GAME( 1992, darkseal2,wizdfire,wizdfire, wizdfire, wizdfire, ROT0,   "Data East Corporation", "Dark Seal 2 (Japan v2.1)", 0 )
1501GAME( 1992, nitrobal, 0,       nitrobal, nitrobal, nitrobal, ROT270, "Data East Corporation", "Nitro Ball (US)", 0 )
1502GAME( 1992, gunball,  nitrobal,nitrobal, nitrobal, nitrobal, ROT270, "Data East Corporation", "Gun Ball (Japan)", 0 )
1503GAME( 1993, schmeisr, 0,       schmeisr, schmeisr, schmeisr, ROT0,   "Hot B",                 "Schmeiser Robo (Japan)", 0 )
1558GAME( 1991, rohga,     0,        rohga,    rohga,    rohga,    ROT0,   "Data East Corporation", "Rohga Armor Force (Asia/Europe v5.0)", GAME_SUPPORTS_SAVE )
1559GAME( 1991, rohga1,    rohga,    rohga,    rohga,    rohga,    ROT0,   "Data East Corporation", "Rohga Armor Force (Asia/Europe v3.0 Set 1)", GAME_SUPPORTS_SAVE )
1560GAME( 1991, rohga2,    rohga,    rohga,    rohga,    rohga,    ROT0,   "Data East Corporation", "Rohga Armor Force (Asia/Europe v3.0 Set 2)", GAME_SUPPORTS_SAVE )
1561GAME( 1991, rohgah,    rohga,    rohga,    rohga,    rohga,    ROT0,   "Data East Corporation", "Rohga Armor Force (Hong Kong v3.0)", GAME_SUPPORTS_SAVE )
1562GAME( 1991, rohgau,    rohga,    rohga,    rohga,    rohga,    ROT0,   "Data East Corporation", "Rohga Armor Force (US v1.0)", GAME_SUPPORTS_SAVE )
1563GAME( 1991, wolffang,  rohga,    rohga,    rohga,    rohga,    ROT0,   "Data East Corporation", "Wolf Fang -Kuhga 2001- (Japan)", GAME_SUPPORTS_SAVE )
1564GAME( 1992, wizdfire,  0,        wizdfire, wizdfire, wizdfire, ROT0,   "Data East Corporation", "Wizard Fire (Over Sea v2.1)", GAME_SUPPORTS_SAVE )
1565GAME( 1992, wizdfireu, wizdfire, wizdfire, wizdfire, wizdfire, ROT0,   "Data East Corporation", "Wizard Fire (US v1.1)", GAME_SUPPORTS_SAVE )
1566GAME( 1992, darkseal2, wizdfire, wizdfire, wizdfire, wizdfire, ROT0,   "Data East Corporation", "Dark Seal 2 (Japan v2.1)", GAME_SUPPORTS_SAVE )
1567GAME( 1992, nitrobal,  0,        nitrobal, nitrobal, nitrobal, ROT270, "Data East Corporation", "Nitro Ball (US)", GAME_SUPPORTS_SAVE )
1568GAME( 1992, gunball,   nitrobal, nitrobal, nitrobal, nitrobal, ROT270, "Data East Corporation", "Gun Ball (Japan)", GAME_SUPPORTS_SAVE )
1569GAME( 1993, schmeisr,  0,        schmeisr, schmeisr, schmeisr, ROT0,   "Hot B",                 "Schmeiser Robo (Japan)", GAME_SUPPORTS_SAVE )
src/mame/drivers/nemesis.c
r7500r7501
5252#include "includes/nemesis.h"
5353#include "includes/konamipt.h"
5454
55int nemesis_irq_on = 0;
56int nemesis_irq2_on = 0;
57static int nemesis_irq1_on = 0;
58static int nemesis_irq4_on = 0;
59static int gx400_irq1_cnt;
60static UINT8 frame_counter;
6155
62
63static MACHINE_RESET( nemesis )
56static INTERRUPT_GEN( nemesis_interrupt )
6457{
65   nemesis_irq_on = 0;
66   nemesis_irq1_on = 0;
67   nemesis_irq2_on = 0;
68   nemesis_irq4_on = 0;
69   gx400_irq1_cnt = 0;
70   frame_counter = 1;
71}
58   nemesis_state *state = (nemesis_state *)device->machine->driver_data;
7259
73
74static INTERRUPT_GEN( nemesis_interrupt )
75{
76   if (nemesis_irq_on)
60   if (state->irq_on)
7761      cpu_set_input_line(device, 1, HOLD_LINE);
7862}
7963
8064static INTERRUPT_GEN( konamigt_interrupt )
8165{
66   nemesis_state *state = (nemesis_state *)device->machine->driver_data;
67
8268   if (cpu_getiloops(device) == 0)
8369   {
84      if ( (nemesis_irq_on) && (gx400_irq1_cnt++ & 1) ) cpu_set_input_line(device, 1, HOLD_LINE);
70      if ((state->irq_on) && (state->gx400_irq1_cnt++ & 1))
71         cpu_set_input_line(device, 1, HOLD_LINE);
8572   }
8673   else
8774   {
88      if (nemesis_irq2_on) cpu_set_input_line(device, 2, HOLD_LINE);
75      if (state->irq2_on)
76         cpu_set_input_line(device, 2, HOLD_LINE);
8977   }
9078}
9179
9280static INTERRUPT_GEN( gx400_interrupt )
9381{
82   nemesis_state *state = (nemesis_state *)device->machine->driver_data;
83
9484   switch (cpu_getiloops(device))
9585   {
9686      case 0:
97         if (nemesis_irq2_on) cpu_set_input_line(device, 2, HOLD_LINE);
87         if (state->irq2_on)
88            cpu_set_input_line(device, 2, HOLD_LINE);
9889         break;
9990
10091      case 1:
101         if ( (nemesis_irq1_on) && (gx400_irq1_cnt++ & 1) ) cpu_set_input_line(device, 1, HOLD_LINE);
92         if ((state->irq1_on) && (state->gx400_irq1_cnt++ & 1))
93            cpu_set_input_line(device, 1, HOLD_LINE);
10294         break;
10395
10496      case 2:
105         if (nemesis_irq4_on) cpu_set_input_line(device, 4, HOLD_LINE);
97         if (state->irq4_on)
98            cpu_set_input_line(device, 4, HOLD_LINE);
10699         break;
107100   }
108101}
109102
110103static INTERRUPT_GEN( salamand_interrupt )
111104{
112   if (nemesis_irq_on)
105   nemesis_state *state = (nemesis_state *)device->machine->driver_data;
106
107   if (state->irq_on)
113108      cpu_set_input_line(device, 1, HOLD_LINE);
114109}
115110
116111static INTERRUPT_GEN( blkpnthr_interrupt )
117112{
118   if (nemesis_irq_on)
113   nemesis_state *state = (nemesis_state *)device->machine->driver_data;
114
115   if (state->irq_on)
119116      cpu_set_input_line(device, 2, HOLD_LINE);
120117}
121118
122119
123120static WRITE16_HANDLER( gx400_irq1_enable_word_w )
124121{
122   nemesis_state *state = (nemesis_state *)space->machine->driver_data;
123
125124   if (ACCESSING_BITS_0_7)
126      nemesis_irq1_on = data & 0x0001;
125      state->irq1_on = data & 0x0001;
127126
128127   if (ACCESSING_BITS_8_15)
129128      coin_lockout_w(space->machine, 1, data & 0x0100);
r7500r7501
131130
132131static WRITE16_HANDLER( gx400_irq2_enable_word_w )
133132{
133   nemesis_state *state = (nemesis_state *)space->machine->driver_data;
134
134135   if (ACCESSING_BITS_0_7)
135      nemesis_irq2_on = data & 0x0001;
136      state->irq2_on = data & 0x0001;
136137
137138   if (ACCESSING_BITS_8_15)
138139      coin_lockout_w(space->machine, 0, data & 0x0100);
r7500r7501
140141
141142static WRITE16_HANDLER( gx400_irq4_enable_word_w )
142143{
144   nemesis_state *state = (nemesis_state *)space->machine->driver_data;
145
143146   if (ACCESSING_BITS_8_15)
144      nemesis_irq4_on = data & 0x0100;
147      state->irq4_on = data & 0x0100;
145148}
146149
147150static WRITE16_HANDLER( nemesis_irq_enable_word_w )
148151{
152   nemesis_state *state = (nemesis_state *)space->machine->driver_data;
153
149154   if (ACCESSING_BITS_0_7)
150      nemesis_irq_on = data & 0xff;
155      state->irq_on = data & 0xff;
151156
152157   if (ACCESSING_BITS_8_15)
153158      coin_lockout_global_w(space->machine, data & 0x0100);
r7500r7501
155160
156161static WRITE16_HANDLER( konamigt_irq_enable_word_w )
157162{
163   nemesis_state *state = (nemesis_state *)space->machine->driver_data;
164
158165   if (ACCESSING_BITS_0_7)
159      nemesis_irq_on = data & 0xff;
166      state->irq_on = data & 0xff;
160167
161168   if (ACCESSING_BITS_8_15)
162169      coin_lockout_w(space->machine, 1, data & 0x0100);
r7500r7501
164171
165172static WRITE16_HANDLER( konamigt_irq2_enable_word_w )
166173{
174   nemesis_state *state = (nemesis_state *)space->machine->driver_data;
175
167176   if (ACCESSING_BITS_0_7)
168      nemesis_irq2_on = data & 0xff;
177      state->irq2_on = data & 0xff;
169178
170179   if (ACCESSING_BITS_8_15)
171180      coin_lockout_w(space->machine, 0, data & 0x0100);
172181}
173182
174183
175static UINT8 *gx400_shared_ram;
176
177184static READ16_HANDLER( gx400_sharedram_word_r )
178185{
179   return gx400_shared_ram[offset];
186   nemesis_state *state = (nemesis_state *)space->machine->driver_data;
187   return state->gx400_shared_ram[offset];
180188}
181189
182190static WRITE16_HANDLER( gx400_sharedram_word_w )
183191{
192   nemesis_state *state = (nemesis_state *)space->machine->driver_data;
193
184194   if (ACCESSING_BITS_0_7)
185      gx400_shared_ram[offset] = data;
195      state->gx400_shared_ram[offset] = data;
186196}
187197
188198
r7500r7501
195205    bit 12-15: accel
196206*/
197207
198   int data=input_port_read(space->machine, "IN3");
199   int data2=input_port_read(space->machine, "PADDLE");
208   int data = input_port_read(space->machine, "IN3");
209   int data2 = input_port_read(space->machine, "PADDLE");
200210
201211   int ret=0x0000;
202212
203//  if(data&0x10) ret|=0x0800;          // turbo/gear?
204//  if(data&0x80) ret|=0x0400;          // turbo?
205   if(data&0x20) ret|=0x0300;         // brake        (0-3)
213//  if (BIT(data, 4)) ret |= 0x0800;          // turbo/gear?
214//  if (BIT(data, 7)) ret |= 0x0400;          // turbo?
215   if (BIT(data, 5))
216      ret |= 0x0300;         // brake        (0-3)
206217
207   if(data&0x40) ret|=0xf000;         // accel        (0-f)
218   if (BIT(data, 6))
219      ret |= 0xf000;         // accel        (0-f)
208220
209   ret|=data2&0x7f;               // steering wheel, not exactly sure if DIAL works ok.
221   ret |= data2 & 0x7f;               // steering wheel, not exactly sure if DIAL works ok.
210222
211223   return ret;
212224}
213225
214/* Copied from WEC Le Mans 24 driver, explicity needed for Hyper Crash */
215UINT16 hcrash_selected_ip;
216
217226static WRITE16_HANDLER( selected_ip_word_w )
218227{
219   if (ACCESSING_BITS_0_7) hcrash_selected_ip = data & 0xff;   // latch the value
228   nemesis_state *state = (nemesis_state *)space->machine->driver_data;
229
230   if (ACCESSING_BITS_0_7)
231      state->selected_ip = data & 0xff;   // latch the value
220232}
221233
222234static READ16_HANDLER( selected_ip_word_r )
223235{
224   switch (hcrash_selected_ip & 0xf)
236   nemesis_state *state = (nemesis_state *)space->machine->driver_data;
237
238   switch (state->selected_ip & 0xf)
225239   {                                    // From WEC Le Mans Schems:
226240      case 0xc:  return input_port_read(space->machine, "ACCEL");   // Accel - Schems: Accelevr
227241      case 0:    return input_port_read(space->machine, "ACCEL");
r7500r7501
236250static WRITE16_HANDLER( nemesis_soundlatch_word_w )
237251{
238252   if (ACCESSING_BITS_0_7)
239      soundlatch_w(space,offset,data & 0xff);
253      soundlatch_w(space, offset, data & 0xff);
240254}
241255
242256static WRITE8_DEVICE_HANDLER( gx400_speech_start_w )
243257{
258   nemesis_state *state = (nemesis_state *)device->machine->driver_data;
259
244260   /* the voice data is not in a rom but in sound RAM at $8000 */
245   vlm5030_set_rom(device, gx400_shared_ram + 0x4000);
261   vlm5030_set_rom(device, state->gx400_shared_ram + 0x4000);
246262   vlm5030_st(device, 1);
247263   vlm5030_st(device, 0);
248264}
r7500r7501
261277   bit 5:     vlm5030 busy
262278   bit 7:     unused by this software version. Bubble Memory version uses this bit.
263279*/
280   nemesis_state *state = (nemesis_state *)device->machine->driver_data;
281   int res = (cpu_get_total_cycles(state->audiocpu) / 1024) & 0x2f; // this should be 0x0f, but it doesn't work
264282
265   running_device *vlm = devtag_get_device(device->machine, "vlm");
266   int res = (cputag_get_total_cycles(device->machine, "audiocpu") / 1024) & 0x2f; // this should be 0x0f, but it doesn't work
267
268283   res |= 0xd0;
269284
270   if (vlm != NULL && vlm5030_bsy(vlm))
285   if (state->vlm != NULL && vlm5030_bsy(state->vlm))
271286      res |= 0x20;
272287
273288   return res;
r7500r7501
275290
276291static WRITE8_DEVICE_HANDLER( city_sound_bank_w )
277292{
278   int bank_A=(data&0x3);
279   int bank_B=((data>>2)&0x3);
280   k007232_set_bank( device, bank_A, bank_B );
293   int bank_A = (data & 0x03);
294   int bank_B = ((data >> 2) & 0x03);
295   k007232_set_bank(device, bank_A, bank_B);
281296}
282297
283298
284299static ADDRESS_MAP_START( nemesis_map, ADDRESS_SPACE_PROGRAM, 16 )
285300   AM_RANGE(0x000000, 0x03ffff) AM_ROM
286   AM_RANGE(0x040000, 0x04ffff) AM_RAM_WRITE(nemesis_characterram_word_w) AM_BASE(&nemesis_characterram) AM_SIZE(&nemesis_characterram_size)
301   AM_RANGE(0x040000, 0x04ffff) AM_RAM_WRITE(nemesis_charram_word_w) AM_BASE_SIZE_MEMBER(nemesis_state, charram, charram_size)
287302   AM_RANGE(0x050000, 0x051fff) AM_RAM
288   AM_RANGE(0x050000, 0x0503ff) AM_BASE(&nemesis_xscroll1)
289   AM_RANGE(0x050400, 0x0507ff) AM_BASE(&nemesis_xscroll2)
290   AM_RANGE(0x050f00, 0x050f7f) AM_BASE(&nemesis_yscroll2)
291   AM_RANGE(0x050f80, 0x050fff) AM_BASE(&nemesis_yscroll1)
292   AM_RANGE(0x052000, 0x052fff) AM_RAM_WRITE(nemesis_videoram1_word_w) AM_BASE(&nemesis_videoram1)      /* VRAM */
293   AM_RANGE(0x053000, 0x053fff) AM_RAM_WRITE(nemesis_videoram2_word_w) AM_BASE(&nemesis_videoram2)
294   AM_RANGE(0x054000, 0x054fff) AM_RAM_WRITE(nemesis_colorram1_word_w) AM_BASE(&nemesis_colorram1)
295   AM_RANGE(0x055000, 0x055fff) AM_RAM_WRITE(nemesis_colorram2_word_w) AM_BASE(&nemesis_colorram2)
296   AM_RANGE(0x056000, 0x056fff) AM_RAM AM_BASE_SIZE_GENERIC(spriteram)
297   AM_RANGE(0x05a000, 0x05afff) AM_RAM_WRITE(nemesis_palette_word_w) AM_BASE_GENERIC(paletteram)
303   AM_RANGE(0x050000, 0x0503ff) AM_BASE_MEMBER(nemesis_state, xscroll1)
304   AM_RANGE(0x050400, 0x0507ff) AM_BASE_MEMBER(nemesis_state, xscroll2)
305   AM_RANGE(0x050f00, 0x050f7f) AM_BASE_MEMBER(nemesis_state, yscroll2)
306   AM_RANGE(0x050f80, 0x050fff) AM_BASE_MEMBER(nemesis_state, yscroll1)
307   AM_RANGE(0x052000, 0x052fff) AM_RAM_WRITE(nemesis_videoram1_word_w) AM_BASE_MEMBER(nemesis_state, videoram1)      /* VRAM */
308   AM_RANGE(0x053000, 0x053fff) AM_RAM_WRITE(nemesis_videoram2_word_w) AM_BASE_MEMBER(nemesis_state, videoram2)
309   AM_RANGE(0x054000, 0x054fff) AM_RAM_WRITE(nemesis_colorram1_word_w) AM_BASE_MEMBER(nemesis_state, colorram1)
310   AM_RANGE(0x055000, 0x055fff) AM_RAM_WRITE(nemesis_colorram2_word_w) AM_BASE_MEMBER(nemesis_state, colorram2)
311   AM_RANGE(0x056000, 0x056fff) AM_RAM AM_BASE_SIZE_MEMBER(nemesis_state, spriteram, spriteram_size)
312   AM_RANGE(0x05a000, 0x05afff) AM_RAM_WRITE(nemesis_palette_word_w) AM_BASE_MEMBER(nemesis_state, paletteram)
298313   AM_RANGE(0x05c000, 0x05c001) AM_WRITE(nemesis_soundlatch_word_w)
299314   AM_RANGE(0x05c400, 0x05c401) AM_READ_PORT("DSW0")
300315   AM_RANGE(0x05c402, 0x05c403) AM_READ_PORT("DSW1")
r7500r7501
316331   AM_RANGE(0x000000, 0x00ffff) AM_ROM      /* ROM BIOS */
317332   AM_RANGE(0x010000, 0x01ffff) AM_RAM
318333   AM_RANGE(0x020000, 0x0287ff) AM_READWRITE(gx400_sharedram_word_r, gx400_sharedram_word_w)
319   AM_RANGE(0x030000, 0x03ffff) AM_RAM_WRITE(nemesis_characterram_word_w) AM_BASE(&nemesis_characterram) AM_SIZE(&nemesis_characterram_size)
334   AM_RANGE(0x030000, 0x03ffff) AM_RAM_WRITE(nemesis_charram_word_w) AM_BASE_SIZE_MEMBER(nemesis_state, charram, charram_size)
320335   AM_RANGE(0x050000, 0x051fff) AM_RAM
321   AM_RANGE(0x050000, 0x0503ff) AM_BASE(&nemesis_xscroll1)
322   AM_RANGE(0x050400, 0x0507ff) AM_BASE(&nemesis_xscroll2)
323   AM_RANGE(0x050f00, 0x050f7f) AM_BASE(&nemesis_yscroll2)
324   AM_RANGE(0x050f80, 0x050fff) AM_BASE(&nemesis_yscroll1)
325   AM_RANGE(0x052000, 0x052fff) AM_RAM_WRITE(nemesis_videoram1_word_w) AM_BASE(&nemesis_videoram1)      /* VRAM */
326   AM_RANGE(0x053000, 0x053fff) AM_RAM_WRITE(nemesis_videoram2_word_w) AM_BASE(&nemesis_videoram2)
327   AM_RANGE(0x054000, 0x054fff) AM_RAM_WRITE(nemesis_colorram1_word_w) AM_BASE(&nemesis_colorram1)
328   AM_RANGE(0x055000, 0x055fff) AM_RAM_WRITE(nemesis_colorram2_word_w) AM_BASE(&nemesis_colorram2)
329   AM_RANGE(0x056000, 0x056fff) AM_RAM AM_BASE_SIZE_GENERIC(spriteram)
336   AM_RANGE(0x050000, 0x0503ff) AM_BASE_MEMBER(nemesis_state, xscroll1)
337   AM_RANGE(0x050400, 0x0507ff) AM_BASE_MEMBER(nemesis_state, xscroll2)
338   AM_RANGE(0x050f00, 0x050f7f) AM_BASE_MEMBER(nemesis_state, yscroll2)
339   AM_RANGE(0x050f80, 0x050fff) AM_BASE_MEMBER(nemesis_state, yscroll1)
340   AM_RANGE(0x052000, 0x052fff) AM_RAM_WRITE(nemesis_videoram1_word_w) AM_BASE_MEMBER(nemesis_state, videoram1)      /* VRAM */
341   AM_RANGE(0x053000, 0x053fff) AM_RAM_WRITE(nemesis_videoram2_word_w) AM_BASE_MEMBER(nemesis_state, videoram2)
342   AM_RANGE(0x054000, 0x054fff) AM_RAM_WRITE(nemesis_colorram1_word_w) AM_BASE_MEMBER(nemesis_state, colorram1)
343   AM_RANGE(0x055000, 0x055fff) AM_RAM_WRITE(nemesis_colorram2_word_w) AM_BASE_MEMBER(nemesis_state, colorram2)
344   AM_RANGE(0x056000, 0x056fff) AM_RAM AM_BASE_SIZE_MEMBER(nemesis_state, spriteram, spriteram_size)
330345   AM_RANGE(0x057000, 0x057fff) AM_RAM            /* needed for twinbee */
331   AM_RANGE(0x05a000, 0x05afff) AM_RAM_WRITE(nemesis_palette_word_w) AM_BASE_GENERIC(paletteram)
346   AM_RANGE(0x05a000, 0x05afff) AM_RAM_WRITE(nemesis_palette_word_w) AM_BASE_MEMBER(nemesis_state, paletteram)
332347   AM_RANGE(0x05c000, 0x05c001) AM_WRITE(nemesis_soundlatch_word_w)
333348   AM_RANGE(0x05c402, 0x05c403) AM_READ_PORT("DSW0")
334349   AM_RANGE(0x05c404, 0x05c405) AM_READ_PORT("DSW1")
r7500r7501
349364
350365static ADDRESS_MAP_START( konamigt_map, ADDRESS_SPACE_PROGRAM, 16 )
351366   AM_RANGE(0x000000, 0x03ffff) AM_ROM
352   AM_RANGE(0x040000, 0x04ffff) AM_RAM_WRITE(nemesis_characterram_word_w) AM_BASE(&nemesis_characterram) AM_SIZE(&nemesis_characterram_size)
367   AM_RANGE(0x040000, 0x04ffff) AM_RAM_WRITE(nemesis_charram_word_w) AM_BASE_SIZE_MEMBER(nemesis_state, charram, charram_size)
353368   AM_RANGE(0x050000, 0x051fff) AM_RAM
354   AM_RANGE(0x050000, 0x0503ff) AM_BASE(&nemesis_xscroll1)
355   AM_RANGE(0x050400, 0x0507ff) AM_BASE(&nemesis_xscroll2)
356   AM_RANGE(0x050f00, 0x050f7f) AM_BASE(&nemesis_yscroll2)
357   AM_RANGE(0x050f80, 0x050fff) AM_BASE(&nemesis_yscroll1)
358   AM_RANGE(0x052000, 0x052fff) AM_RAM_WRITE(nemesis_videoram1_word_w) AM_BASE(&nemesis_videoram1)      /* VRAM */
359   AM_RANGE(0x053000, 0x053fff) AM_RAM_WRITE(nemesis_videoram2_word_w) AM_BASE(&nemesis_videoram2)
360   AM_RANGE(0x054000, 0x054fff) AM_RAM_WRITE(nemesis_colorram1_word_w) AM_BASE(&nemesis_colorram1)
361   AM_RANGE(0x055000, 0x055fff) AM_RAM_WRITE(nemesis_colorram2_word_w) AM_BASE(&nemesis_colorram2)
362   AM_RANGE(0x056000, 0x056fff) AM_RAM AM_BASE_SIZE_GENERIC(spriteram)
363   AM_RANGE(0x05a000, 0x05afff) AM_RAM_WRITE(nemesis_palette_word_w) AM_BASE_GENERIC(paletteram)
369   AM_RANGE(0x050000, 0x0503ff) AM_BASE_MEMBER(nemesis_state, xscroll1)
370   AM_RANGE(0x050400, 0x0507ff) AM_BASE_MEMBER(nemesis_state, xscroll2)
371   AM_RANGE(0x050f00, 0x050f7f) AM_BASE_MEMBER(nemesis_state, yscroll2)
372   AM_RANGE(0x050f80, 0x050fff) AM_BASE_MEMBER(nemesis_state, yscroll1)
373   AM_RANGE(0x052000, 0x052fff) AM_RAM_WRITE(nemesis_videoram1_word_w) AM_BASE_MEMBER(nemesis_state, videoram1)      /* VRAM */
374   AM_RANGE(0x053000, 0x053fff) AM_RAM_WRITE(nemesis_videoram2_word_w) AM_BASE_MEMBER(nemesis_state, videoram2)
375   AM_RANGE(0x054000, 0x054fff) AM_RAM_WRITE(nemesis_colorram1_word_w) AM_BASE_MEMBER(nemesis_state, colorram1)
376   AM_RANGE(0x055000, 0x055fff) AM_RAM_WRITE(nemesis_colorram2_word_w) AM_BASE_MEMBER(nemesis_state, colorram2)
377   AM_RANGE(0x056000, 0x056fff) AM_RAM AM_BASE_SIZE_MEMBER(nemesis_state, spriteram, spriteram_size)
378   AM_RANGE(0x05a000, 0x05afff) AM_RAM_WRITE(nemesis_palette_word_w) AM_BASE_MEMBER(nemesis_state, paletteram)
364379   AM_RANGE(0x05c000, 0x05c001) AM_WRITE(nemesis_soundlatch_word_w)
365380   AM_RANGE(0x05c400, 0x05c401) AM_READ_PORT("DSW0")
366381   AM_RANGE(0x05c402, 0x05c403) AM_READ_PORT("DSW1")
r7500r7501
383398   AM_RANGE(0x000000, 0x00ffff) AM_ROM      /* ROM BIOS */
384399   AM_RANGE(0x010000, 0x01ffff) AM_RAM
385400   AM_RANGE(0x020000, 0x0287ff) AM_READWRITE(gx400_sharedram_word_r, gx400_sharedram_word_w)
386   AM_RANGE(0x030000, 0x03ffff) AM_RAM_WRITE(nemesis_characterram_word_w) AM_BASE(&nemesis_characterram) AM_SIZE(&nemesis_characterram_size)
401   AM_RANGE(0x030000, 0x03ffff) AM_RAM_WRITE(nemesis_charram_word_w) AM_BASE_SIZE_MEMBER(nemesis_state, charram, charram_size)
387402   AM_RANGE(0x050000, 0x051fff) AM_RAM
388   AM_RANGE(0x050000, 0x0503ff) AM_BASE(&nemesis_xscroll1)
389   AM_RANGE(0x050400, 0x0507ff) AM_BASE(&nemesis_xscroll2)
390   AM_RANGE(0x050f00, 0x050f7f) AM_BASE(&nemesis_yscroll2)
391   AM_RANGE(0x050f80, 0x050fff) AM_BASE(&nemesis_yscroll1)
392   AM_RANGE(0x052000, 0x052fff) AM_RAM_WRITE(nemesis_videoram1_word_w) AM_BASE(&nemesis_videoram1)      /* VRAM */
393   AM_RANGE(0x053000, 0x053fff) AM_RAM_WRITE(nemesis_videoram2_word_w) AM_BASE(&nemesis_videoram2)
394   AM_RANGE(0x054000, 0x054fff) AM_RAM_WRITE(nemesis_colorram1_word_w) AM_BASE(&nemesis_colorram1)
395   AM_RANGE(0x055000, 0x055fff) AM_RAM_WRITE(nemesis_colorram2_word_w) AM_BASE(&nemesis_colorram2)
396   AM_RANGE(0x056000, 0x056fff) AM_RAM AM_BASE_SIZE_GENERIC(spriteram)
397   AM_RANGE(0x05a000, 0x05afff) AM_RAM_WRITE(nemesis_palette_word_w) AM_BASE_GENERIC(paletteram)
403   AM_RANGE(0x050000, 0x0503ff) AM_BASE_MEMBER(nemesis_state, xscroll1)
404   AM_RANGE(0x050400, 0x0507ff) AM_BASE_MEMBER(nemesis_state, xscroll2)
405   AM_RANGE(0x050f00, 0x050f7f) AM_BASE_MEMBER(nemesis_state, yscroll2)
406   AM_RANGE(0x050f80, 0x050fff) AM_BASE_MEMBER(nemesis_state, yscroll1)
407   AM_RANGE(0x052000, 0x052fff) AM_RAM_WRITE(nemesis_videoram1_word_w) AM_BASE_MEMBER(nemesis_state, videoram1)      /* VRAM */
408   AM_RANGE(0x053000, 0x053fff) AM_RAM_WRITE(nemesis_videoram2_word_w) AM_BASE_MEMBER(nemesis_state, videoram2)
409   AM_RANGE(0x054000, 0x054fff) AM_RAM_WRITE(nemesis_colorram1_word_w) AM_BASE_MEMBER(nemesis_state, colorram1)
410   AM_RANGE(0x055000, 0x055fff) AM_RAM_WRITE(nemesis_colorram2_word_w) AM_BASE_MEMBER(nemesis_state, colorram2)
411   AM_RANGE(0x056000, 0x056fff) AM_RAM AM_BASE_SIZE_MEMBER(nemesis_state, spriteram, spriteram_size)
412   AM_RANGE(0x05a000, 0x05afff) AM_RAM_WRITE(nemesis_palette_word_w) AM_BASE_MEMBER(nemesis_state, paletteram)
398413   AM_RANGE(0x05c000, 0x05c001) AM_WRITE(nemesis_soundlatch_word_w)
399414   AM_RANGE(0x05c402, 0x05c403) AM_READ_PORT("DSW0")
400415   AM_RANGE(0x05c404, 0x05c405) AM_READ_PORT("DSW1")
r7500r7501
418433static ADDRESS_MAP_START( sound_map, ADDRESS_SPACE_PROGRAM, 8 )
419434   AM_RANGE(0x0000, 0x3fff) AM_ROM
420435   AM_RANGE(0x4000, 0x47ff) AM_RAM
421   AM_RANGE(0xa000, 0xafff) AM_DEVWRITE("konami", k005289_pitch_A_w)
422   AM_RANGE(0xc000, 0xcfff) AM_DEVWRITE("konami", k005289_pitch_B_w)
436   AM_RANGE(0xa000, 0xafff) AM_DEVWRITE("k007232", k005289_pitch_A_w)
437   AM_RANGE(0xc000, 0xcfff) AM_DEVWRITE("k007232", k005289_pitch_B_w)
423438   AM_RANGE(0xe001, 0xe001) AM_READ(soundlatch_r)
424   AM_RANGE(0xe003, 0xe003) AM_DEVWRITE("konami", k005289_keylatch_A_w)
425   AM_RANGE(0xe004, 0xe004) AM_DEVWRITE("konami", k005289_keylatch_B_w)
439   AM_RANGE(0xe003, 0xe003) AM_DEVWRITE("k007232", k005289_keylatch_A_w)
440   AM_RANGE(0xe004, 0xe004) AM_DEVWRITE("k007232", k005289_keylatch_B_w)
426441   AM_RANGE(0xe005, 0xe005) AM_DEVWRITE("ay2", ay8910_address_w)
427442   AM_RANGE(0xe006, 0xe006) AM_DEVWRITE("ay1", ay8910_address_w)
428443   AM_RANGE(0xe086, 0xe086) AM_DEVREAD("ay1", ay8910_r)
r7500r7501
433448
434449static ADDRESS_MAP_START( gx400_sound_map, ADDRESS_SPACE_PROGRAM, 8 )
435450   AM_RANGE(0x0000, 0x1fff) AM_ROM
436   AM_RANGE(0x4000, 0x87ff) AM_RAM AM_BASE(&gx400_shared_ram)
437   AM_RANGE(0xa000, 0xafff) AM_DEVWRITE("konami", k005289_pitch_A_w)
438   AM_RANGE(0xc000, 0xcfff) AM_DEVWRITE("konami", k005289_pitch_B_w)
451   AM_RANGE(0x4000, 0x87ff) AM_RAM AM_BASE_MEMBER(nemesis_state, gx400_shared_ram)
452   AM_RANGE(0xa000, 0xafff) AM_DEVWRITE("k007232", k005289_pitch_A_w)
453   AM_RANGE(0xc000, 0xcfff) AM_DEVWRITE("k007232", k005289_pitch_B_w)
439454   AM_RANGE(0xe000, 0xe000) AM_DEVWRITE("vlm", vlm5030_data_w)
440455   AM_RANGE(0xe001, 0xe001) AM_READ(soundlatch_r)
441   AM_RANGE(0xe003, 0xe003) AM_DEVWRITE("konami", k005289_keylatch_A_w)
442   AM_RANGE(0xe004, 0xe004) AM_DEVWRITE("konami", k005289_keylatch_B_w)
456   AM_RANGE(0xe003, 0xe003) AM_DEVWRITE("k007232", k005289_keylatch_A_w)
457   AM_RANGE(0xe004, 0xe004) AM_DEVWRITE("k007232", k005289_keylatch_B_w)
443458   AM_RANGE(0xe005, 0xe005) AM_DEVWRITE("ay2", ay8910_address_w)
444459   AM_RANGE(0xe006, 0xe006) AM_DEVWRITE("ay1", ay8910_address_w)
445460   AM_RANGE(0xe030, 0xe030) AM_DEVWRITE("vlm", gx400_speech_start_w)
r7500r7501
454469static ADDRESS_MAP_START( salamand_map, ADDRESS_SPACE_PROGRAM, 16 )
455470   AM_RANGE(0x000000, 0x07ffff) AM_ROM
456471   AM_RANGE(0x080000, 0x087fff) AM_RAM
457   AM_RANGE(0x090000, 0x091fff) AM_RAM_WRITE(salamander_palette_word_w) AM_BASE_GENERIC(paletteram)
472   AM_RANGE(0x090000, 0x091fff) AM_RAM_WRITE(salamander_palette_word_w) AM_BASE_MEMBER(nemesis_state, paletteram)
458473   AM_RANGE(0x0a0000, 0x0a0001) AM_WRITE(salamand_control_port_word_w)      /* irq enable, flipscreen, etc. */
459474   AM_RANGE(0x0c0000, 0x0c0001) AM_WRITE(nemesis_soundlatch_word_w)
460475   AM_RANGE(0x0c0002, 0x0c0003) AM_READ_PORT("DSW0")
r7500r7501
463478   AM_RANGE(0x0c2002, 0x0c2003) AM_READ_PORT("IN1")
464479   AM_RANGE(0x0c2004, 0x0c2005) AM_READ_PORT("IN2")
465480   AM_RANGE(0x0c2006, 0x0c2007) AM_READ_PORT("DSW1")
466   AM_RANGE(0x100000, 0x100fff) AM_RAM_WRITE(nemesis_videoram2_word_w) AM_BASE(&nemesis_videoram2)      /* VRAM */
467   AM_RANGE(0x101000, 0x101fff) AM_RAM_WRITE(nemesis_videoram1_word_w) AM_BASE(&nemesis_videoram1)
468   AM_RANGE(0x102000, 0x102fff) AM_RAM_WRITE(nemesis_colorram2_word_w) AM_BASE(&nemesis_colorram2)
469   AM_RANGE(0x103000, 0x103fff) AM_RAM_WRITE(nemesis_colorram1_word_w) AM_BASE(&nemesis_colorram1)
470   AM_RANGE(0x120000, 0x12ffff) AM_RAM_WRITE(nemesis_characterram_word_w) AM_BASE(&nemesis_characterram) AM_SIZE(&nemesis_characterram_size)
471   AM_RANGE(0x180000, 0x180fff) AM_RAM AM_BASE_SIZE_GENERIC(spriteram)      /* more sprite ram ??? */
481   AM_RANGE(0x100000, 0x100fff) AM_RAM_WRITE(nemesis_videoram2_word_w) AM_BASE_MEMBER(nemesis_state, videoram2)      /* VRAM */
482   AM_RANGE(0x101000, 0x101fff) AM_RAM_WRITE(nemesis_videoram1_word_w) AM_BASE_MEMBER(nemesis_state, videoram1)
483   AM_RANGE(0x102000, 0x102fff) AM_RAM_WRITE(nemesis_colorram2_word_w) AM_BASE_MEMBER(nemesis_state, colorram2)
484   AM_RANGE(0x103000, 0x103fff) AM_RAM_WRITE(nemesis_colorram1_word_w) AM_BASE_MEMBER(nemesis_state, colorram1)
485   AM_RANGE(0x120000, 0x12ffff) AM_RAM_WRITE(nemesis_charram_word_w) AM_BASE_SIZE_MEMBER(nemesis_state, charram, charram_size)
486   AM_RANGE(0x180000, 0x180fff) AM_RAM AM_BASE_SIZE_MEMBER(nemesis_state, spriteram, spriteram_size)      /* more sprite ram ??? */
472487   AM_RANGE(0x190000, 0x191fff) AM_RAM
473   AM_RANGE(0x190000, 0x1903ff) AM_BASE(&nemesis_xscroll2)
474   AM_RANGE(0x190400, 0x1907ff) AM_BASE(&nemesis_xscroll1)
475   AM_RANGE(0x190f00, 0x190f7f) AM_BASE(&nemesis_yscroll1)
476   AM_RANGE(0x190f80, 0x190fff) AM_BASE(&nemesis_yscroll2)
488   AM_RANGE(0x190000, 0x1903ff) AM_BASE_MEMBER(nemesis_state, xscroll2)
489   AM_RANGE(0x190400, 0x1907ff) AM_BASE_MEMBER(nemesis_state, xscroll1)
490   AM_RANGE(0x190f00, 0x190f7f) AM_BASE_MEMBER(nemesis_state, yscroll1)
491   AM_RANGE(0x190f80, 0x190fff) AM_BASE_MEMBER(nemesis_state, yscroll2)
477492ADDRESS_MAP_END
478493
479494static ADDRESS_MAP_START( blkpnthr_map, ADDRESS_SPACE_PROGRAM, 16 )
480495   AM_RANGE(0x000000, 0x07ffff) AM_ROM
481   AM_RANGE(0x080000, 0x081fff) AM_RAM_WRITE(salamander_palette_word_w) AM_BASE_GENERIC(paletteram)
496   AM_RANGE(0x080000, 0x081fff) AM_RAM_WRITE(salamander_palette_word_w) AM_BASE_MEMBER(nemesis_state, paletteram)
482497   AM_RANGE(0x090000, 0x097fff) AM_RAM
483498   AM_RANGE(0x0a0000, 0x0a0001) AM_RAM_WRITE(salamand_control_port_word_w)      /* irq enable, flipscreen, etc. */
484499   AM_RANGE(0x0c0000, 0x0c0001) AM_WRITE(nemesis_soundlatch_word_w)
r7500r7501
488503   AM_RANGE(0x0c2002, 0x0c2003) AM_READ_PORT("IN1")
489504   AM_RANGE(0x0c2004, 0x0c2005) AM_READ_PORT("IN2")
490505   AM_RANGE(0x0c2006, 0x0c2007) AM_READ_PORT("DSW1")
491   AM_RANGE(0x100000, 0x100fff) AM_RAM_WRITE(nemesis_colorram1_word_w) AM_BASE(&nemesis_colorram1) AM_MIRROR(0x4000)   /* VRAM */
492   AM_RANGE(0x101000, 0x101fff) AM_RAM_WRITE(nemesis_colorram2_word_w) AM_BASE(&nemesis_colorram2) AM_MIRROR(0x4000)
493   AM_RANGE(0x102000, 0x102fff) AM_RAM_WRITE(nemesis_videoram1_word_w) AM_BASE(&nemesis_videoram1)
494   AM_RANGE(0x103000, 0x103fff) AM_RAM_WRITE(nemesis_videoram2_word_w) AM_BASE(&nemesis_videoram2)
495   AM_RANGE(0x120000, 0x12ffff) AM_RAM_WRITE(nemesis_characterram_word_w) AM_BASE(&nemesis_characterram) AM_SIZE(&nemesis_characterram_size)
506   AM_RANGE(0x100000, 0x100fff) AM_RAM_WRITE(nemesis_colorram1_word_w) AM_BASE_MEMBER(nemesis_state, colorram1) AM_MIRROR(0x4000)   /* VRAM */
507   AM_RANGE(0x101000, 0x101fff) AM_RAM_WRITE(nemesis_colorram2_word_w) AM_BASE_MEMBER(nemesis_state, colorram2) AM_MIRROR(0x4000)
508   AM_RANGE(0x102000, 0x102fff) AM_RAM_WRITE(nemesis_videoram1_word_w) AM_BASE_MEMBER(nemesis_state, videoram1)
509   AM_RANGE(0x103000, 0x103fff) AM_RAM_WRITE(nemesis_videoram2_word_w) AM_BASE_MEMBER(nemesis_state, videoram2)
510   AM_RANGE(0x120000, 0x12ffff) AM_RAM_WRITE(nemesis_charram_word_w) AM_BASE_SIZE_MEMBER(nemesis_state, charram, charram_size)
496511   AM_RANGE(0x180000, 0x181fff) AM_RAM
497   AM_RANGE(0x180000, 0x1803ff) AM_BASE(&nemesis_xscroll1)
498   AM_RANGE(0x180400, 0x1807ff) AM_BASE(&nemesis_xscroll2)
499   AM_RANGE(0x180f00, 0x180f7f) AM_BASE(&nemesis_yscroll2)
500   AM_RANGE(0x180f80, 0x180fff) AM_BASE(&nemesis_yscroll1)
501   AM_RANGE(0x190000, 0x190fff) AM_RAM AM_BASE_SIZE_GENERIC(spriteram)      /* more sprite ram ??? */
512   AM_RANGE(0x180000, 0x1803ff) AM_BASE_MEMBER(nemesis_state, xscroll1)
513   AM_RANGE(0x180400, 0x1807ff) AM_BASE_MEMBER(nemesis_state, xscroll2)
514   AM_RANGE(0x180f00, 0x180f7f) AM_BASE_MEMBER(nemesis_state, yscroll2)
515   AM_RANGE(0x180f80, 0x180fff) AM_BASE_MEMBER(nemesis_state, yscroll1)
516   AM_RANGE(0x190000, 0x190fff) AM_RAM AM_BASE_SIZE_MEMBER(nemesis_state, spriteram, spriteram_size)      /* more sprite ram ??? */
502517ADDRESS_MAP_END
503518
504519static ADDRESS_MAP_START( citybomb_map, ADDRESS_SPACE_PROGRAM, 16 )
505520   AM_RANGE(0x000000, 0x01ffff) AM_ROM
506521   AM_RANGE(0x080000, 0x087fff) AM_RAM
507   AM_RANGE(0x0e0000, 0x0e1fff) AM_RAM_WRITE(salamander_palette_word_w) AM_BASE_GENERIC(paletteram)
522   AM_RANGE(0x0e0000, 0x0e1fff) AM_RAM_WRITE(salamander_palette_word_w) AM_BASE_MEMBER(nemesis_state, paletteram)
508523   AM_RANGE(0x0f0000, 0x0f0001) AM_READ_PORT("DSW1")
509524   AM_RANGE(0x0f0002, 0x0f0003) AM_READ_PORT("IN2")
510525   AM_RANGE(0x0f0004, 0x0f0005) AM_READ_PORT("IN1")
r7500r7501
515530   AM_RANGE(0x0f0020, 0x0f0021) AM_READ(selected_ip_word_r) AM_WRITENOP   /* WEC Le Mans 24 control? */
516531   AM_RANGE(0x0f8000, 0x0f8001) AM_WRITE(salamand_control_port_word_w)      /* irq enable, flipscreen, etc. */
517532   AM_RANGE(0x100000, 0x1bffff) AM_ROM
518   AM_RANGE(0x200000, 0x20ffff) AM_RAM_WRITE(nemesis_characterram_word_w) AM_BASE(&nemesis_characterram) AM_SIZE(&nemesis_characterram_size)
519   AM_RANGE(0x210000, 0x210fff) AM_RAM_WRITE(nemesis_videoram1_word_w) AM_BASE(&nemesis_videoram1)      /* VRAM */
520   AM_RANGE(0x211000, 0x211fff) AM_RAM_WRITE(nemesis_videoram2_word_w) AM_BASE(&nemesis_videoram2)
521   AM_RANGE(0x212000, 0x212fff) AM_RAM_WRITE(nemesis_colorram1_word_w) AM_BASE(&nemesis_colorram1)
522   AM_RANGE(0x213000, 0x213fff) AM_RAM_WRITE(nemesis_colorram2_word_w) AM_BASE(&nemesis_colorram2)
533   AM_RANGE(0x200000, 0x20ffff) AM_RAM_WRITE(nemesis_charram_word_w) AM_BASE_SIZE_MEMBER(nemesis_state, charram, charram_size)
534   AM_RANGE(0x210000, 0x210fff) AM_RAM_WRITE(nemesis_videoram1_word_w) AM_BASE_MEMBER(nemesis_state, videoram1)      /* VRAM */
535   AM_RANGE(0x211000, 0x211fff) AM_RAM_WRITE(nemesis_videoram2_word_w) AM_BASE_MEMBER(nemesis_state, videoram2)
536   AM_RANGE(0x212000, 0x212fff) AM_RAM_WRITE(nemesis_colorram1_word_w) AM_BASE_MEMBER(nemesis_state, colorram1)
537   AM_RANGE(0x213000, 0x213fff) AM_RAM_WRITE(nemesis_colorram2_word_w) AM_BASE_MEMBER(nemesis_state, colorram2)
523538   AM_RANGE(0x300000, 0x301fff) AM_RAM
524   AM_RANGE(0x300000, 0x3003ff) AM_BASE(&nemesis_xscroll1)
525   AM_RANGE(0x300400, 0x3007ff) AM_BASE(&nemesis_xscroll2)
526   AM_RANGE(0x300f00, 0x300f7f) AM_BASE(&nemesis_yscroll2)
527   AM_RANGE(0x300f80, 0x300fff) AM_BASE(&nemesis_yscroll1)
528   AM_RANGE(0x310000, 0x310fff) AM_RAM AM_BASE_SIZE_GENERIC(spriteram)      /* more sprite ram ??? */
539   AM_RANGE(0x300000, 0x3003ff) AM_BASE_MEMBER(nemesis_state, xscroll1)
540   AM_RANGE(0x300400, 0x3007ff) AM_BASE_MEMBER(nemesis_state, xscroll2)
541   AM_RANGE(0x300f00, 0x300f7f) AM_BASE_MEMBER(nemesis_state, yscroll2)
542   AM_RANGE(0x300f80, 0x300fff) AM_BASE_MEMBER(nemesis_state, yscroll1)
543   AM_RANGE(0x310000, 0x310fff) AM_RAM AM_BASE_SIZE_MEMBER(nemesis_state, spriteram, spriteram_size)      /* more sprite ram ??? */
529544ADDRESS_MAP_END
530545
531546static ADDRESS_MAP_START( nyanpani_map, ADDRESS_SPACE_PROGRAM, 16 )
532547   AM_RANGE(0x000000, 0x01ffff) AM_ROM
533548   AM_RANGE(0x040000, 0x047fff) AM_RAM
534   AM_RANGE(0x060000, 0x061fff) AM_RAM_WRITE(salamander_palette_word_w) AM_BASE_GENERIC(paletteram)
549   AM_RANGE(0x060000, 0x061fff) AM_RAM_WRITE(salamander_palette_word_w) AM_BASE_MEMBER(nemesis_state, paletteram)
535550   AM_RANGE(0x100000, 0x13ffff) AM_ROM
536551   AM_RANGE(0x070000, 0x070001) AM_READ_PORT("DSW1")
537552   AM_RANGE(0x070002, 0x070003) AM_READ_PORT("IN2")
r7500r7501
541556   AM_RANGE(0x070010, 0x070011) AM_WRITE(nemesis_soundlatch_word_w)
542557   AM_RANGE(0x070018, 0x070019) AM_WRITE(watchdog_reset16_w)   /* probably */
543558   AM_RANGE(0x078000, 0x078001) AM_WRITE(salamand_control_port_word_w)      /* irq enable, flipscreen, etc. */
544   AM_RANGE(0x200000, 0x200fff) AM_RAM_WRITE(nemesis_videoram1_word_w) AM_BASE(&nemesis_videoram1)      /* VRAM */
545   AM_RANGE(0x201000, 0x201fff) AM_RAM_WRITE(nemesis_videoram2_word_w) AM_BASE(&nemesis_videoram2)
546   AM_RANGE(0x202000, 0x202fff) AM_RAM_WRITE(nemesis_colorram1_word_w) AM_BASE(&nemesis_colorram1)
547   AM_RANGE(0x203000, 0x203fff) AM_RAM_WRITE(nemesis_colorram2_word_w) AM_BASE(&nemesis_colorram2)
548   AM_RANGE(0x210000, 0x21ffff) AM_RAM_WRITE(nemesis_characterram_word_w) AM_BASE(&nemesis_characterram) AM_SIZE(&nemesis_characterram_size)
549   AM_RANGE(0x300000, 0x300fff) AM_RAM AM_BASE_SIZE_GENERIC(spriteram)      /* more sprite ram ??? */
559   AM_RANGE(0x200000, 0x200fff) AM_RAM_WRITE(nemesis_videoram1_word_w) AM_BASE_MEMBER(nemesis_state, videoram1)      /* VRAM */
560   AM_RANGE(0x201000, 0x201fff) AM_RAM_WRITE(nemesis_videoram2_word_w) AM_BASE_MEMBER(nemesis_state, videoram2)
561   AM_RANGE(0x202000, 0x202fff) AM_RAM_WRITE(nemesis_colorram1_word_w) AM_BASE_MEMBER(nemesis_state, colorram1)
562   AM_RANGE(0x203000, 0x203fff) AM_RAM_WRITE(nemesis_colorram2_word_w) AM_BASE_MEMBER(nemesis_state, colorram2)
563   AM_RANGE(0x210000, 0x21ffff) AM_RAM_WRITE(nemesis_charram_word_w) AM_BASE_SIZE_MEMBER(nemesis_state, charram, charram_size)
564   AM_RANGE(0x300000, 0x300fff) AM_RAM AM_BASE_SIZE_MEMBER(nemesis_state, spriteram, spriteram_size)      /* more sprite ram ??? */
550565   AM_RANGE(0x310000, 0x311fff) AM_RAM
551   AM_RANGE(0x310000, 0x3103ff) AM_BASE(&nemesis_xscroll1)
552   AM_RANGE(0x310400, 0x3107ff) AM_BASE(&nemesis_xscroll2)
553   AM_RANGE(0x310f00, 0x310f7f) AM_BASE(&nemesis_yscroll2)
554   AM_RANGE(0x310f80, 0x310fff) AM_BASE(&nemesis_yscroll1)
566   AM_RANGE(0x310000, 0x3103ff) AM_BASE_MEMBER(nemesis_state, xscroll1)
567   AM_RANGE(0x310400, 0x3107ff) AM_BASE_MEMBER(nemesis_state, xscroll2)
568   AM_RANGE(0x310f00, 0x310f7f) AM_BASE_MEMBER(nemesis_state, yscroll2)
569   AM_RANGE(0x310f80, 0x310fff) AM_BASE_MEMBER(nemesis_state, yscroll1)
555570ADDRESS_MAP_END
556571
557572static READ8_HANDLER( wd_r )
558573{
559   frame_counter^= 1;
560   return frame_counter;
574   nemesis_state *state = (nemesis_state *)space->machine->driver_data;
575   state->frame_counter ^= 1;
576   return state->frame_counter;
561577}
562578
563579static ADDRESS_MAP_START( sal_sound_map, ADDRESS_SPACE_PROGRAM, 8 )
564580   AM_RANGE(0x0000, 0x7fff) AM_ROM
565581   AM_RANGE(0x8000, 0x87ff) AM_RAM
566582   AM_RANGE(0xa000, 0xa000) AM_READ(soundlatch_r)
567   AM_RANGE(0xb000, 0xb00d) AM_DEVREADWRITE("konami", k007232_r, k007232_w)
583   AM_RANGE(0xb000, 0xb00d) AM_DEVREADWRITE("k007232", k007232_r, k007232_w)
568584   AM_RANGE(0xc000, 0xc001) AM_DEVREADWRITE("ymsnd", ym2151_r, ym2151_w)
569585   AM_RANGE(0xd000, 0xd000) AM_DEVWRITE("vlm", vlm5030_data_w)
570586   AM_RANGE(0xe000, 0xe000) AM_READ(wd_r) /* watchdog?? */
r7500r7501
575591   AM_RANGE(0x0000, 0x7fff) AM_ROM
576592   AM_RANGE(0x8000, 0x87ff) AM_RAM
577593   AM_RANGE(0xa000, 0xa000) AM_READ(soundlatch_r)
578   AM_RANGE(0xb000, 0xb00d) AM_DEVREADWRITE("konami", k007232_r, k007232_w)
594   AM_RANGE(0xb000, 0xb00d) AM_DEVREADWRITE("k007232", k007232_r, k007232_w)
579595   AM_RANGE(0xc000, 0xc001) AM_DEVREADWRITE("ymsnd", ym2151_r, ym2151_w)
580596   AM_RANGE(0xe000, 0xe000) AM_READ(wd_r) /* watchdog?? */
581597ADDRESS_MAP_END
r7500r7501
583599static ADDRESS_MAP_START( city_sound_map, ADDRESS_SPACE_PROGRAM, 8 )
584600   AM_RANGE(0x0000, 0x7fff) AM_ROM
585601   AM_RANGE(0x8000, 0x87ff) AM_RAM
586   AM_RANGE(0x9800, 0x987f) AM_DEVWRITE("konami2", k051649_waveform_w)
587   AM_RANGE(0x9880, 0x9889) AM_DEVWRITE("konami2", k051649_frequency_w)
588   AM_RANGE(0x988a, 0x988e) AM_DEVWRITE("konami2", k051649_volume_w)
589   AM_RANGE(0x988f, 0x988f) AM_DEVWRITE("konami2", k051649_keyonoff_w)
602   AM_RANGE(0x9800, 0x987f) AM_DEVWRITE("k051649", k051649_waveform_w)
603   AM_RANGE(0x9880, 0x9889) AM_DEVWRITE("k051649", k051649_frequency_w)
604   AM_RANGE(0x988a, 0x988e) AM_DEVWRITE("k051649", k051649_volume_w)
605   AM_RANGE(0x988f, 0x988f) AM_DEVWRITE("k051649", k051649_keyonoff_w)
590606   AM_RANGE(0xa000, 0xa001) AM_DEVREADWRITE("ymsnd", ym3812_r, ym3812_w)
591   AM_RANGE(0xb000, 0xb00d) AM_DEVREADWRITE("konami", k007232_r, k007232_w)
592   AM_RANGE(0xc000, 0xc000) AM_DEVWRITE("konami", city_sound_bank_w) /* 7232 bankswitch */
607   AM_RANGE(0xb000, 0xb00d) AM_DEVREADWRITE("k007232", k007232_r, k007232_w)
608   AM_RANGE(0xc000, 0xc000) AM_DEVWRITE("k007232", city_sound_bank_w) /* 7232 bankswitch */
593609   AM_RANGE(0xd000, 0xd000) AM_READ(soundlatch_r)
594610ADDRESS_MAP_END
595611
r7500r7501
599615   AM_RANGE(0x000000, 0x00ffff) AM_ROM
600616   AM_RANGE(0x040000, 0x05ffff) AM_ROM
601617   AM_RANGE(0x080000, 0x083fff) AM_RAM
602   AM_RANGE(0x090000, 0x091fff) AM_RAM_WRITE(salamander_palette_word_w) AM_BASE_GENERIC(paletteram)
618   AM_RANGE(0x090000, 0x091fff) AM_RAM_WRITE(salamander_palette_word_w) AM_BASE_MEMBER(nemesis_state, paletteram)
603619   AM_RANGE(0x0a0000, 0x0a0001) AM_WRITE(salamand_control_port_word_w)      /* irq enable, flipscreen, etc. */
604620   AM_RANGE(0x0c0000, 0x0c0001) AM_WRITE(nemesis_soundlatch_word_w)
605621   AM_RANGE(0x0c0002, 0x0c0003) AM_READ_PORT("DSW0")
r7500r7501
613629   AM_RANGE(0x0c2804, 0x0c2805) AM_WRITENOP
614630   AM_RANGE(0x0c4000, 0x0c4001) AM_READ_PORT("IN1") AM_WRITE(selected_ip_word_w)
615631   AM_RANGE(0x0c4002, 0x0c4003) AM_READ(selected_ip_word_r) AM_WRITENOP   /* WEC Le Mans 24 control. latches the value read previously */
616   AM_RANGE(0x100000, 0x100fff) AM_RAM_WRITE(nemesis_videoram2_word_w) AM_BASE(&nemesis_videoram2)      /* VRAM */
617   AM_RANGE(0x101000, 0x101fff) AM_RAM_WRITE(nemesis_videoram1_word_w) AM_BASE(&nemesis_videoram1)
618   AM_RANGE(0x102000, 0x102fff) AM_RAM_WRITE(nemesis_colorram2_word_w) AM_BASE(&nemesis_colorram2)
619   AM_RANGE(0x103000, 0x103fff) AM_RAM_WRITE(nemesis_colorram1_word_w) AM_BASE(&nemesis_colorram1)
620   AM_RANGE(0x120000, 0x12ffff) AM_RAM_WRITE(nemesis_characterram_word_w) AM_BASE(&nemesis_characterram) AM_SIZE(&nemesis_characterram_size)
621   AM_RANGE(0x180000, 0x180fff) AM_RAM AM_BASE_SIZE_GENERIC(spriteram)
632   AM_RANGE(0x100000, 0x100fff) AM_RAM_WRITE(nemesis_videoram2_word_w) AM_BASE_MEMBER(nemesis_state, videoram2)      /* VRAM */
633   AM_RANGE(0x101000, 0x101fff) AM_RAM_WRITE(nemesis_videoram1_word_w) AM_BASE_MEMBER(nemesis_state, videoram1)
634   AM_RANGE(0x102000, 0x102fff) AM_RAM_WRITE(nemesis_colorram2_word_w) AM_BASE_MEMBER(nemesis_state, colorram2)
635   AM_RANGE(0x103000, 0x103fff) AM_RAM_WRITE(nemesis_colorram1_word_w) AM_BASE_MEMBER(nemesis_state, colorram1)
636   AM_RANGE(0x120000, 0x12ffff) AM_RAM_WRITE(nemesis_charram_word_w) AM_BASE_SIZE_MEMBER(nemesis_state, charram, charram_size)
637   AM_RANGE(0x180000, 0x180fff) AM_RAM AM_BASE_SIZE_MEMBER(nemesis_state, spriteram, spriteram_size)
622638   AM_RANGE(0x190000, 0x191fff) AM_RAM
623   AM_RANGE(0x190000, 0x1903ff) AM_BASE(&nemesis_xscroll2)
624   AM_RANGE(0x190400, 0x1907ff) AM_BASE(&nemesis_xscroll1)
625   AM_RANGE(0x190f00, 0x190f7f) AM_BASE(&nemesis_yscroll1)
626   AM_RANGE(0x190f80, 0x190fff) AM_BASE(&nemesis_yscroll2)
639   AM_RANGE(0x190000, 0x1903ff) AM_BASE_MEMBER(nemesis_state, xscroll2)
640   AM_RANGE(0x190400, 0x1907ff) AM_BASE_MEMBER(nemesis_state, xscroll1)
641   AM_RANGE(0x190f00, 0x190f7f) AM_BASE_MEMBER(nemesis_state, yscroll1)
642   AM_RANGE(0x190f80, 0x190fff) AM_BASE_MEMBER(nemesis_state, yscroll2)
627643ADDRESS_MAP_END
628644
629645/******************************************************************************/
r7500r7501
15941610   AY8910_DEFAULT_LOADS,
15951611   DEVCB_NULL,
15961612   DEVCB_NULL,
1597   DEVCB_DEVICE_HANDLER("konami", k005289_control_A_w),
1598   DEVCB_DEVICE_HANDLER("konami", k005289_control_B_w)
1613   DEVCB_DEVICE_HANDLER("k007232", k005289_control_A_w),
1614   DEVCB_DEVICE_HANDLER("k007232", k005289_control_B_w)
15991615};
16001616
16011617static void sound_irq(running_device *device, int state)
16021618{
16031619/* Interrupts _are_ generated, I wonder where they go.. */
1604/*cputag_set_input_line(device->machine, "audiocpu", 0, HOLD_LINE);*/
1620// nemesis_state *driver_state = (nemesis_state *)device->machine->driver_data;
1621// cpu_set_input_line(driver_state->audiocpu, 0, HOLD_LINE);
16051622}
16061623
16071624static const ym2151_interface ym2151_config =
r7500r7501
16161633
16171634static void volume_callback(running_device *device, int v)
16181635{
1619   k007232_set_volume(device,0,(v >> 4) * 0x11,0);
1620   k007232_set_volume(device,1,0,(v & 0x0f) * 0x11);
1636   k007232_set_volume(device, 0, (v >> 4) * 0x11, 0);
1637   k007232_set_volume(device, 1, 0, (v & 0x0f) * 0x11);
16211638}
16221639
16231640static const k007232_interface k007232_config =
r7500r7501
16271644
16281645/******************************************************************************/
16291646
1647static MACHINE_START( nemesis )
1648{
1649   nemesis_state *state = (nemesis_state *)machine->driver_data;
1650
1651   state->maincpu = devtag_get_device(machine, "maincpu");
1652   state->audiocpu = devtag_get_device(machine, "audiocpu");
1653   state->vlm = devtag_get_device(machine, "vlm");
1654
1655   state_save_register_global(machine, state->irq_on);
1656   state_save_register_global(machine, state->irq1_on);
1657   state_save_register_global(machine, state->irq2_on);
1658   state_save_register_global(machine, state->irq4_on);
1659   state_save_register_global(machine, state->frame_counter);
1660   state_save_register_global(machine, state->gx400_irq1_cnt);
1661   state_save_register_global(machine, state->selected_ip);
1662
1663   state_save_register_global(machine, state->tilemap_flip);
1664   state_save_register_global(machine, state->flipscreen);
1665   state_save_register_global(machine, state->irq_port_last);
1666}
1667
1668static MACHINE_RESET( nemesis )
1669{
1670   nemesis_state *state = (nemesis_state *)machine->driver_data;
1671
1672   state->irq_on = 0;
1673   state->irq1_on = 0;
1674   state->irq2_on = 0;
1675   state->irq4_on = 0;
1676   state->gx400_irq1_cnt = 0;
1677   state->frame_counter = 1;
1678   state->selected_ip = 0;
1679
1680   state->flipscreen = 0;
1681   state->tilemap_flip = 0;
1682   state->irq_port_last = 0;
1683}
1684
16301685static MACHINE_DRIVER_START( nemesis )
16311686
1687   /* driver data */
1688   MDRV_DRIVER_DATA(nemesis_state)
1689
16321690   /* basic machine hardware */
16331691   MDRV_CPU_ADD("maincpu", M68000,18432000/2)         /* 9.216 MHz? */
16341692//          14318180/2, /* From schematics, should be accurate */
r7500r7501
16381696   MDRV_CPU_ADD("audiocpu", Z80,14318180/4) /* From schematics, should be accurate */
16391697   MDRV_CPU_PROGRAM_MAP(sound_map)   /* fixed */
16401698
1699   MDRV_MACHINE_START(nemesis)
16411700   MDRV_MACHINE_RESET(nemesis)
16421701
16431702   /* video hardware */
r7500r7501
16651724   MDRV_SOUND_CONFIG(ay8910_interface_2)   /* fixed */
16661725   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.00)   /* verified with OST */
16671726
1668   MDRV_SOUND_ADD("konami", K005289, 3579545/2)
1727   MDRV_SOUND_ADD("k007232", K005289, 3579545/2)
16691728   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.35)   /* verified with OST */
16701729
16711730   MDRV_SOUND_ADD("vlm", VLM5030, 3579545)
r7500r7501
16751734
16761735static MACHINE_DRIVER_START( gx400 )
16771736
1737   /* driver data */
1738   MDRV_DRIVER_DATA(nemesis_state)
1739
16781740   /* basic machine hardware */
16791741   MDRV_CPU_ADD("maincpu", M68000,18432000/2)     /* 9.216MHz */
16801742   MDRV_CPU_PROGRAM_MAP(gx400_map)
r7500r7501
16841746   MDRV_CPU_PROGRAM_MAP(gx400_sound_map)
16851747   MDRV_CPU_VBLANK_INT("screen", nmi_line_pulse)   /* interrupts are triggered by the main CPU */
16861748
1749   MDRV_MACHINE_START(nemesis)
16871750   MDRV_MACHINE_RESET(nemesis)
16881751
16891752   /* video hardware */
r7500r7501
17111774   MDRV_SOUND_CONFIG(ay8910_interface_2)
17121775   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.00)   /* verified with OST */
17131776
1714   MDRV_SOUND_ADD("konami", K005289, 3579545/2)
1777   MDRV_SOUND_ADD("k007232", K005289, 3579545/2)
17151778   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.35)   /* verified with OST */
17161779
17171780   MDRV_SOUND_ADD("vlm", VLM5030, 3579545)
r7500r7501
17211784
17221785static MACHINE_DRIVER_START( konamigt )
17231786
1787   /* driver data */
1788   MDRV_DRIVER_DATA(nemesis_state)
1789
17241790   /* basic machine hardware */
17251791   MDRV_CPU_ADD("maincpu", M68000,18432000/2)         /* 9.216 MHz? */
17261792   MDRV_CPU_PROGRAM_MAP(konamigt_map)
r7500r7501
17291795   MDRV_CPU_ADD("audiocpu", Z80,14318180/4)        /* 3.579545 MHz */
17301796   MDRV_CPU_PROGRAM_MAP(sound_map)
17311797
1798   MDRV_MACHINE_START(nemesis)
17321799   MDRV_MACHINE_RESET(nemesis)
17331800
17341801   /* video hardware */
r7500r7501
17561823   MDRV_SOUND_CONFIG(ay8910_interface_2)
17571824   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.80)
17581825
1759   MDRV_SOUND_ADD("konami", K005289, 3579545/2)
1826   MDRV_SOUND_ADD("k007232", K005289, 3579545/2)
17601827   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.60)
17611828MACHINE_DRIVER_END
17621829
17631830
17641831static MACHINE_DRIVER_START( rf2_gx400 )
17651832
1833   /* driver data */
1834   MDRV_DRIVER_DATA(nemesis_state)
1835
17661836   /* basic machine hardware */
17671837   MDRV_CPU_ADD("maincpu", M68000,18432000/2)     /* 9.216MHz */
17681838   MDRV_CPU_PROGRAM_MAP(rf2_gx400_map)
r7500r7501
17721842   MDRV_CPU_PROGRAM_MAP(gx400_sound_map)
17731843   MDRV_CPU_VBLANK_INT("screen", nmi_line_pulse)   /* interrupts are triggered by the main CPU */
17741844
1845   MDRV_MACHINE_START(nemesis)
17751846   MDRV_MACHINE_RESET(nemesis)
17761847
17771848   /* video hardware */
r7500r7501
17991870   MDRV_SOUND_CONFIG(ay8910_interface_2)
18001871   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.80)
18011872
1802   MDRV_SOUND_ADD("konami", K005289, 3579545/2)
1873   MDRV_SOUND_ADD("k007232", K005289, 3579545/2)
18031874   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.60)
18041875
18051876   MDRV_SOUND_ADD("vlm", VLM5030, 3579545)
r7500r7501
18091880
18101881static MACHINE_DRIVER_START( salamand )
18111882
1883   /* driver data */
1884   MDRV_DRIVER_DATA(nemesis_state)
1885
18121886   /* basic machine hardware */
18131887   MDRV_CPU_ADD("maincpu", M68000,18432000/2)       /* 9.216MHz */
18141888   MDRV_CPU_PROGRAM_MAP(salamand_map)
r7500r7501
18171891   MDRV_CPU_ADD("audiocpu", Z80, 3579545)         /* 3.579545 MHz */
18181892   MDRV_CPU_PROGRAM_MAP(sal_sound_map)
18191893
1894   MDRV_MACHINE_START(nemesis)
18201895   MDRV_MACHINE_RESET(nemesis)
18211896
18221897   /* video hardware */
r7500r7501
18421917   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 0.60)
18431918   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 0.60)
18441919
1845   MDRV_SOUND_ADD("konami", K007232, 3579545)
1920   MDRV_SOUND_ADD("k007232", K007232, 3579545)
18461921   MDRV_SOUND_CONFIG(k007232_config)
18471922   MDRV_SOUND_ROUTE(0, "lspeaker", 0.10)
18481923   MDRV_SOUND_ROUTE(0, "rspeaker", 0.10)
r7500r7501
18581933
18591934static MACHINE_DRIVER_START( blkpnthr )
18601935
1936   /* driver data */
1937   MDRV_DRIVER_DATA(nemesis_state)
1938
18611939   /* basic machine hardware */
18621940   MDRV_CPU_ADD("maincpu", M68000,18432000/2)         /* 9.216 MHz? */
18631941   MDRV_CPU_PROGRAM_MAP(blkpnthr_map)
r7500r7501
18661944   MDRV_CPU_ADD("audiocpu", Z80, 3579545)        /* 3.579545 MHz */
18671945   MDRV_CPU_PROGRAM_MAP(blkpnthr_sound_map)
18681946
1947   MDRV_MACHINE_START(nemesis)
18691948   MDRV_MACHINE_RESET(nemesis)
18701949
18711950   /* video hardware */
r7500r7501
18871966   /* sound hardware */
18881967   MDRV_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker")
18891968
1890   MDRV_SOUND_ADD("konami", K007232, 3579545)
1969   MDRV_SOUND_ADD("k007232", K007232, 3579545)
18911970   MDRV_SOUND_CONFIG(k007232_config)
18921971   MDRV_SOUND_ROUTE(0, "lspeaker", 0.10)
18931972   MDRV_SOUND_ROUTE(0, "rspeaker", 0.10)
r7500r7501
19031982
19041983static MACHINE_DRIVER_START( citybomb )
19051984
1985   /* driver data */
1986   MDRV_DRIVER_DATA(nemesis_state)
1987
19061988   /* basic machine hardware */
19071989   MDRV_CPU_ADD("maincpu", M68000,18432000/2)         /* 9.216 MHz? */
19081990   MDRV_CPU_PROGRAM_MAP(citybomb_map)
r7500r7501
19111993   MDRV_CPU_ADD("audiocpu", Z80, 3579545)        /* 3.579545 MHz */
19121994   MDRV_CPU_PROGRAM_MAP(city_sound_map)
19131995
1996   MDRV_MACHINE_START(nemesis)
19141997   MDRV_MACHINE_RESET(nemesis)
19151998
19161999   /* video hardware */
r7500r7501
19322015   /* sound hardware */
19332016   MDRV_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker")
19342017
1935   MDRV_SOUND_ADD("konami", K007232, 3579545)
2018   MDRV_SOUND_ADD("k007232", K007232, 3579545)
19362019   MDRV_SOUND_CONFIG(k007232_config)
19372020   MDRV_SOUND_ROUTE(0, "lspeaker", 0.30)
19382021   MDRV_SOUND_ROUTE(0, "rspeaker", 0.30)
r7500r7501
19442027   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 1.0)
19452028   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 1.0)
19462029
1947   MDRV_SOUND_ADD("konami2", K051649, 3579545/2)
2030   MDRV_SOUND_ADD("k051649", K051649, 3579545/2)
19482031   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 0.38)
19492032   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 0.38)
19502033MACHINE_DRIVER_END
r7500r7501
19522035
19532036static MACHINE_DRIVER_START( nyanpani )
19542037
2038   /* driver data */
2039   MDRV_DRIVER_DATA(nemesis_state)
2040
19552041   /* basic machine hardware */
19562042   MDRV_CPU_ADD("maincpu", M68000,18432000/2)         /* 9.216 MHz? */
19572043   MDRV_CPU_PROGRAM_MAP(nyanpani_map)
r7500r7501
19602046   MDRV_CPU_ADD("audiocpu", Z80, 3579545)        /* 3.579545 MHz */
19612047   MDRV_CPU_PROGRAM_MAP(city_sound_map)
19622048
2049   MDRV_MACHINE_START(nemesis)
19632050   MDRV_MACHINE_RESET(nemesis)
19642051
19652052   /* video hardware */
r7500r7501
19812068   /* sound hardware */
19822069   MDRV_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker")
19832070
1984   MDRV_SOUND_ADD("konami", K007232, 3579545)
2071   MDRV_SOUND_ADD("k007232", K007232, 3579545)
19852072   MDRV_SOUND_CONFIG(k007232_config)
19862073   MDRV_SOUND_ROUTE(0, "lspeaker", 0.30)
19872074   MDRV_SOUND_ROUTE(0, "rspeaker", 0.30)
r7500r7501
19932080   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 1.0)
19942081   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 1.0)
19952082
1996   MDRV_SOUND_ADD("konami2", K051649, 3579545/2)
2083   MDRV_SOUND_ADD("k051649", K051649, 3579545/2)
19972084   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 0.38)
19982085   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 0.38)
19992086MACHINE_DRIVER_END
r7500r7501
20012088
20022089static MACHINE_DRIVER_START( hcrash )
20032090
2091   /* driver data */
2092   MDRV_DRIVER_DATA(nemesis_state)
2093
20042094   /* basic machine hardware */
20052095   MDRV_CPU_ADD("maincpu", M68000,18432000/3)         /* 6.144MHz */
20062096   MDRV_CPU_PROGRAM_MAP(hcrash_map)
r7500r7501
20092099   MDRV_CPU_ADD("audiocpu", Z80,14318180/4)       /* 3.579545 MHz */
20102100   MDRV_CPU_PROGRAM_MAP(sal_sound_map)
20112101
2102   MDRV_MACHINE_START(nemesis)
20122103   MDRV_MACHINE_RESET(nemesis)
20132104
20142105   /* video hardware */
r7500r7501
20322123   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "lspeaker", 0.60)
20332124   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "rspeaker", 0.60)
20342125
2035   MDRV_SOUND_ADD("konami", K007232, 3579545)
2126   MDRV_SOUND_ADD("k007232", K007232, 3579545)
20362127   MDRV_SOUND_CONFIG(k007232_config)
20372128   MDRV_SOUND_ROUTE(0, "lspeaker", 0.10)
20382129   MDRV_SOUND_ROUTE(0, "rspeaker", 0.10)
r7500r7501
20652156   ROM_REGION( 0x10000, "audiocpu", 0 )    /* 64k for sound */
20662157   ROM_LOAD(      "456-d09.9c",   0x00000, 0x4000, CRC(26bf9636) SHA1(009dcbf18ea6230fc75a72232bd4fc29ad28dbf0) )
20672158
2068   ROM_REGION( 0x0200,  "konami", 0 )      /* 2x 256 byte for 0005289 wavetable data */
2159   ROM_REGION( 0x0200,  "k007232", 0 )      /* 2x 256 byte for 0005289 wavetable data */
20692160   ROM_LOAD(      "400-a01.fse",  0x00000, 0x0100, CRC(5827b1e8) SHA1(fa8cf5f868cfb08bce203baaebb6c4055ee2a000) )
20702161   ROM_LOAD(      "400-a02.fse",  0x00100, 0x0100, CRC(2f44f970) SHA1(7ab46f9d5d587665782cefc623b8de0124a6d38a) )
20712162ROM_END
r7500r7501
20842175   ROM_REGION( 0x10000, "audiocpu", 0 )    /* 64k for sound */
20852176   ROM_LOAD(      "456-d09.9c",   0x00000, 0x4000, CRC(26bf9636) SHA1(009dcbf18ea6230fc75a72232bd4fc29ad28dbf0) )
20862177
2087   ROM_REGION( 0x0200,  "konami", 0 )      /* 2x 256 byte for 0005289 wavetable data */
2178   ROM_REGION( 0x0200,  "k007232", 0 )      /* 2x 256 byte for 0005289 wavetable data */
20882179   ROM_LOAD(      "400-a01.fse",  0x00000, 0x0100, CRC(5827b1e8) SHA1(fa8cf5f868cfb08bce203baaebb6c4055ee2a000) )
20892180   ROM_LOAD(      "400-a02.fse",  0x00100, 0x0100, CRC(2f44f970) SHA1(7ab46f9d5d587665782cefc623b8de0124a6d38a) )
20902181ROM_END
r7500r7501
21032194   ROM_REGION( 0x10000, "audiocpu", 0 )    /* 64k for sound */
21042195   ROM_LOAD(       "561-b09.9c",  0x00000, 0x4000, CRC(539d0c49) SHA1(4c16b07fbd876b6445fc0ec49c3ad5ab1a92cbf6) )
21052196
2106   ROM_REGION( 0x0200,  "konami", 0 )      /* 2x 256 byte for 0005289 wavetable data */
2197   ROM_REGION( 0x0200,  "k007232", 0 )      /* 2x 256 byte for 0005289 wavetable data */
21072198   ROM_LOAD(      "400-a01.fse",  0x00000, 0x0100, CRC(5827b1e8) SHA1(fa8cf5f868cfb08bce203baaebb6c4055ee2a000) )
21082199   ROM_LOAD(      "400-a02.fse",  0x00100, 0x0100, CRC(2f44f970) SHA1(7ab46f9d5d587665782cefc623b8de0124a6d38a) )
21092200ROM_END
r7500r7501
21182209   ROM_REGION( 0x10000, "audiocpu", 0 )    /* 64k for sound */
21192210   ROM_LOAD(      "400-e03.5l",   0x00000, 0x02000, CRC(a5a8e57d) SHA1(f4236770093392dec3f76835a5766e9b3ed64e2e) )
21202211
2121   ROM_REGION( 0x0200,  "konami", 0 )      /* 2x 256 byte for 0005289 wavetable data */
2212   ROM_REGION( 0x0200,  "k007232", 0 )      /* 2x 256 byte for 0005289 wavetable data */
21222213   ROM_LOAD(      "400-a01.fse",  0x00000, 0x0100, CRC(5827b1e8) SHA1(fa8cf5f868cfb08bce203baaebb6c4055ee2a000) )
21232214   ROM_LOAD(      "400-a02.fse",  0x00100, 0x0100, CRC(2f44f970) SHA1(7ab46f9d5d587665782cefc623b8de0124a6d38a) )
21242215ROM_END
r7500r7501
21332224   ROM_REGION( 0x10000, "audiocpu", 0 )    /* 64k for sound */
21342225   ROM_LOAD(      "400-e03.5l",   0x00000, 0x02000, CRC(a5a8e57d) SHA1(f4236770093392dec3f76835a5766e9b3ed64e2e) )
21352226
2136   ROM_REGION( 0x0200,  "konami", 0 )      /* 2x 256 byte for 0005289 wavetable data */
2227   ROM_REGION( 0x0200,  "k007232", 0 )      /* 2x 256 byte for 0005289 wavetable data */
21372228   ROM_LOAD(      "400-a01.fse",  0x00000, 0x0100, CRC(5827b1e8) SHA1(fa8cf5f868cfb08bce203baaebb6c4055ee2a000) )
21382229   ROM_LOAD(      "400-a02.fse",  0x00100, 0x0100, CRC(2f44f970) SHA1(7ab46f9d5d587665782cefc623b8de0124a6d38a) )
21392230ROM_END
r7500r7501
21482239   ROM_REGION( 0x10000, "audiocpu", 0 )    /* 64k for sound */
21492240   ROM_LOAD(      "400-e03.5l",   0x00000, 0x2000, CRC(a5a8e57d) SHA1(f4236770093392dec3f76835a5766e9b3ed64e2e) )
21502241
2151   ROM_REGION( 0x0200,  "konami", 0 )      /* 2x 256 byte for 0005289 wavetable data */
2242   ROM_REGION( 0x0200,  "k007232", 0 )      /* 2x 256 byte for 0005289 wavetable data */
21522243   ROM_LOAD(      "400-a01.fse",  0x00000, 0x0100, CRC(5827b1e8) SHA1(fa8cf5f868cfb08bce203baaebb6c4055ee2a000) )
21532244   ROM_LOAD(      "400-a02.fse",  0x00100, 0x0100, CRC(2f44f970) SHA1(7ab46f9d5d587665782cefc623b8de0124a6d38a) )
21542245ROM_END
r7500r7501
21632254   ROM_REGION( 0x10000, "audiocpu", 0 )    /* 64k for sound */
21642255   ROM_LOAD(      "400-e03.5l",   0x00000, 0x02000, CRC(a5a8e57d) SHA1(f4236770093392dec3f76835a5766e9b3ed64e2e) )
21652256
2166   ROM_REGION( 0x0200,  "konami", 0 )      /* 2x 256 byte for 0005289 wavetable data */
2257   ROM_REGION( 0x0200,  "k007232", 0 )      /* 2x 256 byte for 0005289 wavetable data */
21672258   ROM_LOAD(      "400-a01.fse",  0x00000, 0x0100, CRC(5827b1e8) SHA1(fa8cf5f868cfb08bce203baaebb6c4055ee2a000) )
21682259   ROM_LOAD(      "400-a02.fse",  0x00100, 0x0100, CRC(2f44f970) SHA1(7ab46f9d5d587665782cefc623b8de0124a6d38a) )
21692260ROM_END
r7500r7501
21812272   ROM_REGION( 0x04000, "vlm", 0 )    /* VLM5030 data? */
21822273   ROM_LOAD(      "587-d08.8g",       0x00000, 0x04000, CRC(f9ac6b82) SHA1(3370fc3a7f82e922e19d54afb3bca7b07fa4aa9a) )
21832274
2184   ROM_REGION( 0x20000, "konami", 0 )    /* 007232 data */
2275   ROM_REGION( 0x20000, "k007232", 0 )    /* 007232 data */
21852276   ROM_LOAD(      "587-c01.10a",      0x00000, 0x20000, CRC(09fe0632) SHA1(4c3b29c623d70bbe8a938a0beb4638912c46fb6a) ) /* Mask rom */
21862277ROM_END
21872278
r7500r7501
21982289   ROM_REGION( 0x04000, "vlm", 0 )    /* VLM5030 data? */
21992290   ROM_LOAD(      "587-d08.8g",       0x00000, 0x04000, CRC(f9ac6b82) SHA1(3370fc3a7f82e922e19d54afb3bca7b07fa4aa9a) )
22002291
2201   ROM_REGION( 0x20000, "konami", 0 )    /* 007232 data */
2292   ROM_REGION( 0x20000, "k007232", 0 )    /* 007232 data */
22022293   ROM_LOAD(      "587-c01.10a",      0x00000, 0x20000, CRC(09fe0632) SHA1(4c3b29c623d70bbe8a938a0beb4638912c46fb6a) ) /* Mask rom */
22032294ROM_END
22042295
r7500r7501
22152306   ROM_REGION( 0x04000, "vlm", 0 )    /* VLM5030 data? */
22162307   ROM_LOAD(      "587-k08.8g",  0x00000, 0x04000, CRC(7f0e9b41) SHA1(c9fc2723fac55691dfbb4cf9b3c472a42efa97c9) )
22172308
2218   ROM_REGION( 0x20000, "konami", 0 )    /* 007232 data */
2309   ROM_REGION( 0x20000, "k007232", 0 )    /* 007232 data */
22192310   ROM_LOAD(      "587-c01.10a",      0x00000, 0x20000, CRC(09fe0632) SHA1(4c3b29c623d70bbe8a938a0beb4638912c46fb6a) ) /* Mask rom */
22202311ROM_END
22212312
r7500r7501
22322323   ROM_REGION( 0x04000, "vlm", 0 )    /* VLM5030 data? */
22332324   ROM_LOAD(      "587-k08.8g",  0x00000, 0x04000, CRC(7f0e9b41) SHA1(c9fc2723fac55691dfbb4cf9b3c472a42efa97c9) )
22342325
2235   ROM_REGION( 0x20000, "konami", 0 )    /* 007232 data */
2326   ROM_REGION( 0x20000, "k007232", 0 )    /* 007232 data */
22362327   ROM_LOAD(      "587-c01.10a", 0x00000, 0x20000, CRC(09fe0632) SHA1(4c3b29c623d70bbe8a938a0beb4638912c46fb6a) ) /* Mask rom */
22372328ROM_END
22382329
r7500r7501
22462337   ROM_REGION( 0x10000, "audiocpu", 0 )    /* 64k for sound */
22472338   ROM_LOAD(      "604-a08.11j",  0x00000, 0x08000, CRC(aff88a2b) SHA1(7080add63deab5755606759a218dea9105df4819) )
22482339
2249   ROM_REGION( 0x20000, "konami", 0 )    /* 007232 data */
2340   ROM_REGION( 0x20000, "k007232", 0 )    /* 007232 data */
22502341   ROM_LOAD(      "604-a01.10a",  0x00000, 0x20000, CRC(eceb64a6) SHA1(028157d336770fe4ca17c24476d62a790255898a) )
22512342ROM_END
22522343
r7500r7501
22642355   ROM_REGION( 0x10000, "audiocpu", 0 )    /* 64k for sound */
22652356   ROM_LOAD(      "787-e02.4h",  0x00000, 0x08000, CRC(f4591e46) SHA1(c17c1a24bf1866fbba388521a4b7ea0975bda587) )
22662357
2267   ROM_REGION( 0x80000, "konami", 0 )    /* 007232 data */
2358   ROM_REGION( 0x80000, "k007232", 0 )    /* 007232 data */
22682359   ROM_LOAD(      "787-e01.1k",  0x00000, 0x80000, CRC(edc34d01) SHA1(b1465d1a7364a7cebc14b96cd01dc78e57975972) )
22692360ROM_END
22702361
r7500r7501
22822373   ROM_REGION( 0x10000, "audiocpu", 0 )    /* 64k for sound */
22832374   ROM_LOAD(      "787-e02.4h",  0x00000, 0x08000, CRC(f4591e46) SHA1(c17c1a24bf1866fbba388521a4b7ea0975bda587) )
22842375
2285   ROM_REGION( 0x80000, "konami", 0 )    /* 007232 data */
2376   ROM_REGION( 0x80000, "k007232", 0 )    /* 007232 data */
22862377   ROM_LOAD(      "787-e01.1k",  0x00000, 0x80000, CRC(edc34d01) SHA1(b1465d1a7364a7cebc14b96cd01dc78e57975972) )
22872378ROM_END
22882379
r7500r7501
22962387   ROM_REGION( 0x10000, "audiocpu", 0 )    /* 64k for sound */
22972388   ROM_LOAD(      "712-e02.4h",  0x00000, 0x08000, CRC(ba76f310) SHA1(cc2164a9617493d1b3b8ac67430f9eb26fd987d2) )
22982389
2299   ROM_REGION( 0x80000, "konami", 0 )    /* 007232 data */
2390   ROM_REGION( 0x80000, "k007232", 0 )    /* 007232 data */
23002391   ROM_LOAD(      "712-b01.1k",  0x00000, 0x80000, CRC(f65b5d95) SHA1(12701be68629844720cd16af857ce38ef06af61c) )
23012392ROM_END
23022393
r7500r7501
23102401   ROM_REGION( 0x10000, "audiocpu", 0 )    /* 64k for sound */
23112402   ROM_LOAD(      "712-e02.4h",  0x00000, 0x08000, CRC(ba76f310) SHA1(cc2164a9617493d1b3b8ac67430f9eb26fd987d2) )
23122403
2313   ROM_REGION( 0x80000, "konami", 0 )    /* 007232 data */
2404   ROM_REGION( 0x80000, "k007232", 0 )    /* 007232 data */
23142405   ROM_LOAD(      "712-b01.1k",  0x00000, 0x80000, CRC(f65b5d95) SHA1(12701be68629844720cd16af857ce38ef06af61c) )
23152406ROM_END
23162407
r7500r7501
24342525   ROM_LOAD( "790-c08.j4",   0x04000, 0x04000, CRC(cfb844bc) SHA1(43b7adb6093e707212204118087ef4f79b0dbc1f) )
24352526   ROM_CONTINUE(             0x00000, 0x04000 ) /* Board is wired for 27C128, top half of EPROM is blank */
24362527
2437   ROM_REGION( 0x80000, "konami", 0 )  /* 007232 data */
2528   ROM_REGION( 0x80000, "k007232", 0 )  /* 007232 data */
24382529   ROM_LOAD( "790-c01.m10",  0x00000, 0x20000, CRC(07976bc3) SHA1(9341ac6084fbbe17c4e7bbefade9a3f1dec3f132) )
24392530ROM_END
24402531
r7500r7501
24522543   ROM_LOAD( "790-c08.j4",   0x04000, 0x04000, CRC(cfb844bc) SHA1(43b7adb6093e707212204118087ef4f79b0dbc1f) )
24532544   ROM_CONTINUE(             0x00000, 0x04000 ) /* Board is wired for 27C128, top half of EPROM is blank */
24542545
2455   ROM_REGION( 0x80000, "konami", 0 )  /* 007232 data */
2546   ROM_REGION( 0x80000, "k007232", 0 )  /* 007232 data */
24562547   ROM_LOAD( "790-c01.m10",  0x00000, 0x20000, CRC(07976bc3) SHA1(9341ac6084fbbe17c4e7bbefade9a3f1dec3f132) )
24572548ROM_END
24582549
24592550
2460static DRIVER_INIT( nemesis )
2461{
2462   /* Set up save state */
2463   state_save_register_global(machine, nemesis_irq_on);
2464   state_save_register_global(machine, nemesis_irq1_on);
2465   state_save_register_global(machine, nemesis_irq2_on);
2466   state_save_register_global(machine, nemesis_irq4_on);
2467   state_save_register_global(machine, frame_counter);
2468   state_save_register_global(machine, gx400_irq1_cnt);
2469   state_save_register_global(machine, hcrash_selected_ip);
2470}
24712551
2472
2473GAME( 1985, nemesis,   0,         nemesis,    nemesis,   nemesis,  ROT0,   "Konami", "Nemesis",  GAME_SUPPORTS_SAVE )
2474GAME( 1985, nemesisuk, nemesis,   nemesis,    nemesuk,   nemesis,  ROT0,   "Konami", "Nemesis (World?)",  GAME_SUPPORTS_SAVE )
2475GAME( 1985, konamigt,  0,         konamigt,   konamigt,  nemesis,  ROT0,   "Konami", "Konami GT",  GAME_SUPPORTS_SAVE )
2476GAME( 1985, rf2,       konamigt,  rf2_gx400,  rf2,       nemesis,  ROT0,   "Konami", "Konami RF2 - Red Fighter",  GAME_SUPPORTS_SAVE )
2477GAME( 1985, twinbee,   0,         gx400,      twinbee,   nemesis,  ROT90,  "Konami", "TwinBee",  GAME_SUPPORTS_SAVE )
2478GAME( 1985, gradius,   nemesis,   gx400,      gradius,   nemesis,  ROT0,   "Konami", "Gradius",  GAME_SUPPORTS_SAVE )
2479GAME( 1985, gwarrior,  0,         gx400,      gwarrior,  nemesis,  ROT0,   "Konami", "Galactic Warriors",  GAME_SUPPORTS_SAVE )
2480GAME( 1986, salamand,  0,         salamand,   salamand,  nemesis,  ROT0,   "Konami", "Salamander (version D)",  GAME_SUPPORTS_SAVE )
2481GAME( 1986, salamandj, salamand,  salamand,   salamand,  nemesis,  ROT0,   "Konami", "Salamander (version J)",  GAME_SUPPORTS_SAVE )
2482GAME( 1986, lifefrce,  salamand,  salamand,   salamand,  nemesis,  ROT0,   "Konami", "Lifeforce (US)",  GAME_SUPPORTS_SAVE )
2483GAME( 1987, lifefrcej, salamand,  salamand,   lifefrcj,  nemesis,  ROT0,   "Konami", "Lifeforce (Japan)",  GAME_SUPPORTS_SAVE )
2484GAME( 1987, blkpnthr,  0,         blkpnthr,   blkpnthr,  nemesis,  ROT0,   "Konami", "Black Panther",  GAME_SUPPORTS_SAVE )
2485GAME( 1987, citybomb,  0,         citybomb,   citybomb,  nemesis,  ROT270, "Konami", "City Bomber (World)",  GAME_SUPPORTS_SAVE )
2486GAME( 1987, citybombj, citybomb,  citybomb,   citybomb,  nemesis,  ROT270, "Konami", "City Bomber (Japan)",  GAME_SUPPORTS_SAVE )
2487GAME( 1987, hcrash,    0,         hcrash,     hcrash,    nemesis,  ROT0,   "Konami", "Hyper Crash (version D)",  GAME_SUPPORTS_SAVE )
2488GAME( 1987, hcrashc,   hcrash,    hcrash,     hcrash,    nemesis,  ROT0,   "Konami", "Hyper Crash (version C)",  GAME_SUPPORTS_SAVE )
2489GAME( 1988, kittenk,   0,         nyanpani,   nyanpani,  nemesis,  ROT0,   "Konami", "Kitten Kaboodle",  GAME_SUPPORTS_SAVE )
2490GAME( 1988, nyanpani,  kittenk,   nyanpani,   nyanpani,  nemesis,  ROT0,   "Konami", "Nyan Nyan Panic (Japan)",  GAME_SUPPORTS_SAVE )
2552GAME( 1985, nemesis,   0,         nemesis,    nemesis,   0,    ROT0,   "Konami", "Nemesis",  GAME_SUPPORTS_SAVE )
2553GAME( 1985, nemesisuk, nemesis,   nemesis,    nemesuk,   0,    ROT0,   "Konami", "Nemesis (World?)",  GAME_SUPPORTS_SAVE )
2554GAME( 1985, konamigt,  0,         konamigt,   konamigt,  0,    ROT0,   "Konami", "Konami GT",  GAME_SUPPORTS_SAVE )
2555GAME( 1985, rf2,       konamigt,  rf2_gx400,  rf2,       0,    ROT0,   "Konami", "Konami RF2 - Red Fighter",  GAME_SUPPORTS_SAVE )
2556GAME( 1985, twinbee,   0,         gx400,      twinbee,   0,    ROT90,  "Konami", "TwinBee",  GAME_SUPPORTS_SAVE )
2557GAME( 1985, gradius,   nemesis,   gx400,      gradius,   0,    ROT0,   "Konami", "Gradius",  GAME_SUPPORTS_SAVE )
2558GAME( 1985, gwarrior,  0,         gx400,      gwarrior,  0,    ROT0,   "Konami", "Galactic Warriors",  GAME_SUPPORTS_SAVE )
2559GAME( 1986, salamand,  0,         salamand,   salamand,  0,    ROT0,   "Konami", "Salamander (version D)",  GAME_SUPPORTS_SAVE )
2560GAME( 1986, salamandj, salamand,  salamand,   salamand,  0,    ROT0,   "Konami", "Salamander (version J)",  GAME_SUPPORTS_SAVE )
2561GAME( 1986, lifefrce,  salamand,  salamand,   salamand,  0,    ROT0,   "Konami", "Lifeforce (US)",  GAME_SUPPORTS_SAVE )
2562GAME( 1987, lifefrcej, salamand,  salamand,   lifefrcj,  0,    ROT0,   "Konami", "Lifeforce (Japan)",  GAME_SUPPORTS_SAVE )
2563GAME( 1987, blkpnthr,  0,         blkpnthr,   blkpnthr,  0,    ROT0,   "Konami", "Black Panther",  GAME_SUPPORTS_SAVE )
2564GAME( 1987, citybomb,  0,         citybomb,   citybomb,  0,    ROT270, "Konami", "City Bomber (World)",  GAME_SUPPORTS_SAVE )
2565GAME( 1987, citybombj, citybomb,  citybomb,   citybomb,  0,    ROT270, "Konami", "City Bomber (Japan)",  GAME_SUPPORTS_SAVE )
2566GAME( 1987, hcrash,    0,         hcrash,     hcrash,    0,    ROT0,   "Konami", "Hyper Crash (version D)",  GAME_SUPPORTS_SAVE )
2567GAME( 1987, hcrashc,   hcrash,    hcrash,     hcrash,    0,    ROT0,   "Konami", "Hyper Crash (version C)",  GAME_SUPPORTS_SAVE )
2568GAME( 1988, kittenk,   0,         nyanpani,   nyanpani,  0,    ROT0,   "Konami", "Kitten Kaboodle",  GAME_SUPPORTS_SAVE )
2569GAME( 1988, nyanpani,  kittenk,   nyanpani,   nyanpani,  0,    ROT0,   "Konami", "Nyan Nyan Panic (Japan)",  GAME_SUPPORTS_SAVE )
src/mame/drivers/ace.c
r7500r7501
4343#define MASTER_CLOCK XTAL_18MHz
4444
4545
46typedef struct _ace_state ace_state;
47struct _ace_state
46class ace_state
4847{
48public:
49   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, ace_state(machine)); }
50
51   ace_state(running_machine &machine) { }
52
4953   /* video-related */
5054   UINT8 *  ram2;
5155   UINT8 *  scoreram;
src/mame/drivers/dreamwld.c
r7500r7501
9090
9191#define MASTER_CLOCK 32000000
9292
93typedef struct _dreamwld_state dreamwld_state;
94struct _dreamwld_state
93class dreamwld_state
9594{
95public:
96   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, dreamwld_state(machine)); }
97
98   dreamwld_state(running_machine &machine) { }
99
96100   /* memory pointers */
97101   UINT32 *  bg_videoram;
98102   UINT32 *  bg2_videoram;
src/mame/drivers/megazone.c
r7500r7501
1515#include "sound/dac.h"
1616#include "sound/flt_rc.h"
1717#include "includes/konamipt.h"
18#include "includes/megazone.h"
1819
19extern UINT8 *megazone_scrollx;
20extern UINT8 *megazone_scrolly;
2120
22extern UINT8 *megazone_videoram;
23extern UINT8 *megazone_videoram2;
24extern UINT8 *megazone_colorram;
25extern UINT8 *megazone_colorram2;
26extern size_t megazone_videoram_size;
27extern size_t megazone_videoram2_size;
28
29static int i8039_status;
30
31VIDEO_START( megazone );
32
33WRITE8_HANDLER( megazone_flipscreen_w );
34PALETTE_INIT( megazone );
35VIDEO_UPDATE( megazone );
36
37
38
39static READ8_DEVICE_HANDLER( megazone_portA_r )
21static READ8_DEVICE_HANDLER( megazone_port_a_r )
4022{
41   int clock,timer;
23   megazone_state *state = (megazone_state *)device->machine->driver_data;
24   int clock, timer;
4225
4326
4427   /* main xtal 14.318MHz, divided by 8 to get the AY-3-8910 clock, further */
r7500r7501
4831   /* (divide by (1024/2), and not 1024, because the CPU cycle counter is */
4932   /* incremented every other state change of the clock) */
5033
51   clock = cputag_get_total_cycles(device->machine, "audiocpu") * 7159/12288;   /* = (14318/8)/(18432/6) */
34   clock = cpu_get_total_cycles(state->audiocpu) * 7159/12288;   /* = (14318/8)/(18432/6) */
5235   timer = (clock / (1024/2)) & 0x0f;
5336
5437   /* low three bits come from the 8039 */
55
56   return (timer << 4) | i8039_status;
38   return (timer << 4) | state->i8039_status;
5739}
5840
59static WRITE8_DEVICE_HANDLER( megazone_portB_w )
41static WRITE8_DEVICE_HANDLER( megazone_port_b_w )
6042{
6143   static const char *const fltname[] = { "filter.0.0", "filter.0.1", "filter.0.2" };
6244   int i;
6345
64
65   for (i = 0;i < 3;i++)
46   for (i = 0; i < 3; i++)
6647   {
67      int C;
48      int C = 0;
49      if (data & 1)
50         C +=  10000;   /*  10000pF = 0.01uF */
51      if (data & 2)
52         C += 220000;   /* 220000pF = 0.22uF */
6853
69
70      C = 0;
71      if (data & 1) C +=  10000;   /*  10000pF = 0.01uF */
72      if (data & 2) C += 220000;   /* 220000pF = 0.22uF */
7354      data >>= 2;
7455      filter_rc_set_RC(devtag_get_device(device->machine, fltname[i]),FLT_RC_LOWPASS,1000,2200,200,CAP_P(C));
7556   }
r7500r7501
7758
7859static WRITE8_HANDLER( megazone_i8039_irq_w )
7960{
80   cputag_set_input_line(space->machine, "daccpu", 0, ASSERT_LINE);
61   megazone_state *state = (megazone_state *)space->machine->driver_data;
62   cpu_set_input_line(state->daccpu, 0, ASSERT_LINE);
8163}
8264
8365static WRITE8_HANDLER( i8039_irqen_and_status_w )
8466{
67   megazone_state *state = (megazone_state *)space->machine->driver_data;
68
8569   if ((data & 0x80) == 0)
86      cputag_set_input_line(space->machine, "daccpu", 0, CLEAR_LINE);
87   i8039_status = (data & 0x70) >> 4;
70      cpu_set_input_line(state->daccpu, 0, CLEAR_LINE);
71   state->i8039_status = (data & 0x70) >> 4;
8872}
8973
9074static WRITE8_HANDLER( megazone_coin_counter_w )
9175{
92   coin_counter_w(space->machine, 1-offset,data);      /* 1-offset, because coin counters are in reversed order */
76   coin_counter_w(space->machine, 1 - offset, data);      /* 1-offset, because coin counters are in reversed order */
9377}
9478
9579
r7500r7501
9983   AM_RANGE(0x0005, 0x0005) AM_WRITE(megazone_flipscreen_w)
10084   AM_RANGE(0x0007, 0x0007) AM_WRITE(interrupt_enable_w)
10185   AM_RANGE(0x0800, 0x0800) AM_WRITE(watchdog_reset_w)
102   AM_RANGE(0x1000, 0x1000) AM_WRITEONLY AM_BASE(&megazone_scrolly)
103   AM_RANGE(0x1800, 0x1800) AM_WRITEONLY AM_BASE(&megazone_scrollx)
104   AM_RANGE(0x2000, 0x23ff) AM_RAM AM_BASE(&megazone_videoram) AM_SIZE(&megazone_videoram_size)
105   AM_RANGE(0x2400, 0x27ff) AM_RAM AM_BASE(&megazone_videoram2) AM_SIZE(&megazone_videoram2_size)
106   AM_RANGE(0x2800, 0x2bff) AM_RAM AM_BASE(&megazone_colorram)
107   AM_RANGE(0x2c00, 0x2fff) AM_RAM AM_BASE(&megazone_colorram2)
108   AM_RANGE(0x3000, 0x33ff) AM_RAM AM_BASE_SIZE_GENERIC(spriteram)
86   AM_RANGE(0x1000, 0x1000) AM_WRITEONLY AM_BASE_MEMBER(megazone_state, scrolly)
87   AM_RANGE(0x1800, 0x1800) AM_WRITEONLY AM_BASE_MEMBER(megazone_state, scrollx)
88   AM_RANGE(0x2000, 0x23ff) AM_RAM AM_BASE_SIZE_MEMBER(megazone_state, videoram, videoram_size)
89   AM_RANGE(0x2400, 0x27ff) AM_RAM AM_BASE_SIZE_MEMBER(megazone_state, videoram2, videoram2_size)
90   AM_RANGE(0x2800, 0x2bff) AM_RAM AM_BASE_MEMBER(megazone_state, colorram)
91   AM_RANGE(0x2c00, 0x2fff) AM_RAM AM_BASE_MEMBER(megazone_state, colorram2)
92   AM_RANGE(0x3000, 0x33ff) AM_RAM AM_BASE_SIZE_MEMBER(megazone_state, spriteram, spriteram_size)
10993   AM_RANGE(0x3800, 0x3fff) AM_RAM AM_SHARE("share1")
11094   AM_RANGE(0x4000, 0xffff) AM_ROM      /* 4000->5FFF is a debug rom */
11195ADDRESS_MAP_END
r7500r7501
232216{
233217   AY8910_LEGACY_OUTPUT,
234218   AY8910_DEFAULT_LOADS,
235   DEVCB_HANDLER(megazone_portA_r),
219   DEVCB_HANDLER(megazone_port_a_r),
236220   DEVCB_NULL,
237221   DEVCB_NULL,
238   DEVCB_HANDLER(megazone_portB_w)
222   DEVCB_HANDLER(megazone_port_b_w)
239223};
240224
241225
242226
227static MACHINE_START( megazone )
228{
229   megazone_state *state = (megazone_state *)machine->driver_data;
230
231   state->maincpu = devtag_get_device(machine, "maincpu");
232   state->audiocpu = devtag_get_device(machine, "audiocpu");
233   state->daccpu = devtag_get_device(machine, "daccpu");
234
235   state_save_register_global(machine, state->flipscreen);
236   state_save_register_global(machine, state->i8039_status);
237}
238
239static MACHINE_RESET( megazone )
240{
241   megazone_state *state = (megazone_state *)machine->driver_data;
242
243   state->flipscreen = 0;
244   state->i8039_status = 0;
245}
246
243247static MACHINE_DRIVER_START( megazone )
244248
249   /* driver data */
250   MDRV_DRIVER_DATA(megazone_state)
251
245252   /* basic machine hardware */
246253   MDRV_CPU_ADD("maincpu", M6809, 18432000/9)        /* 2 MHz */
247254   MDRV_CPU_PROGRAM_MAP(megazone_map)
r7500r7501
257264   MDRV_CPU_IO_MAP(megazone_i8039_io_map)
258265
259266   MDRV_QUANTUM_TIME(HZ(900))
267   MDRV_MACHINE_START(megazone)
268   MDRV_MACHINE_RESET(megazone)
260269
261270   /* video hardware */
262271   MDRV_SCREEN_ADD("screen", RASTER)
r7500r7501
519528}
520529
521530/* these just display a Konami copyright, no logo */
522GAME( 1983, megazone, 0,        megazone, megazone, megazone, ROT90, "Konami",                       "Mega Zone (Konami set 1)", 0 )
523GAME( 1983, megazonea, megazone, megazone, megazona, megazone, ROT90, "Konami",                       "Mega Zone (Konami set 2)", 0 )
531GAME( 1983, megazone, 0,         megazone, megazone, megazone, ROT90, "Konami",                       "Mega Zone (Konami set 1)", GAME_SUPPORTS_SAVE )
532GAME( 1983, megazonea, megazone, megazone, megazona, megazone, ROT90, "Konami",                       "Mega Zone (Konami set 2)", GAME_SUPPORTS_SAVE )
524533
525534/* these display Konami and Kosuka copyright, no logo */
526GAME( 1983, megazoneb, megazone, megazone, megazone, megazone, ROT90, "Konami / Kosuka",              "Mega Zone (Kosuka set 1)", 0 )
527GAME( 1983, megazonec, megazone, megazone, megazone, megazone, ROT90, "Konami / Kosuka",              "Mega Zone (Kosuka set 2)", 0 )
535GAME( 1983, megazoneb, megazone, megazone, megazone, megazone, ROT90, "Konami / Kosuka",              "Mega Zone (Kosuka set 1)", GAME_SUPPORTS_SAVE )
536GAME( 1983, megazonec, megazone, megazone, megazone, megazone, ROT90, "Konami / Kosuka",              "Mega Zone (Kosuka set 2)", GAME_SUPPORTS_SAVE )
528537
529538/* this displays Konami and Kosuka copyright with a Konami / Interlogic logo */
530GAME( 1983, megazonei, megazone, megazone, megazone, megazone, ROT90, "Konami / Interlogic + Kosuka", "Mega Zone (Interlogic + Kosuka)", 0 )
539GAME( 1983, megazonei, megazone, megazone, megazone, megazone, ROT90, "Konami / Interlogic + Kosuka", "Mega Zone (Interlogic + Kosuka)", GAME_SUPPORTS_SAVE )
src/mame/drivers/galaga.c
r7500r7501
881881{
882882   /* create the interrupt timer */
883883   cpu3_interrupt_timer = timer_alloc(machine, cpu3_interrupt_callback, NULL);
884   custom_mod = 0;
885   state_save_register_global(machine, custom_mod);
884886}
885887
886888static void bosco_latch_reset(running_machine *machine)
src/mame/drivers/macs.c
r7500r7501
6363
6464
6565static UINT8 macs_mux_data;
66static UINT8 macs_rev;
67UINT8 macs_cart_slot;
6668
6769static MACHINE_RESET(macs);
6870
6971
7072static ADDRESS_MAP_START( macs_mem, ADDRESS_SPACE_PROGRAM, 8 )
71   AM_RANGE(0x0000, 0x7fff) AM_ROM
73   AM_RANGE(0x0000, 0x7fff) AM_ROMBANK("bank4")
7274   AM_RANGE(0x8000, 0xbfff) AM_ROMBANK("bank1")
7375   AM_RANGE(0xc000, 0xcfff) AM_READ(st0016_sprite_ram_r) AM_WRITE(st0016_sprite_ram_w)
7476   AM_RANGE(0xd000, 0xdfff) AM_READ(st0016_sprite2_ram_r) AM_WRITE(st0016_sprite2_ram_w)
r7500r7501
118120   return 0xff;
119121}
120122
123
124static WRITE8_HANDLER( macs_rom_bank_w )
125{
126   memory_set_bankptr(space->machine,  "bank1", memory_region(space->machine, "maincpu") + (data* 0x4000) + 0x10000 + macs_cart_slot*0x400000 );
127
128   st0016_rom_bank=data;
129}
130
121131static WRITE8_HANDLER( macs_output_w )
122132{
133   UINT8 *ROM = memory_region(space->machine, "maincpu");
134
123135   switch(offset)
124136   {
125      case 0: memory_set_bankptr(space->machine,  "bank2", &macs_ram1[((data&0x20)>>5)*0x1000+0x800] );break;
137      case 0:
138      /*
139        --x- ---- sets RAM bank?
140        ---- -x-- Cassette B slot
141        ---- --x- Cassette A slot
142        */
143
144      if(macs_rev == 1)
145      {
146         /* FIXME: dunno if this RAM bank is right, DASM tracking made on the POST screens indicates that there's just one RAM bank,
147                      but then MACS2 games locks up. */
148         memory_set_bankptr(space->machine,  "bank3", &macs_ram1[((data&0x20)>>5)*0x1000+0x000] );
149
150         macs_cart_slot = (data & 0xc) >> 2;
151
152         memory_set_bankptr(space->machine,  "bank4", &ROM[macs_cart_slot*0x400000+0x10000] );
153      }
154
155      memory_set_bankptr(space->machine,  "bank2", &macs_ram1[((data&0x20)>>5)*0x1000+0x800] );
156      break;
126157      case 2: macs_mux_data = data; break;
127158
128159   }
r7500r7501
133164   AM_RANGE(0x00, 0xbf) AM_READ(st0016_vregs_r) AM_WRITE(st0016_vregs_w) /* video/crt regs ? */
134165   AM_RANGE(0xc0, 0xc7) AM_READWRITE(macs_input_r,macs_output_w)
135166   AM_RANGE(0xe0, 0xe0) AM_WRITENOP /* renju = $40, neratte = 0 */
136   AM_RANGE(0xe1, 0xe1) AM_WRITE(st0016_rom_bank_w)
167   AM_RANGE(0xe1, 0xe1) AM_WRITE(macs_rom_bank_w)
137168   AM_RANGE(0xe2, 0xe2) AM_WRITE(st0016_sprite_bank_w)
138169   AM_RANGE(0xe3, 0xe4) AM_WRITE(st0016_character_bank_w)
139170   AM_RANGE(0xe5, 0xe5) AM_WRITE(st0016_palette_bank_w)
r7500r7501
297328   PORT_BIT( 0xf0, IP_ACTIVE_LOW, IPT_UNUSED )
298329INPUT_PORTS_END
299330
300static INPUT_PORTS_START( macs_m)
331static INPUT_PORTS_START( macs_m )
301332   PORT_INCLUDE( macs_base )
302333
303334   /*MAHJONG PANEL*/
r7500r7501
344375   PORT_BIT( 0xf0, IP_ACTIVE_LOW, IPT_UNUSED )
345376INPUT_PORTS_END
346377
347static INPUT_PORTS_START( macs_h)
378static INPUT_PORTS_START( kisekaem )
379   PORT_INCLUDE( macs_m )
380
381   PORT_MODIFY("SYS1")
382   PORT_DIPNAME( 0x01, 0x01, "SYS1 - BIT 1" )
383   PORT_DIPSETTING(    0x01, DEF_STR( Off ) )
384   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
385   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_COIN1 )
386   PORT_DIPNAME( 0x04, 0x04, "BIT 4" )
387   PORT_DIPSETTING(    0x04, DEF_STR( Off ) )
388   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
389   PORT_DIPNAME( 0x08, 0x08, "BIT 8" )
390   PORT_DIPSETTING(    0x08, DEF_STR( Off ) )
391   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
392   PORT_DIPNAME( 0x10, 0x10, "BIT 10" )
393   PORT_DIPSETTING(    0x10, DEF_STR( Off ) )
394   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
395   PORT_DIPNAME( 0x20, 0x20, "BIT 20" )
396   PORT_DIPSETTING(    0x20, DEF_STR( Off ) )
397   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
398   PORT_DIPNAME( 0x40, 0x40, "BIT 40" )
399   PORT_DIPSETTING(    0x40, DEF_STR( Off ) )
400   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
401   PORT_DIPNAME( 0x80, 0x00, "BIT 80" )
402   PORT_DIPSETTING(    0x80, DEF_STR( Off ) )
403   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
404INPUT_PORTS_END
405
406static INPUT_PORTS_START( macs_h )
348407   PORT_INCLUDE( macs_base )
349408
350409   /*HANAFUDA PANEL*/
r7500r7501
475534   ROM_REGION( 0x400000, "user3", ROMREGION_ERASEFF ) // Slot B
476535
477536   ROM_REGION( 0x1000000, "maincpu", 0 )
478   ROM_COPY( "user2",   0x00000, 0x010000, 0x400000 )
479   ROM_COPY( "user2",   0x00000, 0x000000, 0x0008000 )
537   ROM_COPY( "user1",   0x00000, 0x010000, 0x400000 )
538   ROM_COPY( "user1",   0x00000, 0x000000, 0x008000 )
539   ROM_COPY( "user2",   0x00000, 0x410000, 0x400000 )
480540ROM_END
481541
482542ROM_START( kisekaeh )
r7500r7501
492552   ROM_REGION( 0x400000, "user3", ROMREGION_ERASEFF ) // Slot B
493553
494554   ROM_REGION( 0x1000000, "maincpu", 0 )
495   ROM_COPY( "user2",   0x00000, 0x010000, 0x400000 )
496   ROM_COPY( "user2",   0x00000, 0x000000, 0x0008000 )
555   ROM_COPY( "user1",   0x00000, 0x010000, 0x400000 )
556   ROM_COPY( "user1",   0x00000, 0x000000, 0x008000 )
557   ROM_COPY( "user2",   0x00000, 0x410000, 0x400000 )
497558ROM_END
498559
499560ROM_START( cultname ) // uses printer - two different games ? (slot a - checks for printer, slot b - not)
500561   MACS_BIOS
501562
502   ROM_REGION( 0x400000, "user3", 0 ) // Slot A
563   ROM_REGION( 0x400000, "user2", 0 ) // Slot A
503564   ROM_LOAD16_BYTE( "cult-d0.u8", 0x000000, 0x100000, CRC(394bc1a6) SHA1(98df5406862234815b46c7b0ac0b19e4b597d1b6) )
504565   ROM_LOAD16_BYTE( "cult-d1.u7", 0x000001, 0x100000, CRC(f628133b) SHA1(f06e20212074e5d95cc7d419ac8ce98fb9be3b62) )
505566   ROM_LOAD16_BYTE( "cult-d2.u6", 0x200000, 0x100000, CRC(c5521bc6) SHA1(7554b56b0201b7d81754defa2244fb7ff7452bf6) )
506567   ROM_LOAD16_BYTE( "cult-d3.u5", 0x200001, 0x100000, CRC(4325b09b) SHA1(45699a0444a221f893724754c917d33041cabcb9) )
507568
508569
509   ROM_REGION( 0x400000, "user2", 0 ) // Slot B
570   ROM_REGION( 0x400000, "user3", 0 ) // Slot B
510571   ROM_LOAD16_BYTE( "cult-g0.u8", 0x000000, 0x100000, CRC(f5ab977b) SHA1(e7ee758cc2864500b339e236b944f98df9a1c10e) )
511572   ROM_LOAD16_BYTE( "cult-g1.u7", 0x000001, 0x100000, CRC(32ae15a4) SHA1(061992efec1ed5527f200bf4c111344b156e759d) )
512573   ROM_LOAD16_BYTE( "cult-g2.u6", 0x200000, 0x100000, CRC(30ed056d) SHA1(71735339bb501b94402ef403b5a2a60effa39c36) )
r7500r7501
514575
515576
516577   ROM_REGION( 0x1000000, "maincpu", 0 )
517   ROM_COPY( "user2",   0x00000, 0x010000, 0x400000 )
518   ROM_COPY( "user2",   0x00000, 0x000000, 0x0008000 )
578   ROM_COPY( "user1",   0x00000, 0x010000, 0x400000 )
579   ROM_COPY( "user1",   0x00000, 0x000000, 0x008000 )
580   ROM_COPY( "user2",   0x00000, 0x410000, 0x400000 )
581   ROM_COPY( "user3",   0x00000, 0x810000, 0x400000 )
519582ROM_END
520583
521584/* these are listed as MACS2 sub-boards, is it the same?  - it's not ;) */
r7500r7501
569632
570633static MACHINE_RESET(macs)
571634{
635   #if 0
572636/*
573637        BIOS ram init:
574638
r7500r7501
635699
636700      macs_ram1[0x0ff9]=0x07;
637701      macs_ram1[0x1ff9]=0x07;
702      #endif
638703
639704      memory_set_bankptr(machine,  "bank1", memory_region(machine, "maincpu") + 0x10000 );
640705      memory_set_bankptr(machine,  "bank2", macs_ram1+0x800);
641706      memory_set_bankptr(machine,  "bank3", macs_ram1+0x10000);
707      memory_set_bankptr(machine,  "bank4", memory_region(machine, "maincpu") );
642708}
643709
644710static DRIVER_INIT(macs)
645711{
646712   macs_ram1=auto_alloc_array(machine, UINT8, 0x20000);
647713   st0016_game=10|0x80;
714   macs_rev = 1;
648715}
649716
717static DRIVER_INIT(macs2)
718{
719   macs_ram1=auto_alloc_array(machine, UINT8, 0x20000);
720   st0016_game=10|0x80;
721   macs_rev = 2;
722}
723
650724static DRIVER_INIT(kisekaeh)
651725{
652726   macs_ram1=auto_alloc_array(machine, UINT8, 0x20000);
653727   st0016_game=11|0x180;
728   macs_rev = 1;
654729}
655730
656731static DRIVER_INIT(kisekaem)
657732{
658733   macs_ram1=auto_alloc_array(machine, UINT8, 0x20000);
659734   st0016_game=10|0x180;
735   macs_rev = 1;
660736}
661737
662738
663739GAME( 1995, macsbios, 0,        macs, macs_m, macs,     ROT0, "I'Max", "Multi Amenity Cassette System BIOS", GAME_IS_BIOS_ROOT | GAME_IMPERFECT_SOUND | GAME_NOT_WORKING )
664GAME( 1995, mac2bios, 0,        macs, macs_m, macs,     ROT0, "I'Max", "Multi Amenity Cassette System 2 BIOS", GAME_IS_BIOS_ROOT | GAME_IMPERFECT_SOUND | GAME_NOT_WORKING )
740GAME( 1995, mac2bios, 0,        macs, macs_m, macs2,     ROT0, "I'Max", "Multi Amenity Cassette System 2 BIOS", GAME_IS_BIOS_ROOT | GAME_IMPERFECT_SOUND | GAME_NOT_WORKING )
665741
666GAME( 1995, kisekaem, macsbios, macs, macs_m, kisekaem, ROT0, "I'Max", "Kisekae Mahjong",  GAME_NOT_WORKING|GAME_IMPERFECT_SOUND )
667GAME( 1995, kisekaeh, macsbios, macs, macs_h, kisekaeh, ROT0, "I'Max", "Kisekae Hanafuda",  GAME_NOT_WORKING |GAME_IMPERFECT_SOUND)
668GAME( 1996, cultname, macsbios, macs, macs_m, macs,     ROT0, "I'Max", "Seimei-Kantei-Meimei-Ki Cult Name",  GAME_NOT_WORKING |GAME_IMPERFECT_SOUND)
669GAME( 1999, yuka,     macsbios, macs, macs_h, macs,     ROT0, "Yubis / T.System", "Yu-Ka",  0 )
670GAME( 1999, yujan,    macsbios, macs, macs_m, macs,     ROT0, "Yubis / T.System", "Yu-Jan",  0 )
742GAME( 1995, kisekaem, macsbios, macs, kisekaem, kisekaem,   ROT0, "I'Max", "Kisekae Mahjong",  GAME_NOT_WORKING|GAME_IMPERFECT_SOUND )
743GAME( 1995, kisekaeh, macsbios, macs, macs_h,   kisekaeh,   ROT0, "I'Max", "Kisekae Hanafuda",  GAME_NOT_WORKING |GAME_IMPERFECT_SOUND)
744GAME( 1996, cultname, macsbios, macs, macs_m,   macs,       ROT0, "I'Max", "Seimei-Kantei-Meimei-Ki Cult Name",  GAME_NOT_WORKING |GAME_IMPERFECT_SOUND)
745GAME( 1999, yuka,     macsbios, macs, macs_h,   macs2,      ROT0, "Yubis / T.System", "Yu-Ka",  0 )
746GAME( 1999, yujan,    macsbios, macs, macs_m,   macs2,      ROT0, "Yubis / T.System", "Yu-Jan",  0 )
src/mame/drivers/sbowling.c
r7500r7501
4545#include "sound/ay8910.h"
4646
4747
48typedef struct _sbowling_state sbowling_state;
49struct _sbowling_state
48class sbowling_state
5049{
50public:
51   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, sbowling_state(machine)); }
52
53   sbowling_state(running_machine &machine) { }
54
5155   int bgmap;
5256   UINT8 *videoram;
5357
src/mame/drivers/good.c
r7500r7501
3535#include "sound/okim6295.h"
3636
3737
38typedef struct _good_state good_state;
39struct _good_state
38class good_state
4039{
40public:
41   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, good_state(machine)); }
42
43   good_state(running_machine &machine) { }
44
4145   /* memory pointers */
4246   UINT16 *  bg_tilemapram;
4347   UINT16 *  fg_tilemapram;
src/mame/drivers/8080bw.c
r7500r7501
183183
184184/*******************************************************/
185185/*                                                     */
186/* Alien Invasion                                      */
187/*                                                     */
188/*******************************************************/
189
190static INPUT_PORTS_START( alieninv )
191   PORT_START("IN0")
192   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_UNKNOWN )
193   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_UNKNOWN )
194   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_UNKNOWN )
195   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_UNKNOWN )
196   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_UNKNOWN )
197   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_UNKNOWN )
198   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_UNKNOWN )
199   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_UNKNOWN )
200
201   PORT_START("IN1")
202   PORT_BIT( 0x01, IP_ACTIVE_LOW,  IPT_COIN1 )
203   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_START2 )
204   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_START1 )
205   PORT_BIT( 0x08, IP_ACTIVE_HIGH, IPT_UNKNOWN )
206   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_BUTTON1 )
207   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT ) PORT_2WAY
208   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT ) PORT_2WAY
209   PORT_BIT( 0x80, IP_ACTIVE_LOW,  IPT_UNKNOWN )
210
211   PORT_START("IN2")
212   PORT_DIPNAME( 0x01, 0x01, DEF_STR( Lives ) )      PORT_DIPLOCATION("SW1:1")
213   PORT_DIPSETTING(    0x00, "2" )
214   PORT_DIPSETTING(    0x01, "3" )
215   PORT_DIPNAME( 0x02, 0x02, "Pence Coinage" )      PORT_DIPLOCATION("SW1:2")
216   PORT_DIPSETTING(    0x02, DEF_STR( Off ) )
217   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
218   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_COIN2 )      PORT_DIPLOCATION("SW1:3") /* Pence Coin */
219   PORT_DIPUNKNOWN_DIPLOC( 0x08, 0x08, "SW1:4" )   /* Not bonus */
220   PORT_BIT( 0x10, IP_ACTIVE_HIGH, IPT_BUTTON1 ) PORT_PLAYER(2)         PORT_DIPLOCATION("SW1:5")
221   PORT_BIT( 0x20, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT ) PORT_2WAY PORT_PLAYER(2)   PORT_DIPLOCATION("SW1:6")
222   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT ) PORT_2WAY PORT_PLAYER(2)   PORT_DIPLOCATION("SW1:7")
223   PORT_DIPNAME( 0x80, 0x00, DEF_STR( Coinage ) )               PORT_DIPLOCATION("SW1:8")
224   PORT_DIPSETTING(    0x00, "2C/1C 50p/3C (+ Bonus Life)" )
225   PORT_DIPSETTING(    0x80, "1C/1C 50p/5C" )
226
227   /* Dummy port for cocktail mode */
228   INVADERS_CAB_TYPE_PORT
229INPUT_PORTS_END
230
231/*******************************************************/
232/*                                                     */
186233/* Space Invaders Model Racing                         */
187234/*                                                     */
188235/*******************************************************/
r7500r7501
20382085
20392086ROM_START( tst_invd )
20402087   ROM_REGION( 0x10000, "maincpu", 0 )
2041   ROM_LOAD( "test.h",   0x0000, 0x0800, CRC(f86a2eea) SHA1(4a72ff01f3e6d16bbe9bf7f123cd98895bfbed9a) )   /*  The Test ROM */
2088   ROM_LOAD( "test.h",       0x0000, 0x0800, CRC(f86a2eea) SHA1(4a72ff01f3e6d16bbe9bf7f123cd98895bfbed9a) )   /*  The Test ROM */
20422089   ROM_LOAD( "invaders.g",   0x0800, 0x0800, CRC(6bfaca4a) SHA1(16f48649b531bdef8c2d1446c429b5f414524350) )
20432090   ROM_LOAD( "invaders.f",   0x1000, 0x0800, CRC(0ccead96) SHA1(537aef03468f63c5b9e11dd61e253f7ae17d9743) )
20442091   ROM_LOAD( "invaders.e",   0x1800, 0x0800, CRC(14e538b0) SHA1(1d6ca0c99f9df71e2990b610deb9d7da0125e2d8) )
r7500r7501
20462093
20472094ROM_START( alieninv )
20482095   ROM_REGION( 0x10000, "maincpu", 0 )
2096   ROM_LOAD( "alieninv.h",   0x0000, 0x0800, CRC(6ad601c3) SHA1(9fc88698f98ce43992a5044d28d3e19751f82772) )
2097   ROM_LOAD( "alieninv.g",   0x0800, 0x0800, CRC(c6bb6fb3) SHA1(01a12163309f967dcffce19890b1e0d079021fc2) )
2098   ROM_LOAD( "alieninv.f",   0x1000, 0x0800, CRC(1d2ff324) SHA1(209766a981fdd3a68e36da3d8122a244c883cae7) )
2099   ROM_LOAD( "alieninv.e",   0x1800, 0x0800, CRC(2f2e6791) SHA1(08a1f17bcfec598182386f1c43e4fc7b476212de) )
2100ROM_END
2101
2102ROM_START( alieninvp2 )
2103   ROM_REGION( 0x10000, "maincpu", 0 )
20492104   ROM_LOAD( "1h.bin",       0x0000, 0x0800, CRC(c46df7f4) SHA1(eec34b3d5585bae03c7b80585daaa05ddfcc2164) )
20502105   ROM_LOAD( "1g.bin",       0x0800, 0x0800, CRC(4b1112d6) SHA1(b693667656e5d8f44eeb2ea730f4d4db436da579) )
20512106   ROM_LOAD( "1f.bin",       0x1000, 0x0800, CRC(adca18a5) SHA1(7e02651692113db31fd469868ae5ffdb0f941ecf) )
r7500r7501
28822937GAMEL(19??, sinvzen,  invaders, invaders, spaceatt, 0, ROT270, "Zenitone-Microsec Ltd", "Super Invaders (Zenitone-Microsec)", GAME_SUPPORTS_SAVE, layout_invaders )
28832938GAMEL(19??, sinvemag, invaders, invaders, sinvemag, 0, ROT270, "bootleg", "Super Invaders (EMAG)", GAME_SUPPORTS_SAVE, layout_invaders )
28842939GAMEL(19??, tst_invd, invaders, invaders, sicv,     0, ROT0,   "Test ROM", "Space Invaders Test ROM", GAME_SUPPORTS_SAVE, layout_invaders )
2885GAMEL(19??, alieninv, invaders, invaders, searthin, 0, ROT270, "bootleg", "Alien Invasion Part II", GAME_SUPPORTS_SAVE, layout_invaders )
2940GAMEL(19??, alieninv, invaders, invaders, alieninv, 0, ROT270, "Margamatics", "Alien Invasion", GAME_SUPPORTS_SAVE, layout_invaders )
2941GAMEL(19??, alieninvp2,invaders, invaders, searthin, 0, ROT270, "bootleg", "Alien Invasion Part II", GAME_SUPPORTS_SAVE, layout_invaders )
28862942GAMEL(1978, spceking, invaders, invaders, sicv,     0, ROT270, "Leijac Corporation (Konami)","Space King", GAME_SUPPORTS_SAVE, layout_invaders )
28872943GAMEL(1978, spcewars, invaders, spcewars, spcewars, 0, ROT270, "Sanritsu", "Space War (Sanritsu)", GAME_IMPERFECT_SOUND | GAME_SUPPORTS_SAVE, layout_invaders )
28882944GAME (19??, astropal, 0,        astropal, astropal, 0, ROT0,   "Sidam?", "Astropal", GAME_SUPPORTS_SAVE | GAME_IMPERFECT_SOUND )
src/mame/drivers/othunder.c
r7500r7501
586586   PORT_INCLUDE( othundrj )
587587
588588   PORT_MODIFY( "DSWB" )
589    PORT_DIPNAME( 0x40, 0x40, DEF_STR( Continue_Price ) )        /* see notes */
590    PORT_DIPSETTING(    0x00, DEF_STR( 1C_1C ) )
591    PORT_DIPSETTING(    0x40, "Same as Start" )
589   PORT_DIPNAME( 0x40, 0x40, DEF_STR( Continue_Price ) )        /* see notes */
590   PORT_DIPSETTING(    0x00, DEF_STR( 1C_1C ) )
591   PORT_DIPSETTING(    0x40, "Same as Start" )
592592INPUT_PORTS_END
593593
594594
r7500r7501
945945
946946
947947
948GAME( 1988, othunder,   0,        othunder, othunder, 0, ORIENTATION_FLIP_X, "Taito Corporation Japan", "Operation Thunderbolt (World)", 0 )
949GAME( 1988, othunderu,  othunder, othunder, othundu,  0, ORIENTATION_FLIP_X, "Taito America Corporation", "Operation Thunderbolt (US)", 0 )
950GAME( 1988, othunderuo, othunder, othunder, othundu,  0, ORIENTATION_FLIP_X, "Taito America Corporation", "Operation Thunderbolt (US, older)", 0 )
951GAME( 1988, othunderj,  othunder, othunder, othundrj, 0, ORIENTATION_FLIP_X, "Taito Corporation", "Operation Thunderbolt (Japan)", 0 )
948GAME( 1988, othunder,   0,        othunder, othunder, 0, ORIENTATION_FLIP_X, "Taito Corporation Japan", "Operation Thunderbolt (World)", GAME_SUPPORTS_SAVE )
949GAME( 1988, othunderu,  othunder, othunder, othundu,  0, ORIENTATION_FLIP_X, "Taito America Corporation", "Operation Thunderbolt (US)", GAME_SUPPORTS_SAVE )
950GAME( 1988, othunderuo, othunder, othunder, othundu,  0, ORIENTATION_FLIP_X, "Taito America Corporation", "Operation Thunderbolt (US, older)", GAME_SUPPORTS_SAVE )
951GAME( 1988, othunderj,  othunder, othunder, othundrj, 0, ORIENTATION_FLIP_X, "Taito Corporation", "Operation Thunderbolt (Japan)", GAME_SUPPORTS_SAVE )
src/mame/drivers/mirage.c
r7500r7501
3636#include "cpu/m68000/m68000.h"
3737#include "includes/decocrpt.h"
3838#include "includes/decoprot.h"
39#include "includes/deco16ic.h"
39#include "video/deco16ic.h"
4040#include "sound/okim6295.h"
4141
42static void draw_sprites(running_machine *machine, bitmap_t *bitmap,const rectangle *cliprect, int pri)
42class mirage_state
4343{
44   UINT16 *spriteram16 = machine->generic.spriteram.u16;
44public:
45   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, mirage_state(machine)); }
46
47   mirage_state(running_machine &machine) { }
48
49   /* memory pointers */
50   UINT16 *  pf1_rowscroll;
51   UINT16 *  pf2_rowscroll;
52   UINT16 *  spriteram;
53//  UINT16 *  paletteram;    // currently this uses generic palette handling (in deco16ic.c)
54   size_t    spriteram_size;
55
56   /* misc */
57   UINT32 mux_data;
58
59   /* devices */
60   running_device *maincpu;
61   running_device *audiocpu;
62   running_device *deco16ic;
63   running_device *oki_sfx;
64   running_device *oki_bgm;
65};
66
67
68static void draw_sprites( running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect, int pri )
69{
70   mirage_state *state = (mirage_state *)machine->driver_data;
71   UINT16 *spriteram = state->spriteram;
4572   int offs;
4673
47   for (offs = 0;offs < 0x400;offs += 4)
74   for (offs = 0; offs < 0x400; offs += 4)
4875   {
49      int x,y,sprite,colour,multi,fx,fy,inc,flash,mult;
76      int x, y, sprite, colour, multi, fx, fy, inc, flash, mult;
5077
51      sprite = spriteram16[offs+1];
52      if (!sprite) continue;
78      sprite = spriteram[offs + 1];
79      if (!sprite)
80         continue;
5381
54      y = spriteram16[offs];
55      flash=y&0x1000;
82      y = spriteram[offs];
83      flash = y & 0x1000;
5684
57      if (flash && (video_screen_get_frame_number(machine->primary_screen) & 1)) continue;
85      if (flash && (video_screen_get_frame_number(machine->primary_screen) & 1))
86         continue;
5887
59      if (pri != ((y & 0x8000)>>15)) continue;
88      if (pri != ((y & 0x8000) >> 15))
89         continue;
6090
61      x = spriteram16[offs+2];
62      colour = (x >>9) & 0x1f;
91      x = spriteram[offs + 2];
92      colour = (x >> 9) & 0x1f;
6393
6494      fx = y & 0x2000;
6595      fy = y & 0x4000;
r7500r7501
71101      if (x >= 320) x -= 512;
72102      if (y >= 256) y -= 512;
73103      y = 240 - y;
74        x = 304 - x;
104      x = 304 - x;
75105
76      if (x>320) continue;
106      if (x > 320)
107         continue;
77108
78109      sprite &= ~multi;
79110      if (fy)
r7500r7501
86117
87118      if (flip_screen_get(machine))
88119      {
89         y=240-y;
90         x=304-x;
91         if (fx) fx=0; else fx=1;
92         if (fy) fy=0; else fy=1;
93         mult=16;
120         y =240 - y;
121         x =304 - x;
122         if (fx) fx = 0; else fx = 1;
123         if (fy) fy = 0; else fy = 1;
124         mult = 16;
94125      }
95      else mult=-16;
126      else mult = -16;
96127
97128      while (multi >= 0)
98129      {
r7500r7501
107138   }
108139}
109140
110static int mirage_bank_callback(const int bank)
141static VIDEO_UPDATE( mirage )
111142{
112   return ((bank>>4)&0x7) * 0x1000;
113}
143   mirage_state *state = (mirage_state *)screen->machine->driver_data;
144   UINT16 flip = deco16ic_pf12_control_r(state->deco16ic, 0, 0xffff);
114145
115static VIDEO_START(mirage)
116{
117   deco16_1_video_init(machine);
146   flip_screen_set(screen->machine, BIT(flip, 7));
147   deco16ic_pf12_update(state->deco16ic, state->pf1_rowscroll, state->pf2_rowscroll);
118148
119   deco16_set_tilemap_bank_callback(0, mirage_bank_callback);
120   deco16_set_tilemap_bank_callback(1, mirage_bank_callback);
121}
149   bitmap_fill(bitmap, cliprect, 256); /* not verified */
122150
123static VIDEO_UPDATE(mirage)
124{
125   flip_screen_set(screen->machine,  deco16_pf12_control[0]&0x80 );
126   deco16_pf12_update(deco16_pf1_rowscroll,deco16_pf2_rowscroll);
151   deco16ic_tilemap_2_draw(state->deco16ic, bitmap, cliprect, TILEMAP_DRAW_OPAQUE, 0);
152   draw_sprites(screen->machine, bitmap, cliprect, 1);
153   deco16ic_tilemap_1_draw(state->deco16ic, bitmap, cliprect, 0, 0);
154   draw_sprites(screen->machine, bitmap, cliprect, 0);
127155
128   bitmap_fill(bitmap,cliprect,256); /* not verified */
129
130   deco16_tilemap_2_draw(screen,bitmap,cliprect,TILEMAP_DRAW_OPAQUE,0);
131   draw_sprites(screen->machine,bitmap,cliprect,1);
132   deco16_tilemap_1_draw(screen,bitmap,cliprect,0,0);
133   draw_sprites(screen->machine,bitmap,cliprect,0);
134
135156   return 0;
136157}
137158
138static UINT32 mux_data;
139159
140160static WRITE16_HANDLER( mirage_mux_w )
141161{
142   mux_data = data & 0x1f;
162   mirage_state *state = (mirage_state *)space->machine->driver_data;
163   state->mux_data = data & 0x1f;
143164}
144165
145166static READ16_HANDLER( mirage_input_r )
146167{
147   switch(mux_data & 0x1f)
168   mirage_state *state = (mirage_state *)space->machine->driver_data;
169   switch (state->mux_data & 0x1f)
148170   {
149171      case 0x01: return input_port_read(space->machine, "KEY0");
150172      case 0x02: return input_port_read(space->machine, "KEY1");
r7500r7501
158180
159181static WRITE16_HANDLER( okim1_rombank_w )
160182{
161   okim6295_set_bank_base(devtag_get_device(space->machine, "oki_sfx"), 0x40000 * (data & 0x3));
183   mirage_state *state = (mirage_state *)space->machine->driver_data;
184   okim6295_set_bank_base(state->oki_sfx, 0x40000 * (data & 0x3));
162185}
163186
164187static WRITE16_HANDLER( okim0_rombank_w )
165188{
189   mirage_state *state = (mirage_state *)space->machine->driver_data;
190
166191   /*bits 4-6 used on POST? */
167
168   okim6295_set_bank_base(devtag_get_device(space->machine, "oki_bgm"), 0x40000 * (data & 0x7));
192   okim6295_set_bank_base(state->oki_bgm, 0x40000 * (data & 0x7));
169193}
170194
171195static ADDRESS_MAP_START( mirage_map, ADDRESS_SPACE_PROGRAM, 16 )
172196   AM_RANGE(0x000000, 0x07ffff) AM_ROM
173197   /* tilemaps */
174   AM_RANGE(0x100000, 0x101fff) AM_RAM_WRITE(deco16_pf1_data_w) AM_BASE(&deco16_pf1_data) // 0x100000 - 0x101fff tested
175   AM_RANGE(0x102000, 0x103fff) AM_RAM_WRITE(deco16_pf2_data_w) AM_BASE(&deco16_pf2_data) // 0x102000 - 0x102fff tested
198   AM_RANGE(0x100000, 0x101fff) AM_DEVREADWRITE("deco_custom", deco16ic_pf1_data_r, deco16ic_pf1_data_w) // 0x100000 - 0x101fff tested
199   AM_RANGE(0x102000, 0x103fff) AM_DEVREADWRITE("deco_custom", deco16ic_pf2_data_r, deco16ic_pf2_data_w) // 0x102000 - 0x102fff tested
176200   /* linescroll */
177   AM_RANGE(0x110000, 0x110bff) AM_RAM AM_BASE(&deco16_pf1_rowscroll)
178   AM_RANGE(0x112000, 0x112bff) AM_RAM AM_BASE(&deco16_pf2_rowscroll)
179   AM_RANGE(0x120000, 0x1207ff) AM_RAM AM_BASE_GENERIC(spriteram)
201   AM_RANGE(0x110000, 0x110bff) AM_RAM AM_BASE_MEMBER(mirage_state, pf1_rowscroll)
202   AM_RANGE(0x112000, 0x112bff) AM_RAM AM_BASE_MEMBER(mirage_state, pf2_rowscroll)
203   AM_RANGE(0x120000, 0x1207ff) AM_RAM AM_BASE_SIZE_MEMBER(mirage_state, spriteram, spriteram_size)
180204   AM_RANGE(0x130000, 0x1307ff) AM_RAM_WRITE(paletteram16_xBBBBBGGGGGRRRRR_word_w) AM_BASE_GENERIC(paletteram)
181205   AM_RANGE(0x140000, 0x14000f) AM_DEVREADWRITE8("oki_sfx", okim6295_r, okim6295_w, 0x00ff)
182206   AM_RANGE(0x150000, 0x15000f) AM_DEVREADWRITE8("oki_bgm", okim6295_r, okim6295_w, 0x00ff)
183207//  AM_RANGE(0x140006, 0x140007) AM_READ(random_readers)
184208//  AM_RANGE(0x150006, 0x150007) AM_READNOP
185209   AM_RANGE(0x160000, 0x160001) AM_WRITENOP
186   AM_RANGE(0x168000, 0x16800f) AM_WRITEONLY AM_BASE(&deco16_pf12_control)
210   AM_RANGE(0x168000, 0x16800f) AM_DEVWRITE("deco_custom", deco16ic_pf12_control_w)
187211   AM_RANGE(0x16a000, 0x16a001) AM_WRITENOP
188212   AM_RANGE(0x16c000, 0x16c001) AM_WRITE(okim1_rombank_w)
189213   AM_RANGE(0x16c002, 0x16c003) AM_WRITE(okim0_rombank_w)
r7500r7501
203227   PORT_SERVICE( 0x0008, IP_ACTIVE_LOW )
204228   PORT_BIT( 0x0010, IP_ACTIVE_HIGH, IPT_VBLANK )
205229   PORT_DIPNAME( 0x0020, 0x0020, DEF_STR( Flip_Screen ) )
206    PORT_DIPSETTING(      0x0020, DEF_STR( Off ) )
207    PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
208    PORT_DIPNAME( 0x0040, 0x0040, DEF_STR( Unknown ) )
209    PORT_DIPSETTING(      0x0000, DEF_STR( Off ) )
210    PORT_DIPSETTING(      0x0040, DEF_STR( On ) )
211    PORT_DIPNAME( 0x0080, 0x0080, DEF_STR( Unknown ) )
212    PORT_DIPSETTING(      0x0080, DEF_STR( Off ) )
213    PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
214    PORT_DIPNAME( 0x0100, 0x0100, DEF_STR( Unknown ) )
215    PORT_DIPSETTING(      0x0100, DEF_STR( Off ) )
216    PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
217    PORT_DIPNAME( 0x0200, 0x0200, DEF_STR( Unknown ) )
218    PORT_DIPSETTING(      0x0200, DEF_STR( Off ) )
219    PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
220    PORT_DIPNAME( 0x0400, 0x0400, DEF_STR( Unknown ) )
221    PORT_DIPSETTING(      0x0400, DEF_STR( Off ) )
222    PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
223    PORT_DIPNAME( 0x0800, 0x0800, DEF_STR( Unknown ) )
224    PORT_DIPSETTING(      0x0800, DEF_STR( Off ) )
225    PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
226    PORT_DIPNAME( 0x1000, 0x1000, DEF_STR( Unknown ) )
227    PORT_DIPSETTING(      0x1000, DEF_STR( Off ) )
228    PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
229    PORT_DIPNAME( 0x2000, 0x2000, DEF_STR( Unknown ) )
230    PORT_DIPSETTING(      0x2000, DEF_STR( Off ) )
231    PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
232    PORT_DIPNAME( 0x4000, 0x4000, DEF_STR( Unknown ) )
233    PORT_DIPSETTING(      0x4000, DEF_STR( Off ) )
234    PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
235    PORT_DIPNAME( 0x8000, 0x8000, DEF_STR( Unknown ) )
236    PORT_DIPSETTING(      0x8000, DEF_STR( Off ) )
237    PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
230   PORT_DIPSETTING(      0x0020, DEF_STR( Off ) )
231   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
232   PORT_DIPNAME( 0x0040, 0x0040, DEF_STR( Unknown ) )
233   PORT_DIPSETTING(      0x0000, DEF_STR( Off ) )
234   PORT_DIPSETTING(      0x0040, DEF_STR( On ) )
235   PORT_DIPNAME( 0x0080, 0x0080, DEF_STR( Unknown ) )
236   PORT_DIPSETTING(      0x0080, DEF_STR( Off ) )
237   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
238   PORT_DIPNAME( 0x0100, 0x0100, DEF_STR( Unknown ) )
239   PORT_DIPSETTING(      0x0100, DEF_STR( Off ) )
240   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
241   PORT_DIPNAME( 0x0200, 0x0200, DEF_STR( Unknown ) )
242   PORT_DIPSETTING(      0x0200, DEF_STR( Off ) )
243   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
244   PORT_DIPNAME( 0x0400, 0x0400, DEF_STR( Unknown ) )
245   PORT_DIPSETTING(      0x0400, DEF_STR( Off ) )
246   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
247   PORT_DIPNAME( 0x0800, 0x0800, DEF_STR( Unknown ) )
248   PORT_DIPSETTING(      0x0800, DEF_STR( Off ) )
249   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
250   PORT_DIPNAME( 0x1000, 0x1000, DEF_STR( Unknown ) )
251   PORT_DIPSETTING(      0x1000, DEF_STR( Off ) )
252   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
253   PORT_DIPNAME( 0x2000, 0x2000, DEF_STR( Unknown ) )
254   PORT_DIPSETTING(      0x2000, DEF_STR( Off ) )
255   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
256   PORT_DIPNAME( 0x4000, 0x4000, DEF_STR( Unknown ) )
257   PORT_DIPSETTING(      0x4000, DEF_STR( Off ) )
258   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
259   PORT_DIPNAME( 0x8000, 0x8000, DEF_STR( Unknown ) )
260   PORT_DIPSETTING(      0x8000, DEF_STR( Off ) )
261   PORT_DIPSETTING(      0x0000, DEF_STR( On ) )
238262
239263   PORT_START("KEY0")
240    PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_MAHJONG_A )
241    PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_MAHJONG_E )
242    PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_MAHJONG_I )
243    PORT_BIT( 0x0008, IP_ACTIVE_LOW, IPT_MAHJONG_M )
244    PORT_BIT( 0x0010, IP_ACTIVE_LOW, IPT_MAHJONG_KAN )
245    PORT_BIT( 0x0020, IP_ACTIVE_LOW, IPT_START1 )
246    PORT_BIT( 0xffc0, IP_ACTIVE_LOW, IPT_UNUSED )
264   PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_MAHJONG_A )
265   PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_MAHJONG_E )
266   PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_MAHJONG_I )
267   PORT_BIT( 0x0008, IP_ACTIVE_LOW, IPT_MAHJONG_M )
268   PORT_BIT( 0x0010, IP_ACTIVE_LOW, IPT_MAHJONG_KAN )
269   PORT_BIT( 0x0020, IP_ACTIVE_LOW, IPT_START1 )
270   PORT_BIT( 0xffc0, IP_ACTIVE_LOW, IPT_UNUSED )
247271
248272   PORT_START("KEY1")
249    PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_MAHJONG_C )
250    PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_MAHJONG_G )
251    PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_MAHJONG_K )
252    PORT_BIT( 0x0008, IP_ACTIVE_LOW, IPT_MAHJONG_CHI )
253    PORT_BIT( 0x0010, IP_ACTIVE_LOW, IPT_MAHJONG_RON )
254    PORT_BIT( 0xffe0, IP_ACTIVE_LOW, IPT_UNUSED )
273   PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_MAHJONG_C )
274   PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_MAHJONG_G )
275   PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_MAHJONG_K )
276   PORT_BIT( 0x0008, IP_ACTIVE_LOW, IPT_MAHJONG_CHI )
277   PORT_BIT( 0x0010, IP_ACTIVE_LOW, IPT_MAHJONG_RON )
278   PORT_BIT( 0xffe0, IP_ACTIVE_LOW, IPT_UNUSED )
255279
256280   PORT_START("KEY2")
257281   PORT_BIT( 0x0008, IP_ACTIVE_LOW, IPT_MAHJONG_FLIP_FLOP )
258    PORT_BIT( 0xfff7, IP_ACTIVE_LOW, IPT_UNUSED )
282   PORT_BIT( 0xfff7, IP_ACTIVE_LOW, IPT_UNUSED )
259283
260284   PORT_START("KEY3")
261    PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_MAHJONG_B )
262    PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_MAHJONG_F )
263    PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_MAHJONG_J )
264    PORT_BIT( 0x0008, IP_ACTIVE_LOW, IPT_MAHJONG_N )
285   PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_MAHJONG_B )
286   PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_MAHJONG_F )
287   PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_MAHJONG_J )
288   PORT_BIT( 0x0008, IP_ACTIVE_LOW, IPT_MAHJONG_N )
265289   PORT_BIT( 0x0010, IP_ACTIVE_LOW, IPT_MAHJONG_REACH )
266    PORT_BIT( 0xffe0, IP_ACTIVE_LOW, IPT_UNUSED )
290   PORT_BIT( 0xffe0, IP_ACTIVE_LOW, IPT_UNUSED )
267291
268292   PORT_START("KEY4")
269    PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_MAHJONG_D )
270    PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_MAHJONG_H )
271    PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_MAHJONG_L )
272    PORT_BIT( 0x0008, IP_ACTIVE_LOW, IPT_MAHJONG_PON )
273    PORT_BIT( 0xfff0, IP_ACTIVE_LOW, IPT_UNUSED )
293   PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_MAHJONG_D )
294   PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_MAHJONG_H )
295   PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_MAHJONG_L )
296   PORT_BIT( 0x0008, IP_ACTIVE_LOW, IPT_MAHJONG_PON )
297   PORT_BIT( 0xfff0, IP_ACTIVE_LOW, IPT_UNUSED )
274298INPUT_PORTS_END
275299
276300
r7500r7501
315339GFXDECODE_END
316340
317341
342static int mirage_bank_callback( const int bank )
343{
344   return ((bank >> 4) & 0x7) * 0x1000;
345}
318346
347static const deco16ic_interface mirage_deco16ic_intf =
348{
349   "screen",
350   1, 0, 1,
351   0x0f, 0x0f, 0x0f, 0x0f,   /* trans masks (default values) */
352   0, 16, 0, 16, /* color base (default values) */
353   0x0f, 0x0f, 0x0f, 0x0f,   /* color masks (default values) */
354   mirage_bank_callback,
355   mirage_bank_callback,
356   NULL,
357   NULL
358};
359
360
361static MACHINE_START( mirage )
362{
363   mirage_state *state = (mirage_state *)machine->driver_data;
364
365   state->maincpu = devtag_get_device(machine, "maincpu");
366   state->deco16ic = devtag_get_device(machine, "deco_custom");
367   state->oki_sfx = devtag_get_device(machine, "oki_sfx");
368   state->oki_bgm = devtag_get_device(machine, "oki_bgm");
369
370   state_save_register_global(machine, state->mux_data);
371}
372
373static MACHINE_RESET( mirage )
374{
375   mirage_state *state = (mirage_state *)machine->driver_data;
376
377   state->mux_data = 0;
378}
379
319380static MACHINE_DRIVER_START( mirage )
320381
382   /* driver data */
383   MDRV_DRIVER_DATA(mirage_state)
384
321385   /* basic machine hardware */
322386   MDRV_CPU_ADD("maincpu", M68000, 28000000/2)
323387   MDRV_CPU_PROGRAM_MAP(mirage_map)
324388   MDRV_CPU_VBLANK_INT("screen", irq6_line_hold)
325389
390   MDRV_MACHINE_START(mirage)
391   MDRV_MACHINE_RESET(mirage)
392
326393   /* video hardware */
327394   MDRV_SCREEN_ADD("screen", RASTER)
328395   MDRV_SCREEN_REFRESH_RATE(58)
r7500r7501
334401   MDRV_GFXDECODE(mirage)
335402   MDRV_PALETTE_LENGTH(1024)
336403
337   MDRV_VIDEO_START(mirage)
338404   MDRV_VIDEO_UPDATE(mirage)
339405
406   MDRV_DECO16IC_ADD("deco_custom", mirage_deco16ic_intf)
407
340408   /* sound hardware */
341409   MDRV_SPEAKER_STANDARD_MONO("mono")
342410
r7500r7501
380448   deco56_decrypt_gfx(machine, "gfx1");
381449}
382450
383GAME( 1994, mirage, 0,        mirage, mirage, mirage, ROT0, "Mitchell", "Mirage Youjuu Mahjongden (Japan)", 0 )
451GAME( 1994, mirage, 0,     mirage, mirage, mirage, ROT0, "Mitchell", "Mirage Youjuu Mahjongden (Japan)", GAME_SUPPORTS_SAVE )
src/mame/drivers/tumblep.c
r7500r7501
4646#include "sound/2151intf.h"
4747#include "sound/3812intf.h"
4848#include "sound/okim6295.h"
49#include "includes/deco16ic.h"
49#include "includes/tumblep.h"
50#include "video/deco16ic.h"
5051
5152#define TUMBLEP_HACK   0
5253
53VIDEO_START( tumblep );
54VIDEO_UPDATE( tumblep );
55
5654/******************************************************************************/
5755
5856#ifdef UNUSED_FUNCTION
5957static WRITE16_DEVICE_HANDLER( tumblep_oki_w )
6058{
61   okim6295_w(0,data&0xff);
59   okim6295_w(0, data & 0xff);
6260    /* STUFF IN OTHER BYTE TOO..*/
6361}
6462
r7500r7501
7068
7169static WRITE16_HANDLER( tumblep_sound_w )
7270{
71   tumblep_state *state = (tumblep_state *)space->machine->driver_data;
7372   soundlatch_w(space, 0, data & 0xff);
74   cputag_set_input_line(space->machine, "audiocpu", 0, HOLD_LINE);
73   cpu_set_input_line(state->audiocpu, 0, HOLD_LINE);
7574}
7675
7776#ifdef UNUSED_FUNCTION
7877static WRITE16_HANDLER( jumppop_sound_w )
7978{
79   tumblep_state *state = (tumblep_state *)space->machine->driver_data;
8080   soundlatch_w(space, 0, data & 0xff);
81   cputag_set_input_line(space->machine, "audiocpu", 0, ASSERT_LINE );
81   cputag_set_input_line(state->audiocpu, 0, ASSERT_LINE );
8282}
8383#endif
8484
r7500r7501
8686
8787static READ16_HANDLER( tumblepop_controls_r )
8888{
89   switch (offset<<1)
89   switch (offset << 1)
9090   {
9191      case 0:
9292         return input_port_read(space->machine, "PLAYERS");
r7500r7501
116116   AM_RANGE(0x140000, 0x1407ff) AM_RAM_WRITE(paletteram16_xxxxBBBBGGGGRRRR_word_w) AM_BASE_GENERIC(paletteram)
117117   AM_RANGE(0x180000, 0x18000f) AM_READ(tumblepop_controls_r)
118118   AM_RANGE(0x18000c, 0x18000d) AM_WRITENOP
119   AM_RANGE(0x1a0000, 0x1a07ff) AM_RAM AM_BASE_SIZE_GENERIC(spriteram)
120   AM_RANGE(0x300000, 0x30000f) AM_WRITEONLY AM_BASE(&deco16_pf12_control)
121   AM_RANGE(0x320000, 0x320fff) AM_RAM_WRITE(deco16_pf1_data_w) AM_BASE(&deco16_pf1_data)
122   AM_RANGE(0x322000, 0x322fff) AM_RAM_WRITE(deco16_pf2_data_w) AM_BASE(&deco16_pf2_data)
123   AM_RANGE(0x340000, 0x3407ff) AM_WRITEONLY AM_BASE(&deco16_pf1_rowscroll) // unused
124   AM_RANGE(0x342000, 0x3427ff) AM_WRITEONLY AM_BASE(&deco16_pf2_rowscroll) // unused
119   AM_RANGE(0x1a0000, 0x1a07ff) AM_RAM AM_BASE_SIZE_MEMBER(tumblep_state, spriteram, spriteram_size)
120   AM_RANGE(0x300000, 0x30000f) AM_DEVWRITE("deco_custom", deco16ic_pf12_control_w)
121   AM_RANGE(0x320000, 0x320fff) AM_DEVREADWRITE("deco_custom", deco16ic_pf1_data_r, deco16ic_pf1_data_w)
122   AM_RANGE(0x322000, 0x322fff) AM_DEVREADWRITE("deco_custom", deco16ic_pf2_data_r, deco16ic_pf2_data_w)
123   AM_RANGE(0x340000, 0x3407ff) AM_WRITEONLY AM_BASE_MEMBER(tumblep_state, pf1_rowscroll) // unused
124   AM_RANGE(0x342000, 0x3427ff) AM_WRITEONLY AM_BASE_MEMBER(tumblep_state, pf2_rowscroll) // unused
125125ADDRESS_MAP_END
126126
127127/******************************************************************************/
r7500r7501
274274
275275static void sound_irq(running_device *device, int state)
276276{
277   cputag_set_input_line(device->machine, "audiocpu", 1, state); /* IRQ 2 */
277   tumblep_state *driver_state = (tumblep_state *)device->machine->driver_data;
278   cpu_set_input_line(driver_state->audiocpu, 1, state); /* IRQ 2 */
278279}
279280
280281static const ym2151_interface ym2151_config =
r7500r7501
282283   sound_irq
283284};
284285
286static const deco16ic_interface tumblep_deco16ic_intf =
287{
288   "screen",
289   1, 0, 1,
290   0x0f, 0x0f, 0x0f, 0x0f,   /* trans masks (default values) */
291   0, 16, 0, 16, /* color base (default values) */
292   0x0f, 0x0f, 0x0f, 0x0f,   /* color masks (default values) */
293   NULL, NULL, NULL, NULL
294};
295
296static MACHINE_START( tumblep )
297{
298   tumblep_state *state = (tumblep_state *)machine->driver_data;
299
300   state->maincpu = devtag_get_device(machine, "maincpu");
301   state->audiocpu = devtag_get_device(machine, "audiocpu");
302   state->deco16ic = devtag_get_device(machine, "deco_custom");
303}
304
285305static MACHINE_DRIVER_START( tumblep )
286306
307   /* driver data */
308   MDRV_DRIVER_DATA(tumblep_state)
309
287310   /* basic machine hardware */
288311   MDRV_CPU_ADD("maincpu", M68000, 14000000)
289312   MDRV_CPU_PROGRAM_MAP(main_map)
r7500r7501
292315   MDRV_CPU_ADD("audiocpu", H6280, 32220000/8)   /* Custom chip 45; Audio section crystal is 32.220 MHz */
293316   MDRV_CPU_PROGRAM_MAP(sound_map)
294317
318   MDRV_MACHINE_START(tumblep)
319
295320   /* video hardware */
296321   MDRV_SCREEN_ADD("screen", RASTER)
297322   MDRV_SCREEN_REFRESH_RATE(58)
r7500r7501
303328   MDRV_GFXDECODE(tumblep)
304329   MDRV_PALETTE_LENGTH(1024)
305330
306   MDRV_VIDEO_START(tumblep)
307331   MDRV_VIDEO_UPDATE(tumblep)
308332
333   MDRV_DECO16IC_ADD("deco_custom", tumblep_deco16ic_intf)
334
309335   /* sound hardware */
310336   MDRV_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker")
311337
r7500r7501
383409
384410/******************************************************************************/
385411
386GAME( 1991, tumblep,  0,       tumblep,   tumblep,  tumblep,  ROT0, "Data East Corporation", "Tumble Pop (World)", 0 )
387GAME( 1991, tumblepj, tumblep, tumblep,   tumblep,  tumblep,  ROT0, "Data East Corporation", "Tumble Pop (Japan)", 0 )
412GAME( 1991, tumblep,  0,       tumblep,   tumblep,  tumblep,  ROT0, "Data East Corporation", "Tumble Pop (World)", GAME_SUPPORTS_SAVE )
413GAME( 1991, tumblepj, tumblep, tumblep,   tumblep,  tumblep,  ROT0, "Data East Corporation", "Tumble Pop (Japan)", GAME_SUPPORTS_SAVE )
388414/* for bootlegs and games on similar hardware see tumbleb.c */
src/mame/drivers/dietgo.c
r7500r7501
1111#include "sound/okim6295.h"
1212#include "includes/decocrpt.h"
1313#include "includes/decoprot.h"
14#include "includes/deco16ic.h"
14#include "includes/dietgo.h"
15#include "video/deco16ic.h"
1516
16VIDEO_UPDATE( dietgo );
17VIDEO_START( dietgo );
1817
19
2018static ADDRESS_MAP_START( dietgo_map, ADDRESS_SPACE_PROGRAM, 16 )
2119   AM_RANGE(0x000000, 0x07ffff) AM_ROM
22   AM_RANGE(0x200000, 0x20000f) AM_WRITEONLY AM_BASE(&deco16_pf12_control)
23   AM_RANGE(0x210000, 0x211fff) AM_WRITE(deco16_pf1_data_w) AM_BASE(&deco16_pf1_data)
24   AM_RANGE(0x212000, 0x213fff) AM_WRITE(deco16_pf2_data_w) AM_BASE(&deco16_pf2_data)
25   AM_RANGE(0x220000, 0x2207ff) AM_WRITEONLY AM_BASE(&deco16_pf1_rowscroll)
26   AM_RANGE(0x222000, 0x2227ff) AM_WRITEONLY AM_BASE(&deco16_pf2_rowscroll)
27   AM_RANGE(0x280000, 0x2807ff) AM_RAM AM_BASE_SIZE_GENERIC(spriteram)
28   AM_RANGE(0x300000, 0x300bff) AM_RAM_WRITE(deco16_nonbuffered_palette_w) AM_BASE_GENERIC(paletteram)
20   AM_RANGE(0x200000, 0x20000f) AM_DEVWRITE("deco_custom", deco16ic_pf12_control_w)
21   AM_RANGE(0x210000, 0x211fff) AM_DEVWRITE("deco_custom", deco16ic_pf1_data_w)
22   AM_RANGE(0x212000, 0x213fff) AM_DEVWRITE("deco_custom", deco16ic_pf2_data_w)
23   AM_RANGE(0x220000, 0x2207ff) AM_WRITEONLY AM_BASE_MEMBER(dietgo_state, pf1_rowscroll)
24   AM_RANGE(0x222000, 0x2227ff) AM_WRITEONLY AM_BASE_MEMBER(dietgo_state, pf2_rowscroll)
25   AM_RANGE(0x280000, 0x2807ff) AM_RAM AM_BASE_SIZE_MEMBER(dietgo_state, spriteram, spriteram_size)
26   AM_RANGE(0x300000, 0x300bff) AM_RAM_DEVWRITE("deco_custom", deco16ic_nonbuffered_palette_w) AM_BASE_GENERIC(paletteram)
2927   AM_RANGE(0x340000, 0x3407ff) AM_READWRITE(dietgo_104_prot_r, dietgo_104_prot_w)
3028   AM_RANGE(0x380000, 0x38ffff) AM_RAM // mainram
3129ADDRESS_MAP_END
r7500r7501
5351   PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_SERVICE1 )
5452   PORT_BIT( 0x0008, IP_ACTIVE_HIGH, IPT_VBLANK )
5553
56   PORT_START("IN1")   /* 16bit */
54   PORT_START("IN1")
5755   PORT_BIT( 0x0001, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_8WAY PORT_PLAYER(1)
5856   PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_8WAY PORT_PLAYER(1)
5957   PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_8WAY PORT_PLAYER(1)
r7500r7501
7169   PORT_BIT( 0x4000, IP_ACTIVE_LOW, IPT_BUTTON3 ) PORT_PLAYER(2)
7270   PORT_BIT( 0x8000, IP_ACTIVE_LOW, IPT_START2 )
7371
74   PORT_START("DSW")   /* Dip switch bank 1 */
72   PORT_START("DSW")
7573   PORT_DIPNAME( 0x0007, 0x0007, DEF_STR( Coin_A ) )
7674   PORT_DIPSETTING(      0x0000, DEF_STR( 3C_1C ) )
7775   PORT_DIPSETTING(      0x0001, DEF_STR( 2C_1C ) )
r7500r7501
9795   PORT_DIPSETTING(      0x0080, "1 Start/1 Continue" )
9896   PORT_DIPSETTING(      0x0000, "2 Start/1 Continue" )
9997
100   /* Dip switch bank 2 */
10198   PORT_DIPNAME( 0x0300, 0x0300, DEF_STR( Lives ) )
10299   PORT_DIPSETTING(      0x0100, "1" )
103100   PORT_DIPSETTING(      0x0000, "2" )
r7500r7501
164161
165162static void sound_irq(running_device *device, int state)
166163{
167   cputag_set_input_line(device->machine, "audiocpu", 1, state); /* IRQ 2 */
164   dietgo_state *driver_state = (dietgo_state *)device->machine->driver_data;
165   cpu_set_input_line(driver_state->audiocpu, 1, state); /* IRQ 2 */
168166}
169167
170168static const ym2151_interface ym2151_config =
r7500r7501
172170   sound_irq
173171};
174172
173
174static int dietgo_bank_callback(const int bank)
175{
176   return ((bank >> 4) & 0x7) * 0x1000;
177}
178
179static const deco16ic_interface dietgo_deco16ic_intf =
180{
181   "screen",
182   1, 0, 1,
183   0x0f, 0x0f, 0x0f, 0x0f,   /* trans masks (default values) */
184   0, 16, 0, 16, /* color base (default values) */
185   0x0f, 0x0f, 0x0f, 0x0f,   /* color masks (default values) */
186   dietgo_bank_callback,
187   dietgo_bank_callback,
188   NULL,
189   NULL
190};
191
192
193static MACHINE_START( dietgo )
194{
195   dietgo_state *state = (dietgo_state *)machine->driver_data;
196
197   state->maincpu = devtag_get_device(machine, "maincpu");
198   state->audiocpu = devtag_get_device(machine, "audiocpu");
199   state->deco16ic = devtag_get_device(machine, "deco_custom");
200}
201
175202static MACHINE_DRIVER_START( dietgo )
203
204   /* driver data */
205   MDRV_DRIVER_DATA(dietgo_state)
206
176207   /* basic machine hardware */
177208   MDRV_CPU_ADD("maincpu", M68000, XTAL_28MHz/2) /* DE102 (verified on pcb) */
178209   MDRV_CPU_PROGRAM_MAP(dietgo_map)
r7500r7501
181212   MDRV_CPU_ADD("audiocpu", H6280, XTAL_32_22MHz/4/3)   /* Custom chip 45; XIN is 32.220MHZ/4, verified on pcb */
182213   MDRV_CPU_PROGRAM_MAP(sound_map)
183214
215   MDRV_MACHINE_START(dietgo)
216
184217   /* video hardware */
185218   MDRV_SCREEN_ADD("screen", RASTER)
186219   MDRV_SCREEN_REFRESH_RATE(58)
r7500r7501
192225   MDRV_PALETTE_LENGTH(1024)
193226   MDRV_GFXDECODE(dietgo)
194227
195   MDRV_VIDEO_START(dietgo)
196228   MDRV_VIDEO_UPDATE(dietgo)
197229
230   MDRV_DECO16IC_ADD("deco_custom", dietgo_deco16ic_intf)
231
198232   /* sound hardware */
199233   MDRV_SPEAKER_STANDARD_MONO("mono")
200234
r7500r7501
334368   deco102_decrypt_cpu(machine, "maincpu", 0xe9ba, 0x01, 0x19);
335369}
336370
337GAME( 1992, dietgo,   0,      dietgo, dietgo,  dietgo,    ROT0, "Data East Corporation", "Diet Go Go (Euro v1.1 1992.09.26)", 0 )
338GAME( 1992, dietgoe,  dietgo, dietgo, dietgo,  dietgo,    ROT0, "Data East Corporation", "Diet Go Go (Euro v1.1 1992.08.04)" , 0) // weird, still version 1.1 but different date
339GAME( 1992, dietgou,  dietgo, dietgo, dietgo,  dietgo,    ROT0, "Data East Corporation", "Diet Go Go (USA v1.1 1992.09.26)", 0 )
340GAME( 1992, dietgoj,  dietgo, dietgo, dietgo,  dietgo,    ROT0, "Data East Corporation", "Diet Go Go (Japan v1.1 1992.09.26)", 0 )
371GAME( 1992, dietgo,   0,      dietgo, dietgo,  dietgo,    ROT0, "Data East Corporation", "Diet Go Go (Euro v1.1 1992.09.26)", GAME_SUPPORTS_SAVE )
372GAME( 1992, dietgoe,  dietgo, dietgo, dietgo,  dietgo,    ROT0, "Data East Corporation", "Diet Go Go (Euro v1.1 1992.08.04)" , GAME_SUPPORTS_SAVE ) // weird, still version 1.1 but different date
373GAME( 1992, dietgou,  dietgo, dietgo, dietgo,  dietgo,    ROT0, "Data East Corporation", "Diet Go Go (USA v1.1 1992.09.26)", GAME_SUPPORTS_SAVE )
374GAME( 1992, dietgoj,  dietgo, dietgo, dietgo,  dietgo,    ROT0, "Data East Corporation", "Diet Go Go (Japan v1.1 1992.09.26)", GAME_SUPPORTS_SAVE )
src/mame/drivers/f1gp.c
r7500r7501
228228   PORT_BIT( 0x0002, IP_ACTIVE_LOW, IPT_UNKNOWN )
229229   PORT_BIT( 0x0004, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_2WAY
230230   PORT_BIT( 0x0008, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_2WAY
231   PORT_BIT( 0x0010, IP_ACTIVE_LOW, IPT_BUTTON2 )
232   PORT_BIT( 0x0020, IP_ACTIVE_LOW, IPT_BUTTON1 )
231   PORT_BIT( 0x0010, IP_ACTIVE_LOW, IPT_BUTTON1 )
232   PORT_BIT( 0x0020, IP_ACTIVE_LOW, IPT_BUTTON2 )
233233   PORT_BIT( 0x0040, IP_ACTIVE_LOW, IPT_UNKNOWN )
234234   PORT_BIT( 0x0080, IP_ACTIVE_LOW, IPT_UNKNOWN )
235235   PORT_BIT( 0x0100, IP_ACTIVE_LOW, IPT_COIN1 )
src/mame/drivers/supdrapo.c
r7500r7501
3333#include "sound/ay8910.h"
3434
3535
36typedef struct _supdrapo_state supdrapo_state;
37struct _supdrapo_state
36class supdrapo_state
3837{
38public:
39   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, supdrapo_state(machine)); }
40
41   supdrapo_state(running_machine &machine) { }
42
3943   UINT8 *char_bank;
4044   UINT8 *col_line;
4145   UINT8 *videoram;
src/mame/drivers/dotrikun.c
r7500r7501
2424#include "cpu/z80/z80.h"
2525
2626
27typedef struct _dotrikun_state dotrikun_state;
28struct _dotrikun_state
27class dotrikun_state
2928{
29public:
30   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, dotrikun_state(machine)); }
31
32   dotrikun_state(running_machine &machine) { }
33
3034   /* memory pointers */
3135   UINT8 *        videoram;
3236   size_t         videoram_size;
src/mame/drivers/spoker.c
r7500r7501
1818                                Video Hardware
1919***************************************************************************/
2020
21typedef struct _spoker_state spoker_state;
22struct _spoker_state
21class spoker_state
2322{
23public:
24   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, spoker_state(machine)); }
25
26   spoker_state(running_machine &machine) { }
27
2428   UINT8   *bg_tile_ram;
2529   tilemap_t *bg_tilemap;
2630
src/mame/drivers/ohmygod.c
r7500r7501
1414#include "emu.h"
1515#include "cpu/m68000/m68000.h"
1616#include "sound/okim6295.h"
17#include "includes/ohmygod.h"
1718
1819
19extern UINT16 *ohmygod_videoram;
20
21WRITE16_HANDLER( ohmygod_videoram_w );
22WRITE16_HANDLER( ohmygod_spritebank_w );
23WRITE16_HANDLER( ohmygod_scrollx_w );
24WRITE16_HANDLER( ohmygod_scrolly_w );
25VIDEO_START( ohmygod );
26VIDEO_UPDATE( ohmygod );
27
28
29static int adpcm_bank_shift;
30static int sndbank;
31
32static MACHINE_RESET( ohmygod )
20static WRITE16_HANDLER( ohmygod_ctrl_w )
3321{
34   UINT8 *rom = memory_region(machine, "oki");
22   ohmygod_state *state = (ohmygod_state *)space->machine->driver_data;
3523
36   sndbank = 0;
37   memcpy(rom + 0x20000,rom + 0x40000 + 0x20000 * sndbank,0x20000);
38}
39
40static WRITE16_HANDLER( ohmygod_ctrl_w )
41{
4224   if (ACCESSING_BITS_0_7)
4325   {
4426      UINT8 *rom = memory_region(space->machine, "oki");
4527
4628      /* ADPCM bank switch */
47      if (sndbank != ((data >> adpcm_bank_shift) & 0x0f))
29      if (state->sndbank != ((data >> state->adpcm_bank_shift) & 0x0f))
4830      {
49         sndbank = (data >> adpcm_bank_shift) & 0x0f;
50         memcpy(rom + 0x20000,rom + 0x40000 + 0x20000 * sndbank,0x20000);
31         state->sndbank = (data >> state->adpcm_bank_shift) & 0x0f;
32         memcpy(rom + 0x20000, rom + 0x40000 + 0x20000 * state->sndbank, 0x20000);
5133      }
5234   }
5335   if (ACCESSING_BITS_8_15)
5436   {
55      coin_counter_w(space->machine, 0,data & 0x1000);
56      coin_counter_w(space->machine, 1,data & 0x2000);
37      coin_counter_w(space->machine, 0, data & 0x1000);
38      coin_counter_w(space->machine, 1, data & 0x2000);
5739   }
5840}
5941
6042static ADDRESS_MAP_START( ohmygod_map, ADDRESS_SPACE_PROGRAM, 16 )
6143   AM_RANGE(0x000000, 0x07ffff) AM_ROM
6244   AM_RANGE(0x300000, 0x303fff) AM_RAM
63   AM_RANGE(0x304000, 0x307fff) AM_RAM_WRITE(ohmygod_videoram_w) AM_BASE(&ohmygod_videoram)
45   AM_RANGE(0x304000, 0x307fff) AM_RAM_WRITE(ohmygod_videoram_w) AM_BASE_MEMBER(ohmygod_state, videoram)
6446   AM_RANGE(0x308000, 0x30ffff) AM_RAM
6547   AM_RANGE(0x400000, 0x400001) AM_WRITE(ohmygod_scrollx_w)
6648   AM_RANGE(0x400002, 0x400003) AM_WRITE(ohmygod_scrolly_w)
6749   AM_RANGE(0x600000, 0x6007ff) AM_RAM_WRITE(paletteram16_xGGGGGRRRRRBBBBB_word_w) AM_BASE_GENERIC(paletteram)
68   AM_RANGE(0x700000, 0x703fff) AM_RAM AM_BASE_SIZE_GENERIC(spriteram)
50   AM_RANGE(0x700000, 0x703fff) AM_RAM AM_BASE_SIZE_MEMBER(ohmygod_state, spriteram, spriteram_size)
6951   AM_RANGE(0x704000, 0x707fff) AM_RAM
7052   AM_RANGE(0x708000, 0x70ffff) AM_RAM    /* Work RAM */
7153   AM_RANGE(0x800000, 0x800001) AM_READ_PORT("P1")
r7500r7501
312294
313295
314296
297static MACHINE_START( ohmygod )
298{
299   ohmygod_state *state = (ohmygod_state *)machine->driver_data;
300
301   state_save_register_global(machine, state->spritebank);
302   state_save_register_global(machine, state->scrollx);
303   state_save_register_global(machine, state->scrolly);
304   state_save_register_global(machine, state->sndbank);
305}
306
307static MACHINE_RESET( ohmygod )
308{
309   ohmygod_state *state = (ohmygod_state *)machine->driver_data;
310   UINT8 *rom = memory_region(machine, "oki");
311
312   state->sndbank = 0;
313   memcpy(rom + 0x20000, rom + 0x40000 + 0x20000 * state->sndbank, 0x20000);
314
315   state->spritebank = 0;
316   state->scrollx = 0;
317   state->scrolly = 0;
318}
319
315320static MACHINE_DRIVER_START( ohmygod )
316321
322   /* driver data */
323   MDRV_DRIVER_DATA(ohmygod_state)
324
317325   /* basic machine hardware */
318326   MDRV_CPU_ADD("maincpu", M68000, 12000000)
319327   MDRV_CPU_PROGRAM_MAP(ohmygod_map)
320328   MDRV_CPU_VBLANK_INT("screen", irq1_line_hold)
321329
322   MDRV_MACHINE_RESET(ohmygod)
323330   MDRV_WATCHDOG_TIME_INIT(SEC(3))   /* a guess, and certainly wrong */
324331
332   MDRV_MACHINE_START(ohmygod)
333   MDRV_MACHINE_RESET(ohmygod)
334
325335   /* video hardware */
326336   MDRV_SCREEN_ADD("screen", RASTER)
327337   MDRV_SCREEN_REFRESH_RATE(60)
r7500r7501
387397
388398static DRIVER_INIT( ohmygod )
389399{
390   adpcm_bank_shift = 4;
400   ohmygod_state *state = (ohmygod_state *)machine->driver_data;
401   state->adpcm_bank_shift = 4;
391402}
392403
393404static DRIVER_INIT( naname )
394405{
395   adpcm_bank_shift = 0;
406   ohmygod_state *state = (ohmygod_state *)machine->driver_data;
407   state->adpcm_bank_shift = 0;
396408}
397409
398410
399GAME( 1993, ohmygod, 0, ohmygod, ohmygod, ohmygod, ROT0, "Atlus", "Oh My God! (Japan)", GAME_NO_COCKTAIL )
400GAME( 1994, naname,  0, ohmygod, naname,  naname,  ROT0, "Atlus", "Naname de Magic! (Japan)", GAME_NO_COCKTAIL )
411GAME( 1993, ohmygod, 0, ohmygod, ohmygod, ohmygod, ROT0, "Atlus", "Oh My God! (Japan)", GAME_NO_COCKTAIL | GAME_SUPPORTS_SAVE )
412GAME( 1994, naname,  0, ohmygod, naname,  naname,  ROT0, "Atlus", "Naname de Magic! (Japan)", GAME_NO_COCKTAIL | GAME_SUPPORTS_SAVE )
src/mame/drivers/aeroboto.c
r7500r7501
4545   aeroboto_state *state = (aeroboto_state *)device->machine->driver_data;
4646
4747   if (!state->disable_irq)
48      cpu_set_input_line(device, 0, HOLD_LINE);
48      cpu_set_input_line(device, 0, ASSERT_LINE);
4949   else
5050      state->disable_irq--;
5151}
5252
53static READ8_HANDLER( aeroboto_irq_ack_r )
54{
55   cputag_set_input_line(space->machine,"maincpu", 0, CLEAR_LINE);
56   return 0xff;
57}
58
5359static READ8_HANDLER( aeroboto_2973_r )
5460{
5561   aeroboto_state *state = (aeroboto_state *)space->machine->driver_data;
r7500r7501
8692   AM_RANGE(0x3004, 0x3004) AM_READ(aeroboto_201_r) AM_WRITEONLY AM_BASE_MEMBER(aeroboto_state, starx)
8793   AM_RANGE(0x3005, 0x3005) AM_WRITEONLY AM_BASE_MEMBER(aeroboto_state, stary)   // usable but probably wrong
8894   AM_RANGE(0x3006, 0x3006) AM_WRITEONLY AM_BASE_MEMBER(aeroboto_state, bgcolor)
89   AM_RANGE(0x3800, 0x3800) AM_READNOP                     // watchdog or IRQ ack
95   AM_RANGE(0x3800, 0x3800) AM_READ(aeroboto_irq_ack_r)      // watchdog or IRQ ack
9096   AM_RANGE(0x4000, 0xffff) AM_ROM                        // main ROM
9197ADDRESS_MAP_END
9298
src/mame/drivers/oneshot.c
r7500r7501
3232#include "emu.h"
3333#include "cpu/z80/z80.h"
3434#include "cpu/m68000/m68000.h"
35#include "includes/oneshot.h"
3536#include "sound/okim6295.h"
3637#include "sound/3812intf.h"
37#include "includes/oneshot.h"
3838
39
40UINT16 *oneshot_sprites;
41UINT16 *oneshot_bg_videoram;
42UINT16 *oneshot_mid_videoram;
43UINT16 *oneshot_fg_videoram;
44UINT16 *oneshot_scroll;
45
46int gun_x_p1,gun_y_p1,gun_x_p2,gun_y_p2;
47int gun_x_shift;
48
4939static READ16_HANDLER( oneshot_in0_word_r )
5040{
41   oneshot_state *state = (oneshot_state *)space->machine->driver_data;
5142   int data = input_port_read(space->machine, "DSW1");
5243
5344   switch (data & 0x0c)
5445   {
5546      case 0x00 :
56         gun_x_shift = 35;
47         state->gun_x_shift = 35;
5748         break;
5849      case 0x04 :
59         gun_x_shift = 30;
50         state->gun_x_shift = 30;
6051         break;
6152      case 0x08 :
62         gun_x_shift = 40;
53         state->gun_x_shift = 40;
6354         break;
6455      case 0x0c :
65         gun_x_shift = 50;
56         state->gun_x_shift = 50;
6657         break;
6758   }
6859
r7500r7501
7162
7263static READ16_HANDLER( oneshot_gun_x_p1_r )
7364{
65   oneshot_state *state = (oneshot_state *)space->machine->driver_data;
66
7467   /* shots must be in a different location to register */
75   static int wobble = 0;
76   wobble ^= 1;
68   state->p1_wobble ^= 1;
7769
78   return gun_x_p1 ^ wobble;
70   return state->gun_x_p1 ^ state->p1_wobble;
7971}
8072
8173static READ16_HANDLER( oneshot_gun_y_p1_r )
8274{
83   return gun_y_p1;
75   oneshot_state *state = (oneshot_state *)space->machine->driver_data;
76   return state->gun_y_p1;
8477}
8578
8679static READ16_HANDLER( oneshot_gun_x_p2_r )
8780{
81   oneshot_state *state = (oneshot_state *)space->machine->driver_data;
82
8883   /* shots must be in a different location to register */
89   static int wobble = 0;
90   wobble ^= 1;
84   state->p2_wobble ^= 1;
9185
92   return gun_x_p2 ^ wobble;
86   return state->gun_x_p2 ^ state->p2_wobble;
9387}
9488
9589static READ16_HANDLER( oneshot_gun_y_p2_r )
9690{
97   return gun_y_p2;
91   oneshot_state *state = (oneshot_state *)space->machine->driver_data;
92   return state->gun_y_p2;
9893}
9994
10095static WRITE16_DEVICE_HANDLER( soundbank_w )
r7500r7501
111106   AM_RANGE(0x000000, 0x03ffff) AM_ROM
112107   AM_RANGE(0x080000, 0x087fff) AM_RAM
113108   AM_RANGE(0x0c0000, 0x0c07ff) AM_RAM_WRITE(paletteram16_xBBBBBGGGGGRRRRR_word_w) AM_BASE_GENERIC(paletteram)
114   AM_RANGE(0x120000, 0x120fff) AM_RAM AM_BASE(&oneshot_sprites)
115   AM_RANGE(0x180000, 0x180fff) AM_RAM_WRITE(oneshot_mid_videoram_w) AM_BASE(&oneshot_mid_videoram) // some people , girl etc.
116   AM_RANGE(0x181000, 0x181fff) AM_RAM_WRITE(oneshot_fg_videoram_w) AM_BASE(&oneshot_fg_videoram) // credits etc.
117   AM_RANGE(0x182000, 0x182fff) AM_RAM_WRITE(oneshot_bg_videoram_w) AM_BASE(&oneshot_bg_videoram) // credits etc.
118   AM_RANGE(0x188000, 0x18800f) AM_WRITEONLY AM_BASE(&oneshot_scroll)   // scroll registers
109   AM_RANGE(0x120000, 0x120fff) AM_RAM AM_BASE_MEMBER(oneshot_state, sprites)
110   AM_RANGE(0x180000, 0x180fff) AM_RAM_WRITE(oneshot_mid_videoram_w) AM_BASE_MEMBER(oneshot_state, mid_videoram) // some people , girl etc.
111   AM_RANGE(0x181000, 0x181fff) AM_RAM_WRITE(oneshot_fg_videoram_w) AM_BASE_MEMBER(oneshot_state, fg_videoram) // credits etc.
112   AM_RANGE(0x182000, 0x182fff) AM_RAM_WRITE(oneshot_bg_videoram_w) AM_BASE_MEMBER(oneshot_state, bg_videoram) // credits etc.
113   AM_RANGE(0x188000, 0x18800f) AM_WRITEONLY AM_BASE_MEMBER(oneshot_state, scroll)   // scroll registers
119114   AM_RANGE(0x190002, 0x190003) AM_READ(soundlatch_word_r)
120115   AM_RANGE(0x190010, 0x190011) AM_WRITE(soundlatch_word_w)
121116   AM_RANGE(0x190018, 0x190019) AM_DEVWRITE("oki", soundbank_w)
r7500r7501
140135
141136
142137static INPUT_PORTS_START( oneshot )
143   PORT_START("DSW1")   /* DSW 1    (0x19c020.l -> 0x08006c.l) */
138   PORT_START("DSW1")   /* 0x19c020.l -> 0x08006c.l */
144139   PORT_DIPNAME( 0x03, 0x00, DEF_STR( Coinage ) )      // 0x080084.l : credits (00-09)
145140   PORT_DIPSETTING(    0x03, DEF_STR( 3C_1C ) )
146141   PORT_DIPSETTING(    0x02, DEF_STR( 2C_1C ) )
r7500r7501
162157   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
163158   PORT_DIPSETTING(    0x80, DEF_STR( On ) )
164159
165   PORT_START("DSW2")   /* DSW 2    (0x19c024.l -> 0x08006e.l) */
160   PORT_START("DSW2")   /* 0x19c024.l -> 0x08006e.l */
166161   PORT_DIPNAME( 0x03, 0x00, DEF_STR( Lives ) )      // 0x082500.l
167162   PORT_DIPSETTING(    0x01, "1" )
168163   PORT_DIPSETTING(    0x02, "2" )
r7500r7501
182177   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
183178   PORT_DIPSETTING(    0x80, DEF_STR( On ) )
184179
185   PORT_START("CREDITS")   /* Credits  (0x19c02c.l -> 0x08007a.l) */
180   PORT_START("CREDITS")   /* 0x19c02c.l -> 0x08007a.l */
186181   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_UNKNOWN )
187182   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_UNKNOWN )
188183   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_UNKNOWN )
r7500r7501
227222INPUT_PORTS_END
228223
229224static INPUT_PORTS_START( maddonna )
230   PORT_START("DSW1") /* DSW A */
225   PORT_START("DSW1")
231226   PORT_DIPNAME( 0x03, 0x00, DEF_STR( Coinage ) )
232227   PORT_DIPSETTING(    0x03, DEF_STR( 3C_1C ) )
233228   PORT_DIPSETTING(    0x02, DEF_STR( 2C_1C ) )
r7500r7501
250245   PORT_DIPSETTING(    0x40, DEF_STR( On ) )
251246   PORT_SERVICE( 0x80, IP_ACTIVE_HIGH )
252247
253   PORT_START("DSW2") /* DSW B */
248   PORT_START("DSW2")
254249   PORT_DIPNAME( 0x03, 0x02, DEF_STR( Difficulty ) )
255250   PORT_DIPSETTING(    0x00, DEF_STR( Easy ) )            // 2 Monsters at start, but "dumber"??
256251   PORT_DIPSETTING(    0x01, DEF_STR( Normal ) )         // 2 Monsters at start
r7500r7501
273268   PORT_DIPSETTING(    0x80, "On - 01" )
274269   PORT_DIPSETTING(    0xc0, "On - 11" )
275270
276   PORT_START("CREDITS")   /* Credits */
271   PORT_START("CREDITS")
277272   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_UNKNOWN )
278273   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_UNKNOWN )
279274   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_UNKNOWN )
r7500r7501
283278   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_START2 )
284279   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_UNKNOWN )
285280
286   PORT_START("P1")   /* Player 1 */
281   PORT_START("P1")
287282   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP ) PORT_8WAY PORT_PLAYER(1)
288283   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN ) PORT_8WAY PORT_PLAYER(1)
289284   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT ) PORT_8WAY PORT_PLAYER(1)
r7500r7501
293288   PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_UNKNOWN )
294289   PORT_BIT( 0x80, IP_ACTIVE_HIGH, IPT_UNKNOWN )
295290
296   PORT_START("P2")   /* Player 1 */
291   PORT_START("P2")
297292   PORT_BIT( 0x01, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP ) PORT_8WAY PORT_PLAYER(2)
298293   PORT_BIT( 0x02, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN ) PORT_8WAY PORT_PLAYER(2)
299294   PORT_BIT( 0x04, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT ) PORT_8WAY PORT_PLAYER(2)
r7500r7501
337332
338333static void irq_handler(running_device *device, int irq)
339334{
340   cputag_set_input_line(device->machine, "audiocpu", 0, irq ? ASSERT_LINE : CLEAR_LINE);
335   oneshot_state *state = (oneshot_state *)device->machine->driver_data;
336   cpu_set_input_line(state->audiocpu, 0, irq ? ASSERT_LINE : CLEAR_LINE);
341337}
342338
343339static const ym3812_interface ym3812_config =
r7500r7501
345341   irq_handler
346342};
347343
344static MACHINE_START( oneshot )
345{
346   oneshot_state *state = (oneshot_state *)machine->driver_data;
347
348   state->maincpu = devtag_get_device(machine, "maincpu");
349   state->audiocpu = devtag_get_device(machine, "audiocpu");
350
351   state_save_register_global(machine, state->gun_x_p1);
352   state_save_register_global(machine, state->gun_y_p1);
353   state_save_register_global(machine, state->gun_x_p2);
354   state_save_register_global(machine, state->gun_y_p2);
355   state_save_register_global(machine, state->gun_x_shift);
356   state_save_register_global(machine, state->p1_wobble);
357   state_save_register_global(machine, state->p2_wobble);
358}
359
360static MACHINE_RESET( oneshot )
361{
362   oneshot_state *state = (oneshot_state *)machine->driver_data;
363
364   state->gun_x_p1 = 0;
365   state->gun_y_p1 = 0;
366   state->gun_x_p2 = 0;
367   state->gun_y_p2 = 0;
368   state->gun_x_shift = 0;
369   state->p1_wobble = 0;
370   state->p2_wobble = 0;
371}
372
348373static MACHINE_DRIVER_START( oneshot )
349374
375   /* driver data */
376   MDRV_DRIVER_DATA(oneshot_state)
377
350378   /* basic machine hardware */
351379   MDRV_CPU_ADD("maincpu", M68000, 12000000)
352380   MDRV_CPU_PROGRAM_MAP(oneshot_map)
r7500r7501
355383   MDRV_CPU_ADD("audiocpu", Z80, 5000000)
356384   MDRV_CPU_PROGRAM_MAP(oneshot_sound_map)
357385
358   MDRV_GFXDECODE(oneshot)
386   MDRV_MACHINE_START(oneshot)
387   MDRV_MACHINE_RESET(oneshot)
359388
360389   /* video hardware */
361390   MDRV_SCREEN_ADD("screen", RASTER)
r7500r7501
365394   MDRV_SCREEN_SIZE(32*16, 32*16)
366395   MDRV_SCREEN_VISIBLE_AREA(0*16, 20*16-1, 0*16, 15*16-1)
367396
397   MDRV_GFXDECODE(oneshot)
368398   MDRV_PALETTE_LENGTH(0x400)
369399
370400   MDRV_VIDEO_START(oneshot)
r7500r7501
470500
471501
472502
473
474
475GAME( 199?, oneshot,  0,        oneshot,  oneshot , 0, ROT0, "<unknown>", "One Shot One Kill", GAME_IMPERFECT_GRAPHICS )
476GAME( 1995, maddonna, 0,        maddonna, maddonna, 0, ROT0, "Tuning",  "Mad Donna (set 1)", 0 )
477GAME( 1995, maddonnb, maddonna, maddonna, maddonna, 0, ROT0, "Tuning",  "Mad Donna (set 2)", GAME_NOT_WORKING )
503GAME( 199?, oneshot,  0,        oneshot,  oneshot , 0, ROT0, "<unknown>", "One Shot One Kill", GAME_IMPERFECT_GRAPHICS | GAME_SUPPORTS_SAVE )
504GAME( 1995, maddonna, 0,        maddonna, maddonna, 0, ROT0, "Tuning",  "Mad Donna (set 1)", GAME_SUPPORTS_SAVE )
505GAME( 1995, maddonnb, maddonna, maddonna, maddonna, 0, ROT0, "Tuning",  "Mad Donna (set 2)", GAME_NOT_WORKING | GAME_SUPPORTS_SAVE )
src/mame/drivers/dominob.c
r7500r7501
6464#include "cpu/z80/z80.h"
6565#include "sound/ay8910.h"
6666
67typedef struct _dominob_state dominob_state;
68struct _dominob_state
67class dominob_state
6968{
69public:
70   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, dominob_state(machine)); }
71
72   dominob_state(running_machine &machine) { }
73
7074   /* memory pointers */
7175   UINT8 *  spriteram;
7276   UINT8 *  videoram;
src/mame/drivers/bladestl.c
r7500r7501
391391
392392ROM_START( bladestl )
393393   ROM_REGION( 0x18000, "maincpu", 0 ) /* code + banked roms */
394   ROM_LOAD( "797t01.bin", 0x10000, 0x08000, CRC(89d7185d) SHA1(0d2f346d9515cab0389106c0e227fb0bd84a2c9c) )   /* fixed ROM */
395   ROM_CONTINUE(         0x08000, 0x08000 )            /* banked ROM */
394   ROM_LOAD( "797-t01.19c", 0x10000, 0x08000, CRC(89d7185d) SHA1(0d2f346d9515cab0389106c0e227fb0bd84a2c9c) )   /* fixed ROM */
395   ROM_CONTINUE(            0x08000, 0x08000 )            /* banked ROM */
396396
397397   ROM_REGION( 0x10000, "audiocpu", 0 ) /* 64k for the sound CPU */
398   ROM_LOAD( "797c02", 0x08000, 0x08000, CRC(65a331ea) SHA1(f206f6c5f0474542a5b7686b2f4d2cc7077dd5b9) )
398   ROM_LOAD( "797-c02.12d", 0x08000, 0x08000, CRC(65a331ea) SHA1(f206f6c5f0474542a5b7686b2f4d2cc7077dd5b9) )
399399
400400   ROM_REGION( 0x080000, "gfx1", 0 )
401   ROM_LOAD( "797a05",   0x000000, 0x40000, CRC(5491ba28) SHA1(c807774827c55c211ab68f548e1e835289cc5744) )   /* tiles */
402   ROM_LOAD( "797a06",   0x040000, 0x40000, CRC(d055f5cc) SHA1(3723b39b2a3e6dd8e7fc66bbfe1eef9f80818774) )   /* sprites */
401   ROM_LOAD( "797a05.19h", 0x000000, 0x40000, CRC(5491ba28) SHA1(c807774827c55c211ab68f548e1e835289cc5744) )   /* tiles */
402   ROM_LOAD( "797a06.13h", 0x040000, 0x40000, CRC(d055f5cc) SHA1(3723b39b2a3e6dd8e7fc66bbfe1eef9f80818774) )   /* sprites */
403403
404404   ROM_REGION( 0x0100, "proms", 0 )
405   ROM_LOAD( "797a07", 0x0000, 0x0100, CRC(7aecad4e) SHA1(05150a8dd25bdd6ab0c5b350e6ffd272f040e46a) ) /* sprites lookup table */
405   ROM_LOAD( "797a07.16i", 0x0000, 0x0100, CRC(7aecad4e) SHA1(05150a8dd25bdd6ab0c5b350e6ffd272f040e46a) ) /* sprites lookup table, 63S141N BPROM */
406406
407407   ROM_REGION( 0xc0000, "upd", 0 ) /* uPD7759 data (chip 1) */
408   ROM_LOAD( "797a03", 0x00000, 0x80000, CRC(9ee1a542) SHA1(c9a142a326875a50f03e49e83a84af8bb423a467) )
409   ROM_LOAD( "797a04",   0x80000, 0x40000, CRC(9ac8ea4e) SHA1(9f81eff970c9e8aea6f67d8a7d89805fae044ae1) )
408   ROM_LOAD( "797a03.11a", 0x00000, 0x80000, CRC(9ee1a542) SHA1(c9a142a326875a50f03e49e83a84af8bb423a467) )
409   ROM_LOAD( "797a04.9a",  0x80000, 0x40000, CRC(9ac8ea4e) SHA1(9f81eff970c9e8aea6f67d8a7d89805fae044ae1) )
410410ROM_END
411411
412ROM_START( bladestll )
413   ROM_REGION( 0x18000, "maincpu", 0 ) /* code + banked roms */
414   ROM_LOAD( "797-l01.19c", 0x10000, 0x08000, CRC(1ab14c40) SHA1(c566e31a666b467d75f5fc9fa427986c3ebc705c) )   /* fixed ROM */
415   ROM_CONTINUE(            0x08000, 0x08000 )            /* banked ROM */
416
417   ROM_REGION( 0x10000, "audiocpu", 0 ) /* 64k for the sound CPU */
418   ROM_LOAD( "797-c02.12d", 0x08000, 0x08000, CRC(65a331ea) SHA1(f206f6c5f0474542a5b7686b2f4d2cc7077dd5b9) )
419
420   ROM_REGION( 0x080000, "gfx1", 0 )
421   ROM_LOAD( "797a05.19h", 0x000000, 0x40000, CRC(5491ba28) SHA1(c807774827c55c211ab68f548e1e835289cc5744) )   /* tiles */
422   ROM_LOAD( "797a06.13h", 0x040000, 0x40000, CRC(d055f5cc) SHA1(3723b39b2a3e6dd8e7fc66bbfe1eef9f80818774) )   /* sprites */
423
424   ROM_REGION( 0x0100, "proms", 0 )
425   ROM_LOAD( "797a07.16i", 0x0000, 0x0100, CRC(7aecad4e) SHA1(05150a8dd25bdd6ab0c5b350e6ffd272f040e46a) ) /* sprites lookup table, 63S141N BPROM */
426
427   ROM_REGION( 0xc0000, "upd", 0 ) /* uPD7759 data (chip 1) */
428   ROM_LOAD( "797a03.11a", 0x00000, 0x80000, CRC(9ee1a542) SHA1(c9a142a326875a50f03e49e83a84af8bb423a467) )
429   ROM_LOAD( "797a04.9a",  0x80000, 0x40000, CRC(9ac8ea4e) SHA1(9f81eff970c9e8aea6f67d8a7d89805fae044ae1) )
430ROM_END
431
412432ROM_START( bladestle )
413433   ROM_REGION( 0x18000, "maincpu", 0 ) /* code + banked roms */
414   ROM_LOAD( "797e01", 0x10000, 0x08000, CRC(f8472e95) SHA1(8b6caa905fb1642300dd9da508871b00429872c3) )   /* fixed ROM */
415   ROM_CONTINUE(      0x08000, 0x08000 )            /* banked ROM */
434   ROM_LOAD( "797-e01.19c", 0x10000, 0x08000, CRC(f8472e95) SHA1(8b6caa905fb1642300dd9da508871b00429872c3) )   /* fixed ROM */
435   ROM_CONTINUE(            0x08000, 0x08000 )            /* banked ROM */
416436
417437   ROM_REGION( 0x10000, "audiocpu", 0 ) /* 64k for the sound CPU */
418   ROM_LOAD( "797c02", 0x08000, 0x08000, CRC(65a331ea) SHA1(f206f6c5f0474542a5b7686b2f4d2cc7077dd5b9) )
438   ROM_LOAD( "797-c02.12d", 0x08000, 0x08000, CRC(65a331ea) SHA1(f206f6c5f0474542a5b7686b2f4d2cc7077dd5b9) )
419439
420440   ROM_REGION( 0x080000, "gfx1", 0 )
421   ROM_LOAD( "797a05",   0x000000, 0x40000, CRC(5491ba28) SHA1(c807774827c55c211ab68f548e1e835289cc5744) )   /* tiles */
422   ROM_LOAD( "797a06",   0x040000, 0x40000, CRC(d055f5cc) SHA1(3723b39b2a3e6dd8e7fc66bbfe1eef9f80818774) )   /* sprites */
441   ROM_LOAD( "797a05.19h", 0x000000, 0x40000, CRC(5491ba28) SHA1(c807774827c55c211ab68f548e1e835289cc5744) )   /* tiles */
442   ROM_LOAD( "797a06.13h", 0x040000, 0x40000, CRC(d055f5cc) SHA1(3723b39b2a3e6dd8e7fc66bbfe1eef9f80818774) )   /* sprites */
423443
424444   ROM_REGION( 0x0100, "proms", 0 )
425   ROM_LOAD( "797a07", 0x0000, 0x0100, CRC(7aecad4e) SHA1(05150a8dd25bdd6ab0c5b350e6ffd272f040e46a) ) /* sprites lookup table */
445   ROM_LOAD( "797a07.16i", 0x0000, 0x0100, CRC(7aecad4e) SHA1(05150a8dd25bdd6ab0c5b350e6ffd272f040e46a) ) /* sprites lookup table, 63S141N BPROM */
426446
427   ROM_REGION( 0xc0000, "upd", 0 ) /* uPD7759 data */
428   ROM_LOAD( "797a03", 0x00000, 0x80000, CRC(9ee1a542) SHA1(c9a142a326875a50f03e49e83a84af8bb423a467) )
429   ROM_LOAD( "797a04",   0x80000, 0x40000, CRC(9ac8ea4e) SHA1(9f81eff970c9e8aea6f67d8a7d89805fae044ae1) )
447   ROM_REGION( 0xc0000, "upd", 0 ) /* uPD7759 data (chip 1) */
448   ROM_LOAD( "797a03.11a", 0x00000, 0x80000, CRC(9ee1a542) SHA1(c9a142a326875a50f03e49e83a84af8bb423a467) )
449   ROM_LOAD( "797a04.9a",  0x80000, 0x40000, CRC(9ac8ea4e) SHA1(9f81eff970c9e8aea6f67d8a7d89805fae044ae1) )
430450ROM_END
431451
432452
r7500r7501
437457 *************************************/
438458
439459GAME( 1987, bladestl,  0,        bladestl, bladestl, 0, ROT90, "Konami", "Blades of Steel (version T)", GAME_SUPPORTS_SAVE )
460GAME( 1987, bladestll, bladestl, bladestl, bladestle,0, ROT90, "Konami", "Blades of Steel (version L)", GAME_SUPPORTS_SAVE )
440461GAME( 1987, bladestle, bladestl, bladestl, bladestle,0, ROT90, "Konami", "Blades of Steel (version E)", GAME_SUPPORTS_SAVE )
src/mame/drivers/funworld.c
r7500r7501
11/**********************************************************************************
22
33
4    FUNWORLD / TAB.
4  FUNWORLD / TAB.
55
6    Original preliminary driver:    Curt Coder, Peter Trauner.
7    Rewrite and aditional work:     Roberto Fresca.
6  Original preliminary driver:    Curt Coder, Peter Trauner.
7  Rewrite and aditional work:     Roberto Fresca.
88
99
10    Games running on this hardware:
10  Games running on this hardware:
1111
12    * Jolly Card (austrian),                            TAB-Austria,        1985.
13    * Jolly Card (3x3 deal),                            TAB-Austria,        1985.
14    * Jolly Card Professional 2.0,                      Spale-Soft,         2000.
15    * Jolly Card (Evona Electronic),                    Evona Electronic    1998.
16    * Jolly Card (croatian, set 1),                     TAB-Austria,        1985.
17    * Jolly Card (croatian, set 2),                     Soft Design,        1993.
18    * Jolly Card (italian, blue TAB board, encrypted),  bootleg,            199?.
19    * Jolly Card (italian, encrypted bootleg),          bootleg,            1990.
20    * Super Joly 2000 - 3x,                             M.P.                1985.
21    * Jolly Card (austrian, Funworld, bootleg),         Inter Games,        1986.
22    * Big Deal (hungarian, set 1),                      Funworld,           1986.
23    * Big Deal (hungarian, set 2),                      Funworld,           1986.
24    * Jolly Card (austrian, Funworld),                  Funworld,           1986.
25    * Cuore 1 (italian),                                C.M.C.,             1996.
26    * Elephant Family (italian, new),                   C.M.C.,             1997.
27    * Elephant Family (italian, old),                   C.M.C.,             1996.
28    * Pool 10 (italian, set 1),                         C.M.C.,             1996.
29    * Pool 10 (italian, set 2),                         C.M.C.,             1996.
30    * Pool 10 (italian, set 3),                         C.M.C.,             1996.
31    * Pool 10 (italian, set 4),                         C.M.C.,             1997.
32    * Tortuga Family (italian),                         C.M.C.,             1997.
33    * Pot Game (italian),                               C.M.C.,             1996.
34    * Bottle 10 (italian, set 1),                       C.M.C.,             1996.
35    * Bottle 10 (italian, set 2),                       C.M.C.,             1996.
36    * Royal Card (austrian, set 1),                     TAB-Austria,        1991.
37    * Royal Card (austrian, set 2),                     TAB-Austria,        1991.
38    * Royal Card (slovak, encrypted),                   Evona Electronic,   1991.
39    * Royal Card Professional 2.0,                      Digital Dreams,     1993.
40    * Lucky Lady (3x3 deal),                            TAB-Austria,        1991.
41    * Lucky Lady (4x1 aces),                            TAB-Austria,        1991.
42    * Magic Card II (bulgarian),                        Impera,             1996.
43    * Magic Card II (green TAB or Impera board),        Impera,             1996.
44    * Magic Card II (blue TAB board, encrypted),        Impera,             1996.
45    * Royal Vegas Joker Card (slow deal),               Funworld,           1993.
46    * Royal Vegas Joker Card (fast deal),               Soft Design,        1993.
47    * Royal Vegas Joker Card (fast deal, english gfx),  Soft Design,        1993.
48    * Jolly Joker,                                      Impera,             198?.
49    * Jolly Joker (50bet),                              Impera,             198?.
50    * Joker Card (Ver.A267BC, encrypted),               Vesely Svet,        1993.
51    * Mongolfier New (italian),                         bootleg,            199?.
52    * Soccer New (italian),                             bootleg,            199?.
53    * Saloon (french, encrypted),                       unknown,            199?.
12  * Jolly Card (austrian),                            TAB-Austria,        1985.
13  * Jolly Card (3x3 deal),                            TAB-Austria,        1985.
14  * Jolly Card Professional 2.0,                      Spale-Soft,         2000.
15  * Jolly Card (Evona Electronic),                    Evona Electronic    1998.
16  * Jolly Card (croatian, set 1),                     TAB-Austria,        1985.
17  * Jolly Card (croatian, set 2),                     Soft Design,        1993.
18  * Jolly Card (italian, blue TAB board, encrypted),  bootleg,            199?.
19  * Jolly Card (italian, encrypted bootleg),          bootleg,            1990.
20  * Super Joly 2000 - 3x,                             M.P.                1985.
21  * Jolly Card (austrian, Funworld, bootleg),         Inter Games,        1986.
22  * Big Deal (hungarian, set 1),                      Funworld,           1986.
23  * Big Deal (hungarian, set 2),                      Funworld,           1986.
24  * Jolly Card (austrian, Funworld),                  Funworld,           1986.
25  * Cuore 1 (italian),                                C.M.C.,             1996.
26  * Elephant Family (italian, new),                   C.M.C.,             1997.
27  * Elephant Family (italian, old),                   C.M.C.,             1996.
28  * Pool 10 (italian, set 1),                         C.M.C.,             1996.
29  * Pool 10 (italian, set 2),                         C.M.C.,             1996.
30  * Pool 10 (italian, set 3),                         C.M.C.,             1996.
31  * Pool 10 (italian, set 4),                         C.M.C.,             1997.
32  * Tortuga Family (italian),                         C.M.C.,             1997.
33  * Pot Game (italian),                               C.M.C.,             1996.
34  * Bottle 10 (italian, set 1),                       C.M.C.,             1996.
35  * Bottle 10 (italian, set 2),                       C.M.C.,             1996.
36  * Royal Card (austrian, set 1),                     TAB-Austria,        1991.
37  * Royal Card (austrian, set 2),                     TAB-Austria,        1991.
38  * Royal Card (slovak, encrypted),                   Evona Electronic,   1991.
39  * Royal Card Professional 2.0,                      Digital Dreams,     1993.
40  * Lucky Lady (3x3 deal),                            TAB-Austria,        1991.
41  * Lucky Lady (4x1 aces),                            TAB-Austria,        1991.
42  * Magic Card II (bulgarian),                        Impera,             1996.
43  * Magic Card II (green TAB or Impera board),        Impera,             1996.
44  * Magic Card II (blue TAB board, encrypted),        Impera,             1996.
45  * Royal Vegas Joker Card (slow deal),               Funworld,           1993.
46  * Royal Vegas Joker Card (fast deal),               Soft Design,        1993.
47  * Royal Vegas Joker Card (fast deal, english gfx),  Soft Design,        1993.
48  * Jolly Joker (98bet, set 1).                       Impera,             198?.
49  * Jolly Joker (98bet, set 2).                       Impera,             198?.
50  * Jolly Joker (40bet, croatian hack),               Impera,             198?.
51  * Joker Card (Ver.A267BC, encrypted),               Vesely Svet,        1993.
52  * Mongolfier New (italian),                         bootleg,            199?.
53  * Soccer New (italian),                             bootleg,            199?.
54  * Saloon (french, encrypted),                       unknown,            199?.
5455
5556
5657***********************************************************************************
5758
5859
59    The hardware is generally composed by:
60  The hardware is generally composed by:
6061
61    CPU:    1x 65SC02 or 65C02 at 2MHz.
62    Sound:  1x AY3-8910 or YM2149F (AY8910 compatible) at 2MHz.
63    I/O:    2x 6821 (PIA)
64    Video:  1x 6845 (CRTC)
65    RAM:    1x 6116
66    NVRAM:  1x 6264
67    ROMs:   3x 27256 (or 27512 in some cases)
68    PROMs:  1x 82S147 (or similar. 512 bytes)
69    PLDs:   1 to 4 PALs, GALs or PEELs
70    Clock:  1x Crystal: 16MHz.
62  CPU:    1x 65SC02 or 65C02 at 2MHz.
63  Sound:  1x AY3-8910 or YM2149F (AY8910 compatible) at 2MHz.
64  I/O:    2x 6821 (PIA)
65  Video:  1x 6845 (CRTC)
66  RAM:    1x 6116
67  NVRAM:  1x 6264
68  ROMs:   3x 27256 (or 27512 in some cases)
69  PROMs:  1x 82S147 (or similar. 512 bytes)
70  PLDs:   1 to 4 PALs, GALs or PEELs
71  Clock:  1x Crystal: 16MHz.
7172
7273
73    All current games are running from a slightly modified to heavily hacked hardware.
74    Color palettes are normally stored in format GGBBBRRR inside a bipolar color PROM.
74  All current games are running from a slightly modified to heavily hacked hardware.
75  Color palettes are normally stored in format GGBBBRRR inside a bipolar color PROM.
7576
76    - bits -
77    7654 3210
78    ---- -xxx   Red component.
79    --xx x---   Blue component.
80    xx-- ----   Green component.
77  - bits -
78  7654 3210
79  ---- -xxx   Red component.
80  --xx x---   Blue component.
81  xx-- ----   Green component.
8182
8283
83    The hardware was designed to manage 4096 tiles with a size of 8x4 pixels each.
84    Also support 4bpp graphics and the palette limitation is 8 bits for color codes (256 x 16colors).
85    It means the hardware was designed for more elaborated graphics than Jolly Card games...
86    Color PROMs from current games are 512 bytes lenght, but they only use the first 256 bytes.
84  The hardware was designed to manage 4096 tiles with a size of 8x4 pixels each.
85  Also support 4bpp graphics and the palette limitation is 8 bits for color codes (256 x 16colors).
86  It means the hardware was designed for more elaborated graphics than Jolly Card games...
87  Color PROMs from current games are 512 bytes lenght, but they only use the first 256 bytes.
8788
88    Normal hardware capabilities:
89  Normal hardware capabilities:
8990
90    - bits -
91    7654 3210
92    xxxx xx--   tiles color (game tiles)    ;codes 0x00-0xdc
93    xxx- x-xx   tiles color (title).        :codes 0xe9-0xeb
94    xxxx -xxx   tiles color (background).   ;codes 0xf1-0xf7
91  - bits -
92  7654 3210
93  xxxx xx--   tiles color (game tiles)    ;codes 0x00-0xdc
94  xxx- x-xx   tiles color (title).        :codes 0xe9-0xeb
95  xxxx -xxx   tiles color (background).   ;codes 0xf1-0xf7
9596
9697
97    About protection, there are several degrees of protection found in the sets:
98  About protection, there are several degrees of protection found in the sets:
9899
99    - There are writes to unknown offsets (out of the normal memory range), and some
100      checks later to see if the data is still there.
100  - There are writes to unknown offsets (out of the normal memory range), and some
101    checks later to see if the data is still there.
101102
102    - There are checks for code in unused RAM and therefore jumps to offsets where there
103      are not pieces of code in RAM or just RAM is inexistent.
104      I think this is to avoid a "ROM swap" that allow the software to run in other game boards.
103  - There are checks for code in unused RAM and therefore jumps to offsets where there
104    are not pieces of code in RAM or just RAM is inexistent.
105    I think this is to avoid a "ROM swap" that allow the software to run in other game boards.
105106
106    - There are "masked" unused inputs.
107      The software is polling the unused input status and expect a special value to boot the game.
107  - There are "masked" unused inputs.
108    The software is polling the unused input status and expect a special value to boot the game.
108109
109    - There are parts of code that are very complex and twisted with fake jumps to inexistent code,
110      or pretending to initialize fake devices.
110  - There are parts of code that are very complex and twisted with fake jumps to inexistent code,
111    or pretending to initialize fake devices.
111112
112    - Encryption.
113  - Encryption.
113114
114            A) Encrypted CPU. At least two Funworld boards have custom encrypted CPUs:
115      A) Encrypted CPU. At least two Funworld boards have custom encrypted CPUs:
115116
116                - Joker Card from Vesely Svet use a custom unknown CPU and use encrypted prg roms.
117                - Royal Card (slovak, encrypted) from Evona Electronic seems to use a block
118                  with CPU + extras (ICs, TTL, etc) to manage the encryption.
117          - Joker Card from Vesely Svet use a custom unknown CPU and use encrypted prg roms.
118          - Royal Card (slovak, encrypted) from Evona Electronic seems to use a block
119            with CPU + extras (ICs, TTL, etc) to manage the encryption.
119120
120            B) General encryption. Managed through hardware:
121      B) General encryption. Managed through hardware:
121122
122                - All games using the blue TAB PCB with 2x HY18CV85 (electrically-erasable PLDs), use
123                  complex operations for each byte nibble. See DRIVER_INIT for the final algorithm.
124                - Saloon (french) use bitswaps to address & data in program, graphics and color PROM.
123          - All games using the blue TAB PCB with 2x HY18CV85 (electrically-erasable PLDs), use
124            complex operations for each byte nibble. See DRIVER_INIT for the final algorithm.
125          - Saloon (french) use bitswaps to address & data in program, graphics and color PROM.
125126
126    - Microcontroller. Some games are using an extra microcontroller mainly for protection.
127  - Microcontroller. Some games are using an extra microcontroller mainly for protection.
127128
128129
129130
130    GENERAL NOTES:
131  GENERAL NOTES:
131132
132    - It takes 46 seconds for the bigdeal/jolycdat games to boot up
133      after the initial screen is displayed!!!
133  - It takes 46 seconds for the bigdeal/jolycdat games to boot up
134    after the initial screen is displayed!!!
134135
135    - The default DIP switch settings must be used when first booting up
136      the games to allow them to complete the NVRAM initialization.
136  - The default DIP switch settings must be used when first booting up
137    the games to allow them to complete the NVRAM initialization.
137138
138    - Almost all games: Start game, press and hold Service1 & Service2, press
139      reset (F3), release Service1/2 and press reset (F3) again.
140      Now the NVRAM has been initialized.
139  - Almost all games: Start game, press and hold Service1 & Service2, press
140    reset (F3), release Service1/2 and press reset (F3) again.
141    Now the NVRAM has been initialized.
141142
142    - Royalcdb needs a hard reset after NVRAM initialization.
143  - Royalcdb needs a hard reset after NVRAM initialization.
143144
144    - For games that allow remote credits, after NVRAM init change the payout
145      DIP switch from "Hopper" to "Manual Payout".
145  - For games that allow remote credits, after NVRAM init change the payout
146    DIP switch from "Hopper" to "Manual Payout".
146147
147148
148149
149    NOTES BY GAME/SET:
150  NOTES BY GAME/SET:
150151
151    * Pool 10
152    * Cuore 1
153    * Elephant Family
154    * Tortuga Family
155    * Pot Game
156    * Bottle 10
152  * Pool 10
153  * Cuore 1
154  * Elephant Family
155  * Tortuga Family
156  * Pot Game
157  * Bottle 10
157158
158    In Italy many people became addicted to videopokers. They put so much money on them,
159    and they had to sell the house. Also some engineers modified videopokers to do less
160    wins and so on... Because of this the government did some laws in order to regulate
161    videopokers wins. Starting from around 1996/1997 there were subsequent laws because
162    engineers always found a way to elude them.
159  In Italy many people became addicted to videopokers. They put so much money on them,
160  and they had to sell the house. Also some engineers modified videopokers to do less
161  wins and so on... Because of this the government did some laws in order to regulate
162  videopokers wins. Starting from around 1996/1997 there were subsequent laws because
163  engineers always found a way to elude them.
163164
164    Today all the videopokers need to be connected via AAMS net (a government society de-
165    dicated to games) which check if the videopoker is regular. Nowadays it's difficult
166    to trick and the videopoker has to give 75% of wins. This has made videopoker market
167    to collapse and infact there aren't many videopokers left.
165  Today all the videopokers need to be connected via AAMS net (a government society de-
166  dicated to games) which check if the videopoker is regular. Nowadays it's difficult
167  to trick and the videopoker has to give 75% of wins. This has made videopoker market
168  to collapse and infact there aren't many videopokers left.
168169
169    Also because the laws changed very often and old videopokers became illegal was a
170    very bad thing for bar owners because they couldn't earn enough money.
170  Also because the laws changed very often and old videopokers became illegal was a
171  very bad thing for bar owners because they couldn't earn enough money.
171172
172    Pool 10 (now found!), apparently was the "father" of other italian gambling games.
173    As soon as it became illegal, was converted to Cuore 1, Elephant Family, Tortuga Family
174    and maybe other games. So you can see that engineers always found a simple way to elude
175    the law.
173  Pool 10 (now found!), apparently was the "father" of other italian gambling games.
174  As soon as it became illegal, was converted to Cuore 1, Elephant Family, Tortuga Family
175  and maybe other games. So you can see that engineers always found a simple way to elude
176  the law.
176177
177    There is another set of Cuore 1. I didn't include it because the only difference with
178    the supported set is the program rom that is double sized, having identical halves.
178  There is another set of Cuore 1. I didn't include it because the only difference with
179  the supported set is the program rom that is double sized, having identical halves.
179180
180    There is at least one missing game in the family... 'Hippo Family', also from C.M.C.
181    This game should be located and dumped.
181  There is at least one missing game in the family... 'Hippo Family', also from C.M.C.
182  This game should be located and dumped.
182183
183184
184    --- Super Game ---
185  --- Super Game ---
185186
186    If you have some points accumulated and need to grab the tokens/tickets, you must to play
187    a bonus game called SUPER GAME to get the points out. To enter the bonus game, you must
188    press STOP5 in the attract mode. The payout system is through this game.
187  If you have some points accumulated and need to grab the tokens/tickets, you must to play
188  a bonus game called SUPER GAME to get the points out. To enter the bonus game, you must
189  press STOP5 in the attract mode. The payout system is through this game.
189190
190    5 themed items will be shown (cuores, balls, elephants, etc... depending of the game).
191    The joker will start to move from item to item quickly, but decreasing the speed gradually.
192    To beat the game, you need to push the start button in the exact moment when the joker is
193    located exactly in the center of the screen (item 3).
191  5 themed items will be shown (cuores, balls, elephants, etc... depending of the game).
192  The joker will start to move from item to item quickly, but decreasing the speed gradually.
193  To beat the game, you need to push the start button in the exact moment when the joker is
194  located exactly in the center of the screen (item 3).
194195
195    Depending of the DIP switches settings, you can grab the prize manually pressing the SCARICA
196    (payout) button, and then TICKET or HOPPER buttons. Press TICKET button to print a 100 points
197    ticket. Press HOPPER button to get tokens x10 points.
196  Depending of the DIP switches settings, you can grab the prize manually pressing the SCARICA
197  (payout) button, and then TICKET or HOPPER buttons. Press TICKET button to print a 100 points
198  ticket. Press HOPPER button to get tokens x10 points.
198199
199    You have 1 attempt for each 100 earned points. If you lose the game, you lose the points.
200  You have 1 attempt for each 100 earned points. If you lose the game, you lose the points.
200201
201202
202    * Jolly Card (austrian, Funworld, bootleg)
203  * Jolly Card (austrian, Funworld, bootleg)
203204
204    This one seems to have normal RAM instead of NVRAM.
205    Going through the code, there's not any NVRAM initialization routine through service 1 & 2.
205  This one seems to have normal RAM instead of NVRAM.
206  Going through the code, there's not any NVRAM initialization routine through service 1 & 2.
206207
207208
208    * Jolly Card Professional 2.0 (Spale-Soft)
209  * Jolly Card Professional 2.0 (Spale-Soft)
209210
210    Each 1st boot, this game show a generated code. You must enter this code in a DOS program to
211    get the input codes necessary to allow boot the game.
211  Each 1st boot, this game show a generated code. You must enter this code in a DOS program to
212  get the input codes necessary to allow boot the game.
212213
213    This set is one of the most wanted for customers because is a real SCAM.
214    The program has 2 hidden menues that allow change parameters without knowledge of the players.
214  This set is one of the most wanted for customers because is a real SCAM.
215  The program has 2 hidden menues that allow change parameters without knowledge of the players.
215216
216217
217     * Jolly Card (Evona Electronic)
218  * Jolly Card (Evona Electronic)
218219
219    This set has some hidden features.
220    In the service 2 screen, press service 1 to enter to a message edit mode.
220  This set has some hidden features.
221  In the service 2 screen, press service 1 to enter to a message edit mode.
221222
222223
223    * Jolly Card (croatian sets) and Jolly Card Professional 2.0
224  * Jolly Card (croatian sets) and Jolly Card Professional 2.0
224225
225    These games don't operate with regular coins/tokens. Only remote credits are allowed.
226  These games don't operate with regular coins/tokens. Only remote credits are allowed.
226227
227228
228    * Royal Card Professional 2.0 (Digital Dreams)
229  * Royal Card Professional 2.0 (Digital Dreams)
229230
230    Same generated code as Jolly Card Professional.
231  Same generated code as Jolly Card Professional.
231232
232233
233    * Magic Card II (Impera)
234  * Magic Card II (Impera)
234235
235    Impera made 2 graphics sets for this game. One of them is encrypted, and meant for the TAB blue board.
236    This board has two HY18CV85 (electrically-erasable PLD) that handle the encryption.
237    In another hand, the sound has some weird things, but is confirmed that happen in the real thing.
236  Impera made 2 graphics sets for this game. One of them is encrypted, and meant for the TAB blue board.
237  This board has two HY18CV85 (electrically-erasable PLD) that handle the encryption.
238  In another hand, the sound has some weird things, but is confirmed that happen in the real thing.
238239
239    The game resolution seems to change 'on the fly' when entering the input test mode.
240    There aren't any writes to the m6845 registers to manage these changes.
240  The game resolution seems to change 'on the fly' when entering the input test mode.
241  There aren't any writes to the m6845 registers to manage these changes.
241242
242    Regarding the CPU, it seems to be a custom one, or a daughterboard with a 65c02 + PLDs/TTLs.
243    Some CPU instructions seems to be changed. The following piece of code at $C1A8 is very clear:
243  Regarding the CPU, it seems to be a custom one, or a daughterboard with a 65c02 + PLDs/TTLs.
244  Some CPU instructions seems to be changed. The following piece of code at $C1A8 is very clear:
244245
245    C1A8: A0 00         ldy  #$00       ; clear Y register to use as counter.
246  C1A8: A0 00         ldy  #$00       ; clear Y register to use as counter.
246247
247    C1AA: B9 9D C1      lda  $C19D,y    ; load PIA port address
248    C1AD: 85 06         sta  $06        ; into $06-$07 ZP vector.
249    C1AF: B9 92 C1      lda  $C192,y    ;
250    C1B2: 85 07         sta  $07        ;
251    C1B4: C0 0B         cpy  #$0B
252    C1B6: B0 0C         bcs  $C1C4
248  C1AA: B9 9D C1      lda  $C19D,y    ; load PIA port address
249  C1AD: 85 06         sta  $06        ; into $06-$07 ZP vector.
250  C1AF: B9 92 C1      lda  $C192,y    ;
251  C1B2: 85 07         sta  $07        ;
252  C1B4: C0 0B         cpy  #$0B
253  C1B6: B0 0C         bcs  $C1C4
253254
254    ... load values to store into Accumulator...
255    ...
256    C1C6: 91 06         sta  ($06),y    ; store value in PIA port, indexed (Y).
257    C1C8: C8            iny             ; increment Y
258    C1C9: C0 0C         cpy  #$0C       ; finish?
259    C1CB: D0 DD         bne  $C1AA      ; if not, branch to load a new PIA adress.
255  ... load values to store into Accumulator...
256  ...
257  C1C6: 91 06         sta  ($06),y    ; store value in PIA port, indexed (Y).
258  C1C8: C8            iny             ; increment Y
259  C1C9: C0 0C         cpy  #$0C       ; finish?
260  C1CB: D0 DD         bne  $C1AA      ; if not, branch to load a new PIA adress.
260261
261    In this example, as soon as Y register increments, the indexed writes go out of range.
262    To get this piece of code working and initialize the PIAs properly, the instruction 0x91 should be
263    "sta ($ZP)" instead of Y indexed. (like instruction 0x92 in stock 65c02's).
262  In this example, as soon as Y register increments, the indexed writes go out of range.
263  To get this piece of code working and initialize the PIAs properly, the instruction 0x91 should be
264  "sta ($ZP)" instead of Y indexed. (like instruction 0x92 in stock 65c02's).
264265
265266
266    * Jolly Joker (Impera, 50bet)
267  * Jolly Joker (Impera, 50bet)
267268
268    To boot this game for 1st time, DSW should be in the following position:
269    1=ON 2=OFF 3=ON 4=OFF 5=OFF 6=ON 7=ON 8=OFF
269  To boot this game for 1st time, DSW should be in the following position:
270  1=ON 2=OFF 3=ON 4=OFF 5=OFF 6=ON 7=ON 8=OFF
270271
271    Press RESET (key F3) and then SERVICE1 & SERVICE2 (keys 9 & 0), then RESET (key F3).
272    When numbers start to fill the screen, press RESET (key F3) again to start the game.
272  Press RESET (key F3) and then SERVICE1 & SERVICE2 (keys 9 & 0), then RESET (key F3).
273  When numbers start to fill the screen, press RESET (key F3) again to start the game.
273274
274275
275    * Mongolfier New
276    * Soccer New
276  * Mongolfier New
277  * Soccer New
277278
278    These games are based in Royal Card. They are running in a heavely modified Royal Card
279    hardware with a microcontroller as an extra (protection?) component and a TDA2003 as
280    audio amplifier.
279  These games are based in Royal Card. They are running in a heavely modified Royal Card
280  hardware with a microcontroller as an extra (protection?) component and a TDA2003 as
281  audio amplifier.
281282
282    The extra microcontroller is a 8 bit (PLCC-44) TSC87C52-16CB from Intel (now dumped!)
283  The extra microcontroller is a 8 bit (PLCC-44) TSC87C52-16CB from Intel (now dumped!)
283284
284    Each set has double sized ROMs. One half contains the proper set and the other half store
285    a complete Royal Card set, so... Is possible the existence of a shortcut,'easter egg',
286    simple hack or DIP switches combination to enable the Royal Card game.
285  Each set has double sized ROMs. One half contains the proper set and the other half store
286  a complete Royal Card set, so... Is possible the existence of a shortcut,'easter egg',
287  simple hack or DIP switches combination to enable the Royal Card game.
287288
288    These games should be moved to a new driver in a near future, as soon as we know a bit more
289    about them and start to implement the missing pieces for an accurate emulation.
289  These games should be moved to a new driver in a near future, as soon as we know a bit more
290  about them and start to implement the missing pieces for an accurate emulation.
290291
291292
292    * Saloon
293  * Saloon
293294
294    This game is totally encrypted. No PIAs to drive I/O. The PCB has printed "LEOPARDO 5", so we
295    can expect a game called the same way to appear.
295  This game is totally encrypted. No PIAs to drive I/O. The PCB has printed "LEOPARDO 5", so we
296  can expect a game called the same way to appear.
296297
297    This game should be moved to a new driver in a near future, as soon as we know a bit more about it.
298  This game should be moved to a new driver in a near future, as soon as we know a bit more about it.
298299
299300
300301
301302***********************************************************************************
302303
303304
304    Memory Map (generic)
305    --------------------
305  Memory Map (generic)
306  --------------------
306307
308  $0000 - $07FF   NVRAM           // All registers and settings.
309  $0800 - $0803   PIA1            // Input Ports 0 & 1.
310  $0A00 - $0A03   PIA2            // Input Ports 2 & 3.
311  $0C00 - $0C00   AY-8910 (R/C)   // Read/Control.
312  $0C01 - $0C01   AY-8910 (W)     // Write. Lamps through output ports.
313  $0E00 - $0E00   CRTC6845 (A)    // MC6845 adressing.
314  $0E01 - $0E01   CRTC6845 (R/W)  // MC6845 Read/Write.
307315
308    $0000 - $07FF   NVRAM           // All registers and settings.
309    $0800 - $0803   PIA1            // Input Ports 0 & 1.
310    $0A00 - $0A03   PIA2            // Input Ports 2 & 3.
311    $0C00 - $0C00   AY-8910 (R/C)   // Read/Control.
312    $0C01 - $0C01   AY-8910 (W)     // Write. Lamps through output ports.
313    $0E00 - $0E00   CRTC6845 (A)    // MC6845 adressing.
314    $0E01 - $0E01   CRTC6845 (R/W)  // MC6845 Read/Write.
316  $2000 - $2FFF   VideoRAM (funworld/bigdeal)
317  $3000 - $3FFF   ColorRAM (funworld/bigdeal)
315318
316    $2000 - $2FFF   VideoRAM (funworld/bigdeal)
317    $3000 - $3FFF   ColorRAM (funworld/bigdeal)
319  $4000 - $4FFF   VideoRAM (magicrd2/royalcrd)
320  $5000 - $5FFF   ColorRAM (magicrd2/royalcrd)
318321
319    $4000 - $4FFF   VideoRAM (magicrd2/royalcrd)
320    $5000 - $5FFF   ColorRAM (magicrd2/royalcrd)
322  $6000 - $6FFF   VideoRAM (CMC italian games)
323  $7000 - $7FFF   ColorRAM (CMC italian games)
321324
322    $6000 - $6FFF   VideoRAM (CMC italian games)
323    $7000 - $7FFF   ColorRAM (CMC italian games)
325  $8000 - $FFFF   ROM (almost all games)
324326
325    $8000 - $FFFF   ROM (almost all games)
326327
328  *** MC6845 Initialization ***
327329
330  ----------------------------------------------------------------------------------------------------------------------
331  register:   00    01    02    03    04    05    06    07    08    09    10    11    12    13    14    15    16    17
332  ----------------------------------------------------------------------------------------------------------------------
333  jollycrd:  0x7C  0x60  0x65  0x08  0x1E  0x08  0x1D  0x1D  0x00  0x07  0x01  0x01  0x00  0x00  0x00  0x00  0x00  0x00.
334  jolycdae:  0x7C  0x60  0x65  0x08  0x1E  0x08  0x1D  0x1D  0x00  0x07  0x01  0x01  0x00  0x00  0x00  0x00  0x00  0x00.
335  jolycdcr:  0x7C  0x60  0x65  0x08  0x1E  0x08  0x1D  0x1D  0x00  0x07  0x01  0x01  0x00  0x00  0x00  0x00  0x00  0x00.
336  jolycdit:  0x7C  0x60  0x65  0x08  0x1E  0x08  0x1D  0x1D  0x00  0x07  0x01  0x01  0x00  0x00  0x00  0x00  0x00  0x00.
337  jolycdab:  0x7C  0x60  0x65  0x08  0x1E  0x08  0x1D  0x1D  0x00  0x07  0x01  0x01  0x00  0x00  0x00  0x00  0x00  0x00.
328338
329    *** MC6845 Initialization ***
339  bigdeal:  0x7C  0x60  0x65 0x08  0x1E  0x08  0x1D  0x1D  0x00  0x07  0x01  0x01  0x00  0x00  0x00  0x00  0x00  0x00.
330340
331    ----------------------------------------------------------------------------------------------------------------------
332    register:   00    01    02    03    04    05    06    07    08    09    10    11    12    13    14    15    16    17
333    ----------------------------------------------------------------------------------------------------------------------
334    jollycrd:  0x7C  0x60  0x65  0x08  0x1E  0x08  0x1D  0x1D  0x00  0x07  0x01  0x01  0x00  0x00  0x00  0x00  0x00  0x00.
335    jolycdae:  0x7C  0x60  0x65  0x08  0x1E  0x08  0x1D  0x1D  0x00  0x07  0x01  0x01  0x00  0x00  0x00  0x00  0x00  0x00.
336    jolycdcr:  0x7C  0x60  0x65  0x08  0x1E  0x08  0x1D  0x1D  0x00  0x07  0x01  0x01  0x00  0x00  0x00  0x00  0x00  0x00.
337    jolycdit:  0x7C  0x60  0x65  0x08  0x1E  0x08  0x1D  0x1D  0x00  0x07  0x01  0x01  0x00  0x00  0x00  0x00  0x00  0x00.
338    jolycdab:  0x7C  0x60  0x65  0x08  0x1E  0x08  0x1D  0x1D  0x00  0x07  0x01  0x01  0x00  0x00  0x00  0x00  0x00  0x00.
341  cuoreuno:  0x7C  0x60  0x65  0x08  0x1E  0x08  0x1D  0x1D  0x00  0x07  0x01  0x01  0x00  0x00  0x00  0x00  0x00  0x00.
342  elephfam:  0x7C  0x60  0x65  0x08  0x1E  0x08  0x1D  0x1D  0x00  0x07  0x01  0x01  0x00  0x00  0x00  0x00  0x00  0x00.
343  pool10:    0x7C  0x60  0x65  0x08  0x1E  0x08  0x1D  0x1D  0x00  0x07  0x01  0x01  0x00  0x00  0x00  0x00  0x00  0x00.
344  tortufam:  0x7C  0x60  0x65  0x08  0x1E  0x08  0x1D  0x1D  0x00  0x07  0x01  0x01  0x00  0x00  0x00  0x00  0x00  0x00.
339345
340    bigdeal:   0x7C  0x60  0x65  0x08  0x1E  0x08  0x1D  0x1D  0x00  0x07  0x01  0x01  0x00  0x00  0x00  0x00  0x00  0x00.
346  royalcrd:  0x7C  0x60  0x65  0xA8  0x1E  0x08  0x1D  0x1C  0x00  0x07  0x01  0x01  0x00  0x00  0x00  0x00  0x00  0x00.
347  magicrd2:  0x7B  0x70  0x66  0xA8  0x24  0x08  0x22  0x22  0x00  0x07  0x01  0x01  0x00  0x00  0x00  0x00  0x00  0x00.
341348
342    cuoreuno:  0x7C  0x60  0x65  0x08  0x1E  0x08  0x1D  0x1D  0x00  0x07  0x01  0x01  0x00  0x00  0x00  0x00  0x00  0x00.
343    elephfam:  0x7C  0x60  0x65  0x08  0x1E  0x08  0x1D  0x1D  0x00  0x07  0x01  0x01  0x00  0x00  0x00  0x00  0x00  0x00.
344    pool10:    0x7C  0x60  0x65  0x08  0x1E  0x08  0x1D  0x1D  0x00  0x07  0x01  0x01  0x00  0x00  0x00  0x00  0x00  0x00.
345    tortufam:  0x7C  0x60  0x65  0x08  0x1E  0x08  0x1D  0x1D  0x00  0x07  0x01  0x01  0x00  0x00  0x00  0x00  0x00  0x00.
349  monglfir:  0x7C  0x60  0x65  0xA8  0x1E  0x08  0x1D  0x1C  0x00  0x07  0x01  0x01  0x00  0x00  0x00  0x00  0x00  0x00.
350  soccernw:  0x7C  0x60  0x65  0xA8  0x1E  0x08  0x1D  0x1C  0x00  0x07  0x01  0x01  0x00  0x00  0x00  0x00  0x00  0x00.
346351
347    royalcrd:  0x7C  0x60  0x65  0xA8  0x1E  0x08  0x1D  0x1C  0x00  0x07  0x01  0x01  0x00  0x00  0x00  0x00  0x00  0x00.
348    magicrd2:  0x7B  0x70  0x66  0xA8  0x24  0x08  0x22  0x22  0x00  0x07  0x01  0x01  0x00  0x00  0x00  0x00  0x00  0x00.
349352
350    monglfir:  0x7C  0x60  0x65  0xA8  0x1E  0x08  0x1D  0x1C  0x00  0x07  0x01  0x01  0x00  0x00  0x00  0x00  0x00  0x00.
351    soccernw:  0x7C  0x60  0x65  0xA8  0x1E  0x08  0x1D  0x1C  0x00  0x07  0x01  0x01  0x00  0x00  0x00  0x00  0x00  0x00.
352
353
354353***********************************************************************************
355354
356355
357    *** Hardware Info ***
356  *** Hardware Info ***
358357
358  Moved all tech info to the ROM load section...
359359
360    Jolly Card, TAB Austria
361    -----------------------
362360
363    Pinouts:
361***********************************************************************************
364362
365    X1-01   GND                     X1-A    GND
366    X1-02   GND                     X1-B    GND
367    X1-03   GND                     X1-C    GND
368    X1-04   +5V                     X1-D    +5V
369    X1-05   +12V                    X1-E    +12V
370    X1-06   NC                      X1-F    NC
371    X1-07   NC                      X1-G    NC
372    X1-08   NC                      X1-H    NC
373    X1-09   NC                      X1-I    Coin 1
374    X1-10   Coin 2                  X1-J    Pay Out SW
375    X1-11   Hold 3                  X1-K    NC
376    X1-12   NC                      X1-L    GND
377    X1-13   Hold 4                  X1-M    Remote
378    X1-14   Bookkeeping SW          X1-N    GND
379    X1-15   Hold 2                  X1-O    Cancel
380    X1-16   Hold 1                  X1-P    Hold 5
381    X1-17   Start                   X1-Q
382    X1-18   Hopper Out              X1-R
383    X1-19   Red                     X1-S    Green
384    X1-20   Blue                    X1-T    Sync
385    X1-21   GND                     X1-U    Speaker GND
386    X1-22   Speaker +               X1-V    Management SW
387363
388    X2-01   GND                     X2-A    GND
389    X2-02   NC                      X2-B    NC
390    X2-03   Start                   X2-C    NC
391    X2-04   NC                      X2-D    NC
392    X2-05   NC                      X2-E    NC
393    X2-06   Lamp Start              X2-F    Lamp Hold 1+3
394    X2-07   Lamp Hold 2             X2-G    Lamp Hold 4
395    X2-08   Lamp Hold 5             X2-H    Lamp Cancel
396    X2-09   NC                      X2-I    NC
397    X2-10   Counter In              X2-J    Counter Out
398    X2-11   Hopper Count            X2-K    Hopper Drive
399    X2-12   Counter Remote          X2-L
400    X2-13                           X2-M
401    X2-14                           X2-N
402    X2-15   NC                      X2-O
403    X2-16                           X2-P
404    X2-17                           X2-Q    Coin Counter
405    X2-18                           X2-R
364  *** Driver Updates by Roberto Fresca ***
406365
407    ---------------------------------------------------
408366
409    DIP Switches:
367  [2005/09/08]
368  - Added Cuore Uno, Elephant Family and Royal Card.
410369
411        ON                  OFF
370  [2005/09/19]
371  - Added some clones.
372  - Cleaned up and renamed all sets. Made parent-clone relationship.
412373
413    1   Hopper              Manual Payout SW    :Payout
414    2   Auto Hold           No Auto Hold        :Hold
415    3   Joker               Without Joker       :Joker
416    4   Dattl Insert        TAB Insert          :Inserts
417    5   5 Points/Coin       10 Points/Coin      :Coin 1
418    6   5 Points/Coin       10 Points/Coin      :Coin 2
419    7   10 Points/Pulse     100 Points/Pulse    :Remote
420    8   Play                Keyboard Test       :Mode
374  [2005/12/15]
375  - Corrected CPU freq (2 MHz) in cuoreuno and elephfam (both have R65c02P2).
376     (I suspect more games must have their CPU running at 2 MHz).
377  - Corrected videoram and colorram offsets in cuoreuno and elephfam.
378  - To initialize the NVRAM in cuoreuno and elephfam:
379     Start game, press and hold Service1 & Service2, press reset (F3),
380     release Service1 & Service2 and press reset (F3) again.
421381
422    ---------------------------------------------------
382  [2006/10/18]
383  - Corrected the screen size and visible area to cuoreuno and elephfam based on mc6845 registers.
384  - Added all inputs to cuoreuno and elephfam.
385  - Added test mode DIP switch to cuoreuno and elephfam.
386  - Managed cuoreuno and elephfam inputs to pass the initial checks. Now both games are playable.
387  - Changed the cuoreuno full name to "Cuore 1" (as shown in the attract).
423388
389  [2006/10/22-28]
390  - Corrected cuoreuno and elephfam graphics to 4bpp.
391  - Fixed elephfam gfx planes.
392  - Simulated cuoreuno palette based on screenshots.
393  - Simulated elephfam palette based on screenshots.
424394
425395
426    Jolly Card (austrian, Funworld, bootleg)
427    ----------------------------------------
396  [2006/11/01 to 2006/12/04]
428397
429    - 1x G65SC02P (CPU)
430    - 1x MC68B45P (CRTC)
431    - 1x AY3-8910 (sound)
432    - 2x MC6821P  (PIAs)
398  ******** REWRITE ********
433399
434    RAM:  - 1x 6116
435          - 1x KM6264AL-10
400  - Merged/splitted some machine drivers, memory maps and inputs.
401  - Unified get_bg_tile_info for all games.
402  - Mapped the input buttons in a better format (all games). Keys: 156-QW-ZXCVBNM.
403  - Added proper color PROM decode routines.
404  - Rewrote the technical notes.
405  - Splitted the driver to driver/video.
436406
437    - 1x Crystal : 16.000 MHz
407  - Corrected the screen size and visible area to magiccrd based on mc6845 registers.
408  - Added the remaining 2 GFX planes to magiccrd, but GFX are imperfect (bad decode or bad dump?). Color PROM need to be dumped.
409  - Royalcrd: Added all inputs and DIP switches.
410     Fixed memory map, gfx decode
411     Corrected screen size and visible area based on mc6845 registers.
412     Corrected CPU clock to 2mhz.
438413
414  - New game added: Joker Poker. Not working due to use of custom encrypted CPU.
415  - New game added: Royal Card (Slovakia, encrypted). Not working due to use of a custom encrypted CPU.
416  - Fixed jolycdcr gfx to 4bpp.
417  - Other fixes to get jolycdcr running.
418  - Managed royalcdb to work, using the 2nd half of program ROM. (seems to be mapped that way)
419  - Managed jolycdit to work, but with imperfect graphics due to gfx encryption.
420  - Fixed CPU clock to 2MHz. in all remaining games.
421  - Fixed ay8910 frequency based on elephfam audio.
422  - Fixed ay8910 volume in all games to avoid clipping.
423  - Reworked jolycdcr inputs: The game was designed to work only with remote credits. After nvram init, set the payout dip to "manual".
424  - Reworked jolycdit inputs: After nvram init, set the payout dip to "manual" to allow work the remote mode.
425  - Set jolycdat as bigdeal clone. The game has the same layout/behaviour instead of the normal jolly card games, even when are sharing gfx roms.
426  - Added the bipolar PROM and GAL to jolycdit. Confirmed the GFX ROMs as good dumps.
427  - Added an alternate set of Elephant Family. This one lacks of test mode and doesn't allow to switch between min-max bets through stop1.
428  - Added color PROMs to cuoreuno and elephfam sets but still no routed. Also added PLDs (protected, bad dumps).
429  - Corrected jollycrd screen size and visible area based on mc6845 registers.
430  - Hooked, wired and decoded the color prom in jollycrd sets based on jolycdit redump. Now colors are perfect.
431  - Wired and decoded the color prom in cuoreuno and elephfam sets. Now colors are perfect.
432  - Wired and decoded the color prom in royalcrd. Now colors are perfect.
433  - Hooked, wired and decoded the color prom in bigdeal sets based on jolycdat (jollycrd palette).
434     Colors seems to be correct, but need to check against the real thing. Flagged as IMPERFECT_COLORS till a color PROM dump appear.
435  - Decrypted jolycdit gfx roms.
436  - Added set Jolly Card (Austria, encrypted).
437  - Decrypted jolycdae and managed the planes to show correct colors. The set is working properly.
439438
440439
441    Jolly Card (other)
442    ------------------
440  [2006/12/24]
441  - Fixed some incomplete inputs.
442  - Added new working game: Pool 10.
443  - Added new working game: Tortuga Family.
444  - Added new game: Mongolfier New. Not working due to the lack of MCU emulation.
445  - Added new game: Soccer New. Not working due to the lack of MCU emulation.
446  - Updated technical notes.
443447
444    - 1x G65SC02P (CPU)
445    - 1x MC68B45P (CRTC)
446    - 1x AY3-8910 (sound)
447    - 2x MC6821P  (PIAs)
448  [2007/02/01]
449  - All crystals documented via #defines.
450  - All CPU and sound clocks derived from #defined crystal values.
451  - Added DIPLOCATIONS to all games.
452  - Added a pool10 alternate set.
453  - Added proper tsc87c52 MCU dumps to monglfir and soccernew.
454  - Modified the refresh rate to 60 fps according to some video evidences.
455  - Updated technical notes.
448456
449    RAM:  - 1x NVram DS1220Y (instead of 6116)
450          - 1x KM6264AL-10
457  [2007/02/25]
458  - Added new game: Snooker 10 (Ver 1.11). Preliminary.
459     Properly decoded GFX
460     Proper colors decoded.
461  - Updated technical notes.
451462
452    - 1x Crystal : 16.000 MHz
463  [2007/09/21]
464  - Added new game: Saloon (France, encrypted). Preliminary.
465  - Updated technical notes.
453466
467  [2008/02/10]
468  - Switched to XTAL def.
469  - Fixed Magic Card II graphics issues.
470  - Fixed Magic Card II inputs.
471  - Fixed screen and visible area to snooker10.
472  - Renamed set monglfir to mongolnw.
473  - Renamed sets description based on languages instead of countries.
474  - Added new game: Magic Card II (green TAB or Impera board). Not working yet.
475  - Added new game: Magic Card II (blue TAB board, encrypted). Not working yet.
476  - Added new game: Jolly Card (3x3 deal).
477  - Added new game: Jolly Card Professional 2.0 (with 'enter code' screen to boot).
478  - Added new game: Lucky Lady (3x3 deal).
479  - Added new game: Lucky Lady (4x1 aces).
480  - Added new game: Royal Vegas Joker Card (fast deal).
481  - Added new game: Royal Vegas Joker Card (slow deal).
482  - Fixed some years and manufacturers.
483  - Updated technical notes.
484  - Cleaned up the driver.
454485
486  [2008/02/22]
487  - Switched the color decoding routines to use resnet code.
488  - Added complete color connections to/from 74ls373 to the source.
455489
456    Jolly Card (italian, blue Tab board, encrypted)
457    -----------------------------------------------
490  [2008/02/25]
491  - Added new game: Royal Vegas Joker Card (fast deal, english gfx).
492  - Added new game: Jolly Joker.
493  - Added new game: Jolly Joker (50bet).
494  - Added new game: Jolly Card (croatian, set 2).
495  - Added new game: Jolly Card (Evona Electronic)
496  - Added new game: Super Joly 2000 - 3x
497  - Fixed some inputs.
498  - Masked inputs to allow jolyjokra to boot.
499  - Added minor corrections.
500  - Updated technical notes.
458501
459    - 1x HY6264LP
460    - 1x MC6845P
461    - 1x HM6116LP
462    - 1x G65SC02 (main)
463    - 1x AY-3-8910 (sound)
464    - 1x MC6821P
465    - 1x oscillator 16.000 MHz
466    - ROMs  2x TMS27c256 (1,2)
467            1x M5M27256 (jn)
468    - 1x prom N82S147
469    - 1x GAL16V8B
470    - 2x HY18CV85 (electrically-erasable PLD)
471    - 1x 8 DIP switches
472    - 1x 22x2 edge connector
473    - 1x 18x2 edge connector
474    - 1x trimmer (volume)(missing)
502  [2008/03/14]
503  - Added proper inputs to jolyc980.
504  - Added temporary patch to allow bypass the "code" screen in jolyc980.
505  - Updated technical notes.
475506
507  [2008/03/18]
508  - Added new game: Pot Game (italian).
509  - Updated technical notes.
476510
477    Jolly Card (italian encrypted bootleg)
478    --------------------------------------
511  [2008/04/18]
512  - Removed the temporary hack to jolyc980.
513  - Updated technical notes regarding Magic Card II & Jolly Card Professional 2.0.
514  - Moved snookr10 to its own driver.
515  - Minor clean-up.
479516
480    - 1x UM6845P
481    - 1x R65C02P3 (main CPU)
482    - 1x AY-3-8910 (sound)
483    - 2x MC68B21P
484    - 1x oscillator 16.000 MHz
485    - ROMs  3x 27256.
486    - 1x PROM M1-7649-5 (not dumped)
487    - 2x PLD HY18CV8S (not dumped)
488    - 1x PAL16L8ACN (not dumped)
489    - 1x 22x2 edge connector
490    - 1x 18x2 edge connector
491    - 1x trimmer (volume)
492    - 1x 8x2 DIP switches.
517  [2008/04/27]
518  - Fixed AY8910 volume to all games to avoid clips.
519  - Merge bigdeal and funworld machine drivers thanks to the AY8910 rewrite.
520  - Removed old unaccurate commentary about magiccrd tiles.
493521
522  [2008/04/29]
523  All CMC italian games:
524  - Added TICKET and HOPPER buttons to allow payout through the SUPER GAME.
525  - Documented the featured SUPER GAME with complete instructions.
526  - Improved DIP switches to properly set the payout system.
494527
495    Big Deal (hungarian)
496    ------------------
528  [2008/05/13]
529  - Found the proper algorithm to decrypt the blue TAB PCB.
530  - Replaced the old decryption tables with the proper decryption scheme.
531  - Updated technical notes.
497532
498    - 1x MC6845P
499    - 1x YM2149F
500    - 2x MC6821P
501    - 1x Crystal 16.000 MHz
533  [2008/07/30]
534  - Added new clone: Pool 10 (italian, set 3).
535  - Updated technical notes.
502536
537  [2008/09/12]
538  - Added new clone: Pool 10 (italian, set 4).
539  - Improved lamps layout for all games.
540  - Added Pool 10 pinout and DIP switches info.
541  - Updated technical notes.
503542
543  [2008/12/01]
544  - Decripted saloon's program, graphics and color PROM.
545  - Created a new memory map and machine driver for saloon.
546  - Removed set jolycdae (it's not coming from a real board).
547  - Renamed the sets magiccrd, magiccda and magiccdb, to magicrd2, magicd2a and magicd2b.
548  - Updated technical notes.
504549
505    Magic Card II (bulgarian)
506    ---------------------------------
550  [2008/12/15]
551  - Added new set: Jolly Card (italian, encrypted bootleg).
552     No coins... Only remote credits. After nvram init, set the Payout DIP to 'manual'
553     to allow the remote credits mode to work.
554  - Created inputs from the scratch for jolycdib.
555  - Updated technical notes.
507556
508    - 1x Special CPU with CM602 (??) on it
509    - 1x MC6845P
510    - 1x YM2149F
511    - 2x MC6821P
512    - 1x Crystal 16.000 MHz
513    - 2x HY18CV85 (electrically-erasable PLD)
557  [2008-12-26]
558  - Correctly setup the MC6845 device for all systems.
559  - Added common MC6845 device interface.
560  - Eliminated the screen size & visible area parameters to Magic Card 2.
514561
562  [2009/01/23]
563  - Added new sets: Bottle 10 (italian, set 1 & 2).
564  - Updated technical notes.
515565
566  [2009/09/09]
567  - Discovered and documented new features in Jolly Card (Evona Electronics).
568  - Removed the commented hack for joly980 driver init since is not needed anymore.
569  - Fixed a bug introduced with the massive input change, that didn't allow initialize
570     all sets that need the normal procedure to do it.
571  - Updated technical notes.
516572
517    Cuore Uno (italian)
518    -----------------------------------
573  [2010/03/01]
574  - Fixed Jolly Joker graphics and colors.
575  - Changed Jolly Joker description to Jolly Joker (98bet).
576  - Added a new croatian set of Jolly Joker with maximum bet = 40.
577  - Moved the hardware description and tech notes to the ROM_LOAD section.
578  - Added a external default NVRAM for Jolly Card Professional 2.0.
579  - Updated technical notes.
519580
520    - CPU 1x G65SC02P
521    - 1x MC68B45P (CRT controller)
522    - 2x MC68B21CP (Peripheral Interface Adapter)
523    - 1x unknown (95101) DIP40 mil600
524    - 1x oscillator 16.000000 MHz
525    - ROMs  1x TMS27C512
526            2x TMS27C256
527    - 1x PROM AM27S29
528    - 2x PALCE20V8H
529    - 1x PALCE16V8H (soldered)
530    - Note 1x JAMMA edge connector (keep -5 disconnected)
531    - 1x trimmer (volume)
532    - 1x 8 DIP switches
533    - 1x battery
534581
582  *** TO DO ***
535583
584  - Figure out the royalcdc & jokercrd encryption.
585  - Figure out the remaining PIA connections for almost all games.
586  - Fix Saloon and move it to its own driver.
587  - Fix the imperfect sound in Magic Card II.
588  - Reverse-engineering the boot code of Jolly Card Professional 2.0,
589     and Royal Card Professional 2.0 to get the proper codes to boot.
590  - Analyze the unknown writes to $2000/$4000 in some games.
591  - Check for the reads to the ay8910 output ports in some games.
592  - Figure out the MCU in monglfir and soccernw.
593  - Correct the ROM_REGION in some games to allow the use of RGN_FRAC
536594
537    Elephant Family (italian, old)
538    -----------------------------
539595
540    - CPU 1x R65C02P2
541    - 1x MC68B45P (CRT controller)
542    - 2x EF6821P (Peripheral Interface Adapter)
543    - 1x unknown (95101) DIP40 mil600
544    - 1x oscillator 16.000 MHz
545    - ROMs  2x M27C256
546            1x TMS27C256
547    - 1x PROM AM27S29
548    - 2x PALCE20V8H (read protected)
549    - 1x PALCE16V8H (read protected)
550    - Note 1x JAMMA edge connector (keep -5 disconnected)
551    - 1x trimmer (volume)
552    - 1x 8 DIP switches
553    - 1x battery
554
555
556
557    Pool 10 (italian)
558    -----------------
559
560    - 1x R65C02P2 (main)
561    - 1x YM2149F (sound)
562    - 1x HD46505 (CRT controller)
563    - 2x EF6821P (Peripheral Interface Adapter)
564    - 1x oscillator 16.000000 MHz
565
566    - 2x M27256 (pool,1)
567    - 1x D27256 (2)
568    - 1x PROM N82S147AN
569    - 2x GAL20V8B (read protected)
570    - 1x PALCE16V8H (read protected)
571
572    - 1x JAMMA edge connector
573    - 1x trimmer (volume)
574    - 1x 8 DIP switches
575    - 1x battery
576
577
578    Connector, DIPs and instructions,
579    copied from an original sheet...
580
581              Components |  | solder
582    ---------------------|--|-----------------
583                     gnd |01| gnd
584                     gnd |02| gnd
585                      +5 |03| +5
586                      +5 |04| +5
587                         |06|
588                     +12 |07| +5
589                         |08| contatore out
590            motor hopper |09| contatore in
591                   audio |10| audio
592               sw hopper |11| gnd
593                   rosso |12| verde
594                     blu |13| sync
595                     gnd |14| statistic
596              manegement |15|
597                  coin 1 |16| coin 2
598               sw ticket |17| motor ticket
599                  hold 3 |18| lamp hold 3
600                  hold 4 |19| lamp hold 4
601                  hold 2 |20| lamp hold 2
602                  hold 1 |21| lamp hold 1
603                  hold 5 |22| lamp hold 5
604                   start |23| lamp hold start
605                  cancel |24| lamp hold cancel
606                      nc |25| +5 lamp
607    ric. ticket + hopper |26| +12 lamp
608                     gnd |27| gnd
609                     gnd |28| gnd
610
611
612    DIPS
613                          1    2   3   4   5   6   7   8
614                         on
615                         off
616    ticket + hopper           on  on
617    hopper                    on  off
618    ticket                    off on
619    no ticket - no hopper     off off
620    1 coin 1 credit                   off off
621    1 coin 5 credits                  off on
622    1 coin 10 credits                 on  off
623    1 coin 50 credits                 on  on
624    five of kind yes                          off
625    five of kind no                           on
626    royal flush yes                               off
627    royal flush no                                on
628    in test                                           on
629    in game                                           off
630
631
632    Instructions:
633
634    STATISTICS = show in and out credits
635    MANEGEMENT = It's the general statistic. It shows in and out credits.
636
637    To cancel statistics press CANCEL for 5 seconds.
638    To change max and min value for play connect to GND the manegement pin,
639    at the same time press toghether HOLD 2 + HOLD 4 for some seconds.
640
641    The following menu will show up:
642
643    HOLD 1 = modify max value for play 1 to 10.
644    HOLD 2 = modify min value foe play 1 to 5.
645    Press start to exit from programming mode.
646
647    To unlock PCB from a possible lock:
648    connect GND to pins component15 and solder14 for 5 seconds
649
650    NB. Use lamps by 12V 0,15W
651    Memory version: V16
652
653
654
655    Tortuga Family (italian) & Pot Game (italian)
656    ---------------------------------------------
657
658    - 1x G65SC02P2 (main)
659    - 1x 95101 (sound)
660    - 1x MC68B45P (CRT controller)
661    - 2x MC68B21CP (Peripheral Interface Adapter)
662    - 1x oscillator 16.000000 MHz
663
664    - 3x TMS27C256
665    - 1x PROM AM27S29PC
666    - 2x PALCE20V8H (read protected)
667    - 1x PALCE16V8H (read protected)
668
669    - 1x JAMMA edge connector
670    - 1x trimmer (volume)
671    - 1x 8 DIP switches
672    - 1x battery
673
674
675
676    Royal Card (set 1)
677    ------------------
678
679    - 1x HM6264LP
680    - 1x HD4650SP
681    - 1x HM6116LP
682    - 1x R65C02P2 (main)
683    - 1x WB5300 (labeled YM8910)(sound)
684    - 1x EF6821P
685    - 1x oscillator 16.000 MHz
686
687    - 1x D27256 (1)
688    - 1x S27C256 (2)
689    - 1x TMS27C256 (r2)
690    - 2x PEEL18CV8 (1 protected)
691    - 1x PALCE16V8H (protected)
692    - 1x PROM N82S147AN
693
694    - 1x 8 DIP Switches
695    - 1x 22x2 edge connector
696    - 1x 18x2 edge connector
697    - 1x trimmer (volume)
698
699
700
701    Royal Card (set 2)
702    ------------------
703
704    - CPU 1x R65C02P2 (main)
705    - 1x MC68B45P (CRT controller)
706    - 2x MC68B21CP (Peripheral Interface Adapter)
707    - 1x oscillator 16.000 MHz
708    - 3x ROMs TMS 27C512
709    - 1x PALCE16V8H
710    - 1x prom AM27S29APC
711
712    - 1x 28x2 connector (maybe NOT jamma)
713    - 1x 10x2 connector
714    - 1x 3 legs connector (solder side)
715    - 1x 8 DIP Switches
716    - 1x trimmer (volume)
717
718
719
720    Royal Card (set 3, encrypted)
721    -----------------------------
722
723    - Custom/encrypted CPU (epoxy block labelled "EVONA EX9511" -> www.evona.sk )
724        inserted into socked with "6502" mark.
725
726    - 1x YM2149
727
728    - 1x HD6845 (CRT controller)
729    - 1x MC68A21P (PIA)
730    - 1x 40 pin IC with surface scratched (PIA)
731    - 1x 8 DIP Switches
732    - Sanyo LC3517B SRAM (videoram ?)
733    - 6264 battery backed SRAM (battery is dead)
734    - 1x PALCE16V8
735    - 1x GAL16V8B
736    - 1x PEEL18CV8P x2
737    - 1x 82S147 PROM (near Yamaha and unknown 40pin) - "82s147.bin"
738    - 1x 27256 close to CPU module - "1.bin"
739    - 2x 27256 - gfx - "2.bin", "3.bin"
740
741
742
743    Mongolfier New
744    --------------
745
746    - 1x G65SC02P2 (main)
747    - 1x KC89C72 (sound)
748    - 1x TDA2003 (sound)
749    - 1x MC68B45P (CRT controller)
750    - 2x EF6821P (Peripheral Interface Adapter)
751    - 1x TSC87C52-16CB (PLCC44)(Programmable 8bit Microcontroller, now dumped)
752    - 1x M48Z08-100PC1 (Zero Power RAM - Lithium Battery)
753    - 1x oscillator 16.0000 MHz
754
755    - 3x M27C512
756    - 1x PROM AM27S29PC
757    - 1x PALCE16V8H (read protected)
758
759    - 1x JAMMA edge connector
760    - 1x trimmer (volume)
761    - 2x 8 DIP switches
762    - 1x 4 DIP switches
763    - 1x green led
764
765
766
767    Soccer New (italian)
768    --------------------
769
770    - 1x G65SC02P2 (main)
771    - 1x KC89C72 (sound)
772    - 1x TDA2003 (sound)
773    - 1x MC68B45P (CRT controller)
774    - 1x EF68B21P (Peripheral Interface Adapter)
775    - 1x EF6821P (Peripheral Interface Adapter)
776    - 1x TSC87C52-16CB (PLCC44)(Programmable 8bit Microcontroller, now dumped)
777    - 1x M48Z08-100PC1 (Zero Power RAM - Lithium Battery)
778    - 1x oscillator 16.0000MHz
779
780    - 3x M27C512
781    - 1x PROM AM27S29PC
782    - 1x PALCE16V8H (read protected)
783
784    - 1x JAMMA edge connector
785    - 1x trimmer (volume)
786    - 2x 8 DIP switches
787    - 1x 4 DIP switches
788    - 1x green led
789
790
791
792    Saloon (France, encrypted)
793    --------------------------
794
795    - 1x 65SC02 (main)
796    - 1x 8948? (sound)
797    - 1x MC6845P (CRT controller)
798    - 1x oscillator 16.000000 MHz
799
800    - 2x M27C512
801    - 1x M27C256B
802    - 1x PROM N82S147N
803    - 1x GAL16V8-25LNC (read protected)
804    - 1x GAL18CV8-25 (read protected)
805
806    - 1x HY6264ALP-12
807    - 1x UM6116K-3L
808
809    - 1x JAMMA edge connector
810    - 1x trimmer (volume?)
811    - 1x LM380N (amplifier)
812    - 1x ULN2803A (8 Darlington arrays)
813    - 1x battery
814    - 1x test button
815    - 1x indicator LED
816    - NO DIP switches
817
818    Board has printed "LEOPARDO 5"
819
820
821
822***********************************************************************************
823
824
825    *** Driver Updates by Roberto Fresca ***
826
827
828    [2005/09/08]
829    - Added Cuore Uno, Elephant Family and Royal Card.
830
831    [2005/09/19]
832    - Added some clones.
833    - Cleaned up and renamed all sets. Made parent-clone relationship.
834
835    [2005/12/15]
836    - Corrected CPU freq (2 MHz) in cuoreuno and elephfam (both have R65c02P2).
837      (I suspect more games must have their CPU running at 2 MHz).
838    - Corrected videoram and colorram offsets in cuoreuno and elephfam.
839    - To initialize the NVRAM in cuoreuno and elephfam:
840      Start game, press and hold Service1 & Service2, press reset (F3),
841      release Service1 & Service2 and press reset (F3) again.
842
843    [2006/10/18]
844    - Corrected the screen size and visible area to cuoreuno and elephfam based on mc6845 registers.
845    - Added all inputs to cuoreuno and elephfam.
846    - Added test mode DIP switch to cuoreuno and elephfam.
847    - Managed cuoreuno and elephfam inputs to pass the initial checks. Now both games are playable.
848    - Changed the cuoreuno full name to "Cuore 1" (as shown in the attract).
849
850    [2006/10/22-28]
851    - Corrected cuoreuno and elephfam graphics to 4bpp.
852    - Fixed elephfam gfx planes.
853    - Simulated cuoreuno palette based on screenshots.
854    - Simulated elephfam palette based on screenshots.
855
856
857    [2006/11/01 to 2006/12/04]
858
859    ******** REWRITE ********
860
861    - Merged/splitted some machine drivers, memory maps and inputs.
862    - Unified get_bg_tile_info for all games.
863    - Mapped the input buttons in a better format (all games). Keys: 156-QW-ZXCVBNM.
864    - Added proper color PROM decode routines.
865    - Rewrote the technical notes.
866    - Splitted the driver to driver/video.
867
868    - Corrected the screen size and visible area to magiccrd based on mc6845 registers.
869    - Added the remaining 2 GFX planes to magiccrd, but GFX are imperfect (bad decode or bad dump?). Color PROM need to be dumped.
870    - Royalcrd: Added all inputs and DIP switches.
871                Fixed memory map, gfx decode
872                Corrected screen size and visible area based on mc6845 registers.
873                Corrected CPU clock to 2mhz.
874
875    - New game added: Joker Poker. Not working due to use of custom encrypted CPU.
876    - New game added: Royal Card (Slovakia, encrypted). Not working due to use of a custom encrypted CPU.
877    - Fixed jolycdcr gfx to 4bpp.
878    - Other fixes to get jolycdcr running.
879    - Managed royalcdb to work, using the 2nd half of program ROM. (seems to be mapped that way)
880    - Managed jolycdit to work, but with imperfect graphics due to gfx encryption.
881    - Fixed CPU clock to 2MHz. in all remaining games.
882    - Fixed ay8910 frequency based on elephfam audio.
883    - Fixed ay8910 volume in all games to avoid clipping.
884    - Reworked jolycdcr inputs: The game was designed to work only with remote credits. After nvram init, set the payout dip to "manual".
885    - Reworked jolycdit inputs: After nvram init, set the payout dip to "manual" to allow work the remote mode.
886    - Set jolycdat as bigdeal clone. The game has the same layout/behaviour instead of the normal jolly card games, even when are sharing gfx roms.
887    - Added the bipolar PROM and GAL to jolycdit. Confirmed the GFX ROMs as good dumps.
888    - Added an alternate set of Elephant Family. This one lacks of test mode and doesn't allow to switch between min-max bets through stop1.
889    - Added color PROMs to cuoreuno and elephfam sets but still no routed. Also added PLDs (protected, bad dumps).
890    - Corrected jollycrd screen size and visible area based on mc6845 registers.
891    - Hooked, wired and decoded the color prom in jollycrd sets based on jolycdit redump. Now colors are perfect.
892    - Wired and decoded the color prom in cuoreuno and elephfam sets. Now colors are perfect.
893    - Wired and decoded the color prom in royalcrd. Now colors are perfect.
894    - Hooked, wired and decoded the color prom in bigdeal sets based on jolycdat (jollycrd palette).
895      Colors seems to be correct, but need to check against the real thing. Flagged as IMPERFECT_COLORS till a color PROM dump appear.
896    - Decrypted jolycdit gfx roms.
897    - Added set Jolly Card (Austria, encrypted).
898    - Decrypted jolycdae and managed the planes to show correct colors. The set is working properly.
899
900
901    [2006/12/24]
902    - Fixed some incomplete inputs.
903    - Added new working game: Pool 10.
904    - Added new working game: Tortuga Family.
905    - Added new game: Mongolfier New. Not working due to the lack of MCU emulation.
906    - Added new game: Soccer New. Not working due to the lack of MCU emulation.
907    - Updated technical notes.
908
909    [2007/02/01]
910    - All crystals documented via #defines.
911    - All CPU and sound clocks derived from #defined crystal values.
912    - Added DIPLOCATIONS to all games.
913    - Added a pool10 alternate set.
914    - Added proper tsc87c52 MCU dumps to monglfir and soccernew.
915    - Modified the refresh rate to 60 fps according to some video evidences.
916    - Updated technical notes.
917
918    [2007/02/25]
919    - Added new game: Snooker 10 (Ver 1.11). Preliminary.
920        Properly decoded GFX
921        Proper colors decoded.
922    - Updated technical notes.
923
924    [2007/09/21]
925    - Added new game: Saloon (France, encrypted). Preliminary.
926    - Updated technical notes.
927
928    [2008/02/10]
929    - Switched to XTAL def.
930    - Fixed Magic Card II graphics issues.
931    - Fixed Magic Card II inputs.
932    - Fixed screen and visible area to snooker10.
933    - Renamed set monglfir to mongolnw.
934    - Renamed sets description based on languages instead of countries.
935    - Added new game: Magic Card II (green TAB or Impera board). Not working yet.
936    - Added new game: Magic Card II (blue TAB board, encrypted). Not working yet.
937    - Added new game: Jolly Card (3x3 deal).
938    - Added new game: Jolly Card Professional 2.0 (with 'enter code' screen to boot).
939    - Added new game: Lucky Lady (3x3 deal).
940    - Added new game: Lucky Lady (4x1 aces).
941    - Added new game: Royal Vegas Joker Card (fast deal).
942    - Added new game: Royal Vegas Joker Card (slow deal).
943    - Fixed some years and manufacturers.
944    - Updated technical notes.
945    - Cleaned up the driver.
946
947    [2008/02/22]
948    - Switched the color decoding routines to use resnet code.
949    - Added complete color connections to/from 74ls373 to the source.
950
951    [2008/02/25]
952    - Added new game: Royal Vegas Joker Card (fast deal, english gfx).
953    - Added new game: Jolly Joker.
954    - Added new game: Jolly Joker (50bet).
955    - Added new game: Jolly Card (croatian, set 2).
956    - Added new game: Jolly Card (Evona Electronic)
957    - Added new game: Super Joly 2000 - 3x
958    - Fixed some inputs.
959    - Masked inputs to allow jolyjokra to boot.
960    - Added minor corrections.
961    - Updated technical notes.
962
963    [2008/03/14]
964    - Added proper inputs to jolyc980.
965    - Added temporary patch to allow bypass the "code" screen in jolyc980.
966    - Updated technical notes.
967
968    [2008/03/18]
969    - Added new game: Pot Game (italian).
970    - Updated technical notes.
971
972    [2008/04/18]
973    - Removed the temporary hack to jolyc980.
974    - Updated technical notes regarding Magic Card II & Jolly Card Professional 2.0.
975    - Moved snookr10 to its own driver.
976    - Minor clean-up.
977
978    [2008/04/27]
979    - Fixed AY8910 volume to all games to avoid clips.
980    - Merge bigdeal and funworld machine drivers thanks to the AY8910 rewrite.
981    - Removed old unaccurate commentary about magiccrd tiles.
982
983    [2008/04/29]
984    All CMC italian games:
985    - Added TICKET and HOPPER buttons to allow payout through the SUPER GAME.
986    - Documented the featured SUPER GAME with complete instructions.
987    - Improved DIP switches to properly set the payout system.
988
989    [2008/05/13]
990    - Found the proper algorithm to decrypt the blue TAB PCB.
991    - Replaced the old decryption tables with the proper decryption scheme.
992    - Updated technical notes.
993
994    [2008/07/30]
995    - Added new clone: Pool 10 (italian, set 3).
996    - Updated technical notes.
997
998    [2008/09/12]
999    - Added new clone: Pool 10 (italian, set 4).
1000    - Improved lamps layout for all games.
1001    - Added Pool 10 pinout and DIP switches info.
1002    - Updated technical notes.
1003
1004    [2008/12/01]
1005    - Decripted saloon's program, graphics and color PROM.
1006    - Created a new memory map and machine driver for saloon.
1007    - Removed set jolycdae (it's not coming from a real board).
1008    - Renamed the sets magiccrd, magiccda and magiccdb, to magicrd2, magicd2a and magicd2b.
1009    - Updated technical notes.
1010
1011    [2008/12/15]
1012    - Added new set: Jolly Card (italian, encrypted bootleg).
1013      No coins... Only remote credits. After nvram init, set the Payout DIP to 'manual'
1014      to allow the remote credits mode to work.
1015    - Created inputs from the scratch for jolycdib.
1016    - Updated technical notes.
1017
1018    [2008-12-26]
1019    - Correctly setup the MC6845 device for all systems.
1020    - Added common MC6845 device interface.
1021    - Eliminated the screen size & visible area parameters to Magic Card 2.
1022
1023    [2009/01/23]
1024    - Added new sets: Bottle 10 (italian, set 1 & 2).
1025    - Updated technical notes.
1026
1027    [2009/09/09]
1028    - Discovered and documented new features in Jolly Card (Evona Electronics).
1029    - Removed the commented hack for joly980 driver init since is not needed anymore.
1030    - Fixed a bug introduced with the massive input change, that didn't allow initialize
1031      all sets that need the normal procedure to do it.
1032    - Updated technical notes.
1033
1034
1035    *** TO DO ***
1036
1037    - Figure out the royalcdc & jokercrd encryption.
1038    - Figure out the remaining PIA connections for almost all games.
1039    - Fix Saloon and move it to its own driver.
1040    - Fix the imperfect sound in Magic Card II.
1041    - Reverse-engineering the boot code of Jolly Card Professional 2.0,
1042      and Royal Card Professional 2.0 to get the proper codes to boot.
1043    - Analyze the unknown writes to $2000/$4000 in some games.
1044    - Check for the reads to the ay8910 output ports in some games.
1045    - Figure out the MCU in monglfir and soccernw.
1046    - Correct the ROM_REGION in some games to allow the use of RGN_FRAC
1047
1048
1049596***********************************************************************************/
1050597
1051598
r7500r7501
21461693   MDRV_CPU_PROGRAM_MAP(saloon_map)
21471694MACHINE_DRIVER_END
21481695
2149static const UINT8 jolyc980_default_eeprom[0x800] = {
2150   0x4C,0x17,0xAC,0x4C,0x3B,0xB6,0xAE,0x65,0x33,0x79,0x40,0x00,0x00,0x20,0x20,0x20,
2151   0x20,0x20,0x31,0x30,0x00,0x00,0x32,0x4D,0x64,0x30,0x00,0x00,0x00,0x00,0x00,0x00,
2152   0x00,0x00,0x00,0x00,0x60,0xE5,0x69,0x03,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
2153   0x00,0x00,0x00,0x00,0x00,0x00,0xD4,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
2154   0x01,0x60,0x05,0x02,0x02,0x02,0xEE,0x07,0x00,0x01,0x00,0x09,0x09,0x99,0x6C,0xD8,
2155   0xA2,0x5A,0x00,0x04,0x00,0x01,0x2A,0x06,0x31,0x12,0x3D,0x00,0x00,0x00,0x01,0x0F,
2156   0x00,0x6D,0x00,0x00,0x00,0x00,0xBE,0x99,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
2157   0xFE,0x04,0x04,0x04,0x40,0x02,0x15,0xB3,0x00,0x40,0x00,0x00,0x00,0x00,0xB8,0xFF,
2158   0x00,0x07,0x01,0x2A,0x38,0x18,0x03,0x3C,0x2C,0x24,0x35,0x0C,0x04,0x3F,0x06,0x31,
2159   0x12,0x3D,0x13,0x1A,0x23,0x11,0x21,0x24,0x1C,0x06,0x27,0xFF,0x00,0xFF,0x00,0xFF,
2160   0x00,0x00,0x01,0xFF,0x00,0xFF,0x00,0xF7,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x02,0x05,
2161   0x00,0x00,0x00,0xFF,0x00,0xFF,0x08,0xFF,0xE3,0x00,0x00,0xFF,0x00,0xFF,0x00,0xFF,
2162   0x40,0x6D,0xFF,0x00,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,0x00,0xFF,
2163   0x00,0xFF,0x00,0xFF,0xDD,0xFD,0x07,0x80,0x07,0x02,0x08,0x80,0x08,0x02,0x0A,0x00,
2164   0x00,0x00,0x07,0x80,0x02,0x00,0x3F,0x00,0xFF,0xFF,0x00,0xFF,0xF0,0xFF,0x00,0x04,
2165   0x00,0x00,0xF0,0xFF,0x00,0x00,0x50,0xFF,0x00,0x00,0x6C,0x0C,0x80,0xE8,0x02,0xFE,
2166   0x48,0x00,0xFE,0x00,0xFF,0x00,0xFE,0x00,0xFF,0x00,0xFE,0x00,0xFF,0x00,0xFE,0x00,
2167   0xFF,0x00,0xFE,0x00,0xFF,0x00,0xEE,0xEC,0x68,0xED,0x00,0x3D,0x9B,0x81,0xC2,0x00,
2168   0x40,0x00,0xC2,0x00,0xDF,0x00,0xC2,0x00,0xDF,0x00,0xC2,0x00,0xDF,0x00,0xC2,0x00,
2169   0xDF,0x00,0xC2,0x00,0xDF,0x00,0xC2,0x00,0xDF,0x00,0xC2,0x00,0xDF,0x00,0xC2,0x00,
2170   0x00,0x00,0xC2,0x00,0xDF,0x00,0xC2,0x00,0xDF,0x00,0xC2,0x00,0xDF,0x00,0xC2,0x00,
2171   0xDF,0x00,0xC2,0x00,0xDF,0x00,0xC2,0x00,0xDF,0x00,0xC2,0x00,0xDF,0x00,0xC2,0x00,
2172   0x00,0x00,0xC2,0x00,0xDF,0x00,0xC2,0x00,0xDF,0x00,0xC2,0x00,0xDF,0x00,0xC2,0x00,
2173   0xDF,0x00,0xC2,0x00,0xDF,0x00,0xC2,0x00,0xDF,0x00,0xC2,0x00,0xDF,0x00,0xC2,0x00,
2174   0x40,0x00,0xC2,0x00,0xDF,0x00,0xC2,0x00,0xDF,0x00,0xC2,0x00,0xDF,0x00,0xC2,0x00,
2175   0xDF,0x00,0xC2,0x00,0xDF,0x00,0xC2,0x00,0xDF,0x00,0xC2,0x00,0xDF,0x00,0xC2,0x00,
2176   0xDF,0x00,0xC2,0x00,0xDF,0x00,0xC2,0x00,0xFF,0x00,0xFE,0x00,0xFF,0x00,0xFE,0x00,
2177   0xFF,0x00,0xFE,0x00,0xFF,0x00,0xFE,0x00,0xFF,0x00,0xFE,0x00,0xFF,0x00,0xFE,0x00,
2178   0x40,0x00,0xFE,0x00,0xFF,0x00,0xFE,0x00,0xFF,0x00,0xFE,0x00,0xFF,0x00,0xFE,0x00,
2179   0xFF,0x00,0xFE,0x00,0xFF,0xEB,0xEB,0x60,0x60,0x60,0xB1,0x60,0xB1,0x60,0x60,0x60,
2180   0xB1,0x89,0xB1,0x0E,0xB0,0x31,0x20,0x20,0x20,0x20,0x20,0x00,0x40,0x79,0x60,0x67,
2181   0x82,0x00,0x04,0x77,0x20,0xD0,0x28,0xA0,0xC3,0x8F,0x4A,0xAB,0x75,0xAB,0xA9,0x86,
2182   0x00,0x00,0x00,0x01,0x98,0x05,0x05,0x00,0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
2183   0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x31,0x02,0x00,
2184   0x01,0x00,0x00,0x00,0x3F,0x06,0x31,0x12,0x3D,0x06,0x00,0x00,0x00,0x00,0x00,0xFF,
2185   0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
2186   0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
2187   0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
2188   0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
2189   0x01,0x01,0x00,0x02,0x00,0x03,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
2190   0x56,0x32,0x2E,0x30,0x20,0x05,0x04,0x00,0x00,0x03,0x05,0x08,0x02,0x02,0x00,0x00,
2191   0x00,0x01,0x29,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
2192   0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
2193   0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
2194   0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
2195   0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
2196   0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
2197   0x18,0x85,0x00,0x00,0x00,0x00,0x00,0x00,0xF8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
2198   0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
2199   0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
2200   0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
2201   0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
2202   0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
2203   0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
2204   0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
2205   0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
2206   0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
2207   0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
2208   0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
2209   0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
2210   0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
2211   0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
2212   0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
2213   0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
2214   0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
2215   0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
2216   0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
2217   0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
2218   0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
2219   0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
2220   0x29,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
2221   0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
2222   0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
2223   0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
2224   0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
2225   0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
2226   0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
2227   0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
2228   0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
2229   0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
2230   0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
2231   0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
2232   0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
2233   0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
2234   0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
2235   0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
2236   0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
2237   0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
2238   0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
2239   0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
2240   0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
2241   0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
2242   0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
2243   0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
2244   0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
2245   0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
2246   0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
2247   0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
2248   0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
2249   0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
2250   0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
2251   0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
2252   0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
2253   0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
2254   0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
2255   0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
2256   0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
2257   0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
2258   0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
2259   0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
2260   0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
2261   0xF0,0x00,0x00,0x00,0x00,0x80,0x00,0x00,0xF0,0x00,0x00,0x00,0x7C,0x00,0x00,0x9F,
2262   0x91,0x62,0x04,0x00,0x00,0x00,0x05,0x15,0x09,0x00,0x00,0x00,0x31,0x85,0x03,0x00,
2263   0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
2264   0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
2265   0x00,0x00,0x00,0x91,0x62,0x04,0x00,0x00,0x00,0x05,0x15,0x09,0x00,0x00,0x00,0x31,
2266   0x85,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
2267   0x20,0x20,0x20,0x20,0x20,0x20,0x20,0xFF,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
2268   0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
2269   0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
2270   0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
2271   0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
2272   0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
2273   0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
2274   0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
2275   0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
2276   0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x9D,
2277   0x1C,0x80,0xF0,0x02,0x00,0x00,0x00,0x80,0x60,0xEB,0x00,0xF7,0x40,0xFF,0x00,0x21
2278};
22791696
1697
1698/*************************
1699*        Rom Load        *
1700*************************/
1701
22801702/*
2281Load a default eeprom, otherwise an annoying password system should be inserted with
2282inputs correlated to a code that pops up on the screen.
2283This code should be inserted into a PC-DOS program, that program is nowhere to be found right now.
2284*/
2285static NVRAM_HANDLER( jolyc980 )
2286{
2287   if (read_or_write)
2288      mame_fwrite(file, machine->generic.nvram.v, machine->generic.nvram_size);
2289   else if (file)
2290      mame_fread(file, machine->generic.nvram.v, machine->generic.nvram_size);
2291   else
2292   {
2293      int i;
2294      for(i=0;i<machine->generic.nvram_size;i++)
2295         machine->generic.nvram.u8[i] = jolyc980_default_eeprom[i];
2296   }
2297}
1703    Jolly Card, TAB Austria
1704    -----------------------
22981705
2299static MACHINE_DRIVER_START( jolyc980 )
2300   MDRV_IMPORT_FROM(cuoreuno)
1706    Pinouts:
23011707
2302   MDRV_NVRAM_HANDLER( jolyc980 )
2303MACHINE_DRIVER_END
1708    X1-01   GND                     X1-A    GND
1709    X1-02   GND                     X1-B    GND
1710    X1-03   GND                     X1-C    GND
1711    X1-04   +5V                     X1-D    +5V
1712    X1-05   +12V                    X1-E    +12V
1713    X1-06   NC                      X1-F    NC
1714    X1-07   NC                      X1-G    NC
1715    X1-08   NC                      X1-H    NC
1716    X1-09   NC                      X1-I    Coin 1
1717    X1-10   Coin 2                  X1-J    Pay Out SW
1718    X1-11   Hold 3                  X1-K    NC
1719    X1-12   NC                      X1-L    GND
1720    X1-13   Hold 4                  X1-M    Remote
1721    X1-14   Bookkeeping SW          X1-N    GND
1722    X1-15   Hold 2                  X1-O    Cancel
1723    X1-16   Hold 1                  X1-P    Hold 5
1724    X1-17   Start                   X1-Q
1725    X1-18   Hopper Out              X1-R
1726    X1-19   Red                     X1-S    Green
1727    X1-20   Blue                    X1-T    Sync
1728    X1-21   GND                     X1-U    Speaker GND
1729    X1-22   Speaker +               X1-V    Management SW
23041730
1731    X2-01   GND                     X2-A    GND
1732    X2-02   NC                      X2-B    NC
1733    X2-03   Start                   X2-C    NC
1734    X2-04   NC                      X2-D    NC
1735    X2-05   NC                      X2-E    NC
1736    X2-06   Lamp Start              X2-F    Lamp Hold 1+3
1737    X2-07   Lamp Hold 2             X2-G    Lamp Hold 4
1738    X2-08   Lamp Hold 5             X2-H    Lamp Cancel
1739    X2-09   NC                      X2-I    NC
1740    X2-10   Counter In              X2-J    Counter Out
1741    X2-11   Hopper Count            X2-K    Hopper Drive
1742    X2-12   Counter Remote          X2-L
1743    X2-13                           X2-M
1744    X2-14                           X2-N
1745    X2-15   NC                      X2-O
1746    X2-16                           X2-P
1747    X2-17                           X2-Q    Coin Counter
1748    X2-18                           X2-R
23051749
2306/*************************
2307*        Rom Load        *
2308*************************/
1750    ---------------------------------------------------
23091751
1752    DIP Switches:
1753
1754        ON                  OFF
1755
1756    1   Hopper              Manual Payout SW    :Payout
1757    2   Auto Hold           No Auto Hold        :Hold
1758    3   Joker               Without Joker       :Joker
1759    4   Dattl Insert        TAB Insert          :Inserts
1760    5   5 Points/Coin       10 Points/Coin      :Coin 1
1761    6   5 Points/Coin       10 Points/Coin      :Coin 2
1762    7   10 Points/Pulse     100 Points/Pulse    :Remote
1763    8   Play                Keyboard Test       :Mode
1764
1765    ---------------------------------------------------
1766*/
1767
23101768ROM_START( jollycrd )
23111769   ROM_REGION( 0x10000, "maincpu", 0 )
23121770   ROM_LOAD( "jolycard.run", 0x8000, 0x8000, CRC(f531dd10) SHA1(969191fbfeff4349afef619d9241ef5186e6d57f) )
r7500r7501
23191777   ROM_LOAD( "82s147.bin",   0x0000, 0x0200, CRC(5ebc5659) SHA1(8d59011a181399682ab6e8ed14f83101e9bfa0c6) )
23201778ROM_END
23211779
1780
23221781ROM_START( jolycdae )   /* encrypted roms...*/
23231782   ROM_REGION( 0x18000, "maincpu", 0 )
23241783   ROM_LOAD( "pokeru0.bin", 0x8000, 0x10000, CRC(7732f177) SHA1(b75fca596a7315d1379fa5bcf07c449ec32c90f5) )
r7500r7501
23321791   ROM_LOAD( "82s147.bin",   0x0000, 0x0200, CRC(5ebc5659) SHA1(8d59011a181399682ab6e8ed14f83101e9bfa0c6) )
23331792ROM_END
23341793
1794
23351795ROM_START( jolyc3x3 )
23361796   ROM_REGION( 0x10000, "maincpu", 0 )
23371797   ROM_LOAD( "jc3x3.bin", 0x8000, 0x8000, CRC(71e304ad) SHA1(238b792d841432582c94b21a674d46a95e8f3826) )
r7500r7501
23441804   ROM_LOAD( "82s147.bin",   0x0000, 0x0200, CRC(5ebc5659) SHA1(8d59011a181399682ab6e8ed14f83101e9bfa0c6) )
23451805ROM_END
23461806
1807
1808/*
1809    Jolly Card Professional 2.0
1810
1811    Special version with maximum bet up to 98 credits.
1812    This game has an annoying password system through a DOS program.
1813*/
1814
23471815ROM_START( jolyc980 )
23481816   ROM_REGION( 0x10000, "maincpu", 0 )
23491817   ROM_LOAD( "j980.bin", 0x8000, 0x8000, CRC(48249fff) SHA1(390cd0eb3399446a66363dc6760458170e1970fd) )
r7500r7501
23521820   ROM_LOAD( "jolycard.ch2", 0x0000, 0x8000, CRC(c512b103) SHA1(1f4e78e97855afaf0332fb75e1b5571aafd01c29) )
23531821   ROM_LOAD( "jolycard.ch1", 0x8000, 0x8000, CRC(0f24f39d) SHA1(ac1f6a8a4a2a37cbc0d45c15187b33c25371bffb) )
23541822
1823/*  Load a default eeprom, otherwise an annoying password system should be inserted with
1824    inputs correlated to a code that pops up on the screen.
1825    This code should be inserted into a PC-DOS program, that program is nowhere to be found right now.
1826*/
1827   ROM_REGION( 0x0800,   "nvram", 0 )
1828   ROM_LOAD( "jolyc980_nv.bin",  0x0000, 0x0800, CRC(c917f071) SHA1(fdcd974d3acd4acf2e0ff5fca820cfc65fe18867) )   /* default NVRAM */
1829
23551830   ROM_REGION( 0x0200, "proms", 0 )
23561831   ROM_LOAD( "82s147.bin",   0x0000, 0x0200, CRC(5ebc5659) SHA1(8d59011a181399682ab6e8ed14f83101e9bfa0c6) )
23571832ROM_END
23581833
1834
23591835ROM_START( jolycdev )   /* Jolly Card (lipa) from Evona */
23601836   ROM_REGION( 0x10000, "maincpu", 0 )
23611837   ROM_LOAD( "lipa.bin", 0x8000, 0x8000, CRC(62657c98) SHA1(237466dde26540c119c631c75f51c87ea59d1a91) )
r7500r7501
23711847   ROM_LOAD( "gal16v8uni.bin", 0x0000, 0x0117, CRC(b81d7e0a) SHA1(7fef0b2bcea931a830d38ae0f1102434cf281d2d) )
23721848ROM_END
23731849
1850
1851/*
1852    Jolly Card (other)
1853    ------------------
1854
1855    - 1x G65SC02P (CPU)
1856    - 1x MC68B45P (CRTC)
1857    - 1x AY3-8910 (sound)
1858    - 2x MC6821P  (PIAs)
1859
1860    RAM:  - 1x NVram DS1220Y (instead of 6116)
1861          - 1x KM6264AL-10
1862
1863    - 1x Crystal : 16.000 MHz
1864*/
1865
23741866ROM_START( jolyccra )   /* Jolly Card (croatian, set 1) */
23751867   ROM_REGION( 0x10000, "maincpu", 0 )
23761868   ROM_LOAD( "jollyc.bin", 0x8000, 0x8000, CRC(8926d99d) SHA1(dd5d1ac03d30d823dfcfe1349328ecb7afbc37fa) )
r7500r7501
23831875   ROM_LOAD( "82s147.bin",   0x0000, 0x0200, CRC(5ebc5659) SHA1(8d59011a181399682ab6e8ed14f83101e9bfa0c6) )
23841876ROM_END
23851877
1878
23861879ROM_START( jolyccrb )   /* Jolly Card (croatian, set 2) */
23871880   ROM_REGION( 0x10000, "maincpu", 0 )
23881881   ROM_LOAD( "jollypkr.003", 0x8000, 0x8000, CRC(ea7340b4) SHA1(7dd468f28a488a4781521809d06db1d7917048ad) )
r7500r7501
23951888   ROM_LOAD( "82s147.bin",   0x0000, 0x0200, CRC(5ebc5659) SHA1(8d59011a181399682ab6e8ed14f83101e9bfa0c6) )
23961889ROM_END
23971890
1891
1892/*
1893    Jolly Card (italian, blue Tab board, encrypted)
1894    -----------------------------------------------
1895
1896    - 1x HY6264LP
1897    - 1x MC6845P
1898    - 1x HM6116LP
1899    - 1x G65SC02 (main)
1900    - 1x AY-3-8910 (sound)
1901    - 1x MC6821P
1902    - 1x oscillator 16.000 MHz
1903    - ROMs  2x TMS27c256 (1,2)
1904            1x M5M27256 (jn)
1905    - 1x prom N82S147
1906    - 1x GAL16V8B
1907    - 2x HY18CV85 (electrically-erasable PLD)
1908    - 1x 8 DIP switches
1909    - 1x 22x2 edge connector
1910    - 1x 18x2 edge connector
1911    - 1x trimmer (volume)(missing)
1912*/
1913
23981914ROM_START( jolycdit )   /* blue TAB PCB, encrypted graphics */
23991915   ROM_REGION( 0x10000, "maincpu", 0 )
24001916   ROM_LOAD( "jn.bin", 0x8000, 0x8000, CRC(6ae00ed0) SHA1(5921c2882aeb5eadd0e04a477fa505ad35e9d98c) )
r7500r7501
24101926   ROM_LOAD( "gal16v8b.bin", 0x0000, 0x0117, CRC(3ad712b1) SHA1(54214841fb178e4b59bf6051522718f7667bad28) )
24111927ROM_END
24121928
2413/* jolycdit vs jolycdib:
24141929
24151.BIN                   1.BIN                   IDENTICAL
24162.BIN                   2.bin                   IDENTICAL
2417jn.BIN                  3.BIN                   97.726440%
1930/*
1931    Jolly Card (italian encrypted bootleg)
1932    --------------------------------------
24181933
2419jolycdib program seems to be the original for blue TAB PCB.
2420jolycdit has some code patches and redirected parts to suspicious offsets (as d500, d000, etc)
1934    - 1x UM6845P
1935    - 1x R65C02P3 (main CPU)
1936    - 1x AY-3-8910 (sound)
1937    - 2x MC68B21P
1938    - 1x oscillator 16.000 MHz
1939    - ROMs  3x 27256.
1940    - 1x PROM M1-7649-5 (not dumped)
1941    - 2x PLD HY18CV8S (not dumped)
1942    - 1x PAL16L8ACN (not dumped)
1943    - 1x 22x2 edge connector
1944    - 1x 18x2 edge connector
1945    - 1x trimmer (volume)
1946    - 1x 8x2 DIP switches.
1947
1948    jolycdit vs jolycdib:
1949
1950    1.BIN                   1.BIN                   IDENTICAL
1951    2.BIN                   2.bin                   IDENTICAL
1952    jn.BIN                  3.BIN                   97.726440%
1953
1954    jolycdib program seems to be the original for blue TAB PCB.
1955    jolycdit has some code patches and redirected parts to suspicious offsets (as d500, d000, etc)
24211956*/
1957
24221958ROM_START( jolycdib )   /* bootleg PCB, encrypted graphics */
24231959   ROM_REGION( 0x10000, "maincpu", 0 )
24241960   ROM_LOAD( "3.bin", 0x8000, 0x8000, CRC(c76fdc79) SHA1(fc75c274d64fa9c99a546d424f38e79f1acf2576) )
r7500r7501
24341970   ROM_LOAD( "gal16v8b.bin", 0x0000, 0x0117, CRC(3ad712b1) SHA1(54214841fb178e4b59bf6051522718f7667bad28) )
24351971ROM_END
24361972
1973
24371974ROM_START( sjcd2kx3 )   /* Super Joly 2000 3x */
24381975   ROM_REGION( 0x10000, "maincpu", 0 )
24391976   ROM_LOAD( "sj3.bin", 0x8000, 0x8000, CRC(c530b518) SHA1(36934d8e1e2cb2f71eb44a05b86ec970c9f398cd) )
r7500r7501
24491986   ROM_LOAD( "gal16v8uni.bin", 0x0000, 0x0117, CRC(b81d7e0a) SHA1(7fef0b2bcea931a830d38ae0f1102434cf281d2d) )
24501987ROM_END
24511988
1989
24521990ROM_START( jolycdab )
24531991   ROM_REGION( 0x10000, "maincpu", 0 )   /* program is testing/writting RAM in offset $8800-$BFFF (ROM)...?? */
24541992   ROM_LOAD( "ig1poker.run", 0x8000, 0x8000, CRC(c96e6542) SHA1(ed6c0cf9fe8597dba9149b2225320d8d9c39219a) )
r7500r7501
24622000   ROM_LOAD( "82s147.bin",   0x0000, 0x0200, CRC(5ebc5659) SHA1(8d59011a181399682ab6e8ed14f83101e9bfa0c6) )
24632001ROM_END
24642002
2003
2004/*
2005    Big Deal (hungarian)
2006    ------------------
2007
2008    - 1x MC6845P
2009    - 1x YM2149F
2010    - 2x MC6821P
2011    - 1x Crystal 16.000 MHz
2012*/
2013
24652014ROM_START( bigdeal )
24662015   ROM_REGION( 0x10000, "maincpu", 0 )
24672016   ROM_LOAD( "poker4.001", 0x8000, 0x8000, CRC(bb0198c1) SHA1(6e7d42beb5723a4368ae3788f83b448f86e5653d) )
r7500r7501
24742023   ROM_LOAD( "82s147.bin",   0x0000, 0x0200, CRC(5ebc5659) SHA1(8d59011a181399682ab6e8ed14f83101e9bfa0c6) )
24752024ROM_END
24762025
2026
24772027ROM_START( bigdealb )
24782028   ROM_REGION( 0x10000, "maincpu", 0 )
24792029   ROM_LOAD( "poker8.003", 0x8000, 0x8000, CRC(09c93745) SHA1(a64e96ef3489bc37c2c642f49e62cfef371de6f1) )
r7500r7501
24862036   ROM_LOAD( "82s147.bin",   0x0000, 0x0200, CRC(5ebc5659) SHA1(8d59011a181399682ab6e8ed14f83101e9bfa0c6) )
24872037ROM_END
24882038
2039
2040/*
2041    Jolly Card (austrian, Funworld, bootleg)
2042    ----------------------------------------
2043
2044    - 1x G65SC02P (CPU)
2045    - 1x MC68B45P (CRTC)
2046    - 1x AY3-8910 (sound)
2047    - 2x MC6821P  (PIAs)
2048
2049    RAM:  - 1x 6116
2050          - 1x KM6264AL-10
2051
2052    - 1x Crystal : 16.000 MHz
2053*/
2054
24892055ROM_START( jolycdat )   /* there are unused pieces of code that compare or jumps within $4000-$5000 range */
24902056   ROM_REGION( 0x10000, "maincpu", 0 )
24912057   ROM_LOAD( "bonucard.cpu", 0x8000, 0x4000, CRC(da342100) SHA1(451fa6074aad19e9efd148c3d18115a20a3d344a) )
r7500r7501
24992065   ROM_LOAD( "82s147.bin",   0x0000, 0x0200, CRC(5ebc5659) SHA1(8d59011a181399682ab6e8ed14f83101e9bfa0c6) )
25002066ROM_END
25012067
2068
2069/*
2070    Cuore Uno (italian)
2071    -----------------------------------
2072
2073    - CPU 1x G65SC02P
2074    - 1x MC68B45P (CRT controller)
2075    - 2x MC68B21CP (Peripheral Interface Adapter)
2076    - 1x unknown (95101) DIP40 mil600
2077    - 1x oscillator 16.000000 MHz
2078    - ROMs  1x TMS27C512
2079            2x TMS27C256
2080    - 1x PROM AM27S29
2081    - 2x PALCE20V8H
2082    - 1x PALCE16V8H (soldered)
2083    - Note 1x JAMMA edge connector (keep -5 disconnected)
2084    - 1x trimmer (volume)
2085    - 1x 8 DIP switches
2086    - 1x battery
2087*/
2088
25022089ROM_START( cuoreuno )
25032090   ROM_REGION( 0x10000, "maincpu", 0 )
25042091   ROM_LOAD( "cuore1a.u2", 0x8000, 0x8000, CRC(6e112184) SHA1(283ac534fc1cb33d11bbdf3447630333f2fc957f) )
r7500r7501
25162103   ROM_LOAD( "palce20v8h_cu.u23", 0x0400, 0x0157, NO_DUMP ) /* PAL is read protected */
25172104ROM_END
25182105
2106
2107/*
2108    Elephant Family (italian, old)
2109    -----------------------------
2110
2111    - CPU 1x R65C02P2
2112    - 1x MC68B45P (CRT controller)
2113    - 2x EF6821P (Peripheral Interface Adapter)
2114    - 1x unknown (95101) DIP40 mil600
2115    - 1x oscillator 16.000 MHz
2116    - ROMs  2x M27C256
2117            1x TMS27C256
2118    - 1x PROM AM27S29
2119    - 2x PALCE20V8H (read protected)
2120    - 1x PALCE16V8H (read protected)
2121    - Note 1x JAMMA edge connector (keep -5 disconnected)
2122    - 1x trimmer (volume)
2123    - 1x 8 DIP switches
2124    - 1x battery
2125*/
2126
25192127ROM_START( elephfam )
25202128   ROM_REGION( 0x18000, "maincpu", 0 )
25212129   ROM_LOAD( "eleph_a.u2", 0x8000, 0x10000, CRC(8392b842) SHA1(74c850c734ca8174167b2f826b9b1ac902669392) )
r7500r7501
25342142   ROM_LOAD( "palce20v8h_ef.u23", 0x0400, 0x0157, NO_DUMP ) /* PAL is read protected */
25352143ROM_END
25362144
2145
25372146ROM_START( elephfmb )
25382147   ROM_REGION( 0x10000, "maincpu", 0 )
25392148   ROM_LOAD( "now.u2", 0x8000, 0x8000, CRC(7b537ce6) SHA1(b221d08c53b9e14178335632420e78070b9cfb27) )
r7500r7501
25512160   ROM_LOAD( "palce20v8h_ef.u23", 0x0400, 0x0157, NO_DUMP ) /* PAL is read protected */
25522161ROM_END
25532162
2163
2164/*
2165    Pool 10 (italian)
2166    -----------------
2167
2168    - 1x R65C02P2 (main)
2169    - 1x YM2149F (sound)
2170    - 1x HD46505 (CRT controller)
2171    - 2x EF6821P (Peripheral Interface Adapter)
2172    - 1x oscillator 16.000000 MHz
2173
2174    - 2x M27256 (pool,1)
2175    - 1x D27256 (2)
2176    - 1x PROM N82S147AN
2177    - 2x GAL20V8B (read protected)
2178    - 1x PALCE16V8H (read protected)
2179
2180    - 1x JAMMA edge connector
2181    - 1x trimmer (volume)
2182    - 1x 8 DIP switches
2183    - 1x battery
2184
2185
2186    Connector, DIPs and instructions,
2187    copied from an original sheet...
2188
2189              Components |  | solder
2190    ---------------------|--|-----------------
2191                     gnd |01| gnd
2192                     gnd |02| gnd
2193                      +5 |03| +5
2194                      +5 |04| +5
2195                         |06|
2196                     +12 |07| +5
2197                         |08| contatore out
2198            motor hopper |09| contatore in
2199                   audio |10| audio
2200               sw hopper |11| gnd
2201                   rosso |12| verde
2202                     blu |13| sync
2203                     gnd |14| statistic
2204              manegement |15|
2205                  coin 1 |16| coin 2
2206               sw ticket |17| motor ticket
2207                  hold 3 |18| lamp hold 3
2208                  hold 4 |19| lamp hold 4
2209                  hold 2 |20| lamp hold 2
2210                  hold 1 |21| lamp hold 1
2211                  hold 5 |22| lamp hold 5
2212                   start |23| lamp hold start
2213                  cancel |24| lamp hold cancel
2214                      nc |25| +5 lamp
2215    ric. ticket + hopper |26| +12 lamp
2216                     gnd |27| gnd
2217                     gnd |28| gnd
2218
2219
2220    DIPS
2221                          1    2   3   4   5   6   7   8
2222                         on
2223                         off
2224    ticket + hopper           on  on
2225    hopper                    on  off
2226    ticket                    off on
2227    no ticket - no hopper     off off
2228    1 coin 1 credit                   off off
2229    1 coin 5 credits                  off on
2230    1 coin 10 credits                 on  off
2231    1 coin 50 credits                 on  on
2232    five of kind yes                          off
2233    five of kind no                           on
2234    royal flush yes                               off
2235    royal flush no                                on
2236    in test                                           on
2237    in game                                           off
2238
2239
2240    Instructions:
2241
2242    STATISTICS = show in and out credits
2243    MANEGEMENT = It's the general statistic. It shows in and out credits.
2244
2245    To cancel statistics press CANCEL for 5 seconds.
2246    To change max and min value for play connect to GND the manegement pin,
2247    at the same time press toghether HOLD 2 + HOLD 4 for some seconds.
2248
2249    The following menu will show up:
2250
2251    HOLD 1 = modify max value for play 1 to 10.
2252    HOLD 2 = modify min value foe play 1 to 5.
2253    Press start to exit from programming mode.
2254
2255    To unlock PCB from a possible lock:
2256    connect GND to pins component15 and solder14 for 5 seconds
2257
2258    NB. Use lamps by 12V 0,15W
2259    Memory version: V16
2260*/
2261
25542262ROM_START( pool10 )
25552263   ROM_REGION( 0x10000, "maincpu", 0 )
25562264   ROM_LOAD( "pool10.u2", 0x8000, 0x8000, CRC(4e928756) SHA1(d9ac3d41ea32e060a7e269502b7f22333c5e6c61) )
r7500r7501
25682276   ROM_LOAD( "gal20v8b_p10.u23",  0x0400, 0x0157, NO_DUMP ) /* GAL is read protected */
25692277ROM_END
25702278
2279
25712280ROM_START( pool10b )   /* this set should be the parent */
25722281   ROM_REGION( 0x18000, "maincpu", 0 )
25732282   ROM_LOAD( "u2.bin", 0x8000, 0x10000, CRC(64fee38e) SHA1(8a624a0b6eb4a3ba09e5b396dc5a01994dfdf294) )
r7500r7501
25872296   ROM_LOAD( "palce20v8h_p10b.u23", 0x0400, 0x0157, NO_DUMP ) /* PAL is read protected */
25882297ROM_END
25892298
2299
25902300ROM_START( pool10c )
25912301   ROM_REGION( 0x10000, "maincpu", 0 )
25922302   ROM_LOAD( "a.u2", 0x8000, 0x8000, CRC(ac157b17) SHA1(f2b7eb940273bc404d3e0d8dd0f00ca757cebf69) )
r7500r7501
26042314   ROM_LOAD( "gal20v8b_p10.u23",  0x0400, 0x0157, NO_DUMP ) /* GAL is read protected */
26052315ROM_END
26062316
2317
26072318ROM_START( pool10d )
26082319   ROM_REGION( 0x18000, "maincpu", 0 )
26092320   ROM_LOAD( "3.50.u2", 0x8000, 0x10000, CRC(4c68e1f4) SHA1(bbab63a18e0c041ce519daa32e12dd1b6a672dce) )
r7500r7501
26212332   ROM_LOAD( "gal20v8b_p10.u23",  0x0400, 0x0157, NO_DUMP ) /* GAL is read protected */
26222333ROM_END
26232334
2335
2336/*
2337    Tortuga Family (italian) & Pot Game (italian)
2338    ---------------------------------------------
2339
2340    - 1x G65SC02P2 (main)
2341    - 1x 95101 (sound)
2342    - 1x MC68B45P (CRT controller)
2343    - 2x MC68B21CP (Peripheral Interface Adapter)
2344    - 1x oscillator 16.000000 MHz
2345
2346    - 3x TMS27C256
2347    - 1x PROM AM27S29PC
2348    - 2x PALCE20V8H (read protected)
2349    - 1x PALCE16V8H (read protected)
2350
2351    - 1x JAMMA edge connector
2352    - 1x trimmer (volume)
2353    - 1x 8 DIP switches
2354    - 1x battery
2355*/
2356
26242357ROM_START( tortufam )
26252358   ROM_REGION( 0x10000, "maincpu", 0 )
26262359   ROM_LOAD( "tortu.a.u2", 0x8000, 0x8000, CRC(6e112184) SHA1(283ac534fc1cb33d11bbdf3447630333f2fc957f) )
r7500r7501
26382371   ROM_LOAD( "palce20v8h_tf.u23", 0x0400, 0x0157, NO_DUMP ) /* PAL is read protected */
26392372ROM_END
26402373
2374
26412375ROM_START( potgame )
26422376   ROM_REGION( 0x10000, "maincpu", 0 )
26432377   ROM_LOAD( "now.u2", 0x8000, 0x8000, CRC(7b537ce6) SHA1(b221d08c53b9e14178335632420e78070b9cfb27) )
r7500r7501
26552389   ROM_LOAD( "palce20v8h_pot.u23", 0x0400, 0x0157, NO_DUMP ) /* PAL is read protected */
26562390ROM_END
26572391
2392
26582393ROM_START( bottle10 )
26592394   ROM_REGION( 0x10000, "maincpu", 0 )
26602395   ROM_LOAD( "boat_3.bin", 0x8000, 0x8000, CRC(e2db8334) SHA1(22ac4ce361a93b7e6d491e260635755dd562b294) )
r7500r7501
26722407   ROM_LOAD( "gal20v8b_p10.u23",  0x0400, 0x0157, NO_DUMP ) /* GAL is read protected */
26732408ROM_END
26742409
2410
26752411ROM_START( bottl10b )
26762412   ROM_REGION( 0x10000, "maincpu", 0 )
26772413   ROM_LOAD( "3.u2", 0x8000, 0x8000, CRC(e2db8334) SHA1(22ac4ce361a93b7e6d491e260635755dd562b294) )
r7500r7501
26892425   ROM_LOAD( "gal20v8b_p10.u23",  0x0400, 0x0157, NO_DUMP ) /* GAL is read protected */
26902426ROM_END
26912427
2428
2429/*
2430    Royal Card (set 1)
2431    ------------------
2432
2433    - 1x HM6264LP
2434    - 1x HD4650SP
2435    - 1x HM6116LP
2436    - 1x R65C02P2 (main)
2437    - 1x WB5300 (labeled YM8910)(sound)
2438    - 1x EF6821P
2439    - 1x oscillator 16.000 MHz
2440
2441    - 1x D27256 (1)
2442    - 1x S27C256 (2)
2443    - 1x TMS27C256 (r2)
2444    - 2x PEEL18CV8 (1 protected)
2445    - 1x PALCE16V8H (protected)
2446    - 1x PROM N82S147AN
2447
2448    - 1x 8 DIP Switches
2449    - 1x 22x2 edge connector
2450    - 1x 18x2 edge connector
2451    - 1x trimmer (volume)
2452*/
2453
26922454ROM_START( royalcrd )
26932455   ROM_REGION( 0x10000, "maincpu", 0 )
26942456   ROM_LOAD( "r2.bin", 0x8000, 0x8000, CRC(25dfe0dc) SHA1(1a857a910d0c34b6b5bfc2b6ea2e08ed8ed0cae0) )
r7500r7501
27062468   ROM_LOAD( "2-peel18cv8.bin",   0x0400, 0x0155, CRC(8fdafd55) SHA1(fbb187ba682111648ea1586f400990cb81a3077a) )
27072469ROM_END
27082470
2471
2472/*
2473    Royal Card (set 2)
2474    ------------------
2475
2476    - CPU 1x R65C02P2 (main)
2477    - 1x MC68B45P (CRT controller)
2478    - 2x MC68B21CP (Peripheral Interface Adapter)
2479    - 1x oscillator 16.000 MHz
2480    - 3x ROMs TMS 27C512
2481    - 1x PALCE16V8H
2482    - 1x prom AM27S29APC
2483
2484    - 1x 28x2 connector (maybe NOT jamma)
2485    - 1x 10x2 connector
2486    - 1x 3 legs connector (solder side)
2487    - 1x 8 DIP Switches
2488    - 1x trimmer (volume)
2489*/
2490
27092491ROM_START( royalcdb ) /* both halves have different programs. we're using the 2nd one */
27102492   ROM_REGION( 0x20000, "maincpu", 0 )   /* 1st half prg is testing RAM in offset $8600-$BF00...?? */
27112493   ROM_LOAD( "rc.bin", 0x10000, 0x10000, CRC(8a9a6dd6) SHA1(04c3f9f17d5404ac1414c51ef8f930df54530e72) )
r7500r7501
27232505   ROM_LOAD( "palce16v8h-4.bin",   0x0000, 0x0117, NO_DUMP ) /* PAL is read protected */
27242506ROM_END
27252507
2508
2509/*
2510    Royal Card (set 3, encrypted)
2511    -----------------------------
2512
2513    - Custom/encrypted CPU (epoxy block labelled "EVONA EX9511" -> www.evona.sk )
2514        inserted into socked with "6502" mark.
2515
2516    - 1x YM2149
2517
2518    - 1x HD6845 (CRT controller)
2519    - 1x MC68A21P (PIA)
2520    - 1x 40 pin IC with surface scratched (PIA)
2521    - 1x 8 DIP Switches
2522    - Sanyo LC3517B SRAM (videoram ?)
2523    - 6264 battery backed SRAM (battery is dead)
2524    - 1x PALCE16V8
2525    - 1x GAL16V8B
2526    - 1x PEEL18CV8P x2
2527    - 1x 82S147 PROM (near Yamaha and unknown 40pin) - "82s147.bin"
2528    - 1x 27256 close to CPU module - "1.bin"
2529    - 2x 27256 - gfx - "2.bin", "3.bin"
2530*/
2531
27262532ROM_START( royalcdc )   /* encrypted program rom */
27272533   ROM_REGION( 0x10000, "maincpu", 0 )
27282534   ROM_LOAD( "rc_1.bin", 0x8000, 0x8000, CRC(8cdcc978) SHA1(489b58760a7c8646399c8cdfb86ec4341823e7dd) )
r7500r7501
27402546   ROM_LOAD( "2-peel18cv8p.bin",   0x0400, 0x0155, NO_DUMP )   /* not present in the set */
27412547ROM_END
27422548
2549
27432550ROM_START( royalcdp )
27442551   ROM_REGION( 0x10000, "maincpu", 0 )
27452552   ROM_LOAD( "u16_m27c256b.bin", 0x8000, 0x8000, CRC(162996ff) SHA1(122c13ee9842e692d31490f216eb972df2321b7f) )
r7500r7501
27552562   ROM_LOAD( "palce16v8h_1.bin", 0x0000, 0x0117, CRC(c89d2f52) SHA1(f9d52d9c42ef95b7b85bbf6d09888ebdeac11fd3) )
27562563ROM_END
27572564
2565
27582566ROM_START( lluck3x3 )
27592567   ROM_REGION( 0x10000, "maincpu", 0 )
27602568   ROM_LOAD( "l3x3.bin", 0x8000, 0x8000, CRC(dbdb07ff) SHA1(6be43aa0b2c10d83373f20f477606cb031bc6dd9) )
r7500r7501
27672575   ROM_LOAD( "n82s147.bin",    0x0000, 0x0200, CRC(8bc86f48) SHA1(4c677ab9314a1f571e35104b22659e6811aeb194) )
27682576ROM_END
27692577
2578
27702579ROM_START( lluck4x1 )
27712580   ROM_REGION( 0x10000, "maincpu", 0 )
27722581   ROM_LOAD( "rk4x1.bin", 0x8000, 0x8000, CRC(37f8a355) SHA1(a6eb4c53464e373bdecbbaaf146f5f7cf66b4bcd) )
r7500r7501
27792588   ROM_LOAD( "n82s147.bin",    0x0000, 0x0200, CRC(8bc86f48) SHA1(4c677ab9314a1f571e35104b22659e6811aeb194) )
27802589ROM_END
27812590
2591
2592/*
2593    Magic Card II (bulgarian)
2594    ---------------------------------
2595
2596    - 1x Special CPU with CM602 (??) on it
2597    - 1x MC6845P
2598    - 1x YM2149F
2599    - 2x MC6821P
2600    - 1x Crystal 16.000 MHz
2601    - 2x HY18CV85 (electrically-erasable PLD)
2602
2603    Some versions have Mexican Rockwell R65c02.
2604    The game doesn't work with a regular 65c02 CPU.
2605*/
2606
27822607ROM_START( magicrd2 )   /* Impera */
27832608   ROM_REGION( 0x18000, "maincpu", 0 )
27842609   ROM_LOAD( "magicard.004", 0x0000, 0x8000,  CRC(f6e948b8) SHA1(7d5983015a508ab135ccbf69b7f3c526c229e3ef) ) /* only last 16kbyte visible? */
r7500r7501
27952620   ROM_LOAD( "gal16v8uni.bin", 0x0000, 0x0117, CRC(b81d7e0a) SHA1(7fef0b2bcea931a830d38ae0f1102434cf281d2d) )
27962621ROM_END
27972622
2623
27982624ROM_START( magicd2a )   /* for green TAB or Impera boards */
27992625   ROM_REGION( 0x10000, "maincpu", 0 )
28002626   ROM_LOAD( "mc2prgv1.bin", 0x8000, 0x8000,  CRC(7f759b70) SHA1(23a1a6e8eda57c4a90c51a970302f9a7bf590083) )
r7500r7501
28112637   ROM_LOAD( "gal16v8uni.bin", 0x0000, 0x0117, CRC(b81d7e0a) SHA1(7fef0b2bcea931a830d38ae0f1102434cf281d2d) )
28122638ROM_END
28132639
2640
28142641ROM_START( magicd2b )   /* for blue TAB board (encrypted)*/
28152642   ROM_REGION( 0x10000, "maincpu", 0 )
28162643//    ROM_LOAD( "mc2prgv1.bin", 0x8000, 0x8000,  CRC(7f759b70) SHA1(23a1a6e8eda57c4a90c51a970302f9a7bf590083) )
r7500r7501
28272654   ROM_LOAD( "gal16v8uni.bin", 0x0000, 0x0117, CRC(b81d7e0a) SHA1(7fef0b2bcea931a830d38ae0f1102434cf281d2d) )
28282655ROM_END
28292656
2657
28302658ROM_START( vegasslw )
28312659   ROM_REGION( 0x10000, "maincpu", 0 )
28322660   ROM_LOAD( "vslow.bin", 0x8000, 0x8000, CRC(9cb7861a) SHA1(f934eacd5b3573a6bbeaa827f521b4a498e5bcdf) )
r7500r7501
28392667   ROM_LOAD( "82s147.bin",   0x0000, 0x0200, CRC(5ebc5659) SHA1(8d59011a181399682ab6e8ed14f83101e9bfa0c6) )
28402668ROM_END
28412669
2670
28422671ROM_START( vegasfst )
28432672   ROM_REGION( 0x10000, "maincpu", 0 )
28442673   ROM_LOAD( "vfast.bin", 0x8000, 0x8000, CRC(87dfb28d) SHA1(9a06e695e59722b6c97e5a9fd2c8b238661e5a4a) )
r7500r7501
28512680   ROM_LOAD( "82s147.bin",   0x0000, 0x0200, CRC(5ebc5659) SHA1(8d59011a181399682ab6e8ed14f83101e9bfa0c6) )
28522681ROM_END
28532682
2683
28542684ROM_START( vegasfte )   /* Royal Vegas Joker Card (fast deal, english gfx) */
28552685   ROM_REGION( 0x10000, "maincpu", 0 )
28562686   ROM_LOAD( "ch3.bin", 0x8000, 0x8000, CRC(87dfb28d) SHA1(9a06e695e59722b6c97e5a9fd2c8b238661e5a4a) )
r7500r7501
28632693   ROM_LOAD( "82s147.bin",   0x0000, 0x0200, CRC(5ebc5659) SHA1(8d59011a181399682ab6e8ed14f83101e9bfa0c6) )
28642694ROM_END
28652695
2866ROM_START( jolyjokr )   /* Jolly Joker (Impera, original) */
2696
2697/*
2698
2699  Impera - Jolly Joker
2700
2701  PCB Layout:
2702   _____________________________________________________________________________________________
2703  |                                                   __________                                |
2704  |                                                  | MOP1603  |                               |
2705  |                               _________    __    |__________|                               |
2706  |    ________________________  |    A    |  |  |       _______      __    __                  |___
2707  |   |                        | |_________|  |  |      |       |    |  |  |  |                  ___|
2708  |   |                        |              |A |      |       |    |D |  |K |                  ___|
2709  |   |        MC6845P         |  _________   |  |      |       |    |  |  |  |                  ___|
2710  |   |                        | |    A    |  |  |      |AY38910|    |  |  |  |                  ___|
2711  |   |________________________| |_________|  |__|      |  A/P  |    |__|  |__|                  ___|
2712  |                                            __       |9120CCA|                                ___|
2713  |                     _________________     |  |      |       |    _______                     ___|
2714  |    _____________   |                 |    |  |      |       |   |   K   |                    ___|
2715  |   | T74LS245B1  |  |  KM6264BL_10    |    |A |      |       |   |_______|                    ___|
2716  |   |_____________|  |                 |    |  |      |       |                                ___|
2717  |                    |  206Y KOREA     |    |  |      |       |         _______       ___      ___|
2718  |                    |_________________|    |__|      |       |        |       |     |   |8   |
2719  |                                                     |       |        |       |     |DIP|    |
2720  |    _____________        _____________               |_______|        |       |     | 1 |    |
2721  |   | SN74LS374N  |      | SN74LS374N  |                               |MC68B21|     |   |    |___
2722  |   |_____________|      |_____________|   ________________________    |      P|     |   |     ___|
2723  |                                         |        R65C02P2        |   |       |     |___|1    ___|
2724  |    __________________       _________   |        11450_12        |   |0K2P   |               ___|
2725  |   |CH1               |     |74LS194AN|  |          9209          |   |LLEG912|    __         ___|
2726  |   |                  |     |_________|  |________________________|   |      6|   |  |        ___|
2727  |   |   M27C512        |                                               |       |   |  |        ___|
2728  |   |                  |                   ___    __________________   |       |   |J |        ___|
2729  |   |__________________|      _________   |   |  |JOKER RUN         |  |       |   |  |        ___|
2730  |                            |74LS194AN|  |   |  |                  |  |       |   |  |        ___|
2731  |    __________________      |_________|  |   |  |   M27C512        |  |       |   |__|        ___|
2732  |   |CH2               |                  | B |  |                  |  |_______|               ___|
2733  |   |                  |      _________   |   |  |__________________|                          ___|
2734  |   |   M27C512        |     |74LS194AN|  |   |                         _______     __         ___|
2735  |   |                  |     |_________|  |   |                        |       |   |  |        ___|
2736  |   |__________________|                  |   |      _______________   |       |   |  |        ___|
2737  |                                         |___|     |               |  |       |   |J |        ___|
2738  |    _________    ________    _________             |    HYUNDAI    |  |MC68B21|   |  |        ___|
2739  |   |T54LS174M|  |DL002D  |  |74LS194AN|   _______  | HY6116ALP_10  |  |      P|   |  |        ___|
2740  |   |_________|  |________|  |_________|  |   C   | |               |  |       |   |__|        ___|
2741  |                                         |_______| |_______________|  |0K2P   |               ___|
2742  |    __     __    __          _________                                |LLEG912|    __         ___|
2743  |   |  |   |  |  |  |        |XTAL     |   _______                     |      6|   |  |        ___|
2744  |   |  |   |  |  |  |        |         |  |   D   |                    |       |   |  |        ___|
2745  |   |I |   |H |  |G |        |  16 Mhz |  |_______|                    |       |   |J |        ___|
2746  |   |  |   |  |  |  |        |_________|                               |       |   |  |        ___|
2747  |   |  |   |  |  |  |         _________      ____                      |       |   |  |        ___|
2748  |   |__|   |  |  |  |        |    E    |    | F  |                     |       |   |__|        ___|
2749  |          |__|  |__|        |_________|    |____|                     |_______|               ___|
2750  |                                                                                             |
2751  |_____________________________________________________________________________________________|
2752
2753
2754  A = PC74HCT157P
2755  B = AMPAL16L8DC
2756  C = HD74LS189P
2757  D = T54LS14M2
2758  E = T74LS393B1
2759  F = TL7705ACP
2760  G = SN74LS374N
2761  H = AM27S29PC
2762  I = PC74HCT174P
2763  J = 4116R_001
2764  K = ULN2003A
2765
2766
2767  DIP1:
2768   ___________________
2769  | ON                |
2770  |  _______________  |
2771  | |#|#|#|#|#|#|#|#| |
2772  | | | | | | | | | | |
2773  | |_______________| |
2774  |  1 2 3 4 5 6 7 8  |
2775  |___________________|
2776
2777*/
2778
2779ROM_START( jolyjokr )   /* Jolly Joker (98bet, set 1) */
28672780   ROM_REGION( 0x10000, "maincpu", 0 )
28682781   ROM_LOAD( "impera3orig.bin", 0x8000, 0x8000, CRC(ceb3a0d5) SHA1(25efae9f225abddfa663e6abcc91801996e5b0ea) )
28692782
28702783   ROM_REGION( 0x10000, "gfx1", 0 )
2871   ROM_LOAD( "impera2.bin", 0x0000, 0x8000, BAD_DUMP CRC(57c1ca04) SHA1(9d3e1f50795ebe5997532b67ba467fd6428e81d2) )
2872   ROM_LOAD( "impera1.bin", 0x8000, 0x8000, CRC(8e354c4a) SHA1(95d7edf83bb07b5c58312af6d8a7dff1cf87cba7) )
2784   ROM_LOAD( "impera2.bin", 0x0000, 0x8000, CRC(f0fa5941) SHA1(1fcade31ed6893ffcfd4efe97dfaaa31d24283ec) )
2785   ROM_LOAD( "impera1.bin", 0x8000, 0x8000, CRC(c3ab44dd) SHA1(e46c0fd94da561f57033647f1703fa135777ece5) )
28732786
28742787   ROM_REGION( 0x0200, "proms", 0 )
2875   ROM_LOAD( "82s147.bin",   0x0000, 0x0200, CRC(5ebc5659) SHA1(8d59011a181399682ab6e8ed14f83101e9bfa0c6) )
2788   ROM_LOAD( "am27s29.bin", 0x0000, 0x0200, CRC(0b671bba) SHA1(92d512e02b50f98b7bc5a60deee4fee722656c4f) )
28762789ROM_END
28772790
2878ROM_START( jolyjokra )   /* Jolly Joker (Impera, 50bet) */
2791
2792ROM_START( jolyjokra )   /* Jolly Joker (98bet, set 2) */
28792793   ROM_REGION( 0x10000, "maincpu", 0 )
28802794   ROM_LOAD( "impera50.bin", 0x8000, 0x8000, CRC(7effc044) SHA1(961438e7fb8222296fb959b510cdf646e4ac3226) )
28812795
28822796   ROM_REGION( 0x10000, "gfx1", 0 )
2883   ROM_LOAD( "impera2.bin", 0x0000, 0x8000, BAD_DUMP CRC(57c1ca04) SHA1(9d3e1f50795ebe5997532b67ba467fd6428e81d2) )
2884   ROM_LOAD( "impera1.bin", 0x8000, 0x8000, CRC(8e354c4a) SHA1(95d7edf83bb07b5c58312af6d8a7dff1cf87cba7) )
2797   ROM_LOAD( "impera2.bin", 0x0000, 0x8000, CRC(f0fa5941) SHA1(1fcade31ed6893ffcfd4efe97dfaaa31d24283ec) )
2798   ROM_LOAD( "impera1.bin", 0x8000, 0x8000, CRC(c3ab44dd) SHA1(e46c0fd94da561f57033647f1703fa135777ece5) )
28852799
28862800   ROM_REGION( 0x0200, "proms", 0 )
2887   ROM_LOAD( "82s147.bin",   0x0000, 0x0200, CRC(5ebc5659) SHA1(8d59011a181399682ab6e8ed14f83101e9bfa0c6) )
2801   ROM_LOAD( "am27s29.bin", 0x0000, 0x0200, CRC(0b671bba) SHA1(92d512e02b50f98b7bc5a60deee4fee722656c4f) )
28882802ROM_END
28892803
2804
2805/*
2806    Jolly Joker (40bet, croatian hack)
2807
2808am27s29_ic40.bin     1ST AND 2ND HALF IDENTICAL
2809ic25.bin             1ST AND 2ND HALF IDENTICAL
2810ic26.bin             1ST AND 2ND HALF IDENTICAL
2811
2812These graphics ROMs have enough data to fix the bitrotten graphics from the other Jolly Joker sets.
2813impera1.bin ---> bits 7 & 6
2814impera2.bin ---> bits 7 & 0
2815
2816Two slightly different programs. One in each half.
2817Both have Min Bet (5), Max Bet (40).
2818Surely selectable through a PLD.
2819
2820*/
2821ROM_START( jolyjokrb )
2822   ROM_REGION( 0x18000, "maincpu", 0 )   /* Two slightly different programs. Using the 1st one...*/
2823   ROM_LOAD( "unbekannt.bin", 0x8000, 0x10000, CRC(327fa3d7) SHA1(2435aada2377b2f8f01d059a7aba9bc7a8993537) )   /* 1st prg */
2824//  ROM_LOAD( "unbekannt.bin", 0x0000, 0x10000, CRC(327fa3d7) SHA1(2435aada2377b2f8f01d059a7aba9bc7a8993537) )  /* 2nd prg */
2825
2826   ROM_REGION( 0x20000, "gfx1", 0 )
2827   ROM_LOAD( "ic25.bin", 0x00000, 0x10000, CRC(1bd067af) SHA1(9436fe085ba63c00a12ea80903470a84535e3dc1) )
2828   ROM_LOAD( "ic26.bin", 0x10000, 0x10000, CRC(3e45dfc6) SHA1(8fd0b0cc00cdd96244ae7e7a91f6613b1c144ee0) )
2829   ROM_COPY( "gfx1",     0x10000, 0x00000, 0x8000 ) /* rgn, srcoffset, offset, length */
2830
2831   ROM_REGION( 0x0200, "proms", 0 )
2832   ROM_LOAD( "am27s29_ic40.bin",   0x0000, 0x0200, CRC(0b671bba) SHA1(92d512e02b50f98b7bc5a60deee4fee722656c4f) )
2833ROM_END
2834
2835
28902836ROM_START( jokercrd )
28912837/*  (Multi) Joker Card from Vesely Svet (Sprightly World). Czech poker game.
28922838    Program roms seems encrypted. Custom Funworld CPU based on 6502 family.
r7500r7501
29052851   ROM_LOAD( "ic13.bin",   0x0000, 0x0200, CRC(e59fc06e) SHA1(88a3bb89f020fe2b20f768ca010a082e0b974831) )
29062852ROM_END
29072853
2854
2855/*
2856    Mongolfier New
2857    --------------
2858
2859    - 1x G65SC02P2 (main)
2860    - 1x KC89C72 (sound)
2861    - 1x TDA2003 (sound)
2862    - 1x MC68B45P (CRT controller)
2863    - 2x EF6821P (Peripheral Interface Adapter)
2864    - 1x TSC87C52-16CB (PLCC44)(Programmable 8bit Microcontroller, now dumped)
2865    - 1x M48Z08-100PC1 (Zero Power RAM - Lithium Battery)
2866    - 1x oscillator 16.0000 MHz
2867
2868    - 3x M27C512
2869    - 1x PROM AM27S29PC
2870    - 1x PALCE16V8H (read protected)
2871
2872    - 1x JAMMA edge connector
2873    - 1x trimmer (volume)
2874    - 2x 8 DIP switches
2875    - 1x 4 DIP switches
2876    - 1x green led
2877*/
2878
29082879ROM_START( mongolnw )
29092880   ROM_REGION( 0x20000, "maincpu", 0 )
29102881   ROM_LOAD( "prgteov.2.3m.u16", 0x10000, 0x10000, CRC(996b851a) SHA1(ef4e3d036ca10b33c83749024d04c4d4c09feeb7) )
r7500r7501
29252896   ROM_LOAD( "palce16v8h_mf.u5",  0x0000, 0x0117, NO_DUMP ) /* PAL is read protected */
29262897ROM_END
29272898
2899
2900/*
2901    Soccer New (italian)
2902    --------------------
2903
2904    - 1x G65SC02P2 (main)
2905    - 1x KC89C72 (sound)
2906    - 1x TDA2003 (sound)
2907    - 1x MC68B45P (CRT controller)
2908    - 1x EF68B21P (Peripheral Interface Adapter)
2909    - 1x EF6821P (Peripheral Interface Adapter)
2910    - 1x TSC87C52-16CB (PLCC44)(Programmable 8bit Microcontroller, now dumped)
2911    - 1x M48Z08-100PC1 (Zero Power RAM - Lithium Battery)
2912    - 1x oscillator 16.0000MHz
2913
2914    - 3x M27C512
2915    - 1x PROM AM27S29PC
2916    - 1x PALCE16V8H (read protected)
2917
2918    - 1x JAMMA edge connector
2919    - 1x trimmer (volume)
2920    - 2x 8 DIP switches
2921    - 1x 4 DIP switches
2922    - 1x green led
2923*/
2924
29282925ROM_START( soccernw )
29292926   ROM_REGION( 0x20000, "maincpu", 0 )
29302927   ROM_LOAD( "prgteo2gv2.3.u16", 0x10000, 0x10000, CRC(c61d1937) SHA1(c516f13a108da60b7ccee338b63a025009ef9099) )
r7500r7501
29452942   ROM_LOAD( "palce16v8h_sn.u5",  0x0000, 0x0117, NO_DUMP ) /* PAL is read protected */
29462943ROM_END
29472944
2945
2946/*
2947    Saloon (France, encrypted)
2948    --------------------------
2949
2950    - 1x 65SC02 (main)
2951    - 1x 8948? (sound)
2952    - 1x MC6845P (CRT controller)
2953    - 1x oscillator 16.000000 MHz
2954
2955    - 2x M27C512
2956    - 1x M27C256B
2957    - 1x PROM N82S147N
2958    - 1x GAL16V8-25LNC (read protected)
2959    - 1x GAL18CV8-25 (read protected)
2960
2961    - 1x HY6264ALP-12
2962    - 1x UM6116K-3L
2963
2964    - 1x JAMMA edge connector
2965    - 1x trimmer (volume?)
2966    - 1x LM380N (amplifier)
2967    - 1x ULN2803A (8 Darlington arrays)
2968    - 1x battery
2969    - 1x test button
2970    - 1x indicator LED
2971    - NO DIP switches
2972
2973    Board has printed "LEOPARDO 5"
2974*/
2975
29482976ROM_START( saloon )
29492977   ROM_REGION( 0x10000, "maincpu", 0 )
29502978   ROM_LOAD( "1s.bin", 0x8000, 0x8000, CRC(66938330) SHA1(09118d607eff7121472db7d2cc24079e063dc7cf) )
r7500r7501
29592987ROM_END
29602988
29612989
2990
29622991/**************************
29632992*  Driver Initialization  *
29642993**************************/
r7500r7501
31703199*      Game Drivers      *
31713200*************************/
31723201
3173/*    YEAR  NAME      PARENT    MACHINE   INPUT     INIT      ROT    COMPANY            FULLNAME                                          FLAGS  */
3174GAME( 1985, jollycrd, 0,        funworld, funworld, 0,        ROT0, "TAB-Austria",     "Jolly Card (austrian)",                           0 )
3175GAME( 1985, jolyc3x3, jollycrd, funworld, funworld, 0,        ROT0, "TAB-Austria",     "Jolly Card (3x3 deal)",                           0 )
3176GAME( 2000, jolyc980, jollycrd, jolyc980, jolyc980, 0,        ROT0, "Spale-Soft",      "Jolly Card Professional 2.0",                     0 )
3177GAME( 1998, jolycdev, jollycrd, funworld, funworld, 0,        ROT0, "TAB/Evona",       "Jolly Card (Evona Electronic)",                   0 )
3178GAME( 1985, jolyccra, jollycrd, cuoreuno, jolycdcr, 0,        ROT0, "TAB-Austria",     "Jolly Card (croatian, set 1)",                    0 )
3179GAME( 1993, jolyccrb, jollycrd, cuoreuno, jolycdcr, 0,        ROT0, "Soft Design",     "Jolly Card (croatian, set 2)",                    0 )
3180GAME( 199?, jolycdit, jollycrd, cuoreuno, jolycdit, tabblue,  ROT0, "bootleg",         "Jolly Card (italian, blue TAB board, encrypted)", 0 )
3181GAME( 1990, jolycdib, jollycrd, cuoreuno, jolycdib, tabblue,  ROT0, "bootleg",         "Jolly Card (italian, encrypted bootleg)",         0 )   /* not a real TAB blue PCB */
3182GAME( 1985, sjcd2kx3, jollycrd, funworld, funworld, 0,        ROT0, "M.P.",            "Super Joly 2000 - 3x",                            0 )
3183GAME( 1986, jolycdab, jollycrd, funworld, funworld, 0,        ROT0, "Inter Games",     "Jolly Card (austrian, Funworld, bootleg)",        GAME_NOT_WORKING )
3184GAME( 1986, bigdeal,  0,        funworld, bigdeal,  0,        ROT0, "Funworld",        "Big Deal (hungarian, set 1)",                     GAME_IMPERFECT_COLORS )
3185GAME( 1986, bigdealb, bigdeal,  funworld, bigdeal,  0,        ROT0, "Funworld",        "Big Deal (hungarian, set 2)",                     GAME_IMPERFECT_COLORS )
3186GAME( 1986, jolycdat, bigdeal,  funworld, bigdeal,  0,        ROT0, "Funworld",        "Jolly Card (austrian, Funworld)",                 GAME_IMPERFECT_COLORS )
3187GAME( 1996, cuoreuno, 0,        cuoreuno, cuoreuno, 0,        ROT0, "C.M.C.",          "Cuore 1 (italian)",                               0 )
3188GAME( 1997, elephfam, 0,        cuoreuno, cuoreuno, 0,        ROT0, "C.M.C.",          "Elephant Family (italian, new)",                  0 )
3189GAME( 1996, elephfmb, elephfam, cuoreuno, cuoreuno, 0,        ROT0, "C.M.C.",          "Elephant Family (italian, old)",                  0 )
3190GAME( 1996, pool10,   0,        cuoreuno, pool10,   0,        ROT0, "C.M.C.",          "Pool 10 (italian, set 1)",                        0 )
3191GAME( 1996, pool10b,  pool10,   cuoreuno, cuoreuno, 0,        ROT0, "C.M.C.",          "Pool 10 (italian, set 2)",                        0 )
3192GAME( 1996, pool10c,  pool10,   cuoreuno, cuoreuno, 0,        ROT0, "C.M.C.",          "Pool 10 (italian, set 3)",                        0 )
3193GAME( 1997, pool10d,  pool10,   cuoreuno, cuoreuno, 0,        ROT0, "C.M.C.",          "Pool 10 (italian, set 4)",                        0 )
3194GAME( 1997, tortufam, 0,        cuoreuno, cuoreuno, 0,        ROT0, "C.M.C.",          "Tortuga Family (italian)",                        0 )
3195GAME( 1996, potgame,  0,        cuoreuno, cuoreuno, 0,        ROT0, "C.M.C.",          "Pot Game (italian)",                              0 )
3196GAME( 1996, bottle10, 0,        cuoreuno, cuoreuno, 0,        ROT0, "C.M.C.",          "Bottle 10 (italian, set 1)",                      0 )
3197GAME( 1996, bottl10b, bottle10, cuoreuno, cuoreuno, 0,        ROT0, "C.M.C.",          "Bottle 10 (italian, set 2)",                      0 )
3198GAME( 1991, royalcrd, 0,        royalcrd, royalcrd, 0,        ROT0, "TAB-Austria",     "Royal Card (austrian, set 1)",                    0 )
3199GAME( 1991, royalcdb, royalcrd, royalcrd, royalcrd, 0,        ROT0, "TAB-Austria",     "Royal Card (austrian, set 2)",                    0 )
3200GAME( 1991, royalcdc, royalcrd, royalcrd, royalcrd, 0,        ROT0, "Evona Electronic","Royal Card (slovak, encrypted)",                  GAME_WRONG_COLORS | GAME_NOT_WORKING )
3201GAME( 1993, royalcdp, royalcrd, cuoreuno, royalcrd, 0,        ROT0, "Digital Dreams",  "Royal Card v2.0 Professional",                    GAME_NOT_WORKING )
3202GAME( 1991, lluck3x3, royalcrd, cuoreuno, royalcrd, 0,        ROT0, "TAB-Austria",     "Lucky Lady (3x3 deal)",                           0 )
3203GAME( 1991, lluck4x1, royalcrd, royalcrd, royalcrd, 0,        ROT0, "TAB-Austria",     "Lucky Lady (4x1 aces)",                           0 )
3204GAME( 1996, magicrd2, 0,        magicrd2, magicrd2, 0,        ROT0, "Impera",          "Magic Card II (bulgarian)",                       GAME_IMPERFECT_SOUND )
3205GAME( 1996, magicd2a, magicrd2, magicrd2, magicrd2, magicd2a, ROT0, "Impera",          "Magic Card II (green TAB or Impera board)",       GAME_NOT_WORKING )
3206GAME( 1996, magicd2b, magicrd2, magicrd2, magicrd2, magicd2b, ROT0, "Impera",          "Magic Card II (blue TAB board, encrypted)",       GAME_NOT_WORKING )
3207GAME( 1993, vegasslw, 0,        funworld, funworld, 0,        ROT0, "Funworld",        "Royal Vegas Joker Card (slow deal)",              0 )
3208GAME( 1993, vegasfst, vegasslw, funworld, funworld, 0,        ROT0, "Soft Design",     "Royal Vegas Joker Card (fast deal)",              0 )
3209GAME( 1993, vegasfte, vegasslw, funworld, funworld, 0,        ROT0, "Soft Design",     "Royal Vegas Joker Card (fast deal, english gfx)", 0 )
3210GAME( 198?, jolyjokr, 0,        funworld, funworld, 0,        ROT0, "Impera",          "Jolly Joker",                                     0 )
3211GAME( 198?, jolyjokra,jolyjokr, funworld, jolyjokra,0,        ROT0, "Impera",          "Jolly Joker (50bet)",                             0 )
3212GAME( 1993, jokercrd, 0,        funworld, funworld, 0,        ROT0, "Vesely Svet",     "Joker Card (Ver.A267BC, encrypted)",              GAME_WRONG_COLORS | GAME_NOT_WORKING )
3213GAME( 199?, mongolnw, 0,        royalmcu, royalcrd, 0,        ROT0, "bootleg",         "Mongolfier New (italian)",                        GAME_UNEMULATED_PROTECTION | GAME_NOT_WORKING )
3214GAME( 199?, soccernw, 0,        royalcrd, royalcrd, soccernw, ROT0, "bootleg",         "Soccer New (italian)",                            GAME_UNEMULATED_PROTECTION | GAME_NOT_WORKING )
3215GAME( 198?, saloon,   0,        saloon,   saloon,   saloon,   ROT0, "<unknown>",       "Saloon (french, encrypted)",                      GAME_NO_SOUND | GAME_WRONG_COLORS | GAME_IMPERFECT_GRAPHICS | GAME_UNEMULATED_PROTECTION | GAME_NOT_WORKING )
3202/*    YEAR  NAME       PARENT    MACHINE   INPUT      INIT      ROT    COMPANY            FULLNAME                                          FLAGS  */
3203GAME( 1985, jollycrd,  0,        funworld, funworld,  0,        ROT0, "TAB-Austria",     "Jolly Card (austrian)",                           0 )
3204GAME( 1985, jolyc3x3,  jollycrd, funworld, funworld,  0,        ROT0, "TAB-Austria",     "Jolly Card (3x3 deal)",                           0 )
3205GAME( 2000, jolyc980,  jollycrd, cuoreuno, jolyc980,  0,        ROT0, "Spale-Soft",      "Jolly Card Professional 2.0",                     0 )
3206GAME( 1998, jolycdev,  jollycrd, funworld, funworld,  0,        ROT0, "TAB/Evona",       "Jolly Card (Evona Electronic)",                   0 )
3207GAME( 1985, jolyccra,  jollycrd, cuoreuno, jolycdcr,  0,        ROT0, "TAB-Austria",     "Jolly Card (croatian, set 1)",                    0 )
3208GAME( 1993, jolyccrb,  jollycrd, cuoreuno, jolycdcr,  0,        ROT0, "Soft Design",     "Jolly Card (croatian, set 2)",                    0 )
3209GAME( 199?, jolycdit,  jollycrd, cuoreuno, jolycdit,  tabblue,  ROT0, "bootleg",         "Jolly Card (italian, blue TAB board, encrypted)", 0 )
3210GAME( 1990, jolycdib,  jollycrd, cuoreuno, jolycdib,  tabblue,  ROT0, "bootleg",         "Jolly Card (italian, encrypted bootleg)",         0 )   /* not a real TAB blue PCB */
3211GAME( 1985, sjcd2kx3,  jollycrd, funworld, funworld,  0,        ROT0, "M.P.",            "Super Joly 2000 - 3x",                            0 )
3212GAME( 1986, jolycdab,  jollycrd, funworld, funworld,  0,        ROT0, "Inter Games",     "Jolly Card (austrian, Funworld, bootleg)",        GAME_NOT_WORKING )
3213GAME( 1986, bigdeal,   0,        funworld, bigdeal,   0,        ROT0, "Funworld",        "Big Deal (hungarian, set 1)",                     GAME_IMPERFECT_COLORS )
3214GAME( 1986, bigdealb,  bigdeal,  funworld, bigdeal,   0,        ROT0, "Funworld",        "Big Deal (hungarian, set 2)",                     GAME_IMPERFECT_COLORS )
3215GAME( 1986, jolycdat,  bigdeal,  funworld, bigdeal,   0,        ROT0, "Funworld",        "Jolly Card (austrian, Funworld)",                 GAME_IMPERFECT_COLORS )
3216GAME( 1996, cuoreuno,  0,        cuoreuno, cuoreuno,  0,        ROT0, "C.M.C.",          "Cuore 1 (italian)",                               0 )
3217GAME( 1997, elephfam,  0,        cuoreuno, cuoreuno,  0,        ROT0, "C.M.C.",          "Elephant Family (italian, new)",                  0 )
3218GAME( 1996, elephfmb,  elephfam, cuoreuno, cuoreuno,  0,        ROT0, "C.M.C.",          "Elephant Family (italian, old)",                  0 )
3219GAME( 1996, pool10,    0,        cuoreuno, pool10,    0,        ROT0, "C.M.C.",          "Pool 10 (italian, set 1)",                        0 )
3220GAME( 1996, pool10b,   pool10,   cuoreuno, cuoreuno,  0,        ROT0, "C.M.C.",          "Pool 10 (italian, set 2)",                        0 )
3221GAME( 1996, pool10c,   pool10,   cuoreuno, cuoreuno,  0,        ROT0, "C.M.C.",          "Pool 10 (italian, set 3)",                        0 )
3222GAME( 1997, pool10d,   pool10,   cuoreuno, cuoreuno,  0,        ROT0, "C.M.C.",          "Pool 10 (italian, set 4)",                        0 )
3223GAME( 1997, tortufam,  0,        cuoreuno, cuoreuno,  0,        ROT0, "C.M.C.",          "Tortuga Family (italian)",                        0 )
3224GAME( 1996, potgame,   0,        cuoreuno, cuoreuno,  0,        ROT0, "C.M.C.",          "Pot Game (italian)",                              0 )
3225GAME( 1996, bottle10,  0,        cuoreuno, cuoreuno,  0,        ROT0, "C.M.C.",          "Bottle 10 (italian, set 1)",                      0 )
3226GAME( 1996, bottl10b,  bottle10, cuoreuno, cuoreuno,  0,        ROT0, "C.M.C.",          "Bottle 10 (italian, set 2)",                      0 )
3227GAME( 1991, royalcrd,  0,        royalcrd, royalcrd,  0,        ROT0, "TAB-Austria",     "Royal Card (austrian, set 1)",                    0 )
3228GAME( 1991, royalcdb,  royalcrd, royalcrd, royalcrd,  0,        ROT0, "TAB-Austria",     "Royal Card (austrian, set 2)",                    0 )
3229GAME( 1991, royalcdc,  royalcrd, royalcrd, royalcrd,  0,        ROT0, "Evona Electronic","Royal Card (slovak, encrypted)",                  GAME_WRONG_COLORS | GAME_NOT_WORKING )
3230GAME( 1993, royalcdp,  royalcrd, cuoreuno, royalcrd,  0,        ROT0, "Digital Dreams",  "Royal Card v2.0 Professional",                    GAME_NOT_WORKING )
3231GAME( 1991, lluck3x3,  royalcrd, cuoreuno, royalcrd,  0,        ROT0, "TAB-Austria",     "Lucky Lady (3x3 deal)",                           0 )
3232GAME( 1991, lluck4x1,  royalcrd, royalcrd, royalcrd,  0,        ROT0, "TAB-Austria",     "Lucky Lady (4x1 aces)",                           0 )
3233GAME( 1996, magicrd2,  0,        magicrd2, magicrd2,  0,        ROT0, "Impera",          "Magic Card II (bulgarian)",                       GAME_IMPERFECT_SOUND )
3234GAME( 1996, magicd2a,  magicrd2, magicrd2, magicrd2,  magicd2a, ROT0, "Impera",          "Magic Card II (green TAB or Impera board)",       GAME_NOT_WORKING )
3235GAME( 1996, magicd2b,  magicrd2, magicrd2, magicrd2,  magicd2b, ROT0, "Impera",          "Magic Card II (blue TAB board, encrypted)",       GAME_NOT_WORKING )
3236GAME( 1993, vegasslw,  0,        funworld, funworld,  0,        ROT0, "Funworld",        "Royal Vegas Joker Card (slow deal)",              0 )
3237GAME( 1993, vegasfst,  vegasslw, funworld, funworld,  0,        ROT0, "Soft Design",     "Royal Vegas Joker Card (fast deal)",              0 )
3238GAME( 1993, vegasfte,  vegasslw, funworld, funworld,  0,        ROT0, "Soft Design",     "Royal Vegas Joker Card (fast deal, english gfx)", 0 )
3239GAME( 198?, jolyjokr,  0,        funworld, funworld,  0,        ROT0, "Impera",          "Jolly Joker (98bet, set 1)",                      0 )
3240GAME( 198?, jolyjokra, jolyjokr, funworld, jolyjokra, 0,        ROT0, "Impera",          "Jolly Joker (98bet, set 2)",                      0 )
3241GAME( 198?, jolyjokrb, jolyjokr, funworld, funworld,  0,        ROT0, "Impera",          "Jolly Joker (40bet, croatian hack)",              0 )
3242GAME( 1993, jokercrd,  0,        funworld, funworld,  0,        ROT0, "Vesely Svet",     "Joker Card (Ver.A267BC, encrypted)",              GAME_WRONG_COLORS | GAME_NOT_WORKING )
3243GAME( 199?, mongolnw,  0,        royalmcu, royalcrd,  0,        ROT0, "bootleg",         "Mongolfier New (italian)",                        GAME_UNEMULATED_PROTECTION | GAME_NOT_WORKING )
3244GAME( 199?, soccernw,  0,        royalcrd, royalcrd,  soccernw, ROT0, "bootleg",         "Soccer New (italian)",                            GAME_UNEMULATED_PROTECTION | GAME_NOT_WORKING )
3245GAME( 198?, saloon,    0,        saloon,   saloon,    saloon,   ROT0, "<unknown>",       "Saloon (french, encrypted)",                      GAME_NO_SOUND | GAME_WRONG_COLORS | GAME_IMPERFECT_GRAPHICS | GAME_UNEMULATED_PROTECTION | GAME_NOT_WORKING )
3246
src/mame/drivers/nmg5.c
r7500r7501
225225#include "sound/okim6295.h"
226226#include "sound/3812intf.h"
227227
228static tilemap_t *fg_tilemap,*bg_tilemap;
229static UINT16 *nmg5_bitmap;
230static UINT16 *fg_videoram,*bg_videoram,*scroll_ram;
231static UINT8 prot_val, input_data, priority_reg, gfx_bank;
232228
229class nmg5_state
230{
231public:
232   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, nmg5_state(machine)); }
233
234   nmg5_state(running_machine &machine) { }
235
236   /* memory pointers */
237   UINT16 *    fg_videoram;
238   UINT16 *    bg_videoram;
239   UINT16 *    scroll_ram;
240   UINT16 *    bitmap;
241   UINT16 *    spriteram;
242//  UINT16 *  paletteram;    // currently this uses generic palette handling
243   size_t      spriteram_size;
244
245   /* video-related */
246   tilemap_t  *bg_tilemap, *fg_tilemap;
247
248   /* misc */
249   UINT8 prot_val, input_data, priority_reg, gfx_bank;
250
251   /* devices */
252   running_device *maincpu;
253   running_device *soundcpu;
254};
255
256
257
233258static WRITE16_HANDLER( fg_videoram_w )
234259{
235   COMBINE_DATA(&fg_videoram[offset]);
236   tilemap_mark_tile_dirty(fg_tilemap,offset);
260   nmg5_state *state = (nmg5_state *)space->machine->driver_data;
261   COMBINE_DATA(&state->fg_videoram[offset]);
262   tilemap_mark_tile_dirty(state->fg_tilemap, offset);
237263}
238264
239265static WRITE16_HANDLER( bg_videoram_w )
240266{
241   COMBINE_DATA(&bg_videoram[offset]);
242   tilemap_mark_tile_dirty(bg_tilemap,offset);
267   nmg5_state *state = (nmg5_state *)space->machine->driver_data;
268   COMBINE_DATA(&state->bg_videoram[offset]);
269   tilemap_mark_tile_dirty(state->bg_tilemap, offset);
243270}
244271
245272static WRITE16_HANDLER( nmg5_soundlatch_w )
246273{
274   nmg5_state *state = (nmg5_state *)space->machine->driver_data;
275
247276   if (ACCESSING_BITS_0_7)
248277   {
249      soundlatch_w(space,0,data & 0xff);
250      cputag_set_input_line(space->machine, "soundcpu", INPUT_LINE_NMI, PULSE_LINE);
278      soundlatch_w(space, 0, data & 0xff);
279      cpu_set_input_line(state->soundcpu, INPUT_LINE_NMI, PULSE_LINE);
251280   }
252281}
253282
254283static READ16_HANDLER( prot_r )
255284{
256   return prot_val | input_data;
285   nmg5_state *state = (nmg5_state *)space->machine->driver_data;
286   return state->prot_val | state->input_data;
257287}
258288
259289static WRITE16_HANDLER( prot_w )
260290{
261   input_data = data & 0xf;
291   nmg5_state *state = (nmg5_state *)space->machine->driver_data;
292   state->input_data = data & 0x0f;
262293}
263294
264295static WRITE16_HANDLER( gfx_bank_w )
265296{
266   if( gfx_bank != (data & 3) )
297   nmg5_state *state = (nmg5_state *)space->machine->driver_data;
298
299   if (state->gfx_bank != (data & 3))
267300   {
268      gfx_bank = data & 3;
301      state->gfx_bank = data & 3;
269302      tilemap_mark_all_tiles_dirty_all(space->machine);
270303   }
271304}
272305
273306static WRITE16_HANDLER( priority_reg_w )
274307{
275   priority_reg = data & 7;
308   nmg5_state *state = (nmg5_state *)space->machine->driver_data;
276309
277   if(priority_reg == 4 || priority_reg == 5 || priority_reg == 6)
278      popmessage("unknown priority_reg value = %d\n",priority_reg);
310   state->priority_reg = data & 7;
311
312   if (state->priority_reg == 4 || state->priority_reg == 5 || state->priority_reg == 6)
313      popmessage("unknown priority_reg value = %d\n", state->priority_reg);
279314}
280315
281316static WRITE8_DEVICE_HANDLER( oki_banking_w )
282317{
283   okim6295_set_bank_base(device, (data & 1) ? 0x40000 : 0 );
318   okim6295_set_bank_base(device, (data & 1) ? 0x40000 : 0);
284319}
285320
286321/*******************************************************************
r7500r7501
293328   AM_RANGE(0x000000, 0x0fffff) AM_ROM
294329   AM_RANGE(0x120000, 0x12ffff) AM_RAM
295330   AM_RANGE(0x140000, 0x1407ff) AM_RAM_WRITE(paletteram16_xBBBBBGGGGGRRRRR_word_w) AM_BASE_GENERIC(paletteram)
296   AM_RANGE(0x160000, 0x1607ff) AM_RAM AM_BASE_SIZE_GENERIC(spriteram)
331   AM_RANGE(0x160000, 0x1607ff) AM_RAM AM_BASE_SIZE_MEMBER(nmg5_state, spriteram, spriteram_size)
297332   AM_RANGE(0x180000, 0x180001) AM_WRITE(nmg5_soundlatch_w)
298333   AM_RANGE(0x180002, 0x180003) AM_WRITENOP
299334   AM_RANGE(0x180004, 0x180005) AM_READWRITE(prot_r, prot_w)
r7500r7501
302337   AM_RANGE(0x18000a, 0x18000b) AM_READ_PORT("SYSTEM")
303338   AM_RANGE(0x18000c, 0x18000d) AM_READ_PORT("INPUTS")
304339   AM_RANGE(0x18000e, 0x18000f) AM_WRITE(priority_reg_w)
305   AM_RANGE(0x300002, 0x300009) AM_WRITEONLY AM_BASE(&scroll_ram)
340   AM_RANGE(0x300002, 0x300009) AM_WRITEONLY AM_BASE_MEMBER(nmg5_state, scroll_ram)
306341   AM_RANGE(0x30000a, 0x30000f) AM_WRITENOP
307   AM_RANGE(0x320000, 0x321fff) AM_RAM_WRITE(bg_videoram_w) AM_BASE(&bg_videoram)
308   AM_RANGE(0x322000, 0x323fff) AM_RAM_WRITE(fg_videoram_w) AM_BASE(&fg_videoram)
309   AM_RANGE(0x800000, 0x80ffff) AM_RAM AM_BASE(&nmg5_bitmap)
342   AM_RANGE(0x320000, 0x321fff) AM_RAM_WRITE(bg_videoram_w) AM_BASE_MEMBER(nmg5_state, bg_videoram)
343   AM_RANGE(0x322000, 0x323fff) AM_RAM_WRITE(fg_videoram_w) AM_BASE_MEMBER(nmg5_state, fg_videoram)
344   AM_RANGE(0x800000, 0x80ffff) AM_RAM AM_BASE_MEMBER(nmg5_state, bitmap)
310345ADDRESS_MAP_END
311346
312347static ADDRESS_MAP_START( pclubys_map, ADDRESS_SPACE_PROGRAM, 16 )
313348   AM_RANGE(0x000000, 0x0fffff) AM_ROM
314349   AM_RANGE(0x200000, 0x20ffff) AM_RAM
315350   AM_RANGE(0x440000, 0x4407ff) AM_RAM_WRITE(paletteram16_xBBBBBGGGGGRRRRR_word_w) AM_BASE_GENERIC(paletteram)
316   AM_RANGE(0x460000, 0x4607ff) AM_RAM AM_BASE_SIZE_GENERIC(spriteram)
351   AM_RANGE(0x460000, 0x4607ff) AM_RAM AM_BASE_SIZE_MEMBER(nmg5_state, spriteram, spriteram_size)
317352   AM_RANGE(0x480000, 0x480001) AM_WRITE(nmg5_soundlatch_w)
318353   AM_RANGE(0x480002, 0x480003) AM_WRITENOP
319354   AM_RANGE(0x480004, 0x480005) AM_READWRITE(prot_r, prot_w)
r7500r7501
322357   AM_RANGE(0x48000a, 0x48000b) AM_READ_PORT("SYSTEM")
323358   AM_RANGE(0x48000c, 0x48000d) AM_READ_PORT("INPUTS")
324359   AM_RANGE(0x48000e, 0x48000f) AM_WRITE(priority_reg_w)
325   AM_RANGE(0x500002, 0x500009) AM_WRITEONLY AM_BASE(&scroll_ram)
326   AM_RANGE(0x520000, 0x521fff) AM_RAM_WRITE(bg_videoram_w) AM_BASE(&bg_videoram)
327   AM_RANGE(0x522000, 0x523fff) AM_RAM_WRITE(fg_videoram_w) AM_BASE(&fg_videoram)
328   AM_RANGE(0x800000, 0x80ffff) AM_RAM AM_BASE(&nmg5_bitmap)
360   AM_RANGE(0x500002, 0x500009) AM_WRITEONLY AM_BASE_MEMBER(nmg5_state, scroll_ram)
361   AM_RANGE(0x520000, 0x521fff) AM_RAM_WRITE(bg_videoram_w) AM_BASE_MEMBER(nmg5_state, bg_videoram)
362   AM_RANGE(0x522000, 0x523fff) AM_RAM_WRITE(fg_videoram_w) AM_BASE_MEMBER(nmg5_state, fg_videoram)
363   AM_RANGE(0x800000, 0x80ffff) AM_RAM AM_BASE_MEMBER(nmg5_state, bitmap)
329364ADDRESS_MAP_END
330365
331366/*******************************************************************
r7500r7501
789824INPUT_PORTS_END
790825
791826
792INLINE void get_tile_info(running_machine *machine,tile_data *tileinfo,int tile_index,UINT16 *vram,int color)
827INLINE void get_tile_info( running_machine *machine, tile_data *tileinfo, int tile_index, UINT16 *vram, int color )
793828{
794   SET_TILE_INFO(0,vram[tile_index] | (gfx_bank << 16),color,0);
829   nmg5_state *state = (nmg5_state *)machine->driver_data;
830   SET_TILE_INFO(0, vram[tile_index] | (state->gfx_bank << 16), color, 0);
795831}
796832
797static TILE_GET_INFO( fg_get_tile_info ) { get_tile_info(machine,tileinfo,tile_index,fg_videoram, 0); }
798static TILE_GET_INFO( bg_get_tile_info ) { get_tile_info(machine,tileinfo,tile_index,bg_videoram, 1); }
833static TILE_GET_INFO( fg_get_tile_info ) { nmg5_state *state = (nmg5_state *)machine->driver_data;   get_tile_info(machine, tileinfo, tile_index, state->fg_videoram, 0); }
834static TILE_GET_INFO( bg_get_tile_info ) { nmg5_state *state = (nmg5_state *)machine->driver_data;   get_tile_info(machine, tileinfo, tile_index, state->bg_videoram, 1); }
799835
800836static VIDEO_START( nmg5 )
801837{
802   bg_tilemap = tilemap_create(machine, bg_get_tile_info,tilemap_scan_rows,8,8,64,64);
803   fg_tilemap = tilemap_create(machine, fg_get_tile_info,tilemap_scan_rows,8,8,64,64);
838   nmg5_state *state = (nmg5_state *)machine->driver_data;
804839
805   tilemap_set_transparent_pen(fg_tilemap,0);
840   state->bg_tilemap = tilemap_create(machine, bg_get_tile_info, tilemap_scan_rows, 8, 8, 64, 64);
841   state->fg_tilemap = tilemap_create(machine, fg_get_tile_info, tilemap_scan_rows, 8, 8, 64, 64);
842   tilemap_set_transparent_pen(state->fg_tilemap, 0);
806843}
807844
808static void draw_sprites(running_machine *machine, bitmap_t *bitmap,const rectangle *cliprect)
845static void draw_sprites( running_machine *machine, bitmap_t *bitmap, const rectangle *cliprect )
809846{
810   UINT16 *spriteram16 = machine->generic.spriteram.u16;
847   nmg5_state *state = (nmg5_state *)machine->driver_data;
848   UINT16 *spriteram = state->spriteram;
811849   int offs;
812850
813   for (offs = 0;offs < machine->generic.spriteram_size/2;offs += 4)
851   for (offs = 0; offs < state->spriteram_size / 2; offs += 4)
814852   {
815      int sx,sy,code,color,flipx,flipy,height,y;
853      int sx, sy, code, color, flipx, flipy, height, y;
816854
817      sx = spriteram16[offs + 2];
818      sy = spriteram16[offs + 0];
819      code = spriteram16[offs + 1];
820      color = (spriteram16[offs + 2] >> 9) & 0xf;
821      height = 1 << ((spriteram16[offs + 0] & 0x0600) >> 9);
822      flipx = spriteram16[offs + 0] & 0x2000;
823      flipy = spriteram16[offs + 0] & 0x4000;
855      sx = spriteram[offs + 2];
856      sy = spriteram[offs + 0];
857      code = spriteram[offs + 1];
858      color = (spriteram[offs + 2] >> 9) & 0xf;
859      height = 1 << ((spriteram[offs + 0] & 0x0600) >> 9);
860      flipx = spriteram[offs + 0] & 0x2000;
861      flipy = spriteram[offs + 0] & 0x4000;
824862
825      for (y = 0;y < height;y++)
863      for (y = 0; y < height; y++)
826864      {
827865         drawgfx_transpen(bitmap,cliprect,machine->gfx[1],
828866               code + (flipy ? height-1 - y : y),
r7500r7501
840878   }
841879}
842880
843static void draw_bitmap(bitmap_t *bitmap)
881static void draw_bitmap( running_machine *machine, bitmap_t *bitmap )
844882{
845   int yyy=256;
846   int xxx=512/4;
847   UINT16 x,y,count;
848   int xoff=-12;
849   int yoff=-9;
883   nmg5_state *state = (nmg5_state *)machine->driver_data;
884   int yyy = 256;
885   int xxx = 512 / 4;
886   UINT16 x, y, count;
887   int xoff = -12;
888   int yoff = -9;
850889   int pix;
851890
852   count=0;
853   for (y=0;y<yyy;y++)
891   count = 0;
892   for (y = 0; y < yyy; y++)
854893   {
855      for(x=0;x<xxx;x++)
894      for (x = 0; x < xxx; x++)
856895      {
857         pix = (nmg5_bitmap[count]&0xf000)>>12;
858         if (pix) *BITMAP_ADDR16(bitmap, y+yoff, x*4+0+xoff) = pix + 0x300;
859         pix = (nmg5_bitmap[count]&0x0f00)>>8;
860         if (pix) *BITMAP_ADDR16(bitmap, y+yoff, x*4+1+xoff) = pix + 0x300;
861         pix = (nmg5_bitmap[count]&0x00f0)>>4;
862         if (pix) *BITMAP_ADDR16(bitmap, y+yoff, x*4+2+xoff) = pix + 0x300;
863         pix = (nmg5_bitmap[count]&0x000f)>>0;
864         if (pix) *BITMAP_ADDR16(bitmap, y+yoff, x*4+3+xoff) = pix + 0x300;
896         pix = (state->bitmap[count] & 0xf000) >> 12;
897         if (pix) *BITMAP_ADDR16(bitmap, y + yoff, x * 4 + 0 + xoff) = pix + 0x300;
898         pix = (state->bitmap[count] & 0x0f00) >> 8;
899         if (pix) *BITMAP_ADDR16(bitmap, y + yoff, x * 4 + 1 + xoff) = pix + 0x300;
900         pix = (state->bitmap[count] & 0x00f0) >> 4;
901         if (pix) *BITMAP_ADDR16(bitmap, y + yoff, x * 4 + 2 + xoff) = pix + 0x300;
902         pix = (state->bitmap[count] & 0x000f) >> 0;
903         if (pix) *BITMAP_ADDR16(bitmap, y + yoff, x * 4 + 3 + xoff) = pix + 0x300;
865904
866905         count++;
867906      }
r7500r7501
871910
872911static VIDEO_UPDATE( nmg5 )
873912{
874   tilemap_set_scrolly(bg_tilemap,0,scroll_ram[3]+9);
875   tilemap_set_scrollx(bg_tilemap,0,scroll_ram[2]+3);
876   tilemap_set_scrolly(fg_tilemap,0,scroll_ram[1]+9);
877   tilemap_set_scrollx(fg_tilemap,0,scroll_ram[0]-1);
913   nmg5_state *state = (nmg5_state *)screen->machine->driver_data;
878914
879   tilemap_draw(bitmap,cliprect,bg_tilemap,0,0);
915   tilemap_set_scrolly(state->bg_tilemap, 0, state->scroll_ram[3] + 9);
916   tilemap_set_scrollx(state->bg_tilemap, 0, state->scroll_ram[2] + 3);
917   tilemap_set_scrolly(state->fg_tilemap, 0, state->scroll_ram[1] + 9);
918   tilemap_set_scrollx(state->fg_tilemap, 0, state->scroll_ram[0] - 1);
880919
881   if(priority_reg == 0)
920   tilemap_draw(bitmap, cliprect, state->bg_tilemap, 0, 0);
921
922   if (state->priority_reg == 0)
882923   {
883      draw_sprites(screen->machine,bitmap,cliprect);
884      tilemap_draw(bitmap,cliprect,fg_tilemap,0,0);
885      draw_bitmap(bitmap);
924      draw_sprites(screen->machine, bitmap, cliprect);
925      tilemap_draw(bitmap, cliprect, state->fg_tilemap, 0, 0);
926      draw_bitmap(screen->machine, bitmap);
886927   }
887   else if(priority_reg == 1)
928   else if (state->priority_reg == 1)
888929   {
889      draw_bitmap(bitmap);
890      draw_sprites(screen->machine,bitmap,cliprect);
891      tilemap_draw(bitmap,cliprect,fg_tilemap,0,0);
930      draw_bitmap(screen->machine, bitmap);
931      draw_sprites(screen->machine, bitmap, cliprect);
932      tilemap_draw(bitmap, cliprect, state->fg_tilemap, 0, 0);
892933   }
893   else if(priority_reg == 2)
934   else if (state->priority_reg == 2)
894935   {
895      draw_sprites(screen->machine,bitmap,cliprect);
896      draw_bitmap(bitmap);
897      tilemap_draw(bitmap,cliprect,fg_tilemap,0,0);
936      draw_sprites(screen->machine, bitmap, cliprect);
937      draw_bitmap(screen->machine, bitmap);
938      tilemap_draw(bitmap, cliprect, state->fg_tilemap, 0, 0);
898939   }
899   else if(priority_reg == 3)
940   else if (state->priority_reg == 3)
900941   {
901      tilemap_draw(bitmap,cliprect,fg_tilemap,0,0);
902      draw_sprites(screen->machine,bitmap,cliprect);
903      draw_bitmap(bitmap);
942      tilemap_draw(bitmap, cliprect, state->fg_tilemap, 0, 0);
943      draw_sprites(screen->machine, bitmap, cliprect);
944      draw_bitmap(screen->machine, bitmap);
904945   }
905   else if(priority_reg == 7)
946   else if (state->priority_reg == 7)
906947   {
907      tilemap_draw(bitmap,cliprect,fg_tilemap,0,0);
908      draw_bitmap(bitmap);
909      draw_sprites(screen->machine,bitmap,cliprect);
948      tilemap_draw(bitmap, cliprect, state->fg_tilemap, 0, 0);
949      draw_bitmap(screen->machine, bitmap);
950      draw_sprites(screen->machine, bitmap, cliprect);
910951   }
911952   return 0;
912953}
r7500r7501
956997GFXDECODE_END
957998
958999
959static void soundirq(running_device *device, int state)
1000static void soundirq( running_device *device, int state )
9601001{
961   cputag_set_input_line(device->machine, "soundcpu", 0, state);
1002   nmg5_state *driver_state = (nmg5_state *)device->machine->driver_data;
1003   cpu_set_input_line(driver_state->soundcpu, 0, state);
9621004}
9631005
9641006static const ym3812_interface ym3812_intf =
r7500r7501
9681010
9691011static MACHINE_START( nmg5 )
9701012{
971   state_save_register_global(machine, gfx_bank);
972   state_save_register_global(machine, priority_reg);
973   state_save_register_global(machine, input_data);
1013   nmg5_state *state = (nmg5_state *)machine->driver_data;
1014
1015   state->maincpu = devtag_get_device(machine, "maincpu");
1016   state->soundcpu = devtag_get_device(machine, "soundcpu");
1017
1018   state_save_register_global(machine, state->gfx_bank);
1019   state_save_register_global(machine, state->priority_reg);
1020   state_save_register_global(machine, state->input_data);
9741021}
9751022
9761023static MACHINE_RESET( nmg5 )
9771024{
1025   nmg5_state *state = (nmg5_state *)machine->driver_data;
1026
9781027   /* some games don't set the priority register so it should be hard-coded to a normal layout */
979   priority_reg = 7;
1028   state->priority_reg = 7;
1029
1030   state->gfx_bank = 0;
1031   state->input_data = 0;
9801032}
9811033
9821034static MACHINE_DRIVER_START( nmg5 )
9831035
1036   /* driver data */
1037   MDRV_DRIVER_DATA(nmg5_state)
1038
9841039   /* basic machine hardware */
9851040   MDRV_CPU_ADD("maincpu", M68000, 16000000)   /* 16 MHz */
9861041   MDRV_CPU_PROGRAM_MAP(nmg5_map)
r7500r7501
14731528
14741529static DRIVER_INIT( prot_val_00 )
14751530{
1476   prot_val = 0x00;
1531   nmg5_state *state = (nmg5_state *)machine->driver_data;
1532   state->prot_val = 0x00;
14771533}
14781534
14791535static DRIVER_INIT( prot_val_10 )
14801536{
1481   prot_val = 0x10;
1537   nmg5_state *state = (nmg5_state *)machine->driver_data;
1538   state->prot_val = 0x10;
14821539}
14831540
14841541static DRIVER_INIT( prot_val_20 )
14851542{
1486   prot_val = 0x20;
1543   nmg5_state *state = (nmg5_state *)machine->driver_data;
1544   state->prot_val = 0x20;
14871545}
14881546
14891547static DRIVER_INIT( prot_val_40 )
14901548{
1491   prot_val = 0x40;
1549   nmg5_state *state = (nmg5_state *)machine->driver_data;
1550   state->prot_val = 0x40;
14921551}
14931552
14941553GAME( 1998, nmg5,     0,       nmg5,     nmg5,     prot_val_10, ROT0, "Yun Sung", "Multi 5 / New Multi Game 5", GAME_SUPPORTS_SAVE )
src/mame/drivers/2mindril.c
r7500r7501
4949#include "sound/2610intf.h"
5050
5151
52typedef struct __2mindril_state _2mindril_state;
53struct __2mindril_state
52class _2mindril_state
5453{
54public:
55   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, _2mindril_state(machine)); }
56
57   _2mindril_state(running_machine &machine) { }
58
5559   /* memory pointers */
5660   UINT16 *      map1ram;
5761   UINT16 *      map2ram;
src/mame/drivers/safarir.c
r7500r7501
5050#include "cpu/i8085/i8085.h"
5151#include "sound/samples.h"
5252
53typedef struct _safarir_state safarir_state;
54struct _safarir_state
53class safarir_state
5554{
55public:
56   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, safarir_state(machine)); }
57
58   safarir_state(running_machine &machine) { }
59
5660   UINT8 *ram_1, *ram_2;
5761   size_t ram_size;
5862   UINT8 ram_bank;
src/mame/drivers/jollyjgr.c
r7500r7501
102102#include "sound/ay8910.h"
103103
104104
105typedef struct _jollyjgr_state jollyjgr_state;
106struct _jollyjgr_state
105class jollyjgr_state
107106{
107public:
108   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, jollyjgr_state(machine)); }
109
110   jollyjgr_state(running_machine &machine) { }
111
108112   /* memory pointers */
109113   UINT8 *  videoram;
110114   UINT8 *  colorram;
src/mame/drivers/ddayjlc.c
r7500r7501
5656#include "sound/ay8910.h"
5757
5858
59typedef struct _ddayjlc_state ddayjlc_state;
60struct _ddayjlc_state
59class ddayjlc_state
6160{
61public:
62   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, ddayjlc_state(machine)); }
63
64   ddayjlc_state(running_machine &machine) { }
65
6266   /* memory pointers */
6367   UINT8 *  bgram;
6468   UINT8 *  mainram;
src/mame/drivers/dorachan.c
r7500r7501
1616#define NUM_PENS   (8)
1717
1818
19typedef struct _dorachan_state dorachan_state;
20struct _dorachan_state
19class dorachan_state
2120{
21public:
22   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, dorachan_state(machine)); }
23
24   dorachan_state(running_machine &machine) { }
25
2226   /* memory pointers */
2327   UINT8 *  videoram;
2428   size_t   videoram_size;
src/mame/drivers/egghunt.c
r7500r7501
4545#include "cpu/z80/z80.h"
4646#include "sound/okim6295.h"
4747
48typedef struct _egghunt_state egghunt_state;
49struct _egghunt_state
48class egghunt_state
5049{
50public:
51   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, egghunt_state(machine)); }
52
53   egghunt_state(running_machine &machine) { }
54
5155   /* memory pointers */
5256   UINT8 *   bgram;
5357   UINT8 *   atram;
src/mame/drivers/mugsmash.c
r7500r7501
4949static WRITE16_HANDLER( mugsmash_reg2_w )
5050{
5151   mugsmash_state *state = (mugsmash_state *)space->machine->driver_data;
52
5253   state->regs2[offset] = data;
5354   //popmessage ("Regs2 %04x, %04x, %04x, %04x", state->regs2[0], state->regs2[1], state->regs2[2], state->regs2[3]);
5455
r7500r7501
5657   {
5758   case 1:
5859      soundlatch_w(space, 1, data & 0xff);
59      cputag_set_input_line(space->machine, "audiocpu", INPUT_LINE_NMI, PULSE_LINE );
60      cpu_set_input_line(state->audiocpu, INPUT_LINE_NMI, PULSE_LINE );
6061      break;
6162
6263   default:
r7500r7501
173174
174175static ADDRESS_MAP_START( mugsmash_map, ADDRESS_SPACE_PROGRAM, 16 )
175176   AM_RANGE(0x000000, 0x07ffff) AM_ROM
176   AM_RANGE(0x080000, 0x080fff) AM_RAM_WRITE(mugsmash_videoram1_w) AM_BASE_MEMBER(mugsmash_state,videoram1)
177   AM_RANGE(0x082000, 0x082fff) AM_RAM_WRITE(mugsmash_videoram2_w) AM_BASE_MEMBER(mugsmash_state,videoram2)
178   AM_RANGE(0x0c0000, 0x0c0007) AM_WRITE(mugsmash_reg_w) AM_BASE_MEMBER(mugsmash_state,regs1)   /* video registers*/
177   AM_RANGE(0x080000, 0x080fff) AM_RAM_WRITE(mugsmash_videoram1_w) AM_BASE_MEMBER(mugsmash_state, videoram1)
178   AM_RANGE(0x082000, 0x082fff) AM_RAM_WRITE(mugsmash_videoram2_w) AM_BASE_MEMBER(mugsmash_state, videoram2)
179   AM_RANGE(0x0c0000, 0x0c0007) AM_WRITE(mugsmash_reg_w) AM_BASE_MEMBER(mugsmash_state, regs1)   /* video registers*/
179180   AM_RANGE(0x100000, 0x1005ff) AM_RAM_WRITE(paletteram16_xRRRRRGGGGGBBBBB_word_w) AM_BASE_GENERIC(paletteram)
180   AM_RANGE(0x140000, 0x140007) AM_WRITE(mugsmash_reg2_w) AM_BASE_MEMBER(mugsmash_state,regs2) /* sound + ? */
181   AM_RANGE(0x140000, 0x140007) AM_WRITE(mugsmash_reg2_w) AM_BASE_MEMBER(mugsmash_state, regs2) /* sound + ? */
181182   AM_RANGE(0x1c0000, 0x1c3fff) AM_RAM /* main ram? */
182183   AM_RANGE(0x1c4000, 0x1cffff) AM_RAM
183   AM_RANGE(0x200000, 0x203fff) AM_RAM AM_BASE_MEMBER(mugsmash_state,spriteram) /* sprite ram */
184   AM_RANGE(0x200000, 0x203fff) AM_RAM AM_BASE_MEMBER(mugsmash_state, spriteram) /* sprite ram */
184185#if USE_FAKE_INPUT_PORTS
185186   AM_RANGE(0x180000, 0x180007) AM_READ(mugsmash_input_ports_r)
186187#else
r7500r7501
390391
391392static void irq_handler(running_device *device, int irq)
392393{
393   cputag_set_input_line(device->machine, "audiocpu", 0 , irq ? ASSERT_LINE : CLEAR_LINE );
394   mugsmash_state *state = (mugsmash_state *)device->machine->driver_data;
395   cpu_set_input_line(state->audiocpu, 0 , irq ? ASSERT_LINE : CLEAR_LINE );
394396}
395397
396398static const ym2151_interface ym2151_config =
r7500r7501
398400   irq_handler
399401};
400402
403static MACHINE_START( mugsmash )
404{
405   mugsmash_state *state = (mugsmash_state *)machine->driver_data;
406
407   state->maincpu = devtag_get_device(machine, "maincpu");
408   state->audiocpu = devtag_get_device(machine, "audiocpu");
409}
410
401411static MACHINE_DRIVER_START( mugsmash )
402412
403413   MDRV_DRIVER_DATA( mugsmash_state )
r7500r7501
409419   MDRV_CPU_ADD("audiocpu", Z80, 4000000)   /* Guess */
410420   MDRV_CPU_PROGRAM_MAP(mugsmash_sound_map)
411421
422   MDRV_MACHINE_START(mugsmash)
423
412424   MDRV_SCREEN_ADD("screen", RASTER)
413425   MDRV_SCREEN_REFRESH_RATE(60)
414426   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(0))
r7500r7501
462474   ROM_LOAD( "mugs_15.bin", 0x180000, 0x080000, CRC(82e8187c) SHA1(c7a0e1b3d90dbbe2588886a27a07a9c336447ae3) )
463475ROM_END
464476
465GAME( 1990?, mugsmash, 0, mugsmash, mugsmash, 0, ROT0, "Electronic Devices Italy / 3D Games England", "Mug Smashers", 0 )
477GAME( 1990?, mugsmash, 0, mugsmash, mugsmash, 0, ROT0, "Electronic Devices Italy / 3D Games England", "Mug Smashers", GAME_SUPPORTS_SAVE )
src/mame/drivers/macrossp.c
r7500r7501
3434 lev 6 : 0x78 : 001f 002a - x
3535 lev 7 : 0x7c : 001f 002a - x
3636
37******************************************************************************/
3837
39#include "emu.h"
40#include "cpu/m68000/m68000.h"
41#include "sound/es5506.h"
38**** README INFO **************************************************************
4239
43/*** README INFO **************************************************************
44
4540--- ROMSET: macrossp ---
4641
4742Macross Plus
r7500r7501
301296
302297******************************************************************************/
303298
304extern UINT32 *macrossp_scra_videoram, *macrossp_scra_videoregs;
305extern UINT32 *macrossp_scrb_videoram, *macrossp_scrb_videoregs;
306extern UINT32 *macrossp_scrc_videoram, *macrossp_scrc_videoregs;
307extern UINT32 *macrossp_text_videoram, *macrossp_text_videoregs;
308extern UINT32 *macrossp_spriteram;
309299
310static UINT32 *macrossp_mainram;
300#include "emu.h"
301#include "cpu/m68000/m68000.h"
302#include "sound/es5506.h"
303#include "includes/macrossp.h"
311304
312/* in video */
313WRITE32_HANDLER( macrossp_scra_videoram_w );
314WRITE32_HANDLER( macrossp_scrb_videoram_w );
315WRITE32_HANDLER( macrossp_scrc_videoram_w );
316WRITE32_HANDLER( macrossp_text_videoram_w );
317VIDEO_START(macrossp);
318VIDEO_UPDATE(macrossp);
319VIDEO_EOF(macrossp);
320
321305/*** VARIOUS READ / WRITE HANDLERS *******************************************/
322306
323307static WRITE32_HANDLER( paletteram32_macrossp_w )
324308{
309   macrossp_state *state = (macrossp_state *)space->machine->driver_data;
325310   int r,g,b;
326   COMBINE_DATA(&space->machine->generic.paletteram.u32[offset]);
311   COMBINE_DATA(&state->paletteram[offset]);
327312
328   b = ((space->machine->generic.paletteram.u32[offset] & 0x0000ff00) >>8);
329   g = ((space->machine->generic.paletteram.u32[offset] & 0x00ff0000) >>16);
330   r = ((space->machine->generic.paletteram.u32[offset] & 0xff000000) >>24);
313   b = ((state->paletteram[offset] & 0x0000ff00) >>8);
314   g = ((state->paletteram[offset] & 0x00ff0000) >>16);
315   r = ((state->paletteram[offset] & 0xff000000) >>24);
331316
332   palette_set_color(space->machine,offset,MAKE_RGB(r,g,b));
317   palette_set_color(space->machine, offset, MAKE_RGB(r,g,b));
333318}
334319
335320
336static int sndpending;
337
338321static READ32_HANDLER ( macrossp_soundstatus_r )
339322{
340   static int toggle;
323   macrossp_state *state = (macrossp_state *)space->machine->driver_data;
341324
342//  logerror("%08x read soundstatus\n",cpu_get_pc(space->cpu));
325   //  logerror("%08x read soundstatus\n", cpu_get_pc(space->cpu));
343326
344327   /* bit 1 is sound status */
345328   /* bit 0 unknown - it is expected to toggle, vblank? */
346329
347   toggle ^= 1;
330   state->snd_toggle ^= 1;
348331
349   return (sndpending << 1) | toggle;
332   return (state->sndpending << 1) | state->snd_toggle;
350333}
351334
352335static WRITE32_HANDLER( macrossp_soundcmd_w )
353336{
337   macrossp_state *state = (macrossp_state *)space->machine->driver_data;
338
354339   if (ACCESSING_BITS_16_31)
355340   {
356341      //logerror("%08x write soundcmd %08x (%08x)\n",cpu_get_pc(space->cpu),data,mem_mask);
357342      soundlatch_word_w(space, 0, data >> 16, 0xffff);
358      sndpending = 1;
359      cputag_set_input_line(space->machine, "audiocpu", 2, HOLD_LINE);
343      state->sndpending = 1;
344      cpu_set_input_line(state->audiocpu, 2, HOLD_LINE);
360345      /* spin for a while to let the sound CPU read the command */
361346      cpu_spinuntil_time(space->cpu, ATTOTIME_IN_USEC(50));
362347   }
r7500r7501
364349
365350static READ16_HANDLER( macrossp_soundcmd_r )
366351{
367//  logerror("%06x read soundcmd\n",cpu_get_pc(space->cpu));
368   sndpending = 0;
352   macrossp_state *state = (macrossp_state *)space->machine->driver_data;
353
354   //  logerror("%06x read soundcmd\n",cpu_get_pc(space->cpu));
355   state->sndpending = 0;
369356   return soundlatch_word_r(space, offset, mem_mask);
370357}
371358
372static INT32 fade_effect,old_fade;
373
374static void update_colors(running_machine *machine)
359static void update_colors( running_machine *machine )
375360{
376   static int i,r,g,b;
361   macrossp_state *state = (macrossp_state *)machine->driver_data;
362   int i, r, g, b;
377363
378   for(i=0;i<0x1000;i++)
364   for (i = 0; i < 0x1000; i++)
379365   {
380      b = ((machine->generic.paletteram.u32[i] & 0x0000ff00) >> 8);
381      if(fade_effect > b) { b = 0; }
382      else            { b-=fade_effect; }
383      g = ((machine->generic.paletteram.u32[i] & 0x00ff0000) >>16);
384      if(fade_effect > g) { g = 0; }
385      else            { g-=fade_effect; }
386      r = ((machine->generic.paletteram.u32[i] & 0xff000000) >>24);
387      if(fade_effect > r) { r = 0; }
388      else            { r-=fade_effect; }
366      b = ((state->paletteram[i] & 0x0000ff00) >>  8);
367      g = ((state->paletteram[i] & 0x00ff0000) >> 16);
368      r = ((state->paletteram[i] & 0xff000000) >> 24);
389369
390      palette_set_color(machine,i,MAKE_RGB(r,g,b));
370      if (state->fade_effect > b)
371         b = 0;
372      else
373         b -= state->fade_effect;
374
375      if (state->fade_effect > g)
376         g = 0;
377      else
378         g -= state->fade_effect;
379
380      if (state->fade_effect > r)
381         r = 0;
382      else
383         r -= state->fade_effect;
384
385      palette_set_color(machine, i, MAKE_RGB(r, g, b));
391386   }
392387}
393388
394389static WRITE32_HANDLER( macrossp_palette_fade_w )
395390{
396   fade_effect = ((data & 0xff00) >> 8) - 0x28;//it writes two times,first with a -0x28 then with the proper data
397//  popmessage("%02x",fade_effect);
398   if(old_fade != fade_effect)
391   macrossp_state *state = (macrossp_state *)space->machine->driver_data;
392
393   state->fade_effect = ((data & 0xff00) >> 8) - 0x28; //it writes two times, first with a -0x28 then with the proper data
394   //  popmessage("%02x",fade_effect);
395
396   if (state->old_fade != state->fade_effect)
399397   {
400      old_fade = fade_effect;
398      state->old_fade = state->fade_effect;
401399      update_colors(space->machine);
402400   }
403401}
r7500r7501
406404
407405static ADDRESS_MAP_START( macrossp_map, ADDRESS_SPACE_PROGRAM, 32 )
408406   AM_RANGE(0x000000, 0x3fffff) AM_ROM
409   AM_RANGE(0x800000, 0x802fff) AM_RAM AM_BASE(&macrossp_spriteram) AM_SIZE_GENERIC(spriteram)
407   AM_RANGE(0x800000, 0x802fff) AM_RAM AM_BASE_SIZE_MEMBER(macrossp_state, spriteram, spriteram_size)
410408   /* SCR A Layer */
411   AM_RANGE(0x900000, 0x903fff) AM_RAM_WRITE(macrossp_scra_videoram_w) AM_BASE(&macrossp_scra_videoram)
409   AM_RANGE(0x900000, 0x903fff) AM_RAM_WRITE(macrossp_scra_videoram_w) AM_BASE_MEMBER(macrossp_state, scra_videoram)
412410   AM_RANGE(0x904200, 0x9043ff) AM_WRITEONLY /* W/O? */
413   AM_RANGE(0x905000, 0x90500b) AM_WRITEONLY AM_BASE(&macrossp_scra_videoregs) /* W/O? */
411   AM_RANGE(0x905000, 0x90500b) AM_WRITEONLY AM_BASE_MEMBER(macrossp_state, scra_videoregs) /* W/O? */
414412   /* SCR B Layer */
415   AM_RANGE(0x908000, 0x90bfff) AM_RAM_WRITE(macrossp_scrb_videoram_w) AM_BASE(&macrossp_scrb_videoram)
413   AM_RANGE(0x908000, 0x90bfff) AM_RAM_WRITE(macrossp_scrb_videoram_w) AM_BASE_MEMBER(macrossp_state, scrb_videoram)
416414   AM_RANGE(0x90c200, 0x90c3ff) AM_WRITEONLY /* W/O? */
417   AM_RANGE(0x90d000, 0x90d00b) AM_WRITEONLY AM_BASE(&macrossp_scrb_videoregs) /* W/O? */
415   AM_RANGE(0x90d000, 0x90d00b) AM_WRITEONLY AM_BASE_MEMBER(macrossp_state, scrb_videoregs) /* W/O? */
418416   /* SCR C Layer */
419   AM_RANGE(0x910000, 0x913fff) AM_RAM_WRITE(macrossp_scrc_videoram_w) AM_BASE(&macrossp_scrc_videoram)
417   AM_RANGE(0x910000, 0x913fff) AM_RAM_WRITE(macrossp_scrc_videoram_w) AM_BASE_MEMBER(macrossp_state, scrc_videoram)
420418   AM_RANGE(0x914200, 0x9143ff) AM_WRITEONLY /* W/O? */
421   AM_RANGE(0x915000, 0x91500b) AM_WRITEONLY AM_BASE(&macrossp_scrc_videoregs) /* W/O? */
419   AM_RANGE(0x915000, 0x91500b) AM_WRITEONLY AM_BASE_MEMBER(macrossp_state, scrc_videoregs) /* W/O? */
422420   /* Text Layer */
423   AM_RANGE(0x918000, 0x91bfff) AM_RAM_WRITE(macrossp_text_videoram_w) AM_BASE(&macrossp_text_videoram)
421   AM_RANGE(0x918000, 0x91bfff) AM_RAM_WRITE(macrossp_text_videoram_w) AM_BASE_MEMBER(macrossp_state, text_videoram)
424422   AM_RANGE(0x91c200, 0x91c3ff) AM_WRITEONLY /* W/O? */
425   AM_RANGE(0x91d000, 0x91d00b) AM_WRITEONLY AM_BASE(&macrossp_text_videoregs) /* W/O? */
423   AM_RANGE(0x91d000, 0x91d00b) AM_WRITEONLY AM_BASE_MEMBER(macrossp_state, text_videoregs) /* W/O? */
426424
427   AM_RANGE(0xa00000, 0xa03fff) AM_RAM_WRITE(paletteram32_macrossp_w) AM_BASE_GENERIC(paletteram)
425   AM_RANGE(0xa00000, 0xa03fff) AM_RAM_WRITE(paletteram32_macrossp_w) AM_BASE_MEMBER(macrossp_state, paletteram)
428426
429427   AM_RANGE(0xb00000, 0xb00003) AM_READ_PORT("INPUTS")
430428   AM_RANGE(0xb00004, 0xb00007) AM_READ(macrossp_soundstatus_r) AM_WRITENOP // irq related?
r7500r7501
435433
436434   AM_RANGE(0xc00000, 0xc00003) AM_WRITE(macrossp_soundcmd_w)
437435
438   AM_RANGE(0xf00000, 0xf1ffff) AM_RAM AM_BASE(&macrossp_mainram) /* Main Ram */
436   AM_RANGE(0xf00000, 0xf1ffff) AM_RAM AM_BASE_MEMBER(macrossp_state, mainram) /* Main Ram */
439437//  AM_RANGE(0xfe0000, 0xfe0003) AM_NOP
440438ADDRESS_MAP_END
441439
r7500r7501
586584
587585static void irqhandler(running_device *device, int irq)
588586{
589   logerror("ES5506 irq %d\n",irq);
587   // macrossp_state *state = (macrossp_state *)space->machine->driver_data;
588   logerror("ES5506 irq %d\n", irq);
590589
591590   /* IRQ lines 1 & 4 on the sound 68000 are definitely triggered by the ES5506,
592591    but I haven't noticed the ES5506 ever assert the line - maybe only used when developing the game? */
593//  cputag_set_input_line(device, "audiocpu", 1, irq ? ASSERT_LINE : CLEAR_LINE);
592   //  cpu_set_input_line(state->audiocpu, 1, irq ? ASSERT_LINE : CLEAR_LINE);
594593}
595594
596595static const es5506_interface es5506_config =
r7500r7501
603602};
604603
605604
605static MACHINE_START( macrossp )
606{
607   macrossp_state *state = (macrossp_state *)machine->driver_data;
608
609   state->maincpu = devtag_get_device(machine, "maincpu");
610   state->audiocpu = devtag_get_device(machine, "audiocpu");
611
612   state_save_register_global(machine, state->sndpending);
613   state_save_register_global(machine, state->snd_toggle);
614   state_save_register_global(machine, state->fade_effect);
615   state_save_register_global(machine, state->old_fade);
616}
617
618static MACHINE_RESET( macrossp )
619{
620   macrossp_state *state = (macrossp_state *)machine->driver_data;
621
622   state->sndpending = 0;
623   state->snd_toggle = 0;
624   state->fade_effect = 0;
625   state->old_fade = 0;
626}
627
606628static MACHINE_DRIVER_START( macrossp )
629
630   /* driver data */
631   MDRV_DRIVER_DATA(macrossp_state)
632
607633   /* basic machine hardware */
608634   MDRV_CPU_ADD("maincpu", M68EC020, 50000000/2)   /* 25 MHz */
609635   MDRV_CPU_PROGRAM_MAP(macrossp_map)
r7500r7501
612638   MDRV_CPU_ADD("audiocpu", M68000, 32000000/2)   /* 16 MHz */
613639   MDRV_CPU_PROGRAM_MAP(macrossp_sound_map)
614640
641   MDRV_MACHINE_START(macrossp)
642   MDRV_MACHINE_RESET(macrossp)
643
615644   /* video hardware */
616645   MDRV_SCREEN_ADD("screen", RASTER)
617646   MDRV_SCREEN_REFRESH_RATE(60)
r7500r7501
749778PC :0001810A 01810A: cmp.w   $f10140.l, D0
750779PC :00018110 018110: beq     18104
751780*/
752   COMBINE_DATA(&macrossp_mainram[0x10158/4]);
753   if (cpu_get_pc(space->cpu)==0x001810A) cpu_spinuntil_int(space->cpu);
781   macrossp_state *state = (macrossp_state *)space->machine->driver_data;
782
783   COMBINE_DATA(&state->mainram[0x10158 / 4]);
784   if (cpu_get_pc(space->cpu) == 0x001810A) cpu_spinuntil_int(space->cpu);
754785}
755786
756787#ifdef UNUSED_FUNCTION
757788static WRITE32_HANDLER( quizmoon_speedup_w )
758789{
759   COMBINE_DATA(&macrossp_mainram[0x00020/4]);
760   if (cpu_get_pc(space->cpu)==0x1cc) cpu_spinuntil_int(space->cpu);
790   macrossp_state *state = (macrossp_state *)space->machine->driver_data;
791
792   COMBINE_DATA(&state->mainram[0x00020 / 4]);
793   if (cpu_get_pc(space->cpu) == 0x1cc) cpu_spinuntil_int(space->cpu);
761794}
762795#endif
763796
r7500r7501
773806#endif
774807}
775808
776GAME( 1996, macrossp, 0, macrossp, macrossp, macrossp, ROT270, "Banpresto", "Macross Plus", GAME_IMPERFECT_GRAPHICS )
777GAME( 1997, quizmoon, 0, quizmoon, quizmoon, quizmoon, ROT0,   "Banpresto", "Quiz Bisyoujo Senshi Sailor Moon - Chiryoku Tairyoku Toki no Un", GAME_IMPERFECT_GRAPHICS )
809GAME( 1996, macrossp, 0, macrossp, macrossp, macrossp, ROT270, "Banpresto", "Macross Plus", GAME_IMPERFECT_GRAPHICS | GAME_SUPPORTS_SAVE )
810GAME( 1997, quizmoon, 0, quizmoon, quizmoon, quizmoon, ROT0,   "Banpresto", "Quiz Bisyoujo Senshi Sailor Moon - Chiryoku Tairyoku Toki no Un", GAME_IMPERFECT_GRAPHICS | GAME_SUPPORTS_SAVE )
src/mame/drivers/imolagp.c
r7500r7501
8383#define HLE_COM
8484
8585
86typedef struct _imolagp_state imolagp_state;
87struct _imolagp_state
86class imolagp_state
8887{
88public:
89   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, imolagp_state(machine)); }
90
91   imolagp_state(running_machine &machine) { }
92
8993   UINT8 *slave_workram; // used only ifdef HLE_COM
9094
9195#ifdef HLE_COM
src/mame/drivers/hotblock.c
r7500r7501
4545#include "cpu/i86/i86.h"
4646#include "sound/ay8910.h"
4747
48typedef struct _hotblock_state hotblock_state;
49struct _hotblock_state
48class hotblock_state
5049{
50public:
51   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, hotblock_state(machine)); }
52
53   hotblock_state(running_machine &machine) { }
54
5155   /* memory pointers */
5256   UINT8 *  vram;
5357   UINT8 *  pal;
src/mame/drivers/segas16b.c
r7500r7501
10721072   state_save_register_global(machine, state->mj_last_val);
10731073   state_save_register_global(machine, state->hwc_input_value);
10741074   state_save_register_global(machine, state->atomicp_sound_divisor);
1075   state_save_register_global(machine, state->atomicp_sound_count);
10761075   state_save_register_global_pointer(machine, segaic16_spriteram_0, 0x00800/2);
10771076   state_save_register_global_pointer(machine, segaic16_paletteram,  0x01000/2);
10781077   state_save_register_global_pointer(machine, segaic16_tileram_0,   0x10000/2);
src/mame/drivers/pktgaldx.c
r7500r7501
5656#include "cpu/m68000/m68000.h"
5757#include "includes/decocrpt.h"
5858#include "includes/decoprot.h"
59#include "includes/deco16ic.h"
59#include "video/deco16ic.h"
6060#include "sound/okim6295.h"
61#include "includes/pktgaldx.h"
6162
62VIDEO_START(pktgaldx);
63VIDEO_UPDATE(pktgaldx);
64VIDEO_START(pktgaldb);
65VIDEO_UPDATE(pktgaldb);
6663
67extern UINT16* pcktgaldb_fgram;
68extern UINT16* pcktgaldb_sprites;
69
7064/**********************************************************************************/
7165
7266static WRITE16_DEVICE_HANDLER(pktgaldx_oki_bank_w)
r7500r7501
7973static ADDRESS_MAP_START( pktgaldx_map, ADDRESS_SPACE_PROGRAM, 16 )
8074   AM_RANGE(0x000000, 0x07ffff) AM_ROM
8175
82   AM_RANGE(0x100000, 0x100fff) AM_RAM_WRITE(deco16_pf1_data_w) AM_BASE(&deco16_pf1_data)
83   AM_RANGE(0x102000, 0x102fff) AM_RAM_WRITE(deco16_pf2_data_w) AM_BASE(&deco16_pf2_data)
84   AM_RANGE(0x110000, 0x1107ff) AM_RAM AM_BASE(&deco16_pf1_rowscroll)
85   AM_RANGE(0x112000, 0x1127ff) AM_RAM AM_BASE(&deco16_pf2_rowscroll)
76   AM_RANGE(0x100000, 0x100fff) AM_DEVREADWRITE("deco_custom", deco16ic_pf1_data_r, deco16ic_pf1_data_w)
77   AM_RANGE(0x102000, 0x102fff) AM_DEVREADWRITE("deco_custom", deco16ic_pf2_data_r, deco16ic_pf2_data_w)
78   AM_RANGE(0x110000, 0x1107ff) AM_RAM AM_BASE_MEMBER(pktgaldx_state, pf1_rowscroll)
79   AM_RANGE(0x112000, 0x1127ff) AM_RAM AM_BASE_MEMBER(pktgaldx_state, pf2_rowscroll)
8680
87   AM_RANGE(0x120000, 0x1207ff) AM_RAM AM_BASE_SIZE_GENERIC(spriteram)
88   AM_RANGE(0x130000, 0x130fff) AM_RAM_WRITE(deco16_nonbuffered_palette_w) AM_BASE_GENERIC(paletteram)
81   AM_RANGE(0x120000, 0x1207ff) AM_RAM AM_BASE_SIZE_MEMBER(pktgaldx_state, spriteram, spriteram_size)
82   AM_RANGE(0x130000, 0x130fff) AM_RAM_DEVWRITE("deco_custom", deco16ic_nonbuffered_palette_w) AM_BASE_GENERIC(paletteram)
8983
9084   AM_RANGE(0x140000, 0x14000f) AM_DEVWRITE8("oki1", okim6295_w, 0x00ff)
9185   AM_RANGE(0x140006, 0x140007) AM_DEVREAD8("oki1", okim6295_r, 0x00ff)
9286   AM_RANGE(0x150000, 0x15000f) AM_DEVWRITE8("oki2", okim6295_w, 0x00ff)
9387   AM_RANGE(0x150006, 0x150007) AM_DEVREAD8("oki2", okim6295_r, 0x00ff)
9488
95   AM_RANGE(0x161800, 0x16180f) AM_WRITEONLY AM_BASE(&deco16_pf12_control)
89   AM_RANGE(0x161800, 0x16180f) AM_DEVWRITE("deco_custom", deco16ic_pf12_control_w)
9690   AM_RANGE(0x164800, 0x164801) AM_DEVWRITE("oki2", pktgaldx_oki_bank_w)
9791   AM_RANGE(0x167800, 0x167fff) AM_READWRITE(deco16_104_pktgaldx_prot_r,deco16_104_pktgaldx_prot_w) AM_BASE(&deco16_prot_ram)
9892   AM_RANGE(0x170000, 0x17ffff) AM_RAM
r7500r7501
127121
128122static ADDRESS_MAP_START( pktgaldb_map, ADDRESS_SPACE_PROGRAM, 16 )
129123   AM_RANGE(0x000000, 0x0fffff) AM_ROM
130   AM_RANGE(0x100000, 0x100fff) AM_RAM AM_BASE(&pcktgaldb_fgram) // fgram on original?
124   AM_RANGE(0x100000, 0x100fff) AM_RAM AM_BASE_MEMBER(pktgaldx_state, pktgaldb_fgram) // fgram on original?
131125   AM_RANGE(0x102000, 0x102fff) AM_RAM // bgram on original?
132   AM_RANGE(0x120000, 0x123fff) AM_RAM AM_BASE(&pcktgaldb_sprites)
126   AM_RANGE(0x120000, 0x123fff) AM_RAM AM_BASE_MEMBER(pktgaldx_state, pktgaldb_sprites)
133127
134128   AM_RANGE(0x130000, 0x130fff) AM_RAM // palette on original?
135129
r7500r7501
298292GFXDECODE_END
299293
300294
295static int pktgaldx_bank_callback( const int bank )
296{
297   return ((bank >> 4) & 0x7) * 0x1000;
298}
299
300static const deco16ic_interface pktgaldx_deco16ic_intf =
301{
302   "screen",
303   1, 0, 1,
304   0x0f, 0x0f, 0x0f, 0x0f,   /* trans masks (default values) */
305   0, 16, 0, 16, /* color base (default values) */
306   0x0f, 0x0f, 0x0f, 0x0f,   /* color masks (default values) */
307   NULL,
308   pktgaldx_bank_callback,
309   NULL,
310   NULL
311};
312
313static MACHINE_START( pktgaldx )
314{
315   pktgaldx_state *state = (pktgaldx_state *)machine->driver_data;
316
317   state->maincpu = devtag_get_device(machine, "maincpu");
318   state->deco16ic = devtag_get_device(machine, "deco_custom");
319}
320
301321static MACHINE_DRIVER_START( pktgaldx )
322
323   /* driver data */
324   MDRV_DRIVER_DATA(pktgaldx_state)
325
302326   /* basic machine hardware */
303327   MDRV_CPU_ADD("maincpu", M68000, 14000000)
304328   MDRV_CPU_PROGRAM_MAP(pktgaldx_map)
305329   MDRV_CPU_VBLANK_INT("screen", irq6_line_hold)
306330
331   MDRV_MACHINE_START(pktgaldx)
332
307333   /* video hardware */
308334   MDRV_SCREEN_ADD("screen", RASTER)
309335   MDRV_SCREEN_REFRESH_RATE(58)
r7500r7501
315341   MDRV_PALETTE_LENGTH(4096)
316342   MDRV_GFXDECODE(pktgaldx)
317343
318   MDRV_VIDEO_START(pktgaldx)
319344   MDRV_VIDEO_UPDATE(pktgaldx)
320345
346   MDRV_DECO16IC_ADD("deco_custom", pktgaldx_deco16ic_intf)
347
321348   /* sound hardware */
322349   MDRV_SPEAKER_STANDARD_STEREO("lspeaker", "rspeaker")
323350
r7500r7501
334361
335362
336363static MACHINE_DRIVER_START( pktgaldb )
364
365   /* driver data */
366   MDRV_DRIVER_DATA(pktgaldx_state)
367
337368   /* basic machine hardware */
338369   MDRV_CPU_ADD("maincpu", M68000, 16000000)
339370   MDRV_CPU_PROGRAM_MAP(pktgaldb_map)
340371   MDRV_CPU_VBLANK_INT("screen", irq6_line_hold)
341372
373   MDRV_MACHINE_START(pktgaldx)
374
342375   /* video hardware */
343376   MDRV_SCREEN_ADD("screen", RASTER)
344377   MDRV_SCREEN_REFRESH_RATE(58)
r7500r7501
350383   MDRV_PALETTE_LENGTH(4096)
351384   MDRV_GFXDECODE(bootleg)
352385
353   MDRV_VIDEO_START(pktgaldb)
354386   MDRV_VIDEO_UPDATE(pktgaldb)
355387
356388   /* sound hardware */
r7500r7501
433465   deco102_decrypt_cpu(machine, "maincpu", 0x42ba, 0x00, 0x00);
434466}
435467
436GAME( 1992, pktgaldx,  0,        pktgaldx, pktgaldx, pktgaldx,  ROT0, "Data East Corporation", "Pocket Gal Deluxe (Euro v3.00)", 0 )
437GAME( 1993, pktgaldxj, pktgaldx, pktgaldx, pktgaldx, pktgaldx,  ROT0, "Nihon System",          "Pocket Gal Deluxe (Japan v3.00)", 0 )
438GAME( 1992, pktgaldxb, pktgaldx, pktgaldb, pktgaldx, 0,         ROT0, "bootleg",               "Pocket Gal Deluxe (Euro v3.00, bootleg)", GAME_IMPERFECT_GRAPHICS )
468GAME( 1992, pktgaldx,  0,        pktgaldx, pktgaldx, pktgaldx,  ROT0, "Data East Corporation", "Pocket Gal Deluxe (Euro v3.00)", GAME_SUPPORTS_SAVE )
469GAME( 1993, pktgaldxj, pktgaldx, pktgaldx, pktgaldx, pktgaldx,  ROT0, "Nihon System",          "Pocket Gal Deluxe (Japan v3.00)", GAME_SUPPORTS_SAVE )
470GAME( 1992, pktgaldxb, pktgaldx, pktgaldb, pktgaldx, 0,         ROT0, "bootleg",               "Pocket Gal Deluxe (Euro v3.00, bootleg)", GAME_IMPERFECT_GRAPHICS | GAME_SUPPORTS_SAVE )
src/mame/drivers/circus.c
r7500r7501
537537   ROM_LOAD( "crash.d14",    0x0000, 0x0200, CRC(833f81e4) SHA1(78a0ace3510546691ecaf6f6275cb3269495edc9) )  /* Cars */
538538ROM_END
539539
540ROM_START( smash )
541   ROM_REGION( 0x10000, "maincpu", 0 )
542   ROM_LOAD( "smash.a1",     0x1000, 0x0200, CRC(b9571203) SHA1(1299e476598d07a67aa1640f3320de1198280296) ) /* Code */
543   ROM_LOAD( "smash.a2",     0x1200, 0x0200, CRC(b4581a95) SHA1(b3662bda5013443a56eabbe21fefa91e255e18e7) )
544   ROM_LOAD( "smash.a3",     0x1400, 0x0200, CRC(597555ae) SHA1(39a6d10e229be0e0d52b1061f2aa2f678b351f0b) )
545   ROM_LOAD( "smash.a4",     0x1600, 0x0200, CRC(0a15d69f) SHA1(c3a7b5ce4406cce511108e5c015b1dd5587b75ed) )
546   ROM_LOAD( "smash.a5",     0x1800, 0x0200, CRC(a9c7a328) SHA1(2f21ee58ba117bf4fe9101373c55449217a08da6) )
547   ROM_LOAD( "smash.a6",     0x1a00, 0x0200, CRC(c7d62d27) SHA1(974800cbeba2f2d0d796200d235371e2ce3a1d28) )
548   ROM_LOAD( "smash.a7",     0x1c00, 0x0200, CRC(5e5af244) SHA1(9ea27241a5ac97b260599d56f60bf9ec3ffcac7f) )
549   ROM_LOAD( "smash.a8",     0x1e00, 0x0200, CRC(3dc50839) SHA1(5782ea7d70e5cbe8b8245ed1075ce92b57cc6ddf) )
550   ROM_RELOAD(               0xfe00, 0x0200 ) /* for the reset and interrupt vectors */
551
552   ROM_REGION( 0x0800, "gfx1", 0 )
553   ROM_LOAD( "smash.c4",     0x0000, 0x0200, CRC(442500e5) SHA1(c54ebd5ccee096d8eed4153f623adc4e655b3909) )  /* Character Set */
554   ROM_LOAD( "smash.c3",     0x0200, 0x0200, CRC(3c8f7560) SHA1(ce4023167a0b4b912bbbc70b00fd3b462990a04c) )
555   ROM_LOAD( "smash.c2",     0x0400, 0x0200, CRC(38f3e4ed) SHA1(4e537402c09b58997bc45498fd721d83a0eac3a7) )
556   ROM_LOAD( "smash.c1",     0x0600, 0x0200, CRC(e9adf1e1) SHA1(c1f6d2a3be1e9b35c8675d1e3f57e6a85ddd99fd) )
557
558   ROM_REGION( 0x0200, "gfx2", 0 )
559   ROM_LOAD( "smash.d14",    0x0000, 0x0200, CRC(833f81e4) SHA1(78a0ace3510546691ecaf6f6275cb3269495edc9) )  /* Cars */
560ROM_END
561
540562ROM_START( ripcord )
541563   ROM_REGION( 0x10000, "maincpu", 0 )
542564   ROM_LOAD( "9027.1a",      0x1000, 0x0200, CRC(56b8dc06) SHA1(5432e4f2e321805a8dc9cfce20b8372793a9a4dd) ) /* Code */
r7500r7501
587609GAMEL(1977, circusse, circus, circus,   circus,   circus,   ROT0, "[Exidy] (Sub-Electro bootleg)", "Circus (Sub-Electro bootleg)", GAME_SUPPORTS_SAVE | GAME_IMPERFECT_SOUND, layout_circus ) // looks like a text hack, but we've seen 2 identical copies so it's worth supporting
588610GAME( 1977, robotbwl, 0,      robotbwl, robotbwl, robotbwl, ROT0, "Exidy", "Robot Bowl", GAME_SUPPORTS_SAVE | GAME_IMPERFECT_SOUND )
589611GAMEL(1979, crash,    0,      crash,    crash,    crash,    ROT0, "Exidy", "Crash", GAME_SUPPORTS_SAVE | GAME_IMPERFECT_SOUND, layout_crash )
612GAMEL(1979, smash,    crash,  crash,    crash,    crash,    ROT0, "[Exidy] (bootleg)", "Smash (Crash bootleg)", GAME_SUPPORTS_SAVE | GAME_IMPERFECT_SOUND, layout_crash ) // looks like a text hack, but it also had a different bezel
590613GAME( 1979, ripcord,  0,      ripcord,  ripcord,  ripcord,  ROT0, "Exidy", "Rip Cord", GAME_SUPPORTS_SAVE | GAME_IMPERFECT_SOUND )
src/mame/drivers/arkanoid.c
r7500r7501
495495  - Known bugs :
496496      * Coins "buttons" don't work - we need to use fake BUTTON2 for each player
497497
498****************************************************************************
499
500    HEXA
501
502    This hardware is derived from Arkanoid's hardware.  The 1986 date found in
503    the roms probably comes from Arkanoid.  This is a Columns style game and
504    the original Columns wasn't released until 1990 and I find it hard to
505    believe that this would pre-date Columns.
506
507    driver by Howie Cohen
508
509    Memory map (prelim)
510    0000 7fff ROM
511    8000 bfff bank switch rom space??
512    c000 c7ff RAM
513    e000 e7ff video ram
514    e800-efff unused RAM
515
516    read:
517    d001      AY8910 read
518    f000      ???????
519
520    write:
521    d000      AY8910 control
522    d001      AY8910 write
523    d008      bit0/1 = flip screen x/y
524              bit 4 = ROM bank??
525              bit 5 = char bank
526              other bits????????
527    d010      watchdog reset, or IRQ acknowledge, or both
528    f000      ????????
529
530    main hardware consists of.....
531
532    sub board with Z80 x2, 2 ROMs and a scratched 18 pin chip (probably a PIC)
533
534    main board has....
535    12MHz xtal
536    ay3-8910
537    8 position DSW x1
538    ROMs x4
539    6116 SRAM x3
540    82S123 PROMs x3
541
498542***************************************************************************
499543
500544DIP locations verified for:
r7500r7501
543587   AM_RANGE(0xf000, 0xffff) AM_READNOP   /* fixes instant death in final level */
544588ADDRESS_MAP_END
545589
590static ADDRESS_MAP_START( hexa_map, ADDRESS_SPACE_PROGRAM, 8 )
591   AM_RANGE(0x0000, 0x7fff) AM_ROM
592   AM_RANGE(0x8000, 0xbfff) AM_ROMBANK("bank1")
593   AM_RANGE(0xc000, 0xc7ff) AM_RAM
594   AM_RANGE(0xd001, 0xd001) AM_DEVREAD("aysnd", ay8910_r)
595   AM_RANGE(0xd000, 0xd001) AM_DEVWRITE("aysnd", ay8910_address_data_w)
596   AM_RANGE(0xd008, 0xd008) AM_WRITE(hexa_d008_w)
597   AM_RANGE(0xd010, 0xd010) AM_WRITE(watchdog_reset_w)   /* or IRQ acknowledge, or both */
598   AM_RANGE(0xe000, 0xe7ff) AM_RAM_WRITE(arkanoid_videoram_w) AM_BASE_SIZE_MEMBER(arkanoid_state, videoram, videoram_size)
599ADDRESS_MAP_END
600
546601static ADDRESS_MAP_START( mcu_map, ADDRESS_SPACE_PROGRAM, 8 )
547602   ADDRESS_MAP_GLOBAL_MASK(0x7ff)
548603   AM_RANGE(0x0000, 0x0000) AM_READWRITE(arkanoid_68705_port_a_r, arkanoid_68705_port_a_w)
r7500r7501
761816INPUT_PORTS_END
762817
763818
819static INPUT_PORTS_START( hexa )
820   PORT_START("INPUTS")
821   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_JOYSTICK_UP ) PORT_4WAY
822   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_JOYSTICK_DOWN ) PORT_4WAY
823   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_JOYSTICK_LEFT ) PORT_4WAY
824   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_JOYSTICK_RIGHT ) PORT_4WAY
825   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_BUTTON1 )
826   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_START1 )
827   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_COIN1 )
828   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_BUTTON2 )
829
830   PORT_START("DSW")
831   PORT_DIPNAME( 0x03, 0x03, DEF_STR( Coinage ) )  PORT_DIPLOCATION("SW1:1,2")
832   PORT_DIPSETTING(    0x00, DEF_STR( 3C_1C ) )
833   PORT_DIPSETTING(    0x01, DEF_STR( 2C_1C ) )
834   PORT_DIPSETTING(    0x03, DEF_STR( 1C_1C ) )
835   PORT_DIPSETTING(    0x02, DEF_STR( 1C_2C ) )
836   PORT_DIPNAME( 0x04, 0x00, "Naughty Pics" )  PORT_DIPLOCATION("SW1:3")
837   PORT_DIPSETTING(    0x04, DEF_STR( Off ) )
838   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
839   PORT_DIPNAME( 0x08, 0x08, DEF_STR( Flip_Screen ) )  PORT_DIPLOCATION("SW1:4")
840   PORT_DIPSETTING(    0x08, DEF_STR( Off ) )
841   PORT_DIPSETTING(    0x00, DEF_STR( On ) )
842   PORT_DIPNAME( 0x30, 0x30, "Difficulty?" )  PORT_DIPLOCATION("SW1:5,6")
843   PORT_DIPSETTING(    0x30, "Easy?" )
844   PORT_DIPSETTING(    0x20, "Medium?" )
845   PORT_DIPSETTING(    0x10, "Hard?" )
846   PORT_DIPSETTING(    0x00, "Hardest?" )
847   PORT_DIPNAME( 0x40, 0x40, "Pobys" )  PORT_DIPLOCATION("SW1:7")
848   PORT_DIPSETTING(    0x40, "2" )
849   PORT_DIPSETTING(    0x00, "4" )
850   PORT_DIPNAME( 0x80, 0x80, DEF_STR( Demo_Sounds ) )  PORT_DIPLOCATION("SW1:8")
851   PORT_DIPSETTING(    0x00, DEF_STR( Off ) )
852   PORT_DIPSETTING(    0x80, DEF_STR( On ) )
853INPUT_PORTS_END
854
764855/***************************************************************************/
765856
766857/* Graphics Layouts */
r7500r7501
783874   // sprites use the same characters above, but are 16x8
784875GFXDECODE_END
785876
877static GFXDECODE_START( hexa )
878   GFXDECODE_ENTRY( "gfx1", 0x0000, charlayout,  0 , 32 )
879GFXDECODE_END
880
881
786882/* Sound Interfaces */
787883
788884static const ay8910_interface ay8910_config =
r7500r7501
795891   DEVCB_NULL
796892};
797893
894
895static const ay8910_interface hexa_ay8910_config =
896{
897   AY8910_LEGACY_OUTPUT,
898   AY8910_DEFAULT_LOADS,
899   DEVCB_INPUT_PORT("INPUTS"),
900   DEVCB_INPUT_PORT("DSW"),
901   DEVCB_NULL,
902   DEVCB_NULL
903};
904
905
906
798907/* Machine Drivers */
799908
800909static MACHINE_START( arkanoid )
r7500r7501
847956   /* driver data */
848957   MDRV_DRIVER_DATA(arkanoid_state)
849958
850   // basic machine hardware
959   /* basic machine hardware */
851960   MDRV_CPU_ADD("maincpu", Z80, XTAL_12MHz/2) /* verified on pcb */
852961   MDRV_CPU_PROGRAM_MAP(arkanoid_map)
853962   MDRV_CPU_VBLANK_INT("screen", irq0_line_hold)
r7500r7501
860969   MDRV_MACHINE_START(arkanoid)
861970   MDRV_MACHINE_RESET(arkanoid)
862971
863   // video hardware
972   /* video hardware */
864973   MDRV_SCREEN_ADD("screen", RASTER)
865974   MDRV_SCREEN_REFRESH_RATE(60)
866975   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(0))
r7500r7501
874983   MDRV_VIDEO_START(arkanoid)
875984   MDRV_VIDEO_UPDATE(arkanoid)
876985
877   // sound hardware
986   /* sound hardware */
878987   MDRV_SPEAKER_STANDARD_MONO("mono")
879988
880989   MDRV_SOUND_ADD("aysnd", YM2149, XTAL_12MHz/4/2) /* YM2149 clock is 3mhz, pin 26 is low so 3mhz/2 */
r7500r7501
882991   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.33)
883992MACHINE_DRIVER_END
884993
994
995static MACHINE_DRIVER_START( hexa )
996   /* driver data */
997   MDRV_DRIVER_DATA(arkanoid_state)
998
999   /* basic machine hardware */
1000   MDRV_CPU_ADD("maincpu", Z80, XTAL_12MHz/2)   /* Imported from arkanoid - correct? */
1001   MDRV_CPU_PROGRAM_MAP(hexa_map)
1002   MDRV_CPU_VBLANK_INT("screen", irq0_line_hold)
1003
1004   MDRV_MACHINE_START(arkanoid)
1005   MDRV_MACHINE_RESET(arkanoid)
1006
1007   /* video hardware */
1008   MDRV_SCREEN_ADD("screen", RASTER)
1009   MDRV_SCREEN_REFRESH_RATE(60)
1010   MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(0))
1011   MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16)
1012   MDRV_SCREEN_SIZE(32*8, 32*8)
1013   MDRV_SCREEN_VISIBLE_AREA(0*8, 32*8-1, 2*8, 30*8-1)
1014
1015   MDRV_GFXDECODE(hexa)
1016   MDRV_PALETTE_LENGTH(256)
1017
1018   MDRV_PALETTE_INIT(RRRR_GGGG_BBBB)
1019   MDRV_VIDEO_START(arkanoid)
1020   MDRV_VIDEO_UPDATE(hexa)
1021
1022   /* sound hardware */
1023   MDRV_SPEAKER_STANDARD_MONO("mono")
1024   MDRV_SOUND_ADD("aysnd", AY8910, XTAL_12MHz/4/2)   /* Imported from arkanoid - correct? */
1025   MDRV_SOUND_CONFIG(hexa_ay8910_config)
1026   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50)
1027MACHINE_DRIVER_END
1028
1029
8851030static MACHINE_DRIVER_START( bootleg )
8861031   MDRV_IMPORT_FROM(arkanoid)
8871032
888   // basic machine hardware
1033   /* basic machine hardware */
8891034   MDRV_CPU_MODIFY("maincpu")
8901035   MDRV_CPU_PROGRAM_MAP(bootleg_map)
8911036
r7500r7501
12551400   ROM_LOAD( "ic75.13e",    0x0400, 0x0200, CRC(a7c6c277) SHA1(adaa003dcd981576ea1cc5f697d709b2d6b2ea29) )   /* blue component */
12561401ROM_END
12571402
1258/* the other Dr. Korea game (Hexa, hexa.c) also appears to be derived from Arkanoid hardware */
12591403
12601404ROM_START( tetrsark )
12611405   ROM_REGION( 0x18000, "maincpu", 0 )
r7500r7501
12741418ROM_END
12751419
12761420
1421ROM_START( hexa )
1422   ROM_REGION( 0x18000, "maincpu", 0 )      /* 64k for code + 32k for banked ROM */
1423   ROM_LOAD( "hexa.20",      0x00000, 0x8000, CRC(98b00586) SHA1(3591a3b0486d720f0aaa9f0bf4be352cd0ffcbc7) )
1424   ROM_LOAD( "hexa.21",      0x10000, 0x8000, CRC(3d5d006c) SHA1(ad4eadab82024b122182eacb5a322cfd6e476a70) )
1425
1426   ROM_REGION( 0x18000, "gfx1", 0 )
1427   ROM_LOAD( "hexa.17",      0x00000, 0x8000, CRC(f6911dd6) SHA1(b12ea27ecddd60820a32d4346afab0cc9d06fa57) )
1428   ROM_LOAD( "hexa.18",      0x08000, 0x8000, CRC(6e3d95d2) SHA1(6399b7b5d088ceda08fdea9cf650f6b405f038e7) )
1429   ROM_LOAD( "hexa.19",      0x10000, 0x8000, CRC(ffe97a31) SHA1(f16b5d2b9ace09bcbbfe3dfb73db7fa377d1af7f) )
1430
1431   ROM_REGION( 0x0300, "proms", 0 )
1432   ROM_LOAD( "hexa.001",     0x0000, 0x0100, CRC(88a055b4) SHA1(eee86a7930d0a251f3e5c2134532cd1dede2026c) )
1433   ROM_LOAD( "hexa.003",     0x0100, 0x0100, CRC(3e9d4932) SHA1(9a336dba7134400312985b9902c77b4141105853) )
1434   ROM_LOAD( "hexa.002",     0x0200, 0x0100, CRC(ff15366c) SHA1(7feaf1c768bfe76432fb80991585e13d95960b34) )
1435ROM_END
1436
1437
12771438/* Driver Initialization */
12781439
12791440static void arkanoid_bootleg_init( running_machine *machine )
r7500r7501
13771538}
13781539
13791540
1541static DRIVER_INIT( hexa )
1542{
1543   UINT8 *RAM = memory_region(machine, "maincpu");
1544#if 0
1545
1546
1547   /* Hexa is not protected or anything, but it keeps writing 0x3f to register */
1548   /* 0x07 of the AY8910, to read the input ports. This causes clicks in the */
1549   /* music since the output channels are continuously disabled and reenabled. */
1550   /* To avoid that, we just NOP out the 0x3f write. */
1551
1552   RAM[0x0124] = 0x00;
1553   RAM[0x0125] = 0x00;
1554   RAM[0x0126] = 0x00;
1555#endif
1556
1557   memory_configure_bank(machine, "bank1", 0, 2, &RAM[0x10000], 0x4000);
1558}
1559
1560
13801561/* Game Drivers */
13811562
13821563GAME( 1986, arkanoid,   0,        arkanoid, arkanoid, 0,        ROT90, "Taito Corporation Japan", "Arkanoid (World)", GAME_SUPPORTS_SAVE )
r7500r7501
13981579GAME( 1986, arktayt2,   arkanoid, bootleg,  arktayt2, 0,        ROT90, "bootleg", "Arkanoid (Tayto bootleg, harder)", GAME_SUPPORTS_SAVE )
13991580GAME( 1987, arkatour,   arkanoid, arkanoid, arkanoid, 0,        ROT90, "Taito America Corporation (Romstar license)", "Tournament Arkanoid (US)", GAME_SUPPORTS_SAVE )
14001581GAME( 19??, tetrsark,   0,        bootleg,  tetrsark, tetrsark, ROT0,  "D.R. Korea", "Tetris (D.R. Korea)", GAME_SUPPORTS_SAVE )
1582GAME( 199?, hexa,       0,        hexa,     hexa,     hexa,     ROT0,  "D.R. Korea", "Hexa", GAME_IMPERFECT_SOUND | GAME_SUPPORTS_SAVE )
src/mame/drivers/srmp6.c
r7500r7501
7171#include "deprecat.h"
7272#include "sound/nile.h"
7373
74typedef struct _srmp6_state srmp6_state;
75struct _srmp6_state
74class srmp6_state
7675{
76public:
77   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, srmp6_state(machine)); }
78
79   srmp6_state(running_machine &machine) { }
80
7781   UINT16* tileram;
7882   UINT16* dmaram;
7983
src/mame/drivers/cball.c
r7500r7501
88#include "cpu/m6800/m6800.h"
99
1010
11typedef struct _cball_state cball_state;
12struct _cball_state
11class cball_state
1312{
13public:
14   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, cball_state(machine)); }
15
16   cball_state(running_machine &machine) { }
17
1418   /* memory pointers */
1519   UINT8 *  video_ram;
1620
src/mame/drivers/bigfghtr.c
r7500r7501
117117#include "sound/3812intf.h"
118118
119119
120typedef struct _bigfghtr_state bigfghtr_state;
121struct _bigfghtr_state
120class bigfghtr_state
122121{
122public:
123   static void *alloc(running_machine &machine) { return auto_alloc_clear(&machine, bigfghtr_state(machine)); }
124
125   bigfghtr_state(running_machine &machine) { }
126
123127   /* video-related */
124128   UINT16 *      text_videoram;
125129   UINT16 *      bg_videoram;
src/mame/drivers/asuka.c
r7500r7501
214214
215215#include "emu.h"
216216#include "cpu/z80/z80.h"
217#include "cpu/z180/z180.h"
217218#include "cpu/m68000/m68000.h"
218219#include "includes/taitoipt.h"
219220#include "video/taitoic.h"
r7500r7501
293294   state->adpcm_pos &= 0xff00;
294295}
295296
297static UINT8 *cadash_shared_ram;
298
299static READ16_HANDLER( cadash_share_r )
300{
301   return cadash_shared_ram[offset];
302}
303
304static WRITE16_HANDLER( cadash_share_w )
305{
306   cadash_shared_ram[offset] = data & 0xff;
307}
308
309
296310/***********************************************************
297311             MEMORY STRUCTURES
298312***********************************************************/
r7500r7501
338352   AM_RANGE(0x0c0000, 0x0c0001) AM_READNOP AM_DEVWRITE8("tc0140syt", tc0140syt_port_w, 0x00ff)
339353   AM_RANGE(0x0c0002, 0x0c0003) AM_DEVREADWRITE8("tc0140syt", tc0140syt_comm_r, tc0140syt_comm_w, 0x00ff)
340354   AM_RANGE(0x100000, 0x107fff) AM_RAM
341   AM_RANGE(0x800000, 0x800fff) AM_RAM   /* network ram */
355   AM_RANGE(0x800000, 0x800fff) AM_READWRITE(cadash_share_r,cadash_share_w)   /* network ram */
342356   AM_RANGE(0x900000, 0x90000f) AM_DEVREADWRITE8("tc0220ioc", tc0220ioc_r, tc0220ioc_w, 0x00ff)
343357   AM_RANGE(0xa00000, 0xa0000f) AM_DEVREADWRITE("tc0110pcr", tc0110pcr_word_r, tc0110pcr_step1_4bpg_word_w)
344358   AM_RANGE(0xb00000, 0xb03fff) AM_DEVREADWRITE("pc090oj", pc090oj_word_r, pc090oj_word_w)   /* sprite ram */
r7500r7501
401415   AM_RANGE(0xa001, 0xa001) AM_DEVREADWRITE("tc0140syt", tc0140syt_slave_comm_r, tc0140syt_slave_comm_w)
402416ADDRESS_MAP_END
403417
418/*
419Cadash communication CPU is a z180.
420[0x8000]: at pc=31, z180 checks a byte ... if it's equal to 0x4d ("M") then the board is in master mode, otherwise it's in slave mode.
421Right now, the z180 is too fast, so it never checks it properly ... maybe I'm missing a z180 halt line that's lying to somewhere on m68k side.
422[0x8002]: puts T in master mode, R in slave mode ... looks a rather obvious flag that says the current Tx / Rx state
423[0x8080-0x80ff]: slave data
424[0x8100-0x817f]: master data
404425
426Internal I/O Asynchronous SCI regs are then checked ... we can't emulate this at the current time, needs two MAME instances.
427
428m68k M communicates with z180 M thru shared ram, then the z180 M communicates with z180 S thru these ASCI regs ... finally, the z180 S
429communicates with m68k S with its own shared ram. In short:
430
431m68k M -> z180 M <-> z180 S <- m68k S
432*/
433
434static ADDRESS_MAP_START( cadash_sub_map, ADDRESS_SPACE_PROGRAM, 8 )
435   AM_RANGE(0x0000, 0x7fff) AM_ROM
436   AM_RANGE(0x8000, 0x87ff) AM_RAM AM_BASE(&cadash_shared_ram)
437ADDRESS_MAP_END
438
439static ADDRESS_MAP_START( cadash_sub_io, ADDRESS_SPACE_IO, 8 )
440   AM_RANGE(0x00, 0x3f) AM_RAM // z180 internal I/O regs
441ADDRESS_MAP_END
442
405443/***********************************************************
406444             INPUT PORTS, DIPs
407445***********************************************************/
r7500r7501
9661004   MDRV_CPU_ADD("audiocpu", Z80, XTAL_8MHz/2)   /* verified on pcb */
9671005   MDRV_CPU_PROGRAM_MAP(cadash_z80_map)
9681006
1007   MDRV_CPU_ADD("subcpu", Z180, 4000000)   /* 4 MHz ??? */
1008   MDRV_CPU_PROGRAM_MAP(cadash_sub_map)
1009   MDRV_CPU_IO_MAP(cadash_sub_io)
1010
9691011   MDRV_MACHINE_START(asuka)
9701012   MDRV_MACHINE_RESET(asuka)
9711013
r7500r7501
13401382   ROM_LOAD( "c21-08.38",   0x00000, 0x04000, CRC(dca495a0) SHA1(4e0f401f1b967da75f33fd7294860ad0b4bf2dce) )
13411383   ROM_CONTINUE(            0x10000, 0x0c000 )   /* banked stuff */
13421384
1343   ROM_REGION( 0x08000, "user1", 0 )   /* 2 machine interface mcu rom ? */
1385   ROM_REGION( 0x08000, "subcpu", 0 )   /* 2 machine interface mcu rom ? */
13441386   ROM_LOAD( "c21-07.57",   0x00000, 0x08000, CRC(f02292bd) SHA1(0a5c06a048ad67f90e0d766b504582e9eef035f7) )
13451387
13461388   ROM_REGION( 0x0800, "plds", 0 )
r7500r7501
13671409   ROM_LOAD( "c21-08.38",   0x00000, 0x04000, CRC(dca495a0) SHA1(4e0f401f1b967da75f33fd7294860ad0b4bf2dce) )
13681410   ROM_CONTINUE(            0x10000, 0x0c000 )   /* banked stuff */
13691411
1370   ROM_REGION( 0x08000, "user1", 0 )   /* 2 machine interface mcu rom ? */
1412   ROM_REGION( 0x08000, "subcpu", 0 )   /* 2 machine interface mcu rom ? */
13711413   ROM_LOAD( "c21-07.57",   0x00000, 0x08000, CRC(f02292bd) SHA1(0a5c06a048ad67f90e0d766b504582e9eef035f7) )
13721414ROM_END
13731415
r7500r7501
13901432   ROM_LOAD( "c21-08.38",   0x00000, 0x04000, CRC(dca495a0) SHA1(4e0f401f1b967da75f33fd7294860ad0b4bf2dce) )
13911433   ROM_CONTINUE(            0x10000, 0x0c000 )   /* banked stuff */
13921434
1393   ROM_REGION( 0x08000, "user1", 0 )   /* 2 machine interface mcu rom ? */
1435   ROM_REGION( 0x08000, "subcpu", 0 )   /* 2 machine interface mcu rom ? */
13941436   ROM_LOAD( "c21-07.57",   0x00000, 0x08000, CRC(f02292bd) SHA1(0a5c06a048ad67f90e0d766b504582e9eef035f7) )
13951437ROM_END
13961438
r7500r7501
14111453   ROM_LOAD( "c21-08.38",   0x00000, 0x04000, CRC(dca495a0) SHA1(4e0f401f1b967da75f33fd7294860ad0b4bf2dce) )
14121454   ROM_CONTINUE(            0x10000, 0x0c000 )   /* banked stuff */
14131455
1414   ROM_REGION( 0x08000, "user1", 0 )   /* 2 machine interface mcu rom ? */
1456   ROM_REGION( 0x08000, "subcpu", 0 )   /* 2 machine interface mcu rom ? */
14151457   ROM_LOAD( "c21-07.57",   0x00000, 0x08000, CRC(f02292bd) SHA1(0a5c06a048ad67f90e0d766b504582e9eef035f7) )
14161458ROM_END
14171459
r7500r7501
14321474   ROM_LOAD( "c21-08.38",   0x00000, 0x04000, CRC(dca495a0) SHA1(4e0f401f1b967da75f33fd7294860ad0b4bf2dce) )
14331475   ROM_CONTINUE(            0x10000, 0x0c000 )   /* banked stuff */
14341476
1435   ROM_REGION( 0x08000, "user1", 0 )   /* 2 machine interface mcu rom ? */
1477   ROM_REGION( 0x08000, "subcpu", 0 )   /* 2 machine interface mcu rom ? */
14361478   ROM_LOAD( "c21-07.57",   0x00000, 0x08000, CRC(f02292bd) SHA1(0a5c06a048ad67f90e0d766b504582e9eef035f7) )
14371479ROM_END
14381480
r7500r7501
14531495   ROM_LOAD( "c21-08.38",   0x00000, 0x04000, CRC(dca495a0) SHA1(4e0f401f1b967da75f33fd7294860ad0b4bf2dce) )
14541496   ROM_CONTINUE(            0x10000, 0x0c000 )   /* banked stuff */
14551497
1456   ROM_REGION( 0x08000, "user1", 0 )   /* 2 machine interface mcu rom ? */
1498   ROM_REGION( 0x08000, "subcpu", 0 )   /* 2 machine interface mcu rom ? */
14571499   ROM_LOAD( "c21-07.57",   0x00000, 0x08000, CRC(f02292bd) SHA1(0a5c06a048ad67f90e0d766b504582e9eef035f7) )
14581500ROM_END
14591501
src/tools/unidasm.c
r7500r7501
333333   { "z8",         _8bit,  0, CPU_DISASSEMBLE_NAME(z8) },
334334};
335335
336void *malloc_file_line(size_t size, const char *file, int line)
337{
338   void *result = malloc(size);
339   return result;
340}
336341
342
343void free_file_line(void *memory, const char *file, int line)
344{
345   free(memory);
346}
347
348
337349void osd_break_into_debugger(const char *text)
338350{
339351   /* we don't have a complete debugger to break in */
src/osd/sdl/strconv.h
r7500r7501
1010#ifndef __SDLSTRCONV__
1111#define __SDLSTRCONV__
1212
13#include "osdcore.h"
13#include "osdcomm.h"
1414
1515
1616
src/osd/sdl/sdlsync_tc.c
r7500r7501
2424#include <unistd.h>
2525
2626// MAME headers
27#include "osdcomm.h"
2728#include "osdcore.h"
2829
2930#include "sdlsync.h"
src/osd/sdl/video.c
r7500r7501
9595static void check_osd_inputs(running_machine *machine);
9696
9797static void extract_video_config(running_machine *machine);
98static void extract_window_config(running_machine *machine, int index, sdl_window_config *conf);
9899static void load_effect_overlay(running_machine *machine, const char *filename);
99100static float get_aspect(const char *name, int report_error);
100101static void get_resolution(const char *name, sdl_window_config *config, int report_error);
r7500r7501
129130   // create the windows
130131   for (index = 0; index < video_config.numscreens; index++)
131132   {
132      video_config.window[index].totalColors = tc;
133      if (sdlwindow_video_window_create(machine, index, pick_monitor(index), &video_config.window[index]))
133      sdl_window_config conf;
134      memset(&conf, 0, sizeof(conf));
135      extract_window_config(machine, index, &conf);
136      conf.totalColors = tc;
137      if (sdlwindow_video_window_create(machine, index, pick_monitor(index), &conf))
134138         goto error;
135139   }
136140
r7500r7501
610614      sdlwindow_toggle_draw(machine, window);
611615}
612616
617//============================================================
618//  extract_window_config
619//============================================================
613620
621static void extract_window_config(running_machine *machine, int index, sdl_window_config *conf)
622{
623   char buf[10];
624
625   sprintf(buf,SDLOPTION_RESOLUTION("%d"), index);
626   // per-window options: extract the data
627   get_resolution(buf, conf, TRUE);
628}
629
614630//============================================================
615631//  extract_video_config
616632//============================================================
r7500r7501
638654   if (stemp != NULL && strcmp(stemp, "none") != 0)
639655      load_effect_overlay(machine, stemp);
640656
641   // per-window options: extract the data
642   get_resolution(SDLOPTION_RESOLUTION("0"), &video_config.window[0], TRUE);
643   get_resolution(SDLOPTION_RESOLUTION("1"), &video_config.window[1], TRUE);
644   get_resolution(SDLOPTION_RESOLUTION("2"), &video_config.window[2], TRUE);
645   get_resolution(SDLOPTION_RESOLUTION("3"), &video_config.window[3], TRUE);
646
647657   // default to working video please
648658   video_config.novideo = 0;
649659
src/osd/sdl/video.h
r7500r7501
102102   int               centerh;
103103   int               centerv;
104104
105
106   // per-window configuration
107   sdl_window_config   window[MAX_VIDEO_WINDOWS];      // configuration data per-window
108
109105   // hardware options
110106   int               mode;         // output mode
111107   int               waitvsync;      // spin until vsync
src/osd/sdl/sdlmisc_os2.c
r7500r7501
2121#include <os2.h>
2222
2323// MAME headers
24#include "osdepend.h"
2524#include "osdcore.h"
2625
2726//============================================================
src/osd/sdl/output.c
r7500r7501
128128
129129#else  /* SDLMAME_WIN32 */
130130
131#include "emu.h"
131#include "emucore.h"
132132
133133//============================================================
134134//  Stub for win32
src/osd/sdl/input.c
r7500r7501
2222#include "ui.h"
2323#include "uiinput.h"
2424#include "emuopts.h"
25#include "osdepend.h"
2625
2726
2827// MAMEOS headers
src/osd/sdl/main.c
r7500r7501
4545#endif
4646
4747   /* convert arguments to UTF-8 */
48   utf8_argv = (char **) osd_malloc(argc * sizeof(*argv));
48   utf8_argv = (char **) malloc(argc * sizeof(*argv));
4949   if (utf8_argv == NULL)
5050      return 999;
5151   for (i = 0; i < argc; i++)
r7500r7501
6161   /* free arguments */
6262   for (i = 0; i < argc; i++)
6363      free(utf8_argv[i]);
64   osd_free(utf8_argv);
64   free(utf8_argv);
6565
6666#ifdef MALLOC_DEBUG
6767   {
src/osd/sdl/gl_shader_mgr.c
r7500r7501
11
22#include <SDL/SDL.h>
33
4#include "osdcomm.h"
5#include "osdcore.h"
6#include "osdepend.h"
7
84#include "osd_opengl.h"
95
106#include "gl_shader_mgr.h"
117#include "gl_shader_tool.h"
128
13// OSD headers
14
159#define GLSL_VERTEX_SHADER_INT_NUMBER 1 // general
1610#define GLSL_VERTEX_SHADER_MAX_NUMBER 2 // general + custom
1711#define GLSL_VERTEX_SHADER_CUSTOM     1 // custom idx
src/osd/windows/wintime.c
r7500r7501
4545#include <mmsystem.h>
4646
4747// MAME headers
48#include "osdepend.h"
48#include "osdcore.h"
4949
5050
5151
src/osd/windows/input.c
r7500r7501
771771            input_seq_set_2(&typedesc->seq[SEQ_TYPE_STANDARD], KEYCODE_LALT, KEYCODE_ENTER);
772772            break;
773773
774#ifdef MESS
774775         case IPT_UI_THROTTLE:
775776            input_seq_set_0(&typedesc->seq[SEQ_TYPE_STANDARD]);
776777            break;
778#endif
777779      }
778780}
779781
src/osd/windows/winmisc.c
r7500r7501
4545#include <tchar.h>
4646
4747// MAME headers
48#include "emucore.h"
48#include "osdcore.h"
4949
5050// MAMEOS headers
5151#include "winutf8.h"
src/emu/debug/express.c
r7500r7501
914914            {
915915               /* if we have a number prefix, assume it is a number */
916916               bufindex = 0;
917               if (buffer[0] == '$') { numbase = 16; bufindex++; must_be_number = 1; }
918               else if (buffer[0] == '0' && buffer[1] == 'x') { numbase = 16; bufindex += 2; must_be_number = 1; }
917               if (buffer[0] == '0' && buffer[1] == 'x') { numbase = 16; bufindex += 2; must_be_number = 1; }
919918               else if (buffer[0] == '#') { numbase = 10; bufindex++; must_be_number = 1; }
920919
921920               /* if we're not forced to be a number, check for a symbol match first */
r7500r7501
939938               /* see if we parse as a number */
940939               if (token->type == TOK_INVALID)
941940               {
941                  if (buffer[0] == '$') { numbase = 16; bufindex++; must_be_number = 1; }
942942                  value = 0;
943943                  while (buffer[bufindex] != 0)
944944                  {
src/emu/cpu/h83002/h8_16.c
r7500r7501
138138   if(h8->ccr & UIFLAG) h8->h8uiflag = 1;
139139   if(h8->ccr & IFLAG) h8->h8iflag = 1;
140140
141   h8_check_irqs(h8);
141   if (!h8->incheckirqs) h8_check_irqs(h8);
142142}
143143
144144static INT16 h8_getreg16(h83xx_state *h8, UINT8 reg)
r7500r7501
256256   h8->h8err = 0;
257257   h8->pc = h8_mem_read32(h8, 0) & 0xffffff;
258258
259   h8->incheckirqs = 0;
260
259261   // disable timers
260262   h8->h8TSTR = 0;
261263
r7500r7501
323325static void h8_check_irqs(h83xx_state *h8)
324326{
325327   int lv = -1;
328
329   h8->incheckirqs = 1;
330
326331   if (h8->h8iflag == 0)
327332   {
328333      lv = 0;
r7500r7501
377382      if (source != 0xff)
378383         h8_GenException(h8, source);
379384   }
385
386   h8->incheckirqs = 0;
380387}
381388
382389#define H8_ADDR_MASK 0xffffff
src/emu/cpu/h83002/h8priv.h
r7500r7501
2323   UINT8  ccr;
2424   UINT8  h8nflag, h8vflag, h8cflag, h8zflag, h8iflag, h8hflag;
2525   UINT8  h8uflag, h8uiflag;
26   UINT8  incheckirqs;
2627
2728   cpu_irq_callback irq_cb;
2829   running_device *device;
src/emu/cpu/h83002/h8_8.c
r7500r7501
154154   if(h8->ccr & UIFLAG) h8->h8uiflag = 1;
155155   if(h8->ccr & IFLAG) h8->h8iflag = 1;
156156
157   h8_check_irqs(h8);
157   if (!h8->incheckirqs) h8_check_irqs(h8);
158158}
159159
160160static INT16 h8_getreg16(h83xx_state *h8, UINT8 reg)
r7500r7501
268268   h8->h8err = 0;
269269   h8->pc = h8_mem_read16(h8, 0);
270270
271   h8->incheckirqs = 0;
272
271273   // disable timers
272274   h8->h8TSTR = 0;
273275   h8->FRC = 0;
r7500r7501
341343{
342344   int lv = 0;
343345
346   h8->incheckirqs = 1;
347
344348   if (h8->h8iflag != 0)
345349   {
346350      lv = 2;
r7500r7501
386390         h8_GenException(h8, source);
387391      }
388392   }
393
394   h8->incheckirqs = 0;
389395}
390396
391397#define H8_ADDR_MASK 0xffff
src/emu/cpu/h83002/h8ops.h
r7500r7501
20532053            bitnr = (ext16>>4)&7;
20542054            if(ext16&0x80)
20552055            {
2056               // bist
2057               h8->h8err = 1;
2056               h8_bist8(h8, bitnr, udata8);  H8_IFETCH_TIMING(2); H8_BYTE_TIMING(2, address24);
20582057            }
20592058            else
20602059            {
r7500r7501
20652064            bitnr = (ext16>>4)&7;
20662065            if(ext16&0x80)
20672066            {
2068               // bild
2069               h8->h8err = 1;
2067               h8_bild8(h8, bitnr, udata8);  H8_IFETCH_TIMING(2); H8_BYTE_TIMING(2, address24);
20702068            }
20712069            else
20722070            {
src/emu/cpu/drcbex86.c
r7500r7501
15531553      if (inst->flags == 0 && (UINT32)param->value == 0)
15541554         /* skip */;
15551555      else if (inst->flags == 0 && (UINT32)param->value == 0xffffffff)
1556         emit_mov_r32_imm(dst, reg, -1);                                    // mov  reg,-1
1556         emit_mov_r32_imm(dst, reg, ~0);                                    // mov  reg,-1
15571557      else
15581558         emit_or_r32_imm(dst, reg, param->value);                           // or   reg,param
15591559   }
r7500r7501
15761576      if (inst->flags == 0 && (UINT32)param->value == 0)
15771577         /* skip */;
15781578      else if (inst->flags == 0 && (UINT32)param->value == 0xffffffff)
1579         emit_mov_m32_imm(dst, MEMPARAMS, -1);                              // mov   [dest],-1
1579         emit_mov_m32_imm(dst, MEMPARAMS, ~0);                              // mov   [dest],-1
15801580      else
15811581         emit_or_m32_imm(dst, MEMPARAMS, param->value);                        // or   [dest],param
15821582   }
r7500r7501
25012501      if (inst->flags == 0 && (UINT32)param->value == 0)
25022502         /* skip */;
25032503      else if (inst->flags == 0 && (UINT32)param->value == 0xffffffff)
2504         emit_mov_r32_imm(dst, reglo, -1);                                 // mov   reglo,-1
2504         emit_mov_r32_imm(dst, reglo, ~0);                                 // mov   reglo,-1
25052505      else
25062506         emit_or_r32_imm(dst, reglo, param->value);                           // or    reglo,param
25072507      if (saveflags) emit_pushf(dst);                                       // pushf
25082508      if (inst->flags == 0 && (UINT32)(param->value >> 32) == 0)
25092509         /* skip */;
25102510      else if (inst->flags == 0 && (UINT32)(param->value >> 32) == 0xffffffff)
2511         emit_mov_r32_imm(dst, reghi, -1);                                 // mov   reghi,-1
2511         emit_mov_r32_imm(dst, reghi, ~0);                                 // mov   reghi,-1
25122512      else
25132513         emit_or_r32_imm(dst, reghi, param->value >> 32);                     // or    reghi,param >> 32
25142514   }
r7500r7501
25362536      if (inst->flags == 0 && (UINT32)param->value == 0)
25372537         /* skip */;
25382538      else if (inst->flags == 0 && (UINT32)param->value == 0xffffffff)
2539         emit_mov_m32_imm(dst, MEMPARAMS, -1);                              // mov   [dest],-1
2539         emit_mov_m32_imm(dst, MEMPARAMS, ~0);                              // mov   [dest],-1
25402540      else
25412541         emit_or_m32_imm(dst, MEMPARAMS, param->value);                        // or    [dest],param
25422542      if (saveflags) emit_pushf(dst);                                       // pushf
25432543      if (inst->flags == 0 && (UINT32)(param->value >> 32) == 0)
25442544         /* skip */;
25452545      else if (inst->flags == 0 && (UINT32)(param->value >> 32) == 0xffffffff)
2546         emit_mov_m32_imm(dst, MEMPARAMS + 4, -1);                           // mov   [dest+4],-1
2546         emit_mov_m32_imm(dst, MEMPARAMS + 4, ~0);                           // mov   [dest+4],-1
25472547      else
25482548         emit_or_m32_imm(dst, MEMPARAMS + 4, param->value >> 32);               // or    [dest+4],param >> 32
25492549   }
src/emu/memory.h
r7500r7501
897897   TOKEN_UINT32_PACK1(ADDRMAP_TOKEN_BASEPTR, 8), \
898898   TOKEN_PTR(memptr, _base),
899899
900#define myoffsetof(_struct, _member)  ((FPTR)&((_struct *)0x1000)->_member - 0x1000)
900901#define AM_BASE_MEMBER(_struct, _member) \
901   TOKEN_UINT32_PACK2(ADDRMAP_TOKEN_BASE_MEMBER, 8, offsetof(_struct, _member), 24),
902   TOKEN_UINT32_PACK2(ADDRMAP_TOKEN_BASE_MEMBER, 8, myoffsetof(_struct, _member), 24),
902903
903904#define AM_BASE_GENERIC(_member) \
904905   TOKEN_UINT32_PACK2(ADDRMAP_TOKEN_BASE_GENERIC, 8, offsetof(generic_pointers, _member), 24),
r7500r7501
908909   TOKEN_PTR(sizeptr, _size),
909910
910911#define AM_SIZE_MEMBER(_struct, _member) \
911   TOKEN_UINT32_PACK2(ADDRMAP_TOKEN_SIZE_MEMBER, 8, offsetof(_struct, _member), 24),
912   TOKEN_UINT32_PACK2(ADDRMAP_TOKEN_SIZE_MEMBER, 8, myoffsetof(_struct, _member), 24),
912913
913914#define AM_SIZE_GENERIC(_member) \
914915   TOKEN_UINT32_PACK2(ADDRMAP_TOKEN_SIZE_GENERIC, 8, offsetof(generic_pointers, _member##_size), 24),
src/emu/mame.c
r7500r7501
13031303      basename = mame_strdup(driver->name);
13041304      config = machine_config_alloc(driver->machine_config);
13051305
1306      /* allocate the driver data */
1307      if (config->driver_data_size != 0)
1308         driver_data = auto_alloc_array_clear(this, UINT8, config->driver_data_size);
1309
13101306      /* attach this machine to all the devices in the configuration */
13111307      devicelist.import_config_list(config->devicelist, *this);
13121308
1309      /* allocate the driver data (after devices) */
1310      if (config->driver_data_alloc != NULL)
1311         driver_data = (*config->driver_data_alloc)(*this);
1312
13131313      /* find devices */
13141314      firstcpu = cpu_first(this);
13151315      primary_screen = video_screen_first(this);
src/emu/machine/z80dma.c
r7500r7501
149149   UINT8   read_regs_follow[7];
150150   UINT8   status;
151151   UINT8   dma_enabled;
152   
152
153153   UINT16 addressA;
154154   UINT16 addressB;
155155   UINT16 count;
r7500r7501
378378   {
379379      z80dma->dma_enabled = 0; //FIXME: Correct?
380380        z80dma->status = 0x19;
381       
381
382382      if(!(z80dma->rdy ^ READY_ACTIVE_HIGH(z80dma))) z80dma->status |= 0x02;   // ready line status
383     
383
384384      if(TRANSFER_MODE(z80dma) == TM_TRANSFER)     z80dma->status |= 0x10;   // no match found
385     
385
386386      z80dma_update_status(device);
387387      if (LOG) logerror("Z80DMA '%s' End of Block\n", device->tag.cstr());
388       
388
389389      if (INT_ON_END_OF_BLOCK(z80dma))
390390        {
391391         trigger_interrupt(device, INT_END_OF_BLOCK);
r7500r7501
721721   if (z80dma->ip)
722722   {
723723       if (LOG) logerror("Z80DMA '%s' Interrupt Acknowledge\n", device->tag.cstr());
724     
724
725725      /* clear interrupt pending flag */
726726      z80dma->ip = 0;
727727       interrupt_check(z80dma);
728728
729729      /* set interrupt under service flag */
730730      z80dma->ius = 1;
731     
731
732732      /* disable DMA */
733733      z80dma->dma_enabled = 0;
734734
src/emu/machine/z80pio.c
r7500r7501
44
55    Copyright Nicola Salmoria and the MAME Team.
66    Visit http://mamedev.org for licensing and usage restrictions.
7   
7
88***************************************************************************/
99
1010#include "emu.h"
r7500r7501
106106   z80pio_t *z80pio = get_safe_token(device);
107107
108108   int state = CLEAR_LINE;
109   
109
110110   for (int index = PORT_A; index < PORT_COUNT; index++)
111111   {
112112      pio_port *port = &z80pio->port[index];
r7500r7501
333333   case MASK: /* interrupt mask */
334334      port->mask = data;
335335      if (LOG) logerror("Z80PIO '%s' Port %c Mask: %02x\n", device->tag.cstr(), 'A' + index, data);
336     
336
337337      /* set interrupt enable */
338338      port->ie = BIT(port->icw, 7);
339339      check_interrupts(device);
r7500r7501
509509{
510510   z80pio_t *z80pio = get_safe_token(device);
511511   pio_port *port = &z80pio->port[PORT_A];
512   
512
513513   UINT8 data = 0xff;
514514
515515   switch (port->mode)
r7500r7501
538538{
539539   z80pio_t *z80pio = get_safe_token(device);
540540   pio_port *port = &z80pio->port[PORT_A];
541   
541
542542   if (port->mode == MODE_BIT_CONTROL)
543543   {
544544      /* latch data */
r7500r7501
555555{
556556   z80pio_t *z80pio = get_safe_token(device);
557557   pio_port *port = &z80pio->port[PORT_B];
558   
558
559559   UINT8 data = 0xff;
560560
561561   switch (port->mode)
r7500r7501
580580{
581581   z80pio_t *z80pio = get_safe_token(device);
582582   pio_port *port = &z80pio->port[PORT_B];
583   
583
584584   if (port->mode == MODE_BIT_CONTROL)
585585   {
586586      /* latch data */
r7500r7501
616616            else if (!port->stb && state) /* rising edge */
617617            {
618618               trigger_interrupt(device, index);
619               
619
620620               /* clear ready line */
621621               set_rdy(device, index, 0);
622622            }
r7500r7501
705705   z80pio_t *z80pio = get_safe_token(device);
706706
707707   int state = 0;
708   
708
709709   for (int index = PORT_A; index < PORT_COUNT; index++)
710710   {
711711      pio_port *port = &z80pio->port[index];
src/emu/machine/z80pio.h
r7500r7501
1717                   PA6   8 |             | 33  PB6
1818                   PA5   9 |             | 32  PB5
1919                   PA4  10 |    Z8420    | 31  PB4
20                   GND  11 |             | 30  PB3
20                   GND  11 |             | 30  PB3
2121                   PA3  12 |             | 29  PB2
2222                   PA2  13 |             | 28  PB1
2323                   PA1  14 |             | 27  PB0
src/emu/machine/pic8259.h
r7500r7501
2525#ifndef __PIC8259_H__
2626#define __PIC8259_H__
2727
28#include "devcb.h"
29
2830#define PIC8259   DEVICE_GET_INFO_NAME(pic8259)
2931
3032/***************************************************************************
src/emu/emualloc.c
r7500r7501
4141#include "coreutil.h"
4242
4343
44/***************************************************************************
45    CONSTANTS
46***************************************************************************/
44//**************************************************************************
45//  CONSTANTS
46//**************************************************************************
4747
4848// align all allocated memory to this size
4949const int memory_align = 16;
r7500r7501
5353
5454
5555
56/***************************************************************************
57    MACROS
58***************************************************************************/
56//**************************************************************************
57//  MACROS
58//**************************************************************************
5959
6060// enable deletion
6161#undef delete
6262
6363
6464
65/***************************************************************************
66    TYPE DEFINITIONS
67***************************************************************************/
65//**************************************************************************
66//  TYPE DEFINITIONS
67//**************************************************************************
6868
6969// this struct is allocated in pools to track memory allocations
7070// it must be a POD type!!
7171class memory_entry
7272{
7373public:
74   memory_entry *      next;         // link to the next entry
75   memory_entry *      prev;         // link to the previous entry
76   size_t            size;         // size of the allocation (not including this header)
77   void *            base;         // base of the allocation
78   const char *      file;         // file the allocation was made from
79   int               line;         // line number within that file
80   int               id;            // unique id
74   memory_entry *      m_next;            // link to the next entry
75   memory_entry *      m_prev;            // link to the previous entry
76   size_t            m_size;            // size of the allocation (not including this header)
77   void *            m_base;            // base of the allocation
78   const char *      m_file;            // file the allocation was made from
79   int               m_line;            // line number within that file
80   int               m_id;            // unique id
8181
82   static const int   hash_prime = 193;
82   static const int   k_hash_prime = 193;
8383
84   static int         curid;         // current ID
85   static osd_lock *   lock;         // lock for managing the list
86   static bool         lock_alloc;      // set to true temporarily during lock allocation
87   static memory_entry *hash[hash_prime];// hash table based on pointer
88   static memory_entry *freehead;      // pointer to the head of the free list
84   static int         s_curid;         // current ID
85   static osd_lock *   s_lock;            // lock for managing the list
86   static bool         s_lock_alloc;      // set to true temporarily during lock allocation
87   static memory_entry *s_hash[k_hash_prime];// hash table based on pointer
88   static memory_entry *s_freehead;      // pointer to the head of the free list
8989
9090   static memory_entry *allocate(size_t size, void *base, const char *file, int line);
9191   static memory_entry *find(void *ptr);
r7500r7501
9999
100100
101101
102/***************************************************************************
103    GLOBALS
104***************************************************************************/
102//**************************************************************************
103//  GLOBALS
104//**************************************************************************
105105
106106// global resource pool to handle allocations outside of the emulator context
107107resource_pool global_resource_pool;
r7500r7501
110110const zeromem_t zeromem = { };
111111
112112// globals for memory_entry
113int memory_entry::curid = 0;
114osd_lock *memory_entry::lock = NULL;
115bool memory_entry::lock_alloc = false;
116memory_entry *memory_entry::hash[memory_entry::hash_prime] = { NULL };
117memory_entry *memory_entry::freehead = NULL;
113int memory_entry::s_curid = 0;
114osd_lock *memory_entry::s_lock = NULL;
115bool memory_entry::s_lock_alloc = false;
116memory_entry *memory_entry::s_hash[memory_entry::k_hash_prime] = { NULL };
117memory_entry *memory_entry::s_freehead = NULL;
118118
119119
120120
121/***************************************************************************
122    GLOBAL HELPERS
123***************************************************************************/
121//**************************************************************************
122//  GLOBAL HELPERS
123//**************************************************************************
124124
125125/*-------------------------------------------------
126126    malloc_file_line - allocate memory with file
r7500r7501
189189
190190
191191
192/***************************************************************************
193    RESOURCE POOL
194***************************************************************************/
192//**************************************************************************
193//  RESOURCE POOL
194//**************************************************************************
195195
196196/*-------------------------------------------------
197197    resource_pool - constructor for a new resource
r7500r7501
199199-------------------------------------------------*/
200200
201201resource_pool::resource_pool()
202   : listlock(osd_lock_alloc()),
203     ordered_head(NULL)
202   : m_listlock(osd_lock_alloc()),
203     m_ordered_head(NULL)
204204{
205   memset(hash, 0, sizeof(hash));
205   memset(m_hash, 0, sizeof(m_hash));
206206}
207207
208208
r7500r7501
215215resource_pool::~resource_pool()
216216{
217217   clear();
218   if (listlock != NULL)
219      osd_lock_free(listlock);
218   if (m_listlock != NULL)
219      osd_lock_free(m_listlock);
220220}
221221
222222
r7500r7501
226226
227227void resource_pool::add(resource_pool_item &item)
228228{
229   osd_lock_acquire(listlock);
229   osd_lock_acquire(m_listlock);
230230
231231   // insert into hash table
232   int hashval = reinterpret_cast<FPTR>(item.ptr) % hash_prime;
233   item.next = hash[hashval];
234   hash[hashval] = &item;
232   int hashval = reinterpret_cast<FPTR>(item.m_ptr) % k_hash_prime;
233   item.m_next = m_hash[hashval];
234   m_hash[hashval] = &item;
235235
236236   // insert into ordered list
237   item.ordered_next = ordered_head;
238   if (ordered_head != NULL)
239      ordered_head->ordered_prev = &item;
240   ordered_head = &item;
237   item.m_ordered_next = m_ordered_head;
238   if (m_ordered_head != NULL)
239      m_ordered_head->m_ordered_prev = &item;
240   m_ordered_head = &item;
241241
242   osd_lock_release(listlock);
242   osd_lock_release(m_listlock);
243243}
244244
245245
r7500r7501
255255      return;
256256
257257   // search for the item
258   osd_lock_acquire(listlock);
258   osd_lock_acquire(m_listlock);
259259
260   int hashval = reinterpret_cast<FPTR>(ptr) % hash_prime;
261   for (resource_pool_item **scanptr = &hash[hashval]; *scanptr != NULL; scanptr = &(*scanptr)->next)
260   int hashval = reinterpret_cast<FPTR>(ptr) % k_hash_prime;
261   for (resource_pool_item **scanptr = &m_hash[hashval]; *scanptr != NULL; scanptr = &(*scanptr)->m_next)
262262
263263      // must match the pointer
264      if ((*scanptr)->ptr == ptr)
264      if ((*scanptr)->m_ptr == ptr)
265265      {
266266         // remove from hash table
267267         resource_pool_item *deleteme = *scanptr;
268         *scanptr = deleteme->next;
268         *scanptr = deleteme->m_next;
269269
270270         // remove from ordered list
271         if (deleteme->ordered_prev != NULL)
272            deleteme->ordered_prev->ordered_next = deleteme->ordered_next;
271         if (deleteme->m_ordered_prev != NULL)
272            deleteme->m_ordered_prev->m_ordered_next = deleteme->m_ordered_next;
273273         else
274            ordered_head = deleteme->ordered_next;
275         if (deleteme->ordered_next != NULL)
276            deleteme->ordered_next->ordered_prev = deleteme->ordered_prev;
274            m_ordered_head = deleteme->m_ordered_next;
275         if (deleteme->m_ordered_next != NULL)
276            deleteme->m_ordered_next->m_ordered_prev = deleteme->m_ordered_prev;
277277
278278         // delete the object and break
279279         delete deleteme;
280280         break;
281281      }
282282
283   osd_lock_release(listlock);
283   osd_lock_release(m_listlock);
284284}
285285
286286
r7500r7501
292292resource_pool_item *resource_pool::find(void *ptr)
293293{
294294   // search for the item
295   osd_lock_acquire(listlock);
295   osd_lock_acquire(m_listlock);
296296
297   int hashval = reinterpret_cast<FPTR>(ptr) % hash_prime;
297   int hashval = reinterpret_cast<FPTR>(ptr) % k_hash_prime;
298298   resource_pool_item *item;
299   for (item = hash[hashval]; item != NULL; item = item->next)
300      if (item->ptr == ptr)
299   for (item = m_hash[hashval]; item != NULL; item = item->m_next)
300      if (item->m_ptr == ptr)
301301         break;
302302
303   osd_lock_release(listlock);
303   osd_lock_release(m_listlock);
304304
305305   return item;
306306}
r7500r7501
317317   UINT8 *ptrend = reinterpret_cast<UINT8 *>(_ptrend);
318318
319319   // search for the item
320   osd_lock_acquire(listlock);
320   osd_lock_acquire(m_listlock);
321321
322322   resource_pool_item *item = NULL;
323   for (item = ordered_head; item != NULL; item = item->ordered_next)
323   for (item = m_ordered_head; item != NULL; item = item->m_ordered_next)
324324   {
325      UINT8 *objstart = reinterpret_cast<UINT8 *>(item->ptr);
326      UINT8 *objend = objstart + item->size;
325      UINT8 *objstart = reinterpret_cast<UINT8 *>(item->m_ptr);
326      UINT8 *objend = objstart + item->m_size;
327327      if (ptrstart >= objstart && ptrend <= objend)
328328         goto found;
329329   }
330330
331331found:
332   osd_lock_release(listlock);
332   osd_lock_release(m_listlock);
333333
334334   return (item != NULL);
335335}
r7500r7501
341341
342342void resource_pool::clear()
343343{
344   osd_lock_acquire(listlock);
344   osd_lock_acquire(m_listlock);
345345
346346   // important: delete in reverse order of adding
347   while (ordered_head != NULL)
348      remove(ordered_head->ptr);
347   while (m_ordered_head != NULL)
348      remove(m_ordered_head->m_ptr);
349349
350   osd_lock_release(listlock);
350   osd_lock_release(m_listlock);
351351}
352352
353353
354354
355/***************************************************************************
356    MEMORY ENTRY
357***************************************************************************/
355//**************************************************************************
356//  MEMORY ENTRY
357//**************************************************************************
358358
359359/*-------------------------------------------------
360360    acquire_lock - acquire the memory entry lock,
r7500r7501
365365{
366366   // allocate a lock on first usage
367367   // note that osd_lock_alloc() may re-enter this path, so protect against recursion!
368   if (lock == NULL)
368   if (s_lock == NULL)
369369   {
370      if (lock_alloc)
370      if (s_lock_alloc)
371371         return;
372      lock_alloc = true;
373      lock = osd_lock_alloc();
374      lock_alloc = false;
372      s_lock_alloc = true;
373      s_lock = osd_lock_alloc();
374      s_lock_alloc = false;
375375   }
376   osd_lock_acquire(lock);
376   osd_lock_acquire(s_lock);
377377}
378378
379379
r7500r7501
383383
384384void memory_entry::release_lock()
385385{
386   osd_lock_release(lock);
386   osd_lock_release(s_lock);
387387}
388388
389389
r7500r7501
396396   acquire_lock();
397397
398398   // if we're out of free entries, allocate a new chunk
399   if (freehead == NULL)
399   if (s_freehead == NULL)
400400   {
401401      // create a new chunk, and fail if we can't
402402      memory_entry *entry = reinterpret_cast<memory_entry *>(osd_malloc(memory_block_alloc_chunk * sizeof(memory_entry)));
r7500r7501
409409      // add all the entries to the list
410410      for (int entrynum = 0; entrynum < memory_block_alloc_chunk; entrynum++)
411411      {
412         entry->next = freehead;
413         freehead = entry++;
412         entry->m_next = s_freehead;
413         s_freehead = entry++;
414414      }
415415   }
416416
417417   // grab a free entry
418   memory_entry *entry = freehead;
419   freehead = entry->next;
418   memory_entry *entry = s_freehead;
419   s_freehead = entry->m_next;
420420
421421   // populate it
422   entry->size = size;
423   entry->base = base;
424   entry->file = file;
425   entry->line = line;
426   entry->id = curid++;
422   entry->m_size = size;
423   entry->m_base = base;
424   entry->m_file = file;
425   entry->m_line = line;
426   entry->m_id = s_curid++;
427427
428428   // add it to the alloc list
429   int hashval = reinterpret_cast<FPTR>(base) % hash_prime;
430   entry->next = hash[hashval];
431   if (entry->next != NULL)
432      entry->next->prev = entry;
433   entry->prev = NULL;
434   hash[hashval] = entry;
429   int hashval = reinterpret_cast<FPTR>(base) % k_hash_prime;
430   entry->m_next = s_hash[hashval];
431   if (entry->m_next != NULL)
432      entry->m_next->m_prev = entry;
433   entry->m_prev = NULL;
434   s_hash[hashval] = entry;
435435
436436   release_lock();
437437   return entry;
r7500r7501
451451   // scan the list under the lock
452452   acquire_lock();
453453
454   int hashval = reinterpret_cast<FPTR>(ptr) % hash_prime;
454   int hashval = reinterpret_cast<FPTR>(ptr) % k_hash_prime;
455455   memory_entry *entry;
456   for (entry = hash[hashval]; entry != NULL; entry = entry->next)
457      if (entry->base == ptr)
456   for (entry = s_hash[hashval]; entry != NULL; entry = entry->m_next)
457      if (entry->m_base == ptr)
458458         break;
459459
460460   release_lock();
r7500r7501
471471   acquire_lock();
472472
473473   // remove ourselves from the alloc list
474   int hashval = reinterpret_cast<FPTR>(entry->base) % hash_prime;
475   if (entry->prev != NULL)
476      entry->prev->next = entry->next;
474   int hashval = reinterpret_cast<FPTR>(entry->m_base) % k_hash_prime;
475   if (entry->m_prev != NULL)
476      entry->m_prev->m_next = entry->m_next;
477477   else
478      hash[hashval] = entry->next;
479   if (entry->next != NULL)
480      entry->next->prev = entry->prev;
478      s_hash[hashval] = entry->m_next;
479   if (entry->m_next != NULL)
480      entry->m_next->m_prev = entry->m_prev;
481481
482482   // add ourself to the free list
483   entry->next = freehead;
484   freehead = entry;
483   entry->m_next = s_freehead;
484   s_freehead = entry;
485485
486486   release_lock();
487487}
r7500r7501
499499   // check for leaked memory
500500   UINT32 total = 0;
501501
502   for (int hashnum = 0; hashnum < hash_prime; hashnum++)
503      for (memory_entry *entry = hash[hashnum]; entry != NULL; entry = entry->next)
504         if (entry->file != NULL)
502   for (int hashnum = 0; hashnum < k_hash_prime; hashnum++)
503      for (memory_entry *entry = s_hash[hashnum]; entry != NULL; entry = entry->m_next)
504         if (entry->m_file != NULL)
505505         {
506506            if (total == 0)
507507               fprintf(stderr, "--- memory leak warning ---\n");
508            total += entry->size;
509            fprintf(stderr, "allocation #%06d, %d bytes (%s:%d)\n", entry->id, static_cast<UINT32>(entry->size), entry->file, (int)entry->line);
508            total += entry->m_size;
509            fprintf(stderr, "allocation #%06d, %d bytes (%s:%d)\n", entry->m_id, static_cast<UINT32>(entry->m_size), entry->m_file, (int)entry->m_line);
510510         }
511511
512512   release_lock();
r7500r7501
514514   if (total > 0)
515515      fprintf(stderr, "a total of %d bytes were not free()'d\n", total);
516516}
517
518
519
520/***************************************************************************
521    STANDARD NEW/DELETE OPERATORS
522***************************************************************************/
523
524void *operator new(std::size_t size) throw (std::bad_alloc)
525{
526   void *result = malloc_file_line(size, NULL, 0);
527   if (result == NULL)
528      throw std::bad_alloc();
529   return result;
530}
531
532
533void *operator new[](std::size_t size) throw (std::bad_alloc)
534{
535   void *result = malloc_file_line(size, NULL, 0);
536   if (result == NULL)
537      throw std::bad_alloc();
538   return result;
539}
540
541
542void operator delete(void *ptr)
543{
544   if (ptr != NULL)
545      free_file_line(ptr, NULL, 0);
546}
547
548
549void operator delete[](void *ptr)
550{
551   if (ptr != NULL)
552      free_file_line(ptr, NULL, 0);
553}
554
555
556
557/***************************************************************************
558    POOL NEW/DELETE OPERATORS
559***************************************************************************/
560
561void *operator new(std::size_t size, const char *file, int line) throw (std::bad_alloc)
562{
563   void *result = malloc_file_line(size, file, line);
564   if (result == NULL)
565      throw std::bad_alloc();
566   return result;
567}
568
569
570void *operator new[](std::size_t size, const char *file, int line) throw (std::bad_alloc)
571{
572   void *result = malloc_file_line(size, file, line);
573   if (result == NULL)
574      throw std::bad_alloc();
575   return result;
576}
577
578
579void operator delete(void *ptr, const char *file, int line)
580{
581   if (ptr != NULL)
582      free_file_line(ptr, file, line);
583}
584
585
586void operator delete[](void *ptr, const char *file, int line)
587{
588   if (ptr != NULL)
589      free_file_line(ptr, file, line);
590}
591
592
593
594/***************************************************************************
595    POOL NEW/DELETE OPERATORS WITH ZEROING
596***************************************************************************/
597
598void *operator new(std::size_t size, const char *file, int line, const zeromem_t &) throw (std::bad_alloc)
599{
600   void *result = malloc_file_line(size, file, line);
601   if (result == NULL)
602      throw std::bad_alloc();
603   memset(result, 0, size);
604   return result;
605}
606
607
608void *operator new[](std::size_t size, const char *file, int line, const zeromem_t &) throw (std::bad_alloc)
609{
610   void *result = malloc_file_line(size, file, line);
611   if (result == NULL)
612      throw std::bad_alloc();
613   memset(result, 0, size);
614   return result;
615}
616
617
618void operator delete(void *ptr, const char *file, int line, const zeromem_t &)
619{
620   if (ptr != NULL)
621      free_file_line(ptr, file, line);
622}
623
624
625void operator delete[](void *ptr, const char *file, int line, const zeromem_t &)
626{
627   if (ptr != NULL)
628      free_file_line(ptr, file, line);
629}
src/emu/emualloc.h
r7500r7501
4646#include "osdcore.h"
4747
4848
49/***************************************************************************
50    TYPE DEFINITIONS
51***************************************************************************/
49//**************************************************************************
50//  MACROS
51//**************************************************************************
5252
53// pool allocation helpers
54#define pool_alloc(_pool, _type)               (_pool).add_object(new(__FILE__, __LINE__) _type)
55#define pool_alloc_clear(_pool, _type)            (_pool).add_object(new(__FILE__, __LINE__, zeromem) _type)
56#define pool_alloc_array(_pool, _type, _num)      (_pool).add_array(new(__FILE__, __LINE__) _type[_num], (_num))
57#define pool_alloc_array_clear(_pool, _type, _num)   (_pool).add_array(new(__FILE__, __LINE__, zeromem) _type[_num], (_num))
58#define pool_free(_pool, v)                     (_pool).remove(v)
59
60// global allocation helpers
61#define global_alloc(_type)                     pool_alloc(global_resource_pool, _type)
62#define global_alloc_clear(_type)               pool_alloc_clear(global_resource_pool, _type)
63#define global_alloc_array(_type, _num)            pool_alloc_array(global_resource_pool, _type, _num)
64#define global_alloc_array_clear(_type, _num)      pool_alloc_array_clear(global_resource_pool, _type, _num)
65#define global_free(v)                        pool_free(global_resource_pool, v)
66
67
68
69//**************************************************************************
70//  TYPE DEFINITIONS
71//**************************************************************************
72
5373// zeromem_t is a dummy class used to tell new to zero memory after allocation
5474class zeromem_t { };
5575
r7500r7501
6282   resource_pool_item &operator=(const resource_pool_item &);
6383
6484public:
65   resource_pool_item(void *_ptr, size_t _size)
66      : next(NULL),
67        ordered_next(NULL),
68        ordered_prev(NULL),
69        ptr(_ptr),
70        size(_size) { }
85   resource_pool_item(void *ptr, size_t size)
86      : m_next(NULL),
87        m_ordered_next(NULL),
88        m_ordered_prev(NULL),
89        m_ptr(ptr),
90        m_size(size) { }
7191   virtual ~resource_pool_item() { }
7292
73   resource_pool_item *   next;
74   resource_pool_item *   ordered_next;
75   resource_pool_item *   ordered_prev;
76   void *               ptr;
77   size_t               size;
93   resource_pool_item *   m_next;
94   resource_pool_item *   m_ordered_next;
95   resource_pool_item *   m_ordered_prev;
96   void *               m_ptr;
97   size_t               m_size;
7898};
7999
80100
r7500r7501
86106   resource_pool_object<T> &operator=(const resource_pool_object<T> &);
87107
88108public:
89   resource_pool_object(T *_object)
90      : resource_pool_item(reinterpret_cast<void *>(_object), sizeof(T)),
91        object(_object) { }
92   virtual ~resource_pool_object() { delete object; }
109   resource_pool_object(T *object)
110      : resource_pool_item(reinterpret_cast<void *>(object), sizeof(T)),
111        m_object(object) { }
112   virtual ~resource_pool_object() { delete m_object; }
93113
94114private:
95   T *object;
115   T *                  m_object;
96116};
97117
98118
r7500r7501
105125   resource_pool_array<T> &operator=(const resource_pool_array<T> &);
106126
107127public:
108   resource_pool_array(T *_array, int _count)
109      : resource_pool_item(reinterpret_cast<void *>(_array), sizeof(T) * _count),
110        array(_array),
111        count(_count) { }
112   virtual ~resource_pool_array() { delete[] array; }
128   resource_pool_array(T *array, int count)
129      : resource_pool_item(reinterpret_cast<void *>(array), sizeof(T) * count),
130        m_array(array),
131        m_count(count) { }
132   virtual ~resource_pool_array() { delete[] m_array; }
113133
114134private:
115   T *array;
116   int count;
135   T *                  m_array;
136   int                m_count;
117137};
118138
119139
r7500r7501
129149   ~resource_pool();
130150
131151   void add(resource_pool_item &item);
132   void remove(resource_pool_item &item) { remove(item.ptr); }
152   void remove(resource_pool_item &item) { remove(item.m_ptr); }
133153   void remove(void *ptr);
134154   void remove(const void *ptr) { remove(const_cast<void *>(ptr)); }
135155   resource_pool_item *find(void *ptr);
r7500r7501
140160   template<class T> T *add_array(T* array, int count) { add(*new(__FILE__, __LINE__) resource_pool_array<T>(array, count)); return array; }
141161
142162private:
143   static const int      hash_prime = 193;
163   static const int      k_hash_prime = 193;
144164
145   osd_lock *            listlock;
146   resource_pool_item *   hash[hash_prime];
147   resource_pool_item *   ordered_head;
165   osd_lock *            m_listlock;
166   resource_pool_item *   m_hash[k_hash_prime];
167   resource_pool_item *   m_ordered_head;
148168};
149169
150170
151171
152/***************************************************************************
153    MACROS
154***************************************************************************/
172//**************************************************************************
173//  GLOBAL VARIABLES
174//**************************************************************************
155175
156// re-route classic malloc-style allocations
157#undef malloc
158#undef calloc
159#undef realloc
160#undef free
161
162#define malloc(x)      malloc_file_line(x, __FILE__, __LINE__)
163#define calloc(x,y)      __error_use_auto_alloc_clear_or_global_alloc_clear_instead__
164#define realloc(x,y)   __error_realloc_is_dangerous__
165#define free(x)         free_file_line(x, __FILE__, __LINE__)
166
167// pool allocation helpers
168#define pool_alloc(_pool, _type)               (_pool).add_object(new(__FILE__, __LINE__) _type)
169#define pool_alloc_clear(_pool, _type)            (_pool).add_object(new(__FILE__, __LINE__, zeromem) _type)
170#define pool_alloc_array(_pool, _type, _num)      (_pool).add_array(new(__FILE__, __LINE__) _type[_num], (_num))
171#define pool_alloc_array_clear(_pool, _type, _num)   (_pool).add_array(new(__FILE__, __LINE__, zeromem) _type[_num], (_num))
172#define pool_free(_pool, v)                     (_pool).remove(v)
173
174// global allocation helpers
175#define global_alloc(_type)                     pool_alloc(global_resource_pool, _type)
176#define global_alloc_clear(_type)               pool_alloc_clear(global_resource_pool, _type)
177#define global_alloc_array(_type, _num)            pool_alloc_array(global_resource_pool, _type, _num)
178#define global_alloc_array_clear(_type, _num)      pool_alloc_array_clear(global_resource_pool, _type, _num)
179#define global_free(v)                        pool_free(global_resource_pool, v)
180
181
182
183/***************************************************************************
184    GLOBAL VARIABLES
185***************************************************************************/
186
187176// global resource pool
188177extern resource_pool global_resource_pool;
189178
r7500r7501
192181
193182
194183
195/***************************************************************************
196    FUNCTION PROTOTYPES
197***************************************************************************/
184//**************************************************************************
185//  FUNCTION PROTOTYPES
186//**************************************************************************
198187
199188// allocate memory with file and line number information
200189void *malloc_file_line(size_t size, const char *file, int line);
r7500r7501
202191// free memory with file and line number information
203192void free_file_line(void *memory, const char *file, int line);
204193
205// called from the exit path of any code that wants to check for unfreed memory
194// called from the exit path of any code that wants to check for unfreed memory
206195void dump_unfreed_mem();
207196
197
198
199//**************************************************************************
200//  INLINE FUNCTIONS
201//**************************************************************************
202
208203// standard new/delete operators (try to avoid using)
209void *operator new(std::size_t size) throw (std::bad_alloc);
210void *operator new[](std::size_t size) throw (std::bad_alloc);
211void operator delete(void *ptr);
212void operator delete[](void *ptr);
204inline void *operator new(std::size_t size) throw (std::bad_alloc)
205{
206   void *result = malloc_file_line(size, NULL, 0);
207   if (result == NULL)
208      throw std::bad_alloc();
209   return result;
210}
213211
212inline void *operator new[](std::size_t size) throw (std::bad_alloc)
213{
214   void *result = malloc_file_line(size, NULL, 0);
215   if (result == NULL)
216      throw std::bad_alloc();
217   return result;
218}
219
220inline void operator delete(void *ptr)
221{
222   if (ptr != NULL)
223      free_file_line(ptr, NULL, 0);
224}
225
226inline void operator delete[](void *ptr)
227{
228   if (ptr != NULL)
229      free_file_line(ptr, NULL, 0);
230}
231
232
214233// file/line new/delete operators
215void *operator new(std::size_t size, const char *file, int line) throw (std::bad_alloc);
216void *operator new[](std::size_t size, const char *file, int line) throw (std::bad_alloc);
217void operator delete(void *ptr, const char *file, int line);
218void operator delete[](void *ptr, const char *file, int line);
234inline void *operator new(std::size_t size, const char *file, int line) throw (std::bad_alloc)
235{
236   void *result = malloc_file_line(size, file, line);
237   if (result == NULL)
238      throw std::bad_alloc();
239   return result;
240}
219241
242inline void *operator new[](std::size_t size, const char *file, int line) throw (std::bad_alloc)
243{
244   void *result = malloc_file_line(size, file, line);
245   if (result == NULL)
246      throw std::bad_alloc();
247   return result;
248}
249
250inline void operator delete(void *ptr, const char *file, int line)
251{
252   if (ptr != NULL)
253      free_file_line(ptr, file, line);
254}
255
256inline void operator delete[](void *ptr, const char *file, int line)
257{
258   if (ptr != NULL)
259      free_file_line(ptr, file, line);
260}
261
262
220263// file/line new/delete operators with zeroing
221void *operator new(std::size_t size, const char *file, int line, const zeromem_t &) throw (std::bad_alloc);
222void *operator new[](std::size_t size, const char *file, int line, const zeromem_t &) throw (std::bad_alloc);
223void operator delete(void *ptr, const char *file, int line, const zeromem_t &);
224void operator delete[](void *ptr, const char *file, int line, const zeromem_t &);
264inline void *operator new(std::size_t size, const char *file, int line, const zeromem_t &) throw (std::bad_alloc)
265{
266   void *result = malloc_file_line(size, file, line);
267   if (result == NULL)
268      throw std::bad_alloc();
269   memset(result, 0, size);
270   return result;
271}
225272
273inline void *operator new[](std::size_t size, const char *file, int line, const zeromem_t &) throw (std::bad_alloc)
274{
275   void *result = malloc_file_line(size, file, line);
276   if (result == NULL)
277      throw std::bad_alloc();
278   memset(result, 0, size);
279   return result;
280}
226281
282inline void operator delete(void *ptr, const char *file, int line, const zeromem_t &)
283{
284   if (ptr != NULL)
285      free_file_line(ptr, file, line);
286}
227287
228/***************************************************************************
229    ADDITIONAL MACROS
230***************************************************************************/
288inline void operator delete[](void *ptr, const char *file, int line, const zeromem_t &)
289{
290   if (ptr != NULL)
291      free_file_line(ptr, file, line);
292}
231293
294
295
296//**************************************************************************
297//  ADDDITIONAL MACROS
298//**************************************************************************
299
300// re-route classic malloc-style allocations
301#undef malloc
302#undef calloc
303#undef realloc
304#undef free
305
306#define malloc(x)      malloc_file_line(x, __FILE__, __LINE__)
307#define calloc(x,y)      __error_use_auto_alloc_clear_or_global_alloc_clear_instead__
308#define realloc(x,y)   __error_realloc_is_dangerous__
309#define free(x)         free_file_line(x, __FILE__, __LINE__)
310
232311// disable direct deletion
233312#define delete         __error_use_pool_free_mechanisms__
234313
235314
236
237315#endif   /* __EMUALLOC_H__ */
src/emu/sound/k051649.c
r7500r7501
158158   int i;
159159
160160   /* reset all the voices */
161   for (i=0; i>5; i++) {
161   for (i = 0; i < 5; i++) {
162162      voice[i].frequency = 0;
163163      voice[i].volume = 0;
164164      voice[i].counter = 0;
src/emu/sound/mos6560.c
r7500r7501
506506
507507
508508/*-------------------------------------------------
509 mos6560_video_update - copy the VIC bitmap to
509 mos6560_video_update - copy the VIC bitmap to
510510     main screen bitmap
511511-------------------------------------------------*/
512512
src/emu/sound/disc_mth.c
r7500r7501
16211621 * input[3]    - Threshold for enable
16221622 *
16231623 ************************************************************************/
1624#define DST_ASWITCH__CTRL      DISCRETE_INPUT(1)
1625#define DST_ASWITCH__IN         DISCRETE_INPUT(2)
1626#define DST_ASWITCH__THRESHOLD   DISCRETE_INPUT(3)
1624#define DST_ASWITCH__CTRL      DISCRETE_INPUT(0)
1625#define DST_ASWITCH__IN         DISCRETE_INPUT(1)
1626#define DST_ASWITCH__THRESHOLD   DISCRETE_INPUT(2)
16271627
16281628
16291629static DISCRETE_STEP(dst_aswitch)
src/emu/sound/sn76496.c
r7500r7501
8888  Thanks to PlgDavid for providing samples which helped immensely here.
8989  Added true clock divider emulation, so sn94624 and sn76494 run 8x faster than
9090  the others, as in real life.
91 
91
9292  15/02/2010: Lord Nightmare & Michael Zapf (additional testing by PlgDavid)
9393  Fix noise period when set to mirror channel 3 and channel 3 period is set to 0 (tested on hardware for noise, wave needs tests) - MZ
9494  Fix phase of noise on sn94624 and sn76489; all chips use a standard XOR, the only inversion is the output itself - LN, Plgdavid
src/emu/sound/es5506.c
r7500r7501
210210   /* allocate volume lookup table */
211211   chip->volume_lookup = auto_alloc_array(chip->device->machine, UINT16, 4096);
212212
213   /* generate ulaw lookup table */
213   /* generate volume lookup table */
214214   for (i = 0; i < 4096; i++)
215215   {
216216      UINT8 exponent = i >> 8;
r7500r7501
870870   /* allocate memory */
871871   chip->scratch = auto_alloc_array(device->machine, INT32, 2 * MAX_SAMPLE_CHUNK);
872872
873   /* register save */
874   state_save_register_device_item(device, 0, chip->sample_rate);
875   state_save_register_device_item(device, 0, chip->write_latch);
876   state_save_register_device_item(device, 0, chip->read_latch);
877
878   state_save_register_device_item(device, 0, chip->current_page);
879   state_save_register_device_item(device, 0, chip->active_voices);
880   state_save_register_device_item(device, 0, chip->mode);
881   state_save_register_device_item(device, 0, chip->wst);
882   state_save_register_device_item(device, 0, chip->wend);
883   state_save_register_device_item(device, 0, chip->lrend);
884   state_save_register_device_item(device, 0, chip->irqv);
885
886   state_save_register_device_item_pointer(device, 0, chip->scratch, 2 * MAX_SAMPLE_CHUNK);
887
888   for (j = 0; j < 32; j++)
889   {
890      state_save_register_device_item(device, j, chip->voice[j].control);
891      state_save_register_device_item(device, j, chip->voice[j].freqcount);
892      state_save_register_device_item(device, j, chip->voice[j].start);
893      state_save_register_device_item(device, j, chip->voice[j].lvol);
894      state_save_register_device_item(device, j, chip->voice[j].end);
895      state_save_register_device_item(device, j, chip->voice[j].lvramp);
896      state_save_register_device_item(device, j, chip->voice[j].accum);
897      state_save_register_device_item(device, j, chip->voice[j].rvol);
898      state_save_register_device_item(device, j, chip->voice[j].rvramp);
899      state_save_register_device_item(device, j, chip->voice[j].ecount);
900      state_save_register_device_item(device, j, chip->voice[j].k2);
901      state_save_register_device_item(device, j, chip->voice[j].k2ramp);
902      state_save_register_device_item(device, j, chip->voice[j].k1);
903      state_save_register_device_item(device, j, chip->voice[j].k1ramp);
904      state_save_register_device_item(device, j, chip->voice[j].o4n1);
905      state_save_register_device_item(device, j, chip->voice[j].o3n1);
906      state_save_register_device_item(device, j, chip->voice[j].o3n2);
907      state_save_register_device_item(device, j, chip->voice[j].o2n1);
908      state_save_register_device_item(device, j, chip->voice[j].o2n2);
909      state_save_register_device_item(device, j, chip->voice[j].o1n1);
910      state_save_register_device_item(device, j, chip->voice[j].exbank);
911      state_save_register_device_item(device, j, chip->voice[j].filtcount);
912   }
913
873914   /* success */
874915}
875916
src/emu/sound/sound.mak
r7500r7501
270270endif
271271
272272
273
273274#-------------------------------------------------
274275# MOS 6560VIC
275276#-------------------------------------------------
src/emu/drawgfx.c
r7500r7501
153153         /* loop over all the planes, converting fractions */
154154         for (j = 0; j < planes; j++)
155155         {
156            UINT32 value = extpoffs[j];
157            if (IS_FRAC(value))
156            UINT32 value1 = extpoffs[j];
157            if (IS_FRAC(value1))
158158            {
159159               assert(region_length != 0);
160               extpoffs[j] = FRAC_OFFSET(value) + region_length * FRAC_NUM(value) / FRAC_DEN(value);
160               extpoffs[j] = FRAC_OFFSET(value1) + region_length * FRAC_NUM(value1) / FRAC_DEN(value1);
161161            }
162162         }
163163
164164         /* loop over all the X/Y offsets, converting fractions */
165165         for (j = 0; j < width; j++)
166166         {
167            UINT32 value = extxoffs[j];
168            if (IS_FRAC(value))
167            UINT32 value2 = extxoffs[j];
168            if (IS_FRAC(value2))
169169            {
170170               assert(region_length != 0);
171               extxoffs[j] = FRAC_OFFSET(value) + region_length * FRAC_NUM(value) / FRAC_DEN(value);
171               extxoffs[j] = FRAC_OFFSET(value2) + region_length * FRAC_NUM(value2) / FRAC_DEN(value2);
172172            }
173173         }
174174
175175         for (j = 0; j < height; j++)
176176         {
177            UINT32 value = extyoffs[j];
178            if (IS_FRAC(value))
177            UINT32 value3 = extyoffs[j];
178            if (IS_FRAC(value3))
179179            {
180180               assert(region_length != 0);
181               extyoffs[j] = FRAC_OFFSET(value) + region_length * FRAC_NUM(value) / FRAC_DEN(value);
181               extyoffs[j] = FRAC_OFFSET(value3) + region_length * FRAC_NUM(value3) / FRAC_DEN(value3);
182182            }
183183         }
184184      }
src/emu/debugint/debugint.c
r7500r7501
13061306            {
13071307               /* autoschow */
13081308               cur_editor = &focus_view->editor;
1309               cur_editor->str = cur_editor->str.substr(0, cur_editor->str.len());
1309               cur_editor->str = cur_editor->str.substr(0, cur_editor->str.len()-1);
13101310            }
13111311            /* if it's any other key and we're not maxed out, update */
13121312            else if (event.ch >= ' ' && event.ch < 0x7f)
src/emu/mconfig.c
r7500r7501
188188
189189         /* core parameters */
190190         case MCONFIG_TOKEN_DRIVER_DATA:
191            TOKEN_UNGET_UINT32(tokens);
192            TOKEN_GET_UINT32_UNPACK2(tokens, entrytype, 8, config->driver_data_size, 24);
191            config->driver_data_alloc = TOKEN_GET_PTR(tokens, driver_data_alloc);
193192            break;
194193
195194         case MCONFIG_TOKEN_QUANTUM_TIME:
src/emu/validity.c
r7500r7501
14261426               error |= validate_tag(driver, "bank", entry->write.tag);
14271427            if (entry->share != NULL)
14281428               error |= validate_tag(driver, "share", entry->share);
1429
1430            /* if there are base or size members, check that they are within bounds */
1431            if (entry->baseptroffs_plus1 != 0 && (entry->baseptroffs_plus1 - 1) >= config->driver_data_size)
1432            {
1433               mame_printf_error("%s: %s device '%s' %s space memory map has an out of bounds AM_BASE_MEMBER entry\n", driver->source_file, driver->name, devconfig->tag.cstr(), address_space_names[spacenum]);
1434               error = TRUE;
1435            }
1436            if (entry->sizeptroffs_plus1 != 0 && (entry->sizeptroffs_plus1 - 1) >= config->driver_data_size)
1437            {
1438               mame_printf_error("%s: %s device '%s' %s space memory map has an out of bounds AM_SIZE_MEMBER entry\n", driver->source_file, driver->name, devconfig->tag.cstr(), address_space_names[spacenum]);
1439               error = TRUE;
1440            }
14411429         }
14421430
14431431         /* release the address map */
src/emu/mconfig.h
r7500r7501
8989typedef void   (*palette_init_func)(running_machine *machine, const UINT8 *color_prom);
9090typedef void   (*video_eof_func)(running_machine *machine);
9191typedef UINT32 (*video_update_func)(running_device *screen, bitmap_t *bitmap, const rectangle *cliprect);
92typedef void * (*driver_data_alloc_func)(running_machine &machine);
9293
9394
9495
r7500r7501
192193typedef struct _machine_config machine_config;
193194struct _machine_config
194195{
195   UINT32               driver_data_size;      /* amount of memory needed for driver_data */
196   driver_data_alloc_func   driver_data_alloc;      /* allocator for driver data */
196197
197198   attotime            minimum_quantum;      /* minimum scheduling quantum */
198199   const char *         perfect_cpu_quantum;   /* tag of CPU to use for "perfect" scheduling */
r7500r7501
247248   palette_init_func palette_init;
248249   video_eof_func video_eof;
249250   video_update_func video_update;
251   driver_data_alloc_func driver_data_alloc;
250252};
251253
252254
r7500r7501
276278
277279
278280/* core parameters */
279#define MDRV_DRIVER_DATA(_struct) \
280   TOKEN_UINT32_PACK2(MCONFIG_TOKEN_DRIVER_DATA, 8, sizeof(_struct), 24),
281#define MDRV_DRIVER_DATA(_class) \
282   TOKEN_UINT32_PACK1(MCONFIG_TOKEN_DRIVER_DATA, 8), \
283   TOKEN_PTR(driver_data_alloc, _class::alloc),
281284
282285#define MDRV_QUANTUM_TIME(_time) \
283286   TOKEN_UINT32_PACK1(MCONFIG_TOKEN_QUANTUM_TIME, 8), \
src/lib/softfloat/softfloat.c
r0r7501
1
2/*============================================================================
3
4This C source file is part of the SoftFloat IEC/IEEE Floating-point Arithmetic
5Package, Release 2b.
6
7Written by John R. Hauser.  This work was made possible in part by the
8International Computer Science Institute, located at Suite 600, 1947 Center
9Street, Berkeley, California 94704.  Funding was partially provided by the
10National Science Foundation under grant MIP-9311980.  The original version
11of this code was written as part of a project to build a fixed-point vector
12processor in collaboration with the University of California at Berkeley,
13overseen by Profs. Nelson Morgan and John Wawrzynek.  More information
14is available through the Web page `http://www.cs.berkeley.edu/~jhauser/
15arithmetic/SoftFloat.html'.
16
17THIS SOFTWARE IS DISTRIBUTED AS IS, FOR FREE.  Although reasonable effort has
18been made to avoid it, THIS SOFTWARE MAY CONTAIN FAULTS THAT WILL AT TIMES
19RESULT IN INCORRECT BEHAVIOR.  USE OF THIS SOFTWARE IS RESTRICTED TO PERSONS
20AND ORGANIZATIONS WHO CAN AND WILL TAKE FULL RESPONSIBILITY FOR ALL LOSSES,
21COSTS, OR OTHER PROBLEMS THEY INCUR DUE TO THE SOFTWARE, AND WHO FURTHERMORE
22EFFECTIVELY INDEMNIFY JOHN HAUSER AND THE INTERNATIONAL COMPUTER SCIENCE
23INSTITUTE (possibly via similar legal warning) AGAINST ALL LOSSES, COSTS, OR
24OTHER PROBLEMS INCURRED BY THEIR CUSTOMERS AND CLIENTS DUE TO THE SOFTWARE.
25
26Derivative works are acceptable, even for commercial purposes, so long as
27(1) the source code for the derivative work includes prominent notice that
28the work is derivative, and (2) the source code includes prominent notice with
29these four paragraphs for those parts of this code that are retained.
30
31=============================================================================*/
32
33#include "milieu.h"
34#include "softfloat.h"
35
36/*----------------------------------------------------------------------------
37| Floating-point rounding mode, extended double-precision rounding precision,
38| and exception flags.
39*----------------------------------------------------------------------------*/
40int8 float_rounding_mode = float_round_nearest_even;
41int8 float_exception_flags = 0;
42#ifdef FLOATX80
43int8 floatx80_rounding_precision = 80;
44#endif
45
46/*----------------------------------------------------------------------------
47| Primitive arithmetic functions, including multi-word arithmetic, and
48| division and square root approximations.  (Can be specialized to target if
49| desired.)
50*----------------------------------------------------------------------------*/
51#include "softfloat-macros"
52
53/*----------------------------------------------------------------------------
54| Functions and definitions to determine:  (1) whether tininess for underflow
55| is detected before or after rounding by default, (2) what (if anything)
56| happens when exceptions are raised, (3) how signaling NaNs are distinguished
57| from quiet NaNs, (4) the default generated quiet NaNs, and (5) how NaNs
58| are propagated from function inputs to output.  These details are target-
59| specific.
60*----------------------------------------------------------------------------*/
61#include "softfloat-specialize"
62
63/*----------------------------------------------------------------------------
64| Takes a 64-bit fixed-point value `absZ' with binary point between bits 6
65| and 7, and returns the properly rounded 32-bit integer corresponding to the
66| input.  If `zSign' is 1, the input is negated before being converted to an
67| integer.  Bit 63 of `absZ' must be zero.  Ordinarily, the fixed-point input
68| is simply rounded to an integer, with the inexact exception raised if the
69| input cannot be represented exactly as an integer.  However, if the fixed-
70| point input is too large, the invalid exception is raised and the largest
71| positive or negative integer is returned.
72*----------------------------------------------------------------------------*/
73
74static int32 roundAndPackInt32( flag zSign, bits64 absZ )
75{
76    int8 roundingMode;
77    flag roundNearestEven;
78    int8 roundIncrement, roundBits;
79    int32 z;
80
81    roundingMode = float_rounding_mode;
82    roundNearestEven = ( roundingMode == float_round_nearest_even );
83    roundIncrement = 0x40;
84    if ( ! roundNearestEven ) {
85        if ( roundingMode == float_round_to_zero ) {
86            roundIncrement = 0;
87        }
88        else {
89            roundIncrement = 0x7F;
90            if ( zSign ) {
91                if ( roundingMode == float_round_up ) roundIncrement = 0;
92            }
93            else {
94                if ( roundingMode == float_round_down ) roundIncrement = 0;
95            }
96        }
97    }
98    roundBits = absZ & 0x7F;
99    absZ = ( absZ + roundIncrement )>>7;
100    absZ &= ~ ( ( ( roundBits ^ 0x40 ) == 0 ) & roundNearestEven );
101    z = absZ;
102    if ( zSign ) z = - z;
103    if ( ( absZ>>32 ) || ( z && ( ( z < 0 ) ^ zSign ) ) ) {
104        float_raise( float_flag_invalid );
105        return zSign ? (sbits32) 0x80000000 : 0x7FFFFFFF;
106    }
107    if ( roundBits ) float_exception_flags |= float_flag_inexact;
108    return z;
109
110}
111
112/*----------------------------------------------------------------------------
113| Takes the 128-bit fixed-point value formed by concatenating `absZ0' and
114| `absZ1', with binary point between bits 63 and 64 (between the input words),
115| and returns the properly rounded 64-bit integer corresponding to the input.
116| If `zSign' is 1, the input is negated before being converted to an integer.
117| Ordinarily, the fixed-point input is simply rounded to an integer, with
118| the inexact exception raised if the input cannot be represented exactly as
119| an integer.  However, if the fixed-point input is too large, the invalid
120| exception is raised and the largest positive or negative integer is
121| returned.
122*----------------------------------------------------------------------------*/
123
124static int64 roundAndPackInt64( flag zSign, bits64 absZ0, bits64 absZ1 )
125{
126    int8 roundingMode;
127    flag roundNearestEven, increment;
128    int64 z;
129
130    roundingMode = float_rounding_mode;
131    roundNearestEven = ( roundingMode == float_round_nearest_even );
132    increment = ( (sbits64) absZ1 < 0 );
133    if ( ! roundNearestEven ) {
134        if ( roundingMode == float_round_to_zero ) {
135            increment = 0;
136        }
137        else {
138            if ( zSign ) {
139                increment = ( roundingMode == float_round_down ) && absZ1;
140            }
141            else {
142                increment = ( roundingMode == float_round_up ) && absZ1;
143            }
144        }
145    }
146    if ( increment ) {
147        ++absZ0;
148        if ( absZ0 == 0 ) goto overflow;
149        absZ0 &= ~ ( ( (bits64) ( absZ1<<1 ) == 0 ) & roundNearestEven );
150    }
151    z = absZ0;
152    if ( zSign ) z = - z;
153    if ( z && ( ( z < 0 ) ^ zSign ) ) {
154 overflow:
155        float_raise( float_flag_invalid );
156        return
157              zSign ? (sbits64) LIT64( 0x8000000000000000 )
158            : LIT64( 0x7FFFFFFFFFFFFFFF );
159    }
160    if ( absZ1 ) float_exception_flags |= float_flag_inexact;
161    return z;
162
163}
164
165/*----------------------------------------------------------------------------
166| Returns the fraction bits of the single-precision floating-point value `a'.
167*----------------------------------------------------------------------------*/
168
169INLINE bits32 extractFloat32Frac( float32 a )
170{
171
172    return a & 0x007FFFFF;
173
174}
175
176/*----------------------------------------------------------------------------
177| Returns the exponent bits of the single-precision floating-point value `a'.
178*----------------------------------------------------------------------------*/
179
180INLINE int16 extractFloat32Exp( float32 a )
181{
182
183    return ( a>>23 ) & 0xFF;
184
185}
186
187/*----------------------------------------------------------------------------
188| Returns the sign bit of the single-precision floating-point value `a'.
189*----------------------------------------------------------------------------*/
190
191INLINE flag extractFloat32Sign( float32 a )
192{
193
194    return a>>31;
195
196}
197
198/*----------------------------------------------------------------------------
199| Normalizes the subnormal single-precision floating-point value represented
200| by the denormalized significand `aSig'.  The normalized exponent and
201| significand are stored at the locations pointed to by `zExpPtr' and
202| `zSigPtr', respectively.
203*----------------------------------------------------------------------------*/
204
205static void
206 normalizeFloat32Subnormal( bits32 aSig, int16 *zExpPtr, bits32 *zSigPtr )
207{
208    int8 shiftCount;
209
210    shiftCount = countLeadingZeros32( aSig ) - 8;
211    *zSigPtr = aSig<<shiftCount;
212    *zExpPtr = 1 - shiftCount;
213
214}
215
216/*----------------------------------------------------------------------------
217| Packs the sign `zSign', exponent `zExp', and significand `zSig' into a
218| single-precision floating-point value, returning the result.  After being
219| shifted into the proper positions, the three fields are simply added
220| together to form the result.  This means that any integer portion of `zSig'
221| will be added into the exponent.  Since a properly normalized significand
222| will have an integer portion equal to 1, the `zExp' input should be 1 less
223| than the desired result exponent whenever `zSig' is a complete, normalized
224| significand.
225*----------------------------------------------------------------------------*/
226
227INLINE float32 packFloat32( flag zSign, int16 zExp, bits32 zSig )
228{
229
230    return ( ( (bits32) zSign )<<31 ) + ( ( (bits32) zExp )<<23 ) + zSig;
231
232}
233
234/*----------------------------------------------------------------------------
235| Takes an abstract floating-point value having sign `zSign', exponent `zExp',
236| and significand `zSig', and returns the proper single-precision floating-
237| point value corresponding to the abstract input.  Ordinarily, the abstract
238| value is simply rounded and packed into the single-precision format, with
239| the inexact exception raised if the abstract input cannot be represented
240| exactly.  However, if the abstract value is too large, the overflow and
241| inexact exceptions are raised and an infinity or maximal finite value is
242| returned.  If the abstract value is too small, the input value is rounded to
243| a subnormal number, and the underflow and inexact exceptions are raised if
244| the abstract input cannot be represented exactly as a subnormal single-
245| precision floating-point number.
246|     The input significand `zSig' has its binary point between bits 30
247| and 29, which is 7 bits to the left of the usual location.  This shifted
248| significand must be normalized or smaller.  If `zSig' is not normalized,
249| `zExp' must be 0; in that case, the result returned is a subnormal number,
250| and it must not require rounding.  In the usual case that `zSig' is
251| normalized, `zExp' must be 1 less than the ``true'' floating-point exponent.
252| The handling of underflow and overflow follows the IEC/IEEE Standard for
253| Binary Floating-Point Arithmetic.
254*----------------------------------------------------------------------------*/
255
256static float32 roundAndPackFloat32( flag zSign, int16 zExp, bits32 zSig )
257{
258    int8 roundingMode;
259    flag roundNearestEven;
260    int8 roundIncrement, roundBits;
261    flag isTiny;
262
263    roundingMode = float_rounding_mode;
264    roundNearestEven = ( roundingMode == float_round_nearest_even );
265    roundIncrement = 0x40;
266    if ( ! roundNearestEven ) {
267        if ( roundingMode == float_round_to_zero ) {
268            roundIncrement = 0;
269        }
270        else {
271            roundIncrement = 0x7F;
272            if ( zSign ) {
273                if ( roundingMode == float_round_up ) roundIncrement = 0;
274            }
275            else {
276                if ( roundingMode == float_round_down ) roundIncrement = 0;
277            }
278        }
279    }
280    roundBits = zSig & 0x7F;
281    if ( 0xFD <= (bits16) zExp ) {
282        if (    ( 0xFD < zExp )
283             || (    ( zExp == 0xFD )
284                  && ( (sbits32) ( zSig + roundIncrement ) < 0 ) )
285           ) {
286            float_raise( float_flag_overflow | float_flag_inexact );
287            return packFloat32( zSign, 0xFF, 0 ) - ( roundIncrement == 0 );
288        }
289        if ( zExp < 0 ) {
290            isTiny =
291                   ( float_detect_tininess == float_tininess_before_rounding )
292                || ( zExp < -1 )
293                || ( zSig + roundIncrement < 0x80000000 );
294            shift32RightJamming( zSig, - zExp, &zSig );
295            zExp = 0;
296            roundBits = zSig & 0x7F;
297            if ( isTiny && roundBits ) float_raise( float_flag_underflow );
298        }
299    }
300    if ( roundBits ) float_exception_flags |= float_flag_inexact;
301    zSig = ( zSig + roundIncrement )>>7;
302    zSig &= ~ ( ( ( roundBits ^ 0x40 ) == 0 ) & roundNearestEven );
303    if ( zSig == 0 ) zExp = 0;
304    return packFloat32( zSign, zExp, zSig );
305
306}
307
308/*----------------------------------------------------------------------------
309| Takes an abstract floating-point value having sign `zSign', exponent `zExp',
310| and significand `zSig', and returns the proper single-precision floating-
311| point value corresponding to the abstract input.  This routine is just like
312| `roundAndPackFloat32' except that `zSig' does not have to be normalized.
313| Bit 31 of `zSig' must be zero, and `zExp' must be 1 less than the ``true''
314| floating-point exponent.
315*----------------------------------------------------------------------------*/
316
317static float32
318 normalizeRoundAndPackFloat32( flag zSign, int16 zExp, bits32 zSig )
319{
320    int8 shiftCount;
321
322    shiftCount = countLeadingZeros32( zSig ) - 1;
323    return roundAndPackFloat32( zSign, zExp - shiftCount, zSig<<shiftCount );
324
325}
326
327/*----------------------------------------------------------------------------
328| Returns the fraction bits of the double-precision floating-point value `a'.
329*----------------------------------------------------------------------------*/
330
331INLINE bits64 extractFloat64Frac( float64 a )
332{
333
334    return a & LIT64( 0x000FFFFFFFFFFFFF );
335
336}
337
338/*----------------------------------------------------------------------------
339| Returns the exponent bits of the double-precision floating-point value `a'.
340*----------------------------------------------------------------------------*/
341
342INLINE int16 extractFloat64Exp( float64 a )
343{
344
345    return ( a>>52 ) & 0x7FF;
346
347}
348
349/*----------------------------------------------------------------------------
350| Returns the sign bit of the double-precision floating-point value `a'.
351*----------------------------------------------------------------------------*/
352
353INLINE flag extractFloat64Sign( float64 a )
354{
355
356    return a>>63;
357
358}
359
360/*----------------------------------------------------------------------------
361| Normalizes the subnormal double-precision floating-point value represented
362| by the denormalized significand `aSig'.  The normalized exponent and
363| significand are stored at the locations pointed to by `zExpPtr' and
364| `zSigPtr', respectively.
365*----------------------------------------------------------------------------*/
366
367static void
368 normalizeFloat64Subnormal( bits64 aSig, int16 *zExpPtr, bits64 *zSigPtr )
369{
370    int8 shiftCount;
371
372    shiftCount = countLeadingZeros64( aSig ) - 11;
373    *zSigPtr = aSig<<shiftCount;
374    *zExpPtr = 1 - shiftCount;
375
376}
377
378/*----------------------------------------------------------------------------
379| Packs the sign `zSign', exponent `zExp', and significand `zSig' into a
380| double-precision floating-point value, returning the result.  After being
381| shifted into the proper positions, the three fields are simply added
382| together to form the result.  This means that any integer portion of `zSig'
383| will be added into the exponent.  Since a properly normalized significand
384| will have an integer portion equal to 1, the `zExp' input should be 1 less
385| than the desired result exponent whenever `zSig' is a complete, normalized
386| significand.
387*----------------------------------------------------------------------------*/
388
389INLINE float64 packFloat64( flag zSign, int16 zExp, bits64 zSig )
390{
391
392    return ( ( (bits64) zSign )<<63 ) + ( ( (bits64) zExp )<<52 ) + zSig;
393
394}
395
396/*----------------------------------------------------------------------------
397| Takes an abstract floating-point value having sign `zSign', exponent `zExp',
398| and significand `zSig', and returns the proper double-precision floating-
399| point value corresponding to the abstract input.  Ordinarily, the abstract
400| value is simply rounded and packed into the double-precision format, with
401| the inexact exception raised if the abstract input cannot be represented
402| exactly.  However, if the abstract value is too large, the overflow and
403| inexact exceptions are raised and an infinity or maximal finite value is
404| returned.  If the abstract value is too small, the input value is rounded
405| to a subnormal number, and the underflow and inexact exceptions are raised
406| if the abstract input cannot be represented exactly as a subnormal double-
407| precision floating-point number.
408|     The input significand `zSig' has its binary point between bits 62
409| and 61, which is 10 bits to the left of the usual location.  This shifted
410| significand must be normalized or smaller.  If `zSig' is not normalized,
411| `zExp' must be 0; in that case, the result returned is a subnormal number,
412| and it must not require rounding.  In the usual case that `zSig' is
413| normalized, `zExp' must be 1 less than the ``true'' floating-point exponent.
414| The handling of underflow and overflow follows the IEC/IEEE Standard for
415| Binary Floating-Point Arithmetic.
416*----------------------------------------------------------------------------*/
417
418static float64 roundAndPackFloat64( flag zSign, int16 zExp, bits64 zSig )
419{
420    int8 roundingMode;
421    flag roundNearestEven;
422    int16 roundIncrement, roundBits;
423    flag isTiny;
424
425    roundingMode = float_rounding_mode;
426    roundNearestEven = ( roundingMode == float_round_nearest_even );
427    roundIncrement = 0x200;
428    if ( ! roundNearestEven ) {
429        if ( roundingMode == float_round_to_zero ) {
430            roundIncrement = 0;
431        }
432        else {
433            roundIncrement = 0x3FF;
434            if ( zSign ) {
435                if ( roundingMode == float_round_up ) roundIncrement = 0;
436            }
437            else {
438                if ( roundingMode == float_round_down ) roundIncrement = 0;
439            }
440        }
441    }
442    roundBits = zSig & 0x3FF;
443    if ( 0x7FD <= (bits16) zExp ) {
444        if (    ( 0x7FD < zExp )
445             || (    ( zExp == 0x7FD )
446                  && ( (sbits64) ( zSig + roundIncrement ) < 0 ) )
447           ) {
448            float_raise( float_flag_overflow | float_flag_inexact );
449            return packFloat64( zSign, 0x7FF, 0 ) - ( roundIncrement == 0 );
450        }
451        if ( zExp < 0 ) {
452            isTiny =
453                   ( float_detect_tininess == float_tininess_before_rounding )
454                || ( zExp < -1 )
455                || ( zSig + roundIncrement < LIT64( 0x8000000000000000 ) );
456            shift64RightJamming( zSig, - zExp, &zSig );
457            zExp = 0;
458            roundBits = zSig & 0x3FF;
459            if ( isTiny && roundBits ) float_raise( float_flag_underflow );
460        }
461    }
462    if ( roundBits ) float_exception_flags |= float_flag_inexact;
463    zSig = ( zSig + roundIncrement )>>10;
464    zSig &= ~ ( ( ( roundBits ^ 0x200 ) == 0 ) & roundNearestEven );
465    if ( zSig == 0 ) zExp = 0;
466    return packFloat64( zSign, zExp, zSig );
467
468}
469
470/*----------------------------------------------------------------------------
471| Takes an abstract floating-point value having sign `zSign', exponent `zExp',
472| and significand `zSig', and returns the proper double-precision floating-
473| point value corresponding to the abstract input.  This routine is just like
474| `roundAndPackFloat64' except that `zSig' does not have to be normalized.
475| Bit 63 of `zSig' must be zero, and `zExp' must be 1 less than the ``true''
476| floating-point exponent.
477*----------------------------------------------------------------------------*/
478
479static float64
480 normalizeRoundAndPackFloat64( flag zSign, int16 zExp, bits64 zSig )
481{
482    int8 shiftCount;
483
484    shiftCount = countLeadingZeros64( zSig ) - 1;
485    return roundAndPackFloat64( zSign, zExp - shiftCount, zSig<<shiftCount );
486
487}
488
489#ifdef FLOATX80
490
491/*----------------------------------------------------------------------------
492| Returns the fraction bits of the extended double-precision floating-point
493| value `a'.
494*----------------------------------------------------------------------------*/
495
496INLINE bits64 extractFloatx80Frac( floatx80 a )
497{
498
499    return a.low;
500
501}
502
503/*----------------------------------------------------------------------------
504| Returns the exponent bits of the extended double-precision floating-point
505| value `a'.
506*----------------------------------------------------------------------------*/
507
508INLINE int32 extractFloatx80Exp( floatx80 a )
509{
510
511    return a.high & 0x7FFF;
512
513}
514
515/*----------------------------------------------------------------------------
516| Returns the sign bit of the extended double-precision floating-point value
517| `a'.
518*----------------------------------------------------------------------------*/
519
520INLINE flag extractFloatx80Sign( floatx80 a )
521{
522
523    return a.high>>15;
524
525}
526
527/*----------------------------------------------------------------------------
528| Normalizes the subnormal extended double-precision floating-point value
529| represented by the denormalized significand `aSig'.  The normalized exponent
530| and significand are stored at the locations pointed to by `zExpPtr' and
531| `zSigPtr', respectively.
532*----------------------------------------------------------------------------*/
533
534static void
535 normalizeFloatx80Subnormal( bits64 aSig, int32 *zExpPtr, bits64 *zSigPtr )
536{
537    int8 shiftCount;
538
539    shiftCount = countLeadingZeros64( aSig );
540    *zSigPtr = aSig<<shiftCount;
541    *zExpPtr = 1 - shiftCount;
542
543}
544
545/*----------------------------------------------------------------------------
546| Packs the sign `zSign', exponent `zExp', and significand `zSig' into an
547| extended double-precision floating-point value, returning the result.
548*----------------------------------------------------------------------------*/
549
550INLINE floatx80 packFloatx80( flag zSign, int32 zExp, bits64 zSig )
551{
552    floatx80 z;
553
554    z.low = zSig;
555    z.high = ( ( (bits16) zSign )<<15 ) + zExp;
556    return z;
557
558}
559
560/*----------------------------------------------------------------------------
561| Takes an abstract floating-point value having sign `zSign', exponent `zExp',
562| and extended significand formed by the concatenation of `zSig0' and `zSig1',
563| and returns the proper extended double-precision floating-point value
564| corresponding to the abstract input.  Ordinarily, the abstract value is
565| rounded and packed into the extended double-precision format, with the
566| inexact exception raised if the abstract input cannot be represented
567| exactly.  However, if the abstract value is too large, the overflow and
568| inexact exceptions are raised and an infinity or maximal finite value is
569| returned.  If the abstract value is too small, the input value is rounded to
570| a subnormal number, and the underflow and inexact exceptions are raised if
571| the abstract input cannot be represented exactly as a subnormal extended
572| double-precision floating-point number.
573|     If `roundingPrecision' is 32 or 64, the result is rounded to the same
574| number of bits as single or double precision, respectively.  Otherwise, the
575| result is rounded to the full precision of the extended double-precision
576| format.
577|     The input significand must be normalized or smaller.  If the input
578| significand is not normalized, `zExp' must be 0; in that case, the result
579| returned is a subnormal number, and it must not require rounding.  The
580| handling of underflow and overflow follows the IEC/IEEE Standard for Binary
581| Floating-Point Arithmetic.
582*----------------------------------------------------------------------------*/
583
584static floatx80
585 roundAndPackFloatx80(
586     int8 roundingPrecision, flag zSign, int32 zExp, bits64 zSig0, bits64 zSig1
587 )
588{
589    int8 roundingMode;
590    flag roundNearestEven, increment, isTiny;
591    int64 roundIncrement, roundMask, roundBits;
592
593    roundingMode = float_rounding_mode;
594    roundNearestEven = ( roundingMode == float_round_nearest_even );
595    if ( roundingPrecision == 80 ) goto precision80;
596    if ( roundingPrecision == 64 ) {
597        roundIncrement = LIT64( 0x0000000000000400 );
598        roundMask = LIT64( 0x00000000000007FF );
599    }
600    else if ( roundingPrecision == 32 ) {
601        roundIncrement = LIT64( 0x0000008000000000 );
602        roundMask = LIT64( 0x000000FFFFFFFFFF );
603    }
604    else {
605        goto precision80;
606    }
607    zSig0 |= ( zSig1 != 0 );
608    if ( ! roundNearestEven ) {
609        if ( roundingMode == float_round_to_zero ) {
610            roundIncrement = 0;
611        }
612        else {
613            roundIncrement = roundMask;
614            if ( zSign ) {
615                if ( roundingMode == float_round_up ) roundIncrement = 0;
616            }
617            else {
618                if ( roundingMode == float_round_down ) roundIncrement = 0;
619            }
620        }
621    }
622    roundBits = zSig0 & roundMask;
623    if ( 0x7FFD <= (bits32) ( zExp - 1 ) ) {
624        if (    ( 0x7FFE < zExp )
625             || ( ( zExp == 0x7FFE ) && ( zSig0 + roundIncrement < zSig0 ) )
626           ) {
627            goto overflow;
628        }
629        if ( zExp <= 0 ) {
630            isTiny =
631                   ( float_detect_tininess == float_tininess_before_rounding )
632                || ( zExp < 0 )
633                || ( zSig0 <= zSig0 + roundIncrement );
634            shift64RightJamming( zSig0, 1 - zExp, &zSig0 );
635            zExp = 0;
636            roundBits = zSig0 & roundMask;
637            if ( isTiny && roundBits ) float_raise( float_flag_underflow );
638            if ( roundBits ) float_exception_flags |= float_flag_inexact;
639            zSig0 += roundIncrement;
640            if ( (sbits64) zSig0 < 0 ) zExp = 1;
641            roundIncrement = roundMask + 1;
642            if ( roundNearestEven && ( roundBits<<1 == roundIncrement ) ) {
643                roundMask |= roundIncrement;
644            }
645            zSig0 &= ~ roundMask;
646            return packFloatx80( zSign, zExp, zSig0 );
647        }
648    }
649    if ( roundBits ) float_exception_flags |= float_flag_inexact;
650    zSig0 += roundIncrement;
651    if ( zSig0 < roundIncrement ) {
652        ++zExp;
653        zSig0 = LIT64( 0x8000000000000000 );
654    }
655    roundIncrement = roundMask + 1;
656    if ( roundNearestEven && ( roundBits<<1 == roundIncrement ) ) {
657        roundMask |= roundIncrement;
658    }
659    zSig0 &= ~ roundMask;
660    if ( zSig0 == 0 ) zExp = 0;
661    return packFloatx80( zSign, zExp, zSig0 );
662 precision80:
663    increment = ( (sbits64) zSig1 < 0 );
664    if ( ! roundNearestEven ) {
665        if ( roundingMode == float_round_to_zero ) {
666            increment = 0;
667        }
668        else {
669            if ( zSign ) {
670                increment = ( roundingMode == float_round_down ) && zSig1;
671            }
672            else {
673                increment = ( roundingMode == float_round_up ) && zSig1;
674            }
675        }
676    }
677    if ( 0x7FFD <= (bits32) ( zExp - 1 ) ) {
678        if (    ( 0x7FFE < zExp )
679             || (    ( zExp == 0x7FFE )
680                  && ( zSig0 == LIT64( 0xFFFFFFFFFFFFFFFF ) )
681                  && increment
682                )
683           ) {
684            roundMask = 0;
685 overflow:
686            float_raise( float_flag_overflow | float_flag_inexact );
687            if (    ( roundingMode == float_round_to_zero )
688                 || ( zSign && ( roundingMode == float_round_up ) )
689                 || ( ! zSign && ( roundingMode == float_round_down ) )
690               ) {
691                return packFloatx80( zSign, 0x7FFE, ~ roundMask );
692            }
693            return packFloatx80( zSign, 0x7FFF, LIT64( 0x8000000000000000 ) );
694        }
695        if ( zExp <= 0 ) {
696            isTiny =
697                   ( float_detect_tininess == float_tininess_before_rounding )
698                || ( zExp < 0 )
699                || ! increment
700                || ( zSig0 < LIT64( 0xFFFFFFFFFFFFFFFF ) );
701            shift64ExtraRightJamming( zSig0, zSig1, 1 - zExp, &zSig0, &zSig1 );
702            zExp = 0;
703            if ( isTiny && zSig1 ) float_raise( float_flag_underflow );
704            if ( zSig1 ) float_exception_flags |= float_flag_inexact;
705            if ( roundNearestEven ) {
706                increment = ( (sbits64) zSig1 < 0 );
707            }
708            else {
709                if ( zSign ) {
710                    increment = ( roundingMode == float_round_down ) && zSig1;
711                }
712                else {
713                    increment = ( roundingMode == float_round_up ) && zSig1;
714                }
715            }
716            if ( increment ) {
717                ++zSig0;
718                zSig0 &=
719                    ~ ( ( (bits64) ( zSig1<<1 ) == 0 ) & roundNearestEven );
720                if ( (sbits64) zSig0 < 0 ) zExp = 1;
721            }
722            return packFloatx80( zSign, zExp, zSig0 );
723        }
724    }
725    if ( zSig1 ) float_exception_flags |= float_flag_inexact;
726    if ( increment ) {
727        ++zSig0;
728        if ( zSig0 == 0 ) {
729            ++zExp;
730            zSig0 = LIT64( 0x8000000000000000 );
731        }
732        else {
733            zSig0 &= ~ ( ( (bits64) ( zSig1<<1 ) == 0 ) & roundNearestEven );
734        }
735    }
736    else {
737        if ( zSig0 == 0 ) zExp = 0;
738    }
739    return packFloatx80( zSign, zExp, zSig0 );
740
741}
742
743/*----------------------------------------------------------------------------
744| Takes an abstract floating-point value having sign `zSign', exponent
745| `zExp', and significand formed by the concatenation of `zSig0' and `zSig1',
746| and returns the proper extended double-precision floating-point value
747| corresponding to the abstract input.  This routine is just like
748| `roundAndPackFloatx80' except that the input significand does not have to be
749| normalized.
750*----------------------------------------------------------------------------*/
751
752static floatx80
753 normalizeRoundAndPackFloatx80(
754     int8 roundingPrecision, flag zSign, int32 zExp, bits64 zSig0, bits64 zSig1
755 )
756{
757    int8 shiftCount;
758
759    if ( zSig0 == 0 ) {
760        zSig0 = zSig1;
761        zSig1 = 0;
762        zExp -= 64;
763    }
764    shiftCount = countLeadingZeros64( zSig0 );
765    shortShift128Left( zSig0, zSig1, shiftCount, &zSig0, &zSig1 );
766    zExp -= shiftCount;
767    return
768        roundAndPackFloatx80( roundingPrecision, zSign, zExp, zSig0, zSig1 );
769
770}
771
772#endif
773
774#ifdef FLOAT128
775
776/*----------------------------------------------------------------------------
777| Returns the least-significant 64 fraction bits of the quadruple-precision
778| floating-point value `a'.
779*----------------------------------------------------------------------------*/
780
781INLINE bits64 extractFloat128Frac1( float128 a )
782{
783
784    return a.low;
785
786}
787
788/*----------------------------------------------------------------------------
789| Returns the most-significant 48 fraction bits of the quadruple-precision
790| floating-point value `a'.
791*----------------------------------------------------------------------------*/
792
793INLINE bits64 extractFloat128Frac0( float128 a )
794{
795
796    return a.high & LIT64( 0x0000FFFFFFFFFFFF );
797
798}
799
800/*----------------------------------------------------------------------------
801| Returns the exponent bits of the quadruple-precision floating-point value
802| `a'.
803*----------------------------------------------------------------------------*/
804
805INLINE int32 extractFloat128Exp( float128 a )
806{
807
808    return ( a.high>>48 ) & 0x7FFF;
809
810}
811
812/*----------------------------------------------------------------------------
813| Returns the sign bit of the quadruple-precision floating-point value `a'.
814*----------------------------------------------------------------------------*/
815
816INLINE flag extractFloat128Sign( float128 a )
817{
818
819    return a.high>>63;
820
821}
822
823/*----------------------------------------------------------------------------
824| Normalizes the subnormal quadruple-precision floating-point value
825| represented by the denormalized significand formed by the concatenation of
826| `aSig0' and `aSig1'.  The normalized exponent is stored at the location
827| pointed to by `zExpPtr'.  The most significant 49 bits of the normalized
828| significand are stored at the location pointed to by `zSig0Ptr', and the
829| least significant 64 bits of the normalized significand are stored at the
830| location pointed to by `zSig1Ptr'.
831*----------------------------------------------------------------------------*/
832
833static void
834 normalizeFloat128Subnormal(
835     bits64 aSig0,
836     bits64 aSig1,
837     int32 *zExpPtr,
838     bits64 *zSig0Ptr,
839     bits64 *zSig1Ptr
840 )
841{
842    int8 shiftCount;
843
844    if ( aSig0 == 0 ) {
845        shiftCount = countLeadingZeros64( aSig1 ) - 15;
846        if ( shiftCount < 0 ) {
847            *zSig0Ptr = aSig1>>( - shiftCount );
848            *zSig1Ptr = aSig1<<( shiftCount & 63 );
849        }
850        else {
851            *zSig0Ptr = aSig1<<shiftCount;
852            *zSig1Ptr = 0;
853        }
854        *zExpPtr = - shiftCount - 63;
855    }
856    else {
857        shiftCount = countLeadingZeros64( aSig0 ) - 15;
858        shortShift128Left( aSig0, aSig1, shiftCount, zSig0Ptr, zSig1Ptr );
859        *zExpPtr = 1 - shiftCount;
860    }
861
862}
863
864/*----------------------------------------------------------------------------
865| Packs the sign `zSign', the exponent `zExp', and the significand formed
866| by the concatenation of `zSig0' and `zSig1' into a quadruple-precision
867| floating-point value, returning the result.  After being shifted into the
868| proper positions, the three fields `zSign', `zExp', and `zSig0' are simply
869| added together to form the most significant 32 bits of the result.  This
870| means that any integer portion of `zSig0' will be added into the exponent.
871| Since a properly normalized significand will have an integer portion equal
872| to 1, the `zExp' input should be 1 less than the desired result exponent
873| whenever `zSig0' and `zSig1' concatenated form a complete, normalized
874| significand.
875*----------------------------------------------------------------------------*/
876
877INLINE float128
878 packFloat128( flag zSign, int32 zExp, bits64 zSig0, bits64 zSig1 )
879{
880    float128 z;
881
882    z.low = zSig1;
883    z.high = ( ( (bits64) zSign )<<63 ) + ( ( (bits64) zExp )<<48 ) + zSig0;
884    return z;
885
886}
887
888/*----------------------------------------------------------------------------
889| Takes an abstract floating-point value having sign `zSign', exponent `zExp',
890| and extended significand formed by the concatenation of `zSig0', `zSig1',
891| and `zSig2', and returns the proper quadruple-precision floating-point value
892| corresponding to the abstract input.  Ordinarily, the abstract value is
893| simply rounded and packed into the quadruple-precision format, with the
894| inexact exception raised if the abstract input cannot be represented
895| exactly.  However, if the abstract value is too large, the overflow and
896| inexact exceptions are raised and an infinity or maximal finite value is
897| returned.  If the abstract value is too small, the input value is rounded to
898| a subnormal number, and the underflow and inexact exceptions are raised if
899| the abstract input cannot be represented exactly as a subnormal quadruple-
900| precision floating-point number.
901|     The input significand must be normalized or smaller.  If the input
902| significand is not normalized, `zExp' must be 0; in that case, the result
903| returned is a subnormal number, and it must not require rounding.  In the
904| usual case that the input significand is normalized, `zExp' must be 1 less
905| than the ``true'' floating-point exponent.  The handling of underflow and
906| overflow follows the IEC/IEEE Standard for Binary Floating-Point Arithmetic.
907*----------------------------------------------------------------------------*/
908
909static float128
910 roundAndPackFloat128(
911     flag zSign, int32 zExp, bits64 zSig0, bits64 zSig1, bits64 zSig2 )
912{
913    int8 roundingMode;
914    flag roundNearestEven, increment, isTiny;
915
916    roundingMode = float_rounding_mode;
917    roundNearestEven = ( roundingMode == float_round_nearest_even );
918    increment = ( (sbits64) zSig2 < 0 );
919    if ( ! roundNearestEven ) {
920        if ( roundingMode == float_round_to_zero ) {
921            increment = 0;
922        }
923        else {
924            if ( zSign ) {
925                increment = ( roundingMode == float_round_down ) && zSig2;
926            }
927            else {
928                increment = ( roundingMode == float_round_up ) && zSig2;
929            }
930        }
931    }
932    if ( 0x7FFD <= (bits32) zExp ) {
933        if (    ( 0x7FFD < zExp )
934             || (    ( zExp == 0x7FFD )
935                  && eq128(
936                         LIT64( 0x0001FFFFFFFFFFFF ),
937                         LIT64( 0xFFFFFFFFFFFFFFFF ),
938                         zSig0,
939                         zSig1
940                     )
941                  && increment
942                )
943           ) {
944            float_raise( float_flag_overflow | float_flag_inexact );
945            if (    ( roundingMode == float_round_to_zero )
946                 || ( zSign && ( roundingMode == float_round_up ) )
947                 || ( ! zSign && ( roundingMode == float_round_down ) )
948               ) {
949                return
950                    packFloat128(
951                        zSign,
952                        0x7FFE,
953                        LIT64( 0x0000FFFFFFFFFFFF ),
954                        LIT64( 0xFFFFFFFFFFFFFFFF )
955                    );
956            }
957            return packFloat128( zSign, 0x7FFF, 0, 0 );
958        }
959        if ( zExp < 0 ) {
960            isTiny =
961                   ( float_detect_tininess == float_tininess_before_rounding )
962                || ( zExp < -1 )
963                || ! increment
964                || lt128(
965                       zSig0,
966                       zSig1,
967                       LIT64( 0x0001FFFFFFFFFFFF ),
968                       LIT64( 0xFFFFFFFFFFFFFFFF )
969                   );
970            shift128ExtraRightJamming(
971                zSig0, zSig1, zSig2, - zExp, &zSig0, &zSig1, &zSig2 );
972            zExp = 0;
973            if ( isTiny && zSig2 ) float_raise( float_flag_underflow );
974            if ( roundNearestEven ) {
975                increment = ( (sbits64) zSig2 < 0 );
976            }
977            else {
978                if ( zSign ) {
979                    increment = ( roundingMode == float_round_down ) && zSig2;
980                }
981                else {
982                    increment = ( roundingMode == float_round_up ) && zSig2;
983                }
984            }
985        }
986    }
987    if ( zSig2 ) float_exception_flags |= float_flag_inexact;
988    if ( increment ) {
989        add128( zSig0, zSig1, 0, 1, &zSig0, &zSig1 );
990        zSig1 &= ~ ( ( zSig2 + zSig2 == 0 ) & roundNearestEven );
991    }
992    else {
993        if ( ( zSig0 | zSig1 ) == 0 ) zExp = 0;
994    }
995    return packFloat128( zSign, zExp, zSig0, zSig1 );
996
997}
998
999/*----------------------------------------------------------------------------
1000| Takes an abstract floating-point value having sign `zSign', exponent `zExp',
1001| and significand formed by the concatenation of `zSig0' and `zSig1', and
1002| returns the proper quadruple-precision floating-point value corresponding
1003| to the abstract input.  This routine is just like `roundAndPackFloat128'
1004| except that the input significand has fewer bits and does not have to be
1005| normalized.  In all cases, `zExp' must be 1 less than the ``true'' floating-
1006| point exponent.
1007*----------------------------------------------------------------------------*/
1008
1009static float128
1010 normalizeRoundAndPackFloat128(
1011     flag zSign, int32 zExp, bits64 zSig0, bits64 zSig1 )
1012{
1013    int8 shiftCount;
1014    bits64 zSig2;
1015
1016    if ( zSig0 == 0 ) {
1017        zSig0 = zSig1;
1018        zSig1 = 0;
1019        zExp -= 64;
1020    }
1021    shiftCount = countLeadingZeros64( zSig0 ) - 15;
1022    if ( 0 <= shiftCount ) {
1023        zSig2 = 0;
1024        shortShift128Left( zSig0, zSig1, shiftCount, &zSig0, &zSig1 );
1025    }
1026    else {
1027        shift128ExtraRightJamming(
1028            zSig0, zSig1, 0, - shiftCount, &zSig0, &zSig1, &zSig2 );
1029    }
1030    zExp -= shiftCount;
1031    return roundAndPackFloat128( zSign, zExp, zSig0, zSig1, zSig2 );
1032
1033}
1034
1035#endif
1036
1037/*----------------------------------------------------------------------------
1038| Returns the result of converting the 32-bit two's complement integer `a'
1039| to the single-precision floating-point format.  The conversion is performed
1040| according to the IEC/IEEE Standard for Binary Floating-Point Arithmetic.
1041*----------------------------------------------------------------------------*/
1042
1043float32 int32_to_float32( int32 a )
1044{
1045    flag zSign;
1046
1047    if ( a == 0 ) return 0;
1048    if ( a == (sbits32) 0x80000000 ) return packFloat32( 1, 0x9E, 0 );
1049    zSign = ( a < 0 );
1050    return normalizeRoundAndPackFloat32( zSign, 0x9C, zSign ? - a : a );
1051
1052}
1053
1054/*----------------------------------------------------------------------------
1055| Returns the result of converting the 32-bit two's complement integer `a'
1056| to the double-precision floating-point format.  The conversion is performed
1057| according to the IEC/IEEE Standard for Binary Floating-Point Arithmetic.
1058*----------------------------------------------------------------------------*/
1059
1060float64 int32_to_float64( int32 a )
1061{
1062    flag zSign;
1063    uint32 absA;
1064    int8 shiftCount;
1065    bits64 zSig;
1066
1067    if ( a == 0 ) return 0;
1068    zSign = ( a < 0 );
1069    absA = zSign ? - a : a;
1070    shiftCount = countLeadingZeros32( absA ) + 21;
1071    zSig = absA;
1072    return packFloat64( zSign, 0x432 - shiftCount, zSig<<shiftCount );
1073
1074}
1075
1076#ifdef FLOATX80
1077
1078/*----------------------------------------------------------------------------
1079| Returns the result of converting the 32-bit two's complement integer `a'
1080| to the extended double-precision floating-point format.  The conversion
1081| is performed according to the IEC/IEEE Standard for Binary Floating-Point
1082| Arithmetic.
1083*----------------------------------------------------------------------------*/
1084
1085floatx80 int32_to_floatx80( int32 a )
1086{
1087    flag zSign;
1088    uint32 absA;
1089    int8 shiftCount;
1090    bits64 zSig;
1091
1092    if ( a == 0 ) return packFloatx80( 0, 0, 0 );
1093    zSign = ( a < 0 );
1094    absA = zSign ? - a : a;
1095    shiftCount = countLeadingZeros32( absA ) + 32;
1096    zSig = absA;
1097    return packFloatx80( zSign, 0x403E - shiftCount, zSig<<shiftCount );
1098
1099}
1100
1101#endif
1102
1103#ifdef FLOAT128
1104
1105/*----------------------------------------------------------------------------
1106| Returns the result of converting the 32-bit two's complement integer `a' to
1107| the quadruple-precision floating-point format.  The conversion is performed
1108| according to the IEC/IEEE Standard for Binary Floating-Point Arithmetic.
1109*----------------------------------------------------------------------------*/
1110
1111float128 int32_to_float128( int32 a )
1112{
1113    flag zSign;
1114    uint32 absA;
1115    int8 shiftCount;
1116    bits64 zSig0;
1117
1118    if ( a == 0 ) return packFloat128( 0, 0, 0, 0 );
1119    zSign = ( a < 0 );
1120    absA = zSign ? - a : a;
1121    shiftCount = countLeadingZeros32( absA ) + 17;
1122    zSig0 = absA;
1123    return packFloat128( zSign, 0x402E - shiftCount, zSig0<<shiftCount, 0 );
1124
1125}
1126
1127#endif
1128
1129/*----------------------------------------------------------------------------
1130| Returns the result of converting the 64-bit two's complement integer `a'
1131| to the single-precision floating-point format.  The conversion is performed
1132| according to the IEC/IEEE Standard for Binary Floating-Point Arithmetic.
1133*----------------------------------------------------------------------------*/
1134
1135float32 int64_to_float32( int64 a )
1136{
1137    flag zSign;
1138    uint64 absA;
1139    int8 shiftCount;
1140//    bits32 zSig;
1141
1142    if ( a == 0 ) return 0;
1143    zSign = ( a < 0 );
1144    absA = zSign ? - a : a;
1145    shiftCount = countLeadingZeros64( absA ) - 40;
1146    if ( 0 <= shiftCount ) {
1147        return packFloat32( zSign, 0x95 - shiftCount, absA<<shiftCount );
1148    }
1149    else {
1150        shiftCount += 7;
1151        if ( shiftCount < 0 ) {
1152            shift64RightJamming( absA, - shiftCount, &absA );
1153        }
1154        else {
1155            absA <<= shiftCount;
1156        }
1157        return roundAndPackFloat32( zSign, 0x9C - shiftCount, absA );
1158    }
1159
1160}
1161
1162/*----------------------------------------------------------------------------
1163| Returns the result of converting the 64-bit two's complement integer `a'
1164| to the double-precision floating-point format.  The conversion is performed
1165| according to the IEC/IEEE Standard for Binary Floating-Point Arithmetic.
1166*----------------------------------------------------------------------------*/
1167
1168float64 int64_to_float64( int64 a )
1169{
1170    flag zSign;
1171
1172    if ( a == 0 ) return 0;
1173    if ( a == (sbits64) LIT64( 0x8000000000000000 ) ) {
1174        return packFloat64( 1, 0x43E, 0 );
1175    }
1176    zSign = ( a < 0 );
1177    return normalizeRoundAndPackFloat64( zSign, 0x43C, zSign ? - a : a );
1178
1179}
1180
1181#ifdef FLOATX80
1182
1183/*----------------------------------------------------------------------------
1184| Returns the result of converting the 64-bit two's complement integer `a'
1185| to the extended double-precision floating-point format.  The conversion
1186| is performed according to the IEC/IEEE Standard for Binary Floating-Point
1187| Arithmetic.
1188*----------------------------------------------------------------------------*/
1189
1190floatx80 int64_to_floatx80( int64 a )
1191{
1192    flag zSign;
1193    uint64 absA;
1194    int8 shiftCount;
1195
1196    if ( a == 0 ) return packFloatx80( 0, 0, 0 );
1197    zSign = ( a < 0 );
1198    absA = zSign ? - a : a;
1199    shiftCount = countLeadingZeros64( absA );
1200    return packFloatx80( zSign, 0x403E - shiftCount, absA<<shiftCount );
1201
1202}
1203
1204#endif
1205
1206#ifdef FLOAT128
1207
1208/*----------------------------------------------------------------------------
1209| Returns the result of converting the 64-bit two's complement integer `a' to
1210| the quadruple-precision floating-point format.  The conversion is performed
1211| according to the IEC/IEEE Standard for Binary Floating-Point Arithmetic.
1212*----------------------------------------------------------------------------*/
1213
1214float128 int64_to_float128( int64 a )
1215{
1216    flag zSign;
1217    uint64 absA;
1218    int8 shiftCount;
1219    int32 zExp;
1220    bits64 zSig0, zSig1;
1221
1222    if ( a == 0 ) return packFloat128( 0, 0, 0, 0 );
1223    zSign = ( a < 0 );
1224    absA = zSign ? - a : a;
1225    shiftCount = countLeadingZeros64( absA ) + 49;
1226    zExp = 0x406E - shiftCount;
1227    if ( 64 <= shiftCount ) {
1228        zSig1 = 0;
1229        zSig0 = absA;
1230        shiftCount -= 64;
1231    }
1232    else {
1233        zSig1 = absA;
1234        zSig0 = 0;
1235    }
1236    shortShift128Left( zSig0, zSig1, shiftCount, &zSig0, &zSig1 );
1237    return packFloat128( zSign, zExp, zSig0, zSig1 );
1238
1239}
1240
1241#endif
1242
1243/*----------------------------------------------------------------------------
1244| Returns the result of converting the single-precision floating-point value
1245| `a' to the 32-bit two's complement integer format.  The conversion is
1246| performed according to the IEC/IEEE Standard for Binary Floating-Point
1247| Arithmetic---which means in particular that the conversion is rounded
1248| according to the current rounding mode.  If `a' is a NaN, the largest
1249| positive integer is returned.  Otherwise, if the conversion overflows, the
1250| largest integer with the same sign as `a' is returned.
1251*----------------------------------------------------------------------------*/
1252
1253int32 float32_to_int32( float32 a )
1254{
1255    flag aSign;
1256    int16 aExp, shiftCount;
1257    bits32 aSig;
1258    bits64 aSig64;
1259
1260    aSig = extractFloat32Frac( a );
1261    aExp = extractFloat32Exp( a );
1262    aSign = extractFloat32Sign( a );
1263    if ( ( aExp == 0xFF ) && aSig ) aSign = 0;
1264    if ( aExp ) aSig |= 0x00800000;
1265    shiftCount = 0xAF - aExp;
1266    aSig64 = aSig;
1267    aSig64 <<= 32;
1268    if ( 0 < shiftCount ) shift64RightJamming( aSig64, shiftCount, &aSig64 );
1269    return roundAndPackInt32( aSign, aSig64 );
1270
1271}
1272
1273/*----------------------------------------------------------------------------
1274| Returns the result of converting the single-precision floating-point value
1275| `a' to the 32-bit two's complement integer format.  The conversion is
1276| performed according to the IEC/IEEE Standard for Binary Floating-Point
1277| Arithmetic, except that the conversion is always rounded toward zero.
1278| If `a' is a NaN, the largest positive integer is returned.  Otherwise, if
1279| the conversion overflows, the largest integer with the same sign as `a' is
1280| returned.
1281*----------------------------------------------------------------------------*/
1282
1283int32 float32_to_int32_round_to_zero( float32 a )
1284{
1285    flag aSign;
1286    int16 aExp, shiftCount;
1287    bits32 aSig;
1288    int32 z;
1289
1290    aSig = extractFloat32Frac( a );
1291    aExp = extractFloat32Exp( a );
1292    aSign = extractFloat32Sign( a );
1293    shiftCount = aExp - 0x9E;
1294    if ( 0 <= shiftCount ) {
1295        if ( a != 0xCF000000 ) {
1296            float_raise( float_flag_invalid );
1297            if ( ! aSign || ( ( aExp == 0xFF ) && aSig ) ) return 0x7FFFFFFF;
1298        }
1299        return (sbits32) 0x80000000;
1300    }
1301    else if ( aExp <= 0x7E ) {
1302        if ( aExp | aSig ) float_exception_flags |= float_flag_inexact;
1303        return 0;
1304    }
1305    aSig = ( aSig | 0x00800000 )<<8;
1306    z = aSig>>( - shiftCount );
1307    if ( (bits32) ( aSig<<( shiftCount & 31 ) ) ) {
1308        float_exception_flags |= float_flag_inexact;
1309    }
1310    if ( aSign ) z = - z;
1311    return z;
1312
1313}
1314
1315/*----------------------------------------------------------------------------
1316| Returns the result of converting the single-precision floating-point value
1317| `a' to the 64-bit two's complement integer format.  The conversion is
1318| performed according to the IEC/IEEE Standard for Binary Floating-Point
1319| Arithmetic---which means in particular that the conversion is rounded
1320| according to the current rounding mode.  If `a' is a NaN, the largest
1321| positive integer is returned.  Otherwise, if the conversion overflows, the
1322| largest integer with the same sign as `a' is returned.
1323*----------------------------------------------------------------------------*/
1324
1325int64 float32_to_int64( float32 a )
1326{
1327    flag aSign;
1328    int16 aExp, shiftCount;
1329    bits32 aSig;
1330    bits64 aSig64, aSigExtra;
1331
1332    aSig = extractFloat32Frac( a );
1333    aExp = extractFloat32Exp( a );
1334    aSign = extractFloat32Sign( a );
1335    shiftCount = 0xBE - aExp;
1336    if ( shiftCount < 0 ) {
1337        float_raise( float_flag_invalid );
1338        if ( ! aSign || ( ( aExp == 0xFF ) && aSig ) ) {
1339            return LIT64( 0x7FFFFFFFFFFFFFFF );
1340        }
1341        return (sbits64) LIT64( 0x8000000000000000 );
1342    }
1343    if ( aExp ) aSig |= 0x00800000;
1344    aSig64 = aSig;
1345    aSig64 <<= 40;
1346    shift64ExtraRightJamming( aSig64, 0, shiftCount, &aSig64, &aSigExtra );
1347    return roundAndPackInt64( aSign, aSig64, aSigExtra );
1348
1349}
1350
1351/*----------------------------------------------------------------------------
1352| Returns the result of converting the single-precision floating-point value
1353| `a' to the 64-bit two's complement integer format.  The conversion is
1354| performed according to the IEC/IEEE Standard for Binary Floating-Point
1355| Arithmetic, except that the conversion is always rounded toward zero.  If
1356| `a' is a NaN, the largest positive integer is returned.  Otherwise, if the
1357| conversion overflows, the largest integer with the same sign as `a' is
1358| returned.
1359*----------------------------------------------------------------------------*/
1360
1361int64 float32_to_int64_round_to_zero( float32 a )
1362{
1363    flag aSign;
1364    int16 aExp, shiftCount;
1365    bits32 aSig;
1366    bits64 aSig64;
1367    int64 z;
1368
1369    aSig = extractFloat32Frac( a );
1370    aExp = extractFloat32Exp( a );
1371    aSign = extractFloat32Sign( a );
1372    shiftCount = aExp - 0xBE;
1373    if ( 0 <= shiftCount ) {
1374        if ( a != 0xDF000000 ) {
1375            float_raise( float_flag_invalid );
1376            if ( ! aSign || ( ( aExp == 0xFF ) && aSig ) ) {
1377                return LIT64( 0x7FFFFFFFFFFFFFFF );
1378            }
1379        }
1380        return (sbits64) LIT64( 0x8000000000000000 );
1381    }
1382    else if ( aExp <= 0x7E ) {
1383        if ( aExp | aSig ) float_exception_flags |= float_flag_inexact;
1384        return 0;
1385    }
1386    aSig64 = aSig | 0x00800000;
1387    aSig64 <<= 40;
1388    z = aSig64>>( - shiftCount );
1389    if ( (bits64) ( aSig64<<( shiftCount & 63 ) ) ) {
1390        float_exception_flags |= float_flag_inexact;
1391    }
1392    if ( aSign ) z = - z;
1393    return z;
1394
1395}
1396
1397/*----------------------------------------------------------------------------
1398| Returns the result of converting the single-precision floating-point value
1399| `a' to the double-precision floating-point format.  The conversion is
1400| performed according to the IEC/IEEE Standard for Binary Floating-Point
1401| Arithmetic.
1402*----------------------------------------------------------------------------*/
1403
1404float64 float32_to_float64( float32 a )
1405{
1406    flag aSign;
1407    int16 aExp;
1408    bits32 aSig;
1409
1410    aSig = extractFloat32Frac( a );
1411    aExp = extractFloat32Exp( a );
1412    aSign = extractFloat32Sign( a );
1413    if ( aExp == 0xFF ) {
1414        if ( aSig ) return commonNaNToFloat64( float32ToCommonNaN( a ) );
1415        return packFloat64( aSign, 0x7FF, 0 );
1416    }
1417    if ( aExp == 0 ) {
1418        if ( aSig == 0 ) return packFloat64( aSign, 0, 0 );
1419        normalizeFloat32Subnormal( aSig, &aExp, &aSig );
1420        --aExp;
1421    }
1422    return packFloat64( aSign, aExp + 0x380, ( (bits64) aSig )<<29 );
1423
1424}
1425
1426#ifdef FLOATX80
1427
1428/*----------------------------------------------------------------------------
1429| Returns the result of converting the single-precision floating-point value
1430| `a' to the extended double-precision floating-point format.  The conversion
1431| is performed according to the IEC/IEEE Standard for Binary Floating-Point
1432| Arithmetic.
1433*----------------------------------------------------------------------------*/
1434
1435floatx80 float32_to_floatx80( float32 a )
1436{
1437    flag aSign;
1438    int16 aExp;
1439    bits32 aSig;
1440
1441    aSig = extractFloat32Frac( a );
1442    aExp = extractFloat32Exp( a );
1443    aSign = extractFloat32Sign( a );
1444    if ( aExp == 0xFF ) {
1445        if ( aSig ) return commonNaNToFloatx80( float32ToCommonNaN( a ) );
1446        return packFloatx80( aSign, 0x7FFF, LIT64( 0x8000000000000000 ) );
1447    }
1448    if ( aExp == 0 ) {
1449        if ( aSig == 0 ) return packFloatx80( aSign, 0, 0 );
1450        normalizeFloat32Subnormal( aSig, &aExp, &aSig );
1451    }
1452    aSig |= 0x00800000;
1453    return packFloatx80( aSign, aExp + 0x3F80, ( (bits64) aSig )<<40 );
1454
1455}
1456
1457#endif
1458
1459#ifdef FLOAT128
1460
1461/*----------------------------------------------------------------------------
1462| Returns the result of converting the single-precision floating-point value
1463| `a' to the double-precision floating-point format.  The conversion is
1464| performed according to the IEC/IEEE Standard for Binary Floating-Point
1465| Arithmetic.
1466*----------------------------------------------------------------------------*/
1467
1468float128 float32_to_float128( float32 a )
1469{
1470    flag aSign;
1471    int16 aExp;
1472    bits32 aSig;
1473
1474    aSig = extractFloat32Frac( a );
1475    aExp = extractFloat32Exp( a );
1476    aSign = extractFloat32Sign( a );
1477    if ( aExp == 0xFF ) {
1478        if ( aSig ) return commonNaNToFloat128( float32ToCommonNaN( a ) );
1479        return packFloat128( aSign, 0x7FFF, 0, 0 );
1480    }
1481    if ( aExp == 0 ) {
1482        if ( aSig == 0 ) return packFloat128( aSign, 0, 0, 0 );
1483        normalizeFloat32Subnormal( aSig, &aExp, &aSig );
1484        --aExp;
1485    }
1486    return packFloat128( aSign, aExp + 0x3F80, ( (bits64) aSig )<<25, 0 );
1487
1488}
1489
1490#endif
1491
1492/*----------------------------------------------------------------------------
1493| Rounds the single-precision floating-point value `a' to an integer, and
1494| returns the result as a single-precision floating-point value.  The
1495| operation is performed according to the IEC/IEEE Standard for Binary
1496| Floating-Point Arithmetic.
1497*----------------------------------------------------------------------------*/
1498
1499float32 float32_round_to_int( float32 a )
1500{
1501    flag aSign;
1502    int16 aExp;
1503    bits32 lastBitMask, roundBitsMask;
1504    int8 roundingMode;
1505    float32 z;
1506
1507    aExp = extractFloat32Exp( a );
1508    if ( 0x96 <= aExp ) {
1509        if ( ( aExp == 0xFF ) && extractFloat32Frac( a ) ) {
1510            return propagateFloat32NaN( a, a );
1511        }
1512        return a;
1513    }
1514    if ( aExp <= 0x7E ) {
1515        if ( (bits32) ( a<<1 ) == 0 ) return a;
1516        float_exception_flags |= float_flag_inexact;
1517        aSign = extractFloat32Sign( a );
1518        switch ( float_rounding_mode ) {
1519         case float_round_nearest_even:
1520            if ( ( aExp == 0x7E ) && extractFloat32Frac( a ) ) {
1521                return packFloat32( aSign, 0x7F, 0 );
1522            }
1523            break;
1524         case float_round_down:
1525            return aSign ? 0xBF800000 : 0;
1526         case float_round_up:
1527            return aSign ? 0x80000000 : 0x3F800000;
1528        }
1529        return packFloat32( aSign, 0, 0 );
1530    }
1531    lastBitMask = 1;
1532    lastBitMask <<= 0x96 - aExp;
1533    roundBitsMask = lastBitMask - 1;
1534    z = a;
1535    roundingMode = float_rounding_mode;
1536    if ( roundingMode == float_round_nearest_even ) {
1537        z += lastBitMask>>1;
1538        if ( ( z & roundBitsMask ) == 0 ) z &= ~ lastBitMask;
1539    }
1540    else if ( roundingMode != float_round_to_zero ) {
1541        if ( extractFloat32Sign( z ) ^ ( roundingMode == float_round_up ) ) {
1542            z += roundBitsMask;
1543        }
1544    }
1545    z &= ~ roundBitsMask;
1546    if ( z != a ) float_exception_flags |= float_flag_inexact;
1547    return z;
1548
1549}
1550
1551/*----------------------------------------------------------------------------
1552| Returns the result of adding the absolute values of the single-precision
1553| floating-point values `a' and `b'.  If `zSign' is 1, the sum is negated
1554| before being returned.  `zSign' is ignored if the result is a NaN.
1555| The addition is performed according to the IEC/IEEE Standard for Binary
1556| Floating-Point Arithmetic.
1557*----------------------------------------------------------------------------*/
1558
1559static float32 addFloat32Sigs( float32 a, float32 b, flag zSign )
1560{
1561    int16 aExp, bExp, zExp;
1562    bits32 aSig, bSig, zSig;
1563    int16 expDiff;
1564
1565    aSig = extractFloat32Frac( a );
1566    aExp = extractFloat32Exp( a );
1567    bSig = extractFloat32Frac( b );
1568    bExp = extractFloat32Exp( b );
1569    expDiff = aExp - bExp;
1570    aSig <<= 6;
1571    bSig <<= 6;
1572    if ( 0 < expDiff ) {
1573        if ( aExp == 0xFF ) {
1574            if ( aSig ) return propagateFloat32NaN( a, b );
1575            return a;
1576        }
1577        if ( bExp == 0 ) {
1578            --expDiff;
1579        }
1580        else {
1581            bSig |= 0x20000000;
1582        }
1583        shift32RightJamming( bSig, expDiff, &bSig );
1584        zExp = aExp;
1585    }
1586    else if ( expDiff < 0 ) {
1587        if ( bExp == 0xFF ) {
1588            if ( bSig ) return propagateFloat32NaN( a, b );
1589            return packFloat32( zSign, 0xFF, 0 );
1590        }
1591        if ( aExp == 0 ) {
1592            ++expDiff;
1593        }
1594        else {
1595            aSig |= 0x20000000;
1596        }
1597        shift32RightJamming( aSig, - expDiff, &aSig );
1598        zExp = bExp;
1599    }
1600    else {
1601        if ( aExp == 0xFF ) {
1602            if ( aSig | bSig ) return propagateFloat32NaN( a, b );
1603            return a;
1604        }
1605        if ( aExp == 0 ) return packFloat32( zSign, 0, ( aSig + bSig )>>6 );
1606        zSig = 0x40000000 + aSig + bSig;
1607        zExp = aExp;
1608        goto roundAndPack;
1609    }
1610    aSig |= 0x20000000;
1611    zSig = ( aSig + bSig )<<1;
1612    --zExp;
1613    if ( (sbits32) zSig < 0 ) {
1614        zSig = aSig + bSig;
1615        ++zExp;
1616    }
1617 roundAndPack:
1618    return roundAndPackFloat32( zSign, zExp, zSig );
1619
1620}
1621
1622/*----------------------------------------------------------------------------
1623| Returns the result of subtracting the absolute values of the single-
1624| precision floating-point values `a' and `b'.  If `zSign' is 1, the
1625| difference is negated before being returned.  `zSign' is ignored if the
1626| result is a NaN.  The subtraction is performed according to the IEC/IEEE
1627| Standard for Binary Floating-Point Arithmetic.
1628*----------------------------------------------------------------------------*/
1629
1630static float32 subFloat32Sigs( float32 a, float32 b, flag zSign )
1631{
1632    int16 aExp, bExp, zExp;
1633    bits32 aSig, bSig, zSig;
1634    int16 expDiff;
1635
1636    aSig = extractFloat32Frac( a );
1637    aExp = extractFloat32Exp( a );
1638    bSig = extractFloat32Frac( b );
1639    bExp = extractFloat32Exp( b );
1640    expDiff = aExp - bExp;
1641    aSig <<= 7;
1642    bSig <<= 7;
1643    if ( 0 < expDiff ) goto aExpBigger;
1644    if ( expDiff < 0 ) goto bExpBigger;
1645    if ( aExp == 0xFF ) {
1646        if ( aSig | bSig ) return propagateFloat32NaN( a, b );
1647        float_raise( float_flag_invalid );
1648        return float32_default_nan;
1649    }
1650    if ( aExp == 0 ) {
1651        aExp = 1;
1652        bExp = 1;
1653    }
1654    if ( bSig < aSig ) goto aBigger;
1655    if ( aSig < bSig ) goto bBigger;
1656    return packFloat32( float_rounding_mode == float_round_down, 0, 0 );
1657 bExpBigger:
1658    if ( bExp == 0xFF ) {
1659        if ( bSig ) return propagateFloat32NaN( a, b );
1660        return packFloat32( zSign ^ 1, 0xFF, 0 );
1661    }
1662    if ( aExp == 0 ) {
1663        ++expDiff;
1664    }
1665    else {
1666        aSig |= 0x40000000;
1667    }
1668    shift32RightJamming( aSig, - expDiff, &aSig );
1669    bSig |= 0x40000000;
1670 bBigger:
1671    zSig = bSig - aSig;
1672    zExp = bExp;
1673    zSign ^= 1;
1674    goto normalizeRoundAndPack;
1675 aExpBigger:
1676    if ( aExp == 0xFF ) {
1677        if ( aSig ) return propagateFloat32NaN( a, b );
1678        return a;
1679    }
1680    if ( bExp == 0 ) {
1681        --expDiff;
1682    }
1683    else {
1684        bSig |= 0x40000000;
1685    }
1686    shift32RightJamming( bSig, expDiff, &bSig );
1687    aSig |= 0x40000000;
1688 aBigger:
1689    zSig = aSig - bSig;
1690    zExp = aExp;
1691 normalizeRoundAndPack:
1692    --zExp;
1693    return normalizeRoundAndPackFloat32( zSign, zExp, zSig );
1694
1695}
1696
1697/*----------------------------------------------------------------------------
1698| Returns the result of adding the single-precision floating-point values `a'
1699| and `b'.  The operation is performed according to the IEC/IEEE Standard for
1700| Binary Floating-Point Arithmetic.
1701*----------------------------------------------------------------------------*/
1702
1703float32 float32_add( float32 a, float32 b )
1704{
1705    flag aSign, bSign;
1706
1707    aSign = extractFloat32Sign( a );
1708    bSign = extractFloat32Sign( b );
1709    if ( aSign == bSign ) {
1710        return addFloat32Sigs( a, b, aSign );
1711    }
1712    else {
1713        return subFloat32Sigs( a, b, aSign );
1714    }
1715
1716}
1717
1718/*----------------------------------------------------------------------------
1719| Returns the result of subtracting the single-precision floating-point values
1720| `a' and `b'.  The operation is performed according to the IEC/IEEE Standard
1721| for Binary Floating-Point Arithmetic.
1722*----------------------------------------------------------------------------*/
1723
1724float32 float32_sub( float32 a, float32 b )
1725{
1726    flag aSign, bSign;
1727
1728    aSign = extractFloat32Sign( a );
1729    bSign = extractFloat32Sign( b );
1730    if ( aSign == bSign ) {
1731        return subFloat32Sigs( a, b, aSign );
1732    }
1733    else {
1734        return addFloat32Sigs( a, b, aSign );
1735    }
1736
1737}
1738
1739/*----------------------------------------------------------------------------
1740| Returns the result of multiplying the single-precision floating-point values
1741| `a' and `b'.  The operation is performed according to the IEC/IEEE Standard
1742| for Binary Floating-Point Arithmetic.
1743*----------------------------------------------------------------------------*/
1744
1745float32 float32_mul( float32 a, float32 b )
1746{
1747    flag aSign, bSign, zSign;
1748    int16 aExp, bExp, zExp;
1749    bits32 aSig, bSig;
1750    bits64 zSig64;
1751    bits32 zSig;
1752
1753    aSig = extractFloat32Frac( a );
1754    aExp = extractFloat32Exp( a );
1755    aSign = extractFloat32Sign( a );
1756    bSig = extractFloat32Frac( b );
1757    bExp = extractFloat32Exp( b );
1758    bSign = extractFloat32Sign( b );
1759    zSign = aSign ^ bSign;
1760    if ( aExp == 0xFF ) {
1761        if ( aSig || ( ( bExp == 0xFF ) && bSig ) ) {
1762            return propagateFloat32NaN( a, b );
1763        }
1764        if ( ( bExp | bSig ) == 0 ) {
1765            float_raise( float_flag_invalid );
1766            return float32_default_nan;
1767        }
1768        return packFloat32( zSign, 0xFF, 0 );
1769    }
1770    if ( bExp == 0xFF ) {
1771        if ( bSig ) return propagateFloat32NaN( a, b );
1772        if ( ( aExp | aSig ) == 0 ) {
1773            float_raise( float_flag_invalid );
1774            return float32_default_nan;
1775        }
1776        return packFloat32( zSign, 0xFF, 0 );
1777    }
1778    if ( aExp == 0 ) {
1779        if ( aSig == 0 ) return packFloat32( zSign, 0, 0 );
1780        normalizeFloat32Subnormal( aSig, &aExp, &aSig );
1781    }
1782    if ( bExp == 0 ) {
1783        if ( bSig == 0 ) return packFloat32( zSign, 0, 0 );
1784        normalizeFloat32Subnormal( bSig, &bExp, &bSig );
1785    }
1786    zExp = aExp + bExp - 0x7F;
1787    aSig = ( aSig | 0x00800000 )<<7;
1788    bSig = ( bSig | 0x00800000 )<<8;
1789    shift64RightJamming( ( (bits64) aSig ) * bSig, 32, &zSig64 );
1790    zSig = zSig64;
1791    if ( 0 <= (sbits32) ( zSig<<1 ) ) {
1792        zSig <<= 1;
1793        --zExp;
1794    }
1795    return roundAndPackFloat32( zSign, zExp, zSig );
1796
1797}
1798
1799/*----------------------------------------------------------------------------
1800| Returns the result of dividing the single-precision floating-point value `a'
1801| by the corresponding value `b'.  The operation is performed according to the
1802| IEC/IEEE Standard for Binary Floating-Point Arithmetic.
1803*----------------------------------------------------------------------------*/
1804
1805float32 float32_div( float32 a, float32 b )
1806{
1807    flag aSign, bSign, zSign;
1808    int16 aExp, bExp, zExp;
1809    bits32 aSig, bSig, zSig;
1810
1811    aSig = extractFloat32Frac( a );
1812    aExp = extractFloat32Exp( a );
1813    aSign = extractFloat32Sign( a );
1814    bSig = extractFloat32Frac( b );
1815    bExp = extractFloat32Exp( b );
1816    bSign = extractFloat32Sign( b );
1817    zSign = aSign ^ bSign;
1818    if ( aExp == 0xFF ) {
1819        if ( aSig ) return propagateFloat32NaN( a, b );
1820        if ( bExp == 0xFF ) {
1821            if ( bSig ) return propagateFloat32NaN( a, b );
1822            float_raise( float_flag_invalid );
1823            return float32_default_nan;
1824        }
1825        return packFloat32( zSign, 0xFF, 0 );
1826    }
1827    if ( bExp == 0xFF ) {
1828        if ( bSig ) return propagateFloat32NaN( a, b );
1829        return packFloat32( zSign, 0, 0 );
1830    }
1831    if ( bExp == 0 ) {
1832        if ( bSig == 0 ) {
1833            if ( ( aExp | aSig ) == 0 ) {
1834                float_raise( float_flag_invalid );
1835                return float32_default_nan;
1836            }
1837            float_raise( float_flag_divbyzero );
1838            return packFloat32( zSign, 0xFF, 0 );
1839        }
1840        normalizeFloat32Subnormal( bSig, &bExp, &bSig );
1841    }
1842    if ( aExp == 0 ) {
1843        if ( aSig == 0 ) return packFloat32( zSign, 0, 0 );
1844        normalizeFloat32Subnormal( aSig, &aExp, &aSig );
1845    }
1846    zExp = aExp - bExp + 0x7D;
1847    aSig = ( aSig | 0x00800000 )<<7;
1848    bSig = ( bSig | 0x00800000 )<<8;
1849    if ( bSig <= ( aSig + aSig ) ) {
1850        aSig >>= 1;
1851        ++zExp;
1852    }
1853    zSig = ( ( (bits64) aSig )<<32 ) / bSig;
1854    if ( ( zSig & 0x3F ) == 0 ) {
1855        zSig |= ( (bits64) bSig * zSig != ( (bits64) aSig )<<32 );
1856    }
1857    return roundAndPackFloat32( zSign, zExp, zSig );
1858
1859}
1860
1861/*----------------------------------------------------------------------------
1862| Returns the remainder of the single-precision floating-point value `a'
1863| with respect to the corresponding value `b'.  The operation is performed
1864| according to the IEC/IEEE Standard for Binary Floating-Point Arithmetic.
1865*----------------------------------------------------------------------------*/
1866
1867float32 float32_rem( float32 a, float32 b )
1868{
1869    flag aSign, bSign, zSign;
1870    int16 aExp, bExp, expDiff;
1871    bits32 aSig, bSig;
1872    bits32 q;
1873    bits64 aSig64, bSig64, q64;
1874    bits32 alternateASig;
1875    sbits32 sigMean;
1876
1877    aSig = extractFloat32Frac( a );
1878    aExp = extractFloat32Exp( a );
1879    aSign = extractFloat32Sign( a );
1880    bSig = extractFloat32Frac( b );
1881    bExp = extractFloat32Exp( b );
1882    bSign = extractFloat32Sign( b );
1883    if ( aExp == 0xFF ) {
1884        if ( aSig || ( ( bExp == 0xFF ) && bSig ) ) {
1885            return propagateFloat32NaN( a, b );
1886        }
1887        float_raise( float_flag_invalid );
1888        return float32_default_nan;
1889    }
1890    if ( bExp == 0xFF ) {
1891        if ( bSig ) return propagateFloat32NaN( a, b );
1892        return a;
1893    }
1894    if ( bExp == 0 ) {
1895        if ( bSig == 0 ) {
1896            float_raise( float_flag_invalid );
1897            return float32_default_nan;
1898        }
1899        normalizeFloat32Subnormal( bSig, &bExp, &bSig );
1900    }
1901    if ( aExp == 0 ) {
1902        if ( aSig == 0 ) return a;
1903        normalizeFloat32Subnormal( aSig, &aExp, &aSig );
1904    }
1905    expDiff = aExp - bExp;
1906    aSig |= 0x00800000;
1907    bSig |= 0x00800000;
1908    if ( expDiff < 32 ) {
1909        aSig <<= 8;
1910        bSig <<= 8;
1911        if ( expDiff < 0 ) {
1912            if ( expDiff < -1 ) return a;
1913            aSig >>= 1;
1914        }
1915        q = ( bSig <= aSig );
1916        if ( q ) aSig -= bSig;
1917        if ( 0 < expDiff ) {
1918            q = ( ( (bits64) aSig )<<32 ) / bSig;
1919            q >>= 32 - expDiff;
1920            bSig >>= 2;
1921            aSig = ( ( aSig>>1 )<<( expDiff - 1 ) ) - bSig * q;
1922        }
1923        else {
1924            aSig >>= 2;
1925            bSig >>= 2;
1926        }
1927    }
1928    else {
1929        if ( bSig <= aSig ) aSig -= bSig;
1930        aSig64 = ( (bits64) aSig )<<40;
1931        bSig64 = ( (bits64) bSig )<<40;
1932        expDiff -= 64;
1933        while ( 0 < expDiff ) {
1934            q64 = estimateDiv128To64( aSig64, 0, bSig64 );
1935            q64 = ( 2 < q64 ) ? q64 - 2 : 0;
1936            aSig64 = - ( ( bSig * q64 )<<38 );
1937            expDiff -= 62;
1938        }
1939        expDiff += 64;
1940        q64 = estimateDiv128To64( aSig64, 0, bSig64 );
1941        q64 = ( 2 < q64 ) ? q64 - 2 : 0;
1942        q = q64>>( 64 - expDiff );
1943        bSig <<= 6;
1944        aSig = ( ( aSig64>>33 )<<( expDiff - 1 ) ) - bSig * q;
1945    }
1946    do {
1947        alternateASig = aSig;
1948        ++q;
1949        aSig -= bSig;
1950    } while ( 0 <= (sbits32) aSig );
1951    sigMean = aSig + alternateASig;
1952    if ( ( sigMean < 0 ) || ( ( sigMean == 0 ) && ( q & 1 ) ) ) {
1953        aSig = alternateASig;
1954    }
1955    zSign = ( (sbits32) aSig < 0 );
1956    if ( zSign ) aSig = - aSig;
1957    return normalizeRoundAndPackFloat32( aSign ^ zSign, bExp, aSig );
1958
1959}
1960
1961/*----------------------------------------------------------------------------
1962| Returns the square root of the single-precision floating-point value `a'.
1963| The operation is performed according to the IEC/IEEE Standard for Binary
1964| Floating-Point Arithmetic.
1965*----------------------------------------------------------------------------*/
1966
1967float32 float32_sqrt( float32 a )
1968{
1969    flag aSign;
1970    int16 aExp, zExp;
1971    bits32 aSig, zSig;
1972    bits64 rem, term;
1973
1974    aSig = extractFloat32Frac( a );
1975    aExp = extractFloat32Exp( a );
1976    aSign = extractFloat32Sign( a );
1977    if ( aExp == 0xFF ) {
1978        if ( aSig ) return propagateFloat32NaN( a, 0 );
1979        if ( ! aSign ) return a;
1980        float_raise( float_flag_invalid );
1981        return float32_default_nan;
1982    }
1983    if ( aSign ) {
1984        if ( ( aExp | aSig ) == 0 ) return a;
1985        float_raise( float_flag_invalid );
1986        return float32_default_nan;
1987    }
1988    if ( aExp == 0 ) {
1989        if ( aSig == 0 ) return 0;
1990        normalizeFloat32Subnormal( aSig, &aExp, &aSig );
1991    }
1992    zExp = ( ( aExp - 0x7F )>>1 ) + 0x7E;
1993    aSig = ( aSig | 0x00800000 )<<8;
1994    zSig = estimateSqrt32( aExp, aSig ) + 2;
1995    if ( ( zSig & 0x7F ) <= 5 ) {
1996        if ( zSig < 2 ) {
1997            zSig = 0x7FFFFFFF;
1998            goto roundAndPack;
1999        }
2000        aSig >>= aExp & 1;
2001        term = ( (bits64) zSig ) * zSig;
2002        rem = ( ( (bits64) aSig )<<32 ) - term;
2003        while ( (sbits64) rem < 0 ) {
2004            --zSig;
2005            rem += ( ( (bits64) zSig )<<1 ) | 1;
2006        }
2007        zSig |= ( rem != 0 );
2008    }
2009    shift32RightJamming( zSig, 1, &zSig );
2010 roundAndPack:
2011    return roundAndPackFloat32( 0, zExp, zSig );
2012
2013}
2014
2015/*----------------------------------------------------------------------------
2016| Returns 1 if the single-precision floating-point value `a' is equal to
2017| the corresponding value `b', and 0 otherwise.  The comparison is performed
2018| according to the IEC/IEEE Standard for Binary Floating-Point Arithmetic.
2019*----------------------------------------------------------------------------*/
2020
2021flag float32_eq( float32 a, float32 b )
2022{
2023
2024    if (    ( ( extractFloat32Exp( a ) == 0xFF ) && extractFloat32Frac( a ) )
2025         || ( ( extractFloat32Exp( b ) == 0xFF ) && extractFloat32Frac( b ) )
2026       ) {
2027        if ( float32_is_signaling_nan( a ) || float32_is_signaling_nan( b ) ) {
2028            float_raise( float_flag_invalid );
2029        }
2030        return 0;
2031    }
2032    return ( a == b ) || ( (bits32) ( ( a | b )<<1 ) == 0 );
2033
2034}
2035
2036/*----------------------------------------------------------------------------
2037| Returns 1 if the single-precision floating-point value `a' is less than
2038| or equal to the corresponding value `b', and 0 otherwise.  The comparison
2039| is performed according to the IEC/IEEE Standard for Binary Floating-Point
2040| Arithmetic.
2041*----------------------------------------------------------------------------*/
2042
2043flag float32_le( float32 a, float32 b )
2044{
2045    flag aSign, bSign;
2046
2047    if (    ( ( extractFloat32Exp( a ) == 0xFF ) && extractFloat32Frac( a ) )
2048         || ( ( extractFloat32Exp( b ) == 0xFF ) && extractFloat32Frac( b ) )
2049       ) {
2050        float_raise( float_flag_invalid );
2051        return 0;
2052    }
2053    aSign = extractFloat32Sign( a );
2054    bSign = extractFloat32Sign( b );
2055    if ( aSign != bSign ) return aSign || ( (bits32) ( ( a | b )<<1 ) == 0 );
2056    return ( a == b ) || ( aSign ^ ( a < b ) );
2057
2058}
2059
2060/*----------------------------------------------------------------------------
2061| Returns 1 if the single-precision floating-point value `a' is less than
2062| the corresponding value `b', and 0 otherwise.  The comparison is performed
2063| according to the IEC/IEEE Standard for Binary Floating-Point Arithmetic.
2064*----------------------------------------------------------------------------*/
2065
2066flag float32_lt( float32 a, float32 b )
2067{
2068    flag aSign, bSign;
2069
2070    if (    ( ( extractFloat32Exp( a ) == 0xFF ) && extractFloat32Frac( a ) )
2071         || ( ( extractFloat32Exp( b ) == 0xFF ) && extractFloat32Frac( b ) )
2072       ) {
2073        float_raise( float_flag_invalid );
2074        return 0;
2075    }
2076    aSign = extractFloat32Sign( a );
2077    bSign = extractFloat32Sign( b );
2078    if ( aSign != bSign ) return aSign && ( (bits32) ( ( a | b )<<1 ) != 0 );
2079    return ( a != b ) && ( aSign ^ ( a < b ) );
2080
2081}
2082
2083/*----------------------------------------------------------------------------
2084| Returns 1 if the single-precision floating-point value `a' is equal to
2085| the corresponding value `b', and 0 otherwise.  The invalid exception is
2086| raised if either operand is a NaN.  Otherwise, the comparison is performed
2087| according to the IEC/IEEE Standard for Binary Floating-Point Arithmetic.
2088*----------------------------------------------------------------------------*/
2089
2090flag float32_eq_signaling( float32 a, float32 b )
2091{
2092
2093    if (    ( ( extractFloat32Exp( a ) == 0xFF ) && extractFloat32Frac( a ) )
2094         || ( ( extractFloat32Exp( b ) == 0xFF ) && extractFloat32Frac( b ) )
2095       ) {
2096        float_raise( float_flag_invalid );
2097        return 0;
2098    }
2099    return ( a == b ) || ( (bits32) ( ( a | b )<<1 ) == 0 );
2100
2101}
2102
2103/*----------------------------------------------------------------------------
2104| Returns 1 if the single-precision floating-point value `a' is less than or
2105| equal to the corresponding value `b', and 0 otherwise.  Quiet NaNs do not
2106| cause an exception.  Otherwise, the comparison is performed according to the
2107| IEC/IEEE Standard for Binary Floating-Point Arithmetic.
2108*----------------------------------------------------------------------------*/
2109
2110flag float32_le_quiet( float32 a, float32 b )
2111{
2112    flag aSign, bSign;
2113//    int16 aExp, bExp;
2114
2115    if (    ( ( extractFloat32Exp( a ) == 0xFF ) && extractFloat32Frac( a ) )
2116         || ( ( extractFloat32Exp( b ) == 0xFF ) && extractFloat32Frac( b ) )
2117       ) {
2118        if ( float32_is_signaling_nan( a ) || float32_is_signaling_nan( b ) ) {
2119            float_raise( float_flag_invalid );
2120        }
2121        return 0;
2122    }
2123    aSign = extractFloat32Sign( a );
2124    bSign = extractFloat32Sign( b );
2125    if ( aSign != bSign ) return aSign || ( (bits32) ( ( a | b )<<1 ) == 0 );
2126    return ( a == b ) || ( aSign ^ ( a < b ) );
2127
2128}
2129
2130/*----------------------------------------------------------------------------
2131| Returns 1 if the single-precision floating-point value `a' is less than
2132| the corresponding value `b', and 0 otherwise.  Quiet NaNs do not cause an
2133| exception.  Otherwise, the comparison is performed according to the IEC/IEEE
2134| Standard for Binary Floating-Point Arithmetic.
2135*----------------------------------------------------------------------------*/
2136
2137flag float32_lt_quiet( float32 a, float32 b )
2138{
2139    flag aSign, bSign;
2140
2141    if (    ( ( extractFloat32Exp( a ) == 0xFF ) && extractFloat32Frac( a ) )
2142         || ( ( extractFloat32Exp( b ) == 0xFF ) && extractFloat32Frac( b ) )
2143       ) {
2144        if ( float32_is_signaling_nan( a ) || float32_is_signaling_nan( b ) ) {
2145            float_raise( float_flag_invalid );
2146        }
2147        return 0;
2148    }
2149    aSign = extractFloat32Sign( a );
2150    bSign = extractFloat32Sign( b );
2151    if ( aSign != bSign ) return aSign && ( (bits32) ( ( a | b )<<1 ) != 0 );
2152    return ( a != b ) && ( aSign ^ ( a < b ) );
2153
2154}
2155
2156/*----------------------------------------------------------------------------
2157| Returns the result of converting the double-precision floating-point value
2158| `a' to the 32-bit two's complement integer format.  The conversion is
2159| performed according to the IEC/IEEE Standard for Binary Floating-Point
2160| Arithmetic---which means in particular that the conversion is rounded
2161| according to the current rounding mode.  If `a' is a NaN, the largest
2162| positive integer is returned.  Otherwise, if the conversion overflows, the
2163| largest integer with the same sign as `a' is returned.
2164*----------------------------------------------------------------------------*/
2165
2166int32 float64_to_int32( float64 a )
2167{
2168    flag aSign;
2169    int16 aExp, shiftCount;
2170    bits64 aSig;
2171
2172    aSig = extractFloat64Frac( a );
2173    aExp = extractFloat64Exp( a );
2174    aSign = extractFloat64Sign( a );
2175    if ( ( aExp == 0x7FF ) && aSig ) aSign = 0;
2176    if ( aExp ) aSig |= LIT64( 0x0010000000000000 );
2177    shiftCount = 0x42C - aExp;
2178    if ( 0 < shiftCount ) shift64RightJamming( aSig, shiftCount, &aSig );
2179    return roundAndPackInt32( aSign, aSig );
2180
2181}
2182
2183/*----------------------------------------------------------------------------
2184| Returns the result of converting the double-precision floating-point value
2185| `a' to the 32-bit two's complement integer format.  The conversion is
2186| performed according to the IEC/IEEE Standard for Binary Floating-Point
2187| Arithmetic, except that the conversion is always rounded toward zero.
2188| If `a' is a NaN, the largest positive integer is returned.  Otherwise, if
2189| the conversion overflows, the largest integer with the same sign as `a' is
2190| returned.
2191*----------------------------------------------------------------------------*/
2192
2193int32 float64_to_int32_round_to_zero( float64 a )
2194{
2195    flag aSign;
2196    int16 aExp, shiftCount;
2197    bits64 aSig, savedASig;
2198    int32 z;
2199
2200    aSig = extractFloat64Frac( a );
2201    aExp = extractFloat64Exp( a );
2202    aSign = extractFloat64Sign( a );
2203    if ( 0x41E < aExp ) {
2204        if ( ( aExp == 0x7FF ) && aSig ) aSign = 0;
2205        goto invalid;
2206    }
2207    else if ( aExp < 0x3FF ) {
2208        if ( aExp || aSig ) float_exception_flags |= float_flag_inexact;
2209        return 0;
2210    }
2211    aSig |= LIT64( 0x0010000000000000 );
2212    shiftCount = 0x433 - aExp;
2213    savedASig = aSig;
2214    aSig >>= shiftCount;
2215    z = aSig;
2216    if ( aSign ) z = - z;
2217    if ( ( z < 0 ) ^ aSign ) {
2218 invalid:
2219        float_raise( float_flag_invalid );
2220        return aSign ? (sbits32) 0x80000000 : 0x7FFFFFFF;
2221    }
2222    if ( ( aSig<<shiftCount ) != savedASig ) {
2223        float_exception_flags |= float_flag_inexact;
2224    }
2225    return z;
2226
2227}
2228
2229/*----------------------------------------------------------------------------
2230| Returns the result of converting the double-precision floating-point value
2231| `a' to the 64-bit two's complement integer format.  The conversion is
2232| performed according to the IEC/IEEE Standard for Binary Floating-Point
2233| Arithmetic---which means in particular that the conversion is rounded
2234| according to the current rounding mode.  If `a' is a NaN, the largest
2235| positive integer is returned.  Otherwise, if the conversion overflows, the
2236| largest integer with the same sign as `a' is returned.
2237*----------------------------------------------------------------------------*/
2238
2239int64 float64_to_int64( float64 a )
2240{
2241    flag aSign;
2242    int16 aExp, shiftCount;
2243    bits64 aSig, aSigExtra;
2244
2245    aSig = extractFloat64Frac( a );
2246    aExp = extractFloat64Exp( a );
2247    aSign = extractFloat64Sign( a );
2248    if ( aExp ) aSig |= LIT64( 0x0010000000000000 );
2249    shiftCount = 0x433 - aExp;
2250    if ( shiftCount <= 0 ) {
2251        if ( 0x43E < aExp ) {
2252            float_raise( float_flag_invalid );
2253            if (    ! aSign
2254                 || (    ( aExp == 0x7FF )
2255                      && ( aSig != LIT64( 0x0010000000000000 ) ) )
2256               ) {
2257                return LIT64( 0x7FFFFFFFFFFFFFFF );
2258            }
2259            return (sbits64) LIT64( 0x8000000000000000 );
2260        }
2261        aSigExtra = 0;
2262        aSig <<= - shiftCount;
2263    }
2264    else {
2265        shift64ExtraRightJamming( aSig, 0, shiftCount, &aSig, &aSigExtra );
2266    }
2267    return roundAndPackInt64( aSign, aSig, aSigExtra );
2268
2269}
2270
2271/*----------------------------------------------------------------------------
2272| Returns the result of converting the double-precision floating-point value
2273| `a' to the 64-bit two's complement integer format.  The conversion is
2274| performed according to the IEC/IEEE Standard for Binary Floating-Point
2275| Arithmetic, except that the conversion is always rounded toward zero.
2276| If `a' is a NaN, the largest positive integer is returned.  Otherwise, if
2277| the conversion overflows, the largest integer with the same sign as `a' is
2278| returned.
2279*----------------------------------------------------------------------------*/
2280
2281int64 float64_to_int64_round_to_zero( float64 a )
2282{
2283    flag aSign;
2284    int16 aExp, shiftCount;
2285    bits64 aSig;
2286    int64 z;
2287
2288    aSig = extractFloat64Frac( a );
2289    aExp = extractFloat64Exp( a );
2290    aSign = extractFloat64Sign( a );
2291    if ( aExp ) aSig |= LIT64( 0x0010000000000000 );
2292    shiftCount = aExp - 0x433;
2293    if ( 0 <= shiftCount ) {
2294        if ( 0x43E <= aExp ) {
2295            if ( a != LIT64( 0xC3E0000000000000 ) ) {
2296                float_raise( float_flag_invalid );
2297                if (    ! aSign
2298                     || (    ( aExp == 0x7FF )
2299                          && ( aSig != LIT64( 0x0010000000000000 ) ) )
2300                   ) {
2301                    return LIT64( 0x7FFFFFFFFFFFFFFF );
2302                }
2303            }
2304            return (sbits64) LIT64( 0x8000000000000000 );
2305        }
2306        z = aSig<<shiftCount;
2307    }
2308    else {
2309        if ( aExp < 0x3FE ) {
2310            if ( aExp | aSig ) float_exception_flags |= float_flag_inexact;
2311            return 0;
2312        }
2313        z = aSig>>( - shiftCount );
2314        if ( (bits64) ( aSig<<( shiftCount & 63 ) ) ) {
2315            float_exception_flags |= float_flag_inexact;
2316        }
2317    }
2318    if ( aSign ) z = - z;
2319    return z;
2320
2321}
2322
2323/*----------------------------------------------------------------------------
2324| Returns the result of converting the double-precision floating-point value
2325| `a' to the single-precision floating-point format.  The conversion is
2326| performed according to the IEC/IEEE Standard for Binary Floating-Point
2327| Arithmetic.
2328*----------------------------------------------------------------------------*/
2329
2330float32 float64_to_float32( float64 a )
2331{
2332    flag aSign;
2333    int16 aExp;
2334    bits64 aSig;
2335    bits32 zSig;
2336
2337    aSig = extractFloat64Frac( a );
2338    aExp = extractFloat64Exp( a );
2339    aSign = extractFloat64Sign( a );
2340    if ( aExp == 0x7FF ) {
2341        if ( aSig ) return commonNaNToFloat32( float64ToCommonNaN( a ) );
2342        return packFloat32( aSign, 0xFF, 0 );
2343    }
2344    shift64RightJamming( aSig, 22, &aSig );
2345    zSig = aSig;
2346    if ( aExp || zSig ) {
2347        zSig |= 0x40000000;
2348        aExp -= 0x381;
2349    }
2350    return roundAndPackFloat32( aSign, aExp, zSig );
2351
2352}
2353
2354#ifdef FLOATX80
2355
2356/*----------------------------------------------------------------------------
2357| Returns the result of converting the double-precision floating-point value
2358| `a' to the extended double-precision floating-point format.  The conversion
2359| is performed according to the IEC/IEEE Standard for Binary Floating-Point
2360| Arithmetic.
2361*----------------------------------------------------------------------------*/
2362
2363floatx80 float64_to_floatx80( float64 a )
2364{
2365    flag aSign;
2366    int16 aExp;
2367    bits64 aSig;
2368
2369    aSig = extractFloat64Frac( a );
2370    aExp = extractFloat64Exp( a );
2371    aSign = extractFloat64Sign( a );
2372    if ( aExp == 0x7FF ) {
2373        if ( aSig ) return commonNaNToFloatx80( float64ToCommonNaN( a ) );
2374        return packFloatx80( aSign, 0x7FFF, LIT64( 0x8000000000000000 ) );
2375    }
2376    if ( aExp == 0 ) {
2377        if ( aSig == 0 ) return packFloatx80( aSign, 0, 0 );
2378        normalizeFloat64Subnormal( aSig, &aExp, &aSig );
2379    }
2380    return
2381        packFloatx80(
2382            aSign, aExp + 0x3C00, ( aSig | LIT64( 0x0010000000000000 ) )<<11 );
2383
2384}
2385
2386#endif
2387
2388#ifdef FLOAT128
2389
2390/*----------------------------------------------------------------------------
2391| Returns the result of converting the double-precision floating-point value
2392| `a' to the quadruple-precision floating-point format.  The conversion is
2393| performed according to the IEC/IEEE Standard for Binary Floating-Point
2394| Arithmetic.
2395*----------------------------------------------------------------------------*/
2396
2397float128 float64_to_float128( float64 a )
2398{
2399    flag aSign;
2400    int16 aExp;
2401    bits64 aSig, zSig0, zSig1;
2402
2403    aSig = extractFloat64Frac( a );
2404    aExp = extractFloat64Exp( a );
2405    aSign = extractFloat64Sign( a );
2406    if ( aExp == 0x7FF ) {
2407        if ( aSig ) return commonNaNToFloat128( float64ToCommonNaN( a ) );
2408        return packFloat128( aSign, 0x7FFF, 0, 0 );
2409    }
2410    if ( aExp == 0 ) {
2411        if ( aSig == 0 ) return packFloat128( aSign, 0, 0, 0 );
2412        normalizeFloat64Subnormal( aSig, &aExp, &aSig );
2413        --aExp;
2414    }
2415    shift128Right( aSig, 0, 4, &zSig0, &zSig1 );
2416    return packFloat128( aSign, aExp + 0x3C00, zSig0, zSig1 );
2417
2418}
2419
2420#endif
2421
2422/*----------------------------------------------------------------------------
2423| Rounds the double-precision floating-point value `a' to an integer, and
2424| returns the result as a double-precision floating-point value.  The
2425| operation is performed according to the IEC/IEEE Standard for Binary
2426| Floating-Point Arithmetic.
2427*----------------------------------------------------------------------------*/
2428
2429float64 float64_round_to_int( float64 a )
2430{
2431    flag aSign;
2432    int16 aExp;
2433    bits64 lastBitMask, roundBitsMask;
2434    int8 roundingMode;
2435    float64 z;
2436
2437    aExp = extractFloat64Exp( a );
2438    if ( 0x433 <= aExp ) {
2439        if ( ( aExp == 0x7FF ) && extractFloat64Frac( a ) ) {
2440            return propagateFloat64NaN( a, a );
2441        }
2442        return a;
2443    }
2444    if ( aExp < 0x3FF ) {
2445        if ( (bits64) ( a<<1 ) == 0 ) return a;
2446        float_exception_flags |= float_flag_inexact;
2447        aSign = extractFloat64Sign( a );
2448        switch ( float_rounding_mode ) {
2449         case float_round_nearest_even:
2450            if ( ( aExp == 0x3FE ) && extractFloat64Frac( a ) ) {
2451                return packFloat64( aSign, 0x3FF, 0 );
2452            }
2453            break;
2454         case float_round_down:
2455            return aSign ? LIT64( 0xBFF0000000000000 ) : 0;
2456         case float_round_up:
2457            return
2458            aSign ? LIT64( 0x8000000000000000 ) : LIT64( 0x3FF0000000000000 );
2459        }
2460        return packFloat64( aSign, 0, 0 );
2461    }
2462    lastBitMask = 1;
2463    lastBitMask <<= 0x433 - aExp;
2464    roundBitsMask = lastBitMask - 1;
2465    z = a;
2466    roundingMode = float_rounding_mode;
2467    if ( roundingMode == float_round_nearest_even ) {
2468        z += lastBitMask>>1;
2469        if ( ( z & roundBitsMask ) == 0 ) z &= ~ lastBitMask;
2470    }
2471    else if ( roundingMode != float_round_to_zero ) {
2472        if ( extractFloat64Sign( z ) ^ ( roundingMode == float_round_up ) ) {
2473            z += roundBitsMask;
2474        }
2475    }
2476    z &= ~ roundBitsMask;
2477    if ( z != a ) float_exception_flags |= float_flag_inexact;
2478    return z;
2479
2480}
2481
2482/*----------------------------------------------------------------------------
2483| Returns the result of adding the absolute values of the double-precision
2484| floating-point values `a' and `b'.  If `zSign' is 1, the sum is negated
2485| before being returned.  `zSign' is ignored if the result is a NaN.
2486| The addition is performed according to the IEC/IEEE Standard for Binary
2487| Floating-Point Arithmetic.
2488*----------------------------------------------------------------------------*/
2489
2490static float64 addFloat64Sigs( float64 a, float64 b, flag zSign )
2491{
2492    int16 aExp, bExp, zExp;
2493    bits64 aSig, bSig, zSig;
2494    int16 expDiff;
2495
2496    aSig = extractFloat64Frac( a );
2497    aExp = extractFloat64Exp( a );
2498    bSig = extractFloat64Frac( b );
2499    bExp = extractFloat64Exp( b );
2500    expDiff = aExp - bExp;
2501    aSig <<= 9;
2502    bSig <<= 9;
2503    if ( 0 < expDiff ) {
2504        if ( aExp == 0x7FF ) {
2505            if ( aSig ) return propagateFloat64NaN( a, b );
2506            return a;
2507        }
2508        if ( bExp == 0 ) {
2509            --expDiff;
2510        }
2511        else {
2512            bSig |= LIT64( 0x2000000000000000 );
2513        }
2514        shift64RightJamming( bSig, expDiff, &bSig );
2515        zExp = aExp;
2516    }
2517    else if ( expDiff < 0 ) {
2518        if ( bExp == 0x7FF ) {
2519            if ( bSig ) return propagateFloat64NaN( a, b );
2520            return packFloat64( zSign, 0x7FF, 0 );
2521        }
2522        if ( aExp == 0 ) {
2523            ++expDiff;
2524        }
2525        else {
2526            aSig |= LIT64( 0x2000000000000000 );
2527        }
2528        shift64RightJamming( aSig, - expDiff, &aSig );
2529        zExp = bExp;
2530    }
2531    else {
2532        if ( aExp == 0x7FF ) {
2533            if ( aSig | bSig ) return propagateFloat64NaN( a, b );
2534            return a;
2535        }
2536        if ( aExp == 0 ) return packFloat64( zSign, 0, ( aSig + bSig )>>9 );
2537        zSig = LIT64( 0x4000000000000000 ) + aSig + bSig;
2538        zExp = aExp;
2539        goto roundAndPack;
2540    }
2541    aSig |= LIT64( 0x2000000000000000 );
2542    zSig = ( aSig + bSig )<<1;
2543    --zExp;
2544    if ( (sbits64) zSig < 0 ) {
2545        zSig = aSig + bSig;
2546        ++zExp;
2547    }
2548 roundAndPack:
2549    return roundAndPackFloat64( zSign, zExp, zSig );
2550
2551}
2552
2553/*----------------------------------------------------------------------------
2554| Returns the result of subtracting the absolute values of the double-
2555| precision floating-point values `a' and `b'.  If `zSign' is 1, the
2556| difference is negated before being returned.  `zSign' is ignored if the
2557| result is a NaN.  The subtraction is performed according to the IEC/IEEE
2558| Standard for Binary Floating-Point Arithmetic.
2559*----------------------------------------------------------------------------*/
2560
2561static float64 subFloat64Sigs( float64 a, float64 b, flag zSign )
2562{
2563    int16 aExp, bExp, zExp;
2564    bits64 aSig, bSig, zSig;
2565    int16 expDiff;
2566
2567    aSig = extractFloat64Frac( a );
2568    aExp = extractFloat64Exp( a );
2569    bSig = extractFloat64Frac( b );
2570    bExp = extractFloat64Exp( b );
2571    expDiff = aExp - bExp;
2572    aSig <<= 10;
2573    bSig <<= 10;
2574    if ( 0 < expDiff ) goto aExpBigger;
2575    if ( expDiff < 0 ) goto bExpBigger;
2576    if ( aExp == 0x7FF ) {
2577        if ( aSig | bSig ) return propagateFloat64NaN( a, b );
2578        float_raise( float_flag_invalid );
2579        return float64_default_nan;
2580    }
2581    if ( aExp == 0 ) {
2582        aExp = 1;
2583        bExp = 1;
2584    }
2585    if ( bSig < aSig ) goto aBigger;
2586    if ( aSig < bSig ) goto bBigger;
2587    return packFloat64( float_rounding_mode == float_round_down, 0, 0 );
2588 bExpBigger:
2589    if ( bExp == 0x7FF ) {
2590        if ( bSig ) return propagateFloat64NaN( a, b );
2591        return packFloat64( zSign ^ 1, 0x7FF, 0 );
2592    }
2593    if ( aExp == 0 ) {
2594        ++expDiff;
2595    }
2596    else {
2597        aSig |= LIT64( 0x4000000000000000 );
2598    }
2599    shift64RightJamming( aSig, - expDiff, &aSig );
2600    bSig |= LIT64( 0x4000000000000000 );
2601 bBigger:
2602    zSig = bSig - aSig;
2603    zExp = bExp;
2604    zSign ^= 1;
2605    goto normalizeRoundAndPack;
2606 aExpBigger:
2607    if ( aExp == 0x7FF ) {
2608        if ( aSig ) return propagateFloat64NaN( a, b );
2609        return a;
2610    }
2611    if ( bExp == 0 ) {
2612        --expDiff;
2613    }
2614    else {
2615        bSig |= LIT64( 0x4000000000000000 );
2616    }
2617    shift64RightJamming( bSig, expDiff, &bSig );
2618    aSig |= LIT64( 0x4000000000000000 );
2619 aBigger:
2620    zSig = aSig - bSig;
2621    zExp = aExp;
2622 normalizeRoundAndPack:
2623    --zExp;
2624    return normalizeRoundAndPackFloat64( zSign, zExp, zSig );
2625
2626}
2627
2628/*----------------------------------------------------------------------------
2629| Returns the result of adding the double-precision floating-point values `a'
2630| and `b'.  The operation is performed according to the IEC/IEEE Standard for
2631| Binary Floating-Point Arithmetic.
2632*----------------------------------------------------------------------------*/
2633
2634float64 float64_add( float64 a, float64 b )
2635{
2636    flag aSign, bSign;
2637
2638    aSign = extractFloat64Sign( a );
2639    bSign = extractFloat64Sign( b );
2640    if ( aSign == bSign ) {
2641        return addFloat64Sigs( a, b, aSign );
2642    }
2643    else {
2644        return subFloat64Sigs( a, b, aSign );
2645    }
2646
2647}
2648
2649/*----------------------------------------------------------------------------
2650| Returns the result of subtracting the double-precision floating-point values
2651| `a' and `b'.  The operation is performed according to the IEC/IEEE Standard
2652| for Binary Floating-Point Arithmetic.
2653*----------------------------------------------------------------------------*/
2654
2655float64 float64_sub( float64 a, float64 b )
2656{
2657    flag aSign, bSign;
2658
2659    aSign = extractFloat64Sign( a );
2660    bSign = extractFloat64Sign( b );
2661    if ( aSign == bSign ) {
2662        return subFloat64Sigs( a, b, aSign );
2663    }
2664    else {
2665        return addFloat64Sigs( a, b, aSign );
2666    }
2667
2668}
2669
2670/*----------------------------------------------------------------------------
2671| Returns the result of multiplying the double-precision floating-point values
2672| `a' and `b'.  The operation is performed according to the IEC/IEEE Standard
2673| for Binary Floating-Point Arithmetic.
2674*----------------------------------------------------------------------------*/
2675
2676float64 float64_mul( float64 a, float64 b )
2677{
2678    flag aSign, bSign, zSign;
2679    int16 aExp, bExp, zExp;
2680    bits64 aSig, bSig, zSig0, zSig1;
2681
2682    aSig = extractFloat64Frac( a );
2683    aExp = extractFloat64Exp( a );
2684    aSign = extractFloat64Sign( a );
2685    bSig = extractFloat64Frac( b );
2686    bExp = extractFloat64Exp( b );
2687    bSign = extractFloat64Sign( b );
2688    zSign = aSign ^ bSign;
2689    if ( aExp == 0x7FF ) {
2690        if ( aSig || ( ( bExp == 0x7FF ) && bSig ) ) {
2691            return propagateFloat64NaN( a, b );
2692        }
2693        if ( ( bExp | bSig ) == 0 ) {
2694            float_raise( float_flag_invalid );
2695            return float64_default_nan;
2696        }
2697        return packFloat64( zSign, 0x7FF, 0 );
2698    }
2699    if ( bExp == 0x7FF ) {
2700        if ( bSig ) return propagateFloat64NaN( a, b );
2701        if ( ( aExp | aSig ) == 0 ) {
2702            float_raise( float_flag_invalid );
2703            return float64_default_nan;
2704        }
2705        return packFloat64( zSign, 0x7FF, 0 );
2706    }
2707    if ( aExp == 0 ) {
2708        if ( aSig == 0 ) return packFloat64( zSign, 0, 0 );
2709        normalizeFloat64Subnormal( aSig, &aExp, &aSig );
2710    }
2711    if ( bExp == 0 ) {
2712        if ( bSig == 0 ) return packFloat64( zSign, 0, 0 );
2713        normalizeFloat64Subnormal( bSig, &bExp, &bSig );
2714    }
2715    zExp = aExp + bExp - 0x3FF;
2716    aSig = ( aSig | LIT64( 0x0010000000000000 ) )<<10;
2717    bSig = ( bSig | LIT64( 0x0010000000000000 ) )<<11;
2718    mul64To128( aSig, bSig, &zSig0, &zSig1 );
2719    zSig0 |= ( zSig1 != 0 );
2720    if ( 0 <= (sbits64) ( zSig0<<1 ) ) {
2721        zSig0 <<= 1;
2722        --zExp;
2723    }
2724    return roundAndPackFloat64( zSign, zExp, zSig0 );
2725
2726}
2727
2728/*----------------------------------------------------------------------------
2729| Returns the result of dividing the double-precision floating-point value `a'
2730| by the corresponding value `b'.  The operation is performed according to
2731| the IEC/IEEE Standard for Binary Floating-Point Arithmetic.
2732*----------------------------------------------------------------------------*/
2733
2734float64 float64_div( float64 a, float64 b )
2735{
2736    flag aSign, bSign, zSign;
2737    int16 aExp, bExp, zExp;
2738    bits64 aSig, bSig, zSig;
2739    bits64 rem0, rem1;
2740    bits64 term0, term1;
2741
2742    aSig = extractFloat64Frac( a );
2743    aExp = extractFloat64Exp( a );
2744    aSign = extractFloat64Sign( a );
2745    bSig = extractFloat64Frac( b );
2746    bExp = extractFloat64Exp( b );
2747    bSign = extractFloat64Sign( b );
2748    zSign = aSign ^ bSign;
2749    if ( aExp == 0x7FF ) {
2750        if ( aSig ) return propagateFloat64NaN( a, b );
2751        if ( bExp == 0x7FF ) {
2752            if ( bSig ) return propagateFloat64NaN( a, b );
2753            float_raise( float_flag_invalid );
2754            return float64_default_nan;
2755        }
2756        return packFloat64( zSign, 0x7FF, 0 );
2757    }
2758    if ( bExp == 0x7FF ) {
2759        if ( bSig ) return propagateFloat64NaN( a, b );
2760        return packFloat64( zSign, 0, 0 );
2761    }
2762    if ( bExp == 0 ) {
2763        if ( bSig == 0 ) {
2764            if ( ( aExp | aSig ) == 0 ) {
2765                float_raise( float_flag_invalid );
2766                return float64_default_nan;
2767            }
2768            float_raise( float_flag_divbyzero );
2769            return packFloat64( zSign, 0x7FF, 0 );
2770        }
2771        normalizeFloat64Subnormal( bSig, &bExp, &bSig );
2772    }
2773    if ( aExp == 0 ) {
2774        if ( aSig == 0 ) return packFloat64( zSign, 0, 0 );
2775        normalizeFloat64Subnormal( aSig, &aExp, &aSig );
2776    }
2777    zExp = aExp - bExp + 0x3FD;
2778    aSig = ( aSig | LIT64( 0x0010000000000000 ) )<<10;
2779    bSig = ( bSig | LIT64( 0x0010000000000000 ) )<<11;
2780    if ( bSig <= ( aSig + aSig ) ) {
2781        aSig >>= 1;
2782        ++zExp;
2783    }
2784    zSig = estimateDiv128To64( aSig, 0, bSig );
2785    if ( ( zSig & 0x1FF ) <= 2 ) {
2786        mul64To128( bSig, zSig, &term0, &term1 );
2787        sub128( aSig, 0, term0, term1, &rem0, &rem1 );
2788        while ( (sbits64) rem0 < 0 ) {
2789            --zSig;
2790            add128( rem0, rem1, 0, bSig, &rem0, &rem1 );
2791        }
2792        zSig |= ( rem1 != 0 );
2793    }
2794    return roundAndPackFloat64( zSign, zExp, zSig );
2795
2796}
2797
2798/*----------------------------------------------------------------------------
2799| Returns the remainder of the double-precision floating-point value `a'
2800| with respect to the corresponding value `b'.  The operation is performed
2801| according to the IEC/IEEE Standard for Binary Floating-Point Arithmetic.
2802*----------------------------------------------------------------------------*/
2803
2804float64 float64_rem( float64 a, float64 b )
2805{
2806    flag aSign, bSign, zSign;
2807    int16 aExp, bExp, expDiff;
2808    bits64 aSig, bSig;
2809    bits64 q, alternateASig;
2810    sbits64 sigMean;
2811
2812    aSig = extractFloat64Frac( a );
2813    aExp = extractFloat64Exp( a );
2814    aSign = extractFloat64Sign( a );
2815    bSig = extractFloat64Frac( b );
2816    bExp = extractFloat64Exp( b );
2817    bSign = extractFloat64Sign( b );
2818    if ( aExp == 0x7FF ) {
2819        if ( aSig || ( ( bExp == 0x7FF ) && bSig ) ) {
2820            return propagateFloat64NaN( a, b );
2821        }
2822        float_raise( float_flag_invalid );
2823        return float64_default_nan;
2824    }
2825    if ( bExp == 0x7FF ) {
2826        if ( bSig ) return propagateFloat64NaN( a, b );
2827        return a;
2828    }
2829    if ( bExp == 0 ) {
2830        if ( bSig == 0 ) {
2831            float_raise( float_flag_invalid );
2832            return float64_default_nan;
2833        }
2834        normalizeFloat64Subnormal( bSig, &bExp, &bSig );
2835    }
2836    if ( aExp == 0 ) {
2837        if ( aSig == 0 ) return a;
2838        normalizeFloat64Subnormal( aSig, &aExp, &aSig );
2839    }
2840    expDiff = aExp - bExp;
2841    aSig = ( aSig | LIT64( 0x0010000000000000 ) )<<11;
2842    bSig = ( bSig | LIT64( 0x0010000000000000 ) )<<11;
2843    if ( expDiff < 0 ) {
2844        if ( expDiff < -1 ) return a;
2845        aSig >>= 1;
2846    }
2847    q = ( bSig <= aSig );
2848    if ( q ) aSig -= bSig;
2849    expDiff -= 64;
2850    while ( 0 < expDiff ) {
2851        q = estimateDiv128To64( aSig, 0, bSig );
2852        q = ( 2 < q ) ? q - 2 : 0;
2853        aSig = - ( ( bSig>>2 ) * q );
2854        expDiff -= 62;
2855    }
2856    expDiff += 64;
2857    if ( 0 < expDiff ) {
2858        q = estimateDiv128To64( aSig, 0, bSig );
2859        q = ( 2 < q ) ? q - 2 : 0;
2860        q >>= 64 - expDiff;
2861        bSig >>= 2;
2862        aSig = ( ( aSig>>1 )<<( expDiff - 1 ) ) - bSig * q;
2863    }
2864    else {
2865        aSig >>= 2;
2866        bSig >>= 2;
2867    }
2868    do {
2869        alternateASig = aSig;
2870        ++q;
2871        aSig -= bSig;
2872    } while ( 0 <= (sbits64) aSig );
2873    sigMean = aSig + alternateASig;
2874    if ( ( sigMean < 0 ) || ( ( sigMean == 0 ) && ( q & 1 ) ) ) {
2875        aSig = alternateASig;
2876    }
2877    zSign = ( (sbits64) aSig < 0 );
2878    if ( zSign ) aSig = - aSig;
2879    return normalizeRoundAndPackFloat64( aSign ^ zSign, bExp, aSig );
2880
2881}
2882
2883/*----------------------------------------------------------------------------
2884| Returns the square root of the double-precision floating-point value `a'.
2885| The operation is performed according to the IEC/IEEE Standard for Binary
2886| Floating-Point Arithmetic.
2887*----------------------------------------------------------------------------*/
2888
2889float64 float64_sqrt( float64 a )
2890{
2891    flag aSign;
2892    int16 aExp, zExp;
2893    bits64 aSig, zSig, doubleZSig;
2894    bits64 rem0, rem1, term0, term1;
2895//    float64 z;
2896
2897    aSig = extractFloat64Frac( a );
2898    aExp = extractFloat64Exp( a );
2899    aSign = extractFloat64Sign( a );
2900    if ( aExp == 0x7FF ) {
2901        if ( aSig ) return propagateFloat64NaN( a, a );
2902        if ( ! aSign ) return a;
2903        float_raise( float_flag_invalid );
2904        return float64_default_nan;
2905    }
2906    if ( aSign ) {
2907        if ( ( aExp | aSig ) == 0 ) return a;
2908        float_raise( float_flag_invalid );
2909        return float64_default_nan;
2910    }
2911    if ( aExp == 0 ) {
2912        if ( aSig == 0 ) return 0;
2913        normalizeFloat64Subnormal( aSig, &aExp, &aSig );
2914    }
2915    zExp = ( ( aExp - 0x3FF )>>1 ) + 0x3FE;
2916    aSig |= LIT64( 0x0010000000000000 );
2917    zSig = estimateSqrt32( aExp, aSig>>21 );
2918    aSig <<= 9 - ( aExp & 1 );
2919    zSig = estimateDiv128To64( aSig, 0, zSig<<32 ) + ( zSig<<30 );
2920    if ( ( zSig & 0x1FF ) <= 5 ) {
2921        doubleZSig = zSig<<1;
2922        mul64To128( zSig, zSig, &term0, &term1 );
2923        sub128( aSig, 0, term0, term1, &rem0, &rem1 );
2924        while ( (sbits64) rem0 < 0 ) {
2925            --zSig;
2926            doubleZSig -= 2;
2927            add128( rem0, rem1, zSig>>63, doubleZSig | 1, &rem0, &rem1 );
2928        }
2929        zSig |= ( ( rem0 | rem1 ) != 0 );
2930    }
2931    return roundAndPackFloat64( 0, zExp, zSig );
2932
2933}
2934
2935/*----------------------------------------------------------------------------
2936| Returns 1 if the double-precision floating-point value `a' is equal to the
2937| corresponding value `b', and 0 otherwise.  The comparison is performed
2938| according to the IEC/IEEE Standard for Binary Floating-Point Arithmetic.
2939*----------------------------------------------------------------------------*/
2940
2941flag float64_eq( float64 a, float64 b )
2942{
2943
2944    if (    ( ( extractFloat64Exp( a ) == 0x7FF ) && extractFloat64Frac( a ) )
2945         || ( ( extractFloat64Exp( b ) == 0x7FF ) && extractFloat64Frac( b ) )
2946       ) {
2947        if ( float64_is_signaling_nan( a ) || float64_is_signaling_nan( b ) ) {
2948            float_raise( float_flag_invalid );
2949        }
2950        return 0;
2951    }
2952    return ( a == b ) || ( (bits64) ( ( a | b )<<1 ) == 0 );
2953
2954}
2955
2956/*----------------------------------------------------------------------------
2957| Returns 1 if the double-precision floating-point value `a' is less than or
2958| equal to the corresponding value `b', and 0 otherwise.  The comparison is
2959| performed according to the IEC/IEEE Standard for Binary Floating-Point
2960| Arithmetic.
2961*----------------------------------------------------------------------------*/
2962
2963flag float64_le( float64 a, float64 b )
2964{
2965    flag aSign, bSign;
2966
2967    if (    ( ( extractFloat64Exp( a ) == 0x7FF ) && extractFloat64Frac( a ) )
2968         || ( ( extractFloat64Exp( b ) == 0x7FF ) && extractFloat64Frac( b ) )
2969       ) {
2970        float_raise( float_flag_invalid );
2971        return 0;
2972    }
2973    aSign = extractFloat64Sign( a );
2974    bSign = extractFloat64Sign( b );
2975    if ( aSign != bSign ) return aSign || ( (bits64) ( ( a | b )<<1 ) == 0 );
2976    return ( a == b ) || ( aSign ^ ( a < b ) );
2977
2978}
2979
2980/*----------------------------------------------------------------------------
2981| Returns 1 if the double-precision floating-point value `a' is less than
2982| the corresponding value `b', and 0 otherwise.  The comparison is performed
2983| according to the IEC/IEEE Standard for Binary Floating-Point Arithmetic.
2984*----------------------------------------------------------------------------*/
2985
2986flag float64_lt( float64 a, float64 b )
2987{
2988    flag aSign, bSign;
2989
2990    if (    ( ( extractFloat64Exp( a ) == 0x7FF ) && extractFloat64Frac( a ) )
2991         || ( ( extractFloat64Exp( b ) == 0x7FF ) && extractFloat64Frac( b ) )
2992       ) {
2993        float_raise( float_flag_invalid );
2994        return 0;
2995    }
2996    aSign = extractFloat64Sign( a );
2997    bSign = extractFloat64Sign( b );
2998    if ( aSign != bSign ) return aSign && ( (bits64) ( ( a | b )<<1 ) != 0 );
2999    return ( a != b ) && ( aSign ^ ( a < b ) );
3000
3001}
3002
3003/*----------------------------------------------------------------------------
3004| Returns 1 if the double-precision floating-point value `a' is equal to the
3005| corresponding value `b', and 0 otherwise.  The invalid exception is raised
3006| if either operand is a NaN.  Otherwise, the comparison is performed
3007| according to the IEC/IEEE Standard for Binary Floating-Point Arithmetic.
3008*----------------------------------------------------------------------------*/
3009
3010flag float64_eq_signaling( float64 a, float64 b )
3011{
3012
3013    if (    ( ( extractFloat64Exp( a ) == 0x7FF ) && extractFloat64Frac( a ) )
3014         || ( ( extractFloat64Exp( b ) == 0x7FF ) && extractFloat64Frac( b ) )
3015       ) {
3016        float_raise( float_flag_invalid );
3017        return 0;
3018    }
3019    return ( a == b ) || ( (bits64) ( ( a | b )<<1 ) == 0 );
3020
3021}
3022
3023/*----------------------------------------------------------------------------
3024| Returns 1 if the double-precision floating-point value `a' is less than or
3025| equal to the corresponding value `b', and 0 otherwise.  Quiet NaNs do not
3026| cause an exception.  Otherwise, the comparison is performed according to the
3027| IEC/IEEE Standard for Binary Floating-Point Arithmetic.
3028*----------------------------------------------------------------------------*/
3029
3030flag float64_le_quiet( float64 a, float64 b )
3031{
3032    flag aSign, bSign;
3033//    int16 aExp, bExp;
3034
3035    if (    ( ( extractFloat64Exp( a ) == 0x7FF ) && extractFloat64Frac( a ) )
3036         || ( ( extractFloat64Exp( b ) == 0x7FF ) && extractFloat64Frac( b ) )
3037       ) {
3038        if ( float64_is_signaling_nan( a ) || float64_is_signaling_nan( b ) ) {
3039            float_raise( float_flag_invalid );
3040        }
3041        return 0;
3042    }
3043    aSign = extractFloat64Sign( a );
3044    bSign = extractFloat64Sign( b );
3045    if ( aSign != bSign ) return aSign || ( (bits64) ( ( a | b )<<1 ) == 0 );
3046    return ( a == b ) || ( aSign ^ ( a < b ) );
3047
3048}
3049
3050/*----------------------------------------------------------------------------
3051| Returns 1 if the double-precision floating-point value `a' is less than
3052| the corresponding value `b', and 0 otherwise.  Quiet NaNs do not cause an
3053| exception.  Otherwise, the comparison is performed according to the IEC/IEEE
3054| Standard for Binary Floating-Point Arithmetic.
3055*----------------------------------------------------------------------------*/
3056
3057flag float64_lt_quiet( float64 a, float64 b )
3058{
3059    flag aSign, bSign;
3060
3061    if (    ( ( extractFloat64Exp( a ) == 0x7FF ) && extractFloat64Frac( a ) )
3062         || ( ( extractFloat64Exp( b ) == 0x7FF ) && extractFloat64Frac( b ) )
3063       ) {
3064        if ( float64_is_signaling_nan( a ) || float64_is_signaling_nan( b ) ) {
3065            float_raise( float_flag_invalid );
3066        }
3067        return 0;
3068    }
3069    aSign = extractFloat64Sign( a );
3070    bSign = extractFloat64Sign( b );
3071    if ( aSign != bSign ) return aSign && ( (bits64) ( ( a | b )<<1 ) != 0 );
3072    return ( a != b ) && ( aSign ^ ( a < b ) );
3073
3074}
3075
3076#ifdef FLOATX80
3077
3078/*----------------------------------------------------------------------------
3079| Returns the result of converting the extended double-precision floating-
3080| point value `a' to the 32-bit two's complement integer format.  The
3081| conversion is performed according to the IEC/IEEE Standard for Binary
3082| Floating-Point Arithmetic---which means in particular that the conversion
3083| is rounded according to the current rounding mode.  If `a' is a NaN, the
3084| largest positive integer is returned.  Otherwise, if the conversion
3085| overflows, the largest integer with the same sign as `a' is returned.
3086*----------------------------------------------------------------------------*/
3087
3088int32 floatx80_to_int32( floatx80 a )
3089{
3090    flag aSign;
3091    int32 aExp, shiftCount;
3092    bits64 aSig;
3093
3094    aSig = extractFloatx80Frac( a );
3095    aExp = extractFloatx80Exp( a );
3096    aSign = extractFloatx80Sign( a );
3097    if ( ( aExp == 0x7FFF ) && (bits64) ( aSig<<1 ) ) aSign = 0;
3098    shiftCount = 0x4037 - aExp;
3099    if ( shiftCount <= 0 ) shiftCount = 1;
3100    shift64RightJamming( aSig, shiftCount, &aSig );
3101    return roundAndPackInt32( aSign, aSig );
3102
3103}
3104
3105/*----------------------------------------------------------------------------
3106| Returns the result of converting the extended double-precision floating-
3107| point value `a' to the 32-bit two's complement integer format.  The
3108| conversion is performed according to the IEC/IEEE Standard for Binary
3109| Floating-Point Arithmetic, except that the conversion is always rounded
3110| toward zero.  If `a' is a NaN, the largest positive integer is returned.
3111| Otherwise, if the conversion overflows, the largest integer with the same
3112| sign as `a' is returned.
3113*----------------------------------------------------------------------------*/
3114
3115int32 floatx80_to_int32_round_to_zero( floatx80 a )
3116{
3117    flag aSign;
3118    int32 aExp, shiftCount;
3119    bits64 aSig, savedASig;
3120    int32 z;
3121
3122    aSig = extractFloatx80Frac( a );
3123    aExp = extractFloatx80Exp( a );
3124    aSign = extractFloatx80Sign( a );
3125    if ( 0x401E < aExp ) {
3126        if ( ( aExp == 0x7FFF ) && (bits64) ( aSig<<1 ) ) aSign = 0;
3127        goto invalid;
3128    }
3129    else if ( aExp < 0x3FFF ) {
3130        if ( aExp || aSig ) float_exception_flags |= float_flag_inexact;
3131        return 0;
3132    }
3133    shiftCount = 0x403E - aExp;
3134    savedASig = aSig;
3135    aSig >>= shiftCount;
3136    z = aSig;
3137    if ( aSign ) z = - z;
3138    if ( ( z < 0 ) ^ aSign ) {
3139 invalid:
3140        float_raise( float_flag_invalid );
3141        return aSign ? (sbits32) 0x80000000 : 0x7FFFFFFF;
3142    }
3143    if ( ( aSig<<shiftCount ) != savedASig ) {
3144        float_exception_flags |= float_flag_inexact;
3145    }
3146    return z;
3147
3148}
3149
3150/*----------------------------------------------------------------------------
3151| Returns the result of converting the extended double-precision floating-
3152| point value `a' to the 64-bit two's complement integer format.  The
3153| conversion is performed according to the IEC/IEEE Standard for Binary
3154| Floating-Point Arithmetic---which means in particular that the conversion
3155| is rounded according to the current rounding mode.  If `a' is a NaN,
3156| the largest positive integer is returned.  Otherwise, if the conversion
3157| overflows, the largest integer with the same sign as `a' is returned.
3158*----------------------------------------------------------------------------*/
3159
3160int64 floatx80_to_int64( floatx80 a )
3161{
3162    flag aSign;
3163    int32 aExp, shiftCount;
3164    bits64 aSig, aSigExtra;
3165
3166    aSig = extractFloatx80Frac( a );
3167    aExp = extractFloatx80Exp( a );
3168    aSign = extractFloatx80Sign( a );
3169    shiftCount = 0x403E - aExp;
3170    if ( shiftCount <= 0 ) {
3171        if ( shiftCount ) {
3172            float_raise( float_flag_invalid );
3173            if (    ! aSign
3174                 || (    ( aExp == 0x7FFF )
3175                      && ( aSig != LIT64( 0x8000000000000000 ) ) )
3176               ) {
3177                return LIT64( 0x7FFFFFFFFFFFFFFF );
3178            }
3179            return (sbits64) LIT64( 0x8000000000000000 );
3180        }
3181        aSigExtra = 0;
3182    }
3183    else {
3184        shift64ExtraRightJamming( aSig, 0, shiftCount, &aSig, &aSigExtra );
3185    }
3186    return roundAndPackInt64( aSign, aSig, aSigExtra );
3187
3188}
3189
3190/*----------------------------------------------------------------------------
3191| Returns the result of converting the extended double-precision floating-
3192| point value `a' to the 64-bit two's complement integer format.  The
3193| conversion is performed according to the IEC/IEEE Standard for Binary
3194| Floating-Point Arithmetic, except that the conversion is always rounded
3195| toward zero.  If `a' is a NaN, the largest positive integer is returned.
3196| Otherwise, if the conversion overflows, the largest integer with the same
3197| sign as `a' is returned.
3198*----------------------------------------------------------------------------*/
3199
3200int64 floatx80_to_int64_round_to_zero( floatx80 a )
3201{
3202    flag aSign;
3203    int32 aExp, shiftCount;
3204    bits64 aSig;
3205    int64 z;
3206
3207    aSig = extractFloatx80Frac( a );
3208    aExp = extractFloatx80Exp( a );
3209    aSign = extractFloatx80Sign( a );
3210    shiftCount = aExp - 0x403E;
3211    if ( 0 <= shiftCount ) {
3212        aSig &= LIT64( 0x7FFFFFFFFFFFFFFF );
3213        if ( ( a.high != 0xC03E ) || aSig ) {
3214            float_raise( float_flag_invalid );
3215            if ( ! aSign || ( ( aExp == 0x7FFF ) && aSig ) ) {
3216                return LIT64( 0x7FFFFFFFFFFFFFFF );
3217            }
3218        }
3219        return (sbits64) LIT64( 0x8000000000000000 );
3220    }
3221    else if ( aExp < 0x3FFF ) {
3222        if ( aExp | aSig ) float_exception_flags |= float_flag_inexact;
3223        return 0;
3224    }
3225    z = aSig>>( - shiftCount );
3226    if ( (bits64) ( aSig<<( shiftCount & 63 ) ) ) {
3227        float_exception_flags |= float_flag_inexact;
3228    }
3229    if ( aSign ) z = - z;
3230    return z;
3231
3232}
3233
3234/*----------------------------------------------------------------------------
3235| Returns the result of converting the extended double-precision floating-
3236| point value `a' to the single-precision floating-point format.  The
3237| conversion is performed according to the IEC/IEEE Standard for Binary
3238| Floating-Point Arithmetic.
3239*----------------------------------------------------------------------------*/
3240
3241float32 floatx80_to_float32( floatx80 a )
3242{
3243    flag aSign;
3244    int32 aExp;
3245    bits64 aSig;
3246
3247    aSig = extractFloatx80Frac( a );
3248    aExp = extractFloatx80Exp( a );
3249    aSign = extractFloatx80Sign( a );
3250    if ( aExp == 0x7FFF ) {
3251        if ( (bits64) ( aSig<<1 ) ) {
3252            return commonNaNToFloat32( floatx80ToCommonNaN( a ) );
3253        }
3254        return packFloat32( aSign, 0xFF, 0 );
3255    }
3256    shift64RightJamming( aSig, 33, &aSig );
3257    if ( aExp || aSig ) aExp -= 0x3F81;
3258    return roundAndPackFloat32( aSign, aExp, aSig );
3259
3260}
3261
3262/*----------------------------------------------------------------------------
3263| Returns the result of converting the extended double-precision floating-
3264| point value `a' to the double-precision floating-point format.  The
3265| conversion is performed according to the IEC/IEEE Standard for Binary
3266| Floating-Point Arithmetic.
3267*----------------------------------------------------------------------------*/
3268
3269float64 floatx80_to_float64( floatx80 a )
3270{
3271    flag aSign;
3272    int32 aExp;
3273    bits64 aSig, zSig;
3274
3275    aSig = extractFloatx80Frac( a );
3276    aExp = extractFloatx80Exp( a );
3277    aSign = extractFloatx80Sign( a );
3278    if ( aExp == 0x7FFF ) {
3279        if ( (bits64) ( aSig<<1 ) ) {
3280            return commonNaNToFloat64( floatx80ToCommonNaN( a ) );
3281        }
3282        return packFloat64( aSign, 0x7FF, 0 );
3283    }
3284    shift64RightJamming( aSig, 1, &zSig );
3285    if ( aExp || aSig ) aExp -= 0x3C01;
3286    return roundAndPackFloat64( aSign, aExp, zSig );
3287
3288}
3289
3290#ifdef FLOAT128
3291
3292/*----------------------------------------------------------------------------
3293| Returns the result of converting the extended double-precision floating-
3294| point value `a' to the quadruple-precision floating-point format.  The
3295| conversion is performed according to the IEC/IEEE Standard for Binary
3296| Floating-Point Arithmetic.
3297*----------------------------------------------------------------------------*/
3298
3299float128 floatx80_to_float128( floatx80 a )
3300{
3301    flag aSign;
3302    int16 aExp;
3303    bits64 aSig, zSig0, zSig1;
3304
3305    aSig = extractFloatx80Frac( a );
3306    aExp = extractFloatx80Exp( a );
3307    aSign = extractFloatx80Sign( a );
3308    if ( ( aExp == 0x7FFF ) && (bits64) ( aSig<<1 ) ) {
3309        return commonNaNToFloat128( floatx80ToCommonNaN( a ) );
3310    }
3311    shift128Right( aSig<<1, 0, 16, &zSig0, &zSig1 );
3312    return packFloat128( aSign, aExp, zSig0, zSig1 );
3313
3314}
3315
3316#endif
3317
3318/*----------------------------------------------------------------------------
3319| Rounds the extended double-precision floating-point value `a' to an integer,
3320| and returns the result as an extended quadruple-precision floating-point
3321| value.  The operation is performed according to the IEC/IEEE Standard for
3322| Binary Floating-Point Arithmetic.
3323*----------------------------------------------------------------------------*/
3324
3325floatx80 floatx80_round_to_int( floatx80 a )
3326{
3327    flag aSign;
3328    int32 aExp;
3329    bits64 lastBitMask, roundBitsMask;
3330    int8 roundingMode;
3331    floatx80 z;
3332
3333    aExp = extractFloatx80Exp( a );
3334    if ( 0x403E <= aExp ) {
3335        if ( ( aExp == 0x7FFF ) && (bits64) ( extractFloatx80Frac( a )<<1 ) ) {
3336            return propagateFloatx80NaN( a, a );
3337        }
3338        return a;
3339    }
3340    if ( aExp < 0x3FFF ) {
3341        if (    ( aExp == 0 )
3342             && ( (bits64) ( extractFloatx80Frac( a )<<1 ) == 0 ) ) {
3343            return a;
3344        }
3345        float_exception_flags |= float_flag_inexact;
3346        aSign = extractFloatx80Sign( a );
3347        switch ( float_rounding_mode ) {
3348         case float_round_nearest_even:
3349            if ( ( aExp == 0x3FFE ) && (bits64) ( extractFloatx80Frac( a )<<1 )
3350               ) {
3351                return
3352                    packFloatx80( aSign, 0x3FFF, LIT64( 0x8000000000000000 ) );
3353            }
3354            break;
3355         case float_round_down:
3356            return
3357                  aSign ?
3358                      packFloatx80( 1, 0x3FFF, LIT64( 0x8000000000000000 ) )
3359                : packFloatx80( 0, 0, 0 );
3360         case float_round_up:
3361            return
3362                  aSign ? packFloatx80( 1, 0, 0 )
3363                : packFloatx80( 0, 0x3FFF, LIT64( 0x8000000000000000 ) );
3364        }
3365        return packFloatx80( aSign, 0, 0 );
3366    }
3367    lastBitMask = 1;
3368    lastBitMask <<= 0x403E - aExp;
3369    roundBitsMask = lastBitMask - 1;
3370    z = a;
3371    roundingMode = float_rounding_mode;
3372    if ( roundingMode == float_round_nearest_even ) {
3373        z.low += lastBitMask>>1;
3374        if ( ( z.low & roundBitsMask ) == 0 ) z.low &= ~ lastBitMask;
3375    }
3376    else if ( roundingMode != float_round_to_zero ) {
3377        if ( extractFloatx80Sign( z ) ^ ( roundingMode == float_round_up ) ) {
3378            z.low += roundBitsMask;
3379        }
3380    }
3381    z.low &= ~ roundBitsMask;
3382    if ( z.low == 0 ) {
3383        ++z.high;
3384        z.low = LIT64( 0x8000000000000000 );
3385    }
3386    if ( z.low != a.low ) float_exception_flags |= float_flag_inexact;
3387    return z;
3388
3389}
3390
3391/*----------------------------------------------------------------------------
3392| Returns the result of adding the absolute values of the extended double-
3393| precision floating-point values `a' and `b'.  If `zSign' is 1, the sum is
3394| negated before being returned.  `zSign' is ignored if the result is a NaN.
3395| The addition is performed according to the IEC/IEEE Standard for Binary
3396| Floating-Point Arithmetic.
3397*----------------------------------------------------------------------------*/
3398
3399static floatx80 addFloatx80Sigs( floatx80 a, floatx80 b, flag zSign )
3400{
3401    int32 aExp, bExp, zExp;
3402    bits64 aSig, bSig, zSig0, zSig1;
3403    int32 expDiff;
3404
3405    aSig = extractFloatx80Frac( a );
3406    aExp = extractFloatx80Exp( a );
3407    bSig = extractFloatx80Frac( b );
3408    bExp = extractFloatx80Exp( b );
3409    expDiff = aExp - bExp;
3410    if ( 0 < expDiff ) {
3411        if ( aExp == 0x7FFF ) {
3412            if ( (bits64) ( aSig<<1 ) ) return propagateFloatx80NaN( a, b );
3413            return a;
3414        }
3415        if ( bExp == 0 ) --expDiff;
3416        shift64ExtraRightJamming( bSig, 0, expDiff, &bSig, &zSig1 );
3417        zExp = aExp;
3418    }
3419    else if ( expDiff < 0 ) {
3420        if ( bExp == 0x7FFF ) {
3421            if ( (bits64) ( bSig<<1 ) ) return propagateFloatx80NaN( a, b );
3422            return packFloatx80( zSign, 0x7FFF, LIT64( 0x8000000000000000 ) );
3423        }
3424        if ( aExp == 0 ) ++expDiff;
3425        shift64ExtraRightJamming( aSig, 0, - expDiff, &aSig, &zSig1 );
3426        zExp = bExp;
3427    }
3428    else {
3429        if ( aExp == 0x7FFF ) {
3430            if ( (bits64) ( ( aSig | bSig )<<1 ) ) {
3431                return propagateFloatx80NaN( a, b );
3432            }
3433            return a;
3434        }
3435        zSig1 = 0;
3436        zSig0 = aSig + bSig;
3437        if ( aExp == 0 ) {
3438            normalizeFloatx80Subnormal( zSig0, &zExp, &zSig0 );
3439            goto roundAndPack;
3440        }
3441        zExp = aExp;
3442        goto shiftRight1;
3443    }
3444    zSig0 = aSig + bSig;
3445    if ( (sbits64) zSig0 < 0 ) goto roundAndPack;
3446 shiftRight1:
3447    shift64ExtraRightJamming( zSig0, zSig1, 1, &zSig0, &zSig1 );
3448    zSig0 |= LIT64( 0x8000000000000000 );
3449    ++zExp;
3450 roundAndPack:
3451    return
3452        roundAndPackFloatx80(
3453            floatx80_rounding_precision, zSign, zExp, zSig0, zSig1 );
3454
3455}
3456
3457/*----------------------------------------------------------------------------
3458| Returns the result of subtracting the absolute values of the extended
3459| double-precision floating-point values `a' and `b'.  If `zSign' is 1, the
3460| difference is negated before being returned.  `zSign' is ignored if the
3461| result is a NaN.  The subtraction is performed according to the IEC/IEEE
3462| Standard for Binary Floating-Point Arithmetic.
3463*----------------------------------------------------------------------------*/
3464
3465static floatx80 subFloatx80Sigs( floatx80 a, floatx80 b, flag zSign )
3466{
3467    int32 aExp, bExp, zExp;
3468    bits64 aSig, bSig, zSig0, zSig1;
3469    int32 expDiff;
3470    floatx80 z;
3471
3472    aSig = extractFloatx80Frac( a );
3473    aExp = extractFloatx80Exp( a );
3474    bSig = extractFloatx80Frac( b );
3475    bExp = extractFloatx80Exp( b );
3476    expDiff = aExp - bExp;
3477    if ( 0 < expDiff ) goto aExpBigger;
3478    if ( expDiff < 0 ) goto bExpBigger;
3479    if ( aExp == 0x7FFF ) {
3480        if ( (bits64) ( ( aSig | bSig )<<1 ) ) {
3481            return propagateFloatx80NaN( a, b );
3482        }
3483        float_raise( float_flag_invalid );
3484        z.low = floatx80_default_nan_low;
3485        z.high = floatx80_default_nan_high;
3486        return z;
3487    }
3488    if ( aExp == 0 ) {
3489        aExp = 1;
3490        bExp = 1;
3491    }
3492    zSig1 = 0;
3493    if ( bSig < aSig ) goto aBigger;
3494    if ( aSig < bSig ) goto bBigger;
3495    return packFloatx80( float_rounding_mode == float_round_down, 0, 0 );
3496 bExpBigger:
3497    if ( bExp == 0x7FFF ) {
3498        if ( (bits64) ( bSig<<1 ) ) return propagateFloatx80NaN( a, b );
3499        return packFloatx80( zSign ^ 1, 0x7FFF, LIT64( 0x8000000000000000 ) );
3500    }
3501    if ( aExp == 0 ) ++expDiff;
3502    shift128RightJamming( aSig, 0, - expDiff, &aSig, &zSig1 );
3503 bBigger:
3504    sub128( bSig, 0, aSig, zSig1, &zSig0, &zSig1 );
3505    zExp = bExp;
3506    zSign ^= 1;
3507    goto normalizeRoundAndPack;
3508 aExpBigger:
3509    if ( aExp == 0x7FFF ) {
3510        if ( (bits64) ( aSig<<1 ) ) return propagateFloatx80NaN( a, b );
3511        return a;
3512    }
3513    if ( bExp == 0 ) --expDiff;
3514    shift128RightJamming( bSig, 0, expDiff, &bSig, &zSig1 );
3515 aBigger:
3516    sub128( aSig, 0, bSig, zSig1, &zSig0, &zSig1 );
3517    zExp = aExp;
3518 normalizeRoundAndPack:
3519    return
3520        normalizeRoundAndPackFloatx80(
3521            floatx80_rounding_precision, zSign, zExp, zSig0, zSig1 );
3522
3523}
3524
3525/*----------------------------------------------------------------------------
3526| Returns the result of adding the extended double-precision floating-point
3527| values `a' and `b'.  The operation is performed according to the IEC/IEEE
3528| Standard for Binary Floating-Point Arithmetic.
3529*----------------------------------------------------------------------------*/
3530
3531floatx80 floatx80_add( floatx80 a, floatx80 b )
3532{
3533    flag aSign, bSign;
3534
3535    aSign = extractFloatx80Sign( a );
3536    bSign = extractFloatx80Sign( b );
3537    if ( aSign == bSign ) {
3538        return addFloatx80Sigs( a, b, aSign );
3539    }
3540    else {
3541        return subFloatx80Sigs( a, b, aSign );
3542    }
3543
3544}
3545
3546/*----------------------------------------------------------------------------
3547| Returns the result of subtracting the extended double-precision floating-
3548| point values `a' and `b'.  The operation is performed according to the
3549| IEC/IEEE Standard for Binary Floating-Point Arithmetic.
3550*----------------------------------------------------------------------------*/
3551
3552floatx80 floatx80_sub( floatx80 a, floatx80 b )
3553{
3554    flag aSign, bSign;
3555
3556    aSign = extractFloatx80Sign( a );
3557    bSign = extractFloatx80Sign( b );
3558    if ( aSign == bSign ) {
3559        return subFloatx80Sigs( a, b, aSign );
3560    }
3561    else {
3562        return addFloatx80Sigs( a, b, aSign );
3563    }
3564
3565}
3566
3567/*----------------------------------------------------------------------------
3568| Returns the result of multiplying the extended double-precision floating-
3569| point values `a' and `b'.  The operation is performed according to the
3570| IEC/IEEE Standard for Binary Floating-Point Arithmetic.
3571*----------------------------------------------------------------------------*/
3572
3573floatx80 floatx80_mul( floatx80 a, floatx80 b )
3574{
3575    flag aSign, bSign, zSign;
3576    int32 aExp, bExp, zExp;
3577    bits64 aSig, bSig, zSig0, zSig1;
3578    floatx80 z;
3579
3580    aSig = extractFloatx80Frac( a );
3581    aExp = extractFloatx80Exp( a );
3582    aSign = extractFloatx80Sign( a );
3583    bSig = extractFloatx80Frac( b );
3584    bExp = extractFloatx80Exp( b );
3585    bSign = extractFloatx80Sign( b );
3586    zSign = aSign ^ bSign;
3587    if ( aExp == 0x7FFF ) {
3588        if (    (bits64) ( aSig<<1 )
3589             || ( ( bExp == 0x7FFF ) && (bits64) ( bSig<<1 ) ) ) {
3590            return propagateFloatx80NaN( a, b );
3591        }
3592        if ( ( bExp | bSig ) == 0 ) goto invalid;
3593        return packFloatx80( zSign, 0x7FFF, LIT64( 0x8000000000000000 ) );
3594    }
3595    if ( bExp == 0x7FFF ) {
3596        if ( (bits64) ( bSig<<1 ) ) return propagateFloatx80NaN( a, b );
3597        if ( ( aExp | aSig ) == 0 ) {
3598 invalid:
3599            float_raise( float_flag_invalid );
3600            z.low = floatx80_default_nan_low;
3601            z.high = floatx80_default_nan_high;
3602            return z;
3603        }
3604        return packFloatx80( zSign, 0x7FFF, LIT64( 0x8000000000000000 ) );
3605    }
3606    if ( aExp == 0 ) {
3607        if ( aSig == 0 ) return packFloatx80( zSign, 0, 0 );
3608        normalizeFloatx80Subnormal( aSig, &aExp, &aSig );
3609    }
3610    if ( bExp == 0 ) {
3611        if ( bSig == 0 ) return packFloatx80( zSign, 0, 0 );
3612        normalizeFloatx80Subnormal( bSig, &bExp, &bSig );
3613    }
3614    zExp = aExp + bExp - 0x3FFE;
3615    mul64To128( aSig, bSig, &zSig0, &zSig1 );
3616    if ( 0 < (sbits64) zSig0 ) {
3617        shortShift128Left( zSig0, zSig1, 1, &zSig0, &zSig1 );
3618        --zExp;
3619    }
3620    return
3621        roundAndPackFloatx80(
3622            floatx80_rounding_precision, zSign, zExp, zSig0, zSig1 );
3623
3624}
3625
3626/*----------------------------------------------------------------------------
3627| Returns the result of dividing the extended double-precision floating-point
3628| value `a' by the corresponding value `b'.  The operation is performed
3629| according to the IEC/IEEE Standard for Binary Floating-Point Arithmetic.
3630*----------------------------------------------------------------------------*/
3631
3632floatx80 floatx80_div( floatx80 a, floatx80 b )
3633{
3634    flag aSign, bSign, zSign;
3635    int32 aExp, bExp, zExp;
3636    bits64 aSig, bSig, zSig0, zSig1;
3637    bits64 rem0, rem1, rem2, term0, term1, term2;
3638    floatx80 z;
3639
3640    aSig = extractFloatx80Frac( a );
3641    aExp = extractFloatx80Exp( a );
3642    aSign = extractFloatx80Sign( a );
3643    bSig = extractFloatx80Frac( b );
3644    bExp = extractFloatx80Exp( b );
3645    bSign = extractFloatx80Sign( b );
3646    zSign = aSign ^ bSign;
3647    if ( aExp == 0x7FFF ) {
3648        if ( (bits64) ( aSig<<1 ) ) return propagateFloatx80NaN( a, b );
3649        if ( bExp == 0x7FFF ) {
3650            if ( (bits64) ( bSig<<1 ) ) return propagateFloatx80NaN( a, b );
3651            goto invalid;
3652        }
3653        return packFloatx80( zSign, 0x7FFF, LIT64( 0x8000000000000000 ) );
3654    }
3655    if ( bExp == 0x7FFF ) {
3656        if ( (bits64) ( bSig<<1 ) ) return propagateFloatx80NaN( a, b );
3657        return packFloatx80( zSign, 0, 0 );
3658    }
3659    if ( bExp == 0 ) {
3660        if ( bSig == 0 ) {
3661            if ( ( aExp | aSig ) == 0 ) {
3662 invalid:
3663                float_raise( float_flag_invalid );
3664                z.low = floatx80_default_nan_low;
3665                z.high = floatx80_default_nan_high;
3666                return z;
3667            }
3668            float_raise( float_flag_divbyzero );
3669            return packFloatx80( zSign, 0x7FFF, LIT64( 0x8000000000000000 ) );
3670        }
3671        normalizeFloatx80Subnormal( bSig, &bExp, &bSig );
3672    }
3673    if ( aExp == 0 ) {
3674        if ( aSig == 0 ) return packFloatx80( zSign, 0, 0 );
3675        normalizeFloatx80Subnormal( aSig, &aExp, &aSig );
3676    }
3677    zExp = aExp - bExp + 0x3FFE;
3678    rem1 = 0;
3679    if ( bSig <= aSig ) {
3680        shift128Right( aSig, 0, 1, &aSig, &rem1 );
3681        ++zExp;
3682    }
3683    zSig0 = estimateDiv128To64( aSig, rem1, bSig );
3684    mul64To128( bSig, zSig0, &term0, &term1 );
3685    sub128( aSig, rem1, term0, term1, &rem0, &rem1 );
3686    while ( (sbits64) rem0 < 0 ) {
3687        --zSig0;
3688        add128( rem0, rem1, 0, bSig, &rem0, &rem1 );
3689    }
3690    zSig1 = estimateDiv128To64( rem1, 0, bSig );
3691    if ( (bits64) ( zSig1<<1 ) <= 8 ) {
3692        mul64To128( bSig, zSig1, &term1, &term2 );
3693        sub128( rem1, 0, term1, term2, &rem1, &rem2 );
3694        while ( (sbits64) rem1 < 0 ) {
3695            --zSig1;
3696            add128( rem1, rem2, 0, bSig, &rem1, &rem2 );
3697        }
3698        zSig1 |= ( ( rem1 | rem2 ) != 0 );
3699    }
3700    return
3701        roundAndPackFloatx80(
3702            floatx80_rounding_precision, zSign, zExp, zSig0, zSig1 );
3703
3704}
3705
3706/*----------------------------------------------------------------------------
3707| Returns the remainder of the extended double-precision floating-point value
3708| `a' with respect to the corresponding value `b'.  The operation is performed
3709| according to the IEC/IEEE Standard for Binary Floating-Point Arithmetic.
3710*----------------------------------------------------------------------------*/
3711
3712floatx80 floatx80_rem( floatx80 a, floatx80 b )
3713{
3714    flag aSign, bSign, zSign;
3715    int32 aExp, bExp, expDiff;
3716    bits64 aSig0, aSig1, bSig;
3717    bits64 q, term0, term1, alternateASig0, alternateASig1;
3718    floatx80 z;
3719
3720    aSig0 = extractFloatx80Frac( a );
3721    aExp = extractFloatx80Exp( a );
3722    aSign = extractFloatx80Sign( a );
3723    bSig = extractFloatx80Frac( b );
3724    bExp = extractFloatx80Exp( b );
3725    bSign = extractFloatx80Sign( b );
3726    if ( aExp == 0x7FFF ) {
3727        if (    (bits64) ( aSig0<<1 )
3728             || ( ( bExp == 0x7FFF ) && (bits64) ( bSig<<1 ) ) ) {
3729            return propagateFloatx80NaN( a, b );
3730        }
3731        goto invalid;
3732    }
3733    if ( bExp == 0x7FFF ) {
3734        if ( (bits64) ( bSig<<1 ) ) return propagateFloatx80NaN( a, b );
3735        return a;
3736    }
3737    if ( bExp == 0 ) {
3738        if ( bSig == 0 ) {
3739 invalid:
3740            float_raise( float_flag_invalid );
3741            z.low = floatx80_default_nan_low;
3742            z.high = floatx80_default_nan_high;
3743            return z;
3744        }
3745        normalizeFloatx80Subnormal( bSig, &bExp, &bSig );
3746    }
3747    if ( aExp == 0 ) {
3748        if ( (bits64) ( aSig0<<1 ) == 0 ) return a;
3749        normalizeFloatx80Subnormal( aSig0, &aExp, &aSig0 );
3750    }
3751    bSig |= LIT64( 0x8000000000000000 );
3752    zSign = aSign;
3753    expDiff = aExp - bExp;
3754    aSig1 = 0;
3755    if ( expDiff < 0 ) {
3756        if ( expDiff < -1 ) return a;
3757        shift128Right( aSig0, 0, 1, &aSig0, &aSig1 );
3758        expDiff = 0;
3759    }
3760    q = ( bSig <= aSig0 );
3761    if ( q ) aSig0 -= bSig;
3762    expDiff -= 64;
3763    while ( 0 < expDiff ) {
3764        q = estimateDiv128To64( aSig0, aSig1, bSig );
3765        q = ( 2 < q ) ? q - 2 : 0;
3766        mul64To128( bSig, q, &term0, &term1 );
3767        sub128( aSig0, aSig1, term0, term1, &aSig0, &aSig1 );
3768        shortShift128Left( aSig0, aSig1, 62, &aSig0, &aSig1 );
3769        expDiff -= 62;
3770    }
3771    expDiff += 64;
3772    if ( 0 < expDiff ) {
3773        q = estimateDiv128To64( aSig0, aSig1, bSig );
3774        q = ( 2 < q ) ? q - 2 : 0;
3775        q >>= 64 - expDiff;
3776        mul64To128( bSig, q<<( 64 - expDiff ), &term0, &term1 );
3777        sub128( aSig0, aSig1, term0, term1, &aSig0, &aSig1 );
3778        shortShift128Left( 0, bSig, 64 - expDiff, &term0, &term1 );
3779        while ( le128( term0, term1, aSig0, aSig1 ) ) {
3780            ++q;
3781            sub128( aSig0, aSig1, term0, term1, &aSig0, &aSig1 );
3782        }
3783    }
3784    else {
3785        term1 = 0;
3786        term0 = bSig;
3787    }
3788    sub128( term0, term1, aSig0, aSig1, &alternateASig0, &alternateASig1 );
3789    if (    lt128( alternateASig0, alternateASig1, aSig0, aSig1 )
3790         || (    eq128( alternateASig0, alternateASig1, aSig0, aSig1 )
3791              && ( q & 1 ) )
3792       ) {
3793        aSig0 = alternateASig0;
3794        aSig1 = alternateASig1;
3795        zSign = ! zSign;
3796    }
3797    return
3798        normalizeRoundAndPackFloatx80(
3799            80, zSign, bExp + expDiff, aSig0, aSig1 );
3800
3801}
3802
3803/*----------------------------------------------------------------------------
3804| Returns the square root of the extended double-precision floating-point
3805| value `a'.  The operation is performed according to the IEC/IEEE Standard
3806| for Binary Floating-Point Arithmetic.
3807*----------------------------------------------------------------------------*/
3808
3809floatx80 floatx80_sqrt( floatx80 a )
3810{
3811    flag aSign;
3812    int32 aExp, zExp;
3813    bits64 aSig0, aSig1, zSig0, zSig1, doubleZSig0;
3814    bits64 rem0, rem1, rem2, rem3, term0, term1, term2, term3;
3815    floatx80 z;
3816
3817    aSig0 = extractFloatx80Frac( a );
3818    aExp = extractFloatx80Exp( a );
3819    aSign = extractFloatx80Sign( a );
3820    if ( aExp == 0x7FFF ) {
3821        if ( (bits64) ( aSig0<<1 ) ) return propagateFloatx80NaN( a, a );
3822        if ( ! aSign ) return a;
3823        goto invalid;
3824    }
3825    if ( aSign ) {
3826        if ( ( aExp | aSig0 ) == 0 ) return a;
3827 invalid:
3828        float_raise( float_flag_invalid );
3829        z.low = floatx80_default_nan_low;
3830        z.high = floatx80_default_nan_high;
3831        return z;
3832    }
3833    if ( aExp == 0 ) {
3834        if ( aSig0 == 0 ) return packFloatx80( 0, 0, 0 );
3835        normalizeFloatx80Subnormal( aSig0, &aExp, &aSig0 );
3836    }
3837    zExp = ( ( aExp - 0x3FFF )>>1 ) + 0x3FFF;
3838    zSig0 = estimateSqrt32( aExp, aSig0>>32 );
3839    shift128Right( aSig0, 0, 2 + ( aExp & 1 ), &aSig0, &aSig1 );
3840    zSig0 = estimateDiv128To64( aSig0, aSig1, zSig0<<32 ) + ( zSig0<<30 );
3841    doubleZSig0 = zSig0<<1;
3842    mul64To128( zSig0, zSig0, &term0, &term1 );
3843    sub128( aSig0, aSig1, term0, term1, &rem0, &rem1 );
3844    while ( (sbits64) rem0 < 0 ) {
3845        --zSig0;
3846        doubleZSig0 -= 2;
3847        add128( rem0, rem1, zSig0>>63, doubleZSig0 | 1, &rem0, &rem1 );
3848    }
3849    zSig1 = estimateDiv128To64( rem1, 0, doubleZSig0 );
3850    if ( ( zSig1 & LIT64( 0x3FFFFFFFFFFFFFFF ) ) <= 5 ) {
3851        if ( zSig1 == 0 ) zSig1 = 1;
3852        mul64To128( doubleZSig0, zSig1, &term1, &term2 );
3853        sub128( rem1, 0, term1, term2, &rem1, &rem2 );
3854        mul64To128( zSig1, zSig1, &term2, &term3 );
3855        sub192( rem1, rem2, 0, 0, term2, term3, &rem1, &rem2, &rem3 );
3856        while ( (sbits64) rem1 < 0 ) {
3857            --zSig1;
3858            shortShift128Left( 0, zSig1, 1, &term2, &term3 );
3859            term3 |= 1;
3860            term2 |= doubleZSig0;
3861            add192( rem1, rem2, rem3, 0, term2, term3, &rem1, &rem2, &rem3 );
3862        }
3863        zSig1 |= ( ( rem1 | rem2 | rem3 ) != 0 );
3864    }
3865    shortShift128Left( 0, zSig1, 1, &zSig0, &zSig1 );
3866    zSig0 |= doubleZSig0;
3867    return
3868        roundAndPackFloatx80(
3869            floatx80_rounding_precision, 0, zExp, zSig0, zSig1 );
3870
3871}
3872
3873/*----------------------------------------------------------------------------
3874| Returns 1 if the extended double-precision floating-point value `a' is
3875| equal to the corresponding value `b', and 0 otherwise.  The comparison is
3876| performed according to the IEC/IEEE Standard for Binary Floating-Point
3877| Arithmetic.
3878*----------------------------------------------------------------------------*/
3879
3880flag floatx80_eq( floatx80 a, floatx80 b )
3881{
3882
3883    if (    (    ( extractFloatx80Exp( a ) == 0x7FFF )
3884              && (bits64) ( extractFloatx80Frac( a )<<1 ) )
3885         || (    ( extractFloatx80Exp( b ) == 0x7FFF )
3886              && (bits64) ( extractFloatx80Frac( b )<<1 ) )
3887       ) {
3888        if (    floatx80_is_signaling_nan( a )
3889             || floatx80_is_signaling_nan( b ) ) {
3890            float_raise( float_flag_invalid );
3891        }
3892        return 0;
3893    }
3894    return
3895           ( a.low == b.low )
3896        && (    ( a.high == b.high )
3897             || (    ( a.low == 0 )
3898                  && ( (bits16) ( ( a.high | b.high )<<1 ) == 0 ) )
3899           );
3900
3901}
3902
3903/*----------------------------------------------------------------------------
3904| Returns 1 if the extended double-precision floating-point value `a' is
3905| less than or equal to the corresponding value `b', and 0 otherwise.  The
3906| comparison is performed according to the IEC/IEEE Standard for Binary
3907| Floating-Point Arithmetic.
3908*----------------------------------------------------------------------------*/
3909
3910flag floatx80_le( floatx80 a, floatx80 b )
3911{
3912    flag aSign, bSign;
3913
3914    if (    (    ( extractFloatx80Exp( a ) == 0x7FFF )
3915              && (bits64) ( extractFloatx80Frac( a )<<1 ) )
3916         || (    ( extractFloatx80Exp( b ) == 0x7FFF )
3917              && (bits64) ( extractFloatx80Frac( b )<<1 ) )
3918       ) {
3919        float_raise( float_flag_invalid );
3920        return 0;
3921    }
3922    aSign = extractFloatx80Sign( a );
3923    bSign = extractFloatx80Sign( b );
3924    if ( aSign != bSign ) {
3925        return
3926               aSign
3927            || (    ( ( (bits16) ( ( a.high | b.high )<<1 ) ) | a.low | b.low )
3928                 == 0 );
3929    }
3930    return
3931          aSign ? le128( b.high, b.low, a.high, a.low )
3932        : le128( a.high, a.low, b.high, b.low );
3933
3934}
3935
3936/*----------------------------------------------------------------------------
3937| Returns 1 if the extended double-precision floating-point value `a' is
3938| less than the corresponding value `b', and 0 otherwise.  The comparison
3939| is performed according to the IEC/IEEE Standard for Binary Floating-Point
3940| Arithmetic.
3941*----------------------------------------------------------------------------*/
3942
3943flag floatx80_lt( floatx80 a, floatx80 b )
3944{
3945    flag aSign, bSign;
3946
3947    if (    (    ( extractFloatx80Exp( a ) == 0x7FFF )
3948              && (bits64) ( extractFloatx80Frac( a )<<1 ) )
3949         || (    ( extractFloatx80Exp( b ) == 0x7FFF )
3950              && (bits64) ( extractFloatx80Frac( b )<<1 ) )
3951       ) {
3952        float_raise( float_flag_invalid );
3953        return 0;
3954    }
3955    aSign = extractFloatx80Sign( a );
3956    bSign = extractFloatx80Sign( b );
3957    if ( aSign != bSign ) {
3958        return
3959               aSign
3960            && (    ( ( (bits16) ( ( a.high | b.high )<<1 ) ) | a.low | b.low )
3961                 != 0 );
3962    }
3963    return
3964          aSign ? lt128( b.high, b.low, a.high, a.low )
3965        : lt128( a.high, a.low, b.high, b.low );
3966
3967}
3968
3969/*----------------------------------------------------------------------------
3970| Returns 1 if the extended double-precision floating-point value `a' is equal
3971| to the corresponding value `b', and 0 otherwise.  The invalid exception is
3972| raised if either operand is a NaN.  Otherwise, the comparison is performed
3973| according to the IEC/IEEE Standard for Binary Floating-Point Arithmetic.
3974*----------------------------------------------------------------------------*/
3975
3976flag floatx80_eq_signaling( floatx80 a, floatx80 b )
3977{
3978
3979    if (    (    ( extractFloatx80Exp( a ) == 0x7FFF )
3980              && (bits64) ( extractFloatx80Frac( a )<<1 ) )
3981         || (    ( extractFloatx80Exp( b ) == 0x7FFF )
3982              && (bits64) ( extractFloatx80Frac( b )<<1 ) )
3983       ) {
3984        float_raise( float_flag_invalid );
3985        return 0;
3986    }
3987    return
3988           ( a.low == b.low )
3989        && (    ( a.high == b.high )
3990             || (    ( a.low == 0 )
3991                  && ( (bits16) ( ( a.high | b.high )<<1 ) == 0 ) )
3992           );
3993
3994}
3995
3996/*----------------------------------------------------------------------------
3997| Returns 1 if the extended double-precision floating-point value `a' is less
3998| than or equal to the corresponding value `b', and 0 otherwise.  Quiet NaNs
3999| do not cause an exception.  Otherwise, the comparison is performed according
4000| to the IEC/IEEE Standard for Binary Floating-Point Arithmetic.
4001*----------------------------------------------------------------------------*/
4002
4003flag floatx80_le_quiet( floatx80 a, floatx80 b )
4004{
4005    flag aSign, bSign;
4006
4007    if (    (    ( extractFloatx80Exp( a ) == 0x7FFF )
4008              && (bits64) ( extractFloatx80Frac( a )<<1 ) )
4009         || (    ( extractFloatx80Exp( b ) == 0x7FFF )
4010              && (bits64) ( extractFloatx80Frac( b )<<1 ) )
4011       ) {
4012        if (    floatx80_is_signaling_nan( a )
4013             || floatx80_is_signaling_nan( b ) ) {
4014            float_raise( float_flag_invalid );
4015        }
4016        return 0;
4017    }
4018    aSign = extractFloatx80Sign( a );
4019    bSign = extractFloatx80Sign( b );
4020    if ( aSign != bSign ) {
4021        return
4022               aSign
4023            || (    ( ( (bits16) ( ( a.high | b.high )<<1 ) ) | a.low | b.low )
4024                 == 0 );
4025    }
4026    return
4027          aSign ? le128( b.high, b.low, a.high, a.low )
4028        : le128( a.high, a.low, b.high, b.low );
4029
4030}
4031
4032/*----------------------------------------------------------------------------
4033| Returns 1 if the extended double-precision floating-point value `a' is less
4034| than the corresponding value `b', and 0 otherwise.  Quiet NaNs do not cause
4035| an exception.  Otherwise, the comparison is performed according to the
4036| IEC/IEEE Standard for Binary Floating-Point Arithmetic.
4037*----------------------------------------------------------------------------*/
4038
4039flag floatx80_lt_quiet( floatx80 a, floatx80 b )
4040{
4041    flag aSign, bSign;
4042
4043    if (    (    ( extractFloatx80Exp( a ) == 0x7FFF )
4044              && (bits64) ( extractFloatx80Frac( a )<<1 ) )
4045         || (    ( extractFloatx80Exp( b ) == 0x7FFF )
4046              && (bits64) ( extractFloatx80Frac( b )<<1 ) )
4047       ) {
4048        if (    floatx80_is_signaling_nan( a )
4049             || floatx80_is_signaling_nan( b ) ) {
4050            float_raise( float_flag_invalid );
4051        }
4052        return 0;
4053    }
4054    aSign = extractFloatx80Sign( a );
4055    bSign = extractFloatx80Sign( b );
4056    if ( aSign != bSign ) {
4057        return
4058               aSign
4059            && (    ( ( (bits16) ( ( a.high | b.high )<<1 ) ) | a.low | b.low )
4060                 != 0 );
4061    }
4062    return
4063          aSign ? lt128( b.high, b.low, a.high, a.low )
4064        : lt128( a.high, a.low, b.high, b.low );
4065
4066}
4067
4068#endif
4069
4070#ifdef FLOAT128
4071
4072/*----------------------------------------------------------------------------
4073| Returns the result of converting the quadruple-precision floating-point
4074| value `a' to the 32-bit two's complement integer format.  The conversion
4075| is performed according to the IEC/IEEE Standard for Binary Floating-Point
4076| Arithmetic---which means in particular that the conversion is rounded
4077| according to the current rounding mode.  If `a' is a NaN, the largest
4078| positive integer is returned.  Otherwise, if the conversion overflows, the
4079| largest integer with the same sign as `a' is returned.
4080*----------------------------------------------------------------------------*/
4081
4082int32 float128_to_int32( float128 a )
4083{
4084    flag aSign;
4085    int32 aExp, shiftCount;
4086    bits64 aSig0, aSig1;
4087
4088    aSig1 = extractFloat128Frac1( a );
4089    aSig0 = extractFloat128Frac0( a );
4090    aExp = extractFloat128Exp( a );
4091    aSign = extractFloat128Sign( a );
4092    if ( ( aExp == 0x7FFF ) && ( aSig0 | aSig1 ) ) aSign = 0;
4093    if ( aExp ) aSig0 |= LIT64( 0x0001000000000000 );
4094    aSig0 |= ( aSig1 != 0 );
4095    shiftCount = 0x4028 - aExp;
4096    if ( 0 < shiftCount ) shift64RightJamming( aSig0, shiftCount, &aSig0 );
4097    return roundAndPackInt32( aSign, aSig0 );
4098
4099}
4100
4101/*----------------------------------------------------------------------------
4102| Returns the result of converting the quadruple-precision floating-point
4103| value `a' to the 32-bit two's complement integer format.  The conversion
4104| is performed according to the IEC/IEEE Standard for Binary Floating-Point
4105| Arithmetic, except that the conversion is always rounded toward zero.  If
4106| `a' is a NaN, the largest positive integer is returned.  Otherwise, if the
4107| conversion overflows, the largest integer with the same sign as `a' is
4108| returned.
4109*----------------------------------------------------------------------------*/
4110
4111int32 float128_to_int32_round_to_zero( float128 a )
4112{
4113    flag aSign;
4114    int32 aExp, shiftCount;
4115    bits64 aSig0, aSig1, savedASig;
4116    int32 z;
4117
4118    aSig1 = extractFloat128Frac1( a );
4119    aSig0 = extractFloat128Frac0( a );
4120    aExp = extractFloat128Exp( a );
4121    aSign = extractFloat128Sign( a );
4122    aSig0 |= ( aSig1 != 0 );
4123    if ( 0x401E < aExp ) {
4124        if ( ( aExp == 0x7FFF ) && aSig0 ) aSign = 0;
4125        goto invalid;
4126    }
4127    else if ( aExp < 0x3FFF ) {
4128        if ( aExp || aSig0 ) float_exception_flags |= float_flag_inexact;
4129        return 0;
4130    }
4131    aSig0 |= LIT64( 0x0001000000000000 );
4132    shiftCount = 0x402F - aExp;
4133    savedASig = aSig0;
4134    aSig0 >>= shiftCount;
4135    z = aSig0;
4136    if ( aSign ) z = - z;
4137    if ( ( z < 0 ) ^ aSign ) {
4138 invalid:
4139        float_raise( float_flag_invalid );
4140        return aSign ? (sbits32) 0x80000000 : 0x7FFFFFFF;
4141    }
4142    if ( ( aSig0<<shiftCount ) != savedASig ) {
4143        float_exception_flags |= float_flag_inexact;
4144    }
4145    return z;
4146
4147}
4148
4149/*----------------------------------------------------------------------------
4150| Returns the result of converting the quadruple-precision floating-point
4151| value `a' to the 64-bit two's complement integer format.  The conversion
4152| is performed according to the IEC/IEEE Standard for Binary Floating-Point
4153| Arithmetic---which means in particular that the conversion is rounded
4154| according to the current rounding mode.  If `a' is a NaN, the largest
4155| positive integer is returned.  Otherwise, if the conversion overflows, the
4156| largest integer with the same sign as `a' is returned.
4157*----------------------------------------------------------------------------*/
4158
4159int64 float128_to_int64( float128 a )
4160{
4161    flag aSign;
4162    int32 aExp, shiftCount;
4163    bits64 aSig0, aSig1;
4164
4165    aSig1 = extractFloat128Frac1( a );
4166    aSig0 = extractFloat128Frac0( a );
4167    aExp = extractFloat128Exp( a );
4168    aSign = extractFloat128Sign( a );
4169    if ( aExp ) aSig0 |= LIT64( 0x0001000000000000 );
4170    shiftCount = 0x402F - aExp;
4171    if ( shiftCount <= 0 ) {
4172        if ( 0x403E < aExp ) {
4173            float_raise( float_flag_invalid );
4174            if (    ! aSign
4175                 || (    ( aExp == 0x7FFF )
4176                      && ( aSig1 || ( aSig0 != LIT64( 0x0001000000000000 ) ) )
4177                    )
4178               ) {
4179                return LIT64( 0x7FFFFFFFFFFFFFFF );
4180            }
4181            return (sbits64) LIT64( 0x8000000000000000 );
4182        }
4183        shortShift128Left( aSig0, aSig1, - shiftCount, &aSig0, &aSig1 );
4184    }
4185    else {
4186        shift64ExtraRightJamming( aSig0, aSig1, shiftCount, &aSig0, &aSig1 );
4187    }
4188    return roundAndPackInt64( aSign, aSig0, aSig1 );
4189
4190}
4191
4192/*----------------------------------------------------------------------------
4193| Returns the result of converting the quadruple-precision floating-point
4194| value `a' to the 64-bit two's complement integer format.  The conversion
4195| is performed according to the IEC/IEEE Standard for Binary Floating-Point
4196| Arithmetic, except that the conversion is always rounded toward zero.
4197| If `a' is a NaN, the largest positive integer is returned.  Otherwise, if
4198| the conversion overflows, the largest integer with the same sign as `a' is
4199| returned.
4200*----------------------------------------------------------------------------*/
4201
4202int64 float128_to_int64_round_to_zero( float128 a )
4203{
4204    flag aSign;
4205    int32 aExp, shiftCount;
4206    bits64 aSig0, aSig1;
4207    int64 z;
4208
4209    aSig1 = extractFloat128Frac1( a );
4210    aSig0 = extractFloat128Frac0( a );
4211    aExp = extractFloat128Exp( a );
4212    aSign = extractFloat128Sign( a );
4213    if ( aExp ) aSig0 |= LIT64( 0x0001000000000000 );
4214    shiftCount = aExp - 0x402F;
4215    if ( 0 < shiftCount ) {
4216        if ( 0x403E <= aExp ) {
4217            aSig0 &= LIT64( 0x0000FFFFFFFFFFFF );
4218            if (    ( a.high == LIT64( 0xC03E000000000000 ) )
4219                 && ( aSig1 < LIT64( 0x0002000000000000 ) ) ) {
4220                if ( aSig1 ) float_exception_flags |= float_flag_inexact;
4221            }
4222            else {
4223                float_raise( float_flag_invalid );
4224                if ( ! aSign || ( ( aExp == 0x7FFF ) && ( aSig0 | aSig1 ) ) ) {
4225                    return LIT64( 0x7FFFFFFFFFFFFFFF );
4226                }
4227            }
4228            return (sbits64) LIT64( 0x8000000000000000 );
4229        }
4230        z = ( aSig0<<shiftCount ) | ( aSig1>>( ( - shiftCount ) & 63 ) );
4231        if ( (bits64) ( aSig1<<shiftCount ) ) {
4232            float_exception_flags |= float_flag_inexact;
4233        }
4234    }
4235    else {
4236        if ( aExp < 0x3FFF ) {
4237            if ( aExp | aSig0 | aSig1 ) {
4238                float_exception_flags |= float_flag_inexact;
4239            }
4240            return 0;
4241        }
4242        z = aSig0>>( - shiftCount );
4243        if (    aSig1
4244             || ( shiftCount && (bits64) ( aSig0<<( shiftCount & 63 ) ) ) ) {
4245            float_exception_flags |= float_flag_inexact;
4246        }
4247    }
4248    if ( aSign ) z = - z;
4249    return z;
4250
4251}
4252
4253/*----------------------------------------------------------------------------
4254| Returns the result of converting the quadruple-precision floating-point
4255| value `a' to the single-precision floating-point format.  The conversion
4256| is performed according to the IEC/IEEE Standard for Binary Floating-Point
4257| Arithmetic.
4258*----------------------------------------------------------------------------*/
4259
4260float32 float128_to_float32( float128 a )
4261{
4262    flag aSign;
4263    int32 aExp;
4264    bits64 aSig0, aSig1;
4265    bits32 zSig;
4266
4267    aSig1 = extractFloat128Frac1( a );
4268    aSig0 = extractFloat128Frac0( a );
4269    aExp = extractFloat128Exp( a );
4270    aSign = extractFloat128Sign( a );
4271    if ( aExp == 0x7FFF ) {
4272        if ( aSig0 | aSig1 ) {
4273            return commonNaNToFloat32( float128ToCommonNaN( a ) );
4274        }
4275        return packFloat32( aSign, 0xFF, 0 );
4276    }
4277    aSig0 |= ( aSig1 != 0 );
4278    shift64RightJamming( aSig0, 18, &aSig0 );
4279    zSig = aSig0;
4280    if ( aExp || zSig ) {
4281        zSig |= 0x40000000;
4282        aExp -= 0x3F81;
4283    }
4284    return roundAndPackFloat32( aSign, aExp, zSig );
4285
4286}
4287
4288/*----------------------------------------------------------------------------
4289| Returns the result of converting the quadruple-precision floating-point
4290| value `a' to the double-precision floating-point format.  The conversion
4291| is performed according to the IEC/IEEE Standard for Binary Floating-Point
4292| Arithmetic.
4293*----------------------------------------------------------------------------*/
4294
4295float64 float128_to_float64( float128 a )
4296{
4297    flag aSign;
4298    int32 aExp;
4299    bits64 aSig0, aSig1;
4300
4301    aSig1 = extractFloat128Frac1( a );
4302    aSig0 = extractFloat128Frac0( a );
4303    aExp = extractFloat128Exp( a );
4304    aSign = extractFloat128Sign( a );
4305    if ( aExp == 0x7FFF ) {
4306        if ( aSig0 | aSig1 ) {
4307            return commonNaNToFloat64( float128ToCommonNaN( a ) );
4308        }
4309        return packFloat64( aSign, 0x7FF, 0 );
4310    }
4311    shortShift128Left( aSig0, aSig1, 14, &aSig0, &aSig1 );
4312    aSig0 |= ( aSig1 != 0 );
4313    if ( aExp || aSig0 ) {
4314        aSig0 |= LIT64( 0x4000000000000000 );
4315        aExp -= 0x3C01;
4316    }
4317    return roundAndPackFloat64( aSign, aExp, aSig0 );
4318
4319}
4320
4321#ifdef FLOATX80
4322
4323/*----------------------------------------------------------------------------
4324| Returns the result of converting the quadruple-precision floating-point
4325| value `a' to the extended double-precision floating-point format.  The
4326| conversion is performed according to the IEC/IEEE Standard for Binary
4327| Floating-Point Arithmetic.
4328*----------------------------------------------------------------------------*/
4329
4330floatx80 float128_to_floatx80( float128 a )
4331{
4332    flag aSign;
4333    int32 aExp;
4334    bits64 aSig0, aSig1;
4335
4336    aSig1 = extractFloat128Frac1( a );
4337    aSig0 = extractFloat128Frac0( a );
4338    aExp = extractFloat128Exp( a );
4339    aSign = extractFloat128Sign( a );
4340    if ( aExp == 0x7FFF ) {
4341        if ( aSig0 | aSig1 ) {
4342            return commonNaNToFloatx80( float128ToCommonNaN( a ) );
4343        }
4344        return packFloatx80( aSign, 0x7FFF, LIT64( 0x8000000000000000 ) );
4345    }
4346    if ( aExp == 0 ) {
4347        if ( ( aSig0 | aSig1 ) == 0 ) return packFloatx80( aSign, 0, 0 );
4348        normalizeFloat128Subnormal( aSig0, aSig1, &aExp, &aSig0, &aSig1 );
4349    }
4350    else {
4351        aSig0 |= LIT64( 0x0001000000000000 );
4352    }
4353    shortShift128Left( aSig0, aSig1, 15, &aSig0, &aSig1 );
4354    return roundAndPackFloatx80( 80, aSign, aExp, aSig0, aSig1 );
4355
4356}
4357
4358#endif
4359
4360/*----------------------------------------------------------------------------
4361| Rounds the quadruple-precision floating-point value `a' to an integer, and
4362| returns the result as a quadruple-precision floating-point value.  The
4363| operation is performed according to the IEC/IEEE Standard for Binary
4364| Floating-Point Arithmetic.
4365*----------------------------------------------------------------------------*/
4366
4367float128 float128_round_to_int( float128 a )
4368{
4369    flag aSign;
4370    int32 aExp;
4371    bits64 lastBitMask, roundBitsMask;
4372    int8 roundingMode;
4373    float128 z;
4374
4375    aExp = extractFloat128Exp( a );
4376    if ( 0x402F <= aExp ) {
4377        if ( 0x406F <= aExp ) {
4378            if (    ( aExp == 0x7FFF )
4379                 && ( extractFloat128Frac0( a ) | extractFloat128Frac1( a ) )
4380               ) {
4381                return propagateFloat128NaN( a, a );
4382            }
4383            return a;
4384        }
4385        lastBitMask = 1;
4386        lastBitMask = ( lastBitMask<<( 0x406E - aExp ) )<<1;
4387        roundBitsMask = lastBitMask - 1;
4388        z = a;
4389        roundingMode = float_rounding_mode;
4390        if ( roundingMode == float_round_nearest_even ) {
4391            if ( lastBitMask ) {
4392                add128( z.high, z.low, 0, lastBitMask>>1, &z.high, &z.low );
4393                if ( ( z.low & roundBitsMask ) == 0 ) z.low &= ~ lastBitMask;
4394            }
4395            else {
4396                if ( (sbits64) z.low < 0 ) {
4397                    ++z.high;
4398                    if ( (bits64) ( z.low<<1 ) == 0 ) z.high &= ~1;
4399                }
4400            }
4401        }
4402        else if ( roundingMode != float_round_to_zero ) {
4403            if (   extractFloat128Sign( z )
4404                 ^ ( roundingMode == float_round_up ) ) {
4405                add128( z.high, z.low, 0, roundBitsMask, &z.high, &z.low );
4406            }
4407        }
4408        z.low &= ~ roundBitsMask;
4409    }
4410    else {
4411        if ( aExp < 0x3FFF ) {
4412            if ( ( ( (bits64) ( a.high<<1 ) ) | a.low ) == 0 ) return a;
4413            float_exception_flags |= float_flag_inexact;
4414            aSign = extractFloat128Sign( a );
4415            switch ( float_rounding_mode ) {
4416             case float_round_nearest_even:
4417                if (    ( aExp == 0x3FFE )
4418                     && (   extractFloat128Frac0( a )
4419                          | extractFloat128Frac1( a ) )
4420                   ) {
4421                    return packFloat128( aSign, 0x3FFF, 0, 0 );
4422                }
4423                break;
4424             case float_round_down:
4425                return
4426                      aSign ? packFloat128( 1, 0x3FFF, 0, 0 )
4427                    : packFloat128( 0, 0, 0, 0 );
4428             case float_round_up:
4429                return
4430                      aSign ? packFloat128( 1, 0, 0, 0 )
4431                    : packFloat128( 0, 0x3FFF, 0, 0 );
4432            }
4433            return packFloat128( aSign, 0, 0, 0 );
4434        }
4435        lastBitMask = 1;
4436        lastBitMask <<= 0x402F - aExp;
4437        roundBitsMask = lastBitMask - 1;
4438        z.low = 0;
4439        z.high = a.high;
4440        roundingMode = float_rounding_mode;
4441        if ( roundingMode == float_round_nearest_even ) {
4442            z.high += lastBitMask>>1;
4443            if ( ( ( z.high & roundBitsMask ) | a.low ) == 0 ) {
4444                z.high &= ~ lastBitMask;
4445            }
4446        }
4447        else if ( roundingMode != float_round_to_zero ) {
4448            if (   extractFloat128Sign( z )
4449                 ^ ( roundingMode == float_round_up ) ) {
4450                z.high |= ( a.low != 0 );
4451                z.high += roundBitsMask;
4452            }
4453        }
4454        z.high &= ~ roundBitsMask;
4455    }
4456    if ( ( z.low != a.low ) || ( z.high != a.high ) ) {
4457        float_exception_flags |= float_flag_inexact;
4458    }
4459    return z;
4460
4461}
4462
4463/*----------------------------------------------------------------------------
4464| Returns the result of adding the absolute values of the quadruple-precision
4465| floating-point values `a' and `b'.  If `zSign' is 1, the sum is negated
4466| before being returned.  `zSign' is ignored if the result is a NaN.
4467| The addition is performed according to the IEC/IEEE Standard for Binary
4468| Floating-Point Arithmetic.
4469*----------------------------------------------------------------------------*/
4470
4471static float128 addFloat128Sigs( float128 a, float128 b, flag zSign )
4472{
4473    int32 aExp, bExp, zExp;
4474    bits64 aSig0, aSig1, bSig0, bSig1, zSig0, zSig1, zSig2;
4475    int32 expDiff;
4476
4477    aSig1 = extractFloat128Frac1( a );
4478    aSig0 = extractFloat128Frac0( a );
4479    aExp = extractFloat128Exp( a );
4480    bSig1 = extractFloat128Frac1( b );
4481    bSig0 = extractFloat128Frac0( b );
4482    bExp = extractFloat128Exp( b );
4483    expDiff = aExp - bExp;
4484    if ( 0 < expDiff ) {
4485        if ( aExp == 0x7FFF ) {
4486            if ( aSig0 | aSig1 ) return propagateFloat128NaN( a, b );
4487            return a;
4488        }
4489        if ( bExp == 0 ) {
4490            --expDiff;
4491        }
4492        else {
4493            bSig0 |= LIT64( 0x0001000000000000 );
4494        }
4495        shift128ExtraRightJamming(
4496            bSig0, bSig1, 0, expDiff, &bSig0, &bSig1, &zSig2 );
4497        zExp = aExp;
4498    }
4499    else if ( expDiff < 0 ) {
4500        if ( bExp == 0x7FFF ) {
4501            if ( bSig0 | bSig1 ) return propagateFloat128NaN( a, b );
4502            return packFloat128( zSign, 0x7FFF, 0, 0 );
4503        }
4504        if ( aExp == 0 ) {
4505            ++expDiff;
4506        }
4507        else {
4508            aSig0 |= LIT64( 0x0001000000000000 );
4509        }
4510        shift128ExtraRightJamming(
4511            aSig0, aSig1, 0, - expDiff, &aSig0, &aSig1, &zSig2 );
4512        zExp = bExp;
4513    }
4514    else {
4515        if ( aExp == 0x7FFF ) {
4516            if ( aSig0 | aSig1 | bSig0 | bSig1 ) {
4517                return propagateFloat128NaN( a, b );
4518            }
4519            return a;
4520        }
4521        add128( aSig0, aSig1, bSig0, bSig1, &zSig0, &zSig1 );
4522        if ( aExp == 0 ) return packFloat128( zSign, 0, zSig0, zSig1 );
4523        zSig2 = 0;
4524        zSig0 |= LIT64( 0x0002000000000000 );
4525        zExp = aExp;
4526        goto shiftRight1;
4527    }
4528    aSig0 |= LIT64( 0x0001000000000000 );
4529    add128( aSig0, aSig1, bSig0, bSig1, &zSig0, &zSig1 );
4530    --zExp;
4531    if ( zSig0 < LIT64( 0x0002000000000000 ) ) goto roundAndPack;
4532    ++zExp;
4533 shiftRight1:
4534    shift128ExtraRightJamming(
4535        zSig0, zSig1, zSig2, 1, &zSig0, &zSig1, &zSig2 );
4536 roundAndPack:
4537    return roundAndPackFloat128( zSign, zExp, zSig0, zSig1, zSig2 );
4538
4539}
4540
4541/*----------------------------------------------------------------------------
4542| Returns the result of subtracting the absolute values of the quadruple-
4543| precision floating-point values `a' and `b'.  If `zSign' is 1, the
4544| difference is negated before being returned.  `zSign' is ignored if the
4545| result is a NaN.  The subtraction is performed according to the IEC/IEEE
4546| Standard for Binary Floating-Point Arithmetic.
4547*----------------------------------------------------------------------------*/
4548
4549static float128 subFloat128Sigs( float128 a, float128 b, flag zSign )
4550{
4551    int32 aExp, bExp, zExp;
4552    bits64 aSig0, aSig1, bSig0, bSig1, zSig0, zSig1;
4553    int32 expDiff;
4554    float128 z;
4555
4556    aSig1 = extractFloat128Frac1( a );
4557    aSig0 = extractFloat128Frac0( a );
4558    aExp = extractFloat128Exp( a );
4559    bSig1 = extractFloat128Frac1( b );
4560    bSig0 = extractFloat128Frac0( b );
4561    bExp = extractFloat128Exp( b );
4562    expDiff = aExp - bExp;
4563    shortShift128Left( aSig0, aSig1, 14, &aSig0, &aSig1 );
4564    shortShift128Left( bSig0, bSig1, 14, &bSig0, &bSig1 );
4565    if ( 0 < expDiff ) goto aExpBigger;
4566    if ( expDiff < 0 ) goto bExpBigger;
4567    if ( aExp == 0x7FFF ) {
4568        if ( aSig0 | aSig1 | bSig0 | bSig1 ) {
4569            return propagateFloat128NaN( a, b );
4570        }
4571        float_raise( float_flag_invalid );
4572        z.low = float128_default_nan_low;
4573        z.high = float128_default_nan_high;
4574        return z;
4575    }
4576    if ( aExp == 0 ) {
4577        aExp = 1;
4578        bExp = 1;
4579    }
4580    if ( bSig0 < aSig0 ) goto aBigger;
4581    if ( aSig0 < bSig0 ) goto bBigger;
4582    if ( bSig1 < aSig1 ) goto aBigger;
4583    if ( aSig1 < bSig1 ) goto bBigger;
4584    return packFloat128( float_rounding_mode == float_round_down, 0, 0, 0 );
4585 bExpBigger:
4586    if ( bExp == 0x7FFF ) {
4587        if ( bSig0 | bSig1 ) return propagateFloat128NaN( a, b );
4588        return packFloat128( zSign ^ 1, 0x7FFF, 0, 0 );
4589    }
4590    if ( aExp == 0 ) {
4591        ++expDiff;
4592    }
4593    else {
4594        aSig0 |= LIT64( 0x4000000000000000 );
4595    }
4596    shift128RightJamming( aSig0, aSig1, - expDiff, &aSig0, &aSig1 );
4597    bSig0 |= LIT64( 0x4000000000000000 );
4598 bBigger:
4599    sub128( bSig0, bSig1, aSig0, aSig1, &zSig0, &zSig1 );
4600    zExp = bExp;
4601    zSign ^= 1;
4602    goto normalizeRoundAndPack;
4603 aExpBigger:
4604    if ( aExp == 0x7FFF ) {
4605        if ( aSig0 | aSig1 ) return propagateFloat128NaN( a, b );
4606        return a;
4607    }
4608    if ( bExp == 0 ) {
4609        --expDiff;
4610    }
4611    else {
4612        bSig0 |= LIT64( 0x4000000000000000 );
4613    }
4614    shift128RightJamming( bSig0, bSig1, expDiff, &bSig0, &bSig1 );
4615    aSig0 |= LIT64( 0x4000000000000000 );
4616 aBigger:
4617    sub128( aSig0, aSig1, bSig0, bSig1, &zSig0, &zSig1 );
4618    zExp = aExp;
4619 normalizeRoundAndPack:
4620    --zExp;
4621    return normalizeRoundAndPackFloat128( zSign, zExp - 14, zSig0, zSig1 );
4622
4623}
4624
4625/*----------------------------------------------------------------------------
4626| Returns the result of adding the quadruple-precision floating-point values
4627| `a' and `b'.  The operation is performed according to the IEC/IEEE Standard
4628| for Binary Floating-Point Arithmetic.
4629*----------------------------------------------------------------------------*/
4630
4631float128 float128_add( float128 a, float128 b )
4632{
4633    flag aSign, bSign;
4634
4635    aSign = extractFloat128Sign( a );
4636    bSign = extractFloat128Sign( b );
4637    if ( aSign == bSign ) {
4638        return addFloat128Sigs( a, b, aSign );
4639    }
4640    else {
4641        return subFloat128Sigs( a, b, aSign );
4642    }
4643
4644}
4645
4646/*----------------------------------------------------------------------------
4647| Returns the result of subtracting the quadruple-precision floating-point
4648| values `a' and `b'.  The operation is performed according to the IEC/IEEE
4649| Standard for Binary Floating-Point Arithmetic.
4650*----------------------------------------------------------------------------*/
4651
4652float128 float128_sub( float128 a, float128 b )
4653{
4654    flag aSign, bSign;
4655
4656    aSign = extractFloat128Sign( a );
4657    bSign = extractFloat128Sign( b );
4658    if ( aSign == bSign ) {
4659        return subFloat128Sigs( a, b, aSign );
4660    }
4661    else {
4662        return addFloat128Sigs( a, b, aSign );
4663    }
4664
4665}
4666
4667/*----------------------------------------------------------------------------
4668| Returns the result of multiplying the quadruple-precision floating-point
4669| values `a' and `b'.  The operation is performed according to the IEC/IEEE
4670| Standard for Binary Floating-Point Arithmetic.
4671*----------------------------------------------------------------------------*/
4672
4673float128 float128_mul( float128 a, float128 b )
4674{
4675    flag aSign, bSign, zSign;
4676    int32 aExp, bExp, zExp;
4677    bits64 aSig0, aSig1, bSig0, bSig1, zSig0, zSig1, zSig2, zSig3;
4678    float128 z;
4679
4680    aSig1 = extractFloat128Frac1( a );
4681    aSig0 = extractFloat128Frac0( a );
4682    aExp = extractFloat128Exp( a );
4683    aSign = extractFloat128Sign( a );
4684    bSig1 = extractFloat128Frac1( b );
4685    bSig0 = extractFloat128Frac0( b );
4686    bExp = extractFloat128Exp( b );
4687    bSign = extractFloat128Sign( b );
4688    zSign = aSign ^ bSign;
4689    if ( aExp == 0x7FFF ) {
4690        if (    ( aSig0 | aSig1 )
4691             || ( ( bExp == 0x7FFF ) && ( bSig0 | bSig1 ) ) ) {
4692            return propagateFloat128NaN( a, b );
4693        }
4694        if ( ( bExp | bSig0 | bSig1 ) == 0 ) goto invalid;
4695        return packFloat128( zSign, 0x7FFF, 0, 0 );
4696    }
4697    if ( bExp == 0x7FFF ) {
4698        if ( bSig0 | bSig1 ) return propagateFloat128NaN( a, b );
4699        if ( ( aExp | aSig0 | aSig1 ) == 0 ) {
4700 invalid:
4701            float_raise( float_flag_invalid );
4702            z.low = float128_default_nan_low;
4703            z.high = float128_default_nan_high;
4704            return z;
4705        }
4706        return packFloat128( zSign, 0x7FFF, 0, 0 );
4707    }
4708    if ( aExp == 0 ) {
4709        if ( ( aSig0 | aSig1 ) == 0 ) return packFloat128( zSign, 0, 0, 0 );
4710        normalizeFloat128Subnormal( aSig0, aSig1, &aExp, &aSig0, &aSig1 );
4711    }
4712    if ( bExp == 0 ) {
4713        if ( ( bSig0 | bSig1 ) == 0 ) return packFloat128( zSign, 0, 0, 0 );
4714        normalizeFloat128Subnormal( bSig0, bSig1, &bExp, &bSig0, &bSig1 );
4715    }
4716    zExp = aExp + bExp - 0x4000;
4717    aSig0 |= LIT64( 0x0001000000000000 );
4718    shortShift128Left( bSig0, bSig1, 16, &bSig0, &bSig1 );
4719    mul128To256( aSig0, aSig1, bSig0, bSig1, &zSig0, &zSig1, &zSig2, &zSig3 );
4720    add128( zSig0, zSig1, aSig0, aSig1, &zSig0, &zSig1 );
4721    zSig2 |= ( zSig3 != 0 );
4722    if ( LIT64( 0x0002000000000000 ) <= zSig0 ) {
4723        shift128ExtraRightJamming(
4724            zSig0, zSig1, zSig2, 1, &zSig0, &zSig1, &zSig2 );
4725        ++zExp;
4726    }
4727    return roundAndPackFloat128( zSign, zExp, zSig0, zSig1, zSig2 );
4728
4729}
4730
4731/*----------------------------------------------------------------------------
4732| Returns the result of dividing the quadruple-precision floating-point value
4733| `a' by the corresponding value `b'.  The operation is performed according to
4734| the IEC/IEEE Standard for Binary Floating-Point Arithmetic.
4735*----------------------------------------------------------------------------*/
4736
4737float128 float128_div( float128 a, float128 b )
4738{
4739    flag aSign, bSign, zSign;
4740    int32 aExp, bExp, zExp;
4741    bits64 aSig0, aSig1, bSig0, bSig1, zSig0, zSig1, zSig2;
4742    bits64 rem0, rem1, rem2, rem3, term0, term1, term2, term3;
4743    float128 z;
4744
4745    aSig1 = extractFloat128Frac1( a );
4746    aSig0 = extractFloat128Frac0( a );
4747    aExp = extractFloat128Exp( a );
4748    aSign = extractFloat128Sign( a );
4749    bSig1 = extractFloat128Frac1( b );
4750    bSig0 = extractFloat128Frac0( b );
4751    bExp = extractFloat128Exp( b );
4752    bSign = extractFloat128Sign( b );
4753    zSign = aSign ^ bSign;
4754    if ( aExp == 0x7FFF ) {
4755        if ( aSig0 | aSig1 ) return propagateFloat128NaN( a, b );
4756        if ( bExp == 0x7FFF ) {
4757            if ( bSig0 | bSig1 ) return propagateFloat128NaN( a, b );
4758            goto invalid;
4759        }
4760        return packFloat128( zSign, 0x7FFF, 0, 0 );
4761    }
4762    if ( bExp == 0x7FFF ) {
4763        if ( bSig0 | bSig1 ) return propagateFloat128NaN( a, b );
4764        return packFloat128( zSign, 0, 0, 0 );
4765    }
4766    if ( bExp == 0 ) {
4767        if ( ( bSig0 | bSig1 ) == 0 ) {
4768            if ( ( aExp | aSig0 | aSig1 ) == 0 ) {
4769 invalid:
4770                float_raise( float_flag_invalid );
4771                z.low = float128_default_nan_low;
4772                z.high = float128_default_nan_high;
4773                return z;
4774            }
4775            float_raise( float_flag_divbyzero );
4776            return packFloat128( zSign, 0x7FFF, 0, 0 );
4777        }
4778        normalizeFloat128Subnormal( bSig0, bSig1, &bExp, &bSig0, &bSig1 );
4779    }
4780    if ( aExp == 0 ) {
4781        if ( ( aSig0 | aSig1 ) == 0 ) return packFloat128( zSign, 0, 0, 0 );
4782        normalizeFloat128Subnormal( aSig0, aSig1, &aExp, &aSig0, &aSig1 );
4783    }
4784    zExp = aExp - bExp + 0x3FFD;
4785    shortShift128Left(
4786        aSig0 | LIT64( 0x0001000000000000 ), aSig1, 15, &aSig0, &aSig1 );
4787    shortShift128Left(
4788        bSig0 | LIT64( 0x0001000000000000 ), bSig1, 15, &bSig0, &bSig1 );
4789    if ( le128( bSig0, bSig1, aSig0, aSig1 ) ) {
4790        shift128Right( aSig0, aSig1, 1, &aSig0, &aSig1 );
4791        ++zExp;
4792    }
4793    zSig0 = estimateDiv128To64( aSig0, aSig1, bSig0 );
4794    mul128By64To192( bSig0, bSig1, zSig0, &term0, &term1, &term2 );
4795    sub192( aSig0, aSig1, 0, term0, term1, term2, &rem0, &rem1, &rem2 );
4796    while ( (sbits64) rem0 < 0 ) {
4797        --zSig0;
4798        add192( rem0, rem1, rem2, 0, bSig0, bSig1, &rem0, &rem1, &rem2 );
4799    }
4800    zSig1 = estimateDiv128To64( rem1, rem2, bSig0 );
4801    if ( ( zSig1 & 0x3FFF ) <= 4 ) {
4802        mul128By64To192( bSig0, bSig1, zSig1, &term1, &term2, &term3 );
4803        sub192( rem1, rem2, 0, term1, term2, term3, &rem1, &rem2, &rem3 );
4804        while ( (sbits64) rem1 < 0 ) {
4805            --zSig1;
4806            add192( rem1, rem2, rem3, 0, bSig0, bSig1, &rem1, &rem2, &rem3 );
4807        }
4808        zSig1 |= ( ( rem1 | rem2 | rem3 ) != 0 );
4809    }
4810    shift128ExtraRightJamming( zSig0, zSig1, 0, 15, &zSig0, &zSig1, &zSig2 );
4811    return roundAndPackFloat128( zSign, zExp, zSig0, zSig1, zSig2 );
4812
4813}
4814
4815/*----------------------------------------------------------------------------
4816| Returns the remainder of the quadruple-precision floating-point value `a'
4817| with respect to the corresponding value `b'.  The operation is performed
4818| according to the IEC/IEEE Standard for Binary Floating-Point Arithmetic.
4819*----------------------------------------------------------------------------*/
4820
4821float128 float128_rem( float128 a, float128 b )
4822{
4823    flag aSign, bSign, zSign;
4824    int32 aExp, bExp, expDiff;
4825    bits64 aSig0, aSig1, bSig0, bSig1, q, term0, term1, term2;
4826    bits64 allZero, alternateASig0, alternateASig1, sigMean1;
4827    sbits64 sigMean0;
4828    float128 z;
4829
4830    aSig1 = extractFloat128Frac1( a );
4831    aSig0 = extractFloat128Frac0( a );
4832    aExp = extractFloat128Exp( a );
4833    aSign = extractFloat128Sign( a );
4834    bSig1 = extractFloat128Frac1( b );
4835    bSig0 = extractFloat128Frac0( b );
4836    bExp = extractFloat128Exp( b );
4837    bSign = extractFloat128Sign( b );
4838    if ( aExp == 0x7FFF ) {
4839        if (    ( aSig0 | aSig1 )
4840             || ( ( bExp == 0x7FFF ) && ( bSig0 | bSig1 ) ) ) {
4841            return propagateFloat128NaN( a, b );
4842        }
4843        goto invalid;
4844    }
4845    if ( bExp == 0x7FFF ) {
4846        if ( bSig0 | bSig1 ) return propagateFloat128NaN( a, b );
4847        return a;
4848    }
4849    if ( bExp == 0 ) {
4850        if ( ( bSig0 | bSig1 ) == 0 ) {
4851 invalid:
4852            float_raise( float_flag_invalid );
4853            z.low = float128_default_nan_low;
4854            z.high = float128_default_nan_high;
4855            return z;
4856        }
4857        normalizeFloat128Subnormal( bSig0, bSig1, &bExp, &bSig0, &bSig1 );
4858    }
4859    if ( aExp == 0 ) {
4860        if ( ( aSig0 | aSig1 ) == 0 ) return a;
4861        normalizeFloat128Subnormal( aSig0, aSig1, &aExp, &aSig0, &aSig1 );
4862    }
4863    expDiff = aExp - bExp;
4864    if ( expDiff < -1 ) return a;
4865    shortShift128Left(
4866        aSig0 | LIT64( 0x0001000000000000 ),
4867        aSig1,
4868        15 - ( expDiff < 0 ),
4869        &aSig0,
4870        &aSig1
4871    );
4872    shortShift128Left(
4873        bSig0 | LIT64( 0x0001000000000000 ), bSig1, 15, &bSig0, &bSig1 );
4874    q = le128( bSig0, bSig1, aSig0, aSig1 );
4875    if ( q ) sub128( aSig0, aSig1, bSig0, bSig1, &aSig0, &aSig1 );
4876    expDiff -= 64;
4877    while ( 0 < expDiff ) {
4878        q = estimateDiv128To64( aSig0, aSig1, bSig0 );
4879        q = ( 4 < q ) ? q - 4 : 0;
4880        mul128By64To192( bSig0, bSig1, q, &term0, &term1, &term2 );
4881        shortShift192Left( term0, term1, term2, 61, &term1, &term2, &allZero );
4882        shortShift128Left( aSig0, aSig1, 61, &aSig0, &allZero );
4883        sub128( aSig0, 0, term1, term2, &aSig0, &aSig1 );
4884        expDiff -= 61;
4885    }
4886    if ( -64 < expDiff ) {
4887        q = estimateDiv128To64( aSig0, aSig1, bSig0 );
4888        q = ( 4 < q ) ? q - 4 : 0;
4889        q >>= - expDiff;
4890        shift128Right( bSig0, bSig1, 12, &bSig0, &bSig1 );
4891        expDiff += 52;
4892        if ( expDiff < 0 ) {
4893            shift128Right( aSig0, aSig1, - expDiff, &aSig0, &aSig1 );
4894        }
4895        else {
4896            shortShift128Left( aSig0, aSig1, expDiff, &aSig0, &aSig1 );
4897        }
4898        mul128By64To192( bSig0, bSig1, q, &term0, &term1, &term2 );
4899        sub128( aSig0, aSig1, term1, term2, &aSig0, &aSig1 );
4900    }
4901    else {
4902        shift128Right( aSig0, aSig1, 12, &aSig0, &aSig1 );
4903        shift128Right( bSig0, bSig1, 12, &bSig0, &bSig1 );
4904    }
4905    do {
4906        alternateASig0 = aSig0;
4907        alternateASig1 = aSig1;
4908        ++q;
4909        sub128( aSig0, aSig1, bSig0, bSig1, &aSig0, &aSig1 );
4910    } while ( 0 <= (sbits64) aSig0 );
4911    add128(
4912        aSig0, aSig1, alternateASig0, alternateASig1, (bits64 *)&sigMean0, &sigMean1 );
4913    if (    ( sigMean0 < 0 )
4914         || ( ( ( sigMean0 | sigMean1 ) == 0 ) && ( q & 1 ) ) ) {
4915        aSig0 = alternateASig0;
4916        aSig1 = alternateASig1;
4917    }
4918    zSign = ( (sbits64) aSig0 < 0 );
4919    if ( zSign ) sub128( 0, 0, aSig0, aSig1, &aSig0, &aSig1 );
4920    return
4921        normalizeRoundAndPackFloat128( aSign ^ zSign, bExp - 4, aSig0, aSig1 );
4922
4923}
4924
4925/*----------------------------------------------------------------------------
4926| Returns the square root of the quadruple-precision floating-point value `a'.
4927| The operation is performed according to the IEC/IEEE Standard for Binary
4928| Floating-Point Arithmetic.
4929*----------------------------------------------------------------------------*/
4930
4931float128 float128_sqrt( float128 a )
4932{
4933    flag aSign;
4934    int32 aExp, zExp;
4935    bits64 aSig0, aSig1, zSig0, zSig1, zSig2, doubleZSig0;
4936    bits64 rem0, rem1, rem2, rem3, term0, term1, term2, term3;
4937    float128 z;
4938
4939    aSig1 = extractFloat128Frac1( a );
4940    aSig0 = extractFloat128Frac0( a );
4941    aExp = extractFloat128Exp( a );
4942    aSign = extractFloat128Sign( a );
4943    if ( aExp == 0x7FFF ) {
4944        if ( aSig0 | aSig1 ) return propagateFloat128NaN( a, a );
4945        if ( ! aSign ) return a;
4946        goto invalid;
4947    }
4948    if ( aSign ) {
4949        if ( ( aExp | aSig0 | aSig1 ) == 0 ) return a;
4950 invalid:
4951        float_raise( float_flag_invalid );
4952        z.low = float128_default_nan_low;
4953        z.high = float128_default_nan_high;
4954        return z;
4955    }
4956    if ( aExp == 0 ) {
4957        if ( ( aSig0 | aSig1 ) == 0 ) return packFloat128( 0, 0, 0, 0 );
4958        normalizeFloat128Subnormal( aSig0, aSig1, &aExp, &aSig0, &aSig1 );
4959    }
4960    zExp = ( ( aExp - 0x3FFF )>>1 ) + 0x3FFE;
4961    aSig0 |= LIT64( 0x0001000000000000 );
4962    zSig0 = estimateSqrt32( aExp, aSig0>>17 );
4963    shortShift128Left( aSig0, aSig1, 13 - ( aExp & 1 ), &aSig0, &aSig1 );
4964    zSig0 = estimateDiv128To64( aSig0, aSig1, zSig0<<32 ) + ( zSig0<<30 );
4965    doubleZSig0 = zSig0<<1;
4966    mul64To128( zSig0, zSig0, &term0, &term1 );
4967    sub128( aSig0, aSig1, term0, term1, &rem0, &rem1 );
4968    while ( (sbits64) rem0 < 0 ) {
4969        --zSig0;
4970        doubleZSig0 -= 2;
4971        add128( rem0, rem1, zSig0>>63, doubleZSig0 | 1, &rem0, &rem1 );
4972    }
4973    zSig1 = estimateDiv128To64( rem1, 0, doubleZSig0 );
4974    if ( ( zSig1 & 0x1FFF ) <= 5 ) {
4975        if ( zSig1 == 0 ) zSig1 = 1;
4976        mul64To128( doubleZSig0, zSig1, &term1, &term2 );
4977        sub128( rem1, 0, term1, term2, &rem1, &rem2 );
4978        mul64To128( zSig1, zSig1, &term2, &term3 );
4979        sub192( rem1, rem2, 0, 0, term2, term3, &rem1, &rem2, &rem3 );
4980        while ( (sbits64) rem1 < 0 ) {
4981            --zSig1;
4982            shortShift128Left( 0, zSig1, 1, &term2, &term3 );
4983            term3 |= 1;
4984            term2 |= doubleZSig0;
4985            add192( rem1, rem2, rem3, 0, term2, term3, &rem1, &rem2, &rem3 );
4986        }
4987        zSig1 |= ( ( rem1 | rem2 | rem3 ) != 0 );
4988    }
4989    shift128ExtraRightJamming( zSig0, zSig1, 0, 14, &zSig0, &zSig1, &zSig2 );
4990    return roundAndPackFloat128( 0, zExp, zSig0, zSig1, zSig2 );
4991
4992}
4993
4994/*----------------------------------------------------------------------------
4995| Returns 1 if the quadruple-precision floating-point value `a' is equal to
4996| the corresponding value `b', and 0 otherwise.  The comparison is performed
4997| according to the IEC/IEEE Standard for Binary Floating-Point Arithmetic.
4998*----------------------------------------------------------------------------*/
4999
5000flag float128_eq( float128 a, float128 b )
5001{
5002
5003    if (    (    ( extractFloat128Exp( a ) == 0x7FFF )
5004              && ( extractFloat128Frac0( a ) | extractFloat128Frac1( a ) ) )
5005         || (    ( extractFloat128Exp( b ) == 0x7FFF )
5006              && ( extractFloat128Frac0( b ) | extractFloat128Frac1( b ) ) )
5007       ) {
5008        if (    float128_is_signaling_nan( a )
5009             || float128_is_signaling_nan( b ) ) {
5010            float_raise( float_flag_invalid );
5011        }
5012        return 0;
5013    }
5014    return
5015           ( a.low == b.low )
5016        && (    ( a.high == b.high )
5017             || (    ( a.low == 0 )
5018                  && ( (bits64) ( ( a.high | b.high )<<1 ) == 0 ) )
5019           );
5020
5021}
5022
5023/*----------------------------------------------------------------------------
5024| Returns 1 if the quadruple-precision floating-point value `a' is less than
5025| or equal to the corresponding value `b', and 0 otherwise.  The comparison
5026| is performed according to the IEC/IEEE Standard for Binary Floating-Point
5027| Arithmetic.
5028*----------------------------------------------------------------------------*/
5029
5030flag float128_le( float128 a, float128 b )
5031{
5032    flag aSign, bSign;
5033
5034    if (    (    ( extractFloat128Exp( a ) == 0x7FFF )
5035              && ( extractFloat128Frac0( a ) | extractFloat128Frac1( a ) ) )
5036         || (    ( extractFloat128Exp( b ) == 0x7FFF )
5037              && ( extractFloat128Frac0( b ) | extractFloat128Frac1( b ) ) )
5038       ) {
5039        float_raise( float_flag_invalid );
5040        return 0;
5041    }
5042    aSign = extractFloat128Sign( a );
5043    bSign = extractFloat128Sign( b );
5044    if ( aSign != bSign ) {
5045        return
5046               aSign
5047            || (    ( ( (bits64) ( ( a.high | b.high )<<1 ) ) | a.low | b.low )
5048                 == 0 );
5049    }
5050    return
5051          aSign ? le128( b.high, b.low, a.high, a.low )
5052        : le128( a.high, a.low, b.high, b.low );
5053
5054}
5055
5056/*----------------------------------------------------------------------------
5057| Returns 1 if the quadruple-precision floating-point value `a' is less than
5058| the corresponding value `b', and 0 otherwise.  The comparison is performed
5059| according to the IEC/IEEE Standard for Binary Floating-Point Arithmetic.
5060*----------------------------------------------------------------------------*/
5061
5062flag float128_lt( float128 a, float128 b )
5063{
5064    flag aSign, bSign;
5065
5066    if (    (    ( extractFloat128Exp( a ) == 0x7FFF )
5067              && ( extractFloat128Frac0( a ) | extractFloat128Frac1( a ) ) )
5068         || (    ( extractFloat128Exp( b ) == 0x7FFF )
5069              && ( extractFloat128Frac0( b ) | extractFloat128Frac1( b ) ) )
5070       ) {
5071        float_raise( float_flag_invalid );
5072        return 0;
5073    }
5074    aSign = extractFloat128Sign( a );
5075    bSign = extractFloat128Sign( b );
5076    if ( aSign != bSign ) {
5077        return
5078               aSign
5079            && (    ( ( (bits64) ( ( a.high | b.high )<<1 ) ) | a.low | b.low )
5080                 != 0 );
5081    }
5082    return
5083          aSign ? lt128( b.high, b.low, a.high, a.low )
5084        : lt128( a.high, a.low, b.high, b.low );
5085
5086}
5087
5088/*----------------------------------------------------------------------------
5089| Returns 1 if the quadruple-precision floating-point value `a' is equal to
5090| the corresponding value `b', and 0 otherwise.  The invalid exception is
5091| raised if either operand is a NaN.  Otherwise, the comparison is performed
5092| according to the IEC/IEEE Standard for Binary Floating-Point Arithmetic.
5093*----------------------------------------------------------------------------*/
5094
5095flag float128_eq_signaling( float128 a, float128 b )
5096{
5097
5098    if (    (    ( extractFloat128Exp( a ) == 0x7FFF )
5099              && ( extractFloat128Frac0( a ) | extractFloat128Frac1( a ) ) )
5100         || (    ( extractFloat128Exp( b ) == 0x7FFF )
5101              && ( extractFloat128Frac0( b ) | extractFloat128Frac1( b ) ) )
5102       ) {
5103        float_raise( float_flag_invalid );
5104        return 0;
5105    }
5106    return
5107           ( a.low == b.low )
5108        && (    ( a.high == b.high )
5109             || (    ( a.low == 0 )
5110                  && ( (bits64) ( ( a.high | b.high )<<1 ) == 0 ) )
5111           );
5112
5113}
5114
5115/*----------------------------------------------------------------------------
5116| Returns 1 if the quadruple-precision floating-point value `a' is less than
5117| or equal to the corresponding value `b', and 0 otherwise.  Quiet NaNs do not
5118| cause an exception.  Otherwise, the comparison is performed according to the
5119| IEC/IEEE Standard for Binary Floating-Point Arithmetic.
5120*----------------------------------------------------------------------------*/
5121
5122flag float128_le_quiet( float128 a, float128 b )
5123{
5124    flag aSign, bSign;
5125
5126    if (    (    ( extractFloat128Exp( a ) == 0x7FFF )
5127              && ( extractFloat128Frac0( a ) | extractFloat128Frac1( a ) ) )
5128         || (    ( extractFloat128Exp( b ) == 0x7FFF )
5129              && ( extractFloat128Frac0( b ) | extractFloat128Frac1( b ) ) )
5130       ) {
5131        if (    float128_is_signaling_nan( a )
5132             || float128_is_signaling_nan( b ) ) {
5133            float_raise( float_flag_invalid );
5134        }
5135        return 0;
5136    }
5137    aSign = extractFloat128Sign( a );
5138    bSign = extractFloat128Sign( b );
5139    if ( aSign != bSign ) {
5140        return
5141               aSign
5142            || (    ( ( (bits64) ( ( a.high | b.high )<<1 ) ) | a.low | b.low )
5143                 == 0 );
5144    }
5145    return
5146          aSign ? le128( b.high, b.low, a.high, a.low )
5147        : le128( a.high, a.low, b.high, b.low );
5148
5149}
5150
5151/*----------------------------------------------------------------------------
5152| Returns 1 if the quadruple-precision floating-point value `a' is less than
5153| the corresponding value `b', and 0 otherwise.  Quiet NaNs do not cause an
5154| exception.  Otherwise, the comparison is performed according to the IEC/IEEE
5155| Standard for Binary Floating-Point Arithmetic.
5156*----------------------------------------------------------------------------*/
5157
5158flag float128_lt_quiet( float128 a, float128 b )
5159{
5160    flag aSign, bSign;
5161
5162    if (    (    ( extractFloat128Exp( a ) == 0x7FFF )
5163              && ( extractFloat128Frac0( a ) | extractFloat128Frac1( a ) ) )
5164         || (    ( extractFloat128Exp( b ) == 0x7FFF )
5165              && ( extractFloat128Frac0( b ) | extractFloat128Frac1( b ) ) )
5166       ) {
5167        if (    float128_is_signaling_nan( a )
5168             || float128_is_signaling_nan( b ) ) {
5169            float_raise( float_flag_invalid );
5170        }
5171        return 0;
5172    }
5173    aSign = extractFloat128Sign( a );
5174    bSign = extractFloat128Sign( b );
5175    if ( aSign != bSign ) {
5176        return
5177               aSign
5178            && (    ( ( (bits64) ( ( a.high | b.high )<<1 ) ) | a.low | b.low )
5179                 != 0 );
5180    }
5181    return
5182          aSign ? lt128( b.high, b.low, a.high, a.low )
5183        : lt128( a.high, a.low, b.high, b.low );
5184
5185}
5186
5187#endif
5188
src/lib/softfloat/softfloat-macros
r0r7501
1
2/*============================================================================
3
4This C source fragment is part of the SoftFloat IEC/IEEE Floating-point
5Arithmetic Package, Release 2b.
6
7Written by John R. Hauser.  This work was made possible in part by the
8International Computer Science Institute, located at Suite 600, 1947 Center
9Street, Berkeley, California 94704.  Funding was partially provided by the
10National Science Foundation under grant MIP-9311980.  The original version
11of this code was written as part of a project to build a fixed-point vector
12processor in collaboration with the University of California at Berkeley,
13overseen by Profs. Nelson Morgan and John Wawrzynek.  More information
14is available through the Web page `http://www.cs.berkeley.edu/~jhauser/
15arithmetic/SoftFloat.html'.
16
17THIS SOFTWARE IS DISTRIBUTED AS IS, FOR FREE.  Although reasonable effort has
18been made to avoid it, THIS SOFTWARE MAY CONTAIN FAULTS THAT WILL AT TIMES
19RESULT IN INCORRECT BEHAVIOR.  USE OF THIS SOFTWARE IS RESTRICTED TO PERSONS
20AND ORGANIZATIONS WHO CAN AND WILL TAKE FULL RESPONSIBILITY FOR ALL LOSSES,
21COSTS, OR OTHER PROBLEMS THEY INCUR DUE TO THE SOFTWARE, AND WHO FURTHERMORE
22EFFECTIVELY INDEMNIFY JOHN HAUSER AND THE INTERNATIONAL COMPUTER SCIENCE
23INSTITUTE (possibly via similar legal notice) AGAINST ALL LOSSES, COSTS, OR
24OTHER PROBLEMS INCURRED BY THEIR CUSTOMERS AND CLIENTS DUE TO THE SOFTWARE.
25
26Derivative works are acceptable, even for commercial purposes, so long as
27(1) the source code for the derivative work includes prominent notice that
28the work is derivative, and (2) the source code includes prominent notice with
29these four paragraphs for those parts of this code that are retained.
30
31=============================================================================*/
32
33/*----------------------------------------------------------------------------
34| Shifts `a' right by the number of bits given in `count'.  If any nonzero
35| bits are shifted off, they are ``jammed'' into the least significant bit of
36| the result by setting the least significant bit to 1.  The value of `count'
37| can be arbitrarily large; in particular, if `count' is greater than 32, the
38| result will be either 0 or 1, depending on whether `a' is zero or nonzero.
39| The result is stored in the location pointed to by `zPtr'.
40*----------------------------------------------------------------------------*/
41
42INLINE void shift32RightJamming( bits32 a, int16 count, bits32 *zPtr )
43{
44    bits32 z;
45
46    if ( count == 0 ) {
47        z = a;
48    }
49    else if ( count < 32 ) {
50        z = ( a>>count ) | ( ( a<<( ( - count ) & 31 ) ) != 0 );
51    }
52    else {
53        z = ( a != 0 );
54    }
55    *zPtr = z;
56
57}
58
59/*----------------------------------------------------------------------------
60| Shifts `a' right by the number of bits given in `count'.  If any nonzero
61| bits are shifted off, they are ``jammed'' into the least significant bit of
62| the result by setting the least significant bit to 1.  The value of `count'
63| can be arbitrarily large; in particular, if `count' is greater than 64, the
64| result will be either 0 or 1, depending on whether `a' is zero or nonzero.
65| The result is stored in the location pointed to by `zPtr'.
66*----------------------------------------------------------------------------*/
67
68INLINE void shift64RightJamming( bits64 a, int16 count, bits64 *zPtr )
69{
70    bits64 z;
71
72    if ( count == 0 ) {
73        z = a;
74    }
75    else if ( count < 64 ) {
76        z = ( a>>count ) | ( ( a<<( ( - count ) & 63 ) ) != 0 );
77    }
78    else {
79        z = ( a != 0 );
80    }
81    *zPtr = z;
82
83}
84
85/*----------------------------------------------------------------------------
86| Shifts the 128-bit value formed by concatenating `a0' and `a1' right by 64
87| _plus_ the number of bits given in `count'.  The shifted result is at most
88| 64 nonzero bits; this is stored at the location pointed to by `z0Ptr'.  The
89| bits shifted off form a second 64-bit result as follows:  The _last_ bit
90| shifted off is the most-significant bit of the extra result, and the other
91| 63 bits of the extra result are all zero if and only if _all_but_the_last_
92| bits shifted off were all zero.  This extra result is stored in the location
93| pointed to by `z1Ptr'.  The value of `count' can be arbitrarily large.
94|     (This routine makes more sense if `a0' and `a1' are considered to form
95| a fixed-point value with binary point between `a0' and `a1'.  This fixed-
96| point value is shifted right by the number of bits given in `count', and
97| the integer part of the result is returned at the location pointed to by
98| `z0Ptr'.  The fractional part of the result may be slightly corrupted as
99| described above, and is returned at the location pointed to by `z1Ptr'.)
100*----------------------------------------------------------------------------*/
101
102INLINE void
103 shift64ExtraRightJamming(
104     bits64 a0, bits64 a1, int16 count, bits64 *z0Ptr, bits64 *z1Ptr )
105{
106    bits64 z0, z1;
107    int8 negCount = ( - count ) & 63;
108
109    if ( count == 0 ) {
110        z1 = a1;
111        z0 = a0;
112    }
113    else if ( count < 64 ) {
114        z1 = ( a0<<negCount ) | ( a1 != 0 );
115        z0 = a0>>count;
116    }
117    else {
118        if ( count == 64 ) {
119            z1 = a0 | ( a1 != 0 );
120        }
121        else {
122            z1 = ( ( a0 | a1 ) != 0 );
123        }
124        z0 = 0;
125    }
126    *z1Ptr = z1;
127    *z0Ptr = z0;
128
129}
130
131/*----------------------------------------------------------------------------
132| Shifts the 128-bit value formed by concatenating `a0' and `a1' right by the
133| number of bits given in `count'.  Any bits shifted off are lost.  The value
134| of `count' can be arbitrarily large; in particular, if `count' is greater
135| than 128, the result will be 0.  The result is broken into two 64-bit pieces
136| which are stored at the locations pointed to by `z0Ptr' and `z1Ptr'.
137*----------------------------------------------------------------------------*/
138
139INLINE void
140 shift128Right(
141     bits64 a0, bits64 a1, int16 count, bits64 *z0Ptr, bits64 *z1Ptr )
142{
143    bits64 z0, z1;
144    int8 negCount = ( - count ) & 63;
145
146    if ( count == 0 ) {
147        z1 = a1;
148        z0 = a0;
149    }
150    else if ( count < 64 ) {
151        z1 = ( a0<<negCount ) | ( a1>>count );
152        z0 = a0>>count;
153    }
154    else {
155        z1 = ( count < 64 ) ? ( a0>>( count & 63 ) ) : 0;
156        z0 = 0;
157    }
158    *z1Ptr = z1;
159    *z0Ptr = z0;
160
161}
162
163/*----------------------------------------------------------------------------
164| Shifts the 128-bit value formed by concatenating `a0' and `a1' right by the
165| number of bits given in `count'.  If any nonzero bits are shifted off, they
166| are ``jammed'' into the least significant bit of the result by setting the
167| least significant bit to 1.  The value of `count' can be arbitrarily large;
168| in particular, if `count' is greater than 128, the result will be either
169| 0 or 1, depending on whether the concatenation of `a0' and `a1' is zero or
170| nonzero.  The result is broken into two 64-bit pieces which are stored at
171| the locations pointed to by `z0Ptr' and `z1Ptr'.
172*----------------------------------------------------------------------------*/
173
174INLINE void
175 shift128RightJamming(
176     bits64 a0, bits64 a1, int16 count, bits64 *z0Ptr, bits64 *z1Ptr )
177{
178    bits64 z0, z1;
179    int8 negCount = ( - count ) & 63;
180
181    if ( count == 0 ) {
182        z1 = a1;
183        z0 = a0;
184    }
185    else if ( count < 64 ) {
186        z1 = ( a0<<negCount ) | ( a1>>count ) | ( ( a1<<negCount ) != 0 );
187        z0 = a0>>count;
188    }
189    else {
190        if ( count == 64 ) {
191            z1 = a0 | ( a1 != 0 );
192        }
193        else if ( count < 128 ) {
194            z1 = ( a0>>( count & 63 ) ) | ( ( ( a0<<negCount ) | a1 ) != 0 );
195        }
196        else {
197            z1 = ( ( a0 | a1 ) != 0 );
198        }
199        z0 = 0;
200    }
201    *z1Ptr = z1;
202    *z0Ptr = z0;
203
204}
205
206/*----------------------------------------------------------------------------
207| Shifts the 192-bit value formed by concatenating `a0', `a1', and `a2' right
208| by 64 _plus_ the number of bits given in `count'.  The shifted result is
209| at most 128 nonzero bits; these are broken into two 64-bit pieces which are
210| stored at the locations pointed to by `z0Ptr' and `z1Ptr'.  The bits shifted
211| off form a third 64-bit result as follows:  The _last_ bit shifted off is
212| the most-significant bit of the extra result, and the other 63 bits of the
213| extra result are all zero if and only if _all_but_the_last_ bits shifted off
214| were all zero.  This extra result is stored in the location pointed to by
215| `z2Ptr'.  The value of `count' can be arbitrarily large.
216|     (This routine makes more sense if `a0', `a1', and `a2' are considered
217| to form a fixed-point value with binary point between `a1' and `a2'.  This
218| fixed-point value is shifted right by the number of bits given in `count',
219| and the integer part of the result is returned at the locations pointed to
220| by `z0Ptr' and `z1Ptr'.  The fractional part of the result may be slightly
221| corrupted as described above, and is returned at the location pointed to by
222| `z2Ptr'.)
223*----------------------------------------------------------------------------*/
224
225INLINE void
226 shift128ExtraRightJamming(
227     bits64 a0,
228     bits64 a1,
229     bits64 a2,
230     int16 count,
231     bits64 *z0Ptr,
232     bits64 *z1Ptr,
233     bits64 *z2Ptr
234 )
235{
236    bits64 z0, z1, z2;
237    int8 negCount = ( - count ) & 63;
238
239    if ( count == 0 ) {
240        z2 = a2;
241        z1 = a1;
242        z0 = a0;
243    }
244    else {
245        if ( count < 64 ) {
246            z2 = a1<<negCount;
247            z1 = ( a0<<negCount ) | ( a1>>count );
248            z0 = a0>>count;
249        }
250        else {
251            if ( count == 64 ) {
252                z2 = a1;
253                z1 = a0;
254            }
255            else {
256                a2 |= a1;
257                if ( count < 128 ) {
258                    z2 = a0<<negCount;
259                    z1 = a0>>( count & 63 );
260                }
261                else {
262                    z2 = ( count == 128 ) ? a0 : ( a0 != 0 );
263                    z1 = 0;
264                }
265            }
266            z0 = 0;
267        }
268        z2 |= ( a2 != 0 );
269    }
270    *z2Ptr = z2;
271    *z1Ptr = z1;
272    *z0Ptr = z0;
273
274}
275
276/*----------------------------------------------------------------------------
277| Shifts the 128-bit value formed by concatenating `a0' and `a1' left by the
278| number of bits given in `count'.  Any bits shifted off are lost.  The value
279| of `count' must be less than 64.  The result is broken into two 64-bit
280| pieces which are stored at the locations pointed to by `z0Ptr' and `z1Ptr'.
281*----------------------------------------------------------------------------*/
282
283INLINE void
284 shortShift128Left(
285     bits64 a0, bits64 a1, int16 count, bits64 *z0Ptr, bits64 *z1Ptr )
286{
287
288    *z1Ptr = a1<<count;
289    *z0Ptr =
290        ( count == 0 ) ? a0 : ( a0<<count ) | ( a1>>( ( - count ) & 63 ) );
291
292}
293
294/*----------------------------------------------------------------------------
295| Shifts the 192-bit value formed by concatenating `a0', `a1', and `a2' left
296| by the number of bits given in `count'.  Any bits shifted off are lost.
297| The value of `count' must be less than 64.  The result is broken into three
298| 64-bit pieces which are stored at the locations pointed to by `z0Ptr',
299| `z1Ptr', and `z2Ptr'.
300*----------------------------------------------------------------------------*/
301
302INLINE void
303 shortShift192Left(
304     bits64 a0,
305     bits64 a1,
306     bits64 a2,
307     int16 count,
308     bits64 *z0Ptr,
309     bits64 *z1Ptr,
310     bits64 *z2Ptr
311 )
312{
313    bits64 z0, z1, z2;
314    int8 negCount;
315
316    z2 = a2<<count;
317    z1 = a1<<count;
318    z0 = a0<<count;
319    if ( 0 < count ) {
320        negCount = ( ( - count ) & 63 );
321        z1 |= a2>>negCount;
322        z0 |= a1>>negCount;
323    }
324    *z2Ptr = z2;
325    *z1Ptr = z1;
326    *z0Ptr = z0;
327
328}
329
330/*----------------------------------------------------------------------------
331| Adds the 128-bit value formed by concatenating `a0' and `a1' to the 128-bit
332| value formed by concatenating `b0' and `b1'.  Addition is modulo 2^128, so
333| any carry out is lost.  The result is broken into two 64-bit pieces which
334| are stored at the locations pointed to by `z0Ptr' and `z1Ptr'.
335*----------------------------------------------------------------------------*/
336
337INLINE void
338 add128(
339     bits64 a0, bits64 a1, bits64 b0, bits64 b1, bits64 *z0Ptr, bits64 *z1Ptr )
340{
341    bits64 z1;
342
343    z1 = a1 + b1;
344    *z1Ptr = z1;
345    *z0Ptr = a0 + b0 + ( z1 < a1 );
346
347}
348
349/*----------------------------------------------------------------------------
350| Adds the 192-bit value formed by concatenating `a0', `a1', and `a2' to the
351| 192-bit value formed by concatenating `b0', `b1', and `b2'.  Addition is
352| modulo 2^192, so any carry out is lost.  The result is broken into three
353| 64-bit pieces which are stored at the locations pointed to by `z0Ptr',
354| `z1Ptr', and `z2Ptr'.
355*----------------------------------------------------------------------------*/
356
357INLINE void
358 add192(
359     bits64 a0,
360     bits64 a1,
361     bits64 a2,
362     bits64 b0,
363     bits64 b1,
364     bits64 b2,
365     bits64 *z0Ptr,
366     bits64 *z1Ptr,
367     bits64 *z2Ptr
368 )
369{
370    bits64 z0, z1, z2;
371    int8 carry0, carry1;
372
373    z2 = a2 + b2;
374    carry1 = ( z2 < a2 );
375    z1 = a1 + b1;
376    carry0 = ( z1 < a1 );
377    z0 = a0 + b0;
378    z1 += carry1;
379    z0 += ( z1 < carry1 );
380    z0 += carry0;
381    *z2Ptr = z2;
382    *z1Ptr = z1;
383    *z0Ptr = z0;
384
385}
386
387/*----------------------------------------------------------------------------
388| Subtracts the 128-bit value formed by concatenating `b0' and `b1' from the
389| 128-bit value formed by concatenating `a0' and `a1'.  Subtraction is modulo
390| 2^128, so any borrow out (carry out) is lost.  The result is broken into two
391| 64-bit pieces which are stored at the locations pointed to by `z0Ptr' and
392| `z1Ptr'.
393*----------------------------------------------------------------------------*/
394
395INLINE void
396 sub128(
397     bits64 a0, bits64 a1, bits64 b0, bits64 b1, bits64 *z0Ptr, bits64 *z1Ptr )
398{
399
400    *z1Ptr = a1 - b1;
401    *z0Ptr = a0 - b0 - ( a1 < b1 );
402
403}
404
405/*----------------------------------------------------------------------------
406| Subtracts the 192-bit value formed by concatenating `b0', `b1', and `b2'
407| from the 192-bit value formed by concatenating `a0', `a1', and `a2'.
408| Subtraction is modulo 2^192, so any borrow out (carry out) is lost.  The
409| result is broken into three 64-bit pieces which are stored at the locations
410| pointed to by `z0Ptr', `z1Ptr', and `z2Ptr'.
411*----------------------------------------------------------------------------*/
412
413INLINE void
414 sub192(
415     bits64 a0,
416     bits64 a1,
417     bits64 a2,
418     bits64 b0,
419     bits64 b1,
420     bits64 b2,
421     bits64 *z0Ptr,
422     bits64 *z1Ptr,
423     bits64 *z2Ptr
424 )
425{
426    bits64 z0, z1, z2;
427    int8 borrow0, borrow1;
428
429    z2 = a2 - b2;
430    borrow1 = ( a2 < b2 );
431    z1 = a1 - b1;
432    borrow0 = ( a1 < b1 );
433    z0 = a0 - b0;
434    z0 -= ( z1 < borrow1 );
435    z1 -= borrow1;
436    z0 -= borrow0;
437    *z2Ptr = z2;
438    *z1Ptr = z1;
439    *z0Ptr = z0;
440
441}
442
443/*----------------------------------------------------------------------------
444| Multiplies `a' by `b' to obtain a 128-bit product.  The product is broken
445| into two 64-bit pieces which are stored at the locations pointed to by
446| `z0Ptr' and `z1Ptr'.
447*----------------------------------------------------------------------------*/
448
449INLINE void mul64To128( bits64 a, bits64 b, bits64 *z0Ptr, bits64 *z1Ptr )
450{
451    bits32 aHigh, aLow, bHigh, bLow;
452    bits64 z0, zMiddleA, zMiddleB, z1;
453
454    aLow = a;
455    aHigh = a>>32;
456    bLow = b;
457    bHigh = b>>32;
458    z1 = ( (bits64) aLow ) * bLow;
459    zMiddleA = ( (bits64) aLow ) * bHigh;
460    zMiddleB = ( (bits64) aHigh ) * bLow;
461    z0 = ( (bits64) aHigh ) * bHigh;
462    zMiddleA += zMiddleB;
463    z0 += ( ( (bits64) ( zMiddleA < zMiddleB ) )<<32 ) + ( zMiddleA>>32 );
464    zMiddleA <<= 32;
465    z1 += zMiddleA;
466    z0 += ( z1 < zMiddleA );
467    *z1Ptr = z1;
468    *z0Ptr = z0;
469
470}
471
472/*----------------------------------------------------------------------------
473| Multiplies the 128-bit value formed by concatenating `a0' and `a1' by
474| `b' to obtain a 192-bit product.  The product is broken into three 64-bit
475| pieces which are stored at the locations pointed to by `z0Ptr', `z1Ptr', and
476| `z2Ptr'.
477*----------------------------------------------------------------------------*/
478
479INLINE void
480 mul128By64To192(
481     bits64 a0,
482     bits64 a1,
483     bits64 b,
484     bits64 *z0Ptr,
485     bits64 *z1Ptr,
486     bits64 *z2Ptr
487 )
488{
489    bits64 z0, z1, z2, more1;
490
491    mul64To128( a1, b, &z1, &z2 );
492    mul64To128( a0, b, &z0, &more1 );
493    add128( z0, more1, 0, z1, &z0, &z1 );
494    *z2Ptr = z2;
495    *z1Ptr = z1;
496    *z0Ptr = z0;
497
498}
499
500/*----------------------------------------------------------------------------
501| Multiplies the 128-bit value formed by concatenating `a0' and `a1' to the
502| 128-bit value formed by concatenating `b0' and `b1' to obtain a 256-bit
503| product.  The product is broken into four 64-bit pieces which are stored at
504| the locations pointed to by `z0Ptr', `z1Ptr', `z2Ptr', and `z3Ptr'.
505*----------------------------------------------------------------------------*/
506
507INLINE void
508 mul128To256(
509     bits64 a0,
510     bits64 a1,
511     bits64 b0,
512     bits64 b1,
513     bits64 *z0Ptr,
514     bits64 *z1Ptr,
515     bits64 *z2Ptr,
516     bits64 *z3Ptr
517 )
518{
519    bits64 z0, z1, z2, z3;
520    bits64 more1, more2;
521
522    mul64To128( a1, b1, &z2, &z3 );
523    mul64To128( a1, b0, &z1, &more2 );
524    add128( z1, more2, 0, z2, &z1, &z2 );
525    mul64To128( a0, b0, &z0, &more1 );
526    add128( z0, more1, 0, z1, &z0, &z1 );
527    mul64To128( a0, b1, &more1, &more2 );
528    add128( more1, more2, 0, z2, &more1, &z2 );
529    add128( z0, z1, 0, more1, &z0, &z1 );
530    *z3Ptr = z3;
531    *z2Ptr = z2;
532    *z1Ptr = z1;
533    *z0Ptr = z0;
534
535}
536
537/*----------------------------------------------------------------------------
538| Returns an approximation to the 64-bit integer quotient obtained by dividing
539| `b' into the 128-bit value formed by concatenating `a0' and `a1'.  The
540| divisor `b' must be at least 2^63.  If q is the exact quotient truncated
541| toward zero, the approximation returned lies between q and q + 2 inclusive.
542| If the exact quotient q is larger than 64 bits, the maximum positive 64-bit
543| unsigned integer is returned.
544*----------------------------------------------------------------------------*/
545
546static bits64 estimateDiv128To64( bits64 a0, bits64 a1, bits64 b )
547{
548    bits64 b0, b1;
549    bits64 rem0, rem1, term0, term1;
550    bits64 z;
551
552    if ( b <= a0 ) return LIT64( 0xFFFFFFFFFFFFFFFF );
553    b0 = b>>32;
554    z = ( b0<<32 <= a0 ) ? LIT64( 0xFFFFFFFF00000000 ) : ( a0 / b0 )<<32;
555    mul64To128( b, z, &term0, &term1 );
556    sub128( a0, a1, term0, term1, &rem0, &rem1 );
557    while ( ( (sbits64) rem0 ) < 0 ) {
558        z -= LIT64( 0x100000000 );
559        b1 = b<<32;
560        add128( rem0, rem1, b0, b1, &rem0, &rem1 );
561    }
562    rem0 = ( rem0<<32 ) | ( rem1>>32 );
563    z |= ( b0<<32 <= rem0 ) ? 0xFFFFFFFF : rem0 / b0;
564    return z;
565
566}
567
568/*----------------------------------------------------------------------------
569| Returns an approximation to the square root of the 32-bit significand given
570| by `a'.  Considered as an integer, `a' must be at least 2^31.  If bit 0 of
571| `aExp' (the least significant bit) is 1, the integer returned approximates
572| 2^31*sqrt(`a'/2^31), where `a' is considered an integer.  If bit 0 of `aExp'
573| is 0, the integer returned approximates 2^31*sqrt(`a'/2^30).  In either
574| case, the approximation returned lies strictly within +/-2 of the exact
575| value.
576*----------------------------------------------------------------------------*/
577
578static bits32 estimateSqrt32( int16 aExp, bits32 a )
579{
580    static const bits16 sqrtOddAdjustments[] = {
581        0x0004, 0x0022, 0x005D, 0x00B1, 0x011D, 0x019F, 0x0236, 0x02E0,
582        0x039C, 0x0468, 0x0545, 0x0631, 0x072B, 0x0832, 0x0946, 0x0A67
583    };
584    static const bits16 sqrtEvenAdjustments[] = {
585        0x0A2D, 0x08AF, 0x075A, 0x0629, 0x051A, 0x0429, 0x0356, 0x029E,
586        0x0200, 0x0179, 0x0109, 0x00AF, 0x0068, 0x0034, 0x0012, 0x0002
587    };
588    int8 index;
589    bits32 z;
590
591    index = ( a>>27 ) & 15;
592    if ( aExp & 1 ) {
593        z = 0x4000 + ( a>>17 ) - sqrtOddAdjustments[ index ];
594        z = ( ( a / z )<<14 ) + ( z<<15 );
595        a >>= 1;
596    }
597    else {
598        z = 0x8000 + ( a>>17 ) - sqrtEvenAdjustments[ index ];
599        z = a / z + z;
600        z = ( 0x20000 <= z ) ? 0xFFFF8000 : ( z<<15 );
601        if ( z <= a ) return (bits32) ( ( (sbits32) a )>>1 );
602    }
603    return ( (bits32) ( ( ( (bits64) a )<<31 ) / z ) ) + ( z>>1 );
604
605}
606
607/*----------------------------------------------------------------------------
608| Returns the number of leading 0 bits before the most-significant 1 bit of
609| `a'.  If `a' is zero, 32 is returned.
610*----------------------------------------------------------------------------*/
611
612static int8 countLeadingZeros32( bits32 a )
613{
614    static const int8 countLeadingZerosHigh[] = {
615        8, 7, 6, 6, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 4, 4,
616        3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
617        2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
618        2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
619        1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
620        1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
621        1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
622        1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
623        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
624        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
625        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
626        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
627        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
628        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
629        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
630        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
631    };
632    int8 shiftCount;
633
634    shiftCount = 0;
635    if ( a < 0x10000 ) {
636        shiftCount += 16;
637        a <<= 16;
638    }
639    if ( a < 0x1000000 ) {
640        shiftCount += 8;
641        a <<= 8;
642    }
643    shiftCount += countLeadingZerosHigh[ a>>24 ];
644    return shiftCount;
645
646}
647
648/*----------------------------------------------------------------------------
649| Returns the number of leading 0 bits before the most-significant 1 bit of
650| `a'.  If `a' is zero, 64 is returned.
651*----------------------------------------------------------------------------*/
652
653static int8 countLeadingZeros64( bits64 a )
654{
655    int8 shiftCount;
656
657    shiftCount = 0;
658    if ( a < ( (bits64) 1 )<<32 ) {
659        shiftCount += 32;
660    }
661    else {
662        a >>= 32;
663    }
664    shiftCount += countLeadingZeros32( a );
665    return shiftCount;
666
667}
668
669/*----------------------------------------------------------------------------
670| Returns 1 if the 128-bit value formed by concatenating `a0' and `a1'
671| is equal to the 128-bit value formed by concatenating `b0' and `b1'.
672| Otherwise, returns 0.
673*----------------------------------------------------------------------------*/
674
675INLINE flag eq128( bits64 a0, bits64 a1, bits64 b0, bits64 b1 )
676{
677
678    return ( a0 == b0 ) && ( a1 == b1 );
679
680}
681
682/*----------------------------------------------------------------------------
683| Returns 1 if the 128-bit value formed by concatenating `a0' and `a1' is less
684| than or equal to the 128-bit value formed by concatenating `b0' and `b1'.
685| Otherwise, returns 0.
686*----------------------------------------------------------------------------*/
687
688INLINE flag le128( bits64 a0, bits64 a1, bits64 b0, bits64 b1 )
689{
690
691    return ( a0 < b0 ) || ( ( a0 == b0 ) && ( a1 <= b1 ) );
692
693}
694
695/*----------------------------------------------------------------------------
696| Returns 1 if the 128-bit value formed by concatenating `a0' and `a1' is less
697| than the 128-bit value formed by concatenating `b0' and `b1'.  Otherwise,
698| returns 0.
699*----------------------------------------------------------------------------*/
700
701INLINE flag lt128( bits64 a0, bits64 a1, bits64 b0, bits64 b1 )
702{
703
704    return ( a0 < b0 ) || ( ( a0 == b0 ) && ( a1 < b1 ) );
705
706}
707
708/*----------------------------------------------------------------------------
709| Returns 1 if the 128-bit value formed by concatenating `a0' and `a1' is
710| not equal to the 128-bit value formed by concatenating `b0' and `b1'.
711| Otherwise, returns 0.
712*----------------------------------------------------------------------------*/
713
714INLINE flag ne128( bits64 a0, bits64 a1, bits64 b0, bits64 b1 )
715{
716
717    return ( a0 != b0 ) || ( a1 != b1 );
718
719}
720
src/lib/softfloat/softfloat-specialize
r0r7501
1
2/*============================================================================
3
4This C source fragment is part of the SoftFloat IEC/IEEE Floating-point
5Arithmetic Package, Release 2b.
6
7Written by John R. Hauser.  This work was made possible in part by the
8International Computer Science Institute, located at Suite 600, 1947 Center
9Street, Berkeley, California 94704.  Funding was partially provided by the
10National Science Foundation under grant MIP-9311980.  The original version
11of this code was written as part of a project to build a fixed-point vector
12processor in collaboration with the University of California at Berkeley,
13overseen by Profs. Nelson Morgan and John Wawrzynek.  More information
14is available through the Web page `http://www.cs.berkeley.edu/~jhauser/
15arithmetic/SoftFloat.html'.
16
17THIS SOFTWARE IS DISTRIBUTED AS IS, FOR FREE.  Although reasonable effort has
18been made to avoid it, THIS SOFTWARE MAY CONTAIN FAULTS THAT WILL AT TIMES
19RESULT IN INCORRECT BEHAVIOR.  USE OF THIS SOFTWARE IS RESTRICTED TO PERSONS
20AND ORGANIZATIONS WHO CAN AND WILL TAKE FULL RESPONSIBILITY FOR ALL LOSSES,
21COSTS, OR OTHER PROBLEMS THEY INCUR DUE TO THE SOFTWARE, AND WHO FURTHERMORE
22EFFECTIVELY INDEMNIFY JOHN HAUSER AND THE INTERNATIONAL COMPUTER SCIENCE
23INSTITUTE (possibly via similar legal warning) AGAINST ALL LOSSES, COSTS, OR
24OTHER PROBLEMS INCURRED BY THEIR CUSTOMERS AND CLIENTS DUE TO THE SOFTWARE.
25
26Derivative works are acceptable, even for commercial purposes, so long as
27(1) the source code for the derivative work includes prominent notice that
28the work is derivative, and (2) the source code includes prominent notice with
29these four paragraphs for those parts of this code that are retained.
30
31=============================================================================*/
32
33/*----------------------------------------------------------------------------
34| Underflow tininess-detection mode, statically initialized to default value.
35| (The declaration in `softfloat.h' must match the `int8' type here.)
36*----------------------------------------------------------------------------*/
37int8 float_detect_tininess = float_tininess_after_rounding;
38
39/*----------------------------------------------------------------------------
40| Raises the exceptions specified by `flags'.  Floating-point traps can be
41| defined here if desired.  It is currently not possible for such a trap to
42| substitute a result value.  If traps are not implemented, this routine
43| should be simply `float_exception_flags |= flags;'.
44*----------------------------------------------------------------------------*/
45
46void float_raise( int8 flags )
47{
48
49    float_exception_flags |= flags;
50
51}
52
53/*----------------------------------------------------------------------------
54| Internal canonical NaN format.
55*----------------------------------------------------------------------------*/
56typedef struct {
57    flag sign;
58    bits64 high, low;
59} commonNaNT;
60
61/*----------------------------------------------------------------------------
62| The pattern for a default generated single-precision NaN.
63*----------------------------------------------------------------------------*/
64#define float32_default_nan 0xFFFFFFFF
65
66/*----------------------------------------------------------------------------
67| Returns 1 if the single-precision floating-point value `a' is a NaN;
68| otherwise returns 0.
69*----------------------------------------------------------------------------*/
70
71flag float32_is_nan( float32 a )
72{
73
74    return ( 0xFF000000 < (bits32) ( a<<1 ) );
75
76}
77
78/*----------------------------------------------------------------------------
79| Returns 1 if the single-precision floating-point value `a' is a signaling
80| NaN; otherwise returns 0.
81*----------------------------------------------------------------------------*/
82
83flag float32_is_signaling_nan( float32 a )
84{
85
86    return ( ( ( a>>22 ) & 0x1FF ) == 0x1FE ) && ( a & 0x003FFFFF );
87
88}
89
90/*----------------------------------------------------------------------------
91| Returns the result of converting the single-precision floating-point NaN
92| `a' to the canonical NaN format.  If `a' is a signaling NaN, the invalid
93| exception is raised.
94*----------------------------------------------------------------------------*/
95
96static commonNaNT float32ToCommonNaN( float32 a )
97{
98    commonNaNT z;
99
100    if ( float32_is_signaling_nan( a ) ) float_raise( float_flag_invalid );
101    z.sign = a>>31;
102    z.low = 0;
103    z.high = ( (bits64) a )<<41;
104    return z;
105
106}
107
108/*----------------------------------------------------------------------------
109| Returns the result of converting the canonical NaN `a' to the single-
110| precision floating-point format.
111*----------------------------------------------------------------------------*/
112
113static float32 commonNaNToFloat32( commonNaNT a )
114{
115
116    return ( ( (bits32) a.sign )<<31 ) | 0x7FC00000 | ( a.high>>41 );
117
118}
119
120/*----------------------------------------------------------------------------
121| Takes two single-precision floating-point values `a' and `b', one of which
122| is a NaN, and returns the appropriate NaN result.  If either `a' or `b' is a
123| signaling NaN, the invalid exception is raised.
124*----------------------------------------------------------------------------*/
125
126static float32 propagateFloat32NaN( float32 a, float32 b )
127{
128    flag aIsNaN, aIsSignalingNaN, bIsNaN, bIsSignalingNaN;
129
130    aIsNaN = float32_is_nan( a );
131    aIsSignalingNaN = float32_is_signaling_nan( a );
132    bIsNaN = float32_is_nan( b );
133    bIsSignalingNaN = float32_is_signaling_nan( b );
134    a |= 0x00400000;
135    b |= 0x00400000;
136    if ( aIsSignalingNaN | bIsSignalingNaN ) float_raise( float_flag_invalid );
137    if ( aIsNaN ) {
138        return ( aIsSignalingNaN & bIsNaN ) ? b : a;
139    }
140    else {
141        return b;
142    }
143
144}
145
146/*----------------------------------------------------------------------------
147| The pattern for a default generated double-precision NaN.
148*----------------------------------------------------------------------------*/
149#define float64_default_nan LIT64( 0xFFFFFFFFFFFFFFFF )
150
151/*----------------------------------------------------------------------------
152| Returns 1 if the double-precision floating-point value `a' is a NaN;
153| otherwise returns 0.
154*----------------------------------------------------------------------------*/
155
156flag float64_is_nan( float64 a )
157{
158
159    return ( LIT64( 0xFFE0000000000000 ) < (bits64) ( a<<1 ) );
160
161}
162
163/*----------------------------------------------------------------------------
164| Returns 1 if the double-precision floating-point value `a' is a signaling
165| NaN; otherwise returns 0.
166*----------------------------------------------------------------------------*/
167
168flag float64_is_signaling_nan( float64 a )
169{
170
171    return
172           ( ( ( a>>51 ) & 0xFFF ) == 0xFFE )
173        && ( a & LIT64( 0x0007FFFFFFFFFFFF ) );
174
175}
176
177/*----------------------------------------------------------------------------
178| Returns the result of converting the double-precision floating-point NaN
179| `a' to the canonical NaN format.  If `a' is a signaling NaN, the invalid
180| exception is raised.
181*----------------------------------------------------------------------------*/
182
183static commonNaNT float64ToCommonNaN( float64 a )
184{
185    commonNaNT z;
186
187    if ( float64_is_signaling_nan( a ) ) float_raise( float_flag_invalid );
188    z.sign = a>>63;
189    z.low = 0;
190    z.high = a<<12;
191    return z;
192
193}
194
195/*----------------------------------------------------------------------------
196| Returns the result of converting the canonical NaN `a' to the double-
197| precision floating-point format.
198*----------------------------------------------------------------------------*/
199
200static float64 commonNaNToFloat64( commonNaNT a )
201{
202
203    return
204          ( ( (bits64) a.sign )<<63 )
205        | LIT64( 0x7FF8000000000000 )
206        | ( a.high>>12 );
207
208}
209
210/*----------------------------------------------------------------------------
211| Takes two double-precision floating-point values `a' and `b', one of which
212| is a NaN, and returns the appropriate NaN result.  If either `a' or `b' is a
213| signaling NaN, the invalid exception is raised.
214*----------------------------------------------------------------------------*/
215
216static float64 propagateFloat64NaN( float64 a, float64 b )
217{
218    flag aIsNaN, aIsSignalingNaN, bIsNaN, bIsSignalingNaN;
219
220    aIsNaN = float64_is_nan( a );
221    aIsSignalingNaN = float64_is_signaling_nan( a );
222    bIsNaN = float64_is_nan( b );
223    bIsSignalingNaN = float64_is_signaling_nan( b );
224    a |= LIT64( 0x0008000000000000 );
225    b |= LIT64( 0x0008000000000000 );
226    if ( aIsSignalingNaN | bIsSignalingNaN ) float_raise( float_flag_invalid );
227    if ( aIsNaN ) {
228        return ( aIsSignalingNaN & bIsNaN ) ? b : a;
229    }
230    else {
231        return b;
232    }
233
234}
235
236#ifdef FLOATX80
237
238/*----------------------------------------------------------------------------
239| The pattern for a default generated extended double-precision NaN.  The
240| `high' and `low' values hold the most- and least-significant bits,
241| respectively.
242*----------------------------------------------------------------------------*/
243#define floatx80_default_nan_high 0xFFFF
244#define floatx80_default_nan_low  LIT64( 0xFFFFFFFFFFFFFFFF )
245
246/*----------------------------------------------------------------------------
247| Returns 1 if the extended double-precision floating-point value `a' is a
248| NaN; otherwise returns 0.
249*----------------------------------------------------------------------------*/
250
251flag floatx80_is_nan( floatx80 a )
252{
253
254    return ( ( a.high & 0x7FFF ) == 0x7FFF ) && (bits64) ( a.low<<1 );
255
256}
257
258/*----------------------------------------------------------------------------
259| Returns 1 if the extended double-precision floating-point value `a' is a
260| signaling NaN; otherwise returns 0.
261*----------------------------------------------------------------------------*/
262
263flag floatx80_is_signaling_nan( floatx80 a )
264{
265    bits64 aLow;
266
267    aLow = a.low & ~ LIT64( 0x4000000000000000 );
268    return
269           ( ( a.high & 0x7FFF ) == 0x7FFF )
270        && (bits64) ( aLow<<1 )
271        && ( a.low == aLow );
272
273}
274
275/*----------------------------------------------------------------------------
276| Returns the result of converting the extended double-precision floating-
277| point NaN `a' to the canonical NaN format.  If `a' is a signaling NaN, the
278| invalid exception is raised.
279*----------------------------------------------------------------------------*/
280
281static commonNaNT floatx80ToCommonNaN( floatx80 a )
282{
283    commonNaNT z;
284
285    if ( floatx80_is_signaling_nan( a ) ) float_raise( float_flag_invalid );
286    z.sign = a.high>>15;
287    z.low = 0;
288    z.high = a.low<<1;
289    return z;
290
291}
292
293/*----------------------------------------------------------------------------
294| Returns the result of converting the canonical NaN `a' to the extended
295| double-precision floating-point format.
296*----------------------------------------------------------------------------*/
297
298static floatx80 commonNaNToFloatx80( commonNaNT a )
299{
300    floatx80 z;
301
302    z.low = LIT64( 0xC000000000000000 ) | ( a.high>>1 );
303    z.high = ( ( (bits16) a.sign )<<15 ) | 0x7FFF;
304    return z;
305
306}
307
308/*----------------------------------------------------------------------------
309| Takes two extended double-precision floating-point values `a' and `b', one
310| of which is a NaN, and returns the appropriate NaN result.  If either `a' or
311| `b' is a signaling NaN, the invalid exception is raised.
312*----------------------------------------------------------------------------*/
313
314static floatx80 propagateFloatx80NaN( floatx80 a, floatx80 b )
315{
316    flag aIsNaN, aIsSignalingNaN, bIsNaN, bIsSignalingNaN;
317
318    aIsNaN = floatx80_is_nan( a );
319    aIsSignalingNaN = floatx80_is_signaling_nan( a );
320    bIsNaN = floatx80_is_nan( b );
321    bIsSignalingNaN = floatx80_is_signaling_nan( b );
322    a.low |= LIT64( 0xC000000000000000 );
323    b.low |= LIT64( 0xC000000000000000 );
324    if ( aIsSignalingNaN | bIsSignalingNaN ) float_raise( float_flag_invalid );
325    if ( aIsNaN ) {
326        return ( aIsSignalingNaN & bIsNaN ) ? b : a;
327    }
328    else {
329        return b;
330    }
331
332}
333
334#endif
335
336#ifdef FLOAT128
337
338/*----------------------------------------------------------------------------
339| The pattern for a default generated quadruple-precision NaN.  The `high' and
340| `low' values hold the most- and least-significant bits, respectively.
341*----------------------------------------------------------------------------*/
342#define float128_default_nan_high LIT64( 0xFFFFFFFFFFFFFFFF )
343#define float128_default_nan_low  LIT64( 0xFFFFFFFFFFFFFFFF )
344
345/*----------------------------------------------------------------------------
346| Returns 1 if the quadruple-precision floating-point value `a' is a NaN;
347| otherwise returns 0.
348*----------------------------------------------------------------------------*/
349
350flag float128_is_nan( float128 a )
351{
352
353    return
354           ( LIT64( 0xFFFE000000000000 ) <= (bits64) ( a.high<<1 ) )
355        && ( a.low || ( a.high & LIT64( 0x0000FFFFFFFFFFFF ) ) );
356
357}
358
359/*----------------------------------------------------------------------------
360| Returns 1 if the quadruple-precision floating-point value `a' is a
361| signaling NaN; otherwise returns 0.
362*----------------------------------------------------------------------------*/
363
364flag float128_is_signaling_nan( float128 a )
365{
366
367    return
368           ( ( ( a.high>>47 ) & 0xFFFF ) == 0xFFFE )
369        && ( a.low || ( a.high & LIT64( 0x00007FFFFFFFFFFF ) ) );
370
371}
372
373/*----------------------------------------------------------------------------
374| Returns the result of converting the quadruple-precision floating-point NaN
375| `a' to the canonical NaN format.  If `a' is a signaling NaN, the invalid
376| exception is raised.
377*----------------------------------------------------------------------------*/
378
379static commonNaNT float128ToCommonNaN( float128 a )
380{
381    commonNaNT z;
382
383    if ( float128_is_signaling_nan( a ) ) float_raise( float_flag_invalid );
384    z.sign = a.high>>63;
385    shortShift128Left( a.high, a.low, 16, &z.high, &z.low );
386    return z;
387
388}
389
390/*----------------------------------------------------------------------------
391| Returns the result of converting the canonical NaN `a' to the quadruple-
392| precision floating-point format.
393*----------------------------------------------------------------------------*/
394
395static float128 commonNaNToFloat128( commonNaNT a )
396{
397    float128 z;
398
399    shift128Right( a.high, a.low, 16, &z.high, &z.low );
400    z.high |= ( ( (bits64) a.sign )<<63 ) | LIT64( 0x7FFF800000000000 );
401    return z;
402
403}
404
405/*----------------------------------------------------------------------------
406| Takes two quadruple-precision floating-point values `a' and `b', one of
407| which is a NaN, and returns the appropriate NaN result.  If either `a' or
408| `b' is a signaling NaN, the invalid exception is raised.
409*----------------------------------------------------------------------------*/
410
411static float128 propagateFloat128NaN( float128 a, float128 b )
412{
413    flag aIsNaN, aIsSignalingNaN, bIsNaN, bIsSignalingNaN;
414
415    aIsNaN = float128_is_nan( a );
416    aIsSignalingNaN = float128_is_signaling_nan( a );
417    bIsNaN = float128_is_nan( b );
418    bIsSignalingNaN = float128_is_signaling_nan( b );
419    a.high |= LIT64( 0x0000800000000000 );
420    b.high |= LIT64( 0x0000800000000000 );
421    if ( aIsSignalingNaN | bIsSignalingNaN ) float_raise( float_flag_invalid );
422    if ( aIsNaN ) {
423        return ( aIsSignalingNaN & bIsNaN ) ? b : a;
424    }
425    else {
426        return b;
427    }
428
429}
430
431#endif
432
src/lib/softfloat/softfloat.h
r0r7501
1
2/*============================================================================
3
4This C header file is part of the SoftFloat IEC/IEEE Floating-point Arithmetic
5Package, Release 2b.
6
7Written by John R. Hauser.  This work was made possible in part by the
8International Computer Science Institute, located at Suite 600, 1947 Center
9Street, Berkeley, California 94704.  Funding was partially provided by the
10National Science Foundation under grant MIP-9311980.  The original version
11of this code was written as part of a project to build a fixed-point vector
12processor in collaboration with the University of California at Berkeley,
13overseen by Profs. Nelson Morgan and John Wawrzynek.  More information
14is available through the Web page `http://www.cs.berkeley.edu/~jhauser/
15arithmetic/SoftFloat.html'.
16
17THIS SOFTWARE IS DISTRIBUTED AS IS, FOR FREE.  Although reasonable effort has
18been made to avoid it, THIS SOFTWARE MAY CONTAIN FAULTS THAT WILL AT TIMES
19RESULT IN INCORRECT BEHAVIOR.  USE OF THIS SOFTWARE IS RESTRICTED TO PERSONS
20AND ORGANIZATIONS WHO CAN AND WILL TAKE FULL RESPONSIBILITY FOR ALL LOSSES,
21COSTS, OR OTHER PROBLEMS THEY INCUR DUE TO THE SOFTWARE, AND WHO FURTHERMORE
22EFFECTIVELY INDEMNIFY JOHN HAUSER AND THE INTERNATIONAL COMPUTER SCIENCE
23INSTITUTE (possibly via similar legal warning) AGAINST ALL LOSSES, COSTS, OR
24OTHER PROBLEMS INCURRED BY THEIR CUSTOMERS AND CLIENTS DUE TO THE SOFTWARE.
25
26Derivative works are acceptable, even for commercial purposes, so long as
27(1) the source code for the derivative work includes prominent notice that
28the work is derivative, and (2) the source code includes prominent notice with
29these four paragraphs for those parts of this code that are retained.
30
31=============================================================================*/
32
33/*----------------------------------------------------------------------------
34| The macro `FLOATX80' must be defined to enable the extended double-precision
35| floating-point format `floatx80'.  If this macro is not defined, the
36| `floatx80' type will not be defined, and none of the functions that either
37| input or output the `floatx80' type will be defined.  The same applies to
38| the `FLOAT128' macro and the quadruple-precision format `float128'.
39*----------------------------------------------------------------------------*/
40#define FLOATX80
41#define FLOAT128
42
43/*----------------------------------------------------------------------------
44| Software IEC/IEEE floating-point types.
45*----------------------------------------------------------------------------*/
46typedef bits32 float32;
47typedef bits64 float64;
48#ifdef FLOATX80
49typedef struct {
50    bits16 high;
51    bits64 low;
52} floatx80;
53#endif
54#ifdef FLOAT128
55typedef struct {
56    bits64 high, low;
57} float128;
58#endif
59
60/*----------------------------------------------------------------------------
61| Software IEC/IEEE floating-point underflow tininess-detection mode.
62*----------------------------------------------------------------------------*/
63extern int8 float_detect_tininess;
64enum {
65    float_tininess_after_rounding  = 0,
66    float_tininess_before_rounding = 1
67};
68
69/*----------------------------------------------------------------------------
70| Software IEC/IEEE floating-point rounding mode.
71*----------------------------------------------------------------------------*/
72extern int8 float_rounding_mode;
73enum {
74    float_round_nearest_even = 0,
75    float_round_to_zero      = 1,
76    float_round_down         = 2,
77    float_round_up           = 3
78};
79
80/*----------------------------------------------------------------------------
81| Software IEC/IEEE floating-point exception flags.
82*----------------------------------------------------------------------------*/
83extern int8 float_exception_flags;
84enum {
85    float_flag_inexact   =  1,
86    float_flag_underflow =  2,
87    float_flag_overflow  =  4,
88    float_flag_divbyzero =  8,
89    float_flag_invalid   = 16
90};
91
92/*----------------------------------------------------------------------------
93| Routine to raise any or all of the software IEC/IEEE floating-point
94| exception flags.
95*----------------------------------------------------------------------------*/
96void float_raise( int8 );
97
98/*----------------------------------------------------------------------------
99| Software IEC/IEEE integer-to-floating-point conversion routines.
100*----------------------------------------------------------------------------*/
101float32 int32_to_float32( int32 );
102float64 int32_to_float64( int32 );
103#ifdef FLOATX80
104floatx80 int32_to_floatx80( int32 );
105#endif
106#ifdef FLOAT128
107float128 int32_to_float128( int32 );
108#endif
109float32 int64_to_float32( int64 );
110float64 int64_to_float64( int64 );
111#ifdef FLOATX80
112floatx80 int64_to_floatx80( int64 );
113#endif
114#ifdef FLOAT128
115float128 int64_to_float128( int64 );
116#endif
117
118/*----------------------------------------------------------------------------
119| Software IEC/IEEE single-precision conversion routines.
120*----------------------------------------------------------------------------*/
121int32 float32_to_int32( float32 );
122int32 float32_to_int32_round_to_zero( float32 );
123int64 float32_to_int64( float32 );
124int64 float32_to_int64_round_to_zero( float32 );
125float64 float32_to_float64( float32 );
126#ifdef FLOATX80
127floatx80 float32_to_floatx80( float32 );
128#endif
129#ifdef FLOAT128
130float128 float32_to_float128( float32 );
131#endif
132
133/*----------------------------------------------------------------------------
134| Software IEC/IEEE single-precision operations.
135*----------------------------------------------------------------------------*/
136float32 float32_round_to_int( float32 );
137float32 float32_add( float32, float32 );
138float32 float32_sub( float32, float32 );
139float32 float32_mul( float32, float32 );
140float32 float32_div( float32, float32 );
141float32 float32_rem( float32, float32 );
142float32 float32_sqrt( float32 );
143flag float32_eq( float32, float32 );
144flag float32_le( float32, float32 );
145flag float32_lt( float32, float32 );
146flag float32_eq_signaling( float32, float32 );
147flag float32_le_quiet( float32, float32 );
148flag float32_lt_quiet( float32, float32 );
149flag float32_is_signaling_nan( float32 );
150
151/*----------------------------------------------------------------------------
152| Software IEC/IEEE double-precision conversion routines.
153*----------------------------------------------------------------------------*/
154int32 float64_to_int32( float64 );
155int32 float64_to_int32_round_to_zero( float64 );
156int64 float64_to_int64( float64 );
157int64 float64_to_int64_round_to_zero( float64 );
158float32 float64_to_float32( float64 );
159#ifdef FLOATX80
160floatx80 float64_to_floatx80( float64 );
161#endif
162#ifdef FLOAT128
163float128 float64_to_float128( float64 );
164#endif
165
166/*----------------------------------------------------------------------------
167| Software IEC/IEEE double-precision operations.
168*----------------------------------------------------------------------------*/
169float64 float64_round_to_int( float64 );
170float64 float64_add( float64, float64 );
171float64 float64_sub( float64, float64 );
172float64 float64_mul( float64, float64 );
173float64 float64_div( float64, float64 );
174float64 float64_rem( float64, float64 );
175float64 float64_sqrt( float64 );
176flag float64_eq( float64, float64 );
177flag float64_le( float64, float64 );
178flag float64_lt( float64, float64 );
179flag float64_eq_signaling( float64, float64 );
180flag float64_le_quiet( float64, float64 );
181flag float64_lt_quiet( float64, float64 );
182flag float64_is_signaling_nan( float64 );
183
184#ifdef FLOATX80
185
186/*----------------------------------------------------------------------------
187| Software IEC/IEEE extended double-precision conversion routines.
188*----------------------------------------------------------------------------*/
189int32 floatx80_to_int32( floatx80 );
190int32 floatx80_to_int32_round_to_zero( floatx80 );
191int64 floatx80_to_int64( floatx80 );
192int64 floatx80_to_int64_round_to_zero( floatx80 );
193float32 floatx80_to_float32( floatx80 );
194float64 floatx80_to_float64( floatx80 );
195#ifdef FLOAT128
196float128 floatx80_to_float128( floatx80 );
197#endif
198
199/*----------------------------------------------------------------------------
200| Software IEC/IEEE extended double-precision rounding precision.  Valid
201| values are 32, 64, and 80.
202*----------------------------------------------------------------------------*/
203extern int8 floatx80_rounding_precision;
204
205/*----------------------------------------------------------------------------
206| Software IEC/IEEE extended double-precision operations.
207*----------------------------------------------------------------------------*/
208floatx80 floatx80_round_to_int( floatx80 );
209floatx80 floatx80_add( floatx80, floatx80 );
210floatx80 floatx80_sub( floatx80, floatx80 );
211floatx80 floatx80_mul( floatx80, floatx80 );
212floatx80 floatx80_div( floatx80, floatx80 );
213floatx80 floatx80_rem( floatx80, floatx80 );
214floatx80 floatx80_sqrt( floatx80 );
215flag floatx80_eq( floatx80, floatx80 );
216flag floatx80_le( floatx80, floatx80 );
217flag floatx80_lt( floatx80, floatx80 );
218flag floatx80_eq_signaling( floatx80, floatx80 );
219flag floatx80_le_quiet( floatx80, floatx80 );
220flag floatx80_lt_quiet( floatx80, floatx80 );
221flag floatx80_is_signaling_nan( floatx80 );
222
223#endif
224
225#ifdef FLOAT128
226
227/*----------------------------------------------------------------------------
228| Software IEC/IEEE quadruple-precision conversion routines.
229*----------------------------------------------------------------------------*/
230int32 float128_to_int32( float128 );
231int32 float128_to_int32_round_to_zero( float128 );
232int64 float128_to_int64( float128 );
233int64 float128_to_int64_round_to_zero( float128 );
234float32 float128_to_float32( float128 );
235float64 float128_to_float64( float128 );
236#ifdef FLOATX80
237floatx80 float128_to_floatx80( float128 );
238#endif
239
240/*----------------------------------------------------------------------------
241| Software IEC/IEEE quadruple-precision operations.
242*----------------------------------------------------------------------------*/
243float128 float128_round_to_int( float128 );
244float128 float128_add( float128, float128 );
245float128 float128_sub( float128, float128 );
246float128 float128_mul( float128, float128 );
247float128 float128_div( float128, float128 );
248float128 float128_rem( float128, float128 );
249float128 float128_sqrt( float128 );
250flag float128_eq( float128, float128 );
251flag float128_le( float128, float128 );
252flag float128_lt( float128, float128 );
253flag float128_eq_signaling( float128, float128 );
254flag float128_le_quiet( float128, float128 );
255flag float128_lt_quiet( float128, float128 );
256flag float128_is_signaling_nan( float128 );
257
258#endif
259
src/lib/softfloat/milieu.h
r0r7501
1
2/*============================================================================
3
4This C header file is part of the SoftFloat IEC/IEEE Floating-point Arithmetic
5Package, Release 2b.
6
7Written by John R. Hauser.  This work was made possible in part by the
8International Computer Science Institute, located at Suite 600, 1947 Center
9Street, Berkeley, California 94704.  Funding was partially provided by the
10National Science Foundation under grant MIP-9311980.  The original version
11of this code was written as part of a project to build a fixed-point vector
12processor in collaboration with the University of California at Berkeley,
13overseen by Profs. Nelson Morgan and John Wawrzynek.  More information
14is available through the Web page `http://www.cs.berkeley.edu/~jhauser/
15arithmetic/SoftFloat.html'.
16
17THIS SOFTWARE IS DISTRIBUTED AS IS, FOR FREE.  Although reasonable effort has
18been made to avoid it, THIS SOFTWARE MAY CONTAIN FAULTS THAT WILL AT TIMES
19RESULT IN INCORRECT BEHAVIOR.  USE OF THIS SOFTWARE IS RESTRICTED TO PERSONS
20AND ORGANIZATIONS WHO CAN AND WILL TAKE FULL RESPONSIBILITY FOR ALL LOSSES,
21COSTS, OR OTHER PROBLEMS THEY INCUR DUE TO THE SOFTWARE, AND WHO FURTHERMORE
22EFFECTIVELY INDEMNIFY JOHN HAUSER AND THE INTERNATIONAL COMPUTER SCIENCE
23INSTITUTE (possibly via similar legal warning) AGAINST ALL LOSSES, COSTS, OR
24OTHER PROBLEMS INCURRED BY THEIR CUSTOMERS AND CLIENTS DUE TO THE SOFTWARE.
25
26Derivative works are acceptable, even for commercial purposes, so long as
27(1) the source code for the derivative work includes prominent notice that
28the work is derivative, and (2) the source code includes prominent notice with
29these four paragraphs for those parts of this code that are retained.
30
31=============================================================================*/
32
33/*----------------------------------------------------------------------------
34| Include common integer types and flags.
35*----------------------------------------------------------------------------*/
36#include "mamesf.h"
37
38/*----------------------------------------------------------------------------
39| Symbolic Boolean literals.
40*----------------------------------------------------------------------------*/
41#define FALSE 0
42#define TRUE 1
src/lib/softfloat/README.txt
r0r7501
1MAME note: this package is derived from the following original SoftFloat
2package and has been "re-packaged" to work with MAME's conventions and
3build system.  The source files come from bits64/ and bits64/templates
4in the original distribution as MAME requires a compiler with a 64-bit
5integer type.
6
7
8Package Overview for SoftFloat Release 2b
9
10John R. Hauser
112002 May 27
12
13
14----------------------------------------------------------------------------
15Overview
16
17SoftFloat is a software implementation of floating-point that conforms to
18the IEC/IEEE Standard for Binary Floating-Point Arithmetic.  SoftFloat is
19distributed in the form of C source code.  Compiling the SoftFloat sources
20generates two things:
21
22-- A SoftFloat object file (typically `softfloat.o') containing the complete
23   set of IEC/IEEE floating-point routines.
24
25-- A `timesoftfloat' program for evaluating the speed of the SoftFloat
26   routines.  (The SoftFloat module is linked into this program.)
27
28The SoftFloat package is documented in four text files:
29
30   SoftFloat.txt          Documentation for using the SoftFloat functions.
31   SoftFloat-source.txt   Documentation for compiling SoftFloat.
32   SoftFloat-history.txt  History of major changes to SoftFloat.
33   timesoftfloat.txt      Documentation for using `timesoftfloat'.
34
35Other files in the package comprise the source code for SoftFloat.
36
37Please be aware that some work is involved in porting this software to other
38targets.  It is not just a matter of getting `make' to complete without
39error messages.  I would have written the code that way if I could, but
40there are fundamental differences between systems that can't be hidden.
41You should not attempt to compile SoftFloat without first reading both
42`SoftFloat.txt' and `SoftFloat-source.txt'.
43
44
45----------------------------------------------------------------------------
46Legal Notice
47
48SoftFloat was written by me, John R. Hauser.  This work was made possible in
49part by the International Computer Science Institute, located at Suite 600,
501947 Center Street, Berkeley, California 94704.  Funding was partially
51provided by the National Science Foundation under grant MIP-9311980.  The
52original version of this code was written as part of a project to build
53a fixed-point vector processor in collaboration with the University of
54California at Berkeley, overseen by Profs. Nelson Morgan and John Wawrzynek.
55
56THIS SOFTWARE IS DISTRIBUTED AS IS, FOR FREE.  Although reasonable effort
57has been made to avoid it, THIS SOFTWARE MAY CONTAIN FAULTS THAT WILL AT
58TIMES RESULT IN INCORRECT BEHAVIOR.  USE OF THIS SOFTWARE IS RESTRICTED TO
59PERSONS AND ORGANIZATIONS WHO CAN AND WILL TAKE FULL RESPONSIBILITY FOR ALL
60LOSSES, COSTS, OR OTHER PROBLEMS THEY INCUR DUE TO THE SOFTWARE, AND WHO
61FURTHERMORE EFFECTIVELY INDEMNIFY JOHN HAUSER AND THE INTERNATIONAL COMPUTER
62SCIENCE INSTITUTE (possibly via similar legal warning) AGAINST ALL LOSSES,
63COSTS, OR OTHER PROBLEMS INCURRED BY THEIR CUSTOMERS AND CLIENTS DUE TO THE
64SOFTWARE.
65
66Derivative works are acceptable, even for commercial purposes, provided
67that the minimal documentation requirements stated in the source code are
68satisfied.
69
70
71----------------------------------------------------------------------------
72Contact Information
73
74At the time of this writing, the most up-to-date information about
75SoftFloat and the latest release can be found at the Web page `http://
76www.cs.berkeley.edu/~jhauser/arithmetic/SoftFloat.html'.
77
78
src/lib/softfloat/mamesf.h
r0r7501
1/*----------------------------------------------------------------------------
2| One of the macros `BIGENDIAN' or `LITTLEENDIAN' must be defined.
3*----------------------------------------------------------------------------*/
4#ifdef LSB_FIRST
5#define LITTLEENDIAN
6#else
7#define BIGENDIAN
8#endif
9
10/*----------------------------------------------------------------------------
11| The macro `BITS64' can be defined to indicate that 64-bit integer types are
12| supported by the compiler.
13*----------------------------------------------------------------------------*/
14#define BITS64
15
16/*----------------------------------------------------------------------------
17| Each of the following `typedef's defines the most convenient type that holds
18| integers of at least as many bits as specified.  For example, `uint8' should
19| be the most convenient type that can hold unsigned integers of as many as
20| 8 bits.  The `flag' type must be able to hold either a 0 or 1.  For most
21| implementations of C, `flag', `uint8', and `int8' should all be `typedef'ed
22| to the same as `int'.
23*----------------------------------------------------------------------------*/
24#include "emu.h"
25
26typedef INT8 flag;
27typedef UINT8 uint8;
28typedef INT8 int8;
29typedef UINT16 uint16;
30typedef INT16 int16;
31typedef UINT32 uint32;
32typedef INT32 int32;
33typedef UINT64 uint64;
34typedef INT64 int64;
35
36/*----------------------------------------------------------------------------
37| Each of the following `typedef's defines a type that holds integers
38| of _exactly_ the number of bits specified.  For instance, for most
39| implementation of C, `bits16' and `sbits16' should be `typedef'ed to
40| `unsigned short int' and `signed short int' (or `short int'), respectively.
41*----------------------------------------------------------------------------*/
42typedef UINT8 bits8;
43typedef INT8 sbits8;
44typedef UINT16 bits16;
45typedef INT16 sbits16;
46typedef UINT32 bits32;
47typedef INT32 sbits32;
48typedef UINT64 bits64;
49typedef INT64 sbits64;
50
51/*----------------------------------------------------------------------------
52| The `LIT64' macro takes as its argument a textual integer literal and
53| if necessary ``marks'' the literal as having a 64-bit integer type.
54| For example, the GNU C Compiler (`gcc') requires that 64-bit literals be
55| appended with the letters `LL' standing for `long long', which is `gcc's
56| name for the 64-bit integer type.  Some compilers may allow `LIT64' to be
57| defined as the identity macro:  `#define LIT64( a ) a'.
58*----------------------------------------------------------------------------*/
59#define LIT64( a ) a##LL
60
61/*----------------------------------------------------------------------------
62| The macro `INLINE' can be used before functions that should be inlined.  If
63| a compiler does not support explicit inlining, this macro should be defined
64| to be `static'.
65*----------------------------------------------------------------------------*/
66// MAME defines INLINE
src/lib/lib.mak
r7500r7501
1717   $(LIBOBJ)/util \
1818   $(LIBOBJ)/expat \
1919   $(LIBOBJ)/zlib \
20   $(LIBOBJ)/softfloat \
2021
2122
2223
r7500r7501
9394$(LIBOBJ)/zlib/%.o: $(LIBSRC)/zlib/%.c | $(OSPREBUILD)
9495   @echo Compiling $<...
9596   $(CC) $(CDEFS) $(CCOMFLAGS) $(CONLYFLAGS) -c $< -o $@
97
98#-------------------------------------------------
99# SoftFloat library objects
100#-------------------------------------------------
101
102PROCESSOR_H = $(LIBSRC)/softfloat/processors/mamesf.h
103SOFTFLOAT_MACROS = $(LIBSRC)/softfloat/softfloat/bits64/softfloat-macros
104
105SOFTFLOATOBJS = \
106   $(LIBOBJ)/softfloat/softfloat.o
107
108$(OBJ)/libsoftfloat.a: $(SOFTFLOATOBJS)
109
110$(LIBOBJ)/softfloat/softfloat.o: $(LIBSRC)/softfloat/softfloat.c $(LIBSRC)/softfloat/softfloat.h $(LIBSRC)/softfloat/softfloat-macros $(LIBSRC)/softfloat/softfloat-specialize
111
src/mess/mess.mak
r7500r7501
230230SOUNDS += CDP1863
231231SOUNDS += CDP1864
232232#SOUNDS += ZSG2
233SOUNDS += MOS656X
233234SOUNDS += SOCRATES
234235SOUNDS += TMC0285
235236SOUNDS += TMS5200
r7500r7501
239240#SOUNDS += TMC0281
240241#SOUNDS += TMS5100
241242#SOUNDS += TMS5110A
242SOUNDS += MOS656X
243243
244244
245245#-------------------------------------------------
docs/messnew.txt
r7500r7501
9494
9595Source Changes:
9696----------------
97- The core is based on MAME 0.136u3.  This incorporates all features of the
97- The core is based on MAME 0.136u4.  This incorporates all features of the
9898  update to this core.  [MAME team]
9999
100100- Refactored MOS6526 CIA interface, added SP/CNT callbacks, and fixed serial
makefile
r7500r7501
420420ifndef NOWERROR
421421CCOMFLAGS += -Werror -fno-strict-aliasing $(ARCHOPTS)
422422else
423CCOMFLAGS += -fno-strict-aliasing $(ARCHOPTS)
423424endif
424425else
425426CCOMFLAGS += -fno-strict-aliasing $(ARCHOPTS)
r7500r7501
462463   -I$(SRC)/osd/$(OSD) \
463464
464465
466#-------------------------------------------------
467# archiving flags
468#-------------------------------------------------
469# Default to something reasonable for all platforms
470ARFLAGS = -cr
471# Deal with macosx brain damage if COMMAND_MODE is in
472# the luser's environment:
473ifeq ($(TARGETOS),macosx)
474ifeq ($(COMMAND_MODE),"legacy")
475ARFLAGS = -crs
476endif
477endif
465478
479
466480#-------------------------------------------------
467481# linking flags
468482#-------------------------------------------------
r7500r7501
552566ZLIB =
553567endif
554568
569# add SoftFloat floating point emulation library
570SOFTFLOAT = $(OBJ)/libsoftfloat.a
555571
556
557572#-------------------------------------------------
558573# 'default' target needs to go here, before the
559574# include files which define additional targets
r7500r7501
642657ifndef EXECUTABLE_DEFINED
643658
644659# always recompile the version string
645$(VERSIONOBJ): $(DRVLIBS) $(LIBOSD) $(LIBEMU) $(LIBCPU) $(LIBSOUND) $(LIBUTIL) $(EXPAT) $(ZLIB) $(LIBOCORE) $(RESFILE)
660$(VERSIONOBJ): $(DRVLIBS) $(LIBOSD) $(LIBEMU) $(LIBCPU) $(LIBSOUND) $(LIBUTIL) $(EXPAT) $(ZLIB) $(SOFTFLOAT) $(LIBOCORE) $(RESFILE)
646661
647$(EMULATOR): $(VERSIONOBJ) $(DRVLIBS) $(LIBOSD) $(LIBEMU) $(LIBCPU) $(LIBDASM) $(LIBSOUND) $(LIBUTIL) $(EXPAT) $(ZLIB) $(LIBOCORE) $(RESFILE)
662$(EMULATOR): $(VERSIONOBJ) $(DRVLIBS) $(LIBOSD) $(LIBEMU) $(LIBCPU) $(LIBDASM) $(LIBSOUND) $(LIBUTIL) $(EXPAT) $(SOFTFLOAT) $(ZLIB) $(LIBOCORE) $(RESFILE)
648663   @echo Linking $@...
649664   $(LD) $(LDFLAGS) $(LDFLAGSEMULATOR) $^ $(LIBS) -o $@
650665
r7500r7501
680695$(OBJ)/%.a:
681696   @echo Archiving $@...
682697   $(RM) $@
683   $(AR) -cr $@ $^
698   $(AR) $(ARFLAGS) $@ $^
684699
685700ifeq ($(TARGETOS),macosx)
686701$(OBJ)/%.o: $(SRC)/%.m | $(OSPREBUILD)

Previous 15994 Revisions Next


© 1998-2018 The MESS Team